/var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/trx_utils/shortcodes
Edit: /var/www/vhosts/ihelp.ro/ajutam.ro/wp-content/plugins/trx_utils/shortcodes/shortcodes_admin.js (35355B)
// Init scripts
jQuery(document).ready(function(){
"use strict";
// Settings and constants
CHARITY_IS_HOPE_STORAGE['shortcodes_delimiter'] = ','; // Delimiter for multiple values
CHARITY_IS_HOPE_STORAGE['shortcodes_popup'] = null; // Popup with current shortcode settings
CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx'] = ''; // Current shortcode's index
CHARITY_IS_HOPE_STORAGE['shortcodes_tab_clone_tab'] = '
{title}';
CHARITY_IS_HOPE_STORAGE['shortcodes_tab_clone_content'] = '';
// Shortcode selector - "change" event handler - add selected shortcode in editor
jQuery('body').on('change', ".sc_selector", function() {
"use strict";
CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx'] = jQuery(this).find(":selected").val();
if (CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx'] == '') return;
var sc = charity_is_hope_clone_object(CHARITY_IS_HOPE_SHORTCODES_DATA[CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx']]);
var hdr = sc.title;
var content = "";
try {
content = tinyMCE.activeEditor ? tinyMCE.activeEditor.selection.getContent({format : 'raw'}) : jQuery('#wp-content-editor-container textarea').selection();
} catch(e) {};
if (content) {
for (var i in sc.params) {
if (i == '_content_') {
sc.params[i].value = content;
break;
}
}
}
var html = (!charity_is_hope_empty(sc.desc) ? '
'+sc.desc+'
' : '')
+ charity_is_hope_shortcodes_prepare_layout(sc);
// Show Dialog popup
CHARITY_IS_HOPE_STORAGE['shortcodes_popup'] = charity_is_hope_message_dialog(html, hdr,
function(popup) {
"use strict";
charity_is_hope_options_init(popup);
popup.find('.charity_is_hope_options_tab_content').css({
maxHeight: jQuery(window).height() - 300 + 'px',
overflow: 'auto'
});
},
function(btn, popup) {
"use strict";
if (btn != 1) return;
var sc = charity_is_hope_shortcodes_get_code(CHARITY_IS_HOPE_STORAGE['shortcodes_popup']);
if (tinyMCE.activeEditor) {
if ( !tinyMCE.activeEditor.isHidden() )
tinyMCE.activeEditor.execCommand( 'mceInsertContent', false, sc );
else
send_to_editor(sc);
} else
send_to_editor(sc);
});
// Set first item active
jQuery(this).get(0).options[0].selected = true;
// Add new child tab
CHARITY_IS_HOPE_STORAGE['shortcodes_popup'].find('.charity_is_hope_shortcodes_tab').on('tabsbeforeactivate', function (e, ui) {
if (ui.newTab.data('id')=='add') {
charity_is_hope_shortcodes_add_tab(ui.newTab);
e.stopImmediatePropagation();
e.preventDefault();
return false;
}
});
// Delete child tab
CHARITY_IS_HOPE_STORAGE['shortcodes_popup'].find('.charity_is_hope_shortcodes_tab > ul').on('click', '> li+li > a > span', function (e) {
var tab = jQuery(this).parents('li');
var idx = tab.data('id');
if (parseInt(idx) > 1) {
if (tab.hasClass('ui-state-active')) {
tab.prev().find('a').trigger('click');
}
tab.parents('.charity_is_hope_shortcodes_tab').find('.charity_is_hope_options_tab_content').eq(idx).remove();
tab.remove();
e.preventDefault();
return false;
}
});
return false;
});
});
// Return result code
//------------------------------------------------------------------------------------------
function charity_is_hope_shortcodes_get_code(popup) {
CHARITY_IS_HOPE_STORAGE['sc_custom'] = '';
var sc_name = CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx'];
var sc = CHARITY_IS_HOPE_SHORTCODES_DATA[sc_name];
var tabs = popup.find('.charity_is_hope_shortcodes_tab > ul > li');
var decor = !charity_is_hope_isset(sc.decorate) || sc.decorate;
var rez = '[' + sc_name + charity_is_hope_shortcodes_get_code_from_tab(popup.find('#charity_is_hope_shortcodes_tab_0_content').eq(0)) + ']';
if (charity_is_hope_isset(sc.children)) {
if (CHARITY_IS_HOPE_STORAGE['sc_custom']!='no') {
var decor2 = !charity_is_hope_isset(sc.children.decorate) || sc.children.decorate;
for (var i=0; i
0) {
rez += content.find('[data-param="_content_"]').val();
}
rez +=
//(decor2 ? '\t' : '') +
'[/' + sc.children.name + ']'
// + (decor ? '\n' : '')
;
}
}
}
} else if (charity_is_hope_isset(sc.container) && sc.container && popup.find('#charity_is_hope_shortcodes_tab_0_content [data-param="_content_"]').length > 0) {
rez += popup.find('#charity_is_hope_shortcodes_tab_0_content [data-param="_content_"]').val();
}
if (charity_is_hope_isset(sc.container) && sc.container || charity_is_hope_isset(sc.children))
rez +=
(charity_is_hope_isset(sc.children) && decor && CHARITY_IS_HOPE_STORAGE['sc_custom']!='no' ? '\n' : '')
+ '[/' + sc_name + ']';
return rez;
}
// Collect all parameters from tab into string
function charity_is_hope_shortcodes_get_code_from_tab(tab) {
var rez = ''
var mainTab = tab.attr('id').indexOf('tab_0') > 0;
tab.find('[data-param]').each(function () {
var field = jQuery(this);
var param = field.data('param');
if (!field.parents('.charity_is_hope_options_field').hasClass('charity_is_hope_options_no_use') && param.substr(0, 1)!='_' && !charity_is_hope_empty(field.val()) && field.val()!='none' && (field.attr('type') != 'checkbox' || field.get(0).checked)) {
rez += ' '+param+'="'+charity_is_hope_shortcodes_prepare_value(field.val())+'"';
}
// On main tab detect param "custom"
if (mainTab && param=='custom') {
CHARITY_IS_HOPE_STORAGE['sc_custom'] = field.val();
}
});
// Get additional params for general tab from items tabs
if (CHARITY_IS_HOPE_STORAGE['sc_custom']!='no' && mainTab) {
var sc = CHARITY_IS_HOPE_SHORTCODES_DATA[CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx']];
var sc_name = CHARITY_IS_HOPE_STORAGE['shortcodes_current_idx'];
if (sc_name == 'trx_columns' || sc_name == 'trx_skills' || sc_name == 'trx_team' || sc_name == 'trx_price_table') { // Determine "count" parameter
var cnt = 0;
tab.siblings('div').each(function() {
var item_tab = jQuery(this);
var merge = parseInt(item_tab.find('[data-param="span"]').val());
cnt += !isNaN(merge) && merge > 0 ? merge : 1;
});
rez += ' count="'+cnt+'"';
}
}
return rez;
}
// Shortcode parameters builder
//-------------------------------------------------------------------------------------------
// Prepare layout from shortcode object (array)
function charity_is_hope_shortcodes_prepare_layout(field) {
"use strict";
// Make params cloneable
field['params'] = [field['params']];
if (!charity_is_hope_empty(field.children)) {
field.children['params'] = [field.children['params']];
}
// Prepare output
var output = ' ';
return output;
}
// Show tabs
function charity_is_hope_shortcodes_show_tabs(field) {
"use strict";
// html output
var output = '