PluginProbe
Easy Bootstrap Shortcode / 4.4
Easy Bootstrap Shortcode v4.4
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 / dropdown / dropdown_plugin.js

dropdown_plugin.js in Easy Bootstrap Shortcode 4.4, at shortcode/dropdown/dropdown_plugin.js

165 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var dropdown={
2 title:"Button Dropdown Shortcode",
3 id :'oscitas-form-dropdown',
4 pluginName: 'dropdown'
5 };
6 (function() {
7 _create_tinyMCE_options(dropdown);
8 })();
9
10 function ebs_return_html_dropdown(pluginObj){
11 var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table">\
12 <tr>\
13 <th class="main_dp_th"><label for="oscitas-dropdown-heading" >Dropdown Button Features</label></th>\
14 <td><table class="tb_multiple_column_upper">\
15 <thead>\
16 <tr><th>Text</th><th>Size</th><th>Style</th><th>Split</th><th>Dropup</th></tr>\
17 </thead>\
18 <tbody>\
19 <tr>\
20 <td><input type="text" name="dropdown-heading" id="oscitas-dropdown-heading" value="Dropdown"/></td>\
21 <td><select name="type" id="oscitas-dropdown-size">\
22 <option value="">Default</option>\
23 <option value="btn-lg">Large</option>\
24 <option value="btn-sm">Small</option>\
25 <option value="btn-xs">Ex-small</option>\
26 </select><br /></td>\
27 <td><select name="type" id="oscitas-dropdown-style">\
28 <option value="btn-default">Simple</option>\
29 <option value="btn-primary">Primary</option>\
30 <option value="btn-success">Success</option>\
31 <option value="btn-info">Information</option>\
32 <option value="btn-warning">Warning</option>\
33 <option value="btn-danger">Danger</option>\
34 <option value="btn-link">Link</option>\
35 </select><br /></td>\
36 <td><input type="checkbox" name="dropdown-split" id="oscitas-dropdown-split" value="split"/></td>\
37 <td><select name="type" id="oscitas-dropdown-dropup">\
38 <option value="dropdown">Drop Down</option>\
39 <option value="dropup">Drop Up</option>\
40 </select></td>\
41 </tr>\
42 </tbody>\
43 </table></td>\
44 </tr>\
45 <tr>\
46 <th class="main_dp_th"><label for="oscitas-line">Dropdown Items</label></th>\
47 <td><table class="tb_multiple_column">\
48 <thead>\
49 <tr><th>Type</th><th>Link</th><th>Title</th><th>Disabled</th><th>Option</th></tr>\
50 </thead>\
51 <tbody id="oscitas-append-dropdownitem">\
52 <tr class="osc_dropdown_list_item">\
53 <td><input type="hidden" class="oscitas-dropdownitem-type" value="menuitem"><span>Menu Item</span></td>\
54 <td><input type="text" name="dropdown-item-link[]" class="oscitas-dropdownitem-link" value="#"/></td>\
55 <td><input type="text" name="dropdown-item-title[]" class="oscitas-dropdownitem-title" value="Dropdown Item"/></td>\
56 <td><input type="checkbox" name="dropdown-item-disabled[]" class="oscitas-dropdownitem-disabled" value="disabled"/></td><td></td>\
57 </tr>\
58 </tbody>\
59 <tfoot>\
60 <tr><td colspan="5"><a id="osc_add_new_dditem" href="javascript:;" style="text-decoration:none;"><i class="glyphicon glyphicon-plus-sign"></i> Add New Item</a></td></tr>\
61 </tfoot>\
62 </table></td>\
63 </tr>\
64 <tr>\
65 <th><label for="oscitas-dropdown-class">Custom Class:</label></th>\
66 <td><input type="text" name="line" id="oscitas-dropdown-class" value=""/><br />\
67 </td>\
68 </tr>\
69 </table>\
70 <p class="submit">\
71 <input type="button" id="oscitas-dropdown-submit" class="button-primary" value="Insert Dropdown" name="submit" />\
72 </p>\
73 </div>');
74 return form;
75 }
76 function create_oscitas_dropdown(pluginObj){
77
78 var form=jQuery(pluginObj.hashId);
79
80 // creates a form to be displayed everytime the button is clicked
81 // you should achieve this using AJAX instead of direct html code like this
82
83
84 var table = form.find('table');
85
86 form.find('#osc_add_new_dditem').click(function(){
87 var item='<tr class="osc_dropdown_list_item"><td class="osc_type_change"><select name="dropdown-item-type[]" class="oscitas-dropdownitem-type"><option value="menuitem">Menu Item</option><option value="divider">Divider</option></select></td><td class="osc_hide"><input type="text" name="dropdown-item-link[]" class="oscitas-dropdownitem-link" value="#"/></td><td class="osc_hide"><input type="text" name="dropdown-item-title[]" class="oscitas-dropdownitem-title" value="Dropdown Item"/></td><td class="osc_hide"><input type="checkbox" name="dropdown-item-disabled[]" class="oscitas-dropdownitem-disabled" value="disabled"/></td><td><a class="osc_remove_dditem" href="javascript:;" style="text-decoration:none;"><i class="glyphicon glyphicon-remove"></i></a></td></tr>';
88 form.find('#oscitas-append-dropdownitem').append(item);
89
90 });
91 jQuery('.osc_remove_dditem').live('click',function(){
92 jQuery(this).parent().parent().remove();
93 })
94 jQuery('.osc_type_change').live('change',function(){
95 var par=jQuery(this).parent();
96 var item=jQuery(this);
97 var val=item.find('.oscitas-dropdownitem-type').val();
98 if(val=='divider'){
99 jQuery(par).find('.osc_hide').hide();
100 item.attr('colspan',4);
101 } else{
102 jQuery(par).find('.osc_hide').show();
103 item.attr('colspan',0);
104 }
105 })
106 // handles the click event of the submit button
107 form.find('#oscitas-dropdown-submit').click(function(){
108 var split,dropup;
109 var type,link,title,disabled;
110 var heading= jQuery('#oscitas-dropdown-heading').val();
111
112 if(jQuery('#oscitas-dropdown-split').is(":checked")==true){
113 split= jQuery('#oscitas-dropdown-split').val();
114 } else{
115 split='';
116 }
117 var size= jQuery('#oscitas-dropdown-size').val();
118 var style= jQuery('#oscitas-dropdown-style').val();
119 dropup= 'dropup="'+jQuery('#oscitas-dropdown-dropup').val()+'"';
120
121 var cusclass;
122 if(table.find('#oscitas-dropdown-class').val()!=''){
123 cusclass= ' class="'+table.find('#oscitas-dropdown-class').val()+'"';
124 }
125 else{
126 cusclass='';
127 }
128 var shortcode='';
129 shortcode ='['+$ebs_prefix+'dropdown '+dropup+cusclass+']<br/>';
130 shortcode +='['+$ebs_prefix+'dropdownhead style="'+style+'" size="'+size+'" split="'+split+'"]<br/>';
131 shortcode += heading+'<br/>';
132 shortcode +='[/'+$ebs_prefix+'dropdownhead]<br/>';
133 shortcode +='['+$ebs_prefix+'dropdownbody]<br/>';
134
135 jQuery('tr.osc_dropdown_list_item').each(function(index){
136
137 type = jQuery(this).find('.oscitas-dropdownitem-type').val();
138 link = jQuery(this).find('.oscitas-dropdownitem-link').val();
139 title = jQuery(this).find('.oscitas-dropdownitem-title').val();
140
141 if(jQuery(this).find('.oscitas-dropdownitem-disabled').is(":checked")==true){
142 disabled='disabled="'+jQuery(this).find('.oscitas-dropdownitem-disabled').val()+'"';
143 } else{
144 disabled='';
145 }
146 if(type=='divider'){
147 shortcode +='['+$ebs_prefix+'dropdownitem type="'+type+'"][/'+$ebs_prefix+'dropdownitem]<br/>';
148 } else if(type=='menuitem'){
149 shortcode +='['+$ebs_prefix+'dropdownitem type="'+type+'" link="'+link+'" '+disabled+']'+title+'[/'+$ebs_prefix+'dropdownitem]<br/>';
150 }
151
152 });
153
154 shortcode +='[/'+$ebs_prefix+'dropdownbody]<br/>';
155 shortcode +='[/'+$ebs_prefix+'dropdown]';
156
157
158 // inserts the shortcode into the active editor
159 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
160
161 close_dialogue(pluginObj.hashId);
162 });
163 }
164
165