Skip to content

Instantly share code, notes, and snippets.

@dpobel
Last active December 18, 2015 08:59
Show Gist options
  • Select an option

  • Save dpobel/5758265 to your computer and use it in GitHub Desktop.

Select an option

Save dpobel/5758265 to your computer and use it in GitHub Desktop.
YUI.add('ez-stuff', function (Y) {
"use strict";
var L = Y.Lang,
MY_CLASS = 'ez-stuff-renderer';
/**
* Provides Y.eZ.Stuff
*
* @module ez-stuff
* @class Y.eZ.Stuff
*/
Y.namespace('eZ');
function _doAnotherStuff(arr) {
for (var i = 0; i <= arr.length; i++) {
arr[i] = arr[i] + 1;
}
}
Y.eZ.Stuff = Y.Base.create('stuffWidget', Y.Widget, [], {
config: {
fooBar: 'bar',
ez: 'eZ Publish'
},
/**
* Initializes the application:
*
* - step 1 bla bla bla
* - step 2 blab blbla
*
* @method initializer
*/
initializer: function () {
this.on('ready', function (e) {
if (e.target.stuff === this.get('config').foo) {
this._doStuff();
}
});
},
/**
* Renders the widget
*
* @method render
* @param node {Node|string} the Y.Node or a string selector to the node
* used to render the widget
*/
render: function (node) {
var cl = MY_CLASS.replace('foo', 'bar');
if (L.isString(node)) {
node = Y.one(node);
}
node.addClass(cl);
this._doStuff();
},
_doStuff: function () {
_doAnotherStuff();
}
}, {
ATTRS: {
/**
* Store the value handled by blalbla
*
* @attribute foo
* @default bar
* @type string
*/
foo: {
value: 'bar'
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment