PluginProbe ʕ •ᴥ•ʔ
Image Widget / 3.2
Image Widget v3.2
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
lang 16 years ago views 15 years ago image-widget.js 16 years ago image-widget.php 15 years ago readme.txt 15 years ago screenshot-1.png 16 years ago screenshot-2.png 16 years ago screenshot-3.png 16 years ago
image-widget.js
104 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_caption);
26
27 // set alt text in widget
28 jQuery( '#widget-'+self.IW_instance+'-alt' ).val(self.IW_alt);
29
30 // set link in widget
31 jQuery( '#widget-'+self.IW_instance+'-link' ).val(self.IW_url);
32
33 // close thickbox
34 tb_remove();
35
36 // change button text
37 jQuery('#add_image-widget-'+self.IW_instance+'-image').html(jQuery('#add_image-widget-'+self.IW_instance+'-image').html().replace(/Add Image/g, 'Change Image'));
38 }
39
40 function changeImgWidth(instance) {
41 var width = jQuery( '#widget-'+instance+'-width' ).val();
42 var height = Math.round(width / imgRatio(instance));
43 changeImgSize(instance,width,height);
44 }
45
46 function changeImgHeight(instance) {
47 var height = jQuery( '#widget-'+instance+'-height' ).val();
48 var width = Math.round(height * imgRatio(instance));
49 changeImgSize(instance,width,height);
50 }
51
52 function imgRatio(instance) {
53 var width_old = jQuery( '#display-widget-'+instance+'-image img').attr('width');
54 var height_old = jQuery( '#display-widget-'+instance+'-image img').attr('height');
55 var ratio = width_old / height_old;
56 return ratio;
57 }
58
59 function changeImgSize(instance,width,height) {
60 if (isNaN(width) || width < 1) {
61 jQuery( '#widget-'+instance+'-width' ).val('');
62 width = 'none';
63 } else {
64 jQuery( '#widget-'+instance+'-width' ).val(width);
65 width = width + 'px';
66 }
67 jQuery( '#display-widget-'+instance+'-image img' ).css({
68 'width':width
69 });
70
71 if (isNaN(height) || height < 1) {
72 jQuery( '#widget-'+instance+'-height' ).val('');
73 height = 'none';
74 } else {
75 jQuery( '#widget-'+instance+'-height' ).val(height);
76 height = height + 'px';
77 }
78 jQuery( '#display-widget-'+instance+'-image img' ).css({
79 'height':height
80 });
81 }
82
83 function changeImgAlign(instance) {
84 var align = jQuery( '#widget-'+instance+'-align' ).val();
85 jQuery( '#display-widget-'+instance+'-image img' ).attr(
86 'class', (align == 'none' ? '' : 'align'+align)
87 );
88 }
89
90 jQuery(document).ready(function() {
91 jQuery("body").click(function(event) {
92 if (jQuery(event.target).is('a.thickbox-image-widget')) {
93 tb_show("Add an Image", event.target.href, false);
94 }
95 });
96 // Modify thickbox link to fit window. Adapted from wp-admin\js\media-upload.dev.js.
97 jQuery('a.thickbox-image-widget').each( function() {
98 var href = jQuery(this).attr('href'), width = jQuery(window).width(), H = jQuery(window).height(), W = ( 720 < width ) ? 720 : width;
99 if ( ! href ) return;
100 href = href.replace(/&width=[0-9]+/g, '');
101 href = href.replace(/&height=[0-9]+/g, '');
102 jQuery(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
103 });
104 });