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 / thumbnail / thumbnail_plugin.js

thumbnail_plugin.js in Easy Bootstrap Shortcode 4.4, at shortcode/thumbnail/thumbnail_plugin.js

127 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var thumbnail={
2 title:"Responsive Image Shortcode",
3 id :'oscitas-form-thumbnail',
4 pluginName: 'thumbnail'
5 };
6 (function() {
7 _create_tinyMCE_options(thumbnail);
8 })();
9
10 function ebs_return_html_thumbnail(pluginObj){
11 var form = jQuery('<div id="'+pluginObj.id+'" class="oscitas-container" title="'+pluginObj.title+'"><table id="oscitas-table" class="form-table">\
12 <th><label for="oscitas-label-content">Upload Image:</label></th>\
13 <td id="osc_thumbnail_upload"><input id="oscitas-thumbnail-src" type="hidden" name="oscitas-thumbnail-src" value="" />\
14 <input id="_btn" class="upload_image_button" type="button" value="Upload Image" />\
15 </td>\
16 </tr>\
17 <tr>\
18 <th><label for="oscitas-thumbnail-link">Alternate Text :</label></th>\
19 <td><input type="text" name="oscitas-alt-txt" id="oscitas-alt-txt" value=""/><br />\
20 </td>\
21 </tr>\
22 <tr>\
23 <th><label for="oscitas-thumbnail-link">Link:</label></th>\
24 <td><input type="text" name="oscitas-thumbnail-link" id="oscitas-thumbnail-link" value=""/><br />\
25 </td>\
26 </tr>\
27 <tr>\
28 <th><label for="oscitas-thumbnail-link">Target:</label></th>\
29 <td><select name="oscitas-thumbnail-link-target" id="oscitas-thumbnail-link-target"><option value="_self">Self</option><option value="_blank">New Window</option></select><br />\
30 </td>\
31 </tr>\
32 <tr>\
33 <th><label for="oscitas-thumbnail-link">Show Border:</label></th>\
34 <td><input type="checkbox" name="oscitas-thumbnail-border" id="oscitas-thumbnail-border" value="1"/><br />\
35 </td>\
36 </tr>\
37 <tr>\
38 <th><label for="oscitas-thumbnail-class">Custom Class:</label></th>\
39 <td><input type="text" name="line" id="oscitas-thumbnail-class" value=""/><br />\
40 </td>\
41 </tr>\
42 </table>\
43 <p class="submit">\
44 <input type="button" id="oscitas-thumbnail-submit" class="button-primary" value="Insert Thumbnail" name="submit" />\
45 </p>\
46 </div>');
47
48 return form;
49 }
50
51 function create_oscitas_thumbnail(pluginObj){
52 var form=jQuery(pluginObj.hashId);
53
54
55
56 var table = form.find('table');
57
58
59
60 form.find('.upload_image_button').click(function() {
61 jQuery('body').addClass('ebs_plugin_shown_now');
62 jQuery('.ui-widget-overlay, .ui-dialog').css('z-index',100);
63 jQuery('html').addClass('Image');
64 formfield = jQuery(this).prev().attr('id');
65 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
66 return false;
67 });
68
69 window.original_send_to_editor = window.send_to_editor;
70
71 window.send_to_editor = function(html) {
72 if (formfield) {
73 if (jQuery(html).find('img').length) {
74 fileurl = jQuery('img', html).attr('src');
75 } else if (jQuery(html).attr('src')) {
76 fileurl = jQuery(html).attr('src');
77 }
78 jQuery('#' + formfield).val(fileurl);
79 tb_remove();
80 form.find('#osc_thumbnail_upload img').remove();
81 form.find('#osc_thumbnail_upload').append('<img src="'+fileurl+'">');
82 jQuery('body').removeClass('ebs_plugin_shown_now');
83 jQuery('html').removeClass('Image');
84
85 } else {
86 window.original_send_to_editor(html);
87 jQuery('body').removeClass('ebs_plugin_shown_now');
88 }
89
90 };
91
92
93 // handles the click event of the submit button
94 form.find('#oscitas-thumbnail-submit').click(function(){
95 var shortcode='';
96 var cusclass='',link='', border='',tget='', alt='';
97 if(table.find('#oscitas-thumbnail-class').val()!=''){
98 cusclass= ' class="'+table.find('#oscitas-thumbnail-class').val()+'"';
99 }
100 if(table.find('#oscitas-thumbnail-link').val()!=''){
101 link= ' link="'+form.find('#oscitas-thumbnail-link').val()+'"';
102 }
103
104 if(table.find('#oscitas-alt-txt').val()!=''){
105 alt= ' alt="'+form.find('#oscitas-alt-txt').val()+'"';
106 }
107
108 if(table.find('#oscitas-thumbnail-link-target').val()!=''){
109 tget= ' target="'+form.find('#oscitas-thumbnail-link-target').val()+'"';
110 }
111
112 if(table.find('#oscitas-thumbnail-border').is(':checked')){
113 border= ' border="1"';
114 }
115
116 if(form.find('#oscitas-thumbnail-src').val()!=''){
117 shortcode = '['+$ebs_prefix+'thumbnail'+link+cusclass+border+tget+alt+' src="'+form.find('#oscitas-thumbnail-src').val()+'"]';
118 }
119 // inserts the shortcode into the active editor
120 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
121
122 // closes Dialoguebox
123 close_dialogue(pluginObj.hashId);
124 });
125 }
126
127