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

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

116 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var tooltip={
2 title:"Tooltip Image Shortcode",
3 id :'oscitas-form-tooltip',
4 pluginName: 'tooltip'
5 };
6 (function() {
7 _create_tinyMCE_options(tooltip);
8 })();
9
10 function create_oscitas_tooltip(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-tooltip-style">Tooltip Style:</label></th>\
19 <td><select name="type" id="oscitas-tooltip-style">\
20 <option value="top">Top</option>\
21 <option value="bottom">Bottom</option>\
22 <option value="left">Left</option>\
23 <option value="right">Right</option>\
24 <option value="auto">Auto</option>\
25 </select><br />\
26 </td>\
27 </tr>\
28 <tr>\
29 <th><label for="oscitas-tooltip-text">Tooltip Text:</label></th>\
30 <td><input type="text" name="tooltip-text" id="oscitas-tooltip-text" value="Tooltip"/><br />\
31 </td>\
32 </tr>\
33 <tr>\
34 <th><label for="oscitas-tooltip-type">Type:</label></th>\
35 <td><select name="type" id="oscitas-tooltip-type">\
36 <option value="link">Link</option>\
37 <option value="button">Button</option>\
38 </select><br />\
39 </td>\
40 </tr >\
41 <tr id="oscitas-tooltip-link-tr">\
42 <th><label for="oscitas-tooltip-link">Link:</label></th>\
43 <td><input type="text" name="tooltip-link" id="oscitas-tooltip-link" value="#"/><br />\
44 </td>\
45 </tr>\
46 <tr>\
47 <th><label for="oscitas-tooltip-link-text">Value:</label></th>\
48 <td><input type="text" name="link-text" id="oscitas-tooltip-link-text" value="Hover Me"/><br />\
49 </td>\
50 </tr>\
51 <tr>\
52 <th><label for="oscitas-tooltip-class">Custom Class:</label></th>\
53 <td><input type="text" name="line" id="oscitas-tooltip-class" value=""/><br />\
54 </td>\
55 </tr>\
56 </table>\
57 <p class="submit">\
58 <input type="button" id="oscitas-tooltip-submit" class="button-primary" value="Insert Tooltip" name="submit" />\
59 </p>\
60 </div>');
61
62 var table = form.find('table');
63 form.appendTo('body').hide();
64 var colors = ['color', 'bgcolor'];
65
66 form.find('#oscitas-tooltip-type').change(function(){
67 if(jQuery(this).val()=='link'){
68 table.find('#oscitas-tooltip-link-tr').show();
69 table.find('#oscitas-tooltip-link').val('#');
70 } else{
71 table.find('#oscitas-tooltip-link-tr').hide();
72 table.find('#oscitas-tooltip-link').val('');
73 }
74 jQuery(this).parents('#oscitas-table').find('tr:visible:even').css('background', '#F0F0F0');
75 jQuery(this).parents('#oscitas-table').find('tr:visible:odd').css('background', '#DADADD');
76 })
77
78 // handles the click event of the submit button
79 form.find('#oscitas-tooltip-submit').click(function() {
80 // defines the options and their default values
81 // again, this is not the most elegant way to do this
82 // but well, this gets the job done nonetheless
83 var cusclass='';
84 if(table.find('#oscitas-tooltip-class').val()!=''){
85 cusclass= ' class="'+table.find('#oscitas-tooltip-class').val()+'"';
86 }
87 var shortcode = '[tooltip';
88 shortcode += ' type="' + table.find('#oscitas-tooltip-type').val();
89
90 shortcode += '" ';
91
92 shortcode += ' link="' + table.find('#oscitas-tooltip-link').val();
93
94 shortcode += '" ';
95 shortcode += ' tooltip="' + table.find('#oscitas-tooltip-text').val();
96
97 shortcode += '" ';
98 shortcode += ' style="' + table.find('#oscitas-tooltip-style').val();
99
100 shortcode += '" ';
101
102 shortcode += cusclass;
103
104 shortcode += ']';
105 shortcode+= table.find('#oscitas-tooltip-link-text').val();
106 shortcode+='[/tooltip]';
107
108 // inserts the shortcode into the active editor
109 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
110
111 // closes fancybox
112 close_dialogue(pluginObj.hashId);
113 });
114 }
115
116