From d81d6348e29a8a2b15441242b29cf0b334c4581a Mon Sep 17 00:00:00 2001 From: Adam Duston Date: Wed, 13 Oct 2010 17:42:36 -0400 Subject: [PATCH] Merge --- media/js/mirosubs.js | 21 --------------------- media/js/widget/dropdown.js | 7 ++++--- media/js/widget/playcontroller.js | 5 +++-- media/js/widget/subtitle/msservermodel.js | 15 ++++++++++++--- media/js/widget/subtitle/sharepanel.js | 2 +- media/js/widget/subtitlecontroller.js | 13 +++++++++---- media/js/widget/translate/dialog.js | 6 +++--- media/js/widget/widget.js | 12 +++++++----- 8 files changed, 39 insertions(+), 42 deletions(-) diff --git a/media/js/mirosubs.js b/media/js/mirosubs.js index a8d0e768..057c067d 100644 --- a/media/js/mirosubs.js +++ b/media/js/mirosubs.js @@ -50,14 +50,6 @@ mirosubs.returnURL = null; */ mirosubs.embedVersion = null; -/** - * @type {string} - * Set in widget constructor. - */ -mirosubs.videoURL = null; - -mirosubs.videoID = null; - /** * Set when widget gets initial state from server. All available languages. * Each member is a two-element array, with language code first then @@ -99,19 +91,6 @@ mirosubs.languageNameForCode = function(code) { return mirosubs.languageMap_[code]; }; -mirosubs.embedCode = function() { - return [ - '\n', - '({\n', - ' video_url: "', mirosubs.videoURL, '"\n', - '})\n', - ''].join(''); -}; - /** * Does not include trailing slash. */ diff --git a/media/js/widget/dropdown.js b/media/js/widget/dropdown.js index ac4c6ba5..e2a7c161 100644 --- a/media/js/widget/dropdown.js +++ b/media/js/widget/dropdown.js @@ -22,9 +22,10 @@ goog.provide('mirosubs.widget.DropDown'); * @constructor * @param {mirosubs.widget.DropDownContents} dropDownContents */ -mirosubs.widget.DropDown = function(dropDownContents, videoTab) { +mirosubs.widget.DropDown = function(videoID, dropDownContents, videoTab) { goog.ui.Component.call(this); + this.videoID_ = videoID; this.setStats_(dropDownContents); this.videoTab_ = videoTab; this.subtitleState_ = null; @@ -150,7 +151,7 @@ mirosubs.widget.DropDown.prototype.createActionList_ = function($d) { }; mirosubs.widget.DropDown.prototype.createSubtitleHomepageURL_ = function() { - return [mirosubs.siteURL(), "/videos/", mirosubs.videoID].join(''); + return [mirosubs.siteURL(), "/videos/", this.videoID_].join(''); }; mirosubs.widget.DropDown.prototype.createDownloadSRTURL_ = function() { @@ -158,7 +159,7 @@ mirosubs.widget.DropDown.prototype.createDownloadSRTURL_ = function() { "/widget/download_", (mirosubs.IS_NULL ? "null_" : ""), "srt/?video_id=", - mirosubs.videoID].join(''); + this.videoID_].join(''); if (this.subtitleState_ && this.subtitleState_.LANGUAGE) url += ['&lang_code=', this.subtitleState_.LANGUAGE].join(''); return url; diff --git a/media/js/widget/playcontroller.js b/media/js/widget/playcontroller.js index 4e87a30a..98ffe0ca 100644 --- a/media/js/widget/playcontroller.js +++ b/media/js/widget/playcontroller.js @@ -23,9 +23,10 @@ goog.provide('mirosubs.widget.PlayController'); * */ mirosubs.widget.PlayController = function( - videoSource, videoPlayer, videoTab, dropDown, opt_subtitleState) + videoID, videoSource, videoPlayer, videoTab, dropDown, opt_subtitleState) { goog.Disposable.call(this); + this.videoID_ = videoID; this.videoSource_ = videoSource; this.videoPlayer_ = videoPlayer; this.videoTab_ = videoTab; @@ -110,7 +111,7 @@ mirosubs.widget.PlayController.prototype.languageSelected = function(languageCod this.videoTab_.showLoading(); mirosubs.Rpc.call( 'fetch_subtitles', - { 'video_id': mirosubs.videoID, + { 'video_id': this.videoID_, 'language_code': languageCode }, function(subStateJSON) { that.turnOffSubs(); diff --git a/media/js/widget/subtitle/msservermodel.js b/media/js/widget/subtitle/msservermodel.js index 9ac48358..a1b49cd4 100644 --- a/media/js/widget/subtitle/msservermodel.js +++ b/media/js/widget/subtitle/msservermodel.js @@ -32,9 +32,10 @@ goog.provide('mirosubs.subtitle.MSServerModel'); * @param {string} videoID MiroSubs videoid * @param {string=} language language code */ -mirosubs.subtitle.MSServerModel = function(videoID, language) { +mirosubs.subtitle.MSServerModel = function(videoID, videoURL, language) { goog.Disposable.call(this); this.videoID_ = videoID; + this.videoURL_ = videoURL; this.language_ = language; this.initialized_ = false; this.finished_ = false; @@ -157,8 +158,16 @@ mirosubs.subtitle.MSServerModel.prototype.makeSaveArgs_ = function() { }; mirosubs.subtitle.MSServerModel.prototype.getEmbedCode = function() { - return [mirosubs.subtitle.MSServerModel.EMBED_JS_URL, - "?video_id=", this.videoID_].join(''); + return [ + '\n', + '({\n', + ' video_url: "', this.videoURL_, '"\n', + '})\n', + ''].join(''); }; mirosubs.subtitle.MSServerModel.prototype.stopTimer_ = function() { diff --git a/media/js/widget/subtitle/sharepanel.js b/media/js/widget/subtitle/sharepanel.js index 29362a9b..ce35c708 100644 --- a/media/js/widget/subtitle/sharepanel.js +++ b/media/js/widget/subtitle/sharepanel.js @@ -61,7 +61,7 @@ mirosubs.subtitle.SharePanel.prototype.createShareList_ = function($d, $t) { mirosubs.subtitle.SharePanel.prototype.createEmbedSection_ = function($d, $t) { this.embedCodeInput_ = $d('input', {'type':'text'}); - var embedCode = mirosubs.embedCode(); + var embedCode = this.serverModel_.getEmbedCode(); this.embedCodeInput_['value'] = embedCode; var flashSpan = $d('span'); diff --git a/media/js/widget/subtitlecontroller.js b/media/js/widget/subtitlecontroller.js index 1a59e43d..e75d2a8a 100644 --- a/media/js/widget/subtitlecontroller.js +++ b/media/js/widget/subtitlecontroller.js @@ -22,8 +22,10 @@ goog.provide('mirosubs.widget.SubtitleController'); * @constructor */ mirosubs.widget.SubtitleController = function( - playController, videoTab, dropDown) + videoID, videoURL, playController, videoTab, dropDown) { + this.videoID_ = videoID; + this.videoURL_ = videoURL; this.videoTab_ = videoTab; this.dropDown_ = dropDown; this.playController_ = playController; @@ -112,7 +114,7 @@ mirosubs.widget.SubtitleController.prototype.possiblyRedirect_ = callback(); else { var uri = new goog.Uri(mirosubs.siteURL() + '/onsite_widget/'); - uri.setParameterValue('video_url', mirosubs.videoURL); + uri.setParameterValue('video_url', this.videoURL_); if (mirosubs.IS_NULL) uri.setParameterValue('null_widget', 'true'); if (addNewTranslation) @@ -160,7 +162,7 @@ mirosubs.widget.SubtitleController.prototype.startEditing_ = this.videoTab_.showLoading(); mirosubs.Rpc.call( 'start_editing', - {'video_id': mirosubs.videoID, + {'video_id': this.videoID_, 'language_code': subLanguageCode, 'original_language_code': originalLanguageCode, 'base_version_no': baseVersionNo, @@ -197,7 +199,8 @@ mirosubs.widget.SubtitleController.prototype.openSubtitlingDialog_ = var subDialog = new mirosubs.subtitle.Dialog( this.playController_.getVideoSource(), new mirosubs.subtitle.MSServerModel( - mirosubs.videoID, subtitleState.LANGUAGE), + this.videoID_, this.videoURL_, + subtitleState.LANGUAGE), subtitleState.SUBTITLES); subDialog.setVisible(true); this.handler_.listenOnce( @@ -210,6 +213,8 @@ mirosubs.widget.SubtitleController.prototype.openDependentTranslationDialog_ = { this.playController_.stopForDialog(); var transDialog = new mirosubs.translate.Dialog( + new mirosubs.subtitle.MSServerModel( + this.videoID_, this.videoURL_, subtitleState.LANGUAGE), this.playController_.getVideoSource(), subtitleState, originalSubtitleState); transDialog.setVisible(true); diff --git a/media/js/widget/translate/dialog.js b/media/js/widget/translate/dialog.js index 74bd0766..c8241298 100644 --- a/media/js/widget/translate/dialog.js +++ b/media/js/widget/translate/dialog.js @@ -22,15 +22,15 @@ goog.provide('mirosubs.translate.Dialog'); * @constructor * */ -mirosubs.translate.Dialog = function(videoSource, +mirosubs.translate.Dialog = function(serverModel, + videoSource, subtitleState, standardSubState) { mirosubs.Dialog.call(this, videoSource); this.subtitleState_ = subtitleState; this.standardSubState_ = standardSubState; this.unitOfWork_ = new mirosubs.UnitOfWork(); - this.serverModel_ = new mirosubs.subtitle.MSServerModel( - mirosubs.videoID, subtitleState.LANGUAGE); + this.serverModel_ = serverModel; this.serverModel_.init(this.unitOfWork_); this.saved_ = false; }; diff --git a/media/js/widget/widget.js b/media/js/widget/widget.js index db7f0187..566796f4 100644 --- a/media/js/widget/widget.js +++ b/media/js/widget/widget.js @@ -30,7 +30,6 @@ mirosubs.widget.Widget = function(widgetConfig) { */ this.videoURL_ = widgetConfig['video_url']; this.videoConfig_ = widgetConfig['video_config']; - mirosubs.videoURL = this.videoURL_; /** * If true, this is the equivalent of clicking on "Add subtitles" * if base state is null, or equivalent of clicking on "Improve @@ -104,6 +103,9 @@ mirosubs.widget.Widget.prototype.addWidget_ = function(el) { mirosubs.widget.Widget.prototype.initializeState_ = function(result) { this.makeGeneralSettings_(result); + + var videoID = result['video_id']; + if (result['flv_url'] && !this.videoSource_) this.setVideoSource_(new mirosubs.video.FlvVideoSource( result['flv_url'])); @@ -114,7 +116,7 @@ mirosubs.widget.Widget.prototype.initializeState_ = function(result) { result['subtitles']); var popupMenu = new mirosubs.widget.DropDown( - dropDownContents, this.videoTab_); + videoID, dropDownContents, this.videoTab_); this.videoTab_.showContent(popupMenu.hasSubtitles(), subtitleState); @@ -125,10 +127,11 @@ mirosubs.widget.Widget.prototype.initializeState_ = function(result) { popupMenu.setCurrentSubtitleState(subtitleState); this.playController_ = new mirosubs.widget.PlayController( - this.videoSource_, this.videoPlayer_, this.videoTab_, - popupMenu, subtitleState); + videoID, this.videoSource_, this.videoPlayer_, + this.videoTab_, popupMenu, subtitleState); this.subtitleController_ = new mirosubs.widget.SubtitleController( + videoID, this.videoURL_, this.playController_, this.videoTab_, popupMenu); if (this.subtitleImmediately_) @@ -144,7 +147,6 @@ mirosubs.widget.Widget.prototype.initializeState_ = function(result) { mirosubs.widget.Widget.prototype.makeGeneralSettings_ = function(result) { if (result['username']) mirosubs.currentUsername = result['username']; - mirosubs.videoID = result['video_id']; mirosubs.embedVersion = result['embed_version']; mirosubs.subtitle.MSServerModel.LOCK_EXPIRATION = result["writelock_expiration"];