Sha256: fd2a8588f640cb3a8ee445fb5327c84fcc7fcc8f0f9ffef064668786fd7f95cb

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

(function($) {
  $.extend(Coolerator, {
    Filters : {
      global : [],
      scoped : {},

      get : function get(scope) {
        return $.merge($.makeArray(this.global), $.makeArray(this.scoped[scope]));
      }
    },

    Filter : function Filter() {
      var scope  = ['*'];
      var filter = this;

      if(arguments.length) {
        var first = arguments[0];

        if('object' === typeof first) {
          scope  = $.isArray(first.scope) ? first.scope : [first.scope || '*'];

          filter = {
            label  : first.label,
            before : (first.before || function no_op() {}),
            after  : (first.after  || function no_op() {})
          };
        }
        else {
          scope = arguments;
        }
      }

      $.each(scope, function(i, selector) {
        if(selector === '*') {
          Coolerator.Filters.global.push(filter);
        }
        else {
          Coolerator.Filters.scoped[selector || '*'] = $.merge(Coolerator.Filters.scoped[selector || '*'] || [], [filter]);
        }
      });
    }
  });

  $.extend(Coolerator.Filter.prototype, {
    before : function before(fn) {
      if('function' == typeof fn) {
        this.before = fn;
      }
    },

    after : function after(fn) {
      if('function' == typeof fn) {
        this.after = fn;
      }
    }
  });
})(jQuery);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
coolerator.vision-0.2.4 public/javascripts/vendor/coolerator/coolerator.filter.js
coolerator.vision-0.2.3 public/javascripts/vendor/coolerator/coolerator.filter.js