PluginProbe ʕ •ᴥ•ʔ
Image Widget / 3.0.5
Image Widget v3.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 / image-widget.js
image-widget Last commit date
image-widget.js 16 years ago image-widget.php 16 years ago readme.txt 16 years ago screenshot-1.png 16 years ago
image-widget.js
101 lines
1 function set_active_widget(instance_id) {
2 self.IW_instance = instance_id;
3 }
4
5 function send_to_editor(h) {
6 // ignore content returned from media uploader and use variables passed to window instead
7
8 // store attachment id in hidden field
9 jQuery( '#widget-'+self.IW_instance+'-image' ).val( self.IW_img_id );
10
11 // display attachment preview
12 jQuery( '#display-widget-'+self.IW_instance+'-image' ).html( self.IW_html );
13
14 // change width & height fields in widget to match image
15 jQuery( '#widget-'+self.IW_instance+'-width' ).val(jQuery( '#display-widget-'+self.IW_instance+'-image img').attr('width'));
16 jQuery( '#widget-'+self.IW_instance+'-height' ).val(jQuery( '#display-widget-'+self.IW_instance+'-image img').attr('height'));
17
18 // set alignment in widget
19 jQuery( '#widget-'+self.IW_instance+'-align' ).val(self.IW_align);
20
21 // set title in widget
22 jQuery( '#widget-'+self.IW_instance+'-title' ).val(self.IW_title);
23
24 // set caption in widget
25 jQuery( '#widget-'+self.IW_instance+'-description' ).val(self.IW_alt);
26
27 // set link in widget
28 jQuery( '#widget-'+self.IW_instance+'-link' ).val(self.IW_url);
29
30 // close thickbox
31 tb_remove();
32
33 // change button text
34 jQuery('#add_image-widget-'+self.IW_instance+'-image').html(jQuery('#add_image-widget-'+self.IW_instance+'-image').html().replace(/Add Image/g, 'Change Image'));
35 }
36
37 function changeImgWidth(instance) {
38 var width = jQuery( '#widget-'+instance+'-width' ).val();
39 var height = Math.round(width / imgRatio(instance));
40 changeImgSize(instance,width,height);
41 }
42
43 function changeImgHeight(instance) {
44 var height = jQuery( '#widget-'+instance+'-height' ).val();
45 var width = Math.round(height * imgRatio(instance));
46 changeImgSize(instance,width,height);
47 }
48
49 function imgRatio(instance) {
50 var width_old = jQuery( '#display-widget-'+instance+'-image img').attr('width');
51 var height_old = jQuery( '#display-widget-'+instance+'-image img').attr('height');
52 var ratio = width_old / height_old;
53 return ratio;
54 }
55
56 function changeImgSize(instance,width,height) {
57 if (isNaN(width) || width < 1) {
58 jQuery( '#widget-'+instance+'-width' ).val('');
59 width = 'none';
60 } else {
61 jQuery( '#widget-'+instance+'-width' ).val(width);
62 width = width + 'px';
63 }
64 jQuery( '#display-widget-'+instance+'-image img' ).css({
65 'width':width,
66 });
67
68 if (isNaN(height) || height < 1) {
69 jQuery( '#widget-'+instance+'-height' ).val('');
70 height = 'none';
71 } else {
72 jQuery( '#widget-'+instance+'-height' ).val(height);
73 height = height + 'px';
74 }
75 jQuery( '#display-widget-'+instance+'-image img' ).css({
76 'height':height
77 });
78 }
79
80 function changeImgAlign(instance) {
81 var align = jQuery( '#widget-'+instance+'-align' ).val();
82 jQuery( '#display-widget-'+instance+'-image img' ).attr(
83 'class', (align == 'none' ? '' : 'align'+align)
84 );
85 }
86
87 jQuery(document).ready(function() {
88 jQuery("body").click(function(event) {
89 if (jQuery(event.target).is('a.thickbox-image-widget')) {
90 tb_show("Add an Image", event.target.href, false);
91 }
92 });
93 // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
94 jQuery('a.thickbox-image-widget').each( function() {
95 var href = jQuery(this).attr('href'), width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
96 if ( ! href ) return;
97 href = href.replace(/&width=[0-9]+/g, '');
98 href = href.replace(/&height=[0-9]+/g, '');
99 jQuery(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
100 });
101 });