colorpicker.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {% assign id = include.id | default: 'default' %}
  2. {% assign alpha = include.alpha | default: false %}
  3. {% assign format = include.format | default: false %}
  4. <input type="text" class="form-control d-block{% if include.class %} {{ include.class }}{% endif %}" id="colorpicker-{{ id }}" value="{{ include.value }}" />
  5. {% capture_global scripts %}
  6. <script>
  7. // @formatter:off
  8. document.addEventListener("DOMContentLoaded", function () {
  9. {% if jekyll.environment == 'development' %}
  10. window.tabler_colorpicker = window.tabler_colorpicker || {};
  11. {% endif %}
  12. window.Coloris && ({% if jekyll.environment == 'development' %}window.tabler_colorpicker["colorpicker-{{ id }}"] = {% endif %}Coloris({
  13. el: "#colorpicker-{{ id }}",
  14. selectInput: false,
  15. alpha: {% if alpha %}true{% else %}false{% endif %},
  16. {% if format %}format: "{{ format }}",{% endif %}
  17. {% if include['swatches-only'] %}swatchesOnly: true,{% endif %}
  18. swatches: [
  19. "#0054a6",
  20. "#45aaf2",
  21. "#6574cd",
  22. "#a55eea",
  23. "#f66d9b",
  24. "#fa4654",
  25. "#fd9644",
  26. "#f1c40f",
  27. "#7bd235",
  28. "#5eba00",
  29. "#2bcbba",
  30. "#17a2b8",
  31. ],
  32. }))
  33. })
  34. // @formatter:on
  35. </script>
  36. {% endcapture_global %}