Changeset 27412
- Timestamp:
- Feb 19, 2014, 6:14:59 AM (10 years ago)
- Location:
- extensions/modus
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/modus/js/thumb.arrange.js
r26836 r27412 15 15 if (this.elements.length === 0) 16 16 this.firstThumbIndex = absIndex; 17 if (!$elt.data("w")) 18 { 19 var w=$elt.width(), h=$elt.height(); 17 var w,h; 18 19 if (! (w=$elt.data("w")) ) { 20 if ( (w=$elt[0].getAttribute("width")) && (w=parseInt(w)) ) { 21 h=parseInt($elt[0].getAttribute("height")); 22 } 23 else { 24 w=$elt.width(); 25 h=$elt.height(); 26 } 20 27 if (h > this.rowHeight) { 21 28 w = Math.round(w * this.rowHeight/h); … … 25 32 .data("h", h); 26 33 } 34 else 35 h=$elt.data("h"); 36 27 37 28 38 var eltObj = { 29 39 $elt: $elt, 30 w: $elt.data("w"),31 h: $elt.data("h")40 w: w, 41 h: h 32 42 }; 33 43 this.elements.push(eltObj); … … 166 176 167 177 reposition: function($img, imgW, imgH, liW, liH) { 168 $img.attr("width", imgW) 169 .attr("height", imgH); 178 /* JQuery .attr and .css functions add too much overhead ...*/ 179 var elt = $img[0]; 180 elt.setAttribute("width", imgW+""); 181 elt.setAttribute("height", imgH+""); 170 182 171 $img.closest("li").css( { 172 width: liW+"px", 173 height: liH+"px" 174 }); 183 elt = elt.parentNode;//a 184 elt.style.left = Math.round((liW-imgW)/2)+"px"; 185 elt.style.top = Math.round((liH-imgH)/2)+"px"; 175 186 176 $img.parent("a").css( {177 left: Math.round((liW-imgW)/2)+"px",178 top: Math.round((liH-imgH)/2)+"px"179 }); 187 elt = elt.parentNode;//li 188 elt.style.width = liW+"px"; 189 elt.style.height = liH+"px"; 190 180 191 } 181 192 -
extensions/modus/js/thumb.arrange.min.js
r26836 r27412 1 1 function RVGTLine(a,c){this.elements=[];this.margin=a;this.rowHeight=c;this.maxHeight=0} 2 RVGTLine.prototype={width:0,elementsWidth:0,firstThumbIndex:0,add:function(a,c){0===this.elements.length&&(this.firstThumbIndex=c); if(!a.data("w")){var d=a.width(),b=a.height();b>this.rowHeight&&(d=Math.round(d*this.rowHeight/b),b=this.rowHeight);a.data("w",d).data("h",b)}d={$elt:a,w:a.data("w"),h:a.data("h")};this.elements.push(d);d.h>this.maxHeight&&(this.maxHeight=d.h);this.width+=this.margin+d.w;this.elementsWidth+=d.w},clear:function(){this.elements.length&&(this.maxHeight=this.width=this.elementsWidth=3 0,this.elements.length=0)}};2 RVGTLine.prototype={width:0,elementsWidth:0,firstThumbIndex:0,add:function(a,c){0===this.elements.length&&(this.firstThumbIndex=c);var d,b;(d=a.data("w"))?b=a.data("h"):((d=a[0].getAttribute("width"))&&(d=parseInt(d))?b=parseInt(a[0].getAttribute("height")):(d=a.width(),b=a.height()),b>this.rowHeight&&(d=Math.round(d*this.rowHeight/b),b=this.rowHeight),a.data("w",d).data("h",b));d={$elt:a,w:d,h:b};this.elements.push(d);d.h>this.maxHeight&&(this.maxHeight=d.h);this.width+=this.margin+d.w;this.elementsWidth+= 3 d.w},clear:function(){this.elements.length&&(this.maxHeight=this.width=this.elementsWidth=0,this.elements.length=0)}}; 4 4 function RVGThumbs(a){this.opts=a;this.$thumbs=$("#thumbnails");if(0!=this.$thumbs.length){this.$thumbs.css("text-align","left");this.opts.extraRowHeight=0;1<window.devicePixelRatio?(a=window.devicePixelRatio,this.opts.resizeThreshold=1.01,this.opts.resizeFactor=0.95,this.opts.extraRowHeight=6,this.opts.rowHeight=Math.round(this.opts.rowHeight/a)+this.opts.extraRowHeight):(this.opts.resizeThreshold=1.1,this.opts.resizeFactor=0.8);this.process();var c=this;$(window).on("resize",function(){1<Math.abs(c.$thumbs.width()- 5 5 c.prevContainerWidth)&&c.process()}).on("RVTS_loaded",function(a,b){c.process(b&&c.$thumbs.width()==c.prevContainerWidth?c.prevLastLineFirstThumbIndex:0)});$.isReady||$(document).ready(function(){c.$thumbs.width()<c.prevContainerWidth&&c.process()})}} 6 6 RVGThumbs.prototype={prevContainerWidth:0,prevLastLineFirstThumbIndex:0,process:function(a){a=a?a:0;var c=this.$thumbs.width();this.prevContainerWidth=c;for(var d=$("li>a>img",this.$thumbs),b=new RVGTLine(this.opts.hMargin,this.opts.rowHeight);a<d.length;a++){var e=$(d[a]);b.add(e,a);b.width>=c-1*b.elements.length&&(this.processLine(b,c),b.clear())}b.elements.length&&this.processLine(b,c,!0);this.prevLastLineFirstThumbIndex=b.firstThumbIndex},processLine:function(a,c,d){var b,e,f=a.maxHeight?a.maxHeight: 7 7 a.elements[0].h;a.width/c>this.opts.resizeThreshold?(e=a.elementsWidth/(a.elementsWidth+c-a.width),b=f/(1+(e-1)*this.opts.resizeFactor),b=6*Math.round(b/6),b<f/e&&(b=Math.ceil(f/e),e=this.opts.rowHeight-this.opts.extraRowHeight-b,0<e&&6>e&&(b+=e)),b<f&&(f=b)):d&&(f=Math.min(f,this.opts.rowHeight-this.opts.extraRowHeight));c=a.width-c;d&&(c=0);for(var k=0;k<a.elements.length;k++){var h=a.elements[k];b=h.w;e=h.h;var g;g=k==a.elements.length-1?c:Math.round(c*b/a.elementsWidth);c-=g;a.elementsWidth-= 8 b;e>f&&(b=Math.round(b*f/h.h),e=f,g-=h.w-b,d&&(g=0));this.reposition(h.$elt,b,e,b-g,f)}},reposition:function(a,c,d,b,e){a .attr("width",c).attr("height",d);a.closest("li").css({width:b+"px",height:e+"px"});a.parent("a").css({left:Math.round((b-c)/2)+"px",top:Math.round((e-d)/2)+"px"})}};8 b;e>f&&(b=Math.round(b*f/h.h),e=f,g-=h.w-b,d&&(g=0));this.reposition(h.$elt,b,e,b-g,f)}},reposition:function(a,c,d,b,e){a=a[0];a.setAttribute("width",c+"");a.setAttribute("height",d+"");a=a.parentNode;a.style.left=Math.round((b-c)/2)+"px";a.style.top=Math.round((e-d)/2)+"px";a=a.parentNode;a.style.width=b+"px";a.style.height=e+"px"}}; -
extensions/modus/themeconf.inc.php
r27332 r27412 69 69 70 70 if ( ($pos=strpos($source, '<ul class="categoryActions">'))!==false || ($pos=strpos($source, '<ul class=categoryActions>'))!==false){ 71 if ( ($pos2=strpos($source, '</ul>', $pos))!==false 71 if ( ($pos2=strpos($source, '</ul>', $pos))!==false 72 72 && (substr_count($source, '<li>', $pos, $pos2-$pos) > 2) ) 73 73 $source = substr_replace($source, '<a id=albumActionsSwitcher class=pwg-button><span class="pwg-icon pwg-icon-ellipsis"></span></a>{combine_script version=1 id=\'modus.async\' path="themes/`$themeconf.id`/js/modus.async.js" load=\'async\'}', $pos, 0); … … 146 146 function modus_css_resolution($params) 147 147 { 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 148 $base = @$params['base']; 149 $min = @$params['min']; 150 $max = @$params['max']; 151 152 $rules = array(); 153 if (!empty($base)) 154 $rules[] = $base; 155 foreach(array('min','max') as $type) 156 { 157 if (!empty($$type)) 158 $rules[] = '(-webkit-'.$type.'-device-pixel-ratio:'.$$type.')'; 159 } 160 $res = implode(' and ', $rules); 161 162 $rules = array(); 163 if (!empty($base)) 164 $rules[] = $base; 165 foreach(array('min','max') as $type) 166 { 167 if (!empty($$type)) 168 $rules[] = '('.$type.'-resolution:'.round(96*$$type,1).'dpi)'; 169 } 170 $res .= ','.implode(' and ', $rules); 171 172 return $res; 173 173 } 174 174 … … 184 184 $device = get_device(); 185 185 $container_margin = 5; 186 186 187 187 if ('mobile'==$device) 188 188 { … … 224 224 } 225 225 while($csize[1]<$row_height-2 && $idx<count($candidates)); 226 226 227 227 if ($do_pop && $idx<count($candidates)) 228 228 { … … 254 254 255 255 $my_base_name = basename(dirname(__FILE__)); 256 257 256 // not async to avoid visible flickering reflow 257 $template->scriptLoader->add('modus.arange', 1, array('jquery'), 'themes/'.$my_base_name."/js/thumb.arrange.min.js", 0); 258 258 if ($do_pop) 259 259 $template->scriptLoader->add('modus.pop', 2, array('jquery'), 'themes/'.$my_base_name."/js/thumb.pop.js", 0);
Note: See TracChangeset
for help on using the changeset viewer.