Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F2113642
checkboxes_old.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, 3:05 PM
Size
6 KB
Mime Type
text/plain
Expires
Fri, Nov 20, 3:05 PM (2 h, 43 m)
Engine
blob
Format
Raw Data
Handle
987684
Attached To
rINP In-Portal
checkboxes_old.js
View Options
var
focusType
=
""
;
var
tabIDs
=
new
Array
();
var
tabSelection
=
new
Array
();
var
LastCheckedItem
=
null
;
function
initCheckBoxes
(
selChangedHandler
)
{
var
checkBoxContainers
=
document
.
body
.
getElementsByTagName
(
"DIV"
);
for
(
var
i
=
0
;
i
<
checkBoxContainers
.
length
;
i
++
)
if
(
checkBoxContainers
[
i
].
getAttribute
(
"isTab"
))
{
if
(
tabIDs
.
length
==
0
)
start_tab
=
checkBoxContainers
[
i
].
id
;
tabIDs
[
tabIDs
.
length
]
=
checkBoxContainers
[
i
].
id
tabSelection
[
checkBoxContainers
[
i
].
id
]
=
0
;
}
tabSelection
[
'categories'
]
=
0
;
categoriesTab
=
document
.
getElementById
(
'categories'
);
var
catInputs
=
categoriesTab
.
getElementsByTagName
(
"INPUT"
);
for
(
var
i
=
0
;
i
<
catInputs
.
length
;
i
++
)
catInputs
.
checked
=
false
;
if
(
categoriesTab
)
categoriesTab
.
active
=
true
;
for
(
var
i
=
0
;
i
<
checkBoxContainers
.
length
;
i
++
)
if
(
checkBoxContainers
[
i
].
getAttribute
(
"inportalType"
))
{
var
inputs
=
checkBoxContainers
[
i
].
getElementsByTagName
(
"INPUT"
);
var
checkBox
;
for
(
var
j
=
0
;
j
<
inputs
.
length
;
j
++
)
if
(
inputs
[
j
].
type
==
"checkbox"
)
{
checkBox
=
inputs
[
j
];
break
;
}
checkBox
.
inportalType
=
checkBoxContainers
[
i
].
getAttribute
(
"inportalType"
);
checkBox
.
onclick
=
checkBoxClick
;
checkBox
.
container
=
checkBoxContainers
[
i
];
checkBox
.
checked
=
false
;
// checkBoxContainers[i].className = (checkBox.checked) ? "selectedContainer" : "unselectedContainer";
selectContainer
(
checkBox
,
checkBox
.
checked
,
true
)
if
(
checkBox
.
checked
)
tabSelection
[
checkBox
.
inportalType
]
++
;
}
tabChanged
();
selectionChanged
();
// toolbar.setTab('category');
}
function
checkBoxClick
()
{
selectContainer
(
this
,
this
.
checked
);
if
(
this
.
checked
)
{
tabSelection
[
this
.
inportalType
]
++
LastCheckedItem
=
this
;
}
else
{
tabSelection
[
this
.
inportalType
]
--
;
LastCheckedItem
=
null
;
}
updateStatus
();
}
function
toggleTab
(
tabId
)
{
//alert('now in toggletab()');
//alert('toggling '+tabId);
var
tab
=
document
.
getElementById
(
tabId
);
if
(
!
tab
)
{
return
;
}
//alert('found tab..');
for
(
var
i
=
0
;
i
<
tabIDs
.
length
;
i
++
)
{
if
(
tabIDs
[
i
]
!=
tabId
)
{
inactiveTab
=
document
.
getElementById
(
tabIDs
[
i
]);
if
(
inactiveTab
.
getAttribute
(
"isTab"
))
{
unselectAll
(
tabIDs
[
i
]);
inactiveTab
.
style
.
display
=
"none"
;
inactiveTab
.
active
=
false
;
}
}
}
tab
.
style
.
display
=
""
;
tab
.
active
=
true
;
if
(
toolbar
)
toolbar
.
setTab
(
tabId
);
activeTab
=
tab
;
tabChanged
();
}
function
toggleCategories
()
{
var
tab
=
document
.
getElementById
(
"categories"
);
tab
.
style
.
display
=
(
tab
.
style
.
display
==
"none"
)
?
""
:
"none"
;
tab
.
active
=
(
tab
.
style
.
display
!=
"none"
);
toolbar
.
showButton
(
'new_cat'
,
tab
.
active
)
unselectAll
(
"categories"
);
tabChanged
();
}
function
selectAll
(
tabId
)
{
changeSelection
(
tabId
,
0
)
}
function
unselectAll
(
tabId
)
{
changeSelection
(
tabId
,
1
)
}
function
invert
(
tabId
)
{
changeSelection
(
tabId
,
2
)
}
function
changeSelection
(
tabId
,
action
)
{
if
(
toolbar
)
{
var
tab
=
document
.
getElementById
(
tabId
);
if
(
!
tab
)
return
;
var
inputs
=
tab
.
getElementsByTagName
(
"INPUT"
);
for
(
var
j
=
0
;
j
<
inputs
.
length
;
j
++
)
if
((
inputs
[
j
].
type
==
"checkbox"
)
&&
(
inputs
[
j
].
inportalType
))
{
switch
(
action
)
{
case
(
0
)
:
selectContainer
(
inputs
[
j
],
true
,
true
)
break
;
case
(
1
)
:
selectContainer
(
inputs
[
j
],
false
,
true
)
break
;
default
:
selectContainer
(
inputs
[
j
],
(
!
inputs
[
j
].
checked
),
true
)
break
;
}
}
selectionChanged
();
}
}
function
selectContainer
(
checkBox
,
value
,
doNotFireSelectionEvent
)
{
if
(
!
checkBox
)
return
;
if
(
checkBox
.
checked
!=
value
)
{
checkBox
.
checked
=
value
;
if
(
value
)
tabSelection
[
checkBox
.
inportalType
]
++
else
tabSelection
[
checkBox
.
inportalType
]
--
;
}
checkBox
.
container
.
parentNode
.
className
=
(
checkBox
.
checked
)
?
"selectedContainer"
:
"unselectedContainer"
;
checkBox
.
container
.
className
=
(
checkBox
.
checked
)
?
"selectedContainer"
:
"unselectedContainer"
;
if
(
!
doNotFireSelectionEvent
)
selectionChanged
();
}
function
updateStatus
()
{
var
StatusString
=
""
;
for
(
var
i
=
0
;
i
<
tabIDs
.
length
;
i
++
)
StatusString
+=
tabIDs
[
i
]
+
": "
+
tabSelection
[
tabIDs
[
i
]]
+
"; "
;
StatusString
+=
"categories: "
+
tabSelection
[
'categories'
]
+
"; "
;
window
.
status
=
StatusString
;
}
function
selectionChanged
()
{
setTimeout
(
'selectionChangedA()'
,
0
)
}
var
activeTab
;
function
selectionChangedA
()
{
var
categories
=
document
.
getElementById
(
'categories'
);
for
(
var
i
=
0
;
i
<
tabIDs
.
length
;
i
++
)
{
var
thisTab
=
document
.
getElementById
(
tabIDs
[
i
])
if
(
!
thisTab
)
continue
;
if
(
thisTab
.
active
)
{
activeTab
=
thisTab
;
activeTab
.
title
=
getTabTitle
(
tabIDs
[
i
]);
break
;
}
}
var
numCategoriesSelected
=
tabSelection
[
'categories'
];
var
numActiveTabSelected
=
(
activeTab
)
?
tabSelection
[
activeTab
.
id
]
:
0
;
if
(
toolbar
)
{
//toolbar.enableButton("edit", (numCategoriesSelected + numActiveTabSelected == 1));
var
enableMiscButtons
=
(
numCategoriesSelected
+
numActiveTabSelected
>
0
&&
numCategoriesSelected
*
numActiveTabSelected
==
0
);
toolbar
.
enableButton
(
"edit"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"delete"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"approve"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"decline"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"cut"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"copy"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"paste"
,
true
);
toolbar
.
enableButton
(
"move_up"
,
enableMiscButtons
);
toolbar
.
enableButton
(
"move_down"
,
enableMiscButtons
);
}
}
function
tabChanged
()
{
if
(
activeTab
)
{
//alert('now active: '+activeTab.id)
}
// toggleMenu();
}
function
getTabTitle
(
tabId
)
{
var
tab
=
document
.
getElementById
(
tabId
);
if
(
!
tab
)
return
;
return
tab
.
getAttribute
(
"tabTitle"
);
}
function
isAnyChecked
(
tabId
)
{
return
tabSelection
[
tabId
]
>
0
;
}
Event Timeline
Log In to Comment