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,4 +1,4 @@
1
- _.component("Luca.containers.CardView").extends("Luca.core.Container").with
1
+ _.def("Luca.containers.CardView").extends("Luca.core.Container").with
2
2
  componentType: 'card_view'
3
3
 
4
4
  className: 'luca-ui-card-view-wrapper'
@@ -12,32 +12,33 @@ _.component("Luca.containers.CardView").extends("Luca.core.Container").with
12
12
  'after:card:switch'
13
13
  ]
14
14
 
15
+ componentClass: 'luca-ui-card'
16
+ appendContainers: true
17
+
15
18
  initialize: (@options)->
16
19
  Luca.core.Container::initialize.apply @,arguments
17
20
  @setupHooks(@hooks)
18
21
 
19
- componentClass: 'luca-ui-card'
20
-
21
- beforeLayout: ()->
22
- @cards = _(@components).map (card,cardIndex) =>
23
- classes: @componentClass
24
- style: "display:#{ (if cardIndex is @activeCard then 'block' else 'none' )}"
25
- id: "#{ @cid }-#{ cardIndex }"
22
+ prepareComponents: ()->
23
+ Luca.core.Container::prepareComponents?.apply(@, arguments)
26
24
 
27
- prepareLayout: ()->
28
- @card_containers = _( @cards ).map (card, index)=>
29
- @$el.append Luca.templates["containers/basic"](card)
30
- $("##{ card.id }")
25
+ _( @components ).each (component,index)=>
26
+ if index is @activeCard
27
+ $( component.container ).show()
28
+ else
29
+ $( component.container ).hide()
31
30
 
32
- prepareComponents: ()->
33
- @components = _( @components ).map (object,index)=>
34
- card = @cards[index]
35
- object.container = "##{ card.id }"
36
- object
31
+ activeComponentElement: ()->
32
+ @componentElements().eq( @activeCard )
37
33
 
38
34
  activeComponent: ()->
39
35
  @getComponent( @activeCard )
40
36
 
37
+ customizeContainerEl: (containerEl, panel, panelIndex)->
38
+ containerEl.style += if panelIndex is @activeCard then "display:block;" else "display:none;"
39
+
40
+ containerEl
41
+
41
42
  cycle: ()->
42
43
  nextIndex = if @activeCard < @components.length - 1 then @activeCard + 1 else 0
43
44
  @activate( nextIndex )
@@ -62,24 +63,22 @@ _.component("Luca.containers.CardView").extends("Luca.core.Container").with
62
63
  index = @indexOf(index)
63
64
  current = @getComponent( index )
64
65
 
65
- return unless current
66
-
66
+ unless current
67
+ return
67
68
 
68
69
  unless silent
69
70
  @trigger "before:card:switch", previous, current
70
71
  previous?.trigger?.apply(previous,["before:deactivation", @, previous, current])
71
72
  current?.trigger?.apply(previous,["before:activation", @, previous, current])
72
73
 
73
- _( @card_containers ).each (container)->
74
- container.hide()
74
+ @componentElements().hide()
75
75
 
76
76
  unless current.previously_activated
77
77
  current.trigger "first:activation"
78
78
  current.previously_activated = true
79
79
 
80
- $( current.container ).show()
81
-
82
80
  @activeCard = index
81
+ @activeComponentElement().show()
83
82
 
84
83
  unless silent
85
84
  @trigger "after:card:switch", previous, current
@@ -1,4 +1,4 @@
1
- _.component('Luca.containers.ColumnView').extends('Luca.core.Container').with
1
+ _.def('Luca.containers.ColumnView').extends('Luca.core.Container').with
2
2
  componentType: 'column_view'
3
3
 
4
4
  className: 'luca-ui-column-view'
@@ -31,11 +31,6 @@ _.component('Luca.containers.ColumnView').extends('Luca.core.Container').with
31
31
 
32
32
  @columnWidths = _( @columnWidths ).map (val)-> "#{ val }%"
33
33
 
34
- beforeComponents: ()->
35
- @debug "column_view before components"
36
- _( @components ).each (component)->
37
- component.ctype ||= "panel_view"
38
-
39
34
  beforeLayout: ()->
40
35
  @debug "column_view before layout"
