luca 0.9.4 → 0.9.6
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.
- data/CHANGELOG +41 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +5 -0
- data/Rakefile +4 -0
- data/assets/javascripts/dependencies/underscore-min.js +5 -31
- data/assets/javascripts/luca-templates.js +1 -0
- data/assets/javascripts/luca-ui-base.coffee +1 -1
- data/assets/javascripts/luca-ui-development-tools.coffee +1 -1
- data/assets/javascripts/luca-ui-full.js +1 -1
- data/assets/javascripts/luca-ui-spec.coffee +1 -1
- data/assets/javascripts/luca-ui.js +3 -0
- data/assets/javascripts/luca/index.coffee +1 -0
- data/lib/generators/luca/application/application_generator.rb +71 -0
- data/lib/generators/luca/application/templates/controller.rb +6 -0
- data/lib/generators/luca/application/templates/index.html.erb +7 -0
- data/lib/generators/luca/application/templates/index.html.haml +6 -0
- data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
- data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
- data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
- data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
- data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
- data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
- data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
- data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
- data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/template.rb +1 -1
- data/spec/components/collection_view_spec.coffee +37 -0
- data/spec/components/multi_collection_view_spec.coffee +5 -0
- data/spec/components/table_view_spec.coffee +17 -0
- data/spec/core/container_spec.coffee +112 -5
- data/spec/core/model_spec.coffee +21 -3
- data/spec/define_spec.coffee +19 -0
- data/spec/mixin_spec.coffee +49 -0
- data/src/components/application.coffee +33 -19
- data/src/components/collection_view.coffee +109 -38
- data/src/components/fields/checkbox_field.coffee +2 -2
- data/src/components/fields/file_upload_field.coffee +0 -3
- data/src/components/fields/hidden_field.coffee +0 -3
- data/src/components/fields/label_field.coffee +1 -4
- data/src/components/fields/select_field.coffee +6 -6
- data/src/components/fields/text_area_field.coffee +1 -0
- data/src/components/fields/text_field.coffee +4 -0
- data/src/components/fields/type_ahead_field.coffee +5 -9
- data/src/components/form_view.coffee +2 -0
- data/src/components/index.coffee +1 -0
- data/src/components/multi_collection_view.coffee +94 -0
- data/src/components/pagination_control.coffee +100 -0
- data/src/components/table_view.coffee +62 -0
- data/src/containers/card_view.coffee +44 -11
- data/src/containers/panel_toolbar.coffee +88 -82
- data/src/containers/tab_view.coffee +3 -3
- data/src/containers/viewport.coffee +10 -4
- data/src/core/collection.coffee +11 -4
- data/src/core/container.coffee +189 -113
- data/src/core/field.coffee +13 -10
- data/src/core/model.coffee +23 -27
- data/src/core/registry.coffee +48 -35
- data/src/core/view.coffee +60 -140
- data/src/define.coffee +91 -19
- data/src/framework.coffee +10 -8
- data/src/index.coffee +23 -0
- data/src/managers/collection_manager.coffee +24 -8
- data/src/modules/application_event_bindings.coffee +19 -0
- data/src/modules/collection_event_bindings.coffee +26 -0
- data/src/modules/deferrable.coffee +3 -1
- data/src/modules/dom_helpers.coffee +49 -0
- data/src/modules/enhanced_properties.coffee +23 -0
- data/src/modules/filterable.coffee +60 -0
- data/src/modules/grid_layout.coffee +15 -0
- data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
- data/src/modules/modal_view.coffee +38 -0
- data/src/modules/paginatable.coffee +79 -0
- data/src/modules/state_model.coffee +16 -0
- data/src/modules/templating.coffee +8 -0
- data/src/plugins/events.coffee +30 -2
- data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
- data/src/templates/components/collection_loader_view.jst.ejs +6 -0
- data/src/templates/components/form_alert.jst.ejs +4 -0
- data/src/templates/components/grid_view.jst.ejs +11 -0
- data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
- data/src/templates/components/load_mask.jst.ejs +5 -0
- data/src/templates/components/nav_bar.jst.ejs +4 -0
- data/src/templates/components/pagination.jst.ejs +10 -0
- data/src/templates/containers/basic.jst.ejs +1 -0
- data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
- data/src/templates/containers/tab_view.jst.ejs +2 -0
- data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
- data/src/templates/fields/button_field.jst.ejs +2 -0
- data/src/templates/fields/button_field_link.jst.ejs +6 -0
- data/src/templates/fields/checkbox_array.jst.ejs +4 -0
- data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
- data/src/templates/fields/checkbox_field.jst.ejs +10 -0
- data/src/templates/fields/file_upload_field.jst.ejs +10 -0
- data/src/templates/fields/hidden_field.jst.ejs +1 -0
- data/src/templates/fields/select_field.jst.ejs +11 -0
- data/src/templates/fields/text_area_field.jst.ejs +11 -0
- data/src/templates/fields/text_field.jst.ejs +16 -0
- data/src/templates/table_view.jst.ejs +4 -0
- data/src/tools/console.coffee +51 -21
- data/src/util.coffee +17 -4
- data/vendor/assets/javascripts/luca-ui-base.js +3288 -613
- data/vendor/assets/javascripts/luca-ui-development-tools.js +49 -21
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
- data/vendor/assets/javascripts/luca-ui-full.js +1704 -554
- data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
- data/vendor/assets/javascripts/luca-ui-spec.js +1783 -830
- data/vendor/assets/javascripts/luca-ui-templates.js +92 -0
- data/vendor/assets/javascripts/luca-ui.js +1694 -523
- data/vendor/assets/javascripts/luca-ui.min.js +4 -4
- metadata +69 -31
- data/assets/javascripts/luca-ui.coffee +0 -3
- data/src/luca.coffee +0 -22
- data/src/templates/components/bootstrap_form_controls.luca +0 -7
- data/src/templates/components/collection_loader_view.luca +0 -5
- data/src/templates/components/form_alert +0 -0
- data/src/templates/components/form_alert.luca +0 -3
- data/src/templates/components/grid_view.luca +0 -7
- data/src/templates/components/grid_view_empty_text.luca +0 -3
- data/src/templates/components/load_mask.luca +0 -3
- data/src/templates/components/nav_bar.luca +0 -2
- data/src/templates/containers/basic.luca +0 -1
- data/src/templates/containers/tab_selector_container.luca +0 -8
- data/src/templates/containers/tab_view.luca +0 -2
- data/src/templates/containers/toolbar_wrapper.luca +0 -1
- data/src/templates/fields/button_field.luca +0 -2
- data/src/templates/fields/button_field_link.luca +0 -5
- data/src/templates/fields/checkbox_array.luca +0 -4
- data/src/templates/fields/checkbox_array_item.luca +0 -4
- data/src/templates/fields/checkbox_field.luca +0 -9
- data/src/templates/fields/file_upload_field.luca +0 -8
- data/src/templates/fields/hidden_field.luca +0 -1
- data/src/templates/fields/select_field.luca +0 -8
- data/src/templates/fields/text_area_field.luca +0 -8
- data/src/templates/fields/text_field.luca +0 -17
- data/src/templates/sample/contents.luca +0 -1
- data/src/templates/sample/welcome.luca +0 -1
- data/vendor/assets/javascripts/luca-spec-dependencies.js +0 -6135
- data/vendor/assets/javascripts/luca-ui-development-dependencies.js +0 -12845
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Luca.modules.GridLayout =
|
|
2
|
+
_initializer: ()->
|
|
3
|
+
if @gridSpan
|
|
4
|
+
@$el.addClass "span#{ @gridSpan }"
|
|
5
|
+
|
|
6
|
+
if @gridOffset
|
|
7
|
+
@$el.addClass "offset#{ @gridOffset }"
|
|
8
|
+
|
|
9
|
+
if @gridRowFluid
|
|
10
|
+
@$el.addClass "row-fluid"
|
|
11
|
+
|
|
12
|
+
if @gridRow
|
|
13
|
+
@$el.addClass "row"
|
|
14
|
+
|
|
15
|
+
# implement
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Luca.modules.LoadMaskable =
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
__initializer: ()->
|
|
3
|
+
return unless @loadMask is true
|
|
4
4
|
|
|
5
5
|
if @loadMask is true
|
|
6
6
|
@defer ()=>
|
|
@@ -11,8 +11,14 @@ Luca.modules.LoadMaskable =
|
|
|
11
11
|
@$('.load-mask').hide()
|
|
12
12
|
.until("after:render")
|
|
13
13
|
|
|
14
|
-
@on (@loadmaskEnableEvent || "enable:loadmask"), @applyLoadMask
|
|
15
|
-
@on (@loadmaskDisableEvent || "disable:loadmask"), @applyLoadMask
|
|
14
|
+
@on (@loadmaskEnableEvent || "enable:loadmask"), @applyLoadMask, @
|
|
15
|
+
@on (@loadmaskDisableEvent || "disable:loadmask"), @applyLoadMask, @
|
|
16
|
+
|
|
17
|
+
showLoadMask: ()->
|
|
18
|
+
@trigger("enable:loadmask")
|
|
19
|
+
|
|
20
|
+
hideLoadMask: ()->
|
|
21
|
+
@trigger("disable:loadmask")
|
|
16
22
|
|
|
17
23
|
loadMaskTarget: ()->
|
|
18
24
|
if @loadMaskEl? then @$(@loadMaskEl) else @$bodyEl()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
Luca.modules.ModalView =
|
|
2
|
+
closeOnEscape: true
|
|
3
|
+
|
|
4
|
+
showOnInitialize: false
|
|
5
|
+
|
|
6
|
+
backdrop: false
|
|
7
|
+
|
|
8
|
+
__initializer: ()->
|
|
9
|
+
@$el.addClass("modal")
|
|
10
|
+
|
|
11
|
+
@on "before:render", applyModalConfig, @
|
|
12
|
+
|
|
13
|
+
@
|
|
14
|
+
|
|
15
|
+
container: ()->
|
|
16
|
+
$('body')
|
|
17
|
+
|
|
18
|
+
toggle: ()->
|
|
19
|
+
@$el.modal('toggle')
|
|
20
|
+
|
|
21
|
+
show: ()->
|
|
22
|
+
@$el.modal('show')
|
|
23
|
+
|
|
24
|
+
hide: ()->
|
|
25
|
+
@$el.modal('hide')
|
|
26
|
+
|
|
27
|
+
applyModalConfig = ()->
|
|
28
|
+
@$el.addClass 'modal'
|
|
29
|
+
@$el.addClass 'fade' if @fade is true
|
|
30
|
+
|
|
31
|
+
$('body').append( @$el )
|
|
32
|
+
|
|
33
|
+
@$el.modal
|
|
34
|
+
backdrop: @backdrop is true
|
|
35
|
+
keyboard: @closeOnEscape is true
|
|
36
|
+
show: @showOnInitialize is true
|
|
37
|
+
|
|
38
|
+
@
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Luca.modules.Paginatable =
|
|
2
|
+
paginatorViewClass: 'Luca.components.PaginationControl'
|
|
3
|
+
paginationSelector: ".toolbar.bottom"
|
|
4
|
+
|
|
5
|
+
__included: ()->
|
|
6
|
+
_.extend(Luca.Collection::, __paginators: {})
|
|
7
|
+
|
|
8
|
+
__initializer:()->
|
|
9
|
+
return if @paginatable is false or not Luca.isBackboneCollection(@collection)
|
|
10
|
+
|
|
11
|
+
_.bindAll @, "paginationControl"
|
|
12
|
+
|
|
13
|
+
@getCollection ||= ()-> @collection
|
|
14
|
+
|
|
15
|
+
collection = @getCollection()
|
|
16
|
+
|
|
17
|
+
paginationState = @getPaginationState()
|
|
18
|
+
|
|
19
|
+
paginationState.on "change", (state)=>
|
|
20
|
+
@trigger "collection:change:pagination", state, collection
|
|
21
|
+
@trigger "refresh"
|
|
22
|
+
|
|
23
|
+
@on "after:refresh", (models, query, options)=>
|
|
24
|
+
_.defer ()=>
|
|
25
|
+
@updatePagination.call(@, models, query, options)
|
|
26
|
+
|
|
27
|
+
@on "after:render", ()=>
|
|
28
|
+
@paginationControl().refresh()
|
|
29
|
+
|
|
30
|
+
if old = @getQueryOptions
|
|
31
|
+
@getQueryOptions = ()->
|
|
32
|
+
_.extend( old(), paginationState.toJSON() )
|
|
33
|
+
else
|
|
34
|
+
@getQueryOptions = ()-> paginationState.toJSON()
|
|
35
|
+
|
|
36
|
+
getPaginationState: ()->
|
|
37
|
+
@collection.__paginators[ @cid ] ||= @paginationControl().state
|
|
38
|
+
|
|
39
|
+
paginationContainer: ()->
|
|
40
|
+
@$(">#{ @paginationSelector }")
|
|
41
|
+
|
|
42
|
+
setCurrentPage: (page=1, options={})->
|
|
43
|
+
@getPaginationState().set('page', page, options)
|
|
44
|
+
|
|
45
|
+
setLimit: (limit=0,options={})->
|
|
46
|
+
@getPaginationState().set('limit', limit, options)
|
|
47
|
+
|
|
48
|
+
updatePagination: (models=[], query={}, options={})->
|
|
49
|
+
_.defaults(options, @getQueryOptions(), limit: 0 )
|
|
50
|
+
|
|
51
|
+
paginator = @paginationControl()
|
|
52
|
+
|
|
53
|
+
itemCount = models?.length || 0
|
|
54
|
+
totalCount = @getCollection()?.length
|
|
55
|
+
|
|
56
|
+
if itemCount is 0 or totalCount <= options.limit
|
|
57
|
+
paginator.$el.hide()
|
|
58
|
+
else
|
|
59
|
+
paginator.$el.show()
|
|
60
|
+
|
|
61
|
+
paginator.state.set(page: options.page, limit: options.limit)
|
|
62
|
+
|
|
63
|
+
paginationControl: ()->
|
|
64
|
+
return @paginator if @paginator?
|
|
65
|
+
|
|
66
|
+
_.defaults(@paginatable ||= {}, page: 1, limit: 20)
|
|
67
|
+
|
|
68
|
+
@paginator = Luca.util.lazyComponent
|
|
69
|
+
type: "pagination_control"
|
|
70
|
+
collection: @getCollection()
|
|
71
|
+
defaultState: @paginatable
|
|
72
|
+
|
|
73
|
+
@paginator
|
|
74
|
+
|
|
75
|
+
renderPaginationControl: ()->
|
|
76
|
+
@paginationControl()
|
|
77
|
+
@paginationContainer().append @paginationControl().render().$el
|
|
78
|
+
|
|
79
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Luca.modules.StateModel =
|
|
2
|
+
__initializer: ()->
|
|
3
|
+
return unless @stateful is true
|
|
4
|
+
return if @state? and not Luca.isBackboneModel(@state)
|
|
5
|
+
|
|
6
|
+
@state = new Backbone.Model(@defaultState || {})
|
|
7
|
+
|
|
8
|
+
@set ||= ()=> @state.set.apply(@state, arguments)
|
|
9
|
+
@get ||= ()=> @state.get.apply(@state, arguments)
|
|
10
|
+
|
|
11
|
+
@state.on "change", (state)=>
|
|
12
|
+
@trigger "state:change", state
|
|
13
|
+
previousValues = state.previousAttributes()
|
|
14
|
+
for changed, value in state.changedAttributes
|
|
15
|
+
@trigger "state:change:#{ changed }", value, state.previous(changed)
|
|
16
|
+
|
data/src/plugins/events.coffee
CHANGED
|
@@ -21,10 +21,11 @@ class DeferredBindingProxy
|
|
|
21
21
|
throw "Must pass a function or a string representing one"
|
|
22
22
|
|
|
23
23
|
if wrapWithUnderscore is true
|
|
24
|
-
@fn = ()
|
|
24
|
+
@fn = _.bind ()->
|
|
25
25
|
_.defer(fn)
|
|
26
|
+
, @object
|
|
26
27
|
else
|
|
27
|
-
@fn = fn
|
|
28
|
+
@fn = _.bind(fn,@object)
|
|
28
29
|
|
|
29
30
|
@
|
|
30
31
|
|
|
@@ -41,6 +42,7 @@ class DeferredBindingProxy
|
|
|
41
42
|
@object
|
|
42
43
|
|
|
43
44
|
Luca.Events =
|
|
45
|
+
|
|
44
46
|
defer: (operation, wrapWithUnderscore=true)->
|
|
45
47
|
new DeferredBindingProxy(@, operation, wrapWithUnderscore)
|
|
46
48
|
|
|
@@ -52,3 +54,29 @@ Luca.Events =
|
|
|
52
54
|
@unbind(trigger, onceFn)
|
|
53
55
|
|
|
54
56
|
@bind trigger, onceFn
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Luca.EventsExt =
|
|
60
|
+
waitUntil:(trigger, context)->
|
|
61
|
+
@waitFor.call(@, trigger, context )
|
|
62
|
+
|
|
63
|
+
waitFor: (trigger, context)->
|
|
64
|
+
self = @
|
|
65
|
+
proxy =
|
|
66
|
+
on:(target)->
|
|
67
|
+
target.waitFor.call(target,trigger,context)
|
|
68
|
+
and:(runList...)->
|
|
69
|
+
for fn in runList
|
|
70
|
+
fn = if _.isFunction(fn) then fn else self[fn]
|
|
71
|
+
self.once(trigger, fn, context)
|
|
72
|
+
andThen: ()->
|
|
73
|
+
self.and.apply(self, arguments)
|
|
74
|
+
|
|
75
|
+
relayEvent: (trigger)->
|
|
76
|
+
on: (components...)=>
|
|
77
|
+
to: (targets...)=>
|
|
78
|
+
for target in targets
|
|
79
|
+
for component in components
|
|
80
|
+
component.on trigger, (args...)=>
|
|
81
|
+
args.unshift(trigger)
|
|
82
|
+
target.trigger.apply(target,args)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<div class="luca-ui-g-view-wrapper">
|
|
2
|
+
<div class="g-view-header"></div>
|
|
3
|
+
<div class="luca-ui-g-view-body">
|
|
4
|
+
<table class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>
|
|
5
|
+
<thead class="fixed"></thead>
|
|
6
|
+
<tbody class="scrollable"></tbody>
|
|
7
|
+
<tfoot></tfoot>
|
|
8
|
+
</table>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="luca-ui-g-view-header"></div>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div id="<%= id %>" class="<%= classes %>" style="<%= style %>"></div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<div id="<%= cid %>-tab-selector" class="tab-selector-container">
|
|
2
|
+
<ul id="<%= cid %>-tabs-nav" class="nav nav-tabs">
|
|
3
|
+
<% for(var i = 0; i < components.length; i++ ) { %>
|
|
4
|
+
<% var component = components[i];%>
|
|
5
|
+
<li class="tab-selector" data-target="<%= i %>">
|
|
6
|
+
<a data-target="<%= i %>">
|
|
7
|
+
<%= component.title %>
|
|
8
|
+
</a>
|
|
9
|
+
</li>
|
|
10
|
+
<% } %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="luca-ui-toolbar-wrapper" id="<%= id %>"></div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<label for="<%= input_id %>">
|
|
2
|
+
<%= label %>
|
|
3
|
+
<input type="checkbox" name="<%= input_name %>" value="<%= input_value %>" style="<%= inputStyles %>" />
|
|
4
|
+
</label>
|
|
5
|
+
|
|
6
|
+
<% if(helperText) { %>
|
|
7
|
+
<p class="helper-text help-block">
|
|
8
|
+
<%= helperText %>
|
|
9
|
+
</p>
|
|
10
|
+
<% } %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<input type="hidden" name="<%= input_name %>" value="<%= input_value %>" style="<%= inputStyles %>" />
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<label for="<%= input_id %>">
|
|
2
|
+
<%= label %>
|
|
3
|
+
</label>
|
|
4
|
+
<div class="controls">
|
|
5
|
+
<select name="<%= input_name %>" value="<%= input_value %>" style="<%= inputStyles %>" ></select>
|
|
6
|
+
<% if(helperText) { %>
|
|
7
|
+
<p class="helper-text help-block">
|
|
8
|
+
<%= helperText %>
|
|
9
|
+
</p>
|
|
10
|
+
<% } %>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<label for="<%= input_id %>">
|
|
2
|
+
<%= label %>
|
|
3
|
+
</label>
|
|
4
|
+
<div class="controls">
|
|
5
|
+
<textarea name="<%= input_name %>" style="<%= inputStyles %>" ><%= input_value %></textarea>
|
|
6
|
+
<% if(helperText) { %>
|
|
7
|
+
<p class="helper-text help-block">
|
|
8
|
+
<%= helperText %>
|
|
9
|
+
</p>
|
|
10
|
+
<% } %>
|
|
11
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {%>
|
|
2
|
+
<label class="control-label" for="<%= input_id %>"><%= label %></label>
|
|
3
|
+
<% } %>
|
|
4
|
+
|
|
5
|
+
<div class="controls">
|
|
6
|
+
<% if( typeof(addOn) !== "undefined" ) { %>
|
|
7
|
+
<span class="add-on"><%= addOn %></span>
|
|
8
|
+
<% } %>
|
|
9
|
+
<input type="text" name="<%= input_name %>" style="<%= inputStyles %>" value="<%= input_value %>" />
|
|
10
|
+
<% if(helperText) { %>
|
|
11
|
+
<p class="helper-text help-block">
|
|
12
|
+
<%= helperText %>
|
|
13
|
+
</p>
|
|
14
|
+
<% } %>
|
|
15
|
+
|
|
16
|
+
</div>
|
data/src/tools/console.coffee
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
readOnly: true
|
|
3
|
-
autoFocus: false
|
|
4
|
-
theme: "monokai"
|
|
5
|
-
mode: "javascript"
|
|
1
|
+
developmentConsole = Luca.register "Luca.tools.DevelopmentConsole"
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
developmentConsole.extends "Luca.core.Container"
|
|
4
|
+
|
|
5
|
+
developmentConsole.defines
|
|
8
6
|
className: "luca-ui-console"
|
|
9
7
|
name: "console"
|
|
10
8
|
history: []
|
|
11
9
|
historyIndex: 0
|
|
10
|
+
width: 1000
|
|
12
11
|
|
|
13
12
|
componentEvents:
|
|
14
|
-
"code_input key:keyup"
|
|
15
|
-
"code_input key:keydown"
|
|
16
|
-
"code_input key:enter"
|
|
13
|
+
"code_input key:keyup" : "historyUp"
|
|
14
|
+
"code_input key:keydown" : "historyDown"
|
|
15
|
+
"code_input key:enter" : "runCommand"
|
|
17
16
|
|
|
18
17
|
compileOptions:
|
|
19
18
|
bare: true
|
|
20
19
|
|
|
21
20
|
components:[
|
|
22
|
-
|
|
21
|
+
type: "code_mirror_field"
|
|
22
|
+
getter: "getCodeMirror"
|
|
23
23
|
additionalClassNames: "clearfix"
|
|
24
24
|
name: "code_output"
|
|
25
25
|
readOnly: true
|
|
@@ -28,8 +28,9 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
28
28
|
lineWrapping: true
|
|
29
29
|
gutter: false
|
|
30
30
|
,
|
|
31
|
-
|
|
31
|
+
type: "text_field"
|
|
32
32
|
name: "code_input"
|
|
33
|
+
getter: "getInput"
|
|
33
34
|
lineNumbers: false
|
|
34
35
|
height: '30px'
|
|
35
36
|
maxHeight: '30px'
|
|
@@ -57,7 +58,10 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
57
58
|
|
|
58
59
|
afterRender: ()->
|
|
59
60
|
@$container().modal(backdrop: false)
|
|
60
|
-
|
|
61
|
+
|
|
62
|
+
if @width?
|
|
63
|
+
marginLeft = parseInt(@width) * 0.5 * -1
|
|
64
|
+
@$container().css("width", @width).css('margin-left', parseInt(marginLeft) )
|
|
61
65
|
|
|
62
66
|
show: (options={})->
|
|
63
67
|
@$container().modal('show')
|
|
@@ -78,19 +82,19 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
78
82
|
@historyIndex -= 1
|
|
79
83
|
@historyIndex = 0 if @historyIndex < 0
|
|
80
84
|
|
|
81
|
-
currentValue =
|
|
82
|
-
|
|
85
|
+
currentValue = @getInput().getValue()
|
|
86
|
+
@getInput().setValue( @history[ @historyIndex ] || currentValue )
|
|
83
87
|
|
|
84
88
|
historyDown: ()->
|
|
85
89
|
@historyIndex += 1
|
|
86
90
|
@historyIndex = @history.length - 1 if @historyIndex > @history.length - 1
|
|
87
91
|
|
|
88
|
-
currentValue =
|
|
92
|
+
currentValue = @getInput().getValue()
|
|
89
93
|
|
|
90
|
-
|
|
94
|
+
@getInput().setValue( @history[ @historyIndex ] || currentValue)
|
|
91
95
|
|
|
92
96
|
append: (code, result, skipFormatting=false)->
|
|
93
|
-
output =
|
|
97
|
+
output = @getCodeMirror()
|
|
94
98
|
current = output.getValue()
|
|
95
99
|
|
|
96
100
|
source = "// #{ code }" if code?
|
|
@@ -105,7 +109,12 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
105
109
|
|
|
106
110
|
onSuccess: (result, js, coffee)->
|
|
107
111
|
@saveHistory(coffee)
|
|
108
|
-
|
|
112
|
+
|
|
113
|
+
dump = ""
|
|
114
|
+
|
|
115
|
+
if _.isArray( result ) or _.isObject( result ) or _.isString( result ) or _.isNumber(result)
|
|
116
|
+
dump = JSON.stringify(result, null, "\t")
|
|
117
|
+
|
|
109
118
|
dump ||= result.toString?()
|
|
110
119
|
|
|
111
120
|
@append(js, dump || "undefined")
|
|
@@ -117,7 +126,7 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
117
126
|
return unless code?.length > 0
|
|
118
127
|
|
|
119
128
|
raw = _.string.strip(raw)
|
|
120
|
-
output =
|
|
129
|
+
output = @getCodeMirror()
|
|
121
130
|
dev = @
|
|
122
131
|
|
|
123
132
|
evaluator = ()->
|
|
@@ -142,6 +151,13 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
142
151
|
|
|
143
152
|
try
|
|
144
153
|
result = evaluator.call( @getContext() )
|
|
154
|
+
|
|
155
|
+
# capture luca objects for special inspection
|
|
156
|
+
if Luca.isComponent( result )
|
|
157
|
+
result = Luca.util.inspectComponent( result )
|
|
158
|
+
else if Luca.isComponentPrototype( result )
|
|
159
|
+
result = Luca.util.inspectComponentPrototype( result )
|
|
160
|
+
|
|
145
161
|
@onSuccess(result, code, raw) unless raw.match(/^console\.log/)
|
|
146
162
|
catch error
|
|
147
163
|
@onError(error, code, raw)
|
|
@@ -149,20 +165,34 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
|
149
165
|
runCommand: ()->
|
|
150
166
|
dev = @
|
|
151
167
|
compile = _.bind(Luca.tools.CoffeeEditor::compile, @)
|
|
152
|
-
raw =
|
|
168
|
+
raw = @getInput().getValue()
|
|
153
169
|
compiled = compile raw, (compiled)->
|
|
154
170
|
dev.evaluateCode(compiled, raw)
|
|
155
171
|
|
|
156
172
|
Luca.util.launchers ||= {}
|
|
157
173
|
|
|
174
|
+
Luca.util.inspectComponentPrototype = (componentPrototype)->
|
|
175
|
+
liveInstances = Luca.registry.findInstancesByClass( componentPrototype )
|
|
176
|
+
|
|
177
|
+
Luca.util.inspectComponent = (component)->
|
|
178
|
+
component = Luca(component) if _.isString(component)
|
|
179
|
+
|
|
180
|
+
{
|
|
181
|
+
name: component.name
|
|
182
|
+
instanceOf: component.displayName
|
|
183
|
+
subclassOf: component._superClass()::displayName
|
|
184
|
+
inheritsFrom: Luca.parentClasses( component )
|
|
185
|
+
}
|
|
186
|
+
|
|
158
187
|
Luca.util.launchers.developmentConsole = (name="luca-development-console")->
|
|
159
188
|
@_lucaDevConsole = Luca name, ()=>
|
|
160
|
-
@$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade")
|
|
189
|
+
@$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade large")
|
|
161
190
|
|
|
162
191
|
console = new Luca.tools.DevelopmentConsole
|
|
163
192
|
name: name
|
|
164
193
|
container: "##{ name }-wrapper"
|
|
165
194
|
|
|
166
195
|
console.render()
|
|
196
|
+
console.getCodeMirror().setHeight(602)
|
|
167
197
|
|
|
168
198
|
@_lucaDevConsole.show()
|