Skip to content

Commit

Permalink
add jshint support + a few minor stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
fat committed Apr 14, 2012
1 parent 8575a45 commit 575f18a
Show file tree
Hide file tree
Showing 29 changed files with 303 additions and 259 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ bootstrap:
lessc --yui-compress ${BOOTSTRAP_LESS} > bootstrap/css/bootstrap.min.css
lessc ${BOOTSTRAP_RESPONSIVE_LESS} > bootstrap/css/bootstrap-responsive.css
lessc --yui-compress ${BOOTSTRAP_RESPONSIVE_LESS} > bootstrap/css/bootstrap-responsive.min.css
jshint js/*.js --config js/.jshintrc
jshint js/tests/unit/*.js --config js/.jshintrc
cat js/bootstrap-transition.js js/bootstrap-alert.js js/bootstrap-button.js js/bootstrap-carousel.js js/bootstrap-collapse.js js/bootstrap-dropdown.js js/bootstrap-modal.js js/bootstrap-tooltip.js js/bootstrap-popover.js js/bootstrap-scrollspy.js js/bootstrap-tab.js js/bootstrap-typeahead.js > bootstrap/js/bootstrap.js
uglifyjs -nc bootstrap/js/bootstrap.js > bootstrap/js/bootstrap.min.tmp.js
echo "/**\n* Bootstrap.js by @fat & @mdo\n* Copyright 2012 Twitter, Inc.\n* http://www.apache.org/licenses/LICENSE-2.0.txt\n*/" > bootstrap/js/copyright.js
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ Developers

We have included a makefile with convenience methods for working with the Bootstrap library.

+ **dependencies**
Our makefile depends on you having less, uglify.js, and jshint installed. To install, just run the following command in npm:

```
$ npm install less uglify-js jshint -g
```

+ **build** - `make`
Runs the LESS compiler to rebuild the `/less` files and compiles the docs pages. Requires lessc and uglify-js. <a href="http://twitter.github.com/bootstrap/less.html#compiling">Read more in our docs &raquo;</a>

Expand Down
Binary file modified docs/assets/bootstrap.zip
Binary file not shown.
55 changes: 25 additions & 30 deletions docs/assets/js/bootstrap-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
* ========================================================== */


!function ( $ ) {
!function ($) {

"use strict"; // jshint ;_;

"use strict"

/* ALERT CLASS DEFINITION
* ====================== */
Expand All @@ -30,43 +31,37 @@
$(el).on('click', dismiss, this.close)
}

Alert.prototype = {

constructor: Alert

, close: function ( e ) {
var $this = $(this)
, selector = $this.attr('data-target')
, $parent

if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
Alert.prototype.close = function (e) {
var $this = $(this)
, selector = $this.attr('data-target')
, $parent

$parent = $(selector)
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}

e && e.preventDefault()
$parent = $(selector)

$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
e && e.preventDefault()

$parent.trigger(e = $.Event('close'))
$parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())

if (e.isDefaultPrevented()) return
$parent.trigger(e = $.Event('close'))

$parent.removeClass('in')
if (e.isDefaultPrevented()) return

function removeElement() {
$parent
.trigger('closed')
.remove()
}
$parent.removeClass('in')

$.support.transition && $parent.hasClass('fade') ?
$parent.on($.support.transition.end, removeElement) :
removeElement()
function removeElement() {
$parent
.trigger('closed')
.remove()
}

$.support.transition && $parent.hasClass('fade') ?
$parent.on($.support.transition.end, removeElement) :
removeElement()
}


Expand All @@ -92,4 +87,4 @@
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})

}( window.jQuery );
}(window.jQuery);
59 changes: 27 additions & 32 deletions docs/assets/js/bootstrap-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,53 @@
* ============================================================ */


