X-Git-Url: https://svn.cri.ensmp.fr/git/Portfolio.git/blobdiff_plain/3940d117b095679f682c973f0bdc83e877b214e6..e3e5d18a6b6dfaeb26dc0c2ee99acf2da0e003f8:/skins/photo_lightbox_viewer.js?ds=sidebyside diff --git a/skins/photo_lightbox_viewer.js b/skins/photo_lightbox_viewer.js index d659ac1..b67f6ab 100644 --- a/skins/photo_lightbox_viewer.js +++ b/skins/photo_lightbox_viewer.js @@ -11,20 +11,20 @@ var Lightbox; var reSelected = /.*selected.*/; -Lightbox = function(grid, toolbar, complete) { +Lightbox = function(grid, toolbar, complete, container_type) { var self = this; this.grid = grid; - this.lastSlide = this.grid.children[this.grid.children.length-1]; + this._buildSlidesIndex(); // set this.slides and this.lastSlide; this.fetchingDisabled = false; this.complete = complete; - console.log('complete:', complete) + this.container_type = container_type; this.toolbar = toolbar; if (toolbar) { this.toolbarFixed = false; addListener(window, 'scroll', function(evt){self.windowScrollToolbarlHandler(evt);}); } addListener(window, 'scroll', function(evt){self.windowScrollGridHandler(evt);}); - addListener(window, 'load', function(evt){ self.windowScrollGridHandler();}); + registerStartupFunction(function(){ self.windowScrollGridHandler();}); this.lastCBChecked = undefined; this.form = undefined; var parent = this.grid.parentNode; @@ -45,15 +45,33 @@ Lightbox = function(grid, toolbar, complete) { fm.onBeforeSubmit = function(fm_, evt) {return self.onBeforeSubmit(fm_, evt);}; fm.onResponseLoad = function(req) {return self.onResponseLoad(req);}; } + + // drag and drop + this.disableDefaultDragging(); + addListener(this.grid, 'dragstart', function(evt){self.onDragStart(evt);}); + addListener(this.grid, 'dragover', function(evt){self.onDragOver(evt);}); + addListener(this.grid, 'dragend', function(evt){self.onDragEnd(evt);}); +}; + +Lightbox.prototype._buildSlidesIndex = function() { + this.slides = []; + var node, i; + for (i=0 ; i this.lastSlide.firstElementChild.offsetTop - getWindowHeight()) { + getWindowScrollY() > + (this.lastSlide.firstElementChild || this.lastSlide.children[0]).offsetTop + - getWindowHeight()) { this.fetchingDisabled = true; this.fetchTail(); } @@ -185,6 +205,9 @@ Lightbox.prototype.onResponseLoad = function(req) { this.fm.submitButton = undefined; this.refreshGrid(); break; + default : + this.fm.loadResponse(req); + break; } }; @@ -247,7 +270,7 @@ Lightbox.prototype.deleteSelection = function() { }; Lightbox.prototype._removeSelection = function() { - var i, e, slide; + var i, e; var toRemove = []; for (i=0 ; i