Skip to content

Commit

Permalink
* fix error in jQuery 3.* and jQuery 2.*.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Sep 5, 2016
1 parent 485ec8d commit 17226fe
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 33 deletions.
66 changes: 36 additions & 30 deletions src/js/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,41 +287,47 @@

var dataType = url.endsWith('.json') ? 'json' : 'html';
var loadFromRemote = function() {
$.get(url, function(data) {
if(data !== null) {
if(isIndexJson) {
dataVersion = data.version;
docIndex = data;
} else if(isIconsJson) {
iconsIndex = {
$.ajax({
url: url,
type: 'GET',
dataType: dataType,
success: function(data) {
if(data !== null) {
if(isIndexJson) {
dataVersion = data.version;
docIndex = data;
} else if(isIconsJson) {
iconsIndex = {
data: data,
version: dataVersion
};
}
cacheData = {
data: data,
version: dataVersion
};
$.zui.store.set('//' + url, data);
$.zui.store.set('//' + url + '::V', dataVersion);

if(debug) console.log('Load', url, 'from remote:', cacheData);
callback(data, 'remote');
} else if(isHasCache && !isIndexJson) {
if(debug) console.log('Failed load', url, 'from remote, instead load cache:', cacheData);
callback(cacheData.data, 'cache');
}
},
error: function() {
if(debug) console.warn("Ajax error:", url);
if(isHasCache && !isIndexJson) {
if(debug) console.log('Failed load', url, 'from remote with error, instead load cache:', cacheData);
callback(cacheData.data, 'cache');
} else {
callback(null, 'error');
}
cacheData = {
data: data,
version: dataVersion
};
$.zui.store.set('//' + url, data);
$.zui.store.set('//' + url + '::V', dataVersion);

if(debug) console.log('Load', url, 'from remote:', cacheData);
callback(data, 'remote');
} else if(isHasCache && !isIndexJson) {
if(debug) console.log('Failed load', url, 'from remote, instead load cache:', cacheData);
callback(cacheData.data, 'cache');
}
}, dataType).error(function() {
if(debug) console.warn("Ajax error:", url);
if(isHasCache && !isIndexJson) {
if(debug) console.log('Failed load', url, 'from remote with error, instead load cache:', cacheData);
callback(cacheData.data, 'cache');
} else {
callback(null, 'error');
}

if($body.hasClass('page-open')) {
$pageBody.children('.loader').addClass('with-error');
if($body.hasClass('page-open')) {
$pageBody.children('.loader').addClass('with-error');
}
}
});
}
Expand Down
7 changes: 4 additions & 3 deletions src/js/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@
selector = $this.attr('href')
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}

var $parent = selector && $(selector)

var $parent;
try {
$parent = selector && $(selector);
} catch(e) {}
return $parent && $parent.length ? $parent : $this.parent()
}

Expand Down

0 comments on commit 17226fe

Please sign in to comment.