!function ( $ ) {
!function ($) {

"use strict"; // jshint ;_;

"use strict"

/* BUTTON PUBLIC CLASS DEFINITION
* ============================== */

var Button = function ( element, options ) {
var Button = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.button.defaults, options)
}

Button.prototype = {

constructor: Button

, setState: function ( state ) {
var d = 'disabled'
, $el = this.$element
, data = $el.data()
, val = $el.is('input') ? 'val' : 'html'
Button.prototype.setState = function (state) {
var d = 'disabled'
, $el = this.$element
, data = $el.data()
, val = $el.is('input') ? 'val' : 'html'

state = state + 'Text'
data.resetText || $el.data('resetText', $el[val]())
state = state + 'Text'
data.resetText || $el.data('resetText', $el[val]())

$el[val](data[state] || this.options[state])
$el[val](data[state] || this.options[state])

// push to event loop to allow forms to submit
setTimeout(function () {
state == 'loadingText' ?
$el.addClass(d).attr(d, d) :
$el.removeClass(d).removeAttr(d)
}, 0)
}

, toggle: function () {
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
// push to event loop to allow forms to submit
setTimeout(function () {
state == 'loadingText' ?
$el.addClass(d).attr(d, d) :
$el.removeClass(d).removeAttr(d)
}, 0)
}

$parent && $parent
.find('.active')
.removeClass('active')
Button.prototype.toggle = function () {
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')

this.$element.toggleClass('active')
}
$parent && $parent
.find('.active')
.removeClass('active')

this.$element.toggleClass('active')
}


/* BUTTON PLUGIN DEFINITION
* ======================== */

$.fn.button = function ( option ) {
$.fn.button = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('button')
Expand Down Expand Up @@ -98,4 +93,4 @@
})
})

}( window.jQuery );
}(window.jQuery);
9 changes: 5 additions & 4 deletions docs/assets/js/bootstrap-carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
* ========================================================== */


!function ( $ ) {
!function ($) {

"use strict"; // jshint ;_;

"use strict"

/* CAROUSEL CLASS DEFINITION
* ========================= */
Expand Down Expand Up @@ -129,7 +130,7 @@
/* CAROUSEL PLUGIN DEFINITION
* ========================== */

$.fn.carousel = function ( option ) {
$.fn.carousel = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('carousel')
Expand Down Expand Up @@ -162,4 +163,4 @@
})
})

}( window.jQuery );
}(window.jQuery);
34 changes: 19 additions & 15 deletions docs/assets/js/bootstrap-collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@
* ============================================================ */


!function ( $ ) {
!function ($) {

"use strict"
"use strict"; // jshint ;_;

var Collapse = function ( element, options ) {
this.$element = $(element)

/* COLLAPSE PUBLIC CLASS DEFINITION
* ================================ */

var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.collapse.defaults, options)

if (this.options["parent"]) {
this.$parent = $(this.options["parent"])
if (this.options.parent) {
this.$parent = $(this.options.parent)
}

this.options.toggle && this.toggle()
Expand All @@ -53,7 +57,6 @@
dimension = this.dimension()
scroll = $.camelCase(['scroll', dimension].join('-'))
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
hasData

if (actives && actives.length) {
hasData = actives.data('collapse')
Expand All @@ -75,20 +78,20 @@
this.$element[dimension](0)
}

, reset: function ( size ) {
, reset: function (size) {
var dimension = this.dimension()

this.$element
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth

this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')

return this
}

, transition: function ( method, startEvent, completeEvent ) {
, transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
if (startEvent == 'show') that.reset()
Expand All @@ -107,18 +110,19 @@
$.support.transition && this.$element.hasClass('collapse') ?
this.$element.one($.support.transition.end, complete) :
complete()
}
}

, toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}

}

/* COLLAPSIBLE PLUGIN DEFINITION

/* COLLAPSIBLE PLUGIN DEFINITION
* ============================== */

$.fn.collapse = function ( option ) {
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
Expand Down Expand Up @@ -149,4 +153,4 @@
})
})

}( window.jQuery );
}(window.jQuery);
16 changes: 9 additions & 7 deletions docs/assets/js/bootstrap-dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
* ============================================================ */


!function ( $ ) {
!function ($) {

"use strict"; // jshint ;_;

"use strict"

/* DROPDOWN CLASS DEFINITION
* ========================= */

var toggle = '[data-toggle="dropdown"]'
, Dropdown = function ( element ) {
, Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () {
$el.parent().removeClass('open')
Expand All @@ -37,7 +38,7 @@

constructor: Dropdown

, toggle: function ( e ) {
, toggle: function (e) {
var $this = $(this)
, selector = $this.attr('data-target')
, $parent
Expand All @@ -54,7 +55,8 @@
isActive = $parent.hasClass('open')

clearMenus()
!isActive && $parent.toggleClass('open')

if (!isActive) $parent.toggleClass('open')

return false
}
Expand All @@ -69,7 +71,7 @@
/* DROPDOWN PLUGIN DEFINITION
* ========================== */

$.fn.dropdown = function ( option ) {
$.fn.dropdown = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('dropdown')
Expand All @@ -91,4 +93,4 @@
.on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
})

}( window.jQuery );
}(window.jQuery);
Loading

0 comments on commit 575f18a

Please sign in to comment.