| 1 |
jQuery(document).ready(function($) { |
| 2 |
$('.tracking_script .active_tracking').click(function(e) { |
| 3 |
var active = $(this).siblings('.script_active').attr('value'); |
| 4 |
|
| 5 |
$(this).removeClass('fa-circle-o'); |
| 6 |
$(this).removeClass('fa-check-circle'); |
| 7 |
|
| 8 |
if(active === 'true') { |
| 9 |
$(this).addClass('fa-circle-o'); |
| 10 |
$(this).attr('title', 'Activate Script'); |
| 11 |
$(this).siblings('.script_active').attr('value', 'false'); |
| 12 |
} else { |
| 13 |
$(this).addClass('fa-check-circle'); |
| 14 |
$(this).attr('title', 'Deactive Script'); |
| 15 |
$(this).siblings('.script_active').attr('value', 'true'); |
| 16 |
} |
| 17 |
}); |
| 18 |
|
| 19 |
$('.tracking_script .edit_tracking').click(function(e) { |
| 20 |
$(this).removeClass('fa-edit'); |
| 21 |
$(this).removeClass('fa-save'); |
| 22 |
|
| 23 |
if($(this).siblings('.script_info').find('input[type="text"]').attr('readonly') === 'readonly') { |
| 24 |
$(this).siblings('.script_info').find('input[type="text"]').attr('readonly', false); |
| 25 |
$(this).addClass('fa-save'); |
| 26 |
$(this).attr('title', 'Save Script'); |
| 27 |
} else { |
| 28 |
$('.tracking_scripts_wrap form').submit(); |
| 29 |
$(this).siblings('.script_info').find('input[type="text"]').attr('readonly', 'readonly'); |
| 30 |
$(this).addClass('fa-edit'); |
| 31 |
$(this).attr('title', 'Edit Script'); |
| 32 |
} |
| 33 |
}); |
| 34 |
|
| 35 |
$('.tracking_script .delete_tracking').click(function(e) { |
| 36 |
var confirmed = confirm("Are you sure you want to delete this script?"); |
| 37 |
if(confirmed) { |
| 38 |
$(this).parent().fadeOut(400, function() { |
| 39 |
$(this).find('.script_exists').attr('value', 'false'); |
| 40 |
|
| 41 |
var index = 1; |
| 42 |
$(this).parent().find('.tracking_script').each(function(i) { |
| 43 |
if($(this).css('display') === 'block') { |
| 44 |
$(this).find('> p').text(index); |
| 45 |
$(this).find('.script_order').attr('value', index); |
| 46 |
index++; |
| 47 |
} |
| 48 |
}); |
| 49 |
|
| 50 |
$('.tracking_scripts_wrap form').submit(); |
| 51 |
}); |
| 52 |
} |
| 53 |
}); |
| 54 |
|
| 55 |
$('.tracking_scripts').sortable({ |
| 56 |
update: function(event, ui) { |
| 57 |
$(this).find('.tracking_script').each(function(i) { |
| 58 |
i++; |
| 59 |
$(this).find('> p').text(i); |
| 60 |
$(this).find('.script_order').attr('value', i); |
| 61 |
}); |
| 62 |
} |
| 63 |
}); |
| 64 |
}); |