| 1 |
(function($) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
$(document).ready(function () { |
| 5 |
|
| 6 |
$('[data-toggle="popover"]').popover(); |
| 7 |
$('[data-toggle="tooltip"]').tooltip(); |
| 8 |
|
| 9 |
|
| 10 |
$(document).find('.form-check-input.select-all').on('click', function() { |
| 11 |
if ($(this).prop('checked') == true) { |
| 12 |
$(document).find('.check-current-row').prop('checked',true) |
| 13 |
} else { |
| 14 |
$(document).find('.check-current-row').prop('checked',false) |
| 15 |
} |
| 16 |
}); |
| 17 |
|
| 18 |
$(document).find('.check-current-row').on('click', function() { |
| 19 |
var checkboxesArr = $(document).find('.check-current-row'); |
| 20 |
var selectAllCheckBox = $(document).find('.form-check-input.select-all'); |
| 21 |
var count = 0; |
| 22 |
|
| 23 |
for (var i = 0; i < checkboxesArr.length; i++) { |
| 24 |
if (checkboxesArr.eq(i).prop('checked') == true) { |
| 25 |
count++; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
if (count == 0 && selectAllCheckBox.prop('checked') == true) { |
| 30 |
selectAllCheckBox.prop('checked', false); |
| 31 |
} else if (count == checkboxesArr.length && selectAllCheckBox.prop('checked') == false) { |
| 32 |
selectAllCheckBox.prop('checked', true); |
| 33 |
} |
| 34 |
}); |
| 35 |
|
| 36 |
$(document).on('mouseenter', '.column-title', function() { |
| 37 |
$(this).find('.chart-list-table-actions-row').css('display', 'flex'); |
| 38 |
}); |
| 39 |
$(document).on('mouseleave', '.column-title', function() { |
| 40 |
$(this).find('.chart-list-table-actions-row').css('display', 'none'); |
| 41 |
}); |
| 42 |
|
| 43 |
$(document).find('.ays-chart-copy-image').on('click', function(){ |
| 44 |
var _this = this; |
| 45 |
var input = $(_this).parent().find('input.ays-chart-shortcode-input'); |
| 46 |
var length = input.val().length; |
| 47 |
|
| 48 |
input[0].focus(); |
| 49 |
input[0].setSelectionRange(0, length); |
| 50 |
document.execCommand('copy'); |
| 51 |
document.getSelection().removeAllRanges(); |
| 52 |
|
| 53 |
$(_this).attr('data-original-title', aysChartBuilderAdmin.copied); |
| 54 |
$(_this).attr("title", aysChartBuilderAdmin.copied); |
| 55 |
$(_this).tooltip('show'); |
| 56 |
}); |
| 57 |
|
| 58 |
$(document).find('.ays-chart-copy-image').on('mouseleave', function(){ |
| 59 |
var _this = this; |
| 60 |
|
| 61 |
$(_this).attr('data-original-title', aysChartBuilderAdmin.clickForCopy); |
| 62 |
$(_this).attr('title', aysChartBuilderAdmin.clickForCopy); |
| 63 |
$(_this).tooltip('show'); |
| 64 |
}); |
| 65 |
|
| 66 |
$(document).on('click', '.notice-dismiss', function (e) { |
| 67 |
changeCurrentUrl('status'); |
| 68 |
}); |
| 69 |
|
| 70 |
var toggle_ddmenu = $(document).find('.toggle_ddmenu'); |
| 71 |
toggle_ddmenu.on('click', function () { |
| 72 |
var ddmenu = $(this).next(); |
| 73 |
var state = ddmenu.attr('data-expanded'); |
| 74 |
switch (state) { |
| 75 |
case 'true': |
| 76 |
$(this).find('.ays_fa').css({ |
| 77 |
transform: 'rotate(0deg)' |
| 78 |
}); |
| 79 |
ddmenu.attr('data-expanded', 'false'); |
| 80 |
break; |
| 81 |
case 'false': |
| 82 |
$(this).find('.ays_fa').css({ |
| 83 |
transform: 'rotate(90deg)' |
| 84 |
}); |
| 85 |
ddmenu.attr('data-expanded', 'true'); |
| 86 |
break; |
| 87 |
} |
| 88 |
}); |
| 89 |
|
| 90 |
function changeCurrentUrl(key){ |
| 91 |
var linkModified = location.href.split('?')[1].split('&'); |
| 92 |
for(var i = 0; i < linkModified.length; i++){ |
| 93 |
if(linkModified[i].split("=")[0] == key){ |
| 94 |
linkModified.splice(i, 1); |
| 95 |
} |
| 96 |
} |
| 97 |
linkModified = linkModified.join('&'); |
| 98 |
window.history.replaceState({}, document.title, '?'+linkModified); |
| 99 |
} |
| 100 |
|
| 101 |
}); |
| 102 |
|
| 103 |
})(jQuery); |