node-waves
Advanced tools
Comparing version 0.7.1 to 0.7.2
{ | ||
"name": "Waves", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"homepage": "http://fian.my.id/Waves", | ||
@@ -5,0 +5,0 @@ "authors": [ |
/*! | ||
* Waves v0.7.1 | ||
* Waves v0.7.2 | ||
* http://fian.my.id/Waves | ||
@@ -182,42 +182,58 @@ * | ||
} | ||
}, | ||
} | ||
}; | ||
/** | ||
* Collection of wrapper for HTML element that only have single tag | ||
* like <input> and <img> | ||
*/ | ||
var TagWrapper = { | ||
// Wrap <input> tag so it can perform the effect | ||
input: function(element) { | ||
var parent = element.parentNode; | ||
// Little hack to make <input> can perform waves effect | ||
wrapInput: function(elements) { | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
return; | ||
} | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
// Put element class and style to the specified parent | ||
var wrapper = document.createElement('i'); | ||
wrapper.className = element.className + ' waves-input-wrapper'; | ||
element.className = 'waves-button-input'; | ||
var element = elements[i]; | ||
// Put element as child | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
if (element.tagName.toLowerCase() === 'input') { | ||
// Apply element color and background color to wrapper | ||
var elementStyle = window.getComputedStyle(element, null); | ||
var color = elementStyle.color; | ||
var backgroundColor = elementStyle.backgroundColor; | ||
var parent = element.parentNode; | ||
wrapper.setAttribute('style', 'color:' + color + ';background:' + backgroundColor); | ||
element.setAttribute('style', 'background-color:rgba(0,0,0,0);'); | ||
}, | ||
// Wrap <img> tag so it can perform the effect | ||
img: function(element) { | ||
var parent = element.parentNode; | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
continue; | ||
} | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
return; | ||
} | ||
// Put element class and style to the specified parent | ||
var wrapper = document.createElement('i'); | ||
wrapper.className = element.className + ' waves-input-wrapper'; | ||
element.className = 'waves-button-input'; | ||
// Put element as child | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
// Apply element color and background color to wrapper | ||
var elementStyle = window.getComputedStyle(element, null); | ||
var color = elementStyle.color; | ||
var backgroundColor = elementStyle.backgroundColor; | ||
wrapper.setAttribute('style', 'color:' + color + ';background:' + backgroundColor); | ||
element.setAttribute('style', 'background-color:rgba(0,0,0,0);'); | ||
} | ||
} | ||
// Put element as child | ||
var wrapper = document.createElement('i'); | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
} | ||
}; | ||
/** | ||
@@ -428,5 +444,2 @@ * Hide the effect and remove the ripple. Must be | ||
//Wrap input inside <i> tag | ||
Effect.wrapInput($$('.waves-effect')); | ||
if (isTouchAvailable) { | ||
@@ -448,2 +461,3 @@ body.addEventListener('touchstart', showEffect, false); | ||
Waves.attach = function(elements, classes) { | ||
elements = getWavesElements(elements); | ||
@@ -457,8 +471,11 @@ | ||
var element; | ||
var element, tagName; | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
element = elements[i]; | ||
if (element.tagName.toLowerCase() === 'input') { | ||
Effect.wrapInput([element]); | ||
tagName = element.tagName.toLowerCase(); | ||
if (['input', 'img'].indexOf(tagName) !== -1) { | ||
TagWrapper[tagName](element); | ||
element = element.parentElement; | ||
@@ -465,0 +482,0 @@ } |
/*! | ||
* Waves v0.7.1 | ||
* Waves v0.7.2 | ||
* http://fian.my.id/Waves | ||
@@ -9,3 +9,3 @@ * | ||
*/ | ||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return b.apply(a)}):"object"==typeof exports?module.exports=b.call(a):a.Waves=b.call(a)}("object"==typeof global?global:this,function(){"use strict";function a(a){return null!==a&&a===a.window}function b(b){return a(b)?b:9===b.nodeType&&b.defaultView}function c(a){var b=typeof a;return"function"===b||"object"===b&&!!a}function d(a){return c(a)&&a.nodeType>0}function e(a){var b=m.call(a);return"[object String]"===b?l(a):c(a)&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(b)&&a.hasOwnProperty("length")?a:d(a)?[a]:[]}function f(a){var c,d,e={top:0,left:0},f=a&&a.ownerDocument;return c=f.documentElement,"undefined"!=typeof a.getBoundingClientRect&&(e=a.getBoundingClientRect()),d=b(f),{top:e.top+d.pageYOffset-c.clientTop,left:e.left+d.pageXOffset-c.clientLeft}}function g(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b+=c+":"+a[c]+";");return b}function h(a,b,c){if(c){c.classList.remove("waves-rippling");var d=c.getAttribute("data-x"),e=c.getAttribute("data-y"),f=c.getAttribute("data-scale"),h=c.getAttribute("data-translate"),i=Date.now()-Number(c.getAttribute("data-hold")),j=350-i;0>j&&(j=0),"mousemove"===a.type&&(j=150);var k="mousemove"===a.type?2500:o.duration;setTimeout(function(){var a={top:e+"px",left:d+"px",opacity:"0","-webkit-transition-duration":k+"ms","-moz-transition-duration":k+"ms","-o-transition-duration":k+"ms","transition-duration":k+"ms","-webkit-transform":f+" "+h,"-moz-transform":f+" "+h,"-ms-transform":f+" "+h,"-o-transform":f+" "+h,transform:f+" "+h};c.setAttribute("style",g(a)),setTimeout(function(){try{b.removeChild(c)}catch(a){return!1}},k)},j)}}function i(a){if(p.allowEvent(a)===!1)return null;for(var b=null,c=a.target||a.srcElement;null!==c.parentElement;){if(c.classList.contains("waves-effect")&&!(c instanceof SVGElement)){b=c;break}c=c.parentElement}return b}function j(a){p.registerEvent(a);var b=i(a);if(null!==b)if("touchstart"===a.type&&o.delay){var c=!1,d=setTimeout(function(){d=null,o.show(a,b)},o.delay),e=function(e){d&&(clearTimeout(d),d=null,o.show(a,b)),c||(c=!0,o.hide(e,b))},f=function(a){d&&(clearTimeout(d),d=null),e(a)};b.addEventListener("touchmove",f,!1),b.addEventListener("touchend",e,!1),b.addEventListener("touchcancel",e,!1)}else o.show(a,b),n&&(b.addEventListener("touchend",o.hide,!1),b.addEventListener("touchcancel",o.hide,!1)),b.addEventListener("mouseup",o.hide,!1),b.addEventListener("mouseleave",o.hide,!1)}var k=k||{},l=document.querySelectorAll.bind(document),m=Object.prototype.toString,n="ontouchstart"in window,o={duration:750,delay:200,show:function(a,b,c){if(2===a.button)return!1;b=b||this;var d=document.createElement("div");d.className="waves-ripple waves-rippling",b.appendChild(d);var e=f(b),h=a.pageY-e.top,i=a.pageX-e.left,j="scale("+b.clientWidth/100*3+")",k="translate(0,0)";c&&(k="translate("+c.x+"px, "+c.y+"px)"),"touches"in a&&a.touches.length&&(h=a.touches[0].pageY-e.top,i=a.touches[0].pageX-e.left),d.setAttribute("data-hold",Date.now()),d.setAttribute("data-x",i),d.setAttribute("data-y",h),d.setAttribute("data-scale",j),d.setAttribute("data-translate",k);var l={top:h+"px",left:i+"px"};d.classList.add("waves-notransition"),d.setAttribute("style",g(l)),d.classList.remove("waves-notransition"),l["-webkit-transform"]=j+" "+k,l["-moz-transform"]=j+" "+k,l["-ms-transform"]=j+" "+k,l["-o-transform"]=j+" "+k,l.transform=j+" "+k,l.opacity="1";var m="mousemove"===a.type?2500:o.duration;l["-webkit-transition-duration"]=m+"ms",l["-moz-transition-duration"]=m+"ms",l["-o-transition-duration"]=m+"ms",l["transition-duration"]=m+"ms",d.setAttribute("style",g(l))},hide:function(a,b){b=b||this;for(var c=b.getElementsByClassName("waves-rippling"),d=0,e=c.length;e>d;d++)h(a,b,c[d])},wrapInput:function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];if("input"===d.tagName.toLowerCase()){var e=d.parentNode;if("i"===e.tagName.toLowerCase()&&e.classList.contains("waves-effect"))continue;var f=document.createElement("i");f.className=d.className+" waves-input-wrapper",d.className="waves-button-input",e.replaceChild(f,d),f.appendChild(d);var g=window.getComputedStyle(d,null),h=g.color,i=g.backgroundColor;f.setAttribute("style","color:"+h+";background:"+i),d.setAttribute("style","background-color:rgba(0,0,0,0);")}}}},p={touches:0,allowEvent:function(a){var b=!0;return/^(mousedown|mousemove)$/.test(a.type)&&p.touches&&(b=!1),b},registerEvent:function(a){var b=a.type;"touchstart"===b?p.touches+=1:/^(touchend|touchcancel)$/.test(b)&&setTimeout(function(){p.touches&&(p.touches-=1)},500)}};return k.init=function(a){var b=document.body;a=a||{},"duration"in a&&(o.duration=a.duration),"delay"in a&&(o.delay=a.delay),o.wrapInput(l(".waves-effect")),n&&(b.addEventListener("touchstart",j,!1),b.addEventListener("touchcancel",p.registerEvent,!1),b.addEventListener("touchend",p.registerEvent,!1)),b.addEventListener("mousedown",j,!1)},k.attach=function(a,b){a=e(a),"[object Array]"===m.call(b)&&(b=b.join(" ")),b=b?" "+b:"";for(var c,d=0,f=a.length;f>d;d++)c=a[d],"input"===c.tagName.toLowerCase()&&(o.wrapInput([c]),c=c.parentElement),c.className+=" waves-effect"+b},k.ripple=function(a,b){a=e(a);var c=a.length;if(b=b||{},b.wait=b.wait||0,b.position=b.position||null,c)for(var d,g,h,i={},j=0,k={type:"mousedown",button:1},l=function(a,b){return function(){o.hide(a,b)}};c>j;j++)if(d=a[j],g=b.position||{x:d.clientWidth/2,y:d.clientHeight/2},h=f(d),i.x=h.left+g.x,i.y=h.top+g.y,k.pageX=i.x,k.pageY=i.y,o.show(k,d),b.wait>=0&&null!==b.wait){var m={type:"mouseup",button:1};setTimeout(l(m,d),b.wait)}},k.calm=function(a){a=e(a);for(var b={type:"mouseup",button:1},c=0,d=a.length;d>c;c++)o.hide(b,a[c])},k.displayEffect=function(a){console.error("Waves.displayEffect() has been deprecated and will be removed in future version. Please use Waves.init() to initialize Waves effect"),k.init(a)},k}); | ||
!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return b.apply(a)}):"object"==typeof exports?module.exports=b.call(a):a.Waves=b.call(a)}("object"==typeof global?global:this,function(){"use strict";function a(a){return null!==a&&a===a.window}function b(b){return a(b)?b:9===b.nodeType&&b.defaultView}function c(a){var b=typeof a;return"function"===b||"object"===b&&!!a}function d(a){return c(a)&&a.nodeType>0}function e(a){var b=m.call(a);return"[object String]"===b?l(a):c(a)&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(b)&&a.hasOwnProperty("length")?a:d(a)?[a]:[]}function f(a){var c,d,e={top:0,left:0},f=a&&a.ownerDocument;return c=f.documentElement,"undefined"!=typeof a.getBoundingClientRect&&(e=a.getBoundingClientRect()),d=b(f),{top:e.top+d.pageYOffset-c.clientTop,left:e.left+d.pageXOffset-c.clientLeft}}function g(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b+=c+":"+a[c]+";");return b}function h(a,b,c){if(c){c.classList.remove("waves-rippling");var d=c.getAttribute("data-x"),e=c.getAttribute("data-y"),f=c.getAttribute("data-scale"),h=c.getAttribute("data-translate"),i=Date.now()-Number(c.getAttribute("data-hold")),j=350-i;0>j&&(j=0),"mousemove"===a.type&&(j=150);var k="mousemove"===a.type?2500:o.duration;setTimeout(function(){var a={top:e+"px",left:d+"px",opacity:"0","-webkit-transition-duration":k+"ms","-moz-transition-duration":k+"ms","-o-transition-duration":k+"ms","transition-duration":k+"ms","-webkit-transform":f+" "+h,"-moz-transform":f+" "+h,"-ms-transform":f+" "+h,"-o-transform":f+" "+h,transform:f+" "+h};c.setAttribute("style",g(a)),setTimeout(function(){try{b.removeChild(c)}catch(a){return!1}},k)},j)}}function i(a){if(q.allowEvent(a)===!1)return null;for(var b=null,c=a.target||a.srcElement;null!==c.parentElement;){if(c.classList.contains("waves-effect")&&!(c instanceof SVGElement)){b=c;break}c=c.parentElement}return b}function j(a){q.registerEvent(a);var b=i(a);if(null!==b)if("touchstart"===a.type&&o.delay){var c=!1,d=setTimeout(function(){d=null,o.show(a,b)},o.delay),e=function(e){d&&(clearTimeout(d),d=null,o.show(a,b)),c||(c=!0,o.hide(e,b))},f=function(a){d&&(clearTimeout(d),d=null),e(a)};b.addEventListener("touchmove",f,!1),b.addEventListener("touchend",e,!1),b.addEventListener("touchcancel",e,!1)}else o.show(a,b),n&&(b.addEventListener("touchend",o.hide,!1),b.addEventListener("touchcancel",o.hide,!1)),b.addEventListener("mouseup",o.hide,!1),b.addEventListener("mouseleave",o.hide,!1)}var k=k||{},l=document.querySelectorAll.bind(document),m=Object.prototype.toString,n="ontouchstart"in window,o={duration:750,delay:200,show:function(a,b,c){if(2===a.button)return!1;b=b||this;var d=document.createElement("div");d.className="waves-ripple waves-rippling",b.appendChild(d);var e=f(b),h=a.pageY-e.top,i=a.pageX-e.left,j="scale("+b.clientWidth/100*3+")",k="translate(0,0)";c&&(k="translate("+c.x+"px, "+c.y+"px)"),"touches"in a&&a.touches.length&&(h=a.touches[0].pageY-e.top,i=a.touches[0].pageX-e.left),d.setAttribute("data-hold",Date.now()),d.setAttribute("data-x",i),d.setAttribute("data-y",h),d.setAttribute("data-scale",j),d.setAttribute("data-translate",k);var l={top:h+"px",left:i+"px"};d.classList.add("waves-notransition"),d.setAttribute("style",g(l)),d.classList.remove("waves-notransition"),l["-webkit-transform"]=j+" "+k,l["-moz-transform"]=j+" "+k,l["-ms-transform"]=j+" "+k,l["-o-transform"]=j+" "+k,l.transform=j+" "+k,l.opacity="1";var m="mousemove"===a.type?2500:o.duration;l["-webkit-transition-duration"]=m+"ms",l["-moz-transition-duration"]=m+"ms",l["-o-transition-duration"]=m+"ms",l["transition-duration"]=m+"ms",d.setAttribute("style",g(l))},hide:function(a,b){b=b||this;for(var c=b.getElementsByClassName("waves-rippling"),d=0,e=c.length;e>d;d++)h(a,b,c[d])}},p={input:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");c.className=a.className+" waves-input-wrapper",a.className="waves-button-input",b.replaceChild(c,a),c.appendChild(a);var d=window.getComputedStyle(a,null),e=d.color,f=d.backgroundColor;c.setAttribute("style","color:"+e+";background:"+f),a.setAttribute("style","background-color:rgba(0,0,0,0);")}},img:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");b.replaceChild(c,a),c.appendChild(a)}}},q={touches:0,allowEvent:function(a){var b=!0;return/^(mousedown|mousemove)$/.test(a.type)&&q.touches&&(b=!1),b},registerEvent:function(a){var b=a.type;"touchstart"===b?q.touches+=1:/^(touchend|touchcancel)$/.test(b)&&setTimeout(function(){q.touches&&(q.touches-=1)},500)}};return k.init=function(a){var b=document.body;a=a||{},"duration"in a&&(o.duration=a.duration),"delay"in a&&(o.delay=a.delay),n&&(b.addEventListener("touchstart",j,!1),b.addEventListener("touchcancel",q.registerEvent,!1),b.addEventListener("touchend",q.registerEvent,!1)),b.addEventListener("mousedown",j,!1)},k.attach=function(a,b){a=e(a),"[object Array]"===m.call(b)&&(b=b.join(" ")),b=b?" "+b:"";for(var c,d,f=0,g=a.length;g>f;f++)c=a[f],d=c.tagName.toLowerCase(),-1!==["input","img"].indexOf(d)&&(p[d](c),c=c.parentElement),c.className+=" waves-effect"+b},k.ripple=function(a,b){a=e(a);var c=a.length;if(b=b||{},b.wait=b.wait||0,b.position=b.position||null,c)for(var d,g,h,i={},j=0,k={type:"mousedown",button:1},l=function(a,b){return function(){o.hide(a,b)}};c>j;j++)if(d=a[j],g=b.position||{x:d.clientWidth/2,y:d.clientHeight/2},h=f(d),i.x=h.left+g.x,i.y=h.top+g.y,k.pageX=i.x,k.pageY=i.y,o.show(k,d),b.wait>=0&&null!==b.wait){var m={type:"mouseup",button:1};setTimeout(l(m,d),b.wait)}},k.calm=function(a){a=e(a);for(var b={type:"mouseup",button:1},c=0,d=a.length;d>c;c++)o.hide(b,a[c])},k.displayEffect=function(a){console.error("Waves.displayEffect() has been deprecated and will be removed in future version. Please use Waves.init() to initialize Waves effect"),k.init(a)},k}); | ||
//# sourceMappingURL=waves.min.js.map |
{ | ||
"name": "node-waves", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Click effect insipired by Google Material Design", | ||
@@ -5,0 +5,0 @@ "author": "Alfiana E. Sibuea <alfian.sibuea@gmail.com>", |
/*! | ||
* Waves v0.7.1 | ||
* Waves v0.7.2 | ||
* http://fian.my.id/Waves | ||
@@ -182,42 +182,58 @@ * | ||
} | ||
}, | ||
} | ||
}; | ||
/** | ||
* Collection of wrapper for HTML element that only have single tag | ||
* like <input> and <img> | ||
*/ | ||
var TagWrapper = { | ||
// Wrap <input> tag so it can perform the effect | ||
input: function(element) { | ||
var parent = element.parentNode; | ||
// Little hack to make <input> can perform waves effect | ||
wrapInput: function(elements) { | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
return; | ||
} | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
// Put element class and style to the specified parent | ||
var wrapper = document.createElement('i'); | ||
wrapper.className = element.className + ' waves-input-wrapper'; | ||
element.className = 'waves-button-input'; | ||
var element = elements[i]; | ||
// Put element as child | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
if (element.tagName.toLowerCase() === 'input') { | ||
// Apply element color and background color to wrapper | ||
var elementStyle = window.getComputedStyle(element, null); | ||
var color = elementStyle.color; | ||
var backgroundColor = elementStyle.backgroundColor; | ||
var parent = element.parentNode; | ||
wrapper.setAttribute('style', 'color:' + color + ';background:' + backgroundColor); | ||
element.setAttribute('style', 'background-color:rgba(0,0,0,0);'); | ||
}, | ||
// Wrap <img> tag so it can perform the effect | ||
img: function(element) { | ||
var parent = element.parentNode; | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
continue; | ||
} | ||
// If input already have parent just pass through | ||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) { | ||
return; | ||
} | ||
// Put element class and style to the specified parent | ||
var wrapper = document.createElement('i'); | ||
wrapper.className = element.className + ' waves-input-wrapper'; | ||
element.className = 'waves-button-input'; | ||
// Put element as child | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
// Apply element color and background color to wrapper | ||
var elementStyle = window.getComputedStyle(element, null); | ||
var color = elementStyle.color; | ||
var backgroundColor = elementStyle.backgroundColor; | ||
wrapper.setAttribute('style', 'color:' + color + ';background:' + backgroundColor); | ||
element.setAttribute('style', 'background-color:rgba(0,0,0,0);'); | ||
} | ||
} | ||
// Put element as child | ||
var wrapper = document.createElement('i'); | ||
parent.replaceChild(wrapper, element); | ||
wrapper.appendChild(element); | ||
} | ||
}; | ||
/** | ||
@@ -428,5 +444,2 @@ * Hide the effect and remove the ripple. Must be | ||
//Wrap input inside <i> tag | ||
Effect.wrapInput($$('.waves-effect')); | ||
if (isTouchAvailable) { | ||
@@ -448,2 +461,3 @@ body.addEventListener('touchstart', showEffect, false); | ||
Waves.attach = function(elements, classes) { | ||
elements = getWavesElements(elements); | ||
@@ -457,8 +471,11 @@ | ||
var element; | ||
var element, tagName; | ||
for (var i = 0, len = elements.length; i < len; i++) { | ||
element = elements[i]; | ||
if (element.tagName.toLowerCase() === 'input') { | ||
Effect.wrapInput([element]); | ||
tagName = element.tagName.toLowerCase(); | ||
if (['input', 'img'].indexOf(tagName) !== -1) { | ||
TagWrapper[tagName](element); | ||
element = element.parentElement; | ||
@@ -465,0 +482,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
234029
2427