Move general jquery-safe javascript to it's own file
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 17 Nov 2010 20:46:33 +0000 (15:46 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 17 Nov 2010 20:46:33 +0000 (15:46 -0500)
horde/js/horde-jquery.js [new file with mode: 0644]
kronolith/js/mobile.js
kronolith/templates/mobile/head.html.php

diff --git a/horde/js/horde-jquery.js b/horde/js/horde-jquery.js
new file mode 100644 (file)
index 0000000..324fc2d
--- /dev/null
@@ -0,0 +1,79 @@
+/**
+ * Some general javascript code, prototypejs free, safe to use with jquery.
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ */
+Date.prototype.getRealWeek = function()
+{
+    var monday = this;
+    if (monday.getDay() < 1) {
+        monday = monday.clone().next().monday();
+    }
+    return monday.getWeek();
+};
+
+/**
+ * Moves a date to the end of the corresponding week.
+ *
+ * @return Date  The same Date object, now pointing to the end of the week.
+ */
+Date.prototype.moveToEndOfWeek = function(weekStart)
+{
+    var weekEndDay = weekStart + 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.
+ */
+Date.prototype.moveToBeginOfWeek = function(weekStart)
+{
+    if (this.getDay() != weekStart) {
+        this.moveToDayOfWeek(weekStart, -1);
+    }
+    return this;
+};
+
+/**
+ * Format date and time to be passed around as a short url parameter,
+ * cache id, etc.
+ *
+ * @return string  Date and time.
+ */
+Date.prototype.dateString = function()
+{
+    return this.toString('yyyyMMdd');
+};
+
+Number.prototype.toPaddedString = function(len,pad)
+{
+    len=(len) ? Number(len) : 2;
+    if (isNaN(len)) {
+      return null;
+    }
+    var dflt = (isNaN(this.toString())) ? " " : "0";
+    pad = (pad) ? pad.toString().substr(0,1) : dflt;
+    var str = this.toString();
+    if (dflt=="0") {
+        while (str.length < len) {
+            str=pad+str;
+        }
+    } else {
+        while (str.length < len) {
+            str += pad;
+        }
+    }
+    return str;
+};
+
+String.prototype.toPaddedString = Number.prototype.toPaddedString;
\ No newline at end of file
index da75ff4..9d5fb7c 100644 (file)
 };
 
 // JQuery Mobile setup
-$(KronolithMobile.onDocumentReady);
-
-// Some Date extensions from horde.js that can't be included because of it's
-// use of prototype.js
-Date.prototype.getRealWeek = function()
-{
-    var monday = this;
-    if (monday.getDay() < 1) {
-        monday = monday.clone().next().monday();
-    }
-    return monday.getWeek();
-};
-
-/**
- * Moves a date to the end of the corresponding week.
- *
- * @return Date  The same Date object, now pointing to the end of the week.
- */
-Date.prototype.moveToEndOfWeek = function(weekStart)
-{
-    var weekEndDay = weekStart + 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.
- */
-Date.prototype.moveToBeginOfWeek = function(weekStart)
-{
-    if (this.getDay() != weekStart) {
-        this.moveToDayOfWeek(weekStart, -1);
-    }
-    return this;
-};
-
-/**
- * Format date and time to be passed around as a short url parameter,
- * cache id, etc.
- *
- * @return string  Date and time.
- */
-Date.prototype.dateString = function()
-{
-    return this.toString('yyyyMMdd');
-};
-
-Number.prototype.toPaddedString = function(len,pad)
-{
-    len=(len) ? Number(len) : 2;
-    if (isNaN(len)) {
-      return null;
-    }
-    var dflt = (isNaN(this.toString())) ? " " : "0";
-    pad = (pad) ? pad.toString().substr(0,1) : dflt;
-    var str = this.toString();
-    if (dflt=="0") {
-        while (str.length < len) {
-            str=pad+str;
-        }
-    } else {
-        while (str.length < len) {
-            str += pad;
-        }
-    }
-    return str;
-};
-
-String.prototype.toPaddedString = Number.prototype.toPaddedString;
\ No newline at end of file
+$(KronolithMobile.onDocumentReady);
\ No newline at end of file
index 261e41f..b151e96 100644 (file)
@@ -1,4 +1,5 @@
   <?php Horde::addInlineScript(Kronolith::includeJSVars());?>
+  <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'horde')?>/horde-jquery.js"></script>
   <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'horde') ?>/date/en-US.js"></script>
   <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'horde') ?>/date/date.js"></script>
   <script type="text/javascript" src="<?php echo $this->registry->get('jsuri', 'kronolith') ?>/mobile.js"></script>