Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var timeout = null;
- var escape_event = true;
- function insertLinks() {
- var grid = $('#task-grid');
- if (grid.length > 0) {
- escape_event = true;
- grid.find('span.close-btn').remove(); //remove old buttons
- grid.find('div.items > .task-item > div.row').each(function() {
- $(this).children('div:first').append('<span class="close-btn"><a href="#"><i class="glyphicon glyphicon-ok"></i></a></span>');
- });
- }
- escape_event = false;
- }
- $('body').on('click', 'span.close-btn a', function (e) {
- e.preventDefault();
- var link = $(this).parents('.task-item').find('div.row > div a').eq(0);
- var res = link.attr('href').match(/.+\/(\d+)/);
- var url = "/ww/task/" + res[1] + "/comment";
- var data = new FormData();
- data.append('action_type', "close");
- data.append('Comment[content]', "");
- data.append('Comment[attachments]', "");
- $.ajax({
- "url": url,
- "type": "POST",
- "contentType": false,
- "processData": false,
- "data": data,
- "success": function(e) {
- refreshPage();
- },
- });
- });
- function refreshPage() {
- if ($('.pagination-wrapper').length > 0) {
- $('.pagination-wrapper .active a').trigger('click');
- } else {
- $('.search-form form input.btn').trigger('click');
- }
- }
- document.addEventListener("DOMSubtreeModified", function() {
- if (!escape_event) {
- if(timeout) clearTimeout(timeout);
- timeout = setTimeout(insertLinks, 500);
- }
- }, false);
- insertLinks();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement