Move onDomLoad() to the bottom again.
authorJan Schneider <jan@horde.org>
Wed, 20 Jan 2010 18:26:18 +0000 (19:26 +0100)
committerJan Schneider <jan@horde.org>
Wed, 20 Jan 2010 22:32:07 +0000 (23:32 +0100)
kronolith/js/kronolith.js

index 364927a..49b90be 100644 (file)
@@ -3538,127 +3538,6 @@ KronolithCore = {
         RedBox.close();
     },
 
-    /* Onload function. */
-    onDomLoad: function()
-    {
-        if (typeof ContextSensitive != 'undefined') {
-            this.DMenu = new ContextSensitive({ onClick: this.contextOnClick, onShow: this.contextOnShow });
-        }
-
-        document.observe('keydown', KronolithCore.keydownHandler.bindAsEventListener(KronolithCore));
-        document.observe('keyup', KronolithCore.keyupHandler.bindAsEventListener(KronolithCore));
-        document.observe('click', KronolithCore.clickHandler.bindAsEventListener(KronolithCore));
-        document.observe('dblclick', KronolithCore.clickHandler.bindAsEventListener(KronolithCore, true));
-        document.observe('mouseover', KronolithCore.mouseHandler.bindAsEventListener(KronolithCore, 'over'));
-
-        $('kronolithSearchTerm').observe('focus', function() {
-            if ($F(this) == this.readAttribute('default')) {
-                this.clear();
-            }
-        });
-        $('kronolithSearchTerm').observe('blur', function() {
-            if (!$F(this)) {
-                this.setValue(this.readAttribute('default'));
-            }
-        });
-
-        // Mouse wheel handler.
-        [ 'kronolithEventStartDate', 'kronolithEventEndDate' ].each(function(field) {
-            $(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) {
-                var date = Date.parseExact($F(field), Kronolith.conf.date_format);
-                if (!date || (!e.wheelData && !e.detail)) {
-                    return;
-                }
-                date.add(e.wheelData > 0 || e.detail < 0 ? 1 : -1).days();
-                $(field).setValue(date.toString(Kronolith.conf.date_format));
-            });
-        });
-
-        [ 'kronolithEventStartTime', 'kronolithEventEndTime' ].each(function(field) {
-            $(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) {
-                var time = $F(field).match(/(\d+)\s*:\s*(\d+)\s*((a|p)m)?/i),
-                    hour, minute;
-                if (!time || (!e.wheelData && !e.detail)) {
-                    return;
-                }
-
-                minute = parseInt(time[2]);
-                if (minute % 10) {
-                    if (e.wheelData > 0 || e.detail < 0) {
-                        minute = (minute + 10) / 10 | 0;
-                    } else {
-                        minute = minute / 10 | 0;
-                    }
-                    minute *= 10;
-                } else {
-                    minute += (e.wheelData > 0 || e.detail < 0 ? 10 : -10);
-                }
-                hour = parseInt(time[1]);
-                if (minute < 0) {
-                    if (hour > 0) {
-                        hour--;
-                        minute = 50;
-                    } else {
-                        minute = 0;
-                    }
-                } else if (minute >= 60) {
-                    if (hour < 23) {
-                        hour++;
-                        minute = 0;
-                    } else {
-                        minute = 59;
-                    }
-                }
-
-                $(field).setValue($F(field).replace(/(.*?)\d+(\s*:\s*)\d+(.*)/, '$1' + hour + ':' + minute.toPaddedString(2) + '$3'));
-
-                /* Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=502818
-                 * Need to stop or else multiple scroll events may be fired. We
-                 * lose the ability to have the mousescroll bubble up, but that is
-                 * more desirable than having the wrong scrolling behavior. */
-                if (Prototype.Browser.Gecko && !e.stop) {
-                    Event.stop(e);
-                }
-            });
-        });
-
-        if (Horde.dhtmlHistory.initialize()) {
-            Horde.dhtmlHistory.addListener(this.go.bind(this));
-        }
-
-        this.updateCalendarList();
-
-        /* Initialize the starting page if necessary. addListener() will have
-         * already fired if there is a current location so only do a go()
-         * call if there is no current location. */
-        if (!Horde.dhtmlHistory.getCurrentLocation()) {
-            this.go(Kronolith.conf.login_view);
-        }
-
-        $('kronolithMenu').select('div.kronolithCalendars div').each(function(s) {
-            s.observe('mouseover', s.addClassName.curry('kronolithCalOver'));
-            s.observe('mouseout', s.removeClassName.curry('kronolithCalOver'));
-        });
-
-        /* Add Growler notifications. */
-        this.Growler = new Growler({
-            log: true,
-            location: 'br',
-            noalerts: Kronolith.text.noalerts
-        });
-
-        if (Kronolith.conf.is_ie6) {
-            /* Disable text selection in preview pane for IE 6. */
-            document.observe('selectstart', Event.stop);
-
-            /* Since IE 6 doesn't support hover over non-links, use javascript
-             * events to replicate mouseover CSS behavior. */
-            $('foobar').compact().invoke('select', 'LI').flatten().compact().each(function(e) {
-                e.observe('mouseover', e.addClassName.curry('over')).observe('mouseout', e.removeClassName.curry('over'));
-            });
-        }
-    },
-
     toggleCalendar: function(elm)
     {
         elm.toggleClassName('on');
@@ -3819,6 +3698,127 @@ KronolithCore = {
         this.placeMapMarker(o.lonlat, false);
         var gc = new HordeMap.Geocoder[Kronolith.conf.maps.geocoder](this.map.map, 'kronolithEventMap');
         gc.reverseGeocode(o.lonlat, this.onReverseGeocode.bind(this), this.onGeocodeError.bind(this) );
+    },
+
+    /* Onload function. */
+    onDomLoad: function()
+    {
+        if (typeof ContextSensitive != 'undefined') {
+            this.DMenu = new ContextSensitive({ onClick: this.contextOnClick, onShow: this.contextOnShow });
+        }
+
+        document.observe('keydown', KronolithCore.keydownHandler.bindAsEventListener(KronolithCore));
+        document.observe('keyup', KronolithCore.keyupHandler.bindAsEventListener(KronolithCore));
+        document.observe('click', KronolithCore.clickHandler.bindAsEventListener(KronolithCore));
+        document.observe('dblclick', KronolithCore.clickHandler.bindAsEventListener(KronolithCore, true));
+        document.observe('mouseover', KronolithCore.mouseHandler.bindAsEventListener(KronolithCore, 'over'));
+
+        $('kronolithSearchTerm').observe('focus', function() {
+            if ($F(this) == this.readAttribute('default')) {
+                this.clear();
+            }
+        });
+        $('kronolithSearchTerm').observe('blur', function() {
+            if (!$F(this)) {
+                this.setValue(this.readAttribute('default'));
+            }
+        });
+
+        // Mouse wheel handler.
+        [ 'kronolithEventStartDate', 'kronolithEventEndDate' ].each(function(field) {
+            $(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) {
+                var date = Date.parseExact($F(field), Kronolith.conf.date_format);
+                if (!date || (!e.wheelData && !e.detail)) {
+                    return;
+                }
+                date.add(e.wheelData > 0 || e.detail < 0 ? 1 : -1).days();
+                $(field).setValue(date.toString(Kronolith.conf.date_format));
+            });
+        });
+
+        [ 'kronolithEventStartTime', 'kronolithEventEndTime' ].each(function(field) {
+            $(field).observe(Prototype.Browser.Gecko ? 'DOMMouseScroll' : 'mousewheel', function(e) {
+                var time = $F(field).match(/(\d+)\s*:\s*(\d+)\s*((a|p)m)?/i),
+                    hour, minute;
+                if (!time || (!e.wheelData && !e.detail)) {
+                    return;
+                }
+
+                minute = parseInt(time[2]);
+                if (minute % 10) {
+                    if (e.wheelData > 0 || e.detail < 0) {
+                        minute = (minute + 10) / 10 | 0;
+                    } else {
+                        minute = minute / 10 | 0;
+                    }
+                    minute *= 10;
+                } else {
+                    minute += (e.wheelData > 0 || e.detail < 0 ? 10 : -10);
+                }
+                hour = parseInt(time[1]);
+                if (minute < 0) {
+                    if (hour > 0) {
+                        hour--;
+                        minute = 50;
+                    } else {
+                        minute = 0;
+                    }
+                } else if (minute >= 60) {
+                    if (hour < 23) {
+                        hour++;
+                        minute = 0;
+                    } else {
+                        minute = 59;
+                    }
+                }
+
+                $(field).setValue($F(field).replace(/(.*?)\d+(\s*:\s*)\d+(.*)/, '$1' + hour + ':' + minute.toPaddedString(2) + '$3'));
+
+                /* Mozilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=502818
+                 * Need to stop or else multiple scroll events may be fired. We
+                 * lose the ability to have the mousescroll bubble up, but that is
+                 * more desirable than having the wrong scrolling behavior. */
+                if (Prototype.Browser.Gecko && !e.stop) {
+                    Event.stop(e);
+                }
+            });
+        });
+
+        if (Horde.dhtmlHistory.initialize()) {
+            Horde.dhtmlHistory.addListener(this.go.bind(this));
+        }
+
+        this.updateCalendarList();
+
+        /* Initialize the starting page if necessary. addListener() will have
+         * already fired if there is a current location so only do a go()
+         * call if there is no current location. */
+        if (!Horde.dhtmlHistory.getCurrentLocation()) {
+            this.go(Kronolith.conf.login_view);
+        }
+
+        $('kronolithMenu').select('div.kronolithCalendars div').each(function(s) {
+            s.observe('mouseover', s.addClassName.curry('kronolithCalOver'));
+            s.observe('mouseout', s.removeClassName.curry('kronolithCalOver'));
+        });
+
+        /* Add Growler notifications. */
+        this.Growler = new Growler({
+            log: true,
+            location: 'br',
+            noalerts: Kronolith.text.noalerts
+        });
+
+        if (Kronolith.conf.is_ie6) {
+            /* Disable text selection in preview pane for IE 6. */
+            document.observe('selectstart', Event.stop);
+
+            /* Since IE 6 doesn't support hover over non-links, use javascript
+             * events to replicate mouseover CSS behavior. */
+            $('foobar').compact().invoke('select', 'LI').flatten().compact().each(function(e) {
+                e.observe('mouseover', e.addClassName.curry('over')).observe('mouseout', e.removeClassName.curry('over'));
+            });
+        }
     }
 
 };