appetizer-ui 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/appetizer-ui.gemspec +15 -13
  2. data/lib/appetizer/ui/assets.rb +21 -8
  3. data/lib/appetizer/ui/jasmine/js/jquery-jasmine.js +288 -0
  4. data/lib/appetizer/ui/jasmine/js/spec-runner.coffee +0 -1
  5. data/lib/appetizer/ui/jasmine/views/specs.erb +12 -4
  6. data/lib/appetizer/ui/rake.rb +29 -10
  7. data/lib/appetizer/ui/spec.rb +1 -2
  8. metadata +122 -61
  9. data/lib/appetizer/ui/app/js/appetizer.coffee +0 -15
  10. data/lib/appetizer/ui/app/js/appetizer/core.coffee +0 -20
  11. data/lib/appetizer/ui/app/js/appetizer/model.coffee +0 -1
  12. data/lib/appetizer/ui/app/js/appetizer/router.coffee +0 -70
  13. data/lib/appetizer/ui/app/js/appetizer/view.coffee +0 -139
  14. data/lib/appetizer/ui/app/js/appetizer/xdr.coffee +0 -57
  15. data/lib/appetizer/ui/app/views/client/appetizer/missing.jst.eco +0 -3
  16. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/appetizerExtensions.spec.js +0 -54
  17. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/checkboxConventionBindings.spec.js +0 -110
  18. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/configurableBindingAttributes.spec.js +0 -117
  19. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/configureAllBindingAttributes.spec.js +0 -139
  20. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/customConvention.spec.js +0 -53
  21. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindConvention.spec.js +0 -151
  22. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindMultiple.spec.js +0 -36
  23. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindSubstitutions.spec.js +0 -137
  24. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfiguraAllBindingAttributes.spec.js +0 -124
  25. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfigurableBindingAttributes.spec.js +0 -36
  26. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/SpecHelper.js +0 -4
  27. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/sample.backbone.app.js +0 -159
  28. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/html5inputConventionBinding.spec.js +0 -142
  29. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/modelUnbinding.spec.js +0 -73
  30. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/noConflict.spec.js +0 -36
  31. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/radioButtonConventionBinding.spec.js +0 -41
  32. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/selectboxConventionBindings.spec.js +0 -60
  33. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/textareaConventionBinding.spec.js +0 -29
  34. data/lib/appetizer/ui/jasmine/js/backbone.modelbinding/textboxConventionBinding.spec.js +0 -66
  35. data/lib/appetizer/ui/vendor/js/backbone.js +0 -1290
  36. data/lib/appetizer/ui/vendor/js/backbone.modelbinding.js +0 -624
  37. data/lib/appetizer/ui/vendor/js/jquery.js +0 -9266
  38. data/lib/appetizer/ui/vendor/js/json2.js +0 -480
  39. data/lib/appetizer/ui/vendor/js/underscore.js +0 -999
  40. data/lib/appetizer/ui/vendor/js/underscore.string.js +0 -480
@@ -7,8 +7,7 @@ module Appetizer
7
7
  def self.registered app
8
8
  return if App.production?
9
9
 
10
- %w(css img js views).each do |d|
11
- App.assets.append_path "./spec/#{d}"
10
+ %w(css img js views fonts).each do |d|
12
11
  App.assets.append_path File.expand_path("../jasmine/#{d}", __FILE__)
13
12
  end
14
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appetizer-ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-15 00:00:00.000000000Z
12
+ date: 2014-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appetizer
16
- requirement: &70231318806980 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70231318806980
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: coffee-script
27
- requirement: &70231318804820 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '2.2'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70231318804820
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.2'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: eco
38
- requirement: &70231318803720 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '1.0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70231318803720
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rack-contrib
49
- requirement: &70231318802660 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '1.1'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70231318802660
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.1'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rack-ssl
60
- requirement: &70231318801720 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '1.3'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70231318801720
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.3'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: sass
71
- requirement: &70231318801060 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '3.1'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70231318801060
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.1'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: sinatra
82
- requirement: &70231318800400 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,43 +117,95 @@ dependencies:
87
117
  version: '1.3'
88
118
  type: :runtime
89
119
  prerelease: false
90
- version_requirements: *70231318800400
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.3'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: sprockets
93
- requirement: &70231318799640 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ~>
97
132
  - !ruby/object:Gem::Version
98
- version: '2.1'
133
+ version: '2.11'
99
134
  type: :runtime
100
135
  prerelease: false
101
- version_requirements: *70231318799640
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: '2.11'
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: sprockets-sass
104
- requirement: &70231318798480 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ~>
148
+ - !ruby/object:Gem::Version
149
+ version: '1.0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
105
153
  none: false
106
154
  requirements:
107
155
  - - ~>
108
156
  - !ruby/object:Gem::Version
