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 / lists / lists_plugin.js

lists_plugin.js in Easy Bootstrap Shortcode 2.5, at shortcode/lists/lists_plugin.js

87 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var lists={
2 title:"List Group Shortcode",
3 id :'oscitas-form-lists',
4 pluginName: 'lists'
5 };
6 (function() {
7 _create_tinyMCE_options(lists);
8 })();
9
10 function create_oscitas_lists(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-type">Lists style</label></th>\
19 <td><select name="type" id="oscitas-type">\
20 <option value="">None</option>\
21 <option value="glyphicon-arrow-right">Arrow</option>\
22 <option value="glyphicon-ok">Check</option>\
23 <option value="glyphicon-plus">Plus</option>\
24 <option value="glyphicon-minus">Minus</option>\
25 </select><br />\
26 </td>\
27 </tr>\
28 <tr>\
29 <th><label for="oscitas-line">No of List Item</label></th>\
30 <td><input type="text" name="line" id="oscitas-list-item" value="3"/><br /><small>Enter a numeric value</small>\
31 </td>\
32 </tr>\
33 <tr>\
34 <th><label for="oscitas-list-class">Custom Class:</label></th>\
35 <td><input type="text" name="line" id="oscitas-list-class" value=""/><br />\
36 </td>\
37 </tr>\
38 </table>\
39 <p class="submit">\
40 <input type="button" id="oscitas-submit" class="button-primary" value="Insert List" name="submit" />\
41 </p>\
42 </div>');
43
44 var table = form.find('table');
45 form.appendTo('body').hide();
46
47 // handles the click event of the submit button
48 form.find('#oscitas-submit').click(function(){
49 // defines the options and their default values
50 // again, this is not the most elegant way to do this
51 // but well, this gets the job done nonetheless
52 var options = {
53 'type' : 'arrow'
54 },list=0,list_type;
55 var cusclass='';
56 if(table.find('#oscitas-list-class').val()!=''){
57 cusclass= ' class="'+table.find('#oscitas-list-class').val()+'"';
58 }
59 var shortcode = '[list'+cusclass;
60 var list_item=jQuery('#oscitas-list-item').val();
61 if(isNaN(list_item)==false){
62 list=list_item;
63 } else{
64 list=3;
65 }
66
67
68 shortcode += ']<br/>';
69 if(table.find('#oscitas-type').val()!=''){
70 list_type=' type="'+table.find('#oscitas-type').val()+'"';
71 }
72 else{
73 list_type='';
74 }
75 for(var i=1;i<=list;i++){
76 shortcode +='[li'+list_type+']your list content[/li]<br/>'
77 }
78 shortcode +='[/list]';
79
80 // inserts the shortcode into the active editor
81 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
82
83 close_dialogue(pluginObj.hashId);
84 });
85 }
86
87