Skip to content

Commit

Permalink
Add icons to play/pause button
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Jun 13, 2016
1 parent b339062 commit 652a25f
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 47 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
.. image:: https://raw.githubusercontent.com/collective/collective.texttospeech/issue_4/docs/texttospeech.png
:align: left
:alt: Text-to-Speech
:height: 100px
:width: 100px

**************
Text-to-Speech
**************
Expand Down
Binary file added docs/texttospeech.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/collective/texttospeech/browser/templates/texttospeech.pt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div i18n:domain="collective.texttospeech"
id="viewlet-texttospeech"
data-label-stopped="Listen"
data-label-playing="Pause"
data-label-paused="Resume"
data-label-stopped="🔊 Listen"
data-label-playing="Pause"
data-label-paused="Resume"
tal:condition="view/enabled"
tal:attributes="data-voice view/voice"
i18n:attributes="data-label-stopped;
Expand All @@ -11,7 +11,7 @@
<input id="texttospeech-button"
class="stopped"
type="button"
value="Listen"
value="🔊 Listen"
title="Speech synthesis control"
i18n:attributes="value; title" />
</div>
26 changes: 13 additions & 13 deletions src/collective/texttospeech/locales/collective.texttospeech.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2016-06-10 20:11+0000\n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand Down Expand Up @@ -34,22 +34,10 @@ msgstr ""
msgid "If selected, Text-to-Speech feature will be enabled sitewide."
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Listen"
msgstr ""

#: collective/texttospeech/interfaces.py:26
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Pause"
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Resume"
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:11
msgid "Speech synthesis control"
msgstr ""
Expand All @@ -75,3 +63,15 @@ msgstr ""
#: collective/texttospeech/profiles.zcml:23
msgid "collective.texttospeech: uninstall"
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "⏸ Pause"
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "▶ Resume"
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "🔊 Listen"
msgstr ""
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-06-10 20:11+0000\n"
"PO-Revision-Date: 2016-06-10 17:16-0300\n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"PO-Revision-Date: 2016-06-10 18:35-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -37,22 +37,10 @@ msgstr "Aquí puede modificar las configuraciones de síntesis de habla."
msgid "If selected, Text-to-Speech feature will be enabled sitewide."
msgstr "Si está seleccionado, la funcionalidad de síntesis de habla estará habilitada en el sitio."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Listen"
msgstr "Escuchar"

#: collective/texttospeech/interfaces.py:26
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr "Sólo los objetos de estos tipos de contenido mostrarán el botón de síntesis de habla."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Pause"
msgstr "Pausar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Resume"
msgstr "Continuar"

#: collective/texttospeech/browser/templates/texttospeech.pt:11
msgid "Speech synthesis control"
msgstr "Control de la síntesis de habla"
Expand All @@ -78,3 +66,15 @@ msgstr "Voz utilizada para leer el texto."
#: collective/texttospeech/profiles.zcml:23
msgid "collective.texttospeech: uninstall"
msgstr "collective.texttospeech: uninstall"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "⏸ Pause"
msgstr "⏸ Pausar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "▶ Resume"
msgstr "▶ Continuar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "🔊 Listen"
msgstr "🔊 Escuchar"
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-06-10 20:11+0000\n"
"PO-Revision-Date: 2016-06-10 17:15-0300\n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"PO-Revision-Date: 2016-06-10 18:35-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -37,22 +37,10 @@ msgstr "Aqui pode modificar as configurações de síntese de voz."
msgid "If selected, Text-to-Speech feature will be enabled sitewide."
msgstr "Se estiver selecionado, a funcionalidade de síntese de voz estará habilitada no site."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Listen"
msgstr "Ouvir"

#: collective/texttospeech/interfaces.py:26
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr "Só objetos de esses tipos de conteúdo mostrarão o botão de síntese de voz."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Pause"
msgstr "Pausar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Resume"
msgstr "Continuar"

