pwnstyles_rails 0.2.4 → 0.2.5
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/VERSION +1 -1
- data/app/assets/javascripts/pwn-fx.js.coffee +45 -29
- data/pwnstyles_rails.gemspec +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb505a680bcc6ffe000289fc2e1df6bbee12a3b5
|
4
|
+
data.tar.gz: 5a1006f114506b563a92ea14e3de0602c2a13564
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfc89f52a51e685b10359d4f67bcec4992c9e15edc6dbf34a66d59d5619dfca00c20443753f0b9f5489deb8cf46090899419cb69c856d814abb2d1e0d158042d
|
7
|
+
data.tar.gz: 7baf908c7f3f74ded03eda0a8151d9f854adf0c813cdb8b22a6dda78fbf9b81ecb9b58ef0a882fc9941e4c9641ed85a2a41354a087a3864c5bb6c3c4f852e3c4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.5
|
@@ -15,12 +15,21 @@ class PwnFxClass
|
|
15
15
|
constructor: ->
|
16
16
|
@effects = []
|
17
17
|
@effectsByName = {}
|
18
|
+
@hiddenClassName = null
|
19
|
+
|
20
|
+
# @attribute {String} the default name of the DOM class used to hide
|
21
|
+
# elements; by default, this is set to the data-pwnfx-hidden-class
|
22
|
+
# attribute of the <body> element
|
23
|
+
hiddenClassName: null
|
18
24
|
|
19
25
|
# Wires JS to elements with data-pwnfx attributes.
|
20
26
|
#
|
21
27
|
# @param {Element} root the element whose content is wired; use document at
|
22
28
|
# load time
|
23
29
|
wire: (root) ->
|
30
|
+
@hiddenClassName ||=
|
31
|
+
document.body.getAttribute('data-pwnfx-hidden-class') || 'hidden'
|
32
|
+
|
24
33
|
for effect in @effects
|
25
34
|
attrName = "data-pwnfx-#{effect[0]}"
|
26
35
|
effectClass = effect[1]
|
@@ -55,7 +64,8 @@ class PwnFxClass
|
|
55
64
|
# returned if no such element exists or if scope is null
|
56
65
|
resolveScope: (scopeId, element) ->
|
57
66
|
element = null if scopeId is null
|
58
|
-
while element
|
67
|
+
while element isnt null &&
|
68
|
+
element.getAttribute('data-pwnfx-scope') isnt scopeId
|
59
69
|
element = element.parentElement
|
60
70
|
element || document
|
61
71
|
|
@@ -67,7 +77,7 @@ class PwnFxClass
|
|
67
77
|
# selector; the scope container can belong to the returned array
|
68
78
|
queryScope: (scope, selector) ->
|
69
79
|
scopeMatches = false
|
70
|
-
if scope
|
80
|
+
if scope isnt document
|
71
81
|
# TODO: machesSelector is in a W3C spec, but only implemented using
|
72
82
|
# prefixes; the code below should be simplified once browsers
|
73
83
|
# implement it without vendor prefixes
|
@@ -106,7 +116,7 @@ class PwnFxClass
|
|
106
116
|
# element is not wrapped in a <form>
|
107
117
|
parentForm: (element) ->
|
108
118
|
while element
|
109
|
-
return element if element.nodeName
|
119
|
+
return element if element.nodeName is 'FORM'
|
110
120
|
element = element.parentNode
|
111
121
|
null
|
112
122
|
|
@@ -130,7 +140,7 @@ class PwnFxClass
|
|
130
140
|
|
131
141
|
# Called when an XHR request issued by PwnFx.xhr works out.
|
132
142
|
_xhr_onload: ->
|
133
|
-
if (@status < 200 || @status >= 300) && (@status
|
143
|
+
if (@status < 200 || @status >= 300) && (@status isnt 304)
|
134
144
|
throw new Error(
|
135
145
|
"XHR result ignored due to HTTP #{@status}: #{@statusText}")
|
136
146
|
@pwnfxOnData @responseText
|
@@ -223,8 +233,8 @@ PwnFx.registerEffect 'render', PwnFxRender
|
|
223
233
|
# data-pwnfx-delayed-method: the HTTP method of AJAX request (default: POST)
|
224
234
|
# data-pwnfx-delayed-ms: the delay between the page load and the issuing of
|
225
235
|
# the AJAX request (default: 1000ms)
|
226
|
-
# data-pwnfx-delayed-target: a space-separated list of identifiers, one of
|
227
|
-
# should match the value of data-pwnfx-delayed; set on the element
|
236
|
+
# data-pwnfx-delayed-target: a space-separated list of identifiers, one of
|
237
|
+
# which should match the value of data-pwnfx-delayed; set on the element
|
228
238
|
# populated with the AJAX response
|
229
239
|
class PwnFxDelayed
|
230
240
|
constructor: (element, identifier, scopeId) ->
|
@@ -257,8 +267,8 @@ PwnFx.registerEffect 'delayed', PwnFxDelayed
|
|
257
267
|
# data-pwnfx-refresh-method: the HTTP method of AJAX request (default: POST)
|
258
268
|
# data-pwnfx-refresh-ms: delay between a change on the source element and
|
259
269
|
# AJAX refresh requests (default: 200ms)
|
260
|
-
# data-pwnfx-refresh-target: a space-separated list of identifiers, one of
|
261
|
-
# should match the value of data-pwnfx-refresh; set on the element
|
270
|
+
# data-pwnfx-refresh-target: a space-separated list of identifiers, one of
|
271
|
+
# which should match the value of data-pwnfx-refresh; set on the element
|
262
272
|
# populated with the AJAX response
|
263
273
|
class PwnFxRefresh
|
264
274
|
constructor: (element, identifier, scopeId) ->
|
@@ -282,10 +292,10 @@ class PwnFxRefresh
|
|
282
292
|
|
283
293
|
onChange = ->
|
284
294
|
value = element.value
|
285
|
-
return true if value
|
295
|
+
return true if value is refreshOldValue
|
286
296
|
refreshOldValue = value
|
287
297
|
|
288
|
-
window.clearTimeout changeTimeout if changeTimeout
|
298
|
+
window.clearTimeout changeTimeout if changeTimeout isnt null
|
289
299
|
changeTimeout = window.setTimeout ajaxRefresh, refreshDelay
|
290
300
|
true
|
291
301
|
|
@@ -303,14 +313,16 @@ PwnFx.registerEffect 'refresh', PwnFxRefresh
|
|
303
313
|
# belong to the same confirmation group; their values have to match to
|
304
314
|
# trigger the "win" condition
|
305
315
|
# data-pwnfx-confirm-class: the CSS class that is added to hidden elements;
|
306
|
-
#
|
316
|
+
# by default, this is {PwnFx.hiddenClassName}, which gets its value from
|
317
|
+
# the data-pwnfx-hidden-class attribute on <body>
|
307
318
|
# data-pwnfx-confirm-win: CSS selector identifying the elements to be shown
|
308
319
|
# when the "win" condition is triggered, and hidden otherwise
|
309
320
|
# data-pwnfx-confirm-fail: CSS selector identifying the elements to be hidden
|
310
321
|
# when the "win" condition is triggered, and shown otherwise
|
311
322
|
class PwnFxConfirm
|
312
323
|
constructor: (element, identifier, scopeId) ->
|
313
|
-
hiddenClass = element.getAttribute('data-pwnfx-confirm-class') ||
|
324
|
+
hiddenClass = element.getAttribute('data-pwnfx-confirm-class') ||
|
325
|
+
PwnFx.hiddenClassName
|
314
326
|
sourceSelector = "[data-pwnfx-confirm-done=\"#{identifier}\"]"
|
315
327
|
winSelector = "[data-pwnfx-confirm-win=\"#{identifier}\"]"
|
316
328
|
failSelector = "[data-pwnfx-confirm-fail=\"#{identifier}\"]"
|
@@ -320,9 +332,9 @@ class PwnFxConfirm
|
|
320
332
|
value = null
|
321
333
|
matching = true
|
322
334
|
for sourceElement, index in PwnFx.queryScope(scope, sourceSelector)
|
323
|
-
if index
|
335
|
+
if index is 0
|
324
336
|
value = sourceElement.value
|
325
|
-
else if sourceElement.value
|
337
|
+
else if sourceElement.value isnt value
|
326
338
|
matching = false
|
327
339
|
break
|
328
340
|
|
@@ -350,7 +362,8 @@ PwnFx.registerEffect 'confirm', PwnFxConfirm
|
|
350
362
|
# element is clicked, "checked" means events are triggered when the
|
351
363
|
# element is checked; (default: click)
|
352
364
|
# data-pwnfx-hide-class: the CSS class that is added to hidden elements;
|
353
|
-
#
|
365
|
+
# by default, this is {PwnFx.hiddenClassName}, which gets its value from
|
366
|
+
# the data-pwnfx-hidden-class attribute on <body>
|
354
367
|
# data-pwnfx-hide-positive: set to the same value as data-pwnfx-hide on
|
355
368
|
# elements that will be hidden when a positive event (click / check) is
|
356
369
|
# triggered, and shown when a negative event (uncheck) is triggered
|
@@ -360,11 +373,12 @@ PwnFx.registerEffect 'confirm', PwnFxConfirm
|
|
360
373
|
class PwnFxHide
|
361
374
|
constructor: (element, identifier, scopeId) ->
|
362
375
|
trigger = element.getAttribute('data-pwnfx-hide-trigger') || 'click'
|
363
|
-
hiddenClass = element.getAttribute('data-pwnfx-hide-class') ||
|
376
|
+
hiddenClass = element.getAttribute('data-pwnfx-hide-class') ||
|
377
|
+
PwnFx.hiddenClassName
|
364
378
|
positiveSelector = "[data-pwnfx-hide-positive=\"#{identifier}\"]"
|
365
379
|
negativeSelector = "[data-pwnfx-hide-negative=\"#{identifier}\"]"
|
366
380
|
onChange = (event) ->
|
367
|
-
positive = (trigger
|
381
|
+
positive = (trigger is 'click') || element.checked
|
368
382
|
hideSelector = if positive then positiveSelector else negativeSelector
|
369
383
|
showSelector = if positive then negativeSelector else positiveSelector
|
370
384
|
|
@@ -373,15 +387,15 @@ class PwnFxHide
|
|
373
387
|
targetElement.classList.add hiddenClass
|
374
388
|
for targetElement in PwnFx.queryScope(scope, showSelector)
|
375
389
|
targetElement.classList.remove hiddenClass
|
376
|
-
if trigger
|
390
|
+
if trigger is 'click'
|
377
391
|
event.preventDefault()
|
378
392
|
false
|
379
393
|
else
|
380
394
|
true
|
381
395
|
|
382
|
-
if trigger
|
396
|
+
if trigger is 'click'
|
383
397
|
element.addEventListener 'click', onChange, false
|
384
|
-
else if trigger
|
398
|
+
else if trigger is 'checked'
|
385
399
|
element.addEventListener 'change', onChange, false
|
386
400
|
onChange()
|
387
401
|
else
|
@@ -397,14 +411,16 @@ PwnFx.registerEffect 'hide', PwnFxHide
|
|
397
411
|
# data-pwnfx-showif-replace: the name of a tag that will be used to replace
|
398
412
|
# the hidden element (default: don't replace the hidden element)
|
399
413
|
# data-pwnfx-showif-class: the CSS class that is added to hidden elements;
|
400
|
-
#
|
414
|
+
# by default, this is {PwnFx.hiddenClassName}, which gets its value from
|
415
|
+
# the data-pwnfx-hidden-class attribute on <body>
|
401
416
|
# data-pwnfx-showif-is: the value that the <input> has to match for this
|
402
417
|
# element to be shown
|
403
418
|
# data-pwnfx-showif-source: set to the identifier in data-pwnfx-showif
|
404
419
|
# on the <input> whose value determines if this element is shown or not
|
405
420
|
class PwnFxShowIf
|
406
421
|
constructor: (element, identifier, scopeId) ->
|
407
|
-
hiddenClass = element.getAttribute('data-pwnfx-showif-class') ||
|
422
|
+
hiddenClass = element.getAttribute('data-pwnfx-showif-class') ||
|
423
|
+
PwnFx.hiddenClassName
|
408
424
|
showValue = element.getAttribute 'data-pwnfx-showif-is'
|
409
425
|
sourceSelector = "[data-pwnfx-showif-source=\"#{identifier}\"]"
|
410
426
|
|
@@ -418,8 +434,8 @@ class PwnFxShowIf
|
|
418
434
|
isHidden = false
|
419
435
|
onChange = (event) ->
|
420
436
|
value = event.target.value
|
421
|
-
willHide = value
|
422
|
-
return if isHidden
|
437
|
+
willHide = value isnt showValue
|
438
|
+
return if isHidden is willHide
|
423
439
|
isHidden = willHide
|
424
440
|
|
425
441
|
if replacement
|
@@ -448,9 +464,9 @@ PwnFx.registerEffect 'showif', PwnFxShowIf
|
|
448
464
|
#
|
449
465
|
# Attributes:
|
450
466
|
# data-pwnfx-remove: an identifier connecting the elements to be removed
|
451
|
-
# data-pwnfx-remove-target: a space-separated list of identifiers, one of
|
452
|
-
# should match the value of data-pwnfx-remove; set on elements that
|
453
|
-
# be removed when the element is clicked
|
467
|
+
# data-pwnfx-remove-target: a space-separated list of identifiers, one of
|
468
|
+
# which should match the value of data-pwnfx-remove; set on elements that
|
469
|
+
# will be removed when the element is clicked
|
454
470
|
class PwnFxRemove
|
455
471
|
constructor: (element, identifier, scopeId) ->
|
456
472
|
targetSelector = "[data-pwnfx-remove-target~=\"#{identifier}\"]"
|
@@ -470,11 +486,11 @@ PwnFx.registerEffect 'remove', PwnFxRemove
|
|
470
486
|
window.PwnFx = PwnFx
|
471
487
|
|
472
488
|
# Wire up the entire DOM after the document is loaded.
|
473
|
-
if document.readyState
|
489
|
+
if document.readyState is 'loading'
|
474
490
|
loaded = false
|
475
491
|
document.addEventListener 'readystatechange', ->
|
476
492
|
return if loaded
|
477
|
-
if document.readyState
|
493
|
+
if document.readyState isnt 'loading'
|
478
494
|
PwnFx.wire(document)
|
479
495
|
loaded = true
|
480
496
|
else
|
data/pwnstyles_rails.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: pwnstyles_rails 0.2.
|
5
|
+
# stub: pwnstyles_rails 0.2.5 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "pwnstyles_rails"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.5"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Victor Costan"]
|
14
|
-
s.date = "2015-
|
14
|
+
s.date = "2015-10-19"
|
15
15
|
s.description = "Included CSS was designed for reuse across pwnb.us apps."
|
16
16
|
s.email = "victor@costan.us"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -71,7 +71,7 @@ Gem::Specification.new do |s|
|
|
71
71
|
]
|
72
72
|
s.homepage = "http://github.com/pwnall/pwnstyles_rails"
|
73
73
|
s.licenses = ["MIT"]
|
74
|
-
s.rubygems_version = "2.4.5"
|
74
|
+
s.rubygems_version = "2.4.5.1"
|
75
75
|
s.summary = "Rails 3 SCSS integration and non-trivial default style."
|
76
76
|
|
77
77
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pwnstyles_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass-rails
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.4.5
|
160
|
+
rubygems_version: 2.4.5.1
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: Rails 3 SCSS integration and non-trivial default style.
|