From: Christopher De Cairos Date: Fri, 22 Jul 2011 18:50:20 +0000 (-0400) Subject: [#553] removed googlenews plug-in and ripped out translate support in the subtitle... X-Git-Tag: v0.8^2~19^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=refs%2Fheads%2Ft553;p=popcorn-js.git [#553] removed googlenews plug-in and ripped out translate support in the subtitle plug-in --- diff --git a/plugins/googlenews/popcorn.googlenews.html b/plugins/googlenews/popcorn.googlenews.html deleted file mode 100755 index a35a344..0000000 --- a/plugins/googlenews/popcorn.googlenews.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - Popcorn google Map Plug-in Demo - - - - - - - -

Popcorn google News Plug-in Demo

-

Google News topic will appear at 0 seconds and disappear at 20 seconds.

-

Google News topic will appear at 25 seconds and disappear at 30 seconds.

-
- -
-
- - diff --git a/plugins/googlenews/popcorn.googlenews.js b/plugins/googlenews/popcorn.googlenews.js deleted file mode 100755 index fb808cf..0000000 --- a/plugins/googlenews/popcorn.googlenews.js +++ /dev/null @@ -1,119 +0,0 @@ -// PLUGIN: Google News - -(function (Popcorn) { - - var scriptLoaded = false, - scriptLoading = false, - callBack = function( data ) { - - if ( typeof google !== 'undefined' && google.load ) { - - google.load("elements", "1", {packages : ["newsshow"], callback: function() {scriptLoaded = true;}}); - } else { - - setTimeout( function() { - - callBack( data ); - }, 1); - } - }; - - /** - * Google News popcorn plug-in - * Displays Google News information on a topic in a targeted div. - * Options parameter will need a start, end and target. - * Optional parameters are topic. topic defaults to "top stories" - * Start is the time that you want this plug-in to execute - * End is the time that you want this plug-in to stop executing - * Target is the id of the document element that the content is - * appended to, this target element must exist on the DOM - * Topic is the topic of news articles you want to display. - * - * @param {Object} options - * - * Example: - var p = Popcorn('#video') - .googlenews({ - start: 5, // seconds, mandatory - end: 15, // seconds, mandatory - topic: 'oil spill', // optional - target: 'newsdiv' // mandatory - } ) - * - */ - Popcorn.plugin( "googlenews" , { - - manifest: { - about:{ - name: "Popcorn Google News Plugin", - version: "0.1", - author: "Scott Downe", - website: "http://scottdowne.wordpress.com/" - }, - options:{ - start : {elem:'input', type:'text', label:'In'}, - end : {elem:'input', type:'text', label:'Out'}, - target : 'news-container', - topic : {elem:'select', type:'text', label:'Type'} - } - }, - _setup : function( options ) { - - if ( !scriptLoading ) { - - scriptLoading = true; - Popcorn.getScript( "http://www.google.com/jsapi", callBack ); - } - - options.container = document.createElement( 'div' ); - var container = document.createElement( 'div' ); - if ( document.getElementById( options.target ) ) { - document.getElementById( options.target ).appendChild( options.container ); - options.container.appendChild( container ); - } - - var readyCheck = setInterval(function() { - if ( !scriptLoaded ) { - return; - } - clearInterval( readyCheck ); - - options.newsShow = new google.elements.NewsShow( container, { - format : "300x250", - queryList : [ - { q: options.topic || "Top Stories" } - ] - } ); - - }, 5); - - options.container.style.display = "none"; - - }, - /** - * @member googlenews - * The start function will be executed when the currentTime - * of the video reaches the start time provided by the - * options variable - */ - start: function( event, options ){ - options.container.setAttribute( 'style', 'display:inline' ); - }, - /** - * @member googlenews - * The end function will be executed when the currentTime - * of the video reaches the end time provided by the - * options variable - */ - end: function( event, options ){ - options.container.setAttribute( 'style', 'display:none' ); - }, - _teardown: function( options ) { - // google news does not like this, throws an error "a is null" - // doesn't hurt popcorn, and only happens once - document.getElementById( options.target ) && document.getElementById( options.target ).removeChild( options.container ); - options.newsShow = null; - } - }); - -})( Popcorn ); diff --git a/plugins/googlenews/popcorn.googlenews.unit.html b/plugins/googlenews/popcorn.googlenews.unit.html deleted file mode 100755 index bf77bca..0000000 --- a/plugins/googlenews/popcorn.googlenews.unit.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - Popcorn Google News Plug-in Test - - - - - - - - - - -

Popcorn Google News Plugin

-

-
-

-
    -
    - - -
    - - diff --git a/plugins/googlenews/popcorn.googlenews.unit.js b/plugins/googlenews/popcorn.googlenews.unit.js deleted file mode 100755 index a41c634..0000000 --- a/plugins/googlenews/popcorn.googlenews.unit.js +++ /dev/null @@ -1,66 +0,0 @@ -test( "Popcorn google news Plugin", function () { - - var popped = Popcorn( "#video" ), - expects = 8, - count = 0, - setupId, - googlenewsdiv = document.getElementById( "googlenewsdiv" ); - - expect(expects); - - function plus() { - if ( ++count===expects ) { - start(); - } - } - - stop(); - - ok ( "googlenews" in popped, "googlenews is a method of the popped instance" ); - plus(); - - equals ( googlenewsdiv.innerHTML, "", "initially, there is nothing inside the googlenewsdiv" ); - plus(); - - popped.googlenews({ - start: 0, // seconds - end: 2, // seconds - topic: "Oil Spill", - target: "googlenewsdiv" - }) - .googlenews({ - start: 2, // seconds - end: 4, // seconds - topic: "Village Telco", - target: "googlenewsdiv" - }) - .volume( 0 ); - - setupId = popped.getLastTrackEventId(); - - popped.exec( 0, function() { - equals( googlenewsdiv.childElementCount, 2, "googlenewsdiv now has two inner elements" ); - plus(); - equals( googlenewsdiv.children[0].style.display , "inline", "first googlenews is visible on the page" ); - plus(); - }); - - popped.exec( 3, function() { - equals( googlenewsdiv.children[1].style.display , "inline", "second googlenews is visible on the page" ); - plus(); - }); - - popped.exec( 4, function() { - equals( googlenewsdiv.children[1].style.display , "none", "second googlenews is no longer visible on the page" ); - plus(); - equals( googlenewsdiv.children[0].style.display , "none", "first googlenews is no longer visible on the page" ); - plus(); - - popped.pause().removeTrackEvent( setupId ); - ok( !googlenewsdiv.children[1], "removed google news was properly destroyed" ); - plus(); - }); - - popped.play(); - -}); diff --git a/plugins/subtitle/popcorn.subtitle.html b/plugins/subtitle/popcorn.subtitle.html index c01a405..bba8e96 100755 --- a/plugins/subtitle/popcorn.subtitle.html +++ b/plugins/subtitle/popcorn.subtitle.html @@ -15,17 +15,11 @@ start: 5, // seconds end: 15, // seconds text: 'this is the first subtitle of 2011', - language: "en", - languagesrc: "language", - accessibilitysrc: "accessibility" } ) .subtitle({ start: 20, // seconds end: 45, // seconds text: 'this is the second subtitle of 2011', - language: "en", - languagesrc: "language", - accessibilitysrc: "accessibility" } ) }, false); @@ -54,24 +48,6 @@ -

    Choose your language

    - -
    - with help from Google Translate
    - All subtitles (accessibility) -
    diff --git a/plugins/subtitle/popcorn.subtitle.js b/plugins/subtitle/popcorn.subtitle.js index 4d9c718..ceff46e 100755 --- a/plugins/subtitle/popcorn.subtitle.js +++ b/plugins/subtitle/popcorn.subtitle.js @@ -2,25 +2,7 @@ (function ( Popcorn ) { - var scriptLoaded = false, - i = 0, - callBack = function( data ) { - - if ( window.google && google.load ) { - - google.load( "language", "1", { - callback: function() { - scriptLoaded = true; - } - }); - } else { - - setTimeout( function() { - - callBack( data ); - }, 1); - } - }, + var i = 0, createDefaultContainer = function( context ) { var ctxContainer = context.container = document.createElement( "div" ), @@ -50,8 +32,6 @@ context.media.parentNode.appendChild( ctxContainer ); }; - Popcorn.getScript( "http://www.google.com/jsapi", callBack ); - /** * Subtitle popcorn plug-in * Displays a subtitle over the video, or in the target div @@ -63,28 +43,6 @@ * appended to, this target element must exist on the DOM * Text is the text of the subtitle you want to display. * - * Language is the expected language the subtitle text is in - * Languagesrc is the target id of the element that contains - * the language value ("en", "fr", etc.) to translate the text into - * example: - * - * Accessibilitysrc is the target id of a checkbox element - * checked means show all subtitles regardless of language and languagesrc - * not checked means only translate if language and languagesrc are different - * if no accessibilitysrc exists, default is to display all subtitles regardless - * * @param {Object} options * * Example: @@ -94,28 +52,10 @@ end: 15, // seconds, mandatory text: 'Hellow world', // optional target: 'subtitlediv', // optional - language: 'en', // optional - languagesrc: 'language', // optional - accessibilitysrc: 'accessibility' // optional } ) * */ - // translates whatever is in options.container into selected language - var translate = function( options, text ) { - - options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value; - google.language.translate( text, "", options.selectedLanguage, function( result ) { - - for( var k = 0, children = options.container.children, len = children.length; k < len; k++ ) { - if ( children[ k ].style.display === "inline" ) { - children[ k ].innerHTML = result.translation; - } - } - - }); - }; - Popcorn.plugin( "subtitle" , { manifest: { @@ -146,12 +86,10 @@ }, _setup: function( options ) { - var newdiv = document.createElement( "div" ), - accessibility = document.getElementById( options.accessibilitysrc ); + var newdiv = document.createElement( "div" ); - newdiv.id = "subtitle-" + i; + newdiv.id = "subtitle-" + i++; newdiv.style.display = "none"; - i++; // Creates a div for all subtitles to use ( !this.container && ( !options.target || options.target === "subtitle-container" ) ) && @@ -171,70 +109,6 @@ options.showSubtitle = function() { options.innerContainer.innerHTML = options.text; }; - options.toggleSubtitles = function() {}; - - var readyCheck = setInterval(function() { - if ( !scriptLoaded ) { - return; - } - clearInterval( readyCheck ); - - if ( options.languagesrc ) { - options.showSubtitle = translate; - options.languageSrc = document.getElementById( options.languagesrc ); - options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value; - - if ( !this.languageSources ) { - this.languageSources = {}; - } - - if ( !this.languageSources[ options.languagesrc ] ) { - this.languageSources[ options.languagesrc ] = {}; - } - - if ( !this.languageSources[ options.languagesrc ][ options.target ] ) { - this.languageSources[ options.languagesrc ][ options.target ] = true; - - options.languageSrc.addEventListener( "change", function() { - - options.toggleSubtitles(); - - for( var k = 0, children = options.container.children, len = children.length; k < len; k++ ) { - if ( children[ k ].style.display === "inline" ) { - options.showSubtitle( options, children[ k ].innerHTML ); - } - } - - }, false ); - - } - - } - if ( accessibility ) { - options.accessibility = accessibility; - - options.toggleSubtitles = function() { - - options.selectedLanguage = options.languageSrc.options[ options.languageSrc.selectedIndex ].value; - - if ( options.accessibility.checked || options.selectedLanguage !== ( options.language || "") ) { - - options.display = "inline"; - options.container.style.display = options.display; - } else if ( options.selectedLanguage === ( options.language || "") ) { - - options.display = "none"; - options.container.style.display = options.display; - } - }; - - options.accessibility.addEventListener( "change", options.toggleSubtitles, false ); - - // initiate it once to set starting state - options.toggleSubtitles(); - } - }, 5); - }, /** * @member subtitle diff --git a/plugins/subtitle/popcorn.subtitle.unit.html b/plugins/subtitle/popcorn.subtitle.unit.html index 05ff6db..ff84ce3 100755 --- a/plugins/subtitle/popcorn.subtitle.unit.html +++ b/plugins/subtitle/popcorn.subtitle.unit.html @@ -54,13 +54,5 @@

    Your user agent does not support the HTML5 Video element.

    -

    Choose your language

    - -
    - with help from Google Translate
    - All subtitles (accessibility) -
    diff --git a/plugins/subtitle/popcorn.subtitle.unit.js b/plugins/subtitle/popcorn.subtitle.unit.js index a0f9328..8101cc5 100755 --- a/plugins/subtitle/popcorn.subtitle.unit.js +++ b/plugins/subtitle/popcorn.subtitle.unit.js @@ -2,7 +2,7 @@ test("Popcorn Subtitle Plugin", function () { var popped = Popcorn( "#video" ), popped2 = Popcorn( "#video2" ), - expects = 16, + expects = 12, count = 0, subTop = 9001, subLeft = 9001, @@ -26,25 +26,16 @@ test("Popcorn Subtitle Plugin", function () { start: 0, end: 2, text: 'this is the first subtitle of 2011', - language: "en", - languagesrc: "language", - accessibilitysrc: "accessibility" } ) .subtitle({ start: 2, end: 4, text: 'this is the second subtitle of 2011', - language: "en", - languagesrc: "language", - accessibilitysrc: "accessibility" } ) .subtitle({ start: 5, end: 7, text: 'this is the third subtitle of 2011', - language: "en", - languagesrc: "language", - accessibilitysrc: "accessibility" } ) .volume(0) .play(); @@ -124,31 +115,6 @@ test("Popcorn Subtitle Plugin", function () { popped.media.play(); }); - - popped.exec( 6, function() { - - popped.media.play(); - - equals (subtitlediv.style.display, "inline", "subtitles being displayed with accessiblity on" ); - plus(); - - // turn accessibility off - document.getElementById( "accessibility" ).click(); - - equals (subtitlediv.style.display, "none", "subtitles not being displayed with accessiblity off" ); - plus(); - - // turn accessibility back on - document.getElementById( "accessibility" ).click(); - - equals (subtitlediv.style.display, "inline", "subtitles being displayed with accessiblity back on" ); - plus(); - - equals (subtitlediv.children[ 2 ].innerHTML, "this is the third subtitle of 2011", "subtitle displaying correct information" ); - plus(); - popped.media.play(); - - }); popped.exec( 8, function() { popped.pause();