backbone.modal
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,1 +0,1 @@ | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};!function(a,b){return"function"==typeof define&&define.amd?define(["exports","underscore","backbone","backbone.marionette"],b):"object"==typeof exports?b(exports,require("underscore"),require("backbone"),require("backbone.marionette")):a.Backbone.Marionette.Modals=b(a.commonJsStrict={},a._,a.Backbone,a.Backbone.Marionette)}(this,function(b,d,e,f){var g;return g=function(b){function e(){return this.destroy=a(this.destroy,this),e.__super__.constructor.apply(this,arguments)}return c(e,b),e.prototype.modals=[],e.prototype.zIndex=0,e.prototype.show=function(a,b){var c,e,g,h,i,j,k,l,m;if(null==b&&(b={}),this._ensureElement(),this.modals.length>0&&(c=d.last(this.modals),c.modalEl.addClass(""+c.prefix+"-view--stacked"),g=this.modals[this.modals.length-1],null!=g&&g.modalEl.removeClass(""+g.prefix+"-modal--stacked-reverse")),a.render(),a.regionEnabled=!0,this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),f.triggerMethodOn(a,"before:show"),this.triggerMethod("swapOut",this.currentView),this.$el.append(a.el),this.currentView=a,this.triggerMethod("swap",a),this.triggerMethod("show",a),f.triggerMethodOn(a,"show"),this.modals.length>0)for(l=this.modals,h=0,j=l.length;j>h;h++)e=l[h],e.$el.css({background:"none"});for(m=this.modals,i=0,k=m.length;k>i;i++)e=m[i],e.undelegateModalEvents();return a.on("modal:destroy",this.destroy),this.modals.push(a),this.zIndex++},e.prototype.destroy=function(){var a,b;return(b=this.currentView)?(b.destroy&&!b.isDestroyed?b.destroy():b.remove&&b.remove(),b.off("modal:destroy",this.destroy),this.modals.splice(d.indexOf(this.modals,b),1),this.zIndex--,this.currentView=this.modals[this.zIndex-1],a=d.last(this.modals),a&&(a.$el.removeAttr("style"),a.modalEl.addClass(""+a.prefix+"-modal--stacked-reverse"),d.delay(function(){return function(){return a.modalEl.removeClass(""+a.prefix+"-modal--stacked")}}(this),300),0!==this.zIndex)?a.delegateModalEvents():void 0):void 0},e.prototype.destroyAll=function(){var a,b,c,d,e;for(d=this.modals,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.destroy());return e},e}(f.Region)})}).call(this); | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};!function(a){return"function"==typeof define&&define.amd?define(["underscore","backbone","backbone.marionette","exports"],a):"object"==typeof exports?a(require("underscore"),require("backbone"),require("backbone.marionette"),exports):a(_,Backbone,Backbone.Marionette,{})}(function(b,d,e,f){return f=function(d){function f(){return this.destroy=a(this.destroy,this),f.__super__.constructor.apply(this,arguments)}return c(f,d),f.prototype.modals=[],f.prototype.zIndex=0,f.prototype.show=function(a,c){var d,f,g,h,i,j,k,l,m;if(null==c&&(c={}),this._ensureElement(),this.modals.length>0&&(d=b.last(this.modals),d.modalEl.addClass(""+d.prefix+"-view--stacked"),g=this.modals[this.modals.length-1],null!=g&&g.modalEl.removeClass(""+g.prefix+"-modal--stacked-reverse")),a.render(),a.regionEnabled=!0,this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),e.triggerMethodOn(a,"before:show"),this.triggerMethod("swapOut",this.currentView),this.$el.append(a.el),this.currentView=a,this.triggerMethod("swap",a),this.triggerMethod("show",a),e.triggerMethodOn(a,"show"),this.modals.length>0)for(l=this.modals,h=0,j=l.length;j>h;h++)f=l[h],f.$el.css({background:"none"});for(m=this.modals,i=0,k=m.length;k>i;i++)f=m[i],f.undelegateModalEvents();return a.on("modal:destroy",this.destroy),this.modals.push(a),this.zIndex++},f.prototype.destroy=function(){var a,c;return(c=this.currentView)?(c.destroy&&!c.isDestroyed?c.destroy():c.remove&&c.remove(),c.off("modal:destroy",this.destroy),this.modals.splice(b.indexOf(this.modals,c),1),this.zIndex--,this.currentView=this.modals[this.zIndex-1],a=b.last(this.modals),a&&(a.$el.removeAttr("style"),a.modalEl.addClass(""+a.prefix+"-modal--stacked-reverse"),b.delay(function(){return function(){return a.modalEl.removeClass(""+a.prefix+"-modal--stacked")}}(this),300),0!==this.zIndex)?a.delegateModalEvents():void 0):void 0},f.prototype.destroyAll=function(){var a,b,c,d,e;for(d=this.modals,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.destroy());return e},f}(e.Region),e.Modals=f,e.Modals})}).call(this); |
@@ -6,13 +6,12 @@ (function() { | ||
(function(root, factory) { | ||
(function(factory) { | ||
if (typeof define === "function" && define.amd) { | ||
return define(["exports", "underscore", "backbone", "backbone.marionette"], factory); | ||
return define(["underscore", "backbone", "backbone.marionette", "exports"], factory); | ||
} else if (typeof exports === "object") { | ||
return factory(exports, require("underscore"), require("backbone"), require("backbone.marionette")); | ||
return factory(require("underscore"), require("backbone"), require("backbone.marionette"), exports); | ||
} else { | ||
return root.Backbone.Marionette.Modals = factory((root.commonJsStrict = {}), root._, root.Backbone, root.Backbone.Marionette); | ||
return factory(_, Backbone, Backbone.Marionette, {}); | ||
} | ||
})(this, function(exports, _, Backbone, Marionette) { | ||
var Modals; | ||
return Modals = (function(_super) { | ||
})(function(_, Backbone, Marionette, Modals) { | ||
Modals = (function(_super) { | ||
__extends(Modals, _super); | ||
@@ -117,4 +116,6 @@ | ||
})(Marionette.Region); | ||
Marionette.Modals = Modals; | ||
return Marionette.Modals; | ||
}); | ||
}).call(this); |
@@ -1,1 +0,1 @@ | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a,b){return"function"==typeof define&&define.amd?define(["exports","underscore","backbone"],b):"object"==typeof exports?b(exports,require("underscore"),require("backbone")):a.Backbone.Modal=b(a.commonJsStrict={},a._,a.Backbone)}(this,function(b,e,f){var g;return g=function(b){function g(){this.triggerCancel=a(this.triggerCancel,this),this.triggerSubmit=a(this.triggerSubmit,this),this.triggerView=a(this.triggerView,this),this.clickOutside=a(this.clickOutside,this),this.checkKey=a(this.checkKey,this),this.rendererCompleted=a(this.rendererCompleted,this),this.args=Array.prototype.slice.apply(arguments),f.View.prototype.constructor.apply(this,this.args),this.setUIElements()}return c(g,b),g.prototype.prefix="bbm",g.prototype.animate=!0,g.prototype.keyControl=!0,g.prototype.render=function(a){var b,c,d;return c=this.serializeData(),this.$el.addClass(""+this.prefix+"-wrapper"),this.modalEl=f.$("<div />").addClass(""+this.prefix+"-modal"),this.template&&this.modalEl.html(this.template(c)),this.$el.html(this.modalEl),this.viewContainer?(this.viewContainerEl=this.modalEl.find(this.viewContainer),this.viewContainerEl.addClass(""+this.prefix+"-modal__views")):this.viewContainerEl=this.modalEl,$(":focus").blur(),(null!=(d=this.views)?d.length:void 0)>0&&this.openAt(a||0),"function"==typeof this.onRender&&this.onRender(),this.delegateModalEvents(),b=this.getOption("animate"),this.$el.fadeIn&&b?(this.modalEl.css({opacity:0}),this.$el.fadeIn({duration:100,complete:this.rendererCompleted})):(this.$el.show(),this.rendererCompleted()),this},g.prototype.rendererCompleted=function(){var a;return this.keyControl&&(f.$("body").on("keyup",this.checkKey),f.$("body").on("click",this.clickOutside)),this.modalEl.css({opacity:1}).addClass(""+this.prefix+"-modal--open"),"function"==typeof this.onShow&&this.onShow(),null!=(a=this.currentView)&&"function"==typeof a.onShow?a.onShow():void 0},g.prototype.setUIElements=function(){var a;if(this.template=this.getOption("template"),this.views=this.getOption("views"),null!=(a=this.views)&&(a.length=e.size(this.views)),this.viewContainer=this.getOption("viewContainer"),this.$el.hide(),e.isUndefined(this.template)&&e.isUndefined(this.views))throw new Error("No template or views defined for Backbone.Modal");if(this.template&&this.views&&e.isUndefined(this.viewContainer))throw new Error("No viewContainer defined for Backbone.Modal")},g.prototype.getOption=function(a){return a?this.options&&d.call(this.options,a)>=0&&null!=this.options[a]?this.options[a]:this[a]:void 0},g.prototype.serializeData=function(){var a;return a={},this.model&&(a=e.extend(a,this.model.toJSON())),this.collection&&(a=e.extend(a,{items:this.collection.toJSON()})),a},g.prototype.delegateModalEvents=function(){var a,b,c,d,f,g,h;this.active=!0,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.on("click",f,this.triggerSubmit),a&&this.$el.on("click",a,this.triggerCancel),h=[];for(b in this.views)e.isString(b)&&"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),g=c[1],d=c[2],h.push(this.$el.on(g,d,this.views[b],this.triggerView))):h.push(void 0);return h},g.prototype.undelegateModalEvents=function(){var a,b,c,d,f,g,h;this.active=!1,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.off("click",f,this.triggerSubmit),a&&this.$el.off("click",a,this.triggerCancel),h=[];for(b in this.views)e.isString(b)&&"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),g=c[1],d=c[2],h.push(this.$el.off(g,d,this.views[b],this.triggerView))):h.push(void 0);return h},g.prototype.checkKey=function(a){if(this.active)switch(a.keyCode){case 27:return this.triggerCancel(a);case 13:return this.triggerSubmit(a)}},g.prototype.clickOutside=function(a){return f.$(a.target).hasClass(""+this.prefix+"-wrapper")&&this.active?this.triggerCancel():void 0},g.prototype.buildView=function(a,b){var c;if(a)return b&&e.isFunction(b)&&(b=b()),e.isFunction(a)?(c=new a(b||this.args[0]),c instanceof f.View?{el:c.render().$el,view:c}:{el:a(b||this.args[0])}):{view:a,el:a.$el}},g.prototype.triggerView=function(a){var b,c,d,f,g,h,i;if(null!=a&&"function"==typeof a.preventDefault&&a.preventDefault(),f=a.data,c=this.buildView(f.view,f.viewOptions),this.currentView&&(this.previousView=this.currentView,!(null!=(i=f.openOptions)?i.skipSubmit:void 0))){if(("function"==typeof(g=this.previousView).beforeSubmit?g.beforeSubmit():void 0)===!1)return;"function"==typeof(h=this.previousView).submit&&h.submit()}this.currentView=c.view||c.el,b=0;for(d in this.views)f.view===this.views[d].view&&(this.currentIndex=b),b++;return f.onActive&&(e.isFunction(f.onActive)?f.onActive(this):e.isString(f.onActive)&&this[f.onActive].call(this,f)),this.shouldAnimate?this.animateToView(c.el):(this.shouldAnimate=!0,this.$(this.viewContainerEl).html(c.el))},g.prototype.animateToView=function(a){var b,c,d,e,g,h,i;return e={position:"relative",top:-9999,left:-9999},g=f.$("<tester/>").css(e),g.html(this.$el.clone().css(e)),0!==f.$("tester").length?f.$("tester").replaceWith(g):f.$("body").append(g),b=g.find(this.viewContainer?this.viewContainer:"."+this.prefix+"-modal"),b.removeAttr("style"),d=b.outerHeight(),b.html(a),c=b.outerHeight(),d===c?(this.$(this.viewContainerEl).html(a),"function"==typeof(h=this.currentView).onShow&&h.onShow(),null!=(i=this.previousView)&&"function"==typeof i.destroy?i.destroy():void 0):(this.$(this.viewContainerEl).css({opacity:0}),this.$(this.viewContainerEl).animate({height:c},100,function(b){return function(){var c,d;return b.$(b.viewContainerEl).css({opacity:1}).removeAttr("style"),b.$(b.viewContainerEl).html(a),"function"==typeof(c=b.currentView).onShow&&c.onShow(),null!=(d=b.previousView)&&"function"==typeof d.destroy?d.destroy():void 0}}(this)))},g.prototype.triggerSubmit=function(a){var b,c;return null!=a&&a.preventDefault(),this.beforeSubmit&&this.beforeSubmit()===!1||this.currentView&&this.currentView.beforeSubmit&&this.currentView.beforeSubmit()===!1?void 0:this.submit||(null!=(b=this.currentView)?b.submit:void 0)||this.getOption("submitEl")?(null!=(c=this.currentView)&&"function"==typeof c.submit&&c.submit(),"function"==typeof this.submit&&this.submit(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy()):this.triggerCancel()},g.prototype.triggerCancel=function(a){return null!=a&&a.preventDefault(),this.beforeCancel&&this.beforeCancel()===!1?void 0:("function"==typeof this.cancel&&this.cancel(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy())},g.prototype.destroy=function(){var a,b;return f.$("body").off("keyup",this.checkKey),f.$("body").off("click",this.clickOutside),"function"==typeof this.onDestroy&&this.onDestroy(),this.shouldAnimate=!1,this.modalEl.addClass(""+this.prefix+"-modal--destroy"),b=function(a){return function(){var b;return null!=(b=a.currentView)&&"function"==typeof b.remove&&b.remove(),a.remove()}}(this),a=this.getOption("animate"),this.$el.fadeOut&&a?(this.$el.fadeOut({duration:200}),e.delay(function(){return b()},200)):b()},g.prototype.openAt=function(a){var b,c,d,f,g;e.isNumber(a)?b=a:e.isNumber(a._index)&&(b=a._index),d=0;for(f in this.views)if("length"!==f)if(e.isNumber(b))d===b&&(g=this.views[f]),d++;else if(e.isObject(a))for(c in this.views[f])a[c]===this.views[f][c]&&(g=this.views[f]);return g&&(this.currentIndex=e.indexOf(this.views,g),this.triggerView({data:e.extend(g,{openOptions:a})})),this},g.prototype.next=function(a){return null==a&&(a={}),this.currentIndex+1<this.views.length?this.openAt(e.extend(a,{_index:this.currentIndex+1})):void 0},g.prototype.previous=function(a){return null==a&&(a={}),this.currentIndex-1<this.views.length-1?this.openAt(e.extend(a,{_index:this.currentIndex-1})):void 0},g}(f.View)})}).call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};!function(a,b){return"function"==typeof define&&define.amd?define(["exports","underscore","backbone","backbone.marionette"],b):"object"==typeof exports?b(exports,require("underscore"),require("backbone"),require("backbone.marionette")):a.Backbone.Marionette.Modals=b(a.commonJsStrict={},a._,a.Backbone,a.Backbone.Marionette)}(this,function(b,d,e,f){var g;return g=function(b){function e(){return this.destroy=a(this.destroy,this),e.__super__.constructor.apply(this,arguments)}return c(e,b),e.prototype.modals=[],e.prototype.zIndex=0,e.prototype.show=function(a,b){var c,e,g,h,i,j,k,l,m;if(null==b&&(b={}),this._ensureElement(),this.modals.length>0&&(c=d.last(this.modals),c.modalEl.addClass(""+c.prefix+"-view--stacked"),g=this.modals[this.modals.length-1],null!=g&&g.modalEl.removeClass(""+g.prefix+"-modal--stacked-reverse")),a.render(),a.regionEnabled=!0,this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),f.triggerMethodOn(a,"before:show"),this.triggerMethod("swapOut",this.currentView),this.$el.append(a.el),this.currentView=a,this.triggerMethod("swap",a),this.triggerMethod("show",a),f.triggerMethodOn(a,"show"),this.modals.length>0)for(l=this.modals,h=0,j=l.length;j>h;h++)e=l[h],e.$el.css({background:"none"});for(m=this.modals,i=0,k=m.length;k>i;i++)e=m[i],e.undelegateModalEvents();return a.on("modal:destroy",this.destroy),this.modals.push(a),this.zIndex++},e.prototype.destroy=function(){var a,b;return(b=this.currentView)?(b.destroy&&!b.isDestroyed?b.destroy():b.remove&&b.remove(),b.off("modal:destroy",this.destroy),this.modals.splice(d.indexOf(this.modals,b),1),this.zIndex--,this.currentView=this.modals[this.zIndex-1],a=d.last(this.modals),a&&(a.$el.removeAttr("style"),a.modalEl.addClass(""+a.prefix+"-modal--stacked-reverse"),d.delay(function(){return function(){return a.modalEl.removeClass(""+a.prefix+"-modal--stacked")}}(this),300),0!==this.zIndex)?a.delegateModalEvents():void 0):void 0},e.prototype.destroyAll=function(){var a,b,c,d,e;for(d=this.modals,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.destroy());return e},e}(f.Region)})}.call(this); | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a){return"function"==typeof define&&define.amd?define(["underscore","backbone","exports"],a):"object"==typeof exports?a(require("underscore"),require("backbone"),exports):a(_,Backbone,{})}(function(b,e,f){return f=function(f){function g(){this.triggerCancel=a(this.triggerCancel,this),this.triggerSubmit=a(this.triggerSubmit,this),this.triggerView=a(this.triggerView,this),this.clickOutside=a(this.clickOutside,this),this.checkKey=a(this.checkKey,this),this.rendererCompleted=a(this.rendererCompleted,this),this.args=Array.prototype.slice.apply(arguments),e.View.prototype.constructor.apply(this,this.args),this.setUIElements()}return c(g,f),g.prototype.prefix="bbm",g.prototype.animate=!0,g.prototype.keyControl=!0,g.prototype.render=function(a){var b,c,d;return c=this.serializeData(),this.$el.addClass(""+this.prefix+"-wrapper"),this.modalEl=e.$("<div />").addClass(""+this.prefix+"-modal"),this.template&&this.modalEl.html(this.template(c)),this.$el.html(this.modalEl),this.viewContainer?(this.viewContainerEl=this.modalEl.find(this.viewContainer),this.viewContainerEl.addClass(""+this.prefix+"-modal__views")):this.viewContainerEl=this.modalEl,$(":focus").blur(),(null!=(d=this.views)?d.length:void 0)>0&&this.openAt(a||0),"function"==typeof this.onRender&&this.onRender(),this.delegateModalEvents(),b=this.getOption("animate"),this.$el.fadeIn&&b?(this.modalEl.css({opacity:0}),this.$el.fadeIn({duration:100,complete:this.rendererCompleted})):(this.$el.show(),this.rendererCompleted()),this},g.prototype.rendererCompleted=function(){var a;return this.keyControl&&(e.$("body").on("keyup",this.checkKey),e.$("body").on("click",this.clickOutside)),this.modalEl.css({opacity:1}).addClass(""+this.prefix+"-modal--open"),"function"==typeof this.onShow&&this.onShow(),null!=(a=this.currentView)&&"function"==typeof a.onShow?a.onShow():void 0},g.prototype.setUIElements=function(){var a;if(this.template=this.getOption("template"),this.views=this.getOption("views"),null!=(a=this.views)&&(a.length=b.size(this.views)),this.viewContainer=this.getOption("viewContainer"),this.$el.hide(),b.isUndefined(this.template)&&b.isUndefined(this.views))throw new Error("No template or views defined for Backbone.Modal");if(this.template&&this.views&&b.isUndefined(this.viewContainer))throw new Error("No viewContainer defined for Backbone.Modal")},g.prototype.getOption=function(a){return a?this.options&&d.call(this.options,a)>=0&&null!=this.options[a]?this.options[a]:this[a]:void 0},g.prototype.serializeData=function(){var a;return a={},this.model&&(a=b.extend(a,this.model.toJSON())),this.collection&&(a=b.extend(a,{items:this.collection.toJSON()})),a},g.prototype.delegateModalEvents=function(){var a,c,d,e,f,g,h;this.active=!0,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.on("click",f,this.triggerSubmit),a&&this.$el.on("click",a,this.triggerCancel),h=[];for(c in this.views)b.isString(c)&&"length"!==c?(d=c.match(/^(\S+)\s*(.*)$/),g=d[1],e=d[2],h.push(this.$el.on(g,e,this.views[c],this.triggerView))):h.push(void 0);return h},g.prototype.undelegateModalEvents=function(){var a,c,d,e,f,g,h;this.active=!1,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.off("click",f,this.triggerSubmit),a&&this.$el.off("click",a,this.triggerCancel),h=[];for(c in this.views)b.isString(c)&&"length"!==c?(d=c.match(/^(\S+)\s*(.*)$/),g=d[1],e=d[2],h.push(this.$el.off(g,e,this.views[c],this.triggerView))):h.push(void 0);return h},g.prototype.checkKey=function(a){if(this.active)switch(a.keyCode){case 27:return this.triggerCancel(a);case 13:return this.triggerSubmit(a)}},g.prototype.clickOutside=function(a){return e.$(a.target).hasClass(""+this.prefix+"-wrapper")&&this.active?this.triggerCancel():void 0},g.prototype.buildView=function(a,c){var d;if(a)return c&&b.isFunction(c)&&(c=c()),b.isFunction(a)?(d=new a(c||this.args[0]),d instanceof e.View?{el:d.render().$el,view:d}:{el:a(c||this.args[0])}):{view:a,el:a.$el}},g.prototype.triggerView=function(a){var c,d,e,f,g,h,i;if(null!=a&&"function"==typeof a.preventDefault&&a.preventDefault(),f=a.data,d=this.buildView(f.view,f.viewOptions),this.currentView&&(this.previousView=this.currentView,!(null!=(i=f.openOptions)?i.skipSubmit:void 0))){if(("function"==typeof(g=this.previousView).beforeSubmit?g.beforeSubmit():void 0)===!1)return;"function"==typeof(h=this.previousView).submit&&h.submit()}this.currentView=d.view||d.el,c=0;for(e in this.views)f.view===this.views[e].view&&(this.currentIndex=c),c++;return f.onActive&&(b.isFunction(f.onActive)?f.onActive(this):b.isString(f.onActive)&&this[f.onActive].call(this,f)),this.shouldAnimate?this.animateToView(d.el):(this.shouldAnimate=!0,this.$(this.viewContainerEl).html(d.el))},g.prototype.animateToView=function(a){var b,c,d,f,g,h,i;return f={position:"relative",top:-9999,left:-9999},g=e.$("<tester/>").css(f),g.html(this.$el.clone().css(f)),0!==e.$("tester").length?e.$("tester").replaceWith(g):e.$("body").append(g),b=g.find(this.viewContainer?this.viewContainer:"."+this.prefix+"-modal"),b.removeAttr("style"),d=b.outerHeight(),b.html(a),c=b.outerHeight(),d===c?(this.$(this.viewContainerEl).html(a),"function"==typeof(h=this.currentView).onShow&&h.onShow(),null!=(i=this.previousView)&&"function"==typeof i.destroy?i.destroy():void 0):(this.$(this.viewContainerEl).css({opacity:0}),this.$(this.viewContainerEl).animate({height:c},100,function(b){return function(){var c,d;return b.$(b.viewContainerEl).css({opacity:1}).removeAttr("style"),b.$(b.viewContainerEl).html(a),"function"==typeof(c=b.currentView).onShow&&c.onShow(),null!=(d=b.previousView)&&"function"==typeof d.destroy?d.destroy():void 0}}(this)))},g.prototype.triggerSubmit=function(a){var b,c;return null!=a&&a.preventDefault(),this.beforeSubmit&&this.beforeSubmit()===!1||this.currentView&&this.currentView.beforeSubmit&&this.currentView.beforeSubmit()===!1?void 0:this.submit||(null!=(b=this.currentView)?b.submit:void 0)||this.getOption("submitEl")?(null!=(c=this.currentView)&&"function"==typeof c.submit&&c.submit(),"function"==typeof this.submit&&this.submit(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy()):this.triggerCancel()},g.prototype.triggerCancel=function(a){return null!=a&&a.preventDefault(),this.beforeCancel&&this.beforeCancel()===!1?void 0:("function"==typeof this.cancel&&this.cancel(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy())},g.prototype.destroy=function(){var a,c;return e.$("body").off("keyup",this.checkKey),e.$("body").off("click",this.clickOutside),"function"==typeof this.onDestroy&&this.onDestroy(),this.shouldAnimate=!1,this.modalEl.addClass(""+this.prefix+"-modal--destroy"),c=function(a){return function(){var b;return null!=(b=a.currentView)&&"function"==typeof b.remove&&b.remove(),a.remove()}}(this),a=this.getOption("animate"),this.$el.fadeOut&&a?(this.$el.fadeOut({duration:200}),b.delay(function(){return c()},200)):c()},g.prototype.openAt=function(a){var c,d,e,f,g;b.isNumber(a)?c=a:b.isNumber(a._index)&&(c=a._index),e=0;for(f in this.views)if("length"!==f)if(b.isNumber(c))e===c&&(g=this.views[f]),e++;else if(b.isObject(a))for(d in this.views[f])a[d]===this.views[f][d]&&(g=this.views[f]);return g&&(this.currentIndex=b.indexOf(this.views,g),this.triggerView({data:b.extend(g,{openOptions:a})})),this},g.prototype.next=function(a){return null==a&&(a={}),this.currentIndex+1<this.views.length?this.openAt(b.extend(a,{_index:this.currentIndex+1})):void 0},g.prototype.previous=function(a){return null==a&&(a={}),this.currentIndex-1<this.views.length-1?this.openAt(b.extend(a,{_index:this.currentIndex-1})):void 0},g}(e.View),e.Modal=f,e.Modal})}).call(this),function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a};!function(a){return"function"==typeof define&&define.amd?define(["underscore","backbone","backbone.marionette","exports"],a):"object"==typeof exports?a(require("underscore"),require("backbone"),require("backbone.marionette"),exports):a(_,Backbone,Backbone.Marionette,{})}(function(b,d,e,f){return f=function(d){function f(){return this.destroy=a(this.destroy,this),f.__super__.constructor.apply(this,arguments)}return c(f,d),f.prototype.modals=[],f.prototype.zIndex=0,f.prototype.show=function(a,c){var d,f,g,h,i,j,k,l,m;if(null==c&&(c={}),this._ensureElement(),this.modals.length>0&&(d=b.last(this.modals),d.modalEl.addClass(""+d.prefix+"-view--stacked"),g=this.modals[this.modals.length-1],null!=g&&g.modalEl.removeClass(""+g.prefix+"-modal--stacked-reverse")),a.render(),a.regionEnabled=!0,this.triggerMethod("before:swap",a),this.triggerMethod("before:show",a),e.triggerMethodOn(a,"before:show"),this.triggerMethod("swapOut",this.currentView),this.$el.append(a.el),this.currentView=a,this.triggerMethod("swap",a),this.triggerMethod("show",a),e.triggerMethodOn(a,"show"),this.modals.length>0)for(l=this.modals,h=0,j=l.length;j>h;h++)f=l[h],f.$el.css({background:"none"});for(m=this.modals,i=0,k=m.length;k>i;i++)f=m[i],f.undelegateModalEvents();return a.on("modal:destroy",this.destroy),this.modals.push(a),this.zIndex++},f.prototype.destroy=function(){var a,c;return(c=this.currentView)?(c.destroy&&!c.isDestroyed?c.destroy():c.remove&&c.remove(),c.off("modal:destroy",this.destroy),this.modals.splice(b.indexOf(this.modals,c),1),this.zIndex--,this.currentView=this.modals[this.zIndex-1],a=b.last(this.modals),a&&(a.$el.removeAttr("style"),a.modalEl.addClass(""+a.prefix+"-modal--stacked-reverse"),b.delay(function(){return function(){return a.modalEl.removeClass(""+a.prefix+"-modal--stacked")}}(this),300),0!==this.zIndex)?a.delegateModalEvents():void 0):void 0},f.prototype.destroyAll=function(){var a,b,c,d,e;for(d=this.modals,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.destroy());return e},f}(e.Region),e.Modals=f,e.Modals})}.call(this); |
@@ -7,13 +7,12 @@ (function() { | ||
(function(root, factory) { | ||
(function(factory) { | ||
if (typeof define === "function" && define.amd) { | ||
return define(["exports", "underscore", "backbone"], factory); | ||
return define(["underscore", "backbone", "exports"], factory); | ||
} else if (typeof exports === "object") { | ||
return factory(exports, require("underscore"), require("backbone")); | ||
return factory(require("underscore"), require("backbone"), exports); | ||
} else { | ||
return root.Backbone.Modal = factory((root.commonJsStrict = {}), root._, root.Backbone); | ||
return factory(_, Backbone, {}); | ||
} | ||
})(this, function(exports, _, Backbone) { | ||
var Modal; | ||
return Modal = (function(_super) { | ||
})(function(_, Backbone, Modal) { | ||
Modal = (function(_super) { | ||
__extends(Modal, _super); | ||
@@ -468,2 +467,4 @@ | ||
})(Backbone.View); | ||
Backbone.Modal = Modal; | ||
return Backbone.Modal; | ||
}); | ||
@@ -478,13 +479,12 @@ | ||
(function(root, factory) { | ||
(function(factory) { | ||
if (typeof define === "function" && define.amd) { | ||
return define(["exports", "underscore", "backbone", "backbone.marionette"], factory); | ||
return define(["underscore", "backbone", "backbone.marionette", "exports"], factory); | ||
} else if (typeof exports === "object") { | ||
return factory(exports, require("underscore"), require("backbone"), require("backbone.marionette")); | ||
return factory(require("underscore"), require("backbone"), require("backbone.marionette"), exports); | ||
} else { | ||
return root.Backbone.Marionette.Modals = factory((root.commonJsStrict = {}), root._, root.Backbone, root.Backbone.Marionette); | ||
return factory(_, Backbone, Backbone.Marionette, {}); | ||
} | ||
})(this, function(exports, _, Backbone, Marionette) { | ||
var Modals; | ||
return Modals = (function(_super) { | ||
})(function(_, Backbone, Marionette, Modals) { | ||
Modals = (function(_super) { | ||
__extends(Modals, _super); | ||
@@ -589,4 +589,6 @@ | ||
})(Marionette.Region); | ||
Marionette.Modals = Modals; | ||
return Marionette.Modals; | ||
}); | ||
}).call(this); |
@@ -1,1 +0,1 @@ | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a,b){return"function"==typeof define&&define.amd?define(["exports","underscore","backbone"],b):"object"==typeof exports?b(exports,require("underscore"),require("backbone")):a.Backbone.Modal=b(a.commonJsStrict={},a._,a.Backbone)}(this,function(b,e,f){var g;return g=function(b){function g(){this.triggerCancel=a(this.triggerCancel,this),this.triggerSubmit=a(this.triggerSubmit,this),this.triggerView=a(this.triggerView,this),this.clickOutside=a(this.clickOutside,this),this.checkKey=a(this.checkKey,this),this.rendererCompleted=a(this.rendererCompleted,this),this.args=Array.prototype.slice.apply(arguments),f.View.prototype.constructor.apply(this,this.args),this.setUIElements()}return c(g,b),g.prototype.prefix="bbm",g.prototype.animate=!0,g.prototype.keyControl=!0,g.prototype.render=function(a){var b,c,d;return c=this.serializeData(),this.$el.addClass(""+this.prefix+"-wrapper"),this.modalEl=f.$("<div />").addClass(""+this.prefix+"-modal"),this.template&&this.modalEl.html(this.template(c)),this.$el.html(this.modalEl),this.viewContainer?(this.viewContainerEl=this.modalEl.find(this.viewContainer),this.viewContainerEl.addClass(""+this.prefix+"-modal__views")):this.viewContainerEl=this.modalEl,$(":focus").blur(),(null!=(d=this.views)?d.length:void 0)>0&&this.openAt(a||0),"function"==typeof this.onRender&&this.onRender(),this.delegateModalEvents(),b=this.getOption("animate"),this.$el.fadeIn&&b?(this.modalEl.css({opacity:0}),this.$el.fadeIn({duration:100,complete:this.rendererCompleted})):(this.$el.show(),this.rendererCompleted()),this},g.prototype.rendererCompleted=function(){var a;return this.keyControl&&(f.$("body").on("keyup",this.checkKey),f.$("body").on("click",this.clickOutside)),this.modalEl.css({opacity:1}).addClass(""+this.prefix+"-modal--open"),"function"==typeof this.onShow&&this.onShow(),null!=(a=this.currentView)&&"function"==typeof a.onShow?a.onShow():void 0},g.prototype.setUIElements=function(){var a;if(this.template=this.getOption("template"),this.views=this.getOption("views"),null!=(a=this.views)&&(a.length=e.size(this.views)),this.viewContainer=this.getOption("viewContainer"),this.$el.hide(),e.isUndefined(this.template)&&e.isUndefined(this.views))throw new Error("No template or views defined for Backbone.Modal");if(this.template&&this.views&&e.isUndefined(this.viewContainer))throw new Error("No viewContainer defined for Backbone.Modal")},g.prototype.getOption=function(a){return a?this.options&&d.call(this.options,a)>=0&&null!=this.options[a]?this.options[a]:this[a]:void 0},g.prototype.serializeData=function(){var a;return a={},this.model&&(a=e.extend(a,this.model.toJSON())),this.collection&&(a=e.extend(a,{items:this.collection.toJSON()})),a},g.prototype.delegateModalEvents=function(){var a,b,c,d,f,g,h;this.active=!0,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.on("click",f,this.triggerSubmit),a&&this.$el.on("click",a,this.triggerCancel),h=[];for(b in this.views)e.isString(b)&&"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),g=c[1],d=c[2],h.push(this.$el.on(g,d,this.views[b],this.triggerView))):h.push(void 0);return h},g.prototype.undelegateModalEvents=function(){var a,b,c,d,f,g,h;this.active=!1,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.off("click",f,this.triggerSubmit),a&&this.$el.off("click",a,this.triggerCancel),h=[];for(b in this.views)e.isString(b)&&"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),g=c[1],d=c[2],h.push(this.$el.off(g,d,this.views[b],this.triggerView))):h.push(void 0);return h},g.prototype.checkKey=function(a){if(this.active)switch(a.keyCode){case 27:return this.triggerCancel(a);case 13:return this.triggerSubmit(a)}},g.prototype.clickOutside=function(a){return f.$(a.target).hasClass(""+this.prefix+"-wrapper")&&this.active?this.triggerCancel():void 0},g.prototype.buildView=function(a,b){var c;if(a)return b&&e.isFunction(b)&&(b=b()),e.isFunction(a)?(c=new a(b||this.args[0]),c instanceof f.View?{el:c.render().$el,view:c}:{el:a(b||this.args[0])}):{view:a,el:a.$el}},g.prototype.triggerView=function(a){var b,c,d,f,g,h,i;if(null!=a&&"function"==typeof a.preventDefault&&a.preventDefault(),f=a.data,c=this.buildView(f.view,f.viewOptions),this.currentView&&(this.previousView=this.currentView,!(null!=(i=f.openOptions)?i.skipSubmit:void 0))){if(("function"==typeof(g=this.previousView).beforeSubmit?g.beforeSubmit():void 0)===!1)return;"function"==typeof(h=this.previousView).submit&&h.submit()}this.currentView=c.view||c.el,b=0;for(d in this.views)f.view===this.views[d].view&&(this.currentIndex=b),b++;return f.onActive&&(e.isFunction(f.onActive)?f.onActive(this):e.isString(f.onActive)&&this[f.onActive].call(this,f)),this.shouldAnimate?this.animateToView(c.el):(this.shouldAnimate=!0,this.$(this.viewContainerEl).html(c.el))},g.prototype.animateToView=function(a){var b,c,d,e,g,h,i;return e={position:"relative",top:-9999,left:-9999},g=f.$("<tester/>").css(e),g.html(this.$el.clone().css(e)),0!==f.$("tester").length?f.$("tester").replaceWith(g):f.$("body").append(g),b=g.find(this.viewContainer?this.viewContainer:"."+this.prefix+"-modal"),b.removeAttr("style"),d=b.outerHeight(),b.html(a),c=b.outerHeight(),d===c?(this.$(this.viewContainerEl).html(a),"function"==typeof(h=this.currentView).onShow&&h.onShow(),null!=(i=this.previousView)&&"function"==typeof i.destroy?i.destroy():void 0):(this.$(this.viewContainerEl).css({opacity:0}),this.$(this.viewContainerEl).animate({height:c},100,function(b){return function(){var c,d;return b.$(b.viewContainerEl).css({opacity:1}).removeAttr("style"),b.$(b.viewContainerEl).html(a),"function"==typeof(c=b.currentView).onShow&&c.onShow(),null!=(d=b.previousView)&&"function"==typeof d.destroy?d.destroy():void 0}}(this)))},g.prototype.triggerSubmit=function(a){var b,c;return null!=a&&a.preventDefault(),this.beforeSubmit&&this.beforeSubmit()===!1||this.currentView&&this.currentView.beforeSubmit&&this.currentView.beforeSubmit()===!1?void 0:this.submit||(null!=(b=this.currentView)?b.submit:void 0)||this.getOption("submitEl")?(null!=(c=this.currentView)&&"function"==typeof c.submit&&c.submit(),"function"==typeof this.submit&&this.submit(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy()):this.triggerCancel()},g.prototype.triggerCancel=function(a){return null!=a&&a.preventDefault(),this.beforeCancel&&this.beforeCancel()===!1?void 0:("function"==typeof this.cancel&&this.cancel(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy())},g.prototype.destroy=function(){var a,b;return f.$("body").off("keyup",this.checkKey),f.$("body").off("click",this.clickOutside),"function"==typeof this.onDestroy&&this.onDestroy(),this.shouldAnimate=!1,this.modalEl.addClass(""+this.prefix+"-modal--destroy"),b=function(a){return function(){var b;return null!=(b=a.currentView)&&"function"==typeof b.remove&&b.remove(),a.remove()}}(this),a=this.getOption("animate"),this.$el.fadeOut&&a?(this.$el.fadeOut({duration:200}),e.delay(function(){return b()},200)):b()},g.prototype.openAt=function(a){var b,c,d,f,g;e.isNumber(a)?b=a:e.isNumber(a._index)&&(b=a._index),d=0;for(f in this.views)if("length"!==f)if(e.isNumber(b))d===b&&(g=this.views[f]),d++;else if(e.isObject(a))for(c in this.views[f])a[c]===this.views[f][c]&&(g=this.views[f]);return g&&(this.currentIndex=e.indexOf(this.views,g),this.triggerView({data:e.extend(g,{openOptions:a})})),this},g.prototype.next=function(a){return null==a&&(a={}),this.currentIndex+1<this.views.length?this.openAt(e.extend(a,{_index:this.currentIndex+1})):void 0},g.prototype.previous=function(a){return null==a&&(a={}),this.currentIndex-1<this.views.length-1?this.openAt(e.extend(a,{_index:this.currentIndex-1})):void 0},g}(f.View)})}).call(this); | ||
(function(){var a=function(a,b){return function(){return a.apply(b,arguments)}},b={}.hasOwnProperty,c=function(a,c){function d(){this.constructor=a}for(var e in c)b.call(c,e)&&(a[e]=c[e]);return d.prototype=c.prototype,a.prototype=new d,a.__super__=c.prototype,a},d=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};!function(a){return"function"==typeof define&&define.amd?define(["underscore","backbone","exports"],a):"object"==typeof exports?a(require("underscore"),require("backbone"),exports):a(_,Backbone,{})}(function(b,e,f){return f=function(f){function g(){this.triggerCancel=a(this.triggerCancel,this),this.triggerSubmit=a(this.triggerSubmit,this),this.triggerView=a(this.triggerView,this),this.clickOutside=a(this.clickOutside,this),this.checkKey=a(this.checkKey,this),this.rendererCompleted=a(this.rendererCompleted,this),this.args=Array.prototype.slice.apply(arguments),e.View.prototype.constructor.apply(this,this.args),this.setUIElements()}return c(g,f),g.prototype.prefix="bbm",g.prototype.animate=!0,g.prototype.keyControl=!0,g.prototype.render=function(a){var b,c,d;return c=this.serializeData(),this.$el.addClass(""+this.prefix+"-wrapper"),this.modalEl=e.$("<div />").addClass(""+this.prefix+"-modal"),this.template&&this.modalEl.html(this.template(c)),this.$el.html(this.modalEl),this.viewContainer?(this.viewContainerEl=this.modalEl.find(this.viewContainer),this.viewContainerEl.addClass(""+this.prefix+"-modal__views")):this.viewContainerEl=this.modalEl,$(":focus").blur(),(null!=(d=this.views)?d.length:void 0)>0&&this.openAt(a||0),"function"==typeof this.onRender&&this.onRender(),this.delegateModalEvents(),b=this.getOption("animate"),this.$el.fadeIn&&b?(this.modalEl.css({opacity:0}),this.$el.fadeIn({duration:100,complete:this.rendererCompleted})):(this.$el.show(),this.rendererCompleted()),this},g.prototype.rendererCompleted=function(){var a;return this.keyControl&&(e.$("body").on("keyup",this.checkKey),e.$("body").on("click",this.clickOutside)),this.modalEl.css({opacity:1}).addClass(""+this.prefix+"-modal--open"),"function"==typeof this.onShow&&this.onShow(),null!=(a=this.currentView)&&"function"==typeof a.onShow?a.onShow():void 0},g.prototype.setUIElements=function(){var a;if(this.template=this.getOption("template"),this.views=this.getOption("views"),null!=(a=this.views)&&(a.length=b.size(this.views)),this.viewContainer=this.getOption("viewContainer"),this.$el.hide(),b.isUndefined(this.template)&&b.isUndefined(this.views))throw new Error("No template or views defined for Backbone.Modal");if(this.template&&this.views&&b.isUndefined(this.viewContainer))throw new Error("No viewContainer defined for Backbone.Modal")},g.prototype.getOption=function(a){return a?this.options&&d.call(this.options,a)>=0&&null!=this.options[a]?this.options[a]:this[a]:void 0},g.prototype.serializeData=function(){var a;return a={},this.model&&(a=b.extend(a,this.model.toJSON())),this.collection&&(a=b.extend(a,{items:this.collection.toJSON()})),a},g.prototype.delegateModalEvents=function(){var a,c,d,e,f,g,h;this.active=!0,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.on("click",f,this.triggerSubmit),a&&this.$el.on("click",a,this.triggerCancel),h=[];for(c in this.views)b.isString(c)&&"length"!==c?(d=c.match(/^(\S+)\s*(.*)$/),g=d[1],e=d[2],h.push(this.$el.on(g,e,this.views[c],this.triggerView))):h.push(void 0);return h},g.prototype.undelegateModalEvents=function(){var a,c,d,e,f,g,h;this.active=!1,a=this.getOption("cancelEl"),f=this.getOption("submitEl"),f&&this.$el.off("click",f,this.triggerSubmit),a&&this.$el.off("click",a,this.triggerCancel),h=[];for(c in this.views)b.isString(c)&&"length"!==c?(d=c.match(/^(\S+)\s*(.*)$/),g=d[1],e=d[2],h.push(this.$el.off(g,e,this.views[c],this.triggerView))):h.push(void 0);return h},g.prototype.checkKey=function(a){if(this.active)switch(a.keyCode){case 27:return this.triggerCancel(a);case 13:return this.triggerSubmit(a)}},g.prototype.clickOutside=function(a){return e.$(a.target).hasClass(""+this.prefix+"-wrapper")&&this.active?this.triggerCancel():void 0},g.prototype.buildView=function(a,c){var d;if(a)return c&&b.isFunction(c)&&(c=c()),b.isFunction(a)?(d=new a(c||this.args[0]),d instanceof e.View?{el:d.render().$el,view:d}:{el:a(c||this.args[0])}):{view:a,el:a.$el}},g.prototype.triggerView=function(a){var c,d,e,f,g,h,i;if(null!=a&&"function"==typeof a.preventDefault&&a.preventDefault(),f=a.data,d=this.buildView(f.view,f.viewOptions),this.currentView&&(this.previousView=this.currentView,!(null!=(i=f.openOptions)?i.skipSubmit:void 0))){if(("function"==typeof(g=this.previousView).beforeSubmit?g.beforeSubmit():void 0)===!1)return;"function"==typeof(h=this.previousView).submit&&h.submit()}this.currentView=d.view||d.el,c=0;for(e in this.views)f.view===this.views[e].view&&(this.currentIndex=c),c++;return f.onActive&&(b.isFunction(f.onActive)?f.onActive(this):b.isString(f.onActive)&&this[f.onActive].call(this,f)),this.shouldAnimate?this.animateToView(d.el):(this.shouldAnimate=!0,this.$(this.viewContainerEl).html(d.el))},g.prototype.animateToView=function(a){var b,c,d,f,g,h,i;return f={position:"relative",top:-9999,left:-9999},g=e.$("<tester/>").css(f),g.html(this.$el.clone().css(f)),0!==e.$("tester").length?e.$("tester").replaceWith(g):e.$("body").append(g),b=g.find(this.viewContainer?this.viewContainer:"."+this.prefix+"-modal"),b.removeAttr("style"),d=b.outerHeight(),b.html(a),c=b.outerHeight(),d===c?(this.$(this.viewContainerEl).html(a),"function"==typeof(h=this.currentView).onShow&&h.onShow(),null!=(i=this.previousView)&&"function"==typeof i.destroy?i.destroy():void 0):(this.$(this.viewContainerEl).css({opacity:0}),this.$(this.viewContainerEl).animate({height:c},100,function(b){return function(){var c,d;return b.$(b.viewContainerEl).css({opacity:1}).removeAttr("style"),b.$(b.viewContainerEl).html(a),"function"==typeof(c=b.currentView).onShow&&c.onShow(),null!=(d=b.previousView)&&"function"==typeof d.destroy?d.destroy():void 0}}(this)))},g.prototype.triggerSubmit=function(a){var b,c;return null!=a&&a.preventDefault(),this.beforeSubmit&&this.beforeSubmit()===!1||this.currentView&&this.currentView.beforeSubmit&&this.currentView.beforeSubmit()===!1?void 0:this.submit||(null!=(b=this.currentView)?b.submit:void 0)||this.getOption("submitEl")?(null!=(c=this.currentView)&&"function"==typeof c.submit&&c.submit(),"function"==typeof this.submit&&this.submit(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy()):this.triggerCancel()},g.prototype.triggerCancel=function(a){return null!=a&&a.preventDefault(),this.beforeCancel&&this.beforeCancel()===!1?void 0:("function"==typeof this.cancel&&this.cancel(),this.regionEnabled?this.trigger("modal:destroy"):this.destroy())},g.prototype.destroy=function(){var a,c;return e.$("body").off("keyup",this.checkKey),e.$("body").off("click",this.clickOutside),"function"==typeof this.onDestroy&&this.onDestroy(),this.shouldAnimate=!1,this.modalEl.addClass(""+this.prefix+"-modal--destroy"),c=function(a){return function(){var b;return null!=(b=a.currentView)&&"function"==typeof b.remove&&b.remove(),a.remove()}}(this),a=this.getOption("animate"),this.$el.fadeOut&&a?(this.$el.fadeOut({duration:200}),b.delay(function(){return c()},200)):c()},g.prototype.openAt=function(a){var c,d,e,f,g;b.isNumber(a)?c=a:b.isNumber(a._index)&&(c=a._index),e=0;for(f in this.views)if("length"!==f)if(b.isNumber(c))e===c&&(g=this.views[f]),e++;else if(b.isObject(a))for(d in this.views[f])a[d]===this.views[f][d]&&(g=this.views[f]);return g&&(this.currentIndex=b.indexOf(this.views,g),this.triggerView({data:b.extend(g,{openOptions:a})})),this},g.prototype.next=function(a){return null==a&&(a={}),this.currentIndex+1<this.views.length?this.openAt(b.extend(a,{_index:this.currentIndex+1})):void 0},g.prototype.previous=function(a){return null==a&&(a={}),this.currentIndex-1<this.views.length-1?this.openAt(b.extend(a,{_index:this.currentIndex-1})):void 0},g}(e.View),e.Modal=f,e.Modal})}).call(this); |
@@ -7,13 +7,12 @@ (function() { | ||
(function(root, factory) { | ||
(function(factory) { | ||
if (typeof define === "function" && define.amd) { | ||
return define(["exports", "underscore", "backbone"], factory); | ||
return define(["underscore", "backbone", "exports"], factory); | ||
} else if (typeof exports === "object") { | ||
return factory(exports, require("underscore"), require("backbone")); | ||
return factory(require("underscore"), require("backbone"), exports); | ||
} else { | ||
return root.Backbone.Modal = factory((root.commonJsStrict = {}), root._, root.Backbone); | ||
return factory(_, Backbone, {}); | ||
} | ||
})(this, function(exports, _, Backbone) { | ||
var Modal; | ||
return Modal = (function(_super) { | ||
})(function(_, Backbone, Modal) { | ||
Modal = (function(_super) { | ||
__extends(Modal, _super); | ||
@@ -468,4 +467,6 @@ | ||
})(Backbone.View); | ||
Backbone.Modal = Modal; | ||
return Backbone.Modal; | ||
}); | ||
}).call(this); |
{ | ||
"title": "Backbone.Modal", | ||
"name": "backbone.modal", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"main": "backbone.modal-bundled.js", | ||
@@ -6,0 +6,0 @@ "ignore": [ |
## Backbone.Modal | ||
[![Build Status](https://travis-ci.org/awkward/backbone.modal.svg?branch=1.1.0-beta)](https://travis-ci.org/awkward/backbone.modal) | ||
[![Coverage Status](https://img.shields.io/coveralls/awkward/backbone.modal.svg)](https://coveralls.io/r/awkward/backbone.modal) | ||
[![Build Status](https://travis-ci.org/awkward/backbone.modal.svg)](https://travis-ci.org/awkward/backbone.modal) | ||
@@ -10,2 +9,4 @@ A plugin for Backbone.js that simplifies creating modals for your application. | ||
`bower install backbone-modal` | ||
For a complete overview of the documentation visit: [http://awkward.github.io/backbone.modal/](http://awkward.github.io/backbone.modal/) | ||
@@ -15,13 +16,13 @@ | ||
If you're using Backbone and Marionette. | ||
* [backbone.modal-bundled-min.js](https://raw.github.com/awkward/backbone.modal/master/backbone.modal-bundled-min.js) | ||
* [backbone.modal-bundled-min.js](https://raw.github.com/awkward/backbone.modal/tree/v1.1.1/backbone.modal-bundled-min.js) | ||
#### Backbone.Modals.js and Backbone.Marionette.Modals.js separate | ||
If you just want to use the Backbone version without Marionette. | ||
* [backbone.modal-min.js](https://raw.github.com/awkward/backbone.modal/master/backbone.modal-min.js) | ||
* [backbone.marionette.modals-min.js](https://raw.github.com/awkward/backbone.modal/master/backbone.marionette.modals-min.js) | ||
* [backbone.modal-min.js](https://raw.github.com/awkward/backbone.modal/tree/v1.1.1/backbone.modal-min.js) | ||
* [backbone.marionette.modals-min.js](https://raw.github.com/awkward/backbone.modal/tree/v1.1.1/backbone.marionette.modals-min.js) | ||
#### CSS files | ||
There's default style, and you can use our theme to make things look pretty. | ||
* [backbone.modal.css](https://raw.github.com/awkward/backbone.modal/master/backbone.modal.css) | ||
* [backbone.modal.theme.css](https://raw.github.com/awkward/backbone.modal/master/backbone.modal.theme.css) | ||
* [backbone.modal.css](https://raw.github.com/awkward/backbone.modal/tree/v1.1.1/backbone.modal.css) | ||
* [backbone.modal.theme.css](https://raw.github.com/awkward/backbone.modal/tree/v1.1.1/backbone.modal.theme.css) | ||
@@ -28,0 +29,0 @@ ### How to contribute |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
149596
35
1977
40
4