upjs-rails 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/dist/up.js CHANGED
@@ -12,12 +12,9 @@
12
12
  Utility functions
13
13
  =================
14
14
 
15
- All methods in this module are for internal use by the Up.js framework
16
- and will frequently change between releases.
17
-
18
- If you use them in your own code, you will get hurt.
19
-
20
- @protected
15
+ Up.js comes with a number of utility functions
16
+ that might save you from loading something like [Underscore.js](http://underscorejs.org/).
17
+
21
18
  @class up.util
22
19
  */
23
20
 
@@ -25,7 +22,12 @@ If you use them in your own code, you will get hurt.
25
22
  var slice = [].slice;
26
23
 
27
24
  up.util = (function($) {
28
- var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, any, cache, castedAttr, clientSize, compact, config, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, emptyJQuery, endsWith, error, escapePressed, evalConsoleTemplate, extend, findWithSelf, finishCssAnimate, fixedToAbsolute, forceCompositing, identity, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isNumber, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, last, locationFromXhr, map, measure, memoize, merge, methodFromXhr, multiSelector, nextFrame, normalizeMethod, normalizeUrl, nullJquery, offsetParent, once, only, option, options, parseUrl, presence, presentAttr, remove, resolvableWhen, resolvedDeferred, resolvedPromise, scrollbarWidth, select, setMissingAttrs, startsWith, temporaryCss, times, titleFromXhr, toArray, trim, unJquery, uniq, unresolvablePromise, unwrapElement, warn;
25
+
26
+ /**
27
+ @function up.util.memoize
28
+ @internal
29
+ */
30
+ var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, any, cache, castedAttr, clientSize, compact, config, contains, copy, copyAttributes, createElement, createElementFromHtml, cssAnimate, debug, detect, each, error, escapePressed, evalConsoleTemplate, extend, findWithSelf, finishCssAnimate, fixedToAbsolute, forceCompositing, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isNumber, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, last, locationFromXhr, map, measure, memoize, merge, methodFromXhr, multiSelector, nextFrame, normalizeMethod, normalizeUrl, nullJQuery, offsetParent, once, only, option, options, parseUrl, presence, presentAttr, remove, resolvableWhen, resolvedDeferred, resolvedPromise, scrollbarWidth, select, selectorForElement, setMissingAttrs, temporaryCss, times, titleFromXhr, toArray, trim, unJQuery, uniq, unresolvablePromise, unwrapElement, warn;
29
31
  memoize = function(func) {
30
32
  var cache, cached;
31
33
  cache = void 0;
@@ -41,6 +43,11 @@ If you use them in your own code, you will get hurt.
41
43
  }
42
44
  };
43
45
  };
46
+
47
+ /**
48
+ @function up.util.ajax
49
+ @internal
50
+ */
44
51
  ajax = function(request) {
45
52
  request = copy(request);
46
53
  if (request.selector) {
@@ -51,16 +58,19 @@ If you use them in your own code, you will get hurt.
51
58
  };
52
59
 
53
60
  /**
61
+ Returns if the given port is the default port for the given protocol.
62
+
54
63
  @function up.util.isStandardPort
55
- @private
64
+ @internal
56
65
  */
57
66
  isStandardPort = function(protocol, port) {
67
+ port = port.toString();
58
68
  return ((port === "" || port === "80") && protocol === 'http:') || (port === "443" && protocol === 'https:');
59
69
  };
60
70
 
61
71
  /**
62
- Normalizes URLs, relative paths and absolute paths to a full URL
63
- that can be checked for equality with other normalized URL.
72
+ Normalizes relative paths and absolute paths to a full URL
73
+ that can be checked for equality with other normalized URLs.
64
74
 
65
75
  By default hashes are ignored, search queries are included.
66
76
 
@@ -71,7 +81,7 @@ If you use them in your own code, you will get hurt.
71
81
  Whether to include a `?query` string in the normalized URL
72
82
  @param {Boolean} [options.stripTrailingSlash=false]
73
83
  Whether to strip a trailing slash from the pathname
74
- @protected
84
+ @internal
75
85
  */
76
86
  normalizeUrl = function(urlOrAnchor, options) {
77
87
  var anchor, normalized, pathname;
@@ -98,8 +108,17 @@ If you use them in your own code, you will get hurt.
98
108
  };
99
109
 
100
110
  /**
111
+ Parses the given URL into components such as hostname and path.
112
+
113
+ If the given URL is not fully qualified, it is assumed to be relative
114
+ to the current page.
115
+
101
116
  @function up.util.parseUrl
102
- @private
117
+ @return {Object}
118
+ The parsed URL as an object with
119
+ `protocol`, `hostname`, `port`, `pathname`, `search` and `hash`
120
+ properties.
121
+ @experimental
103
122
  */
104
123
  parseUrl = function(urlOrAnchor) {
105
124
  var anchor;
@@ -112,14 +131,14 @@ If you use them in your own code, you will get hurt.
112
131
  anchor.href = anchor.href;
113
132
  }
114
133
  } else {
115
- anchor = unJquery(urlOrAnchor);
134
+ anchor = unJQuery(urlOrAnchor);
116
135
  }
117
136
  return anchor;
118
137
  };
119
138
 
120
139
  /**
121
140
  @function up.util.normalizeMethod
122
- @protected
141
+ @internal
123
142
  */
124
143
  normalizeMethod = function(method) {
125
144
  if (method) {
@@ -128,6 +147,11 @@ If you use them in your own code, you will get hurt.
128
147
  return 'GET';
129
148
  }
130
149
  };
150
+
151
+ /**
152
+ @function $createElementFromSelector
153
+ @internal
154
+ */
131
155
  $createElementFromSelector = function(selector) {
132
156
  var $element, $parent, $root, classes, conjunction, depthSelector, expression, html, id, iteration, j, k, len, len1, path, tag;
133
157
  path = selector.split(/[ >]/);
@@ -180,8 +204,12 @@ If you use them in your own code, you will get hurt.
180
204
  };
181
205
 
182
206
  /**
207
+ Prints a debugging message to the browser console.
208
+
183
209
  @function up.debug
184
- @protected
210
+ @param {String} message
211
+ @param {Array} args...
212
+ @internal
185
213
  */
186
214
  debug = function() {
187
215
  var args, message, ref;
@@ -192,7 +220,7 @@ If you use them in your own code, you will get hurt.
192
220
 
193
221
  /**
194
222
  @function up.warn
195
- @protected
223
+ @internal
196
224
  */
197
225
  warn = function() {
198
226
  var args, message, ref;
@@ -214,6 +242,7 @@ If you use them in your own code, you will get hurt.
214
242
  up.error('Unexpected result %o', result)
215
243
 
216
244
  @function up.error
245
+ @internal
217
246
  */
218
247
  error = function() {
219
248
  var $error, args, asString, ref;
@@ -260,7 +289,24 @@ If you use them in your own code, you will get hurt.
260
289
  return arg;
261
290
  });
262
291
  };
263
- createSelectorFromElement = function(element) {
292
+
293
+ /**
294
+ Returns a CSS selector that matches the given element as good as possible.
295
+
296
+ This uses, in decreasing order of priority:
297
+
298
+ - The element's `up-id` attribute
299
+ - The element's ID
300
+ - The element's name
301
+ - The element's classes
302
+ - The element's tag names
303
+
304
+ @function up.util.selectorForElement
305
+ @param {String|Element|jQuery}
306
+ The element for which to create a selector.
307
+ @experimental
308
+ */
309
+ selectorForElement = function(element) {
264
310
  var $element, classString, classes, id, j, klass, len, name, selector, upId;
265
311
  $element = $(element);
266
312
  selector = void 0;
@@ -312,21 +358,70 @@ If you use them in your own code, you will get hurt.
312
358
  return createElement('div', html);
313
359
  }
314
360
  };
361
+
362
+ /**
363
+ Merge the contents of two or more objects together into the first object.
364
+
365
+ @function up.util.extend
366
+ @param {Object} target
367
+ @param {Array<Object>} sources...
368
+ @stable
369
+ */
315
370
  extend = $.extend;
371
+
372
+ /**
373
+ Returns a new string with whitespace removed from the beginning
374
+ and end of the given string.
375
+
376
+ @param {String}
377
+ A string that might have whitespace at the beginning and end.
378
+ @return {String}
379
+ The trimmed string.
380
+ @stable
381
+ */
316
382
  trim = $.trim;
