Skip to content

Commit

Permalink
Merge branch 'RB_1.6' into manualtests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Aug 13, 2009
2 parents 765f2cb + fa5885f commit 0e4907e
Show file tree
Hide file tree
Showing 9 changed files with 186 additions and 12 deletions.
4 changes: 4 additions & 0 deletions 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
Expand Down
1 change: 1 addition & 0 deletions manualtests/widgets/autosuggest/index.html
Expand Up @@ -54,6 +54,7 @@ <h2>Autosuggest with minimum input length, and completion</h2>
}
},
complete: true,
activeOnShow: false,
delim: " "
}
)
Expand Down
3 changes: 2 additions & 1 deletion src/dom/dom.js
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/events/events.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -475,6 +474,7 @@
else {
capturingMode = true
}
break;

case "blur":
// IE
Expand All @@ -488,6 +488,7 @@
else {
capturingMode = true
}
break;

}

Expand Down
6 changes: 4 additions & 2 deletions src/glow/glow.js
Expand Up @@ -705,7 +705,7 @@
},
env = glow.env,
d = document;

//dom ready stuff
//run queued ready functions when DOM is ready

Expand Down Expand Up @@ -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(); }
Expand Down
18 changes: 16 additions & 2 deletions src/widgets/autosuggest/autosuggest.js
Expand Up @@ -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);
}
}
}

Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -763,6 +772,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
}

/**
Expand Down Expand Up @@ -1029,6 +1039,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);
Expand Down Expand Up @@ -1061,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();
}
Expand Down
11 changes: 9 additions & 2 deletions src/widgets/widgets.carousel.css
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 */
}
Expand Down
3 changes: 2 additions & 1 deletion srcloader/map.js
Expand Up @@ -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"]
}
)

Expand Down
145 changes: 144 additions & 1 deletion test/glow/widgets/autosuggest/autosuggest.js
Expand Up @@ -117,9 +117,152 @@ 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("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('<div><input type="text" id="example"/></div>');

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");

window.tempContainer.empty();
window.tempContainer = null;

t.ok(true, "Cleaned");
});

0 comments on commit 0e4907e

Please sign in to comment.