luca 0.9.89 → 0.9.91

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 (186) hide show
  1. data/CHANGELOG +11 -1
  2. data/Gemfile +5 -2
  3. data/Gemfile.lock +84 -56
  4. data/Rakefile +10 -2
  5. data/app/assets/javascripts/luca/components/application.coffee +82 -89
  6. data/app/assets/javascripts/luca/components/collection_view.coffee +9 -5
  7. data/app/assets/javascripts/luca/components/controller.coffee +72 -11
  8. data/app/assets/javascripts/luca/components/fields/base.coffee +61 -8
  9. data/app/assets/javascripts/luca/components/fields/button_field.coffee +53 -7
  10. data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
  11. data/app/assets/javascripts/luca/components/fields/text_field.coffee +1 -1
  12. data/app/assets/javascripts/luca/components/form_view.coffee +2 -2
  13. data/app/assets/javascripts/luca/components/grid_layout_view.coffee +0 -1
  14. data/app/assets/javascripts/luca/components/page.coffee +1 -0
  15. data/app/assets/javascripts/luca/components/table_view.coffee +2 -2
  16. data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
  17. data/app/assets/javascripts/luca/containers/card_view.coffee +84 -54
  18. data/app/assets/javascripts/luca/containers/container.coffee +126 -46
  19. data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
  20. data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
  21. data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +1 -1
  22. data/app/assets/javascripts/luca/containers/viewport.coffee +2 -5
  23. data/app/assets/javascripts/luca/core/collection.coffee +18 -4
  24. data/app/assets/javascripts/luca/core/model.coffee +1 -1
  25. data/app/assets/javascripts/luca/core/panel.coffee +1 -1
  26. data/app/assets/javascripts/luca/core/view.coffee +26 -7
  27. data/app/assets/javascripts/luca/development/code_sync_manager.coffee +51 -4
  28. data/app/assets/javascripts/luca/development/console.coffee +1 -1
  29. data/app/assets/javascripts/luca/framework.coffee +1 -1
  30. data/app/assets/javascripts/luca/index.coffee +1 -0
  31. data/app/assets/javascripts/luca/util/luca.coffee +2 -1
  32. data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
  33. data/bin/luca +14 -0
  34. data/docs/framework.json +1 -1
  35. data/docs/luca-framework-documentation.js +1 -0
  36. data/lib/luca/cli/generate.rb +37 -0
  37. data/lib/luca/cli/server.rb +20 -0
  38. data/lib/luca/cli/sync.rb +40 -0
  39. data/lib/luca/cli/watch.rb +16 -0
  40. data/lib/luca/cli.rb +68 -0
  41. data/lib/luca/collection/endpoint.rb +1 -0
  42. data/lib/luca/component_definition.rb +23 -5
  43. data/lib/luca/luca_application.rb +18 -7
  44. data/lib/luca/rails/version.rb +1 -1
  45. data/lib/luca/server.rb +7 -0
  46. data/lib/luca/stylesheet.rb +2 -3
  47. data/lib/luca/version.rb +3 -0
  48. data/lib/luca/watcher.rb +72 -0
  49. data/lib/luca.rb +8 -1
  50. data/luca.gemspec +14 -7
  51. data/site/.bundle/config +2 -0
  52. data/site/.gitignore +5 -0
  53. data/site/.rvmrc +1 -0
  54. data/site/CHANGELOG.md +41 -0
  55. data/site/DOCS.md +41 -0
  56. data/site/Gemfile +8 -0
  57. data/site/Gemfile.lock +134 -0
  58. data/site/LICENSE.md +19 -0
  59. data/site/config.rb +84 -0
  60. data/site/helpers/site_helpers.rb +20 -0
  61. data/site/html5bp-docs/README.md +38 -0
  62. data/site/html5bp-docs/contribute.md +104 -0
  63. data/site/html5bp-docs/crossdomain.md +21 -0
  64. data/site/html5bp-docs/css.md +135 -0
  65. data/site/html5bp-docs/extend.md +507 -0
  66. data/site/html5bp-docs/faq.md +77 -0
  67. data/site/html5bp-docs/htaccess.md +323 -0
  68. data/site/html5bp-docs/html.md +170 -0
  69. data/site/html5bp-docs/js.md +31 -0
  70. data/site/html5bp-docs/misc.md +25 -0
  71. data/site/html5bp-docs/usage.md +109 -0
  72. data/site/readme.md +47 -0
  73. data/site/source/.htaccess +540 -0
  74. data/site/source/404.html +157 -0
  75. data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
  76. data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
  77. data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
  78. data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
  79. data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
  80. data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
  81. data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
  82. data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
  83. data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
  84. data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
  85. data/site/source/app/assets/javascripts/docs/lib/util.coffee +0 -0
  86. data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
  87. data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
  88. data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
  89. data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
  90. data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
  91. data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
  92. data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
  93. data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
  94. data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
  95. data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
  96. data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
  97. data/site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee +0 -0
  98. data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
  99. data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
  100. data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
  101. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
  102. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
  103. data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
  104. data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
  105. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
  106. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
  107. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
  108. data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
  109. data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
  110. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
  111. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
  112. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
  113. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
  114. data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
  115. data/site/source/app/assets/javascripts/docs-docs.js +1 -0
  116. data/site/source/app/assets/javascripts/luca-docs.js +1 -0
  117. data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
  118. data/site/source/app/assets/javascripts/site.js.coffee +4 -0
  119. data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
  120. data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
  121. data/site/source/app/assets/javascripts/vendor/css.js +465 -0
  122. data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
  123. data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
  124. data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
  125. data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
  126. data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
  127. data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
  128. data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
  129. data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
  130. data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
  131. data/site/source/app/assets/stylesheets/site.css.scss +2 -0
  132. data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
  133. data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
  134. data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
  135. data/site/source/crossdomain.xml +15 -0
  136. data/site/source/documentation.html.haml +1 -0
  137. data/site/source/favicon_base.png +0 -0
  138. data/site/source/humans.txt +15 -0
  139. data/site/source/images/background.png +0 -0
  140. data/site/source/images/middleman.png +0 -0
  141. data/site/source/index.html.haml +1 -0
  142. data/site/source/layouts/layout.haml +55 -0
  143. data/site/source/readme.md +63 -0
  144. data/site/source/robots.txt +3 -0
  145. data/spec/javascripts/components/collection_view_spec.coffee +1 -1
  146. data/spec/javascripts/containers/card_view_spec.coffee +58 -5
  147. data/spec/javascripts/core/collection_spec.coffee +1 -1
  148. data/spec/javascripts/core/view_spec.coffee +2 -2
  149. data/vendor/assets/javascripts/backbone-min.js +37 -33
  150. data/vendor/assets/javascripts/backbone-query.min.js +1 -1
  151. data/vendor/assets/javascripts/jquery.js +5 -4
  152. data/vendor/assets/javascripts/luca-dependencies.min.js +8 -6
  153. data/vendor/assets/javascripts/luca-development.min.js +1 -1
  154. data/vendor/assets/javascripts/luca.full.min.js +12 -10
  155. data/vendor/assets/javascripts/luca.min.js +5 -5
  156. data/vendor/assets/javascripts/underscore-min.js +1 -5
  157. data/vendor/assets/javascripts/underscore-string.min.js +1 -1
  158. data/vendor/assets/stylesheets/luca-components.css +0 -2
  159. data/vendor/assets/stylesheets/luca-development.css +1 -1
  160. metadata +215 -39
  161. data/app/assets/javascripts/luca/components/page_controller.coffee +0 -3
  162. data/app/assets/javascripts/luca/core/collection_view.coffee +0 -150
  163. data/site/assets/bootstrap.min.js +0 -7
  164. data/site/assets/dependencies.js +0 -94
  165. data/site/assets/glyphicons-halflings-white.png +0 -0
  166. data/site/assets/glyphicons-halflings.png +0 -0
  167. data/site/assets/luca-ui-bootstrap.css +0 -1331
  168. data/site/assets/luca-ui-bootstrap.js +0 -9
  169. data/site/assets/luca-ui-development-tools.css +0 -234
  170. data/site/assets/luca-ui-development-tools.js +0 -18561
  171. data/site/assets/luca-ui-development-tools.min.js +0 -15
  172. data/site/assets/luca-ui-full.min.js +0 -8
  173. data/site/assets/luca-ui.min.js +0 -4
  174. data/site/assets/sandbox.css +0 -62
  175. data/site/assets/sandbox.js +0 -469
  176. data/site/docs/application.html +0 -41
  177. data/site/docs/caching.html +0 -43
  178. data/site/docs/collection.html +0 -75
  179. data/site/docs/collection_manager.html +0 -71
  180. data/site/docs/containers.html +0 -118
  181. data/site/docs/events.html +0 -153
  182. data/site/docs/view.html +0 -128
  183. data/site/img/glyphicons-halflings-white.png +0 -0
  184. data/site/img/glyphicons-halflings.png +0 -0
  185. data/site/index.html +0 -20
  186. data/site/source-map.js +0 -1