317
- each = function(collection, block) {
383
+
384
+ /**
385
+ Calls the given function for each element (and, optional, index)
386
+ of the given array.
387
+
388
+ @function up.util.each
389
+ @param {Array} array
390
+ @param {Function<Object, Number>} block
391
+ A function that will be called with each element and (optional) iteration index.
392
+ @stable
393
+ */
394
+ each = function(array, block) {
318
395
  var index, item, j, len, results;
319
396
  results = [];
320
- for (index = j = 0, len = collection.length; j < len; index = ++j) {
321
- item = collection[index];
397
+ for (index = j = 0, len = array.length; j < len; index = ++j) {
398
+ item = array[index];
322
399
  results.push(block(item, index));
323
400
  }
324
401
  return results;
325
402
  };
403
+
404
+ /**
405
+ Translate all items in an array to new array of items.
406
+
407
+ @function up.util.map
408
+ @param {Array} array
409
+ @param {Function<Object, Number>} block
410
+ A function that will be called with each element and (optional) iteration index.
411
+ @return {Array}
412
+ A new array containing the result of each function call.
413
+ @stable
414
+ */
326
415
  map = each;
327
- identity = function(x) {
328
- return x;
329
- };
416
+
417
+ /**
418
+ Calls the given function for the given number of times.
419
+
420
+ @function up.util.times
421
+ @param {Number} count
422
+ @param {Function} block
423
+ @stable
424
+ */
330
425
  times = function(count, block) {
331
426
  var iteration, j, ref, results;
332
427
  results = [];
@@ -335,75 +430,281 @@ If you use them in your own code, you will get hurt.
335
430
  }
336
431
  return results;
337
432
  };
433
+
434
+ /**
435
+ Returns whether the given argument is `null`.
436
+
437
+ @function up.util.isNull
438
+ @param object
439
+ @return {Boolean}
440
+ @stable
441
+ */
338
442
  isNull = function(object) {
339
443
  return object === null;
340
444
  };
445
+
446
+ /**
447
+ Returns whether the given argument is `undefined`.
448
+
449
+ @function up.util.isUndefined
450
+ @param object
451
+ @return {Boolean}
452
+ @stable
453
+ */
341
454
  isUndefined = function(object) {
342
455
  return object === void(0);
343
456
  };
457
+
458
+ /**
459
+ Returns whether the given argument is not `undefined`.
460
+
461
+ @function up.util.isDefined
462
+ @param object
463
+ @return {Boolean}
464
+ @stable
465
+ */
344
466
  isDefined = function(object) {
345
467
  return !isUndefined(object);
346
468
  };
469
+
470
+ /**
471
+ Returns whether the given argument is either `undefined` or `null`.
472
+
473
+ Note that empty strings or zero are *not* considered to be "missing".
474
+
475
+ For the opposite of `up.util.isMissing` see [`up.util.isGiven`](/up.util.isGiven).
476
+
477
+ @function up.util.isMissing
478
+ @param object
479
+ @return {Boolean}
480
+ @stable
481
+ */
347
482
  isMissing = function(object) {
348
483
  return isUndefined(object) || isNull(object);
349
484
  };
485
+
486
+ /**
487
+ Returns whether the given argument is neither `undefined` nor `null`.
488
+
489
+ Note that empty strings or zero *are* considered to be "given".
490
+
491
+ For the opposite of `up.util.isGiven` see [`up.util.isMissing`](/up.util.isMissing).
492
+
493
+ @function up.util.isGiven
494
+ @param object
495
+ @return {Boolean}
496
+ @stable
497
+ */
350
498
  isGiven = function(object) {
351
499
  return !isMissing(object);
352
500
  };
501
+
502
+ /**
503
+ Return whether the given argument is considered to be blank.
504
+
505
+ This returns `true` for:
506
+
507
+ - `undefined`
508
+ - `null`
509
+ - Empty strings
510
+ - Empty arrays
511
+ - An object without own enumerable properties
512
+
513
+ All other arguments return `false`.
514
+
515
+ @function up.util.isBlank
516
+ @param object
517
+ @return {Boolean}
518
+ @stable
519
+ */
353
520
  isBlank = function(object) {
354
521
  return isMissing(object) || (isObject(object) && Object.keys(object).length === 0) || (object.length === 0);
355
522
  };
356
- presence = function(object, checker) {
357
- if (checker == null) {
358
- checker = isPresent;
523
+
524
+ /**
525
+ Returns the given argument if the argument is [present](/up.util.isPresent),
526
+ otherwise returns `undefined`.
527
+
528
+ @function up.util.presence
529
+ @param object
530
+ @param {Function<T>} [tester=up.util.isPresent]
531
+ The function that will be used to test whether the argument is present.
532
+ @return {T|Undefined}
533
+ @stable
534
+ */
535
+ presence = function(object, tester) {
536
+ if (tester == null) {
537
+ tester = isPresent;
359
538
  }
360
- if (checker(object)) {
539
+ if (tester(object)) {
361
540
  return object;
362
541
  } else {
363
- return null;
542
+ return void 0;
364
543
  }
365
544
  };
545
+
546
+ /**
547
+ Returns whether the given argument is not [blank](/up.util.isBlank).
548
+
549
+ @function up.util.isPresent
550
+ @param object
551
+ @return {Boolean}
552
+ @stable
553
+ */
366
554
  isPresent = function(object) {
367
555
  return !isBlank(object);
368
556
  };
557
+
558
+ /**
559
+ Returns whether the given argument is a function.
560
+
561
+ @function up.util.isFunction
562
+ @param object
563
+ @return {Boolean}
564
+ @stable
565
+ */
369
566
  isFunction = function(object) {
370
567
  return typeof object === 'function';
371
568
  };
569
+
570
+ /**
571
+ Returns whether the given argument is a string.
572
+
573
+ @function up.util.isString
574
+ @param object
575
+ @return {Boolean}
576
+ @stable
577
+ */
372
578
  isString = function(object) {
373
579
  return typeof object === 'string';
374
580
  };
581
+
582
+ /**
583
+ Returns whether the given argument is a number.
584
+
585
+ Note that this will check the argument's *type*.
586
+ It will return `false` for a string like `"123"`.
587
+
588
+ @function up.util.isNumber
589
+ @param object
590
+ @return {Boolean}
591
+ @stable
592
+ */
375
593
  isNumber = function(object) {
376
594
  return typeof object === 'number';
377
595
  };
596
+
597
+ /**
598
+ Returns whether the given argument is an object, but not a function.
599
+
600
+ @function up.util.isHash
601
+ @param object
602
+ @return {Boolean}
603
+ @stable
604
+ */
378
605
  isHash = function(object) {
379
606
  return typeof object === 'object' && !!object;
380
607
  };
608
+
609
+ /**
610
+ Returns whether the given argument is an object.
611
+
612
+ This also returns `true` for functions, which may behave like objects in Javascript.
613
+ For an alternative that returns `false` for functions, see [`up.util.isHash`](/up.util.isHash).
614
+
615
+ @function up.util.isObject
616
+ @param object
617
+ @return {Boolean}
618
+ @stable
619
+ */
381
620
  isObject = function(object) {
382
621
  return isHash(object) || (typeof object === 'function');
383
622
  };
623
+
624
+ /**
625
+ Returns whether the given argument is a DOM element.
626
+
627
+ @function up.util.isElement
628
+ @param object
629
+ @return {Boolean}
630
+ @stable
631
+ */
384
632
  isElement = function(object) {
385
633
  return !!(object && object.nodeType === 1);
386
634
  };
635
+
636
+ /**
637
+ Returns whether the given argument is a jQuery collection.
638
+
639
+ @function up.util.isJQuery
640
+ @param object
641
+ @return {Boolean}
642
+ @stable
643
+ */
387
644
  isJQuery = function(object) {
388
645
  return object instanceof jQuery;
389
646
  };
647
+
648
+ /**
649
+ Returns whether the given argument is an object with a `then` method.
650
+
651
+ @function up.util.isPromise
652
+ @param object
653
+ @return {Boolean}
654
+ @stable
655
+ */
390
656
  isPromise = function(object) {
391
657
  return isObject(object) && isFunction(object.then);
392
658
  };
659
+
660
+ /**
661
+ Returns whether the given argument is an object with `then` and `resolve` methods.
662
+
663
+ @function up.util.isDeferred
664
+ @param object
665
+ @return {Boolean}
666
+ @stable
667
+ */
393
668
  isDeferred = function(object) {
394
669
  return isPromise(object) && isFunction(object.resolve);
395
670
  };
396
- ifGiven = function(object) {
397
- if (isGiven(object)) {
398
- return object;
399
- }
400
- };
671
+
672
+ /**
673
+ Returns whether the given argument is an array.
674
+
675
+ @function up.util.isArray
676
+ @param object
677
+ @return {Boolean}
678
+ @stable
679
+ */
401
680
  isArray = Array.isArray || function(object) {
402
681
  return Object.prototype.toString.call(object) === '[object Array]';
403
682
  };
683
+
684
+ /**
685
+ Converts the given array-like argument into an array.
686
+
687
+ Returns the array.
688
+
689
+ @function up.util.isDeferred
690
+ @param object
691
+ @return {Array}
692
+ @stable
693
+ */
404
694
  toArray = function(object) {
405
695
  return Array.prototype.slice.call(object);
406
696
  };
697
+
698
+ /**
699
+ Shallow-copies the given array or object into a new array or object.
700
+
701
+ Returns the new array or object.
702
+
703
+ @function up.util.copy
704
+ @param {Object|Array} object
705
+ @return {Object|Array}
706
+ @stable
707
+ */
407
708
  copy = function(object) {
408
709
  if (isArray(object)) {
409
710
  return object.slice();
@@ -411,16 +712,49 @@ If you use them in your own code, you will get hurt.
411
712
  return extend({}, object);
412
713
  }
413
714
  };
414
- unJquery = function(object) {
715
+
716
+ /**
717
+ If given a jQuery collection, returns the underlying array of DOM element.
718
+ If given any other argument, returns the argument unchanged.
719
+
720
+ @function up.util.unJQuery
721
+ @param object
722
+ @internal
723
+ */
724
+ unJQuery = function(object) {
415
725
  if (isJQuery(object)) {
416
726
  return object.get(0);
417
727
  } else {
418
728
  return object;
419
729
  }
420
730
  };
421
- merge = function(object, otherObject) {
422
- return extend(copy(object), otherObject);
731
+
732
+ /**
733
+ Creates a new object by merging together the properties from the given objects.
734
+
735
+ @function up.util.merge
736
+ @param {Array<Object>} sources...
737
+ @return Object
738
+ @stable
739
+ */
740
+ merge = function() {
741
+ var sources;
742
+ sources = 1 <= arguments.length ? slice.call(arguments, 0) : [];
743
+ return extend.apply(null, [{}].concat(slice.call(sources)));
423
744
  };
745
+
746
+ /**
747
+ Creates an options hash from the given argument and some defaults.
748
+
749
+ The semantics of this function are confusing.
750
+ We want to get rid of this in the future.
751
+
752
+ @function up.util.options
753
+ @param {Object} object
754
+ @param {Object} [defaults]
755
+ @return {Object}
756
+ @internal
757
+ */
424
758
  options = function(object, defaults) {
425
759
  var defaultValue, key, merged, value;
426
760
  merged = object ? copy(object) : {};
@@ -448,6 +782,7 @@ If you use them in your own code, you will get hurt.
448
782
 
449
783
  @function up.util.option
450
784
  @param {Array} args...
785
+ @internal
451
786
  */
452
787
  option = function() {
453
788
  var arg, args, j, len, match, value;
@@ -466,6 +801,19 @@ If you use them in your own code, you will get hurt.
466
801
  }
467
802
  return match;
468
803
  };
804
+
805
+ /**
806
+ Passes each element in the given array to the given function.
807
+ Returns the first element for which the function returns a truthy value.
808
+
809
+ If no object matches, returns `undefined`.
810
+
811
+ @function up.util.detect
812
+ @param {Array<T>} array
813
+ @param {Function<T>} tester
814
+ @return {T|Undefined}
815
+ @stable
816
+ */
469
817
  detect = function(array, tester) {
470
818
  var element, j, len, match;
471
819
  match = void 0;
@@ -478,14 +826,51 @@ If you use them in your own code, you will get hurt.
478
826
  }
479
827
  return match;
480
828
  };
829
+
830
+ /**
831
+ Returns whether the given function returns a truthy value
832
+ for any element in the given array.
833
+
834
+ @function up.util.any
835
+ @param {Array<T>} array
836
+ @param {Function<T>} tester
837
+ @return {Boolean}
838
+ @experimental
839
+ */
481
840
  any = function(array, tester) {
482
- var match;
483
- match = detect(array, tester);
484
- return isDefined(match);
841
+ var element, j, len, match;
842
+ match = false;
843
+ for (j = 0, len = array.length; j < len; j++) {
844
+ element = array[j];
845
+ if (tester(element)) {
846
+ match = true;
847
+ break;
848
+ }
849
+ }
850
+ return match;
485
851
  };
852
+
853
+ /**
854
+ Returns all elements from the given array that are
855
+ neither `null` or `undefined`.
856
+
857
+ @function up.util.compact
858
+ @param {Array<T>} array
859
+ @return {Array<T>}
860
+ @stable
861
+ */
486
862
  compact = function(array) {
487
863
  return select(array, isGiven);
488
864
  };
865
+
866
+ /**
867
+ Returns the given array without duplicates.
868
+
869
+ @function up.util.uniq
870
+ @param {Array<T>} array
871
+ @return {Array<T>}
872
+ @stable
873
+ */
489
874
  uniq = function(array) {
490
875
  var seen;
491
876
  seen = {};
@@ -497,6 +882,16 @@ If you use them in your own code, you will get hurt.
497
882
  }
498
883
  });
499
884
  };
885
+
886
+ /**
887
+ Returns all elements from the given array that return
888
+ a truthy value when passed to the given function.
889
+
890
+ @function up.util.select
891
+ @param {Array<T>} array
892
+ @return {Array<T>}
893
+ @stable
894
+ */
500
895
  select = function(array, tester) {
501
896
  var matches;
502
897
  matches = [];
@@ -507,6 +902,14 @@ If you use them in your own code, you will get hurt.
507
902
  });
508
903
  return matches;
509
904
  };
