assets/ableplayer/scripts/transcript.js in wai-website-theme-1.2 vs assets/ableplayer/scripts/transcript.js in wai-website-theme-1.3
- old
+ new
@@ -33,11 +33,10 @@
var languageSelectWrapper = $('<div class="transcript-language-select-wrapper">');
this.$transcriptLanguageSelectContainer = languageSelectWrapper;
languageSelectWrapper.append($('<label for="transcript-language-select">' + this.tt.language + ': </label>'), this.$transcriptLanguageSelect);
this.$transcriptToolbar.append(languageSelectWrapper);
-
this.$transcriptArea.append(this.$transcriptToolbar, this.$transcriptDiv);
// If client has provided separate transcript location, put it there.
// Otherwise append it to the body
if (this.transcriptDivLocation) {
@@ -68,11 +67,11 @@
this.$autoScrollTranscriptCheckbox.click(function () {
thisObj.handleTranscriptLockToggle(thisObj.$autoScrollTranscriptCheckbox.prop('checked'));
});
- this.$transcriptDiv.bind('mousewheel DOMMouseScroll click scroll', function (event) {
+ this.$transcriptDiv.on('mousewheel DOMMouseScroll click scroll', function (e) {
// Propagation is stopped in transcript click handler, so clicks are on the scrollbar
// or outside of a clickable span.
if (!thisObj.scrollingTranscript) {
thisObj.autoScrollTranscript = false;
thisObj.refreshControls();
@@ -80,14 +79,14 @@
thisObj.scrollingTranscript = false;
});
if (typeof this.$transcriptLanguageSelect !== 'undefined') {
- this.$transcriptLanguageSelect.on('click mousedown',function (event) {
+ this.$transcriptLanguageSelect.on('click mousedown',function (e) {
// execute default behavior
// prevent propagation of mouse event to toolbar or window
- event.stopPropagation();
+ e.stopPropagation();
});
this.$transcriptLanguageSelect.on('change',function () {
var language = thisObj.$transcriptLanguageSelect.val();
@@ -210,14 +209,24 @@
// handle clicks on text within transcript
// Note: This event listeners handles clicks only, not keydown events
// Pressing Enter on an element that is not natively clickable does NOT trigger click()
// Keydown events are handled elsehwere, both globally (ableplayer-base.js) and locally (event.js)
if (this.$transcriptArea.length > 0) {
- this.$transcriptArea.find('span.able-transcript-seekpoint').click(function(event) {
+ this.$transcriptArea.find('span.able-transcript-seekpoint').click(function(e) {
+ thisObj.seekTrigger = 'transcript';
var spanStart = parseFloat($(this).attr('data-start'));
// Add a tiny amount so that we're inside the span.
spanStart += .01;
- thisObj.seekTo(spanStart);
+ // Each click within the transcript triggers two click events (not sure why)
+ // this.seekingFromTranscript is a stopgab to prevent two calls to SeekTo()
+ if (!thisObj.seekingFromTranscript) {
+ thisObj.seekingFromTranscript = true;
+ thisObj.seekTo(spanStart);
+ }
+ else {
+ // don't seek a second time, but do reset var
+ thisObj.seekingFromTranscript = false;
+ }
});
}
};
AblePlayer.prototype.highlightTranscript = function (currentTime) {