@@ -1,29 +1,70 @@
1
+ # The Controller is a special type of CardView that is used to provide structure to a Luca.Application. Each
2
+ # component in the controller is expected to have a unique `@name` property. The Application's router configuration
3
+ # will map URL / Hashbangs to the `@name`s of components that belong to the Application controller.
4
+ #
5
+ # Applications which structure their 'pages' in controllers, or sections, will have the names of which
6
+ # section or page is active inside of its state model. One example / common application structure we see:
7
+ #
8
+ # application:
9
+ # main_controller:
10
+ # controller / section_one:
11
+ # page_one
12
+ # page_two
13
+ # page_three
14
+ # controller / section_two
15
+ # page_alpha
16
+ # page_bravo
17
+ #
18
+ # In the above example, the Application would attempt to route to page_one, and the state
19
+ # of the application may look like:
20
+ #
21
+ # application.activeSection() #=> 'section_one'
22
+ # application.activeSubSection() # => 'page_one'
23
+ # application.activePage() # => page_one
24
+ #
1
25
  controller = Luca.register "Luca.components.Controller"
2
26
  controller.extends "Luca.containers.CardView"
3
27
 
4
- controller.publicInterface
28
+ controller.publicConfiguration
29
+ # If there is an active application, we will attempt to
30
+ # set the name of our currently activated page on the application's
31
+ # state machine. The attribute we will set can be configured by setting this value.
5
32
  tracker: "page"
