Changeset 1914
- Timestamp:
- 2011-07-20 15:04:26 (10 months ago)
- Location:
- trunk/modules/kauri-forms/kauri-forms-framework/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-controls.js
r1833 r1914 207 207 */ 208 208 CheckBoxControl.prototype.normaliseValue = function (value) { 209 if (value && value.constructor == Boolean ) return value; // note Boolean object holding false would become true with !! operation210 return !!value; //anything becomes true, nothing or false becomes false209 if (value && value.constructor == Boolean && typeof value === 'object') return value; // note Boolean object holding false would become true with !! operation 210 return new Boolean(!!value); //anything becomes true, nothing or false becomes false 211 211 } 212 212 … … 331 331 } 332 332 this.setValue(value, noValidation); 333 $select.blur(); // force event on control to repaint on ie 333 // on IE we need to trigger repaint by 334 $select.blur(); // calling blur 334 335 } 335 336 -
trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-formatters.js
r1906 r1914 83 83 var thousandSep = $.getThousandSeparator(); 84 84 var decimalSep = $.getDecimalSeparator(); 85 var regex = new RegExp("^(-\s?)?([0-9]{1,3}("+thousandSep+"[0-9]{3})*(\\"+decimalSep+"[0-9]+)?|\\"+decimalSep+"[0-9]+)$"); 85 function toRegexp(c) { 86 return c == '.' ? "\\." : c; 87 } 88 var expression = "^(-\\s*)?[0-9]{1,3}("+toRegexp(thousandSep)+"[0-9]{3})*("+toRegexp(decimalSep)+"[0-9]+)?$"; 89 var regex = new RegExp(expression); 86 90 87 91 var match = regex.exec(valstr); 88 92 if(match && match.length > 0){ 89 var parts = valstr.split(t housandSep);93 var parts = valstr.split(toRegexp(thousandSep)); 90 94 valstr = parts.join(""); 91 95 } -
trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-controls.js
r1908 r1914 164 164 165 165 166 expect(1 5);167 166 expect(18); 167 168 168 169 169 // verify creation of control … … 172 172 ok(c.getForm() == form, "control form ok"); 173 173 equal(c.getId(), id, "control id checked"); 174 175 // check initial value 176 var initial = c.getValue(); 177 ok(initial == false, "initially we should be logically false"); 178 ok(initial.constructor == Boolean && typeof initial === 'object', "and the actual type should be nicely converted"); 174 179 175 180 // verify creation of control elements … … 184 189 185 190 equal($messages.html(), "", "validation error clearing."); 186 equal(c.getValue(), okValue, "get-set value match."); 191 equal(c.getValue(), okValue, "get-set value match (logically)."); 192 equal(c.getValue().constructor, Boolean, "get-set value matches type."); 187 193 188 194 … … 367 373 }); 368 374 375 376 test("IE8/9 width of async selection-control (see #457)", function() { 377 378 // create 379 var $main = $('#main').show(); 380 var $form = $('<form />').appendTo($main); 381 382 var id = "s2"; 383 var fconf = { "members": {}}; 384 fconf.members[id] = { 385 "base": "string", 386 "control": { 387 "base": "selection-control" 388 } 389 }; 390 391 var form = new $.org.kauriproject.forms.Form($form, fconf); 392 393 //expect(18); 394 395 396 // verify creation of control 397 var c = form.findControl(id); 398 ok(c != null, "control creation passed"); 399 ok(c.getForm() == form, "control form ok"); 400 equal(c.getId(), id, "control id checked"); 401 402 // 1. get size of control now 403 var $sel = c.getElement(); 404 var initWidth = $sel.width(); 405 406 // 2. manually set options uri to options/main.js and call refresh 407 var opts = c.options; 408 opts.uri = new $.org.kauriproject.UriTemplate("options/main.json", {skipEscape: true}); 409 opts.update(function() { 410 // 3. check size 411 var afterWidth = $sel.width(); 412 ok(afterWidth > initWidth,"selector with options should be bigger (before = "+initWidth+" , after = "+afterWidth+")."); 413 414 // 415 // cleanup 416 $main.html("").hide(); 417 418 start(); 419 }); 420 421 opts.refresh(); 422 stop(); 423 424 }); 425 369 426 }); 370 427
Note: See TracChangeset
for help on using the changeset viewer.