main.min.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ;
  2. jQuery( function() {
  3. // 提示
  4. if($('[data-toggle="tooltip"]')[0]) {
  5. $('[data-toggle="tooltip"]').tooltip({
  6. "container" : 'body',
  7. });
  8. }
  9. // 弹出框
  10. if($('[data-toggle="popover"]')[0]) {
  11. $('[data-toggle="popover"]').popover();
  12. }
  13. // 标签
  14. $('.js-tags-input').each(function() {
  15. var $this = $(this);
  16. $this.tagsInput({
  17. height: $this.data('height') ? $this.data('height') : '38px',
  18. width: '100%',
  19. defaultText: $this.attr("placeholder"),
  20. removeWithBackspace: true,
  21. delimiter: [',']
  22. });
  23. });
  24. // 时间选择
  25. jQuery('.js-datetimepicker').each(function() {
  26. var $input = jQuery(this);
  27. $input.datetimepicker({
  28. format: $input.data('format') ? $input.data('format') : false,
  29. useCurrent: $input.data('use-current') ? $input.data('use-current') : false,
  30. locale: moment.locale('' + ($input.data('locale') ? $input.data('locale') : '') + ''),
  31. showTodayButton: $input.data('show-today-button') ? $input.data('show-today-button') : false,
  32. showClear: $input.data('show-clear') ? $input.data('show-clear') : false,
  33. showClose: $input.data('show-close') ? $input.data('show-close') : false,
  34. sideBySide: $input.data('side-by-side') ? $input.data('side-by-side') : false,
  35. inline: $input.data('inline') ? $input.data('inline') : false,
  36. });
  37. });
  38. // 日期选择
  39. jQuery('.js-datepicker').each(function() {
  40. var options = {
  41. weekStart: 1,
  42. autoclose: typeof($(this).data('auto-close')) != 'undefined' ? $(this).data('auto-close') : true,
  43. language: 'zh-CN', // 默认简体中文
  44. multidateSeparator: ', ', // 默认多个日期用,分隔
  45. format: $(this).data('date-format') ? $(this).data('date-format') : 'yyyy-mm-dd',
  46. };
  47. if ( $(this).prop("tagName") != 'INPUT' ) {
  48. options.inputs = [$(this).find('input:first'), $(this).find('input:last')];
  49. }
  50. $(this).datepicker(options);
  51. });
  52. // 颜色选取
  53. jQuery('.js-colorpicker').each(function() {
  54. var $colorpicker = jQuery(this);
  55. var $colorpickerMode = $colorpicker.data('colorpicker-mode') ? $colorpicker.data('colorpicker-mode') : 'hex';
  56. var $colorpickerinline = $colorpicker.data('colorpicker-inline') ? true: false;
  57. $colorpicker.colorpicker({
  58. 'format': $colorpickerMode,
  59. 'inline': $colorpickerinline
  60. });
  61. });
  62. // 复选框全选
  63. $("#check-all").change(function () {
  64. $("input[type='checkbox']").prop('checked', $(this).prop("checked"));
  65. });
  66. // iframe打开tab
  67. $(document).on('click', '.js-create-tab', function() {
  68. parent.$(parent.document).data('multitabs').create({
  69. iframe : true,
  70. title : $(this).data('title') ? $(this).data('title') : '标题',
  71. url : $(this).data('url') ? $(this).data('url') : 'lyear-main.html'
  72. }, true);
  73. });
  74. });