Merge pull request #8399 from shivapoudel/tweak-meta
Tweaks Meta boxes Scripts
This commit is contained in:
commit
05ca8898fe
|
@ -1,9 +1,8 @@
|
|||
/*global woocommerce_admin_meta_boxes */
|
||||
jQuery( function ( $ ) {
|
||||
|
||||
// run tip tip
|
||||
// Run tipTip
|
||||
function runTipTip() {
|
||||
// remove any lingering tooltips
|
||||
// Remove any lingering tooltips
|
||||
$( '#tiptip_holder' ).removeAttr( 'style' );
|
||||
$( '#tiptip_arrow' ).removeAttr( 'style' );
|
||||
$( '.tips' ).tipTip({
|
||||
|
@ -16,65 +15,67 @@ jQuery( function ( $ ) {
|
|||
|
||||
runTipTip();
|
||||
|
||||
// Allow tabbing
|
||||
$('#titlediv #title').keyup(function( event ) {
|
||||
// Allow Tabbing
|
||||
$( '#titlediv #title' ).keyup( function( event ) {
|
||||
var code = event.keyCode || event.which;
|
||||
|
||||
if ( code == '9' && $('#woocommerce-coupon-description').size() > 0 ) {
|
||||
// Tab key
|
||||
if ( code === '9' && $( '#woocommerce-coupon-description' ).size() > 0 ) {
|
||||
event.stopPropagation();
|
||||
$('#woocommerce-coupon-description').focus();
|
||||
$( '#woocommerce-coupon-description' ).focus();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(function(){
|
||||
$('.wc-metabox > h3').click( function(event){
|
||||
$( function() {
|
||||
$( '.wc-metabox > h3' ).click( function() {
|
||||
$( this ).parent( '.wc-metabox' ).toggleClass( 'closed' ).toggleClass( 'open' );
|
||||
});
|
||||
});
|
||||
|
||||
// TABS
|
||||
$('ul.wc-tabs').show();
|
||||
$('div.panel-wrap').each(function(){
|
||||
$(this).find('div.panel:not(:first)').hide();
|
||||
});
|
||||
$('ul.wc-tabs a').click(function(){
|
||||
var panel_wrap = $(this).closest('div.panel-wrap');
|
||||
$('ul.wc-tabs li', panel_wrap).removeClass('active');
|
||||
$(this).parent().addClass('active');
|
||||
$('div.panel', panel_wrap).hide();
|
||||
$( $(this).attr('href') ).show();
|
||||
return false;
|
||||
});
|
||||
$('ul.wc-tabs li:visible').eq(0).find('a').click();
|
||||
|
||||
$( document.body ).on( 'wc-init-datepickers', function() {
|
||||
$( ".date-picker-field, .date-picker" ).datepicker({
|
||||
dateFormat: "yy-mm-dd",
|
||||
numberOfMonths: 1,
|
||||
showButtonPanel: true,
|
||||
// Tabbed Panels
|
||||
$( document.body ).on( 'wc-init-tabbed-panels', function() {
|
||||
$( 'ul.wc-tabs' ).show();
|
||||
$( 'ul.wc-tabs a' ).click( function() {
|
||||
var panel_wrap = $( this ).closest( 'div.panel-wrap' );
|
||||
$( 'ul.wc-tabs li', panel_wrap ).removeClass( 'active' );
|
||||
$( this ).parent().addClass( 'active' );
|
||||
$( 'div.panel', panel_wrap ).hide();
|
||||
$( $( this ).attr( 'href' ) ).show();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$( 'div.panel-wrap' ).each( function() {
|
||||
$( this ).find( 'ul.wc-tabs li' ).eq( 0 ).find( 'a' ).click();
|
||||
});
|
||||
}).trigger( 'wc-init-tabbed-panels' );
|
||||
|
||||
$( document.body ).trigger( 'wc-init-datepickers' );
|
||||
// Date Picker
|
||||
$( document.body ).on( 'wc-init-datepickers', function() {
|
||||
$( '.date-picker-field, .date-picker' ).datepicker({
|
||||
dateFormat: 'yy-mm-dd',
|
||||
numberOfMonths: 1,
|
||||
showButtonPanel: true
|
||||
});
|
||||
}).trigger( 'wc-init-datepickers' );
|
||||
|
||||
// META BOXES - Open/close
|
||||
$('.wc-metaboxes-wrapper').on('click', '.wc-metabox h3', function(event){
|
||||
// Meta-Boxes - Open/close
|
||||
$( '.wc-metaboxes-wrapper' ).on( 'click', '.wc-metabox h3', function( event ) {
|
||||
// If the user clicks on some form input inside the h3, like a select list (for variations), the box should not be toggled
|
||||
if ($(event.target).filter(':input, option').length) return;
|
||||
if ( $( event.target ).filter( ':input, option' ).length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(this).next('.wc-metabox-content').stop().slideToggle();
|
||||
$( this ).next( '.wc-metabox-content' ).stop().slideToggle();
|
||||
})
|
||||
.on('click', '.expand_all', function(event){
|
||||
$(this).closest('.wc-metaboxes-wrapper').find('.wc-metabox > .wc-metabox-content').show();
|
||||
.on( 'click', '.expand_all', function() {
|
||||
$( this ).closest( '.wc-metaboxes-wrapper' ).find( '.wc-metabox > .wc-metabox-content' ).show();
|
||||
return false;
|
||||
})
|
||||
.on('click', '.close_all', function(event){
|
||||
$(this).closest('.wc-metaboxes-wrapper').find('.wc-metabox > .wc-metabox-content').hide();
|
||||
.on( 'click', '.close_all', function() {
|
||||
$( this ).closest( '.wc-metaboxes-wrapper' ).find( '.wc-metabox > .wc-metabox-content' ).hide();
|
||||
return false;
|
||||
});
|
||||
$('.wc-metabox.closed').each(function(){
|
||||
$(this).find('.wc-metabox-content').hide();
|
||||
$( '.wc-metabox.closed' ).each( function() {
|
||||
$( this ).find( '.wc-metabox-content' ).hide();
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue