(function() {
CmmAppVideoApi.DecorationTypes = {
Credit: {
height : 18,
getHtml : function(){
var html = [];
var credits = yq.trim(this.player.video.credits);
if (credits.length) {
html.push('
'+CmmAppVideoApi._htmlescape(credits)+'
');
};
return html.join('');
}
},
Default: {
height : 18,
getHtml : function(){return 'default decoration'}
}
};
CmmAppVideoApi.ContentTypes = {
FacebookButton : function(){
this.name = 'FacebookButton';
this.width = 92;
this.height = 30;
this.buttonSrc = '/images/fb_button.png';
this.buttonOverSrc = '/images/fb_button_over.png';
this.pinDuration = 23700;
switch (this.player.type) {
case 'LightBoxArticlePlayer':
this.top = 20;
this.right = 20;
break;
default:
this.top = 20;
this.left = 20;
}
this.getHtml = function(){
this.initialized = false;
var html = [];
html.push('');
html.push('
');
html.push('');
return this._super.getHtml.call(this, html.join(''));
};
this.init = function(){
var _this = this;
this._super.init.call(this);
if(!this.initialized){
this.contentDomElement.find('img').hover(
function(){
yq(this).attr('src', _this.buttonOverSrc);
},
function(){
yq(this).attr('src', _this.buttonSrc);
}
);
this.initialized = true;
};
};
this.show = function(reload){
this._super.show.call(this);
if(reload){
var _this = this;
this.pin(function(){
_this.hide();
});
};
};
this.update = function(){
this.contentDomElement.find('a').attr('href',
CmmAppVideoApi.CONST.FacebookSharingUrl.replace('MYURL', encodeURI(this.player.video.facebookPagePath))
);
};
},
Splash : function(){
this.name = 'Splash';
this.top = 0;
this.left = 0;
this.width = "100%";
this.height = "100%";
this.pinDuration = 3700;
this.splashSrc = "'/images/ynet_video_buffering_splash.swf'";
this.show = function(){
var html = new Array();
html.push("");
this.contentDomElement.html(html.join('')).show();
};
this.init = function(){
this._super.init.call(this);
this.enabled = false;
};
this.onBeforeBegin = function(arg){
var _this = this;
if (!this.player.hiroLoaded || this.enabled){
this.show();
this.pin(function(){
//_this.player.contentManager.fireEvent('onClipStart');
_this.hide(true);
_this.resumeClip();
setTimeout(function(){
_this.resumeClip();
}, 200);
});
} else {
this.enabled = true;
};
};
this.onCuepoint = function(cuepoint){
if(cuepoint == 0 && this.pinned){
this.pauseClip();
};
};
this.pauseClip = function(){
var playButton = this.player.flowplayer.getPlugin('play');
if (playButton) {
playButton.css({opacity : 0});
};
this.player.flowplayer.pause();
};
this.resumeClip = function(){
if (this.player.visible()) {
var playButton = this.player.flowplayer.getPlugin('play');
this.player.flowplayer.resume();
if (playButton) {
playButton.css({opacity : 1});
};
};
};
this.onClipStart = function(){};
this.onClipFinish = function(){};
this.onPlayerMouseOver = function(){};
this.onPlayerMouseOut = function(){};
this.onPlayerFullscreen = function(){};
this.onDecorationMouseEnter = function(){};
this.onDecorationMouseLeave = function(){};
this.explorerFix = function(){};
},
Decoration : function(){
for (var decorationType in CmmAppVideoApi.DecorationConfig) {
var decoration = CmmAppVideoApi.DecorationConfig[decorationType];
if (!decoration.players || decoration.players.indexOf(this.player.type) >=0) {
if (!decoration.sites || decoration.sites.indexOf(CmmAppVideoApi.CONST.siteName) >= 0) {
this.decoration = CmmAppVideoApi.DecorationTypes[decorationType];
break;
};
};
};
if (!this.decoration) {this.decoration = CmmAppVideoApi.DecorationTypes.Default;};
this.name = 'Decoration';
this.height = this.decoration.height;
this.left = 0;
this.width = "100%";
this.pinDuration = 23700;
this.init = function(){
this.top = this.player.height - this.height - 26;
this._super.init.call(this);
};
this.getHtml = function(){
var html = [];
html.push('');
html.push('
');
html.push('
');
html.push('
');
html.push('
');
return this._super.getHtml.call(this, html.join(''));
};
this.update = function() {
var decorationHtml = this.decoration.getHtml.call(this);
if (decorationHtml.length) {
this.contentDomElement.find('.content_decoration_html').html(decorationHtml);
} else {
this.enabled = false;
};
};
this.show = function(reload) {
this._super.show.call(this);
if(reload){
var _this = this;
this.pin(function(){
_this.hide();
});
};
};
}
};
CmmAppVideoApi.Content = function(type, player){
this._super = CmmAppVideoApi.Content.prototype;
this.player = player;
this.superInitialized = false;
this.initialized = false;
this.enabled = false;
this.pinned = false;
this.suspended = false;
this.containerId = 'fpContent_' + type + player.id;
this.contentDomElement = null;
var instance = null;
try{
var content = CmmAppVideoApi.ContentTypes[type];
content.prototype = this;
instance = new content();
} catch(e){}
return instance;
};
CmmAppVideoApi.Content.prototype = {
getName : function(){
return this.name;
},
getHtml : function(content){
this.superInitialized = false;
var html = [];
html.push(''+(content?content:'')+'
');
return html.join('');
},
init : function(){
if (!this.superInitialized) {
this.contentDomElement = yq('#'+this.containerId);
this.contentDomElement.css({
display: 'none',
position: 'absolute',
top: this.top,
right: this.right,
bottom: this.bottom,
left: this.left,
width: this.width,
height: this.height,
overflow: 'hidden'
});
this.contentDomElement.find('img').css({
border: 'none'
});
this.explorerFix();
this.superInitialized = true;
};
this.enabled = true;
this.pinned = false;
this.suspended = false;
if (this.update) {this.update()};
},
hide : function(force){
if(force || (this.enabled && !this.suspended && !this.player.mouseInPlayer)){
this.contentDomElement.hide();
};
},
show : function(force){
if(force || (this.enabled && !this.suspended)){
this.contentDomElement.show();
};
},
pin : function(onTimeout){
var _this = this;
if(this.timeoutId){clearTimeout(this.timeoutId)};
this.timeoutId = setTimeout(function(){
_this.enabled = true;
_this.pinned = false;
onTimeout();
}, this.pinDuration);
this.enabled = false;
this.pinned = true;
},
suspend : function(){
this.suspended = true;
},
resume : function(){
this.suspended = false;
},
explorerFix : function(){
if(document.all){
var _this = this;
this.contentDomElement.unbind('mouseenter').bind('mouseenter',function(){
_this.player.contentManager.all('suspend');
_this.player.decorationEnabled = false;
}).unbind('mouseleave').bind('mouseleave',function(){
_this.player.contentManager.all('resume');
_this.player.contentManager.fireEvent('onPlayerMouseOut');
_this.player.decorationEnabled = true;
});
};
},
onBeforePlayerLoad : function(){
if(this.superInitialized){
this.hide(true);
};
},
onPlayerLoad : function(){
this.init();
},
onClipStart : function(){
this.show(true);
},
onClipFinish : function(){
this.hide(true);
},
onPlayerMouseOver : function(){
this.show();
},
onPlayerMouseOut : function(){
this.hide();
},
onPlayerFullscreen : function(){
if(!this.pinned){
this.hide(true);
};
},
onDecorationMouseEnter : function(){
this.enabled = false;
},
onDecorationMouseLeave : function(){
if(!this.pinned){
this.enabled = true;
this.hide();
};
}
}
CmmAppVideoApi.ContentManager = function(player){
this.pool = [];
this.add = function(content){
if (content) {
this.pool.push(content);
};
};
this.fireEvent = function(name, arg){
var res = true;
for(var i = 0; i < this.pool.length; i++){
try {
var tmpRes = this.pool[i][name](arg);
if (tmpRes != undefined) {
res = res && tmpRes;
}
}
catch(e){}
};
return res;
};
this.getHtml = function(){
var html = [];
for(var i = 0; i < this.pool.length; i++){
html.push(this.pool[i].getHtml());
};
return html.join('');
};
this.getContent = function(name){
for(var i = 0; i < this.pool.length; i++){
if (this.pool[i].getName() == name){
return this.pool[i];
};
};
return null;
};
this.all = function(command) {
for(var i = 0; i < this.pool.length; i++){
this.pool[i][command]();
};
};
for (var contentType in CmmAppVideoApi.ContentConfig) {
var content = CmmAppVideoApi.ContentConfig[contentType];
if (!content.players || content.players.indexOf(player.type) >=0) {
if (!content.sites || content.sites.indexOf(CmmAppVideoApi.CONST.siteName) >= 0) {
if (contentType == 'Splash' && ( CmmAppVideoApi.CONST.noSplash || player.params.noSplash)) {continue};
this.add(new CmmAppVideoApi.Content(contentType, player));
}
}
}
};
CmmAppVideoApi.ContentConfig = {
Decoration : {
players : ['HomepagePlayer', 'LightBoxArticlePlayer']
},
FacebookButton : {
players : ['VideoChannel', 'LightBoxArticlePlayer']
},
Splash : {
sites : ['ynet']
}
};
CmmAppVideoApi.DecorationConfig = {
Credit : {
players : ['HomepagePlayer', 'LightBoxArticlePlayer']
}
};
})();