Skip to content

Commit

Permalink
gallery-2010.06.30-19-54 apipkin gallery-plugin-node-io
Browse files Browse the repository at this point in the history
  • Loading branch information
YUI Builder committed Jun 30, 2010
1 parent e1fef10 commit b4fab58
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/gallery-plugin-node-io/build.properties
@@ -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=

7 changes: 7 additions & 0 deletions src/gallery-plugin-node-io/build.xml
@@ -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>
84 changes: 84 additions & 0 deletions src/gallery-plugin-node-io/js/plugin-node-io.js
@@ -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;

0 comments on commit b4fab58

Please sign in to comment.