%3 ::xowiki::BootstrapNavbarDropdownMenuItem ::xowiki::BootstrapNavbarDropdownMenuItem render ::xowiki::MenuItem ::xowiki::MenuItem init render ::xowiki::BootstrapNavbarDropdownMenuItem->::xowiki::MenuItem ::xowiki::BootstrapNavbarModeButton ::xowiki::BootstrapNavbarModeButton js render ::xowiki::BootstrapNavbarModeButton->::xowiki::MenuItem ::xowiki::YUIMenuItem ::xowiki::YUIMenuItem render ::xowiki::YUIMenuItem->::xowiki::MenuItem ::xowiki::MenuComponent ::xowiki::MenuComponent html_id js_name ::xowiki::MenuItem->::xowiki::MenuComponent ::xo::tdom::Object ::xo::tdom::Object ::xowiki::MenuComponent->::xo::tdom::Object

Class ::xowiki::BootstrapNavbarModeButton

::xowiki::BootstrapNavbarModeButton[i] create ... \
           [ -CSSclass (default "checkbox-slider--b-flat") ] \
           [ -button button ] \
           [ -href (default "#") ] \
           [ -on:boolean (default "false") ] \
           [ -spanStyle (default "padding-left: 6px; padding-right: 6px;") ]

Class Relations

  • class: ::xo::tdom::Class[i]
  • superclass: ::xowiki::MenuItem[i]
::xo::tdom::Class create ::xowiki::BootstrapNavbarModeButton \
     -superclass ::xowiki::MenuItem

Methods (to be applied on instances)

  • CSSclass (setter)

  • button (setter)

  • href (setter)

  • js (scripted)

    #
    # In the current implementation, the page refreshes itself after
    # successful mode change. This could be made configurable.
    #
    html::script -type "text/javascript" -nonce [security::csp::nonce] {
      html::t {
        function mode_button_ajax_submit(form) {
          $.ajax({
            type: "POST",
            url: $(form).attr('action'),
            data: $(form).serialize(),
            success: function(msg) { location.reload(true); },
            error: function(){alert("failure");}
          });
        };
      }
      html t [subst {
        document.getElementById('${:id}').addEventListener('click', function (event) {
          mode_button_ajax_submit(this.form);
        });
      }]
    }
  • on (setter)

  • render (scripted)

    html::li {
      html::form -class "form" -method "POST" -action ${:href} {
        html::div -class "checkbox ${:CSSclass}" {
          html::label -class "checkbox-inline" {
            set checked [expr {${:on} ? {-checked true} : ""}]
            html::input -id ${:id} -class "debug form-control" -name "debug" -type "checkbox" {*}$checked
            html::span -style ${:spanStyle} {html::t ${:text}}
            html::input -name "modebutton" -type "hidden" -value "${:button}"
          }
        }
      }
      :js
    }
  • spanStyle (setter)