svghmi/widget_back.ysl2
author Edouard Tisserant
Thu, 04 Jun 2020 11:14:21 +0200
branchsvghmi
changeset 2980 2a21d6060d64
parent 2958 895d3f2b1786
child 3232 7bdb766c2a4d
permissions -rw-r--r--
SVGHMI: add "unsubscribable" property to widgets in order to generalize what already happens for jump buttons.
In most cases jump buttons do not really subscribe to pointed HMI variable, path is given as a relative page jump path. When widget.unsubscribable is set to true, no subscription is made on page switch, but still offset is updated.
This fixes bug happening on relative jump buttons without "disabled" element where offset did not change on relative page switch.
2902
1fcb50af0335 SVGHMI: added Back widget.
Edouard Tisserant
parents: 2901
diff changeset
     1
// widget_back.ysl2
2779
75c6a31caca6 SVGHMI: Work In Progress : fixed pointer types in ctypes interface, cleaned up server startup and cleanup code, changed document type to XHTML, cleaner JS script : encapsulated in a function and in CDATA.
Edouard Tisserant
parents: 2763
diff changeset
     2
2958
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     3
template "widget[@type='Back']", mode="widget_class"
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     4
    ||
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     5
    class BackWidget extends Widget{
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     6
        on_click(evt) {
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     7
            if(jump_history.length > 1){
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     8
               jump_history.pop();
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
     9
               let [page_name, index] = jump_history.pop();
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    10
               switch_page(page_name, index);
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    11
            }
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    12
        }
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    13
        init() {
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    14
            this.element.setAttribute("onclick", "hmi_widgets['"+this.element_id+"'].on_click(evt)");
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    15
        }
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    16
    }
895d3f2b1786 SVGHMI: Back button updated to class style
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2912
diff changeset
    17
    ||