X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-ui-debug.js;h=699aabf81ab3a453bd83d9acc270c4b02183456d;hp=b2950f88dec239b4d27f9bceb9f7ab65210c7188;hb=refs%2Fheads%2Fwip_alan_T6011_fixing_surrogate_characters;hpb=bbea05ba2ddfd77b500f7065e9081f94e407e4d9 diff --git a/roojs-ui-debug.js b/roojs-ui-debug.js index b2950f88de..699aabf81a 100644 --- a/roojs-ui-debug.js +++ b/roojs-ui-debug.js @@ -16990,6 +16990,10 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { * @cfg {Boolean} selectOnFocus True to automatically select any existing field text when the field receives input focus (defaults to false) */ selectOnFocus : false, + /** + * @cfg {Boolean} allowLeadingSpace True to prevent the stripping of leading white space + */ + allowLeadingSpace : false, /** * @cfg {String} blankText Error text to display if the allow blank validation fails (defaults to "This field is required") */ @@ -17034,8 +17038,11 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { if(this.selectOnFocus){ this.on("focus", this.preFocus, this); - } + if (!this.allowLeadingSpace) { + this.on('blur', this.cleanLeadingSpace, this); + } + if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Roo.form.VTypes[this.vtype+'Mask']))){ this.el.on("keypress", this.filterKeys, this); } @@ -17071,7 +17078,15 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { this.autoSize(); } }, - + // private - clean the leading white space + cleanLeadingSpace : function(e) + { + if ( this.inputType == 'file') { + return; + } + + this.setValue((this.getValue() + '').replace(/^\s+/,'')); + }, /** * Resets the current field value to the originally-loaded value and clears any validation messages. * @@ -17079,9 +17094,7 @@ Roo.extend(Roo.form.TextField, Roo.form.Field, { reset : function(){ Roo.form.TextField.superclass.reset.call(this); - }, - - + }, // private preFocus : function(){ @@ -17833,7 +17846,8 @@ Roo.extend(Roo.form.NumberField, Roo.form.TextField, { * Create a new DateField * @param {Object} config */ -Roo.form.DateField = function(config){ +Roo.form.DateField = function(config) +{ Roo.form.DateField.superclass.constructor.call(this, config); this.addEvents({ @@ -18181,7 +18195,13 @@ dateField.setValue('2006-5-4'); return String(this.getValue()) !== String(this.startValue); + }, + // @overide + cleanLeadingSpace : function(e) + { + return; } + });/* * Based on: * Ext JS Library 1.1.1 @@ -19655,7 +19675,7 @@ Roo.extend(Roo.form.ComboBox, Roo.form.TriggerField, { this.view.select(match); var sn = Roo.get(this.view.getSelectedNodes()[0]); sn.scrollIntoView(sn.dom.parentNode, false); - } + } /** * @cfg {Boolean} grow @@ -20779,17 +20799,32 @@ Roo.extend(Roo.HtmlEditorCore, Roo.Component, { html = this.cleanHtml(html); // fix up the special chars.. normaly like back quotes in word... // however we do not want to do this with chinese.. - html = html.replace(/([\x80-\uffff])/g, function (a, b) { - var cc = b.charCodeAt(); - if ( + html = html.replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\u0080-\uFFFF]/g, function(match) { + + var cc = match.charCodeAt(); + + // Get the character value, handling surrogate pairs + if (match.length == 2) { + // It's a surrogate pair, calculate the Unicode code point + var high = match.charCodeAt(0) - 0xD800; + var low = match.charCodeAt(1) - 0xDC00; + cc = (high * 0x400) + low + 0x10000; + } else if ( (cc >= 0x4E00 && cc < 0xA000 ) || (cc >= 0x3400 && cc < 0x4E00 ) || (cc >= 0xf900 && cc < 0xfb00 ) ) { - return b; - } - return "&#"+cc+";" + return match; + } + + // No, use a numeric entity. Here we brazenly (and possibly mistakenly) + return "&#" + cc + ";"; + + }); + + + if(this.owner.fireEvent('beforesync', this, html) !== false){ this.el.dom.value = html; this.owner.fireEvent('sync', this, html); @@ -30120,7 +30155,7 @@ Roo.extend(Roo.LayoutRegion, Roo.BasicLayoutRegion, { * Collapses this region. * @param {Boolean} skipAnim (optional) true to collapse the element without animation (if animate is true) */ - collapse : function(skipAnim, skipCheck = false){ + collapse : function(skipAnim, skipCheck){ if(this.collapsed) { return; }