41
36
 
@@ -1,83 +1,32 @@
1
- _.component('Luca.containers.ModalView').extends('Luca.core.Container').with
2
- componentType: 'modal_view'
1
+ _.def("Luca.ModalView").extends("Luca.View").with
3
2
 
4
- className: 'luca-ui-modal-view'
3
+ closeOnEscape: true
5
4
 
6
- components:[]
5
+ showOnInitialize: false
7
6
 
8
- renderOnInitialize: true
7
+ backdrop: false
9
8
 
10
- showOnRender: false
9
+ container: ()->
10
+ $('body')
11
11
 
12
- hooks:[
13
- 'before:show',
14
- 'before:hide'
15
- ]
12
+ toggle: ()->
13
+ @$el.modal('toggle')
16
14
 
17
- defaultModalOptions:
18
- minWidth: 375
19
- maxWidth: 375
20
- minHeight: 550
21
- maxHeight: 550
22
- opacity: 80
23
- onOpen: (modal)->
24
- @onOpen.apply @
25
- @onModalOpen.apply modal, [modal, @]
26
- onClose: (modal)->
27
- @onClose.apply @
28
- @onModalClose.apply modal, [modal, @]
29
-
30
- modalOptions: {}
31
-
32
- initialize: (@options={})->
33
- Luca.core.Container::initialize.apply @,arguments
34
- @setupHooks(@hooks)
35
-
36
- _( @defaultModalOptions ).each (value,setting) => @modalOptions[ setting ] ||= value
37
-
38
- @modalOptions.onOpen = _.bind( @modalOptions.onOpen, @)
39
- @modalOptions.onClose = _.bind( @modalOptions.onClose, @)
40
-
41
- # this will get called within the context of the modal view
42
- onOpen: ()-> true
43
-
44
- # this will get called within the context of the modal view
45
- onClose: ()-> true
46
-
47
- getModal: ()-> @modal
48
-
49
- # this will be called within the context of the simple modal object
50
- onModalOpen: (modal, view)->
51
- view.modal = modal
15
+ show: ()->
16
+ @$el.modal('show')
52
17
 
53
- modal.overlay.show()
54
- modal.container.show()
55
- modal.data.show()
18
+ hide: ()->
19
+ @$el.modal('hide')
56
20
 
57
- # this will be called within the context of the simple modal object
58
- onModalClose: (modal, view)->
59
- $.modal.close()
21
+ render: ()->
22
+ @$el.addClass 'modal'
23
+ @$el.addClass 'fade' if @fade is true
60
24
 
61
- prepareLayout: ()->
62
25
  $('body').append( @$el )
63
26
 
64
- prepareComponents: ()->
65
- @components = _(@components).map (object,index) =>
66
- object.container = @el
67
- object
68
-
69
- afterInitialize: ()->
70
- @$el.hide()
71
- @render() if @renderOnInitialize
72
-
73
- afterRender: ()->
74
- @show() if @showOnRender
27
+ @$el.modal
28
+ backdrop: @backdrop is true
29
+ keyboard: @closeOnEscape is true
30
+ show: @showOnInitialize is true
75
31
 
