Browse files

some custom changes for tech training

Committer: Weiwei Shi <weiwei@tearsamebank-lm.peking.corp.yahoo.com>

On branch training
Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)

	modified:   examples/ajax/datasource_get.html
	modified:   examples/ajax/datasource_get_schema.html
	new file:   examples/ajax/io-queue.html
	new file:   examples/ajax/io-queue.php
	new file:   examples/ajax/node_load_pjax.html
	modified:   examples/events/event_order_dom.html
	modified:   examples/events/on_available.html
	new file:   examples/events/synthetic-konami.html
	modified:   examples/loading/add_monkeypatching.html
	modified:   examples/loading/js/patches/node-patches/node-patches.js
  • Loading branch information...
1 parent 9063837 commit 3477662d6a5a5d7e1ade72fd33bd390c6d47f98c @shiweiwei97 committed Sep 13, 2012
View
4 examples/ajax/datasource_get.html
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<title>Using a Remote JSON DataSource</title>
-<h1>JSLint: Recently closed issues</h1>
+<h1>Mojito: Recently closed issues</h1>
<ol id="issues"></ol>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
<script>
YUI().use('datasource-get', 'node-base', function (Y) {
- var src = 'https://api.github.com/repos/douglascrockford/JSLint/issues?state=closed',
+ var src = 'https://api.github.com/repos/yahoo/mojito/issues?state=closed',
dataSource = new Y.DataSource.Get({ source: src });
function displayIssues(rsp) {
View
4 examples/ajax/datasource_get_schema.html
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<title>Normalizing a Remote JSON DataSource with a DataSchema</title>
-<h1>JSLint: Recently closed issues</h1>
+<h1>Mojito: Recently closed issues</h1>
<ol id="issues"></ol>
<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
<script>
YUI().use('datasource-get', 'datasource-jsonschema', 'node-base', function (Y) {
- var src = 'https://api.github.com/repos/douglascrockford/JSLint/issues?state=closed',
+ var src = 'https://api.github.com/repos/yahoo/mojito/issues?state=closed',
dataSource = new Y.DataSource.Get({ source: src });
function displayIssues(rsp) {
View
31 examples/ajax/io-queue.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<title>IO Queue</title>
+
+<div id="demo"> </div>
+
+<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
+<script>
+YUI().use("io-queue", 'node-base', 'json-parse', function(Y) {
+
+ var cfg = {
+ on: {
+ success: function (id, response) {
+ var answer = Y.JSON.parse(response.responseText);
+ Y.one('#demo').append('<p> No: ' + answer.no + '</p>');
+ }
+ }
+ };
+
+ Y.io.queue.stop();
+
+ var task0 = Y.io.queue('io-queue.php', Y.merge(cfg, {data: {"no": 0}}));
+ var task1 = Y.io.queue('io-queue.php', Y.merge(cfg, {data: {"no": 1}}));
+ var task2 = Y.io.queue('io-queue.php', Y.merge(cfg, {data: {"no": 2}}));
+ var task3 = Y.io.queue('io-queue.php', Y.merge(cfg, {data: {"no": 3}}));
+
+ Y.io.queue.promote(task2);
+ Y.io.queue.remove(task3);
+
+ Y.io.queue.start();
+});
+</script>
View
7 examples/ajax/io-queue.php
@@ -0,0 +1,7 @@
+<?php
+header('Content-type: application/json');
+
+$response = array();
+$response['no'] = isset($_GET['no'])? $_GET['no']: 0;
+echo json_encode($response);
+?>
View
21 examples/ajax/node_load_pjax.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<title>Loading HTML Content into a Node</title>
+
+<h1>My Awesome Documentation</h1>
+<ul id="nav">
+ <li><a href="install.html" class="yui3-pjax">Installation</a></li>
+ <li><a href="examples.html" class="yui3-pjax">Examples</a></li>
+ <li><a href="api.html" class="yui3-pjax">API Reference</a></li>
+</ul>
+<div id="main">
+ <p>Some great documentation is about to appear here!</p>
+ <p>Boy howdy!</p>
+</div>
+<p id="footer">This is a footer. Copyright 2012, by ME.</p>
+
+<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
+<script>
+YUI().use('pjax', function (Y) {
+ new Y.Pjax({container: '#main'});
+});
+</script>
View
7 examples/events/event_order_dom.html
@@ -7,8 +7,11 @@
<script>
YUI().use('node-base', function (Y) {
var p = Y.one('p');
- p.on('click', function () { Y.log('I will execute first.') });
- p.on('click', function () { Y.log('I will execute second.') });
+ p.on('click', function (e) {
+ Y.log('I will execute first.');
+ e.stopImmediatePropagation();
+ });
p.on('click', function () { Y.log('I will execute third.') });
+ p.after('click', function () { Y.log('I will execute second.') });
});
</script>
View
7 examples/events/on_available.html
@@ -5,14 +5,13 @@
<script>
YUI().use('*', function (Y) {
if (Y.one('#demo') === null) {
- Y.log("We're sorry, the #demo node is currently not available.");
- Y.log('Your function() call is very important to us. Please try again later.');
+ Y.log("the #demo node not available.");
}
Y.on('available', function () {
- Y.one('#demo').setHTML('Sorry, I changed the div as fast as I could!');
+ Y.one('#demo').setHTML('#demo node changed.');
}, '#demo');
});
</script>
-<div id="demo"></div>
+<div id="demo">Original Content</div>
View
58 examples/events/synthetic-konami.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<title>Defining a Konami Synthetic Event</title>
+
+<input type="text" id="text-input">
+<p>
+ <input type="text" class="ko">
+ <input type="text" class="ko">
+ <input type="text" class="ko">
+</p>
+
+<script src="http://yui.yahooapis.com/3.5.0/build/yui/yui-min.js"></script>
+<script>
+YUI().use('node', 'event-synthetic', function (Y) {
+ var config = {
+ _keys: [ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65 ],
+
+ on: function (node, sub, notifier, filter) {
+ var method = (filter) ? 'delegate' : 'on',
+ progressKey = '-yui3-konami-progress(' + Y.guid() + ')',
+ keys = this._keys,
+ len = keys.length;
+
+ sub.handle = node[method]("keydown", function (e) {
+ var progress = this.getData(progressKey) || 0;
+
+ if (e.keyCode === keys[progress]) {
+ if (++progress === len) {
+ this.clearData(progressKey);
+ progress = 0;
+ notifier.fire(e);
+ }
+ } else {
+ progress = 0;
+ }
+
+ this.setData(progressKey, progress);
+
+ }, (filter || node));
+ },
+
+ detach: function (node, sub) {
+ sub.handle.detach();
+ }
+ };
+ config.delegate = config.on;
+ config.detachDelegate = config.detach;
+
+ Y.Event.define('konami', config);
+
+ Y.one('#text-input').on('konami', function (e) {
+ alert("You're a filthy cheater, and will be rewarded for it");
+ });
+
+ Y.one('p').delegate('konami', function (e) {
+ alert("You're a filthy cheater, and will be rewarded for it");
+ }, '.ko');
+});
+</script>
View
4 examples/loading/add_monkeypatching.html
@@ -9,7 +9,7 @@
groups: {
patches: {
// NOTE: On a local filesystem, change to './js/patches/'
- base: '/js/patches/',
+ base: './js/patches/',
modules: {
'node-patches' : {
path: 'node-patches/node-patches.js',
@@ -23,6 +23,6 @@
}
}
}).use('node-base', function (Y) {
- Y.one('#demo').setHTML("Hmmm, setHTML() is unusually fast these days.");
+ Y.one('#demo').setContent("Hmmm, setHTML() is unusually fast these days.");
});
</script>
View
4 examples/loading/js/patches/node-patches/node-patches.js
@@ -1,5 +1,5 @@
YUI.add('node-patches', function (Y) {
Y.Node.prototype.setContent = function (content) {
- this.set('innerHTML', content);
+ this.set('innerHTML', 'patched: ' + content);
}
-});
+});

0 comments on commit 3477662

Please sign in to comment.