6
33
 
34
+ # We will set the name of the active page / section on our DOM element
35
+ # The attribute we will set can be configured by setting this.
36
+ activeAttribute: "active-section"
37
+ stateful: true
38
+ defaultPage: undefined
39
+ defaultCard: 0
40
+
41
+ controller.publicMethods
42
+ # Navigate to the default ( or first ) component on this controller.
43
+ # This will automatically get called upon rendering, so that it sets up
44
+ # the proper state tracking, event binding, etc.
7
45
  default: (callback)->
8
46
  @navigate_to(@defaultPage || @defaultCard, callback)
9
47
 
48
+ # Returns the name of the component which is currently active
49
+ # on this controller.
10
50
  activePage: ()->
11
51
  @activeSection()
12
52
 
13
- navigate_to: (section, callback)->
14
- section ||= @defaultCard
53
+ # Navigate to a page on this controller by name. If passed an optional
54
+ # callback, the callback will be called within the context of the activated page.
55
+ navigate_to: (page, callback)->
56
+ page ||= @defaultCard
15
57
 
16
- @activate section, false, (activator, previous,current)=>
58
+ @activate page, false, (activator, previous,current)=>
17
59
  if current.activatedByController is true
18
60
  current.trigger("on:controller:reactivation")
19
61
  else
20
- current.trigger("on:controller:reactivation")
21
62
  current.trigger("on:controller:activation")
22
63
  current.activatedByController = true
23
64
 
24
65
  @state.set(active_section: current.name )
25
66
 
26
- if app = Luca.getApplication?()
67
+ if @tracker? and app = @app || Luca.getApplication?()
27
68
  app.state.set(@tracker, current.name)
28
69
 
29
70
  Luca.key?.setScope( current.name )
@@ -31,15 +72,37 @@ controller.publicInterface
31
72
  if _.isFunction( callback )
32
73
  callback.call(current)
33
74
 
34
- # return the section we are navigating to
35
- @find(section)
75
+ # return the component we are navigating to
76
+ @find(page)
36
77
 
37
78
  controller.classMethods
79
+ # For each component we control, if there is a keyEvents property defined
80
+ # then we will define a keymaster scope for that component's name, and setup
81
+ # bindings as directed. This is important because each time a controller
82
+ # activates a component, that component will attempt to change the scope of
83
+ # the keymaster so that components becomes responsible for handling detected key events.
38
84
  setupComponentKeyEvents: ()->
39
85
  @_().each (component)->
40
86
  if _.isObject(component.keyEvents) and component.name?
41
87
  Luca.util.setupKeymaster(component.keyEvents, component.name).on(component)
42
88
 
