chr 0.2.8 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gruntfile.coffee +33 -27
- data/README.md +6 -1
- data/app/assets/javascripts/chr.coffee +18 -16
- data/app/assets/javascripts/chr/core/chr.coffee +41 -76
- data/app/assets/javascripts/chr/core/chr_router.coffee +141 -0
- data/app/assets/javascripts/chr/core/item.coffee +36 -49
- data/app/assets/javascripts/chr/core/list.coffee +26 -71
- data/app/assets/javascripts/chr/core/list_config.coffee +28 -13
- data/app/assets/javascripts/chr/core/list_pagination.coffee +56 -13
- data/app/assets/javascripts/chr/core/list_reorder.coffee +2 -2
- data/app/assets/javascripts/chr/core/list_search.coffee +2 -2
- data/app/assets/javascripts/chr/core/module.coffee +24 -93
- data/app/assets/javascripts/chr/core/utils.coffee +4 -0
- data/app/assets/javascripts/chr/core/view.coffee +123 -43
- data/app/assets/javascripts/chr/core/view_local-storage.coffee +58 -0
- data/app/assets/javascripts/chr/store/{_array-store.coffee → array-store.coffee} +3 -1
- data/app/assets/javascripts/chr/store/{_object-store.coffee → object-store.coffee} +0 -0
- data/app/assets/javascripts/chr/store/rails-array-store.coffee +39 -0
- data/app/assets/javascripts/chr/store/{mongosteen-object-store.coffee → rails-form-object-parser.coffee} +11 -20
- data/app/assets/javascripts/chr/store/rails-object-store.coffee +35 -0
- data/app/assets/javascripts/chr/store/rest-array-store.coffee +3 -5
- data/app/assets/javascripts/chr/store/rest-object-store.coffee +1 -1
- data/app/assets/javascripts/form/expandable-group.coffee +30 -0
- data/app/assets/javascripts/{chr/form → form}/form.coffee +3 -1
- data/app/assets/javascripts/{chr/form → form}/input-checkbox.coffee +1 -1
- data/app/assets/javascripts/{chr/form → form}/input-color.coffee +2 -0
- data/app/assets/javascripts/{chr/form → form}/input-date.coffee +0 -0
- data/app/assets/javascripts/{chr/form → form}/input-file.coffee +28 -1
- data/app/assets/javascripts/{chr/form → form}/input-form.coffee +14 -5
- data/app/assets/javascripts/{chr/form → form}/input-form_reorder.coffee +0 -0
- data/app/assets/javascripts/{chr/form → form}/input-hidden.coffee +9 -9
- data/app/assets/javascripts/{chr/form → form}/input-list.coffee +61 -53
- data/app/assets/javascripts/{chr/form → form}/input-list_reorder.coffee +2 -0
- data/app/assets/javascripts/form/input-list_typeahead.coffee +55 -0
- data/app/assets/javascripts/{chr/form → form}/input-password.coffee +1 -0
- data/app/assets/javascripts/{chr/form → form}/input-select.coffee +10 -11
- data/app/assets/javascripts/form/input-select2.coffee +33 -0
- data/app/assets/javascripts/{chr/form → form}/input-string.coffee +45 -2
- data/app/assets/javascripts/{chr/form → form}/input-text.coffee +6 -3
- data/app/assets/javascripts/input-html.coffee +8 -5
- data/app/assets/javascripts/input-markdown.coffee +10 -5
- data/app/assets/javascripts/input-redactor.coffee +1 -61
- data/app/assets/javascripts/redactor/input-redactor.coffee +53 -0
- data/app/assets/javascripts/redactor/input-redactor_character.coffee +83 -0
- data/app/assets/javascripts/redactor/input-redactor_images.coffee +166 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/ace.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/jquery.scrollparent.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/jquery.textarea_autosize.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/jquery.typeahead.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/marked.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/mode-html.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/mode-markdown.js +0 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/redactor.fixedtoolbar.js +1 -1
- data/app/assets/javascripts/vendor/select2.js +5274 -0
- data/app/assets/javascripts/{chr/vendor → vendor}/slip.js +0 -0
- data/app/assets/stylesheets/_chr.scss +11 -13
- data/app/assets/stylesheets/_input-redactor.scss +17 -16
- data/app/assets/stylesheets/{core → chr}/_icons.scss +1 -1
- data/app/assets/stylesheets/chr/_main.scss +110 -0
- data/app/assets/stylesheets/{core → chr}/_mixins.scss +58 -34
- data/app/assets/stylesheets/{core → chr}/_settings.scss +7 -1
- data/app/assets/stylesheets/form/_expandable-group.scss +16 -0
- data/app/assets/stylesheets/form/_input-select2.scss +94 -0
- data/app/assets/stylesheets/form/_main.scss +180 -0
- data/app/assets/stylesheets/vendor/select2.css +258 -0
- data/bower.json +2 -2
- data/dist/chr.js +2292 -2030
- data/dist/input-ace.js +18 -8
- data/dist/input-redactor.js +0 -156
- data/docs/bootstrap.md +1 -1
- data/docs/rails.md +10 -10
- data/lib/chr.rb +1 -8
- data/lib/chr/version.rb +1 -1
- data/lib/mongoid/character.rb +30 -0
- data/package.json +1 -1
- metadata +49 -43
- data/app/assets/javascripts/chr/store/mongosteen-array-store.coffee +0 -55
- data/app/assets/stylesheets/core/_list.scss +0 -39
- data/app/assets/stylesheets/core/_main.scss +0 -49
- data/app/assets/stylesheets/core/_responsive.scss +0 -62
- data/app/assets/stylesheets/form/_form.scss +0 -41
- data/app/assets/stylesheets/form/_input-checkbox.scss +0 -18
- data/app/assets/stylesheets/form/_input-color.scss +0 -10
- data/app/assets/stylesheets/form/_input-file.scss +0 -29
- data/app/assets/stylesheets/form/_input-form.scss +0 -26
- data/app/assets/stylesheets/form/_input-list.scss +0 -36
- data/app/assets/stylesheets/form/_input-string.scss +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f826f08992b4b9540353bcbbba91f9065e0de72
|
4
|
+
data.tar.gz: a63be1339e56a9672be6dd74e1e4a8c527827bde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3213804478267d46391d85bacfa7adb5070a67667b0c1310004480f44a9793903f9634f0b61c8ac7e603fc400b32359d7aa4ee269ac72a1ccd026501b7b3344
|
7
|
+
data.tar.gz: 5308776a2b5f5b5b76385a14ca232786b8555cff71419ee3f7d267b35089bc857591f04647c061aee2e4d362f82bac665ece115f4726bb9fd90dcfefa180448c
|
data/Gruntfile.coffee
CHANGED
@@ -10,6 +10,7 @@ module.exports = (grunt) ->
|
|
10
10
|
'build/chr.js': [
|
11
11
|
# core
|
12
12
|
'app/assets/javascripts/chr/core/utils.coffee'
|
13
|
+
'app/assets/javascripts/chr/core/chr_router.coffee'
|
13
14
|
'app/assets/javascripts/chr/core/chr.coffee'
|
14
15
|
'app/assets/javascripts/chr/core/module.coffee'
|
15
16
|
'app/assets/javascripts/chr/core/list_config.coffee'
|
@@ -18,29 +19,34 @@ module.exports = (grunt) ->
|
|
18
19
|
'app/assets/javascripts/chr/core/list_search.coffee'
|
19
20
|
'app/assets/javascripts/chr/core/list.coffee'
|
20
21
|
'app/assets/javascripts/chr/core/item.coffee'
|
22
|
+
'app/assets/javascripts/chr/core/view_local-storage.coffee'
|
21
23
|
'app/assets/javascripts/chr/core/view.coffee'
|
22
|
-
# form
|
23
|
-
'app/assets/javascripts/chr/form/form.coffee'
|
24
|
-
'app/assets/javascripts/chr/form/input-form_reorder.coffee'
|
25
|
-
'app/assets/javascripts/chr/form/input-form.coffee'
|
26
|
-
'app/assets/javascripts/chr/form/input-string.coffee'
|
27
|
-
'app/assets/javascripts/chr/form/input-hidden.coffee'
|
28
|
-
'app/assets/javascripts/chr/form/input-checkbox.coffee'
|
29
|
-
'app/assets/javascripts/chr/form/input-color.coffee'
|
30
|
-
'app/assets/javascripts/chr/form/input-date.coffee'
|
31
|
-
'app/assets/javascripts/chr/form/input-file.coffee'
|
32
|
-
'app/assets/javascripts/chr/form/input-list_reorder.coffee'
|
33
|
-
'app/assets/javascripts/chr/form/input-list.coffee'
|
34
|
-
'app/assets/javascripts/chr/form/input-password.coffee'
|
35
|
-
'app/assets/javascripts/chr/form/input-select.coffee'
|
36
|
-
'app/assets/javascripts/chr/form/input-text.coffee'
|
37
24
|
# stores
|
38
|
-
'app/assets/javascripts/chr/store/
|
39
|
-
'app/assets/javascripts/chr/store/
|
25
|
+
'app/assets/javascripts/chr/store/array-store.coffee'
|
26
|
+
'app/assets/javascripts/chr/store/object-store.coffee'
|
40
27
|
'app/assets/javascripts/chr/store/rest-array-store.coffee'
|
41
28
|
'app/assets/javascripts/chr/store/rest-object-store.coffee'
|
42
|
-
'app/assets/javascripts/chr/store/
|
43
|
-
'app/assets/javascripts/chr/store/
|
29
|
+
'app/assets/javascripts/chr/store/rails-form-object-parser.coffee'
|
30
|
+
'app/assets/javascripts/chr/store/rails-array-store.coffee'
|
31
|
+
'app/assets/javascripts/chr/store/rails-object-store.coffee'
|
32
|
+
# form
|
33
|
+
'app/assets/javascripts/form/form.coffee'
|
34
|
+
'app/assets/javascripts/form/input-form_reorder.coffee'
|
35
|
+
'app/assets/javascripts/form/input-form.coffee'
|
36
|
+
'app/assets/javascripts/form/input-string.coffee'
|
37
|
+
'app/assets/javascripts/form/input-hidden.coffee'
|
38
|
+
'app/assets/javascripts/form/input-checkbox.coffee'
|
39
|
+
'app/assets/javascripts/form/input-color.coffee'
|
40
|
+
'app/assets/javascripts/form/input-date.coffee'
|
41
|
+
'app/assets/javascripts/form/input-file.coffee'
|
42
|
+
'app/assets/javascripts/form/input-list_typeahead.coffee'
|
43
|
+
'app/assets/javascripts/form/input-list_reorder.coffee'
|
44
|
+
'app/assets/javascripts/form/input-list.coffee'
|
45
|
+
'app/assets/javascripts/form/input-password.coffee'
|
46
|
+
'app/assets/javascripts/form/input-select.coffee'
|
47
|
+
'app/assets/javascripts/form/input-text.coffee'
|
48
|
+
'app/assets/javascripts/form/input-select2.coffee'
|
49
|
+
'app/assets/javascripts/form/extendable-group.coffee'
|
44
50
|
]
|
45
51
|
|
46
52
|
'build/input-ace.js': [
|
@@ -55,20 +61,20 @@ module.exports = (grunt) ->
|
|
55
61
|
concat:
|
56
62
|
chr:
|
57
63
|
src: [
|
58
|
-
'app/assets/javascripts/
|
59
|
-
'app/assets/javascripts/
|
60
|
-
'app/assets/javascripts/
|
61
|
-
'app/assets/javascripts/
|
64
|
+
'app/assets/javascripts/vendor/slip.js'
|
65
|
+
'app/assets/javascripts/vendor/jquery.scrollparent.js'
|
66
|
+
'app/assets/javascripts/vendor/jquery.textarea_autosize.js'
|
67
|
+
'app/assets/javascripts/vendor/jquery.typeahead.js'
|
62
68
|
'build/chr.js'
|
63
69
|
]
|
64
70
|
dest: 'dist/chr.js'
|
65
71
|
|
66
72
|
ace:
|
67
73
|
src: [
|
68
|
-
'app/assets/javascripts/
|
69
|
-
'app/assets/javascripts/
|
70
|
-
'app/assets/javascripts/
|
71
|
-
'app/assets/javascripts/
|
74
|
+
'app/assets/javascripts/vendor/ace.js'
|
75
|
+
'app/assets/javascripts/vendor/mode-html.js'
|
76
|
+
'app/assets/javascripts/vendor/mode-markdown.js'
|
77
|
+
'app/assets/javascripts/vendor/marked.js'
|
72
78
|
'build/input-ace.js'
|
73
79
|
]
|
74
80
|
dest: 'dist/input-ace.js'
|
data/README.md
CHANGED
@@ -39,12 +39,17 @@ Styles setup:
|
|
39
39
|
|
40
40
|
## Documentation
|
41
41
|
|
42
|
-
* [
|
42
|
+
* [Rails Setup](docs/rails.md)
|
43
43
|
* [Bootstrap Data](docs/bootstrap.md)
|
44
44
|
|
45
45
|
More documentation and samples comming soon...
|
46
46
|
|
47
47
|
|
48
|
+
## Notes
|
49
|
+
|
50
|
+
1. Consider replace ```slip.js``` with [sortable.js](https://github.com/RubaXa/Sortable)
|
51
|
+
|
52
|
+
|
48
53
|
## Character family:
|
49
54
|
|
50
55
|
- [Character](https://github.com/slate-studio/chr): Powerful responsive javascript CMS for apps
|
@@ -6,21 +6,23 @@
|
|
6
6
|
#= require ./chr/core/item
|
7
7
|
#= require ./chr/core/view
|
8
8
|
|
9
|
-
#= require ./chr/
|
10
|
-
#= require ./chr/
|
11
|
-
#= require ./chr/form/input-hidden
|
12
|
-
#= require ./chr/form/input-string
|
13
|
-
#= require ./chr/form/input-text
|
14
|
-
#= require ./chr/form/input-checkbox
|
15
|
-
#= require ./chr/form/input-password
|
16
|
-
#= require ./chr/form/input-color
|
17
|
-
#= require ./chr/form/input-file
|
18
|
-
#= require ./chr/form/input-list
|
19
|
-
#= require ./chr/form/input-select
|
20
|
-
|
21
|
-
#= require ./chr/store/_object-store
|
22
|
-
#= require ./chr/store/_array-store
|
9
|
+
#= require ./chr/store/object-store
|
10
|
+
#= require ./chr/store/array-store
|
23
11
|
#= require ./chr/store/rest-object-store
|
24
12
|
#= require ./chr/store/rest-array-store
|
25
|
-
#= require ./chr/store/
|
26
|
-
#= require ./chr/store/
|
13
|
+
#= require ./chr/store/rails-object-store
|
14
|
+
#= require ./chr/store/rails-array-store
|
15
|
+
|
16
|
+
#= require ./form/form
|
17
|
+
#= require ./form/input-form
|
18
|
+
#= require ./form/input-hidden
|
19
|
+
#= require ./form/input-string
|
20
|
+
#= require ./form/input-text
|
21
|
+
#= require ./form/input-checkbox
|
22
|
+
#= require ./form/input-password
|
23
|
+
#= require ./form/input-color
|
24
|
+
#= require ./form/input-file
|
25
|
+
#= require ./form/input-list
|
26
|
+
#= require ./form/input-select
|
27
|
+
#= require ./form/input-select2
|
28
|
+
#= require ./form/expandable-group
|
@@ -9,19 +9,21 @@
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
# CHARACTER
|
11
11
|
# -----------------------------------------------------------------------------
|
12
|
+
#
|
12
13
|
# Public attributes:
|
13
14
|
# modules
|
14
15
|
# formInputs
|
15
16
|
# itemsPerPageRequest
|
16
17
|
#
|
17
18
|
# Public methods:
|
18
|
-
# start(@config)
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
19
|
+
# start(@config) - start the character app with configuration
|
20
|
+
# updateHash(hash, skipRoute) - change window location hash
|
21
|
+
# isMobile() - check if running on mobile
|
22
|
+
# showAlert(message) - show alert notification
|
23
|
+
# showError(message) - show error message
|
24
|
+
#
|
25
|
+
# Dependencies:
|
26
|
+
#= require ./chr_router
|
25
27
|
#
|
26
28
|
# -----------------------------------------------------------------------------
|
27
29
|
class @Chr
|
@@ -34,8 +36,9 @@ class @Chr
|
|
34
36
|
|
35
37
|
# PRIVATE ===============================================
|
36
38
|
|
37
|
-
|
39
|
+
_unset_active_items: ->
|
38
40
|
$('.sidebar .menu a.active').removeClass('active')
|
41
|
+
$('.list .items .item.active').removeClass('active')
|
39
42
|
|
40
43
|
|
41
44
|
_set_active_menu_item: ->
|
@@ -46,54 +49,41 @@ class @Chr
|
|
46
49
|
return $(a).addClass('active')
|
47
50
|
|
48
51
|
|
49
|
-
|
50
|
-
|
52
|
+
_add_menu_item: (moduleName, title) ->
|
53
|
+
@$mainMenu.append "<a href='#/#{ moduleName }' class='menu-#{ moduleName }'>#{ title }</a>"
|
51
54
|
|
52
|
-
# if module changed, hide previous module
|
53
|
-
if @module != @modules[crumbs[1]]
|
54
|
-
@module?.hide()
|
55
55
|
|
56
|
-
|
56
|
+
_bind_hashchange: ->
|
57
|
+
@skipRoute = false
|
57
58
|
|
58
|
-
|
59
|
-
@
|
59
|
+
window.onhashchange = =>
|
60
|
+
@_unset_active_items()
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
if ! @skipRoute then @_route()
|
63
|
+
@skipRoute = false
|
63
64
|
|
64
|
-
|
65
|
-
for crumb in crumbs
|
66
|
-
if crumb == 'new'
|
67
|
-
return @module.showView(null, config, 'New')
|
65
|
+
$(this).trigger 'hashchange'
|
68
66
|
|
69
|
-
|
70
|
-
objectId = _last(crumbs)
|
71
|
-
return @module.showViewByObjectId(objectId, config)
|
67
|
+
$(this).on 'hashchange', => @_set_active_menu_item()
|
72
68
|
|
73
|
-
config = config.items[crumb]
|
74
69
|
|
75
|
-
|
76
|
-
|
70
|
+
_on_start: ->
|
71
|
+
if location.hash != ''
|
72
|
+
@_route()
|
73
|
+
return $(this).trigger('hashchange')
|
77
74
|
|
78
|
-
|
79
|
-
|
80
|
-
else
|
81
|
-
@module.showRootList()
|
75
|
+
if ! @isMobile()
|
76
|
+
return @updateHash('#/' + Object.keys(@modules)[0])
|
82
77
|
|
83
78
|
|
84
79
|
# PUBLIC ================================================
|
85
80
|
|
86
|
-
unsetActiveListItems: ->
|
87
|
-
$('.list .items .item.active').removeClass('active')
|
88
|
-
|
89
|
-
|
90
81
|
isMobile: ->
|
91
82
|
$(window).width() < 760
|
92
83
|
|
93
84
|
|
94
|
-
updateHash: (
|
95
|
-
window.
|
96
|
-
location.hash = hash
|
85
|
+
updateHash: (path, @skipRoute=false) ->
|
86
|
+
window.location.hash = path
|
97
87
|
|
98
88
|
|
99
89
|
start: (@config) ->
|
@@ -101,43 +91,15 @@ class @Chr
|
|
101
91
|
@$navBar =$ "<nav class='sidebar'>"
|
102
92
|
@$mainMenu =$ "<div class='menu'>"
|
103
93
|
|
104
|
-
@$navBar.append
|
105
|
-
@$el.append
|
106
|
-
|
107
|
-
@modules[name] = new Module(this, name, config) for name, config of @config.modules
|
108
|
-
|
109
|
-
$(this).on 'hashchange', => @_set_active_menu_item()
|
110
|
-
|
111
|
-
window.onhashchange = =>
|
112
|
-
@_unset_active_menu_items()
|
113
|
-
@unsetActiveListItems()
|
114
|
-
|
115
|
-
# this allows to skip chr _navigate method for silent hashchanges,
|
116
|
-
# e.g. close view event
|
117
|
-
if not window._skipHashchange then @_navigate(location.hash)
|
118
|
-
window._skipHashchange = false
|
94
|
+
@$navBar.append(@$mainMenu)
|
95
|
+
@$el.append(@$navBar)
|
119
96
|
|
120
|
-
|
121
|
-
|
122
|
-
|
97
|
+
for name, config of @config.modules
|
98
|
+
@modules[name] = new Module(this, name, config)
|
99
|
+
@_add_menu_item(name, @modules[name].menuTitle)
|
123
100
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
# if not mobile navigate on first page load or page refresh
|
128
|
-
window._skipHashchange = false
|
129
|
-
|
130
|
-
# if hash is not empty go to module
|
131
|
-
if location.hash != ''
|
132
|
-
@_navigate(location.hash)
|
133
|
-
$(this).trigger('hashchange')
|
134
|
-
else if ! @isMobile()
|
135
|
-
# if on desktop/tablet while hash is empty go to first module in the list
|
136
|
-
location.hash = '#/' + Object.keys(@modules)[0]
|
137
|
-
|
138
|
-
|
139
|
-
addMenuItem: (moduleName, title) ->
|
140
|
-
@$mainMenu.append "<a href='#/#{ moduleName }'>#{ title }</a>"
|
101
|
+
@_bind_hashchange()
|
102
|
+
@_on_start()
|
141
103
|
|
142
104
|
|
143
105
|
showAlert: (message) ->
|
@@ -148,9 +110,12 @@ class @Chr
|
|
148
110
|
alert 'Error: ' + message
|
149
111
|
|
150
112
|
|
151
|
-
|
113
|
+
include(Chr, chrRouter)
|
114
|
+
|
115
|
+
|
116
|
+
# ---------------------------------------------------------
|
152
117
|
# Initialize `chr` object in global scope
|
153
|
-
#
|
118
|
+
# ---------------------------------------------------------
|
154
119
|
window.chr = new Chr()
|
155
120
|
|
156
121
|
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
# Author: Alexander Kravets <alex@slatestudio.com>,
|
3
|
+
# Slate Studio (http://www.slatestudio.com)
|
4
|
+
#
|
5
|
+
# Coding Guide:
|
6
|
+
# https://github.com/thoughtbot/guides/tree/master/style/coffeescript
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
|
9
|
+
# -----------------------------------------------------------------------------
|
10
|
+
# CHARACTER ROUTER
|
11
|
+
# -----------------------------------------------------------------------------
|
12
|
+
|
13
|
+
@chrRouter =
|
14
|
+
|
15
|
+
# PRIVATE ===============================================
|
16
|
+
|
17
|
+
# format: #/<module>[/<list>]+[/new]OR[/view/<objectId>]
|
18
|
+
_parse_path: ->
|
19
|
+
params =
|
20
|
+
path: location.hash
|
21
|
+
module: null
|
22
|
+
backToMenu: false
|
23
|
+
moduleHasChanged: false
|
24
|
+
nestedListNames: []
|
25
|
+
lastNestedListName: null
|
26
|
+
showView: false
|
27
|
+
objectId: null
|
28
|
+
showNestedView: false
|
29
|
+
|
30
|
+
crumbs = params.path.split('/')
|
31
|
+
module = @modules[crumbs[1]]
|
32
|
+
params.module = module
|
33
|
+
params.backToMenu = if module then false else true
|
34
|
+
params.moduleHasChanged = ( @module != module )
|
35
|
+
|
36
|
+
crumbs = crumbs.splice(2)
|
37
|
+
for crumb in crumbs
|
38
|
+
if crumb == 'new'
|
39
|
+
return $.extend(params, { showView: true })
|
40
|
+
|
41
|
+
if crumb == 'view'
|
42
|
+
return $.extend(params, { showView: true, objectId: _last(crumbs) })
|
43
|
+
|
44
|
+
params.lastNestedListName = crumb
|
45
|
+
params.nestedListNames.push(crumb)
|
46
|
+
|
47
|
+
# check if last list name is a name for nested view
|
48
|
+
if params.lastNestedListName
|
49
|
+
lastList = module.nestedLists[params.lastNestedListName]
|
50
|
+
if ! lastList
|
51
|
+
nestedViewName = params.nestedListNames.pop()
|
52
|
+
params.lastNestedListName = _last(params.nestedListNames)
|
53
|
+
|
54
|
+
parentList = module.nestedLists[params.lastNestedListName]
|
55
|
+
parentList ?= module.rootList
|
56
|
+
|
57
|
+
params.showNestedView = true
|
58
|
+
params.showView = true
|
59
|
+
params.objectId = ''
|
60
|
+
params.config = parentList.config.items[nestedViewName]
|
61
|
+
|
62
|
+
return params
|
63
|
+
|
64
|
+
|
65
|
+
_route: ->
|
66
|
+
params = @_parse_path()
|
67
|
+
|
68
|
+
if params.backToMenu
|
69
|
+
if @module
|
70
|
+
@module.activeList.scrollCache = 0
|
71
|
+
@module.hide()
|
72
|
+
@module = null
|
73
|
+
return
|
74
|
+
|
75
|
+
if params.moduleHasChanged
|
76
|
+
@module?.hide()
|
77
|
+
@module = params.module
|
78
|
+
|
79
|
+
# show module, root list becomes active
|
80
|
+
@module.show()
|
81
|
+
@module.activeList.updateItems()
|
82
|
+
|
83
|
+
# show nested lists
|
84
|
+
for listName in params.nestedListNames
|
85
|
+
@module.showList(listName)
|
86
|
+
@module.activeList.updateItems()
|
87
|
+
|
88
|
+
else
|
89
|
+
@module.destroyView()
|
90
|
+
|
91
|
+
for name, list of @module.nestedLists
|
92
|
+
# hide all lists not in the path and flush scroll cache for them
|
93
|
+
if params.path.indexOf(list.path) != 0
|
94
|
+
list.scrollCache = 0
|
95
|
+
list.hide()
|
96
|
+
|
97
|
+
update_active_list_items = true
|
98
|
+
|
99
|
+
# show view
|
100
|
+
if params.showView
|
101
|
+
update_active_list_items = false
|
102
|
+
|
103
|
+
# close view
|
104
|
+
if @module.activeList.path == params.path
|
105
|
+
update_active_list_items = false
|
106
|
+
|
107
|
+
# back to parent
|
108
|
+
if @module.activeList.path.indexOf(params.path) == 0
|
109
|
+
update_active_list_items = false
|
110
|
+
|
111
|
+
@module.showList(params.lastNestedListName)
|
112
|
+
|
113
|
+
if update_active_list_items
|
114
|
+
@module.activeList.updateItems()
|
115
|
+
|
116
|
+
|
117
|
+
params.config ?= @module.activeList.config
|
118
|
+
|
119
|
+
# show view
|
120
|
+
if params.showView
|
121
|
+
@module.showView(params.objectId, params.config)
|
122
|
+
|
123
|
+
@mobileListLock(params.showView)
|
124
|
+
|
125
|
+
|
126
|
+
# PUBLIC ================================================
|
127
|
+
|
128
|
+
mobileListLock: (showView) ->
|
129
|
+
if chr.isMobile()
|
130
|
+
@module.rootList.$el.addClass('scroll-lock')
|
131
|
+
|
132
|
+
for name, list of @module.nestedLists
|
133
|
+
list.$el.addClass('scroll-lock')
|
134
|
+
|
135
|
+
if ! showView
|
136
|
+
@module.activeList.$el.removeClass('scroll-lock')
|
137
|
+
$(window).scrollTop( @module.activeList.scrollCache ? 0)
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|