PluginProbe
Easy Bootstrap Shortcode / 2.5
Easy Bootstrap Shortcode v2.5
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 / tables / tables_plugin.js

tables_plugin.js in Easy Bootstrap Shortcode 2.5, at shortcode/tables/tables_plugin.js

122 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var tables={
2 title:"Table Shortcode",
3 id :'oscitas-form-table',
4 pluginName: 'tables'
5 };
6 (function() {
7 _create_tinyMCE_options(tables);
8 })();
9
10 function create_oscitas_tables(pluginObj){
11 if(jQuery(pluginObj.hashId).length){
12 jQuery(pluginObj.hashId).remove();
13 }
14 // creates a form to be displayed everytime the button is clicked
15 // you should achieve this using AJAX instead of direct html code like this
16 var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table">\
17 <tr>\
18 <th><label for="oscitas-table-width">Table Width</label></th>\
19 <td><input type="text" name="icontag" id="oscitas-table-width" value="100%" /><br />\
20 </td>\
21 </tr>\
22 <tr>\
23 <th><label for="oscitas-table-columns">Columns</label></th>\
24 <td><input type="text" name="link" id="oscitas-table-columns" value="4" /><br />\
25 </td>\
26 </tr>\
27 <tr>\
28 <th><label for="oscitas-table-rows">Rows</label></th>\
29 <td><input type="text" name="title" id="oscitas-table-rows" value="4" /><br />\
30 </td>\
31 </tr>\
32 <tr>\
33 <th><label for="oscitas-table-rows">Table style</label></th>\
34 <td>\
35 <select name="tablestyle" id="oscitas-table-style">\
36 <option value="">Simple</option>\
37 <option value="table-striped">Striped</option>\
38 <option value="table-bordered">Bordered</option>\
39 <option value="table-striped table-bordered">Striped + Bordered</option>\
40 </select>\
41 <br />\
42 </td>\
43 </tr>\
44 <tr>\
45 <th><label for="oscitas-table-rows">Show hover effect</label></th>\
46 <td>\
47 <input type="checkbox" id="oscitas-table-hover" value="table-hover">\
48 <br />\
49 </td>\
50 </tr>\
51 <tr>\
52 <th><label for="oscitas-table-rows">Responsive</label></th>\
53 <td>\
54 <input type="checkbox" id="oscitas-table-scroll" value="table-responsive">\
55 <br />\
56 </td>\
57 </tr>\
58 <tr>\
59 <th><label for="oscitas-table-class">Custom Class:</label></th>\
60 <td><input type="text" name="line" id="oscitas-table-class" value=""/><br />\
61 </td>\
62 </tr>\
63 </table>\
64 <p class="submit">\
65 <input type="button" id="oscitas-submit" class="button-primary" value="Insert Table" name="submit" />\
66 </p>\
67 </div>');
68
69 var table = form.find('table');
70 form.appendTo('body').hide();
71
72 // handles the click event of the submit button
73 form.find('#oscitas-submit').click(function(){
74 // defines the options and their default values
75 // again, this is not the most elegant way to do this
76 // but well, this gets the job done nonetheless
77 var cusclass='';
78 if(table.find('#oscitas-table-class').val()!=''){
79 cusclass= ' class="'+table.find('#oscitas-table-class').val()+'"';
80 }
81 var columns = table.find('#oscitas-table-columns').val();
82 var rows = table.find('#oscitas-table-rows').val();
83 var value = table.find('#oscitas-table-width').val();
84 var osStyle = table.find('#oscitas-table-style').val();
85
86 var osHover = table.find('#oscitas-table-hover').prop('checked') ? ' table-hover' : '' ;
87 var osScroll = table.find('#oscitas-table-scroll').prop('checked')? 'true': 'false';
88 //creating table
89 var shortcode = '[table ';
90 shortcode += 'width ="' + value + '"';
91 shortcode += ' style ="' + osStyle +osHover+ '"';
92 shortcode += ' responsive ="' +osScroll+ '"'+cusclass;
93
94 shortcode += ']<br/>[table_head]<br/>';
95 for (var i=1;i<=columns;i++)
96 {
97 shortcode += '[th_column]Heading-'+i+'[/th_column]<br/>';
98 }
99 shortcode += '[/table_head]<br/>[table_body]<br/>';
100
101 for (var j=1;j<=rows;j++)
102 {
103 shortcode += '[table_row]<br/>';
104 for (var i=1;i<=columns;i++)
105 {
106 shortcode += '[row_column]value-'+i+'[/row_column]<br/>';
107 }
108
109 shortcode += '[/table_row]<br/>';
110 }
111 shortcode += '[/table_body]<br/>[/table]';
112
113
114 // inserts the shortcode into the active editor
115 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
116
117 // closes fancybox
118 close_dialogue(pluginObj.hashId);
119 });
120 }
121
122