svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2977 82f062408e70
parent 2976 99c4521bb844
child 2979 9442f6a6449e
equal deleted inserted replaced
2976:99c4521bb844 2977:82f062408e70
  2727 </xsl:text>
  2727 </xsl:text>
  2728     </xsl:for-each>
  2728     </xsl:for-each>
  2729     <xsl:text>    ],
  2729     <xsl:text>    ],
  2730 </xsl:text>
  2730 </xsl:text>
  2731   </xsl:template>
  2731   </xsl:template>
       
  2732   <xsl:template mode="widget_defs" match="widget[@type='ToggleButton']">
       
  2733     <xsl:param name="hmi_element"/>
       
  2734     <xsl:call-template name="defs_by_labels">
       
  2735       <xsl:with-param name="hmi_element" select="$hmi_element"/>
       
  2736       <xsl:with-param name="labels">
       
  2737         <xsl:text>active inactive</xsl:text>
       
  2738       </xsl:with-param>
       
  2739     </xsl:call-template>
       
  2740     <xsl:text>    frequency: 5,
       
  2741 </xsl:text>
       
  2742     <xsl:text>    state: 0,
       
  2743 </xsl:text>
       
  2744     <xsl:text>    dispatch: function(value) {
       
  2745 </xsl:text>
       
  2746     <xsl:text>        this.state = value;
       
  2747 </xsl:text>
       
  2748     <xsl:text>        if (this.state) {
       
  2749 </xsl:text>
       
  2750     <xsl:text>            this.active_elt.setAttribute("style", this.active_style);
       
  2751 </xsl:text>
       
  2752     <xsl:text>            this.inactive_elt.setAttribute("style", "display:none");
       
  2753 </xsl:text>
       
  2754     <xsl:text>            this.state = 0;
       
  2755 </xsl:text>
       
  2756     <xsl:text>        } else {
       
  2757 </xsl:text>
       
  2758     <xsl:text>            this.inactive_elt.setAttribute("style", this.inactive_style);
       
  2759 </xsl:text>
       
  2760     <xsl:text>            this.active_elt.setAttribute("style", "display:none");
       
  2761 </xsl:text>
       
  2762     <xsl:text>            this.state = 1;
       
  2763 </xsl:text>
       
  2764     <xsl:text>        }
       
  2765 </xsl:text>
       
  2766     <xsl:text>    },
       
  2767 </xsl:text>
       
  2768     <xsl:text>    on_click: function(evt) {
       
  2769 </xsl:text>
       
  2770     <xsl:text>        change_hmi_value(this.indexes[0], "="+this.state);
       
  2771 </xsl:text>
       
  2772     <xsl:text>    },
       
  2773 </xsl:text>
       
  2774     <xsl:text>    active_style: undefined,
       
  2775 </xsl:text>
       
  2776     <xsl:text>    inactive_style: undefined,
       
  2777 </xsl:text>
       
  2778     <xsl:text>    init: function() {
       
  2779 </xsl:text>
       
  2780     <xsl:text>        this.active_style = this.active_elt.style.cssText;
       
  2781 </xsl:text>
       
  2782     <xsl:text>        this.inactive_style = this.inactive_elt.style.cssText;
       
  2783 </xsl:text>
       
  2784     <xsl:text>        this.element.setAttribute("onclick", "hmi_widgets['</xsl:text>
       
  2785     <xsl:value-of select="$hmi_element/@id"/>
       
  2786     <xsl:text>'].on_click(evt)");
       
  2787 </xsl:text>
       
  2788     <xsl:text>    },
       
  2789 </xsl:text>
       
  2790   </xsl:template>
  2732   <xsl:template match="/">
  2791   <xsl:template match="/">
  2733     <xsl:comment>
  2792     <xsl:comment>
  2734       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  2793       <xsl:text>Made with SVGHMI. https://beremiz.org</xsl:text>
  2735     </xsl:comment>
  2794     </xsl:comment>
  2736     <xsl:comment>
  2795     <xsl:comment>