app/assets/javascripts/pwn-fx.js.coffee in pwnstyles_rails-0.2.2 vs app/assets/javascripts/pwn-fx.js.coffee in pwnstyles_rails-0.2.3
- old
+ new
@@ -141,20 +141,21 @@
# Moves an element using data-pwnfx-move.
#
# Attributes:
# data-pwnfx-move: an identifier connecting the move's target element
-# data-pwnfx-move-target: set to the same value as data-pwnfx-move on the
-# element that will receive the moved element as its last child
+# data-pwnfx-move-target: a space-separated list of identifiers, one of which
+# should match the value of data-pwnfx-move; set on the element that will
+# receive the moved element as its last child
# data-pwnfx-move-method: 'append' adds the moved as the element as the
# target's last child, 'replace' clears the target element, then adds the
# moved element as the target's only child
class PwnFxMove
constructor: (element, identifier, scopeId) ->
scope = PwnFx.resolveScope scopeId, element
method = element.getAttribute('data-pwnfx-move-method') || 'append'
- target = document.querySelector "[data-pwnfx-move-target=\"#{identifier}\"]"
+ target = document.querySelector "[data-pwnfx-move-target~=\"#{identifier}\"]"
switch method
when 'append'
target.appendChild element
when 'replace'
@@ -173,18 +174,19 @@
# data-pwnfx-render: identifier for the render operation
# data-pwnfx-render-where: insertAdjacentHTML position argument; can be
# beforebegin, afterbegin, beforeend, afterend; defaults to beforeend
# data-pwnfx-render-randomize: regexp pattern whose matches will be replaced
# with a random string; useful for generating unique IDs
-# data-pwnfx-render-target: set on the element(s) receiving the rendered HTML;
-# set to the identifier in data-pwnfx-render
+# data-pwnfx-render-target: a space-separated list of identifiers, one of
+# which should match the value of data-pwnfx-render; set on the element(s)
+# receiving the rendered HTML
# data-pwnfx-render-source: set to the identifier in data-pwnfx-render, on the
# <script> tag containing the source HTML
class PwnFxRender
constructor: (element, identifier, scopeId) ->
sourceSelector = "script[data-pwnfx-render-source=\"#{identifier}\"]"
- targetSelector = "[data-pwnfx-render-target=\"#{identifier}\"]"
+ targetSelector = "[data-pwnfx-render-target~=\"#{identifier}\"]"
insertionPoint = element.getAttribute('data-pwnfx-render-where') ||
'beforeend'
randomizedPatten = element.getAttribute('data-pwnfx-render-randomize')
if randomizedPatten
randomizeRegExp = new RegExp(randomizedPatten, 'g')
@@ -219,15 +221,16 @@
# data-pwnfx-delayed: identifier connecting the AJAX data receiver
# data-pwnfx-delayed-url: URL to perform an AJAX request to
# data-pwnfx-delayed-method: the HTTP method of AJAX request (default: POST)
# data-pwnfx-delayed-ms: the delay between the page load and the issuing of
# the AJAX request (default: 1000ms)
-# data-pwnfx-delayed-target: set to the value of data-pwnfx-delayed on the
-# element populated with the AJAX response
+# data-pwnfx-delayed-target: a space-separated list of identifiers, one of which
+# should match the value of data-pwnfx-delayed; set on the element
+# populated with the AJAX response
class PwnFxDelayed
constructor: (element, identifier, scopeId) ->
- targetSelector = "[data-pwnfx-delayed-target=\"#{identifier}\"]"
+ targetSelector = "[data-pwnfx-delayed-target~=\"#{identifier}\"]"
xhrUrl = element.getAttribute('data-pwnfx-delayed-url')
xhrMethod = element.getAttribute('data-pwnfx-delayed-method') || 'POST'
xhrForm = PwnFx.parentForm element
delay = parseInt(
element.getAttribute('data-pwnfx-delayed-ms') || '1000');
@@ -252,15 +255,16 @@
# data-pwnfx-refresh: identifier connecting the AJAX data receiver
# data-pwnfx-refresh-url: URL to perform an AJAX request to
# data-pwnfx-refresh-method: the HTTP method of AJAX request (default: POST)
# data-pwnfx-refresh-ms: delay between a change on the source element and
# AJAX refresh requests (default: 200ms)
-# data-pwnfx-refresh-target: set to the value of data-pwnfx-refresh on the
-# element populated with the AJAX response
+# data-pwnfx-refresh-target: a space-separated list of identifiers, one of which
+# should match the value of data-pwnfx-refresh; set on the element
+# populated with the AJAX response
class PwnFxRefresh
constructor: (element, identifier, scopeId) ->
- targetSelector = "[data-pwnfx-refresh-target=\"#{identifier}\"]"
+ targetSelector = "[data-pwnfx-refresh-target~=\"#{identifier}\"]"
xhrUrl = element.getAttribute('data-pwnfx-refresh-url')
xhrMethod = element.getAttribute('data-pwnfx-refresh-method') || 'POST'
xhrForm = PwnFx.parentForm element
refreshDelay = parseInt(
element.getAttribute('data-pwnfx-refresh-ms') || '200');
@@ -442,14 +446,15 @@
# Removes elements from the DOM when an element is clicked.
#
# Attributes:
# data-pwnfx-remove: an identifier connecting the elements to be removed
-# data-pwnfx-remove-target: set to the same value as data-pwnfx-remove on
-# elements that will be removed when the element is clicked
+# data-pwnfx-remove-target: a space-separated list of identifiers, one of which
+# should match the value of data-pwnfx-remove; set on elements that will
+# be removed when the element is clicked
class PwnFxRemove
constructor: (element, identifier, scopeId) ->
- targetSelector = "[data-pwnfx-remove-target=\"#{identifier}\"]"
+ targetSelector = "[data-pwnfx-remove-target~=\"#{identifier}\"]"
onClick = (event) ->
scope = PwnFx.resolveScope scopeId, element
for targetElement in PwnFx.queryScope(scope, targetSelector)
targetElement.parentNode.removeChild targetElement