PluginProbe
Easy Bootstrap Shortcode / 4.4
Easy Bootstrap Shortcode v4.4
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 / notifications / notifications_plugin.js

notifications_plugin.js in Easy Bootstrap Shortcode 4.4, at shortcode/notifications/notifications_plugin.js

80 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var notifications={
2 title:"Notifications Shortcode",
3 id :'oscitas-form-notifications',
4 pluginName: 'notifications'
5 };
6 (function() {
7 _create_tinyMCE_options(notifications);
8 })();
9
10 function ebs_return_html_notifications(pluginObj){
11 var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table">\
12 <tr>\
13 <th><label for="oscitas-type">Style :</label></th>\
14 <td><select name="type" id="oscitas-type">\
15 <option value="alert-warning">Warning</option>\
16 <option value="alert-success">Success</option>\
17 <option value="alert-info">Information</option>\
18 <option value="alert-danger">Danger</option>\
19 </select><br />\
20 </td>\
21 </tr>\
22 <tr>\
23 <th><label for="oscitas-line">Close link</label></th>\
24 <td><input type="checkbox" id="oscitas-close"/><br />\
25 </td>\
26 </tr>\
27 <tr>\
28 <th><label for="oscitas-note-class">Custom Class:</label></th>\
29 <td><input type="text" name="line" id="oscitas-note-class" value=""/><br />\
30 </td>\
31 </tr>\
32 </table>\
33 <p class="submit">\
34 <input type="button" id="oscitas-submit" class="button-primary" value="Insert Notification" name="submit" />\
35 </p>\
36 </div>');
37 return form;
38 }
39 function create_oscitas_notifications(pluginObj){
40 var form=jQuery(pluginObj.hashId);
41 var table = form.find('table');
42
43
44 // handles the click event of the submit button
45 form.find('#oscitas-submit').click(function(){
46 // defines the options and their default values
47 // again, this is not the most elegant way to do this
48 // but well, this gets the job done nonetheless
49 var options = {
50 'type' : 'error'
51 };
52 var cusclass='';
53 if(table.find('#oscitas-note-class').val()!=''){
54 cusclass= ' class="'+table.find('#oscitas-note-class').val()+'"';
55 }
56 var shortcode = '['+$ebs_prefix+'notification';
57
58 for( var index in options) {
59 var value = table.find('#oscitas-' + index).val();
60
61 // attaches the attribute to the shortcode only if it's different from the default value
62 //if ( value !== options[index] )
63 shortcode += ' ' + index + '="' + value + '"';
64 }
65
66 var selected_content = tinyMCE.activeEditor.selection.getContent();
67 if(!selected_content)
68 var selected_content = 'Your notification';
69 shortcode += ' close="'+(table.find('#oscitas-close').prop('checked')? 'true': 'false')+ '" ';
70
71 shortcode += cusclass+']'+selected_content+'[/'+$ebs_prefix+'notification]';
72
73 // inserts the shortcode into the active editor
74 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
75
76 close_dialogue(pluginObj.hashId);
77 });
78 }
79
80