vendor/assets/javascripts/holder.js in holder_rails-2.3.1 vs vendor/assets/javascripts/holder.js in holder_rails-2.3.2

- old
+ new

@@ -1,8 +1,8 @@ /*! -Holder - 2.3.1 - client side image placeholders +Holder - 2.3.2 - client side image placeholders (c) 2012-2014 Ivan Malopinsky / http://imsky.co Provided under the MIT License. Commercial use requires attribution. @@ -267,11 +267,11 @@ height:height, text_height:text_height, font:font, template:template }) - return "data:image/svg+xml;base64,"+btoa(string); + return "data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(string))); } function draw(args) { if(instance_config.use_canvas && !instance_config.use_svg){ return draw_canvas(args); @@ -498,23 +498,24 @@ } return app; }; app.run = function (o) { + instance_config = extend({}, system_config) preempted = true; var options = extend(settings, o), images = [], imageNodes = [], bgnodes = []; - + if(options.use_canvas != null && options.use_canvas){ instance_config.use_canvas = true; instance_config.use_svg = false; } - + if (typeof (options.images) == "string") { imageNodes = selector(options.images); } else if (window.NodeList && options.images instanceof window.NodeList) { imageNodes = options.images; } else if (window.Node && options.images instanceof window.Node) { @@ -529,24 +530,29 @@ bgnodes = options.bgnodes; } else if (window.Node && options.bgnodes instanceof window.Node) { bgnodes = [options.bgnodes]; } for (i = 0, l = imageNodes.length; i < l; i++) images.push(imageNodes[i]); + var holdercss = document.getElementById("holderjs-style"); if (!holdercss) { holdercss = document.createElement("style"); holdercss.setAttribute("id", "holderjs-style"); holdercss.type = "text/css"; document.getElementsByTagName("head")[0].appendChild(holdercss); } + if (!options.nocss) { if (holdercss.styleSheet) { holdercss.styleSheet.cssText += options.stylesheet; } else { - holdercss.appendChild(document.createTextNode(options.stylesheet)); + if(options.stylesheet.length){ + holdercss.appendChild(document.createTextNode(options.stylesheet)); + } } } + var cssregex = new RegExp(options.domain + "\/(.*?)\"?\\)"); for (var l = bgnodes.length, i = 0; i < l; i++) { var src = window.getComputedStyle(bgnodes[i], null) .getPropertyValue("background-image"); var flags = src.match(cssregex); @@ -596,9 +602,13 @@ window.addEventListener("orientationchange", resizable_update, false); } else { window.attachEvent("onresize", resizable_update) } preempted || app.run({}); + + if (typeof window.Turbolinks === "object") { + document.addEventListener("page:change", function() { app.run({}) }) + } }); if (typeof define === "function" && define.amd) { define([], function () { return app; });