luca 0.8.599 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/.gitignore +3 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG +51 -2
  4. data/README.md +10 -247
  5. data/ROADMAP +6 -2
  6. data/app.rb +16 -2
  7. data/assets/javascripts/dependencies/bootstrap.min.js +7 -1
  8. data/assets/javascripts/dependencies/codemirror-coffeescript.js +347 -0
  9. data/assets/javascripts/dependencies/codemirror-css.js +124 -0
  10. data/assets/javascripts/dependencies/codemirror-html.js +410 -0
  11. data/assets/javascripts/dependencies/codemirror-javascript.js +361 -0
  12. data/assets/javascripts/dependencies/codemirror-less.js +232 -0
  13. data/assets/javascripts/dependencies/codemirror-vim.js +500 -0
  14. data/assets/javascripts/dependencies/codemirror.js +3076 -0
  15. data/assets/javascripts/dependencies.coffee +0 -1
  16. data/assets/javascripts/luca-ui-base.coffee +10 -3
  17. data/assets/javascripts/luca-ui-bootstrap.js +1 -0
  18. data/assets/javascripts/luca-ui-development-tools.coffee +9 -0
  19. data/assets/javascripts/luca-ui.coffee +6 -1
  20. data/assets/javascripts/sandbox/application.coffee +51 -0
  21. data/assets/javascripts/sandbox/router.coffee +14 -0
  22. data/assets/javascripts/sandbox/templates/main.luca +33 -0
  23. data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +1 -0
  24. data/assets/javascripts/sandbox/templates/sandbox.luca +1 -0
  25. data/assets/javascripts/sandbox/views/top_navigation.coffee +4 -0
  26. data/assets/javascripts/sandbox.coffee +2 -2
  27. data/assets/stylesheets/bootstrap.min.css +395 -297
  28. data/assets/stylesheets/codemirror-blackboard.css +25 -0
  29. data/assets/stylesheets/codemirror-monokai.css +33 -0
  30. data/assets/stylesheets/codemirror.css +126 -0
  31. data/assets/stylesheets/luca-ui-bootstrap.css +0 -1
  32. data/assets/stylesheets/luca-ui-development-tools.css +5 -0
  33. data/assets/stylesheets/sandbox/sandbox.scss +1 -3
  34. data/assets/stylesheets/themes/amelia-bootstrap.css +826 -0
  35. data/assets/stylesheets/themes/slate-bootstrap.css +797 -0
  36. data/assets/stylesheets/themes/superhero-bootstrap.css +830 -0
  37. data/lib/luca/code_browser.rb +55 -0
  38. data/lib/luca/rails/version.rb +1 -1
  39. data/lib/luca/rails.rb +1 -0
  40. data/spec/components/fields/checkbox_array_spec.coffee +46 -0
  41. data/spec/components/form_view_spec.coffee +10 -4
  42. data/spec/containers/card_view_spec.coffee +7 -0
  43. data/spec/core/collection_spec.coffee +58 -4
  44. data/spec/core/container_spec.coffee +6 -6
  45. data/spec/core/view_spec.coffee +93 -7
  46. data/spec/framework_spec.coffee +15 -12
  47. data/src/components/application.coffee +126 -18
  48. data/src/components/base_toolbar.coffee +2 -2
  49. data/src/components/collection_loader_view.coffee +1 -2
  50. data/src/components/collection_view.coffee +77 -0
  51. data/src/components/controller.coffee +1 -4
  52. data/src/components/fields/button_field.coffee +1 -1
  53. data/src/components/fields/checkbox_array.coffee +2 -2
  54. data/src/components/fields/checkbox_field.coffee +3 -1
  55. data/src/components/fields/file_upload_field.coffee +1 -1
  56. data/src/components/fields/hidden_field.coffee +1 -1
  57. data/src/components/fields/select_field.coffee +1 -1
  58. data/src/components/fields/text_area_field.coffee +1 -1
  59. data/src/components/fields/text_field.coffee +10 -6
  60. data/src/components/fields/type_ahead_field.coffee +18 -5
  61. data/src/components/form_button_toolbar.coffee +1 -2
  62. data/src/components/form_view.coffee +44 -62
  63. data/src/components/grid_view.coffee +27 -20
  64. data/src/components/load_mask.coffee +3 -0
  65. data/src/components/nav_bar.coffee +26 -0
  66. data/src/components/record_manager.coffee +1 -3
  67. data/src/components/router.coffee +1 -1
  68. data/src/components/template.coffee +3 -15
  69. data/src/components/toolbar_dialog.coffee +25 -0
  70. data/src/containers/card_view.coffee +22 -23
  71. data/src/containers/column_view.coffee +1 -6
  72. data/src/containers/modal_view.coffee +20 -71
  73. data/src/containers/panel_toolbar.coffee +156 -0
  74. data/src/containers/panel_view.coffee +1 -1
  75. data/src/containers/split_view.coffee +1 -3
  76. data/src/containers/tab_view.coffee +29 -29
  77. data/src/containers/viewport.coffee +38 -3
  78. data/src/core/collection.coffee +80 -48
  79. data/src/core/container.coffee +153 -72
  80. data/src/core/core.coffee +181 -0
  81. data/src/core/field.coffee +4 -2
  82. data/src/core/model.coffee +1 -1
  83. data/src/core/observer.coffee +3 -3
  84. data/src/core/panel.coffee +143 -0
  85. data/src/core/registry.coffee +104 -0
  86. data/src/core/util.coffee +82 -0
  87. data/src/core/view.coffee +158 -85
  88. data/src/framework.coffee +112 -178
  89. data/src/index.coffee +0 -255
  90. data/src/managers/collection_manager.coffee +1 -0
  91. data/src/samples/definition.coffee +49 -0
  92. data/src/stylesheets/base.scss +0 -78
  93. data/src/stylesheets/components/form_view.scss +8 -3
  94. data/src/stylesheets/components/grid_view.scss +3 -7
  95. data/src/stylesheets/components/load_mask.scss +14 -0
  96. data/src/stylesheets/components/toolbar.scss +0 -15
  97. data/src/stylesheets/containers/container.scss +14 -2
  98. data/src/stylesheets/containers/panels.scss +23 -0
  99. data/src/stylesheets/tools/class_browser.scss +32 -0
  100. data/src/stylesheets/tools/code_editor.scss +24 -0
  101. data/src/stylesheets/tools/component_tester.scss +8 -0
  102. data/src/stylesheets/tools/console.scss +26 -0
  103. data/src/templates/components/collection_loader_view.luca +1 -1
  104. data/src/templates/components/form_view.luca +2 -13
  105. data/src/templates/components/grid_view.luca +0 -2
  106. data/src/templates/components/load_mask.luca +3 -0
  107. data/src/templates/components/nav_bar.luca +2 -0
  108. data/src/templates/containers/tab_view.luca +1 -0
  109. data/src/templates/fields/text_field.luca +4 -1
  110. data/src/tools/class_browser.coffee +39 -0
  111. data/src/tools/code_editor.coffee +258 -0
  112. data/src/tools/code_mirror_field.coffee +57 -0
  113. data/src/tools/coffee_script_editor.coffee +60 -0
  114. data/src/tools/collection_inspector.coffee +4 -0
  115. data/src/tools/component_tester.coffee +472 -0
  116. data/src/tools/components/class_browser_detail.coffee +10 -0
  117. data/src/tools/components/class_browser_list.coffee +74 -0
  118. data/src/tools/console.coffee +147 -0
  119. data/src/tools/development_console.coffee +147 -0
  120. data/src/tools/models/components.coffee +63 -0
  121. data/src/tools/templates/component_tester/help.luca +14 -0
  122. data/vendor/assets/javascripts/luca-ui-base.js +1389 -611
  123. data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
  124. data/vendor/assets/javascripts/luca-ui-development-tools.js +18719 -0
  125. data/vendor/assets/javascripts/luca-ui-spec.js +2065 -878
  126. data/vendor/assets/javascripts/luca-ui.js +1759 -852
  127. data/vendor/assets/javascripts/luca-ui.min.js +3 -3
  128. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +494 -440
  129. data/vendor/assets/stylesheets/luca-ui-development-tools.css +224 -0
  130. data/vendor/assets/stylesheets/luca-ui-spec.css +99 -140
  131. data/vendor/assets/stylesheets/luca-ui.css +99 -140
  132. data/views/index.erb +6 -3
  133. metadata +60 -18
  134. data/assets/javascripts/dependencies/jquery-console.js +0 -649
  135. data/assets/javascripts/development-console.coffee +0 -2
  136. data/assets/javascripts/sandbox/sandbox.coffee +0 -16
  137. data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +0 -33
  138. data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +0 -48
  139. data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +0 -24
  140. data/assets/javascripts/sandbox/templates/features/introduction.luca +0 -11
  141. data/assets/javascripts/sandbox/templates/features/view_helpers.luca +0 -43
  142. data/assets/javascripts/sandbox/templates/navigation.luca +0 -8
  143. data/assets/javascripts/sandbox/views/form_demo.coffee +0 -47
  144. data/assets/javascripts/sandbox/views/grid_demo.coffee +0 -23
  145. data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +0 -1
  146. data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +0 -38
  147. data/src/components/collection_inspector.coffee +0 -2
  148. data/src/components/development_console.coffee +0 -59
  149. data/src/stylesheets/components/development_console.scss +0 -47
