author | ivanl |
Tue, 21 Jul 2009 12:22:37 +0100 | |
changeset 11 | aaba47256eea |
parent 10 | 07ac2f6a36a9 |
permissions | -rw-r--r-- |
0 | 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 |
||
10
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
14 |
this.items = []; |
0 | 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; |
|
10
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
36 |
this.items[childMenuItem.id] = childMenuItem; |
0 | 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; |
|
10
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
78 |
for(var i in this.items) |
0 | 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 |
} |
|
10
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
91 |
|
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
92 |
// make TRUE menuItem.js script loaded |
07ac2f6a36a9
1.0rc10 Fixes annoyances and buglets in reading forums and blog.
ivanl
parents:
0
diff
changeset
|
93 |
window.parent.NOKIA.scriptsLoaded.menuItem = true; |