Index: trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php |
— | — | @@ -49,6 +49,8 @@ |
50 | 50 | 'mwe-improve_transcript' => 'Improve', |
51 | 51 | 'mwe-no_text_tracks_found' => 'No text tracks were found', |
52 | 52 | 'mwe-subtitles' => '$1 subtitles', |
| 53 | + 'mwe-no_text_tracks_found' => 'No text subtitles found', |
| 54 | + 'mwe-add-edit-subs' => 'Add/edit subtitles', |
53 | 55 | |
54 | 56 | /* |
55 | 57 | * js file: /libSequencer/mvTimedEffectsEdit.js |
Index: trunk/phase3/js2/mwEmbed/libTimedText/mvTextInterface.js |
— | — | @@ -4,7 +4,8 @@ |
5 | 5 | "mwe-auto_scroll" : "auto scroll", |
6 | 6 | "mwe-close" : "close", |
7 | 7 | "mwe-improve_transcript" : "Improve", |
8 | | - "mwe-no_text_tracks_found" : "No text tracks were found" |
| 8 | + "mwe-no_text_tracks_found" : "No text subtitles found", |
| 9 | + "mwe-add-edit-subs" : "Add/edit subtitles" |
9 | 10 | }) |
10 | 11 | // text interface object (for inline display captions) |
11 | 12 | var mvTextInterface = function( parentEmbed ){ |
— | — | @@ -18,6 +19,11 @@ |
19 | 20 | autoscroll:true, |
20 | 21 | add_to_end_on_this_pass:false, |
21 | 22 | scrollTimerId:0, |
| 23 | + found_tracks: false, |
| 24 | + suportedMime:{ |
| 25 | + 'srt': 'text/x-srt', |
| 26 | + 'cmml': 'text/cmml' |
| 27 | + }, |
22 | 28 | init:function( parentEmbed ){ |
23 | 29 | //init a new availableTracks obj: |
24 | 30 | this.availableTracks={}; |
— | — | @@ -28,7 +34,7 @@ |
29 | 35 | }, |
30 | 36 | //@@todo separate out data loader & data display |
31 | 37 | getTimedTextTracks:function(){ |
32 | | - js_log("load timed text from roe: "+ this.pe.roe); |
| 38 | + //js_log("load timed text from roe: "+ this.pe.roe); |
33 | 39 | var _this = this; |
34 | 40 | var apiUrl = mwGetLocalApiUrl(); |
35 | 41 | //if roe not yet loaded do load it: |
— | — | @@ -39,13 +45,12 @@ |
40 | 46 | if(_this.pe.roe){ |
41 | 47 | do_request( _this.pe.roe, function(data) |
42 | 48 | { |
43 | | - //continue |
44 | 49 | _this.pe.media_element.addROE(data); |
45 | 50 | _this.getParseTimedText_rowReady(); |
46 | 51 | }); |
47 | 52 | }else if( _this.pe.wikiTitleKey ){ |
48 | 53 | do_api_req({ |
49 | | - 'url': apiUrl, |
| 54 | + 'url' : apiUrl, |
50 | 55 | 'data': { |
51 | 56 | 'list' : 'allpages', |
52 | 57 | 'apprefix' : 'TimedText:' + _this.pe.wikiTitleKey |
— | — | @@ -68,11 +73,8 @@ |
69 | 74 | var langKey = subPage.title.split('.'); |
70 | 75 | var extension = langKey.pop(); |
71 | 76 | langKey = langKey.pop(); |
72 | | - var mimeTypes = { |
73 | | - 'srt': 'text/x-srt', |
74 | | - 'cmml': 'text/cmml' |
75 | | - } |
76 | | - if( !mimeTypes[ extension ] ){ |
| 77 | + |
| 78 | + if( ! _this.suportedMime[ extension ] ){ |
77 | 79 | js_log('Error: unknown extension:'+ extension); |
78 | 80 | continue; |
79 | 81 | } |
— | — | @@ -84,14 +86,15 @@ |
85 | 87 | $j(textElm).attr({ |
86 | 88 | 'category' : 'SUB', |
87 | 89 | 'lang' : langKey, |
88 | | - 'type' : mimeTypes[ extension ], |
| 90 | + 'type' : _this.suportedMime[ extension ], |
89 | 91 | 'title' : langData[ langKey], |
90 | 92 | 'src' : wgServer + wgScript + '?title=' + subPage.title + '&action=raw' |
91 | 93 | }); |
92 | | - _this.pe.media_element.tryAddSource( textElm ); |
93 | | - _this.getParseTimedText_rowReady(); |
| 94 | + _this.pe.media_element.tryAddSource( textElm ); |
94 | 95 | } |
95 | 96 | } |
| 97 | + //after all text loaded: |
| 98 | + _this.getParseTimedText_rowReady(); |
96 | 99 | }); //do_api_req({ |
97 | 100 | }); //function( subData ) { |
98 | 101 | } |
— | — | @@ -107,15 +110,12 @@ |
108 | 111 | } |
109 | 112 | } |
110 | 113 | }, |
111 | | - getParseTimedText_rowReady: function (){ |
112 | | - var _this = this; |
113 | | - //create timedTextObj |
114 | | - var default_found=false; |
| 114 | + getParseTimedText_rowReady: function (){ |
| 115 | + var _this = this; |
| 116 | + //create timedTextObj |
115 | 117 | js_log("mv_txt_load_:SHOW mv_txt_load_"); |
116 | 118 | $j('#mv_txt_load_'+_this.pe.id).show(); //show the loading icon |
117 | | - |
118 | 119 | $j.each( this.pe.media_element.sources, function(inx, source){ |
119 | | - |
120 | 120 | if( typeof source.id == 'undefined' || source.id == null ){ |
121 | 121 | source.id = 'tt_' + inx; |
122 | 122 | } |
— | — | @@ -128,7 +128,7 @@ |
129 | 129 | //display if requested: |
130 | 130 | if( source['default'] == "true" ){ |
131 | 131 | //we did set at least one track by default tag |
132 | | - default_found=true; |
| 132 | + _this.found_tracks=true; |
133 | 133 | js_log('do load timed text: ' + source.id ); |
134 | 134 | _this.loadAndDisplay( source.id ); |
135 | 135 | }else{ |
— | — | @@ -136,22 +136,15 @@ |
137 | 137 | } |
138 | 138 | } |
139 | 139 | }); |
140 | | - |
141 | 140 | //no default clip found take the first_id |
142 | | - if(!default_found){ |
| 141 | + if(!_this.found_tracks){ |
143 | 142 | $j.each( _this.availableTracks, function(inx, sourceTrack){ |
144 | 143 | _this.loadAndDisplay( sourceTrack.id ); |
145 | | - default_found=true; |
146 | | - //retun after loading first available |
| 144 | + _this.found_tracks=true; |
| 145 | + //return after loading first available |
147 | 146 | return false; |
148 | 147 | }); |
149 | 148 | } |
150 | | - |
151 | | - //if nothing found anywhere update the loading icon to say no tracks found |
152 | | - if(!default_found) |
153 | | - $j('#mv_txt_load_'+_this.pe.id).html( gM('mwe-no_text_tracks_found') ); |
154 | | - |
155 | | - |
156 | 149 | }, |
157 | 150 | loadAndDisplay: function ( track_id){ |
158 | 151 | var _this = this; |
— | — | @@ -299,7 +292,7 @@ |
300 | 293 | applyTsSelect:function(){ |
301 | 294 | var _this = this; |
302 | 295 | //update availableTracks |
303 | | - $j('#mvtsel_'+this.pe.id+' .mvTsSelect').each(function(){ |
| 296 | + $j('#mvtsel_' + this.pe.id + ' .mvTsSelect').each(function(){ |
304 | 297 | if(this.checked){ |
305 | 298 | var track_id = this.name; |
306 | 299 | //if not yet loaded now would be a good time |
— | — | @@ -394,13 +387,23 @@ |
395 | 388 | }, |
396 | 389 | getMenu:function(){ |
397 | 390 | var out=''; |
| 391 | + var _this = this; |
398 | 392 | //add in loading icon: |
399 | 393 | var as_checked = (this.autoscroll)?'checked':''; |
400 | | - out+= '<div id="tt_mmenu_'+this.pe.id+'" class="ui-widget-header" style="font-size:.6em;position:absolute;top:0;height:30px;left:0px;right:0px;">' + |
401 | | - $j.btnHtml(gM('mwe-select_transcript_set'), 'tt-select', 'shuffle'); |
402 | | - if(this.pe.media_element.linkback){ |
403 | | - out+=' ' + $j.btnHtml(gM('mwe-improve_transcript'), 'tt-improve', 'document', {href:this.pe.media_element.linkback, target:'_new'}); |
| 394 | + out += '<div id="tt_mmenu_'+this.pe.id+'" class="ui-widget-header" style="font-size:.6em;position:absolute;top:0;height:30px;left:0px;right:0px;">'; |
| 395 | + out += $j.btnHtml( gM('mwe-select_transcript_set'), 'tt-select', 'shuffle'); |
| 396 | + |
| 397 | + _this.editlink = ''; |
| 398 | + |
| 399 | + if( this.pe.media_element.linkback ){ |
| 400 | + _this.editlink = this.pe.media_element.linkback; |
| 401 | + }else if(this.pe.wikiTitleKey && wgServer && wgScript) { //check for wikiTitleKey (for edit linkback) |
| 402 | + //only local: |
| 403 | + _this.editlink = wgServer + wgScript + '?title=TimedText:' + this.pe.wikiTitleKey +'.'+ wgContentLanguage + '.srt&action=edit'; |
404 | 404 | } |
| 405 | + if(_this.editlink!='') |
| 406 | + out+=' ' + $j.btnHtml(gM('mwe-improve_transcript'), 'tt-improve', 'document', {href:_this.editlink, target:'_new'}); |
| 407 | + |
405 | 408 | out+='<input onClick="document.getElementById(\''+this.pe.id+'\').textInterface.setAutoScroll(this.checked);return false;" ' + |
406 | 409 | 'type="checkbox" '+as_checked +'>'+gM('mwe-auto_scroll') + ' ' + |
407 | 410 | $j.btnHtml(gM('mwe-close'), 'tt-close', 'circle-close'); |
— | — | @@ -420,6 +423,15 @@ |
421 | 424 | }); |
422 | 425 | //use hard-coded link: |
423 | 426 | $j(mt + ' .tt-improve').btnBind(); |
| 427 | + |
| 428 | + //dobule check we have sublties (else add default missing msg) |
| 429 | + //if nothing found anywhere update the loading icon to say no tracks found |
| 430 | + if(!_this.found_tracks){ |
| 431 | + $j( '#mmbody_' + _this.pe.id).html( ''+ |
| 432 | + '<h3>' + gM('mwe-no_text_tracks_found') + '</h3>' + |
| 433 | + '<a href="' + _this.editlink + '">'+ gM('mwe-add-edit-subs') + '</a>' |
| 434 | + ); |
| 435 | + } |
424 | 436 | } |
425 | 437 | } |
426 | 438 | |