109
- version: '0.6'
157
+ version: '1.0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: sprockets-helpers
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: '1.1'
110
166
  type: :runtime
111
167
  prerelease: false
112
- version_requirements: *70231318798480
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ~>
172
+ - !ruby/object:Gem::Version
173
+ version: '1.1'
113
174
  - !ruby/object:Gem::Dependency
114
175
  name: uglifier
115
- requirement: &70231318797720 !ruby/object:Gem::Requirement
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ~>
180
+ - !ruby/object:Gem::Version
181
+ version: '1.0'
182
+ type: :runtime
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
116
185
  none: false
117
186
  requirements:
118
187
  - - ~>
119
188
  - !ruby/object:Gem::Version
120
189
  version: '1.0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: vendorer
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: '0.1'
121
198
  type: :runtime
122
199
  prerelease: false
123
- version_requirements: *70231318797720
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '0.1'
124
206
  - !ruby/object:Gem::Dependency
125
207
  name: yajl-ruby
126
- requirement: &70231318796420 !ruby/object:Gem::Requirement
208
+ requirement: !ruby/object:Gem::Requirement
127
209
  none: false
128
210
  requirements:
129
211
  - - ~>
@@ -131,10 +213,15 @@ dependencies:
131
213
  version: '1.0'
132
214
  type: :runtime
133
215
  prerelease: false
134
- version_requirements: *70231318796420
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: '1.0'
135
222
  - !ruby/object:Gem::Dependency
136
223
  name: yui-compressor
137
- requirement: &70231318794860 !ruby/object:Gem::Requirement
224
+ requirement: !ruby/object:Gem::Requirement
138
225
  none: false
139
226
  requirements:
140
227
  - - ~>
@@ -142,7 +229,12 @@ dependencies:
142
229
  version: '0.9'
143
230
  type: :runtime
144
231
  prerelease: false
145
- version_requirements: *70231318794860
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ~>
236
+ - !ruby/object:Gem::Version
237
+ version: '0.9'
146
238
  description: A painfully opinionated Appetizer extension for web apps.
147
239
  email:
148
240
  - tech@audiosocket.com
@@ -156,48 +248,17 @@ files:
156
248
  - Rakefile
157
249
  - appetizer-ui.gemspec
158
250
  - lib/appetizer/ui.rb
159
- - lib/appetizer/ui/app/js/appetizer.coffee
160
- - lib/appetizer/ui/app/js/appetizer/core.coffee
161
- - lib/appetizer/ui/app/js/appetizer/model.coffee
162
- - lib/appetizer/ui/app/js/appetizer/router.coffee
163
- - lib/appetizer/ui/app/js/appetizer/view.coffee
164
- - lib/appetizer/ui/app/js/appetizer/xdr.coffee
165
- - lib/appetizer/ui/app/views/client/appetizer/missing.jst.eco
166
251
  - lib/appetizer/ui/assets.rb
167
252
  - lib/appetizer/ui/assets/delivery.rb
168
253
  - lib/appetizer/ui/jasmine/css/jasmine.css
169
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/appetizerExtensions.spec.js
170
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/checkboxConventionBindings.spec.js
171
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/configurableBindingAttributes.spec.js
172
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/configureAllBindingAttributes.spec.js
173
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/customConvention.spec.js
174
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindConvention.spec.js
175
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindMultiple.spec.js
176
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/dataBindSubstitutions.spec.js
177
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfiguraAllBindingAttributes.spec.js
178
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/globalConfigurableBindingAttributes.spec.js
179
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/SpecHelper.js
180
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/helpers/sample.backbone.app.js
181
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/html5inputConventionBinding.spec.js
182
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/modelUnbinding.spec.js
183
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/noConflict.spec.js
184
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/radioButtonConventionBinding.spec.js
185
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/selectboxConventionBindings.spec.js
186
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/textareaConventionBinding.spec.js
187
- - lib/appetizer/ui/jasmine/js/backbone.modelbinding/textboxConventionBinding.spec.js
188
254
  - lib/appetizer/ui/jasmine/js/jasmine-html.js
189
255
  - lib/appetizer/ui/jasmine/js/jasmine-jquery-matchers.js
190
256
  - lib/appetizer/ui/jasmine/js/jasmine.js
257
+ - lib/appetizer/ui/jasmine/js/jquery-jasmine.js
191
258
  - lib/appetizer/ui/jasmine/js/spec-runner.coffee
192
259
  - lib/appetizer/ui/jasmine/views/specs.erb
193
260
  - lib/appetizer/ui/rake.rb
194
261
  - lib/appetizer/ui/spec.rb
195
- - lib/appetizer/ui/vendor/js/backbone.js
196
- - lib/appetizer/ui/vendor/js/backbone.modelbinding.js
197
- - lib/appetizer/ui/vendor/js/jquery.js
198
- - lib/appetizer/ui/vendor/js/json2.js
199
- - lib/appetizer/ui/vendor/js/underscore.js
200
- - lib/appetizer/ui/vendor/js/underscore.string.js
201
262
  homepage: https://github.com/audiosocket/appetizer-ui
