123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681 |
- require({cache:{
- 'dijit/form/Textarea':function(){
- define("dijit/form/Textarea", [
- "dojo/_base/declare", // declare
- "dojo/dom-style", // domStyle.set
- "./_ExpandingTextAreaMixin",
- "./SimpleTextarea"
- ], function(declare, domStyle, _ExpandingTextAreaMixin, SimpleTextarea){
- /*=====
- var _ExpandingTextAreaMixin = dijit.form._ExpandingTextAreaMixin;
- var SimpleTextarea = dijit.form.SimpleTextarea;
- =====*/
- // module:
- // dijit/form/Textarea
- // summary:
- // A textarea widget that adjusts it's height according to the amount of data.
- return declare("dijit.form.Textarea", [SimpleTextarea, _ExpandingTextAreaMixin], {
- // summary:
- // A textarea widget that adjusts it's height according to the amount of data.
- //
- // description:
- // A textarea that dynamically expands/contracts (changing it's height) as
- // the user types, to display all the text without requiring a scroll bar.
- //
- // Takes nearly all the parameters (name, value, etc.) that a vanilla textarea takes.
- // Rows is not supported since this widget adjusts the height.
- //
- // example:
- // | <textarea data-dojo-type="dijit.form.TextArea">...</textarea>
- // TODO: for 2.0, rename this to ExpandingTextArea, and rename SimpleTextarea to TextArea
- baseClass: "dijitTextBox dijitTextArea dijitExpandingTextArea",
- // Override SimpleTextArea.cols to default to width:100%, for backward compatibility
- cols: "",
- buildRendering: function(){
- this.inherited(arguments);
- // tweak textarea style to reduce browser differences
- domStyle.set(this.textbox, { overflowY: 'hidden', overflowX: 'auto', boxSizing: 'border-box', MsBoxSizing: 'border-box', WebkitBoxSizing: 'border-box', MozBoxSizing: 'border-box' });
- }
- });
- });
- },
- 'dijit/form/_ExpandingTextAreaMixin':function(){
- define("dijit/form/_ExpandingTextAreaMixin", [
- "dojo/_base/declare", // declare
- "dojo/dom-construct", // domConstruct.create
- "dojo/_base/lang", // lang.hitch
- "dojo/_base/window" // win.body
- ], function(declare, domConstruct, lang, win){
- // module:
- // dijit/form/_ExpandingTextAreaMixin
- // summary:
- // Mixin for textarea widgets to add auto-expanding capability
- // feature detection
- var needsHelpShrinking;
- return declare("dijit.form._ExpandingTextAreaMixin", null, {
- // summary:
- // Mixin for textarea widgets to add auto-expanding capability
- _setValueAttr: function(){
- this.inherited(arguments);
- this.resize();
- },
- postCreate: function(){
- this.inherited(arguments);
- var textarea = this.textbox;
- if(needsHelpShrinking == undefined){
- var te = domConstruct.create('textarea', {rows:"5", cols:"20", value: ' ', style: {zoom:1, fontSize:"12px", height:"96px", overflow:'hidden', visibility:'hidden', position:'absolute', border:"5px solid white", margin:"0", padding:"0", boxSizing: 'border-box', MsBoxSizing: 'border-box', WebkitBoxSizing: 'border-box', MozBoxSizing: 'border-box' }}, win.body(), "last");
- needsHelpShrinking = te.scrollHeight >= te.clientHeight;
- win.body().removeChild(te);
- }
- this.connect(textarea, "onresize", "_resizeLater");
- this.connect(textarea, "onfocus", "_resizeLater");
- textarea.style.overflowY = "hidden";
- },
- startup: function(){
- this.inherited(arguments);
- this._resizeLater();
- },
- _onInput: function(e){
- this.inherited(arguments);
- this.resize();
- },
- _estimateHeight: function(){
- // summary:
- // Approximate the height when the textarea is invisible with the number of lines in the text.
- // Fails when someone calls setValue with a long wrapping line, but the layout fixes itself when the user clicks inside so . . .
- // In IE, the resize event is supposed to fire when the textarea becomes visible again and that will correct the size automatically.
- //
- var textarea = this.textbox;
- // #rows = #newlines+1
- textarea.rows = (textarea.value.match(/\n/g) || []).length + 1;
- },
- _resizeLater: function(){
- this.defer("resize");
- },
- resize: function(){
- // summary:
- // Resizes the textarea vertically (should be called after a style/value change)
- var textarea = this.textbox;
- function textareaScrollHeight(){
- var empty = false;
- if(textarea.value === ''){
- textarea.value = ' ';
- empty = true;
- }
- var sh = textarea.scrollHeight;
- if(empty){ textarea.value = ''; }
- return sh;
- }
- if(textarea.style.overflowY == "hidden"){ textarea.scrollTop = 0; }
- if(this.busyResizing){ return; }
- this.busyResizing = true;
- if(textareaScrollHeight() || textarea.offsetHeight){
- var newH = textareaScrollHeight() + Math.max(textarea.offsetHeight - textarea.clientHeight, 0);
- var newHpx = newH + "px";
- if(newHpx != textarea.style.height){
- textarea.style.height = newHpx;
- textarea.rows = 1; // rows can act like a minHeight if not cleared
- }
- if(needsHelpShrinking){
- var origScrollHeight = textareaScrollHeight(),
- newScrollHeight = origScrollHeight,
- origMinHeight = textarea.style.minHeight,
- decrement = 4, // not too fast, not too slow
- thisScrollHeight,
- origScrollTop = textarea.scrollTop;
- textarea.style.minHeight = newHpx; // maintain current height
- textarea.style.height = "auto"; // allow scrollHeight to change
- while(newH > 0){
- textarea.style.minHeight = Math.max(newH - decrement, 4) + "px";
- thisScrollHeight = textareaScrollHeight();
- var change = newScrollHeight - thisScrollHeight;
- newH -= change;
- if(change < decrement){
- break; // scrollHeight didn't shrink
- }
- newScrollHeight = thisScrollHeight;
- decrement <<= 1;
- }
- textarea.style.height = newH + "px";
- textarea.style.minHeight = origMinHeight;
- textarea.scrollTop = origScrollTop;
- }
- textarea.style.overflowY = textareaScrollHeight() > textarea.clientHeight ? "auto" : "hidden";
- if(textarea.style.overflowY == "hidden"){ textarea.scrollTop = 0; }
- }else{
- // hidden content of unknown size
- this._estimateHeight();
- }
- this.busyResizing = false;
- }
- });
- });
- },
- 'dijit/form/SimpleTextarea':function(){
- define("dijit/form/SimpleTextarea", [
- "dojo/_base/declare", // declare
- "dojo/dom-class", // domClass.add
- "dojo/_base/sniff", // has("ie") has("opera")
- "dojo/_base/window", // win.doc.selection win.doc.selection.createRange
- "./TextBox"
- ], function(declare, domClass, has, win, TextBox){
- /*=====
- var TextBox = dijit.form.TextBox;
- =====*/
- // module:
- // dijit/form/SimpleTextarea
- // summary:
- // A simple textarea that degrades, and responds to
- // minimal LayoutContainer usage, and works with dijit.form.Form.
- // Doesn't automatically size according to input, like Textarea.
- return declare("dijit.form.SimpleTextarea", TextBox, {
- // summary:
- // A simple textarea that degrades, and responds to
- // minimal LayoutContainer usage, and works with dijit.form.Form.
- // Doesn't automatically size according to input, like Textarea.
- //
- // example:
- // | <textarea data-dojo-type="dijit.form.SimpleTextarea" name="foo" value="bar" rows=30 cols=40></textarea>
- //
- // example:
- // | new dijit.form.SimpleTextarea({ rows:20, cols:30 }, "foo");
- baseClass: "dijitTextBox dijitTextArea",
- // rows: Number
- // The number of rows of text.
- rows: "3",
- // rows: Number
- // The number of characters per line.
- cols: "20",
- templateString: "<textarea ${!nameAttrSetting} data-dojo-attach-point='focusNode,containerNode,textbox' autocomplete='off'></textarea>",
- postMixInProperties: function(){
- // Copy value from srcNodeRef, unless user specified a value explicitly (or there is no srcNodeRef)
- // TODO: parser will handle this in 2.0
- if(!this.value && this.srcNodeRef){
- this.value = this.srcNodeRef.value;
- }
- this.inherited(arguments);
- },
- buildRendering: function(){
- this.inherited(arguments);
- if(has("ie") && this.cols){ // attribute selectors is not supported in IE6
- domClass.add(this.textbox, "dijitTextAreaCols");
- }
- },
- filter: function(/*String*/ value){
- // Override TextBox.filter to deal with newlines... specifically (IIRC) this is for IE which writes newlines
- // as \r\n instead of just \n
- if(value){
- value = value.replace(/\r/g,"");
- }
- return this.inherited(arguments);
- },
- _onInput: function(/*Event?*/ e){
- // Override TextBox._onInput() to enforce maxLength restriction
- if(this.maxLength){
- var maxLength = parseInt(this.maxLength);
- var value = this.textbox.value.replace(/\r/g,'');
- var overflow = value.length - maxLength;
- if(overflow > 0){
- var textarea = this.textbox;
- if(textarea.selectionStart){
- var pos = textarea.selectionStart;
- var cr = 0;
- if(has("opera")){
- cr = (this.textbox.value.substring(0,pos).match(/\r/g) || []).length;
- }
- this.textbox.value = value.substring(0,pos-overflow-cr)+value.substring(pos-cr);
- textarea.setSelectionRange(pos-overflow, pos-overflow);
- }else if(win.doc.selection){ //IE
- textarea.focus();
- var range = win.doc.selection.createRange();
- // delete overflow characters
- range.moveStart("character", -overflow);
- range.text = '';
- // show cursor
- range.select();
- }
- }
- }
- this.inherited(arguments);
- }
- });
- });
- },
- 'dojox/xml/DomParser':function(){
- define("dojox/xml/DomParser", [
- "dojo/_base/kernel",// dojo.getObject
- "dojo/_base/array" // dojo.forEach
- ], function(dojo){
- dojo.getObject("xml", true, dojox);
- dojox.xml.DomParser=new (function(){
- /**********************************************************
- * The DomParser is a close-to (but not entirely)
- * conforming XML parser based on regular
- * expressions. It will take any XML fragment
- * and return a lightweight JS structure that is
- * similar to (but not exactly) the DOM specification.
- *
- * Getter and setter methods are NOT available; the goal
- * was to keep the resulting object model entirely JS-like.
- *
- * All node types but document fragments are supported;
- * all nodes support getElementsByTagName and
- * getElementsByTagNameNS (with short names byName and
- * byNameNS). The document node supports getElementById
- * (byId), and all nodes support a supplimental
- * childrenByName/childrenByNameNS method as well.
- *
- * The object model is intended to be a READONLY format;
- * mutation events are NOT supported, and though you
- * can change properties on a node-by-node basis, certain
- * operations are not supported (such as changing the ID
- * of an element).
- **********************************************************/
- // internal use only.
- var nodeTypes={ ELEMENT:1, ATTRIBUTE:2, TEXT:3, CDATA_SECTION:4, PROCESSING_INSTRUCTION:7, COMMENT:8, DOCUMENT:9 };
- // compile the regular expressions once.
- var reTags=/<([^>\/\s+]*)([^>]*)>([^<]*)/g;
- var reAttr=/([^=]*)=(("([^"]*)")|('([^']*)'))/g; // patch from tdedischew AT gmail, with additional grouping
- var reEntity=/<!ENTITY\s+([^"]*)\s+"([^"]*)">/g;
- var reCData=/<!\[CDATA\[([\u0001-\uFFFF]*?)\]\]>/g;
- var reComments=/<!--([\u0001-\uFFFF]*?)-->/g;
- var trim=/^\s+|\s+$/g;
- var normalize=/\s+/g;
- var egt=/\>/g;
- var elt=/\</g;
- var equot=/\"/g;
- var eapos=/\'/g;
- var eamp=/\&/g;
- var dNs="_def_";
- // create a root node.
- function _doc(){
- return new (function(){
- var all={};
- this.nodeType=nodeTypes.DOCUMENT;
- this.nodeName="#document";
- this.namespaces={};
- this._nsPaths={};
- this.childNodes=[];
- this.documentElement=null;
- // any element with an ID attribute will be added to the internal hashtable.
- this._add=function(obj){
- if(typeof(obj.id)!="undefined"){ all[obj.id]=obj; }
- };
- this._remove=function(id){
- if(all[id]){ delete all[id]; }
- };
- this.byId=this.getElementById=function(id){ return all[id]; };
- this.byName=this.getElementsByTagName=byName;
- this.byNameNS=this.getElementsByTagNameNS=byNameNS;
- this.childrenByName=childrenByName;
- this.childrenByNameNS=childrenByNameNS;
- })();
- }
- // functions attached to element nodes
- function byName(name){
- // return all descendants with name. Fully qualified (i.e. svg:svg)
- function __(node, name, arr){
- dojo.forEach(node.childNodes, function(c){
- if(c.nodeType==nodeTypes.ELEMENT){
- if(name=="*"){ arr.push(c); }
- else if(c.nodeName==name){ arr.push(c); }
- __(c, name, arr);
- }
- });
- }
- var a=[];
- __(this, name, a);
- return a;
- }
- function byNameNS(name, ns){
- // return all descendants with name by namespace. If no namespace passed, the default is used.
- function __(node, name, ns, arr){
- dojo.forEach(node.childNodes, function(c){
- if(c.nodeType==nodeTypes.ELEMENT){
- if(name=="*"&&c.ownerDocument._nsPaths[ns]==c.namespace){ arr.push(c); }
- else if(c.localName==name&&c.ownerDocument._nsPaths[ns]==c.namespace){ arr.push(c); }
- __(c, name, ns, arr);
- }
- });
- }
- if(!ns){ ns=dNs; }
- var a=[];
- __(this, name, ns, a);
- return a;
- }
- // Only child nodes with name.
- function childrenByName(name){
- var a=[];
- dojo.forEach(this.childNodes, function(c){
- if(c.nodeType==nodeTypes.ELEMENT){
- if(name=="*"){ a.push(c); }
- else if(c.nodeName==name){ a.push(c); }
- }
- });
- return a;
- }
- function childrenByNameNS(name, ns){
- var a=[];
- dojo.forEach(this.childNodes, function(c){
- if(c.nodeType==nodeTypes.ELEMENT){
- if(name=="*"&&c.ownerDocument._nsPaths[ns]==c.namespace){ a.push(c); }
- else if(c.localName==name&&c.ownerDocument._nsPaths[ns]==c.namespace){ a.push(c); }
- }
- });
- return a;
- }
- function _createTextNode(v){
- return {
- nodeType:nodeTypes.TEXT,
- nodeName:"#text",
- nodeValue:v.replace(normalize," ").replace(egt,">").replace(elt,"<").replace(eapos,"'").replace(equot,'"').replace(eamp,"&")
- };
- }
- // attribute functions
- function getAttr(name){
- for(var i=0; i<this.attributes.length; i++){
- if(this.attributes[i].nodeName==name){
- return this.attributes[i].nodeValue;
- }
- }
- return null;
- }
- function getAttrNS(name, ns){
- for(var i=0; i<this.attributes.length; i++){
- if(this.ownerDocument._nsPaths[ns]==this.attributes[i].namespace
- &&this.attributes[i].localName==name
- ){
- return this.attributes[i].nodeValue;
- }
- }
- return null;
- }
- // note that you can only swap IDs using setAttribute, NOT with setAttributeNS.
- function setAttr(name, val){
- var old=null;
- for(var i=0; i<this.attributes.length; i++){
- if(this.attributes[i].nodeName==name){
- old=this.attributes[i].nodeValue;
- this.attributes[i].nodeValue=val;
- break;
- }
- }
- if(name=="id"){
- if(old!=null){ this.ownerDocument._remove(old); }
- this.ownerDocument._add(this);
- }
- }
- function setAttrNS(name, val, ns){
- for(var i=0; i<this.attributes.length; i++){
- if(this.ownerDocument._nsPaths[ns]==this.attributes[i].namespace
- &&this.attributes[i].localName==name
- ){
- this.attributes[i].nodeValue=val;
- return;
- }
- }
- }
- // navigation
- function prev(){
- var p=this.parentNode;
- if(p){
- for(var i=0;i<p.childNodes.length;i++){
- if(p.childNodes[i]==this&&i>0){
- return p.childNodes[i-1];
- }
- }
- }
- return null;
- }
- function next(){
- var p=this.parentNode;
- if(p){
- for(var i=0;i<p.childNodes.length;i++){
- if(p.childNodes[i]==this&&(i+1)<p.childNodes.length){
- return p.childNodes[i+1];
- }
- }
- }
- return null;
- }
- // the main method.
- this.parse=function(/* String */str){
- var root=_doc();
- if(str==null){ return root; }
- if(str.length==0){ return root; }
- // preprocess custom entities
- if(str.indexOf("<!ENTITY")>0){
- var entity, eRe=[];
- if(reEntity.test(str)){
- reEntity.lastIndex=0;
- // match entities
- while((entity=reEntity.exec(str))!=null){
- eRe.push({
- entity:"&"+entity[1].replace(trim,"")+";",
- expression:entity[2]
- });
- }
- // replace instances in the document.
- for(var i=0; i<eRe.length; i++){
- str=str.replace(new RegExp(eRe[i].entity, "g"), eRe[i].expression);
- }
- }
- }
- // pre-parse for CData, and tokenize.
- var cdSections=[], cdata;
- while((cdata=reCData.exec(str))!=null){ cdSections.push(cdata[1]); }
- for(var i=0; i<cdSections.length; i++){ str=str.replace(cdSections[i], i); }
-
- // pre-parse for comments, and tokenize.
- var comments=[], comment;
- while((comment=reComments.exec(str))!=null){ comments.push(comment[1]); }
- for(i=0; i<comments.length; i++){ str=str.replace(comments[i], i); }
- // parse the document
- var res, obj=root;
- while((res=reTags.exec(str))!=null){
- // closing tags.
- if(res[2].charAt(0)=="/" && res[2].replace(trim, "").length>1){
- if(obj.parentNode){
- obj=obj.parentNode;
- }
- var text=(res[3]||"").replace(trim, "");
- if(text.length>0) {
- obj.childNodes.push(_createTextNode(text));
- }
- }
- // open tags.
- else if(res[1].length>0){
- // figure out the type of node.
- if(res[1].charAt(0)=="?"){
- // processing instruction
- var name=res[1].substr(1);
- var target=res[2].substr(0,res[2].length-2);
- obj.childNodes.push({
- nodeType:nodeTypes.PROCESSING_INSTRUCTION,
- nodeName:name,
- nodeValue:target
- });
- }
- else if(res[1].charAt(0)=="!"){
- // CDATA; skip over any declaration elements.
- if(res[1].indexOf("![CDATA[")==0){
- var val=parseInt(res[1].replace("![CDATA[","").replace("]]",""));
- obj.childNodes.push({
- nodeType:nodeTypes.CDATA_SECTION,
- nodeName:"#cdata-section",
- nodeValue:cdSections[val]
- });
- }
- // Comments.
- else if(res[1].substr(0,3)=="!--"){
- var val=parseInt(res[1].replace("!--","").replace("--",""));
- obj.childNodes.push({
- nodeType:nodeTypes.COMMENT,
- nodeName:"#comment",
- nodeValue:comments[val]
- });
- }
- }
- else {
- // Elements (with attribute and text)
- var name=res[1].replace(trim,"");
- var o={
- nodeType:nodeTypes.ELEMENT,
- nodeName:name,
- localName:name,
- namespace:dNs,
- ownerDocument:root,
- attributes:[],
- parentNode:null,
- childNodes:[]
- };
- // check to see if it's namespaced.
- if(name.indexOf(":")>-1){
- var t=name.split(":");
- o.namespace=t[0];
- o.localName=t[1];
- }
- // set the function references.
- o.byName=o.getElementsByTagName=byName;
- o.byNameNS=o.getElementsByTagNameNS=byNameNS;
- o.childrenByName=childrenByName;
- o.childrenByNameNS=childrenByNameNS;
- o.getAttribute=getAttr;
- o.getAttributeNS=getAttrNS;
- o.setAttribute=setAttr;
- o.setAttributeNS=setAttrNS;
- o.previous=o.previousSibling=prev;
- o.next=o.nextSibling=next;
- // parse the attribute string.
- var attr;
- while((attr=reAttr.exec(res[2]))!=null){
- if(attr.length>0){
- var name=attr[1].replace(trim,"");
- var val=(attr[4]||attr[6]||"").replace(normalize," ")
- .replace(egt,">")
- .replace(elt,"<")
- .replace(eapos,"'")
- .replace(equot,'"')
- .replace(eamp,"&");
- if(name.indexOf("xmlns")==0){
- if(name.indexOf(":")>0){
- var ns=name.split(":");
- root.namespaces[ns[1]]=val;
- root._nsPaths[val]=ns[1];
- } else {
- root.namespaces[dNs]=val;
- root._nsPaths[val]=dNs;
- }
- } else {
- var ln=name;
- var ns=dNs;
- if(name.indexOf(":")>0){
- var t=name.split(":");
- ln=t[1];
- ns=t[0];
- }
- o.attributes.push({
- nodeType:nodeTypes.ATTRIBUTE,
- nodeName:name,
- localName:ln,
- namespace:ns,
- nodeValue:val
- });
- // only add id as a property.
- if(ln=="id"){ o.id=val; }
- }
- }
- }
- root._add(o);
- if(obj){
- obj.childNodes.push(o);
- o.parentNode=obj;
- // if it's not a self-closing node.
- if(res[2].charAt(res[2].length-1)!="/"){
- obj=o;
- }
- }
- var text=res[3];
- if(text.length>0){
- obj.childNodes.push(_createTextNode(text));
- }
- }
- }
- }
- // set the document element
- for(var i=0; i<root.childNodes.length; i++){
- var e=root.childNodes[i];
- if(e.nodeType==nodeTypes.ELEMENT){
- root.documentElement=e;
- break;
- }
- }
- return root;
- };
- })();
- return dojox.xml.DomParser;
- });
- }}});
- define("dojo/buxViewer", [], 1);
|