76
- wrapper: ()-> $( @$el.parent() )
77
-
78
- show: ()->
79
- @trigger "before:show", @
80
- @$el.modal( @modalOptions )
81
-
82
- hide: ()->
83
- @trigger "before:hide", @
32
+ _.def("Luca.containers.ModalView").extends("Luca.ModalView").with()
@@ -0,0 +1,156 @@
1
+
2
+ # button config accepts the following paramters:
3
+ #
4
+ # label what should the button say
5
+ # eventId what event should the button trigger
6
+ # dropdown an array of arrays: [eventId, label]
7
+ # group an array of button configs
8
+ # wrapper a css class, in addition to btn-group
9
+ # icon which icon do you want to use on this button?
10
+ # white true or false: is it a white colored text?
11
+ # color options are primary, info, success, warning, danger, inverse
12
+
13
+ make = Backbone.View::make
14
+
15
+ buildButton = (config, wrap=true)->
16
+ if config.ctype?
17
+ config.className ||= ""
18
+ config.className += 'toolbar-component'
19
+
20
+ object = Luca(config).render()
21
+ if Luca.isBackboneView(object)
22
+ console.log "Adding toolbar component", object
23
+ return object.el
24
+
25
+ if config.spacer
26
+ return make "div", class: "spacer #{ config.spacer }"
27
+
28
+ if config.text
29
+ return make "div", {class: "toolbar-text"}, config.text
30
+
31
+ wrapper = 'btn-group'
32
+ wrapper += " #{ config.wrapper }" if config.wrapper?
33
+ wrapper += " align-#{ config.align }" if config.align?
34
+
35
+ # if we're passed a group, then we need to just
36
+ # wrap the contents of the buttons property in that group
37
+ # skipping the btn-group wrapping that takes place for
38
+ # individual buttons
39
+ if config.group? and config.buttons?
40
+ buttons = prepareButtons( config.buttons, false )
41
+ return make "div", class: wrapper, buttons
42
+
43
+ # if it is a normal button, and not a button group
44
+ else
45
+ label = config.label ||= ""
46
+
47
+ config.eventId ||= _.string.dasherize( config.label.toLowerCase() )
48
+
49
+ if config.icon
50
+ label = " " if _.string.isBlank( label )
51
+ white = "icon-white" if config.white
52
+ label = "<i class='#{ white || "" } icon-#{ config.icon }' /> #{ label }"
53
+
54
+ buttonAttributes =
55
+ class: _.compact(["btn",config.classes,config.className]).join(" ")
56
+ "data-eventId" : config.eventId
57
+ title: config.title || config.description
58
+
59
+ buttonAttributes["class"] += " btn-#{ config.color }" if config.color?
60
+
61
+ if config.dropdown
62
+ label = "#{ label } <span class='caret'></span>"
63
+ buttonAttributes["class"] += " dropdown-toggle"
64
+ buttonAttributes["data-toggle"] = "dropdown"
65
+
66
+ dropdownItems = _(config.dropdown).map (dropdownItem)=>
67
+ link = make "a", {}, dropdownItem[1]
68
+ make "li", {"data-eventId": dropdownItem[0]}, link
69
+
70
+ dropdownEl = make "ul", {class:"dropdown-menu"}, dropdownItems
71
+
72
+ buttonEl = make "a", buttonAttributes, label
73
+
74
+ # needs to be wrapped for proper rendering, but not
75
+ # if it already is part of a group
76
+ autoWrapClass = "btn-group"
77
+ autoWrapClass += " align-#{ config.align }" if config.align?
78
+
79
+ if wrap is true
80
+ return make "div", {class: autoWrapClass}, [buttonEl,dropdownEl]
81
+ else
82
+ # for buttons which are already part f a group
83
+ buttonEl
84
+
85
+ prepareButtons = (buttons, wrap=true)->
86
+ _( buttons ).map (button)->
87
+ buildButton(button, wrap)
88
+
89
+
90
+ #### Panel Toolbar Component
91
+ #
92
+ # The Panel Toolbar is a collection of buttons and / or dropdowns
93
+ # which are automatically created by BasicPanel classes, or can be
94
+ # added to any other view component.
95
+ _.def("Luca.containers.PanelToolbar").extends("Luca.View").with
96
+
97
+ className: "luca-ui-toolbar btn-toolbar"
98
+
99
+ # @buttons is an array of button config objects
100
+
101
+
102
+ buttons:[]
103
+
104
+ well: true
105
+
106
+ orientation: 'top'
107
+
108
+ autoBindEventHandlers: true
109
+
110
+ events:
111
+ "click a.btn, click .dropdown-menu li" : "clickHandler"
112
+
113
+ #autoBindEventHandlers: true
114
+
115
+ # The Toolbar behaves by triggering events on the components which they
116
+ # belong to. Combined with Luca.View::setupHooks it is a clean way
117
+ # to organize actions
118
+ clickHandler: (e)->
119
+ me = my = $( e.target )
120
+
121
+ if me.is('i')
122
+ me = my = $( e.target ).parent()
123
+
124
+ eventId = my.data('eventid')
125
+
126
+ return unless eventId?
127
+
128
+ hook = Luca.util.hook( eventId )
129
+
130
+ source = @parent || @
131
+ if _.isFunction( source[hook] )
132
+ source[ hook ].call(@, me, e)
133
+ else
134
+ source.trigger(eventId, me, e)
135
+
136
+ beforeRender:()->
137
+ @_super("beforeRender", @, arguments)
138
+
139
+ if @well is true
140
+ @$el.addClass 'well'
141
+
142
+ @$el.addClass "toolbar-#{ @orientation }"
143
+
144
+ @applyStyles( @styles ) if @styles?
145
+
146
+ render: ()->
147
+ @$el.empty()
148
+
149
+ elements = prepareButtons(@buttons)
150
+ _( elements ).each (element)=>
151
+ @$el.append( element )
152
+
153
+ afterRender: ()->
154
+ @_super("afterRender", @, arguments)
155
+ # @$('.toolbar-component label').remove()
156
+ # @$('.toolbar-component').addClass('btn-group')
@@ -1,4 +1,4 @@
1
- _.component('Luca.containers.PanelView').extends('Luca.core.Container').with
1
+ _.def('Luca.containers.PanelView').extends('Luca.core.Container').with
2
2
  className: 'luca-ui-panel'
