| 1 |
var buttons={ |
| 2 |
title:"Button Shortcode", |
| 3 |
id :'oscitas-form-button', |
| 4 |
pluginName: 'buttons' |
| 5 |
|
| 6 |
}; |
| 7 |
(function() { |
| 8 |
_create_tinyMCE_options(buttons, 800); |
| 9 |
})(); |
| 10 |
|
| 11 |
function ebs_return_html_buttons(pluginObj){ |
| 12 |
|
| 13 |
var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table ebs-default-options">\ |
| 14 |
<tr>\ |
| 15 |
<th><label for="oscitas-button-style">Style:</label></th>\ |
| 16 |
<td><select name="type" id="oscitas-button-style">\ |
| 17 |
<option value="btn-default">'+ebsjstrans.simple+'</option>\ |
| 18 |
<option value="btn-primary">'+ebsjstrans.primary+'</option>\ |
| 19 |
<option value="btn-success">'+ebsjstrans.success+'</option>\ |
| 20 |
<option value="btn-info">'+ebsjstrans.information+'</option>\ |
| 21 |
<option value="btn-warning">'+ebsjstrans.warning+'</option>\ |
| 22 |
<option value="btn-danger">'+ebsjstrans.danger+'</option>\ |
| 23 |
<option value="btn-link">'+ebsjstrans.link+'</option>\ |
| 24 |
</select><br />\ |
| 25 |
</td>\ |
| 26 |
</tr>\ |
| 27 |
<tr>\ |
| 28 |
<th><label for="oscitas-button-size">Size:</label></th>\ |
| 29 |
<td><select name="type" id="oscitas-button-size">\ |
| 30 |
<option value="btn-lg">'+ebsjstrans.large+'</option>\ |
| 31 |
<option value="btn-sm">'+ebsjstrans.small+'</option>\ |
| 32 |
<option value="btn-xs">'+ebsjstrans.exsmall+'</option>\ |
| 33 |
</select><br />\ |
| 34 |
</td>\ |
| 35 |
</tr>\ |
| 36 |
<tr>\ |
| 37 |
<th><label for="oscitas-button-type">Type:</label></th>\ |
| 38 |
<td><select name="type" id="oscitas-button-type">\ |
| 39 |
<option value="link">'+ebsjstrans.link+'</option>\ |
| 40 |
<option value="button">'+ebsjstrans.button+'</option>\ |
| 41 |
</select><br />\ |
| 42 |
</td>\ |
| 43 |
</tr>\ |
| 44 |
<tr>\ |
| 45 |
<th><label for="oscitas-heading-icon">'+ebsjstrans.select+' '+ebsjstrans.icon+':</label></th>\ |
| 46 |
<td><div id="click_icon_list_button" class="oscitas-icon-div"><span id="osc_show_icon_button"></span><span class="show-drop"></span></div><input type="hidden" id="osc_icon_class_val_button" value="">\ |
| 47 |
<div id="osc_show_iconlist_button" class="oscitas-icon" style="display:none;width:100%">'+font_awesome_include('oscitas-heading-icon_button')+'</div>\ |
| 48 |
</td>\ |
| 49 |
</tr>\ |
| 50 |
<tr>\ |
| 51 |
<th><label for="oscitas-button-iconalign">'+ebsjstrans.icon+' '+ebsjstrans.alignment+':</label></th>\ |
| 52 |
<td><select name="type" id="oscitas-button-iconalign">\ |
| 53 |
<option value="left">'+ebsjstrans.left+'</option>\ |
| 54 |
<option value="right">'+ebsjstrans.right+'</option>\ |
| 55 |
</select><br />\ |
| 56 |
</td>\ |
| 57 |
</tr>\ |
| 58 |
<tr>\ |
| 59 |
<th><label for="oscitas-button-iconcolor">'+ebsjstrans.icon+' '+ebsjstrans.color+':</label></th>\ |
| 60 |
<td><input type="text" name="label" id="oscitas-button-iconcolor" class="color" value="" /><br />\ |
| 61 |
</td>\ |
| 62 |
</tr>\ |
| 63 |
<tr>\ |
| 64 |
<th><label for="oscitas-table-rows">'+ebsjstrans.makeblock+'</label></th>\ |
| 65 |
<td>\ |
| 66 |
<input type="checkbox" id="oscitas-button-block">\ |
| 67 |
<br />\ |
| 68 |
</td>\ |
| 69 |
</tr>\ |
| 70 |
<tr>\ |
| 71 |
<th><label for="oscitas-button-title">'+ebsjstrans.title+':</label></th>\ |
| 72 |
<td><input type="text" name="title" id="oscitas-button-title" value="Button"/><br />\ |
| 73 |
</td>\ |
| 74 |
</tr>\ |
| 75 |
<tr class="tr-button-link">\ |
| 76 |
<th><label for="oscitas-button-link">'+ebsjstrans.link+'</label></th>\ |
| 77 |
<td><input type="text" name="link" id="oscitas-button-link" value="#" /><br />\ |
| 78 |
</td>\ |
| 79 |
</tr>\ |
| 80 |
<tr class="tr-button-link">\ |
| 81 |
<th><label for="oscitas-button-link">'+ebsjstrans.rel+'</label></th>\ |
| 82 |
<td><input type="text" name="rel" id="oscitas-button-linkrel" value="" /><br />\ |
| 83 |
</td>\ |
| 84 |
</tr>\ |
| 85 |
<tr id="tr-button-newwindow">\ |
| 86 |
<th><label for="oscitas-table-rows">'+ebsjstrans.newtarget+'</label></th>\ |
| 87 |
<td>\ |
| 88 |
<input type="checkbox" id="oscitas-button-target">\ |
| 89 |
<br />\ |
| 90 |
</td>\ |
| 91 |
</tr>\ |
| 92 |
<tr>\ |
| 93 |
<th><label for="oscitas-button-class">'+ebsjstrans.customclass+':</label></th>\ |
| 94 |
<td><input type="text" name="line" id="oscitas-button-class" value=""/><br />\ |
| 95 |
</td>\ |
| 96 |
</tr>\ |
| 97 |
</table>\ |
| 98 |
<p class="submit ebs-default-options">\ |
| 99 |
<input type="button" id="oscitas-button-submit" class="button-primary" value="'+ebsjstrans.insert+' '+ebsjstrans.button+'" name="submit" />\ |
| 100 |
</p>\ |
| 101 |
<div class="pro-version-image aligncenter" style="display: none;"><img src="'+ebs_url+'shortcode/buttons/screenshot.jpg"/></div>\ |
| 102 |
</div>'); |
| 103 |
return form; |
| 104 |
} |
| 105 |
function create_oscitas_buttons(pluginObj){ |
| 106 |
var form= jQuery(pluginObj.hashId) |
| 107 |
var table = form.find('table'); |
| 108 |
jQuery('.glyphicon').css('display','inline'); |
| 109 |
|
| 110 |
form.find('.color').wpColorPicker(); |
| 111 |
table.find('#click_icon_list_button').click(function(){ |
| 112 |
if(!jQuery(this).hasClass('osc_icon_showing_button')){ |
| 113 |
jQuery(this).addClass('osc_icon_showing_button') |
| 114 |
table.find('#osc_show_iconlist_button').show(); |
| 115 |
} else{ |
| 116 |
jQuery(this).removeClass('osc_icon_showing_button') |
| 117 |
table.find('#osc_show_iconlist_button').hide(); |
| 118 |
} |
| 119 |
}); |
| 120 |
table.find('.oscitas-heading-icon_button li').click(function(){ |
| 121 |
var val=jQuery(this).attr('data-value'); |
| 122 |
var type=jQuery(this).attr('type'); |
| 123 |
table.find('.oscitas-heading-icon_button li').removeClass('osc_icon_selected_button'); |
| 124 |
jQuery(this).addClass('osc_icon_selected_button'); |
| 125 |
table.find('#osc_show_iconlist_button').hide(); |
| 126 |
table.find('#osc_show_icon_button').removeClass().addClass(type).addClass(val); |
| 127 |
table.find('#osc_icon_class_val_button').val(type+' '+val); |
| 128 |
}) |
| 129 |
|
| 130 |
table.find('#oscitas-button-type').change(function(){ |
| 131 |
var abc = jQuery(this).val(); |
| 132 |
if('link' == abc){ |
| 133 |
jQuery(".tr-button-link").show(); |
| 134 |
jQuery("#tr-button-newwindow").show(); |
| 135 |
}else{ |
| 136 |
jQuery(".tr-button-link").hide(); |
| 137 |
jQuery("#tr-button-newwindow").hide(); |
| 138 |
} |
| 139 |
jQuery('#oscitas-form-button table tr:visible:even').css('background', '#ffffff'); |
| 140 |
jQuery('#oscitas-form-button table tr:visible:odd').css('background', '#efefef'); |
| 141 |
}); |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
// handles the click event of the submit button |
| 147 |
form.find('#oscitas-button-submit').click(function(){ |
| 148 |
// defines the options and their default values |
| 149 |
// again, this is not the most elegant way to do this |
| 150 |
// but well, this gets the job done nonetheless |
| 151 |
var options; |
| 152 |
var type = table.find('#oscitas-button-type').val(); |
| 153 |
if(type=='button'){ |
| 154 |
options = { |
| 155 |
'title' : 'osCitas' |
| 156 |
}; |
| 157 |
} |
| 158 |
else{ |
| 159 |
options = { |
| 160 |
'title' : 'osCitas', |
| 161 |
'link' : '', |
| 162 |
'linkrel' : '' |
| 163 |
}; |
| 164 |
} |
| 165 |
var cusclass='',icon=''; |
| 166 |
if(table.find('#oscitas-button-class').val()!=''){ |
| 167 |
cusclass= ' class="'+table.find('#oscitas-button-class').val()+'"'; |
| 168 |
} |
| 169 |
if(table.find('#osc_icon_class_val_button').val()!=''){ |
| 170 |
icon= ' icon="'+table.find('#osc_icon_class_val_button').val()+'" '; |
| 171 |
icon += ' align="'+table.find('#oscitas-button-iconalign').val()+'" '; |
| 172 |
if(table.find('#oscitas-button-iconcolor').val()!=''){ |
| 173 |
icon+= ' iconcolor="'+table.find('#oscitas-button-iconcolor').val()+'" '; |
| 174 |
} |
| 175 |
} |
| 176 |
|
| 177 |
var shortcode = '['+$ebs_prefix+'button'+cusclass; |
| 178 |
|
| 179 |
shortcode += ' style="'+table.find('#oscitas-button-style').val(); |
| 180 |
shortcode += ' '+table.find('#oscitas-button-size').val(); |
| 181 |
shortcode += table.find('#oscitas-button-block').prop('checked')? ' btn-block': ''; |
| 182 |
shortcode += '" '; |
| 183 |
shortcode += icon; |
| 184 |
shortcode += ' type="'+type+'" '; |
| 185 |
if(type!='button'){ |
| 186 |
shortcode += ' target="'+(table.find('#oscitas-button-target').prop('checked')? 'true': 'false')+ '" '; |
| 187 |
} |
| 188 |
for( var index in options) { |
| 189 |
var value = table.find('#oscitas-button-' + index).val(); |
| 190 |
// var value = table.find('#oscitas-button-' + index).val(); |
| 191 |
shortcode += ' ' + index + '="' + value + '"'; |
| 192 |
} |
| 193 |
|
| 194 |
shortcode += ']'; |
| 195 |
|
| 196 |
// inserts the shortcode into the active editor |
| 197 |
ebsInsertShortcode(shortcode); |
| 198 |
|
| 199 |
// closes fancybox |
| 200 |
close_dialogue(pluginObj.hashId); |
| 201 |
}); |
| 202 |
} |
| 203 |
|
| 204 |
|