|
40 | 40 | $('body').trigger('youtubeIframeAPIReady', []); |
41 | 41 | }; |
42 | 42 |
|
43 | | - // |
| 43 | + // If there is only one player on the page, dispatch global keydown events to it |
| 44 | + // Otherwise, keydowwn events are handled locally (see event.js > handleEventListeners()) |
44 | 45 | $(window).keydown(function(e) { |
45 | | - if (AblePlayer.nextIndex === 1) { |
46 | | - // Only one player on the page; dispatch global key presses to it. |
| 46 | + if (AblePlayer.nextIndex === 1) { |
47 | 47 | AblePlayer.lastCreated.onPlayerKeyPress(e); |
48 | 48 | } |
49 | 49 | }); |
50 | 50 |
|
51 | | - |
52 | 51 | // Construct an AblePlayer object |
53 | 52 | // Parameters are: |
54 | 53 | // media - jQuery selector or element identifying the media. |
|
1140 | 1139 | thisObj.onClickPlayerButton(this); |
1141 | 1140 | }); |
1142 | 1141 |
|
1143 | | - // TODO: Ascertain whether this is needed |
1144 | | - // handle local key-presses if this is not the only player on the page; |
1145 | | - // otherwise these are dispatched by global handler. |
1146 | | - this.$ccButton.keydown(function (e) { |
1147 | | - if (AblePlayer.nextIndex > 1) { |
1148 | | - thisObj.onPlayerKeyPress(e); |
1149 | | - } |
1150 | | - }); |
1151 | | - |
1152 | 1142 | // TODO: might need to adjust width and height of div.able-vidcap-container |
1153 | 1143 | // Only used if !this.usingYouTubeCaptions |
1154 | 1144 | /* |
|
6116 | 6106 |
|
6117 | 6107 | (function ($) { |
6118 | 6108 | AblePlayer.prototype.updateTranscript = function() { |
| 6109 | + |
6119 | 6110 | if (!this.includeTranscript) { |
6120 | 6111 | return; |
6121 | 6112 | } |
|
6160 | 6151 | } |
6161 | 6152 |
|
6162 | 6153 | // handle clicks on text within transcript |
6163 | | - // Note #1: Only one transcript per page is supported |
6164 | | - // Note #2: Pressing Enter on an element that is not natively clickable does NOT trigger click() |
6165 | | - // Forcing this elsewhere, in the keyboard handler section |
6166 | | - if ($('.able-transcript').length > 0) { |
6167 | | - $('.able-transcript span.able-transcript-seekpoint').click(function(event) { |
| 6154 | + // Note: This event listeners handles clicks only, not keydown events |
| 6155 | + // Pressing Enter on an element that is not natively clickable does NOT trigger click() |
| 6156 | + // Keydown events are handled elsehwere, both globally (ableplayer-base.js) and locally (event.js) |
| 6157 | + if (this.$transcriptArea.length > 0) { |
| 6158 | + this.$transcriptArea.find('.able-transcript span.able-transcript-seekpoint').click(function(event) { |
6168 | 6159 | var spanStart = parseFloat($(this).attr('data-start')); |
6169 | 6160 | // Add a tiny amount so that we're inside the span. |
6170 | 6161 | spanStart += .01; |
|
6185 | 6176 | currentTime = parseFloat(currentTime); |
6186 | 6177 |
|
6187 | 6178 | // Highlight the current transcript item. |
6188 | | - $('.able-transcript span.able-transcript-caption').each(function() { |
| 6179 | + this.$transcriptArea.find('.able-transcript span.able-transcript-caption').each(function() { |
6189 | 6180 | start = parseFloat($(this).attr('data-start')); |
6190 | 6181 | end = parseFloat($(this).attr('data-end')); |
6191 | 6182 | if (currentTime >= start && currentTime <= end) { |
6192 | 6183 | // move all previous highlights before adding one to current span |
6193 | | - $('.able-highlight').removeClass('able-highlight'); |
| 6184 | + thisObj.$transcriptArea.find('.able-highlight').removeClass('able-highlight'); |
6194 | 6185 | $(this).addClass('able-highlight'); |
6195 | 6186 | return false; |
6196 | 6187 | } |
|
6747 | 6738 | } |
6748 | 6739 | // Convert to lower case. |
6749 | 6740 | var which = e.which; |
| 6741 | + |
6750 | 6742 | if (which >= 65 && which <= 90) { |
6751 | 6743 | which += 32; |
6752 | 6744 | } |
|
7029 | 7021 | thisObj.onClickPlayerButton(this); |
7030 | 7022 | }); |
7031 | 7023 |
|
7032 | | - // handle local key-presses if we're not the only player on the page; otherwise these are dispatched by global handler. |
| 7024 | + // handle local keydown events if this isn't the only player on the page; |
| 7025 | + // otherwise these are dispatched by global handler (see ableplayer-base,js) |
7033 | 7026 | this.$ableDiv.keydown(function (e) { |
7034 | 7027 | if (AblePlayer.nextIndex > 1) { |
7035 | 7028 | thisObj.onPlayerKeyPress(e); |
7036 | 7029 | } |
7037 | 7030 | }); |
7038 | | - |
| 7031 | + // transcript is not a child of this.$ableDiv |
| 7032 | + // therefore, must be added separately |
| 7033 | + this.$transcriptArea.keydown(function (e) { |
| 7034 | + if (AblePlayer.nextIndex > 1) { |
| 7035 | + thisObj.onPlayerKeyPress(e); |
| 7036 | + } |
| 7037 | + }); |
| 7038 | + |
7039 | 7039 | // handle clicks on playlist items |
7040 | 7040 | if (this.$playlist) { |
7041 | 7041 | this.$playlist.click(function() { |
|
0 commit comments