var _DishListView = function() { this.sCategoryKey = null; this.createSearchDishListDivFromDishList = function(dishList) { var ret = this._createDishListDiv(dishList, null, true); return ret; }; this.createDishListDiv = function(sCategoryKey) { var dishList = T_Dishes.getDishesForCategory(sCategoryKey); return this._createDishListDiv(dishList, sCategoryKey,false); }; this._createDishListDiv = function(dishList, sCategoryKey, bForSearch) { this.sCategoryKey = sCategoryKey; var divDishes = document.createElement("div"); divDishes.lstDishes=dishList; var bHasContent = false; var table = document.createElement("table"); if (T_MenuLanguages.isLangRTL()) table.setAttribute("dir", "rtl"); table.style.width = "100%"; table.style.borderCollapse="collapse"; var col1 = document.createElement("col"); var col2 = document.createElement("col"); var col3 = document.createElement("col"); col1.setAttribute("width", "20%"); col2.setAttribute("width", "80%"); col3.setAttribute("width", "20%"); table.appendChild(col1); table.appendChild(col2); table.appendChild(col3); divDishes.appendChild(table); var tr; // category name var sHeader = null; if (bForSearch == true) { sHeader = UITexts.getText("Search Results"); }else { if(sCategoryKey !=null) { sHeader=T_Categories.getCategoryName(sCategoryKey); } } if (sHeader != null) { tr = document.createElement("tr"); table.appendChild(tr); td = document.createElement("td"); tr.appendChild(td); td.textContent = sHeader; td.className = "CategoryNameInDishPage"; td.colSpan = "3"; td.align = "center"; } if (dishList != null) { for ( var index in dishList) { var dish = dishList[index]; // tr tr = document.createElement("tr"); tr.className="trDishRow"; tr.attributes["dishID"] = dish; tr.attributes["categoryID"] = sCategoryKey; table.appendChild(tr); tr.onclick = function(e) { if (GUI.isDoubleFired()) return; this.setAttribute("pressed","true"); setTimeout(function(elem){ elem.setAttribute("pressed","false"); },400,this); setTimeout(function(row){ LargePreview.show(row.attributes["dishID"], row.parentElement.parentElement.lstDishes); },10,this); //LargePreview.show(this.attributes["dishID"], this.parentElement.parentElement.lstDishes); }; // td for image var td = document.createElement("td"); tr.appendChild(td); var sImage = T_Dishes.getThumbPath(dish); if (sImage ==null) { tr.style.height = "2.5em"; } else { tr.style.height = "2.5em";// keep space for image (to // avoid later resizing var img = document.createElement("img"); img.src = sImage; img.className="imgDishThumb"; img.style.maxWidth = "100%"; img.style.maxHeight = "2.5em"; img.style.borderRadius="10px"; // img.style.height = "100%"; don't set height, keep aspect // ratio td.appendChild(img); } // td for dish name td = document.createElement("td"); tr.appendChild(td); td.textContent = T_Dishes.getName(dish); td.className = "dishName"; // td for price td = document.createElement("td"); tr.appendChild(td); td.textContent = T_Dishes.getPrice(dish); td.className = "dishPrice"; bHasContent = true; } } if (!bHasContent && bForSearch) { tr = document.createElement("tr"); table.appendChild(tr); td = document.createElement("td"); tr.appendChild(td); td.textContent = UITexts.getText("No Results"); td.className = "dishName"; td.colSpan = "3"; td.align = "center"; } // if (!bHasContent) // return null; return divDishes; }; }; var DishListView = new _DishListView();