Author: jcrowley
Date: 2007-10-25 08:04:19 -0700 (Thu, 25 Oct 2007)
New Revision: 7007

Modified:
   openlaszlo/trunk/demos/lzpix/app.lzx
   openlaszlo/trunk/demos/lzpix/classes/favorites.lzx
   openlaszlo/trunk/demos/lzpix/classes/photo.lzx
   openlaszlo/trunk/demos/lzpix/classes/pivotlayout.lzx
   openlaszlo/trunk/demos/lzpix/classes/search.lzx
   openlaszlo/trunk/demos/lzpix/views/tools.lzx
Log:
Change 20071019-jcrowley-N by [EMAIL PROTECTED] on 2007-10-19 04:46:51 EDT
    in /Users/jcrowley/src/svn/openlaszlo/trunk-a
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Various LzPix fixes

New Features:

Bugs Fixed: LPP-4877 - LZPix, SWF7 FireFox 2.0.0.7 WXP SP2: Scrolling
        beyond 100 photos (or back from over 100) mashes counter and
        counter only incremements by one
        LPP-4876 - LZPix, SWF7 Safari 2.0.4 OSX 10.4.10: Searches
        only returning 100 photos
        LPP-4874 - LZPix, SWF7 Firefox 2.0.0.7 OSX 10.4.10: Scrolling
        backwards through found set presents photos in expanding grouping
        LPP-4873 - LZPix, SWF7 Firefox 2.0.0.7 OSX 10.4.10: Scrolling
        quickly during photo download will result in empty photo pane.

Technical Reviewer: max
QA Reviewer: ben
Doc Reviewer: 

Documentation:

Release Notes:

