Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
aduston committed Oct 13, 2010
1 parent d8861c8 commit d81d634
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 42 deletions.
21 changes: 0 additions & 21 deletions media/js/mirosubs.js
Expand Up @@ -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
Expand Down Expand Up @@ -99,19 +91,6 @@ mirosubs.languageNameForCode = function(code) {
return mirosubs.languageMap_[code];
};

mirosubs.embedCode = function() {
return [
'<sc',
'ript type="text/javascript" src="',
mirosubs.mediaURL(),
'embed', mirosubs.embedVersion, '.js',
'">\n',
'({\n',
' video_url: "', mirosubs.videoURL, '"\n',
'})\n',
'</script>'].join('');
};

/**
* Does not include trailing slash.
*/
Expand Down
7 changes: 4 additions & 3 deletions media/js/widget/dropdown.js
Expand Up @@ -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;
Expand Down Expand Up @@ -150,15 +151,15 @@ 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() {
var url = [mirosubs.siteURL(),
"/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;
Expand Down
5 changes: 3 additions & 2 deletions media/js/widget/playcontroller.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
15 changes: 12 additions & 3 deletions media/js/widget/subtitle/msservermodel.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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 [
'<sc',
'ript type="text/javascript" src="',
mirosubs.mediaURL(),
'embed', mirosubs.embedVersion, '.js',
'">\n',
'({\n',
' video_url: "', this.videoURL_, '"\n',
'})\n',
'</script>'].join('');
};

mirosubs.subtitle.MSServerModel.prototype.stopTimer_ = function() {
Expand Down
2 changes: 1 addition & 1 deletion media/js/widget/subtitle/sharepanel.js
Expand Up @@ -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');
Expand Down
13 changes: 9 additions & 4 deletions media/js/widget/subtitlecontroller.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions media/js/widget/translate/dialog.js
Expand Up @@ -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;
};
Expand Down
12 changes: 7 additions & 5 deletions media/js/widget/widget.js
Expand Up @@ -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
Expand Down Expand Up @@ -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']));
Expand All @@ -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);
Expand All @@ -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_)
Expand All @@ -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"];
Expand Down

0 comments on commit d81d634

Please sign in to comment.