108 lines
3.6 KiB
JavaScript
108 lines
3.6 KiB
JavaScript
document.observe('dom:loaded', function(){
|
|
document.observe('click', function(event){
|
|
var el = null;
|
|
if(el = event.findElement('a.claim') || event.findElement('a.unclaim') || event.findElement('a.unassign')){
|
|
el.insert({after: "<img class='spinner' src='/images/spinner.gif'/>"});
|
|
new Ajax.Request(el['href'], {
|
|
onSuccess: function(response){
|
|
var body = el.up(4);
|
|
body.previous().remove();
|
|
body.replace(response.responseText);
|
|
},
|
|
onFailure: function(response){
|
|
el.next('.spinner').remove();
|
|
if(response.status == 403) {
|
|
alert(response.responseText);
|
|
}
|
|
},
|
|
method: 'put'});
|
|
event.stop();
|
|
|
|
} else if(el = event.findElement('div.list_article .head a.title')) {
|
|
var head = el.up(1);
|
|
var body = head.next();
|
|
if(body && body.hasClassName('body')){
|
|
if(!body.visible()){
|
|
$$('tr.head.select').each(function(tr){
|
|
tr.removeClassName('select');
|
|
tr.next().hide();
|
|
});
|
|
}
|
|
body.toggle();
|
|
head.toggleClassName('select');
|
|
head.scrollTo();
|
|
} else {
|
|
new Ajax.Request(el['href'], {
|
|
onSuccess: function(response){
|
|
$$('tr.head.select').each(function(tr){
|
|
tr.removeClassName('select');
|
|
tr.next().hide();
|
|
});
|
|
head.insert({after: response.responseText});
|
|
head.addClassName('select');
|
|
head.scrollTo();
|
|
},
|
|
onFailure: function(response){
|
|
if(response.status == 403) alert(response.responseText);
|
|
},
|
|
method: 'get'
|
|
});
|
|
}
|
|
event.stop();
|
|
} else if(el = event.findElement('td.view div.content a')){
|
|
el['target'] = '_blank';
|
|
} else if(el = event.findElement('div.assign button')) {
|
|
var id = el.up(4).previous()['id'];
|
|
var editor_id = el.previous().select('select')[0].value;
|
|
new Ajax.Request('/editor_tasks/' + id + '/assign', {
|
|
method: 'put',
|
|
parameters: {editor_id: editor_id},
|
|
onSuccess: function(response){
|
|
el.up(4).previous().remove();
|
|
el.up(4).replace(response.responseText);
|
|
},
|
|
onFailure: function(response){
|
|
if(response.status == 403) alert(response.responseText);
|
|
}
|
|
});
|
|
} else if(el = event.findElement('div.discard button')) {
|
|
var id = el.up(4).previous()['id'];
|
|
var reason = el.previous().value;
|
|
if(reason.strip().empty()){
|
|
alert('请填写舍弃原因!');
|
|
return;
|
|
}
|
|
new Ajax.Request('/editor_tasks/' + id + '/discard', {
|
|
method: 'put',
|
|
parameters: {reason: reason},
|
|
onSuccess: function(response){
|
|
el.up(4).previous().remove();
|
|
el.up(4).replace(response.responseText);
|
|
},
|
|
onFailure: function(response){
|
|
if(response.status == 403) alert(response.responseText);
|
|
}
|
|
});
|
|
} else if(el = event.findElement('div.restore button')) {
|
|
var id = el.up(4).previous()['id'];
|
|
new Ajax.Request('/editor_tasks/' + id + '/restore', {
|
|
method: 'put',
|
|
onSuccess: function(response){
|
|
el.up(4).previous().remove();
|
|
el.up(4).replace(response.responseText);
|
|
},
|
|
onFailure: function(response){
|
|
if(response.status == 403) alert(response.responseText);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
function submit_search(){
|
|
$('et_search_form').submit();
|
|
}
|
|
$('accepter_id').observe('change', submit_search);
|
|
$('status').observe('change', submit_search);
|
|
|
|
});
|