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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26c788a581e13778cf0b5d333af096b34f60ce3b
4
- data.tar.gz: a809c99a82907e0b6c857b06db91aaf3b2a21939
3
+ metadata.gz: 073fb5fcc0f954e4377b65558dce2feae071c49c
4
+ data.tar.gz: 111fa9aec310abea7f535e3a9b230d754c95599b
5
5
  SHA512:
6
- metadata.gz: 638a879974f949739088ed3e9f1ed152c52efeb2dd7a3d7a3746a6f2da294eefafe20f3db872334a7d69290e42daf5ccf25407cb16b4615d23406072d509cc44
7
- data.tar.gz: 0f10ff1c25ecd42de224a2cd21b05df2c39e91f75368f881d6021385bc6c9cfb316ddfa243f36b7566c5265bbd894bacf128b1b1092c9be6e861b207f9a17e80
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
- @sync(attr) if @_listening
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 = $("template##{id}.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('template',{id: id, type: 'text/p-template'}, &block)
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('template',{id: id, type: 'text/p-partial', class: 'p'}, &block)
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}) }}")
@@ -1,3 +1,3 @@
1
1
  module Pinkman
2
- VERSION = "0.9.9.5.2"
2
+ VERSION = "0.9.9.6"
3
3
  end
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.5.2
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-20 00:00:00.000000000 Z
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler