Skip to content

Commit

Permalink
gallery-2011.03.11-23-49 solmsted gallery-asynchronouscommandqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
YUI Builder committed Mar 11, 2011
1 parent fadacee commit 74be7f7
Show file tree
Hide file tree
Showing 14 changed files with 683 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.base.properties
@@ -0,0 +1,32 @@
# Asynchronous Command Queue Base Module Build Properties

# As long as the 'builder' project is cloned to the default folder
# next to the 'yui3-gallery' project folder, the 'builddir' property does not
# need to be changed
#
# If the 'builder' project is checked out to an alternate location, this
# property should be updated to point to the checkout location.
builddir=../../../builder/componentbuild

global.src.component=../../src/gallery-asynchronouscommandqueue
global.build.component=../../src/gallery-asynchronouscommandqueue

# The name of the component. E.g. event, attribute, widget
component=gallery-asynchronouscommandqueue-base

# The list of files which should be concatenated to create the component
# NOTE: For a css component. (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
# component.jsfiles=my.custom.module.js, my.custom.moduleHelperClass.js, my.custom.moduleSubComponentClass.js
component.jsfiles=asynchronouscommandqueue.js

# The list of modules this component. requires. Used to set up the Y.add module call for YUI 3.
component.requires=base

# The list of modules this component. supersedes. Used to set up the Y.add module call for YUI 3.
component.supersedes=

# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
component.optional=

# If your module has a skin file, set this flag to "true"
component.skinnable=false
7 changes: 7 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.base.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- YUI 3 Gallery Component Build File -->
<project name="Asynchronous Command Queue Module" default="local">
<description>Asynchronous Command Queue Base Module Build File</description>
<property file="build.base.properties" />
<import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
</project>
32 changes: 32 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.command.properties
@@ -0,0 +1,32 @@
# Asynchronous Command Module Build Properties

# As long as the 'builder' project is cloned to the default folder
# next to the 'yui3-gallery' project folder, the 'builddir' property does not
# need to be changed
#
# If the 'builder' project is checked out to an alternate location, this
# property should be updated to point to the checkout location.
builddir=../../../builder/componentbuild

global.src.component=../../src/gallery-asynchronouscommandqueue
global.build.component=../../src/gallery-asynchronouscommandqueue

# The name of the component. E.g. event, attribute, widget
component=gallery-asynchronouscommand

# The list of files which should be concatenated to create the component
# NOTE: For a css component. (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
# component.jsfiles=my.custom.module.js, my.custom.moduleHelperClass.js, my.custom.moduleSubComponentClass.js
component.jsfiles=asynchronouscommand.js

# The list of modules this component. requires. Used to set up the Y.add module call for YUI 3.
component.requires=base

# The list of modules this component. supersedes. Used to set up the Y.add module call for YUI 3.
component.supersedes=

# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
component.optional=

# If your module has a skin file, set this flag to "true"
component.skinnable=false
7 changes: 7 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.command.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- YUI 3 Gallery Component Build File -->
<project name="Asynchronous Command Queue Module" default="local">
<description>Asynchronous Command Module Build File</description>
<property file="build.command.properties" />
<import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
</project>
24 changes: 24 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.properties
@@ -0,0 +1,24 @@
# Asynchronous Command Queue Module Build Properties

# As long as the 'builder' project is cloned to the default folder
# next to the 'yui3-gallery' project folder, the 'builddir' property does not
# need to be changed
#
# If the 'builder' project is checked out to an alternate location, this
# property should be updated to point to the checkout location.
builddir=../../../builder/componentbuild

# The name of the component. E.g. event, attribute, widget
component=gallery-asynchronouscommandqueue
component.rollup=true

# Path to sub-module build files
component.rollup.modules.buildfiles=build.base.xml build.command.xml

global.build.component=../../build/gallery-asynchronouscommandqueue

# The list of modules this component. requires. Used to set up the Y.add module call for YUI 3.
component.requires=gallery-asynchronouscommand, gallery-asynchronouscommandqueue-base

