mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
New filter implementation is working.
This commit is contained in:
parent
1dbd477ced
commit
55228d2ec3
2 changed files with 27 additions and 4 deletions
|
@ -5,7 +5,7 @@ window.filtersExecuted = window.filtersExecuted || {before : [], after : []};
|
|||
(function(){ var filter = new Paloma.FilterScope('sample_namespace/baz');
|
||||
|
||||
// Skip Filters From Namespace
|
||||
/*
|
||||
|
||||
filter.skip_before_filter('All - Skip This Before Filter');
|
||||
filter.skip_before_filter('Only - Skip This Before Filter');
|
||||
filter.skip_before_filter('Except - Skip This Before Filter');
|
||||
|
@ -17,7 +17,7 @@ window.filtersExecuted = window.filtersExecuted || {before : [], after : []};
|
|||
filter.skip_around_filter('All - Skip This Around Filter');
|
||||
filter.skip_around_filter('Only - Skip This Around Filter');
|
||||
filter.skip_around_filter('Except - Skip This Around Filter');
|
||||
*/
|
||||
|
||||
|
||||
// Before
|
||||
filter.as('Standard Before').
|
||||
|
|
27
vendor/assets/javascripts/paloma_core.js
vendored
27
vendor/assets/javascripts/paloma_core.js
vendored
|
@ -43,7 +43,7 @@ Paloma.execute = function(controller, action, params){
|
|||
|
||||
|
||||
Paloma._filters = {'before' : {}, 'after' : {}, 'around' : {}};
|
||||
|
||||
Paloma._scopes = {};
|
||||
|
||||
Paloma._getOrderedFilters = function(before_or_after, namespace, controller, action){
|
||||
var namespaceFilters = Paloma._filters[before_or_after][namespace],
|
||||
|
@ -82,12 +82,35 @@ Paloma._performFilters = function(filters, params){
|
|||
|
||||
|
||||
// FilterScope Class
|
||||
Paloma.FilterScope = function(name){ this.name = name; };
|
||||
Paloma.FilterScope = function(name){
|
||||
this.name = name;
|
||||
this.skipFilters = [];
|
||||
this.skipFilterType = undefined;
|
||||
this.skipType = 'all';
|
||||
|
||||
Paloma._scopes[name] = this;
|
||||
};
|
||||
|
||||
Paloma.FilterScope.prototype.as = function(filterName){
|
||||
return (new Paloma.Filter(this.name, filterName));
|
||||
};
|
||||
|
||||
// skip_*_filter methods
|
||||
(function(){
|
||||
var types = ['before', 'after', 'around'];
|
||||
for (var i = 0, n = types.length; i < n; i++){
|
||||
var type = types[i];
|
||||
Paloma.FilterScope.prototype['skip_' + type + '_filter'] = function(){
|
||||
this.skipFilterType = type;
|
||||
this.skipFilters = Array.prototype.slice.call(arguments);
|
||||
return this;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
||||
Paloma.FilterScope.prototype.only = function(){ this.skipType = 'only'; };
|
||||
Paloma.FilterScope.prototype.except = function(){ this.skipType = 'except'; };
|
||||
|
||||
|
||||
|
||||
// Filter class
|
||||
|
|
Loading…
Reference in a new issue