sc_require("views/view"); SC.View.reopen( /** @scope SC.View.prototype */ { /** Set to YES to indicate the view has visibility support added. */ hasVisibility: YES, /** YES only if the view and all of its parent views are currently visible in the window. This property is used to optimize certain behaviors in the view. For example, updates to the view layer are not performed if the view until the view becomes visible in the window. */ isVisibleInWindow: NO, /** By default we don't disable the context menu. Overriding this property can enable/disable the context menu per view. */ isContextMenuEnabled: function() { return SC.CONTEXT_MENU_ENABLED; }.property(), /** Recomputes the isVisibleInWindow property based on the visibility of the view and its parent. If the recomputed value differs from the current isVisibleInWindow state, this method will also call recomputIsVisibleInWindow() on its child views as well. As an optional optimization, you can pass the isVisibleInWindow state of the parentView if you already know it. You will not generally need to call or override this method yourself. It is used by the SC.View hierarchy to relay window visibility changes up and down the chain. @property {Boolean} parentViewIsVisible @returns {SC.View} receiver */ recomputeIsVisibleInWindow: function(parentViewIsVisible) { var previous = this.get('isVisibleInWindow'), current = this.get('isVisible'), parentView; // isVisibleInWindow = isVisible && parentView.isVisibleInWindow // this approach only goes up to the parentView if necessary. if (current) { // If we weren't passed in 'parentViewIsVisible' (we generally aren't; // it's an optimization), then calculate it. if (parentViewIsVisible === undefined) { parentView = this.get('parentView'); parentViewIsVisible = parentView ? parentView.get('isVisibleInWindow') : NO; } current = current && parentViewIsVisible; } // If our visibility has changed, then set the new value and notify our // child views to update their value. if (previous !== current) { this.set('isVisibleInWindow', current); var childViews = this.get('childViews'), len = childViews.length, idx, view; for(idx=0;idx