PluginProbe
Easy Bootstrap Shortcode / 3.7
Easy Bootstrap Shortcode v3.7
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 3.7, at shortcode/lists/lists_plugin.js

116 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 tinymce.create('tinymce.plugins.oscitasLists', {
3 init : function(ed, url) {
4 ed.addButton('oscitaslists', {
5 title : 'List Group Shortcode',
6 image : url+'/icon.png',
7 onclick : function() {
8 create_oscitas_lists();
9 jQuery.fancybox({
10 'type' : 'inline',
11 'title' : 'List Group Shortcode',
12 'href' : '#oscitas-form-lists',
13 helpers: {
14 title : {
15 type : 'over',
16 position:'top'
17 }
18 }
19 });
20 }
21 });
22 },
23 createControl : function(n, cm) {
24 return null;
25 },
26 getInfo : function() {
27 return {
28 longname : "List Group Shortcode",
29 author : 'Oscitas Themes',
30 authorurl : 'http://www.oscitasthemes.com/',
31 infourl : 'http://www.oscitasthemes.com/',
32 version : "2.0.0"
33 };
34 }
35 });
36 tinymce.PluginManager.add('oscitaslists', tinymce.plugins.oscitasLists);
37 })();
38
39 function create_oscitas_lists(){
40 if(jQuery('#oscitas-form-lists').length){
41 jQuery('#oscitas-form-lists').remove();
42 }
43 // creates a form to be displayed everytime the button is clicked
44 // you should achieve this using AJAX instead of direct html code like this
45 var form = jQuery('<div id="oscitas-form-lists" class="oscitas-container"><table id="oscitas-table" class="form-table">\
46 <tr>\
47 <th><label for="oscitas-type">Lists style</label></th>\
48 <td><select name="type" id="oscitas-type">\
49 <option value="">None</option>\
50 <option value="glyphicon-arrow-right">Arrow</option>\
51 <option value="glyphicon-ok">Check</option>\
52 <option value="glyphicon-plus">Plus</option>\
53 <option value="glyphicon-minus">Minus</option>\
54 </select><br />\
55 </td>\
56 </tr>\
57 <tr>\
58 <th><label for="oscitas-line">No of List Item</label></th>\
59 <td><input type="text" name="line" id="oscitas-list-item" value="3"/><br /><small>Enter a numeric value</small>\
60 </td>\
61 </tr>\
62 <tr>\
63 <th><label for="oscitas-list-class">Custom Class:</label></th>\
64 <td><input type="text" name="line" id="oscitas-list-class" value=""/><br />\
65 </td>\
66 </tr>\
67 </table>\
68 <p class="submit">\
69 <input type="button" id="oscitas-submit" class="button-primary" value="Insert List" name="submit" />\
70 </p>\
71 </div>');
72
73 var table = form.find('table');
74 form.appendTo('body').hide();
75
76 // handles the click event of the submit button
77 form.find('#oscitas-submit').click(function(){
78 // defines the options and their default values
79 // again, this is not the most elegant way to do this
80 // but well, this gets the job done nonetheless
81 var options = {
82 'type' : 'arrow'
83 },list=0,list_type;
84 var cusclass='';
85 if(table.find('#oscitas-list-class').val()!=''){
86 cusclass= ' class="'+table.find('#oscitas-list-class').val()+'"';
87 }
88 var shortcode = '[list'+cusclass;
89 var list_item=jQuery('#oscitas-list-item').val();
90 if(isNaN(list_item)==false){
91 list=list_item;
92 } else{
93 list=3;
94 }
95
96
97 shortcode += ']<br/>';
98 if(table.find('#oscitas-type').val()!=''){
99 list_type=' type="'+table.find('#oscitas-type').val()+'"';
100 }
101 else{
102 list_type='';
103 }
104 for(var i=1;i<=list;i++){
105 shortcode +='[li'+list_type+']your list content[/li]<br/>'
106 }
107 shortcode +='[/list]';
108
109 // inserts the shortcode into the active editor
110 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
111
112 jQuery.fancybox.close();
113 });
114 }
115
116