Skip to content

Commit

Permalink
Fix #67
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinchoolur committed Feb 11, 2019
1 parent 123c309 commit 6b42444
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 61 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightgallery.js",
"version": "1.1.2",
"version": "1.1.3",
"description": "Full featured lightbox gallery. Zero dependencies",
"main": [
"dist/js/lightgallery.min.js",
Expand Down
48 changes: 18 additions & 30 deletions dist/js/lightgallery.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* lightgallery.js | 1.0.3 | August 8th 2018
* lightgallery.js | 1.1.3 | February 11th 2019
* http://sachinchoolur.github.io/lightgallery.js/
* Copyright (c) 2016 Sachin N;
* @license GPLv3
Expand All @@ -23,26 +23,14 @@
value: true
});

/*
*@todo remove function from window and document. Update on and off functions
*/
window.getAttribute = function (label) {
return window[label];
};

window.setAttribute = function (label, value) {
window[label] = value;
};

document.getAttribute = function (label) {
return document[label];
};

document.setAttribute = function (label, value) {
document[label] = value;
};

var utils = {
getAttribute: function getAttribute(el, label) {
return el[label];
},

setAttribute: function setAttribute(el, label, value) {
el[label] = value;
},
wrap: function wrap(el, className) {
if (!el) {
return;
Expand Down Expand Up @@ -85,8 +73,6 @@
} else {
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}

return false;
},

// ex Transform
Expand Down Expand Up @@ -120,15 +106,17 @@
uid: 0
},
on: function on(el, events, fn) {
var _this = this;

if (!el) {
return;
}

events.split(' ').forEach(function (event) {
var _id = el.getAttribute('lg-event-uid') || '';
var _id = _this.getAttribute(el, 'lg-event-uid') || '';
utils.Listener.uid++;
_id += '&' + utils.Listener.uid;
el.setAttribute('lg-event-uid', _id);
_this.setAttribute(el, 'lg-event-uid', _id);
utils.Listener[event + utils.Listener.uid] = fn;
el.addEventListener(event.split('.')[0], fn, false);
});
Expand All @@ -139,7 +127,7 @@
return;
}

var _id = el.getAttribute('lg-event-uid');
var _id = this.getAttribute(el, 'lg-event-uid');
if (_id) {
_id = _id.split('&');
for (var i = 0; i < _id.length; i++) {
Expand All @@ -150,14 +138,14 @@
if (utils.Listener.hasOwnProperty(key)) {
if (key.split('.').indexOf(_event.split('.')[1]) > -1) {
el.removeEventListener(key.split('.')[0], utils.Listener[key]);
el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
this.setAttribute(el, 'lg-event-uid', this.getAttribute(el, 'lg-event-uid').replace('&' + _id[i], ''));
delete utils.Listener[key];
}
}
}
} else {
el.removeEventListener(_event.split('.')[0], utils.Listener[_event]);
el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
this.setAttribute(el, 'lg-event-uid', this.getAttribute(el, 'lg-event-uid').replace('&' + _id[i], ''));
delete utils.Listener[_event];
}
}
Expand Down Expand Up @@ -637,7 +625,7 @@
};
}

