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
| JSON.stringify(o, function (k,v) { | |
| if (v && typeof v === 'object' && !isArray(v)) { // assumes an isArray function | |
| var sorted = {}, | |
| keys = [], | |
| key,i,len; | |
| for (key in v) { | |
| if (v.hasOwnProperty(key)) { | |
| keys.push(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
| function increment() { | |
| count++; | |
| } | |
| var a = new Y.EventTarget(), | |
| b = new Y.EventTarget({ | |
| bubbles: true, | |
| emitFacade: true, | |
| prefix: 'foo' | |
| }), |
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
| function A() { Y.Widget.apply(this,arguments); }; | |
| Y.extend(A, Y.Widget); | |
| A.NAME = 'a'; | |
| function B() { Y.Widget.apply(this,arguments); }; | |
| Y.extend(B, Y.Widget); | |
| B.NAME = 'b'; | |
| var a = new A(), | |
| b = new B(); |
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
| YUI.add('prop.mod-a', function (Y) { | |
| /* Your module code here */ | |
| // shortcut to ensure Y.config.modules object is in place | |
| Y.namespace('config.modules')['yui2-utilities'] = { | |
| fullpath: 'http://yui.yahooapis.com/2.8.0r4/build/utilities/utilities.js' | |
| }; | |
| Y.use('yui2-utilities', function (Y) { |
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 options = '', i, len; | |
| for (var i = 0, len = ddActionsMenuData.length; i < len; ++i) { | |
| options += '<option value="' + ddActionsMenuData[i].value + '">' + | |
| ddActionsMenuData[i].text + '</option>'; | |
| } | |
| var div = document.createElement('div'); | |
| div.innerHTML = '<select name="foo">' + options + '</select>'; |
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
| YUI().use('node-base', function(Y) { | |
| Y.on('click', handler(1), document); | |
| Y.on('click', handler(2), document); | |
| Y.on('click', handler(3), document); | |
| if (document.addEventListener) { | |
| document.addEventListener('click', dhandler(1), false); | |
| document.addEventListener('click', dhandler(2), false); | |
| document.addEventListener('click', dhandler(3), false); |
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
| myAutoComplete._isIgnoreKey = (function (original) { | |
| return function (keyCode) { | |
| return (keyCode > 47 && keyCode < 58) || original.apply(this, arguments); | |
| } | |
| })(myAutoComplete._isIgnoreKey); | |
| // OR |
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
| YAHOO.util.Number.format = function (n, cfg) { | |
| if (!isFinite(+n)) { | |
| return ''; | |
| } | |
| n = !isFinite(+n) ? 0 : +n; | |
| cfg = YAHOO.lang.merge(YAHOO.util.Number.format.defaults, (cfg || {})); | |
| var neg = n < 0, | |
| absN = Math.abs(n), |
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
| /** | |
| * My fancy gallery module. This requires another non-YUI 3 script be included as | |
| * well. This can be accomplished by adding a 'modules' entry for it in the config | |
| * object passed to the YUI constructor. Do like'a dis: | |
| * YUI({ | |
| * modules: { | |
| * 'other-stuff': { // name it whatever you like, it's not a true module | |
| * fullpath: 'http://path.to/other/stuff.js' | |
| * }, | |
| * 'gallery-module': { // tack on the requirement here |
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
| <script> | |
| /* Alternate snippet to asynchronously embed the Google Analytics script. | |
| * This requires the following things of the pages that will contain it: | |
| * 1. the page only include one GA tracker (common case), | |
| * 2. the page is not be behind SSL (http, not https), | |
| */ | |
| var _gaq = [['_setAccount', 'UA-XXXXXX-X'],['_trackPageview']]; | |
| (function(d) { | |
| var script = d.createElement('script'), |