# If your module has a skin file, set this flag to "true"
component.skinnable=false
7 changes: 7 additions & 0 deletions src/gallery-asynchronouscommandqueue/build.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- YUI 3 Gallery Component Build File -->
<project name="Asynchronous Command Queue Module" default="local">
<description>Asynchronous Command Queue Module Build File</description>
<property file="build.properties" />
<import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
</project>
@@ -0,0 +1,79 @@
YUI.add('gallery-asynchronouscommand', function(Y) {

'use strict';

var _class;

_class = function (config) {
_class.superclass.constructor.call(this, config);
};

_class.ATTRS = {
args: {
value: [],
writeOnce: 'initOnly'
},
completed: {
readOnly: true,
value: false
},
context: {
value: Y.config.win,
writeOnce: 'initOnly'
},
delay: {
readOnly: true,
value: 0
},
fn: {
value: function (asynchronousCommand) {
asynchronousCommand.fire('complete');
},
writeOnce: 'initOnly'
},
started: {
readOnly: true,
value: false
}
};
_class.NAME = 'AsynchronousCommand';

Y.extend(_class, Y.Base, {
execute: function () {
Y.later(this.get('delay'), this, function () {
this.fire('start');
this.get('fn').apply(this.get('context'), this.get('args'));
});
return this;
},
initializer: function () {
this.publish('complete', {
fireOnce: true
});
this.publish('start', {
fireOnce: true
});

var args = this.get('args');

if (!Y.Lang.isArray(args)) {
args = [args];
}

args.unshift(this);
this._set('args', args);

this.on('complete', function () {
this._set('completed', true);
}, this);

this.on('start', function () {
this._set('started', true);
}, this);
}
});

Y.AsynchronousCommand = _class;


}, '@VERSION@' ,{skinnable:false, requires:['base']});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,79 @@
YUI.add('gallery-asynchronouscommand', function(Y) {

'use strict';

var _class;

_class = function (config) {
_class.superclass.constructor.call(this, config);
};

_class.ATTRS = {
args: {
value: [],
writeOnce: 'initOnly'
},
completed: {
readOnly: true,
value: false
},
context: {
value: Y.config.win,
writeOnce: 'initOnly'
},
delay: {
readOnly: true,
value: 0
},
fn: {
value: function (asynchronousCommand) {
asynchronousCommand.fire('complete');
},
writeOnce: 'initOnly'
},
started: {
readOnly: true,
value: false
}
};
_class.NAME = 'AsynchronousCommand';

Y.extend(_class, Y.Base, {
execute: function () {
Y.later(this.get('delay'), this, function () {
this.fire('start');
this.get('fn').apply(this.get('context'), this.get('args'));
});
return this;
},
initializer: function () {
this.publish('complete', {
fireOnce: true
});
this.publish('start', {
fireOnce: true
});

var args = this.get('args');

if (!Y.Lang.isArray(args)) {
args = [args];
}

args.unshift(this);
this._set('args', args);

this.on('complete', function () {
this._set('completed', true);
}, this);

this.on('start', function () {
this._set('started', true);
}, this);
}
});

Y.AsynchronousCommand = _class;


}, '@VERSION@' ,{skinnable:false, requires:['base']});
@@ -0,0 +1,115 @@
YUI.add('gallery-asynchronouscommandqueue-base', function(Y) {

'use strict';

var _class;

_class = function (config) {
_class.superclass.constructor.call(this, config);
};

_class.ATTRS = {
completed: {
readOnly: true,
value: false
},
paused: {
value: false
},
started: {
readOnly: true,
value: false
},
queue: {
value: [],
writeOnce: 'initOnly'
}
};
_class.NAME = 'AsynchronousCommandQueue';

Y.extend(_class, Y.Base, {
addCommand: function (asynchronousCommand) {
this.get('queue').push(asynchronousCommand);
return this;
},
getCommandCount: function () {
return this.get('queue.length');
},
initializer: function () {
this.publish('complete', {
fireOnce: true
});
this.publish('pause');
this.publish('resume');
this.publish('start', {
fireOnce: true
});

this.on('complete', function (eventFacade, response, args) {
this._set('completed', true);
}, this);

this.on('start', function (eventFacade, response, args) {
this._set('started', true);
}, this);
},
pauseQueue: function () {
this.set('paused', true);
this.fire('pause');
return this;
},
resumeQueue: function () {
this.set('paused', false);
this.fire('resume');
return this.startQueue();
},
startAll: function () {
var commandCount,
completeCount = 0,
i,
startCommand,
queue = this.get('queue');

startCommand = function (asynchronousCommand) {
asynchronousCommand.execute().on('complete', function () {
completeCount += 1;
if (completeCount === commandCount) {
this._set('queue', queue.slice(commandCount));
if (this.get('queue.length')) {
this.startAll();
} else {
this.fire('complete');
}
}
}, this);
};

this.fire('start');

for (i = 0, commandCount = queue.length; i < commandCount; i += 1) {
startCommand.call(this, queue[i]);
}

return this;
},
startQueue: function () {
if (this.get('paused')) {
return this;
} else if (!this.get('queue.length')) {
this.fire('complete');
return this;
}

this.fire('start');
this.get('queue').shift().execute().on('complete', function () {
this.startQueue();
}, this);

return this;
}
});

Y.AsynchronousCommandQueue = _class;


}, '@VERSION@' ,{skinnable:false, requires:['base']});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 74be7f7

Please sign in to comment.