API Docs for: undefined
Show:

File: js/async-command-delay.js

  1. /**
  2.  * @module gallery-async-command-delay
  3.  */
  4. (function (Y, moduleName) {
  5.     'use strict';
  6.    
  7.     var _string_delay = 'delay',
  8.         _string_delayed = 'delayed',
  9.         _string_run = 'run',
  10.        
  11.         _Do = Y.Do,
  12.         _DoAlterReturn = _Do.AlterReturn,
  13.         _DoPrevent = _Do.Prevent,
  14.         _Plugin = Y.Plugin,
  15.        
  16.         _delay = Y.delay;

  17.     /**
  18.      * Asynchronous command delay plugin.
  19.      * @class AsyncCommandDelay
  20.      * @extends Plugin.Base
  21.      * @namespace Plugin
  22.      * @param {Object} config Configuration Object.
  23.      */
  24.     _Plugin.AsyncCommandDelay = Y.Base.create(moduleName, _Plugin.Base, [], {
  25.         initializer: function () {
  26.             var me = this,
  27.            
  28.                 host = me.get('host'),
  29.                 run = host.run;
  30.            
  31.             me.afterHostMethod(_string_run, function () {
  32.                 return new _DoAlterReturn(_string_delayed, host);
  33.             });
  34.            
  35.             me.beforeHostMethod(_string_run, function () {
  36.                 _delay(run, me.get(_string_delay)).call(host);
  37.                 return new _DoPrevent(_string_delayed);
  38.             });
  39.         }
  40.     }, {
  41.         ATTRS: {
  42.             /**
  43.              * Approximate delay in milliseconds to wait between the time run is
  44.              * called and when the command function is executed.
  45.              * @attribute delay
  46.              * @default 0
  47.              * @initonly
  48.              * @type Number
  49.              */
  50.             delay: {
  51.                 value: 0,
  52.                 writeOnce: 'initOnly'
  53.             }
  54.         },
  55.         NS: _string_delay
  56.     });
  57. }(Y, arguments[1]));
  58.