Edouard@2902: // widget_back.ysl2
Edouard@2779: 
edouard@3241: widget_desc("Back") {
edouard@3241:     longdesc
edouard@3241:     ||
edouard@3241:     Back widget brings focus back to previous page in history when clicked.
edouard@3241:     ||
edouard@3241: 
edouard@3241:     shortdesc > Jump to previous page
edouard@3241: }
edouard@3241: 
edouard@3232: widget_class("Back")
edouard@2958:     ||
edouard@2958:         on_click(evt) {
edouard@2958:             if(jump_history.length > 1){
Edouard@3653:                let page_name, index;
Edouard@3653:                do {
Edouard@3653:                    jump_history.pop(); // forget current page
Edouard@3653:                    if(jump_history.length == 0) return;
Edouard@3653:                    [page_name, index] = jump_history[jump_history.length-1];
Edouard@3653:                } while(page_name == "ScreenSaver") // never go back to ScreenSaver
edouard@2958:                switch_page(page_name, index);
edouard@2958:             }
edouard@2958:         }
edouard@2958:         init() {
Edouard@3654:             this.element.onclick = this.on_click.bind(this);
edouard@2958:         }
edouard@2958:     ||