Skip to content

Commit

Permalink
Fix some instances of embedded helioviewer (#537)
Browse files Browse the repository at this point in the history
* fix embed page

* patches for embed
  • Loading branch information
dgarciabriseno authored Feb 26, 2024
1 parent afe54b3 commit a0bbad3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 23 deletions.
9 changes: 8 additions & 1 deletion resources/js/HelioviewerClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ var HelioviewerClient = Class.extend(
* @description Checks browser support for various features used in Helioviewer
*/
_checkBrowser: function () {
let localStorageSupport = true;
try {
localStorageSupport = ('localStorage' in window) && window['localStorage'] !== null;
} catch (e) {
localStorageSupport = false;
}

// Base support
$.extend($.support, {
"localStorage" : ('localStorage' in window) && window['localStorage'] !== null,
"localStorage" : localStorageSupport,
"nativeJSON" : typeof (JSON) !== "undefined",
"video" : !!document.createElement('video').canPlayType,
"h264" : false,
Expand Down
58 changes: 36 additions & 22 deletions resources/js/UI/ImageScale.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,24 @@ var ImageScale = Class.extend(
Helioviewer.userSettings.get("state.containerY") <= ( $('#hv-header').height() || 0 ) ||
Helioviewer.userSettings.get("state.containerY") >= this.container.parent().height()-this.container.height()
) {
this.containerX = this.container.parent().width()*0.66 - this.container.width()/2; //center the earth container
this.containerY = $('#earth-button').position().top + $('#scale').position().top + this.container.height();
this.container.css({
'position' : 'absolute',
'top' : this.containerY+'px',
'left' : this.containerX+'px'
});
if (outputType == 'embed') {
this.containerX = 15;
this.containerY = this.container.parent().height() - this.container.height() - 15;
this.container.css({
'position' : 'absolute',
'top' : this.containerY+'px',
'left' : this.containerX+'px'
});
} else {
this.containerX = this.container.parent().width()*0.66 - this.container.width()/2; //center the earth container
this.containerY = $('#earth-button').position().top + $('#scale').position().top + this.container.height();
this.container.css({
'position' : 'absolute',
'top' : this.containerY+'px',
'left' : this.containerX+'px'
});
}

}
}else{// minimal helioviewer
var dm = $('#date-manager-container');
Expand Down Expand Up @@ -317,21 +328,24 @@ var ImageScale = Class.extend(
if ( parseInt(Helioviewer.userSettings.get("state.scaleX")) == 0 ||
parseInt(Helioviewer.userSettings.get("state.scaleY")) == 0 ) {


if (outputType != 'minimal'){

this.containerX = this.container.parent().width()*0.66 - this.container.width()/2; //center the earth container
this.containerY = $('#earth-button').position().top + $('#scale').position().top + this.container.height();
this.scale = false;

}else{
var sc = $('#scale');
this.containerX = sc.position().left + (sc.outerWidth()/2) - this.container.width()/2; //center the earth container
this.containerY = sc.position().top - this.container.height() - 3;
//this.containerX = this.container.parent().width() - 150;
//this.containerY = this.container.parent().height() - 100;
this.scale = true;
}
switch(outputType) {
case "minimal":
var sc = $('#scale');
this.containerX = sc.position().left + (sc.outerWidth()/2) - this.container.width()/2; //center the earth container
this.containerY = sc.position().top - this.container.height() - 3;
this.scale = true;
break;
case "embed":
this.scale = false;
this.containerX = 15;
this.containerY = this.container.parent().height() - this.container.height() - 15;
break;
default:
this.containerX = this.container.parent().width()*0.66 - this.container.width()/2; //center the earth container
this.containerY = $('#earth-button').position().top + $('#scale').position().top + this.container.height();
this.scale = false;
break;
}
}

this.scaleContainerDragTo(this.containerX, this.containerY);
Expand Down

0 comments on commit a0bbad3

Please sign in to comment.