Fetch des photos suivante (implémentation incomplète).
authorBenoît Pin <benoit.pin@gmail.com>
Thu, 10 Jul 2014 06:42:49 +0000 (08:42 +0200)
committerBenoît Pin <benoit.pin@gmail.com>
Thu, 10 Jul 2014 06:42:49 +0000 (08:42 +0200)
skins/getPhotosInfos.py
skins/photo_lightbox_viewer.js
skins/portfolio_thumbnails_tail.py

index e77739f..c5b00a7 100755 (executable)
@@ -1,4 +1,4 @@
-##parameters=portfolio
+##parameters=portfolio, pho_start=None, batch_size=None
 from Products.Plinn.PloneMisc import Batch
 from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.permissions import ReviewPortalContent, ModifyPortalContent
 from Products.Plinn.PloneMisc import Batch
 from Products.CMFCore.utils import getToolByName
 from Products.CMFCore.permissions import ReviewPortalContent, ModifyPortalContent
@@ -22,13 +22,14 @@ if mtool.checkPermission(ModifyPortalContent, context) :
     features['checkbox'] = True
 
 req = context.REQUEST
     features['checkbox'] = True
 
 req = context.REQUEST
-pho_start = req.get('pho_start', 0)
+pho_start = pho_start if pho_start is not None else 0
+batch_size = batch_size if batch_size is not None else context.default_batch_size
 sort_on, sort_order = context.getDefaultSorting()
 contentFilter = {'portal_type' : ['Photo'],
                  'sort_on' : sort_on,
                  'sort_order' : sort_order}
 batch = Batch(portfolio.listCatalogedContents(contentFilter=contentFilter),
 sort_on, sort_order = context.getDefaultSorting()
 contentFilter = {'portal_type' : ['Photo'],
                  'sort_on' : sort_on,
                  'sort_order' : sort_order}
 batch = Batch(portfolio.listCatalogedContents(contentFilter=contentFilter),
-              context.default_batch_size, pho_start, orphan=5, quantumleap=1, b_start_str='pho_start')
+              batch_size, pho_start, orphan=5, quantumleap=1, b_start_str='pho_start')
 
 
 infos = []
 
 
 infos = []
index 0b40288..9a57ac2 100644 (file)
@@ -53,7 +53,7 @@ Lightbox.prototype.windowScrollHandler = function(evt) {
                this.switchToolBarPositioning(false);
        }
     if (window.scrollY > this.lastSlide.firstElementChild.offsetTop - getWindowHeight()) {
                this.switchToolBarPositioning(false);
        }
     if (window.scrollY > this.lastSlide.firstElementChild.offsetTop - getWindowHeight()) {
-        console.log('À boire !');
+        this.fetchTail();
     }
 };
 
     }
 };
 
@@ -325,6 +325,40 @@ Lightbox.prototype._refreshGrid = function(req) {
     }
 };
 
     }
 };
 
+Lightbox.prototype.fetchTail = function() {
+       var req = new XMLHttpRequest();
+       self = this;
+       req.onreadystatechange = function() {
+               switch (req.readyState) {
+                       case 1 :
+                               showProgressImage();
+                               break;
+                       case 4 :
+                               hideProgressImage();
+                               if (req.status === 200) {
+                                       self._appendTail(req)
+                               }
+                               break;
+               }
+       };
+       
+       var url = absolute_url() +
+                         '/portfolio_thumbnails_tail?start:int=' +
+              String(this.grid.children.length + 1 ) +
+              '&size:int=10';
+       req.open('GET', url, true);
+       req.send();
+};
+
+Lightbox.prototype._appendTail = function(req) {
+    var doc = req.responseXML.documentElement;
+    var i;
+    var slides = this.grid.children;
+    for (i=0 ; i<doc.children.length ; i++) {
+        this.grid.replaceChild(getCopyOfNode(doc.children[i]), slides[i]);
+    }
+};
+
 
 var _outlineSelectedSlide;
 if (browser.isGecko) {
 
 var _outlineSelectedSlide;
 if (browser.isGecko) {
index 819e759..4f47bf3 100644 (file)
@@ -1,4 +1,6 @@
 ##parameters=start=0, size=10
 options={}
 ##parameters=start=0, size=10
 options={}
-options.update(context.getPhotosInfos(context))
+options.update(context.getPhotosInfos(context,
+                                      pho_start=start,
+                                      batch_size=size))
 return context.portfolio_thumbnails_tail_template(**options)
\ No newline at end of file
 return context.portfolio_thumbnails_tail_template(**options)
\ No newline at end of file