2016-11-05 15:26:42 +08:00
|
|
|
|
(function ($) {
|
2016-11-05 16:46:19 +08:00
|
|
|
|
logPlugin = function (options) {
|
|
|
|
|
this.options = $.extend({}, logPlugin.settings, options);
|
2016-11-05 15:26:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 16:46:19 +08:00
|
|
|
|
logPlugin.settings = {
|
2016-11-05 15:26:42 +08:00
|
|
|
|
url: '../api/Logs',
|
|
|
|
|
click: {
|
|
|
|
|
query: 'btn_query',
|
|
|
|
|
del: 'btn_delete',
|
|
|
|
|
save: 'btnSubmit'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 16:46:19 +08:00
|
|
|
|
logPlugin.prototype = {
|
|
|
|
|
constructor: logPlugin,
|
|
|
|
|
init: function () {
|
|
|
|
|
var that = this;
|
|
|
|
|
// handler click event
|
|
|
|
|
for (name in this.options.click) {
|
|
|
|
|
var cId = this.options.click[name];
|
|
|
|
|
var source = $("#" + cId);
|
|
|
|
|
source.data('click', name);
|
|
|
|
|
source.click(function () {
|
|
|
|
|
var method = $(this).data('click');
|
|
|
|
|
logPlugin.prototype[method].call(that, this);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-11-05 15:26:42 +08:00
|
|
|
|
query: function (element) {
|
2016-11-05 16:46:19 +08:00
|
|
|
|
//log(this.options.url, { crud: '查询' });
|
|
|
|
|
},
|
|
|
|
|
save: function () {
|
|
|
|
|
log(this.options.url, { crud: '保存' });
|
|
|
|
|
},
|
|
|
|
|
del: function () {
|
|
|
|
|
log(this.options.url, { crud: '删除' });
|
2016-11-05 15:26:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 16:46:19 +08:00
|
|
|
|
logPlugin.init = function (options) {
|
|
|
|
|
var log = new logPlugin(options);
|
|
|
|
|
log.init();
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-05 15:26:42 +08:00
|
|
|
|
var log = function (url, data) {
|
2016-11-05 16:46:19 +08:00
|
|
|
|
$.extend(data, { requestUrl: window.location.pathname });
|
2016-11-05 15:26:42 +08:00
|
|
|
|
$.post(url, data);
|
|
|
|
|
}
|
2016-11-05 16:46:19 +08:00
|
|
|
|
})(jQuery);
|
|
|
|
|
|
|
|
|
|
$(function () {
|
|
|
|
|
logPlugin.init();
|
|
|
|
|
});
|