Skip to content

Commit

Permalink
Wait to load responsive voice before show the button
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou authored and hvelarde committed Jun 15, 2016
1 parent e76dd39 commit d038cfd
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,8 @@ Changelog
1.0b2 (unreleased)
------------------

- Nothing changed yet.
- The '🔊 Listen' button is now shown only after ResponsiveVoice library has been loaded.
[rodfersou]


1.0b1 (2016-06-14)
Expand Down
2 changes: 1 addition & 1 deletion src/collective/texttospeech/profiles/default/metadata.xml
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<metadata>
<version>2</version>
<version>3</version>
</metadata>
6 changes: 6 additions & 0 deletions src/collective/texttospeech/static/main.css
@@ -1,7 +1,13 @@
#viewlet-texttospeech
{
min-height: 1.2em;

text-align: right;
}
#viewlet-texttospeech > input
{
display: none;
}
#texttospeech-button
{
cursor: pointer;
Expand Down
4 changes: 2 additions & 2 deletions src/collective/texttospeech/static/main.js
Expand Up @@ -8,6 +8,7 @@ var MainView = (function() {
return;
}
this.$button = $('#texttospeech-button', this.$el);
this.$button.fadeIn();
this.voice = this.$el.attr('data-voice');
this.label_stopped = this.$el.attr('data-label-stopped');
this.label_playing = this.$el.attr('data-label-playing');
Expand Down Expand Up @@ -82,8 +83,7 @@ var ControlPanelView = (function() {
return ControlPanelView;
})();


$(function() {
responsiveVoice.addEventListener("OnReady", function() {
if ($('#viewlet-texttospeech').length > 0) {
new MainView();
}
Expand Down
2 changes: 1 addition & 1 deletion src/collective/texttospeech/tests/test_setup.py
Expand Up @@ -55,7 +55,7 @@ def test_profile_version(self):
profile = PROJECTNAME + ':default'
setup_tool = self.portal['portal_setup']
self.assertEqual(
setup_tool.getLastVersionForProfile(profile), (u'2',))
setup_tool.getLastVersionForProfile(profile), (u'3',))


class UninstallTestCase(unittest.TestCase):
Expand Down
14 changes: 14 additions & 0 deletions src/collective/texttospeech/tests/test_upgrades.py
Expand Up @@ -64,3 +64,17 @@ def test_pin_responsivevoice(self):
self._do_upgrade(step)
self.assertNotIn(OLD_JS, portal_js.getResourceIds())
self.assertIn(NEW_JS, portal_js.getResourceIds())


class To3TestCase(UpgradeBaseTestCase):

from_ = '2'
to_ = '3'

def test_profile_version(self):
version = self.setup.getLastVersionForProfile(self.profile_id)[0]
self.assertEqual(version, self.from_)

def test_registered_steps(self):
steps = len(self.setup.listUpgrades(self.profile_id)[0])
self.assertEqual(steps, 2)
1 change: 1 addition & 0 deletions src/collective/texttospeech/upgrades/configure.zcml
@@ -1,3 +1,4 @@
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".v2" />
<include package=".v3" />
</configure>
1 change: 1 addition & 0 deletions src/collective/texttospeech/upgrades/v3/__init__.py
@@ -0,0 +1 @@
# -*- coding: utf-8 -*-
24 changes: 24 additions & 0 deletions src/collective/texttospeech/upgrades/v3/configure.zcml
@@ -0,0 +1,24 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:genericsetup="http://namespaces.zope.org/genericsetup">

<genericsetup:upgradeSteps
source="2"
destination="3"
profile="collective.texttospeech:default">

<genericsetup:upgradeStep
title="Cook CSS resources"
description="There were changes in the CSS files, so we need to cook the resources."
handler="..cook_css_resources"
/>

<genericsetup:upgradeStep
title="Cook JavaScript resources"
description="There were changes in the JavaScript files, so we need to cook the resources."
handler="..cook_javascript_resources"
/>

</genericsetup:upgradeSteps>

</configure>

0 comments on commit d038cfd

Please sign in to comment.