202
263
  licenses: []
203
264
  post_install_message:
@@ -218,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
279
  version: '0'
219
280
  requirements: []
220
281
  rubyforge_project:
221
- rubygems_version: 1.8.10
282
+ rubygems_version: 1.8.23
222
283
  signing_key:
223
284
  specification_version: 3
224
285
  summary: Helpers for rich clients using Sinatra, Sass, and CoffeeScript.
@@ -1,15 +0,0 @@
1
- #= require json2
2
- #= require jquery
3
- #= require underscore
4
- #= require underscore.string
5
-
6
- #= require backbone
7
- #= require backbone.modelbinding
8
-
9
- #= require appetizer/core
10
- #= require appetizer/model
11
- #= require appetizer/view
12
-
13
- # Mixin non-conflicting methods to underscore.
14
-
15
- _.mixin _.str.exports()
@@ -1,20 +0,0 @@
1
- window.Appetizer ||= {}
2
-
3
- # All Backbone's classes that inherit from Backbone.Event
4
- # are also given a "one" method, which can be used to fire
5
- # a callback only on the next occurence of a given event.
6
-
7
- one =
8
- one: (ev, callback, context) ->
9
- self = this
10
-
11
- fn = ->
12
- callback.apply this, arguments
13
- self.unbind.apply self, [ev, fn]
14
-
15
- this.bind ev, fn, context
16
-
17
- _.extend Backbone.Model.prototype, one
18
- _.extend Backbone.Collection.prototype, one
19
- _.extend Backbone.View.prototype, one
20
- _.extend Backbone.Router.prototype, one
@@ -1 +0,0 @@
1
- class Appetizer.Model extends Backbone.Model
@@ -1,70 +0,0 @@
1
- # A superclass for Backbone.router. It adds the following features:
2
- # * Register dynamic routes: the method @dynamicRoutes, if present,
3
- # is executed when initializing the router. Using the provided @register
4
- # method, it is then possible to register routes within the @dynamicRoutes
5
- # method.
6
- #
7
- # * Components facilities: the property @components should contain an
8
- # array of components used in the application, such as "page", "panel",
9
- # "sidebar", etc..
10
- # For each component, a method showFoo is created, which can then be used
11
- # to show a component. For instance, showPage App.View.Page, options. Upon
12
- # calling showFoo App.View.Bar the following is performed:
13
- # - Call @foo.hide true if @foo exists
14
- # - Instanciate a fresh @foo = new App.View.Bar options
15
- # - Save current route in @foo.currentRoute
16
- # - Emit "foo:showing", @foo
17
- # - Call @foo.show()
18
- # - Emit "foo:shown", @foo when @foo has been shown
19
- #
20
- # Component facilites can be used to properly implement your application's
21
- # logic. For instance, you can do the following:
22
- # components: ["page", "sidebar"]
23
- #
24
- # initialize: ->
25
- # # Show the sidebar corresponding to current shown page.
26
- # @bind "page:shown", (page) -> @showSidebar @findSidebarForPage(page)
27
-
28
- class Appetizer.Router extends Backbone.Router
29
- initialize: ->
30
- @children = []
31
-
32
- @dynamicRoutes() if @dynamicRoutes?
33
-
34
- # Create showItem functions
35
-
36
- if @components?
37
- @addShowFunction item for item in @components
38
-
39
- register: (route, name) =>
40
- @route route, name, this[name]
41
-
42
- # Create an instance of a view, set this as the view's parent, and
43
- # add the view to the router's list of children.
44
-
45
- createChild: (kind, options) ->
46
- child = new kind options
47
- child.parent = this
48
- @children.push child
49
- child
50
-
51
- # Required for Appetizer.View hierarchy management.
52
-
53
- removeChild: (view) ->
54
- @children.splice _.indexOf(@children, view), 1
55
- this
56
-
57
- addShowFunction: (item) ->
58
- fn = "show#{item.charAt(0).toUpperCase()}#{item.slice 1}"
59
-
60
- this[fn] = (kind, options) ->
61
- if this[item]?
62
- this[item].hide true
63
- @removeChild this[item]
64
-
65
- this[item] = @createChild(kind, options)
66
- this[item].currentRoute = Backbone.history.getFragment()
67
-
68
- @trigger "#{item}:showing", this[item]
69
- this[item].bind "shown", => @trigger "#{item}:shown", this[item]
70
- this[item].show()
@@ -1,139 +0,0 @@
1
- # Shockingly enough, a superclass for views. Provides hooks and
2
- # abstractions for incoming and outgoing bindings, parent and child
3
- # views, default template rendering, async actions before show, and
4
- # show()/hide()/makeVisible() helpers on top of render() and remove().
5
-
6
- class Appetizer.View extends Backbone.View
7
-
8
- # Subclasses must always call `super` in their initializers:
9
- # Important binding, parent, and child relationships get created.
10
-
11
- initialize: (options) ->
12
- @bindings = []
13
- @children = []
14
- @parent = options.parent if options?.parent?
15
- @route = options?.route or @constructor.route
16
-
17
- @bind "ancestor:shown", ->
18
- child.trigger "ancestor:shown" for child in @children
19
- @shown = true
20
-
21
- # true if the element or its ancestor have already been shown.
22
- # Can be used at rendering time to execute operations that
23
- # need the element to be hooked-up in the DOM, such as computing
24
- # its height.
25
-
26
- shown: false
27
-
28
- # Add a child `view`. Its `parent` will be set to `this`, and it
29
- # will be dismissed when this view is dismissed.
30
-
31
- addChild: (view) ->
32
- view.parent = this
33
- @children.push view
34
- this
35
-
36
- # Hook to allow async processes to occur before and after showing
37
- # the view. A bound callback `fn` is passed to this method by
38
- # `show`, and should be called when the view is ready to be shown.
39
-
40
- aroundShow: (fn) -> fn()
41
-
42
- # Bind `fn` to an `event` on `src`, remembering that we've bound it
43
- # for future unbinding. Use this instead of calling `bind` directly
44
- # on other sources. Returns `this`.
45
-
46
- bindTo: (src, event, fn) ->
47
- src.bind event, fn, this
48
- @bindings.push evt: event, fn: fn, src: src
49
- this
50
-
51
- # Create and return a new instance of `kind`, passing along
52
- # `options` to the constructor. Add it as a child view.
53
-
54
- createChild: (kind, options) ->
55
- child = new kind options
56
- @addChild child
57
- child
58
-
59
- # Indicate that this view is no longer necessary. Optionally takes a
60
- # DOM event `e` and calls `preventDefault` on it to make wiring
61
- # easier. Unbinds all incoming and outgoing events, calls `dismiss`
62
- # on all children, and removes this view from any parent it might
63
- # have. Returns `this`.
64
-
65
- hide: (e) ->
66
- e.preventDefault() if e?.preventDefault?
67
-
68
- @trigger "hiding"
69
- @remove()
70
-
71
- @trigger "hidden"
72
- @unbind()
73
-
74
- _(@children).chain().clone().each (c) -> c.hide() if c.hide?
75
- @parent.removeChild this if @parent?.removeChild
76
-
77
- this
78
-
79
- # Hook to provide actual DOM insertion/manipulation for the
80
- # view. The default implementation logs an error message to the
81
- # console.
82
-
83
- makeVisible: ->
84
- console.log "Can't make #{this.constructor.name} visible."
85
-
86
- # Remove `view` from this view's list of children. Returns `this`.
87
-
88
- removeChild: (view) ->
89
- @children.splice _.indexOf(@children, view), 1
90
- this
91
-
92
- # Render the contents of the view. Updates the view element's
93
- # contents, but doesn't do any other manipulation. Uses a JST based
94
- # on either the view class' `template` default value or a `template`
95
- # key passed in to the constructor. Triggers a "rendered" event
96
- # after the element's contents are in place. Returns `this`.
97
- #
98
- # Assumes that views are under a "client/" prefix and that their
99
- # template functions are available on a "JST" global.
100
-
101
- render: =>
102
- template = @options.template || @template || "appetizer/missing"
103
- renderer = JST["client/#{template}"] or JST["client/appetizer/missing"]
104
-
105
- @trigger "rendering"
106
- $(@el).html renderer this
107
- @trigger "rendered"
108
-
109
- this
110
-
111
- # Display this view. Possibly asynchronous: Passes a bound callback
112
- # to `beforeShow` that will call `makeVisible` when the view is
113
- # ready for display. The default implementation of `makeVisible`
114
- # calls the callback immediately. Returns `this`.
115
-
116
- show: ->
117
- @aroundShow =>
118
- @trigger "showing"
119
- @makeVisible()
120
- @trigger "shown"
121
-
122
- @shown = true
123
- child.trigger "ancestor:shown" for child in @children
124
-
125
- this
126
-
127
- # Unbind any listeners who have bound themselves to us, and unbind
128
- # any listeners we've bound to others. Returns `this`.
129
-
130
- unbind: ->
131
- super # from Backbone.Events
132
- b.src.unbind b.evt, b.fn for b in @bindings
133
- this
134
-
135
- # Unbind all events we may have bound on `src`. Returns `this`.
136
-
137
- unbindFrom: (src) ->
138
- b.src.unbind b.evt, b.fn for b in @bindings when b.src is src
139
- this