Skip to content

Commit

Permalink
Merge remote-tracking branch 'acheetham/FLUID-4745' into demo
Browse files Browse the repository at this point in the history
* acheetham/FLUID-4745:
  FLUID-4745: Clean up binding of press() to click for toggleButton
  FLUID-4745: Restore mute button activation via keyboard.
  • Loading branch information
michelled committed Aug 29, 2012
2 parents cb56354 + fdc163f commit a752873
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
12 changes: 7 additions & 5 deletions js/ToggleButton.js
Expand Up @@ -63,6 +63,12 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}
button.prop("aria-pressed", pressed);
};

that.press = function () {
that.requestStateChange();
that.events.onPress.fire(that);
return false;
};
};

fluid.toggleButton.setUpToggleButton = function (that) {
Expand All @@ -83,11 +89,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

fluid.toggleButton.bindToggleButtonEvents = function (that) {
var button = that.locate("button");
button.click(function () {
that.requestStateChange();
that.events.onPress.fire();
return false;
});
button.click(that.press);

that.applier.modelChanged.addListener(that.options.modelPath, function () {
that.refreshView();
Expand Down
14 changes: 0 additions & 14 deletions js/VideoPlayer.js
Expand Up @@ -431,19 +431,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
});
};

fluid.videoPlayer.bindEscKey = function (that) {
var opts = {
additionalBindings: [{
key: that.options.keyBindings.escape.key,
activateHandler: function () {
that.controllers.captionControls.menu.hide();
that.controllers.transcriptControls.menu.hide();
}
}]
};
that.container.fluid("activatable", [that.container, opts]);
};

fluid.videoPlayer.preInit = function (that) {
fluid.each(that.options.defaultKinds, function(defaultKind, index) {
fluid.videoPlayer.addDefaultKind(fluid.get(that.options.video, index), defaultKind);
Expand Down Expand Up @@ -575,7 +562,6 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
}

that.locate("controllers").hide();
fluid.videoPlayer.bindEscKey(that);

that.events.onReady.fire(that);
});
Expand Down
2 changes: 1 addition & 1 deletion js/VideoPlayer_controllers.js
Expand Up @@ -458,7 +458,7 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
fluid.tabindex(that.locate("handle"), -1);

fluid.activatable(that.container, function (evt) {
that.muteButton.events.onPress.fire();
that.muteButton.press();
});
// TODO: This will be converted to use the activatable plugin
// as part of FLUID-4552
Expand Down
18 changes: 18 additions & 0 deletions tests/js/ToggleButtonTests.js
Expand Up @@ -73,6 +73,24 @@ fluid.registerNamespace("fluid.tests");
});
});

toggleButtonTests.asyncTest("Press", function () {
expect(3);
var testComponent;
testComponent = fluid.tests.initToggleButton({
listeners: {
onReady: function (that) {
jqUnit.assertEquals("Initial state should be 'false'", false, that.readIndirect("modelPath"));
that.press();
},
onPress: function (that) {
jqUnit.assertTrue("onPress event should fire", true);
jqUnit.assertEquals("State should change to be 'true'", true, that.readIndirect("modelPath"));
start();
}
}
});
});

toggleButtonTests.asyncTest("Default integrated functionality", function () {
var testComponent = fluid.tests.initToggleButton({
listeners: {
Expand Down

0 comments on commit a752873

Please sign in to comment.