905
+
906
+ /**
907
+ Returns the first [present](/up.util.isPresent) element attribute
908
+ among the given list of attribute names.
909
+
910
+ @function up.util.presentAttr
911
+ @internal
912
+ */
510
913
  presentAttr = function() {
511
914
  var $element, attrName, attrNames, values;
512
915
  $element = arguments[0], attrNames = 2 <= arguments.length ? slice.call(arguments, 1) : [];
@@ -521,12 +924,36 @@ If you use them in your own code, you will get hurt.
521
924
  })();
522
925
  return detect(values, isPresent);
523
926
  };
927
+
928
+ /**
929
+ Schedules the given function to be called in the
930
+ next Javascript execution frame.
931
+
932
+ @function up.util.nextFrame
933
+ @param {Function} block
934
+ @stable
935
+ */
524
936
  nextFrame = function(block) {
525
937
  return setTimeout(block, 0);
526
938
  };
939
+
940
+ /**
941
+ Returns the last element of the given array.
942
+
943
+ @function up.util.last
944
+ @param {Array<T>} array
945
+ @return {T}
946
+ */
527
947
  last = function(array) {
528
948
  return array[array.length - 1];
529
949
  };
950
+
951
+ /**
952
+ Measures the drawable area of the document.
953
+
954
+ @function up.util.clientSize
955
+ @internal
956
+ */
530
957
  clientSize = function() {
531
958
  var element;
532
959
  element = document.documentElement;
@@ -535,6 +962,15 @@ If you use them in your own code, you will get hurt.
535
962
  height: element.clientHeight
536
963
  };
537
964
  };
965
+
966
+ /**
967
+ Returns the width of a scrollbar.
968
+
969
+ This only runs once per page load.
970
+
971
+ @function up.util.scrollbarWidth
972
+ @internal
973
+ */
538
974
  scrollbarWidth = memoize(function() {
539
975
  var $outer, outer, width;
540
976
  $outer = $('<div>').css({
@@ -557,14 +993,17 @@ If you use them in your own code, you will get hurt.
557
993
  Subsequent calls will return the previous return value.
558
994
 
559
995
  @function up.util.once
560
- @private
996
+ @param {Function} fun
997
+ @experimental
561
998
  */
562
999
  once = function(fun) {
563
1000
  var result;
564
1001
  result = void 0;
565
1002
  return function() {
1003
+ var args;
1004
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
566
1005
  if (fun != null) {
567
- result = fun();
1006
+ result = fun.apply(null, args);
568
1007
  }
569
1008
  fun = void 0;
570
1009
  return result;
@@ -572,15 +1011,17 @@ If you use them in your own code, you will get hurt.
572
1011
  };
573
1012
 
574
1013
  /**
575
- * Temporarily sets the CSS for the given element.
576
- #
577
- * @function up.util.temporaryCss
578
- * @param {jQuery} $element
579
- * @param {Object} css
580
- * @param {Function} [block]
581
- * If given, the CSS is set, the block is called and
582
- * the old CSS is restored.
583
- * @private
1014
+ Temporarily sets the CSS for the given element.
1015
+
1016
+ @function up.util.temporaryCss
1017
+ @param {jQuery} $element
1018
+ @param {Object} css
1019
+ @param {Function} [block]
1020
+ If given, the CSS is set, the block is called and
1021
+ the old CSS is restored.
1022
+ @return {Function}
1023
+ A function that restores the original CSS when called.
1024
+ @internal
584
1025
  */
585
1026
  temporaryCss = function($element, css, block) {
586
1027
  var memo, oldCss;
@@ -596,6 +1037,13 @@ If you use them in your own code, you will get hurt.
596
1037
  return once(memo);
597
1038
  }
598
1039
  };
1040
+
1041
+ /**
1042
+ Forces the given jQuery element into an accelerated compositing layer.
1043
+
1044
+ @function up.util.forceCompositing
1045
+ @internal
1046
+ */
599
1047
  forceCompositing = function($element) {
600
1048
  var memo, oldTransforms;
601
1049
  oldTransforms = $element.css(['transform', '-webkit-transform']);
@@ -637,6 +1085,7 @@ If you use them in your own code, you will get hurt.
637
1085
  for a list of pre-defined timing functions.
638
1086
  @return
639
1087
  A promise for the animation's end.
1088
+ @internal
640
1089
  */
641
1090
  cssAnimate = function(elementOrSelector, lastFrame, opts) {
642
1091
  var $element, deferred, endTimeout, transition, withoutCompositing, withoutTransition;
@@ -687,8 +1136,8 @@ If you use them in your own code, you will get hurt.
687
1136
  Also see [`up.motion.finish`](/up.motion.finish).
688
1137
 
689
1138
  @function up.util.finishCssAnimate
690
- @protected
691
1139
  @param {Element|jQuery|String} elementOrSelector
1140
+ @internal
692
1141
  */
693
1142
  finishCssAnimate = function(elementOrSelector) {
694
1143
  return $(elementOrSelector).each(function() {
@@ -698,6 +1147,13 @@ If you use them in your own code, you will get hurt.
698
1147
  }
699
1148
  });
700
1149
  };
1150
+
1151
+ /**
1152
+ Measures the given element.
1153
+
1154
+ @function up.util.measure
1155
+ @internal
1156
+ */
701
1157
  measure = function($element, opts) {
702
1158
  var $context, box, contextCoords, coordinates, elementCoords, viewport;
703
1159
  opts = options(opts, {
@@ -742,6 +1198,13 @@ If you use them in your own code, you will get hurt.
742
1198
  }
743
1199
  return box;
744
1200
  };
1201
+
1202
+ /**
1203
+ Copies all attributes from the source element to the target element.
1204
+
1205
+ @function up.util.copyAttributes
1206
+ @internal
1207
+ */
745
1208
  copyAttributes = function($source, $target) {
746
1209
  var attr, j, len, ref, results;
747
1210
  ref = $source.get(0).attributes;
@@ -756,21 +1219,43 @@ If you use them in your own code, you will get hurt.
756
1219
  }
757
1220
  return results;
758
1221
  };
1222
+
1223
+ /**
1224
+ Looks for the given selector in the element and its descendants.
1225
+
1226
+ @function up.util.findWithSelf
1227
+ @internal
1228
+ */
759
1229
  findWithSelf = function($element, selector) {
760
1230
  return $element.find(selector).addBack(selector);
761
1231
  };
1232
+
1233
+ /**
1234
+ Returns whether the given keyboard event involved the ESC key.
1235
+
1236
+ @function up.util.escapePressed
1237
+ @internal
1238
+ */
762
1239
  escapePressed = function(event) {
763
1240
  return event.keyCode === 27;
764
1241
  };
765
- startsWith = function(string, element) {
766
- return string.indexOf(element) === 0;
767
- };
768
- endsWith = function(string, element) {
769
- return string.indexOf(element) === string.length - element.length;
770
- };
771
- contains = function(stringOrArray, element) {
772
- return stringOrArray.indexOf(element) >= 0;
1242
+
1243
+ /**
1244
+ Returns whether the given array or string contains the given element or substring.
1245
+
1246
+ @function up.util.contains
1247
+ @param {Array|String} arrayOrString
1248
+ @param elementOrSubstring
1249
+ @stable
1250
+ */
1251
+ contains = function(arrayOrString, elementOrSubstring) {
1252
+ return arrayOrString.indexOf(elementOrSubstring) >= 0;
773
1253
  };
1254
+
1255
+ /**
1256
+ @function up.util.castedAttr
1257
+ @internal
1258
+ */
774
1259
  castedAttr = function($element, attrName) {
775
1260
  var value;
776
1261
  value = $element.attr(attrName);
@@ -785,58 +1270,127 @@ If you use them in your own code, you will get hurt.
785
1270
  return value;
786
1271
  }
787
1272
  };
1273
+
1274
+ /**
1275
+ @function up.util.locationFromXhr
1276
+ @internal
1277
+ */
788
1278
  locationFromXhr = function(xhr) {
789
1279
  return xhr.getResponseHeader('X-Up-Location');
790
1280
  };
1281
+
1282
+ /**
1283
+ @function up.util.titleFromXhr
1284
+ @internal
1285
+ */
791
1286
  titleFromXhr = function(xhr) {
792
1287
  return xhr.getResponseHeader('X-Up-Title');
793
1288
  };
1289
+
1290
+ /**
1291
+ @function up.util.methodFromXhr
1292
+ @internal
1293
+ */
794
1294
  methodFromXhr = function(xhr) {
795
1295
  return xhr.getResponseHeader('X-Up-Method');
796
1296
  };
1297
+
1298
+ /**
1299
+ Returns a copy of the given object that only contains
1300
+ the given properties.
1301
+
1302
+ @function up.util.only
1303
+ @param {Object} object
1304
+ @param {Array} keys...
1305
+ @stable
1306
+ */
797
1307
  only = function() {
798
- var filtered, j, key, keys, len, object;
799
- object = arguments[0], keys = 2 <= arguments.length ? slice.call(arguments, 1) : [];
1308
+ var filtered, j, len, object, properties, property;
1309
+ object = arguments[0], properties = 2 <= arguments.length ? slice.call(arguments, 1) : [];
800
1310
  filtered = {};
801
- for (j = 0, len = keys.length; j < len; j++) {
802
- key = keys[j];
803
- if (object.hasOwnProperty(key)) {
804
- filtered[key] = object[key];
1311
+ for (j = 0, len = properties.length; j < len; j++) {
1312
+ property = properties[j];
1313
+ if (object.hasOwnProperty(property)) {
1314
+ filtered[property] = object[property];
805
1315
  }
806
1316
  }
807
1317
  return filtered;
808
1318
  };
1319
+
1320
+ /**
1321
+ @function up.util.isUnmodifiedKeyEvent
1322
+ @internal
1323
+ */
809
1324
  isUnmodifiedKeyEvent = function(event) {
810
1325
  return !(event.metaKey || event.shiftKey || event.ctrlKey);
811
1326
  };
1327
+
1328
+ /**
1329
+ @function up.util.isUnmodifiedMouseEvent
1330
+ @internal
1331
+ */
812
1332
  isUnmodifiedMouseEvent = function(event) {
813
1333
  var isLeftButton;
814
1334
  isLeftButton = isUndefined(event.button) || event.button === 0;
815
1335
  return isLeftButton && isUnmodifiedKeyEvent(event);
816
1336
  };
1337
+
1338
+ /**
1339
+ Returns a [Deferred object](https://api.jquery.com/category/deferred-object/) that is
1340
+ already resolved.
1341
+
1342
+ @function up.util.resolvedDeferred
1343
+ @return {Deferred}
1344
+ @stable
1345
+ */
817
1346
  resolvedDeferred = function() {
818
1347
  var deferred;
819
1348
  deferred = $.Deferred();
820
1349
  deferred.resolve();
821
1350
  return deferred;
822
1351
  };
1352
+
1353
+ /**
1354
+ Returns a promise that is already resolved.
1355
+
1356
+ @function up.util.resolvedPromise
1357
+ @return {Promise}
1358
+ @stable
1359
+ */
823
1360
  resolvedPromise = function() {
824
1361
  return resolvedDeferred().promise();
825
1362
  };
1363
+
1364
+ /**
1365
+ Returns a promise that will never be resolved.
1366
+
1367
+ @function up.util.unresolvablePromise
1368
+ @experimental
1369
+ */
826
1370
  unresolvablePromise = function() {
827
1371
  return $.Deferred().promise();
828
1372
  };
829
- nullJquery = function() {
830
- return {
831
- is: function() {
832
- return false;
833
- },
834
- attr: function() {},
835
- find: function() {
836
- return [];
837
- }
838
- };
1373
+
1374
+ /**
1375
+ Returns an empty jQuery collection.
1376
+
1377
+ @function up.util.nullJQuery
1378
+ @internal
1379
+ */
1380
+ nullJQuery = function() {
1381
+ return $();
839
1382
  };
1383
+
1384
+ /**
1385
+ Returns a new promise that resolves once all promises in arguments resolve.
1386
+
1387
+ Other then [`$.when` from jQuery](https://api.jquery.com/jquery.when/),
1388
+ the combined promise will have a `resolve` method. This `resolve` method
1389
+ will resolve all the wrapped promises.
1390
+
1391
+ @function up.util.resolvableWhen
1392
+ @internal
1393
+ */
840
1394
  resolvableWhen = function() {
841
1395
  var deferreds, joined;
842
1396
  deferreds = 1 <= arguments.length ? slice.call(arguments, 0) : [];
@@ -848,6 +1402,13 @@ If you use them in your own code, you will get hurt.
848
1402
  };
849
1403
  return joined;
850
1404
  };
1405
+
1406
+ /**
1407
+ On the given element, set attributes that are still missing.
1408
+
1409
+ @function up.util.setMissingAttrs
1410
+ @internal
1411
+ */
851
1412
  setMissingAttrs = function($element, attrs) {
852
1413
  var key, results, value;
853
1414
  results = [];
@@ -861,6 +1422,17 @@ If you use them in your own code, you will get hurt.
861
1422
  }
862
1423
  return results;
863
1424
  };
1425
+
1426
+ /**
1427
+ Removes the given element from the given array.
1428
+
1429
+ This changes the given array.
1430
+
1431
+ @function up.util.remove
1432
+ @param {Array<T>} array
1433
+ @param {T} element
1434
+ @stable
1435
+ */
864
1436
  remove = function(array, element) {
865
1437
  var index;
866
1438
  index = array.indexOf(element);
@@ -869,9 +1441,11 @@ If you use them in your own code, you will get hurt.
869
1441
  return element;
870
1442
  }
871
1443
  };
872
- emptyJQuery = function() {
873
- return $([]);
874
- };
1444
+
1445
+ /**
1446
+ @function up.util.multiSelector
1447
+ @internal
1448
+ */
875
1449
  multiSelector = function(parts) {
876
1450
  var combinedSelector, elements, j, len, obj, part, selectors;
877
1451
  obj = {};
@@ -895,7 +1469,7 @@ If you use them in your own code, you will get hurt.
895
1469
  };
896
1470
  obj.find = function($root) {
897
1471
  var $matches, $result, k, len1, ref, selector;
898
- $result = emptyJQuery();
1472
+ $result = nullJQuery();
899
1473
  ref = obj.parsed;
900
1474
  for (k = 0, len1 = ref.length; k < len1; k++) {
901
1475
  selector = ref[k];
@@ -931,7 +1505,7 @@ If you use them in your own code, you will get hurt.
931
1505
  }
932
1506
  $element = $element.parent();
933
1507
  }
934
- return $result || emptyJQuery();
1508
+ return $result || nullJQuery();
935
1509
  };
936
1510
  return obj;
937
1511
  };
@@ -949,6 +1523,7 @@ If you use them in your own code, you will get hurt.
949
1523
  @param {Function<Object>} [config.key]
950
1524
  A function that takes an argument and returns a `String` key
951
1525
  for storage. If omitted, `toString()` is called on the argument.
1526
+ @internal
952
1527
  */
953
1528
  cache = function(config) {
954
1529
  var alias, clear, expiryMilis, get, isFresh, keys, log, maxSize, normalizeStoreKey, set, store, timestamp;
@@ -1083,6 +1658,11 @@ If you use them in your own code, you will get hurt.
1083
1658
  keys: keys
1084
1659
  };
1085
1660
  };
1661
+
1662
+ /**
1663
+ @function up.util.config
1664
+ @internal
1665
+ */
1086
1666
  config = function(factoryOptions) {
1087
1667
  var hash;
1088
1668
  if (factoryOptions == null) {
@@ -1096,9 +1676,14 @@ If you use them in your own code, you will get hurt.
1096
1676
  Object.preventExtensions(hash);
1097
1677
  return hash;
1098
1678
  };
1679
+
1680
+ /**
1681
+ @function up.util.unwrapElement
1682
+ @internal
1683
+ */
1099
1684
  unwrapElement = function(wrapper) {
1100
1685
  var parent, wrappedNodes;
1101
- wrapper = unJquery(wrapper);
1686
+ wrapper = unJQuery(wrapper);
1102
1687
  parent = wrapper.parentNode;
1103
1688
  wrappedNodes = toArray(wrapper.childNodes);
1104
1689
  each(wrappedNodes, function(wrappedNode) {
@@ -1106,6 +1691,11 @@ If you use them in your own code, you will get hurt.
1106
1691
  });
1107
1692
  return parent.removeChild(wrapper);
1108
1693
  };
1694
+
1695
+ /**
1696
+ @function up.util.offsetParent
1697
+ @internal
1698
+ */
1109
1699
  offsetParent = function($element) {
1110
1700
  var $match, position;
1111
1701
  $match = void 0;
@@ -1118,6 +1708,11 @@ If you use them in your own code, you will get hurt.
1118
1708
  }
1119
1709
  return $match;
1120
1710
  };
1711
+
1712
+ /**
1713
+ @function up.util.fixedToAbsolute
1714
+ @internal
1715
+ */
1121
1716
  fixedToAbsolute = function(element, $viewport) {
1122
1717
  var $element, $futureOffsetParent, elementCoords, futureParentCoords;
1123
1718
  $element = $(element);
@@ -1142,7 +1737,7 @@ If you use them in your own code, you will get hurt.
1142
1737
  normalizeMethod: normalizeMethod,
1143
1738
  createElementFromHtml: createElementFromHtml,
1144
1739
  $createElementFromSelector: $createElementFromSelector,
1145
- createSelectorFromElement: createSelectorFromElement,
1740
+ selectorForElement: selectorForElement,
1146
1741
  ajax: ajax,
1147
1742
  extend: extend,
1148
1743
  copy: copy,
@@ -1154,7 +1749,6 @@ If you use them in your own code, you will get hurt.
1154
1749
  warn: warn,
1155
1750
  each: each,
1156
1751
  map: map,
1157
- identity: identity,
1158
1752
  times: times,
1159
1753
  any: any,
1160
1754
  detect: detect,
@@ -1178,11 +1772,10 @@ If you use them in your own code, you will get hurt.
1178
1772
  isPromise: isPromise,
1179
1773
  isDeferred: isDeferred,
1180
1774
  isHash: isHash,
1181
- ifGiven: ifGiven,
1182
1775
  isUnmodifiedKeyEvent: isUnmodifiedKeyEvent,
1183
1776
  isUnmodifiedMouseEvent: isUnmodifiedMouseEvent,
1184
- nullJquery: nullJquery,
1185
- unJquery: unJquery,
1777
+ nullJQuery: nullJQuery,
1778
+ unJQuery: unJQuery,
1186
1779
  nextFrame: nextFrame,
1187
1780
  measure: measure,
1188
1781
  temporaryCss: temporaryCss,
@@ -1193,8 +1786,6 @@ If you use them in your own code, you will get hurt.
1193
1786
  copyAttributes: copyAttributes,
1194
1787
  findWithSelf: findWithSelf,
1195
1788
  contains: contains,
1196
- startsWith: startsWith,
1197
- endsWith: endsWith,
1198
1789
  isArray: isArray,
1199
1790
  toArray: toArray,
1200
1791
  castedAttr: castedAttr,
@@ -1216,7 +1807,6 @@ If you use them in your own code, you will get hurt.
1216
1807
  cache: cache,
1217
1808
  unwrapElement: unwrapElement,
1218
1809
  multiSelector: multiSelector,
1219
- emptyJQuery: emptyJQuery,
1220
1810
  evalConsoleTemplate: evalConsoleTemplate
1221
1811
  };
1222
1812
  })($);
