Skip to content

Instantly share code, notes, and snippets.

View stlsmiths's full-sized avatar
🎯
Focusing

Todd Smith stlsmiths

🎯
Focusing
View GitHub Profile
@stlsmiths
stlsmiths / dt_formatters.js
Created August 31, 2012 17:03
DT formatters
//
// trying to implement "named" formatters ... as {key:'foo', formatter:"currency2", ...}
//
// getting close ... http://blunderalong.com/yui/dtb/dt_formatters1.html
//
YUI.add("dt-formatters", function(Y){
var DtFormatStrings = {
Y.MyAwesomeView = Y.Base.create('myview',Y.View,[],{
// static props and methods
},{
// attrs and stuff
});
// referring to http://yuilibrary.com/yui/docs/api/classes/Base.html#method_create
//
@stlsmiths
stlsmiths / main.js
Created October 12, 2012 14:17 — forked from davglass/main.js
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Your Title</title>
<!-- Enter any page specific CSS link files -->
<link href="/yui/google-code-prettify/prettify.css" rel="stylesheet" type="text/css" />
<!-- Enter any local CSS declarations here -->
<style></style>
@stlsmiths
stlsmiths / gist:3940973
Created October 23, 2012 19:16
DS pag with custom query
// YUI3 functionality
YUI({skin: 'night'}).use('autocomplete', 'autocomplete-filters', 'autocomplete-highlighters', 'datatable-sort', 'datatable-scroll', 'cssfonts', 'cssbutton', 'dataschema-json', 'datatable-datasource', 'datasource-io', 'datatype', "datasource-jsonschema", 'model-sync-rest', 'gallery-paginator-view', 'gallery-datatable-paginator', 'dataschema', function(Y){
// Create datasource
var ds = new Y.DataSource.IO({source: '/index/test/load'});
ds.plug(Y.Plugin.DataSourceJSONSchema, {
schema: {
resultListLocator: 'Results',
resultFields: ['id', 'name'],
metaFields: {
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>DT Destroy</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body class="yui3-skin-sam">
<button id="btnRebuild">Rebuild it!</button>
<button id="btnDestroy">Destroy it!</button>
@stlsmiths
stlsmiths / gist:4155407
Created November 27, 2012 16:47
Creating a View instance to wrap a Popup Calendar in an Overlay
//
// Double-click on a cell in last column "Trans Date", opens a pop-up Calendar
// in an Overlay
// http://www.blunderalong.com/yui/dta/editing/dt_cellediting.html
PopupCalView = Y.Base.create('popupCal',Y.View,[],{
// Setup static properties to hold instances of Overlay and Calendar
_overlay: null,
@stlsmiths
stlsmiths / gist:4367514
Created December 24, 2012 04:22
Overriding paginatorDSRequest to add extra stuff ...
//
var dt = new Y.DataTable({
columns: ...
paginator: .....
requestStringTemplate: "?page={page}&itemsPerPage={itemsPerPage}&sortBy={sortBy}" // or whatever
});
// if you're using DataSource.IO see http://yuilibrary.com/yui/docs/api/classes/DataSource.IO.html#event_response
// if you're using DataSource.Get see http://yuilibrary.com/yui/docs/api/classes/DataSource.Get.html#event_response
// listen for the DS response as ....
myYUI3DataSource.after('response', function(o) {
/* the response object contains the following;
o.response.meta, = meta fields parsed from the DataSchema "metaFields"
@stlsmiths
stlsmiths / gist:4401054
Created December 28, 2012 19:23
YUI3 DT column formatter for HTML "link"
/**
This assumes you have "data" with the following "keys" defined,
customer_id, customer_name, carrier_name, carrier_id
It defines an HTML template as the base link HTML and uses a
YUI3 substitution function (Y.Lang.sub) to safely replace the
tokens within the htmlTMPL.
You must have "allowHTML:true" set for this to work properly.
BaseView = Y.Base.create('baseview', Y.View,[],{
//
// my awesome BaseView statics and methods
//
},{
ATTRS:{
//
// my awesome BaseView ATTRS
//
}