├── .gitignore
├── .npmignore
├── DEVELOPER.markdown
├── INSTALL
├── LICENSE
├── Makefile
├── README.textile
├── cli.js
├── examples
├── 2in3-meta.js
├── colors.js
├── config.js
├── configure.js
├── daemon.js
├── express
│ ├── assets
│ │ ├── main.js
│ │ └── tabview.js
│ ├── express.js
│ └── views
│ │ ├── index.html
│ │ ├── layout.html
│ │ ├── partials
│ │ ├── layout_append.html
│ │ ├── layout_head.html
│ │ ├── layout_prepend.html
│ │ └── test.html
│ │ └── tabview.html
├── external-module.js
├── from-string.js
├── gallery-meta.js
├── gallery.js
├── general-dom.js
├── inside.js
├── io.js
├── library.js
├── loadDir.js
├── loader.js
├── markup
│ ├── layout.html
│ └── tabview.html
├── mods
│ ├── mod1.js
│ ├── mod2.js
│ ├── mod3.js
│ ├── modals
│ │ ├── mod1.js
│ │ ├── mod2.js
│ │ └── mod3.js
│ └── views
│ │ ├── mod1.js
│ │ ├── mod2.js
│ │ └── mod3.js
├── module-dyn.js
├── module-groups.js
├── module.js
├── overlay-markup.js
├── overlay-script.js
├── parallel.js
├── process.js
├── rls.js
├── scrape-object.js
├── scrape.js
├── slider-script.js
├── stdin.js
├── sync-mod.js
├── sync-module.js
├── sync.js
├── tabview-markup.js
├── tabview-script.js
├── tnt-calendar-script.js
├── tnt-calendar-serve.js
├── tnt-datatable-script.js
├── tnt-layout-script.js
├── trap-error.js
├── trap-test.js
├── versions.js
├── y-browser.js
├── y-server-template.js
└── y-server.js
├── lib
├── node-yui3.js
├── yui3-dom-after.js
├── yui3-dom.js
├── yui3-error.js
├── yui3-express.js
├── yui3-io.js
├── yui3-node.js
├── yui3-parallel.js
├── yui3-rls.js
└── yui3-yui3.js
├── package.json
├── packages
├── bare-package.json
├── base-package.json
├── default-package.json
└── full-package.json
├── perf
└── load.js
├── scripts
├── deps.sh
├── install.sh
├── make_package.sh
├── merge_package_json.js
├── publish.sh
└── test.sh
└── tests
├── deps.js
├── dom.js
├── extras
├── loader-debug.js
└── loader-min.js
├── html
├── dd.html
├── dom.html
├── node.html
└── selector.html
├── interface.js
├── manual
├── comments.html
├── comments.js
└── dd.js
├── node.js
└── selector.js
/.gitignore:
--------------------------------------------------------------------------------
1 | build/*
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | .git
2 | sandbox
3 | yui3
4 |
--------------------------------------------------------------------------------
/DEVELOPER.markdown:
--------------------------------------------------------------------------------
1 | #Testing the latest YUI release with Node
2 |
3 | I've tried to make it simple to test the latest YUI source code against my nodejs package.
4 | First you need to install yuitest:
5 |
6 | npm install yuitest
7 |
8 | Now, go into your clone of the yui3 source tree and npm install it:
9 |
10 | cd /path/to/yui3
11 | npm install .
12 |
13 | Now you can test this code:
14 |
15 | yuitest ./tests/*.js
16 |
17 | Currently there are over 100 tests that should pass 100% if your YUI3 code works ;)
18 |
19 | ##Developing
20 |
21 | If you are patching YUI core or working with Dom/Event/Node code, you really need to check to make sure
22 | that your code doesn't contain things that will break on the server. Each time you do a build, you should also
23 | follow the steps above to `npm install` then `yuitest ./tests/*.js` to make sure you didn't introduce a
24 | change that will break when your code is executed on the server.
25 |
--------------------------------------------------------------------------------
/INSTALL:
--------------------------------------------------------------------------------
1 | This repository includes 3 yui3 npm packages. bare, base and full.
2 |
3 | Bare:
4 | This package is just the contents of this repository with a package.json file that
5 | contains no dependencies. This package should only be used if you are providing your
6 | own special yui3-core package.
7 |
8 | Base:
9 | This package is the contents of this directory with the dependency of yui3-core. This
10 | package assumes you are running YUI3 inside of NodeJS without needing DOM. Even tho
11 | DOM support is in this package, jsom and other dependencies will not be installed.
12 |
13 | Full:
14 | The original YUI3 source package that requires the dependencies required for using DOM
15 | on the server.
16 |
17 |
18 | Installation:
19 |
20 | make: Will make all 3 packages
21 | make && make install: Will make all 3 packages and install them via npm
22 |
23 | make bare: Will only make the bare package
24 | make base: Will only make the base package
25 | make full: Will only make the full package
26 |
27 | make full && make install: Will make the full package and install it
28 |
29 | make clean: Will delete the ./build directory
30 |
31 | make test: Will run the yuitest's for this project
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2013 Yahoo! Inc.
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are met:
6 | * Redistributions of source code must retain the above copyright
7 | notice, this list of conditions and the following disclaimer.
8 | * Redistributions in binary form must reproduce the above copyright
9 | notice, this list of conditions and the following disclaimer in the
10 | documentation and/or other materials provided with the distribution.
11 | * Neither the name of the Yahoo! Inc. nor the
12 | names of its contributors may be used to endorse or promote products
13 | derived from this software without specific prior written permission.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 | DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY
19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 |
26 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | all: deps clean bare base full
2 |
3 | full: deps
4 | @./scripts/make_package.sh full
5 |
6 | bare: deps
7 | @./scripts/make_package.sh bare
8 |
9 | base: deps
10 | @./scripts/make_package.sh base
11 |
12 | publish: deps install test
13 | @./scripts/publish.sh
14 |
15 | dev: deps clean full install
16 | @echo "make clean && make full && make install: DONE"
17 |
18 | test: deps
19 | @./scripts/test.sh
20 |
21 | tests: test
22 | isntall: install
23 |
24 | install: deps all
25 | @./scripts/install.sh
26 |
27 | deps: ./scripts/deps.sh
28 |
29 | clean:
30 | rm -rRf ./build/
31 |
32 | help:
33 | @cat ./INSTALL
34 |
35 | .PHONY: all install test bare base full publish clean deps test help
36 |
--------------------------------------------------------------------------------
/README.textile:
--------------------------------------------------------------------------------
1 | h1. YUI Bootstrapper for Node.js
2 |
3 | The YUI3NodeJS project uses several 3rd party open source libraries and tools.
4 |
5 | This file summarizes the tools used, their purpose, and the licenses under which they're released.
6 |
7 | This node.js module attempts to setup and bootstrap a working YUI 3 instance.
8 |
9 | This module includes support for remote script loading via Y.Get.script() and remote data fetching via Y.io.
10 |
11 | See "JSDom Support" below for DOM manipulation.
12 |
13 | h2. Node.js
14 |
15 | All of the examples and tests assume you have @node@ in your path and they are all executable.
16 |
17 | h2. Dependencies
18 |
19 | All dependencies are installed when you install the yui3 package via @npm@
20 |
21 | For server side dom manipulation, you need the following packages installed:
22 |
23 | "JSDom":http://github.com/tmpvar/jsdom : "LICENSE":http://github.com/tmpvar/jsdom/blob/master/LICENSE.txt
24 |
25 |
npm install jsdom
26 |
27 | "HTML Parser":http://github.com/tautologistics/node-htmlparser : "LICENSE":http://github.com/tautologistics/node-htmlparser/blob/master/LICENSE
28 |
29 | npm install htmlparser
30 |
31 | h2. Optional Dependancies
32 |
33 | "Express":http://expressjs.com/ : LICENSE (MIT)
34 |
35 | npm install express
36 |
37 | "Connect":http://github.com/senchalabs/connect : LICENSE (MIT)
38 |
39 | npm install connect
40 |
41 | h2. Installing - via NPM
42 |
43 |
44 | npm install yui3
45 |
46 |
47 | h2. Installing - as a developer
48 |
49 | You must have git and npm installed before you can develop.
50 |
51 |
52 | git clone git://github.com/davglass/nodejs-yui3.git
53 | cd nodejs-yui3/
54 | npm install .
55 |
56 |
57 | h2. Using YUI3
58 |
59 | "This is the general-dom example":http://gist.github.com/541501
60 |
61 | h2. Remote Fetching
62 |
63 | "This example shows fetching a remote document and then using Node to modify it":http://gist.github.com/574000
64 |
65 | h2. Using the Y.Browser object
66 |
67 | To comply with the "no-globals" CommonJS spec, there is no global document or window in this mode.
68 | Just including the nodejs-dom module will create a fake dom for this instance.
69 | You can create a document like this:
70 | "View this Gist":http://gist.github.com/359776
71 |
72 | You can make older DOM code run by setting up a couple of local variables, "like this":http://gist.github.com/359778
73 |
74 |
75 | If you are using YUI to serve pages, you should use a Nested Use to create the document when the request comes in.
76 |
77 | "Something like this":http://gist.github.com/359781
78 |
79 |
80 | I have an example showing this: @examples/y-browser.js@
81 |
82 |
83 | h2. Examples
84 |
85 |
86 | cd examples/
87 | ./general-dom.js
88 | ./io.js
89 | ./library.js
90 | ./y-brower.js
91 |
92 |
93 | h2. Tests
94 |
95 | 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.
96 |
97 | Testing is pretty simple now once you install `yuitest`:
98 |
99 |
100 | npm install yuitest
101 | yuitest ./tests/*.js
102 |
103 |
104 | h2. License
105 |
106 | This software is offered under the terms of the BSD license. See the LICENSE file or the "YUI License":http://developer.yahoo.com/yui/license.html for license text and copyright information.
107 |
108 | h2. Contribute
109 |
110 | Your contributions are welcome! Please review the "YUI contributor guide":http://developer.yahoo.com/yui/community/#cla before contributing. If you haven't contributed to a "YUI project":http://yuilibrary.com before, you'll need to review and sign the "YUI CLA":http://developer.yahoo.com/yui/community/#cla before we can accept your pull request.
111 |
112 |
113 |
--------------------------------------------------------------------------------
/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var yui3 = require('yui3-core');
4 |
5 | process.chdir(yui3.path() + '/api/');
6 |
7 | try {
8 | var express = require('express');
9 | } catch (e) {
10 | console.log('Could not require expressjs; install via: npm install express');
11 | process.exit();
12 | }
13 | var args = process.argv.slice(2),
14 | arg, key, config = { port: 8100 };
15 |
16 | while (arg = args.shift()) {
17 | if ("--" === arg.substr(0, 2)) {
18 | key = arg.substr(2).split('=');
19 | config[key[0]] = key[1];
20 | }
21 | }
22 |
23 | var app = express.createServer();
24 | app.configure(function() {
25 | app.use(express.staticProvider(process.cwd()));
26 | });
27 | var port = parseInt(config.port);
28 | app.listen(port);
29 | console.log('YUI3 API Docs are available:');
30 | console.log('http://localhost:' + port);
31 |
--------------------------------------------------------------------------------
/examples/colors.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | debug: true
9 | }).use('node', function(Y) {
10 |
11 | Y.log('This output should be colored');
12 |
13 | });
14 |
15 |
16 | YUI({
17 | filter: 'debug',
18 | useColor: false,
19 | debug: true
20 | }).use('node', function(Y) {
21 |
22 | Y.log('This output SHOULD NOT be colored');
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/examples/config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | foo: function(num) {
3 | console.log('(' + num + ') Config::Foo called');
4 | }
5 | };
6 |
--------------------------------------------------------------------------------
/examples/configure.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 |
4 | var YUIConfig = {
5 | core: '3.3.0',
6 | gallery: '2010.09.22',
7 | '2in3': '0.0.3'
8 | };
9 |
10 | var yui3 = require('yui3');
11 | var Y = yui3.configure(YUIConfig).useSync('node', 'gallery-torelativetime');
12 |
13 | console.log(Y.config.base);
14 | console.log(Y.config.groups.gallery.base);
15 | console.log(Y.config.groups.yui2.base);
16 |
17 |
--------------------------------------------------------------------------------
/examples/daemon.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var YUI = require('yui3').YUI;
4 |
5 | YUI({
6 | debug: true,
7 | modules: {
8 | 'process': {
9 | fullpath: __dirname + '/process.js'
10 | }
11 | }
12 | }).use('base', 'process', function(Y) {
13 | var p = new Y.Process({
14 | workers: 10
15 | });
16 | p.on('ready', function() {
17 | this.message('CHILD PROCESS STARTED FROM READY EVENT');
18 | });
19 | p.on('sigcont', function(e) {
20 | this.message('SIGCONT LISTENER, stopping..');
21 | e.halt();
22 | });
23 | p.on('sigchild', function(e) {
24 | //this.message('SIGCHILD STOPPED');
25 | //e.halt();
26 | });
27 | p.on('message', function(e) {
28 | //console.log('Message from (' + e.pid + '): ', e.message);
29 | });
30 |
31 | p.spawn();
32 | });
33 |
--------------------------------------------------------------------------------
/examples/express/assets/main.js:
--------------------------------------------------------------------------------
1 | alert('Loaded..');
2 |
--------------------------------------------------------------------------------
/examples/express/assets/tabview.js:
--------------------------------------------------------------------------------
1 | YUI({ fetchCSS: false }).use('tabview', function(Y) {
2 | new Y.TabView({
3 | srcNode: '#demo .yui3-tabview-content'
4 | }).render();
5 | });
6 |
--------------------------------------------------------------------------------
/examples/express/express.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var express = require('express'),
4 | YUI = require('yui3').YUI;
5 |
6 |
7 | YUI().use('express', 'node', function(Y) {
8 |
9 | var app = express.createServer();
10 |
11 | app.configure(function(){
12 | app.use(express.methodOverride());
13 | app.use(express.bodyDecoder());
14 | app.use(app.router);
15 | app.use(express.staticProvider(__dirname + '/assets'));
16 | });
17 |
18 | app.register('.html', YUI);
19 |
20 | app.get('/combo', YUI.combo);
21 |
22 | app.get('/tabview', function(req, res) {
23 | YUI().use('node', function(Y) {
24 | Y.Env._loader.ignoreRegistered = true;
25 | Y.use('tabview', function(Y) {
26 | var div = Y.Node.create('
');
27 | Y.one('title').set('innerHTML', 'YUI3 tabView Page');
28 | Y.one('body').addClass('yui3-skin-sam').appendChild(div);
29 |
30 | Y.log('Creating the TabView from script..');
31 | var tabview = new Y.TabView({
32 | children: [{
33 | label: 'foo',
34 | content: 'foo content
'
35 | }, {
36 | label: 'bar',
37 | content: 'bar content
'
38 | }, {
39 | label: 'baz',
40 | content: 'baz content
'
41 | }]
42 | });
43 | tabview.render('#demo');
44 |
45 | res.render('tabview.html', {
46 | locals: {
47 | instance: Y,
48 | use: ['tabview'],
49 | //filter: 'debug',
50 | content: '#content',
51 | after: function(Y) {
52 | Y.Get.domScript('/tabview.js');
53 | }
54 | }
55 | });
56 | });
57 | });
58 | });
59 |
60 | YUI.partials = [
61 | {
62 | method: 'append',
63 | node: 'body',
64 | name: 'layout_append'
65 | },
66 | {
67 | method: 'prepend',
68 | node: 'body',
69 | name: 'layout_prepend'
70 | }
71 | ];
72 |
73 | app.get('/', function(req, res){
74 | res.render('index.html', {
75 | locals: {
76 | content: '#content',
77 | sub: {
78 | above_content: 'This was inserted above the content.',
79 | title1: 'Title #1',
80 | title2: 'Title #2',
81 | title3: 'Title #3',
82 | title4: 'Title #4'
83 | },
84 | partials: [
85 | {
86 | method: 'append',
87 | node: 'head',
88 | name: 'layout_head'
89 | }
90 | ],
91 | after: function(Y, options, partial) {
92 | Y.Get.domScript('/main.js');
93 | Y.one('title').set('innerHTML', 'This is a test');
94 |
95 | var str = partial('test');
96 | var html = '';
97 | var data = ['one', 'two', 'three'];
98 | data.forEach(function(v) {
99 | html += Y.Lang.sub(str, { name: v })
100 | });
101 | Y.one('#content').prepend('');
102 | },
103 | before: function(Y) {
104 | Y.one('h1').set('innerHTML', 'BooYah!!');
105 | }
106 | }
107 | });
108 | });
109 |
110 | app.get('/pre', YUI.express({render: 'index.html', locals: {}}), function(req, res){
111 | res.sub({
112 | above_content: 'This was inserted above the content.',
113 | title: 'Title #1',
114 | title2: 'Title #2',
115 | title3: 'Title #3',
116 | title4: 'Title #4'
117 | });
118 | res.send();
119 | });
120 |
121 | Y.log('Server listening: http:/'+'/localhost:3000/', 'info', 'express');
122 | app.listen(3000);
123 |
124 | });
125 |
126 |
--------------------------------------------------------------------------------
/examples/express/views/index.html:
--------------------------------------------------------------------------------
1 | {title}
2 | This is only a test. This is only a test. This is only a test. This is only a test. This is only a test. This is only a test.
3 | {title2}
4 | This is only a test. This is only a test. This is only a test. This is only a test. This is only a test. This is only a test.
5 | {title3}
6 | This is only a test. This is only a test. This is only a test. This is only a test. This is only a test. This is only a test.
7 | {title4}
8 | This is only a test. This is only a test. This is only a test. This is only a test. This is only a test. This is only a test.
9 |
--------------------------------------------------------------------------------
/examples/express/views/layout.html:
--------------------------------------------------------------------------------
1 |
6 |
7 | Above normal content
8 |
9 |
10 |
11 |
12 | {above_content}
13 |
14 |
15 |
16 |
17 | Below normal content
18 |
23 |
--------------------------------------------------------------------------------
/examples/express/views/partials/layout_append.html:
--------------------------------------------------------------------------------
1 | © 2010 DavGlass.com This is a footer test.
2 |
--------------------------------------------------------------------------------
/examples/express/views/partials/layout_head.html:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/examples/express/views/partials/layout_prepend.html:
--------------------------------------------------------------------------------
1 |
This is the header of the page..
2 |
--------------------------------------------------------------------------------
/examples/express/views/partials/test.html:
--------------------------------------------------------------------------------
1 | {name}
2 |
--------------------------------------------------------------------------------
/examples/express/views/tabview.html:
--------------------------------------------------------------------------------
1 | This is only a test. This is only a test. This is only a test. This is only a test. This is only a test. This is only a test.
2 |
--------------------------------------------------------------------------------
/examples/external-module.js:
--------------------------------------------------------------------------------
1 | YUI.add('external-foo', function(Y) {
2 |
3 | Y.log(__dirname, 'info', '__dirname');
4 | Y.log(__filename, 'info', '__filename');
5 |
6 | //console.log(require);
7 | //console.log(process);
8 |
9 | var sys = require('sys');
10 | sys.puts('PRINTED FROM INTERNAL REQUIRE WITH sys.puts');
11 |
12 | var config = require('./config');
13 | Y.log(config);
14 | config.foo('#1 Relative');
15 |
16 | var config = require(__dirname + '/config');
17 | Y.log(config);
18 | config.foo('#2 Full Dir Require');
19 |
20 | Y.log('EXTERNAL FOO LOADED');
21 |
22 | }, '1.0.0', { requires: ['node'] });
23 |
--------------------------------------------------------------------------------
/examples/from-string.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var html = 'My Title ' +
4 | 'Foo ' +
5 | 'Foo ' +
6 | 'Foo ' +
7 | 'Foo ' +
8 | '';
9 |
10 | require('yui3').fromString(html, function(Y) {
11 | Y.log('Page Title: ' + Y.one('title').get('innerHTML'));
12 | Y.log('Anchors: ' + Y.all('a').size());
13 | Y.log('Lists: ' + Y.all('ol,ul').size());
14 | Y.log('List Items: ' + Y.all('li').size());
15 | });
16 |
17 |
--------------------------------------------------------------------------------
/examples/gallery.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | yui3 = require("yui3");
5 |
6 | var YUI = yui3.YUI;
7 |
8 | var YUI3 = yui3.configure({
9 | core: '@2010.12.06',
10 | gallery: '2010.09.22'
11 | });
12 |
13 |
14 | YUI3({
15 | debug: true
16 | }).use('node', 'gallery-yql', function(Y) {
17 |
18 | new Y.yql('select * from github.user.info where (id = "davglass")', function(r) {
19 | //Do something here.
20 | Y.log(r.query, 'debug', 'yql');
21 | });
22 |
23 |
24 | console.log('Gallery: ');
25 | console.log(Y.config.groups.gallery);
26 | });
27 |
28 | YUI({
29 | debug: true
30 | }).use('node', 'gallery-yql', function(Y) {
31 |
32 | new Y.yql('select * from github.user.info where (id = "davglass")', function(r) {
33 | //Do something here.
34 | Y.log(r.query, 'debug', 'yql');
35 | });
36 |
37 |
38 | console.log('Gallery: ');
39 | console.log(Y.config.groups.gallery);
40 | });
41 |
--------------------------------------------------------------------------------
/examples/general-dom.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | _logExclude: {
9 | 'attribute': true,
10 | 'base': true,
11 | 'get': true,
12 | 'loader': true,
13 | 'yui': true,
14 | 'widget': true,
15 | 'event': true
16 | },
17 | debug: true
18 | }).use('node', function(Y) {
19 |
20 | Y.log('JSDom testing..');
21 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
22 | var document = Y.Browser.document;
23 |
24 | var i = Y.Node.create('Test This ');
25 | i.addClass('foo');
26 | Y.one('body').append(i);
27 |
28 | var div = document.createElement('div');
29 | div.id = 'foo';
30 | div.innerHTML = 'Test this awesome shit.. ';
31 | document.body.appendChild(div);
32 |
33 | var foo = Y.one('#foo');
34 | foo.addClass('bar');
35 |
36 | Y.log(document.getElementById('foo').outerHTML, 'info', 'GEBI');
37 | Y.log(document.getElementById('bax').outerHTML, 'info', 'GEBI');
38 |
39 | //sys.puts('Inside2: ' + sys.inspect(process.memoryUsage()));
40 | Y.log(Y.Node.getDOMNode(Y.one('strong')), 'info');
41 | Y.log(Y.all('em, #bax').toString(), 'info');
42 | Y.log(Y.Node.getDOMNode(Y.one('strong')), 'info');
43 |
44 | Y.log(Y.all('em, u').toString(), 'info');
45 | Y.log(Y.all('#foo, em, u, #bax'), 'info');
46 | //sys.puts('Inside3: ' + sys.inspect(process.memoryUsage()));
47 |
48 | Y.log(i.toString(), 'info', 'node-instance');
49 | Y.log(Y.Node.getDOMNode(i).outerHTML, 'info', 'HTML');
50 | Y.log(foo.toString(), 'info', 'node-instance');
51 | Y.log(foo.get('className'), 'info', 'classname');
52 | Y.log(Y.Node.getDOMNode(foo).outerHTML, 'info', 'HTML');
53 |
54 | Y.log(Y.one('body'), 'info', 'BODY');
55 | Y.log(Y.all('body, div', null, true), 'info', 'BODY');
56 |
57 | Y.log(document.body.outerHTML, 'info', 'HTML');
58 | Y.log(document.getElementById('foo\:bar'), 'info', 'HTML');
59 | Y.log(document.getElementById('foo:bar'), 'info', 'HTML');
60 |
61 |
62 | Y.log(document.parentNode, 'info', 'document.parentNode');
63 |
64 | Y.log(document.outerHTML, 'info', 'document.outerHTML');
65 |
66 | //Y.log(document.getElementById('bax').outerHTML, 'HTML');
67 |
68 | });
69 |
--------------------------------------------------------------------------------
/examples/inside.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | debug: true
10 | }).use('json', 'base', 'io', 'yql', function(Y) {
11 |
12 | console.log('YQL1: ', Y.YQL);
13 | var Y2 = YUI({ filter: 'debug', debug: true }).use('*');
14 | console.log('YQL2: ', Y2.YQL);
15 |
16 | });
17 |
--------------------------------------------------------------------------------
/examples/io.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | debug: true
10 | }).use('json', 'io', function(Y) {
11 |
12 | var url = 'http:/'+'/yuilibrary.com/gallery/api/user/davglass';
13 |
14 | var url2 = 'http:/'+'/localhost/~davglass/node-post/';
15 |
16 | var url3 = 'http:/'+'/localhost:8500/';
17 |
18 | var url4 = 'https:/'+'/graph.facebook.com:443/davglass';
19 |
20 | Y.io(url, {
21 | on: {
22 | start: function() {
23 | Y.log('Start IO #1', 'info', 'io1');
24 | },
25 | success: function(id, o) {
26 | //Y.log(o.responseText);
27 | Y.log(sys.inspect(Y.JSON.parse(o.responseText).userinfo), 'info', 'io1');
28 | }
29 | }
30 | });
31 |
32 |
33 | Y.io(url2, {
34 | method: 'POST',
35 | headers: {
36 | foo: 'bar'
37 | },
38 | data: 'test=post&this=data&testing=three',
39 | on: {
40 | start: function() {
41 | Y.log('Start IO #2', 'info', 'io2');
42 | },
43 | success: function(id, o) {
44 | Y.log(sys.inspect(Y.JSON.parse(o.responseText)), 'info', 'io2');
45 | },
46 | failure: function(id, o) {
47 | Y.log('IO FAILED', 'error', 'io2');
48 | }
49 | }
50 | });
51 |
52 | Y.io(url3, {
53 | on: {
54 | start: function() {
55 | Y.log('Start IO #3', 'info', 'io3');
56 | },
57 | failure: function(id, o) {
58 | Y.log('IO FAILED', 'error', 'io3');
59 | }
60 | }
61 | });
62 |
63 | Y.io(url4, {
64 | on: {
65 | start: function() {
66 | Y.log('Start IO #4', 'info', 'io4');
67 | },
68 | success: function(id, o) {
69 | Y.log(sys.inspect(Y.JSON.parse(o.responseText)), 'info', 'io4');
70 | }
71 | }
72 | });
73 |
74 | });
75 |
--------------------------------------------------------------------------------
/examples/library.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var start = (new Date()).getTime();
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 |
7 | YUI({
8 | filter: 'debug',
9 | debug: true
10 | }).use('json', 'base', 'yql', function(Y) {
11 |
12 | //sys.puts('Inside: ' + sys.inspect(process.memoryUsage()));
13 | //Logger outputs with sys.puts
14 | Y.log('This is a test');
15 | //Lang is available
16 | Y.log('Test: ' + Y.Lang.isBoolean(true), 'debug', 'myapp');
17 |
18 | //Creating a simple class
19 | var One = function() {
20 | One.superclass.constructor.apply(this, arguments);
21 | };
22 | //Extending it with Y.Base so we have Custom Events and a lifecycle
23 | Y.extend(One, Y.Base, {
24 | test: function() {
25 | this.publish('foo', {
26 | emitFacade: true
27 | });
28 | this.fire('foo');
29 | }
30 | }, {
31 | NAME: 'one'
32 | });
33 |
34 | //Create a new instance of our new class
35 | var o = new One();
36 | o.on('foo', function(o) {
37 | Y.log('Foo Fired', 'debug', 'myapp');
38 | //Y.log(o, 'debug');
39 | });
40 | o.test(); //Should fire the one:foo Event.
41 |
42 | //sys.puts(sys.inspect(Y));
43 |
44 | Y.YQL('select * from github.user.info where (id = "davglass")', function(r) {
45 | //Do something here.
46 | Y.log(r.query, 'debug', 'yql');
47 | Y.log((new Date()).getTime() - start + 'ms', 'info', 'TIMER');
48 | });
49 |
50 | var json = '{ "test": "one" }';
51 | Y.log(Y.JSON.parse(json), 'debug', 'json');
52 |
53 | });
54 |
--------------------------------------------------------------------------------
/examples/loadDir.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 |
7 | YUI.add('foo', function(Y) {
8 | Y.log('FOO LOADED');
9 | });
10 |
11 | YUI({
12 | loadDir: {
13 | base: __dirname + '/mods/',
14 | dirs: ['/', 'views/', '/modals/', '/foo/']
15 | },
16 | filter: 'debug',
17 | debug: true
18 | }).use('base', 'mod1', 'mod2', 'mod3', 'view-mod1', 'view-mod2', 'view-mod3', 'modal-mod1', 'modal-mod2', 'modal-mod3', function(Y) {
19 |
20 | Y.log('This is a test of loading internal and external custom YUI3 modules');
21 |
22 | });
23 |
--------------------------------------------------------------------------------
/examples/loader.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var start = (new Date()).getTime();
3 | var YUI = require("yui3").YUI;
4 |
5 |
6 | YUI({
7 | combine: false,
8 | filter: 'debug',
9 | debug: true
10 | }).use('node', function(Y) {
11 |
12 | var end = (new Date()).getTime();
13 | Y.log(end - start + 'ms', 'info', 'timer');
14 |
15 | });
16 |
--------------------------------------------------------------------------------
/examples/markup/layout.html:
--------------------------------------------------------------------------------
1 |
2 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
3 |
4 |
5 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
6 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
7 |
8 |
9 |
Right 1
10 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
11 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
12 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
13 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
14 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
15 |
16 |
17 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
18 |
19 |
20 |
Toggle Right Toggle Left
21 | Close Left Add Gutter to Right
22 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, .
23 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
24 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
25 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
26 |
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse justo nibh, pharetra at, adipiscing ullamcorper.
27 |
28 |
29 |
--------------------------------------------------------------------------------
/examples/markup/tabview.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/examples/mods/mod1.js:
--------------------------------------------------------------------------------
1 | YUI.add('mod1', function(Y) {
2 |
3 | Y.log('EXTERNAL MOD1 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/mod2.js:
--------------------------------------------------------------------------------
1 | YUI.add('mod2', function(Y) {
2 |
3 | Y.log('EXTERNAL MOD2 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/mod3.js:
--------------------------------------------------------------------------------
1 | YUI.add('mod3', function(Y) {
2 |
3 | Y.log('EXTERNAL MOD3 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/modals/mod1.js:
--------------------------------------------------------------------------------
1 | YUI.add('modal-mod1', function(Y) {
2 |
3 | Y.log('EXTERNAL MODAL-MOD1 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/modals/mod2.js:
--------------------------------------------------------------------------------
1 | YUI.add('modal-mod2', function(Y) {
2 |
3 | Y.log('EXTERNAL MODAL-MOD2 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/modals/mod3.js:
--------------------------------------------------------------------------------
1 | YUI.add('modal-mod3', function(Y) {
2 |
3 | Y.log('EXTERNAL MODAL-MOD3 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/views/mod1.js:
--------------------------------------------------------------------------------
1 | YUI.add('view-mod1', function(Y) {
2 |
3 | Y.log('EXTERNAL VIEW-MOD1 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/views/mod2.js:
--------------------------------------------------------------------------------
1 | YUI.add('view-mod2', function(Y) {
2 |
3 | Y.log('EXTERNAL VIEW-MOD2 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/mods/views/mod3.js:
--------------------------------------------------------------------------------
1 | YUI.add('view-mod3', function(Y) {
2 |
3 | Y.log('EXTERNAL VIEW-MOD3 LOADED');
4 |
5 | }, '1.0.0', { requires: ['node'] });
6 |
--------------------------------------------------------------------------------
/examples/module-dyn.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 |
7 | YUI.add('foo', function(Y) {
8 | Y.log('FOO LOADED');
9 | }, '1.0', { requires: ['external-foo'] });
10 |
11 | YUI({
12 | filter: 'debug',
13 | debug: true,
14 | modules: {
15 | 'external-foo': {
16 | fullpath: __dirname + '/external-module.js'
17 | }
18 | }
19 | }).use('base', 'foo', function(Y) {
20 |
21 | Y.log('This is a test of loading internal and external custom YUI3 modules');
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/examples/module-groups.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 |
7 | YUI.add('foo', function(Y) {
8 | Y.log('FOO LOADED');
9 | }, '1.0', { requires: ['external-foo'] });
10 |
11 | YUI({
12 | filter: 'debug',
13 | debug: true,
14 | groups: {
15 | dav: {
16 | modules: {
17 | 'external-foo': {
18 | fullpath: __dirname + '/external-module.js',
19 | requires: ['dom']
20 | }
21 | }
22 | }
23 | }
24 | }).use('base', 'foo', function(Y) {
25 |
26 | Y.log('This is a test of loading internal and external custom YUI3 modules');
27 |
28 | });
29 |
--------------------------------------------------------------------------------
/examples/module.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 | var YUI = require("yui3").YUI;
5 |
6 |
7 | YUI.add('foo', function(Y) {
8 | Y.log('FOO LOADED');
9 | });
10 |
11 | YUI({
12 | filter: 'debug',
13 | debug: true,
14 | modules: {
15 | 'external-foo': {
16 | fullpath: __dirname + '/external-module.js'
17 | }
18 | }
19 | }).use('base', 'foo', 'external-foo', function(Y) {
20 |
21 | Y.log('This is a test of loading internal and external custom YUI3 modules');
22 |
23 | });
24 |
--------------------------------------------------------------------------------
/examples/overlay-markup.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys');
3 |
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | debug: true
9 | }).use('overlay', function(Y) {
10 | var document = Y.Browser.document;
11 |
12 | Y.log('JSDom testing..');
13 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
14 |
15 | var div = document.createElement('div');
16 | div.id = 'demo';
17 | div.innerHTML = 'Overlay Header
Overlay Body
Overlay Footer
';
18 | document.body.appendChild(div);
19 |
20 | Y.log('Creating the Overlay from source..');
21 | var overlay = new Y.Overlay({
22 | // Specify a reference to a node which already exists
23 | // on the page and contains header/body/footer content
24 | srcNode:"#myContent",
25 |
26 | // Also set some of the attributes inherited from
27 | // the base Widget class.
28 | visible:false,
29 | width:"20em"
30 | });
31 |
32 | // Default everything
33 | Y.log('Rendering..');
34 | overlay.render("#demo");
35 |
36 |
37 | Y.log('Done..');
38 | Y.log(div.outerHTML, 'HTML');
39 |
40 | });
41 |
--------------------------------------------------------------------------------
/examples/overlay-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys');
3 |
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | logExclude: {
9 | 'attribute': true,
10 | 'base': true,
11 | //'get': true,
12 | 'loader': true,
13 | 'yui': true,
14 | 'widget': true,
15 | 'event': true
16 | },
17 | debug: true
18 | }).use('nodejs-dom', 'event', 'node-base', 'overlay', function(Y) {
19 | var document = Y.Browser.document;
20 |
21 | Y.log('JSDom testing..');
22 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
23 |
24 | var div = document.createElement('div');
25 | div.id = 'demo';
26 | document.body.appendChild(div);
27 |
28 | Y.log('Creating the Overlay from script..');
29 | // Default everything
30 | var overlay = new Y.Overlay({
31 | headerContent:"My Overlay Header",
32 | bodyContent:"My Overlay Body",
33 | footerContent:"My Footer Content",
34 | x: 200,
35 | y: 200
36 | });
37 | Y.log('Rendering..');
38 | overlay.render("#demo");
39 |
40 |
41 | Y.log('Done..');
42 | Y.log(div.outerHTML, 'HTML');
43 |
44 | });
45 |
--------------------------------------------------------------------------------
/examples/parallel.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var fs = require('fs');
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | debug: true
9 | }).use('parallel', function(Y) {
10 |
11 | Y.log('Reading this directory and reading the contents of each file..');
12 | var stack = new Y.Parallel();
13 | fs.readdir(__dirname, stack.add(function(err, files) {
14 | files.forEach(function(f) {
15 | fs.readFile(__dirname + f, stack.add(function(err, data) {
16 | //Do something here..
17 | }));
18 | });
19 | }));
20 | stack.done(function() {
21 | Y.log('All callbacks have fired..');
22 | });
23 |
24 | });
25 |
--------------------------------------------------------------------------------
/examples/process.js:
--------------------------------------------------------------------------------
1 | YUI.add('process', function(Y) {
2 |
3 | var netBinding = process.binding('net'),
4 | child_process = YUI.require('child_process'),
5 | net = YUI.require('net'),
6 | cwd = process.cwd(),
7 | isChild = false;
8 |
9 | process.argv.forEach(function(v) {
10 | if (v === '--child') {
11 | isChild = true;
12 | }
13 | });
14 |
15 | var Process = function() {
16 | Process.superclass.constructor.apply(this, arguments);
17 | };
18 | Y.extend(Process, Y.Base, {
19 | _children: null,
20 | _spawnChild: function() {
21 | var fds = netBinding.socketpair();
22 |
23 | // Collect the child process arguments
24 | var args = process.argv.slice(1);
25 | args.push('--child');
26 |
27 | // Spawn the child process
28 | var child = child_process.spawn(
29 | process.argv[0],
30 | args,
31 | undefined,
32 | [fds[1], fds[2], fds[3]]
33 | );
34 |
35 | child.__pid = parseInt(child.pid);
36 |
37 | this._children[child.pid] = child;
38 |
39 | if (!child.stdin) {
40 | child.stdin = new net.Stream(fds[0], 'unix');
41 | }
42 | if (!child.stdout) {
43 | child.stdout = new net.Stream(fds[1], 'unix');
44 | }
45 |
46 | child.stdout.addListener('data', Y.bind(function(data) {
47 | var d = JSON.parse(data);
48 | Y.log('Message: ' + d.message, 'info', 'child[' + d.pid + ']');
49 |
50 | this.fire('message', d);
51 | }, this));
52 | return child;
53 | },
54 | message: function(str) {
55 | console.log(JSON.stringify({ pid: process.pid, message: str }));
56 | },
57 | _onServerSignal: function(signal) {
58 | Y.log('Killing all children with signal: '+ signal);
59 | Y.each(this._children, function(c) {
60 | try {
61 | c.kill(signal);
62 | } catch (e) {}
63 | });
64 | process.exit();
65 | },
66 | _startServer: function() {
67 | var w = this.get('workers');
68 | for (var i = 0; i < w; i++) {
69 | this._spawnChild();
70 | }
71 | var self = this;
72 | ['SIGINT', 'SIGHUP', 'SIGTERM'].forEach(function(signal) {
73 | process.addListener(signal, Y.bind(self._onServerSignal, self, signal));
74 | });
75 | this.get('respawn');
76 |
77 | this.publish('sigchild', {
78 | defaultFn: this._sigChildFn
79 | });
80 | this.publish('sigcont', {
81 | defaultFn: this._sigContFn
82 | });
83 | this.publish('message', {
84 | emitFacade: false
85 | });
86 | },
87 | _sigChildFn: function(e) {
88 | Y.log('Child[' + e.child.__pid + '] died, spawning again.');
89 | this._spawnChild();
90 | },
91 | _onChildSig: function() {
92 | Y.each(this._children, function(c, i) {
93 | if (!c.pid) {
94 | delete this._children[i];
95 | this.fire('sigchild', { child: c });
96 | }
97 | }, this);
98 | },
99 | _sigContFn: function() {
100 | Y.log('SIGCONT Received Respawning all children');
101 | Y.each(this._children, function(c) {
102 | c.kill('SIGTERM');
103 | });
104 | },
105 | _onSigCont: function() {
106 | this.fire('sigcont');
107 | },
108 | _setRespawn: function() {
109 | Y.log('Adding respawn listeners');
110 | process.addListener('SIGCHLD', Y.bind(this._onChildSig, this));
111 | process.addListener('SIGCONT', Y.bind(this._onSigCont, this))
112 | },
113 | initializer: function() {
114 | this._children = {};
115 | },
116 | spawn: function() {
117 | if (this.get('child')) {
118 | this.fire('ready');
119 | Y.later((process.pid / 10), this, function() {
120 | this.message('Child process holder exiting..');
121 | });
122 | } else {
123 | this._startServer();
124 | }
125 | }
126 | }, {
127 | ATTRS: {
128 | child: {
129 | value: isChild
130 | },
131 | respawn: {
132 | value: true,
133 | setter: '_setRespawn'
134 | },
135 | workers: {
136 | value: 5
137 | }
138 | }
139 | });
140 |
141 | Y.Process = Process;
142 | });
143 |
--------------------------------------------------------------------------------
/examples/rls.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var start = (new Date()).getTime();
3 | var yui3 = require('yui3');
4 | var path = require('path');
5 | yui3.rls({
6 | //m: 'yui,loader,dd,widget,autocomplete,gallery-yql,yui2-datatable,gallery-aui-toolbar',
7 | //m: 'yui,loader,dd',
8 | //m: 'dd',
9 | m: 'loader,dd,widget,autocomplete,gallery-yql,yui2-datatable',
10 | //m: 'yui',
11 | //env: 'yui',
12 | //m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
13 | //env: 'node,attribute',
14 | //v: 'yui3-core@3.2.0',
15 | //v: '3.2.0',
16 | //gv: '2010.09.22',
17 | //parse: true //This parses the file content and returns it as the last arg
18 | //gmeta: __dirname + '/gallery-meta.js',
19 | //yui2meta: __dirname + '/2in3-meta.js',
20 | //filt: 'debug',
21 | //'2in3v': '2.8.0',
22 | GlobalConfig: {
23 | loaderPath: path.join(__dirname, '..', 'tests', 'extras', '/loader-min.js'),
24 | debug: true
25 | }
26 | }, function(err, data) {
27 | var end = (new Date()).getTime() - start;
28 | console.log('Callback..');
29 | console.log(data.js);
30 | console.log(data.css);
31 | var size = 0;
32 | for (var i in data.d) {
33 | if (data.d[i]) {
34 | size += data.d[i].length;
35 | console.log('i: ', i, (data.d[i].length));
36 | }
37 | }
38 | console.log('Total: ', [].concat(data.js, data.css).length);
39 | console.log('Total JS: ', data.js.length);
40 | console.log('Total CSS: ', data.css.length);
41 | console.log('Data: ', Object.keys(data.d).length);
42 | console.log('Size: (bytes)', size);
43 | console.log('Time: %sms', end);
44 |
45 | });
46 |
47 |
48 |
--------------------------------------------------------------------------------
/examples/scrape-object.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var YUI = require("yui3").YUI;
4 |
5 | YUI({
6 | debug: true
7 | }).use('node', 'io', function(Y) {
8 |
9 | //Messing with the main page..
10 | Y.one('title').set('innerHTML', 'Digg News Headlines');
11 | //Creating the list that we will append the remote data to
12 | var ul = Y.one('body').appendChild(Y.Node.create(''));
13 |
14 | //Creating a sandboxed instance that we will bind to the remote page that we fetch
15 | YUI().use('node', function(remotePage) {
16 | //The page we are fetching
17 | var url = 'http://digg.com:9500/news';
18 |
19 | //This will call io under the hood and get the content of the URL,
20 | //It will then dump the content of that page into this sandboxed document.
21 | remotePage.fetch(url, {
22 | success: function() {
23 | //Get all the news items from the remote page.
24 | var newsItems = remotePage.all('#story-items h3');
25 | //Iterate them
26 | newsItems.each(function(n) {
27 | //Import this "A" node into the outside instances document
28 | var a = ul.importNode(n.one('a'), true);
29 | //Clean up the relative URL's of hrefs
30 | a.set('href', 'http://digg.com' + a.get('href'));
31 | //Append the new node to the list
32 | ul.appendChild(Y.Node.create(' ')).append(a);
33 | });
34 | //Now, we can print the "outer" instances html and drop it to the screen
35 | console.log(Y.get('doc').get('outerHTML'));
36 | },
37 | failure: function() {
38 | Y.log('Fetch FAILED', 'error');
39 | }
40 | });
41 | });
42 |
43 | });
44 |
--------------------------------------------------------------------------------
/examples/scrape.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var YUI = require("yui3").YUI;
4 |
5 | YUI({
6 | debug: true
7 | }).use('node', 'io', function(Y) {
8 |
9 | //Messing with the main page..
10 | Y.one('title').set('innerHTML', 'Digg News Headlines');
11 | //Creating the list that we will append the remote data to
12 | var ul = Y.one('body').appendChild(Y.Node.create(''));
13 |
14 | //Creating a sandboxed instance that we will bind to the remote page that we fetch
15 | YUI().use('node', function(remotePage) {
16 | //The page we are fetching
17 | var url = 'http://digg.com/news';
18 |
19 | //This will call io under the hood and get the content of the URL,
20 | //It will then dump the content of that page into this sandboxed document.
21 | remotePage.fetch(url, function() {
22 | //Get all the news items from the remote page.
23 | var newsItems = remotePage.all('#story-items h3');
24 | //Iterate them
25 | newsItems.each(function(n) {
26 | //Import this "A" node into the outside instances document
27 | var a = ul.importNode(n.one('a'), true);
28 | //Clean up the relative URL's of hrefs
29 | a.set('href', 'http://digg.com' + a.get('href'));
30 | //Append the new node to the list
31 | ul.appendChild(Y.Node.create(' ')).append(a);
32 | });
33 | //Now, we can print the "outer" instances html and drop it to the screen
34 | console.log(Y.one('doc').get('outerHTML'));
35 | });
36 | });
37 |
38 | });
39 |
--------------------------------------------------------------------------------
/examples/slider-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys');
3 |
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | logExclude: {
9 | 'attribute': true,
10 | 'base': true,
11 | 'get': true,
12 | 'loader': true,
13 | 'yui': true,
14 | 'widget': true,
15 | 'event': true
16 | },
17 | debug: true
18 | }).use('nodejs-dom', 'event', 'node-base', 'slider', function(Y) {
19 | var document = Y.Browser.document;
20 |
21 | Y.log('JSDom testing..');
22 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
23 |
24 | var div = document.createElement('div');
25 | div.id = 'demo';
26 | document.body.appendChild(div);
27 |
28 | Y.log('Creating the Slider from script..');
29 | // Default everything
30 | var slider = new Y.Slider();
31 | Y.log('Rendering..');
32 | slider.render("#demo");
33 |
34 | Y.log('Done..');
35 | Y.log(div.outerHTML, 'HTML');
36 |
37 | });
38 |
--------------------------------------------------------------------------------
/examples/stdin.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | //Catch example errors
3 | var timer = setTimeout(function() {
4 | console.log('Failed to read stdin in 5 seconds, exiting..');
5 | process.exit(1)
6 | }, 5000);
7 |
8 | // curl -s http://yuilibrary.com/ | ./stdin.js
9 |
10 | require('yui3').stdin(function(Y) {
11 | clearTimeout(timer);
12 | Y.log('Page Title: ' + Y.one('title').get('innerHTML'));
13 | Y.log('Anchors: ' + Y.all('a').size());
14 | Y.log('Lists: ' + Y.all('ol,ul').size());
15 | Y.log('List Items: ' + Y.all('li').size());
16 | });
17 |
18 |
--------------------------------------------------------------------------------
/examples/sync-mod.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var Y = require('./sync-module');
3 |
4 | Y.YQL('select * from github.user.info where (id = "davglass")', function(r) {
5 | //Do something here.
6 | Y.log(r.query, 'debug', 'yql');
7 | });
8 |
--------------------------------------------------------------------------------
/examples/sync-module.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var YUI = require("yui3").YUI;
4 |
5 | YUI({
6 | filter: 'debug',
7 | _logExclude: {
8 | 'attribute': true,
9 | 'base': true,
10 | 'get': true,
11 | 'loader': true,
12 | 'yui': true,
13 | 'widget': true,
14 | 'event': true
15 | },
16 | debug: true
17 | }).useSync('yql', function(Ysync) {
18 |
19 | module.exports = Ysync;
20 |
21 | });
22 |
--------------------------------------------------------------------------------
/examples/sync.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var Y = require('yui3').useSync('yql');
3 |
4 | Y.YQL('select * from github.user.info where (id = "davglass")', function(r) {
5 | //Do something here.
6 | Y.log(r.query, 'debug', 'yql');
7 | });
8 |
--------------------------------------------------------------------------------
/examples/tabview-markup.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | debug: true
10 | }).use('tabview', function(Y) {
11 |
12 | var document = Y.Browser.document;
13 | Y.log('JSDom testing..');
14 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
15 |
16 | var div = document.createElement('div');
17 | div.id = 'demo';
18 | div.innerHTML = '';
19 | document.body.appendChild(div);
20 |
21 | console.log(div.outerHTML);
22 |
23 |
24 | Y.log('Creating the TabView from source..');
25 | Y.log(Y.one('#demo'));
26 |
27 | var tabview = new Y.TabView({
28 | srcNode: '#demo'
29 | });
30 |
31 | Y.log('Rendering..');
32 | tabview.on('render', function() {
33 | console.log(Y.one('doc').get('outerHTML'));
34 |
35 | Y.log('Render event listener');
36 | });
37 | tabview.render();
38 |
39 | Y.log('Done..');
40 | Y.log(div.outerHTML, 'HTML');
41 |
42 | });
43 |
--------------------------------------------------------------------------------
/examples/tabview-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys');
3 |
4 | var YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | logExclude: {
9 | 'attribute': true,
10 | 'base': true,
11 | //'get': true,
12 | //'loader': true,
13 | 'yui': true,
14 | 'widget': true,
15 | 'event': true
16 | },
17 | debug: true
18 | }).use('nodejs-dom', 'event', 'node-base', 'tabview', function(Y) {
19 |
20 | var document = Y.Browser.document;
21 | Y.log('JSDom testing..');
22 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
23 |
24 | var div = document.createElement('div');
25 | div.id = 'demo';
26 | document.body.appendChild(div);
27 |
28 | Y.log('Creating the TabView from script..');
29 | var tabview = new Y.TabView({
30 | children: [{
31 | label: 'foo',
32 | content: 'foo content
'
33 | }, {
34 | label: 'bar',
35 | content: 'bar content
'
36 | }, {
37 | label: 'baz',
38 | content: 'baz content
'
39 | }]
40 | });
41 |
42 | Y.log('Rendering..');
43 | tabview.render('#demo');
44 | //tabview.render(div);
45 | //tabview.render(Y.Node.getDOMNode(Y.one('#demo')));
46 | //Y.log(Y.Node.getDOMNode(Y.one('#demo')));
47 | //Y.log(div);
48 | Y.log('Done..');
49 | //Y.log(div.outerHTML, 'HTML');
50 | Y.log(Y.config.doc.outerHTML);
51 | });
52 |
--------------------------------------------------------------------------------
/examples/tnt-calendar-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys'),
3 | fs = require('fs');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | _logExclude: {
10 | 'attribute': true,
11 | 'base': true,
12 | 'get': true,
13 | 'loader': true,
14 | 'yui': true,
15 | 'widget': true,
16 | 'event': true
17 | },
18 | debug: true
19 | }).use('nodejs-dom', function(Y) {
20 | document = Y.Browser.document;
21 | navigator = Y.Browser.navigator;
22 | window = Y.Browser.window;
23 |
24 | Y.use('yui2-calendar', 'yui2-logger', function() {
25 | var YAHOO = Y.YUI2;
26 |
27 | Y.log('JSDom testing..');
28 |
29 | var el = document.createElement('div');
30 | el.id = 'cal1Container';
31 | document.body.appendChild(el);
32 |
33 | var cal1 = new YAHOO.widget.Calendar("cal1Container");
34 | cal1.renderEvent.subscribe(function() {
35 | Y.log('Done..');
36 | Y.log(document.outerHTML, 'HTML');
37 | });
38 | cal1.render();
39 | });
40 |
41 | });
42 |
--------------------------------------------------------------------------------
/examples/tnt-calendar-serve.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys'),
3 | http = require('http'),
4 | url = require('url'),
5 | fs = require('fs');
6 |
7 | var YUI = require("yui3").YUI;
8 |
9 | YUI({
10 | filter: 'raw',
11 | _logExclude: {
12 | 'attribute': true,
13 | 'base': true,
14 | 'get': true,
15 | 'loader': true,
16 | 'yui': true,
17 | 'widget': true,
18 | 'event': true
19 | },
20 | debug: true
21 | }).use('nodejs-dom', 'node', function(Y) {
22 | document = Y.Browser.document;
23 | navigator = Y.Browser.navigator;
24 | window = Y.Browser.window;
25 |
26 | var docType = '' + "\n";
27 |
28 | http.createServer(function (req, res) {
29 | var urlInfo = url.parse(req.url, true);
30 | YUI().use('nodejs-dom', 'node', function(Page) {
31 | Page.log(sys.inspect(urlInfo));
32 |
33 | Y.log('JSDom testing..');
34 | document = Page.Browser.document;
35 | navigator = Page.Browser.navigator;
36 | window = Page.Browser.window;
37 |
38 | document.title = 'Calendar Test';
39 |
40 | Page.one('body').addClass('yui-skin-sam');
41 |
42 | var ln = document.createElement('link');
43 | ln.href = "http://yui.yahooapis.com/2in3.1/2.8.0/build/yui2-skin-sam-calendar/assets/skins/sam/yui2-skin-sam-calendar-min.css"
44 | ln.setAttribute('rel', 'stylesheet');
45 | ln.setAttribute('type', 'text/css');
46 | document.getElementsByTagName('head')[0].appendChild(ln);
47 |
48 | var el = document.createElement('div');
49 | el.id = 'cal1Container';
50 | document.body.appendChild(el);
51 |
52 |
53 | Page.log('Fetching Calendar');
54 | Page.use('yui2-calendar', function () {
55 | var YAHOO = Page.YUI2,
56 | config = {};
57 | if (urlInfo.query) {
58 | var q = urlInfo.query;
59 | if (q.day && q.month && q.year) {
60 | config.pagedate = q.month + '/' + q.year;
61 | config.selected = q.month + '/' + q.day + '/' + q.year;
62 | }
63 | if (q.page) {
64 | config.pagedate = q.page;
65 | }
66 | }
67 | var cal1 = new YAHOO.widget.Calendar('cal1', "cal1Container", config);
68 | cal1.HIDE_BLANK_WEEKS = true;
69 | cal1.renderEvent.subscribe(function() {
70 | var pageDate = cal1.cfg.getProperty('pagedate');
71 | var next = YAHOO.widget.DateMath.add(pageDate, 'M', 1);
72 | var prev = YAHOO.widget.DateMath.subtract(pageDate, 'M', 1);
73 | next = (next.getMonth() + 1) + '/' + next.getFullYear();
74 | prev = (prev.getMonth() + 1) + '/' + prev.getFullYear();
75 |
76 | //Fix up the dom
77 | Page.one('#cal1 .calheader .calnavright').set('href', '/?page=' + next);
78 | Page.one('#cal1 .calheader .calnavleft').set('href', '/?page=' + prev);
79 | var as = Page.all('#cal1 .calcell a');
80 | Page.log('Found: ' + as.size());
81 | as.each(function(node) {
82 | node.set('href', '/?month=' + (pageDate.getMonth() + 1) + '&year=' + pageDate.getFullYear() + '&day=' + node.get('innerHTML'));
83 | });
84 |
85 | var oom = Page.all('#cal1 .calcell.oom');
86 | Page.log('Found: ' + oom.size());
87 | oom.set('innerHTML', '');
88 |
89 | Y.log('Done..');
90 | res.writeHead(200, {
91 | 'Content-Type': 'text/html'}
92 | );
93 | var out = docType + Page.one('doc').get('outerHTML');
94 | res.write(out);
95 | res.close();
96 |
97 | Page.log('PAGE: Serving Page');
98 | });
99 | cal1.render();
100 | });
101 |
102 |
103 | });
104 | }).listen(8000);
105 |
106 | Y.log('Server running at http://127.0.0.1:8000/');
107 |
108 | });
109 |
--------------------------------------------------------------------------------
/examples/tnt-datatable-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys'),
3 | fs = require('fs');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | //yui2: '2.8.0',
9 | filter: 'debug',
10 | _logExclude: {
11 | 'attribute': true,
12 | 'base': true,
13 | //'get': true,
14 | //'loader': true,
15 | 'yui': true,
16 | 'widget': true,
17 | 'event': true
18 | },
19 | debug: true
20 | }).use('nodejs-dom', function(Y) {
21 | document = Y.Browser.document;
22 | navigator = Y.Browser.navigator;
23 | window = Y.Browser.window;
24 |
25 | Y.log('JSDom testing..');
26 | Y.use('yui2-datatable', 'yui2-datasource', function(Y) {
27 | var YAHOO = Y.YUI2;
28 |
29 | var el = document.createElement('div');
30 | el.id = 'basic';
31 | document.body.appendChild(el);
32 |
33 | YAHOO.example.Data = {
34 | bookorders: [
35 | {id:"po-0167", date:new Date(1980, 2, 24), quantity:1, amount:4, title:"A Book About Nothing"},
36 | {id:"po-0783", date:new Date("January 3, 1983"), quantity:null, amount:12.12345, title:"The Meaning of Life"},
37 | {id:"po-0297", date:new Date(1978, 11, 12), quantity:12, amount:1.25, title:"This Book Was Meant to Be Read Aloud"},
38 | {id:"po-1482", date:new Date("March 11, 1985"), quantity:6, amount:3.5, title:"Read Me Twice"}
39 | ]
40 | };
41 |
42 |
43 | var myColumnDefs = [
44 | {key:"id", sortable:true, resizeable:true},
45 | {key:"date", formatter:YAHOO.widget.DataTable.formatDate, sortable:true, sortOptions:{defaultDir:YAHOO.widget.DataTable.CLASS_DESC},resizeable:true},
46 | {key:"quantity", formatter:YAHOO.widget.DataTable.formatNumber, sortable:true, resizeable:true},
47 | {key:"amount", formatter:YAHOO.widget.DataTable.formatCurrency, sortable:true, resizeable:true},
48 | {key:"title", sortable:true, resizeable:true}
49 | ];
50 |
51 | Y.log('Creating DataSource..');
52 | var myDataSource = new YAHOO.util.DataSource(YAHOO.example.Data.bookorders);
53 | myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
54 | myDataSource.responseSchema = {
55 | fields: ["id","date","quantity","amount","title"]
56 | };
57 | Y.log('Creating DataTable..');
58 |
59 | var myDataTable = new YAHOO.widget.DataTable("basic",
60 | myColumnDefs, myDataSource, {caption:"DataTable Caption"});
61 |
62 | myDataTable.on('renderEvent', function() {
63 | Y.log('Done..');
64 | Y.log(document.body.outerHTML, 'HTML');
65 | });
66 | });
67 | });
68 |
--------------------------------------------------------------------------------
/examples/tnt-layout-script.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 | var sys = require('sys'),
3 | fs = require('fs');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | logExclude: {
10 | 'attribute': true,
11 | 'base': true,
12 | 'get': true,
13 | 'loader': true,
14 | 'yui': true,
15 | 'widget': true,
16 | 'event': true
17 | },
18 | debug: true
19 | }).use('nodejs-dom', function(Y) {
20 | //GLOBALS!!!!
21 | document = Y.Browser.document;
22 | navigator = Y.Browser.navigator;
23 | window = Y.Browser.window;
24 | location = Y.Browser.location;
25 | self = Y.Browser.self;
26 |
27 |
28 | Y.log('JSDom testing..');
29 |
30 | Y.use('yui2-layout', function(Y) {
31 | var YAHOO = Y.YUI2;
32 | fs.readFile('./markup/layout.html', encoding='utf-8', function(err, data) {
33 | Y.log('Markup loaded..');
34 | Y.log(data);
35 | document.body.innerHTML = data;
36 | var layout = new YAHOO.widget.Layout({
37 | units: [
38 | { position: 'top', height: 50, body: 'top1', header: 'Top', gutter: '5px', collapse: true, resize: true },
39 | { position: 'right', header: 'Right', width: 300, resize: true, gutter: '5px', footer: 'Footer', collapse: true, scroll: true, body: 'right1', animate: true },
40 | { position: 'bottom', header: 'Bottom', height: 100, resize: true, body: 'bottom1', gutter: '5px', collapse: true },
41 | { position: 'left', header: 'Left', width: 200, resize: true, body: 'left1', gutter: '5px', collapse: true, close: true, collapseSize: 50, scroll: true, animate: true },
42 | { position: 'center', body: 'center1' }
43 | ]
44 | });
45 | Y.log('Rendering..');
46 | layout.render();
47 |
48 |
49 | Y.log('Done..');
50 | Y.log(document.body.outerHTML, 'HTML');
51 | });
52 | });
53 |
54 | });
55 |
--------------------------------------------------------------------------------
/examples/trap-error.js:
--------------------------------------------------------------------------------
1 | YUI.add('error', function(Y) {
2 | //This file contains a syntax error...
3 |
4 | if (baz.foo) {
5 | //This should error
6 | }
7 |
8 |
9 | }, '1.0.1');
10 |
--------------------------------------------------------------------------------
/examples/trap-test.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys');
4 |
5 | var YUI = require("yui3").YUI;
6 |
7 | YUI({
8 | filter: 'debug',
9 | debug: true,
10 | modules: {
11 | 'error': {
12 | fullpath: __dirname + '/trap-error.js'
13 | }
14 | }
15 | }).use('json', 'error', function(Y) {
16 |
17 | Y.log('Loaded..');
18 |
19 | });
20 |
21 |
--------------------------------------------------------------------------------
/examples/versions.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var netBinding = process.binding('net'),
4 | net = require('net'),
5 | fds = netBinding.socketpair(),
6 | npm = require('npm'),
7 | config = {
8 | exit: false,
9 | loglevel: 'silent',
10 | outfd: new net.Stream(fds[0], 'unix'),
11 | logfd: new net.Stream(fds[1], 'unix')
12 | };
13 |
14 | console.log('Fetching YUI versions from npm, this may take a moment...');
15 |
16 | npm.load(config, function() {
17 | npm.commands.ls(['yui3'], function(err, data) {
18 | var installed = {};
19 | for (var i in data) {
20 | if (i.match(/yui3-/)) {
21 | var c = i.split('@');
22 | installed[c[0]] = data[i].data.versions;
23 | }
24 | }
25 | start(installed);
26 | });
27 | });
28 |
29 | var express = require('express'),
30 | app = express.createServer();
31 |
32 | var start = function(mods) {
33 | var qs = require('querystring');
34 |
35 |
36 | var items = {
37 | 'core': {
38 | q: 'v'
39 | },
40 | 'gallery': {
41 | q: 'g'
42 | },
43 | '2in3': {
44 | q: 'yui2'
45 | }
46 | };
47 |
48 | app.get('/', function(req, res) {
49 | var p = req.query,
50 | out = '',
51 | helpers = {};
52 |
53 | var modules = 'Installed Packages ';
54 | for (var i in items) {
55 | var name = 'yui3-' + i;
56 | modules += '' + name + ' ';
57 | for (var v in mods[name]) {
58 | var m = mods[name][v];
59 | modules += '' + ((m.installed) ? '' + v + ' ' : v) + ((m.installed) ? ' Installed ' : ' Not Installed install via: npm install ' + name + '@' + v + '
') + ' ';
60 | if (m.installed) {
61 | if (!helpers[items[i].q]) {
62 | if (p[items[i].q] !== v) {
63 | helpers[items[i].q] = v;
64 | }
65 | }
66 | }
67 | }
68 | modules += ' ';
69 | }
70 |
71 | var YUIConfig = {};
72 | if (p.v) {
73 | YUIConfig.core = p.v;
74 | }
75 | if (p.g) {
76 | YUIConfig.gallery = p.g;
77 | }
78 | if (p.yui2) {
79 | YUIConfig['2in3'] = p.yui2;
80 | }
81 | var yui3 = require('yui3');
82 | var YUI = yui3.configure(YUIConfig).YUI;
83 |
84 | out += 'YUI Loaded From Config ';
85 | out += 'Core: ' + YUI.GlobalConfig.base + ' ';
86 | if (YUI.GlobalConfig.groups && YUI.GlobalConfig.groups.gallery) {
87 | out += 'Gallery: ' + YUI.GlobalConfig.groups.gallery.base + ' ';
88 | } else {
89 | out += 'Gallery is not installed: npm install yui3-gallery
';
90 | }
91 | if (YUI.GlobalConfig.groups && YUI.GlobalConfig.groups.yui2) {
92 | out += '2in3: ' + YUI.GlobalConfig.groups.yui2.base + ' ';
93 | } else {
94 | out += '2in3 is not installed: npm install yui3-2in3
';
95 | }
96 |
97 | var u = 'http:/'+'/localhost:8181/?' + qs.stringify(helpers);
98 | out += 'Hint: Try passing a config to the url: ' + u + ' ';
99 |
100 | out += modules;
101 |
102 | res.send(out);
103 | });
104 |
105 | console.log('Done, Server listening: http:/'+'/localhost:8181/');
106 | app.listen(8181);
107 | };
108 |
--------------------------------------------------------------------------------
/examples/y-browser.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | YUI = require("yui3").YUI;
5 |
6 | YUI({
7 | filter: 'debug',
8 | _logExclude: {
9 | 'attribute': true,
10 | 'base': true,
11 | 'get': true,
12 | 'loader': true,
13 | 'yui': true,
14 | 'widget': true,
15 | 'event': true
16 | },
17 | debug: false
18 | }).use('nodejs-dom', 'node', function(Y) {
19 |
20 | var document = Y.Browser.document;
21 | var window = Y.Browser.window;
22 | var self = Y.Browser.self;
23 | var navigator = Y.Browser.navigator;
24 | var location = Y.Browser.location;
25 |
26 | document.title = 'Example #1';
27 |
28 | //With the local aliases
29 | var el = document.createElement('div');
30 | el.id = 'foo';
31 | el.innerHTML = 'This is a test This is another test ';
32 | document.body.appendChild(el);
33 |
34 |
35 | //SCOPED
36 | var el2 = Y.Browser.document.createElement('div');
37 | el2.id = 'foo2bar';
38 | el2.innerHTML = 'This is a test This is another test ';
39 | Y.Browser.document.body.appendChild(el2);
40 |
41 | sys.puts('getElementByid(foo2bar): ' + Y.Browser.document.getElementById('foo2bar'));
42 | sys.puts('getElementByid(foo): ' + Y.Browser.document.getElementById('foo'));
43 | sys.puts('getElementByTagName(em): ' + Y.Browser.document.getElementsByTagName('em'));
44 | sys.puts('getElementByClassName(odd): ' + Y.Browser.document.getElementsByClassName('odd'));
45 |
46 | sys.puts('');
47 | sys.puts('Y.Browser.document.outerHTML: ');
48 | sys.puts(Y.Browser.document.outerHTML);
49 | });
50 |
51 | YUI({
52 | filter: 'debug',
53 | _logExclude: {
54 | 'attribute': true,
55 | 'base': true,
56 | 'get': true,
57 | 'loader': true,
58 | 'yui': true,
59 | 'widget': true,
60 | 'event': true
61 | },
62 | debug: false
63 | }).use('nodejs-dom', 'node', function(Y) {
64 |
65 | var document = Y.Browser.document;
66 | var window = Y.Browser.window;
67 | var self = Y.Browser.self;
68 | var navigator = Y.Browser.navigator;
69 | var location = Y.Browser.location;
70 |
71 | document.title = 'Example #2';
72 |
73 | //With the local aliases
74 | var el = document.createElement('div');
75 | el.id = 'foo';
76 | el.innerHTML = 'This is a test This is another test ';
77 | document.body.appendChild(el);
78 |
79 |
80 | //SCOPED
81 | var el2 = Y.Browser.document.createElement('div');
82 | el2.id = 'foo2bar';
83 | el2.innerHTML = 'This is a test This is another test ';
84 | Y.Browser.document.body.appendChild(el2);
85 |
86 | sys.puts('getElementByid(foo2bar): ' + Y.Browser.document.getElementById('foo2bar'));
87 | sys.puts('getElementByid(foo): ' + Y.Browser.document.getElementById('foo'));
88 | sys.puts('getElementByTagName(em): ' + Y.Browser.document.getElementsByTagName('em'));
89 | sys.puts('getElementByClassName(odd): ' + Y.Browser.document.getElementsByClassName('odd'));
90 |
91 | sys.puts('');
92 | sys.puts('Y.Browser.document.outerHTML: ');
93 | sys.puts(Y.Browser.document.outerHTML);
94 |
95 | });
96 |
--------------------------------------------------------------------------------
/examples/y-server-template.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | http = require('http'),
5 | fs = require('fs'),
6 | YUI = require("yui3").YUI;
7 |
8 | var DEBUG = true;
9 |
10 | YUI({ debug: DEBUG }).use('base', 'nodejs-dom', 'node', 'gallery-yql', 'json-stringify', function(Y) {
11 | Y.log('Loaded first instance..');
12 |
13 | var docType = '' + "\n";
14 |
15 | http.createServer(function (req, res) {
16 |
17 | YUI({ debug: DEBUG }).use('nodejs-dom', 'node', 'gallery-yql', 'json-stringify', function(Page) {
18 | //This is an example, normally we would use HTML templates.
19 | //Some JSON data to work on the template.
20 | var data = {
21 | TITLE: 'Test Page: ' + (new Date()),
22 | PARAS: [
23 | 'This is some test',
24 | 'This is some test',
25 | 'This is some test',
26 | 'This is some test',
27 | 'This is some test',
28 | 'This is some test'
29 | ]
30 | };
31 | Page.one('title').set('innerHTML', data.TITLE);
32 |
33 |
34 | var body = Page.one('body');
35 | body.append('The content below is dynamically generated on the server. You can access this code in 3 different ways:
');
36 | body.append('
');
37 |
38 | var el = Page.one('#wrapper');
39 |
40 | Y.each(data.PARAS, function(v, k) {
41 | el.append('' + v + ' : #' + k + '
');
42 | });
43 |
44 | var out = '', contentType = 'text/html';
45 | switch (req.url) {
46 | case '/json':
47 | out = Page.JSON.stringify(data);
48 | contentType = 'text/plain';
49 | break;
50 | case '/html':
51 | out = el.get('innerHTML');
52 | break;
53 | default:
54 | out = docType + Page.one('doc').get('outerHTML');
55 | }
56 | res.writeHead(200, {
57 | 'Content-Type': contentType
58 | });
59 | res.write(out);
60 | res.close();
61 |
62 | Page.log('PAGE: Serving Page');
63 | });
64 |
65 |
66 | }).listen(8000);
67 |
68 | Y.log('Server running at http://127.0.0.1:8000/');
69 |
70 | });
71 |
72 |
--------------------------------------------------------------------------------
/examples/y-server.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | http = require('http'),
5 | YUI = require("yui3").YUI;
6 |
7 | var DEBUG = true;
8 |
9 | YUI({ debug: DEBUG }).use('base', 'nodejs-dom', 'node', function(Y) {
10 | Y.log('Loaded first instance..');
11 |
12 | var docType = '' + "\n";
13 |
14 | http.createServer(function (req, res) {
15 |
16 | YUI({ debug: DEBUG }).use('nodejs-dom', 'node', function(Page) {
17 |
18 | Page.one('title').set('innerHTML', 'Test Page: ' + (new Date()));
19 | Page.one('body').append('This is a test
');
20 |
21 | res.writeHead(200, {
22 | 'Content-Type': 'text/html'}
23 | );
24 | var out = docType + Page.one('doc').get('outerHTML');
25 | //Y.log(out);
26 | res.write(out);
27 | res.close();
28 |
29 | Page.log('PAGE: Serving Page');
30 | //sys.puts(sys.inspect(process.memoryUsage(), true));
31 | });
32 |
33 |
34 | }).listen(8000);
35 |
36 | Y.log('Server running at http://127.0.0.1:8000/');
37 |
38 | });
39 |
40 |
--------------------------------------------------------------------------------
/lib/node-yui3.js:
--------------------------------------------------------------------------------
1 | var getYUI = function(c) {
2 | var yui3 = require('./yui3-yui3');
3 | var YUI = yui3.configure(c);
4 | return YUI;
5 | }
6 |
7 | // YInterface allows these two to work:
8 | // var Y = yui3.useSync("io");
9 | // var Y = yui3.configure({core:"3.3.0"}).useSync("io");
10 | // See also: tests/interface.js
11 | var inter = {};
12 |
13 | inter.__defineGetter__('YUI', function() {
14 | var YUI = getYUI();
15 | return YUI;
16 | });
17 |
18 | inter.silent = function(c) {
19 | var YUI = getYUI(c);
20 | return YUI({ debug: false });
21 | };
22 | inter.sync = function(c) {
23 | var YUI = getYUI(c);
24 | YUI.loadSync = true;
25 | return YUI();
26 | };
27 | inter.async = function(c) {
28 | var YUI = getYUI(c);
29 | YUI.loadSync = false;
30 | return YUI();
31 | };
32 |
33 | inter.useSync = function() {
34 | var YUI = getYUI();
35 | YUI.loadSync = true;
36 | var Y = YUI();
37 | return Y.use.apply(Y, arguments);
38 | }
39 |
40 | inter.use = function() {
41 | var YUI = getYUI();
42 | YUI.loadSync = false;
43 | var Y = YUI();
44 | return Y.use.apply(Y, arguments);
45 | }
46 |
47 | inter.configure = function (config) {
48 | var YUI = getYUI(config);
49 | var Y = YUI();
50 | //Workaround for old school .YUI access..
51 | Y.__defineGetter__('YUI', function() {
52 | var YUI = getYUI(config);
53 | return YUI;
54 | });
55 | return Y;
56 | };
57 |
58 | /**
59 | * This method accepts the default RLS configuration object and returns two arrays of file paths for js and css files.
60 | * @method rls
61 | * @param {Object} config The RLS configuration to work from
62 | * @param {Function} fn The callback executed when the process is completed
63 | * @returns {Callback} js, css Callback returns two arguments. Both arrays of file paths, one for JS and one for CSS files.
64 | */
65 | inter.rls = function(config, fn) {
66 | //The config to create the YUI instance with
67 | var c = {
68 | core: config.v,
69 | gallery: config.gv,
70 | yui2: config['2v'] || config['2in3v']
71 | };
72 |
73 | var YUI = getYUI(c);
74 | require('./yui3-rls').rls(YUI, config, fn);
75 |
76 | };
77 |
78 | /**
79 | * Inject the given HTML into a new YUI instance and return the instance.
80 | * @method fromString
81 | * @param {HTML} html The HTML string to inject into the YUI instance
82 | * @param {Object} config Optional YUI Config object
83 | * @param {Function} fn The callback executed when the process is completed
84 | * @returns {Callback} Y, html Callback returns two arguments. Y is the Y instance created, html is the original HTML.
85 | */
86 | inter.fromString = function(html, config, fn) {
87 | if (typeof config === 'function') {
88 | fn = config;
89 | config = {};
90 | }
91 | makeYUIFromHTML(html, config, fn);
92 | };
93 |
94 | /**
95 | * Inspired by: https://github.com/visionmedia/query/
96 | */
97 | /**
98 | * This method listens for the process stdin and takes the html from it and injects it into a new YUI instance.
99 | * @method stdin
100 | * @param {Object} config Optional YUI Config object
101 | * @param {Function} fn The callback executed when the process is completed
102 | * @returns {Callback} Y, html Callback returns two arguments. Y is the Y instance created, html is the original HTML.
103 | */
104 | inter.stdin = function(config, fn) {
105 | if (typeof config === 'function') {
106 | fn = config;
107 | config = {};
108 | }
109 | var YUI = getYUI(config);
110 |
111 | var stdin = process.openStdin(),
112 | html = '';
113 |
114 | stdin.setEncoding('utf8');
115 | stdin.on('data', function(data) {
116 | html += data;
117 | });
118 | stdin.on('end', function() {
119 | makeYUIFromHTML(html, config, fn);
120 | });
121 |
122 | };
123 |
124 | //Helper method to make a YUI instance from a string, used in fromString and stdin
125 | var makeYUIFromHTML = function(html, config, fn) {
126 | var YUI = getYUI(config);
127 |
128 | YUI({ logInclude: { cli: true } , debug: true }).use('node', function(Y) {
129 | if (html.indexOf(' -1) {
133 | //This is an HTML doc
134 | Y.one('doc').set('innerHTML', html);
135 | } else if (html.indexOf(' and ');
708 | if (cb) {
709 | pass(cb);
710 | }
711 | }
712 | };
713 |
714 | /**
715 | * Adds the link tag to the document, if it exists, if it doesn't, the files are added to the _cssLoad hash and loaded from processCSS
716 | */
717 | Y.Get.css = function(s, cb) {
718 | Y.log('Get.css', 'debug', 'get');
719 | if (!Y.Lang.isArray(s)) {
720 | s = [s];
721 | }
722 | if (!Y.config.win) {
723 | if (!Y.config._cssLoad) {
724 | Y.config._cssLoad = [];
725 | }
726 | s.forEach(function(v) {
727 | Y.config._cssLoad.push(v);
728 | Y.log('Defer Loading CSS: ' + v, 'debug', 'get');
729 | });
730 | } else {
731 | Y.log('Real CSS loading', 'debug', 'get');
732 | var head = Y.config.doc.getElementsByTagName('head')[0];
733 | s.forEach(function(link) {
734 |
735 | var base = Y.config.base,
736 | domBase = Y.config.domBase;
737 |
738 | if (link.indexOf(base) == -1) {
739 | base = domBase;
740 | }
741 | domBase = YUI.domRoot.yui3;
742 |
743 | if (link.indexOf('yui3-2in3') > -1) {
744 | base = Y.config.groups.yui2.base;
745 | //domBase = Y.config.groups.yui2.domBase;
746 | domBase = YUI.domRoot.yui2;
747 | }
748 | if (link.indexOf('yui3-gallery') > -1) {
749 | base = Y.config.groups.gallery.base;
750 | domBase = Y.config.groups.gallery.domBase;
751 | }
752 | link = link.replace(base, domBase);
753 | var l = Y.config.doc.createElement('link');
754 | l.setAttribute('rel', 'stylesheet');
755 | l.setAttribute('type', 'text/css');
756 | l.setAttribute('href', link);
757 | head.appendChild(l);
758 | });
759 | }
760 | if (cb) {
761 | pass(cb);
762 | }
763 | };
764 | });
765 |
766 | return YUI;
767 | }
768 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version":"0.5.34",
3 | "author":"Dav Glass ",
4 | "bugs":{
5 | "web":"http://github.com/davglass/nodejs-yui3/issues"},
6 | "os":[
7 | "darwin",
8 | "linux"],
9 | "contributors":[
10 | "Isaac Z. Schlueter (http://blog.izs.me)",
11 | "Robert Tsai ",
12 | "Bart Teeuwisse (http://thecodemill.biz/)",
13 | "Phil Dokas ",
14 | "Standa Opichal ",
15 | "Reid Burke "],
16 | "engines":{
17 | "node":">=0.4.0"},
18 | "scripts":{
19 | "test":"make tests"},
20 | "directories":{
21 | "lib":"lib"},
22 | "main":"./lib/node-yui3",
23 | "licenses":[
24 | {
25 | "type":"BSD",
26 | "url":"http://developer.yahoo.com/yui/license.html"}],
27 | "repository":{
28 | "type":"git",
29 | "url":"http://github.com/davglass/nodejs-yui3.git"},
30 | "name":"yui3",
31 | "description":"YUI 3 Library on NodeJS - Full Install - All dependencies",
32 | "bin":{
33 | "yui3docs":"./cli.js"},
34 | "dependencies":{
35 | "yui3-core":">=3.3.0",
36 | "jsdom":">=0.1.23",
37 | "htmlparser":">=1.7.3",
38 | "express":">=1.0.7",
39 | "connect":">=0.5.0"},
40 | "devDependencies":{
41 | "yuitest":"*"}}
--------------------------------------------------------------------------------
/packages/bare-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yui3-bare",
3 | "description": "YUI 3 Library on NodeJS - Bare - No Dependencies - Only install if you know what you are doing.",
4 | "devDependencies": {
5 | "yui3-core": ">=3.3.0",
6 | "jsdom": ">=0.1.23",
7 | "htmlparser": ">=1.7.3",
8 | "express": ">=1.0.7",
9 | "connect": ">=0.5.0",
10 | "yuitest" : "*"
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/packages/base-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yui3-base",
3 | "description": "YUI 3 Library on NodeJS - Base - Includes yui3-core dependency - NO DOM SUPPORT",
4 | "dependencies": {
5 | "yui3-core": ">=3.3.0"
6 | },
7 | "devDependencies": {
8 | "jsdom": ">=0.1.23",
9 | "htmlparser": ">=1.7.3",
10 | "express": ">=1.0.7",
11 | "connect": ">=0.5.0",
12 | "yuitest" : "*"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/packages/default-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.5.34",
3 | "author": "Dav Glass ",
4 | "bugs": { "web" : "http://github.com/davglass/nodejs-yui3/issues" },
5 | "os": ["darwin", "linux"],
6 | "contributors": [
7 | "Isaac Z. Schlueter (http://blog.izs.me)",
8 | "Robert Tsai ",
9 | "Bart Teeuwisse (http://thecodemill.biz/)",
10 | "Phil Dokas ",
11 | "Standa Opichal ",
12 | "Reid Burke "
13 | ],
14 | "engines": {
15 | "node" : ">=0.4.0"
16 | },
17 | "scripts": {
18 | "test": "make tests"
19 | },
20 | "directories": {
21 | "lib" : "lib"
22 | },
23 | "main": "./lib/node-yui3",
24 | "licenses":[
25 | {
26 | "type" : "BSD",
27 | "url" : "http://developer.yahoo.com/yui/license.html"
28 | }
29 | ],
30 | "repository": {
31 | "type":"git",
32 | "url":"http://github.com/davglass/nodejs-yui3.git"
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/packages/full-package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "yui3",
3 | "description": "YUI 3 Library on NodeJS - Full Install - All dependencies",
4 | "bin" : { "yui3docs" : "./cli.js" },
5 | "dependencies": {
6 | "yui3-core": ">=3.3.0",
7 | "jsdom": ">=0.1.23",
8 | "htmlparser": ">=1.7.3",
9 | "express": ">=1.0.7",
10 | "connect": ">=0.5.0"
11 | },
12 | "devDependencies": {
13 | "yuitest" : "*"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/perf/load.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var util = require('util'),
4 | assert = require('assert'),
5 | i, start, end, times, startTime, endTime, t,
6 | max = 500;
7 |
8 | console.log('Starting JS Load test with', max, 'requires');
9 |
10 | var print = function(i) {
11 | var per = Math.round(Math.max((i / max) * 100)),
12 | bar = '', o;
13 | for (o = 0; o < 50; o++) {
14 | if ((o*2) <= per) {
15 | bar += '#';
16 | }
17 | }
18 | util.print('\r(' + i + ') ' + per + '% ' + bar);
19 | }
20 |
21 | startTime = (new Date()).getTime();
22 | times = [];
23 |
24 | for (var i = 0; i <= max; i++) {
25 | start = (new Date()).getTime();
26 | var YUI = require('yui3').YUI;
27 | var Y = YUI({debug: false}).useSync('yql');
28 | //assert.ok(Y.YQL);
29 | end = (new Date()).getTime();
30 | times.push((end - start));
31 | print(i);
32 | }
33 |
34 | endTime = (new Date()).getTime();
35 | t = 0;
36 |
37 | times.forEach(function(v) {
38 | t += v;
39 | });
40 |
41 | util.print('\r\n');
42 | console.log('Test time: ', ((endTime - startTime) / 1000), 'sec');
43 | console.log('Average Time: ', ((t / max) / 1000), 'sec');
44 |
45 |
--------------------------------------------------------------------------------
/scripts/deps.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | node=`which node`
4 |
5 | if [ ! -f "$node" ]; then
6 | echo "NodeJS is required.."; exit 1;
7 | fi
8 |
9 | npm=`which npm`
10 |
11 | if [ ! -f "$npm" ]; then
12 | echo "NPM is required.."; exit 1;
13 | fi
14 |
15 |
--------------------------------------------------------------------------------
/scripts/install.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if ! test -d ./build; then
4 | echo "No build directory found"; exit 1;
5 | fi
6 | cd ./build
7 | for dir in ./*; do
8 | if [ "$dir" = "./*" ]; then
9 | echo "No builds found in ./build dir"
10 | exit 1;
11 | fi
12 | if test -f $dir/package.json; then
13 | echo "Installing from: $dir";
14 | echo "npm install $dir/"
15 | npm install $dir/
16 | fi
17 | done
18 |
--------------------------------------------------------------------------------
/scripts/make_package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | pack=$1;
4 |
5 | case $1 in
6 | base|bare|full) ;;
7 | *) echo "Invalid Package Name"; exit 1;;
8 | esac
9 |
10 | echo "Making YUI3 $pack package"
11 |
12 | if test -d ./build/$pack; then
13 | rm -rRf ./build/$pack
14 | fi
15 |
16 | dir="./build/$pack/"
17 |
18 | mkdir -p $dir
19 |
20 | cp README.* $dir
21 | wait
22 | cp LICENSE $dir
23 | wait
24 | cp -R lib $dir
25 | wait
26 | cp ./cli.js $dir
27 | wait
28 | cp ./packages/$pack-package.json ${dir}package.json
29 | wait
30 | ./scripts/merge_package_json.js $pack
31 | wait
32 | echo "Build Complete: $dir"
33 |
--------------------------------------------------------------------------------
/scripts/merge_package_json.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var fs = require('fs'),
4 | sys = require(process.binding('natives').util ? 'util' : 'sys'),
5 | path = require('path'),
6 | exists = path.existsSync,
7 | argv = process.argv.splice(2);
8 |
9 | if (argv.length === 0) {
10 | console.log('Pass a package type to merge..');
11 | process.exit(1);
12 | }
13 |
14 | var pack = argv[0];
15 | var main = fs.readFileSync('./packages/default-package.json', encoding='utf8');
16 | if (exists('./packages/' + pack + '-package.json')) {
17 | var other = fs.readFileSync('./packages/' + pack + '-package.json', encoding='utf8');
18 | } else {
19 | console.log('Can not find package: ', pack);
20 | process.exit(1);
21 | }
22 | try {
23 | main = JSON.parse(main);
24 | } catch (e) {
25 | console.log('default-package.json file failed to be parsed');
26 | process.exit(1);
27 | }
28 | try {
29 | other = JSON.parse(other);
30 | } catch (e) {
31 | console.log(pack + '-package.json file failed to be parsed');
32 | process.exit(1);
33 | }
34 |
35 | for (var i in other) {
36 | main[i] = other[i];
37 | }
38 |
39 | //var outData = sys.inspect(main, false, Infinity);
40 | var outData = JSON.stringify(main);
41 |
42 | outData = outData.replace(/,/g, ',\n\t').replace(/{/g, '{\n').replace(/\[/g, '[\n');
43 |
44 | if (exists('./build/' + pack)) {
45 | fs.writeFileSync(path.join('./build/', pack, 'package.json'), outData);
46 | } else {
47 | console.log('Failed to locate the build directory: ./build/' + pack);
48 | process.exit(1);
49 | }
50 |
--------------------------------------------------------------------------------
/scripts/publish.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Publishing all.."
4 | if ! test -d ./build; then
5 | echo "No build directory found"; exit 1;
6 | fi
7 | cd ./build
8 | for dir in ./*; do
9 | if [ "$dir" = "./*" ]; then
10 | echo "No builds found in ./build dir"
11 | exit 1;
12 | fi
13 | if test -f $dir/package.json; then
14 | echo "Publishing from: $dir";
15 | echo "npm publish $dir/"
16 | npm publish $dir/
17 | fi
18 | done
19 |
20 |
--------------------------------------------------------------------------------
/scripts/test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | yuitest=`which yuitest`
4 |
5 | if [ ! -f "$yuitest" ]; then
6 | echo "YUITest CLI is required.. (npm install yuitest)"; exit 1;
7 | fi
8 |
9 | #Checking Dependencies
10 | ./tests/deps.js
11 | if test $? -gt 0; then
12 | echo "Test dependencies failed.."; exit 1;
13 | fi
14 |
15 | $yuitest ./tests/*.js
16 |
--------------------------------------------------------------------------------
/tests/deps.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | try {
4 | require('yui3-core@3.2.0');
5 | } catch (e) {
6 | console.log('yui3-core@3.2.0 needs to be installed');
7 | process.exit(1);
8 | }
9 | try {
10 | require('yui3-core@3.3.0');
11 | } catch (e) {
12 | console.log('yui3-core@3.3.0 needs to be installed');
13 | process.exit(1);
14 | }
15 | try {
16 | require('yui3-gallery@2010.09.22');
17 | } catch (e) {
18 | console.log('yui3-gallery@2010.09.22 needs to be installed');
19 | process.exit(1);
20 | }
21 | try {
22 | require('yui3-2in3');
23 | } catch (e) {
24 | console.log('yui3-2in3 needs to be installed');
25 | process.exit(1);
26 | }
27 |
--------------------------------------------------------------------------------
/tests/html/dd.html:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 | item
8 | item
9 | item
10 | item
11 | item
12 | item
13 | item
14 |
15 |
16 |
--------------------------------------------------------------------------------
/tests/html/dom.html:
--------------------------------------------------------------------------------
1 |
2 |
Page Header
3 |
4 |
5 |
Section Header
6 |
choose
7 |
lorem ipsum
8 |
9 |
10 |
Module Header
11 |
12 |
13 |
Fusce feugiat diam. Vestibulum elementum dui in augue. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Mauris pulvinar.
14 |
15 |
16 |
17 |
18 |
19 |
Module Header
20 |
21 |
22 |
30 |
31 |
32 |
33 |
34 |
67 |
68 |
69 |
70 | test
71 |
72 |
73 |
74 |
In hac habitasse platea dictumst. Sed sit amet ligula vitae justo consequat facilisis. Integer tortor. Integer erat. In hac habitasse platea dictumst. Phasellus convallis quam vitae turpis aliquam lobortis. Aliquam scelerisque condimentum lectus. Proin semper adipiscing leo. Nulla facilisi.
75 |
76 |
77 |
--------------------------------------------------------------------------------
/tests/html/node.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
10 |
Lorem ipsum dolor sit .
11 |
12 |
13 |
Yahoo!
14 |
foo
15 |
16 | label
17 |
18 |
19 |
20 |
21 |
22 | textarea text
23 |
24 | button
25 |
26 | button text
27 |
28 | test class
29 |
texttest node
30 |
31 |
getStyle
32 |
baz
33 | text
34 |
35 |
foo bar baz
36 |
37 |
38 | inline style
39 |
40 | test computed style
41 |
42 |
43 | foo
44 | bar
45 | baz
46 |
47 |
48 |
49 |
50 | item 1
51 | item 2
52 | item 3
53 | item 4
54 |
55 |
56 | item 1
57 | item 2
58 | item 3
59 | item 4
60 |
61 |
62 |
63 |
66 |
67 |
68 | item 1
69 | item 2
70 | item 3
71 | item 4
72 |
73 |
74 | foo
75 |
76 |
test
77 |
78 |
79 |
80 | item 1
81 | item 2
82 | item 3
83 | item 4
84 |
85 |
86 |
87 |
test
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/tests/html/selector.html:
--------------------------------------------------------------------------------
1 |
2 |
lorem ipsum
3 |
lorem ipsum
4 |
lorem ipsum
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
15 |
16 | foo
17 | bar
18 | baz
19 |
20 |
21 |
22 | foo
23 | foo
24 | foo
25 | foo
26 | foo
27 | foo
28 | foo
29 | foo
30 | foo
31 | foo
32 |
33 |
34 |
35 |
span
36 |
first div
37 |
span
38 |
second div
39 |
third div
40 |
fourth div
41 |
span
42 |
43 | foo
44 |
45 | label
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | foo
55 | bar
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
H3 - Title
66 |
lorem ipsum dolor sit link
67 |
68 |
69 |
70 | contains "' & ]
71 |
72 |
73 |
74 |
75 | Window size
76 | dd1
77 | Document size
78 | dd2
79 |
80 |
81 |
test
82 | custom attribute
83 |
84 |
--------------------------------------------------------------------------------
/tests/interface.js:
--------------------------------------------------------------------------------
1 | var yui3 = require("../lib/node-yui3");
2 | var YUITest = require("yuitest").YUITest;
3 |
4 | var Assert = YUITest.Assert,
5 | ArrayAssert = YUITest.ArrayAssert,
6 | suite = new YUITest.TestSuite("YUI");
7 |
8 | //Generic Async Wait
9 | var async = function(fn) {
10 | var count = 0;
11 | return function(data) {
12 | var loaded = false;
13 | var w = function() {
14 | if (count === 100) {
15 | throw new Error('Async Timer reached 100 iterations..');
16 | }
17 | count++;
18 | if (!loaded) {
19 | this.wait(w, 10);
20 | }
21 | };
22 | var next = function() {
23 | loaded = true;
24 | };
25 | fn.call(this, data, next);
26 | this.wait(w, 10);
27 | };
28 | };
29 |
30 |
31 | suite.add( new YUITest.TestCase({
32 | name: 'Interface',
33 | "yui3 useSync" : function () {
34 | var Y = yui3.silent().useSync("loader");
35 | Assert.isObject(Y.Loader);
36 | },
37 | "yui3 configure useSync" : function () {
38 | var Y = yui3.configure({ debug: false }).useSync("loader");
39 | Assert.isObject(Y.Loader);
40 | },
41 | "yui3 YUI" : function () {
42 | var Y = yui3.YUI;
43 | Assert.isObject(Y);
44 | Assert.isUndefined(Y.Loader);
45 | },
46 | "yui3 configure YUI" : function () {
47 | var Y = yui3.configure({}).YUI;
48 | Assert.isObject(Y);
49 | Assert.isObject(Y.GlobalConfig);
50 | Assert.isUndefined(Y.Loader);
51 | },
52 | "yui3 configure core 320 YUI" : function () {
53 | var Y = yui3.configure({ core: '3.2.0' }).YUI;
54 | Assert.isObject(Y);
55 | Assert.isObject(Y.GlobalConfig);
56 | Assert.areNotEqual(Y.GlobalConfig.base.indexOf('3.2.0'), -1);
57 | Assert.isUndefined(Y.Loader);
58 | },
59 | "yui3 configure core 330 YUI" : function () {
60 | var Y = yui3.configure({ core: '3.3.0' }).YUI;
61 | Assert.isObject(Y);
62 | Assert.isObject(Y.GlobalConfig);
63 | Assert.areNotEqual(Y.GlobalConfig.base.indexOf('3.3.0'), -1);
64 | Assert.isUndefined(Y.Loader);
65 | },
66 | "yui3 use" : async(function (data, next) {
67 | yui3.silent().use("loader", function (Y) {
68 | Assert.isObject(Y.Loader);
69 | next();
70 | });
71 | }),
72 | "yui3 configure use" : async(function (data, next) {
73 | yui3.configure({ debug: false }).use("loader", function (Y) {
74 | Assert.isObject(Y.Loader);
75 | next();
76 | });
77 | }),
78 | "yui3 no gallery" : async(function (data, next) {
79 | yui3.configure({ debug: false, gallery: false }).use("loader", function (Y) {
80 | Assert.isUndefined(Y.config.groups.gallery);
81 | Assert.isObject(Y.Loader);
82 | next();
83 | });
84 | }),
85 | "yui3 no 2in3" : async(function (data, next) {
86 | yui3.configure({ debug: false, '2in3': false }).use("loader", function (Y) {
87 | Assert.isUndefined(Y.config.groups.yui2);
88 | Assert.isObject(Y.Loader);
89 | next();
90 | });
91 | }),
92 | "yui3 no 2in3 and no gallery" : async(function (data, next) {
93 | yui3.configure({ debug: false, '2in3': false, gallery: false }).use("loader", function (Y) {
94 | Assert.isUndefined(Y.config.groups.gallery);
95 | Assert.isUndefined(Y.config.groups.yui2);
96 | Assert.isObject(Y.Loader);
97 | next();
98 | });
99 | }),
100 | "yui3 no 2in3 and no gallery" : async(function (data, next) {
101 | var core = require('yui3-core@3.3.0');
102 | yui3.configure({ debug: false, '2in3': false, gallery: false, yuiPath: core.path(), yuiCoreFile: 'build/yui/yui-debug.js' }).use("loader", function (Y) {
103 | Assert.isUndefined(Y.config.groups.gallery);
104 | Assert.isUndefined(Y.config.groups.yui2);
105 | Assert.isObject(Y.Loader);
106 | next();
107 | });
108 | }),
109 | "imageloader test" : async(function (data, next) {
110 | var core = require('yui3-core@3.3.0');
111 | yui3.configure({ debug: false, '2in3': false, gallery: false, yuiPath: core.path(), yuiCoreFile: 'build/yui/yui-debug.js' }).use("imageloader", function (Y) {
112 | Assert.isUndefined(Y.config.groups.gallery);
113 | Assert.isUndefined(Y.config.groups.yui2);
114 | Assert.isObject(Y.Loader);
115 | Assert.isObject(Y.ImgLoadGroup);
116 | next();
117 | });
118 | }),
119 | "uploader test" : async(function (data, next) {
120 | var core = require('yui3-core@3.3.0');
121 | yui3.configure({ debug: false, '2in3': false, gallery: false, yuiPath: core.path(), yuiCoreFile: 'build/yui/yui-debug.js' }).use("uploader", function (Y) {
122 | Assert.isUndefined(Y.config.groups.gallery);
123 | Assert.isUndefined(Y.config.groups.yui2);
124 | Assert.isObject(Y.Loader);
125 | Assert.isObject(Y.Uploader);
126 | next();
127 | });
128 | })
129 | }));
130 |
131 |
132 | suite.add( new YUITest.TestCase({
133 | name: 'RLS',
134 | "rls full": async(function(data, next) {
135 | yui3.rls({
136 | m: 'yui,loader,dd,widget,autocomplete,gallery-yql,yui2-datatable',
137 | v: '3.3.0',
138 | parse: true,
139 | gv: '2010.09.22',
140 | '2in3v': '2.8.0'
141 | }, function(err, data) {
142 | Assert.areEqual(data.js.length, 33);
143 | Assert.areEqual(data.css.length, 4);
144 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
145 | next();
146 | });
147 | }),
148 | //No ENV, should return YUI module
149 | "rls mods no env": async(function(data, next) {
150 | yui3.rls({
151 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
152 | v: '3.3.0',
153 | parse: true,
154 | gv: '2010.09.22',
155 | '2in3v': '2.8.0'//,
156 | //filt: 'RAW',
157 | }, function(err, data) {
158 | Assert.areEqual(data.js.length, 32);
159 | Assert.areEqual(data.css.length, 4);
160 | Assert.areEqual((data.js.length + data.css.length), Object.keys(data.d).length);
161 | next();
162 | });
163 | }),
164 | "rls yui loader": async(function(data, next) {
165 | yui3.rls({
166 | m: 'yui,loader,dd',
167 | v: '3.3.0'
168 | }, function(err, data) {
169 | Assert.areEqual(data.js.length, 14);
170 | Assert.areEqual(data.css.length, 0);
171 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
172 | next();
173 | });
174 | }),
175 | "rls yui one module and noloader": async(function(data, next) {
176 | yui3.rls({
177 | m: 'yui,dd',
178 | v: '3.3.0'
179 | }, function(err, data) {
180 | Assert.areEqual(data.js.length, 13);
181 | Assert.areEqual(data.css.length, 0);
182 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
183 | next();
184 | });
185 | }),
186 | "rls yui only": async(function(data, next) {
187 | yui3.rls({
188 | m: 'yui',
189 | v: '3.3.0'
190 | }, function(err, data) {
191 | Assert.areEqual(data.js.length, 1);
192 | Assert.areEqual(data.css.length, 0);
193 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
194 | next();
195 | });
196 | }),
197 | "rls yui customloader no serve loader": async(function(data, next) {
198 | yui3.rls({
199 | m: 'yui,dd',
200 | v: '3.3.0',
201 | GlobalConfig: {
202 | loaderPath: __dirname + '/extras/loader-min.js'
203 | }
204 | }, function(err, data) {
205 | Assert.areEqual(data.Y.config.loaderPath, __dirname + '/extras/loader-min.js');
206 | Assert.areEqual(data.js.length, 13);
207 | Assert.areEqual(data.css.length, 0);
208 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
209 | next();
210 | });
211 | }),
212 | "rls yui customloader debug": async(function(data, next) {
213 | yui3.rls({
214 | m: 'yui,dd',
215 | v: '3.3.0',
216 | GlobalConfig: {
217 | loaderPath: __dirname + '/extras/loader-debug.js'
218 | }
219 | }, function(err, data) {
220 | Assert.areEqual(data.Y.config.loaderPath, __dirname + '/extras/loader-debug.js');
221 | Assert.areEqual(data.js.length, 13);
222 | Assert.areEqual(data.css.length, 0);
223 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
224 | next();
225 | });
226 | }),
227 | //Custom loader should only be used on the server, it should not be served.
228 | "rls yui customloader serve loader": async(function(data, next) {
229 | yui3.rls({
230 | m: 'yui,loader,dd',
231 | v: '3.3.0',
232 | GlobalConfig: {
233 | loaderPath: __dirname + '/extras/loader-min.js'
234 | }
235 | }, function(err, data) {
236 | Assert.areEqual(data.Y.config.loaderPath, __dirname + '/extras/loader-min.js');
237 | Assert.areNotEqual(data.Y.config.loaderPath, data.js[1]);
238 | Assert.areEqual(data.Y.config._loaderPath, data.js[1]);
239 | Assert.areEqual(data.js.length, 14);
240 | Assert.areEqual(data.css.length, 0);
241 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
242 | next();
243 | });
244 | }),
245 | "rls env": async(function(data, next) {
246 | yui3.rls({
247 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
248 | env: 'yui,node,attribute',
249 | v: '3.3.0',
250 | parse: true,
251 | gv: '2010.09.22',
252 | '2in3v': '2.8.0'//,
253 | //filt: 'RAW',
254 | }, function(err, data) {
255 | Assert.areEqual(data.js.length, 27);
256 | Assert.areEqual(data.css.length, 4);
257 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
258 | next();
259 | });
260 | }),
261 | "rls filter raw": async(function(data, next) {
262 | yui3.rls({
263 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
264 | env: 'yui,node,attribute',
265 | v: '3.3.0',
266 | parse: true,
267 | gv: '2010.09.22',
268 | '2in3v': '2.8.0',
269 | filt: 'RAW'
270 | }, function(err, data) {
271 | Assert.areEqual(data.js.length, 27);
272 | Assert.areEqual(data.css.length, 4);
273 | Assert.isTrue(data.js[1].indexOf('classnamemanager.js') > 0);
274 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
275 | next();
276 | });
277 | }),
278 | "rls filter min": async(function(data, next) {
279 | yui3.rls({
280 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
281 | env: 'yui,node,attribute',
282 | v: '3.3.0',
283 | parse: true,
284 | gv: '2010.09.22',
285 | '2in3v': '2.8.0',
286 | filt: 'MIN'
287 | }, function(err, data) {
288 | Assert.areEqual(data.js.length, 27);
289 | Assert.areEqual(data.css.length, 4);
290 | Assert.isTrue(data.js[1].indexOf('classnamemanager-min.js') > 0);
291 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
292 | next();
293 | });
294 | }),
295 | "rls filter debug": async(function(data, next) {
296 | var loaded = false;
297 | yui3.rls({
298 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
299 | env: 'yui,node,attribute',
300 | v: '3.3.0',
301 | parse: true,
302 | gv: '2010.09.22',
303 | '2in3v': '2.8.0',
304 | filt: 'DEBUG'
305 | }, function(err, data) {
306 | Assert.areEqual(data.js.length, 27);
307 | Assert.areEqual(data.css.length, 4);
308 | Assert.isTrue(data.js[1].indexOf('classnamemanager-debug.js') > 0);
309 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
310 | next();
311 | });
312 | }),
313 | "rls version 33": async(function(data, next) {
314 | yui3.rls({
315 | m: 'dd,widget,autocomplete,gallery-yql,yui2-datatable',
316 | env: 'yui,node,attribute',
317 | v: '3.3.0',
318 | parse: true,
319 | gv: '2010.09.22',
320 | '2in3v': '2.8.0'
321 | }, function(err, data) {
322 | Assert.areEqual(data.js.length, 27);
323 | Assert.areEqual(data.css.length, 4);
324 | Assert.isTrue(data.js[0].indexOf('3.3.0') > 0);
325 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
326 | next();
327 | });
328 | }),
329 | "rls version 32": async(function(data, next) {
330 | yui3.rls({
331 | m: 'dd,widget,gallery-yql,yui2-datatable',
332 | env: 'yui,node,attribute',
333 | v: '3.2.0',
334 | parse: true,
335 | gv: '2010.09.22',
336 | '2in3v': '2.8.0'
337 | }, function(err, data) {
338 | Assert.areEqual(data.js.length, 16);
339 | Assert.areEqual(data.css.length, 2);
340 | Assert.isTrue(data.js[0].indexOf('3.2.0') > 0);
341 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
342 | next();
343 | });
344 | }),
345 | "rls version gallery": async(function(data, next) {
346 | yui3.rls({
347 | m: 'dd,widget,gallery-yql,yui2-datatable',
348 | env: 'yui,node,attribute',
349 | parse: true,
350 | v: '3.2.0',
351 | gv: '2010.09.22',
352 | '2in3v': '2.8.0'
353 | }, function(err, data) {
354 | Assert.areEqual(data.js.length, 16);
355 | Assert.areEqual(data.css.length, 2);
356 | data.js.forEach(function(v) {
357 | if (v.indexOf('yui3-gallery') > -1) {
358 | Assert.isTrue(v.indexOf('2010.09.22') > 0);
359 | }
360 | });
361 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
362 | next();
363 | });
364 | }),
365 | "rls version yui2": async(function(data, next) {
366 | yui3.rls({
367 | m: 'dd,widget,gallery-yql,yui2-datatable',
368 | env: 'yui,node,attribute',
369 | parse: true,
370 | v: '3.2.0',
371 | gv: '2010.09.22',
372 | '2in3v': '2.8.0'
373 | }, function(err, data) {
374 | Assert.areEqual(data.js.length, 16);
375 | Assert.areEqual(data.css.length, 2);
376 | data.js.forEach(function(v) {
377 | if (v.indexOf('yui3-2in3') > -1) {
378 | Assert.isTrue(v.indexOf('2.8.0') > 0);
379 | }
380 | });
381 | Assert.areEqual([].concat(data.js, data.css).length, Object.keys(data.d).length);
382 | next();
383 | });
384 | }),
385 | "rls imageloader": async(function(data, next) {
386 | yui3.rls({
387 | m: 'imageloader',
388 | env: 'yui',
389 | v: '3.3.0'
390 | }, function(err, data) {
391 | Assert.isArray(data.js);
392 | Assert.areEqual(11, data.js.length, 'Not enough files returned');
393 | next();
394 | });
395 | }),
396 | "rls uploader": async(function(data, next) {
397 | yui3.rls({
398 | m: 'uploader',
399 | env: 'yui',
400 | v: '3.3.0'
401 | }, function(err, data) {
402 | Assert.isArray(data.js);
403 | Assert.areEqual(13, data.js.length, 'Not enough files returned');
404 | next();
405 | });
406 | })
407 | }));
408 |
409 | YUITest.TestRunner.add(suite);
410 |
--------------------------------------------------------------------------------
/tests/manual/comments.html:
--------------------------------------------------------------------------------
1 |
2 | This is a test. This is another test.
3 |
4 |
5 |
6 | This is a test. This is another test.
7 |
8 |
9 |
10 | This is a test. This is another test.
11 |
12 |
13 |
--------------------------------------------------------------------------------
/tests/manual/comments.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | fs = require('fs');
5 |
6 | var YUI = require("yui3").YUI;
7 |
8 | require("assert").equal( global.YUI, undefined, "global yui created");
9 |
10 |
11 | YUI({
12 | filter: 'debug',
13 | logExclude: {
14 | 'attribute': true,
15 | 'base': true,
16 | 'get': true,
17 | 'loader': true,
18 | 'yui': true,
19 | 'widget': true,
20 | 'event': true
21 | },
22 | debug: true
23 | }).use('nodejs-dom', function(Y) {
24 |
25 | Y.log('JSDom testing..');
26 |
27 | fs.readFile('./comments.html', encoding="utf-8", function(err, data) {
28 |
29 | Y.config.doc.body.innerHTML = data;
30 |
31 | Y.log('Document loaded');
32 | Y.log(Y.config.doc.outerHTML);
33 |
34 | });
35 |
36 |
37 |
38 |
39 |
40 |
41 | });
42 |
--------------------------------------------------------------------------------
/tests/manual/dd.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var sys = require('sys'),
4 | fs = require('fs');
5 |
6 | var YUI = require("yui3").YUI;
7 |
8 | require("assert").equal( global.YUI, undefined, "global yui created");
9 |
10 |
11 | YUI({
12 | filter: 'debug',
13 | logExclude: {
14 | 'dom-screen': true,
15 | 'attribute': true,
16 | 'base': true,
17 | 'get': true,
18 | 'loader': true,
19 | 'yui': true,
20 | 'widget': true,
21 | 'event': true
22 | },
23 | debug: true
24 | }).use('event', 'node', 'dd', 'dd-plugin', 'dd-drop-plugin', 'test', 'selector-css3', function(Y) {
25 |
26 | var document = Y.Browser.document;
27 | var window = Y.Browser.window;
28 |
29 |
30 | var dd_events = [
31 | 'drag:drag',
32 | 'drag:drophit',
33 | 'drag:end',
34 | 'drag:start',
35 | 'drag:enter',
36 | 'drag:over',
37 | 'drop:over',
38 | 'drop:enter',
39 | 'drop:hit'
40 | ],
41 | moveCount = 728;
42 |
43 | var _count = {},
44 | _resetCount = function() {
45 | Y.each(_count, function(v, k) {
46 | _count[k] = 0;
47 | });
48 | },
49 | _fakeStart = function(node) {
50 | _resetCount();
51 | Y.DD.DDM._noShim = true;
52 | node._dragThreshMet = true;
53 | node.set('activeHandle', node.get('node'));
54 | node._setStartPosition(node.get('node').getXY());
55 | Y.DD.DDM.activeDrag = node;
56 | Y.DD.DDM._start();
57 | node.start();
58 | },
59 | _fakeEnd = function(node) {
60 | Y.DD.DDM._end();
61 | node.end();
62 | node._handleMouseUp();
63 | Y.DD.DDM._noShim = false;
64 | },
65 | _moveNode = function(node, num, flip) {
66 | if (flip) {
67 | Y.DD.DDM._move({ pageX: 110, pageY: num });
68 | } else {
69 | Y.DD.DDM._move({ pageX: num, pageY: 110 });
70 | }
71 | },
72 | _moveNodeAll = function(node, max, flip) {
73 | for (var i = 0; i < max; i++) {
74 | _moveNode(node, i, flip);
75 | }
76 | },
77 | _fakeMove = function(node, max, flip) {
78 | _fakeStart(node);
79 | _moveNodeAll(node, max, flip);
80 | _fakeEnd(node);
81 | },
82 | _data = {
83 | one: 1,
84 | two: 2,
85 | three: 3
86 | },
87 | _handleCount = function(e) {
88 | if (!_count[e.type]) {
89 | _count[e.type] = 0;
90 | }
91 | _count[e.type]++;
92 | },
93 | dd, drop, proxy, del,
94 |
95 | template = {
96 | setUp : function() {
97 | },
98 |
99 | tearDown : function() {
100 | },
101 | test_shim: function() {
102 | var s = Y.DD.DDM._pg;
103 | Y.Assert.isNull(s, 'Shim: Node Instance');
104 | },
105 | test_drop_setup: function() {
106 | drop = new Y.DD.Drop({ node: '#drop', data: { one: 1, two: 2, three: 3 } });
107 | Y.Assert.isInstanceOf(Y.DD.Drop, drop, 'drop: Drop Instance');
108 | Y.Assert.isTrue(drop.get('node').hasClass('yui3-dd-drop'), 'drop: Drop Instance ClassName');
109 | },
110 | test_drop_setup_events: function() {
111 | Y.each(dd_events, function(v) {
112 | var handle = drop.on(v, _handleCount);
113 | Y.Assert.isInstanceOf(Y.EventHandle, handle, 'drop:handle [' + v + ']: Handle Instance');
114 | });
115 | },
116 | test_drag_setup: function() {
117 | dd = new Y.DD.Drag({ node: '#drag' });
118 | Y.Assert.isInstanceOf(Y.DD.Drag, dd, 'dd: Drag Instance');
119 | Y.Assert.isTrue(dd.get('node').hasClass('yui3-dd-draggable'), 'dd: Drag Instance ClassName');
120 | },
121 | test_shim_after: function() {
122 | var s = Y.DD.DDM._pg;
123 | Y.Assert.isInstanceOf(Y.Node, s, 'Shim: Node Instance');
124 | },
125 | test_drag_drop_setup: function() {
126 | dd.destroy();
127 | dd = new Y.DD.Drag({ node: '#drag', target: true });
128 | Y.Assert.isInstanceOf(Y.DD.Drag, dd, 'dd: Drag Instance');
129 | Y.Assert.isTrue(dd.get('node').hasClass('yui3-dd-draggable'), 'dd: Drag Instance ClassName');
130 | Y.Assert.isInstanceOf(Y.DD.Drop, dd.target, 'drag.target: Drop Instance');
131 | Y.each(dd._yuievt.targets, function(v, k) {
132 | Y.Assert.areSame(v, dd.target._yuievt.targets[k], 'bubbleTargets are not the same');
133 | });
134 | },
135 | test_drag_drop_group_setup: function() {
136 | dd.destroy();
137 | dd = new Y.DD.Drag({ node: '#drag', groups: ['one', 'two'], target: true });
138 | Y.Assert.areSame(dd.get('groups').length, dd.target.get('groups').length, 'Groups failed to pass from Drag to Drop');
139 | },
140 | test_drag_drop_group_pass_setup: function() {
141 | dd.destroy();
142 | dd = new Y.DD.Drag({ node: '#drag', target: { groups: ['one', 'two'] } });
143 | Y.Assert.areSame(1, dd.get('groups').length, 'Groups failed to pass from Drag to Drop');
144 | Y.Assert.areSame(2, dd.target.get('groups').length, 'Groups failed to pass from Drag to Drop');
145 | },
146 | test_drag_add_handle: function() {
147 | Y.Assert.isNull(dd._handles, 'dd: Handles NOT Null');
148 | dd.set('handles', ['h2']);
149 | Y.Assert.isObject(dd._handles, 'dd: Handles not an object');
150 | Y.Assert.isNotUndefined(dd._handles.h2, 'dd: Handles H2 not there');
151 | dd.set('handles', false);
152 | Y.Assert.isNull(dd._handles, 'dd: Handles NOT Null');
153 | dd.addHandle('h2');
154 | Y.Assert.isObject(dd._handles, 'dd: Handles not an object');
155 | Y.Assert.isNotUndefined(dd._handles.h2, 'dd: Handles H2 not there');
156 | dd.set('handles', false);
157 | Y.Assert.isNull(dd._handles, 'dd: Handles NOT Null');
158 | var wrap = Y.one('#wrap');
159 | dd.addHandle(wrap);
160 | Y.Assert.isObject(dd._handles, 'dd: Handles not an object');
161 | Y.Assert.isNotUndefined(dd._handles[wrap._yuid], 'dd: Handles ' + wrap._yuid + ' not there (Node Based Handle)');
162 | dd.set('handles', false);
163 | Y.Assert.isNull(dd._handles, 'dd: Handles NOT Null');
164 | },
165 | test_drag_setup_events: function() {
166 | Y.each(dd_events, function(v) {
167 | _count[v] = 0;
168 | var handle = dd.on(v, _handleCount);
169 | Y.Assert.isInstanceOf(Y.EventHandle, handle, 'drag:handle [' + v + ']: Handle Instance');
170 | });
171 | },
172 | test_drag_move: function() {
173 | dd.on('drag:end', function() {
174 | Y.Assert.areSame(moveCount, _count['drag:drag'], 'drag:drag should fire ' + moveCount + ' times');
175 | //Y.Assert.areSame(1, _count['drag:drophit'], 'drag:drophit should fire 1 time');
176 | Y.Assert.areSame(1, _count['drag:end'], 'drag:end should fire 1 time');
177 | Y.Assert.areSame(1, _count['drag:start'], 'drag:start should fire 1 time');
178 | //Y.Assert.areSame(1, _count['drag:enter'], 'drag:enter should fire 1 time');
179 | //Y.Assert.areSame(30, _count['drag:over'], 'drag:over should fire 30 times');
180 |
181 | //Y.Assert.areSame(30, _count['drop:over'], 'drop:over should fire 30 times');
182 | //Y.Assert.areSame(1, _count['drop:enter'], 'drop:enter should fire 1 time');
183 | //Y.Assert.areSame(1, _count['drop:hit'], 'drop:hit should fire 1 time');
184 | });
185 | _fakeMove(dd, moveCount);
186 | },
187 | test_drag_destroy: function() {
188 | dd.destroy();
189 | Y.Assert.isFalse(dd.get('node').hasClass('yui3-dd-draggable'), 'drag: Drag Instance NO ClassName');
190 | Y.Assert.isTrue(dd.get('destroyed'), 'drag: Destroyed Attribute');
191 | },
192 | test_proxy: function() {
193 | _resetCount();
194 | Y.one('#drag').setStyles({ top: '', left: '' });
195 | proxy = new Y.DD.Drag({
196 | node: '#drag'
197 | }).plug(Y.Plugin.DDProxy, {
198 | moveOnEnd: false
199 | });
200 | var p = Y.DD.DDM._proxy;
201 | Y.Assert.isInstanceOf(Y.Node, p, 'Proxy: Node Instance');
202 | Y.Assert.isInstanceOf(Y.Plugin.DDProxy, proxy.proxy, 'Proxy: Proxy Instance');
203 | Y.Assert.isTrue(p.hasClass('yui3-dd-proxy'), 'proxy: Proxy Node Instance ClassName');
204 | },
205 | test_proxy_setup_events: function() {
206 | Y.each(dd_events, function(v) {
207 | var handle = proxy.on(v, _handleCount);
208 | Y.Assert.isInstanceOf(Y.EventHandle, handle, 'proxy:handle [' + v + ']: Handle Instance');
209 | });
210 | },
211 | test_proxy_move: function() {
212 | _fakeMove(proxy, moveCount);
213 |
214 | Y.Assert.areSame(moveCount, _count['drag:drag'], 'drag:drag should fire ' + moveCount + ' times');
215 |
216 | //Y.Assert.areSame(1, _count['drag:drophit'], 'drag:drophit should fire 1 time');
217 | Y.Assert.areSame(1, _count['drag:end'], 'drag:end should fire 1 time');
218 | Y.Assert.areSame(1, _count['drag:start'], 'drag:start should fire 1 time');
219 | //Y.Assert.areSame(1, _count['drag:enter'], 'drag:enter should fire 1 time');
220 | //Y.Assert.areSame(30, _count['drag:over'], 'drag:over should fire 30 times');
221 |
222 | //Y.Assert.areSame(30, _count['drop:over'], 'drop:over should fire 30 times');
223 | //Y.Assert.areSame(1, _count['drop:enter'], 'drop:enter should fire 1 time');
224 | //Y.Assert.areSame(1, _count['drop:hit'], 'drop:hit should fire 1 time');
225 | },
226 | test_proxy_destroy: function() {
227 | proxy.destroy();
228 | Y.Assert.isFalse(proxy.get('node').hasClass('yui3-dd-draggable'), 'proxy: Drag Instance NO ClassName');
229 | Y.Assert.isTrue(proxy.get('destroyed'), 'Proxy: Destroyed Attribute');
230 | },
231 | test_drop_destroy: function() {
232 | drop.destroy();
233 | Y.Assert.isFalse(drop.get('node').hasClass('yui3-dd-drop'), 'Drop: Drop Instance NO ClassName');
234 | Y.Assert.isTrue(drop.get('destroyed'), 'Drop: Destroyed Attribute');
235 | },
236 | /*
237 | test_constrain_node_setup: function() {
238 | Y.one('#drag').setStyles({ top: '10px', left: '950px' });
239 | dd = new Y.DD.Drag({
240 | node: '#drag'
241 | }).plug(Y.Plugin.DDConstrained, {
242 | constrain2node: '#wrap'
243 | });
244 | Y.Assert.isInstanceOf(Y.DD.Drag, dd, 'dd: Drag Instance');
245 | Y.Assert.isInstanceOf(Y.Plugin.DDConstrained, dd.con, 'Constrained: DDConstrained Instance');
246 | Y.Assert.isTrue(dd.get('node').hasClass('yui3-dd-draggable'), 'dd: Drag Instance ClassName');
247 | },
248 | test_constrain_node_move: function() {
249 | var inRegion_before = dd.get('node').inRegion(Y.one('#wrap'));
250 |
251 | _fakeMove(dd, 25);
252 |
253 | var inRegion_after = dd.get('node').inRegion(Y.one('#wrap'));
254 | Y.Assert.isFalse(inRegion_before, 'Drag Node is in the region of #wrap');
255 | Y.Assert.isTrue(inRegion_after, 'Drag Node is NOT in the region of #wrap');
256 | dd.destroy();
257 | },
258 |
259 | test_constrain_view_setup: function() {
260 | Y.one('#drag').setStyles({ top: '-150px', left: '200px' });
261 | dd = new Y.DD.Drag({
262 | node: '#drag'
263 | }).plug(Y.Plugin.DDConstrained, {
264 | constrain2view: true
265 | });
266 | Y.Assert.isInstanceOf(Y.DD.Drag, dd, 'dd: Drag Instance');
267 | Y.Assert.isInstanceOf(Y.Plugin.DDConstrained, dd.con, 'Constrained: DDConstrained Instance');
268 | Y.Assert.isTrue(dd.get('node').hasClass('yui3-dd-draggable'), 'dd: Drag Instance ClassName');
269 | },
270 | test_constrain_view_move: function() {
271 | var inRegion_before = dd.get('node').inViewportRegion();
272 |
273 | _fakeMove(dd, 250);
274 |
275 | var inRegion_after = dd.get('node').inViewportRegion();
276 | Y.Assert.isFalse(inRegion_before, 'Drag Node is in the viewport');
277 | Y.Assert.isTrue(inRegion_after, 'Drag Node is NOT in the viewport');
278 | dd.destroy();
279 | },
280 | test_window_scroll: function() {
281 | Y.one('body').setStyle('height', '3000px');
282 | Y.one('#drag').setStyles({ top: '', left: '' });
283 | dd = new Y.DD.Drag({
284 | node: '#drag'
285 | }).plug(Y.Plugin.DDWinScroll);
286 | Y.Assert.isInstanceOf(Y.DD.Drag, dd, 'dd: Drag Instance');
287 | Y.Assert.isInstanceOf(Y.Plugin.DDWinScroll, dd.winscroll, 'WinScroll: WinScroll Instance');
288 |
289 | Y.one(window).set('scrollTop', 0);
290 | Y.one(window).set('scrollLeft', 0);
291 | _fakeStart(dd);
292 | var self = this,
293 | winHeight = Y.one(window).get('winHeight'),
294 | i = (winHeight - dd.get('node').get('offsetHeight') - 100),
295 | wait = function() {
296 | if (i < (Y.one(window).get('winHeight') - 30)) {
297 | _moveNode(dd, i, true);
298 | i++;
299 | self.wait.call(self, wait, 0);
300 | } else {
301 | self.wait.call(self, function() {
302 | _fakeEnd(dd);
303 | Y.Assert.isTrue((Y.one(window).get('scrollTop') > 0), 'window.scrollTop is not greater than 0');
304 | dd.destroy();
305 | Y.one('#drag').setStyles({ top: '', left: '' });
306 | Y.one(window).set('scrollTop', 0);
307 | Y.one(window).set('scrollLeft', 0);
308 | Y.one('body').setStyle('height', '');
309 | }, 1500);
310 | }
311 | };
312 | this.wait(wait, 0);
313 | },
314 | */
315 | test_delegate: function() {
316 | Y.one('#wrap').setStyle('display', 'none');
317 | Y.one('#del').setStyle('display', 'block');
318 | del = new Y.DD.Delegate({
319 | cont: '#del',
320 | nodes: 'li',
321 | invalid: '.disabled'
322 | });
323 | Y.Assert.isInstanceOf(Y.DD.Delegate, del, 'del: Delegate Instance');
324 | Y.Assert.isInstanceOf(Y.DD.Drag, del.dd, 'del.dd: Drag Instance');
325 | },
326 | test_delegate_setup_events: function() {
327 | Y.each(dd_events, function(v) {
328 | _count[v] = 0;
329 | var handle = del.on(v, _handleCount);
330 | Y.Assert.isInstanceOf(Y.EventHandle, handle, 'drag:handle [' + v + ']: Handle Instance');
331 | });
332 | },
333 | test_delegate_move: function() {
334 | _resetCount();
335 | del.on('drag:end', function() {
336 | Y.Assert.areSame(moveCount, _count['drag:drag'], 'drag:drag should fire ' + moveCount + ' times');
337 | Y.Assert.areSame(1, _count['drag:end'], 'drag:end should fire 1 time');
338 | Y.Assert.areSame(1, _count['drag:start'], 'drag:start should fire 1 time');
339 | del.get('currentNode').setStyles({
340 | top: 0, left: 0
341 | });
342 | });
343 | del._delMouseDown({
344 | currentTarget: Y.one('#del ul li')
345 | });
346 | _fakeMove(del.dd, moveCount);
347 | },
348 | test_delegate_move2: function() {
349 | _resetCount();
350 | del._delMouseDown({
351 | currentTarget: Y.one('#del ul li:nth-child(4)')
352 | });
353 | _fakeMove(del.dd, moveCount);
354 | },
355 | test_delegate_disabled: function() {
356 | del.detachAll();
357 | _resetCount();
358 | var mDown = false;
359 | del.on('drag:mouseDown', function() {
360 | mDown = true;
361 | });
362 | del._delMouseDown({
363 | currentTarget: Y.one('#del ul li:nth-child(6)')
364 | });
365 | Y.Assert.isFalse(mDown, 'Delegate mouseDown fired on a disabled item');
366 | }
367 | };
368 |
369 | Y.Test.Runner.clear();
370 | Y.Test.Runner.add(new Y.Test.Case(template));
371 |
372 | Y.log('JSDom testing..');
373 | //sys.puts('Inside1: ' + sys.inspect(process.memoryUsage()));
374 | fs.readFile(__dirname + '/../html/dd.html', encoding="utf-8", function(err, data) {
375 | ///Y.log(data);
376 | document.body.innerHTML = data;
377 | //Y.log(document.body);
378 |
379 | Y.log('Document loaded, run tests..');
380 | Y.Test.Runner.run();
381 | });
382 |
383 | });
384 |
--------------------------------------------------------------------------------