Skip to content

detects safari browser #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
63 changes: 34 additions & 29 deletions common/body_tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
if (found >= 0 && found < 3) return url;
if (url[0] !== "/") url = "/" + url;

return baseUri + url;
return baseUri + url;
}

//Save markerjs state before reopening when resizing composer
Expand Down Expand Up @@ -75,6 +75,34 @@
$(".markerjs-toolbar").css("margin-left", "13%");
}
}

function isSafari() {
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)){
// making compatible with Safari
let tempAlt = [];
let tempWidth = [];
let tempHeight = [];
let tempSrcs = [];
let tempClass = $(".resizable").attr("class");
$(".image-anotator-area").attr("crossorigin", "anonymous");
for (let i = 0; i < $(".d-editor-preview img").length; i++) {
tempSrcs[i] = $(".d-editor-preview img")[i].src;
tempWidth[i] = $(".d-editor-preview img")[i].width;
tempHeight[i] = $(".d-editor-preview img")[i].height;
tempAlt[i] = $(".d-editor-preview img")[i].alt;
}
$(".resizable").removeAttr("src");
$(".resizable").removeAttr("alt");
$(".resizable").removeAttr("width");
$(".resizable").removeAttr("height");
for (let i = 0; i < $(".d-editor-preview img").length; i++) {
$(".d-editor-preview img")[i].src = tempSrcs[i];
$(".d-editor-preview img")[i].width = tempWidth[i];
$(".d-editor-preview img")[i].height = tempHeight[i];
$(".d-editor-preview img")[i].alt = tempAlt[i];
}
}
}

//Display markerjs when image is clicked
let mark;
Expand Down Expand Up @@ -175,8 +203,8 @@
$("svg").on("click", function () {
return saveState(newObj, img, mark);
});
return newObj;
}
return newObj;
}

//Exec when image is clicked
$("body").on("click", ".d-editor-preview img", function () {
Expand All @@ -188,7 +216,7 @@
});

mobileSize();

isSafari();
removeDuplicates();
let theMarker = showMarkerJs(this);

Expand Down Expand Up @@ -229,31 +257,8 @@
$(".d-editor-preview img").addClass("resizable");
$(".resizable").attr("crossorigin", "anonymous");
$("#reply-control").css("height", "80%");

// making compatible with Safari
let tempAlt = [];
let tempWidth = [];
let tempHeight = [];
let tempSrcs = [];
let tempClass = $(".resizable").attr("class");
$(".image-anotator-area").attr("crossorigin", "anonymous");
for (let i = 0; i < $(".d-editor-preview img").length; i++) {
tempSrcs[i] = $(".d-editor-preview img")[i].src;
tempWidth[i] = $(".d-editor-preview img")[i].width;
tempHeight[i] = $(".d-editor-preview img")[i].height;
tempAlt[i] = $(".d-editor-preview img")[i].alt;
}
$(".resizable").removeAttr("src");
$(".resizable").removeAttr("alt");
$(".resizable").removeAttr("width");
$(".resizable").removeAttr("height");
for (let i = 0; i < $(".d-editor-preview img").length; i++) {
$(".d-editor-preview img")[i].src = tempSrcs[i];
$(".d-editor-preview img")[i].width = tempWidth[i];
$(".d-editor-preview img")[i].height = tempHeight[i];
$(".d-editor-preview img")[i].alt = tempAlt[i];
}
isSafari();
mobileSize();
});
});
</script>
</script>
Loading