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 / image / image_plugin.js

image_plugin.js in Easy Bootstrap Shortcode 2.5, at shortcode/image/image_plugin.js

95 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 var image={
2 title:"Image Effects Shortcode",
3 id :'oscitas-form-image',
4 pluginName: 'image'
5 };
6 (function() {
7 _create_tinyMCE_options(image);
8 })();
9
10 function create_oscitas_image(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><th><label for="oscitas-label-content">Upload Image:</label></th>\
18 <td id="osc_image_upload"><input id="oscitas-image-src" type="hidden" name="oscitas-thumbnail-src" value="" />\
19 <input id="_btn" class="upload_image_button" type="button" value="Upload Image" />\
20 </td>\
21 </tr>\
22 <tr>\
23 <th><label for="oscitas-image-shape">Image Shape:</label></th>\
24 <td><select name="oscitas-image-shape" id="oscitas-image-shape">\
25 <option value="img-rounded">Rounded</option>\
26 <option value="img-circle">Circle</option>\
27 <option value="img-thumbnail">Thumbnail</option>\
28 </select>\
29 </td>\
30 </tr>\
31 <tr>\
32 <th><label for="oscitas-image-class">Custom Class:</label></th>\
33 <td><input type="text" name="line" id="oscitas-image-class" value=""/><br />\
34 </td>\
35 </tr>\
36 </table>\
37 <p class="submit">\
38 <input type="button" id="oscitas-image-submit" class="button-primary" value="Insert Image" name="submit" />\
39 </p>\
40 </div>');
41
42 var table = form.find('table');
43 form.appendTo('body').hide();
44
45
46 form.find('.upload_image_button').click(function() {
47 jQuery('.ui-widget-overlay, .ui-dialog').css('z-index',100);
48 jQuery('html').addClass('Image');
49 formfield = jQuery(this).prev().attr('id');
50 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
51 return false;
52 });
53
54 window.original_send_to_editor = window.send_to_editor;
55
56 window.send_to_editor = function(html) {
57 if (formfield) {
58 if (jQuery(html).find('img').length) {
59 fileurl = jQuery('img', html).attr('src');
60 } else if (jQuery(html).attr('src')) {
61 fileurl = jQuery(html).attr('src');
62 }
63 jQuery('#' + formfield).val(fileurl);
64 tb_remove();
65 form.find('#osc_image_upload img').remove();
66 form.find('#osc_image_upload').append('<img src="'+fileurl+'">')
67 jQuery('html').removeClass('Image');
68
69 } else {
70 window.original_send_to_editor(html);
71 }
72
73 };
74
75
76 // handles the click event of the submit button
77 form.find('#oscitas-image-submit').click(function(){
78 var shortcode='';
79 var shape=form.find('#oscitas-image-shape').val();
80 var cusclass='';
81 if(table.find('#oscitas-image-class').val()!=''){
82 cusclass= ' class="'+table.find('#oscitas-image-class').val()+'"';
83 }
84 if(form.find('#oscitas-image-src').val()!=''){
85 shortcode = '[image'+cusclass+' src="'+form.find('#oscitas-image-src').val()+'" shape="'+shape+'"]';
86 }
87 // inserts the shortcode into the active editor
88 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
89
90 // closes Dialoguebox
91 close_dialogue(pluginObj.hashId);
92 });
93 }
94
95