From eb07150f22c453f66524b8124b0c9ffd4bb119b7 Mon Sep 17 00:00:00 2001 From: patdenice Date: Sat, 4 Oct 2008 13:54:54 +0000 Subject: - 883: category status wasn't saved. - 870, 877, 878: growfield plugins send wrong value when empty textarea. Now use another plugin for autogrow. git-svn-id: http://piwigo.org/svn/trunk@2653 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/cat_modify.php | 2 +- admin/template/goto/include/autosize.inc.tpl | 8 +- .../lib/plugins/jquery.autogrow-textarea.js | 47 +++ template-common/lib/plugins/jquery.growfield.js | 330 --------------------- .../lib/plugins/jquery.growfield.packed.js | 1 - 5 files changed, 51 insertions(+), 337 deletions(-) create mode 100644 template-common/lib/plugins/jquery.autogrow-textarea.js delete mode 100644 template-common/lib/plugins/jquery.growfield.js delete mode 100644 template-common/lib/plugins/jquery.growfield.packed.js diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 74f59f0a8..4a385217d 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -100,7 +100,7 @@ UPDATE '.CATEGORIES_TABLE.' SET image_order='.(isset($image_order) ? 'NULL':"'$i { set_cat_visible(array($_GET['cat_id']), $_POST['visible']); } - if ($cat_info['status'] != get_boolean( $_POST['status'] ) ) + if ($cat_info['status'] != $_POST['status'] ) { set_cat_status(array($_GET['cat_id']), $_POST['status']); } diff --git a/admin/template/goto/include/autosize.inc.tpl b/admin/template/goto/include/autosize.inc.tpl index 79152302c..9b06727ff 100644 --- a/admin/template/goto/include/autosize.inc.tpl +++ b/admin/template/goto/include/autosize.inc.tpl @@ -1,16 +1,14 @@ {* $Id$ *} {known_script id="jquery" src=$ROOT_URL|@cat:"template-common/lib/jquery.packed.js"} -{known_script id="jquery.ui" src=$ROOT_URL|@cat:"template-common/lib/ui/ui.core.packed.js"} -{known_script id="jquery.growfield" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.growfield.packed.js"} +{known_script id="jquery.autogrow" src=$ROOT_URL|@cat:"template-common/lib/plugins/jquery.autogrow-textarea.js"} {* Auto size and auto grow textarea *} {literal} {/literal} diff --git a/template-common/lib/plugins/jquery.autogrow-textarea.js b/template-common/lib/plugins/jquery.autogrow-textarea.js new file mode 100644 index 000000000..2e85b98af --- /dev/null +++ b/template-common/lib/plugins/jquery.autogrow-textarea.js @@ -0,0 +1,47 @@ +(function($) { + + /* + * Auto-growing textareas; technique ripped from Facebook + */ + $.fn.autogrow = function(options) { + + this.filter('textarea').each(function() { + + var $this = $(this), + minHeight = $this.height(), + lineHeight = $this.css('lineHeight'); + + var shadow = $('
').css({ + position: 'absolute', + top: -10000, + left: -10000, + width: $(this).width(), + fontSize: $this.css('fontSize'), + fontFamily: $this.css('fontFamily'), + lineHeight: $this.css('lineHeight'), + resize: 'none' + }).appendTo(document.body); + + var update = function() { + + var val = this.value.replace(//g, '>') + .replace(/&/g, '&') + .replace(/\n/g, '
'); + + shadow.html(val); + $(this).css('height', Math.max(shadow.height() + 20, minHeight)); + + } + + $(this).change(update).keyup(update).keydown(update); + + update.apply(this); + + }); + + return this; + + } + +})(jQuery); \ No newline at end of file diff --git a/template-common/lib/plugins/jquery.growfield.js b/template-common/lib/plugins/jquery.growfield.js deleted file mode 100644 index 7c8d35468..000000000 --- a/template-common/lib/plugins/jquery.growfield.js +++ /dev/null @@ -1,330 +0,0 @@ -/** jQuery textarea autogrow plugin - * jQuery.1.2.6 required - * - * optional parameters: // $(elem).growfield( options ) - * * * * * * * * * * * * * * * * * * * - * auto - bool // default = true // if false, ctrl + up/down are enabled - * animate - bool // default = true - * before(jEvent), after(jEvent) - callbacks // 'this' will be the dom object - * min - integer - height in pixels // default = min-height ? css.min-height || initial height - * max - integer - height in pixels // maximum size // default = css.max-height || none - * restore - bool - restore original size on blur (and back to growed on focus) // default = false - * speed - integer - animation speed. not a jquery parameter // default = 300 (ms) - * offset - integer - bottom offset // default is calculated for each textarea separately // i don't recommend to touch it :) - * - * additional functions (public interface): - * * * * * * * * * * * * * * * * * * * - * $(..).increase( [step] ), decrease( [step] ), growTo( height ), growToggleAuto( bool ), growToggleRestore( bool ), - * growSetMin( integer ), growSetMax( integer ) - * - * notes - * * * * * * * * * * * * * * * * * * * - * parameters may be set in html attributes // tag attributes have priority - * - * - * increase and decrease functions are working only in auto mode - * - * opera: - * in opera, if you don't have border style for textarea, plugin will set it (opera hides borders in overflow:hidden mode). - * in auto mode it won't work at all. More than that, opera returns border:2px solid #00000 even if you don't set it. :( - * - * known problems: - * after restore (onfocus) with animation textarea sometimes looses cursor. :( // ff2, ie7xp - * when reached maximum height, opera will jitter on every keydown :( // opera < 9.5 - * - * ctrl + up/down: - * in opera and ie this shortcut doesn't work properly. But you may use ctrl + whatever + up/down. - * - * three things that make possible scrollHeight update in opera < 9.5: - * (actually, we don't need scrollHeight in opera < 9.5, but we need something to be updated when typing) - * height: auto, toggle overflow to hidden and back to auto, and (!!!) padding >= 4px (am i crazy?!) - * we need textarea because only in this way we can calculate height with all inherited styles - * - * @author: johann kuindji (www.kuindji.com, www.stuffedguys.com, www.stuffedtracker.com) jk@kuindji.com - * @version 1.1 - * - * example: - * $('textarea').growfield(); - */ - -(function($){ -$.fn.growfield = function( options ) { - this.each( function() { - this._growField = true; - var txt = $(this); - if (this.tagName.toLowerCase() != 'textarea') return false; - if (!options) options = {}; - var th = this; - this.gf = { - auto: (typeof(options.auto) != 'undefined' ? options.auto : true), - animate: (typeof(options.animate) != 'undefined' ? options.animate : true), - hOffset: (typeof(options.offset) != 'undefined' ? options.offset : 0), - before: (options.before || null), after: (options.after || null), - min: (options.min || false), max: (options.max || false), restore: (options.restore || false), initialH:0, - busy: false, keysEnabled: false, dummy: null, queue: 0, speed: 300, ms: 15, timeout: false, opera9: false, impossible: false - }; - - this._growInit = function() { - if (this.gf.before) this._growCallbackBefore = this.gf.before; - if (this.gf.after) this._growCallbackAfter = this.gf.after; - this.gf.initialH = txt.get(0).offsetHeight; - if (typeof(txt.attr('autogrow')) != 'undefined') this.gf.auto = parseInt(txt.attr('autogrow')); - if (typeof(txt.attr('animate')) != 'undefined') this.gf.animate = parseInt(txt.attr('animate')); - if (typeof(txt.attr('min')) != 'undefined') this.gf.min = parseInt(txt.attr('min')); - if (typeof(txt.attr('max')) != 'undefined') this.gf.max = parseInt(txt.attr('max')); - if (typeof(txt.attr('restore')) != 'undefined') this.gf.restore = parseInt(txt.attr('restore')); - if (typeof(txt.attr('speed')) != 'undefined') this.gf.speed = parseInt(txt.attr('speed')); - if (!this.gf.min) this.gf.min = parseInt(txt.css('min-height')); - if (!this.gf.min) this.gf.min = this.gf.initialH; - if (!this.gf.max) this.gf.max = parseInt(txt.css('max-height')); - this.gf.opera9 = ($.browser.opera && $.browser.version < 9.5); - if (this.gf.restore) { this.gf.restore = false; this._toggleRestore( true );} - if (this.gf.auto) { - if (this.gf.initialH == 0) { txt.bind('keyup.growinit', this._afterShowInit); } - else { this.gf.auto = false; this._toggleAuto( true ); } - } - else this._toggleKeys( true ); - return true; - }; - - this._afterShowInit = function() { - this.gf.initialH = txt.get(0).offsetHeight; - if (!this.gf.initialH) return true; - if (!this.gf.min) this.gf.min = this.gf.initialH; - txt.unbind('.growinit'); - this.gf.auto = false; - this._toggleAuto( true ); - txt.focus(); - return true; - }; - - this._toggleKeys = function( on ) { - if ( on ) { - if (this.gf.keysEnabled) return false; - txt.bind( ($.browser.msie? 'keyup':'keydown')+'.autogrow', function( event ) { - if (!event.ctrlKey || $.inArray(event.keyCode,[38,40])==-1) return true; - txt[ event.keyCode==38 ? 'decrease':'increase' ]( false, event ); - if ($.browser.opera) txt.focus(); // !! - if ($.browser.msie || $.browser.opera) return false; - return true; - }); - this.gf.keysEnabled = true; - } else { - if (!this.gf.keysEnabled) return false; - txt.unbind(($.browser.msie? 'keyup':'keydown')+'.autogrow'); - this.gf.keysEnabled = false; - } - }; - - this._toggleAuto = function( on ) { - if ($.browser.opera || on ) { - txt.css('overflow', 'hidden'); - if ($.browser.opera && txt.attr('style') && txt.attr('style').indexOf('border') == -1) txt.css('border', '1px solid #ccc'); // see notes - } - if ( on ) { - if (this.gf.auto) return false; - this._toggleKeys( false ); - this._createDummy(); - if (this.gf.impossible) { this._growField = false; return false; } - txt.css('overflow', 'hidden'); - txt.bind('keyup.autogrow', function( event ) { - if (!txt.val()) this._changeSize(this.gf.min, event ); - else return this._changeSize(this._textHeight(), event ); - }); - if ( txt.val() ) txt.keyup(); - $(window).bind('resize.autogrow', function( event ) { th.gf.dummy.width( txt.width() );}); - this.gf.auto = true; - } else { - if (!this.gf.auto) return false; - this.gf.dummy.remove(); - this.gf.dummy = null; - txt.unbind('keyup.autogrow'); - $(window).unbind('resize.autogrow'); - txt.css('overflow', 'auto'); - this.gf.auto = false; - this._toggleKeys( true ); - } - return true; - }; - - this._toggleRestore = function( on ) { - if ( on ) { - if (this.gf.restore) return false; - this.gf.restore = true; - txt.bind('focus.autogrow', function( event, noChange ) { - if (!this.gf.auto || noChange || !txt.val()) return true; - else return this._changeSize(this._textHeight(), event ); - }); - txt.bind('blur.autogrow', function( event ) { return this.gf.auto ? this._changeSize( this.gf.min, event ) : true; }); - } else { - if (!this.gf.restore) return false; - this.gf.restore = false; - txt.unbind('focus.autogrow').unbind('blur.autogrow'); - txt.keyup(); - } - }; - - this._changeSize = function( to, event ) { - if (this.gf.busy) return true; - if (!event) event = {}; - this._growBefore( event ); - var ovr = txt.css('overflow'); - - if (this.gf.max > 0 && to >= this.gf.max) { // if we have reached the maximum height - to = this.gf.max; - if (ovr == 'hidden') { // if overflow is still hidden, we need to switch it to auto so that user could see the text - txt.css('overflow', 'auto'); - if (event.type=='keyup') txt.focus(); - if (event.type=='focus' && this.gf.animate && this.gf.auto) txt.trigger('focus', true); - } - } - else if (ovr=='auto' && this.gf.auto) { // if there is a space left (or no maximum is defined) - txt.css('overflow', 'hidden'); // we need to switch overflow back to hidden - if (event.type=='keyup') txt.focus(); // focus event is neccessary - } - if (this.gf.min > 0 && to <= this.gf.min) to = this.gf.min; // if we have minimum height - - if (to == txt.get(0).offsetHeight) {this.gf.busy=false; return true;} - - return this._animate( txt.get(0).offsetHeight, to, event, ovr); - }; - - this._animate = function( from, to, event, ovr ) { - if (!this.gf.animate || (ovr == 'auto' && this.gf.auto) || event.type == 'init' ) { - txt.height( to ); - return this._growAfter( event ); - } - this.gf.queue = Math.floor((this.gf.speed / this.gf.ms) * ( to < from ? -1 : 1)); - this._timeout( from, to ); - return true; - }; - - this._timeout = function( from, to ) { - if (th.gf.queue==0) return th._growAfter(); - th.gf.queue += (th.gf.queue > 0 ? -1 : 1); - if ( Math.abs(to-from)<3 ) { - txt.height( to ); - return th._growAfter(); - } - from = th.gf.queue == 0 ? to : from + Math.ceil( (to-from) /2); - txt.height( from ); - th.gf.timeout = window.setTimeout(function(){ th._timeout(from, to) }, th.gf.ms); - }; - - this._textHeight = function() { - var val = txt.val(); - if ($.browser.safari && val.substr(-2) == "\n\n") val = val.substring(0,val.length-2)+"\n11"; // empty row fix for safari - if ($.browser.safari) this.gf.dummy.val(''); // another fix for safari - this.gf.dummy.val(val); - if (this.gf.opera9) this.gf.dummy.css('overflow', 'hidden').css('overflow', 'auto'); - var d = this.gf.dummy.get(0); - if (this.gf.opera9) return d.clientHeight + this.gf.hOffset; - if ((d.scrollHeight + ($.browser.safari ? 1 : 0)) > d.clientHeight) { - return d.scrollHeight +( d.offsetHeight-d.clientHeight) + this.gf.hOffset + ($.browser.safari ? this.gf.hOffset : 0); - } - else { - if ( !txt.val()) return this.gf.min; - else return d.offsetHeight + this.gf.hOffset; - } - }; - - this._createDummy = function() { - if (this.gf.dummy) { this.gf.dummy.remove(); this.gf.dummy = false; } - var i = true; var tryPadding = false; - while (i) { - this.gf.dummy = txt.clone().css({position:'absolute', left:-9999, top:0, visibility: 'hidden', width: txt.get(0).offsetWidth}).attr('tabindex', -9999); - // in hidden mode opera < 9.5 doesn't update scrollHeight, but if we change overflow every time, it almost works - if (this.gf.opera9) { - this.gf.dummy.css({overflow:'auto', height:'auto'}); - var padding = txt.css('padding'); - if ((padding && padding< 4) || tryPadding) this.gf.dummy.css({padding: '4px'}); // !!!! only with padding textarea will update scrollHeight - } - this.gf.dummy.get(0)._growField = false; - txt.after(this.gf.dummy); - this.gf.dummy.val('').height(10); - this.gf.dummy.val("11"); - if (this.gf.opera9) this.gf.dummy.css('overflow', 'hidden').css('overflow', 'auto'); - var s1 = this.gf.dummy.get(0).scrollHeight; - this.gf.dummy.val("11\n11"); - if (this.gf.opera9) this.gf.dummy.css('overflow', 'hidden').css('overflow', 'auto'); - var s2 = this.gf.dummy.get(0).scrollHeight; - if (!this.gf.hOffset) { - this.gf.hOffset = s2-s1; - if ($.browser.opera && !this.gf.opera9) this.gf.hOffset += this.gf.dummy.get(0).offsetHeight - this.gf.dummy.height(); - } - if (this.gf.opera9 && this.gf.hOffset==0) { - if (tryPadding) i=false; - else { tryPadding=true; this.gf.dummy.remove(); continue; } - } - else i=false; - } - }; - - this._growBefore = function( event ) { this.gf.busy = true; this._growCallbackBefore( event ); }; - this._growAfter = function( event ) { - if (this.gf.timeout) { - window.clearTimeout(this.gf.timeout); - this.gf.timeout = false; - } - this.gf.busy = false; - this._growCallbackAfter( event ); - return true; - }; - this._growCallbackBefore = function() {}; - this._growCallbackAfter = function() {}; - $(function() { th._growInit(); }); - }); -}; - -$.fn.increase = function( step, event ) { this.each( function() { - if (!this._growField || this.gf.auto) return true; - this._changeSize( this.offsetHeight + (step ? parseInt(step) : this.gf.hOffset), event); -});}; -$.fn.decrease = function( step, event ) { this.each( function() { - if (!this._growField || this.gf.auto) return true; - this._changeSize( this.offsetHeight - (step ? parseInt(step) : this.gf.hOffset), event); -});}; -$.fn.growToggleAuto = function( bool ) { - if (bool && bool != true && bool != false && bool.toLowerCase() != 'on' && bool.toLowerCase() != 'off') delete(bool); - if (bool && typeof(bool)=='string') bool = bool.toLowerCase()=='on' ? true: false; - this.each( function() { - if (!this._growField) return true; - this._toggleAuto(bool); -});}; -$.fn.growToggleAnimation = function( bool ) { - if (bool && bool != true && bool != false && bool.toLowerCase() != 'on' && bool.toLowerCase() != 'off') delete(bool); - if (bool && typeof(bool)=='string') bool = bool.toLowerCase()=='on' ? true: false; - this.each( function() { - if (!this._growField) return true; - this.gf.animate = bool; -});}; -$.fn.growTo = function( h ) { this.each( function() { - if (!this._growField) return true; - this._changeSize(h); -});}; -$.fn.growSetMin = function( h ) { this.each( function() { - if (!this._growField) return true; - h = parseInt(h); - if (h < 10 && this.gf.initialH) h = this.gf.initialH; - if (h < 10) return true; - this.gf.min = parseInt(h); - if (this.offsetHeight < this.gf.min) $(this).growTo(this.gf.min); -});}; -$.fn.growSetMax = function( h ) { this.each( function() { - if (!this._growField) return true; - this.gf.max = parseInt(h); - if (this.offsetHeight > this.gf.max) $(this).growTo(this.gf.max); -});}; -$.fn.growToggleRestore = function( bool ) { - if (bool && bool != true && bool != false && bool.toLowerCase() != 'on' && bool.toLowerCase() != 'off') delete(bool); - if (bool && typeof(bool)=='string') bool = bool.toLowerCase()=='on' ? true: false; - this.each( function() { - if (!this._growField) return true; - this._toggleRestore( bool ); -});}; -$.fn.growRenewDummy = function() { this.each(function(){ - if (!this._growField) return true; - this._createDummy(); -});}; - -})(jQuery); \ No newline at end of file diff --git a/template-common/lib/plugins/jquery.growfield.packed.js b/template-common/lib/plugins/jquery.growfield.packed.js deleted file mode 100644 index 2d3691d59..000000000 --- a/template-common/lib/plugins/jquery.growfield.packed.js +++ /dev/null @@ -1 +0,0 @@ -(function($){$.fn.growfield=function(options){this.each(function(){this._growField=true;var txt=$(this);if(this.tagName.toLowerCase()!='textarea')return false;if(!options)options={};var th=this;this.gf={auto:(typeof(options.auto)!='undefined'?options.auto:true),animate:(typeof(options.animate)!='undefined'?options.animate:true),hOffset:(typeof(options.offset)!='undefined'?options.offset:0),before:(options.before||null),after:(options.after||null),min:(options.min||false),max:(options.max||false),restore:(options.restore||false),initialH:0,busy:false,keysEnabled:false,dummy:null,queue:0,speed:300,ms:15,timeout:false,opera9:false,impossible:false};this._growInit=function(){if(this.gf.before)this._growCallbackBefore=this.gf.before;if(this.gf.after)this._growCallbackAfter=this.gf.after;this.gf.initialH=txt.get(0).offsetHeight;if(typeof(txt.attr('autogrow'))!='undefined')this.gf.auto=parseInt(txt.attr('autogrow'));if(typeof(txt.attr('animate'))!='undefined')this.gf.animate=parseInt(txt.attr('animate'));if(typeof(txt.attr('min'))!='undefined')this.gf.min=parseInt(txt.attr('min'));if(typeof(txt.attr('max'))!='undefined')this.gf.max=parseInt(txt.attr('max'));if(typeof(txt.attr('restore'))!='undefined')this.gf.restore=parseInt(txt.attr('restore'));if(typeof(txt.attr('speed'))!='undefined')this.gf.speed=parseInt(txt.attr('speed'));if(!this.gf.min)this.gf.min=parseInt(txt.css('min-height'));if(!this.gf.min)this.gf.min=this.gf.initialH;if(!this.gf.max)this.gf.max=parseInt(txt.css('max-height'));this.gf.opera9=($.browser.opera&&$.browser.version<9.5);if(this.gf.restore){this.gf.restore=false;this._toggleRestore(true)}if(this.gf.auto){if(this.gf.initialH==0){txt.bind('keyup.growinit',this._afterShowInit)}else{this.gf.auto=false;this._toggleAuto(true)}}else this._toggleKeys(true);return true};this._afterShowInit=function(){this.gf.initialH=txt.get(0).offsetHeight;if(!this.gf.initialH)return true;if(!this.gf.min)this.gf.min=this.gf.initialH;txt.unbind('.growinit');this.gf.auto=false;this._toggleAuto(true);txt.focus();return true};this._toggleKeys=function(on){if(on){if(this.gf.keysEnabled)return false;txt.bind(($.browser.msie?'keyup':'keydown')+'.autogrow',function(event){if(!event.ctrlKey||$.inArray(event.keyCode,[38,40])==-1)return true;txt[event.keyCode==38?'decrease':'increase'](false,event);if($.browser.opera)txt.focus();if($.browser.msie||$.browser.opera)return false;return true});this.gf.keysEnabled=true}else{if(!this.gf.keysEnabled)return false;txt.unbind(($.browser.msie?'keyup':'keydown')+'.autogrow');this.gf.keysEnabled=false}};this._toggleAuto=function(on){if($.browser.opera||on){txt.css('overflow','hidden');if($.browser.opera&&txt.attr('style')&&txt.attr('style').indexOf('border')==-1)txt.css('border','1px solid #ccc')}if(on){if(this.gf.auto)return false;this._toggleKeys(false);this._createDummy();if(this.gf.impossible){this._growField=false;return false}txt.css('overflow','hidden');txt.bind('keyup.autogrow',function(event){if(!txt.val())this._changeSize(this.gf.min,event);else return this._changeSize(this._textHeight(),event)});if(txt.val())txt.keyup();$(window).bind('resize.autogrow',function(event){th.gf.dummy.width(txt.width())});this.gf.auto=true}else{if(!this.gf.auto)return false;this.gf.dummy.remove();this.gf.dummy=null;txt.unbind('keyup.autogrow');$(window).unbind('resize.autogrow');txt.css('overflow','auto');this.gf.auto=false;this._toggleKeys(true)}return true};this._toggleRestore=function(on){if(on){if(this.gf.restore)return false;this.gf.restore=true;txt.bind('focus.autogrow',function(event,noChange){if(!this.gf.auto||noChange||!txt.val())return true;else return this._changeSize(this._textHeight(),event)});txt.bind('blur.autogrow',function(event){return this.gf.auto?this._changeSize(this.gf.min,event):true})}else{if(!this.gf.restore)return false;this.gf.restore=false;txt.unbind('focus.autogrow').unbind('blur.autogrow');txt.keyup()}};this._changeSize=function(to,event){if(this.gf.busy)return true;if(!event)event={};this._growBefore(event);var ovr=txt.css('overflow');if(this.gf.max>0&&to>=this.gf.max){to=this.gf.max;if(ovr=='hidden'){txt.css('overflow','auto');if(event.type=='keyup')txt.focus();if(event.type=='focus'&&this.gf.animate&&this.gf.auto)txt.trigger('focus',true)}}else if(ovr=='auto'&&this.gf.auto){txt.css('overflow','hidden');if(event.type=='keyup')txt.focus()}if(this.gf.min>0&&to<=this.gf.min)to=this.gf.min;if(to==txt.get(0).offsetHeight){this.gf.busy=false;return true}return this._animate(txt.get(0).offsetHeight,to,event,ovr)};this._animate=function(from,to,event,ovr){if(!this.gf.animate||(ovr=='auto'&&this.gf.auto)||event.type=='init'){txt.height(to);return this._growAfter(event)}this.gf.queue=Math.floor((this.gf.speed/this.gf.ms)*(to0?-1:1);if(Math.abs(to-from)<3){txt.height(to);return th._growAfter()}from=th.gf.queue==0?to:from+Math.ceil((to-from)/2);txt.height(from);th.gf.timeout=window.setTimeout(function(){th._timeout(from,to)},th.gf.ms)};this._textHeight=function(){var val=txt.val();if($.browser.safari&&val.substr(-2)=="\n\n")val=val.substring(0,val.length-2)+"\n11";if($.browser.safari)this.gf.dummy.val('');this.gf.dummy.val(val);if(this.gf.opera9)this.gf.dummy.css('overflow','hidden').css('overflow','auto');var d=this.gf.dummy.get(0);if(this.gf.opera9)return d.clientHeight+this.gf.hOffset;if((d.scrollHeight+($.browser.safari?1:0))>d.clientHeight){return d.scrollHeight+(d.offsetHeight-d.clientHeight)+this.gf.hOffset+($.browser.safari?this.gf.hOffset:0)}else{if(!txt.val())return this.gf.min;else return d.offsetHeight+this.gf.hOffset}};this._createDummy=function(){if(this.gf.dummy){this.gf.dummy.remove();this.gf.dummy=false}var i=true;var tryPadding=false;while(i){this.gf.dummy=txt.clone().css({position:'absolute',left:-9999,top:0,visibility:'hidden',width:txt.get(0).offsetWidth}).attr('tabindex',-9999);if(this.gf.opera9){this.gf.dummy.css({overflow:'auto',height:'auto'});var padding=txt.css('padding');if((padding&&padding<4)||tryPadding)this.gf.dummy.css({padding:'4px'})}this.gf.dummy.get(0)._growField=false;txt.after(this.gf.dummy);this.gf.dummy.val('').height(10);this.gf.dummy.val("11");if(this.gf.opera9)this.gf.dummy.css('overflow','hidden').css('overflow','auto');var s1=this.gf.dummy.get(0).scrollHeight;this.gf.dummy.val("11\n11");if(this.gf.opera9)this.gf.dummy.css('overflow','hidden').css('overflow','auto');var s2=this.gf.dummy.get(0).scrollHeight;if(!this.gf.hOffset){this.gf.hOffset=s2-s1;if($.browser.opera&&!this.gf.opera9)this.gf.hOffset+=this.gf.dummy.get(0).offsetHeight-this.gf.dummy.height()}if(this.gf.opera9&&this.gf.hOffset==0){if(tryPadding)i=false;else{tryPadding=true;this.gf.dummy.remove();continue}}else i=false}};this._growBefore=function(event){this.gf.busy=true;this._growCallbackBefore(event)};this._growAfter=function(event){if(this.gf.timeout){window.clearTimeout(this.gf.timeout);this.gf.timeout=false}this.gf.busy=false;this._growCallbackAfter(event);return true};this._growCallbackBefore=function(){};this._growCallbackAfter=function(){};$(function(){th._growInit()})})};$.fn.increase=function(step,event){this.each(function(){if(!this._growField||this.gf.auto)return true;this._changeSize(this.offsetHeight+(step?parseInt(step):this.gf.hOffset),event)})};$.fn.decrease=function(step,event){this.each(function(){if(!this._growField||this.gf.auto)return true;this._changeSize(this.offsetHeight-(step?parseInt(step):this.gf.hOffset),event)})};$.fn.growToggleAuto=function(bool){if(bool&&bool!=true&&bool!=false&&bool.toLowerCase()!='on'&&bool.toLowerCase()!='off')delete(bool);if(bool&&typeof(bool)=='string')bool=bool.toLowerCase()=='on'?true:false;this.each(function(){if(!this._growField)return true;this._toggleAuto(bool)})};$.fn.growToggleAnimation=function(bool){if(bool&&bool!=true&&bool!=false&&bool.toLowerCase()!='on'&&bool.toLowerCase()!='off')delete(bool);if(bool&&typeof(bool)=='string')bool=bool.toLowerCase()=='on'?true:false;this.each(function(){if(!this._growField)return true;this.gf.animate=bool})};$.fn.growTo=function(h){this.each(function(){if(!this._growField)return true;this._changeSize(h)})};$.fn.growSetMin=function(h){this.each(function(){if(!this._growField)return true;h=parseInt(h);if(h<10&&this.gf.initialH)h=this.gf.initialH;if(h<10)return true;this.gf.min=parseInt(h);if(this.offsetHeightthis.gf.max)$(this).growTo(this.gf.max)})};$.fn.growToggleRestore=function(bool){if(bool&&bool!=true&&bool!=false&&bool.toLowerCase()!='on'&&bool.toLowerCase()!='off')delete(bool);if(bool&&typeof(bool)=='string')bool=bool.toLowerCase()=='on'?true:false;this.each(function(){if(!this._growField)return true;this._toggleRestore(bool)})};$.fn.growRenewDummy=function(){this.each(function(){if(!this._growField)return true;this._createDummy()})}})(jQuery); \ No newline at end of file -- cgit v1.2.3