3178 </xsl:text> |
3186 </xsl:text> |
3179 <xsl:text> grow_text(up_to) { |
3187 <xsl:text> grow_text(up_to) { |
3180 </xsl:text> |
3188 </xsl:text> |
3181 <xsl:text> let count = 1; |
3189 <xsl:text> let count = 1; |
3182 </xsl:text> |
3190 </xsl:text> |
3183 <xsl:text> let txt = this.text_elt; |
3191 <xsl:text> let txt = this.text_elt; |
3184 </xsl:text> |
3192 </xsl:text> |
3185 <xsl:text> let first = txt.firstElementChild; |
3193 <xsl:text> let first = txt.firstElementChild; |
3186 </xsl:text> |
3194 </xsl:text> |
3187 <xsl:text> // Real world (pixels) boundaries of current page |
3195 <xsl:text> // Real world (pixels) boundaries of current page |
3188 </xsl:text> |
3196 </xsl:text> |
3189 <xsl:text> let bounds = svg_root.getBoundingClientRect(); |
3197 <xsl:text> let bounds = svg_root.getBoundingClientRect(); |
3190 </xsl:text> |
3198 </xsl:text> |
3191 <xsl:text> this.lift = 0; |
3199 <xsl:text> this.lift = 0; |
3192 </xsl:text> |
3200 </xsl:text> |
3193 <xsl:text> while(count < up_to) { |
3201 <xsl:text> while(count < up_to) { |
3194 </xsl:text> |
3202 </xsl:text> |
3282 </xsl:text> |
3290 </xsl:text> |
3283 <xsl:text> close(){ |
3291 <xsl:text> close(){ |
3284 </xsl:text> |
3292 </xsl:text> |
3285 <xsl:text> // Stop hogging all click events |
3293 <xsl:text> // Stop hogging all click events |
3286 </xsl:text> |
3294 </xsl:text> |
|
3295 <xsl:text> svg_root.removeEventListener("pointerdown", numb_event, true); |
|
3296 </xsl:text> |
|
3297 <xsl:text> svg_root.removeEventListener("pointerup", numb_event, true); |
|
3298 </xsl:text> |
3287 <xsl:text> svg_root.removeEventListener("click", this.bound_close_on_click_elsewhere, true); |
3299 <xsl:text> svg_root.removeEventListener("click", this.bound_close_on_click_elsewhere, true); |
3288 </xsl:text> |
3300 </xsl:text> |
3289 <xsl:text> // Restore position and sixe of widget elements |
3301 <xsl:text> // Restore position and sixe of widget elements |
3290 </xsl:text> |
3302 </xsl:text> |
3291 <xsl:text> this.reset_text(); |
3303 <xsl:text> this.reset_text(); |
3292 </xsl:text> |
3304 </xsl:text> |
|
3305 <xsl:text> this.reset_clickables(); |
|
3306 </xsl:text> |
3293 <xsl:text> this.reset_box(); |
3307 <xsl:text> this.reset_box(); |
3294 </xsl:text> |
3308 </xsl:text> |
3295 <xsl:text> // Put the button back in place |
3309 <xsl:text> // Put the button back in place |
3296 </xsl:text> |
3310 </xsl:text> |
3297 <xsl:text> this.element.appendChild(this.button_elt); |
3311 <xsl:text> this.element.appendChild(this.button_elt); |
3304 </xsl:text> |
3318 </xsl:text> |
3305 <xsl:text> this.apply_cache(); |
3319 <xsl:text> this.apply_cache(); |
3306 </xsl:text> |
3320 </xsl:text> |
3307 <xsl:text> } |
3321 <xsl:text> } |
3308 </xsl:text> |
3322 </xsl:text> |
|
3323 <xsl:text> // Make item (text span) clickable by overlaying a rectangle on top of it |
|
3324 </xsl:text> |
|
3325 <xsl:text> make_clickable(span, func) { |
|
3326 </xsl:text> |
|
3327 <xsl:text> let txt = this.text_elt; |
|
3328 </xsl:text> |
|
3329 <xsl:text> let first = txt.firstElementChild; |
|
3330 </xsl:text> |
|
3331 <xsl:text> let original_text_y = this.text_bbox.y; |
|
3332 </xsl:text> |
|
3333 <xsl:text> let highlight = this.highlight_elt; |
|
3334 </xsl:text> |
|
3335 <xsl:text> let original_h_y = highlight.getBBox().y; |
|
3336 </xsl:text> |
|
3337 <xsl:text> let clickable = highlight.cloneNode(); |
|
3338 </xsl:text> |
|
3339 <xsl:text> let yoffset = span.getBBox().y - original_text_y; |
|
3340 </xsl:text> |
|
3341 <xsl:text> clickable.setAttribute("y", original_h_y + yoffset); |
|
3342 </xsl:text> |
|
3343 <xsl:text> clickable.style.pointerEvents = "bounding-box"; |
|
3344 </xsl:text> |
|
3345 <xsl:text> clickable.style.visibility = "hidden"; |
|
3346 </xsl:text> |
|
3347 <xsl:text> //clickable.onclick = () => alert("love JS"); |
|
3348 </xsl:text> |
|
3349 <xsl:text> clickable.onclick = func; |
|
3350 </xsl:text> |
|
3351 <xsl:text> this.element.appendChild(clickable); |
|
3352 </xsl:text> |
|
3353 <xsl:text> this.clickables.push(clickable) |
|
3354 </xsl:text> |
|
3355 <xsl:text> } |
|
3356 </xsl:text> |
|
3357 <xsl:text> reset_clickables() { |
|
3358 </xsl:text> |
|
3359 <xsl:text> while(this.clickables.length){ |
|
3360 </xsl:text> |
|
3361 <xsl:text> this.element.removeChild(this.clickables.pop()); |
|
3362 </xsl:text> |
|
3363 <xsl:text> } |
|
3364 </xsl:text> |
|
3365 <xsl:text> } |
|
3366 </xsl:text> |
3309 <xsl:text> // Set text content when content is smaller than menu (no scrolling) |
3367 <xsl:text> // Set text content when content is smaller than menu (no scrolling) |
3310 </xsl:text> |
3368 </xsl:text> |
3311 <xsl:text> set_complete_text(){ |
3369 <xsl:text> set_complete_text(){ |
3312 </xsl:text> |
3370 </xsl:text> |
3313 <xsl:text> let spans = this.text_elt.children; |
3371 <xsl:text> let spans = this.text_elt.children; |
3314 </xsl:text> |
3372 </xsl:text> |
3315 <xsl:text> let c = 0; |
3373 <xsl:text> let c = 0; |
3316 </xsl:text> |
3374 </xsl:text> |
3317 <xsl:text> for(let item of this.content){ |
3375 <xsl:text> for(let item of this.content){ |
3318 </xsl:text> |
3376 </xsl:text> |
3319 <xsl:text> let span=spans[c]; |
3377 <xsl:text> let span=spans[c]; |
3320 </xsl:text> |
3378 </xsl:text> |
3321 <xsl:text> span.textContent = item; |
3379 <xsl:text> span.textContent = item; |
3322 </xsl:text> |
3380 </xsl:text> |
3323 <xsl:text> span.onclick = (evt) => this.bound_on_selection_click(c); |
3381 <xsl:text> let sel = c; |
|
3382 </xsl:text> |
|
3383 <xsl:text> this.make_clickable(span, (evt) => this.bound_on_selection_click(sel)); |
3324 </xsl:text> |
3384 </xsl:text> |
3325 <xsl:text> c++; |
3385 <xsl:text> c++; |
3326 </xsl:text> |
3386 </xsl:text> |
3327 <xsl:text> } |
3387 <xsl:text> } |
3328 </xsl:text> |
3388 </xsl:text> |
3350 </xsl:text> |
3410 </xsl:text> |
3351 <xsl:text> if(forward){ |
3411 <xsl:text> if(forward){ |
3352 </xsl:text> |
3412 </xsl:text> |
3353 <xsl:text> this.menu_offset = Math.min( |
3413 <xsl:text> this.menu_offset = Math.min( |
3354 </xsl:text> |
3414 </xsl:text> |
3355 <xsl:text> contentlength - spans.length + 1, |
3415 <xsl:text> contentlength - spans.length + 1, |
3356 </xsl:text> |
3416 </xsl:text> |
3357 <xsl:text> this.menu_offset + spanslength); |
3417 <xsl:text> this.menu_offset + spanslength); |
3358 </xsl:text> |
3418 </xsl:text> |
3359 <xsl:text> }else{ |
3419 <xsl:text> }else{ |
3360 </xsl:text> |
3420 </xsl:text> |
3361 <xsl:text> this.menu_offset = Math.max( |
3421 <xsl:text> this.menu_offset = Math.max( |
3362 </xsl:text> |
3422 </xsl:text> |
3363 <xsl:text> 0, |
3423 <xsl:text> 0, |
3364 </xsl:text> |
3424 </xsl:text> |
3365 <xsl:text> this.menu_offset - spanslength); |
3425 <xsl:text> this.menu_offset - spanslength); |
3366 </xsl:text> |
3426 </xsl:text> |
3367 <xsl:text> } |
3427 <xsl:text> } |
3368 </xsl:text> |
3428 </xsl:text> |
|
3429 <xsl:text> this.reset_clickables(); |
|
3430 </xsl:text> |
3369 <xsl:text> this.set_partial_text(); |
3431 <xsl:text> this.set_partial_text(); |
3370 </xsl:text> |
3432 </xsl:text> |
3371 <xsl:text> } |
3433 <xsl:text> } |
3372 </xsl:text> |
3434 </xsl:text> |
3373 <xsl:text> // Setup partial view text content |
3435 <xsl:text> // Setup partial view text content |
3374 </xsl:text> |
3436 </xsl:text> |
3375 <xsl:text> // with jumps at first and last entry when appropriate |
3437 <xsl:text> // with jumps at first and last entry when appropriate |
3376 </xsl:text> |
3438 </xsl:text> |
3377 <xsl:text> set_partial_text(){ |
3439 <xsl:text> set_partial_text(){ |
3378 </xsl:text> |
3440 </xsl:text> |
3379 <xsl:text> let spans = this.text_elt.children; |
3441 <xsl:text> let spans = this.text_elt.children; |
3380 </xsl:text> |
3442 </xsl:text> |
3381 <xsl:text> let contentlength = this.content.length; |
3443 <xsl:text> let contentlength = this.content.length; |
3382 </xsl:text> |
3444 </xsl:text> |
3383 <xsl:text> let spanslength = spans.length; |
3445 <xsl:text> let spanslength = spans.length; |
3384 </xsl:text> |
3446 </xsl:text> |
3385 <xsl:text> let i = this.menu_offset, c = 0; |
3447 <xsl:text> let i = this.menu_offset, c = 0; |
3386 </xsl:text> |
3448 </xsl:text> |
|
3449 <xsl:text> let m = this.box_bbox; |
|
3450 </xsl:text> |
3387 <xsl:text> while(c < spanslength){ |
3451 <xsl:text> while(c < spanslength){ |
3388 </xsl:text> |
3452 </xsl:text> |
3389 <xsl:text> let span=spans[c]; |
3453 <xsl:text> let span=spans[c]; |
3390 </xsl:text> |
3454 </xsl:text> |
|
3455 <xsl:text> let onclickfunc; |
|
3456 </xsl:text> |
3391 <xsl:text> // backward jump only present if not exactly at start |
3457 <xsl:text> // backward jump only present if not exactly at start |
3392 </xsl:text> |
3458 </xsl:text> |
3393 <xsl:text> if(c == 0 && i != 0){ |
3459 <xsl:text> if(c == 0 && i != 0){ |
3394 </xsl:text> |
3460 </xsl:text> |
3395 <xsl:text> span.textContent = "↑ ↑ ↑"; |
3461 <xsl:text> span.textContent = "▲"; |
3396 </xsl:text> |
3462 </xsl:text> |
3397 <xsl:text> span.onclick = this.bound_on_backward_click; |
3463 <xsl:text> onclickfunc = this.bound_on_backward_click; |
|
3464 </xsl:text> |
|
3465 <xsl:text> let o = span.getBBox(); |
|
3466 </xsl:text> |
|
3467 <xsl:text> span.setAttribute("dx", (m.width - o.width)/2); |
3398 </xsl:text> |
3468 </xsl:text> |
3399 <xsl:text> // presence of forward jump when not right at the end |
3469 <xsl:text> // presence of forward jump when not right at the end |
3400 </xsl:text> |
3470 </xsl:text> |
3401 <xsl:text> }else if(c == spanslength-1 && i < contentlength - 1){ |
3471 <xsl:text> }else if(c == spanslength-1 && i < contentlength - 1){ |
3402 </xsl:text> |
3472 </xsl:text> |
3403 <xsl:text> span.textContent = "↓ ↓ ↓"; |
3473 <xsl:text> span.textContent = "▼"; |
3404 </xsl:text> |
3474 </xsl:text> |
3405 <xsl:text> span.onclick = this.bound_on_forward_click; |
3475 <xsl:text> onclickfunc = this.bound_on_forward_click; |
|
3476 </xsl:text> |
|
3477 <xsl:text> let o = span.getBBox(); |
|
3478 </xsl:text> |
|
3479 <xsl:text> span.setAttribute("dx", (m.width - o.width)/2); |
3406 </xsl:text> |
3480 </xsl:text> |
3407 <xsl:text> // otherwise normal content |
3481 <xsl:text> // otherwise normal content |
3408 </xsl:text> |
3482 </xsl:text> |
3409 <xsl:text> }else{ |
3483 <xsl:text> }else{ |
3410 </xsl:text> |
3484 </xsl:text> |
3411 <xsl:text> span.textContent = this.content[i]; |
3485 <xsl:text> span.textContent = this.content[i]; |
3412 </xsl:text> |
3486 </xsl:text> |
3413 <xsl:text> let sel = i; |
3487 <xsl:text> let sel = i; |
3414 </xsl:text> |
3488 </xsl:text> |
3415 <xsl:text> span.onclick = (evt) => this.bound_on_selection_click(sel); |
3489 <xsl:text> onclickfunc = (evt) => this.bound_on_selection_click(sel); |
|
3490 </xsl:text> |
|
3491 <xsl:text> span.removeAttribute("dx"); |
3416 </xsl:text> |
3492 </xsl:text> |
3417 <xsl:text> i++; |
3493 <xsl:text> i++; |
3418 </xsl:text> |
3494 </xsl:text> |
3419 <xsl:text> } |
3495 <xsl:text> } |
3420 </xsl:text> |
3496 </xsl:text> |
|
3497 <xsl:text> this.make_clickable(span, onclickfunc); |
|
3498 </xsl:text> |
3421 <xsl:text> c++; |
3499 <xsl:text> c++; |
3422 </xsl:text> |
3500 </xsl:text> |
3423 <xsl:text> } |
3501 <xsl:text> } |
3424 </xsl:text> |
3502 </xsl:text> |
3425 <xsl:text> } |
3503 <xsl:text> } |
3476 </xsl:text> |
3554 </xsl:text> |
3477 <xsl:text> this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |
3555 <xsl:text> this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); |
3478 </xsl:text> |
3556 </xsl:text> |
3479 <xsl:text> // disable interaction with background |
3557 <xsl:text> // disable interaction with background |
3480 </xsl:text> |
3558 </xsl:text> |
|
3559 <xsl:text> svg_root.addEventListener("pointerdown", numb_event, true); |
|
3560 </xsl:text> |
|
3561 <xsl:text> svg_root.addEventListener("pointerup", numb_event, true); |
|
3562 </xsl:text> |
3481 <xsl:text> svg_root.addEventListener("click", this.bound_close_on_click_elsewhere, true); |
3563 <xsl:text> svg_root.addEventListener("click", this.bound_close_on_click_elsewhere, true); |
3482 </xsl:text> |
3564 </xsl:text> |
3483 <xsl:text> // mark as open |
3565 <xsl:text> // mark as open |
3484 </xsl:text> |
3566 </xsl:text> |
3485 <xsl:text> this.opened = true; |
3567 <xsl:text> this.opened = true; |
3488 </xsl:text> |
3570 </xsl:text> |
3489 <xsl:text> // Put text element in normalized state |
3571 <xsl:text> // Put text element in normalized state |
3490 </xsl:text> |
3572 </xsl:text> |
3491 <xsl:text> reset_text(){ |
3573 <xsl:text> reset_text(){ |
3492 </xsl:text> |
3574 </xsl:text> |
3493 <xsl:text> let txt = this.text_elt; |
3575 <xsl:text> let txt = this.text_elt; |
3494 </xsl:text> |
3576 </xsl:text> |
3495 <xsl:text> let first = txt.firstElementChild; |
3577 <xsl:text> let first = txt.firstElementChild; |
3496 </xsl:text> |
3578 </xsl:text> |
3497 <xsl:text> // remove attribute eventually added to first text line while opening |
3579 <xsl:text> // remove attribute eventually added to first text line while opening |
3498 </xsl:text> |
3580 </xsl:text> |
3499 <xsl:text> first.removeAttribute("onclick"); |
3581 <xsl:text> first.onclick = null; |
3500 </xsl:text> |
3582 </xsl:text> |
3501 <xsl:text> first.removeAttribute("dy"); |
3583 <xsl:text> first.removeAttribute("dy"); |
3502 </xsl:text> |
3584 </xsl:text> |
|
3585 <xsl:text> first.removeAttribute("dx"); |
|
3586 </xsl:text> |
3503 <xsl:text> // keep only the first line of text |
3587 <xsl:text> // keep only the first line of text |
3504 </xsl:text> |
3588 </xsl:text> |
3505 <xsl:text> for(let span of Array.from(txt.children).slice(1)){ |
3589 <xsl:text> for(let span of Array.from(txt.children).slice(1)){ |
3506 </xsl:text> |
3590 </xsl:text> |
3507 <xsl:text> txt.removeChild(span) |
3591 <xsl:text> txt.removeChild(span) |
3554 <xsl:template mode="widget_defs" match="widget[@type='DropDown']"> |
3638 <xsl:template mode="widget_defs" match="widget[@type='DropDown']"> |
3555 <xsl:param name="hmi_element"/> |
3639 <xsl:param name="hmi_element"/> |
3556 <xsl:call-template name="defs_by_labels"> |
3640 <xsl:call-template name="defs_by_labels"> |
3557 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3641 <xsl:with-param name="hmi_element" select="$hmi_element"/> |
3558 <xsl:with-param name="labels"> |
3642 <xsl:with-param name="labels"> |
3559 <xsl:text>text box button</xsl:text> |
3643 <xsl:text>text box button highlight</xsl:text> |
3560 </xsl:with-param> |
3644 </xsl:with-param> |
3561 </xsl:call-template> |
3645 </xsl:call-template> |
3562 <xsl:text> // It is assumed that list content conforms to Array interface. |
3646 <xsl:text> // It is assumed that list content conforms to Array interface. |
3563 </xsl:text> |
3647 </xsl:text> |
3564 <xsl:text> content: [ |
3648 <xsl:text> content: [ |