Re-add horde.js as a container of commonly used prototype extensions.
authorJan Schneider <jan@horde.org>
Wed, 29 Jul 2009 14:50:00 +0000 (16:50 +0200)
committerJan Schneider <jan@horde.org>
Wed, 29 Jul 2009 16:53:26 +0000 (18:53 +0200)
imp/js/src/DimpCore.js
imp/lib/DIMP.php
kronolith/js/src/kronolith.js
kronolith/lib/Kronolith.php

index df6624d..471995a 100644 (file)
@@ -469,74 +469,3 @@ var DimpCore = {
     }
 
 };
-
-/* Helper methods for setting/getting element text without mucking
- * around with multiple TextNodes. */
-Element.addMethods({
-    setText: function(element, text)
-    {
-        var t = 0;
-        $A(element.childNodes).each(function(node) {
-            if (node.nodeType == 3) {
-                if (t++) {
-                    Element.remove(node);
-                } else {
-                    node.nodeValue = text;
-                }
-            }
-        });
-
-        if (!t) {
-            $(element).insert(text);
-        }
-    },
-
-    getText: function(element, recursive)
-    {
-        var text = '';
-        $A(element.childNodes).each(function(node) {
-            if (node.nodeType == 3) {
-                text += node.nodeValue;
-            } else if (recursive && node.hasChildNodes()) {
-                text += $(node).getText(true);
-            }
-        });
-        return text;
-    }
-});
-
-/* Create some utility functions. */
-Object.extend(Array.prototype, {
-    // Need our own diff() function because prototypejs's without() function
-    // does not handle array input.
-    diff: function(values)
-    {
-        return this.select(function(value) {
-            return !values.include(value);
-        });
-    },
-    numericSort: function()
-    {
-        return this.collect(Number).sort(function(a,b) {
-            return (a > b) ? 1 : ((a < b) ? -1 : 0);
-        });
-    }
-});
-
-Object.extend(String.prototype, {
-    // We define our own version of evalScripts() to make sure that all
-    // scripts are running in the same scope and that all functions are
-    // defined in the global scope. This is not the case when using
-    // prototype's evalScripts().
-    evalScripts: function()
-    {
-        var re = /function\s+([^\s(]+)/g;
-        this.extractScripts().each(function(s) {
-            var func;
-            eval(s);
-            while (func = re.exec(s)) {
-                window[func[1]] = eval(func[1]);
-            }
-        });
-    }
-});
index 120819b..5959009 100644 (file)
@@ -64,6 +64,7 @@ class DIMP
         // Need to include script files before we start output
         Horde::addScriptFile('prototype.js', 'horde', true);
         Horde::addScriptFile('effects.js', 'horde', true);
+        Horde::addScriptFile('horde.js', 'horde', true);
 
         // ContextSensitive must be loaded before DimpCore.
         while (list($key, $val) = each($scripts)) {
index 7543513..9b04092 100644 (file)
@@ -1497,14 +1497,14 @@ KronolithCore = {
 
         switch (view) {
         case 'week':
-            start.moveToBeginOfWeek();
-            end.moveToEndOfWeek();
+            start.moveToBeginOfWeek(Kronolith.conf.week_start);
+            end.moveToEndOfWeek(Kronolith.conf.week_start);
             break;
         case 'month':
             start.setDate(1);
-            start.moveToBeginOfWeek();
+            start.moveToBeginOfWeek(Kronolith.conf.week_start);
             end.moveToLastDayOfMonth();
-            end.moveToEndOfWeek();
+            end.moveToEndOfWeek(Kronolith.conf.week_start);
             break;
         case 'year':
             start.setDate(1);
@@ -2204,124 +2204,6 @@ KronolithCore = {
 
 };
 
-/* Helper methods for setting/getting element text without mucking
- * around with multiple TextNodes. */
-Element.addMethods({
-    setText: function(element, text)
-    {
-        var t = 0;
-        $A(element.childNodes).each(function(node) {
-            if (node.nodeType == 3) {
-                if (t++) {
-                    Element.remove(node);
-                } else {
-                    node.nodeValue = text;
-                }
-            }
-        });
-
-        if (!t) {
-            $(element).insert(text);
-        }
-
-        return element;
-    },
-
-    getText: function(element, recursive)
-    {
-        var text = '';
-        $A(element.childNodes).each(function(node) {
-            if (node.nodeType == 3) {
-                text += node.nodeValue;
-            } else if (recursive && node.hasChildNodes()) {
-                text += $(node).getText(true);
-            }
-        });
-        return text;
-    }
-});
-
-/* Create some utility functions. */
-Object.extend(Array.prototype, {
-    // Need our own diff() function because prototypejs's without() function
-    // does not handle array input.
-    diff: function(values)
-    {
-        return this.select(function(value) {
-            return !values.include(value);
-        });
-    },
-    numericSort: function()
-    {
-        return this.collect(Number).sort(function(a,b) {
-            return (a > b) ? 1 : ((a < b) ? -1 : 0);
-        });
-    }
-});
-
-Object.extend(String.prototype, {
-    // We define our own version of evalScripts() to make sure that all
-    // scripts are running in the same scope and that all functions are
-    // defined in the global scope. This is not the case when using
-    // prototype's evalScripts().
-    evalScripts: function()
-    {
-        var re = /function\s+([^\s(]+)/g;
-        this.extractScripts().each(function(s) {
-            var func;
-            eval(s);
-            while (func = re.exec(s)) {
-                window[func[1]] = eval(func[1]);
-            }
-        });
-    }
-});
-
-Object.extend(Date.prototype, {
-    /**
-     * Moves a date to the end of the corresponding week.
-     *
-     * @return Date  The same Date object, now pointing to the end of the week.
-     */
-    moveToEndOfWeek: function()
-    {
-        var weekEndDay = Kronolith.conf.week_start + 6;
-        if (weekEndDay > 6) {
-            weekEndDay -= 7;
-        }
-        if (this.getDay() != weekEndDay) {
-            this.moveToDayOfWeek(weekEndDay, 1);
-        }
-        return this;
-    },
-
-    /**
-     * Moves a date to the begin of the corresponding week.
-     *
-     * @return Date  The same Date object, now pointing to the begin of the
-     *               week.
-     */
-    moveToBeginOfWeek: function()
-    {
-        if (this.getDay() != Kronolith.conf.week_start) {
-            this.moveToDayOfWeek(Kronolith.conf.week_start, -1);
-        }
-        return this;
-    },
-
-    /**
-     * Format date and time to be passed around as a short url parameter,
-     * cache id, etc.
-     *
-     * @return string  Date and time.
-     */
-    dateString: function()
-    {
-        return this.toString('yyyyMMdd');
-    }
-
-});
-
 /* Initialize global event handlers. */
 document.observe('dom:loaded', KronolithCore.onDomLoad.bind(KronolithCore));
 Event.observe(window, 'resize', KronolithCore.onResize.bind(KronolithCore));
index 51af864..0296039 100644 (file)
@@ -71,6 +71,7 @@ class Kronolith
         // Need to include script files before we start output
         Horde::addScriptFile('prototype.js', 'horde', true);
         Horde::addScriptFile('effects.js', 'horde', true);
+        Horde::addScriptFile('horde.js', 'horde', true);
         Horde::addScriptFile('dragdrop2.js', 'horde', true);
         Horde::addScriptFile('Growler.js', 'horde', true);