Skip to content

Commit

Permalink
Consolidated tileLayerData params into separate object to improve rea…
Browse files Browse the repository at this point in the history
…dability after difference bug fix.
  • Loading branch information
Helioviewer-Kirill committed Jun 11, 2018
1 parent a18cd0a commit 038a546
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 22 deletions.
4 changes: 2 additions & 2 deletions resources/build/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<echo>concatenating JavaScript...</echo>
<concat destfile="resources/compressed/helioviewer.js" encoding="UTF-8" outputencoding="UTF-8" fixlastline="true">
<filelist dir="resources/js" files="Utility/Config.js, Utility/HelperFunctions.js, Tiling/Layer/Layer.js, Tiling/Layer/TileLoader.js, Tiling/Layer/TileLayer.js, Tiling/Layer/HelioviewerTileLayer.js, Utility/KeyboardManager.js, Tiling/Manager/LayerManager.js, Tiling/Manager/TileLayerManager.js, Tiling/Manager/HelioviewerTileLayerManager.js, Image/JP2Image.js, Viewport/Helper/MouseCoordinates.js, Viewport/Helper/HelioviewerMouseCoordinates.js, Viewport/Helper/SandboxHelper.js, Viewport/Helper/ViewportMovementHelper.js, Viewport/HelioviewerViewport.js, HelioviewerClient.js, UI/ZoomControls.js, UI/ImageScale.js, UI/Timeline.js, UI/TimelineEvents.js, Utility/InputValidator.js, Utility/SettingsLoader.js, Utility/UserSettings.js, Tiling/Manager/LayerManager.js, Events/EventManager.js, Events/EventType.js, Events/EventTree.js, Events/EventFeatureRecognitionMethod.js, Events/EventLayerManager.js, Events/EventMarker.js, Events/EventLayerManager.js, Events/HelioviewerEventLayer.js, Events/HelioviewerEventLayerManager.js, UI/TreeSelect.js, UI/ImageSelectTool.js, Media/MediaManagerUI.js, Media/MediaManager.js, Media/MovieManager.js, Media/MovieManagerUI.js, Media/ScreenshotManager.js, Media/ScreenshotManagerUI.js, UI/TileLayerAccordion.js, UI/TimeSelector.js, UI/EventLayerAccordion.js, UI/MessageConsole.js, UI/TimeControls.js, Utility/FullscreenControl.js, Utility/Tutorial.js, HelioviewerWebClient.js, UI/UserVideoGallery.js, UI/ImagePresets.js, UI/Glossary.js, UI/jquery.ui.dynaccordion.js"/>
<filelist dir="resources/js" files="UI/TileLayerData.js, Utility/Config.js, Utility/HelperFunctions.js, Tiling/Layer/Layer.js, Tiling/Layer/TileLoader.js, Tiling/Layer/TileLayer.js, Tiling/Layer/HelioviewerTileLayer.js, Utility/KeyboardManager.js, Tiling/Manager/LayerManager.js, Tiling/Manager/TileLayerManager.js, Tiling/Manager/HelioviewerTileLayerManager.js, Image/JP2Image.js, Viewport/Helper/MouseCoordinates.js, Viewport/Helper/HelioviewerMouseCoordinates.js, Viewport/Helper/SandboxHelper.js, Viewport/Helper/ViewportMovementHelper.js, Viewport/HelioviewerViewport.js, HelioviewerClient.js, UI/ZoomControls.js, UI/ImageScale.js, UI/Timeline.js, UI/TimelineEvents.js, Utility/InputValidator.js, Utility/SettingsLoader.js, Utility/UserSettings.js, Tiling/Manager/LayerManager.js, Events/EventManager.js, Events/EventType.js, Events/EventTree.js, Events/EventFeatureRecognitionMethod.js, Events/EventLayerManager.js, Events/EventMarker.js, Events/EventLayerManager.js, Events/HelioviewerEventLayer.js, Events/HelioviewerEventLayerManager.js, UI/TreeSelect.js, UI/ImageSelectTool.js, Media/MediaManagerUI.js, Media/MediaManager.js, Media/MovieManager.js, Media/MovieManagerUI.js, Media/ScreenshotManager.js, Media/ScreenshotManagerUI.js, UI/TileLayerAccordion.js, UI/TimeSelector.js, UI/EventLayerAccordion.js, UI/MessageConsole.js, UI/TimeControls.js, Utility/FullscreenControl.js, Utility/Tutorial.js, HelioviewerWebClient.js, UI/UserVideoGallery.js, UI/ImagePresets.js, UI/Glossary.js, UI/jquery.ui.dynaccordion.js"/>
</concat>

<echo>concatenating CSS...</echo>
Expand Down Expand Up @@ -71,7 +71,7 @@

