+ 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._buildSlidesIndex = function() {
+ 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];
+};
+
+Lightbox.prototype.windowScrollToolbarlHandler = function(evt) {
+ if (this.toolbar.offsetTop < getWindowScrollY() && !this.toolbarFixed) {
+ this.toolbarFixed = true;
+ this.backThreshold = this.toolbar.offsetTop;
+ this.switchToolBarPositioning(true);
+ }
+ else if (this.toolbarFixed && getWindowScrollY() < this.backThreshold) {
+ this.toolbarFixed = false;
+ this.switchToolBarPositioning(false);
+ }
+};
+Lightbox.prototype.windowScrollGridHandler = function(evt) {
+ if (!this.complete &&
+ !this.fetchingDisabled &&
+ getWindowScrollY() >
+ (this.lastSlide.firstElementChild || this.lastSlide.children[0]).offsetTop
+ - getWindowHeight()) {
+ this.fetchingDisabled = true;
+ this.fetchTail();
+ }
+};