SearchBox_wev8.js
3.87 KB
define("SearchBox_html",function(){return'<div id="NMEC_${id}" class="wev-comp-${compType}" > <div class="wev-searchbox wev-search"> {@if leftBtns.length > 0} <div class="wev-searchbox-btn-wrap"> {@each leftBtns as btn,index} {@if btn.text && btn.icon} <div class="btn" data-index="${btn.index}"> <div class="btn-inner"> <img src="${btn.icon}"> <div>$${btn.text}</div> </div> </div> {@else if btn.text} <button class="btn" data-index="${btn.index}">$${btn.text}</button> {@else if btn.icon} <img class="btn" data-index="${btn.index}" src="${btn.icon}"> {@/if} {@/each} </div> {@/if} <div class="wev-search-inner"> <div class="wev-placeholder"> <div class="wev-placeholder-inner wev-ellipsis"> <span class="wev-small-icon wev-icon-search"></span><span class="wev-placeholder-text">${tip}</span> </div> </div> <div class="wev-clear-btn"></div> </div> {@if rightBtns.length > 0} <div class="wev-searchbox-btn-wrap"> {@each rightBtns as btn,index} {@if btn.text && btn.icon} <div class="btn" data-index="${btn.index}"> <div class="btn-inner"> <img src="${btn.icon}"> <div>$${btn.text}</div> </div> </div> {@else if btn.text} <button class="btn" data-index="${btn.index}">$${btn.text}</button> {@else if btn.icon} <img class="btn" data-index="${btn.index}" src="${btn.icon}"> {@/if} {@/each} </div> {@/if} </div></div>'}),define(["mUtil","Component","mService"],function(l,i,s){return i.init(function(e){i.super(this,e),this.type="SearchBox",this.tpl=this.type+"_html",this.css=this.type+"_css";var r=this.viewModel={tip:"",scan:!0,history:!0,btns:[],onSearch:function(){},standalone:!0},t={};this.beforeMount=function(){r.leftBtns=[],r.rightBtns=[],r.btns.forEach(function(e){e.index=l.UUID(),"left"==e.align?r.leftBtns.push(e):"right"==e.align&&r.rightBtns.push(e)})},this.mounted=function(){var a=this,e=this.$el.children(".wev-comp-"+r.compType),i=$(".wev-search",e);require("i18n"),a.$container,e.on("click",".btn",function(){var s=$(this).data("index");r.btns.every(function(e,i){if(e.index!=s)return!0;var n=e.click.toString().replace(/^function\s?\(\){/,"").replace(/}$/,""),t=new Function('var that= _u.getInstance("'+a.id+'");'+n);return l.eval(t,a.pageid),!1})});var n=function(e){s.show("searchbox",{preload:e,compid:a.id,tip:r.tip,scan:r.scan,history:r.history,classAnimation:"show_hide_searchbox",searchkey:r.searchkey,toThirdPage:r.toThirdPage,closeCallback:function(){l.back()},onSearch:function(e){r.searchkey=e,t.onSearch(e,!0)}})};i.on("click.active",".wev-placeholder",function(e){n(!1)}),n(!0)},t.onSearch=function(e,i){if(l.isObject(r.onSearch)){var n=r.onSearch,t="";if(l.isEmpty(e)||(t=n.query.replace("$KEY$",encodeURIComponent(e))),l.getPageId(n.pageid)==this.pageid){Mobile_NS.refreshSpecifiedList(n.pageid,n.compoid,t).then(function(){i&&l.back()});var s=this.$el.find(".wev-ellipsis"),a=s.find(".wev-icon-search"),c=s.find(".wev-placeholder-text"),o=e||r.tip;""!=e?a.hide():a.show(),c.html(o.replaceAll(" "," ")),s.toggleClass("wev-placeholder-inner",!e).toggleClass("wev-placeholder-left",e)}else{var d={onPageLoad:function(){Mobile_NS.refreshList(n.compoid,t)}};r.toThirdPage=!0,$u("/mobilemode/appHomepageView.jsp?appHomepageId="+n.pageid,d)}}else l.eval(r.onSearch,this.pageid,e)},this.onSearch=function(e){t.onSearch(e,!1)},t.onSearch=t.onSearch.bind(this)})});