// included in ../mtvn.jhtml // depends on community_flux.jhtml // Flux Widget Proxy for MTVN // MTVN.Flux.Widgets = new function(){ // you can turn off widgets globally by setting this to false or // on locally by calling MTVN.Flux.Widgets.enabled = false; this.enabled = true; this.create=function(name, options){ if (!(Flux && typeof Flux.createWidget == "function") || !this.enabled) { return; } options = this.getOptionsByName(name, options); var widgetName = this.getWidgetNameByName(name); Flux.createWidget(widgetName, options); } this.loadAllAttempted = false; this.loadAll=function() { if (!MTVN.Flux.Widgets.loadAllAttempted) { $j(".fluxWidget:not(.delay-load)").each( function() { MTVN.Flux.Widgets.loadEach(this); }); MTVN.Flux.Widgets.loadAllAttempted = true; } } this.loadEach = function(el) { try{ var jsonText = ""; var code = $j(el).find("code"); if (code.get(0).firstChild && code.get(0).firstChild.nodeType == 8) { jsonText = code.get(0).firstChild.nodeValue; } if (jsonText.length > 0 && ($j(el).parent().attr("id").indexOf("scriptPopupWidget_") == -1 || $j("#playerContainer").is("*") || el.toString().indexOf("#ModuleVideoList_") > -1)) { var obj = eval("(" + jsonText + ")"); $j(el).empty().removeClass("hide"); if (typeof(MTV) != "undefined" && typeof(MTV.Flux) != "undefined" && typeof(MTV.Flux.ucid) != "undefined") { if (!(MTV.Flux.ucid == "0ABEFFFF01F364840002FFFFBE0A" && obj.args.containerId == "wQuickMenu")) if (!(MTV.Flux.ucid == "D3FCFFFF0002D51D0002FFFFFCD3" && obj.args.containerId == "wQuickMenu2")) MTVN.Flux.Widgets.create(obj.widget, obj.args); } else MTVN.Flux.Widgets.create(obj.widget, obj.args); } }catch(e){} } // set default options based on the name parameter // passed to the create method this.getOptionsByName=function(name, options) { switch(name) { case 'Share2' : var opts = {}; opts.elements = [ { id: 'Facebook', placeholder: 'service1Element'}, { id: 'Twitter', placeholder: 'service2Element'}, { id: 'StumbleUpon', placeholder: 'service3Element'}, { id: 'More', placeholder: 'moreElement'} ]; opts.overlayElements = [ { id: 'FeedTab', visible: false }, { id: 'GroupsTab', visible: false}, { id: 'OtherTab', visible: true, elements: [ { id: 'Facebook', visible: true }, { id: 'Twitter', visible: true }, { id: 'StumbleUpon', visible: true }, { id: 'Digg', visible: true }, { id: 'MySpace', visible: true }, { id: 'Blogger', visible: true }, { id: 'GoogleBuzz', visible: true }, { id: 'Yahoo', visible: true }, { id: 'Orkut', visible: true }, { id: 'Hyves', visible: true } ] } ]; return $j.extend(opts, options); break; case 'Share' : var opts = {} opts.size = 'small'; opts.items = [ { id: 'share', title: 'Share' }, { id: 'addToFavorites', title: 'Favorite' } ]; return $j.extend(opts, options); break; case 'Rate' : var opts = {}; opts.size = 'small'; var ratings_title = 'Rate this'; if (options['ratings_title'] != null){ ratings_title = ratings_title + ' ' + options['ratings_title']; } opts.items = [ { id: 'rate', title: ratings_title } ]; return $j.extend(opts, options); break; case 'Statistics' : var opts = {} opts.size = 'small'; if ( options.hide_titles ) { opts.items = [ { id: 'viewCount', title: '' }, { id: 'commentCount', title: ''}, { id: 'contentRating', title: { thumbsUpTitle: '', thumbsDownTitle: '' }} ]; } else { opts.items = [ { id: 'viewCount', title: 'Views' }, { id: 'commentCount', title: 'Comments'}, { id: 'contentRating', title: { thumbsUpTitle: 'Rating', thumbsDownTitle: 'Rating' }} ]; } if (!options.hide_ratings) { var ratings_title = options.hide_titles ? '' : 'Rate ' + options['ratings_title']; options['ratings_title'] = null; options['hide_ratings'] = null; opts.items.push({ id: 'rate', title: ratings_title }); } return $j.extend(opts, options); break; case 'Usage' : var opts = {}; opts.layout = 'horizontal'; opts.size = 'small'; opts.items = [ { id: 'commentCount', title: 'comments' }, { id: 'contentRating', title: { thumbsUpTitle: 'Rating', thumbsDownTitle: 'Rating' }} ]; return $j.extend(opts, options); break; case 'Rating' : var opts = {}; opts.layout = 'horizontal'; opts.size = 'small'; opts.items = [ { id: 'commentCount', title: 'Comments' }, { id: 'contentRating', title: { thumbsUpTitle: 'Rating', thumbsDownTitle: 'Rating' }}, { id: 'rate' }, { id: 'share', title: 'Share' }, { id: 'addToFavorites', title: 'Favorite' } ]; return $j.extend(opts, options); break; case 'QuickMenu' : var opts = {}; opts.showFBConnectButton = true; return $j.extend(opts, options); break; default : return options; break; } } this.getWidgetNameByName=function(name) { switch(name) { case 'Rating' : case 'Rate' : case 'Usage' : case 'Statistics' : case 'Share' : return 'ContentAction'; break; case 'Share2' : return 'Share'; break; default : return name; break; } } }; MTVN.Flux.widgetDelayLoad = function(arg) { if ((typeof(MTV) == "undefined" || typeof(MTV.Flux) == "undefined") || typeof(MTV.Flux.ucid) == "undefined" || arg == "load") { $j('.fluxWidget.delay-load').each(function(){ var widget = $j(this); MTVN.UI.InView.register(widget, function() { MTVN.Flux.Widgets.loadEach(widget); }); }); } } if (typeof(excludefluxWidgetLoadCall) == "undefined") $j(MTVN.Flux.widgetDelayLoad);