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

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