Skip to content

Instantly share code, notes, and snippets.

View juandopazo's full-sized avatar

Juan Dopazo juandopazo

View GitHub Profile
@juandopazo
juandopazo / gist:4506753
Last active December 10, 2015 23:08
Issues with the current Y.Promise design when writing complex APIs based on promises
// This doesn't work due to some limitations in indexedDB
// It's just an example
// I'd like to be able to write:
Y.IndexedDB.open('mydb').store('myStore').put({
foo: 'bar'
});
/***************************
@juandopazo
juandopazo / gist:4177211
Created November 30, 2012 17:32
TabView structure
TabView boundingBox --> <div class="yui3-widget yui3-tabview">
TabView contentBox --> <div id="demo" class="yui3-tabview-content">
TabView listNode --> <ul class="yui3-tabview-list">
Tab boundingBox --> <li class="yui3-tab yui3-widget yui3-tab-selected">
Tab contentBox --> <a href="#foo" class="yui3-tab-label yui3-tab-content">foo</a>
</li>
</ul>
TabView panelNode --> <div class="yui3-tabview-panel">
Tab panelNode --> <div id="foo" class="yui3-tab-panel">foo content</div>
</div>
@juandopazo
juandopazo / gist:4128855
Created November 22, 2012 01:14
From ActiveX event to YUI instance
<script type="text/javascript">
YUI().use('datatable', function (Y) {
var datatable = new Y.DataTable(/* ... */);
Y.config.win.myCallback = function () {
// update datatable
};
});
</script>
<script type="text/javascript" for="MyControl" event="ReceiveMessage(msg)">
@juandopazo
juandopazo / gist:3936301
Created October 23, 2012 02:20
Foo module structure
src
|_ json
|_ js
| |_ foo.js
|
|_ meta
| |_ foo.json
| |_ foo-test.js
|
|_ build.json
{
"name": "foo",
"builds": {
"foo": {
"jsfiles": [
"foo.js"
]
},
"foo-fallback": {
"jsfiles": [
class EventEmitter extends Set {
constructor(owner) {
super();
this._owner = owner;
}
add(fn) {
super.add(listener);
return {
@juandopazo
juandopazo / gist:3928185
Created October 21, 2012 19:25
Templates template
YUI.add('mywidget-template', function (Y) {
Y.namespace('templates').mywidget = '<a href="#">{{foo}}</a>';
}, '0.0.1', {requires: ['substitute']});
@juandopazo
juandopazo / gist:3893468
Created October 15, 2012 16:35
YUI Stack plugin
function Stack(config) {
this.host = config.host;
Stack._instances.push(this);
this.host.on('mousedown', this.bringToFront, this);
}
Stack.NS = 'stack';
Stack._instances = [];
Y.mix(Stack.prototype, {
_unlist: function () {
var i = 0,
@juandopazo
juandopazo / foo.js
Created October 8, 2012 15:03
Loading modules with relative paths
YUI.add('foo', function (Y) {
Y.foo = 'foo';
});