var buttons={ title:"Button Shortcode", id :'oscitas-form-button', pluginName: 'buttons' }; (function() { _create_tinyMCE_options(buttons, 800); })(); function create_oscitas_buttons(pluginObj){ if(jQuery(pluginObj.hashId).length){ jQuery(pluginObj.hashId).remove(); } // creates a form to be displayed everytime the button is clicked // you should achieve this using AJAX instead of direct html code like this var form = jQuery('
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

\

\

\
\ \

\

\
\ \
\

\
\ \
\

\
\

\ \

\
'); var table = form.find('table'); jQuery('.glyphicon').css('display','inline'); form.appendTo('body').hide(); form.find('.color').wpColorPicker(); table.find('#click_icon_list_button').click(function(){ if(!jQuery(this).hasClass('osc_icon_showing_button')){ jQuery(this).addClass('osc_icon_showing_button') table.find('#osc_show_iconlist_button').show(); } else{ jQuery(this).removeClass('osc_icon_showing_button') table.find('#osc_show_iconlist_button').hide(); } }); table.find('#oscitas-heading-icon_button li').click(function(){ var val=jQuery(this).attr('data-value'); table.find('#oscitas-heading-icon_button li').removeClass('osc_icon_selected_button'); jQuery(this).addClass('osc_icon_selected_button'); table.find('#osc_show_iconlist_button').hide(); table.find('#osc_show_icon_button').removeClass().addClass('glyphicon').addClass(val); table.find('#osc_icon_class_val_button').val(val); }) table.find('#oscitas-button-type').change(function(){ var abc = jQuery(this).val(); if('link' == abc){ jQuery("#tr-button-link").show(); jQuery("#tr-button-newwindow").show(); }else{ jQuery("#tr-button-link").hide(); jQuery("#tr-button-newwindow").hide(); } jQuery('#oscitas-form-button table tr:visible:even').css('background', '#F0F0F0'); jQuery('#oscitas-form-button table tr:visible:odd').css('background', '#DADADD'); }); // handles the click event of the submit button form.find('#oscitas-button-submit').click(function(){ // defines the options and their default values // again, this is not the most elegant way to do this // but well, this gets the job done nonetheless var options; var type = table.find('#oscitas-button-type').val(); if(type=='button'){ options = { 'title' : 'osCitas' }; } else{ options = { 'title' : 'osCitas', 'link' : '' }; } var cusclass='',icon=''; if(table.find('#oscitas-button-class').val()!=''){ cusclass= ' class="'+table.find('#oscitas-button-class').val()+'"'; } if(table.find('#osc_icon_class_val_button').val()!=''){ icon= ' icon="'+table.find('#osc_icon_class_val_button').val()+'" '; icon += ' align="'+table.find('#oscitas-button-iconalign').val()+'" '; if(table.find('#oscitas-button-iconcolor').val()!=''){ icon+= ' iconcolor="'+table.find('#oscitas-button-iconcolor').val()+'" '; } } var shortcode = '[button'+cusclass; shortcode += ' style="'+table.find('#oscitas-button-style').val(); shortcode += ' '+table.find('#oscitas-button-size').val(); shortcode += table.find('#oscitas-button-block').prop('checked')? ' btn-block': ''; shortcode += '" '; shortcode += icon; shortcode += ' type="'+type+'" '; if(type!='button'){ shortcode += ' target="'+(table.find('#oscitas-button-target').prop('checked')? 'true': 'false')+ '" '; } for( var index in options) { var value = table.find('#oscitas-button-' + index).val(); // var value = table.find('#oscitas-button-' + index).val(); shortcode += ' ' + index + '="' + value + '"'; } shortcode += ']'; // inserts the shortcode into the active editor tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode); // closes fancybox close_dialogue(pluginObj.hashId); }); }