1// Master Control for site overlays 2 3jQuery(function ($) { 4 // metadata allows array of data to be applied inline and be used wihin function 5 $("body").on("click", ".trigger-overlay", function (e) { 6 overlayDisplay(null, $(this).data()); 7 e.preventDefault(); 8 }); 9}); 10 11 12function overlayDisplay(content, data) { 13 if (data === undefined) { 14 data = ""; 15 data.options = ""; 16 }; 17 var $mainContent = $("#mainOverlayContent"); 18 19 // check to see if data.options are present 20 if (data.options && data.options) { 21 // sets data type for request 22 var dataType = (data.options.dataType) ? data.options.dataType : "json"; 23 // sets directory for ajax 24 var queryTool = (data.options.QueryTool) ? data.options.QueryTool : "store"; 25 // enables direct ajax URL control 26 var ajaxUrl = (data.options.ajaxUrl) ? data.options.ajaxUrl : "/ajax/" + queryTool + "/ajax.aspx?"; 27 }; 28 29 // checks to see if content is being passed as a string to be used instead of ajax request 30 if (content != null) { 31 if (content.constructor == String) { 32 // injects static content 33 $mainContent.html(content); 34 buildOverlay(); 35 return false; 36 }; 37 }; 38 39 // checks to see if modal should use static content embedded within page instead of ajax request 40 (data.options && data.options.StaticId) ? buildOverlay() : buildAjax(); 41 42 function buildAjax(cacheResults) { 43 // query path built from data array pulled from object 44 var query = ajaxUrl + $.param(data.query); 45 46 // check for cache; process and output ajax query 47 var cacheResp = window[query]; 48 if (!data.options.noCache && cacheResp) { 49 handleOverlayResult(cacheResp, data, query); 50 } else { 51 //$.getJSON(query, function(o) { handleOverlayResult(o, data, query); }); 52 // above has been replaced with below for more control over requests 53 $.ajax({ 54 "type": "GET", 55 "data": "", 56 "async": "false", 57 "contentType": "application/json; charset=utf-8", 58 "url": query, 59 "dataType": dataType, 60 "success": function (o) { 61 handleOverlayResult(o, data, query); 62 } 63 }); 64 65 }; 66 }; 67 68 function handleOverlayResult(o, data, query) { 69 // handle ajax query results 70 var ac = ''; 71 if (!o.Success) { 72 ac += '<div class="errorMessage" style="margin:30px 30px 20px 30px;">'; 73 ac += ' <table cellspacing="0" cellpadding="10" border="0">'; 74 ac += ' <tr>'; 75 ac += ' <td valign="top" style="width: 30px;"><img width="24" height="24" alt="Error" style="border-style: none; padding-top: 6px;" src="/cms/images/exclam.gif"></td>'; 76 ac += ' <td style="width: 100%;"><p class="bold red">This was not processed due to the following reasons:</p>» ' + o.Error + '</td>'; 77 ac += ' </tr>'; 78 ac += ' </table>'; 79 ac += '</div>'; 80 81 } else { 82 if (!data.options.noCache) window[query] = o; 83 84 switch (data.query.f) { 85 case 'BuyNow': ac = processBuyNow(o); break; 86 case 'GetVideo': ac = o.VideoHtml; break; 87 case 'GetProductVideo': ac = processGetVideo(o); break; 88 case 'GetSizeChart': ac = processGetSizeChart(o); break; 89 default: ac = (o.html) ? o.html : o.HTML; 90 }; 91 }; 92 93 // injects ajax content inside of overlay container and triggers overlay 94 $mainContent.html(ac); 95 96 switch (data.query.f) { 97 case 'BuyNow': buildBuyNow(o); break; 98 case 'GetProductVideo': buildGetVideo(o); break; 99 }; 100 101 $("div.sizeChartA").accordion({ 102 header: "h3", 103 autoHeight: false, 104 collapsible: true 105 }); 106 107 buildOverlay(); 108 }; 109 110 function buildOverlay() { 111 var $overlayId = $("#overlay-main"); 112 if (data.options && data.options.StaticId) { 113 $overlayId = $("#" + data.options.StaticId); 114 $mainContent = $("#" + data.options.StaticId + "Content"); 115 } 116 if (data.options && data.options.oWidth) $overlayId.css('width', data.options.oWidth + 'px'); 117 118 // initializes and loads overlay. 119 $overlayId.overlay({ 120 top: 'center', 121 closeOnClick: true, 122 oneInstance: false, 123 expose: { 124 color: '#000', 125 loadSpeed: 0, 126 closeSpeed: 0, 127 maskId: 'exposeMask', 128 opacity: 0.90 129 }, 130 onLoad: function() { $("#exposeMask").css("height", $(document).height()); }, 131 onClose: function() { $overlayId.removeAttr('style'); }, 132 api: true 133 }).load(); 134 135 // binds closing functions 136 $overlayId.bgIframe().find(".overlayClose, .modalClose").click(function() { 137 $overlayId.overlay().close(); 138 139 //if (!data.options.StaticId) $mainContent.html(''); 140 }); 141 }; 142};
143 144function processGetSizeChart(o) { 145 return o.HTML; 146} 147 148function processBuyNow(o) { 149 var sBuyNow = ''; 150 sBuyNow += o.HTML 151 152 return sBuyNow; 153}; 154 155function buildBuyNow(o) { 156 //alert(o.Selections.Variable); 157 window[o.Selections.Variable] = new IdevSelections(o.Selections); 158 window[o.Selections.Variable].Create(); 159 160 for (var i = 0; i < o.Selections.Classifications.length; i++) { 161 var c = o.Selections.Classifications[i]; 162 if (c.s.length === 1) { 163 window[o.Selections.Variable].Select(c.i, c.s[0].i, true); 164 } 165 } 166 167 if (window.addthis){ window.addthis = null; } 168 $.getScript('http://s7.addthis.com/js/250/addthis_widget.js#pubid=xxx',function(){ 169 170 var add_this_html = 171 '<div class="addthis_toolbox addthis_default_style" addthis:url="' + o.ItemUrl + '">'+ 172 '<a class="addthis_button_twitter"></a> '+ 173 '<a class="addthis_button_preferred_1"></a>'+ 174 '<a class="addthis_button_preferred_2"></a>'+ 175 '<a class="addthis_button_facebook_like"></a>'+ 176 '</div>'; 177 178 $("#loadhere").html(add_this_html); 179 addthis.init(); 180 }); 181 182 $(".siteOverlay select:not(.noStyle)").peek("selectmenu").hide(); 183 $(".siteOverlay .tabModule .tabdiv").peek("jScrollPane"); 184 185 var overlayTabs = $('.siteOverlay .tabModule').tabs(); 186 overlayTabs.find(".tabnav").children().first().addClass('firstTab'); 187 overlayTabs.find(".tabnav").children().last().addClass('lastTab'); 188}; 189 190function processGetVideo(o) { 191 var s = ''; 192 s += ' <div class="pvInner">'; 193 s+= o.VideoCode; 194 s += ' </div>'; 195 196 return s; 197}; 198 199function buildGetVideo(o) { 200 var flashvars = {}; 201 flashvars.datasrc = "/GetVideoPlayerXml.aspx?VideoId=" + o.VideoId + "%26Preview%3dFalse"; 202 var params = {}; 203 params.quality = "best"; 204 params.autostart = "true"; 205 params.videoid = o.VideoId; 206 params.wmode = "transparent"; 207 params.allowfullscreen = "true"; 208 params.allowscriptaccess = "always"; 209 var attributes = {}; 210 swfobject.embedSWF("/flash/video_player.swf", "videoDiv", "384", "253", "9.0.0", false, flashvars, params, attributes); 211}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.