From 4e20a991931eaf956a1c28fbf943cdfb663271a7 Mon Sep 17 00:00:00 2001 From: jennylee Date: Thu, 13 Dec 2012 12:18:55 -0400 Subject: [PATCH 1/2] BUG-3860 New Feature. Add options "Capitalize Phrase" and "Title Case" to "Text transform to". New Feature. I added new functions to Capitalize Phrase and Title Case in''Text transform to'. --- gulliver/js/form/core/form.js | 10 ++++++++++ gulliver/js/maborak/core/maborak.js | 5 +++-- gulliver/js/maborak/core/maborak.old.js | 11 +++++++++++ gulliver/system/class.xmlform.php | 15 +++++++++++++++ workflow/engine/xmlform/dynaforms/fields/text.xml | 2 +- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gulliver/js/form/core/form.js b/gulliver/js/form/core/form.js index 66208abc6..f23a6751e 100755 --- a/gulliver/js/form/core/form.js +++ b/gulliver/js/form/core/form.js @@ -1502,6 +1502,16 @@ function G_Text(form, element, name) case 'LOWER': this.element.value = this.element.value.toLowerCase(); break; + case 'TITLE': + this.element.value = this.element.value.toLowerCase(); + this.element.value = this.element.value.toInitCap(this.element.value); + break; + case 'PHRASE': + //this.element.value = this.element.value.toLowerCase(); + var phrase = this.element.value.split(' '); + phrase[0] = phrase[0].toInitCap(phrase[0]); + this.element.value = phrase.join(' '); + break; } } }.extend(this); diff --git a/gulliver/js/maborak/core/maborak.js b/gulliver/js/maborak/core/maborak.js index 019e7d191..9e046ba20 100644 --- a/gulliver/js/maborak/core/maborak.js +++ b/gulliver/js/maborak/core/maborak.js @@ -120,7 +120,8 @@ return camelizedString;};String.prototype.toArray=function() {return this.split("");};String.prototype.extractScript=function() {var matchAll=new RegExp(tagScript,'img');return(this.match(matchAll)||[]);};String.prototype.evalScript=function() {return(this.match(new RegExp(tagScript,'img'))||[]).evalScript();};String.prototype.stripScript=function() -{return this.replace(new RegExp(tagScript,'img'),'');};if((typeof XMLSerializer)==='undefined') +{return this.replace(new RegExp(tagScript,'img'),'');};String.prototype.toInitCap=function(str) +{return(str+'').replace(/^([a-z])|\s+([a-z])/g,function($1){return $1.toUpperCase();});};if((typeof XMLSerializer)==='undefined') {window.XMLSerializer=function(){this.toString=function() {return"[object XMLSerializer]";};this.serializeToString=function(xml){return xml.xml||xml.outerHTML||"Error XMLSerializer";};};}};this.loadMethods=function(methods,instance) {var _return_=[];var tmp;for(var i=0;istrTo === 'LOWER') { $value = strtolower( $value ); } + if ($this->strTo === 'TITLE') { + $value = strtolower( $value ); + $value = ucwords( $value ); + } + if ($this->strTo === 'PHRASE') { + //$value = strtolower( $value ); + + $title = explode(" ",$value); + + $title[0] = ucwords( $title[0] ); + + $value = implode(" ", $title); + } //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); + print_r($this->renderMode); $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); if ($this->replaceTags == 1) { $value = G::replaceDataField( $value, $owner->values ); @@ -1285,6 +1299,7 @@ class XmlForm_Field_Suggest extends XmlForm_Field_SimpleText //by neyek if ($this->strTo === 'LOWER') { $value = strtolower( $value ); } + //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); diff --git a/workflow/engine/xmlform/dynaforms/fields/text.xml b/workflow/engine/xmlform/dynaforms/fields/text.xml index 4efaba779..0d493c11c 100755 --- a/workflow/engine/xmlform/dynaforms/fields/text.xml +++ b/workflow/engine/xmlform/dynaforms/fields/text.xml @@ -38,7 +38,7 @@ - Text transform to + Text transform to Required From 2ddaae9bb369aebaab03fb58fc65fe3027804ebe Mon Sep 17 00:00:00 2001 From: jennylee Date: Thu, 13 Dec 2012 12:28:11 -0400 Subject: [PATCH 2/2] BUG-3860 New Feature. Add options "Capitalize Phrase" and "Title Case" to "Text transform to". New Feature. I added new functions to Capitalize Phrase and Title Case in''Text transform to'. --- gulliver/system/class.xmlform.php | 1 - 1 file changed, 1 deletion(-) diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index 27963d17e..658608c50 100755 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -1127,7 +1127,6 @@ class XmlForm_Field_Text extends XmlForm_Field_SimpleText $value = implode(" ", $title); } //if ($this->strTo==='CAPITALIZE') $value = strtocapitalize($value); - print_r($this->renderMode); $onkeypress = G::replaceDataField( $this->onkeypress, $owner->values ); if ($this->replaceTags == 1) { $value = G::replaceDataField( $value, $owner->values );