|
@@ -1,4 +1,5 @@
|
|
|
$(function() {
|
|
|
+ var errorTag = $('#error');
|
|
|
var reloadPhotosTag = $('#reload_photos');
|
|
|
var showLicenseTag = $('#show_license');
|
|
|
var showLicenseVal = showLicenseTag.val();
|
|
@@ -11,10 +12,18 @@ $(function() {
|
|
|
var applyLicenseTag = $('#apply_license');
|
|
|
var licenseLinkTag = $('#license_link');
|
|
|
|
|
|
+ function controlsDisabled(disabled) {
|
|
|
+ reloadPhotosTag.prop('disabled', disabled);
|
|
|
+ showLicenseTag.prop('disabled', disabled);
|
|
|
+ showPrivacyTag.prop('disabled', disabled);
|
|
|
+ showIgnoredTag.prop('disabled', disabled);
|
|
|
+ selectLicenseTag.prop('disabled', disabled)
|
|
|
+ }
|
|
|
+
|
|
|
function reloadPhotos(params = {}, path = '/photos/1') {
|
|
|
- reloadPhotosTag.prop('disabled', true)
|
|
|
- selectLicenseTag.prop('disabled', true)
|
|
|
+ controlsDisabled(true);
|
|
|
$.getJSON(path, params, function(data) {
|
|
|
+ photosTag.children('.spinner').remove();
|
|
|
console.log(data);
|
|
|
|
|
|
if (data.path) {
|
|
@@ -23,9 +32,10 @@ $(function() {
|
|
|
showLicenseTag.change();
|
|
|
showPrivacyTag.change();
|
|
|
showIgnoredTag.change();
|
|
|
- reloadPhotosTag.prop('disabled', false);
|
|
|
- selectLicenseTag.prop('disabled', false);
|
|
|
+ controlsDisabled(false);
|
|
|
}
|
|
|
+ }).fail(function() {
|
|
|
+ controlsDisabled(false);
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -36,6 +46,8 @@ $(function() {
|
|
|
$.post('/user', {show_license: showLicenseTag.val()}, function() {
|
|
|
showLicenseVal = showLicenseTag.val();
|
|
|
showLicense();
|
|
|
+ }).fail(function() {
|
|
|
+ showLicenseTag.val(showLicenseVal);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -47,6 +59,8 @@ $(function() {
|
|
|
$.post('/user', {show_privacy: showPrivacyTag.val()}, function() {
|
|
|
showPrivacyVal = showPrivacyTag.val();
|
|
|
showPrivacy();
|
|
|
+ }).fail(function() {
|
|
|
+ showPrivacyTag.val(showPrivacyVal);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -58,12 +72,23 @@ $(function() {
|
|
|
$.post('/user', {show_ignored: showIgnoredTag.val()}, function() {
|
|
|
showIgnoredVal = showIgnoredTag.val();
|
|
|
showIgnored();
|
|
|
+ }).fail(function() {
|
|
|
+ showIgnoredTag.val(showIgnoredVal);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ errorTag.dialog({autoOpen: false, modal: true});
|
|
|
+ $(document).ajaxError(function(event, request, settings, error) {
|
|
|
+ if (request.responseJSON && request.responseJSON.error) {
|
|
|
+ errorTag.text(request.responseJSON.error);
|
|
|
+ } else {
|
|
|
+ errorTag.empty().append($('<div>').text(request.status + ' ' + error), $('<iframe>', {style: 'height: 100%; width: 100%;', srcdoc: request.responseText}));
|
|
|
+ }
|
|
|
+ errorTag.dialog('open');
|
|
|
+ });
|
|
|
reloadPhotosTag.click(function() {
|
|
|
- photosTag.empty();
|
|
|
+ photosTag.empty().append('<div class="spinner">');
|
|
|
selectLicenseTag.val('').change();
|
|
|
reloadPhotos({reload: true});
|
|
|
});
|