luca 0.8.06 → 0.8.59
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +32 -1
- data/Guardfile +14 -9
- data/app.rb +1 -0
- data/assets/javascripts/sandbox/config.coffee +1 -1
- data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +6 -0
- data/lib/luca/rails/version.rb +1 -1
- data/spec/framework_spec.coffee +33 -1
- data/src/components/application.coffee +1 -3
- data/src/components/base_toolbar.coffee +5 -6
- data/src/components/collection_inspector.coffee +2 -0
- data/src/components/collection_loader_view.coffee +7 -6
- data/src/components/controller.coffee +3 -1
- data/src/components/development_console.coffee +7 -4
- data/src/components/fields/button_field.coffee +2 -5
- data/src/components/fields/checkbox_array.coffee +64 -0
- data/src/components/fields/checkbox_field.coffee +7 -10
- data/src/components/fields/file_upload_field.coffee +3 -6
- data/src/components/fields/hidden_field.coffee +4 -10
- data/src/components/fields/select_field.coffee +15 -18
- data/src/components/fields/text_area_field.coffee +5 -8
- data/src/components/fields/text_field.coffee +7 -14
- data/src/components/fields/type_ahead_field.coffee +4 -6
- data/src/components/form_button_toolbar.coffee +4 -4
- data/src/components/form_view.coffee +24 -10
- data/src/components/grid_view.coffee +80 -42
- data/src/components/record_manager.coffee +21 -22
- data/src/components/template.coffee +6 -8
- data/src/containers/card_view.coffee +2 -4
- data/src/containers/column_view.coffee +10 -12
- data/src/containers/modal_view.coffee +7 -9
- data/src/containers/panel_view.coffee +4 -4
- data/src/containers/split_view.coffee +3 -5
- data/src/containers/tab_view.coffee +3 -2
- data/src/containers/viewport.coffee +2 -3
- data/src/core/container.coffee +4 -4
- data/src/core/field.coffee +14 -13
- data/src/core/model.coffee +1 -1
- data/src/core/view.coffee +12 -3
- data/src/framework.coffee +134 -17
- data/src/managers/collection_manager.coffee +1 -1
- data/src/stylesheets/components/development_console.scss +5 -0
- data/src/templates/fields/checkbox_array.luca +5 -0
- data/src/templates/fields/checkbox_array_item.luca +4 -0
- data/vendor/assets/javascripts/luca-ui-base.js +155 -43
- data/vendor/assets/javascripts/luca-ui-spec.js +385 -133
- data/vendor/assets/javascripts/luca-ui.js +344 -132
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +4 -1
- data/vendor/assets/stylesheets/luca-ui-spec.css +4 -1
- data/vendor/assets/stylesheets/luca-ui.css +4 -1
- metadata +6 -2
@@ -1,4 +1,5 @@
|
|
1
|
-
Luca.components.FormView
|
1
|
+
_.component("Luca.components.FormView").extends('Luca.core.Container').with
|
2
|
+
|
2
3
|
tagName: 'form'
|
3
4
|
|
4
5
|
className: 'luca-ui-form-view'
|
@@ -93,8 +94,15 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
93
94
|
_( @components ).each (component)->
|
94
95
|
component.container = container
|
95
96
|
|
97
|
+
afterComponents: ()->
|
98
|
+
Luca.core.Container::afterComponents?.apply(@, arguments)
|
99
|
+
@eachField (field)=>
|
100
|
+
field.getForm = ()=> @
|
101
|
+
field.getModel = ()=> @currentModel()
|
102
|
+
|
96
103
|
render: ()->
|
97
104
|
$( @container ).append( @$el )
|
105
|
+
@
|
98
106
|
|
99
107
|
wrapper: ()->
|
100
108
|
@$el.parents('.luca-ui-form-view-wrapper')
|
@@ -108,6 +116,9 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
108
116
|
toolbar = Luca.util.lazyComponent(toolbar)
|
109
117
|
toolbar.render()
|
110
118
|
|
119
|
+
eachField: (iterator)->
|
120
|
+
_( @getFields() ).map( iterator )
|
121
|
+
|
111
122
|
getField: (name)->
|
112
123
|
_( @getFields('name', name) ).first()
|
113
124
|
|
@@ -147,7 +158,7 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
147
158
|
@trigger "after:load:#{ (if @current_model.isNew() then "new" else "existing")}", @, @current_model
|
148
159
|
|
149
160
|
reset: ()->
|
150
|
-
@loadModel( @current_model )
|
161
|
+
@loadModel( @current_model ) if @current_model?
|
151
162
|
|
152
163
|
clear: ()->
|
153
164
|
@current_model = if @defaultModel? then @defaultModel() else undefined
|
@@ -178,9 +189,7 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
178
189
|
|
179
190
|
@syncFormWithModel() unless options.silent? is true
|
180
191
|
|
181
|
-
getValues: (options)->
|
182
|
-
options ||= {}
|
183
|
-
|
192
|
+
getValues: (options={})->
|
184
193
|
options.reject_blank = true unless options.reject_blank?
|
185
194
|
options.skip_buttons = true unless options.skip_buttons?
|
186
195
|
|
@@ -189,9 +198,16 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
189
198
|
key = field.input_name || field.name
|
190
199
|
|
191
200
|
skip = false
|
201
|
+
|
202
|
+
# don't include the values of buttons in our values hash
|
192
203
|
skip = true if options.skip_buttons and field.ctype is "button_field"
|
193
|
-
|
194
|
-
|
204
|
+
|
205
|
+
# if the value is blank and we are passed reject_blank in the options
|
206
|
+
# then we should not include this field in our hash. however, if the
|
207
|
+
# field is setup to send blanks, then we will send this value anyway
|
208
|
+
if _.string.isBlank( value )
|
209
|
+
skip = true if options.reject_blank and !field.send_blanks
|
210
|
+
skip = true if field.input_name is "id"
|
195
211
|
|
196
212
|
memo[ key ] = value unless skip is true
|
197
213
|
|
@@ -230,6 +246,4 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
230
246
|
@current_model?.set( @getValues() )
|
231
247
|
|
232
248
|
setLegend: (@legend)->
|
233
|
-
$('fieldset legend', @el).first().html(@legend)
|
234
|
-
|
235
|
-
Luca.register 'form_view', 'Luca.components.FormView'
|
249
|
+
$('fieldset legend', @el).first().html(@legend)
|
@@ -1,12 +1,25 @@
|
|
1
|
-
Luca.components.GridView
|
1
|
+
_.component('Luca.components.GridView').extend('Luca.View').with
|
2
|
+
|
2
3
|
autoBindEventHandlers: true
|
3
4
|
|
4
5
|
events:
|
5
|
-
"dblclick
|
6
|
-
"click
|
6
|
+
"dblclick table tbody tr" : "double_click_handler"
|
7
|
+
"click table tbody tr": "click_handler"
|
7
8
|
|
8
9
|
className: 'luca-ui-g-view'
|
9
10
|
|
11
|
+
rowClass: "luca-ui-g-row"
|
12
|
+
|
13
|
+
wrapperClass: "luca-ui-g-view-wrapper"
|
14
|
+
|
15
|
+
# add whatever additional container classes you want
|
16
|
+
# to be applied to the wrapper here
|
17
|
+
additionalWrapperClasses: []
|
18
|
+
|
19
|
+
# add additional style declarations to the wrapper if you like
|
20
|
+
# these will be added by jquery.css and accept the same syntax
|
21
|
+
wrapperStyles: {}
|
22
|
+
|
10
23
|
scrollable: true
|
11
24
|
|
12
25
|
emptyText: 'No Results To display.'
|
@@ -15,49 +28,62 @@ Luca.components.GridView = Luca.View.extend
|
|
15
28
|
# or any combination of these, split up by space
|
16
29
|
tableStyle: 'striped'
|
17
30
|
|
31
|
+
# we have to specify height to make the scrollable table portion work
|
32
|
+
defaultHeight: 285
|
33
|
+
|
34
|
+
# unless we specify the width ourselves
|
35
|
+
# the width of the grid will automatically be set to the width of the container
|
36
|
+
# and if it can't be determined, then it will be set to the default
|
37
|
+
defaultWidth: 756
|
38
|
+
|
39
|
+
# the grid should never outgrow its container
|
40
|
+
maxWidth: undefined
|
41
|
+
|
42
|
+
# hooks is configuration sugar
|
43
|
+
# the before:grid:render trigger
|
44
|
+
# will automatically fire the
|
45
|
+
# beforeGridRender function
|
18
46
|
hooks:[
|
19
|
-
"before:grid:render"
|
20
|
-
"before:render:header"
|
21
|
-
"before:render:row"
|
22
|
-
"after:grid:render"
|
23
|
-
"row:double:click"
|
24
|
-
"row:click"
|
47
|
+
"before:grid:render"
|
48
|
+
"before:render:header"
|
49
|
+
"before:render:row"
|
50
|
+
"after:grid:render"
|
51
|
+
"row:double:click"
|
52
|
+
"row:click"
|
25
53
|
"after:collection:load"
|
26
54
|
]
|
27
55
|
|
28
|
-
rowClass: "luca-ui-g-row"
|
29
|
-
|
30
56
|
initialize: (@options={})->
|
31
57
|
_.extend @, @options
|
32
58
|
_.extend @, Luca.modules.Deferrable
|
33
59
|
|
34
60
|
Luca.View::initialize.apply( @, arguments )
|
35
61
|
|
36
|
-
_.bindAll @, "double_click_handler", "click_handler"
|
37
|
-
|
38
62
|
@configure_collection()
|
39
63
|
|
40
64
|
@collection.bind "reset", (collection) =>
|
41
65
|
@refresh()
|
42
66
|
@trigger "after:collection:load", collection
|
43
67
|
|
68
|
+
# if a model changes, then we will update the row's contents
|
69
|
+
# by rerendering that row's cells
|
70
|
+
@collection.bind "change", (model)=>
|
71
|
+
rowEl = @getRowEl( model.id || model.get('id') || model.cid )
|
72
|
+
cells = @render_row(model, @indexOf(model), cellsOnly: true )
|
73
|
+
$( rowEl ).html( cells )
|
74
|
+
|
44
75
|
beforeRender: ()->
|
45
76
|
@trigger "before:grid:render", @
|
46
77
|
|
47
|
-
@$el.addClass 'scrollable-g-view' if @scrollable
|
48
|
-
|
49
78
|
@$el.html Luca.templates["components/grid_view"]()
|
50
79
|
|
51
|
-
@table
|
52
|
-
@header
|
53
|
-
@body
|
54
|
-
@footer
|
80
|
+
@table = @$ 'table.luca-ui-g-view'
|
81
|
+
@header = @$ "thead"
|
82
|
+
@body = @$ "tbody"
|
83
|
+
@footer = @$ "tfoot"
|
84
|
+
@wrapper = @$ ".#{ @wrapperClass }"
|
55
85
|
|
56
|
-
|
57
|
-
@table.addClass('table')
|
58
|
-
|
59
|
-
_( @tableStyle?.split(" ") ).each (style)=>
|
60
|
-
@table.addClass("table-#{ style }")
|
86
|
+
@applyCssClasses()
|
61
87
|
|
62
88
|
@setDimensions() if @scrollable
|
63
89
|
|
@@ -69,6 +95,18 @@ Luca.components.GridView = Luca.View.extend
|
|
69
95
|
|
70
96
|
$(@container).append @$el
|
71
97
|
|
98
|
+
applyCssClasses: ()->
|
99
|
+
@$el.addClass 'scrollable-g-view' if @scrollable
|
100
|
+
|
101
|
+
_( @additionalWrapperClasses ).each (containerClass)=>
|
102
|
+
@wrapper?.addClass( containerClass )
|
103
|
+
|
104
|
+
if Luca.enableBootstrap
|
105
|
+
@table.addClass('table')
|
106
|
+
|
107
|
+
_( @tableStyle?.split(" ") ).each (style)=>
|
108
|
+
@table.addClass("table-#{ style }")
|
109
|
+
|
72
110
|
toolbarContainers:(position="bottom")->
|
73
111
|
$(".toolbar-container.#{ position }", @el)
|
74
112
|
|
@@ -78,24 +116,21 @@ Luca.components.GridView = Luca.View.extend
|
|
78
116
|
toolbar.container = @toolbarContainers( toolbar.position )
|
79
117
|
toolbar.render()
|
80
118
|
|
81
|
-
defaultWidth: 756
|
82
|
-
defaultHeight: 285
|
83
|
-
|
84
119
|
setDimensions: (offset)->
|
85
120
|
@height ||= @defaultHeight
|
86
121
|
|
87
|
-
|
88
|
-
|
122
|
+
@$('.luca-ui-g-view-body').height( @height )
|
123
|
+
@$('tbody.scrollable').height( @height - 23 )
|
89
124
|
|
90
125
|
@container_width = do => $(@container).width()
|
91
126
|
|
92
|
-
@width
|
93
|
-
@width = _([@width, (@maxWidth || @width)]).max()
|
127
|
+
@width ||= if @container_width > 0 then @container_width else @defaultWidth
|
94
128
|
|
95
|
-
|
129
|
+
# don't let the grid outgrow its maxWidth
|
130
|
+
@width = _([@width, (@maxWidth || @width)]).max()
|
96
131
|
|
97
|
-
|
98
|
-
|
132
|
+
@$('.luca-ui-g-view-body').width @width
|
133
|
+
@$('.luca-ui-g-view-body table').width @width
|
99
134
|
|
100
135
|
@setDefaultColumnWidths()
|
101
136
|
|
@@ -103,8 +138,8 @@ Luca.components.GridView = Luca.View.extend
|
|
103
138
|
difference = newWidth - @width
|
104
139
|
@width = newWidth
|
105
140
|
|
106
|
-
|
107
|
-
|
141
|
+
@$('.luca-ui-g-view-body').width( @width )
|
142
|
+
@$('.luca-ui-g-view-body table').width( @width )
|
108
143
|
|
109
144
|
if @columns.length > 0
|
110
145
|
distribution = difference / @columns.length
|
@@ -131,7 +166,6 @@ Luca.components.GridView = Luca.View.extend
|
|
131
166
|
|
132
167
|
@padLastColumn()
|
133
168
|
|
134
|
-
|
135
169
|
lastColumn: ()->
|
136
170
|
@columns[ @columns.length - 1 ]
|
137
171
|
|
@@ -175,7 +209,7 @@ Luca.components.GridView = Luca.View.extend
|
|
175
209
|
getRowEl: (id)->
|
176
210
|
@$ "[data-record-id=#{ id }]", 'table'
|
177
211
|
|
178
|
-
render_row: (row,row_index)->
|
212
|
+
render_row: (row,row_index, options={})->
|
179
213
|
rowClass = @rowClass
|
180
214
|
|
181
215
|
model_id = if row?.get and row?.attributes then row.get('id') else ''
|
@@ -190,11 +224,17 @@ Luca.components.GridView = Luca.View.extend
|
|
190
224
|
|
191
225
|
"<td style='#{ style }' class='column-#{ col_index }'>#{ display }</td>"
|
192
226
|
|
227
|
+
return cells if options.cellsOnly
|
228
|
+
|
193
229
|
altClass = ''
|
194
230
|
if @alternateRowClasses
|
195
231
|
altClass = if row_index % 2 is 0 then "even" else "odd"
|
196
232
|
|
197
|
-
|
233
|
+
content = "<tr data-record-id='#{ model_id }' data-row-index='#{ row_index }' class='#{ rowClass } #{ altClass }' id='row-#{ row_index }'>#{ cells }</tr>"
|
234
|
+
|
235
|
+
return content if options.contentOnly is true
|
236
|
+
|
237
|
+
@body?.append(content)
|
198
238
|
|
199
239
|
cell_renderer: (row, column, columnIndex )->
|
200
240
|
if _.isFunction column.renderer
|
@@ -218,6 +258,4 @@ Luca.components.GridView = Luca.View.extend
|
|
218
258
|
@trigger "row:click", @, record, rowIndex
|
219
259
|
|
220
260
|
$(".#{ @rowClass }", @body ).removeClass('selected-row')
|
221
|
-
me.addClass('selected-row')
|
222
|
-
|
223
|
-
Luca.register "grid_view","Luca.components.GridView"
|
261
|
+
me.addClass('selected-row')
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The RecordManager is a high level component which incorporates
|
2
2
|
# a filterable grid, and an editor form responsible for editing
|
3
|
-
# the records in that grid.
|
3
|
+
# the records in that grid.
|
4
4
|
#
|
5
5
|
# it provides convenience methods for accesing those components.
|
6
6
|
#
|
@@ -8,9 +8,8 @@
|
|
8
8
|
# which work together. inter-component communication should be handled
|
9
9
|
# by parent containers, and not individual components, which should
|
10
10
|
# usually not be aware of other components.
|
11
|
-
|
12
|
-
|
13
|
-
Luca.components.RecordManager = Luca.containers.CardView.extend
|
11
|
+
_.component('Luca.components.RecordManager')
|
12
|
+
.extend('Luca.containers.CardView').with
|
14
13
|
|
15
14
|
events:
|
16
15
|
"click .record-manager-grid .edit-link" : "edit_handler"
|
@@ -19,12 +18,12 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
19
18
|
"click .add-button" : "add_handler"
|
20
19
|
"click .refresh-button" : "filter_handler"
|
21
20
|
"click .back-to-search-button" : "back_to_search_handler"
|
22
|
-
|
21
|
+
|
23
22
|
record_manager: true
|
24
23
|
|
25
24
|
initialize: (@options={})->
|
26
25
|
Luca.containers.CardView::initialize.apply @, arguments
|
27
|
-
|
26
|
+
|
28
27
|
throw "Record Managers must specify a name" unless @name
|
29
28
|
|
30
29
|
_.bindAll @, "add_handler", "edit_handler", "filter_handler", "reset_filter_handler"
|
@@ -32,7 +31,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
32
31
|
_.extend @components[0][0], @filterConfig if @filterConfig
|
33
32
|
_.extend @components[0][1], @gridConfig if @gridConfig
|
34
33
|
_.extend @components[1][0], @editorConfig if @editorConfig
|
35
|
-
|
34
|
+
|
36
35
|
@bind "after:card:switch", () =>
|
37
36
|
@trigger("activation:search", @) if @activeCard is 0
|
38
37
|
@trigger("activation:editor", @) if @activeCard is 1
|
@@ -47,7 +46,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
47
46
|
]
|
48
47
|
,
|
49
48
|
ctype: 'form_view'
|
50
|
-
]
|
49
|
+
]
|
51
50
|
|
52
51
|
getSearch: (activate=false, reset=true)->
|
53
52
|
@activate(0) if activate is true
|
@@ -74,7 +73,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
74
73
|
beforeRender: ()->
|
75
74
|
@$el.addClass("#{ @resource }-manager")
|
76
75
|
Luca.containers.CardView::beforeRender?.apply @, arguments
|
77
|
-
|
76
|
+
|
78
77
|
@$el.addClass("#{ @resource } record-manager")
|
79
78
|
@$el.data('resource', @resource)
|
80
79
|
|
@@ -87,18 +86,18 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
87
86
|
# components are responsible for component communication.
|
88
87
|
#
|
89
88
|
# child components should not be aware of other components
|
90
|
-
# in the layout. Their parents should be responsible for
|
89
|
+
# in the layout. Their parents should be responsible for
|
91
90
|
# controlling how they interact. listening to events on one,
|
92
91
|
# changing state, inducing effects in the others
|
93
92
|
afterRender: ()->
|
94
|
-
Luca.containers.CardView::afterRender?.apply @, arguments
|
93
|
+
Luca.containers.CardView::afterRender?.apply @, arguments
|
95
94
|
|
96
95
|
manager = @
|
97
96
|
grid = @getGrid()
|
98
97
|
filter = @getFilter()
|
99
98
|
editor = @getEditor()
|
100
99
|
collection = @getCollection()
|
101
|
-
|
100
|
+
|
102
101
|
# when a row is double clicked on the grid
|
103
102
|
# then we edit that row
|
104
103
|
grid.bind "row:double:click", (grid,model,index)->
|
@@ -111,7 +110,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
111
110
|
|
112
111
|
editor.bind "after:submit", ()=>
|
113
112
|
$('.form-view-body', @el).spin(false)
|
114
|
-
|
113
|
+
|
115
114
|
editor.bind "after:submit:fatal_error", ()=>
|
116
115
|
$('.form-view-flash-container', @el ).append "<li class='error'>There was an internal server error saving this record. Please contact developers@benchprep.com to report this error.</li>"
|
117
116
|
$('.form-view-body', @el).spin(false)
|
@@ -119,10 +118,10 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
119
118
|
editor.bind "after:submit:error", (form, model, response)=>
|
120
119
|
_( response.errors ).each (error)=>
|
121
120
|
$('.form-view-flash-container', @el ).append "<li class='error'>#{ error }</li>"
|
122
|
-
|
121
|
+
|
123
122
|
editor.bind "after:submit:success", (form, model, response)=>
|
124
123
|
$('.form-view-flash-container', @el).append "<li class='success'>Successfully Saved Record</li>"
|
125
|
-
|
124
|
+
|
126
125
|
model.set( response.result )
|
127
126
|
form.loadModel( model )
|
128
127
|
|
@@ -132,13 +131,13 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
132
131
|
$('.form-view-flash-container li.success', @el).fadeOut(1000)
|
133
132
|
$('.form-view-flash-container', @el).html('')
|
134
133
|
, 4000
|
135
|
-
|
134
|
+
|
136
135
|
filter.eachComponent (component)=>
|
137
136
|
try
|
138
137
|
component.bind "on:change", @filter_handler
|
139
138
|
catch e
|
140
139
|
undefined
|
141
|
-
|
140
|
+
|
142
141
|
firstActivation: ()->
|
143
142
|
@getGrid().trigger "first:activation", @, @getGrid()
|
144
143
|
@getFilter().trigger "first:activation", @, @getGrid()
|
@@ -149,16 +148,16 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
149
148
|
grid = @getGrid()
|
150
149
|
filter = @getFilter()
|
151
150
|
editor = @getEditor()
|
152
|
-
|
151
|
+
|
153
152
|
# refresh the select fields in the filter
|
154
153
|
filter.clear()
|
155
154
|
|
156
155
|
grid.applyFilter()
|
157
|
-
|
156
|
+
|
158
157
|
manageRecord: (record_id)->
|
159
158
|
model = @getCollection().get(record_id)
|
160
159
|
return @loadModel(model) if model
|
161
|
-
|
160
|
+
|
162
161
|
console.log "Could Not Find Model, building and fetching"
|
163
162
|
|
164
163
|
model = @buildModel()
|
@@ -186,7 +185,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
186
185
|
createModel: ()->
|
187
186
|
@loadModel(@buildModel())
|
188
187
|
|
189
|
-
##### DOM Event Handlers
|
188
|
+
##### DOM Event Handlers
|
190
189
|
reset_filter_handler: (e)->
|
191
190
|
@getFilter().clear()
|
192
191
|
@getGrid().applyFilter( @getFilter().getValues() )
|
@@ -197,7 +196,7 @@ Luca.components.RecordManager = Luca.containers.CardView.extend
|
|
197
196
|
edit_handler: (e)->
|
198
197
|
me = my = $( e.currentTarget )
|
199
198
|
record_id = my.parents('tr').data('record-id')
|
200
|
-
|
199
|
+
|
201
200
|
if record_id
|
202
201
|
model = @getGrid().collection.get( record_id )
|
203
202
|
|
@@ -1,4 +1,7 @@
|
|
1
|
-
Luca.components.Template
|
1
|
+
_.component('Luca.components.Template').extends('Luca.View').with
|
2
|
+
|
3
|
+
templateContainer: "Luca.templates"
|
4
|
+
|
2
5
|
initialize: (@options={})->
|
3
6
|
Luca.View::initialize.apply @, arguments
|
4
7
|
throw "Templates must specify which template / markup to use" unless @template or @markup
|
@@ -6,14 +9,9 @@ Luca.components.Template = Luca.View.extend
|
|
6
9
|
if _.isString(@templateContainer)
|
7
10
|
@templateContainer = eval("(window || global).#{ @templateContainer }")
|
8
11
|
|
9
|
-
templateContainer: "Luca.templates"
|
10
|
-
|
11
12
|
beforeRender: ()->
|
12
|
-
@templateContainer = JST if _.isUndefined( @templateContainer)
|
13
|
+
@templateContainer = JST if _.isUndefined( @templateContainer)
|
13
14
|
@$el.html(@markup || @templateContainer[ @template ](@options) )
|
14
15
|
|
15
16
|
render: ()->
|
16
|
-
$(@container).append( @$el )
|
17
|
-
|
18
|
-
|
19
|
-
Luca.register "template", "Luca.components.Template"
|
17
|
+
$(@container).append( @$el )
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Luca.containers.CardView
|
1
|
+
_.component("Luca.containers.CardView").extends("Luca.core.Container").with
|
2
2
|
componentType: 'card_view'
|
3
3
|
|
4
4
|
className: 'luca-ui-card-view-wrapper'
|
@@ -88,6 +88,4 @@ Luca.containers.CardView = Luca.core.Container.extend
|
|
88
88
|
|
89
89
|
|
90
90
|
if _.isFunction(callback)
|
91
|
-
callback.apply @, [@,previous,current]
|
92
|
-
|
93
|
-
Luca.register 'card_view', "Luca.containers.CardView"
|
91
|
+
callback.apply @, [@,previous,current]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Luca.containers.ColumnView
|
1
|
+
_.component('Luca.containers.ColumnView').extends('Luca.core.Container').with
|
2
2
|
componentType: 'column_view'
|
3
3
|
|
4
4
|
className: 'luca-ui-column-view'
|
@@ -8,34 +8,34 @@ Luca.containers.ColumnView = Luca.core.Container.extend
|
|
8
8
|
initialize: (@options={})->
|
9
9
|
Luca.core.Container::initialize.apply @, arguments
|
10
10
|
@setColumnWidths()
|
11
|
-
|
11
|
+
|
12
12
|
componentClass: 'luca-ui-column'
|
13
13
|
|
14
14
|
containerTemplate: "containers/basic"
|
15
15
|
|
16
16
|
appendContainers: true
|
17
17
|
|
18
|
-
autoColumnWidths: ()->
|
18
|
+
autoColumnWidths: ()->
|
19
19
|
widths = []
|
20
20
|
|
21
|
-
_( @components.length ).times ()=>
|
21
|
+
_( @components.length ).times ()=>
|
22
22
|
widths.push( parseInt( 100 / @components.length ) )
|
23
23
|
|
24
24
|
widths
|
25
25
|
|
26
26
|
setColumnWidths: ()->
|
27
|
-
@columnWidths = if @layout?
|
28
|
-
_( @layout.split('/') ).map((v)-> parseInt(v) )
|
29
|
-
else
|
27
|
+
@columnWidths = if @layout?
|
28
|
+
_( @layout.split('/') ).map((v)-> parseInt(v) )
|
29
|
+
else
|
30
30
|
@autoColumnWidths()
|
31
31
|
|
32
32
|
@columnWidths = _( @columnWidths ).map (val)-> "#{ val }%"
|
33
|
-
|
33
|
+
|
34
34
|
beforeComponents: ()->
|
35
35
|
@debug "column_view before components"
|
36
36
|
_( @components ).each (component)->
|
37
37
|
component.ctype ||= "panel_view"
|
38
|
-
|
38
|
+
|
39
39
|
beforeLayout: ()->
|
40
40
|
@debug "column_view before layout"
|
41
41
|
|
@@ -43,6 +43,4 @@ Luca.containers.ColumnView = Luca.core.Container.extend
|
|
43
43
|
@components[index].float = "left"
|
44
44
|
@components[index].width = width
|
45
45
|
|
46
|
-
Luca.core.Container::beforeLayout?.apply @, arguments
|
47
|
-
|
48
|
-
Luca.register 'column_view', "Luca.containers.ColumnView"
|
46
|
+
Luca.core.Container::beforeLayout?.apply @, arguments
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Luca.containers.ModalView
|
1
|
+
_.component('Luca.containers.ModalView').extends('Luca.core.Container').with
|
2
2
|
componentType: 'modal_view'
|
3
3
|
|
4
4
|
className: 'luca-ui-modal-view'
|
@@ -22,18 +22,18 @@ Luca.containers.ModalView = Luca.core.Container.extend
|
|
22
22
|
opacity: 80
|
23
23
|
onOpen: (modal)->
|
24
24
|
@onOpen.apply @
|
25
|
-
@onModalOpen.apply modal, [modal, @]
|
26
|
-
onClose: (modal)->
|
25
|
+
@onModalOpen.apply modal, [modal, @]
|
26
|
+
onClose: (modal)->
|
27
27
|
@onClose.apply @
|
28
28
|
@onModalClose.apply modal, [modal, @]
|
29
|
-
|
29
|
+
|
30
30
|
modalOptions: {}
|
31
31
|
|
32
32
|
initialize: (@options={})->
|
33
33
|
Luca.core.Container::initialize.apply @,arguments
|
34
34
|
@setupHooks(@hooks)
|
35
35
|
|
36
|
-
_( @defaultModalOptions ).each (value,setting) => @modalOptions[ setting ] ||= value
|
36
|
+
_( @defaultModalOptions ).each (value,setting) => @modalOptions[ setting ] ||= value
|
37
37
|
|
38
38
|
@modalOptions.onOpen = _.bind( @modalOptions.onOpen, @)
|
39
39
|
@modalOptions.onClose = _.bind( @modalOptions.onClose, @)
|
@@ -66,7 +66,7 @@ Luca.containers.ModalView = Luca.core.Container.extend
|
|
66
66
|
object.container = @el
|
67
67
|
object
|
68
68
|
|
69
|
-
afterInitialize: ()->
|
69
|
+
afterInitialize: ()->
|
70
70
|
@$el.hide()
|
71
71
|
@render() if @renderOnInitialize
|
72
72
|
|
@@ -80,6 +80,4 @@ Luca.containers.ModalView = Luca.core.Container.extend
|
|
80
80
|
@$el.modal( @modalOptions )
|
81
81
|
|
82
82
|
hide: ()->
|
83
|
-
@trigger "before:hide", @
|
84
|
-
|
85
|
-
Luca.register "modal_view","Luca.containers.ModalView"
|
83
|
+
@trigger "before:hide", @
|
@@ -1,13 +1,13 @@
|
|
1
|
-
Luca.containers.PanelView
|
1
|
+
_.component('Luca.containers.PanelView').extends('Luca.core.Container').with
|
2
2
|
className: 'luca-ui-panel'
|
3
3
|
|
4
4
|
initialize: (@options={})->
|
5
5
|
Luca.core.Container::initialize.apply @, arguments
|
6
|
-
|
6
|
+
|
7
7
|
afterLayout: ()->
|
8
8
|
if @template
|
9
9
|
contents = ( Luca.templates || JST )[ @template ]( @ )
|
10
|
-
@$el.html(contents)
|
10
|
+
@$el.html(contents)
|
11
11
|
|
12
12
|
render: ()->
|
13
13
|
$(@container).append @$el
|
@@ -19,5 +19,5 @@ Luca.containers.PanelView = Luca.core.Container.extend
|
|
19
19
|
@$el.css(property,value)
|
20
20
|
|
21
21
|
|
22
|
-
|
22
|
+
|
23
23
|
|
@@ -1,12 +1,10 @@
|
|
1
|
-
Luca.containers.SplitView
|
1
|
+
_.component('Luca.containers.SplitView').extends('Luca.core.Container').with
|
2
2
|
layout: '100'
|
3
3
|
|
4
4
|
componentType: 'split_view'
|
5
5
|
|
6
6
|
containerTemplate: 'containers/basic'
|
7
7
|
|
8
|
-
className: 'luca-ui-split-view'
|
9
|
-
|
10
|
-
componentClass: 'luca-ui-panel'
|
8
|
+
className: 'luca-ui-split-view'
|
11
9
|
|
12
|
-
|
10
|
+
componentClass: 'luca-ui-panel'
|
@@ -1,4 +1,5 @@
|
|
1
|
-
Luca.containers.TabView
|
1
|
+
_.component('Luca.containers.TabView').extends('Luca.containers.CardView').with
|
2
|
+
|
2
3
|
events:
|
3
4
|
"click ul.nav-tabs li" : "select"
|
4
5
|
|
@@ -23,7 +24,7 @@ Luca.containers.TabView = Luca.containers.CardView.extend
|
|
23
24
|
@bind "after:card:switch", @highlightSelectedTab
|
24
25
|
|
25
26
|
activeTabSelector: ()->
|
26
|
-
@tabSelectors().eq( @activeCard )
|
27
|
+
@tabSelectors().eq( @activeCard || @activeTab || @activeItem )
|
27
28
|
|
28
29
|
prepareLayout: ()->
|
29
30
|
@card_containers = _( @cards ).map (card, index)=>
|
@@ -1,4 +1,5 @@
|
|
1
|
-
Luca.containers.Viewport
|
1
|
+
_.component('Luca.containers.Viewport').extend('Luca.containers.CardView').with
|
2
|
+
|
2
3
|
activeItem: 0
|
3
4
|
|
4
5
|
className: 'luca-ui-viewport'
|
@@ -7,10 +8,8 @@ Luca.containers.Viewport = Luca.containers.CardView.extend
|
|
7
8
|
|
8
9
|
initialize: (@options={})->
|
9
10
|
Luca.core.Container::initialize.apply(@, arguments)
|
10
|
-
|
11
11
|
$('html,body').addClass('luca-ui-fullscreen') if @fullscreen
|
12
12
|
|
13
13
|
render: ()->
|
14
|
-
console.log "Rendering Viewport"
|
15
14
|
@$el.addClass('luca-ui-viewport')
|
16
15
|
|