Sha256: aefcbf9724e4a16f1f9c972e408236a6f19eebd52101590cac98d3f621f221d8
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
"use strict"; /** * Turns the specified string into an object (and sub objects) that can be used * to namespace classes and other data. * * Basic usage: * * console.log(Foo); // => ReferenceError * * namespace('Foo.Bar.Baz'); * * console.log(Foo); // => {Bar: {Baz: {}}} * * If segments of the namespace already exist they will remain untouched, this * function merely creates non existing segments. * * @example * namespace('Zen.Editor'); * * Zen.Editor.Markdown = new Class(...); * * @since 2011-12-22 * @param {string} name The namespace to create. */ function namespace(name) { var stack = window; name.split('.').each(function(segment) { stack[segment] = stack[segment] || {}; stack = stack[segment]; }); } /** * Returns the translation for the given string. This function allows you to * retrieve languages in the same way as you would do in the Ruby code for your * application: * * var string = lang('foo.bar'); * * This code is the same as the following: * * var string = Zen.translations['foo.bar']; * * @since 2011-12-22 * @param {string} key The language key to retrieve. * @return {string} */ function lang(key) { if ( !Zen.translations[key] ) { throw new Error('The language key "' + key + '" does not exist'); } return Zen.translations[key]; }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
zen-0.4.3 | lib/zen/public/admin/zen/js/lib/base.js |