@@ -1236,7 +1826,6 @@ Browser interface
1236
1826
  Some browser-interfacing methods and switches that
1237
1827
  we can't currently get rid off.
1238
1828
 
1239
- @protected
1240
1829
  @class up.browser
1241
1830
  */
1242
1831
 
@@ -1280,8 +1869,13 @@ we can't currently get rid off.
1280
1869
  It also prints substitution strings (e.g. `console.log("From %o to %o", "a", "b")`)
1281
1870
  as a single string if the browser console does not support substitution strings.
1282
1871
 
1872
+ \#\#\#\# Example
1873
+
1874
+ up.browser.puts('log', 'Hi world');
1875
+ up.browser.puts('error', 'There was an error in %o', obj);
1876
+
1283
1877
  @function up.browser.puts
1284
- @protected
1878
+ @internal
1285
1879
  */
1286
1880
  puts = function() {
1287
1881
  var args, message, stream;
@@ -1344,6 +1938,7 @@ we can't currently get rid off.
1344
1938
  This leaves you with a classic server-side application.
1345
1939
 
1346
1940
  @function up.browser.isSupported
1941
+ @experimental
1347
1942
  */
1348
1943
  isSupported = function() {
1349
1944
  return (!isIE8OrWorse()) && isRecentJQuery();
@@ -1491,6 +2086,7 @@ and call `preventDefault()` on the `event` object:
1491
2086
  and passed as a second argument.
1492
2087
  @return {Function}
1493
2088
  A function that unbinds the event listeners when called.
2089
+ @stable
1494
2090
  */
1495
2091
  live = function() {
1496
2092
  var $document, args, behavior, description, lastIndex;
@@ -1532,7 +2128,7 @@ and call `preventDefault()` on the `event` object:
1532
2128
  or `stopPropagation()`.
1533
2129
  @param {jQuery} [eventProps.$element=$(document)]
1534
2130
  The element on which the event is trigered.
1535
- @protected
2131
+ @experimental
1536
2132
  */
1537
2133
  emit = function(eventName, eventProps) {
1538
2134
  var $target, event;
@@ -1553,7 +2149,7 @@ and call `preventDefault()` on the `event` object:
1553
2149
  @function up.bus.nobodyPrevents
1554
2150
  @param {String} eventName
1555
2151
  @param {Object} eventProps
1556
- @protected
2152
+ @experimental
1557
2153
  */
1558
2154
  nobodyPrevents = function() {
1559
2155
  var args, event;
@@ -1571,7 +2167,7 @@ and call `preventDefault()` on the `event` object:
1571
2167
  The listener function to register.
1572
2168
  @return {Function}
1573
2169
  A function that unbinds the event listeners when called.
1574
- @protected
2170
+ @experimental
1575
2171
  */
1576
2172
  onEscape = function(listener) {
1577
2173
  return live('keydown', 'body', function(event) {
@@ -1585,7 +2181,7 @@ and call `preventDefault()` on the `event` object:
1585
2181
  Makes a snapshot of the currently registered event listeners,
1586
2182
  to later be restored through [`up.bus.reset`](/up.bus.reset).
1587
2183
 
1588
- @private
2184
+ @internal
1589
2185
  */
1590
2186
  snapshot = function() {
1591
2187
  return defaultLiveDescriptions = u.copy(liveDescriptions);
@@ -1595,7 +2191,7 @@ and call `preventDefault()` on the `event` object:
1595
2191
  Resets the list of registered event listeners to the
1596
2192
  moment when the framework was booted.
1597
2193
 
1598
- @private
2194
+ @internal
1599
2195
  */
1600
2196
  restoreSnapshot = function() {
1601
2197
  var description, i, len, ref;
@@ -1616,8 +2212,8 @@ and call `preventDefault()` on the `event` object:
1616
2212
  This is an internal method for to enable unit testing.
1617
2213
  Don't use this in production.
1618
2214
 
1619
- @protected
1620
2215
  @function up.reset
2216
+ @experimental
1621
2217
  */
1622
2218
  emitReset = function() {
1623
2219
  return up.emit('up:framework:reset');
@@ -1626,8 +2222,8 @@ and call `preventDefault()` on the `event` object:
1626
2222
  /**
1627
2223
  This event is [emitted](/up.emit) when Up.js is [reset](/up.reset) during unit tests.
1628
2224
 
1629
- @protected
1630
2225
  @event up:framework:reset
2226
+ @experimental
1631
2227
  */
1632
2228
 
1633
2229
  /**
@@ -1638,8 +2234,8 @@ and call `preventDefault()` on the `event` object:
1638
2234
 
1639
2235
  Emits the [`up:framework:boot`](/up:framework:boot) event.
1640
2236
 
1641
- @protected
1642
2237
  @function up.boot
2238
+ @experimental
1643
2239
  */
1644
2240
  boot = function() {
1645
2241
  if (up.browser.isSupported()) {
@@ -1651,7 +2247,7 @@ and call `preventDefault()` on the `event` object:
1651
2247
  This event is [emitted](/up.emit) when Up.js [boots](/up.boot).
1652
2248
 
1653
2249
  @event up:framework:boot
1654
- @protected
2250
+ @experimental
1655
2251
  */
1656
2252
  live('up:framework:boot', snapshot);
1657
2253
  live('up:framework:reset', restoreSnapshot);
@@ -1871,6 +2467,7 @@ later.
1871
2467
  clear global state such as time-outs and event handlers bound to the document.
1872
2468
  The destructor is *not* expected to remove the element from the DOM, which
1873
2469
  is already handled by [`up.destroy`](/up.destroy).
2470
+ @stable
1874
2471
  */
1875
2472
  compilers = [];
1876
2473
  defaultCompilers = null;
@@ -1935,16 +2532,13 @@ later.
1935
2532
 
1936
2533
  Returns an empty object if the element has no `up-data` attribute.
1937
2534
 
1938
- The API of this method is likely to change in the future, so
1939
- we can support getting or setting individual keys.
1940
-
1941
- @protected
1942
2535
  @function up.syntax.data
1943
2536
  @param {String|Element|jQuery} elementOrSelector
1944
2537
  @return
1945
2538
  The JSON-decoded value of the `up-data` attribute.
1946
2539
 
1947
2540
  Returns an empty object (`{}`) if the element has no (or an empty) `up-data` attribute.
2541
+ @experimental
1948
2542
  */
1949
2543
 
1950
2544
  /*
@@ -1959,6 +2553,7 @@ later.
1959
2553
  @selector [up-data]
1960
2554
  @param {JSON} up-data
1961
2555
  A serialized JSON string
2556
+ @stable
1962
2557
  */
1963
2558
  data = function(elementOrSelector) {
1964
2559
  var $element, json;
@@ -1975,7 +2570,7 @@ later.
1975
2570
  Makes a snapshot of the currently registered event listeners,
1976
2571
  to later be restored through `reset`.
1977
2572
 
1978
- @private
2573
+ @internal
1979
2574
  */
1980
2575
  snapshot = function() {
1981
2576
  return defaultCompilers = u.copy(compilers);
@@ -1985,7 +2580,7 @@ later.
1985
2580
  Resets the list of registered compiler directives to the
1986
2581
  moment when the framework was booted.
1987
2582
 
1988
- @private
2583
+ @internal
1989
2584
  */
1990
2585
  reset = function() {
1991
2586
  return compilers = u.copy(defaultCompilers);
@@ -2010,6 +2605,7 @@ later.
2010
2605
 
2011
2606
  @function up.hello
2012
2607
  @param {String|Element|jQuery} selectorOrElement
2608
+ @stable
2013
2609
  */
2014
2610
  hello = function(selectorOrElement) {
2015
2611
  var $element;
@@ -2033,6 +2629,7 @@ later.
2033
2629
  @event up:fragment:inserted
2034
2630
  @param {jQuery} event.$element
2035
2631
  The fragment that has been inserted or updated.
2632
+ @stable
2036
2633
  */
2037
2634
  up.on('ready', (function() {
2038
2635
  return hello(document.body);
@@ -2108,7 +2705,7 @@ We need to work on this page:
2108
2705
  [`up.history.replace`](/up.history.replace).
2109
2706
 
2110
2707
  @function up.history.previousUrl
2111
- @protected
2708
+ @internal
2112
2709
  */
2113
2710
  previousUrl = void 0;
2114
2711
  nextPreviousUrl = void 0;
@@ -2127,7 +2724,7 @@ We need to work on this page:
2127
2724
  Returns a normalized URL for the current history entry.
2128
2725
 
2129
2726
  @function up.history.url
2130
- @protected
2727
+ @experimental
2131
2728
  */
2132
2729
  currentUrl = function() {
2133
2730
  return normalizeUrl(up.browser.url());
@@ -2144,19 +2741,41 @@ We need to work on this page:
2144
2741
  };
2145
2742
 
2146
2743
  /**
2744
+ Replaces the current history entry and updates the
2745
+ browser's location bar with the given URL.
2746
+
2747
+ When the user navigates to the replaced history entry at a later time,
2748
+ Up.js will [`replace`](/up.replace) the document body with
2749
+ the body from that URL.
2750
+
2751
+ Note that functions like [`up.replace`](/up.replace) or
2752
+ [`up.submit`](/up.submit) will automatically update the
2753
+ browser's location bar for you.
2754
+
2147
2755
  @function up.history.replace
2148
2756
  @param {String} url
2149
2757
  @param {Boolean} [options.force=false]
2150
- @protected
2758
+ @experimental
2151
2759
  */
2152
2760
  replace = function(url, options) {
2153
2761
  return manipulate('replace', url, options);
2154
2762
  };
2155
2763
 
2156
2764
  /**
2765
+ Adds a new history entry and updates the browser's
2766
+ address bar with the given URL.
2767
+
2768
+ When the user navigates to the added history entry at a later time,
2769
+ Up.js will [`replace`](/up.replace) the document body with
2770
+ the body from that URL.
2771
+
2772
+ Note that functions like [`up.replace`](/up.replace) or
2773
+ [`up.submit`](/up.submit) will automatically update the
2774
+ browser's location bar for you.
2775
+
2157
2776
  @function up.history.push
2158
2777
  @param {String} url
2159
- @protected
2778
+ @experimental
2160
2779
  */
2161
2780
  push = function(url, options) {
2162
2781
  return manipulate('push', url, options);
@@ -2245,6 +2864,7 @@ We need to work on this page:
2245
2864
  </a>
2246
2865
 
2247
2866
  @selector [up-back]
2867
+ @stable
2248
2868
  */
2249
2869
  up.compiler('[up-back]', function($link) {
2250
2870
  if (u.isPresent(previousUrl)) {
@@ -2364,7 +2984,6 @@ This modules contains functions to scroll the viewport and reveal contained elem
2364
2984
  is called a second time, the previous animation will instantly jump to the
2365
2985
  last frame before the next animation is started.
2366
2986
 
2367
- @protected
2368
2987
  @function up.scroll
2369
2988
  @param {String|Element|jQuery} viewport
2370
2989
  The container element to scroll.
@@ -2376,6 +2995,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2376
2995
  The timing function that controls the acceleration for the scrolling's animation.
2377
2996
  @return {Deferred}
2378
2997
  A promise that will be resolved when the scrolling ends.
2998
+ @experimental
2379
2999
  */
2380
3000
  scroll = function(viewport, scrollTop, options) {
2381
3001
  var $viewport, deferred, duration, easing, targetProps;
@@ -2413,7 +3033,9 @@ This modules contains functions to scroll the viewport and reveal contained elem
2413
3033
 
2414
3034
  /**
2415
3035
  @function up.layout.finishScrolling
2416
- @private
3036
+ @param {String|Element|jQuery}
3037
+ The element that might currently be scrolling.
3038
+ @internal
2417
3039
  */
2418
3040
  finishScrolling = function(elementOrSelector) {
2419
3041
  return $(elementOrSelector).each(function() {
@@ -2426,7 +3048,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2426
3048
 
2427
3049
  /**
2428
3050
  @function up.layout.anchoredRight
2429
- @private
3051
+ @internal
2430
3052
  */
2431
3053
  anchoredRight = function() {
2432
3054
  return u.multiSelector(config.anchoredRight).select();
@@ -2507,6 +3129,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2507
3129
  with the top edge of the viewport.
2508
3130
  @return {Deferred}
2509
3131
  A promise that will be resolved when the element is revealed.
3132
+ @stable
2510
3133
  */
2511
3134
  reveal = function(elementOrSelector, options) {
2512
3135
  var $element, $viewport, elementDims, firstElementRow, lastElementRow, newScrollPos, obstruction, offsetShift, originalScrollPos, predictFirstVisibleRow, predictLastVisibleRow, snap, viewportHeight, viewportIsDocument;
@@ -2566,9 +3189,9 @@ This modules contains functions to scroll the viewport and reveal contained elem
2566
3189
 
2567
3190
  Throws an error if no viewport could be found.
2568
3191
 
2569
- @protected
2570
3192
  @function up.layout.viewportOf
2571
3193
  @param {String|Element|jQuery} selectorOrElement
3194
+ @internal
2572
3195
  */
2573
3196
  viewportOf = function(selectorOrElement) {
2574
3197
  var $element, $viewport;
@@ -2582,10 +3205,10 @@ This modules contains functions to scroll the viewport and reveal contained elem
2582
3205
  Returns a jQuery collection of all the viewports contained within the
2583
3206
  given selector or element.
2584
3207
 
2585
- @protected
2586
3208
  @function up.layout.viewportsWithin
2587
3209
  @param {String|Element|jQuery} selectorOrElement
2588
3210
  @return jQuery
3211
+ @internal
2589
3212
  */
2590
3213
  viewportsWithin = function(selectorOrElement) {
2591
3214
  var $element;
@@ -2596,8 +3219,8 @@ This modules contains functions to scroll the viewport and reveal contained elem
2596
3219
  /**
2597
3220
  Returns a jQuery collection of all the viewports on the screen.
2598
3221
 
2599
- @protected
2600
3222
  @function up.layout.viewports
3223
+ @internal
2601
3224
  */
2602
3225
  viewports = function() {
2603
3226
  return viewportSelector().select();
@@ -2614,7 +3237,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2614
3237
 
2615
3238
  @function up.layout.scrollTops
2616
3239
  @return Object<String, Number>
2617
- @protected
3240
+ @internal
2618
3241
  */
2619
3242
  scrollTops = function() {
2620
3243
  var $viewport, i, key, len, ref, topsBySelector, viewport;
@@ -2636,7 +3259,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2636
3259
 
2637
3260
  /**
2638
3261
  @function up.layout.fixedChildren
2639
- @protected
3262
+ @internal
2640
3263
  */
2641
3264
  fixedChildren = function(root) {
2642
3265
  var $elements, $root;
@@ -2668,7 +3291,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2668
3291
  @function up.layout.saveScroll
2669
3292
  @param {String} [options.url]
2670
3293
  @param {Object<String, Number>} [options.tops]
2671
- @protected
3294
+ @experimental
2672
3295
  */
2673
3296
  saveScroll = function(options) {
2674
3297
  var tops, url;
@@ -2692,7 +3315,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2692
3315
  @param {jQuery} [options.around]
2693
3316
  If set, only restores viewports that are either an ancestor
2694
3317
  or descendant of the given element.
2695
- @protected
3318
+ @experimental
2696
3319
  */
2697
3320
  restoreScroll = function(options) {
2698
3321
  var $ancestorViewports, $descendantViewports, $matchingViewport, $viewports, key, right, scrollTop, tops, url;
@@ -2722,9 +3345,10 @@ This modules contains functions to scroll the viewport and reveal contained elem
2722
3345
  };
2723
3346
 
2724
3347
  /**
2725
- @protected
2726
3348
  @function up.layout.revealOrRestoreScroll
2727
- @return {Deferred} A promise for when the revealing or scroll restauration ends
3349
+ @return {Deferred}
3350
+ A promise for when the revealing or scroll restauration ends
3351
+ @internal
2728
3352
  */
2729
3353
  revealOrRestoreScroll = function(selectorOrElement, options) {
2730
3354
  var $element, $target, id, parsed;
@@ -2800,6 +3424,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2800
3424
  </div>
2801
3425
 
2802
3426
  @selector [up-viewport]
3427
+ @stable
2803
3428
  */
2804
3429
 
2805
3430
  /**
@@ -2814,6 +3439,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2814
3439
  <div class="top-nav" up-fixed="top">...</div>
2815
3440
 
2816
3441
  @selector [up-fixed=top]
3442
+ @stable
2817
3443
  */
2818
3444
 
2819
3445
  /**
@@ -2828,6 +3454,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2828
3454
  <div class="bottom-nav" up-fixed="bottom">...</div>
2829
3455
 
2830
3456
  @selector [up-fixed=bottom]
3457
+ @stable
2831
3458
  */
2832
3459
  up.on('up:framework:reset', reset);
2833
3460
  return {
@@ -2890,7 +3517,7 @@ are based on this module.
2890
3517
 
2891
3518
  /**
2892
3519
  @function up.flow.resolveSelector
2893
- @private
3520
+ @internal
2894
3521
  */
2895
3522
  resolveSelector = function(selectorOrElement, options) {
2896
3523
  var origin, originSelector, selector;
@@ -2898,14 +3525,14 @@ are based on this module.
2898
3525
  selector = selectorOrElement;
2899
3526
  if (u.contains(selector, '&')) {
2900
3527
  if (origin = u.presence(options.origin)) {
2901
- originSelector = u.createSelectorFromElement(origin);
3528
+ originSelector = u.selectorForElement(origin);
2902
3529
  selector = selector.replace(/\&/, originSelector);
2903
3530
  } else {
2904
3531
  u.error("Found origin reference %o in selector %o, but options.origin is missing", '&', selector);
2905
3532
  }
2906
3533
  }
2907
3534
  } else {
2908
- selector = u.createSelectorFromElement(selectorOrElement);
3535
+ selector = u.selectorForElement(selectorOrElement);
2909
3536
  }
2910
3537
  return selector;
2911
3538
  };
@@ -3015,6 +3642,7 @@ are based on this module.
3015
3642
  with the request.
3016
3643
  @return {Promise}
3017
3644
  A promise that will be resolved when the page has been updated.
3645
+ @stable
3018
3646
  */
3019
3647
  replace = function(selectorOrElement, url, options) {
3020
3648
  var promise, request, selector;
@@ -3091,12 +3719,12 @@ are based on this module.
3091
3719
  Note how only `.two` has changed. The update for `.one` was
3092
3720
  discarded, since it didn't match the selector.
3093
3721
 
3094
- @function up.flow.implant
3095
- @protected
3722
+ @function up.implant
3096
3723
  @param {String|Element|jQuery} selectorOrElement
3097
3724
  @param {String} html
3098
3725
  @param {Object} [options]
3099
3726
  See options for [`up.replace`](/up.replace).
3727
+ @experimental
3100
3728
  */
3101
3729
  implant = function(selectorOrElement, html, options) {
3102
3730
  var $new, $old, j, len, ref, response, results, selector, step;
@@ -3245,12 +3873,12 @@ are based on this module.
3245
3873
 
3246
3874
  Returns `undefined` if no element matches these conditions.
3247
3875
 
3248
- @protected
3249
3876
  @function up.first
3250
- @param {String|Element|jQuery} selectorOrElement
3877
+ @param {String|Element|jQuery|Array<Element>} selectorOrElement
3251
3878
  @return {jQuery}
3252
3879
  The first element that is neither a ghost or being destroyed,
3253
3880
  or `undefined` if no such element was given.
3881
+ @experimental
3254
3882
  */
3255
3883
  first = function(selectorOrElement) {
3256
3884
  var $element, $match, element, elements, j, len;
@@ -3297,6 +3925,7 @@ are based on this module.
3297
3925
  The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
3298
3926
  @return {Deferred}
3299
3927
  A promise that will be resolved once the element has been removed from the DOM.
3928
+ @stable
3300
3929
  */
3301
3930
  destroy = function(selectorOrElement, options) {
3302
3931
  var $element, animateOptions, animationDeferred;
@@ -3340,6 +3969,7 @@ are based on this module.
3340
3969
  The page fragment that is about to be destroyed.
3341
3970
  @param event.preventDefault()
3342
3971
  Event listeners may call this method to prevent the fragment from being destroyed.
3972
+ @stable
3343
3973
  */
3344
3974
 
3345
3975
  /**
@@ -3352,6 +3982,7 @@ are based on this module.
3352
3982
  @event up:fragment:destroyed
3353
3983
  @param {jQuery} event.$element
3354
3984
  The page fragment that is about to be removed from the DOM.
3985
+ @stable
3355
3986
  */
3356
3987
 
3357
3988
  /**
@@ -3373,6 +4004,7 @@ are based on this module.
3373
4004
  @param {String} [options.url]
3374
4005
  The URL from which to reload the fragment.
3375
4006
  This defaults to the URL from which the fragment was originally loaded.
4007
+ @stable
3376
4008
  */
3377
4009
  reload = function(selectorOrElement, options) {
3378
4010
  var sourceUrl;
@@ -3397,6 +4029,8 @@ are based on this module.
3397
4029
 
3398
4030
  up.replace = up.flow.replace;
3399
4031
 
4032
+ up.implant = up.flow.implant;
4033
+
3400
4034
  up.reload = up.flow.reload;
3401
4035
 
3402
4036
  up.destroy = up.flow.destroy;
@@ -3531,6 +4165,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3531
4165
  for a list of pre-defined timing functions.
3532
4166
  @return {Promise}
3533
4167
  A promise for the animation's end.
4168
+ @stable
3534
4169
  */
3535
4170
  animate = function(elementOrSelector, animation, options) {
3536
4171
  var $element;
@@ -3556,8 +4191,8 @@ or [transitions](/up.transition) using Javascript or CSS.
3556
4191
  If `$element` is given, also inspects the element for animation-related
3557
4192
  attributes like `up-easing` or `up-duration`.
3558
4193
 
3559
- @protected
3560
4194
  @function up.motion.animateOptions
4195
+ @internal
3561
4196
  */
3562
4197
  animateOptions = function(allOptions, $element) {
3563
4198
  var options;
@@ -3624,6 +4259,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3624
4259
 
3625
4260
  @function up.motion.finish
3626
4261
  @param {Element|jQuery|String} elementOrSelector
4262
+ @stable
3627
4263
  */
3628
4264
  finish = function(elementOrSelector) {
3629
4265
  return $(elementOrSelector).each(function() {
@@ -3709,6 +4345,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3709
4345
  Whether to reveal the new element by scrolling its parent viewport.
3710
4346
  @return {Promise}
3711
4347
  A promise for the transition's end.
4348
+ @stable
3712
4349
  */
3713
4350
  morph = function(source, target, transitionOrName, options) {
3714
4351
  var $new, $old, animation, deferred, parsedOptions, parts, transition;
@@ -3751,7 +4388,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3751
4388
  We use this to skip morphing for old browsers, or when the developer
3752
4389
  decides to only animate the new element (i.e. no real ghosting or transition) .
3753
4390
 
3754
- @private
4391
+ @internal
3755
4392
  */
3756
4393
  skipMorph = function($old, $new, options) {
3757
4394
  $old.hide();
@@ -3759,7 +4396,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3759
4396
  };
3760
4397
 
3761
4398
  /**
3762
- @private
4399
+ @internal
3763
4400
  */
3764
4401
  prependCopy = function($element, $viewport) {
3765
4402
  var $bounds, $fixedElements, $ghost, elementDims, fixedElement, i, len, moveTop, top;
@@ -3838,6 +4475,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3838
4475
  @function up.transition
3839
4476
  @param {String} name
3840
4477
  @param {Function} transition
4478
+ @stable
3841
4479
  */
3842
4480
  transition = function(name, transition) {
3843
4481
  return transitions[name] = transition;
@@ -3872,6 +4510,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3872
4510
  @function up.animation
3873
4511
  @param {String} name
3874
4512
  @param {Function} animation
4513
+ @stable
3875
4514
  */
3876
4515
  animation = function(name, animation) {
3877
4516
  return animations[name] = animation;
@@ -3891,6 +4530,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3891
4530
  @function up.motion.when
3892
4531
  @param promises...
3893
4532
  @return A new promise.
4533
+ @experimental
3894
4534
  */
3895
4535
  resolvableWhen = u.resolvableWhen;
3896
4536
 
@@ -3901,6 +4541,7 @@ or [transitions](/up.transition) using Javascript or CSS.
3901
4541
  @function up.motion.none
3902
4542
  @return {Promise}
3903
4543
  A resolved promise
4544
+ @stable
3904
4545
  */
3905
4546
  none = u.resolvedDeferred;
3906
4547
  animation('none', none);
@@ -4167,8 +4808,15 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4167
4808
  });
4168
4809
 
4169
4810
  /**
4170
- @protected
4811
+ Returns a cached response for the given request.
4812
+
4813
+ Returns `undefined` if the given request is not currently cached.
4814
+
4171
4815
  @function up.proxy.get
4816
+ @return {Promise}
4817
+ A promise for the response that is API-compatible with the
4818
+ promise returned by [`jQuery.ajax`](http://api.jquery.com/jquery.ajax/).
4819
+ @experimental
4172
4820
  */
4173
4821
  get = function(request) {
4174
4822
  var candidate, candidates, i, len, requestForBody, requestForHtml, response;
@@ -4195,21 +4843,41 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4195
4843
  };
4196
4844
 
4197
4845
  /**
4198
- @protected
4846
+ Manually stores a promise for the response to the given request.
4847
+
4199
4848
  @function up.proxy.set
4849
+ @param {String} request.url
4850
+ @param {String} [request.method='GET']
4851
+ @param {String} [request.selector='body']
4852
+ @param {Promise} response
4853
+ A promise for the response that is API-compatible with the
4854
+ promise returned by [`jQuery.ajax`](http://api.jquery.com/jquery.ajax/).
4855
+ @experimental
4200
4856
  */
4201
4857
  set = cache.set;
4202
4858
 
4203
4859
  /**
4204
- @protected
4860
+ Manually removes the given request from the cache.
4861
+
4862
+ You can also [configure](/up.proxy.config) when the proxy
4863
+ automatically removes cache entries.
4864
+
4205
4865
  @function up.proxy.remove
4866
+ @param {String} request.url
4867
+ @param {String} [request.method='GET']
4868
+ @param {String} [request.selector='body']
4869
+ @experimental
4206
4870
  */
4207
4871
  remove = cache.remove;
4208
4872
 
4209
4873
  /**
4210
4874
  Removes all cache entries.
4211
4875
 
4876
+ Up.js also automatically clears the cache whenever it processes
4877
+ a request with a non-GET HTTP method.
4878
+
4212
4879
  @function up.proxy.clear
4880
+ @stable
4213
4881
  */
4214
4882
  clear = cache.clear;
4215
4883
  cancelPreloadDelay = function() {
@@ -4260,13 +4928,17 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4260
4928
  @function up.proxy.ajax
4261
4929
  @param {String} request.url
4262
4930
  @param {String} [request.method='GET']
4263
- @param {String} [request.selector]
4931
+ @param {String} [request.selector='body']
4264
4932
  @param {Boolean} [request.cache]
4265
4933
  Whether to use a cached response, if available.
4266
4934
  If set to `false` a network connection will always be attempted.
4267
4935
  @param {Object} [request.headers={}]
4268
4936
  An object of additional header key/value pairs to send along
4269
4937
  with the request.
4938
+ @return
4939
+ A promise for the response that is API-compatible with the
4940
+ promise returned by [`jQuery.ajax`](http://api.jquery.com/jquery.ajax/).
4941
+ @stable
4270
4942
  */
4271
4943
  ajax = function(options) {
4272
4944
  var forceCache, ignoreCache, pending, promise, request;
@@ -4302,7 +4974,9 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4302
4974
  used to busy, but is now idle.
4303
4975
 
4304
4976
  @function up.proxy.idle
4305
- @return {Boolean} Whether the proxy is idle
4977
+ @return {Boolean}
4978
+ Whether the proxy is idle
4979
+ @experimental
4306
4980
  */
4307
4981
  idle = function() {
4308
4982
  return pendingCount === 0;
@@ -4316,7 +4990,9 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4316
4990
  used to be idle, but is now busy.
4317
4991
 
4318
4992
  @function up.proxy.busy
4319
- @return {Boolean} Whether the proxy is busy
4993
+ @return {Boolean}
4994
+ Whether the proxy is busy
4995
+ @experimental
4320
4996
  */
4321
4997
  busy = function() {
4322
4998
  return pendingCount > 0;
@@ -4356,6 +5032,7 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4356
5032
  waiting, **no** additional `up:proxy:busy` events will be triggered.
4357
5033
 
4358
5034
  @event up:proxy:busy
5035
+ @stable
4359
5036
  */
4360
5037
  loadEnded = function() {
4361
5038
  pendingCount -= 1;
@@ -4370,6 +5047,7 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4370
5047
  have [taken long to finish](/up:proxy:busy), but have finished now.
4371
5048
 
4372
5049
  @event up:proxy:idle
5050
+ @stable
4373
5051
  */
4374
5052
  load = function(request) {
4375
5053
  var promise;
@@ -4387,10 +5065,10 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4387
5065
  is starting to load.
4388
5066
 
4389
5067
  @event up:proxy:load
4390
- @protected
4391
5068
  @param event.url
4392
5069
  @param event.method
4393
5070
  @param event.selector
5071
+ @experimental
4394
5072
  */
4395
5073
 
4396
5074
  /**
@@ -4398,10 +5076,10 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4398
5076
  has been received.
4399
5077
 
4400
5078
  @event up:proxy:received
4401
- @protected
4402
5079
  @param event.url
4403
5080
  @param event.method
4404
5081
  @param event.selector
5082
+ @experimental
4405
5083
  */
4406
5084
  isIdempotent = function(request) {
4407
5085
  normalizeRequest(request);
@@ -4425,12 +5103,12 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4425
5103
  };
4426
5104
 
4427
5105
  /**
4428
- @protected
4429
5106
  @function up.proxy.preload
4430
5107
  @param {String|Element|jQuery}
4431
5108
  The element whose destination should be preloaded.
4432
5109
  @return
4433
5110
  A promise that will be resolved when the request was loaded and cached
5111
+ @stable
4434
5112
  */
4435
5113
  preload = function(linkOrSelector, options) {
4436
5114
  var $link, method;
@@ -4461,6 +5139,7 @@ You can change (or remove) this delay by [configuring `up.proxy`](/up.proxy.conf
4461
5139
  The number of milliseconds to wait between hovering
4462
5140
  and preloading. Increasing this will lower the load in your server,
4463
5141
  but will also make the interaction feel less instant.
5142
+ @stable
4464
5143
  */
4465
5144
  up.on('mouseover mousedown touchstart', '[up-preload]', function(event, $element) {
4466
5145
  if (!up.link.childClicked(event, $element)) {
@@ -4591,6 +5270,7 @@ Read on
4591
5270
  The selector to replace.
4592
5271
  @param {Object} options
4593
5272
  See options for [`up.replace`](/up.replace)
5273
+ @stable
4594
5274
  */
4595
5275
  visit = function(url, options) {
4596
5276
  var selector;
@@ -4640,6 +5320,10 @@ Read on
4640
5320
  @param {Object} [options.headers={}]
4641
5321
  An object of additional header key/value pairs to send along
4642
5322
  with the request.
5323
+ @return {Promise}
5324
+ A promise that will be resolved when the link destination
5325
+ has been loaded and rendered.
5326
+ @stable
4643
5327
  */
4644
5328
  follow = function(linkOrSelector, options) {
4645
5329
  var $link, selector, url;
@@ -4662,12 +5346,12 @@ Read on
4662
5346
  Returns the HTTP method that should be used when following the given link.
4663
5347
 
4664
5348
  Looks at the link's `up-method` or `data-method` attribute.
4665
- Defaults to `get`.
5349
+ Defaults to `"get"`.
4666
5350
 
4667
- @protected
4668
5351
  @function up.link.followMethod
4669
5352
  @param linkOrSelector
4670
5353
  @param options.method {String}
5354
+ @internal
4671
5355
  */
4672
5356
  followMethod = function(linkOrSelector, options) {
4673
5357
  var $link;
@@ -4738,6 +5422,7 @@ Read on
4738
5422
  Whether to force the use of a cached response (`true`)
4739
5423
  or never use the cache (`false`)
4740
5424
  or make an educated guess (`undefined`).
5425
+ @stable
4741
5426
  */
4742
5427
  up.on('click', 'a[up-target], [up-href][up-target]', function(event, $link) {
4743
5428
  if (shouldProcessLinkEvent(event, $link)) {
@@ -4767,6 +5452,7 @@ Read on
4767
5452
  systems switch tabs on `mousedown` instead of `click`.
4768
5453
 
4769
5454
  @selector a[up-instant]
5455
+ @stable
4770
5456
  */
4771
5457
  up.on('mousedown', 'a[up-instant], [up-href][up-instant]', function(event, $link) {
4772
5458
  if (shouldProcessLinkEvent(event, $link)) {
@@ -4777,7 +5463,7 @@ Read on
4777
5463
 
4778
5464
  /**
4779
5465
  @function up.link.childClicked
4780
- @private
5466
+ @internal
4781
5467
  */
4782
5468
  childClicked = function(event, $link) {
4783
5469
  var $target, $targetLink;
@@ -4793,10 +5479,10 @@ Read on
4793
5479
  Makes sure that the given link is handled by Up.js.
4794
5480
 
4795
5481
  This is done by giving the link an `up-follow` attribute
4796
- if it doesn't already have it an `up-target` or `up-follow` attribute.
5482
+ unless it already have it an `up-target` or `up-follow` attribute.
4797
5483
 
4798
5484
  @function up.link.makeFollowable
4799
- @protected
5485
+ @internal
4800
5486
  */
4801
5487
  makeFollowable = function(link) {
4802
5488
  var $link;
@@ -4814,8 +5500,7 @@ Read on
4814
5500
 
4815
5501
  <a href="/users" up-follow>User list</a>
4816
5502
 
4817
- To only update a fragment instead of the entire page,
4818
- see [`up-target`](/up-target).
5503
+ To only update a fragment instead of the entire page, see [`up-target`](/up-target).
4819
5504
 
4820
5505
  \#\#\#\# Turn any element into a link
4821
5506
 
@@ -4834,6 +5519,7 @@ Read on
4834
5519
  @param [up-restore-scroll='false']
4835
5520
  Whether to restore the scroll position of all viewports
4836
5521
  within the response.
5522
+ @stable
4837
5523
  */
4838
5524
  up.on('click', 'a[up-follow], [up-href][up-follow]', function(event, $link) {
4839
5525
  if (shouldProcessLinkEvent(event, $link)) {
@@ -4862,6 +5548,7 @@ Read on
4862
5548
  (`up-target`, `up-instant`, `up-preload`, etc.).
4863
5549
 
4864
5550
  @selector [up-expand]
5551
+ @stable
4865
5552
  */
4866
5553
  up.compiler('[up-expand]', function($area) {
4867
5554
  var attribute, i, len, link, name, newAttrs, ref, upAttributePattern;
@@ -4900,6 +5587,7 @@ Read on
4900
5587
  <a href="/users" up-target=".main" up-instant up-preload>User list</a>
4901
5588
 
4902
5589
  @selector [up-dash]
5590
+ @stable
4903
5591
  */
4904
5592
  up.compiler('[up-dash]', function($element) {
4905
5593
  var newAttrs, target;
@@ -5035,6 +5723,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5035
5723
  with the request.
5036
5724
  @return {Promise}
5037
5725
  A promise for the successful form submission.
5726
+ @stable
5038
5727
  */
5039
5728
  submit = function(formOrSelector, options) {
5040
5729
  var $form, failureSelector, failureTransition, hasFileInputs, headers, historyOption, httpMethod, implantOptions, request, successSelector, successTransition, successUrl, url, useCache;
@@ -5042,7 +5731,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5042
5731
  options = u.options(options);
5043
5732
  successSelector = up.flow.resolveSelector(u.option(options.target, $form.attr('up-target'), 'body'), options);
5044
5733
  failureSelector = up.flow.resolveSelector(u.option(options.failTarget, $form.attr('up-fail-target'), function() {
5045
- return u.createSelectorFromElement($form);
5734
+ return u.selectorForElement($form);
5046
5735
  }), options);
5047
5736
  historyOption = u.option(options.history, u.castedAttr($form, 'up-history'), true);
5048
5737
  successTransition = u.option(options.transition, u.castedAttr($form, 'up-transition'));
@@ -5157,6 +5846,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5157
5846
  The number of miliseconds to wait before executing the callback
5158
5847
  after the input value changes. Use this to limit how often the callback
5159
5848
  will be invoked for a fast typist.
5849
+ @stable
5160
5850
  */
5161
5851
  observe = function(fieldOrSelector, options) {
5162
5852
  var $field, callback, callbackPromise, callbackTimer, changeEvents, check, clearTimer, codeOnChange, delay, knownValue, nextCallback, runNextCallback;
@@ -5233,7 +5923,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5233
5923
  error('Could not find default validation target for %o (tried ancestors %o)', $field, config.validateTargets);
5234
5924
  }
5235
5925
  if (!u.isString(target)) {
5236
- target = u.createSelectorFromElement(target);
5926
+ target = u.selectorForElement(target);
5237
5927
  }
5238
5928
  return target;
5239
5929
  };
@@ -5260,6 +5950,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5260
5950
  @return {Promise}
5261
5951
  A promise that is resolved when the server-side
5262
5952
  validation is received and the form was updated.
5953
+ @stable
5263
5954
  */
5264
5955
  validate = function(fieldOrSelector, options) {
5265
5956
  var $field, $form, promise;
@@ -5372,6 +6063,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5372
6063
  or make an educated guess (`undefined`).
5373
6064
 
5374
6065
  By default only responses to `GET` requests are cached for a few minutes.
6066
+ @stable
5375
6067
  */
5376
6068
  up.on('submit', 'form[up-target]', function(event, $form) {
5377
6069
  event.preventDefault();
@@ -5519,6 +6211,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5519
6211
  The CSS selector to update with the server response.
5520
6212
 
5521
6213
  This defaults to a fieldset or form group around the validating field.
6214
+ @stable
5522
6215
  */
5523
6216
  up.on('change', '[up-validate]', function(event, $field) {
5524
6217
  return validate($field);
@@ -5551,6 +6244,7 @@ open dialogs with sub-forms, etc. all without losing form state.
5551
6244
  @selector [up-observe]
5552
6245
  @param {String} up-observe
5553
6246
  The code to run when the field's value changes.
6247
+ @stable
5554
6248
  */
5555
6249
  up.compiler('[up-observe]', function($field) {
5556
6250
  return observe($field);
@@ -5631,6 +6325,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5631
6325
  @function up.popup.url
5632
6326
  @return {String}
5633
6327
  the source URL
6328
+ @stable
5634
6329
  */
5635
6330
  currentUrl = void 0;
5636
6331
 
@@ -5639,7 +6334,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5639
6334
 
5640
6335
  @function up.popup.coveredUrl
5641
6336
  @return {String}
5642
- @protected
6337
+ @experimental
5643
6338
  */
5644
6339
  coveredUrl = function() {
5645
6340
  var $popup;
@@ -5788,6 +6483,9 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5788
6483
  If set to `true`, the popup remains
5789
6484
  open even if the page changes in the background.
5790
6485
  @param {Object} [options.history=false]
6486
+ @return {Promise}
6487
+ A promise that will be resolved when the popup has been loaded and rendered.
6488
+ @stable
5791
6489
  */
5792
6490
  attach = function(linkOrSelector, options) {
5793
6491
  var $link, $popup, animateOptions, animation, history, position, selector, sticky, url;
@@ -5817,6 +6515,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5817
6515
  @function up.popup.close
5818
6516
  @param {Object} options
5819
6517
  See options for [`up.animate`](/up.animate).
6518
+ @stable
5820
6519
  */
5821
6520
  close = function(options) {
5822
6521
  var $popup;
@@ -5846,7 +6545,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5846
6545
 
5847
6546
  @methods up.popup.contains
5848
6547
  @param {String} elementOrSelector
5849
- @protected
6548
+ @stable
5850
6549
  */
5851
6550
  contains = function(elementOrSelector) {
5852
6551
  var $element;
@@ -5868,6 +6567,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5868
6567
  @selector a[up-popup]
5869
6568
  @param [up-sticky]
5870
6569
  @param [up-position]
6570
+ @stable
5871
6571
  */
5872
6572
  up.on('click', 'a[up-popup]', function(event, $link) {
5873
6573
  event.preventDefault();
@@ -5903,6 +6603,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
5903
6603
  a currently open popup is closed.
5904
6604
 
5905
6605
  @selector [up-close]
6606
+ @stable
5906
6607
  */
5907
6608
  up.on('click', '[up-close]', function(event, $element) {
5908
6609
  if ($element.closest('.up-popup').length) {
@@ -6052,6 +6753,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6052
6753
  @function up.modal.url
6053
6754
  @return {String}
6054
6755
  the source URL
6756
+ @stable
6055
6757
  */
6056
6758
  currentUrl = void 0;
6057
6759
 
@@ -6060,7 +6762,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6060
6762
 
6061
6763
  @function up.modal.coveredUrl
6062
6764
  @return {String}
6063
- @protected
6765
+ @experimental
6064
6766
  */
6065
6767
  coveredUrl = function() {
6066
6768
  var $modal;
@@ -6186,7 +6888,8 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6186
6888
  @param {String} [options.easing]
6187
6889
  The timing function that controls the animation's acceleration. [`up.animate`](/up.animate).
6188
6890
  @return {Promise}
6189
- A promise that will be resolved when the modal has finished loading.
6891
+ A promise that will be resolved when the popup has been loaded and rendered.
6892
+ @stable
6190
6893
  */
6191
6894
  follow = function(linkOrSelector, options) {
6192
6895
  options = u.options(options);
@@ -6214,6 +6917,9 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6214
6917
  The extracted content will be placed into the dialog window.
6215
6918
  @param {Object} options
6216
6919
  See options for [previous `up.modal.open` variant](/up.modal.open).
6920
+ @return {Promise}
6921
+ A promise that will be resolved when the popup has been loaded and rendered.
6922
+ @stable
6217
6923
  */
6218
6924
  visit = function(url, options) {
6219
6925
  options = u.options(options);
@@ -6222,13 +6928,13 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6222
6928
  };
6223
6929
 
6224
6930
  /**
6225
- @function up.modal.open
6226
- @private
6931
+ @function open
6932
+ @internal
6227
6933
  */
6228
6934
  open = function(options) {
6229
6935
  var $link, $modal, animateOptions, animation, height, history, maxWidth, selector, sticky, url, width;
6230
6936
  options = u.options(options);
6231
- $link = u.option(options.$link, u.nullJquery());
6937
+ $link = u.option(options.$link, u.nullJQuery());
6232
6938
  url = u.option(options.url, $link.attr('up-href'), $link.attr('href'));
6233
6939
  selector = u.option(options.target, $link.attr('up-modal'), 'body');
6234
6940
  width = u.option(options.width, $link.attr('up-width'), config.width);
@@ -6266,12 +6972,14 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6266
6972
  @event up:modal:open
6267
6973
  @param event.preventDefault()
6268
6974
  Event listeners may call this method to prevent the modal from opening.
6975
+ @stable
6269
6976
  */
6270
6977
 
6271
6978
  /**
6272
6979
  This event is [emitted](/up.emit) when a modal dialog has finished opening.
6273
6980
 
6274
6981
  @event up:modal:opened
6982
+ @stable
6275
6983
  */
6276
6984
 
6277
6985
  /**
@@ -6283,6 +6991,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6283
6991
  @function up.modal.close
6284
6992
  @param {Object} options
6285
6993
  See options for [`up.animate`](/up.animate)
6994
+ @stable
6286
6995
  */
6287
6996
  close = function(options) {
6288
6997
  var $modal, deferred;
@@ -6321,6 +7030,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6321
7030
  @event up:modal:close
6322
7031
  @param event.preventDefault()
6323
7032
  Event listeners may call this method to prevent the modal from closing.
7033
+ @stable
6324
7034
  */
6325
7035
 
6326
7036
  /**
@@ -6328,6 +7038,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6328
7038
  is done [closing](/up.modal.close).
6329
7039
 
6330
7040
  @event up:modal:closed
7041
+ @stable
6331
7042
  */
6332
7043
  autoclose = function() {
6333
7044
  if (!$('.up-modal').is('[up-sticky]')) {
@@ -6342,7 +7053,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6342
7053
 
6343
7054
  @function up.modal.contains
6344
7055
  @param {String} elementOrSelector
6345
- @protected
7056
+ @stable
6346
7057
  */
6347
7058
  contains = function(elementOrSelector) {
6348
7059
  var $element;
@@ -6369,6 +7080,7 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6369
7080
  @param [up-height]
6370
7081
  @param [up-width]
6371
7082
  @param [up-history]
7083
+ @stable
6372
7084
  */
6373
7085
  up.on('click', 'a[up-modal]', function(event, $link) {
6374
7086
  event.preventDefault();
@@ -6401,9 +7113,16 @@ To disable this behavior, give the opening link an `up-sticky` attribute:
6401
7113
 
6402
7114
  /**
6403
7115
  When this element is clicked, closes a currently open dialog.
7116
+
6404
7117
  Does nothing if no modal is currently open.
6405
7118
 
7119
+ To make a link that closes the current modal, but follows to
7120
+ a fallback destination if no modal is open:
7121
+
7122
+ <a href="/fallback" up-close>Okay</a>
7123
+
6406
7124
  @selector [up-close]
7125
+ @stable
6407
7126
  */
6408
7127
  up.on('click', '[up-close]', function(event, $element) {
6409
7128
  if ($element.closest('.up-modal').length) {
@@ -6544,6 +7263,9 @@ The tooltip element is appended to the end of `<body>`.
6544
7263
  The position of the tooltip. Known values are `top` and `bottom`.
6545
7264
  @param {String} [options.animation]
6546
7265
  The animation to use when opening the tooltip.
7266
+ @return {Promise}
7267
+ A promise that will be resolved when the tooltip's opening animation has finished.
7268
+ @stable
6547
7269
  */
6548
7270
  attach = function(linkOrSelector, options) {
6549
7271
  var $link, $tooltip, animateOptions, animation, html, position, text;
@@ -6572,6 +7294,7 @@ The tooltip element is appended to the end of `<body>`.
6572
7294
  @function up.tooltip.close
6573
7295
  @param {Object} options
6574
7296
  See options for [`up.animate`](/up.animate).
7297
+ @stable
6575
7298
  */
6576
7299
  close = function(options) {
6577
7300
  var $tooltip;
@@ -6603,6 +7326,7 @@ The tooltip element is appended to the end of `<body>`.
6603
7326
  The default position of tooltips relative to the element.
6604
7327
  Can be either `"top"` or `"bottom"`.
6605
7328
  Defaults to [`up.tooltip.config.position`](/up.tooltip.config).
7329
+ @stable
6606
7330
  */
6607
7331
 
6608
7332
  /**
@@ -6611,6 +7335,7 @@ The tooltip element is appended to the end of `<body>`.
6611
7335
  <a href="/decks" up-tooltip="Show &lt;b&gt;all&lt;/b&gt; decks">Decks</a>
6612
7336
 
6613
7337
  @selector [up-tooltip-html]
7338
+ @stable
6614
7339
  */
6615
7340
  up.compiler('[up-tooltip], [up-tooltip-html]', function($link) {
6616
7341
  $link.on('mouseover', function() {
@@ -6784,6 +7509,7 @@ by providing instant feedback for user interactions.
6784
7509
  <a href="/foo" up-follow up-current>Foo</a>
6785
7510
 
6786
7511
  @selector [up-active]
7512
+ @stable
6787
7513
  */
6788
7514
  sectionClicked = function($section) {
6789
7515
  unmarkActive();
@@ -6849,6 +7575,7 @@ by providing instant feedback for user interactions.
6849
7575
  <a href="/reports" up-alias="/reports/*">Reports</a>
6850
7576
 
6851
7577
  @selector [up-current]
7578
+ @stable
6852
7579
  */
6853
7580
  up.on('up:fragment:inserted', function() {
6854
7581
  unmarkActive();