89
+ # The Controller Path is an array of the names of the controllers
90
+ # a given component belongs to. This method will get patched on to each
91
+ # component that belongs to a controller. It will always be bound to the instance
92
+ # of the component itself. Example:
93
+ #
94
+ # application.contains
95
+ # name: "main_controller"
96
+ # components: [
97
+ # name: "sub_controller"
98
+ # components:[
99
+ # name: "page"
100
+ # ]
101
+ # ]
102
+ #
103
+ # The @controllerPath() method for the component named page would be ['sub_controller','page'].
104
+ # This will be used internally by the Application route builder, so that each of page's parent
105
+ # controllers are activated in the proper order needed to make page visible.
43
106
  controllerPath: ()->
44
107
  component = @
45
108
 
@@ -57,9 +120,6 @@ controller.afterDefinition ()->
57
120
  Luca.View::hooks.push "on:controller:activation"
58
121
 
59
122
  controller.defines
60
- additionalClassNames: 'luca-ui-controller'
61
- activeAttribute: "active-section"
62
- stateful: true
63
123
 
64
124
  initialize: (@options)->
65
125
  # let's phase out the 'card' terminology
@@ -98,6 +158,7 @@ controller.defines
98
158
  @availableSections.apply(@, arguments)
99
159
 
100
160
  availableSections: ()->
161
+ console.log "The availableSections()/availablePages() method will be removed in 1.0"
101
162
  base = {}
102
163
  base[ @name ] = @sectionNames()
103
164
 
@@ -1,3 +1,9 @@
1
+ # The `Luca.core.Field` is an abstract base class for field components
2
+ # which are used in the `Luca.components.FormView`. They provide common
3
+ # functionality like getValue, setValue, change and validation event bindings.
4
+ #
5
+ # Additionally, the field component provides common Twitter Bootstrap styling
6
+ # hooks, such as error, warning, and success status flagging.
1
7
  field = Luca.register "Luca.core.Field"
2
8
 
3
9
  field.extends "Luca.View"
@@ -7,39 +13,83 @@ field.triggers "before:validation",
7
13
  "on:change"
8
14
 
9
15
  field.publicConfiguration
16
+ className: 'luca-ui-field'
17
+
18
+ # Controls whether or not this field is rendered in a disabled state
19
+ disabled: undefined
20
+
21
+ # Controls the bootstrap helperText value for this field control
22
+ helperText: undefined
23
+
24
+ # Text value for the label element that goes along with this field control
25
+ label: undefined
26
+
27
+ # Controls the positioning of the label element. Valid options are
28
+ # 'top', 'left'. For any other custom display you can control this
29
+ # on your own by specifying a template
10
30
  labelAlign: 'top'
11
- className: 'luca-ui-text-field luca-ui-field'
31
+
32
+ # Controls the value displayed in this field when it is in an untouched state
33
+ # by the user. Uses the html5 placeholder attribute
34
+ placeHolder: undefined
35
+
36
+ # Controls whether or not we want to display visual indicator
37
+ # that this field is required.
38
+ required: undefined
39
+
40
+ # Which statuses can be applied to this field? Valid options are taken
41
+ # from bootstrap state styling.
12
42
  statuses: [
13
43
  "warning"
14
44
  "error"
15
45
  "success"
16
46
  ]
17
47
 
18
- field.publicInterface
48
+ # What is the type of value that this field
49
+ # should have? You can use this to coerce the `getValue()` type
50
+ # into an integer, string, or float.
51
+ valueType: "string"
52
+
53
+
54
+
55
+ field.publicMethods
56
+ # Disable this field
19
57
  disable: ()->
20
58
  @getInputElement().attr('disabled', true)
21
59
 
60
+ # Enable this field
22
61
  enable: ()->
23
62
  @getInputElement().attr('disabled', false)
24
63
 
64
+ # Gets the value from the input element in this field control
25
65
  getValue: ()->
26
- @getParsedValue(@getInputElement()?.attr('value'))
66
+ raw = @getInputElement()?.val()
67
+ @getParsedValue(raw)
27
68
 
69
+ # Sets the value on the input element inside this field control
28
70
  setValue: (value)->
29
- @getInputElement()?.attr('value', value)
71
+ @getInputElement()?.val(value)
30
72
 
73
+ # Update the state of this field. Valid options are defined on
74
+ # this fields `@statuses` property
31
75
  updateState: (state)->
32
- _( @statuses ).each (cls)=>
33
- @$el.removeClass(cls)
76
+ for cssClass in @statuses
77
+ @$el.removeClass(cssClass)
78
+
34
79
  @$el.addClass(state)
35
80
 
81
+ # Remove any visual error indications from this field control
36
82
  clearErrors: ()->
37
83
  @$el.removeClass('error')
