views:

13

answers:

1

IE only bug... go figure...

I get Object doesn't support this property or method when I do this...

$('#the-content').showAsModal({
     'leftPosition': 100,
     'topPosition': 200,
     'centerX': true
});

I extended jQuery like this...

(function ($) {
    $.fn.showAsModal = function (options) {
        var settings = $.extend({
            'leftPosition': 0,
            'topPosition': 0,
            'transition': 'none',
            'transitionSpeed': 500,
            'zIndex': 9001,
            'centerX': false,
            'centerY': false
        }, options || {});

        return this.each(function () {
            var self = $(this)
            if (settings.centerY) settings.y = Math.floor((($(document).height() - self.height()) / 2);
            if (settings.centerX) settings.x = Math.floor(($(document).width() - self.width()) / 2);

            self.css({ 'position': 'absolute', 'top': settings.y + "px", 'left': settings.x + "px", 'z-index': settings.zIndex });

            if (self.parent('.modal-container').length <= 0)
                self.wrap("<div style=\"display:none;\" class=\"modal-container\"></div>");
            if (self.siblings('.modal-mask').length <= 0)
                self.parent().append("<div style=\"width:" + $(document).width() + "px;height:" + $(document).height() + "px;\" class=\"modal-mask\"></div>");
            self.parent().show().end();
        });
    };

    $.say = function () {

    };
})(jQuery);

Im importing JQuery then a file with the above snippet only in it.

This works great in firefox.

Lets just start an initiative to block people from our websites that use IE. If we all do it....

+1  A: 

You have an syntax-error inside the code, by this your code does'nt work in any browser.

if (settings.centerY) settings.y = Math.floor((($(document).height() - self.height()) / 2);

One of the 3 brackets following Math.floor is too much

Dr.Molle
wow - its so obvious when i read the question back now.. The weird thing is that it was working in FF. Must have been caching or something.
Blankasaurus