marionette-modal 1.0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/Gemfile +4 -0
  4. data/Gruntfile.coffee +111 -0
  5. data/LICENSE +22 -0
  6. data/README.md +42 -0
  7. data/Rakefile +1 -0
  8. data/dist/backbone.marionette.modals-min.js +1 -0
  9. data/dist/backbone.marionette.modals.js +104 -0
  10. data/dist/backbone.modal-min.js +1 -0
  11. data/dist/backbone.modal.js +382 -0
  12. data/dist/marionette.modal-bundled-min.js +1 -0
  13. data/dist/marionette.modal-bundled.js +858 -0
  14. data/dist/marionette.modal-min.js +1 -0
  15. data/dist/marionette.modal.css +24 -0
  16. data/dist/marionette.modal.js +370 -0
  17. data/dist/marionette.modal.theme.css +324 -0
  18. data/examples/1_single_view.html +71 -0
  19. data/examples/2_tab_based.html +104 -0
  20. data/examples/3_stacked_modal_with_marionette.html +105 -0
  21. data/examples/4_wizard.html +132 -0
  22. data/examples/css/style.css +45 -0
  23. data/examples/img/tab-icons.png +0 -0
  24. data/examples/style.css +35 -0
  25. data/examples/vendor/backbone.js +1591 -0
  26. data/examples/vendor/backbone.marionette.modals.js +104 -0
  27. data/examples/vendor/backbone.modal.css +24 -0
  28. data/examples/vendor/backbone.modal.js +382 -0
  29. data/examples/vendor/backbone.modal.theme.css +324 -0
  30. data/examples/vendor/jquery-1.9.1.js +9597 -0
  31. data/examples/vendor/marionette.js +2466 -0
  32. data/examples/vendor/marionette.modal.css +24 -0
  33. data/examples/vendor/marionette.modal.js +370 -0
  34. data/examples/vendor/marionette.modal.theme.css +324 -0
  35. data/examples/vendor/underscore.js +1314 -0
  36. data/lib/marionette-modal/version.rb +3 -0
  37. data/lib/marionette-modal.rb +22 -0
  38. data/marionette-modal.gemspec +23 -0
  39. data/package.json +19 -0
  40. data/src/backbone.marionette.modals.coffee +67 -0
  41. data/src/backbone.modal.coffee +253 -0
  42. data/src/marionette.modal.coffee +248 -0
  43. data/src/marionette.modal.sass +26 -0
  44. data/src/marionette.modal.theme.sass +486 -0
  45. data/src/style.sass +48 -0
  46. data/test/spec/backbone.marionette.modals.spec.js +120 -0
  47. data/test/spec/backbone.modal.spec.js +224 -0
  48. data/test/spec.html +41 -0
  49. data/test/src/backbone.marionette.modals.spec.coffee +56 -0
  50. data/test/src/backbone.modal.spec.coffee +139 -0
  51. metadata +128 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24640f6ef008f5bb2efc0aed757411c319b70691
