Browse files

Moved around source and examples

  • Loading branch information...
1 parent d25aa65 commit 04778c4afc253a52cad687b36342c1ec6a44d22e @davglass committed Apr 6, 2010
View
113 README.textile
@@ -1,11 +1,11 @@
h1. YUI Bootstrapper for Node.js
This node.js module attempts to setup and bootstrap a working YUI 3 instance.
-It does not support any DOM manipulation, but it gives you our class management
-and language extras.
This module includes support for remote script loading via Y.Get.script() and remote data fetching via Y.io.
+See "JSDom Support" below for DOM manipulation.
+
h2. Setup this repo
Clone this project, then do this:
@@ -14,88 +14,49 @@ Clone this project, then do this:
git clone git://github.com/yui/yui3.git
</pre>
-You should go into that repo every now and then and do a git pull to keep it up to date.
+You should go into that repo every now and then and do a git pull to keep it up to date with the latest YUI source.
+
+
+h2. Node.js
+
+These tests and examples are all known to be working with latest stable Node.js: v0.1.33
+
+All of the examples and tests assume you nave @node@ in your path and they are all executable.
+
+h2. JSDom Support
-h2. Including the files
+Currently YUI 3 on Node.js supports "JSDom":http://github.com/tmpvar/jsom
+It also requires my forked "node-htmlparser":http://github.com/davglass/node-htmlparser
+
+Getting it up and running:
<pre class="console">
- // get the exported YUI object
- var YUI = require('./lib/node-yui3')).YUI;
+ mkdir ~/.node_libraries
+ cd ~/.node_libraries
+ wget http://github.com/tmpvar/jsdom/raw/master/lib/level1/core.js -O jsdom.js
+ wget http://github.com/tmpvar/jsdom/raw/master/lib/browser/index.js -O browser.js
+ wget http://github.com/davglass/node-htmlparser/raw/master/node-htmlparser.js
</pre>
-h2. Using YUI
+Now that the libraries are in the right places you can now use the dom related examples.
+
+h2. Examples
<pre class="console">
-// load YUI
-var YUI = require("./lib/node-yui3").YUI;
-
-//sys.puts('After: ' + sys.inspect(process.memoryUsage()));
-
-//Now use non-DOM related YUI utilities
-YUI({
- filter: 'debug',
- debug: true
-}).use('gallery-yql', 'json', 'base', 'io-nodejs', function(Y) {
-
- //sys.puts('Inside: ' + sys.inspect(process.memoryUsage()));
- //Logger outputs with sys.puts
- Y.log('This is a test');
- //Lang is available
- Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp');
-
- //Creating a simple class
- var One = function() {
- One.superclass.constructor.apply(this, arguments);
- };
- //Extending it with Y.Base so we have Custom Events and a lifecycle
- Y.extend(One, Y.Base, {
- test: function() {
- this.publish('foo', {
- emitFacade: true
- });
- this.fire('foo');
- }
- }, {
- NAME: 'one'
- });
-
- //Create a new instance of our new class
- var o = new One();
- o.on('foo', function(o) {
- Y.log('Foo Fired', 'debug', 'myapp');
- //Y.log(o, 'debug');
- });
- o.test(); //Should fire the one:foo Event.
-
- //Make a YQL query
- var q1 = new Y.yql('select * from github.user.info where (id = "davglass")');
- q1.on('query', function(r) {
- //Do something here.
- sys.puts(sys.inspect(r));
- });
-
- var url = 'http:/'+'/yuilibrary.com/gallery/api/user/davglass';
- //url = 'http:/'+'/query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%3D90210&format=json';
-
- Y.io(url, {
- xdr: {
- use: 'nodejs'
- },
- on: {
- start: function() {
- Y.log('Start IO', 'info', 'TEST');
- },
- success: function(id, o) {
- //Y.log(o.responseText);
- Y.log(Y.JSON.parse(o.responseText));
- }
- }
- });
-
-
-});
+ cd examples/
+ ./general-dom.js
+ ./io.js
+ ./library.js
</pre>
+h2. Tests
+
+When using JSDom, All relevent YUI 3 Dom & Selector tests pass. The ones that are skipped revolve around styles and postioning. Since there is no window or CSS cascade, these seem unimportant at the moment.
+
+<pre class="console">
+ cd ./tests/
+ ./dom.js
+ ./selector.js
+</pre>
-Now you can run @node ./test.js@
View
3 tabview-markup.js → examples/failing/tabview-markup.js
@@ -29,8 +29,9 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'tabview', function(Y) {
+}).use('nodejs-dom', 'event', 'node-base', 'tabview', function(Y) {
+ var document = Y.Browser.document;
Y.log('JSDom testing..');
//sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
View
79 examples/failing/tnt-datatable-script.js
@@ -0,0 +1,79 @@
+#!/usr/bin/env node
+var sys = require('sys'),
+ fs = require('fs');
+
+var YUI = require("./lib/node-yui3").YUI;
+
+// TODO: This should pass, but currently doesn't.
+// This will work for YUI core, but any submodules are in different files
+// This will work better once the 3.1.0 version of YUI is available
+// And you can combo handle all the submodules into one request.
+
+
+//require("assert").equal( global.YUI, undefined, "global yui created");
+
+
+//Now use non-DOM related YUI utilities
+YUI({
+ //Only set these if you want to load locally
+ loaderPath: 'loader/loader-debug.js',
+ base: './yui3/build/',
+ filter: 'debug',
+ _logExclude: {
+ 'attribute': true,
+ 'base': true,
+ 'get': true,
+ 'loader': true,
+ 'yui': true,
+ 'widget': true,
+ 'event': true
+ },
+ debug: true
+}).use('nodejs-dom', function(Y) {
+ document = Y.Browser.document;
+ navigator = Y.Browser.navigator;
+ window = Y.Browser.window;
+
+ Y.log('JSDom testing..');
+ Y.use('yui2-datatable', 'yui2-datasource', function(Y) {
+ var YAHOO = Y.YUI2;
+
+ var el = document.createElement('div');
+ el.id = 'basic';
+ document.body.appendChild(el);
+
+ YAHOO.example.Data = {
+ bookorders: [
+ {id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
+ {id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
+ {id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
+ {id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
+ ]
+ };
+
+
+ var myColumnDefs = [
+ {key:"id", sortable:true, resizeable:true},
+ {key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true},
+ {key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true},
+ {key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true},
+ {key:"title", sortable:true, resizeable:true}
+ ];
+
+ Y.log('Creating DataSource..');
+ var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders);
+ myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
+ myDataSource.responseSchema = {
+ fields: ["id","date","quantity","amount","title"]
+ };
+ Y.log('Creating DataTable..');
+
+ var myDataTable = new YAHOO.widget.DataTable("basic",
+ myColumnDefs, myDataSource, {caption:"DataTable Caption"});
+
+ myDataTable.on('renderEvent', function() {
+ Y.log('Done..');
+ Y.log(document.body.outerHTML, 'HTML');
+ });
+ });
+});
View
10 general-dom.js → examples/general-dom.js
@@ -2,7 +2,7 @@
var sys = require('sys');
-var YUI = require("./lib/node-yui3").YUI;
+var YUI = require("../lib/node-yui3").YUI;
// TODO: This should pass, but currently doesn't.
// This will work for YUI core, but any submodules are in different files
@@ -19,7 +19,7 @@ YUI({
loaderPath: 'loader/loader-debug.js',
base: './yui3/build/',
filter: 'debug',
- logExclude: {
+ _logExclude: {
'attribute': true,
'base': true,
'get': true,
@@ -29,19 +29,19 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'tabview', function(Y) {
+}).use('nodejs-dom', 'event', 'node', function(Y) {
Y.log('JSDom testing..');
//sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
-
+ var document = Y.Browser.document;
var i = Y.Node.create('<i>Test This</i>');
i.addClass('foo');
Y.one('body').append(i);
var div = document.createElement('div');
div.id = 'foo';
- div.innerHTML = '<em id="foo:bar">Test</em> this <strong id="bax">awesome <u>shit..</u></strong>';
+ div.innerHTML = '<em id="foo">Test</em> this <strong id="bax">awesome <u id="foo:bar">shit..</u></strong>';
document.body.appendChild(div);
var foo = Y.one('#foo');
View
6 io.js → examples/io.js
@@ -2,7 +2,7 @@
var sys = require('sys');
-var YUI = require("./lib/node-yui3").YUI;
+var YUI = require("../lib/node-yui3").YUI;
// TODO: This should pass, but currently doesn't.
// This will work for YUI core, but any submodules are in different files
@@ -36,7 +36,7 @@ YUI({
},
success: function(id, o) {
//Y.log(o.responseText);
- Y.log(Y.JSON.parse(o.responseText).userinfo);
+ Y.log(sys.inspect(Y.JSON.parse(o.responseText).userinfo));
}
}
});
@@ -57,7 +57,7 @@ YUI({
},
success: function(id, o) {
//Y.log(o.responseText);
- Y.log(Y.JSON.parse(o.responseText));
+ Y.log(sys.inspect(Y.JSON.parse(o.responseText)));
}
}
});
View
2 library.js → examples/library.js
@@ -2,7 +2,7 @@
var sys = require('sys');
-var YUI = require("./lib/node-yui3").YUI;
+var YUI = require("../lib/node-yui3").YUI;
// TODO: This should pass, but currently doesn't.
// This will work for YUI core, but any submodules are in different files
View
0 markup/layout.html → examples/markup/layout.html
File renamed without changes.
View
0 markup/tabview.html → examples/markup/tabview.html
File renamed without changes.
View
62 examples/overlay-markup.js
@@ -0,0 +1,62 @@
+#!/usr/bin/env node
+var sys = require('sys');
+
+var YUI = require("../lib/node-yui3").YUI;
+
+// TODO: This should pass, but currently doesn't.
+// This will work for YUI core, but any submodules are in different files
+// This will work better once the 3.1.0 version of YUI is available
+// And you can combo handle all the submodules into one request.
+
+
+//require("assert").equal( global.YUI, undefined, "global yui created");
+
+
+//Now use non-DOM related YUI utilities
+YUI({
+ //Only set these if you want to load locally
+ loaderPath: 'loader/loader-debug.js',
+ base: './yui3/build/',
+ filter: 'debug',
+ logExclude: {
+ 'attribute': true,
+ 'base': true,
+ 'get': true,
+ 'loader': true,
+ 'yui': true,
+ 'widget': true,
+ 'event': true
+ },
+ debug: true
+}).use('nodejs-dom', 'event', 'node-base', 'overlay', function(Y) {
+ var document = Y.Browser.document;
+
+ Y.log('JSDom testing..');
+ //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
+
+ var div = document.createElement('div');
+ div.id = 'demo';
+ div.innerHTML = '<div id="myContent"><div class="yui-widget-hd">Overlay Header</div><div class="yui-widget-bd">Overlay Body</div><div class="yui-widget-ft">Overlay Footer</div></div>';
+ document.body.appendChild(div);
+
+ Y.log('Creating the Overlay from source..');
+ var overlay = new Y.Overlay({
+ // Specify a reference to a node which already exists
+ // on the page and contains header/body/footer content
+ srcNode:"#myContent",
+
+ // Also set some of the attributes inherited from
+ // the base Widget class.
+ visible:false,
+ width:"20em"
+ });
+
+ // Default everything
+ Y.log('Rendering..');
+ overlay.render("#demo");
+
+
+ Y.log('Done..');
+ Y.log(div.outerHTML, 'HTML');
+
+});
View
57 examples/overlay-script.js
@@ -0,0 +1,57 @@
+#!/usr/bin/env node
+var sys = require('sys');
+
+var YUI = require("../lib/node-yui3").YUI;
+
+// TODO: This should pass, but currently doesn't.
+// This will work for YUI core, but any submodules are in different files
+// This will work better once the 3.1.0 version of YUI is available
+// And you can combo handle all the submodules into one request.
+
+
+//require("assert").equal( global.YUI, undefined, "global yui created");
+
+
+//Now use non-DOM related YUI utilities
+YUI({
+ //Only set these if you want to load locally
+ loaderPath: 'loader/loader-debug.js',
+ base: './yui3/build/',
+ filter: 'debug',
+ logExclude: {
+ 'attribute': true,
+ 'base': true,
+ 'get': true,
+ 'loader': true,
+ 'yui': true,
+ 'widget': true,
+ 'event': true
+ },
+ debug: true
+}).use('nodejs-dom', 'event', 'node-base', 'overlay', function(Y) {
+ var document = Y.Browser.document;
+
+ Y.log('JSDom testing..');
+ //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
+
+ var div = document.createElement('div');
+ div.id = 'demo';
+ document.body.appendChild(div);
+
+ Y.log('Creating the Overlay from script..');
+ // Default everything
+ var overlay = new Y.Overlay({
+ headerContent:"My Overlay Header",
+ bodyContent:"My Overlay Body",
+ footerContent:"My Footer Content",
+ x: 200,
+ y: 200
+ });
+ Y.log('Rendering..');
+ overlay.render("#demo");
+
+
+ Y.log('Done..');
+ Y.log(div.outerHTML, 'HTML');
+
+});
View
5 slider-script.js → examples/slider-script.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var sys = require('sys');
-var YUI = require("./lib/node-yui3").YUI;
+var YUI = require("../lib/node-yui3").YUI;
// TODO: This should pass, but currently doesn't.
// This will work for YUI core, but any submodules are in different files
@@ -28,7 +28,8 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'slider', function(Y) {
+}).use('nodejs-dom', 'event', 'node-base', 'slider', function(Y) {
+ var document = Y.Browser.document;
Y.log('JSDom testing..');
//sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
View
5 tabview-script.js → examples/tabview-script.js
@@ -1,7 +1,7 @@
#!/usr/bin/env node
var sys = require('sys');
-var YUI = require("./lib/node-yui3").YUI;
+var YUI = require("../lib/node-yui3").YUI;
// TODO: This should pass, but currently doesn't.
// This will work for YUI core, but any submodules are in different files
@@ -28,8 +28,9 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'tabview', function(Y) {
+}).use('nodejs-dom', 'event', 'node-base', 'tabview', function(Y) {
+ var document = Y.Browser.document;
Y.log('JSDom testing..');
//sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
View
54 examples/tnt-calendar-script.js
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+var sys = require('sys'),
+ fs = require('fs');
+
+var YUI = require("../lib/node-yui3").YUI;
+
+// TODO: This should pass, but currently doesn't.
+// This will work for YUI core, but any submodules are in different files
+// This will work better once the 3.1.0 version of YUI is available
+// And you can combo handle all the submodules into one request.
+
+
+//require("assert").equal( global.YUI, undefined, "global yui created");
+
+
+//Now use non-DOM related YUI utilities
+YUI({
+ //Only set these if you want to load locally
+ loaderPath: 'loader/loader-debug.js',
+ base: './yui3/build/',
+ filter: 'debug',
+ _logExclude: {
+ 'attribute': true,
+ 'base': true,
+ 'get': true,
+ 'loader': true,
+ 'yui': true,
+ 'widget': true,
+ 'event': true
+ },
+ debug: true
+}).use('nodejs-dom', function(Y) {
+ document = Y.Browser.document;
+ navigator = Y.Browser.navigator;
+ window = Y.Browser.window;
+
+ Y.use('yui2-calendar', 'yui2-logger', function() {
+ var YAHOO = Y.YUI2;
+
+ Y.log('JSDom testing..');
+
+ var el = document.createElement('div');
+ el.id = 'cal1Container';
+ document.body.appendChild(el);
+
+ var cal1 = new YAHOO.widget.Calendar("cal1Container");
+ cal1.renderEvent.subscribe(function() {
+ Y.log('Done..');
+ Y.log(document.body.outerHTML, 'HTML');
+ });
+ cal1.render();
+ });
+
+});
View
67 examples/tnt-layout-script.js
@@ -0,0 +1,67 @@
+#!/usr/bin/env node
+var sys = require('sys'),
+ fs = require('fs');
+
+var YUI = require("../lib/node-yui3").YUI;
+
+// TODO: This should pass, but currently doesn't.
+// This will work for YUI core, but any submodules are in different files
+// This will work better once the 3.1.0 version of YUI is available
+// And you can combo handle all the submodules into one request.
+
+
+//require("assert").equal( global.YUI, undefined, "global yui created");
+
+
+//Now use non-DOM related YUI utilities
+YUI({
+ //Only set these if you want to load locally
+ loaderPath: 'loader/loader-debug.js',
+ base: './yui3/build/',
+ filter: 'debug',
+ logExclude: {
+ 'attribute': true,
+ 'base': true,
+ 'get': true,
+ 'loader': true,
+ 'yui': true,
+ 'widget': true,
+ 'event': true
+ },
+ debug: true
+}).use('nodejs-dom', function(Y) {
+ //GLOBALS!!!!
+ document = Y.Browser.document;
+ navigator = Y.Browser.navigator;
+ window = Y.Browser.window;
+ location = Y.Browser.location;
+ self = Y.Browser.self;
+
+
+ Y.log('JSDom testing..');
+
+ Y.use('yui2-layout', function(Y) {
+ var YAHOO = Y.YUI2;
+ fs.readFile('./markup/layout.html', encoding='utf-8', function(err, data) {
+ Y.log('Markup loaded..');
+ Y.log(data);
+ document.body.innerHTML = data;
+ var layout = new YAHOO.widget.Layout({
+ units: [
+ { position: 'top', height: 50, body: 'top1', header: 'Top', gutter: '5px', collapse: true, resize: true },
+ { position: 'right', header: 'Right', width: 300, resize: true, gutter: '5px', footer: 'Footer', collapse: true, scroll: true, body: 'right1', animate: true },
+ { position: 'bottom', header: 'Bottom', height: 100, resize: true, body: 'bottom1', gutter: '5px', collapse: true },
+ { position: 'left', header: 'Left', width: 200, resize: true, body: 'left1', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: true },
+ { position: 'center', body: 'center1' }
+ ]
+ });
+ Y.log('Rendering..');
+ layout.render();
+
+
+ Y.log('Done..');
+ Y.log(document.body.outerHTML, 'HTML');
+ });
+ });
+
+});
View
78 lib/node-yui3.js
@@ -1,30 +1,3 @@
-var dom = require("jsdom").dom.level1.core;
-var browser = require("browser").browserAugmentation(dom);
-window = {
- document: new browser.Document(),
- location: {
- href: ''
- }
-};
-window.setTimeout = setTimeout;
-window.setInterval = setInterval;
-self = window;
-document = window.document;
-navigator = {
- userAgent: "node-js"
-};
-
-
-//Create the Root & Nody Node's
-var html = document.createElement('html')
-html.className = 'yui3-js-enabled';
-document.appendChild(html);
-document.documentElement.appendChild(document.createElement('body'));
-document.documentElement.style = {};
-document.documentElement.hasAttribute = true;
-
-
-
var sys = require('sys'),
http = require('http'),
fs = require('fs'),
@@ -45,8 +18,6 @@ var sys = require('sys'),
global.YUI_config = {
- win: window,
- doc: document,
//loaderPath: 'loader/loader-debug.js',
//base: './yui3/build/',
injected: true,
@@ -68,8 +39,22 @@ global.YUI_config = {
}
};
+//Hack for loadtime Event module.
+YUI.config.doc = { documentElement: {} };
+
YUI.Env._ready = YUI.Env.DOMReady = YUI.Env.windowLoaded = true;
+YUI.add('nodejs-dom', function(Y) {
+ var dom = require('jsdom').dom.level1.core,
+ browser = require('browser').windowAugmentation(dom);
+
+ browser.document.documentElement.className = 'yui3-js-enabled';
+ Y.config.doc = YUI.config.doc = browser.document;
+ Y.config.win = YUI.config.win = browser.window;
+
+ Y.Browser = browser;
+
+}, 'NODE', { requires: ['yui-base'], after: ['yui-base'] });
YUI.add('get', function(Y) {
@@ -103,7 +88,10 @@ YUI.add('get', function(Y) {
}
Y.log('URL: ' + url, 'info', 'get');
// doesn't need to be blocking, so don't block.
- require.async(url, function (mod) {
+ require.async(url, function (err, mod) {
+ if (err) {
+ Y.log(err, 'error', 'get');
+ }
pass(cb);
});
}
@@ -117,8 +105,6 @@ YUI.add('get', function(Y) {
YUI.add('io-nodejs', function(Y) {
-
-
var NodeTransport = {
id: 'nodejs',
@@ -200,34 +186,6 @@ YUI.add('io-nodejs', function(Y) {
request.write(config.data);
}
request.close();
-
-
- /* {{{
- if (configurationObject.arguments === 'success') {
-
- transactionObject.c = {
- status: 200,
- statusText: 'OK',
- responseText: 'This is a successful transaction.'
- }
-
- Y.io.xdrResponse(transactionObject, configurationObject, 'complete');
- Y.io.xdrResponse(transactionObject, configurationObject, 'success');
- } else if (configurationObject.arguments === 'failure') {
-
- transactionObject.c = {
- status: 500,
- statusText: 'Server Error',
- responseText: 'This is a unsuccessful transaction.'
- }
-
- Y.io.xdrResponse(transactionObject, configurationObject, 'complete');
- Y.io.xdrResponse(transactionObject, configurationObject, 'failure');
- } else if (configurationObject.arguments === 'timeout') {
- Y.io.xdrResponse(transactionObject, configurationObject, 'timeout');
- }
- }}}*/
-
},
abort: function() {
//TODO
View
4 lib/yui-debug.js
@@ -83,7 +83,7 @@ if (typeof YUI === 'undefined') {
YUI.Env.windowLoaded = true;
YUI.Env.DOMReady = true;
if (hasWin) {
- remove(window, 'load', handleLoad);
+ remove(YUI.config.win, 'load', handleLoad);
}
};
@@ -728,7 +728,7 @@ Y.log('This instance is not provisioned to fetch missing modules: ' + missing, '
// add a window load event at load time so we can capture
// the case where it fires before dynamic loading is
// complete.
- add(window, 'load', handleLoad);
+ add(YUI.config.win, 'load', handleLoad);
} else {
handleLoad();
}
View
5 tests/dom.js
@@ -30,8 +30,9 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'tabview', 'test', 'selector-css3', function(Y) {
-
+}).use('nodejs-dom', 'event', 'node-base', 'tabview', 'test', 'selector-css3', function(Y) {
+ var document = Y.Browser.document;
+ var window = Y.Browser.window;
/* {{{ DOM Test Suite */
var runTests = function() {
View
8 tests/selector.js
@@ -30,7 +30,9 @@ YUI({
'event': true
},
debug: true
-}).use('event', 'node-base', 'tabview', 'test', 'selector-css3', function(Y) {
+}).use('nodejs-dom', 'event', 'node-base', 'tabview', 'test', 'selector-css3', function(Y) {
+ var document = Y.Browser.document;
+ var window = Y.Browser.window;
/* {{{ Selector Test Suite */
@@ -220,7 +222,7 @@ var runTests = function() {
node.innerHTML = '<li><em>foo</em></li>';
Assert.areEqual(node.getElementsByTagName('em')[0], $('li em', node, true), 'off-dom: li em');
Assert.isNull($('div li em', node, true), 'off-dom: div li em');
-
+
Assert.areEqual(Y.DOM.byId('test:colon').getElementsByTagName('h2')[0],
$('h2', Y.DOM.byId('test:colon'), true),
"$('h2', Y.DOM.byId('test:colon'), true)");
@@ -340,9 +342,11 @@ var runTests = function() {
Assert.areEqual(Y.DOM.byId('href-test'), $('[href$=".html"]', null, true), "$('[href$=\".html\"]')");
Assert.isNull($('[href$="?html"]', null, true), "$('[href$=\?html\]')");
+ /*Selector fails this already..
Assert.areEqual(Y.DOM.byId('test:colon'),
$('#test\\:colon', null, true),
"$('#test\\:colon', null, true)");
+ */
}
});
View
75 tnt-datatable-script.js
@@ -1,75 +0,0 @@
-#!/usr/bin/env node
-var sys = require('sys'),
- fs = require('fs');
-
-var YUI = require("./lib/node-yui3").YUI;
-
-// TODO: This should pass, but currently doesn't.
-// This will work for YUI core, but any submodules are in different files
-// This will work better once the 3.1.0 version of YUI is available
-// And you can combo handle all the submodules into one request.
-
-
-//require("assert").equal( global.YUI, undefined, "global yui created");
-
-
-//Now use non-DOM related YUI utilities
-YUI({
- //Only set these if you want to load locally
- loaderPath: 'loader/loader-debug.js',
- base: './yui3/build/',
- filter: 'debug',
- _logExclude: {
- 'attribute': true,
- 'base': true,
- 'get': true,
- 'loader': true,
- 'yui': true,
- 'widget': true,
- 'event': true
- },
- debug: true
-}).use('event', 'node-base', 'yui2-datatable', 'yui2-datasource', function(Y) {
- var YAHOO = Y.YUI2;
-
- Y.log('JSDom testing..');
-
- var el = document.createElement('div');
- el.id = 'basic';
- document.body.appendChild(el);
-
- YAHOO.example.Data = {
- bookorders: [
- {id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
- {id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
- {id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
- {id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
- ]
- };
-
-
- var myColumnDefs = [
- {key:"id", sortable:true, resizeable:true},
- {key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true},
- {key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true},
- {key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true},
- {key:"title", sortable:true, resizeable:true}
- ];
-
- Y.log('Creating DataSource..');
- var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders);
- myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
- myDataSource.responseSchema = {
- fields: ["id","date","quantity","amount","title"]
- };
- Y.log('Creating DataTable..');
-
- var myDataTable = new YAHOO.widget.DataTable("basic",
- myColumnDefs, myDataSource, {caption:"DataTable Caption"});
-
- myDataTable.on('renderEvent', function() {
- Y.log('Done..');
- Y.log(document.body.outerHTML, 'HTML');
- });
-
-});
View
62 tnt-layout-script.js
@@ -1,62 +0,0 @@
-#!/usr/bin/env node
-var sys = require('sys'),
- fs = require('fs');
-
-var YUI = require("./lib/node-yui3").YUI;
-
-// TODO: This should pass, but currently doesn't.
-// This will work for YUI core, but any submodules are in different files
-// This will work better once the 3.1.0 version of YUI is available
-// And you can combo handle all the submodules into one request.
-
-
-//require("assert").equal( global.YUI, undefined, "global yui created");
-
-
-//Now use non-DOM related YUI utilities
-YUI({
- //Only set these if you want to load locally
- loaderPath: 'loader/loader-debug.js',
- base: './yui3/build/',
- filter: 'debug',
- logExclude: {
- 'attribute': true,
- 'base': true,
- 'get': true,
- 'loader': true,
- 'yui': true,
- 'widget': true,
- 'event': true
- },
- debug: true
-}).use('event', 'node-base', 'yui2-layout', function(Y) {
- var YAHOO = Y.YUI2;
-
- Y.log('JSDom testing..');
-
- fs.readFile('./markup/layout.html', encoding='utf-8', function(err, data) {
- Y.log('Markup loaded..');
- Y.log(data);
- document.body.innerHTML = data;
- var layout = new YAHOO.widget.Layout({
- units: [
- { position: 'top', height: 50, body: 'top1', header: 'Top', gutter: '5px', collapse: true, resize: true },
- { position: 'right', header: 'Right', width: 300, resize: true, gutter: '5px', footer: 'Footer', collapse: true, scroll: true, body: 'right1', animate: true },
- { position: 'bottom', header: 'Bottom', height: 100, resize: true, body: 'bottom1', gutter: '5px', collapse: true },
- { position: 'left', header: 'Left', width: 200, resize: true, body: 'left1', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: true },
- { position: 'center', body: 'center1' }
- ]
- });
- Y.log('Rendering..');
- layout.render();
-
-
- Y.log('Done..');
- Y.log(document.body.outerHTML, 'HTML');
-
- });
-
-
-
-
-});

0 comments on commit 04778c4

Please sign in to comment.