Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

floatinglabel.js 1.7KB

123456789101112131415161718192021222324252627282930313233
  1. $(function () {
  2. $("body").on("input propertychange", ".floating-label-form-group", function (e) {
  3. //$(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
  4. }).on("focus", ".floating-label-form-group", function () {
  5. //$(this).addClass("floating-label-form-group-with-focus");
  6. $(this).addClass("floating-label-form-group-with-value");
  7. }).on("blur", ".floating-label-form-group", function () {
  8. //$(this).removeClass("floating-label-form-group-with-focus");
  9. //$(this).removeClass("floating-label-form-group-with-value");
  10. //if ($('.floating-label-control').val().length == 0) {
  11. // $(this).removeClass("floating-label-form-group-with-value");
  12. //}
  13. if ($(this).find('.floating-label-control').val() != "") {
  14. $(this).addClass("floating-label-form-group-with-value");
  15. }
  16. else if ($(this).find('.floating-label-control').val() == "") {
  17. $(this).removeClass("floating-label-form-group-with-value");
  18. }
  19. }).on("focusin", ".floating-label-control", function () {
  20. $(this).attr('placeholder', $(this).data('placeholder'));
  21. }).on("focusout", ".floating-label-control", function () {
  22. $(this).attr('placeholder', $(this).data('label'));
  23. });
  24. });
  25. var _floatingLabelHelper = {
  26. init: function () {
  27. $('div.floating-label-form-group > input,textarea,select').each(function () {
  28. if ($(this).val() && !$(this).parent(".floating-label-form-group").hasClass("floating-label-form-group-with-value")) {
  29. $(this).parent(".floating-label-form-group").addClass("floating-label-form-group-with-value");
  30. }
  31. });
  32. }
  33. }