Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F802112
in-portal
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
Sat, Feb 22, 3:48 AM
Size
21 KB
Mime Type
text/x-diff
Expires
Mon, Feb 24, 3:48 AM (10 m, 21 s)
Engine
blob
Format
Raw Data
Handle
575262
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/RC/core/admin_templates/tree.tpl
===================================================================
--- branches/RC/core/admin_templates/tree.tpl (revision 9044)
+++ branches/RC/core/admin_templates/tree.tpl (revision 9045)
@@ -1,125 +1,126 @@
<inp2:m_Set skip_last_template="1"/>
<inp2:m_include t="incs/header" nobody="yes" noform="yes"/>
<inp2:m_NoDebug/>
<body style="margin: 0px; height: 100%" bgcolor="#DCEBF6">
<inp2:m_RenderElement name="kernel_form"/>
<script type="text/javascript">
function credits(url)
{
var width = 200;
var height = 200;
var screen_x = (screen.availWidth-width)/2;
var screen_y = (screen.availHeight-height)/2;
window.open(url, 'credits', 'width=280,height=520,left='+screen_x+',top='+screen_y);
}
</script>
<script src="js/ajax.js"></script>
<script src="js/tree.js"></script>
<style type="text/css">
.tree_head.td, .tree_head, .tree_head:hover {
font-weight: bold;
font-size: 10px;
color: #FFFFFF;
font-family: Verdana, Arial;
text-decoration: none;
}
.tree {
padding: 0px;
border: none;
border-collapse: collapse;
}
.tree tr td {
padding: 0px;
margin: 0px;
font-family: helvetica, arial, verdana,;
font-size: 11px;
white-space: nowrap;
}
.tree tr td a {
font-size: 11px;
color: #000000;
font-family: Helvetica, Arial, Verdana;
text-decoration: none;
}
.tree tr td a:hover {
color: #009FF0;
}
</style>
<table style="height: 100%; width: 100%; border-collapse: collapse;" border="0">
<tr style="background: #5291DE url(img/menu_bar.gif) repeat-x left bottom;" class="tree_head">
<td align="left" width="80%" height="21">
<a class="tree_head" href="javascript:credits('<inp2:m_Link index_file="help/credits.php" destform="popup"/>');">In-Portal v <inp2:adm_ModuleVersion module="In-Portal"/></a>
</td>
<td align="right" width="20%">
<select name="language" style="width: 62px; border: 0px; background-color: #FFFFFF; font-size: 9px; color: black;" onchange="submit_event('lang', 'OnChangeLanguage', 'index');">
<inp2:m_DefineElement name="lang_elem">
<option value="<inp2:Field name="LanguageId"/>" <inp2:m_if check="SelectedLanguage">selected="selected"</inp2:m_if> ><inp2:Field name="PackName"/></option>
</inp2:m_DefineElement>
<inp2:lang_ListLanguages render_as="lang_elem" row_start_render_as="html:" row_end_render_as="html:"/>
</select>
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: top; padding: 5px;">
<inp2:m_DefineElement name="xml_node" icon_module="">
<inp2:m_if check="m_ParamEquals" param="children_count" value="0">
<item href="<inp2:m_param name="section_url" js_escape="1"/>" priority="<inp2:m_param name="priority"/>" onclick="<inp2:m_param name="onclick" js_escape="1"/>" icon="<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif"><inp2:m_phrase name="$label" escape="1"/></item>
<inp2:m_else/>
<folder href="<inp2:m_param name="section_url" js_escape="1"/>" priority="<inp2:m_param name="priority"/>" onclick="<inp2:m_param name="onclick" js_escape="1"/>" name="<inp2:m_phrase name="$label" escape="1"/>" icon="<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif" load_url="<inp2:m_param name="late_load" js_escape="1"/>"><inp2:adm_PrintSections render_as="xml_node" section_name="$section_name"/></folder>
</inp2:m_if>
</inp2:m_DefineElement>
<table class="tree">
<tbody id="tree">
</tbody>
</table>
<script type="text/javascript">
var TREE_ICONS_PATH = 'img/tree';
var TREE_SHOW_PRIORITY = <inp2:m_if check="adm_ConstOn" name="DBG_SHOW_TREE_PRIORITY" debug_mode="1">1<inp2:m_else/>0</inp2:m_if>;
+ var TREE_SHOW_FIRST_ITEM = 0;
<inp2:m_DefineElement name="root_node">
var the_tree = new TreeFolder('tree', '<inp2:m_param name="label"/>', '<inp2:m_param name="section_url"/>', '<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif', null, null, '<inp2:m_param name="priority"/>');
</inp2:m_DefineElement>
<inp2:adm_PrintSection render_as="root_node" section_name="in-portal:root"/>
the_tree.AddFromXML('<tree><inp2:adm_PrintSections render_as="xml_node" section_name="in-portal:root"/></tree>');
</script>
</td>
</tr>
</table>
<inp2:m_include t="incs/footer"/>
<script type="text/javascript">
// when changing language submit is made to frameset, not the current frame
var $kf = document.getElementById($form_name);
$kf.target = 'main_frame';
function checkCatalog($cat_id) {
var $ret = checkEditMode();
var $right_frame = getFrame('main');
if ($ret && $right_frame.$is_catalog) {
$right_frame.$Catalog.go_to_cat($cat_id);
return 1; // this opens folder, but disables click
}
return $ret;
}
function checkEditMode()
{
var $phrase = "<inp2:adm_TreeEditWarrning label="la_EditingInProgress" escape="1"/>";
if (getFrame('main').$edit_mode) {
return confirm($phrase) ? true : false;
}
return true;
}
</script>
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/tree.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.7.2.1
\ No newline at end of property
Index: branches/RC/core/admin_templates/js/tree.js
===================================================================
--- branches/RC/core/admin_templates/js/tree.js (revision 9044)
+++ branches/RC/core/admin_templates/js/tree.js (revision 9045)
@@ -1,605 +1,635 @@
var last_hightlighted = null;
var last_highlighted_key = null;
function TreeItem(title, url, icon, onclick, priority)
{
this.Title = title;
this.Url = url;
this.Rendered = false;
this.Displayed = false;
this.Level = 0;
this.Icon = icon;
this.Onclick = onclick;
this.Priority = isset(priority) ? priority : false;
this.Children = false;
}
+TreeItem.prototype.isFolder = function()
+{
+ return typeof(this.folderClick) == 'function';
+}
+
TreeItem.prototype.Render = function(before, force)
{
if (!this.Rendered || force) {
if (!isset(before)) {before = null}
tr = document.createElement('tr');
this.ParentElement.insertBefore(tr, before);
if (!this.Displayed) { tr.style.display = 'none' }
td = document.createElement('td');
td.TreeElement = this;
tr.appendChild(td);
this.appendLevel(td);
if (this.ParentFolder != null) this.appendNodeImage(td);
this.appendIcon(td);
this.appendLink(td);
this.Tr = tr;
this.Rendered = true;
// alert(this.Tr.innerHTML)
}
}
TreeItem.prototype.remove = function()
{
var p = this.Tr.parentNode;
p.removeChild(this.Tr);
}
TreeItem.prototype.appendLevel = function(td)
{
for (var i=0; i < this.Level; i++)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = TREE_ICONS_PATH+'/ftv2blank.gif';
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
}
TreeItem.prototype.getNodeImage = function(is_last)
{
return is_last ? TREE_ICONS_PATH+'/ftv2lastnode.gif' : TREE_ICONS_PATH+'/ftv2node.gif';
}
TreeItem.prototype.appendNodeImage = function(td)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = this.getNodeImage();
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
TreeItem.prototype.appendIcon = function (td)
{
img = document.createElement('img');
img.style.width = '24px';
img.style.height = '22px';
if (this.Icon.indexOf('http://') != -1) {
img.src = this.Icon;
}
else {
img.src = this.Icon;
}
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
TreeItem.prototype.appendLink = function (td)
{
var $node_text = document.createElement('span');
$node_text.innerHTML = this.Title;
if (TREE_SHOW_PRIORITY && this.Priority !== false) {
$node_text.innerHTML += '<span class="priority"><sup>' + this.Priority + '</sup></span>';
}
link = document.createElement('a');
link.nodeValue = this.Title;
link.href = this.Url;
link.target = 'main';
link.appendChild($node_text);
link.treeItem = this;
//addEvent(link, 'click',
link.onclick =
function(ev) {
var e = is.ie ? window.event : ev;
res = true;
if (isset(this.treeItem.Onclick)) {
res = eval(this.treeItem.Onclick);
}
if (!res) { // if we need to cancel onclick action
if (is.ie) {
window.event.cancelBubble = true;
window.event.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
return res;
}
else {
// ensures, that click is made before AJAX request will be sent
if (res === true) {
// only in case of "true" is returned, used in catalog
+
+ if (this.treeItem.isFolder() && TREE_SHOW_FIRST_ITEM) {
+ this.treeItem.locateFirstItem().propagateUrl();
+ this.href = this.treeItem.Url; // update href's url affected by propagateUrl method
+ }
+
getFrame(link.target).location.href = this.href;
}
-
- if (!this.treeItem.Expanded && typeof(this.treeItem.folderClick) == 'function') {
+
+ if (!this.treeItem.Expanded && this.treeItem.isFolder()) {
if (this.treeItem.folderClick());
}
this.treeItem.highLight();
return false;
}
}
td.appendChild(link);
/*
if (this.LateLoadURL) {
var span = document.createElement('span');
span.innerHTML = ' Reload';
span.treeItem = this;
span.onclick = function(ev) {
this.treeItem.reload();
}
td.appendChild(span);
}
*/
}
TreeItem.prototype.display = function()
{
this.Tr.style.display = is.ie ? 'block' : 'table-row';
this.Displayed = true;
var do_sub = TreeManager.isExpanded(this.Key);
if (this.Children && do_sub && !this.Expanding) {
this.expand();
}
}
TreeItem.prototype.hide = function()
{
this.Tr.style.display = 'none';
this.Displayed = false;
}
TreeItem.prototype.highLight = function()
{
if (last_hightlighted) last_hightlighted.Tr.className = '';
- if (this.Children && this.Children.length > 0 && this.Children[0].Url.replace('&', '&') == this.Url.replace('&', '&')) {
+ if (this.Children && this.Children.length > 0 && (this.Children[0].Url.replace('&', '&') == this.Url.replace('&', '&') || TREE_SHOW_FIRST_ITEM)) {
if (!this.Expanded) {
this.expand();
}
this.Children[0].highLight();
return;
}
this.Tr.className = "highlighted";
last_hightlighted = this;
last_highlighted_key = this.Key;
if (!this.Expanded) {
this.expand();
}
}
TreeItem.prototype.expand = function() { this.display() }
TreeItem.prototype.collapse = function() { this.hide() }
TreeItem.prototype.updateLastNodes = function(is_last, lines_pattern)
{
if (!isset(is_last)) is_last = true;
if (!isset(this.Tr)) return;
if (!isset(lines_pattern)) { var lines_pattern = new Array() }
imgs = this.Tr.getElementsByTagName('img');
found = false;
for (var i=0; i<imgs.length; i++)
{
the_img = imgs.item(i);
if (in_array(i, lines_pattern) && the_img.src.indexOf('ftv2blank.gif') != -1) {
the_img.src = TREE_ICONS_PATH+'/ftv2vertline.gif';
}
if (this.isNodeImage(the_img))
{
found = true;
break;
}
}
if (found) {
the_img.src = this.getNodeImage(is_last);
}
this.isLast = is_last;
return lines_pattern;
}
TreeItem.prototype.isNodeImage = function(img)
{
return (
img.src.indexOf('ftv2node.gif') != -1 ||
img.src.indexOf('ftv2lastnode.gif') != -1
)
}
TreeItem.prototype.locateLastItem = function()
{
return this;
}
TreeItem.prototype.locateItemByURL = function(url)
{
if (this.Url == url) return this;
return false;
}
TreeItem.prototype.locateItemByKey = function(key)
{
if (this.Key == key) return this;
return false;
}
+TreeItem.prototype.propagateUrl = function()
+{
+ var $tree_node = this;
+ while (this.ParentFolder != null && $tree_node.Id == 1) {
+ $tree_node = $tree_node.ParentFolder;
+ $tree_node.Url = this.Url;
+ }
+}
+
TreeItem.prototype.reload = function()
{
}
/* FOLDER */
function TreeFolder(parent_id, title, url, icon, late_load_url, onclick, priority)
{
var render = false;
if (isset(parent_id)) {
this.ParentElement = document.getElementById(parent_id);
render = true;
}
else {
}
this.Title = title;
this.Url = url;
this.Rendered = false;
this.Displayed = false;
this.Expanded = false;
this.Level = 0;
this.Id = 0;
this.Tr = null;
this.Icon = icon;
this.LateLoadURL = isset(late_load_url) ? late_load_url : false;
this.Loaded = false;
this.Onclick = onclick;
this.Priority = isset(priority) ? priority : false;
this.Children = new Array();
this.ChildIndex = 0;
if (render) {
this.Expanded = true;
this.Displayed = true;
this.Render();
this.expand();
}
}
TreeFolder.prototype = new TreeItem;
TreeFolder.prototype.locateLastItem = function()
{
if (this.Children.length == 0) return this;
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateLastItem()
}
return last_item;
}
+TreeFolder.prototype.locateFirstItem = function()
+{
+ var $folder_node = this;
+ while ($folder_node.isFolder() && $folder_node.Children.length > 0) {
+ $folder_node = $folder_node.Children[0];
+ }
+
+ return $folder_node;
+}
+
TreeFolder.prototype.locateItemByURL = function(url, with_late_load)
{
last_item = false;
if (this.Url == url && ( (with_late_load && this.LateLoadURL) || !with_late_load) ) {
return this;
}
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateItemByURL(url, with_late_load)
if (last_item) return last_item;
}
return last_item;
}
TreeFolder.prototype.locateItemByKey = function(key)
{
last_item = false;
if (this.Key == key) {
return this;
}
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateItemByKey(key)
if (last_item) return last_item;
}
return last_item;
}
TreeFolder.prototype.locateTopItem = function()
{
if (this.ParentFolder == null) return this;
return this.ParentFolder.locateTopItem();
}
TreeFolder.prototype.AddItem = function(an_item, render, display) {
an_item.ParentElement = this.ParentElement;
an_item.Level = this.ParentFolder != null ? this.Level + 1 : 0;
an_item.ParentFolder = this;
last_item = this.locateLastItem();
this.Children.push(an_item);
an_item.Id = this.Children.length;
an_item.Render(last_item.Tr.nextSibling);
var keys = new Array()
var tmp = an_item;
keys.push(tmp.Level + '_' + tmp.Id);
while (tmp.ParentFolder) {
tmp = tmp.ParentFolder
keys.push(tmp.Level + '_' + tmp.Id);
}
keys = keys.reverse();
key_str = keys.join('-');
an_item.Key = key_str;
if (this.Expanded)
{
an_item.display();
}
return an_item;
}
TreeFolder.prototype.AddFromXML = function(xml, render)
{
// start = new Date();
if (!isset(render)) render = true;
doc = getDocumentFromXML(xml);
this.LastFolder = this;
this.ProcessXMLNode(doc, render);
// end = new Date();
this.locateTopItem().updateLastNodes();
// alert('AddFromXML took: '+(end - start))
}
TreeFolder.prototype.ProcessXMLNode = function(node, render)
{
if (!isset(render)) render = true;
if (!isset(this.LastFolder)) this.LastFolder = this;
for (var i=0; i<node.childNodes.length; i++)
{
child = node.childNodes.item(i);
if (child.tagName == 'folder') {
var backupLastFolder = this.LastFolder;
this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url'), child.getAttribute('onclick'), child.getAttribute('priority')), render);
if (child.hasChildNodes) {
this.ProcessXMLNode(child);
}
this.LastFolder = backupLastFolder;
}
else if (child.tagName == 'item') {
this.LastFolder.AddItem(new TreeItem(child.firstChild.nodeValue, child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('onclick'), child.getAttribute('priority')), render)
}
else if (child.tagName == 'tree') {
this.LastFolder = this;
this.ProcessXMLNode(child);
}
}
}
TreeFolder.prototype.getNodeImage = function(is_last)
{
if (is_last) {
return this.Expanded ? TREE_ICONS_PATH+'/ftv2mlastnode.gif' : TREE_ICONS_PATH+'/ftv2plastnode.gif';
}
else {
return this.Expanded ? TREE_ICONS_PATH+'/ftv2mnode.gif' : TREE_ICONS_PATH+'/ftv2pnode.gif';
}
}
TreeFolder.prototype.appendNodeImage = function(td, is_last)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = this.getNodeImage(is_last);
img.style.cursor = 'hand';
img.style.cursor = 'pointer';
img.style.verticalAlign = 'middle';
img.onclick = function() { this.parentNode.TreeElement.folderClick(this) }
this.Img = img;
td.appendChild(img);
}
TreeFolder.prototype.updateLastNodes = function(is_last, lines_pattern)
{
if (!isset(is_last)) is_last = true;
if (!isset(lines_pattern)) { var lines_pattern = new Array() }
if (!is_last && !in_array(this.Level, lines_pattern)) { lines_pattern.push(this.Level) }
lines_pattern = TreeItem.prototype.updateLastNodes.apply(this, new Array(is_last, lines_pattern))
for (var i=0; i<this.Children.length; i++)
{
lines_pattern = this.Children[i].updateLastNodes((i+1) == this.Children.length, lines_pattern)
}
lines_pattern[array_search(this.Level, lines_pattern)] = -1;
return lines_pattern;
}
TreeFolder.prototype.isNodeImage = function(img)
{
return (
img.src.indexOf('ftv2mlastnode.gif') != -1 ||
img.src.indexOf('ftv2plastnode.gif') != -1 ||
img.src.indexOf('ftv2mnode.gif') != -1 ||
img.src.indexOf('ftv2pnode.gif') != -1
)
}
TreeFolder.prototype.folderClick = function(img)
{
if (this.Expanded) {
this.collapse();
}
else {
this.expand();
}
}
TreeFolder.prototype.remove = function()
{
this.removeChildren();
var p = this.Tr.parentNode;
p.removeChild(this.Tr);
}
TreeFolder.prototype.removeChildren = function()
{
for (var i in this.Children) {
this.Children[i].remove();
}
this.Children = new Array();
}
TreeFolder.prototype.successCallback = function ($request, $params, $object) {
if ($params == 'reload') {
$object.removeChildren();
}
$object.Loaded = true;
$object.ProcessXMLNode($request.responseXML);
$object.Render();
$object.locateTopItem().updateLastNodes();
$object.expand();
if (last_highlighted_key) {
var fld = $object.locateItemByKey(last_highlighted_key)
if (fld) {
fld.highLight();
}
}
}
TreeFolder.prototype.reload = function()
{
Request.headers['Content-type'] = 'text/xml';
Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, 'reload', this);
}
TreeFolder.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX ERROR: ' + Request.getErrorHtml($request));
}
TreeFolder.prototype.expand = function(mode)
{
if (this.Expanding) {
return;
}
this.Expanding = true;
if (!isset(mode)) mode = 0;
this.display();
if (mode == 0 || this.Expanded ) {
for (var i=0; i<this.Children.length; i++)
{
this.Children[i].expand(mode+1);
}
}
if (mode == 0) {
if (this.LateLoadURL && !this.Loaded) {
Request.headers['Content-type'] = 'text/xml';
Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, '', this);
}
this.Expanded = true;
TreeManager.markStatus(this.Key, 1)
if (isset(this.Img)) {
this.Img.src = this.getNodeImage(this.isLast);
}
}
this.Expanding = false;
}
TreeFolder.prototype.collapse = function(mode)
{
if (!isset(mode)) mode = 0;
for (var i=0; i<this.Children.length; i++)
{
this.Children[i].collapse(mode+1);
this.Children[i].hide();
}
if (mode == 0) {
this.Expanded = false;
TreeManager.markStatus(this.Key, 0)
if (isset(this.Img)) {
this.Img.src = this.getNodeImage(this.isLast);
}
}
}
function TreeManager() {}
TreeManager.ExpandStatus = [];
TreeManager.markStatus = function(id, status)
{
this.ExpandStatus[id] = status;
if (!status) {
for (var i in this.ExpandStatus) {
if (i.indexOf(id) == 0) { // if i starts with the same as id, meaning it is its child node
this.ExpandStatus[i] = 0;
}
}
}
TreeManager.saveStatus()
}
TreeManager.isExpanded = function(id)
{
return (this.ExpandStatus[id] == 1);
}
TreeManager.saveStatus = function ()
{
var cookieString = new Array();
for (var i in this.ExpandStatus) {
if (this.ExpandStatus[i] == 1) {
cookieString.push(i);
}
}
document.cookie = 'TreeExpandStatus=' + cookieString.join(':');
}
TreeManager.loadStatus = function ()
{
var doc_cookies = document.cookie.split('; ');
for (var i=0; i < doc_cookies.length; i++) {
var pair = doc_cookies[i].split('=');
if ('TreeExpandStatus' == pair[0] && pair[1]) {
var expandedBranches = pair[1].split(':');
for (var j=0; j<expandedBranches.length; j++) {
this.ExpandStatus[expandedBranches[j]] = true;
}
}
}
// print_pre(this.ExpandStatus)
}
TreeManager.loadStatus();
Property changes on: branches/RC/core/admin_templates/js/tree.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6
\ No newline at end of property
+1.6.2.1
\ No newline at end of property
Event Timeline
Log In to Comment