38
84
 
85
+ # Display a visual error state on this field
39
86
  displayErrors: (errors)->
40
87
  @updateState('error')
41
88
 
42
- field.methods
89
+ field.privateMethods
90
+ # Runs the value from the underlying input element
91
+ # through a type conversion process configured by
92
+ # the `@valueType` field
43
93
  getParsedValue: (raw)->
44
94
  return raw if _.str.isBlank( raw )
45
95
 
@@ -50,10 +100,11 @@ field.methods
50
100
  else raw
51
101
 
52
102
  field.privateConfiguration
103
+ # A convenience method for identifying field components
53
104
  isField: true
54
105
  template: 'fields/text_field'
55
106
 
56
- field.defines
107
+ field.privateMethods
57
108
  initialize: (@options={})->
58
109
  _.extend @, @options
59
110
 
@@ -89,3 +140,5 @@ field.defines
89
140
 
90
141
  getInputElement: ()->
91
142
  @input ||= @$('input').eq(0)
143
+
144
+ field.register()
@@ -1,3 +1,9 @@
1
+ # The `Luca.fields.ButtonField` provides an easy way to generate
2
+ # a button element, with an optional icon. Supports all of the
3
+ # available bootstrap icons, and color states.
4
+ #
5
+ # The `Luca.fields.ButtonField` component will typically be used as
6
+ # part of a `Luca.components.FormView` or a `Luca.components.PanelToolbar`.
1
7
  buttonField = Luca.register "Luca.fields.ButtonField"
2
8
 
3
9
  buttonField.extends "Luca.core.Field"
@@ -5,28 +11,62 @@ buttonField.extends "Luca.core.Field"
5
11
  buttonField.triggers "button:click"
6
12
 
7
13
  buttonField.publicConfiguration
14
+ # Which size should this button be? Valid options are:
15
+ # - none ( default )
16
+ # - large
17
+ # - mini
18
+ # - small
19
+ buttonSize: undefined
20
+
21
+ # Which bootstrap color class should we apply to this button?
22
+ # Valid options are any css button class, or the defaults which
23
+ # ship with bootstrap:
24
+ #
25
+ # - btn-primary
26
+ # - btn-info
27
+ # - btn-success
28
+ # - btn-warning
29
+ # - btn-danger
30
+ # - btn-inverse
31
+ # - btn-link
32
+ class: undefined
33
+
34
+ # specifies the bootstrap icon class you want to use for this button
35
+ # you can use 'icon-ok-sign' or just 'ok-sign'
36
+ icon_class: undefined
37
+
38
+ # specifies the text value of the button
39
+ label: undefined
40
+
41
+ # an alias for label, or input_value. controls which text
42
+ # displays inside of the button
43
+ text: undefined
44
+
45
+ # should we render the white icon?
46
+ white: false
47
+
48
+ buttonField.privateConfiguration
8
49
  readOnly: true
9
50
  input_value: undefined
10
51
  input_type: "button"
11
52
  icon_class: undefined
12
53
  input_name: undefined
13
- white: undefined
14
54
  buttonClasses: ""
15
55
 
16
56
  buttonField.privateConfiguration
17
57
  isButton: true
58
+ autoBindEventHandlers: true
18
59
  template: "fields/button_field"
19
60
  events:
20
- "click input" : "click_handler"
61
+ "click input" : "clickHandler"
21
62
 
22
- buttonField.privateInterface
23
- click_handler: (e)->
63
+ buttonField.privateMethods
64
+ clickHandler: (e)->
24
65
  me = my = $( e.currentTarget )
25
66
  @trigger "button:click"
26
67
 
27
68
  initialize: (@options={})->
28
- _.extend @options
29
- _.bindAll @, "click_handler"
69
+ _.extend @, @options
30
70
 
31
71
  Luca.core.Field::initialize.apply @, arguments
32
72
 
@@ -37,9 +77,15 @@ buttonField.privateInterface
37
77
  @input_name ||= @name ||= @input_id
38
78
  @input_value ||= @label ||= @text
39
79
  @input_class ||= @class ||= @buttonClasses
80
+
81
+ if @buttonSize?.length > 0
82
+ @input_class += " #{ buttonSize.replace(/btn-/,'') }"
83
+
40
84
  @icon_class ||= ""
41
85
  @icon_class = "icon-#{ @icon_class }" if @icon_class.length and !@icon_class.match(/^icon-/)
42
86
  @icon_class += " icon-white" if @white
43
87
 
