summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/extended
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/extended')
-rw-r--r--framework/Web/Javascripts/extended/base.js43
-rw-r--r--framework/Web/Javascripts/extended/builder.js1
-rw-r--r--framework/Web/Javascripts/extended/dom.js7
-rw-r--r--framework/Web/Javascripts/extended/event.js64
-rw-r--r--framework/Web/Javascripts/extended/string.js13
-rw-r--r--framework/Web/Javascripts/extended/util.js91
6 files changed, 35 insertions, 184 deletions
diff --git a/framework/Web/Javascripts/extended/base.js b/framework/Web/Javascripts/extended/base.js
index 06a916d6..53856684 100644
--- a/framework/Web/Javascripts/extended/base.js
+++ b/framework/Web/Javascripts/extended/base.js
@@ -1,26 +1,29 @@
-/**
- * get element
- @ @param element or element id string
- @ returns element
+/**
+ * Similar to bindAsEventLister, but takes additional arguments.
*/
-function $(n,d) {
- if(isElement(n)) return n;
- if(isString(n)==false) return null;
- var p,i,x;
- if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
- d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
- if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
- for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=DOM.find(n,d.layers[i].document);
- if(!x && d.getElementById) x=d.getElementById(n); return x;
+Function.prototype.bindEvent = function()
+{
+ var __method = this, args = $A(arguments), object = args.shift();
+ return function(event)
+ {
+ return __method.apply(object, [event || window.event].concat(args));
+ }
}
/**
- * Similar to bindAsEventLister, but takes additional arguments.
+ * Creates a new function by copying function definition from
+ * the <tt>base</tt> and optional <tt>definition</tt>.
+ * @param function a base function to copy from.
+ * @param array additional definition
+ * @param function return a new function with definition from both
+ * <tt>base</tt> and <tt>definition</tt>.
*/
-Function.prototype.bindEvent = function() {
- var __method = this, args = $A(arguments), object = args.shift();
- return function(event) {
- return __method.apply(object, [event || window.event].concat(args));
- }
-}
+Class.extend = function(base, definition)
+{
+ var component = Class.create();
+ Object.extend(component.prototype, base.prototype);
+ if(definition)
+ Object.extend(component.prototype, definition);
+ return component;
+} \ No newline at end of file
diff --git a/framework/Web/Javascripts/extended/builder.js b/framework/Web/Javascripts/extended/builder.js
index 141eab51..c50fc6c6 100644
--- a/framework/Web/Javascripts/extended/builder.js
+++ b/framework/Web/Javascripts/extended/builder.js
@@ -1,3 +1,4 @@
+
Object.extend(Builder,
{
exportTags:function()
diff --git a/framework/Web/Javascripts/extended/dom.js b/framework/Web/Javascripts/extended/dom.js
deleted file mode 100644
index 21016b03..00000000
--- a/framework/Web/Javascripts/extended/dom.js
+++ /dev/null
@@ -1,7 +0,0 @@
-Object.extend(Element, {
- condClassName : function (element, className, cond)
- {
- (cond?Element.addClassName:Element.removeClassName)(element,className);
- }
-});
-
diff --git a/framework/Web/Javascripts/extended/event.js b/framework/Web/Javascripts/extended/event.js
index fc1c447b..40cf60a1 100644
--- a/framework/Web/Javascripts/extended/event.js
+++ b/framework/Web/Javascripts/extended/event.js
@@ -21,72 +21,10 @@ Object.extend(Event,
// opera onload is in document, not window
var w = document.addEventListener &&
!window.addEventListener ? document : window;
- Event.__observe(w,'load',fn);
+ Event.observe(w,'load',fn);
},
/**
- * Adds the specified event listener function to the set of
- * listeners registered on given element to handle events of the
- * specified type. If <tt>useCapture</tt> is <tt>true</tt>, the
- * listener is registered as a capturing event listener. If
- * <tt>useCapture</tt> is <tt>false</tt>, it is registered as a
- * normal event listener.
- *
- * <tt>Event.observe</tt> may be called multiple times to register
- * multiple event handlers for the same type of event on the
- * same nodes. Note, however, that the DOM makes no guarantees
- * about the order in which multiple event handlers will be invoked.
- *
- * Example: Show an alert box with message "Clicked!" when a link
- * with ID "link1" is clicked.
- * <code>
- * var link1_clicked = function()
- * {
- * alert("Clicked!");
- * };
- * Event.observe("link1", "click", link1_clicked);
- * </code>
- *
- * @param {Object} element id string, DOM Element, or an Array
- * of element ids or elements.
- * @param {String} The type of event for which the event listener
- * is to be invoked. For example, "load", "click", or "mousedown".
- * @param {Function} The event listener function that will be
- * invoked when an event of the specified type is dispatched to
- * this Document node.
- * @param {Boolean} If true, the specified listener is to be
- * invoked only during the capturing phase of event propagation.
- * The more common value of <tt>false</tt> means that the listener
- * will not be invoked during the capturing phase but instead will
- * be invoked when this node is the actual event target or when the
- * event bubbles up to this node from its original target.
- */
- observe: function(elements, name, observer, useCapture)
- {
- if(!isList(elements))
- return this.__observe(elements, name, observer, useCapture);
- for(var i=0; i<elements.length; i++)
- this.__observe(elements[i], name, observer, useCapture);
- },
-
- /**
- * Register event listeners.
- * @private
- */
- __observe: function(element, name, observer, useCapture)
- {
- var element = $(element);
- useCapture = useCapture || false;
-
- if (name == 'keypress' &&
- ((navigator.appVersion.indexOf('AppleWebKit') > 0)
- || element.attachEvent))
- name = 'keydown';
-
- this._observeAndCache(element, name, observer, useCapture);
- },
-
- /**
* @param {Event} a keyboard event
* @return {Number} the Unicode character code generated by the key
* that was struck.
diff --git a/framework/Web/Javascripts/extended/string.js b/framework/Web/Javascripts/extended/string.js
index 46274256..5cd1bd8e 100644
--- a/framework/Web/Javascripts/extended/string.js
+++ b/framework/Web/Javascripts/extended/string.js
@@ -79,13 +79,14 @@ Object.extend(String.prototype, {
if(command[new String(action)])
command=command[new String(action)];
});
- if(isFunction(command))
+ if(typeof(command) == "function")
return command;
else
{
if(typeof Logger != "undefined")
Logger.error("Missing function", this);
- return Prototype.emptyFunction;
+
+ throw new Error ("Missing function '"+this+"'");
}
},
@@ -110,11 +111,17 @@ Object.extend(String.prototype, {
*/
toDouble : function(decimalchar)
{
+ if(this.length <= 0) return null;
decimalchar = decimalchar || ".";
var exp = new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + decimalchar + "(\\d+))?\\s*$");
var m = this.match(exp);
+
if (m == null)
return null;
+ m[1] = m[1] || "";
+ m[2] = m[2] || "0";
+ m[4] = m[4] || "0";
+
var cleanInput = m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
@@ -161,4 +168,4 @@ Object.extend(String.prototype, {
{
return Date.SimpleParse(this, format);
}
-});
+}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/extended/util.js b/framework/Web/Javascripts/extended/util.js
deleted file mode 100644
index 86f2ae90..00000000
--- a/framework/Web/Javascripts/extended/util.js
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * @return {Boolean} true if is an object and has no constructors.
- */
-function isAlien(a) { return isObject(a) && typeof a.constructor != 'function' }
-
-/**
- * @return {Boolean}
- */
-function isArray(a) { return isObject(a) && a.constructor == Array }
-
-/**
- * isBoolean?
- */
-function isBoolean(a) { return typeof a == 'boolean' }
-
-/**
- * isFunction?
- */
-function isFunction(a) { return typeof a == 'function' }
-
-/**
- * isNull?
- */
-function isNull(a) { return typeof a == 'object' && !a }
-
-/**
- * isNumber?
- */
-function isNumber(a) { return typeof a == 'number' && isFinite(a) }
-
-/**
- * isObject?
- */
-function isObject(a) { return (a && typeof a == 'object') || isFunction(a) }
-
-/**
- * isRegexp?
- * we would prefer to use instanceof, but IE/mac is crippled and will choke at it
- */
-function isRegexp(a) { return a && a.constructor == RegExp }
-
-/**
- * isString?
- */
-function isString(a) { return typeof a == 'string' }
-
-/**
- * isUndefined?
- */
-function isUndefined(a) { return typeof a == 'undefined' }
-
-/**
- * isEmpty?
- */
-function isEmpty(o) {
- var i, v;
- if (isObject(o)) {
- for (i in o) {
- v = o[i];
- if (isUndefined(v) && isFunction(v)) {
- return false;
- }
- }
- }
- return true;
-}
-
-/**
- * alias for isUndefined
- */
-function undef(v) { return isUndefined(v) }
-
-/**
- * alias for !isUndefined
- */
-function isdef(v) { return !isUndefined(v) }
-
-/**
- * true if o is an Element Node or document or window. The last two because it's used for onload events
- if you specify strict as true, return false for document or window
- */
-function isElement(o, strict) {
- return o && isObject(o) && ((!strict && (o==window || o==document)) || o.nodeType == 1)
-}
-
-/**
- * true if o is an Array or a NodeList, (NodeList in Opera returns a type of function)
- */
-function isList(o) { return o && isObject(o) && isArray(o) }
-
-