summaryrefslogtreecommitdiffstats
path: root/usr/local/www/javascript/scriptaculous/builder.js
diff options
context:
space:
mode:
authorBill Marquette <billm@pfsense.org>2008-08-02 03:49:34 +0000
committerBill Marquette <billm@pfsense.org>2008-08-02 03:49:34 +0000
commitb5a7edb1ca42023606cde872cb8b5339d3b9837a (patch)
tree43a00507b7551f32e6aa805212be6efaf3a7fb70 /usr/local/www/javascript/scriptaculous/builder.js
parent0af7398aabc8d2ae09bc46c89067cfcddb706aab (diff)
downloadpfsense-b5a7edb1ca42023606cde872cb8b5339d3b9837a.zip
pfsense-b5a7edb1ca42023606cde872cb8b5339d3b9837a.tar.gz
update scriptaculous to version 1.8.1
Diffstat (limited to 'usr/local/www/javascript/scriptaculous/builder.js')
-rw-r--r--usr/local/www/javascript/scriptaculous/builder.js57
1 files changed, 46 insertions, 11 deletions
diff --git a/usr/local/www/javascript/scriptaculous/builder.js b/usr/local/www/javascript/scriptaculous/builder.js
index 5b15ba9..8301999 100644
--- a/usr/local/www/javascript/scriptaculous/builder.js
+++ b/usr/local/www/javascript/scriptaculous/builder.js
@@ -1,6 +1,9 @@
-// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
+// script.aculo.us builder.js v1.8.1, Thu Jan 03 22:07:12 -0500 2008
+
+// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
-// See scriptaculous.js for full license.
+// script.aculo.us is freely distributable under the terms of an MIT-style license.
+// For details, see the script.aculo.us web site: http://script.aculo.us/
var Builder = {
NODEMAP: {
@@ -33,7 +36,7 @@ var Builder = {
var element = parentElement.firstChild || null;
// see if browser added wrapping tags
- if(element && (element.tagName != elementName))
+ if(element && (element.tagName.toUpperCase() != elementName))
element = element.getElementsByTagName(elementName)[0];
// fallback to createElement approach
@@ -45,7 +48,8 @@ var Builder = {
// attributes (or text)
if(arguments[1])
if(this._isStringOrNumber(arguments[1]) ||
- (arguments[1] instanceof Array)) {
+ (arguments[1] instanceof Array) ||
+ arguments[1].tagName) {
this._children(element, arguments[1]);
} else {
var attrs = this._attributes(arguments[1]);
@@ -61,9 +65,9 @@ var Builder = {
for(attr in arguments[1])
element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
}
- if(element.tagName != elementName)
+ if(element.tagName.toUpperCase() != elementName)
element = parentElement.getElementsByTagName(elementName)[0];
- }
+ }
}
// text, or array of children
@@ -75,14 +79,24 @@ var Builder = {
_text: function(text) {
return document.createTextNode(text);
},
+
+ ATTR_MAP: {
+ 'className': 'class',
+ 'htmlFor': 'for'
+ },
+
_attributes: function(attributes) {
var attrs = [];
for(attribute in attributes)
- attrs.push((attribute=='className' ? 'class' : attribute) +
- '="' + attributes[attribute].toString().escapeHTML() + '"');
+ attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
+ '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"');
return attrs.join(" ");
},
_children: function(element, children) {
+ if(children.tagName) {
+ element.appendChild(children);
+ return;
+ }
if(typeof children=='object') { // array can hold nodes and text
children.flatten().each( function(e) {
if(typeof e=='object')
@@ -92,10 +106,31 @@ var Builder = {
element.appendChild(Builder._text(e));
});
} else
- if(Builder._isStringOrNumber(children))
- element.appendChild(Builder._text(children));
+ if(Builder._isStringOrNumber(children))
+ element.appendChild(Builder._text(children));
},
_isStringOrNumber: function(param) {
return(typeof param=='string' || typeof param=='number');
+ },
+ build: function(html) {
+ var element = this.node('div');
+ $(element).update(html.strip());
+ return element.down();
+ },
+ dump: function(scope) {
+ if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
+
+ var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
+ "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
+ "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
+
+ tags.each( function(tag){
+ scope[tag] = function() {
+ return Builder.node.apply(Builder, [tag].concat($A(arguments)));
+ }
+ });
}
-} \ No newline at end of file
+}
OpenPOWER on IntegriCloud