Skip to content

Commit

Permalink
Merge pull request #932 from IIIF/532-global-window-settings
Browse files Browse the repository at this point in the history
532 global window settings
  • Loading branch information
aeschylus committed May 18, 2016
2 parents f401c6f + 6808c2c commit fb5e7df
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 182 deletions.
85 changes: 40 additions & 45 deletions js/src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,54 +38,49 @@
//only valid if no windowObjects have been initialized
//if there are multiple slots, it will be bound to the first slot and the selected manifest will open in that slot

//default window settings, but can be changed in Mirador configuration on initialization
'windowSettings' : {
"availableViews" : ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], //any subset removes others
"viewType" : 'ThumbnailsView', //one of [_'ThumbnailsView'_, 'ImageView', 'ScrollView', 'BookView'] - if using availableViews, must be in subset
"bottomPanel" : true, //whether or not to make the bottom panel available in this window
"bottomPanelVisible" : true, //whether or not to make the bottom panel visible in this window on load. This setting is dependent on bottomPanel being true
"sidePanel" : true, //whether or not to make the side panel available in this window
//control what is available in the side panel. if "sidePanel" is false, these options won't be applied
"sidePanelOptions" : {
"toc" : true,
"annotations" : false
},
"sidePanelVisible" : true, //whether or not to make the side panel visible in this window on load. This setting is dependent on sidePanel being true
"overlay" : true, //whether or not to make the metadata overlay available/visible in this window
"annotationLayer" : true, //whether or not to make annotation layer available in this window
"annotationCreation" : true, /*whether or not to make annotation creation available in this window,
only valid if annotationLayer is set to True and an annotationEndpoint is defined.
This setting does NOT affect whether or not a user can edit an individual annotation that has already been created.*/
"annotationState" : 'annoOff', //[_'annoOff'_, 'annoOnCreateOff', 'annoOnCreateOn'] whether or not to turn on the annotation layer on window load
"fullScreen" : true, //whether or not to make the window's fullScreen button visible to user
"displayLayout" : true, //whether or not to display all layout options, removing individual menu options is separate
//control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied
"layoutOptions" : {
"newObject" : true,
"close" : true,
"slotRight" : true,
"slotLeft" : true,
"slotAbove" : true,
"slotBelow" : true,
}
},

'windowObjects' : [
/** within a single object, the following options:
* "loadedManifest": [manifestURI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json"
* "canvasID": [canvas URI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/canvas/canvas-12"
*
* "availableViews" : defaults to ['ThumbnailsView', 'ImageView', 'ScrollView', 'BookView'], any subset removes others
* "viewType" : one of [_'ThumbnailsView'_, 'ImageView', 'ScrollView', 'BookView'] - if using availableViews, must be in subset
*
* "bottomPanel" : [_true_, false] whether or not to make the bottom panel available in this window
* "bottomPanelVisible" : [_true_, false] whether or not to make the bottom panel visible in this window on load. This setting is dependent
* on bottomPanel being true
* "sidePanel" : [_true_, false] whether or not to make the side panel available in this window
* "sidePanelOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied
* {
* "toc" : [_true_, false]
* "annotations" : [true, _false_]
* }
* "sidePanelVisible" : [_true_, false] whether or not to make the side panel visible in this window on load. This setting is dependent
* on sidePanel being true
* "overlay" : [_true_, false] whether or not to make the overlay available/visible in this window
*
* "annotationLayer" : [_true_, false] whether or not to make annotation layer available in this window
* "annotationCreation" : [_true_, false] whether or not to make annotation creation available in this window,
* only valid if annotationLayer is set to True and an annotationEndpoint is defined.
* This setting does NOT affect whether or not a user can edit an individual annotation that has already been created.
* "annotationState" : [_'annoOff'_, 'annoOnCreateOff', 'annoOnCreateOn'] whether or not to turn on the annotation layer on window load
*
* "fullScreen" : [_true_, false] whether or not to make the fullScreen HUD button visible to user
*
* "displayLayout" : [_true_, false], whether or not to display all layout options, removing individual menu options is separate
* "layoutOptions" : control individual menu items in layout menu. if "displayLayout" is false, these options won't be applied
* {
* "newObject" : [_true_, false]
* "close" : [_true_, false]
* "slotRight" : [_true_, false]
* "slotLeft" : [_true_, false]
* "slotAbove" : [_true_, false]
* "slotBelow" : [_true_, false]
* }
* "windowOptions" : [data specific to the view type, such as OSD bounds and zoom level - automatically saved in SaveController]
* "id" : [unique window ID - set by application and automatically saved in SaveController]
**/
/* Using the same settings listed in `windowSettings`, change the settings for a specific window
* Structured as an array of objects
* A few additional settings only available in `windowObjecs`
* "loadedManifest": [manifestURI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/manifest.json"
* "canvasID": [canvas URI] e.g. "http://dms-data.stanford.edu/data/manifests/Walters/qm670kv1873/canvas/canvas-12"
* "id" : [unique window ID - set by application and automatically saved in SaveController]
* "windowOptions" : [data specific to the view type, such as OSD bounds and zoom level - automatically saved in SaveController]
*/
],

'defaultWindowSettings': {

},

