167 lines
4.2 KiB
JavaScript
167 lines
4.2 KiB
JavaScript
|
$(document).ready(function(e) {
|
||
|
$('.edit').click(function(e) {
|
||
|
$(this).litedit({'id':$(this).attr('rel')});
|
||
|
});
|
||
|
$('.order').click(function(e) {
|
||
|
$(this).litorder({'id':$(this).attr('rel')});
|
||
|
});
|
||
|
});
|
||
|
// JavaScript Document
|
||
|
(function( $ ){
|
||
|
|
||
|
$.fn.litedit = function( options ) {
|
||
|
|
||
|
var settings = $.extend( {
|
||
|
id:'',
|
||
|
content : '',
|
||
|
}, options);
|
||
|
|
||
|
var methods = {
|
||
|
edit : function(id)
|
||
|
{
|
||
|
methods.creatWindow(id);
|
||
|
},
|
||
|
creatWindow : function(id){
|
||
|
$.colorbox({
|
||
|
initialHeight: '0',
|
||
|
initialWidth: '0',
|
||
|
html: methods.dialog,
|
||
|
opacity: '0.3',
|
||
|
onComplete: function(){
|
||
|
$('.confirm_yes').click(function(e){
|
||
|
e.preventDefault();
|
||
|
methods.submited(id);
|
||
|
$.colorbox.close();
|
||
|
});
|
||
|
$('.confirm_no').click(function(e){
|
||
|
e.preventDefault();
|
||
|
$.colorbox.close();
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
submited : function(id){
|
||
|
$.ajax({
|
||
|
'type':"POST",
|
||
|
'url':'/author/literature/',
|
||
|
'data':'ac=edit&id='+id+'&content='+$('#content_input_area').val(),
|
||
|
'success':function(data){
|
||
|
if (typeof(data)=='object')
|
||
|
{
|
||
|
if(typeof(data.error)!='undefined')
|
||
|
{alert(data.error);}
|
||
|
if(typeof(data.success)!='undefined')
|
||
|
{
|
||
|
window.location.reload();
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
alert('出现错误,请稍候再试');
|
||
|
}
|
||
|
},
|
||
|
'timeout': 30000,
|
||
|
'error': function(){
|
||
|
alert('出现错误,请刷新后重试');
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
dialog : function(content){
|
||
|
HTML = '<div class=""><div class="modal-header"><h3>修改文献</h3></div>'
|
||
|
+ '<div class="modal-body"><textarea class="span8" id="content_input_area">'+settings.content+'</textarea></div>'
|
||
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
|
||
|
return HTML;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.each(function() {
|
||
|
if( settings.id == '')
|
||
|
{
|
||
|
alert('参数错误');
|
||
|
}
|
||
|
|
||
|
settings.content = $(this).parent('p').prev('p').html();
|
||
|
|
||
|
methods.edit(settings.id);
|
||
|
});
|
||
|
|
||
|
};
|
||
|
})( jQuery );
|
||
|
|
||
|
(function( $ ){
|
||
|
|
||
|
$.fn.litorder = function( options ) {
|
||
|
|
||
|
var settings = $.extend( {
|
||
|
id:'',
|
||
|
order : '',
|
||
|
}, options);
|
||
|
|
||
|
var methods = {
|
||
|
edit : function(id)
|
||
|
{
|
||
|
methods.creatWindow(id);
|
||
|
},
|
||
|
creatWindow : function(id){
|
||
|
$.colorbox({
|
||
|
initialHeight: '0',
|
||
|
initialWidth: '0',
|
||
|
html: methods.dialog,
|
||
|
opacity: '0.3',
|
||
|
onComplete: function(){
|
||
|
$('.confirm_yes').click(function(e){
|
||
|
e.preventDefault();
|
||
|
methods.submited(id);
|
||
|
$.colorbox.close();
|
||
|
});
|
||
|
$('.confirm_no').click(function(e){
|
||
|
e.preventDefault();
|
||
|
$.colorbox.close();
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
submited : function(id){
|
||
|
$.ajax({
|
||
|
'type':"POST",
|
||
|
'url':'/author/literature/',
|
||
|
'data':'ac=order&id='+id+'&order='+$('#order_input').val(),
|
||
|
'success':function(data){
|
||
|
if (typeof(data)=='object')
|
||
|
{
|
||
|
if(typeof(data.error)!='undefined')
|
||
|
{alert(data.error);}
|
||
|
if(typeof(data.success)!='undefined')
|
||
|
{
|
||
|
window.location.reload();
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
alert('出现错误,请稍候再试');
|
||
|
}
|
||
|
},
|
||
|
'timeout': 30000,
|
||
|
'error': function(){
|
||
|
alert('出现错误,请刷新后重试');
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
dialog : function(content){
|
||
|
HTML = '<div class=""><div class="modal-header"><h3>修改排序</h3></div>'
|
||
|
+ '<div class="modal-body">数字越小排序越靠前<br />'
|
||
|
+ '请输入排序数字<input type="text" id="order_input" value="'+settings.order+'"/></div>'
|
||
|
+ '<div class="modal-footer"><a href="javascript:void(0);" class="btn btn-primary confirm_yes">是</a><a href="javascript:void(0);" class="btn confirm_no">否</a></div></div>';
|
||
|
return HTML;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
this.each(function() {
|
||
|
if( settings.id == '')
|
||
|
{
|
||
|
alert('参数错误');
|
||
|
}
|
||
|
settings.order = $(this).attr('rev');
|
||
|
methods.edit(settings.id);
|
||
|
});
|
||
|
|
||
|
};
|
||
|
})( jQuery );
|