define(
'filters/booleanSearchFilter',
[
	'underscore',
	'bookmarksApp'
], 
function(_, bookmarksApp) { 'use strict';

bookmarksApp.filter('booleanSearchFilter', function($filter) {
		var standardFilter = $filter('filter');
		var orderBy = $filter('orderBy');

		this.andExpression = 'and';
		var orExpression = 'or';

		// Compress some whitespaces to one. Defaults to whitespace characters.
		var clean = function(input, characters){
			if (!angular.isString(input)) {
                return input;
            }

            if (!characters) {
                characters = '\\s';
            }

            return String(input).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
        };

        // Trims defined characters from begining and ending of the string. Defaults to whitespace characters.
        var trim = function(input, characters){
			if (!angular.isString(input)) {
                return input;
            }

            if (!characters) {
                characters = '\\s';
            }

            return String(input)
                .replace(new RegExp('^' + characters + '+|' + characters + '+$', 'g'), '');
        };

        var isBlank = function(str){
	    	if (str == null) str = '';
	    	return (/^\s*$/).test(str);
	    };

        var words = function(str, delimiter) {
	    	if (isBlank(str)) return [];
	    	return trim(str, delimiter).split(delimiter || /\s+/);
	    };

	    var comperator = function(obj){
				return true;
			};

		return function(input, search, order) {
			var searchWords = [];

			if (search) {
				var cleanSearch = clean(search);
				searchWords = words(cleanSearch);
			}

			

			return orderBy(standardFilter(input, function(obj, searchWords){
				return true;
			}), order, order === 'date');
		};
  });
});













@@ -34,17 +34,20 @@
 ter',%0A%5B%0A
-%09
+    
 'undersc
@@ -263,13 +263,12 @@
 %0A%0A%09%09
-this.
+var 
 andE
@@ -1441,69 +1441,8 @@
 %7D;%0A%0A
-%09    var comperator = function(obj)%7B%0A%09%09%09%09return true;%0A%09%09%09%7D;%0A%0A
 %09%09re
@@ -1490,24 +1490,23 @@
 var 
-searchWords = %5B%5D
+expression = %7B%7D
 ;%0A%0A%09
@@ -1562,16 +1562,20 @@
 h);%0A%09%09%09%09
+var 
 searchWo
@@ -1601,111 +1601,154 @@
 arch
-);%0A%09%09%09%7D%0A%0A%09%09%09%0A%0A%09%09%09return orderBy(standardFilter(input, function(obj, searchWords)%7B%0A%09%09%09%09return true;%0A%09%09%09%7D
+, ':');%0A%0A%09%09%09%09%0A%09%09%09%7D%0A%0A      %09%09var comparator = function (obj) %7B%0A        %09%09return true;%0A      %09%09%7D%0A%0A%09%09%09return orderBy(standardFilter(input, comparator
 ), o
@@ -1790,17 +1790,4 @@
 %0A%7D);
-%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A%0A

add underscore to filter