This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add('typing-pause', function(Y) { | |
/** | |
* Custom event that fires after a configured delay in keyboard activity. The | |
* optional configuration object passed as the fourth param to Y.on accepts the | |
* following keys: | |
* <ul> | |
* <li><code>adaptive</code> - adapt the delay to the user's typing rate. | |
* Default <code>true</code></li> | |
* <li><code>minLength</code> - minimum number of characters to qualify |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Test Page</title> | |
</head> | |
<body> | |
<h1>The typing-pause special event</h1> | |
<p>Type stuff in the input below and watch for messages in the console.</p> | |
<input id="delay"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_sort: function(nodes) { | |
if (nodes) { | |
nodes = NativeSelector._toArray(nodes); | |
if (nodes.sort) { | |
var indices = [], i; | |
for (i = nodes.length - 1; i >= 0; --i) { | |
indices[i] = { i:i, idx:Y.DOM.srcIndex(nodes[i]) }; | |
} | |
indices.sort(function(a, b) { | |
return a.idx - b.idx; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
// The signature is pure coincidence ;) | |
function L(U,C){var d=document,f='firstChild',r='readyState',h=d.documentElement[f],s=d.createElement('script'),m=s[r]:'onreadystatechange':'';s.type='text/javascript';s.src=U;s[m||'onload']=function(){if(!m||/loaded|complete/.test(s[r])){s[m]=null;C()}};h.insertBefore(s,h[f]);} | |
// async loading of javascript files, starting asap. | |
L("http://example.com/example.js",function () { | |
doSomething(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is an out of date work in progress plugin for YUI 3 Slider to add | |
// support for value stops (aka ticks). | |
YUI.add('slider-values', function (Y) { | |
var MIN = 'min', | |
MAX = 'max', | |
VALUE = 'value', | |
isNumber = Y.Lang.isNumber, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1. Concat all module files you plan on using in your page into a | |
// personal rollup file. We'll call it bacon.js. | |
// At the end of bacon.js, add this line: | |
YUI.add('bacon', function (Y) {}, '@VERSION@',{ uses: ['list','of','the','concated','modules'] }); | |
// Step 2. Create a module config object to pass to the YUI constructor | |
var myModules = { | |
bacon: { | |
fullpath: 'https://path.to/bacon.js' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This gist aims to prove or disprove the assertion made here[1] and linked on | |
Ajaxian[2] that dynamic script requests, or more specifically JSONP requests, | |
leak memory in all modern browsers. | |
The specific setup is a 200ms interval that requests an uncached script pointed at | |
the simple php file. This file in response sends the following string: | |
update() | |
This is not technically a JSONP response, since the would-be callback is executed | |
without arguments. However, memory footprint results can be gauged on generic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How to rename DataTable columns from data in a server response | |
// This example assumes server response JSON looking like this: | |
{ records: [...], columnLabels: ['1/1/2009','1/2/2009','1/3/2009',...] } | |
// Add a convenience method onto the Column prototype | |
YAHOO.widget.Column.prototype.setLabel = function (label) { | |
var el = YAHOO.util.Dom.getElementsByClassName('yui-dt-label', 'span', this.getThLinerEl())[0]; | |
// The label needing updating could be a span or an anchor element for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myDataSource.connMgr = { | |
asyncRequest: function (req, callback) { | |
var originalFailureHandler = callback.failure; | |
callback.failure = function (o) { | |
if (o.status == '403') { | |
// Do your thing | |
} else { | |
originalFailureHandler(o); | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="frameworks/yui_2.7.0b/yui/build/yuiloader/yuiloader-debug.js"></script> | |
<script type="text/javascript" src="js/loader-config.js"></script> | |
<script type="text/javascript"> | |
(function() { | |
_yuiloader_config.config.onSuccess = function () { | |
}; | |
_yuiloader_config.config.onFailure = function () { | |
}; | |
var loader = new YAHOO.util.YUILoader(_yuiloader_config.config); |