| 1 |
/*! |
| 2 |
|
| 3 |
========================================================= |
| 4 |
* WPERP | Accounting - v1.0.0 |
| 5 |
========================================================= |
| 6 |
|
| 7 |
* Product Page: https://wperp.com |
| 8 |
* Copyright 2018 Creative Tim (https://wperp.com) |
| 9 |
|
| 10 |
========================================================= |
| 11 |
|
| 12 |
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 13 |
|
| 14 |
*/ |
| 15 |
|
| 16 |
|
| 17 |
$(document).ready(function() { |
| 18 |
|
| 19 |
// handle dropdown menu |
| 20 |
$('.dropdown-trigger').click(function( e ) { |
| 21 |
e.preventDefault(); |
| 22 |
e.stopPropagation(); |
| 23 |
var parentElement = $(this).parents('.wperp-has-dropdown'); |
| 24 |
// $('.wperp-has-dropdown').removeClass('dropdown-opened'); |
| 25 |
parentElement.toggleClass('dropdown-opened'); |
| 26 |
|
| 27 |
// if( parentElement.hasClass('wperp-open') ){ |
| 28 |
// parentElement.find('.wperp-dropdown-toggle').attr('aria-expanded', 'true'); |
| 29 |
// }else { |
| 30 |
// parentElement.find('.wperp-dropdown-toggle').attr('aria-expanded', 'false'); |
| 31 |
// } |
| 32 |
}); |
| 33 |
|
| 34 |
$(document).on("click", function(event){ |
| 35 |
if( event.target.classList.contains('dropdown-menu') == false ) { |
| 36 |
$('.wperp-has-dropdown').removeClass('dropdown-opened'); |
| 37 |
} |
| 38 |
}); |
| 39 |
|
| 40 |
// active select2 |
| 41 |
$('.wperp-is-select2').each(function(){ |
| 42 |
$(this).select2(); |
| 43 |
}); |
| 44 |
|
| 45 |
$('.delete-row').click(function(){ |
| 46 |
var confirmMessage = confirm("Press a button!"); |
| 47 |
if ( confirmMessage ) { |
| 48 |
$(this).parents('tr').remove(); |
| 49 |
} |
| 50 |
}); |
| 51 |
|
| 52 |
|
| 53 |
/* $('.option-dropdown').click(function (e) { |
| 54 |
e.preventDefault(); |
| 55 |
|
| 56 |
// $(this).attr('tabindex', 1).focus(); |
| 57 |
$(this).toggleClass('active'); |
| 58 |
$(this).find('.dropdown-content').slideToggle(300); |
| 59 |
}); |
| 60 |
$('.option-dropdown').focusout(function () { |
| 61 |
$(this).removeClass('active'); |
| 62 |
$(this).find('.dropdown-content').slideUp(300); |
| 63 |
}); |
| 64 |
$('.option-dropdown .dropdown-content li a').click(function () { |
| 65 |
$(this).parents('.option-dropdown').find('span').html($(this).html()); |
| 66 |
$(this).parents('.option-dropdown').find('input').attr('value', $(this).attr('id')); |
| 67 |
});*/ |
| 68 |
/*End Dropdown Menu*/ |
| 69 |
|
| 70 |
|
| 71 |
/*$('.dropdown-content li').click(function () { |
| 72 |
var input = '<strong>' + $(this).parents('.option-dropdown').find('input').val() + '</strong>', |
| 73 |
msg = '<span class="msg">Hidden input value: '; |
| 74 |
$('.msg').html(msg + input + '</span>'); |
| 75 |
});*/ |
| 76 |
|
| 77 |
|
| 78 |
// Toggle list table rows on small screens |
| 79 |
$( 'tbody' ).on( 'click', '.wperp-toggle-row', function() { |
| 80 |
$( this ).closest( 'tr' ).toggleClass( 'is-row-expanded' ); |
| 81 |
}); |
| 82 |
|
| 83 |
$('#cb-select-all').click(function() { |
| 84 |
var isChecked = $(this).prop("checked"); |
| 85 |
|
| 86 |
$('.wperp-table tbody tr:has(th)').find('input[type="checkbox"]').prop('checked', isChecked); |
| 87 |
|
| 88 |
$(this).closest('.table-container').toggleClass('bulk-actions').find('.bulk-action').toggle(); |
| 89 |
|
| 90 |
}); |
| 91 |
|
| 92 |
$('tbody .form-check-input, thead .form-check-input').on('change', function(){ |
| 93 |
if ($('.wperp-table tbody tr th input:checked').length > 1) { |
| 94 |
$(this).closest('.table-container').addClass('bulk-actions').find('.bulk-action').show(); |
| 95 |
} else { |
| 96 |
$(this).closest('.table-container').removeClass('bulk-actions').find('.bulk-action').hide(); |
| 97 |
} |
| 98 |
}); |
| 99 |
|
| 100 |
$('.close-div').click(function(){ |
| 101 |
$(this).closest('.table-container').removeClass('bulk-actions').find('.bulk-action').hide(); |
| 102 |
}); |
| 103 |
|
| 104 |
// invoice print trigger |
| 105 |
$('.print-btn').click(function(e){ |
| 106 |
e.preventDefault(); |
| 107 |
window.print(); |
| 108 |
}); |
| 109 |
|
| 110 |
// modal trigger |
| 111 |
$("[data-toggle='wperp-modal']").click(function( e ){ |
| 112 |
e.preventDefault(); |
| 113 |
var targetModal = $(this).data('target'); |
| 114 |
$('#'+targetModal).addClass('wperp-modal-open'); |
| 115 |
$('body').addClass('wperp-has-modal'); |
| 116 |
}); |
| 117 |
|
| 118 |
// modal dismiss |
| 119 |
$('.wperp-modal .wperp-close').click(function(e){ |
| 120 |
e.preventDefault(); |
| 121 |
$('body').removeClass('wperp-has-modal'); |
| 122 |
$(this).parents('.wperp-modal').removeClass('wperp-modal-open'); |
| 123 |
}); |
| 124 |
|
| 125 |
// modal dimiss when click on body |
| 126 |
$(document).on('click', function( e ) { |
| 127 |
if ( e.target.classList.contains('wperp-modal') ){ |
| 128 |
$('.wperp-modal .wperp-close').trigger('click'); |
| 129 |
} |
| 130 |
}); |
| 131 |
|
| 132 |
// dismiss modal when ESC pressed |
| 133 |
document.onkeydown = function(evt) { |
| 134 |
evt = evt || window.event; |
| 135 |
if (evt.keyCode == 27) { |
| 136 |
$('.wperp-modal .wperp-close').trigger('click'); |
| 137 |
} |
| 138 |
}; |
| 139 |
|
| 140 |
}); |