-
Notifications
You must be signed in to change notification settings - Fork 6
/
stickjaw.min.js
1 lines (1 loc) · 7.39 KB
/
stickjaw.min.js
1
'use strict';var SJ_HLW_SELECTOR='[data-proportion-h]',SJ_WLH_SELECTOR='[data-proportion-w]',SJ_HLT_SELECTOR='[data-proportion-targer-h]',SJ_WLT_SELECTOR='[data-proportion-targer-w]',SJ_PROPORTION_TARGET='[data-proportion-target]',SJ_OHLT_SELECTOR='[data-proportion-targer-oh]',SJ_OWLT_SELECTOR='[data-proportion-targer-ow]',SJ_PROPORTION_TARGET_OH='[data-proportion-target-oh]',SJ_PROPORTION_TARGET_OW='[data-proportion-target-ow]',SJ_ALO_SELECTOR='[data-parent-alo]',SJ_targetId,SJ_targetHeight,SJ_targetWidth,SJ_arr=[],SJ=function(a){return this.settings=a,this.hlwRawSelector=SJ_HLW_SELECTOR,this.wlhRawSelector=SJ_WLH_SELECTOR,this.hltRawSelector=SJ_HLT_SELECTOR,this.wltRawSelector=SJ_WLT_SELECTOR,this.rawProportionTarget=SJ_PROPORTION_TARGET,this.ohltRawSelector=SJ_OHLT_SELECTOR,this.rawProportionTargetOH=SJ_PROPORTION_TARGET_OH,this.owltRawSelector=SJ_OWLT_SELECTOR,this.rawProportionTargetOW=SJ_PROPORTION_TARGET_OW,this.proportionTarget=this.rawProportionTarget.substring(1,this.rawProportionTarget.length-1),this.proportionTargetOH=this.rawProportionTargetOH.substring(1,this.rawProportionTargetOH.length-1),this.proportionTargetOW=this.rawProportionTargetOW.substring(1,this.rawProportionTargetOW.length-1),this.aloRawSelector=SJ_ALO_SELECTOR,this.switch=!1,this.hystory=[],void 0!=a&&void 0!==a.settings.writeHystory&&!0===a.settings.writeHystory&&this.resizeWindow(),this.Init(this.settings),void 0!=a&&void 0!==a.settings.windowResize&&!0===a.settings.windowResize&&this.resizeWindow(),this};SJ.prototype.Init=function(a){if(!(a!=void 0))this.hlw(),this.wlh(),this.hlt(),this.wlt(),this.alo(),this.ohlt(),this.owlt();else if(void 0!=a.options){var b=Object.keys(a.options);SJ=this;for(var c=0;c<b.length;c+=1)l=b[c],!0===a.options[l]&&SJ[l]()}else this.hlw(),this.wlh(),this.hlt(),this.wlt(),this.ohlt(),this.owlt(),this.alo()},SJ.prototype.hlwMethodElement=function(a,b){a.style.height=a.offsetWidth*b+'px'},SJ.prototype.hlwMethod=function(a,b){if(null!==a){var c=document.getElementById(a);this.hlwMethodElement(c,b)}},SJ.prototype.hlw=function(){this.selector=this.hlwRawSelector.substring(1,this.hlwRawSelector.length-1),this.list=document.querySelectorAll(this.hlwRawSelector),this.event='hlw',this.length=this.list.length;for(var a=0;a<this.length;a+=1)this.dadgerSelector=this.wlhRawSelector.substring(1,this.wlhRawSelector.length-1),void 0==this.list[a].getAttribute(this.dadgerSelector)?this.list[a].style.height=this.list[a].offsetWidth*this.list[a].getAttribute(this.selector)+'px':console.error('\u041D\u0435\u043B\u044C\u0437\u044F \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C '+this.dadgerSelector),this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),null);return this},SJ.prototype.wlhMethodElement=function(a,b){a.style.width=a.offsetHeight*b+'px'},SJ.prototype.wlhMethod=function(a,b){if(null!==a){var c=document.getElementById(a);this.wlhMethodElement(c,b)}},SJ.prototype.wlh=function(){this.selector=this.wlhRawSelector.substring(1,this.wlhRawSelector.length-1),this.list=document.querySelectorAll(this.wlhRawSelector),this.event='wlh',this.length=this.list.length;for(var a=0;a<this.length;a+=1)this.dadgerSelector=this.hlwRawSelector.substring(1,this.hlwRawSelector.length-1),void 0==this.list[a].getAttribute(this.dadgerSelector)?this.list[a].style.width=this.list[a].offsetHeight*this.list[a].getAttribute(this.selector)+'px':console.error('\u041D\u0435\u043B\u044C\u0437\u044F \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C '+this.dadgerSelector),this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),null);return this},SJ.prototype.hltMethod=function(a,b,c){element=document.getElementById(a),targetHeight=document.getElementById(c).offsetHeight,element.style.height=targetHeight*b+'px'},SJ.prototype.hlt=function(){this.selector=this.hltRawSelector.substring(1,this.hltRawSelector.length-1),this.list=document.querySelectorAll(this.hltRawSelector),this.event='hlt',this.length=this.list.length;for(var a=0;a<this.length;a+=1)SJ_targetId=this.list[a].getAttribute(this.proportionTarget),SJ_targetHeight=document.querySelector('#'+SJ_targetId).offsetHeight,this.list[a].style.height=SJ_targetHeight*this.list[a].getAttribute(this.selector)+'px',this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),document.querySelector('#'+SJ_targetId));return this},SJ.prototype.wltMethod=function(a,b,c){element=document.getElementById(a),targetHeight=document.getElementById(c).offsetWidth,element.style.width=targetHeight*b+'px'},SJ.prototype.wlt=function(){this.selector=this.wltRawSelector.substring(1,this.wltRawSelector.length-1),this.list=document.querySelectorAll(this.wltRawSelector),this.event='wlt',this.length=this.list.length;for(var a=0;a<this.length;a+=1)SJ_targetId=this.list[a].getAttribute(this.proportionTarget),SJ_targetWidth=document.querySelector('#'+SJ_targetId).offsetWidth,this.list[a].style.width=SJ_targetWidth*this.list[a].getAttribute(this.selector)+'px',this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),document.querySelector('#'+SJ_targetId));return this},SJ.prototype.alo=function(){function a(g){for(var k=g,m=0;m<k.length;m+=1)SJ_arr[m]=k[m].offsetHeight;e=function(n){return Math.max.apply(null,n)}(SJ_arr);for(var m=0;m<k.length;m+=1)k[m].style.height=e+'px',SJ.writeHystory(k[m],'alo',e+'px',null)}this.selector=this.aloRawSelector.substring(1,this.aloRawSelector.length-1),this.list=document.querySelectorAll(this.aloRawSelector);for(var b=this.list,c=0;c<b.length;c+=1)if('default'===b[c].getAttribute(this.selector)){var d=document.querySelectorAll('['+this.selector+'="default"] > *'),e=0;a(d)}else{var f=b[c].getAttribute(this.selector),d=document.querySelectorAll(this.aloRawSelector+' > '+f),e=0;a(d)}return this},SJ.prototype.ohlt=function(){this.selector=this.ohltRawSelector.substring(1,this.ohltRawSelector.length-1),this.list=document.querySelectorAll(this.ohltRawSelector),this.event='ohlt',this.length=this.list.length;for(var a=0;a<this.length;a+=1)SJ_targetId=this.list[a].getAttribute(this.proportionTargetOH),SJ_targetHeight=document.querySelector('#'+SJ_targetId).offsetHeight,this.list[a].style.height=SJ_targetHeight*this.list[a].getAttribute(this.selector)+'px',this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),document.querySelector('#'+SJ_targetId));return this},SJ.prototype.owlt=function(){this.selector=this.owltRawSelector.substring(1,this.owltRawSelector.length-1),this.list=document.querySelectorAll(this.owltRawSelector),this.event='owtl',this.length=this.list.length;for(var a=0;a<this.length;a+=1)SJ_targetId=this.list[a].getAttribute(this.proportionTargetOW),SJ_targetWidth=document.querySelector('#'+SJ_targetId).offsetWidth,this.list[a].style.width=SJ_targetWidth*this.list[a].getAttribute(this.selector)+'px',this.writeHystory(this.list[a],this.event,this.list[a].getAttribute(this.selector),document.querySelector('#'+SJ_targetId));return this},SJ.prototype.loop=function(a){null==a?this.Init(this.settings):a.map(function(b){var c=b.method+'Method';SJ[c](b.currentTarget,b.proportion,b.target)})},SJ.prototype.resizeWindow=function(){SJ_windowObject=this.settings,window.addEventListener('resize',function(){SJ.Init(SJ_windowObject)},SJ,SJ_windowObject)},SJ.prototype.writeHystory=function(a,b,c,d){this.settings.settings.writeHystory!==void 0&&!0===this.settings.settings.writeHystory&&this.hystory.push({element:a,methode:b,proportion:c,target:d})};