pinkman 0.9.9.5.2 → 0.9.9.6
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/pinkman_base/collection.coffee +16 -0
- data/app/assets/javascripts/pinkman_base/common.coffee +31 -6
- data/app/assets/javascripts/pinkman_base/render.coffee.erb +2 -2
- data/app/helpers/pinkman_helper.rb +2 -2
- data/lib/pinkman/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 073fb5fcc0f954e4377b65558dce2feae071c49c
|
4
|
+
data.tar.gz: 111fa9aec310abea7f535e3a9b230d754c95599b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ac52b2e517cafe3dbeb8dee1fc669151ac61786cded8800ce31e8ff91a97742bf206e2543f103a15e7568a10098889afa70a289b4d09c62612d5e178fa02f12
|
7
|
+
data.tar.gz: 0c8e720d3377a9e8ae498a9980de537f02718f98e11253d25bddb51ad7d07ad7868290673559d20721324daa885e05570614726629ae5cbac1b931cdd3a6d80c
|
@@ -30,6 +30,22 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
30
30
|
json.push(object.json()) if object.isPink and object.json? and typeof object.json == 'function'
|
31
31
|
json
|
32
32
|
|
33
|
+
# Desc: sum a certain attribute of every element
|
34
|
+
sum: (attr,callback) ->
|
35
|
+
if attr?
|
36
|
+
v = 0
|
37
|
+
@each (obj) ->
|
38
|
+
if Pinkman.isNumber(obj[attr])
|
39
|
+
v = Number(obj[attr]) + v
|
40
|
+
else if obj[attr]?
|
41
|
+
v = obj[attr] + v
|
42
|
+
, =>
|
43
|
+
callback(this, v) if typeof callback == 'function'
|
44
|
+
return(v)
|
45
|
+
else
|
46
|
+
callback(this,0) if typeof callback == 'function'
|
47
|
+
return(0)
|
48
|
+
|
33
49
|
# Desc: collection size
|
34
50
|
count: (criteria='') ->
|
35
51
|
if criteria? and typeof criteria == 'function'
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class window.PinkmanCommon
|
2
|
-
|
2
|
+
|
3
|
+
@privateAttributes = ['isPink','isObject','isCollection','pinkey','config','pinkmanType','collections','renderQueue','_listening']
|
4
|
+
|
3
5
|
constructor: (attributesObject) ->
|
4
6
|
@_listening = true
|
5
7
|
@initialize(attributesObject) if attributesObject?
|
6
8
|
|
7
|
-
@privateAttributes = ['isPink','isObject','isCollection','pinkey','config','pinkmanType','collections','renderQueue','_listening']
|
8
|
-
|
9
9
|
@mixin: (args...) ->
|
10
10
|
Pinkman.mixin(args...)
|
11
11
|
|
@@ -47,15 +47,29 @@ class window.PinkmanCommon
|
|
47
47
|
if attr? and value?
|
48
48
|
this[attr] = value
|
49
49
|
callback(this) if typeof callback == 'function'
|
50
|
-
@
|
50
|
+
if @pinkey? and @_listening
|
51
|
+
sId = "__pSync__#{@pinkey}__"
|
52
|
+
clearTimeout(window[sId]) if window[sId]?
|
53
|
+
window[sId] = sleep 0.005, =>
|
54
|
+
# console.log "syncing #{@pinkey}"
|
55
|
+
@sync(attr) if @_listening
|
51
56
|
return this
|
52
57
|
|
53
|
-
sync: (attribute) ->
|
58
|
+
sync: (attribute) ->
|
59
|
+
if @constructor.__computed?
|
60
|
+
for c in @constructor.__computed
|
61
|
+
# console.log "computar: #{this.pinkey} #{this[c].call(this)}"
|
62
|
+
Pinkman.sync(this, c, this[c].call(this)) if this[c]? and typeof this[c] == 'function'
|
63
|
+
|
54
64
|
if attribute? and attribute!=''
|
55
65
|
Pinkman.sync(this, attribute, this[attribute])
|
56
66
|
else
|
57
67
|
Pinkman.sync(this, k, v) for k, v of @attributes()
|
58
68
|
true
|
69
|
+
|
70
|
+
lazySync: (args...)->
|
71
|
+
sleep 0.25, =>
|
72
|
+
@sync(args...)
|
59
73
|
|
60
74
|
stop: ->
|
61
75
|
@_listening = no
|
@@ -133,4 +147,15 @@ class window.PinkmanCommon
|
|
133
147
|
@hasErrorOn(args...)
|
134
148
|
|
135
149
|
_data: ->
|
136
|
-
{ pink_obj: @json(), scope: Pinkman.scope(this) }
|
150
|
+
{ pink_obj: @json(), scope: Pinkman.scope(this) }
|
151
|
+
|
152
|
+
# computed Functions
|
153
|
+
# computed functions cant have arguments
|
154
|
+
@compute: (f) ->
|
155
|
+
@__computed ||= []
|
156
|
+
if @__computed.indexOf(f) != -1
|
157
|
+
# console.log "colocou f"
|
158
|
+
@__computed.push(f)
|
159
|
+
else
|
160
|
+
# console.log "não colocou f"
|
161
|
+
@__computed.push(f)
|
@@ -83,7 +83,7 @@ Pinkman.template_engines =
|
|
83
83
|
# partialRegex = /{{(?:\s)*partial\((?:\s)*((?:\w|-)*)(?:\s)*\)(?:\s)*}}/gm
|
84
84
|
# id = id.replace(partialRegex,'$1')
|
85
85
|
# console.log id
|
86
|
-
p = $("
|
86
|
+
p = $("script##{id}.p[type='text/p-partial']")
|
87
87
|
if p.length
|
88
88
|
p.html()
|
89
89
|
else
|
@@ -143,7 +143,7 @@ Pinkman.template_engines =
|
|
143
143
|
Pinkman.__syncing = new Object
|
144
144
|
|
145
145
|
Pinkman.sync = (obj,attribute,value) ->
|
146
|
-
if typeof obj == 'object' and obj.pinkey? and obj[attribute]? and Pinkman.isPrintable(obj[attribute])
|
146
|
+
if typeof obj == 'object' and obj.pinkey? and obj[attribute]? and (value? or Pinkman.isPrintable(obj[attribute]))
|
147
147
|
# clearTimeout(Pinkman.__syncing[attribute]) if Pinkman.__syncing[attribute]?
|
148
148
|
# Pinkman.__syncing[attribute] = sleep 0.5, ->
|
149
149
|
value = obj[attribute] unless value? and value != ''
|
@@ -19,7 +19,7 @@ module PinkmanHelper
|
|
19
19
|
if block_given?
|
20
20
|
name = path.to_s
|
21
21
|
id = (/(?:-template)$/ =~ name) ? name : (name +'-template')
|
22
|
-
content_tag('
|
22
|
+
content_tag('script',{id: id, type: 'text/p-template'}, &block)
|
23
23
|
# rendering template partial mode
|
24
24
|
else
|
25
25
|
render partial: "pinkman/#{path}"
|
@@ -31,7 +31,7 @@ module PinkmanHelper
|
|
31
31
|
name = path.to_s
|
32
32
|
id = (/(?:-template)$/ =~ name) ? name : (name +'-template')
|
33
33
|
if block_given?
|
34
|
-
content_tag('
|
34
|
+
content_tag('script',{id: id, type: 'text/p-partial', class: 'p'}, &block)
|
35
35
|
# rendering template partial mode
|
36
36
|
else
|
37
37
|
raw("{{ partial(#{id}) }}")
|
data/lib/pinkman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pinkman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.9.
|
4
|
+
version: 0.9.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agilso Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|