if(!dojo._hasResource["dijit.form.Textarea"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["dijit.form.Textarea"] = true;
dojo.provide("dijit.form.Textarea");
dojo.require("dijit.form._FormWidget");
dojo.require("dojo.i18n");
dojo.requireLocalization("dijit.form", "Textarea", null, "zh,pt,da,tr,ru,de,ROOT,sv,ja,he,fi,nb,el,ar,pt-pt,cs,fr,es,ko,nl,zh-tw,pl,it,hu");
dojo.declare(
"dijit.form.Textarea",
dijit.form._FormValueWidget,
{
// summary: A resizing textarea widget
//
// description:
// A textarea that resizes vertically to contain the data.
// Takes nearly all the parameters (name, value, etc.) that a vanilla textarea takes.
// Cols is not supported and the width should be specified with style width.
// Rows is not supported since this widget adjusts the height.
//
// example:
// |
//
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormValueWidget.prototype.attributeMap),
{style:"styleNode", 'class':"styleNode"}),
templateString: (dojo.isIE || dojo.isSafari || dojo.isFF) ?
((dojo.isIE || dojo.isSafari || dojo.isFF >= 3) ? '
':'')
: '',
setAttribute: function(/*String*/ attr, /*anything*/ value){
this.inherited(arguments);
switch(attr){
case "disabled":
this.formValueNode.disabled = this.disabled;
case "readOnly":
if(dojo.isIE || dojo.isSafari || dojo.isFF >= 3){
this.editNode.contentEditable = (!this.disabled && !this.readOnly);
}else if(dojo.isFF){
this.iframe.contentDocument.designMode = (this.disabled || this.readOnly)? "off" : "on";
}
}
},
focus: function(){
// summary: Received focus, needed for the InlineEditBox widget
if(!this.disabled && !this.readOnly){
this._changing(); // set initial height
}
dijit.focus(this.iframe || this.focusNode);
},
setValue: function(/*String*/ value, /*Boolean, optional*/ priorityChange){
var editNode = this.editNode;
if(typeof value == "string"){
editNode.innerHTML = ""; // wipe out old nodes
if(value.split){
var _this=this;
var isFirst = true;
dojo.forEach(value.split("\n"), function(line){
if(isFirst){ isFirst = false; }
else{
editNode.appendChild(dojo.doc.createElement("BR")); // preserve line breaks
}
if(line){
editNode.appendChild(dojo.doc.createTextNode(line)); // use text nodes so that imbedded tags can be edited
}
});
}else if(value){
editNode.appendChild(dojo.doc.createTextNode(value));
}
if(!dojo.isIE){
editNode.appendChild(dojo.doc.createElement("BR")); // so that you see a cursor
}
}else{
// blah blah --> blah\nblah
//
blah
blah
--> blah\nblah
//
blah
blah
--> blah\nblah
// &<> -->&< >
value = editNode.innerHTML;
if(this.iframe){ // strip sizeNode
value = value.replace(/
<\/div>\r?\n?$/i,"");
}
value = value.replace(/\s*\r?\n|^\s+|\s+$| /g,"").replace(/>\s+<").replace(/<\/(p|div)>$|^<(p|div)[^>]*>/gi,"").replace(/([^>])
/g,"$1\n").replace(/<\/p>\s*
]*>| ]*>|<\/div>\s*
]*>/gi,"\n").replace(/<[^>]*>/g,"").replace(/&/gi,"\&").replace(/</gi,"<").replace(/>/gi,">");
if(!dojo.isIE){
value = value.replace(/\n$/,""); // remove added
}
}
this.value = this.formValueNode.value = value;
if(this.iframe){
var sizeNode = dojo.doc.createElement('div');
editNode.appendChild(sizeNode);
var newHeight = sizeNode.offsetTop;
if(editNode.scrollWidth > editNode.clientWidth){ newHeight+=16; } // scrollbar space needed?
if(this.lastHeight != newHeight){ // cache size so that we don't get a resize event because of a resize event
if(newHeight == 0){ newHeight = 16; } // height = 0 causes the browser to not set scrollHeight
dojo.contentBox(this.iframe, {h: newHeight});
this.lastHeight = newHeight;
}
editNode.removeChild(sizeNode);
}
dijit.form.Textarea.superclass.setValue.call(this, this.getValue(), priorityChange);
},
getValue: function(){
return this.value.replace(/\r/g,"");
},
postMixInProperties: function(){
this.inherited(arguments);
// don't let the source text be converted to a DOM structure since we just want raw text
if(this.srcNodeRef && this.srcNodeRef.innerHTML != ""){
this.value = this.srcNodeRef.innerHTML;
this.srcNodeRef.innerHTML = "";
}
if((!this.value || this.value == "") && this.srcNodeRef && this.srcNodeRef.value){
this.value = this.srcNodeRef.value;
}
if(!this.value){ this.value = ""; }
this.value = this.value.replace(/\r\n/g,"\n").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&");
if(dojo.isFF == 2){
// In the case of Firefox an iframe is used and when the text gets focus,
// focus is fired from the document object. There isn't a way to put a
// waiRole on the document object and as a result screen readers don't
// announce the role. As a result screen reader users are lost.
//
// An additional problem is that the browser gives the document object a
// very cryptic accessible name, e.g.
// wysiwyg://13/http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_InlineEditBox.html
// When focus is fired from the document object, the screen reader speaks
// the accessible name. The cyptic accessile name is confusing.
//
// A workaround for both of these problems is to give the iframe's
// document a title, the name of which is similar to a role name, i.e.
// "edit area". This will be used as the accessible name which will replace
// the cryptic name and will also convey the role information to the user.
// Because it is read directly to the user, the string must be localized.
// In addition, since a