|
1 /* |
|
2 Function : MenuItem() |
|
3 Argument : Void |
|
4 Returns : Void |
|
5 Description : Constructor Function creates a Menu object to the WINDOW |
|
6 */ |
|
7 |
|
8 function MenuItem(name, id) |
|
9 { |
|
10 this.id = id; |
|
11 this.name = name; |
|
12 this.isDimmed = false; |
|
13 |
|
14 this.items = []; |
|
15 this.index = null; |
|
16 this.parent = null; |
|
17 this.type = 'MenuItem'; |
|
18 |
|
19 |
|
20 // Event triggers |
|
21 this.onSelect = null; |
|
22 } |
|
23 |
|
24 |
|
25 /* |
|
26 Function : MenuItem.append(MenuItem) |
|
27 Argument : Menu Object |
|
28 Returns : Void |
|
29 Description : Function appends childMenuItem to a MenuItem |
|
30 */ |
|
31 MenuItem.prototype.append = function(childMenuItem) |
|
32 { |
|
33 if( (childMenuItem != null) && (childMenuItem.type == 'MenuItem')) |
|
34 { |
|
35 childMenuItem.parent = this; |
|
36 this.items[childMenuItem.id] = childMenuItem; |
|
37 } |
|
38 } |
|
39 |
|
40 |
|
41 /* |
|
42 Function : MenuItem.remove() |
|
43 Argument : Menu Object |
|
44 Returns : Void |
|
45 Description : Function Removes childMenuItem and its children from the parent menu item. |
|
46 */ |
|
47 MenuItem.prototype.remove = function(childMenuItem) |
|
48 { |
|
49 if((childMenuItem != null) && (childMenuItem.type == 'MenuItem')) |
|
50 { |
|
51 var i = this.search(childMenuItem); |
|
52 if(i > -1) |
|
53 this.items.splice(i, 1); |
|
54 } |
|
55 } |
|
56 |
|
57 /* |
|
58 Function : MenuItem.remove() |
|
59 Argument : Menu Object |
|
60 Returns : Void |
|
61 Description : If flag is true the MenuItem is hidden and if flag is false the item is shown. |
|
62 */ |
|
63 MenuItem.prototype.setDimmed = function(flag) |
|
64 { |
|
65 this.isDimmed = flag; |
|
66 } |
|
67 |
|
68 |
|
69 /* |
|
70 Function : MenuItem.search() |
|
71 Argument : MenuItem Object |
|
72 Returns : Integer |
|
73 Description : Function Replace oldMenuItem with newMenuItem |
|
74 */ |
|
75 MenuItem.prototype.search = function(MenuItem) |
|
76 { |
|
77 var flag = false; |
|
78 for(var i in this.items) |
|
79 { |
|
80 if(this.items[i].id == MenuItem.id) |
|
81 { |
|
82 flag = true; |
|
83 break; |
|
84 } |
|
85 } |
|
86 if(flag) |
|
87 return i; |
|
88 else |
|
89 return -1; |
|
90 } |
|
91 |
|
92 // make TRUE menuItem.js script loaded |
|
93 window.parent.NOKIA.scriptsLoaded.menuItem = true; |