Author: sevein
Date: Fri Apr 6 16:02:11 2012
New Revision: 11419
Log:
Issue 2288. Implementing methods to show ancestors, expand items...
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
branches/2.0/js/dominion.js
branches/2.0/plugins/qtDominionPlugin/css/less/_treeview.less
branches/2.0/plugins/qtDominionPlugin/css/less/main.css
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
==============================================================================
--- branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Fri Apr 6 15:21:44 2012 (r11418)
+++ branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Fri Apr 6 16:02:11 2012 (r11419)
@@ -1,8 +1,8 @@
-<div class="span5 tree tab-pane active" id="treeview">
+<div class="span5 tree tab-pane active" id="treeview" data-xhr-location="<?php
echo url_for(array($resource, 'module' => 'informationobject', 'action' =>
'treeView')) ?>">
<ul class="unstyled">
- <li class="back" data-location="<?php echo url_for(array($resource,
'module' => 'informationobject', 'action' => 'treeView', 'show' => 'all'))
?>"><i></i><?php echo link_to(__('Show all'), array('module' =>
'informationobject', 'action' => 'browse')) ?></li>
+ <li class="back"><i></i><?php echo link_to(__('Show all'), array('module'
=> 'informationobject', 'action' => 'browse')) ?></li>
<?php $resultSet = $current->getResults() ?>
<?php $doc = $resultSet[0]->getData() ?>
@@ -14,7 +14,7 @@
<?php foreach($doc['ancestors'] as $id): ?>
<?php if ($id == QubitInformationObject::ROOT_ID) continue; ?>
<?php $ancestor = QubitInformationObject::getById($id) ?>
- <li class="ancestor up"><i></i><?php echo link_to($ancestor,
array($ancestor, 'module' => 'informationobject')) ?></li>
+ <li class="ancestor"><i></i><?php echo link_to($ancestor,
array($ancestor, 'module' => 'informationobject')) ?></li>
<?php endforeach; ?>
<li class="active"><i></i><?php echo link_to($resource, array($resource,
'module' => 'informationobject')) ?></li>
Modified: branches/2.0/js/dominion.js
==============================================================================
--- branches/2.0/js/dominion.js Fri Apr 6 15:21:44 2012 (r11418)
+++ branches/2.0/js/dominion.js Fri Apr 6 16:02:11 2012 (r11419)
@@ -225,6 +225,8 @@
var Treeview = function (element)
{
this.$element = element;
+ this.$showAllButton = this.$element.find('li:first');
+ this.url = this.$element.data('xhr-location');
this.loading = false;
this.init();
};
@@ -239,7 +241,6 @@
.on('click.treeview.qubit', 'li', $.proxy(this.click, this))
.on('mouseenter.treeview.qubit', 'li', $.proxy(this.mouseenter,
this))
.on('mouseleave.treeview.qubit', 'li', $.proxy(this.mouseleave,
this));
-
},
mouseenter: function (e)
@@ -254,35 +255,85 @@
click: function(e)
{
- console.log('li clicked');
+ if (this.loading)
+ {
+ return;
+ }
+
+ var $li = 'LI' == e.target.tagName ? $(e.target) :
$(e.target).closest('li');
+
+ if ($li.hasClass('back'))
+ {
+ e.preventDefault();
+ e.stopPropagation();
+
+ return this.showAll($li);
+ }
+
+ if ('I' != e.target.tagName)
+ {
+ return this;
+ }
+
e.preventDefault();
e.stopPropagation();
- if (this.loading)
+ if ($li.hasClass('ancestor'))
{
- console.log("Ignored");
- return;
+ return this.showAncestor($li);
+ }
+ else if ($li.hasClass('expand'))
+ {
+ return this.showItem($li);
}
- var $target = 'LI' == e.target.tagName ? $(e.target) :
$(e.target).closest('li');
+ return this;
+ },
- if ($target.hasClass('back'))
+ showAll: function ($element)
{
$.ajax({
- url: $target.data('location'),
+ url: this.url,
context: this,
dataType: 'html',
+ data: { show: 'all' },
beforeSend: function ()
{
this.loading = true;
},
success: function (data)
{
- $target
+ $element
.hide()
.nextAll().remove().end()
.after(data).end();
+ },
+ complete: function ()
+ {
+ this.loading = false;
+ },
+ error: function ()
+ {
+ }
+ });
+ return this;
+ },
+
+ showAncestor: function($element)
+ {
+ $.ajax({
+ url: this.url,
+ context: this,
+ dataType: 'html',
+ data: { show: 'ancestor' },
+ beforeSend: function ()
+ {
+ this.loading = true;
+ },
+ success: function (data)
+ {
+ this.$showAllButton.show();
},
complete: function ()
{
@@ -293,10 +344,35 @@
}
});
- }
+ return this;
+ },
- }
+ showItem: function($element)
+ {
+ $.ajax({
+ url: this.url,
+ context: this,
+ dataType: 'html',
+ data: { show: 'ancestor' },
+ beforeSend: function ()
+ {
+ this.loading = true;
+ },
+ success: function (data)
+ {
+ this.$showAllButton.show();
+ },
+ complete: function ()
+ {
+ this.loading = false;
+ },
+ error: function ()
+ {
+ }
+ });
+ return this;
+ }
};
$.fn.treeview = function()
Modified: branches/2.0/plugins/qtDominionPlugin/css/less/_treeview.less
==============================================================================
--- branches/2.0/plugins/qtDominionPlugin/css/less/_treeview.less Fri Apr
6 15:21:44 2012 (r11418)
+++ branches/2.0/plugins/qtDominionPlugin/css/less/_treeview.less Fri Apr
6 16:02:11 2012 (r11419)
@@ -35,7 +35,7 @@
}
- &.up {
+ &.ancestor {
border-bottom: 1px solid @white;
padding-left: 2px !important;
@@ -61,7 +61,7 @@
}
- &.up i,
+ &.ancestor i,
&.back i,
&.expand i {
@@ -77,13 +77,12 @@
}
- &.up i { background-position: 0 -10px; }
+ &.ancestor i { background-position: 0 -10px; }
&.back i { background-position: -10px -10px; }
&.expand i { background-position: -20px -10px; }
- &.active.up i { background-position: 0 0; }
- &.active.back i { background-position: -10px 0; }
- &.active.expand i { background-position: -20px 0; }
+ &.hover i,
+ &.active i { background-position-y: 0px; }
}
Modified: branches/2.0/plugins/qtDominionPlugin/css/less/main.css
==============================================================================
--- branches/2.0/plugins/qtDominionPlugin/css/less/main.css Fri Apr 6
15:21:44 2012 (r11418)
+++ branches/2.0/plugins/qtDominionPlugin/css/less/main.css Fri Apr 6
16:02:11 2012 (r11419)
@@ -906,17 +906,15 @@
#treeview ul li:hover{background-color:rgba(255, 255, 255,
0.2);text-decoration:none;}
#treeview ul li .adminbuttons a:hover{color:#000000 !important;}
#treeview ul li.expand{padding-left:2px !important;}
-#treeview ul li.up{border-bottom:1px solid #ffffff;padding-left:2px
!important;background:none;}
+#treeview ul li.ancestor{border-bottom:1px solid #ffffff;padding-left:2px
!important;background:none;}
#treeview ul li.back{border-bottom:1px solid #ffffff;padding-left:2px
!important;background:none;}
#treeview ul li.active{background-color:#ffffff;}#treeview ul li.active
a{color:#f6ac00;}
-#treeview ul li.up i,#treeview ul li.back i,#treeview ul li.expand
i{display:inline-block;width:10px;height:10px;vertical-align:middle;margin-right:3px;background-image:url(../../images/arrow-sprites.png);background-position:10px
10px;background-repeat:no-repeat;*margin-right:.3em;}#treeview ul li.up
i:last-child,#treeview ul li.back i:last-child,#treeview ul li.expand
i:last-child{*margin-left:0;}
-#treeview ul li.up i:last-child,#treeview ul li.back i:last-child,#treeview ul
li.expand i:last-child{*margin-left:0;}
-#treeview ul li.up i{background-position:0 -10px;}
+#treeview ul li.ancestor i,#treeview ul li.back i,#treeview ul li.expand
i{display:inline-block;width:10px;height:10px;vertical-align:middle;margin-right:3px;background-image:url(../../images/arrow-sprites.png);background-position:10px
10px;background-repeat:no-repeat;*margin-right:.3em;}#treeview ul li.ancestor
i:last-child,#treeview ul li.back i:last-child,#treeview ul li.expand
i:last-child{*margin-left:0;}
+#treeview ul li.ancestor i:last-child,#treeview ul li.back
i:last-child,#treeview ul li.expand i:last-child{*margin-left:0;}
+#treeview ul li.ancestor i{background-position:0 -10px;}
#treeview ul li.back i{background-position:-10px -10px;}
#treeview ul li.expand i{background-position:-20px -10px;}
-#treeview ul li.active.up i{background-position:0 0;}
-#treeview ul li.active.back i{background-position:-10px 0;}
-#treeview ul li.active.expand i{background-position:-20px 0;}
+#treeview ul li.hover i,#treeview ul li.active i{background-position-y:0px;}
.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px;}.popover.top{margin-top:-5px;}
.popover.right{margin-left:5px;}
.popover.bottom{margin-top:5px;}
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.