Add minifier script for hinter.js, fix autocomplete=off, fix onChange showing
parent
c44c49cb39
commit
5d7554af89
11
hinter.js
11
hinter.js
|
@ -92,7 +92,6 @@ var SimpleAutocomplete = function(input, dataLoader, params)
|
|||
this.delay = 300;
|
||||
|
||||
// Variables
|
||||
this.origAutocomplete = input.autocomplete;
|
||||
this.more = 0;
|
||||
this.timer = null;
|
||||
this.closure = [];
|
||||
|
@ -111,6 +110,7 @@ var SimpleAutocomplete = function(input, dataLoader, params)
|
|||
SimpleAutocomplete.prototype.init = function()
|
||||
{
|
||||
var e = this.input;
|
||||
e.autocomplete = 'off';
|
||||
var l = SimpleAutocomplete.SimpleAutocompletes;
|
||||
this.id = this.input.id + l.length;
|
||||
l.push(this);
|
||||
|
@ -348,10 +348,7 @@ SimpleAutocomplete.prototype.toggleValue = function(index)
|
|||
SimpleAutocomplete.prototype.hide = function()
|
||||
{
|
||||
if (!this.skipHideCounter)
|
||||
{
|
||||
this.hintLayer.style.display = 'none';
|
||||
this.input.autocomplete = this.origAutocomplete;
|
||||
}
|
||||
else
|
||||
this.skipHideCounter = 0;
|
||||
};
|
||||
|
@ -365,7 +362,6 @@ SimpleAutocomplete.prototype.show = function()
|
|||
this.hintLayer.style.top = (p.top+this.input.offsetHeight) + 'px';
|
||||
this.hintLayer.style.left = p.left + 'px';
|
||||
this.hintLayer.style.display = '';
|
||||
this.input.autocomplete = 'off';
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -379,9 +375,8 @@ SimpleAutocomplete.prototype.disable = function()
|
|||
// Enable hinter
|
||||
SimpleAutocomplete.prototype.enable = function()
|
||||
{
|
||||
var show = this.disabled;
|
||||
this.disabled = false;
|
||||
if (show)
|
||||
if (this.hasFocus)
|
||||
this.show();
|
||||
}
|
||||
|
||||
|
@ -524,7 +519,6 @@ SimpleAutocomplete.prototype.onKeyPress = function(ev)
|
|||
SimpleAutocomplete.prototype.onInputFocus = function()
|
||||
{
|
||||
this.show();
|
||||
this.input.autocomplete = 'off';
|
||||
this.hasFocus = true;
|
||||
return true;
|
||||
};
|
||||
|
@ -533,7 +527,6 @@ SimpleAutocomplete.prototype.onInputFocus = function()
|
|||
SimpleAutocomplete.prototype.onInputBlur = function()
|
||||
{
|
||||
this.hide();
|
||||
this.input.autocomplete = this.origAutocomplete;
|
||||
this.hasFocus = false;
|
||||
return true;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/perl
|
||||
# Mangle names in SimpleAutocomplete code for better compression
|
||||
|
||||
use strict;
|
||||
|
||||
my $output = 'hinter.min.js';
|
||||
my %whitelist = map { $_ => 1 } qw(input remove replaceItems hide onChange);
|
||||
my %var = ();
|
||||
my @names = 'a'..'ba';
|
||||
|
||||
local $/ = undef;
|
||||
open FD, "hinter.js";
|
||||
open OFD, "| yui-compressor --type js -o $output";
|
||||
while(<FD>)
|
||||
{
|
||||
s/(this|self|SimpleAutocomplete(?:\.prototype)?)\.([a-zA-Z0-9_]+)/$1 . '.' . ($whitelist{$2} ? $2 : ($var{$2} ||= shift @names))/egs;
|
||||
print OFD $_;
|
||||
}
|
||||
close FD;
|
||||
close OFD;
|
||||
|
||||
open FD, "+<", $output;
|
||||
$_ = <FD>;
|
||||
seek FD, 0, 0;
|
||||
print FD "// (c) Vitaliy Filippov 2011-2013
|
||||
// \@license MPL 2.0 http://www.mozilla.org/MPL/2.0/
|
||||
// http://yourcmc.ru/wiki/SimpleAutocomplete
|
||||
$_";
|
||||
close FD;
|
||||
|
||||
print "Compressed SimpleAutocomplete written to $output\n";
|
Loading…
Reference in New Issue