1'use strict'; 2(function (factory) { 3 if (typeof define === 'function' && define.amd) { 4 // AMD. Register as an anonymous module. 5 define(['jquery'], factory); 6 } else if (typeof exports === 'object') { 7 // Node/CommonJS style for Browserify 8 module.exports = factory; 9 } else { 10 // Browser globals 11 factory(jQuery); 12 } 13}( 14/** 15 * @param {jQuery} $ 16 */ 17function($) { 18 let globDur = 400; 19 let globEse = 'cubic-bezier(.4,0,.2,1)'; 20 let stylFix = $(document.createElement('style')).appendTo(document.head).addClass('ripple-custom-config') 21 let stylSet = $(document.createElement('style')).appendTo(document.head).addClass('ripple-coordinates') 22 let stylObj = {}; 23 let stylPos = {}; 24 let nowRuns = 0; 25 let pointerdown = ('ontouchstart') ? 'mousedown touchstart' : 'mousedown' 26 $.fn.ripple = function(opt) { 27 // console.log('RIPPLE :: ', this); in document.body 28 let def = { 29 ease: globEse, 30 duration: globDur, 31 onclick: false, 32 disable: false, 33 type: 'pointed', // 'centered' | 'icon' | 'trigger' | 'target' 34 size: 1, 35 }; 36 let selectorIDX = 'ripple-'+Math.round(Math.random()*1E9); 37 // element setup 38 $(this).each((i,v) => { 39 let $elm = $(v); 40 // jQuery('v').prop() 41 if(typeof opt === 'string') { 42 switch(opt) { 43 case 'onmousedown': 44 $elm[0].rippleVars.ondown = true; 45 $elm 46 .unbind('click', $elm[0].rippleVars.callback) 47 .bind(pointerdown, $elm[0].rippleVars.callback); 48 break; 49 case 'onclick': 50 $elm[0].rippleVars.ondown = false; 51 $elm 52 .unbind(pointerdown, $elm[0].rippleVars.callback) 53 .bind('click', $elm[0].rippleVars.callback); 54 break; 55 case 'enable': 56 $elm 57 .removeClass('ripple-disabled') 58 .bind($elm[0].rippleVars.ondown ? pointerdown : 'click', $elm[0].rippleVars.callback); 59 break; 60 case 'disable': 61 $elm 62 .addClass('ripple-disabled') 63 // .removeClass('ripple') 64 .unbind('click', $elm[0].rippleVars.callback) 65 .unbind(pointerdown, $elm[0].rippleVars.callback); 66 break; 67 case 'ripple': 68 $elm 69 .removeClass('ripple-disabled') 70 .trigger($elm[0].rippleVars.ondown ? 'mousedown' : 'click'); 71 break; 72 case 'dismiss': 73 $elm 74 .removeClass('ripple') 75 break; 76 default: 77 // $elm.bind('click', $elm[0].rippleVars.callback); 78 break; 79 } 80 return; 81 } 82 def = $.extend(def, opt); 83 def.duration = (typeof def.duration == 'number' ? def.duration : ((/^([2-9]|10)x$/i).test(def.duration) ? def.duration.toLowerCase() : globDur)) 84 let rePos = e => { 85 // console.log(e); 86 // let rid = 'ripple-running-'+Math.round(Math.random()*1E9); 87 // debugger 88 let rc, x1, y1, px, py; 89 if(e.type == 'touchstart') { 90 rc = e.currentTarget.getBoundingClientRect() 91 x1 = e.originalEvent.touches[0].clientX - rc.left 92 y1 = e.originalEvent.touches[0].clientY - rc.top 93 px = e.originalEvent.touches[0].pageX 94 py = e.originalEvent.touches[0].pageY 95 } else { 96 x1 = e.offsetX 97 y1 = e.offsetY 98 px = e.pageX 99 py = e.pageY 100 } 101 if((x1 == 0 && y1 == 0) || ($elm[0].rippleVars.type == 'trigger')) stylPos[$elm[0].rippleVars.rid] = ``; // && e.pageX == 0 && e.pageY == 0 && e.clientX == 0 && e.clientY == 0 102 else { 103 let off = $elm.offset() 104 stylPos[$elm[0].rippleVars.rid] = ` 105 .ripple-element.${ $elm[0].rippleVars.rid }.ripple::after { 106 left: ${ 100*((px-off.left)/$elm.outerWidth())-100 }%; 107 top: ${ 100*((py-off.top)/$elm.outerHeight()) }%; 108 }`; 109 } 110 let stylTxt = ''; 111 for(let s in stylPos) { 112 stylTxt += stylPos[s]; 113 } 114 stylSet.html(stylTxt); 115 }; 116 $elm[0].rippleVars = { 117 idx: selectorIDX, 118 rid: 'ripple-running-'+Math.round(Math.random()*1E9), 119 size: parseInt(Math.min(Math.max(def.size, 1), 10)), 120 ease: def.ease, 121 type: def.type, 122 time: ((/^([2-9]|10)x$/i).test(def.duration) ? parseInt(def.duration)*globDur : def.duration), 123 timeout: 0, 124 ondown: !def.onclick, 125 callback: (e) => { 126 // console.log(e.offsetX, e.offsetY, $elm.outerWidth(), $elm.outerHeight()); 127 if(e.type == 'mousedown' && 'ontouchstart' in document.body) return; 128 if($elm.hasClass('ripple-disabled')) { 129 return; 130 } 131 if($elm[0].rippleVars.timeout == 0) { // means NOT running 132 nowRuns++; 133 if($elm[0].rippleVars.type == 'pointed') rePos(e); 134 $elm.addClass('ripple'); 135 /* 136 $elm[0].rippleVars.timeout = 1; 137 $elm.one('animationend', e => { 138 // console.log('ripple END!!!'); 139 $elm.removeClass('ripple'); 140 $elm[0].rippleVars.timeout = 0; 141 nowRuns--; 142 if(nowRuns <= 0) { 143 nowRuns = 0; 144 stylPos = {}; 145 stylSet.html(''); 146 } 147 }) 148 //*/ 149 } else { // running 150 /*clearTimeout(_it.rippleVars.timeout);*/ 151 $elm.removeClass('ripple'); 152 if($elm[0].rippleVars.type == 'pointed') rePos(e); 153 requestAnimationFrame(()=>{ 154 $elm.addClass('ripple'); 155 }) 156 /*$elm[0].rippleVars.timeout = setTimeout(()=>{ 157 // console.log('ripple OUT!!! 2'); 158 $elm.removeClass('ripple'); 159 clearTimeout($elm[0].rippleVars.timeout); 160 $elm[0].rippleVars.timeout = 0; 161 },$elm[0].rippleVars.time)*/ 162 } 163 // cut from if block above 164 clearTimeout($elm[0].rippleVars.timeout); 165 $elm[0].rippleVars.timeout = setTimeout(()=>{ 166 // console.log('ripple OUT!!!'); 167 $elm.removeClass('ripple'); 168 $elm[0].rippleVars.timeout = 0; 169 nowRuns--; 170 if(nowRuns <= 0) { 171 nowRuns = 0; 172 stylPos = {}; 173 stylSet.html(''); 174 } 175 }, $elm[0].rippleVars.time+16) 176 } 177 }; 178 let iconClass = ''; 179 switch($elm[0].rippleVars.type) { 180 case 'icon': 181 iconClass = ' ripple-icon' 182 break; 183 case 'icon-big': 184 iconClass = ' ripple-icon-big' 185 break; 186 case 'icon-small': 187 iconClass = ' ripple-icon-small' 188 break; 189 default: 190 break; 191 } 192 $elm 193 // .addClass('ripple-element'+iconClass+(def.disable ? ' ripple-disabled' : '')+' '+$elm[0].rippleVars.idx) 194 .addClass('ripple-'+(def.type == 'trigger' ? 'trigger' : 'element')+iconClass+(def.disable ? ' ripple-disabled' : '')+' '+$elm[0].rippleVars.idx) 195 .addClass($elm[0].rippleVars.rid) 196 .addClass($elm[0].rippleVars.size >= 2 && $elm[0].rippleVars.size <= 10 ? 'ripple-anim-'+$elm[0].rippleVars.size+'x' : '') 197 .addClass((/^([2-9]|10)x$/i).test(def.duration) ? 'ripple-time-'+parseInt(def.duration)+'x' : '') 198 .bind($elm[0].rippleVars.ondown ? pointerdown : 'click', $elm[0].rippleVars.callback) 199 .click(function cl(e) { 200 if($elm[0].rippleVars.timeout == 0 && $elm[0].rippleVars.ondown && e.offsetY == 0 && e.offsetX == 0) $elm.trigger('mousedown', e); 201 }) 202 }); // each 203 if(typeof opt === 'object') { 204 def = $.extend(def, opt); 205 // if(def.duration !== globDur || def.ease !== globEse || def.size !== 1) stylObj[selectorIDX] = 206 if((def.duration !== globDur && (/^([2-9]|10)x$/i).test(def.duration) === false) || def.ease !== globEse) stylObj[selectorIDX] = 207 `.ripple-${ def.type == 'trigger' ? 'trigger' : 'element' }.${ selectorIDX }.ripple${ def.type == 'trigger' ? ' .ripple-target' : '' }::after {`+ 208 // `${ def.size !== 1 ? 'animation-name: rippleanim-'+def.size+'x;' : '' }`+ 209 `${ def.ease !== globEse ? 'animation-timing-function: '+def.ease+';' : '' }`+ 210 `${ (def.duration !== globDur && (/^([2-9]|10)x$/i).test(def.duration) === false) ? 'animation-duration: '+def.duration+'ms;' : '' }`+ 211 `}` 212 let stylTxt = ''; 213 for(let s in stylObj) {
214 stylTxt += stylObj[s]; 215 } 216 stylFix.html(stylTxt); 217 } 218 return this; 219 } 220 // $.fn.rippleDismiss = function(ondown=false) { 221 // return _it; 222 // } 223 return $; 224}));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.