if (typeof MMui === 'undefined') MMui = {};

// Utils are extracted from other libraries or
// written from scratch to plug holes in browser compatibility.
MMui.u = {
    // From Bonzo
    offset: function(el) {
        // TODO: window margins
        //
        // Okay, so fall back to styles if offsetWidth and height are botched
        // by Firefox.
        var width = el.offsetWidth || parseInt(el.style.width, 10),
            height = el.offsetHeight || parseInt(el.style.height, 10),
            doc_body = document.body,
            top = 0,
            left = 0;

        var calculateOffset = function(el) {
            if (el === doc_body || el === document.documentElement) return;
            top += el.offsetTop;
            left += el.offsetLeft;

            var style = el.style.transform ||
                el.style.WebkitTransform ||
                el.style.OTransform ||
                el.style.MozTransform ||
                el.style.msTransform;

            if (style) {
                var match;
                if (match = style.match(/translate\((.+)px, (.+)px\)/)) {
                    top += parseInt(match[2], 10);
                    left += parseInt(match[1], 10);
                } else if (match = style.match(/translate3d\((.+)px, (.+)px, (.+)px\)/)) {
                    top += parseInt(match[2], 10);
                    left += parseInt(match[1], 10);
                } else if (match = style.match(/matrix3d\(([\-\d,\s]+)\)/)) {
                    var pts = match[1].split(',');
                    top += parseInt(pts[13], 10);
                    left += parseInt(pts[12], 10);
                } else if (match = style.match(/matrix\(.+, .+, .+, .+, (.+), (.+)\)/)) {
                    top += parseInt(match[2], 10);
                    left += parseInt(match[1], 10);
                }
            }
        };

        calculateOffset(el);

        try {
            while (el = el.offsetParent) { calculateOffset(el); }
        } catch(e) {
            // Hello, internet explorer.
        }

        // Offsets from the body
        top += doc_body.offsetTop;
        left += doc_body.offsetLeft;
        // Offsets from the HTML element
        top += doc_body.parentNode.offsetTop;
        left += doc_body.parentNode.offsetLeft;

        // Firefox and other weirdos. Similar technique to jQuery's
        // `doesNotIncludeMarginInBodyOffset`.
        var htmlComputed = document.defaultView ?
            window.getComputedStyle(doc_body.parentNode, null) :
            doc_body.parentNode.currentStyle;
        if (doc_body.parentNode.offsetTop !==
            parseInt(htmlComputed.marginTop, 10) &&
            !isNaN(parseInt(htmlComputed.marginTop, 10))) {
            top += parseInt(htmlComputed.marginTop, 10);
            left += parseInt(htmlComputed.marginLeft, 10);
        }

        return {
            top: top,
            left: left,
            height: height,
            width: width
        };
    },

    '$': function(x) {
        return (typeof x === 'string') ?
            document.getElementById(x) :
            x;
    },

    // From quirksmode: normalize the offset of an event from the top-left
    // of the page.
    eventoffset: function(e) {
        var posx = 0;
        var posy = 0;
        if (!e) { e = window.event; }
        if (e.pageX || e.pageY) {
            // Good browsers
            return {
                x: e.pageX,
                y: e.pageY
            };
        } else if (e.clientX || e.clientY) {
            // Internet Explorer
            return {
                x: e.clientX,
                y: e.clientY
            };
        } else if (e.touches && e.touches.length === 1) {
            // Touch browsers
            return {
                x: e.touches[0].pageX,
                y: e.touches[0].pageY
            };
        }
    },

    // Ripped from underscore.js
    // Internal function used to implement `_.throttle` and `_.debounce`.
    limit: function(func, wait, debounce) {
        var timeout;
        return function() {
            var context = this, args = arguments;
            var throttler = function() {
                timeout = null;
                func.apply(context, args);
            };
            if (debounce) clearTimeout(timeout);
            if (debounce || !timeout) timeout = setTimeout(throttler, wait);
        };
    },

    // Returns a function, that, when invoked, will only be triggered at most once
    // during a given window of time.
    throttle: function(func, wait) {
        return this.limit(func, wait, false);
    },

    sanitize: function(content) {
        if (!content) return '';

        function urlX(url) {
            // Data URIs are subject to a bug in Firefox
            // https://bugzilla.mozilla.org/show_bug.cgi?id=255107
            // which let them be a vector. But WebKit does 'the right thing'
            // or at least 'something' about this situation, so we'll tolerate
            // them.
            if (/^(https?:\/\/|data:image)/.test(url)) {
                return url;
            }
        }

        function idX(id) { return id; }

        return html_sanitize(content, urlX, idX);
    }
};

