PluginProbe ʕ •ᴥ•ʔ
Image Widget / 4.0.5
Image Widget v4.0.5
trunk 1.0 2.0 2.1 2.2 2.2.1 2.2.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.2 3.2.1 3.2.10 3.2.11 3.2.2 3.2.3 3.2.4 3.2.5 3.2.7 3.2.8 3.2.9 3.3 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1 4.1.1 4.1.2 4.2 4.2.1 4.2.2 4.3 4.3.1 4.4 4.4.1 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9
image-widget / resources / js / image-widget.deprecated.js
image-widget / resources / js Last commit date
image-widget.deprecated.js 13 years ago image-widget.deprecated.upload-fixer.js 13 years ago image-widget.js 13 years ago
image-widget.deprecated.js
123 lines
1 var imageWidget;
2
3 (function($){
4
5 imageWidget = {
6
7 sendToEditor : function(h) {
8 // ignore content returned from media uploader and use variables passed to window instead
9
10 // store attachment id in hidden field
11 $( '#widget-'+self.IW_instance+'-image' ).val( self.IW_img_id );
12
13 // display attachment preview
14 $( '#display-widget-'+self.IW_instance+'-image' ).html( self.IW_html );
15
16 // change width & height fields in widget to match image
17 $( '#widget-'+self.IW_instance+'-width' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('width'));
18 $( '#widget-'+self.IW_instance+'-height' ).val($( '#display-widget-'+self.IW_instance+'-image img').attr('height'));
19
20 // set alignment in widget
21 $( '#widget-'+self.IW_instance+'-align' ).val(self.IW_align);
22
23 // set title in widget
24 $( '#widget-'+self.IW_instance+'-title' ).val(self.IW_title);
25
26 // set caption in widget
27 $( '#widget-'+self.IW_instance+'-description' ).val(self.IW_caption);
28
29 // set alt text in widget
30 $( '#widget-'+self.IW_instance+'-alt' ).val(self.IW_alt);
31
32 // set link in widget
33 $( '#widget-'+self.IW_instance+'-link' ).val(self.IW_url);
34
35 // close thickbox
36 tb_remove();
37
38 // change button text
39 $('#add_image-widget-'+self.IW_instance+'-image').html($('#add_image-widget-'+self.IW_instance+'-image').html().replace(/Add Image/g, 'Change Image'));
40 },
41
42 changeImgWidth : function(instance) {
43 var width = $( '#widget-'+instance+'-width' ).val();
44 var height = Math.round(width / imageWidget.imgRatio(instance));
45 imageWidget.changeImgSize(instance,width,height);
46 },
47
48 changeImgHeight : function(instance) {
49 var height = $( '#widget-'+instance+'-height' ).val();
50 var width = Math.round(height * imageWidget.imgRatio(instance));
51 imageWidget.changeImgSize(instance,width,height);
52 },
53
54 imgRatio : function(instance) {
55 var width_old = $( '#display-widget-'+instance+'-image img').attr('width');
56 var height_old = $( '#display-widget-'+instance+'-image img').attr('height');
57 var ratio = width_old / height_old;
58 return ratio;
59 },
60
61 changeImgSize : function(instance,width,height) {
62 if (isNaN(width) || width < 1) {
63 $( '#widget-'+instance+'-width' ).val('');
64 width = 'none';
65 } else {
66 $( '#widget-'+instance+'-width' ).val(width);
67 width = width + 'px';
68 }
69 $( '#display-widget-'+instance+'-image img' ).css({
70 'width':width
71 });
72
73 if (isNaN(height) || height < 1) {
74 $( '#widget-'+instance+'-height' ).val('');
75 height = 'none';
76 } else {
77 $( '#widget-'+instance+'-height' ).val(height);
78 height = height + 'px';
79 }
80 $( '#display-widget-'+instance+'-image img' ).css({
81 'height':height
82 });
83 },
84
85 changeImgAlign : function(instance) {
86 var align = $( '#widget-'+instance+'-align' ).val();
87 $( '#display-widget-'+instance+'-image img' ).attr(
88 'class', (align == 'none' ? '' : 'align'+align)
89 );
90 },
91
92 imgHandler : function(event) {
93 event.preventDefault();
94 window.send_to_editor = imageWidget.sendToEditor;
95 tb_show("Add an Image", event.target.href, false);
96 },
97
98 setActiveWidget : function(instance_id) {
99 self.IW_instance = instance_id;
100 }
101
102 };
103
104 $(document).ready(function() {
105 // Use new style event handling since $.fn.live() will be deprecated
106 if ( typeof $.fn.on !== 'undefined' ) {
107 $("#wpbody").on("click", ".thickbox-image-widget", imageWidget.imgHandler);
108 }
109 else {
110 $("a.thickbox-image-widget").live('click', imageWidget.imgHandler);
111 }
112
113 // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
114 $('a.thickbox-image-widget').each( function() {
115 var href = $(this).attr('href'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width;
116 if ( ! href ) return;
117 href = href.replace(/&width=[0-9]+/g, '');
118 href = href.replace(/&height=[0-9]+/g, '');
119 $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
120 });
121 });
122
123 })(jQuery);