HTMLOptions

class webix.HTMLOptions()

Htmloptions mixin

Referenced by

views
radio(), segmented().

External references

Official documentation page.

Code

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
webix.HTMLOptions = {
    $init:function(config){
        if(webix.skin.$active.customRadio || this.addOption)
            webix._event( this.$view, "keydown", this._moveSelection, {bind:this});
    },
    _focus: function(){
        var input = this._getInputNode();
        if(input)
            for(var i=0; i<input.length; i++){
                if(input[i].getAttribute("tabindex") == "0")
                    input[i].focus();
            }
    },
    _blur: function(){
        var input = this._getInputNode();
        if(input)
            for(var i=0; i<input.length; i++){
                if(input[i].getAttribute("tabindex") == "0") input[i].blur();
            }
    },
    _moveSelection:function(e){
        var code = e.which || e.keyCode;

        var startCode = this.addOption?34:36;

        if(code>startCode && code <41){
            webix.html.preventEvent(e);
            var index;
            var inp = this._getInputNode();

            if(code == 35) index = inp.length-1;
            else if(code === 36 ) index = 0;
            else{
                var dir = (code === 37 || code ===38)?-1:1;
                for(var i =0; i<inp.length; i++){
                    if(inp[i].getAttribute("tabindex") == "0"){
                        index = i + dir;
                        if(index<0) index = inp.length-1;
                        else if(index>=inp.length) index = 0;
                        break;
                    }
                }
            }
            if(!webix.isUndefined(index)){
                var id = this.addOption ? inp[index].getAttribute("button_id") : inp[index].value;
                if(webix.skin.$active.customRadio && !this.addOption)
                    inp = this.$view.getElementsByTagName("BUTTON");

                this.setValue(id);
                inp[index].focus();
            }
        }
    }
};


webix.attachEvent("onClick", function(e){
    var element = webix.$$(e);
    if (element && element.touchable){
        webix.UIManager.applyChanges(element);

        //for inline elements - restore pointer to the master element
        element.getNode(e);
        //reaction on custom css elements in buttons
        var trg=e.target||e.srcElement;
        if (trg.className == "webix_disabled")
            return;

        var css = "";
        var id = null;
        var found = false;
        if (trg.className && trg.className.toString().indexOf("webix_view")===0) return;

        if (element)
            webix.UIManager._focus_action(element);

        //loop through all parents
        while (trg && trg.parentNode){
            if (trg.getAttribute){
                if (trg.getAttribute("view_id"))
                    break;

                css=trg.className;
                if (css){
                    css = css.toString().split(" ");
                    for (var i =0; i<css.length; i++){
                        if (element.on_click[css[i]]){
                            var res =  element.on_click[css[i]].call(element,e,element._settings.id,trg);
                            if (res===false)
                                return;
                        }
                    }
                }
            }
            trg=trg.parentNode;
        }


        if (element._settings.click){
            var code = webix.toFunctor(element._settings.click, element.$scope);
            if (code && code.call) code.call(element, element._settings.id, e);
        }



        var popup = element._settings.popup;
        if (element._settings.popup && !element._settings.readonly){
            if (typeof popup == "object" && !popup.name)
                popup = element._settings.popup = webix.ui(popup)._settings.id;

            var popup = webix.$$(popup);
            webix.assert(popup, "Unknown popup");

            if (!popup.isVisible()){
                popup._settings.master = element._settings.id;
                popup.show((element.getInputNode()||element.getNode()),null,true);
            }
        }

        element.callEvent("onItemClick", [element._settings.id, e]);
    }
});