';
return output;
}
// Show tabs
function lorem_ipsum_books_media_store_shortcodes_show_tabs(field) {
"use strict";
// html output
var output = '
'
+ '
'
+ LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_tab_clone_tab'].replace(/{id}/g, 0).replace('{icon}', 'cog').replace('{title}', 'General');
if (lorem_ipsum_books_media_store_isset(field.children)) {
for (var i=0; i';
return output;
}
// Add new tab
function lorem_ipsum_books_media_store_shortcodes_add_tab(tab) {
"use strict";
var idx = 0;
tab.siblings().each(function () {
"use strict";
var i = parseInt(jQuery(this).data('id'));
if (i > idx) idx = i;
});
idx++;
tab.before( LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_tab_clone_tab'].replace(/{id}/g, idx).replace('{icon}', 'cancel').replace('{title}', LOREM_IPSUM_BOOKS_MEDIA_STORE_SHORTCODES_DATA[LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_current_idx']].children.title + ' ' + idx) );
tab.parents('.lorem_ipsum_books_media_store_shortcodes_tab').append(LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_tab_clone_content'].replace(/tab_1_/g, 'tab_' + idx + '_'));
tab.parents('.lorem_ipsum_books_media_store_shortcodes_tab').tabs('refresh');
lorem_ipsum_books_media_store_options_init(tab.parents('.lorem_ipsum_books_media_store_shortcodes_tab').find('.lorem_ipsum_books_media_store_options_tab_content').eq(idx));
tab.prev().find('a').trigger('click');
}
// Show one field layout
function lorem_ipsum_books_media_store_shortcodes_show_field(field, tab_idx) {
"use strict";
// html output
var output = '';
// Parse field params
for (var clone_num in field['params']) {
var tab_id = 'tab_' + (parseInt(tab_idx) + parseInt(clone_num));
output += '
';
for (var param_num in field['params'][clone_num]) {
var param = field['params'][clone_num][param_num];
var id = tab_id + '_' + param_num;
// Divider after field
var divider = lorem_ipsum_books_media_store_isset(param['divider']) && param['divider'] ? ' lorem_ipsum_books_media_store_options_divider' : '';
// Setup default parameters
if (param['type']=='media') {
if (!lorem_ipsum_books_media_store_isset(param['before'])) param['before'] = {};
param['before'] = lorem_ipsum_books_media_store_merge_objects({
'title': 'Choose image',
'action': 'media_upload',
'type': 'image',
'multiple': false,
'sizes': false,
'linked_field': '',
'captions': {
'choose': 'Choose image',
'update': 'Select image'
}
}, param['before']);
if (!lorem_ipsum_books_media_store_isset(param['after'])) param['after'] = {};
param['after'] = lorem_ipsum_books_media_store_merge_objects({
'icon': 'iconadmin-cancel',
'action': 'media_reset'
}, param['after']);
}
if (param['type']=='color' && (LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_cp']=='tiny' || (lorem_ipsum_books_media_store_isset(param['style']) && param['style']!='wp'))) {
if (!lorem_ipsum_books_media_store_isset(param['after'])) param['after'] = {};
param['after'] = lorem_ipsum_books_media_store_merge_objects({
'icon': 'iconadmin-cancel',
'action': 'color_reset'
}, param['after']);
}
// Buttons before and after field
var before = '', after = '', buttons_classes = '', rez, rez2, i, key, opt;
if (lorem_ipsum_books_media_store_isset(param['before'])) {
rez = lorem_ipsum_books_media_store_shortcodes_action_button(param['before'], 'before');
before = rez[0];
buttons_classes += rez[1];
}
if (lorem_ipsum_books_media_store_isset(param['after'])) {
rez = lorem_ipsum_books_media_store_shortcodes_action_button(param['after'], 'after');
after = rez[0];
buttons_classes += rez[1];
}
if (lorem_ipsum_books_media_store_in_array(param['type'], ['list', 'select', 'fonts']) || (param['type']=='socials' && (lorem_ipsum_books_media_store_empty(param['style']) || param['style']=='icons'))) {
buttons_classes += ' lorem_ipsum_books_media_store_options_button_after_small';
}
if (param['type'] != 'hidden') {
output += '
'
+ "\n"
+ ''
+ "\n"
+ '
'
+ "\n";
}
if (!lorem_ipsum_books_media_store_isset(param['value'])) {
param['value'] = '';
}
switch ( param['type'] ) {
case 'hidden':
output += '';
break;
case 'date':
if (lorem_ipsum_books_media_store_isset(param['style']) && param['style']=='inline') {
output += ''
+ '';
} else {
output += ''
+ before
+ after;
}
break;
case 'text':
output += ''
+ before
+ after;
break;
case 'textarea':
var cols = lorem_ipsum_books_media_store_isset(param['cols']) && param['cols'] > 10 ? param['cols'] : '40';
var rows = lorem_ipsum_books_media_store_isset(param['rows']) && param['rows'] > 1 ? param['rows'] : '8';
output += '
';
if (!lorem_ipsum_books_media_store_empty(param['desc']))
output += '
' + param['desc'] + '
' + "\n";
output += '
' + "\n";
}
}
output += '
';
}
return output;
}
// Return menu items list (menu, images or icons)
function lorem_ipsum_books_media_store_shortcodes_menu_list(field) {
"use strict";
if (field['type'] == 'socials') field['value'] = field['value']['icon'];
var list = '
';
var caption = '';
for (var key in field['options']) {
var value = field['options'][key];
if (lorem_ipsum_books_media_store_in_array(field['type'], ['list', 'icons', 'socials'])) key = value;
var selected = '';
if (lorem_ipsum_books_media_store_in_list(field['value'], key, LOREM_IPSUM_BOOKS_MEDIA_STORE_STORAGE['shortcodes_delimiter'])) {
caption = value;
selected = ' lorem_ipsum_books_media_store_options_state_checked';
}
list += '';
if (lorem_ipsum_books_media_store_in_array(field['type'], ['list', 'select', 'fonts']))
list += value;
else if (field['type'] == 'icons' || (field['type'] == 'socials' && field['style'] == 'icons'))
list += '';
else if (field['type'] == 'images' || (field['type'] == 'socials' && field['style'] == 'images'))
list += '';
list += '';
}
list += '
';
return [list, caption];
}
// Return action button
function lorem_ipsum_books_media_store_shortcodes_action_button(data, type) {
"use strict";
var class_name = ' lorem_ipsum_books_media_store_options_button_' + type + (lorem_ipsum_books_media_store_empty(data['title']) ? ' lorem_ipsum_books_media_store_options_button_'+type+'_small' : '');
var output = ''
+ (type == 'button' || (lorem_ipsum_books_media_store_empty(data['icon']) && !lorem_ipsum_books_media_store_empty(data['title'])) ? data['title'] : '')
+ '';
return [output, class_name];
}
// Prepare string to insert as parameter's value
function lorem_ipsum_books_media_store_shortcodes_prepare_value(val) {
return typeof val == 'string' ? val.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(//g, '>') : val;
}