// Control for whether or not to auto hide controls on the OSD canvas and specific durations in milliseconds
// durations assume `autoHideControls` is true
'autoHideControls': true,
Expand Down
26 changes: 4 additions & 22 deletions js/src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,34 +280,16 @@
loadManifestFromConfig: function(options) {
// check if there are available slots, otherwise don't process this object from config
//if we have more windowObjects that slots in the layout, return
// it may not be necesary to set the slotAddress here since it is also covered in workspace
var _this = this;
var slotAddress = options.slotAddress ? options.slotAddress : this.workspace.getAvailableSlot() ? this.workspace.getAvailableSlot().layoutAddress : null;
options.slotAddress = slotAddress;
if (!slotAddress) {
return;
}

var windowConfig = {
manifest: this.state.getStateProperty('manifests')[options.loadedManifest],
currentFocus : options.viewType,
focusesOriginal : options.availableViews,
currentCanvasID : options.canvasID,
id : options.id,
focusOptions : options.windowOptions,
bottomPanelAvailable : options.bottomPanel,
bottomPanelVisible : options.bottomPanelVisible,
sidePanelAvailable : options.sidePanel,
sidePanelOptions : options.sidePanelOptions,
sidePanelVisible : options.sidePanelVisible,
overlayAvailable : options.overlay,
annotationLayerAvailable : options.annotationLayer,
annotationCreationAvailable : options.annotationCreation,
annotationState : options.annotationState,
fullScreenAvailable : options.fullScreen,
slotAddress: slotAddress,
displayLayout : options.displayLayout,
layoutOptions: options.layoutOptions
};

//make a copy of options and pass that so we don't get a circular reference
var windowConfig = jQuery.extend(true, {}, options);
_this.eventEmitter.publish('ADD_WINDOW', windowConfig);
}
};
Expand Down
8 changes: 4 additions & 4 deletions js/src/viewer/manifestListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@
this.element.on('click', function() {
var windowConfig = {
manifest: _this.manifest,
currentCanvasID: null,
currentFocus: 'ThumbnailsView'
canvasID: null,
viewType: 'ThumbnailsView'
};
_this.eventEmitter.publish('ADD_WINDOW', windowConfig);
});
Expand All @@ -151,8 +151,8 @@
e.stopPropagation();
var windowConfig = {
manifest: _this.manifest,
currentCanvasID: jQuery(this).attr('data-image-id'),
currentFocus: 'ImageView'
canvasID: jQuery(this).attr('data-image-id'),
viewType: _this.state.getStateProperty('windowSettings').viewType //get the view type from settings rather than always defaulting to ImageView
};
_this.eventEmitter.publish('ADD_WINDOW', windowConfig);
});
Expand Down
30 changes: 27 additions & 3 deletions js/src/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@
slotAddress: slot.layoutAddress,
state: _this.state,
appendTo: slot.element,
currentCanvasID: window.currentCanvasID,
currentFOcus: window.currentFocus
canvasID: window.canvasID,
viewType: window.viewType
});
});
},
Expand Down Expand Up @@ -480,7 +480,31 @@
windowConfig.id = windowConfig.id || $.genUUID();

_this.eventEmitter.publish("windowSlotAdded", {id: windowConfig.id, slotAddress: windowConfig.slotAddress});
newWindow = new $.Window(windowConfig);

//extend the windowConfig with the default settings
var mergedConfig = jQuery.extend(true, {}, _this.state.getStateProperty('windowSettings'), windowConfig);

//"rename" some keys in the merged object to align settings parameters with window parameters
if (mergedConfig.loadedManifest) {
mergedConfig.manifest = _this.state.getStateProperty('manifests')[mergedConfig.loadedManifest];
delete mergedConfig.loadedManifest;
}

if (mergedConfig.bottomPanel) {
mergedConfig.bottomPanelAvailable = mergedConfig.bottomPanel;
delete mergedConfig.bottomPanel;
}

if (mergedConfig.sidePanel) {
mergedConfig.sidePanelAvailable = mergedConfig.sidePanel;
delete mergedConfig.sidePanel;
}

if (mergedConfig.overlay) {
mergedConfig.overlayAvailable = mergedConfig.overlay;
delete mergedConfig.overlay;
}
newWindow = new $.Window(mergedConfig);
_this.windows.push(newWindow);

targetSlot.window = newWindow;
Expand Down
8 changes: 4 additions & 4 deletions js/src/workspaces/slot.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
// image view. If we don't specify the focus, the
// window will open in thumbnail view with the
// chosen page highlighted.
windowConfig.currentCanvasID = canvasId;
windowConfig.currentFocus = 'ImageView';
windowConfig.canvasID = canvasId;
windowConfig.viewType = 'ImageView';
}

_this.eventEmitter.publish('ADD_WINDOW', windowConfig);
Expand Down Expand Up @@ -206,8 +206,8 @@
// image view. If we don't specify the focus, the
// window will open in thumbnail view with the
// chosen page highlighted.
windowConfig.currentCanvasID = canvasId;
windowConfig.currentFocus = 'ImageView';
windowConfig.canvasID = canvasId;
windowConfig.viewType = 'ImageView';
}

_this.eventEmitter.publish('ADD_WINDOW', windowConfig);
Expand Down

0 comments on commit fb5e7df

Please sign in to comment.