PluginProbe
Easy Bootstrap Shortcode / 3.6
Easy Bootstrap Shortcode v3.6
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 / tooltip / tooltip_plugin.js

tooltip_plugin.js in Easy Bootstrap Shortcode 3.6, at shortcode/tooltip/tooltip_plugin.js

144 lines 5.2 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.oscitasTooltip', {
3 init: function(ed, url) {
4 ed.addButton('oscitastooltip', {
5 title: 'Tooltip Shortcode',
6 image: url + '/icon.png',
7 onclick: function() {
8 create_oscitas_tooltip();
9 jQuery.fancybox({
10 'type' : 'inline',
11 'title' : 'Tooltip Shortcode',
12 'href' : '#oscitas-form-tooltip',
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: "Tooltip 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('oscitastooltip', tinymce.plugins.oscitasTooltip);
37 })();
38
39 function create_oscitas_tooltip(){
40 if(jQuery('#oscitas-form-tooltip').length){
41 jQuery('#oscitas-form-tooltip').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-tooltip"><table id="oscitas-table" class="form-table">\
46 <tr>\
47 <th><label for="oscitas-tooltip-style">Tooltip Style:</label></th>\
48 <td><select name="type" id="oscitas-tooltip-style">\
49 <option value="top">Top</option>\
50 <option value="bottom">Bottom</option>\
51 <option value="left">Left</option>\
52 <option value="right">Right</option>\
53 <option value="auto">Auto</option>\
54 </select><br />\
55 </td>\
56 </tr>\
57 <tr>\
58 <th><label for="oscitas-tooltip-text">Tooltip Text:</label></th>\
59 <td><input type="text" name="tooltip-text" id="oscitas-tooltip-text" value="Tooltip"/><br />\
60 </td>\
61 </tr>\
62 <tr>\
63 <th><label for="oscitas-tooltip-type">Type:</label></th>\
64 <td><select name="type" id="oscitas-tooltip-type">\
65 <option value="link">Link</option>\
66 <option value="button">Button</option>\
67 </select><br />\
68 </td>\
69 </tr >\
70 <tr id="oscitas-tooltip-link-tr">\
71 <th><label for="oscitas-tooltip-link">Link:</label></th>\
72 <td><input type="text" name="tooltip-link" id="oscitas-tooltip-link" value="#"/><br />\
73 </td>\
74 </tr>\
75 <tr>\
76 <th><label for="oscitas-tooltip-link-text">Value:</label></th>\
77 <td><input type="text" name="link-text" id="oscitas-tooltip-link-text" value="Hover Me"/><br />\
78 </td>\
79 </tr>\
80 <tr>\
81 <th><label for="oscitas-tooltip-class">Custom Class:</label></th>\
82 <td><input type="text" name="line" id="oscitas-tooltip-class" value=""/><br />\
83 </td>\
84 </tr>\
85 </table>\
86 <p class="submit">\
87 <input type="button" id="oscitas-tooltip-submit" class="button-primary" value="Insert Tooltip" name="submit" />\
88 </p>\
89 </div>');
90
91 var table = form.find('table');
92 form.appendTo('body').hide();
93 var colors = ['color', 'bgcolor'];
94
95 form.find('#oscitas-tooltip-type').change(function(){
96 if(jQuery(this).val()=='link'){
97 table.find('#oscitas-tooltip-link-tr').show();
98 table.find('#oscitas-tooltip-link').val('#');
99 } else{
100 table.find('#oscitas-tooltip-link-tr').hide();
101 table.find('#oscitas-tooltip-link').val('');
102
103 }
104 jQuery('#oscitas-table tr:visible:even').css('background', '#F0F0F0');
105 jQuery('#oscitas-table tr:visible:odd').css('background', '#DADADD');
106 })
107
108 // handles the click event of the submit button
109 form.find('#oscitas-tooltip-submit').click(function() {
110 // defines the options and their default values
111 // again, this is not the most elegant way to do this
112 // but well, this gets the job done nonetheless
113 var cusclass='';
114 if(table.find('#oscitas-tooltip-class').val()!=''){
115 cusclass= ' class="'+table.find('#oscitas-tooltip-class').val()+'"';
116 }
117 var shortcode = '[tooltip';
118 shortcode += ' type="' + table.find('#oscitas-tooltip-type').val();
119
120 shortcode += '" ';
121
122 shortcode += ' link="' + table.find('#oscitas-tooltip-link').val();
123
124 shortcode += '" ';
125 shortcode += ' tooltip="' + table.find('#oscitas-tooltip-text').val();
126
127 shortcode += '" ';
128 shortcode += ' style="' + table.find('#oscitas-tooltip-style').val();
129
130 shortcode += cusclass;
131
132 shortcode += ']';
133 shortcode+= table.find('#oscitas-tooltip-link-text').val();
134 shortcode+='[/tooltip]';
135
136 // inserts the shortcode into the active editor
137 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
138
139 // closes fancybox
140 jQuery.fancybox.close();
141 });
142 }
143
144