luca 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +17 -0
  3. data/Gemfile.lock +77 -0
  4. data/Guardfile +22 -0
  5. data/README.md +291 -0
  6. data/Rakefile +28 -0
  7. data/app.rb +46 -0
  8. data/assets/images/glyphicons-halflings-white.png +0 -0
  9. data/assets/images/glyphicons-halflings.png +0 -0
  10. data/assets/javascripts/dependencies/backbone-min.js +37 -0
  11. data/assets/javascripts/dependencies/backbone-query.min.js +1 -0
  12. data/assets/javascripts/dependencies/bootstrap.min.js +1 -0
  13. data/assets/javascripts/dependencies/jasmine-html.js +190 -0
  14. data/assets/javascripts/dependencies/jasmine.js +2476 -0
  15. data/assets/javascripts/dependencies/jquery.js +4 -0
  16. data/assets/javascripts/dependencies/modal.js +698 -0
  17. data/assets/javascripts/dependencies/modernizr.min.js +30 -0
  18. data/assets/javascripts/dependencies/prettify.js +28 -0
  19. data/assets/javascripts/dependencies/sinon.js +3469 -0
  20. data/assets/javascripts/dependencies/spin-min.js +2 -0
  21. data/assets/javascripts/dependencies/underscore-min.js +31 -0
  22. data/assets/javascripts/dependencies/underscore-string.min.js +14 -0
  23. data/assets/javascripts/dependencies.coffee +7 -0
  24. data/assets/javascripts/luca-ui-base.coffee +12 -0
  25. data/assets/javascripts/luca-ui-spec.coffee +2 -0
  26. data/assets/javascripts/luca-ui.coffee +3 -0
  27. data/assets/javascripts/sandbox/collections/sample.coffee +0 -0
  28. data/assets/javascripts/sandbox/config.coffee +7 -0
  29. data/assets/javascripts/sandbox/sandbox.coffee +16 -0
  30. data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +33 -0
  31. data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +48 -0
  32. data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +24 -0
  33. data/assets/javascripts/sandbox/templates/features/introduction.luca +11 -0
  34. data/assets/javascripts/sandbox/templates/features/view_helpers.luca +43 -0
  35. data/assets/javascripts/sandbox/templates/navigation.luca +8 -0
  36. data/assets/javascripts/sandbox/views/form_demo.coffee +47 -0
  37. data/assets/javascripts/sandbox/views/grid_demo.coffee +23 -0
  38. data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +1 -0
  39. data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +28 -0
  40. data/assets/javascripts/sandbox.coffee +4 -0
  41. data/assets/javascripts/spec-dependencies.coffee +4 -0
  42. data/assets/stylesheets/bootstrap-responsive.min.css +3 -0
  43. data/assets/stylesheets/bootstrap.min.css +610 -0
  44. data/assets/stylesheets/jasmine.css +166 -0
  45. data/assets/stylesheets/luca-ui-bootstrap.css +5 -0
  46. data/assets/stylesheets/luca-ui-spec.css +3 -0
  47. data/assets/stylesheets/luca-ui.css +3 -0
  48. data/assets/stylesheets/prettify.css +40 -0
  49. data/assets/stylesheets/sandbox/sandbox.scss +4 -0
  50. data/assets/stylesheets/sandbox.css +3 -0
  51. data/config.ru +11 -0
  52. data/lib/luca/command_line.rb +69 -0
  53. data/lib/luca/rails/engine.rb +12 -0
  54. data/lib/luca/rails/version.rb +6 -0
  55. data/lib/luca/rails.rb +9 -0
  56. data/lib/luca/template.rb +51 -0
  57. data/lib/luca/test_harness.rb +106 -0
  58. data/lib/luca.rb +1 -0
  59. data/lib/sprockets/luca_template.rb +49 -0
  60. data/lib/templates/spec_manifest_javascripts.erb +7 -0
  61. data/lib/templates/spec_manifest_stylesheets.erb +11 -0
  62. data/luca.gemspec +26 -0
  63. data/public/jasmine/index.html +26 -0
  64. data/public/sandbox/api.js +1 -0
  65. data/spec/components/application_spec.coffee +0 -0
  66. data/spec/components/collection_loader_view_spec.coffee +0 -0
  67. data/spec/components/controller_spec.coffee +0 -0
  68. data/spec/components/form_view_spec.coffee +13 -0
  69. data/spec/components/grid_view_spec.coffee +0 -0
  70. data/spec/components/record_manager_spec.coffee +0 -0
  71. data/spec/components/template_spec.coffee +0 -0
  72. data/spec/containers/card_view_spec.coffee +1 -0
  73. data/spec/containers/column_view_spec.coffee +0 -0
  74. data/spec/containers/modal_view_spec.coffee +0 -0
  75. data/spec/containers/panel_view_spec.coffee +0 -0
  76. data/spec/containers/split_view_spec.coffee +0 -0
  77. data/spec/containers/tab_view_spec.coffee +0 -0
  78. data/spec/containers/viewport_spec.coffee +0 -0
  79. data/spec/core/collection_spec.coffee +215 -0
  80. data/spec/core/container_spec.coffee +0 -0
  81. data/spec/core/field_spec.coffee +0 -0
  82. data/spec/core/observer_spec.coffee +0 -0
  83. data/spec/core/view_spec.coffee +87 -0
  84. data/spec/framework_spec.coffee +48 -0
  85. data/spec/helper.coffee +120 -0
  86. data/spec/managers/collection_manager_spec.coffee +95 -0
  87. data/spec/managers/socket_manager_spec.coffee +0 -0
  88. data/src/components/application.coffee +83 -0
  89. data/src/components/base_toolbar.coffee +16 -0
  90. data/src/components/collection_loader_view.coffee +37 -0
  91. data/src/components/controller.coffee +41 -0
  92. data/src/components/fields/button_field.coffee +40 -0
  93. data/src/components/fields/checkbox_field.coffee +41 -0
  94. data/src/components/fields/file_upload_field.coffee +15 -0
  95. data/src/components/fields/hidden_field.coffee +18 -0
  96. data/src/components/fields/select_field.coffee +100 -0
  97. data/src/components/fields/text_area_field.coffee +43 -0
  98. data/src/components/fields/text_field.coffee +42 -0
  99. data/src/components/fields/type_ahead_field.coffee +10 -0
  100. data/src/components/form_button_toolbar.coffee +26 -0
  101. data/src/components/form_view.coffee +205 -0
  102. data/src/components/grid_view.coffee +208 -0
  103. data/src/components/record_manager.coffee +215 -0
  104. data/src/components/router.coffee +34 -0
  105. data/src/components/template.coffee +19 -0
  106. data/src/containers/card_view.coffee +89 -0
  107. data/src/containers/column_view.coffee +48 -0
  108. data/src/containers/modal_view.coffee +85 -0
  109. data/src/containers/panel_view.coffee +24 -0
  110. data/src/containers/split_view.coffee +12 -0
  111. data/src/containers/tab_view.coffee +77 -0
  112. data/src/containers/viewport.coffee +16 -0
  113. data/src/core/collection.coffee +319 -0
  114. data/src/core/container.coffee +256 -0
  115. data/src/core/field.coffee +68 -0
  116. data/src/core/observer.coffee +17 -0
  117. data/src/core/view.coffee +190 -0
  118. data/src/framework.coffee +110 -0
  119. data/src/index.coffee +255 -0
  120. data/src/managers/collection_manager.coffee +168 -0
  121. data/src/managers/socket_manager.coffee +54 -0
  122. data/src/modules/deferrable.coffee +18 -0
  123. data/src/modules/local_storage.coffee +50 -0
  124. data/src/stylesheets/base.scss +78 -0
  125. data/src/stylesheets/components/form_view.scss +54 -0
  126. data/src/stylesheets/components/grid_view.scss +111 -0
  127. data/src/stylesheets/components/toolbar.scss +15 -0
  128. data/src/stylesheets/containers/container.scss +7 -0
  129. data/src/stylesheets/containers/modal_view.scss +0 -0
  130. data/src/stylesheets/containers/tab_view.scss +33 -0
  131. data/src/stylesheets/normalize.scss +430 -0
  132. data/src/templates/components/bootstrap_form_controls.luca +7 -0
  133. data/src/templates/components/collection_loader_view.luca +5 -0
  134. data/src/templates/components/form_view.luca +15 -0
  135. data/src/templates/components/grid_view.luca +9 -0
  136. data/src/templates/components/grid_view_empty_text.luca +3 -0
  137. data/src/templates/containers/basic.luca +1 -0
  138. data/src/templates/containers/tab_selector_container.luca +8 -0
  139. data/src/templates/containers/tab_view.luca +1 -0
  140. data/src/templates/containers/toolbar_wrapper.luca +1 -0
  141. data/src/templates/fields/button_field.luca +2 -0
  142. data/src/templates/fields/button_field_link.luca +5 -0
  143. data/src/templates/fields/checkbox_field.luca +9 -0
  144. data/src/templates/fields/file_upload_field.luca +8 -0
  145. data/src/templates/fields/hidden_field.luca +1 -0
  146. data/src/templates/fields/select_field.luca +7 -0
  147. data/src/templates/fields/text_area_field.luca +8 -0
  148. data/src/templates/fields/text_field.luca +13 -0
  149. data/src/templates/sample/contents.luca +1 -0
  150. data/src/templates/sample/welcome.luca +1 -0
  151. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  152. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  153. data/vendor/assets/javascripts/luca-spec-dependencies.js +6135 -0
  154. data/vendor/assets/javascripts/luca-ui-base.js +1527 -0
  155. data/vendor/assets/javascripts/luca-ui-spec.js +3654 -0
  156. data/vendor/assets/javascripts/luca-ui.js +2763 -0
  157. data/vendor/assets/luca-ui/base.css +85 -0
  158. data/vendor/assets/luca-ui/components/application.js +91 -0
  159. data/vendor/assets/luca-ui/components/base_toolbar.js +23 -0
  160. data/vendor/assets/luca-ui/components/controller.js +38 -0
  161. data/vendor/assets/luca-ui/components/fields/button_field.js +45 -0
  162. data/vendor/assets/luca-ui/components/fields/checkbox_field.js +43 -0
  163. data/vendor/assets/luca-ui/components/fields/file_upload_field.js +20 -0
  164. data/vendor/assets/luca-ui/components/fields/hidden_field.js +20 -0
  165. data/vendor/assets/luca-ui/components/fields/select_field.js +97 -0
  166. data/vendor/assets/luca-ui/components/fields/text_area_field.js +48 -0
  167. data/vendor/assets/luca-ui/components/fields/text_field.js +46 -0
  168. data/vendor/assets/luca-ui/components/fields/type_ahead_field.js +13 -0
  169. data/vendor/assets/luca-ui/components/form_button_toolbar.js +32 -0
  170. data/vendor/assets/luca-ui/components/form_view.css +32 -0
  171. data/vendor/assets/luca-ui/components/form_view.js +207 -0
  172. data/vendor/assets/luca-ui/components/grid_view.css +76 -0
  173. data/vendor/assets/luca-ui/components/grid_view.js +202 -0
  174. data/vendor/assets/luca-ui/components/record_manager.js +207 -0
  175. data/vendor/assets/luca-ui/components/router.js +36 -0
  176. data/vendor/assets/luca-ui/components/template.js +26 -0
  177. data/vendor/assets/luca-ui/components/toolbar.css +11 -0
  178. data/vendor/assets/luca-ui/containers/card_view.js +98 -0
  179. data/vendor/assets/luca-ui/containers/column_view.js +52 -0
  180. data/vendor/assets/luca-ui/containers/container.css +3 -0
  181. data/vendor/assets/luca-ui/containers/modal_view.css +0 -0
  182. data/vendor/assets/luca-ui/containers/modal_view.js +87 -0
  183. data/vendor/assets/luca-ui/containers/panel_view.js +34 -0
  184. data/vendor/assets/luca-ui/containers/split_view.js +13 -0
  185. data/vendor/assets/luca-ui/containers/tab_view.css +16 -0
  186. data/vendor/assets/luca-ui/containers/tab_view.js +80 -0
  187. data/vendor/assets/luca-ui/containers/viewport.js +18 -0
  188. data/vendor/assets/luca-ui/core/collection.js +221 -0
  189. data/vendor/assets/luca-ui/core/container.js +205 -0
  190. data/vendor/assets/luca-ui/core/field.js +59 -0
  191. data/vendor/assets/luca-ui/core/observer.js +42 -0
  192. data/vendor/assets/luca-ui/core/view.js +127 -0
  193. data/vendor/assets/luca-ui/framework.js +110 -0
  194. data/vendor/assets/luca-ui/index.js +5 -0
  195. data/vendor/assets/luca-ui/managers/collection_manager.js +98 -0
  196. data/vendor/assets/luca-ui/managers/socket_manager.js +52 -0
  197. data/vendor/assets/luca-ui/modules/deferrable.js +21 -0
  198. data/vendor/assets/luca-ui/modules/local_storage.js +81 -0
  199. data/vendor/assets/luca-ui/normalize.css +359 -0
  200. data/vendor/assets/luca-ui/stylesheets/base.css +85 -0
  201. data/vendor/assets/luca-ui/stylesheets/components/form_view.css +32 -0
  202. data/vendor/assets/luca-ui/stylesheets/components/grid_view.css +76 -0
  203. data/vendor/assets/luca-ui/stylesheets/components/toolbar.css +11 -0
  204. data/vendor/assets/luca-ui/stylesheets/containers/container.css +3 -0
  205. data/vendor/assets/luca-ui/stylesheets/containers/modal_view.css +0 -0
  206. data/vendor/assets/luca-ui/stylesheets/containers/tab_view.css +16 -0
  207. data/vendor/assets/luca-ui/stylesheets/normalize.css +359 -0
  208. data/vendor/assets/luca-ui/templates/components/bootstrap_form_controls.js +4 -0
  209. data/vendor/assets/luca-ui/templates/components/form_view.js +4 -0
  210. data/vendor/assets/luca-ui/templates/components/grid_view.js +4 -0
  211. data/vendor/assets/luca-ui/templates/components/grid_view_empty_text.js +4 -0
  212. data/vendor/assets/luca-ui/templates/containers/basic.js +4 -0
  213. data/vendor/assets/luca-ui/templates/containers/tab_selector_container.js +4 -0
  214. data/vendor/assets/luca-ui/templates/containers/tab_view.js +4 -0
  215. data/vendor/assets/luca-ui/templates/containers/toolbar_wrapper.js +4 -0
  216. data/vendor/assets/luca-ui/templates/fields/button_field.js +4 -0
  217. data/vendor/assets/luca-ui/templates/fields/button_field_link.js +4 -0
  218. data/vendor/assets/luca-ui/templates/fields/checkbox_field.js +4 -0
  219. data/vendor/assets/luca-ui/templates/fields/file_upload_field.js +4 -0
  220. data/vendor/assets/luca-ui/templates/fields/hidden_field.js +4 -0
  221. data/vendor/assets/luca-ui/templates/fields/select_field.js +4 -0
  222. data/vendor/assets/luca-ui/templates/fields/text_area_field.js +4 -0
  223. data/vendor/assets/luca-ui/templates/fields/text_field.js +4 -0
  224. data/vendor/assets/luca-ui/templates/sample/contents.js +4 -0
  225. data/vendor/assets/luca-ui/templates/sample/welcome.js +4 -0
  226. data/vendor/assets/stylesheets/luca-spec-dependencies.css +166 -0
  227. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +1201 -0
  228. data/vendor/assets/stylesheets/luca-ui-spec.css +586 -0
  229. data/vendor/assets/stylesheets/luca-ui.css +586 -0
  230. data/views/index.erb +20 -0
  231. data/views/jasmine.erb +22 -0
  232. data/views/spec_harness.erb +29 -0
  233. metadata +361 -0
