marionette-modal 1.0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,224 @@
1
+ (function() {
2
+ var __hasProp = {}.hasOwnProperty,
3
+ __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; };
4
+
5
+ describe('Backbone.Modal', function() {
6
+ var modal;
7
+ modal = {};
8
+ beforeEach(function() {
9
+ var backboneView, _ref, _ref1;
10
+ backboneView = (function(_super) {
11
+ __extends(backboneView, _super);
12
+
13
+ function backboneView() {
14
+ _ref = backboneView.__super__.constructor.apply(this, arguments);
15
+ return _ref;
16
+ }
17
+
18
+ return backboneView;
19
+
20
+ })(Backbone.View);
21
+ return modal = (function(_super) {
22
+ __extends(modal, _super);
23
+
24
+ function modal() {
25
+ _ref1 = modal.__super__.constructor.apply(this, arguments);
26
+ return _ref1;
27
+ }
28
+
29
+ modal.prototype.viewContainer = 'div';
30
+
31
+ modal.prototype.cancelEl = '.close';
32
+
33
+ modal.prototype.submitEl = '.submit';
34
+
35
+ modal.prototype.template = function() {
36
+ return '<a class="class"></a><a id="id"></a><div></div><a data-event="true"></a><a class="close"></a><a class="submit"></a>';
37
+ };
38
+
39
+ modal.prototype.views = {
40
+ 'click .class': {
41
+ view: new backboneView
42
+ },
43
+ 'click #id': {
44
+ view: function() {
45
+ return '<p>html</p>';
46
+ }
47
+ },
48
+ 'click [data-event]': {
49
+ view: function() {
50
+ return new Backbone.View({
51
+ option: true
52
+ });
53
+ }
54
+ }
55
+ };
56
+
57
+ modal.prototype._shouldCancel = true;
58
+
59
+ modal.prototype._shouldSubmit = true;
60
+
61
+ modal.prototype.beforeCancel = function() {
62
+ return this._shouldCancel;
63
+ };
64
+
65
+ modal.prototype.beforeSubmit = function() {
66
+ return this._shouldSubmit;
67
+ };
68
+
69
+ modal.prototype.cancel = function() {};
70
+
71
+ modal.prototype.submit = function() {};
72
+
73
+ return modal;
74
+
75
+ })(Backbone.Modal);
76
+ });
77
+ afterEach(function() {
78
+ return modal = {};
79
+ });
80
+ it("should have Backbone defined", function() {
81
+ return expect(Backbone).toBeDefined();
82
+ });
83
+ it('should throw an exception if there is no template or views present', function() {
84
+ delete modal.prototype.views;
85
+ delete modal.prototype.template;
86
+ return expect(function() {
87
+ return new modal();
88
+ }).toThrow();
89
+ });
90
+ it('should throw an exception if a template and views are defined and no viewContainer is present', function() {
91
+ delete modal.prototype.viewContainer;
92
+ return expect(function() {
93
+ return new modal;
94
+ }).toThrow();
95
+ });
96
+ describe('views:', function() {
97
+ var view;
98
+ view = {};
99
+ beforeEach(function() {
100
+ return view = new modal();
101
+ });
102
+ it('should trigger the first view when rendered', function() {
103
+ spyOn(view, 'triggerView');
104
+ view.render();
105
+ return expect(view.triggerView).toHaveBeenCalled();
106
+ });
107
+ it("#buildView: checks if it's a Backbone.View or just a HTML template that is passed along", function() {
108
+ var key, v, _results;
109
+ _results = [];
110
+ for (key in view.views) {
111
+ v = view.buildView(view.views[key].view);
112
+ if (_.isFunction(v)) {
113
+ _results.push(expect(_.isString(v.render().el)));
114
+ } else {
115
+ _results.push(expect(_.isString(v)));
116
+ }
117
+ }
118
+ return _results;
119
+ });
120
+ return it("#length should return the length of the total views", function() {
121
+ return expect(view.views.length).toEqual(3);
122
+ });
123
+ });
124
+ describe('#openAt', function() {
125
+ return it('opens a view at the specified index', function() {
126
+ var view;
127
+ view = new modal();
128
+ view.openAt(1);
129
+ return expect(view.currentIndex).toBe(1);
130
+ });
131
+ });
132
+ describe('#next', function() {
133
+ return it('should open the next view', function() {
134
+ var view;
135
+ view = new modal();
136
+ view.render().next();
137
+ return expect(view.currentIndex).toBe(1);
138
+ });
139
+ });
140
+ describe('#previous', function() {
141
+ return it('should open the previous view', function() {
142
+ var view;
143
+ view = new modal();
144
+ view.render().openAt(2).previous();
145
+ return expect(view.currentIndex).toBe(1);
146
+ });
147
+ });
148
+ describe('#currentIndex', function() {
149
+ return it('should return the index of the current view', function() {
150
+ var view;
151
+ view = new modal();
152
+ view.render().openAt(2);
153
+ return expect(view.currentIndex).toBe(2);
154
+ });
155
+ });
156
+ describe('#render', function() {
157
+ return it('renders the modal and internal views', function() {
158
+ var view;
159
+ view = new modal();
160
+ return expect(_.isString(view.render().el));
161
+ });
162
+ });
163
+ describe('#beforeCancel', function() {
164
+ it("should call this method when it's defined", function() {
165
+ var view;
166
+ view = new modal();
167
+ spyOn(view, 'beforeCancel');
168
+ view.render().triggerCancel();
169
+ return expect(view.beforeCancel).toHaveBeenCalled();
170
+ });
171
+ return it('stops the cancel when it returns false', function() {
172
+ var view;
173
+ view = new modal();
174
+ spyOn(view, 'close');
175
+ view._shouldCancel = false;
176
+ view.render().triggerCancel();
177
+ return expect(view.close.calls.length).toEqual(0);
178
+ });
179
+ });
180
+ describe('#cancel', function() {
181
+ return it('should be called when cancelEl is triggered', function() {
182
+ var view;
183
+ view = new modal();
184
+ spyOn(view, 'cancel');
185
+ view.render().$(view.cancelEl).click();
186
+ return expect(view.cancel.calls.length).toEqual(1);
187
+ });
188
+ });
189
+ describe('#beforeSubmit', function() {
190
+ it("should call this method when it's defined", function() {
191
+ var view;
192
+ view = new modal();
193
+ spyOn(view, 'beforeSubmit');
194
+ view.render().triggerSubmit({
195
+ preventDefault: function() {}
196
+ });
197
+ return expect(view.beforeSubmit).toHaveBeenCalled();
198
+ });
199
+ return it('stops the submit when it returns false', function() {
200
+ var view;
201
+ view = new modal();
202
+ spyOn(view, 'submit');
203
+ view._shouldSubmit = false;
204
+ view.render().triggerSubmit({
205
+ preventDefault: function() {}
206
+ });
207
+ return expect(view.submit.calls.length).toEqual(0);
208
+ });
209
+ });
210
+ describe('#submit', function() {
211
+ return it('should be called when submitEl is triggered', function() {
212
+ var view;
213
+ view = new modal();
214
+ spyOn(view, 'submit');
215
+ view.render().$(view.submitEl).click();
216
+ return expect(view.submit.calls.length).toEqual(1);
217
+ });
218
+ });
219
+ return describe('#animate', function() {
220
+ return it('should do all the animation work', function() {});
221
+ });
222
+ });
223
+
224
+ }).call(this);
data/test/spec.html ADDED
@@ -0,0 +1,41 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Jasmine Spec Runner</title>
6
+
7
+ <link rel="stylesheet" type="text/css" href=".grunt/grunt-contrib-jasmine/jasmine.css">
8
+
9
+
10
+
11
+ <script src="./.grunt/grunt-contrib-jasmine/jasmine.js"></script>
12
+
13
+ <script src="./.grunt/grunt-contrib-jasmine/jasmine-html.js"></script>
14
+
15
+ <script src="./examples/vendor/jquery-1.9.1.js"></script>
16
+
17
+ <script src="./examples/vendor/underscore.js"></script>
18
+
19
+ <script src="./examples/vendor/backbone.js"></script>
20
+
21
+ <script src="./examples/vendor/marionette.js"></script>
22
+
23
+ <script src="./dist/backbone.modal.js"></script>
24
+
25
+ <script src="./dist/marionette.modal.js"></script>
26
+
27
+ <script src="./dist/backbone.marionette.modals.js"></script>
28
+
29
+ <script src="./test/spec/backbone.marionette.modals.spec.js"></script>
30
+
31
+ <script src="./test/spec/backbone.modal.spec.js"></script>
32
+
33
+ <script src="./.grunt/grunt-contrib-jasmine/reporter.js"></script>
34
+
35
+ <script src="./.grunt/grunt-contrib-jasmine/jasmine-helper.js"></script>
36
+
37
+
38
+ </head>
39
+ <body>
40
+ </body>
41
+ </html>
@@ -0,0 +1,56 @@
1
+ describe 'Backbone.Marionette.Modals', ->
2
+
3
+ myLayout = {}
4
+
5
+ class layout extends Backbone.Marionette.Layout
6
+ template: -> '<div id="modals"></div>'
7
+ regions:
8
+ modals:
9
+ selector: '#modals'
10
+ regionType: Backbone.Marionette.Modals
11
+
12
+ class BackboneModal extends Backbone.Modal
13
+ viewContainer: 'div'
14
+ cancelEl: '.close'
15
+ submitEl: '.submit'
16
+ template: -> '<a id="id"></a><div></div><a class="close"></a><a class="submit"></a>'
17
+ views:
18
+ 'click #id':
19
+ view: -> '<p>html</p>'
20
+ cancel: ->
21
+ submit: ->
22
+
23
+ class MarionetteModal extends Marionette.Modal
24
+ viewContainer: 'div'
25
+ cancelEl: '.close'
26
+ submitEl: '.submit'
27
+ template: -> '<a id="id"></a><div></div><a class="close"></a><a class="submit"></a>'
28
+ views:
29
+ 'click #id':
30
+ view: -> '<p>html</p>'
31
+ cancel: ->
32
+ submit: ->
33
+
34
+ myLayout = new layout()
35
+
36
+ describe '#show', ->
37
+ it 'should stack a modal view', ->
38
+ myLayout.modals.show(new modal())
39
+ expect(myLayout.modals.zIndex).toBe(1)
40
+
41
+ it 'should disable modals with zIndex < modal', ->
42
+
43
+ describe '#close', ->
44
+ it 'should only close the last modal', ->
45
+ myLayout.modals.close()
46
+ expect(myLayout.modals.zIndex).toBe(0)
47
+
48
+ it 'should enable the last modal', ->
49
+
50
+ describe '#closeAll', ->
51
+ it 'should close all the modals', ->
52
+ myLayout.modals.show(new modal())
53
+ myLayout.modals.closeAll()
54
+ expect(myLayout.modals.modals.length).toBe(0)
55
+
56
+
@@ -0,0 +1,139 @@
1
+ describe 'Backbone.Modal', ->
2
+ modal = {}
3
+
4
+ beforeEach ->
5
+ class backboneView extends Backbone.View
6
+
7
+ class modal extends Backbone.Modal
8
+ viewContainer: 'div'
9
+ cancelEl: '.close'
10
+ submitEl: '.submit'
11
+ template: -> '<a class="class"></a><a id="id"></a><div></div><a data-event="true"></a><a class="close"></a><a class="submit"></a>'
12
+ views:
13
+ 'click .class':
14
+ view: new backboneView
15
+ 'click #id':
16
+ view: -> '<p>html</p>'
17
+ 'click [data-event]':
18
+ view: -> new Backbone.View(option: true)
19
+
20
+ _shouldCancel: true
21
+ _shouldSubmit: true
22
+ beforeCancel: -> @_shouldCancel
23
+ beforeSubmit: -> @_shouldSubmit
24
+ cancel: ->
25
+ submit: ->
26
+
27
+ afterEach ->
28
+ modal = {}
29
+
30
+ it "should have Backbone defined", ->
31
+ expect(Backbone).toBeDefined()
32
+
33
+ it 'should throw an exception if there is no template or views present', ->
34
+ delete modal::views
35
+ delete modal::template
36
+
37
+ expect(-> new modal()).toThrow()
38
+
39
+ it 'should throw an exception if a template and views are defined and no viewContainer is present', ->
40
+ delete modal::viewContainer
41
+
42
+ expect(-> new modal).toThrow()
43
+
44
+ describe 'views:', ->
45
+ view = {}
46
+
47
+ beforeEach ->
48
+ view = new modal()
49
+
50
+ it 'should trigger the first view when rendered', ->
51
+ spyOn(view, 'triggerView')
52
+ view.render()
53
+
54
+ expect(view.triggerView).toHaveBeenCalled()
55
+
56
+ it "#buildView: checks if it's a Backbone.View or just a HTML template that is passed along", ->
57
+ for key of view.views
58
+ v = view.buildView(view.views[key].view)
59
+ if _.isFunction(v)
60
+ expect(_.isString(v.render().el))
61
+ else
62
+ expect(_.isString(v))
63
+
64
+ it "#length should return the length of the total views", ->
65
+ expect(view.views.length).toEqual(3)
66
+
67
+ describe '#openAt', ->
68
+ it 'opens a view at the specified index', ->
69
+ view = new modal()
70
+ view.openAt(1)
71
+ expect(view.currentIndex).toBe(1)
72
+
73
+ describe '#next', ->
74
+ it 'should open the next view', ->
75
+ view = new modal()
76
+ view.render().next()
77
+ expect(view.currentIndex).toBe(1)
78
+
79
+ describe '#previous', ->
80
+ it 'should open the previous view', ->
81
+ view = new modal()
82
+ view.render().openAt(2).previous()
83
+ expect(view.currentIndex).toBe(1)
84
+
85
+ describe '#currentIndex', ->
86
+ it 'should return the index of the current view', ->
87
+ view = new modal()
88
+ view.render().openAt(2)
89
+ expect(view.currentIndex).toBe(2)
90
+
91
+ describe '#render', ->
92
+ it 'renders the modal and internal views', ->
93
+ view = new modal()
94
+ expect(_.isString(view.render().el))
95
+
96
+ describe '#beforeCancel', ->
97
+ it "should call this method when it's defined", ->
98
+ view = new modal()
99
+ spyOn(view, 'beforeCancel')
100
+ view.render().triggerCancel()
101
+ expect(view.beforeCancel).toHaveBeenCalled()
102
+
103
+ it 'stops the cancel when it returns false', ->
104
+ view = new modal()
105
+ spyOn(view, 'close')
106
+ view._shouldCancel = false
107
+ view.render().triggerCancel()
108
+ expect(view.close.calls.length).toEqual(0)
109
+
110
+ describe '#cancel', ->
111
+ it 'should be called when cancelEl is triggered', ->
112
+ view = new modal()
113
+ spyOn(view, 'cancel')
114
+ view.render().$(view.cancelEl).click()
115
+ expect(view.cancel.calls.length).toEqual(1)
116
+
117
+ describe '#beforeSubmit', ->
118
+ it "should call this method when it's defined", ->
119
+ view = new modal()
120
+ spyOn(view, 'beforeSubmit')
121
+ view.render().triggerSubmit({preventDefault: ->})
122
+ expect(view.beforeSubmit).toHaveBeenCalled()
123
+
124
+ it 'stops the submit when it returns false', ->
125
+ view = new modal()
126
+ spyOn(view, 'submit')
127
+ view._shouldSubmit = false
128
+ view.render().triggerSubmit({preventDefault: ->})
129
+ expect(view.submit.calls.length).toEqual(0)
130
+
131
+ describe '#submit', ->
132
+ it 'should be called when submitEl is triggered', ->
133
+ view = new modal()
134
+ spyOn(view, 'submit')
135
+ view.render().$(view.submitEl).click()
136
+ expect(view.submit.calls.length).toEqual(1)
137
+
138
+ describe '#animate', ->
139
+ it 'should do all the animation work', ->
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marionette-modal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.8
5
+ platform: ruby
6
+ authors:
7
+ - Jared Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Fork of Backbone.Modal Backbone.js plugin
42
+ email:
43
+ - jcsmith1859@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gruntfile.coffee
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - dist/backbone.marionette.modals-min.js
55
+ - dist/backbone.marionette.modals.js
56
+ - dist/backbone.modal-min.js
57
+ - dist/backbone.modal.js
58
+ - dist/marionette.modal-bundled-min.js
59
+ - dist/marionette.modal-bundled.js
60
+ - dist/marionette.modal-min.js
61
+ - dist/marionette.modal.css
62
+ - dist/marionette.modal.js
63
+ - dist/marionette.modal.theme.css
64
+ - examples/1_single_view.html
65
+ - examples/2_tab_based.html
66
+ - examples/3_stacked_modal_with_marionette.html
67
+ - examples/4_wizard.html
68
+ - examples/css/style.css
69
+ - examples/img/tab-icons.png
70
+ - examples/style.css
71
+ - examples/vendor/backbone.js
72
+ - examples/vendor/backbone.marionette.modals.js
73
+ - examples/vendor/backbone.modal.css
74
+ - examples/vendor/backbone.modal.js
75
+ - examples/vendor/backbone.modal.theme.css
76
+ - examples/vendor/jquery-1.9.1.js
77
+ - examples/vendor/marionette.js
78
+ - examples/vendor/marionette.modal.css
79
+ - examples/vendor/marionette.modal.js
80
+ - examples/vendor/marionette.modal.theme.css
81
+ - examples/vendor/underscore.js
82
+ - lib/marionette-modal.rb
83
+ - lib/marionette-modal/version.rb
84
+ - marionette-modal.gemspec
85
+ - package.json
86
+ - src/backbone.marionette.modals.coffee
87
+ - src/backbone.modal.coffee
88
+ - src/marionette.modal.coffee
89
+ - src/marionette.modal.sass
90
+ - src/marionette.modal.theme.sass
91
+ - src/style.sass
92
+ - test/spec.html
93
+ - test/spec/backbone.marionette.modals.spec.js
94
+ - test/spec/backbone.modal.spec.js
95
+ - test/src/backbone.marionette.modals.spec.coffee
96
+ - test/src/backbone.modal.spec.coffee
97
+ homepage: https://github.com/Outcome-Engenuity/marionette-modal
98
+ licenses:
99
+ - MIT
100
+ metadata: {}
101
+ post_install_message:
102
+ rdoc_options: []
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ requirements: []
116
+ rubyforge_project:
117
+ rubygems_version: 2.1.10
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Fork of the Backbone.Modal Backbone.js plugin that is more tightly integrated
121
+ with Marionette.js
122
+ test_files:
123
+ - test/spec.html
124
+ - test/spec/backbone.marionette.modals.spec.js
125
+ - test/spec/backbone.modal.spec.js
126
+ - test/src/backbone.marionette.modals.spec.coffee
127
+ - test/src/backbone.modal.spec.coffee
128
+ has_rdoc: