Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F2112127
toolbar.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Nov 18, 1:08 PM
Size
6 KB
Mime Type
text/plain
Expires
Fri, Nov 20, 1:08 PM (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
987813
Attached To
rINP In-Portal
toolbar.js
View Options
var
toolbar
;
//var imagesPath = "images/";
var
separatorImg
=
"divider"
;
var
imagesPreName
=
"tool_"
;
var
imagesPostName_Active
=
"_f2"
;
var
imagesPostName_Disabled
=
"_f3"
;
var
imagesExt
=
".gif"
;
var
preloadImages
=
new
Array
();
preloadImage
(
getButtonSrc
(
separatorImg
,
0
));
function
initToolbar
(
id
,
actionHandler
)
{
toolbar
=
document
.
getElementById
(
id
);
if
(
!
toolbar
)
return
;
toolbar
.
actionHandler
=
actionHandler
;
toolbar
.
className
=
"toolbarDiv"
var
childNodes
=
toolbar
.
getElementsByTagName
(
"*"
);
if
(
childNodes
.
length
==
0
)
childNodes
=
toolbar
.
childNodes
;
var
_oTable
=
document
.
createElement
(
"TABLE"
);
var
_oTBody
=
document
.
createElement
(
"TBODY"
);
var
_oTR
=
document
.
createElement
(
"TR"
);
var
_oTD
=
document
.
createElement
(
"TD"
);
_oTD
.
className
=
"toolbarTD"
;
_oTR
.
appendChild
(
_oTD
);
_oTBody
.
appendChild
(
_oTR
);
_oTable
.
appendChild
(
_oTBody
);
_oTable
.
align
=
"left"
;
_oTable
.
cellSpacing
=
0
;
_oTable
.
cellPadding
=
0
;
_oTable
.
border
=
0
;
_oTable
.
className
=
"toolbarTable"
_oTable
.
width
=
"100%"
;
var
oTable
=
document
.
createElement
(
"TABLE"
);
var
oTBody
=
document
.
createElement
(
"TBODY"
);
var
oTR
=
document
.
createElement
(
"TR"
);
oTR
.
parentToolbar
=
toolbar
;
oTBody
.
appendChild
(
oTR
);
oTable
.
appendChild
(
oTBody
);
oTable
.
align
=
"left"
;
oTable
.
cellSpacing
=
0
;
oTable
.
cellPadding
=
0
;
oTable
.
border
=
0
;
// oTable.width = "100%";
oTable
.
className
=
"toolbarTable"
_oTD
.
appendChild
(
oTable
);
for
(
var
i
=
0
;
i
<
childNodes
.
length
;
i
++
)
if
(
childNodes
[
i
].
nodeType
==
1
)
{
oTD
=
document
.
createElement
(
"TD"
);
oTD
.
action
=
childNodes
[
i
].
getAttribute
(
"action"
);
// oTD.width = "1%";
oIMG
=
document
.
createElement
(
"IMG"
);
if
(
childNodes
[
i
].
getAttribute
(
"align"
)
==
"right"
&&
!
oTR
.
alignedRight
)
{
_owTD
=
document
.
createElement
(
"TD"
);
_owTD
.
innerHTML
=
" "
;
_owTD
.
width
=
"99%"
;
oTR
.
appendChild
(
_owTD
);
oTR
.
alignedRight
=
true
;
}
switch
(
childNodes
[
i
].
tagName
.
toLowerCase
())
{
case
"tb:separator"
:
oIMG
.
basepath
=
childNodes
[
i
].
getAttribute
(
"ImagePath"
);
oIMG
.
action
=
"divider"
;
oIMG
.
src
=
getButtonSrc
(
oIMG
,
0
);
break
;
case
"tb:button"
:
oIMG
.
toolbar
=
toolbar
;
oIMG
.
action
=
childNodes
[
i
].
getAttribute
(
"action"
);
var
enabled
=
new
String
(
childNodes
[
i
].
getAttribute
(
"enabled"
));
oIMG
.
disabled
=
(
enabled
==
"false"
);
oIMG
.
basepath
=
childNodes
[
i
].
getAttribute
(
"ImagePath"
);
oIMG
.
src
=
getButtonSrc
(
oIMG
,
(
oIMG
.
disabled
)
?
2
:
0
)
for
(
var
j
=
0
;
j
<
3
;
j
++
)
preloadImage
(
getButtonSrc
(
oIMG
,
j
),
oIMG
.
basepath
);
oIMG
.
style
.
cursor
=
(
oIMG
.
disabled
)
?
"default"
:
"hand"
;
oIMG
.
setAttribute
(
"title"
,
childNodes
[
i
].
getAttribute
(
"title"
));
oIMG
.
onclick
=
function
()
{
if
(
this
.
disabled
)
return
;
if
(
this
.
toolbar
.
actionHandler
)
this
.
toolbar
.
actionHandler
(
this
);
}
oIMG
.
onmouseover
=
function
(
e
)
{
var
evt
=
(
e
)
?
e
:
event
;
// evt.cancelBubble = true;
if
(
this
.
disabled
)
return
;
this
.
src
=
getButtonSrc
(
this
,
1
);
}
oIMG
.
onmouseout
=
function
(
e
)
{
var
evt
=
(
e
)
?
e
:
event
;
// evt.cancelBubble = true;
if
(
this
.
disabled
)
return
;
this
.
src
=
getButtonSrc
(
this
,
0
);
}
break
;
}
var
tab
=
(
childNodes
[
i
].
getAttribute
(
"tab"
))
?
childNodes
[
i
].
getAttribute
(
"tab"
)
:
""
;
oTD
.
tab
=
tab
;
if
(
tab
!=
""
)
oTD
.
style
.
display
=
"none"
;
oTD
.
appendChild
(
oIMG
);
oTR
.
appendChild
(
oTD
)
}
toolbar
.
appendChild
(
_oTable
);
toolbar
.
setTab
=
toolbarSetTab
;
toolbar
.
showButton
=
toolbarShowButton
;
toolbar
.
enableButton
=
toolbarEnableButton
;
toolbar
.
disableButton
=
toolbarDisableButton
;
}
function
toolbarSetTab
(
tab
)
{
var
TDs
=
this
.
getElementsByTagName
(
"TD"
);
for
(
var
i
=
0
;
i
<
TDs
.
length
;
i
++
)
if
(
TDs
[
i
].
tab
)
if
(
TDs
[
i
].
tab
!=
""
)
{
if
(
TDs
[
i
].
tab
==
tab
)
TDs
[
i
].
style
.
display
=
""
else
TDs
[
i
].
style
.
display
=
"none"
;
}
}
function
toolbarShowButton
(
action
,
value
)
{
var
TDs
=
this
.
getElementsByTagName
(
"TD"
);
for
(
var
i
=
0
;
i
<
TDs
.
length
;
i
++
)
if
(
TDs
[
i
].
action
==
action
)
TDs
[
i
].
style
.
display
=
(
value
)
?
""
:
"none"
;
}
function
findButton
(
toolbar
,
action
)
{
if
(
!
toolbar
)
return
;
var
buttons
=
toolbar
.
getElementsByTagName
(
"IMG"
);
for
(
var
i
=
0
;
i
<
buttons
.
length
;
i
++
)
if
(
buttons
[
i
].
action
==
action
)
return
buttons
[
i
];
}
function
toolbarEnableButton
(
action
,
value
)
{
var
button
=
findButton
(
this
,
action
);
if
(
!
button
)
return
;
button
.
src
=
getButtonSrc
(
button
,
(
value
==
false
)
?
2
:
0
)
button
.
style
.
cursor
=
(
value
==
false
)
?
"default"
:
"hand"
;
button
.
disabled
=
(
value
==
false
)
?
true
:
false
;
}
function
toolbarDisableButton
(
action
)
{
this
.
enableButton
(
action
,
false
)
}
function
getButtonSrc
(
button
,
state
)
{
var
stateExt
;
switch
(
state
)
{
case
(
1
)
:
stateExt
=
imagesPostName_Active
;
break
;
case
(
2
)
:
stateExt
=
imagesPostName_Disabled
;
break
;
default
:
stateExt
=
""
;
}
return
button
.
basepath
+
imagesPreName
+
button
.
action
+
stateExt
+
imagesExt
;
}
function
preloadImage
(
src
)
{
var
img
=
new
Image
();
img
.
src
=
src
;
preloadImages
[
preloadImages
.
length
]
=
img
;
}
function
showContextMenu
(
evt
)
{
initContextMenu
(
evt
.
clientX
,
evt
.
clientY
+
document
.
body
.
scrollTop
);
window
.
FW_showMenu
(
window
.
contextMenu
,
evt
.
clientX
,
evt
.
clientY
+
document
.
body
.
scrollTop
);
evt
.
returnValue
=
false
;
evt
.
cancelBubble
=
true
;
return
false
;
}
function
initContextMenu
(){
window
.
contextMenu
=
new
Menu
(
"Context"
);
contextMenu
.
addMenuItem
(
"Edit"
,
"check_submit('','edit');"
,
""
);
contextMenu
.
addMenuItem
(
"Delete"
,
"check_submit('admin/browse','delete');"
,
""
);
contextMenu
.
addMenuSeparator
();
contextMenu
.
addMenuItem
(
"Approve"
,
"check_submit('admin/browse','approve');"
,
""
);
contextMenu
.
addMenuItem
(
"Decline"
,
"check_submit('admin/browse','decline');"
,
""
);
contextMenu
.
addMenuSeparator
();
contextMenu
.
addMenuItem
(
"Cut"
,
"check_submit('admin/browse','cut');"
,
""
);
contextMenu
.
addMenuItem
(
"Copy"
,
"check_submit('admin/browse','copy');"
,
""
);
if
(
typeof
(
activeTab
)
!=
'undefined'
)
{
if
(
TabPasteEnabled
(
activeTab
.
title
))
contextMenu
.
addMenuItem
(
"Paste"
,
"check_submit('admin/browse','paste');"
,
""
);
}
window
.
triedToWriteMenus
=
false
;
window
.
contextMenu
.
writeMenus
();
return
true
;
}
Event Timeline
Log In to Comment