var _Toolbar = function() { this.heightPercent = 10; this.imgLogo = null; this.imgBack = null; this.imgSearch = null; this.divTopBar=null; this.divSearch = null; function positionImage(img) { img.style.maxHeight = Toolbar.divTopBar.style.height; img.style.top=(Toolbar.divTopBar.clientHeight-img.clientHeight)/2+"px"; if (img==Toolbar.imgLogo) { Toolbar.imgLogo.style.left=(Toolbar.divTopBar.clientWidth-Toolbar.imgLogo.clientWidth)/2+"px"; } } function createImgDiv(arrUrls) { var img=GUI.createMultiSrcImg(arrUrls); img.style.position="absolute"; img.onload=function(e){ var img =e.target; positionImage(img); }; // if (altImgUrl != null) { // img.onerror = function(e) { // // e.target.onerror = null; // e.target.src = altImgUrl; // }; // // } // img.src = imgUrl; return img; } this.init = function() { var barHeight=Math.round(window.innerHeight*this.heightPercent/100); this.divTopBar = document.createElement("div"); this.divTopBar.style.width = "100%"; this.divTopBar.className="divToolbar"; this.divTopBar.style.height = barHeight + "px"; this.divTopBar.style.position = "relative"; this.divTopBar.align = "center"; this.divTopBar.style.zIndex = 100; GUI.divMain.appendChild(this.divTopBar); var sLangCode=T_MenuLanguages.getCurrentLanguageCode(); this.imgLogo = createImgDiv([Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/logo"+sLangCode+".png"), Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/logo.png")]); this.imgBack = createImgDiv([Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/back"+sLangCode+".png"), Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/back.png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/back"+sLangCode+".png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/back.png")]); if (Settings.isSearchEnabled()) this.imgSearch = createImgDiv([Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/search"+sLangCode+".png"), Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/search.png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/search"+sLangCode+".png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/search.png")]); this.divTopBar.appendChild(this.imgBack); //add the logo img in an 'a' element, and add href to call the restaurant var aImg = document.createElement("a"); var sPhoneNumber = Settings.getPhoneNumber(); if (sPhoneNumber!=null && sPhoneNumber!="") aImg.setAttribute("href","tel:"+sPhoneNumber); aImg.appendChild(this.imgLogo); this.divTopBar.appendChild(aImg); this.divTopBar.appendChild(this.imgSearch); if (T_MenuLanguages.isLangRTL()) { this.imgBack.style.right="5px"; this.imgSearch.style.left="5px"; } else { this.imgBack.style.left="5px"; this.imgSearch.style.right="5px"; } this.imgLogo.style.float="center"; this.imgBack.style.opacity = 0; //GUI.setTransition(this.imgBack,"opacity 0.5s ease-in-out"); this.imgBack.onclick = function(e) { if (GUI.isDoubleFired()) return; if (LargePreview.isShown()) { LargePreview.hide(); return; } MainScrollView.goPrevPage(); }; if (this.imgSearch != null) { this.imgSearch.onclick = function(e) { if (GUI.isDoubleFired()) return; Toolbar.SearchClicked(); }; }; }; this.SearchClicked = function() { if (this.divSearch==null) { //create search div this.divSearch = document.createElement("div"); this.divSearch.style.position = "absolute"; this.divSearch.style.top = "0px"; this.divSearch.style.left = "0px"; this.divSearch.style.width = "100%"; this.divSearch.style.zIndex=101; this.divSearch.style.height= "100%"; this.divSearch.onclick = function(e) { if (GUI.isDoubleFired()) return; Toolbar.closeSearch(); }; document.body.appendChild(this.divSearch); var div = document.createElement("div"); div.style.position = "absolute"; div.style.top = "0px"; div.style.left = "0px"; div.className="divSearchBar"; div.style.width = "100%"; div.style.top = div.style.height = this.divTopBar.style.height; //this.divSearch.style.backgroundColor = "rgba(64,64,64,0.8)"; this.divSearch.appendChild(div); div.onclick = function(e) { e.cancelBubble = true; };// prevent clicks on mask ; ; // create input var inputSearch = document.createElement("input"); inputSearch.setAttribute("type", "search");; inputSearch.style.width = "80%"; inputSearch.style.borderRadius = "10px"; inputSearch.style.fontSize =div.clientHeight*0.7+"px"; inputSearch.style.position= "absolute"; inputSearch.style.color="black"; inputSearch.style.border = "0px"; inputSearch.style.margin="0px"; // inputSearch.style.padding = "0px 5px 0px 5px"; inputSearch.placeholder = UITexts.getText("enter text..."); inputSearch.autofocus="autofocus"; inputSearch.onkeyup =function(e) { if (e.keyCode==13) { Toolbar.closeSearch(); SearchView.show(e.target.value); } } // inputSearch.onchange2 = function(e) { // try{ // Toolbar.closeSearch();//prevent double events by removing the div first (exception if already removed) // SearchView.show(e.target.value); // }catch(ex) // { // } // }; ; div.appendChild(inputSearch); inputSearch.style.top=(div.clientHeight-inputSearch.clientHeight)/2+"px"; var sLangCode=T_MenuLanguages.getCurrentLanguageCode(); // create image (glass) imgGlass = createImgDiv([Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/searchGo"+sLangCode+".png"), Common.getUrl("smartphones/sites/" + Common.getSiteID() + "/searchGo.png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/searchGo"+sLangCode+".png"), Common.getUrl("smartphones/dists/" + T_Sites.getDistName() + "/searchGo.png")]); imgGlass.inputObject = inputSearch; imgGlass.style.position = "absolute"; imgGlass.style.maxHeight=div.style.height; imgGlass.onload=function(e) { var img = e.target; var bar=img.parentNode; if (img.clientHeight