View gist:5888864
1 2 3 4 5
menu.on('itemClick', function (e) {
if (e.item.isOpen()) {
e.preventDefault();
}
});
View getAbsoluteBoundingRect.js
1 2 3 4 5 6 7 8 9 10
/**
Returns a bounding rect for _el_ with absolute coordinates corrected for
scroll positions.
The native `getBoundingClientRect()` returns coordinates for an element's
visual position relative to the top left of the viewport, so if the element
is part of a scrollable region that has been scrolled, its coordinates will
be different than if the region hadn't been scrolled.
This method corrects for scroll offsets all the way up the node tree, so the
View dom-class.js
1 2 3 4 5 6 7 8 9 10
var addClass, hasClass, removeClass;
 
// Some old browers don't support classList, fallbacks use className property
var _hasClassList = Y2.config.doc && 'classList' in Y2.config.doc.body;
 
Y2.mix(Y2.DOM, {
/**
* Determines whether a DOM element has the given className.
* @method hasClass
* @for DOM
View gist:5305286
1 2 3 4 5 6 7 8 9 10
YUI().use('autocomplete', 'jsonp', function (Y) {
 
var ac = new Y.AutoComplete({
source: function (query, callback) {
Y.jsonp('http://example.com/api/autocomplete?query=' + encodeURIComponent(query) + '&callback={callback}', {
timeout: 10000 // 10 seconds,
 
on: {
success: callback,
failure: function () { /* ... */ },
View lazy-model.js
1 2 3 4 5 6 7 8 9 10
// Super fast read-only fake Model.
 
var GlobalEnv = YUI.namespace('Env.Model');
 
function LazyModel(config) {
this.data = Y.merge(config);
 
this.data.clientId || (this.data.clientId = this.generateClientId());
this.lists = [];
}
View yaypie.html
1 2 3 4 5 6 7 8 9 10
 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>pie is good</title>
<style>
html { background: #fff; }
body {
View gist:4676369
1 2 3 4 5 6
var re = /a/g,
str ='foo bar biz quux';
 
console.log(re.exec(str)); // => ["a"]
re.lastIndex = 0;
console.log(re.exec(str)); // => ["a"] (would be null if lastIndex weren't reset)
View stache.js
1 2 3 4 5 6 7 8 9 10
(function () {
 
// -- Constructor --------------------------------------------------------------
function Stache(template) {
this.parsed = false;
this._template = template;
}
 
// -- Static Functions ---------------------------------------------------------
Stache.render = function (template, view, partials) {
View property-base.js
1 2 3 4 5 6 7 8 9 10
function Property() {}
 
Property.prototype = {
// -- Public Prototype Methods ---------------------------------------------
defineProperties: function (properties) {
return Property.defineProperties(this, properties);
},
 
defineProperty: function (name, descriptor) {
return Property.defineProperty(this, name, descriptor);
View gist:3658306
1 2 3 4 5 6 7 8 9 10
{
// enforcing options (true means potentially more warnings)
 
"bitwise": true, // true if bitwise operators should not be allowed
"curly": true, // true if curly braces should be required around blocks in loops and conditionals
"eqeqeq": true, // true if === should be required (for ALL equality comparisons)
"forin": false, // true if unfiltered 'for in' statements should be forbidden
"immed": true, // true if immediate function invocations must be wrapped in parens
"newcap": true, // true if Initial Caps must be used with constructor functions
"noarg": true, // true if arguments.caller and arguments.callee should be forbidden
Something went wrong with that request. Please try again.