Details: It turns out, Flickr's data can only be loaded in pages
        of up to 100.  So when there are more than 100 results,
        it's broken up into separate XML pages that have to be
        individually requested.  So I added in a bunch of stuff
        to facilitate this, where if you get to the end of one
        list, it will request the next list when you move to the
        right.  This results in a rather insubstantial bit of
        loading time while we switch between sheets.  I added a
        text field that temporarily replaces the image counter
        in the lower right-hand side that appears during this
        loading time, to indicate that it's getting the next 100
        or previous 100 (if you're going backward).

        In doing so, I also made it so you can't scroll beyond
        the 100 in each list, which fixes one of the other bugs.

        Meanwhile, I noticed and fixed a few minor glitches while
        I was in there (like if you search for a new term, the
        search results come in starting at the image number
        where you'd left off in the previous search), and
        a couple other minor things (misplaced text, etc).

Tests: Run modified LzPix versus unmodified:

        Move beyond 100 images.  Note that new data is loaded
        after you get to the end of the first set of 100, and
        that you no longer move off into oblivion with a
        broken counter.

        Move backward from 100, and note that you move into the
        previous data.  Note that images aren't grouped together
        awkwardly as described in LPP-4874.

        Move forward to about 150.  Search for something new,
        either by using the search box or clicking on one of
        the "favorites" pictures.  Note that the image count
        resets instead of remaining where you were.



Modified: openlaszlo/trunk/demos/lzpix/app.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/app.lzx        2007-10-25 09:28:29 UTC (rev 
7006)
+++ openlaszlo/trunk/demos/lzpix/app.lzx        2007-10-25 15:04:19 UTC (rev 
7007)
@@ -244,7 +244,13 @@
                 // create a method to be called when the last photo view is 
created
                 // find out how many images there are
                 if (! this.pagecounter_dp.p) return;
-                var c = this.pagecounter_dp.p.childNodes.length;               
+                var c = this.pagecounter_dp.p.childNodes.length;
+                var currentpage = this.pagecounter_dp.xpathQuery('@page');
+                var perpage = this.pagecounter_dp.xpathQuery('@perpage');
+                var totalpages = this.pagecounter_dp.xpathQuery('@pages');
+                photoscontainer.lyt.setAttribute('currentpage', currentpage);
+                photoscontainer.lyt.setAttribute('perpage', perpage);
+                photoscontainer.lyt.setAttribute('totalpages', totalpages);
                 tls.setpPagingParams( c );
                 gResultsCountLabel.setText( this.buildResultsString(c) );      
           
                 this.watchforlast();

Modified: openlaszlo/trunk/demos/lzpix/classes/favorites.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/classes/favorites.lzx  2007-10-25 09:28:29 UTC 
(rev 7006)
+++ openlaszlo/trunk/demos/lzpix/classes/favorites.lzx  2007-10-25 15:04:19 UTC 
(rev 7007)
@@ -169,8 +169,9 @@
             <view name="interior" height="${parent.height}">
                 <favoriteslayout name="lyt" spacing="15" inset="0" 
                                  mymask="parent.parent"/>
-                <photo datapath="favoritesds:/rsp/photos/photo">
+                <photo datapath="favoritesds:/rsp/photos/photo" visible="true">
                     <method event="onclick">
+                        photoscontainer.lyt.setAttribute('currentpage', 1);
                         var id = datapath.p.getAttr("id");
                         var tag = datapath.p.getAttr("favoritetag");   
                        classroot.loadSet( tag ); 
@@ -186,6 +187,6 @@
 </library>
 <!--
 * X_LZ_COPYRIGHT_BEGIN ****************************************************
-* Copyright 2006 Laszlo Systems, Inc.  All Rights Reserved.          *
+* Copyright 2007 Laszlo Systems, Inc.  All Rights Reserved.          *
 * Use is subject to license terms.                                        *
 * X_LZ_COPYRIGHT_END ******************************************************-->

Modified: openlaszlo/trunk/demos/lzpix/classes/photo.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/classes/photo.lzx      2007-10-25 09:28:29 UTC 
(rev 7006)
+++ openlaszlo/trunk/demos/lzpix/classes/photo.lzx      2007-10-25 15:04:19 UTC 
(rev 7007)
@@ -1,7 +1,7 @@
-<!-- Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved. -->
+<!-- Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved. -->
 <library>
 
-    <class name="photo" width="77" height="77">
+    <class name="photo" width="77" height="77" visible="${!tls.waitforload}">
         <attribute name="defaultplacement" value="interior" type="text" />
         <attribute name="text" value="title" type="text" />   
 
@@ -137,7 +137,9 @@
             this.updateY( true );
             this.setAttribute( "loaded", true );
             intparent.interior.setAttribute("opacity", 0);
-            this.intparent.setVisible(true);
+            if(tls.waitforload != true){
+                this.intparent.setVisible(true);
+            }
             intparent.interior.animate('opacity', 1, 200);
         </method>
 
@@ -180,9 +182,11 @@
         
         <!-- title -->
         <text text="" width="100" fgcolor="0x1b1191" fontsize="10" 
-              name="txt">
-            <method event="ontext"  >
-                this.adjustDimensions()
+              name="txt" visible="false"><!-- Setting this initially to false
+              seems to fix a visual issue where these would cluster on the
+              upper left of the page in DHTML. -->
+            <method event="ontext">
+                this.adjustDimensions();
             </method>
             <method event="onvisible" >
                 this.adjustDimensions();
@@ -194,6 +198,9 @@
                this.setX(tx);
                this.setY(classroot.height + 3);
              </method>
+             <method name="makeVisible">
+                
+             </method>
         </text>
 
         <attribute name="doesdrag" value="false"/>

Modified: openlaszlo/trunk/demos/lzpix/classes/pivotlayout.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/classes/pivotlayout.lzx        2007-10-25 
09:28:29 UTC (rev 7006)
+++ openlaszlo/trunk/demos/lzpix/classes/pivotlayout.lzx        2007-10-25 
15:04:19 UTC (rev 7007)
@@ -1,6 +1,6 @@
 <!--
 * X_LZ_COPYRIGHT_BEGIN ****************************************************
-* Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.          *
+* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.          *
 * Use is subject to license terms.                                        *
 * X_LZ_COPYRIGHT_END ******************************************************-->
 <library>
@@ -69,7 +69,12 @@
         <attribute name="pagebegin"   value="-1" /> 
         <attribute name="pageend"     value="-1" />
         <attribute name="pagesize"    value="0" />
+        <attribute name="totalitems" value="0"/>
         
+        <attribute name="currentpage" value="1"/>
+        <attribute name="perpage" value="0"/>
+        <attribute name="totalpages" value="0"/>
+        
         <attribute name="duration"     value="0"/>
         <attribute name="calcpageparams"     value="true"/>
         
@@ -139,6 +144,12 @@
             var numinrow = Math.floor( limitwidth/( itemwidth + this.xspacing 
) );
             limitwidth = numinrow*( itemwidth + this.xspacing );
             
+            var limitheight = this.immediateparent.height;
+            var numincol = Math.floor(limitheight/(itemwidth + this.xspacing));
+            
+            // Set the total number of items possible on the page.
+            this.setAttribute('totalitems', numinrow * numincol);
+            
             // now we can calculate the row of the view that is 
subviews[pivotindex]
             var pivotrow = Math.floor( this.pivotindex/ numinrow );
             

Modified: openlaszlo/trunk/demos/lzpix/classes/search.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/classes/search.lzx     2007-10-25 09:28:29 UTC 
(rev 7006)
+++ openlaszlo/trunk/demos/lzpix/classes/search.lzx     2007-10-25 15:04:19 UTC 
(rev 7007)
@@ -1,8 +1,8 @@
-<!-- Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved. -->
 <library>
     <class name="search" >
         <attribute name="sendsearch_del" 
                    value="$once{new LzDelegate( this, 'sendsearch') }"/>
+        <attribute name="lastsearchterm" value="${null}"/>
 
         <method name="doSearch">
             if ( !canvas.isopen ) {
@@ -27,6 +27,8 @@
             resource="transparent_rsc"
             width="${parent.width}" height="${parent.height}" >
             <method event="onclick">
+                photoscontainer.lyt.setAttribute('currentpage', 1);
+                tls.resetOnLoad();
                 classroot.doSearch(); 
             </method>
         </mybutton>
@@ -44,6 +46,8 @@
             <inputtext name="txt"  width="${parent.width}" 
height="${parent.height}" y="3">       
                 <method event="onkeyup" args="k" >
                     if ( k == 13 ) { //return key
+                        photoscontainer.lyt.setAttribute('currentpage', 1);
+                        tls.resetOnLoad();
                         classroot.doSearch();
                     }
                 </method>
@@ -53,7 +57,7 @@
         <!-- Only search for photos with a creative commons license:
             http://creativecommons.org/licenses/by/2.0/
         -->
-        <method name="sendsearch" >
+        <method name="sendsearch">
             var tags = this.getText();
             var argobj;
             if (tags == "interesting") {
@@ -77,8 +81,14 @@
                     {argname:"tag_mode", argvalue:"all"},
                     {argname:"sort", argvalue:"interestingness-desc"}
                 ]
-            } 
-            gDataMan.doFlickrRequest(photods, argobj);                    
+            }
+            if(this.getText() != this.lastsearchterm){
+                photoscontainer.lyt.setAttribute('currentpage', 1);
+                tls.resetOnLoad();
+            }
+            argobj.push({argname:"page", 
argvalue:Number(photoscontainer.lyt.currentpage)});
+            this.setAttribute('lastsearchterm', this.getText());
+            gDataMan.doFlickrRequest(photods, argobj);
             //info('sendsearch', tags);
             tls.displayPage();
         </method>
@@ -101,6 +111,6 @@
 </library>
 <!--
 * X_LZ_COPYRIGHT_BEGIN ****************************************************
-* Copyright 2006 Laszlo Systems, Inc.  All Rights Reserved.          *
+* Copyright 2007 Laszlo Systems, Inc.  All Rights Reserved.          *
 * Use is subject to license terms.                                        *
 * X_LZ_COPYRIGHT_END ******************************************************-->

Modified: openlaszlo/trunk/demos/lzpix/views/tools.lzx
===================================================================
--- openlaszlo/trunk/demos/lzpix/views/tools.lzx        2007-10-25 09:28:29 UTC 
(rev 7006)
+++ openlaszlo/trunk/demos/lzpix/views/tools.lzx        2007-10-25 15:04:19 UTC 
(rev 7007)
@@ -1,6 +1,6 @@
 <!--
 * X_LZ_COPYRIGHT_BEGIN ****************************************************
-* Copyright 2001-2006 Laszlo Systems, Inc.  All Rights Reserved.          *
+* Copyright 2001-2007 Laszlo Systems, Inc.  All Rights Reserved.          *
 * Use is subject to license terms.                                        *
 * X_LZ_COPYRIGHT_END ******************************************************-->
     <view id="tls" name="tools" 
@@ -19,6 +19,8 @@
         <attribute name="nextstartindex"     value="1"/>
         <attribute name="endindex"       value="18"/>
         <attribute name="nextendindex"     value="18"/>
+        
+        <attribute name="waitforload" type="boolean" value="false"/>
 
 
         <method name="reset">
@@ -26,6 +28,15 @@
            this.endindex  = this.startindex + photoscontainer.lyt.pagesize -1;
            this.displayRange(this.startindex,this.endindex);
         </method>
+        
+        <method name="resetOnLoad">
+            this.loadtext.setText('Loading...');
+            this.setAttribute('waitforload', true);
+            this.setAttribute('startindex', 1);
+            this.setAttribute('nextstartindex', 1);
+            this.setAttribute('endindex', 1 + photoscontainer.lyt.totalitems);
+            this.setAttribute('nextendindex', 1 + 
photoscontainer.lyt.totalitems);
+        </method>
 
         <method name="enableZoom">
             thmb.setVisible(true);
@@ -68,9 +79,14 @@
             showhandcursor="false" onclick="" bgcolor="0x7F7F7F" 
             x="0" y="13" width="130" height="30" />
 
-        <text name="firstphotoindex"  fgcolor="0x463e9D" y="7" x="152" 
fontsize="9"/>
-        <text text="-" fgcolor="0x463e9D" y="4" x="165" />        
-        <text name="lastphotoindex"  fgcolor="0x463e9D" y="7" x="172" 
fontsize="9" />
+        <text name="firstphotoindex"  fgcolor="0x463e9D" y="7" x="${152 - 
(this.width / 2)}" fontsize="9"
+            visible="${!parent.waitforload}"/>
+        <text text="-" fgcolor="0x463e9D" y="4" x="162" 
visible="${!parent.waitforload}"/>        
+        <text name="lastphotoindex"  fgcolor="0x463e9D" y="7" x="172" 
fontsize="9"
+            visible="${!parent.waitforload}"/>
+        
+        <text name="loadtext" fgcolor="0x463e9D" x="${170 - (this.width / 2)}" 
y="7" fontsize="9"
+            visible="${parent.waitforload}"/>
    
         <!-- Button for previous page -->
         <mybutton name="pageprev" 
