mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 16:35:47 +01:00
closes #4505
This commit is contained in:
@@ -116,5 +116,7 @@
|
||||
"enter_page_number": "Enter page number",
|
||||
"upload_file": "Upload file",
|
||||
"upload": "Upload",
|
||||
"allowed-file-types": "Allowed file types are %1"
|
||||
"allowed-file-types": "Allowed file types are %1",
|
||||
|
||||
"unsaved-changes": "You have unsaved changes. Are you sure you wish to navigate away?"
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
||||
customCSS.getSession().setMode("ace/mode/css");
|
||||
|
||||
customCSS.on('change', function(e) {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customCSS-holder').val(customCSS.getValue());
|
||||
});
|
||||
|
||||
@@ -23,6 +25,8 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
||||
customHTML.getSession().setMode("ace/mode/html");
|
||||
|
||||
customHTML.on('change', function(e) {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
$('#customHTML-holder').val(customHTML.getValue());
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,6 +18,9 @@ define('admin/manage/category', [
|
||||
if (cid) {
|
||||
modified_categories[cid] = modified_categories[cid] || {};
|
||||
modified_categories[cid][$(el).attr('data-name')] = $(el).val();
|
||||
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +34,7 @@ define('admin/manage/category', [
|
||||
}
|
||||
|
||||
if (result && result.length) {
|
||||
app.flags._unsaved = false;
|
||||
app.alert({
|
||||
title: 'Updated Categories',
|
||||
message: 'Category IDs ' + result.join(', ') + ' was successfully updated.',
|
||||
|
||||
@@ -27,6 +27,12 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
revertBtn = $('#revert'),
|
||||
x, key, inputType, field;
|
||||
|
||||
// Handle unsaved changes
|
||||
$(fields).on('change', function() {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
});
|
||||
|
||||
for (x = 0; x < numFields; x++) {
|
||||
field = fields.eq(x);
|
||||
key = field.attr('data-field');
|
||||
@@ -77,6 +83,9 @@ define('admin/settings', ['uploader'], function(uploader) {
|
||||
type: 'danger'
|
||||
});
|
||||
}
|
||||
|
||||
app.flags._unsaved = false;
|
||||
|
||||
app.alert({
|
||||
alert_id: 'config_status',
|
||||
timeout: 2500,
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
"use strict";
|
||||
/*global app, bootbox, templates, socket, config, RELATIVE_PATH*/
|
||||
|
||||
var ajaxify = ajaxify || {};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
/*global app, templates, socket, config, RELATIVE_PATH*/
|
||||
|
||||
var location = document.location || window.location;
|
||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
var apiXHR = null;
|
||||
@@ -295,30 +293,8 @@ $(document).ready(function() {
|
||||
|
||||
// Enhancing all anchors to ajaxify...
|
||||
$(document.body).on('click', 'a', function (e) {
|
||||
if (this.target !== '' || (this.protocol !== 'http:' && this.protocol !== 'https:')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var internalLink = this.host === '' || // Relative paths are always internal links
|
||||
(this.host === window.location.host && this.protocol === window.location.protocol && // Otherwise need to check if protocol and host match
|
||||
(RELATIVE_PATH.length > 0 ? this.pathname.indexOf(RELATIVE_PATH) === 0 : true)); // Subfolder installs need this additional check
|
||||
|
||||
if ($(this).attr('data-ajaxify') === 'false') {
|
||||
if (!internalLink) {
|
||||
return;
|
||||
} else {
|
||||
return e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
if (internalLink && $(this).attr('href').endsWith('.rss')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hrefEmpty(this.href) || this.protocol === 'javascript:' || $(this).attr('href') === '#') {
|
||||
return e.preventDefault();
|
||||
}
|
||||
|
||||
var _self = this;
|
||||
var process = function() {
|
||||
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && e.which === 1) {
|
||||
if (internalLink) {
|
||||
var pathname = this.href.replace(rootUrl + RELATIVE_PATH + '/', '');
|
||||
@@ -341,6 +317,46 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (this.target !== '' || (this.protocol !== 'http:' && this.protocol !== 'https:')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var internalLink = this.host === '' || // Relative paths are always internal links
|
||||
(this.host === window.location.host && this.protocol === window.location.protocol && // Otherwise need to check if protocol and host match
|
||||
(RELATIVE_PATH.length > 0 ? this.pathname.indexOf(RELATIVE_PATH) === 0 : true)); // Subfolder installs need this additional check
|
||||
|
||||
if ($(this).attr('data-ajaxify') === 'false') {
|
||||
if (!internalLink) {
|
||||
return;
|
||||
} else {
|
||||
return e.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
// Default behaviour for rss feeds
|
||||
if (internalLink && $(this).attr('href').endsWith('.rss')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hrefEmpty(this.href) || this.protocol === 'javascript:' || $(this).attr('href') === '#') {
|
||||
return e.preventDefault();
|
||||
}
|
||||
|
||||
if (app.flags && app.flags.hasOwnProperty('_unsaved') && app.flags._unsaved === true) {
|
||||
translator.translate('[[global:unsaved-changes]]', function(text) {
|
||||
bootbox.confirm(text, function(navigate) {
|
||||
if (navigate) {
|
||||
app.flags._unsaved = false;
|
||||
process.call(_self);
|
||||
}
|
||||
});
|
||||
});
|
||||
return e.preventDefault();
|
||||
}
|
||||
|
||||
process.call(_self);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -473,6 +473,12 @@ define('settings', function () {
|
||||
});
|
||||
$(window).trigger('action:admin.settingsLoaded');
|
||||
|
||||
// Handle unsaved changes
|
||||
$(formEl).on('change', 'input, select, textarea', function() {
|
||||
app.flags = app.flags || {};
|
||||
app.flags._unsaved = true;
|
||||
});
|
||||
|
||||
callback(null, values);
|
||||
});
|
||||
},
|
||||
@@ -498,6 +504,9 @@ define('settings', function () {
|
||||
hash: hash,
|
||||
values: values
|
||||
}, function (err) {
|
||||
// Remove unsaved flag to re-enable ajaxify
|
||||
app.flags._unsaved = false;
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
callback();
|
||||
} else {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
var app = {
|
||||
template: "{template.name}",
|
||||
user: JSON.parse('{{userJSON}}'),
|
||||
config: JSON.parse(decodeURIComponent("{{adminConfigJSON}}"))
|
||||
config: JSON.parse(decodeURIComponent("{{adminConfigJSON}}")),
|
||||
flags: {}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user