unpoly-rails 0.32.0 → 0.33.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +106 -76
- data/README.md +8 -5
- data/README_RAILS.md +1 -1
- data/design/test_rejected_promise.txt +5 -0
- data/dist/unpoly-bootstrap3.js +1 -1
- data/dist/unpoly-bootstrap3.min.js +1 -1
- data/dist/unpoly.js +814 -417
- data/dist/unpoly.min.js +3 -3
- data/lib/assets/javascripts/unpoly/{browser.js.coffee → browser.coffee} +15 -6
- data/lib/assets/javascripts/unpoly/{bus.js.coffee → bus.coffee} +13 -13
- data/lib/assets/javascripts/unpoly/dom/extract_cascade.coffee +73 -0
- data/lib/assets/javascripts/unpoly/dom/extract_plan.coffee +65 -0
- data/lib/assets/javascripts/unpoly/{flow.js.coffee → dom.coffee} +109 -114
- data/lib/assets/javascripts/unpoly/{navigation.js.coffee → feedback.coffee} +11 -11
- data/lib/assets/javascripts/unpoly/{form.js.coffee → form.coffee} +35 -24
- data/lib/assets/javascripts/unpoly/{history.js.coffee → history.coffee} +9 -10
- data/lib/assets/javascripts/unpoly/{layout.js.coffee → layout.coffee} +53 -21
- data/lib/assets/javascripts/unpoly/{link.js.coffee → link.coffee} +46 -40
- data/lib/assets/javascripts/unpoly/{log.js.coffee → log.coffee} +2 -2
- data/lib/assets/javascripts/unpoly/{modal.js.coffee → modal.coffee} +17 -14
- data/lib/assets/javascripts/unpoly/{motion.js.coffee → motion.coffee} +28 -31
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +10 -0
- data/lib/assets/javascripts/unpoly/{popup.js.coffee → popup.coffee} +22 -10
- data/lib/assets/javascripts/unpoly/{proxy.js.coffee → proxy.coffee} +34 -12
- data/lib/assets/javascripts/unpoly/{rails.js.coffee → rails.coffee} +0 -0
- data/lib/assets/javascripts/unpoly/{syntax.js.coffee → syntax.coffee} +32 -21
- data/lib/assets/javascripts/unpoly/{toast.js.coffee → toast.coffee} +0 -0
- data/lib/assets/javascripts/unpoly/{tooltip.js.coffee → tooltip.coffee} +2 -2
- data/lib/assets/javascripts/unpoly/{util.js.coffee → util.coffee} +122 -35
- data/lib/assets/javascripts/unpoly-bootstrap3/{form-ext.js.coffee → form-ext.coffee} +0 -0
- data/lib/assets/javascripts/unpoly-bootstrap3/{layout-ext.js.coffee → layout-ext.coffee} +0 -0
- data/lib/assets/javascripts/unpoly-bootstrap3/{modal-ext.js.coffee → modal-ext.coffee} +0 -0
- data/lib/assets/javascripts/unpoly-bootstrap3/{navigation-ext.js.coffee → navigation-ext.coffee} +1 -1
- data/lib/assets/javascripts/{unpoly-bootstrap3.js.coffee → unpoly-bootstrap3.coffee} +0 -0
- data/lib/assets/javascripts/unpoly.coffee +22 -0
- data/lib/assets/stylesheets/unpoly/{close.css.sass → close.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{flow.css.sass → flow.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{link.css.sass → link.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{modal.css.sass → modal.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{popup.css.sass → popup.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{toast.css.sass → toast.sass} +0 -0
- data/lib/assets/stylesheets/unpoly/{tooltip.css.sass → tooltip.sass} +0 -0
- data/lib/assets/stylesheets/unpoly-bootstrap3/{modal-ext.css.sass → modal-ext.sass} +0 -0
- data/lib/assets/stylesheets/{unpoly-bootstrap3.css.sass → unpoly-bootstrap3.sass} +0 -0
- data/lib/assets/stylesheets/{unpoly.css.sass → unpoly.sass} +0 -0
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -1
- data/spec_app/Gemfile.lock +11 -13
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -1
- data/spec_app/app/assets/stylesheets/_helpers.sass +1 -1
- data/spec_app/config/initializers/assets.rb +1 -5
- data/spec_app/spec/javascripts/up/{flow_spec.js.coffee → dom_spec.js.coffee} +294 -44
- data/spec_app/spec/javascripts/up/{navigation_spec.js.coffee → feedback_spec.js.coffee} +2 -2
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +1 -0
- data/spec_app/spec/javascripts/up/layout_spec.js.coffee +10 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +28 -0
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +46 -9
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +32 -2
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +5 -4
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +75 -0
- data/spec_app/vendor/{assets/bower_components/jasmine-ajax → asset-libs/jasmine-ajax-3.3.1}/.bower.json +0 -0
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.gitignore +6 -0
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.npmignore +10 -0
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.pairs +6 -0
- data/spec_app/vendor/asset-libs/jasmine-ajax-3.3.1/.travis.yml +56 -0
- data/spec_app/vendor/{assets/bower_components/jasmine-ajax/lib/mock-ajax.js → asset-libs/jasmine-ajax-3.3.1/jasmine-ajax.js} +83 -26
- data/spec_app/vendor/{assets/bower_components/jasmine-fixture/dist → asset-libs/jasmine-fixture-1.3.4}/jasmine-fixture.js +13 -13
- data/spec_app/vendor/{assets/bower_components/jasmine-jquery → asset-libs/jasmine-jquery-2.1.1}/.bower.json +0 -0
- data/spec_app/vendor/{assets/bower_components/jasmine-jquery/lib → asset-libs/jasmine-jquery-2.1.1}/jasmine-jquery.js +0 -0
- data/spec_app/vendor/assets/{javascripts/.keep → .keep} +0 -0
- metadata +52 -203
- data/lib/assets/javascripts/unpoly/module.js.coffee.erb +0 -8
- data/lib/assets/javascripts/unpoly.js.coffee +0 -21
- data/spec_app/Bowerfile +0 -3
- data/spec_app/vendor/assets/.bowerrc +0 -3
- data/spec_app/vendor/assets/bower.json +0 -8
- data/spec_app/vendor/assets/bower_components/jasmine/.bower.json +0 -50
- data/spec_app/vendor/assets/bower_components/jasmine/CONTRIBUTING.md +0 -130
- data/spec_app/vendor/assets/bower_components/jasmine/GOALS_2.0.md +0 -64
- data/spec_app/vendor/assets/bower_components/jasmine/MANIFEST.in +0 -5
- data/spec_app/vendor/assets/bower_components/jasmine/MIT.LICENSE +0 -20
- data/spec_app/vendor/assets/bower_components/jasmine/README.md +0 -73
- data/spec_app/vendor/assets/bower_components/jasmine/RELEASE.md +0 -73
- data/spec_app/vendor/assets/bower_components/jasmine/bower.json +0 -41
- data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine-horizontal.png +0 -0
- data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine-horizontal.svg +0 -102
- data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine_favicon.png +0 -0
- data/spec_app/vendor/assets/bower_components/jasmine/lib/console/console.js +0 -190
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/boot.js +0 -143
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js +0 -24
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js +0 -9
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine-html.js +0 -446
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine.css +0 -58
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine.js +0 -3298
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/json2.js +0 -489
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/node_boot.js +0 -41
- data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core.js +0 -37
- data/spec_app/vendor/assets/bower_components/jasmine/package.json +0 -34
- data/spec_app/vendor/assets/bower_components/jasmine/requirements.txt +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/MIT.LICENSE +0 -20
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/README.markdown +0 -289
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/bower.json +0 -35
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/package.json +0 -26
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/2.0.2.md +0 -50
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/2.99.md +0 -14
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.0.md +0 -28
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.1.0.md +0 -24
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.1.1.md +0 -23
- data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.2.0.md +0 -20
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/.bower.json +0 -27
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/.gitignore +0 -8
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/.npmignore +0 -8
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/LICENSE.txt +0 -24
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/README.md +0 -118
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/bower.json +0 -17
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/dist/jasmine-fixture.min.js +0 -5
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/basic-usage-spec.coffee +0 -14
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/invariants.coffee +0 -17
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/spec-within-a-spec.coffee +0 -24
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/tmp-files.coffee +0 -8
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/support/jasmine1-testem-config.json +0 -11
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/support/jasmine2-testem-config.json +0 -11
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-1.11.0.js +0 -10337
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-1.8.3.js +0 -9472
- data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-2.1.0.js +0 -9111
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/CONTRIBUTING.md +0 -28
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/Gruntfile.js +0 -49
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/LICENSE +0 -20
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/README.md +0 -367
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/bower.json +0 -15
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/package.json +0 -35
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_checkbox_with_checked.html +0 -6
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_javascript.html +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_javascript_block.html +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/javascripts/jasmine_javascript_click.js +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/javascripts/jasmine_javascript_hover.js +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/json/jasmine_json_test.json +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/real_non_mocked_fixture.html +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/real_non_mocked_fixture_style.css +0 -1
- data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/suites/jasmine-jquery-spec.js +0 -1842
- data/spec_app/vendor/assets/bower_components/jquery/.bower.json +0 -38
- data/spec_app/vendor/assets/bower_components/jquery/MIT-LICENSE.txt +0 -21
- data/spec_app/vendor/assets/bower_components/jquery/bower.json +0 -28
- data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.js +0 -9210
- data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.min.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.min.map +0 -1
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/jsonp.js +0 -89
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/load.js +0 -75
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/parseJSON.js +0 -13
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/parseXML.js +0 -28
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/script.js +0 -64
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/var/nonce.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/var/rquery.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax/xhr.js +0 -136
- data/spec_app/vendor/assets/bower_components/jquery/src/ajax.js +0 -786
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes/attr.js +0 -141
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes/classes.js +0 -158
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes/prop.js +0 -94
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes/support.js +0 -35
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes/val.js +0 -161
- data/spec_app/vendor/assets/bower_components/jquery/src/attributes.js +0 -11
- data/spec_app/vendor/assets/bower_components/jquery/src/callbacks.js +0 -205
- data/spec_app/vendor/assets/bower_components/jquery/src/core/access.js +0 -60
- data/spec_app/vendor/assets/bower_components/jquery/src/core/init.js +0 -123
- data/spec_app/vendor/assets/bower_components/jquery/src/core/parseHTML.js +0 -39
- data/spec_app/vendor/assets/bower_components/jquery/src/core/ready.js +0 -97
- data/spec_app/vendor/assets/bower_components/jquery/src/core/var/rsingleTag.js +0 -4
- data/spec_app/vendor/assets/bower_components/jquery/src/core.js +0 -502
- data/spec_app/vendor/assets/bower_components/jquery/src/css/addGetHookIf.js +0 -22
- data/spec_app/vendor/assets/bower_components/jquery/src/css/curCSS.js +0 -57
- data/spec_app/vendor/assets/bower_components/jquery/src/css/defaultDisplay.js +0 -70
- data/spec_app/vendor/assets/bower_components/jquery/src/css/hiddenVisibleSelectors.js +0 -15
- data/spec_app/vendor/assets/bower_components/jquery/src/css/support.js +0 -96
- data/spec_app/vendor/assets/bower_components/jquery/src/css/swap.js +0 -28
- data/spec_app/vendor/assets/bower_components/jquery/src/css/var/cssExpand.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/css/var/getStyles.js +0 -12
- data/spec_app/vendor/assets/bower_components/jquery/src/css/var/isHidden.js +0 -13
- data/spec_app/vendor/assets/bower_components/jquery/src/css/var/rmargin.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/css/var/rnumnonpx.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/css.js +0 -450
- data/spec_app/vendor/assets/bower_components/jquery/src/data/Data.js +0 -181
- data/spec_app/vendor/assets/bower_components/jquery/src/data/accepts.js +0 -20
- data/spec_app/vendor/assets/bower_components/jquery/src/data/var/data_priv.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/data/var/data_user.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/data.js +0 -178
- data/spec_app/vendor/assets/bower_components/jquery/src/deferred.js +0 -149
- data/spec_app/vendor/assets/bower_components/jquery/src/deprecated.js +0 -13
- data/spec_app/vendor/assets/bower_components/jquery/src/dimensions.js +0 -50
- data/spec_app/vendor/assets/bower_components/jquery/src/effects/Tween.js +0 -114
- data/spec_app/vendor/assets/bower_components/jquery/src/effects/animatedSelector.js +0 -13
- data/spec_app/vendor/assets/bower_components/jquery/src/effects.js +0 -648
- data/spec_app/vendor/assets/bower_components/jquery/src/event/ajax.js +0 -13
- data/spec_app/vendor/assets/bower_components/jquery/src/event/alias.js +0 -39
- data/spec_app/vendor/assets/bower_components/jquery/src/event/support.js +0 -9
- data/spec_app/vendor/assets/bower_components/jquery/src/event.js +0 -868
- data/spec_app/vendor/assets/bower_components/jquery/src/exports/amd.js +0 -24
- data/spec_app/vendor/assets/bower_components/jquery/src/exports/global.js +0 -32
- data/spec_app/vendor/assets/bower_components/jquery/src/intro.js +0 -44
- data/spec_app/vendor/assets/bower_components/jquery/src/jquery.js +0 -37
- data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/_evalUrl.js +0 -18
- data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/support.js +0 -32
- data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/var/rcheckableType.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/manipulation.js +0 -580
- data/spec_app/vendor/assets/bower_components/jquery/src/offset.js +0 -207
- data/spec_app/vendor/assets/bower_components/jquery/src/outro.js +0 -1
- data/spec_app/vendor/assets/bower_components/jquery/src/queue/delay.js +0 -22
- data/spec_app/vendor/assets/bower_components/jquery/src/queue.js +0 -142
- data/spec_app/vendor/assets/bower_components/jquery/src/selector-native.js +0 -172
- data/spec_app/vendor/assets/bower_components/jquery/src/selector-sizzle.js +0 -14
- data/spec_app/vendor/assets/bower_components/jquery/src/selector.js +0 -1
- data/spec_app/vendor/assets/bower_components/jquery/src/serialize.js +0 -111
- data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.js +0 -2067
- data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.map +0 -1
- data/spec_app/vendor/assets/bower_components/jquery/src/traversing/findFilter.js +0 -100
- data/spec_app/vendor/assets/bower_components/jquery/src/traversing/var/rneedsContext.js +0 -6
- data/spec_app/vendor/assets/bower_components/jquery/src/traversing.js +0 -199
- data/spec_app/vendor/assets/bower_components/jquery/src/var/arr.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/var/class2type.js +0 -4
- data/spec_app/vendor/assets/bower_components/jquery/src/var/concat.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/var/hasOwn.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/var/indexOf.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/var/pnum.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/var/push.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/var/rnotwhite.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/var/slice.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/var/strundefined.js +0 -3
- data/spec_app/vendor/assets/bower_components/jquery/src/var/support.js +0 -4
- data/spec_app/vendor/assets/bower_components/jquery/src/var/toString.js +0 -5
- data/spec_app/vendor/assets/bower_components/jquery/src/wrap.js +0 -79
- data/spec_app/vendor/assets/stylesheets/.keep +0 -0
@@ -268,7 +268,7 @@ up.modal = (($) ->
|
|
268
268
|
if u.documentHasVerticalScrollbar()
|
269
269
|
$body = $('body')
|
270
270
|
scrollbarWidth = u.scrollbarWidth()
|
271
|
-
bodyRightPadding =
|
271
|
+
bodyRightPadding = parseFloat($body.css('padding-right'))
|
272
272
|
bodyRightShift = scrollbarWidth + bodyRightPadding
|
273
273
|
unshiftBody = u.temporaryCss($body,
|
274
274
|
'padding-right': "#{bodyRightShift}px",
|
@@ -277,7 +277,7 @@ up.modal = (($) ->
|
|
277
277
|
state.unshifters.push(unshiftBody)
|
278
278
|
up.layout.anchoredRight().each ->
|
279
279
|
$element = $(this)
|
280
|
-
elementRight =
|
280
|
+
elementRight = parseFloat($element.css('right'))
|
281
281
|
elementRightShift = scrollbarWidth + elementRight
|
282
282
|
unshifter = u.temporaryCss($element, 'right': elementRightShift)
|
283
283
|
state.unshifters.push(unshifter)
|
@@ -293,6 +293,7 @@ up.modal = (($) ->
|
|
293
293
|
This also returns `true` if the modal is in an opening or closing animation.
|
294
294
|
|
295
295
|
@function up.modal.isOpen
|
296
|
+
@return {Boolean}
|
296
297
|
@stable
|
297
298
|
###
|
298
299
|
isOpen = ->
|
@@ -338,11 +339,11 @@ up.modal = (($) ->
|
|
338
339
|
@param {String} [options.animation]
|
339
340
|
The animation to use when opening the modal.
|
340
341
|
@param {Number} [options.duration]
|
341
|
-
The duration of the animation. See [`up.animate`](/up.animate).
|
342
|
+
The duration of the animation. See [`up.animate()`](/up.animate).
|
342
343
|
@param {Number} [options.delay]
|
343
|
-
The delay before the animation starts. See [`up.animate`](/up.animate).
|
344
|
+
The delay before the animation starts. See [`up.animate()`](/up.animate).
|
344
345
|
@param {String} [options.easing]
|
345
|
-
The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
|
346
|
+
The timing function that controls the animation's acceleration. [`up.animate()`](/up.animate).
|
346
347
|
@return {Promise}
|
347
348
|
A promise that will be resolved when the modal has been loaded and
|
348
349
|
the opening animation has completed.
|
@@ -356,7 +357,7 @@ up.modal = (($) ->
|
|
356
357
|
###*
|
357
358
|
Opens a modal for the given URL.
|
358
359
|
|
359
|
-
Example
|
360
|
+
\#\#\# Example
|
360
361
|
|
361
362
|
up.modal.visit('/foo', { target: '.list' });
|
362
363
|
|
@@ -372,7 +373,7 @@ up.modal = (($) ->
|
|
372
373
|
The CSS selector to extract from the response.
|
373
374
|
The extracted content will be placed into the dialog window.
|
374
375
|
@param {Object} options
|
375
|
-
See options for [`up.modal.follow`](/up.modal.follow).
|
376
|
+
See options for [`up.modal.follow()`](/up.modal.follow).
|
376
377
|
@return {Promise}
|
377
378
|
A promise that will be resolved when the modal has been loaded and the opening
|
378
379
|
animation has completed.
|
@@ -387,7 +388,7 @@ up.modal = (($) ->
|
|
387
388
|
[Extracts](/up.extract) the given CSS selector from the given HTML string and
|
388
389
|
opens the results in a modal.
|
389
390
|
|
390
|
-
Example
|
391
|
+
\#\#\# Example
|
391
392
|
|
392
393
|
var html = 'before <div class="content">inner</div> after';
|
393
394
|
up.modal.extract('.content', html);
|
@@ -404,7 +405,7 @@ up.modal = (($) ->
|
|
404
405
|
@param {String} html
|
405
406
|
The HTML containing the modal content.
|
406
407
|
@param {Object} options
|
407
|
-
See options for [`up.modal.follow`](/up.modal.follow).
|
408
|
+
See options for [`up.modal.follow()`](/up.modal.follow).
|
408
409
|
@return {Promise}
|
409
410
|
A promise that will be resolved when the modal has been opened and the opening
|
410
411
|
animation has completed.
|
@@ -464,7 +465,7 @@ up.modal = (($) ->
|
|
464
465
|
if options.history
|
465
466
|
state.coveredUrl = up.browser.url()
|
466
467
|
state.coveredTitle = document.title
|
467
|
-
options.
|
468
|
+
options.provideTarget = -> createFrame(target, options)
|
468
469
|
extractOptions = u.merge(options, animation: false)
|
469
470
|
if html
|
470
471
|
promise = up.extract(target, html, extractOptions)
|
@@ -503,7 +504,7 @@ up.modal = (($) ->
|
|
503
504
|
|
504
505
|
@function up.modal.close
|
505
506
|
@param {Object} options
|
506
|
-
See options for [`up.animate`](/up.animate)
|
507
|
+
See options for [`up.animate()`](/up.animate)
|
507
508
|
@return {Promise}
|
508
509
|
A promise that will be resolved once the modal's close
|
509
510
|
animation has finished.
|
@@ -534,7 +535,7 @@ up.modal = (($) ->
|
|
534
535
|
up.bus.whenEmitted('up:modal:close', $element: state.$modal, message: 'Closing modal').then ->
|
535
536
|
state.phase = 'closing'
|
536
537
|
# the current URL must be deleted *before* calling up.destroy,
|
537
|
-
# since up.
|
538
|
+
# since up.feedback listens to up:fragment:destroyed and then
|
538
539
|
# re-assigns .up-current classes.
|
539
540
|
state.url = null
|
540
541
|
state.coveredUrl = null
|
@@ -601,6 +602,8 @@ up.modal = (($) ->
|
|
601
602
|
|
602
603
|
@function up.modal.contains
|
603
604
|
@param {String} elementOrSelector
|
605
|
+
The element to test
|
606
|
+
@return {Boolean}
|
604
607
|
@stable
|
605
608
|
###
|
606
609
|
contains = (elementOrSelector) ->
|
@@ -609,7 +612,7 @@ up.modal = (($) ->
|
|
609
612
|
|
610
613
|
flavor = (name, overrideConfig = {}) ->
|
611
614
|
up.log.warn 'The up.modal.flavor function is deprecated. Use the up.modal.flavors property instead.'
|
612
|
-
u.
|
615
|
+
u.assign(flavorOverrides(name), overrideConfig)
|
613
616
|
|
614
617
|
###*
|
615
618
|
Returns a config object for the given flavor.
|
@@ -784,7 +787,7 @@ up.modal = (($) ->
|
|
784
787
|
if u.isPresent(options.$link)
|
785
788
|
u.horizontalScreenHalf(options.$link)
|
786
789
|
else
|
787
|
-
# In case the drawer was opened programmatically through
|
790
|
+
# In case the drawer was opened programmatically through Javascript,
|
788
791
|
# we might now know the link that was clicked on.
|
789
792
|
'left'
|
790
793
|
|
@@ -26,8 +26,8 @@ of the dialog by adding an [`up-animation`](/up-modal#up-animation) attribute to
|
|
26
26
|
Unpoly ships with a number of [predefined transitions](/up.morph#named-transitions)
|
27
27
|
and [predefined animations](/up.animate#named-animations).
|
28
28
|
|
29
|
-
You can define custom animations using [`up.transition`](/up.transition) and
|
30
|
-
[`up.animation`](/up.animation).
|
29
|
+
You can define custom animations using [`up.transition()`](/up.transition) and
|
30
|
+
[`up.animation()`](/up.animation).
|
31
31
|
|
32
32
|
@class up.motion
|
33
33
|
###
|
@@ -120,7 +120,7 @@ up.motion = (($) ->
|
|
120
120
|
| `move-from-right` | Moves the element leftwards from beyond the right edge of the screen until it reaches its current position |
|
121
121
|
| `none` | An animation that has no visible effect. Sounds useless at first, but can save you a lot of `if` statements. |
|
122
122
|
|
123
|
-
You can define additional named animations using [`up.animation`](/up.animation).
|
123
|
+
You can define additional named animations using [`up.animation()`](/up.animation).
|
124
124
|
|
125
125
|
\#\#\# Animating CSS properties directly
|
126
126
|
|
@@ -165,7 +165,7 @@ up.motion = (($) ->
|
|
165
165
|
$element = $(elementOrSelector)
|
166
166
|
finish($element)
|
167
167
|
options = animateOptions(options)
|
168
|
-
if
|
168
|
+
if isNone(animation)
|
169
169
|
none()
|
170
170
|
else if u.isFunction(animation)
|
171
171
|
assertIsDeferred(animation($element, options), animation)
|
@@ -283,6 +283,9 @@ up.motion = (($) ->
|
|
283
283
|
@stable
|
284
284
|
###
|
285
285
|
finish = (elementOrSelector = '.up-animating') ->
|
286
|
+
# We don't need to crawl through the DOM if we aren't animating anyway
|
287
|
+
return unless isEnabled()
|
288
|
+
|
286
289
|
$element = $(elementOrSelector)
|
287
290
|
$animatingSubtree = u.findWithSelf($element, '.up-animating')
|
288
291
|
u.finishCssAnimate($animatingSubtree)
|
@@ -320,7 +323,7 @@ up.motion = (($) ->
|
|
320
323
|
| `move-right` | Moves the first element rightwards until it exists the screen at the right edge. Simultaneously moves the second element rightwards from beyond the left edge of the screen until it reaches its current position. |
|
321
324
|
| `none` | A transition that has no visible effect. Sounds useless at first, but can save you a lot of `if` statements. |
|
322
325
|
|
323
|
-
You can define additional named transitions using [`up.transition`](/up.transition).
|
326
|
+
You can define additional named transitions using [`up.transition()`](/up.transition).
|
324
327
|
|
325
328
|
You can also compose a transition from two [named animations](/named-animations).
|
326
329
|
separated by a slash character (`/`):
|
@@ -366,32 +369,27 @@ up.motion = (($) ->
|
|
366
369
|
@stable
|
367
370
|
###
|
368
371
|
morph = (source, target, transitionOrName, options) ->
|
369
|
-
if transitionOrName == 'none'
|
370
|
-
transitionOrName = false
|
371
|
-
|
372
372
|
options = u.options(options)
|
373
373
|
|
374
|
+
willMorph = isEnabled() && !isNone(transitionOrName)
|
374
375
|
$old = $(source)
|
375
376
|
$new = $(target)
|
376
377
|
|
377
|
-
|
378
|
-
ensureMorphable($new, transitionOrName)
|
379
|
-
|
380
|
-
up.log.group ('Morphing %o to %o (using %s, %o)' if transitionOrName), $old.get(0), $new.get(0), transitionOrName, options, ->
|
381
|
-
|
378
|
+
up.log.group ('Morphing %o to %o (using %s, %o)' if willMorph), $old.get(0), $new.get(0), transitionOrName, options, ->
|
382
379
|
parsedOptions = u.only(options, 'reveal', 'restoreScroll', 'source')
|
383
|
-
parsedOptions = u.
|
380
|
+
parsedOptions = u.assign(parsedOptions, animateOptions(options))
|
384
381
|
|
385
|
-
|
386
|
-
|
387
|
-
|
382
|
+
finish($old)
|
383
|
+
finish($new)
|
384
|
+
|
385
|
+
if willMorph
|
386
|
+
ensureMorphable($old)
|
387
|
+
ensureMorphable($new)
|
388
388
|
|
389
|
-
if
|
390
|
-
return skipMorph($old, $new, parsedOptions)
|
391
|
-
else if animation = animations[transitionOrName]
|
389
|
+
if animation = animations[transitionOrName]
|
392
390
|
skipMorph($old, $new, parsedOptions)
|
393
391
|
return animate($new, animation, parsedOptions)
|
394
|
-
else if transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName]
|
392
|
+
else if transition = (u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName])
|
395
393
|
return withGhosts $old, $new, parsedOptions, ($oldGhost, $newGhost) ->
|
396
394
|
transitionPromise = transition($oldGhost, $newGhost, parsedOptions)
|
397
395
|
assertIsDeferred(transitionPromise, transitionOrName)
|
@@ -408,8 +406,8 @@ up.motion = (($) ->
|
|
408
406
|
else
|
409
407
|
return skipMorph($old, $new, parsedOptions)
|
410
408
|
|
411
|
-
ensureMorphable = ($element
|
412
|
-
if
|
409
|
+
ensureMorphable = ($element) ->
|
410
|
+
if $element.parents('body').length == 0
|
413
411
|
element = $element.get(0)
|
414
412
|
up.fail("Can't morph a <%s> element (%o)", element.tagName, element)
|
415
413
|
|
@@ -490,10 +488,10 @@ up.motion = (($) ->
|
|
490
488
|
)
|
491
489
|
)
|
492
490
|
|
493
|
-
It is recommended that your transitions use [`up.animate`](/up.animate),
|
491
|
+
It is recommended that your transitions use [`up.animate()`](/up.animate),
|
494
492
|
passing along the `options` that were passed to you.
|
495
493
|
|
496
|
-
If you choose to *not* use `up.animate` and roll your own
|
494
|
+
If you choose to *not* use `up.animate()` and roll your own
|
497
495
|
logic instead, your code must honor the following contract:
|
498
496
|
|
499
497
|
1. It must honor the passed options `{ delay, duration, easing }` if present
|
@@ -502,7 +500,7 @@ up.motion = (($) ->
|
|
502
500
|
4. The returned promise responds to a `resolve()` function that
|
503
501
|
instantly jumps to the last transition frame and resolves the promise.
|
504
502
|
|
505
|
-
Calling [`up.animate`](/up.animate) with an object argument
|
503
|
+
Calling [`up.animate()`](/up.animate) with an object argument
|
506
504
|
will take care of all these points.
|
507
505
|
|
508
506
|
@function up.transition
|
@@ -524,10 +522,10 @@ up.motion = (($) ->
|
|
524
522
|
})
|
525
523
|
|
526
524
|
It is recommended that your definitions always end by calling
|
527
|
-
calling [`up.animate`](/up.animate) with an object argument, passing along
|
525
|
+
calling [`up.animate()`](/up.animate) with an object argument, passing along
|
528
526
|
the `options` that were passed to you.
|
529
527
|
|
530
|
-
If you choose to *not* use `up.animate` and roll your own
|
528
|
+
If you choose to *not* use `up.animate()` and roll your own
|
531
529
|
animation code instead, your code must honor the following contract:
|
532
530
|
|
533
531
|
1. It must honor the passed options `{ delay, duration, easing }` if present
|
@@ -536,7 +534,7 @@ up.motion = (($) ->
|
|
536
534
|
4. The returned promise responds to a `resolve()` function that
|
537
535
|
instantly jumps to the last animation frame and resolves the promise.
|
538
536
|
|
539
|
-
Calling [`up.animate`](/up.animate) with an object argument
|
537
|
+
Calling [`up.animate()`](/up.animate) with an object argument
|
540
538
|
will take care of all these points.
|
541
539
|
|
542
540
|
@function up.animation
|
@@ -589,7 +587,7 @@ up.motion = (($) ->
|
|
589
587
|
@internal
|
590
588
|
###
|
591
589
|
isNone = (animation) ->
|
592
|
-
animation is false || animation is 'none' || animation
|
590
|
+
animation is false || animation is 'none' || u.isMissing(animation) || u.isResolvedPromise(animation)
|
593
591
|
|
594
592
|
animation('none', none)
|
595
593
|
|
@@ -721,7 +719,6 @@ up.motion = (($) ->
|
|
721
719
|
animation: animation
|
722
720
|
config: config
|
723
721
|
isEnabled: isEnabled
|
724
|
-
defaults: -> up.fail('up.motion.defaults(...) no longer exists. Set values on he up.motion.config property instead.')
|
725
722
|
none: none
|
726
723
|
when: resolvableWhen
|
727
724
|
prependCopy: prependCopy
|
@@ -87,8 +87,9 @@ up.popup = (($) ->
|
|
87
87
|
history: false
|
88
88
|
|
89
89
|
###*
|
90
|
-
Returns the
|
91
|
-
|
90
|
+
Returns the URL from which the current popup's contents were loaded.
|
91
|
+
|
92
|
+
Returns `undefined` if no popup is open.
|
92
93
|
|
93
94
|
@function up.popup.url
|
94
95
|
@return {String}
|
@@ -168,6 +169,7 @@ up.popup = (($) ->
|
|
168
169
|
Returns whether popup modal is currently open.
|
169
170
|
|
170
171
|
@function up.popup.isOpen
|
172
|
+
@return {Boolean}
|
171
173
|
@stable
|
172
174
|
###
|
173
175
|
isOpen = ->
|
@@ -201,11 +203,11 @@ up.popup = (($) ->
|
|
201
203
|
@param {String} [options.animation]
|
202
204
|
The animation to use when opening the popup.
|
203
205
|
@param {Number} [options.duration]
|
204
|
-
The duration of the animation. See [`up.animate`](/up.animate).
|
206
|
+
The duration of the animation. See [`up.animate()`](/up.animate).
|
205
207
|
@param {Number} [options.delay]
|
206
|
-
The delay before the animation starts. See [`up.animate`](/up.animate).
|
208
|
+
The delay before the animation starts. See [`up.animate()`](/up.animate).
|
207
209
|
@param {String} [options.easing]
|
208
|
-
The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
|
210
|
+
The timing function that controls the animation's acceleration. [`up.animate()`](/up.animate).
|
209
211
|
@param {String} [options.method="GET"]
|
210
212
|
Override the request method.
|
211
213
|
@param {Boolean} [options.sticky=false]
|
@@ -251,7 +253,7 @@ up.popup = (($) ->
|
|
251
253
|
state.coveredUrl = up.browser.url()
|
252
254
|
state.coveredTitle = document.title
|
253
255
|
state.sticky = options.sticky
|
254
|
-
options.
|
256
|
+
options.provideTarget = -> createFrame(target)
|
255
257
|
extractOptions = u.merge(options, animation: false)
|
256
258
|
if html
|
257
259
|
promise = up.extract(target, html, extractOptions)
|
@@ -290,7 +292,7 @@ up.popup = (($) ->
|
|
290
292
|
|
291
293
|
@function up.popup.close
|
292
294
|
@param {Object} options
|
293
|
-
See options for [`up.animate`](/up.animate).
|
295
|
+
See options for [`up.animate()`](/up.animate).
|
294
296
|
@return {Promise}
|
295
297
|
A promise that will be resolved once the modal's close
|
296
298
|
animation has finished.
|
@@ -311,7 +313,7 @@ up.popup = (($) ->
|
|
311
313
|
title: state.coveredTitle
|
312
314
|
)
|
313
315
|
animateOptions = up.motion.animateOptions(options, duration: config.closeDuration, easing: config.closeEasing)
|
314
|
-
u.
|
316
|
+
u.assign(options, animateOptions)
|
315
317
|
|
316
318
|
up.bus.whenEmitted('up:popup:close', message: 'Closing popup', $element: state.$popup).then ->
|
317
319
|
state.phase = 'closing'
|
@@ -355,6 +357,8 @@ up.popup = (($) ->
|
|
355
357
|
|
356
358
|
@methods up.popup.contains
|
357
359
|
@param {String} elementOrSelector
|
360
|
+
The element to test
|
361
|
+
@return {Boolean}
|
358
362
|
@stable
|
359
363
|
###
|
360
364
|
contains = (elementOrSelector) ->
|
@@ -424,11 +428,19 @@ up.popup = (($) ->
|
|
424
428
|
up.bus.onEscape(closeAsap)
|
425
429
|
|
426
430
|
###*
|
427
|
-
When
|
428
|
-
a currently open popup is closed.
|
431
|
+
When this element is clicked, a currently open [popup](/up.popup) is closed.
|
429
432
|
|
430
433
|
Does nothing if no popup is currently open.
|
431
434
|
|
435
|
+
\#\#\# Example
|
436
|
+
|
437
|
+
Clickin on this `<span>` will close a currently open popup:
|
438
|
+
|
439
|
+
<span class='up-close'>Close this popup</span>
|
440
|
+
|
441
|
+
When a popup changes the current URL, you might need to deal with content being displayed
|
442
|
+
as either a popup or a full page.
|
443
|
+
|
432
444
|
To make a link that closes the current popup, but follows to
|
433
445
|
a fallback destination if no popup is open:
|
434
446
|
|
@@ -1,22 +1,25 @@
|
|
1
1
|
###*
|
2
|
-
|
3
|
-
|
2
|
+
AJAX acceleration
|
3
|
+
=================
|
4
4
|
|
5
|
-
Unpoly
|
6
|
-
making requests to these URLs return instantly.
|
5
|
+
Unpoly comes with a number of tricks to shorten the latency between browser and server.
|
7
6
|
|
8
|
-
|
9
|
-
If you need to make cache-aware requests from your [custom JavaScript](/up.syntax),
|
10
|
-
use [`up.ajax`](/up.ajax).
|
7
|
+
\#\#\# Server responses are cached by default
|
11
8
|
|
12
|
-
|
9
|
+
Unpoly caches server responses for a few minutes,
|
10
|
+
making requests to these URLs return instantly.
|
11
|
+
All Unpoly functions and selectors go through this cache, unless
|
12
|
+
you explicitly pass a `{ cache: false }` option or set an `up-cache="false"` attribute.
|
13
13
|
|
14
14
|
The cache holds up to 70 responses for 5 minutes. You can configure the cache size and expiry using
|
15
|
-
[`up.proxy.config`](/up.proxy.config), or clear the cache manually using [`up.proxy.clear`](/up.proxy.clear).
|
15
|
+
[`up.proxy.config`](/up.proxy.config), or clear the cache manually using [`up.proxy.clear()`](/up.proxy.clear).
|
16
16
|
|
17
17
|
Also the entire cache is cleared with every non-`GET` request (like `POST` or `PUT`).
|
18
18
|
|
19
|
-
|
19
|
+
If you need to make cache-aware requests from your [custom JavaScript](/up.syntax),
|
20
|
+
use [`up.ajax()`](/up.ajax).
|
21
|
+
|
22
|
+
\#\#\# Preloading links
|
20
23
|
|
21
24
|
Unpoly also lets you speed up reaction times by [preloading
|
22
25
|
links](/up-preload) when the user hovers over the click area (or puts the mouse/finger
|
@@ -28,6 +31,13 @@ the user releases the mouse/finger.
|
|
28
31
|
You can listen to the [`up:proxy:slow`](/up:proxy:slow) event to implement a spinner
|
29
32
|
that appears during a long-running request.
|
30
33
|
|
34
|
+
\#\#\# More acceleration
|
35
|
+
|
36
|
+
Other Unpoly modules contain even more tricks to outsmart network latency:
|
37
|
+
|
38
|
+
- [Instantaneous feedback for links that are currently loading](/up-active)
|
39
|
+
- [Follow links on `mousedown` instead of `click`](/up-instant)
|
40
|
+
|
31
41
|
@class up.proxy
|
32
42
|
###
|
33
43
|
up.proxy = (($) ->
|
@@ -193,6 +203,11 @@ up.proxy = (($) ->
|
|
193
203
|
@param {String} [request.url]
|
194
204
|
You can omit the first string argument and pass the URL as
|
195
205
|
a `request` property instead.
|
206
|
+
@param {String} [request.timeout]
|
207
|
+
A timeout in milliseconds for the request.
|
208
|
+
|
209
|
+
If [`up.proxy.config.maxRequests`](/up.proxy.config#maxRequests) is set, the timeout
|
210
|
+
will not include the time spent waiting in the queue.
|
196
211
|
@return
|
197
212
|
A promise for the response that is API-compatible with the
|
198
213
|
promise returned by [`jQuery.ajax`](http://api.jquery.com/jquery.ajax/).
|
@@ -206,7 +221,15 @@ up.proxy = (($) ->
|
|
206
221
|
forceCache = (options.cache == true)
|
207
222
|
ignoreCache = (options.cache == false)
|
208
223
|
|
209
|
-
request = u.only
|
224
|
+
request = u.only options,
|
225
|
+
'url',
|
226
|
+
'method',
|
227
|
+
'data',
|
228
|
+
'target',
|
229
|
+
'headers',
|
230
|
+
'timeout',
|
231
|
+
'_normalized'
|
232
|
+
|
210
233
|
request = normalizeRequest(request)
|
211
234
|
|
212
235
|
pending = true
|
@@ -561,7 +584,6 @@ up.proxy = (($) ->
|
|
561
584
|
isBusy: isBusy
|
562
585
|
isCachable: isCachable
|
563
586
|
config: config
|
564
|
-
defaults: -> up.fail('up.proxy.defaults(...) no longer exists. Set values on he up.proxy.config property instead.')
|
565
587
|
|
566
588
|
)(jQuery)
|
567
589
|
|
File without changes
|
@@ -33,21 +33,32 @@ up.syntax = (($) ->
|
|
33
33
|
Registers a function to be called whenever an element with
|
34
34
|
the given selector is inserted into the DOM.
|
35
35
|
|
36
|
+
Use compilers to activate your custom Javascript behavior on matching
|
37
|
+
elements.
|
38
|
+
|
39
|
+
You should migrate your [jQuery ready callbacks](https://api.jquery.com/ready/)
|
40
|
+
to compilers.
|
41
|
+
|
42
|
+
|
43
|
+
\#\#\# Example
|
44
|
+
|
45
|
+
Let's say that any element with the `action` class should alert a message when clicked.
|
46
|
+
We can implement this behavior as a compiler function that is called on all elements matching
|
47
|
+
the `.action` selector:
|
48
|
+
|
36
49
|
up.compiler('.action', function($element) {
|
37
|
-
|
50
|
+
$element.on('click', function() {
|
51
|
+
alert('Action was clicked!');
|
52
|
+
});
|
38
53
|
});
|
39
54
|
|
40
|
-
The
|
41
|
-
the page loads, or
|
42
|
-
later.
|
43
|
-
|
44
|
-
If you have used Angular.js before, this resembles
|
45
|
-
[Angular directives](https://docs.angularjs.org/guide/directive).
|
55
|
+
The compiler function will be called once for each matching element when
|
56
|
+
the page loads, or when a matching fragment is [inserted](/up.replace) later.
|
46
57
|
|
47
58
|
|
48
59
|
\#\#\# Integrating jQuery plugins
|
49
60
|
|
50
|
-
`up.compiler` is a great way to integrate jQuery plugins.
|
61
|
+
`up.compiler()` is a great way to integrate jQuery plugins.
|
51
62
|
Let's say your JavaScript plugin wants you to call `lightboxify()`
|
52
63
|
on links that should open a lightbox. You decide to
|
53
64
|
do this for all links with an `lightbox` class:
|
@@ -64,7 +75,7 @@ up.syntax = (($) ->
|
|
64
75
|
|
65
76
|
\#\#\# Custom elements
|
66
77
|
|
67
|
-
You can use `up.compiler` to implement custom elements like this:
|
78
|
+
You can use `up.compiler()` to implement custom elements like this:
|
68
79
|
|
69
80
|
<clock></clock>
|
70
81
|
|
@@ -141,7 +152,7 @@ up.syntax = (($) ->
|
|
141
152
|
});
|
142
153
|
|
143
154
|
|
144
|
-
\#\#\# Migrating jQuery event handlers to `up.compiler`
|
155
|
+
\#\#\# Migrating jQuery event handlers to `up.compiler()`
|
145
156
|
|
146
157
|
Within the compiler, Unpoly will bind `this` to the
|
147
158
|
native DOM element to help you migrate your existing jQuery code to
|
@@ -155,9 +166,9 @@ up.syntax = (($) ->
|
|
155
166
|
});
|
156
167
|
});
|
157
168
|
|
158
|
-
... you can reuse the
|
169
|
+
... you can reuse the callback function like this:
|
159
170
|
|
160
|
-
|
171
|
+
up.compiler('.action', function($element) {
|
161
172
|
$element.on('click', function() {
|
162
173
|
$(this).something();
|
163
174
|
});
|
@@ -191,7 +202,7 @@ up.syntax = (($) ->
|
|
191
202
|
[clear global state](/up.compiler#cleaning-up-after-yourself)
|
192
203
|
such as timeouts and event handlers bound to the document.
|
193
204
|
The destructor is *not* expected to remove the element from the DOM, which
|
194
|
-
is already handled by [`up.destroy`](/up.destroy).
|
205
|
+
is already handled by [`up.destroy()`](/up.destroy).
|
195
206
|
|
196
207
|
The function may also return an array of destructor functions.
|
197
208
|
@stable
|
@@ -202,7 +213,7 @@ up.syntax = (($) ->
|
|
202
213
|
###*
|
203
214
|
Registers a [compiler](/up.compiler) that is run before all other compilers.
|
204
215
|
|
205
|
-
You can use `up.macro` to register a compiler that sets other UJS attributes.
|
216
|
+
You can use `up.macro()` to register a compiler that sets other UJS attributes.
|
206
217
|
|
207
218
|
\#\#\# Example
|
208
219
|
|
@@ -234,10 +245,10 @@ up.syntax = (($) ->
|
|
234
245
|
@param {String} selector
|
235
246
|
The selector to match.
|
236
247
|
@param {Object} options
|
237
|
-
See options for [`up.compiler`](/up.compiler).
|
248
|
+
See options for [`up.compiler()`](/up.compiler).
|
238
249
|
@param {Function($element, data)} compiler
|
239
250
|
The function to call when a matching element is inserted.
|
240
|
-
See [`up.compiler`](/up.compiler) for details.
|
251
|
+
See [`up.compiler()`](/up.compiler) for details.
|
241
252
|
@stable
|
242
253
|
###
|
243
254
|
macro = (args...) ->
|
@@ -290,7 +301,7 @@ up.syntax = (($) ->
|
|
290
301
|
|
291
302
|
###*
|
292
303
|
Applies all compilers on the given element and its descendants.
|
293
|
-
Unlike [`up.hello`](/up.hello), this doesn't emit any events.
|
304
|
+
Unlike [`up.hello()`](/up.hello), this doesn't emit any events.
|
294
305
|
|
295
306
|
@function up.syntax.compile
|
296
307
|
@param {Array<Element>} [options.skip]
|
@@ -320,7 +331,7 @@ up.syntax = (($) ->
|
|
320
331
|
|
321
332
|
###*
|
322
333
|
Runs any destroyers on the given fragment and its descendants.
|
323
|
-
Unlike [`up.destroy`](/up.destroy), this doesn't emit any events
|
334
|
+
Unlike [`up.destroy()`](/up.destroy), this doesn't emit any events
|
324
335
|
and does not remove the element from the DOM.
|
325
336
|
|
326
337
|
@function up.syntax.clean
|
@@ -350,7 +361,7 @@ up.syntax = (($) ->
|
|
350
361
|
|
351
362
|
<span class="person" up-data="{ age: 18, name: 'Bob' }">Bob</span>
|
352
363
|
|
353
|
-
Calling `up.syntax.data` will deserialize the JSON string into a JavaScript object:
|
364
|
+
Calling `up.syntax.data()` will deserialize the JSON string into a JavaScript object:
|
354
365
|
|
355
366
|
up.syntax.data('.person') // returns { age: 18, name: 'Bob' }
|
356
367
|
|
@@ -366,7 +377,7 @@ up.syntax = (($) ->
|
|
366
377
|
###*
|
367
378
|
If an element annotated with [`up-data`] is inserted into the DOM,
|
368
379
|
Up will parse the JSON and pass the resulting object to any matching
|
369
|
-
[`up.compiler`](/up.compiler) handlers.
|
380
|
+
[`up.compiler()`](/up.compiler) handlers.
|
370
381
|
|
371
382
|
For instance, a container for a [Google Map](https://developers.google.com/maps/documentation/javascript/tutorial)
|
372
383
|
might attach the location and names of its marker pins:
|
@@ -395,7 +406,7 @@ up.syntax = (($) ->
|
|
395
406
|
|
396
407
|
Similarly, when an event is triggered on an element annotated with
|
397
408
|
[`up-data`], the parsed object will be passed to any matching
|
398
|
-
[`up.on`](/up.on) handlers.
|
409
|
+
[`up.on()`](/up.on) handlers.
|
399
410
|
|
400
411
|
up.on('click', '.google-map', function(event, $element, pins) {
|
401
412
|
console.log("There are %d pins on the clicked map", pins.length);
|
File without changes
|
@@ -175,7 +175,7 @@ up.tooltip = (($) ->
|
|
175
175
|
|
176
176
|
@function up.tooltip.close
|
177
177
|
@param {Object} options
|
178
|
-
See options for [`up.animate`](/up.animate).
|
178
|
+
See options for [`up.animate()`](/up.animate).
|
179
179
|
@return {Promise}
|
180
180
|
A promise for the end of the closing animation.
|
181
181
|
@stable
|
@@ -191,7 +191,7 @@ up.tooltip = (($) ->
|
|
191
191
|
|
192
192
|
options = u.options(options, animation: config.closeAnimation)
|
193
193
|
animateOptions = up.motion.animateOptions(options, duration: config.closeDuration, easing: config.closeEasing)
|
194
|
-
u.
|
194
|
+
u.assign(options, animateOptions)
|
195
195
|
state.phase = 'closing'
|
196
196
|
up.destroy(state.$tooltip, options).then ->
|
197
197
|
state.phase = 'closed'
|