static/js/forms.js
changeset 36 d7a159024912
parent 21 3510b9092bc4
equal deleted inserted replaced
35:13b5dd3a7a5f 36:d7a159024912
    15             this.attr("disabled", "disabled");
    15             this.attr("disabled", "disabled");
    16         else
    16         else
    17             this.removeAttr("disabled");
    17             this.removeAttr("disabled");
    18     }
    18     }
    19 
    19 
       
    20     /**
       
    21      * Query or set form field checked state
       
    22      */
    20     $.fn.checked = function (flag) {
    23     $.fn.checked = function (flag) {
    21         if (flag == undefined)
    24         if (flag == undefined)
    22             // XXX: jQuery returns true here?
    25             // XXX: jQuery returns true here?
    23             return !!this.attr("checked");
    26             return !!this.attr("checked");
    24 
    27 
    26         if (flag)
    29         if (flag)
    27             this.attr("checked", "checked");
    30             this.attr("checked", "checked");
    28         else
    31         else
    29             this.removeAttr("checked");
    32             this.removeAttr("checked");
    30     }
    33     }
       
    34 
       
    35     /**
       
    36      * Redirect browser to another URL
       
    37      *
       
    38      * XXX: Can I do a global function like this?
       
    39      */
       
    40     $.redirect = function (url) {
       
    41         window.location.href = url;
       
    42 
       
    43         return false;
       
    44     }
       
    45 
    31 
    46 
    32     /*
    47     /*
    33      * The given checkbox acts as an enable/disable toggle for this form control
    48      * The given checkbox acts as an enable/disable toggle for this form control
    34      */
    49      */
    35     $.fn.formEnabledBy = function (checkbox) {
    50     $.fn.formEnabledBy = function (checkbox) {