Sha256: b5617154636c9bbec07156907e6c115a6293ba8088e2ce770dd0f07944df43c7

Contents?: true

Size: 1.59 KB

Versions: 536

Compression:

Stored size: 1.59 KB

Contents

<%= content_tag(:li,
    aria: object.aria,
    class: object.classname,
    data: object.data,
    id: object.id,
    **combined_html_options) do %>
  <% if object.variant == "radio"%>
    <%= pb_rails("radio", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% else %>
    <%= pb_rails("checkbox", props: { text: object.text, checked: object.checked, input_options: object.input_options } ) %>
    <% if content.present? %>
      <%= content %>
    <% end %>
  <% end %>

  <% if object.variant == "checkbox"%>
    <script>
      var checkboxElement = document.querySelector("#<%=object.id%> input[type=checkbox]")
      
      checkboxElement.addEventListener("change", (evt) => {
        var listItemElement = document.querySelector("#<%=object.id%>")
        
        if (evt.target.checked) {
          listItemElement.classList.add("checked_item");
        } else {
          listItemElement.classList.remove("checked_item")
        }
      })
    </script>
  <% else %>
    <script>
      var radioElement = document.querySelector("#<%=object.id%> input[type=radio]")

      radioElement.addEventListener("change", () => {        
        var radios = radioElement.closest("ul").querySelectorAll("input[type=radio]")
        
        radios.forEach((radio) => {
          if (radio.checked) {
            radio.closest("li").classList.add("checked_item");
          } else {
            radio.closest("li").classList.remove("checked_item")
          }
        });
      })
    </script>
  <% end %>
<% end %>

Version data entries

536 entries across 536 versions & 1 rubygems

Version Path
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5413 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.5 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.play1724darkmodeauditmap5409 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PLAY1720phonenumberinputformatAsYouType5377 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.play17725374 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.play17725372 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.4 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.hfhbrakemanplaybook5370 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.responsivetablerails5364 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.responsivetablerails5362 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PBNTR769sticky5359 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PBNTR573datepickerinvestigation5355 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5341 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5340 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.11.1.pre.alpha.PLAY1750pbcontenttagkitbutton5339 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.3 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.2 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.1 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.12.0.pre.rc.0 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5315 app/pb_kits/playbook/pb_selectable_list/selectable_list_item.html.erb