Compare commits

...

11 Commits

Author SHA1 Message Date
Ian Gilman
d956b2ae9d
Merge pull request #2166 from joedf/patch-for-PR-1303
Patch for #1303
2022-06-13 13:49:17 -07:00
Joachim de fourestier
3ca17c1508 missing period 2022-06-08 20:15:21 -04:00
Joachim de fourestier
ff4f88dc64 add some documentation 2022-06-08 20:05:43 -04:00
Joe DF
df0e598e38 fix typo 2022-05-29 21:38:38 -04:00
Joe DF
3661d6cae5 remove auto code 2022-05-29 21:31:29 -04:00
Joe DF
9772901d71 Don't overwrite the element's id if it has one already 2022-05-29 21:30:48 -04:00
Joe DF
4a877d60f7 remove unneeded code, not sure how it got there 2022-05-29 21:23:22 -04:00
Joe DF
ca368797b0 restructure again to make less confusing, less duplicate code 2022-05-29 21:18:28 -04:00
Joe DF
d4dfcd2288 fix inconsistent open-close braces, add warn when using element even when id provided 2022-05-29 20:53:11 -04:00
Joe DF
21146b6b2c Merge remote-tracking branch 'cameronbaney/add-element-option-navigator' into patch-for-PR-1303 2022-05-29 20:33:23 -04:00
Cameron Baney
4301254fa0 Allow user to add element option for navigator 2017-09-05 14:05:36 -04:00

View File

@ -45,7 +45,9 @@
* @memberof OpenSeadragon
* @extends OpenSeadragon.Viewer
* @extends OpenSeadragon.EventSource
* @param {Object} options
* @param {Object} options - Navigator options
* @param {Element} [options.element] - An element to use for the navigator.
* @param {String} [options.id] - Id of the element to use for the navigator. However, this is ignored if {@link options.element} is provided.
*/
$.Navigator = function( options ){
@ -55,8 +57,31 @@ $.Navigator = function( options ){
navigatorSize;
//We may need to create a new element and id if they did not
//provide the id for the existing element
if( !options.id ){
//provide the id for the existing element or the element itself
if( options.element || options.id ){
if ( options.element ) {
if ( options.id ){
$.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead.");
} else {
// Don't overwrite the element's id if it has one already
if ( options.element.id ) {
options.id = options.element.id;
} else {
options.id = 'navigator-' + $.now();
}
}
this.element = options.element;
} else {
this.element = document.getElementById( options.id );
}
options.controlOptions = {
anchor: $.ControlAnchor.NONE,
attachToViewer: false,
autoFade: false
};
} else {
options.id = 'navigator-' + $.now();
this.element = $.makeNeutralElement( "div" );
options.controlOptions = {
@ -82,14 +107,6 @@ $.Navigator = function( options ){
options.controlOptions.width = options.width;
}
}
} else {
this.element = document.getElementById( options.id );
options.controlOptions = {
anchor: $.ControlAnchor.NONE,
attachToViewer: false,
autoFade: false
};
}
this.element.id = options.id;
this.element.className += ' navigator';