0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-06 04:08:22 +01:00

Merge branch 'raphaelz-patch-1' into 2.0.1-wip

Conflicts:
	docs/assets/bootstrap.zip
This commit is contained in:
Mark Otto 2012-02-06 23:36:31 -08:00
commit 4ed1b13719
7 changed files with 24 additions and 10 deletions

Binary file not shown.

View File

@ -26,7 +26,7 @@
* ====================== */ * ====================== */
var Modal = function ( content, options ) { var Modal = function ( content, options ) {
this.options = $.extend({}, $.fn.modal.defaults, options) this.options = options
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
} }
@ -177,16 +177,17 @@
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('modal') , data = $this.data('modal')
, options = typeof option == 'object' && option , options = $.extend({}, $.fn.modal.defaults, typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options))) if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
else data.show() else if (options.show) data.show()
}) })
} }
$.fn.modal.defaults = { $.fn.modal.defaults = {
backdrop: true backdrop: true
, keyboard: true , keyboard: true
, show: true
} }
$.fn.modal.Constructor = Modal $.fn.modal.Constructor = Modal

View File

@ -273,6 +273,12 @@
<td>true</td> <td>true</td>
<td>Closes the modal when escape key is pressed</td> <td>Closes the modal when escape key is pressed</td>
</tr> </tr>
<tr>
<td>show</td>
<td>boolean</td>
<td>true</td>
<td>Shows the modal when initialized.</td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>Markup</h3> <h3>Markup</h3>

View File

@ -197,6 +197,12 @@
<td>{{_i}}true{{/i}}</td> <td>{{_i}}true{{/i}}</td>
<td>{{_i}}Closes the modal when escape key is pressed{{/i}}</td> <td>{{_i}}Closes the modal when escape key is pressed{{/i}}</td>
</tr> </tr>
<tr>
<td>{{_i}}show{{/i}}</td>
<td>{{_i}}boolean{{/i}}</td>
<td>{{_i}}true{{/i}}</td>
<td>{{_i}}Shows the modal when initialized.{{/i}}</td>
</tr>
</tbody> </tbody>
</table> </table>
<h3>{{_i}}Markup{{/i}}</h3> <h3>{{_i}}Markup{{/i}}</h3>

View File

@ -37,7 +37,7 @@ All methods should accept an optional options object, a string which targets a p
Options should be sparse and add universal value. We should pick the right defaults. Options should be sparse and add universal value. We should pick the right defaults.
All plugins should have a default object which can be modified to effect all instance's default options. The defaults object should be available via `$.fn.plugin.defaults`. All plugins should have a default object which can be modified to affect all instances' default options. The defaults object should be available via `$.fn.plugin.defaults`.
$.fn.modal.defaults = { … } $.fn.modal.defaults = { … }
@ -64,7 +64,7 @@ All events should have an infinitive and past participle form. The infinitive is
### CONSTRUCTORS ### CONSTRUCTORS
Each plugin should expose it's raw constructor on a `Constructor` property -- accessed in the following way: Each plugin should expose its raw constructor on a `Constructor` property -- accessed in the following way:
$.fn.popover.Constructor $.fn.popover.Constructor

View File

@ -26,7 +26,7 @@
* ====================== */ * ====================== */
var Modal = function ( content, options ) { var Modal = function ( content, options ) {
this.options = $.extend({}, $.fn.modal.defaults, options) this.options = options
this.$element = $(content) this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
} }
@ -177,16 +177,17 @@
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('modal') , data = $this.data('modal')
, options = typeof option == 'object' && option , options = $.extend({}, $.fn.modal.defaults, typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options))) if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
else data.show() else if (options.show) data.show()
}) })
} }
$.fn.modal.defaults = { $.fn.modal.defaults = {
backdrop: true backdrop: true
, keyboard: true , keyboard: true
, show: true
} }
$.fn.modal.Constructor = Modal $.fn.modal.Constructor = Modal

View File

@ -13,7 +13,7 @@ $(function () {
test("should fade element out on clicking .close", function () { test("should fade element out on clicking .close", function () {
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert-message warning fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
+ '</div>' + '</div>'
, alert = $(alertHTML).alert() , alert = $(alertHTML).alert()
@ -27,7 +27,7 @@ $(function () {
var alertHTML = '<div class="alert-message warning fade in">' var alertHTML = '<div class="alert-message warning fade in">'
+ '<a class="close" href="#" data-dismiss="alert">×</a>' + '<a class="close" href="#" data-dismiss="alert">×</a>'
+ '<p><strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.</p>' + '<p><strong>Holy guacamole!</strong> Best check yo self, you\'re not looking too good.</p>'
+ '</div>' + '</div>'
, alert = $(alertHTML).appendTo('#qunit-fixture').alert() , alert = $(alertHTML).appendTo('#qunit-fixture').alert()