2 * Copyright 2016-2017, CMCC Technologies Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
16 var initLeftMenu = function() {
\r
17 var i18nName = "openo_frame_left_menu_i18n";
\r
24 url : "json/menu_list.json",
\r
26 "success" : function (res, textStatus, jqXHR) {
\r
27 parentMenus = res.parentMenus;
\r
28 childMenus = res.childMenus;
\r
30 error : function () {
\r
34 var templateParent = "<a href='javascript:'>" +
\r
35 "<i class='{iconClass}'></i>" +
\r
36 "<span id='{id}' name_i18n='{i18nName}' class='title'></span>" +
\r
37 "<span class='selected'></span>" +
\r
38 "<span class='arrow'></span>" +
\r
41 var templateChild = "<li>" +
\r
42 "<a href='{url}' class='iframe' id='{hrefId}'>" +
\r
43 "<i class='{iconClass}'></i>" +
\r
44 "<span id='{id}' name_i18n='{i18nName}'></span>" +
\r
48 var menuContent = "";
\r
49 for (var i = 0; i < parentMenus.length; i++) {
\r
50 var parentMenuContent = templateParent.replace("{id}", parentMenus[i].id)
\r
51 .replace("{iconClass}", parentMenus[i].iconClass)
\r
52 .replace("{i18nName}", i18nName);
\r
54 var childMenuContent = "";
\r
55 for (var j = 0; j < childMenus.length; j++) {
\r
56 if (childMenus[j].parentId == parentMenus[i].id) {
\r
57 childMenuContent = childMenuContent + templateChild.replace("{id}", childMenus[j].id)
\r
58 .replace("{url}", childMenus[j].url)
\r
59 .replace("{iconClass}", childMenus[j].iconClass)
\r
60 .replace("{hrefId}", childMenus[j].id + "_href")
\r
61 .replace("{i18nName}", i18nName);
\r
64 childMenuContent = "<ul class='sub-menu'>" + childMenuContent + "</ul>";
\r
66 menuContent = menuContent + "<li>" + parentMenuContent + childMenuContent + "</li>";
\r