Нет описания

meta-boxes.js 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. jQuery( function ( $ ) {
  2. // Run tipTip
  3. function runTipTip() {
  4. // Remove any lingering tooltips
  5. $( '#tiptip_holder' ).removeAttr( 'style' );
  6. $( '#tiptip_arrow' ).removeAttr( 'style' );
  7. $( '.tips' ).tipTip({
  8. 'attribute': 'data-tip',
  9. 'fadeIn': 50,
  10. 'fadeOut': 50,
  11. 'delay': 200,
  12. 'keepAlive': true
  13. });
  14. }
  15. runTipTip();
  16. $( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox > h3', function() {
  17. var metabox = $( this ).parent( '.wc-metabox' );
  18. if ( metabox.hasClass( 'closed' ) ) {
  19. metabox.removeClass( 'closed' );
  20. } else {
  21. metabox.addClass( 'closed' );
  22. }
  23. if ( metabox.hasClass( 'open' ) ) {
  24. metabox.removeClass( 'open' );
  25. } else {
  26. metabox.addClass( 'open' );
  27. }
  28. });
  29. // Tabbed Panels
  30. $( document.body ).on( 'wc-init-tabbed-panels', function() {
  31. $( 'ul.wc-tabs' ).show();
  32. $( 'ul.wc-tabs a' ).on( 'click', function( e ) {
  33. e.preventDefault();
  34. var panel_wrap = $( this ).closest( 'div.panel-wrap' );
  35. $( 'ul.wc-tabs li', panel_wrap ).removeClass( 'active' );
  36. $( this ).parent().addClass( 'active' );
  37. $( 'div.panel', panel_wrap ).hide();
  38. $( $( this ).attr( 'href' ) ).show();
  39. });
  40. $( 'div.panel-wrap' ).each( function() {
  41. $( this ).find( 'ul.wc-tabs li' ).eq( 0 ).find( 'a' ).trigger( 'click' );
  42. });
  43. }).trigger( 'wc-init-tabbed-panels' );
  44. // Date Picker
  45. $( document.body ).on( 'wc-init-datepickers', function() {
  46. $( '.date-picker-field, .date-picker' ).datepicker({
  47. dateFormat: 'yy-mm-dd',
  48. numberOfMonths: 1,
  49. showButtonPanel: true
  50. });
  51. }).trigger( 'wc-init-datepickers' );
  52. // Meta-Boxes - Open/close
  53. $( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox h3', function( event ) {
  54. // If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled
  55. if ( $( event.target ).filter( ':input, option, .sort' ).length ) {
  56. return;
  57. }
  58. $( this ).next( '.wc-metabox-content' ).stop().slideToggle();
  59. })
  60. .on( 'click', '.expand_all', function() {
  61. $( this ).closest( '.wc-metaboxes-wrapper' ).find( '.wc-metabox > .wc-metabox-content' ).show();
  62. return false;
  63. })
  64. .on( 'click', '.close_all', function() {
  65. $( this ).closest( '.wc-metaboxes-wrapper' ).find( '.wc-metabox > .wc-metabox-content' ).hide();
  66. return false;
  67. });
  68. $( '.wc-metabox.closed' ).each( function() {
  69. $( this ).find( '.wc-metabox-content' ).hide();
  70. });
  71. });