-
Notifications
You must be signed in to change notification settings - Fork 1
/
arcMenu.min.js
1 lines (1 loc) · 2.77 KB
/
arcMenu.min.js
1
(function(){function a(m){if((typeof m.menu_btn)==="string"){this.menu_btn=document.getElementById(m.menu_btn)}else{if(typeof m.menu_btn==="object"){this.menu_btn=m.menu_btn}}if((typeof m.menu_box)==="string"){this.menu_box=document.getElementById(m.menu_box)}else{if(typeof m.menu_box==="object"){this.menu_box=m.menu_box}}this.start_angel=m.start_angel||0;this.total_angel=m.total_angel||90;this.distance=m.distance||120;this.isRotate=m.isRotate||false;this.isActive=m.isActive||false;this.isStraight=m.isStraight||false;this.active=false;this.openEvt=m.openEvt||function(){};this.closeEvt=m.closeEvt||function(){};var n=this;this.menus=(function(){var q=n.menu_box.childNodes;var o=[];for(var p=0;p<q.length;p++){if(q[p].nodeType===k){o.push(q[p])}}return o})();this.segment=[];this.angle=parseInt(this.total_angel)/(this.menus.length-1)||0;this.menu_angle=[];this.x=[];this.y=[];this.init()}a.prototype.open=function(){if((typeof this.openEvt)==="function"){this.openEvt()}this.setPos("open");this.active=true};a.prototype.close=function(){if((typeof this.closeEvt)==="function"){this.closeEvt()}this.setPos("close");this.active=false};a.prototype.init=function(){var n=this;b(n.menus,function(o,p){n.menu_angle[p]=(parseInt(n.start_angel)+n.angle*(p))*Math.PI/180;n.x[p]=(n.distance*Math.sin(n.menu_angle[p]));n.y[p]=(n.distance*Math.cos(n.menu_angle[p]));if(n.isStraight){n.segment[p]=(n.distance/n.menus.length)*(p+1);n.x[p]=n.segment[p]*Math.sin((parseInt(n.start_angel)+n.total_angel)*Math.PI/180);n.y[p]=n.segment[p]*Math.cos((parseInt(n.start_angel)+n.total_angel)*Math.PI/180)}if(n.isRotate){o.style.webkitTransform="rotate("+(90-n.menu_angle[p]*180/Math.PI)+"deg)"}});n.menu_btn.removeEventListener("click",m,false);var m=function(o){o.stopPropagation();if(n.active){n.close()}else{n.open()}};n.menu_btn.addEventListener("click",m,false);if(window.FastClick){FastClick.attach(n.menu_btn)}if(n.isActive){n.setPos("open");n.active=!n.active}};a.prototype.setPos=function(n){var m=this.menus;var o=this;b(m,function(q,p){q.style.left=(n==="close"?0:o.y[p])+"px";q.style.top=(n==="close"?0:-o.x[p])+"px"})};window.arcMenu=a;var c=Array.isArray;function e(m){return typeof m==="function"}function f(m){return typeof m==="string"}function d(n){if(n==null){return false}var m=n.length;if(n.nodeType===k&&m){return true}return f(n)||c(n)||m===0||typeof m==="number"&&m>0&&(m-1) in n}function b(r,o,m){var p,q;if(r){if(e(r)){for(p in r){if(p!="prototype"&&p!="length"&&p!="name"&&(!r.hasOwnProperty||r.hasOwnProperty(p))){o.call(m,r[p],p,r)}}}else{if(c(r)||d(r)){var n=typeof r!=="object";for(p=0,q=r.length;p<q;p++){if(n||p in r){o.call(m,r[p],p,r)}}}else{if(r.forEach&&r.forEach!==b){r.forEach(o,m,r)}else{for(p in r){if(r.hasOwnProperty(p)){o.call(m,r[p],p,r)}}}}}}return r}var k=1;var g=2;var l=3;var h=8;var i=9;var j=11})();