K2LL33D SHELL

 Apache/2.4.7 (Ubuntu)
 Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64
 uid=33(www-data) gid=33(www-data) groups=33(www-data)
 safemode : OFF
 MySQL: ON | Perl: ON | cURL: OFF | WGet: ON
  >  / var / www / html / sman1baleendah_sch_id / member / js /
server ip : 172.67.156.115

your ip : 172.70.127.59

H O M E


Filename/var/www/html/sman1baleendah_sch_id/member/js/GrowingInput.js
Size2.12 kb
Permissionrwxr-xr-x
Ownerroot : root
Create time11-Jun-2025 21:32
Last modified11-Jun-2025 21:32
Last accessed05-Jul-2025 15:27
Actionsedit | rename | delete | download (gzip)
Viewtext | code | image
/*
Script: GrowingInput.js
Alters the size of an input depending on its content

License:
MIT-style license.

Authors:
Guillermo Rauch
*/

(function(){

GrowingInput = function(element, options){

var value, lastValue, calc;

options = $.extend({
min: 0,
max: null,
startWidth: 15,
correction: 15
}, options);

element = $(element).data('growing', this);

var self = this;
var init = function(){
calc = $('<span></span>').css({
'float': 'left',
'display': 'inline-block',
'position': 'absolute',
'left': -1000
}).insertAfter(element);
$.each(['font-size', 'font-family', 'padding-left', 'padding-top', 'padding-bottom',
'padding-right', 'border-left', 'border-right', 'border-top', 'border-bottom',
'word-spacing', 'letter-spacing', 'text-indent', 'text-transform'], function(i, p){
calc.css(p, element.css(p));
});
element.blur(resize).keyup(resize).keydown(resize).keypress(resize);
resize();
};

var calculate = function(chars){
calc.html(chars);
var width = calc.width();
return (width ? width : options.startWidth) + options.correction;
};

var resize = function(){
lastValue = value;
value = element.val();
var retValue = value;
if(chk(options.min) && value.length < options.min){
if(chk(lastValue) && (lastValue.length <= options.min)) return;
retValue = str_pad(value, options.min, '-');
} else if(chk(options.max) && value.length > options.max){
if(chk(lastValue) && (lastValue.length >= options.max)) return;
retValue = value.substr(0, options.max);
}
element.width(calculate(retValue));
return self;
};

this.resize = resize;
init();
};

var chk = function(v){ return !!(v || v === 0); };
var str_repeat = function(str, times){ return new Array(times + 1).join(str); };
var str_pad = function(self, length, str, dir){
if (self.length >= length) return this;
str = str || ' ';
var pad = str_repeat(str, length - self.length).substr(0, length - self.length);
if (!dir || dir == 'right') return self + pad;
if (dir == 'left') return pad + self;
return pad.substr(0, (pad.length / 2).floor()) + self + pad.substr(0, (pad.length / 2).ceil());
};

})();