From 48aa209348c47df65f4edb0d8a36ccaac357eb0a Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 10 Sep 2011 12:49:21 -0700 Subject: [PATCH 1/2] more tests, more js goodness --- docs/index.html | 2 +- docs/javascript.html | 8 +-- js/bootstrap-modal.js | 30 +++++------ js/bootstrap-popover.js | 1 + js/bootstrap-twipsy.js | 4 ++ js/tests/unit/bootstrap-modal.js | 52 +++++++++++++------ js/tests/unit/bootstrap-popover.js | 13 +++++ js/tests/unit/bootstrap-tabs.js | 49 ++++++++++++++++++ js/tests/unit/bootstrap-twipsy.js | 81 ++++++++++++++++++++++++++++++ 9 files changed, 206 insertions(+), 34 deletions(-) diff --git a/docs/index.html b/docs/index.html index ab66d968ce..d8febe0a4b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,7 +21,7 @@ - + diff --git a/docs/javascript.html b/docs/javascript.html index 7d1c6d6ca4..8a4636bb3d 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -89,12 +89,12 @@ $('#modal-content').modal({

modal:toggle

Toggle the modal open state.

$('#modal-content').trigger('modal:toggle')
-

modal:open

+

modal:show

Opens the modal.

-
$('#modal-content').trigger('modal:open')
-

modal:close

+
$('#modal-content').trigger('modal:show')
+

modal:hide

Closes the modal.

-
$('#modal-content').trigger('modal:close')
+
$('#modal-content').trigger('modal:hide')

Demo

diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 4b4f05ae36..54cbad4b11 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -40,10 +40,10 @@ } this.$element = $(content) - .bind('modal:open', $.proxy(this.open, this)) - .bind('modal:close', $.proxy(this.close, this)) + .bind('modal:show', $.proxy(this.show, this)) + .bind('modal:hide', $.proxy(this.hide, this)) .bind('modal:toggle', $.proxy(this.toggle, this)) - .delegate('.close', 'click', $.proxy(this.close, this)) + .delegate('.close', 'click', $.proxy(this.hide, this)) return this } @@ -51,12 +51,12 @@ Modal.prototype = { toggle: function () { - return this[!this.isOpen ? 'open' : 'close']() + return this[!this.isShown ? 'show' : 'hide']() } - , open: function () { + , show: function () { var that = this - this.isOpen = true + this.isShown = true _.escape.call(this) _.backdrop.call(this) @@ -73,12 +73,12 @@ return this } - , close: function (e) { + , hide: function (e) { e && e.preventDefault() var that = this - this.isOpen = false + this.isShown = false _.escape.call(this) _.backdrop.call(this) @@ -108,11 +108,11 @@ backdrop: function () { var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' - if ( this.isOpen && this.settings.backdrop ) { + if ( this.isShown && this.settings.backdrop ) { this.$backdrop = $('