API Docs for: undefined
Show:

File: js/async-progress.js

  1. /**
  2.  * @module gallery-async-progress
  3.  */
  4. (function (Y, moduleName) {
  5.     'use strict';
  6.    
  7.     var _string_progress = 'progress',
  8.        
  9.         _Plugin = Y.Plugin,
  10.        
  11.         _invoke = Y.Array.invoke;

  12.     /**
  13.      * Asynchronous command runner progress plugin.
  14.      * @class Plugin.AsyncProgress
  15.      * @extends Plugin.Base
  16.      * @param {Object} config Configuration Object.
  17.      */
  18.     _Plugin.AsyncProgress = Y.Base.create(moduleName, _Plugin.Base, [], {
  19.         destructor: function () {
  20.             _invoke(this._subs, 'detach');
  21.         },
  22.         initializer: function () {
  23.             var completed = 0,
  24.                 host = this.get('host'),
  25.                 run = host.get('run'),
  26.                 total = run.length;
  27.                
  28.             this._subs = _invoke(run, 'on', 'complete', function () {
  29.                 completed += 1;
  30.                
  31.                 /**
  32.                  * @event progress
  33.                  * @for Async
  34.                  * @param {Number} completed
  35.                  * @param {Number} total
  36.                  */
  37.                 host.fire(_string_progress, {
  38.                     completed: completed,
  39.                     total: total
  40.                 });
  41.             });
  42.         }
  43.     }, {
  44.         NS: _string_progress
  45.     });
  46. }(Y, arguments[1]));
  47.