$(document).ready(function(e) { $('.edit').click(function(e) { $(this).litedit({'id':$(this).attr('rel')}); }); $('.order').click(function(e) { $(this).litorder({'id':$(this).attr('rel')}); }); $('.insert').click(function(e) { $(this).litinsert({'id':$(this).attr('rel'),'uuid':$(this).attr('uuid')}); }); }); // JavaScript Document (function( $ ){ $.fn.litedit = function( options ) { var settings = $.extend( { id:'', content : '', uuid:'' }, options); var methods = { edit : function(id) { methods.creatWindow(id); }, creatWindow : function(id,html){ $.colorbox({ initialHeight: '0', initialWidth: '0', html: html, 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&'+$('#edit-mdref').serialize(), '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('出现错误,请刷新后重试'); } }); }, loadinfo : function(id){ $.ajax({ 'type':"POST", 'url':'/author/literature/', 'data':'ac=get&id='+id, 'success':function(data){ html = methods.dialog(data); methods.creatWindow(id,html); }, 'timeout': 30000, 'error': function(){ alert('出现错误,请刷新后重试'); } }); }, dialog : function(data){ HTML = '
' + '' + '
'; return HTML; } } this.each(function() { if( settings.id == '') { alert('参数错误'); } settings.uuid = $(this).attr('rev'); methods.loadinfo(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 = '
' + '' + '
'; return HTML; } } this.each(function() { if( settings.id == '') { alert('参数错误'); } settings.order = $(this).attr('rev'); methods.edit(settings.id); }); }; })( jQuery ); (function( $ ){ $.fn.litinsert = function( options ) { var settings = $.extend( { id:'', order : '', uuid:'', }, options); var methods = { edit : function(id,uuid) { methods.creatWindow(id,uuid); }, creatWindow : function(id,uuid){ $.colorbox({ initialHeight: '0', initialWidth: '0', html: methods.dialog, opacity: '0.3', onComplete: function(){ $('.confirm_yes').click(function(e){ e.preventDefault(); methods.submited(id,uuid); $.colorbox.close(); }); $('.confirm_no').click(function(e){ e.preventDefault(); $.colorbox.close(); }); } }); }, submited : function(id,uuid){ $.ajax({ 'type':"POST", 'url':'/author/literature/', 'data':'ac=insert&id='+id+'&uuid='+uuid+'&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 = '
' + '' + '
'; return HTML; } } this.each(function() { if( settings.id == '') { alert('参数错误'); } settings.order = $(this).attr('rev'); settings.uuid = $(this).attr('uuid'); methods.edit(settings.id,settings.uuid); }); }; })( jQuery );