-
+ 7FC93034CC58ED0DDC89DB40188EE4E8BAFAC7494555A36B3BF3BD352ECF98BBC156E6BB24897AF05FA5E481C6B4981257764DDE2A4AB49A1E1566A3293E7D82
mp-wp/wp-includes/js/scriptaculous/builder.js
(0 . 0)(1 . 136)
107672 // script.aculo.us builder.js v1.8.0, Tue Nov 06 15:01:40 +0300 2007
107673
107674 // Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
107675 //
107676 // script.aculo.us is freely distributable under the terms of an MIT-style license.
107677 // For details, see the script.aculo.us web site: http://script.aculo.us/
107678
107679 var Builder = {
107680 NODEMAP: {
107681 AREA: 'map',
107682 CAPTION: 'table',
107683 COL: 'table',
107684 COLGROUP: 'table',
107685 LEGEND: 'fieldset',
107686 OPTGROUP: 'select',
107687 OPTION: 'select',
107688 PARAM: 'object',
107689 TBODY: 'table',
107690 TD: 'table',
107691 TFOOT: 'table',
107692 TH: 'table',
107693 THEAD: 'table',
107694 TR: 'table'
107695 },
107696 // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken,
107697 // due to a Firefox bug
107698 node: function(elementName) {
107699 elementName = elementName.toUpperCase();
107700
107701 // try innerHTML approach
107702 var parentTag = this.NODEMAP[elementName] || 'div';
107703 var parentElement = document.createElement(parentTag);
107704 try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
107705 parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";
107706 } catch(e) {}
107707 var element = parentElement.firstChild || null;
107708
107709 // see if browser added wrapping tags
107710 if(element && (element.tagName.toUpperCase() != elementName))
107711 element = element.getElementsByTagName(elementName)[0];
107712
107713 // fallback to createElement approach
107714 if(!element) element = document.createElement(elementName);
107715
107716 // abort if nothing could be created
107717 if(!element) return;
107718
107719 // attributes (or text)
107720 if(arguments[1])
107721 if(this._isStringOrNumber(arguments[1]) ||
107722 (arguments[1] instanceof Array) ||
107723 arguments[1].tagName) {
107724 this._children(element, arguments[1]);
107725 } else {
107726 var attrs = this._attributes(arguments[1]);
107727 if(attrs.length) {
107728 try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707
107729 parentElement.innerHTML = "<" +elementName + " " +
107730 attrs + "></" + elementName + ">";
107731 } catch(e) {}
107732 element = parentElement.firstChild || null;
107733 // workaround firefox 1.0.X bug
107734 if(!element) {
107735 element = document.createElement(elementName);
107736 for(attr in arguments[1])
107737 element[attr == 'class' ? 'className' : attr] = arguments[1][attr];
107738 }
107739 if(element.tagName.toUpperCase() != elementName)
107740 element = parentElement.getElementsByTagName(elementName)[0];
107741 }
107742 }
107743
107744 // text, or array of children
107745 if(arguments[2])
107746 this._children(element, arguments[2]);
107747
107748 return element;
107749 },
107750 _text: function(text) {
107751 return document.createTextNode(text);
107752 },
107753
107754 ATTR_MAP: {
107755 'className': 'class',
107756 'htmlFor': 'for'
107757 },
107758
107759 _attributes: function(attributes) {
107760 var attrs = [];
107761 for(attribute in attributes)
107762 attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) +
107763 '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'"') + '"');
107764 return attrs.join(" ");
107765 },
107766 _children: function(element, children) {
107767 if(children.tagName) {
107768 element.appendChild(children);
107769 return;
107770 }
107771 if(typeof children=='object') { // array can hold nodes and text
107772 children.flatten().each( function(e) {
107773 if(typeof e=='object')
107774 element.appendChild(e)
107775 else
107776 if(Builder._isStringOrNumber(e))
107777 element.appendChild(Builder._text(e));
107778 });
107779 } else
107780 if(Builder._isStringOrNumber(children))
107781 element.appendChild(Builder._text(children));
107782 },
107783 _isStringOrNumber: function(param) {
107784 return(typeof param=='string' || typeof param=='number');
107785 },
107786 build: function(html) {
107787 var element = this.node('div');
107788 $(element).update(html.strip());
107789 return element.down();
107790 },
107791 dump: function(scope) {
107792 if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope
107793
107794 var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " +
107795 "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " +
107796 "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+
107797 "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+
107798 "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+
107799 "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);
107800
107801 tags.each( function(tag){
107802 scope[tag] = function() {
107803 return Builder.node.apply(Builder, [tag].concat($A(arguments)));
107804 }
107805 });
107806 }
107807 }