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",
|
"enter_page_number": "Enter page number",
|
||||||
"upload_file": "Upload file",
|
"upload_file": "Upload file",
|
||||||
"upload": "Upload",
|
"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.getSession().setMode("ace/mode/css");
|
||||||
|
|
||||||
customCSS.on('change', function(e) {
|
customCSS.on('change', function(e) {
|
||||||
|
app.flags = app.flags || {};
|
||||||
|
app.flags._unsaved = true;
|
||||||
$('#customCSS-holder').val(customCSS.getValue());
|
$('#customCSS-holder').val(customCSS.getValue());
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -23,6 +25,8 @@ define('admin/appearance/customise', ['admin/settings'], function(Settings) {
|
|||||||
customHTML.getSession().setMode("ace/mode/html");
|
customHTML.getSession().setMode("ace/mode/html");
|
||||||
|
|
||||||
customHTML.on('change', function(e) {
|
customHTML.on('change', function(e) {
|
||||||
|
app.flags = app.flags || {};
|
||||||
|
app.flags._unsaved = true;
|
||||||
$('#customHTML-holder').val(customHTML.getValue());
|
$('#customHTML-holder').val(customHTML.getValue());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ define('admin/manage/category', [
|
|||||||
if (cid) {
|
if (cid) {
|
||||||
modified_categories[cid] = modified_categories[cid] || {};
|
modified_categories[cid] = modified_categories[cid] || {};
|
||||||
modified_categories[cid][$(el).attr('data-name')] = $(el).val();
|
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) {
|
if (result && result.length) {
|
||||||
|
app.flags._unsaved = false;
|
||||||
app.alert({
|
app.alert({
|
||||||
title: 'Updated Categories',
|
title: 'Updated Categories',
|
||||||
message: 'Category IDs ' + result.join(', ') + ' was successfully updated.',
|
message: 'Category IDs ' + result.join(', ') + ' was successfully updated.',
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ define('admin/settings', ['uploader'], function(uploader) {
|
|||||||
revertBtn = $('#revert'),
|
revertBtn = $('#revert'),
|
||||||
x, key, inputType, field;
|
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++) {
|
for (x = 0; x < numFields; x++) {
|
||||||
field = fields.eq(x);
|
field = fields.eq(x);
|
||||||
key = field.attr('data-field');
|
key = field.attr('data-field');
|
||||||
@@ -77,6 +83,9 @@ define('admin/settings', ['uploader'], function(uploader) {
|
|||||||
type: 'danger'
|
type: 'danger'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.flags._unsaved = false;
|
||||||
|
|
||||||
app.alert({
|
app.alert({
|
||||||
alert_id: 'config_status',
|
alert_id: 'config_status',
|
||||||
timeout: 2500,
|
timeout: 2500,
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
/*global app, bootbox, templates, socket, config, RELATIVE_PATH*/
|
||||||
|
|
||||||
var ajaxify = ajaxify || {};
|
var ajaxify = ajaxify || {};
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
/*global app, templates, socket, config, RELATIVE_PATH*/
|
|
||||||
|
|
||||||
var location = document.location || window.location;
|
var location = document.location || window.location;
|
||||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||||
var apiXHR = null;
|
var apiXHR = null;
|
||||||
@@ -295,6 +293,32 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
// Enhancing all anchors to ajaxify...
|
// Enhancing all anchors to ajaxify...
|
||||||
$(document.body).on('click', 'a', function (e) {
|
$(document.body).on('click', 'a', function (e) {
|
||||||
|
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 + '/', '');
|
||||||
|
|
||||||
|
// Special handling for urls with hashes
|
||||||
|
if (window.location.pathname === this.pathname && this.hash.length) {
|
||||||
|
window.location.hash = this.hash;
|
||||||
|
} else {
|
||||||
|
if (ajaxify.go(pathname)) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (window.location.pathname !== '/outgoing') {
|
||||||
|
if (config.openOutgoingLinksInNewTab) {
|
||||||
|
window.open(this.href, '_blank');
|
||||||
|
e.preventDefault();
|
||||||
|
} else if (config.useOutgoingLinksPage) {
|
||||||
|
ajaxify.go('outgoing?url=' + encodeURIComponent(this.href));
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (this.target !== '' || (this.protocol !== 'http:' && this.protocol !== 'https:')) {
|
if (this.target !== '' || (this.protocol !== 'http:' && this.protocol !== 'https:')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -311,6 +335,7 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Default behaviour for rss feeds
|
||||||
if (internalLink && $(this).attr('href').endsWith('.rss')) {
|
if (internalLink && $(this).attr('href').endsWith('.rss')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -319,28 +344,19 @@ $(document).ready(function() {
|
|||||||
return e.preventDefault();
|
return e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!e.ctrlKey && !e.shiftKey && !e.metaKey && e.which === 1) {
|
if (app.flags && app.flags.hasOwnProperty('_unsaved') && app.flags._unsaved === true) {
|
||||||
if (internalLink) {
|
translator.translate('[[global:unsaved-changes]]', function(text) {
|
||||||
var pathname = this.href.replace(rootUrl + RELATIVE_PATH + '/', '');
|
bootbox.confirm(text, function(navigate) {
|
||||||
|
if (navigate) {
|
||||||
// Special handling for urls with hashes
|
app.flags._unsaved = false;
|
||||||
if (window.location.pathname === this.pathname && this.hash.length) {
|
process.call(_self);
|
||||||
window.location.hash = this.hash;
|
|
||||||
} else {
|
|
||||||
if (ajaxify.go(pathname)) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
} else if (window.location.pathname !== '/outgoing') {
|
});
|
||||||
if (config.openOutgoingLinksInNewTab) {
|
return e.preventDefault();
|
||||||
window.open(this.href, '_blank');
|
|
||||||
e.preventDefault();
|
|
||||||
} else if (config.useOutgoingLinksPage) {
|
|
||||||
ajaxify.go('outgoing?url=' + encodeURIComponent(this.href));
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.call(_self);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -473,6 +473,12 @@ define('settings', function () {
|
|||||||
});
|
});
|
||||||
$(window).trigger('action:admin.settingsLoaded');
|
$(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);
|
callback(null, values);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -498,6 +504,9 @@ define('settings', function () {
|
|||||||
hash: hash,
|
hash: hash,
|
||||||
values: values
|
values: values
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
|
// Remove unsaved flag to re-enable ajaxify
|
||||||
|
app.flags._unsaved = false;
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
var app = {
|
var app = {
|
||||||
template: "{template.name}",
|
template: "{template.name}",
|
||||||
user: JSON.parse('{{userJSON}}'),
|
user: JSON.parse('{{userJSON}}'),
|
||||||
config: JSON.parse(decodeURIComponent("{{adminConfigJSON}}"))
|
config: JSON.parse(decodeURIComponent("{{adminConfigJSON}}")),
|
||||||
|
flags: {}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user