From c68622dd7477da4d650fe36e6ab34325cad59132 Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Tue, 11 Aug 2009 15:38:14 +0100 Subject: [PATCH 1/8] Modified carousel css to correctly hide arrow label text. --- src/widgets/widgets.carousel.css | 11 +++++++++-- srcloader/map.js | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets.carousel.css b/src/widgets/widgets.carousel.css index dae3127..6a3549e 100644 --- a/src/widgets/widgets.carousel.css +++ b/src/widgets/widgets.carousel.css @@ -83,8 +83,15 @@ overflow:hidden; } -.glowCSSVERSION-carousel .carousel-nav span { +.glowCSSVERSION-carousel .carousel-nav span, +.glowCSSVERSION-vCarousel .carousel-nav span { background-repeat:no-repeat; + text-indent: -5000px; /* move text away when images are enabled */ +} + +.glowCSSVERSION-basic .glowCSSVERSION-carousel .carousel-nav span, +.glowCSSVERSION-basic .glowCSSVERSION-vCarousel .carousel-nav span { + text-indent: 0px; /* move text back when images are not enabled */ } .glowCSSVERSION-carousel .carousel-nav .carousel-background { @@ -242,7 +249,7 @@ } .glowCSSVERSION-basic .glowCSSVERSION-carousel .dot .dotLabel, -.glowCSSVERSION-basic .glowCSSVERSION-vCarousel .dot .dotLabel, { +.glowCSSVERSION-basic .glowCSSVERSION-vCarousel .dot .dotLabel { overflow: visible; text-indent: 0; /* images are disabled, so move text back, but not for arrows */ } diff --git a/srcloader/map.js b/srcloader/map.js index 8acca06..7fb00ba 100644 --- a/srcloader/map.js +++ b/srcloader/map.js @@ -55,7 +55,8 @@ gloader.map.add( "glow.widgets.AutoComplete": ["{$base}/widgets/autocomplete/autocomplete.js"], "glow.widgets.Carousel": ["{$base}/widgets/carousel/carousel.js"], "glow.widgets.Timetable": ["{$base}/widgets/timetable/timetable.js"], - "glow.widgets.Editor": ["{$base}/widgets/editor/editor.js"] + "glow.widgets.Editor": ["{$base}/widgets/editor/editor.js"], + "glow.i18n": ["{$base}/i18n/i18n.js"] } ) From e4f1f9f7d11259d381c539afd2eb4cf701d471de Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 12 Aug 2009 07:56:14 +0100 Subject: [PATCH 2/8] Add support for new filter option to limit or modify the found result set. --- src/widgets/autosuggest/autosuggest.js | 4 ++ test/glow/widgets/autosuggest/autosuggest.js | 43 ++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/widgets/autosuggest/autosuggest.js b/src/widgets/autosuggest/autosuggest.js index ee792df..e25bc21 100755 --- a/src/widgets/autosuggest/autosuggest.js +++ b/src/widgets/autosuggest/autosuggest.js @@ -763,6 +763,7 @@ this._isMatch = this.opts.isMatch || function(word, lookFor) { return (word.indexOf(lookFor) == 0); } // default this._formatItem = this.opts.formatItem || function(o) { return (o.name)? o.name : o.toString(); }; // default this._matchItem = this.opts.formatItem || function(o) { return o.name; }; // default + this._filter = this.opts.filter || function(results) { return results; }; // do nothing } /** @@ -1029,6 +1030,9 @@ } } + // apply any optional filtyering to the results + found = this._filter(found); + this._found = found; // used to get the selected object in event handlers if (found.length) { if (this.opts.maxListLength) found.length = Math.min(found.length, this.opts.maxListLength); diff --git a/test/glow/widgets/autosuggest/autosuggest.js b/test/glow/widgets/autosuggest/autosuggest.js index babd20d..070c1fd 100755 --- a/test/glow/widgets/autosuggest/autosuggest.js +++ b/test/glow/widgets/autosuggest/autosuggest.js @@ -117,6 +117,49 @@ t.test("val", function() { }); +t.test("filter", function() { + t.expect(3); + + var myForm = glow.dom.get("#example"); + var recipes = [ + {name:"Green-bean Chilli", type:"Vegetarian"}, + {name:"Green Seaweed Soup", type:"Seafood"}, + {name:"Green Oysters on Ice", type:"Seafood"}, + {name:"Green Apple Flan", type:"Pastry"} + ]; + + myAutoSuggest = new glow.widgets.AutoSuggest( + myForm, + recipes, + { + filter: function(results) { + return results.slice(0, 2); // limit results to first 2 + } + } + ); + + myAutoSuggest.find("green"); // should find all recipes + /*1*/ t.equals(myAutoSuggest._found.length, 2, "A filter can be applied to limit the results to a given length."); + + myAutoSuggest._filter = function(results) { + var filtered = []; + + for (var i = results.length; i--;) { + if (results[i].type == "Vegetarian") { + filtered.push(results[i]); + } + } + + return filtered; + }; + + myAutoSuggest.find("green"); // should find all recipes + /*2*/ t.equals(myAutoSuggest._found.length, 1, "A filter can be applied to limit the results to those with a certain property."); + /*3*/ t.equals(myAutoSuggest._found[0].name, "Green-bean Chilli", "A filter can be applied and the expected result is returned."); + + myAutoSuggest.find(""); // to hide the results +}); + t.test("cleanup", function() { t.expect(1); From 9ea3d76f051aee430de750fbdf98ed3797d8d840 Mon Sep 17 00:00:00 2001 From: jakearchibald Date: Wed, 12 Aug 2009 12:08:17 +0100 Subject: [PATCH 3/8] glow core: Catching browsers that don't support addEventListener (eg ps3) --- src/glow/glow.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/glow/glow.js b/src/glow/glow.js index 204c883..feb707a 100644 --- a/src/glow/glow.js +++ b/src/glow/glow.js @@ -705,7 +705,7 @@ }, env = glow.env, d = document; - + //dom ready stuff //run queued ready functions when DOM is ready @@ -783,7 +783,9 @@ runDomReadyQueue(); glow._removeReadyBlock("glow_domReady"); }; - d.addEventListener("DOMContentLoaded", callback, false); + if (d.addEventListener) { + d.addEventListener("DOMContentLoaded", callback, false); + } var oldOnload = window.onload; window.onload = function () { if (oldOnload) { oldOnload(); } From 284bd28bcd08666ebd1a2990005f6c97e5209c4f Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 12 Aug 2009 15:01:17 +0100 Subject: [PATCH 4/8] Added new features to autosuggest so that original value can be restored by using the keyboard. --- manualtests/widgets/autosuggest/index.html | 1 + src/widgets/autosuggest/autosuggest.js | 14 ++- test/glow/widgets/autosuggest/autosuggest.js | 102 ++++++++++++++++++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/manualtests/widgets/autosuggest/index.html b/manualtests/widgets/autosuggest/index.html index 8c2d534..cc3411a 100755 --- a/manualtests/widgets/autosuggest/index.html +++ b/manualtests/widgets/autosuggest/index.html @@ -54,6 +54,7 @@

Autosuggest with minimum input length, and completion

} }, complete: true, + activeOnShow: false, delim: " " } ) diff --git a/src/widgets/autosuggest/autosuggest.js b/src/widgets/autosuggest/autosuggest.js index e25bc21..efc210d 100755 --- a/src/widgets/autosuggest/autosuggest.js +++ b/src/widgets/autosuggest/autosuggest.js @@ -154,6 +154,10 @@ deactivateItem(that, currItem); activateItem(that, nextItem); } + else { // move selection down off of suggestion list, back into the input element + that.val(that._original); + deactivateItem(that, currItem); + } } } @@ -175,6 +179,10 @@ deactivateItem(that, currItem); activateItem(that, prevItem); } + else { // move selection up off of suggestion list, back into the input element + that.val(that._original); + deactivateItem(that, currItem); + } } } @@ -406,8 +414,9 @@ } } else if (e.key == 'ESC') { // bail - // user accepts the hilited text - that._value = that.inputElement.val(); + // return to the value originally entered by the user + that.inputElement.val(that._original); + that._value = that._original; valueChanged(that, true); that.hide(); return false; @@ -1065,6 +1074,7 @@ @description Make the overlay visible. */ glow.widgets.AutoSuggest.prototype.show = function() { /*debug*///console.log("show()") + this._original = this.val(); place(this); this.overlay.show(); } diff --git a/test/glow/widgets/autosuggest/autosuggest.js b/test/glow/widgets/autosuggest/autosuggest.js index 070c1fd..5e88fe4 100755 --- a/test/glow/widgets/autosuggest/autosuggest.js +++ b/test/glow/widgets/autosuggest/autosuggest.js @@ -160,9 +160,109 @@ t.test("filter", function() { myAutoSuggest.find(""); // to hide the results }); +t.test("keyboard navigation", function() { + t.expect(5); + + // discard any event handlers that may have been applied to the form in previous tests + window.tempContainer.empty(); + window.tempContainer.html('
'); + + var myForm = glow.dom.get("#example"); + var recipes = [ + {name:"Green-bean Chilli", type:"Vegetarian"}, + {name:"Green Seaweed Soup", type:"Seafood"}, + {name:"Green Oysters on Ice", type:"Seafood"}, + {name:"Green Apple Flan", type:"Pastry"} + ]; + + myAutoSuggest = new glow.widgets.AutoSuggest( + myForm, + recipes, + { + complete: true + } + ); + + // simulate a search + myAutoSuggest.val("green"); + myAutoSuggest.find(); // should find all recipes + /*1*/ t.ok(myAutoSuggest._found.length, "A new input element can be created and used."); + + // simulate an arrow down + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "DOWN" } + ) + ); + + /*2*/ t.equals(myAutoSuggest.inputElement[0].value, "Green Seaweed Soup", "Using arrow down with complete changes the value in the input element."); + + + // simulate two arrow ups + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "UP" } + ) + ); + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "UP" } + ) + ); + + /*3*/ t.equals(myAutoSuggest.inputElement[0].value, "green", "Using arrow up restores the original value in the input element."); + + // simulate ups and down arrow + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "UP" } + ) + ); + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "DOWN" } + ) + ); + + /*4*/ t.equals(myAutoSuggest.inputElement[0].value, "green", "Using arrow down restores the original value in the input element."); + + // simulate down arrow and then esc + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "DOWN" } + ) + ); + glow.events.fire( + myAutoSuggest.inputElement[0], + "keydown", + new glow.events.Event( + { key: "ESC" } + ) + ); + + /*5*/ t.equals(myAutoSuggest.inputElement[0].value, "green", "Using arrow down restores the original value in the input element."); + +}); + + t.test("cleanup", function() { t.expect(1); - tempContainer.css("height", 0).css("overflow", "hidden").css("visibility", "hidden"); + + //tempContainer.css("height", 0).css("overflow", "hidden").css("visibility", "hidden"); + delete window.tempContainer; + t.ok(true, "Cleaned"); }); \ No newline at end of file From e9e9b0d8a0643dfe64193aa4de978329ba8a28a3 Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 12 Aug 2009 16:08:19 +0100 Subject: [PATCH 5/8] Minor cleanup of tests based on browser testing results. --- test/glow/widgets/autosuggest/autosuggest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/glow/widgets/autosuggest/autosuggest.js b/test/glow/widgets/autosuggest/autosuggest.js index 5e88fe4..325588b 100755 --- a/test/glow/widgets/autosuggest/autosuggest.js +++ b/test/glow/widgets/autosuggest/autosuggest.js @@ -261,8 +261,8 @@ t.test("keyboard navigation", function() { t.test("cleanup", function() { t.expect(1); - //tempContainer.css("height", 0).css("overflow", "hidden").css("visibility", "hidden"); - delete window.tempContainer; + window.tempContainer.empty(); + window.tempContainer = null; t.ok(true, "Cleaned"); }); \ No newline at end of file From 3d827c08538f7e3f0bfdcf2c956b493154b6e4aa Mon Sep 17 00:00:00 2001 From: jakearchibald Date: Wed, 12 Aug 2009 17:12:13 +0100 Subject: [PATCH 6/8] events: Prevent case statement falling through --- src/events/events.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/events/events.js b/src/events/events.js index f42b739..63dcfd2 100644 --- a/src/events/events.js +++ b/src/events/events.js @@ -153,7 +153,7 @@ function addDomListener (attachTo, name, capturingMode) { var wheelEventName; - capturingMode = capturingMode || false; + capturingMode = !!capturingMode; if (glow.env.opera) { if (name.toLowerCase() == 'resize' && !operaResizeListener && attachTo == window) { @@ -446,9 +446,8 @@ var objEventListeners = objListeners[name]; if (! objEventListeners) { objEventListeners = objListeners[name] = []; } objEventListeners[objEventListeners.length] = listener; - + if ((attachTo.addEventListener || attachTo.attachEvent) && ! domListeners[objIdent + ':' + name]) { - // handle 'special' dom events (ie, ones that aren't directly mapped to real dom events) // we don't actually add a dom listener for these event names switch (name) { @@ -475,6 +474,7 @@ else { capturingMode = true } + break; case "blur": // IE @@ -488,6 +488,7 @@ else { capturingMode = true } + break; } From 622f06f78522563671cb96d93fec3c805d9af14d Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Wed, 12 Aug 2009 17:53:07 +0100 Subject: [PATCH 7/8] Added fix for safari 4 positioning when text is zoomed. --- src/dom/dom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dom/dom.js b/src/dom/dom.js index 850e580..3a26bb1 100755 --- a/src/dom/dom.js +++ b/src/dom/dom.js @@ -2554,7 +2554,8 @@ docScrollPos = scrollPos(); //this is simple(r) if we can use 'getBoundingClientRect' - if (elm.getBoundingClientRect) { + // Sorry but the sooper dooper simple(r) way is not accurate in Safari 4 + if (!glow.env.webkit && elm.getBoundingClientRect) { var rect = elm.getBoundingClientRect(); return { top: rect.top From fa5885f6a8a5928b80f77334959479a580e3e4a9 Mon Sep 17 00:00:00 2001 From: Michael Mathews Date: Thu, 13 Aug 2009 11:16:31 +0100 Subject: [PATCH 8/8] Added new bugfixes to changelog. --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 424ae37..3dbf267 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Glow Changelog +NEW BUGFIXES +* glow.widgets.Carousel - Fixed bug that caused Next and Previous text to be visible in Opera when images were on +* glow.widgets.AutoSuggest - Fixed bug that caused position of suggestion list to be wrong when text was zoomed in recent webkit browsers + 1.6.0-rc1 * glow.widgets.Timetable - Fixing bug that may result in item sizes less than 0