UNPKG

vesh-vj

Version:

VESH's JavaScript Framework

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,onLoad:{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")}),V.stopProp(t),!1}),n.node.on("click","a,.click",function(t){var e=$(this);return!(!e.attr("href")||!(e.attr("href").indexOf("http://")>=0||e.attr("href").indexOf("https://")>=0))||(n.call("click",{e:t,vid:e.attr("vid")||e.attr("href"),name:e.attr("name")}),V.stopProp(t),!1)})}},render:{value:function(t){n.node.html(V.format(a.content,t))}}},"string"==typeof t?{template:t}:t||{})]]),a.replaceNode=n.replaceNode,n.replaceNode=function(){a.content=n.node.html(),a.replaceNode.apply(n,arguments)}},W.History=function(t,e){var n=this;V.inherit.apply(n,[W.Control2,[W.Control2.merge({template:'<span class="c_history" style="display:none;"></span>',onLoad:{change:function(t,e,a){$(window).bind("hashchange",function(t){n.lastAction!=window.location.hash.replace(/#/g,"")&&(n.call("change",{lastAction:n.lastAction}),n.lastAction=n.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){n.get().history=n.get().history||[],window.location.hash&&function(){var t=n.get().history;!(t.length>0&&t[t.length-1]==window.location.hash.replace(/#/g,""))&&t.push(window.location.hash.replace(/#/g,""))}(),t=t.replace(/#/g,""),n.lastAction!=t&&function(){window.location.hash=t,n.lastAction=t}()},remove:function(t){n.get().history.pop()},back:function(t){n.get().history&&n.get().history.length>0&&t&&(window.location.hash=n.get().history.pop())}}},"string"==typeof t?{template:t}:t||{})]])},W.TextBox=function(t,e){var n=this;V.inherit.apply(n,[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){n.txt=t.find("span:first"),n.input=t.find("input:first")},hover:function(t,e,a){n.node.hover(function(){n.node.parents("[disabled]").length>0||n.call("Hover",{hover:!0})},function(){n.node.parents("[disabled]").length>0||n.call("Hover",{hover:!1})})},blur:function(t,e,a){n.input&&n.input.blur(function(){n.call("blur")})}},fill:function(){var t=$.trim(n.input.val());return t=t==n.vm.data.title||t==n.vm.data.error?"":t,{text:t,value:t}},render:{enable:function(t,e){t?n.input.removeAttr("disabled"):n.input.attr("disabled","disabled")},title:function(t,e){n.input.attr("placeholder",t||"")},value:{override:!0,as:["text"],Method:function(t,e){"boolean"!=typeof t&&"false"!=(""+t).toLowerCase()&&"undefined"!=(""+t).toLowerCase()?function(){n.input.val(t),!(!n.vm.data.title||V.isValid(t))&&n.input.val(n.vm.data.title)}():function(){n.input.val("")}()}},name:{override:!0,Method:function(t,e){n.input.attr("name",t)}},key:{override:!0,Method:function(t,e){n.txt.text(t).show()}},size:{override:!0,Method:function(t,e){n.input.attr("size",t)}},kind:{override:!0,Method:function(t,e){n.input.attr("type",t)}},maxlength:{override:!0,Method:function(t,e){n.input.attr("maxlength",t)}}}},"string"==typeof t?{template:t}:t||{})]]),n.animate=function(t,e){n._animate(t,n.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){var n=this;V.inherit.apply(n,[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.find(":selected").val(),_.input.find(":selected").attr("selected",!1),_.input.find('option[value="'+t+'"]').attr("selected",!0)}};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.find("option:selected").val()}}},render:{values:function(v){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):function(){var t=V.sb();V.forC(v,function(e,n){t.appendFormat('<option value="{value}">{key}</option>',{key:e,value:n})},function(){_.input.empty().html(t.clear()),t=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 e=V.sb();V.forC(t,function(t,n){e.appendFormat(o.content,{key:t,value:n,name:a.vm.data.name})},function(){a.ul.empty().append(e.toString()),e.clear(),e=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 a.ul.children().length>0?{value:function(){var t=[];return a.ul.find(":checkbox:checked").each(function(e,n){t.push($(n).val())}),t.join(",")}()}:{}}}},"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 n=this;V.inherit.apply(n,[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,a){n.input.attr(a,t)}}}},"string"==typeof t?{template:t}:t||{})]])},W.Button=function(t,e){var n=this;V.inherit.apply(n,[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){var n=this;V.inherit.apply(n,[W.Button,[t||'<span class="c_submit"><span style="display:none;"></span><input type="submit"/></span>',e]])},W.Reset=function(t,e){var n=this;V.inherit.apply(n,[W.Button,[t||'<span class="c_reset"><span style="display:none;"></span><input type="reset"/></span>',e]])},W.Form=function(t,e){var n=this;V.inherit.apply(n,[W.Control2,[W.Control2.merge({template:'<form method="get" action="" class="c_form"></form>',vm:{data:{enctype:"multipart/form-data"}},onLoad:{init:function(t){n.cons=[],t.find("[_]").each(function(t,e){n.cons[n.cons.length]=$(e).attr("id")})}},fill:function(){var t={};return n.vm.data.value={},n.cons&&(n.cons=n.cons&&n.controls&&!n.cons.length&&n.controls.length?n.controls.map(function(t){return t.vm.id}):n.cons,n.cons.length&&n.cons.forEach(function(e){var a=(n.vms?n.vms[e]:null)||n.parent.vms[e]||n.page.vms[e];a&&"fill"!=a.nodeName&&(t[e]=a.update().value)})),{value:t}},render:{method:function(t){n.node.attr("method",t)},action:function(t){n.node.attr("action",t)},target:function(t){n.node.attr("target",t)},name:function(t){n.node.attr("name",t)},enctype:function(t){n.node.attr("enctype",t)},valid:function(t){t&&function(){var e=n.cons.length?Array.prototype.slice.apply(n.cons):n.controls.map(function(t){return t.vm.id});V.whileC2(function(){return e.shift()},function(t,e){var a=(n.vms?n.vms[t]:null)||n.parent.vms[t]||n.page.vms[t];a&&a.update({valid:e})},function(){t(n.fill().value)})}()},enable:function(t){n.cons=n.cons.length?n.cons:n.controls.map(function(t){return t.vm.id}),V.each(n.cons,function(e){var a=(n.vms?n.vms[e]:null)||n.parent.vms[e]||n.page.vms[e];a&&a.update({enable:t})})},value:function(t){n.node[0].reset(),n.vm.data.value=t||{},n.cons=n.cons.length?n.cons:n.controls.map(function(t){return t.vm.id}),V.each(n.cons,function(e){var a=(n.vms?n.vms[e]:null)||n.parent.vms[e]||n.page.vms[e];a&&("fill"==a.nodeName?a.update({value:t||{}}):a.update({value:t[e]||!1}))})},clear:function(){n.cons=[],n.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 e=[];V.forC(l.status.panelaction,function(t,n){n&&(e[e.length]=t)},function(){i.node.attr("panelaction",e.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&&function(){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(t){var e=t.target.hasAttribute("panelid")?$(t.target):$(t.target).parents("[panelid]:first");if(e=e.length>0?e:null,e&&e.attr("panelid")==l.status.panelid&&function(){switch(t.type){case"panright":case"panleft":case"swiperight":case"swipeleft":!l.status.panelaction.hor&&function(){e=$(e).parents("[panelid]:first"),e=e.length>0?e:null}();break;case"panup":case"pandown":case"swipeup":case"swipedown":!l.status.panelaction.vol&&function(){e=$(e).parents("[panelid]:first"),e=e.length>0?e:null}();break;case"pinchstart":case"pinchmove":case"pinchin":case"pinchout":case"pinchend":!l.status.panelaction.pinch&&function(){e=$(e).parents("[panelid]:first"),e=e.length>0?e:null}();break;case"rotate":case"rotatestart":case"rotatemove":case"rotateend":!l.status.panelaction.rotate&&function(){e=$(e).parents("[panelid]:first"),e=e.length>0?e:null}();break;case"doubletap":!l.status.panelaction.dblclick&&function(){e=$(e).parents("[panelid]:first"),e=e.length>0?e:null}()}}(),e&&e.attr("panelid")!=l.status.panelid&&""!=e.attr("panelaction")&&function(){var n=e.attr("panelaction").split(",");switch(t.type){case"panright":case"panleft":case"swiperight":case"swipeleft":if($.inArray("hor",n)>=0)return;break;case"panup":case"pandown":case"swipeup":case"swipedown":if($.inArray("vol",n)>=0)return;break;case"pinchstart":case"pinchmove":case"pinchin":case"pinchout":case"pinchend":if($.inArray("pinch",n)>=0)return;break;case"rotate":case"rotatestart":case"rotatemove":case"rotateend":if($.inArray("rotate",n)>=0)return;break;case"doubletap":if($.inArray("dblclick",n)>=0);}}(),!l.finalMove){switch(i.node.removeClass("animate").find(".animate").removeClass("animate"),t.type){case"panright":case"swiperight":l.status.hor&&!l.rotating&&!l.finalMove&&Math.abs(t.deltaX)>Math.abs(t.deltaY)?(l.status.lastAction="right",l.finalMove=i.onRight(t,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-t.deltaX,0)));break;case"panleft":case"swipeleft":l.status.hor&&!l.rotating&&!l.finalMove&&Math.abs(t.deltaX)>Math.abs(t.deltaY)?(l.status.lastAction="left",l.finalMove=i.onLeft(t,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-t.deltaX,document.body.scrollWidth-document.body.clientWidth)));break;case"panup":case"swipeup":l.status.vol&&!l.rotating&&!l.finalMove&&Math.abs(t.deltaX)<Math.abs(t.deltaY)?(l.status.lastAction="up",l.finalMove=i.onUp(t,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-t.deltaY,document.body.scrollHeight-document.body.clientHeight)));break;case"pandown":case"swipedown":l.status.vol&&!l.rotating&&!l.finalMove&&Math.abs(t.deltaX)<Math.abs(t.deltaY)?(l.status.lastAction="down",l.finalMove=i.onDown(t,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-t.deltaY,document.body.scrollHeight)));break;case"pinchstart":l.rotating=!0;case"pinchmove":l.finalMove=i.onScale(t,l.status);break;case"pinchin":case"pinchout":l.status.lastAction="scale",l.scale=t.scale;break;case"pinchend":l.rotating=!1;break;case"rotate":case"rotatestart":l.rotating=!0;case"rotatemove":l.status.lastAction="rotate",l.status.angle=t.angle,l.finalMove=i.onRotate(t,l.status),l.pinch&&(l.status.scale=t.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&&function(){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(t,e,n){l.status.lock||l.moving||(V.once(function(){l.status.transform=V.merge(l.status.transform,e);var n=V.format("translate3d({tx}px,{ty}px,0px) scale({scale},{scale}) rotate3d(0,0,0,{angle}deg)",l.status.transform);t.css("webkitTransform",n).css("mozTransform",n).css("transform",n),l.moving=!1},n||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(){}},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&&function(){i.get().top=!1,i.onBackAnimate(i.node,V.merge(i.status,{transform:{tx:0,ty:0}},!0))}()},bottom:function(t){t&&function(){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(n>5&&(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(n>5&&(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);var a=V.getValue(e.id,V.random());return i.vs[a]?void V.showException("控件id为"+id+"的子控件已经存在,请更换id名"):(i.vs[a]=n,V.inherit.apply(e,[M.Control,[]]),i.vms[a]=e,n.bind(e),e)},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(){if(e.vol&&e.transform.ty<0&&e.transform.ty>i.node.height()-i.panel.height())return void(e.transform.y=e.transform.ty);if(e.hor&&e.transform.tx<0&&e.transform.tx>i.node.width()-i.panel.width())return void(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);var 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 n=this,a={};V.inherit.apply(n,[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){n.reload(t),a.cons.length>0&&(n.vm.data.next=a.cons[0])}},render:{value:function(t){a.his.push(t),n.change(t)},next:function(t){t&&t!=n.vm.data.value&&function(){!(a.vms[t]&&t!=n.vm.data.value)&&function(){for(var e=!1,o=0;o<a.cons.length;o++)e&&V.getValue(a.vms[a.cons[o]].canActive,!0)?function(){t=a.cons[o],o=a.cons.length}():a.cons[o]==n.vm.data.value&&(e=!0)}(),a.his.push(t),n.change(t)}()},prev:function(t){t&&t!=n.vm.data.value&&function(){a.vms[t]&&t!=n.vm.data.value?function(){var e=!1,n=Array.prototype.slice.call(a.his,0);V.whileC(function(){return e?null:n.pop()},function(o){o==t&&function(){e=!0,a.his=n,a.his.push(t)}()},function(){(!e||!V.getValue(a.vms[value].data.canActive,!0))&&(value=null)},!0)}():function(){value=null,V.whileC(function(){return null==value?a.his.pop():null},function(t){V.getValue(a.vms[t].data.canActive,!0)&&(value=t)},null,!0)}(),n.change(value)}()},size:function(t){t&&t.width&&t.height&&function(){n.node.width(t.width),n.node.height(t.height),n.node.children().width(t.width),n.node.children().height(t.height),V.each(a.cons,function(e){a.vms[e].call("size",{size:t})})}()},clear:function(t){V.forC(a.vms,function(t,e){n.removeControl(t)},function(){a.cons=[],a.vms={},a.his=[],delete n.vm.data.value})},values:{as:"addvalues",Method:function(t){V.next(function(t,e){"values"==key.toLowerCase()?V.forC(a.vms,function(t,e){n.removeControl(t)},function(){a.cons=[],a.vms={},a.his=[],delete n.vm.data.value,e()}):e()},function(t,e){V.each(value,function(t){t.onActive=t.onActive?t.onActive:function(t,e){e.update({show:t.showaction}),V.once(function(){e.call("showed")},500)},n.addControl(null,t)},function(){n.reload(n.node),a.cons.length>0&&n.render({size:n.vm.data.size,value:a.cons[0]})})})}}}},"string"==typeof t?{template:t,vm:e}:t||{})]]),a.render=n.render,a.onLoad=n.onLoad,n.reload=function(t){a.cons=[],a.vms={},a.his=[],t.children().each(function(t,e){var o=$(e).hide().attr("id");if(o){var i=n.vms[o]?n.vms[o]:n.parent.vms[o]?n.parent.vms[o]:n.page.vms[o];i?(a.cons.push(o),a.vms[o]=i,V.merge(i,{canActive:i.data&&i.data.canActive||!0,isActive:!1},!0)):V.showException("不是VJ控件,自动隐藏")}else V.showException("没有找到id,自动隐藏")})},n.change=function(t){t&&(n.vm.data.value&&(a.vms[n.vm.data.value].update({hide:n.vm.data.hideaction,isActive:!1}),a.vms[n.vm.data.value].call("inactive")),a.vms[t]&&(a.vms[t].update({showaction:n.vm.data.showaction,isActive:!0}),a.vms[t].call("active")),n.call("change",{value:t,visible:!0}))}}}(VJ,jQuery,VJ.view,VJ.viewmodel);