<echo>concatenating JavaScript...</echo>
<concat destfile="resources/compressed/helioviewer-embed.js" encoding="UTF-8" outputencoding="UTF-8" fixlastline="true">
<filelist dir="resources/js" files="Utility/Config.js, Utility/HelperFunctions.js, Tiling/Layer/Layer.js, Tiling/Layer/TileLoader.js, Tiling/Layer/TileLayer.js, Tiling/Layer/HelioviewerTileLayer.js, Utility/KeyboardManager.js, Tiling/Manager/LayerManager.js, Tiling/Manager/TileLayerManager.js, Tiling/Manager/HelioviewerTileLayerManager.js, Image/JP2Image.js, Viewport/Helper/MouseCoordinates.js, Viewport/Helper/HelioviewerMouseCoordinates.js, Viewport/Helper/SandboxHelper.js, Viewport/Helper/ViewportMovementHelper.js, Viewport/HelioviewerViewport.js, HelioviewerClient.js, UI/ZoomControls.js, UI/ImageScale.js, UI/ImagePresets.js, UI/TimeSelector.js, Utility/InputValidator.js, Utility/SettingsLoader.js, Utility/UserSettings.js, Utility/Tutorial.js, Tiling/Manager/LayerManager.js, Events/EventManager.js, Events/EventType.js, Events/EventTree.js, Events/EventFeatureRecognitionMethod.js, Events/EventLayerManager.js, Events/EventMarker.js, Events/EventLayerManager.js, Events/HelioviewerEventLayer.js, Events/HelioviewerEventLayerManager.js, HelioviewerEmbeddedClient.js"/>
<filelist dir="resources/js" files="UI/TileLayerData.js, Utility/Config.js, Utility/HelperFunctions.js, Tiling/Layer/Layer.js, Tiling/Layer/TileLoader.js, Tiling/Layer/TileLayer.js, Tiling/Layer/HelioviewerTileLayer.js, Utility/KeyboardManager.js, Tiling/Manager/LayerManager.js, Tiling/Manager/TileLayerManager.js, Tiling/Manager/HelioviewerTileLayerManager.js, Image/JP2Image.js, Viewport/Helper/MouseCoordinates.js, Viewport/Helper/HelioviewerMouseCoordinates.js, Viewport/Helper/SandboxHelper.js, Viewport/Helper/ViewportMovementHelper.js, Viewport/HelioviewerViewport.js, HelioviewerClient.js, UI/ZoomControls.js, UI/ImageScale.js, UI/ImagePresets.js, UI/TimeSelector.js, Utility/InputValidator.js, Utility/SettingsLoader.js, Utility/UserSettings.js, Utility/Tutorial.js, Tiling/Manager/LayerManager.js, Events/EventManager.js, Events/EventType.js, Events/EventTree.js, Events/EventFeatureRecognitionMethod.js, Events/EventLayerManager.js, Events/EventMarker.js, Events/EventLayerManager.js, Events/HelioviewerEventLayer.js, Events/HelioviewerEventLayerManager.js, HelioviewerEmbeddedClient.js"/>
</concat>

<echo>concatenating CSS...</echo>
Expand Down
74 changes: 54 additions & 20 deletions resources/js/UI/TileLayerAccordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,30 @@ var TileLayerAccordion = Layer.extend(
index = 1000;
}

this._createAccordionEntry(index, id, name, sourceId, visible, startOpened);
//this._initTreeSelect(id, hierarchy);
this._initTreeSelect(id, sourceId, date, difference, diffCount, diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate, name, hierarchy);
this._initOpacitySlider(id, opacity, onOpacityChange);
this._initDifference(id, sourceId, date, difference, diffCount, diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate, name, hierarchy);
// store tile layer params in bundle object
var tileLayerData = new TileLayerData(id, sourceId, difference, diffCount,
diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate,
hierarchy, index, name, visible, startOpened, opacity, onOpacityChange);

this._createAccordionEntry(tileLayerData);
this._initTreeSelect(tileLayerData);
this._initOpacitySlider(tileLayerData);
this._initDifference(tileLayerData);
this._setupEventHandlers(id);
//this._updateTimeStamp(id, date);
},

