pinkman 0.9.9.1 → 0.9.9.2.fix
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/pinkman_base/collection.coffee +34 -6
- data/app/assets/javascripts/pinkman_base/controller.coffee +6 -4
- data/app/assets/javascripts/pinkman_base/css_and_config.coffee +1 -1
- data/app/assets/javascripts/pinkman_base/pinkman.coffee +13 -1
- data/app/assets/javascripts/pinkman_base/render.coffee.erb +27 -3
- data/app/assets/javascripts/pinkman_base/router.coffee +28 -4
- data/app/helpers/pinkman_helper.rb +14 -1
- data/lib/pinkman/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2026e4d3d78024833d6de5d1673787649d49893
|
4
|
+
data.tar.gz: 2d2c250b32799088f81a17e1abced7ed53098f63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0770bfd824f5d45ec4a7372947cf77015a26497b4a82e31145d3c87bd467e91e15b3e42519fa56bc192670cff60b40bf83691c578eb5c29f6aa7bf029c243e4
|
7
|
+
data.tar.gz: 824a087f1fa19265e597d263e31853cc6a6a34c6f98b11009b187bd81ed07bd23997cf46c80dfa808b63a477839492874cd9dca928d724c3394c9168d31af3f9
|
@@ -52,8 +52,11 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
52
52
|
# tip: you can chain functions. Example: collection.each(transform).first()
|
53
53
|
each: (transformation='',callback) ->
|
54
54
|
if transformation? and typeof transformation=='function'
|
55
|
-
|
56
|
-
|
55
|
+
i = 0
|
56
|
+
for o in @collection
|
57
|
+
i = i+1
|
58
|
+
transformation(o)
|
59
|
+
callback(this) if (i == @count()) and typeof callback == 'function'
|
57
60
|
return this
|
58
61
|
|
59
62
|
# rails/ruby equivalent: where/select
|
@@ -79,6 +82,23 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
79
82
|
callback(selection) if typeof callback == 'function'
|
80
83
|
return(selection)
|
81
84
|
|
85
|
+
# every element of this collection will be substituted by the element of the collection passed
|
86
|
+
absorb: (collection, callback) ->
|
87
|
+
if typeof collection == 'object' and collection.isPink and collection.isCollection
|
88
|
+
@each (obj) =>
|
89
|
+
o = collection.find(obj.id)
|
90
|
+
if o?
|
91
|
+
@remove obj, =>
|
92
|
+
@forceUnshift(o)
|
93
|
+
, callback
|
94
|
+
|
95
|
+
# substitute element a by element b
|
96
|
+
substitute: (a,b,callback) ->
|
97
|
+
if a? and b?
|
98
|
+
@remove(a)
|
99
|
+
@push(b)
|
100
|
+
callback() if typeof callback == 'function'
|
101
|
+
|
82
102
|
# Desc: insert in last position
|
83
103
|
push: (arg) ->
|
84
104
|
if Pinkman.isArray(arg)
|
@@ -109,6 +129,12 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
109
129
|
|
110
130
|
forcePush: (object) ->
|
111
131
|
@collection.push(object)
|
132
|
+
|
133
|
+
directUnshift: (object) ->
|
134
|
+
@collection.unshift(object) unless @include(object)
|
135
|
+
|
136
|
+
forceUnshift: (object) ->
|
137
|
+
@collection.unshift(object)
|
112
138
|
|
113
139
|
unshiftIndividually: (object) ->
|
114
140
|
if object? and typeof object == 'object' and not @include(object)
|
@@ -136,15 +162,17 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
136
162
|
@remove(@first())
|
137
163
|
|
138
164
|
# Desc: remove a object from the collection
|
139
|
-
remove: (object) ->
|
165
|
+
remove: (object,callback) ->
|
140
166
|
if typeof object == 'object' and object.id? and (a = @find(object.id))?
|
141
167
|
i = @collection.indexOf a
|
142
168
|
@collection.splice(i,1)
|
143
|
-
|
169
|
+
value = a
|
144
170
|
else
|
145
171
|
i = @collection.indexOf object
|
146
172
|
@collection.splice(i,1)
|
147
|
-
|
173
|
+
value = object
|
174
|
+
callback(this) if typeof callback == 'function'
|
175
|
+
return(value)
|
148
176
|
|
149
177
|
# Desc: remove the first object that matches
|
150
178
|
removeBy: (attribute,value) ->
|
@@ -204,7 +232,7 @@ class window.PinkmanCollection extends window.PinkmanCommon
|
|
204
232
|
|
205
233
|
# Desc: return trues if has at least one member. If a criteria is specificied, returns true if at least one member satisfies it.
|
206
234
|
any: (criteria='') ->
|
207
|
-
if criteria? and typeof criteria == 'function'
|
235
|
+
if criteria? and (typeof criteria == 'function' or typeof criteria == 'object')
|
208
236
|
@select(criteria).count() > 0
|
209
237
|
else
|
210
238
|
@count() > 0
|
@@ -57,11 +57,11 @@ class window.PinkmanController extends window.PinkmanObject
|
|
57
57
|
@actions.getBy('name',args[0])
|
58
58
|
else
|
59
59
|
[name, eventName,callback,unknown...] = args
|
60
|
-
|
60
|
+
id = "#{@pinkey}-#{name}-#{eventName}"
|
61
|
+
a = new PinkmanAction(id: id, name: name, eventName: eventName, call: callback, controller: this)
|
61
62
|
a.set('selector',"##{a.controller.id} [data-action='#{a.name}']")
|
62
63
|
Pinkman.actions.push(a)
|
63
|
-
@actions.push(a)
|
64
|
-
a.listen() if a.call? and typeof a.call == 'function'
|
64
|
+
a.listen() if @actions.push(a) and a.call? and typeof a.call == 'function'
|
65
65
|
return(a)
|
66
66
|
|
67
67
|
|
@@ -205,10 +205,12 @@ class window.PinkmanAction extends window.PinkmanObject
|
|
205
205
|
|
206
206
|
# Desc: attaches one single event
|
207
207
|
attach: (eventName) ->
|
208
|
-
if Pinkman.isString(eventName)
|
208
|
+
if Pinkman.isString(eventName)
|
209
209
|
action = this
|
210
210
|
@events.push(eventName)
|
211
211
|
$('body').on eventName, action.selector, (ev) ->
|
212
|
+
# debugger
|
213
|
+
# console.log "#{action.id}: called - #{action.name}"
|
212
214
|
ev.preventDefault() if eventName != 'keypress' and eventName != 'mousedown'
|
213
215
|
obj = window.Pinkman.closest($(this))
|
214
216
|
action.call(obj,$(this),ev)
|
@@ -4,5 +4,5 @@ Pinkman.css = (selector,property,value) ->
|
|
4
4
|
|
5
5
|
$(document).ready ->
|
6
6
|
unless $('style#pinkman-css-injector').length
|
7
|
-
$('
|
7
|
+
$('head').append('<style id="pinkman-css-injector" type="text/css">pink{display: inline; margin: 0; padding: 0; color: inherit; background-color: inherit; font: inherit;} template, template *{ display: none !important;}</style>')
|
8
8
|
document.createElement('pink') if document.createElement?
|
@@ -91,7 +91,19 @@ class window.Pinkman
|
|
91
91
|
i = i+1
|
92
92
|
a
|
93
93
|
|
94
|
-
|
94
|
+
# i hated that i had to do this
|
95
|
+
@unescape: (string) ->
|
96
|
+
if Pinkman.isString(string)
|
97
|
+
map = { '&': '&', '<': '<', '>': '>', '"': '"', ''': "'", '/': '/', '`': '`', '=': '=' }
|
98
|
+
keys = []
|
99
|
+
keys.push("(?:#{k})") for k,v of map
|
100
|
+
window.regexp = new RegExp(keys.join('+|') + '+','gm')
|
101
|
+
string.replace regexp, (match) ->
|
102
|
+
map[match]
|
103
|
+
else
|
104
|
+
''
|
105
|
+
|
106
|
+
|
95
107
|
@calledFunctions = []
|
96
108
|
|
97
109
|
# --- Scope
|
@@ -33,9 +33,17 @@ Pinkman.template_engines =
|
|
33
33
|
template = Pinkman.templates.get(template: options.template, engine: options.engine)
|
34
34
|
else
|
35
35
|
template = new Pinkman.object(template: options.template, engine: options.engine)
|
36
|
-
@compile(options.engine, template, @
|
36
|
+
@compile(options.engine, template, @templateModifier($('#' + options.template).html()))
|
37
37
|
Pinkman.templates.push(template)
|
38
38
|
return(template)
|
39
|
+
|
40
|
+
# templateModifier
|
41
|
+
# apply all pinkman modifiers to templates
|
42
|
+
templateModifier: (templateBody) ->
|
43
|
+
# content = templateBody
|
44
|
+
# content = @partialAdapter(templateBody)
|
45
|
+
# content = @templateAdapter(templateBody)
|
46
|
+
Pinkman.unescape(@templateAdapter(@partialAdapter(templateBody)))
|
39
47
|
|
40
48
|
|
41
49
|
# attrAdapterHelper: helper for templateAdapter
|
@@ -49,7 +57,7 @@ Pinkman.template_engines =
|
|
49
57
|
array.push('pinkey')
|
50
58
|
pinkey = array.join('.')
|
51
59
|
"#{$1}<pink data-pinkey=\"{{ #{pinkey} }}\" data-attribute=\"#{attr}\">{{ #{$2} }}</pink>#{$3}"
|
52
|
-
|
60
|
+
|
53
61
|
# changes templates html to insert binders so pinkman can make realtime updates
|
54
62
|
templateAdapter: (templateBody) ->
|
55
63
|
if templateBody? and templateBody != ''
|
@@ -59,6 +67,21 @@ Pinkman.template_engines =
|
|
59
67
|
content.replace(escapeSyncingRegex,'{{')
|
60
68
|
else
|
61
69
|
''
|
70
|
+
|
71
|
+
# modifies templates inserting partials before sending them to rendering the engines
|
72
|
+
partialAdapter: (templateBody) ->
|
73
|
+
if templateBody? and templateBody != ''
|
74
|
+
partialRegex = /{{(?:\s)*partial\((?:\s)*(.*)(?:\s)*\)(?:\s)*}}/gm
|
75
|
+
templateBody.replace(partialRegex,@partialInception)
|
76
|
+
else
|
77
|
+
''
|
78
|
+
|
79
|
+
partialInception: (match,id) ->
|
80
|
+
p = $("template##{id}.p")
|
81
|
+
if p.length
|
82
|
+
p.html()
|
83
|
+
else
|
84
|
+
match
|
62
85
|
|
63
86
|
context: (options) ->
|
64
87
|
options.object = options.context if options.context?
|
@@ -128,8 +151,9 @@ Pinkman.render = (options) ->
|
|
128
151
|
Pinkman.template_engines.render(options)
|
129
152
|
options.object.queue(options) if options.reRender and options.object? and options.object.isPink
|
130
153
|
|
154
|
+
Pinkman.scrolling = new PinkmanCollection unless Pinkman.scrolling?
|
155
|
+
|
131
156
|
Pinkman.saveElementScrollPosition = (id) ->
|
132
|
-
Pinkman.scrolling = new PinkmanCollection unless Pinkman.scrolling?
|
133
157
|
a = Pinkman.scrolling.find(id)
|
134
158
|
a = new Pinkman.object unless a?
|
135
159
|
a.set('id',id)
|
@@ -138,20 +138,38 @@ class window.PinkmanRouter
|
|
138
138
|
routes(router) if typeof routes == 'function'
|
139
139
|
return(router)
|
140
140
|
|
141
|
+
@scrolling = new PinkmanCollection
|
142
|
+
|
143
|
+
@saveWindowScroll = (id) ->
|
144
|
+
@scrolling.firstOrInitialize(id: id).set('position', window.scrollY)
|
141
145
|
|
146
|
+
@restoreWindowScroll = (id) ->
|
147
|
+
o = @scrolling.firstOrInitialize(id: id)
|
148
|
+
# console.log o.position
|
149
|
+
o.position = 0 unless o.position?
|
150
|
+
window.scrollTo(0,o.position)
|
151
|
+
|
142
152
|
@render: (r, callback) ->
|
153
|
+
@saveWindowScroll(Pinkman.routes.current.controller) if Pinkman.routes.current?
|
143
154
|
Pinkman.state.initialize()
|
144
155
|
yieldIn = r.route.yieldIn() || @_config.yield
|
145
156
|
$(yieldIn).html("<div class='pink-yield' id='#{r.controller}'></div>") if r.route.blank
|
146
157
|
r.initialize()
|
147
|
-
|
158
|
+
Pinkman.routes.set('current',r.route)
|
159
|
+
unless Pinkman.router._config.freeze or (r.options? and r.options.freeze)
|
160
|
+
# console.log 'topo'
|
161
|
+
window.scrollTo(0,0)
|
162
|
+
else
|
163
|
+
sleep 0.15, =>
|
164
|
+
@restoreWindowScroll(r.route.controller)
|
148
165
|
callback() if typeof callback == 'function'
|
149
166
|
true
|
150
167
|
|
151
168
|
# Search path throughout routes. On match, activate respective controllers: clears template and execute main(s) function(s)
|
152
|
-
@activate: (path,callback) ->
|
169
|
+
@activate: (path,callback,options) ->
|
153
170
|
r = Pinkman.routes.match(path)
|
154
171
|
if r? and r
|
172
|
+
r.options = options
|
155
173
|
if @_config.transition? and typeof @_config.transition == 'function'
|
156
174
|
@_config.transition =>
|
157
175
|
@render(r,callback)
|
@@ -164,12 +182,12 @@ class window.PinkmanRouter
|
|
164
182
|
@visit: (path) ->
|
165
183
|
@activate path, ->
|
166
184
|
Pinkman.state.push(path)
|
167
|
-
|
185
|
+
|
168
186
|
@force: (path) ->
|
169
187
|
(window.location=path) unless @visit(path)
|
170
188
|
|
171
189
|
@restore: (path) ->
|
172
|
-
(window.location=path) unless @activate(path)
|
190
|
+
(window.location=path) unless @activate(path,null,{freeze: yes})
|
173
191
|
|
174
192
|
@redirect: (args...) ->
|
175
193
|
@force(args...)
|
@@ -179,6 +197,12 @@ class window.PinkmanRouter
|
|
179
197
|
|
180
198
|
@go: (args...) ->
|
181
199
|
@force(args...)
|
200
|
+
|
201
|
+
@forward: ->
|
202
|
+
window.history.forward() if window.history?
|
203
|
+
|
204
|
+
@back: ->
|
205
|
+
window.history.back() if window.history?
|
182
206
|
|
183
207
|
@start: ->
|
184
208
|
Pinkman.ready =>
|
@@ -13,18 +13,31 @@ module PinkmanHelper
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
|
16
17
|
def template path, &block
|
17
18
|
# definition mode
|
18
19
|
if block_given?
|
19
20
|
name = path.to_s
|
20
21
|
id = (/(?:-template)$/ =~ name) ? name : (name +'-template')
|
21
|
-
content_tag('
|
22
|
+
content_tag('template',{id: id, type: 'text/p-template'}, &block)
|
22
23
|
# rendering template partial mode
|
23
24
|
else
|
24
25
|
render partial: "pinkman/#{path}"
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
29
|
+
def partial path, &block
|
30
|
+
# definition mode
|
31
|
+
name = path.to_s
|
32
|
+
id = (/(?:-template)$/ =~ name) ? name : (name +'-template')
|
33
|
+
if block_given?
|
34
|
+
content_tag('template',{id: id, type: 'text/p-partial', class: 'p'}, &block)
|
35
|
+
# rendering template partial mode
|
36
|
+
else
|
37
|
+
raw("{{ partial(#{id}) }}")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
28
41
|
def load_templates
|
29
42
|
if Rails
|
30
43
|
dir = Rails.root.join('app','views','pinkman')
|
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.2.fix
|
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-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -239,9 +239,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
239
239
|
version: '0'
|
240
240
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
241
|
requirements:
|
242
|
-
- - "
|
242
|
+
- - ">"
|
243
243
|
- !ruby/object:Gem::Version
|
244
|
-
version:
|
244
|
+
version: 1.3.1
|
245
245
|
requirements: []
|
246
246
|
rubyforge_project:
|
247
247
|
rubygems_version: 2.5.1
|