upjs-rails 0.3.0 → 0.3.2
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.
- checksums.yaml +4 -4
- data/dist/up.css +5 -1
- data/dist/up.js +239 -95
- data/dist/up.min.css +1 -1
- data/dist/up.min.js +1 -1
- data/lib/assets/javascripts/up.js.coffee +6 -2
- data/lib/assets/javascripts/up/browser.js.coffee +52 -0
- data/lib/assets/javascripts/up/flow.js.coffee +9 -2
- data/lib/assets/javascripts/up/form.js.coffee +4 -0
- data/lib/assets/javascripts/up/history.js.coffee +10 -6
- data/lib/assets/javascripts/up/magic.js.coffee +4 -0
- data/lib/assets/javascripts/up/marker.js.coffee +4 -2
- data/lib/assets/javascripts/up/modal.js.coffee +1 -1
- data/lib/assets/javascripts/up/motion.js.coffee +28 -26
- data/lib/assets/javascripts/up/popup.js.coffee +1 -1
- data/lib/assets/javascripts/up/util.js.coffee +99 -38
- data/lib/assets/stylesheets/up/modal.css.sass +7 -2
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/spec/javascripts/helpers/reset_path.js.coffee +1 -1
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +90 -68
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +90 -77
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +35 -24
- data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +52 -50
- 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: f2bd908d4b8ae9ccc80617aab947a39f49e91cd6
|
4
|
+
data.tar.gz: 3d82e0f710813f128f9e8ae4aa48311b0990c04f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eac37753503ff8163ff92fc7e37b34c3a8c20a1d76033e0f5784ed6077f52cd4b4bb8e84cc3584c68e83d559f9e7f5a2d62eb9a89f292408de556428a1bfbe3
|
7
|
+
data.tar.gz: e8fe7e337a8c754f45b5fe0b5e849ed79d60a8bb95b819a33236a4d98178ddaa4d228489cd48f854099692b31f2f8e21b757e85c2cf03e0ff7afa5f6fd31a4c5
|
data/dist/up.css
CHANGED
@@ -16,6 +16,8 @@
|
|
16
16
|
top: 50%;
|
17
17
|
left: 50%;
|
18
18
|
transform: translate(-50%, -50%);
|
19
|
+
-ms-transform: translate(-50%, -50%);
|
20
|
+
-webkit-transform: translate(-50%, -50%);
|
19
21
|
max-width: 100%;
|
20
22
|
max-height: 100%;
|
21
23
|
background-color: #fff;
|
@@ -35,7 +37,9 @@
|
|
35
37
|
font-weight: bold;
|
36
38
|
text-transform: uppercase;
|
37
39
|
cursor: pointer;
|
38
|
-
transform: translateY(-100%);
|
40
|
+
transform: translateY(-100%);
|
41
|
+
-ms-transform: translateY(-100%);
|
42
|
+
-webkit-transform: translateY(-100%); }
|
39
43
|
|
40
44
|
.up-modal-content {
|
41
45
|
overflow-x: hidden;
|
data/dist/up.js
CHANGED
@@ -25,7 +25,7 @@ If you use them in your own code, you will get hurt.
|
|
25
25
|
var __slice = [].slice;
|
26
26
|
|
27
27
|
up.util = (function() {
|
28
|
-
var $createElementFromSelector, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, detect, each, error, escapePressed, extend, findWithSelf, forceCompositing, get, ifGiven, isArray, isBlank, isDefined, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, last, locationFromXhr, measure, merge, nextFrame, normalizeUrl, option, options, prependGhost, presence, presentAttr, select, temporaryCss, unwrap;
|
28
|
+
var $createElementFromSelector, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, detect, each, error, escapePressed, extend, findWithSelf, forceCompositing, get, ifGiven, isArray, isBlank, isDefined, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, keys, last, locationFromXhr, measure, merge, nextFrame, normalizeUrl, only, option, options, prependGhost, presence, presentAttr, resolvedPromise, select, temporaryCss, trim, unwrap;
|
29
29
|
get = function(url, options) {
|
30
30
|
options = options || {};
|
31
31
|
options.url = url;
|
@@ -126,7 +126,9 @@ If you use them in your own code, you will get hurt.
|
|
126
126
|
createElement = function(tagName, html) {
|
127
127
|
var element;
|
128
128
|
element = document.createElement(tagName);
|
129
|
-
|
129
|
+
if (isPresent(html)) {
|
130
|
+
element.innerHTML = html;
|
131
|
+
}
|
130
132
|
return element;
|
131
133
|
};
|
132
134
|
error = function() {
|
@@ -153,17 +155,47 @@ If you use them in your own code, you will get hurt.
|
|
153
155
|
return selector;
|
154
156
|
};
|
155
157
|
createElementFromHtml = function(html) {
|
156
|
-
var
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
158
|
+
var anything, bodyElement, bodyMatch, bodyPattern, capture, closeTag, headElement, htmlElement, openTag, titleElement, titleMatch, titlePattern;
|
159
|
+
openTag = function(tag) {
|
160
|
+
return "<" + tag + "(?: [^>]*)?>";
|
161
|
+
};
|
162
|
+
closeTag = function(tag) {
|
163
|
+
return "</" + tag + ">";
|
164
|
+
};
|
165
|
+
anything = '(?:.|\\n)*?';
|
166
|
+
capture = function(pattern) {
|
167
|
+
return "(" + pattern + ")";
|
168
|
+
};
|
169
|
+
titlePattern = new RegExp(openTag('head') + anything + openTag('title') + capture(anything) + closeTag('title') + anything + closeTag('body'), 'i');
|
170
|
+
bodyPattern = new RegExp(openTag('body') + capture(anything) + closeTag('body'), 'i');
|
171
|
+
if (bodyMatch = html.match(bodyPattern)) {
|
172
|
+
htmlElement = document.createElement('html');
|
173
|
+
bodyElement = createElement('body', bodyMatch[1]);
|
174
|
+
htmlElement.appendChild(bodyElement);
|
175
|
+
if (titleMatch = html.match(titlePattern)) {
|
176
|
+
headElement = createElement('head');
|
177
|
+
htmlElement.appendChild(headElement);
|
178
|
+
titleElement = createElement('title', titleMatch[1]);
|
179
|
+
headElement.appendChild(titleElement);
|
180
|
+
}
|
181
|
+
return htmlElement;
|
161
182
|
} else {
|
162
|
-
|
183
|
+
return createElement('div', html);
|
163
184
|
}
|
164
|
-
return createElement('html', innerHtml);
|
165
185
|
};
|
166
186
|
extend = $.extend;
|
187
|
+
trim = $.trim;
|
188
|
+
keys = Object.keys || function(object) {
|
189
|
+
var key, result, _i, _len;
|
190
|
+
result = [];
|
191
|
+
for (_i = 0, _len = object.length; _i < _len; _i++) {
|
192
|
+
key = object[_i];
|
193
|
+
if (object.hasOwnProperty(key)) {
|
194
|
+
result.push(key);
|
195
|
+
}
|
196
|
+
}
|
197
|
+
return result;
|
198
|
+
};
|
167
199
|
each = function(collection, block) {
|
168
200
|
var index, item, _i, _len, _results;
|
169
201
|
_results = [];
|
@@ -189,7 +221,7 @@ If you use them in your own code, you will get hurt.
|
|
189
221
|
return !isMissing(object);
|
190
222
|
};
|
191
223
|
isBlank = function(object) {
|
192
|
-
return isMissing(object) || (isObject(object) &&
|
224
|
+
return isMissing(object) || (isObject(object) && keys(object).length === 0) || (object.length === 0);
|
193
225
|
};
|
194
226
|
presence = function(object, checker) {
|
195
227
|
if (checker == null) {
|
@@ -227,7 +259,9 @@ If you use them in your own code, you will get hurt.
|
|
227
259
|
return object;
|
228
260
|
}
|
229
261
|
};
|
230
|
-
isArray = Array.isArray
|
262
|
+
isArray = Array.isArray || function(object) {
|
263
|
+
return Object.prototype.toString.call(object) === '[object Array]';
|
264
|
+
};
|
231
265
|
copy = function(object) {
|
232
266
|
if (isArray(object)) {
|
233
267
|
return object.slice();
|
@@ -274,35 +308,32 @@ If you use them in your own code, you will get hurt.
|
|
274
308
|
@param {Array} args...
|
275
309
|
*/
|
276
310
|
option = function() {
|
277
|
-
var args, match;
|
311
|
+
var arg, args, match, value, _i, _len;
|
278
312
|
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
279
313
|
match = null;
|
280
|
-
args.
|
281
|
-
|
314
|
+
for (_i = 0, _len = args.length; _i < _len; _i++) {
|
315
|
+
arg = args[_i];
|
282
316
|
value = arg;
|
283
317
|
if (isFunction(value)) {
|
284
318
|
value = value();
|
285
319
|
}
|
286
320
|
if (isPresent(value)) {
|
287
321
|
match = value;
|
288
|
-
|
289
|
-
} else {
|
290
|
-
return true;
|
322
|
+
break;
|
291
323
|
}
|
292
|
-
}
|
324
|
+
}
|
293
325
|
return match;
|
294
326
|
};
|
295
327
|
detect = function(array, tester) {
|
296
|
-
var match;
|
328
|
+
var element, match, _i, _len;
|
297
329
|
match = null;
|
298
|
-
array.
|
330
|
+
for (_i = 0, _len = array.length; _i < _len; _i++) {
|
331
|
+
element = array[_i];
|
299
332
|
if (tester(element)) {
|
300
333
|
match = element;
|
301
|
-
|
302
|
-
} else {
|
303
|
-
return true;
|
334
|
+
break;
|
304
335
|
}
|
305
|
-
}
|
336
|
+
}
|
306
337
|
return match;
|
307
338
|
};
|
308
339
|
select = function(array, tester) {
|
@@ -345,7 +376,7 @@ If you use them in your own code, you will get hurt.
|
|
345
376
|
};
|
346
377
|
temporaryCss = function($element, css, block) {
|
347
378
|
var memo, oldCss;
|
348
|
-
oldCss = $element.css(
|
379
|
+
oldCss = $element.css(keys(css));
|
349
380
|
$element.css(css);
|
350
381
|
memo = function() {
|
351
382
|
return $element.css(oldCss);
|
@@ -395,28 +426,33 @@ If you use them in your own code, you will get hurt.
|
|
395
426
|
*/
|
396
427
|
cssAnimate = function(elementOrSelector, lastFrame, opts) {
|
397
428
|
var $element, deferred, transition, withoutCompositing, withoutTransition;
|
398
|
-
opts = options(opts, {
|
399
|
-
duration: 300,
|
400
|
-
delay: 0,
|
401
|
-
easing: 'ease'
|
402
|
-
});
|
403
429
|
$element = $(elementOrSelector);
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
430
|
+
if (up.browser.canCssAnimation()) {
|
431
|
+
opts = options(opts, {
|
432
|
+
duration: 300,
|
433
|
+
delay: 0,
|
434
|
+
easing: 'ease'
|
435
|
+
});
|
436
|
+
deferred = $.Deferred();
|
437
|
+
transition = {
|
438
|
+
'transition-property': keys(lastFrame).join(', '),
|
439
|
+
'transition-duration': opts.duration + "ms",
|
440
|
+
'transition-delay': opts.delay + "ms",
|
441
|
+
'transition-timing-function': opts.easing
|
442
|
+
};
|
443
|
+
withoutCompositing = forceCompositing($element);
|
444
|
+
withoutTransition = temporaryCss($element, transition);
|
445
|
+
$element.css(lastFrame);
|
446
|
+
deferred.then(withoutCompositing);
|
447
|
+
deferred.then(withoutTransition);
|
448
|
+
setTimeout((function() {
|
449
|
+
return deferred.resolve();
|
450
|
+
}), opts.duration + opts.delay);
|
451
|
+
return deferred.promise();
|
452
|
+
} else {
|
453
|
+
$element.css(lastFrame);
|
454
|
+
return resolvedPromise();
|
455
|
+
}
|
420
456
|
};
|
421
457
|
measure = function($element, options) {
|
422
458
|
var box, coordinates, viewport;
|
@@ -488,6 +524,24 @@ If you use them in your own code, you will get hurt.
|
|
488
524
|
locationFromXhr = function(xhr) {
|
489
525
|
return xhr.getResponseHeader('X-Up-Current-Location');
|
490
526
|
};
|
527
|
+
only = function() {
|
528
|
+
var filtered, key, keys, object, _i, _len;
|
529
|
+
object = arguments[0], keys = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
530
|
+
filtered = {};
|
531
|
+
for (_i = 0, _len = keys.length; _i < _len; _i++) {
|
532
|
+
key = keys[_i];
|
533
|
+
if (object.hasOwnProperty(key)) {
|
534
|
+
filtered[key] = object[key];
|
535
|
+
}
|
536
|
+
}
|
537
|
+
return filtered;
|
538
|
+
};
|
539
|
+
resolvedPromise = function() {
|
540
|
+
var deferred;
|
541
|
+
deferred = $.Deferred();
|
542
|
+
deferred.resolve();
|
543
|
+
return deferred.promise();
|
544
|
+
};
|
491
545
|
return {
|
492
546
|
presentAttr: presentAttr,
|
493
547
|
createElement: createElement,
|
@@ -537,7 +591,11 @@ If you use them in your own code, you will get hurt.
|
|
537
591
|
castsToTrue: castsToTrue,
|
538
592
|
castsToFalse: castsToFalse,
|
539
593
|
locationFromXhr: locationFromXhr,
|
540
|
-
clientSize: clientSize
|
594
|
+
clientSize: clientSize,
|
595
|
+
only: only,
|
596
|
+
trim: trim,
|
597
|
+
keys: keys,
|
598
|
+
resolvedPromise: resolvedPromise
|
541
599
|
};
|
542
600
|
})();
|
543
601
|
|
@@ -551,13 +609,76 @@ Browser interface
|
|
551
609
|
*/
|
552
610
|
|
553
611
|
(function() {
|
612
|
+
var __slice = [].slice;
|
613
|
+
|
554
614
|
up.browser = (function() {
|
555
|
-
var url;
|
615
|
+
var canCssAnimation, canPushState, ensureConsoleExists, isSupported, loadPage, memoize, u, url;
|
616
|
+
u = up.util;
|
617
|
+
loadPage = function(url, options) {
|
618
|
+
var $form, csrfParam, csrfToken, metadataInput, method, target;
|
619
|
+
if (options == null) {
|
620
|
+
options = {};
|
621
|
+
}
|
622
|
+
method = u.option(options.method, 'get').toLowerCase();
|
623
|
+
if (method === 'get') {
|
624
|
+
return location.href = url;
|
625
|
+
} else if ($.rails) {
|
626
|
+
target = options.target;
|
627
|
+
csrfToken = $.rails.csrfToken();
|
628
|
+
csrfParam = $.rails.csrfParam();
|
629
|
+
$form = $("<form method='post' action='" + url + "'></form>");
|
630
|
+
metadataInput = "<input name='_method' value='" + method + "' type='hidden' />";
|
631
|
+
if (u.isDefined(csrfParam) && u.isDefined(csrfToken)) {
|
632
|
+
metadataInput += "<input name='" + csrfParam + "' value='" + csrfToken + "' type='hidden' />";
|
633
|
+
}
|
634
|
+
if (target) {
|
635
|
+
$form.attr('target', target);
|
636
|
+
}
|
637
|
+
$form.hide().append(metadataInput).appendTo('body');
|
638
|
+
return $form.submit();
|
639
|
+
} else {
|
640
|
+
return error("Can't fake a " + (method.toUpperCase()) + " request without Rails UJS");
|
641
|
+
}
|
642
|
+
};
|
556
643
|
url = function() {
|
557
644
|
return location.href;
|
558
645
|
};
|
646
|
+
ensureConsoleExists = function() {
|
647
|
+
var _base;
|
648
|
+
window.console || (window.console = {});
|
649
|
+
return (_base = window.console).log || (_base.log = function() {});
|
650
|
+
};
|
651
|
+
memoize = function(func) {
|
652
|
+
var cache, cached;
|
653
|
+
cache = void 0;
|
654
|
+
cached = false;
|
655
|
+
return function() {
|
656
|
+
var args;
|
657
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
658
|
+
if (cached) {
|
659
|
+
return cache;
|
660
|
+
} else {
|
661
|
+
cached = true;
|
662
|
+
return cache = func.apply(null, args);
|
663
|
+
}
|
664
|
+
};
|
665
|
+
};
|
666
|
+
canPushState = memoize(function() {
|
667
|
+
return u.isDefined(history.pushState);
|
668
|
+
});
|
669
|
+
canCssAnimation = memoize(function() {
|
670
|
+
return 'transition' in document.documentElement.style;
|
671
|
+
});
|
672
|
+
isSupported = memoize(function() {
|
673
|
+
return u.isDefined(document.addEventListener);
|
674
|
+
});
|
559
675
|
return {
|
560
|
-
url: url
|
676
|
+
url: url,
|
677
|
+
ensureConsoleExists: ensureConsoleExists,
|
678
|
+
loadPage: loadPage,
|
679
|
+
canPushState: canPushState,
|
680
|
+
canCssAnimation: canCssAnimation,
|
681
|
+
isSupported: isSupported
|
561
682
|
};
|
562
683
|
})();
|
563
684
|
|
@@ -720,6 +841,7 @@ We need to work on this page:
|
|
720
841
|
@param {String} url
|
721
842
|
The URL to fetch from the server.
|
722
843
|
@param {String} [options.title]
|
844
|
+
@param {String} [options.method='get']
|
723
845
|
@param {String|Boolean} [options.history=true]
|
724
846
|
If a `String` is given, it is used as the URL the browser's location bar and history.
|
725
847
|
If omitted or true, the `url` argument will be used.
|
@@ -732,10 +854,14 @@ We need to work on this page:
|
|
732
854
|
var selector;
|
733
855
|
options = u.options(options);
|
734
856
|
selector = u.presence(selectorOrElement) ? selectorOrElement : u.createSelectorFromElement($(selectorOrElement));
|
857
|
+
if (!up.browser.canPushState() && !u.castsToFalse(options.history)) {
|
858
|
+
up.browser.loadPage(url, u.only(options, 'method'));
|
859
|
+
return;
|
860
|
+
}
|
735
861
|
return u.ajax({
|
736
862
|
url: url,
|
737
863
|
selector: selector
|
738
|
-
}).done(function(html, textStatus, xhr) {
|
864
|
+
}, u.only(options, 'method')).done(function(html, textStatus, xhr) {
|
739
865
|
var currentLocation;
|
740
866
|
if (currentLocation = u.locationFromXhr(xhr)) {
|
741
867
|
url = currentLocation;
|
@@ -778,7 +904,7 @@ We need to work on this page:
|
|
778
904
|
_results = [];
|
779
905
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
780
906
|
step = _ref1[_i];
|
781
|
-
$old = u.presence($(".up-popup " + step.selector)) || u.presence($(".up-modal " + step.selector)) || u.presence($(step.selector));
|
907
|
+
$old = u.presence($(".up-popup " + step.selector)) || u.presence($(".up-modal " + step.selector)) || u.presence($(step.selector)) || u.error("Could not find selector (" + step.selector + ") in current body HTML");
|
782
908
|
if (fragment = htmlElement.querySelector(step.selector)) {
|
783
909
|
$new = $(fragment);
|
784
910
|
_results.push(swapElements($old, $new, step.pseudoClass, step.transition, options));
|
@@ -981,6 +1107,9 @@ We need to work on this page:
|
|
981
1107
|
defaultLiveDescriptions = null;
|
982
1108
|
live = function(events, selector, behavior) {
|
983
1109
|
var description, _ref;
|
1110
|
+
if (!up.browser.isSupported()) {
|
1111
|
+
return;
|
1112
|
+
}
|
984
1113
|
description = [
|
985
1114
|
events, selector, function(event) {
|
986
1115
|
return behavior.apply(this, [event, $(this)]);
|
@@ -1014,6 +1143,9 @@ We need to work on this page:
|
|
1014
1143
|
awaken = function() {
|
1015
1144
|
var args, awakener, options, selector;
|
1016
1145
|
selector = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
1146
|
+
if (!up.browser.isSupported()) {
|
1147
|
+
return;
|
1148
|
+
}
|
1017
1149
|
awakener = args.pop();
|
1018
1150
|
options = u.options(args[0], {
|
1019
1151
|
batch: false
|
@@ -1194,10 +1326,14 @@ We need to work on this page:
|
|
1194
1326
|
}
|
1195
1327
|
};
|
1196
1328
|
manipulate = function(method, url) {
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1329
|
+
if (up.browser.canPushState()) {
|
1330
|
+
method += "State";
|
1331
|
+
return window.history[method]({
|
1332
|
+
fromUp: true
|
1333
|
+
}, '', url);
|
1334
|
+
} else {
|
1335
|
+
return u.error("This browser doesn't support history.pushState");
|
1336
|
+
}
|
1201
1337
|
};
|
1202
1338
|
pop = function(event) {
|
1203
1339
|
var state;
|
@@ -1212,12 +1348,14 @@ We need to work on this page:
|
|
1212
1348
|
return console.log("strange state", state);
|
1213
1349
|
}
|
1214
1350
|
};
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1351
|
+
if (up.browser.canPushState()) {
|
1352
|
+
setTimeout((function() {
|
1353
|
+
$(window).on("popstate", pop);
|
1354
|
+
return replace(up.browser.url(), {
|
1355
|
+
force: true
|
1356
|
+
});
|
1357
|
+
}), 200);
|
1358
|
+
}
|
1221
1359
|
return {
|
1222
1360
|
push: push,
|
1223
1361
|
replace: replace
|
@@ -1380,25 +1518,29 @@ We need to work on this page:
|
|
1380
1518
|
*/
|
1381
1519
|
morph = function(source, target, transitionOrName, options) {
|
1382
1520
|
var $new, $old, animation, parts, transition;
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
return
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1521
|
+
if (up.browser.canCssAnimation()) {
|
1522
|
+
options = u.options(config);
|
1523
|
+
$old = $(source);
|
1524
|
+
$new = $(target);
|
1525
|
+
transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName];
|
1526
|
+
if (transition) {
|
1527
|
+
return withGhosts($old, $new, function($oldGhost, $newGhost) {
|
1528
|
+
return assertIsPromise(transition($oldGhost, $newGhost, options), ["Transition did not return a promise", transitionOrName]);
|
1529
|
+
});
|
1530
|
+
} else if (animation = animations[transitionOrName]) {
|
1531
|
+
$old.hide();
|
1532
|
+
return animate($new, animation, options);
|
1533
|
+
} else if (u.isString(transitionOrName) && transitionOrName.indexOf('/') >= 0) {
|
1534
|
+
parts = transitionOrName.split('/');
|
1535
|
+
transition = function($old, $new, options) {
|
1536
|
+
return $.when(animate($old, parts[0], options), animate($new, parts[1], options));
|
1537
|
+
};
|
1538
|
+
return morph($old, $new, transition, options);
|
1539
|
+
} else {
|
1540
|
+
return u.error("Unknown transition: " + transitionOrName);
|
1541
|
+
}
|
1400
1542
|
} else {
|
1401
|
-
return u.
|
1543
|
+
return u.resolvedPromise();
|
1402
1544
|
}
|
1403
1545
|
};
|
1404
1546
|
|
@@ -1440,12 +1582,7 @@ We need to work on this page:
|
|
1440
1582
|
@return {Promise}
|
1441
1583
|
A resolved promise
|
1442
1584
|
*/
|
1443
|
-
none =
|
1444
|
-
var deferred;
|
1445
|
-
deferred = $.Deferred();
|
1446
|
-
deferred.resolve();
|
1447
|
-
return deferred.promise();
|
1448
|
-
};
|
1585
|
+
none = u.resolvedPromise;
|
1449
1586
|
animation('none', none);
|
1450
1587
|
animation('fade-in', function($ghost, options) {
|
1451
1588
|
$ghost.css({
|
@@ -1875,6 +2012,10 @@ We need to work on this page:
|
|
1875
2012
|
httpMethod = u.option(options.method, $form.attr('up-method'), $form.attr('data-method'), $form.attr('method'), 'post').toUpperCase();
|
1876
2013
|
url = u.option(options.url, $form.attr('action'), up.browser.url());
|
1877
2014
|
$form.addClass('up-active');
|
2015
|
+
if (!up.browser.canPushState() && !u.castsToFalse(historyOption)) {
|
2016
|
+
$form.get(0).submit();
|
2017
|
+
return;
|
2018
|
+
}
|
1878
2019
|
request = {
|
1879
2020
|
url: url,
|
1880
2021
|
type: httpMethod,
|
@@ -2180,7 +2321,7 @@ We need to work on this page:
|
|
2180
2321
|
origin = u.option(options.origin, $link.attr('up-origin'), config.origin);
|
2181
2322
|
animation = u.option(options.animation, $link.attr('up-animation'), config.openAnimation);
|
2182
2323
|
sticky = u.option(options.sticky, $link.is('[up-sticky]'));
|
2183
|
-
history = u.option(options.history, $link.attr('up-history'), false);
|
2324
|
+
history = up.browser.canPushState() ? u.option(options.history, $link.attr('up-history'), false) : false;
|
2184
2325
|
close();
|
2185
2326
|
$popup = createHiddenPopup($link, selector, sticky);
|
2186
2327
|
return up.replace(selector, url, {
|
@@ -2404,7 +2545,7 @@ We need to work on this page:
|
|
2404
2545
|
height = u.option(options.height, $link.attr('up-height'), config.height);
|
2405
2546
|
animation = u.option(options.animation, $link.attr('up-animation'), config.openAnimation);
|
2406
2547
|
sticky = u.option(options.sticky, $link.is('[up-sticky]'));
|
2407
|
-
history = u.option(options.history, $link.attr('up-history'), true);
|
2548
|
+
history = up.browser.canPushState() ? u.option(options.history, $link.attr('up-history'), true) : false;
|
2408
2549
|
close();
|
2409
2550
|
$modal = createHiddenModal(selector, width, height, sticky);
|
2410
2551
|
return up.replace(selector, url, {
|
@@ -2740,12 +2881,13 @@ TODO: Write some documentation
|
|
2740
2881
|
|
2741
2882
|
(function() {
|
2742
2883
|
up.marker = (function() {
|
2743
|
-
var check, hasContent;
|
2884
|
+
var check, hasContent, u;
|
2885
|
+
u = up.util;
|
2744
2886
|
hasContent = function($marker) {
|
2745
|
-
return $marker.html()
|
2887
|
+
return u.trim($marker.html()) !== '';
|
2746
2888
|
};
|
2747
2889
|
check = function($element) {
|
2748
|
-
return
|
2890
|
+
return u.findWithSelf($element, '[up-marker]').each(function() {
|
2749
2891
|
var $marker;
|
2750
2892
|
$marker = $(this);
|
2751
2893
|
if (!hasContent($marker)) {
|
@@ -2773,10 +2915,12 @@ TODO: Write some documentation
|
|
2773
2915
|
|
2774
2916
|
}).call(this);
|
2775
2917
|
(function() {
|
2776
|
-
up.
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2918
|
+
if (up.browser.isSupported()) {
|
2919
|
+
up.browser.ensureConsoleExists();
|
2920
|
+
up.bus.emit('framework:ready');
|
2921
|
+
$(document).on('ready', function() {
|
2922
|
+
return up.bus.emit('app:ready');
|
2923
|
+
});
|
2924
|
+
}
|
2781
2925
|
|
2782
2926
|
}).call(this);
|