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.
Files changed (144) hide show
  1. data/CHANGELOG +41 -1
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +2 -0
  4. data/README.md +5 -0
  5. data/Rakefile +4 -0
  6. data/assets/javascripts/dependencies/underscore-min.js +5 -31
  7. data/assets/javascripts/luca-templates.js +1 -0
  8. data/assets/javascripts/luca-ui-base.coffee +1 -1
  9. data/assets/javascripts/luca-ui-development-tools.coffee +1 -1
  10. data/assets/javascripts/luca-ui-full.js +1 -1
  11. data/assets/javascripts/luca-ui-spec.coffee +1 -1
  12. data/assets/javascripts/luca-ui.js +3 -0
  13. data/assets/javascripts/luca/index.coffee +1 -0
  14. data/lib/generators/luca/application/application_generator.rb +71 -0
  15. data/lib/generators/luca/application/templates/controller.rb +6 -0
  16. data/lib/generators/luca/application/templates/index.html.erb +7 -0
  17. data/lib/generators/luca/application/templates/index.html.haml +6 -0
  18. data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
  19. data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
  20. data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
  21. data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
  22. data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
  23. data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
  24. data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
  25. data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
  26. data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
  27. data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
  28. data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
  29. data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
  30. data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
  31. data/lib/luca/rails/version.rb +1 -1
  32. data/lib/luca/template.rb +1 -1
  33. data/spec/components/collection_view_spec.coffee +37 -0
  34. data/spec/components/multi_collection_view_spec.coffee +5 -0
  35. data/spec/components/table_view_spec.coffee +17 -0
  36. data/spec/core/container_spec.coffee +112 -5
  37. data/spec/core/model_spec.coffee +21 -3
  38. data/spec/define_spec.coffee +19 -0
  39. data/spec/mixin_spec.coffee +49 -0
  40. data/src/components/application.coffee +33 -19
  41. data/src/components/collection_view.coffee +109 -38
  42. data/src/components/fields/checkbox_field.coffee +2 -2
  43. data/src/components/fields/file_upload_field.coffee +0 -3
  44. data/src/components/fields/hidden_field.coffee +0 -3
  45. data/src/components/fields/label_field.coffee +1 -4
  46. data/src/components/fields/select_field.coffee +6 -6
  47. data/src/components/fields/text_area_field.coffee +1 -0
  48. data/src/components/fields/text_field.coffee +4 -0
  49. data/src/components/fields/type_ahead_field.coffee +5 -9
  50. data/src/components/form_view.coffee +2 -0
  51. data/src/components/index.coffee +1 -0
  52. data/src/components/multi_collection_view.coffee +94 -0
  53. data/src/components/pagination_control.coffee +100 -0
  54. data/src/components/table_view.coffee +62 -0
  55. data/src/containers/card_view.coffee +44 -11
  56. data/src/containers/panel_toolbar.coffee +88 -82
  57. data/src/containers/tab_view.coffee +3 -3
  58. data/src/containers/viewport.coffee +10 -4
  59. data/src/core/collection.coffee +11 -4
  60. data/src/core/container.coffee +189 -113
  61. data/src/core/field.coffee +13 -10
  62. data/src/core/model.coffee +23 -27
  63. data/src/core/registry.coffee +48 -35
  64. data/src/core/view.coffee +60 -140
  65. data/src/define.coffee +91 -19
  66. data/src/framework.coffee +10 -8
  67. data/src/index.coffee +23 -0
  68. data/src/managers/collection_manager.coffee +24 -8
  69. data/src/modules/application_event_bindings.coffee +19 -0
  70. data/src/modules/collection_event_bindings.coffee +26 -0
  71. data/src/modules/deferrable.coffee +3 -1
  72. data/src/modules/dom_helpers.coffee +49 -0
  73. data/src/modules/enhanced_properties.coffee +23 -0
  74. data/src/modules/filterable.coffee +60 -0
  75. data/src/modules/grid_layout.coffee +15 -0
  76. data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
  77. data/src/modules/modal_view.coffee +38 -0
  78. data/src/modules/paginatable.coffee +79 -0
  79. data/src/modules/state_model.coffee +16 -0
  80. data/src/modules/templating.coffee +8 -0
  81. data/src/plugins/events.coffee +30 -2
  82. data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
  83. data/src/templates/components/collection_loader_view.jst.ejs +6 -0
  84. data/src/templates/components/form_alert.jst.ejs +4 -0
  85. data/src/templates/components/grid_view.jst.ejs +11 -0
  86. data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
  87. data/src/templates/components/load_mask.jst.ejs +5 -0
  88. data/src/templates/components/nav_bar.jst.ejs +4 -0
  89. data/src/templates/components/pagination.jst.ejs +10 -0
  90. data/src/templates/containers/basic.jst.ejs +1 -0
  91. data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
  92. data/src/templates/containers/tab_view.jst.ejs +2 -0
  93. data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
  94. data/src/templates/fields/button_field.jst.ejs +2 -0
  95. data/src/templates/fields/button_field_link.jst.ejs +6 -0
  96. data/src/templates/fields/checkbox_array.jst.ejs +4 -0
  97. data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
  98. data/src/templates/fields/checkbox_field.jst.ejs +10 -0
  99. data/src/templates/fields/file_upload_field.jst.ejs +10 -0
  100. data/src/templates/fields/hidden_field.jst.ejs +1 -0
  101. data/src/templates/fields/select_field.jst.ejs +11 -0
  102. data/src/templates/fields/text_area_field.jst.ejs +11 -0
  103. data/src/templates/fields/text_field.jst.ejs +16 -0
  104. data/src/templates/table_view.jst.ejs +4 -0
  105. data/src/tools/console.coffee +51 -21
  106. data/src/util.coffee +17 -4
  107. data/vendor/assets/javascripts/luca-ui-base.js +3288 -613
  108. data/vendor/assets/javascripts/luca-ui-development-tools.js +49 -21
  109. data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
  110. data/vendor/assets/javascripts/luca-ui-full.js +1704 -554
  111. data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
  112. data/vendor/assets/javascripts/luca-ui-spec.js +1783 -830
  113. data/vendor/assets/javascripts/luca-ui-templates.js +92 -0
  114. data/vendor/assets/javascripts/luca-ui.js +1694 -523
  115. data/vendor/assets/javascripts/luca-ui.min.js +4 -4
  116. metadata +69 -31
  117. data/assets/javascripts/luca-ui.coffee +0 -3
  118. data/src/luca.coffee +0 -22
  119. data/src/templates/components/bootstrap_form_controls.luca +0 -7
  120. data/src/templates/components/collection_loader_view.luca +0 -5
  121. data/src/templates/components/form_alert +0 -0
  122. data/src/templates/components/form_alert.luca +0 -3
  123. data/src/templates/components/grid_view.luca +0 -7
  124. data/src/templates/components/grid_view_empty_text.luca +0 -3
  125. data/src/templates/components/load_mask.luca +0 -3
  126. data/src/templates/components/nav_bar.luca +0 -2
  127. data/src/templates/containers/basic.luca +0 -1
  128. data/src/templates/containers/tab_selector_container.luca +0 -8
  129. data/src/templates/containers/tab_view.luca +0 -2
  130. data/src/templates/containers/toolbar_wrapper.luca +0 -1
  131. data/src/templates/fields/button_field.luca +0 -2
  132. data/src/templates/fields/button_field_link.luca +0 -5
  133. data/src/templates/fields/checkbox_array.luca +0 -4
  134. data/src/templates/fields/checkbox_array_item.luca +0 -4
  135. data/src/templates/fields/checkbox_field.luca +0 -9
  136. data/src/templates/fields/file_upload_field.luca +0 -8
  137. data/src/templates/fields/hidden_field.luca +0 -1
  138. data/src/templates/fields/select_field.luca +0 -8
  139. data/src/templates/fields/text_area_field.luca +0 -8
  140. data/src/templates/fields/text_field.luca +0 -17
  141. data/src/templates/sample/contents.luca +0 -1
  142. data/src/templates/sample/welcome.luca +0 -1
  143. data/vendor/assets/javascripts/luca-spec-dependencies.js +0 -6135
  144. 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
