* ====================== */
var Modal = function ( content, options ) {
- this.options = $.extend({}, $.fn.modal.defaults, options)
+ this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
}
return this.each(function () {
var $this = $(this)
, 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 (typeof option == 'string') data[option]()
- else data.show()
+ else if (options.show) data.show()
})
}
$.fn.modal.defaults = {
backdrop: true
, keyboard: true
+ , show: true
}
$.fn.modal.Constructor = Modal
<td>true</td>
<td>Closes the modal when escape key is pressed</td>
</tr>
+ <tr>
+ <td>show</td>
+ <td>boolean</td>
+ <td>true</td>
+ <td>Shows the modal when initialized.</td>
+ </tr>
</tbody>
</table>
<h3>Markup</h3>
<td>{{_i}}true{{/i}}</td>
<td>{{_i}}Closes the modal when escape key is pressed{{/i}}</td>
</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>
</table>
<h3>{{_i}}Markup{{/i}}</h3>
* ====================== */
var Modal = function ( content, options ) {
- this.options = $.extend({}, $.fn.modal.defaults, options)
+ this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
}
return this.each(function () {
var $this = $(this)
, 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 (typeof option == 'string') data[option]()
- else data.show()
+ else if (options.show) data.show()
})
}
$.fn.modal.defaults = {
backdrop: true
, keyboard: true
+ , show: true
}
$.fn.modal.Constructor = Modal
test("should fade element out on clicking .close", function () {
var alertHTML = '<div class="alert-message warning fade in">'
+ '<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>'
, alert = $(alertHTML).alert()
var alertHTML = '<div class="alert-message warning fade in">'
+ '<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>'
, alert = $(alertHTML).appendTo('#qunit-fixture').alert()