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

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

133 lines 4.9 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.oscitasThumbnail', {
3 init : function(ed, url) {
4 ed.addButton('oscitasthumbnail', {
5 title : 'Responsive Image Shortcode',
6 image : url+'/icon.png',
7 onclick : function() {
8 create_oscitas_thumbnail();
9 jQuery.fancybox({
10 'type' : 'inline',
11 'title' : 'Responsive Image Shortcode',
12 'href' : '#oscitas-form-thumbnail',
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 : "Responsive Image 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('oscitasthumbnail', tinymce.plugins.oscitasThumbnail);
38 })();
39
40 function create_oscitas_thumbnail(){
41 if(jQuery('#oscitas-form-thumbnail').length){
42 jQuery('#oscitas-form-thumbnail').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-thumbnail" 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_thumbnail_upload"><input id="oscitas-thumbnail-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-thumbnail-link">Link:</label></th>\
54 <td><input type="text" name="oscitas-thumbnail-link" id="oscitas-thumbnail-link" value=""/><br />\
55 </td>\
56 </tr>\
57 <tr>\
58 <th><label for="oscitas-thumbnail-link">Show Border:</label></th>\
59 <td><input type="checkbox" name="oscitas-thumbnail-border" id="oscitas-thumbnail-border" value="1"/><br />\
60 </td>\
61 </tr>\
62 <tr>\
63 <th><label for="oscitas-thumbnail-class">Custom Class:</label></th>\
64 <td><input type="text" name="line" id="oscitas-thumbnail-class" value=""/><br />\
65 </td>\
66 </tr>\
67 </table>\
68 <p class="submit">\
69 <input type="button" id="oscitas-thumbnail-submit" class="button-primary" value="Insert Thumbnail" name="submit" />\
70 </p>\
71 </div>');
72
73 var table = form.find('table');
74 form.appendTo('body').hide();
75
76
77 form.find('.upload_image_button').click(function() {
78 jQuery('.fancybox-overlay').css('z-index',100);
79 jQuery('html').addClass('Image');
80 formfield = jQuery(this).prev().attr('id');
81 tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
82 return false;
83 });
84
85 window.original_send_to_editor = window.send_to_editor;
86
87 window.send_to_editor = function(html) {
88 if (formfield) {
89 if (jQuery(html).find('img').length) {
90 fileurl = jQuery('img', html).attr('src');
91 } else if (jQuery(html).attr('src')) {
92 fileurl = jQuery(html).attr('src');
93 }
94 jQuery('#' + formfield).val(fileurl);
95 tb_remove();
96 form.find('#osc_thumbnail_upload img').remove();
97 form.find('#osc_thumbnail_upload').append('<img src="'+fileurl+'">')
98 jQuery('html').removeClass('Image');
99
100 } else {
101 window.original_send_to_editor(html);
102 }
103
104 };
105
106
107 // handles the click event of the submit button
108 form.find('#oscitas-thumbnail-submit').click(function(){
109 var shortcode='';
110 var cusclass='',link='', border='';
111 if(table.find('#oscitas-thumbnail-class').val()!=''){
112 cusclass= ' class="'+table.find('#oscitas-thumbnail-class').val()+'"';
113 }
114 if(table.find('#oscitas-thumbnail-class').val()!=''){
115 link= ' link="'+form.find('#oscitas-thumbnail-link').val()+'"';
116 }
117
118 if(table.find('#oscitas-thumbnail-border').is(':checked')){
119 border= ' border="1"';
120 }
121
122 if(form.find('#oscitas-thumbnail-src').val()!=''){
123 shortcode = '[thumbnail'+link+cusclass+border+' src="'+form.find('#oscitas-thumbnail-src').val()+'"]';
124 }
125 // inserts the shortcode into the active editor
126 tinyMCE.activeEditor.execCommand('mceInsertContent', 0, shortcode);
127
128 // closes fancybox
129 jQuery.fancybox.close();
130 });
131 }
132
133