unpoly-rails 0.57.0 → 0.60.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (186) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +393 -1
  3. data/Gemfile.lock +5 -2
  4. data/README.md +1 -1
  5. data/README_RAILS.md +1 -1
  6. data/Rakefile +10 -1
  7. data/design/es6.js +32 -0
  8. data/design/ie11.txt +9 -0
  9. data/design/measure_jquery/element_list.js +41 -0
  10. data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
  11. data/design/todo_jquery.txt +13 -0
  12. data/dist/unpoly-bootstrap3.js +8 -8
  13. data/dist/unpoly-bootstrap3.min.js +1 -1
  14. data/dist/unpoly.css +22 -20
  15. data/dist/unpoly.js +6990 -5336
  16. data/dist/unpoly.min.css +1 -1
  17. data/dist/unpoly.min.js +4 -4
  18. data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
  19. data/lib/assets/javascripts/unpoly.coffee +8 -6
  20. data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
  21. data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
  22. data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
  23. data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
  24. data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
  25. data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
  26. data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
  27. data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
  28. data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
  29. data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
  30. data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
  31. data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
  32. data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
  33. data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
  34. data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
  35. data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
  36. data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
  37. data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
  38. data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
  39. data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
  40. data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
  41. data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
  42. data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
  43. data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
  44. data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
  45. data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
  46. data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
  47. data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
  48. data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
  49. data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
  50. data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
  51. data/lib/assets/javascripts/unpoly/history.coffee +29 -28
  52. data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
  53. data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
  54. data/lib/assets/javascripts/unpoly/log.coffee +99 -19
  55. data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
  56. data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
  57. data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
  58. data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
  59. data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
  60. data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
  61. data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
  62. data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
  63. data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
  64. data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
  65. data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
  66. data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
  67. data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
  68. data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
  69. data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
  70. data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
  71. data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
  72. data/lib/unpoly/rails/version.rb +1 -1
  73. data/package.json +1 -2
  74. data/spec_app/Gemfile +2 -1
  75. data/spec_app/Gemfile.lock +38 -27
  76. data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
  77. data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
  78. data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
  79. data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
  80. data/spec_app/app/views/css_test/modal.erb +6 -6
  81. data/spec_app/app/views/css_test/popup.erb +44 -18
  82. data/spec_app/app/views/css_test/tooltip.erb +23 -4
  83. data/spec_app/app/views/error_test/trigger.erb +1 -1
  84. data/spec_app/app/views/form_test/basics/new.erb +1 -3
  85. data/spec_app/app/views/pages/start.erb +9 -2
  86. data/spec_app/app/views/reveal_test/long1.erb +1 -1
  87. data/spec_app/app/views/reveal_test/long2.erb +1 -1
  88. data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
  89. data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
  90. data/spec_app/app/views/scroll_test/long1.erb +30 -0
  91. data/spec_app/config/routes.rb +1 -0
  92. data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
  93. data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
  94. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
  95. data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
  96. data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
  97. data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
  98. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
  99. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
  100. data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
  101. data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
  102. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
  103. data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
  104. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
  105. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
  106. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
  107. data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
  108. data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
  109. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
  110. data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
  111. data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
  112. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
  113. data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
  114. data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
  115. data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
  116. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
  117. data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
  118. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
  119. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
  120. data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
  121. data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
  122. data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
  123. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
  124. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
  125. data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
  126. data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
  127. data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
  128. data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
  129. data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
  130. data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
  131. data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
  132. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
  133. data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
  134. data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
  135. data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
  136. data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
  137. data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
  138. data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
  139. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
  140. data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
  141. data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
  142. data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
  143. data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
  144. data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
  145. data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
  146. data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
  147. data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
  148. data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
  149. data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
  150. data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
  151. data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
  152. data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
  153. data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
  154. data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
  155. data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
  156. data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
  157. data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
  158. data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
  159. data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
  160. data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
  161. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
  162. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
  163. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
  164. data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
  165. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
  166. data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
  167. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
  168. data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
  169. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
  170. data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
  171. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
  172. data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
  173. data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
  174. metadata +57 -19
  175. data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
  176. data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
  177. data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
  178. data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
  179. data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
  180. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
  181. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
  182. data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
  183. data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
  184. data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
  185. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
  186. data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -38,13 +38,14 @@ Other Unpoly modules contain even more tricks to outsmart network latency:
38
38
  - [Instantaneous feedback for links that are currently loading](/a.up-active)
39
39
  - [Follow links on `mousedown` instead of `click`](/a-up-instant)
40
40
 
41
- @class up.proxy
41
+ @module up.proxy
42
42
  ###