44
- setValue: ()-> true
88
+ setValue: ()->
89
+ true
45
90
 
91
+ buttonField.register()
@@ -1,11 +1,10 @@
1
- make = Luca.View::make
2
-
1
+ # The `Luca.fields.CheckboxArray` renders an array of values
2
+ # into checkbox controls. This is for fields which can have
3
+ # a list of values associated with them.
3
4
  checkboxArray = Luca.register "Luca.fields.CheckboxArray"
4
5
  checkboxArray.extends "Luca.core.Field"
5
6
 
6
- checkboxArray.defines
7
- version: 2
8
-
7
+ checkboxArray.privateConfiguration
9
8
  template: "fields/checkbox_array"
10
9
 
11
10
  className: "luca-ui-checkbox-array"
@@ -15,6 +14,7 @@ checkboxArray.defines
15
14
 
16
15
  selectedItems: []
17
16
 
17
+ checkboxArray.privateMethods
18
18
  initialize: (@options={})->
19
19
  _.extend @, @options
20
20
  _.extend @, Luca.concerns.Deferrable
@@ -65,8 +65,8 @@ checkboxArray.defines
65
65
  label = model.get(@displayField)
66
66
  input_id = _.uniqueId("#{ @cid }_checkbox")
67
67
 
68
- inputElement = make("input",type:"checkbox",class:"array-checkbox",name:@input_name,value:value,id: input_id)
69
- element = make("label", {for:input_id}, inputElement)
68
+ inputElement = @make("input",type:"checkbox",class:"array-checkbox",name:@input_name,value:value,id: input_id)
69
+ element = @make("label", {for:input_id}, inputElement)
70
70
 
71
71
  $( element ).append(" #{ label }")
72
72
  @controls().append( element )
@@ -80,6 +80,9 @@ checkboxArray.defines
80
80
  allFields: ()->
81
81
  @controls().find("input[type='checkbox']")
82
82
 
83
+ checkboxArray.publicMethods
84
+ # Check the selected items. Expects an array of values
85
+ # for boxes you would like to see checked.
83
86
  checkSelected: (items)->
84
87
  @selectedItems = items if items?
85
88
 
@@ -91,6 +94,8 @@ checkboxArray.defines
91
94
 
92
95
  @selectedItems
93
96
 
97
+ # Gets an array of values for the checkboxes in this array
98
+ # which are checked.
94
99
  getValue: ()->
95
100
  @$(field).val() for field in @allFields() when @$(field).prop('checked')
96
101
 
@@ -2,7 +2,7 @@ textField = Luca.register 'Luca.fields.TextField'
2
2
  textField.extends 'Luca.core.Field'
3
3
 
4
4
  textField.defines
5
- _events:
5
+ _inheritEvents:
6
6
  "blur input" : "blur_handler"
7
7
  "focus input" : "focus_handler"
8
8
  "change input" : "change_handler"
@@ -96,7 +96,7 @@ formView.privateConfiguration
96
96
  # These events will get registered on the component
97
97
  # but still leave the @events property open to extend
98
98
  # for any component which inherits from us.
99
- _events:
99
+ _inheritEvents:
100
100
  "click .submit-button" : "submitHandler"
101
101
  "click .reset-button" : "resetHandler"
102
102
 
@@ -120,7 +120,7 @@ formView.privateMethods
120
120
 
121
121
  # have our events be internal to the view, and not
122
122
  # part of the normal @events chain, so they can be inherited
123
- for eventId, handler of @_events
123
+ for eventId, handler of @_inheritEvents
124
124
  @registerEvent(eventId, handler)
125
125
 
126
126
  if @trackDirtyState is true
@@ -36,7 +36,6 @@ gridView.privateMethods
36
36
  rowIndex = 0 if index > 0 and index % @itemsPerRow is 0
37
37
  row
38
38
 
39
- console.log "Appending rows", rows
40
39
  for row in rows
41
40
  @$append(row)
42
41
 
@@ -26,6 +26,7 @@ page.privateMethods
26
26
  initialize: (@options={})->
27
27
  @assignComponentsToRegions()
28
28
  @bodyTemplate = @options.layout || @layout
29
+ @bodyTemplate ||= @options.template || @template
29
30
  Luca.Container::initialize.apply(@, arguments)
30
31
 
31
32
  # Takes the configuration specified in @regions
@@ -67,7 +67,7 @@ tableView.classMethods
67
67
  content = column.header
68
68
  content = "<a class='link'>#{ column.header }</a>" if column.sortable
69
69
 