@@ -0,0 +1,85 @@
1
+ html.luca-ui-fullscreen {
2
+ height: 100%; }
3
+ html.luca-ui-fullscreen body {
4
+ height: 100%;
5
+ padding: 0;
6
+ margin: 0; }
7
+ html.luca-ui-fullscreen .luca-ui-viewport {
8
+ height: 100%;
9
+ padding: 0;
10
+ margin: 0; }
11
+
12
+ .luca-ui-viewport li {
13
+ list-style-type: none; }
14
+ .luca-ui-viewport li.nav {
15
+ cursor: pointer; }
16
+
17
+ /*http://csswizardry.com/fluid-grids/#generated-grids*/
18
+ .wrapper {
19
+ max-width: 1208px;
20
+ /* max-width:894px;*/
21
+ padding: 0 15px;
22
+ margin: 0 auto; }
23
+
24
+ /*
25
+ Column container
26
+ */
27
+ .grids {
28
+ width: auto;
29
+ max-width: 924px;
30
+ clear: both;
31
+ margin: 0 0 0 -3.247%;
32
+ list-style: none;
33
+ /* So we can make grids out of lists. */
34
+ overflow: hidden;
35
+ /* Clear the floats */ }
36
+
37
+ [class*="grid-"] {
38
+ float: left;
39
+ margin: 0 3.247% 0 0; }
40
+
41
+ .grid-margin {
42
+ margin: 0 3.247% 0 0; }
43
+
44
+ .grids .grid-margin {
45
+ margin: 0 0 0 3.247%; }
46
+
47
+ .grids [class*="grid-"] {
48
+ margin: 0 0 0 3.247%; }
49
+
50
+ .grid-1 {
51
+ width: 5.087%; }
52
+
53
+ .grid-2 {
54
+ width: 13.42%; }
55
+
56
+ .grid-3 {
57
+ width: 21.753%; }
58
+
59
+ .grid-4 {
60
+ width: 30.087%; }
61
+
62
+ .grid-5 {
63
+ width: 38.42%; }
64
+
65
+ .grid-6 {
66
+ width: 46.753%; }
67
+
68
+ .grid-7 {
69
+ width: 55.087%; }
70
+
71
+ .grid-8 {
72
+ width: 63.42%; }
73
+
74
+ .grid-9 {
75
+ width: 71.753%; }
76
+
77
+ .grid-10 {
78
+ width: 80.087%; }
79
+
80
+ .grid-11 {
81
+ width: 88.42%; }
82
+
83
+ .grid-12 {
84
+ width: 96.753%;
85
+ margin: 0; }
@@ -0,0 +1,91 @@
1
+ (function() {
2
+
3
+ Luca.Application = Luca.containers.Viewport.extend({
4
+ components: [
5
+ {
6
+ ctype: 'controller',
7
+ name: 'main_controller',
8
+ defaultCard: 'welcome',
9
+ components: [
10
+ {
11
+ ctype: 'template',
12
+ name: 'welcome',
13
+ template: 'sample/welcome',
14
+ templateContainer: "Luca.templates"
15
+ }
16
+ ]
17
+ }
18
+ ],
19
+ initialize: function(options) {
20
+ var _this = this;
21
+ this.options = options != null ? options : {};
22
+ Luca.containers.Viewport.prototype.initialize.apply(this, arguments);
23
+ this.collectionManager = new Luca.CollectionManager();
24
+ this.state = new Backbone.Model(this.defaultState);
25
+ return this.bind("ready", function() {
26
+ return _this.render();
27
+ });
28
+ },
29
+ activeView: function() {
30
+ var active;
31
+ if (active = this.activeSubSection()) {
32
+ return this.view(active);
33
+ } else {
34
+ return this.view(this.activeSection());
35
+ }
36
+ },
37
+ activeSubSection: function() {
38
+ return this.get("active_sub_section");
39
+ },
40
+ activeSection: function() {
41
+ return this.get("active_section");
42
+ },
43
+ afterComponents: function() {
44
+ var _ref, _ref2, _ref3,
45
+ _this = this;
46
+ if ((_ref = Luca.containers.Viewport.prototype.afterComponents) != null) {
47
+ _ref.apply(this, arguments);
48
+ }
49
+ if ((_ref2 = this.getMainController()) != null) {
50
+ _ref2.bind("after:card:switch", function(previous, current) {
51
+ return _this.state.set({
52
+ active_section: current.name
53
+ });
54
+ });
55
+ }
56
+ return (_ref3 = this.getMainController()) != null ? _ref3.each(function(component) {
57
+ if (component.ctype.match(/controller$/)) {
58
+ return component.bind("after:card:switch", function(previous, current) {
59
+ return _this.state.set({
60
+ active_sub_section: current.name
61
+ });
62
+ });
63
+ }
64
+ }) : void 0;
65
+ },
66
+ beforeRender: function() {
67
+ var _ref;
68
+ return (_ref = Luca.containers.Viewport.prototype.beforeRender) != null ? _ref.apply(this, arguments) : void 0;
69
+ },
70
+ boot: function() {
71
+ console.log("Sup?");
72
+ return this.trigger("ready");
73
+ },
74
+ collection: function() {
75
+ return this.collectionManager.getOrCreate.apply(this.collectionManager, arguments);
76
+ },
77
+ get: function(attribute) {
78
+ return this.state.get(attribute);
79
+ },
80
+ getMainController: function() {
81
+ return this.view("main_controler");
82
+ },
83
+ set: function(attributes) {
84
+ return this.state.set(attributes);
85
+ },
86
+ view: function(name) {
87
+ return Luca.cache(name);
88
+ }
89
+ });
90
+
91
+ }).call(this);
@@ -0,0 +1,23 @@
1
+ (function() {
2
+
3
+ Luca.components.Toolbar = Luca.core.Container.extend({
4
+ className: 'luca-ui-toolbar',
5
+ position: 'bottom',
6
+ initialize: function(options) {
7
+ this.options = options != null ? options : {};
8
+ return Luca.core.Container.prototype.initialize.apply(this, arguments);
9
+ },
10
+ prepareComponents: function() {
11
+ var _this = this;
12
+ return _(this.components).each(function(component) {
13
+ return component.container = _this.el;
14
+ });
15
+ },
16
+ render: function() {
17
+ return $(this.container).append(this.el);
18
+ }
19
+ });
20
+
21
+ Luca.register("toolbar", "Luca.components.Toolbar");
22
+
23
+ }).call(this);
@@ -0,0 +1,38 @@
1
+ (function() {
2
+
3
+ Luca.components.Controller = Luca.containers.CardView.extend({
4
+ initialize: function(options) {
5
+ var _ref;
6
+ this.options = options;
7
+ Luca.containers.CardView.prototype.initialize.apply(this, arguments);
8
+ this.defaultCard || (this.defaultCard = (_ref = this.components[0]) != null ? _ref.name : void 0);
9
+ if (!this.defaultCard) {
10
+ throw "Controllers must specify a defaultCard property and/or the first component must have a name";
11
+ }
12
+ return this.state = new Backbone.Model({
13
+ active_section: this.defaultCard
14
+ });
15
+ },
16
+ each: function(fn) {
17
+ var _this = this;
18
+ return _(this.components).each(function(component) {
19
+ return fn.apply(_this, [component]);
20
+ });
21
+ },
22
+ "default": function(callback) {
23
+ return this.navigate_to(this.defaultCard, callback);
24
+ },
25
+ navigate_to: function(section, callback) {
26
+ var _this = this;
27
+ section || (section = this.defaultCard);
28
+ this.activate(section, false, function(activator, previous, current) {
29
+ _this.state.set({
30
+ active_section: current.name
31
+ });
32
+ if (_.isFunction(callback)) return callback.apply(current);
33
+ });
34
+ return this.find(section);
35
+ }
36
+ });
37
+
38
+ }).call(this);
@@ -0,0 +1,45 @@
1
+ (function() {
2
+
3
+ Luca.fields.ButtonField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ readOnly: true,
6
+ events: {
7
+ "click input": "click_handler"
8
+ },
9
+ hooks: ["button:click"],
10
+ className: 'luca-ui-field luca-ui-button-field',
11
+ template: 'fields/button_field',
12
+ click_handler: function(e) {
13
+ var me, my;
14
+ me = my = $(e.currentTarget);
15
+ return this.trigger("button:click");
16
+ },
17
+ initialize: function(options) {
18
+ var _ref;
19
+ this.options = options != null ? options : {};
20
+ _.extend(this.options);
21
+ _.bindAll(this, "click_handler");
22
+ Luca.core.Field.prototype.initialize.apply(this, arguments);
23
+ if ((_ref = this.icon_class) != null ? _ref.length : void 0) {
24
+ return this.template = "fields/button_field_link";
25
+ }
26
+ },
27
+ afterInitialize: function() {
28
+ this.input_id || (this.input_id = _.uniqueId('button'));
29
+ this.input_name || (this.input_name = this.name || (this.name = this.input_id));
30
+ this.input_value || (this.input_value = this.label || (this.label = this.text));
31
+ this.input_type || (this.input_type = "button");
32
+ this.input_class || (this.input_class = this["class"]);
33
+ this.icon_class || (this.icon_class = "");
34
+ if (this.icon_class.length && !this.icon_class.match(/^icon-/)) {
35
+ return this.icon_class = "icon-" + this.icon_class;
36
+ }
37
+ },
38
+ setValue: function() {
39
+ return true;
40
+ }
41
+ });
42
+
43
+ Luca.register("button_field", "Luca.fields.ButtonField");
44
+
45
+ }).call(this);
@@ -0,0 +1,43 @@
1
+ (function() {
2
+
3
+ Luca.fields.CheckboxField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ events: {
6
+ "change input": "change_handler"
7
+ },
8
+ change_handler: function(e) {
9
+ var me, my;
10
+ me = my = $(e.currentTarget);
11
+ this.trigger("on:change", this, e);
12
+ if (me.checked === true) {
13
+ return this.trigger("checked");
14
+ } else {
15
+ return this.trigger("unchecked");
16
+ }
17
+ },
18
+ className: 'luca-ui-checkbox-field luca-ui-field',
19
+ template: 'fields/checkbox_field',
20
+ hooks: ["checked", "unchecked"],
21
+ initialize: function(options) {
22
+ this.options = options != null ? options : {};
23
+ _.extend(this, this.options);
24
+ _.bindAll(this, "change_handler");
25
+ return Luca.core.Field.prototype.initialize.apply(this, arguments);
26
+ },
27
+ afterInitialize: function() {
28
+ this.input_id || (this.input_id = _.uniqueId('field'));
29
+ this.input_name || (this.input_name = this.name);
30
+ this.input_value || (this.input_value = 1);
31
+ return this.label || (this.label = this.name);
32
+ },
33
+ setValue: function(checked) {
34
+ return this.input.attr('checked', checked);
35
+ },
36
+ getValue: function() {
37
+ return this.input.attr('checked') === true;
38
+ }
39
+ });
40
+
41
+ Luca.register("checkbox_field", "Luca.fields.CheckboxField");
42
+
43
+ }).call(this);
@@ -0,0 +1,20 @@
1
+ (function() {
2
+
3
+ Luca.fields.FileUploadField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ template: 'fields/file_upload_field',
6
+ initialize: function(options) {
7
+ this.options = options != null ? options : {};
8
+ return Luca.core.Field.prototype.initialize.apply(this, arguments);
9
+ },
10
+ afterInitialize: function() {
11
+ this.input_id || (this.input_id = _.uniqueId('field'));
12
+ this.input_name || (this.input_name = this.name);
13
+ this.label || (this.label = this.name);
14
+ return this.helperText || (this.helperText = "");
15
+ }
16
+ });
17
+
18
+ Luca.register("file_upload_field", "Luca.fields.FileUploadField");
19
+
20
+ }).call(this);
@@ -0,0 +1,20 @@
1
+ (function() {
2
+
3
+ Luca.fields.HiddenField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ template: 'fields/hidden_field',
6
+ initialize: function(options) {
7
+ this.options = options != null ? options : {};
8
+ return Luca.core.Field.prototype.initialize.apply(this, arguments);
9
+ },
10
+ afterInitialize: function() {
11
+ this.input_id || (this.input_id = _.uniqueId('field'));
12
+ this.input_name || (this.input_name = this.name);
13
+ this.input_value || (this.input_value = this.value);
14
+ return this.label || (this.label = this.name);
15
+ }
16
+ });
17
+
18
+ Luca.register("hidden_field", "Luca.fields.HiddenField");
19
+
20
+ }).call(this);
@@ -0,0 +1,97 @@
1
+ (function() {
2
+
3
+ Luca.fields.SelectField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ events: {
6
+ "change select": "change_handler"
7
+ },
8
+ hooks: ["after:select"],
9
+ className: 'luca-ui-select-field luca-ui-field',
10
+ template: "fields/select_field",
11
+ includeBlank: true,
12
+ blankValue: '',
13
+ blankText: 'Select One',
14
+ initialize: function(options) {
15
+ this.options = options != null ? options : {};
16
+ _.extend(this, this.options);
17
+ _.extend(this, Luca.modules.Deferrable);
18
+ _.bindAll(this, "change_handler", "populateOptions", "beforeFetch");
19
+ Luca.core.Field.prototype.initialize.apply(this, arguments);
20
+ this.input_id || (this.input_id = _.uniqueId('field'));
21
+ this.input_name || (this.input_name = this.name);
22
+ this.label || (this.label = this.name);
23
+ if (_.isUndefined(this.retainValue)) return this.retainValue = true;
24
+ },
25
+ afterInitialize: function() {
26
+ var _ref;
27
+ if ((_ref = this.collection) != null ? _ref.data : void 0) {
28
+ this.valueField || (this.valueField = "id");
29
+ this.displayField || (this.displayField = "name");
30
+ this.parseData();
31
+ }
32
+ try {
33
+ this.configure_collection();
34
+ } catch (e) {
35
+ console.log("Error Configuring Collection", this, e.message);
36
+ }
37
+ this.collection.bind("before:fetch", this.beforeFetch);
38
+ return this.collection.bind("reset", this.populateOptions);
39
+ },
40
+ parseData: function() {
41
+ var _this = this;
42
+ return this.collection.data = _(this.collection.data).map(function(record) {
43
+ var hash;
44
+ if (!_.isArray(record)) return record;
45
+ hash = {};
46
+ hash[_this.valueField] = record[0];
47
+ hash[_this.displayField] = record[1];
48
+ return hash;
49
+ });
50
+ },
51
+ afterRender: function() {
52
+ var _ref, _ref2;
53
+ this.input = $('select', this.el);
54
+ if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
55
+ return this.populateOptions();
56
+ } else {
57
+ return this.collection.trigger("reset");
58
+ }
59
+ },
60
+ setValue: function(value) {
61
+ this.currentValue = value;
62
+ return Luca.core.Field.prototype.setValue.apply(this, arguments);
63
+ },
64
+ beforeFetch: function() {
65
+ return this.resetOptions();
66
+ },
67
+ change_handler: function(e) {
68
+ return this.trigger("on:change", this, e);
69
+ },
70
+ resetOptions: function() {
71
+ this.input.html('');
72
+ if (this.includeBlank) {
73
+ return this.input.append("<option value='" + this.blankValue + "'>" + this.blankText + "</option>");
74
+ }
75
+ },
76
+ populateOptions: function() {
77
+ var _ref,
78
+ _this = this;
79
+ this.resetOptions();
80
+ if (((_ref = this.collection) != null ? _ref.each : void 0) != null) {
81
+ this.collection.each(function(model) {
82
+ var display, option, selected, value;
83
+ value = model.get(_this.valueField);
84
+ display = model.get(_this.displayField);
85
+ if (_this.selected && value === _this.selected) selected = "selected";
86
+ option = "<option " + selected + " value='" + value + "'>" + display + "</option>";
87
+ return _this.input.append(option);
88
+ });
89
+ }
90
+ this.trigger("after:populate:options", this);
91
+ return this.setValue(this.currentValue);
92
+ }
93
+ });
94
+
95
+ Luca.register("select_field", "Luca.fields.SelectField");
96
+
97
+ }).call(this);
@@ -0,0 +1,48 @@
1
+ (function() {
2
+
3
+ Luca.fields.TextAreaField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ events: {
6
+ "keydown input": "keydown_handler",
7
+ "blur input": "blur_handler",
8
+ "focus input": "focus_handler"
9
+ },
10
+ template: 'fields/text_area_field',
11
+ height: "200px",
12
+ width: "90%",
13
+ initialize: function(options) {
14
+ this.options = options != null ? options : {};
15
+ _.bindAll(this, "keydown_handler");
16
+ Luca.core.Field.prototype.initialize.apply(this, arguments);
17
+ this.input_id || (this.input_id = _.uniqueId('field'));
18
+ this.input_name || (this.input_name = this.name);
19
+ this.label || (this.label = this.name);
20
+ this.input_class || (this.input_class = this["class"]);
21
+ return this.inputStyles || (this.inputStyles = "height:" + this.height + ";width:" + this.width);
22
+ },
23
+ setValue: function(value) {
24
+ return $(this.field()).val(value);
25
+ },
26
+ getValue: function() {
27
+ return $(this.field()).val();
28
+ },
29
+ field: function() {
30
+ return this.input = $("textarea#" + this.input_id, this.el);
31
+ },
32
+ keydown_handler: function(e) {
33
+ var me, my;
34
+ return me = my = $(e.currentTarget);
35
+ },
36
+ blur_handler: function(e) {
37
+ var me, my;
38
+ return me = my = $(e.currentTarget);
39
+ },
40
+ focus_handler: function(e) {
41
+ var me, my;
42
+ return me = my = $(e.currentTarget);
43
+ }
44
+ });
45
+
46
+ Luca.register("text_area_field", "Luca.fields.TextAreaField");
47
+
48
+ }).call(this);
@@ -0,0 +1,46 @@
1
+ (function() {
2
+
3
+ Luca.fields.TextField = Luca.core.Field.extend({
4
+ form_field: true,
5
+ events: {
6
+ "keydown input": "keydown_handler",
7
+ "blur input": "blur_handler",
8
+ "focus input": "focus_handler",
9
+ "change input": "change_handler"
10
+ },
11
+ template: 'fields/text_field',
12
+ initialize: function(options) {
13
+ this.options = options != null ? options : {};
14
+ _.bindAll(this, "keydown_handler", "blur_handler", "focus_handler");
15
+ Luca.core.Field.prototype.initialize.apply(this, arguments);
16
+ this.input_id || (this.input_id = _.uniqueId('field'));
17
+ this.input_name || (this.input_name = this.name);
18
+ this.label || (this.label = this.name);
19
+ if (this.prepend) {
20
+ this.$el.addClass('input-prepend');
21
+ this.addOn = this.prepend;
22
+ }
23
+ if (this.append) {
24
+ this.$el.addClass('input-append');
25
+ return this.addOn = this.append;
26
+ }
27
+ },
28
+ keydown_handler: _.throttle((function(e) {
29
+ return this.change_handler.apply(this, arguments);
30
+ }), 300),
31
+ blur_handler: function(e) {
32
+ var me, my;
33
+ return me = my = $(e.currentTarget);
34
+ },
35
+ focus_handler: function(e) {
36
+ var me, my;
37
+ return me = my = $(e.currentTarget);
38
+ },
39
+ change_handler: function(e) {
40
+ return this.trigger("on:change", this, e);
41
+ }
42
+ });
43
+
44
+ Luca.register("text_field", "Luca.fields.TextField");
45
+
46
+ }).call(this);
@@ -0,0 +1,13 @@
1
+ (function() {
2
+
3
+ Luca.fields.TypeAheadField = Luca.fields.TextField.extend({
4
+ form_field: true,
5
+ className: 'luca-ui-field',
6
+ afterInitialize: function() {
7
+ this.input_id || (this.input_id = _.uniqueId('field'));
8
+ this.input_name || (this.input_name = this.name);
9
+ return this.label || (this.label = this.name);
10
+ }
11
+ });
12
+
13
+ }).call(this);
@@ -0,0 +1,32 @@
1
+ (function() {
2
+
3
+ Luca.components.FormButtonToolbar = Luca.components.Toolbar.extend({
4
+ className: 'luca-ui-form-toolbar form-actions',
5
+ position: 'bottom',
6
+ includeReset: false,
7
+ render: function() {
8
+ return $(this.container).append(this.el);
9
+ },
10
+ initialize: function(options) {
11
+ this.options = options != null ? options : {};
12
+ Luca.components.Toolbar.prototype.initialize.apply(this, arguments);
13
+ this.components = [
14
+ {
15
+ ctype: 'button_field',
16
+ label: 'Submit',
17
+ "class": 'btn submit-button'
18
+ }
19
+ ];
20
+ if (this.includeReset) {
21
+ return this.components.push({
22
+ ctype: 'button_field',
23
+ label: 'Reset',
24
+ "class": 'btn reset-button'
25
+ });
26
+ }
27
+ }
28
+ });
29
+
30
+ Luca.register("form_button_toolbar", "Luca.components.FormButtonToolbar");
31
+
32
+ }).call(this);
@@ -0,0 +1,32 @@
1
+ .luca-ui-form-view-wrapper {
2
+ width: 100%;
3
+ float: left;
4
+ display: block;
5
+ clear: both;
6
+ margin: 10px 0px; }
7
+
8
+ .luca-ui-form-view .luca-ui-field {
9
+ margin: 5px;
10
+ padding: 5px; }
11
+ .luca-ui-form-view .luca-ui-field .helper-text {
12
+ font-size: 0.75em;
13
+ font-color: #ccc; }
14
+
15
+ .luca-ui-form-view.label-align-top .luca-ui-field label, .luca-ui-form-view.label-align-top .luca-ui-field input, .luca-ui-form-view.label-align-top .luca-ui-field select, .luca-ui-form-view.label-align-top .luca-ui-field textarea {
16
+ margin: 5px 0px;
17
+ display: block; }
18
+
19
+ .luca-ui-form-view.column-layout .luca-ui-field {
20
+ float: left; }
21
+
22
+ .form-view-footer .toolbar-container {
23
+ float: left;
24
+ width: 100%;
25
+ clear: both;
26
+ display: block; }
27
+ .form-view-footer .toolbar-container .luca-ui-form-toolbar, .form-view-footer .toolbar-container .luca-ui-toolbar {
28
+ width: 50%;
29
+ display: block;
30
+ margin: 0px auto; }
31
+ .form-view-footer .toolbar-container .luca-ui-form-toolbar .luca-ui-field, .form-view-footer .toolbar-container .luca-ui-toolbar .luca-ui-field {
32
+ float: left; }