Skip to content

Instantly share code, notes, and snippets.

@lsmith
lsmith / datatable-node.js
Created March 12, 2012 18:55
Simple DataTable progressive enhancement Node plugin
YUI.add('datatable-node', function (Y) {
Y.Plugin.DataTable = Y.Base.create('datatable', Y.DataTable, [], {
initializer: function (config) {
// Get the string contents of each <th> in the <thead> as an array
var columns = config.host.all('thead th').get('text'),
count = columns.length,
data = [],
i;
nsLeftPanel.cols = [
{
key:"email",
label:"Email",
formatter: function (o) {
if (o.data.id === nsLeftPanel.selectedRowId) {
o.rowClass += 'clickedRow';
}
if (!o.data.active) {
o.rowClass += ' inactiveShopper';
{
key: "pt_name",
label:"Pt name",
sortable:true,
formatter:fmt.general.ptNameFormatter,
sortOptions:{
sortFunction: function(a,b,desc,field){
desc = desc ? -1 : 1;
var name_a = fmt.general.getPtName(a),
@lsmith
lsmith / event-multi-defaultFn.js
Created February 17, 2012 20:45
Proof of concept support for multiple event behaviors
YUI.add('event-multi-defaultFn', function (Y) {
// FIXME: publish() needs to be patched to support allowing this to be called before
// publish(). Today, the publish() call will clobber the AOP wrapper.
Y.EventTarget.prototype.addEventBehavior = function (type, fn, when) {
var event = this.getEvent(type),
method = when === 'before' ? 'before' : 'after',
handle;
@lsmith
lsmith / gist:1726751
Created February 3, 2012 00:35
Button as subclass of Node
<!doctype html>
<head>
<meta charset="utf-8">
<title>Test Page</title>
</head>
<body>
<div id="x">
<button id="btn3">Button 3</button>
<button id="btn4">Button 4</button>
</div>
Y.DataTable.prototype.getCellColumnKey = function (node) {
var classRE = new RegExp('\b' + this.getClassName('col') + '-(\W+)'),
name, column;
node = node.ancestor('.' + this.getClassName('cell'), true);
if (node) {
name = (node.get('className').match(classRE) || [])[1];
column = name && this.getColumn(name);
@lsmith
lsmith / gist:1684564
Created January 26, 2012 19:29
Create an outerWidth Node attribute
Node.ATTRS.outerWidth = {
getter: function (el) {
return el.offsetWidth +
(parseInt(this.getComputedStyle('marginLeft'), 10) | 0) +
(parseInt(this.getComputedStyle('marginRight'), 10) | 0);
}
};
node.get('outerWidth'); // e.g. 300
// Version 1. Without separate 'uploader' module
YUI.add('uploader-flash', function (Y) {
function FlashUploader() { ... }
Uploader.ATTRS = {
};
Y.mix(FlashUploader.prototype, {
// prototype definition of Y.Uploader
@lsmith
lsmith / gist:1650683
Created January 21, 2012 01:38
Patch to make gallery-datatable-350-preview scrollable extension work
YUI.add('gallery-getscrollbarwidth', function (Y) {
Y.DOM.getScrollbarWidth = Y.cached(function () {
var doc = Y.config.doc,
testNode = doc.createElement('div'),
body = doc.getElementsByTagName('body')[0],
// 0.1 because cached doesn't support falsy refetch values
width = 0.1;
if (body) {
testNode.style.cssText = "position:absolute;visibility:hidden;overflow:scroll;width:20px;";
@lsmith
lsmith / README.md
Created January 20, 2012 18:46
DataTable code review local testing starter template

Locally testing DataTable (proposed for 3.5.0)

This describes how to set up your dev environment to build and test the DataTable code as it is proposed in pull request 70 (yui/yui3#70).

Requirements

  1. Local build of yui/yui3 repo from github
  2. Local build of yui/builder from github