Author: sevein
Date: Sat Jun 9 15:40:04 2012
New Revision: 11755
Log:
JavaScript code to retreive and render more items from the server, includes
detection of scrollbar position so when the ends is reached more items will be
fetched
Modified:
branches/2.0/js/dominion.js
Modified: branches/2.0/js/dominion.js
==============================================================================
--- branches/2.0/js/dominion.js Sat Jun 9 15:21:48 2012 (r11754)
+++ branches/2.0/js/dominion.js Sat Jun 9 15:40:04 2012 (r11755)
@@ -314,6 +314,25 @@
.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));
+
+ $('#navigation').bind('scroll', $.proxy(this.scroll, this));
+ },
+
+ scroll: function (e)
+ {
+ var $target = $(e.target);
+
+ // Detect when users scrolls to the bottom
+ if ($target.scrollTop() + $target.innerHeight() >=
$target.get(0).scrollHeight)
+ {
+ var self = this;
+
+ // Delay the trigger
+ window.setTimeout(function()
+ {
+ self.$element.find('li.more:last').trigger('click');
+ }, 250);
+ }
},
mouseenter: function (e)
@@ -343,10 +362,12 @@
return this.showAll($li);
}
+ /*
if ('I' !== e.target.tagName)
{
return this;
}
+ */
e.preventDefault();
e.stopPropagation();
@@ -359,6 +380,52 @@
{
return this.showItem($li);
}
+ else if ($li.hasClass('more'))
+ {
+ var $a = $li.find('a');
+
+ var loadingId = window.setInterval(function()
+ {
+ $a.append('.');
+ }, 125);
+
+ if (!$li.next().length)
+ {
+ var action = 'nextSiblings';
+ var url = $li.data('xhr-location');
+ }
+ else
+ {
+ var action = 'prevSiblings';
+ var url = $li.data('xhr-location');
+ }
+
+ console.log($li.data('xhr-location'));
+
+ $.ajax({
+ url: url,
+ context: this,
+ dataType: 'html',
+ data: { show: action },
+ beforeSend: function()
+ {
+ this.loading = true;
+ },
+ success: function (data)
+ {
+ $li.replaceWith(data);
+ },
+ complete: function ()
+ {
+ this.loading = false;
+
+ window.clearTimeout(loadingId);
+ },
+ error: function ()
+ {
+ }
+ });
+ }
return this;
},
--
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.