Changeset 13652 for extensions/GThumb/js
- Timestamp:
- Mar 20, 2012, 11:32:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GThumb/js/gthumb.js
r12857 r13652 1 1 var GThumb = { 2 2 3 root: './',4 3 max_height: 200, 5 4 margin: 10, … … 10 9 t: new Array, 11 10 12 queue: jQuery.manageAjax.create('queued', {13 queue: true,14 cacheResponse: false,15 maxRequests: 3,16 preventDoubleRequests: false17 }),18 19 11 build: function () { 20 12 21 13 GThumb.t = new Array; 22 jQuery('#thumbnails img.thumbnail').each(function() { 23 id = parseInt(this.id.substring(2)); 14 jQuery('#thumbnails img.thumbnail').each(function(index) { 24 15 width = parseInt(jQuery(this).attr('width')); 25 16 height = parseInt(jQuery(this).attr('height')); 26 th = {i d:id,width:width,height:height,real_width:width,real_height:height};17 th = {index:index,width:width,height:height,real_width:width,real_height:height}; 27 18 if (height < GThumb.max_height) { 28 19 th.width = Math.round(GThumb.max_height * width / height); … … 30 21 } 31 22 GThumb.t.push(th); 23 }); 32 24 33 if (jQuery(this).attr('src') == '') { 34 GThumb.addToQueue(id, 1); 35 } 36 }); 25 first = GThumb.t[0]; 26 GThumb.small_thumb = {index:first.index,width:first.real_width,height:first.real_height,src:jQuery('#thumbnails img:first').attr('src')} 37 27 38 28 jQuery.resize.throttleWindow = false; 39 29 jQuery.resize.delay = 50; 40 30 GThumb.process(); 41 },42 43 addToQueue: function (id, loop) {44 45 GThumb.queue.add({46 type: 'GET',47 url: GThumb.root+'ws.php',48 data: {49 method: 'pwg.images.getGThumbPlusThumbnail',50 image_id: id,51 format: 'json'52 },53 dataType: 'json',54 success: function(data) {55 if (data.stat == 'ok') {56 jQuery('#gt'+data.result.id).prop('src', GThumb.root+data.result.src).show();57 } else if (loop < 4) {58 GThumb.addToQueue(id, ++loop);59 }60 },61 error: function() {62 if (loop < 4) GThumb.addToQueue(id, ++loop);63 }64 });65 31 }, 66 32 … … 98 64 if (line > 2) { 99 65 if (height >= best_size.height && width/height >= min_ratio && height<=GThumb.big_thumb.height) { 100 best_size = {width:width,height:height} 66 best_size = {width:width,height:height}; 101 67 } 102 68 break; … … 153 119 if (width_count > available_width) { 154 120 155 last_thumb = GThumb.t[i].i d;121 last_thumb = GThumb.t[i].index; 156 122 ratio = width_count / available_width; 157 123 new_height = Math.round(max_height / ratio); … … 161 127 for (j=0;j<thumb_process.length;j++) { 162 128 163 if (thumb_process[j].i d== last_thumb) {129 if (thumb_process[j].index == last_thumb) { 164 130 new_width = available_width - width_count - GThumb.margin; 165 131 } else { … … 168 134 new_width = Math.round(new_width); 169 135 } 170 GThumb.resize(jQuery('# gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false);136 GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, new_width, new_height, false); 171 137 172 138 width_count += new_width + GThumb.margin; … … 181 147 // Last line does not need to be cropped 182 148 for (j=0;j<thumb_process.length;j++) { 183 GThumb.resize(jQuery('# gt'+thumb_process[j].id), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false);149 GThumb.resize(jQuery('#thumbnails img.thumbnail').eq(thumb_process[j].index), thumb_process[j].real_width, thumb_process[j].real_height, thumb_process[j].width, max_height, false); 184 150 } 185 151
Note: See TracChangeset
for help on using the changeset viewer.