@@ -164,3700 +164,128 @@
 = %7B%0A
-    // From Bonzo%0A    offset: function(el) %7B%0A        // TODO: window margins%0A        //%0A        // Okay, so fall back to styles if offsetWidth and height are botched%0A        // by Firefox.%0A        var width = el.offsetWidth %7C%7C parseInt(el.style.width, 10),%0A            height = el.offsetHeight %7C%7C parseInt(el.style.height, 10),%0A            doc_body = document.body,%0A            top = 0,%0A            left = 0;%0A%0A        var calculateOffset = function(el) %7B%0A            if (el === doc_body %7C%7C el === document.documentElement) return;%0A            top += el.offsetTop;%0A            left += el.offsetLeft;%0A%0A            var style = el.style.transform %7C%7C%0A                el.style.WebkitTransform %7C%7C%0A                el.style.OTransform %7C%7C%0A                el.style.MozTransform %7C%7C%0A                el.style.msTransform;%0A%0A            if (style) %7B%0A                var match;%0A                if (match = style.match(/translate%5C((.+)px, (.+)px%5C)/)) %7B%0A                    top += parseInt(match%5B2%5D, 10);%0A                    left += parseInt(match%5B1%5D, 10);%0A                %7D else if (match = style.match(/translate3d%5C((.+)px, (.+)px, (.+)px%5C)/)) %7B%0A                    top += parseInt(match%5B2%5D, 10);%0A                    left += parseInt(match%5B1%5D, 10);%0A                %7D else if (match = style.match(/matrix3d%5C((%5B%5C-%5Cd,%5Cs%5D+)%5C)/)) %7B%0A                    var pts = match%5B1%5D.split(',');%0A                    top += parseInt(pts%5B13%5D, 10);%0A                    left += parseInt(pts%5B12%5D, 10);%0A                %7D else if (match = style.match(/matrix%5C(.+, .+, .+, .+, (.+), (.+)%5C)/)) %7B%0A                    top += parseInt(match%5B2%5D, 10);%0A                    left += parseInt(match%5B1%5D, 10);%0A                %7D%0A            %7D%0A        %7D;%0A%0A        calculateOffset(el);%0A%0A        try %7B%0A            while (el = el.offsetParent) %7B calculateOffset(el); %7D%0A        %7D catch(e) %7B%0A            // Hello, internet explorer.%0A        %7D%0A%0A        // Offsets from the body%0A        top += doc_body.offsetTop;%0A        left += doc_body.offsetLeft;%0A        // Offsets from the HTML element%0A        top += doc_body.parentNode.offsetTop;%0A        left += doc_body.parentNode.offsetLeft;%0A%0A        // Firefox and other weirdos. Similar technique to jQuery's%0A        // %60doesNotIncludeMarginInBodyOffset%60.%0A        var htmlComputed = document.defaultView ?%0A            window.getComputedStyle(doc_body.parentNode, null) :%0A            doc_body.parentNode.currentStyle;%0A        if (doc_body.parentNode.offsetTop !==%0A            parseInt(htmlComputed.marginTop, 10) &&%0A            !isNaN(parseInt(htmlComputed.marginTop, 10))) %7B%0A            top += parseInt(htmlComputed.marginTop, 10);%0A            left += parseInt(htmlComputed.marginLeft, 10);%0A        %7D%0A%0A        return %7B%0A            top: top,%0A            left: left,%0A            height: height,%0A            width: width%0A        %7D;%0A    %7D,%0A%0A    '$': function(x) %7B%0A        return (typeof x === 'string') ?%0A            document.getElementById(x) :%0A            x;%0A    %7D,%0A%0A    // From quirksmode: normalize the offset of an event from the top-left%0A    // of the page.%0A    eventoffset: function(e) %7B%0A        var posx = 0;%0A        var posy = 0;%0A        if (!e) %7B e = window.event; %7D%0A        if (e.pageX %7C%7C e.pageY) %7B%0A            // Good browsers%0A            return %7B%0A                x: e.pageX,%0A                y: e.pageY%0A            %7D;%0A        %7D else if (e.clientX %7C%7C e.clientY) %7B%0A            // Internet Explorer%0A            return %7B%0A                x: e.clientX,%0A                y: e.clientY%0A            %7D;%0A        %7D else if (e.touches && e.touches.length === 1) %7B%0A            // Touch browsers%0A            return %7B%0A                x: e.touches%5B0%5D.pageX,%0A                y: e.touches%5B0%5D.pageY%0A            %7D;%0A        %7D
+%0A    '$': function(x) %7B%0A        return (typeof x === 'string') ?%0A            document.getElementById(x) :%0A            x;
 %0A   

Remove unused utils