+ this.slides = [];
+ var node, i;
+ for (i=0 ; i<this.grid.childNodes.length ; i++) {
+ node = this.grid.childNodes[i];
+ if (node.nodeType === 1) { // is element
+ this.slides.push(node);
+ }
+ }
+ this.lastSlide = this.slides[this.slides.length-1];
+ this.fetchingDisabled = false;
+ this.complete = complete;
+ console.log('complete:', complete)
+ 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();});
+ this.lastCBChecked = undefined;
+ this.form = undefined;
+ var parent = this.grid.parentNode;
+ while(parent) {
+ parent = parent.parentNode;
+ if (parent.tagName === 'FORM') {
+ this.form = parent;
+ break;
+ }
+ else if (parent.tagName === 'BODY') {
+ break;
+ }
+ }
+ addListener(this.grid, 'click', function(evt){self.mouseClickHandler(evt);});
+ if (this.form) {
+ var fm = this.fm = new FormManager(this.form);
+ addListener(this.form, 'change', function(evt){self.onChangeHandler(evt);});
+ fm.onBeforeSubmit = function(fm_, evt) {return self.onBeforeSubmit(fm_, evt);};
+ fm.onResponseLoad = function(req) {return self.onResponseLoad(req);};
+ }
+};
+
+Lightbox.prototype.windowScrollToolbarlHandler = function(evt) {
+ if (this.toolbar.offsetTop < window.scrollY && !this.toolbarFixed) {
+ this.toolbarFixed = true;
+ this.backThreshold = this.toolbar.offsetTop;
+ this.switchToolBarPositioning(true);
+ }
+ else if (this.toolbarFixed && window.scrollY < this.backThreshold) {
+ this.toolbarFixed = false;
+ this.switchToolBarPositioning(false);
+ }
+};
+Lightbox.prototype.windowScrollGridHandler = function(evt) {
+ if (!this.complete &&
+ !this.fetchingDisabled &&
+ window.scrollY > this.lastSlide.firstElementChild.offsetTop - getWindowHeight()) {
+ this.fetchingDisabled = true;
+ this.fetchTail();