--- a/src/pyams_skin/resources/js/myams.js Fri Oct 13 09:54:36 2017 +0200
+++ b/src/pyams_skin/resources/js/myams.js Fri Oct 13 10:01:32 2017 +0200
@@ -718,7 +718,9 @@
if (copied) {
ams.skin.smallBox('success',
{
- title: ams.i18n.CLIPBOARD_COPY_OK,
+ title: text.length > 1
+ ? ams.i18n.CLIPBOARD_TEXT_COPY_OK
+ : ams.i18n.CLIPBOARD_CHARACTER_COPY_OK,
icon: 'fa fa-fw fa-info-circle font-xs align-top margin-top-10',
timeout: 1000
});
@@ -1030,9 +1032,11 @@
break;
case 'info':
case 'success':
- ams.form.resetChanged(form);
- if (result.close_form !== false) {
- ams.dialog.close(form);
+ if (form !== undefined) {
+ ams.form.resetChanged(form);
+ if (result.close_form !== false) {
+ ams.dialog.close(form);
+ }
}
break;
case 'message':
@@ -1041,29 +1045,47 @@
case 'notify':
case 'callback':
case 'callbacks':
- ams.form.resetChanged(form);
- if (result.close_form !== false) {
- ams.dialog.close(form);
+ if (form !== undefined) {
+ ams.form.resetChanged(form);
+ if (result.close_form !== false) {
+ ams.dialog.close(form);
+ }
}
break;
case 'modal':
ams.dialog.open(result.location);
break;
case 'reload':
- ams.form.resetChanged(form);
- if (result.close_form !== false) {
- ams.dialog.close(form);
+ if (form !== undefined) {
+ ams.form.resetChanged(form);
+ if (result.close_form !== false) {
+ ams.dialog.close(form);
+ }
}
url = result.location || window.location.hash;
if (url.startsWith('#')) {
url = url.substr(1);
}
- ams.skin.loadURL(url, result.target || target || '#content');
+ var loadTarget = $(result.target || target || '#content');
+ ams.skin.loadURL(url, loadTarget, {
+ preLoadCallback: ams.getFunctionByName(result.pre_reload) || function() {
+ $('[data-ams-pre-reload]', loadTarget).each(function() {
+ ams.executeFunctionByName($(this).data('ams-pre-reload'));
+ });
+ },
+ afterLoadCallback: ams.getFunctionByName(result.post_reload) || function () {
+ $('[data-ams-post-reload]', loadTarget).each(function () {
+ ams.executeFunctionByName($(this).data('ams-post-reload'));
+ });
+ }
+ });
break;
case 'redirect':
- ams.form.resetChanged(form);
- if (result.close_form === true) {
- ams.dialog.close(form);
+ if (form !== undefined) {
+ ams.form.resetChanged(form);
+ if (result.close_form === true) {
+ ams.dialog.close(form);
+ }
}
url = result.location || window.location.href;
if (result.window) {
@@ -1170,6 +1192,9 @@
}
if (result.events) {
var event;
+ if (form === undefined) {
+ form = $(document);
+ }
for (index =0; index < result.events.length; index++) {
event = result.events[index];
if (typeof(event) === 'string') {
@@ -1391,9 +1416,9 @@
*/
init: function(element) {
- // Store value of hidden inputs
$('FORM', element).each(function() {
var form = $(this);
+ // Store value of hidden inputs
$('INPUT.select2[type="hidden"]', form).each(function() {
var input = $(this);
input.data('ams-select2-input-value', input.val());
@@ -2416,6 +2441,19 @@
*/
MyAMS.helpers = {
+ /** Sort DOM elements into selected container */
+ sort: function(container, attribute) {
+ if (!attribute) {
+ attribute = 'weight';
+ }
+ var childs = container.children();
+ childs.sort(function(a, b) {
+ return +$(a).data(attribute) - +$(b).data(attribute);
+ }).each(function() {
+ container.append(this);
+ });
+ },
+
/** Clear Select2 slection */
select2ClearSelection: function() {
var source = $(this);
@@ -2443,6 +2481,14 @@
}
},
+ /** Select2 'select-all' helper */
+ select2SelectAllHelper: function() {
+ var source = $(this);
+ var parent = source.parents('label:first');
+ var input = $('.select2', parent);
+ input.select2('data', input.data('ams-select2-data'));
+ },
+
/** Select2 query results callback */
select2QueryUrlResultsCallback: function(data, page, context) {
switch (data.status) {
@@ -4030,7 +4076,7 @@
"advlist autosave autolink lists link image charmap print preview hr anchor pagebreak",
"searchreplace wordcount visualblocks visualchars code fullscreen",
"insertdatetime media nonbreaking save table contextmenu directionality",
- "emoticons paste textcolor colorpicker textpattern"
+ "emoticons paste textcolor colorpicker textpattern autoresize"
],
toolbar1: data.amsTinymceToolbar1 || "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
toolbar2: data.amsTinymceToolbar2 || "forecolor backcolor emoticons | charmap link image media | fullscreen preview print | code",
@@ -4044,6 +4090,10 @@
image_class_list: data.amsTinymceImageClassList,
link_list: ams.getFunctionByName(data.amsTinymceLinkList) || data.amsTinymceLinkList,
link_class_list: data.amsTinymceLinkClassList,
+ height: 50,
+ min_height: 50,
+ autoresize_min_height: 50,
+ autoresize_max_height: 500,
resize: true
};
if (data.amsTinymceExternalPlugins) {
@@ -4139,6 +4189,10 @@
fancyboxes.each(function() {
var fancybox = $(this);
var data = fancybox.data();
+ var elements = fancybox;
+ if (data.amsFancyboxElements) {
+ elements = $(data.amsFancyboxElements, fancybox);
+ }
var helpers = (data.amsFancyboxHelpers || '').split(/\s+/);
if (helpers.length > 0) {
for (var index=0; index < helpers.length; index++) {
@@ -4165,18 +4219,52 @@
type: data.amsFancyboxType,
padding: data.amsFancyboxPadding || 10,
margin: data.amsFancyboxMargin || 10,
+ loop: data.amsFancyboxLoop,
beforeLoad: ams.getFunctionByName(data.amsFancyboxBeforeLoad) || function() {
- this.title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this) || $(this.element).attr('original-title') || $(this.element).attr('title');
+ var title;
+ if (data.amsFancyboxTitleGetter) {
+ title = ams.executeFunctionByName(data.amsFancyboxTitleGetter, this);
+ }
+ if (!title) {
+ var content = $('*:first', this.element);
+ title = content.attr('original-title') || content.attr('title');
+ if (!title) {
+ title = $(this.element).attr('original-title') || $(this.element).attr('title');
+ }
+ }
+ this.title = title;
},
+ afterLoad: ams.getFunctionByName(data.amsFancyboxAfterLoad),
helpers: {
title: {
type: 'inside'
}
}
};
+ if (helpers.length > 0) {
+ for (index = 0; index < helpers.length; index++) {
+ helper = helpers[index];
+ switch (helper) {
+ case 'buttons':
+ dataOptions.helpers.buttons = {
+ position: data.amsFancyboxButtonsPosition || 'top'
+ };
+ break;
+ case 'thumbs':
+ dataOptions.helpers.thumbs = {
+ width: data.amsFancyboxThumbsWidth || 50,
+ height: data.amsFancyboxThumbsHeight || 50
+ };
+ break;
+ case 'media':
+ dataOptions.helpers.media = true;
+ break;
+ }
+ }
+ }
var settings = $.extend({}, dataOptions, data.amsFancyboxOptions);
settings = ams.executeFunctionByName(data.amsFancyboxInitCallback, fancybox, settings) || settings;
- var plugin = fancybox.fancybox(settings);
+ var plugin = elements.fancybox(settings);
ams.executeFunctionByName(data.amsFancyboxAfterInitCallback, fancybox, plugin, settings);
});
});
@@ -4472,6 +4560,9 @@
} else {
tr.remove();
}
+ if (result.handle_json) {
+ MyAMS.ajax.handleJSON(result);
+ }
} else {
MyAMS.ajax.handleJSON(result);
}
@@ -4843,6 +4934,9 @@
dataType: 'html',
cache: false,
beforeSend: function() {
+ if (options && options.preLoadCallback) {
+ ams.executeFunctionByName(options.preLoadCallback, this);
+ }
ams.skin.cleanContainer(container);
container.html('<h1 class="loading"><i class="fa fa-cog fa-spin"></i> ' + ams.i18n.LOADING + ' </h1>');
if (container[0] === $('#content')[0]) {
@@ -5499,7 +5593,7 @@
BAD_LOGIN_TITLE: "Bad login!",
BAD_LOGIN_MESSAGE: "Your anthentication credentials didn't allow you to open a session; " +
- "please check your credentials or contact administrator.",
+ "please check your credentials or contact administrator.",
CONFIRM: "Confirm",
CONFIRM_REMOVE: "Removing this content can't be undone. Do you confirm?",
@@ -5515,7 +5609,8 @@
BTN_YES_NO: "[Yes][No]",
CLIPBOARD_COPY: "Copy to clipboard with Ctrl+C, and Enter",
- CLIPBOARD_COPY_OK: "Text copied to clipboard",
+ CLIPBOARD_CHARACTER_COPY_OK: "Character copied to clipboard",
+ CLIPBOARD_TEXT_COPY_OK: "Text copied to clipboard",
FORM_CHANGED_WARNING: "Some changes were not saved. These updates will be lost if you leave this page.",
DELETE_WARNING: "This change can't be undone. Are you sure that you want to delete this element?",
@@ -5538,7 +5633,19 @@
SELECT2_FREETAG_PREFIX: "Free text: ",
DT_COLUMNS: "Columns"
-
+ }
+
+ MyAMS.plugins.i18n = {
+ widgets: {},
+ validate: {},
+ datatables: {},
+ fancybox: {
+ ERROR: "Can't load requested content.",
+ RETRY: "Please check URL or try again later.",
+ CLOSE: "Close",
+ NEXT: "Next",
+ PREVIOUS: "Previous"
+ }
};