Skip to content

Instantly share code, notes, and snippets.

View hatched's full-sized avatar

Jeff Pihach hatched

View GitHub Profile
Y.on('yqlData', function(e) {
Y.log(e.myYqlResponse);
});
Y.YQL('select...', function(e) {
Y.fire('yqlData', {myYqlResponse: e});
});
@hatched
hatched / gist:3814136
Created October 1, 2012 20:13
Add placeholder support to old browsers
YUI.add('placeholder', function(Y) {
var VALUE = 'value',
PLACEHOLDER = 'placeholder',
elements = {},
events = [];
/*
* The sync method allows you to add additional inputs to the page and then resync the placeholders
*/
isNumberSetter: function(value, name) {
Y.log('isNumberSetter', 'info', this.name);
var intValue = parseInt(value, 10);
if (!isNaN(intValue)) {
return intValue;
} else {
Y.log(name + ' is not a valid integer.', 'warn', this.name);
this.fire(name + 'ValidationFail');
@hatched
hatched / gist:3250093
Created August 3, 2012 18:09
Add a render event to the datatable body view
Y.DataTable.BodyView.prototype._afterDataChange = function (e) {
var view = this;
this.publish('render', {
defaultFn: function() {
view.render();
}
})
this.fire('render');
};
@hatched
hatched / gist:3220081
Created July 31, 2012 20:10
Add button trigger support to Y.PopupCalendar
//This is untested code, might need some tweaking
Y.PopupCalendar.prototype._bindEvents = function() {
Y.log('_bindEvents', 'info', this.name);
var input = this.get('input');
if (input.get('type') === 'text') {
input.on('focus', this.showCalendar, this);
} else {
@hatched
hatched / gist:3170219
Created July 24, 2012 14:28
Display the current git branch in the prompt
export PS1='\u@\h \w `git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`\[\033[37m\]:'
modules: {
'mock-model-sync-rest': {
fullpath: 'lib/mock-model-sync-rest.js',
condition: {
trigger: 'model-sync-rest',
test: function() {
return true
},
when: 'after'
}
YUI.use('module', function(Y) {
Y.use('newModule');
// will load into current scope but you have no guarantee it's available
Y.use('newModule', function(Y) {
//Will only execute once the module is loaded but your now in your new scope
});
Y.on('newModuleLoaded', callbackInMainScope);
@hatched
hatched / gist:3000390
Created June 27, 2012 00:11
Use YUI Handlebars with expressjs 3
var Y = require('yui/handlebars');
app.configure(function() {
app.engine('handlebars', function(path, options, fn) {
fs.readFile('views/layout.handlebars', 'utf8', function(err, layout) {
fs.readFile(path, 'utf8', function(err, str) {
if (err) { return fn(err); }
var container = Y.Handlebars.compile(layout);
fn(null, container({body: str}));
@hatched
hatched / extension-view-parent.js
Created May 15, 2012 16:13 — forked from tivac/_README.md
View extension to support a simple Parent -> [ Child, Child, Child ] structure for Views
/*global YUI:true */
YUI.add("extension-view-parent", function(Y) {
var ViewParent;
ViewParent = function() {};
ViewParent.ATTRS = {
views : {
value : false
},
render : {