Patch for IE bugs in ui.dialog and ui.slider

Patch for IE bugs in ui.dialog and ui.slider


What do people think of these patches to fix exceptions being thrown
in IE6 and 7 when
using dialogs and sliders and one of the attributes ends up being NaN?
Another issue addressed is displaying ui.dialog with width and height
set to 'none' (IE6 and IE7)
and the margin set to 'auto' (IE7), and also making sure the layout is
correctly rendered in IE6 & 7.
I think it would be nice to have these or similar patches in the newer
versions of jquery.ui.
Thanks,
/Chandan Kudige
diff -ruBb jpoker-reference/jquery/ui/ui.dialog.js jpoker-ckfix/jquery/
ui/ui.dialog.js
--- jpoker-reference/jquery/ui/ui.dialog.js    2008-07-28
17:42:00.000000000 +1000
+++ jpoker-ckfix/jquery/ui/ui.dialog.js    2008-07-29 17:37:30.000000000
+1000
@@ -29,6 +29,20 @@
$.widget("ui.dialog", {
    init: function() {
+     if ($.browser.msie) {
+        /* IE Compatibility bug:
+         * IE does not accept width or height to be set as 'none',
+         * This code fixes the behaviour to be as if the width or height
was not set.
+         */
+        if (this.options.width == 'none') {
+         this.options.width = undefined;
+        }
+
+        if (this.options.height == 'none') {
+         this.options.height = undefined;
+        }
+     }
+
        var self = this,
            options = this.options,
            resizeHandles = typeof options.resizable == 'string'
@@ -40,9 +54,17 @@
                .wrap('<div/>')
                .wrap('<div/>'),
+     /* IE Compatibility bug:
+     * When the uiDialogContainer is set to a width/height of 100%
+     * and the widget width is 'none', IE does not render the widget
correctly.
+     * To fix this, ability to override containerWidth/Height is
required.
+     * Pass these in the options.
+     */
            uiDialogContainer = (this.uiDialogContainer =
uiDialogContent.parent()
                .addClass('ui-dialog-container')
-                .css({position: 'relative', width: '100%', height: '100%'})),
+                .css({position: 'relative',
+                 width: options.containerWidth,
+                 height: options.containerHeight})),
            title = options.title || uiDialogContent.attr('title') || '',
            uiDialogTitlebar = (this.uiDialogTitlebar =
@@ -237,6 +259,16 @@
            content = this.element,
            tbMargin = parseInt(content.css('margin-top')) +
parseInt(content.css('margin-bottom')),
            lrMargin = parseInt(content.css('margin-left')) +
parseInt(content.css('margin-right'));
+
+     /* IE Compatibility Bug
+         * When margin is set to auto, the lbMargin and lrMargin values are
NaN and
+         * causes exception on IE.
+         */
+      if (isNaN(tbMargin))
+         tbMargin = 0;
+      if (isNaN(lrMargin))
+         lrMargin = 0;
+
        content.height(container.height() - titlebar.outerHeight() -
tbMargin);
        content.width(container.width() - lrMargin);
    },
@@ -340,7 +372,13 @@
        resizable: true,
        stack: true,
        width: 300,
-        zIndex: 1000
+      zIndex: 1000,
+/*
+ * IE Compatibility (by CK)
+ * Please refer to function ui.dialog.init
+ */
+ containerWidth: '100%',
+ containerHeight: '100%'
    },
    overlay: function(dialog) {
diff -ruBb jpoker-reference/jquery/ui/ui.slider.js jpoker-ckfix/jquery/
ui/ui.slider.js
--- jpoker-reference/jquery/ui/ui.slider.js    2008-07-28
17:42:00.000000000 +1000
+++ jpoker-ckfix/jquery/ui/ui.slider.js    2008-07-29 15:37:06.000000000
+1000
@@ -379,7 +379,12 @@
        if(x !== undefined && x.constructor != Number) {
            var me = /^\-\=/.test(x), pe = /^\+\=/.test(x);
            if(me || pe) {
-                x = this.value(null, "x") + parseInt(x.replace(me ? '=' : '+=',
''), 10);
+             /* Fix for slider errors on IE:
+             * A lot of math in ui.slider is not tested for division by
zero and such
+             * These conditions return NaN values which are safely ignored
on
+             * Firefox/Safari but causes exceptions on IE.
+             */
+             x = isNaN(this.value(null, "x"))?0:this.value(null, "x") +
parseInt(x.replace(me ? '=' : '+=', ''), 10);
            } else {
                x = isNaN(parseInt(x, 10)) ? undefined : parseInt(x, 10);
            }
@@ -388,7 +393,7 @@
        if(y !== undefined && y.constructor != Number) {
            var me = /^\-\=/.test(y), pe = /^\+\=/.test(y);
            if(me || pe) {
-                y = this.value(null, "y") + parseInt(y.replace(me ? '=' : '+=',
''), 10);
+                y = isNaN(this.value(null, "y"))?0:this.value(null, "y") +
parseInt(y.replace(me ? '=' : '+=', ''), 10);
            } else {
                y = isNaN(parseInt(y, 10)) ? undefined : parseInt(y, 10);
            }
@@ -399,6 +404,12 @@
            x = this.translateValue(x, "x");
            x = this.translateLimits(x, "x");
            x = this.translateRange(x, "x");
+            /* Fix for slider errors on IE:
+             * A lot of math in ui.slider is not tested for division by zero
and such
+             * These conditions return NaN values which are safely ignored on
+             * Firefox/Safari but causes exceptions on IE.
+             */
+            if (!isNaN(x))
            this.currentHandle.css({ left: x });
        }
@@ -407,6 +418,7 @@
            y = this.translateValue(y, "y");
            y = this.translateLimits(y, "y");
            y = this.translateRange(y, "y");
+            if (!isNaN(y))
            this.currentHandle.css({ top: y });
        }