Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: commits

[8566] Fixing the up/down arrow jumpiness part of bug 1460.

 

 

Bricolage commits RSS feed   Index | Next | Previous | View Threaded


slanning at bricolage

Apr 9, 2009, 7:23 AM

Post #1 of 1 (923 views)
Permalink
[8566] Fixing the up/down arrow jumpiness part of bug 1460.

Revision: 8566
Author: slanning
Date: 2009-04-09 07:23:57 -0700 (Thu, 09 Apr 2009)
ViewCVS: http://viewsvn.bricolage.cc/?rev=8566&view=rev

Log Message:
-----------
Fixing the up/down arrow jumpiness part of bug 1460.
Code from http://blog.gilluminate.com/2009/01/20/scriptaculous-autocomplete-page-jump-using-arrow-keys/

Bugzilla Links:
--------------
http://bugs.bricolage.cc/show_bug.cgi?id=1460

Modified Paths:
--------------
bricolage/trunk/comp/media/js/lib.js
bricolage/trunk/lib/Bric/Changes.pod

Modified: bricolage/trunk/comp/media/js/lib.js
===================================================================
--- bricolage/trunk/comp/media/js/lib.js 2009-04-09 09:41:50 UTC (rev 8565)
+++ bricolage/trunk/comp/media/js/lib.js 2009-04-09 14:23:57 UTC (rev 8566)
@@ -35,6 +35,34 @@
Ajax.Autocompleter.prototype._onKeyPress =
Ajax.Autocompleter.prototype.onKeyPress;
Object.extend(Ajax.Autocompleter.prototype, {
+ initialize: function(element, update, url, options) {
+ this.baseInitialize(element, update, options);
+ this.options.asynchronous = true;
+ this.options.onComplete = this.onComplete.bind(this);
+ this.options.defaultParams = this.options.parameters || null;
+ this.url = url;
+ this.cache = {};
+ },
+
+ getUpdatedChoices: function() {
+ this.startIndicator();
+
+ var t = this.getToken();
+ if (this.cache[t]) {
+ this.updateChoices(this.cache[t]);
+ } else {
+ entry = encodeURIComponent(this.options.paramName) + '=' + encodeURIComponent(t);
+
+ this.options.parameters = this.options.callback ?
+ this.options.callback(this.element, entry) : entry;
+
+ if(this.options.defaultParams)
+ this.options.parameters += '&' + this.options.defaultParams;
+
+ new Ajax.Request(this.url, this.options);
+ }
+ },
+
onKeyPress: function(event) {
var originallyActive = this.active;
this._onKeyPress(event);
@@ -72,7 +100,71 @@
} else if (this.options.onNotEmpty) {
this.options.onNotEmpty(this.element);
}
- }
+
+ // for caching
+ this.updateChoices(this.cache[this.getToken()] = request.responseText);
+ },
+
+ // Page jump fix
+ markPrevious: function() {
+ if (this.index > 0) {
+ this.index--;
+ } else {
+ this.index = this.entryCount-1;
+ this.update.scrollTop = this.update.scrollHeight;
+ }
+
+ selection = this.getEntry(this.index);
+ selection_top = selection.offsetTop;
+
+ if (selection_top < this.update.scrollTop) {
+ this.update.scrollTop = this.update.scrollTop - selection.offsetHeight;
+ }
+ },
+
+ markNext: function() {
+ if (this.index < this.entryCount-1) {
+ this.index++;
+ } else {
+ this.index = 0;
+ this.update.scrollTop = 0;
+ }
+ selection = this.getEntry(this.index);
+ selection_bottom = selection.offsetTop+selection.offsetHeight;
+ if (selection_bottom > this.update.scrollTop + this.update.offsetHeight) {
+ this.update.scrollTop = this.update.scrollTop+selection.offsetHeight;
+ }
+ },
+
+ updateChoices: function(choices) {
+ if (!this.changed && this.hasFocus) {
+ this.update.innerHTML = choices;
+ Element.cleanWhitespace(this.update);
+ Element.cleanWhitespace(this.update.down());
+
+ if (this.update.firstChild && this.update.down().childNodes) {
+ this.entryCount = this.update.down().childNodes.length;
+ for (var i = 0; i < this.entryCount; i++) {
+ var entry = this.getEntry(i);
+ entry.autocompleteIndex = i;
+ this.addObservers(entry);
+ }
+ } else {
+ this.entryCount = 0;
+ }
+
+ this.stopIndicator();
+ this.update.scrollTop = 0;
+ this.index = 0;
+
+ if (this.entryCount==1 && this.options.autoSelect) {
+ this.selectEntry();
+ this.hide();
+ } else {
+ this.render();
+ }
+ }
+ }
});

// set up global to track names of double list managers

Modified: bricolage/trunk/lib/Bric/Changes.pod
===================================================================
--- bricolage/trunk/lib/Bric/Changes.pod 2009-04-09 09:41:50 UTC (rev 8565)
+++ bricolage/trunk/lib/Bric/Changes.pod 2009-04-09 14:23:57 UTC (rev 8566)
@@ -462,6 +462,12 @@
Fixed bug 1458, where related media that failed to be thumbnailed caused the
Story Profile to error. Similarly fixed bug 1461 for Find Media. [Scott]

+=item *
+
+Fixed part of bug 1460, the auto-completion was jumping around. See
+L<http://blog.gilluminate.com/2009/01/20/scriptaculous-autocomplete-page-jump-using-arrow-keys/>
+for details. [Scott]
+
=back

=head1 VERSION 1.11.1 (2008-10-03)

Bricolage commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.