Fixes filter problems.
This commit is contained in:
parent
48522d8e68
commit
6d3438cb1c
3 changed files with 19 additions and 24 deletions
|
@ -71,6 +71,7 @@ It profits from these great projects:
|
|||
* updates jQuery to 1.10.2
|
||||
* adds `uk` translation by Viktor Matveenko
|
||||
|
||||
|
||||
### v0.22.1 - *2012-10-16*
|
||||
|
||||
* bug fix concerning API requests in PHP mode
|
||||
|
|
|
@ -3,17 +3,16 @@
|
|||
.topbar-right;
|
||||
|
||||
input {
|
||||
display: none;
|
||||
border: none;
|
||||
font-family: @font-family;
|
||||
color: @col;
|
||||
background-color: rgba(0,0,0,0);
|
||||
width: 100px;
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
&.current {
|
||||
input {
|
||||
display: inline;
|
||||
width: 150px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], function (_, $, allsettings, resource) {
|
||||
modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource', 'core/event'], function (_, $, allsettings, resource, event) {
|
||||
|
||||
var settings = _.extend({
|
||||
enabled: false
|
||||
|
@ -58,20 +58,24 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
|
|||
|
||||
sequence = $.map($.trim(sequence).split(/\s+/), function (part) {
|
||||
|
||||
return _.map(part.split(''), function (char) {
|
||||
return _.map(part.split(''), function (character) {
|
||||
|
||||
return escapeRegExp(char);
|
||||
return escapeRegExp(character);
|
||||
}).join('.*?');
|
||||
}).join('|');
|
||||
|
||||
return new RegExp(sequence, 'i');
|
||||
},
|
||||
|
||||
update = function () {
|
||||
update = function (focus) {
|
||||
|
||||
var val = $input.val();
|
||||
|
||||
if (val) {
|
||||
if (focus) {
|
||||
$input.focus();
|
||||
}
|
||||
|
||||
if (val || focus) {
|
||||
filter(parseFilterSequence(val));
|
||||
$filter.addClass('current');
|
||||
} else {
|
||||
|
@ -79,6 +83,8 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
|
|||
$filter.removeClass('current');
|
||||
}
|
||||
},
|
||||
updt = function () { update(true); },
|
||||
updf = function () { update(false); },
|
||||
|
||||
init = function () {
|
||||
|
||||
|
@ -90,30 +96,19 @@ modulejs.define('ext/filter', ['_', '$', 'core/settings', 'core/resource'], func
|
|||
$input = $filter.find('input');
|
||||
$noMatch = $(noMatchTemplate).appendTo('#view');
|
||||
|
||||
$filter
|
||||
.on('click', function () {
|
||||
|
||||
$input.focus();
|
||||
});
|
||||
|
||||
$input
|
||||
.on('focus', function () {
|
||||
|
||||
$filter.addClass('current');
|
||||
})
|
||||
.on('blur keyup', update);
|
||||
$filter.on('click', updt);
|
||||
$input.on('focus blur keyup', updf);
|
||||
|
||||
$(document)
|
||||
.on('keydown', function (event) {
|
||||
|
||||
if (event.which === 27) {
|
||||
$input.attr('value','').blur();
|
||||
$input.val('').blur();
|
||||
}
|
||||
})
|
||||
.on('keypress', function (event) {
|
||||
.on('keypress', updt);
|
||||
|
||||
$input.focus();
|
||||
});
|
||||
event.sub('location.changed', updf)
|
||||
};
|
||||
|
||||
init();
|
||||
|
|
Loading…
Add table
Reference in a new issue