upjs-rails 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/design/design.txt +1 -1
- data/dist/up.js +195 -179
- data/dist/up.min.js +2 -2
- data/lib/assets/javascripts/up/browser.js.coffee +1 -0
- data/lib/assets/javascripts/up/flow.js.coffee +19 -4
- data/lib/assets/javascripts/up/form.js.coffee +2 -2
- data/lib/assets/javascripts/up/link.js.coffee +1 -1
- data/lib/assets/javascripts/up/magic.js.coffee +41 -36
- data/lib/assets/javascripts/up/slot.js.coffee +1 -4
- data/lib/assets/javascripts/up/tooltip.js.coffee +1 -1
- data/lib/assets/javascripts/up/util.js.coffee +9 -16
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +2 -1
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +59 -4
- data/spec_app/spec/javascripts/up/magic_spec.js.coffee +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 772b610a2d92e9bab9bbb3645ba43a8d54034d3a
|
4
|
+
data.tar.gz: b98035a0a638940813babac04dadb7a81d7330ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74283762d6f5a9dc34ef2f10e58961f66a5155dbbfbc46667311a38a55980c579052672486df539ffd8645f9b38abc29bcbde73f87077543086369dd6c94e719
|
7
|
+
data.tar.gz: 47b081aa12d808affa5b732294043601b7209ea64919df3e34472fc36022cf25bdcf4069dc5988e073e0c16a0bbaa71ba0e53ca263e0bd2b1b26e34e8efd5b2f
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
GEM
|
2
2
|
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
coffee-script (2.
|
4
|
+
coffee-script (2.4.1)
|
5
5
|
coffee-script-source
|
6
6
|
execjs
|
7
|
-
coffee-script-source (1.9.
|
8
|
-
execjs (2.
|
7
|
+
coffee-script-source (1.9.1.1)
|
8
|
+
execjs (2.5.2)
|
9
9
|
hike (1.2.3)
|
10
10
|
json (1.8.2)
|
11
|
-
libv8 (3.16.14.
|
11
|
+
libv8 (3.16.14.11)
|
12
12
|
multi_json (1.10.1)
|
13
13
|
rack (1.6.0)
|
14
14
|
rake (10.4.2)
|
data/design/design.txt
CHANGED
data/dist/up.js
CHANGED
@@ -22,10 +22,10 @@ If you use them in your own code, you will get hurt.
|
|
22
22
|
*/
|
23
23
|
|
24
24
|
(function() {
|
25
|
-
var
|
25
|
+
var slice = [].slice;
|
26
26
|
|
27
27
|
up.util = (function() {
|
28
|
-
var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, measure, merge, methodFromXhr, nextFrame, normalizeMethod, normalizeUrl, nullJquery, only, option, options, prependGhost, presence, presentAttr, resolvableWhen, resolvedDeferred, resolvedPromise, select, setMissingAttrs, stringSet, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unwrap;
|
28
|
+
var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, measure, merge, methodFromXhr, nextFrame, normalizeMethod, normalizeUrl, nullJquery, only, option, options, prependGhost, presence, presentAttr, resolvableWhen, resolvedDeferred, resolvedPromise, select, setMissingAttrs, stringSet, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unwrap, warn;
|
29
29
|
get = function(url, options) {
|
30
30
|
options = options || {};
|
31
31
|
options.url = url;
|
@@ -105,17 +105,17 @@ If you use them in your own code, you will get hurt.
|
|
105
105
|
}
|
106
106
|
};
|
107
107
|
$createElementFromSelector = function(selector) {
|
108
|
-
var $element, $parent, $root, classes, conjunction, depthSelector, expression, html, id, iteration,
|
108
|
+
var $element, $parent, $root, classes, conjunction, depthSelector, expression, html, id, iteration, j, k, len, len1, path, tag;
|
109
109
|
path = selector.split(/[ >]/);
|
110
110
|
$root = null;
|
111
|
-
for (iteration =
|
111
|
+
for (iteration = j = 0, len = path.length; j < len; iteration = ++j) {
|
112
112
|
depthSelector = path[iteration];
|
113
113
|
conjunction = depthSelector.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g);
|
114
114
|
tag = "div";
|
115
115
|
classes = [];
|
116
116
|
id = null;
|
117
|
-
for (
|
118
|
-
expression = conjunction[
|
117
|
+
for (k = 0, len1 = conjunction.length; k < len1; k++) {
|
118
|
+
expression = conjunction[k];
|
119
119
|
switch (expression[0]) {
|
120
120
|
case ".":
|
121
121
|
classes.push(expression.substr(1));
|
@@ -155,36 +155,27 @@ If you use them in your own code, you will get hurt.
|
|
155
155
|
return element;
|
156
156
|
};
|
157
157
|
debug = function() {
|
158
|
-
var args,
|
159
|
-
args =
|
160
|
-
args = toArray(args);
|
161
|
-
message = args.shift();
|
158
|
+
var args, message;
|
159
|
+
message = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
162
160
|
message = "[UP] " + message;
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
try {
|
171
|
-
value = group();
|
172
|
-
} finally {
|
173
|
-
console.groupEnd();
|
174
|
-
}
|
175
|
-
}
|
176
|
-
return value;
|
161
|
+
return console.debug.apply(console, [message].concat(slice.call(args)));
|
162
|
+
};
|
163
|
+
warn = function() {
|
164
|
+
var args, message;
|
165
|
+
message = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
166
|
+
message = "[UP] " + message;
|
167
|
+
return console.warn.apply(console, [message].concat(slice.call(args)));
|
177
168
|
};
|
178
169
|
error = function() {
|
179
170
|
var $error, args, asString;
|
180
|
-
args = 1 <= arguments.length ?
|
171
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
181
172
|
args[0] = "[UP] " + args[0];
|
182
173
|
console.error.apply(console, args);
|
183
174
|
asString = stringifyConsoleArgs(args);
|
184
175
|
$error = presence($('.up-error')) || $('<div class="up-error"></div>').prependTo('body');
|
185
176
|
$error.addClass('up-error');
|
186
177
|
$error.text(asString);
|
187
|
-
throw asString;
|
178
|
+
throw new Error(asString);
|
188
179
|
};
|
189
180
|
CONSOLE_PLACEHOLDERS = /\%[odisf]/g;
|
190
181
|
stringifyConsoleArgs = function(args) {
|
@@ -211,7 +202,7 @@ If you use them in your own code, you will get hurt.
|
|
211
202
|
});
|
212
203
|
};
|
213
204
|
createSelectorFromElement = function($element) {
|
214
|
-
var classString, classes, id,
|
205
|
+
var classString, classes, id, j, klass, len, selector;
|
215
206
|
debug("Creating selector from element %o", $element);
|
216
207
|
classes = (classString = $element.attr("class")) ? classString.split(" ") : [];
|
217
208
|
id = $element.attr("id");
|
@@ -219,8 +210,8 @@ If you use them in your own code, you will get hurt.
|
|
219
210
|
if (id) {
|
220
211
|
selector += "#" + id;
|
221
212
|
}
|
222
|
-
for (
|
223
|
-
klass = classes[
|
213
|
+
for (j = 0, len = classes.length; j < len; j++) {
|
214
|
+
klass = classes[j];
|
224
215
|
selector += "." + klass;
|
225
216
|
}
|
226
217
|
return selector;
|
@@ -257,10 +248,10 @@ If you use them in your own code, you will get hurt.
|
|
257
248
|
extend = $.extend;
|
258
249
|
trim = $.trim;
|
259
250
|
keys = Object.keys || function(object) {
|
260
|
-
var
|
251
|
+
var j, key, len, result;
|
261
252
|
result = [];
|
262
|
-
for (
|
263
|
-
key = object[
|
253
|
+
for (j = 0, len = object.length; j < len; j++) {
|
254
|
+
key = object[j];
|
264
255
|
if (object.hasOwnProperty(key)) {
|
265
256
|
result.push(key);
|
266
257
|
}
|
@@ -268,21 +259,21 @@ If you use them in your own code, you will get hurt.
|
|
268
259
|
return result;
|
269
260
|
};
|
270
261
|
each = function(collection, block) {
|
271
|
-
var index, item,
|
272
|
-
|
273
|
-
for (index =
|
262
|
+
var index, item, j, len, results;
|
263
|
+
results = [];
|
264
|
+
for (index = j = 0, len = collection.length; j < len; index = ++j) {
|
274
265
|
item = collection[index];
|
275
|
-
|
266
|
+
results.push(block(item, index));
|
276
267
|
}
|
277
|
-
return
|
268
|
+
return results;
|
278
269
|
};
|
279
270
|
times = function(count, block) {
|
280
|
-
var iteration,
|
281
|
-
|
282
|
-
for (iteration =
|
283
|
-
|
271
|
+
var iteration, j, ref, results;
|
272
|
+
results = [];
|
273
|
+
for (iteration = j = 0, ref = count - 1; 0 <= ref ? j <= ref : j >= ref; iteration = 0 <= ref ? ++j : --j) {
|
274
|
+
results.push(block(iteration));
|
284
275
|
}
|
285
|
-
return
|
276
|
+
return results;
|
286
277
|
};
|
287
278
|
isNull = function(object) {
|
288
279
|
return object === null;
|
@@ -396,11 +387,11 @@ If you use them in your own code, you will get hurt.
|
|
396
387
|
@param {Array} args...
|
397
388
|
*/
|
398
389
|
option = function() {
|
399
|
-
var arg, args,
|
400
|
-
args = 1 <= arguments.length ?
|
390
|
+
var arg, args, j, len, match, value;
|
391
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
401
392
|
match = null;
|
402
|
-
for (
|
403
|
-
arg = args[
|
393
|
+
for (j = 0, len = args.length; j < len; j++) {
|
394
|
+
arg = args[j];
|
404
395
|
value = arg;
|
405
396
|
if (isFunction(value)) {
|
406
397
|
value = value();
|
@@ -413,10 +404,10 @@ If you use them in your own code, you will get hurt.
|
|
413
404
|
return match;
|
414
405
|
};
|
415
406
|
detect = function(array, tester) {
|
416
|
-
var element,
|
407
|
+
var element, j, len, match;
|
417
408
|
match = null;
|
418
|
-
for (
|
419
|
-
element = array[
|
409
|
+
for (j = 0, len = array.length; j < len; j++) {
|
410
|
+
element = array[j];
|
420
411
|
if (tester(element)) {
|
421
412
|
match = element;
|
422
413
|
break;
|
@@ -436,15 +427,15 @@ If you use them in your own code, you will get hurt.
|
|
436
427
|
};
|
437
428
|
presentAttr = function() {
|
438
429
|
var $element, attrName, attrNames, values;
|
439
|
-
$element = arguments[0], attrNames = 2 <= arguments.length ?
|
430
|
+
$element = arguments[0], attrNames = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
440
431
|
values = (function() {
|
441
|
-
var
|
442
|
-
|
443
|
-
for (
|
444
|
-
attrName = attrNames[
|
445
|
-
|
432
|
+
var j, len, results;
|
433
|
+
results = [];
|
434
|
+
for (j = 0, len = attrNames.length; j < len; j++) {
|
435
|
+
attrName = attrNames[j];
|
436
|
+
results.push($element.attr(attrName));
|
446
437
|
}
|
447
|
-
return
|
438
|
+
return results;
|
448
439
|
})();
|
449
440
|
return detect(values, isPresent);
|
450
441
|
};
|
@@ -600,18 +591,18 @@ If you use them in your own code, you will get hurt.
|
|
600
591
|
return box;
|
601
592
|
};
|
602
593
|
copyAttributes = function($source, $target) {
|
603
|
-
var attr,
|
604
|
-
|
605
|
-
|
606
|
-
for (
|
607
|
-
attr =
|
594
|
+
var attr, j, len, ref, results;
|
595
|
+
ref = $source.get(0).attributes;
|
596
|
+
results = [];
|
597
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
598
|
+
attr = ref[j];
|
608
599
|
if (attr.specified) {
|
609
|
-
|
600
|
+
results.push($target.attr(attr.name, attr.value));
|
610
601
|
} else {
|
611
|
-
|
602
|
+
results.push(void 0);
|
612
603
|
}
|
613
604
|
}
|
614
|
-
return
|
605
|
+
return results;
|
615
606
|
};
|
616
607
|
prependGhost = function($element) {
|
617
608
|
var $ghost, dimensions;
|
@@ -652,11 +643,11 @@ If you use them in your own code, you will get hurt.
|
|
652
643
|
return xhr.getResponseHeader('X-Up-Method');
|
653
644
|
};
|
654
645
|
only = function() {
|
655
|
-
var filtered, key, keys,
|
656
|
-
object = arguments[0], keys = 2 <= arguments.length ?
|
646
|
+
var filtered, j, key, keys, len, object;
|
647
|
+
object = arguments[0], keys = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
657
648
|
filtered = {};
|
658
|
-
for (
|
659
|
-
key = keys[
|
649
|
+
for (j = 0, len = keys.length; j < len; j++) {
|
650
|
+
key = keys[j];
|
660
651
|
if (object.hasOwnProperty(key)) {
|
661
652
|
filtered[key] = object[key];
|
662
653
|
}
|
@@ -691,7 +682,7 @@ If you use them in your own code, you will get hurt.
|
|
691
682
|
};
|
692
683
|
resolvableWhen = function() {
|
693
684
|
var deferreds, joined;
|
694
|
-
deferreds = 1 <= arguments.length ?
|
685
|
+
deferreds = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
695
686
|
joined = $.when.apply($, deferreds);
|
696
687
|
joined.resolve = function() {
|
697
688
|
return each(deferreds, function(deferred) {
|
@@ -701,20 +692,20 @@ If you use them in your own code, you will get hurt.
|
|
701
692
|
return joined;
|
702
693
|
};
|
703
694
|
setMissingAttrs = function($element, attrs) {
|
704
|
-
var key,
|
705
|
-
|
695
|
+
var key, results, value;
|
696
|
+
results = [];
|
706
697
|
for (key in attrs) {
|
707
698
|
value = attrs[key];
|
708
699
|
if (isMissing($element.attr(key))) {
|
709
|
-
|
700
|
+
results.push($element.attr(key, value));
|
710
701
|
} else {
|
711
|
-
|
702
|
+
results.push(void 0);
|
712
703
|
}
|
713
704
|
}
|
714
|
-
return
|
705
|
+
return results;
|
715
706
|
};
|
716
707
|
stringSet = function(array) {
|
717
|
-
var includes, includesAny, key, put, set, string
|
708
|
+
var includes, includesAny, j, key, len, put, set, string;
|
718
709
|
set = {};
|
719
710
|
includes = function(string) {
|
720
711
|
return set[key(string)];
|
@@ -728,8 +719,8 @@ If you use them in your own code, you will get hurt.
|
|
728
719
|
key = function(string) {
|
729
720
|
return "_" + string;
|
730
721
|
};
|
731
|
-
for (
|
732
|
-
string = array[
|
722
|
+
for (j = 0, len = array.length; j < len; j++) {
|
723
|
+
string = array[j];
|
733
724
|
put(string);
|
734
725
|
}
|
735
726
|
return {
|
@@ -755,6 +746,7 @@ If you use them in your own code, you will get hurt.
|
|
755
746
|
option: option,
|
756
747
|
error: error,
|
757
748
|
debug: debug,
|
749
|
+
warn: warn,
|
758
750
|
each: each,
|
759
751
|
times: times,
|
760
752
|
detect: detect,
|
@@ -823,7 +815,7 @@ Some browser-interfacing methods and switches that we can't currently get rid of
|
|
823
815
|
*/
|
824
816
|
|
825
817
|
(function() {
|
826
|
-
var
|
818
|
+
var slice = [].slice;
|
827
819
|
|
828
820
|
up.browser = (function() {
|
829
821
|
var canCssAnimation, canInputEvent, canPushState, ensureConsoleExists, ensureRecentJquery, isSupported, loadPage, memoize, u, url;
|
@@ -858,16 +850,17 @@ Some browser-interfacing methods and switches that we can't currently get rid of
|
|
858
850
|
return location.href;
|
859
851
|
};
|
860
852
|
ensureConsoleExists = function() {
|
861
|
-
var
|
853
|
+
var base, base1, base2, base3, base4, base5, base6, base7, noop;
|
862
854
|
window.console || (window.console = {});
|
863
855
|
noop = function() {};
|
864
|
-
(
|
865
|
-
(
|
866
|
-
(
|
867
|
-
(
|
868
|
-
(
|
869
|
-
(
|
870
|
-
|
856
|
+
(base = window.console).log || (base.log = noop);
|
857
|
+
(base1 = window.console).info || (base1.info = noop);
|
858
|
+
(base2 = window.console).error || (base2.error = noop);
|
859
|
+
(base3 = window.console).debug || (base3.debug = noop);
|
860
|
+
(base4 = window.console).warn || (base4.warn = noop);
|
861
|
+
(base5 = window.console).group || (base5.group = noop);
|
862
|
+
(base6 = window.console).groupCollapsed || (base6.groupCollapsed = noop);
|
863
|
+
return (base7 = window.console).groupEnd || (base7.groupEnd = noop);
|
871
864
|
};
|
872
865
|
memoize = function(func) {
|
873
866
|
var cache, cached;
|
@@ -875,7 +868,7 @@ Some browser-interfacing methods and switches that we can't currently get rid of
|
|
875
868
|
cached = false;
|
876
869
|
return function() {
|
877
870
|
var args;
|
878
|
-
args = 1 <= arguments.length ?
|
871
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
879
872
|
if (cached) {
|
880
873
|
return cache;
|
881
874
|
} else {
|
@@ -965,7 +958,7 @@ We need to work on this page:
|
|
965
958
|
*/
|
966
959
|
|
967
960
|
(function() {
|
968
|
-
var
|
961
|
+
var slice = [].slice;
|
969
962
|
|
970
963
|
up.bus = (function() {
|
971
964
|
var callbacksByEvent, callbacksFor, defaultCallbacksByEvent, emit, listen, reset, snapshot, u;
|
@@ -984,14 +977,14 @@ We need to work on this page:
|
|
984
977
|
@method up.bus.snapshot
|
985
978
|
*/
|
986
979
|
snapshot = function() {
|
987
|
-
var callbacks, event,
|
980
|
+
var callbacks, event, results;
|
988
981
|
defaultCallbacksByEvent = {};
|
989
|
-
|
982
|
+
results = [];
|
990
983
|
for (event in callbacksByEvent) {
|
991
984
|
callbacks = callbacksByEvent[event];
|
992
|
-
|
985
|
+
results.push(defaultCallbacksByEvent[event] = u.copy(callbacks));
|
993
986
|
}
|
994
|
-
return
|
987
|
+
return results;
|
995
988
|
};
|
996
989
|
|
997
990
|
/**
|
@@ -1044,7 +1037,7 @@ We need to work on this page:
|
|
1044
1037
|
*/
|
1045
1038
|
emit = function() {
|
1046
1039
|
var args, callbacks, eventName;
|
1047
|
-
eventName = arguments[0], args = 2 <= arguments.length ?
|
1040
|
+
eventName = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
1048
1041
|
u.debug("Emitting event %o with args %o", eventName, args);
|
1049
1042
|
callbacks = callbacksFor(eventName);
|
1050
1043
|
return u.each(callbacks, function(callback) {
|
@@ -1214,7 +1207,7 @@ We need to work on this page:
|
|
1214
1207
|
|
1215
1208
|
(function() {
|
1216
1209
|
up.flow = (function() {
|
1217
|
-
var autofocus, destroy, elementsInserted, findOldFragment, implant, parseImplantSteps, parseResponse, prepareForReplacement, reload, replace, reset, reveal, setSource, source, swapElements, u;
|
1210
|
+
var autofocus, destroy, elementsInserted, findOldFragment, fragmentNotFound, implant, parseImplantSteps, parseResponse, prepareForReplacement, reload, replace, reset, reveal, setSource, source, swapElements, u;
|
1218
1211
|
u = up.util;
|
1219
1212
|
setSource = function(element, sourceUrl) {
|
1220
1213
|
var $element;
|
@@ -1301,7 +1294,16 @@ We need to work on this page:
|
|
1301
1294
|
};
|
1302
1295
|
|
1303
1296
|
/**
|
1304
|
-
|
1297
|
+
Updates a selector on the current page with the
|
1298
|
+
same selector from the given HTML string.
|
1299
|
+
|
1300
|
+
Example:
|
1301
|
+
|
1302
|
+
html = '<div class="before">new-before</div>' +
|
1303
|
+
'<div class="middle">new-middle</div>' +
|
1304
|
+
'<div class="after">new-after</div>';
|
1305
|
+
|
1306
|
+
up.flow.implant('.middle', html):
|
1305
1307
|
|
1306
1308
|
@method up.flow.implant
|
1307
1309
|
@protected
|
@@ -1315,7 +1317,7 @@ We need to work on this page:
|
|
1315
1317
|
@param {String} [options.historyMethod='push']
|
1316
1318
|
*/
|
1317
1319
|
implant = function(selector, html, options) {
|
1318
|
-
var $new, $old,
|
1320
|
+
var $new, $old, j, len, ref, response, results, step;
|
1319
1321
|
options = u.options(options, {
|
1320
1322
|
historyMethod: 'push'
|
1321
1323
|
});
|
@@ -1328,30 +1330,38 @@ We need to work on this page:
|
|
1328
1330
|
options.source = u.option(options.source, options.history);
|
1329
1331
|
response = parseResponse(html);
|
1330
1332
|
options.title || (options.title = response.title());
|
1331
|
-
|
1332
|
-
|
1333
|
-
for (
|
1334
|
-
step =
|
1333
|
+
ref = parseImplantSteps(selector, options);
|
1334
|
+
results = [];
|
1335
|
+
for (j = 0, len = ref.length; j < len; j++) {
|
1336
|
+
step = ref[j];
|
1335
1337
|
$old = findOldFragment(step.selector);
|
1336
1338
|
$new = response.find(step.selector);
|
1337
|
-
|
1339
|
+
results.push(prepareForReplacement($old, options).then(function() {
|
1338
1340
|
return swapElements($old, $new, step.pseudoClass, step.transition, options);
|
1339
1341
|
}));
|
1340
1342
|
}
|
1341
|
-
return
|
1343
|
+
return results;
|
1342
1344
|
};
|
1343
1345
|
findOldFragment = function(selector) {
|
1344
1346
|
var selectorWithExcludes;
|
1345
1347
|
selectorWithExcludes = selector + ":not(.up-ghost, .up-destroying)";
|
1346
|
-
return u.presence($(".up-popup " + selectorWithExcludes)) || u.presence($(".up-modal " + selectorWithExcludes)) || u.presence($(selectorWithExcludes)) ||
|
1348
|
+
return u.presence($(".up-popup " + selectorWithExcludes)) || u.presence($(".up-modal " + selectorWithExcludes)) || u.presence($(selectorWithExcludes)) || fragmentNotFound(selector);
|
1349
|
+
};
|
1350
|
+
fragmentNotFound = function(selector) {
|
1351
|
+
var message;
|
1352
|
+
message = 'Could not find selector %o in current body HTML';
|
1353
|
+
if (message[0] === '#') {
|
1354
|
+
message += ' (avoid using IDs)';
|
1355
|
+
}
|
1356
|
+
return u.error(message, selector);
|
1347
1357
|
};
|
1348
1358
|
parseResponse = function(html) {
|
1349
1359
|
var htmlElement;
|
1350
1360
|
htmlElement = u.createElementFromHtml(html);
|
1351
1361
|
return {
|
1352
1362
|
title: function() {
|
1353
|
-
var
|
1354
|
-
return (
|
1363
|
+
var ref;
|
1364
|
+
return (ref = htmlElement.querySelector("title")) != null ? ref.textContent : void 0;
|
1355
1365
|
},
|
1356
1366
|
find: function(selector) {
|
1357
1367
|
var child;
|
@@ -1414,25 +1424,25 @@ We need to work on this page:
|
|
1414
1424
|
}
|
1415
1425
|
};
|
1416
1426
|
parseImplantSteps = function(selector, options) {
|
1417
|
-
var comma, disjunction, i,
|
1427
|
+
var comma, disjunction, i, j, len, results, selectorAtom, selectorParts, transition, transitionString, transitions;
|
1418
1428
|
transitionString = options.transition || options.animation || 'none';
|
1419
1429
|
comma = /\ *,\ */;
|
1420
1430
|
disjunction = selector.split(comma);
|
1421
1431
|
if (u.isPresent(transitionString)) {
|
1422
1432
|
transitions = transitionString.split(comma);
|
1423
1433
|
}
|
1424
|
-
|
1425
|
-
for (i =
|
1434
|
+
results = [];
|
1435
|
+
for (i = j = 0, len = disjunction.length; j < len; i = ++j) {
|
1426
1436
|
selectorAtom = disjunction[i];
|
1427
1437
|
selectorParts = selectorAtom.match(/^(.+?)(?:\:(before|after))?$/);
|
1428
1438
|
transition = transitions[i] || u.last(transitions);
|
1429
|
-
|
1439
|
+
results.push({
|
1430
1440
|
selector: selectorParts[1],
|
1431
1441
|
pseudoClass: selectorParts[2],
|
1432
1442
|
transition: transition
|
1433
1443
|
});
|
1434
1444
|
}
|
1435
|
-
return
|
1445
|
+
return results;
|
1436
1446
|
};
|
1437
1447
|
autofocus = function($element) {
|
1438
1448
|
var $control, selector;
|
@@ -1557,10 +1567,10 @@ We need to work on this page:
|
|
1557
1567
|
*/
|
1558
1568
|
|
1559
1569
|
(function() {
|
1560
|
-
var
|
1570
|
+
var slice = [].slice;
|
1561
1571
|
|
1562
1572
|
up.magic = (function() {
|
1563
|
-
var DESTROYABLE_CLASS, DESTROYER_KEY,
|
1573
|
+
var DESTROYABLE_CLASS, DESTROYER_KEY, applyCompiler, compile, compiler, compilers, data, defaultCompilers, defaultLiveDescriptions, destroy, live, liveDescriptions, onEscape, ready, reset, snapshot, u;
|
1564
1574
|
u = up.util;
|
1565
1575
|
DESTROYABLE_CLASS = 'up-destroyable';
|
1566
1576
|
DESTROYER_KEY = 'up-destroyer';
|
@@ -1624,7 +1634,7 @@ We need to work on this page:
|
|
1624
1634
|
liveDescriptions = [];
|
1625
1635
|
defaultLiveDescriptions = null;
|
1626
1636
|
live = function(events, selector, behavior) {
|
1627
|
-
var description,
|
1637
|
+
var description, ref;
|
1628
1638
|
if (!up.browser.isSupported()) {
|
1629
1639
|
return;
|
1630
1640
|
}
|
@@ -1634,7 +1644,7 @@ We need to work on this page:
|
|
1634
1644
|
}
|
1635
1645
|
];
|
1636
1646
|
liveDescriptions.push(description);
|
1637
|
-
return (
|
1647
|
+
return (ref = $(document)).on.apply(ref, description);
|
1638
1648
|
};
|
1639
1649
|
|
1640
1650
|
/**
|
@@ -1651,24 +1661,24 @@ We need to work on this page:
|
|
1651
1661
|
|
1652
1662
|
This Javascript will do exactly that:
|
1653
1663
|
|
1654
|
-
up.
|
1664
|
+
up.compiler('a[rel=lightbox]', function($element) {
|
1655
1665
|
$element.lightboxify();
|
1656
1666
|
});
|
1657
1667
|
|
1658
|
-
Note that within the
|
1668
|
+
Note that within the compiler, Up.js will bind `this` to the
|
1659
1669
|
native DOM element to help you migrate your existing jQuery code to
|
1660
1670
|
this new syntax.
|
1661
1671
|
|
1662
1672
|
|
1663
1673
|
\#\#\#\# Custom elements
|
1664
1674
|
|
1665
|
-
You can also use `up.
|
1675
|
+
You can also use `up.compiler` to implement custom elements like this:
|
1666
1676
|
|
1667
1677
|
<current-time></current-time>
|
1668
1678
|
|
1669
1679
|
Here is the Javascript that inserts the current time into to these elements:
|
1670
1680
|
|
1671
|
-
up.
|
1681
|
+
up.compiler('current-time', function($element) {
|
1672
1682
|
var now = new Date();
|
1673
1683
|
$element.text(now.toString()));
|
1674
1684
|
});
|
@@ -1676,19 +1686,19 @@ We need to work on this page:
|
|
1676
1686
|
|
1677
1687
|
\#\#\#\# Cleaning up after yourself
|
1678
1688
|
|
1679
|
-
If your
|
1689
|
+
If your compiler returns a function, Up.js will use this as a *destructor* to
|
1680
1690
|
clean up if the element leaves the DOM. Note that in Up.js the same DOM ad Javascript environment
|
1681
1691
|
will persist through many page loads, so it's important to not create
|
1682
1692
|
[memory leaks](https://makandracards.com/makandra/31325-how-to-create-memory-leaks-in-jquery).
|
1683
1693
|
|
1684
|
-
You should clean up after yourself whenever your
|
1694
|
+
You should clean up after yourself whenever your compilers have global
|
1685
1695
|
side effects, like a [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval)
|
1686
1696
|
or event handlers bound to the document root.
|
1687
1697
|
|
1688
1698
|
Here is a version of `<current-time>` that updates
|
1689
1699
|
the time every second, and cleans up once it's done:
|
1690
1700
|
|
1691
|
-
up.
|
1701
|
+
up.compiler('current-time', function($element) {
|
1692
1702
|
|
1693
1703
|
function update() {
|
1694
1704
|
var now = new Date();
|
@@ -1722,7 +1732,7 @@ We need to work on this page:
|
|
1722
1732
|
|
1723
1733
|
The JSON will parsed and handed to your event handler as a second argument:
|
1724
1734
|
|
1725
|
-
up.
|
1735
|
+
up.compiler('.google-map', function($element, pins) {
|
1726
1736
|
|
1727
1737
|
var map = new google.maps.Map($element);
|
1728
1738
|
|
@@ -1740,75 +1750,77 @@ We need to work on this page:
|
|
1740
1750
|
|
1741
1751
|
\#\#\#\# Migrating jQuery event handlers to `up.on`
|
1742
1752
|
|
1743
|
-
Within the
|
1753
|
+
Within the compiler, Up.js will bind `this` to the
|
1744
1754
|
native DOM element to help you migrate your existing jQuery code to
|
1745
1755
|
this new syntax.
|
1746
1756
|
|
1747
1757
|
|
1748
|
-
@method up.
|
1758
|
+
@method up.compiler
|
1749
1759
|
@param {String} selector
|
1750
1760
|
The selector to match.
|
1751
1761
|
@param {Boolean} [options.batch=false]
|
1752
1762
|
If set to `true` and a fragment insertion contains multiple
|
1753
|
-
elements matching the selector, `
|
1763
|
+
elements matching the selector, `compiler` is only called once
|
1754
1764
|
with a jQuery collection containing all matching elements.
|
1755
|
-
@param {Function($element, data)}
|
1765
|
+
@param {Function($element, data)} compiler
|
1756
1766
|
The function to call when a matching element is inserted.
|
1757
1767
|
The function takes the new element as the first argument (as a jQuery object).
|
1758
1768
|
If the element has an `up-data` attribute, its value is parsed as JSON
|
1759
1769
|
and passed as a second argument.
|
1760
1770
|
|
1761
|
-
The function may return
|
1762
|
-
object
|
1763
|
-
time-outs and event handlers bound to the document.
|
1771
|
+
The function may return a destructor function that destroys the compiled
|
1772
|
+
object before it is removed from the DOM. The destructor is supposed to
|
1773
|
+
clear global state such as time-outs and event handlers bound to the document.
|
1774
|
+
The destructor is *not* expected to remove the element from the DOM, which
|
1775
|
+
is already handled by [`up.destroy`](/up.flow#up.destroy).
|
1764
1776
|
*/
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
var args,
|
1769
|
-
selector = arguments[0], args = 2 <= arguments.length ?
|
1777
|
+
compilers = [];
|
1778
|
+
defaultCompilers = null;
|
1779
|
+
compiler = function() {
|
1780
|
+
var args, options, selector;
|
1781
|
+
selector = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
1770
1782
|
if (!up.browser.isSupported()) {
|
1771
1783
|
return;
|
1772
1784
|
}
|
1773
|
-
|
1785
|
+
compiler = args.pop();
|
1774
1786
|
options = u.options(args[0], {
|
1775
1787
|
batch: false
|
1776
1788
|
});
|
1777
|
-
return
|
1789
|
+
return compilers.push({
|
1778
1790
|
selector: selector,
|
1779
|
-
callback:
|
1791
|
+
callback: compiler,
|
1780
1792
|
batch: options.batch
|
1781
1793
|
});
|
1782
1794
|
};
|
1783
|
-
|
1795
|
+
applyCompiler = function(compiler, $jqueryElement, nativeElement) {
|
1784
1796
|
var destroyer;
|
1785
|
-
u.debug("Applying
|
1786
|
-
destroyer =
|
1797
|
+
u.debug("Applying compiler %o on %o", compiler.selector, nativeElement);
|
1798
|
+
destroyer = compiler.callback.apply(nativeElement, [$jqueryElement, data($jqueryElement)]);
|
1787
1799
|
if (u.isFunction(destroyer)) {
|
1788
1800
|
$jqueryElement.addClass(DESTROYABLE_CLASS);
|
1789
1801
|
return $jqueryElement.data(DESTROYER_KEY, destroyer);
|
1790
1802
|
}
|
1791
1803
|
};
|
1792
1804
|
compile = function($fragment) {
|
1793
|
-
var $matches,
|
1805
|
+
var $matches, i, len, results;
|
1794
1806
|
u.debug("Compiling fragment %o", $fragment);
|
1795
|
-
|
1796
|
-
for (
|
1797
|
-
|
1798
|
-
$matches = u.findWithSelf($fragment,
|
1807
|
+
results = [];
|
1808
|
+
for (i = 0, len = compilers.length; i < len; i++) {
|
1809
|
+
compiler = compilers[i];
|
1810
|
+
$matches = u.findWithSelf($fragment, compiler.selector);
|
1799
1811
|
if ($matches.length) {
|
1800
|
-
if (
|
1801
|
-
|
1812
|
+
if (compiler.batch) {
|
1813
|
+
results.push(applyCompiler(compiler, $matches, $matches.get()));
|
1802
1814
|
} else {
|
1803
|
-
|
1804
|
-
return
|
1815
|
+
results.push($matches.each(function() {
|
1816
|
+
return applyCompiler(compiler, $(this), this);
|
1805
1817
|
}));
|
1806
1818
|
}
|
1807
1819
|
} else {
|
1808
|
-
|
1820
|
+
results.push(void 0);
|
1809
1821
|
}
|
1810
1822
|
}
|
1811
|
-
return
|
1823
|
+
return results;
|
1812
1824
|
};
|
1813
1825
|
destroy = function($fragment) {
|
1814
1826
|
return u.findWithSelf($fragment, "." + DESTROYABLE_CLASS).each(function() {
|
@@ -1838,7 +1850,7 @@ We need to work on this page:
|
|
1838
1850
|
|
1839
1851
|
If an element annotated with [`up-data`] is inserted into the DOM,
|
1840
1852
|
Up will parse the JSON and pass the resulting object to any matching
|
1841
|
-
[`up.
|
1853
|
+
[`up.compiler`](/up.magic#up.magic.compiler) handlers.
|
1842
1854
|
|
1843
1855
|
Similarly, when an event is triggered on an element annotated with
|
1844
1856
|
[`up-data`], the parsed object will be passed to any matching
|
@@ -1868,7 +1880,7 @@ We need to work on this page:
|
|
1868
1880
|
*/
|
1869
1881
|
snapshot = function() {
|
1870
1882
|
defaultLiveDescriptions = u.copy(liveDescriptions);
|
1871
|
-
return
|
1883
|
+
return defaultCompilers = u.copy(compilers);
|
1872
1884
|
};
|
1873
1885
|
|
1874
1886
|
/**
|
@@ -1879,15 +1891,15 @@ We need to work on this page:
|
|
1879
1891
|
@method up.magic.reset
|
1880
1892
|
*/
|
1881
1893
|
reset = function() {
|
1882
|
-
var description,
|
1883
|
-
for (
|
1884
|
-
description = liveDescriptions[
|
1894
|
+
var description, i, len, ref;
|
1895
|
+
for (i = 0, len = liveDescriptions.length; i < len; i++) {
|
1896
|
+
description = liveDescriptions[i];
|
1885
1897
|
if (!u.contains(defaultLiveDescriptions, description)) {
|
1886
|
-
(
|
1898
|
+
(ref = $(document)).off.apply(ref, description);
|
1887
1899
|
}
|
1888
1900
|
}
|
1889
1901
|
liveDescriptions = u.copy(defaultLiveDescriptions);
|
1890
|
-
return
|
1902
|
+
return compilers = u.copy(defaultCompilers);
|
1891
1903
|
};
|
1892
1904
|
|
1893
1905
|
/**
|
@@ -1923,7 +1935,7 @@ We need to work on this page:
|
|
1923
1935
|
up.bus.on('framework:ready', snapshot);
|
1924
1936
|
up.bus.on('framework:reset', reset);
|
1925
1937
|
return {
|
1926
|
-
|
1938
|
+
compiler: compiler,
|
1927
1939
|
on: live,
|
1928
1940
|
ready: ready,
|
1929
1941
|
onEscape: onEscape,
|
@@ -1931,12 +1943,19 @@ We need to work on this page:
|
|
1931
1943
|
};
|
1932
1944
|
})();
|
1933
1945
|
|
1934
|
-
up.
|
1946
|
+
up.compiler = up.magic.compiler;
|
1935
1947
|
|
1936
1948
|
up.on = up.magic.on;
|
1937
1949
|
|
1938
1950
|
up.ready = up.magic.ready;
|
1939
1951
|
|
1952
|
+
up.awaken = function() {
|
1953
|
+
var args;
|
1954
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
1955
|
+
up.util.warn("up.awaken has been renamed to up.compiler and will be removed in a future version");
|
1956
|
+
return up.compiler.apply(up, args);
|
1957
|
+
};
|
1958
|
+
|
1940
1959
|
}).call(this);
|
1941
1960
|
|
1942
1961
|
/**
|
@@ -3200,7 +3219,7 @@ Read on
|
|
3200
3219
|
@method [up-dash]
|
3201
3220
|
@ujs
|
3202
3221
|
*/
|
3203
|
-
up.
|
3222
|
+
up.compiler('[up-dash]', function($element) {
|
3204
3223
|
var newAttrs, target;
|
3205
3224
|
target = $element.attr('up-dash');
|
3206
3225
|
newAttrs = {
|
@@ -3523,7 +3542,7 @@ We need to work on this page:
|
|
3523
3542
|
@ujs
|
3524
3543
|
@param {String} up-observe
|
3525
3544
|
*/
|
3526
|
-
up.
|
3545
|
+
up.compiler('[up-observe]', function($field) {
|
3527
3546
|
return observe($field);
|
3528
3547
|
});
|
3529
3548
|
return {
|
@@ -3841,7 +3860,7 @@ For small popup overlays ("dropdowns") see [up.popup](/up.popup) instead.
|
|
3841
3860
|
*/
|
3842
3861
|
|
3843
3862
|
(function() {
|
3844
|
-
var
|
3863
|
+
var slice = [].slice;
|
3845
3864
|
|
3846
3865
|
up.modal = (function() {
|
3847
3866
|
var autoclose, close, config, createHiddenModal, defaults, discardHistory, open, rememberHistory, source, templateHtml, u, updated;
|
@@ -3984,7 +4003,7 @@ For small popup overlays ("dropdowns") see [up.popup](/up.popup) instead.
|
|
3984
4003
|
*/
|
3985
4004
|
open = function() {
|
3986
4005
|
var $link, $modal, animateOptions, animation, args, height, history, options, selector, sticky, url, width;
|
3987
|
-
args = 1 <= arguments.length ?
|
4006
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
3988
4007
|
if (u.isObject(args[0]) && !u.isElement(args[0]) && !u.isJQuery(args[0])) {
|
3989
4008
|
$link = u.nullJquery();
|
3990
4009
|
options = args[0];
|
@@ -4270,7 +4289,7 @@ We need to work on this page:
|
|
4270
4289
|
@method [up-tooltip]
|
4271
4290
|
@ujs
|
4272
4291
|
*/
|
4273
|
-
up.
|
4292
|
+
up.compiler('[up-tooltip]', function($link) {
|
4274
4293
|
$link.on('mouseover', function() {
|
4275
4294
|
return open($link);
|
4276
4295
|
});
|
@@ -4328,13 +4347,13 @@ From Up's point of view the "current" location is either:
|
|
4328
4347
|
SELECTORS_SECTION = ['a[href]', 'a[up-target]', '[up-follow]', '[up-modal]', '[up-popup]', '[up-href]'];
|
4329
4348
|
SELECTOR_SECTION = SELECTORS_SECTION.join(', ');
|
4330
4349
|
SELECTOR_SECTION_INSTANT = ((function() {
|
4331
|
-
var
|
4332
|
-
|
4333
|
-
for (
|
4334
|
-
selector = SELECTORS_SECTION[
|
4335
|
-
|
4350
|
+
var i, len, results;
|
4351
|
+
results = [];
|
4352
|
+
for (i = 0, len = SELECTORS_SECTION.length; i < len; i++) {
|
4353
|
+
selector = SELECTORS_SECTION[i];
|
4354
|
+
results.push(selector + "[up-instant]");
|
4336
4355
|
}
|
4337
|
-
return
|
4356
|
+
return results;
|
4338
4357
|
})()).join(', ');
|
4339
4358
|
SELECTOR_ACTIVE = "." + CLASS_ACTIVE;
|
4340
4359
|
normalizeUrl = function(url) {
|
@@ -4346,12 +4365,12 @@ From Up's point of view the "current" location is either:
|
|
4346
4365
|
}
|
4347
4366
|
};
|
4348
4367
|
sectionUrls = function($section) {
|
4349
|
-
var $link, attr,
|
4368
|
+
var $link, attr, i, len, ref, url, urls;
|
4350
4369
|
urls = [];
|
4351
4370
|
if ($link = up.link.resolve($section)) {
|
4352
|
-
|
4353
|
-
for (
|
4354
|
-
attr =
|
4371
|
+
ref = ['href', 'up-follow', 'up-href'];
|
4372
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
4373
|
+
attr = ref[i];
|
4355
4374
|
if (url = u.presentAttr($link, attr)) {
|
4356
4375
|
url = normalizeUrl(url);
|
4357
4376
|
urls.push(url);
|
@@ -4420,10 +4439,7 @@ For example, you might have
|
|
4420
4439
|
<div up-slot class="alerts"></div>
|
4421
4440
|
|
4422
4441
|
<script>
|
4423
|
-
up.
|
4424
|
-
|
4425
|
-
RELOAD SHOULD NOT CACHE
|
4426
|
-
|
4442
|
+
up.compiler('.alerts', function ($element) {
|
4427
4443
|
setInterval(3000, function() { up.reload('.alerts') });
|
4428
4444
|
});
|
4429
4445
|
</script>
|