You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
793 B
JavaScript
37 lines
793 B
JavaScript
'use strict';
|
|
/* globals define, app, ajaxify */
|
|
|
|
define('ajaxifyCache', function() {
|
|
var Cache = {
|
|
url: undefined,
|
|
DOM: undefined,
|
|
tempDOM: undefined
|
|
};
|
|
|
|
Cache.set = function() {
|
|
Cache.DOM = $('#content > *').detach();
|
|
};
|
|
|
|
Cache.get = function(url, callback) {
|
|
if (url === Cache.url && ajaxify.isPopState) {
|
|
// Swap DOM elements
|
|
// setTimeout(function() {
|
|
Cache.tempDOM = $('#content > *').detach();
|
|
$('#content').append(Cache.DOM);
|
|
Cache.DOM = Cache.tempDOM;
|
|
// }, 100); // 100ms for realism! :sunglasses:
|
|
|
|
// Set the values that normally get set on ajaxify
|
|
Cache.url = ajaxify.currentPage;
|
|
ajaxify.currentPage = url;
|
|
|
|
if (typeof callback === 'function') { callback(); }
|
|
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
};
|
|
|
|
return Cache;
|
|
}); |