@@ -91,11 +107,30 @@
         
        
         <method name="displayNextPage" >
+            <![CDATA[
             //get paging parameters at this point ( before layout is animated 
offscreen )
             this.nextstartindex = this.endindex + 1;
             this.nextendindex   = Math.min( this.nextstartindex + 
photoscontainer.lyt.pagesize - 1, this.numberofphotos );
-            photoscontainer.lyt.calcpageparams = false;
-            photoscontainer.lyt.pageNext.doStart();
+            if(this.nextstartindex <= this.numberofphotos){
+                if(nextendindex == this.numberofphotos){
+                    this.nextendindex = this.numberofphotos;
+                    this.nextstartindex = this.nextendindex - 
photoscontainer.lyt.totalitems + 1;
+                }
+                photoscontainer.lyt.calcpageparams = false;
+                photoscontainer.lyt.pageNext.doStart();
+            } else if(photoscontainer.lyt.currentpage < 
photoscontainer.lyt.totalpages){
+                /* Request the next set of data, if we've reached the limit.
+                Unfortunately, we have to go by sets of 100, because Flickr's
+                API breaks data up into single-request XML pages of 100 items
+                apiece. */
+                this.loadtext.setText('Next 100...');
+                this.setAttribute('waitforload', true);
+                this.nextstartindex = 1;
+                this.nextendindex = Math.min(this.nextstartindex + 
photoscontainer.lyt.pagesize - 1, this.numberofphotos );
+                photoscontainer.lyt.setAttribute('currentpage', 
Number(photoscontainer.lyt.currentpage) + 1);
+                gSearch.doSearch();
+            }
+            ]]>
         </method>
         
         <method event="onstop" reference="photoscontainer.lyt.pageNext" >
