luca 0.8.599 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/.rvmrc +1 -0
- data/CHANGELOG +51 -2
- data/README.md +10 -247
- data/ROADMAP +6 -2
- data/app.rb +16 -2
- data/assets/javascripts/dependencies/bootstrap.min.js +7 -1
- data/assets/javascripts/dependencies/codemirror-coffeescript.js +347 -0
- data/assets/javascripts/dependencies/codemirror-css.js +124 -0
- data/assets/javascripts/dependencies/codemirror-html.js +410 -0
- data/assets/javascripts/dependencies/codemirror-javascript.js +361 -0
- data/assets/javascripts/dependencies/codemirror-less.js +232 -0
- data/assets/javascripts/dependencies/codemirror-vim.js +500 -0
- data/assets/javascripts/dependencies/codemirror.js +3076 -0
- data/assets/javascripts/dependencies.coffee +0 -1
- data/assets/javascripts/luca-ui-base.coffee +10 -3
- data/assets/javascripts/luca-ui-bootstrap.js +1 -0
- data/assets/javascripts/luca-ui-development-tools.coffee +9 -0
- data/assets/javascripts/luca-ui.coffee +6 -1
- data/assets/javascripts/sandbox/application.coffee +51 -0
- data/assets/javascripts/sandbox/router.coffee +14 -0
- data/assets/javascripts/sandbox/templates/main.luca +33 -0
- data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +1 -0
- data/assets/javascripts/sandbox/templates/sandbox.luca +1 -0
- data/assets/javascripts/sandbox/views/top_navigation.coffee +4 -0
- data/assets/javascripts/sandbox.coffee +2 -2
- data/assets/stylesheets/bootstrap.min.css +395 -297
- data/assets/stylesheets/codemirror-blackboard.css +25 -0
- data/assets/stylesheets/codemirror-monokai.css +33 -0
- data/assets/stylesheets/codemirror.css +126 -0
- data/assets/stylesheets/luca-ui-bootstrap.css +0 -1
- data/assets/stylesheets/luca-ui-development-tools.css +5 -0
- data/assets/stylesheets/sandbox/sandbox.scss +1 -3
- data/assets/stylesheets/themes/amelia-bootstrap.css +826 -0
- data/assets/stylesheets/themes/slate-bootstrap.css +797 -0
- data/assets/stylesheets/themes/superhero-bootstrap.css +830 -0
- data/lib/luca/code_browser.rb +55 -0
- data/lib/luca/rails/version.rb +1 -1
- data/lib/luca/rails.rb +1 -0
- data/spec/components/fields/checkbox_array_spec.coffee +46 -0
- data/spec/components/form_view_spec.coffee +10 -4
- data/spec/containers/card_view_spec.coffee +7 -0
- data/spec/core/collection_spec.coffee +58 -4
- data/spec/core/container_spec.coffee +6 -6
- data/spec/core/view_spec.coffee +93 -7
- data/spec/framework_spec.coffee +15 -12
- data/src/components/application.coffee +126 -18
- data/src/components/base_toolbar.coffee +2 -2
- data/src/components/collection_loader_view.coffee +1 -2
- data/src/components/collection_view.coffee +77 -0
- data/src/components/controller.coffee +1 -4
- data/src/components/fields/button_field.coffee +1 -1
- data/src/components/fields/checkbox_array.coffee +2 -2
- data/src/components/fields/checkbox_field.coffee +3 -1
- data/src/components/fields/file_upload_field.coffee +1 -1
- data/src/components/fields/hidden_field.coffee +1 -1
- data/src/components/fields/select_field.coffee +1 -1
- data/src/components/fields/text_area_field.coffee +1 -1
- data/src/components/fields/text_field.coffee +10 -6
- data/src/components/fields/type_ahead_field.coffee +18 -5
- data/src/components/form_button_toolbar.coffee +1 -2
- data/src/components/form_view.coffee +44 -62
- data/src/components/grid_view.coffee +27 -20
- data/src/components/load_mask.coffee +3 -0
- data/src/components/nav_bar.coffee +26 -0
- data/src/components/record_manager.coffee +1 -3
- data/src/components/router.coffee +1 -1
- data/src/components/template.coffee +3 -15
- data/src/components/toolbar_dialog.coffee +25 -0
- data/src/containers/card_view.coffee +22 -23
- data/src/containers/column_view.coffee +1 -6
- data/src/containers/modal_view.coffee +20 -71
- data/src/containers/panel_toolbar.coffee +156 -0
- data/src/containers/panel_view.coffee +1 -1
- data/src/containers/split_view.coffee +1 -3
- data/src/containers/tab_view.coffee +29 -29
- data/src/containers/viewport.coffee +38 -3
- data/src/core/collection.coffee +80 -48
- data/src/core/container.coffee +153 -72
- data/src/core/core.coffee +181 -0
- data/src/core/field.coffee +4 -2
- data/src/core/model.coffee +1 -1
- data/src/core/observer.coffee +3 -3
- data/src/core/panel.coffee +143 -0
- data/src/core/registry.coffee +104 -0
- data/src/core/util.coffee +82 -0
- data/src/core/view.coffee +158 -85
- data/src/framework.coffee +112 -178
- data/src/index.coffee +0 -255
- data/src/managers/collection_manager.coffee +1 -0
- data/src/samples/definition.coffee +49 -0
- data/src/stylesheets/base.scss +0 -78
- data/src/stylesheets/components/form_view.scss +8 -3
- data/src/stylesheets/components/grid_view.scss +3 -7
- data/src/stylesheets/components/load_mask.scss +14 -0
- data/src/stylesheets/components/toolbar.scss +0 -15
- data/src/stylesheets/containers/container.scss +14 -2
- data/src/stylesheets/containers/panels.scss +23 -0
- data/src/stylesheets/tools/class_browser.scss +32 -0
- data/src/stylesheets/tools/code_editor.scss +24 -0
- data/src/stylesheets/tools/component_tester.scss +8 -0
- data/src/stylesheets/tools/console.scss +26 -0
- data/src/templates/components/collection_loader_view.luca +1 -1
- data/src/templates/components/form_view.luca +2 -13
- data/src/templates/components/grid_view.luca +0 -2
- data/src/templates/components/load_mask.luca +3 -0
- data/src/templates/components/nav_bar.luca +2 -0
- data/src/templates/containers/tab_view.luca +1 -0
- data/src/templates/fields/text_field.luca +4 -1
- data/src/tools/class_browser.coffee +39 -0
- data/src/tools/code_editor.coffee +258 -0
- data/src/tools/code_mirror_field.coffee +57 -0
- data/src/tools/coffee_script_editor.coffee +60 -0
- data/src/tools/collection_inspector.coffee +4 -0
- data/src/tools/component_tester.coffee +472 -0
- data/src/tools/components/class_browser_detail.coffee +10 -0
- data/src/tools/components/class_browser_list.coffee +74 -0
- data/src/tools/console.coffee +147 -0
- data/src/tools/development_console.coffee +147 -0
- data/src/tools/models/components.coffee +63 -0
- data/src/tools/templates/component_tester/help.luca +14 -0
- data/vendor/assets/javascripts/luca-ui-base.js +1389 -611
- data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
- data/vendor/assets/javascripts/luca-ui-development-tools.js +18719 -0
- data/vendor/assets/javascripts/luca-ui-spec.js +2065 -878
- data/vendor/assets/javascripts/luca-ui.js +1759 -852
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +494 -440
- data/vendor/assets/stylesheets/luca-ui-development-tools.css +224 -0
- data/vendor/assets/stylesheets/luca-ui-spec.css +99 -140
- data/vendor/assets/stylesheets/luca-ui.css +99 -140
- data/views/index.erb +6 -3
- metadata +60 -18
- data/assets/javascripts/dependencies/jquery-console.js +0 -649
- data/assets/javascripts/development-console.coffee +0 -2
- data/assets/javascripts/sandbox/sandbox.coffee +0 -16
- data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +0 -33
- data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +0 -48
- data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +0 -24
- data/assets/javascripts/sandbox/templates/features/introduction.luca +0 -11
- data/assets/javascripts/sandbox/templates/features/view_helpers.luca +0 -43
- data/assets/javascripts/sandbox/templates/navigation.luca +0 -8
- data/assets/javascripts/sandbox/views/form_demo.coffee +0 -47
- data/assets/javascripts/sandbox/views/grid_demo.coffee +0 -23
- data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +0 -1
- data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +0 -38
- data/src/components/collection_inspector.coffee +0 -2
- data/src/components/development_console.coffee +0 -59
- data/src/stylesheets/components/development_console.scss +0 -47
@@ -1,4 +1,4 @@
|
|
1
|
-
_.
|
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
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
_( @components ).each (component,index)=>
|
26
|
+
if index is @activeCard
|
27
|
+
$( component.container ).show()
|
28
|
+
else
|
29
|
+
$( component.container ).hide()
|
31
30
|
|
32
|
-
|
33
|
-
@
|
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
|
-
|
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
|
-
|
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
|
-
_.
|
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
|
-
_.
|
2
|
-
componentType: 'modal_view'
|
1
|
+
_.def("Luca.ModalView").extends("Luca.View").with
|
3
2
|
|
4
|
-
|
3
|
+
closeOnEscape: true
|
5
4
|
|
6
|
-
|
5
|
+
showOnInitialize: false
|
7
6
|
|
8
|
-
|
7
|
+
backdrop: false
|
9
8
|
|
10
|
-
|
9
|
+
container: ()->
|
10
|
+
$('body')
|
11
11
|
|
12
|
-
|
13
|
-
'
|
14
|
-
'before:hide'
|
15
|
-
]
|
12
|
+
toggle: ()->
|
13
|
+
@$el.modal('toggle')
|
16
14
|
|
17
|
-
|
18
|
-
|
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
|
-
|
54
|
-
modal
|
55
|
-
modal.data.show()
|
18
|
+
hide: ()->
|
19
|
+
@$el.modal('hide')
|
56
20
|
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
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,7 +1,4 @@
|
|
1
|
-
_.
|
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
|
-
|
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
|
37
|
+
Luca.containers.CardView::beforeLayout?.apply @, arguments
|
45
38
|
|
46
|
-
|
47
|
-
Luca.containers.CardView::
|
48
|
-
@
|
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
|
-
|
56
|
-
|
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.
|
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
|
-
|
75
|
+
@$('ul.nav-tabs', @tabContainerWrapper() )
|
76
76
|
|
77
77
|
tabSelectors: ()->
|
78
|
-
|
78
|
+
@$( 'li.tab-selector', @tabContainer() )
|
@@ -1,4 +1,4 @@
|
|
1
|
-
_.
|
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
|
-
|
14
|
-
|
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
|
|