Sha256: ee08d8b39ee84d00add00741ec3285bbbf121c776dbad01672a4d0d6d1486807

Contents?: true

Size: 1.65 KB

Versions: 3

Compression:

Stored size: 1.65 KB

Contents

/**
 * This file contains various extensions and core functions that are used by the
 * Javascript API provided by Zen.
 *
 * @author Yorick Peterse
 * @since  0.2.6
 */
Zen = {};

/**
 * Object containing all the assets that were loaded from a class using the Depends
 * mutator.
 *
 * @author Yorick Peterse
 * @since  0.2.6
 */
Zen.assets = {
    javascript: [],
    stylesheet: []
}

/**
 * Extends the Class class so that dependencies on Javascript and CSS files can be
 * inserted into a class using the assets system that comes with Mootools.
 *
 * Note that you shouldn't specify the file extension, this will be added automatically.
 *
 * @example
 *  var my_class = new Class(
 *  {
 *      Depends:
 *      {
 *          stylesheet: ['zen/editor']
 *      }
 *  });
 *
 * @author Yorick Peterse
 * @since  0.2.6
 * @param  [Object] deps Object containing the stylesheets and Javascript files required
 * by a class.
 */
Class.Mutators.Depends = function(deps)
{
    // Load all Javascript files
    if ( deps.javascript )
    {
        deps.javascript.each(function(file)
        {
            file = '/admin/js/' + file + '.js';

            if ( !Zen.assets.javascript.contains(file) )
            {
                Asset.javascript(file);
                Zen.assets.javascript.push(file);
            }
        });
    }

    // Load all stylesheets
    if ( deps.stylesheet )
    {
        deps.stylesheet.each(function(file)
        {
            file = '/admin/css/' + file + '.css';

            if ( !Zen.assets.stylesheet.contains(file) )
            {
                Asset.css(file);
                Zen.assets.stylesheet.push(file);
            }
        }); 
    }
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zen-0.2.7 lib/zen/public/admin/js/zen/core.js
zen-0.2.6.1 lib/zen/public/admin/js/zen/core.js
zen-0.2.6 lib/zen/public/admin/js/zen/core.js