-
transport layer
-
transaction layer
-
encapsulated configuration layer (aka Resource/DataSource)
-
Transport layer
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
var datasource = new Y.DataSource.IO({ source: ... }); | |
datasource.on('data', function (e) { | |
var raw = Y.JSON.parse(e.data), | |
data = [], | |
key; | |
for (key in raw.pathToDataObject) { | |
if (raw.pathToDataObject[key]) { | |
data.push(raw.pathToDataObject[key]); | |
} |
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
var proxy = { | |
_data: {}, | |
get: function (name) { | |
var model = this._data; | |
return model.isYUIModel ? | |
model.apply(model, arguments) : | |
model[name]; | |
}, | |
set: function () { |
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
// Class extension to DataTable ... | |
Y.DataTable.Selection = function () {} | |
Y.DataTable.Selection.ATTRS = { | |
// selectionMode: for supporting multiple selection could be its own extension | |
selectionType: { | |
value: null, // Feature should not change base behavior by default | |
validator: '_validateSelectionType' |
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
// Adding a title attribute to a DataTable cell with a cellTemplate and a formatter | |
new Y.DataTable({ | |
columns: [ | |
{ | |
key: 'foo', | |
allowHTML: true, | |
// Notice the lack of > before {content} | |
cellTemplate: '<td class="{className}"{headers} {content}</td>', | |
formatter: function (o) { | |
// the > is included in the cell content string returned from the formatter. allowHTML is required. |
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
// Until some planned performance enhancements are applied to DataTable's infrastructure, | |
// this is a quick hack to improve rendering performance if it's needed: | |
// Some quacking will be needed for the various places where duck-typing is used | |
function DumbRecord(data) { | |
this.data = data; | |
this._id = 'record_' + DumbRecord._id++; | |
this.lists = []; // quack | |
} |
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
// Include this after the table's render() | |
// CAVEAT: this is NOT compatible with nodeFormatters | |
table.body._afterDataChange = function (e) { | |
var type = (e.type.match(/:(add|remove|change)$/) || [])[1], | |
odd = ['yui3-datatable-odd', 'yui3-datatable-even'], | |
even = ['yui3-datatable-even', 'yui3-datatable-odd'], | |
row, index; | |
switch (type) { | |
case 'change': |
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 code should allow users to tab to the first row in the table, which will "select" it by | |
adding a class to it and storing a reference to the row node. Alternately, users can click | |
on a row to select it. Selection can be shifted to the next or previous row with the up and down arrow keys. The 'enter' key will fire a 'rowAction' custom event. | |
*/ | |
table.getRow(0).setAttribute('tabindex', table.get('tabIndex') || 0); | |
table.delegate('keydown', function (e) { | |
var selected = this._selectedRow, | |
tbody = this._tbodyNode, |
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
// Add support for table.getColumn( node ) | |
Y.DataTable.prototype.getColumn = (function (original) { | |
return function (seed) { | |
var cell; | |
if (Y.instanceof(seed, Y.Node)) { | |
cell = this.getCell(seed); | |
seed = cell && (cell.get('className').match( | |
new RegExp(this.getClassName('col', '(\\w+)'))) || [])[1]; |
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 lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>test page</title> | |
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.4.1/build/cssreset/cssreset-min.css" id="changeme"> | |
</head> | |
<body> | |
<h1>This is a heading</h1> |