PluginProbe
Easy Bootstrap Shortcode / 3.7
Easy Bootstrap Shortcode v3.7
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 3.7, at shortcode/image/image_plugin.js

125 lines 4.6 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.oscitasImage', {
3 init : function(ed, url) {
4 ed.addButton('oscitasimage', {
5 title : 'Image Effects Shortcode',
6 image : url+'/icon.png',
7 onclick : function() {
8 create_oscitas_image();
9 jQuery.fancybox({
10 'type' : 'inline',
11 'title' : 'Image Effects Shortcode',
12 'href' : '#oscitas-form-image',
13 helpers: {
14 title : {
15 type : 'over',
16 position:'top'
17 }
18 }
19
20 });
21 }
22 });
23 },
24 createControl : function(n, cm) {
25 return null;
26 },
27 getInfo : function() {
28 return {
29 longname : "Image Effects Shortcode",
30 author : 'Oscitas Themes',
31 authorurl : 'http://www.oscitasthemes.com/',
32 infourl : 'http://www.oscitasthemes.com/',
33 version : "2.0.0"
34 };
35 }
36 });
37 tinymce.PluginManager.add('oscitasimage', tinymce.plugins.oscitasImage);
38 })();
39
40 function create_oscitas_image(){
41 if(jQuery('#oscitas-form-image').length){
42 jQuery('#oscitas-form-image').remove();
43 }
44 // creates a form to be displayed everytime the button is clicked
45 // you should achieve this using AJAX instead of direct html code like this
46 var form = jQuery('<div id="oscitas-form-image" class="oscitas-container"><table id="oscitas-table" class="form-table">\
47 <th><label for="oscitas-label-content">Upload Image:</label></th>\
48 <td id="osc_image_upload"><input id="oscitas-image-src" type="hidden" name="oscitas-thumbnail-src" value="" />\
49 <input id="_btn" class="upload_image_button" type="button" value="Upload Image" />\
50 </td>\
51 </tr>\
52 <tr>\
53 <th><label for="oscitas-image-shape">Image Shape:</label></th>\
54 <td><select name="oscitas-image-shape" id="oscitas-image-shape">\
55 <option value="img-rounded">Rounded</option>\
56 <option value="img-circle">Circle</option>\
57 <option value="img-thumbnail">Thumbnail</option>\
58 </select>\
59 </td>\
60 </tr>\
61 <tr>\
62 <th><label for="oscitas-image-class">Custom Class:</label></th>\
63 <td><input type="text" name="line" id="oscitas-image-class" value=""/><br />\
64 </td>\
65 </tr>\
66 </table>\
67 <p class="submit">\
68 <input type="button" id="oscitas-image-submit" class="button-primary" value="Insert Image" name="submit" />\
69 </p>\
70 </div>');
71
72 var table = form.find('table');
73 form.appendTo('body').hide();
74
75
76 form.find('.upload_image_button').click(function() {
77 jQuery('.fancybox-overlay').css('z-index',100);
78 jQuery('html').addClass('Image');
79 formfield = jQuery(this).prev().attr('id');
80 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
81 return false;
82 });
83
84 window.original_send_to_editor = window.send_to_editor;
85
86 window.send_to_editor = function(html) {
87 if (formfield) {
88 if (jQuery(html).find('img').length) {
89 fileurl = jQuery('img', html).attr('src');
90 } else if (jQuery(html).attr('src')) {
91 fileurl = jQuery(html).attr('src');
92 }
93 jQuery('#' + formfield).val(fileurl);
94 tb_remove();
95 form.find('#osc_image_upload img').remove();
96 form.find('#osc_image_upload').append('<img src="'+fileurl+'">')
97 jQuery('html').removeClass('Image');
98
99 } else {
100 window.original_send_to_editor(html);
101 }
102
103 };
104
105
106 // handles the click event of the submit button
107 form.find('#oscitas-image-submit').click(function(){
108 var shortcode='';
109 var shape=form.find('#oscitas-image-shape').val();
110 var cusclass='';
111 if(table.find('#oscitas-image-class').val()!=''){
112 cusclass= ' class="'+table.find('#oscitas-image-class').val()+'"';
113 }
114 if(form.find('#oscitas-image-src').val()!=''){
115 shortcode = '[image'+cusclass+' src="'+form.find('#oscitas-image-src').val()+'" shape="'+shape+'"]';
116 }
117 // inserts the shortcode into the active editor
118 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
119
120 // closes fancybox
121 jQuery.fancybox.close();
122 });
123 }
124
125