Mini Kabibi Habibi
(function($, undefined) {
window.VideoPortal = {
historyStatePopped: ('state' in window.history),
initialURL: location.href,
initialize: function() {
if(!VideoPortal.isHistoryAPIAvailable())
return;
VideoPortal.initializeHyperlinks();
$(window).bind('popstate', function(evt) {
var initialStatePop = !VideoPortal.historyStatePopped && location.href == VideoPortal.initialURL;
VideoPortal.historyStatePopped = true;
if(!initialStatePop) {
theForm.action = evt.originalEvent.state;
cpView.PerformCallback();
}
});
},
initializeHyperlinks: function() {
var controlCollection = ASPxClientControl.GetControlCollection();
controlCollection.ControlsInitialized.AddHandler(function() {
$('a').each(function() {
if(this.href !== "")
$(this).attr('href', this.href);
});
$('img').each(function() {
$(this).attr('src', this.src);
});
if(window['commentEditor'])
commentEditor.AdjustControl();
});
},
isHistoryAPIAvailable: function() {
return history.pushState !== undefined;
},
inCallback: function() {
var callbackPanels = ['cpView', 'cpVideoRelated', 'cpComments', 'cpVideos'];
for(var i = 0; i < callbackPanels.length; i++) {
if(window[callbackPanels[i]] && window[callbackPanels[i]].InCallback())
return true;
}
return false;
},
onHyperLinkClick: function(evt, callbackPanel) {
if(!VideoPortal.isHistoryAPIAvailable() || $.browser.opera)
return;
ASPxClientUtils.PreventEvent(evt);
if(VideoPortal.inCallback())
return;
var link = $(evt.target).is('a') ? evt.target : $(evt.target).parents('a').get(0);
theForm.action = link.href;
history.pushState(link.href, '', link.href);
callbackPanel.PerformCallback();
$('body,html').animate({ scrollTop: 0 }, 600);
},
onTagCloudItemClick: function(s, e) {
VideoPortal.onHyperLinkClick(e.htmlEvent, cpVideos);
},
onHlToAllVideosClick: function(s, e) {
VideoPortal.onHyperLinkClick(e.htmlEvent, cpView);
},
onHlVideoClick: function(htmlEvent) {
VideoPortal.onHyperLinkClick(htmlEvent, cpView);
},
onHlRelatedVideoClick: function(htmlEvent) {
commentEditor.SetHtml('');
VideoPortal.onHlVideoClick(htmlEvent);
},
onHlVideoTagClick: function(s, e) {
VideoPortal.onHyperLinkClick(e.htmlEvent, cpView);
},
onTcVideoClick: function(s, e) {
if(tcVideo.GetActiveTabIndex() === e.tab.index || VideoPortal.inCallback()) {
e.cancel = true;
ASPxClientUtils.PreventEvent(e.htmlEvent);
return;
}
VideoPortal.onHyperLinkClick(e.htmlEvent, cpVideoRelated);
},
showToAllVideosButton: function() {
hlToAllVideos.SetVisible(true);
},
hideToAllVideosButton: function() {
hlToAllVideos.SetVisible(false);
},
onBtnPostCommentClick: function(s, e) {
var text = $.trim($('<div>')
.html(commentEditor.GetHtml())
.text());
cpComments.PerformCallback(text);
},
onVideoPanelInit: function(s, e) {
VideoPortal.showToAllVideosButton();
var userAgent = navigator.userAgent.toLowerCase();
if(userAgent.match(/(iphone|ipod|ipad)/))
return;
var hasPlayer = false;
try {
hasPlayer = !!(new ActiveXObject('ShockwaveFlash.ShockwaveFlash'));
} catch(e) {
hasPlayer = !!(navigator.mimeTypes["application/x-shockwave-flash"]);
}
if(!hasPlayer)
$("#getPlayerPanel").show();
}
};
} (jQuery));