(function () { tinymce.PluginManager.add('ig_shortcodes', function (editor, url) { var site_url = '../wp-content/themes/base-wp/extra/ig-shortcodes' // Add a button that opens a window editor.addButton('ig_shortcodes_button', { Title: 'Theme Shortcodes', image: site_url + "/images/toolbar-icon.png", onclick: function () { /* Show the popup */ var width = jQuery(window).width(), H = jQuery(window).height(), W = (720 < width) ? 720 : width; W = W - 80; H = H - 84; tb_show('Theme Shortcodes', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=ig-shortcodes-form'); } }); }); jQuery(function () { /* Social Links */ var social_icons = 'Choose icon
\ \ '; var fa_icons = ''; /* The form */ var form = jQuery('\
\
\ \
\ \
\

Add a button

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \
\ \ or add a hex value\ \
\ \
\ \
\ \
\
\
\ \
\

Add social links and icons

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
' + social_icons + '\ \ \
\
\
\ \
\

Add columns

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\
\ \ ½½\
\ \ \ \
\ ¼¼¼¼\ ½¼¼\ ¼¼½\ ¼½¼\ \
\
\
\
\ \
\

Add toggles

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \
\ \
\
\
\ \
\

Add an accordion

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\ Choose an icon\ \ \ \ \ \
\
\
\ \
\

Add tabs

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\
\
\
\
\
\
\
\
\
\
\
\
\ \
\

Add an Alert Box

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \
\ \ or add a hex value\ \
\
\
\ \
\

Add a Pull Quote Left

\
\ \ \ \ \ \ \ \ \ \
\ \ or add a hex value\ \
\
\
\ \
\

Add a Pull Quote Right

\
\ \ \ \ \ \ \ \ \ \
\ \ or add a hex value\ \
\
\
\ \
\

Box Features

\
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \
\ or add a hex value\ \
\
\
\ \
\

Add List

\
\ \ \ \ \ \ \ \ \ \ \ \
\ Choose an icon\ \ \ \
\ \ or add a hex value\ \
\
\
\
\
\ \ \ \
\
'); form.appendTo('body').hide(); /* Change tab */ var ig_shortcode_type = "button"; var ig_shortcode_code = ""; form.find('.ig-shortcodes-form-types ul li a').click(function () { ig_shortcode_type = jQuery(this).parent('li').attr('type'); jQuery('input#ig-shortcodes-form-type').val(ig_shortcode_type); jQuery('.ig-shortcodes-form-tab').hide(); jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type).show(); jQuery('.ig-shortcodes-form-types .active').removeClass('active'); jQuery(this).parent('li').addClass('active'); jQuery('.ig-shortcodes-form .ig-shortcodes-form-types').css({ "height": jQuery('.ig-shortcodes-form-tabs').outerHeight() }); return false; }); /* Choose icon */ jQuery('.ig-shortcodes-toggle-icon-list').click(function () { jQuery(this).parent('td').find('.ig-shortcodes-icon-list-holder').fadeToggle(); return false; }); jQuery('.ig-shortcodes-icon-list li a').click(function () { jQuery(this).parentsUntil('td').parent('td').find('input[type="text"]:first').val(jQuery(this).find('span').text()); jQuery('.ig-shortcodes-icon-list-holder').hide(); jQuery(this).parentsUntil('td').parent('td').find('.current-icon').attr({ 'class': 'current-icon fa-icon- fa-icon-' + jQuery(this).find('span').text() }); var icon_to_add = jQuery(this).find('span').text(); if (icon_to_add.search('ja-social-icon') > -1) { jQuery(this).parentsUntil('td').parent('td').find('.current-social-icon').attr({ 'class': 'current-social-icon ja-social-icon- ' + jQuery(this).find('span').text() }); jQuery(this).parentsUntil('td').parent('td').find('.social-icon').hide(); jQuery(this).parentsUntil('td').parent('td').find('.current-social-icon').show(); } else { jQuery(this).parentsUntil('td').parent('td').find('.social-icon').show(); jQuery(this).parentsUntil('td').parent('td').find('.current-social-icon').hide(); } return false; }); /* Color Picker */ if (jQuery('.ig-shortcodes-button_colour_custom').size() > 0) { jQuery('.ig-shortcodes-button_colour_custom').wpColorPicker(); } /* Choose Column Structure */ var num_of_columns = 2; jQuery('.column-structures a').click(function () { jQuery('.column-structures a').removeClass('active'); jQuery(this).addClass('active'); jQuery('.column-structures input').val(jQuery(this).attr('split')); num_of_columns = jQuery(this).attr('split'); num_of_columns = num_of_columns.split('|'); num_of_columns = num_of_columns.length; jQuery('#ig-shortcodes-form-tab_columns textarea').attr({ 'disabled': 'disabled' }); var i = -1; while (i < (num_of_columns - 1)) { i++; jQuery('#ig-shortcodes-form-tab_columns textarea').eq(i).removeAttr('disabled'); } return false; }); /* On submit click */ form.find('#ig_shortcodes-submit').click(function () { /* Create shortcode */ ig_shortcode_code = ''; if (ig_shortcode_type == "social") { /* Social shortcode */ ig_shortcode_code = ig_shortcode_code + '[ig_' + ig_shortcode_type + ']'; jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' td').each(function () { if (jQuery(this).find('input:first').val() == "" || jQuery(this).find('input:first').val() == undefined) {} else { ig_shortcode_code = ig_shortcode_code + '[ig_social_link service="'; ig_shortcode_code = ig_shortcode_code + jQuery(this).find('input').eq(0).val(); ig_shortcode_code = ig_shortcode_code + '" link="'; ig_shortcode_code = ig_shortcode_code + jQuery(this).find('input').eq(1).val(); ig_shortcode_code = ig_shortcode_code + '"] '; } }); ig_shortcode_code = ig_shortcode_code + '[/ig_' + ig_shortcode_type + ']'; } else if (ig_shortcode_type == "columns") { /* Columns shortcode */ ig_shortcode_code = ig_shortcode_code + '[ig_' + ig_shortcode_type + ' '; jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' input, #ig-shortcodes-form-tab_' + ig_shortcode_type + ' select').each(function () { if (jQuery(this).attr('fieldname') != "" || jQuery(this).attr('fieldname') != undefined) { ig_shortcode_code = ig_shortcode_code + ' ' + jQuery(this).attr('fieldname') + '="' + jQuery(this).val() + '"'; } }); ig_shortcode_code = ig_shortcode_code + ']'; /* the actual cols */ var col_counter = 0; var col_class = 'a'; jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' textarea').each(function () { if (jQuery(this).attr('disabled') == "disabled") {} else { col_counter++; if (col_counter == 1) { col_class = "a"; } if (col_counter == 2) { col_class = "b"; } if (col_counter == 3) { col_class = "c"; } if (col_counter == 4) { col_class = "d"; } ig_shortcode_code = ig_shortcode_code + '[ig_col position="' + col_class + '"]' + jQuery(this).val() + '[/ig_col]'; } }); ig_shortcode_code = ig_shortcode_code + '[/ig_' + ig_shortcode_type + ']'; } else if (ig_shortcode_type == "tabs") { /* Tabs shortcode */ ig_shortcode_code = ig_shortcode_code + '[ig_' + ig_shortcode_type + ']'; /* the actual tabs */ jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' input').each(function () { if (jQuery(this).val() != "") { ig_shortcode_code = ig_shortcode_code + '[ig_tab label="' + jQuery(this).val() + '"]' + jQuery(this).parent('td').find('textarea').val() + '[/ig_tab]'; } }); ig_shortcode_code = ig_shortcode_code + '[/ig_' + ig_shortcode_type + ']'; } else if (ig_shortcode_type == "accordion") { /* Accordion shortcode */ ig_shortcode_code = ig_shortcode_code + '[ig_' + ig_shortcode_type + ']'; /* the actual toggle */ jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' tr').each(function () { if (jQuery(this).find('textarea').val() != "") { ig_shortcode_code = ig_shortcode_code + '[ig_toggle accordion="1" icon="' + jQuery(this).find('input').eq(0).val() + '" heading="' + jQuery(this).find('input').eq(1).val() + '" onload="' + jQuery(this).find('select').val() + '"]' + jQuery(this).find('textarea').val() + '[/ig_toggle]'; } }); ig_shortcode_code = ig_shortcode_code + '[/ig_' + ig_shortcode_type + ']'; } else if (ig_shortcode_type == "toggle") { jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type).each(function () { ig_shortcode_code = ig_shortcode_code + '[ig_toggle icon="' + jQuery(this).find('input').eq(0).val() + '" heading="' + jQuery(this).find('input').eq(1).val() + '" onload="' + jQuery(this).find('select').val() + '"]' + jQuery(this).find('textarea').val() + '[/ig_toggle]'; }); } else if (ig_shortcode_type == "list") { jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type).each(function () { ig_shortcode_code = ig_shortcode_code + '[ig_list icon="' + jQuery(this).find('input').eq(0).val() + '" colour="' + jQuery(this).find('select').val() + '" custom_colour="' + jQuery(this).find('input').eq(1).val() + '"]' + jQuery(this).find('textarea').val() + '[/ig_list]'; }); } else if (ig_shortcode_type == "features") { jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type).each(function () { ig_shortcode_code = ig_shortcode_code + '[ig_features icon="' + jQuery(this).find('input').eq(0).val() + '" url="' + jQuery(this).find('input').eq(4).val() + '" title="' + jQuery(this).find('input').eq(3).val() + '" custom_colour="' + jQuery(this).find('input').eq(1).val() + '"]' + jQuery(this).find('textarea').val() + '[/ig_features]'; }); } else if (ig_shortcode_type == "alertbox") { jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type).each(function () { ig_shortcode_code = ig_shortcode_code + '[ig_alertbox icon="' + jQuery(this).find('input').eq(0).val() + '" colour="' + jQuery(this).find('select').val() + '" custom_colour="' + jQuery(this).find('input').eq(1).val() + '"]' + jQuery(this).find('textarea').val() + '[/ig_alertbox]'; }); } else { /* Basic shortcodes */ ig_shortcode_code = ig_shortcode_code + '[ig_' + ig_shortcode_type + ' '; jQuery('#ig-shortcodes-form-tab_' + ig_shortcode_type + ' input, #ig-shortcodes-form-tab_' + ig_shortcode_type + ' select, #ig-shortcodes-form-tab_' + ig_shortcode_type + ' textarea').each(function () { if (jQuery(this).attr('fieldname') != "" && jQuery(this).attr('fieldname') != undefined) { ig_shortcode_code = ig_shortcode_code + ' ' + jQuery(this).attr('fieldname') + '="' + jQuery(this).val() + '"'; } }); ig_shortcode_code = ig_shortcode_code + ']'; } /* Insert shortcode */ tinyMCE.activeEditor.execCommand('mceInsertContent', 0, ig_shortcode_code); tb_remove(); return false; }); }); })()