4
+ data.tar.gz: eefb33d85d18d9519d7490571ff8928e950ff608
5
+ SHA512:
6
+ metadata.gz: f60562a46e965323c44dc44ad9074f74b8b3614091c880c93a6b39fa9819143b97f724840ecdbe6b3926cec8383dc66eecab4710d1a44d426a9c50417043d18c
7
+ data.tar.gz: 0a7b3a029e8134afc7f15b65db3973e32f02b842f78f033b8e0502eff7f487f0f04333bd24832b65f38d60f530c4a33a1006bbea553f3c0f7e26e55d0cd78dd0
data/.gitignore ADDED
@@ -0,0 +1,36 @@
1
+ # Ruby Gem
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ # NPM
21
+ node_modules
22
+
23
+ # Grunt
24
+ .grunt
25
+
26
+ # SASS/SCSS cache files
27
+ *.scssc
28
+ *.sassc
29
+ .sass-cache
30
+
31
+ # Mac finder artifacts
32
+ .DS_Store
33
+
34
+ # Sublime Text project files
35
+ *.sublime-project
36
+ *.sublime-workspace
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marionette.modal.gemspec
4
+ gemspec
data/Gruntfile.coffee ADDED
@@ -0,0 +1,111 @@
1
+ module.exports = (grunt) ->
2
+ fs = require('fs')
3
+
4
+ grunt.initConfig
5
+ open:
6
+ default:
7
+ url: 'http://localhost:8000'
8
+
9
+ connect:
10
+ default:
11
+ options:
12
+ base: './'
13
+ middleware: (connect, options) ->
14
+ [connect.static(options.base), (req, res, next) ->
15
+ fs.readFile "#{options.base}/test/spec.html", (err, data) ->
16
+ res.writeHead(200)
17
+ res.end(data)
18
+ ]
19
+ examples:
20
+ options:
21
+ port: 5000
22
+ base: './examples/'
23
+ middleware: (connect, options) ->
24
+ [connect.static(options.base), (req, res, next) ->
25
+ fs.readFile "#{options.base}/1_single_view.html", (err, data) ->
26
+ res.writeHead(200)
27
+ res.end(data)
28
+ ]
29
+
30
+ uglify:
31
+ modal:
32
+ src: 'dist/backbone.modal.js'
33
+ dest: 'dist/backbone.modal-min.js'
34
+ marionettemodal:
35
+ src: 'dist/marionette.modal.js'
36
+ dest: 'dist/marionette.modal-min.js'
37
+ modals:
38
+ src: 'dist/backbone.marionette.modals.js'
39
+ dest: 'dist/backbone.marionette.modals-min.js'
40
+ bundled:
41
+ src: 'dist/marionette.modal-bundled.js'
42
+ dest: 'dist/marionette.modal-bundled-min.js'
43
+
44
+ jasmine:
45
+ all:
46
+ src: ['dist/backbone.modal.js', 'dist/marionette.modal.js', 'dist/backbone.marionette.modals.js']
47
+ options:
48
+ specs: 'test/spec/**/*.js'
49
+ outfile: 'test/spec.html'
50
+ host: 'http://127.0.0.1:8000/'
51
+ vendor: ['examples/vendor/jquery-1.9.1.js', 'examples/vendor/underscore.js', 'examples/vendor/backbone.js', 'examples/vendor/marionette.js']
52
+
53
+ clean: ['dist', 'test/spec']
54
+
55
+ coffee:
56
+ all:
57
+ files:
58
+ 'dist/backbone.modal.js': 'src/backbone.modal.coffee'
59
+ 'dist/marionette.modal.js': 'src/marionette.modal.coffee'
60
+ 'dist/backbone.marionette.modals.js': 'src/backbone.marionette.modals.coffee'
61
+ 'dist/marionette.modal-bundled.js': ['src/backbone.modal.coffee', 'src/marionette.modal.coffee', 'src/backbone.marionette.modals.coffee']
62
+
63
+ 'examples/vendor/backbone.modal.js': 'src/backbone.modal.coffee'
64
+ 'examples/vendor/marionette.modal.js': 'src/marionette.modal.coffee'
65
+ 'examples/vendor/backbone.marionette.modals.js': 'src/backbone.marionette.modals.coffee'
66
+ specs:
67
+ files:
68
+ grunt.file.expandMapping(['test/src/**/*.coffee'], 'test/spec/',
69
+ rename: (destBase, destPath) ->
70
+ return destBase + destPath.slice(9, destPath.length).replace(/\.coffee$/, '.js')
71
+ )
72
+
73
+ sass:
74
+ compile:
75
+ files:
76
+ 'dist/marionette.modal.css': 'src/marionette.modal.sass'
77
+ 'dist/marionette.modal.theme.css': 'src/marionette.modal.theme.sass'
78
+ 'examples/vendor/marionette.modal.css': 'src/marionette.modal.sass'
79
+ 'examples/vendor/marionette.modal.theme.css': 'src/marionette.modal.theme.sass'
80
+ 'examples/style.css': 'src/style.sass'
81
+
82
+ concurrent:
83
+ compile: ['coffee', 'sass']
84
+
85
+ regarde:
86
+ livereloadJS:
87
+ files: ['test/**/*.js', 'examples/vendor/*.js']
88
+ tasks: ['livereload']
89
+ livereloadCSS:
90
+ files: ['examples/vendor/marionette.modal.css', 'examples/vendor/marionette.modal.theme.css', 'examples/style.css']
91
+ tasks: ['livereload:dist/marionette.modal.css', 'livereload:examples/vendor/marionette.modal.theme.css', 'livereload:examples/style.css']
92
+ sass:
93
+ files: ['src/**/*.sass']
94
+ tasks: ['sass']
95
+ coffee:
96
+ files: ['src/**/*.coffee', 'test/src/**/*.coffee']
97
+ tasks: ['uglify', 'coffee']
98
+
99
+ grunt.loadNpmTasks 'grunt-contrib-coffee'
100
+ grunt.loadNpmTasks 'grunt-contrib-clean'
101
+ grunt.loadNpmTasks 'grunt-regarde'
102
+ grunt.loadNpmTasks 'grunt-open'
103
+ grunt.loadNpmTasks 'grunt-contrib-connect'
104
+ grunt.loadNpmTasks 'grunt-contrib-livereload'
105
+ grunt.loadNpmTasks 'grunt-contrib-jasmine'
106
+ grunt.loadNpmTasks 'grunt-contrib-uglify'
107
+ grunt.loadNpmTasks 'grunt-contrib-sass'
108
+ grunt.loadNpmTasks 'grunt-concurrent'
109
+
110
+ grunt.registerTask 'build', ['clean', 'concurrent', 'uglify', 'jasmine:all:build']
111
+ grunt.registerTask 'watch', ['connect', 'clean', 'build', 'livereload-start', 'open', 'regarde']
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jared Smith
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ ## Marionette.Modal
2
+
3
+ A plugin for Marionette.js that simplifies creating modals for your marionette application.
4
+
5
+ This project is a fork of the original Backbone.Modal that has tighter integration with the Marionette.js framework.
6
+
7
+ Marionette.Modal.js removes boilerplate code and adds default behaviors and interactions. You can create a simple dialog modal or complex wizards with stacked modals on top of each other in a few lines of code.
8
+
9
+ Documentation is roughly the same as Backbone.Modal. The internals of the base modal view are extending Marionette.View rather than
10
+ Backbone.View in order to take advantage of the builtin functionality that marionette provides.
11
+
12
+ For a complete overview of the forked repo documentation visit: [http://awkward.github.io/backbone.modal/](http://awkward.github.io/backbone.modal/)
13
+
14
+ #### Bundled version
15
+ If you're using Backbone and Marionette.
16
+ * [marionette.modal-bundled-min.js](https://raw.github.com/Outcome-Engenuity/marionette.modal/master/marionette.modal-bundled-min.js)
17
+
18
+ #### Backbone.Modals.js and Backbone.Marionette.Modals.js separate
19
+ If you just want to use the Backbone version without Marionette.
20
+ * [backbone.modal-min.js](https://raw.github.com/Outcome-Engenuity/marionette.modal/master/backbone.modal-min.js)
21
+ * [backbone.marionette.modals-min.js](https://raw.github.com/Outcome-Engenuity/marionette.modal/master/backbone.marionette.modals-min.js)
22
+
23
+ #### CSS files
24
+ There's default style, and you can use our theme to make things look pretty.
25
+ * [marionette.modal.css](https://raw.github.com/Outcome-Engenuity/marionette.modal/master/marionette.modal.css)
26
+ * [marionette.modal.theme.css](https://raw.github.com/Outcome-Engenuity/marionette.modal/master/marionette.modal.theme.css)
27
+
28
+ ### How to contribute
29
+
30
+ To get started `grunt install` to install all dependencies. If you have any requests, please create an issue. If you're working on something yourself, make a pull request and we'll make sure to check it out to get in into the next release.
31
+
32
+ ### Tests
33
+
34
+ ##### (Please note that there are currently no tests written for the marionette.modal view currently. I will make some when time permits.)
35
+
36
+ When you run the project by doing `grunt watch`. This will watch the tests, src and example files. It will open up a browser with the tests on `http://localhost:8000`. When you head over `http://localhost:5000`, it will show the example that's defined in the `Gruntfile.coffee`.
37
+
38
+ ### Legal stuff (MIT License)
39
+
40
+ Copyright (c) 2013 jcsmith1859.
41
+
42
+ Distributed under MIT license.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1 @@
1
+ (function(){var a,b=function(a,b){return function(){return a.apply(b,arguments)}},c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};if("undefined"==typeof Backbone||null===Backbone)throw new Error("Backbone is not defined. Please include the latest version from http://documentcloud.github.com/backbone/backbone.js");Backbone.Marionette.Modals=function(c){function e(){return this.close=b(this.close,this),a=e.__super__.constructor.apply(this,arguments)}return d(e,c),e.prototype.modals=[],e.prototype.zIndex=0,e.prototype.show=function(a,b){var c,d,e,f,g,h;for(null==b&&(b={}),this.ensureEl(),this.modals.length>0&&(c=_.last(this.modals),c.modalEl.addClass(""+c.prefix+"-modal--stacked"),e=this.modals[this.modals.length-1],null!=e&&e.modalEl.removeClass(""+e.prefix+"-modal--stacked-reverse")),a.render(),a.regionEnabled=!0,this.$el.show(),this.$el.append(a.el),this.modals.length>0&&a.$el.css({background:"none"}),Marionette.triggerMethod.call(a,"show"),Marionette.triggerMethod.call(this,"show",a),this.currentView=a,h=this.modals,f=0,g=h.length;g>f;f++)d=h[f],d.undelegateModalEvents();return a.on("modal:close",this.close),this.modals.push(a),this.zIndex++},e.prototype.close=function(){var a,b;return b=this.currentView,b&&!b.isClosed?(b.close?b.close():b.remove&&b.remove(),b.off("modal:close",this.close),this.modals.splice(_.indexOf(this.modals,b),1),this.zIndex--,this.currentView=this.modals[this.zIndex-1],a=_.last(this.modals),a&&(a.modalEl.addClass(""+a.prefix+"-modal--stacked-reverse"),_.delay(function(){return a.modalEl.removeClass(""+a.prefix+"-modal--stacked")},300),0!==this.zIndex&&a.delegateModalEvents()),Marionette.triggerMethod.call(this,"close")):void 0},e.prototype.closeAll=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.close());return e},e}(Backbone.Marionette.Region)}).call(this);
@@ -0,0 +1,104 @@
1
+ (function() {
2
+ var _ref,
3
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
4
+ __hasProp = {}.hasOwnProperty,
5
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
6
+
7
+ if (typeof Backbone === "undefined" || Backbone === null) {
8
+ throw new Error("Backbone is not defined. Please include the latest version from http://documentcloud.github.com/backbone/backbone.js");
9
+ }
10
+
11
+ Backbone.Marionette.Modals = (function(_super) {
12
+ __extends(Modals, _super);
13
+
14
+ function Modals() {
15
+ this.close = __bind(this.close, this);
16
+ _ref = Modals.__super__.constructor.apply(this, arguments);
17
+ return _ref;
18
+ }
19
+
20
+ Modals.prototype.modals = [];
21
+
22
+ Modals.prototype.zIndex = 0;
23
+
24
+ Modals.prototype.show = function(modal, options) {
25
+ var lastModal, m, secondLastModal, _i, _len, _ref1;
26
+ if (options == null) {
27
+ options = {};
28
+ }
29
+ this.ensureEl();
30
+ if (this.modals.length > 0) {
31
+ lastModal = _.last(this.modals);
32
+ lastModal.modalEl.addClass("" + lastModal.prefix + "-modal--stacked");
33
+ secondLastModal = this.modals[this.modals.length - 1];
34
+ if (secondLastModal != null) {
35
+ secondLastModal.modalEl.removeClass("" + secondLastModal.prefix + "-modal--stacked-reverse");
36
+ }
37
+ }
38
+ modal.render();
39
+ modal.regionEnabled = true;
40
+ this.$el.show();
41
+ this.$el.append(modal.el);
42
+ if (this.modals.length > 0) {
43
+ modal.$el.css({
44
+ background: 'none'
45
+ });
46
+ }
47
+ Marionette.triggerMethod.call(modal, "show");
48
+ Marionette.triggerMethod.call(this, "show", modal);
49
+ this.currentView = modal;
50
+ _ref1 = this.modals;
51
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
52
+ m = _ref1[_i];
53
+ m.undelegateModalEvents();
54
+ }
55
+ modal.on('modal:close', this.close);
56
+ this.modals.push(modal);
57
+ return this.zIndex++;
58
+ };
59
+
60
+ Modals.prototype.close = function() {
61
+ var lastModal, modal,
62
+ _this = this;
63
+ modal = this.currentView;
64
+ if (!modal || modal.isClosed) {
65
+ return;
66
+ }
67
+ if (modal.close) {
68
+ modal.close();
69
+ } else if (modal.remove) {
70
+ modal.remove();
71
+ }
72
+ modal.off('modal:close', this.close);
73
+ this.modals.splice(_.indexOf(this.modals, modal), 1);
74
+ this.zIndex--;
75
+ this.currentView = this.modals[this.zIndex - 1];
76
+ lastModal = _.last(this.modals);
77
+ if (lastModal) {
78
+ lastModal.modalEl.addClass("" + lastModal.prefix + "-modal--stacked-reverse");
79
+ _.delay(function() {
80
+ return lastModal.modalEl.removeClass("" + lastModal.prefix + "-modal--stacked");
81
+ }, 300);
82
+ if (this.zIndex !== 0) {
83
+ lastModal.delegateModalEvents();
84
+ }
85
+ }
86
+ return Marionette.triggerMethod.call(this, "close");
87
+ };
88
+
89
+ Modals.prototype.closeAll = function() {
90
+ var modal, _i, _len, _ref1, _results;
91
+ _ref1 = this.modals;
92
+ _results = [];
93
+ for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
94
+ modal = _ref1[_i];
95
+ _results.push(this.close());
96
+ }
97
+ return _results;
98
+ };
99
+
100
+ return Modals;
101
+
102
+ })(Backbone.Marionette.Region);
103
+
104
+ }).call(this);
@@ -0,0 +1 @@
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};if("undefined"==typeof Backbone||null===Backbone)throw new Error("Backbone is not defined. Please include the latest version from http://documentcloud.github.com/backbone/backbone.js");Backbone.Modal=function(b){function e(){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.args=Array.prototype.slice.apply(arguments),Backbone.View.prototype.constructor.apply(this,this.args),this.setUIElements(),this.delegateModalEvents()}return c(e,b),e.prototype.prefix="bbm",e.prototype.render=function(a){var b,c,d=this;return null==a&&(a={}),b=this.serializeData(),this.$el.addClass(""+this.prefix+"-wrapper"),this.modalEl=Backbone.$("<div />").addClass(""+this.prefix+"-modal"),this.template&&this.modalEl.html(this.template(b)),this.$el.html(this.modalEl),Backbone.$("body").on("keyup",this.checkKey),Backbone.$("body").on("click",this.clickOutside),this.viewContainer?(this.viewContainerEl=this.modalEl.find(this.viewContainer),this.viewContainerEl.addClass(""+this.prefix+"-modal__views")):this.viewContainerEl=this.modalEl,this.$el.show(),(null!=(c=this.views)?c.length:void 0)>0&&this.openAt(0),"function"==typeof this.onRender&&this.onRender(),this.modalEl.css({opacity:0}),this.$el.fadeIn({duration:100,complete:function(){return d.modalEl.css({opacity:1}).addClass(""+d.prefix+"-modal--open")}}),this},e.prototype.setUIElements=function(){var a;if(this.template=this.getOption("template"),this.views=this.getOption("views"),null!=(a=this.views)&&(a.length=_.size(this.views)),this.viewContainer=this.getOption("viewContainer"),this.$el.hide(),_.isUndefined(this.template)&&_.isUndefined(this.views))throw new Error("No template or views defined for Backbone.Modal");if(this.template&&this.views&&_.isUndefined(this.viewContainer))throw new Error("No viewContainer defined for Backbone.Modal")},e.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},e.prototype.serializeData=function(){var a;return a={},this.model&&(a=_.extend(a,this.model.toJSON())),this.collection&&(a=_.extend(a,{items:this.collection.toJSON()})),a},e.prototype.delegateModalEvents=function(){var a,b,c,d,e,f,g;this.active=!0,a=this.getOption("cancelEl"),e=this.getOption("submitEl"),e&&this.$el.on("click",e,this.triggerSubmit),a&&this.$el.on("click",a,this.triggerCancel),g=[];for(b in this.views)"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),f=c[1],d=c[2],g.push(this.$el.on(f,d,this.views[b],this.triggerView))):g.push(void 0);return g},e.prototype.undelegateModalEvents=function(){var a,b,c,d,e,f,g;this.active=!1,a=this.getOption("cancelEl"),e=this.getOption("submitEl"),e&&this.$el.off("click",e,this.triggerSubmit),a&&this.$el.off("click",a,this.triggerCancel),g=[];for(b in this.views)"length"!==b?(c=b.match(/^(\S+)\s*(.*)$/),f=c[1],d=c[2],g.push(this.$el.off(f,d,this.views[b],this.triggerView))):g.push(void 0);return g},e.prototype.checkKey=function(a){if(this.active)switch(a.keyCode){case 27:return this.triggerCancel();case 13:return this.triggerSubmit()}},e.prototype.clickOutside=function(a){return Backbone.$(a.target).hasClass(""+this.prefix+"-wrapper")&&this.active?this.triggerCancel(null,!0):void 0},e.prototype.buildView=function(a){var b;if(a)return _.isFunction(a)?(b=new a(this.args[0]),b instanceof Backbone.View?{el:b.render().$el,view:b}:{el:a(this.args[0])}):{view:a,el:a.$el}},e.prototype.triggerView=function(a){var b,c,d,e;null!=a&&"function"==typeof a.preventDefault&&a.preventDefault(),e=a.data,c=this.buildView(e.view),this.currentView&&(this.previousView=this.currentView),this.currentView=c.view||c.el,b=0;for(d in this.views)e.view===this.views[d].view&&(this.currentIndex=b),b++;return e.onActive&&(_.isFunction(e.onActive)?e.onActive(this):_.isString(e.onActive)&&this[e.onActive].call(this,e)),this.shouldAnimate?this.animateToView(c.el):(this.shouldAnimate=!0,this.$(this.viewContainerEl).html(c.el))},e.prototype.animateToView=function(a){var b,c,d,e,f,g,h=this;return e={position:"relative",top:-9999,left:-9999},f=Backbone.$("<tester/>").css(e),f.html(this.$el.clone().css(e)),0!==Backbone.$("tester").length?Backbone.$("tester").replaceWith(f):Backbone.$("body").append(f),b=this.viewContainer?f.find(this.viewContainer):f.find("."+this.prefix+"-modal"),b.removeAttr("style"),d=b.outerHeight(),b.html(a),c=b.outerHeight(),d===c?(this.$(this.viewContainerEl).html(a),null!=(g=this.previousView)?"function"==typeof g.close?g.close():void 0:void 0):(this.$(this.viewContainerEl).css({opacity:0}),this.$(this.viewContainerEl).animate({height:c},100,function(){var b;return h.$(h.viewContainerEl).css({opacity:1}).removeAttr("style"),h.$(h.viewContainerEl).html(a),null!=(b=h.previousView)?"function"==typeof b.close?b.close():void 0:void 0}))},e.prototype.triggerSubmit=function(a){return a&&(null!=a&&a.preventDefault(),!this.beforeSubmit||this.beforeSubmit()!==!1)?("function"==typeof this.submit&&this.submit(),this.regionEnabled?this.trigger("modal:close"):this.close()):void 0},e.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:close"):this.close())},e.prototype.close=function(){var a=this;return Backbone.$("body").off("keyup",this.checkKey),Backbone.$("body").off("click",this.clickOutside),"function"==typeof this.onClose&&this.onClose(),this.shouldAnimate=!1,this.modalEl.addClass(""+this.prefix+"-modal--close"),this.$el.fadeOut({duration:200}),_.delay(function(){var b;return null!=(b=a.currentView)&&"function"==typeof b.remove&&b.remove(),a.remove()},200)},e.prototype.openAt=function(a){var b,c,d;b=0;for(c in this.views)"length"!==c&&(b===a&&(d=this.views[c]),b++);return d&&(this.currentIndex=a,this.triggerView({data:d})),this},e.prototype.next=function(){return this.currentIndex+1<this.views.length?this.openAt(this.currentIndex+1):void 0},e.prototype.previous=function(){return this.currentIndex-1<this.views.length-1?this.openAt(this.currentIndex-1):void 0},e}(Backbone.View)}).call(this);