svghmi/widget_dropdown.ysl2
branchsvghmi
changeset 2927 23c35f3ba111
parent 2926 90f9d9782632
child 2928 c73d0b042ca8
equal deleted inserted replaced
2926:90f9d9782632 2927:23c35f3ba111
    18                         "eleven", "twelve", "thirteen", "fourteen", "fifteen"];
    18                         "eleven", "twelve", "thirteen", "fourteen", "fifteen"];
    19         //this.content = ["one", "two", "three", "four", "5", "6"];
    19         //this.content = ["one", "two", "three", "four", "5", "6"];
    20         this.menu_offset = 0;
    20         this.menu_offset = 0;
    21         this.lift = 0;
    21         this.lift = 0;
    22         this.opened = false;
    22         this.opened = false;
       
    23         this.bound_inhibit_click_elsewhere = this.inhibit_click_elsewhere.bind(this);
    23     },
    24     },
    24     on_selection_click: function(selection) {
    25     on_selection_click: function(selection) {
    25         console.log("selected "+selection);
    26         console.log("selected "+selection);
    26         this.close();
    27         this.close();
    27         this.set_selection(selection);
    28         this.set_selection(selection);
    70             }
    71             }
    71             count++;
    72             count++;
    72         }
    73         }
    73         return count;
    74         return count;
    74     },
    75     },
       
    76     inhibit_click_elsewhere: function(e) {
       
    77         console.log("inhibit", e);
       
    78         console.log(e.target.parentNode, this.text_elt);
       
    79         if(e.target.parentNode !== this.text_elt)
       
    80             e.stopPropagation();
       
    81     },
    75     close: function(){
    82     close: function(){
    76         this.reset_text();
    83         this.reset_text();
    77         this.reset_box();
    84         this.reset_box();
    78         this.element.appendChild(this.button_elt);
    85         this.element.appendChild(this.button_elt);
       
    86         document.removeEventListener("click", this.bound_inhibit_click_elsewhere, true);
    79         this.opened = false;
    87         this.opened = false;
    80     },
    88     },
    81     set_complete_text: function(){
    89     set_complete_text: function(){
    82         let spans = this.text_elt.children; 
    90         let spans = this.text_elt.children; 
    83         let c = 0;
    91         let c = 0;
   136         } else {
   144         } else {
   137             this.set_partial_text();
   145             this.set_partial_text();
   138         }
   146         }
   139         this.adjust_box_to_text();
   147         this.adjust_box_to_text();
   140         this.element.removeChild(this.button_elt);
   148         this.element.removeChild(this.button_elt);
   141         /* TODO disable interaction with background */
   149         // disable interaction with background
       
   150         document.addEventListener("click", this.bound_inhibit_click_elsewhere, true);
   142         this.opened = true;
   151         this.opened = true;
   143     },
   152     },
   144     reset_text: function(){
   153     reset_text: function(){
   145         let txt = this.text_elt; 
   154         let txt = this.text_elt; 
   146         let first = txt.firstElementChild;
   155         let first = txt.firstElementChild;