+ Added iQ.timeout, which wraps setTimeout in try/catch. Everything uses this now
authorIan Gilman <ian@iangilman.com>
Thu, 10 Jun 2010 12:04:39 -0700
changeset 49459 cb9cbc26802dd521a11891bbb9f203a7d856fcd9
parent 49457 6dfc3bf713aec2358ab10aad315e1d17dc0e8823
child 49460 53445c94521fea3c6b599cfebb789503af0ada77
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
+ Added iQ.timeout, which wraps setTimeout in try/catch. Everything uses this now
browser/base/content/tabview/iq.js
--- a/browser/base/content/tabview/iq.js
+++ b/browser/base/content/tabview/iq.js
@@ -415,41 +415,33 @@ iQ.fn = iQ.prototype = {
 		
 		return this;
 	},
 
   // ----------
   // Function: width
 	width: function(unused) {
     Utils.assert('does not yet support setting', unused === undefined);
-/*     Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1); */
-    return parseInt(this.css('width')); //this[0].clientWidth;
+    return parseInt(this.css('width')); 
   },
 
   // ----------
   // Function: height
 	height: function(unused) {
     Utils.assert('does not yet support setting', unused === undefined);
-/*     Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1); */
-    return parseInt(this.css('height')); //this[0].clientHeight;
+    return parseInt(this.css('height'));
   },
 
   // ----------
   // Function: position
   position: function(unused) {
     Utils.assert('does not yet support setting', unused === undefined);
-/*     Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1); */
-/*     var el = this[0]; */
     return {
       left: parseInt(this.css('left')),
       top: parseInt(this.css('top'))
-/*
-      left: (parseInt(el.style.left) || el.offsetLeft), 
-      top: (parseInt(el.style.top) || el.offsetTop)
-*/
     };
   },
   
   // ----------
   // Function: bounds
   bounds: function(unused) {
     Utils.assert('does not yet support setting', unused === undefined);
     Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
@@ -616,29 +608,25 @@ iQ.fn = iQ.prototype = {
         '-moz-transition-property': 'all', // TODO: just animate the properties we're changing  
         '-moz-transition-duration': (duration / 1000) + 's',  
         '-moz-transition-timing-function': easing
       });
 
       this.css(css);
       
       var self = this;
-      setTimeout(function() {
-        try {
-          self.css({
-            '-moz-transition-property': 'none',  
-            '-moz-transition-duration': '',  
-            '-moz-transition-timing-function': ''
-          });
-  
-          if(iQ.isFunction(options.complete))
-            options.complete.apply(self);
-        } catch(e) {
-          Utils.log(e);
-        }      
+      iQ.timeout(function() {
+        self.css({
+          '-moz-transition-property': 'none',  
+          '-moz-transition-duration': '',  
+          '-moz-transition-timing-function': ''
+        });
+
+        if(iQ.isFunction(options.complete))
+          options.complete.apply(self);
       }, duration);
     } catch(e) {
       Utils.log(e);
     }
     
     return this;
   },
     
@@ -769,17 +757,17 @@ iQ.fn = iQ.prototype = {
         }
       }
       
       elem.removeEventListener(type, handler, false);
     }
     
     return this; 
   },
-
+  
   // ----------
   // Function: draggable
   draggable: function(options) {
     try {
       if(!options)
         options = {};
         
       var cancelClasses = [];
@@ -1264,17 +1252,30 @@ iQ.extend({
 		// that pass the validator function
 		for ( var i = 0, length = elems.length; i < length; i++ ) {
 			if ( !inv !== !callback( elems[ i ], i ) ) {
 				ret.push( elems[ i ] );
 			}
 		}
 
 		return ret;
-	}	
+	},
+
+  // ----------
+  // Function: timeout
+  // wraps setTimeout with try/catch
+  timeout: function(func, delay) {
+    setTimeout(function() { 
+      try {
+        func();
+      } catch(e) {
+        Utils.log(e);
+      }
+    }, delay);
+  }
 });
 
 // ----------
 // Create various event aliases
 (function() {
   var events = [
     'keyup',
     'keydown',