Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Dec 29, 2017
2 parents 8be6e7b + 481dc37 commit e30a5d2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 68 deletions.
12 changes: 5 additions & 7 deletions doc/res/common.js
Expand Up @@ -24,8 +24,8 @@ if ( document.location.protocol !== "file:"
// Support the tracking of emails, downloads and external links in Google
// Analytics

$(document).ready(function($) {
$("a").on("click", function() {
$(document).ready(function() {
$("a").click(function() {
var element = $(this);
var href = (typeof element.attr("href") !== "undefined")?element.attr("href"):"";
var track = true;
Expand Down Expand Up @@ -262,11 +262,10 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
if (liId.length)
subMenuSelected = subMenuCounter;
} else {
if (menuItemLink.length) {
if (menuItemLink.length)
tableRowClasses += " clickableMenuItem";
} else {
else
tableRowClasses += " nonClickableMenuItem";
}
}

var subMenuButton = "";
Expand Down Expand Up @@ -349,9 +348,8 @@ function doHeaderAndContentsMenu(pageName, relativePath, r, g, b, data) {
// Hide our contents menu if the ESC key is pressed

$(document).keyup(function(event) {
if (event.keyCode === 27) {
if (event.keyCode === 27)
$("ul.contentsMenu > li > ul").css("visibility", "hidden");
}
});

// Show/hide a given sub-menu
Expand Down
4 changes: 2 additions & 2 deletions doc/res/downloads.js
Expand Up @@ -360,6 +360,7 @@ function versions(downloads) {

var fileName = "OpenCOR-"+versionVersion+"-"+platformName.replace(" ", "")+((typeof fileBitness !== "undefined")?fileBitness:"")+fileExtension;
var fullFileName = versionFolder+"/"+fileName;
var fileType;

if ( (fileExtension === ".exe")
|| (fileExtension === ".dmg"))
Expand Down Expand Up @@ -462,9 +463,8 @@ function versions(downloads) {
// anywhere on the document

$(document).keyup(function(event) {
if (event.keyCode === 27) {
if (event.keyCode === 27)
$("ul.downloadsMenu").css("visibility", "hidden");
}
});

$(document).click(function() {
Expand Down
116 changes: 57 additions & 59 deletions doc/user/res/imagepopup.js
@@ -1,83 +1,81 @@
$(window).on('load', function() {
jQuery(document).ready(function($) {
// Create a div for our popup image
$(document).ready(function() {
// Create a div for our popup image

$("body").append("<div class=\"imagepopup\"><img class=\"popup\"></div>");
$("body").append("<div class=\"imagepopup\"><img class=\"popup\"></div>");

// Disable the mousewheel when the div for our popup image is visible
// Disable the mousewheel when the div for our popup image is visible

$("div.imagepopup").bind("mousewheel", function() {
return false;
});

// Initially hide the div for our popup image

hideImagePopup();
$("div.imagepopup").bind("mousewheel", function() {
return false;
});

// Show and update the contents of the div for our popup image
// Initially hide the div for our popup image

$("[imagepopup]").click(function() {
$("div.imagepopup").css("visibility", "visible");
hideImagePopup();

var imagepopup = $("div.imagepopup img.popup");
// Show and update the contents of the div for our popup image

// Retrieve the size of our image and its padding
// Note: to use $(imagepopup).width() and $(imagepopup).height() to
// retrieve the size of our image is not good enough since
// our image won't be loaded yet, so we would effectively be
// retrieving the size of our previous image. Now, when it
// comes to the padding, it will always be the same for all
// our images, hence we can safely use $(imagepopup)...
$("[imagepopup]").click(function() {
$("div.imagepopup").css("visibility", "visible");

var image = new Image();
var imagepopup = $("div.imagepopup img.popup");

image.src = $(this).attr("src");
// Retrieve the size of our image and its padding
// Note: to use $(imagepopup).width() and $(imagepopup).height() to
// retrieve the size of our image is not good enough since our
// image won't be loaded yet, so we would effectively be
// retrieving the size of our previous image. Now, when it comes
// to the padding, it will always be the same for all our images,
// hence we can safely use $(imagepopup)...

var imageWidth = image.width;
var imageHeight = image.height;
var imagePaddingX = $(imagepopup).innerWidth()-$(imagepopup).width();
var imagePaddingY = $(imagepopup).innerHeight()-$(imagepopup).height();
var image = new Image();

$(imagepopup).attr("src", $(this).attr("src"));
image.src = $(this).attr("src");

$(imagepopup).css({
"width": imageWidth,
"height": imageHeight,
"margin-top": -0.5*(imageHeight+imagePaddingY),
"margin-left": -0.5*(imageWidth+imagePaddingX)
});
});
var imageWidth = image.width;
var imageHeight = image.height;
var imagePaddingX = $(imagepopup).innerWidth()-$(imagepopup).width();
var imagePaddingY = $(imagepopup).innerHeight()-$(imagepopup).height();

// Hide the div for our popup image when clicking on it
$(imagepopup).attr("src", $(this).attr("src"));

$("div.imagepopup").click(function() {
hideImagePopup();
$(imagepopup).css({
"width": imageWidth,
"height": imageHeight,
"margin-top": -0.5*(imageHeight+imagePaddingY),
"margin-left": -0.5*(imageWidth+imagePaddingX)
});
});

// Ignore all key strokes, except the ESC key, when the div for our
// popup image is visible
// Hide the div for our popup image when clicking on it

$(document).keydown(function(event) {
if ($("div.imagepopup").css("visibility") === "visible") {
if (event.keyCode !== 27)
event.preventDefault();
}
});
$("div.imagepopup").click(function() {
hideImagePopup();
});

// Hide the div for our popup image if the ESC key is pressed when our
// div is visible
// Ignore all key strokes, except the ESC key, when the div for our popup
// image is visible

$(document).keyup(function(event) {
if ( ($("div.imagepopup").css("visibility") === "visible")
&& (event.keyCode === 27)) {
hideImagePopup();
}
});
$(document).keydown(function(event) {
if ($("div.imagepopup").css("visibility") === "visible") {
if (event.keyCode !== 27)
event.preventDefault();
}
});

// Hide the div for our popup image
// Hide the div for our popup image if the ESC key is pressed when our div
// is visible

function hideImagePopup() {
$("div.imagepopup").css("visibility", "hidden");
$(document).keyup(function(event) {
if ( ($("div.imagepopup").css("visibility") === "visible")
&& (event.keyCode === 27)) {
hideImagePopup();
}
});

// Hide the div for our popup image

function hideImagePopup() {
$("div.imagepopup").css("visibility", "hidden");
}
});

0 comments on commit e30a5d2

Please sign in to comment.