MAF.system.BaseView

This component implements the basics for a view.

new MAF.system.BaseView()

The following properties are used in views:

  • this.config - properties passed at initiation
  • this.persist - Persistant storage for when the view gets reloaded.
  • this.cache - For storage of temporary data.
  • this.controls - References to view controls that will have state saving.
  • this.elements - References to view controls without state saving.

Methods

animate(config) inherited

Parameters:

NameTypeDescription
configObject

A config object

Fires:

createView() virtual

View creation method that must be implemented (or overridden) by objects that inherit the member.

destroyView() virtual

View destruction method that can be implemented (or overridden) by objects that inherit the member.

freeze() → {Class} inherited

Freezes this component. Screen renders no longer trigger until thawed.

Returns:

This component.

getAbsolutePosition() → {Object} inherited

Give back the position relative to its first positioned ancestor element

Returns:

{hOffset:Number, vOffset: Number}

getView() → {Class} inherited

Returns:

Returns the view this class is appended on.

hide() → {Class} inherited

Hides this component.

Returns:

This component.

hideView() virtual

View hide method that can be implemented (or overridden) by objects that inherit the member.

initialize() inherited

Initialize the class

initView() virtual

View initialization method that can be implemented (or overridden) by objects that inherit the member.

registerMessageCenterListenerCallback()

Register a function for callback on MAF.messages.

Example

var myView = new MAF.Class({
   initView: function() {
      this.registerMessageCenterListenerCallback(this.dataChanged);
      MAF.messages.store('news', 'The news is in.');
      MAF.messages.store('games', 'What games?');
   },
   dataChanged: function (event) {
      if (event.payload.value && !this.frozen) {
         switch (event.payload.key) {
            case 'news':
               //The view is visible and news is stored in MAF.messages
               break;
         }
      } else {
         switch (event.payload.key) {
            case 'news':
               //news is stored in MAF.messages and the view is not visible
               break;
         }
      }
      if (event.payload.key === 'games') {
         //Once this view has loaded we always do something when games is stored on MAF.messages.
         //Also when a different view is active.
      }
   }
});

registerMessageCenterListenerControl()

Register a component for callback on MAF.messages.

Example

var myView = new MAF.Class({
   createView: function () {
      this.controls.header = new MAF.control.Header({
         label: 'Header',
         events: {
            onBroadcast: function () {
               this.setText('Button randomized: ' + MAF.messages.fetch('button'));
            }
         }
      }).appendTo(this);

      this.controls.button = new MAF.control.TextButton({
         label: 'Random number stored',
         styles: {
            vOffset: this.controls.header.outerHeight
         },
         events: {
            onSelect: function () {
               MAF.messages.store('button', Number.random(1, 1000));
            }
         }
      }).appendTo(this);
   },
   updateView: function() {
      this.registerMessageCenterListenerControl(this.controls.header);
   }
});

selectView() virtual

View has gained focus method that can be implemented (or overridden) by objects that inherit the member.

show() → {Class} inherited

Shows this component.

Returns:

This component.

thaw() → {Class} inherited

Thawes this component. Screen renders can trigger again.

Returns:

This component.

unselectView() virtual

View has lost focus method that can be implemented (or overridden) by objects that inherit the member.

updateView() virtual

View update method that can be implemented (or overridden) by objects that inherit the member.

Events

onAnimationEnded

Fired when a animation on this component has ended.

onAppend

Fired when component has appended to a parent. Update visual appearances by applying a Theme style and rendering the skin.