vendor: 4,310 bytes, lines 1-34
1/*function pinIt(){ 2 var e = document.createElement('script'); 3 e.setAttribute('type','text/javascript'); 4 e.setAttribute('charset','UTF-8'); 5 e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999); 6 document.body.appendChild(e); 7}*/ 8 9 10/*! Lazy Load 1.9.3 - MIT license - Copyright 2010-2013 Mika Tuupola */ 11!function(a,b,c,d){var e=a(b);a.fn.lazyload=function(f){function g(){var b=0;i.each(function(){var c=a(this);if(!j.skip_invisible||c.is(":visible"))if(a.abovethetop(this,j)||a.leftofbegin(this,j));else if(a.belowthefold(this,j)||a.rightoffold(this,j)){if(++b>j.failure_limit)return!1}else c.trigger("appear"),b=0})}var h,i=this,j={threshold:0,failure_limit:0,event:"scroll",effect:"show",container:b,data_attribute:"original",skip_invisible:!0,appear:null,load:null,placeholder:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"};return f&&(d!==f.failurelimit&&(f.failure_limit=f.failurelimit,delete f.failurelimit),d!==f.effectspeed&&(f.effect_speed=f.effectspeed,delete f.effectspeed),a.extend(j,f)),h=j.container===d||j.container===b?e:a(j.container),0===j.event.indexOf("scroll")&&h.bind(j.event,function(){return g()}),this.each(function(){var b=this,c=a(b);b.loaded=!1,(c.attr("src")===d||c.attr("src")===!1)&&c.is("img")&&c.attr("src",j.placeholder),c.one("appear",function(){if(!this.loaded){if(j.appear){var d=i.length;j.appear.call(b,d,j)}a("<img />").bind("load",function(){var d=c.attr("data-"+j.data_attribute);c.hide(),c.is("img")?c.attr("src",d):c.css("background-image","url('"+d+"')"),c[j.effect](j.effect_speed),b.loaded=!0;var e=a.grep(i,function(a){return!a.loaded});if(i=a(e),j.load){var f=i.length;j.load.call(b,f,j)}}).attr("src",c.attr("data-"+j.data_attribute))}}),0!==j.event.indexOf("scroll")&&c.bind(j.event,function(){b.loaded||c.trigger("appear")})}),e.bind("resize",function(){g()}),/(?:iphone|ipod|ipad).*os 5/gi.test(navigator.appVersion)&&e.bind("pageshow",function(b){b.originalEvent&&b.originalEvent.persisted&&i.each(function(){a(this).trigger("appear")})}),a(c).ready(function(){g()}),this},a.belowthefold=function(c,f){var g;return g=f.container===d||f.container===b?(b.innerHeight?b.innerHeight:e.height())+e.scrollTop():a(f.container).offset().top+a(f.container).height(),g<=a(c).offset().top-f.threshold},a.rightoffold=function(c,f){var g;return g=f.container===d||f.container===b?e.width()+e.scrollLeft():a(f.container).offset().left+a(f.container).width(),g<=a(c).offset().left-f.threshold},a.abovethetop=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollTop():a(f.container).offset().top,g>=a(c).offset().top+f.threshold+a(c).height()},a.leftofbegin=function(c,f){var g;return g=f.container===d||f.container===b?e.scrollLeft():a(f.container).offset().left,g>=a(c).offset().left+f.threshold+a(c).width()},a.inviewport=function(b,c){return!(a.rightoffold(b,c)||a.leftofbegin(b,c)||a.belowthefold(b,c)||a.abovethetop(b,c))},a.extend(a.expr[":"],{"below-the-fold":function(b){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-screen":function(b){return a.rightoffold(b,{threshold:0})},"left-of-screen":function(b){return!a.rightoffold(b,{threshold:0})},"in-viewport":function(b){return a.inviewport(b,{threshold:0})},"above-the-fold":function(b){return!a.belowthefold(b,{threshold:0})},"right-of-fold":function(b){return a.rightoffold(b,{threshold:0})},"left-of-fold":function(b){return!a.rightoffold(b,{threshold:0})}})}(jQuery,window,document); 12 13/* 14Copyright (c) 2012 Linus Suter 15Examples and docs at: http://codewelt.com/blendmode 16Licensed GPL licenses: 17http://www.gnu.org/licenses/gpl.html 18*/ 19(function($) { 20 $.fn.blendmode = function(options) { 21 var settings = $.extend( { 22 mode : "multiply", 23 object : null, 24 scale : false 25 }, options); 26 27 var blend = function(object) { 28 var $this = object; 29 if ($this == null) return; 30 var sourceCanvas = document.getElementsByName('blendModePlugin_sourceCanvas_' + $this.id)[0]; 31 if (sourceCanvas == null) { 32 sourceCanvas = document.createElement('canvas'); 33 sourceCanvas.name = 'blendModePlugin_sourceCanvas_' + $this.id; 34 }
35 var sourceCanvasContext = sourceCanvas.getContext("2d"); 36 37 if ($this.nodeName == "IMG") { 38 sourceCanvas.width = $this.width; 39 sourceCanvas.height = $this.height; 40 sourceCanvasContext.drawImage($this, 0, 0); 41 } else if ($this.nodeName == "CANVAS") { 42 sourceCanvas = $this; 43 sourceCanvasContext = $this.getContext("2d"); 44 } else return; 45 sourcePixels = sourceCanvasContext.getImageData(0, 0, $this.width, $this.height); 46 var param; 47 var targetCanvas = document.getElementsByName('blendModePlugin_targetCanvas_' + $this.id)[0]; 48 if (targetCanvas == null) { 49 targetCanvas = document.createElement('canvas'); 50 targetCanvas.name = 'blendModePlugin_targetCanvas_' + $this.id; 51 } 52 var targetCanvasContext = targetCanvas.getContext("2d"); 53 if (typeof options.object == "string") { 54 var ext = options.object.substring(options.object.lastIndexOf(".") + 1).toLowerCase(); 55 if (ext == "jpg" || ext == "jpeg" || ext == "gif" || ext == "bmp" || ext == "png") { 56 var targetImageAdd = document.getElementsByName('blendModePlugin_targetImageAdd_' + $this.id)[0]; 57 if (targetImageAdd == null) { 58 targetImageAdd = document.createElement("img"); 59 targetImageAdd.name = 'blendModePlugin_targetImageAdd_' + $this.id; 60 } 61 targetImageAdd.src = options.object; 62 targetCanvas.width = $this.width; 63 targetCanvas.height = $this.height; 64 targetCanvasContext.drawImage(targetImageAdd, 0, 0); 65 } else { 66 targetCanvas.width = $(this).width(); 67 targetCanvas.height = $(this).height(); 68 $(targetCanvas).css("background-color", options.object); 69 targetCanvasContext.fillStyle = $(targetCanvas).css("background-color"); 70 targetCanvasContext.fillRect(0, 0, targetCanvas.width, targetCanvas.height); 71 } 72 param = targetCanvas; 73 targetCanvasContext.drawImage(param, 0, 0, $this.width, $this.height); 74 targetPixels = targetCanvasContext.getImageData(0, 0, $this.width, $this.height); 75 } else { 76 if (!options.object) return; 77 var targetPixels; 78 param = options.object.get(0); 79 if (param.nodeName == "DIV") { 80 targetCanvas.width = $(this).width(); 81 targetCanvas.height = $(this).height(); 82 targetCanvasContext.fillStyle = $(this).css("background-color"); 83 targetCanvasContext.fillRect(0, 0, targetCanvas.width, targetCanvas.height); 84 } else if (param.nodeName == "IMG") { 85 targetCanvas.width = $this.width; 86 targetCanvas.height = $this.height; 87 } else if (param.nodeName == "CANVAS") { 88 var stringData = param.toDataURL("image/png"); 89 var targetImage = document.getElementsByName('blendModePlugin_targetImage_' + $this.id)[0]; 90 if (targetImage == null) { 91 targetImage = document.createElement("img"); 92 targetImage.name = 'blendModePlugin_targetImage_' + $this.id; 93 } 94 targetImage.src = stringData; 95 targetCanvas.width= $this.width; 96 targetCanvas.height= $this.height; 97 param = targetImage; 98 } else return; 99 if (!options.scaletofit) targetCanvasContext.drawImage(param, 0, 0); 100 else targetCanvasContext.drawImage(param, 0, 0, $this.width, $this.height); 101 targetPixels = targetCanvasContext.getImageData(0, 0, $this.width, $this.height); 102 } 103 104 switch (options.mode) { 105 case "normal" : 106 for (var x = 0; x < targetPixels.width; x++) { 107 for (var y = 0; y < targetPixels.height; y++) { 108 var i = 4 * (y * targetPixels.width + x); 109 sourcePixels.data[i] = targetPixels.data[i]; 110 sourcePixels.data[i + 1] = targetPixels.data[i+ 1]; 111 sourcePixels.data[i + 2] = targetPixels.data[i+ 2]; 112 } 113 } 114 break; 115 116 117 case "lighten" : 118 for (var x = 0; x < targetPixels.width; x++) { 119 for (var y = 0; y < targetPixels.height; y++) { 120 var i = 4 * (y * targetPixels.width + x); 121 var red = targetPixels.data[i]; 122 var green = targetPixels.data[i + 1]; 123 var blue = targetPixels.data[i + 2]; 124 if (red > sourcePixels.data[i]) sourcePixels.data[i] = red; 125 if (green > sourcePixels.data[i + 1]) sourcePixels.data[i + 1] = green; 126 if (blue > sourcePixels.data[i + 2]) sourcePixels.data[i + 2] = blue; 127 } 128 } 129 break; 130 131 132 } 133 134 if ($this.nodeName == "IMG") { 135 sourceCanvasContext.putImageData(sourcePixels, 0, 0); 136 var dummy = sourceCanvasContext.getImageData(0, 0, sourceCanvas.width, sourceCanvas.height); 137 var targetStringData = sourceCanvas.toDataURL("image/png"); 138 $this.src = targetStringData; 139 } else { 140 $this.getContext("2d").putImageData(sourcePixels, 0, 0); 141 } 142 $(this).bind('hashchange', function() { blend($this); }); 143 $(options.object).bind('hashchange', function() { blend($this); }); 144 }; 145 146 return this.each(function() { 147 var $this = $(this).get(0); 148 149 blend($this); 150 }); 151 152 }; 153})(jQuery); 154 155 156 157 158 159 160/* 161* jQuery File Download Plugin v1.4.5 162* 163* http://www.johnculviner.com 164* 165* Copyright (c) 2013 - John Culviner 166* 167* Licensed under the MIT license: 168* http://www.opensource.org/licenses/mit-license.php 169* 170* !!!!NOTE!!!! 171* You must also write a cookie in conjunction with using this plugin as mentioned in the orignal post: 172* http://johnculviner.com/jquery-file-download-plugin-for-ajax-like-feature-rich-file-downloads/ 173* !!!!NOTE!!!! 174*/ 175 176(function($, window){ 177 // i'll just put them here to get evaluated on script load 178 var htmlSpecialCharsRegEx = /[<>&\r\n"']/gm; 179 var htmlSpecialCharsPlaceHolders = { 180 '<': 'lt;', 181 '>': 'gt;', 182 '&': 'amp;', 183 '\r': "#13;", 184 '\n': "#10;", 185 '"': 'quot;', 186 "'": '#39;' /*single quotes just to be safe, IE8 doesn't support ', so use ' instead */ 187 }; 188 189$.extend({ 190 // 191 //$.fileDownload('/path/to/url/', options) 192 // see directly below for possible 'options' 193 fileDownload: function (fileUrl, options) { 194 195 //provide some reasonable defaults to any unspecified options below 196 var settings = $.extend({ 197 198 // 199 //Requires jQuery UI: provide a message to display to the user when the file download is being prepared before the browser's dialog appears 200 // 201 preparingMessageHtml: null, 202 203 // 204 //Requires jQuery UI: provide a message to display to the user when a file download fails 205 // 206 failMessageHtml: null, 207 208 // 209 //the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780 210 //specify a message here to display if a user tries with an android browser 211 //if jQuery UI is installed this will be a dialog, otherwise it will be an alert 212 //Set to null to disable the message and attempt to download anyway 213 // 214 androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.", 215 216 // 217 //Requires jQuery UI: options to pass into jQuery UI Dialog 218 // 219 dialogOptions: { modal: true }, 220 221 // 222 //a function to call while the dowload is being prepared before the browser's dialog appears 223 //Args: 224 // url - the original url attempted 225 // 226 prepareCallback: function (url) { }, 227 228 // 229 //a function to call after a file download successfully completed 230 //Args: 231 // url - the original url attempted 232 // 233 successCallback: function (url) { }, 234 235 // 236 //a function to call after a file download request was canceled 237 //Args: 238 // url - the original url attempted 239 // 240 abortCallback: function (url) { }, 241 242 // 243 //a function to call after a file download failed 244 //Args: 245 // responseHtml - the html that came back in response to the file download. this won't necessarily come back depending on the browser. 246 // in less than IE9 a cross domain error occurs because 500+ errors cause a cross domain issue due to IE subbing out the 247 // server's error message with a "helpful" IE built in message 248 // url - the original url attempted 249 // error - original error cautch from exception 250 // 251 failCallback: function (responseHtml, url, error) { }, 252 253 // 254 // the HTTP method to use. Defaults to "GET". 255 // 256 httpMethod: "GET", 257 258 // 259 // if specified will perform a "httpMethod" request to the specified 'fileUrl' using the specified data. 260 // data must be an object (which will be $.param seri
260alized) or already a key=value param string 261 // 262 data: null, 263 264 // 265 //a period in milliseconds to poll to determine if a successful file download has occured or not 266 // 267 checkInterval: 100, 268 269 // 270 //the cookie name to indicate if a file download has occured 271 // 272 cookieName: "fileDownload", 273 274 // 275 //the cookie value for the above name to indicate that a file download has occured 276 // 277 cookieValue: "true", 278 279 // 280 //the cookie path for above name value pair 281 // 282 cookiePath: "/", 283 284 // 285 //if specified it will be used when attempting to clear the above name value pair 286 //useful for when downloads are being served on a subdomain (e.g. downloads.example.com) 287 // 288 cookieDomain: null, 289 290 // 291 //the title for the popup second window as a download is processing in the case of a mobile browser 292 // 293 popupWindowTitle: "Initiating file download...", 294 295 // 296 //Functionality to encode HTML entities for a POST, need this if data is an object with properties whose values contains strings with quotation marks. 297 //HTML entity encoding is done by replacing all &,<,>,',",\r,\n characters. 298 //Note that some browsers will POST the string htmlentity-encoded whilst others will decode it before POSTing. 299 //It is recommended that on the server, htmlentity decoding is done irrespective. 300 // 301 encodeHTMLEntities: true 302 303 }, options); 304 305 var deferred = new $.Deferred(); 306 307 //Setup mobile browser detection: Partial credit: http://detectmobilebrowser.com/ 308 var userAgent = (navigator.userAgent || navigator.vendor || window.opera).toLowerCase(); 309 310 var isIos; //has full support of features in iOS 4.0+, uses a new window to accomplish this. 311 var isAndroid; //has full support of GET features in 4.0+ by using a new window. Non-GET is completely unsupported by the browser. See above for specifying a message. 312 var isOtherMobileBrowser; //there is no way to reliably guess here so all other mobile devices will GET and POST to the current window. 313 314 if (/ip(ad|hone|od)/.test(userAgent)) { 315 316 isIos = true; 317 318 } else if (userAgent.indexOf('android') !== -1) { 319 320 isAndroid = true; 321 322 } else { 323 324 isOtherMobileBrowser = /avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(userAgent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|
324sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(userAgent.substr(0, 4)); 325 326 } 327 328 var httpMethodUpper = settings.httpMethod.toUpperCase(); 329 330 if (isAndroid && httpMethodUpper !== "GET" && settings.androidPostUnsupportedMessageHtml) { 331 //the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780 332 333 if ($().dialog) { 334 $("<div>").html(settings.androidPostUnsupportedMessageHtml).dialog(settings.dialogOptions); 335 } else { 336 alert(settings.androidPostUnsupportedMessageHtml); 337 } 338 339 return deferred.reject(); 340 } 341 342 var $preparingDialog = null; 343 344 var internalCallbacks = { 345 346 onPrepare: function (url) { 347 348 //wire up a jquery dialog to display the preparing message if specified 349 if (settings.preparingMessageHtml) { 350 351 $preparingDialog = $("<div>").html(settings.preparingMessageHtml).dialog(settings.dialogOptions); 352 353 } else if (settings.prepareCallback) { 354 355 settings.prepareCallback(url); 356 357 } 358 359 }, 360 361 onSuccess: function (url) { 362 363 //remove the perparing message if it was specified 364 if ($preparingDialog) { 365 $preparingDialog.dialog('close'); 366 } 367 368 settings.successCallback(url); 369 370 deferred.resolve(url); 371 }, 372 373 onAbort: function (url) { 374 375 //remove the perparing message if it was specified 376 if ($preparingDialog) { 377 $preparingDialog.dialog('close'); 378 }; 379 380 settings.abortCallback(url); 381 382 deferred.reject(url); 383 }, 384 385 onFail: function (responseHtml, url, error) { 386 387 //remove the perparing message if it was specified 388 if ($preparingDialog) { 389 $preparingDialog.dialog('close'); 390 } 391 392 //wire up a jquery dialog to display the fail message if specified 393 if (settings.failMessageHtml) { 394 $("<div>").html(settings.failMessageHtml).dialog(settings.dialogOptions); 395 } 396 397 settings.failCallback(responseHtml, url, error); 398 399 deferred.reject(responseHtml, url); 400 } 401 }; 402 403 internalCallbacks.onPrepare(fileUrl); 404 405 //make settings.data a param string if it exists and isn't already 406 if (settings.data !== null && typeof settings.data !== "string") { 407 settings.data = $.param(settings.data); 408 } 409 410 411 var $iframe, 412 downloadWindow, 413 formDoc, 414 $form; 415 416 if (httpMethodUpper === "GET") { 417 418 if (settings.data !== null) { 419 //need to merge any fileUrl params with the data object 420 421 var qsStart = fileUrl.indexOf('?'); 422 423 if (qsStart !== -1) { 424 //we have a querystring in the url 425 426 if (fileUrl.substring(fileUrl.length - 1) !== "&") { 427 fileUrl = fileUrl + "&"; 428 } 429 } else { 430 431 fileUrl = fileUrl + "?"; 432 } 433 434 fileUrl = fileUrl + settings.data; 435 } 436 437 if (isIos || isAndroid) { 438 439 downloadWindow = window.open(fileUrl); 440 downloadWindow.document.title = settings.popupWindowTitle; 441 window.focus(); 442 443 } else if (isOtherMobileBrowser) { 444 445 window.location(fileUrl); 446 447 } else { 448 449 //create a temporary iframe that is used to request the fileUrl as a GET request 450 $iframe = $("<iframe>") 451 .hide() 452 .prop("src", fileUrl) 453 .appendTo("body"); 454 } 455 456 } else { 457 458 var formInnerHtml = ""; 459 460 if (settings.data !== null) { 461 462 $.each(settings.data.replace(/\+/g, ' ').split("&"), function () { 463 464 var kvp = this.split("="); 465 466 //Issue: When value contains sign '=' then the kvp array does have more than 2 items. We have to join value back 467 var k = kvp[0]; 468 kvp.shift(); 469 var v = kvp.join("="); 470 kvp = [k, v]; 471 472 var key = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[0])) : decodeURIComponent(kvp[0]); 473 if (key) { 474 var value = settings.encodeHTMLEntities ? htmlSpecialCharsEntityEncode(decodeURIComponent(kvp[1])) : decodeURIComponent(kvp[1]); 475 formInnerHtml += '<input type="hidden" name="' + key + '" value="' + value + '" />'; 476 } 477 }); 478 } 479 480 if (isOtherMobileBrowser) { 481 482 $form = $("<form>").appendTo("body"); 483 $form.hide() 484 .prop('method', settings.httpMethod) 485 .prop('action', fileUrl) 486 .html(formInnerHtml); 487 488 } else { 489 490 if (isIos) { 491 492 downloadWindow = window.open("about:blank"); 493 downloadWindow.document.title = settings.popupWindowTitle; 494 formDoc = downloadWindow.document; 495 window.focus(); 496 497 } else { 498 499 $iframe = $("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body"); 500 formDoc = getiframeDocument($iframe); 501 } 502 503 formDoc.write("<html><head></head><body><form method='" + settings.httpMethod + "' action='" + fileUrl + "'>" + formInnerHtml + "</form>" + settings.popupWindowTitle + "</body></html>"); 504 $form = $(formDoc).find('form'); 505 } 506 507 $form.submit(); 508 } 509 510 511 //check if the file download has completed every checkInterval ms 512 setTimeout(checkFileDownloadComplete, settings.checkInterval); 513 514 515 function checkFileDownloadComplete() { 516 //has the cookie been written due to a file download occuring? 517 518 var cookieValue = settings.cookieValue; 519 if(typeof cookieValue == 'string') { 520 cookieValue = cookieValue.toLowerCase(); 521 } 522 523 var lowerCaseCookie = settings.cookieName.toLowerCase() + "=" + cookieValue; 524 525 if (document.cookie.toLowerCase().indexOf(lowerCaseCookie) > -1) { 526 527 //execute specified callback 528 internalCallbacks.onSuccess(fileUrl); 529 530 //remove cookie 531 var cookieData = settings.cookieName + "=; path=" + settings.cookiePath + "; expires=" + new Date(0).toUTCString() + ";"; 532 if (settings.cookieDomain) cookieData += " domain=" + settings.cookieDomain + ";"; 533 document.cookie = cookieData; 534 535 //remove iframe 536 cleanUp(false); 537 538 return; 539 } 540 541 //has an error occured? 542 //if neither containers exist below then the file download is occuring on the current window 543 if (downloadWindow || $iframe) { 544 545 //has an error occured? 546 try { 547 548 var formDoc = downloadWindow ? downloadWindow.document : getiframeDocument($iframe); 549 550 if (formDoc && formDoc.body !== null && formDoc.body.innerHTML.length) { 551 552 var isFailure = true; 553 554 if ($form && $form.length) { 555 var $contents = $(formDoc.body).contents().first(); 556 557 try { 558 if ($contents.length && $contents[0] === $form[0]) { 559 isFailure = false;
560 } 561 } catch (e) { 562 if (e && e.number == -2146828218) { 563 // IE 8-10 throw a permission denied after the form reloads on the "$contents[0] === $form[0]" comparison 564 isFailure = true; 565 } else { 566 throw e; 567 } 568 } 569 } 570 571 if (isFailure) { 572 // IE 8-10 don't always have the full content available right away, they need a litle bit to finish 573 setTimeout(function () { 574 internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl); 575 cleanUp(true); 576 }, 100); 577 578 return; 579 } 580 } 581 } 582 catch (err) { 583 584 //500 error less than IE9 585 internalCallbacks.onFail('', fileUrl, err); 586 587 cleanUp(true); 588 589 return; 590 } 591 } 592 593 594 //keep checking... 595 setTimeout(checkFileDownloadComplete, settings.checkInterval); 596 } 597 598 //gets an iframes document in a cross browser compatible manner 599 function getiframeDocument($iframe) { 600 var iframeDoc = $iframe[0].contentWindow || $iframe[0].contentDocument; 601 if (iframeDoc.document) { 602 iframeDoc = iframeDoc.document; 603 } 604 return iframeDoc; 605 } 606 607 function cleanUp(isFailure) { 608 609 setTimeout(function() { 610 611 if (downloadWindow) { 612 613 if (isAndroid) { 614 downloadWindow.close(); 615 } 616 617 if (isIos) { 618 if (downloadWindow.focus) { 619 downloadWindow.focus(); //ios safari bug doesn't allow a window to be closed unless it is focused 620 if (isFailure) { 621 downloadWindow.close(); 622 } 623 } 624 } 625 } 626 627 //iframe cleanup appears to randomly cause the download to fail 628 //not doing it seems better than failure... 629 //if ($iframe) { 630 // $iframe.remove(); 631 //} 632 633 }, 0); 634 } 635 636 637 function htmlSpecialCharsEntityEncode(str) { 638 return str.replace(htmlSpecialCharsRegEx, function(match) { 639 return '&' + htmlSpecialCharsPlaceHolders[match]; 640 }); 641 } 642 var promise = deferred.promise(); 643 promise.abort = function() { 644 cleanUp(); 645 $iframe.attr('src', '').html(''); 646 internalCallbacks.onAbort(fileUrl); 647 }; 648 return promise; 649 } 650}); 651 652})(jQuery, this || window);
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.