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; $('
 
').appendTo('body').css({opacity:0.7,height:document.height+'px'}); $('').appendTo('body'); var top=$(document).scrollTop()+($(window).height()*0.5)-($('#vs-managewrap').height()*0.5)-20; $('#vs-managewrap').css({top:top+'px',zIndex:maxZ()+1000}).show(); $('#vs-manageclose').bind('click',function(e){e.preventDefault(); vs_manageClose()}); } function vs_manageClose() { $('#vs-managewrap').remove(); $('#vs-obscure').remove(); vs_refreshSelectors(); $.vs_xdomaincheck=false; } function vs_checkXdomain(options, delay) { if (options.session==undefined) options.session=''; $.get($.vslocal+'go=logo.xdomain&token='+$.vstoken+'',function(data){ d=data.split('|'); if (d[0]=='t') { //console(d[1].replace('##link##',options.link)); eval(d[1].replace('##link##',options.link).replace('##session##',options.session)); vs_manageClose(); } else if($.vs_xdomaincheck) setTimeout(function(){vs_checkXdomain(options,delay*1.5)},delay); // lengthen delay each time }); } function vs_bondImages(link, vsref) { $('.js_vsdebug-'+link).html(''); var selector='.js_vsimg-'+link; $(selector).each(function(){ var el=$(this); var src=$(this).find('img').attr('src'); var newsrc=vs_brandSrc(src, vsref); if (src!=newsrc) { el.css('opacity',0.5); // background by now is a loading gif var id='js_vsimg-' + vsref + (Math.random()*999999); el.find('img').attr('src',$.vsapi+'vs-loading.gif'); $('').attr('src',newsrc).load(function(){ el.find('img').attr('src',newsrc).show(); $('.js_vsdebug-'+link).html(''); el.css('opacity',1); }) } }); } function vs_dropUp(link, force) { if (force!=undefined && force) { $('.js_vsopenee-'+link).slideUp(200); } else { setTimeout(function(){ if (!$('.js_vsopenee-'+link).is('.js_vsisopen')) $('.js_vsopenee-'+link).slideUp(300); },300); } } function vs_dropDown(link, wait, e){ if (wait==undefined) wait=0; if (true){ $('img.vs-oninit').each(function(){ if ($(this).attr('rel')!='') $(this).attr({src:$(this).attr('rel'), rel:''}).removeClass('vs-oninit'); }); var button=$('.js_vsopener-'+link); var popdrop=$('.js_vsopenee-'+link); popdrop.addClass('js_vsisopen'); setTimeout(function(){ var popwidth=popdrop.width(); var popheight=popdrop.height(); var left=e.pageX-(popwidth/2); if (button.position().top>0){ /*var top=button.position().top+button.height()-7; } else //This was taken out for Mantis Ticket #2932 BrianG { // struggling to get location of button so using mousepos */var top=e.pageY-(popheight/3); } if (top<50) top=50; // avoid top menu // don't fall off left if (left<10) left=10; // dont' fall off right var windoww=$(window).width(); if (left+popwidth>windoww) left=windoww-popwidth-20; popdrop.css({position:'absolute', top:top+'px', left:left+'px', zIndex:maxZ()+100}); // auto position //var top=button.position().top+button.height()-7; //var left=button.position().left+button.width()-popdrop.width()+10; // var modal=popdrop.parents('div:last'); //if (left<0) left=5; //popdrop.css({position:'absolute', top:top+'px', left:left+'px'}); //$('*').css('z-index',1); if ($('.js_vsopenee-'+link).is('.js_vsisopen')) popdrop.show(0).css({zIndex:maxZ()+100}); },wait); } } function vs_brandSrc(src, vsref) { var newsrc=src.split('.'); var ext=newsrc.pop(); newsrc=newsrc.join('.'); regexp=new RegExp(/!b\=\((.*)\)/gi); if (m=regexp.exec(newsrc)) { newsrc=newsrc.replace(m[0],'');//,'b=('+vsref+')'); } if (vsref!=0) newsrc+='!b=('+vsref+')'; newsrc+='.'+ext; return newsrc; /* bits=src.split('/').pop().split('.'); var newsrc=bits[0] + '.' + bits[1] + '.' ; var actions=bits[2].split('!'); newactions=new Array(); for (i in actions) { pair=actions[i].split('='); if (pair[0]=='b') continue; // remove current branding newactions[i]=actions[i]; } newsrc+=newactions.join('!'); */ return $.vsprod + newsrc + '!b=(' + vsref + ').' + bits.pop(); } function vs_bondSrc(watermark, ref, size, logo) { return $.vsprocess + watermark + '.' + ref + '.s=' + size + '!b=' + logo + '.jpg'; } function vs_imageBonding(el,bool) { if (bool) { el.append('
Branding...
'); } else { el.find('.vsloading').remove(); } } /* old method */ function imgBondImages(logo_id,link,func){ /* repost the logo change all images */ //logo_id=logo_id.replace(/[^a-zA-Z0-9]/g,''); if (logo_id!=''){ //popMsg('Branding images... Some product images may take a few seconds to refresh after this message disappears.',true); $('.js_vstlimg-'+link+' img').css('opacity',0.5); var pos=$('.js_vstl:first').position(); $('body').append('
Processing logo...
'); $.get(COMMONURL+'vs/uploadtotl.php?r='+escape(logo_id),function(d){ $('#vstl-uploading').remove(); if (func=='session') $.get('ajax.php?go=misc&do=bondlogo&bondlogo='+logo_id+'&bondlogoref='+d); $('.js_vstlimg-'+link).each(function(){ imgBondImage($(this),d); }); }); }else{ if (func=='session') $.get('ajax.php?go=misc&do=bondlogo&bondlogo=0&bondlogoref=0'); $('.js_vstlimg-'+link).each(function(){ imgBondImage($(this),0); }); } } function imgBondImage(el,d){ var elimg=el.find('img'); var classes=el.attr('class').split(' '); var size; for (i=0; i').attr('src',src).load(function(){ elimg.attr('src',src).css({opacity:1}); }); } if (window['loadFirebugConsole']) { window.loadFirebugConsole(); } else { if (!window['console']) { window.console = function(){}; window.console.info = function(){}; window.console.log = function(){}; window.console.warn = function(){}; window.console.error = function(){}; } } /* jQuery(function($){ $.vs3d.start({ imagePrefix:'http://vs.tradeonly.com/_vs.1.02/templates/images/3d-demo-' ,imageRange:12 ,imageSuffix:'.jpg' ,target:$('#vs3d') }); }); */ $.extend({ vs3d:{ settings:{ wait:300 } , playing:false , images:new Array() , cache:new Array() , start:function(options){ for (i=1; i<=options.imageRange; i++) { j=('0'+String(i)).substr(-2); var src=options.imagePrefix+j+options.imageSuffix; this.images.push(src); this.preloadImages(src); } this.target=options.target; this.target.find('.vs3d-playpause').bind('click',function(){ if ($.vs3d.playing) $.vs3d.pause(); else $.vs3d.play(); return false; }).end().find('.vs3d-prev').bind('click',function(){ $.vs3d.prev(); }).end().find('.vs3d-next').bind('click',function(){ $.vs3d.next(); }); this.amount=i; this.at=-1; this.play(); } , play:function(){ if (true)//!this.playing) { clearTimeout(this.timer); this.playing=true; this.target.find('.vs3d-playpause').removeClass('vs3d-paused').addClass('vs3d-playing'); this.at++; this.show(); this.timer=setTimeout(function(){ $.vs3d.play(); },this.settings.wait); } } , pause:function(){ this.playing=false; this.target.find('.vs3d-playpause').addClass('vs3d-paused').removeClass('vs3d-playing'); clearTimeout(this.timer); } , prev:function(){ this.pause(); this.at--; this.show(); } , next:function(){ this.pause(); this.at++; this.show(); } , show:function(){ if (this.at==this.amount-1) this.at=0; if (this.at<0) this.at=this.amount-2; this.target.find('.i').html(''); } , preloadImages: function() { var args_len = arguments.length; for (var i = args_len; i--;) { var cacheImage = document.createElement('img'); cacheImage.src = arguments[i]; this.cache.push(cacheImage); } } } });