svghmi/widget_slider.ysl2
author usveticic
Tue, 18 Aug 2020 11:42:28 +0200
branchsvghmi
changeset 3045 f6d428330e04
parent 3021 49799de67540
child 3056 827bf284feec
permissions -rw-r--r--
All widgets reworked to use widget class and animate function if needed
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     1
// widget_slider.ysl2
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     2
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     3
template "widget[@type='Slider']", mode="widget_class"
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     4
    ||
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     5
    class SliderWidget extends Widget{
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     6
        frequency = 5;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     7
        range = undefined;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
     8
        fi = undefined;
3045
f6d428330e04 All widgets reworked to use widget class and animate function if needed
usveticic
parents: 3021
diff changeset
     9
        svg_dist = undefined;
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    10
        drag = false;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    11
        enTimer = false;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    12
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    13
        dispatch(value) {
3020
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
    14
            if(this.value_elt)
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
    15
                this.value_elt.textContent = String(value);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    16
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    17
            this.update_DOM(value, this.handle_elt);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    18
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    19
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    20
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    21
        last_drag = false;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    22
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    23
        update_DOM(value, elt){
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    24
            let [min,max,start,totallength] = this.range;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    25
            let length = Math.max(0,Math.min(totallength,(Number(value)-min)*totallength/(max-min)));
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    26
            let tip = this.range_elt.getPointAtLength(length);
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    27
            elt.setAttribute('transform',"translate("+(tip.x-start.x)+","+(tip.y-start.y)+")");
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    28
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    29
            if(this.setpoint_elt != undefined){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    30
                if(this.last_drag!= this.drag){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    31
                    if(this.drag){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    32
                        this.setpoint_elt.setAttribute("style", this.setpoint_style);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    33
                    }else{
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    34
                        this.setpoint_elt.setAttribute("style", "display:none");
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    35
                    }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    36
                    this.last_drag = this.drag;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    37
                }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    38
            }
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    39
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    40
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    41
        on_release(evt) {
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    42
            window.removeEventListener("touchmove", this.on_bound_drag, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    43
            window.removeEventListener("mousemove", this.on_bound_drag, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    44
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    45
            window.removeEventListener("mouseup", this.bound_on_release, true)
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    46
            window.removeEventListener("touchend", this.bound_on_release, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    47
            window.removeEventListener("touchcancel", this.bound_on_release, true);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    48
            if(this.drag){
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    49
                this.drag = false;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    50
            }
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    51
            this.update_position(evt);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    52
        }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    53
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    54
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    55
        on_drag(evt){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    56
            if(this.enTimer && this.drag){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    57
                this.update_position(evt);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    58
                //reset timer
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    59
                this.enTimer = false;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    60
                setTimeout("{hmi_widgets['"+this.element_id+"'].enTimer = true;}", 100);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    61
            }
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    62
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    63
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    64
        update_position(evt){
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    65
            var html_dist = 0;
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    66
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    67
            //calculate size of widget in html
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    68
            var range_borders = this.range_elt.getBoundingClientRect();
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    69
            var range_length = Math.sqrt( range_borders.height*range_borders.height + range_borders.width*range_borders.width );
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    70
            var [minX,minY,maxX,maxY] = [range_borders.left,range_borders.bottom,range_borders.right,range_borders.top];
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    71
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    72
            //get range and mouse coordinates
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    73
            var mouseX = undefined;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    74
            var mouseY = undefined;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    75
            if (evt.type.startsWith("touch")){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    76
                mouseX = Math.ceil(evt.touches[0].clientX);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    77
                mouseY = Math.ceil(evt.touches[0].clientY);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    78
            }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    79
            else{
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    80
                mouseX = evt.pageX;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    81
                mouseY = evt.pageY;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    82
            }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    83
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    84
            //get handle distance from mouse position
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    85
            if (minX > mouseX && minY < mouseY){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    86
                html_dist = 0;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    87
            }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    88
            else if (maxX < mouseX && maxY > mouseY){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    89
                html_dist = range_length;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    90
            }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    91
            else{
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    92
                // calculate distace
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    93
                if(this.fi > 0.7){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    94
                    html_dist = (minY - mouseY)/Math.sin(this.fi);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    95
                }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    96
                else{
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
    97
                    html_dist = (mouseX - minX)/Math.cos(this.fi);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    98
                }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
    99
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   100
                //check if in range
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   101
                if (html_dist > range_length){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   102
                    html_dist = range_length;
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   103
                }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   104
                else if (html_dist < 0){
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   105
                    html_dist = 0;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   106
                }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   107
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   108
            }
3020
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
   109
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   110
            this.svg_dist=Math.ceil((html_dist/range_length)*this.range[1]);
3020
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
   111
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   112
            this.apply_hmi_value(0, this.svg_dist);
3020
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
   113
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   114
            // update ghost cursor
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   115
            if(this.setpoint_elt != undefined){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   116
                this.request_animate();
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   117
            }
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   118
        }
3020
895bbeced72d SVGHMI: Update Slider widget so that it doesn't display future value but actual value only.
Edouard Tisserant
parents: 3018
diff changeset
   119
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   120
        animate(){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   121
            this.update_DOM(this.svg_dist, this.setpoint_elt);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   122
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   123
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   124
        on_select(evt){
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   125
            this.drag = true;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   126
            this.enTimer = true;
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   127
            window.addEventListener("touchmove", this.on_bound_drag, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   128
            window.addEventListener("mousemove", this.on_bound_drag, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   129
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   130
            window.addEventListener("mouseup", this.bound_on_release, true)
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   131
            window.addEventListener("touchend", this.bound_on_release, true);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   132
            window.addEventListener("touchcancel", this.bound_on_release, true);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   133
            this.update_position(evt);
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   134
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   135
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   136
        init() {
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   137
            let min = this.min_elt ?
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   138
                        Number(this.min_elt.textContent) :
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   139
                        this.args.length >= 1 ? this.args[0] : 0;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   140
            let max = this.max_elt ?
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   141
                        Number(this.max_elt.textContent) :
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   142
                        this.args.length >= 2 ? this.args[1] : 100;
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   143
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   144
            this.range = [min, max, this.range_elt.getPointAtLength(0),this.range_elt.getTotalLength()];
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   145
            let start = this.range_elt.getPointAtLength(0);
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   146
            let end = this.range_elt.getPointAtLength(this.range_elt.getTotalLength());
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   147
            this.fi = Math.atan2(start.y-end.y, end.x-start.x);
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   148
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   149
            this.bound_on_select = this.on_select.bind(this);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   150
            this.bound_on_release = this.on_release.bind(this);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   151
            this.on_bound_drag = this.on_drag.bind(this);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   152
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   153
            this.element.addEventListener("mousedown", this.bound_on_select);
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   154
            this.element.addEventListener("touchstart", this.bound_on_select);
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   155
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   156
            if(this.setpoint_elt != undefined){
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   157
                this.setpoint_style = this.setpoint_elt.getAttribute("style");
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   158
                this.setpoint_elt.setAttribute("style", "display:none");
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   159
            }
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   160
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   161
        }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   162
    }
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   163
    ||
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   164
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   165
template "widget[@type='Slider']", mode="widget_defs" {
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   166
    param "hmi_element";
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   167
    labels("handle range");
3021
49799de67540 SVGHMI: add a SetPoint to Slider Widget, visible only when operating the slider.
Edouard Tisserant
parents: 3020
diff changeset
   168
    optional_labels("value min max setpoint");
3012
65471f50b421 Create new slider widget which extand class widget
usveticic
parents:
diff changeset
   169
    |,
3018
Edouard Tisserant
parents: 3012
diff changeset
   170
}