forked from yui/yui3-gallery
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gallery-2010.11.03-19-46 ghinch gallery-datasource-manage-stale
- Loading branch information
YUI Builder
committed
Nov 3, 2010
1 parent
acc3dbd
commit b6089b5
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# MyComponent Build Properties | ||
|
||
# As long as the 'builder' project is cloned to the default folder | ||
# next to the 'yui3' 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-datasource-manage-stale | ||
|
||
# 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=manage-stale.js | ||
|
||
# The list of modules this component requires. Used to setup the Y.add module call for YUI 3. | ||
# NOTE: For a css component, this property is not used/required. | ||
|
||
# component.use, component.supersedes, component.optional and component.skinnable are other properties which can be defined | ||
component.requires=datasource-local | ||
component.builddir=../../tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- YUI 3 Component Build File --> | ||
|
||
<project name="DataSourceManageStale" default="local"> | ||
<description>Gallery DataSource Manage Stale Build File</description> | ||
<property file="build.properties" /> | ||
<import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" /> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
var IGNORE_STALE_RESPONSES = 'ignoreStaleResponses', | ||
CANCEL_STALE_REQUESTS = 'cancelStaleRequests', | ||
DATA = 'data', | ||
HOST = 'host', | ||
DEF_REQUEST_FN = '_defRequestFn'; | ||
|
||
Y.namespace('Plugin').DataSourceManageStale = Y.Base.create('datasource-manage-stale', Y.Plugin.Base, [], { | ||
_lastId : null, | ||
_transactions : null, | ||
|
||
_doBeforeData : function (e) { | ||
if (!this._transactions[e.tId] || (this.get(IGNORE_STALE_RESPONSES) && e.tId != this._lastId)) { | ||
e.halt(); | ||
} | ||
}, | ||
|
||
_doBeforeDefRequestFn : function (e) { | ||
if (this.get(CANCEL_STALE_REQUESTS)) { | ||
Y.Object.each(this._transactions, function (t, id) { | ||
if (t.abort) { | ||
t.abort(); | ||
delete this._transactions[id]; | ||
delete Y.DataSource.Local.transactions[id]; | ||
} | ||
}, this); | ||
} | ||
}, | ||
|
||
_doAfterDefRequestFn : function (e) { | ||
if (this.get(IGNORE_STALE_RESPONSES)) { | ||
this._lastId = e.tId; | ||
} | ||
|
||
this._transactions[e.tId] = Y.DataSource.Local.transactions[e.tId]; | ||
}, | ||
|
||
initializer : function () { | ||
this._transactions = {}; | ||
|
||
this.doBefore(DATA, this._doBeforeData, this); | ||
this.doBefore(DEF_REQUEST_FN, this._doBeforeDefRequestFn, this); | ||
this.doAfter(DEF_REQUEST_FN, this._doAfterDefRequestFn, this); | ||
} | ||
}, { | ||
NS : 'stale', | ||
|
||
ATTRS : { | ||
cancelStaleRequests : { | ||
value : false | ||
}, | ||
ignoreStaleResponses : { | ||
value : false | ||
} | ||
} | ||
}); |