PluginProbe
Easy Bootstrap Shortcode / trunk
Easy Bootstrap Shortcode vtrunk
trunk 2.4.0 2.5 3.4 3.5 3.6 3.7 4.0.0 4.4 4.5 4.5.4 5.0.0 5.0.1 5.0.2
easy-bootstrap-shortcodes / shortcode / wpcolumns / wpcolumns_plugin.js

wpcolumns_plugin.js in Easy Bootstrap Shortcode trunk, at shortcode/wpcolumns/wpcolumns_plugin.js

351 lines 13.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var wpcolumns={
2 title:"Columns Shortcode",
3 id :'oscitas-form-wpcolumns',
4 pluginName: 'wpcolumns'
5 };
6 (function() {
7 _create_tinyMCE_options(wpcolumns, 1094);
8 })();
9
10 function ebs_return_html_wpcolumns(pluginObj){
11 var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table ebs-default-options">\
12 <tr>\
13 <th><label for="oscitas-no-of-wpcolumns">'+ebsjstrans.noof+' '+ebsjstrans.columns+':</label></th>\
14 <td><select name="type" id="oscitas-no-of-wpcolumns">\
15 <option value="1" selected="selected">'+ebsjstrans.one+' '+ebsjstrans.column+'</option>\
16 <option value="2">'+ebsjstrans.two+' '+ebsjstrans.column+'</option>\
17 <option value="3">'+ebsjstrans.three+' '+ebsjstrans.column+'</option>\
18 <option value="4">'+ebsjstrans.four+' '+ebsjstrans.column+'</option>\
19 </select><br />\
20 </td>\
21 </tr>\
22 <tr id="wptwo" style="display:none;">\
23 <th><label for="oscitas-two-columns">2 '+ebsjstrans.column+' '+ebsjstrans.division+'</label></th>\
24 <td><select name="type" id="oscitas-two-columns" class="osc-change-col">\
25 <option value="6$6">1/2-1/2</option>\
26 <option value="4$8">1/3-2/3</option>\
27 <option value="8$3">2/3-1/3</option>\
28 <option value="3$9">1/4-3/4</option>\
29 <option value="9$3">3/4-1/4</option>\
30 </select> '+ebsjstrans.for+' '+ebsjstrans.large+' '+ebsjstrans.screen+'<br />\
31 </td>\
32 </tr>\
33 <tr id="wpthree" style="display:none;">\
34 <th><label for="oscitas-three-columns">3 column division</label></th>\
35 <td><select name="type" id="oscitas-three-columns" class="osc-change-col">\
36 <option value="4$4$4">1/3-1/3-1/3</option>\
37 <option value="3$6$3">1/4-2/4-1/4</option>\
38 <option value="3$3$6">1/4-1/4-2/4</option>\
39 <option value="6$3$3">2/4-1/4-1/4</option>\
40 </select> '+ebsjstrans.for+' '+ebsjstrans.large+' '+ebsjstrans.screen+'<br />\
41 </tr>\
42 <tr id="">\
43 <th><label for="append_column_table">'+ebsjstrans.column+' '+ebsjstrans.specification+'</label></th>\
44 <td id="append_column_table"></td>\
45 </tr>\
46 <tr>\
47 <th><label for="oscitas-column-class">'+ebsjstrans.customclass+':</label></th>\
48 <td><input type="text" name="line" id="oscitas-column-class" value=""/>\
49 </td>\
50 </tr>\
51 </table>\
52 <p class="submit ebs-default-options">\
53 <input type="button" id="oscitas-submit-wp_column" class="button-primary" value="'+ebsjstrans.insert+' '+ebsjstrans.columns+'" name="submit" />\
54 </p>\
55 <div class="pro-version-image aligncenter" style="display: none;"><img src="'+ebs_url+'shortcode/wpcolumns/screenshot.jpg"/></div>\
56 </div>');
57
58 return form;
59 }
60 function create_oscitas_wpcolumns(pluginObj){
61 var form=jQuery(pluginObj.hashId);
62
63
64 var table = form.find('table');
65
66
67 function show_table(){
68
69 var ele='',e=0,sm,smoff,md,mdoff,lg,lgoff,xs,xsoff,sel,val=0,selcol,hidecol;
70 var col= form.find('#oscitas-no-of-wpcolumns').val();
71 ele = '<i>'+ebsjstrans.youcanselect+'</i><br/>';
72
73 var option={
74 'lg': ebsjstrans.large+' '+ebsjstrans.screen,
75 'md': ebsjstrans.medium +' '+ebsjstrans.screen,
76 'sm': ebsjstrans.small+' '+ebsjstrans.screen,
77 'xs': ebsjstrans.xsmall+' '+ebsjstrans.screen
78 }
79 ele+= '<table id="appended" class="tb_multiple_column"><thead><tr><th>'+ebsjstrans.screen+'</th><th style="min-width:50px;max-width:50px">'+ebsjstrans.hide+' '+ebsjstrans.row+'</th>';
80
81 for(i=1;i<=col;i++){
82 ele+='<th><div class="head_division head_division_check">'+ebsjstrans.clear+' '+ebsjstrans.left+'</div><div class="head_division">'+ebsjstrans.column+'</div><div class="head_division">'+ebsjstrans.offset+'</div><div class="head_division head_division_check right">'+ebsjstrans.hide+'</div></th>';
83
84 }
85 ele+= '</tr></thead><tbody class="column_tbody">';
86 jQuery.each(option,function(index,val){
87 ele+='<tr><th class="column_td_first">'+val+'</th><td style="min-width:50px;max-width:50px"><input type="checkbox" name="'+index+'rowhide" id="'+index+'rowhide" value="yes"></td>';
88 for(var i=1;i<=col;i++){
89 sm='<select name="'+index+'['+i+']" id="'+index+i+'">';
90 for( e=1;e<=12;e++){
91 if(index=='lg'){
92
93 selcol=12/col;
94 if(e==selcol){
95 sel='selected=selected'
96 }
97 else{
98 sel='';
99 }
100 } else{
101 if(e==12){
102 sel='selected=selected'
103 }
104 else{
105 sel='';
106 }
107 }
108 sm+='<option value="'+e+'" '+sel+'>'+e+'</option>';
109 }
110 sm+='</select>';
111 smoff='<select name="'+index+'off['+i+']" id="'+index+'off'+i+'">';
112 for( e=0;e<12;e++){
113
114 smoff+='<option value="'+e+'">'+e+'</option>';
115 }
116 smoff+='</select>';
117
118 clearleft='<input type="checkbox" name="'+index+'clear['+i+']" id="'+index+'clear'+i+'" value="yes">';
119
120 hidecol='<input type="checkbox" name="'+index+'hide['+i+']" id="'+index+'hide'+i+'" value="yes">';
121
122
123 ele+='<td><div class="head_division head_division_check">'+clearleft+'</div><div class="head_division">'+sm+'</div><div class="head_division">'+smoff+'</div><div class="head_division head_division_check right">'+hidecol+'</div></td>';
124
125
126
127 }
128 ele+='</tr>';
129 });
130 ele +='</tbody></table>';
131 table.find('#append_column_table').html(ele);
132 jQuery("#oscitas-table tr:not(#appended tr):visible:even").css('background-color', '#ffffff');
133 jQuery("#oscitas-table tr:not(#appended tr):visible:odd").css('background-color', '#efefef');
134 }
135 function chnage_col_value(){
136
137 var col= form.find('#oscitas-no-of-wpcolumns').val(),str,arr=[],i=0;
138 if(col==2 || col==3){
139 if(col==2){
140 str=form.find('#oscitas-two-columns').val();
141 } else if(col==3){
142 str=form.find('#oscitas-three-columns').val();
143 }
144 arr=str.split('$');
145 jQuery.each(arr,function(index,val){
146 i=parseInt(index)+1;
147 jQuery('#lg'+i).val(val);
148 })
149
150 }
151 jQuery("#oscitas-table tr:not(#appended tr):visible:even").css('background-color', '#FFFFFF');
152 jQuery("#oscitas-table tr:not(#appended tr):visible:odd").css('background-color', '#efefef');
153 }
154
155 show_table();
156
157 jQuery('#oscitas-no-of-wpcolumns').change(function(){
158 var noOfColumns = jQuery(this).val();
159 if(2 == noOfColumns){
160
161 jQuery("#wpthree").hide();
162 jQuery("#wptwo").show();
163 }
164 else if(3 == noOfColumns){
165 jQuery("#wptwo").hide();
166 jQuery("#wpthree").show();
167 }
168 else{
169 jQuery("#wptwo").hide();
170 jQuery("#wpthree").hide();
171
172 }
173 show_table();
174 chnage_col_value();
175
176
177 });
178 form.find('.osc-change-col').change(function(){
179 chnage_col_value();
180 })
181 var arr={
182 1:'lg',
183 2: 'md',
184 3:'sm',
185 4:'xs'
186 };
187
188
189 var value1 =0,valueoff=0,lastSel,previous;
190 jQuery.each(arr,function(i,valuenum){
191 jQuery.each(arr,function(tt,index){
192
193 form.on('focus', '#'+index+i, function(){
194 previous = this.value;
195 }).on('change', '#'+index+i, function(){
196 value1= parseInt(jQuery(this).val());
197 valueoff =parseInt(jQuery('#'+index+'off'+i).val());
198 value1=value1+valueoff;
199 if(value1<=12){
200 previous = this.value;
201 }
202 else{
203 jQuery('#'+index+i).val(previous);
204 alert(ebsjstrans.cantchange);
205 }
206 });
207
208 form.on('focus', '#'+index+'off'+i, function(){
209 previous = this.value;
210 }).on('change', '#'+index+'off'+i, function(){
211 value1= parseInt(jQuery(this).val());
212 valueoff = parseInt(jQuery('#'+index+i).val());
213 value1=value1+valueoff;
214 if(value1<=12){
215 previous = this.value;
216 }
217 else{
218 jQuery('#'+index+'off'+i).val(previous);
219 alert(ebsjstrans.cantchange);
220 }
221 });
222 })
223 });
224
225 // handles the click event of the submit button
226 form.find('#oscitas-submit-wp_column').click(function(){
227 // defines the options and their default values
228 // again, this is not the most elegant way to do this
229 // but well, this gets the job done nonetheless
230 var a_md=[],a_sm=[],a_xs=[],a_lg=[],j=0,a_md_off=[],a_sm_off=[],a_xs_off=[],a_lg_off=[],a_md_hide=[],a_sm_hide=[],a_xs_hide=[],a_lg_hide=[],sm='',md='',xs='',smoff='',mdoff='',xsoff='',lgoff='',smhide='',mdhide='',xshide='',lghide='',smclear='',mdclear='',xsclear='',lgclear='';
231
232
233 var noOfColumns = jQuery('#oscitas-no-of-wpcolumns').val();
234 var shortcode = '';
235 var cusclass='';
236 if(table.find('#oscitas-column-class').val()!=''){
237 cusclass= ' class="'+table.find('#oscitas-column-class').val()+'"';
238 }
239 shortcode ='['+$ebs_prefix+'row'+cusclass+']';
240 for(var i=1;i<=parseInt(noOfColumns);i++){
241
242 a_md[i] = jQuery('#md'+i).val();
243 a_sm[i] = jQuery('#sm'+i).val();
244 a_xs[i] = jQuery('#xs'+i).val();
245 a_lg[i] = jQuery('#lg'+i).val();
246 a_md_off[i] = jQuery('#mdoff'+i).val();
247 a_sm_off[i] = jQuery('#smoff'+i).val();
248 a_xs_off[i] = jQuery('#xsoff'+i).val();
249 a_lg_off[i] = jQuery('#lgoff'+i).val();
250
251 //if(a_md[i]!=12){
252 md=' md="'+a_md[i]+'"';
253 //} else{
254 // md='';
255 //}
256 //if(a_sm[i]!=12){
257 sm=' sm="'+a_sm[i]+'"';
258 //} else{
259 // sm='';
260 //}
261 //if(a_xs[i]!=12){
262 xs=' xs="'+a_xs[i]+'"';
263 //} else{
264 // xs='';
265 //}
266 if(a_md_off[i]!=0){
267 mdoff=' mdoff="'+a_md_off[i]+'"';
268 }
269 else{
270 mdoff='';
271 }
272 if(a_sm_off[i]!=0){
273 smoff=' smoff="'+a_sm_off[i]+'"';
274 }
275 else{
276 smoff='';
277 }
278 if(a_xs_off[i]!=0){
279 xsoff=' xsoff="'+a_xs_off[i]+'"';
280 }
281 else{
282 xsoff='';
283 }
284 if(a_lg_off[i]!=0){
285 lgoff=' lgoff="'+a_lg_off[i]+'"';
286 }
287 else{
288 lgoff='';
289 }
290
291 if(jQuery('#mdrowhide').is(':checked') || jQuery('#mdhide'+i).is(':checked')){
292 mdhide=' mdhide="yes"';
293 }
294 else{
295 mdhide='';
296 }
297 if(jQuery('#smrowhide').is(':checked') ||jQuery('#smhide'+i).is(':checked')){
298 smhide=' smhide="yes"';
299 }
300 else{
301 smhide='';
302 }
303 if(jQuery('#xsrowhide').is(':checked') ||jQuery('#xshide'+i).is(':checked')){
304 xshide=' xshide="yes"';
305 }
306 else{
307 xshide='';
308 }
309 if(jQuery('#lgrowhide').is(':checked') ||jQuery('#lghide'+i).is(':checked')){
310 lghide=' lghide="yes"';
311 }
312 else{
313 lghide='';
314 }
315
316 if(jQuery('#mdclear'+i).is(':checked')){
317 mdclear=' mdclear="yes"';
318 }
319 else{
320 mdclear='';
321 }
322 if(jQuery('#smclear'+i).is(':checked')){
323 smclear=' smclear="yes"';
324 }
325 else{
326 smclear='';
327 }
328 if(jQuery('#xsclear'+i).is(':checked')){
329 xsclear=' xsclear="yes"';
330 }
331 else{
332 xsclear='';
333 }
334 if(jQuery('#lgclear'+i).is(':checked')){
335 lgclear=' lgclear="yes"';
336 }
337 else{
338 lgclear='';
339 }
340
341 shortcode += '<br/>['+$ebs_prefix+'column lg="'+a_lg[i]+'"'+md+sm+xs+mdoff+smoff+xsoff+lgoff+mdhide+smhide+xshide+lghide+mdclear+smclear+xsclear+lgclear+' ]<br/>'+ebsjstrans.text+'<br/>[/'+$ebs_prefix+'column]';
342 }
343
344 shortcode += '<br/>[/'+$ebs_prefix+'row]';
345 // inserts the shortcode into the active editor
346 ebsInsertShortcode(shortcode);
347 // closes Thickbox
348 close_dialogue(pluginObj.hashId);
349 });
350 }
351