#: collective/texttospeech/browser/templates/texttospeech.pt:11
msgid "Speech synthesis control"
msgstr "Controle da síntese de voz"
Expand All @@ -78,3 +66,15 @@ msgstr "Voz utilizada para ler o texto."
#: collective/texttospeech/profiles.zcml:23
msgid "collective.texttospeech: uninstall"
msgstr "collective.texttospeech: uninstall"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "⏸ Pause"
msgstr "⏸ Pausar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "▶ Resume"
msgstr "▶ Continuar"

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "🔊 Listen"
msgstr "🔊 Ouvir"
1 change: 1 addition & 0 deletions src/collective/texttospeech/static/file-audio-o.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion src/collective/texttospeech/static/main.css
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
#viewlet-texttospeech{ text-align: right;}
#viewlet-texttospeech
{
text-align: right;
}
#texttospeech-button
{
cursor: pointer;
}
81 changes: 80 additions & 1 deletion src/collective/texttospeech/static/main.js
Original file line number Diff line number Diff line change
@@ -1 +1,80 @@
var MainView = (function() { function MainView() { this.$el = $('#viewlet-texttospeech'); this.$button = $('#texttospeech-button', this.$el); 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'); this.label_paused = this.$el.attr('data-label-paused'); this.playing = false; this.paused = true; this.$button.on('click', $.proxy(this.play_pause, this)); } MainView.prototype.onstart = function() { this.playing = true; this.paused = false; this.$button.attr('value', this.label_playing); this.$button.attr('class', 'playing'); }; MainView.prototype.onend = function() { this.playing = false; this.paused = true; this.$button.attr('value', this.label_stopped); this.$button.attr('class', 'stopped'); }; MainView.prototype.play_pause = function(e) { e.preventDefault(); if (this.playing) { if (this.paused) { this.paused = false; this.$button.attr('value', this.label_playing); this.$button.attr('class', 'playing'); responsiveVoice.resume(); } else { this.paused = true; this.$button.attr('value', this.label_paused); this.$button.attr('class', 'paused'); responsiveVoice.pause(); } } else { responsiveVoice.speak( $('#content').text(), this.voice, { onstart: $.proxy(this.onstart, this), onend: $.proxy(this.onend, this) } ); } }; return MainView;})();var ControlPanelView = (function() { function ControlPanelView() { this.template = "<select id=\"form-widgets-voice\" name=\"form.widgets.voice\" class=\"text-widget required textline-field\">\n</select>"; this.actual_voice = $('#form-widgets-voice').val(); this.render(); } ControlPanelView.prototype.render = function() { $('#form-widgets-voice').replaceWith(this.template); var voicelist = responsiveVoice.getVoices(); var vselect = $('#form-widgets-voice'); var i, len, voice; for (i = 0, len = voicelist.length; i < len; i++) { voice = voicelist[i]; if (voice.name === this.actual_voice) { vselect.append($('<option selected="selected" />').val(voice.name).text(voice.name)); } else { vselect.append($('<option />').val(voice.name).text(voice.name)); } } }; return ControlPanelView;})();$(function() { if ($('#viewlet-texttospeech').length > 0) { new MainView(); } if ($('body.template-texttospeech-settings').length > 0) { new ControlPanelView(); }});
var MainView = (function() {
function MainView() {
this.$el = $('#viewlet-texttospeech');
this.$button = $('#texttospeech-button', this.$el);
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');
this.label_paused = this.$el.attr('data-label-paused');
this.playing = false;
this.paused = true;
this.$button.on('click', $.proxy(this.play_pause, this));
}
MainView.prototype.onstart = function() {
this.playing = true;
this.paused = false;
this.$button.attr('value', this.label_playing);
};
MainView.prototype.onend = function() {
this.playing = false;
this.paused = true;
this.$button.attr('value', this.label_stopped);
};
MainView.prototype.play_pause = function(e) {
e.preventDefault();
if (this.playing) {
if (this.paused) {
this.paused = false;
this.$button.attr('value', this.label_playing);
responsiveVoice.resume();
} else {
this.paused = true;
this.$button.attr('value', this.label_paused);
responsiveVoice.pause();
}
} else {
responsiveVoice.speak(
$('#content').text(),
this.voice, {
onstart: $.proxy(this.onstart, this),
onend: $.proxy(this.onend, this)
}
);
}
};
return MainView;
})();


var ControlPanelView = (function() {
function ControlPanelView() {
this.template = "<select id=\"form-widgets-voice\" name=\"form.widgets.voice\" class=\"text-widget required textline-field\">\n</select>";
this.actual_voice = $('#form-widgets-voice').val();
this.render();
}
ControlPanelView.prototype.render = function() {
$('#form-widgets-voice').replaceWith(this.template);
var voicelist = responsiveVoice.getVoices();
var vselect = $('#form-widgets-voice');
var i, len, voice;
for (i = 0, len = voicelist.length; i < len; i++) {
voice = voicelist[i];
if (voice.name === this.actual_voice) {
vselect.append($('<option selected="selected" />').val(voice.name).text(voice.name));
} else {
vselect.append($('<option />').val(voice.name).text(voice.name));
}
}
};
return ControlPanelView;
})();


$(function() {
if ($('#viewlet-texttospeech').length > 0) {
new MainView();
}
if ($('body.template-texttospeech-settings').length > 0) {
new ControlPanelView();
}
});
Binary file modified src/collective/texttospeech/static/texttospeech-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 652a25f

Please sign in to comment.