Skip to content

Commit

Permalink
Fixes #22
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPeek committed Jun 15, 2022
1 parent efb07e3 commit 652c876
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 184 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ Several elements of **Text Entry** have been assigned a label using the [aria-la
No known limitations.

----------------------------
**Version number:** 5.1.2
**Framework versions supported:** 5+
**Version number:** 5.2.0
**Framework versions supported:** 5.8+
**Author / maintainer:** DeltaNet with [contributors](https://github.com/deltanet/adapt-textEntry-audio/graphs/contributors)
**Accessibility support:** yes
**RTL support:** yes
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "adapt-textEntry-audio",
"version": "5.1.2",
"framework": ">=5",
"version": "5.2.0",
"framework": ">=5.8",
"homepage": "https://github.com/deltanet/adapt-textEntry-audio",
"issues": "https://github.com/deltanet/adapt-textEntry-audio/issues",
"description": "A text entry component to capture user text",
Expand Down
16 changes: 6 additions & 10 deletions js/adapt-textEntry-audio.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
define([
'core/js/adapt',
'./textEntryAudioView',
'core/js/models/componentModel'
], function(Adapt, TextEntryAudioView, ComponentModel) {

return Adapt.register('textEntry-audio', {
view: TextEntryAudioView,
model: ComponentModel.extend({})
});
import Adapt from 'core/js/adapt';
import TextEntryAudioModel from './textEntryAudioModel';
import TextEntryAudioView from './textEntryAudioView';

export default Adapt.register('textEntry-audio', {
model: TextEntryAudioModel,
view: TextEntryAudioView
});
3 changes: 3 additions & 0 deletions js/textEntryAudioModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ComponentModel from 'core/js/models/componentModel';

export default class TextEntryAudioModel extends ComponentModel {}
69 changes: 36 additions & 33 deletions js/textEntryAudioPopupView.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
define([
'core/js/adapt'
], function(Adapt) {
'use strict';
import Adapt from 'core/js/adapt';

var TextEntryAudioPopupView = Backbone.View.extend({
class TextEntryAudioPopupView extends Backbone.View {

className: 'textEntry-audio-popup-content',
className() {
return 'textEntry-audio-popup-content';
}

events: {
'click .textEntry-close-button': 'closePopup'
},
events() {
return {
'click .textEntry-close-button': 'closePopup'
};
}

initialize: function() {
this.listenToOnce(Adapt, 'notify:opened', this.onOpened);
this.render();
},
initialize(...args) {
super.initialize(...args);

onOpened: function() {
this.playAudio();
},
this.listenToOnce(Adapt, 'notify:opened', this.onOpened);
this.render();
}

render: function() {
var data = this.model.toJSON();
var template = Handlebars.templates['textEntryAudioPopup'];
this.$el.html(template(data));
},
onOpened() {
this.playAudio();
}

closePopup: function(event) {
Adapt.trigger('notify:close');
},
render() {
const data = this.model.toJSON();
data.view = this;
const template = Handlebars.templates[this.constructor.template];
this.$el.html(template(data));
}

playAudio: function() {
if (Adapt.audio && this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
Adapt.audio.audioClip[this.model.get('_audio')._channel].onscreenID = "";
Adapt.trigger('audio:playAudio', this.model.get("_feedback")._audio.src, this.model.get('_id'), this.model.get('_audio')._channel);
}
}
closePopup(event) {
Adapt.trigger('notify:close');
}

});
playAudio() {
if (Adapt.audio && this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
Adapt.audio.audioClip[this.model.get('_audio')._channel].onscreenID = "";
Adapt.trigger('audio:playAudio', this.model.get("_feedback")._audio.src, this.model.get('_id'), this.model.get('_audio')._channel);
}
}
}

return TextEntryAudioPopupView;
TextEntryAudioPopupView.template = 'textEntryAudioPopup';

});
export default TextEntryAudioPopupView;
Loading

0 comments on commit 652c876

Please sign in to comment.