UNPKG

vesh-cli

Version:

码农村nodejs版本VESH框架脚手架搭建器

1 lines 30.6 kB
!function(V,$,W,M){W.Box=function(t,e){var n=this;V.inherit.apply(n,[W.Control2,[W.Control2.merge({template:'<div class="c_box"></div>',vm:{border:1},render:{border:function(t){n.node.css({border:"solid "+t+"px;"})},key:function(t){n.node.css({"text-align":"center","line-height":n.node.height()+"px","vertical-align":"middle",margin:"0 auto",minwidth:"40px",minheight:"20px"}).html(t)}}},"string"==typeof t?{template:t}:t||{})]])},W.FillControl=function(t,e){var n=this,a={};V.inherit.apply(n,[W.Control2,[W.Control2.merge({template:'<div class="c_fillControl"></div>',vm:e,event:{init:function(t){a.firstHide&&(a.timeshow=window.setTimeout(function(){delete a.firstHide,t.show()},500))},click:function(t){n.node.on("click","input",function(t){var e=$(this);return n.call("click",{e:t,vid:e.val(),name:e.attr("name")}),!1}),n.node.on("click","a,.click",function(t){var e=$(this);return!(!e.attr("href")||!(0<=e.attr("href").indexOf("http://")||0<=e.attr("href").indexOf("https://")))||(n.call("click",{e:t,vid:e.attr("vid")||e.attr("href"),name:e.attr("name")}),!1)})}},render:{value:function(t){n.node.html(V.format(a.content,t))},visible:function(t){!t&&a.timeshow&&(window.clearTimeout(a.timeshow),delete a.timeshow),t?n.node.show():n.node.hide()}}},"string"==typeof t?{template:t}:t||{})]]),a.replaceNode=n.replaceNode,n.replaceNode=function(){a.content=n.node.html(),"none".eq(n.node.css("display"))||(n.node.hide(),a.firstHide=!0),a.replaceNode.apply(n,arguments)}},W.History=function(t,e){var a=this;V.inherit.apply(a,[W.Control2,[W.Control2.merge({template:'<span class="c_history" style="display:none;"></span>',onLoad:{change:function(t,e,n){$(window).bind("hashchange",function(t){a.lastAction!=window.location.hash.replace(/#/g,"")&&(a.call("change",{lastAction:a.lastAction}),a.lastAction=a.get().history.pop())})}},fill:function(){return{hash:window.location.hash.replace(/#/g,"")}},render:{visible:{override:!0,Method:!1},invisible:{override:!0,Method:!1},add:function(t){var e;a.get().history=a.get().history||[],window.location.hash&&(0<(e=a.get().history).length&&e[e.length-1]==window.location.hash.replace(/#/g,"")||e.push(window.location.hash.replace(/#/g,""))),t=t.replace(/#/g,""),a.lastAction!=t&&(window.location.hash=t,a.lastAction=t)},remove:function(t){a.get().history.pop()},back:function(t){a.get().history&&0<a.get().history.length&&t&&(window.location.hash=a.get().history.pop())}}},"string"==typeof t?{template:t}:t||{})]])},W.TextBox=function(t,e){var a=this;V.inherit.apply(a,[W.Control2,[W.Control2.merge({template:'<span class="c_textBox"><span style="display:none;"></span><input type="text"/></span>',vm:e||{},onLoad:{init:function(t){a.txt=t.find("span:first"),a.input=t.find("input:first")},hover:function(t,e,n){a.node.hover(function(){0<a.node.parents("[disabled]").length||a.call("Hover",{hover:!0})},function(){0<a.node.parents("[disabled]").length||a.call("Hover",{hover:!1})})},blur:function(t,e,n){a.input&&a.input.blur(function(){a.call("blur")})}},fill:function(){var t=$.trim(a.input.val());return{text:t=t==a.vm.data.title||t==a.vm.data.error?"":t,value:t}},render:{enable:function(t,e){t?a.input.removeAttr("disabled"):a.input.attr("disabled","disabled")},title:function(t,e){t&&a.input.attr("placeholder",e.placeholder||t).attr("title",t)},value:{override:!0,as:["text"],Method:function(t,e){a.input.val(t||"")}},name:{override:!0,Method:function(t,e){a.input.attr("name",t)}},key:{override:!0,Method:function(t,e){a.txt.html(t).show()}},size:{override:!0,Method:function(t,e){a.input.attr("size",t)}},kind:{override:!0,Method:function(t,e){a.input.attr("type",t)}},maxlength:{override:!0,Method:function(t,e){a.input.attr("maxlength",t)}}}},"string"==typeof t?{template:t}:t||{})]]),a.animate=function(t,e){a._animate(t,a.input,e)}},W.RadioBox=function(t,e){var n=this;V.inherit.apply(n,[W.TextBox,[W.Control2.merge({template:'<span class="c_radioBox"><span style="display:none;"></span><input type="radio"/></span>',vm:e,fill:{override:!0,Method:function(){var t={checked:!!n.input.attr("checked")};return t.value=t.checked,t}},render:{value:{override:!0,as:["checked"],Method:function(t){V.setChecked(n.input,!!t)}}}},"string"==typeof t?{template:t}:t||{})]])},W.CheckBox=function(t,e){V.inherit.apply(this,[W.RadioBox,[t||'<span class="c_checkBox"><span style="display:none;"></span><input type="checkbox"/></span>',e]])},W.Select=function(path,vm){var _=this,__={setValue:function(t){_.vm.data.preValue=_.input.val(),_.input.val(t)}};V.inherit.apply(_,[W.TextBox,[W.Control2.merge({template:'<span class="c_select"><span style="display:none;"></span><select></select></span>',vm:vm,onLoad:{init:function(t,e,n){_.txt=t.find("span:first"),_.input=t.find("select:first"),_.events.error&&_.get().validate&&_.validate(_,_.input)}},fill:{override:!0,Method:function(){return{value:_.input.val()}}},render:{values:function(v){var Ba;v="string"==V.getType(v)?eval("("+v+")"):v,V.userAgent.ie7||V.userAgent.ie8?V.forC(v,function(t,e){var n=document.createElement("OPTION");_.input.get(0).appendChild(n),_.vm.data.value&&_.vm.data.value==e&&(n.selected=!0),n.innerText=t,n.v=e},function(){V.once(function(){_.input.css("display","none").css("display","block")})},!0):(Ba=V.sb(),V.forC(v,function(t,e){Ba.appendFormat('<option value="{value}">{key}</option>',{key:t,value:e})},function(){_.input.empty().html(Ba.clear()),Ba=null,_.vm.data.value&&__.setValue(_.vm.data.value)},!0))},value:__.setValue}},"string"==typeof path?{template:path}:path||{})]]),_.animate=function(t,e){_._animate(t,_.input,e)}},W.RadioList=function(t,e,n){var a=this,o={content:e||'<li><span class="c_RadioList_li"><input name="{name}" type="radio" value="{value}"/><span>{key}</span></span></li>'};a.paths=":radio",V.inherit.apply(a,[W.Control2,[W.Control2.merge({template:'<span class="c_RadioList"><span></span><ul></ul></span>',vm:n,fill:function(){return{value:a.ul.find(a.paths+":checked").val()}},onLoad:{init:function(t){a.title=t.find("span:first"),a.ul=t.find("ul"),a.vm.data.name=V.getValue(a.vm.data.name,a.paths.trim(":")+V.random())}},render:{key:function(t){a.title.html(t)},values:function(t){var n=V.sb();V.forC(t,function(t,e){n.appendFormat(o.content,{key:t,value:e,name:a.vm.data.name})},function(){a.ul.empty().append(n.toString()),n.clear(),n=null,a.vm.data.value&&a.setValue(a.vm.data.value)})},value:function(t){a.setValue(t)},name:function(t){a.node.find(a.paths).attr("name",t)},enable:function(t){t?a.node.find(a.paths).removeAttr("disabled"):a.node.find(a.paths).attr("disabled","disabled")}}},"string"==typeof t?{template:t}:t||{})]]),a.setValue=function(t){V.setChecked(a.ul.find(a.paths+":checked"),!1),V.setChecked(a.ul.find(a.paths+'[value="'+t+'"]'),!0)},a.animate=function(t,e){a._animate(t,a.ul,e)}},W.CheckList=function(t,e,n){var a=this;V.inherit.apply(a,[W.RadioList,[W.Control2.merge({template:'<div class="c_CheckList"><span></span><ul></ul></div>',vm:n,fill:{override:!0,Method:function(){return 0<a.ul.children().length?{value:(n=[],a.ul.find(":checkbox:checked").each(function(t,e){n.push($(e).val())}),n.join(","))}:{};var n}}},"string"==typeof t?{template:t}:t||{}),V.getValue(e,'<li><span class="c_CheckList_li"><input name="{name}" type="checkbox" value="{value}"/><span>{key}</span></span></li>')]]),a.paths=":checkbox",a.setValue=function(t){t=V.getValue(t+"",""),V.setChecked(a.ul.find(":checkbox:checked"),!1),V.each(t.split(","),function(t){V.setChecked(a.ul.find(':checkbox[value="'+t+'"]'),!0)})},a.animate=function(t,e){a._animate(t,a.sel,e)}},W.Hidden=function(t,e){var n=this;V.inherit.apply(n,[W.Control2,[W.Control2.merge({template:'<input class="c_hidden" type="hidden"/>',vm:e,fill:function(){return{val:n.node.val()}},render:{value:function(t){n.node.val(t)},name:function(t){n.node.attr("name",value)}}},"string"==typeof t?{template:t}:t||{})]])},W.PasswordBox=function(t,e){var a=this;V.inherit.apply(a,[W.TextBox,[W.Control2.merge({template:'<span class="c_passwordBox"><span style="display:none;"></span><input type="password"/></span>',vm:e,render:{passchar:{as:["alt"],Method:function(t,e,n){a.input.attr(n,t)}}}},"string"==typeof t?{template:t}:t||{})]])},W.Button=function(t,e){V.inherit.apply(this,[W.TextBox,[W.Control2.merge({template:'<span class="c_button"><span style="display:none;"></span><input type="button"/></span>',vm:e,fill:{override:!0,Method:function(){return{}}}},"string"==typeof t?{template:t}:t||{})]])},W.Submit=function(t,e){V.inherit.apply(this,[W.Button,[t||'<span class="c_submit"><span style="display:none;"></span><input type="submit"/></span>',e]])},W.Reset=function(t,e){V.inherit.apply(this,[W.Button,[t||'<span class="c_reset"><span style="display:none;"></span><input type="reset"/></span>',e]])},W.Form=function(t,e){var a=this;V.inherit.apply(a,[W.Control2,[W.Control2.merge({template:'<form method="get" action="" class="c_form"></form>',vm:{data:{enctype:"multipart/form-data"}},onLoad:{init:function(t){a.cons=[],t.find("[_]").each(function(t,e){a.cons.push($(e).attr("id"))}),a.controls=a.controls||[]}},fill:function(){var e,n={};return a.vm.data.value={},a.cons&&(a.cons&&a.controls&&!a.cons.length&&a.controls.length&&(e=[],a.controls.forEach(function(t){e.push(t.vm.id)}),a.cons=e),a.cons.length&&a.cons.forEach(function(t){var e=(a.vms?a.vms[t]:null)||a.parent.vms[t]||a.page.vms[t];e&&"fill"!=e.nodeName&&(n[t]=e.update().value)})),{value:n}},render:{method:function(t){a.node.attr("method",t)},action:function(t){a.node.attr("action",t)},target:function(t){a.node.attr("target",t)},name:function(t){a.node.attr("name",t)},enctype:function(t){a.node.attr("enctype",t)},valid:{override:!0,Method:function(t){var e;t&&(e=[],a.cons.length?e=Array.prototype.slice.apply(a.cons):a.controls.forEach(function(t){e.push(t.vm.id)}),V.whileC2(function(){return e.shift()},function(t,e){t=(a.vms?a.vms[t]:null)||a.parent.vms[t]||a.page.vms[t];t&&t.update({valid:e})},function(){t(a.fill().value)}))}},enable:function(e){a.cons.length||a.controls.forEach(function(t){a.cons.push(t.vm.id)}),V.each(a.cons,function(t){t=(a.vms?a.vms[t]:null)||a.parent.vms[t]||a.page.vms[t];t&&t.update({enable:e})})},value:function(n){a.node[0].reset(),a.vm.data.value=n||{},a.cons.length||a.controls.forEach(function(t){a.cons.push(t.vm.id)}),V.each(a.cons,function(t){var e=(a.vms?a.vms[t]:null)||a.parent.vms[t]||a.page.vms[t];e&&("fill"==e.nodeName?e.update({value:n||{}}):e.update({value:n[t]||!1}))})},clear:function(){a.cons=[],a.clearControl()}}},"string"==typeof t?{template:t,vm:e}:t||{})]])},W.Panel=function(t,e,n,a,o){var i=this,l={hasRender:!1,status:{panelid:"p"+V.random(),transform:{tx:0,ty:0,scale:1,angle:0,rx:0,ry:0,rz:0},callevent:{value:!1},limit:V.getValue(n,0),limitBack:V.getValue(a,!0),lock:o||!1,startX:0,startY:0,moving:!1,panelaction:{}}};V.inherit.apply(i,[W.Control2,[W.Control2.merge({template:'<div class="c_panel"></div>',vm:V.merge(e||{},{data:{_:!0}}),onLoad:{init:function(t){t.attr("panelid",l.status.panelid)},finally:function(t){var n=[];V.forC(l.status.panelaction,function(t,e){e&&n.push(t)},function(){i.node.attr("panelaction",n.join(","))},!0)},up:function(t){V.merge(l.status.panelaction,{vol:!0,down:!0},!0)},down:function(){V.merge(l.status.panelaction,{vol:!0,down:!0},!0)},upout:function(){V.merge(l.status.panelaction,{vol:!0,upout:!0},!0)},downout:function(){V.merge(l.status.panelaction,{vol:!0,downout:!0},!0)},left:function(){V.merge(l.status.panelaction,{hor:!0,left:!0},!0)},right:function(){V.merge(l.status.panelaction,{hor:!0,right:!0},!0)},leftout:function(){V.merge(l.status.panelaction,{hor:!0,leftout:!0},!0)},rightout:function(){V.merge(l.status.panelaction,{hor:!0,rightout:!0},!0)},scale:function(){l.status.panelaction.pinch=!0},rotate:function(){l.status.panelaction.rotate=!0},dblclick:function(){l.status.panelaction.dblclick=!0}},render:{width:function(t){i.node.width(t)},height:function(t){i.node.height(t)},_:{finally:!0,Method:function(t){l.hasRender||(l.document=$(document),l.hasRender=!0,l.finalMove=!1,l.mc=new Hammer.Manager(i.node[0]),l.mc.add(new Hammer.Pan({threshold:0,pointers:0})),(l.status.panelaction.rotate||l.status.panelaction.pinch)&&l.mc.add(new Hammer.Rotate({threshold:0})).recognizeWith(l.mc.get("pan")),l.status.panelaction.pinch&&l.mc.add(new Hammer.Pinch({threshold:0})).recognizeWith([l.mc.get("pan"),l.mc.get("rotate")]),l.status.panelaction.dblclick&&l.mc.add(new Hammer.Tap({event:"doubletap",taps:2})),l.mc.on(V.format("panleft panright panup pandown {pinorrot} {doubleclick}",{pinorrot:l.status.panelaction.rotate?"rotatestart rotatemove rotateend rotate":l.status.panelaction.pinch?"pinchstart pinchmove pinchend":"",doubleclick:l.status.panelaction.dblclick?"doubletap":""}),function(e){var n=e.target.hasAttribute("panelid")?$(e.target):$(e.target).parents("[panelid]:first");if((n=0<n.length?n:null)&&n.attr("panelid")==l.status.panelid&&function(){switch(e.type){case"panright":case"panleft":case"swiperight":case"swipeleft":l.status.panelaction.hor||(n=0<(n=$(n).parents("[panelid]:first")).length?n:null);break;case"panup":case"pandown":case"swipeup":case"swipedown":l.status.panelaction.vol||(n=0<(n=$(n).parents("[panelid]:first")).length?n:null);break;case"pinchstart":case"pinchmove":case"pinchin":case"pinchout":case"pinchend":l.status.panelaction.pinch||(n=0<(n=$(n).parents("[panelid]:first")).length?n:null);break;case"rotate":case"rotatestart":case"rotatemove":case"rotateend":l.status.panelaction.rotate||(n=0<(n=$(n).parents("[panelid]:first")).length?n:null);break;case"doubletap":l.status.panelaction.dblclick||(n=0<(n=$(n).parents("[panelid]:first")).length?n:null)}}(),n&&n.attr("panelid")!=l.status.panelid&&""!=n.attr("panelaction")&&function(){var t=n.attr("panelaction").split(",");switch(e.type){case"panright":case"panleft":case"swiperight":case"swipeleft":if(0<=$.inArray("hor",t))return;break;case"panup":case"pandown":case"swipeup":case"swipedown":if(0<=$.inArray("vol",t))return;break;case"pinchstart":case"pinchmove":case"pinchin":case"pinchout":case"pinchend":if(0<=$.inArray("pinch",t))return;break;case"rotate":case"rotatestart":case"rotatemove":case"rotateend":if(0<=$.inArray("rotate",t))return;break;case"doubletap":if(0<=$.inArray("dblclick",t));}}(),!l.finalMove){switch(i.node.removeClass("animate").find(".animate").removeClass("animate"),e.type){case"panright":case"swiperight":l.status.hor&&!l.rotating&&!l.finalMove&&Math.abs(e.deltaX)>Math.abs(e.deltaY)?(l.status.lastAction="right",l.finalMove=i.onRight(e,l.status)):!l.status.hor&&document.body.clientWidth<document.body.scrollWidth&&(0==l.status.startX&&(l.status.startX=l.document.scrollLeft()),l.document.scrollLeft(Math.max(l.status.startX-e.deltaX,0)));break;case"panleft":case"swipeleft":l.status.hor&&!l.rotating&&!l.finalMove&&Math.abs(e.deltaX)>Math.abs(e.deltaY)?(l.status.lastAction="left",l.finalMove=i.onLeft(e,l.status)):!l.status.hor&&document.body.clientWidth<document.body.scrollWidth&&(0==l.status.startX&&(l.status.startX=l.document.scrollLeft()),l.document.scrollLeft(Math.min(l.status.startX-e.deltaX,document.body.scrollWidth-document.body.clientWidth)));break;case"panup":case"swipeup":l.status.vol&&!l.rotating&&!l.finalMove&&Math.abs(e.deltaX)<Math.abs(e.deltaY)?(l.status.lastAction="up",l.finalMove=i.onUp(e,l.status)):!l.status.vol&&window.screen.availHeight<document.body.scrollHeight&&(0==l.status.startY&&(l.status.startY=l.document.scrollTop()),l.document.scrollTop(Math.max(l.status.startY-e.deltaY,document.body.scrollHeight-document.body.clientHeight)));break;case"pandown":case"swipedown":l.status.vol&&!l.rotating&&!l.finalMove&&Math.abs(e.deltaX)<Math.abs(e.deltaY)?(l.status.lastAction="down",l.finalMove=i.onDown(e,l.status)):!l.status.vol&&window.screen.availHeight<document.body.scrollHeight&&(0==l.status.startY&&(l.status.startY=l.document.scrollTop()),l.document.scrollTop(Math.min(l.status.startY-e.deltaY,document.body.scrollHeight)));break;case"pinchstart":l.rotating=!0;case"pinchmove":l.finalMove=i.onScale(e,l.status);break;case"pinchin":case"pinchout":l.status.lastAction="scale",l.scale=e.scale;break;case"pinchend":l.rotating=!1;break;case"rotate":case"rotatestart":l.rotating=!0;case"rotatemove":l.status.lastAction="rotate",l.status.angle=e.angle,l.finalMove=i.onRotate(e,l.status),l.pinch&&(l.status.scale=e.scale);break;case"rotateend":l.rotating=!1}l.finalMove&&V.once(function(){l.status.callevent.value&&i.onFinal(l.status),i.onBackAnimate(i.node,l.status),l.status.callevent.value=!1,V.once(function(){l.finalMove=!1},300)},100)}}),l.mc.on("hammer.input",function(t){t.isFinal&&!l.finalMove&&V.once(function(){l.status.callevent.value&&i.onFinal(l.status),i.onBackAnimate(i.node,l.status),l.status.callevent.value=!1,V.once(function(){l.finalMove=!1},300)},100)}))}}}},"string"==typeof t?{template:t}:t||{})]]),i.status=l.status,i.am=function(e,n,t){l.status.lock||l.moving||(V.once(function(){l.status.transform=V.merge(l.status.transform,n);var t=V.format("translate3d({tx}px,{ty}px,0px) scale({scale},{scale}) rotate3d(0,0,0,{angle}deg)",l.status.transform);e.css("webkitTransform",t).css("mozTransform",t).css("transform",t),l.moving=!1},t||1e3/60),l.moving=!0)},i.onLeft=function(t,e){if(!(Math.abs(t.deltaX)<Math.max(30,i.node.width()*e.limit)))return e.callevent.value=!0,e.limitBack;i.am(i.node,{tx:e.left||e.leftout?t.deltaX:Math.max(0,t.deltaX),ty:0})},i.onRight=function(t,e){if(!(Math.abs(t.deltaX)<Math.max(30,i.node.width()*e.limit)))return e.callevent.value=!0,e.limitBack;i.am(i.node,{tx:e.right||e.rightout?t.deltaX:Math.max(0,t.deltaX),ty:0})},i.onUp=function(t,e){if(!(Math.abs(t.deltaY)<Math.max(30,i.node.height()*e.limit)))return e.callevent.value=!0,e.limitBack;i.am(i.node,{ty:e.up||e.upout?t.deltaY:Math.max(0,t.deltaY),tx:0})},i.onDown=function(t,e){if(!(Math.abs(t.deltaY)<Math.max(30,i.node.height()*e.limit)))return e.callevent.value=!0,e.limitBack;i.am(i.node,{ty:e.down||e.downout?t.deltaY:Math.min(0,t.deltaY),tx:0})},i.onScale=function(t,e){Math.abs(t.scale-1)<e.limit?i.am(i.node,{scale:t.scale}):e.callevent.value=!0},i.onRotate=function(t,e){i.am(i.node,{angle:t.rotation,scale:e.pinch?t.scale:1}),e.callevent.value=!0},i.onBackAnimate=function(t,e){switch(V.merge(e.transform,{tx:0,ty:0,scale:1,angle:0,rx:0,ry:0,rz:0,startX:0,startY:0},!0),e.lastAction){case"left":e.leftout&&(e.transform.tx=-1*screen.width);break;case"right":e.rightout&&(e.transform.tx=screen.width);break;case"up":e.upout&&(e.transform.ty=-1*screen.height);break;case"down":e.downout&&(e.transform.ty=screen.height)}var n=V.format("translate3d({tx}px,{ty}px,0px) scale({scale},{scale}) rotate3d({rx},{ry},{rz},{angle}deg)",e.transform);switch(t.addClass("animate").css("webkitTransform",n).css("mozTransform",n).css("transform",n),e.lastAction){case"left":e.leftout&&t.hide();break;case"right":e.rightout&&t.hide();break;case"up":e.upout&&t.hide();break;case"down":e.downout&&t.hide()}},i.onFinal=function(t){switch(t.lastAction){case"left":t.leftout?i.call("leftout"):i.call("left");break;case"right":t.rightout?i.call("rightout"):i.call("right");break;case"up":t.upout?i.call("upout"):i.call("up");break;case"down":t.downout?i.call("downout"):i.call("down");break;case"scale":i.call("scale",{scale:t.scale});break;case"rotate":t.pinch&&1!=t.scale&&i.call("scale",{scale:t.scale}),i.call("rotate",{angle:t.angle})}}},W.PagePanel=function(t,e,n,a,o){var i=this,l={};V.inherit.apply(i,[t.getTypeByAppName("VESH.view","panel"),[W.Control2.merge({template:'<div style="overflow:hidden;" class="c_pagePanel"><div style="display:none;"></div></div>',vm:V.merge(V.getValue(n,{}),{data:{direction:"hor",value:0},onLeft:function(t,e){i.change(!0)},onRight:function(t,e){i.change(!1)},onUp:function(t,e){i.change(!0)},onDown:function(t,e){i.change(!1)}},!0),onLoad:{init:function(t){switch(t.removeClass("animate"),i.panel=t.find("div:first"),i.children=i.panel.siblings(),i.length=i.children.length,i.children.css("overflow","hidden").css("position","relative"),i.children.addClass("noactive"),i.panel.append(i.children),i.get().direction){case"vol":i.vol=!0,delete i.events.left,delete i.events.right,i.panel.css("height",i.length+"00%").css("width","100%"),i.children.css("height",Math.floor(1e4/i.length)/100+"%").css("width","100%");break;case"hor":default:i.hor=!0,delete i.events.up,delete i.events.down,i.panel.css("width",i.length+"00%").css("height","100%"),i.children.css("width",Math.floor(1e4/i.length)/100+"%").css("height","100%").css("float","left")}},change:{override:!0,Method:function(){}}},render:{value:function(t){i.change(t,!0,l.first),l.first=!1},lock:{as:["freeze"],Method:function(t){i.lock=t}},height:{override:!0,Method:function(){}},width:{override:!0,Method:function(){}},add:function(t){var e=V.newEl("div").prependTo(i.panel);i.addControl(V.newEl("div").appendTo(e),t),i.vm.update({values:Array.prototype.slice.apply(i.panel.children())})},remove:function(t){var e;i.vms[t]&&(e=i.vms[t].v.node.parents("div.noactive"),i.removeControl(t),e&&e.remove(),i.vm.data.values=Array.prototype.slice.apply(i.panel.children()))},values:function(t){var e=V.newEl("div","","").css("display","none;");V.each(t,function(t){e.append(t)},function(){i.children=e.children(),i.length=i.children.length,i.children.css("overflow","hidden").css("position","relative"),i.children.addClass("noactive"),i.panel.empty().append(i.children).show(),i.vol?(i.panel.css("height",i.length+"00%").css("width","100%"),i.children.css("height",Math.floor(1e4/i.length)/100+"%").css("width","100%")):(i.panel.css("width",i.length+"00%").css("height","100%"),i.children.css("width",Math.floor(1e4/i.length)/100+"%").css("height","100%"),i.children.css("float","left")),i.change(NaN==i.index?0:i.index,!0,!0),e.remove()})}}},"string"==typeof e?{template:e}:e||{}),null,a||.2,o||!0,!0]]),l.onLoad=i.onLoad,l.render=i.render,i.lock=!1,l.onLeft=i.onLeft,i.onLeft=function(t,e){if(!i.vol&&!i.lock)return l.distance=Math.abs(t.deltaX),l.onLeft(t,e)},l.onRight=i.onRight,i.onRight=function(t,e){if(!i.vol&&!i.lock)return l.distance=Math.abs(t.deltaX),l.onRight(t,e)},l.onUp=i.onUp,i.onUp=function(t,e){if(!i.hor&&!i.lock)return l.distance=Math.abs(t.deltaY),l.onUp(t,e)},l.onDown=i.onDown,i.onDown=function(t,e){if(!i.hor&&!i.lock)return l.distance=Math.abs(t.deltaY),l.onDown(t,e)},l.first=!0,i.change=function(t,e,n){t=(""+t).toLowerCase();var a=Math.ceil(l.distance/(i.hor?i.node.width():i.node.height()));t=Math.max(0,Math.min(i.children.length-1,"true"==t?i.get().value+a:"false"==t?i.get().value-a:parseInt(t))),i.index=t,e||t==parseInt(i.get().value)?i.onBackAnimate(i.panel,i.status,n):i.call("change",{value:t})},i.onBackAnimate=function(t,e,n){V.once(function(){V.merge(e.transform,{tx:0,ty:0,scale:1,angle:0,rx:0,ry:0,rz:0,startX:0,startY:0},!0),i.hor?e.transform.tx-=i.node.width()*i.index:i.vol&&(e.transform.ty-=i.node.height()*i.index);var t=V.format("translate3d({tx}px,{ty}px,0px) scale({scale},{scale}) rotate3d({rx},{ry},{rz},{angle}deg)",e.transform);n||i.panel.addClass("animate"),i.panel.css("webkitTransform",t).css("mozTransform",t).css("transform",t).show()},10)}},W.ScrollPanel=function(t,e,n,a,o){var i=this,l={};V.inherit.apply(i,[t.getTypeByAppName("VESH.view","panel"),[W.Control2.merge({template:'<div style="overflow:hidden;" class="c_scrollPanel"><div style="display:none;"></div></div>',vm:V.merge(V.getValue(n,{}),{data:{direction:"vol",_:!0},onLeft:function(t,e){i.call("next")},onRight:function(t,e){i.call("reload")},onUp:function(t,e){i.call("next")},onDown:function(t,e){i.call("reload")}},!0),onLoad:{init:function(t){switch(t.removeClass("animate"),i.panel=t.find("div:first"),i.children=i.panel.siblings(),i.length=i.children.length,i.value=Math.max(0,Math.min(i.children.length,parseInt(i.value))),i.children.css("position","relative"),i.children.addClass("noactive"),i.panel.append(i.children),i.get().direction){case"vol":i.vol=!0,delete i.events.left,delete i.events.right,i.panel.css("width","100%"),i.children.css("width","100%");break;case"hor":default:i.hor=!0,delete i.events.up,delete i.events.down,i.panel.css("height","100%"),i.children.width()&&i.panel.width(i.children.width()),i.children.css("height","100%").css("float","left")}},next:{as:["reload"],override:!0,Method:function(){}}},render:{value:function(t){i.onValue([t],function(t){switch(typeof t){case"string":i.panel.empty().append(t);break;case"object":i.panel.empty(),i.addControl(null,t)}})},values:function(t){i.onValue(t,function(t){switch(typeof t){case"string":i.panel.empty().append(t);break;case"object":V.isArray(t)||(t=[t]),i.panel.empty(),V.each(t,function(t){i.addControl(null,t)})}})},addvalues:function(t){i.onValue(t,function(t){switch(typeof t){case"string":i.panel.append(t);break;case"object":V.isArray(t)||(t=[t]),V.each(t,function(t){i.addControl(null,t)})}})},top:function(t){t&&(i.get().top=!1,i.onBackAnimate(i.node,V.merge(i.status,{transform:{tx:0,ty:0}},!0)))},bottom:function(t){t&&(i.get().bottom=!1,i.onBackAnimate(i.node,V.merge(i.status,{transform:{tx:i.status.vol?0:i.node.width()-i.panel.width(),ty:i.status.hor?0:i.node.height()-i.panel.height()}},!0)))},lock:{as:["freeze"],Method:function(t){i.lock=t}},_:function(){i.panel.show()}}},"string"==typeof e?{template:e}:e||{}),null,a||.2,o||!0,!0]]),i.lock=!1,V.merge(i.status.transform,{x:0,y:0},!0),i.onLeft=function(t,e){if(!i.vol&&!i.lock){l.distance=Math.abs(t.deltaX);var n=e.transform.x+t.deltaX;if(n<i.node.width()-5-i.panel.width()&&(e.callevent.value=!0),!(n>Math.min(-e.limit,i.node.width()-e.limit-i.panel.width())))return e.limitBack;i.am(i.panel,{tx:e.left||e.leftout?n:Math.max(0,t.deltaX),ty:0})}},i.onRight=function(t,e){if(!i.vol&&!i.lock){l.distance=Math.abs(t.deltaX);var n=e.transform.x+t.deltaX;if(5<n&&(e.callevent.value=!0),!(n<e.limit))return e.limitBack;i.am(i.panel,{tx:e.right||e.rightout?n:Math.max(0,t.deltaX),ty:0})}},i.onUp=function(t,e){if(!i.hor&&!i.lock){l.distance=Math.abs(t.deltaY);var n=e.transform.y+t.deltaY;if(n<i.node.height()-5-i.panel.height()&&(e.callevent.value=!0),!(n>Math.min(-e.limit,i.node.height()-e.limit-i.panel.height())))return e.limitBack;i.am(i.panel,{ty:e.up||e.upout?n:Math.max(0,t.deltaY),tx:0})}},i.onDown=function(t,e){if(!i.hor&&!i.lock){l.distance=Math.abs(t.deltaY);var n=e.transform.y+t.deltaY;if(5<n&&(e.callevent.value=!0),!(n<e.limit))return e.limitBack;i.am(i.panel,{ty:e.down||e.downout?n:Math.max(0,t.deltaY),tx:0})}},i.onScale=function(t,e){Math.abs(t.scale-1)*Math.min(i.node.width(),i.node.height)<e.limit?i.am(i.panel,{scale:t.scale}):e.callevent.value=!0},i.addControl=function(t,e){i.controls||(i.controls=[],i.vs={},i.vms={},i.models=i.vms);var n=i.middler.getObjectByAppName(W.APP,e.type);if(!n)throw new Error("配置文件中没有找到对象类型定义:"+e.type);t=t||V.newEl("div").appendTo(i.panel),n.init(i,t,e.data),n.page=i.page,i.controls.push(n);t=V.getValue(e.id,V.random());if(!i.vs[t])return i.vs[t]=n,V.inherit.apply(e,[M.Control,[]]),i.vms[t]=e,n.bind(e),e;V.showException("控件id为"+id+"的子控件已经存在,请更换id名")},i.onValue=function(t,e){V.isArray(t)||(t=[t]);var n=V.sb();V.each(t,function(t){"string"==typeof t?n.append(t):n.append(V.toJsonString(t))},function(){e(n.clear()),n=null})},i.onBackAnimate=function(t,e){V.once(function(){var t;e.vol&&e.transform.ty<0&&e.transform.ty>i.node.height()-i.panel.height()?e.transform.y=e.transform.ty:e.hor&&e.transform.tx<0&&e.transform.tx>i.node.width()-i.panel.width()?e.transform.x=e.transform.tx:(V.merge(e.transform,{tx:Math.min(0,Math.max(i.node.width()-i.panel.width(),e.transform.tx)),ty:Math.min(0,Math.max(i.node.height()-i.panel.height(),e.transform.ty)),scale:1,angle:0,rx:0,ry:0,rz:0,startX:0,startY:0},!0),V.merge(e.transform,{x:e.transform.tx,y:e.transform.ty},!0),t=V.format("translate3d({tx}px,{ty}px,0px) scale({scale},{scale}) rotate3d({rx},{ry},{rz},{angle}deg)",e.transform),i.panel.addClass("animate").css("webkitTransform",t).css("mozTransform",t).css("transform",t).show())},10)}},W.Router=function(t,e){var o=this,i={};V.inherit.apply(o,[W.Panel,[W.Control2.merge({template:'<div style="display:none;" class="c_router"></div>',vm:e||{data:{showaction:"fadeInRight",hideaction:"fadeOutRight"}},onLoad:{change:{override:!0,Method:function(){}},finally:function(t){o.reload(t),0<i.cons.length&&(o.vm.data.next=i.cons[0])}},render:{value:function(t){i.his.push(t),o.change(t)},next:function(n){n&&n!=o.vm.data.value&&(i.vms[n]&&n!=o.vm.data.value||function(){for(var t=!1,e=0;e<i.cons.length;e++)t&&V.getValue(i.vms[i.cons[e]].canActive,!0)?(n=i.cons[e],e=i.cons.length):i.cons[e]==o.vm.data.value&&(t=!0)}(),i.his.push(n),o.change(n))},prev:function(e){var n,a;e&&e!=o.vm.data.value&&(i.vms[e]&&e!=o.vm.data.value?(n=!1,a=Array.prototype.slice.call(i.his,0),V.whileC(function(){return n?null:a.pop()},function(t){t==e&&(n=!0,i.his=a,i.his.push(e))},function(){n&&V.getValue(i.vms[value].data.canActive,!0)||(value=null)},!0)):(value=null,V.whileC(function(){return null==value?i.his.pop():null},function(t){V.getValue(i.vms[t].data.canActive,!0)&&(value=t)},null,!0)),o.change(value))},size:function(e){e&&e.width&&e.height&&(o.node.width(e.width),o.node.height(e.height),o.node.children().width(e.width),o.node.children().height(e.height),V.each(i.cons,function(t){i.vms[t].call("size",{size:e})}))},clear:function(t){V.forC(i.vms,function(t,e){o.removeControl(t)},function(){i.cons=[],i.vms={},i.his=[],delete o.vm.data.value})},values:{as:"addvalues",Method:function(t){V.next(function(t,e){"values"==key.toLowerCase()?V.forC(i.vms,function(t,e){o.removeControl(t)},function(){i.cons=[],i.vms={},i.his=[],delete o.vm.data.value,e()}):e()},function(t,e){V.each(value,function(t){t.onActive=t.onActive||function(t,e){e.update({show:t.showaction}),V.once(function(){e.call("showed")},500)},o.addControl(null,t)},function(){o.reload(o.node),0<i.cons.length&&o.render({size:o.vm.data.size,value:i.cons[0]})})})}}}},"string"==typeof t?{template:t,vm:e}:t||{})]]),i.render=o.render,i.onLoad=o.onLoad,o.reload=function(t){i.cons=[],i.vms={},i.his=[],t.children().each(function(t,e){var n=$(e).hide().attr("id");n?(e=o.vms[n]||o.parent.vms[n]||o.page.vms[n])?(i.cons.push(n),i.vms[n]=e,V.merge(e,{canActive:e.data&&e.data.canActive||!0,isActive:!1},!0)):V.showException("不是VJ控件,自动隐藏"):V.showException("没有找到id,自动隐藏")})},o.change=function(t){t&&(o.vm.data.value&&(i.vms[o.vm.data.value].update({hide:o.vm.data.hideaction,isActive:!1}),i.vms[o.vm.data.value].call("inactive")),i.vms[t]&&(i.vms[t].update({showaction:o.vm.data.showaction,isActive:!0}),i.vms[t].call("active")),o.call("change",{value:t,visible:!0}))}}}(VJ,jQuery,VJ.view,VJ.viewmodel);