3
3
 
4
4
  initialize: (@options={})->
@@ -1,6 +1,4 @@
1
- _.component('Luca.containers.SplitView').extends('Luca.core.Container').with
2
- layout: '100'
3
-
1
+ _.def('Luca.containers.SplitView').extends('Luca.core.Container').with
4
2
  componentType: 'split_view'
5
3
 
6
4
  containerTemplate: 'containers/basic'
@@ -1,7 +1,4 @@
1
- _.component('Luca.containers.TabView').extends('Luca.containers.CardView').with
2
-
3
- events:
4
- "click ul.nav-tabs li" : "select"
1
+ _.def('Luca.containers.TabView').extends('Luca.containers.CardView').with
5
2
 
6
3
  hooks:[
7
4
  "before:select"
@@ -16,9 +13,14 @@ _.component('Luca.containers.TabView').extends('Luca.containers.CardView').with
16
13
 
17
14
  tabVerticalOffset: '50px'
18
15
 
16
+ bodyTemplate: "containers/tab_view"
17
+ bodyEl: "div.tab-content"
18
+
19
19
  initialize: (@options={})->
20
20
  Luca.containers.CardView::initialize.apply @, arguments
21
+
21
22
  _.bindAll @, "select", "highlightSelectedTab"
23
+
22
24
  @setupHooks( @hooks )
23
25
 
24
26
  @bind "after:card:switch", @highlightSelectedTab
@@ -26,45 +28,43 @@ _.component('Luca.containers.TabView').extends('Luca.containers.CardView').with
26
28
  activeTabSelector: ()->
27
29
  @tabSelectors().eq( @activeCard || @activeTab || @activeItem )
28
30
 
29
- prepareLayout: ()->
30
- @card_containers = _( @cards ).map (card, index)=>
31
- @$('.tab-content').append Luca.templates["containers/basic"](card)
32
- $("##{ card.id }")
33
-
34
31
  beforeLayout: ()->
35
32
  @$el.addClass("tabs-#{ @tab_position }")
33
+ @activeTabSelector().addClass 'active'
36
34
 
37
- if @tab_position is "below"
38
- @$el.append Luca.templates["containers/tab_view"](@)
39
- @$el.append Luca.templates["containers/tab_selector_container"](@)
40
- else
41
- @$el.append Luca.templates["containers/tab_selector_container"](@)
42
- @$el.append Luca.templates["containers/tab_view"](@)
35
+ @createTabSelectors()
43
36
 
44
- Luca.containers.CardView::beforeLayout.apply @, arguments
37
+ Luca.containers.CardView::beforeLayout?.apply @, arguments
45
38
 
46
- beforeRender: ()->
47
- Luca.containers.CardView::beforeRender?.apply @, arguments
48
- @activeTabSelector().addClass('active')
39
+ afterRender: ()->
40
+ Luca.containers.CardView::afterRender?.apply @, arguments
41
+ @registerEvent("click ##{ @cid }-tabs-selector li a", "select")
42
+
43
+ if Luca.enableBootstrap and (@tab_position is "left" or @tab_position is "right")
44
+ @tabContainerWrapper().addClass("span2")
45
+ @tabContentWrapper().addClass("span9")
49
46
 
50
- if Luca.enableBootstrap and @tab_position is "left" or @tab_position is "right"
51
- @$el.addClass('grid-12')
52
- @tabContainerWrapper().addClass('grid-3')
53
- @tabContentWrapper().addClass('grid-9')
54
47
 
55
- if @tabVerticalOffset
56
- @tabContainerWrapper().css('padding-top', @tabVerticalOffset )
48
+ createTabSelectors: ()->
49
+ tabView = @
50
+ @each (component,index)->
51
+ selector = tabView.make("li",{class:"tab-selector","data-target":index}, "<a>#{ component.title }</a>")
52
+ tabView.tabContainer().append(selector)
57
53
 
58
54
  highlightSelectedTab: ()->
59
55
  @tabSelectors().removeClass('active')
60
56
  @activeTabSelector().addClass('active')
61
57
 
62
58
  select: (e)->
63
- me = my = $( e.currentTarget )
59
+ me = my = $( e.target )
60
+
64
61
  @trigger "before:select", @
65
- @activate my.data('target')
62
+ @activate my.parent().data('target')
66
63
  @trigger "after:select", @
67
64
 
65
+ componentElements: ()->
66
+ @$(">.tab-content >.#{ @componentClass }")
67
+
68
68
  tabContentWrapper: ()->
69
69
  $("##{ @cid }-tab-view-content")
70
70
 
@@ -72,7 +72,7 @@ _.component('Luca.containers.TabView').extends('Luca.containers.CardView').with
72
72
  $("##{ @cid }-tabs-selector")
73
73
 
74
74
  tabContainer: ()->
75
- $("ul##{ @cid }-tabs-nav")
75
+ @$('ul.nav-tabs', @tabContainerWrapper() )
76
76
 
77
77
  tabSelectors: ()->
78
- $( 'li.tab-selector', @tabContainer() )
78
+ @$( 'li.tab-selector', @tabContainer() )
@@ -1,4 +1,4 @@
1
- _.component('Luca.containers.Viewport').extend('Luca.containers.CardView').with
1
+ _.def('Luca.containers.Viewport').extend('Luca.containers.CardView').with
2
2
 
3
3
  activeItem: 0
4
4
 
@@ -6,10 +6,45 @@ _.component('Luca.containers.Viewport').extend('Luca.containers.CardView').with
6
6
 
7
7
  fullscreen: true
8
8
 
9
+ fluid: false
10
+
11
+ wrapperClass: 'row'
12
+
9
13
  initialize: (@options={})->
10
14
  Luca.core.Container::initialize.apply(@, arguments)
15
+
16
+ if Luca.enableBootstrap is true
17
+ @wrapperClass = "row-fluid" if @fluid is true
18
+ @$el.wrap("<div class='#{ @wrapperClass }' />").addClass('span12')
19
+
11
20
  $('html,body').addClass('luca-ui-fullscreen') if @fullscreen
12
21
 
13
- render: ()->
14
- @$el.addClass('luca-ui-viewport')
22
+ beforeRender: ()->
23
+ Luca.containers.CardView::beforeRender?.apply(@, arguments)
24
+
25
+ if Luca.enableBootstrap and @topNav and @fullscreen
26
+ $('body').css('padding','40px')
27
+
28
+ @renderTopNavigation() if @topNav?
29
+ @renderBottomNavigation() if @bottomNav?
30
+
31
+ renderTopNavigation: ()->
32
+ return unless @topNav?
33
+
34
+ if _.isString( @topNav )
35
+ @topNav = Luca.util.lazyComponent(@topNav)
36
+
37
+ if _.isObject( @topNav )
38
+ @topNav.ctype ||= @topNav.type || "nav_bar"
39
+ unless Luca.isBackboneView(@topNav)
40
+ @topNav = Luca.util.lazyComponent( @topNav )
41
+
42
+ @topNav.app = @
43
+
44
+ $('body').prepend( @topNav.render().el )
45
+
46
+
47
+ renderBottomNavigation: ()->
48
+
49
+
15
50