Improve JS behavior when editing slug (fixes #132)

pull/180/head
Serafeim Papastefanos 2014-04-03 18:51:54 +03:00
rodzic a1c9224b7a
commit a854c03f44
1 zmienionych plików z 14 dodań i 2 usunięć

Wyświetl plik

@ -261,8 +261,20 @@ function initSlugAutoPopulate(){
}
function initSlugCleaning(){
$('#id_slug').on('keyup blur', function(){
$(this).val(cleanForSlug($(this).val()));
$('#id_slug').on({
'blur': function(){
$(this).val(cleanForSlug($(this).val()));
},
'keyup': function(event){
var keyCode = ('which' in event) ? event.which : event.keyCode;
if (
(keyCode != 32) && // not spacebar
(keyCode != 8) && // not backspace
(keyCode != 46) && // not delete
((keyCode < 40) ) // non-character
) return ;
$(this).val(cleanForSlug($(this).val()));
}
});
}