From b9b1105224ef72a45a384e51333b9cfe191be84e Mon Sep 17 00:00:00 2001
From: wei <>
Date: Mon, 26 Mar 2007 07:06:21 +0000
Subject: rearrange javascript library
---
framework/Web/Javascripts/js/debug/colorpicker.js | 119 +-
framework/Web/Javascripts/js/debug/prado.js | 1423 +++++++++------------
2 files changed, 679 insertions(+), 863 deletions(-)
(limited to 'framework/Web/Javascripts/js/debug')
diff --git a/framework/Web/Javascripts/js/debug/colorpicker.js b/framework/Web/Javascripts/js/debug/colorpicker.js
index b1b2aae4..914c2d75 100644
--- a/framework/Web/Javascripts/js/debug/colorpicker.js
+++ b/framework/Web/Javascripts/js/debug/colorpicker.js
@@ -96,7 +96,7 @@ Rico.Color.createFromHex = function(hexCode) {
if ( hexCode.indexOf('#') == 0 )
hexCode = hexCode.substring(1);
-
+
var red = "ff", green = "ff", blue="ff";
if(hexCode.length > 4)
{
@@ -240,13 +240,14 @@ Rico.Color.RGBtoHSB = function(r, g, b) {
return { h : hue, s : saturation, b : brightness };
}
-
-
+
+
+
Prado.WebUI.TColorPicker = Class.create();
Object.extend(Prado.WebUI.TColorPicker,
{
- palettes:
+ palettes:
{
Small : [["fff", "fcc", "fc9", "ff9", "ffc", "9f9", "9ff", "cff", "ccf", "fcf"],
["ccc", "f66", "f96", "ff6", "ff3", "6f9", "3ff", "6ff", "99f", "f9f"],
@@ -261,7 +262,7 @@ Object.extend(Prado.WebUI.TColorPicker,
["808080"/*gray*/, "ff0000"/*red*/, "800080"/*purple*/, "000000"/*black*/]]
},
- UIImages :
+ UIImages :
{
'button.gif' : 'button.gif',
// 'target_black.gif' : 'target_black.gif',
@@ -272,11 +273,11 @@ Object.extend(Prado.WebUI.TColorPicker,
}
});
-Object.extend(Prado.WebUI.TColorPicker.prototype,
+Object.extend(Prado.WebUI.TColorPicker.prototype,
{
initialize : function(options)
{
- var basics =
+ var basics =
{
Palette : 'Small',
ClassName : 'TColorPicker',
@@ -285,7 +286,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
CancelButtonText : 'Cancel',
ShowColorPicker : true
}
-
+
this.element = null;
this.showing = false;
@@ -301,10 +302,10 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
updatePicker : function(e)
{
- var color = Rico.Color.createFromHex(this.input.value);
+ var color = Rico.Color.createFromHex(this.input.value);
this.button.style.backgroundColor = color.toString();
},
-
+
buttonOnClick : function(event)
{
var mode = this.options['Mode'];
@@ -328,7 +329,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.initializeFullPicker();
}
this.show(mode);
- },
+ },
show : function(type)
{
@@ -340,14 +341,14 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.element.style.top = (pos[1]-1) + "px";
this.element.style.left = pos[0] + "px";
this.element.style.display = "block";
-
+
this.ieHack(type);
//observe for clicks on the document body
this._documentClickEvent = this.hideOnClick.bindEvent(this, type);
this._documentKeyDownEvent = this.keyPressed.bindEvent(this, type);
Event.observe(document.body, "click", this._documentClickEvent);
- Event.observe(document,"keydown", this._documentKeyDownEvent);
+ Event.observe(document,"keydown", this._documentKeyDownEvent);
this.showing = true;
if(type == "Full")
@@ -359,7 +360,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
}
}
},
-
+
hide : function(event)
{
if(this.showing)
@@ -370,11 +371,11 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.element.style.display = "none";
this.showing = false;
Event.stopObserving(document.body, "click", this._documentClickEvent);
- Event.stopObserving(document,"keydown", this._documentKeyDownEvent);
-
+ Event.stopObserving(document,"keydown", this._documentKeyDownEvent);
+
if(this._observingMouseMove)
- {
- Event.stopObserving(document.body, "mousemove", this._onMouseMove);
+ {
+ Event.stopObserving(document.body, "mousemove", this._onMouseMove);
this._observingMouseMove = false;
}
}
@@ -396,16 +397,16 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
within = within || el == this.button;
within = within || el == this.input;
if(within) break;
- el = el.parentNode;
+ el = el.parentNode;
}
while(el);
if(!within) this.hide(ev);
},
- ieHack : function()
+ ieHack : function()
{
// IE hack
- if(this.iePopUp)
+ if(this.iePopUp)
{
this.iePopUp.style.display = "block";
this.iePopUp.style.top = (this.element.offsetTop) + "px";
@@ -448,7 +449,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
cellOnClick : function(e)
{
- var el = Event.element(e);
+ var el = Event.element(e);
if(el.tagName.toLowerCase() != "img")
return;
var color = Rico.Color.createColorFromBackground(el);
@@ -464,15 +465,15 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
},
getFullPickerContainer : function(pickerID)
- {
+ {
//create the 3 buttons
- this.buttons =
+ this.buttons =
{
//Less : INPUT({value:'Less Colors', className:'button', type:'button'}),
OK : INPUT({value:this.options.OKButtonText, className:'button', type:'button'}),
Cancel : INPUT({value:this.options.CancelButtonText, className:'button', type:'button'})
};
-
+
//create the 6 inputs
var inputs = {};
['H','S','V','R','G','B'].each(function(type)
@@ -483,13 +484,13 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
//create the HEX input
inputs['HEX'] = INPUT({className:'hex',type:'text',size:'6',maxlength:'6'});
this.inputs = inputs;
-
+
var images = Prado.WebUI.TColorPicker.UIImages;
this.inputs['currentColor'] = SPAN({className:'currentColor'});
this.inputs['oldColor'] = SPAN({className:'oldColor'});
- var inputsTable =
+ var inputsTable =
TABLE({className:'inputs'}, TBODY(null,
TR(null,
TD({className:'currentcolor',colSpan:2},
@@ -502,30 +503,30 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
TR(null,
TD(null,'S:'),
TD(null,this.inputs['S'], '%')),
-
- TR(null,
+
+ TR(null,
TD(null,'V:'),
TD(null,this.inputs['V'], '%')),
-
- TR(null,
+
+ TR(null,
TD({className:'gap'},'R:'),
TD({className:'gap'},this.inputs['R'])),
-
- TR(null,
+
+ TR(null,
TD(null,'G:'),
TD(null, this.inputs['G'])),
- TR(null,
+ TR(null,
TD(null,'B:'),
TD(null, this.inputs['B'])),
- TR(null,
+ TR(null,
TD({className:'gap'},'#'),
TD({className:'gap'},this.inputs['HEX']))
));
- var UIimages =
- {
+ var UIimages =
+ {
selector : SPAN({className:'selector'}),
background : SPAN({className:'colorpanel'}),
slider : SPAN({className:'slider'}),
@@ -538,23 +539,23 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var filter = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader";
UIimages['background'] = SPAN({className:'colorpanel',style:filter+"(src='"+images['background.png']+"' sizingMethod=scale);"})
}
-
+
this.inputs = Object.extend(this.inputs, UIimages);
- var pickerTable =
+ var pickerTable =
TABLE(null,TBODY(null,
TR({className:'selection'},
TD({className:'colors'},UIimages['selector'],UIimages['background']),
TD({className:'hue'},UIimages['slider'],UIimages['hue']),
TD({className:'inputs'}, inputsTable)
),
- TR({className:'options'},
- TD({colSpan:3},
- this.buttons['OK'],
+ TR({className:'options'},
+ TD({colSpan:3},
+ this.buttons['OK'],
this.buttons['Cancel'])
)
));
-
+
return DIV({className:this.options['ClassName']+" FullColorPicker",
id:pickerID+"_picker"},pickerTable);
},
@@ -565,16 +566,16 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.inputs.oldColor.style.backgroundColor = color.asHex();
this.setColor(color,true);
- var i = 0;
+ var i = 0;
for(var type in this.inputs)
{
- Event.observe(this.inputs[type], "change",
+ Event.observe(this.inputs[type], "change",
this.onInputChanged.bindEvent(this,type));
i++;
if(i > 6) break;
}
-
+
this.isMouseDownOnColor = false;
this.isMouseDownOnHue = false;
@@ -587,9 +588,9 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
Event.observe(this.inputs.selector, "mousedown", this._onColorMouseDown);
Event.observe(this.inputs.hue, "mousedown", this._onHueMouseDown);
Event.observe(this.inputs.slider, "mousedown", this._onHueMouseDown);
-
+
Event.observe(document.body, "mouseup", this._onMouseUp);
-
+
this.observeMouseMovement();
Event.observe(this.buttons.Cancel, "click", this.hide.bindEvent(this,this.options['Mode']));
@@ -602,7 +603,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
{
Event.observe(document.body, "mousemove", this._onMouseMove);
this._observingMouseMove = true;
- }
+ }
},
onColorMouseDown : function(ev)
@@ -633,15 +634,15 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
if(this.isMouseDownOnHue)
this.changeH(ev);
Event.stop(ev);
- },
+ },
changeSV : function(ev)
{
var px = Event.pointerX(ev);
var py = Event.pointerY(ev);
var pos = Position.cumulativeOffset(this.inputs.background);
-
- var x = this.truncate(px - pos[0],0,255);
+
+ var x = this.truncate(px - pos[0],0,255);
var y = this.truncate(py - pos[1],0,255);
@@ -650,7 +651,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var current_s = parseInt(this.inputs.S.value);
var current_b = parseInt(this.inputs.V.value);
-
+
if(current_s == parseInt(s*100) && current_b == parseInt(b*100)) return;
var h = this.truncate(this.inputs.H.value,0,360)/360;
@@ -661,7 +662,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.inputs.selector.style.left = x+"px";
this.inputs.selector.style.top = y+"px";
-
+
this.inputs.currentColor.style.backgroundColor = color.asHex();
return this.setColor(color);
@@ -672,7 +673,7 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
var py = Event.pointerY(ev);
var pos = Position.cumulativeOffset(this.inputs.background);
var y = this.truncate(py - pos[1],0,255);
-
+
var h = (255-y)/255;
var current_h = this.truncate(this.inputs.H.value,0,360);
current_h = current_h == 0 ? 360 : current_h;
@@ -743,12 +744,12 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
this.inputs.G.value = color.rgb.g;
this.inputs.B.value = color.rgb.b;
this.inputs.HEX.value = color.asHex().substring(1).toUpperCase();
-
+
var images = Prado.WebUI.TColorPicker.UIImages;
var changeCss = color.isBright() ? 'removeClassName' : 'addClassName';
Element[changeCss](this.inputs.selector, 'target_white');
-
+
if(update)
this.updateSelectors(color);
},
@@ -757,11 +758,11 @@ Object.extend(Prado.WebUI.TColorPicker.prototype,
{
var hsb = color.asHSB();
var pos = [hsb.s*255, hsb.b*255, hsb.h*255];
-
+
this.inputs.selector.style.left = this.truncate(pos[0],0,255)+"px";
this.inputs.selector.style.top = this.truncate(255-pos[1],0,255)+"px";
this.inputs.slider.style.top = this.truncate(255-pos[2],0,255)+"px";
-
+
var hue = new Rico.Color(color.rgb.r,color.rgb.g,color.rgb.b);
hue.setSaturation(1); hue.setBrightness(1);
this.inputs.background.style.backgroundColor = hue.asHex();
diff --git a/framework/Web/Javascripts/js/debug/prado.js b/framework/Web/Javascripts/js/debug/prado.js
index b9ed0117..12d790e6 100644
--- a/framework/Web/Javascripts/js/debug/prado.js
+++ b/framework/Web/Javascripts/js/debug/prado.js
@@ -3349,6 +3349,63 @@ var Builder = {
+var Prado =
+{
+ Version: '3.0.0',
+
+ /**
+ * Returns browser information. Example
+ *
+ * var browser = Prado.Browser();
+ * alert(browser.ie); //should ouput true if IE, false otherwise
+ *
+ * @param ${parameter}
+ * @return ${return}
+ */
+ Browser : function()
+ {
+ var info = { Version : "1.0" };
+ var is_major = parseInt( navigator.appVersion );
+ info.nver = is_major;
+ info.ver = navigator.appVersion;
+ info.agent = navigator.userAgent;
+ info.dom = document.getElementById ? 1 : 0;
+ info.opera = window.opera ? 1 : 0;
+ info.ie5 = ( info.ver.indexOf( "MSIE 5" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
+ info.ie6 = ( info.ver.indexOf( "MSIE 6" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
+ info.ie4 = ( document.all && !info.dom && !info.opera ) ? 1 : 0;
+ info.ie = info.ie4 || info.ie5 || info.ie6;
+ info.mac = info.agent.indexOf( "Mac" ) > -1;
+ info.ns6 = ( info.dom && parseInt( info.ver ) >= 5 ) ? 1 : 0;
+ info.ie3 = ( info.ver.indexOf( "MSIE" ) && ( is_major < 4 ) );
+ info.hotjava = ( info.agent.toLowerCase().indexOf( 'hotjava' ) != -1 ) ? 1 : 0;
+ info.ns4 = ( document.layers && !info.dom && !info.hotjava ) ? 1 : 0;
+ info.bw = ( info.ie6 || info.ie5 || info.ie4 || info.ns4 || info.ns6 || info.opera );
+ info.ver3 = ( info.hotjava || info.ie3 );
+ info.opera7 = ( ( info.agent.toLowerCase().indexOf( 'opera 7' ) > -1 ) || ( info.agent.toLowerCase().indexOf( 'opera/7' ) > -1 ) );
+ info.operaOld = info.opera && !info.opera7;
+ return info;
+ },
+
+ ImportCss : function(doc, css_file)
+ {
+ if (Prado.Browser().ie)
+ var styleSheet = doc.createStyleSheet(css_file);
+ else
+ {
+ var elm = doc.createElement("link");
+
+ elm.rel = "stylesheet";
+ elm.href = css_file;
+
+ if (headArr = doc.getElementsByTagName("head"))
+ headArr[0].appendChild(elm);
+ }
+ }
+};
+
+
+
/**
* Similar to bindAsEventLister, but takes additional arguments.
*/
@@ -3484,140 +3541,379 @@ Base.implement = function(_interface) {
if (_interface instanceof Function) _interface = _interface.prototype;
this.prototype.extend(_interface);
};
-
-
+
/**
- * @class String extensions
+ * Performs a post-back using javascript
+ *
*/
-Object.extend(String.prototype, {
- /**
- * @param {String} "left" to pad the string on the left, "right" to pad right.
- * @param {Number} minimum string length.
- * @param {String} character(s) to pad
- * @return {String} padded character(s) on the left or right to satisfy minimum string length
- */
+Prado.PostBack = function(event,options)
+{
+ var form = $(options['FormID']);
+ var canSubmit = true;
- pad : function(side, len, chr) {
- if (!chr) chr = ' ';
- var s = this;
- var left = side.toLowerCase()=='left';
- while (s.length 0)
+ form.action = options['PostBackUrl'];
+
+ if(options['TrackFocus'])
+ {
+ var lastFocus = $('PRADO_LASTFOCUS');
+ if(lastFocus)
+ {
+ var active = document.activeElement; //where did this come from
+ if(active)
+ lastFocus.value = active.id;
+ else
+ lastFocus.value = options['EventTarget'];
+ }
+ }
+ $('PRADO_POSTBACK_TARGET').value = options['EventTarget'];
+ $('PRADO_POSTBACK_PARAMETER').value = options['EventParameter'];
/**
- * @param {Number} minimum string length.
- * @param {String} character(s) to pad
- * @return {String} padded character(s) on the left to satisfy minimum string length
+ * Since google toolbar prevents browser default action,
+ * we will always disable default client-side browser action
*/
- padLeft : function(len, chr) {
- return this.pad('left',len,chr);
- },
+ /*if(options['StopEvent']) */
+ Event.stop(event);
+ Event.fireEvent(form,"submit");
+}
+/**
+ * Additional element utilities.
+ */
+Prado.Element =
+{
/**
- * @param {Number} minimum string length.
- * @param {String} character(s) to pad
- * @return {String} padded character(s) on the right to satisfy minimum string length
+ * Set the value of a particular element.
+ * @param string element id
+ * @param string new element value.
*/
- padRight : function(len, chr) {
- return this.pad('right',len,chr);
+ setValue : function(element, value)
+ {
+ var el = $(element);
+ if(el && typeof(el.value) != "undefined")
+ el.value = value;
},
- /**
- * @param {Number} minimum string length.
- * @return {String} append zeros to the left to satisfy minimum string length.
- */
- zerofill : function(len) {
- return this.padLeft(len,'0');
+ select : function(element, method, value)
+ {
+ var el = $(element);
+ var isList = element.indexOf('[]') > -1;
+ if(!el && !isList) return;
+ method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
+ var selection = Prado.Element.Selection;
+ if(isFunction(selection[method]))
+ selection[method](isList ? element : el,value);
},
- /**
- * @return {String} removed white spaces from both ends.
- */
- trim : function() {
- return this.replace(/^\s+|\s+$/g,'');
+ click : function(element)
+ {
+ var el = $(element);
+ if(el)
+ Event.fireEvent(el,'click');
},
- /**
- * @return {String} removed white spaces from the left end.
- */
- trimLeft : function() {
- return this.replace(/^\s+/,'');
+ setAttribute : function(element, attribute, value)
+ {
+ var el = $(element);
+ if(attribute == "disabled" && value==false)
+ el.removeAttribute(attribute);
+ else
+ el.setAttribute(attribute, value);
},
- /**
- * @return {String} removed white spaces from the right end.
- */
- trimRight : function() {
- return this.replace(/\s+$/,'');
+ setOptions : function(element, options)
+ {
+ var el = $(element);
+ if(el && el.tagName.toLowerCase() == "select")
+ {
+ while(el.length > 0)
+ el.remove(0);
+ for(var i = 0; iInternationalization
- * is not supported
- * @param {String} the decimal character
- * @return {Double} null if string does not represent a float value
- */
- toDouble : function(decimalchar)
+ selectAll : function(el)
{
- 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);
+ $A(el.options).each(function(option)
+ {
+ option.selected = true;
+ Logger.warn(option.value);
+ });
},
- /**
- * Convert strings that represent a currency value (e.g. a float with grouping
- * characters) to float. E.g. "10,000.50" will become "10000.50". The number
+ selectInvert : function(el)
+ {
+ $A(el.options).each(function(option)
+ {
+ option.selected = !option.selected;
+ });
+ },
+
+ checkValue : function(name, value)
+ {
+ $A(document.getElementsByName(name)).each(function(el)
+ {
+ el.checked = el.value == value
+ });
+ },
+
+ checkIndex : function(name, index)
+ {
+ var elements = $A(document.getElementsByName(name));
+ for(var i = 0; i1)
+ return Builder.node(tag,args.shift(),args);
+
+ };
+ });
+ }
+});
+
+Builder.exportTags();
+
+/**
+ * @class String extensions
+ */
+Object.extend(String.prototype, {
+ /**
+ * @param {String} "left" to pad the string on the left, "right" to pad right.
+ * @param {Number} minimum string length.
+ * @param {String} character(s) to pad
+ * @return {String} padded character(s) on the left or right to satisfy minimum string length
+ */
+
+ pad : function(side, len, chr) {
+ if (!chr) chr = ' ';
+ var s = this;
+ var left = side.toLowerCase()=='left';
+ while (s.lengthInternationalization
+ * is not supported
+ * @param {String} the decimal character
+ * @return {Double} null if string does not represent a float value
+ */
+ 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);
+ },
+
+ /**
+ * Convert strings that represent a currency value (e.g. a float with grouping
+ * characters) to float. E.g. "10,000.50" will become "10000.50". The number
* of dicimal digits, grouping and decimal characters can be specified.
* The currency input format is very strict, null will be returned if
* the pattern does not match.
@@ -3640,14 +3936,14 @@ Object.extend(String.prototype, {
return null;
var intermed = m[2] + m[5] ;
var cleanInput = m[1] + intermed.replace(
- new RegExp("(\\" + groupchar + ")", "g"), "")
+ new RegExp("(\\" + groupchar + ")", "g"), "")
+ ((digits > 0) ? "." + m[7] : "");
var num = parseFloat(cleanInput);
return (isNaN(num) ? null : num);
},
/**
- * Converts the string to a date by finding values that matches the
+ * Converts the string to a date by finding values that matches the
* date format pattern.
* @param string date format pattern, e.g. MM-dd-yyyy
* @return {Date} the date extracted from the string
@@ -3656,19 +3952,19 @@ Object.extend(String.prototype, {
{
return Date.SimpleParse(this, format);
}
-});
-
+});
+
/**
* @class Event extensions.
*/
-Object.extend(Event,
+Object.extend(Event,
{
/**
- * Register a function to be executed when the page is loaded.
- * Note that the page is only loaded if all resources (e.g. images)
+ * Register a function to be executed when the page is loaded.
+ * Note that the page is only loaded if all resources (e.g. images)
* are loaded.
- *
- * Example: Show an alert box with message "Page Loaded!" when the
+ *
+ * Example: Show an alert box with message "Page Loaded!" when the
* page finished loading.
*
* Event.OnLoad(function(){ alert("Page Loaded!"); });
@@ -3676,18 +3972,18 @@ Object.extend(Event,
*
* @param {Function} function to execute when page is loaded.
*/
- OnLoad : function (fn)
+ OnLoad : function (fn)
{
// opera onload is in document, not window
- var w = document.addEventListener &&
+ var w = document.addEventListener &&
!window.addEventListener ? document : window;
Event.observe(w,'load',fn);
},
/**
* @param {Event} a keyboard event
- * @return {Number} the Unicode character code generated by the key
- * that was struck.
+ * @return {Number} the Unicode character code generated by the key
+ * that was struck.
*/
keyCode : function(e)
{
@@ -3696,33 +3992,33 @@ Object.extend(Event,
/**
* @param {String} event type or event name.
- * @return {Boolean} true if event type is of HTMLEvent, false
+ * @return {Boolean} true if event type is of HTMLEvent, false
* otherwise
*/
isHTMLEvent : function(type)
{
- var events = ['abort', 'blur', 'change', 'error', 'focus',
- 'load', 'reset', 'resize', 'scroll', 'select',
+ var events = ['abort', 'blur', 'change', 'error', 'focus',
+ 'load', 'reset', 'resize', 'scroll', 'select',
'submit', 'unload'];
return events.include(type);
},
/**
* @param {String} event type or event name
- * @return {Boolean} true if event type is of MouseEvent,
+ * @return {Boolean} true if event type is of MouseEvent,
* false otherwise
*/
isMouseEvent : function(type)
{
- var events = ['click', 'mousedown', 'mousemove', 'mouseout',
+ var events = ['click', 'mousedown', 'mousemove', 'mouseout',
'mouseover', 'mouseup'];
return events.include(type);
},
/**
- * Dispatch the DOM event of a given type on a DOM
- * element. Only HTMLEvent and MouseEvent can be
- * dispatched, keyboard events or UIEvent can not be dispatch
+ * Dispatch the DOM event of a given type on a DOM
+ * element. Only HTMLEvent and MouseEvent can be
+ * dispatched, keyboard events or UIEvent can not be dispatch
* via javascript consistently.
* For the "submit" event the submit() method is called.
* @param {Object} element id string or a DOM element.
@@ -3734,7 +4030,7 @@ Object.extend(Event,
if(type == "submit")
return element.submit();
if(document.createEvent)
- {
+ {
if(Event.isHTMLEvent(type))
{
var event = document.createEvent('HTMLEvents');
@@ -3742,11 +4038,11 @@ Object.extend(Event,
}
else if(Event.isMouseEvent(type))
{
- var event = document.createEvent('MouseEvents');
+ var event = document.createEvent('MouseEvents');
if (event.initMouseEvent)
{
event.initMouseEvent(type,true,true,
- document.defaultView, 1, 0, 0, 0, 0, false,
+ document.defaultView, 1, 0, 0, 0, 0, false,
false, false, false, 0, null);
}
else
@@ -3766,663 +4062,177 @@ Object.extend(Event,
else if(typeof(element['on'+type]) == "function")
element['on'+type]();
}
-});
-
+});
+
+
Object.extend(Date.prototype,
-{
+{
SimpleFormat: function(format, data)
{
data = data || {};
var bits = new Array();
bits['d'] = this.getDate();
bits['dd'] = String(this.getDate()).zerofill(2);
-
+
bits['M'] = this.getMonth()+1;
bits['MM'] = String(this.getMonth()+1).zerofill(2);
if(data.AbbreviatedMonthNames)
bits['MMM'] = data.AbbreviatedMonthNames[this.getMonth()];
- if(data.MonthNames)
- bits['MMMM'] = data.MonthNames[this.getMonth()];
- var yearStr = "" + this.getFullYear();
- yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
- bits['yyyy'] = yearStr;
- bits['yy'] = bits['yyyy'].toString().substr(2,2);
-
- // do some funky regexs to replace the format string
- // with the real values
- var frm = new String(format);
- for (var sect in bits)
- {
- var reg = new RegExp("\\b"+sect+"\\b" ,"g");
- frm = frm.replace(reg, bits[sect]);
- }
- return frm;
- },
-
- toISODate : function()
- {
- var y = this.getFullYear();
- var m = String(this.getMonth() + 1).zerofill(2);
- var d = String(this.getDate()).zerofill(2);
- return String(y) + String(m) + String(d);
- }
-});
-
-Object.extend(Date,
-{
- SimpleParse: function(value, format)
- {
- val=String(value);
- format=String(format);
-
- if(val.length <= 0) return null;
-
- if(format.length <= 0) return new Date(value);
-
- var isInteger = function (val)
- {
- var digits="1234567890";
- for (var i=0; i < val.length; i++)
- {
- if (digits.indexOf(val.charAt(i))==-1) { return false; }
- }
- return true;
- };
-
- var getInt = function(str,i,minlength,maxlength)
- {
- for (var x=maxlength; x>=minlength; x--)
- {
- var token=str.substring(i,i+x);
- if (token.length < minlength) { return null; }
- if (isInteger(token)) { return token; }
- }
- return null;
- };
-
- var i_val=0;
- var i_format=0;
- var c="";
- var token="";
- var token2="";
- var x,y;
- var now=new Date();
- var year=now.getFullYear();
- var month=now.getMonth()+1;
- var date=1;
-
- while (i_format < format.length)
- {
- // Get next token from format string
- c=format.charAt(i_format);
- token="";
- while ((format.charAt(i_format)==c) && (i_format < format.length))
- {
- token += format.charAt(i_format++);
- }
-
- // Extract contents of value based on format token
- if (token=="yyyy" || token=="yy" || token=="y")
- {
- if (token=="yyyy") { x=4;y=4; }
- if (token=="yy") { x=2;y=2; }
- if (token=="y") { x=2;y=4; }
- year=getInt(val,i_val,x,y);
- if (year==null) { return null; }
- i_val += year.length;
- if (year.length==2)
- {
- if (year > 70) { year=1900+(year-0); }
- else { year=2000+(year-0); }
- }
- }
-
- else if (token=="MM"||token=="M")
- {
- month=getInt(val,i_val,token.length,2);
- if(month==null||(month<1)||(month>12)){return null;}
- i_val+=month.length;
- }
- else if (token=="dd"||token=="d")
- {
- date=getInt(val,i_val,token.length,2);
- if(date==null||(date<1)||(date>31)){return null;}
- i_val+=date.length;
- }
- else
- {
- if (val.substring(i_val,i_val+token.length)!=token) {return null;}
- else {i_val+=token.length;}
- }
- }
-
- // If there are any trailing characters left in the value, it doesn't match
- if (i_val != val.length) { return null; }
-
- // Is date valid for month?
- if (month==2)
- {
- // Check for leap year
- if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
- if (date > 29){ return null; }
- }
- else { if (date > 28) { return null; } }
- }
-
- if ((month==4)||(month==6)||(month==9)||(month==11))
- {
- if (date > 30) { return null; }
- }
-
- var newdate=new Date(year,month-1,date, 0, 0, 0);
- return newdate;
- }
-});
-
-
-Object.extend(Builder,
-{
- exportTags:function()
- {
- var tags=["BUTTON","TT","PRE","H1","H2","H3","BR","CANVAS","HR","LABEL","TEXTAREA","FORM","STRONG","SELECT","OPTION","OPTGROUP","LEGEND","FIELDSET","P","UL","OL","LI","TD","TR","THEAD","TBODY","TFOOT","TABLE","TH","INPUT","SPAN","A","DIV","IMG", "CAPTION"];
- tags.each(function(tag)
- {
- window[tag]=function()
- {
- var args=$A(arguments);
- if(args.length==0)
- return Builder.node(tag,null);
- if(args.length==1)
- return Builder.node(tag,args[0]);
- if(args.length>1)
- return Builder.node(tag,args.shift(),args);
-
- };
- });
- }
-});
-
-Builder.exportTags();
-
-
-
-var Prado =
-{
- Version: '3.0.0',
-
- /**
- * Returns browser information. Example
- *
- * var browser = Prado.Browser();
- * alert(browser.ie); //should ouput true if IE, false otherwise
- *
- * @param ${parameter}
- * @return ${return}
- */
- Browser : function()
- {
- var info = { Version : "1.0" };
- var is_major = parseInt( navigator.appVersion );
- info.nver = is_major;
- info.ver = navigator.appVersion;
- info.agent = navigator.userAgent;
- info.dom = document.getElementById ? 1 : 0;
- info.opera = window.opera ? 1 : 0;
- info.ie5 = ( info.ver.indexOf( "MSIE 5" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
- info.ie6 = ( info.ver.indexOf( "MSIE 6" ) > -1 && info.dom && !info.opera ) ? 1 : 0;
- info.ie4 = ( document.all && !info.dom && !info.opera ) ? 1 : 0;
- info.ie = info.ie4 || info.ie5 || info.ie6;
- info.mac = info.agent.indexOf( "Mac" ) > -1;
- info.ns6 = ( info.dom && parseInt( info.ver ) >= 5 ) ? 1 : 0;
- info.ie3 = ( info.ver.indexOf( "MSIE" ) && ( is_major < 4 ) );
- info.hotjava = ( info.agent.toLowerCase().indexOf( 'hotjava' ) != -1 ) ? 1 : 0;
- info.ns4 = ( document.layers && !info.dom && !info.hotjava ) ? 1 : 0;
- info.bw = ( info.ie6 || info.ie5 || info.ie4 || info.ns4 || info.ns6 || info.opera );
- info.ver3 = ( info.hotjava || info.ie3 );
- info.opera7 = ( ( info.agent.toLowerCase().indexOf( 'opera 7' ) > -1 ) || ( info.agent.toLowerCase().indexOf( 'opera/7' ) > -1 ) );
- info.operaOld = info.opera && !info.opera7;
- return info;
- },
-
- ImportCss : function(doc, css_file)
- {
- if (Prado.Browser().ie)
- var styleSheet = doc.createStyleSheet(css_file);
- else
- {
- var elm = doc.createElement("link");
-
- elm.rel = "stylesheet";
- elm.href = css_file;
-
- if (headArr = doc.getElementsByTagName("head"))
- headArr[0].appendChild(elm);
- }
- }
-};
-
-
-/*Prado.Focus = Class.create();
-
-Prado.Focus.setFocus = function(id)
-{
- var target = document.getElementById ? document.getElementById(id) : document.all[id];
- if(target && !Prado.Focus.canFocusOn(target))
- {
- target = Prado.Focus.findTarget(target);
- }
- if(target)
- {
- try
- {
- target.focus();
- target.scrollIntoView(false);
- if (window.__smartNav)
- {
- window.__smartNav.ae = target.id;
- }
- }
- catch (e)
- {
- }
- }
-}
-
-Prado.Focus.canFocusOn = function(element)
-{
- if(!element || !(element.tagName))
- return false;
- var tagName = element.tagName.toLowerCase();
- return !element.disabled && (!element.type || element.type.toLowerCase() != "hidden") && Prado.Focus.isFocusableTag(tagName) && Prado.Focus.isVisible(element);
-}
-
-Prado.Focus.isFocusableTag = function(tagName)
-{
- return (tagName == "input" || tagName == "textarea" || tagName == "select" || tagName == "button" || tagName == "a");
-}
-
-
-Prado.Focus.findTarget = function(element)
-{
- if(!element || !(element.tagName))
- {
- return null;
- }
- var tagName = element.tagName.toLowerCase();
- if (tagName == "undefined")
- {
- return null;
- }
- var children = element.childNodes;
- if (children)
- {
- for(var i=0;i 0)
- form.action = options['PostBackUrl'];
-
- if(options['TrackFocus'])
- {
- var lastFocus = $('PRADO_LASTFOCUS');
- if(lastFocus)
- {
- var active = document.activeElement; //where did this come from
- if(active)
- lastFocus.value = active.id;
- else
- lastFocus.value = options['EventTarget'];
- }
- }
-
- $('PRADO_POSTBACK_TARGET').value = options['EventTarget'];
- $('PRADO_POSTBACK_PARAMETER').value = options['EventParameter'];
- /**
- * Since google toolbar prevents browser default action,
- * we will always disable default client-side browser action
- */
- /*if(options['StopEvent']) */
- Event.stop(event);
- Event.fireEvent(form,"submit");
-}
-
-/*
-
-Prado.doPostBack = function(formID, eventTarget, eventParameter, performValidation, validationGroup, actionUrl, trackFocus, clientSubmit)
-{
- if (typeof(performValidation) == 'undefined')
- {
- var performValidation = false;
- var validationGroup = '';
- var actionUrl = null;
- var trackFocus = false;
- var clientSubmit = true;
- }
- var theForm = document.getElementById ? document.getElementById(formID) : document.forms[formID];
- var canSubmit = true;
- if (performValidation)
- {
- //canSubmit = Prado.Validation.validate(validationGroup);
- * Prado.Validation.ActiveTarget = theForm;
- Prado.Validation.CurrentTargetGroup = null;
- Prado.Validation.IsGroupValidation = false;
- canSubmit = Prado.Validation.IsValid(theForm);
- Logger.debug(canSubmit);*
- canSubmit = Prado.Validation.IsValid(theForm);
- }
- if (canSubmit)
- {
- if (actionUrl != null && (actionUrl.length > 0))
- {
- theForm.action = actionUrl;
- }
- if (trackFocus)
- {
- var lastFocus = theForm.elements['PRADO_LASTFOCUS'];
- if ((typeof(lastFocus) != 'undefined') && (lastFocus != null))
- {
- var active = document.activeElement;
- if (typeof(active) == 'undefined')
- {
- lastFocus.value = eventTarget;
- }
- else
- {
- if ((active != null) && (typeof(active.id) != 'undefined'))
- {
- if (active.id.length > 0)
- {
- lastFocus.value = active.id;
- }
- else if (typeof(active.name) != 'undefined')
- {
- lastFocus.value = active.name;
- }
- }
- }
- }
- }
- if (!clientSubmit)
- {
- canSubmit = false;
- }
- }
- if (canSubmit && (!theForm.onsubmit || theForm.onsubmit()))
- {
- theForm.PRADO_POSTBACK_TARGET.value = eventTarget;
- theForm.PRADO_POSTBACK_PARAMETER.value = eventParameter;
- theForm.submit();
- }
-}
-*/
-
-Prado.Element =
-{
- /**
- * Set the value of a particular element.
- * @param string element id
- * @param string new element value.
- */
- setValue : function(element, value)
- {
- var el = $(element);
- if(el && typeof(el.value) != "undefined")
- el.value = value;
- },
-
- select : function(element, method, value)
- {
- var el = $(element);
- var isList = element.indexOf('[]') > -1;
- if(!el && !isList) return;
- method = isList ? 'check'+method : el.tagName.toLowerCase()+method;
- var selection = Prado.Element.Selection;
- if(isFunction(selection[method]))
- selection[method](isList ? element : el,value);
- },
-
- click : function(element)
- {
- var el = $(element);
- if(el)
- Event.fireEvent(el,'click');
- },
-
- setAttribute : function(element, attribute, value)
- {
- var el = $(element);
- if(attribute == "disabled" && value==false)
- el.removeAttribute(attribute);
- else
- el.setAttribute(attribute, value);
- },
+ if(data.MonthNames)
+ bits['MMMM'] = data.MonthNames[this.getMonth()];
+ var yearStr = "" + this.getFullYear();
+ yearStr = (yearStr.length == 2) ? '19' + yearStr: yearStr;
+ bits['yyyy'] = yearStr;
+ bits['yy'] = bits['yyyy'].toString().substr(2,2);
- setOptions : function(element, options)
- {
- var el = $(element);
- if(el && el.tagName.toLowerCase() == "select")
+ // do some funky regexs to replace the format string
+ // with the real values
+ var frm = new String(format);
+ for (var sect in bits)
{
- while(el.length > 0)
- el.remove(0);
- for(var i = 0; i=minlength; x--)
+ {
+ var token=str.substring(i,i+x);
+ if (token.length < minlength) { return null; }
+ if (isInteger(token)) { return token; }
+ }
+ return null;
+ };
- selectInvert : function(el)
- {
- $A(el.options).each(function(option)
- {
- option.selected = !option.selected;
- });
- },
+ var i_val=0;
+ var i_format=0;
+ var c="";
+ var token="";
+ var token2="";
+ var x,y;
+ var now=new Date();
+ var year=now.getFullYear();
+ var month=now.getMonth()+1;
+ var date=1;
- checkValue : function(name, value)
- {
- $A(document.getElementsByName(name)).each(function(el)
+ while (i_format < format.length)
{
- el.checked = el.value == value
- });
- },
+ // Get next token from format string
+ c=format.charAt(i_format);
+ token="";
+ while ((format.charAt(i_format)==c) && (i_format < format.length))
+ {
+ token += format.charAt(i_format++);
+ }
- checkIndex : function(name, index)
- {
- var elements = $A(document.getElementsByName(name));
- for(var i = 0; i 70) { year=1900+(year-0); }
+ else { year=2000+(year-0); }
+ }
+ }
+
+ else if (token=="MM"||token=="M")
+ {
+ month=getInt(val,i_val,token.length,2);
+ if(month==null||(month<1)||(month>12)){return null;}
+ i_val+=month.length;
+ }
+ else if (token=="dd"||token=="d")
+ {
+ date=getInt(val,i_val,token.length,2);
+ if(date==null||(date<1)||(date>31)){return null;}
+ i_val+=date.length;
+ }
+ else
+ {
+ if (val.substring(i_val,i_val+token.length)!=token) {return null;}
+ else {i_val+=token.length;}
+ }
}
- },
- checkClear : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = false;
- });
- },
+ // If there are any trailing characters left in the value, it doesn't match
+ if (i_val != val.length) { return null; }
- checkAll : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
- {
- el.checked = true;
- });
- },
- checkInvert : function(name)
- {
- $A(document.getElementsByName(name)).each(function(el)
+ // Is date valid for month?
+ if (month==2)
{
- el.checked = !el.checked;
- });
- }
-};
-
-Prado.WebUI = Class.create();
-
-//base postback-able controls
-/*Prado.WebUI.PostBackControl = Class.create();
-Prado.WebUI.PostBackControl.prototype =
-{
- initialize : function(options)
- {
- this.element = $(options['ID']);
+ // Check for leap year
+ if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
+ if (date > 29){ return null; }
+ }
+ else { if (date > 28) { return null; } }
+ }
-/* if(options.CausesValidation && typeof(Prado.Validation) != 'undefined')
+ if ((month==4)||(month==6)||(month==9)||(month==11))
{
- Prado.Validation.registerTarget(options);
+ if (date > 30) { return null; }
}
- //TODO: what do the following options do?
- //options['PostBackUrl']
- //options['ClientSubmit']
-
- if(this.onInit)
- this.onInit(options);
+ var newdate=new Date(year,month-1,date, 0, 0, 0);
+ return newdate;
}
-};
-
-//short cut to create postback components
-Prado.WebUI.createPostBackComponent = function(definition)
-{
- var component = Class.create();
- Object.extend(component.prototype, Prado.WebUI.PostBackControl.prototype);
- if(definition) Object.extend(component.prototype, definition);
- return component;
-}
+});
+
+Prado.WebUI = Class.create();
-Prado.WebUI.TButton = Prado.WebUI.createPostBackComponent();
-*/
Prado.WebUI.PostBackControl = Class.create();
Prado.WebUI.PostBackControl.prototype =
{
- _elementOnClick : null, //capture the element's onclick function
-
initialize : function(options)
{
+ this._elementOnClick = null, //capture the element's onclick function
+
this.element = $(options.ID);
- if(this.onInit)
- this.onInit(options);
+ if(this.element)
+ {
+ if(this.onInit)
+ this.onInit(options);
+ }
},
onInit : function(options)
@@ -4432,10 +4242,10 @@ Prado.WebUI.PostBackControl.prototype =
this._elementOnClick = this.element.onclick;
this.element.onclick = null;
}
- Event.observe(this.element, "click", this.onClick.bindEvent(this,options));
+ Event.observe(this.element, "click", this.elementClicked.bindEvent(this,options));
},
- onClick : function(event, options)
+ elementClicked : function(event, options)
{
var src = Event.element(event);
var doPostBack = true;
@@ -4493,15 +4303,33 @@ Object.extend(Prado.WebUI.TImageButton.prototype,
*/
addXYInput : function(event,options)
{
- var imagePos = Position.cumulativeOffset(this.element);
- var clickedPos = [event.clientX, event.clientY];
- var x = clickedPos[0]-imagePos[0]+1;
- var y = clickedPos[1]-imagePos[1]+1;
- var id = options['EventTarget'];
- var x_input = INPUT({type:'hidden',name:id+'_x',value:x});
- var y_input = INPUT({type:'hidden',name:id+'_y',value:y});
- this.element.parentNode.appendChild(x_input);
- this.element.parentNode.appendChild(y_input);
+ imagePos = Position.cumulativeOffset(this.element);
+ clickedPos = [event.clientX, event.clientY];
+ x = clickedPos[0]-imagePos[0]+1;
+ y = clickedPos[1]-imagePos[1]+1;
+ x = x < 0 ? 0 : x;
+ y = y < 0 ? 0 : y;
+ id = options['EventTarget'];
+ x_input = $(id+"_x");
+ y_input = $(id+"_y");
+ if(x_input)
+ {
+ x_input.value = x;
+ }
+ else
+ {
+ x_input = INPUT({type:'hidden',name:id+'_x','id':id+'_x',value:x});
+ this.element.parentNode.appendChild(x_input);
+ }
+ if(y_input)
+ {
+ y_input.value = y;
+ }
+ else
+ {
+ y_input = INPUT({type:'hidden',name:id+'_y','id':id+'_y',value:y});
+ this.element.parentNode.appendChild(y_input);
+ }
}
});
@@ -4516,8 +4344,11 @@ Object.extend(Prado.WebUI.TRadioButton.prototype,
initialize : function(options)
{
this.element = $(options['ID']);
- if(!this.element.checked)
- this.onRadioButtonInitialize(options);
+ if(this.element)
+ {
+ if(!this.element.checked)
+ this.onRadioButtonInitialize(options);
+ }
}
});
@@ -4526,9 +4357,11 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl,
{
onInit : function(options)
{
+ this.options=options;
if(options['TextMode'] != 'MultiLine')
Event.observe(this.element, "keydown", this.handleReturnKey.bind(this));
- Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
+ if(this.options['AutoPostBack']==true)
+ Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options));
},
handleReturnKey : function(e)
@@ -4538,8 +4371,19 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl,
var target = Event.element(e);
if(target)
{
- Event.fireEvent(target, "change");
- Event.stop(e);
+ if(this.options['AutoPostBack']==true)
+ {
+ Event.fireEvent(target, "change");
+ Event.stop(e);
+ }
+ else
+ {
+ if(this.options['CausesValidation'] && typeof(Prado.Validation) != "undefined")
+ {
+ if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], $(this.options['ID'])))
+ return Event.stop(e);
+ }
+ }
}
}
}
@@ -4630,66 +4474,37 @@ Object.extend(Prado.WebUI.TTextHighlighter,
obj.parentNode.className = "copycode";
}
});
-
-
-Prado.WebUI.TRatingList = Class.create();
-Prado.WebUI.TRatingList.prototype =
-{
- selectedIndex : -1,
- initialize : function(options)
+
+Prado.WebUI.TCheckBoxList = Base.extend(
+{
+ constructor : function(options)
{
- this.options = options;
- this.element = $(options['ID']);
- Element.addClassName(this.element,options.cssClass);
- this.radios = document.getElementsByName(options.field);
- for(var i = 0; i -1 ?
- this.radios[index].value : this.options.caption;
+ for(var i = 0; i