v1.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * 切换选中的交互。
  3. * Toggle the display of checked interaction.
  4. *
  5. * @access public
  6. * @return void
  7. */
  8. window.toggleChecked = function()
  9. {
  10. if($(this).data('type') == 'radio')
  11. {
  12. if($(this).find('input').prop('checked')) return;
  13. $(this).find('input').prop('checked', !$(this).find('input').prop('checked'));
  14. $(this).closest('.think-check-list').find('.item-control').removeClass('is-checked');
  15. $(this).toggleClass('is-checked', $(this).find('input').is(':checked'));
  16. $(this).closest('.think-check-list').find('.radio-primary').removeClass('checked');
  17. $(this).find('.radio-primary').toggleClass('checked');
  18. }
  19. else
  20. {
  21. $(this).find('input').prop('checked', !$(this).find('input').prop('checked'));
  22. $(this).find('.checkbox-primary').toggleClass('checked', $(this).find('input').is(':checked'));
  23. $(this).toggleClass('is-checked', $(this).find('input').is(':checked'));
  24. }
  25. /* 如果当前项是其他的话,选中时展示输入框,类型为单选时,选择其他项隐藏输入框,多选时取消选中隐藏输入框。*/
  26. /* If the current item is Other, display the input box when selected. If the type is Single Choice, select Other to hide the input box. If Multiple Choice, uncheck the hide input box. */
  27. if($(this).hasClass('has-input'))
  28. {
  29. $(this).find('textarea').toggleClass('hidden', !$(this).find('input').prop('checked'));
  30. if($(this).find('input').prop('checked')) $(this).find('textarea').trigger('focus');
  31. }
  32. else
  33. {
  34. if($(this).data('type') == 'radio')$(this).closest('.think-check-list').find('.has-input textarea').addClass('hidden');
  35. }
  36. }
  37. /**
  38. * 输入其他内容。
  39. * Input other content.
  40. *
  41. * @access public
  42. * @return void
  43. */
  44. window.inputOther = function()
  45. {
  46. this.style.height = 'auto';
  47. this.style.height = (this.scrollHeight > 96 ? 96 : this.scrollHeight) + 'px';
  48. }