ui_form_one.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. +function ($) {
  2. $.fn.formFocus = function (){
  3. var $this = $(this);
  4. if($this.parents('.input-group').find('span.input-group-addon').length>0 && $this.attr('data-form')=="focus"){
  5. $span = $this.parents('.input-group').find('span.input-group-addon');
  6. $span.addClass('focus');
  7. $this.on('blur',function(){
  8. $span.removeClass('focus');
  9. });
  10. }
  11. if($this.attr('data-form')=="clear"){
  12. var $clear = $('<div class="input-clear"><span class="close"></span></div>').appendTo($this.parents('.input-group'));
  13. $this.on('blur',function(){
  14. setTimeout(function(){$clear.remove();},200)
  15. });
  16. $clear.on('click',function(){
  17. $this.val('').focus();
  18. })
  19. }
  20. }
  21. $(document).on('focus','input[data-form="focus"],input[data-form="clear"]',function(){
  22. $(this).formFocus();
  23. });
  24. // data-checked="true"
  25. $(document).on('click','div.input-group-pack[data-checked="true"]',function(){
  26. var $el=$(this),
  27. $input=$el.children('input');
  28. if($input.attr("checked")){
  29. return;
  30. }else{
  31. $el.toggleClass('checked');
  32. $input.attr("checked",true);
  33. }
  34. alert(2)
  35. });
  36. }(jQuery);