@@ -1,33 +0,0 @@
1
- %h1 Collection Helpers
2
- %pre.prettyprint.lang-coffee
3
- :plain
4
- Luca.Collection.bootstrap window.BootstrappedData.sample_collection_1
5
-
6
- SampleCollection = Luca.View.extend
7
- # The Collection Manager is responsible for tracking
8
- # all instances of this collection, so that we don't
9
- # create more than one instance if we don't need to
10
- registerWith: "CollectionManager"
11
-
12
- # specify a unique ID to register this collection
13
- # with the CollectionManager. This will allow us to
14
- # call
15
- #
16
- # MyApp.collection("sample_collection")
17
- #
18
- # and get an instance of this collection
19
- registerAs: "sample_collection"
20
-
21
- myScopeVariable: 1
22
-
23
- # Bootstrap Models
24
- #
25
- # Specify the named property of the object which contains
26
- # our bootstrapped models. This allows us to load up an array
27
- # of model attributes on page load, and automatically populate
28
- # our collection with them
29
- #
30
- # This will look in the models cache for sample_collection_1
31
- # and automatically populate this collection with those models
32
- # when fetch() is called
33
- cached: ()-> "sample_collection_" + @myScopeVariable
@@ -1,48 +0,0 @@
1
- .code-sample-container
2
- %h3
3
- This was created by the following code snippet
4
-
5
- %pre.prettyprint.lang-coffee
6
- :plain
7
- Sandbox.views.FormDemo = Luca.components.FormView.extend
8
- components:[
9
- ctype: 'column_view'
10
- layout: '33/33/33'
11
- components:[
12
- components:[
13
- ctype: 'text_field'
14
- name: 'textfield3'
15
- label: 'Sup baby?'
16
- placeHolder: 'Bootstrapped'
17
- ]
18
- ,
19
- components:[
20
- ctype: 'checkbox_field'
21
- label: 'Checkbox Field'
22
- name: 'checkbox1'
23
- state: 'success'
24
- ,
25
- ctype: 'select_field'
26
- label: 'Select Field'
27
- displayField: 'name'
28
- valueField: 'id'
29
- state: 'warning'
30
- collection:
31
- url: '/sandbox/api'
32
- ]
33
- ,
34
- components:[
35
- ctype: 'text_field'
36
- label: 'Text Field'
37
- name: 'textfield1'
38
- state: 'error'
39
- placeHolder: 'This is a placeholder'
40
- helperText : 'This is helper text'
41
- ,
42
- ctype: 'text_area_field'
43
- label: 'Text Area'
44
- name: 'textarea',
45
- width: 125
46
- ]
47
- ]
48
- ]
@@ -1,24 +0,0 @@
1
- .code-sample-container
2
- %h3
3
- This was created by the following code snippet
4
-
5
- %pre.prettyprint.lang-coffee
6
- :plain
7
- Sandbox.views.GridViewDemo = Luca.components.GridView.extend
8
- collection:
9
- url: "/sandbox/api"
10
-
11
- afterInitialize: ()->
12
- @bind "activation", ()=>
13
- @resize( @$container().width() )
14
-
15
- columns:[
16
- header: "Name"
17
- data: 'name'
18
- ,
19
- header : "Location"
20
- data: "location"
21
- ,
22
- header : "Website"
23
- data: "website"
24
- ]
@@ -1,11 +0,0 @@
1
- %h2 Introduction
2
- %p Luca.JS was developed after a year of doing battle with Backbone.js developing large single page applications which acted as first class clients for the REST API which served our mobile apps.
3
- %p Backbone.js, for anyone who has developed a fair share of thick client apps in Javascript, is a godsend. Their minimialist philosophy in providing you just what you need to be able to build things really appeals to me and addressed the shortcomings in much larger frameworks such as ExtJS, SproutCoure, which provided you with too much and made it harder to develop unique looking public facing apps. However, for a lot of apps, especially for non-public facing, internal tools, it was almost too minimalist, and there was a lot of boilerplate code that needed to be written.
4
- %p Luca.js attempts to address a lot of these shortcomings by encompassing a lot of common patterns and what I consider to be best practices. It provides an augmented Backbone.View and Backbone.Collection class, many utilities and manager components.
5
- %h3 Containers
6
- %p One important feature of Luca is the concept of Container Views. These are views which are responsible for containing several other views, and their role is generating the structural DOM elements for you to be able to lay out these child views and show, hide, display or activate them as needed.
7
- %p Luca adheres to the Backbone.js party line mostly, in staying very minimalist. You can use Backbone and Luca interchangeably in almost every case.
8
- %h3 Components
9
- %p In addition to providing you with building blocks, I have included several Components which are built using Luca.Views, Luca.Collections and the various types of containers. These are things like a Grid which is a scrollable table automatically generated from a collection. A Form component which generates a form for you based on a given model, and handles a lot of tasks for you.
10
- %h3 Twitter Bootstrap 2.0 Integration
11
- %p Twitter and Backbone play very nicely together due to their philosophy of providing you with only the bare minimum pieces you need, and allowing you to choose which to use. Twitter is almost a pure CSS library, and Backbone is a way of structuring your code and handling DOM events and integration with your data persistence strategies. They overlap very little, if at all. Because they solve two different problems, and impose very little requirements on the developer, I have decided to give you the option to use both of them simultaneously.
@@ -1,43 +0,0 @@
1
- %h1 View Helpers
2
-
3
- %pre.prettyprint.lang-coffee
4
- :plain
5
- MyView = Luca.View.extend
6
- # conveniently bind to collections on
7
- # the collection manager, through this
8
- # hash syntax similar to Backbone.View's
9
- # event configuration for DOM event binding
10
- collectionEvents:
11
- "sample_collection reset" : "updateItems"
12
-
13
- # skip the common task of having to call
14
- # _.bindAll @, "itemClickHandler"
15
- # for all of your event handlers
16
- autoBindEventHandlers: true
17
-
18
- # define a list of DOM event bindings
19
- # since we set autoBindEventHandlers to true
20
- # we guarantee that all event handlers will
21
- # be called in the context of @this view
22
- events:
23
- "click .item" : "itemClickHandler"
24
-
25
- # don't forget to call the Luca.View prototype initialize
26
- initialize: (@options={})->
27
- Luca.View.prototype.initialize.apply @, arguments
28
-
29
- # Luca.View hooks
30
-
31
- # These methods will automatically get called when
32
- # a matching event is triggered on them
33
- beforeRender: ()->
34
- @$el.addClass('before-render')
35
-
36
- afterRender: ()->
37
- @$el.addClass('after-render')
38
-
39
- # If this view is activated for the first time by a Luca.Container
40
- # such as the CardView or the TabPanel, then this function will get
41
- # called only at that time
42
- firstActivation: ()->
43
- @doSomethingExpensiveOnlyOnce()
@@ -1,8 +0,0 @@
1
- %li.nav.cardswitch{:data=>{:slide=>0}} Card Container
2
- %li.nav.cardswitch{:data=>{:slide=>1}} Column Container
3
- %li.nav.cardswitch{:data=>{:slide=>2}} Split Container
4
- %li.nav.cardswitch{:data=>{:slide=>3}} Tabbed Container
5
- %li.nav.cardswitch{:data=>{:slide=>4}} Grid View
6
- %li.nav.cardswitch{:data=>{:slide=>5}} Form View
7
- %li.nav.cardswitch{:data=>{:slide=>6}} Complex View
8
- %li.nav.modal Modal Container
@@ -1,47 +0,0 @@
1
- Sandbox.views.FormDemo = Luca.components.FormView.extend
2
- afterRender: ()->
3
- @$el.parent().append Luca.templates["features/form_demo_code"]()
4
- prettyPrint()
5
- components:[
6
- markup: '<h3>Form View with Nested Column Container</h3>'
7
- ,
8
- ctype: 'column_view'
9
- layout: '33/33/33'
10
- components:[
11
- components:[
12
- ctype: 'text_field'
13
- name: 'textfield3'
14
- label: 'Sup baby?'
15
- placeHolder: 'Bootstrapped'
16
- ]
17
- ,
18
- components:[
19
- ctype: 'checkbox_field'
20
- label: 'Checkbox Field'
21
- name: 'checkbox1'
22
- state: 'success'
23
- ,
24
- ctype: 'select_field'
25
- label: 'Select Field'
26
- displayField: 'name'
27
- valueField: 'id'
28
- state: 'warning'
29
- collection:
30
- url: '/sandbox/api.js'
31
- ]
32
- ,
33
- components:[
34
- ctype: 'text_field'
35
- label: 'Text Field'
36
- name: 'textfield1'
37
- state: 'error'
38
- placeHolder: 'This is a placeholder'
39
- helperText : 'This is helper text'
40
- ,
41
- ctype: 'text_area_field'
42
- label: 'Text Area'
43
- name: 'textarea',
44
- width: 125
45
- ]
46
- ]
47
- ]
@@ -1,23 +0,0 @@
1
- Sandbox.views.GridDemo = Luca.components.GridView.extend
2
- collection:
3
- url: "/sandbox/api.js"
4
-
5
- afterInitialize: ()->
6
- @bind "activation", ()=>
7
- @resize( @$container().width() )
8
-
9
- afterRender: ()->
10
- Luca.components.GridView.prototype.afterRender?.apply @, arguments
11
- @$el.parent().append Luca.templates["features/grid_demo_code"]
12
- prettyPrint()
13
-
14
- columns:[
15
- header: "Name"
16
- data: 'name'
17
- ,
18
- header : "Location"
19
- data: "location"
20
- ,
21
- header : "Website"
22
- data: "website"
23
- ]
@@ -1 +0,0 @@
1
- Sandbox.views.CollectionEvents = Luca.View.extend
@@ -1,38 +0,0 @@
1
- Sandbox.views.PagesController = Luca.components.Controller.extend
2
- # the main component is the tab view which
3
- # has its own individual demos
4
- components:[
5
- ctype: 'tab_view'
6
- name: 'pages_tab_view'
7
- tab_position: 'left'
8
- components:[
9
- name: 'introduction'
10
- title: 'Introduction'
11
- template: 'features/introduction'
12
- ,
13
- name: 'view_helpers'
14
- title: 'View Helpers'
15
- template: 'features/view_helpers'
16
- ,
17
- name: 'collection_helpers'
18
- title: 'Collection Helpers'
19
- template: 'features/collection_helpers'
20
- ,
21
- ctype: 'form_demo'
22
- name: 'form_demo'
23
- title: 'Form Views'
24
- ,
25
- ctype: 'grid_demo'
26
- name: 'grid_demo'
27
- title: 'Collection Grid'
28
- ,
29
- ctype: 'development_console'
30
- name: 'development_console'
31
- title: "Development Console"
32
- ,
33
- ctype: "collection_inspector"
34
- name: "collection_inspector"
35
- title: "Collection Inspector"
36
- ]
37
- ]
38
-
@@ -1,2 +0,0 @@
1
- _.component('Luca.components.CollectionInspector').extends('Luca.View').with
2
- name: "collection_inspector"
@@ -1,59 +0,0 @@
1
- _.component('Luca.components.DevelopmentConsole').extends('Luca.View').with
2
-
3
- name: "development_console"
4
-
5
- className: 'luca-ui-development-console'
6
-
7
- initialize: (@options={})->
8
- Luca.View::initialize.apply @, arguments
9
- if @modal
10
- @$el.addClass 'luca-ui-modal'
11
-
12
- beforeRender: ()->
13
- @$el.append @make("div",class:"console-inner")
14
-
15
- @console_el = @$('.console-inner')
16
-
17
- @console = @console_el.console
18
- promptLabel: "Coffee> "
19
- animateScroll: true
20
- promptHistory: true
21
- autoFocus: true
22
- commandValidate: (line)->
23
- valid = true
24
-
25
- valid = false if line is ""
26
-
27
- try
28
- if CoffeeScript.compile(line)
29
- valid = true
30
- else
31
- valid = false
32
- catch error
33
- valid = false
34
-
35
- valid
36
-
37
- returnValue: (val)->
38
- return "undefined" unless val?
39
- val?.toString() || ""
40
-
41
- parseLine: (line)->
42
- line = _.string.strip(line)
43
- line = line.replace(/^return/,' ')
44
-
45
- "return #{ line }"
46
-
47
- commandHandle: (line)->
48
- return if line is ""
49
-
50
- compiled = CoffeeScript.compile( @parseLine(line) )
51
-
52
- try
53
- ret = eval(compiled)
54
- return @returnValue(ret)
55
- catch error
56
- if error.message.match /circular structure to JSON/
57
- return ret.toString()
58
-
59
- error.toString()
@@ -1,47 +0,0 @@
1
- .luca-ui-development-console.luca-ui-modal {
2
- position: absolute;
3
- left: 50%;
4
- margin-left: -375px;
5
- width: 750px;
6
- height: 500px;
7
- }
8
-
9
- .luca-ui-development-console {
10
- background: rgba(0,0,0,0.9);
11
- font-size: 16px;
12
- margin-top: 1em;
13
- font-family: "Monaco";
14
- .console-inner {
15
- color: #fff;
16
- height: 600px;
17
- width: 800px;
18
- max-height: 600px;
19
- .jquery-console-inner {
20
- height: 599px;
21
- width: 799px;
22
- overflow: auto;
23
- padding: 0.5em;
24
- }
25
-
26
- .jquery-console-focus .jquery-console-cursor {
27
- font-weight: bold;
28
- color: #fff;
29
- background: rgba(255,255,255,0.2);
30
- }
31
-
32
- .jquery-console-message {
33
- margin:10px 0px;
34
- }
35
-
36
- .jquery-console-message-error {
37
- font-weight: bold;
38
- color: #ef0505;
39
- padding: 0.1em;
40
- }
41
-
42
- .jquery-console-prompt-label {
43
- font-weight: bold;
44
- color: yellow;
45
- }
46
- }
47
- }