Changeset 1914


Ignore:
Timestamp:
2011-07-20 15:04:26 (10 months ago)
Author:
mpo
Message:

test on #457 and additional fix for the numeric see r1905 and r1906

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  
    207207     */ 
    208208    CheckBoxControl.prototype.normaliseValue = function (value) { 
    209         if (value && value.constructor == Boolean) return value; // note Boolean object holding false would become true with !! operation 
    210         return !!value; //anything becomes true, nothing or false becomes false 
     209        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 
    211211    } 
    212212 
     
    331331        }  
    332332        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 
    334335    } 
    335336 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/main/kauri/static-{build}.key/kauri.forms/basic-formatters.js

    r1906 r1914  
    8383                    var thousandSep = $.getThousandSeparator(); 
    8484                    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); 
    8690                     
    8791                    var match = regex.exec(valstr); 
    8892                    if(match && match.length > 0){ 
    89                         var parts = valstr.split(thousandSep); 
     93                        var parts = valstr.split(toRegexp(thousandSep)); 
    9094                        valstr = parts.join(""); 
    9195                    } 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-controls.js

    r1908 r1914  
    164164     
    165165 
    166     expect(15); 
    167  
     166    expect(18); 
     167     
    168168     
    169169    // verify creation of control 
     
    172172    ok(c.getForm() == form, "control form ok"); 
    173173    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"); 
    174179     
    175180    // verify creation  of control elements 
     
    184189 
    185190    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."); 
    187193 
    188194     
     
    367373}); 
    368374 
     375 
     376test("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 
    369426}); 
    370427 
Note: See TracChangeset for help on using the changeset viewer.