r86847 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86846‎ | r86847 | r86848 >
Date:11:46, 25 April 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Javascript tweaks
Modified paths:
  • /trunk/extensions/Translate/js/jquery.autoresize.js (modified) (history)
  • /trunk/extensions/Translate/js/quickedit.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/js/jquery.autoresize.js
@@ -2,6 +2,7 @@
33 * jQuery autoResize (textarea auto-resizer)
44 * @copyright James Padolsey http://james.padolsey.com
55 * @version 1.04
 6+ * Modified by Nike
67 */
78
89 (function($){
@@ -16,9 +17,12 @@
1718 animateDuration : 150,
1819 animateCallback : function(){},
1920 extraSpace : 20,
20 - limit: 1000
 21+ limit: 1000,
 22+ delay: 1000,
2123 }, options);
2224
 25+ var timer;
 26+
2327 // Only textarea's auto-resize:
2428 this.filter('textarea').each(function(){
2529
@@ -47,30 +51,34 @@
4852 top: 0,
4953 left: -9999
5054 }).css(propOb).attr('tabIndex','-1').insertBefore(textarea);
51 -
 55+
5256 })(),
5357 lastScrollTop = null,
5458 updateSize = function() {
55 -
 59+ var that = this;
 60+ if (timer !== null) clearTimeout(timer);
 61+ timer = setTimeout(updateSizeLazy, settings.delay, that);
 62+ },
 63+ updateSizeLazy = function(that) {
5664 // Prepare the clone:
57 - clone.height(0).val($(this).val()).scrollTop(10000);
58 -
 65+ clone.height(0).val($(that).val()).scrollTop(10000);
 66+
5967 // Find the height of text:
6068 var scrollTop = Math.max(clone.scrollTop(), origHeight) + settings.extraSpace,
61 - toChange = $(this).add(clone);
62 -
 69+ toChange = $(that).add(clone);
 70+
6371 // Don't do anything if scrollTip hasen't changed:
6472 if (lastScrollTop === scrollTop) { return; }
6573 lastScrollTop = scrollTop;
66 -
 74+
6775 // Check for limit:
6876 if ( scrollTop >= settings.limit ) {
69 - $(this).css('overflow-y','');
 77+ $(that).css('overflow-y','');
7078 return;
7179 }
7280 // Fire off callback:
73 - settings.onResize.call(this);
74 -
 81+ settings.onResize.call(that);
 82+
7583 // Either animate or directly apply height:
7684 settings.animate && textarea.css('display') === 'block' ?
7785 toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback)
Index: trunk/extensions/Translate/js/quickedit.js
@@ -33,7 +33,7 @@
3434 this.setup = function() {
3535 this.cancel();
3636 var self = this;
37 - this.timeoutID = window.setTimeout( self.act, 600 );
 37+ this.timeoutID = window.setTimeout( self.act, 1000 );
3838 };
3939
4040 this.cancel = function() {
@@ -114,8 +114,9 @@
115115 });
116116
117117 var textarea = form.find( '.mw-translate-edit-area' );
 118+ textarea.css( 'display', 'block' );
 119+ textarea.autoResize({extraSpace: 15, limit: 200}).trigger( 'change' );
118120 textarea.focus();
119 - textarea.autoResize({extraSpace: 15, limit: 200}).trigger( 'change' );
120121
121122 if ( form.find( '.mw-translate-messagechecks' ) ) {
122123 var checker = new MessageCheckUpdater( function() {

Status & tagging log