Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions src/CodeCoverage/Report/HTML/Renderer/Template/js/holder.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!

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.
Expand Down Expand Up @@ -249,10 +249,10 @@ function draw_svg(args){
var text_height = ts.height;
var width = dimensions.width,
height = dimensions.height;

var font = template.font ? template.font : "Arial,Helvetica,sans-serif";
var text = template.text ? template.text : (Math.floor(dimensions.width) + "x" + Math.floor(dimensions.height));

if (literal) {
var dimensions = holder.dimensions;
text = dimensions.width + "x" + dimensions.height;
Expand All @@ -262,14 +262,14 @@ function draw_svg(args){
text = (Math.floor(dimensions.width) + "x" + Math.floor(dimensions.height));
}
var string = svg_el({
text: text,
width:width,
height:height,
text_height:text_height,
font:font,
text: text,
width:width,
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) {
Expand All @@ -295,7 +295,7 @@ function render(mode, el, holder, src) {
el.setAttribute("data-src", src);
holder.theme = theme;
el.holder_data = holder;

if (mode == "image") {
el.setAttribute("alt", text ? text : theme.text ? theme.text + " [" + dimensions_caption + "]" : dimensions_caption);
if (instance_config.use_fallback || !holder.auto) {
Expand All @@ -306,12 +306,12 @@ function render(mode, el, holder, src) {
el.style.backgroundColor = theme.background;
} else {
el.setAttribute("src", draw({ctx: ctx, dimensions: dimensions, template: theme, ratio:ratio, holder: holder}));

if(holder.textmode && holder.textmode == "exact"){
resizable_images.push(el);
resizable_update(el);
}

}
} else if (mode == "background") {
if (!instance_config.use_fallback) {
Expand All @@ -333,9 +333,9 @@ function render(mode, el, holder, src) {
if (el.style.display == "inline" || el.style.display === "" || el.style.display == "none") {
el.style.display = "block";
}

set_initial_dimensions(el)

if (instance_config.use_fallback) {
el.style.backgroundColor = theme.background;
} else {
Expand Down Expand Up @@ -500,19 +500,20 @@ app.add_image = function (src, el) {
};

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) {
Expand All @@ -531,20 +532,25 @@ app.run = function (o) {
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)
Expand Down Expand Up @@ -598,6 +604,10 @@ contentLoaded(win, function () {
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 () {
Expand Down