[xiph-commits] r4058 - itext/javascript
silvia at svn.annodex.net
silvia at svn.annodex.net
Thu Oct 29 18:08:20 PDT 2009
Author: silvia
Date: 2009-10-29 18:08:20 -0700 (Thu, 29 Oct 2009)
New Revision: 4058
Modified:
itext/javascript/subtitles_v2.js
Log:
Fixed the display of the menu.
Also added a "none" item to disable tracks.
Modified: itext/javascript/subtitles_v2.js
===================================================================
--- itext/javascript/subtitles_v2.js 2009-10-29 13:22:51 UTC (rev 4057)
+++ itext/javascript/subtitles_v2.js 2009-10-30 01:08:20 UTC (rev 4058)
@@ -493,7 +493,6 @@
onleave: null,
primary_lang: null,
secondary_lang: null,
- fetch_lang: null,
init: function (itextlist) {
this.itextlist = itextlist;
this.category = jQuery(itextlist).attr("category");
@@ -506,20 +505,21 @@
this.load();
// fetch the appropriate track
+ var default_lang;
if (this.primary_lang) {
- this.fetch_lang = this.primary_lang;
+ default_lang = this.primary_lang;
} else if (this.secondary_lang) {
- this.fetch_lang = this.secondary_lang;
+ default_lang = this.secondary_lang;
}
if (this.active != "none") {
- if (this.active != "auto") {
- if (this.itexts[this.active]) {
- this.fetch_lang = this.active;
- } else {
+ if (this.active == "auto") {
+ this.active = default_lang;
+ } else {
+ if (!this.itexts[this.active]) {
this.active = "none";
}
}
- this.itexts[this.fetch_lang].fetch();
+ this.itexts[this.active].fetch();
}
},
load: function() {
@@ -544,6 +544,14 @@
this.itexts = itexts_tmp;
this.secondary_lang = secondary_lang_tmp;
this.primary_lang = primary_lang_tmp;
+ },
+ enable: function(lang) {
+ if (lang === 'none') {
+ this.active = "none";
+ } else if (this.itexts[lang]) {
+ this.itexts[lang].fetch();
+ this.active = lang;
+ }
}
};
@@ -587,19 +595,29 @@
var appendText = '<div class="itextMenu" role="presentation">\n';
appendText += '<ul class="catMenu" role="presentation">\n';
for (var i in this.itextlist) {
- var submenu = i.name || categoryName(i.category);
- appendText += '<li role="menuitem" aria-haspopup="true" tabindex="0"> < ' + submenu + '\n';
- appendText += '<ul class="langMenu" role="menu" >\n';
- for (var j in i.itexts) {
- appendText += '<li role="menuitemradio" tabindex="0"';
- if (i.fetch_lang === j.lang) {
- appendText += ' aria-checked="true"';
- } else {
- appendText += ' aria-checked="false"';
- }
- appendText += '><a href="#" onclick="'+elstring+'.itexts.tracks[\'' + i + '\'][\'' + j + '\'].enable();jQuery(\'.catMenu\').css(\'visibility\', \'hidden\');return false;">' + j.langName + '</a></li>\n';
+ var subm = this.itextlist[i];
+ var submenu = subm.name || categoryName(i);
+ appendText += '<li role="menuitem" aria-haspopup="true" tabindex="0"> < ' + submenu + '\n';
+ appendText += '<ul class="langMenu" role="menu" >\n';
+ // add a default of "none" element to menu
+ appendText += '<li role="menuitemradio" tabindex="0"';
+ if (subm.active === 'none') {
+ appendText += ' aria-checked="true"';
+ } else {
+ appendText += ' aria-checked="false"';
+ }
+ appendText += '><a href="#" onclick="'+elstring+'.itexts.itextlist[\'' + i + '\'].enable(\'none\');jQuery(\'.catMenu\').css(\'visibility\', \'hidden\');return false;">None</a></li>\n';
+ for (var j in subm.itexts) {
+ var elt = subm.itexts[j];
+ appendText += '<li role="menuitemradio" tabindex="0"';
+ if (subm.active === j) {
+ appendText += ' aria-checked="true"';
+ } else {
+ appendText += ' aria-checked="false"';
}
- appendText += '</ul>\n</li>\n';
+ appendText += '><a href="#" onclick="'+elstring+'.itexts.itextlist[\'' + i + '\'].enable(\'' + j + '\');jQuery(\'.catMenu\').css(\'visibility\', \'hidden\');return false;">' + elt.langName + '</a></li>\n';
+ }
+ appendText += '</ul>\n</li>\n';
}
appendText += '</ul></div>\n';
jQuery(baseEl).append(appendText);
@@ -618,7 +636,7 @@
// get content for active tracks only
if (li.active != "none") {
- content = li.itexts[li.fetch_lang].currentText(currentTime);
+ content = li.itexts[li.active].currentText(currentTime);
// update content & styling of itext div if necessary
if (content) {
@@ -665,6 +683,9 @@
// remove content
jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "hidden");
}
+ } else {
+ // remove content
+ jQuery("#" + this.div_id + " > .itext_" + i).css("visibility", "hidden");
}
}
}
More information about the commits
mailing list