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 / tooltip / tooltip_plugin.js

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

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