Ticket #1589: FisheyeList.js.patch
| File FisheyeList.js.patch, 8.4 kB (added by werner.punz@…, 2 years ago) |
|---|
-
.
60 60 61 61 enableCrappySvgSupport: false, 62 62 63 maxNoDisplayItems:10000, //all items 64 scrollerBegin: 0, //first item beginning item 65 visibleWindow:5, 63 66 67 persist: true, // save splitter positions in a cookie 68 64 69 // 65 70 // 66 71 // … … 129 134 }, 130 135 131 136 postCreate: function(args, frag) { 137 138 if(this.persist){ 139 this.restoreState(); 140 } 141 if(this.visibleWindow > this.children.length) { 142 this.visibleWindow = this.children.length; 143 } 144 if(this.scrollerBegin > this.children.length) { 145 this.scrollerBegin = this.children.length - this.visibleWindow; 146 } 132 147 this.initializePositioning(); 133 148 134 149 // … … 141 156 // Deactivate the menu if mouse is moved off screen (doesn't work for FF?) 142 157 dojo.event.connect(document.documentElement, "onmouseout", this, "onBodyOut"); 143 158 dojo.event.connect(this, "addChild", this, "initializePositioning"); 159 160 }, 161 162 163 onRightScroll: function(ev) { 164 this.scrollerBegin = (this.scrollerBegin + this.visibleWindow < this.itemCount? (this.scrollerBegin + 1): this.scrollerBegin); 165 this.initializePositioning(); 166 144 167 }, 145 168 169 onLeftScroll: function(ev) { 170 this.scrollerBegin = (this.scrollerBegin > 0 ? (this.scrollerBegin - 1): 0); 171 this.initializePositioning(); 172 173 }, 174 175 calcScrollerEnd : function() { 176 return ((this.scrollerBegin + this.visibleWindow) > this.children.length ? 177 this.children.length : this.scrollerBegin+this.visibleWindow); 178 }, 179 146 180 initializePositioning: function(){ 181 if(this.persist){ 182 this.saveState(this); 183 } 184 185 186 147 187 this.itemCount = this.children.length; 148 188 149 this.barWidth = (this.isHorizontal ? this.itemCount : 1) * this.itemWidth; 189 var scrollerEnd = this.calcScrollerEnd(); 190 191 var barItemCount = (this.itemCount > this.maxNoDisplayItems ? this.maxNoDisplayItems: this.itemCount); 192 193 194 this.barWidth = (this.isHorizontal ? this.visibleWindow : 1) * this.itemWidth; 150 195 this.barHeight = (this.isHorizontal ? 1 : this.itemCount) * this.itemHeight; 151 196 152 197 this.totalWidth = this.proximityLeft + this.proximityRight + this.barWidth; … … 152 197 this.totalWidth = this.proximityLeft + this.proximityRight + this.barWidth; 153 198 this.totalHeight = this.proximityTop + this.proximityBottom + this.barHeight; 154 199 200 155 201 // 156 202 // calculate effect ranges for each item 157 203 // 204 for(var i=0; i<(this.scrollerBegin); i+=1) { 205 this.children[i].posX = 1000; 206 this.children[i].posY = 1000; 207 } 208 209 for(var i=scrollerEnd; i<(this.children.length); i+=1) { 210 this.children[i].posX = 1000; 211 this.children[i].posY = 1000; 212 } 158 213 159 for (var i= 0; i<this.children.length; i++){214 for (var i=this.scrollerBegin; i<scrollerEnd; i+=1){ 160 215 161 this.children[i].posX = this.itemWidth * (this.isHorizontal ? i: 0);216 this.children[i].posX = this.itemWidth * (this.isHorizontal ? (i - this.scrollerBegin) : 0); 162 217 this.children[i].posY = this.itemHeight * (this.isHorizontal ? 0 : i); 163 218 164 219 this.children[i].cenX = this.children[i].posX + (this.itemWidth / 2); … … 184 239 } 185 240 186 241 242 243 187 244 // 188 245 // create the bar 189 246 // … … 195 252 // 196 253 // position the items 197 254 // 198 for (var i=0; i<this.children.length; i++){255 for(var i=0; i<this.scrollerBegin; i+=1) { 199 256 var itm = this.children[i]; 200 257 var elm = itm.domNode; 201 elm.style.left = itm.posX + 'px'; 258 //elm.style.left = 8000 + 'px'; 259 //elm.style.top = 8000 + 'px'; 260 elm.style.visibility = "hidden"; 261 } 262 263 for(var i=scrollerEnd; i<(this.children.length); i+=1) { 264 var itm = this.children[i]; 265 var elm = itm.domNode; 266 //elm.style.left = 8000 + 'px'; 267 //elm.style.top = 8000 + 'px'; 268 elm.style.visibility = "hidden"; 269 } 270 271 272 for (var i=this.scrollerBegin; i<scrollerEnd; i+=1){ 273 var itm = this.children[i]; 274 var elm = itm.domNode; 275 elm.style.left = itm.posX + 'px'; 202 276 elm.style.top = itm.posY + 'px'; 203 277 elm.style.width = this.itemWidth + 'px'; 204 278 elm.style.height = this.itemHeight + 'px'; 205 279 elm.style.visibility = "visible"; 206 280 if ( itm.svgNode ) { 207 281 itm.svgNode.style.position = 'absolute'; 208 282 itm.svgNode.style.left = this.itemPadding+'%'; … … 279 353 }else{ 280 354 if (this.isOver){ 281 355 this.setDormant(e); 356 this.initializePositioning(); 282 357 } 283 358 } 284 359 }, … … 297 372 var y=this.pos.y; 298 373 299 374 if( this.itemCount <= 0 ){ return; } 375 var scrollerEnd = this.calcScrollerEnd(); 300 376 301 377 // 302 378 // figure out our main index … … 309 385 (1.0-this.timerScale)*this.itemWidth + this.timerScale*this.itemMaxWidth : 310 386 (1.0-this.timerScale)*this.itemHeight + this.timerScale*this.itemMaxHeight ; 311 387 312 var cen = ((pos - prx) / siz) - 0.5 ;388 var cen = ((pos - prx) / siz) - 0.5 + this.scrollerBegin; 313 389 var max_off_cen = (sim / siz) - 0.5; 314 390 315 391 if (max_off_cen > this.effectUnits){ max_off_cen = this.effectUnits; } … … 357 433 // set the sizes 358 434 // 359 435 360 for(var i= 0; i<this.itemCount; i++){436 for(var i=this.scrollerBegin; i<scrollerEnd; i+=1){ 361 437 362 438 var weight = this.weightAt(cen, i); 363 439 … … 371 447 // 372 448 373 449 var main_p = Math.round(cen); 450 451 452 if(main_p < this.scrollerBegin) 453 main_p = this.scrollerBegin; 454 if(cen > 0 && cen < this.scrollerBegin) 455 cen = this.scrollerBegin; 456 374 457 var offset = 0; 375 458 376 if (cen < 0){ 377 main_p = 0; 459 var scrollerEnd = this.calcScrollerEnd(); 378 460 379 }else if (cen > this.itemCount - 1){380 381 main_p = this.itemCount -1;382 461 if (cen < this.scrollerBegin){ 462 main_p = this.scrollerBegin; 463 } else if (cen > scrollerEnd - 1){ 464 main_p = scrollerEnd - 1; 383 465 }else{ 384 385 466 offset = (cen - main_p) * ((this.isHorizontal ? this.itemWidth : this.itemHeight) - this.children[main_p].sizeMain); 386 467 } 387 468 … … 406 487 this.setitemsize(p, w); 407 488 408 489 var wx = w; 409 for(var i=p; i<this.itemCount; i++){ 490 491 for(var i=p; i<this.itemCount; i+=1){ 410 492 wx = 0.8 * wx; 411 493 this.setitemsize(i, wx); 412 494 } … … 412 494 } 413 495 414 496 var wx = w; 497 415 498 for(var i=p; i>=0; i--){ 416 499 wx = 0.8 * wx; 417 500 this.setitemsize(i, wx); … … 451 534 this.children[p].domNode.style.top = y + 'px'; 452 535 453 536 this.children[p].domNode.style.left = this.children[p].usualX + 'px'; 454 537 455 538 }else{ 456 539 457 540 this.children[p].sizeW = w; … … 489 572 }, 490 573 491 574 positionElementsFrom: function(p, offset){ 492 493 575 var pos = 0; 576 var scrollerEnd = this.calcScrollerEnd();; 494 577 578 495 579 if (this.isHorizontal){ 496 580 pos = Math.round(this.children[p].usualX + offset); 497 581 this.children[p].domNode.style.left = pos + 'px'; … … 508 592 509 593 var bpos = pos; 510 594 511 for(var i=p-1; i>=0; i--){595 for(var y=p-1; y>=this.scrollerBegin; y-=1){ 512 596 513 bpos -= this.children[ i].sizeMain;597 bpos -= this.children[y].sizeMain; 514 598 515 599 if (this.isHorizontal){ 516 this.children[ i].domNode.style.left = bpos + 'px';600 this.children[y].domNode.style.left = bpos + 'px'; 517 601 }else{ 518 this.children[ i].domNode.style.top = bpos + 'px';602 this.children[y].domNode.style.top = bpos + 'px'; 519 603 } 520 this.positionLabel(this.children[ i]);604 this.positionLabel(this.children[y]); 521 605 } 522 606 523 607 // … … 526 610 527 611 var apos = pos; 528 612 529 for(var i=p+1; i< this.itemCount; i++){613 for(var i=p+1; i< scrollerEnd; i+=1){ 530 614 531 615 apos += this.children[i-1].sizeMain; 532 616 … … 596 680 dojo.lang.setTimeout(this, "expandSlowly", 10); 597 681 } 598 682 }, 683 684 _getCookieName: function(i) { 685 return this.widgetId + "_" + i; 686 }, 599 687 688 restoreState: function () { 689 var cookieName = this._getCookieName(0); 690 var cookieValue = dojo.io.cookie.getCookie(cookieName); 691 if(cookieValue == null) return; 692 //dojo.debug("val"+cookieValue); 693 this.scrollerBegin = parseInt(cookieValue); 694 695 }, 696 697 saveState: function (){ 698 var cookieName = this._getCookieName(0); 699 dojo.io.cookie.setCookie(cookieName,this.scrollerBegin, null, null, null, null); 700 }, 701 702 600 703 destroy: function(){ 601 704 // need to disconnect when we destroy 602 705 dojo.event.disconnect(document.documentElement, "onmouseout", this, "onBodyOut"); … … 608 711 dojo.widget.defineWidget( 609 712 "dojo.widget.FisheyeListItem", 610 713 dojo.widget.HtmlWidget, 611 { 714 { 612 715 // Constructor arguments 613 716 iconSrc: "", 614 717 svgSrc: "", … … 700 803 var scale_x = w / this.zeroWidth; 701 804 var scale_y = h / this.zeroHeight; 702 805 703 for(var i=0; i<this.svgDoc.childNodes.length; i+ +){806 for(var i=0; i<this.svgDoc.childNodes.length; i+=1){ 704 807 if (this.svgDoc.childNodes[i].setAttribute){ 705 808 this.svgDoc.childNodes[i].setAttribute( "transform", "scale("+scale_x+","+scale_y+")" ); 706 809 }