luca 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.rvmrc +1 -1
- data/CHANGELOG +46 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/Guardfile +1 -1
- data/README.md +64 -27
- data/ROADMAP +17 -2
- data/Rakefile +49 -1
- data/app.rb +38 -2
- data/assets/javascripts/luca-ui-base.coffee +1 -20
- data/assets/javascripts/luca-ui-full.js +3 -0
- data/assets/javascripts/luca-ui.coffee +0 -5
- data/assets/javascripts/sandbox/application.coffee +24 -18
- data/assets/javascripts/sandbox/router.coffee +16 -6
- data/assets/javascripts/sandbox/templates/builder/component_list.luca +1 -0
- data/assets/javascripts/sandbox/templates/builder.luca +2 -0
- data/assets/javascripts/sandbox/templates/main.luca +4 -3
- data/assets/javascripts/sandbox/templates/sandbox/docs_index.luca +1 -0
- data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +6 -1
- data/assets/javascripts/sandbox/templates/sandbox/readme.luca +30 -0
- data/assets/javascripts/sandbox/views/builder/builder_canvas.coffee +3 -0
- data/assets/javascripts/sandbox/views/builder/builder_editor.coffee +6 -0
- data/assets/javascripts/sandbox/views/builder/component_list.coffee +38 -0
- data/assets/javascripts/sandbox/views/builder/project_browser.coffee +14 -0
- data/assets/javascripts/sandbox/views/builder.coffee +133 -0
- data/assets/javascripts/sandbox/views/docs_controller.coffee +7 -0
- data/assets/javascripts/sandbox/views/inspector/instance_filter.coffee +18 -0
- data/assets/javascripts/sandbox/{collections/sample.coffee → views/inspector/instance_list.coffee} +0 -0
- data/assets/javascripts/sandbox/views/inspector.coffee +11 -0
- data/assets/javascripts/sandbox.coffee +2 -0
- data/assets/stylesheets/luca-ui-full.css +3 -0
- data/assets/stylesheets/sandbox/builder.scss +79 -0
- data/assets/stylesheets/sandbox/sandbox.scss +2 -1
- data/docs/application.md +41 -0
- data/docs/collection.md +79 -0
- data/docs/collection_manager.md +76 -0
- data/docs/container_philosophy.md +122 -0
- data/docs/event_binding_helpers.md +164 -0
- data/docs/method_caching_and_computed_properties.md +77 -0
- data/docs/view.md +119 -0
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/template.rb +9 -9
- data/site/assets/bootstrap.min.js +7 -0
- data/site/assets/luca-ui-bootstrap.css +19 -1
- data/site/assets/luca-ui-development-tools.css +10 -0
- data/site/assets/luca-ui-development-tools.min.js +15 -0
- data/site/assets/luca-ui-full.min.js +8 -0
- data/site/assets/luca-ui.min.js +4 -0
- data/site/assets/sandbox.css +52 -4
- data/site/assets/sandbox.js +368 -30
- data/site/docs/application.html +41 -0
- data/site/docs/caching.html +43 -0
- data/site/docs/collection.html +75 -0
- data/site/docs/collection_manager.html +71 -0
- data/site/docs/containers.html +118 -0
- data/site/docs/events.html +153 -0
- data/site/docs/view.html +128 -0
- data/site/img/glyphicons-halflings-white.png +0 -0
- data/site/img/glyphicons-halflings.png +0 -0
- data/site/source-map.js +1 -0
- data/spec/core/view_spec.coffee +5 -17
- data/spec/managers/collection_manager_spec.coffee +4 -7
- data/src/components/application.coffee +202 -77
- data/src/components/base_toolbar.coffee +1 -1
- data/src/components/collection_view.coffee +38 -10
- data/src/components/controller.coffee +24 -1
- data/src/components/fields/checkbox_field.coffee +9 -12
- data/src/components/fields/label_field.coffee +14 -0
- data/src/components/fields/select_field.coffee +2 -2
- data/src/components/fields/text_field.coffee +12 -7
- data/src/components/fields/type_ahead_field.coffee +1 -0
- data/src/components/form_view.coffee +44 -25
- data/src/components/page_controller.coffee +2 -0
- data/src/containers/card_view.coffee +4 -1
- data/src/containers/column_view.coffee +2 -1
- data/src/containers/modal_view.coffee +6 -2
- data/src/containers/page_view.coffee +2 -0
- data/src/containers/panel_toolbar.coffee +0 -5
- data/src/containers/viewport.coffee +28 -10
- data/src/core/collection.coffee +7 -1
- data/src/core/container.coffee +57 -30
- data/src/core/core.coffee +0 -186
- data/src/core/field.coffee +11 -3
- data/src/core/model.coffee +31 -16
- data/src/core/panel.coffee +6 -46
- data/src/core/registry.coffee +19 -2
- data/src/core/script_loader.coffee +32 -0
- data/src/core/view.coffee +112 -139
- data/src/define.coffee +110 -0
- data/src/framework.coffee +8 -2
- data/src/luca.coffee +22 -0
- data/src/managers/collection_manager.coffee +65 -31
- data/src/modules/load_mask.coffee +47 -0
- data/src/plugins/development_tool_helpers.coffee +21 -0
- data/src/plugins/events.coffee +54 -0
- data/src/stylesheets/components/viewport.scss +15 -0
- data/src/stylesheets/containers/container.scss +1 -4
- data/src/stylesheets/tools/component_tester.scss +18 -0
- data/src/templates/fields/select_field.luca +6 -5
- data/src/templates/fields/text_field.luca +10 -9
- data/src/tools/application_inspector.coffee +2 -0
- data/src/tools/coffee_script_editor.coffee +28 -6
- data/src/tools/collections/components.coffee +59 -0
- data/src/tools/collections/instances.coffee +15 -0
- data/src/tools/component_tester.coffee +12 -22
- data/src/tools/console.coffee +22 -4
- data/src/tools/models/components.coffee +16 -54
- data/src/tools/models/instance.coffee +2 -0
- data/src/{core/util.coffee → util.coffee} +10 -1
- data/vendor/assets/javascripts/luca-ui-base.js +132 -137
- data/vendor/assets/javascripts/luca-ui-development-tools.js +191 -219
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +2 -2
- data/vendor/assets/javascripts/luca-ui-full.js +4680 -0
- data/vendor/assets/javascripts/luca-ui-full.min.js +8 -0
- data/vendor/assets/javascripts/luca-ui-spec.js +291 -225
- data/vendor/assets/javascripts/luca-ui.js +1001 -724
- data/vendor/assets/javascripts/luca-ui.min.js +4 -4
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +19 -1
- data/vendor/assets/stylesheets/luca-ui-development-tools.css +10 -0
- data/vendor/assets/stylesheets/luca-ui-full.css +1334 -0
- data/vendor/assets/stylesheets/luca-ui-spec.css +19 -1
- data/vendor/assets/stylesheets/luca-ui.css +19 -1
- data/views/index.erb +2 -5
- metadata +58 -9
- data/lib/sprockets/luca_template.rb +0 -49
- data/src/tools/class_browser.coffee +0 -39
- data/src/tools/components/class_browser_detail.coffee +0 -10
- data/src/tools/components/class_browser_list.coffee +0 -74
data/src/luca.coffee
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#= require ./framework
|
2
|
+
#= require ./util
|
3
|
+
#= require_tree ./plugins
|
4
|
+
#= require ./define
|
5
|
+
|
6
|
+
#= require_tree ./templates
|
7
|
+
#= require_tree ./modules
|
8
|
+
|
9
|
+
#= require ./core/registry
|
10
|
+
#= require ./core/observer
|
11
|
+
#= require ./core/view
|
12
|
+
#= require ./core/model
|
13
|
+
#= require ./core/collection
|
14
|
+
#= require ./core/panel
|
15
|
+
#= require ./core/field
|
16
|
+
#= require ./core/container
|
17
|
+
|
18
|
+
#= require_tree ./managers
|
19
|
+
|
20
|
+
#= require ./containers/split_view
|
21
|
+
#= require ./containers/column_view
|
22
|
+
#= require_tree ./containers
|
@@ -1,8 +1,12 @@
|
|
1
1
|
class Luca.CollectionManager
|
2
2
|
name: "primary"
|
3
3
|
|
4
|
+
collectionNamespace: Luca.Collection.namespace
|
5
|
+
|
4
6
|
__collections: {}
|
5
7
|
|
8
|
+
relayEvents: true
|
9
|
+
|
6
10
|
constructor: (@options={})->
|
7
11
|
_.extend @, @options
|
8
12
|
|
@@ -25,15 +29,7 @@ class Luca.CollectionManager
|
|
25
29
|
@state = new Luca.Model()
|
26
30
|
|
27
31
|
if @initialCollections
|
28
|
-
|
29
|
-
@state.bind "change:loaded_collections_count", @collectionCountDidChange
|
30
|
-
|
31
|
-
if @useProgressLoader
|
32
|
-
@loaderView ||= new Luca.components.CollectionLoaderView(manager: @,name:"collection_loader_view")
|
33
|
-
|
34
|
-
@loadInitialCollections()
|
35
|
-
|
36
|
-
@
|
32
|
+
handleInitialCollections.call(@)
|
37
33
|
|
38
34
|
add: (key, collection)->
|
39
35
|
@currentScope()[ key ] ||= collection
|
@@ -46,19 +42,21 @@ class Luca.CollectionManager
|
|
46
42
|
# skip registering this collection
|
47
43
|
create: (key, collectionOptions={}, initialModels=[])->
|
48
44
|
CollectionClass = collectionOptions.base
|
49
|
-
CollectionClass ||=
|
45
|
+
CollectionClass ||= guessCollectionClass.call(@, key)
|
50
46
|
collectionOptions.name = "" if collectionOptions.private
|
51
47
|
|
52
48
|
collection = new CollectionClass(initialModels,collectionOptions)
|
53
49
|
|
54
50
|
@add(key, collection)
|
55
51
|
|
56
|
-
|
52
|
+
collectionManager = @
|
57
53
|
|
54
|
+
if @relayEvents is true
|
55
|
+
@bind "*", ()->
|
56
|
+
console.log "Relay Events on Collection Manager *", collection, arguments
|
58
57
|
|
59
|
-
|
58
|
+
return collection
|
60
59
|
|
61
|
-
|
62
60
|
currentScope: ()->
|
63
61
|
if current_scope = @getScope()
|
64
62
|
@__collections[ current_scope ] ||= {}
|
@@ -73,28 +71,22 @@ class Luca.CollectionManager
|
|
73
71
|
|
74
72
|
getScope: ()-> undefined
|
75
73
|
|
74
|
+
destroy: (key)->
|
75
|
+
c = @get(key)
|
76
|
+
delete @currentScope()[key]
|
77
|
+
c
|
78
|
+
|
76
79
|
getOrCreate: (key,collectionOptions={},initialModels=[])->
|
77
80
|
@get(key) || @create(key,collectionOptions,initialModels,false)
|
78
81
|
|
79
|
-
guessCollectionClass: (key)->
|
80
|
-
classified = Luca.util.classify( key )
|
81
|
-
guess = (@collectionNamespace || (window || global) )[ classified ]
|
82
|
-
guess ||= (@collectionNamespace || (window || global) )[ "#{classified}Collection" ]
|
83
|
-
guess
|
84
|
-
|
85
|
-
loadInitialCollections: ()->
|
86
|
-
collectionDidLoad = (collection) =>
|
87
|
-
collection.unbind "reset"
|
88
|
-
@trigger "collection_loaded", collection.name
|
89
|
-
|
90
|
-
_(@initialCollections).each (name) =>
|
91
|
-
collection = @getOrCreate(name)
|
92
|
-
collection.bind "reset", ()->
|
93
|
-
collectionDidLoad(collection)
|
94
|
-
collection.fetch()
|
95
|
-
|
96
82
|
collectionCountDidChange: ()->
|
97
|
-
|
83
|
+
if @allCollectionsLoaded()
|
84
|
+
# for backwards compat
|
85
|
+
@trigger "all_collections_loaded"
|
86
|
+
@trigger "initial:load"
|
87
|
+
|
88
|
+
allCollectionsLoaded:()->
|
89
|
+
@totalCollectionsCount() is @loadedCollectionsCount()
|
98
90
|
|
99
91
|
totalCollectionsCount: ()->
|
100
92
|
@state.get("collections_count")
|
@@ -107,3 +99,45 @@ class Luca.CollectionManager
|
|
107
99
|
|
108
100
|
Luca.CollectionManager.destroyAll = ()->
|
109
101
|
Luca.CollectionManager.instances = {}
|
102
|
+
|
103
|
+
guessCollectionClass = (key)->
|
104
|
+
classified = Luca.util.classify( key )
|
105
|
+
# support our naming convention of Books
|
106
|
+
guess = (@collectionNamespace || (window || global) )[ classified ]
|
107
|
+
# support naming covention like BooksCollection
|
108
|
+
guess ||= (@collectionNamespace || (window || global) )[ "#{classified}Collection" ]
|
109
|
+
|
110
|
+
if not guess? and Luca.Collection.namespaces?.length > 0
|
111
|
+
guesses = _( Luca.Collection.namespaces.reverse() ).map (namespace)->
|
112
|
+
Luca.util.resolve("#{ namespace }.#{ classified }") || Luca.util.resolve("#{ namespace }.#{ classified }Collection")
|
113
|
+
|
114
|
+
guesses = _( guesses ).compact()
|
115
|
+
|
116
|
+
guess = guesses[0] if guesses.length > 0
|
117
|
+
|
118
|
+
guess
|
119
|
+
|
120
|
+
loadInitialCollections = ()->
|
121
|
+
collectionDidLoad = (collection) =>
|
122
|
+
current = @state.get("loaded_collections_count")
|
123
|
+
|
124
|
+
@state.set("loaded_collections_count", current + 1)
|
125
|
+
@trigger "collection_loaded", collection.name
|
126
|
+
collection.unbind "reset"
|
127
|
+
|
128
|
+
_(@initialCollections).each (name) =>
|
129
|
+
collection = @getOrCreate(name)
|
130
|
+
collection.once "reset", ()->
|
131
|
+
collectionDidLoad(collection)
|
132
|
+
collection.fetch()
|
133
|
+
|
134
|
+
handleInitialCollections = ()->
|
135
|
+
@state.set({loaded_collections_count: 0, collections_count: @initialCollections.length })
|
136
|
+
@state.bind "change:loaded_collections_count", ()=> @collectionCountDidChange()
|
137
|
+
|
138
|
+
if @useProgressLoader
|
139
|
+
@loaderView ||= new Luca.components.CollectionLoaderView(manager: @,name:"collection_loader_view")
|
140
|
+
|
141
|
+
loadInitialCollections.call(@)
|
142
|
+
|
143
|
+
@
|
@@ -0,0 +1,47 @@
|
|
1
|
+
Luca.modules.LoadMaskable =
|
2
|
+
_included: (self, module)->
|
3
|
+
_.bindAll self, "applyLoadMask", "disableLoadMask"
|
4
|
+
|
5
|
+
if @loadMask is true
|
6
|
+
@defer ()=>
|
7
|
+
@$el.addClass('with-mask')
|
8
|
+
|
9
|
+
if @$('.load-mask').length is 0
|
10
|
+
@loadMaskTarget().prepend Luca.template(@loadMaskTemplate, @)
|
11
|
+
@$('.load-mask').hide()
|
12
|
+
.until("after:render")
|
13
|
+
|
14
|
+
@on (@loadmaskEnableEvent || "enable:loadmask"), @applyLoadMask
|
15
|
+
@on (@loadmaskDisableEvent || "disable:loadmask"), @applyLoadMask
|
16
|
+
|
17
|
+
loadMaskTarget: ()->
|
18
|
+
if @loadMaskEl? then @$(@loadMaskEl) else @$bodyEl()
|
19
|
+
|
20
|
+
disableLoadMask: ()->
|
21
|
+
@$('.load-mask .bar').css("width","100%")
|
22
|
+
@$('.load-mask').hide()
|
23
|
+
clearInterval(@loadMaskInterval)
|
24
|
+
|
25
|
+
enableLoadMask: ()->
|
26
|
+
@$('.load-mask').show().find('.bar').css("width","0%")
|
27
|
+
maxWidth = @$('.load-mask .progress').width()
|
28
|
+
if maxWidth < 20 and (maxWidth = @$el.width()) < 20
|
29
|
+
maxWidth = @$el.parent().width()
|
30
|
+
|
31
|
+
@loadMaskInterval = setInterval ()=>
|
32
|
+
currentWidth = @$('.load-mask .bar').width()
|
33
|
+
newWidth = currentWidth + 12
|
34
|
+
@$('.load-mask .bar').css('width', newWidth)
|
35
|
+
, 200
|
36
|
+
|
37
|
+
return unless @loadMaskTimeout?
|
38
|
+
|
39
|
+
_.delay ()=>
|
40
|
+
@disableLoadMask()
|
41
|
+
, @loadMaskTimeout
|
42
|
+
|
43
|
+
applyLoadMask: ()->
|
44
|
+
if @$('.load-mask').is(":visible")
|
45
|
+
@disableLoadMask()
|
46
|
+
else
|
47
|
+
@enableLoadMask()
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Luca.DevelopmentToolHelpers =
|
2
|
+
refreshCode: ()->
|
3
|
+
view = @
|
4
|
+
|
5
|
+
_( @eventHandlerProperties() ).each (prop)->
|
6
|
+
view[ prop ] = view.definitionClass()[prop]
|
7
|
+
|
8
|
+
if @autoBindEventHandlers is true
|
9
|
+
@bindAllEventHandlers()
|
10
|
+
|
11
|
+
@delegateEvents()
|
12
|
+
|
13
|
+
eventHandlerProperties: ()->
|
14
|
+
handlerIds = _( @events ).values()
|
15
|
+
_( handlerIds ).select (v)->
|
16
|
+
_.isString(v)
|
17
|
+
|
18
|
+
eventHandlerFunctions: ()->
|
19
|
+
handlerIds = _( @events ).values()
|
20
|
+
_( handlerIds ).map (handlerId)=>
|
21
|
+
if _.isFunction(handlerId) then handlerId else @[handlerId]
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Luca.Events
|
2
|
+
#
|
3
|
+
# These helpers will get mixed into Luca.Collection, Luca.View, and Luca.Model.
|
4
|
+
#
|
5
|
+
# They allow for syntactic sugar like:
|
6
|
+
#
|
7
|
+
# view.defer("someMethodOnTheView").until("collection","fetch")
|
8
|
+
#
|
9
|
+
# or
|
10
|
+
#
|
11
|
+
# view.defer( myCallback ).until("triggered:event")
|
12
|
+
class DeferredBindingProxy
|
13
|
+
constructor: (@object, operation, wrapWithUnderscore=true)->
|
14
|
+
if _.isFunction(operation)
|
15
|
+
fn = operation
|
16
|
+
|
17
|
+
else if _.isString(operation) and _.isFunction(@object[operation])
|
18
|
+
fn = @object[operation]
|
19
|
+
|
20
|
+
unless _.isFunction(fn)
|
21
|
+
throw "Must pass a function or a string representing one"
|
22
|
+
|
23
|
+
if wrapWithUnderscore is true
|
24
|
+
@fn = ()=>
|
25
|
+
_.defer(fn)
|
26
|
+
else
|
27
|
+
@fn = fn
|
28
|
+
|
29
|
+
@
|
30
|
+
|
31
|
+
# until accepts an object to bind to, and a trigger to bind with
|
32
|
+
# if you just pass a trigger, the object getting bound to
|
33
|
+
# will implicitly be @object
|
34
|
+
until: (watch, trigger)->
|
35
|
+
if watch? and not trigger?
|
36
|
+
trigger = watch
|
37
|
+
watch = @object
|
38
|
+
|
39
|
+
watch.once(trigger, @fn)
|
40
|
+
|
41
|
+
@object
|
42
|
+
|
43
|
+
Luca.Events =
|
44
|
+
defer: (operation, wrapWithUnderscore=true)->
|
45
|
+
new DeferredBindingProxy(@, operation, wrapWithUnderscore)
|
46
|
+
|
47
|
+
once: (trigger, callback, context)->
|
48
|
+
context ||= @
|
49
|
+
|
50
|
+
onceFn = ()->
|
51
|
+
callback.apply(context, arguments)
|
52
|
+
@unbind(trigger, onceFn)
|
53
|
+
|
54
|
+
@bind trigger, onceFn
|
@@ -0,0 +1,15 @@
|
|
1
|
+
html.luca-ui-fullscreen, body.luca-ui-fullscreen {
|
2
|
+
height: 100%;
|
3
|
+
}
|
4
|
+
|
5
|
+
.luca-ui-fullscreen {
|
6
|
+
.fluid-viewport-wrapper {
|
7
|
+
padding-top:40px;
|
8
|
+
}
|
9
|
+
.luca-ui-viewport, .fullscreen-container {
|
10
|
+
min-height: 100%;
|
11
|
+
height: auto !important;
|
12
|
+
height: 100%;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
@@ -5,4 +5,22 @@ ul.typeahead.dropdown-menu {
|
|
5
5
|
.font-large .CodeMirror {
|
6
6
|
font-size: 18px;
|
7
7
|
line-height: 1.7;
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
#component_tester {
|
12
|
+
#editor_container {
|
13
|
+
.toolbar-container.bottom {
|
14
|
+
margin: 0px;
|
15
|
+
.luca-ui-toolbar {
|
16
|
+
margin: 0px;
|
17
|
+
padding: 0px;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
[data-luca-owner="component_detail"] {
|
22
|
+
max-height: 600px;
|
23
|
+
overflow: scroll;
|
24
|
+
min-height: 400px;
|
25
|
+
}
|
8
26
|
}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
%label{:for=>"<%= input_id %>"}
|
2
2
|
<%= label %>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
.controls
|
4
|
+
%select{:style=>"<%= inputStyles %>",:id=>"<%= input_id %>",:name=>"<%= input_name %>"}
|
5
|
+
<% if(helperText) { %>
|
6
|
+
%p.helper-text.help-block
|
7
|
+
<%= helperText %>
|
8
|
+
<% } %>
|
@@ -3,14 +3,15 @@
|
|
3
3
|
<%= label %>
|
4
4
|
<% } %>
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
.controls
|
7
|
+
<% if( typeof(addOn) !== "undefined" ) { %>
|
8
|
+
%span.add-on
|
9
|
+
<%= addOn %>
|
10
|
+
<% } %>
|
10
11
|
|
11
|
-
%input{:style=>"<%= inputStyles %>",:id=>"<%= input_id %>",:type=>"text",:name=>"<%= input_name %>",:placeholder=>"<%= placeHolder %>", :class=>"<%= input_class %>"}
|
12
|
+
%input{:style=>"<%= inputStyles %>",:id=>"<%= input_id %>",:type=>"text",:name=>"<%= input_name %>",:placeholder=>"<%= placeHolder %>", :class=>"<%= input_class %>"}
|
12
13
|
|
13
|
-
<% if(helperText) { %>
|
14
|
-
%p.helper-text.help-block
|
15
|
-
|
16
|
-
<% } %>
|
14
|
+
<% if(helperText) { %>
|
15
|
+
%p.helper-text.help-block
|
16
|
+
<%= helperText %>
|
17
|
+
<% } %>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
_.def("Luca.tools.CoffeeEditor").extends("Luca.tools.CodeMirrorField").with
|
2
2
|
name : "coffeescript_editor"
|
3
3
|
|
4
|
+
autoCompile: true
|
5
|
+
|
4
6
|
compileOptions:
|
5
7
|
bare: true
|
6
8
|
|
@@ -11,7 +13,7 @@ _.def("Luca.tools.CoffeeEditor").extends("Luca.tools.CodeMirrorField").with
|
|
11
13
|
initialize: (@options)->
|
12
14
|
Luca.tools.CodeMirrorField::initialize.apply(@, arguments)
|
13
15
|
|
14
|
-
_.bindAll(@, "editorChange")
|
16
|
+
_.bindAll(@, "editorChange", "toggleSource")
|
15
17
|
|
16
18
|
editor = @
|
17
19
|
|
@@ -30,6 +32,12 @@ _.def("Luca.tools.CoffeeEditor").extends("Luca.tools.CodeMirrorField").with
|
|
30
32
|
@state.bind "change:javascript", (model)->
|
31
33
|
editor.onJavascriptChange?.call(editor, model.get('javascript') )
|
32
34
|
|
35
|
+
@state.bind "change:currentMode", (model)->
|
36
|
+
if model.get('currentMode') is "javascript"
|
37
|
+
editor.setValue model.get('javascript')
|
38
|
+
else
|
39
|
+
editor.setValue model.get('coffeescript')
|
40
|
+
|
33
41
|
compile: (code, callback)->
|
34
42
|
response = {}
|
35
43
|
code ||= @getValue()
|
@@ -48,13 +56,27 @@ _.def("Luca.tools.CoffeeEditor").extends("Luca.tools.CodeMirrorField").with
|
|
48
56
|
compiled: ''
|
49
57
|
message: error.message
|
50
58
|
|
59
|
+
toggleMode: ()->
|
60
|
+
if @currentMode() is "coffeescript"
|
61
|
+
@state.set('currentMode', 'javascript')
|
62
|
+
else if @currentMode() is "javascript"
|
63
|
+
@state.set('currentMode', 'coffeescript')
|
64
|
+
|
51
65
|
currentMode: ()->
|
52
66
|
@state.get("currentMode")
|
53
67
|
|
54
|
-
|
55
|
-
|
56
|
-
|
68
|
+
getCoffeescript: ()->
|
69
|
+
@state.get("coffeescript")
|
70
|
+
|
71
|
+
getJavascript: (recompile=false)->
|
72
|
+
js = @state.get("javascript")
|
73
|
+
|
74
|
+
if recompile is true or js?.length is 0
|
75
|
+
results = @compile( @getCoffeescript() )
|
76
|
+
js = results?.compiled
|
77
|
+
|
78
|
+
js
|
57
79
|
|
58
80
|
editorChange: ()->
|
59
|
-
@
|
60
|
-
|
81
|
+
if @autoCompile is true
|
82
|
+
@state.set( @currentMode(), @getValue() )
|
@@ -0,0 +1,59 @@
|
|
1
|
+
_.def('Luca.app.Components').extends('Luca.Collection').with
|
2
|
+
|
3
|
+
cachedMethods: [
|
4
|
+
"namespaces"
|
5
|
+
"classes"
|
6
|
+
"roots"
|
7
|
+
"views"
|
8
|
+
"collections"
|
9
|
+
"models"
|
10
|
+
]
|
11
|
+
|
12
|
+
cache_key: "luca_components"
|
13
|
+
|
14
|
+
name: "components"
|
15
|
+
|
16
|
+
initialize: ()->
|
17
|
+
@model = Luca.app.Component
|
18
|
+
Luca.Collection::initialize.apply(@, arguments)
|
19
|
+
|
20
|
+
url: ()->
|
21
|
+
"/luca/source-map.js"
|
22
|
+
|
23
|
+
collections: ()->
|
24
|
+
@select (component)-> Luca.isCollectionPrototype( component.definition() )
|
25
|
+
|
26
|
+
modelClasses: ()->
|
27
|
+
@select (component)-> Luca.isModelPrototype( component.definition() )
|
28
|
+
|
29
|
+
views: ()->
|
30
|
+
@select (component)-> Luca.isViewPrototype( component.definition() )
|
31
|
+
|
32
|
+
classes: ()->
|
33
|
+
_.uniq( @pluck("className") )
|
34
|
+
|
35
|
+
roots: ()->
|
36
|
+
_.uniq( @invoke("root") )
|
37
|
+
|
38
|
+
namespaces: ()->
|
39
|
+
_.uniq( @invoke("namespace") )
|
40
|
+
|
41
|
+
asTree: ()->
|
42
|
+
classes = @classes()
|
43
|
+
namespaces = @namespaces()
|
44
|
+
roots = @roots()
|
45
|
+
|
46
|
+
tree = _( roots ).inject (memo,root)->
|
47
|
+
memo[ root ] ||= {}
|
48
|
+
regexp = new RegExp("^#{ root }")
|
49
|
+
memo[root] = _( namespaces ).select (namespace)->
|
50
|
+
regexp.exec(namespace) and _( namespaces ).include(namespace) and namespace.split('.').length is 2
|
51
|
+
memo
|
52
|
+
, {}
|
53
|
+
|
54
|
+
_( tree ).inject (memo, namespaces, root)->
|
55
|
+
memo[root] = {}
|
56
|
+
_( namespaces ).each (namespace)->
|
57
|
+
memo[root][namespace] = {}
|
58
|
+
memo
|
59
|
+
, {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
_.def("Luca.app.Instances").extends("Luca.Collection").with
|
2
|
+
name:"instances"
|
3
|
+
refresh:(options={})->
|
4
|
+
models = _( Luca.registry.instances() ).map (instance)->
|
5
|
+
cid: instance.cid
|
6
|
+
name: instance.name
|
7
|
+
ctype: instance.ctype
|
8
|
+
displayName: instance.displayName || instance::displayName
|
9
|
+
object: instance
|
10
|
+
|
11
|
+
@reset(models, options)
|
12
|
+
|
13
|
+
initialize:(initialModels=[],@options={})->
|
14
|
+
@model = Luca.app.Instance
|
15
|
+
Luca.Collection::initialize.apply(@,arguments)
|
@@ -95,12 +95,21 @@ ComponentPicker = Luca.fields.TypeAheadField.extend
|
|
95
95
|
|
96
96
|
|
97
97
|
_.def("Luca.tools.ComponentTester").extends("Luca.core.Container").with
|
98
|
+
id: "component_tester"
|
98
99
|
name: "component_tester"
|
99
100
|
|
100
|
-
className:"span11"
|
101
|
-
|
102
101
|
autoEvaluateCode: true
|
103
102
|
|
103
|
+
currentSize: 1
|
104
|
+
|
105
|
+
sizes:[
|
106
|
+
icon: "resize-full"
|
107
|
+
value: ()-> $(window).height() * 0.3
|
108
|
+
,
|
109
|
+
icon: "resize-small"
|
110
|
+
value: ()-> $(window).height() * 0.6
|
111
|
+
]
|
112
|
+
|
104
113
|
components:[
|
105
114
|
ctype: 'card_view'
|
106
115
|
name: "component_detail"
|
@@ -116,11 +125,6 @@ _.def("Luca.tools.ComponentTester").extends("Luca.core.Container").with
|
|
116
125
|
className: 'font-large fixed-height'
|
117
126
|
minHeight:'350px'
|
118
127
|
|
119
|
-
styles:
|
120
|
-
"position" : "absolute"
|
121
|
-
"bottom" : "0px"
|
122
|
-
"width" : "96%"
|
123
|
-
|
124
128
|
currentBuffers: defaults
|
125
129
|
|
126
130
|
compiledBuffers:["component","setup","implementation"]
|
@@ -241,13 +245,6 @@ _.def("Luca.tools.ComponentTester").extends("Luca.core.Container").with
|
|
241
245
|
@defer("editComponent").until("after:render")
|
242
246
|
|
243
247
|
afterRender: ()->
|
244
|
-
@getOutput().applyStyles('min-height':'400px')
|
245
|
-
|
246
|
-
# TEMP
|
247
|
-
# Visual hacks
|
248
|
-
@$('.toolbar-container').css('padding-right','12px')
|
249
|
-
@$('.luca-ui-toolbar.toolbar-bottom').css('margin','0px')
|
250
|
-
|
251
248
|
changeHandler = _.idleMedium ()=>
|
252
249
|
if @autoEvaluateCode is true
|
253
250
|
@applyTestRun()
|
@@ -330,14 +327,7 @@ _.def("Luca.tools.ComponentTester").extends("Luca.core.Container").with
|
|
330
327
|
@editBuffer @currentBufferName, (newMode is "javascript")
|
331
328
|
|
332
329
|
|
333
|
-
|
334
|
-
sizes:[
|
335
|
-
icon: "resize-full"
|
336
|
-
value: ()-> $(window).height() * 0.3
|
337
|
-
,
|
338
|
-
icon: "resize-small"
|
339
|
-
value: ()-> $(window).height() * 0.6
|
340
|
-
]
|
330
|
+
|
341
331
|
|
342
332
|
toggleSize: (button)->
|
343
333
|
index = @currentSize++ % @sizes.length
|
data/src/tools/console.coffee
CHANGED
@@ -20,12 +20,11 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
20
20
|
|
21
21
|
components:[
|
22
22
|
ctype: "code_mirror_field"
|
23
|
+
additionalClassNames: "clearfix"
|
23
24
|
name: "code_output"
|
24
25
|
readOnly: true
|
25
26
|
lineNumbers: false
|
26
27
|
mode: "javascript"
|
27
|
-
height:"621px"
|
28
|
-
maxHeight:"621px"
|
29
28
|
lineWrapping: true
|
30
29
|
gutter: false
|
31
30
|
,
|
@@ -56,8 +55,13 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
56
55
|
@$('input').focus()
|
57
56
|
]
|
58
57
|
|
58
|
+
afterRender: ()->
|
59
|
+
@$container().modal(backdrop: false)
|
60
|
+
@$container.css
|
61
|
+
|
59
62
|
show: (options={})->
|
60
|
-
@$
|
63
|
+
@$container().modal('show')
|
64
|
+
@
|
61
65
|
|
62
66
|
getContext: ()->
|
63
67
|
window
|
@@ -147,4 +151,18 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
147
151
|
compile = _.bind(Luca.tools.CoffeeEditor::compile, @)
|
148
152
|
raw = Luca("code_input").getValue()
|
149
153
|
compiled = compile raw, (compiled)->
|
150
|
-
dev.evaluateCode(compiled, raw)
|
154
|
+
dev.evaluateCode(compiled, raw)
|
155
|
+
|
156
|
+
Luca.util.launchers ||= {}
|
157
|
+
|
158
|
+
Luca.util.launchers.developmentConsole = (name="luca-development-console")->
|
159
|
+
@_lucaDevConsole = Luca name, ()=>
|
160
|
+
@$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade")
|
161
|
+
|
162
|
+
console = new Luca.tools.DevelopmentConsole
|
163
|
+
name: name
|
164
|
+
container: "##{ name }-wrapper"
|
165
|
+
|
166
|
+
console.render()
|
167
|
+
|
168
|
+
@_lucaDevConsole.show()
|