var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
var youtube = src.match(/\/\/(?:www\.)?youtu(?:\.be|be\.com|be-nocookie\.com)\/(?:watch\?v=|embed\/)?([a-z0-9\-\_\%]+)/i);
var vimeo = src.match(/\/\/(?:www\.)?vimeo.com\/([0-9a-z\-_]+)/i);
var dailymotion = src.match(/\/\/(?:www\.)?dai.ly\/([0-9a-z\-_]+)/i);
var vk = src.match(/\/\/(?:www\.)?(?:vk\.com|vkontakte\.ru)\/(?:video_ext\.php\?)(.*)/i);
Expand Down Expand Up @@ -1243,8 +1231,8 @@
prev.removeAttribute('disabled');
_lgUtils2.default.removeClass(prev, 'disabled');
} else {
next.setAttribute('disabled', 'disabled');
_lgUtils2.default.addClass(next, 'disabled');
prev.setAttribute('disabled', 'disabled');
_lgUtils2.default.addClass(prev, 'disabled');
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions dist/js/lightgallery.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightgallery.js",
"version": "1.1.2",
"version": "1.1.3",
"description": "Full featured lightbox gallery. Zero dependencies",
"keywords": [
"gallery",
Expand Down Expand Up @@ -56,7 +56,7 @@
"build-debug": "browserify src/js/lightgallery.js -s Lightgallery -t [babelify] -p [bannerify --file .banner ] -o dist/js/lightgallery.js",
"build-min": "uglifyjs dist/js/lightgallery.js --comments '/!/' -m screw_ie8=true -c screw_ie8=true,unused=false -o dist/js/lightgallery.min.js",
"watch": "watchify src/js/lightgallery.js -s Lightgallery -t [babelify] -o dist/js/lightgallery.js -v",
"dev": "watchify src/js/lightgallery.js -s Lightgallery -t [babelify] -o ../lg/lightgallery.js/lightgallery/js/lightgallery.js -v",
"dev": "watchify src/js/lightgallery.js -s Lightgallery -t [babelify] -o /Users/sachin/workspace/lightgallery-js/gh-pages/lightgallery.js/lightgallery/js/lightgallery.js -v",
"css": "cleancss -o dist/css/lightgallery.min.css dist/css/lightgallery.css && cleancss -o dist/css/lg-fb-comment-box.min.css dist/css/lg-fb-comment-box.css && cleancss -o dist/css/lg-transitions.min.css dist/css/lg-transitions.css",
"copyfiles": "copyfiles -u 1 ./src/fonts/** dist && copyfiles -u 1 ./src/img/** dist && copyfiles -u 1 ./src/css/** dist",
"lint": "jshint src",
Expand Down
38 changes: 12 additions & 26 deletions src/js/lg-utils.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@

/*
*@todo remove function from window and document. Update on and off functions
*/
window.getAttribute = function(label) {
return window[label];
};

window.setAttribute = function(label, value) {
window[label] = value;
};

document.getAttribute = function(label) {
return document[label];
};

document.setAttribute = function(label, value) {
document[label] = value;
};

var utils = {
getAttribute: function(el, label) {
return el[label];
},

setAttribute: function(el, label, value) {
el[label] = value;
},
wrap: function(el, className) {
if (!el) {
return;
Expand Down Expand Up @@ -61,8 +49,6 @@ var utils = {
} else {
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}

return false;
},

// ex Transform
Expand Down Expand Up @@ -99,10 +85,10 @@ var utils = {
}

events.split(' ').forEach(event => {
var _id = el.getAttribute('lg-event-uid') || '';
var _id = this.getAttribute(el, 'lg-event-uid') || '';
utils.Listener.uid++;
_id += '&' + utils.Listener.uid;
el.setAttribute('lg-event-uid', _id);
this.setAttribute(el, 'lg-event-uid', _id);
utils.Listener[event + utils.Listener.uid] = fn;
el.addEventListener(event.split('.')[0], fn, false);
});
Expand All @@ -113,7 +99,7 @@ var utils = {
return;
}

var _id = el.getAttribute('lg-event-uid');
var _id = this.getAttribute(el, 'lg-event-uid');
if (_id) {
_id = _id.split('&');
for (var i = 0; i < _id.length; i++) {
Expand All @@ -124,14 +110,14 @@ var utils = {
if (utils.Listener.hasOwnProperty(key)) {
if (key.split('.').indexOf(_event.split('.')[1]) > -1) {
el.removeEventListener(key.split('.')[0], utils.Listener[key]);
el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
this.setAttribute(el, 'lg-event-uid', this.getAttribute(el, 'lg-event-uid').replace('&' + _id[i], ''));
delete utils.Listener[key];
}
}
}
} else {
el.removeEventListener(_event.split('.')[0], utils.Listener[_event]);
el.setAttribute('lg-event-uid', el.getAttribute('lg-event-uid').replace('&' + _id[i], ''));
this.setAttribute(el, 'lg-event-uid', this.getAttribute(el, 'lg-event-uid').replace('&' + _id[i], ''));
delete utils.Listener[_event];
}
}
Expand Down

0 comments on commit 6b42444

Please sign in to comment.