evrobone 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/evrobone/app-mixins/views-management.js.coffee +29 -20
- data/app/assets/javascripts/evrobone/app-mixins/window-navigation.js.coffee +2 -2
- data/app/assets/javascripts/evrobone/helpers.js.coffee.erb +1 -1
- data/app/assets/javascripts/evrobone/jquery-additions.js.coffee +1 -1
- data/app/assets/javascripts/evrobone/view.js.coffee +3 -2
- data/evrobone.gemspec +2 -0
- data/lib/evrobone/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3863ddda85ac2654aec7e76c4239c8678c59feb
|
4
|
+
data.tar.gz: c152a7a0be3c7e22cff207c27b7bf5f1bbc5e76a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 482ca778bc56de3e5d28d0c9a3f2fdab11a555b8a95f3e6a82560c3104701985d82b847d3e4b704e69e5cbf69cb4dcd7356a3e1264f3cc21c686c166f8165f40
|
7
|
+
data.tar.gz: ec047fc8af6bec9181af5831b6d3939f887350dd98111fa0d66f6518089ff14379f4597deb9043bfd3621ee3849d94d172402b5916385a8f8531909943c2b3eb
|
@@ -7,14 +7,15 @@ Evrobone.AppMixins.ViewsManagement =
|
|
7
7
|
ProtoViews: {}
|
8
8
|
Views: {}
|
9
9
|
|
10
|
+
preventMultibind: true
|
10
11
|
warnOnMultibind: true
|
11
|
-
preventMultibind: false
|
12
12
|
groupBindingLog: true
|
13
13
|
|
14
14
|
viewInstances: null
|
15
15
|
|
16
16
|
viewsManagementInitialize: ->
|
17
17
|
@viewInstances = []
|
18
|
+
@warnOnMultibind = DEBUG_MODE and @warnOnMultibind
|
18
19
|
@on 'start', @viewsManagementStart, @
|
19
20
|
@on 'stop', @viewsManagementStop, @
|
20
21
|
return
|
@@ -24,46 +25,52 @@ Evrobone.AppMixins.ViewsManagement =
|
|
24
25
|
@performancePoint('Bound %count% view%s%', boundViews.length) if @performanceReport
|
25
26
|
return
|
26
27
|
|
27
|
-
viewsManagementStop:
|
28
|
+
viewsManagementStop: ->
|
28
29
|
@unbindViews @viewInstances
|
29
30
|
return
|
30
31
|
|
31
32
|
bindViews: ($root = $('html'), checkRoot = true) ->
|
32
33
|
if @groupBindingLog
|
33
34
|
console?.groupCollapsed? 'bindViews on', $root
|
34
|
-
|
35
|
+
allBoundViews = []
|
35
36
|
sortedViews = _.sortBy(_.pairs(@Views), (p) -> -p[1].priority or 0)
|
36
37
|
for [viewName, viewClass] in sortedViews when viewClass::el
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
$elements = $root.find(viewClass::el)
|
39
|
+
$elements = $root.filter(viewClass::el).add($elements) if checkRoot
|
40
|
+
if $elements.length
|
41
|
+
boundViews = @_bindViews($elements, viewClass, viewName)
|
42
|
+
if boundViews.length > 0
|
43
|
+
@_boundInfo(boundViews, viewClass, viewName) if DEBUG_MODE and viewName and viewClass.silent isnt true
|
44
|
+
allBoundViews = allBoundViews.concat(boundViews)
|
40
45
|
if @groupBindingLog
|
41
46
|
console?.groupEnd?()
|
42
|
-
|
47
|
+
allBoundViews
|
43
48
|
|
44
|
-
_bindViews: (
|
45
|
-
$elements.
|
46
|
-
if view = @bindView(el, viewClass, viewName)
|
47
|
-
boundViews.push view
|
48
|
-
return
|
49
|
+
_bindViews: ($elements, viewClass, viewName) ->
|
50
|
+
view for el in $elements.get() when view = @bindView(el, viewClass, viewName)
|
49
51
|
|
50
|
-
bindView: (element, viewClass
|
52
|
+
bindView: (element, viewClass) ->
|
51
53
|
if @canBind(element, viewClass)
|
52
|
-
|
53
|
-
view = new viewClass(options)
|
54
|
-
if viewName
|
55
|
-
cout 'info', "Bound view #{viewName}:", view
|
54
|
+
view = new viewClass(el: element)
|
56
55
|
@viewInstances.push view
|
57
56
|
view
|
58
57
|
|
58
|
+
_boundInfo: (views, viewClass, viewName) ->
|
59
|
+
instancesInfo = 'silent instances' if viewClass.silent is 'instances'
|
60
|
+
if views.length > 1
|
61
|
+
cout 'info', @_plurMessage("Bound view #{viewName} %count% time%s%:", views.length), instancesInfo or views
|
62
|
+
else
|
63
|
+
cout 'info', "Bound view #{viewName}:", instancesInfo or views[0]
|
64
|
+
return
|
65
|
+
|
59
66
|
canBind: (element, viewClass) ->
|
60
|
-
if @
|
67
|
+
if @preventMultibind or @warnOnMultibind
|
61
68
|
views = @getViewsOnElement(element)
|
62
69
|
l = views.length
|
63
70
|
if l > 0
|
64
71
|
if @warnOnMultibind
|
65
72
|
cout 'warn', @_plurMessage('Element already has bound %count% view%s%', l), element, viewClass, views
|
66
|
-
not @preventMultibind
|
73
|
+
not ( @preventMultibind and _.findWhere(views, constructor: viewClass) )
|
67
74
|
else
|
68
75
|
true
|
69
76
|
else
|
@@ -75,7 +82,9 @@ Evrobone.AppMixins.ViewsManagement =
|
|
75
82
|
view.undelegateEvents()
|
76
83
|
view.leave context
|
77
84
|
@viewInstances = _.without(@viewInstances, views...)
|
78
|
-
|
85
|
+
if DEBUG_MODE
|
86
|
+
cout 'info', @_plurMessage('Unbound %count% view%s%:', views.length),
|
87
|
+
_.filter(views, (v) -> not v.constructor.silent)
|
79
88
|
return
|
80
89
|
|
81
90
|
getViewsOnElement: (element) ->
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Evrobone.AppMixins.WindowNavigation =
|
2
2
|
|
3
|
-
changeLocation: (url, push = false) ->
|
3
|
+
changeLocation: (url, push = false, title = '', options) ->
|
4
4
|
#cout '!> changeLocation', url
|
5
5
|
historyMethod = window.history[if push then 'pushState' else 'replaceState']
|
6
6
|
if historyMethod
|
7
|
-
historyMethod.call window.history, { turbolinks: Turbolinks?, url: url },
|
7
|
+
historyMethod.call window.history, _.extend({ turbolinks: Turbolinks?, url: url }, options), title, url
|
8
8
|
else
|
9
9
|
window.location.hash = url
|
10
10
|
return
|
@@ -22,7 +22,7 @@ window.todo = (subject, location = null, numberOrString = null) =>
|
|
22
22
|
cout 'warn', "TODO: #{subject}#{if location then " ### #{location}" else ''}#{if numberOrString then (if _.isNumber(numberOrString) then ":#{numberOrString}" else " > #{numberOrString}") else ''}"
|
23
23
|
|
24
24
|
window.getParams = (searchString = location.search) ->
|
25
|
-
q = searchString.replace(
|
25
|
+
q = searchString.replace(/^.*\?/, '').split('&')
|
26
26
|
r = {}
|
27
27
|
for e in q
|
28
28
|
t = e.split('=')
|
@@ -71,7 +71,7 @@ do ($ = jQuery) =>
|
|
71
71
|
callback $(element)
|
72
72
|
|
73
73
|
$.fn.closestScrollable = ->
|
74
|
-
$(_.find(@parents().get(), (p) -> $(p).css('overflowY') is 'auto') or window)
|
74
|
+
$(_.find(@.get().concat(@parents().get()), (p) -> $(p).css('overflowY') is 'auto') or window)
|
75
75
|
|
76
76
|
# RESEARCH
|
77
77
|
# $.fn.blockHide = ->
|
@@ -6,9 +6,10 @@ class Evrobone.View extends Backbone.View
|
|
6
6
|
|
7
7
|
@mixinNames: null
|
8
8
|
|
9
|
-
|
10
|
-
@reflectOptions options
|
9
|
+
setElement: ->
|
11
10
|
super
|
11
|
+
@reflectOptions()
|
12
|
+
@
|
12
13
|
|
13
14
|
reflectOptions: (options = @$el.data()) ->
|
14
15
|
@[attr] = value for attr, value of options when not _.isUndefined(@[attr])
|
data/evrobone.gemspec
CHANGED
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'backbone-rails'
|
24
|
+
spec.add_development_dependency 'turbolinks'
|
23
25
|
spec.add_development_dependency 'rubocop'
|
24
26
|
spec.add_development_dependency 'coffeelint'
|
25
27
|
end
|
data/lib/evrobone/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evrobone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry KODer Karpunin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: backbone-rails
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: turbolinks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rubocop
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|