|
7 | 7 | factory(jQuery);
|
8 | 8 | }
|
9 | 9 | }(function($) {
|
| 10 | +var DEFAULT_CALLBACKS, KEY_CODE; |
| 11 | + |
| 12 | +KEY_CODE = { |
| 13 | + DOWN: 40, |
| 14 | + UP: 38, |
| 15 | + ESC: 27, |
| 16 | + TAB: 9, |
| 17 | + ENTER: 13, |
| 18 | + CTRL: 17, |
| 19 | + A: 65, |
| 20 | + P: 80, |
| 21 | + N: 78, |
| 22 | + LEFT: 37, |
| 23 | + UP: 38, |
| 24 | + RIGHT: 39, |
| 25 | + DOWN: 40, |
| 26 | + BACKSPACE: 8, |
| 27 | + SPACE: 32 |
| 28 | +}; |
| 29 | + |
| 30 | +DEFAULT_CALLBACKS = { |
| 31 | + beforeSave: function(data) { |
| 32 | + return Controller.arrayToDefaultHash(data); |
| 33 | + }, |
| 34 | + matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) { |
| 35 | + var _a, _y, match, regexp, space; |
| 36 | + flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); |
| 37 | + if (should_startWithSpace) { |
| 38 | + flag = '(?:^|\\s)' + flag; |
| 39 | + } |
| 40 | + _a = decodeURI("%C3%80"); |
| 41 | + _y = decodeURI("%C3%BF"); |
| 42 | + space = acceptSpaceBar ? "\ " : ""; |
| 43 | + regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_" + space + "\'\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi'); |
| 44 | + match = regexp.exec(subtext); |
| 45 | + if (match) { |
| 46 | + return match[2] || match[1]; |
| 47 | + } else { |
| 48 | + return null; |
| 49 | + } |
| 50 | + }, |
| 51 | + filter: function(query, data, searchKey) { |
| 52 | + var _results, i, item, len; |
| 53 | + _results = []; |
| 54 | + for (i = 0, len = data.length; i < len; i++) { |
| 55 | + item = data[i]; |
| 56 | + if (~new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase())) { |
| 57 | + _results.push(item); |
| 58 | + } |
| 59 | + } |
| 60 | + return _results; |
| 61 | + }, |
| 62 | + remoteFilter: null, |
| 63 | + sorter: function(query, items, searchKey) { |
| 64 | + var _results, i, item, len; |
| 65 | + if (!query) { |
| 66 | + return items; |
| 67 | + } |
| 68 | + _results = []; |
| 69 | + for (i = 0, len = items.length; i < len; i++) { |
| 70 | + item = items[i]; |
| 71 | + item.atwho_order = new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase()); |
| 72 | + if (item.atwho_order > -1) { |
| 73 | + _results.push(item); |
| 74 | + } |
| 75 | + } |
| 76 | + return _results.sort(function(a, b) { |
| 77 | + return a.atwho_order - b.atwho_order; |
| 78 | + }); |
| 79 | + }, |
| 80 | + tplEval: function(tpl, map) { |
| 81 | + var error, error1, template; |
| 82 | + template = tpl; |
| 83 | + try { |
| 84 | + if (typeof tpl !== 'string') { |
| 85 | + template = tpl(map); |
| 86 | + } |
| 87 | + return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) { |
| 88 | + return map[key]; |
| 89 | + }); |
| 90 | + } catch (error1) { |
| 91 | + error = error1; |
| 92 | + return ""; |
| 93 | + } |
| 94 | + }, |
| 95 | + highlighter: function(li, query) { |
| 96 | + var regexp; |
| 97 | + if (!query) { |
| 98 | + return li; |
| 99 | + } |
| 100 | + regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig'); |
| 101 | + return li.replace(regexp, function(str, $1, $2, $3) { |
| 102 | + return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <'; |
| 103 | + }); |
| 104 | + }, |
| 105 | + beforeInsert: function(value, $li) { |
| 106 | + return value; |
| 107 | + }, |
| 108 | + beforeReposition: function(offset) { |
| 109 | + return offset; |
| 110 | + }, |
| 111 | + afterMatchFailed: function(at, el) {} |
| 112 | +}; |
| 113 | + |
10 | 114 | var App;
|
11 | 115 |
|
12 | 116 | App = (function() {
|
@@ -984,110 +1088,6 @@ View = (function() {
|
984 | 1088 |
|
985 | 1089 | })();
|
986 | 1090 |
|
987 |
| -var DEFAULT_CALLBACKS, KEY_CODE; |
988 |
| - |
989 |
| -KEY_CODE = { |
990 |
| - DOWN: 40, |
991 |
| - UP: 38, |
992 |
| - ESC: 27, |
993 |
| - TAB: 9, |
994 |
| - ENTER: 13, |
995 |
| - CTRL: 17, |
996 |
| - A: 65, |
997 |
| - P: 80, |
998 |
| - N: 78, |
999 |
| - LEFT: 37, |
1000 |
| - UP: 38, |
1001 |
| - RIGHT: 39, |
1002 |
| - DOWN: 40, |
1003 |
| - BACKSPACE: 8, |
1004 |
| - SPACE: 32 |
1005 |
| -}; |
1006 |
| - |
1007 |
| -DEFAULT_CALLBACKS = { |
1008 |
| - beforeSave: function(data) { |
1009 |
| - return Controller.arrayToDefaultHash(data); |
1010 |
| - }, |
1011 |
| - matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) { |
1012 |
| - var _a, _y, match, regexp, space; |
1013 |
| - flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); |
1014 |
| - if (should_startWithSpace) { |
1015 |
| - flag = '(?:^|\\s)' + flag; |
1016 |
| - } |
1017 |
| - _a = decodeURI("%C3%80"); |
1018 |
| - _y = decodeURI("%C3%BF"); |
1019 |
| - space = acceptSpaceBar ? "\ " : ""; |
1020 |
| - regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_" + space + "\'\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi'); |
1021 |
| - match = regexp.exec(subtext); |
1022 |
| - if (match) { |
1023 |
| - return match[2] || match[1]; |
1024 |
| - } else { |
1025 |
| - return null; |
1026 |
| - } |
1027 |
| - }, |
1028 |
| - filter: function(query, data, searchKey) { |
1029 |
| - var _results, i, item, len; |
1030 |
| - _results = []; |
1031 |
| - for (i = 0, len = data.length; i < len; i++) { |
1032 |
| - item = data[i]; |
1033 |
| - if (~new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase())) { |
1034 |
| - _results.push(item); |
1035 |
| - } |
1036 |
| - } |
1037 |
| - return _results; |
1038 |
| - }, |
1039 |
| - remoteFilter: null, |
1040 |
| - sorter: function(query, items, searchKey) { |
1041 |
| - var _results, i, item, len; |
1042 |
| - if (!query) { |
1043 |
| - return items; |
1044 |
| - } |
1045 |
| - _results = []; |
1046 |
| - for (i = 0, len = items.length; i < len; i++) { |
1047 |
| - item = items[i]; |
1048 |
| - item.atwho_order = new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase()); |
1049 |
| - if (item.atwho_order > -1) { |
1050 |
| - _results.push(item); |
1051 |
| - } |
1052 |
| - } |
1053 |
| - return _results.sort(function(a, b) { |
1054 |
| - return a.atwho_order - b.atwho_order; |
1055 |
| - }); |
1056 |
| - }, |
1057 |
| - tplEval: function(tpl, map) { |
1058 |
| - var error, error1, template; |
1059 |
| - template = tpl; |
1060 |
| - try { |
1061 |
| - if (typeof tpl !== 'string') { |
1062 |
| - template = tpl(map); |
1063 |
| - } |
1064 |
| - return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) { |
1065 |
| - return map[key]; |
1066 |
| - }); |
1067 |
| - } catch (error1) { |
1068 |
| - error = error1; |
1069 |
| - return ""; |
1070 |
| - } |
1071 |
| - }, |
1072 |
| - highlighter: function(li, query) { |
1073 |
| - var regexp; |
1074 |
| - if (!query) { |
1075 |
| - return li; |
1076 |
| - } |
1077 |
| - regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig'); |
1078 |
| - return li.replace(regexp, function(str, $1, $2, $3) { |
1079 |
| - return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <'; |
1080 |
| - }); |
1081 |
| - }, |
1082 |
| - beforeInsert: function(value, $li) { |
1083 |
| - return value; |
1084 |
| - }, |
1085 |
| - beforeReposition: function(offset) { |
1086 |
| - return offset; |
1087 |
| - }, |
1088 |
| - afterMatchFailed: function(at, el) {} |
1089 |
| -}; |
1090 |
| - |
1091 | 1091 | var Api;
|
1092 | 1092 |
|
1093 | 1093 | Api = {
|
|
0 commit comments