Skip to content

Commit

Permalink
Update backbone.bootstrap-modal adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
powmedia committed Sep 6, 2012
1 parent 461c3c7 commit 565e696
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ Writing a custom editor is simple. They must extend from Backbone.Form.editors.B


###0.10.0
- Update backbone.bootstrap-modal adapter
- Refactor rendering.
- <legend> tags are now defined in the template.
- Where a template is used, (e.g. advanced editors, field etc.), the entirety of the HTML is now defined in the template to make custom templating easier.
Expand Down
35 changes: 27 additions & 8 deletions distribution/adapters/backbone.bootstrap-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<h3>{{title}}</h3>\
</div>\
<% } %>\
<div class="modal-body"><p>{{content}}</p></div>\
<div class="modal-body">{{content}}</div>\
<div class="modal-footer">\
<% if (allowCancel) { %>\
<% if (cancelText) { %>\
Expand All @@ -54,13 +54,11 @@
event.preventDefault();

this.trigger('cancel');
this.close();
},
'click .cancel': function(event) {
event.preventDefault();

this.trigger('cancel');
this.close();
},
'click .ok': function(event) {
event.preventDefault();
Expand Down Expand Up @@ -110,11 +108,11 @@
//Create the modal container
$el.html(options.template(options));

var $content = this.$content = $el.find('.modal-body p')
var $content = this.$content = $el.find('.modal-body')

//Insert the main content if it's a view
if (content.$el) {
$el.find('.modal-body p').html(content.render().$el);
$el.find('.modal-body').html(content.render().$el);
}

if (options.animate) $el.addClass('fade');
Expand All @@ -126,8 +124,10 @@

/**
* Renders and shows the modal
*
* @param {Function} [cb] Optional callback that runs only when OK is pressed.
*/
open: function() {
open: function(cb) {
if (!this.isRendered) this.render();

var self = this,
Expand Down Expand Up @@ -155,7 +155,26 @@
$backdrop.css('z-index', backdropIndex + numModals);
this.$el.css('z-index', elIndex + numModals);

if (this.options.allowCancel) {
$backdrop.one('click', function() {
self.trigger('cancel');
});

$(document).one('keyup.dismiss.modal', function (e) {
e.which == 27 && self.trigger('cancel');
});
}

this.on('cancel', function() {
self.close();
});

Modal.count++;

//Run callback on OK if provided
if (cb) {
self.on('ok', cb);
}

return this;
},
Expand Down Expand Up @@ -201,14 +220,14 @@

//EXPORTS
//CommonJS
if (typeof require == 'function' && module && exports) {
if (typeof require == 'function' && typeof module !== 'undefined' && exports) {
module.exports = Modal;
}

//AMD / RequireJS
if (typeof define === 'function' && define.amd) {
return define(function() {
return Modal;
Backbone.BootstrapModal = Modal;
})
}

Expand Down
2 changes: 1 addition & 1 deletion distribution/adapters/backbone.bootstrap-modal.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/backbone.bootstrap-modal
2 changes: 1 addition & 1 deletion node_modules/buildify
Submodule buildify updated 4 files
+49 −3 README.md
+45 −1 index.js
+3 −2 package.json
+52 −7 test/index.test.js

0 comments on commit 565e696

Please sign in to comment.