70
- @$(targetElement).find('tr').append( Backbone.View::make "th", attrs, content )
70
+ @$(targetElement).find('tr').append( Luca.View::make "th", attrs, content )
71
71
 
72
72
 
73
73
  index = 0
@@ -88,6 +88,6 @@ tableView.classMethods
88
88
  if _.isFunction( column.renderer )
89
89
  cellValue = column.renderer.call @, cellValue, model, column
90
90
 
91
- Backbone.View::make("td", {"data-col-index":index}, cellValue)
91
+ Luca.View::make("td", {"data-col-index":index}, cellValue)
92
92
 
93
93
  tableView.register()
@@ -46,10 +46,10 @@ Luca.concerns.DomHelpers =
46
46
  console.log "Error in $template: #{ template } #{ @identifier?() ? @name || @cid }"
47
47
 
48
48
  $html: (content)->
49
- @$el.html( content )
49
+ if content? then @$el.html(content) else @$el.html()
50
50
 
51
51
  $append: (content)->
52
- @$el.append( content )
52
+ @$el.append(content)
53
53
 
54
54
  $attach: ()->
55
55
  @$container().append( @el )
@@ -1,8 +1,3 @@
1
- component = Luca.define "Luca.containers.CardView"
2
- component.extends "Luca.Container"
3
-
4
- component.aliases "Luca.PageView"
5
- #
6
1
  # The CardView is a type of Container which has many sub-views
7
2
  # which are only going to be visible one at a time. A CardView
8
3
  # allows you to @activate() its cards, navigate through them using
@@ -23,72 +18,70 @@ component.aliases "Luca.PageView"
23
18
  # cardView.activeComponent().name # => "one"
24
19
  # cardView.activate('two')
25
20
  # cardView.activeComponent().name # => "two"
26
- #
27
- component.defaults
28
- activeCard: 0
21
+ component = Luca.register "Luca.containers.CardView"
22
+ component.extends "Luca.Container"
29
23
 
24
+ component.publicConfiguration
25
+ activeCard: 0
30
26
  components: []
31
27
 
28
+ component.classInterface
29
+ # When the activate method is called and passed a callback
30
+ # what context should we run that callback in? Default is
31
+ # to call the callback in the context of the component that
32
+ # is currently being activated
33
+ activationContext: "current"
34
+
35
+ component.privateConfiguration
36
+ # Will automatically call beforeCardSwitch and afterCardSwitch
37
+ # methods if they exist on this view. These events will be triggered
38
+ # in response to a call to @activate()
32
39
  hooks:[
33
40
  'before:card:switch',
34
41
  'after:card:switch'
35
42
  ]
36
43
 
44
+ # Which css class should we apply to each of the cards
37
45
  componentClass: 'luca-ui-card'
38
- generateComponentElements: true
39
-
40
- initialize: (@options)->
41
- @components ||= @pages ||= @cards
42
- Luca.Container::initialize.apply @,arguments
43
- @setupHooks(@hooks)
44
-
45
- @defer( @simulateActivationEvent, @ ).until("after:render")
46
-
47
- simulateActivationEvent: ()->
48
- c = @activeComponent()
49
46
 
50
- if c? and @$el.is(":visible")
51
- c?.trigger "activation", @, c, c
52
-
53
- prepareComponents: ()->
54
- Luca.Container::prepareComponents?.apply(@, arguments)
55
- @componentElements().hide()
56
- @activeComponentElement().show()
57
-
58
- activeComponentElement: ()->
59
- @componentElements().eq( @activeCard )
60
-
61
- activeComponent: ()->
62
- @getComponent( @activeCard )
63
-
64
- customizeContainerEl: (containerEl, panel, panelIndex)->
65
- containerEl.style += if panelIndex is @activeCard then "display:block;" else "display:none;"
66
-
67
- containerEl
47
+ # Should we generate elements to append each component?
48
+ generateComponentElements: true
68
49
 
50
+ component.publicMethods
51
+ # Returns true if at the first
69
52
  atFirst: ()->
70
53
  @activeCard is 0
71
54
 
55
+ # Returns true if we're at the last card
72
56
  atLast: ()->
73
57
  @activeCard is @components.length - 1
74
58
 
59
+ # Activate the next component. If at the last, do nothing.
75
60
  next: ()->
76
61
  return if @atLast()
77
62
  @activate( @activeCard + 1)
78
63
 
64
+ # Activate the previous component. If at the first, do nothing.
79
65
  previous: ()->
