var COMMONURL='/c/'; var VS_APIURL='//sarvs.tradeonly.com/'; /* this is the correct js file to edit but include vs.js.php */ if (typeof COMMONURL=='undefined' || COMMONURL=='') COMMONURL='/c/'; if (typeof VS_APIURL=='undefined' || VS_APIURL=='') VS_APIURL='//vs.tradeonly.com/'; var vsopenee=new Array(); var clipboard_open=false; jQuery(function($){ if (typeof include_css_once=="undefined"){ function include_css_once(fn){ if ($('head link[href="'+fn+'"]').length<1) $('head').append(''); } } $.vs_xdomaincheck=false; $.vstl=false; // page includes TL images $.vsapi='http:'+VS_APIURL; //vs.tradeonly.com/'; $.vsprod=$.vsapi+'view.prod/'; $.vslogo=$.vsapi+'view.logo/'; $.vslocal=COMMONURL+'vs/vs.php?'; $.vstlurl='http://vsi.tradeonly.com/OneClick.OneClick?fwid=##fwid##&accesskey=##accesskey##&clickpath=##clickpath##&ver=eodpro&width=##size##&height=##size##&fixed=true&trimThreshold=8'; //$.vstoken='7844.5036'; //$('head').append(''); include_css_once(COMMONURL+'vs/vs.css'); //$('head').append(''); include_css_once(COMMONURL+'themes/cloud/cloud_popdrops.css'); vs_init(); //vs_updateImages('vslogo'); }); if (typeof maxZ=="undefined"){ function maxZ(){ return Math.max.apply(null,$.map($('body > *'), function(e,n){ if ($(e).css('position')=='absolute') return parseInt($(e).css('z-index'))||1 ; }) ); } } function vs_refreshSelectors(){ $('.vs-selectlogo').each(function(){vs_init_selector($(this));}); } function vs_init_selector(el, options){ if (options==undefined) options=vs_getOptions(el); if (options.size==undefined) options.size=150; if (options.session==undefined) options.session=false; if (options.system==undefined) options.system='cloud'; var thisclass='vs-selectlogo-'+options.link; var url=COMMONURL+'vs/vs.php?link='+options.link+'&session='+options.session+'&system='+options.system+'&size='+options.size; if (options.access!=undefined) url+='&access='+options.access; if (options.classname!=undefined) url+='&classname='+options.classname; if (options.filter!=undefined) url+='&filter='+options.filter; el.addClass(thisclass).addClass('vs-selectlogo'); el.load(url,function(){ if (options.buttontext!=undefined) el.find('b:first').text(options.buttontext); //if (options.nostyle!=undefined) el.find('*').removeClass('button-vs').removeClass('button-vs-main'); vs_init('.'+thisclass); vs_filterInit(); $.vstoken=$('.vs-token:first').val(); }); el.css({cursor:'pointer'}).bind('click',function(){ // vs_openSelectLogo(options.link); }); } function vs_init(parent, forcerefresh){ $=jQuery; if (forcerefresh==undefined) forcerefresh=false; if (parent==undefined) parent=''; if (typeof(parent)=='string') var kids=$(parent+' *[class^="vs{"]'); else var kids=$(parent).find('*[class^="vs{"]'); var img=0; kids.each(function(i){ /* *** SETUP ONLY This is for making elements ready for vs_doSelectLogo() which is called onchange of logo vs_doSelectLogo(). All actions are to go in that vs_doSelectLogo(). *** */ var el=$(this); var options=vs_getOptions(el); if (options.link!=undefined) { // check more more than one link because // me:img and me:tlimg can be affected by more than one link. if (options.link.indexOf('/')) options.links=options.link.split('/'); else options.links=options.link; var addclass='js_vslink-'+options.link; if (!$(this).is('.'+addclass) && !forcerefresh) // only do once { el.addClass(addclass); if (options.me!=undefined) { switch (options.me) { case 'selectlogo': vs_init_selector(el, options); break; case 'opener': // , '.popdrop-labels' can't be VS drop down opener buttons. what is this to fix? $(this, '.popdrop-labels').addClass('js_vsopener-'+options.link).bind('click',function(e, e_passed){ if (e_passed) e=e_passed; // event has been passed from another function triggering click vs_dropDown(options.link, 0, e); }).bind('mouseleave',function(){ $('.js_vsopenee-'+options.link).removeClass('js_vsisopen'); vs_dropUp(options.link); }); //.bind('mouseenter',function(e){ // vs_dropDown(options.link,1000,e); //}) break; case 'openee': // , '.popdrop-labels' can't also be VS drop down divs. what is this to fix? $(this, '.popdrop-labels').addClass('js_vsopenee-'+options.link).bind('mouseenter',function(){ $(this).addClass('js_vsisopen'); }).bind('mouseleave',function(){ $(this).removeClass('js_vsisopen'); vs_dropUp(options.link); // #column-wide, #topbar, #search_re etc ect - can't be this specific. i asked why this was here, no response. removed until i see the bug in mantis // if ($.browser.msie) // { // // $("#column-wide, #topbar, #search_results_list, .boxwrapper, #edit-view, #design-view").bind('mouseenter',function(){ // vs_dropUp(options.link); // }); // } // else // { // vs_dropUp(options.link); // } }); /* splice this div from here and append to body - some CSS styles were conflicting when left inline */ $(this).appendTo('body'); break; case 'clearlogo': el.addClass('vs-clearlogo'); el.css({cursor:'pointer'}).bind('click',function(e){ e.preventDefault(); vs_dropUp(options.link, true); vs_doSelectLogo(options.link, 0, options.session); }); break; case 'img': for (i in options.links) el.addClass('js_vsimg-'+options.links[i]); /* if (options.size!=undefined) { var thiscss={width:options.size+'px', height:options.size+'px'}; el.css(thiscss); el.find('img').css(thiscss); } else */ if (el.find('img').length>0) { el.css({width:el.find('img').width()+'px', height:el.find('img').height()+'px'}); } break; case 'tlimg': for (i in options.links) el.addClass('js_vstl').addClass('js_vstlimg-'+options.links[i]).addClass('nigelogo_'+options.tl); /* if (options.size!=undefined) { var thiscss={width:options.size+'px', height:options.size+'px'}; el.css(thiscss); el.find('img').css(thiscss); } else */ if (el.find('img').length>0) el.css({width:el.find('img').width()+'px', height:el.find('img').height()+'px'}); $.vstl=true; break; case 'showlogo': el.addClass('js_vsshowlogo-'+options.link); // make sure it has a size and an img. // options.size needs to be an integer, and when writing our HTML needs 'px' appended if (options.size==undefined) { options.size=parseInt(el.height()); if (options.size==undefined || options.size==0) { options.size=el.find('img').height(); } } if (el.find('img').length>0) { el.find('img').css({width:options.size+'px', height:options.size+'px'}); } else if (typeof options.logoref!=undefined && options.logoref!=undefined && options.logoref!='undefined') { el.html(''); } else { el.html(''); } el.find('img').data('height',options.size); // if the vs space doesn't have a default logoref set, use the one from the input field if (typeof options.logoref==undefined && $('.js_vslogoref-'+options.link).length && $('input[name=logoref].js_vslink-'+options.link+':first').val()!=0) { var src=$.vslogo+$('.js_vslogoref-'+options.link).val()+ '!fit='+ options.size+'.png'; el.find('img').attr("src", src); el.find('img').show(); } break; case 'logoref': $(this).addClass('js_vslogoref-'+options.link); break; case 'updater': el.addClass('js_vsupdater-'+options.link); break; case 'debug': el.addClass('js_vsdebug-'+options.link); break; case 'setlogo': el.bind('click',function(e){ e.preventDefault(); vs_dropUp(options.link, true); vs_doSelectLogo(options.link, options.logoref, options.session); }); break; case 'uploader': el.addClass('vs-uploader'); el.css({cursor:'pointer'}).bind('click',function(e){ e.preventDefault(); vs_openManageLogos(el,options); }); break; } } } } // elements that may or may not require options.link if (options.me!=undefined) { switch (options.me) { case 'managelogos': el.addClass('vs-managelogos'); el.css({cursor:'pointer'}).bind('click',function(e){ e.preventDefault(); vs_openManageLogos(el,options); }); break; } } }); $('.js_vstl, .js_vsimg').css({background:'url('+$.vsapi+'vs-loading.gif) no-repeat center', display:'block'}); } function vs_filterInit() { $('.popdrop-labels').unbind('change').bind('change',function(){ var filter=$(this).parents('.popdrop-pop').find('.popdrop-filter'); if ($(this).val()=='') filter.val(''); else filter.val('label:'+$(this).val()); vs_filterDo($(this).parents('.popdrop-pop')); }); $('.popdrop-filter').unbind('keyup').bind('keyup',function(){ vs_filterDo($(this).parents('.popdrop-pop')); $('.popdrop-labels option').attr('selected',''); }); $('.popdrop-clearfilter').unbind('click').bind('click',function(e){ e.preventDefault(); $('.popdrop-labels option').attr('selected',''); var popdrop=$(this).parents('.popdrop-pop'); popdrop.find('.popdrop-filter').val(''); vs_filterDo($(this).parents('.popdrop-pop')); }); $('.popdrop-pop').each(function(){vs_filterDo($(this));}); // doesn't matter if this does some more than once } function vs_filterDo(popdrop) { popdrop.find('.popdrop-list li').show(); var s=popdrop.find('.popdrop-filter').val().toLowerCase(); popdrop.find('.popdrop-list li').show().each(function(){ if ($(this).attr('class').toLowerCase().indexOf(s)<0) $(this).hide(); }); var filter=popdrop.find('.popdrop-filter').val(); if (filter!='') { if (filter.match(/label:/g)) s='label "'+filter.replace('label:','')+'"'; else s='"'+filter+'"'; if (popdrop.find('.popdrop-list li:visible').length>0) { s='Logos matching '+s; } else { s='No logos match '+s+'. Clear search filter or upload a logo'; } } else s='Showing all logos'; popdrop.find('.popdrop-resultstext').html(s); //var attrclass=popdrop.find('.vs-managelogos').attr('class').replace(/fil/,s); } function vs_getOptions(el) { var options=$.extend(); var classes=el.attr('class'); if (classes!=undefined) { // regex may be unescaping the string so try this method //regexp=new RegExp(/vs\{(.*?)\}/gi) //if (m=regexp.exec(classes)) //{ // optslist=m[1]; var optslist=classes.split('{')[1].split('}')[0]; if (optslist!=undefined) { cs=optslist.replace('+','').replace(' ','').split(','); // remove things that break it for (i in cs) { var b=$.trim(cs[i]).split(':'); eval ("options=$.extend(options, {'"+b[0]+"':'"+b[1]+"'});"); // eval ("options."+b[0]+"='"+b[1]+"'"); } } } return options; } function vs_doSelectLogo(link, logoref, session) { if (typeof logoref==undefined || logoref=='undefined') return; if ($.vstl) imgBondImages(logoref,link); vs_bondImages(link, logoref); // update $_SESSION var url=$.vslocal+'go=setlogo&session='+session+'&logoref='+logoref; $.get(url); //$('').appendTo('body'); // show logo $('.js_vsshowlogo-'+link+' img').each(function(){ if (logoref==0) { $(this).hide(); } else { if ($(this).height()!=undefined && $(this).height()!=0) h=$(this).height(); else if ($(this).data('height')!=undefined) h=$(this).data('height'); else h=300; var src=$.vslogo+logoref+ '!fit='+ h +'.png'; $(this).attr("src", src); $(this).show(); } }); // update any input fields that expect to be $('input.js_vslogoref-'+link+', form.js_vsupdater-'+link+' input[name=logoref]').val(logoref).trigger('change'); if(typeof $().ajaxSubmit == 'function') $('form.js_vsupdater-'+link).ajaxSubmit(); if ($.clipboard_exists!=undefined && $.clipboard_exists==true) clipboard_load(); } function vs_openSelectLogo(link) { /* pops open select logo window, telling the selection which vslink to action on */ var selector='.js_vslink-'+link; } function vs_clearLogo(link) { /* pops open select logo window, telling the selection which vslink to action on */ var selector='.js_vslink-'+link; } function vs_openManageLogos(el,options) { /* pops open select logo window, telling the selection which vslink to action on */ // sometimes only the upload option is wanted, but it takes a bit of work because this is xdomain if (options.me=='uploader') { var url=$.vsapi+'?token='+$.vstoken+'&go=logo.uploadform&func=options&me=uploader&link='+options.link; if (options.session!=undefined) url+='&session='+options.session; $.vs_xdomaincheck=true; vs_checkXdomain(options,1000); } else var url=$.vsapi+'?token='+$.vstoken+'&go=logo.many&func=options'; var filter=el.parents('.popdrop-pop').find('.popdrop-filter').val(); if (filter!=undefined) url+='&filter='+filter; $('