mirror of
https://github.com/201206030/novel-plus.git
synced 2025-07-05 16:56:39 +00:00
上传后台管理系统代码
This commit is contained in:
@ -0,0 +1,246 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define('simple-hotkeys', ["jquery",
|
||||
"simple-module"], function ($, SimpleModule) {
|
||||
return (root.returnExportsGlobal = factory($, SimpleModule));
|
||||
});
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require("jquery"),
|
||||
require("simple-module"));
|
||||
} else {
|
||||
root.simple = root.simple || {};
|
||||
root.simple['hotkeys'] = factory(jQuery,
|
||||
SimpleModule);
|
||||
}
|
||||
}(this, function ($, SimpleModule) {
|
||||
|
||||
var Hotkeys, hotkeys,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
Hotkeys = (function(_super) {
|
||||
__extends(Hotkeys, _super);
|
||||
|
||||
function Hotkeys() {
|
||||
return Hotkeys.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Hotkeys.count = 0;
|
||||
|
||||
Hotkeys.keyNameMap = {
|
||||
8: "Backspace",
|
||||
9: "Tab",
|
||||
13: "Enter",
|
||||
16: "Shift",
|
||||
17: "Control",
|
||||
18: "Alt",
|
||||
19: "Pause",
|
||||
20: "CapsLock",
|
||||
27: "Esc",
|
||||
32: "Spacebar",
|
||||
33: "PageUp",
|
||||
34: "PageDown",
|
||||
35: "End",
|
||||
36: "Home",
|
||||
37: "Left",
|
||||
38: "Up",
|
||||
39: "Right",
|
||||
40: "Down",
|
||||
45: "Insert",
|
||||
46: "Del",
|
||||
91: "Meta",
|
||||
93: "Meta",
|
||||
48: "0",
|
||||
49: "1",
|
||||
50: "2",
|
||||
51: "3",
|
||||
52: "4",
|
||||
53: "5",
|
||||
54: "6",
|
||||
55: "7",
|
||||
56: "8",
|
||||
57: "9",
|
||||
65: "A",
|
||||
66: "B",
|
||||
67: "C",
|
||||
68: "D",
|
||||
69: "E",
|
||||
70: "F",
|
||||
71: "G",
|
||||
72: "H",
|
||||
73: "I",
|
||||
74: "J",
|
||||
75: "K",
|
||||
76: "L",
|
||||
77: "M",
|
||||
78: "N",
|
||||
79: "O",
|
||||
80: "P",
|
||||
81: "Q",
|
||||
82: "R",
|
||||
83: "S",
|
||||
84: "T",
|
||||
85: "U",
|
||||
86: "V",
|
||||
87: "W",
|
||||
88: "X",
|
||||
89: "Y",
|
||||
90: "Z",
|
||||
96: "0",
|
||||
97: "1",
|
||||
98: "2",
|
||||
99: "3",
|
||||
100: "4",
|
||||
101: "5",
|
||||
102: "6",
|
||||
103: "7",
|
||||
104: "8",
|
||||
105: "9",
|
||||
106: "Multiply",
|
||||
107: "Add",
|
||||
109: "Subtract",
|
||||
110: "Decimal",
|
||||
111: "Divide",
|
||||
112: "F1",
|
||||
113: "F2",
|
||||
114: "F3",
|
||||
115: "F4",
|
||||
116: "F5",
|
||||
117: "F6",
|
||||
118: "F7",
|
||||
119: "F8",
|
||||
120: "F9",
|
||||
121: "F10",
|
||||
122: "F11",
|
||||
123: "F12",
|
||||
124: "F13",
|
||||
125: "F14",
|
||||
126: "F15",
|
||||
127: "F16",
|
||||
128: "F17",
|
||||
129: "F18",
|
||||
130: "F19",
|
||||
131: "F20",
|
||||
132: "F21",
|
||||
133: "F22",
|
||||
134: "F23",
|
||||
135: "F24",
|
||||
59: ";",
|
||||
61: "=",
|
||||
186: ";",
|
||||
187: "=",
|
||||
188: ",",
|
||||
190: ".",
|
||||
191: "/",
|
||||
192: "`",
|
||||
219: "[",
|
||||
220: "\\",
|
||||
221: "]",
|
||||
222: "'"
|
||||
};
|
||||
|
||||
Hotkeys.aliases = {
|
||||
"escape": "esc",
|
||||
"delete": "del",
|
||||
"return": "enter",
|
||||
"ctrl": "control",
|
||||
"space": "spacebar",
|
||||
"ins": "insert",
|
||||
"cmd": "meta",
|
||||
"command": "meta",
|
||||
"wins": "meta",
|
||||
"windows": "meta"
|
||||
};
|
||||
|
||||
Hotkeys.normalize = function(shortcut) {
|
||||
var i, key, keyname, keys, _i, _len;
|
||||
keys = shortcut.toLowerCase().replace(/\s+/gi, "").split("+");
|
||||
for (i = _i = 0, _len = keys.length; _i < _len; i = ++_i) {
|
||||
key = keys[i];
|
||||
keys[i] = this.aliases[key] || key;
|
||||
}
|
||||
keyname = keys.pop();
|
||||
keys.sort().push(keyname);
|
||||
return keys.join("_");
|
||||
};
|
||||
|
||||
Hotkeys.prototype.opts = {
|
||||
el: document
|
||||
};
|
||||
|
||||
Hotkeys.prototype._init = function() {
|
||||
this.id = ++this.constructor.count;
|
||||
this._map = {};
|
||||
this._delegate = typeof this.opts.el === "string" ? document : this.opts.el;
|
||||
return $(this._delegate).on("keydown.simple-hotkeys-" + this.id, this.opts.el, (function(_this) {
|
||||
return function(e) {
|
||||
var _ref;
|
||||
return (_ref = _this._getHander(e)) != null ? _ref.call(_this, e) : void 0;
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
Hotkeys.prototype._getHander = function(e) {
|
||||
var keyname, shortcut;
|
||||
if (!(keyname = this.constructor.keyNameMap[e.which])) {
|
||||
return;
|
||||
}
|
||||
shortcut = "";
|
||||
if (e.altKey) {
|
||||
shortcut += "alt_";
|
||||
}
|
||||
if (e.ctrlKey) {
|
||||
shortcut += "control_";
|
||||
}
|
||||
if (e.metaKey) {
|
||||
shortcut += "meta_";
|
||||
}
|
||||
if (e.shiftKey) {
|
||||
shortcut += "shift_";
|
||||
}
|
||||
shortcut += keyname.toLowerCase();
|
||||
return this._map[shortcut];
|
||||
};
|
||||
|
||||
Hotkeys.prototype.respondTo = function(subject) {
|
||||
if (typeof subject === 'string') {
|
||||
return this._map[this.constructor.normalize(subject)] != null;
|
||||
} else {
|
||||
return this._getHander(subject) != null;
|
||||
}
|
||||
};
|
||||
|
||||
Hotkeys.prototype.add = function(shortcut, handler) {
|
||||
this._map[this.constructor.normalize(shortcut)] = handler;
|
||||
return this;
|
||||
};
|
||||
|
||||
Hotkeys.prototype.remove = function(shortcut) {
|
||||
delete this._map[this.constructor.normalize(shortcut)];
|
||||
return this;
|
||||
};
|
||||
|
||||
Hotkeys.prototype.destroy = function() {
|
||||
$(this._delegate).off(".simple-hotkeys-" + this.id);
|
||||
this._map = {};
|
||||
return this;
|
||||
};
|
||||
|
||||
return Hotkeys;
|
||||
|
||||
})(SimpleModule);
|
||||
|
||||
hotkeys = function(opts) {
|
||||
return new Hotkeys(opts);
|
||||
};
|
||||
|
||||
|
||||
return hotkeys;
|
||||
|
||||
|
||||
}));
|
||||
|
1
novel-admin/src/main/resources/static/js/plugins/simditor/hotkeys.min.js
vendored
Normal file
1
novel-admin/src/main/resources/static/js/plugins/simditor/hotkeys.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(a,b){"function"==typeof define&&define.amd?define("simple-hotkeys",["jquery","simple-module"],function(c,d){return a.returnExportsGlobal=b(c,d)}):"object"==typeof exports?module.exports=b(require("jquery"),require("simple-module")):(a.simple=a.simple||{},a.simple.hotkeys=b(jQuery,SimpleModule))}(this,function(a,b){var c,d,e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return f(c,b),c.count=0,c.keyNameMap={8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",91:"Meta",93:"Meta",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"Multiply",107:"Add",109:"Subtract",110:"Decimal",111:"Divide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",59:";",61:"=",186:";",187:"=",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},c.aliases={escape:"esc","delete":"del","return":"enter",ctrl:"control",space:"spacebar",ins:"insert",cmd:"meta",command:"meta",wins:"meta",windows:"meta"},c.normalize=function(a){var b,c,d,e,f,g;for(e=a.toLowerCase().replace(/\s+/gi,"").split("+"),b=f=0,g=e.length;g>f;b=++f)c=e[b],e[b]=this.aliases[c]||c;return d=e.pop(),e.sort().push(d),e.join("_")},c.prototype.opts={el:document},c.prototype._init=function(){return this.id=++this.constructor.count,this._map={},this._delegate="string"==typeof this.opts.el?document:this.opts.el,a(this._delegate).on("keydown.simple-hotkeys-"+this.id,this.opts.el,function(a){return function(b){var c;return null!=(c=a._getHander(b))?c.call(a,b):void 0}}(this))},c.prototype._getHander=function(a){var b,c;if(b=this.constructor.keyNameMap[a.which])return c="",a.altKey&&(c+="alt_"),a.ctrlKey&&(c+="control_"),a.metaKey&&(c+="meta_"),a.shiftKey&&(c+="shift_"),c+=b.toLowerCase(),this._map[c]},c.prototype.respondTo=function(a){return"string"==typeof a?null!=this._map[this.constructor.normalize(a)]:null!=this._getHander(a)},c.prototype.add=function(a,b){return this._map[this.constructor.normalize(a)]=b,this},c.prototype.remove=function(a){return delete this._map[this.constructor.normalize(a)],this},c.prototype.destroy=function(){return a(this._delegate).off(".simple-hotkeys-"+this.id),this._map={},this},c}(b),d=function(a){return new c(a)}});
|
5
novel-admin/src/main/resources/static/js/plugins/simditor/jquery.min.js
vendored
Normal file
5
novel-admin/src/main/resources/static/js/plugins/simditor/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,174 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define('simple-module', ["jquery"], function ($) {
|
||||
return (root.returnExportsGlobal = factory($));
|
||||
});
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require("jquery"));
|
||||
} else {
|
||||
root['SimpleModule'] = factory(jQuery);
|
||||
}
|
||||
}(this, function ($) {
|
||||
|
||||
var Module,
|
||||
__slice = [].slice;
|
||||
|
||||
Module = (function() {
|
||||
Module.extend = function(obj) {
|
||||
var key, val, _ref;
|
||||
if (!((obj != null) && typeof obj === 'object')) {
|
||||
return;
|
||||
}
|
||||
for (key in obj) {
|
||||
val = obj[key];
|
||||
if (key !== 'included' && key !== 'extended') {
|
||||
this[key] = val;
|
||||
}
|
||||
}
|
||||
return (_ref = obj.extended) != null ? _ref.call(this) : void 0;
|
||||
};
|
||||
|
||||
Module.include = function(obj) {
|
||||
var key, val, _ref;
|
||||
if (!((obj != null) && typeof obj === 'object')) {
|
||||
return;
|
||||
}
|
||||
for (key in obj) {
|
||||
val = obj[key];
|
||||
if (key !== 'included' && key !== 'extended') {
|
||||
this.prototype[key] = val;
|
||||
}
|
||||
}
|
||||
return (_ref = obj.included) != null ? _ref.call(this) : void 0;
|
||||
};
|
||||
|
||||
Module.connect = function(cls) {
|
||||
if (typeof cls !== 'function') {
|
||||
return;
|
||||
}
|
||||
if (!cls.pluginName) {
|
||||
throw new Error('Module.connect: cannot connect plugin without pluginName');
|
||||
return;
|
||||
}
|
||||
cls.prototype._connected = true;
|
||||
if (!this._connectedClasses) {
|
||||
this._connectedClasses = [];
|
||||
}
|
||||
this._connectedClasses.push(cls);
|
||||
if (cls.pluginName) {
|
||||
return this[cls.pluginName] = cls;
|
||||
}
|
||||
};
|
||||
|
||||
Module.prototype.opts = {};
|
||||
|
||||
function Module(opts) {
|
||||
var cls, instance, instances, name, _base, _i, _len;
|
||||
this.opts = $.extend({}, this.opts, opts);
|
||||
(_base = this.constructor)._connectedClasses || (_base._connectedClasses = []);
|
||||
instances = (function() {
|
||||
var _i, _len, _ref, _results;
|
||||
_ref = this.constructor._connectedClasses;
|
||||
_results = [];
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
cls = _ref[_i];
|
||||
name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1);
|
||||
if (cls.prototype._connected) {
|
||||
cls.prototype._module = this;
|
||||
}
|
||||
_results.push(this[name] = new cls());
|
||||
}
|
||||
return _results;
|
||||
}).call(this);
|
||||
if (this._connected) {
|
||||
this.opts = $.extend({}, this.opts, this._module.opts);
|
||||
} else {
|
||||
this._init();
|
||||
for (_i = 0, _len = instances.length; _i < _len; _i++) {
|
||||
instance = instances[_i];
|
||||
if (typeof instance._init === "function") {
|
||||
instance._init();
|
||||
}
|
||||
}
|
||||
}
|
||||
this.trigger('initialized');
|
||||
}
|
||||
|
||||
Module.prototype._init = function() {};
|
||||
|
||||
Module.prototype.on = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
(_ref = $(this)).on.apply(_ref, args);
|
||||
return this;
|
||||
};
|
||||
|
||||
Module.prototype.one = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
(_ref = $(this)).one.apply(_ref, args);
|
||||
return this;
|
||||
};
|
||||
|
||||
Module.prototype.off = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
(_ref = $(this)).off.apply(_ref, args);
|
||||
return this;
|
||||
};
|
||||
|
||||
Module.prototype.trigger = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
(_ref = $(this)).trigger.apply(_ref, args);
|
||||
return this;
|
||||
};
|
||||
|
||||
Module.prototype.triggerHandler = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
return (_ref = $(this)).triggerHandler.apply(_ref, args);
|
||||
};
|
||||
|
||||
Module.prototype._t = function() {
|
||||
var args, _ref;
|
||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
||||
return (_ref = this.constructor)._t.apply(_ref, args);
|
||||
};
|
||||
|
||||
Module._t = function() {
|
||||
var args, key, result, _ref;
|
||||
key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
||||
result = ((_ref = this.i18n[this.locale]) != null ? _ref[key] : void 0) || '';
|
||||
if (!(args.length > 0)) {
|
||||
return result;
|
||||
}
|
||||
result = result.replace(/([^%]|^)%(?:(\d+)\$)?s/g, function(p0, p, position) {
|
||||
if (position) {
|
||||
return p + args[parseInt(position) - 1];
|
||||
} else {
|
||||
return p + args.shift();
|
||||
}
|
||||
});
|
||||
return result.replace(/%%s/g, '%s');
|
||||
};
|
||||
|
||||
Module.i18n = {
|
||||
'zh-CN': {}
|
||||
};
|
||||
|
||||
Module.locale = 'zh-CN';
|
||||
|
||||
return Module;
|
||||
|
||||
})();
|
||||
|
||||
|
||||
return Module;
|
||||
|
||||
|
||||
}));
|
1
novel-admin/src/main/resources/static/js/plugins/simditor/module.min.js
vendored
Normal file
1
novel-admin/src/main/resources/static/js/plugins/simditor/module.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(a,b){"function"==typeof define&&define.amd?define("simple-module",["jquery"],function(c){return a.returnExportsGlobal=b(c)}):"object"==typeof exports?module.exports=b(require("jquery")):a.SimpleModule=b(jQuery)}(this,function(a){var b,c=[].slice;return b=function(){function b(b){var c,d,e,f,g,h,i;if(this.opts=a.extend({},this.opts,b),(g=this.constructor)._connectedClasses||(g._connectedClasses=[]),e=function(){var a,b,d,e;for(d=this.constructor._connectedClasses,e=[],a=0,b=d.length;b>a;a++)c=d[a],f=c.pluginName.charAt(0).toLowerCase()+c.pluginName.slice(1),c.prototype._connected&&(c.prototype._module=this),e.push(this[f]=new c);return e}.call(this),this._connected)this.opts=a.extend({},this.opts,this._module.opts);else for(this._init(),h=0,i=e.length;i>h;h++)d=e[h],"function"==typeof d._init&&d._init();this.trigger("initialized")}return b.extend=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)c=a[b],"included"!==b&&"extended"!==b&&(this[b]=c);return null!=(d=a.extended)?d.call(this):void 0}},b.include=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)c=a[b],"included"!==b&&"extended"!==b&&(this.prototype[b]=c);return null!=(d=a.included)?d.call(this):void 0}},b.connect=function(a){if("function"==typeof a){if(!a.pluginName)throw new Error("Module.connect: cannot connect plugin without pluginName");return a.prototype._connected=!0,this._connectedClasses||(this._connectedClasses=[]),this._connectedClasses.push(a),a.pluginName?this[a.pluginName]=a:void 0}},b.prototype.opts={},b.prototype._init=function(){},b.prototype.on=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).on.apply(d,b),this},b.prototype.one=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).one.apply(d,b),this},b.prototype.off=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).off.apply(d,b),this},b.prototype.trigger=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).trigger.apply(d,b),this},b.prototype.triggerHandler=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).triggerHandler.apply(d,b)},b.prototype._t=function(){var a,b;return a=1<=arguments.length?c.call(arguments,0):[],(b=this.constructor)._t.apply(b,a)},b._t=function(){var a,b,d,e;return b=arguments[0],a=2<=arguments.length?c.call(arguments,1):[],d=(null!=(e=this.i18n[this.locale])?e[b]:void 0)||"",a.length>0?(d=d.replace(/([^%]|^)%(?:(\d+)\$)?s/g,function(b,c,d){return d?c+a[parseInt(d)-1]:c+a.shift()}),d.replace(/%%s/g,"%s")):d},b.i18n={"zh-CN":{}},b.locale="zh-CN",b}()});
|
File diff suppressed because it is too large
Load Diff
3
novel-admin/src/main/resources/static/js/plugins/simditor/simditor.min.js
vendored
Normal file
3
novel-admin/src/main/resources/static/js/plugins/simditor/simditor.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,268 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define('simple-uploader', ["jquery",
|
||||
"simple-module"], function ($, SimpleModule) {
|
||||
return (root.returnExportsGlobal = factory($, SimpleModule));
|
||||
});
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require("jquery"),
|
||||
require("simple-module"));
|
||||
} else {
|
||||
root.simple = root.simple || {};
|
||||
root.simple['uploader'] = factory(jQuery,
|
||||
SimpleModule);
|
||||
}
|
||||
}(this, function ($, SimpleModule) {
|
||||
|
||||
var Uploader, uploader,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
Uploader = (function(_super) {
|
||||
__extends(Uploader, _super);
|
||||
|
||||
function Uploader() {
|
||||
return Uploader.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
Uploader.count = 0;
|
||||
|
||||
Uploader.prototype.opts = {
|
||||
url: '',
|
||||
params: null,
|
||||
fileKey: 'upload_file',
|
||||
connectionCount: 3
|
||||
};
|
||||
|
||||
Uploader.prototype._init = function() {
|
||||
this.files = [];
|
||||
this.queue = [];
|
||||
this.id = ++Uploader.count;
|
||||
this.on('uploadcomplete', (function(_this) {
|
||||
return function(e, file) {
|
||||
_this.files.splice($.inArray(file, _this.files), 1);
|
||||
if (_this.queue.length > 0 && _this.files.length < _this.opts.connectionCount) {
|
||||
return _this.upload(_this.queue.shift());
|
||||
} else {
|
||||
return _this.uploading = false;
|
||||
}
|
||||
};
|
||||
})(this));
|
||||
return $(window).on('beforeunload.uploader-' + this.id, (function(_this) {
|
||||
return function(e) {
|
||||
if (!_this.uploading) {
|
||||
return;
|
||||
}
|
||||
e.originalEvent.returnValue = _this._t('leaveConfirm');
|
||||
return _this._t('leaveConfirm');
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
Uploader.prototype.generateId = (function() {
|
||||
var id;
|
||||
id = 0;
|
||||
return function() {
|
||||
return id += 1;
|
||||
};
|
||||
})();
|
||||
|
||||
Uploader.prototype.upload = function(file, opts) {
|
||||
var f, key, _i, _len;
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
if ($.isArray(file)) {
|
||||
for (_i = 0, _len = file.length; _i < _len; _i++) {
|
||||
f = file[_i];
|
||||
this.upload(f, opts);
|
||||
}
|
||||
} else if ($(file).is('input:file')) {
|
||||
key = $(file).attr('name');
|
||||
if (key) {
|
||||
opts.fileKey = key;
|
||||
}
|
||||
this.upload($.makeArray($(file)[0].files), opts);
|
||||
} else if (!file.id || !file.obj) {
|
||||
file = this.getFile(file);
|
||||
}
|
||||
if (!(file && file.obj)) {
|
||||
return;
|
||||
}
|
||||
$.extend(file, opts);
|
||||
if (this.files.length >= this.opts.connectionCount) {
|
||||
this.queue.push(file);
|
||||
return;
|
||||
}
|
||||
if (this.triggerHandler('beforeupload', [file]) === false) {
|
||||
return;
|
||||
}
|
||||
this.files.push(file);
|
||||
this._xhrUpload(file);
|
||||
return this.uploading = true;
|
||||
};
|
||||
|
||||
Uploader.prototype.getFile = function(fileObj) {
|
||||
var name, _ref, _ref1;
|
||||
if (fileObj instanceof window.File || fileObj instanceof window.Blob) {
|
||||
name = (_ref = fileObj.fileName) != null ? _ref : fileObj.name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
id: this.generateId(),
|
||||
url: this.opts.url,
|
||||
params: this.opts.params,
|
||||
fileKey: this.opts.fileKey,
|
||||
name: name,
|
||||
size: (_ref1 = fileObj.fileSize) != null ? _ref1 : fileObj.size,
|
||||
ext: name ? name.split('.').pop().toLowerCase() : '',
|
||||
obj: fileObj
|
||||
};
|
||||
};
|
||||
|
||||
Uploader.prototype._xhrUpload = function(file) {
|
||||
var formData, k, v, _ref;
|
||||
formData = new FormData();
|
||||
formData.append(file.fileKey, file.obj);
|
||||
formData.append("original_filename", file.name);
|
||||
if (file.params) {
|
||||
_ref = file.params;
|
||||
for (k in _ref) {
|
||||
v = _ref[k];
|
||||
formData.append(k, v);
|
||||
}
|
||||
}
|
||||
return file.xhr = $.ajax({
|
||||
url: file.url,
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
headers: {
|
||||
'X-File-Name': encodeURIComponent(file.name)
|
||||
},
|
||||
xhr: function() {
|
||||
var req;
|
||||
req = $.ajaxSettings.xhr();
|
||||
if (req) {
|
||||
req.upload.onprogress = (function(_this) {
|
||||
return function(e) {
|
||||
return _this.progress(e);
|
||||
};
|
||||
})(this);
|
||||
}
|
||||
return req;
|
||||
},
|
||||
progress: (function(_this) {
|
||||
return function(e) {
|
||||
if (!e.lengthComputable) {
|
||||
return;
|
||||
}
|
||||
return _this.trigger('uploadprogress', [file, e.loaded, e.total]);
|
||||
};
|
||||
})(this),
|
||||
error: (function(_this) {
|
||||
return function(xhr, status, err) {
|
||||
return _this.trigger('uploaderror', [file, xhr, status]);
|
||||
};
|
||||
})(this),
|
||||
success: (function(_this) {
|
||||
return function(result) {
|
||||
_this.trigger('uploadprogress', [file, file.size, file.size]);
|
||||
return _this.trigger('uploadsuccess', [file, result]);
|
||||
};
|
||||
})(this),
|
||||
complete: (function(_this) {
|
||||
return function(xhr, status) {
|
||||
return _this.trigger('uploadcomplete', [file, xhr.responseText]);
|
||||
};
|
||||
})(this)
|
||||
});
|
||||
};
|
||||
|
||||
Uploader.prototype.cancel = function(file) {
|
||||
var f, _i, _len, _ref;
|
||||
if (!file.id) {
|
||||
_ref = this.files;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
f = _ref[_i];
|
||||
if (f.id === file * 1) {
|
||||
file = f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.trigger('uploadcancel', [file]);
|
||||
if (file.xhr) {
|
||||
file.xhr.abort();
|
||||
}
|
||||
return file.xhr = null;
|
||||
};
|
||||
|
||||
Uploader.prototype.readImageFile = function(fileObj, callback) {
|
||||
var fileReader, img;
|
||||
if (!$.isFunction(callback)) {
|
||||
return;
|
||||
}
|
||||
img = new Image();
|
||||
img.onload = function() {
|
||||
return callback(img);
|
||||
};
|
||||
img.onerror = function() {
|
||||
return callback();
|
||||
};
|
||||
if (window.FileReader && FileReader.prototype.readAsDataURL && /^image/.test(fileObj.type)) {
|
||||
fileReader = new FileReader();
|
||||
fileReader.onload = function(e) {
|
||||
return img.src = e.target.result;
|
||||
};
|
||||
return fileReader.readAsDataURL(fileObj);
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
};
|
||||
|
||||
Uploader.prototype.destroy = function() {
|
||||
var file, _i, _len, _ref;
|
||||
this.queue.length = 0;
|
||||
_ref = this.files;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
file = _ref[_i];
|
||||
this.cancel(file);
|
||||
}
|
||||
$(window).off('.uploader-' + this.id);
|
||||
return $(document).off('.uploader-' + this.id);
|
||||
};
|
||||
|
||||
Uploader.i18n = {
|
||||
'zh-CN': {
|
||||
leaveConfirm: '正在上传文件,如果离开上传会自动取消'
|
||||
}
|
||||
};
|
||||
|
||||
Uploader.locale = 'zh-CN';
|
||||
|
||||
return Uploader;
|
||||
|
||||
})(SimpleModule);
|
||||
|
||||
uploader = function(opts) {
|
||||
return new Uploader(opts);
|
||||
};
|
||||
|
||||
|
||||
return uploader;
|
||||
|
||||
|
||||
}));
|
||||
|
||||
|
1
novel-admin/src/main/resources/static/js/plugins/simditor/uploader.min.js
vendored
Normal file
1
novel-admin/src/main/resources/static/js/plugins/simditor/uploader.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(a,b){"function"==typeof define&&define.amd?define("simple-uploader",["jquery","simple-module"],function(c,d){return a.returnExportsGlobal=b(c,d)}):"object"==typeof exports?module.exports=b(require("jquery"),require("simple-module")):(a.simple=a.simple||{},a.simple.uploader=b(jQuery,SimpleModule))}(this,function(a,b){var c,d,e={}.hasOwnProperty,f=function(a,b){function c(){this.constructor=a}for(var d in b)e.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a};return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return f(c,b),c.count=0,c.prototype.opts={url:"",params:null,fileKey:"upload_file",connectionCount:3},c.prototype._init=function(){return this.files=[],this.queue=[],this.id=++c.count,this.on("uploadcomplete",function(b){return function(c,d){return b.files.splice(a.inArray(d,b.files),1),b.queue.length>0&&b.files.length<b.opts.connectionCount?b.upload(b.queue.shift()):b.uploading=!1}}(this)),a(window).on("beforeunload.uploader-"+this.id,function(a){return function(b){return a.uploading?(b.originalEvent.returnValue=a._t("leaveConfirm"),a._t("leaveConfirm")):void 0}}(this))},c.prototype.generateId=function(){var a;return a=0,function(){return a+=1}}(),c.prototype.upload=function(b,c){var d,e,f,g;if(null==c&&(c={}),null!=b){if(a.isArray(b))for(f=0,g=b.length;g>f;f++)d=b[f],this.upload(d,c);else a(b).is("input:file")?(e=a(b).attr("name"),e&&(c.fileKey=e),this.upload(a.makeArray(a(b)[0].files),c)):b.id&&b.obj||(b=this.getFile(b));if(b&&b.obj){if(a.extend(b,c),this.files.length>=this.opts.connectionCount)return void this.queue.push(b);if(this.triggerHandler("beforeupload",[b])!==!1)return this.files.push(b),this._xhrUpload(b),this.uploading=!0}}},c.prototype.getFile=function(a){var b,c,d;return a instanceof window.File||a instanceof window.Blob?(b=null!=(c=a.fileName)?c:a.name,{id:this.generateId(),url:this.opts.url,params:this.opts.params,fileKey:this.opts.fileKey,name:b,size:null!=(d=a.fileSize)?d:a.size,ext:b?b.split(".").pop().toLowerCase():"",obj:a}):null},c.prototype._xhrUpload=function(b){var c,d,e,f;if(c=new FormData,c.append(b.fileKey,b.obj),c.append("original_filename",b.name),b.params){f=b.params;for(d in f)e=f[d],c.append(d,e)}return b.xhr=a.ajax({url:b.url,data:c,dataType:"json",processData:!1,contentType:!1,type:"POST",headers:{"X-File-Name":encodeURIComponent(b.name)},xhr:function(){var b;return b=a.ajaxSettings.xhr(),b&&(b.upload.onprogress=function(a){return function(b){return a.progress(b)}}(this)),b},progress:function(a){return function(c){return c.lengthComputable?a.trigger("uploadprogress",[b,c.loaded,c.total]):void 0}}(this),error:function(a){return function(c,d){return a.trigger("uploaderror",[b,c,d])}}(this),success:function(a){return function(c){return a.trigger("uploadprogress",[b,b.size,b.size]),a.trigger("uploadsuccess",[b,c])}}(this),complete:function(a){return function(c){return a.trigger("uploadcomplete",[b,c.responseText])}}(this)})},c.prototype.cancel=function(a){var b,c,d,e;if(!a.id)for(e=this.files,c=0,d=e.length;d>c;c++)if(b=e[c],b.id===1*a){a=b;break}return this.trigger("uploadcancel",[a]),a.xhr&&a.xhr.abort(),a.xhr=null},c.prototype.readImageFile=function(b,c){var d,e;if(a.isFunction(c))return e=new Image,e.onload=function(){return c(e)},e.onerror=function(){return c()},window.FileReader&&FileReader.prototype.readAsDataURL&&/^image/.test(b.type)?(d=new FileReader,d.onload=function(a){return e.src=a.target.result},d.readAsDataURL(b)):c()},c.prototype.destroy=function(){var b,c,d,e;for(this.queue.length=0,e=this.files,c=0,d=e.length;d>c;c++)b=e[c],this.cancel(b);return a(window).off(".uploader-"+this.id),a(document).off(".uploader-"+this.id)},c.i18n={"zh-CN":{leaveConfirm:"正在上传文件,如果离开上传会自动取消"}},c.locale="zh-CN",c}(b),d=function(a){return new c(a)}});
|
Reference in New Issue
Block a user