温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:无忧劳保库存系统源码
当前文件:
Labor/TaskMenu.js,打开代码结构图
Labor/TaskMenu.js,打开代码结构图1//**************************************************** 2
// TaskMenu 3.0 3
// 静静的黎明 4
// http://www.docode.cn 5
//**************************************************** 6
///////////////////////////////////////////////////////////////////////////////// 7
var INF_IS_IEXPLORER = (navigator.userAgent.indexOf("MSIE") == -1)? false : true; 8
var INF_IS_MENU_BEHAVIOR_AUTO = true; 9
var INF_IS_SCROLLBAR_ENABLED = false; 10
/////////////////////////////////////////////////////// 11
/////////////*** CONFIG ***//////////////////////////// 12
var CFG_FRAME_COUNT = 6; 13
var CFG_DOCUMENT_MARGIN = 12; 14
var CFG_MENU_SPACING = 15; 15
var CFG_MENU_WIDTH = 185; 16
var CFG_SCROLLBAR_WIDTH = 17; 17
var CFG_TITLEBAR_HEIGHT = 25; 18
var CFG_TITLEBAR_LEFT_WIDTH = 13; 19
var CFG_TITLEBAR_RIGHT_WIDTH = 25; 20
var CFG_TITLEBAR_MIDDLE_WIDTH = CFG_MENU_WIDTH - CFG_TITLEBAR_LEFT_WIDTH - CFG_TITLEBAR_RIGHT_WIDTH; 21
var CFG_TITLEBAR_BORDER_WIDTH = 0; 22
var CFG_MENUBODY_PADDING = 9; 23
var CFG_MENUBODY_BORDER_WIDTH = 1; 24
var CFG_SLEEP_TIME_BEGIN = 20; 25
var CFG_SLEEP_TIME_END = 60; 26
var CFG_ALPHA_STEP = Math.ceil( 100 / (CFG_FRAME_COUNT) ); 27
var CFG_IS_SCROLLBAR_ENABLED = true; 28
var CFG_IS_SPECIAL_HEAD_NODE = false; 29
30
////////////////////////////////////////////////////////// 31
////////////////////////////////////////////////////////// 32
if(new Array().push == null) 33
{ 34
//usage: array.push(Array); for ie5.0 35
Array.prototype.push = function() 36
{ 37
this[this.length] = arguments[0]; 38
return this.length; 39
} 40
} 41
if(new Array().splice == null) 42
{ 43
/// usage: array.splice(startPos,deleteCount,[item1,item2,...]);for ie5.0 44
Array.prototype.splice = function() 45
{ 46
if(arguments.length < 2 || arguments[1] < 0) 47
return new Array(); 48
49
var endPoint1 = arguments[0]; 50
if(endPoint1 < 0 && Math.abs(endPoint1) > this.length) 51
endPoint1 = 0; 52
53
var startPoint2 = (endPoint1 < 0)? (this.length + endPoint1 + arguments[1]) : (endPoint1 + arguments[1]); 54
55
var bArray = this.slice(0,endPoint1); 56
var dArray = this.slice(endPoint1,startPoint2); 57
var eArray = this.slice(startPoint2); 58
var nArray = new Array(); 59
for(var i = 2; i < arguments.length; i++) 60
{ 61
nArray.push(arguments[i]); 62
} 63
var fArray = bArray.concat(nArray,eArray); 64
65
for(var i = 0; i < fArray.length; i++) 66
{ 67
this[i] = fArray[i]; 68
} 69
this.length = fArray.length; 70
71
return dArray; 72
} 73
} 74
75
///////////////////////////////////////////////////////////////// 76
function TaskMenuState(){} 77
TaskMenuState.uninited = 0; 78
TaskMenuState.open = 1; 79
TaskMenuState.close = 2; 80
TaskMenuState.opening = 4; 81
TaskMenuState.closing = 8; 82
TaskMenuState.transforming = 16; 83
84
function TaskMenuItem(strLabel,strIcon,strCommand) 85
{ 86
this.label = strLabel; 87
this.icon = strIcon; 88
this.command = strCommand; 89
this.hItem = null; 90
this.hLabel = null; 91
this.hIcon = null; 92
this.hLabelCell = null; 93
this.container = null; 94
this.operTimer = null; 95
this.tranTimer = null; 96
this.operStep = 0; 97
this.tranStep = 0; 98
this.operCount = 0; 99
this.tranCount = 0; 100
101
this.init = function() 102
{ 103
(this.hLabel = document.createElement("FONT")).reflectClass = this; 104
with(this.hLabel) 105
{ 106
reflectClass = this; 107
} 108
with(this.hItem = document.createElement("TABLE")) 109
{ 110
cellPadding = 0; 111
cellSpacing = 0; 112
style.width = "100%"; 113
} 114
(itemRow = this.hItem.insertRow(0)).className="MenuItemRow"; 115
with(blankCell = itemRow.insertCell(0)) 116
{ 117
style.width = (CFG_MENUBODY_PADDING - 2) +"px"; 118
} 119
with(iconCell = itemRow.insertCell(1)) 120
{ 121
align = "RIGHT"; 122
style.cssText = "width:18px;vertical-align:top;padding-top:3px"; 123
with(this.hIcon = iconCell.appendChild(document.createElement("DIV"))) 124
{ 125
className = "IconContainer"; 126
} 127
} 128
129
with(this.hLabelCell = itemRow.insertCell(2)) 130
{ 131
style.padding = "2px " + CFG_MENUBODY_PADDING +"px 2px 5px"; 132
appendChild(this.hLabel); 133
} 134
with(this) 135
{ 136
setIcon(icon); setLabel(label); setCommand(command); 137
} 138
} 139
140
this.getLabel = function() 141
{ 142
return this.label; 143
} 144
145
this.setLabel = function(strLabel) 146
{ 147
this.hLabel.innerHTML = this.label = strLabel; 148
} 149
this.getIcon = function() 150
{ 151
return this.icon; 152
} 153
154
this.setIcon = function(strIcon) 155
{ 156
this.icon = strIcon; 157
158
while(this.hIcon.firstChild != null) 159
{ 160
this.hIcon.removeChild(this.hIcon.firstChild); 161
} 162
163
if(this.icon != null) 164
{ 165
with(this.hIcon) 166
{ 167
style.width = "18px"; 168
parentNode.style.width = "18px"; 169
with(appendChild(new Image())) 170
{ 171
src= this.icon; 172
} 173
} 174
} 175
else 176
{ 177
this.hIcon.style.width = "0px"; 178
this.hIcon.parentNode.style.width = "0px"; 179
} 180
} 181
182
this.getCommand = function() 183
{ 184
return this.command; 185
} 186
187
this.setCommand = function(strCommand) 188
{ 189
if( (this.command = strCommand) != null) 190
{ 191
JS.addListener(this.hLabel,"mouseover",TaskMenuItem.onMouseBehavior,false); 192
JS.addListener(this.hLabel,"mouseout",TaskMenuItem.onMouseBehavior,false); 193
JS.addListener(this.hLabel,"click",TaskMenuItem.onClick,false); 194
this.hLabel.className = "MenuItemLabel"; 195
} 196
else 197
{ 198
JS.removeListener(this.hLabel,"mouseover",TaskMenuItem.onMouseBehavior,false); 199
JS.removeListener(this.hLabel,"mouseout",TaskMenuItem.onMouseBehavior,false); 200
JS.removeListener(this.hLabel,"click",TaskMenuItem.onClick,false); 201
this.hLabel.className = "MenuItemLabelDisabled"; 202
} 203
} 204
205
this.runCommand = function() 206
{ 207
try 208
{ 209
eval(this.command); 210
} 211
catch(ex) 212
{ 213
alert("Javascript Error:" + ex.description); 214
} 215
} 216
217
this.cloneNode = function() 218
{ 219
return new TaskMenuItem(this.label,this.icon,this.command); 220
} 221
222
this.init(); 223
} 224
225
TaskMenuItem.onMouseBehavior = function() 226
{ 227
with(JS.getSourceElement(arguments[0])) 228
{ 229
if(arguments[0].type.toUpperCase() == "MOUSEOVER") 230
className = "MenuItemLabelMouseOver"; 231
232
else 233
className = "MenuItemLabel"; 234
} 235
} 236
237
TaskMenuItem.onClick = function() 238
{ 239
var refClass = JS.getSourceElement(arguments[0]).reflectClass; 240
if(refClass != null) refClass.runCommand(); 241
} 242
243
function TaskMenu(strLabel,menuState) 244
{ 245
this.menuID; 246
this.label = strLabel; 247
this.state = menuState; 248
this.items = []; 249
this.hLabel = null; 250
this.hArrayCell = null; 251
this.titlebar = null; 252
this.menuBody = null; 253
this.previous = null; 254
this.next = null; 255
this.background = null; 256
this.operationTimer; 257
this.transformTimer; 258
this.invalidateTimer 259
this.operationStep; 260
this.transformStep; 261
this.operationSleep; 262
this.transformSleep; 263
264
this._getAlphaOpacity = function() 265
{ 266
try 267
{ 268
if(INF_IS_IEXPLORER) 269
return this.menuBody.filters.alpha.opacity; 270
271
else 272
return this.menuBody.style.MozOpacity * 100; 273
} 274
catch(ex) 275
{ 276
return 100; 277
} 278
} 279
280
this._setAlphaOpacity = function(n) 281
{ 282
try 283





}
}