@@ -53,7 +53,7 @@ var feature = function (arg) {
53
53
54
54
// Don't bind handlers for improved performance on features that don't
55
55
// require it.
56
- if ( ! m_selectionAPI ) {
56
+ if ( ! this . selectionAPI ( ) ) {
57
57
return ;
58
58
}
59
59
@@ -413,24 +413,37 @@ var feature = function (arg) {
413
413
////////////////////////////////////////////////////////////////////////////
414
414
/**
415
415
* Get/Set visibility of the feature
416
+ *
417
+ * @param {boolean|undefined } val: undefined to return the visibility, a
418
+ * boolean to change the visibility.
419
+ * @param {boolean } direct: if true, when getting the visibility, disregard
420
+ * the visibility of the parent layer, and when setting, refresh the state
421
+ * regardless of whether it has changed or not.
422
+ * @return {boolean|object } either the visibility (if getting) or the feature
423
+ * (if setting).
416
424
*/
417
425
////////////////////////////////////////////////////////////////////////////
418
- this . visible = function ( val ) {
426
+ this . visible = function ( val , direct ) {
419
427
if ( val === undefined ) {
428
+ if ( ! direct && m_layer && m_layer . visible && ! m_layer . visible ( ) ) {
429
+ return false ;
430
+ }
420
431
return m_visible ;
421
432
}
422
- if ( m_visible !== val ) {
433
+ if ( m_visible !== val || direct ) {
423
434
m_visible = val ;
424
435
m_this . modified ( ) ;
425
-
436
+ if ( m_layer && m_layer . visible && ! m_layer . visible ( ) ) {
437
+ val = false ;
438
+ }
426
439
// bind or unbind mouse handlers on visibility change
427
- if ( m_visible ) {
440
+ if ( val ) {
428
441
m_this . _bindMouseHandlers ( ) ;
429
442
} else {
430
443
m_this . _unbindMouseHandlers ( ) ;
431
444
}
432
445
for ( var i = 0 ; i < m_dependentFeatures . length ; i += 1 ) {
433
- m_dependentFeatures [ i ] . visible ( val ) ;
446
+ m_dependentFeatures [ i ] . visible ( m_visible , direct ) ;
434
447
}
435
448
}
436
449
return m_this ;
@@ -532,16 +545,26 @@ var feature = function (arg) {
532
545
533
546
////////////////////////////////////////////////////////////////////////////
534
547
/**
535
- * Query or set if the selection API is enabled for this feature.
536
- * @returns {bool }
548
+ * Get/Set if the selection API is enabled for this feature.
549
+ *
550
+ * @param {boolean|undefined } val: undefined to return the selectionAPI
551
+ * state, or a boolean to change the state.
552
+ * @param {boolean } direct: if true, when getting the selectionAPI state,
553
+ * disregard the state of the parent layer, and when setting, refresh the
554
+ * state regardless of whether it has changed or not.
555
+ * @return {boolean|object } either the selectionAPI state (if getting) or the
556
+ * feature (if setting).
537
557
*/
538
558
////////////////////////////////////////////////////////////////////////////
539
- this . selectionAPI = function ( arg ) {
559
+ this . selectionAPI = function ( arg , direct ) {
540
560
if ( arg === undefined ) {
561
+ if ( ! direct && m_layer && m_layer . selectionAPI && ! m_layer . selectionAPI ( ) ) {
562
+ return false ;
563
+ }
541
564
return m_selectionAPI ;
542
565
}
543
566
arg = ! ! arg ;
544
- if ( arg !== m_selectionAPI ) {
567
+ if ( arg !== m_selectionAPI || direct ) {
545
568
m_selectionAPI = arg ;
546
569
this . _unbindMouseHandlers ( ) ;
547
570
this . _bindMouseHandlers ( ) ;
0 commit comments