43
- up.proxy = (($) ->
43
+ up.proxy = do ->
44
44
 
45
45
  u = up.util
46
+ e = up.element
46
47
 
47
- $waitingLink = undefined
48
+ waitingLink = undefined
48
49
  preloadDelayTimer = undefined
49
50
  slowDelayTimer = undefined
50
51
  pendingCount = undefined
@@ -85,7 +86,7 @@ up.proxy = (($) ->
85
86
  cache after an unsafe request.
86
87
  @stable
87
88
  ###
88
- config = u.config
89
+ config = new up.Config
89
90
  slowDelay: 300
90
91
  preloadDelay: 75
91
92
  cacheSize: 70
@@ -118,14 +119,14 @@ up.proxy = (($) ->
118
119
  if request.target != 'html'
119
120
  # Since <html> is the root tag, a request for the `html` selector
120
121
  # will contain all other selectors.
121
- requestForHtml = request.copy(target: 'html')
122
+ requestForHtml = request.variant(target: 'html')
122
123
  candidates.push(requestForHtml)
123
124
 
124
125
  # Although <body> is not the root tag, we consider it the selector developers
125
126
  # will use when they want to replace the entire page. Hence we consider it
126
127
  # a suitable match for all other selectors, including `html`.
127
128
  if request.target != 'body'
128
- requestForBody = request.copy(target: 'body')
129
+ requestForBody = request.variant(target: 'body')
129
130
  candidates.push(requestForBody)
130
131
 
131
132
  for candidate in candidates
@@ -141,7 +142,7 @@ up.proxy = (($) ->
141
142
  slowDelayTimer = null
142
143
 
143
144
  reset = ->
144
- $waitingLink = null
145
+ waitingLink = null
145
146
  cancelPreloadDelay()
146
147
  cancelSlowDelay()
147
148
  pendingCount = 0
@@ -158,10 +159,10 @@ up.proxy = (($) ->
158
159
  \#\#\# Example
159
160
 
160
161
  up.request('/search', params: { query: 'sunshine' }).then(function(response) {
161
- console.log('The response text is %o', response.text);
162
+ console.log('The response text is %o', response.text)
162
163
  }).catch(function() {
163
- console.error('The request failed');
164
- });
164
+ console.error('The request failed')
165
+ })
165
166
 
166
167
  \#\#\# Caching
167
168
 
@@ -193,7 +194,7 @@ up.proxy = (($) ->
193
194
  @param {Object} [options.headers={}]
194
195
  An object of additional HTTP headers.
195
196
  @param {Object|FormData|string|Array} [options.params={}]
196
- [Parameters](/up.params) that should be sent as the request's payload.
197
+ [Parameters](/up.Params) that should be sent as the request's payload.
197
198
  @param {string} [options.timeout]
198
199
  A timeout in milliseconds.
199
200
 
@@ -239,7 +240,7 @@ up.proxy = (($) ->
239
240
  promise = loadOrQueue(request)
240
241
  set(request, promise)
241
242
  # Uncache failed requests
242
- promise.catch (e) ->
243
+ promise.catch ->
243
244
  remove(request)
244
245
 
245
246
  if !request.preload
@@ -266,10 +267,10 @@ up.proxy = (($) ->
266
267
  \#\#\# Example
267
268
 
268
269
  up.request('/search', params: { query: 'sunshine' }).then(function(text) {
269
- console.log('The response text is %o', text);
270
+ console.log('The response text is %o', text)
270
271
  }).catch(function() {
271
- console.error('The request failed');
272
- });
272
+ console.error('The request failed')
273
+ })
273
274
 
274
275
  @function up.ajax
275
276
  @param {string} [url]
@@ -288,7 +289,9 @@ up.proxy = (($) ->
288
289
  An object of additional header key/value pairs to send along
289
290
  with the request.
290
291
  @param {Object|FormData|string|Array} [options.params]
291
- [Parameters](/up.params) that should be sent as the request's payload.
292
+ [Parameters](/up.Params) that should be sent as the request's payload.
293
+
294
+ On IE 11 and Edge, `FormData` payloads require a [polyfill for `FormData#entries()`](https://github.com/jimmywarting/FormData).
292
295
  @param {string} [request.timeout]
293
296
  A timeout in milliseconds for the request.
294
297
 
@@ -300,7 +303,7 @@ up.proxy = (($) ->
300
303
  Use [`up.request()`](/up.request) instead.
301
304
  ###
302
305
  ajax = (args...) ->
303
- up.warn('up.ajax() has been deprecated. Use up.request() instead.')
306
+ up.legacy.warn('up.ajax() has been deprecated. Use up.request() instead.')
304
307
  new Promise (resolve, reject) ->
305
308
  pickResponseText = (response) -> resolve(response.text)
306
309
  makeRequest(args...).then(pickResponseText, reject)
@@ -336,9 +339,9 @@ up.proxy = (($) ->
336
339
  # we wrap the mission in a function for scheduling below.
337
340
  emission = ->
338
341
  if isBusy() # a fast response might have beaten the delay
339
- up.emit('up:proxy:slow', message: 'Proxy is slow to respond')
342
+ up.emit('up:proxy:slow', log: 'Proxy is slow to respond')
340
343
  slowEventEmitted = true
341
- slowDelayTimer = u.setTimer(config.slowDelay, emission)
344
+ slowDelayTimer = u.timer(config.slowDelay, emission)
342
345
 
343
346
 
344
347
  ###**
@@ -368,19 +371,17 @@ up.proxy = (($) ->
368
371
 
369
372
  Here is the JavaScript to make it alive:
370
373
 
371
- up.compiler('.spinner', function($element) {
372
-
373
- show = function() { $element.show() };
374
- hide = function() { $element.hide() };
374
+ up.compiler('.spinner', function(element) {
375
+ show = () => { up.element.show(element) }
376
+ hide = () => { up.element.hide(element) }
375
377
 
376
- hide();
378
+ hide()
377
379
 
378
380
  return [
379
381
  up.on('up:proxy:slow', show),
380
382
  up.on('up:proxy:recover', hide)
381
- ];
382
-
383
- });
383
+ ]
384
+ })
384
385
 
385
386
  The `up:proxy:slow` event will be emitted after a delay of 300 ms
386
387
  to prevent the spinner from flickering on and off.
@@ -399,7 +400,7 @@ up.proxy = (($) ->
399
400
  if isIdle()
400
401
  cancelSlowDelay()
401
402
  if slowEventEmitted
402
- up.emit('up:proxy:recover', message: 'Proxy has recovered from slow response')
403
+ up.emit('up:proxy:recover', log: 'Proxy has recovered from slow response')
403
404
  slowEventEmitted = false
404
405
 
405
406
  ###**
@@ -429,9 +430,9 @@ up.proxy = (($) ->
429
430
  load = (request) ->
430
431
  eventProps =
431
432
  request: request
432
- message: ['Loading %s %s', request.method, request.url]
433
+ log: ['Loading %s %s', request.method, request.url]
433
434
 
434
- if up.bus.nobodyPrevents('up:proxy:load', eventProps)
435
+ if up.event.nobodyPrevents('up:proxy:load', eventProps)
435
436
  responsePromise = request.send()
436
437
  u.always responsePromise, responseReceived
437
438
  u.always responsePromise, pokeQueue
@@ -454,7 +455,7 @@ up.proxy = (($) ->
454
455
  registerAliasForRedirect = (response) ->
455
456
  request = response.request
456
457
  if response.url && request.url != response.url
457
- newRequest = request.copy(
458
+ newRequest = request.variant(
458
459
  method: response.method
459
460
  url: response.url
460
461
  )
@@ -463,13 +464,13 @@ up.proxy = (($) ->
463
464
  responseReceived = (response) ->
464
465
  if response.isFatalError()
465
466
  up.emit 'up:proxy:fatal',
466
- message: 'Fatal error during request'
467
+ log: 'Fatal error during request'
467
468
  request: response.request
468
469
  response: response
469
470
  else
470
471
  registerAliasForRedirect(response) unless response.isError()
471
472
  up.emit 'up:proxy:loaded',
472
- message: ['Server responded with HTTP %d (%d bytes)', response.status, response.text.length]
473
+ log: ['Server responded with HTTP %d (%d bytes)', response.status, response.text.length]
473
474
  request: response.request
474
475
  response: response
475
476
 
@@ -557,24 +558,24 @@ up.proxy = (($) ->
557
558
  ###
558
559
  clear = cache.clear
559
560
 
560
- up.bus.deprecateRenamedEvent('up:proxy:received', 'up:proxy:loaded')
561
+ # up.legacy.renamedEvent('up:proxy:received', 'up:proxy:loaded')
561
562
 
562
- preloadAfterDelay = ($link) ->
563
- delay = parseInt(u.presentAttr($link, 'up-delay')) || config.preloadDelay
564
- unless $link.is($waitingLink)
565
- $waitingLink = $link
563
+ preloadAfterDelay = (link) ->
564
+ delay = e.numberAttr(link, 'up-delay') || config.preloadDelay
565
+ unless link == waitingLink
566
+ waitingLink = link
566
567
  cancelPreloadDelay()
567
568
  curriedPreload = ->
568
- u.muteRejection preload($link)
569
- $waitingLink = null
569
+ u.muteRejection preload(link)
570
+ waitingLink = null
570
571
  startPreloadDelay(curriedPreload, delay)
571
572
 
572
573
  startPreloadDelay = (block, delay) ->
573
574
  preloadDelayTimer = setTimeout(block, delay)
574
575
 
575
- stopPreload = ($link) ->
576
- if $link.is($waitingLink)
577
- $waitingLink = undefined
576
+ stopPreload = (link) ->
577
+ if link == waitingLink
578
+ waitingLink = undefined
578
579
  cancelPreloadDelay()
579
580
 
580
581
  ###**
@@ -584,22 +585,22 @@ up.proxy = (($) ->
584
585
  making the interaction feel instant.
585
586
 
586
587
  @function up.proxy.preload
587
- @param {string|Element|jQuery}
588
+ @param {string|Element|jQuery} linkOrSelector
588
589
  The element whose destination should be preloaded.
589
- @param {object} options
590
+ @param {Object} options
590
591
  Options that will be passed to the function making the HTTP requests.
591
592
  @return
592
593
  A promise that will be fulfilled when the request was loaded and cached
593
594
  @experimental
594
595
  ###
595
596
  preload = (linkOrSelector, options) ->
596
- $link = $(linkOrSelector)
597
+ link = e.get(linkOrSelector)
597
598
 
598
- if up.link.isSafe($link)
599
- preloadEventAttrs = { message: ['Preloading link %o', $link.get(0)], $element: $link, $link: $link }
600
- up.bus.whenEmitted('up:link:preload', preloadEventAttrs).then ->
601
- variant = up.link.followVariantForLink($link)
602
- variant.preloadLink($link, options)
599
+ if up.link.isSafe(link)
600
+ preloadEventAttrs = { log: ['Preloading link %o', link], target: link }
601
+ up.event.whenEmitted('up:link:preload', preloadEventAttrs).then ->
602
+ variant = up.link.followVariantForLink(link)
603
+ variant.preloadLink(link, options)
603
604
  else
604
605
  Promise.reject(new Error("Won't preload unsafe link"))
605
606
 
@@ -607,7 +608,7 @@ up.proxy = (($) ->
607
608
  This event is [emitted](/up.emit) before a link is [preloaded](/up.preload).
608
609
 
609
610
  @event up:link:preload
610
- @param {jQuery} event.$link
611
+ @param {Element} event.target
611
612
  The link element that will be preloaded.
612
613
  @param event.preventDefault()
613
614
  Event listeners may call this method to prevent the link from being preloaded.
@@ -625,9 +626,9 @@ up.proxy = (($) ->
625
626
  ###
626
627
  wrapMethod = (method, params) ->
627
628
  if u.contains(config.wrapMethods, method)
628
- params = up.params.add(params, up.protocol.config.methodParam, method)
629
+ params.add(up.protocol.config.methodParam, method)
629
630
  method = 'POST'
630
- [method, params]
631
+ method
631
632
 
632
633
  ###**
633
634
  Links with an `up-preload` attribute will silently fetch their target
@@ -644,15 +645,13 @@ up.proxy = (($) ->
644
645
  but will also make the interaction feel less instant.
645
646
  @stable
646
647
  ###
647
- up.compiler 'a[up-preload], [up-href][up-preload]', ($link) ->
648
- if up.link.isSafe($link)
649
- $link.on 'mouseenter touchstart', (event) ->
650
- # Don't do anything if we are hovering over the child of a link.
651
- # The actual link will receive the event and bubble in a second.
652
- if up.link.shouldProcessEvent(event, $link)
653
- preloadAfterDelay($link)
654
- $link.on 'mouseleave', ->
655
- stopPreload($link)
648
+ up.compiler 'a[up-preload], [up-href][up-preload]', (link) ->
649
+ if up.link.isSafe(link)
650
+ link.addEventListener 'mouseenter', (event) ->
651
+ if up.link.shouldProcessEvent(event, link)
652
+ preloadAfterDelay(link)
653
+ link.addEventListener 'mouseleave', ->
654
+ stopPreload(link)
656
655
 
657
656
  up.on 'up:framework:reset', reset
658
657
 
@@ -668,8 +667,6 @@ up.proxy = (($) ->
668
667
  isSafeMethod: isSafeMethod
669
668
  wrapMethod: wrapMethod
670
669
  config: config
671
-
672
- )(jQuery)
673
670
 
674
671
  up.ajax = up.proxy.ajax
675
672
  up.request = up.proxy.request
@@ -5,9 +5,9 @@ Passive updates
5
5
  This work-in-progress package will contain functionality to
6
6
  passively receive updates from the server.
7
7
 
8
- @class up.radio
8
+ @module up.radio
9
9
  ###
10
- up.radio = (($) ->
10
+ up.radio = do ->
11
11
 
12
12
  u = up.util
13
13
 
@@ -27,7 +27,7 @@ up.radio = (($) ->
27
27
  By default this is not set and the original replacement's transition is used.
28
28
  @stable
29
29
  ###
30
- config = u.config
30
+ config = new up.Config
31
31
  hungry: ['[up-hungry]']
32
32
  hungryTransition: null
33
33
 
@@ -58,5 +58,3 @@ up.radio = (($) ->
58
58
 
59
59
  config: config
60
60
  hungrySelector: hungrySelector
61
-
62
- )(jQuery)
@@ -3,23 +3,22 @@ Play nice with Rails UJS
3
3
  ========================
4
4
  ###
5
5
 
6
- up.rails = (($) ->
6
+ up.rails = do ->
7
7
 
8
8
  u = up.util
9
+ e = up.element
9
10
 
10
11
  isRails = ->
11
- !!$.rails
12
+ !!(window.Rails || (window.jQuery?.rails))
12
13
 
13
14
  u.each ['method', 'confirm'], (feature) ->
14
15
 
15
16
  dataAttribute = "data-#{feature}"
16
17
  upAttribute = "up-#{feature}"
17
18
 
18
- up.macro "[#{dataAttribute}]", ($element) ->
19
- if isRails() && up.link.isFollowable($element)
19
+ up.macro "[#{dataAttribute}]", (element) ->
20
+ if isRails() && up.link.isFollowable(element)
20
21
  replacement = {}
21
- replacement[upAttribute] = $element.attr(dataAttribute)
22
- u.setMissingAttrs($element, replacement)
23
- $element.removeAttr(dataAttribute)
24
-
25
- )(jQuery)
22
+ replacement[upAttribute] = element.getAttribute(dataAttribute)
23
+ e.setMissingAttrs(element, replacement)
24
+ element.removeAttribute(dataAttribute)
@@ -7,21 +7,22 @@ in order to integrate libraries or implement custom behavior.
7
7
 
8
8
  Unpoly lets you organize your JavaScript snippets using [compilers](/up.compiler).
9
9
 
10
- For instance, to activate the [Masonry](http://masonry.desandro.com/) jQuery plugin for every element
10
+ For instance, to activate the [Masonry](http://masonry.desandro.com/) library for every element
11
11
  with a `grid` class, use this compiler:
12
12
 
13
- up.compiler('.grid', function($element) {
14
- $element.masonry();
15
- });
13
+ up.compiler('.grid', function(element) {
14
+ new Masonry(element, { itemSelector: '.grid--item' })
15
+ })
16
16
 
17
17
  The compiler function will be called on matching elements when the page loads
18
18
  or when a matching fragment is [inserted via AJAX](/up.link) later.
19
19
 
20
- @class up.syntax
20
+ @module up.syntax
21
21
  ###
22
- up.syntax = (($) ->
22
+ up.syntax = do ->
23
23
 
24
24
  u = up.util
25
+ e = up.element
25
26
 
26
27
  SYSTEM_MACRO_PRIORITIES = {
27
28
  '[up-back]': -100 # sets [up-href] to previous URL
@@ -32,40 +33,39 @@ up.syntax = (($) ->
32
33
  '[data-confirm]': -400, # converts [data-conform] to [up-confirm] only if link has followable [up-*] attributes
33
34
  }
34
35
 
35
- isBooting = true
36
36
  compilers = []
37
37
  macros = []
38
38
 
39
39
  ###**
40
- Registers a function to be called whenever an element with
40
+ Registers a function to be called when an element with
41
41
  the given selector is inserted into the DOM.
42
42
 
43
43
  Use compilers to activate your custom Javascript behavior on matching
44
44
  elements.
45
45
 
46
- You should migrate your [jQuery ready callbacks](https://api.jquery.com/ready/)
47
- to compilers.
46
+ You should migrate your [`DOMContentLoaded`](https://api.jquery.com/ready/)
47
+ callbacks to compilers. This will make sure they run both at page load and
48
+ when [a new fragment is inserted later](/a-up-target).
49
+ It will also organize your JavaScript snippets by selector of affected elements.
48
50
 
49
51
 
50
52
  \#\#\# Example
51
53
 
52
- Let's say that any element with the `action` class should alert a message when clicked.
53
- We can implement this behavior as a compiler function that is called on all elements matching
54
- the `.action` selector:
54
+ This jQuery compiler will insert the current time into a
55
+ `<div class='current-time'></div>`:
55
56
 
56
- up.compiler('.action', function($element) {
57
- $element.on('click', function() {
58
- alert('Action was clicked!');
59
- });
60
- });
57
+ up.compiler('.current-time', function(element) {
58
+ var now = new Date()
59
+ element.textContent = now.toString()
60
+ })
61
61
 
62
62
  The compiler function will be called once for each matching element when
63
63
  the page loads, or when a matching fragment is [inserted](/up.replace) later.
64
64
 
65
65
 
66
- \#\#\# Integrating jQuery plugins
66
+ \#\#\# Integrating JavaScript libraries
67
67
 
68
- `up.compiler()` is a great way to integrate jQuery plugins.
68
+ `up.compiler()` is a great way to integrate JavaScript libraries.
69
69
  Let's say your JavaScript plugin wants you to call `lightboxify()`
70
70
  on links that should open a lightbox. You decide to
71
71
  do this for all links with an `lightbox` class:
@@ -75,24 +75,9 @@ up.syntax = (($) ->
75
75
 
76
76
  This JavaScript will do exactly that:
77
77
 
78
- up.compiler('a.lightbox', function($element) {
79
- $element.lightboxify();
80
- });
81
-
82
-
83
- \#\#\# Custom elements
84
-
85
- You can use `up.compiler()` to implement custom elements like this:
86
-
87
- <clock></clock>
88
-
89
- Here is the JavaScript that inserts the current time into to these elements:
90
-
91
- up.compiler('clock', function($element) {
92
- var now = new Date();
93
- $element.text(now.toString()));
94
- });
95
-
78
+ up.compiler('a.lightbox', function(element) {
79
+ lightboxify(element)
80
+ })
96
81
 
97
82
  \#\#\# Cleaning up after yourself
98
83
 
@@ -105,24 +90,24 @@ up.syntax = (($) ->
105
90
  side effects, like a [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval)
106
91
  or [event handlers bound to the document root](/up.on).
107
92
 
108
- Here is a version of `<clock>` that updates
93
+ Here is a version of `.current-time` that updates
109
94
  the time every second, and cleans up once it's done. Note how it returns
110
95
  a function that calls `clearInterval`:
111
96
 
112
- up.compiler('clock', function($element) {
97
+ up.compiler('.current-time', function(element) {
113
98
 
114
99
  function update() {
115
- var now = new Date();
116
- $element.text(now.toString()));
100
+ var now = new Date()
101
+ element.textContent = now.toString()
117
102
  }
118
103
 
119
- setInterval(update, 1000);
104
+ setInterval(update, 1000)
120
105
 
121
106
  return function() {
122
- clearInterval(update);
107
+ clearInterval(update)
123
108
  };
124
109
 
125
- });
110
+ })
126
111
 
127
112
  If we didn't clean up after ourselves, we would have many ticking intervals
128
113
  operating on detached DOM elements after we have created and removed a couple
@@ -143,43 +128,18 @@ up.syntax = (($) ->
143
128
 
144
129
  The JSON will parsed and handed to your compiler as a second argument:
145
130
 
146
- up.compiler('.google-map', function($element, pins) {
147
-
148
- var map = new google.maps.Map($element);
131
+ up.compiler('.google-map', function(element, pins) {
132
+ var map = new google.maps.Map(element)
149
133
 
150
134
  pins.forEach(function(pin) {
151
- var position = new google.maps.LatLng(pin.lat, pin.lng);
135
+ var position = new google.maps.LatLng(pin.lat, pin.lng)
152
136
  new google.maps.Marker({
153
137
  position: position,
154
138
  map: map,
155
139
  title: pin.title
156
- });
157
- });
158
-
159
- });
160
-
161
-
162
- \#\#\# Migrating jQuery event handlers to `up.compiler()`
163
-
164
- Within the compiler, Unpoly will bind `this` to the
165
- native DOM element to help you migrate your existing jQuery code to
166
- this new syntax.
167
-
168
- So if you had this before:
169
-
170
- $(function() {
171
- $('.action').on('click', function() {
172
- $(this).something();
173
- });
174
- });
175
-
176
- ... you can reuse the callback function like this:
177
-
178
- up.compiler('.action', function($element) {
179
- $element.on('click', function() {
180
- $(this).something();
181
- });
182
- });
140
+ })
141
+ })
142
+ })
183
143
 
184
144
 
185
145
  @function up.compiler
@@ -198,13 +158,14 @@ up.syntax = (($) ->
198
158
  [page updates](/a-up-target).
199
159
 
200
160
  This has the same effect as setting an `up-keep` attribute on the element.
201
- @param {Function($element, data)} compiler
161
+ @param {Function(element, data)} compiler
202
162
  The function to call when a matching element is inserted.
203
- The function takes the new element as the first argument (as a jQuery object).
163
+
164
+ The function takes the new element as the first argument.
204
165
  If the element has an [`up-data`](/up-data) attribute, its value is parsed as JSON
205
166
  and passed as a second argument.
206
167
 
207
- The function may return a destructor function that destroys the compiled
168
+ The function may return a destructor function that cleans the compiled
208
169
  object before it is removed from the DOM. The destructor is supposed to
209
170
  [clear global state](/up.compiler#cleaning-up-after-yourself)
210
171
  such as timeouts and event handlers bound to the document.
@@ -213,13 +174,48 @@ up.syntax = (($) ->
213
174
  @stable
214
175
  ###
215
176
  registerCompiler = (args...) ->
216
- compiler = buildCompiler(args...)
217
- insertCompiler(compilers, compiler)
177
+ compiler = buildCompiler(args)
178
+ return insertCompiler(compilers, compiler)
179
+
180
+ ###**
181
+ Registers a function to be called when an element with
182
+ the given selector is inserted into the DOM. The function is called
183
+ with each matching element as a
184
+ [jQuery object](https://learn.jquery.com/using-jquery-core/jquery-object/).
185
+
186
+ If you're not using jQuery, use `up.compiler()` instead, which calls
187
+ the compiler function with a native element.
188
+
189
+ \#\#\# Example
190
+
191
+ This jQuery compiler will insert the current time into a
192
+ `<div class='current-time'></div>`:
193
+
194
+ up.$compiler('.current-time', function($element) {
195
+ var now = new Date()
196
+ $element.text(now.toString())
197
+ })
198
+
199
+ @function up.$compiler
200
+ @param {string} selector
201
+ The selector to match.
202
+ @param {Object} [options]
203
+ See [`options` argument for `up.compiler()`](/up.compiler#parameters).
204
+ @param {Function($element, data)} compiler
205
+ The function to call when a matching element is inserted.
206
+
207
+ See [`compiler` argument for `up.compiler()`](/up.compiler#parameters).
208
+ @stable
209
+ ###
210
+ registerJQueryCompiler = (args...) ->
211
+ compiler = registerCompiler(args...)
212
+ compiler.jQuery = true
213
+ compiler
218
214
 
219
215
  ###**
220
216
  Registers a [compiler](/up.compiler) that is run before all other compilers.
221
217
 
222
- You can use `up.macro()` to register a compiler that sets other UJS attributes.
218
+ Use `up.macro()` to register a compiler that sets multiply Unpoly attributes.
223
219
 
224
220
  \#\#\# Example
225
221
 
@@ -229,21 +225,21 @@ up.syntax = (($) ->
229
225
  <a href="/page2" up-target=".content" up-transition="cross-fade" up-duration="300">Page 2</a>
230
226
  <a href="/page3" up-target=".content" up-transition="cross-fade" up-duration="300">Page 3</a>
231
227
 
232
- We would much rather define a new `content-link` attribute that let's us
228
+ We would much rather define a new `[content-link]` attribute that let's us
233
229
  write the same links like this:
234
230
 
235
231
  <a href="/page1" content-link>Page 1</a>
236
232
  <a href="/page2" content-link>Page 2</a>
237
233
  <a href="/page3" content-link>Page 3</a>
238
234
 
239
- We can define the `content-link` attribute by registering a macro that
240
- sets the `up-target`, `up-transition` and `up-duration` attributes for us:
235
+ We can define the `[content-link]` attribute by registering a macro that
236
+ sets the `[up-target]`, `[up-transition]` and `[up-duration]` attributes for us:
241
237
 
242
- up.macro('[content-link]', function($link) {
243
- $link.attr('up-target', '.content');
244
- $link.attr('up-transition', 'cross-fade');
245
- $link.attr('up-duration', '300');
246
- });
238
+ up.macro('[content-link]', function(link) {
239
+ link.setAttribute('up-target', '.content')
240
+ link.setAttribute('up-transition', 'cross-fade')
241
+ link.setAttribute('up-duration', '300')
242
+ })
247
243
 
248
244
  Examples for built-in macros are [`a[up-dash]`](/a-up-dash) and [`[up-expand]`](/up-expand).
249
245
 
@@ -252,32 +248,73 @@ up.syntax = (($) ->
252
248
  The selector to match.
253
249
  @param {Object} options
254
250
  See options for [`up.compiler()`](/up.compiler).
255
- @param {Function($element, data)} macro
251
+ @param {Function(element, data)} macro
256
252
  The function to call when a matching element is inserted.
257
- See [`up.compiler()`](/up.compiler) for details.
253
+
254
+ See [`up.compiler()`](/up.compiler#parameters) for details.
258
255
  @stable
259
256
  ###
260
257
  registerMacro = (args...) ->
261
- macro = buildCompiler(args...)
262
- if isBooting
258
+ macro = buildCompiler(args)
259
+ if up.framework.isBooting()
263
260
  macro.priority = detectSystemMacroPriority(macro.selector) ||
264
261
  up.fail('Unregistered priority for system macro %o', macro.selector)
265
- insertCompiler(macros, macro)
262
+ return insertCompiler(macros, macro)
263
+
264
+ ###**
265
+ Registers a [compiler](/up.compiler) that is run before all other compilers.
266
+ The compiler function is called with each matching element as a
267
+ [jQuery object](https://learn.jquery.com/using-jquery-core/jquery-object/).
268
+
269
+ If you're not using jQuery, use `up.macro()` instead, which calls
270
+ the macro function with a native element.
271
+
272
+ \#\#\# Example
273
+
274
+ up.$macro('[content-link]', function($link) {
275
+ $link.attr(
276
+ 'up-target': '.content',
277
+ 'up-transition': 'cross-fade',
278
+ 'up-duration':'300'
279
+ )
280
+ })
281
+
282
+ @function up.$macro
283
+ @param {string} selector
284
+ The selector to match.
285
+ @param {Object} options
286
+ See [`options` argument for `up.compiler()`](/up.compiler#parameters).
287
+ @param {Function(element, data)} macro
288
+ The function to call when a matching element is inserted.
289
+
290
+ See [`compiler` argument for `up.compiler()`](/up.compiler#parameters).
291
+ @stable
292
+ ###
293
+ registerJQueryMacro = (args...) ->
294
+ macro = registerMacro(args...)
295
+ macro.jQuery = true
296
+ macro
266
297
 
267
298
  detectSystemMacroPriority = (macroSelector) ->
268
299
  for substr, priority of SYSTEM_MACRO_PRIORITIES
269
300
  if macroSelector.indexOf(substr) >= 0
270
301
  return priority
271
302
 
272
- buildCompiler = (selector, args...) ->
303
+ parseCompilerArgs = (args) ->
304
+ selector = args.shift()
273
305
  callback = args.pop()
274
306
  options = u.extractOptions(args)
307
+ return [selector, options, callback]
308
+
309
+ buildCompiler = (args) ->
310
+ [selector, options, callback] = parseCompilerArgs(args)
275
311
  options = u.options(options,
276
312
  selector: selector,
277
- isSystem: isBooting,
313
+ isDefault: up.framework.isBooting(),
278
314
  priority: 0,
279
315
  batch: false
280
- keep: false
316
+ keep: false,
317
+ jQuery: false
281
318
  )
282
319
  return u.assign(callback, options)
283
320
 
@@ -286,6 +323,7 @@ up.syntax = (($) ->
286
323
  while (existingCompiler = queue[index]) && (existingCompiler.priority >= newCompiler.priority)
287
324
  index += 1
288
325
  queue.splice(index, 0, newCompiler)
326
+ return newCompiler
289
327
 
290
328
  ###**
291
329
  Applies all compilers on the given element and its descendants.
@@ -296,33 +334,44 @@ up.syntax = (($) ->
296
334
  A list of elements whose subtrees should not be compiled.
297
335
  @internal
298
336
  ###
299
- compile = ($fragment, options) ->
337
+ compile = (fragment, options) ->
300
338
  orderedCompilers = macros.concat(compilers)
301
- compileRun = new up.CompilePass($fragment, orderedCompilers, options)
339
+ compileRun = new up.CompilePass(fragment, orderedCompilers, options)
302
340
  compileRun.compile()
303
341
 
304
342
  ###**
305
- @function up.syntax.destructor
343
+ Registers a function to be called when the given element
344
+ is [destroyed](/up.destroy).
345
+
346
+ The preferred way to register a destructor function is to `return`
347
+ it from a [compiler function](/up.compiler).
348
+
349
+ @function up.destructor
350
+ @param {Element} element
351
+ @param {Function|Array<Function>} destructor
352
+ One or more destructor functions
306
353
  @internal
307
354
  ###
308
355
  registerDestructor = (element, destructor) ->
309
- element = u.element(element)
310
356
  unless destructors = element.upDestructors
311
357
  destructors = []
312
358
  element.upDestructors = destructors
313
359
  element.classList.add('up-can-clean')
314
- destructors.push(destructor)
360
+ if u.isArray(destructor)
361
+ destructors.push(destructor...)
362
+ else
363
+ destructors.push(destructor)
315
364
 
316
365
  ###**
317
- Runs any destroyers on the given fragment and its descendants.
366
+ Runs any destructor on the given fragment and its descendants.
318
367
  Unlike [`up.destroy()`](/up.destroy), this doesn't emit any events
319
368
  and does not remove the element from the DOM.
320
369
 
321
370
  @function up.syntax.clean
322
371
  @internal
323
372
  ###
324
- clean = ($fragment) ->
325
- cleanables = u.selectInSubtree($fragment, '.up-can-clean')
373
+ clean = (fragment) ->
374
+ cleanables = e.subtree(fragment, '.up-can-clean')
326
375
  u.each cleanables, (cleanable) ->
327
376
  if destructors = cleanable.upDestructors
328
377
  destructor() for destructor in destructors
@@ -369,28 +418,25 @@ up.syntax = (($) ->
369
418
 
370
419
  The JSON will parsed and handed to your compiler as a second argument:
371
420
 
372
- up.compiler('.google-map', function($element, pins) {
373
-
374
- var map = new google.maps.Map($element);
375
-
421
+ up.compiler('.google-map', function(element, pins) {
422
+ var map = new google.maps.Map(element)
376
423
  pins.forEach(function(pin) {
377
- var position = new google.maps.LatLng(pin.lat, pin.lng);
424
+ var position = new google.maps.LatLng(pin.lat, pin.lng)
378
425
  new google.maps.Marker({
379
426
  position: position,
380
427
  map: map,
381
428
  title: pin.title
382
- });
383
- });
384
-
385
- });
429
+ })
430
+ })
431
+ })
386
432
 
387
433
  Similarly, when an event is triggered on an element annotated with
388
434
  [`up-data`], the parsed object will be passed to any matching
389
435
  [`up.on()`](/up.on) handlers.
390
436
 
391
- up.on('click', '.google-map', function(event, $element, pins) {
392
- console.log("There are %d pins on the clicked map", pins.length);
393
- });
437
+ up.on('click', '.google-map', function(event, element, pins) {
438
+ console.log("There are %d pins on the clicked map", pins.length)
439
+ })
394
440
 
395
441
  @selector [up-data]
396
442
  @param {JSON} up-data
@@ -398,8 +444,8 @@ up.syntax = (($) ->
398
444
  @stable
399
445
  ###
400
446
  readData = (elementOrSelector) ->
401
- if element = u.element(elementOrSelector)
402
- u.jsonAttr(element, 'up-data') || {}
447
+ element = e.get(elementOrSelector)
448
+ e.jsonAttr(element, 'up-data') || {}
403
449
 
404
450
  ###**
405
451
  Resets the list of registered compiler directives to the
@@ -408,22 +454,24 @@ up.syntax = (($) ->
408
454
  @internal
409
455
  ###
410
456
  reset = ->
411
- compilers = u.select(compilers, 'isSystem')
412
- macros = u.select(macros, 'isSystem')
457
+ compilers = u.filter(compilers, 'isDefault')
458
+ macros = u.filter(macros, 'isDefault')
413
459
 
414
- up.on 'up:framework:booted', -> isBooting = false
415
460
  up.on 'up:framework:reset', reset
416
461
 
417
462
  <% if ENV['JS_KNIFE'] %>knife: eval(Knife.point)<% end %>
418
463
  compiler: registerCompiler
419
464
  macro: registerMacro
465
+ $compiler: registerJQueryCompiler
466
+ $macro: registerJQueryMacro
420
467
  destructor: registerDestructor
421
468
  compile: compile
422
469
  clean: clean
423
470
  data: readData
424
471
 
425
- )(jQuery)
426
-
427
472
  up.compiler = up.syntax.compiler
473
+ up.$compiler = up.syntax.$compiler
428
474
  up.destructor = up.syntax.destructor
429
475
  up.macro = up.syntax.macro
476
+ up.$macro = up.syntax.$macro
477
+