80
66
  return if @atFirst()
81
67
  @activate( @activeCard - 1)
82
68
 
69
+ # Activates the next component after the current one.
70
+ # If at the last component, it will activate the first.
83
71
  cycle: ()->
84
72
  nextIndex = if @atLast() then 0 else @activeCard + 1
85
73
  @activate( nextIndex )
86
74
 
87
- find: (name)-> Luca(name)
88
-
89
- firstActivation: ()->
90
- @activeComponent()?.trigger "first:activation", @, @activeComponent()
75
+ # Find a direct component on this card by its name.
76
+ find: (name)->
77
+ _( @components ).detect (c)->
78
+ c.name is name
91
79
 
80
+ # Activates the component at the specified index. You may optionally specify
81
+ # the name of the component you wish to activate. You can pass false as your second
82
+ # argument, to disable the event handling that occurs when you activate a card on this container.
83
+ # If you pass a callback function to the activate method, that callback will be executed within
84
+ # the context of the activated component.
92
85
  activate: (index, silent=false, callback)->
93
86
  if _.isFunction(silent)
94
87
  silent = false
@@ -97,14 +90,12 @@ component.defaults
97
90
  return if index is @activeCard
98
91
 
99
92
  previous = @activeComponent()
100
- current = @getComponent(index)
101
93
 
102
- if !current
103
- index = @indexOf(index)
104
- current = @getComponent( index )
94
+ current = @getComponent(index)
105
95
 
106
- unless current
107
- return
96
+ if !current?
97
+ index = @indexOf(index)
98
+ return unless current = @getComponent(index)
108
99
 
109
100
  unless silent is true
110
101
  @trigger "before:card:switch", previous, current
@@ -120,21 +111,18 @@ component.defaults
120
111
  if current.rendered is true
121
112
  current.trigger "first:activation"
122
113
  else
123
- current.defer ()->
114
+ current.once "after:render", ()->
115
+ current.rendered = true
124
116
  current.trigger("first:activation")
125
- .until current, "after:render"
126
-
127
117
  current.previously_activated = true
128
118
 
129
- @activeCard = index
119
+ @activeCard = index
130
120
  @activeComponentElement().show()
131
121
 
132
122
  unless silent is true
133
123
  @trigger "after:card:switch", previous, current
134
124
  previous?.trigger "deactivation", @, previous, current
135
- current?.trigger "on:deactivation", @, previous, current
136
125
  current?.trigger "activation", @, previous, current
137
- current?.trigger "on:activation", @, previous, current
138
126
 
139
127
  activationContext = @
140
128
 
@@ -144,5 +132,47 @@ component.defaults
144
132
  if _.isFunction(callback)
145
133
  callback.apply activationContext, [@,previous,current]
146
134
 
135
+ component.privateMethods
136
+ initialize: (@options)->
137
+ @components ||= @pages ||= @cards
138
+ Luca.Container::initialize.apply @,arguments
139
+ @setupHooks(@hooks)
140
+ @defer( @simulateActivationEvent, @ ).until("after:render")
141
+
142
+ # Simulates the activation event being triggered on the
143
+ # active component that gets rendered inside of this card view.
144
+ simulateActivationEvent: ()->
145
+ c = @activeComponent()
146
+
147
+ if c? and (@visible || @$el.is(":visible"))
148
+ c?.trigger "activation", @, c, c
149
+ if !c.previously_activated
150
+ c.trigger "first:activation"
151
+ c.previously_activated = true
152
+
153
+ prepareComponents: ()->
154
+ Luca.Container::prepareComponents?.apply(@, arguments)
155
+ @componentElements().hide()
156
+ @activeComponentElement().show()
157
+
158
+ activeComponentElement: ()->
159
+ @componentElements().eq( @activeCard )
160
+
161
+ activeComponent: ()->
162
+ @getComponent( @activeCard )
163
+
164
+ customizeContainerEl: (containerEl, panel, panelIndex)->
165
+ containerEl.style += if panelIndex is @activeCard then "display:block;" else "display:none;"
166
+
167
+ containerEl
168
+
169
+
170
+
171
+ # The first time activate event is triggered on this component
172
+ # the @firstActivation hook is responsible for relaying that event
173
+ # to our @activeComponent() so that it knows it has been activated.
174
+ firstActivation: ()->
175
+ if activeComponent = @activeComponent()
176
+ activeComponent.trigger "first:activation", @, @activeComponent()
147
177
 
148
- Luca.containers.CardView.activationContext = "current"
178
+ component.register()