-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTURLS.js
31 lines (27 loc) · 974 Bytes
/
TURLS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$(document).ready(function(){
$('#turls .actions').on('click', 'button', function(){
switch($(this).children().attr('class').match(/fa-\w+/)[0]){
case 'fa-pencil':
$(this).closest('tr').find('input').attr({'readonly': false, 'type': 'text'});
$(this).closest('tr').find('a').toggleClass('hide');
break;
case 'fa-check':
return $('form#urls').submit();
case 'fa-trash':
if(confirm($(this).attr('confirm'))){
$(this).closest('tr').remove();
$('form#urls').submit();
}
return;
case 'fa-ban':
$('form#urls').trigger('reset');
$(this).closest('tr').find('input').attr({'readonly': true, 'type': 'hidden'});
$(this).closest('tr').find('a').toggleClass('hide');
break;
}
$(this).closest('tr').find('button').each(function(i, elem){
$(elem).children().toggleClass(['fa-pencil fa-check', 'fa-trash fa-ban'][i]);
$(elem).attr({'title': $(elem).attr('at'), 'at': $(elem).attr('title')});
});
});
});