/**
*
*/
_createAccordionEntry: function (index, id, name, sourceId, visible, startOpened) {
var visibilityBtn, removeBtn, hidden, head, body;
_createAccordionEntry: function (tileLayerData) {
var visibilityBtn, removeBtn, hidden, head, body,
index = tileLayerData.index,
id = tileLayerData.id,
name = tileLayerData.name,
sourceId = tileLayerData.sourceId,
visible = tileLayerData.visible,
startOpened = tileLayerData.startOpened;

// initial visibility
hidden = (visible ? "fa fa-eye fa-fw layerManagerBtn visible" : "fa fa-eye-slash fa-fw layerManagerBtn visible hidden");
Expand Down Expand Up @@ -133,12 +143,13 @@ var TileLayerAccordion = Layer.extend(
/**
*
*/
//_initTreeSelect: function (id, hierarchy) {
_initTreeSelect: function(id, sourceId, date, difference, diffCount, diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate, name, hierarchy) {
var ids = new Array(),
selected = new Array(),
letters = ['a','b','c','d','e'],
self = this;
_initTreeSelect: function(tileLayerData) {
var ids = new Array(),
selected = new Array(),
letters = ['a','b','c','d','e'],
self = this,
id = tileLayerData.id,
hierarchy = tileLayerData.hierarchy;

$.each( letters, function (i, letter) {
ids.push('#'+letter+'-select-'+id);
Expand All @@ -158,8 +169,15 @@ var TileLayerAccordion = Layer.extend(
'label': obj['label'],
'name' : obj['name'] };
});
difference = parseInt($('#'+id+' .layer-select-difference').val());
self._initDifference(id, leaf.sourceId, date, difference, diffCount, diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate, leaf.nickname, leaf.uiLabels);

//update the tile layer data
tileLayerData.difference = parseInt($('#'+id+' .layer-select-difference').val());
tileLayerData.sourceId = leaf.sourceId;
tileLayerData.name = leaf.nickname;
tileLayerData.hierarchy = leaf.uiLabels;
//re-init the callbacks
self._initDifference(tileLayerData);

$(document).trigger("tile-layer-data-source-changed",
[id, hierarchySelected, leaf.sourceId, leaf.nickname,
leaf.layeringOrder]);
Expand All @@ -170,7 +188,11 @@ var TileLayerAccordion = Layer.extend(
/**
*
*/
_initOpacitySlider: function (id, opacity, onOpacityChange) {
_initOpacitySlider: function (tileLayerData) {
var id = tileLayerData.id,
opacity = tileLayerData.opacity,
onOpacityChange = tileLayerData.onOpacityChange;

$("#opacity-slider-track-" + id).slider({
value: opacity,
min : 0,
Expand All @@ -190,8 +212,22 @@ var TileLayerAccordion = Layer.extend(
/**
*
*/
_initDifference: function (id, sourceId, date, difference, diffCount, diffTime, baseDiffTime, onDifference, onDiffCount, onDiffTime, onDiffDate, name, hierarchy){
var self = this;
_initDifference: function (tileLayerData){

//extract necessary params from data object
var self = this,
id = tileLayerData.id,
sourceId = tileLayerData.sourceId,
difference = tileLayerData.difference,
diffCount = tileLayerData.diffCount,
diffTime = tileLayerData.diffTime,
baseDiffTime = tileLayerData.baseDiffTime,
onDifference = tileLayerData.onDifference,
onDiffCount = tileLayerData.onDiffCount,
onDiffTime = tileLayerData.onDiffTime,
onDiffDate = tileLayerData.onDiffDate,
name = tileLayerData.name,
hierarchy = tileLayerData.hierarchy;

//unbind previously initialized change listeners
$('#'+id+' .layer-select-difference').unbind('change');
Expand Down Expand Up @@ -676,8 +712,6 @@ var TileLayerAccordion = Layer.extend(
*
*/
_updateAccordionEntry: function (event, id, name, sourceId, opacity, date, imageId, hierarchy, imageName, difference, diffCount, diffTime, baseDiffTime) {
console.log('_updateAccordionEntry',sourceId);


var entry=$("#"+id), self=this, letters=['a','b','c','d','e'],
label, select;
Expand Down
26 changes: 26 additions & 0 deletions resources/js/UI/TileLayerData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//container object for params used during tile layer creation and mutation
class TileLayerData {
constructor(id, sourceId, difference, diffCount, diffTime, baseDiffTime,
onDifference, onDiffCount, onDiffTime, onDiffDate, hierarchy,
index, name, visible, startOpened, opacity, onOpacityChange){

this.id = id;
this.sourceId = sourceId;
this.difference = difference;
this.diffCount = diffCount;
this.diffTime = diffTime;
this.baseDiffTime = baseDiffTime;
this.onDifference = onDifference;
this.onDiffCount = onDiffCount;
this.onDiffTime = onDiffTime;
this.onDiffDate = onDiffDate;
this.hierarchy = hierarchy;
this.index = index;
this.name = name;
this.visible = visible;
this.startOpened = startOpened;
this.opacity = opacity;
this.onOpacityChange = onOpacityChange;

}
}

0 comments on commit 038a546

Please sign in to comment.