class followingList{ constructor(){ } getDataStatus(){ $('.username a').click(function(e) { $(this).css({'color': '#ff0000'}); // Đổi màu chữ khi click }); $(document).on('click', '.checkItem', function() { let data = $(this).val(); //lấy trạng thái của checkbox let status = $(this).prop('checked') === true ? 1 : 0; $.ajax({ type: "post", url: "/instagram/profile-status", dataType: "json", data: {'id': data, 'status': status}, headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, success: function (msg) { if (msg.status == 1) { instagramFollowing.showToast(msg.msg, 'success'); } else { instagramFollowing.showToast(msg.msg, 'error'); } }, error: function (request, error) { instagramFollowing.showToast('Lỗi kết nối', 'error'); } });//End ajax }); } showToast(msg, type, node = 0) { let typeToast = { success: "linear-gradient(to right, #00b09b, #96c93d)", error: "red", warning: "yellow", }; if(node == 1){ let link = document.createElement("a"); link.href = msg; link.textContent = msg; link.target = "_blank"; // mở tab mới nếu muốn link.style.color = "#fff"; // chỉnh màu nếu cần Toastify({ node: link, // dùng node thay cho text duration: 10000, close: true, gravity: "top", position: "right", stopOnFocus: true, style: { background: typeToast[type], } }).showToast(); }else{ Toastify({ text: msg, duration: 10000, close: true, gravity: "top", // `top` or `bottom` position: "right", // `left`, `center` or `right` stopOnFocus: true, // Prevents dismissing of toast on hover style: { background: typeToast[type], }, onClick: function () { } // Callback after click }).showToast(); } } } $(function () { instagramFollowing = new followingList(); instagramFollowing.getDataStatus(); });