+ add the feature of tree group.
This commit is contained in:
@@ -94,7 +94,7 @@ $lang->release->menu = $lang->product->menu;
|
||||
|
||||
/* 项目视图菜单设置。*/
|
||||
$lang->project->menu->list = '%s';
|
||||
$lang->project->menu->task = array('link' => '任务列表|project|task|projectID=%s', 'subModule' => 'task');
|
||||
$lang->project->menu->task = array('link' => '任务列表|project|task|projectID=%s', 'subModule' => 'task', 'alias' => 'grouptask');
|
||||
$lang->project->menu->story = array('link' => '需求列表|project|story|projectID=%s', 'alias' => 'linkstory');
|
||||
$lang->project->menu->bug = 'Bug列表|project|bug|projectID=%s';
|
||||
$lang->project->menu->build = array('link' => 'Build列表|project|build|projectID=%s', 'subModule' => 'build');
|
||||
|
||||
3
trunk/module/common/treetable.html.php
Normal file
3
trunk/module/common/treetable.html.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<link rel='stylesheet' href='<?php echo $clientTheme;?>treetable.css' type='text/css' />
|
||||
<script src='<?php echo $jsRoot;?>jquery/treetable/min.js' type='text/javascript'></script>
|
||||
<script language='javascript'>$(function() { $("#treetable").treeTable({clickableNodeNames:true,initialState:"expanded"})})</script>
|
||||
@@ -75,9 +75,6 @@ class project extends control
|
||||
/* 浏览某一个项目下面的任务。*/
|
||||
public function task($projectID = 0, $orderBy = 'status|asc,id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
/* 加载任务模块。*/
|
||||
$this->loadModel('task');
|
||||
|
||||
/* 公共的操作。*/
|
||||
$project = $this->commonAction($projectID);
|
||||
$projectID = $project->id;
|
||||
@@ -87,28 +84,81 @@ class project extends control
|
||||
$this->app->session->set('storyList', $this->app->getURI(true));
|
||||
|
||||
/* 设定header和position信息。*/
|
||||
$header['title'] = $project->name . $this->lang->colon . $this->lang->project->task;
|
||||
$position[] = html::a($this->createLink('project', 'browse', "projectID=$projectID"), $project->name);
|
||||
$position[] = $this->lang->project->task;
|
||||
$this->view->header->title = $project->name . $this->lang->colon . $this->lang->project->task;
|
||||
$this->view->position[] = html::a($this->createLink('project', 'browse', "projectID=$projectID"), $project->name);
|
||||
$this->view->position[] = $this->lang->project->task;
|
||||
|
||||
/* 分页操作。*/
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
$tasks = $this->task->getProjectTasks($projectID, $orderBy, $pager);
|
||||
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $orderBy, $pager);
|
||||
|
||||
/* 赋值。*/
|
||||
$this->assign('header', $header);
|
||||
$this->assign('position', $position);
|
||||
$this->assign('tasks', $tasks);
|
||||
$this->assign('tabID', 'task');
|
||||
$this->assign('pager', $pager->get());
|
||||
$this->assign('recTotal', $pager->recTotal);
|
||||
$this->assign('recPerPage', $pager->recPerPage);
|
||||
$this->assign('orderBy', $orderBy);
|
||||
$this->view->tasks = $tasks;
|
||||
$this->view->tabID = 'task';
|
||||
$this->view->pager = $pager->get();
|
||||
$this->view->recTotal = $pager->recTotal;
|
||||
$this->view->recPerPage = $pager->recPerPage;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->browseType = 'list';
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 按照tree的方式查看任务。*/
|
||||
public function grouptask($projectID = 0, $groupBy = 'story')
|
||||
{
|
||||
/* 公共的操作。*/
|
||||
$project = $this->commonAction($projectID);
|
||||
$projectID = $project->id;
|
||||
|
||||
/* 记录用户当前选择的列表。*/
|
||||
$this->app->session->set('taskList', $this->app->getURI(true));
|
||||
$this->app->session->set('storyList', $this->app->getURI(true));
|
||||
|
||||
/* 设定header和position信息。*/
|
||||
$this->view->header['title'] = $project->name . $this->lang->colon . $this->lang->project->task;
|
||||
$this->view->position[] = html::a($this->createLink('project', 'browse', "projectID=$projectID"), $project->name);
|
||||
$this->view->position[] = $this->lang->project->task;
|
||||
|
||||
/* 获得任务列表,并将其分组。*/
|
||||
$tasks = $this->loadModel('task')->getProjectTasks($projectID, $groupBy);
|
||||
$groupBy = strtolower(str_replace('`', '', $groupBy));
|
||||
$taskLang = $this->lang->task;
|
||||
$groupByList = array();
|
||||
foreach($tasks as $task)
|
||||
{
|
||||
if($groupBy == 'story')
|
||||
{
|
||||
$groupTasks[$task->story][] = $task;
|
||||
$groupByList[$task->story] = $task->storyTitle;
|
||||
}
|
||||
elseif($groupBy == 'status')
|
||||
{
|
||||
$groupTasks[$taskLang->statusList[$task->status]][] = $task;
|
||||
}
|
||||
elseif($groupBy == 'owner')
|
||||
{
|
||||
$groupTasks[$task->ownerRealName][] = $task;
|
||||
}
|
||||
elseif($groupBy == 'type')
|
||||
{
|
||||
$groupTasks[$taskLang->typeList[$task->type]][] = $task;
|
||||
}
|
||||
else
|
||||
{
|
||||
$groupTasks[$task->$groupBy][] = $task;
|
||||
}
|
||||
}
|
||||
|
||||
/* 赋值。*/
|
||||
$this->view->tasks = $groupTasks;
|
||||
$this->view->tabID = 'task';
|
||||
$this->view->groupByList = $groupByList;
|
||||
$this->view->browseType = $groupBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/* 浏览某一个项目下面的需求。*/
|
||||
public function story($projectID = 0, $orderBy = 'status|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
|
||||
@@ -78,6 +78,16 @@ $lang->project->bug = 'Bug列表';
|
||||
$lang->project->build = 'Build列表';
|
||||
$lang->project->burn = '燃烧图';
|
||||
$lang->project->burnData = '燃烧图数据';
|
||||
$lang->project->listTask = '列表方式';
|
||||
$lang->project->groupTaskByStory = '按需求分组';
|
||||
$lang->project->groupTaskByStatus = '按状态分组';
|
||||
$lang->project->groupTaskByPri = '按优先级分组';
|
||||
$lang->project->groupTaskByOwner = '按指派给分组';
|
||||
$lang->project->groupTaskByEstimate = '按预计工时分组';
|
||||
$lang->project->groupTaskByConsumed = '按已消耗分组';
|
||||
$lang->project->groupTaskByLeft = '按剩余工时分组';
|
||||
$lang->project->groupTaskByType = '按任务类型分组';
|
||||
$lang->project->groupTaskByDeadline = '按截止日期分组';
|
||||
|
||||
$lang->project->beginAndEnd = '起止时间';
|
||||
$lang->project->lblStats = '工时统计';
|
||||
|
||||
74
trunk/module/project/view/grouptask.html.php
Normal file
74
trunk/module/project/view/grouptask.html.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* The task group view file of project module of ZenTaoMS.
|
||||
*
|
||||
* ZenTaoMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* ZenTaoMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @copyright Copyright 2009-2010 Chunsheng Wang
|
||||
* @author Chunsheng Wang <wwccss@263.net>
|
||||
* @package project
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.cn
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<?php include '../../common/treetable.html.php';?>
|
||||
<?php include './taskheader.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<table class='table-1' id='treetable'>
|
||||
<tr class='colhead bg-gray strong a-center'>
|
||||
<td></td>
|
||||
<td><?php echo $lang->task->name;?></td>
|
||||
<td><?php echo $lang->task->pri;?></td>
|
||||
<td><?php echo $lang->task->owner;?></td>
|
||||
<td><?php echo $lang->task->estimate;?></td>
|
||||
<td><?php echo $lang->task->consumed;?></td>
|
||||
<td><?php echo $lang->task->left;?></td>
|
||||
<td><?php echo $lang->task->type;?></td>
|
||||
<td><?php echo $lang->task->deadline;?></td>
|
||||
<td colspan='2' class='a-left'><?php echo $lang->task->status;?></td>
|
||||
</tr>
|
||||
<tr><td colspan='12' style='padding:0; background:#e4e4e4; height:1px'></td></tr>
|
||||
<?php $i = 0;?>
|
||||
<?php foreach($tasks as $groupKey => $groupTasks):?>
|
||||
<?php $groupClass = ($i % 2 == 0) ? 'odd' : 'bg-yellow'; $i ++;?>
|
||||
<tr id='node-<?php echo $groupKey;?>'>
|
||||
<td class='<?php echo $groupClass;?> a-center f-16px strong'><?php echo $groupKey;?></td>
|
||||
<td colspan='11'><?php if($groupByList) echo $groupByList[$groupKey];?></td>
|
||||
</tr>
|
||||
<?php foreach($groupTasks as $task):?>
|
||||
<?php $ownerClass = $task->owner == $app->user->account ? 'style=color:red' : '';?>
|
||||
<tr id='<?php echo $task->id;?>' class='a-center child-of-node-<?php echo $groupKey;?>'>
|
||||
<td class='<?php echo $groupClass;?>'></td>
|
||||
<td class='a-left'> <?php echo $task->id . $lang->colon; if(common::hasPriv('task', 'view')) echo html::a($this->createLink('task', 'view', "task=$task->id"), $task->name); else echo $task->name;?></td>
|
||||
<td><?php echo $task->pri;?></td>
|
||||
<td <?php echo $ownerClass;?>><?php echo $task->ownerRealName;?></td>
|
||||
<td><?php echo $task->estimate;?></td>
|
||||
<td><?php echo $task->consumed;?></td>
|
||||
<td><?php echo $task->left;?></td>
|
||||
<td><?php echo $lang->task->typeList[$task->type];?></td>
|
||||
<td class=<?php if(isset($task->delay)) echo 'delayed';?>><?php if(substr($task->deadline, 0, 4) > 0) echo $task->deadline;?></td>
|
||||
<td class=<?php echo $task->status;?> ><?php echo $lang->task->statusList[$task->status];?></td>
|
||||
<td>
|
||||
<?php if(common::hasPriv('task', 'edit')) echo html::a($this->createLink('task', 'edit', "taskid=$task->id"), $lang->edit);?>
|
||||
<?php if(common::hasPriv('task', 'delete')) echo html::a($this->createLink('task', 'delete', "projectID=$task->project&taskid=$task->id"), $lang->delete, 'hiddenwin');?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<tr><td colspan='12' style='padding:0; background:#e4e4e4; height:1px'></td></tr>
|
||||
<?php endforeach;?>
|
||||
</table>
|
||||
</div>
|
||||
<script language='Javascript'>$('#by<?php echo $browseType;?>').addClass('active');</script>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
@@ -24,18 +24,8 @@
|
||||
?>
|
||||
<?php include '../../common/header.html.php';?>
|
||||
<?php include '../../common/colorize.html.php';?>
|
||||
<div class="yui-d0">
|
||||
<div id='featurebar'>
|
||||
<div class='f-left'>
|
||||
<?php include './project.html.php';?>
|
||||
</div>
|
||||
<div class='f-right'>
|
||||
<?php
|
||||
common::printLink('task', 'create', "project=$project->id", $lang->task->create);
|
||||
//common::printLink('task', 'import', "project=$project->id", $lang->task->import);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php include './taskheader.html.php';?>
|
||||
<div class='yui-d0'>
|
||||
<table class='table-1 fixed colored'>
|
||||
<?php $vars = "projectID=$project->id&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage"; ?>
|
||||
<thead>
|
||||
@@ -67,7 +57,7 @@
|
||||
<td><?php echo $task->left;?></td>
|
||||
<td><?php echo $lang->task->typeList[$task->type];?></td>
|
||||
<td class=<?php if(isset($task->delay)) echo 'delayed';?>><?php if(substr($task->deadline, 0, 4) > 0) echo $task->deadline;?></td>
|
||||
<td class=<?php echo $task->status;?> ><?php echo $lang->task->statusList->{$task->status};?></td>
|
||||
<td class=<?php echo $task->status;?> ><?php echo $lang->task->statusList[$task->status];?></td>
|
||||
<td class='a-left nobr'>
|
||||
<?php
|
||||
if($task->storyID)
|
||||
@@ -87,4 +77,5 @@
|
||||
</table>
|
||||
<div class='a-right'><?php echo $pager;?></div>
|
||||
</div>
|
||||
<script language='Javascript'>$('#by<?php echo $browseType;?>').addClass('active');</script>
|
||||
<?php include '../../common/footer.html.php';?>
|
||||
|
||||
22
trunk/module/project/view/taskheader.html.php
Normal file
22
trunk/module/project/view/taskheader.html.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="yui-d0">
|
||||
<div class='bg-gray mb-10px padding-5px'>
|
||||
<?php include './project.html.php';?>
|
||||
</div>
|
||||
<div id='featurebar'>
|
||||
<div class='f-left'>
|
||||
<?php
|
||||
echo "<span id='bylist'>" ; common::printLink('project', 'task', "project=$project->id", $lang->project->listTask); echo '</span>' ;
|
||||
echo "<span id='bystory'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=story", $lang->project->groupTaskByStory); echo '</span>' ;
|
||||
echo "<span id='bystatus'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=status", $lang->project->groupTaskByStatus); echo '</span>' ;
|
||||
echo "<span id='bypri'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=pri", $lang->project->groupTaskByPri); echo '</span>' ;
|
||||
echo "<span id='byowner'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=owner", $lang->project->groupTaskByOwner); echo '</span>' ;
|
||||
echo "<span id='byestimate'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=estimate",$lang->project->groupTaskByEstimate); echo '</span>' ;
|
||||
echo "<span id='byconsumed'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=consumed",$lang->project->groupTaskByConsumed); echo '</span>' ;
|
||||
echo "<span id='byleft'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=`left`", $lang->project->groupTaskByLeft); echo '</span>' ;
|
||||
echo "<span id='bytype'>" ; common::printLink('project', 'groupTask', "project=$project->id&groupby=type", $lang->project->groupTaskByType); echo '</span>' ;
|
||||
echo "<span id='bydeadline'>"; common::printLink('project', 'groupTask', "project=$project->id&groupby=deadline",$lang->project->groupTaskByDeadline); echo '</span>' ;
|
||||
?>
|
||||
</div>
|
||||
<div class='f-right'><?php common::printLink('task', 'create', "project=$project->id", $lang->task->create); ?></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,11 +45,11 @@ $lang->task->status = '任务状态';
|
||||
$lang->task->desc = '任务描述';
|
||||
$lang->task->statusCustom = '状态排序';
|
||||
|
||||
$lang->task->statusList->wait = '未开始';
|
||||
$lang->task->statusList->doing = '进行中';
|
||||
$lang->task->statusList->done = '已完成';
|
||||
$lang->task->statusList->cancel = '已取消';
|
||||
$lang->task->statusList->delayed = '延期';
|
||||
$lang->task->statusList['wait'] = '未开始';
|
||||
$lang->task->statusList['doing'] = '进行中';
|
||||
$lang->task->statusList['done'] = '已完成';
|
||||
$lang->task->statusList['cancel'] = '已取消';
|
||||
$lang->task->statusList['delayed'] = '延期';
|
||||
|
||||
$lang->task->typeList[''] = '';
|
||||
$lang->task->typeList['design'] = '设计';
|
||||
|
||||
13
trunk/www/js/jquery/treetable/min.js
vendored
Normal file
13
trunk/www/js/jquery/treetable/min.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/* jQuery treeTable Plugin 2.2.3 - http://ludo.cubicphuse.nl/jquery-plugins/treeTable/ */
|
||||
(function($){var options;var defaultPaddingLeft;$.fn.treeTable=function(opts){options=$.extend({},$.fn.treeTable.defaults,opts);return this.each(function(){$(this).addClass("treeTable").find("tbody tr").each(function(){if(!options.expandable||$(this)[0].className.search("child-of-")==-1){if(isNaN(defaultPaddingLeft)){defaultPaddingLeft=parseInt($($(this).children("td")[options.treeColumn]).css('padding-left'),10);}
|
||||
initialize($(this));}else if(options.initialState=="collapsed"){this.style.display="none";}});});};$.fn.treeTable.defaults={childPrefix:"child-of-",clickableNodeNames:false,expandable:true,indent:19,initialState:"collapsed",treeColumn:0};$.fn.collapse=function(){$(this).addClass("collapsed");childrenOf($(this)).each(function(){if(!$(this).hasClass("collapsed")){$(this).collapse();}
|
||||
this.style.display="none";});return this;};$.fn.expand=function(){$(this).removeClass("collapsed").addClass("expanded");childrenOf($(this)).each(function(){initialize($(this));if($(this).is(".expanded.parent")){$(this).expand();}
|
||||
$(this).show();});return this;};$.fn.appendBranchTo=function(destination){var node=$(this);var parent=parentOf(node);var ancestorNames=$.map(ancestorsOf($(destination)),function(a){return a.id;});if($.inArray(node[0].id,ancestorNames)==-1&&(!parent||(destination.id!=parent[0].id))&&destination.id!=node[0].id){indent(node,ancestorsOf(node).length*options.indent*-1);if(parent){node.removeClass(options.childPrefix+parent[0].id);}
|
||||
node.addClass(options.childPrefix+destination.id);move(node,destination);indent(node,ancestorsOf(node).length*options.indent);}
|
||||
return this;};$.fn.reverse=function(){return this.pushStack(this.get().reverse(),arguments);};$.fn.toggleBranch=function(){if($(this).hasClass("collapsed")){$(this).expand();}else{$(this).removeClass("expanded").collapse();}
|
||||
return this;};function ancestorsOf(node){var ancestors=[];while(node=parentOf(node)){ancestors[ancestors.length]=node[0];}
|
||||
return ancestors;};function childrenOf(node){return $("table.treeTable tbody tr."+options.childPrefix+node[0].id);};function getPaddingLeft(node){var paddingLeft=parseInt(node[0].style.paddingLeft,10);return(isNaN(paddingLeft))?defaultPaddingLeft:paddingLeft;}
|
||||
function indent(node,value){var cell=$(node.children("td")[options.treeColumn]);cell[0].style.paddingLeft=getPaddingLeft(cell)+value+"px";childrenOf(node).each(function(){indent($(this),value);});};function initialize(node){if(!node.hasClass("initialized")){node.addClass("initialized");var childNodes=childrenOf(node);if(!node.hasClass("parent")&&childNodes.length>0){node.addClass("parent");}
|
||||
if(node.hasClass("parent")){var cell=$(node.children("td")[options.treeColumn]);var padding=getPaddingLeft(cell)+options.indent;childNodes.each(function(){$(this).children("td")[options.treeColumn].style.paddingLeft=padding+"px";});if(options.expandable){cell.prepend('<span style="margin-left: -'+options.indent+'px; padding-left: '+options.indent+'px" class="expander"></span>');$(cell[0].firstChild).click(function(){node.toggleBranch();});if(options.clickableNodeNames){cell[0].style.cursor="pointer";$(cell).click(function(e){if(e.target.className!='expander'){node.toggleBranch();}});}
|
||||
if(!(node.hasClass("expanded")||node.hasClass("collapsed"))){node.addClass(options.initialState);}
|
||||
if(node.hasClass("expanded")){node.expand();}}}}};function move(node,destination){node.insertAfter(destination);childrenOf(node).reverse().each(function(){move($(this),node[0]);});};function parentOf(node){var classNames=node[0].className.split(' ');for(key in classNames){if(classNames[key].match("child-of-")){return $("#"+classNames[key].substring(9));}}};})(jQuery);
|
||||
191
trunk/www/js/jquery/treetable/raw.js
vendored
Normal file
191
trunk/www/js/jquery/treetable/raw.js
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
/* jQuery treeTable Plugin 2.2.2 - http://ludo.cubicphuse.nl/jquery-plugins/treeTable/ */
|
||||
(function($) {
|
||||
// Helps to make options available to all functions
|
||||
// TODO: This gives problems when there are both expandable and non-expandable
|
||||
// trees on a page. The options shouldn't be global to all these instances!
|
||||
var options;
|
||||
|
||||
$.fn.treeTable = function(opts) {
|
||||
options = $.extend({}, $.fn.treeTable.defaults, opts);
|
||||
|
||||
return this.each(function() {
|
||||
$(this).addClass("treeTable").find("tbody tr").each(function() {
|
||||
// Initialize root nodes only if possible
|
||||
if(!options.expandable || $(this)[0].className.search("child-of-") == -1) {
|
||||
initialize($(this));
|
||||
} else if(options.initialState == "collapsed") {
|
||||
this.style.display = "none"; // Performance! $(this).hide() is slow...
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.treeTable.defaults = {
|
||||
childPrefix: "child-of-",
|
||||
clickableNodeNames: false,
|
||||
expandable: true,
|
||||
indent: 19,
|
||||
initialState: "collapsed",
|
||||
treeColumn: 0
|
||||
};
|
||||
|
||||
// Recursively hide all node's children in a tree
|
||||
$.fn.collapse = function() {
|
||||
$(this).addClass("collapsed");
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
if(!$(this).hasClass("collapsed")) {
|
||||
$(this).collapse();
|
||||
}
|
||||
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Recursively show all node's children in a tree
|
||||
$.fn.expand = function() {
|
||||
$(this).removeClass("collapsed").addClass("expanded");
|
||||
|
||||
childrenOf($(this)).each(function() {
|
||||
initialize($(this));
|
||||
|
||||
if($(this).is(".expanded.parent")) {
|
||||
$(this).expand();
|
||||
}
|
||||
|
||||
$(this).show();
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add an entire branch to +destination+
|
||||
$.fn.appendBranchTo = function(destination) {
|
||||
var node = $(this);
|
||||
var parent = parentOf(node);
|
||||
|
||||
var ancestorNames = $.map(ancestorsOf($(destination)), function(a) { return a.id; });
|
||||
|
||||
// Conditions:
|
||||
// 1: +node+ should not be inserted in a location in a branch if this would
|
||||
// result in +node+ being an ancestor of itself.
|
||||
// 2: +node+ should not have a parent OR the destination should not be the
|
||||
// same as +node+'s current parent (this last condition prevents +node+
|
||||
// from being moved to the same location where it already is).
|
||||
// 3: +node+ should not be inserted as a child of +node+ itself.
|
||||
if($.inArray(node[0].id, ancestorNames) == -1 && (!parent || (destination.id != parent[0].id)) && destination.id != node[0].id) {
|
||||
indent(node, ancestorsOf(node).length * options.indent * -1); // Remove indentation
|
||||
|
||||
if(parent) { node.removeClass(options.childPrefix + parent[0].id); }
|
||||
|
||||
node.addClass(options.childPrefix + destination.id);
|
||||
move(node, destination); // Recursively move nodes to new location
|
||||
indent(node, ancestorsOf(node).length * options.indent);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// Add reverse() function from JS Arrays
|
||||
$.fn.reverse = function() {
|
||||
return this.pushStack(this.get().reverse(), arguments);
|
||||
};
|
||||
|
||||
// Toggle an entire branch
|
||||
$.fn.toggleBranch = function() {
|
||||
if($(this).hasClass("collapsed")) {
|
||||
$(this).expand();
|
||||
} else {
|
||||
$(this).removeClass("expanded").collapse();
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
// === Private functions
|
||||
|
||||
function ancestorsOf(node) {
|
||||
var ancestors = [];
|
||||
while(node = parentOf(node)) {
|
||||
ancestors[ancestors.length] = node[0];
|
||||
}
|
||||
return ancestors;
|
||||
};
|
||||
|
||||
function childrenOf(node) {
|
||||
return $("table.treeTable tbody tr." + options.childPrefix + node[0].id);
|
||||
};
|
||||
|
||||
function indent(node, value) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
var padding = parseInt(cell.css("padding-left"), 10) + value;
|
||||
|
||||
cell.css("padding-left", + padding + "px");
|
||||
|
||||
childrenOf(node).each(function() {
|
||||
indent($(this), value);
|
||||
});
|
||||
};
|
||||
|
||||
function initialize(node) {
|
||||
if(!node.hasClass("initialized")) {
|
||||
node.addClass("initialized");
|
||||
|
||||
var childNodes = childrenOf(node);
|
||||
|
||||
if(!node.hasClass("parent") && childNodes.length > 0) {
|
||||
node.addClass("parent");
|
||||
}
|
||||
|
||||
if(node.hasClass("parent")) {
|
||||
var cell = $(node.children("td")[options.treeColumn]);
|
||||
var padding = parseInt(cell.css("padding-left"), 10) + options.indent;
|
||||
|
||||
childNodes.each(function() {
|
||||
$($(this).children("td")[options.treeColumn]).css("padding-left", padding + "px");
|
||||
});
|
||||
|
||||
if(options.expandable) {
|
||||
cell.prepend('<span style="margin-left: -' + options.indent + 'px; padding-left: ' + options.indent + 'px" class="expander"></span>');
|
||||
$(cell[0].firstChild).click(function() { node.toggleBranch(); });
|
||||
|
||||
if(options.clickableNodeNames) {
|
||||
$(cell).css('cursor', 'pointer');
|
||||
$(cell).click(function(e) {
|
||||
// Don't double-toggle if the click is on the existing expander icon
|
||||
if (e.target.className != 'expander') {
|
||||
node.toggleBranch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check for a class set explicitly by the user, otherwise set the default class
|
||||
if(!(node.hasClass("expanded") || node.hasClass("collapsed"))) {
|
||||
node.addClass(options.initialState);
|
||||
}
|
||||
|
||||
if(node.hasClass("expanded")) {
|
||||
node.expand();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function move(node, destination) {
|
||||
node.insertAfter(destination);
|
||||
childrenOf(node).reverse().each(function() { move($(this), node[0]); });
|
||||
};
|
||||
|
||||
function parentOf(node) {
|
||||
var classNames = node[0].className.split(' ');
|
||||
|
||||
for(key in classNames) {
|
||||
if(classNames[key].match("child-of-")) {
|
||||
return $("#" + classNames[key].substring(9));
|
||||
}
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
trunk/www/theme/default/images/treetable/toggle-expand-dark.png
Normal file
BIN
trunk/www/theme/default/images/treetable/toggle-expand-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
trunk/www/theme/default/images/treetable/toggle-expand-light.png
Normal file
BIN
trunk/www/theme/default/images/treetable/toggle-expand-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
@@ -126,6 +126,7 @@ caption {border:1px solid #e4e4e4; background:#efefef; margin:0; padding:5
|
||||
.margin-15px {margin: 15px}
|
||||
.margin-20px {margin: 20px}
|
||||
.padding-10px{padding: 10px}
|
||||
.padding-5px {padding: 5px}
|
||||
|
||||
.mt-10px {margin-top: 10px}
|
||||
.mr-10px {margin-right: 10px}
|
||||
@@ -242,7 +243,9 @@ caption {border:1px solid #e4e4e4; background:#efefef; margin:0; padding:5
|
||||
.done {color:darkgreen}
|
||||
.wait {color:#9F9F5F}
|
||||
.doing {color:red}
|
||||
.delayed {background:red}
|
||||
.pass {color:darkgreen}
|
||||
.blocked {color:yellow}
|
||||
.fail {color:red}
|
||||
.hand {cursor:pointer}
|
||||
.strong {font-weight:bold}
|
||||
|
||||
43
trunk/www/theme/default/treetable.css
Normal file
43
trunk/www/theme/default/treetable.css
Normal file
@@ -0,0 +1,43 @@
|
||||
/* jQuery TreeTable Core 2.0 stylesheet
|
||||
*
|
||||
* This file contains styles that are used to display the tree table. Each tree
|
||||
* table is assigned the +treeTable+ class.
|
||||
* ========================================================================= */
|
||||
|
||||
/* jquery.treeTable.collapsible
|
||||
* ------------------------------------------------------------------------- */
|
||||
.treeTable tr td .expander {
|
||||
background-position: left center;
|
||||
background-repeat: no-repeat;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
zoom: 1; /* IE7 Hack */
|
||||
}
|
||||
|
||||
.treeTable tr.collapsed td .expander {
|
||||
background-image: url(./images/treetable/toggle-expand-dark.png);
|
||||
}
|
||||
|
||||
.treeTable tr.expanded td .expander {
|
||||
background-image: url(./images/treetable/toggle-collapse-dark.png);
|
||||
}
|
||||
|
||||
/* jquery.treeTable.sortable
|
||||
* ------------------------------------------------------------------------- */
|
||||
.treeTable tr.selected, .treeTable tr.accept {
|
||||
background-color: #3875d7;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.treeTable tr.collapsed.selected td .expander, .treeTable tr.collapsed.accept td .expander {
|
||||
background-image: url(./images/treetable/toggle-expand-light.png);
|
||||
}
|
||||
|
||||
.treeTable tr.expanded.selected td .expander, .treeTable tr.expanded.accept td .expander {
|
||||
background-image: url(./images/treetable/toggle-collapse-light.png);
|
||||
}
|
||||
|
||||
.treeTable .ui-draggable-dragging {
|
||||
color: #000;
|
||||
z-index: 1;
|
||||
}
|
||||
Reference in New Issue
Block a user