@@ -111,13 +146,26 @@
         </method>
 
         <method name="displayPrevPage" >
+            <![CDATA[
             if ( this.startindex > 1 ) {
                 this.nextendindex     = this.startindex - 1;
-                this.nextstartindex   = Math.max( this.nextendindex - 
photoscontainer.lyt.pagesize + 1, 1 );
-                if (  this.nextstartindex == 1  ) this.nextendindex =  
photoscontainer.lyt.pagesize;
+                this.nextstartindex   = Math.max( this.nextendindex - 
photoscontainer.lyt.totalitems + 1, 1 );
+                if (  this.nextstartindex == 1  ) this.nextendindex =  
photoscontainer.lyt.totalitems;
                 photoscontainer.lyt.calcpageparams = false;
                 photoscontainer.lyt.pagePrev.doStart();
+            } else if(photoscontainer.lyt.currentpage > 1){
+                /* Request the previous set of data, if we've reached the 
limit.
+                Unfortunately, we have to go by sets of 100, because Flickr's
+                API breaks data up into single-request XML pages of 100 items
+                apiece. */
+                this.loadtext.setText('Prev 100...');
+                this.setAttribute('waitforload', true);
+                this.nextendindex = this.numberofphotos;
+                this.nextstartindex = this.nextendindex - 
photoscontainer.lyt.totalitems + 1;
+                photoscontainer.lyt.setAttribute('currentpage', 
Number(photoscontainer.lyt.currentpage) - 1);
+                gSearch.doSearch();
             }
+            ]]>
         </method>
 
         <method event="onstop" reference="photoscontainer.lyt.pagePrev" >
@@ -150,8 +198,8 @@
         </method>
 
         <method name="displayRange"  args="s,e" >
-            this.firstphotoindex.setText( s);
-            this.lastphotoindex.setText( e );
+            this.firstphotoindex.setText( s + (photoscontainer.lyt.perpage * 
(photoscontainer.lyt.currentpage - 1)));
+            this.lastphotoindex.setText( e + (photoscontainer.lyt.perpage * 
(photoscontainer.lyt.currentpage - 1)));
         </method>
 
         <method name="setpPagingParams" args="n" >
@@ -162,6 +210,7 @@
         </method>
 
         <method event="ondata" reference="photods" >
+            this.setAttribute('waitforload', false);
             photoscontainer.lyt.calcparams = true;
         </method>
 


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to