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.06.30-19-54 apipkin gallery-plugin-node-io
- Loading branch information
YUI Builder
committed
Jun 30, 2010
1 parent
e1fef10
commit b4fab58
Showing
3 changed files
with
118 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,27 @@ | ||
# Node IO 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-plugin-node-io | ||
|
||
# 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=plugin-node-io.js, plugin-node-ioHelperClass.js, plugin-node-ioSubComponentClass.js | ||
component.jsfiles=plugin-node-io.js | ||
|
||
# The list of modules this component requires. Used to set up the Y.add module call for YUI 3. | ||
component.requires=plugin,node,io | ||
|
||
# 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= | ||
|
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,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- YUI 3 Gallery Component Build File --> | ||
<project name="Node IO" default="local"> | ||
<description>Node IO 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,84 @@ | ||
var NodeIo; | ||
|
||
NodeIo = function(config) { | ||
NodeIo.superclass.constructor.apply(this,arguments); | ||
} | ||
|
||
Y.extend(NodeIo, Y.Plugin.Base, { | ||
_io : null, | ||
|
||
load : function(uri) { | ||
this.set('uri',uri); | ||
this.refresh(); | ||
}, | ||
|
||
refresh : function() { | ||
var ioConfig = this.get('ioConfig'); | ||
ioConfig.context = this; | ||
this._io = Y.io(this.get('uri'), ioConfig); | ||
}, | ||
|
||
abort : function() { | ||
return this._stopIO(); | ||
}, | ||
|
||
_stopIO : function() { | ||
try { | ||
this._io.abort(); | ||
}catch(e){ | ||
// no io to stop | ||
} | ||
return this; | ||
}, | ||
|
||
_placeContent : function(content) { | ||
var host = this.get('host'); | ||
switch(this.get('placement')) { | ||
case 'replace' : | ||
host.setContent(content); | ||
break; | ||
case 'prepend' : | ||
host.prepend(content); | ||
break; | ||
case 'append' : | ||
host.append(content); | ||
break; | ||
} | ||
} | ||
|
||
},{ | ||
NAME : 'node-io', | ||
NS : 'io', | ||
ATTRS : { | ||
uri : { | ||
setter : function(val) { | ||
this._stopIO(); | ||
return val; | ||
} | ||
}, | ||
placement : { | ||
value : 'replace', | ||
validator : function(val){ | ||
switch(val) { | ||
case 'replace': // overflow intentional | ||
case 'prepend': | ||
case 'append': | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
}, | ||
ioConfig : { | ||
value : { | ||
on : { | ||
success : function(id, o, args) { | ||
this._placeContent(o.responseText); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
Y.namespace('Plugin').NodeIo = NodeIo; |