Sha256: d7d074b0060004fd1442e965800da07eab5813d0e55647a12dc9cbef0f8ef49f

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

//http://stackoverflow.com/questions/6167805/using-rails-3-1-where-do-you-put-your-page-specific-javascript-code
POKE = {
    blank: function(o) {
        return typeof o === "undefined" || o === null;
    },
    present: function(o) {
        return !POKE.blank(o);
    },
    get_or_create: function(namespace, o) {
        if (POKE.blank(o))
            o = APP;
        if (POKE.blank(o[namespace]))
            o[namespace] = {};
        return o[namespace];
    },
    define: function(namespace, hash, o) {
        var o_namespace = POKE.get_or_create(namespace, o);
        $.extend(o_namespace, hash);
    },


    exec_all: function(controller, format, action) {
        POKE.exec("app", format);
        POKE.exec(controller, format);
        POKE.exec(controller, format, action);
    },
    exec: function(controller, format, action) {
        var ns = APP,
            action = (action === undefined) ? "init" : action;

        if (controller !== "" && ns[controller] &&
            format !== "" && ns[controller][format]) {
            var funct = ns[controller][format][action],
                params = ns[controller][format][action + "_params"];

            if ($.isFunction(funct))
                funct(params);
        }
    },
    init: function() {
        var $body = $('body');
        POKE.exec_all($body.data("controller"), "html", $body.data("action"));
    }
};

if (POKE.blank(window["APP"]))
    APP = {};
$(POKE.init);

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
poke_js-0.1.0 app/assets/javascripts/poke_js.js