- _included: (self, module)->
3
- _.bindAll self, "applyLoadMask", "disableLoadMask"
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
+
@@ -0,0 +1,8 @@
1
+ Luca.modules.Templating =
2
+ __initializer: ()->
3
+ templateVars = Luca.util.read.call(@, @bodyTemplateVars) || {}
4
+
5
+ if template = @bodyTemplate
6
+ @$el.empty()
7
+ templateContent = Luca.template(template, templateVars)
8
+ Luca.View::$html.call(@, templateContent)
@@ -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,10 @@
1
+ <div class="btn-group form-actions">
2
+ <a class="btn btn-primary submit-button">
3
+ <i class="icon icon-ok icon-white"></i>
4
+ Save Changes
5
+ </a>
6
+ <a class="btn reset-button cancel-button">
7
+ <i class="icon icon-remove"></i>
8
+ Cancel
9
+ </a>
10
+ </div>
@@ -0,0 +1,6 @@
1
+ <div id="progress-modal" class="modal" style="display: none">
2
+ <div class="progress progress-info progress-striped active">
3
+ <div class="bar" style="width:0%;"></div>
4
+ </div>
5
+ <div class="message">Initializing...</div>
6
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="<%= className %>">
2
+ <a class="close" href="#" data-dismiss="alert">x</a>
3
+ <%= message %>
4
+ </div>
@@ -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,3 @@
1
+ <div class="empty-text empty-text-wrapper">
2
+ <p><%= text %></p>
3
+ </div>
@@ -0,0 +1,5 @@
1
+ <div class="load-mask">
2
+ <div class="progress progress-striped active">
3
+ <div class="bar" style="width:0%"></div>
4
+ </div>
5
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="navbar-inner">
2
+ <div class="luca-ui-navbar-body container">
3
+ </div>
4
+ </div>
@@ -0,0 +1,10 @@
1
+ <div class="pagination">
2
+ <a class="btn previous">
3
+ <i class="icon icon-chevron-left"></i>
4
+ </a>
5
+ <div class="pagination-group">
6
+ </div>
7
+ <a class="btn next">
8
+ <i class="icon icon-chevron-right"></i>
9
+ </a>
10
+ </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,2 @@
1
+ <ul id="<%= cid %>-tabs-selector" class="nav <%= navClass %>"></ul>
2
+ <div id="<%= cid %>-tab-view-content" class="tab-content"></div>
@@ -0,0 +1 @@
1
+ <div class="luca-ui-toolbar-wrapper" id="<%= id %>"></div>
@@ -0,0 +1,2 @@
1
+ <label>&nbsp;</label>
2
+ <input style="<%= inputStyles %>" class="btn <%= input_class %>" value="<%= input_value %>" type="<%= input_type %>" id="<%= input_id" />
@@ -0,0 +1,6 @@
1
+ <a class="btn <%= input_class %>">
2
+ <% if(icon_class.length) { %>
3
+ <i class="<%= icon_class %>"></i>
4
+ <%= input_value %>
5
+ <% } %>
6
+ </a>
@@ -0,0 +1,4 @@
1
+ <div class="control-group">
2
+ <label for="<%= input_id %>"><%= label =>
3
+ <div class="controls"><div>
4
+ </div>
@@ -0,0 +1,3 @@
1
+ <label for="<%= input_id %>">
2
+ <input id="<%= input_id %>" type="checkbox" name="<%= input_name %>" value="<%= value %>" />
3
+ </label>
@@ -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,10 @@
1
+ <label for="<%= input_id %>">
2
+ <%= label %>
3
+ <input type="file" 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>
@@ -0,0 +1,4 @@
1
+ <thead></thead>
2
+ <tbody class="table-body"></tbody>
3
+ <tfoot></tfoot>
4
+ <caption></caption>
@@ -1,25 +1,25 @@
1
- codeMirrorOptions =
2
- readOnly: true
3
- autoFocus: false
4
- theme: "monokai"
5
- mode: "javascript"
1
+ developmentConsole = Luca.register "Luca.tools.DevelopmentConsole"
6
2
 
7
- Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
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" : "historyUp"
15
- "code_input key:keydown" : "historyDown"
16
- "code_input key:enter" : "runCommand"
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
- ctype: "code_mirror_field"
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
- ctype: "text_field"
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
- @$container.css
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 = Luca("code_input").getValue()
82
- Luca("code_input").setValue( @history[ @historyIndex ] || currentValue )
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 = Luca("code_input").getValue()
92
+ currentValue = @getInput().getValue()
89
93
 
90
- Luca("code_input").setValue( @history[ @historyIndex ] || currentValue)
94
+ @getInput().setValue( @history[ @historyIndex ] || currentValue)
91
95
 
92
96
  append: (code, result, skipFormatting=false)->
93
- output = Luca("code_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
- dump = JSON.stringify(result, null, "\t")
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 = Luca("code_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 = Luca("code_input").getValue()
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()