+if (browser.isGecko) {
+ Lightbox.prototype.disableDefaultDragging = function(element) {
+ if (!element) {
+ element = this.grid;
+ }
+ var i, j, name, elements;
+ var elementsNames = ['a', 'img'];
+ for (i=0 ; i < elementsNames.length ; i++) {
+ name = elementsNames[i];
+ elements = element.getElementsByTagName(name);
+ for (j=0 ; j < elements.length ; j++) {
+ elements[j].draggable=false;
+ }
+ }
+ };
+}
+else {
+ Lightbox.prototype.disableDefaultDragging = function() {};
+}
+
+Lightbox.prototype.getSelectedSlides = function() {
+ var i, e, slide;
+ var slides = [];
+ for (i=0 ; i<this.form.elements.length ; i++) {
+ e = this.form.elements[i];
+ if (e.type === 'checkbox' && e.checked) {
+ slide = e.parentNode.parentNode;
+ slides.push(slide);
+ }
+ }
+ return slides;
+};
+
+Lightbox.prototype.onDragStart = function(evt) {
+ var target = getTargetedObject(evt);
+ this.dragged = target;
+ this.draggedSelection = this.getSelectedSlides();
+ if (this.draggedSelection.indexOf(target) === -1) {
+ this.draggedSelection.push(target);
+ }
+ evt.dataTransfer.setData('text', '');
+ var i, slide;
+ for(i=0 ; i<this.draggedSelection.length ; i++) {
+ slide = this.draggedSelection[i];
+ slide.style.opacity = 0;
+ slide.style.width = 0;
+ }
+};
+
+Lightbox.prototype.onDragOver = function(evt) {
+ var target = getTargetedObject(evt);
+ if (!target) {return;}
+ while(target.className !== 'slide') {
+ target = target.parentNode;
+ }
+ target = target.parentNode;
+ if (target !== this.dragged) {
+ target.classList.add('dragover');
+ }
+ if (this.previousDragOver && this.previousDragOver !== target) {
+ this.previousDragOver.classList.remove('dragover');
+ }
+ this.previousDragOver = target;
+};
+
+Lightbox.prototype.onDragEnd = function(evt) {
+ if (this.previousDragOver) {
+ this.previousDragOver.classList.remove('dragover');
+ var i, slide;
+ for(i=this.draggedSelection.length -1 ; i>=0 ; i--) {
+ console.log(i);
+ slide = this.draggedSelection[i].cloneNode(true);
+ this.grid.insertBefore(slide, this.previousDragOver.nextSibling);
+ slide.style.opacity = 1;
+ slide.style.width = '';
+ }
+ }
+ this.draggedSelection = this.previousDragOver = this.dragged = undefined;
+};
+