@@ -14,4 +14,3 @@ django-shortuuidfield==0.1.3 |
||
14 | 14 |
django-six==1.0.4 |
15 | 15 |
django-uniapi==1.0.7 |
16 | 16 |
django-we==1.5.5 |
17 |
-django-simditor==0.0.15 |
@@ -0,0 +1,35 @@ |
||
1 |
+"""simditor fields.""" |
|
2 |
+from django import forms |
|
3 |
+from django.db import models |
|
4 |
+ |
|
5 |
+from .widgets import SimditorWidget |
|
6 |
+ |
|
7 |
+ |
|
8 |
+class RichTextFormField(forms.fields.CharField): |
|
9 |
+ """RichTextFormField.""" |
|
10 |
+ |
|
11 |
+ def __init__(self, *args, **kwargs): |
|
12 |
+ kwargs.update( |
|
13 |
+ { |
|
14 |
+ 'widget': SimditorWidget() |
|
15 |
+ } |
|
16 |
+ ) |
|
17 |
+ super(RichTextFormField, self).__init__(*args, **kwargs) |
|
18 |
+ |
|
19 |
+ |
|
20 |
+class RichTextField(models.TextField): |
|
21 |
+ """RichTextField.""" |
|
22 |
+ |
|
23 |
+ def __init__(self, *args, **kwargs): |
|
24 |
+ super(RichTextField, self).__init__(*args, **kwargs) |
|
25 |
+ |
|
26 |
+ def formfield(self, **kwargs): |
|
27 |
+ defaults = { |
|
28 |
+ 'form_class': self._get_form_class() |
|
29 |
+ } |
|
30 |
+ defaults.update(kwargs) |
|
31 |
+ return super(RichTextField, self).formfield(**defaults) |
|
32 |
+ |
|
33 |
+ @staticmethod |
|
34 |
+ def _get_form_class(): |
|
35 |
+ return RichTextFormField |
@@ -0,0 +1,10 @@ |
||
1 |
+"""simditor image pillow_backend.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+from simditor import utils |
|
5 |
+ |
|
6 |
+ |
|
7 |
+def image_verify(file_object): |
|
8 |
+ """image_verify.""" |
|
9 |
+ if not utils.is_valid_image_extension(file_object.name): |
|
10 |
+ raise utils.NotAnImageException |
@@ -0,0 +1,26 @@ |
||
1 |
+"""simditor image pillow_backend.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+import os |
|
5 |
+from io import BytesIO |
|
6 |
+ |
|
7 |
+from django.core.files.storage import default_storage |
|
8 |
+from django.core.files.uploadedfile import InMemoryUploadedFile |
|
9 |
+ |
|
10 |
+from simditor import utils |
|
11 |
+ |
|
12 |
+try: |
|
13 |
+ from PIL import Image, ImageOps |
|
14 |
+except ImportError: |
|
15 |
+ import Image |
|
16 |
+ import ImageOps |
|
17 |
+ |
|
18 |
+ |
|
19 |
+THUMBNAIL_SIZE = (75, 75) |
|
20 |
+ |
|
21 |
+ |
|
22 |
+def image_verify(f): |
|
23 |
+ try: |
|
24 |
+ Image.open(f).verify() |
|
25 |
+ except IOError: |
|
26 |
+ raise utils.NotAnImageException |
@@ -0,0 +1,15 @@ |
||
1 |
+"""simditor image_processing.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+from django.conf import settings |
|
5 |
+ |
|
6 |
+ |
|
7 |
+def get_backend(): |
|
8 |
+ """Get backend.""" |
|
9 |
+ backend = getattr(settings, 'SIMDITOR_IMAGE_BACKEND', None) |
|
10 |
+ |
|
11 |
+ if backend == 'pillow': |
|
12 |
+ from simditor.image import pillow_backend as backend |
|
13 |
+ else: |
|
14 |
+ from simditor.image import dummy_backend as backend |
|
15 |
+ return backend |
@@ -0,0 +1,11 @@ |
||
1 |
+<?xml version="1.0" standalone="no"?> |
|
2 |
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > |
|
3 |
+<svg xmlns="http://www.w3.org/2000/svg"> |
|
4 |
+<metadata>Generated by IcoMoon</metadata> |
|
5 |
+<defs> |
|
6 |
+<font id="icomoon" horiz-adv-x="512"> |
|
7 |
+<font-face units-per-em="512" ascent="480" descent="-32" /> |
|
8 |
+<missing-glyph horiz-adv-x="512" /> |
|
9 |
+<glyph unicode=" " d="" horiz-adv-x="256" /> |
|
10 |
+<glyph unicode="" d="M438.624 86.624l-73.376 73.376-45.248-45.248 73.376-73.376-73.376-73.376h192v192zM192 480h-192v-192l73.376 73.376 72.688-72.624 45.248 45.248-72.688 72.624zM192 114.752l-45.248 45.248-73.376-73.376-73.376 73.376v-192h192l-73.376 73.376zM512 480h-192l73.376-73.376-72.688-72.624 45.248-45.248 72.688 72.624 73.376-73.376z" /> |
|
11 |
+</font></defs></svg> |
@@ -0,0 +1,82 @@ |
||
1 |
+{ |
|
2 |
+ "IcoMoonType": "selection", |
|
3 |
+ "icons": [ |
|
4 |
+ { |
|
5 |
+ "icon": { |
|
6 |
+ "paths": [ |
|
7 |
+ "M877.248 786.752l-146.752-146.752-90.496 90.496 146.752 146.752-146.752 146.752h384v-384zM384 0h-384v384l146.752-146.752 145.376 145.248 90.496-90.496-145.376-145.248zM384 730.496l-90.496-90.496-146.752 146.752-146.752-146.752v384h384l-146.752-146.752zM1024 0h-384l146.752 146.752-145.376 145.248 90.496 90.496 145.376-145.248 146.752 146.752z" |
|
8 |
+ ], |
|
9 |
+ "tags": [ |
|
10 |
+ "fullscreen", |
|
11 |
+ "expand" |
|
12 |
+ ], |
|
13 |
+ "grid": 16, |
|
14 |
+ "attrs": [] |
|
15 |
+ }, |
|
16 |
+ "attrs": [], |
|
17 |
+ "properties": { |
|
18 |
+ "id": 99, |
|
19 |
+ "order": 2, |
|
20 |
+ "prevSize": 16, |
|
21 |
+ "code": 58880, |
|
22 |
+ "name": "fullscreen" |
|
23 |
+ }, |
|
24 |
+ "setIdx": 1, |
|
25 |
+ "setId": 6, |
|
26 |
+ "iconIdx": 99 |
|
27 |
+ } |
|
28 |
+ ], |
|
29 |
+ "height": 1024, |
|
30 |
+ "metadata": { |
|
31 |
+ "name": "icomoon" |
|
32 |
+ }, |
|
33 |
+ "preferences": { |
|
34 |
+ "fontPref": { |
|
35 |
+ "prefix": "icon-", |
|
36 |
+ "metadata": { |
|
37 |
+ "fontFamily": "icomoon", |
|
38 |
+ "majorVersion": 1, |
|
39 |
+ "minorVersion": 0 |
|
40 |
+ }, |
|
41 |
+ "showGlyphs": true, |
|
42 |
+ "metrics": { |
|
43 |
+ "emSize": 512, |
|
44 |
+ "baseline": 6.25, |
|
45 |
+ "whitespace": 50 |
|
46 |
+ }, |
|
47 |
+ "resetPoint": 58880, |
|
48 |
+ "showQuickUse": true, |
|
49 |
+ "quickUsageToken": false, |
|
50 |
+ "showMetrics": false, |
|
51 |
+ "showMetadata": false, |
|
52 |
+ "autoHost": true, |
|
53 |
+ "embed": false, |
|
54 |
+ "ie7": false, |
|
55 |
+ "showSelector": false, |
|
56 |
+ "showVersion": true |
|
57 |
+ }, |
|
58 |
+ "imagePref": { |
|
59 |
+ "color": 0, |
|
60 |
+ "height": 32, |
|
61 |
+ "columns": 16, |
|
62 |
+ "margin": 16, |
|
63 |
+ "png": false, |
|
64 |
+ "sprites": true, |
|
65 |
+ "prefix": "icon-" |
|
66 |
+ }, |
|
67 |
+ "historySize": 100, |
|
68 |
+ "showCodes": true, |
|
69 |
+ "gridSize": 16, |
|
70 |
+ "showLiga": false, |
|
71 |
+ "showGrid": true, |
|
72 |
+ "showGlyphs": true, |
|
73 |
+ "showQuickUse": true, |
|
74 |
+ "search": "", |
|
75 |
+ "quickUsageToken": { |
|
76 |
+ "UntitledProject1": "ZWEwOTk2NTRmNjMyOGQ1MzAwZWFiYmJlODViMWMzZDcjMiMxNDA3NzM0MTA2IyMj" |
|
77 |
+ }, |
|
78 |
+ "showQuickUse2": true, |
|
79 |
+ "showSVGs": true, |
|
80 |
+ "fontHostingName": false |
|
81 |
+ } |
|
82 |
+} |
@@ -0,0 +1,241 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simple-hotkeys', ["jquery","simple-module"], function ($, SimpleModule) { |
|
5 |
+ return (root['hotkeys'] = factory($, SimpleModule)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery"),require("simple-module")); |
|
12 |
+ } else { |
|
13 |
+ root.simple = root.simple || {}; |
|
14 |
+ root.simple['hotkeys'] = factory(jQuery,SimpleModule); |
|
15 |
+ } |
|
16 |
+}(this, function ($, SimpleModule) { |
|
17 |
+ |
|
18 |
+var Hotkeys, hotkeys, |
|
19 |
+ extend = 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; }, |
|
20 |
+ hasProp = {}.hasOwnProperty; |
|
21 |
+ |
|
22 |
+Hotkeys = (function(superClass) { |
|
23 |
+ extend(Hotkeys, superClass); |
|
24 |
+ |
|
25 |
+ function Hotkeys() { |
|
26 |
+ return Hotkeys.__super__.constructor.apply(this, arguments); |
|
27 |
+ } |
|
28 |
+ |
|
29 |
+ Hotkeys.count = 0; |
|
30 |
+ |
|
31 |
+ Hotkeys.keyNameMap = { |
|
32 |
+ 8: "Backspace", |
|
33 |
+ 9: "Tab", |
|
34 |
+ 13: "Enter", |
|
35 |
+ 16: "Shift", |
|
36 |
+ 17: "Control", |
|
37 |
+ 18: "Alt", |
|
38 |
+ 19: "Pause", |
|
39 |
+ 20: "CapsLock", |
|
40 |
+ 27: "Esc", |
|
41 |
+ 32: "Spacebar", |
|
42 |
+ 33: "PageUp", |
|
43 |
+ 34: "PageDown", |
|
44 |
+ 35: "End", |
|
45 |
+ 36: "Home", |
|
46 |
+ 37: "Left", |
|
47 |
+ 38: "Up", |
|
48 |
+ 39: "Right", |
|
49 |
+ 40: "Down", |
|
50 |
+ 45: "Insert", |
|
51 |
+ 46: "Del", |
|
52 |
+ 91: "Meta", |
|
53 |
+ 93: "Meta", |
|
54 |
+ 48: "0", |
|
55 |
+ 49: "1", |
|
56 |
+ 50: "2", |
|
57 |
+ 51: "3", |
|
58 |
+ 52: "4", |
|
59 |
+ 53: "5", |
|
60 |
+ 54: "6", |
|
61 |
+ 55: "7", |
|
62 |
+ 56: "8", |
|
63 |
+ 57: "9", |
|
64 |
+ 65: "A", |
|
65 |
+ 66: "B", |
|
66 |
+ 67: "C", |
|
67 |
+ 68: "D", |
|
68 |
+ 69: "E", |
|
69 |
+ 70: "F", |
|
70 |
+ 71: "G", |
|
71 |
+ 72: "H", |
|
72 |
+ 73: "I", |
|
73 |
+ 74: "J", |
|
74 |
+ 75: "K", |
|
75 |
+ 76: "L", |
|
76 |
+ 77: "M", |
|
77 |
+ 78: "N", |
|
78 |
+ 79: "O", |
|
79 |
+ 80: "P", |
|
80 |
+ 81: "Q", |
|
81 |
+ 82: "R", |
|
82 |
+ 83: "S", |
|
83 |
+ 84: "T", |
|
84 |
+ 85: "U", |
|
85 |
+ 86: "V", |
|
86 |
+ 87: "W", |
|
87 |
+ 88: "X", |
|
88 |
+ 89: "Y", |
|
89 |
+ 90: "Z", |
|
90 |
+ 96: "0", |
|
91 |
+ 97: "1", |
|
92 |
+ 98: "2", |
|
93 |
+ 99: "3", |
|
94 |
+ 100: "4", |
|
95 |
+ 101: "5", |
|
96 |
+ 102: "6", |
|
97 |
+ 103: "7", |
|
98 |
+ 104: "8", |
|
99 |
+ 105: "9", |
|
100 |
+ 106: "Multiply", |
|
101 |
+ 107: "Add", |
|
102 |
+ 109: "Subtract", |
|
103 |
+ 110: "Decimal", |
|
104 |
+ 111: "Divide", |
|
105 |
+ 112: "F1", |
|
106 |
+ 113: "F2", |
|
107 |
+ 114: "F3", |
|
108 |
+ 115: "F4", |
|
109 |
+ 116: "F5", |
|
110 |
+ 117: "F6", |
|
111 |
+ 118: "F7", |
|
112 |
+ 119: "F8", |
|
113 |
+ 120: "F9", |
|
114 |
+ 121: "F10", |
|
115 |
+ 122: "F11", |
|
116 |
+ 123: "F12", |
|
117 |
+ 124: "F13", |
|
118 |
+ 125: "F14", |
|
119 |
+ 126: "F15", |
|
120 |
+ 127: "F16", |
|
121 |
+ 128: "F17", |
|
122 |
+ 129: "F18", |
|
123 |
+ 130: "F19", |
|
124 |
+ 131: "F20", |
|
125 |
+ 132: "F21", |
|
126 |
+ 133: "F22", |
|
127 |
+ 134: "F23", |
|
128 |
+ 135: "F24", |
|
129 |
+ 59: ";", |
|
130 |
+ 61: "=", |
|
131 |
+ 186: ";", |
|
132 |
+ 187: "=", |
|
133 |
+ 188: ",", |
|
134 |
+ 190: ".", |
|
135 |
+ 191: "/", |
|
136 |
+ 192: "`", |
|
137 |
+ 219: "[", |
|
138 |
+ 220: "\\", |
|
139 |
+ 221: "]", |
|
140 |
+ 222: "'" |
|
141 |
+ }; |
|
142 |
+ |
|
143 |
+ Hotkeys.aliases = { |
|
144 |
+ "escape": "esc", |
|
145 |
+ "delete": "del", |
|
146 |
+ "return": "enter", |
|
147 |
+ "ctrl": "control", |
|
148 |
+ "space": "spacebar", |
|
149 |
+ "ins": "insert", |
|
150 |
+ "cmd": "meta", |
|
151 |
+ "command": "meta", |
|
152 |
+ "wins": "meta", |
|
153 |
+ "windows": "meta" |
|
154 |
+ }; |
|
155 |
+ |
|
156 |
+ Hotkeys.normalize = function(shortcut) { |
|
157 |
+ var i, j, key, keyname, keys, len; |
|
158 |
+ keys = shortcut.toLowerCase().replace(/\s+/gi, "").split("+"); |
|
159 |
+ for (i = j = 0, len = keys.length; j < len; i = ++j) { |
|
160 |
+ key = keys[i]; |
|
161 |
+ keys[i] = this.aliases[key] || key; |
|
162 |
+ } |
|
163 |
+ keyname = keys.pop(); |
|
164 |
+ keys.sort().push(keyname); |
|
165 |
+ return keys.join("_"); |
|
166 |
+ }; |
|
167 |
+ |
|
168 |
+ Hotkeys.prototype.opts = { |
|
169 |
+ el: document |
|
170 |
+ }; |
|
171 |
+ |
|
172 |
+ Hotkeys.prototype._init = function() { |
|
173 |
+ this.id = ++this.constructor.count; |
|
174 |
+ this._map = {}; |
|
175 |
+ this._delegate = typeof this.opts.el === "string" ? document : this.opts.el; |
|
176 |
+ return $(this._delegate).on("keydown.simple-hotkeys-" + this.id, this.opts.el, (function(_this) { |
|
177 |
+ return function(e) { |
|
178 |
+ var ref; |
|
179 |
+ return (ref = _this._getHander(e)) != null ? ref.call(_this, e) : void 0; |
|
180 |
+ }; |
|
181 |
+ })(this)); |
|
182 |
+ }; |
|
183 |
+ |
|
184 |
+ Hotkeys.prototype._getHander = function(e) { |
|
185 |
+ var keyname, shortcut; |
|
186 |
+ if (!(keyname = this.constructor.keyNameMap[e.which])) { |
|
187 |
+ return; |
|
188 |
+ } |
|
189 |
+ shortcut = ""; |
|
190 |
+ if (e.altKey) { |
|
191 |
+ shortcut += "alt_"; |
|
192 |
+ } |
|
193 |
+ if (e.ctrlKey) { |
|
194 |
+ shortcut += "control_"; |
|
195 |
+ } |
|
196 |
+ if (e.metaKey) { |
|
197 |
+ shortcut += "meta_"; |
|
198 |
+ } |
|
199 |
+ if (e.shiftKey) { |
|
200 |
+ shortcut += "shift_"; |
|
201 |
+ } |
|
202 |
+ shortcut += keyname.toLowerCase(); |
|
203 |
+ return this._map[shortcut]; |
|
204 |
+ }; |
|
205 |
+ |
|
206 |
+ Hotkeys.prototype.respondTo = function(subject) { |
|
207 |
+ if (typeof subject === 'string') { |
|
208 |
+ return this._map[this.constructor.normalize(subject)] != null; |
|
209 |
+ } else { |
|
210 |
+ return this._getHander(subject) != null; |
|
211 |
+ } |
|
212 |
+ }; |
|
213 |
+ |
|
214 |
+ Hotkeys.prototype.add = function(shortcut, handler) { |
|
215 |
+ this._map[this.constructor.normalize(shortcut)] = handler; |
|
216 |
+ return this; |
|
217 |
+ }; |
|
218 |
+ |
|
219 |
+ Hotkeys.prototype.remove = function(shortcut) { |
|
220 |
+ delete this._map[this.constructor.normalize(shortcut)]; |
|
221 |
+ return this; |
|
222 |
+ }; |
|
223 |
+ |
|
224 |
+ Hotkeys.prototype.destroy = function() { |
|
225 |
+ $(this._delegate).off(".simple-hotkeys-" + this.id); |
|
226 |
+ this._map = {}; |
|
227 |
+ return this; |
|
228 |
+ }; |
|
229 |
+ |
|
230 |
+ return Hotkeys; |
|
231 |
+ |
|
232 |
+})(SimpleModule); |
|
233 |
+ |
|
234 |
+hotkeys = function(opts) { |
|
235 |
+ return new Hotkeys(opts); |
|
236 |
+}; |
|
237 |
+ |
|
238 |
+return hotkeys; |
|
239 |
+ |
|
240 |
+})); |
|
241 |
+ |
@@ -0,0 +1,7 @@ |
||
1 |
+!function(a,b){"function"==typeof define&&define.amd? |
|
2 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
3 |
+define("simple-hotkeys",["jquery","simple-module"],function(c,d){return a.hotkeys=b(c,d)}):"object"==typeof exports? |
|
4 |
+// Node. Does not work with strict CommonJS, but |
|
5 |
+// only CommonJS-like environments that support module.exports, |
|
6 |
+// like Node. |
|
7 |
+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=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(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(f=a.toLowerCase().replace(/\s+/gi,"").split("+"),b=c=0,g=f.length;g>c;b=++c)d=f[b],f[b]=this.aliases[d]||d;return e=f.pop(),f.sort().push(e),f.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)}}); |
@@ -0,0 +1,4 @@ |
||
1 |
+/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ |
|
2 |
+!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+-new Date,v=a.document,w=0,x=0,y=gb(),z=gb(),A=gb(),B=function(a,b){return a===b&&(l=!0),0},C="undefined",D=1<<31,E={}.hasOwnProperty,F=[],G=F.pop,H=F.push,I=F.push,J=F.slice,K=F.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},L="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",M="[\\x20\\t\\r\\n\\f]",N="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",O=N.replace("w","w#"),P="\\["+M+"*("+N+")(?:"+M+"*([*^$|!~]?=)"+M+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+O+"))|)"+M+"*\\]",Q=":("+N+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+P+")*)|.*)\\)|)",R=new RegExp("^"+M+"+|((?:^|[^\\\\])(?:\\\\.)*)"+M+"+$","g"),S=new RegExp("^"+M+"*,"+M+"*"),T=new RegExp("^"+M+"*([>+~]|"+M+")"+M+"*"),U=new RegExp("="+M+"*([^\\]'\"]*?)"+M+"*\\]","g"),V=new RegExp(Q),W=new RegExp("^"+O+"$"),X={ID:new RegExp("^#("+N+")"),CLASS:new RegExp("^\\.("+N+")"),TAG:new RegExp("^("+N.replace("w","w*")+")"),ATTR:new RegExp("^"+P),PSEUDO:new RegExp("^"+Q),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+L+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ab=/[+~]/,bb=/'|\\/g,cb=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),db=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{I.apply(F=J.call(v.childNodes),v.childNodes),F[v.childNodes.length].nodeType}catch(eb){I={apply:F.length?function(a,b){H.apply(a,J.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function fb(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],!a||"string"!=typeof a)return d;if(1!==(k=b.nodeType)&&9!==k)return[];if(p&&!e){if(f=_.exec(a))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return I.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return I.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=9===k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(bb,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+qb(o[l]);w=ab.test(a)&&ob(b.parentNode)||b,x=o.join(",")}if(x)try{return I.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function gb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function hb(a){return a[u]=!0,a}function ib(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function jb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function kb(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||D)-(~a.sourceIndex||D);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function lb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function mb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function nb(a){return hb(function(b){return b=+b,hb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function ob(a){return a&&typeof a.getElementsByTagName!==C&&a}c=fb.support={},f=fb.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=fb.setDocument=function(a){var b,e=a?a.ownerDocument||a:v,g=e.defaultView;return e!==n&&9===e.nodeType&&e.documentElement?(n=e,o=e.documentElement,p=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){m()},!1):g.attachEvent&&g.attachEvent("onunload",function(){m()})),c.attributes=ib(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ib(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(e.getElementsByClassName)&&ib(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=ib(function(a){return o.appendChild(a).id=u,!e.getElementsByName||!e.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==C&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(cb,db);return function(a){var c=typeof a.getAttributeNode!==C&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==C?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==C&&p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(e.querySelectorAll))&&(ib(function(a){a.innerHTML="<select msallowclip=''><option selected=''></option></select>",a.querySelectorAll("[msallowclip^='']").length&&q.push("[*^$]="+M+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+M+"*(?:value|"+L+")"),a.querySelectorAll(":checked").length||q.push(":checked")}),ib(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+M+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ib(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",Q)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===v&&t(v,a)?-1:b===e||b.ownerDocument===v&&t(v,b)?1:k?K.call(k,a)-K.call(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],i=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:k?K.call(k,a)-K.call(k,b):0;if(f===g)return kb(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?kb(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},e):n},fb.matches=function(a,b){return fb(a,null,null,b)},fb.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return fb(b,n,null,[a]).length>0},fb.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},fb.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&E.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},fb.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},fb.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=fb.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=fb.selectors={cacheLength:50,createPseudo:hb,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(cb,db),a[3]=(a[3]||a[4]||a[5]||"").replace(cb,db),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||fb.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&fb.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(cb,db).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+M+")"+a+"("+M+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==C&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=fb.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||fb.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?hb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=K.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:hb(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?hb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:hb(function(a){return function(b){return fb(a,b).length>0}}),contains:hb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:hb(function(a){return W.test(a||"")||fb.error("unsupported lang: "+a),a=a.replace(cb,db).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:nb(function(){return[0]}),last:nb(function(a,b){return[b-1]}),eq:nb(function(a,b,c){return[0>c?c+b:c]}),even:nb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:nb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:nb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:nb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=lb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=mb(b);function pb(){}pb.prototype=d.filters=d.pseudos,d.setFilters=new pb,g=fb.tokenize=function(a,b){var c,e,f,g,h,i,j,k=z[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=S.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=T.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(R," ")}),h=h.slice(c.length));for(g in d.filter)!(e=X[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?fb.error(a):z(a,i).slice(0)};function qb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function rb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function sb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function tb(a,b,c){for(var d=0,e=b.length;e>d;d++)fb(a,b[d],c);return c}function ub(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function vb(a,b,c,d,e,f){return d&&!d[u]&&(d=vb(d)),e&&!e[u]&&(e=vb(e,f)),hb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||tb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:ub(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=ub(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?K.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=ub(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):I.apply(g,r)})}function wb(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=rb(function(a){return a===b},h,!0),l=rb(function(a){return K.call(b,a)>-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>i;i++)if(c=d.relative[a[i].type])m=[rb(sb(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return vb(i>1&&sb(m),i>1&&qb(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&wb(a.slice(i,e)),f>e&&wb(a=a.slice(e)),f>e&&qb(a))}m.push(c)}return sb(m)}function xb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=G.call(i));s=ub(s)}I.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&fb.uniqueSort(i)}return k&&(w=v,j=t),r};return c?hb(f):f}return h=fb.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=wb(b[c]),f[u]?d.push(f):e.push(f);f=A(a,xb(e,d)),f.selector=a}return f},i=fb.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(cb,db),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(cb,db),ab.test(j[0].type)&&ob(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&qb(j),!a)return I.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,ab.test(a)&&ob(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ib(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ib(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||jb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ib(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||jb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ib(function(a){return null==a.getAttribute("disabled")})||jb(L,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),fb}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+Math.random()}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b) |
|
3 |
+},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?n.queue(this[0],a):void 0===b?this:this.each(function(){var c=n.queue(this,a,b);n._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&n.dequeue(this,a)})},dequeue:function(a){return this.each(function(){n.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=n.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===n.css(a,"display")||!n.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=l.createDocumentFragment(),b=a.appendChild(l.createElement("div")),c=l.createElement("input");c.setAttribute("type","radio"),c.setAttribute("checked","checked"),c.setAttribute("name","t"),b.appendChild(c),k.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||l,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[n.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new n.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=l),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&n.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return n.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&a.originalEvent&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=n.extend(new n.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?n.event.trigger(e,null,b):n.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},n.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},n.Event=function(a,b){return this instanceof n.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.returnValue===!1?Z:$):this.type=a,b&&n.extend(this,b),this.timeStamp=a&&a.timeStamp||n.now(),void(this[n.expando]=!0)):new n.Event(a,b)},n.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){var a=this.originalEvent;this.isImmediatePropagationStopped=Z,a&&a.stopImmediatePropagation&&a.stopImmediatePropagation(),this.stopPropagation()}},n.each({mouseenter:"mouseover",mouseleave:"mouseout",pointerenter:"pointerover",pointerleave:"pointerout"},function(a,b){n.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!n.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),k.focusinBubbles||n.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){n.event.simulate(b,a.target,n.event.fix(a),!0)};n.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),n.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return n().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=n.guid++)),this.each(function(){n.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,n(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){n.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){n.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?n.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(ob(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(ob(c,"script"),kb),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(hb,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function tb(a){var b=l,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||n("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||n.contains(a.ownerDocument,a)||(g=n.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d=l.documentElement,e=l.createElement("div"),f=l.createElement("div");if(f.style){f.style.backgroundClip="content-box",f.cloneNode(!0).style.backgroundClip="",k.clearCloneStyle="content-box"===f.style.backgroundClip,e.style.cssText="border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;position:absolute",e.appendChild(f);function g(){f.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute",f.innerHTML="",d.appendChild(e);var g=a.getComputedStyle(f,null);b="1%"!==g.top,c="4px"===g.width,d.removeChild(e)}a.getComputedStyle&&n.extend(k,{pixelPosition:function(){return g(),b},boxSizingReliable:function(){return null==c&&g(),c},reliableMarginRight:function(){var b,c=f.appendChild(l.createElement("div"));return c.style.cssText=f.style.cssText="-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0",c.style.marginRight=c.style.width="0",f.style.width="1px",d.appendChild(e),b=!parseFloat(a.getComputedStyle(c,null).marginRight),d.removeChild(e),b}})}}(),n.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:"0",fontWeight:"400"},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=n.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=n.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=n.css(a,"border"+R[f]+"Width",!0,e))):(g+=n.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=n.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===n.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(k.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):(e=S(d),"none"===c&&e||L.set(d,"olddisplay",e?c:n.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}n.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=n.camelCase(b),i=a.style;return b=n.cssProps[h]||(n.cssProps[h]=Fb(i,h)),g=n.cssHooks[b]||n.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(n.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||n.cssNumber[h]||(c+="px"),k.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=n.camelCase(b);return b=n.cssProps[h]||(n.cssProps[h]=Fb(a.style,h)),g=n.cssHooks[b]||n.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||n.isNumeric(f)?f||0:e):e}}),n.each(["height","width"],function(a,b){n.cssHooks[b]={get:function(a,c,d){return c?zb.test(n.css(a,"display"))&&0===a.offsetWidth?n.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===n.css(a,"boxSizing",!1,e),e):0)}}}),n.cssHooks.marginRight=yb(k.reliableMarginRight,function(a,b){return b?n.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),n.each({margin:"",padding:"",border:"Width"},function(a,b){n.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(n.cssHooks[a+b].set=Gb)}),n.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(n.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=n.css(a,b[g],!1,d);return f}return void 0!==c?n.style(a,b,c):n.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?n(this).show():n(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}n.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(n.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?n.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=n.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){n.fx.step[a.prop]?n.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[n.cssProps[a.prop]]||n.cssHooks[a.prop])?n.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},n.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},n.fx=Kb.prototype.init,n.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(n.cssNumber[a]?"":"px"),g=(n.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(n.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,n.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=n.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},o=a.style,p=a.nodeType&&S(a),q=L.get(a,"fxshow");c.queue||(h=n._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,n.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[o.overflow,o.overflowX,o.overflowY],j=n.css(a,"display"),k="none"===j?L.get(a,"olddisplay")||tb(a.nodeName):j,"inline"===k&&"none"===n.css(a,"float")&&(o.display="inline-block")),c.overflow&&(o.overflow="hidden",l.always(function(){o.overflow=c.overflow[0],o.overflowX=c.overflow[1],o.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(p?"hide":"show")){if("show"!==e||!q||void 0===q[d])continue;p=!0}m[d]=q&&q[d]||n.style(a,d)}else j=void 0;if(n.isEmptyObject(m))"inline"===("none"===j?tb(a.nodeName):j)&&(o.display=j);else{q?"hidden"in q&&(p=q.hidden):q=L.access(a,"fxshow",{}),f&&(q.hidden=!p),p?n(a).show():l.done(function(){n(a).hide()}),l.done(function(){var b;L.remove(a,"fxshow");for(b in m)n.style(a,b,m[b])});for(d in m)g=Ub(p?q[d]:0,d,l),d in q||(q[d]=g.start,p&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=n.camelCase(c),e=b[d],f=a[c],n.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=n.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=n.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:n.extend({},b),opts:n.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=n.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return n.map(k,Ub,j),n.isFunction(j.opts.start)&&j.opts.start.call(a,j),n.fx.timer(n.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}n.Animation=n.extend(Xb,{tweener:function(a,b){n.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),n.speed=function(a,b,c){var d=a&&"object"==typeof a?n.extend({},a):{complete:c||!c&&b||n.isFunction(a)&&a,duration:a,easing:c&&b||b&&!n.isFunction(b)&&b};return d.duration=n.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in n.fx.speeds?n.fx.speeds[d.duration]:n.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){n.isFunction(d.old)&&d.old.call(this),d.queue&&n.dequeue(this,d.queue)},d},n.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=n.isEmptyObject(a),f=n.speed(b,c,d),g=function(){var b=Xb(this,n.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=n.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&n.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=n.timers,g=d?d.length:0;for(c.finish=!0,n.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),n.each(["toggle","show","hide"],function(a,b){var c=n.fn[b];n.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),n.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){n.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),n.timers=[],n.fx.tick=function(){var a,b=0,c=n.timers;for(Lb=n.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||n.fx.stop(),Lb=void 0},n.fx.timer=function(a){n.timers.push(a),a()?n.fx.start():n.timers.pop()},n.fx.interval=13,n.fx.start=function(){Mb||(Mb=setInterval(n.fx.tick,n.fx.interval))},n.fx.stop=function(){clearInterval(Mb),Mb=null},n.fx.speeds={slow:600,fast:200,_default:400},n.fn.delay=function(a,b){return a=n.fx?n.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=l.createElement("input"),b=l.createElement("select"),c=b.appendChild(l.createElement("option"));a.type="checkbox",k.checkOn=""!==a.value,k.optSelected=c.selected,b.disabled=!0,k.optDisabled=!c.disabled,a=l.createElement("input"),a.value="t",a.type="radio",k.radioValue="t"===a.value}();var Yb,Zb,$b=n.expr.attrHandle;n.fn.extend({attr:function(a,b){return J(this,n.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){n.removeAttr(this,a)})}}),n.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?n.prop(a,b,c):(1===f&&n.isXMLDoc(a)||(b=b.toLowerCase(),d=n.attrHooks[b]||(n.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void n.removeAttr(a,b)) |
|
4 |
+},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=n.propFix[c]||c,n.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!k.radioValue&&"radio"===b&&n.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?n.removeAttr(a,c):a.setAttribute(c,c),c}},n.each(n.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||n.find.attr;$b[b]=function(a,b,d){var e,f;return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;n.fn.extend({prop:function(a,b){return J(this,n.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[n.propFix[a]||a]})}}),n.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!n.isXMLDoc(a),f&&(b=n.propFix[b]||b,e=n.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),k.optSelected||(n.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),n.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){n.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;n.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=n.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(n.isFunction(a))return this.each(function(b){n(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?n.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(n.isFunction(a)?function(c){n(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=n(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;n.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=n.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,n(this).val()):a,null==e?e="":"number"==typeof e?e+="":n.isArray(e)&&(e=n.map(e,function(a){return null==a?"":a+""})),b=n.valHooks[this.type]||n.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=n.valHooks[e.type]||n.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),n.extend({valHooks:{option:{get:function(a){var b=n.find.attr(a,"value");return null!=b?b:n.trim(n.text(a))}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(k.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&n.nodeName(c.parentNode,"optgroup"))){if(b=n(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=n.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=n.inArray(d.value,f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),n.each(["radio","checkbox"],function(){n.valHooks[this]={set:function(a,b){return n.isArray(b)?a.checked=n.inArray(n(a).val(),b)>=0:void 0}},k.checkOn||(n.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),n.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){n.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),n.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=n.now(),dc=/\?/;n.parseJSON=function(a){return JSON.parse(a+"")},n.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&n.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=l.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(n.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,n.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=n.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&n.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}n.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":n.parseJSON,"text xml":n.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,n.ajaxSettings),b):tc(n.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=n.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?n(l):n.event,o=n.Deferred(),p=n.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(o.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=n.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=n.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===n.active++&&n.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(n.lastModified[d]&&v.setRequestHeader("If-Modified-Since",n.lastModified[d]),n.etag[d]&&v.setRequestHeader("If-None-Match",n.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(n.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(n.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?o.resolveWith(l,[r,x,v]):o.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--n.active||n.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return n.get(a,b,c,"json")},getScript:function(a,b){return n.get(a,void 0,b,"script")}}),n.each(["get","post"],function(a,b){n[b]=function(a,c,d,e){return n.isFunction(c)&&(e=e||d,d=c,c=void 0),n.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),n.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){n.fn[b]=function(a){return this.on(b,a)}}),n._evalUrl=function(a){return n.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},n.fn.extend({wrapAll:function(a){var b;return n.isFunction(a)?this.each(function(b){n(this).wrapAll(a.call(this,b))}):(this[0]&&(b=n(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(n.isFunction(a)?function(b){n(this).wrapInner(a.call(this,b))}:function(){var b=n(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=n.isFunction(a);return this.each(function(c){n(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){n.nodeName(this,"body")||n(this).replaceWith(this.childNodes)}).end()}}),n.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},n.expr.filters.visible=function(a){return!n.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(n.isArray(b))n.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==n.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}n.param=function(a,b){var c,d=[],e=function(a,b){b=n.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=n.ajaxSettings&&n.ajaxSettings.traditional),n.isArray(a)||a.jquery&&!n.isPlainObject(a))n.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},n.fn.extend({serialize:function(){return n.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=n.prop(this,"elements");return a?n.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!n(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=n(this).val();return null==c?null:n.isArray(c)?n.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),n.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=n.ajaxSettings.xhr();a.ActiveXObject&&n(a).on("unload",function(){for(var a in Dc)Dc[a]()}),k.cors=!!Fc&&"withCredentials"in Fc,k.ajax=Fc=!!Fc,n.ajaxTransport(function(a){var b;return k.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort");try{f.send(a.hasContent&&a.data||null)}catch(h){if(b)throw h}},abort:function(){b&&b()}}:void 0}),n.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return n.globalEval(a),a}}}),n.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),n.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=n("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),l.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;n.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||n.expando+"_"+cc++;return this[a]=!0,a}}),n.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=n.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||n.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&n.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),n.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||l;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=n.buildFragment([a],b,e),e&&e.length&&n(e).remove(),n.merge([],d.childNodes))};var Ic=n.fn.load;n.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=n.trim(a.slice(h)),a=a.slice(0,h)),n.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&n.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?n("<div>").append(n.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},n.expr.filters.animated=function(a){return n.grep(n.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return n.isWindow(a)?a:9===a.nodeType&&a.defaultView}n.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=n.css(a,"position"),l=n(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=n.css(a,"top"),i=n.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),n.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},n.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){n.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,n.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===n.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),n.nodeName(a[0],"html")||(d=a.offset()),d.top+=n.css(a[0],"borderTopWidth",!0),d.left+=n.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-n.css(c,"marginTop",!0),left:b.left-d.left-n.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!n.nodeName(a,"html")&&"static"===n.css(a,"position"))a=a.offsetParent;return a||Jc})}}),n.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;n.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),n.each(["top","left"],function(a,b){n.cssHooks[b]=yb(k.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?n(a).position()[b]+"px":c):void 0})}),n.each({Height:"height",Width:"width"},function(a,b){n.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){n.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return n.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var Lc=a.jQuery,Mc=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=Mc),b&&a.jQuery===n&&(a.jQuery=Lc),n},typeof b===U&&(a.jQuery=a.$=n),n}); |
@@ -0,0 +1,4 @@ |
||
1 |
+(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.options.tables?this.rules=p.tables:this.rules=p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=u.breaks:this.rules=u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function a(t,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=h({},a.defaults,n||{});var l,o,p=n.highlight,u=0;try{l=e.lex(t,n)}catch(c){return i(c)}o=l.length;var g=function(e){if(e)return n.highlight=p,i(e);var t;try{t=r.parse(l,n)}catch(s){e=s}return n.highlight=p,e?i(e):i(null,t)};if(!p||p.length<3)return g();if(delete n.highlight,!o)return g();for(;u<l.length;u++)!function(e){return"code"!==e.type?--o||g():p(e.text,e.lang,function(t,n){return t?g(t):null==n||n===e.text?--o||g():(e.text=n,e.escaped=!0,void(--o||g()))})}(l[u])}else try{return n&&(n=h({},a.defaults,n)),r.parse(e.lex(t,n),n)}catch(c){if(c.message+="\nPlease report this to https://github.com/chjj/marked.",(n||a.defaults).silent)return"<p>An error occured:</p><pre>"+s(c.message+"",!0)+"</pre>";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]||""});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.lheading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(i=this.rules.hr.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;c>u;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(t&&(i=this.rules.paragraph.exec(e)))e=e.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=this.renderer.text(s(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,s=0;r>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+s(t,!0)+'">'+(n?e:s(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:s(e,!0))+"\n</code></pre>"},n.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},n.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},n.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},n.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},n.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},n.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"</"+n+">\n"},n.prototype.strong=function(e){return"<strong>"+e+"</strong>"},n.prototype.em=function(e){return"<em>"+e+"</em>"},n.prototype.codespan=function(e){return"<code>"+e+"</code>"},n.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},n.prototype.del=function(e){return"<del>"+e+"</del>"},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>"},n.prototype.image=function(e,t,n){var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},n.prototype.text=function(e){return e},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;e<this.token.header.length;e++)r={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(i+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",s=0;s<t.length;s++)n+=this.renderer.tablecell(this.inline.output(t[s]),{header:!1,align:this.token.align[s]});l+=this.renderer.tablerow(n)}return this.renderer.table(i,l);case"blockquote_start":for(var l="";"blockquote_end"!==this.next().type;)l+=this.tok();return this.renderer.blockquote(l);case"list_start":for(var l="",o=this.token.ordered;"list_end"!==this.next().type;)l+=this.tok();return this.renderer.list(l,o);case"list_item_start":for(var l="";"list_item_end"!==this.next().type;)l+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(l);case"loose_item_start":for(var l="";"list_item_end"!==this.next().type;)l+=this.tok();return this.renderer.listitem(l);case"html":var h=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(h);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},o.exec=o,a.options=a.setOptions=function(e){return h(a.defaults,e),a},a.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new n,xhtml:!1},a.Parser=r,a.parser=r.parse,a.Renderer=n,a.Lexer=e,a.lexer=e.lex,a.InlineLexer=t,a.inlineLexer=t.output,a.parse=a,"undefined"!=typeof module&&"object"==typeof exports?module.exports=a:"function"==typeof define&&define.amd?define(function(){return a}):this.marked=a}).call(function(){return this||("undefined"!=typeof window?window:global)}()); |
|
2 |
+//# sourceMappingURL=marked.min.js.map(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else{if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else{if(typeof global!=="undefined"){g=global}else{if(typeof self!=="undefined"){g=self}else{g=this}}}g.toMarkdown=f()}}})(function(){var define,module,exports;return(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){return a(o,!0)}if(i){return i(o,!0)}var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++){s(r[o])}return s})({1:[function(require,module,exports){var toMarkdown;var converters;var mdConverters=require("./lib/md-converters");var gfmConverters=require("./lib/gfm-converters");var HtmlParser=require("./lib/html-parser");var collapse=require("collapse-whitespace");var blocks=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function isBlock(node){return blocks.indexOf(node.nodeName.toLowerCase())!==-1}var voids=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function isVoid(node){return voids.indexOf(node.nodeName.toLowerCase())!==-1}function htmlToDom(string){var tree=new HtmlParser().parseFromString(string,"text/html");collapse(tree.documentElement,isBlock);return tree}function bfsOrder(node){var inqueue=[node];var outqueue=[];var elem;var children;var i;while(inqueue.length>0){elem=inqueue.shift();outqueue.push(elem);children=elem.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){inqueue.push(children[i])}}}outqueue.shift();return outqueue}function getContent(node){var text="";for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType===1){text+=node.childNodes[i]._replacement}else{if(node.childNodes[i].nodeType===3){text+=node.childNodes[i].data}else{continue}}}return text}function outer(node,content){return node.cloneNode(false).outerHTML.replace("><",">"+content+"<")}function canConvert(node,filter){if(typeof filter==="string"){return filter===node.nodeName.toLowerCase()}if(Array.isArray(filter)){return filter.indexOf(node.nodeName.toLowerCase())!==-1}else{if(typeof filter==="function"){return filter.call(toMarkdown,node)}else{throw new TypeError("`filter` needs to be a string, array, or function")}}}function isFlankedByWhitespace(side,node){var sibling;var regExp;var isFlanked;if(side==="left"){sibling=node.previousSibling;regExp=/ $/}else{sibling=node.nextSibling;regExp=/^ /}if(sibling){if(sibling.nodeType===3){isFlanked=regExp.test(sibling.nodeValue)}else{if(sibling.nodeType===1&&!isBlock(sibling)){isFlanked=regExp.test(sibling.textContent)}}}return isFlanked}function flankingWhitespace(node,content){var leading="";var trailing="";if(!isBlock(node)){var hasLeading=/^[ \r\n\t]/.test(content);var hasTrailing=/[ \r\n\t]$/.test(content);if(hasLeading&&!isFlankedByWhitespace("left",node)){leading=" "}if(hasTrailing&&!isFlankedByWhitespace("right",node)){trailing=" "}}return{leading:leading,trailing:trailing}}function process(node){var replacement;var content=getContent(node);if(!isVoid(node)&&!/A|TH|TD/.test(node.nodeName)&&/^\s*$/i.test(content)){node._replacement="";return}for(var i=0;i<converters.length;i++){var converter=converters[i];if(canConvert(node,converter.filter)){if(typeof converter.replacement!=="function"){throw new TypeError("`replacement` needs to be a function that returns a string")}var whitespace=flankingWhitespace(node,content);if(whitespace.leading||whitespace.trailing){content=content.trim()}replacement=whitespace.leading+converter.replacement.call(toMarkdown,content,node)+whitespace.trailing;break}}node._replacement=replacement}toMarkdown=function(input,options){options=options||{};if(typeof input!=="string"){throw new TypeError(input+" is not a string")}if(input===""){return""}input=input.replace(/(\d+)\. /g,"$1\\. ");var clone=htmlToDom(input).body;var nodes=bfsOrder(clone);var output;converters=mdConverters.slice(0);if(options.gfm){converters=gfmConverters.concat(converters)}if(options.converters){converters=options.converters.concat(converters)}for(var i=nodes.length-1;i>=0;i--){process(nodes[i])}output=getContent(clone);return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")};toMarkdown.isBlock=isBlock;toMarkdown.isVoid=isVoid;toMarkdown.outer=outer;module.exports=toMarkdown},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){function cell(content,node){var index=Array.prototype.indexOf.call(node.parentNode.childNodes,node); |
|
3 |
+var prefix=" ";if(index===0){prefix="| "}return prefix+content+" |"}var highlightRegEx=/highlight highlight-(\S+)/;module.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(content){return"~~"+content+"~~"}},{filter:function(node){return node.type==="checkbox"&&node.parentNode.nodeName==="LI"},replacement:function(content,node){return(node.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(content,node){return cell(content,node)}},{filter:"tr",replacement:function(content,node){var borderCells="";var alignMap={left:":--",right:"--:",center:":-:"};if(node.parentNode.nodeName==="THEAD"){for(var i=0;i<node.childNodes.length;i++){var align=node.childNodes[i].attributes.align;var border="---";if(align){border=alignMap[align.value]||border}borderCells+=cell(border,node.childNodes[i])}}return"\n"+content+(borderCells?"\n"+borderCells:"")}},{filter:"table",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(content){return content}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n```\n"+node.firstChild.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="PRE"&&node.parentNode.nodeName==="DIV"&&highlightRegEx.test(node.parentNode.className)},replacement:function(content,node){var language=node.parentNode.className.match(highlightRegEx)[1];return"\n\n```"+language+"\n"+node.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="DIV"&&highlightRegEx.test(node.className)},replacement:function(content){return"\n\n"+content+"\n\n"}}]},{}],3:[function(require,module,exports){var _window=(typeof window!=="undefined"?window:this);function canParseHtmlNatively(){var Parser=_window.DOMParser;var canParse=false;try{if(new Parser().parseFromString("","text/html")){canParse=true}}catch(e){}return canParse}function createHtmlParser(){var Parser=function(){};if(typeof document==="undefined"){var jsdom=require("jsdom");Parser.prototype.parseFromString=function(string){return jsdom.jsdom(string,{features:{FetchExternalResources:[],ProcessExternalResources:false}})}}else{if(!shouldUseActiveX()){Parser.prototype.parseFromString=function(string){var doc=document.implementation.createHTMLDocument("");doc.open();doc.write(string);doc.close();return doc}}else{Parser.prototype.parseFromString=function(string){var doc=new window.ActiveXObject("htmlfile");doc.designMode="on";doc.open();doc.write(string);doc.close();return doc}}}return Parser}function shouldUseActiveX(){var useActiveX=false;try{document.implementation.createHTMLDocument("").open()}catch(e){if(window.ActiveXObject){useActiveX=true}}return useActiveX}module.exports=canParseHtmlNatively()?_window.DOMParser:createHtmlParser()},{"jsdom":6}],4:[function(require,module,exports){module.exports=[{filter:"p",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(content,node){var hLevel=node.nodeName.charAt(1);var hPrefix="";for(var i=0;i<hLevel;i++){hPrefix+="#"}return"\n\n"+hPrefix+" "+content+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(content){return"_"+content+"_"}},{filter:["strong","b"],replacement:function(content){return"**"+content+"**"}},{filter:function(node){var hasSiblings=node.previousSibling||node.nextSibling;var isCodeBlock=node.parentNode.nodeName==="PRE"&&!hasSiblings;return node.nodeName==="CODE"&&!isCodeBlock},replacement:function(content){return"`"+content+"`"}},{filter:function(node){return node.nodeName==="A"&&node.getAttribute("href")},replacement:function(content,node){var titlePart=node.title?' "'+node.title+'"':"";return"["+content+"]("+node.getAttribute("href")+titlePart+")"}},{filter:"img",replacement:function(content,node){var alt=node.alt||"";var src=node.getAttribute("src")||"";var title=node.title||"";var titlePart=title?' "'+title+'"':"";return src?"!["+alt+"]"+"("+src+titlePart+")":""}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n "+node.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(content){content=content.trim();content=content.replace(/\n{3,}/g,"\n\n");content=content.replace(/^/gm,"> ");return"\n\n"+content+"\n\n"}},{filter:"li",replacement:function(content,node){content=content.replace(/^\s+/,"").replace(/\n/gm,"\n ");var prefix="* ";var parent=node.parentNode;var index=Array.prototype.indexOf.call(parent.children,node)+1;prefix=/ol/i.test(parent.nodeName)?index+". ":"* ";return prefix+content}},{filter:["ul","ol"],replacement:function(content,node){var strings=[];for(var i=0;i<node.childNodes.length;i++){strings.push(node.childNodes[i]._replacement) |
|
4 |
+}if(/li/i.test(node.parentNode.nodeName)){return"\n"+strings.join("\n")}return"\n\n"+strings.join("\n")+"\n\n"}},{filter:function(node){return this.isBlock(node)},replacement:function(content,node){return"\n\n"+this.outer(node,content)+"\n\n"}},{filter:function(){return true},replacement:function(content,node){return this.outer(node,content)}}]},{}],5:[function(require,module,exports){module.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],6:[function(require,module,exports){},{}],7:[function(require,module,exports){var voidElements=require("void-elements");Object.keys(voidElements).forEach(function(name){voidElements[name.toUpperCase()]=1});var blockElements={};require("block-elements").forEach(function(name){blockElements[name.toUpperCase()]=1});function isBlockElem(node){return !!(node&&blockElements[node.nodeName])}function isVoid(node){return !!(node&&voidElements[node.nodeName])}function collapseWhitespace(elem,isBlock){if(!elem.firstChild||elem.nodeName==="PRE"){return}if(typeof isBlock!=="function"){isBlock=isBlockElem}var prevText=null;var prevVoid=false;var prev=null;var node=next(prev,elem);while(node!==elem){if(node.nodeType===3){var text=node.data.replace(/[ \r\n\t]+/g," ");if((!prevText||/ $/.test(prevText.data))&&!prevVoid&&text[0]===" "){text=text.substr(1)}if(!text){node=remove(node);continue}node.data=text;prevText=node}else{if(node.nodeType===1){if(isBlock(node)||node.nodeName==="BR"){if(prevText){prevText.data=prevText.data.replace(/ $/,"")}prevText=null;prevVoid=false}else{if(isVoid(node)){prevText=null;prevVoid=true}}}else{node=remove(node);continue}}var nextNode=next(prev,node);prev=node;node=nextNode}if(prevText){prevText.data=prevText.data.replace(/ $/,"");if(!prevText.data){remove(prevText)}}}function remove(node){var next=node.nextSibling||node.parentNode;node.parentNode.removeChild(node);return next}function next(prev,current){if(prev&&prev.parentNode===current||current.nodeName==="PRE"){return current.nextSibling||current.parentNode}return current.firstChild||current.nextSibling||current.parentNode}module.exports=collapseWhitespace},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){module.exports={"area":true,"base":true,"br":true,"col":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"menuitem":true,"meta":true,"param":true,"source":true,"track":true,"wbr":true}},{}]},{},[1])(1)});(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-markdown",["jquery","simditor","to-markdown","marked"],function(a0,b1,c2,d3){return(root["SimditorMarkdown"]=factory(a0,b1,c2,d3))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"),require("to-markdown"),require("marked"))}else{root["SimditorMarkdown"]=factory(jQuery,Simditor,toMarkdown,marked)}}}(this,function($,Simditor,toMarkdown,marked){var SimditorMarkdown,extend=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},hasProp={}.hasOwnProperty;SimditorMarkdown=(function(superClass){extend(SimditorMarkdown,superClass);function SimditorMarkdown(){return SimditorMarkdown.__super__.constructor.apply(this,arguments)}SimditorMarkdown.prototype.name="markdown";SimditorMarkdown.prototype.icon="markdown";SimditorMarkdown.prototype.needFocus=false;SimditorMarkdown.prototype._init=function(){SimditorMarkdown.__super__._init.call(this);this.markdownEl=$('<div class="markdown-editor" />').insertBefore(this.editor.body);this.textarea=$("<textarea/>").attr("placeholder",this.editor.opts.placeholder).appendTo(this.markdownEl);this.textarea.on("focus",(function(_this){return function(e){return _this.editor.el.addClass("focus")}})(this)).on("blur",(function(_this){return function(e){return _this.editor.el.removeClass("focus")}})(this));this.editor.on("valuechanged",(function(_this){return function(e){if(!_this.editor.markdownMode){return}return _this._initMarkdownValue()}})(this));this.markdownChange=this.editor.util.throttle((function(_this){return function(){_this._autosizeTextarea();return _this._convert()}})(this),200);if(this.editor.util.support.oninput){this.textarea.on("input",(function(_this){return function(e){return _this.markdownChange()}})(this))}else{this.textarea.on("keyup",(function(_this){return function(e){return _this.markdownChange()}})(this))}if(this.editor.opts.markdown){return this.editor.on("initialized",(function(_this){return function(){return _this.el.mousedown()}})(this))}};SimditorMarkdown.prototype.status=function(){};SimditorMarkdown.prototype.command=function(){var button,i,len,ref;this.editor.blur();this.editor.el.toggleClass("simditor-markdown");this.editor.markdownMode=this.editor.el.hasClass("simditor-markdown");if(this.editor.markdownMode){this.editor.inputManager.lastCaretPosition=null;this.editor.hidePopover();this.editor.body.removeAttr("contenteditable");this._initMarkdownValue()}else{this.textarea.val("");this.editor.body.attr("contenteditable","true")}ref=this.editor.toolbar.buttons;for(i=0,len=ref.length;i<len;i++){button=ref[i];if(button.name==="markdown"){button.setActive(this.editor.markdownMode)}else{button.setDisabled(this.editor.markdownMode)}}return null};SimditorMarkdown.prototype._initMarkdownValue=function(){this._fileterUnsupportedTags();this.textarea.val(toMarkdown(this.editor.getValue(),{gfm:true}));return this._autosizeTextarea()};SimditorMarkdown.prototype._autosizeTextarea=function(){this._textareaPadding||(this._textareaPadding=this.textarea.innerHeight()-this.textarea.height());return this.textarea.height(this.textarea[0].scrollHeight-this._textareaPadding)};SimditorMarkdown.prototype._convert=function(){var markdownText,text;text=this.textarea.val();markdownText=marked(text);this.editor.textarea.val(markdownText);this.editor.body.html(markdownText);this.editor.formatter.format();return this.editor.formatter.decorate()};SimditorMarkdown.prototype._fileterUnsupportedTags=function(){return this.editor.body.find("colgroup").remove()};return SimditorMarkdown})(Simditor.Button);Simditor.Toolbar.addButton(SimditorMarkdown);return SimditorMarkdown})); |
@@ -0,0 +1,2 @@ |
||
1 |
+(function(){function e(e){this.tokens=[],this.tokens.links={},this.options=e||a.defaults,this.rules=p.normal,this.options.gfm&&(this.options.tables?this.rules=p.tables:this.rules=p.gfm)}function t(e,t){if(this.options=t||a.defaults,this.links=e,this.rules=u.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=u.breaks:this.rules=u.gfm:this.options.pedantic&&(this.rules=u.pedantic)}function n(e){this.options=e||{}}function r(e){this.tokens=[],this.token=null,this.options=e||a.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function s(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function i(e){return e.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function l(e,t){return e=e.source,t=t||"",function n(r,s){return r?(s=s.source||s,s=s.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,s),n):new RegExp(e,t)}}function o(){}function h(e){for(var t,n,r=1;r<arguments.length;r++){t=arguments[r];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}function a(t,n,i){if(i||"function"==typeof n){i||(i=n,n=null),n=h({},a.defaults,n||{});var l,o,p=n.highlight,u=0;try{l=e.lex(t,n)}catch(c){return i(c)}o=l.length;var g=function(e){if(e)return n.highlight=p,i(e);var t;try{t=r.parse(l,n)}catch(s){e=s}return n.highlight=p,e?i(e):i(null,t)};if(!p||p.length<3)return g();if(delete n.highlight,!o)return g();for(;u<l.length;u++)!function(e){return"code"!==e.type?--o||g():p(e.text,e.lang,function(t,n){return t?g(t):null==n||n===e.text?--o||g():(e.text=n,e.escaped=!0,void(--o||g()))})}(l[u])}else try{return n&&(n=h({},a.defaults,n)),r.parse(e.lex(t,n),n)}catch(c){if(c.message+="\nPlease report this to https://github.com/chjj/marked.",(n||a.defaults).silent)return"<p>An error occured:</p><pre>"+s(c.message+"",!0)+"</pre>";throw c}}var p={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:o,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:o,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:o,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};p.bullet=/(?:[*+-]|\d+\.)/,p.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,p.item=l(p.item,"gm")(/bull/g,p.bullet)(),p.list=l(p.list)(/bull/g,p.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+p.def.source+")")(),p.blockquote=l(p.blockquote)("def",p.def)(),p._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",p.html=l(p.html)("comment",/<!--[\s\S]*?-->/)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)(/tag/g,p._tag)(),p.paragraph=l(p.paragraph)("hr",p.hr)("heading",p.heading)("lheading",p.lheading)("blockquote",p.blockquote)("tag","<"+p._tag)("def",p.def)(),p.normal=h({},p),p.gfm=h({},p.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),p.gfm.paragraph=l(p.paragraph)("(?!","(?!"+p.gfm.fences.source.replace("\\1","\\2")+"|"+p.list.source.replace("\\1","\\3")+"|")(),p.tables=h({},p.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),e.rules=p,e.lex=function(t,n){var r=new e(n);return r.lex(t)},e.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},e.prototype.token=function(e,t,n){for(var r,s,i,l,o,h,a,u,c,e=e.replace(/^ +$/gm,"");e;)if((i=this.rules.newline.exec(e))&&(e=e.substring(i[0].length),i[0].length>1&&this.tokens.push({type:"space"})),i=this.rules.code.exec(e))e=e.substring(i[0].length),i=i[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?i:i.replace(/\n+$/,"")});else if(i=this.rules.fences.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"code",lang:i[2],text:i[3]||""});else if(i=this.rules.heading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:i[1].length,text:i[2]});else if(t&&(i=this.rules.nptable.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].split(/ *\| */);this.tokens.push(h)}else if(i=this.rules.lheading.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"heading",depth:"="===i[2]?1:2,text:i[1]});else if(i=this.rules.hr.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"hr"});else if(i=this.rules.blockquote.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"blockquote_start"}),i=i[0].replace(/^ *> ?/gm,""),this.token(i,t,!0),this.tokens.push({type:"blockquote_end"});else if(i=this.rules.list.exec(e)){for(e=e.substring(i[0].length),l=i[2],this.tokens.push({type:"list_start",ordered:l.length>1}),i=i[0].match(this.rules.item),r=!1,c=i.length,u=0;c>u;u++)h=i[u],a=h.length,h=h.replace(/^ *([*+-]|\d+\.) +/,""),~h.indexOf("\n ")&&(a-=h.length,h=this.options.pedantic?h.replace(/^ {1,4}/gm,""):h.replace(new RegExp("^ {1,"+a+"}","gm"),"")),this.options.smartLists&&u!==c-1&&(o=p.bullet.exec(i[u+1])[0],l===o||l.length>1&&o.length>1||(e=i.slice(u+1).join("\n")+e,u=c-1)),s=r||/\n\n(?!\s*$)/.test(h),u!==c-1&&(r="\n"===h.charAt(h.length-1),s||(s=r)),this.tokens.push({type:s?"loose_item_start":"list_item_start"}),this.token(h,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(i=this.rules.html.exec(e))e=e.substring(i[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===i[1]||"script"===i[1]||"style"===i[1]),text:i[0]});else if(!n&&t&&(i=this.rules.def.exec(e)))e=e.substring(i[0].length),this.tokens.links[i[1].toLowerCase()]={href:i[2],title:i[3]};else if(t&&(i=this.rules.table.exec(e))){for(e=e.substring(i[0].length),h={type:"table",header:i[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:i[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:i[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u<h.align.length;u++)/^ *-+: *$/.test(h.align[u])?h.align[u]="right":/^ *:-+: *$/.test(h.align[u])?h.align[u]="center":/^ *:-+ *$/.test(h.align[u])?h.align[u]="left":h.align[u]=null;for(u=0;u<h.cells.length;u++)h.cells[u]=h.cells[u].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(h)}else if(t&&(i=this.rules.paragraph.exec(e)))e=e.substring(i[0].length),this.tokens.push({type:"paragraph",text:"\n"===i[1].charAt(i[1].length-1)?i[1].slice(0,-1):i[1]});else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),this.tokens.push({type:"text",text:i[0]});else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0));return this.tokens};var u={escape:/^\\([\\`*{}\[\]()#+\-.!_>])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:o,tag:/^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:o,text:/^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/};u._inside=/(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/,u._href=/\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/,u.link=l(u.link)("inside",u._inside)("href",u._href)(),u.reflink=l(u.reflink)("inside",u._inside)(),u.normal=h({},u),u.pedantic=h({},u.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),u.gfm=h({},u.normal,{escape:l(u.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:l(u.text)("]|","~]|")("|","|https?://|")()}),u.breaks=h({},u.gfm,{br:l(u.br)("{2,}","*")(),text:l(u.gfm.text)("{2,}","*")()}),t.rules=u,t.output=function(e,n,r){var s=new t(n,r);return s.output(e)},t.prototype.output=function(e){for(var t,n,r,i,l="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),l+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1]),r=this.mangle("mailto:")+n):(n=s(i[1]),r=n),l+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^<a /i.test(i[0])?this.inLink=!0:this.inLink&&/^<\/a>/i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),l+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):s(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,l+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){l+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,l+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),l+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),l+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),l+=this.renderer.codespan(s(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),l+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),l+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),l+=this.renderer.text(s(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=s(i[1]),r=n,l+=this.renderer.link(r,null,n);return l},t.prototype.outputLink=function(e,t){var n=s(t.href),r=t.title?s(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,s(e[1]))},t.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},t.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,s=0;r>s;s++)t=e.charCodeAt(s),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},n.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'<pre><code class="'+this.options.langPrefix+s(t,!0)+'">'+(n?e:s(e,!0))+"\n</code></pre>\n":"<pre><code>"+(n?e:s(e,!0))+"\n</code></pre>"},n.prototype.blockquote=function(e){return"<blockquote>\n"+e+"</blockquote>\n"},n.prototype.html=function(e){return e},n.prototype.heading=function(e,t,n){return"<h"+t+' id="'+this.options.headerPrefix+n.toLowerCase().replace(/[^\w]+/g,"-")+'">'+e+"</h"+t+">\n"},n.prototype.hr=function(){return this.options.xhtml?"<hr/>\n":"<hr>\n"},n.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"</"+n+">\n"},n.prototype.listitem=function(e){return"<li>"+e+"</li>\n"},n.prototype.paragraph=function(e){return"<p>"+e+"</p>\n"},n.prototype.table=function(e,t){return"<table>\n<thead>\n"+e+"</thead>\n<tbody>\n"+t+"</tbody>\n</table>\n"},n.prototype.tablerow=function(e){return"<tr>\n"+e+"</tr>\n"},n.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"</"+n+">\n"},n.prototype.strong=function(e){return"<strong>"+e+"</strong>"},n.prototype.em=function(e){return"<em>"+e+"</em>"},n.prototype.codespan=function(e){return"<code>"+e+"</code>"},n.prototype.br=function(){return this.options.xhtml?"<br/>":"<br>"},n.prototype.del=function(e){return"<del>"+e+"</del>"},n.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(i(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(s){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var l='<a href="'+e+'"';return t&&(l+=' title="'+t+'"'),l+=">"+n+"</a>"},n.prototype.image=function(e,t,n){var r='<img src="'+e+'" alt="'+n+'"';return t&&(r+=' title="'+t+'"'),r+=this.options.xhtml?"/>":">"},n.prototype.text=function(e){return e},r.parse=function(e,t,n){var s=new r(t,n);return s.parse(e)},r.prototype.parse=function(e){this.inline=new t(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var n="";this.next();)n+=this.tok();return n},r.prototype.next=function(){return this.token=this.tokens.pop()},r.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},r.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},r.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,s,i="",l="";for(n="",e=0;e<this.token.header.length;e++)r={header:!0,align:this.token.align[e]},n+=this.renderer.tablecell(this.inline.output(this.token.header[e]),{header:!0,align:this.token.align[e]});for(i+=this.renderer.tablerow(n),e=0;e<this.token.cells.length;e++){for(t=this.token.cells[e],n="",s=0;s<t.length;s++)n+=this.renderer.tablecell(this.inline.output(t[s]),{header:!1,align:this.token.align[s]});l+=this.renderer.tablerow(n)}return this.renderer.table(i,l);case"blockquote_start":for(var l="";"blockquote_end"!==this.next().type;)l+=this.tok();return this.renderer.blockquote(l);case"list_start":for(var l="",o=this.token.ordered;"list_end"!==this.next().type;)l+=this.tok();return this.renderer.list(l,o);case"list_item_start":for(var l="";"list_item_end"!==this.next().type;)l+="text"===this.token.type?this.parseText():this.tok();return this.renderer.listitem(l);case"loose_item_start":for(var l="";"list_item_end"!==this.next().type;)l+=this.tok();return this.renderer.listitem(l);case"html":var h=this.token.pre||this.options.pedantic?this.token.text:this.inline.output(this.token.text);return this.renderer.html(h);case"paragraph":return this.renderer.paragraph(this.inline.output(this.token.text));case"text":return this.renderer.paragraph(this.parseText())}},o.exec=o,a.options=a.setOptions=function(e){return h(a.defaults,e),a},a.defaults={gfm:!0,tables:!0,breaks:!1,pedantic:!1,sanitize:!1,sanitizer:null,mangle:!0,smartLists:!1,silent:!1,highlight:null,langPrefix:"lang-",smartypants:!1,headerPrefix:"",renderer:new n,xhtml:!1},a.Parser=r,a.parser=r.parse,a.Renderer=n,a.Lexer=e,a.lexer=e.lex,a.InlineLexer=t,a.inlineLexer=t.output,a.parse=a,"undefined"!=typeof module&&"object"==typeof exports?module.exports=a:"function"==typeof define&&define.amd?define(function(){return a}):this.marked=a}).call(function(){return this||("undefined"!=typeof window?window:global)}()); |
|
2 |
+//# sourceMappingURL=marked.min.js.map |
@@ -0,0 +1,172 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simple-module', ["jquery"], function (a0) { |
|
5 |
+ return (root['Module'] = factory(a0)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery")); |
|
12 |
+ } else { |
|
13 |
+ root['SimpleModule'] = factory(jQuery); |
|
14 |
+ } |
|
15 |
+}(this, function ($) { |
|
16 |
+ |
|
17 |
+var Module, |
|
18 |
+ slice = [].slice; |
|
19 |
+ |
|
20 |
+Module = (function() { |
|
21 |
+ Module.extend = function(obj) { |
|
22 |
+ var key, ref, val; |
|
23 |
+ if (!((obj != null) && typeof obj === 'object')) { |
|
24 |
+ return; |
|
25 |
+ } |
|
26 |
+ for (key in obj) { |
|
27 |
+ val = obj[key]; |
|
28 |
+ if (key !== 'included' && key !== 'extended') { |
|
29 |
+ this[key] = val; |
|
30 |
+ } |
|
31 |
+ } |
|
32 |
+ return (ref = obj.extended) != null ? ref.call(this) : void 0; |
|
33 |
+ }; |
|
34 |
+ |
|
35 |
+ Module.include = function(obj) { |
|
36 |
+ var key, ref, val; |
|
37 |
+ if (!((obj != null) && typeof obj === 'object')) { |
|
38 |
+ return; |
|
39 |
+ } |
|
40 |
+ for (key in obj) { |
|
41 |
+ val = obj[key]; |
|
42 |
+ if (key !== 'included' && key !== 'extended') { |
|
43 |
+ this.prototype[key] = val; |
|
44 |
+ } |
|
45 |
+ } |
|
46 |
+ return (ref = obj.included) != null ? ref.call(this) : void 0; |
|
47 |
+ }; |
|
48 |
+ |
|
49 |
+ Module.connect = function(cls) { |
|
50 |
+ if (typeof cls !== 'function') { |
|
51 |
+ return; |
|
52 |
+ } |
|
53 |
+ if (!cls.pluginName) { |
|
54 |
+ throw new Error('Module.connect: cannot connect plugin without pluginName'); |
|
55 |
+ return; |
|
56 |
+ } |
|
57 |
+ cls.prototype._connected = true; |
|
58 |
+ if (!this._connectedClasses) { |
|
59 |
+ this._connectedClasses = []; |
|
60 |
+ } |
|
61 |
+ this._connectedClasses.push(cls); |
|
62 |
+ if (cls.pluginName) { |
|
63 |
+ return this[cls.pluginName] = cls; |
|
64 |
+ } |
|
65 |
+ }; |
|
66 |
+ |
|
67 |
+ Module.prototype.opts = {}; |
|
68 |
+ |
|
69 |
+ function Module(opts) { |
|
70 |
+ var base, cls, i, instance, instances, len, name; |
|
71 |
+ this.opts = $.extend({}, this.opts, opts); |
|
72 |
+ (base = this.constructor)._connectedClasses || (base._connectedClasses = []); |
|
73 |
+ instances = (function() { |
|
74 |
+ var i, len, ref, results; |
|
75 |
+ ref = this.constructor._connectedClasses; |
|
76 |
+ results = []; |
|
77 |
+ for (i = 0, len = ref.length; i < len; i++) { |
|
78 |
+ cls = ref[i]; |
|
79 |
+ name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1); |
|
80 |
+ if (cls.prototype._connected) { |
|
81 |
+ cls.prototype._module = this; |
|
82 |
+ } |
|
83 |
+ results.push(this[name] = new cls()); |
|
84 |
+ } |
|
85 |
+ return results; |
|
86 |
+ }).call(this); |
|
87 |
+ if (this._connected) { |
|
88 |
+ this.opts = $.extend({}, this.opts, this._module.opts); |
|
89 |
+ } else { |
|
90 |
+ this._init(); |
|
91 |
+ for (i = 0, len = instances.length; i < len; i++) { |
|
92 |
+ instance = instances[i]; |
|
93 |
+ if (typeof instance._init === "function") { |
|
94 |
+ instance._init(); |
|
95 |
+ } |
|
96 |
+ } |
|
97 |
+ } |
|
98 |
+ this.trigger('initialized'); |
|
99 |
+ } |
|
100 |
+ |
|
101 |
+ Module.prototype._init = function() {}; |
|
102 |
+ |
|
103 |
+ Module.prototype.on = function() { |
|
104 |
+ var args, ref; |
|
105 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
106 |
+ (ref = $(this)).on.apply(ref, args); |
|
107 |
+ return this; |
|
108 |
+ }; |
|
109 |
+ |
|
110 |
+ Module.prototype.one = function() { |
|
111 |
+ var args, ref; |
|
112 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
113 |
+ (ref = $(this)).one.apply(ref, args); |
|
114 |
+ return this; |
|
115 |
+ }; |
|
116 |
+ |
|
117 |
+ Module.prototype.off = function() { |
|
118 |
+ var args, ref; |
|
119 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
120 |
+ (ref = $(this)).off.apply(ref, args); |
|
121 |
+ return this; |
|
122 |
+ }; |
|
123 |
+ |
|
124 |
+ Module.prototype.trigger = function() { |
|
125 |
+ var args, ref; |
|
126 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
127 |
+ (ref = $(this)).trigger.apply(ref, args); |
|
128 |
+ return this; |
|
129 |
+ }; |
|
130 |
+ |
|
131 |
+ Module.prototype.triggerHandler = function() { |
|
132 |
+ var args, ref; |
|
133 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
134 |
+ return (ref = $(this)).triggerHandler.apply(ref, args); |
|
135 |
+ }; |
|
136 |
+ |
|
137 |
+ Module.prototype._t = function() { |
|
138 |
+ var args, ref; |
|
139 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
140 |
+ return (ref = this.constructor)._t.apply(ref, args); |
|
141 |
+ }; |
|
142 |
+ |
|
143 |
+ Module._t = function() { |
|
144 |
+ var args, key, ref, result; |
|
145 |
+ key = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; |
|
146 |
+ result = ((ref = this.i18n[this.locale]) != null ? ref[key] : void 0) || ''; |
|
147 |
+ if (!(args.length > 0)) { |
|
148 |
+ return result; |
|
149 |
+ } |
|
150 |
+ result = result.replace(/([^%]|^)%(?:(\d+)\$)?s/g, function(p0, p, position) { |
|
151 |
+ if (position) { |
|
152 |
+ return p + args[parseInt(position) - 1]; |
|
153 |
+ } else { |
|
154 |
+ return p + args.shift(); |
|
155 |
+ } |
|
156 |
+ }); |
|
157 |
+ return result.replace(/%%s/g, '%s'); |
|
158 |
+ }; |
|
159 |
+ |
|
160 |
+ Module.i18n = { |
|
161 |
+ 'zh-CN': {} |
|
162 |
+ }; |
|
163 |
+ |
|
164 |
+ Module.locale = 'zh-CN'; |
|
165 |
+ |
|
166 |
+ return Module; |
|
167 |
+ |
|
168 |
+})(); |
|
169 |
+ |
|
170 |
+return Module; |
|
171 |
+ |
|
172 |
+})); |
@@ -0,0 +1,3 @@ |
||
1 |
+!function(a,b){"function"==typeof define&&define.amd? |
|
2 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
3 |
+define("simple-module",["jquery"],function(c){return a.Module=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),(c=this.constructor)._connectedClasses||(c._connectedClasses=[]),g=function(){var a,b,c,e;for(c=this.constructor._connectedClasses,e=[],a=0,b=c.length;b>a;a++)d=c[a],i=d.pluginName.charAt(0).toLowerCase()+d.pluginName.slice(1),d.prototype._connected&&(d.prototype._module=this),e.push(this[i]=new d);return e}.call(this),this._connected)this.opts=a.extend({},this.opts,this._module.opts);else for(this._init(),e=0,h=g.length;h>e;e++)f=g[e],"function"==typeof f._init&&f._init();this.trigger("initialized")}return b.extend=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this[b]=d);return null!=(c=a.extended)?c.call(this):void 0}},b.include=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this.prototype[b]=d);return null!=(c=a.included)?c.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):[],e=(null!=(d=this.i18n[this.locale])?d[b]:void 0)||"",a.length>0?(e=e.replace(/([^%]|^)%(?:(\d+)\$)?s/g,function(b,c,d){return d?c+a[parseInt(d)-1]:c+a.shift()}),e.replace(/%%s/g,"%s")):e},b.i18n={"zh-CN":{}},b.locale="zh-CN",b}()}); |
@@ -0,0 +1,170 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simditor-checklist', ["jquery","simditor"], function (a0,b1) { |
|
5 |
+ return (root['ChecklistButton'] = factory(a0,b1)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery"),require("simditor")); |
|
12 |
+ } else { |
|
13 |
+ root['ChecklistButton'] = factory(jQuery,Simditor); |
|
14 |
+ } |
|
15 |
+}(this, function ($, Simditor) { |
|
16 |
+ |
|
17 |
+var ChecklistButton, |
|
18 |
+ extend = 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; }, |
|
19 |
+ hasProp = {}.hasOwnProperty, |
|
20 |
+ slice = [].slice; |
|
21 |
+ |
|
22 |
+ChecklistButton = (function(superClass) { |
|
23 |
+ extend(ChecklistButton, superClass); |
|
24 |
+ |
|
25 |
+ ChecklistButton.prototype.type = 'ul.simditor-checklist'; |
|
26 |
+ |
|
27 |
+ ChecklistButton.prototype.name = 'checklist'; |
|
28 |
+ |
|
29 |
+ ChecklistButton.prototype.icon = 'checklist'; |
|
30 |
+ |
|
31 |
+ ChecklistButton.prototype.htmlTag = 'li'; |
|
32 |
+ |
|
33 |
+ ChecklistButton.prototype.disableTag = 'pre, table'; |
|
34 |
+ |
|
35 |
+ function ChecklistButton() { |
|
36 |
+ var args; |
|
37 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
38 |
+ ChecklistButton.__super__.constructor.apply(this, args); |
|
39 |
+ if ('input' && $.inArray('input', this.editor.formatter._allowedTags) < 0) { |
|
40 |
+ this.editor.formatter._allowedTags.push('input'); |
|
41 |
+ } |
|
42 |
+ $.extend(this.editor.formatter._allowedAttributes, { |
|
43 |
+ input: ['type', 'checked'] |
|
44 |
+ }); |
|
45 |
+ } |
|
46 |
+ |
|
47 |
+ ChecklistButton.prototype._init = function() { |
|
48 |
+ ChecklistButton.__super__._init.call(this); |
|
49 |
+ this.editor.on('decorate', (function(_this) { |
|
50 |
+ return function(e, $el) { |
|
51 |
+ return $el.find('ul > li input[type=checkbox]').each(function(i, checkbox) { |
|
52 |
+ return _this._decorate($(checkbox)); |
|
53 |
+ }); |
|
54 |
+ }; |
|
55 |
+ })(this)); |
|
56 |
+ this.editor.on('undecorate', (function(_this) { |
|
57 |
+ return function(e, $el) { |
|
58 |
+ return $el.find('.simditor-checklist > li').each(function(i, node) { |
|
59 |
+ return _this._undecorate($(node)); |
|
60 |
+ }); |
|
61 |
+ }; |
|
62 |
+ })(this)); |
|
63 |
+ this.editor.body.on('click', '.simditor-checklist > li', (function(_this) { |
|
64 |
+ return function(e) { |
|
65 |
+ var $node, range; |
|
66 |
+ e.preventDefault(); |
|
67 |
+ e.stopPropagation(); |
|
68 |
+ $node = $(e.currentTarget); |
|
69 |
+ range = document.createRange(); |
|
70 |
+ _this.editor.selection.save(); |
|
71 |
+ range.setStart($node[0], 0); |
|
72 |
+ range.setEnd($node[0], _this.editor.util.getNodeLength($node[0])); |
|
73 |
+ _this.editor.selection.range(range); |
|
74 |
+ document.execCommand('strikethrough'); |
|
75 |
+ $node.attr('checked', !$node.attr('checked')); |
|
76 |
+ _this.editor.selection.restore(); |
|
77 |
+ return _this.editor.trigger('valuechanged'); |
|
78 |
+ }; |
|
79 |
+ })(this)); |
|
80 |
+ return this.editor.keystroke.add('13', 'li', (function(_this) { |
|
81 |
+ return function(e, $node) { |
|
82 |
+ return setTimeout(function() { |
|
83 |
+ var $li; |
|
84 |
+ $li = _this.editor.selection.blockNodes().last().next(); |
|
85 |
+ if ($li.length) { |
|
86 |
+ $li[0].removeAttribute('checked'); |
|
87 |
+ if (document.queryCommandState('strikethrough')) { |
|
88 |
+ return document.execCommand('strikethrough'); |
|
89 |
+ } |
|
90 |
+ } |
|
91 |
+ }, 0); |
|
92 |
+ }; |
|
93 |
+ })(this)); |
|
94 |
+ }; |
|
95 |
+ |
|
96 |
+ ChecklistButton.prototype._status = function() { |
|
97 |
+ var $node; |
|
98 |
+ ChecklistButton.__super__._status.call(this); |
|
99 |
+ $node = this.editor.selection.rootNodes(); |
|
100 |
+ if ($node.is('.simditor-checklist')) { |
|
101 |
+ this.editor.toolbar.findButton('ul').setActive(false); |
|
102 |
+ this.editor.toolbar.findButton('ol').setActive(false); |
|
103 |
+ this.editor.toolbar.findButton('ul').setDisabled(true); |
|
104 |
+ return this.editor.toolbar.findButton('ol').setDisabled(true); |
|
105 |
+ } else { |
|
106 |
+ return this.editor.toolbar.findButton('checklist').setActive(false); |
|
107 |
+ } |
|
108 |
+ }; |
|
109 |
+ |
|
110 |
+ ChecklistButton.prototype.command = function(param) { |
|
111 |
+ var $list, $rootNodes; |
|
112 |
+ $rootNodes = this.editor.selection.blockNodes(); |
|
113 |
+ this.editor.selection.save(); |
|
114 |
+ $list = null; |
|
115 |
+ $rootNodes.each((function(_this) { |
|
116 |
+ return function(i, node) { |
|
117 |
+ var $node; |
|
118 |
+ $node = $(node); |
|
119 |
+ if ($node.is('blockquote, li') || $node.is(_this.disableTag) || !$.contains(document, node)) { |
|
120 |
+ return; |
|
121 |
+ } |
|
122 |
+ if ($node.is('.simditor-checklist')) { |
|
123 |
+ $node.children('li').each(function(i, li) { |
|
124 |
+ var $childList, $li; |
|
125 |
+ $li = $(li); |
|
126 |
+ $childList = $li.children('ul, ol').insertAfter($node); |
|
127 |
+ return $('<p/>').append($(li).html() || _this.editor.util.phBr).insertBefore($node); |
|
128 |
+ }); |
|
129 |
+ return $node.remove(); |
|
130 |
+ } else if ($node.is('ul, ol')) { |
|
131 |
+ return $('<ul class="simditor-checklist" />').append($node.contents()).replaceAll($node); |
|
132 |
+ } else if ($list && $node.prev().is($list)) { |
|
133 |
+ $('<li/>').append($node.html() || _this.editor.util.phBr).appendTo($list); |
|
134 |
+ return $node.remove(); |
|
135 |
+ } else { |
|
136 |
+ $list = $('<ul class="simditor-checklist"><li></li></ul>'); |
|
137 |
+ $list.find('li').append($node.html() || _this.editor.util.phBr); |
|
138 |
+ return $list.replaceAll($node); |
|
139 |
+ } |
|
140 |
+ }; |
|
141 |
+ })(this)); |
|
142 |
+ this.editor.selection.restore(); |
|
143 |
+ return this.editor.trigger('valuechanged'); |
|
144 |
+ }; |
|
145 |
+ |
|
146 |
+ ChecklistButton.prototype._decorate = function($checkbox) { |
|
147 |
+ var $node, checked; |
|
148 |
+ checked = !!$checkbox.attr('checked'); |
|
149 |
+ $node = $checkbox.closest('li'); |
|
150 |
+ $checkbox.remove(); |
|
151 |
+ $node.attr('checked', checked); |
|
152 |
+ return $node.closest('ul').addClass('simditor-checklist'); |
|
153 |
+ }; |
|
154 |
+ |
|
155 |
+ ChecklistButton.prototype._undecorate = function($node) { |
|
156 |
+ var $checkbox, checked; |
|
157 |
+ checked = !!$node.attr('checked'); |
|
158 |
+ $checkbox = $('<input type="checkbox">').attr('checked', checked); |
|
159 |
+ return $node.attr('checked', '').prepend($checkbox); |
|
160 |
+ }; |
|
161 |
+ |
|
162 |
+ return ChecklistButton; |
|
163 |
+ |
|
164 |
+})(Simditor.Button); |
|
165 |
+ |
|
166 |
+Simditor.Toolbar.addButton(ChecklistButton); |
|
167 |
+ |
|
168 |
+return ChecklistButton; |
|
169 |
+ |
|
170 |
+})); |
@@ -0,0 +1 @@ |
||
1 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-checklist",["jquery","simditor"],function(a0,b1){return(root["ChecklistButton"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["ChecklistButton"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var ChecklistButton,extend=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},hasProp={}.hasOwnProperty,slice=[].slice;ChecklistButton=(function(superClass){extend(ChecklistButton,superClass);ChecklistButton.prototype.type="ul.simditor-checklist";ChecklistButton.prototype.name="checklist";ChecklistButton.prototype.icon="checklist";ChecklistButton.prototype.htmlTag="li";ChecklistButton.prototype.disableTag="pre, table";function ChecklistButton(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ChecklistButton.__super__.constructor.apply(this,args);if("input"&&$.inArray("input",this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push("input")}$.extend(this.editor.formatter._allowedAttributes,{input:["type","checked"]})}ChecklistButton.prototype._init=function(){ChecklistButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("ul > li input[type=checkbox]").each(function(i,checkbox){return _this._decorate($(checkbox))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find(".simditor-checklist > li").each(function(i,node){return _this._undecorate($(node))})}})(this));this.editor.body.on("click",".simditor-checklist > li",(function(_this){return function(e){var $node,range;e.preventDefault();e.stopPropagation();$node=$(e.currentTarget);range=document.createRange();_this.editor.selection.save();range.setStart($node[0],0);range.setEnd($node[0],_this.editor.util.getNodeLength($node[0]));_this.editor.selection.range(range);document.execCommand("strikethrough");$node.attr("checked",!$node.attr("checked"));_this.editor.selection.restore();return _this.editor.trigger("valuechanged")}})(this));return this.editor.keystroke.add("13","li",(function(_this){return function(e,$node){return setTimeout(function(){var $li;$li=_this.editor.selection.blockNodes().last().next();if($li.length){$li[0].removeAttribute("checked");if(document.queryCommandState("strikethrough")){return document.execCommand("strikethrough")}}},0)}})(this))};ChecklistButton.prototype._status=function(){var $node;ChecklistButton.__super__._status.call(this);$node=this.editor.selection.rootNodes();if($node.is(".simditor-checklist")){this.editor.toolbar.findButton("ul").setActive(false);this.editor.toolbar.findButton("ol").setActive(false);this.editor.toolbar.findButton("ul").setDisabled(true);return this.editor.toolbar.findButton("ol").setDisabled(true)}else{return this.editor.toolbar.findButton("checklist").setActive(false)}};ChecklistButton.prototype.command=function(param){var $list,$rootNodes;$rootNodes=this.editor.selection.blockNodes();this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||!$.contains(document,node)){return}if($node.is(".simditor-checklist")){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is("ul, ol")){return $('<ul class="simditor-checklist" />').append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$('<ul class="simditor-checklist"><li></li></ul>');$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};ChecklistButton.prototype._decorate=function($checkbox){var $node,checked;checked=!!$checkbox.attr("checked");$node=$checkbox.closest("li");$checkbox.remove();$node.attr("checked",checked);return $node.closest("ul").addClass("simditor-checklist")};ChecklistButton.prototype._undecorate=function($node){var $checkbox,checked;checked=!!$node.attr("checked");$checkbox=$('<input type="checkbox">').attr("checked",checked);return $node.attr("checked","").prepend($checkbox)};return ChecklistButton})(Simditor.Button);Simditor.Toolbar.addButton(ChecklistButton);return ChecklistButton})); |
@@ -0,0 +1,122 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module. |
|
4 |
+ define(["jquery", |
|
5 |
+ "simple-module", |
|
6 |
+ "simditor"], function ($, SimpleModule, Simditor) { |
|
7 |
+ return (root.returnExportsGlobal = factory($, SimpleModule, Simditor)); |
|
8 |
+ }); |
|
9 |
+ } else if (typeof exports === 'object') { |
|
10 |
+ // Node. Does not work with strict CommonJS, but |
|
11 |
+ // only CommonJS-like enviroments that support module.exports, |
|
12 |
+ // like Node. |
|
13 |
+ module.exports = factory(require("jquery"), |
|
14 |
+ require("simple-module"), |
|
15 |
+ require("simditor")); |
|
16 |
+ } else { |
|
17 |
+ root['Simditor'] = factory(jQuery, |
|
18 |
+ SimpleModule, |
|
19 |
+ Simditor); |
|
20 |
+ } |
|
21 |
+}(this, function ($, SimpleModule, Simditor) { |
|
22 |
+ |
|
23 |
+var Dropzone, |
|
24 |
+ __hasProp = {}.hasOwnProperty, |
|
25 |
+ __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; }; |
|
26 |
+ |
|
27 |
+Dropzone = (function(_super) { |
|
28 |
+ __extends(Dropzone, _super); |
|
29 |
+ |
|
30 |
+ function Dropzone() { |
|
31 |
+ return Dropzone.__super__.constructor.apply(this, arguments); |
|
32 |
+ } |
|
33 |
+ |
|
34 |
+ Dropzone.pluginName = "Dropzone"; |
|
35 |
+ |
|
36 |
+ Dropzone.prototype._entered = 0; |
|
37 |
+ |
|
38 |
+ Dropzone.prototype._init = function() { |
|
39 |
+ this.editor = this._module; |
|
40 |
+ if (this.editor.uploader == null) { |
|
41 |
+ throw new Error("Can't work without 'simple-uploader' module"); |
|
42 |
+ return; |
|
43 |
+ } |
|
44 |
+ $(document.body).on("dragover", function(e) { |
|
45 |
+ e.originalEvent.dataTransfer.dropEffect = "none"; |
|
46 |
+ return e.preventDefault(); |
|
47 |
+ }); |
|
48 |
+ $(document.body).on('drop', function(e) { |
|
49 |
+ return e.preventDefault(); |
|
50 |
+ }); |
|
51 |
+ this.imageBtn = this.editor.toolbar.findButton("image"); |
|
52 |
+ return this.editor.body.on("dragover", function(e) { |
|
53 |
+ e.originalEvent.dataTransfer.dropEffect = "copy"; |
|
54 |
+ e.stopPropagation(); |
|
55 |
+ return e.preventDefault(); |
|
56 |
+ }).on("dragenter", (function(_this) { |
|
57 |
+ return function(e) { |
|
58 |
+ if ((_this._entered += 1) === 1) { |
|
59 |
+ _this.show(); |
|
60 |
+ } |
|
61 |
+ e.preventDefault(); |
|
62 |
+ return e.stopPropagation(); |
|
63 |
+ }; |
|
64 |
+ })(this)).on("dragleave", (function(_this) { |
|
65 |
+ return function(e) { |
|
66 |
+ if ((_this._entered -= 1) <= 0) { |
|
67 |
+ _this.hide(); |
|
68 |
+ } |
|
69 |
+ e.preventDefault(); |
|
70 |
+ return e.stopPropagation(); |
|
71 |
+ }; |
|
72 |
+ })(this)).on("drop", (function(_this) { |
|
73 |
+ return function(e) { |
|
74 |
+ var file, imageFiles, _i, _j, _len, _len1, _ref; |
|
75 |
+ imageFiles = []; |
|
76 |
+ _ref = e.originalEvent.dataTransfer.files; |
|
77 |
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) { |
|
78 |
+ file = _ref[_i]; |
|
79 |
+ if (!_this.validFile(file)) { |
|
80 |
+ alert("「" + file.name + "]」文件不是图片。"); |
|
81 |
+ _this.hide(); |
|
82 |
+ return false; |
|
83 |
+ } |
|
84 |
+ imageFiles.push(file); |
|
85 |
+ } |
|
86 |
+ for (_j = 0, _len1 = imageFiles.length; _j < _len1; _j++) { |
|
87 |
+ file = imageFiles[_j]; |
|
88 |
+ _this.editor.uploader.upload(file, { |
|
89 |
+ inline: true |
|
90 |
+ }); |
|
91 |
+ } |
|
92 |
+ _this.hide(); |
|
93 |
+ e.stopPropagation(); |
|
94 |
+ return e.preventDefault(); |
|
95 |
+ }; |
|
96 |
+ })(this)); |
|
97 |
+ }; |
|
98 |
+ |
|
99 |
+ Dropzone.prototype.show = function() { |
|
100 |
+ return this.imageBtn.setActive(true); |
|
101 |
+ }; |
|
102 |
+ |
|
103 |
+ Dropzone.prototype.hide = function() { |
|
104 |
+ this.imageBtn.setActive(false); |
|
105 |
+ return this._entered = 0; |
|
106 |
+ }; |
|
107 |
+ |
|
108 |
+ Dropzone.prototype.validFile = function(file) { |
|
109 |
+ return file.type.indexOf("image/") > -1; |
|
110 |
+ }; |
|
111 |
+ |
|
112 |
+ return Dropzone; |
|
113 |
+ |
|
114 |
+})(SimpleModule); |
|
115 |
+ |
|
116 |
+Simditor.connect(Dropzone); |
|
117 |
+ |
|
118 |
+ |
|
119 |
+return Simditor; |
|
120 |
+ |
|
121 |
+ |
|
122 |
+})); |
@@ -0,0 +1 @@ |
||
1 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define(["jquery","simple-module","simditor"],function($,SimpleModule,Simditor){return(root.returnExportsGlobal=factory($,SimpleModule,Simditor))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simple-module"),require("simditor"))}else{root["Simditor"]=factory(jQuery,SimpleModule,Simditor)}}}(this,function($,SimpleModule,Simditor){var Dropzone,__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};Dropzone=(function(_super){__extends(Dropzone,_super);function Dropzone(){return Dropzone.__super__.constructor.apply(this,arguments)}Dropzone.pluginName="Dropzone";Dropzone.prototype._entered=0;Dropzone.prototype._init=function(){this.editor=this._module;if(this.editor.uploader==null){throw new Error("Can't work without 'simple-uploader' module");return}$(document.body).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="none";return e.preventDefault()});$(document.body).on("drop",function(e){return e.preventDefault()});this.imageBtn=this.editor.toolbar.findButton("image");return this.editor.body.on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy";e.stopPropagation();return e.preventDefault()}).on("dragenter",(function(_this){return function(e){if((_this._entered+=1)===1){_this.show()}e.preventDefault();return e.stopPropagation()}})(this)).on("dragleave",(function(_this){return function(e){if((_this._entered-=1)<=0){_this.hide()}e.preventDefault();return e.stopPropagation()}})(this)).on("drop",(function(_this){return function(e){var file,imageFiles,_i,_j,_len,_len1,_ref;imageFiles=[];_ref=e.originalEvent.dataTransfer.files;for(_i=0,_len=_ref.length;_i<_len;_i++){file=_ref[_i];if(!_this.validFile(file)){alert("「"+file.name+"]」文件不是图片。");_this.hide();return false}imageFiles.push(file)}for(_j=0,_len1=imageFiles.length;_j<_len1;_j++){file=imageFiles[_j];_this.editor.uploader.upload(file,{inline:true})}_this.hide();e.stopPropagation();return e.preventDefault()}})(this))};Dropzone.prototype.show=function(){return this.imageBtn.setActive(true)};Dropzone.prototype.hide=function(){this.imageBtn.setActive(false);return this._entered=0};Dropzone.prototype.validFile=function(file){return file.type.indexOf("image/")>-1};return Dropzone})(SimpleModule);Simditor.connect(Dropzone);return Simditor})); |
@@ -0,0 +1,90 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simditor-fullscreen', ["jquery","simditor"], function (a0,b1) { |
|
5 |
+ return (root['SimditorFullscreen'] = factory(a0,b1)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery"),require("simditor")); |
|
12 |
+ } else { |
|
13 |
+ root['SimditorFullscreen'] = factory(jQuery,Simditor); |
|
14 |
+ } |
|
15 |
+}(this, function ($, Simditor) { |
|
16 |
+ |
|
17 |
+var SimditorFullscreen, |
|
18 |
+ extend = 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; }, |
|
19 |
+ hasProp = {}.hasOwnProperty; |
|
20 |
+ |
|
21 |
+SimditorFullscreen = (function(superClass) { |
|
22 |
+ extend(SimditorFullscreen, superClass); |
|
23 |
+ |
|
24 |
+ function SimditorFullscreen() { |
|
25 |
+ return SimditorFullscreen.__super__.constructor.apply(this, arguments); |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ SimditorFullscreen.cls = 'simditor-fullscreen'; |
|
29 |
+ |
|
30 |
+ SimditorFullscreen.i18n = { |
|
31 |
+ 'zh-CN': { |
|
32 |
+ fullscreen: '全屏' |
|
33 |
+ } |
|
34 |
+ }; |
|
35 |
+ |
|
36 |
+ SimditorFullscreen.prototype.name = 'fullscreen'; |
|
37 |
+ |
|
38 |
+ SimditorFullscreen.prototype.needFocus = false; |
|
39 |
+ |
|
40 |
+ SimditorFullscreen.prototype.iconClassOf = function() { |
|
41 |
+ return 'icon-fullscreen'; |
|
42 |
+ }; |
|
43 |
+ |
|
44 |
+ SimditorFullscreen.prototype._init = function() { |
|
45 |
+ SimditorFullscreen.__super__._init.call(this); |
|
46 |
+ this.window = $(window); |
|
47 |
+ this.body = $('body'); |
|
48 |
+ this.editable = this.editor.body; |
|
49 |
+ return this.toolbar = this.editor.toolbar.wrapper; |
|
50 |
+ }; |
|
51 |
+ |
|
52 |
+ SimditorFullscreen.prototype.status = function() { |
|
53 |
+ return this.setActive(this.body.hasClass(this.constructor.cls)); |
|
54 |
+ }; |
|
55 |
+ |
|
56 |
+ SimditorFullscreen.prototype.command = function() { |
|
57 |
+ var editablePadding, isFullscreen; |
|
58 |
+ this.body.toggleClass(this.constructor.cls); |
|
59 |
+ isFullscreen = this.body.hasClass(this.constructor.cls); |
|
60 |
+ if (isFullscreen) { |
|
61 |
+ editablePadding = this.editable.outerHeight() - this.editable.height(); |
|
62 |
+ this.window.on("resize.simditor-fullscreen-" + this.editor.id, (function(_this) { |
|
63 |
+ return function() { |
|
64 |
+ return _this._resize({ |
|
65 |
+ height: _this.window.height() - _this.toolbar.outerHeight() - editablePadding |
|
66 |
+ }); |
|
67 |
+ }; |
|
68 |
+ })(this)).resize(); |
|
69 |
+ } else { |
|
70 |
+ this.window.off("resize.simditor-fullscreen-" + this.editor.id).resize(); |
|
71 |
+ this._resize({ |
|
72 |
+ height: 'auto' |
|
73 |
+ }); |
|
74 |
+ } |
|
75 |
+ return this.setActive(isFullscreen); |
|
76 |
+ }; |
|
77 |
+ |
|
78 |
+ SimditorFullscreen.prototype._resize = function(size) { |
|
79 |
+ return this.editable.height(size.height); |
|
80 |
+ }; |
|
81 |
+ |
|
82 |
+ return SimditorFullscreen; |
|
83 |
+ |
|
84 |
+})(Simditor.Button); |
|
85 |
+ |
|
86 |
+Simditor.Toolbar.addButton(SimditorFullscreen); |
|
87 |
+ |
|
88 |
+return SimditorFullscreen; |
|
89 |
+ |
|
90 |
+})); |
@@ -0,0 +1 @@ |
||
1 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-fullscreen",["jquery","simditor"],function(a0,b1){return(root["SimditorFullscreen"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["SimditorFullscreen"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var SimditorFullscreen,extend=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},hasProp={}.hasOwnProperty;SimditorFullscreen=(function(superClass){extend(SimditorFullscreen,superClass);function SimditorFullscreen(){return SimditorFullscreen.__super__.constructor.apply(this,arguments)}SimditorFullscreen.cls="simditor-fullscreen";SimditorFullscreen.i18n={"zh-CN":{fullscreen:"全屏"}};SimditorFullscreen.prototype.name="fullscreen";SimditorFullscreen.prototype.needFocus=false;SimditorFullscreen.prototype.iconClassOf=function(){return"icon-fullscreen"};SimditorFullscreen.prototype._init=function(){SimditorFullscreen.__super__._init.call(this);this.window=$(window);this.body=$("body");this.editable=this.editor.body;return this.toolbar=this.editor.toolbar.wrapper};SimditorFullscreen.prototype.status=function(){return this.setActive(this.body.hasClass(this.constructor.cls))};SimditorFullscreen.prototype.command=function(){var editablePadding,isFullscreen;this.body.toggleClass(this.constructor.cls);isFullscreen=this.body.hasClass(this.constructor.cls);if(isFullscreen){editablePadding=this.editable.outerHeight()-this.editable.height();this.window.on("resize.simditor-fullscreen-"+this.editor.id,(function(_this){return function(){return _this._resize({height:_this.window.height()-_this.toolbar.outerHeight()-editablePadding})}})(this)).resize()}else{this.window.off("resize.simditor-fullscreen-"+this.editor.id).resize();this._resize({height:"auto"})}return this.setActive(isFullscreen)};SimditorFullscreen.prototype._resize=function(size){return this.editable.height(size.height)};return SimditorFullscreen})(Simditor.Button);Simditor.Toolbar.addButton(SimditorFullscreen);return SimditorFullscreen})); |
@@ -0,0 +1,146 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simditor-markdown', ["jquery","simditor","to-markdown","marked"], function (a0,b1,c2,d3) { |
|
5 |
+ return (root['SimditorMarkdown'] = factory(a0,b1,c2,d3)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery"),require("simditor"),require("to-markdown"),require("marked")); |
|
12 |
+ } else { |
|
13 |
+ root['SimditorMarkdown'] = factory(jQuery,Simditor,toMarkdown,marked); |
|
14 |
+ } |
|
15 |
+}(this, function ($, Simditor, toMarkdown, marked) { |
|
16 |
+ |
|
17 |
+var SimditorMarkdown, |
|
18 |
+ extend = 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; }, |
|
19 |
+ hasProp = {}.hasOwnProperty; |
|
20 |
+ |
|
21 |
+SimditorMarkdown = (function(superClass) { |
|
22 |
+ extend(SimditorMarkdown, superClass); |
|
23 |
+ |
|
24 |
+ function SimditorMarkdown() { |
|
25 |
+ return SimditorMarkdown.__super__.constructor.apply(this, arguments); |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ SimditorMarkdown.prototype.name = 'markdown'; |
|
29 |
+ |
|
30 |
+ SimditorMarkdown.prototype.icon = 'markdown'; |
|
31 |
+ |
|
32 |
+ SimditorMarkdown.prototype.needFocus = false; |
|
33 |
+ |
|
34 |
+ SimditorMarkdown.prototype._init = function() { |
|
35 |
+ SimditorMarkdown.__super__._init.call(this); |
|
36 |
+ this.markdownEl = $('<div class="markdown-editor" />').insertBefore(this.editor.body); |
|
37 |
+ this.textarea = $('<textarea/>').attr('placeholder', this.editor.opts.placeholder).appendTo(this.markdownEl); |
|
38 |
+ this.textarea.on('focus', (function(_this) { |
|
39 |
+ return function(e) { |
|
40 |
+ return _this.editor.el.addClass('focus'); |
|
41 |
+ }; |
|
42 |
+ })(this)).on('blur', (function(_this) { |
|
43 |
+ return function(e) { |
|
44 |
+ return _this.editor.el.removeClass('focus'); |
|
45 |
+ }; |
|
46 |
+ })(this)); |
|
47 |
+ this.editor.on('valuechanged', (function(_this) { |
|
48 |
+ return function(e) { |
|
49 |
+ if (!_this.editor.markdownMode) { |
|
50 |
+ return; |
|
51 |
+ } |
|
52 |
+ return _this._initMarkdownValue(); |
|
53 |
+ }; |
|
54 |
+ })(this)); |
|
55 |
+ this.markdownChange = this.editor.util.throttle((function(_this) { |
|
56 |
+ return function() { |
|
57 |
+ _this._autosizeTextarea(); |
|
58 |
+ return _this._convert(); |
|
59 |
+ }; |
|
60 |
+ })(this), 200); |
|
61 |
+ if (this.editor.util.support.oninput) { |
|
62 |
+ this.textarea.on('input', (function(_this) { |
|
63 |
+ return function(e) { |
|
64 |
+ return _this.markdownChange(); |
|
65 |
+ }; |
|
66 |
+ })(this)); |
|
67 |
+ } else { |
|
68 |
+ this.textarea.on('keyup', (function(_this) { |
|
69 |
+ return function(e) { |
|
70 |
+ return _this.markdownChange(); |
|
71 |
+ }; |
|
72 |
+ })(this)); |
|
73 |
+ } |
|
74 |
+ if (this.editor.opts.markdown) { |
|
75 |
+ return this.editor.on('initialized', (function(_this) { |
|
76 |
+ return function() { |
|
77 |
+ return _this.el.mousedown(); |
|
78 |
+ }; |
|
79 |
+ })(this)); |
|
80 |
+ } |
|
81 |
+ }; |
|
82 |
+ |
|
83 |
+ SimditorMarkdown.prototype.status = function() {}; |
|
84 |
+ |
|
85 |
+ SimditorMarkdown.prototype.command = function() { |
|
86 |
+ var button, i, len, ref; |
|
87 |
+ this.editor.blur(); |
|
88 |
+ this.editor.el.toggleClass('simditor-markdown'); |
|
89 |
+ this.editor.markdownMode = this.editor.el.hasClass('simditor-markdown'); |
|
90 |
+ if (this.editor.markdownMode) { |
|
91 |
+ this.editor.inputManager.lastCaretPosition = null; |
|
92 |
+ this.editor.hidePopover(); |
|
93 |
+ this.editor.body.removeAttr('contenteditable'); |
|
94 |
+ this._initMarkdownValue(); |
|
95 |
+ } else { |
|
96 |
+ this.textarea.val(''); |
|
97 |
+ this.editor.body.attr('contenteditable', 'true'); |
|
98 |
+ } |
|
99 |
+ ref = this.editor.toolbar.buttons; |
|
100 |
+ for (i = 0, len = ref.length; i < len; i++) { |
|
101 |
+ button = ref[i]; |
|
102 |
+ if (button.name === 'markdown') { |
|
103 |
+ button.setActive(this.editor.markdownMode); |
|
104 |
+ } else { |
|
105 |
+ button.setDisabled(this.editor.markdownMode); |
|
106 |
+ } |
|
107 |
+ } |
|
108 |
+ return null; |
|
109 |
+ }; |
|
110 |
+ |
|
111 |
+ SimditorMarkdown.prototype._initMarkdownValue = function() { |
|
112 |
+ this._fileterUnsupportedTags(); |
|
113 |
+ this.textarea.val(toMarkdown(this.editor.getValue(), { |
|
114 |
+ gfm: true |
|
115 |
+ })); |
|
116 |
+ return this._autosizeTextarea(); |
|
117 |
+ }; |
|
118 |
+ |
|
119 |
+ SimditorMarkdown.prototype._autosizeTextarea = function() { |
|
120 |
+ this._textareaPadding || (this._textareaPadding = this.textarea.innerHeight() - this.textarea.height()); |
|
121 |
+ return this.textarea.height(this.textarea[0].scrollHeight - this._textareaPadding); |
|
122 |
+ }; |
|
123 |
+ |
|
124 |
+ SimditorMarkdown.prototype._convert = function() { |
|
125 |
+ var markdownText, text; |
|
126 |
+ text = this.textarea.val(); |
|
127 |
+ markdownText = marked(text); |
|
128 |
+ this.editor.textarea.val(markdownText); |
|
129 |
+ this.editor.body.html(markdownText); |
|
130 |
+ this.editor.formatter.format(); |
|
131 |
+ return this.editor.formatter.decorate(); |
|
132 |
+ }; |
|
133 |
+ |
|
134 |
+ SimditorMarkdown.prototype._fileterUnsupportedTags = function() { |
|
135 |
+ return this.editor.body.find('colgroup').remove(); |
|
136 |
+ }; |
|
137 |
+ |
|
138 |
+ return SimditorMarkdown; |
|
139 |
+ |
|
140 |
+})(Simditor.Button); |
|
141 |
+ |
|
142 |
+Simditor.Toolbar.addButton(SimditorMarkdown); |
|
143 |
+ |
|
144 |
+return SimditorMarkdown; |
|
145 |
+ |
|
146 |
+})); |
@@ -0,0 +1 @@ |
||
1 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-markdown",["jquery","simditor","to-markdown","marked"],function(a0,b1,c2,d3){return(root["SimditorMarkdown"]=factory(a0,b1,c2,d3))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"),require("to-markdown"),require("marked"))}else{root["SimditorMarkdown"]=factory(jQuery,Simditor,toMarkdown,marked)}}}(this,function($,Simditor,toMarkdown,marked){var SimditorMarkdown,extend=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},hasProp={}.hasOwnProperty;SimditorMarkdown=(function(superClass){extend(SimditorMarkdown,superClass);function SimditorMarkdown(){return SimditorMarkdown.__super__.constructor.apply(this,arguments)}SimditorMarkdown.prototype.name="markdown";SimditorMarkdown.prototype.icon="markdown";SimditorMarkdown.prototype.needFocus=false;SimditorMarkdown.prototype._init=function(){SimditorMarkdown.__super__._init.call(this);this.markdownEl=$('<div class="markdown-editor" />').insertBefore(this.editor.body);this.textarea=$("<textarea/>").attr("placeholder",this.editor.opts.placeholder).appendTo(this.markdownEl);this.textarea.on("focus",(function(_this){return function(e){return _this.editor.el.addClass("focus")}})(this)).on("blur",(function(_this){return function(e){return _this.editor.el.removeClass("focus")}})(this));this.editor.on("valuechanged",(function(_this){return function(e){if(!_this.editor.markdownMode){return}return _this._initMarkdownValue()}})(this));this.markdownChange=this.editor.util.throttle((function(_this){return function(){_this._autosizeTextarea();return _this._convert()}})(this),200);if(this.editor.util.support.oninput){this.textarea.on("input",(function(_this){return function(e){return _this.markdownChange()}})(this))}else{this.textarea.on("keyup",(function(_this){return function(e){return _this.markdownChange()}})(this))}if(this.editor.opts.markdown){return this.editor.on("initialized",(function(_this){return function(){return _this.el.mousedown()}})(this))}};SimditorMarkdown.prototype.status=function(){};SimditorMarkdown.prototype.command=function(){var button,i,len,ref;this.editor.blur();this.editor.el.toggleClass("simditor-markdown");this.editor.markdownMode=this.editor.el.hasClass("simditor-markdown");if(this.editor.markdownMode){this.editor.inputManager.lastCaretPosition=null;this.editor.hidePopover();this.editor.body.removeAttr("contenteditable");this._initMarkdownValue()}else{this.textarea.val("");this.editor.body.attr("contenteditable","true")}ref=this.editor.toolbar.buttons;for(i=0,len=ref.length;i<len;i++){button=ref[i];if(button.name==="markdown"){button.setActive(this.editor.markdownMode)}else{button.setDisabled(this.editor.markdownMode)}}return null};SimditorMarkdown.prototype._initMarkdownValue=function(){this._fileterUnsupportedTags();this.textarea.val(toMarkdown(this.editor.getValue(),{gfm:true}));return this._autosizeTextarea()};SimditorMarkdown.prototype._autosizeTextarea=function(){this._textareaPadding||(this._textareaPadding=this.textarea.innerHeight()-this.textarea.height());return this.textarea.height(this.textarea[0].scrollHeight-this._textareaPadding)};SimditorMarkdown.prototype._convert=function(){var markdownText,text;text=this.textarea.val();markdownText=marked(text);this.editor.textarea.val(markdownText);this.editor.body.html(markdownText);this.editor.formatter.format();return this.editor.formatter.decorate()};SimditorMarkdown.prototype._fileterUnsupportedTags=function(){return this.editor.body.find("colgroup").remove()};return SimditorMarkdown})(Simditor.Button);Simditor.Toolbar.addButton(SimditorMarkdown);return SimditorMarkdown})); |
@@ -0,0 +1,3 @@ |
||
1 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define(["jquery","simple-module","simditor"],function($,SimpleModule,Simditor){return(root.returnExportsGlobal=factory($,SimpleModule,Simditor))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simple-module"),require("simditor"))}else{root["Simditor"]=factory(jQuery,SimpleModule,Simditor)}}}(this,function($,SimpleModule,Simditor){var Dropzone,__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};Dropzone=(function(_super){__extends(Dropzone,_super);function Dropzone(){return Dropzone.__super__.constructor.apply(this,arguments)}Dropzone.pluginName="Dropzone";Dropzone.prototype._entered=0;Dropzone.prototype._init=function(){this.editor=this._module;if(this.editor.uploader==null){throw new Error("Can't work without 'simple-uploader' module");return}$(document.body).on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="none";return e.preventDefault()});$(document.body).on("drop",function(e){return e.preventDefault()});this.imageBtn=this.editor.toolbar.findButton("image");return this.editor.body.on("dragover",function(e){e.originalEvent.dataTransfer.dropEffect="copy";e.stopPropagation();return e.preventDefault()}).on("dragenter",(function(_this){return function(e){if((_this._entered+=1)===1){_this.show()}e.preventDefault();return e.stopPropagation()}})(this)).on("dragleave",(function(_this){return function(e){if((_this._entered-=1)<=0){_this.hide()}e.preventDefault();return e.stopPropagation()}})(this)).on("drop",(function(_this){return function(e){var file,imageFiles,_i,_j,_len,_len1,_ref;imageFiles=[];_ref=e.originalEvent.dataTransfer.files;for(_i=0,_len=_ref.length;_i<_len;_i++){file=_ref[_i];if(!_this.validFile(file)){alert("「"+file.name+"]」文件不是图片。");_this.hide();return false}imageFiles.push(file)}for(_j=0,_len1=imageFiles.length;_j<_len1;_j++){file=imageFiles[_j];_this.editor.uploader.upload(file,{inline:true})}_this.hide();e.stopPropagation();return e.preventDefault()}})(this))};Dropzone.prototype.show=function(){return this.imageBtn.setActive(true)};Dropzone.prototype.hide=function(){this.imageBtn.setActive(false);return this._entered=0};Dropzone.prototype.validFile=function(file){return file.type.indexOf("image/")>-1};return Dropzone})(SimpleModule);Simditor.connect(Dropzone);return Simditor}));(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-fullscreen",["jquery","simditor"],function(a0,b1){return(root["SimditorFullscreen"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["SimditorFullscreen"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var SimditorFullscreen,extend=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},hasProp={}.hasOwnProperty;SimditorFullscreen=(function(superClass){extend(SimditorFullscreen,superClass);function SimditorFullscreen(){return SimditorFullscreen.__super__.constructor.apply(this,arguments)}SimditorFullscreen.cls="simditor-fullscreen";SimditorFullscreen.i18n={"zh-CN":{fullscreen:"全屏"}};SimditorFullscreen.prototype.name="fullscreen";SimditorFullscreen.prototype.needFocus=false;SimditorFullscreen.prototype.iconClassOf=function(){return"icon-fullscreen"};SimditorFullscreen.prototype._init=function(){SimditorFullscreen.__super__._init.call(this);this.window=$(window);this.body=$("body");this.editable=this.editor.body;return this.toolbar=this.editor.toolbar.wrapper};SimditorFullscreen.prototype.status=function(){return this.setActive(this.body.hasClass(this.constructor.cls))};SimditorFullscreen.prototype.command=function(){var editablePadding,isFullscreen;this.body.toggleClass(this.constructor.cls);isFullscreen=this.body.hasClass(this.constructor.cls);if(isFullscreen){editablePadding=this.editable.outerHeight()-this.editable.height();this.window.on("resize.simditor-fullscreen-"+this.editor.id,(function(_this){return function(){return _this._resize({height:_this.window.height()-_this.toolbar.outerHeight()-editablePadding})}})(this)).resize()}else{this.window.off("resize.simditor-fullscreen-"+this.editor.id).resize();this._resize({height:"auto"})}return this.setActive(isFullscreen)};SimditorFullscreen.prototype._resize=function(size){return this.editable.height(size.height)};return SimditorFullscreen})(Simditor.Button);Simditor.Toolbar.addButton(SimditorFullscreen);return SimditorFullscreen}));(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else{if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else{if(typeof global!=="undefined"){g=global}else{if(typeof self!=="undefined"){g=self}else{g=this}}}g.toMarkdown=f()}}})(function(){var define,module,exports;return(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){return a(o,!0)}if(i){return i(o,!0)}var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++){s(r[o])}return s})({1:[function(require,module,exports){var toMarkdown;var converters;var mdConverters=require("./lib/md-converters");var gfmConverters=require("./lib/gfm-converters");var HtmlParser=require("./lib/html-parser");var collapse=require("collapse-whitespace");var blocks=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function isBlock(node){return blocks.indexOf(node.nodeName.toLowerCase())!==-1}var voids=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function isVoid(node){return voids.indexOf(node.nodeName.toLowerCase())!==-1}function htmlToDom(string){var tree=new HtmlParser().parseFromString(string,"text/html");collapse(tree.documentElement,isBlock);return tree}function bfsOrder(node){var inqueue=[node];var outqueue=[];var elem;var children;var i;while(inqueue.length>0){elem=inqueue.shift();outqueue.push(elem);children=elem.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){inqueue.push(children[i])}}}outqueue.shift();return outqueue}function getContent(node){var text="";for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType===1){text+=node.childNodes[i]._replacement}else{if(node.childNodes[i].nodeType===3){text+=node.childNodes[i].data}else{continue}}}return text}function outer(node,content){return node.cloneNode(false).outerHTML.replace("><",">"+content+"<")}function canConvert(node,filter){if(typeof filter==="string"){return filter===node.nodeName.toLowerCase()}if(Array.isArray(filter)){return filter.indexOf(node.nodeName.toLowerCase())!==-1}else{if(typeof filter==="function"){return filter.call(toMarkdown,node)}else{throw new TypeError("`filter` needs to be a string, array, or function")}}}function isFlankedByWhitespace(side,node){var sibling;var regExp;var isFlanked;if(side==="left"){sibling=node.previousSibling;regExp=/ $/}else{sibling=node.nextSibling;regExp=/^ /}if(sibling){if(sibling.nodeType===3){isFlanked=regExp.test(sibling.nodeValue)}else{if(sibling.nodeType===1&&!isBlock(sibling)){isFlanked=regExp.test(sibling.textContent)}}}return isFlanked}function flankingWhitespace(node,content){var leading="";var trailing="";if(!isBlock(node)){var hasLeading=/^[ \r\n\t]/.test(content);var hasTrailing=/[ \r\n\t]$/.test(content);if(hasLeading&&!isFlankedByWhitespace("left",node)){leading=" "}if(hasTrailing&&!isFlankedByWhitespace("right",node)){trailing=" "}}return{leading:leading,trailing:trailing}}function process(node){var replacement;var content=getContent(node);if(!isVoid(node)&&!/A|TH|TD/.test(node.nodeName)&&/^\s*$/i.test(content)){node._replacement="";return}for(var i=0;i<converters.length;i++){var converter=converters[i];if(canConvert(node,converter.filter)){if(typeof converter.replacement!=="function"){throw new TypeError("`replacement` needs to be a function that returns a string")}var whitespace=flankingWhitespace(node,content);if(whitespace.leading||whitespace.trailing){content=content.trim()}replacement=whitespace.leading+converter.replacement.call(toMarkdown,content,node)+whitespace.trailing;break}}node._replacement=replacement}toMarkdown=function(input,options){options=options||{};if(typeof input!=="string"){throw new TypeError(input+" is not a string")}if(input===""){return""}input=input.replace(/(\d+)\. /g,"$1\\. ");var clone=htmlToDom(input).body;var nodes=bfsOrder(clone);var output;converters=mdConverters.slice(0);if(options.gfm){converters=gfmConverters.concat(converters)}if(options.converters){converters=options.converters.concat(converters)}for(var i=nodes.length-1;i>=0;i--){process(nodes[i])}output=getContent(clone);return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")};toMarkdown.isBlock=isBlock;toMarkdown.isVoid=isVoid;toMarkdown.outer=outer;module.exports=toMarkdown},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){function cell(content,node){var index=Array.prototype.indexOf.call(node.parentNode.childNodes,node); |
|
2 |
+var prefix=" ";if(index===0){prefix="| "}return prefix+content+" |"}var highlightRegEx=/highlight highlight-(\S+)/;module.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(content){return"~~"+content+"~~"}},{filter:function(node){return node.type==="checkbox"&&node.parentNode.nodeName==="LI"},replacement:function(content,node){return(node.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(content,node){return cell(content,node)}},{filter:"tr",replacement:function(content,node){var borderCells="";var alignMap={left:":--",right:"--:",center:":-:"};if(node.parentNode.nodeName==="THEAD"){for(var i=0;i<node.childNodes.length;i++){var align=node.childNodes[i].attributes.align;var border="---";if(align){border=alignMap[align.value]||border}borderCells+=cell(border,node.childNodes[i])}}return"\n"+content+(borderCells?"\n"+borderCells:"")}},{filter:"table",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(content){return content}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n```\n"+node.firstChild.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="PRE"&&node.parentNode.nodeName==="DIV"&&highlightRegEx.test(node.parentNode.className)},replacement:function(content,node){var language=node.parentNode.className.match(highlightRegEx)[1];return"\n\n```"+language+"\n"+node.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="DIV"&&highlightRegEx.test(node.className)},replacement:function(content){return"\n\n"+content+"\n\n"}}]},{}],3:[function(require,module,exports){var _window=(typeof window!=="undefined"?window:this);function canParseHtmlNatively(){var Parser=_window.DOMParser;var canParse=false;try{if(new Parser().parseFromString("","text/html")){canParse=true}}catch(e){}return canParse}function createHtmlParser(){var Parser=function(){};if(typeof document==="undefined"){var jsdom=require("jsdom");Parser.prototype.parseFromString=function(string){return jsdom.jsdom(string,{features:{FetchExternalResources:[],ProcessExternalResources:false}})}}else{if(!shouldUseActiveX()){Parser.prototype.parseFromString=function(string){var doc=document.implementation.createHTMLDocument("");doc.open();doc.write(string);doc.close();return doc}}else{Parser.prototype.parseFromString=function(string){var doc=new window.ActiveXObject("htmlfile");doc.designMode="on";doc.open();doc.write(string);doc.close();return doc}}}return Parser}function shouldUseActiveX(){var useActiveX=false;try{document.implementation.createHTMLDocument("").open()}catch(e){if(window.ActiveXObject){useActiveX=true}}return useActiveX}module.exports=canParseHtmlNatively()?_window.DOMParser:createHtmlParser()},{"jsdom":6}],4:[function(require,module,exports){module.exports=[{filter:"p",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(content,node){var hLevel=node.nodeName.charAt(1);var hPrefix="";for(var i=0;i<hLevel;i++){hPrefix+="#"}return"\n\n"+hPrefix+" "+content+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(content){return"_"+content+"_"}},{filter:["strong","b"],replacement:function(content){return"**"+content+"**"}},{filter:function(node){var hasSiblings=node.previousSibling||node.nextSibling;var isCodeBlock=node.parentNode.nodeName==="PRE"&&!hasSiblings;return node.nodeName==="CODE"&&!isCodeBlock},replacement:function(content){return"`"+content+"`"}},{filter:function(node){return node.nodeName==="A"&&node.getAttribute("href")},replacement:function(content,node){var titlePart=node.title?' "'+node.title+'"':"";return"["+content+"]("+node.getAttribute("href")+titlePart+")"}},{filter:"img",replacement:function(content,node){var alt=node.alt||"";var src=node.getAttribute("src")||"";var title=node.title||"";var titlePart=title?' "'+title+'"':"";return src?"!["+alt+"]"+"("+src+titlePart+")":""}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n "+node.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(content){content=content.trim();content=content.replace(/\n{3,}/g,"\n\n");content=content.replace(/^/gm,"> ");return"\n\n"+content+"\n\n"}},{filter:"li",replacement:function(content,node){content=content.replace(/^\s+/,"").replace(/\n/gm,"\n ");var prefix="* ";var parent=node.parentNode;var index=Array.prototype.indexOf.call(parent.children,node)+1;prefix=/ol/i.test(parent.nodeName)?index+". ":"* ";return prefix+content}},{filter:["ul","ol"],replacement:function(content,node){var strings=[];for(var i=0;i<node.childNodes.length;i++){strings.push(node.childNodes[i]._replacement) |
|
3 |
+}if(/li/i.test(node.parentNode.nodeName)){return"\n"+strings.join("\n")}return"\n\n"+strings.join("\n")+"\n\n"}},{filter:function(node){return this.isBlock(node)},replacement:function(content,node){return"\n\n"+this.outer(node,content)+"\n\n"}},{filter:function(){return true},replacement:function(content,node){return this.outer(node,content)}}]},{}],5:[function(require,module,exports){module.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],6:[function(require,module,exports){},{}],7:[function(require,module,exports){var voidElements=require("void-elements");Object.keys(voidElements).forEach(function(name){voidElements[name.toUpperCase()]=1});var blockElements={};require("block-elements").forEach(function(name){blockElements[name.toUpperCase()]=1});function isBlockElem(node){return !!(node&&blockElements[node.nodeName])}function isVoid(node){return !!(node&&voidElements[node.nodeName])}function collapseWhitespace(elem,isBlock){if(!elem.firstChild||elem.nodeName==="PRE"){return}if(typeof isBlock!=="function"){isBlock=isBlockElem}var prevText=null;var prevVoid=false;var prev=null;var node=next(prev,elem);while(node!==elem){if(node.nodeType===3){var text=node.data.replace(/[ \r\n\t]+/g," ");if((!prevText||/ $/.test(prevText.data))&&!prevVoid&&text[0]===" "){text=text.substr(1)}if(!text){node=remove(node);continue}node.data=text;prevText=node}else{if(node.nodeType===1){if(isBlock(node)||node.nodeName==="BR"){if(prevText){prevText.data=prevText.data.replace(/ $/,"")}prevText=null;prevVoid=false}else{if(isVoid(node)){prevText=null;prevVoid=true}}}else{node=remove(node);continue}}var nextNode=next(prev,node);prev=node;node=nextNode}if(prevText){prevText.data=prevText.data.replace(/ $/,"");if(!prevText.data){remove(prevText)}}}function remove(node){var next=node.nextSibling||node.parentNode;node.parentNode.removeChild(node);return next}function next(prev,current){if(prev&&prev.parentNode===current||current.nodeName==="PRE"){return current.nextSibling||current.parentNode}return current.firstChild||current.nextSibling||current.parentNode}module.exports=collapseWhitespace},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){module.exports={"area":true,"base":true,"br":true,"col":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"menuitem":true,"meta":true,"param":true,"source":true,"track":true,"wbr":true}},{}]},{},[1])(1)});(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-markdown",["jquery","simditor","to-markdown","marked"],function(a0,b1,c2,d3){return(root["SimditorMarkdown"]=factory(a0,b1,c2,d3))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"),require("to-markdown"),require("marked"))}else{root["SimditorMarkdown"]=factory(jQuery,Simditor,toMarkdown,marked)}}}(this,function($,Simditor,toMarkdown,marked){var SimditorMarkdown,extend=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},hasProp={}.hasOwnProperty;SimditorMarkdown=(function(superClass){extend(SimditorMarkdown,superClass);function SimditorMarkdown(){return SimditorMarkdown.__super__.constructor.apply(this,arguments)}SimditorMarkdown.prototype.name="markdown";SimditorMarkdown.prototype.icon="markdown";SimditorMarkdown.prototype.needFocus=false;SimditorMarkdown.prototype._init=function(){SimditorMarkdown.__super__._init.call(this);this.markdownEl=$('<div class="markdown-editor" />').insertBefore(this.editor.body);this.textarea=$("<textarea/>").attr("placeholder",this.editor.opts.placeholder).appendTo(this.markdownEl);this.textarea.on("focus",(function(_this){return function(e){return _this.editor.el.addClass("focus")}})(this)).on("blur",(function(_this){return function(e){return _this.editor.el.removeClass("focus")}})(this));this.editor.on("valuechanged",(function(_this){return function(e){if(!_this.editor.markdownMode){return}return _this._initMarkdownValue()}})(this));this.markdownChange=this.editor.util.throttle((function(_this){return function(){_this._autosizeTextarea();return _this._convert()}})(this),200);if(this.editor.util.support.oninput){this.textarea.on("input",(function(_this){return function(e){return _this.markdownChange()}})(this))}else{this.textarea.on("keyup",(function(_this){return function(e){return _this.markdownChange()}})(this))}if(this.editor.opts.markdown){return this.editor.on("initialized",(function(_this){return function(){return _this.el.mousedown()}})(this))}};SimditorMarkdown.prototype.status=function(){};SimditorMarkdown.prototype.command=function(){var button,i,len,ref;this.editor.blur();this.editor.el.toggleClass("simditor-markdown");this.editor.markdownMode=this.editor.el.hasClass("simditor-markdown");if(this.editor.markdownMode){this.editor.inputManager.lastCaretPosition=null;this.editor.hidePopover();this.editor.body.removeAttr("contenteditable");this._initMarkdownValue()}else{this.textarea.val("");this.editor.body.attr("contenteditable","true")}ref=this.editor.toolbar.buttons;for(i=0,len=ref.length;i<len;i++){button=ref[i];if(button.name==="markdown"){button.setActive(this.editor.markdownMode)}else{button.setDisabled(this.editor.markdownMode)}}return null};SimditorMarkdown.prototype._initMarkdownValue=function(){this._fileterUnsupportedTags();this.textarea.val(toMarkdown(this.editor.getValue(),{gfm:true}));return this._autosizeTextarea()};SimditorMarkdown.prototype._autosizeTextarea=function(){this._textareaPadding||(this._textareaPadding=this.textarea.innerHeight()-this.textarea.height());return this.textarea.height(this.textarea[0].scrollHeight-this._textareaPadding)};SimditorMarkdown.prototype._convert=function(){var markdownText,text;text=this.textarea.val();markdownText=marked(text);this.editor.textarea.val(markdownText);this.editor.body.html(markdownText);this.editor.formatter.format();return this.editor.formatter.decorate()};SimditorMarkdown.prototype._fileterUnsupportedTags=function(){return this.editor.body.find("colgroup").remove()};return SimditorMarkdown})(Simditor.Button);Simditor.Toolbar.addButton(SimditorMarkdown);return SimditorMarkdown})); |
@@ -0,0 +1,5588 @@ |
||
1 |
+/*! |
|
2 |
+* Simditor v2.3.6 |
|
3 |
+* http://simditor.tower.im/ |
|
4 |
+* 2015-12-21 |
|
5 |
+*/ |
|
6 |
+(function (root, factory) { |
|
7 |
+ if (typeof define === 'function' && define.amd) { |
|
8 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
9 |
+ define('simditor', ["jquery","simple-module","simple-hotkeys","simple-uploader"], function ($, SimpleModule, simpleHotkeys, simpleUploader) { |
|
10 |
+ return (root['Simditor'] = factory($, SimpleModule, simpleHotkeys, simpleUploader)); |
|
11 |
+ }); |
|
12 |
+ } else if (typeof exports === 'object') { |
|
13 |
+ // Node. Does not work with strict CommonJS, but |
|
14 |
+ // only CommonJS-like environments that support module.exports, |
|
15 |
+ // like Node. |
|
16 |
+ module.exports = factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader")); |
|
17 |
+ } else { |
|
18 |
+ root['Simditor'] = factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader); |
|
19 |
+ } |
|
20 |
+}(this, function ($, SimpleModule, simpleHotkeys, simpleUploader) { |
|
21 |
+ |
|
22 |
+var AlignmentButton, BlockquoteButton, BoldButton, Button, Clipboard, CodeButton, CodePopover, ColorButton, FontScaleButton, Formatter, HrButton, ImageButton, ImagePopover, IndentButton, Indentation, InputManager, ItalicButton, Keystroke, LinkButton, LinkPopover, ListButton, OrderListButton, OutdentButton, Popover, Selection, Simditor, StrikethroughButton, TableButton, TitleButton, Toolbar, UnderlineButton, UndoManager, UnorderListButton, Util, |
|
23 |
+ extend = 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; }, |
|
24 |
+ hasProp = {}.hasOwnProperty, |
|
25 |
+ indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, |
|
26 |
+ slice = [].slice; |
|
27 |
+ |
|
28 |
+Selection = (function(superClass) { |
|
29 |
+ extend(Selection, superClass); |
|
30 |
+ |
|
31 |
+ function Selection() { |
|
32 |
+ return Selection.__super__.constructor.apply(this, arguments); |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ Selection.pluginName = 'Selection'; |
|
36 |
+ |
|
37 |
+ Selection.prototype._range = null; |
|
38 |
+ |
|
39 |
+ Selection.prototype._startNodes = null; |
|
40 |
+ |
|
41 |
+ Selection.prototype._endNodes = null; |
|
42 |
+ |
|
43 |
+ Selection.prototype._containerNode = null; |
|
44 |
+ |
|
45 |
+ Selection.prototype._nodes = null; |
|
46 |
+ |
|
47 |
+ Selection.prototype._blockNodes = null; |
|
48 |
+ |
|
49 |
+ Selection.prototype._rootNodes = null; |
|
50 |
+ |
|
51 |
+ Selection.prototype._init = function() { |
|
52 |
+ this.editor = this._module; |
|
53 |
+ this._selection = document.getSelection(); |
|
54 |
+ this.editor.on('selectionchanged', (function(_this) { |
|
55 |
+ return function(e) { |
|
56 |
+ _this.reset(); |
|
57 |
+ return _this._range = _this._selection.getRangeAt(0); |
|
58 |
+ }; |
|
59 |
+ })(this)); |
|
60 |
+ return this.editor.on('blur', (function(_this) { |
|
61 |
+ return function(e) { |
|
62 |
+ return _this.reset(); |
|
63 |
+ }; |
|
64 |
+ })(this)); |
|
65 |
+ }; |
|
66 |
+ |
|
67 |
+ Selection.prototype.reset = function() { |
|
68 |
+ this._range = null; |
|
69 |
+ this._startNodes = null; |
|
70 |
+ this._endNodes = null; |
|
71 |
+ this._containerNode = null; |
|
72 |
+ this._nodes = null; |
|
73 |
+ this._blockNodes = null; |
|
74 |
+ return this._rootNodes = null; |
|
75 |
+ }; |
|
76 |
+ |
|
77 |
+ Selection.prototype.clear = function() { |
|
78 |
+ var e; |
|
79 |
+ try { |
|
80 |
+ this._selection.removeAllRanges(); |
|
81 |
+ } catch (_error) { |
|
82 |
+ e = _error; |
|
83 |
+ } |
|
84 |
+ return this.reset(); |
|
85 |
+ }; |
|
86 |
+ |
|
87 |
+ Selection.prototype.range = function(range) { |
|
88 |
+ var ffOrIE; |
|
89 |
+ if (range) { |
|
90 |
+ this.clear(); |
|
91 |
+ this._selection.addRange(range); |
|
92 |
+ this._range = range; |
|
93 |
+ ffOrIE = this.editor.util.browser.firefox || this.editor.util.browser.msie; |
|
94 |
+ if (!this.editor.inputManager.focused && ffOrIE) { |
|
95 |
+ this.editor.body.focus(); |
|
96 |
+ } |
|
97 |
+ } else if (!this._range && this.editor.inputManager.focused && this._selection.rangeCount) { |
|
98 |
+ this._range = this._selection.getRangeAt(0); |
|
99 |
+ } |
|
100 |
+ return this._range; |
|
101 |
+ }; |
|
102 |
+ |
|
103 |
+ Selection.prototype.startNodes = function() { |
|
104 |
+ if (this._range) { |
|
105 |
+ this._startNodes || (this._startNodes = (function(_this) { |
|
106 |
+ return function() { |
|
107 |
+ var startNodes; |
|
108 |
+ startNodes = $(_this._range.startContainer).parentsUntil(_this.editor.body).get(); |
|
109 |
+ startNodes.unshift(_this._range.startContainer); |
|
110 |
+ return $(startNodes); |
|
111 |
+ }; |
|
112 |
+ })(this)()); |
|
113 |
+ } |
|
114 |
+ return this._startNodes; |
|
115 |
+ }; |
|
116 |
+ |
|
117 |
+ Selection.prototype.endNodes = function() { |
|
118 |
+ var endNodes; |
|
119 |
+ if (this._range) { |
|
120 |
+ this._endNodes || (this._endNodes = this._range.collapsed ? this.startNodes() : (endNodes = $(this._range.endContainer).parentsUntil(this.editor.body).get(), endNodes.unshift(this._range.endContainer), $(endNodes))); |
|
121 |
+ } |
|
122 |
+ return this._endNodes; |
|
123 |
+ }; |
|
124 |
+ |
|
125 |
+ Selection.prototype.containerNode = function() { |
|
126 |
+ if (this._range) { |
|
127 |
+ this._containerNode || (this._containerNode = $(this._range.commonAncestorContainer)); |
|
128 |
+ } |
|
129 |
+ return this._containerNode; |
|
130 |
+ }; |
|
131 |
+ |
|
132 |
+ Selection.prototype.nodes = function() { |
|
133 |
+ if (this._range) { |
|
134 |
+ this._nodes || (this._nodes = (function(_this) { |
|
135 |
+ return function() { |
|
136 |
+ var nodes; |
|
137 |
+ nodes = []; |
|
138 |
+ if (_this.startNodes().first().is(_this.endNodes().first())) { |
|
139 |
+ nodes = _this.startNodes().get(); |
|
140 |
+ } else { |
|
141 |
+ _this.startNodes().each(function(i, node) { |
|
142 |
+ var $endNode, $node, $nodes, endIndex, index, sharedIndex, startIndex; |
|
143 |
+ $node = $(node); |
|
144 |
+ if (_this.endNodes().index($node) > -1) { |
|
145 |
+ return nodes.push(node); |
|
146 |
+ } else if ($node.parent().is(_this.editor.body) || (sharedIndex = _this.endNodes().index($node.parent())) > -1) { |
|
147 |
+ if (sharedIndex && sharedIndex > -1) { |
|
148 |
+ $endNode = _this.endNodes().eq(sharedIndex - 1); |
|
149 |
+ } else { |
|
150 |
+ $endNode = _this.endNodes().last(); |
|
151 |
+ } |
|
152 |
+ $nodes = $node.parent().contents(); |
|
153 |
+ startIndex = $nodes.index($node); |
|
154 |
+ endIndex = $nodes.index($endNode); |
|
155 |
+ return $.merge(nodes, $nodes.slice(startIndex, endIndex).get()); |
|
156 |
+ } else { |
|
157 |
+ $nodes = $node.parent().contents(); |
|
158 |
+ index = $nodes.index($node); |
|
159 |
+ return $.merge(nodes, $nodes.slice(index).get()); |
|
160 |
+ } |
|
161 |
+ }); |
|
162 |
+ _this.endNodes().each(function(i, node) { |
|
163 |
+ var $node, $nodes, index; |
|
164 |
+ $node = $(node); |
|
165 |
+ if ($node.parent().is(_this.editor.body) || _this.startNodes().index($node.parent()) > -1) { |
|
166 |
+ nodes.push(node); |
|
167 |
+ return false; |
|
168 |
+ } else { |
|
169 |
+ $nodes = $node.parent().contents(); |
|
170 |
+ index = $nodes.index($node); |
|
171 |
+ return $.merge(nodes, $nodes.slice(0, index + 1)); |
|
172 |
+ } |
|
173 |
+ }); |
|
174 |
+ } |
|
175 |
+ return $($.unique(nodes)); |
|
176 |
+ }; |
|
177 |
+ })(this)()); |
|
178 |
+ } |
|
179 |
+ return this._nodes; |
|
180 |
+ }; |
|
181 |
+ |
|
182 |
+ Selection.prototype.blockNodes = function() { |
|
183 |
+ if (!this._range) { |
|
184 |
+ return; |
|
185 |
+ } |
|
186 |
+ this._blockNodes || (this._blockNodes = (function(_this) { |
|
187 |
+ return function() { |
|
188 |
+ return _this.nodes().filter(function(i, node) { |
|
189 |
+ return _this.editor.util.isBlockNode(node); |
|
190 |
+ }); |
|
191 |
+ }; |
|
192 |
+ })(this)()); |
|
193 |
+ return this._blockNodes; |
|
194 |
+ }; |
|
195 |
+ |
|
196 |
+ Selection.prototype.rootNodes = function() { |
|
197 |
+ if (!this._range) { |
|
198 |
+ return; |
|
199 |
+ } |
|
200 |
+ this._rootNodes || (this._rootNodes = (function(_this) { |
|
201 |
+ return function() { |
|
202 |
+ return _this.nodes().filter(function(i, node) { |
|
203 |
+ var $parent; |
|
204 |
+ $parent = $(node).parent(); |
|
205 |
+ return $parent.is(_this.editor.body) || $parent.is('blockquote'); |
|
206 |
+ }); |
|
207 |
+ }; |
|
208 |
+ })(this)()); |
|
209 |
+ return this._rootNodes; |
|
210 |
+ }; |
|
211 |
+ |
|
212 |
+ Selection.prototype.rangeAtEndOf = function(node, range) { |
|
213 |
+ var afterLastNode, beforeLastNode, endNode, endNodeLength, lastNodeIsBr, result; |
|
214 |
+ if (range == null) { |
|
215 |
+ range = this.range(); |
|
216 |
+ } |
|
217 |
+ if (!(range && range.collapsed)) { |
|
218 |
+ return; |
|
219 |
+ } |
|
220 |
+ node = $(node)[0]; |
|
221 |
+ endNode = range.endContainer; |
|
222 |
+ endNodeLength = this.editor.util.getNodeLength(endNode); |
|
223 |
+ beforeLastNode = range.endOffset === endNodeLength - 1; |
|
224 |
+ lastNodeIsBr = $(endNode).contents().last().is('br'); |
|
225 |
+ afterLastNode = range.endOffset === endNodeLength; |
|
226 |
+ if (!((beforeLastNode && lastNodeIsBr) || afterLastNode)) { |
|
227 |
+ return false; |
|
228 |
+ } |
|
229 |
+ if (node === endNode) { |
|
230 |
+ return true; |
|
231 |
+ } else if (!$.contains(node, endNode)) { |
|
232 |
+ return false; |
|
233 |
+ } |
|
234 |
+ result = true; |
|
235 |
+ $(endNode).parentsUntil(node).addBack().each(function(i, n) { |
|
236 |
+ var $lastChild, beforeLastbr, isLastNode, nodes; |
|
237 |
+ nodes = $(n).parent().contents().filter(function() { |
|
238 |
+ return !(this !== n && this.nodeType === 3 && !this.nodeValue); |
|
239 |
+ }); |
|
240 |
+ $lastChild = nodes.last(); |
|
241 |
+ isLastNode = $lastChild.get(0) === n; |
|
242 |
+ beforeLastbr = $lastChild.is('br') && $lastChild.prev().get(0) === n; |
|
243 |
+ if (!(isLastNode || beforeLastbr)) { |
|
244 |
+ result = false; |
|
245 |
+ return false; |
|
246 |
+ } |
|
247 |
+ }); |
|
248 |
+ return result; |
|
249 |
+ }; |
|
250 |
+ |
|
251 |
+ Selection.prototype.rangeAtStartOf = function(node, range) { |
|
252 |
+ var result, startNode; |
|
253 |
+ if (range == null) { |
|
254 |
+ range = this.range(); |
|
255 |
+ } |
|
256 |
+ if (!(range && range.collapsed)) { |
|
257 |
+ return; |
|
258 |
+ } |
|
259 |
+ node = $(node)[0]; |
|
260 |
+ startNode = range.startContainer; |
|
261 |
+ if (range.startOffset !== 0) { |
|
262 |
+ return false; |
|
263 |
+ } |
|
264 |
+ if (node === startNode) { |
|
265 |
+ return true; |
|
266 |
+ } else if (!$.contains(node, startNode)) { |
|
267 |
+ return false; |
|
268 |
+ } |
|
269 |
+ result = true; |
|
270 |
+ $(startNode).parentsUntil(node).addBack().each(function(i, n) { |
|
271 |
+ var nodes; |
|
272 |
+ nodes = $(n).parent().contents().filter(function() { |
|
273 |
+ return !(this !== n && this.nodeType === 3 && !this.nodeValue); |
|
274 |
+ }); |
|
275 |
+ if (nodes.first().get(0) !== n) { |
|
276 |
+ return result = false; |
|
277 |
+ } |
|
278 |
+ }); |
|
279 |
+ return result; |
|
280 |
+ }; |
|
281 |
+ |
|
282 |
+ Selection.prototype.insertNode = function(node, range) { |
|
283 |
+ if (range == null) { |
|
284 |
+ range = this.range(); |
|
285 |
+ } |
|
286 |
+ if (!range) { |
|
287 |
+ return; |
|
288 |
+ } |
|
289 |
+ node = $(node)[0]; |
|
290 |
+ range.insertNode(node); |
|
291 |
+ return this.setRangeAfter(node, range); |
|
292 |
+ }; |
|
293 |
+ |
|
294 |
+ Selection.prototype.setRangeAfter = function(node, range) { |
|
295 |
+ if (range == null) { |
|
296 |
+ range = this.range(); |
|
297 |
+ } |
|
298 |
+ if (range == null) { |
|
299 |
+ return; |
|
300 |
+ } |
|
301 |
+ node = $(node)[0]; |
|
302 |
+ range.setEndAfter(node); |
|
303 |
+ range.collapse(false); |
|
304 |
+ return this.range(range); |
|
305 |
+ }; |
|
306 |
+ |
|
307 |
+ Selection.prototype.setRangeBefore = function(node, range) { |
|
308 |
+ if (range == null) { |
|
309 |
+ range = this.range(); |
|
310 |
+ } |
|
311 |
+ if (range == null) { |
|
312 |
+ return; |
|
313 |
+ } |
|
314 |
+ node = $(node)[0]; |
|
315 |
+ range.setEndBefore(node); |
|
316 |
+ range.collapse(false); |
|
317 |
+ return this.range(range); |
|
318 |
+ }; |
|
319 |
+ |
|
320 |
+ Selection.prototype.setRangeAtStartOf = function(node, range) { |
|
321 |
+ if (range == null) { |
|
322 |
+ range = this.range(); |
|
323 |
+ } |
|
324 |
+ node = $(node).get(0); |
|
325 |
+ range.setEnd(node, 0); |
|
326 |
+ range.collapse(false); |
|
327 |
+ return this.range(range); |
|
328 |
+ }; |
|
329 |
+ |
|
330 |
+ Selection.prototype.setRangeAtEndOf = function(node, range) { |
|
331 |
+ var $lastNode, $node, contents, lastChild, lastChildLength, lastText, nodeLength; |
|
332 |
+ if (range == null) { |
|
333 |
+ range = this.range(); |
|
334 |
+ } |
|
335 |
+ $node = $(node); |
|
336 |
+ node = $node[0]; |
|
337 |
+ if ($node.is('pre')) { |
|
338 |
+ contents = $node.contents(); |
|
339 |
+ if (contents.length > 0) { |
|
340 |
+ lastChild = contents.last(); |
|
341 |
+ lastText = lastChild.text(); |
|
342 |
+ lastChildLength = this.editor.util.getNodeLength(lastChild[0]); |
|
343 |
+ if (lastText.charAt(lastText.length - 1) === '\n') { |
|
344 |
+ range.setEnd(lastChild[0], lastChildLength - 1); |
|
345 |
+ } else { |
|
346 |
+ range.setEnd(lastChild[0], lastChildLength); |
|
347 |
+ } |
|
348 |
+ } else { |
|
349 |
+ range.setEnd(node, 0); |
|
350 |
+ } |
|
351 |
+ } else { |
|
352 |
+ nodeLength = this.editor.util.getNodeLength(node); |
|
353 |
+ if (node.nodeType !== 3 && nodeLength > 0) { |
|
354 |
+ $lastNode = $(node).contents().last(); |
|
355 |
+ if ($lastNode.is('br')) { |
|
356 |
+ nodeLength -= 1; |
|
357 |
+ } else if ($lastNode[0].nodeType !== 3 && this.editor.util.isEmptyNode($lastNode)) { |
|
358 |
+ $lastNode.append(this.editor.util.phBr); |
|
359 |
+ node = $lastNode[0]; |
|
360 |
+ nodeLength = 0; |
|
361 |
+ } |
|
362 |
+ } |
|
363 |
+ range.setEnd(node, nodeLength); |
|
364 |
+ } |
|
365 |
+ range.collapse(false); |
|
366 |
+ return this.range(range); |
|
367 |
+ }; |
|
368 |
+ |
|
369 |
+ Selection.prototype.deleteRangeContents = function(range) { |
|
370 |
+ var atEndOfBody, atStartOfBody, endRange, startRange; |
|
371 |
+ if (range == null) { |
|
372 |
+ range = this.range(); |
|
373 |
+ } |
|
374 |
+ startRange = range.cloneRange(); |
|
375 |
+ endRange = range.cloneRange(); |
|
376 |
+ startRange.collapse(true); |
|
377 |
+ endRange.collapse(false); |
|
378 |
+ atStartOfBody = this.rangeAtStartOf(this.editor.body, startRange); |
|
379 |
+ atEndOfBody = this.rangeAtEndOf(this.editor.body, endRange); |
|
380 |
+ if (!range.collapsed && atStartOfBody && atEndOfBody) { |
|
381 |
+ this.editor.body.empty(); |
|
382 |
+ range.setStart(this.editor.body[0], 0); |
|
383 |
+ range.collapse(true); |
|
384 |
+ this.range(range); |
|
385 |
+ } else { |
|
386 |
+ range.deleteContents(); |
|
387 |
+ } |
|
388 |
+ return range; |
|
389 |
+ }; |
|
390 |
+ |
|
391 |
+ Selection.prototype.breakBlockEl = function(el, range) { |
|
392 |
+ var $el; |
|
393 |
+ if (range == null) { |
|
394 |
+ range = this.range(); |
|
395 |
+ } |
|
396 |
+ $el = $(el); |
|
397 |
+ if (!range.collapsed) { |
|
398 |
+ return $el; |
|
399 |
+ } |
|
400 |
+ range.setStartBefore($el.get(0)); |
|
401 |
+ if (range.collapsed) { |
|
402 |
+ return $el; |
|
403 |
+ } |
|
404 |
+ return $el.before(range.extractContents()); |
|
405 |
+ }; |
|
406 |
+ |
|
407 |
+ Selection.prototype.save = function(range) { |
|
408 |
+ var endCaret, endRange, startCaret; |
|
409 |
+ if (range == null) { |
|
410 |
+ range = this.range(); |
|
411 |
+ } |
|
412 |
+ if (this._selectionSaved) { |
|
413 |
+ return; |
|
414 |
+ } |
|
415 |
+ endRange = range.cloneRange(); |
|
416 |
+ endRange.collapse(false); |
|
417 |
+ startCaret = $('<span/>').addClass('simditor-caret-start'); |
|
418 |
+ endCaret = $('<span/>').addClass('simditor-caret-end'); |
|
419 |
+ endRange.insertNode(endCaret[0]); |
|
420 |
+ range.insertNode(startCaret[0]); |
|
421 |
+ this.clear(); |
|
422 |
+ return this._selectionSaved = true; |
|
423 |
+ }; |
|
424 |
+ |
|
425 |
+ Selection.prototype.restore = function() { |
|
426 |
+ var endCaret, endContainer, endOffset, range, startCaret, startContainer, startOffset; |
|
427 |
+ if (!this._selectionSaved) { |
|
428 |
+ return false; |
|
429 |
+ } |
|
430 |
+ startCaret = this.editor.body.find('.simditor-caret-start'); |
|
431 |
+ endCaret = this.editor.body.find('.simditor-caret-end'); |
|
432 |
+ if (startCaret.length && endCaret.length) { |
|
433 |
+ startContainer = startCaret.parent(); |
|
434 |
+ startOffset = startContainer.contents().index(startCaret); |
|
435 |
+ endContainer = endCaret.parent(); |
|
436 |
+ endOffset = endContainer.contents().index(endCaret); |
|
437 |
+ if (startContainer[0] === endContainer[0]) { |
|
438 |
+ endOffset -= 1; |
|
439 |
+ } |
|
440 |
+ range = document.createRange(); |
|
441 |
+ range.setStart(startContainer.get(0), startOffset); |
|
442 |
+ range.setEnd(endContainer.get(0), endOffset); |
|
443 |
+ startCaret.remove(); |
|
444 |
+ endCaret.remove(); |
|
445 |
+ this.range(range); |
|
446 |
+ } else { |
|
447 |
+ startCaret.remove(); |
|
448 |
+ endCaret.remove(); |
|
449 |
+ } |
|
450 |
+ this._selectionSaved = false; |
|
451 |
+ return range; |
|
452 |
+ }; |
|
453 |
+ |
|
454 |
+ return Selection; |
|
455 |
+ |
|
456 |
+})(SimpleModule); |
|
457 |
+ |
|
458 |
+Formatter = (function(superClass) { |
|
459 |
+ extend(Formatter, superClass); |
|
460 |
+ |
|
461 |
+ function Formatter() { |
|
462 |
+ return Formatter.__super__.constructor.apply(this, arguments); |
|
463 |
+ } |
|
464 |
+ |
|
465 |
+ Formatter.pluginName = 'Formatter'; |
|
466 |
+ |
|
467 |
+ Formatter.prototype.opts = { |
|
468 |
+ allowedTags: [], |
|
469 |
+ allowedAttributes: {}, |
|
470 |
+ allowedStyles: {} |
|
471 |
+ }; |
|
472 |
+ |
|
473 |
+ Formatter.prototype._init = function() { |
|
474 |
+ this.editor = this._module; |
|
475 |
+ this._allowedTags = $.merge(['br', 'span', 'a', 'img', 'b', 'strong', 'i', 'strike', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'hr'], this.opts.allowedTags); |
|
476 |
+ this._allowedAttributes = $.extend({ |
|
477 |
+ img: ['src', 'alt', 'width', 'height', 'data-non-image'], |
|
478 |
+ a: ['href', 'target'], |
|
479 |
+ font: ['color'], |
|
480 |
+ code: ['class'] |
|
481 |
+ }, this.opts.allowedAttributes); |
|
482 |
+ this._allowedStyles = $.extend({ |
|
483 |
+ span: ['color', 'font-size'], |
|
484 |
+ b: ['color'], |
|
485 |
+ i: ['color'], |
|
486 |
+ strong: ['color'], |
|
487 |
+ strike: ['color'], |
|
488 |
+ u: ['color'], |
|
489 |
+ p: ['margin-left', 'text-align'], |
|
490 |
+ h1: ['margin-left', 'text-align'], |
|
491 |
+ h2: ['margin-left', 'text-align'], |
|
492 |
+ h3: ['margin-left', 'text-align'], |
|
493 |
+ h4: ['margin-left', 'text-align'] |
|
494 |
+ }, this.opts.allowedStyles); |
|
495 |
+ return this.editor.body.on('click', 'a', function(e) { |
|
496 |
+ return false; |
|
497 |
+ }); |
|
498 |
+ }; |
|
499 |
+ |
|
500 |
+ Formatter.prototype.decorate = function($el) { |
|
501 |
+ if ($el == null) { |
|
502 |
+ $el = this.editor.body; |
|
503 |
+ } |
|
504 |
+ this.editor.trigger('decorate', [$el]); |
|
505 |
+ return $el; |
|
506 |
+ }; |
|
507 |
+ |
|
508 |
+ Formatter.prototype.undecorate = function($el) { |
|
509 |
+ if ($el == null) { |
|
510 |
+ $el = this.editor.body.clone(); |
|
511 |
+ } |
|
512 |
+ this.editor.trigger('undecorate', [$el]); |
|
513 |
+ return $el; |
|
514 |
+ }; |
|
515 |
+ |
|
516 |
+ Formatter.prototype.autolink = function($el) { |
|
517 |
+ var $link, $node, findLinkNode, k, lastIndex, len, linkNodes, match, re, replaceEls, subStr, text, uri; |
|
518 |
+ if ($el == null) { |
|
519 |
+ $el = this.editor.body; |
|
520 |
+ } |
|
521 |
+ linkNodes = []; |
|
522 |
+ findLinkNode = function($parentNode) { |
|
523 |
+ return $parentNode.contents().each(function(i, node) { |
|
524 |
+ var $node, text; |
|
525 |
+ $node = $(node); |
|
526 |
+ if ($node.is('a') || $node.closest('a, pre', $el).length) { |
|
527 |
+ return; |
|
528 |
+ } |
|
529 |
+ if (!$node.is('iframe') && $node.contents().length) { |
|
530 |
+ return findLinkNode($node); |
|
531 |
+ } else if ((text = $node.text()) && /https?:\/\/|www\./ig.test(text)) { |
|
532 |
+ return linkNodes.push($node); |
|
533 |
+ } |
|
534 |
+ }); |
|
535 |
+ }; |
|
536 |
+ findLinkNode($el); |
|
537 |
+ re = /(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/ig; |
|
538 |
+ for (k = 0, len = linkNodes.length; k < len; k++) { |
|
539 |
+ $node = linkNodes[k]; |
|
540 |
+ text = $node.text(); |
|
541 |
+ replaceEls = []; |
|
542 |
+ match = null; |
|
543 |
+ lastIndex = 0; |
|
544 |
+ while ((match = re.exec(text)) !== null) { |
|
545 |
+ subStr = text.substring(lastIndex, match.index); |
|
546 |
+ replaceEls.push(document.createTextNode(subStr)); |
|
547 |
+ lastIndex = re.lastIndex; |
|
548 |
+ uri = /^(http(s)?:\/\/|\/)/.test(match[0]) ? match[0] : 'http://' + match[0]; |
|
549 |
+ $link = $("<a href=\"" + uri + "\" rel=\"nofollow\"></a>").text(match[0]); |
|
550 |
+ replaceEls.push($link[0]); |
|
551 |
+ } |
|
552 |
+ replaceEls.push(document.createTextNode(text.substring(lastIndex))); |
|
553 |
+ $node.replaceWith($(replaceEls)); |
|
554 |
+ } |
|
555 |
+ return $el; |
|
556 |
+ }; |
|
557 |
+ |
|
558 |
+ Formatter.prototype.format = function($el) { |
|
559 |
+ var $node, blockNode, k, l, len, len1, n, node, ref, ref1; |
|
560 |
+ if ($el == null) { |
|
561 |
+ $el = this.editor.body; |
|
562 |
+ } |
|
563 |
+ if ($el.is(':empty')) { |
|
564 |
+ $el.append('<p>' + this.editor.util.phBr + '</p>'); |
|
565 |
+ return $el; |
|
566 |
+ } |
|
567 |
+ ref = $el.contents(); |
|
568 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
569 |
+ n = ref[k]; |
|
570 |
+ this.cleanNode(n, true); |
|
571 |
+ } |
|
572 |
+ ref1 = $el.contents(); |
|
573 |
+ for (l = 0, len1 = ref1.length; l < len1; l++) { |
|
574 |
+ node = ref1[l]; |
|
575 |
+ $node = $(node); |
|
576 |
+ if ($node.is('br')) { |
|
577 |
+ if (typeof blockNode !== "undefined" && blockNode !== null) { |
|
578 |
+ blockNode = null; |
|
579 |
+ } |
|
580 |
+ $node.remove(); |
|
581 |
+ } else if (this.editor.util.isBlockNode(node)) { |
|
582 |
+ if ($node.is('li')) { |
|
583 |
+ if (blockNode && blockNode.is('ul, ol')) { |
|
584 |
+ blockNode.append(node); |
|
585 |
+ } else { |
|
586 |
+ blockNode = $('<ul/>').insertBefore(node); |
|
587 |
+ blockNode.append(node); |
|
588 |
+ } |
|
589 |
+ } else { |
|
590 |
+ blockNode = null; |
|
591 |
+ } |
|
592 |
+ } else { |
|
593 |
+ if (!blockNode || blockNode.is('ul, ol')) { |
|
594 |
+ blockNode = $('<p/>').insertBefore(node); |
|
595 |
+ } |
|
596 |
+ blockNode.append(node); |
|
597 |
+ if (this.editor.util.isEmptyNode(blockNode)) { |
|
598 |
+ blockNode.append(this.editor.util.phBr); |
|
599 |
+ } |
|
600 |
+ } |
|
601 |
+ } |
|
602 |
+ return $el; |
|
603 |
+ }; |
|
604 |
+ |
|
605 |
+ Formatter.prototype.cleanNode = function(node, recursive) { |
|
606 |
+ var $blockEls, $childImg, $node, $p, $td, allowedAttributes, attr, contents, isDecoration, k, l, len, len1, n, ref, ref1, text, textNode; |
|
607 |
+ $node = $(node); |
|
608 |
+ if (!($node.length > 0)) { |
|
609 |
+ return; |
|
610 |
+ } |
|
611 |
+ if ($node[0].nodeType === 3) { |
|
612 |
+ text = $node.text().replace(/(\r\n|\n|\r)/gm, ''); |
|
613 |
+ if (text) { |
|
614 |
+ textNode = document.createTextNode(text); |
|
615 |
+ $node.replaceWith(textNode); |
|
616 |
+ } else { |
|
617 |
+ $node.remove(); |
|
618 |
+ } |
|
619 |
+ return; |
|
620 |
+ } |
|
621 |
+ contents = $node.is('iframe') ? null : $node.contents(); |
|
622 |
+ isDecoration = this.editor.util.isDecoratedNode($node); |
|
623 |
+ if ($node.is(this._allowedTags.join(',')) || isDecoration) { |
|
624 |
+ if ($node.is('a') && ($childImg = $node.find('img')).length > 0) { |
|
625 |
+ $node.replaceWith($childImg); |
|
626 |
+ $node = $childImg; |
|
627 |
+ contents = null; |
|
628 |
+ } |
|
629 |
+ if ($node.is('td') && ($blockEls = $node.find(this.editor.util.blockNodes.join(','))).length > 0) { |
|
630 |
+ $blockEls.each((function(_this) { |
|
631 |
+ return function(i, blockEl) { |
|
632 |
+ return $(blockEl).contents().unwrap(); |
|
633 |
+ }; |
|
634 |
+ })(this)); |
|
635 |
+ contents = $node.contents(); |
|
636 |
+ } |
|
637 |
+ if ($node.is('img') && $node.hasClass('uploading')) { |
|
638 |
+ $node.remove(); |
|
639 |
+ } |
|
640 |
+ if (!isDecoration) { |
|
641 |
+ allowedAttributes = this._allowedAttributes[$node[0].tagName.toLowerCase()]; |
|
642 |
+ ref = $.makeArray($node[0].attributes); |
|
643 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
644 |
+ attr = ref[k]; |
|
645 |
+ if (attr.name === 'style') { |
|
646 |
+ continue; |
|
647 |
+ } |
|
648 |
+ if (!((allowedAttributes != null) && (ref1 = attr.name, indexOf.call(allowedAttributes, ref1) >= 0))) { |
|
649 |
+ $node.removeAttr(attr.name); |
|
650 |
+ } |
|
651 |
+ } |
|
652 |
+ this._cleanNodeStyles($node); |
|
653 |
+ if ($node.is('span') && $node[0].attributes.length === 0) { |
|
654 |
+ $node.contents().first().unwrap(); |
|
655 |
+ } |
|
656 |
+ } |
|
657 |
+ } else if ($node[0].nodeType === 1 && !$node.is(':empty')) { |
|
658 |
+ if ($node.is('div, article, dl, header, footer, tr')) { |
|
659 |
+ $node.append('<br/>'); |
|
660 |
+ contents.first().unwrap(); |
|
661 |
+ } else if ($node.is('table')) { |
|
662 |
+ $p = $('<p/>'); |
|
663 |
+ $node.find('tr').each(function(i, tr) { |
|
664 |
+ return $p.append($(tr).text() + '<br/>'); |
|
665 |
+ }); |
|
666 |
+ $node.replaceWith($p); |
|
667 |
+ contents = null; |
|
668 |
+ } else if ($node.is('thead, tfoot')) { |
|
669 |
+ $node.remove(); |
|
670 |
+ contents = null; |
|
671 |
+ } else if ($node.is('th')) { |
|
672 |
+ $td = $('<td/>').append($node.contents()); |
|
673 |
+ $node.replaceWith($td); |
|
674 |
+ } else { |
|
675 |
+ contents.first().unwrap(); |
|
676 |
+ } |
|
677 |
+ } else { |
|
678 |
+ $node.remove(); |
|
679 |
+ contents = null; |
|
680 |
+ } |
|
681 |
+ if (recursive && (contents != null) && !$node.is('pre')) { |
|
682 |
+ for (l = 0, len1 = contents.length; l < len1; l++) { |
|
683 |
+ n = contents[l]; |
|
684 |
+ this.cleanNode(n, true); |
|
685 |
+ } |
|
686 |
+ } |
|
687 |
+ return null; |
|
688 |
+ }; |
|
689 |
+ |
|
690 |
+ Formatter.prototype._cleanNodeStyles = function($node) { |
|
691 |
+ var allowedStyles, k, len, pair, ref, ref1, style, styleStr, styles; |
|
692 |
+ styleStr = $node.attr('style'); |
|
693 |
+ if (!styleStr) { |
|
694 |
+ return; |
|
695 |
+ } |
|
696 |
+ $node.removeAttr('style'); |
|
697 |
+ allowedStyles = this._allowedStyles[$node[0].tagName.toLowerCase()]; |
|
698 |
+ if (!(allowedStyles && allowedStyles.length > 0)) { |
|
699 |
+ return $node; |
|
700 |
+ } |
|
701 |
+ styles = {}; |
|
702 |
+ ref = styleStr.split(';'); |
|
703 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
704 |
+ style = ref[k]; |
|
705 |
+ style = $.trim(style); |
|
706 |
+ pair = style.split(':'); |
|
707 |
+ if (!(pair.length = 2)) { |
|
708 |
+ continue; |
|
709 |
+ } |
|
710 |
+ if (ref1 = pair[0], indexOf.call(allowedStyles, ref1) >= 0) { |
|
711 |
+ styles[$.trim(pair[0])] = $.trim(pair[1]); |
|
712 |
+ } |
|
713 |
+ } |
|
714 |
+ if (Object.keys(styles).length > 0) { |
|
715 |
+ $node.css(styles); |
|
716 |
+ } |
|
717 |
+ return $node; |
|
718 |
+ }; |
|
719 |
+ |
|
720 |
+ Formatter.prototype.clearHtml = function(html, lineBreak) { |
|
721 |
+ var container, contents, result; |
|
722 |
+ if (lineBreak == null) { |
|
723 |
+ lineBreak = true; |
|
724 |
+ } |
|
725 |
+ container = $('<div/>').append(html); |
|
726 |
+ contents = container.contents(); |
|
727 |
+ result = ''; |
|
728 |
+ contents.each((function(_this) { |
|
729 |
+ return function(i, node) { |
|
730 |
+ var $node, children; |
|
731 |
+ if (node.nodeType === 3) { |
|
732 |
+ return result += node.nodeValue; |
|
733 |
+ } else if (node.nodeType === 1) { |
|
734 |
+ $node = $(node); |
|
735 |
+ children = $node.is('iframe') ? null : $node.contents(); |
|
736 |
+ if (children && children.length > 0) { |
|
737 |
+ result += _this.clearHtml(children); |
|
738 |
+ } |
|
739 |
+ if (lineBreak && i < contents.length - 1 && $node.is('br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header')) { |
|
740 |
+ return result += '\n'; |
|
741 |
+ } |
|
742 |
+ } |
|
743 |
+ }; |
|
744 |
+ })(this)); |
|
745 |
+ return result; |
|
746 |
+ }; |
|
747 |
+ |
|
748 |
+ Formatter.prototype.beautify = function($contents) { |
|
749 |
+ var uselessP; |
|
750 |
+ uselessP = function($el) { |
|
751 |
+ return !!($el.is('p') && !$el.text() && $el.children(':not(br)').length < 1); |
|
752 |
+ }; |
|
753 |
+ return $contents.each(function(i, el) { |
|
754 |
+ var $el, invalid; |
|
755 |
+ $el = $(el); |
|
756 |
+ invalid = $el.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty'); |
|
757 |
+ if (invalid || uselessP($el)) { |
|
758 |
+ $el.remove(); |
|
759 |
+ } |
|
760 |
+ return $el.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove(); |
|
761 |
+ }); |
|
762 |
+ }; |
|
763 |
+ |
|
764 |
+ return Formatter; |
|
765 |
+ |
|
766 |
+})(SimpleModule); |
|
767 |
+ |
|
768 |
+InputManager = (function(superClass) { |
|
769 |
+ extend(InputManager, superClass); |
|
770 |
+ |
|
771 |
+ function InputManager() { |
|
772 |
+ return InputManager.__super__.constructor.apply(this, arguments); |
|
773 |
+ } |
|
774 |
+ |
|
775 |
+ InputManager.pluginName = 'InputManager'; |
|
776 |
+ |
|
777 |
+ InputManager.prototype._modifierKeys = [16, 17, 18, 91, 93, 224]; |
|
778 |
+ |
|
779 |
+ InputManager.prototype._arrowKeys = [37, 38, 39, 40]; |
|
780 |
+ |
|
781 |
+ InputManager.prototype._init = function() { |
|
782 |
+ var selectAllKey, submitKey; |
|
783 |
+ this.editor = this._module; |
|
784 |
+ this.throttledValueChanged = this.editor.util.throttle((function(_this) { |
|
785 |
+ return function(params) { |
|
786 |
+ return setTimeout(function() { |
|
787 |
+ return _this.editor.trigger('valuechanged', params); |
|
788 |
+ }, 10); |
|
789 |
+ }; |
|
790 |
+ })(this), 300); |
|
791 |
+ this.throttledSelectionChanged = this.editor.util.throttle((function(_this) { |
|
792 |
+ return function() { |
|
793 |
+ return _this.editor.trigger('selectionchanged'); |
|
794 |
+ }; |
|
795 |
+ })(this), 50); |
|
796 |
+ $(document).on('selectionchange.simditor' + this.editor.id, (function(_this) { |
|
797 |
+ return function(e) { |
|
798 |
+ var triggerEvent; |
|
799 |
+ if (!(_this.focused && !_this.editor.clipboard.pasting)) { |
|
800 |
+ return; |
|
801 |
+ } |
|
802 |
+ triggerEvent = function() { |
|
803 |
+ if (_this._selectionTimer) { |
|
804 |
+ clearTimeout(_this._selectionTimer); |
|
805 |
+ _this._selectionTimer = null; |
|
806 |
+ } |
|
807 |
+ if (_this.editor.selection._selection.rangeCount > 0) { |
|
808 |
+ return _this.throttledSelectionChanged(); |
|
809 |
+ } else { |
|
810 |
+ return _this._selectionTimer = setTimeout(function() { |
|
811 |
+ _this._selectionTimer = null; |
|
812 |
+ if (_this.focused) { |
|
813 |
+ return triggerEvent(); |
|
814 |
+ } |
|
815 |
+ }, 10); |
|
816 |
+ } |
|
817 |
+ }; |
|
818 |
+ return triggerEvent(); |
|
819 |
+ }; |
|
820 |
+ })(this)); |
|
821 |
+ this.editor.on('valuechanged', (function(_this) { |
|
822 |
+ return function() { |
|
823 |
+ var $rootBlocks; |
|
824 |
+ _this.lastCaretPosition = null; |
|
825 |
+ $rootBlocks = _this.editor.body.children().filter(function(i, node) { |
|
826 |
+ return _this.editor.util.isBlockNode(node); |
|
827 |
+ }); |
|
828 |
+ if (_this.focused && $rootBlocks.length === 0) { |
|
829 |
+ _this.editor.selection.save(); |
|
830 |
+ _this.editor.formatter.format(); |
|
831 |
+ _this.editor.selection.restore(); |
|
832 |
+ } |
|
833 |
+ _this.editor.body.find('hr, pre, .simditor-table').each(function(i, el) { |
|
834 |
+ var $el, formatted; |
|
835 |
+ $el = $(el); |
|
836 |
+ if ($el.parent().is('blockquote') || $el.parent()[0] === _this.editor.body[0]) { |
|
837 |
+ formatted = false; |
|
838 |
+ if ($el.next().length === 0) { |
|
839 |
+ $('<p/>').append(_this.editor.util.phBr).insertAfter($el); |
|
840 |
+ formatted = true; |
|
841 |
+ } |
|
842 |
+ if ($el.prev().length === 0) { |
|
843 |
+ $('<p/>').append(_this.editor.util.phBr).insertBefore($el); |
|
844 |
+ formatted = true; |
|
845 |
+ } |
|
846 |
+ if (formatted) { |
|
847 |
+ return _this.throttledValueChanged(); |
|
848 |
+ } |
|
849 |
+ } |
|
850 |
+ }); |
|
851 |
+ _this.editor.body.find('pre:empty').append(_this.editor.util.phBr); |
|
852 |
+ if (!_this.editor.util.support.onselectionchange && _this.focused) { |
|
853 |
+ return _this.throttledSelectionChanged(); |
|
854 |
+ } |
|
855 |
+ }; |
|
856 |
+ })(this)); |
|
857 |
+ this.editor.body.on('keydown', $.proxy(this._onKeyDown, this)).on('keypress', $.proxy(this._onKeyPress, this)).on('keyup', $.proxy(this._onKeyUp, this)).on('mouseup', $.proxy(this._onMouseUp, this)).on('focus', $.proxy(this._onFocus, this)).on('blur', $.proxy(this._onBlur, this)).on('drop', $.proxy(this._onDrop, this)).on('input', $.proxy(this._onInput, this)); |
|
858 |
+ if (this.editor.util.browser.firefox) { |
|
859 |
+ this.editor.hotkeys.add('cmd+left', (function(_this) { |
|
860 |
+ return function(e) { |
|
861 |
+ e.preventDefault(); |
|
862 |
+ _this.editor.selection._selection.modify('move', 'backward', 'lineboundary'); |
|
863 |
+ return false; |
|
864 |
+ }; |
|
865 |
+ })(this)); |
|
866 |
+ this.editor.hotkeys.add('cmd+right', (function(_this) { |
|
867 |
+ return function(e) { |
|
868 |
+ e.preventDefault(); |
|
869 |
+ _this.editor.selection._selection.modify('move', 'forward', 'lineboundary'); |
|
870 |
+ return false; |
|
871 |
+ }; |
|
872 |
+ })(this)); |
|
873 |
+ selectAllKey = this.editor.util.os.mac ? 'cmd+a' : 'ctrl+a'; |
|
874 |
+ this.editor.hotkeys.add(selectAllKey, (function(_this) { |
|
875 |
+ return function(e) { |
|
876 |
+ var $children, firstBlock, lastBlock, range; |
|
877 |
+ $children = _this.editor.body.children(); |
|
878 |
+ if (!($children.length > 0)) { |
|
879 |
+ return; |
|
880 |
+ } |
|
881 |
+ firstBlock = $children.first().get(0); |
|
882 |
+ lastBlock = $children.last().get(0); |
|
883 |
+ range = document.createRange(); |
|
884 |
+ range.setStart(firstBlock, 0); |
|
885 |
+ range.setEnd(lastBlock, _this.editor.util.getNodeLength(lastBlock)); |
|
886 |
+ _this.editor.selection.range(range); |
|
887 |
+ return false; |
|
888 |
+ }; |
|
889 |
+ })(this)); |
|
890 |
+ } |
|
891 |
+ submitKey = this.editor.util.os.mac ? 'cmd+enter' : 'ctrl+enter'; |
|
892 |
+ return this.editor.hotkeys.add(submitKey, (function(_this) { |
|
893 |
+ return function(e) { |
|
894 |
+ _this.editor.el.closest('form').find('button:submit').click(); |
|
895 |
+ return false; |
|
896 |
+ }; |
|
897 |
+ })(this)); |
|
898 |
+ }; |
|
899 |
+ |
|
900 |
+ InputManager.prototype._onFocus = function(e) { |
|
901 |
+ if (this.editor.clipboard.pasting) { |
|
902 |
+ return; |
|
903 |
+ } |
|
904 |
+ this.editor.el.addClass('focus').removeClass('error'); |
|
905 |
+ this.focused = true; |
|
906 |
+ return setTimeout((function(_this) { |
|
907 |
+ return function() { |
|
908 |
+ var $blockEl, range; |
|
909 |
+ range = _this.editor.selection._selection.getRangeAt(0); |
|
910 |
+ if (range.startContainer === _this.editor.body[0]) { |
|
911 |
+ if (_this.lastCaretPosition) { |
|
912 |
+ _this.editor.undoManager.caretPosition(_this.lastCaretPosition); |
|
913 |
+ } else { |
|
914 |
+ $blockEl = _this.editor.body.children().first(); |
|
915 |
+ range = document.createRange(); |
|
916 |
+ _this.editor.selection.setRangeAtStartOf($blockEl, range); |
|
917 |
+ } |
|
918 |
+ } |
|
919 |
+ _this.lastCaretPosition = null; |
|
920 |
+ _this.editor.triggerHandler('focus'); |
|
921 |
+ if (!_this.editor.util.support.onselectionchange) { |
|
922 |
+ return _this.throttledSelectionChanged(); |
|
923 |
+ } |
|
924 |
+ }; |
|
925 |
+ })(this), 0); |
|
926 |
+ }; |
|
927 |
+ |
|
928 |
+ InputManager.prototype._onBlur = function(e) { |
|
929 |
+ var ref; |
|
930 |
+ if (this.editor.clipboard.pasting) { |
|
931 |
+ return; |
|
932 |
+ } |
|
933 |
+ this.editor.el.removeClass('focus'); |
|
934 |
+ this.editor.sync(); |
|
935 |
+ this.focused = false; |
|
936 |
+ this.lastCaretPosition = (ref = this.editor.undoManager.currentState()) != null ? ref.caret : void 0; |
|
937 |
+ return this.editor.triggerHandler('blur'); |
|
938 |
+ }; |
|
939 |
+ |
|
940 |
+ InputManager.prototype._onMouseUp = function(e) { |
|
941 |
+ if (!this.editor.util.support.onselectionchange) { |
|
942 |
+ return this.throttledSelectionChanged(); |
|
943 |
+ } |
|
944 |
+ }; |
|
945 |
+ |
|
946 |
+ InputManager.prototype._onKeyDown = function(e) { |
|
947 |
+ var ref, ref1; |
|
948 |
+ if (this.editor.triggerHandler(e) === false) { |
|
949 |
+ return false; |
|
950 |
+ } |
|
951 |
+ if (this.editor.hotkeys.respondTo(e)) { |
|
952 |
+ return; |
|
953 |
+ } |
|
954 |
+ if (this.editor.keystroke.respondTo(e)) { |
|
955 |
+ this.throttledValueChanged(); |
|
956 |
+ return false; |
|
957 |
+ } |
|
958 |
+ if ((ref = e.which, indexOf.call(this._modifierKeys, ref) >= 0) || (ref1 = e.which, indexOf.call(this._arrowKeys, ref1) >= 0)) { |
|
959 |
+ return; |
|
960 |
+ } |
|
961 |
+ if (this.editor.util.metaKey(e) && e.which === 86) { |
|
962 |
+ return; |
|
963 |
+ } |
|
964 |
+ if (!this.editor.util.support.oninput) { |
|
965 |
+ this.throttledValueChanged(['typing']); |
|
966 |
+ } |
|
967 |
+ return null; |
|
968 |
+ }; |
|
969 |
+ |
|
970 |
+ InputManager.prototype._onKeyPress = function(e) { |
|
971 |
+ if (this.editor.triggerHandler(e) === false) { |
|
972 |
+ return false; |
|
973 |
+ } |
|
974 |
+ }; |
|
975 |
+ |
|
976 |
+ InputManager.prototype._onKeyUp = function(e) { |
|
977 |
+ var p, ref; |
|
978 |
+ if (this.editor.triggerHandler(e) === false) { |
|
979 |
+ return false; |
|
980 |
+ } |
|
981 |
+ if (!this.editor.util.support.onselectionchange && (ref = e.which, indexOf.call(this._arrowKeys, ref) >= 0)) { |
|
982 |
+ this.throttledValueChanged(); |
|
983 |
+ return; |
|
984 |
+ } |
|
985 |
+ if ((e.which === 8 || e.which === 46) && this.editor.util.isEmptyNode(this.editor.body)) { |
|
986 |
+ this.editor.body.empty(); |
|
987 |
+ p = $('<p/>').append(this.editor.util.phBr).appendTo(this.editor.body); |
|
988 |
+ this.editor.selection.setRangeAtStartOf(p); |
|
989 |
+ } |
|
990 |
+ }; |
|
991 |
+ |
|
992 |
+ InputManager.prototype._onDrop = function(e) { |
|
993 |
+ if (this.editor.triggerHandler(e) === false) { |
|
994 |
+ return false; |
|
995 |
+ } |
|
996 |
+ return this.throttledValueChanged(); |
|
997 |
+ }; |
|
998 |
+ |
|
999 |
+ InputManager.prototype._onInput = function(e) { |
|
1000 |
+ return this.throttledValueChanged(['oninput']); |
|
1001 |
+ }; |
|
1002 |
+ |
|
1003 |
+ return InputManager; |
|
1004 |
+ |
|
1005 |
+})(SimpleModule); |
|
1006 |
+ |
|
1007 |
+Keystroke = (function(superClass) { |
|
1008 |
+ extend(Keystroke, superClass); |
|
1009 |
+ |
|
1010 |
+ function Keystroke() { |
|
1011 |
+ return Keystroke.__super__.constructor.apply(this, arguments); |
|
1012 |
+ } |
|
1013 |
+ |
|
1014 |
+ Keystroke.pluginName = 'Keystroke'; |
|
1015 |
+ |
|
1016 |
+ Keystroke.prototype._init = function() { |
|
1017 |
+ this.editor = this._module; |
|
1018 |
+ this._keystrokeHandlers = {}; |
|
1019 |
+ return this._initKeystrokeHandlers(); |
|
1020 |
+ }; |
|
1021 |
+ |
|
1022 |
+ Keystroke.prototype.add = function(key, node, handler) { |
|
1023 |
+ key = key.toLowerCase(); |
|
1024 |
+ key = this.editor.hotkeys.constructor.aliases[key] || key; |
|
1025 |
+ if (!this._keystrokeHandlers[key]) { |
|
1026 |
+ this._keystrokeHandlers[key] = {}; |
|
1027 |
+ } |
|
1028 |
+ return this._keystrokeHandlers[key][node] = handler; |
|
1029 |
+ }; |
|
1030 |
+ |
|
1031 |
+ Keystroke.prototype.respondTo = function(e) { |
|
1032 |
+ var base, key, ref, result; |
|
1033 |
+ key = (ref = this.editor.hotkeys.constructor.keyNameMap[e.which]) != null ? ref.toLowerCase() : void 0; |
|
1034 |
+ if (!key) { |
|
1035 |
+ return; |
|
1036 |
+ } |
|
1037 |
+ if (key in this._keystrokeHandlers) { |
|
1038 |
+ result = typeof (base = this._keystrokeHandlers[key])['*'] === "function" ? base['*'](e) : void 0; |
|
1039 |
+ if (!result) { |
|
1040 |
+ this.editor.selection.startNodes().each((function(_this) { |
|
1041 |
+ return function(i, node) { |
|
1042 |
+ var handler, ref1; |
|
1043 |
+ if (node.nodeType !== Node.ELEMENT_NODE) { |
|
1044 |
+ return; |
|
1045 |
+ } |
|
1046 |
+ handler = (ref1 = _this._keystrokeHandlers[key]) != null ? ref1[node.tagName.toLowerCase()] : void 0; |
|
1047 |
+ result = typeof handler === "function" ? handler(e, $(node)) : void 0; |
|
1048 |
+ if (result === true || result === false) { |
|
1049 |
+ return false; |
|
1050 |
+ } |
|
1051 |
+ }; |
|
1052 |
+ })(this)); |
|
1053 |
+ } |
|
1054 |
+ if (result) { |
|
1055 |
+ return true; |
|
1056 |
+ } |
|
1057 |
+ } |
|
1058 |
+ }; |
|
1059 |
+ |
|
1060 |
+ Keystroke.prototype._initKeystrokeHandlers = function() { |
|
1061 |
+ var titleEnterHandler; |
|
1062 |
+ if (this.editor.util.browser.safari) { |
|
1063 |
+ this.add('enter', '*', (function(_this) { |
|
1064 |
+ return function(e) { |
|
1065 |
+ var $blockEl, $br; |
|
1066 |
+ if (!e.shiftKey) { |
|
1067 |
+ return; |
|
1068 |
+ } |
|
1069 |
+ $blockEl = _this.editor.selection.blockNodes().last(); |
|
1070 |
+ if ($blockEl.is('pre')) { |
|
1071 |
+ return; |
|
1072 |
+ } |
|
1073 |
+ $br = $('<br/>'); |
|
1074 |
+ if (_this.editor.selection.rangeAtEndOf($blockEl)) { |
|
1075 |
+ _this.editor.selection.insertNode($br); |
|
1076 |
+ _this.editor.selection.insertNode($('<br/>')); |
|
1077 |
+ _this.editor.selection.setRangeBefore($br); |
|
1078 |
+ } else { |
|
1079 |
+ _this.editor.selection.insertNode($br); |
|
1080 |
+ } |
|
1081 |
+ return true; |
|
1082 |
+ }; |
|
1083 |
+ })(this)); |
|
1084 |
+ } |
|
1085 |
+ if (this.editor.util.browser.webkit || this.editor.util.browser.msie) { |
|
1086 |
+ titleEnterHandler = (function(_this) { |
|
1087 |
+ return function(e, $node) { |
|
1088 |
+ var $p; |
|
1089 |
+ if (!_this.editor.selection.rangeAtEndOf($node)) { |
|
1090 |
+ return; |
|
1091 |
+ } |
|
1092 |
+ $p = $('<p/>').append(_this.editor.util.phBr).insertAfter($node); |
|
1093 |
+ _this.editor.selection.setRangeAtStartOf($p); |
|
1094 |
+ return true; |
|
1095 |
+ }; |
|
1096 |
+ })(this); |
|
1097 |
+ this.add('enter', 'h1', titleEnterHandler); |
|
1098 |
+ this.add('enter', 'h2', titleEnterHandler); |
|
1099 |
+ this.add('enter', 'h3', titleEnterHandler); |
|
1100 |
+ this.add('enter', 'h4', titleEnterHandler); |
|
1101 |
+ this.add('enter', 'h5', titleEnterHandler); |
|
1102 |
+ this.add('enter', 'h6', titleEnterHandler); |
|
1103 |
+ } |
|
1104 |
+ this.add('backspace', '*', (function(_this) { |
|
1105 |
+ return function(e) { |
|
1106 |
+ var $blockEl, $prevBlockEl, $rootBlock, isWebkit; |
|
1107 |
+ $rootBlock = _this.editor.selection.rootNodes().first(); |
|
1108 |
+ $prevBlockEl = $rootBlock.prev(); |
|
1109 |
+ if ($prevBlockEl.is('hr') && _this.editor.selection.rangeAtStartOf($rootBlock)) { |
|
1110 |
+ _this.editor.selection.save(); |
|
1111 |
+ $prevBlockEl.remove(); |
|
1112 |
+ _this.editor.selection.restore(); |
|
1113 |
+ return true; |
|
1114 |
+ } |
|
1115 |
+ $blockEl = _this.editor.selection.blockNodes().last(); |
|
1116 |
+ isWebkit = _this.editor.util.browser.webkit; |
|
1117 |
+ if (isWebkit && _this.editor.selection.rangeAtStartOf($blockEl)) { |
|
1118 |
+ _this.editor.selection.save(); |
|
1119 |
+ _this.editor.formatter.cleanNode($blockEl, true); |
|
1120 |
+ _this.editor.selection.restore(); |
|
1121 |
+ return null; |
|
1122 |
+ } |
|
1123 |
+ }; |
|
1124 |
+ })(this)); |
|
1125 |
+ this.add('enter', 'li', (function(_this) { |
|
1126 |
+ return function(e, $node) { |
|
1127 |
+ var $cloneNode, listEl, newBlockEl, newListEl; |
|
1128 |
+ $cloneNode = $node.clone(); |
|
1129 |
+ $cloneNode.find('ul, ol').remove(); |
|
1130 |
+ if (!(_this.editor.util.isEmptyNode($cloneNode) && $node.is(_this.editor.selection.blockNodes().last()))) { |
|
1131 |
+ return; |
|
1132 |
+ } |
|
1133 |
+ listEl = $node.parent(); |
|
1134 |
+ if ($node.next('li').length > 0) { |
|
1135 |
+ if (!_this.editor.util.isEmptyNode($node)) { |
|
1136 |
+ return; |
|
1137 |
+ } |
|
1138 |
+ if (listEl.parent('li').length > 0) { |
|
1139 |
+ newBlockEl = $('<li/>').append(_this.editor.util.phBr).insertAfter(listEl.parent('li')); |
|
1140 |
+ newListEl = $('<' + listEl[0].tagName + '/>').append($node.nextAll('li')); |
|
1141 |
+ newBlockEl.append(newListEl); |
|
1142 |
+ } else { |
|
1143 |
+ newBlockEl = $('<p/>').append(_this.editor.util.phBr).insertAfter(listEl); |
|
1144 |
+ newListEl = $('<' + listEl[0].tagName + '/>').append($node.nextAll('li')); |
|
1145 |
+ newBlockEl.after(newListEl); |
|
1146 |
+ } |
|
1147 |
+ } else { |
|
1148 |
+ if (listEl.parent('li').length > 0) { |
|
1149 |
+ newBlockEl = $('<li/>').insertAfter(listEl.parent('li')); |
|
1150 |
+ if ($node.contents().length > 0) { |
|
1151 |
+ newBlockEl.append($node.contents()); |
|
1152 |
+ } else { |
|
1153 |
+ newBlockEl.append(_this.editor.util.phBr); |
|
1154 |
+ } |
|
1155 |
+ } else { |
|
1156 |
+ newBlockEl = $('<p/>').append(_this.editor.util.phBr).insertAfter(listEl); |
|
1157 |
+ if ($node.children('ul, ol').length > 0) { |
|
1158 |
+ newBlockEl.after($node.children('ul, ol')); |
|
1159 |
+ } |
|
1160 |
+ } |
|
1161 |
+ } |
|
1162 |
+ if ($node.prev('li').length) { |
|
1163 |
+ $node.remove(); |
|
1164 |
+ } else { |
|
1165 |
+ listEl.remove(); |
|
1166 |
+ } |
|
1167 |
+ _this.editor.selection.setRangeAtStartOf(newBlockEl); |
|
1168 |
+ return true; |
|
1169 |
+ }; |
|
1170 |
+ })(this)); |
|
1171 |
+ this.add('enter', 'pre', (function(_this) { |
|
1172 |
+ return function(e, $node) { |
|
1173 |
+ var $p, breakNode, range; |
|
1174 |
+ e.preventDefault(); |
|
1175 |
+ if (e.shiftKey) { |
|
1176 |
+ $p = $('<p/>').append(_this.editor.util.phBr).insertAfter($node); |
|
1177 |
+ _this.editor.selection.setRangeAtStartOf($p); |
|
1178 |
+ return true; |
|
1179 |
+ } |
|
1180 |
+ range = _this.editor.selection.range(); |
|
1181 |
+ breakNode = null; |
|
1182 |
+ range.deleteContents(); |
|
1183 |
+ if (!_this.editor.util.browser.msie && _this.editor.selection.rangeAtEndOf($node)) { |
|
1184 |
+ breakNode = document.createTextNode('\n\n'); |
|
1185 |
+ range.insertNode(breakNode); |
|
1186 |
+ range.setEnd(breakNode, 1); |
|
1187 |
+ } else { |
|
1188 |
+ breakNode = document.createTextNode('\n'); |
|
1189 |
+ range.insertNode(breakNode); |
|
1190 |
+ range.setStartAfter(breakNode); |
|
1191 |
+ } |
|
1192 |
+ range.collapse(false); |
|
1193 |
+ _this.editor.selection.range(range); |
|
1194 |
+ return true; |
|
1195 |
+ }; |
|
1196 |
+ })(this)); |
|
1197 |
+ this.add('enter', 'blockquote', (function(_this) { |
|
1198 |
+ return function(e, $node) { |
|
1199 |
+ var $closestBlock, range; |
|
1200 |
+ $closestBlock = _this.editor.selection.blockNodes().last(); |
|
1201 |
+ if (!($closestBlock.is('p') && !$closestBlock.next().length && _this.editor.util.isEmptyNode($closestBlock))) { |
|
1202 |
+ return; |
|
1203 |
+ } |
|
1204 |
+ $node.after($closestBlock); |
|
1205 |
+ range = document.createRange(); |
|
1206 |
+ _this.editor.selection.setRangeAtStartOf($closestBlock, range); |
|
1207 |
+ return true; |
|
1208 |
+ }; |
|
1209 |
+ })(this)); |
|
1210 |
+ this.add('backspace', 'li', (function(_this) { |
|
1211 |
+ return function(e, $node) { |
|
1212 |
+ var $br, $childList, $newLi, $prevChildList, $prevNode, $textNode, isFF, range, text; |
|
1213 |
+ $childList = $node.children('ul, ol'); |
|
1214 |
+ $prevNode = $node.prev('li'); |
|
1215 |
+ if (!($childList.length > 0 && $prevNode.length > 0)) { |
|
1216 |
+ return false; |
|
1217 |
+ } |
|
1218 |
+ text = ''; |
|
1219 |
+ $textNode = null; |
|
1220 |
+ $node.contents().each(function(i, n) { |
|
1221 |
+ if (n.nodeType === 1 && /UL|OL/.test(n.nodeName)) { |
|
1222 |
+ return false; |
|
1223 |
+ } |
|
1224 |
+ if (n.nodeType === 1 && /BR/.test(n.nodeName)) { |
|
1225 |
+ return; |
|
1226 |
+ } |
|
1227 |
+ if (n.nodeType === 3 && n.nodeValue) { |
|
1228 |
+ text += n.nodeValue; |
|
1229 |
+ } else if (n.nodeType === 1) { |
|
1230 |
+ text += $(n).text(); |
|
1231 |
+ } |
|
1232 |
+ return $textNode = $(n); |
|
1233 |
+ }); |
|
1234 |
+ isFF = _this.editor.util.browser.firefox && !$textNode.next('br').length; |
|
1235 |
+ if ($textNode && text.length === 1 && isFF) { |
|
1236 |
+ $br = $(_this.editor.util.phBr).insertAfter($textNode); |
|
1237 |
+ $textNode.remove(); |
|
1238 |
+ _this.editor.selection.setRangeBefore($br); |
|
1239 |
+ return true; |
|
1240 |
+ } else if (text.length > 0) { |
|
1241 |
+ return false; |
|
1242 |
+ } |
|
1243 |
+ range = document.createRange(); |
|
1244 |
+ $prevChildList = $prevNode.children('ul, ol'); |
|
1245 |
+ if ($prevChildList.length > 0) { |
|
1246 |
+ $newLi = $('<li/>').append(_this.editor.util.phBr).appendTo($prevChildList); |
|
1247 |
+ $prevChildList.append($childList.children('li')); |
|
1248 |
+ $node.remove(); |
|
1249 |
+ _this.editor.selection.setRangeAtEndOf($newLi, range); |
|
1250 |
+ } else { |
|
1251 |
+ _this.editor.selection.setRangeAtEndOf($prevNode, range); |
|
1252 |
+ $prevNode.append($childList); |
|
1253 |
+ $node.remove(); |
|
1254 |
+ _this.editor.selection.range(range); |
|
1255 |
+ } |
|
1256 |
+ return true; |
|
1257 |
+ }; |
|
1258 |
+ })(this)); |
|
1259 |
+ this.add('backspace', 'pre', (function(_this) { |
|
1260 |
+ return function(e, $node) { |
|
1261 |
+ var $newNode, codeStr, range; |
|
1262 |
+ if (!_this.editor.selection.rangeAtStartOf($node)) { |
|
1263 |
+ return; |
|
1264 |
+ } |
|
1265 |
+ codeStr = $node.html().replace('\n', '<br/>') || _this.editor.util.phBr; |
|
1266 |
+ $newNode = $('<p/>').append(codeStr).insertAfter($node); |
|
1267 |
+ $node.remove(); |
|
1268 |
+ range = document.createRange(); |
|
1269 |
+ _this.editor.selection.setRangeAtStartOf($newNode, range); |
|
1270 |
+ return true; |
|
1271 |
+ }; |
|
1272 |
+ })(this)); |
|
1273 |
+ return this.add('backspace', 'blockquote', (function(_this) { |
|
1274 |
+ return function(e, $node) { |
|
1275 |
+ var $firstChild, range; |
|
1276 |
+ if (!_this.editor.selection.rangeAtStartOf($node)) { |
|
1277 |
+ return; |
|
1278 |
+ } |
|
1279 |
+ $firstChild = $node.children().first().unwrap(); |
|
1280 |
+ range = document.createRange(); |
|
1281 |
+ _this.editor.selection.setRangeAtStartOf($firstChild, range); |
|
1282 |
+ return true; |
|
1283 |
+ }; |
|
1284 |
+ })(this)); |
|
1285 |
+ }; |
|
1286 |
+ |
|
1287 |
+ return Keystroke; |
|
1288 |
+ |
|
1289 |
+})(SimpleModule); |
|
1290 |
+ |
|
1291 |
+UndoManager = (function(superClass) { |
|
1292 |
+ extend(UndoManager, superClass); |
|
1293 |
+ |
|
1294 |
+ function UndoManager() { |
|
1295 |
+ return UndoManager.__super__.constructor.apply(this, arguments); |
|
1296 |
+ } |
|
1297 |
+ |
|
1298 |
+ UndoManager.pluginName = 'UndoManager'; |
|
1299 |
+ |
|
1300 |
+ UndoManager.prototype._index = -1; |
|
1301 |
+ |
|
1302 |
+ UndoManager.prototype._capacity = 20; |
|
1303 |
+ |
|
1304 |
+ UndoManager.prototype._startPosition = null; |
|
1305 |
+ |
|
1306 |
+ UndoManager.prototype._endPosition = null; |
|
1307 |
+ |
|
1308 |
+ UndoManager.prototype._init = function() { |
|
1309 |
+ var redoShortcut, undoShortcut; |
|
1310 |
+ this.editor = this._module; |
|
1311 |
+ this._stack = []; |
|
1312 |
+ if (this.editor.util.os.mac) { |
|
1313 |
+ undoShortcut = 'cmd+z'; |
|
1314 |
+ redoShortcut = 'shift+cmd+z'; |
|
1315 |
+ } else if (this.editor.util.os.win) { |
|
1316 |
+ undoShortcut = 'ctrl+z'; |
|
1317 |
+ redoShortcut = 'ctrl+y'; |
|
1318 |
+ } else { |
|
1319 |
+ undoShortcut = 'ctrl+z'; |
|
1320 |
+ redoShortcut = 'shift+ctrl+z'; |
|
1321 |
+ } |
|
1322 |
+ this.editor.hotkeys.add(undoShortcut, (function(_this) { |
|
1323 |
+ return function(e) { |
|
1324 |
+ e.preventDefault(); |
|
1325 |
+ _this.undo(); |
|
1326 |
+ return false; |
|
1327 |
+ }; |
|
1328 |
+ })(this)); |
|
1329 |
+ this.editor.hotkeys.add(redoShortcut, (function(_this) { |
|
1330 |
+ return function(e) { |
|
1331 |
+ e.preventDefault(); |
|
1332 |
+ _this.redo(); |
|
1333 |
+ return false; |
|
1334 |
+ }; |
|
1335 |
+ })(this)); |
|
1336 |
+ this.throttledPushState = this.editor.util.throttle((function(_this) { |
|
1337 |
+ return function() { |
|
1338 |
+ return _this._pushUndoState(); |
|
1339 |
+ }; |
|
1340 |
+ })(this), 2000); |
|
1341 |
+ this.editor.on('valuechanged', (function(_this) { |
|
1342 |
+ return function(e, src) { |
|
1343 |
+ if (src === 'undo' || src === 'redo') { |
|
1344 |
+ return; |
|
1345 |
+ } |
|
1346 |
+ return _this.throttledPushState(); |
|
1347 |
+ }; |
|
1348 |
+ })(this)); |
|
1349 |
+ this.editor.on('selectionchanged', (function(_this) { |
|
1350 |
+ return function(e) { |
|
1351 |
+ _this.resetCaretPosition(); |
|
1352 |
+ return _this.update(); |
|
1353 |
+ }; |
|
1354 |
+ })(this)); |
|
1355 |
+ this.editor.on('focus', (function(_this) { |
|
1356 |
+ return function(e) { |
|
1357 |
+ if (_this._stack.length === 0) { |
|
1358 |
+ return _this._pushUndoState(); |
|
1359 |
+ } |
|
1360 |
+ }; |
|
1361 |
+ })(this)); |
|
1362 |
+ return this.editor.on('blur', (function(_this) { |
|
1363 |
+ return function(e) { |
|
1364 |
+ return _this.resetCaretPosition(); |
|
1365 |
+ }; |
|
1366 |
+ })(this)); |
|
1367 |
+ }; |
|
1368 |
+ |
|
1369 |
+ UndoManager.prototype.resetCaretPosition = function() { |
|
1370 |
+ this._startPosition = null; |
|
1371 |
+ return this._endPosition = null; |
|
1372 |
+ }; |
|
1373 |
+ |
|
1374 |
+ UndoManager.prototype.startPosition = function() { |
|
1375 |
+ if (this.editor.selection._range) { |
|
1376 |
+ this._startPosition || (this._startPosition = this._getPosition('start')); |
|
1377 |
+ } |
|
1378 |
+ return this._startPosition; |
|
1379 |
+ }; |
|
1380 |
+ |
|
1381 |
+ UndoManager.prototype.endPosition = function() { |
|
1382 |
+ if (this.editor.selection._range) { |
|
1383 |
+ this._endPosition || (this._endPosition = (function(_this) { |
|
1384 |
+ return function() { |
|
1385 |
+ var range; |
|
1386 |
+ range = _this.editor.selection.range(); |
|
1387 |
+ if (range.collapsed) { |
|
1388 |
+ return _this._startPosition; |
|
1389 |
+ } |
|
1390 |
+ return _this._getPosition('end'); |
|
1391 |
+ }; |
|
1392 |
+ })(this)()); |
|
1393 |
+ } |
|
1394 |
+ return this._endPosition; |
|
1395 |
+ }; |
|
1396 |
+ |
|
1397 |
+ UndoManager.prototype._pushUndoState = function() { |
|
1398 |
+ var caret; |
|
1399 |
+ if (this.editor.triggerHandler('pushundostate') === false) { |
|
1400 |
+ return; |
|
1401 |
+ } |
|
1402 |
+ caret = this.caretPosition(); |
|
1403 |
+ if (!caret.start) { |
|
1404 |
+ return; |
|
1405 |
+ } |
|
1406 |
+ this._index += 1; |
|
1407 |
+ this._stack.length = this._index; |
|
1408 |
+ this._stack.push({ |
|
1409 |
+ html: this.editor.body.html(), |
|
1410 |
+ caret: this.caretPosition() |
|
1411 |
+ }); |
|
1412 |
+ if (this._stack.length > this._capacity) { |
|
1413 |
+ this._stack.shift(); |
|
1414 |
+ return this._index -= 1; |
|
1415 |
+ } |
|
1416 |
+ }; |
|
1417 |
+ |
|
1418 |
+ UndoManager.prototype.currentState = function() { |
|
1419 |
+ if (this._stack.length && this._index > -1) { |
|
1420 |
+ return this._stack[this._index]; |
|
1421 |
+ } else { |
|
1422 |
+ return null; |
|
1423 |
+ } |
|
1424 |
+ }; |
|
1425 |
+ |
|
1426 |
+ UndoManager.prototype.undo = function() { |
|
1427 |
+ var state; |
|
1428 |
+ if (this._index < 1 || this._stack.length < 2) { |
|
1429 |
+ return; |
|
1430 |
+ } |
|
1431 |
+ this.editor.hidePopover(); |
|
1432 |
+ this._index -= 1; |
|
1433 |
+ state = this._stack[this._index]; |
|
1434 |
+ this.editor.body.get(0).innerHTML = state.html; |
|
1435 |
+ this.caretPosition(state.caret); |
|
1436 |
+ this.editor.body.find('.selected').removeClass('selected'); |
|
1437 |
+ this.editor.sync(); |
|
1438 |
+ return this.editor.trigger('valuechanged', ['undo']); |
|
1439 |
+ }; |
|
1440 |
+ |
|
1441 |
+ UndoManager.prototype.redo = function() { |
|
1442 |
+ var state; |
|
1443 |
+ if (this._index < 0 || this._stack.length < this._index + 2) { |
|
1444 |
+ return; |
|
1445 |
+ } |
|
1446 |
+ this.editor.hidePopover(); |
|
1447 |
+ this._index += 1; |
|
1448 |
+ state = this._stack[this._index]; |
|
1449 |
+ this.editor.body.get(0).innerHTML = state.html; |
|
1450 |
+ this.caretPosition(state.caret); |
|
1451 |
+ this.editor.body.find('.selected').removeClass('selected'); |
|
1452 |
+ this.editor.sync(); |
|
1453 |
+ return this.editor.trigger('valuechanged', ['redo']); |
|
1454 |
+ }; |
|
1455 |
+ |
|
1456 |
+ UndoManager.prototype.update = function() { |
|
1457 |
+ var currentState; |
|
1458 |
+ currentState = this.currentState(); |
|
1459 |
+ if (!currentState) { |
|
1460 |
+ return; |
|
1461 |
+ } |
|
1462 |
+ currentState.html = this.editor.body.html(); |
|
1463 |
+ return currentState.caret = this.caretPosition(); |
|
1464 |
+ }; |
|
1465 |
+ |
|
1466 |
+ UndoManager.prototype._getNodeOffset = function(node, index) { |
|
1467 |
+ var $parent, merging, offset; |
|
1468 |
+ if ($.isNumeric(index)) { |
|
1469 |
+ $parent = $(node); |
|
1470 |
+ } else { |
|
1471 |
+ $parent = $(node).parent(); |
|
1472 |
+ } |
|
1473 |
+ offset = 0; |
|
1474 |
+ merging = false; |
|
1475 |
+ $parent.contents().each(function(i, child) { |
|
1476 |
+ if (node === child || (index === i && i === 0)) { |
|
1477 |
+ return false; |
|
1478 |
+ } |
|
1479 |
+ if (child.nodeType === Node.TEXT_NODE) { |
|
1480 |
+ if (!merging && child.nodeValue.length > 0) { |
|
1481 |
+ offset += 1; |
|
1482 |
+ merging = true; |
|
1483 |
+ } |
|
1484 |
+ } else { |
|
1485 |
+ offset += 1; |
|
1486 |
+ merging = false; |
|
1487 |
+ } |
|
1488 |
+ if (index - 1 === i) { |
|
1489 |
+ return false; |
|
1490 |
+ } |
|
1491 |
+ return null; |
|
1492 |
+ }); |
|
1493 |
+ return offset; |
|
1494 |
+ }; |
|
1495 |
+ |
|
1496 |
+ UndoManager.prototype._getPosition = function(type) { |
|
1497 |
+ var $nodes, node, nodes, offset, position, prevNode, range; |
|
1498 |
+ if (type == null) { |
|
1499 |
+ type = 'start'; |
|
1500 |
+ } |
|
1501 |
+ range = this.editor.selection.range(); |
|
1502 |
+ offset = range[type + "Offset"]; |
|
1503 |
+ $nodes = this.editor.selection[type + "Nodes"](); |
|
1504 |
+ node = $nodes.first()[0]; |
|
1505 |
+ if (node.nodeType === Node.TEXT_NODE) { |
|
1506 |
+ prevNode = node.previousSibling; |
|
1507 |
+ while (prevNode && prevNode.nodeType === Node.TEXT_NODE) { |
|
1508 |
+ node = prevNode; |
|
1509 |
+ offset += this.editor.util.getNodeLength(prevNode); |
|
1510 |
+ prevNode = prevNode.previousSibling; |
|
1511 |
+ } |
|
1512 |
+ nodes = $nodes.get(); |
|
1513 |
+ nodes[0] = node; |
|
1514 |
+ $nodes = $(nodes); |
|
1515 |
+ } else { |
|
1516 |
+ offset = this._getNodeOffset(node, offset); |
|
1517 |
+ } |
|
1518 |
+ position = [offset]; |
|
1519 |
+ $nodes.each((function(_this) { |
|
1520 |
+ return function(i, node) { |
|
1521 |
+ return position.unshift(_this._getNodeOffset(node)); |
|
1522 |
+ }; |
|
1523 |
+ })(this)); |
|
1524 |
+ return position; |
|
1525 |
+ }; |
|
1526 |
+ |
|
1527 |
+ UndoManager.prototype._getNodeByPosition = function(position) { |
|
1528 |
+ var child, childNodes, i, k, len, node, offset, ref; |
|
1529 |
+ node = this.editor.body[0]; |
|
1530 |
+ ref = position.slice(0, position.length - 1); |
|
1531 |
+ for (i = k = 0, len = ref.length; k < len; i = ++k) { |
|
1532 |
+ offset = ref[i]; |
|
1533 |
+ childNodes = node.childNodes; |
|
1534 |
+ if (offset > childNodes.length - 1) { |
|
1535 |
+ if (i === position.length - 2 && $(node).is('pre:empty')) { |
|
1536 |
+ child = document.createTextNode(''); |
|
1537 |
+ node.appendChild(child); |
|
1538 |
+ childNodes = node.childNodes; |
|
1539 |
+ } else { |
|
1540 |
+ node = null; |
|
1541 |
+ break; |
|
1542 |
+ } |
|
1543 |
+ } |
|
1544 |
+ node = childNodes[offset]; |
|
1545 |
+ } |
|
1546 |
+ return node; |
|
1547 |
+ }; |
|
1548 |
+ |
|
1549 |
+ UndoManager.prototype.caretPosition = function(caret) { |
|
1550 |
+ var endContainer, endOffset, range, startContainer, startOffset; |
|
1551 |
+ if (!caret) { |
|
1552 |
+ range = this.editor.selection.range(); |
|
1553 |
+ caret = this.editor.inputManager.focused && (range != null) ? { |
|
1554 |
+ start: this.startPosition(), |
|
1555 |
+ end: this.endPosition(), |
|
1556 |
+ collapsed: range.collapsed |
|
1557 |
+ } : {}; |
|
1558 |
+ return caret; |
|
1559 |
+ } else { |
|
1560 |
+ if (!caret.start) { |
|
1561 |
+ return; |
|
1562 |
+ } |
|
1563 |
+ startContainer = this._getNodeByPosition(caret.start); |
|
1564 |
+ startOffset = caret.start[caret.start.length - 1]; |
|
1565 |
+ if (caret.collapsed) { |
|
1566 |
+ endContainer = startContainer; |
|
1567 |
+ endOffset = startOffset; |
|
1568 |
+ } else { |
|
1569 |
+ endContainer = this._getNodeByPosition(caret.end); |
|
1570 |
+ endOffset = caret.start[caret.start.length - 1]; |
|
1571 |
+ } |
|
1572 |
+ if (!startContainer || !endContainer) { |
|
1573 |
+ if (typeof console !== "undefined" && console !== null) { |
|
1574 |
+ if (typeof console.warn === "function") { |
|
1575 |
+ console.warn('simditor: invalid caret state'); |
|
1576 |
+ } |
|
1577 |
+ } |
|
1578 |
+ return; |
|
1579 |
+ } |
|
1580 |
+ range = document.createRange(); |
|
1581 |
+ range.setStart(startContainer, startOffset); |
|
1582 |
+ range.setEnd(endContainer, endOffset); |
|
1583 |
+ return this.editor.selection.range(range); |
|
1584 |
+ } |
|
1585 |
+ }; |
|
1586 |
+ |
|
1587 |
+ return UndoManager; |
|
1588 |
+ |
|
1589 |
+})(SimpleModule); |
|
1590 |
+ |
|
1591 |
+Util = (function(superClass) { |
|
1592 |
+ extend(Util, superClass); |
|
1593 |
+ |
|
1594 |
+ function Util() { |
|
1595 |
+ return Util.__super__.constructor.apply(this, arguments); |
|
1596 |
+ } |
|
1597 |
+ |
|
1598 |
+ Util.pluginName = 'Util'; |
|
1599 |
+ |
|
1600 |
+ Util.prototype._init = function() { |
|
1601 |
+ this.editor = this._module; |
|
1602 |
+ if (this.browser.msie && this.browser.version < 11) { |
|
1603 |
+ return this.phBr = ''; |
|
1604 |
+ } |
|
1605 |
+ }; |
|
1606 |
+ |
|
1607 |
+ Util.prototype.phBr = '<br/>'; |
|
1608 |
+ |
|
1609 |
+ Util.prototype.os = (function() { |
|
1610 |
+ var os; |
|
1611 |
+ os = {}; |
|
1612 |
+ if (/Mac/.test(navigator.appVersion)) { |
|
1613 |
+ os.mac = true; |
|
1614 |
+ } else if (/Linux/.test(navigator.appVersion)) { |
|
1615 |
+ os.linux = true; |
|
1616 |
+ } else if (/Win/.test(navigator.appVersion)) { |
|
1617 |
+ os.win = true; |
|
1618 |
+ } else if (/X11/.test(navigator.appVersion)) { |
|
1619 |
+ os.unix = true; |
|
1620 |
+ } |
|
1621 |
+ if (/Mobi/.test(navigator.appVersion)) { |
|
1622 |
+ os.mobile = true; |
|
1623 |
+ } |
|
1624 |
+ return os; |
|
1625 |
+ })(); |
|
1626 |
+ |
|
1627 |
+ Util.prototype.browser = (function() { |
|
1628 |
+ var chrome, edge, firefox, ie, ref, ref1, ref2, ref3, ref4, safari, ua; |
|
1629 |
+ ua = navigator.userAgent; |
|
1630 |
+ ie = /(msie|trident)/i.test(ua); |
|
1631 |
+ chrome = /chrome|crios/i.test(ua); |
|
1632 |
+ safari = /safari/i.test(ua) && !chrome; |
|
1633 |
+ firefox = /firefox/i.test(ua); |
|
1634 |
+ edge = /edge/i.test(ua); |
|
1635 |
+ if (ie) { |
|
1636 |
+ return { |
|
1637 |
+ msie: true, |
|
1638 |
+ version: ((ref = ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)) != null ? ref[2] : void 0) * 1 |
|
1639 |
+ }; |
|
1640 |
+ } else if (edge) { |
|
1641 |
+ return { |
|
1642 |
+ edge: true, |
|
1643 |
+ webkit: true, |
|
1644 |
+ version: ((ref1 = ua.match(/edge\/(\d+(\.\d+)?)/i)) != null ? ref1[1] : void 0) * 1 |
|
1645 |
+ }; |
|
1646 |
+ } else if (chrome) { |
|
1647 |
+ return { |
|
1648 |
+ webkit: true, |
|
1649 |
+ chrome: true, |
|
1650 |
+ version: ((ref2 = ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)) != null ? ref2[1] : void 0) * 1 |
|
1651 |
+ }; |
|
1652 |
+ } else if (safari) { |
|
1653 |
+ return { |
|
1654 |
+ webkit: true, |
|
1655 |
+ safari: true, |
|
1656 |
+ version: ((ref3 = ua.match(/version\/(\d+(\.\d+)?)/i)) != null ? ref3[1] : void 0) * 1 |
|
1657 |
+ }; |
|
1658 |
+ } else if (firefox) { |
|
1659 |
+ return { |
|
1660 |
+ mozilla: true, |
|
1661 |
+ firefox: true, |
|
1662 |
+ version: ((ref4 = ua.match(/firefox\/(\d+(\.\d+)?)/i)) != null ? ref4[1] : void 0) * 1 |
|
1663 |
+ }; |
|
1664 |
+ } else { |
|
1665 |
+ return {}; |
|
1666 |
+ } |
|
1667 |
+ })(); |
|
1668 |
+ |
|
1669 |
+ Util.prototype.support = (function() { |
|
1670 |
+ return { |
|
1671 |
+ onselectionchange: (function() { |
|
1672 |
+ var e, onselectionchange; |
|
1673 |
+ onselectionchange = document.onselectionchange; |
|
1674 |
+ if (onselectionchange !== void 0) { |
|
1675 |
+ try { |
|
1676 |
+ document.onselectionchange = 0; |
|
1677 |
+ return document.onselectionchange === null; |
|
1678 |
+ } catch (_error) { |
|
1679 |
+ e = _error; |
|
1680 |
+ } finally { |
|
1681 |
+ document.onselectionchange = onselectionchange; |
|
1682 |
+ } |
|
1683 |
+ } |
|
1684 |
+ return false; |
|
1685 |
+ })(), |
|
1686 |
+ oninput: (function() { |
|
1687 |
+ return !/(msie|trident)/i.test(navigator.userAgent); |
|
1688 |
+ })() |
|
1689 |
+ }; |
|
1690 |
+ })(); |
|
1691 |
+ |
|
1692 |
+ Util.prototype.reflow = function(el) { |
|
1693 |
+ if (el == null) { |
|
1694 |
+ el = document; |
|
1695 |
+ } |
|
1696 |
+ return $(el)[0].offsetHeight; |
|
1697 |
+ }; |
|
1698 |
+ |
|
1699 |
+ Util.prototype.metaKey = function(e) { |
|
1700 |
+ var isMac; |
|
1701 |
+ isMac = /Mac/.test(navigator.userAgent); |
|
1702 |
+ if (isMac) { |
|
1703 |
+ return e.metaKey; |
|
1704 |
+ } else { |
|
1705 |
+ return e.ctrlKey; |
|
1706 |
+ } |
|
1707 |
+ }; |
|
1708 |
+ |
|
1709 |
+ Util.prototype.isEmptyNode = function(node) { |
|
1710 |
+ var $node; |
|
1711 |
+ $node = $(node); |
|
1712 |
+ return $node.is(':empty') || (!$node.text() && !$node.find(':not(br, span, div)').length); |
|
1713 |
+ }; |
|
1714 |
+ |
|
1715 |
+ Util.prototype.isDecoratedNode = function(node) { |
|
1716 |
+ return $(node).is('[class^="simditor-"]'); |
|
1717 |
+ }; |
|
1718 |
+ |
|
1719 |
+ Util.prototype.blockNodes = ["div", "p", "ul", "ol", "li", "blockquote", "hr", "pre", "h1", "h2", "h3", "h4", "h5", "table"]; |
|
1720 |
+ |
|
1721 |
+ Util.prototype.isBlockNode = function(node) { |
|
1722 |
+ node = $(node)[0]; |
|
1723 |
+ if (!node || node.nodeType === 3) { |
|
1724 |
+ return false; |
|
1725 |
+ } |
|
1726 |
+ return new RegExp("^(" + (this.blockNodes.join('|')) + ")$").test(node.nodeName.toLowerCase()); |
|
1727 |
+ }; |
|
1728 |
+ |
|
1729 |
+ Util.prototype.getNodeLength = function(node) { |
|
1730 |
+ node = $(node)[0]; |
|
1731 |
+ switch (node.nodeType) { |
|
1732 |
+ case 7: |
|
1733 |
+ case 10: |
|
1734 |
+ return 0; |
|
1735 |
+ case 3: |
|
1736 |
+ case 8: |
|
1737 |
+ return node.length; |
|
1738 |
+ default: |
|
1739 |
+ return node.childNodes.length; |
|
1740 |
+ } |
|
1741 |
+ }; |
|
1742 |
+ |
|
1743 |
+ Util.prototype.dataURLtoBlob = function(dataURL) { |
|
1744 |
+ var BlobBuilder, arrayBuffer, bb, blobArray, byteString, hasArrayBufferViewSupport, hasBlobConstructor, i, intArray, k, mimeString, ref, supportBlob; |
|
1745 |
+ hasBlobConstructor = window.Blob && (function() { |
|
1746 |
+ var e; |
|
1747 |
+ try { |
|
1748 |
+ return Boolean(new Blob()); |
|
1749 |
+ } catch (_error) { |
|
1750 |
+ e = _error; |
|
1751 |
+ return false; |
|
1752 |
+ } |
|
1753 |
+ })(); |
|
1754 |
+ hasArrayBufferViewSupport = hasBlobConstructor && window.Uint8Array && (function() { |
|
1755 |
+ var e; |
|
1756 |
+ try { |
|
1757 |
+ return new Blob([new Uint8Array(100)]).size === 100; |
|
1758 |
+ } catch (_error) { |
|
1759 |
+ e = _error; |
|
1760 |
+ return false; |
|
1761 |
+ } |
|
1762 |
+ })(); |
|
1763 |
+ BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder; |
|
1764 |
+ supportBlob = hasBlobConstructor || BlobBuilder; |
|
1765 |
+ if (!(supportBlob && window.atob && window.ArrayBuffer && window.Uint8Array)) { |
|
1766 |
+ return false; |
|
1767 |
+ } |
|
1768 |
+ if (dataURL.split(',')[0].indexOf('base64') >= 0) { |
|
1769 |
+ byteString = atob(dataURL.split(',')[1]); |
|
1770 |
+ } else { |
|
1771 |
+ byteString = decodeURIComponent(dataURL.split(',')[1]); |
|
1772 |
+ } |
|
1773 |
+ arrayBuffer = new ArrayBuffer(byteString.length); |
|
1774 |
+ intArray = new Uint8Array(arrayBuffer); |
|
1775 |
+ for (i = k = 0, ref = byteString.length; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) { |
|
1776 |
+ intArray[i] = byteString.charCodeAt(i); |
|
1777 |
+ } |
|
1778 |
+ mimeString = dataURL.split(',')[0].split(':')[1].split(';')[0]; |
|
1779 |
+ if (hasBlobConstructor) { |
|
1780 |
+ blobArray = hasArrayBufferViewSupport ? intArray : arrayBuffer; |
|
1781 |
+ return new Blob([blobArray], { |
|
1782 |
+ type: mimeString |
|
1783 |
+ }); |
|
1784 |
+ } |
|
1785 |
+ bb = new BlobBuilder(); |
|
1786 |
+ bb.append(arrayBuffer); |
|
1787 |
+ return bb.getBlob(mimeString); |
|
1788 |
+ }; |
|
1789 |
+ |
|
1790 |
+ Util.prototype.throttle = function(func, wait) { |
|
1791 |
+ var args, call, ctx, last, rtn, throttled, timeoutID; |
|
1792 |
+ last = 0; |
|
1793 |
+ timeoutID = 0; |
|
1794 |
+ ctx = args = rtn = null; |
|
1795 |
+ call = function() { |
|
1796 |
+ timeoutID = 0; |
|
1797 |
+ last = +new Date(); |
|
1798 |
+ rtn = func.apply(ctx, args); |
|
1799 |
+ ctx = null; |
|
1800 |
+ return args = null; |
|
1801 |
+ }; |
|
1802 |
+ throttled = function() { |
|
1803 |
+ var delta; |
|
1804 |
+ ctx = this; |
|
1805 |
+ args = arguments; |
|
1806 |
+ delta = new Date() - last; |
|
1807 |
+ if (!timeoutID) { |
|
1808 |
+ if (delta >= wait) { |
|
1809 |
+ call(); |
|
1810 |
+ } else { |
|
1811 |
+ timeoutID = setTimeout(call, wait - delta); |
|
1812 |
+ } |
|
1813 |
+ } |
|
1814 |
+ return rtn; |
|
1815 |
+ }; |
|
1816 |
+ throttled.clear = function() { |
|
1817 |
+ if (!timeoutID) { |
|
1818 |
+ return; |
|
1819 |
+ } |
|
1820 |
+ clearTimeout(timeoutID); |
|
1821 |
+ return call(); |
|
1822 |
+ }; |
|
1823 |
+ return throttled; |
|
1824 |
+ }; |
|
1825 |
+ |
|
1826 |
+ Util.prototype.formatHTML = function(html) { |
|
1827 |
+ var cursor, indentString, lastMatch, level, match, re, repeatString, result, str; |
|
1828 |
+ re = /<(\/?)(.+?)(\/?)>/g; |
|
1829 |
+ result = ''; |
|
1830 |
+ level = 0; |
|
1831 |
+ lastMatch = null; |
|
1832 |
+ indentString = ' '; |
|
1833 |
+ repeatString = function(str, n) { |
|
1834 |
+ return new Array(n + 1).join(str); |
|
1835 |
+ }; |
|
1836 |
+ while ((match = re.exec(html)) !== null) { |
|
1837 |
+ match.isBlockNode = $.inArray(match[2], this.blockNodes) > -1; |
|
1838 |
+ match.isStartTag = match[1] !== '/' && match[3] !== '/'; |
|
1839 |
+ match.isEndTag = match[1] === '/' || match[3] === '/'; |
|
1840 |
+ cursor = lastMatch ? lastMatch.index + lastMatch[0].length : 0; |
|
1841 |
+ if ((str = html.substring(cursor, match.index)).length > 0 && $.trim(str)) { |
|
1842 |
+ result += str; |
|
1843 |
+ } |
|
1844 |
+ if (match.isBlockNode && match.isEndTag && !match.isStartTag) { |
|
1845 |
+ level -= 1; |
|
1846 |
+ } |
|
1847 |
+ if (match.isBlockNode && match.isStartTag) { |
|
1848 |
+ if (!(lastMatch && lastMatch.isBlockNode && lastMatch.isEndTag)) { |
|
1849 |
+ result += '\n'; |
|
1850 |
+ } |
|
1851 |
+ result += repeatString(indentString, level); |
|
1852 |
+ } |
|
1853 |
+ result += match[0]; |
|
1854 |
+ if (match.isBlockNode && match.isEndTag) { |
|
1855 |
+ result += '\n'; |
|
1856 |
+ } |
|
1857 |
+ if (match.isBlockNode && match.isStartTag) { |
|
1858 |
+ level += 1; |
|
1859 |
+ } |
|
1860 |
+ lastMatch = match; |
|
1861 |
+ } |
|
1862 |
+ return $.trim(result); |
|
1863 |
+ }; |
|
1864 |
+ |
|
1865 |
+ return Util; |
|
1866 |
+ |
|
1867 |
+})(SimpleModule); |
|
1868 |
+ |
|
1869 |
+Toolbar = (function(superClass) { |
|
1870 |
+ extend(Toolbar, superClass); |
|
1871 |
+ |
|
1872 |
+ function Toolbar() { |
|
1873 |
+ return Toolbar.__super__.constructor.apply(this, arguments); |
|
1874 |
+ } |
|
1875 |
+ |
|
1876 |
+ Toolbar.pluginName = 'Toolbar'; |
|
1877 |
+ |
|
1878 |
+ Toolbar.prototype.opts = { |
|
1879 |
+ toolbar: true, |
|
1880 |
+ toolbarFloat: true, |
|
1881 |
+ toolbarHidden: false, |
|
1882 |
+ toolbarFloatOffset: 0 |
|
1883 |
+ }; |
|
1884 |
+ |
|
1885 |
+ Toolbar.prototype._tpl = { |
|
1886 |
+ wrapper: '<div class="simditor-toolbar"><ul></ul></div>', |
|
1887 |
+ separator: '<li><span class="separator"></span></li>' |
|
1888 |
+ }; |
|
1889 |
+ |
|
1890 |
+ Toolbar.prototype._init = function() { |
|
1891 |
+ var floatInitialized, initToolbarFloat, toolbarHeight; |
|
1892 |
+ this.editor = this._module; |
|
1893 |
+ if (!this.opts.toolbar) { |
|
1894 |
+ return; |
|
1895 |
+ } |
|
1896 |
+ if (!$.isArray(this.opts.toolbar)) { |
|
1897 |
+ this.opts.toolbar = ['bold', 'italic', 'underline', 'strikethrough', '|', 'ol', 'ul', 'blockquote', 'code', '|', 'link', 'image', '|', 'indent', 'outdent']; |
|
1898 |
+ } |
|
1899 |
+ this._render(); |
|
1900 |
+ this.list.on('click', function(e) { |
|
1901 |
+ return false; |
|
1902 |
+ }); |
|
1903 |
+ this.wrapper.on('mousedown', (function(_this) { |
|
1904 |
+ return function(e) { |
|
1905 |
+ return _this.list.find('.menu-on').removeClass('.menu-on'); |
|
1906 |
+ }; |
|
1907 |
+ })(this)); |
|
1908 |
+ $(document).on('mousedown.simditor' + this.editor.id, (function(_this) { |
|
1909 |
+ return function(e) { |
|
1910 |
+ return _this.list.find('.menu-on').removeClass('.menu-on'); |
|
1911 |
+ }; |
|
1912 |
+ })(this)); |
|
1913 |
+ if (!this.opts.toolbarHidden && this.opts.toolbarFloat) { |
|
1914 |
+ this.wrapper.css('top', this.opts.toolbarFloatOffset); |
|
1915 |
+ toolbarHeight = 0; |
|
1916 |
+ initToolbarFloat = (function(_this) { |
|
1917 |
+ return function() { |
|
1918 |
+ _this.wrapper.css('position', 'static'); |
|
1919 |
+ _this.wrapper.width('auto'); |
|
1920 |
+ _this.editor.util.reflow(_this.wrapper); |
|
1921 |
+ _this.wrapper.width(_this.wrapper.outerWidth()); |
|
1922 |
+ _this.wrapper.css('left', _this.editor.util.os.mobile ? _this.wrapper.position().left : _this.wrapper.offset().left); |
|
1923 |
+ _this.wrapper.css('position', ''); |
|
1924 |
+ |
|
1925 |
+ _this.editor.wrapper.width(_this.wrapper.outerWidth()); |
|
1926 |
+ |
|
1927 |
+ toolbarHeight = _this.wrapper.outerHeight(); |
|
1928 |
+ _this.editor.placeholderEl.css('top', toolbarHeight); |
|
1929 |
+ return true; |
|
1930 |
+ }; |
|
1931 |
+ })(this); |
|
1932 |
+ floatInitialized = null; |
|
1933 |
+ $(window).on('resize.simditor-' + this.editor.id, function(e) { |
|
1934 |
+ return floatInitialized = initToolbarFloat(); |
|
1935 |
+ }); |
|
1936 |
+ $(window).on('scroll.simditor-' + this.editor.id, (function(_this) { |
|
1937 |
+ return function(e) { |
|
1938 |
+ var bottomEdge, scrollTop, topEdge; |
|
1939 |
+ if (!_this.wrapper.is(':visible')) { |
|
1940 |
+ return; |
|
1941 |
+ } |
|
1942 |
+ topEdge = _this.editor.wrapper.offset().top; |
|
1943 |
+ bottomEdge = topEdge + _this.editor.wrapper.outerHeight() - 80; |
|
1944 |
+ scrollTop = $(document).scrollTop() + _this.opts.toolbarFloatOffset; |
|
1945 |
+ if (scrollTop <= topEdge || scrollTop >= bottomEdge) { |
|
1946 |
+ _this.editor.wrapper.removeClass('toolbar-floating').css('padding-top', ''); |
|
1947 |
+ if (_this.editor.util.os.mobile) { |
|
1948 |
+ return _this.wrapper.css('top', _this.opts.toolbarFloatOffset); |
|
1949 |
+ } |
|
1950 |
+ } else { |
|
1951 |
+ floatInitialized || (floatInitialized = initToolbarFloat()); |
|
1952 |
+ _this.editor.wrapper.addClass('toolbar-floating').css('padding-top', toolbarHeight); |
|
1953 |
+ if (_this.editor.util.os.mobile) { |
|
1954 |
+ return _this.wrapper.css('top', scrollTop - topEdge + _this.opts.toolbarFloatOffset); |
|
1955 |
+ } |
|
1956 |
+ } |
|
1957 |
+ }; |
|
1958 |
+ })(this)); |
|
1959 |
+ } |
|
1960 |
+ this.editor.on('destroy', (function(_this) { |
|
1961 |
+ return function() { |
|
1962 |
+ return _this.buttons.length = 0; |
|
1963 |
+ }; |
|
1964 |
+ })(this)); |
|
1965 |
+ return $(document).on("mousedown.simditor-" + this.editor.id, (function(_this) { |
|
1966 |
+ return function(e) { |
|
1967 |
+ return _this.list.find('li.menu-on').removeClass('menu-on'); |
|
1968 |
+ }; |
|
1969 |
+ })(this)); |
|
1970 |
+ }; |
|
1971 |
+ |
|
1972 |
+ Toolbar.prototype._render = function() { |
|
1973 |
+ var k, len, name, ref; |
|
1974 |
+ this.buttons = []; |
|
1975 |
+ this.wrapper = $(this._tpl.wrapper).prependTo(this.editor.wrapper); |
|
1976 |
+ this.list = this.wrapper.find('ul'); |
|
1977 |
+ ref = this.opts.toolbar; |
|
1978 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
1979 |
+ name = ref[k]; |
|
1980 |
+ if (name === '|') { |
|
1981 |
+ $(this._tpl.separator).appendTo(this.list); |
|
1982 |
+ continue; |
|
1983 |
+ } |
|
1984 |
+ if (!this.constructor.buttons[name]) { |
|
1985 |
+ throw new Error("simditor: invalid toolbar button " + name); |
|
1986 |
+ continue; |
|
1987 |
+ } |
|
1988 |
+ this.buttons.push(new this.constructor.buttons[name]({ |
|
1989 |
+ editor: this.editor |
|
1990 |
+ })); |
|
1991 |
+ } |
|
1992 |
+ if (this.opts.toolbarHidden) { |
|
1993 |
+ return this.wrapper.hide(); |
|
1994 |
+ } |
|
1995 |
+ }; |
|
1996 |
+ |
|
1997 |
+ Toolbar.prototype.findButton = function(name) { |
|
1998 |
+ var button; |
|
1999 |
+ button = this.list.find('.toolbar-item-' + name).data('button'); |
|
2000 |
+ return button != null ? button : null; |
|
2001 |
+ }; |
|
2002 |
+ |
|
2003 |
+ Toolbar.addButton = function(btn) { |
|
2004 |
+ return this.buttons[btn.prototype.name] = btn; |
|
2005 |
+ }; |
|
2006 |
+ |
|
2007 |
+ Toolbar.buttons = {}; |
|
2008 |
+ |
|
2009 |
+ return Toolbar; |
|
2010 |
+ |
|
2011 |
+})(SimpleModule); |
|
2012 |
+ |
|
2013 |
+Indentation = (function(superClass) { |
|
2014 |
+ extend(Indentation, superClass); |
|
2015 |
+ |
|
2016 |
+ function Indentation() { |
|
2017 |
+ return Indentation.__super__.constructor.apply(this, arguments); |
|
2018 |
+ } |
|
2019 |
+ |
|
2020 |
+ Indentation.pluginName = 'Indentation'; |
|
2021 |
+ |
|
2022 |
+ Indentation.prototype.opts = { |
|
2023 |
+ tabIndent: true |
|
2024 |
+ }; |
|
2025 |
+ |
|
2026 |
+ Indentation.prototype._init = function() { |
|
2027 |
+ this.editor = this._module; |
|
2028 |
+ return this.editor.keystroke.add('tab', '*', (function(_this) { |
|
2029 |
+ return function(e) { |
|
2030 |
+ var codeButton; |
|
2031 |
+ codeButton = _this.editor.toolbar.findButton('code'); |
|
2032 |
+ if (!(_this.opts.tabIndent || (codeButton && codeButton.active))) { |
|
2033 |
+ return; |
|
2034 |
+ } |
|
2035 |
+ return _this.indent(e.shiftKey); |
|
2036 |
+ }; |
|
2037 |
+ })(this)); |
|
2038 |
+ }; |
|
2039 |
+ |
|
2040 |
+ Indentation.prototype.indent = function(isBackward) { |
|
2041 |
+ var $blockNodes, $endNodes, $startNodes, nodes, result; |
|
2042 |
+ $startNodes = this.editor.selection.startNodes(); |
|
2043 |
+ $endNodes = this.editor.selection.endNodes(); |
|
2044 |
+ $blockNodes = this.editor.selection.blockNodes(); |
|
2045 |
+ nodes = []; |
|
2046 |
+ $blockNodes = $blockNodes.each(function(i, node) { |
|
2047 |
+ var include, j, k, len, n; |
|
2048 |
+ include = true; |
|
2049 |
+ for (j = k = 0, len = nodes.length; k < len; j = ++k) { |
|
2050 |
+ n = nodes[j]; |
|
2051 |
+ if ($.contains(node, n)) { |
|
2052 |
+ include = false; |
|
2053 |
+ break; |
|
2054 |
+ } else if ($.contains(n, node)) { |
|
2055 |
+ nodes.splice(j, 1, node); |
|
2056 |
+ include = false; |
|
2057 |
+ break; |
|
2058 |
+ } |
|
2059 |
+ } |
|
2060 |
+ if (include) { |
|
2061 |
+ return nodes.push(node); |
|
2062 |
+ } |
|
2063 |
+ }); |
|
2064 |
+ $blockNodes = $(nodes); |
|
2065 |
+ result = false; |
|
2066 |
+ $blockNodes.each((function(_this) { |
|
2067 |
+ return function(i, blockEl) { |
|
2068 |
+ var r; |
|
2069 |
+ r = isBackward ? _this.outdentBlock(blockEl) : _this.indentBlock(blockEl); |
|
2070 |
+ if (r) { |
|
2071 |
+ return result = r; |
|
2072 |
+ } |
|
2073 |
+ }; |
|
2074 |
+ })(this)); |
|
2075 |
+ return result; |
|
2076 |
+ }; |
|
2077 |
+ |
|
2078 |
+ Indentation.prototype.indentBlock = function(blockEl) { |
|
2079 |
+ var $blockEl, $childList, $nextTd, $nextTr, $parentLi, $pre, $td, $tr, marginLeft, tagName; |
|
2080 |
+ $blockEl = $(blockEl); |
|
2081 |
+ if (!$blockEl.length) { |
|
2082 |
+ return; |
|
2083 |
+ } |
|
2084 |
+ if ($blockEl.is('pre')) { |
|
2085 |
+ $pre = this.editor.selection.containerNode(); |
|
2086 |
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) { |
|
2087 |
+ return; |
|
2088 |
+ } |
|
2089 |
+ this.indentText(this.editor.selection.range()); |
|
2090 |
+ } else if ($blockEl.is('li')) { |
|
2091 |
+ $parentLi = $blockEl.prev('li'); |
|
2092 |
+ if ($parentLi.length < 1) { |
|
2093 |
+ return; |
|
2094 |
+ } |
|
2095 |
+ this.editor.selection.save(); |
|
2096 |
+ tagName = $blockEl.parent()[0].tagName; |
|
2097 |
+ $childList = $parentLi.children('ul, ol'); |
|
2098 |
+ if ($childList.length > 0) { |
|
2099 |
+ $childList.append($blockEl); |
|
2100 |
+ } else { |
|
2101 |
+ $('<' + tagName + '/>').append($blockEl).appendTo($parentLi); |
|
2102 |
+ } |
|
2103 |
+ this.editor.selection.restore(); |
|
2104 |
+ } else if ($blockEl.is('p, h1, h2, h3, h4')) { |
|
2105 |
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0; |
|
2106 |
+ marginLeft = (Math.round(marginLeft / this.opts.indentWidth) + 1) * this.opts.indentWidth; |
|
2107 |
+ $blockEl.css('margin-left', marginLeft); |
|
2108 |
+ } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) { |
|
2109 |
+ $td = this.editor.selection.containerNode().closest('td, th'); |
|
2110 |
+ $nextTd = $td.next('td, th'); |
|
2111 |
+ if (!($nextTd.length > 0)) { |
|
2112 |
+ $tr = $td.parent('tr'); |
|
2113 |
+ $nextTr = $tr.next('tr'); |
|
2114 |
+ if ($nextTr.length < 1 && $tr.parent().is('thead')) { |
|
2115 |
+ $nextTr = $tr.parent('thead').next('tbody').find('tr:first'); |
|
2116 |
+ } |
|
2117 |
+ $nextTd = $nextTr.find('td:first, th:first'); |
|
2118 |
+ } |
|
2119 |
+ if (!($td.length > 0 && $nextTd.length > 0)) { |
|
2120 |
+ return; |
|
2121 |
+ } |
|
2122 |
+ this.editor.selection.setRangeAtEndOf($nextTd); |
|
2123 |
+ } else { |
|
2124 |
+ return false; |
|
2125 |
+ } |
|
2126 |
+ return true; |
|
2127 |
+ }; |
|
2128 |
+ |
|
2129 |
+ Indentation.prototype.indentText = function(range) { |
|
2130 |
+ var text, textNode; |
|
2131 |
+ text = range.toString().replace(/^(?=.+)/mg, '\u00A0\u00A0'); |
|
2132 |
+ textNode = document.createTextNode(text || '\u00A0\u00A0'); |
|
2133 |
+ range.deleteContents(); |
|
2134 |
+ range.insertNode(textNode); |
|
2135 |
+ if (text) { |
|
2136 |
+ range.selectNode(textNode); |
|
2137 |
+ return this.editor.selection.range(range); |
|
2138 |
+ } else { |
|
2139 |
+ return this.editor.selection.setRangeAfter(textNode); |
|
2140 |
+ } |
|
2141 |
+ }; |
|
2142 |
+ |
|
2143 |
+ Indentation.prototype.outdentBlock = function(blockEl) { |
|
2144 |
+ var $blockEl, $parent, $parentLi, $pre, $prevTd, $prevTr, $td, $tr, marginLeft, range; |
|
2145 |
+ $blockEl = $(blockEl); |
|
2146 |
+ if (!($blockEl && $blockEl.length > 0)) { |
|
2147 |
+ return; |
|
2148 |
+ } |
|
2149 |
+ if ($blockEl.is('pre')) { |
|
2150 |
+ $pre = this.editor.selection.containerNode(); |
|
2151 |
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) { |
|
2152 |
+ return; |
|
2153 |
+ } |
|
2154 |
+ this.outdentText(range); |
|
2155 |
+ } else if ($blockEl.is('li')) { |
|
2156 |
+ $parent = $blockEl.parent(); |
|
2157 |
+ $parentLi = $parent.parent('li'); |
|
2158 |
+ this.editor.selection.save(); |
|
2159 |
+ if ($parentLi.length < 1) { |
|
2160 |
+ range = document.createRange(); |
|
2161 |
+ range.setStartBefore($parent[0]); |
|
2162 |
+ range.setEndBefore($blockEl[0]); |
|
2163 |
+ $parent.before(range.extractContents()); |
|
2164 |
+ $('<p/>').insertBefore($parent).after($blockEl.children('ul, ol')).append($blockEl.contents()); |
|
2165 |
+ $blockEl.remove(); |
|
2166 |
+ } else { |
|
2167 |
+ if ($blockEl.next('li').length > 0) { |
|
2168 |
+ $('<' + $parent[0].tagName + '/>').append($blockEl.nextAll('li')).appendTo($blockEl); |
|
2169 |
+ } |
|
2170 |
+ $blockEl.insertAfter($parentLi); |
|
2171 |
+ if ($parent.children('li').length < 1) { |
|
2172 |
+ $parent.remove(); |
|
2173 |
+ } |
|
2174 |
+ } |
|
2175 |
+ this.editor.selection.restore(); |
|
2176 |
+ } else if ($blockEl.is('p, h1, h2, h3, h4')) { |
|
2177 |
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0; |
|
2178 |
+ marginLeft = Math.max(Math.round(marginLeft / this.opts.indentWidth) - 1, 0) * this.opts.indentWidth; |
|
2179 |
+ $blockEl.css('margin-left', marginLeft === 0 ? '' : marginLeft); |
|
2180 |
+ } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) { |
|
2181 |
+ $td = this.editor.selection.containerNode().closest('td, th'); |
|
2182 |
+ $prevTd = $td.prev('td, th'); |
|
2183 |
+ if (!($prevTd.length > 0)) { |
|
2184 |
+ $tr = $td.parent('tr'); |
|
2185 |
+ $prevTr = $tr.prev('tr'); |
|
2186 |
+ if ($prevTr.length < 1 && $tr.parent().is('tbody')) { |
|
2187 |
+ $prevTr = $tr.parent('tbody').prev('thead').find('tr:first'); |
|
2188 |
+ } |
|
2189 |
+ $prevTd = $prevTr.find('td:last, th:last'); |
|
2190 |
+ } |
|
2191 |
+ if (!($td.length > 0 && $prevTd.length > 0)) { |
|
2192 |
+ return; |
|
2193 |
+ } |
|
2194 |
+ this.editor.selection.setRangeAtEndOf($prevTd); |
|
2195 |
+ } else { |
|
2196 |
+ return false; |
|
2197 |
+ } |
|
2198 |
+ return true; |
|
2199 |
+ }; |
|
2200 |
+ |
|
2201 |
+ Indentation.prototype.outdentText = function(range) {}; |
|
2202 |
+ |
|
2203 |
+ return Indentation; |
|
2204 |
+ |
|
2205 |
+})(SimpleModule); |
|
2206 |
+ |
|
2207 |
+Clipboard = (function(superClass) { |
|
2208 |
+ extend(Clipboard, superClass); |
|
2209 |
+ |
|
2210 |
+ function Clipboard() { |
|
2211 |
+ return Clipboard.__super__.constructor.apply(this, arguments); |
|
2212 |
+ } |
|
2213 |
+ |
|
2214 |
+ Clipboard.pluginName = 'Clipboard'; |
|
2215 |
+ |
|
2216 |
+ Clipboard.prototype.opts = { |
|
2217 |
+ pasteImage: false, |
|
2218 |
+ cleanPaste: false |
|
2219 |
+ }; |
|
2220 |
+ |
|
2221 |
+ Clipboard.prototype._init = function() { |
|
2222 |
+ this.editor = this._module; |
|
2223 |
+ if (this.opts.pasteImage && typeof this.opts.pasteImage !== 'string') { |
|
2224 |
+ this.opts.pasteImage = 'inline'; |
|
2225 |
+ } |
|
2226 |
+ return this.editor.body.on('paste', (function(_this) { |
|
2227 |
+ return function(e) { |
|
2228 |
+ var range; |
|
2229 |
+ if (_this.pasting || _this._pasteBin) { |
|
2230 |
+ return; |
|
2231 |
+ } |
|
2232 |
+ if (_this.editor.triggerHandler(e) === false) { |
|
2233 |
+ return false; |
|
2234 |
+ } |
|
2235 |
+ range = _this.editor.selection.deleteRangeContents(); |
|
2236 |
+ if (_this.editor.body.html()) { |
|
2237 |
+ if (!range.collapsed) { |
|
2238 |
+ range.collapse(true); |
|
2239 |
+ } |
|
2240 |
+ } else { |
|
2241 |
+ _this.editor.formatter.format(); |
|
2242 |
+ _this.editor.selection.setRangeAtStartOf(_this.editor.body.find('p:first')); |
|
2243 |
+ } |
|
2244 |
+ if (_this._processPasteByClipboardApi(e)) { |
|
2245 |
+ return false; |
|
2246 |
+ } |
|
2247 |
+ _this.editor.inputManager.throttledValueChanged.clear(); |
|
2248 |
+ _this.editor.inputManager.throttledSelectionChanged.clear(); |
|
2249 |
+ _this.editor.undoManager.throttledPushState.clear(); |
|
2250 |
+ _this.editor.selection.reset(); |
|
2251 |
+ _this.editor.undoManager.resetCaretPosition(); |
|
2252 |
+ _this.pasting = true; |
|
2253 |
+ return _this._getPasteContent(function(pasteContent) { |
|
2254 |
+ _this._processPasteContent(pasteContent); |
|
2255 |
+ _this._pasteInBlockEl = null; |
|
2256 |
+ _this._pastePlainText = null; |
|
2257 |
+ return _this.pasting = false; |
|
2258 |
+ }); |
|
2259 |
+ }; |
|
2260 |
+ })(this)); |
|
2261 |
+ }; |
|
2262 |
+ |
|
2263 |
+ Clipboard.prototype._processPasteByClipboardApi = function(e) { |
|
2264 |
+ var imageFile, pasteItem, ref, uploadOpt; |
|
2265 |
+ if (this.editor.util.browser.edge) { |
|
2266 |
+ return; |
|
2267 |
+ } |
|
2268 |
+ if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.items && e.originalEvent.clipboardData.items.length > 0) { |
|
2269 |
+ pasteItem = e.originalEvent.clipboardData.items[0]; |
|
2270 |
+ if (/^image\//.test(pasteItem.type)) { |
|
2271 |
+ imageFile = pasteItem.getAsFile(); |
|
2272 |
+ if (!((imageFile != null) && this.opts.pasteImage)) { |
|
2273 |
+ return; |
|
2274 |
+ } |
|
2275 |
+ if (!imageFile.name) { |
|
2276 |
+ imageFile.name = "Clipboard Image.png"; |
|
2277 |
+ } |
|
2278 |
+ if (this.editor.triggerHandler('pasting', [imageFile]) === false) { |
|
2279 |
+ return; |
|
2280 |
+ } |
|
2281 |
+ uploadOpt = {}; |
|
2282 |
+ uploadOpt[this.opts.pasteImage] = true; |
|
2283 |
+ if ((ref = this.editor.uploader) != null) { |
|
2284 |
+ ref.upload(imageFile, uploadOpt); |
|
2285 |
+ } |
|
2286 |
+ return true; |
|
2287 |
+ } |
|
2288 |
+ } |
|
2289 |
+ }; |
|
2290 |
+ |
|
2291 |
+ Clipboard.prototype._getPasteContent = function(callback) { |
|
2292 |
+ var state; |
|
2293 |
+ this._pasteBin = $('<div contenteditable="true" />').addClass('simditor-paste-bin').attr('tabIndex', '-1').appendTo(this.editor.el); |
|
2294 |
+ state = { |
|
2295 |
+ html: this.editor.body.html(), |
|
2296 |
+ caret: this.editor.undoManager.caretPosition() |
|
2297 |
+ }; |
|
2298 |
+ this._pasteBin.focus(); |
|
2299 |
+ return setTimeout((function(_this) { |
|
2300 |
+ return function() { |
|
2301 |
+ var pasteContent; |
|
2302 |
+ _this.editor.hidePopover(); |
|
2303 |
+ _this.editor.body.get(0).innerHTML = state.html; |
|
2304 |
+ _this.editor.undoManager.caretPosition(state.caret); |
|
2305 |
+ _this.editor.body.focus(); |
|
2306 |
+ _this.editor.selection.reset(); |
|
2307 |
+ _this.editor.selection.range(); |
|
2308 |
+ _this._pasteInBlockEl = _this.editor.selection.blockNodes().last(); |
|
2309 |
+ _this._pastePlainText = _this.opts.cleanPaste || _this._pasteInBlockEl.is('pre, table'); |
|
2310 |
+ if (_this._pastePlainText) { |
|
2311 |
+ pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true); |
|
2312 |
+ } else { |
|
2313 |
+ pasteContent = $('<div/>').append(_this._pasteBin.contents()); |
|
2314 |
+ pasteContent.find('table colgroup').remove(); |
|
2315 |
+ _this.editor.formatter.format(pasteContent); |
|
2316 |
+ _this.editor.formatter.decorate(pasteContent); |
|
2317 |
+ _this.editor.formatter.beautify(pasteContent.children()); |
|
2318 |
+ pasteContent = pasteContent.contents(); |
|
2319 |
+ } |
|
2320 |
+ _this._pasteBin.remove(); |
|
2321 |
+ _this._pasteBin = null; |
|
2322 |
+ return callback(pasteContent); |
|
2323 |
+ }; |
|
2324 |
+ })(this), 0); |
|
2325 |
+ }; |
|
2326 |
+ |
|
2327 |
+ Clipboard.prototype._processPasteContent = function(pasteContent) { |
|
2328 |
+ var $blockEl, $img, blob, children, insertPosition, k, l, lastLine, len, len1, len2, len3, len4, line, lines, m, node, o, q, ref, ref1, ref2, uploadOpt; |
|
2329 |
+ if (this.editor.triggerHandler('pasting', [pasteContent]) === false) { |
|
2330 |
+ return; |
|
2331 |
+ } |
|
2332 |
+ $blockEl = this._pasteInBlockEl; |
|
2333 |
+ if (!pasteContent) { |
|
2334 |
+ return; |
|
2335 |
+ } else if (this._pastePlainText) { |
|
2336 |
+ if ($blockEl.is('table')) { |
|
2337 |
+ lines = pasteContent.split('\n'); |
|
2338 |
+ lastLine = lines.pop(); |
|
2339 |
+ for (k = 0, len = lines.length; k < len; k++) { |
|
2340 |
+ line = lines[k]; |
|
2341 |
+ this.editor.selection.insertNode(document.createTextNode(line)); |
|
2342 |
+ this.editor.selection.insertNode($('<br/>')); |
|
2343 |
+ } |
|
2344 |
+ this.editor.selection.insertNode(document.createTextNode(lastLine)); |
|
2345 |
+ } else { |
|
2346 |
+ pasteContent = $('<div/>').text(pasteContent); |
|
2347 |
+ ref = pasteContent.contents(); |
|
2348 |
+ for (l = 0, len1 = ref.length; l < len1; l++) { |
|
2349 |
+ node = ref[l]; |
|
2350 |
+ this.editor.selection.insertNode($(node)[0]); |
|
2351 |
+ } |
|
2352 |
+ } |
|
2353 |
+ } else if ($blockEl.is(this.editor.body)) { |
|
2354 |
+ for (m = 0, len2 = pasteContent.length; m < len2; m++) { |
|
2355 |
+ node = pasteContent[m]; |
|
2356 |
+ this.editor.selection.insertNode(node); |
|
2357 |
+ } |
|
2358 |
+ } else if (pasteContent.length < 1) { |
|
2359 |
+ return; |
|
2360 |
+ } else if (pasteContent.length === 1) { |
|
2361 |
+ if (pasteContent.is('p')) { |
|
2362 |
+ children = pasteContent.contents(); |
|
2363 |
+ if (children.length === 1 && children.is('img')) { |
|
2364 |
+ $img = children; |
|
2365 |
+ if (/^data:image/.test($img.attr('src'))) { |
|
2366 |
+ if (!this.opts.pasteImage) { |
|
2367 |
+ return; |
|
2368 |
+ } |
|
2369 |
+ blob = this.editor.util.dataURLtoBlob($img.attr("src")); |
|
2370 |
+ blob.name = "Clipboard Image.png"; |
|
2371 |
+ uploadOpt = {}; |
|
2372 |
+ uploadOpt[this.opts.pasteImage] = true; |
|
2373 |
+ if ((ref1 = this.editor.uploader) != null) { |
|
2374 |
+ ref1.upload(blob, uploadOpt); |
|
2375 |
+ } |
|
2376 |
+ return; |
|
2377 |
+ } else if ($img.is('img[src^="webkit-fake-url://"]')) { |
|
2378 |
+ return; |
|
2379 |
+ } |
|
2380 |
+ } |
|
2381 |
+ for (o = 0, len3 = children.length; o < len3; o++) { |
|
2382 |
+ node = children[o]; |
|
2383 |
+ this.editor.selection.insertNode(node); |
|
2384 |
+ } |
|
2385 |
+ } else if ($blockEl.is('p') && this.editor.util.isEmptyNode($blockEl)) { |
|
2386 |
+ $blockEl.replaceWith(pasteContent); |
|
2387 |
+ this.editor.selection.setRangeAtEndOf(pasteContent); |
|
2388 |
+ } else if (pasteContent.is('ul, ol')) { |
|
2389 |
+ if (pasteContent.find('li').length === 1) { |
|
2390 |
+ pasteContent = $('<div/>').text(pasteContent.text()); |
|
2391 |
+ ref2 = pasteContent.contents(); |
|
2392 |
+ for (q = 0, len4 = ref2.length; q < len4; q++) { |
|
2393 |
+ node = ref2[q]; |
|
2394 |
+ this.editor.selection.insertNode($(node)[0]); |
|
2395 |
+ } |
|
2396 |
+ } else if ($blockEl.is('li')) { |
|
2397 |
+ $blockEl.parent().after(pasteContent); |
|
2398 |
+ this.editor.selection.setRangeAtEndOf(pasteContent); |
|
2399 |
+ } else { |
|
2400 |
+ $blockEl.after(pasteContent); |
|
2401 |
+ this.editor.selection.setRangeAtEndOf(pasteContent); |
|
2402 |
+ } |
|
2403 |
+ } else { |
|
2404 |
+ $blockEl.after(pasteContent); |
|
2405 |
+ this.editor.selection.setRangeAtEndOf(pasteContent); |
|
2406 |
+ } |
|
2407 |
+ } else { |
|
2408 |
+ if ($blockEl.is('li')) { |
|
2409 |
+ $blockEl = $blockEl.parent(); |
|
2410 |
+ } |
|
2411 |
+ if (this.editor.selection.rangeAtStartOf($blockEl)) { |
|
2412 |
+ insertPosition = 'before'; |
|
2413 |
+ } else if (this.editor.selection.rangeAtEndOf($blockEl)) { |
|
2414 |
+ insertPosition = 'after'; |
|
2415 |
+ } else { |
|
2416 |
+ this.editor.selection.breakBlockEl($blockEl); |
|
2417 |
+ insertPosition = 'before'; |
|
2418 |
+ } |
|
2419 |
+ $blockEl[insertPosition](pasteContent); |
|
2420 |
+ this.editor.selection.setRangeAtEndOf(pasteContent.last()); |
|
2421 |
+ } |
|
2422 |
+ return this.editor.inputManager.throttledValueChanged(); |
|
2423 |
+ }; |
|
2424 |
+ |
|
2425 |
+ return Clipboard; |
|
2426 |
+ |
|
2427 |
+})(SimpleModule); |
|
2428 |
+ |
|
2429 |
+Simditor = (function(superClass) { |
|
2430 |
+ extend(Simditor, superClass); |
|
2431 |
+ |
|
2432 |
+ function Simditor() { |
|
2433 |
+ return Simditor.__super__.constructor.apply(this, arguments); |
|
2434 |
+ } |
|
2435 |
+ |
|
2436 |
+ Simditor.connect(Util); |
|
2437 |
+ |
|
2438 |
+ Simditor.connect(InputManager); |
|
2439 |
+ |
|
2440 |
+ Simditor.connect(Selection); |
|
2441 |
+ |
|
2442 |
+ Simditor.connect(UndoManager); |
|
2443 |
+ |
|
2444 |
+ Simditor.connect(Keystroke); |
|
2445 |
+ |
|
2446 |
+ Simditor.connect(Formatter); |
|
2447 |
+ |
|
2448 |
+ Simditor.connect(Toolbar); |
|
2449 |
+ |
|
2450 |
+ Simditor.connect(Indentation); |
|
2451 |
+ |
|
2452 |
+ Simditor.connect(Clipboard); |
|
2453 |
+ |
|
2454 |
+ Simditor.count = 0; |
|
2455 |
+ |
|
2456 |
+ Simditor.prototype.opts = { |
|
2457 |
+ textarea: null, |
|
2458 |
+ placeholder: '', |
|
2459 |
+ defaultImage: 'images/image.png', |
|
2460 |
+ params: {}, |
|
2461 |
+ upload: false, |
|
2462 |
+ indentWidth: 40 |
|
2463 |
+ }; |
|
2464 |
+ |
|
2465 |
+ Simditor.prototype._init = function() { |
|
2466 |
+ var e, editor, form, uploadOpts; |
|
2467 |
+ this.textarea = $(this.opts.textarea); |
|
2468 |
+ this.opts.placeholder = this.opts.placeholder || this.textarea.attr('placeholder'); |
|
2469 |
+ if (!this.textarea.length) { |
|
2470 |
+ throw new Error('simditor: param textarea is required.'); |
|
2471 |
+ return; |
|
2472 |
+ } |
|
2473 |
+ editor = this.textarea.data('simditor'); |
|
2474 |
+ if (editor != null) { |
|
2475 |
+ editor.destroy(); |
|
2476 |
+ } |
|
2477 |
+ this.id = ++Simditor.count; |
|
2478 |
+ this._render(); |
|
2479 |
+ if (simpleHotkeys) { |
|
2480 |
+ this.hotkeys = simpleHotkeys({ |
|
2481 |
+ el: this.body |
|
2482 |
+ }); |
|
2483 |
+ } else { |
|
2484 |
+ throw new Error('simditor: simple-hotkeys is required.'); |
|
2485 |
+ return; |
|
2486 |
+ } |
|
2487 |
+ if (this.opts.upload && simpleUploader) { |
|
2488 |
+ uploadOpts = typeof this.opts.upload === 'object' ? this.opts.upload : {}; |
|
2489 |
+ this.uploader = simpleUploader(uploadOpts); |
|
2490 |
+ } |
|
2491 |
+ form = this.textarea.closest('form'); |
|
2492 |
+ if (form.length) { |
|
2493 |
+ form.on('submit.simditor-' + this.id, (function(_this) { |
|
2494 |
+ return function() { |
|
2495 |
+ return _this.sync(); |
|
2496 |
+ }; |
|
2497 |
+ })(this)); |
|
2498 |
+ form.on('reset.simditor-' + this.id, (function(_this) { |
|
2499 |
+ return function() { |
|
2500 |
+ return _this.setValue(''); |
|
2501 |
+ }; |
|
2502 |
+ })(this)); |
|
2503 |
+ } |
|
2504 |
+ this.on('initialized', (function(_this) { |
|
2505 |
+ return function() { |
|
2506 |
+ if (_this.opts.placeholder) { |
|
2507 |
+ _this.on('valuechanged', function() { |
|
2508 |
+ return _this._placeholder(); |
|
2509 |
+ }); |
|
2510 |
+ } |
|
2511 |
+ _this.setValue(_this.textarea.val().trim() || ''); |
|
2512 |
+ if (_this.textarea.attr('autofocus')) { |
|
2513 |
+ return _this.focus(); |
|
2514 |
+ } |
|
2515 |
+ }; |
|
2516 |
+ })(this)); |
|
2517 |
+ if (this.util.browser.mozilla) { |
|
2518 |
+ this.util.reflow(); |
|
2519 |
+ try { |
|
2520 |
+ document.execCommand('enableObjectResizing', false, false); |
|
2521 |
+ return document.execCommand('enableInlineTableEditing', false, false); |
|
2522 |
+ } catch (_error) { |
|
2523 |
+ e = _error; |
|
2524 |
+ } |
|
2525 |
+ } |
|
2526 |
+ }; |
|
2527 |
+ |
|
2528 |
+ Simditor.prototype._tpl = "<div class=\"simditor\">\n <div class=\"simditor-wrapper\">\n <div class=\"simditor-placeholder\"></div>\n <div class=\"simditor-body\" contenteditable=\"true\">\n </div>\n </div>\n</div>"; |
|
2529 |
+ |
|
2530 |
+ Simditor.prototype._render = function() { |
|
2531 |
+ var key, ref, results, val; |
|
2532 |
+ this.el = $(this._tpl).insertBefore(this.textarea); |
|
2533 |
+ this.wrapper = this.el.find('.simditor-wrapper'); |
|
2534 |
+ this.body = this.wrapper.find('.simditor-body'); |
|
2535 |
+ this.placeholderEl = this.wrapper.find('.simditor-placeholder').append(this.opts.placeholder); |
|
2536 |
+ this.el.data('simditor', this); |
|
2537 |
+ this.wrapper.append(this.textarea); |
|
2538 |
+ this.textarea.data('simditor', this).blur(); |
|
2539 |
+ this.body.attr('tabindex', this.textarea.attr('tabindex')); |
|
2540 |
+ if (this.util.os.mac) { |
|
2541 |
+ this.el.addClass('simditor-mac'); |
|
2542 |
+ } else if (this.util.os.linux) { |
|
2543 |
+ this.el.addClass('simditor-linux'); |
|
2544 |
+ } |
|
2545 |
+ if (this.util.os.mobile) { |
|
2546 |
+ this.el.addClass('simditor-mobile'); |
|
2547 |
+ } |
|
2548 |
+ if (this.opts.params) { |
|
2549 |
+ ref = this.opts.params; |
|
2550 |
+ results = []; |
|
2551 |
+ for (key in ref) { |
|
2552 |
+ val = ref[key]; |
|
2553 |
+ results.push($('<input/>', { |
|
2554 |
+ type: 'hidden', |
|
2555 |
+ name: key, |
|
2556 |
+ value: val |
|
2557 |
+ }).insertAfter(this.textarea)); |
|
2558 |
+ } |
|
2559 |
+ return results; |
|
2560 |
+ } |
|
2561 |
+ }; |
|
2562 |
+ |
|
2563 |
+ Simditor.prototype._placeholder = function() { |
|
2564 |
+ var children; |
|
2565 |
+ children = this.body.children(); |
|
2566 |
+ if (children.length === 0 || (children.length === 1 && this.util.isEmptyNode(children) && parseInt(children.css('margin-left') || 0) < this.opts.indentWidth)) { |
|
2567 |
+ return this.placeholderEl.show(); |
|
2568 |
+ } else { |
|
2569 |
+ return this.placeholderEl.hide(); |
|
2570 |
+ } |
|
2571 |
+ }; |
|
2572 |
+ |
|
2573 |
+ Simditor.prototype.setValue = function(val) { |
|
2574 |
+ this.hidePopover(); |
|
2575 |
+ this.textarea.val(val); |
|
2576 |
+ this.body.get(0).innerHTML = val; |
|
2577 |
+ this.formatter.format(); |
|
2578 |
+ this.formatter.decorate(); |
|
2579 |
+ this.util.reflow(this.body); |
|
2580 |
+ this.inputManager.lastCaretPosition = null; |
|
2581 |
+ return this.trigger('valuechanged'); |
|
2582 |
+ }; |
|
2583 |
+ |
|
2584 |
+ Simditor.prototype.getValue = function() { |
|
2585 |
+ return this.sync(); |
|
2586 |
+ }; |
|
2587 |
+ |
|
2588 |
+ Simditor.prototype.sync = function() { |
|
2589 |
+ var children, cloneBody, emptyP, firstP, lastP, val; |
|
2590 |
+ cloneBody = this.body.clone(); |
|
2591 |
+ this.formatter.undecorate(cloneBody); |
|
2592 |
+ this.formatter.format(cloneBody); |
|
2593 |
+ this.formatter.autolink(cloneBody); |
|
2594 |
+ children = cloneBody.children(); |
|
2595 |
+ lastP = children.last('p'); |
|
2596 |
+ firstP = children.first('p'); |
|
2597 |
+ while (lastP.is('p') && this.util.isEmptyNode(lastP)) { |
|
2598 |
+ emptyP = lastP; |
|
2599 |
+ lastP = lastP.prev('p'); |
|
2600 |
+ emptyP.remove(); |
|
2601 |
+ } |
|
2602 |
+ while (firstP.is('p') && this.util.isEmptyNode(firstP)) { |
|
2603 |
+ emptyP = firstP; |
|
2604 |
+ firstP = lastP.next('p'); |
|
2605 |
+ emptyP.remove(); |
|
2606 |
+ } |
|
2607 |
+ cloneBody.find('img.uploading').remove(); |
|
2608 |
+ val = $.trim(cloneBody.html()); |
|
2609 |
+ this.textarea.val(val); |
|
2610 |
+ return val; |
|
2611 |
+ }; |
|
2612 |
+ |
|
2613 |
+ Simditor.prototype.focus = function() { |
|
2614 |
+ var $blockEl, range; |
|
2615 |
+ if (!(this.body.is(':visible') && this.body.is('[contenteditable]'))) { |
|
2616 |
+ this.el.find('textarea:visible').focus(); |
|
2617 |
+ return; |
|
2618 |
+ } |
|
2619 |
+ if (this.inputManager.lastCaretPosition) { |
|
2620 |
+ this.undoManager.caretPosition(this.inputManager.lastCaretPosition); |
|
2621 |
+ return this.inputManager.lastCaretPosition = null; |
|
2622 |
+ } else { |
|
2623 |
+ $blockEl = this.body.children().last(); |
|
2624 |
+ if (!$blockEl.is('p')) { |
|
2625 |
+ $blockEl = $('<p/>').append(this.util.phBr).appendTo(this.body); |
|
2626 |
+ } |
|
2627 |
+ range = document.createRange(); |
|
2628 |
+ return this.selection.setRangeAtEndOf($blockEl, range); |
|
2629 |
+ } |
|
2630 |
+ }; |
|
2631 |
+ |
|
2632 |
+ Simditor.prototype.blur = function() { |
|
2633 |
+ if (this.body.is(':visible') && this.body.is('[contenteditable]')) { |
|
2634 |
+ return this.body.blur(); |
|
2635 |
+ } else { |
|
2636 |
+ return this.body.find('textarea:visible').blur(); |
|
2637 |
+ } |
|
2638 |
+ }; |
|
2639 |
+ |
|
2640 |
+ Simditor.prototype.hidePopover = function() { |
|
2641 |
+ return this.el.find('.simditor-popover').each(function(i, popover) { |
|
2642 |
+ popover = $(popover).data('popover'); |
|
2643 |
+ if (popover.active) { |
|
2644 |
+ return popover.hide(); |
|
2645 |
+ } |
|
2646 |
+ }); |
|
2647 |
+ }; |
|
2648 |
+ |
|
2649 |
+ Simditor.prototype.destroy = function() { |
|
2650 |
+ this.triggerHandler('destroy'); |
|
2651 |
+ this.textarea.closest('form').off('.simditor .simditor-' + this.id); |
|
2652 |
+ this.selection.clear(); |
|
2653 |
+ this.inputManager.focused = false; |
|
2654 |
+ this.textarea.insertBefore(this.el).hide().val('').removeData('simditor'); |
|
2655 |
+ this.el.remove(); |
|
2656 |
+ $(document).off('.simditor-' + this.id); |
|
2657 |
+ $(window).off('.simditor-' + this.id); |
|
2658 |
+ return this.off(); |
|
2659 |
+ }; |
|
2660 |
+ |
|
2661 |
+ return Simditor; |
|
2662 |
+ |
|
2663 |
+})(SimpleModule); |
|
2664 |
+ |
|
2665 |
+Simditor.i18n = { |
|
2666 |
+ 'zh-CN': { |
|
2667 |
+ 'blockquote': '引用', |
|
2668 |
+ 'bold': '加粗文字', |
|
2669 |
+ 'code': '插入代码', |
|
2670 |
+ 'color': '文字颜色', |
|
2671 |
+ 'coloredText': '彩色文字', |
|
2672 |
+ 'hr': '分隔线', |
|
2673 |
+ 'image': '插入图片', |
|
2674 |
+ 'externalImage': '外链图片', |
|
2675 |
+ 'uploadImage': '上传图片', |
|
2676 |
+ 'uploadFailed': '上传失败了', |
|
2677 |
+ 'uploadError': '上传出错了', |
|
2678 |
+ 'imageUrl': '图片地址', |
|
2679 |
+ 'imageSize': '图片尺寸', |
|
2680 |
+ 'imageAlt': '图片描述', |
|
2681 |
+ 'restoreImageSize': '还原图片尺寸', |
|
2682 |
+ 'uploading': '正在上传', |
|
2683 |
+ 'indent': '向右缩进', |
|
2684 |
+ 'outdent': '向左缩进', |
|
2685 |
+ 'italic': '斜体文字', |
|
2686 |
+ 'link': '插入链接', |
|
2687 |
+ 'linkText': '链接文字', |
|
2688 |
+ 'linkUrl': '链接地址', |
|
2689 |
+ 'linkTarget': '打开方式', |
|
2690 |
+ 'openLinkInCurrentWindow': '在新窗口中打开', |
|
2691 |
+ 'openLinkInNewWindow': '在当前窗口中打开', |
|
2692 |
+ 'removeLink': '移除链接', |
|
2693 |
+ 'ol': '有序列表', |
|
2694 |
+ 'ul': '无序列表', |
|
2695 |
+ 'strikethrough': '删除线文字', |
|
2696 |
+ 'table': '表格', |
|
2697 |
+ 'deleteRow': '删除行', |
|
2698 |
+ 'insertRowAbove': '在上面插入行', |
|
2699 |
+ 'insertRowBelow': '在下面插入行', |
|
2700 |
+ 'deleteColumn': '删除列', |
|
2701 |
+ 'insertColumnLeft': '在左边插入列', |
|
2702 |
+ 'insertColumnRight': '在右边插入列', |
|
2703 |
+ 'deleteTable': '删除表格', |
|
2704 |
+ 'title': '标题', |
|
2705 |
+ 'normalText': '普通文本', |
|
2706 |
+ 'underline': '下划线文字', |
|
2707 |
+ 'alignment': '水平对齐', |
|
2708 |
+ 'alignCenter': '居中', |
|
2709 |
+ 'alignLeft': '居左', |
|
2710 |
+ 'alignRight': '居右', |
|
2711 |
+ 'selectLanguage': '选择程序语言', |
|
2712 |
+ 'fontScale': '字体大小', |
|
2713 |
+ 'fontScaleXLarge': '超大字体', |
|
2714 |
+ 'fontScaleLarge': '大号字体', |
|
2715 |
+ 'fontScaleNormal': '正常大小', |
|
2716 |
+ 'fontScaleSmall': '小号字体', |
|
2717 |
+ 'fontScaleXSmall': '超小字体' |
|
2718 |
+ }, |
|
2719 |
+ 'en-US': { |
|
2720 |
+ 'blockquote': 'Block Quote', |
|
2721 |
+ 'bold': 'Bold', |
|
2722 |
+ 'code': 'Code', |
|
2723 |
+ 'color': 'Text Color', |
|
2724 |
+ 'coloredText': 'Colored Text', |
|
2725 |
+ 'hr': 'Horizontal Line', |
|
2726 |
+ 'image': 'Insert Image', |
|
2727 |
+ 'externalImage': 'External Image', |
|
2728 |
+ 'uploadImage': 'Upload Image', |
|
2729 |
+ 'uploadFailed': 'Upload failed', |
|
2730 |
+ 'uploadError': 'Error occurs during upload', |
|
2731 |
+ 'imageUrl': 'Url', |
|
2732 |
+ 'imageSize': 'Size', |
|
2733 |
+ 'imageAlt': 'Alt', |
|
2734 |
+ 'restoreImageSize': 'Restore Origin Size', |
|
2735 |
+ 'uploading': 'Uploading', |
|
2736 |
+ 'indent': 'Indent', |
|
2737 |
+ 'outdent': 'Outdent', |
|
2738 |
+ 'italic': 'Italic', |
|
2739 |
+ 'link': 'Insert Link', |
|
2740 |
+ 'linkText': 'Text', |
|
2741 |
+ 'linkUrl': 'Url', |
|
2742 |
+ 'linkTarget': 'Target', |
|
2743 |
+ 'openLinkInCurrentWindow': 'Open link in current window', |
|
2744 |
+ 'openLinkInNewWindow': 'Open link in new window', |
|
2745 |
+ 'removeLink': 'Remove Link', |
|
2746 |
+ 'ol': 'Ordered List', |
|
2747 |
+ 'ul': 'Unordered List', |
|
2748 |
+ 'strikethrough': 'Strikethrough', |
|
2749 |
+ 'table': 'Table', |
|
2750 |
+ 'deleteRow': 'Delete Row', |
|
2751 |
+ 'insertRowAbove': 'Insert Row Above', |
|
2752 |
+ 'insertRowBelow': 'Insert Row Below', |
|
2753 |
+ 'deleteColumn': 'Delete Column', |
|
2754 |
+ 'insertColumnLeft': 'Insert Column Left', |
|
2755 |
+ 'insertColumnRight': 'Insert Column Right', |
|
2756 |
+ 'deleteTable': 'Delete Table', |
|
2757 |
+ 'title': 'Title', |
|
2758 |
+ 'normalText': 'Text', |
|
2759 |
+ 'underline': 'Underline', |
|
2760 |
+ 'alignment': 'Alignment', |
|
2761 |
+ 'alignCenter': 'Align Center', |
|
2762 |
+ 'alignLeft': 'Align Left', |
|
2763 |
+ 'alignRight': 'Align Right', |
|
2764 |
+ 'selectLanguage': 'Select Language', |
|
2765 |
+ 'fontScale': 'Font Size', |
|
2766 |
+ 'fontScaleXLarge': 'X Large Size', |
|
2767 |
+ 'fontScaleLarge': 'Large Size', |
|
2768 |
+ 'fontScaleNormal': 'Normal Size', |
|
2769 |
+ 'fontScaleSmall': 'Small Size', |
|
2770 |
+ 'fontScaleXSmall': 'X Small Size' |
|
2771 |
+ } |
|
2772 |
+}; |
|
2773 |
+ |
|
2774 |
+Button = (function(superClass) { |
|
2775 |
+ extend(Button, superClass); |
|
2776 |
+ |
|
2777 |
+ Button.prototype._tpl = { |
|
2778 |
+ item: '<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>', |
|
2779 |
+ menuWrapper: '<div class="toolbar-menu"></div>', |
|
2780 |
+ menuItem: '<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>', |
|
2781 |
+ separator: '<li><span class="separator"></span></li>' |
|
2782 |
+ }; |
|
2783 |
+ |
|
2784 |
+ Button.prototype.name = ''; |
|
2785 |
+ |
|
2786 |
+ Button.prototype.icon = ''; |
|
2787 |
+ |
|
2788 |
+ Button.prototype.title = ''; |
|
2789 |
+ |
|
2790 |
+ Button.prototype.text = ''; |
|
2791 |
+ |
|
2792 |
+ Button.prototype.htmlTag = ''; |
|
2793 |
+ |
|
2794 |
+ Button.prototype.disableTag = ''; |
|
2795 |
+ |
|
2796 |
+ Button.prototype.menu = false; |
|
2797 |
+ |
|
2798 |
+ Button.prototype.active = false; |
|
2799 |
+ |
|
2800 |
+ Button.prototype.disabled = false; |
|
2801 |
+ |
|
2802 |
+ Button.prototype.needFocus = true; |
|
2803 |
+ |
|
2804 |
+ Button.prototype.shortcut = null; |
|
2805 |
+ |
|
2806 |
+ function Button(opts) { |
|
2807 |
+ this.editor = opts.editor; |
|
2808 |
+ this.title = this._t(this.name); |
|
2809 |
+ Button.__super__.constructor.call(this, opts); |
|
2810 |
+ } |
|
2811 |
+ |
|
2812 |
+ Button.prototype._init = function() { |
|
2813 |
+ var k, len, ref, tag; |
|
2814 |
+ this.render(); |
|
2815 |
+ this.el.on('mousedown', (function(_this) { |
|
2816 |
+ return function(e) { |
|
2817 |
+ var exceed, noFocus, param; |
|
2818 |
+ e.preventDefault(); |
|
2819 |
+ noFocus = _this.needFocus && !_this.editor.inputManager.focused; |
|
2820 |
+ if (_this.el.hasClass('disabled') || noFocus) { |
|
2821 |
+ return false; |
|
2822 |
+ } |
|
2823 |
+ if (_this.menu) { |
|
2824 |
+ _this.wrapper.toggleClass('menu-on').siblings('li').removeClass('menu-on'); |
|
2825 |
+ if (_this.wrapper.is('.menu-on')) { |
|
2826 |
+ exceed = _this.menuWrapper.offset().left + _this.menuWrapper.outerWidth() + 5 - _this.editor.wrapper.offset().left - _this.editor.wrapper.outerWidth(); |
|
2827 |
+ if (exceed > 0) { |
|
2828 |
+ _this.menuWrapper.css({ |
|
2829 |
+ 'left': 'auto', |
|
2830 |
+ 'right': 0 |
|
2831 |
+ }); |
|
2832 |
+ } |
|
2833 |
+ _this.trigger('menuexpand'); |
|
2834 |
+ } |
|
2835 |
+ return false; |
|
2836 |
+ } |
|
2837 |
+ param = _this.el.data('param'); |
|
2838 |
+ _this.command(param); |
|
2839 |
+ return false; |
|
2840 |
+ }; |
|
2841 |
+ })(this)); |
|
2842 |
+ this.wrapper.on('click', 'a.menu-item', (function(_this) { |
|
2843 |
+ return function(e) { |
|
2844 |
+ var btn, noFocus, param; |
|
2845 |
+ e.preventDefault(); |
|
2846 |
+ btn = $(e.currentTarget); |
|
2847 |
+ _this.wrapper.removeClass('menu-on'); |
|
2848 |
+ noFocus = _this.needFocus && !_this.editor.inputManager.focused; |
|
2849 |
+ if (btn.hasClass('disabled') || noFocus) { |
|
2850 |
+ return false; |
|
2851 |
+ } |
|
2852 |
+ _this.editor.toolbar.wrapper.removeClass('menu-on'); |
|
2853 |
+ param = btn.data('param'); |
|
2854 |
+ _this.command(param); |
|
2855 |
+ return false; |
|
2856 |
+ }; |
|
2857 |
+ })(this)); |
|
2858 |
+ this.wrapper.on('mousedown', 'a.menu-item', function(e) { |
|
2859 |
+ return false; |
|
2860 |
+ }); |
|
2861 |
+ this.editor.on('blur', (function(_this) { |
|
2862 |
+ return function() { |
|
2863 |
+ var editorActive; |
|
2864 |
+ editorActive = _this.editor.body.is(':visible') && _this.editor.body.is('[contenteditable]'); |
|
2865 |
+ if (!(editorActive && !_this.editor.clipboard.pasting)) { |
|
2866 |
+ return; |
|
2867 |
+ } |
|
2868 |
+ _this.setActive(false); |
|
2869 |
+ return _this.setDisabled(false); |
|
2870 |
+ }; |
|
2871 |
+ })(this)); |
|
2872 |
+ if (this.shortcut != null) { |
|
2873 |
+ this.editor.hotkeys.add(this.shortcut, (function(_this) { |
|
2874 |
+ return function(e) { |
|
2875 |
+ _this.el.mousedown(); |
|
2876 |
+ return false; |
|
2877 |
+ }; |
|
2878 |
+ })(this)); |
|
2879 |
+ } |
|
2880 |
+ ref = this.htmlTag.split(','); |
|
2881 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
2882 |
+ tag = ref[k]; |
|
2883 |
+ tag = $.trim(tag); |
|
2884 |
+ if (tag && $.inArray(tag, this.editor.formatter._allowedTags) < 0) { |
|
2885 |
+ this.editor.formatter._allowedTags.push(tag); |
|
2886 |
+ } |
|
2887 |
+ } |
|
2888 |
+ return this.editor.on('selectionchanged', (function(_this) { |
|
2889 |
+ return function(e) { |
|
2890 |
+ if (_this.editor.inputManager.focused) { |
|
2891 |
+ return _this._status(); |
|
2892 |
+ } |
|
2893 |
+ }; |
|
2894 |
+ })(this)); |
|
2895 |
+ }; |
|
2896 |
+ |
|
2897 |
+ Button.prototype.iconClassOf = function(icon) { |
|
2898 |
+ if (icon) { |
|
2899 |
+ return "simditor-icon simditor-icon-" + icon; |
|
2900 |
+ } else { |
|
2901 |
+ return ''; |
|
2902 |
+ } |
|
2903 |
+ }; |
|
2904 |
+ |
|
2905 |
+ Button.prototype.setIcon = function(icon) { |
|
2906 |
+ return this.el.find('span').removeClass().addClass(this.iconClassOf(icon)).text(this.text); |
|
2907 |
+ }; |
|
2908 |
+ |
|
2909 |
+ Button.prototype.render = function() { |
|
2910 |
+ this.wrapper = $(this._tpl.item).appendTo(this.editor.toolbar.list); |
|
2911 |
+ this.el = this.wrapper.find('a.toolbar-item'); |
|
2912 |
+ this.el.attr('title', this.title).addClass("toolbar-item-" + this.name).data('button', this); |
|
2913 |
+ this.setIcon(this.icon); |
|
2914 |
+ if (!this.menu) { |
|
2915 |
+ return; |
|
2916 |
+ } |
|
2917 |
+ this.menuWrapper = $(this._tpl.menuWrapper).appendTo(this.wrapper); |
|
2918 |
+ this.menuWrapper.addClass("toolbar-menu-" + this.name); |
|
2919 |
+ return this.renderMenu(); |
|
2920 |
+ }; |
|
2921 |
+ |
|
2922 |
+ Button.prototype.renderMenu = function() { |
|
2923 |
+ var $menuBtnEl, $menuItemEl, k, len, menuItem, ref, ref1, results; |
|
2924 |
+ if (!$.isArray(this.menu)) { |
|
2925 |
+ return; |
|
2926 |
+ } |
|
2927 |
+ this.menuEl = $('<ul/>').appendTo(this.menuWrapper); |
|
2928 |
+ ref = this.menu; |
|
2929 |
+ results = []; |
|
2930 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
2931 |
+ menuItem = ref[k]; |
|
2932 |
+ if (menuItem === '|') { |
|
2933 |
+ $(this._tpl.separator).appendTo(this.menuEl); |
|
2934 |
+ continue; |
|
2935 |
+ } |
|
2936 |
+ $menuItemEl = $(this._tpl.menuItem).appendTo(this.menuEl); |
|
2937 |
+ $menuBtnEl = $menuItemEl.find('a.menu-item').attr({ |
|
2938 |
+ 'title': (ref1 = menuItem.title) != null ? ref1 : menuItem.text, |
|
2939 |
+ 'data-param': menuItem.param |
|
2940 |
+ }).addClass('menu-item-' + menuItem.name); |
|
2941 |
+ if (menuItem.icon) { |
|
2942 |
+ results.push($menuBtnEl.find('span').addClass(this.iconClassOf(menuItem.icon))); |
|
2943 |
+ } else { |
|
2944 |
+ results.push($menuBtnEl.find('span').text(menuItem.text)); |
|
2945 |
+ } |
|
2946 |
+ } |
|
2947 |
+ return results; |
|
2948 |
+ }; |
|
2949 |
+ |
|
2950 |
+ Button.prototype.setActive = function(active) { |
|
2951 |
+ if (active === this.active) { |
|
2952 |
+ return; |
|
2953 |
+ } |
|
2954 |
+ this.active = active; |
|
2955 |
+ return this.el.toggleClass('active', this.active); |
|
2956 |
+ }; |
|
2957 |
+ |
|
2958 |
+ Button.prototype.setDisabled = function(disabled) { |
|
2959 |
+ if (disabled === this.disabled) { |
|
2960 |
+ return; |
|
2961 |
+ } |
|
2962 |
+ this.disabled = disabled; |
|
2963 |
+ return this.el.toggleClass('disabled', this.disabled); |
|
2964 |
+ }; |
|
2965 |
+ |
|
2966 |
+ Button.prototype._disableStatus = function() { |
|
2967 |
+ var disabled, endNodes, startNodes; |
|
2968 |
+ startNodes = this.editor.selection.startNodes(); |
|
2969 |
+ endNodes = this.editor.selection.endNodes(); |
|
2970 |
+ disabled = startNodes.filter(this.disableTag).length > 0 || endNodes.filter(this.disableTag).length > 0; |
|
2971 |
+ this.setDisabled(disabled); |
|
2972 |
+ if (this.disabled) { |
|
2973 |
+ this.setActive(false); |
|
2974 |
+ } |
|
2975 |
+ return this.disabled; |
|
2976 |
+ }; |
|
2977 |
+ |
|
2978 |
+ Button.prototype._activeStatus = function() { |
|
2979 |
+ var active, endNode, endNodes, startNode, startNodes; |
|
2980 |
+ startNodes = this.editor.selection.startNodes(); |
|
2981 |
+ endNodes = this.editor.selection.endNodes(); |
|
2982 |
+ startNode = startNodes.filter(this.htmlTag); |
|
2983 |
+ endNode = endNodes.filter(this.htmlTag); |
|
2984 |
+ active = startNode.length > 0 && endNode.length > 0 && startNode.is(endNode); |
|
2985 |
+ this.node = active ? startNode : null; |
|
2986 |
+ this.setActive(active); |
|
2987 |
+ return this.active; |
|
2988 |
+ }; |
|
2989 |
+ |
|
2990 |
+ Button.prototype._status = function() { |
|
2991 |
+ this._disableStatus(); |
|
2992 |
+ if (this.disabled) { |
|
2993 |
+ return; |
|
2994 |
+ } |
|
2995 |
+ return this._activeStatus(); |
|
2996 |
+ }; |
|
2997 |
+ |
|
2998 |
+ Button.prototype.command = function(param) {}; |
|
2999 |
+ |
|
3000 |
+ Button.prototype._t = function() { |
|
3001 |
+ var args, ref, result; |
|
3002 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
3003 |
+ result = Button.__super__._t.apply(this, args); |
|
3004 |
+ if (!result) { |
|
3005 |
+ result = (ref = this.editor)._t.apply(ref, args); |
|
3006 |
+ } |
|
3007 |
+ return result; |
|
3008 |
+ }; |
|
3009 |
+ |
|
3010 |
+ return Button; |
|
3011 |
+ |
|
3012 |
+})(SimpleModule); |
|
3013 |
+ |
|
3014 |
+Simditor.Button = Button; |
|
3015 |
+ |
|
3016 |
+Popover = (function(superClass) { |
|
3017 |
+ extend(Popover, superClass); |
|
3018 |
+ |
|
3019 |
+ Popover.prototype.offset = { |
|
3020 |
+ top: 4, |
|
3021 |
+ left: 0 |
|
3022 |
+ }; |
|
3023 |
+ |
|
3024 |
+ Popover.prototype.target = null; |
|
3025 |
+ |
|
3026 |
+ Popover.prototype.active = false; |
|
3027 |
+ |
|
3028 |
+ function Popover(opts) { |
|
3029 |
+ this.button = opts.button; |
|
3030 |
+ this.editor = opts.button.editor; |
|
3031 |
+ Popover.__super__.constructor.call(this, opts); |
|
3032 |
+ } |
|
3033 |
+ |
|
3034 |
+ Popover.prototype._init = function() { |
|
3035 |
+ this.el = $('<div class="simditor-popover"></div>').appendTo(this.editor.el).data('popover', this); |
|
3036 |
+ this.render(); |
|
3037 |
+ this.el.on('mouseenter', (function(_this) { |
|
3038 |
+ return function(e) { |
|
3039 |
+ return _this.el.addClass('hover'); |
|
3040 |
+ }; |
|
3041 |
+ })(this)); |
|
3042 |
+ return this.el.on('mouseleave', (function(_this) { |
|
3043 |
+ return function(e) { |
|
3044 |
+ return _this.el.removeClass('hover'); |
|
3045 |
+ }; |
|
3046 |
+ })(this)); |
|
3047 |
+ }; |
|
3048 |
+ |
|
3049 |
+ Popover.prototype.render = function() {}; |
|
3050 |
+ |
|
3051 |
+ Popover.prototype._initLabelWidth = function() { |
|
3052 |
+ var $fields; |
|
3053 |
+ $fields = this.el.find('.settings-field'); |
|
3054 |
+ if (!($fields.length > 0)) { |
|
3055 |
+ return; |
|
3056 |
+ } |
|
3057 |
+ this._labelWidth = 0; |
|
3058 |
+ $fields.each((function(_this) { |
|
3059 |
+ return function(i, field) { |
|
3060 |
+ var $field, $label; |
|
3061 |
+ $field = $(field); |
|
3062 |
+ $label = $field.find('label'); |
|
3063 |
+ if (!($label.length > 0)) { |
|
3064 |
+ return; |
|
3065 |
+ } |
|
3066 |
+ return _this._labelWidth = Math.max(_this._labelWidth, $label.width()); |
|
3067 |
+ }; |
|
3068 |
+ })(this)); |
|
3069 |
+ return $fields.find('label').width(this._labelWidth); |
|
3070 |
+ }; |
|
3071 |
+ |
|
3072 |
+ Popover.prototype.show = function($target, position) { |
|
3073 |
+ if (position == null) { |
|
3074 |
+ position = 'bottom'; |
|
3075 |
+ } |
|
3076 |
+ if ($target == null) { |
|
3077 |
+ return; |
|
3078 |
+ } |
|
3079 |
+ this.el.siblings('.simditor-popover').each(function(i, popover) { |
|
3080 |
+ popover = $(popover).data('popover'); |
|
3081 |
+ if (popover.active) { |
|
3082 |
+ return popover.hide(); |
|
3083 |
+ } |
|
3084 |
+ }); |
|
3085 |
+ if (this.active && this.target) { |
|
3086 |
+ this.target.removeClass('selected'); |
|
3087 |
+ } |
|
3088 |
+ this.target = $target.addClass('selected'); |
|
3089 |
+ if (this.active) { |
|
3090 |
+ this.refresh(position); |
|
3091 |
+ return this.trigger('popovershow'); |
|
3092 |
+ } else { |
|
3093 |
+ this.active = true; |
|
3094 |
+ this.el.css({ |
|
3095 |
+ left: -9999 |
|
3096 |
+ }).show(); |
|
3097 |
+ if (!this._labelWidth) { |
|
3098 |
+ this._initLabelWidth(); |
|
3099 |
+ } |
|
3100 |
+ this.editor.util.reflow(); |
|
3101 |
+ this.refresh(position); |
|
3102 |
+ return this.trigger('popovershow'); |
|
3103 |
+ } |
|
3104 |
+ }; |
|
3105 |
+ |
|
3106 |
+ Popover.prototype.hide = function() { |
|
3107 |
+ if (!this.active) { |
|
3108 |
+ return; |
|
3109 |
+ } |
|
3110 |
+ if (this.target) { |
|
3111 |
+ this.target.removeClass('selected'); |
|
3112 |
+ } |
|
3113 |
+ this.target = null; |
|
3114 |
+ this.active = false; |
|
3115 |
+ this.el.hide(); |
|
3116 |
+ return this.trigger('popoverhide'); |
|
3117 |
+ }; |
|
3118 |
+ |
|
3119 |
+ Popover.prototype.refresh = function(position) { |
|
3120 |
+ var editorOffset, left, maxLeft, targetH, targetOffset, top; |
|
3121 |
+ if (position == null) { |
|
3122 |
+ position = 'bottom'; |
|
3123 |
+ } |
|
3124 |
+ if (!this.active) { |
|
3125 |
+ return; |
|
3126 |
+ } |
|
3127 |
+ editorOffset = this.editor.el.offset(); |
|
3128 |
+ targetOffset = this.target.offset(); |
|
3129 |
+ targetH = this.target.outerHeight(); |
|
3130 |
+ if (position === 'bottom') { |
|
3131 |
+ top = targetOffset.top - editorOffset.top + targetH; |
|
3132 |
+ } else if (position === 'top') { |
|
3133 |
+ top = targetOffset.top - editorOffset.top - this.el.height(); |
|
3134 |
+ } |
|
3135 |
+ maxLeft = this.editor.wrapper.width() - this.el.outerWidth() - 10; |
|
3136 |
+ left = Math.min(targetOffset.left - editorOffset.left, maxLeft); |
|
3137 |
+ return this.el.css({ |
|
3138 |
+ top: top + this.offset.top, |
|
3139 |
+ left: left + this.offset.left |
|
3140 |
+ }); |
|
3141 |
+ }; |
|
3142 |
+ |
|
3143 |
+ Popover.prototype.destroy = function() { |
|
3144 |
+ this.target = null; |
|
3145 |
+ this.active = false; |
|
3146 |
+ this.editor.off('.linkpopover'); |
|
3147 |
+ return this.el.remove(); |
|
3148 |
+ }; |
|
3149 |
+ |
|
3150 |
+ Popover.prototype._t = function() { |
|
3151 |
+ var args, ref, result; |
|
3152 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
3153 |
+ result = Popover.__super__._t.apply(this, args); |
|
3154 |
+ if (!result) { |
|
3155 |
+ result = (ref = this.button)._t.apply(ref, args); |
|
3156 |
+ } |
|
3157 |
+ return result; |
|
3158 |
+ }; |
|
3159 |
+ |
|
3160 |
+ return Popover; |
|
3161 |
+ |
|
3162 |
+})(SimpleModule); |
|
3163 |
+ |
|
3164 |
+Simditor.Popover = Popover; |
|
3165 |
+ |
|
3166 |
+TitleButton = (function(superClass) { |
|
3167 |
+ extend(TitleButton, superClass); |
|
3168 |
+ |
|
3169 |
+ function TitleButton() { |
|
3170 |
+ return TitleButton.__super__.constructor.apply(this, arguments); |
|
3171 |
+ } |
|
3172 |
+ |
|
3173 |
+ TitleButton.prototype.name = 'title'; |
|
3174 |
+ |
|
3175 |
+ TitleButton.prototype.htmlTag = 'h1, h2, h3, h4, h5'; |
|
3176 |
+ |
|
3177 |
+ TitleButton.prototype.disableTag = 'pre, table'; |
|
3178 |
+ |
|
3179 |
+ TitleButton.prototype._init = function() { |
|
3180 |
+ this.menu = [ |
|
3181 |
+ { |
|
3182 |
+ name: 'normal', |
|
3183 |
+ text: this._t('normalText'), |
|
3184 |
+ param: 'p' |
|
3185 |
+ }, '|', { |
|
3186 |
+ name: 'h1', |
|
3187 |
+ text: this._t('title') + ' 1', |
|
3188 |
+ param: 'h1' |
|
3189 |
+ }, { |
|
3190 |
+ name: 'h2', |
|
3191 |
+ text: this._t('title') + ' 2', |
|
3192 |
+ param: 'h2' |
|
3193 |
+ }, { |
|
3194 |
+ name: 'h3', |
|
3195 |
+ text: this._t('title') + ' 3', |
|
3196 |
+ param: 'h3' |
|
3197 |
+ }, { |
|
3198 |
+ name: 'h4', |
|
3199 |
+ text: this._t('title') + ' 4', |
|
3200 |
+ param: 'h4' |
|
3201 |
+ }, { |
|
3202 |
+ name: 'h5', |
|
3203 |
+ text: this._t('title') + ' 5', |
|
3204 |
+ param: 'h5' |
|
3205 |
+ } |
|
3206 |
+ ]; |
|
3207 |
+ return TitleButton.__super__._init.call(this); |
|
3208 |
+ }; |
|
3209 |
+ |
|
3210 |
+ TitleButton.prototype.setActive = function(active, param) { |
|
3211 |
+ TitleButton.__super__.setActive.call(this, active); |
|
3212 |
+ if (active) { |
|
3213 |
+ param || (param = this.node[0].tagName.toLowerCase()); |
|
3214 |
+ } |
|
3215 |
+ this.el.removeClass('active-p active-h1 active-h2 active-h3 active-h4 active-h5'); |
|
3216 |
+ if (active) { |
|
3217 |
+ return this.el.addClass('active active-' + param); |
|
3218 |
+ } |
|
3219 |
+ }; |
|
3220 |
+ |
|
3221 |
+ TitleButton.prototype.command = function(param) { |
|
3222 |
+ var $rootNodes; |
|
3223 |
+ $rootNodes = this.editor.selection.rootNodes(); |
|
3224 |
+ this.editor.selection.save(); |
|
3225 |
+ $rootNodes.each((function(_this) { |
|
3226 |
+ return function(i, node) { |
|
3227 |
+ var $node; |
|
3228 |
+ $node = $(node); |
|
3229 |
+ if ($node.is('blockquote') || $node.is(param) || $node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node)) { |
|
3230 |
+ return; |
|
3231 |
+ } |
|
3232 |
+ return $('<' + param + '/>').append($node.contents()).replaceAll($node); |
|
3233 |
+ }; |
|
3234 |
+ })(this)); |
|
3235 |
+ this.editor.selection.restore(); |
|
3236 |
+ return this.editor.trigger('valuechanged'); |
|
3237 |
+ }; |
|
3238 |
+ |
|
3239 |
+ return TitleButton; |
|
3240 |
+ |
|
3241 |
+})(Button); |
|
3242 |
+ |
|
3243 |
+Simditor.Toolbar.addButton(TitleButton); |
|
3244 |
+ |
|
3245 |
+FontScaleButton = (function(superClass) { |
|
3246 |
+ extend(FontScaleButton, superClass); |
|
3247 |
+ |
|
3248 |
+ function FontScaleButton() { |
|
3249 |
+ return FontScaleButton.__super__.constructor.apply(this, arguments); |
|
3250 |
+ } |
|
3251 |
+ |
|
3252 |
+ FontScaleButton.prototype.name = 'fontScale'; |
|
3253 |
+ |
|
3254 |
+ FontScaleButton.prototype.icon = 'font'; |
|
3255 |
+ |
|
3256 |
+ FontScaleButton.prototype.disableTag = 'pre'; |
|
3257 |
+ |
|
3258 |
+ FontScaleButton.prototype.htmlTag = 'span'; |
|
3259 |
+ |
|
3260 |
+ FontScaleButton.prototype.sizeMap = { |
|
3261 |
+ 'x-large': '1.5em', |
|
3262 |
+ 'large': '1.25em', |
|
3263 |
+ 'small': '.75em', |
|
3264 |
+ 'x-small': '.5em' |
|
3265 |
+ }; |
|
3266 |
+ |
|
3267 |
+ FontScaleButton.prototype._init = function() { |
|
3268 |
+ this.menu = [ |
|
3269 |
+ { |
|
3270 |
+ name: '150%', |
|
3271 |
+ text: this._t('fontScaleXLarge'), |
|
3272 |
+ param: '5' |
|
3273 |
+ }, { |
|
3274 |
+ name: '125%', |
|
3275 |
+ text: this._t('fontScaleLarge'), |
|
3276 |
+ param: '4' |
|
3277 |
+ }, { |
|
3278 |
+ name: '100%', |
|
3279 |
+ text: this._t('fontScaleNormal'), |
|
3280 |
+ param: '3' |
|
3281 |
+ }, { |
|
3282 |
+ name: '75%', |
|
3283 |
+ text: this._t('fontScaleSmall'), |
|
3284 |
+ param: '2' |
|
3285 |
+ }, { |
|
3286 |
+ name: '50%', |
|
3287 |
+ text: this._t('fontScaleXSmall'), |
|
3288 |
+ param: '1' |
|
3289 |
+ } |
|
3290 |
+ ]; |
|
3291 |
+ return FontScaleButton.__super__._init.call(this); |
|
3292 |
+ }; |
|
3293 |
+ |
|
3294 |
+ FontScaleButton.prototype._activeStatus = function() { |
|
3295 |
+ var active, endNode, endNodes, range, startNode, startNodes; |
|
3296 |
+ range = this.editor.selection.range(); |
|
3297 |
+ startNodes = this.editor.selection.startNodes(); |
|
3298 |
+ endNodes = this.editor.selection.endNodes(); |
|
3299 |
+ startNode = startNodes.filter('span[style*="font-size"]'); |
|
3300 |
+ endNode = endNodes.filter('span[style*="font-size"]'); |
|
3301 |
+ active = startNodes.length > 0 && endNodes.length > 0 && startNode.is(endNode); |
|
3302 |
+ this.setActive(active); |
|
3303 |
+ return this.active; |
|
3304 |
+ }; |
|
3305 |
+ |
|
3306 |
+ FontScaleButton.prototype.command = function(param) { |
|
3307 |
+ var $scales, containerNode, range; |
|
3308 |
+ range = this.editor.selection.range(); |
|
3309 |
+ if (range.collapsed) { |
|
3310 |
+ return; |
|
3311 |
+ } |
|
3312 |
+ document.execCommand('styleWithCSS', false, true); |
|
3313 |
+ document.execCommand('fontSize', false, param); |
|
3314 |
+ document.execCommand('styleWithCSS', false, false); |
|
3315 |
+ this.editor.selection.reset(); |
|
3316 |
+ this.editor.selection.range(); |
|
3317 |
+ containerNode = this.editor.selection.containerNode(); |
|
3318 |
+ if (containerNode[0].nodeType === Node.TEXT_NODE) { |
|
3319 |
+ $scales = containerNode.closest('span[style*="font-size"]'); |
|
3320 |
+ } else { |
|
3321 |
+ $scales = containerNode.find('span[style*="font-size"]'); |
|
3322 |
+ } |
|
3323 |
+ $scales.each((function(_this) { |
|
3324 |
+ return function(i, n) { |
|
3325 |
+ var $span, size; |
|
3326 |
+ $span = $(n); |
|
3327 |
+ size = n.style.fontSize; |
|
3328 |
+ if (/large|x-large|small|x-small/.test(size)) { |
|
3329 |
+ return $span.css('fontSize', _this.sizeMap[size]); |
|
3330 |
+ } else if (size === 'medium') { |
|
3331 |
+ return $span.replaceWith($span.contents()); |
|
3332 |
+ } |
|
3333 |
+ }; |
|
3334 |
+ })(this)); |
|
3335 |
+ return this.editor.trigger('valuechanged'); |
|
3336 |
+ }; |
|
3337 |
+ |
|
3338 |
+ return FontScaleButton; |
|
3339 |
+ |
|
3340 |
+})(Button); |
|
3341 |
+ |
|
3342 |
+Simditor.Toolbar.addButton(FontScaleButton); |
|
3343 |
+ |
|
3344 |
+BoldButton = (function(superClass) { |
|
3345 |
+ extend(BoldButton, superClass); |
|
3346 |
+ |
|
3347 |
+ function BoldButton() { |
|
3348 |
+ return BoldButton.__super__.constructor.apply(this, arguments); |
|
3349 |
+ } |
|
3350 |
+ |
|
3351 |
+ BoldButton.prototype.name = 'bold'; |
|
3352 |
+ |
|
3353 |
+ BoldButton.prototype.icon = 'bold'; |
|
3354 |
+ |
|
3355 |
+ BoldButton.prototype.htmlTag = 'b, strong'; |
|
3356 |
+ |
|
3357 |
+ BoldButton.prototype.disableTag = 'pre'; |
|
3358 |
+ |
|
3359 |
+ BoldButton.prototype.shortcut = 'cmd+b'; |
|
3360 |
+ |
|
3361 |
+ BoldButton.prototype._init = function() { |
|
3362 |
+ if (this.editor.util.os.mac) { |
|
3363 |
+ this.title = this.title + ' ( Cmd + b )'; |
|
3364 |
+ } else { |
|
3365 |
+ this.title = this.title + ' ( Ctrl + b )'; |
|
3366 |
+ this.shortcut = 'ctrl+b'; |
|
3367 |
+ } |
|
3368 |
+ return BoldButton.__super__._init.call(this); |
|
3369 |
+ }; |
|
3370 |
+ |
|
3371 |
+ BoldButton.prototype._activeStatus = function() { |
|
3372 |
+ var active; |
|
3373 |
+ active = document.queryCommandState('bold') === true; |
|
3374 |
+ this.setActive(active); |
|
3375 |
+ return this.active; |
|
3376 |
+ }; |
|
3377 |
+ |
|
3378 |
+ BoldButton.prototype.command = function() { |
|
3379 |
+ document.execCommand('bold'); |
|
3380 |
+ if (!this.editor.util.support.oninput) { |
|
3381 |
+ this.editor.trigger('valuechanged'); |
|
3382 |
+ } |
|
3383 |
+ return $(document).trigger('selectionchange'); |
|
3384 |
+ }; |
|
3385 |
+ |
|
3386 |
+ return BoldButton; |
|
3387 |
+ |
|
3388 |
+})(Button); |
|
3389 |
+ |
|
3390 |
+Simditor.Toolbar.addButton(BoldButton); |
|
3391 |
+ |
|
3392 |
+ItalicButton = (function(superClass) { |
|
3393 |
+ extend(ItalicButton, superClass); |
|
3394 |
+ |
|
3395 |
+ function ItalicButton() { |
|
3396 |
+ return ItalicButton.__super__.constructor.apply(this, arguments); |
|
3397 |
+ } |
|
3398 |
+ |
|
3399 |
+ ItalicButton.prototype.name = 'italic'; |
|
3400 |
+ |
|
3401 |
+ ItalicButton.prototype.icon = 'italic'; |
|
3402 |
+ |
|
3403 |
+ ItalicButton.prototype.htmlTag = 'i'; |
|
3404 |
+ |
|
3405 |
+ ItalicButton.prototype.disableTag = 'pre'; |
|
3406 |
+ |
|
3407 |
+ ItalicButton.prototype.shortcut = 'cmd+i'; |
|
3408 |
+ |
|
3409 |
+ ItalicButton.prototype._init = function() { |
|
3410 |
+ if (this.editor.util.os.mac) { |
|
3411 |
+ this.title = this.title + " ( Cmd + i )"; |
|
3412 |
+ } else { |
|
3413 |
+ this.title = this.title + " ( Ctrl + i )"; |
|
3414 |
+ this.shortcut = 'ctrl+i'; |
|
3415 |
+ } |
|
3416 |
+ return ItalicButton.__super__._init.call(this); |
|
3417 |
+ }; |
|
3418 |
+ |
|
3419 |
+ ItalicButton.prototype._activeStatus = function() { |
|
3420 |
+ var active; |
|
3421 |
+ active = document.queryCommandState('italic') === true; |
|
3422 |
+ this.setActive(active); |
|
3423 |
+ return this.active; |
|
3424 |
+ }; |
|
3425 |
+ |
|
3426 |
+ ItalicButton.prototype.command = function() { |
|
3427 |
+ document.execCommand('italic'); |
|
3428 |
+ if (!this.editor.util.support.oninput) { |
|
3429 |
+ this.editor.trigger('valuechanged'); |
|
3430 |
+ } |
|
3431 |
+ return $(document).trigger('selectionchange'); |
|
3432 |
+ }; |
|
3433 |
+ |
|
3434 |
+ return ItalicButton; |
|
3435 |
+ |
|
3436 |
+})(Button); |
|
3437 |
+ |
|
3438 |
+Simditor.Toolbar.addButton(ItalicButton); |
|
3439 |
+ |
|
3440 |
+UnderlineButton = (function(superClass) { |
|
3441 |
+ extend(UnderlineButton, superClass); |
|
3442 |
+ |
|
3443 |
+ function UnderlineButton() { |
|
3444 |
+ return UnderlineButton.__super__.constructor.apply(this, arguments); |
|
3445 |
+ } |
|
3446 |
+ |
|
3447 |
+ UnderlineButton.prototype.name = 'underline'; |
|
3448 |
+ |
|
3449 |
+ UnderlineButton.prototype.icon = 'underline'; |
|
3450 |
+ |
|
3451 |
+ UnderlineButton.prototype.htmlTag = 'u'; |
|
3452 |
+ |
|
3453 |
+ UnderlineButton.prototype.disableTag = 'pre'; |
|
3454 |
+ |
|
3455 |
+ UnderlineButton.prototype.shortcut = 'cmd+u'; |
|
3456 |
+ |
|
3457 |
+ UnderlineButton.prototype.render = function() { |
|
3458 |
+ if (this.editor.util.os.mac) { |
|
3459 |
+ this.title = this.title + ' ( Cmd + u )'; |
|
3460 |
+ } else { |
|
3461 |
+ this.title = this.title + ' ( Ctrl + u )'; |
|
3462 |
+ this.shortcut = 'ctrl+u'; |
|
3463 |
+ } |
|
3464 |
+ return UnderlineButton.__super__.render.call(this); |
|
3465 |
+ }; |
|
3466 |
+ |
|
3467 |
+ UnderlineButton.prototype._activeStatus = function() { |
|
3468 |
+ var active; |
|
3469 |
+ active = document.queryCommandState('underline') === true; |
|
3470 |
+ this.setActive(active); |
|
3471 |
+ return this.active; |
|
3472 |
+ }; |
|
3473 |
+ |
|
3474 |
+ UnderlineButton.prototype.command = function() { |
|
3475 |
+ document.execCommand('underline'); |
|
3476 |
+ if (!this.editor.util.support.oninput) { |
|
3477 |
+ this.editor.trigger('valuechanged'); |
|
3478 |
+ } |
|
3479 |
+ return $(document).trigger('selectionchange'); |
|
3480 |
+ }; |
|
3481 |
+ |
|
3482 |
+ return UnderlineButton; |
|
3483 |
+ |
|
3484 |
+})(Button); |
|
3485 |
+ |
|
3486 |
+Simditor.Toolbar.addButton(UnderlineButton); |
|
3487 |
+ |
|
3488 |
+ColorButton = (function(superClass) { |
|
3489 |
+ extend(ColorButton, superClass); |
|
3490 |
+ |
|
3491 |
+ function ColorButton() { |
|
3492 |
+ return ColorButton.__super__.constructor.apply(this, arguments); |
|
3493 |
+ } |
|
3494 |
+ |
|
3495 |
+ ColorButton.prototype.name = 'color'; |
|
3496 |
+ |
|
3497 |
+ ColorButton.prototype.icon = 'tint'; |
|
3498 |
+ |
|
3499 |
+ ColorButton.prototype.disableTag = 'pre'; |
|
3500 |
+ |
|
3501 |
+ ColorButton.prototype.menu = true; |
|
3502 |
+ |
|
3503 |
+ ColorButton.prototype.render = function() { |
|
3504 |
+ var args; |
|
3505 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
3506 |
+ return ColorButton.__super__.render.apply(this, args); |
|
3507 |
+ }; |
|
3508 |
+ |
|
3509 |
+ ColorButton.prototype.renderMenu = function() { |
|
3510 |
+ $('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper); |
|
3511 |
+ this.menuWrapper.on('mousedown', '.color-list', function(e) { |
|
3512 |
+ return false; |
|
3513 |
+ }); |
|
3514 |
+ return this.menuWrapper.on('click', '.font-color', (function(_this) { |
|
3515 |
+ return function(e) { |
|
3516 |
+ var $link, $p, hex, range, rgb, textNode; |
|
3517 |
+ _this.wrapper.removeClass('menu-on'); |
|
3518 |
+ $link = $(e.currentTarget); |
|
3519 |
+ if ($link.hasClass('font-color-default')) { |
|
3520 |
+ $p = _this.editor.body.find('p, li'); |
|
3521 |
+ if (!($p.length > 0)) { |
|
3522 |
+ return; |
|
3523 |
+ } |
|
3524 |
+ rgb = window.getComputedStyle($p[0], null).getPropertyValue('color'); |
|
3525 |
+ hex = _this._convertRgbToHex(rgb); |
|
3526 |
+ } else { |
|
3527 |
+ rgb = window.getComputedStyle($link[0], null).getPropertyValue('background-color'); |
|
3528 |
+ hex = _this._convertRgbToHex(rgb); |
|
3529 |
+ } |
|
3530 |
+ if (!hex) { |
|
3531 |
+ return; |
|
3532 |
+ } |
|
3533 |
+ range = _this.editor.selection.range(); |
|
3534 |
+ if (!$link.hasClass('font-color-default') && range.collapsed) { |
|
3535 |
+ textNode = document.createTextNode(_this._t('coloredText')); |
|
3536 |
+ range.insertNode(textNode); |
|
3537 |
+ range.selectNodeContents(textNode); |
|
3538 |
+ _this.editor.selection.range(range); |
|
3539 |
+ } |
|
3540 |
+ document.execCommand('styleWithCSS', false, true); |
|
3541 |
+ document.execCommand('foreColor', false, hex); |
|
3542 |
+ document.execCommand('styleWithCSS', false, false); |
|
3543 |
+ if (!_this.editor.util.support.oninput) { |
|
3544 |
+ return _this.editor.trigger('valuechanged'); |
|
3545 |
+ } |
|
3546 |
+ }; |
|
3547 |
+ })(this)); |
|
3548 |
+ }; |
|
3549 |
+ |
|
3550 |
+ ColorButton.prototype._convertRgbToHex = function(rgb) { |
|
3551 |
+ var match, re, rgbToHex; |
|
3552 |
+ re = /rgb\((\d+),\s?(\d+),\s?(\d+)\)/g; |
|
3553 |
+ match = re.exec(rgb); |
|
3554 |
+ if (!match) { |
|
3555 |
+ return ''; |
|
3556 |
+ } |
|
3557 |
+ rgbToHex = function(r, g, b) { |
|
3558 |
+ var componentToHex; |
|
3559 |
+ componentToHex = function(c) { |
|
3560 |
+ var hex; |
|
3561 |
+ hex = c.toString(16); |
|
3562 |
+ if (hex.length === 1) { |
|
3563 |
+ return '0' + hex; |
|
3564 |
+ } else { |
|
3565 |
+ return hex; |
|
3566 |
+ } |
|
3567 |
+ }; |
|
3568 |
+ return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); |
|
3569 |
+ }; |
|
3570 |
+ return rgbToHex(match[1] * 1, match[2] * 1, match[3] * 1); |
|
3571 |
+ }; |
|
3572 |
+ |
|
3573 |
+ return ColorButton; |
|
3574 |
+ |
|
3575 |
+})(Button); |
|
3576 |
+ |
|
3577 |
+Simditor.Toolbar.addButton(ColorButton); |
|
3578 |
+ |
|
3579 |
+ListButton = (function(superClass) { |
|
3580 |
+ extend(ListButton, superClass); |
|
3581 |
+ |
|
3582 |
+ function ListButton() { |
|
3583 |
+ return ListButton.__super__.constructor.apply(this, arguments); |
|
3584 |
+ } |
|
3585 |
+ |
|
3586 |
+ ListButton.prototype.type = ''; |
|
3587 |
+ |
|
3588 |
+ ListButton.prototype.disableTag = 'pre, table'; |
|
3589 |
+ |
|
3590 |
+ ListButton.prototype.command = function(param) { |
|
3591 |
+ var $list, $rootNodes, anotherType; |
|
3592 |
+ $rootNodes = this.editor.selection.blockNodes(); |
|
3593 |
+ anotherType = this.type === 'ul' ? 'ol' : 'ul'; |
|
3594 |
+ this.editor.selection.save(); |
|
3595 |
+ $list = null; |
|
3596 |
+ $rootNodes.each((function(_this) { |
|
3597 |
+ return function(i, node) { |
|
3598 |
+ var $node; |
|
3599 |
+ $node = $(node); |
|
3600 |
+ if ($node.is('blockquote, li') || $node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node) || !$.contains(document, node)) { |
|
3601 |
+ return; |
|
3602 |
+ } |
|
3603 |
+ if ($node.is(_this.type)) { |
|
3604 |
+ $node.children('li').each(function(i, li) { |
|
3605 |
+ var $childList, $li; |
|
3606 |
+ $li = $(li); |
|
3607 |
+ $childList = $li.children('ul, ol').insertAfter($node); |
|
3608 |
+ return $('<p/>').append($(li).html() || _this.editor.util.phBr).insertBefore($node); |
|
3609 |
+ }); |
|
3610 |
+ return $node.remove(); |
|
3611 |
+ } else if ($node.is(anotherType)) { |
|
3612 |
+ return $('<' + _this.type + '/>').append($node.contents()).replaceAll($node); |
|
3613 |
+ } else if ($list && $node.prev().is($list)) { |
|
3614 |
+ $('<li/>').append($node.html() || _this.editor.util.phBr).appendTo($list); |
|
3615 |
+ return $node.remove(); |
|
3616 |
+ } else { |
|
3617 |
+ $list = $("<" + _this.type + "><li></li></" + _this.type + ">"); |
|
3618 |
+ $list.find('li').append($node.html() || _this.editor.util.phBr); |
|
3619 |
+ return $list.replaceAll($node); |
|
3620 |
+ } |
|
3621 |
+ }; |
|
3622 |
+ })(this)); |
|
3623 |
+ this.editor.selection.restore(); |
|
3624 |
+ return this.editor.trigger('valuechanged'); |
|
3625 |
+ }; |
|
3626 |
+ |
|
3627 |
+ return ListButton; |
|
3628 |
+ |
|
3629 |
+})(Button); |
|
3630 |
+ |
|
3631 |
+OrderListButton = (function(superClass) { |
|
3632 |
+ extend(OrderListButton, superClass); |
|
3633 |
+ |
|
3634 |
+ function OrderListButton() { |
|
3635 |
+ return OrderListButton.__super__.constructor.apply(this, arguments); |
|
3636 |
+ } |
|
3637 |
+ |
|
3638 |
+ OrderListButton.prototype.type = 'ol'; |
|
3639 |
+ |
|
3640 |
+ OrderListButton.prototype.name = 'ol'; |
|
3641 |
+ |
|
3642 |
+ OrderListButton.prototype.icon = 'list-ol'; |
|
3643 |
+ |
|
3644 |
+ OrderListButton.prototype.htmlTag = 'ol'; |
|
3645 |
+ |
|
3646 |
+ OrderListButton.prototype.shortcut = 'cmd+/'; |
|
3647 |
+ |
|
3648 |
+ OrderListButton.prototype._init = function() { |
|
3649 |
+ if (this.editor.util.os.mac) { |
|
3650 |
+ this.title = this.title + ' ( Cmd + / )'; |
|
3651 |
+ } else { |
|
3652 |
+ this.title = this.title + ' ( ctrl + / )'; |
|
3653 |
+ this.shortcut = 'ctrl+/'; |
|
3654 |
+ } |
|
3655 |
+ return OrderListButton.__super__._init.call(this); |
|
3656 |
+ }; |
|
3657 |
+ |
|
3658 |
+ return OrderListButton; |
|
3659 |
+ |
|
3660 |
+})(ListButton); |
|
3661 |
+ |
|
3662 |
+UnorderListButton = (function(superClass) { |
|
3663 |
+ extend(UnorderListButton, superClass); |
|
3664 |
+ |
|
3665 |
+ function UnorderListButton() { |
|
3666 |
+ return UnorderListButton.__super__.constructor.apply(this, arguments); |
|
3667 |
+ } |
|
3668 |
+ |
|
3669 |
+ UnorderListButton.prototype.type = 'ul'; |
|
3670 |
+ |
|
3671 |
+ UnorderListButton.prototype.name = 'ul'; |
|
3672 |
+ |
|
3673 |
+ UnorderListButton.prototype.icon = 'list-ul'; |
|
3674 |
+ |
|
3675 |
+ UnorderListButton.prototype.htmlTag = 'ul'; |
|
3676 |
+ |
|
3677 |
+ UnorderListButton.prototype.shortcut = 'cmd+.'; |
|
3678 |
+ |
|
3679 |
+ UnorderListButton.prototype._init = function() { |
|
3680 |
+ if (this.editor.util.os.mac) { |
|
3681 |
+ this.title = this.title + ' ( Cmd + . )'; |
|
3682 |
+ } else { |
|
3683 |
+ this.title = this.title + ' ( Ctrl + . )'; |
|
3684 |
+ this.shortcut = 'ctrl+.'; |
|
3685 |
+ } |
|
3686 |
+ return UnorderListButton.__super__._init.call(this); |
|
3687 |
+ }; |
|
3688 |
+ |
|
3689 |
+ return UnorderListButton; |
|
3690 |
+ |
|
3691 |
+})(ListButton); |
|
3692 |
+ |
|
3693 |
+Simditor.Toolbar.addButton(OrderListButton); |
|
3694 |
+ |
|
3695 |
+Simditor.Toolbar.addButton(UnorderListButton); |
|
3696 |
+ |
|
3697 |
+BlockquoteButton = (function(superClass) { |
|
3698 |
+ extend(BlockquoteButton, superClass); |
|
3699 |
+ |
|
3700 |
+ function BlockquoteButton() { |
|
3701 |
+ return BlockquoteButton.__super__.constructor.apply(this, arguments); |
|
3702 |
+ } |
|
3703 |
+ |
|
3704 |
+ BlockquoteButton.prototype.name = 'blockquote'; |
|
3705 |
+ |
|
3706 |
+ BlockquoteButton.prototype.icon = 'quote-left'; |
|
3707 |
+ |
|
3708 |
+ BlockquoteButton.prototype.htmlTag = 'blockquote'; |
|
3709 |
+ |
|
3710 |
+ BlockquoteButton.prototype.disableTag = 'pre, table'; |
|
3711 |
+ |
|
3712 |
+ BlockquoteButton.prototype.command = function() { |
|
3713 |
+ var $rootNodes, clearCache, nodeCache; |
|
3714 |
+ $rootNodes = this.editor.selection.rootNodes(); |
|
3715 |
+ $rootNodes = $rootNodes.filter(function(i, node) { |
|
3716 |
+ return !$(node).parent().is('blockquote'); |
|
3717 |
+ }); |
|
3718 |
+ this.editor.selection.save(); |
|
3719 |
+ nodeCache = []; |
|
3720 |
+ clearCache = (function(_this) { |
|
3721 |
+ return function() { |
|
3722 |
+ if (nodeCache.length > 0) { |
|
3723 |
+ $("<" + _this.htmlTag + "/>").insertBefore(nodeCache[0]).append(nodeCache); |
|
3724 |
+ return nodeCache.length = 0; |
|
3725 |
+ } |
|
3726 |
+ }; |
|
3727 |
+ })(this); |
|
3728 |
+ $rootNodes.each((function(_this) { |
|
3729 |
+ return function(i, node) { |
|
3730 |
+ var $node; |
|
3731 |
+ $node = $(node); |
|
3732 |
+ if (!$node.parent().is(_this.editor.body)) { |
|
3733 |
+ return; |
|
3734 |
+ } |
|
3735 |
+ if ($node.is(_this.htmlTag)) { |
|
3736 |
+ clearCache(); |
|
3737 |
+ return $node.children().unwrap(); |
|
3738 |
+ } else if ($node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node)) { |
|
3739 |
+ return clearCache(); |
|
3740 |
+ } else { |
|
3741 |
+ return nodeCache.push(node); |
|
3742 |
+ } |
|
3743 |
+ }; |
|
3744 |
+ })(this)); |
|
3745 |
+ clearCache(); |
|
3746 |
+ this.editor.selection.restore(); |
|
3747 |
+ return this.editor.trigger('valuechanged'); |
|
3748 |
+ }; |
|
3749 |
+ |
|
3750 |
+ return BlockquoteButton; |
|
3751 |
+ |
|
3752 |
+})(Button); |
|
3753 |
+ |
|
3754 |
+Simditor.Toolbar.addButton(BlockquoteButton); |
|
3755 |
+ |
|
3756 |
+CodeButton = (function(superClass) { |
|
3757 |
+ extend(CodeButton, superClass); |
|
3758 |
+ |
|
3759 |
+ function CodeButton() { |
|
3760 |
+ return CodeButton.__super__.constructor.apply(this, arguments); |
|
3761 |
+ } |
|
3762 |
+ |
|
3763 |
+ CodeButton.prototype.name = 'code'; |
|
3764 |
+ |
|
3765 |
+ CodeButton.prototype.icon = 'code'; |
|
3766 |
+ |
|
3767 |
+ CodeButton.prototype.htmlTag = 'pre'; |
|
3768 |
+ |
|
3769 |
+ CodeButton.prototype.disableTag = 'ul, ol, table'; |
|
3770 |
+ |
|
3771 |
+ CodeButton.prototype._init = function() { |
|
3772 |
+ CodeButton.__super__._init.call(this); |
|
3773 |
+ this.editor.on('decorate', (function(_this) { |
|
3774 |
+ return function(e, $el) { |
|
3775 |
+ return $el.find('pre').each(function(i, pre) { |
|
3776 |
+ return _this.decorate($(pre)); |
|
3777 |
+ }); |
|
3778 |
+ }; |
|
3779 |
+ })(this)); |
|
3780 |
+ return this.editor.on('undecorate', (function(_this) { |
|
3781 |
+ return function(e, $el) { |
|
3782 |
+ return $el.find('pre').each(function(i, pre) { |
|
3783 |
+ return _this.undecorate($(pre)); |
|
3784 |
+ }); |
|
3785 |
+ }; |
|
3786 |
+ })(this)); |
|
3787 |
+ }; |
|
3788 |
+ |
|
3789 |
+ CodeButton.prototype.render = function() { |
|
3790 |
+ var args; |
|
3791 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
3792 |
+ CodeButton.__super__.render.apply(this, args); |
|
3793 |
+ return this.popover = new CodePopover({ |
|
3794 |
+ button: this |
|
3795 |
+ }); |
|
3796 |
+ }; |
|
3797 |
+ |
|
3798 |
+ CodeButton.prototype._checkMode = function() { |
|
3799 |
+ var $blockNodes, range; |
|
3800 |
+ range = this.editor.selection.range(); |
|
3801 |
+ if (($blockNodes = $(range.cloneContents()).find(this.editor.util.blockNodes.join(','))) > 0 || (range.collapsed && this.editor.selection.startNodes().filter('code').length === 0)) { |
|
3802 |
+ this.inlineMode = false; |
|
3803 |
+ return this.htmlTag = 'pre'; |
|
3804 |
+ } else { |
|
3805 |
+ this.inlineMode = true; |
|
3806 |
+ return this.htmlTag = 'code'; |
|
3807 |
+ } |
|
3808 |
+ }; |
|
3809 |
+ |
|
3810 |
+ CodeButton.prototype._status = function() { |
|
3811 |
+ this._checkMode(); |
|
3812 |
+ CodeButton.__super__._status.call(this); |
|
3813 |
+ if (this.inlineMode) { |
|
3814 |
+ return; |
|
3815 |
+ } |
|
3816 |
+ if (this.active) { |
|
3817 |
+ return this.popover.show(this.node); |
|
3818 |
+ } else { |
|
3819 |
+ return this.popover.hide(); |
|
3820 |
+ } |
|
3821 |
+ }; |
|
3822 |
+ |
|
3823 |
+ CodeButton.prototype.decorate = function($pre) { |
|
3824 |
+ var $code, lang, ref, ref1; |
|
3825 |
+ $code = $pre.find('> code'); |
|
3826 |
+ if ($code.length > 0) { |
|
3827 |
+ lang = (ref = $code.attr('class')) != null ? (ref1 = ref.match(/lang-(\S+)/)) != null ? ref1[1] : void 0 : void 0; |
|
3828 |
+ $code.contents().unwrap(); |
|
3829 |
+ if (lang) { |
|
3830 |
+ return $pre.attr('data-lang', lang); |
|
3831 |
+ } |
|
3832 |
+ } |
|
3833 |
+ }; |
|
3834 |
+ |
|
3835 |
+ CodeButton.prototype.undecorate = function($pre) { |
|
3836 |
+ var $code, lang; |
|
3837 |
+ lang = $pre.attr('data-lang'); |
|
3838 |
+ $code = $('<code/>'); |
|
3839 |
+ if (lang && lang !== -1) { |
|
3840 |
+ $code.addClass('lang-' + lang); |
|
3841 |
+ } |
|
3842 |
+ return $pre.wrapInner($code).removeAttr('data-lang'); |
|
3843 |
+ }; |
|
3844 |
+ |
|
3845 |
+ CodeButton.prototype.command = function() { |
|
3846 |
+ if (this.inlineMode) { |
|
3847 |
+ return this._inlineCommand(); |
|
3848 |
+ } else { |
|
3849 |
+ return this._blockCommand(); |
|
3850 |
+ } |
|
3851 |
+ }; |
|
3852 |
+ |
|
3853 |
+ CodeButton.prototype._blockCommand = function() { |
|
3854 |
+ var $rootNodes, clearCache, nodeCache, resultNodes; |
|
3855 |
+ $rootNodes = this.editor.selection.rootNodes(); |
|
3856 |
+ nodeCache = []; |
|
3857 |
+ resultNodes = []; |
|
3858 |
+ clearCache = (function(_this) { |
|
3859 |
+ return function() { |
|
3860 |
+ var $pre; |
|
3861 |
+ if (!(nodeCache.length > 0)) { |
|
3862 |
+ return; |
|
3863 |
+ } |
|
3864 |
+ $pre = $("<" + _this.htmlTag + "/>").insertBefore(nodeCache[0]).text(_this.editor.formatter.clearHtml(nodeCache)); |
|
3865 |
+ resultNodes.push($pre[0]); |
|
3866 |
+ return nodeCache.length = 0; |
|
3867 |
+ }; |
|
3868 |
+ })(this); |
|
3869 |
+ $rootNodes.each((function(_this) { |
|
3870 |
+ return function(i, node) { |
|
3871 |
+ var $node, $p; |
|
3872 |
+ $node = $(node); |
|
3873 |
+ if ($node.is(_this.htmlTag)) { |
|
3874 |
+ clearCache(); |
|
3875 |
+ $p = $('<p/>').append($node.html().replace('\n', '<br/>')).replaceAll($node); |
|
3876 |
+ return resultNodes.push($p[0]); |
|
3877 |
+ } else if ($node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node) || $node.is('blockquote')) { |
|
3878 |
+ return clearCache(); |
|
3879 |
+ } else { |
|
3880 |
+ return nodeCache.push(node); |
|
3881 |
+ } |
|
3882 |
+ }; |
|
3883 |
+ })(this)); |
|
3884 |
+ clearCache(); |
|
3885 |
+ this.editor.selection.setRangeAtEndOf($(resultNodes).last()); |
|
3886 |
+ return this.editor.trigger('valuechanged'); |
|
3887 |
+ }; |
|
3888 |
+ |
|
3889 |
+ CodeButton.prototype._inlineCommand = function() { |
|
3890 |
+ var $code, $contents, range; |
|
3891 |
+ range = this.editor.selection.range(); |
|
3892 |
+ if (this.active) { |
|
3893 |
+ range.selectNodeContents(this.node[0]); |
|
3894 |
+ this.editor.selection.save(range); |
|
3895 |
+ this.node.contents().unwrap(); |
|
3896 |
+ this.editor.selection.restore(); |
|
3897 |
+ } else { |
|
3898 |
+ $contents = $(range.extractContents()); |
|
3899 |
+ $code = $("<" + this.htmlTag + "/>").append($contents.contents()); |
|
3900 |
+ range.insertNode($code[0]); |
|
3901 |
+ range.selectNodeContents($code[0]); |
|
3902 |
+ this.editor.selection.range(range); |
|
3903 |
+ } |
|
3904 |
+ return this.editor.trigger('valuechanged'); |
|
3905 |
+ }; |
|
3906 |
+ |
|
3907 |
+ return CodeButton; |
|
3908 |
+ |
|
3909 |
+})(Button); |
|
3910 |
+ |
|
3911 |
+CodePopover = (function(superClass) { |
|
3912 |
+ extend(CodePopover, superClass); |
|
3913 |
+ |
|
3914 |
+ function CodePopover() { |
|
3915 |
+ return CodePopover.__super__.constructor.apply(this, arguments); |
|
3916 |
+ } |
|
3917 |
+ |
|
3918 |
+ CodePopover.prototype.render = function() { |
|
3919 |
+ var $option, k, lang, len, ref; |
|
3920 |
+ this._tpl = "<div class=\"code-settings\">\n <div class=\"settings-field\">\n <select class=\"select-lang\">\n <option value=\"-1\">" + (this._t('selectLanguage')) + "</option>\n </select>\n </div>\n</div>"; |
|
3921 |
+ this.langs = this.editor.opts.codeLanguages || [ |
|
3922 |
+ { |
|
3923 |
+ name: 'Bash', |
|
3924 |
+ value: 'bash' |
|
3925 |
+ }, { |
|
3926 |
+ name: 'C++', |
|
3927 |
+ value: 'c++' |
|
3928 |
+ }, { |
|
3929 |
+ name: 'C#', |
|
3930 |
+ value: 'cs' |
|
3931 |
+ }, { |
|
3932 |
+ name: 'CSS', |
|
3933 |
+ value: 'css' |
|
3934 |
+ }, { |
|
3935 |
+ name: 'Erlang', |
|
3936 |
+ value: 'erlang' |
|
3937 |
+ }, { |
|
3938 |
+ name: 'Less', |
|
3939 |
+ value: 'less' |
|
3940 |
+ }, { |
|
3941 |
+ name: 'Sass', |
|
3942 |
+ value: 'sass' |
|
3943 |
+ }, { |
|
3944 |
+ name: 'Diff', |
|
3945 |
+ value: 'diff' |
|
3946 |
+ }, { |
|
3947 |
+ name: 'CoffeeScript', |
|
3948 |
+ value: 'coffeescript' |
|
3949 |
+ }, { |
|
3950 |
+ name: 'HTML,XML', |
|
3951 |
+ value: 'html' |
|
3952 |
+ }, { |
|
3953 |
+ name: 'JSON', |
|
3954 |
+ value: 'json' |
|
3955 |
+ }, { |
|
3956 |
+ name: 'Java', |
|
3957 |
+ value: 'java' |
|
3958 |
+ }, { |
|
3959 |
+ name: 'JavaScript', |
|
3960 |
+ value: 'js' |
|
3961 |
+ }, { |
|
3962 |
+ name: 'Markdown', |
|
3963 |
+ value: 'markdown' |
|
3964 |
+ }, { |
|
3965 |
+ name: 'Objective C', |
|
3966 |
+ value: 'oc' |
|
3967 |
+ }, { |
|
3968 |
+ name: 'PHP', |
|
3969 |
+ value: 'php' |
|
3970 |
+ }, { |
|
3971 |
+ name: 'Perl', |
|
3972 |
+ value: 'parl' |
|
3973 |
+ }, { |
|
3974 |
+ name: 'Python', |
|
3975 |
+ value: 'python' |
|
3976 |
+ }, { |
|
3977 |
+ name: 'Ruby', |
|
3978 |
+ value: 'ruby' |
|
3979 |
+ }, { |
|
3980 |
+ name: 'SQL', |
|
3981 |
+ value: 'sql' |
|
3982 |
+ } |
|
3983 |
+ ]; |
|
3984 |
+ this.el.addClass('code-popover').append(this._tpl); |
|
3985 |
+ this.selectEl = this.el.find('.select-lang'); |
|
3986 |
+ ref = this.langs; |
|
3987 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
3988 |
+ lang = ref[k]; |
|
3989 |
+ $option = $('<option/>', { |
|
3990 |
+ text: lang.name, |
|
3991 |
+ value: lang.value |
|
3992 |
+ }).appendTo(this.selectEl); |
|
3993 |
+ } |
|
3994 |
+ this.selectEl.on('change', (function(_this) { |
|
3995 |
+ return function(e) { |
|
3996 |
+ var selected; |
|
3997 |
+ _this.lang = _this.selectEl.val(); |
|
3998 |
+ selected = _this.target.hasClass('selected'); |
|
3999 |
+ _this.target.removeClass().removeAttr('data-lang'); |
|
4000 |
+ if (_this.lang !== -1) { |
|
4001 |
+ _this.target.attr('data-lang', _this.lang); |
|
4002 |
+ } |
|
4003 |
+ if (selected) { |
|
4004 |
+ _this.target.addClass('selected'); |
|
4005 |
+ } |
|
4006 |
+ return _this.editor.trigger('valuechanged'); |
|
4007 |
+ }; |
|
4008 |
+ })(this)); |
|
4009 |
+ return this.editor.on('valuechanged', (function(_this) { |
|
4010 |
+ return function(e) { |
|
4011 |
+ if (_this.active) { |
|
4012 |
+ return _this.refresh(); |
|
4013 |
+ } |
|
4014 |
+ }; |
|
4015 |
+ })(this)); |
|
4016 |
+ }; |
|
4017 |
+ |
|
4018 |
+ CodePopover.prototype.show = function() { |
|
4019 |
+ var args; |
|
4020 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
4021 |
+ CodePopover.__super__.show.apply(this, args); |
|
4022 |
+ this.lang = this.target.attr('data-lang'); |
|
4023 |
+ if (this.lang != null) { |
|
4024 |
+ return this.selectEl.val(this.lang); |
|
4025 |
+ } else { |
|
4026 |
+ return this.selectEl.val(-1); |
|
4027 |
+ } |
|
4028 |
+ }; |
|
4029 |
+ |
|
4030 |
+ return CodePopover; |
|
4031 |
+ |
|
4032 |
+})(Popover); |
|
4033 |
+ |
|
4034 |
+Simditor.Toolbar.addButton(CodeButton); |
|
4035 |
+ |
|
4036 |
+LinkButton = (function(superClass) { |
|
4037 |
+ extend(LinkButton, superClass); |
|
4038 |
+ |
|
4039 |
+ function LinkButton() { |
|
4040 |
+ return LinkButton.__super__.constructor.apply(this, arguments); |
|
4041 |
+ } |
|
4042 |
+ |
|
4043 |
+ LinkButton.prototype.name = 'link'; |
|
4044 |
+ |
|
4045 |
+ LinkButton.prototype.icon = 'link'; |
|
4046 |
+ |
|
4047 |
+ LinkButton.prototype.htmlTag = 'a'; |
|
4048 |
+ |
|
4049 |
+ LinkButton.prototype.disableTag = 'pre'; |
|
4050 |
+ |
|
4051 |
+ LinkButton.prototype.render = function() { |
|
4052 |
+ var args; |
|
4053 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
4054 |
+ LinkButton.__super__.render.apply(this, args); |
|
4055 |
+ return this.popover = new LinkPopover({ |
|
4056 |
+ button: this |
|
4057 |
+ }); |
|
4058 |
+ }; |
|
4059 |
+ |
|
4060 |
+ LinkButton.prototype._status = function() { |
|
4061 |
+ LinkButton.__super__._status.call(this); |
|
4062 |
+ if (this.active && !this.editor.selection.rangeAtEndOf(this.node)) { |
|
4063 |
+ return this.popover.show(this.node); |
|
4064 |
+ } else { |
|
4065 |
+ return this.popover.hide(); |
|
4066 |
+ } |
|
4067 |
+ }; |
|
4068 |
+ |
|
4069 |
+ LinkButton.prototype.command = function() { |
|
4070 |
+ var $contents, $link, $newBlock, linkText, range, txtNode; |
|
4071 |
+ range = this.editor.selection.range(); |
|
4072 |
+ if (this.active) { |
|
4073 |
+ txtNode = document.createTextNode(this.node.text()); |
|
4074 |
+ this.node.replaceWith(txtNode); |
|
4075 |
+ range.selectNode(txtNode); |
|
4076 |
+ } else { |
|
4077 |
+ $contents = $(range.extractContents()); |
|
4078 |
+ linkText = this.editor.formatter.clearHtml($contents.contents(), false); |
|
4079 |
+ $link = $('<a/>', { |
|
4080 |
+ href: 'http://www.example.com', |
|
4081 |
+ target: '_blank', |
|
4082 |
+ text: linkText || this._t('linkText') |
|
4083 |
+ }); |
|
4084 |
+ if (this.editor.selection.blockNodes().length > 0) { |
|
4085 |
+ range.insertNode($link[0]); |
|
4086 |
+ } else { |
|
4087 |
+ $newBlock = $('<p/>').append($link); |
|
4088 |
+ range.insertNode($newBlock[0]); |
|
4089 |
+ } |
|
4090 |
+ range.selectNodeContents($link[0]); |
|
4091 |
+ this.popover.one('popovershow', (function(_this) { |
|
4092 |
+ return function() { |
|
4093 |
+ if (linkText) { |
|
4094 |
+ _this.popover.urlEl.focus(); |
|
4095 |
+ return _this.popover.urlEl[0].select(); |
|
4096 |
+ } else { |
|
4097 |
+ _this.popover.textEl.focus(); |
|
4098 |
+ return _this.popover.textEl[0].select(); |
|
4099 |
+ } |
|
4100 |
+ }; |
|
4101 |
+ })(this)); |
|
4102 |
+ } |
|
4103 |
+ this.editor.selection.range(range); |
|
4104 |
+ return this.editor.trigger('valuechanged'); |
|
4105 |
+ }; |
|
4106 |
+ |
|
4107 |
+ return LinkButton; |
|
4108 |
+ |
|
4109 |
+})(Button); |
|
4110 |
+ |
|
4111 |
+LinkPopover = (function(superClass) { |
|
4112 |
+ extend(LinkPopover, superClass); |
|
4113 |
+ |
|
4114 |
+ function LinkPopover() { |
|
4115 |
+ return LinkPopover.__super__.constructor.apply(this, arguments); |
|
4116 |
+ } |
|
4117 |
+ |
|
4118 |
+ LinkPopover.prototype.render = function() { |
|
4119 |
+ var tpl; |
|
4120 |
+ tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('linkText')) + "</label>\n <input class=\"link-text\" type=\"text\"/>\n <a class=\"btn-unlink\" href=\"javascript:;\" title=\"" + (this._t('removeLink')) + "\"\n tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-unlink\"></span>\n </a>\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('linkUrl')) + "</label>\n <input class=\"link-url\" type=\"text\"/>\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('linkTarget')) + "</label>\n <select class=\"link-target\">\n <option value=\"_blank\">" + (this._t('openLinkInNewWindow')) + " (_blank)</option>\n <option value=\"_self\">" + (this._t('openLinkInCurrentWindow')) + " (_self)</option>\n </select>\n </div>\n</div>"; |
|
4121 |
+ this.el.addClass('link-popover').append(tpl); |
|
4122 |
+ this.textEl = this.el.find('.link-text'); |
|
4123 |
+ this.urlEl = this.el.find('.link-url'); |
|
4124 |
+ this.unlinkEl = this.el.find('.btn-unlink'); |
|
4125 |
+ this.selectTarget = this.el.find('.link-target'); |
|
4126 |
+ this.textEl.on('keyup', (function(_this) { |
|
4127 |
+ return function(e) { |
|
4128 |
+ if (e.which === 13) { |
|
4129 |
+ return; |
|
4130 |
+ } |
|
4131 |
+ _this.target.text(_this.textEl.val()); |
|
4132 |
+ return _this.editor.inputManager.throttledValueChanged(); |
|
4133 |
+ }; |
|
4134 |
+ })(this)); |
|
4135 |
+ this.urlEl.on('keyup', (function(_this) { |
|
4136 |
+ return function(e) { |
|
4137 |
+ var val; |
|
4138 |
+ if (e.which === 13) { |
|
4139 |
+ return; |
|
4140 |
+ } |
|
4141 |
+ val = _this.urlEl.val(); |
|
4142 |
+ if (!(/https?:\/\/|^\//ig.test(val) || !val)) { |
|
4143 |
+ val = 'http://' + val; |
|
4144 |
+ } |
|
4145 |
+ _this.target.attr('href', val); |
|
4146 |
+ return _this.editor.inputManager.throttledValueChanged(); |
|
4147 |
+ }; |
|
4148 |
+ })(this)); |
|
4149 |
+ $([this.urlEl[0], this.textEl[0]]).on('keydown', (function(_this) { |
|
4150 |
+ return function(e) { |
|
4151 |
+ var range; |
|
4152 |
+ if (e.which === 13 || e.which === 27 || (!e.shiftKey && e.which === 9 && $(e.target).hasClass('link-url'))) { |
|
4153 |
+ e.preventDefault(); |
|
4154 |
+ range = document.createRange(); |
|
4155 |
+ _this.editor.selection.setRangeAfter(_this.target, range); |
|
4156 |
+ _this.hide(); |
|
4157 |
+ return _this.editor.inputManager.throttledValueChanged(); |
|
4158 |
+ } |
|
4159 |
+ }; |
|
4160 |
+ })(this)); |
|
4161 |
+ this.unlinkEl.on('click', (function(_this) { |
|
4162 |
+ return function(e) { |
|
4163 |
+ var range, txtNode; |
|
4164 |
+ txtNode = document.createTextNode(_this.target.text()); |
|
4165 |
+ _this.target.replaceWith(txtNode); |
|
4166 |
+ _this.hide(); |
|
4167 |
+ range = document.createRange(); |
|
4168 |
+ _this.editor.selection.setRangeAfter(txtNode, range); |
|
4169 |
+ return _this.editor.inputManager.throttledValueChanged(); |
|
4170 |
+ }; |
|
4171 |
+ })(this)); |
|
4172 |
+ return this.selectTarget.on('change', (function(_this) { |
|
4173 |
+ return function(e) { |
|
4174 |
+ _this.target.attr('target', _this.selectTarget.val()); |
|
4175 |
+ return _this.editor.inputManager.throttledValueChanged(); |
|
4176 |
+ }; |
|
4177 |
+ })(this)); |
|
4178 |
+ }; |
|
4179 |
+ |
|
4180 |
+ LinkPopover.prototype.show = function() { |
|
4181 |
+ var args; |
|
4182 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
4183 |
+ LinkPopover.__super__.show.apply(this, args); |
|
4184 |
+ this.textEl.val(this.target.text()); |
|
4185 |
+ return this.urlEl.val(this.target.attr('href')); |
|
4186 |
+ }; |
|
4187 |
+ |
|
4188 |
+ return LinkPopover; |
|
4189 |
+ |
|
4190 |
+})(Popover); |
|
4191 |
+ |
|
4192 |
+Simditor.Toolbar.addButton(LinkButton); |
|
4193 |
+ |
|
4194 |
+ImageButton = (function(superClass) { |
|
4195 |
+ extend(ImageButton, superClass); |
|
4196 |
+ |
|
4197 |
+ function ImageButton() { |
|
4198 |
+ return ImageButton.__super__.constructor.apply(this, arguments); |
|
4199 |
+ } |
|
4200 |
+ |
|
4201 |
+ ImageButton.prototype.name = 'image'; |
|
4202 |
+ |
|
4203 |
+ ImageButton.prototype.icon = 'picture-o'; |
|
4204 |
+ |
|
4205 |
+ ImageButton.prototype.htmlTag = 'img'; |
|
4206 |
+ |
|
4207 |
+ ImageButton.prototype.disableTag = 'pre, table'; |
|
4208 |
+ |
|
4209 |
+ ImageButton.prototype.defaultImage = ''; |
|
4210 |
+ |
|
4211 |
+ ImageButton.prototype.needFocus = false; |
|
4212 |
+ |
|
4213 |
+ ImageButton.prototype._init = function() { |
|
4214 |
+ var item, k, len, ref; |
|
4215 |
+ if (this.editor.opts.imageButton) { |
|
4216 |
+ if (Array.isArray(this.editor.opts.imageButton)) { |
|
4217 |
+ this.menu = []; |
|
4218 |
+ ref = this.editor.opts.imageButton; |
|
4219 |
+ for (k = 0, len = ref.length; k < len; k++) { |
|
4220 |
+ item = ref[k]; |
|
4221 |
+ this.menu.push({ |
|
4222 |
+ name: item + '-image', |
|
4223 |
+ text: this._t(item + 'Image') |
|
4224 |
+ }); |
|
4225 |
+ } |
|
4226 |
+ } else { |
|
4227 |
+ this.menu = false; |
|
4228 |
+ } |
|
4229 |
+ } else { |
|
4230 |
+ if (this.editor.uploader != null) { |
|
4231 |
+ this.menu = [ |
|
4232 |
+ { |
|
4233 |
+ name: 'upload-image', |
|
4234 |
+ text: this._t('uploadImage') |
|
4235 |
+ }, { |
|
4236 |
+ name: 'external-image', |
|
4237 |
+ text: this._t('externalImage') |
|
4238 |
+ } |
|
4239 |
+ ]; |
|
4240 |
+ } else { |
|
4241 |
+ this.menu = false; |
|
4242 |
+ } |
|
4243 |
+ } |
|
4244 |
+ this.defaultImage = this.editor.opts.defaultImage; |
|
4245 |
+ this.editor.body.on('click', 'img:not([data-non-image])', (function(_this) { |
|
4246 |
+ return function(e) { |
|
4247 |
+ var $img, range; |
|
4248 |
+ $img = $(e.currentTarget); |
|
4249 |
+ range = document.createRange(); |
|
4250 |
+ range.selectNode($img[0]); |
|
4251 |
+ _this.editor.selection.range(range); |
|
4252 |
+ if (!_this.editor.util.support.onselectionchange) { |
|
4253 |
+ _this.editor.trigger('selectionchanged'); |
|
4254 |
+ } |
|
4255 |
+ return false; |
|
4256 |
+ }; |
|
4257 |
+ })(this)); |
|
4258 |
+ this.editor.body.on('mouseup', 'img:not([data-non-image])', function(e) { |
|
4259 |
+ return false; |
|
4260 |
+ }); |
|
4261 |
+ this.editor.on('selectionchanged.image', (function(_this) { |
|
4262 |
+ return function() { |
|
4263 |
+ var $contents, $img, range; |
|
4264 |
+ range = _this.editor.selection.range(); |
|
4265 |
+ if (range == null) { |
|
4266 |
+ return; |
|
4267 |
+ } |
|
4268 |
+ $contents = $(range.cloneContents()).contents(); |
|
4269 |
+ if ($contents.length === 1 && $contents.is('img:not([data-non-image])')) { |
|
4270 |
+ $img = $(range.startContainer).contents().eq(range.startOffset); |
|
4271 |
+ return _this.popover.show($img); |
|
4272 |
+ } else { |
|
4273 |
+ return _this.popover.hide(); |
|
4274 |
+ } |
|
4275 |
+ }; |
|
4276 |
+ })(this)); |
|
4277 |
+ this.editor.on('valuechanged.image', (function(_this) { |
|
4278 |
+ return function() { |
|
4279 |
+ var $masks; |
|
4280 |
+ $masks = _this.editor.wrapper.find('.simditor-image-loading'); |
|
4281 |
+ if (!($masks.length > 0)) { |
|
4282 |
+ return; |
|
4283 |
+ } |
|
4284 |
+ return $masks.each(function(i, mask) { |
|
4285 |
+ var $img, $mask, file; |
|
4286 |
+ $mask = $(mask); |
|
4287 |
+ $img = $mask.data('img'); |
|
4288 |
+ if (!($img && $img.parent().length > 0)) { |
|
4289 |
+ $mask.remove(); |
|
4290 |
+ if ($img) { |
|
4291 |
+ file = $img.data('file'); |
|
4292 |
+ if (file) { |
|
4293 |
+ _this.editor.uploader.cancel(file); |
|
4294 |
+ if (_this.editor.body.find('img.uploading').length < 1) { |
|
4295 |
+ return _this.editor.uploader.trigger('uploadready', [file]); |
|
4296 |
+ } |
|
4297 |
+ } |
|
4298 |
+ } |
|
4299 |
+ } |
|
4300 |
+ }); |
|
4301 |
+ }; |
|
4302 |
+ })(this)); |
|
4303 |
+ return ImageButton.__super__._init.call(this); |
|
4304 |
+ }; |
|
4305 |
+ |
|
4306 |
+ ImageButton.prototype.render = function() { |
|
4307 |
+ var args; |
|
4308 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
4309 |
+ ImageButton.__super__.render.apply(this, args); |
|
4310 |
+ this.popover = new ImagePopover({ |
|
4311 |
+ button: this |
|
4312 |
+ }); |
|
4313 |
+ if (this.editor.opts.imageButton === 'upload') { |
|
4314 |
+ return this._initUploader(this.el); |
|
4315 |
+ } |
|
4316 |
+ }; |
|
4317 |
+ |
|
4318 |
+ ImageButton.prototype.renderMenu = function() { |
|
4319 |
+ ImageButton.__super__.renderMenu.call(this); |
|
4320 |
+ return this._initUploader(); |
|
4321 |
+ }; |
|
4322 |
+ |
|
4323 |
+ ImageButton.prototype._initUploader = function($uploadItem) { |
|
4324 |
+ var $input, createInput, uploadProgress; |
|
4325 |
+ if ($uploadItem == null) { |
|
4326 |
+ $uploadItem = this.menuEl.find('.menu-item-upload-image'); |
|
4327 |
+ } |
|
4328 |
+ if (this.editor.uploader == null) { |
|
4329 |
+ this.el.find('.btn-upload').remove(); |
|
4330 |
+ return; |
|
4331 |
+ } |
|
4332 |
+ $input = null; |
|
4333 |
+ createInput = (function(_this) { |
|
4334 |
+ return function() { |
|
4335 |
+ if ($input) { |
|
4336 |
+ $input.remove(); |
|
4337 |
+ } |
|
4338 |
+ return $input = $('<input/>', { |
|
4339 |
+ type: 'file', |
|
4340 |
+ title: _this._t('uploadImage'), |
|
4341 |
+ multiple: true, |
|
4342 |
+ accept: 'image/*' |
|
4343 |
+ }).appendTo($uploadItem); |
|
4344 |
+ }; |
|
4345 |
+ })(this); |
|
4346 |
+ createInput(); |
|
4347 |
+ $uploadItem.on('click mousedown', 'input[type=file]', function(e) { |
|
4348 |
+ return e.stopPropagation(); |
|
4349 |
+ }); |
|
4350 |
+ $uploadItem.on('change', 'input[type=file]', (function(_this) { |
|
4351 |
+ return function(e) { |
|
4352 |
+ if (_this.editor.inputManager.focused) { |
|
4353 |
+ _this.editor.uploader.upload($input, { |
|
4354 |
+ inline: true |
|
4355 |
+ }); |
|
4356 |
+ createInput(); |
|
4357 |
+ } else { |
|
4358 |
+ _this.editor.one('focus', function(e) { |
|
4359 |
+ _this.editor.uploader.upload($input, { |
|
4360 |
+ inline: true |
|
4361 |
+ }); |
|
4362 |
+ return createInput(); |
|
4363 |
+ }); |
|
4364 |
+ _this.editor.focus(); |
|
4365 |
+ } |
|
4366 |
+ return _this.wrapper.removeClass('menu-on'); |
|
4367 |
+ }; |
|
4368 |
+ })(this)); |
|
4369 |
+ this.editor.uploader.on('beforeupload', (function(_this) { |
|
4370 |
+ return function(e, file) { |
|
4371 |
+ var $img; |
|
4372 |
+ if (!file.inline) { |
|
4373 |
+ return; |
|
4374 |
+ } |
|
4375 |
+ if (file.img) { |
|
4376 |
+ $img = $(file.img); |
|
4377 |
+ } else { |
|
4378 |
+ $img = _this.createImage(file.name); |
|
4379 |
+ file.img = $img; |
|
4380 |
+ } |
|
4381 |
+ $img.addClass('uploading'); |
|
4382 |
+ $img.data('file', file); |
|
4383 |
+ return _this.editor.uploader.readImageFile(file.obj, function(img) { |
|
4384 |
+ var src; |
|
4385 |
+ if (!$img.hasClass('uploading')) { |
|
4386 |
+ return; |
|
4387 |
+ } |
|
4388 |
+ src = img ? img.src : _this.defaultImage; |
|
4389 |
+ return _this.loadImage($img, src, function() { |
|
4390 |
+ if (_this.popover.active) { |
|
4391 |
+ _this.popover.refresh(); |
|
4392 |
+ return _this.popover.srcEl.val(_this._t('uploading')).prop('disabled', true); |
|
4393 |
+ } |
|
4394 |
+ }); |
|
4395 |
+ }); |
|
4396 |
+ }; |
|
4397 |
+ })(this)); |
|
4398 |
+ uploadProgress = $.proxy(this.editor.util.throttle(function(e, file, loaded, total) { |
|
4399 |
+ var $img, $mask, percent; |
|
4400 |
+ if (!file.inline) { |
|
4401 |
+ return; |
|
4402 |
+ } |
|
4403 |
+ $mask = file.img.data('mask'); |
|
4404 |
+ if (!$mask) { |
|
4405 |
+ return; |
|
4406 |
+ } |
|
4407 |
+ $img = $mask.data('img'); |
|
4408 |
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) { |
|
4409 |
+ $mask.remove(); |
|
4410 |
+ return; |
|
4411 |
+ } |
|
4412 |
+ percent = loaded / total; |
|
4413 |
+ percent = (percent * 100).toFixed(0); |
|
4414 |
+ if (percent > 99) { |
|
4415 |
+ percent = 99; |
|
4416 |
+ } |
|
4417 |
+ return $mask.find('.progress').height((100 - percent) + "%"); |
|
4418 |
+ }, 500), this); |
|
4419 |
+ this.editor.uploader.on('uploadprogress', uploadProgress); |
|
4420 |
+ this.editor.uploader.on('uploadsuccess', (function(_this) { |
|
4421 |
+ return function(e, file, result) { |
|
4422 |
+ var $img, img_path, msg; |
|
4423 |
+ if (!file.inline) { |
|
4424 |
+ return; |
|
4425 |
+ } |
|
4426 |
+ $img = file.img; |
|
4427 |
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) { |
|
4428 |
+ return; |
|
4429 |
+ } |
|
4430 |
+ if (typeof result !== 'object') { |
|
4431 |
+ try { |
|
4432 |
+ result = $.parseJSON(result); |
|
4433 |
+ } catch (_error) { |
|
4434 |
+ e = _error; |
|
4435 |
+ result = { |
|
4436 |
+ success: false |
|
4437 |
+ }; |
|
4438 |
+ } |
|
4439 |
+ } |
|
4440 |
+ if (result.success === false) { |
|
4441 |
+ msg = result.msg || _this._t('uploadFailed'); |
|
4442 |
+ alert(msg); |
|
4443 |
+ img_path = _this.defaultImage; |
|
4444 |
+ } else { |
|
4445 |
+ img_path = result.file_path; |
|
4446 |
+ } |
|
4447 |
+ _this.loadImage($img, img_path, function() { |
|
4448 |
+ var $mask; |
|
4449 |
+ $img.removeData('file'); |
|
4450 |
+ $img.removeClass('uploading').removeClass('loading'); |
|
4451 |
+ $mask = $img.data('mask'); |
|
4452 |
+ if ($mask) { |
|
4453 |
+ $mask.remove(); |
|
4454 |
+ } |
|
4455 |
+ $img.removeData('mask'); |
|
4456 |
+ _this.editor.trigger('valuechanged'); |
|
4457 |
+ if (_this.editor.body.find('img.uploading').length < 1) { |
|
4458 |
+ return _this.editor.uploader.trigger('uploadready', [file, result]); |
|
4459 |
+ } |
|
4460 |
+ }); |
|
4461 |
+ if (_this.popover.active) { |
|
4462 |
+ _this.popover.srcEl.prop('disabled', false); |
|
4463 |
+ return _this.popover.srcEl.val(result.file_path); |
|
4464 |
+ } |
|
4465 |
+ }; |
|
4466 |
+ })(this)); |
|
4467 |
+ return this.editor.uploader.on('uploaderror', (function(_this) { |
|
4468 |
+ return function(e, file, xhr) { |
|
4469 |
+ var $img, msg, result; |
|
4470 |
+ if (!file.inline) { |
|
4471 |
+ return; |
|
4472 |
+ } |
|
4473 |
+ if (xhr.statusText === 'abort') { |
|
4474 |
+ return; |
|
4475 |
+ } |
|
4476 |
+ if (xhr.responseText) { |
|
4477 |
+ try { |
|
4478 |
+ result = $.parseJSON(xhr.responseText); |
|
4479 |
+ msg = result.msg; |
|
4480 |
+ } catch (_error) { |
|
4481 |
+ e = _error; |
|
4482 |
+ msg = _this._t('uploadError'); |
|
4483 |
+ } |
|
4484 |
+ alert(msg); |
|
4485 |
+ } |
|
4486 |
+ $img = file.img; |
|
4487 |
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) { |
|
4488 |
+ return; |
|
4489 |
+ } |
|
4490 |
+ _this.loadImage($img, _this.defaultImage, function() { |
|
4491 |
+ var $mask; |
|
4492 |
+ $img.removeData('file'); |
|
4493 |
+ $img.removeClass('uploading').removeClass('loading'); |
|
4494 |
+ $mask = $img.data('mask'); |
|
4495 |
+ if ($mask) { |
|
4496 |
+ $mask.remove(); |
|
4497 |
+ } |
|
4498 |
+ return $img.removeData('mask'); |
|
4499 |
+ }); |
|
4500 |
+ if (_this.popover.active) { |
|
4501 |
+ _this.popover.srcEl.prop('disabled', false); |
|
4502 |
+ _this.popover.srcEl.val(_this.defaultImage); |
|
4503 |
+ } |
|
4504 |
+ _this.editor.trigger('valuechanged'); |
|
4505 |
+ if (_this.editor.body.find('img.uploading').length < 1) { |
|
4506 |
+ return _this.editor.uploader.trigger('uploadready', [file, result]); |
|
4507 |
+ } |
|
4508 |
+ }; |
|
4509 |
+ })(this)); |
|
4510 |
+ }; |
|
4511 |
+ |
|
4512 |
+ ImageButton.prototype._status = function() { |
|
4513 |
+ return this._disableStatus(); |
|
4514 |
+ }; |
|
4515 |
+ |
|
4516 |
+ ImageButton.prototype.loadImage = function($img, src, callback) { |
|
4517 |
+ var $mask, img, positionMask; |
|
4518 |
+ positionMask = (function(_this) { |
|
4519 |
+ return function() { |
|
4520 |
+ var imgOffset, wrapperOffset; |
|
4521 |
+ imgOffset = $img.offset(); |
|
4522 |
+ wrapperOffset = _this.editor.wrapper.offset(); |
|
4523 |
+ return $mask.css({ |
|
4524 |
+ top: imgOffset.top - wrapperOffset.top, |
|
4525 |
+ left: imgOffset.left - wrapperOffset.left, |
|
4526 |
+ width: $img.width(), |
|
4527 |
+ height: $img.height() |
|
4528 |
+ }).show(); |
|
4529 |
+ }; |
|
4530 |
+ })(this); |
|
4531 |
+ $img.addClass('loading'); |
|
4532 |
+ $mask = $img.data('mask'); |
|
4533 |
+ if (!$mask) { |
|
4534 |
+ $mask = $('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper); |
|
4535 |
+ positionMask(); |
|
4536 |
+ $img.data('mask', $mask); |
|
4537 |
+ $mask.data('img', $img); |
|
4538 |
+ } |
|
4539 |
+ img = new Image(); |
|
4540 |
+ img.onload = (function(_this) { |
|
4541 |
+ return function() { |
|
4542 |
+ var height, width; |
|
4543 |
+ if (!$img.hasClass('loading') && !$img.hasClass('uploading')) { |
|
4544 |
+ return; |
|
4545 |
+ } |
|
4546 |
+ width = img.width; |
|
4547 |
+ height = img.height; |
|
4548 |
+ $img.attr({ |
|
4549 |
+ src: src, |
|
4550 |
+ width: width, |
|
4551 |
+ height: height, |
|
4552 |
+ 'data-image-size': width + ',' + height |
|
4553 |
+ }).removeClass('loading'); |
|
4554 |
+ if ($img.hasClass('uploading')) { |
|
4555 |
+ _this.editor.util.reflow(_this.editor.body); |
|
4556 |
+ positionMask(); |
|
4557 |
+ } else { |
|
4558 |
+ $mask.remove(); |
|
4559 |
+ $img.removeData('mask'); |
|
4560 |
+ } |
|
4561 |
+ if ($.isFunction(callback)) { |
|
4562 |
+ return callback(img); |
|
4563 |
+ } |
|
4564 |
+ }; |
|
4565 |
+ })(this); |
|
4566 |
+ img.onerror = function() { |
|
4567 |
+ if ($.isFunction(callback)) { |
|
4568 |
+ callback(false); |
|
4569 |
+ } |
|
4570 |
+ $mask.remove(); |
|
4571 |
+ return $img.removeData('mask').removeClass('loading'); |
|
4572 |
+ }; |
|
4573 |
+ return img.src = src; |
|
4574 |
+ }; |
|
4575 |
+ |
|
4576 |
+ ImageButton.prototype.createImage = function(name) { |
|
4577 |
+ var $img, range; |
|
4578 |
+ if (name == null) { |
|
4579 |
+ name = 'Image'; |
|
4580 |
+ } |
|
4581 |
+ if (!this.editor.inputManager.focused) { |
|
4582 |
+ this.editor.focus(); |
|
4583 |
+ } |
|
4584 |
+ range = this.editor.selection.range(); |
|
4585 |
+ range.deleteContents(); |
|
4586 |
+ this.editor.selection.range(range); |
|
4587 |
+ $img = $('<img/>').attr('alt', name); |
|
4588 |
+ range.insertNode($img[0]); |
|
4589 |
+ this.editor.selection.setRangeAfter($img, range); |
|
4590 |
+ this.editor.trigger('valuechanged'); |
|
4591 |
+ return $img; |
|
4592 |
+ }; |
|
4593 |
+ |
|
4594 |
+ ImageButton.prototype.command = function(src) { |
|
4595 |
+ var $img; |
|
4596 |
+ $img = this.createImage(); |
|
4597 |
+ return this.loadImage($img, src || this.defaultImage, (function(_this) { |
|
4598 |
+ return function() { |
|
4599 |
+ _this.editor.trigger('valuechanged'); |
|
4600 |
+ _this.editor.util.reflow($img); |
|
4601 |
+ $img.click(); |
|
4602 |
+ return _this.popover.one('popovershow', function() { |
|
4603 |
+ _this.popover.srcEl.focus(); |
|
4604 |
+ return _this.popover.srcEl[0].select(); |
|
4605 |
+ }); |
|
4606 |
+ }; |
|
4607 |
+ })(this)); |
|
4608 |
+ }; |
|
4609 |
+ |
|
4610 |
+ return ImageButton; |
|
4611 |
+ |
|
4612 |
+})(Button); |
|
4613 |
+ |
|
4614 |
+ImagePopover = (function(superClass) { |
|
4615 |
+ extend(ImagePopover, superClass); |
|
4616 |
+ |
|
4617 |
+ function ImagePopover() { |
|
4618 |
+ return ImagePopover.__super__.constructor.apply(this, arguments); |
|
4619 |
+ } |
|
4620 |
+ |
|
4621 |
+ ImagePopover.prototype.offset = { |
|
4622 |
+ top: 6, |
|
4623 |
+ left: -4 |
|
4624 |
+ }; |
|
4625 |
+ |
|
4626 |
+ ImagePopover.prototype.render = function() { |
|
4627 |
+ var tpl; |
|
4628 |
+ tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\"\n title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <div class='settings-field'>\n <label>" + (this._t('imageAlt')) + "</label>\n <input class=\"image-alt\" id=\"image-alt\" type=\"text\" tabindex=\"1\" />\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\"\n title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n</div>"; |
|
4629 |
+ this.el.addClass('image-popover').append(tpl); |
|
4630 |
+ this.srcEl = this.el.find('.image-src'); |
|
4631 |
+ this.widthEl = this.el.find('#image-width'); |
|
4632 |
+ this.heightEl = this.el.find('#image-height'); |
|
4633 |
+ this.altEl = this.el.find('#image-alt'); |
|
4634 |
+ this.srcEl.on('keydown', (function(_this) { |
|
4635 |
+ return function(e) { |
|
4636 |
+ var range; |
|
4637 |
+ if (!(e.which === 13 && !_this.target.hasClass('uploading'))) { |
|
4638 |
+ return; |
|
4639 |
+ } |
|
4640 |
+ e.preventDefault(); |
|
4641 |
+ range = document.createRange(); |
|
4642 |
+ _this.button.editor.selection.setRangeAfter(_this.target, range); |
|
4643 |
+ return _this.hide(); |
|
4644 |
+ }; |
|
4645 |
+ })(this)); |
|
4646 |
+ this.srcEl.on('blur', (function(_this) { |
|
4647 |
+ return function(e) { |
|
4648 |
+ return _this._loadImage(_this.srcEl.val()); |
|
4649 |
+ }; |
|
4650 |
+ })(this)); |
|
4651 |
+ this.el.find('.image-size').on('blur', (function(_this) { |
|
4652 |
+ return function(e) { |
|
4653 |
+ _this._resizeImg($(e.currentTarget)); |
|
4654 |
+ return _this.el.data('popover').refresh(); |
|
4655 |
+ }; |
|
4656 |
+ })(this)); |
|
4657 |
+ this.el.find('.image-size').on('keyup', (function(_this) { |
|
4658 |
+ return function(e) { |
|
4659 |
+ var inputEl; |
|
4660 |
+ inputEl = $(e.currentTarget); |
|
4661 |
+ if (!(e.which === 13 || e.which === 27 || e.which === 9)) { |
|
4662 |
+ return _this._resizeImg(inputEl, true); |
|
4663 |
+ } |
|
4664 |
+ }; |
|
4665 |
+ })(this)); |
|
4666 |
+ this.el.find('.image-size').on('keydown', (function(_this) { |
|
4667 |
+ return function(e) { |
|
4668 |
+ var $img, inputEl, range; |
|
4669 |
+ inputEl = $(e.currentTarget); |
|
4670 |
+ if (e.which === 13 || e.which === 27) { |
|
4671 |
+ e.preventDefault(); |
|
4672 |
+ if (e.which === 13) { |
|
4673 |
+ _this._resizeImg(inputEl); |
|
4674 |
+ } else { |
|
4675 |
+ _this._restoreImg(); |
|
4676 |
+ } |
|
4677 |
+ $img = _this.target; |
|
4678 |
+ _this.hide(); |
|
4679 |
+ range = document.createRange(); |
|
4680 |
+ return _this.button.editor.selection.setRangeAfter($img, range); |
|
4681 |
+ } else if (e.which === 9) { |
|
4682 |
+ return _this.el.data('popover').refresh(); |
|
4683 |
+ } |
|
4684 |
+ }; |
|
4685 |
+ })(this)); |
|
4686 |
+ this.altEl.on('keydown', (function(_this) { |
|
4687 |
+ return function(e) { |
|
4688 |
+ var range; |
|
4689 |
+ if (e.which === 13) { |
|
4690 |
+ e.preventDefault(); |
|
4691 |
+ range = document.createRange(); |
|
4692 |
+ _this.button.editor.selection.setRangeAfter(_this.target, range); |
|
4693 |
+ return _this.hide(); |
|
4694 |
+ } |
|
4695 |
+ }; |
|
4696 |
+ })(this)); |
|
4697 |
+ this.altEl.on('keyup', (function(_this) { |
|
4698 |
+ return function(e) { |
|
4699 |
+ if (e.which === 13 || e.which === 27 || e.which === 9) { |
|
4700 |
+ return; |
|
4701 |
+ } |
|
4702 |
+ _this.alt = _this.altEl.val(); |
|
4703 |
+ return _this.target.attr('alt', _this.alt); |
|
4704 |
+ }; |
|
4705 |
+ })(this)); |
|
4706 |
+ this.el.find('.btn-restore').on('click', (function(_this) { |
|
4707 |
+ return function(e) { |
|
4708 |
+ _this._restoreImg(); |
|
4709 |
+ return _this.el.data('popover').refresh(); |
|
4710 |
+ }; |
|
4711 |
+ })(this)); |
|
4712 |
+ this.editor.on('valuechanged', (function(_this) { |
|
4713 |
+ return function(e) { |
|
4714 |
+ if (_this.active) { |
|
4715 |
+ return _this.refresh(); |
|
4716 |
+ } |
|
4717 |
+ }; |
|
4718 |
+ })(this)); |
|
4719 |
+ return this._initUploader(); |
|
4720 |
+ }; |
|
4721 |
+ |
|
4722 |
+ ImagePopover.prototype._initUploader = function() { |
|
4723 |
+ var $uploadBtn, createInput; |
|
4724 |
+ $uploadBtn = this.el.find('.btn-upload'); |
|
4725 |
+ if (this.editor.uploader == null) { |
|
4726 |
+ $uploadBtn.remove(); |
|
4727 |
+ return; |
|
4728 |
+ } |
|
4729 |
+ createInput = (function(_this) { |
|
4730 |
+ return function() { |
|
4731 |
+ if (_this.input) { |
|
4732 |
+ _this.input.remove(); |
|
4733 |
+ } |
|
4734 |
+ return _this.input = $('<input/>', { |
|
4735 |
+ type: 'file', |
|
4736 |
+ title: _this._t('uploadImage'), |
|
4737 |
+ multiple: true, |
|
4738 |
+ accept: 'image/*' |
|
4739 |
+ }).appendTo($uploadBtn); |
|
4740 |
+ }; |
|
4741 |
+ })(this); |
|
4742 |
+ createInput(); |
|
4743 |
+ this.el.on('click mousedown', 'input[type=file]', function(e) { |
|
4744 |
+ return e.stopPropagation(); |
|
4745 |
+ }); |
|
4746 |
+ return this.el.on('change', 'input[type=file]', (function(_this) { |
|
4747 |
+ return function(e) { |
|
4748 |
+ _this.editor.uploader.upload(_this.input, { |
|
4749 |
+ inline: true, |
|
4750 |
+ img: _this.target |
|
4751 |
+ }); |
|
4752 |
+ return createInput(); |
|
4753 |
+ }; |
|
4754 |
+ })(this)); |
|
4755 |
+ }; |
|
4756 |
+ |
|
4757 |
+ ImagePopover.prototype._resizeImg = function(inputEl, onlySetVal) { |
|
4758 |
+ var height, value, width; |
|
4759 |
+ if (onlySetVal == null) { |
|
4760 |
+ onlySetVal = false; |
|
4761 |
+ } |
|
4762 |
+ value = inputEl.val() * 1; |
|
4763 |
+ if (!(this.target && ($.isNumeric(value) || value < 0))) { |
|
4764 |
+ return; |
|
4765 |
+ } |
|
4766 |
+ if (inputEl.is(this.widthEl)) { |
|
4767 |
+ width = value; |
|
4768 |
+ height = this.height * value / this.width; |
|
4769 |
+ this.heightEl.val(height); |
|
4770 |
+ } else { |
|
4771 |
+ height = value; |
|
4772 |
+ width = this.width * value / this.height; |
|
4773 |
+ this.widthEl.val(width); |
|
4774 |
+ } |
|
4775 |
+ if (!onlySetVal) { |
|
4776 |
+ this.target.attr({ |
|
4777 |
+ width: width, |
|
4778 |
+ height: height |
|
4779 |
+ }); |
|
4780 |
+ return this.editor.trigger('valuechanged'); |
|
4781 |
+ } |
|
4782 |
+ }; |
|
4783 |
+ |
|
4784 |
+ ImagePopover.prototype._restoreImg = function() { |
|
4785 |
+ var ref, size; |
|
4786 |
+ size = ((ref = this.target.data('image-size')) != null ? ref.split(",") : void 0) || [this.width, this.height]; |
|
4787 |
+ this.target.attr({ |
|
4788 |
+ width: size[0] * 1, |
|
4789 |
+ height: size[1] * 1 |
|
4790 |
+ }); |
|
4791 |
+ this.widthEl.val(size[0]); |
|
4792 |
+ this.heightEl.val(size[1]); |
|
4793 |
+ return this.editor.trigger('valuechanged'); |
|
4794 |
+ }; |
|
4795 |
+ |
|
4796 |
+ ImagePopover.prototype._loadImage = function(src, callback) { |
|
4797 |
+ if (/^data:image/.test(src) && !this.editor.uploader) { |
|
4798 |
+ if (callback) { |
|
4799 |
+ callback(false); |
|
4800 |
+ } |
|
4801 |
+ return; |
|
4802 |
+ } |
|
4803 |
+ if (this.target.attr('src') === src) { |
|
4804 |
+ return; |
|
4805 |
+ } |
|
4806 |
+ return this.button.loadImage(this.target, src, (function(_this) { |
|
4807 |
+ return function(img) { |
|
4808 |
+ var blob; |
|
4809 |
+ if (!img) { |
|
4810 |
+ return; |
|
4811 |
+ } |
|
4812 |
+ if (_this.active) { |
|
4813 |
+ _this.width = img.width; |
|
4814 |
+ _this.height = img.height; |
|
4815 |
+ _this.widthEl.val(_this.width); |
|
4816 |
+ _this.heightEl.val(_this.height); |
|
4817 |
+ } |
|
4818 |
+ if (/^data:image/.test(src)) { |
|
4819 |
+ blob = _this.editor.util.dataURLtoBlob(src); |
|
4820 |
+ blob.name = "Base64 Image.png"; |
|
4821 |
+ _this.editor.uploader.upload(blob, { |
|
4822 |
+ inline: true, |
|
4823 |
+ img: _this.target |
|
4824 |
+ }); |
|
4825 |
+ } else { |
|
4826 |
+ _this.editor.trigger('valuechanged'); |
|
4827 |
+ } |
|
4828 |
+ if (callback) { |
|
4829 |
+ return callback(img); |
|
4830 |
+ } |
|
4831 |
+ }; |
|
4832 |
+ })(this)); |
|
4833 |
+ }; |
|
4834 |
+ |
|
4835 |
+ ImagePopover.prototype.show = function() { |
|
4836 |
+ var $img, args; |
|
4837 |
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
|
4838 |
+ ImagePopover.__super__.show.apply(this, args); |
|
4839 |
+ $img = this.target; |
|
4840 |
+ this.width = $img.width(); |
|
4841 |
+ this.height = $img.height(); |
|
4842 |
+ this.alt = $img.attr('alt'); |
|
4843 |
+ if ($img.hasClass('uploading')) { |
|
4844 |
+ return this.srcEl.val(this._t('uploading')).prop('disabled', true); |
|
4845 |
+ } else { |
|
4846 |
+ this.srcEl.val($img.attr('src')).prop('disabled', false); |
|
4847 |
+ this.widthEl.val(this.width); |
|
4848 |
+ this.heightEl.val(this.height); |
|
4849 |
+ return this.altEl.val(this.alt); |
|
4850 |
+ } |
|
4851 |
+ }; |
|
4852 |
+ |
|
4853 |
+ return ImagePopover; |
|
4854 |
+ |
|
4855 |
+})(Popover); |
|
4856 |
+ |
|
4857 |
+Simditor.Toolbar.addButton(ImageButton); |
|
4858 |
+ |
|
4859 |
+IndentButton = (function(superClass) { |
|
4860 |
+ extend(IndentButton, superClass); |
|
4861 |
+ |
|
4862 |
+ function IndentButton() { |
|
4863 |
+ return IndentButton.__super__.constructor.apply(this, arguments); |
|
4864 |
+ } |
|
4865 |
+ |
|
4866 |
+ IndentButton.prototype.name = 'indent'; |
|
4867 |
+ |
|
4868 |
+ IndentButton.prototype.icon = 'indent'; |
|
4869 |
+ |
|
4870 |
+ IndentButton.prototype._init = function() { |
|
4871 |
+ this.title = this._t(this.name) + ' (Tab)'; |
|
4872 |
+ return IndentButton.__super__._init.call(this); |
|
4873 |
+ }; |
|
4874 |
+ |
|
4875 |
+ IndentButton.prototype._status = function() {}; |
|
4876 |
+ |
|
4877 |
+ IndentButton.prototype.command = function() { |
|
4878 |
+ return this.editor.indentation.indent(); |
|
4879 |
+ }; |
|
4880 |
+ |
|
4881 |
+ return IndentButton; |
|
4882 |
+ |
|
4883 |
+})(Button); |
|
4884 |
+ |
|
4885 |
+Simditor.Toolbar.addButton(IndentButton); |
|
4886 |
+ |
|
4887 |
+OutdentButton = (function(superClass) { |
|
4888 |
+ extend(OutdentButton, superClass); |
|
4889 |
+ |
|
4890 |
+ function OutdentButton() { |
|
4891 |
+ return OutdentButton.__super__.constructor.apply(this, arguments); |
|
4892 |
+ } |
|
4893 |
+ |
|
4894 |
+ OutdentButton.prototype.name = 'outdent'; |
|
4895 |
+ |
|
4896 |
+ OutdentButton.prototype.icon = 'outdent'; |
|
4897 |
+ |
|
4898 |
+ OutdentButton.prototype._init = function() { |
|
4899 |
+ this.title = this._t(this.name) + ' (Shift + Tab)'; |
|
4900 |
+ return OutdentButton.__super__._init.call(this); |
|
4901 |
+ }; |
|
4902 |
+ |
|
4903 |
+ OutdentButton.prototype._status = function() {}; |
|
4904 |
+ |
|
4905 |
+ OutdentButton.prototype.command = function() { |
|
4906 |
+ return this.editor.indentation.indent(true); |
|
4907 |
+ }; |
|
4908 |
+ |
|
4909 |
+ return OutdentButton; |
|
4910 |
+ |
|
4911 |
+})(Button); |
|
4912 |
+ |
|
4913 |
+Simditor.Toolbar.addButton(OutdentButton); |
|
4914 |
+ |
|
4915 |
+HrButton = (function(superClass) { |
|
4916 |
+ extend(HrButton, superClass); |
|
4917 |
+ |
|
4918 |
+ function HrButton() { |
|
4919 |
+ return HrButton.__super__.constructor.apply(this, arguments); |
|
4920 |
+ } |
|
4921 |
+ |
|
4922 |
+ HrButton.prototype.name = 'hr'; |
|
4923 |
+ |
|
4924 |
+ HrButton.prototype.icon = 'minus'; |
|
4925 |
+ |
|
4926 |
+ HrButton.prototype.htmlTag = 'hr'; |
|
4927 |
+ |
|
4928 |
+ HrButton.prototype._status = function() {}; |
|
4929 |
+ |
|
4930 |
+ HrButton.prototype.command = function() { |
|
4931 |
+ var $hr, $newBlock, $nextBlock, $rootBlock; |
|
4932 |
+ $rootBlock = this.editor.selection.rootNodes().first(); |
|
4933 |
+ $nextBlock = $rootBlock.next(); |
|
4934 |
+ if ($nextBlock.length > 0) { |
|
4935 |
+ this.editor.selection.save(); |
|
4936 |
+ } else { |
|
4937 |
+ $newBlock = $('<p/>').append(this.editor.util.phBr); |
|
4938 |
+ } |
|
4939 |
+ $hr = $('<hr/>').insertAfter($rootBlock); |
|
4940 |
+ if ($newBlock) { |
|
4941 |
+ $newBlock.insertAfter($hr); |
|
4942 |
+ this.editor.selection.setRangeAtStartOf($newBlock); |
|
4943 |
+ } else { |
|
4944 |
+ this.editor.selection.restore(); |
|
4945 |
+ } |
|
4946 |
+ return this.editor.trigger('valuechanged'); |
|
4947 |
+ }; |
|
4948 |
+ |
|
4949 |
+ return HrButton; |
|
4950 |
+ |
|
4951 |
+})(Button); |
|
4952 |
+ |
|
4953 |
+Simditor.Toolbar.addButton(HrButton); |
|
4954 |
+ |
|
4955 |
+TableButton = (function(superClass) { |
|
4956 |
+ extend(TableButton, superClass); |
|
4957 |
+ |
|
4958 |
+ function TableButton() { |
|
4959 |
+ return TableButton.__super__.constructor.apply(this, arguments); |
|
4960 |
+ } |
|
4961 |
+ |
|
4962 |
+ TableButton.prototype.name = 'table'; |
|
4963 |
+ |
|
4964 |
+ TableButton.prototype.icon = 'table'; |
|
4965 |
+ |
|
4966 |
+ TableButton.prototype.htmlTag = 'table'; |
|
4967 |
+ |
|
4968 |
+ TableButton.prototype.disableTag = 'pre, li, blockquote'; |
|
4969 |
+ |
|
4970 |
+ TableButton.prototype.menu = true; |
|
4971 |
+ |
|
4972 |
+ TableButton.prototype._init = function() { |
|
4973 |
+ TableButton.__super__._init.call(this); |
|
4974 |
+ $.merge(this.editor.formatter._allowedTags, ['thead', 'th', 'tbody', 'tr', 'td', 'colgroup', 'col']); |
|
4975 |
+ $.extend(this.editor.formatter._allowedAttributes, { |
|
4976 |
+ td: ['rowspan', 'colspan'], |
|
4977 |
+ col: ['width'] |
|
4978 |
+ }); |
|
4979 |
+ $.extend(this.editor.formatter._allowedStyles, { |
|
4980 |
+ td: ['text-align'], |
|
4981 |
+ th: ['text-align'] |
|
4982 |
+ }); |
|
4983 |
+ this._initShortcuts(); |
|
4984 |
+ this.editor.on('decorate', (function(_this) { |
|
4985 |
+ return function(e, $el) { |
|
4986 |
+ return $el.find('table').each(function(i, table) { |
|
4987 |
+ return _this.decorate($(table)); |
|
4988 |
+ }); |
|
4989 |
+ }; |
|
4990 |
+ })(this)); |
|
4991 |
+ this.editor.on('undecorate', (function(_this) { |
|
4992 |
+ return function(e, $el) { |
|
4993 |
+ return $el.find('table').each(function(i, table) { |
|
4994 |
+ return _this.undecorate($(table)); |
|
4995 |
+ }); |
|
4996 |
+ }; |
|
4997 |
+ })(this)); |
|
4998 |
+ this.editor.on('selectionchanged.table', (function(_this) { |
|
4999 |
+ return function(e) { |
|
5000 |
+ var $container, range; |
|
5001 |
+ _this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active'); |
|
5002 |
+ range = _this.editor.selection.range(); |
|
5003 |
+ if (!range) { |
|
5004 |
+ return; |
|
5005 |
+ } |
|
5006 |
+ $container = _this.editor.selection.containerNode(); |
|
5007 |
+ if (range.collapsed && $container.is('.simditor-table')) { |
|
5008 |
+ if (_this.editor.selection.rangeAtStartOf($container)) { |
|
5009 |
+ $container = $container.find('th:first'); |
|
5010 |
+ } else { |
|
5011 |
+ $container = $container.find('td:last'); |
|
5012 |
+ } |
|
5013 |
+ _this.editor.selection.setRangeAtEndOf($container); |
|
5014 |
+ } |
|
5015 |
+ return $container.closest('td, th', _this.editor.body).addClass('active'); |
|
5016 |
+ }; |
|
5017 |
+ })(this)); |
|
5018 |
+ this.editor.on('blur.table', (function(_this) { |
|
5019 |
+ return function(e) { |
|
5020 |
+ return _this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active'); |
|
5021 |
+ }; |
|
5022 |
+ })(this)); |
|
5023 |
+ this.editor.keystroke.add('up', 'td', (function(_this) { |
|
5024 |
+ return function(e, $node) { |
|
5025 |
+ _this._tdNav($node, 'up'); |
|
5026 |
+ return true; |
|
5027 |
+ }; |
|
5028 |
+ })(this)); |
|
5029 |
+ this.editor.keystroke.add('up', 'th', (function(_this) { |
|
5030 |
+ return function(e, $node) { |
|
5031 |
+ _this._tdNav($node, 'up'); |
|
5032 |
+ return true; |
|
5033 |
+ }; |
|
5034 |
+ })(this)); |
|
5035 |
+ this.editor.keystroke.add('down', 'td', (function(_this) { |
|
5036 |
+ return function(e, $node) { |
|
5037 |
+ _this._tdNav($node, 'down'); |
|
5038 |
+ return true; |
|
5039 |
+ }; |
|
5040 |
+ })(this)); |
|
5041 |
+ return this.editor.keystroke.add('down', 'th', (function(_this) { |
|
5042 |
+ return function(e, $node) { |
|
5043 |
+ _this._tdNav($node, 'down'); |
|
5044 |
+ return true; |
|
5045 |
+ }; |
|
5046 |
+ })(this)); |
|
5047 |
+ }; |
|
5048 |
+ |
|
5049 |
+ TableButton.prototype._tdNav = function($td, direction) { |
|
5050 |
+ var $anotherTr, $tr, action, anotherTag, index, parentTag, ref; |
|
5051 |
+ if (direction == null) { |
|
5052 |
+ direction = 'up'; |
|
5053 |
+ } |
|
5054 |
+ action = direction === 'up' ? 'prev' : 'next'; |
|
5055 |
+ ref = direction === 'up' ? ['tbody', 'thead'] : ['thead', 'tbody'], parentTag = ref[0], anotherTag = ref[1]; |
|
5056 |
+ $tr = $td.parent('tr'); |
|
5057 |
+ $anotherTr = this["_" + action + "Row"]($tr); |
|
5058 |
+ if (!($anotherTr.length > 0)) { |
|
5059 |
+ return true; |
|
5060 |
+ } |
|
5061 |
+ index = $tr.find('td, th').index($td); |
|
5062 |
+ return this.editor.selection.setRangeAtEndOf($anotherTr.find('td, th').eq(index)); |
|
5063 |
+ }; |
|
5064 |
+ |
|
5065 |
+ TableButton.prototype._nextRow = function($tr) { |
|
5066 |
+ var $nextTr; |
|
5067 |
+ $nextTr = $tr.next('tr'); |
|
5068 |
+ if ($nextTr.length < 1 && $tr.parent('thead').length > 0) { |
|
5069 |
+ $nextTr = $tr.parent('thead').next('tbody').find('tr:first'); |
|
5070 |
+ } |
|
5071 |
+ return $nextTr; |
|
5072 |
+ }; |
|
5073 |
+ |
|
5074 |
+ TableButton.prototype._prevRow = function($tr) { |
|
5075 |
+ var $prevTr; |
|
5076 |
+ $prevTr = $tr.prev('tr'); |
|
5077 |
+ if ($prevTr.length < 1 && $tr.parent('tbody').length > 0) { |
|
5078 |
+ $prevTr = $tr.parent('tbody').prev('thead').find('tr'); |
|
5079 |
+ } |
|
5080 |
+ return $prevTr; |
|
5081 |
+ }; |
|
5082 |
+ |
|
5083 |
+ TableButton.prototype.initResize = function($table) { |
|
5084 |
+ var $colgroup, $resizeHandle, $wrapper; |
|
5085 |
+ $wrapper = $table.parent('.simditor-table'); |
|
5086 |
+ $colgroup = $table.find('colgroup'); |
|
5087 |
+ if ($colgroup.length < 1) { |
|
5088 |
+ $colgroup = $('<colgroup/>').prependTo($table); |
|
5089 |
+ $table.find('thead tr th').each(function(i, td) { |
|
5090 |
+ var $col; |
|
5091 |
+ return $col = $('<col/>').appendTo($colgroup); |
|
5092 |
+ }); |
|
5093 |
+ this.refreshTableWidth($table); |
|
5094 |
+ } |
|
5095 |
+ $resizeHandle = $('<div />', { |
|
5096 |
+ "class": 'simditor-resize-handle', |
|
5097 |
+ contenteditable: 'false' |
|
5098 |
+ }).appendTo($wrapper); |
|
5099 |
+ $wrapper.on('mousemove', 'td, th', function(e) { |
|
5100 |
+ var $col, $td, index, ref, ref1, x; |
|
5101 |
+ if ($wrapper.hasClass('resizing')) { |
|
5102 |
+ return; |
|
5103 |
+ } |
|
5104 |
+ $td = $(e.currentTarget); |
|
5105 |
+ x = e.pageX - $(e.currentTarget).offset().left; |
|
5106 |
+ if (x < 5 && $td.prev().length > 0) { |
|
5107 |
+ $td = $td.prev(); |
|
5108 |
+ } |
|
5109 |
+ if ($td.next('td, th').length < 1) { |
|
5110 |
+ $resizeHandle.hide(); |
|
5111 |
+ return; |
|
5112 |
+ } |
|
5113 |
+ if ((ref = $resizeHandle.data('td')) != null ? ref.is($td) : void 0) { |
|
5114 |
+ $resizeHandle.show(); |
|
5115 |
+ return; |
|
5116 |
+ } |
|
5117 |
+ index = $td.parent().find('td, th').index($td); |
|
5118 |
+ $col = $colgroup.find('col').eq(index); |
|
5119 |
+ if ((ref1 = $resizeHandle.data('col')) != null ? ref1.is($col) : void 0) { |
|
5120 |
+ $resizeHandle.show(); |
|
5121 |
+ return; |
|
5122 |
+ } |
|
5123 |
+ return $resizeHandle.css('left', $td.position().left + $td.outerWidth() - 5).data('td', $td).data('col', $col).show(); |
|
5124 |
+ }); |
|
5125 |
+ $wrapper.on('mouseleave', function(e) { |
|
5126 |
+ return $resizeHandle.hide(); |
|
5127 |
+ }); |
|
5128 |
+ return $wrapper.on('mousedown', '.simditor-resize-handle', function(e) { |
|
5129 |
+ var $handle, $leftCol, $leftTd, $rightCol, $rightTd, minWidth, startHandleLeft, startLeftWidth, startRightWidth, startX, tableWidth; |
|
5130 |
+ $handle = $(e.currentTarget); |
|
5131 |
+ $leftTd = $handle.data('td'); |
|
5132 |
+ $leftCol = $handle.data('col'); |
|
5133 |
+ $rightTd = $leftTd.next('td, th'); |
|
5134 |
+ $rightCol = $leftCol.next('col'); |
|
5135 |
+ startX = e.pageX; |
|
5136 |
+ startLeftWidth = $leftTd.outerWidth() * 1; |
|
5137 |
+ startRightWidth = $rightTd.outerWidth() * 1; |
|
5138 |
+ startHandleLeft = parseFloat($handle.css('left')); |
|
5139 |
+ tableWidth = $leftTd.closest('table').width(); |
|
5140 |
+ minWidth = 50; |
|
5141 |
+ $(document).on('mousemove.simditor-resize-table', function(e) { |
|
5142 |
+ var deltaX, leftWidth, rightWidth; |
|
5143 |
+ deltaX = e.pageX - startX; |
|
5144 |
+ leftWidth = startLeftWidth + deltaX; |
|
5145 |
+ rightWidth = startRightWidth - deltaX; |
|
5146 |
+ if (leftWidth < minWidth) { |
|
5147 |
+ leftWidth = minWidth; |
|
5148 |
+ deltaX = minWidth - startLeftWidth; |
|
5149 |
+ rightWidth = startRightWidth - deltaX; |
|
5150 |
+ } else if (rightWidth < minWidth) { |
|
5151 |
+ rightWidth = minWidth; |
|
5152 |
+ deltaX = startRightWidth - minWidth; |
|
5153 |
+ leftWidth = startLeftWidth + deltaX; |
|
5154 |
+ } |
|
5155 |
+ $leftCol.attr('width', (leftWidth / tableWidth * 100) + '%'); |
|
5156 |
+ $rightCol.attr('width', (rightWidth / tableWidth * 100) + '%'); |
|
5157 |
+ return $handle.css('left', startHandleLeft + deltaX); |
|
5158 |
+ }); |
|
5159 |
+ $(document).one('mouseup.simditor-resize-table', function(e) { |
|
5160 |
+ $(document).off('.simditor-resize-table'); |
|
5161 |
+ return $wrapper.removeClass('resizing'); |
|
5162 |
+ }); |
|
5163 |
+ $wrapper.addClass('resizing'); |
|
5164 |
+ return false; |
|
5165 |
+ }); |
|
5166 |
+ }; |
|
5167 |
+ |
|
5168 |
+ TableButton.prototype._initShortcuts = function() { |
|
5169 |
+ this.editor.hotkeys.add('ctrl+alt+up', (function(_this) { |
|
5170 |
+ return function(e) { |
|
5171 |
+ _this.editMenu.find('.menu-item[data-param=insertRowAbove]').click(); |
|
5172 |
+ return false; |
|
5173 |
+ }; |
|
5174 |
+ })(this)); |
|
5175 |
+ this.editor.hotkeys.add('ctrl+alt+down', (function(_this) { |
|
5176 |
+ return function(e) { |
|
5177 |
+ _this.editMenu.find('.menu-item[data-param=insertRowBelow]').click(); |
|
5178 |
+ return false; |
|
5179 |
+ }; |
|
5180 |
+ })(this)); |
|
5181 |
+ this.editor.hotkeys.add('ctrl+alt+left', (function(_this) { |
|
5182 |
+ return function(e) { |
|
5183 |
+ _this.editMenu.find('.menu-item[data-param=insertColLeft]').click(); |
|
5184 |
+ return false; |
|
5185 |
+ }; |
|
5186 |
+ })(this)); |
|
5187 |
+ return this.editor.hotkeys.add('ctrl+alt+right', (function(_this) { |
|
5188 |
+ return function(e) { |
|
5189 |
+ _this.editMenu.find('.menu-item[data-param=insertColRight]').click(); |
|
5190 |
+ return false; |
|
5191 |
+ }; |
|
5192 |
+ })(this)); |
|
5193 |
+ }; |
|
5194 |
+ |
|
5195 |
+ TableButton.prototype.decorate = function($table) { |
|
5196 |
+ var $headRow, $tbody, $thead; |
|
5197 |
+ if ($table.parent('.simditor-table').length > 0) { |
|
5198 |
+ this.undecorate($table); |
|
5199 |
+ } |
|
5200 |
+ $table.wrap('<div class="simditor-table"></div>'); |
|
5201 |
+ if ($table.find('thead').length < 1) { |
|
5202 |
+ $thead = $('<thead />'); |
|
5203 |
+ $headRow = $table.find('tr').first(); |
|
5204 |
+ $thead.append($headRow); |
|
5205 |
+ this._changeCellTag($headRow, 'th'); |
|
5206 |
+ $tbody = $table.find('tbody'); |
|
5207 |
+ if ($tbody.length > 0) { |
|
5208 |
+ $tbody.before($thead); |
|
5209 |
+ } else { |
|
5210 |
+ $table.prepend($thead); |
|
5211 |
+ } |
|
5212 |
+ } |
|
5213 |
+ this.initResize($table); |
|
5214 |
+ return $table.parent(); |
|
5215 |
+ }; |
|
5216 |
+ |
|
5217 |
+ TableButton.prototype.undecorate = function($table) { |
|
5218 |
+ if (!($table.parent('.simditor-table').length > 0)) { |
|
5219 |
+ return; |
|
5220 |
+ } |
|
5221 |
+ return $table.parent().replaceWith($table); |
|
5222 |
+ }; |
|
5223 |
+ |
|
5224 |
+ TableButton.prototype.renderMenu = function() { |
|
5225 |
+ var $table; |
|
5226 |
+ $("<div class=\"menu-create-table\">\n</div>\n<div class=\"menu-edit-table\">\n <ul>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteRow\">\n <span>" + (this._t('deleteRow')) + "</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertRowAbove\">\n <span>" + (this._t('insertRowAbove')) + " ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertRowBelow\">\n <span>" + (this._t('insertRowBelow')) + " ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class=\"separator\"></span></li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteCol\">\n <span>" + (this._t('deleteColumn')) + "</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertColLeft\">\n <span>" + (this._t('insertColumnLeft')) + " ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertColRight\">\n <span>" + (this._t('insertColumnRight')) + " ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class=\"separator\"></span></li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteTable\">\n <span>" + (this._t('deleteTable')) + "</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper); |
|
5227 |
+ this.createMenu = this.menuWrapper.find('.menu-create-table'); |
|
5228 |
+ this.editMenu = this.menuWrapper.find('.menu-edit-table'); |
|
5229 |
+ $table = this.createTable(6, 6).appendTo(this.createMenu); |
|
5230 |
+ this.createMenu.on('mouseenter', 'td, th', (function(_this) { |
|
5231 |
+ return function(e) { |
|
5232 |
+ var $td, $tr, $trs, num; |
|
5233 |
+ _this.createMenu.find('td, th').removeClass('selected'); |
|
5234 |
+ $td = $(e.currentTarget); |
|
5235 |
+ $tr = $td.parent(); |
|
5236 |
+ num = $tr.find('td, th').index($td) + 1; |
|
5237 |
+ $trs = $tr.prevAll('tr').addBack(); |
|
5238 |
+ if ($tr.parent().is('tbody')) { |
|
5239 |
+ $trs = $trs.add($table.find('thead tr')); |
|
5240 |
+ } |
|
5241 |
+ return $trs.find("td:lt(" + num + "), th:lt(" + num + ")").addClass('selected'); |
|
5242 |
+ }; |
|
5243 |
+ })(this)); |
|
5244 |
+ this.createMenu.on('mouseleave', function(e) { |
|
5245 |
+ return $(e.currentTarget).find('td, th').removeClass('selected'); |
|
5246 |
+ }); |
|
5247 |
+ return this.createMenu.on('mousedown', 'td, th', (function(_this) { |
|
5248 |
+ return function(e) { |
|
5249 |
+ var $closestBlock, $td, $tr, colNum, rowNum; |
|
5250 |
+ _this.wrapper.removeClass('menu-on'); |
|
5251 |
+ if (!_this.editor.inputManager.focused) { |
|
5252 |
+ return; |
|
5253 |
+ } |
|
5254 |
+ $td = $(e.currentTarget); |
|
5255 |
+ $tr = $td.parent(); |
|
5256 |
+ colNum = $tr.find('td').index($td) + 1; |
|
5257 |
+ rowNum = $tr.prevAll('tr').length + 1; |
|
5258 |
+ if ($tr.parent().is('tbody')) { |
|
5259 |
+ rowNum += 1; |
|
5260 |
+ } |
|
5261 |
+ $table = _this.createTable(rowNum, colNum, true); |
|
5262 |
+ $closestBlock = _this.editor.selection.blockNodes().last(); |
|
5263 |
+ if (_this.editor.util.isEmptyNode($closestBlock)) { |
|
5264 |
+ $closestBlock.replaceWith($table); |
|
5265 |
+ } else { |
|
5266 |
+ $closestBlock.after($table); |
|
5267 |
+ } |
|
5268 |
+ _this.decorate($table); |
|
5269 |
+ _this.editor.selection.setRangeAtStartOf($table.find('th:first')); |
|
5270 |
+ _this.editor.trigger('valuechanged'); |
|
5271 |
+ return false; |
|
5272 |
+ }; |
|
5273 |
+ })(this)); |
|
5274 |
+ }; |
|
5275 |
+ |
|
5276 |
+ TableButton.prototype.createTable = function(row, col, phBr) { |
|
5277 |
+ var $table, $tbody, $td, $thead, $tr, c, k, l, r, ref, ref1; |
|
5278 |
+ $table = $('<table/>'); |
|
5279 |
+ $thead = $('<thead/>').appendTo($table); |
|
5280 |
+ $tbody = $('<tbody/>').appendTo($table); |
|
5281 |
+ for (r = k = 0, ref = row; 0 <= ref ? k < ref : k > ref; r = 0 <= ref ? ++k : --k) { |
|
5282 |
+ $tr = $('<tr/>'); |
|
5283 |
+ $tr.appendTo(r === 0 ? $thead : $tbody); |
|
5284 |
+ for (c = l = 0, ref1 = col; 0 <= ref1 ? l < ref1 : l > ref1; c = 0 <= ref1 ? ++l : --l) { |
|
5285 |
+ $td = $(r === 0 ? '<th/>' : '<td/>').appendTo($tr); |
|
5286 |
+ if (phBr) { |
|
5287 |
+ $td.append(this.editor.util.phBr); |
|
5288 |
+ } |
|
5289 |
+ } |
|
5290 |
+ } |
|
5291 |
+ return $table; |
|
5292 |
+ }; |
|
5293 |
+ |
|
5294 |
+ TableButton.prototype.refreshTableWidth = function($table) { |
|
5295 |
+ var cols, tableWidth; |
|
5296 |
+ tableWidth = $table.width(); |
|
5297 |
+ cols = $table.find('col'); |
|
5298 |
+ return $table.find('thead tr th').each(function(i, td) { |
|
5299 |
+ var $col; |
|
5300 |
+ $col = cols.eq(i); |
|
5301 |
+ return $col.attr('width', ($(td).outerWidth() / tableWidth * 100) + '%'); |
|
5302 |
+ }); |
|
5303 |
+ }; |
|
5304 |
+ |
|
5305 |
+ TableButton.prototype.setActive = function(active) { |
|
5306 |
+ TableButton.__super__.setActive.call(this, active); |
|
5307 |
+ if (active) { |
|
5308 |
+ this.createMenu.hide(); |
|
5309 |
+ return this.editMenu.show(); |
|
5310 |
+ } else { |
|
5311 |
+ this.createMenu.show(); |
|
5312 |
+ return this.editMenu.hide(); |
|
5313 |
+ } |
|
5314 |
+ }; |
|
5315 |
+ |
|
5316 |
+ TableButton.prototype._changeCellTag = function($tr, tagName) { |
|
5317 |
+ return $tr.find('td, th').each(function(i, cell) { |
|
5318 |
+ var $cell; |
|
5319 |
+ $cell = $(cell); |
|
5320 |
+ return $cell.replaceWith("<" + tagName + ">" + ($cell.html()) + "</" + tagName + ">"); |
|
5321 |
+ }); |
|
5322 |
+ }; |
|
5323 |
+ |
|
5324 |
+ TableButton.prototype.deleteRow = function($td) { |
|
5325 |
+ var $newTr, $tr, index; |
|
5326 |
+ $tr = $td.parent('tr'); |
|
5327 |
+ if ($tr.closest('table').find('tr').length < 1) { |
|
5328 |
+ return this.deleteTable($td); |
|
5329 |
+ } else { |
|
5330 |
+ $newTr = this._nextRow($tr); |
|
5331 |
+ if (!($newTr.length > 0)) { |
|
5332 |
+ $newTr = this._prevRow($tr); |
|
5333 |
+ } |
|
5334 |
+ index = $tr.find('td, th').index($td); |
|
5335 |
+ if ($tr.parent().is('thead')) { |
|
5336 |
+ $newTr.appendTo($tr.parent()); |
|
5337 |
+ this._changeCellTag($newTr, 'th'); |
|
5338 |
+ } |
|
5339 |
+ $tr.remove(); |
|
5340 |
+ return this.editor.selection.setRangeAtEndOf($newTr.find('td, th').eq(index)); |
|
5341 |
+ } |
|
5342 |
+ }; |
|
5343 |
+ |
|
5344 |
+ TableButton.prototype.insertRow = function($td, direction) { |
|
5345 |
+ var $newTr, $table, $tr, cellTag, colNum, i, index, k, ref; |
|
5346 |
+ if (direction == null) { |
|
5347 |
+ direction = 'after'; |
|
5348 |
+ } |
|
5349 |
+ $tr = $td.parent('tr'); |
|
5350 |
+ $table = $tr.closest('table'); |
|
5351 |
+ colNum = 0; |
|
5352 |
+ $table.find('tr').each(function(i, tr) { |
|
5353 |
+ return colNum = Math.max(colNum, $(tr).find('td').length); |
|
5354 |
+ }); |
|
5355 |
+ index = $tr.find('td, th').index($td); |
|
5356 |
+ $newTr = $('<tr/>'); |
|
5357 |
+ cellTag = 'td'; |
|
5358 |
+ if (direction === 'after' && $tr.parent().is('thead')) { |
|
5359 |
+ $tr.parent().next('tbody').prepend($newTr); |
|
5360 |
+ } else if (direction === 'before' && $tr.parent().is('thead')) { |
|
5361 |
+ $tr.before($newTr); |
|
5362 |
+ $tr.parent().next('tbody').prepend($tr); |
|
5363 |
+ this._changeCellTag($tr, 'td'); |
|
5364 |
+ cellTag = 'th'; |
|
5365 |
+ } else { |
|
5366 |
+ $tr[direction]($newTr); |
|
5367 |
+ } |
|
5368 |
+ for (i = k = 1, ref = colNum; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) { |
|
5369 |
+ $("<" + cellTag + "/>").append(this.editor.util.phBr).appendTo($newTr); |
|
5370 |
+ } |
|
5371 |
+ return this.editor.selection.setRangeAtStartOf($newTr.find('td, th').eq(index)); |
|
5372 |
+ }; |
|
5373 |
+ |
|
5374 |
+ TableButton.prototype.deleteCol = function($td) { |
|
5375 |
+ var $newTd, $table, $tr, index, noOtherCol, noOtherRow; |
|
5376 |
+ $tr = $td.parent('tr'); |
|
5377 |
+ noOtherRow = $tr.closest('table').find('tr').length < 2; |
|
5378 |
+ noOtherCol = $td.siblings('td, th').length < 1; |
|
5379 |
+ if (noOtherRow && noOtherCol) { |
|
5380 |
+ return this.deleteTable($td); |
|
5381 |
+ } else { |
|
5382 |
+ index = $tr.find('td, th').index($td); |
|
5383 |
+ $newTd = $td.next('td, th'); |
|
5384 |
+ if (!($newTd.length > 0)) { |
|
5385 |
+ $newTd = $tr.prev('td, th'); |
|
5386 |
+ } |
|
5387 |
+ $table = $tr.closest('table'); |
|
5388 |
+ $table.find('col').eq(index).remove(); |
|
5389 |
+ $table.find('tr').each(function(i, tr) { |
|
5390 |
+ return $(tr).find('td, th').eq(index).remove(); |
|
5391 |
+ }); |
|
5392 |
+ this.refreshTableWidth($table); |
|
5393 |
+ return this.editor.selection.setRangeAtEndOf($newTd); |
|
5394 |
+ } |
|
5395 |
+ }; |
|
5396 |
+ |
|
5397 |
+ TableButton.prototype.insertCol = function($td, direction) { |
|
5398 |
+ var $col, $newCol, $newTd, $table, $tr, index, tableWidth, width; |
|
5399 |
+ if (direction == null) { |
|
5400 |
+ direction = 'after'; |
|
5401 |
+ } |
|
5402 |
+ $tr = $td.parent('tr'); |
|
5403 |
+ index = $tr.find('td, th').index($td); |
|
5404 |
+ $table = $td.closest('table'); |
|
5405 |
+ $col = $table.find('col').eq(index); |
|
5406 |
+ $table.find('tr').each((function(_this) { |
|
5407 |
+ return function(i, tr) { |
|
5408 |
+ var $newTd, cellTag; |
|
5409 |
+ cellTag = $(tr).parent().is('thead') ? 'th' : 'td'; |
|
5410 |
+ $newTd = $("<" + cellTag + "/>").append(_this.editor.util.phBr); |
|
5411 |
+ return $(tr).find('td, th').eq(index)[direction]($newTd); |
|
5412 |
+ }; |
|
5413 |
+ })(this)); |
|
5414 |
+ $newCol = $('<col/>'); |
|
5415 |
+ $col[direction]($newCol); |
|
5416 |
+ tableWidth = $table.width(); |
|
5417 |
+ width = Math.max(parseFloat($col.attr('width')) / 2, 50 / tableWidth * 100); |
|
5418 |
+ $col.attr('width', width + '%'); |
|
5419 |
+ $newCol.attr('width', width + '%'); |
|
5420 |
+ this.refreshTableWidth($table); |
|
5421 |
+ $newTd = direction === 'after' ? $td.next('td, th') : $td.prev('td, th'); |
|
5422 |
+ return this.editor.selection.setRangeAtStartOf($newTd); |
|
5423 |
+ }; |
|
5424 |
+ |
|
5425 |
+ TableButton.prototype.deleteTable = function($td) { |
|
5426 |
+ var $block, $table; |
|
5427 |
+ $table = $td.closest('.simditor-table'); |
|
5428 |
+ $block = $table.next('p'); |
|
5429 |
+ $table.remove(); |
|
5430 |
+ if ($block.length > 0) { |
|
5431 |
+ return this.editor.selection.setRangeAtStartOf($block); |
|
5432 |
+ } |
|
5433 |
+ }; |
|
5434 |
+ |
|
5435 |
+ TableButton.prototype.command = function(param) { |
|
5436 |
+ var $td; |
|
5437 |
+ $td = this.editor.selection.containerNode().closest('td, th'); |
|
5438 |
+ if (!($td.length > 0)) { |
|
5439 |
+ return; |
|
5440 |
+ } |
|
5441 |
+ if (param === 'deleteRow') { |
|
5442 |
+ this.deleteRow($td); |
|
5443 |
+ } else if (param === 'insertRowAbove') { |
|
5444 |
+ this.insertRow($td, 'before'); |
|
5445 |
+ } else if (param === 'insertRowBelow') { |
|
5446 |
+ this.insertRow($td); |
|
5447 |
+ } else if (param === 'deleteCol') { |
|
5448 |
+ this.deleteCol($td); |
|
5449 |
+ } else if (param === 'insertColLeft') { |
|
5450 |
+ this.insertCol($td, 'before'); |
|
5451 |
+ } else if (param === 'insertColRight') { |
|
5452 |
+ this.insertCol($td); |
|
5453 |
+ } else if (param === 'deleteTable') { |
|
5454 |
+ this.deleteTable($td); |
|
5455 |
+ } else { |
|
5456 |
+ return; |
|
5457 |
+ } |
|
5458 |
+ return this.editor.trigger('valuechanged'); |
|
5459 |
+ }; |
|
5460 |
+ |
|
5461 |
+ return TableButton; |
|
5462 |
+ |
|
5463 |
+})(Button); |
|
5464 |
+ |
|
5465 |
+Simditor.Toolbar.addButton(TableButton); |
|
5466 |
+ |
|
5467 |
+StrikethroughButton = (function(superClass) { |
|
5468 |
+ extend(StrikethroughButton, superClass); |
|
5469 |
+ |
|
5470 |
+ function StrikethroughButton() { |
|
5471 |
+ return StrikethroughButton.__super__.constructor.apply(this, arguments); |
|
5472 |
+ } |
|
5473 |
+ |
|
5474 |
+ StrikethroughButton.prototype.name = 'strikethrough'; |
|
5475 |
+ |
|
5476 |
+ StrikethroughButton.prototype.icon = 'strikethrough'; |
|
5477 |
+ |
|
5478 |
+ StrikethroughButton.prototype.htmlTag = 'strike'; |
|
5479 |
+ |
|
5480 |
+ StrikethroughButton.prototype.disableTag = 'pre'; |
|
5481 |
+ |
|
5482 |
+ StrikethroughButton.prototype._activeStatus = function() { |
|
5483 |
+ var active; |
|
5484 |
+ active = document.queryCommandState('strikethrough') === true; |
|
5485 |
+ this.setActive(active); |
|
5486 |
+ return this.active; |
|
5487 |
+ }; |
|
5488 |
+ |
|
5489 |
+ StrikethroughButton.prototype.command = function() { |
|
5490 |
+ document.execCommand('strikethrough'); |
|
5491 |
+ if (!this.editor.util.support.oninput) { |
|
5492 |
+ this.editor.trigger('valuechanged'); |
|
5493 |
+ } |
|
5494 |
+ return $(document).trigger('selectionchange'); |
|
5495 |
+ }; |
|
5496 |
+ |
|
5497 |
+ return StrikethroughButton; |
|
5498 |
+ |
|
5499 |
+})(Button); |
|
5500 |
+ |
|
5501 |
+Simditor.Toolbar.addButton(StrikethroughButton); |
|
5502 |
+ |
|
5503 |
+AlignmentButton = (function(superClass) { |
|
5504 |
+ extend(AlignmentButton, superClass); |
|
5505 |
+ |
|
5506 |
+ function AlignmentButton() { |
|
5507 |
+ return AlignmentButton.__super__.constructor.apply(this, arguments); |
|
5508 |
+ } |
|
5509 |
+ |
|
5510 |
+ AlignmentButton.prototype.name = "alignment"; |
|
5511 |
+ |
|
5512 |
+ AlignmentButton.prototype.icon = 'align-left'; |
|
5513 |
+ |
|
5514 |
+ AlignmentButton.prototype.htmlTag = 'p, h1, h2, h3, h4, td, th'; |
|
5515 |
+ |
|
5516 |
+ AlignmentButton.prototype._init = function() { |
|
5517 |
+ this.menu = [ |
|
5518 |
+ { |
|
5519 |
+ name: 'left', |
|
5520 |
+ text: this._t('alignLeft'), |
|
5521 |
+ icon: 'align-left', |
|
5522 |
+ param: 'left' |
|
5523 |
+ }, { |
|
5524 |
+ name: 'center', |
|
5525 |
+ text: this._t('alignCenter'), |
|
5526 |
+ icon: 'align-center', |
|
5527 |
+ param: 'center' |
|
5528 |
+ }, { |
|
5529 |
+ name: 'right', |
|
5530 |
+ text: this._t('alignRight'), |
|
5531 |
+ icon: 'align-right', |
|
5532 |
+ param: 'right' |
|
5533 |
+ } |
|
5534 |
+ ]; |
|
5535 |
+ return AlignmentButton.__super__._init.call(this); |
|
5536 |
+ }; |
|
5537 |
+ |
|
5538 |
+ AlignmentButton.prototype.setActive = function(active, align) { |
|
5539 |
+ if (align == null) { |
|
5540 |
+ align = 'left'; |
|
5541 |
+ } |
|
5542 |
+ if (align !== 'left' && align !== 'center' && align !== 'right') { |
|
5543 |
+ align = 'left'; |
|
5544 |
+ } |
|
5545 |
+ if (align === 'left') { |
|
5546 |
+ AlignmentButton.__super__.setActive.call(this, false); |
|
5547 |
+ } else { |
|
5548 |
+ AlignmentButton.__super__.setActive.call(this, active); |
|
5549 |
+ } |
|
5550 |
+ this.el.removeClass('align-left align-center align-right'); |
|
5551 |
+ if (active) { |
|
5552 |
+ this.el.addClass('align-' + align); |
|
5553 |
+ } |
|
5554 |
+ this.setIcon('align-' + align); |
|
5555 |
+ return this.menuEl.find('.menu-item').show().end().find('.menu-item-' + align).hide(); |
|
5556 |
+ }; |
|
5557 |
+ |
|
5558 |
+ AlignmentButton.prototype._status = function() { |
|
5559 |
+ this.nodes = this.editor.selection.nodes().filter(this.htmlTag); |
|
5560 |
+ if (this.nodes.length < 1) { |
|
5561 |
+ this.setDisabled(true); |
|
5562 |
+ return this.setActive(false); |
|
5563 |
+ } else { |
|
5564 |
+ this.setDisabled(false); |
|
5565 |
+ return this.setActive(true, this.nodes.first().css('text-align')); |
|
5566 |
+ } |
|
5567 |
+ }; |
|
5568 |
+ |
|
5569 |
+ AlignmentButton.prototype.command = function(align) { |
|
5570 |
+ if (align !== 'left' && align !== 'center' && align !== 'right') { |
|
5571 |
+ throw new Error("simditor alignment button: invalid align " + align); |
|
5572 |
+ } |
|
5573 |
+ this.nodes.css({ |
|
5574 |
+ 'text-align': align === 'left' ? '' : align |
|
5575 |
+ }); |
|
5576 |
+ this.editor.trigger('valuechanged'); |
|
5577 |
+ return this.editor.inputManager.throttledSelectionChanged(); |
|
5578 |
+ }; |
|
5579 |
+ |
|
5580 |
+ return AlignmentButton; |
|
5581 |
+ |
|
5582 |
+})(Button); |
|
5583 |
+ |
|
5584 |
+Simditor.Toolbar.addButton(AlignmentButton); |
|
5585 |
+ |
|
5586 |
+return Simditor; |
|
5587 |
+ |
|
5588 |
+})); |
@@ -0,0 +1,25 @@ |
||
1 |
+!function(a,b){"function"==typeof define&&define.amd? |
|
2 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
3 |
+define("simple-module",["jquery"],function(c){return a.Module=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),(c=this.constructor)._connectedClasses||(c._connectedClasses=[]),g=function(){var a,b,c,e;for(c=this.constructor._connectedClasses,e=[],a=0,b=c.length;b>a;a++)d=c[a],i=d.pluginName.charAt(0).toLowerCase()+d.pluginName.slice(1),d.prototype._connected&&(d.prototype._module=this),e.push(this[i]=new d);return e}.call(this),this._connected)this.opts=a.extend({},this.opts,this._module.opts);else for(this._init(),e=0,h=g.length;h>e;e++)f=g[e],"function"==typeof f._init&&f._init();this.trigger("initialized")}return b.extend=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this[b]=d);return null!=(c=a.extended)?c.call(this):void 0}},b.include=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this.prototype[b]=d);return null!=(c=a.included)?c.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):[],e=(null!=(d=this.i18n[this.locale])?d[b]:void 0)||"",a.length>0?(e=e.replace(/([^%]|^)%(?:(\d+)\$)?s/g,function(b,c,d){return d?c+a[parseInt(d)-1]:c+a.shift()}),e.replace(/%%s/g,"%s")):e},b.i18n={"zh-CN":{}},b.locale="zh-CN",b}()});!function(a,b){"function"==typeof define&&define.amd? |
|
4 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
5 |
+define("simple-hotkeys",["jquery","simple-module"],function(c,d){return a.hotkeys=b(c,d)}):"object"==typeof exports? |
|
6 |
+// Node. Does not work with strict CommonJS, but |
|
7 |
+// only CommonJS-like environments that support module.exports, |
|
8 |
+// like Node. |
|
9 |
+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=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(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(f=a.toLowerCase().replace(/\s+/gi,"").split("+"),b=c=0,g=f.length;g>c;b=++c)d=f[b],f[b]=this.aliases[d]||d;return e=f.pop(),f.sort().push(e),f.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)}});!function(a,b){"function"==typeof define&&define.amd? |
|
10 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
11 |
+define("simple-uploader",["jquery","simple-module"],function(c,d){return a.uploader=b(c,d)}):"object"==typeof exports? |
|
12 |
+// Node. Does not work with strict CommonJS, but |
|
13 |
+// only CommonJS-like environments that support module.exports, |
|
14 |
+// like Node. |
|
15 |
+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=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(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)||b instanceof FileList)for(e=0,g=b.length;g>e;e++)d=b[e],this.upload(d,c);else a(b).is("input:file")?(f=a(b).attr("name"),f&&(c.fileKey=f),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){e=b.params;for(d in e)f=e[d],c.append(d,f)}return b.xhr=a.ajax({url:b.url,data:c,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,e){return a.trigger("uploaderror",[b,c,d])}}(this),success:function(c){return function(d){return c.trigger("uploadprogress",[b,b.size,b.size]),c.trigger("uploadsuccess",[b,d]),a(document).trigger("uploadsuccess",[b,d,c])}}(this),complete:function(a){return function(c,d){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)}});/*! |
|
16 |
+* Simditor v2.3.6 |
|
17 |
+* http://simditor.tower.im/ |
|
18 |
+* 2015-12-21 |
|
19 |
+*/ |
|
20 |
+!function(a,b){"function"==typeof define&&define.amd? |
|
21 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
22 |
+define("simditor",["jquery","simple-module","simple-hotkeys","simple-uploader"],function(c,d,e,f){return a.Simditor=b(c,d,e,f)}):"object"==typeof exports?module.exports=b(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader")):a.Simditor=b(jQuery,SimpleModule,simple.hotkeys,simple.uploader)}(this,function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M=function(a,b){function c(){this.constructor=a}for(var d in b)N.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},N={}.hasOwnProperty,O=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},P=[].slice;return C=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Selection",c.prototype._range=null,c.prototype._startNodes=null,c.prototype._endNodes=null,c.prototype._containerNode=null,c.prototype._nodes=null,c.prototype._blockNodes=null,c.prototype._rootNodes=null,c.prototype._init=function(){return this.editor=this._module,this._selection=document.getSelection(),this.editor.on("selectionchanged",function(a){return function(b){return a.reset(),a._range=a._selection.getRangeAt(0)}}(this)),this.editor.on("blur",function(a){return function(b){return a.reset()}}(this))},c.prototype.reset=function(){return this._range=null,this._startNodes=null,this._endNodes=null,this._containerNode=null,this._nodes=null,this._blockNodes=null,this._rootNodes=null},c.prototype.clear=function(){var a;try{this._selection.removeAllRanges()}catch(b){a=b}return this.reset()},c.prototype.range=function(a){var b;return a?(this.clear(),this._selection.addRange(a),this._range=a,b=this.editor.util.browser.firefox||this.editor.util.browser.msie,!this.editor.inputManager.focused&&b&&this.editor.body.focus()):!this._range&&this.editor.inputManager.focused&&this._selection.rangeCount&&(this._range=this._selection.getRangeAt(0)),this._range},c.prototype.startNodes=function(){return this._range&&(this._startNodes||(this._startNodes=function(b){return function(){var c;return c=a(b._range.startContainer).parentsUntil(b.editor.body).get(),c.unshift(b._range.startContainer),a(c)}}(this)())),this._startNodes},c.prototype.endNodes=function(){var b;return this._range&&(this._endNodes||(this._endNodes=this._range.collapsed?this.startNodes():(b=a(this._range.endContainer).parentsUntil(this.editor.body).get(),b.unshift(this._range.endContainer),a(b)))),this._endNodes},c.prototype.containerNode=function(){return this._range&&(this._containerNode||(this._containerNode=a(this._range.commonAncestorContainer))),this._containerNode},c.prototype.nodes=function(){return this._range&&(this._nodes||(this._nodes=function(b){return function(){var c;return c=[],b.startNodes().first().is(b.endNodes().first())?c=b.startNodes().get():(b.startNodes().each(function(d,e){var f,g,h,i,j,k,l;return g=a(e),b.endNodes().index(g)>-1?c.push(e):g.parent().is(b.editor.body)||(k=b.endNodes().index(g.parent()))>-1?(f=k&&k>-1?b.endNodes().eq(k-1):b.endNodes().last(),h=g.parent().contents(),l=h.index(g),i=h.index(f),a.merge(c,h.slice(l,i).get())):(h=g.parent().contents(),j=h.index(g),a.merge(c,h.slice(j).get()))}),b.endNodes().each(function(d,e){var f,g,h;return f=a(e),f.parent().is(b.editor.body)||b.startNodes().index(f.parent())>-1?(c.push(e),!1):(g=f.parent().contents(),h=g.index(f),a.merge(c,g.slice(0,h+1)))})),a(a.unique(c))}}(this)())),this._nodes},c.prototype.blockNodes=function(){return this._range?(this._blockNodes||(this._blockNodes=function(a){return function(){return a.nodes().filter(function(b,c){return a.editor.util.isBlockNode(c)})}}(this)()),this._blockNodes):void 0},c.prototype.rootNodes=function(){return this._range?(this._rootNodes||(this._rootNodes=function(b){return function(){return b.nodes().filter(function(c,d){var e;return e=a(d).parent(),e.is(b.editor.body)||e.is("blockquote")})}}(this)()),this._rootNodes):void 0},c.prototype.rangeAtEndOf=function(b,c){var d,e,f,g,h,i;return null==c&&(c=this.range()),c&&c.collapsed?(b=a(b)[0],f=c.endContainer,g=this.editor.util.getNodeLength(f),e=c.endOffset===g-1,h=a(f).contents().last().is("br"),d=c.endOffset===g,e&&h||d?b===f?!0:a.contains(b,f)?(i=!0,a(f).parentsUntil(b).addBack().each(function(b,c){var d,e,f,g;return g=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),d=g.last(),f=d.get(0)===c,e=d.is("br")&&d.prev().get(0)===c,f||e?void 0:(i=!1,!1)}),i):!1:!1):void 0},c.prototype.rangeAtStartOf=function(b,c){var d,e;return null==c&&(c=this.range()),c&&c.collapsed?(b=a(b)[0],e=c.startContainer,0!==c.startOffset?!1:b===e?!0:a.contains(b,e)?(d=!0,a(e).parentsUntil(b).addBack().each(function(b,c){var e;return e=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),e.first().get(0)!==c?d=!1:void 0}),d):!1):void 0},c.prototype.insertNode=function(b,c){return null==c&&(c=this.range()),c?(b=a(b)[0],c.insertNode(b),this.setRangeAfter(b,c)):void 0},c.prototype.setRangeAfter=function(b,c){return null==c&&(c=this.range()),null!=c?(b=a(b)[0],c.setEndAfter(b),c.collapse(!1),this.range(c)):void 0},c.prototype.setRangeBefore=function(b,c){return null==c&&(c=this.range()),null!=c?(b=a(b)[0],c.setEndBefore(b),c.collapse(!1),this.range(c)):void 0},c.prototype.setRangeAtStartOf=function(b,c){return null==c&&(c=this.range()),b=a(b).get(0),c.setEnd(b,0),c.collapse(!1),this.range(c)},c.prototype.setRangeAtEndOf=function(b,c){var d,e,f,g,h,i,j;return null==c&&(c=this.range()),e=a(b),b=e[0],e.is("pre")?(f=e.contents(),f.length>0?(g=f.last(),i=g.text(),h=this.editor.util.getNodeLength(g[0]),"\n"===i.charAt(i.length-1)?c.setEnd(g[0],h-1):c.setEnd(g[0],h)):c.setEnd(b,0)):(j=this.editor.util.getNodeLength(b),3!==b.nodeType&&j>0&&(d=a(b).contents().last(),d.is("br")?j-=1:3!==d[0].nodeType&&this.editor.util.isEmptyNode(d)&&(d.append(this.editor.util.phBr),b=d[0],j=0)),c.setEnd(b,j)),c.collapse(!1),this.range(c)},c.prototype.deleteRangeContents=function(a){var b,c,d,e;return null==a&&(a=this.range()),e=a.cloneRange(),d=a.cloneRange(),e.collapse(!0),d.collapse(!1),c=this.rangeAtStartOf(this.editor.body,e),b=this.rangeAtEndOf(this.editor.body,d),!a.collapsed&&c&&b?(this.editor.body.empty(),a.setStart(this.editor.body[0],0),a.collapse(!0),this.range(a)):a.deleteContents(),a},c.prototype.breakBlockEl=function(b,c){var d;return null==c&&(c=this.range()),d=a(b),c.collapsed?(c.setStartBefore(d.get(0)),c.collapsed?d:d.before(c.extractContents())):d},c.prototype.save=function(b){var c,d,e;return null==b&&(b=this.range()),this._selectionSaved?void 0:(d=b.cloneRange(),d.collapse(!1),e=a("<span/>").addClass("simditor-caret-start"),c=a("<span/>").addClass("simditor-caret-end"),d.insertNode(c[0]),b.insertNode(e[0]),this.clear(),this._selectionSaved=!0)},c.prototype.restore=function(){var a,b,c,d,e,f,g;return this._selectionSaved?(e=this.editor.body.find(".simditor-caret-start"),a=this.editor.body.find(".simditor-caret-end"),e.length&&a.length?(f=e.parent(),g=f.contents().index(e),b=a.parent(),c=b.contents().index(a),f[0]===b[0]&&(c-=1),d=document.createRange(),d.setStart(f.get(0),g),d.setEnd(b.get(0),c),e.remove(),a.remove(),this.range(d)):(e.remove(),a.remove()),this._selectionSaved=!1,d):!1},c}(b),n=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Formatter",c.prototype.opts={allowedTags:[],allowedAttributes:{},allowedStyles:{}},c.prototype._init=function(){return this.editor=this._module,this._allowedTags=a.merge(["br","span","a","img","b","strong","i","strike","u","font","p","ul","ol","li","blockquote","pre","code","h1","h2","h3","h4","hr"],this.opts.allowedTags),this._allowedAttributes=a.extend({img:["src","alt","width","height","data-non-image"],a:["href","target"],font:["color"],code:["class"]},this.opts.allowedAttributes),this._allowedStyles=a.extend({span:["color","font-size"],b:["color"],i:["color"],strong:["color"],strike:["color"],u:["color"],p:["margin-left","text-align"],h1:["margin-left","text-align"],h2:["margin-left","text-align"],h3:["margin-left","text-align"],h4:["margin-left","text-align"]},this.opts.allowedStyles),this.editor.body.on("click","a",function(a){return!1})},c.prototype.decorate=function(a){return null==a&&(a=this.editor.body),this.editor.trigger("decorate",[a]),a},c.prototype.undecorate=function(a){return null==a&&(a=this.editor.body.clone()),this.editor.trigger("undecorate",[a]),a},c.prototype.autolink=function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o;for(null==b&&(b=this.editor.body),i=[],e=function(c){return c.contents().each(function(c,d){var f,g;return f=a(d),f.is("a")||f.closest("a, pre",b).length?void 0:!f.is("iframe")&&f.contents().length?e(f):(g=f.text())&&/https?:\/\/|www\./gi.test(g)?i.push(f):void 0})},e(b),k=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/gi,f=0,h=i.length;h>f;f++){for(d=i[f],n=d.text(),l=[],j=null,g=0;null!==(j=k.exec(n));)m=n.substring(g,j.index),l.push(document.createTextNode(m)),g=k.lastIndex,o=/^(http(s)?:\/\/|\/)/.test(j[0])?j[0]:"http://"+j[0],c=a('<a href="'+o+'" rel="nofollow"></a>').text(j[0]),l.push(c[0]);l.push(document.createTextNode(n.substring(g))),d.replaceWith(a(l))}return b},c.prototype.format=function(b){var c,d,e,f,g,h,i,j,k,l;if(null==b&&(b=this.editor.body),b.is(":empty"))return b.append("<p>"+this.editor.util.phBr+"</p>"),b;for(k=b.contents(),e=0,g=k.length;g>e;e++)i=k[e],this.cleanNode(i,!0);for(l=b.contents(),f=0,h=l.length;h>f;f++)j=l[f],c=a(j),c.is("br")?("undefined"!=typeof d&&null!==d&&(d=null),c.remove()):this.editor.util.isBlockNode(j)?c.is("li")?d&&d.is("ul, ol")?d.append(j):(d=a("<ul/>").insertBefore(j),d.append(j)):d=null:((!d||d.is("ul, ol"))&&(d=a("<p/>").insertBefore(j)),d.append(j),this.editor.util.isEmptyNode(d)&&d.append(this.editor.util.phBr));return b},c.prototype.cleanNode=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(f=a(b),f.length>0){if(3===f[0].nodeType)return t=f.text().replace(/(\r\n|\n|\r)/gm,""),void(t?(u=document.createTextNode(t),f.replaceWith(u)):f.remove());if(k=f.is("iframe")?null:f.contents(),l=this.editor.util.isDecoratedNode(f),f.is(this._allowedTags.join(","))||l){if(f.is("a")&&(e=f.find("img")).length>0&&(f.replaceWith(e),f=e,k=null),f.is("td")&&(d=f.find(this.editor.util.blockNodes.join(","))).length>0&&(d.each(function(b){return function(b,c){return a(c).contents().unwrap()}}(this)),k=f.contents()),f.is("img")&&f.hasClass("uploading")&&f.remove(),!l){for(i=this._allowedAttributes[f[0].tagName.toLowerCase()],r=a.makeArray(f[0].attributes),m=0,o=r.length;o>m;m++)j=r[m],"style"!==j.name&&(null!=i&&(s=j.name,O.call(i,s)>=0)||f.removeAttr(j.name));this._cleanNodeStyles(f),f.is("span")&&0===f[0].attributes.length&&f.contents().first().unwrap()}}else 1!==f[0].nodeType||f.is(":empty")?(f.remove(),k=null):f.is("div, article, dl, header, footer, tr")?(f.append("<br/>"),k.first().unwrap()):f.is("table")?(g=a("<p/>"),f.find("tr").each(function(b,c){return g.append(a(c).text()+"<br/>")}),f.replaceWith(g),k=null):f.is("thead, tfoot")?(f.remove(),k=null):f.is("th")?(h=a("<td/>").append(f.contents()),f.replaceWith(h)):k.first().unwrap();if(c&&null!=k&&!f.is("pre"))for(n=0,p=k.length;p>n;n++)q=k[n],this.cleanNode(q,!0);return null}},c.prototype._cleanNodeStyles=function(b){var c,d,e,f,g,h,i,j,k;if(j=b.attr("style")){if(b.removeAttr("style"),c=this._allowedStyles[b[0].tagName.toLowerCase()],!(c&&c.length>0))return b;for(k={},g=j.split(";"),d=0,e=g.length;e>d;d++)i=g[d],i=a.trim(i),f=i.split(":"),(f.length=2)&&(h=f[0],O.call(c,h)>=0&&(k[a.trim(f[0])]=a.trim(f[1])));return Object.keys(k).length>0&&b.css(k),b}},c.prototype.clearHtml=function(b,c){var d,e,f;return null==c&&(c=!0),d=a("<div/>").append(b),e=d.contents(),f="",e.each(function(b){return function(d,g){var h,i;return 3===g.nodeType?f+=g.nodeValue:1===g.nodeType&&(h=a(g),i=h.is("iframe")?null:h.contents(),i&&i.length>0&&(f+=b.clearHtml(i)),c&&d<e.length-1&&h.is("br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header"))?f+="\n":void 0}}(this)),f},c.prototype.beautify=function(b){var c;return c=function(a){return!!(a.is("p")&&!a.text()&&a.children(":not(br)").length<1)},b.each(function(b,d){var e,f;return e=a(d),f=e.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty'),(f||c(e))&&e.remove(),e.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove()})},c}(b),t=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="InputManager",c.prototype._modifierKeys=[16,17,18,91,93,224],c.prototype._arrowKeys=[37,38,39,40],c.prototype._init=function(){var b,c;return this.editor=this._module,this.throttledValueChanged=this.editor.util.throttle(function(a){return function(b){return setTimeout(function(){return a.editor.trigger("valuechanged",b)},10)}}(this),300),this.throttledSelectionChanged=this.editor.util.throttle(function(a){return function(){return a.editor.trigger("selectionchanged")}}(this),50),a(document).on("selectionchange.simditor"+this.editor.id,function(a){return function(b){var c;if(a.focused&&!a.editor.clipboard.pasting)return(c=function(){return a._selectionTimer&&(clearTimeout(a._selectionTimer),a._selectionTimer=null),a.editor.selection._selection.rangeCount>0?a.throttledSelectionChanged():a._selectionTimer=setTimeout(function(){return a._selectionTimer=null,a.focused?c():void 0},10)})()}}(this)),this.editor.on("valuechanged",function(b){return function(){var c;return b.lastCaretPosition=null,c=b.editor.body.children().filter(function(a,c){return b.editor.util.isBlockNode(c)}),b.focused&&0===c.length&&(b.editor.selection.save(),b.editor.formatter.format(),b.editor.selection.restore()),b.editor.body.find("hr, pre, .simditor-table").each(function(c,d){var e,f;return e=a(d),(e.parent().is("blockquote")||e.parent()[0]===b.editor.body[0])&&(f=!1,0===e.next().length&&(a("<p/>").append(b.editor.util.phBr).insertAfter(e),f=!0),0===e.prev().length&&(a("<p/>").append(b.editor.util.phBr).insertBefore(e),f=!0),f)?b.throttledValueChanged():void 0}),b.editor.body.find("pre:empty").append(b.editor.util.phBr),!b.editor.util.support.onselectionchange&&b.focused?b.throttledSelectionChanged():void 0}}(this)),this.editor.body.on("keydown",a.proxy(this._onKeyDown,this)).on("keypress",a.proxy(this._onKeyPress,this)).on("keyup",a.proxy(this._onKeyUp,this)).on("mouseup",a.proxy(this._onMouseUp,this)).on("focus",a.proxy(this._onFocus,this)).on("blur",a.proxy(this._onBlur,this)).on("drop",a.proxy(this._onDrop,this)).on("input",a.proxy(this._onInput,this)),this.editor.util.browser.firefox&&(this.editor.hotkeys.add("cmd+left",function(a){return function(b){return b.preventDefault(),a.editor.selection._selection.modify("move","backward","lineboundary"),!1}}(this)),this.editor.hotkeys.add("cmd+right",function(a){return function(b){return b.preventDefault(),a.editor.selection._selection.modify("move","forward","lineboundary"),!1}}(this)),b=this.editor.util.os.mac?"cmd+a":"ctrl+a",this.editor.hotkeys.add(b,function(a){return function(b){var c,d,e,f;return c=a.editor.body.children(),c.length>0?(d=c.first().get(0),e=c.last().get(0),f=document.createRange(),f.setStart(d,0),f.setEnd(e,a.editor.util.getNodeLength(e)),a.editor.selection.range(f),!1):void 0}}(this))),c=this.editor.util.os.mac?"cmd+enter":"ctrl+enter",this.editor.hotkeys.add(c,function(a){return function(b){return a.editor.el.closest("form").find("button:submit").click(),!1}}(this))},c.prototype._onFocus=function(a){return this.editor.clipboard.pasting?void 0:(this.editor.el.addClass("focus").removeClass("error"),this.focused=!0,setTimeout(function(a){return function(){var b,c;return c=a.editor.selection._selection.getRangeAt(0),c.startContainer===a.editor.body[0]&&(a.lastCaretPosition?a.editor.undoManager.caretPosition(a.lastCaretPosition):(b=a.editor.body.children().first(),c=document.createRange(),a.editor.selection.setRangeAtStartOf(b,c))),a.lastCaretPosition=null,a.editor.triggerHandler("focus"),a.editor.util.support.onselectionchange?void 0:a.throttledSelectionChanged()}}(this),0))},c.prototype._onBlur=function(a){var b;if(!this.editor.clipboard.pasting)return this.editor.el.removeClass("focus"),this.editor.sync(),this.focused=!1,this.lastCaretPosition=null!=(b=this.editor.undoManager.currentState())?b.caret:void 0,this.editor.triggerHandler("blur")},c.prototype._onMouseUp=function(a){return this.editor.util.support.onselectionchange?void 0:this.throttledSelectionChanged()},c.prototype._onKeyDown=function(a){var b,c;if(this.editor.triggerHandler(a)===!1)return!1;if(!this.editor.hotkeys.respondTo(a)){if(this.editor.keystroke.respondTo(a))return this.throttledValueChanged(),!1;if(b=a.which,!(O.call(this._modifierKeys,b)>=0||(c=a.which,O.call(this._arrowKeys,c)>=0)||this.editor.util.metaKey(a)&&86===a.which))return this.editor.util.support.oninput||this.throttledValueChanged(["typing"]),null}},c.prototype._onKeyPress=function(a){return this.editor.triggerHandler(a)===!1?!1:void 0},c.prototype._onKeyUp=function(b){var c,d;return this.editor.triggerHandler(b)===!1?!1:!this.editor.util.support.onselectionchange&&(d=b.which,O.call(this._arrowKeys,d)>=0)?void this.throttledValueChanged():void(8!==b.which&&46!==b.which||!this.editor.util.isEmptyNode(this.editor.body)||(this.editor.body.empty(),c=a("<p/>").append(this.editor.util.phBr).appendTo(this.editor.body),this.editor.selection.setRangeAtStartOf(c)))},c.prototype._onDrop=function(a){return this.editor.triggerHandler(a)===!1?!1:this.throttledValueChanged()},c.prototype._onInput=function(a){return this.throttledValueChanged(["oninput"])},c}(b),v=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Keystroke",c.prototype._init=function(){return this.editor=this._module,this._keystrokeHandlers={},this._initKeystrokeHandlers()},c.prototype.add=function(a,b,c){return a=a.toLowerCase(),a=this.editor.hotkeys.constructor.aliases[a]||a,this._keystrokeHandlers[a]||(this._keystrokeHandlers[a]={}),this._keystrokeHandlers[a][b]=c},c.prototype.respondTo=function(b){var c,d,e,f;return(d=null!=(e=this.editor.hotkeys.constructor.keyNameMap[b.which])?e.toLowerCase():void 0)&&d in this._keystrokeHandlers&&(f="function"==typeof(c=this._keystrokeHandlers[d])["*"]?c["*"](b):void 0,f||this.editor.selection.startNodes().each(function(c){return function(e,g){var h,i;if(g.nodeType===Node.ELEMENT_NODE)return h=null!=(i=c._keystrokeHandlers[d])?i[g.tagName.toLowerCase()]:void 0,f="function"==typeof h?h(b,a(g)):void 0,f===!0||f===!1?!1:void 0}}(this)),f)?!0:void 0},c.prototype._initKeystrokeHandlers=function(){var b;return this.editor.util.browser.safari&&this.add("enter","*",function(b){return function(c){var d,e;if(c.shiftKey&&(d=b.editor.selection.blockNodes().last(),!d.is("pre")))return e=a("<br/>"),b.editor.selection.rangeAtEndOf(d)?(b.editor.selection.insertNode(e),b.editor.selection.insertNode(a("<br/>")),b.editor.selection.setRangeBefore(e)):b.editor.selection.insertNode(e),!0}}(this)),(this.editor.util.browser.webkit||this.editor.util.browser.msie)&&(b=function(b){return function(c,d){var e;if(b.editor.selection.rangeAtEndOf(d))return e=a("<p/>").append(b.editor.util.phBr).insertAfter(d),b.editor.selection.setRangeAtStartOf(e),!0}}(this),this.add("enter","h1",b),this.add("enter","h2",b),this.add("enter","h3",b),this.add("enter","h4",b),this.add("enter","h5",b),this.add("enter","h6",b)),this.add("backspace","*",function(a){return function(b){var c,d,e,f;return e=a.editor.selection.rootNodes().first(),d=e.prev(),d.is("hr")&&a.editor.selection.rangeAtStartOf(e)?(a.editor.selection.save(),d.remove(),a.editor.selection.restore(),!0):(c=a.editor.selection.blockNodes().last(),f=a.editor.util.browser.webkit,f&&a.editor.selection.rangeAtStartOf(c)?(a.editor.selection.save(),a.editor.formatter.cleanNode(c,!0),a.editor.selection.restore(),null):void 0)}}(this)),this.add("enter","li",function(b){return function(c,d){var e,f,g,h;if(e=d.clone(),e.find("ul, ol").remove(),b.editor.util.isEmptyNode(e)&&d.is(b.editor.selection.blockNodes().last())){if(f=d.parent(),d.next("li").length>0){if(!b.editor.util.isEmptyNode(d))return;f.parent("li").length>0?(g=a("<li/>").append(b.editor.util.phBr).insertAfter(f.parent("li")),h=a("<"+f[0].tagName+"/>").append(d.nextAll("li")),g.append(h)):(g=a("<p/>").append(b.editor.util.phBr).insertAfter(f),h=a("<"+f[0].tagName+"/>").append(d.nextAll("li")),g.after(h))}else f.parent("li").length>0?(g=a("<li/>").insertAfter(f.parent("li")),d.contents().length>0?g.append(d.contents()):g.append(b.editor.util.phBr)):(g=a("<p/>").append(b.editor.util.phBr).insertAfter(f),d.children("ul, ol").length>0&&g.after(d.children("ul, ol")));return d.prev("li").length?d.remove():f.remove(),b.editor.selection.setRangeAtStartOf(g),!0}}}(this)),this.add("enter","pre",function(b){return function(c,d){var e,f,g;return c.preventDefault(),c.shiftKey?(e=a("<p/>").append(b.editor.util.phBr).insertAfter(d),b.editor.selection.setRangeAtStartOf(e),!0):(g=b.editor.selection.range(),f=null,g.deleteContents(),!b.editor.util.browser.msie&&b.editor.selection.rangeAtEndOf(d)?(f=document.createTextNode("\n\n"),g.insertNode(f),g.setEnd(f,1)):(f=document.createTextNode("\n"),g.insertNode(f),g.setStartAfter(f)),g.collapse(!1),b.editor.selection.range(g),!0)}}(this)),this.add("enter","blockquote",function(a){return function(b,c){var d,e;return d=a.editor.selection.blockNodes().last(),d.is("p")&&!d.next().length&&a.editor.util.isEmptyNode(d)?(c.after(d),e=document.createRange(),a.editor.selection.setRangeAtStartOf(d,e),!0):void 0}}(this)),this.add("backspace","li",function(b){return function(c,d){var e,f,g,h,i,j,k,l,m;return f=d.children("ul, ol"),i=d.prev("li"),f.length>0&&i.length>0?(m="",j=null,d.contents().each(function(b,c){if(1===c.nodeType&&/UL|OL/.test(c.nodeName))return!1;if(1!==c.nodeType||!/BR/.test(c.nodeName))return 3===c.nodeType&&c.nodeValue?m+=c.nodeValue:1===c.nodeType&&(m+=a(c).text()),j=a(c)}),k=b.editor.util.browser.firefox&&!j.next("br").length,j&&1===m.length&&k?(e=a(b.editor.util.phBr).insertAfter(j),j.remove(),b.editor.selection.setRangeBefore(e),!0):m.length>0?!1:(l=document.createRange(),h=i.children("ul, ol"),h.length>0?(g=a("<li/>").append(b.editor.util.phBr).appendTo(h),h.append(f.children("li")),d.remove(),b.editor.selection.setRangeAtEndOf(g,l)):(b.editor.selection.setRangeAtEndOf(i,l),i.append(f),d.remove(),b.editor.selection.range(l)),!0)):!1}}(this)),this.add("backspace","pre",function(b){return function(c,d){var e,f,g;if(b.editor.selection.rangeAtStartOf(d))return f=d.html().replace("\n","<br/>")||b.editor.util.phBr,e=a("<p/>").append(f).insertAfter(d),d.remove(),g=document.createRange(),b.editor.selection.setRangeAtStartOf(e,g),!0}}(this)),this.add("backspace","blockquote",function(a){return function(b,c){var d,e;if(a.editor.selection.rangeAtStartOf(c))return d=c.children().first().unwrap(),e=document.createRange(),a.editor.selection.setRangeAtStartOf(d,e),!0}}(this))},c}(b),J=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="UndoManager",c.prototype._index=-1,c.prototype._capacity=20,c.prototype._startPosition=null,c.prototype._endPosition=null,c.prototype._init=function(){var a,b;return this.editor=this._module,this._stack=[],this.editor.util.os.mac?(b="cmd+z",a="shift+cmd+z"):this.editor.util.os.win?(b="ctrl+z",a="ctrl+y"):(b="ctrl+z",a="shift+ctrl+z"),this.editor.hotkeys.add(b,function(a){return function(b){return b.preventDefault(),a.undo(),!1}}(this)),this.editor.hotkeys.add(a,function(a){return function(b){return b.preventDefault(),a.redo(),!1}}(this)),this.throttledPushState=this.editor.util.throttle(function(a){return function(){return a._pushUndoState()}}(this),2e3),this.editor.on("valuechanged",function(a){return function(b,c){return"undo"!==c&&"redo"!==c?a.throttledPushState():void 0}}(this)),this.editor.on("selectionchanged",function(a){return function(b){return a.resetCaretPosition(),a.update()}}(this)),this.editor.on("focus",function(a){return function(b){return 0===a._stack.length?a._pushUndoState():void 0}}(this)),this.editor.on("blur",function(a){return function(b){return a.resetCaretPosition()}}(this))},c.prototype.resetCaretPosition=function(){return this._startPosition=null,this._endPosition=null},c.prototype.startPosition=function(){return this.editor.selection._range&&(this._startPosition||(this._startPosition=this._getPosition("start"))),this._startPosition},c.prototype.endPosition=function(){return this.editor.selection._range&&(this._endPosition||(this._endPosition=function(a){return function(){var b;return b=a.editor.selection.range(),b.collapsed?a._startPosition:a._getPosition("end")}}(this)())),this._endPosition},c.prototype._pushUndoState=function(){var a;if(this.editor.triggerHandler("pushundostate")!==!1&&(a=this.caretPosition(),a.start))return this._index+=1,this._stack.length=this._index,this._stack.push({html:this.editor.body.html(),caret:this.caretPosition()}),this._stack.length>this._capacity?(this._stack.shift(),this._index-=1):void 0},c.prototype.currentState=function(){return this._stack.length&&this._index>-1?this._stack[this._index]:null},c.prototype.undo=function(){var a;if(!(this._index<1||this._stack.length<2))return this.editor.hidePopover(),this._index-=1,a=this._stack[this._index],this.editor.body.get(0).innerHTML=a.html,this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["undo"])},c.prototype.redo=function(){var a;if(!(this._index<0||this._stack.length<this._index+2))return this.editor.hidePopover(),this._index+=1,a=this._stack[this._index],this.editor.body.get(0).innerHTML=a.html,this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["redo"])},c.prototype.update=function(){var a;return(a=this.currentState())?(a.html=this.editor.body.html(),a.caret=this.caretPosition()):void 0},c.prototype._getNodeOffset=function(b,c){var d,e,f;return d=a.isNumeric(c)?a(b):a(b).parent(),f=0,e=!1,d.contents().each(function(a,d){return b===d||c===a&&0===a?!1:(d.nodeType===Node.TEXT_NODE?!e&&d.nodeValue.length>0&&(f+=1,e=!0):(f+=1,e=!1),c-1===a?!1:null)}),f},c.prototype._getPosition=function(b){var c,d,e,f,g,h,i;if(null==b&&(b="start"),i=this.editor.selection.range(),f=i[b+"Offset"],c=this.editor.selection[b+"Nodes"](),d=c.first()[0],d.nodeType===Node.TEXT_NODE){for(h=d.previousSibling;h&&h.nodeType===Node.TEXT_NODE;)d=h,f+=this.editor.util.getNodeLength(h),h=h.previousSibling;e=c.get(),e[0]=d,c=a(e)}else f=this._getNodeOffset(d,f);return g=[f],c.each(function(a){return function(b,c){return g.unshift(a._getNodeOffset(c))}}(this)),g},c.prototype._getNodeByPosition=function(b){var c,d,e,f,g,h,i,j;for(h=this.editor.body[0],j=b.slice(0,b.length-1),e=f=0,g=j.length;g>f;e=++f){if(i=j[e],d=h.childNodes,i>d.length-1){if(e!==b.length-2||!a(h).is("pre:empty")){h=null;break}c=document.createTextNode(""),h.appendChild(c),d=h.childNodes}h=d[i]}return h},c.prototype.caretPosition=function(a){var b,c,d,e,f;if(a){if(!a.start)return;return e=this._getNodeByPosition(a.start),f=a.start[a.start.length-1],a.collapsed?(b=e,c=f):(b=this._getNodeByPosition(a.end),c=a.start[a.start.length-1]),e&&b?(d=document.createRange(),d.setStart(e,f),d.setEnd(b,c),this.editor.selection.range(d)):void("undefined"!=typeof console&&null!==console&&"function"==typeof console.warn&&console.warn("simditor: invalid caret state"))}return d=this.editor.selection.range(),a=this.editor.inputManager.focused&&null!=d?{start:this.startPosition(),end:this.endPosition(),collapsed:d.collapsed}:{}},c}(b),L=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Util",c.prototype._init=function(){return this.editor=this._module,this.browser.msie&&this.browser.version<11?this.phBr="":void 0},c.prototype.phBr="<br/>",c.prototype.os=function(){var a;return a={},/Mac/.test(navigator.appVersion)?a.mac=!0:/Linux/.test(navigator.appVersion)?a.linux=!0:/Win/.test(navigator.appVersion)?a.win=!0:/X11/.test(navigator.appVersion)&&(a.unix=!0),/Mobi/.test(navigator.appVersion)&&(a.mobile=!0),a}(),c.prototype.browser=function(){var a,b,c,d,e,f,g,h,i,j,k;return k=navigator.userAgent,d=/(msie|trident)/i.test(k),a=/chrome|crios/i.test(k),j=/safari/i.test(k)&&!a,c=/firefox/i.test(k),b=/edge/i.test(k),d?{msie:!0,version:1*(null!=(e=k.match(/(msie |rv:)(\d+(\.\d+)?)/i))?e[2]:void 0)}:b?{edge:!0,webkit:!0,version:1*(null!=(f=k.match(/edge\/(\d+(\.\d+)?)/i))?f[1]:void 0)}:a?{webkit:!0,chrome:!0,version:1*(null!=(g=k.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i))?g[1]:void 0)}:j?{webkit:!0,safari:!0,version:1*(null!=(h=k.match(/version\/(\d+(\.\d+)?)/i))?h[1]:void 0)}:c?{mozilla:!0,firefox:!0,version:1*(null!=(i=k.match(/firefox\/(\d+(\.\d+)?)/i))?i[1]:void 0)}:{}}(),c.prototype.support=function(){return{onselectionchange:function(){var a,b;if(b=document.onselectionchange,void 0!==b)try{return document.onselectionchange=0,null===document.onselectionchange}catch(c){a=c}finally{document.onselectionchange=b}return!1}(),oninput:function(){return!/(msie|trident)/i.test(navigator.userAgent)}()}}(),c.prototype.reflow=function(b){return null==b&&(b=document),a(b)[0].offsetHeight},c.prototype.metaKey=function(a){var b;return b=/Mac/.test(navigator.userAgent),b?a.metaKey:a.ctrlKey},c.prototype.isEmptyNode=function(b){var c;return c=a(b),c.is(":empty")||!c.text()&&!c.find(":not(br, span, div)").length},c.prototype.isDecoratedNode=function(b){return a(b).is('[class^="simditor-"]')},c.prototype.blockNodes=["div","p","ul","ol","li","blockquote","hr","pre","h1","h2","h3","h4","h5","table"],c.prototype.isBlockNode=function(b){return b=a(b)[0],b&&3!==b.nodeType?new RegExp("^("+this.blockNodes.join("|")+")$").test(b.nodeName.toLowerCase()):!1},c.prototype.getNodeLength=function(b){switch(b=a(b)[0],b.nodeType){case 7:case 10:return 0;case 3:case 8:return b.length;default:return b.childNodes.length}},c.prototype.dataURLtoBlob=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;if(h=window.Blob&&function(){var a;try{return Boolean(new Blob)}catch(b){return a=b,!1}}(),g=h&&window.Uint8Array&&function(){var a;try{return 100===new Blob([new Uint8Array(100)]).size}catch(b){return a=b,!1}}(),b=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,n=h||b,!(n&&window.atob&&window.ArrayBuffer&&window.Uint8Array))return!1;for(f=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),c=new ArrayBuffer(f.length),j=new Uint8Array(c),i=k=0,m=f.length;m>=0?m>=k:k>=m;i=m>=0?++k:--k)j[i]=f.charCodeAt(i);return l=a.split(",")[0].split(":")[1].split(";")[0],h?(e=g?j:c,new Blob([e],{type:l})):(d=new b,d.append(c),d.getBlob(l))},c.prototype.throttle=function(a,b){var c,d,e,f,g,h,i;return f=0,i=0,e=c=g=null,d=function(){return i=0,f=+new Date,g=a.apply(e,c),e=null,c=null},h=function(){var a;return e=this,c=arguments,a=new Date-f,i||(a>=b?d():i=setTimeout(d,b-a)),g},h.clear=function(){return i?(clearTimeout(i),d()):void 0},h},c.prototype.formatHTML=function(b){var c,d,e,f,g,h,i,j,k;for(h=/<(\/?)(.+?)(\/?)>/g,j="",f=0,e=null,d=" ",i=function(a,b){return new Array(b+1).join(a)};null!==(g=h.exec(b));)g.isBlockNode=a.inArray(g[2],this.blockNodes)>-1,g.isStartTag="/"!==g[1]&&"/"!==g[3],g.isEndTag="/"===g[1]||"/"===g[3],c=e?e.index+e[0].length:0,(k=b.substring(c,g.index)).length>0&&a.trim(k)&&(j+=k),g.isBlockNode&&g.isEndTag&&!g.isStartTag&&(f-=1),g.isBlockNode&&g.isStartTag&&(e&&e.isBlockNode&&e.isEndTag||(j+="\n"),j+=i(d,f)),j+=g[0],g.isBlockNode&&g.isEndTag&&(j+="\n"),g.isBlockNode&&g.isStartTag&&(f+=1),e=g;return a.trim(j)},c}(b),H=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Toolbar",c.prototype.opts={toolbar:!0,toolbarFloat:!0, |
|
23 |
+toolbarHidden:!1,toolbarFloatOffset:0},c.prototype._tpl={wrapper:'<div class="simditor-toolbar"><ul></ul></div>',separator:'<li><span class="separator"></span></li>'},c.prototype._init=function(){var b,c,d;return this.editor=this._module,this.opts.toolbar?(a.isArray(this.opts.toolbar)||(this.opts.toolbar=["bold","italic","underline","strikethrough","|","ol","ul","blockquote","code","|","link","image","|","indent","outdent"]),this._render(),this.list.on("click",function(a){return!1}),this.wrapper.on("mousedown",function(a){return function(b){return a.list.find(".menu-on").removeClass(".menu-on")}}(this)),a(document).on("mousedown.simditor"+this.editor.id,function(a){return function(b){return a.list.find(".menu-on").removeClass(".menu-on")}}(this)),!this.opts.toolbarHidden&&this.opts.toolbarFloat&&(this.wrapper.css("top",this.opts.toolbarFloatOffset),d=0,c=function(a){return function(){return a.wrapper.css("position","static"),a.wrapper.width("auto"),a.editor.util.reflow(a.wrapper),a.wrapper.width(a.wrapper.outerWidth()),a.wrapper.css("left",a.editor.util.os.mobile?a.wrapper.position().left:a.wrapper.offset().left),a.wrapper.css("position",""),d=a.wrapper.outerHeight(),a.editor.placeholderEl.css("top",d),!0}}(this),b=null,a(window).on("resize.simditor-"+this.editor.id,function(a){return b=c()}),a(window).on("scroll.simditor-"+this.editor.id,function(e){return function(f){var g,h,i;if(e.wrapper.is(":visible"))if(i=e.editor.wrapper.offset().top,g=i+e.editor.wrapper.outerHeight()-80,h=a(document).scrollTop()+e.opts.toolbarFloatOffset,i>=h||h>=g){if(e.editor.wrapper.removeClass("toolbar-floating").css("padding-top",""),e.editor.util.os.mobile)return e.wrapper.css("top",e.opts.toolbarFloatOffset)}else if(b||(b=c()),e.editor.wrapper.addClass("toolbar-floating").css("padding-top",d),e.editor.util.os.mobile)return e.wrapper.css("top",h-i+e.opts.toolbarFloatOffset)}}(this))),this.editor.on("destroy",function(a){return function(){return a.buttons.length=0}}(this)),a(document).on("mousedown.simditor-"+this.editor.id,function(a){return function(b){return a.list.find("li.menu-on").removeClass("menu-on")}}(this))):void 0},c.prototype._render=function(){var b,c,d,e;for(this.buttons=[],this.wrapper=a(this._tpl.wrapper).prependTo(this.editor.wrapper),this.list=this.wrapper.find("ul"),e=this.opts.toolbar,b=0,c=e.length;c>b;b++)if(d=e[b],"|"!==d){if(!this.constructor.buttons[d])throw new Error("simditor: invalid toolbar button "+d);this.buttons.push(new this.constructor.buttons[d]({editor:this.editor}))}else a(this._tpl.separator).appendTo(this.list);return this.opts.toolbarHidden?this.wrapper.hide():void 0},c.prototype.findButton=function(a){var b;return b=this.list.find(".toolbar-item-"+a).data("button"),null!=b?b:null},c.addButton=function(a){return this.buttons[a.prototype.name]=a},c.buttons={},c}(b),s=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Indentation",c.prototype.opts={tabIndent:!0},c.prototype._init=function(){return this.editor=this._module,this.editor.keystroke.add("tab","*",function(a){return function(b){var c;return c=a.editor.toolbar.findButton("code"),a.opts.tabIndent||c&&c.active?a.indent(b.shiftKey):void 0}}(this))},c.prototype.indent=function(b){var c,d,e,f,g;return e=this.editor.selection.startNodes(),d=this.editor.selection.endNodes(),c=this.editor.selection.blockNodes(),f=[],c=c.each(function(b,c){var d,e,g,h,i;for(d=!0,e=g=0,h=f.length;h>g;e=++g){if(i=f[e],a.contains(c,i)){d=!1;break}if(a.contains(i,c)){f.splice(e,1,c),d=!1;break}}return d?f.push(c):void 0}),c=a(f),g=!1,c.each(function(a){return function(c,d){var e;return e=b?a.outdentBlock(d):a.indentBlock(d),e?g=e:void 0}}(this)),g},c.prototype.indentBlock=function(b){var c,d,e,f,g,h,i,j,k,l;if(c=a(b),c.length){if(c.is("pre")){if(h=this.editor.selection.containerNode(),!h.is(c)&&!h.closest("pre").is(c))return;this.indentText(this.editor.selection.range())}else if(c.is("li")){if(g=c.prev("li"),g.length<1)return;this.editor.selection.save(),l=c.parent()[0].tagName,d=g.children("ul, ol"),d.length>0?d.append(c):a("<"+l+"/>").append(c).appendTo(g),this.editor.selection.restore()}else if(c.is("p, h1, h2, h3, h4"))k=parseInt(c.css("margin-left"))||0,k=(Math.round(k/this.opts.indentWidth)+1)*this.opts.indentWidth,c.css("margin-left",k);else{if(!c.is("table")&&!c.is(".simditor-table"))return!1;if(i=this.editor.selection.containerNode().closest("td, th"),e=i.next("td, th"),e.length>0||(j=i.parent("tr"),f=j.next("tr"),f.length<1&&j.parent().is("thead")&&(f=j.parent("thead").next("tbody").find("tr:first")),e=f.find("td:first, th:first")),!(i.length>0&&e.length>0))return;this.editor.selection.setRangeAtEndOf(e)}return!0}},c.prototype.indentText=function(a){var b,c;return b=a.toString().replace(/^(?=.+)/gm," "),c=document.createTextNode(b||" "),a.deleteContents(),a.insertNode(c),b?(a.selectNode(c),this.editor.selection.range(a)):this.editor.selection.setRangeAfter(c)},c.prototype.outdentBlock=function(b){var c,d,e,f,g,h,i,j,k,l;if(c=a(b),c&&c.length>0){if(c.is("pre")){if(f=this.editor.selection.containerNode(),!f.is(c)&&!f.closest("pre").is(c))return;this.outdentText(l)}else if(c.is("li"))d=c.parent(),e=d.parent("li"),this.editor.selection.save(),e.length<1?(l=document.createRange(),l.setStartBefore(d[0]),l.setEndBefore(c[0]),d.before(l.extractContents()),a("<p/>").insertBefore(d).after(c.children("ul, ol")).append(c.contents()),c.remove()):(c.next("li").length>0&&a("<"+d[0].tagName+"/>").append(c.nextAll("li")).appendTo(c),c.insertAfter(e),d.children("li").length<1&&d.remove()),this.editor.selection.restore();else if(c.is("p, h1, h2, h3, h4"))k=parseInt(c.css("margin-left"))||0,k=Math.max(Math.round(k/this.opts.indentWidth)-1,0)*this.opts.indentWidth,c.css("margin-left",0===k?"":k);else{if(!c.is("table")&&!c.is(".simditor-table"))return!1;if(i=this.editor.selection.containerNode().closest("td, th"),g=i.prev("td, th"),g.length>0||(j=i.parent("tr"),h=j.prev("tr"),h.length<1&&j.parent().is("tbody")&&(h=j.parent("tbody").prev("thead").find("tr:first")),g=h.find("td:last, th:last")),!(i.length>0&&g.length>0))return;this.editor.selection.setRangeAtEndOf(g)}return!0}},c.prototype.outdentText=function(a){},c}(b),i=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Clipboard",c.prototype.opts={pasteImage:!1,cleanPaste:!1},c.prototype._init=function(){return this.editor=this._module,this.opts.pasteImage&&"string"!=typeof this.opts.pasteImage&&(this.opts.pasteImage="inline"),this.editor.body.on("paste",function(a){return function(b){var c;if(!a.pasting&&!a._pasteBin)return a.editor.triggerHandler(b)===!1?!1:(c=a.editor.selection.deleteRangeContents(),a.editor.body.html()?c.collapsed||c.collapse(!0):(a.editor.formatter.format(),a.editor.selection.setRangeAtStartOf(a.editor.body.find("p:first"))),a._processPasteByClipboardApi(b)?!1:(a.editor.inputManager.throttledValueChanged.clear(),a.editor.inputManager.throttledSelectionChanged.clear(),a.editor.undoManager.throttledPushState.clear(),a.editor.selection.reset(),a.editor.undoManager.resetCaretPosition(),a.pasting=!0,a._getPasteContent(function(b){return a._processPasteContent(b),a._pasteInBlockEl=null,a._pastePlainText=null,a.pasting=!1})))}}(this))},c.prototype._processPasteByClipboardApi=function(a){var b,c,d,e;if(!this.editor.util.browser.edge&&a.originalEvent.clipboardData&&a.originalEvent.clipboardData.items&&a.originalEvent.clipboardData.items.length>0&&(c=a.originalEvent.clipboardData.items[0],/^image\//.test(c.type))){if(b=c.getAsFile(),null==b||!this.opts.pasteImage)return;if(b.name||(b.name="Clipboard Image.png"),this.editor.triggerHandler("pasting",[b])===!1)return;return e={},e[this.opts.pasteImage]=!0,null!=(d=this.editor.uploader)&&d.upload(b,e),!0}},c.prototype._getPasteContent=function(b){var c;return this._pasteBin=a('<div contenteditable="true" />').addClass("simditor-paste-bin").attr("tabIndex","-1").appendTo(this.editor.el),c={html:this.editor.body.html(),caret:this.editor.undoManager.caretPosition()},this._pasteBin.focus(),setTimeout(function(d){return function(){var e;return d.editor.hidePopover(),d.editor.body.get(0).innerHTML=c.html,d.editor.undoManager.caretPosition(c.caret),d.editor.body.focus(),d.editor.selection.reset(),d.editor.selection.range(),d._pasteInBlockEl=d.editor.selection.blockNodes().last(),d._pastePlainText=d.opts.cleanPaste||d._pasteInBlockEl.is("pre, table"),d._pastePlainText?e=d.editor.formatter.clearHtml(d._pasteBin.html(),!0):(e=a("<div/>").append(d._pasteBin.contents()),e.find("table colgroup").remove(),d.editor.formatter.format(e),d.editor.formatter.decorate(e),d.editor.formatter.beautify(e.children()),e=e.contents()),d._pasteBin.remove(),d._pasteBin=null,b(e)}}(this),0)},c.prototype._processPasteContent=function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;if(this.editor.triggerHandler("pasting",[b])!==!1&&(c=this._pasteInBlockEl,b)){if(this._pastePlainText)if(c.is("table")){for(q=b.split("\n"),j=q.pop(),h=0,k=q.length;k>h;h++)p=q[h],this.editor.selection.insertNode(document.createTextNode(p)),this.editor.selection.insertNode(a("<br/>"));this.editor.selection.insertNode(document.createTextNode(j))}else for(b=a("<div/>").text(b),v=b.contents(),i=0,l=v.length;l>i;i++)s=v[i],this.editor.selection.insertNode(a(s)[0]);else if(c.is(this.editor.body))for(r=0,m=b.length;m>r;r++)s=b[r],this.editor.selection.insertNode(s);else{if(b.length<1)return;if(1===b.length)if(b.is("p")){if(f=b.contents(),1===f.length&&f.is("img")){if(d=f,/^data:image/.test(d.attr("src"))){if(!this.opts.pasteImage)return;return e=this.editor.util.dataURLtoBlob(d.attr("src")),e.name="Clipboard Image.png",y={},y[this.opts.pasteImage]=!0,void(null!=(w=this.editor.uploader)&&w.upload(e,y))}if(d.is('img[src^="webkit-fake-url://"]'))return}for(t=0,n=f.length;n>t;t++)s=f[t],this.editor.selection.insertNode(s)}else if(c.is("p")&&this.editor.util.isEmptyNode(c))c.replaceWith(b),this.editor.selection.setRangeAtEndOf(b);else if(b.is("ul, ol"))if(1===b.find("li").length)for(b=a("<div/>").text(b.text()),x=b.contents(),u=0,o=x.length;o>u;u++)s=x[u],this.editor.selection.insertNode(a(s)[0]);else c.is("li")?(c.parent().after(b),this.editor.selection.setRangeAtEndOf(b)):(c.after(b),this.editor.selection.setRangeAtEndOf(b));else c.after(b),this.editor.selection.setRangeAtEndOf(b);else c.is("li")&&(c=c.parent()),this.editor.selection.rangeAtStartOf(c)?g="before":this.editor.selection.rangeAtEndOf(c)?g="after":(this.editor.selection.breakBlockEl(c),g="before"),c[g](b),this.editor.selection.setRangeAtEndOf(b.last())}return this.editor.inputManager.throttledValueChanged()}},c}(b),D=function(b){function e(){return e.__super__.constructor.apply(this,arguments)}return M(e,b),e.connect(L),e.connect(t),e.connect(C),e.connect(J),e.connect(v),e.connect(n),e.connect(H),e.connect(s),e.connect(i),e.count=0,e.prototype.opts={textarea:null,placeholder:"",defaultImage:"images/image.png",params:{},upload:!1,indentWidth:40},e.prototype._init=function(){var b,f,g,h;if(this.textarea=a(this.opts.textarea),this.opts.placeholder=this.opts.placeholder||this.textarea.attr("placeholder"),!this.textarea.length)throw new Error("simditor: param textarea is required.");if(f=this.textarea.data("simditor"),null!=f&&f.destroy(),this.id=++e.count,this._render(),!c)throw new Error("simditor: simple-hotkeys is required.");if(this.hotkeys=c({el:this.body}),this.opts.upload&&d&&(h="object"==typeof this.opts.upload?this.opts.upload:{},this.uploader=d(h)),g=this.textarea.closest("form"),g.length&&(g.on("submit.simditor-"+this.id,function(a){return function(){return a.sync()}}(this)),g.on("reset.simditor-"+this.id,function(a){return function(){return a.setValue("")}}(this))),this.on("initialized",function(a){return function(){return a.opts.placeholder&&a.on("valuechanged",function(){return a._placeholder()}),a.setValue(a.textarea.val().trim()||""),a.textarea.attr("autofocus")?a.focus():void 0}}(this)),this.util.browser.mozilla){this.util.reflow();try{return document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(i){b=i}}},e.prototype._tpl='<div class="simditor">\n <div class="simditor-wrapper">\n <div class="simditor-placeholder"></div>\n <div class="simditor-body" contenteditable="true">\n </div>\n </div>\n</div>',e.prototype._render=function(){var b,c,d,e;if(this.el=a(this._tpl).insertBefore(this.textarea),this.wrapper=this.el.find(".simditor-wrapper"),this.body=this.wrapper.find(".simditor-body"),this.placeholderEl=this.wrapper.find(".simditor-placeholder").append(this.opts.placeholder),this.el.data("simditor",this),this.wrapper.append(this.textarea),this.textarea.data("simditor",this).blur(),this.body.attr("tabindex",this.textarea.attr("tabindex")),this.util.os.mac?this.el.addClass("simditor-mac"):this.util.os.linux&&this.el.addClass("simditor-linux"),this.util.os.mobile&&this.el.addClass("simditor-mobile"),this.opts.params){c=this.opts.params,d=[];for(b in c)e=c[b],d.push(a("<input/>",{type:"hidden",name:b,value:e}).insertAfter(this.textarea));return d}},e.prototype._placeholder=function(){var a;return a=this.body.children(),0===a.length||1===a.length&&this.util.isEmptyNode(a)&&parseInt(a.css("margin-left")||0)<this.opts.indentWidth?this.placeholderEl.show():this.placeholderEl.hide()},e.prototype.setValue=function(a){return this.hidePopover(),this.textarea.val(a),this.body.get(0).innerHTML=a,this.formatter.format(),this.formatter.decorate(),this.util.reflow(this.body),this.inputManager.lastCaretPosition=null,this.trigger("valuechanged")},e.prototype.getValue=function(){return this.sync()},e.prototype.sync=function(){var b,c,d,e,f,g;for(c=this.body.clone(),this.formatter.undecorate(c),this.formatter.format(c),this.formatter.autolink(c),b=c.children(),f=b.last("p"),e=b.first("p");f.is("p")&&this.util.isEmptyNode(f);)d=f,f=f.prev("p"),d.remove();for(;e.is("p")&&this.util.isEmptyNode(e);)d=e,e=f.next("p"),d.remove();return c.find("img.uploading").remove(),g=a.trim(c.html()),this.textarea.val(g),g},e.prototype.focus=function(){var b,c;return this.body.is(":visible")&&this.body.is("[contenteditable]")?this.inputManager.lastCaretPosition?(this.undoManager.caretPosition(this.inputManager.lastCaretPosition),this.inputManager.lastCaretPosition=null):(b=this.body.children().last(),b.is("p")||(b=a("<p/>").append(this.util.phBr).appendTo(this.body)),c=document.createRange(),this.selection.setRangeAtEndOf(b,c)):void this.el.find("textarea:visible").focus()},e.prototype.blur=function(){return this.body.is(":visible")&&this.body.is("[contenteditable]")?this.body.blur():this.body.find("textarea:visible").blur()},e.prototype.hidePopover=function(){return this.el.find(".simditor-popover").each(function(b,c){return c=a(c).data("popover"),c.active?c.hide():void 0})},e.prototype.destroy=function(){return this.triggerHandler("destroy"),this.textarea.closest("form").off(".simditor .simditor-"+this.id),this.selection.clear(),this.inputManager.focused=!1,this.textarea.insertBefore(this.el).hide().val("").removeData("simditor"),this.el.remove(),a(document).off(".simditor-"+this.id),a(window).off(".simditor-"+this.id),this.off()},e}(b),D.i18n={"zh-CN":{blockquote:"引用",bold:"加粗文字",code:"插入代码",color:"文字颜色",coloredText:"彩色文字",hr:"分隔线",image:"插入图片",externalImage:"外链图片",uploadImage:"上传图片",uploadFailed:"上传失败了",uploadError:"上传出错了",imageUrl:"图片地址",imageSize:"图片尺寸",imageAlt:"图片描述",restoreImageSize:"还原图片尺寸",uploading:"正在上传",indent:"向右缩进",outdent:"向左缩进",italic:"斜体文字",link:"插入链接",linkText:"链接文字",linkUrl:"链接地址",linkTarget:"打开方式",openLinkInCurrentWindow:"在新窗口中打开",openLinkInNewWindow:"在当前窗口中打开",removeLink:"移除链接",ol:"有序列表",ul:"无序列表",strikethrough:"删除线文字",table:"表格",deleteRow:"删除行",insertRowAbove:"在上面插入行",insertRowBelow:"在下面插入行",deleteColumn:"删除列",insertColumnLeft:"在左边插入列",insertColumnRight:"在右边插入列",deleteTable:"删除表格",title:"标题",normalText:"普通文本",underline:"下划线文字",alignment:"水平对齐",alignCenter:"居中",alignLeft:"居左",alignRight:"居右",selectLanguage:"选择程序语言",fontScale:"字体大小",fontScaleXLarge:"超大字体",fontScaleLarge:"大号字体",fontScaleNormal:"正常大小",fontScaleSmall:"小号字体",fontScaleXSmall:"超小字体"},"en-US":{blockquote:"Block Quote",bold:"Bold",code:"Code",color:"Text Color",coloredText:"Colored Text",hr:"Horizontal Line",image:"Insert Image",externalImage:"External Image",uploadImage:"Upload Image",uploadFailed:"Upload failed",uploadError:"Error occurs during upload",imageUrl:"Url",imageSize:"Size",imageAlt:"Alt",restoreImageSize:"Restore Origin Size",uploading:"Uploading",indent:"Indent",outdent:"Outdent",italic:"Italic",link:"Insert Link",linkText:"Text",linkUrl:"Url",linkTarget:"Target",openLinkInCurrentWindow:"Open link in current window",openLinkInNewWindow:"Open link in new window",removeLink:"Remove Link",ol:"Ordered List",ul:"Unordered List",strikethrough:"Strikethrough",table:"Table",deleteRow:"Delete Row",insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",deleteColumn:"Delete Column",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteTable:"Delete Table",title:"Title",normalText:"Text",underline:"Underline",alignment:"Alignment",alignCenter:"Align Center",alignLeft:"Align Left",alignRight:"Align Right",selectLanguage:"Select Language",fontScale:"Font Size",fontScaleXLarge:"X Large Size",fontScaleLarge:"Large Size",fontScaleNormal:"Normal Size",fontScaleSmall:"Small Size",fontScaleXSmall:"X Small Size"}},h=function(b){function c(a){this.editor=a.editor,this.title=this._t(this.name),c.__super__.constructor.call(this,a)}return M(c,b),c.prototype._tpl={item:'<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',menuWrapper:'<div class="toolbar-menu"></div>',menuItem:'<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',separator:'<li><span class="separator"></span></li>'},c.prototype.name="",c.prototype.icon="",c.prototype.title="",c.prototype.text="",c.prototype.htmlTag="",c.prototype.disableTag="",c.prototype.menu=!1,c.prototype.active=!1,c.prototype.disabled=!1,c.prototype.needFocus=!0,c.prototype.shortcut=null,c.prototype._init=function(){var b,c,d,e;for(this.render(),this.el.on("mousedown",function(a){return function(b){var c,d,e;return b.preventDefault(),d=a.needFocus&&!a.editor.inputManager.focused,a.el.hasClass("disabled")||d?!1:a.menu?(a.wrapper.toggleClass("menu-on").siblings("li").removeClass("menu-on"),a.wrapper.is(".menu-on")&&(c=a.menuWrapper.offset().left+a.menuWrapper.outerWidth()+5-a.editor.wrapper.offset().left-a.editor.wrapper.outerWidth(),c>0&&a.menuWrapper.css({left:"auto",right:0}),a.trigger("menuexpand")),!1):(e=a.el.data("param"),a.command(e),!1)}}(this)),this.wrapper.on("click","a.menu-item",function(b){return function(c){var d,e,f;return c.preventDefault(),d=a(c.currentTarget),b.wrapper.removeClass("menu-on"),e=b.needFocus&&!b.editor.inputManager.focused,d.hasClass("disabled")||e?!1:(b.editor.toolbar.wrapper.removeClass("menu-on"),f=d.data("param"),b.command(f),!1)}}(this)),this.wrapper.on("mousedown","a.menu-item",function(a){return!1}),this.editor.on("blur",function(a){return function(){var b;return b=a.editor.body.is(":visible")&&a.editor.body.is("[contenteditable]"),b&&!a.editor.clipboard.pasting?(a.setActive(!1),a.setDisabled(!1)):void 0}}(this)),null!=this.shortcut&&this.editor.hotkeys.add(this.shortcut,function(a){return function(b){return a.el.mousedown(),!1}}(this)),d=this.htmlTag.split(","),b=0,c=d.length;c>b;b++)e=d[b],e=a.trim(e),e&&a.inArray(e,this.editor.formatter._allowedTags)<0&&this.editor.formatter._allowedTags.push(e);return this.editor.on("selectionchanged",function(a){return function(b){return a.editor.inputManager.focused?a._status():void 0}}(this))},c.prototype.iconClassOf=function(a){return a?"simditor-icon simditor-icon-"+a:""},c.prototype.setIcon=function(a){return this.el.find("span").removeClass().addClass(this.iconClassOf(a)).text(this.text)},c.prototype.render=function(){return this.wrapper=a(this._tpl.item).appendTo(this.editor.toolbar.list),this.el=this.wrapper.find("a.toolbar-item"),this.el.attr("title",this.title).addClass("toolbar-item-"+this.name).data("button",this),this.setIcon(this.icon),this.menu?(this.menuWrapper=a(this._tpl.menuWrapper).appendTo(this.wrapper),this.menuWrapper.addClass("toolbar-menu-"+this.name),this.renderMenu()):void 0},c.prototype.renderMenu=function(){var b,c,d,e,f,g,h,i;if(a.isArray(this.menu)){for(this.menuEl=a("<ul/>").appendTo(this.menuWrapper),g=this.menu,i=[],d=0,e=g.length;e>d;d++)f=g[d],"|"!==f?(c=a(this._tpl.menuItem).appendTo(this.menuEl),b=c.find("a.menu-item").attr({title:null!=(h=f.title)?h:f.text,"data-param":f.param}).addClass("menu-item-"+f.name),f.icon?i.push(b.find("span").addClass(this.iconClassOf(f.icon))):i.push(b.find("span").text(f.text))):a(this._tpl.separator).appendTo(this.menuEl);return i}},c.prototype.setActive=function(a){return a!==this.active?(this.active=a,this.el.toggleClass("active",this.active)):void 0},c.prototype.setDisabled=function(a){return a!==this.disabled?(this.disabled=a,this.el.toggleClass("disabled",this.disabled)):void 0},c.prototype._disableStatus=function(){var a,b,c;return c=this.editor.selection.startNodes(),b=this.editor.selection.endNodes(),a=c.filter(this.disableTag).length>0||b.filter(this.disableTag).length>0,this.setDisabled(a),this.disabled&&this.setActive(!1),this.disabled},c.prototype._activeStatus=function(){var a,b,c,d,e;return e=this.editor.selection.startNodes(),c=this.editor.selection.endNodes(),d=e.filter(this.htmlTag),b=c.filter(this.htmlTag),a=d.length>0&&b.length>0&&d.is(b),this.node=a?d:null,this.setActive(a),this.active},c.prototype._status=function(){return this._disableStatus(),this.disabled?void 0:this._activeStatus()},c.prototype.command=function(a){},c.prototype._t=function(){var a,b,d;return a=1<=arguments.length?P.call(arguments,0):[],d=c.__super__._t.apply(this,a),d||(d=(b=this.editor)._t.apply(b,a)),d},c}(b),D.Button=h,B=function(b){function c(a){this.button=a.button,this.editor=a.button.editor,c.__super__.constructor.call(this,a)}return M(c,b),c.prototype.offset={top:4,left:0},c.prototype.target=null,c.prototype.active=!1,c.prototype._init=function(){return this.el=a('<div class="simditor-popover"></div>').appendTo(this.editor.el).data("popover",this),this.render(),this.el.on("mouseenter",function(a){return function(b){return a.el.addClass("hover")}}(this)),this.el.on("mouseleave",function(a){return function(b){return a.el.removeClass("hover")}}(this))},c.prototype.render=function(){},c.prototype._initLabelWidth=function(){var b;return b=this.el.find(".settings-field"),b.length>0?(this._labelWidth=0,b.each(function(b){return function(c,d){var e,f;return e=a(d),f=e.find("label"),f.length>0?b._labelWidth=Math.max(b._labelWidth,f.width()):void 0}}(this)),b.find("label").width(this._labelWidth)):void 0},c.prototype.show=function(b,c){return null==c&&(c="bottom"),null!=b?(this.el.siblings(".simditor-popover").each(function(b,c){return c=a(c).data("popover"),c.active?c.hide():void 0}),this.active&&this.target&&this.target.removeClass("selected"),this.target=b.addClass("selected"),this.active?(this.refresh(c),this.trigger("popovershow")):(this.active=!0,this.el.css({left:-9999}).show(),this._labelWidth||this._initLabelWidth(),this.editor.util.reflow(),this.refresh(c),this.trigger("popovershow"))):void 0},c.prototype.hide=function(){return this.active?(this.target&&this.target.removeClass("selected"),this.target=null,this.active=!1,this.el.hide(),this.trigger("popoverhide")):void 0},c.prototype.refresh=function(a){var b,c,d,e,f,g;return null==a&&(a="bottom"),this.active?(b=this.editor.el.offset(),f=this.target.offset(),e=this.target.outerHeight(),"bottom"===a?g=f.top-b.top+e:"top"===a&&(g=f.top-b.top-this.el.height()),d=this.editor.wrapper.width()-this.el.outerWidth()-10,c=Math.min(f.left-b.left,d),this.el.css({top:g+this.offset.top,left:c+this.offset.left})):void 0},c.prototype.destroy=function(){return this.target=null,this.active=!1,this.editor.off(".linkpopover"),this.el.remove()},c.prototype._t=function(){var a,b,d;return a=1<=arguments.length?P.call(arguments,0):[],d=c.__super__._t.apply(this,a),d||(d=(b=this.button)._t.apply(b,a)),d},c}(b),D.Popover=B,G=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="title",c.prototype.htmlTag="h1, h2, h3, h4, h5",c.prototype.disableTag="pre, table",c.prototype._init=function(){return this.menu=[{name:"normal",text:this._t("normalText"),param:"p"},"|",{name:"h1",text:this._t("title")+" 1",param:"h1"},{name:"h2",text:this._t("title")+" 2",param:"h2"},{name:"h3",text:this._t("title")+" 3",param:"h3"},{name:"h4",text:this._t("title")+" 4",param:"h4"},{name:"h5",text:this._t("title")+" 5",param:"h5"}],c.__super__._init.call(this)},c.prototype.setActive=function(a,b){return c.__super__.setActive.call(this,a),a&&(b||(b=this.node[0].tagName.toLowerCase())),this.el.removeClass("active-p active-h1 active-h2 active-h3 active-h4 active-h5"),a?this.el.addClass("active active-"+b):void 0},c.prototype.command=function(b){var c;return c=this.editor.selection.rootNodes(),this.editor.selection.save(),c.each(function(c){return function(d,e){var f;return f=a(e),f.is("blockquote")||f.is(b)||f.is(c.disableTag)||c.editor.util.isDecoratedNode(f)?void 0:a("<"+b+"/>").append(f.contents()).replaceAll(f)}}(this)),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(G),m=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="fontScale",c.prototype.icon="font",c.prototype.disableTag="pre",c.prototype.htmlTag="span",c.prototype.sizeMap={"x-large":"1.5em",large:"1.25em",small:".75em","x-small":".5em"},c.prototype._init=function(){return this.menu=[{name:"150%",text:this._t("fontScaleXLarge"),param:"5"},{name:"125%",text:this._t("fontScaleLarge"),param:"4"},{name:"100%",text:this._t("fontScaleNormal"),param:"3"},{name:"75%",text:this._t("fontScaleSmall"),param:"2"},{name:"50%",text:this._t("fontScaleXSmall"),param:"1"}],c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a,b,c,d,e,f;return d=this.editor.selection.range(),f=this.editor.selection.startNodes(),c=this.editor.selection.endNodes(),e=f.filter('span[style*="font-size"]'),b=c.filter('span[style*="font-size"]'),a=f.length>0&&c.length>0&&e.is(b),this.setActive(a),this.active},c.prototype.command=function(b){var c,d,e;return e=this.editor.selection.range(),e.collapsed?void 0:(document.execCommand("styleWithCSS",!1,!0),document.execCommand("fontSize",!1,b),document.execCommand("styleWithCSS",!1,!1),this.editor.selection.reset(),this.editor.selection.range(),d=this.editor.selection.containerNode(),c=d[0].nodeType===Node.TEXT_NODE?d.closest('span[style*="font-size"]'):d.find('span[style*="font-size"]'),c.each(function(b){return function(c,d){var e,f;return e=a(d),f=d.style.fontSize,/large|x-large|small|x-small/.test(f)?e.css("fontSize",b.sizeMap[f]):"medium"===f?e.replaceWith(e.contents()):void 0}}(this)),this.editor.trigger("valuechanged"))},c}(h),D.Toolbar.addButton(m),g=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="bold",c.prototype.icon="bold",c.prototype.htmlTag="b, strong",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+b",c.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + b )":(this.title=this.title+" ( Ctrl + b )",this.shortcut="ctrl+b"),c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("bold")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("bold"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(g),u=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="italic",c.prototype.icon="italic",c.prototype.htmlTag="i",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+i",c.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + i )":(this.title=this.title+" ( Ctrl + i )",this.shortcut="ctrl+i"),c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("italic")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("italic"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(u),I=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="underline",c.prototype.icon="underline",c.prototype.htmlTag="u",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+u",c.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + u )":(this.title=this.title+" ( Ctrl + u )",this.shortcut="ctrl+u"),c.__super__.render.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("underline")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("underline"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(I),l=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="color",c.prototype.icon="tint",c.prototype.disableTag="pre",c.prototype.menu=!0,c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a)},c.prototype.renderMenu=function(){return a('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper),this.menuWrapper.on("mousedown",".color-list",function(a){return!1}),this.menuWrapper.on("click",".font-color",function(b){return function(c){var d,e,f,g,h,i;if(b.wrapper.removeClass("menu-on"),d=a(c.currentTarget),d.hasClass("font-color-default")){if(e=b.editor.body.find("p, li"),!(e.length>0))return;h=window.getComputedStyle(e[0],null).getPropertyValue("color"),f=b._convertRgbToHex(h)}else h=window.getComputedStyle(d[0],null).getPropertyValue("background-color"),f=b._convertRgbToHex(h);return f?(g=b.editor.selection.range(),!d.hasClass("font-color-default")&&g.collapsed&&(i=document.createTextNode(b._t("coloredText")),g.insertNode(i),g.selectNodeContents(i),b.editor.selection.range(g)),document.execCommand("styleWithCSS",!1,!0),document.execCommand("foreColor",!1,f),document.execCommand("styleWithCSS",!1,!1),b.editor.util.support.oninput?void 0:b.editor.trigger("valuechanged")):void 0}}(this))},c.prototype._convertRgbToHex=function(a){var b,c,d;return c=/rgb\((\d+),\s?(\d+),\s?(\d+)\)/g,(b=c.exec(a))?(d=function(a,b,c){var d;return d=function(a){var b;return b=a.toString(16),1===b.length?"0"+b:b},"#"+d(a)+d(b)+d(c)})(1*b[1],1*b[2],1*b[3]):""},c}(h),D.Toolbar.addButton(l),y=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.type="",c.prototype.disableTag="pre, table",c.prototype.command=function(b){var c,d,e;return d=this.editor.selection.blockNodes(),e="ul"===this.type?"ol":"ul",this.editor.selection.save(),c=null,d.each(function(b){return function(d,f){ |
|
24 |
+var g;return g=a(f),g.is("blockquote, li")||g.is(b.disableTag)||b.editor.util.isDecoratedNode(g)||!a.contains(document,f)?void 0:g.is(b.type)?(g.children("li").each(function(c,d){var e,f;return f=a(d),e=f.children("ul, ol").insertAfter(g),a("<p/>").append(a(d).html()||b.editor.util.phBr).insertBefore(g)}),g.remove()):g.is(e)?a("<"+b.type+"/>").append(g.contents()).replaceAll(g):c&&g.prev().is(c)?(a("<li/>").append(g.html()||b.editor.util.phBr).appendTo(c),g.remove()):(c=a("<"+b.type+"><li></li></"+b.type+">"),c.find("li").append(g.html()||b.editor.util.phBr),c.replaceAll(g))}}(this)),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),z=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.type="ol",b.prototype.name="ol",b.prototype.icon="list-ol",b.prototype.htmlTag="ol",b.prototype.shortcut="cmd+/",b.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + / )":(this.title=this.title+" ( ctrl + / )",this.shortcut="ctrl+/"),b.__super__._init.call(this)},b}(y),K=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.type="ul",b.prototype.name="ul",b.prototype.icon="list-ul",b.prototype.htmlTag="ul",b.prototype.shortcut="cmd+.",b.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + . )":(this.title=this.title+" ( Ctrl + . )",this.shortcut="ctrl+."),b.__super__._init.call(this)},b}(y),D.Toolbar.addButton(z),D.Toolbar.addButton(K),f=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="blockquote",c.prototype.icon="quote-left",c.prototype.htmlTag="blockquote",c.prototype.disableTag="pre, table",c.prototype.command=function(){var b,c,d;return b=this.editor.selection.rootNodes(),b=b.filter(function(b,c){return!a(c).parent().is("blockquote")}),this.editor.selection.save(),d=[],c=function(b){return function(){return d.length>0?(a("<"+b.htmlTag+"/>").insertBefore(d[0]).append(d),d.length=0):void 0}}(this),b.each(function(b){return function(e,f){var g;return g=a(f),g.parent().is(b.editor.body)?g.is(b.htmlTag)?(c(),g.children().unwrap()):g.is(b.disableTag)||b.editor.util.isDecoratedNode(g)?c():d.push(f):void 0}}(this)),c(),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(f),j=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="code",c.prototype.icon="code",c.prototype.htmlTag="pre",c.prototype.disableTag="ul, ol, table",c.prototype._init=function(){return c.__super__._init.call(this),this.editor.on("decorate",function(b){return function(c,d){return d.find("pre").each(function(c,d){return b.decorate(a(d))})}}(this)),this.editor.on("undecorate",function(b){return function(c,d){return d.find("pre").each(function(c,d){return b.undecorate(a(d))})}}(this))},c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new k({button:this})},c.prototype._checkMode=function(){var b,c;return c=this.editor.selection.range(),(b=a(c.cloneContents()).find(this.editor.util.blockNodes.join(",")))>0||c.collapsed&&0===this.editor.selection.startNodes().filter("code").length?(this.inlineMode=!1,this.htmlTag="pre"):(this.inlineMode=!0,this.htmlTag="code")},c.prototype._status=function(){return this._checkMode(),c.__super__._status.call(this),this.inlineMode?void 0:this.active?this.popover.show(this.node):this.popover.hide()},c.prototype.decorate=function(a){var b,c,d,e;return b=a.find("> code"),b.length>0&&(c=null!=(d=b.attr("class"))&&null!=(e=d.match(/lang-(\S+)/))?e[1]:void 0,b.contents().unwrap(),c)?a.attr("data-lang",c):void 0},c.prototype.undecorate=function(b){var c,d;return d=b.attr("data-lang"),c=a("<code/>"),d&&-1!==d&&c.addClass("lang-"+d),b.wrapInner(c).removeAttr("data-lang")},c.prototype.command=function(){return this.inlineMode?this._inlineCommand():this._blockCommand()},c.prototype._blockCommand=function(){var b,c,d,e;return b=this.editor.selection.rootNodes(),d=[],e=[],c=function(b){return function(){var c;if(d.length>0)return c=a("<"+b.htmlTag+"/>").insertBefore(d[0]).text(b.editor.formatter.clearHtml(d)),e.push(c[0]),d.length=0}}(this),b.each(function(b){return function(f,g){var h,i;return h=a(g),h.is(b.htmlTag)?(c(),i=a("<p/>").append(h.html().replace("\n","<br/>")).replaceAll(h),e.push(i[0])):h.is(b.disableTag)||b.editor.util.isDecoratedNode(h)||h.is("blockquote")?c():d.push(g)}}(this)),c(),this.editor.selection.setRangeAtEndOf(a(e).last()),this.editor.trigger("valuechanged")},c.prototype._inlineCommand=function(){var b,c,d;return d=this.editor.selection.range(),this.active?(d.selectNodeContents(this.node[0]),this.editor.selection.save(d),this.node.contents().unwrap(),this.editor.selection.restore()):(c=a(d.extractContents()),b=a("<"+this.htmlTag+"/>").append(c.contents()),d.insertNode(b[0]),d.selectNodeContents(b[0]),this.editor.selection.range(d)),this.editor.trigger("valuechanged")},c}(h),k=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.render=function(){var b,c,d,e,f;for(this._tpl='<div class="code-settings">\n <div class="settings-field">\n <select class="select-lang">\n <option value="-1">'+this._t("selectLanguage")+"</option>\n </select>\n </div>\n</div>",this.langs=this.editor.opts.codeLanguages||[{name:"Bash",value:"bash"},{name:"C++",value:"c++"},{name:"C#",value:"cs"},{name:"CSS",value:"css"},{name:"Erlang",value:"erlang"},{name:"Less",value:"less"},{name:"Sass",value:"sass"},{name:"Diff",value:"diff"},{name:"CoffeeScript",value:"coffeescript"},{name:"HTML,XML",value:"html"},{name:"JSON",value:"json"},{name:"Java",value:"java"},{name:"JavaScript",value:"js"},{name:"Markdown",value:"markdown"},{name:"Objective C",value:"oc"},{name:"PHP",value:"php"},{name:"Perl",value:"parl"},{name:"Python",value:"python"},{name:"Ruby",value:"ruby"},{name:"SQL",value:"sql"}],this.el.addClass("code-popover").append(this._tpl),this.selectEl=this.el.find(".select-lang"),f=this.langs,c=0,e=f.length;e>c;c++)d=f[c],b=a("<option/>",{text:d.name,value:d.value}).appendTo(this.selectEl);return this.selectEl.on("change",function(a){return function(b){var c;return a.lang=a.selectEl.val(),c=a.target.hasClass("selected"),a.target.removeClass().removeAttr("data-lang"),-1!==a.lang&&a.target.attr("data-lang",a.lang),c&&a.target.addClass("selected"),a.editor.trigger("valuechanged")}}(this)),this.editor.on("valuechanged",function(a){return function(b){return a.active?a.refresh():void 0}}(this))},c.prototype.show=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,a),this.lang=this.target.attr("data-lang"),null!=this.lang?this.selectEl.val(this.lang):this.selectEl.val(-1)},c}(B),D.Toolbar.addButton(j),w=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="link",c.prototype.icon="link",c.prototype.htmlTag="a",c.prototype.disableTag="pre",c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new x({button:this})},c.prototype._status=function(){return c.__super__._status.call(this),this.active&&!this.editor.selection.rangeAtEndOf(this.node)?this.popover.show(this.node):this.popover.hide()},c.prototype.command=function(){var b,c,d,e,f,g;return f=this.editor.selection.range(),this.active?(g=document.createTextNode(this.node.text()),this.node.replaceWith(g),f.selectNode(g)):(b=a(f.extractContents()),e=this.editor.formatter.clearHtml(b.contents(),!1),c=a("<a/>",{href:"http://www.example.com",target:"_blank",text:e||this._t("linkText")}),this.editor.selection.blockNodes().length>0?f.insertNode(c[0]):(d=a("<p/>").append(c),f.insertNode(d[0])),f.selectNodeContents(c[0]),this.popover.one("popovershow",function(a){return function(){return e?(a.popover.urlEl.focus(),a.popover.urlEl[0].select()):(a.popover.textEl.focus(),a.popover.textEl[0].select())}}(this))),this.editor.selection.range(f),this.editor.trigger("valuechanged")},c}(h),x=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.render=function(){var b;return b='<div class="link-settings">\n <div class="settings-field">\n <label>'+this._t("linkText")+'</label>\n <input class="link-text" type="text"/>\n <a class="btn-unlink" href="javascript:;" title="'+this._t("removeLink")+'"\n tabindex="-1">\n <span class="simditor-icon simditor-icon-unlink"></span>\n </a>\n </div>\n <div class="settings-field">\n <label>'+this._t("linkUrl")+'</label>\n <input class="link-url" type="text"/>\n </div>\n <div class="settings-field">\n <label>'+this._t("linkTarget")+'</label>\n <select class="link-target">\n <option value="_blank">'+this._t("openLinkInNewWindow")+' (_blank)</option>\n <option value="_self">'+this._t("openLinkInCurrentWindow")+" (_self)</option>\n </select>\n </div>\n</div>",this.el.addClass("link-popover").append(b),this.textEl=this.el.find(".link-text"),this.urlEl=this.el.find(".link-url"),this.unlinkEl=this.el.find(".btn-unlink"),this.selectTarget=this.el.find(".link-target"),this.textEl.on("keyup",function(a){return function(b){return 13!==b.which?(a.target.text(a.textEl.val()),a.editor.inputManager.throttledValueChanged()):void 0}}(this)),this.urlEl.on("keyup",function(a){return function(b){var c;if(13!==b.which)return c=a.urlEl.val(),!/https?:\/\/|^\//gi.test(c)&&c&&(c="http://"+c),a.target.attr("href",c),a.editor.inputManager.throttledValueChanged()}}(this)),a([this.urlEl[0],this.textEl[0]]).on("keydown",function(b){return function(c){var d;return 13===c.which||27===c.which||!c.shiftKey&&9===c.which&&a(c.target).hasClass("link-url")?(c.preventDefault(),d=document.createRange(),b.editor.selection.setRangeAfter(b.target,d),b.hide(),b.editor.inputManager.throttledValueChanged()):void 0}}(this)),this.unlinkEl.on("click",function(a){return function(b){var c,d;return d=document.createTextNode(a.target.text()),a.target.replaceWith(d),a.hide(),c=document.createRange(),a.editor.selection.setRangeAfter(d,c),a.editor.inputManager.throttledValueChanged()}}(this)),this.selectTarget.on("change",function(a){return function(b){return a.target.attr("target",a.selectTarget.val()),a.editor.inputManager.throttledValueChanged()}}(this))},c.prototype.show=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,a),this.textEl.val(this.target.text()),this.urlEl.val(this.target.attr("href"))},c}(B),D.Toolbar.addButton(w),p=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="image",c.prototype.icon="picture-o",c.prototype.htmlTag="img",c.prototype.disableTag="pre, table",c.prototype.defaultImage="",c.prototype.needFocus=!1,c.prototype._init=function(){var b,d,e,f;if(this.editor.opts.imageButton)if(Array.isArray(this.editor.opts.imageButton))for(this.menu=[],f=this.editor.opts.imageButton,d=0,e=f.length;e>d;d++)b=f[d],this.menu.push({name:b+"-image",text:this._t(b+"Image")});else this.menu=!1;else null!=this.editor.uploader?this.menu=[{name:"upload-image",text:this._t("uploadImage")},{name:"external-image",text:this._t("externalImage")}]:this.menu=!1;return this.defaultImage=this.editor.opts.defaultImage,this.editor.body.on("click","img:not([data-non-image])",function(b){return function(c){var d,e;return d=a(c.currentTarget),e=document.createRange(),e.selectNode(d[0]),b.editor.selection.range(e),b.editor.util.support.onselectionchange||b.editor.trigger("selectionchanged"),!1}}(this)),this.editor.body.on("mouseup","img:not([data-non-image])",function(a){return!1}),this.editor.on("selectionchanged.image",function(b){return function(){var c,d,e;return e=b.editor.selection.range(),null!=e?(c=a(e.cloneContents()).contents(),1===c.length&&c.is("img:not([data-non-image])")?(d=a(e.startContainer).contents().eq(e.startOffset),b.popover.show(d)):b.popover.hide()):void 0}}(this)),this.editor.on("valuechanged.image",function(b){return function(){var c;return c=b.editor.wrapper.find(".simditor-image-loading"),c.length>0?c.each(function(c,d){var e,f,g;return f=a(d),e=f.data("img"),!(e&&e.parent().length>0)&&(f.remove(),e&&(g=e.data("file"),g&&(b.editor.uploader.cancel(g),b.editor.body.find("img.uploading").length<1)))?b.editor.uploader.trigger("uploadready",[g]):void 0}):void 0}}(this)),c.__super__._init.call(this)},c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new q({button:this}),"upload"===this.editor.opts.imageButton?this._initUploader(this.el):void 0},c.prototype.renderMenu=function(){return c.__super__.renderMenu.call(this),this._initUploader()},c.prototype._initUploader=function(b){var c,d,e;return null==b&&(b=this.menuEl.find(".menu-item-upload-image")),null==this.editor.uploader?void this.el.find(".btn-upload").remove():(c=null,d=function(d){return function(){return c&&c.remove(),c=a("<input/>",{type:"file",title:d._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),d(),b.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),b.on("change","input[type=file]",function(a){return function(b){return a.editor.inputManager.focused?(a.editor.uploader.upload(c,{inline:!0}),d()):(a.editor.one("focus",function(b){return a.editor.uploader.upload(c,{inline:!0}),d()}),a.editor.focus()),a.wrapper.removeClass("menu-on")}}(this)),this.editor.uploader.on("beforeupload",function(b){return function(c,d){var e;if(d.inline)return d.img?e=a(d.img):(e=b.createImage(d.name),d.img=e),e.addClass("uploading"),e.data("file",d),b.editor.uploader.readImageFile(d.obj,function(a){var c;if(e.hasClass("uploading"))return c=a?a.src:b.defaultImage,b.loadImage(e,c,function(){return b.popover.active?(b.popover.refresh(),b.popover.srcEl.val(b._t("uploading")).prop("disabled",!0)):void 0})})}}(this)),e=a.proxy(this.editor.util.throttle(function(a,b,c,d){var e,f,g;if(b.inline&&(f=b.img.data("mask")))return e=f.data("img"),e.hasClass("uploading")&&e.parent().length>0?(g=c/d,g=(100*g).toFixed(0),g>99&&(g=99),f.find(".progress").height(100-g+"%")):void f.remove()},500),this),this.editor.uploader.on("uploadprogress",e),this.editor.uploader.on("uploadsuccess",function(b){return function(c,d,e){var f,g,h;if(d.inline&&(f=d.img,f.hasClass("uploading")&&f.parent().length>0)){if("object"!=typeof e)try{e=a.parseJSON(e)}catch(i){c=i,e={success:!1}}return e.success===!1?(h=e.msg||b._t("uploadFailed"),alert(h),g=b.defaultImage):g=e.file_path,b.loadImage(f,g,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask"),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,e]):void 0}),b.popover.active?(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(e.file_path)):void 0}}}(this)),this.editor.uploader.on("uploaderror",function(b){return function(c,d,e){var f,g,h;if(d.inline&&"abort"!==e.statusText){if(e.responseText){try{h=a.parseJSON(e.responseText),g=h.msg}catch(i){c=i,g=b._t("uploadError")}alert(g)}if(f=d.img,f.hasClass("uploading")&&f.parent().length>0)return b.loadImage(f,b.defaultImage,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask")}),b.popover.active&&(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(b.defaultImage)),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,h]):void 0}}}(this)))},c.prototype._status=function(){return this._disableStatus()},c.prototype.loadImage=function(b,c,d){var e,f,g;return g=function(a){return function(){var c,d;return c=b.offset(),d=a.editor.wrapper.offset(),e.css({top:c.top-d.top,left:c.left-d.left,width:b.width(),height:b.height()}).show()}}(this),b.addClass("loading"),e=b.data("mask"),e||(e=a('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper),g(),b.data("mask",e),e.data("img",b)),f=new Image,f.onload=function(h){return function(){var i,j;if(b.hasClass("loading")||b.hasClass("uploading"))return j=f.width,i=f.height,b.attr({src:c,width:j,height:i,"data-image-size":j+","+i}).removeClass("loading"),b.hasClass("uploading")?(h.editor.util.reflow(h.editor.body),g()):(e.remove(),b.removeData("mask")),a.isFunction(d)?d(f):void 0}}(this),f.onerror=function(){return a.isFunction(d)&&d(!1),e.remove(),b.removeData("mask").removeClass("loading")},f.src=c},c.prototype.createImage=function(b){var c,d;return null==b&&(b="Image"),this.editor.inputManager.focused||this.editor.focus(),d=this.editor.selection.range(),d.deleteContents(),this.editor.selection.range(d),c=a("<img/>").attr("alt",b),d.insertNode(c[0]),this.editor.selection.setRangeAfter(c,d),this.editor.trigger("valuechanged"),c},c.prototype.command=function(a){var b;return b=this.createImage(),this.loadImage(b,a||this.defaultImage,function(a){return function(){return a.editor.trigger("valuechanged"),a.editor.util.reflow(b),b.click(),a.popover.one("popovershow",function(){return a.popover.srcEl.focus(),a.popover.srcEl[0].select()})}}(this))},c}(h),q=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.offset={top:6,left:-4},c.prototype.render=function(){var b;return b='<div class="link-settings">\n <div class="settings-field">\n <label>'+this._t("imageUrl")+'</label>\n <input class="image-src" type="text" tabindex="1" />\n <a class="btn-upload" href="javascript:;"\n title="'+this._t("uploadImage")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-upload"></span>\n </a>\n </div>\n <div class=\'settings-field\'>\n <label>'+this._t("imageAlt")+'</label>\n <input class="image-alt" id="image-alt" type="text" tabindex="1" />\n </div>\n <div class="settings-field">\n <label>'+this._t("imageSize")+'</label>\n <input class="image-size" id="image-width" type="text" tabindex="2" />\n <span class="times">×</span>\n <input class="image-size" id="image-height" type="text" tabindex="3" />\n <a class="btn-restore" href="javascript:;"\n title="'+this._t("restoreImageSize")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-undo"></span>\n </a>\n </div>\n</div>',this.el.addClass("image-popover").append(b),this.srcEl=this.el.find(".image-src"),this.widthEl=this.el.find("#image-width"),this.heightEl=this.el.find("#image-height"),this.altEl=this.el.find("#image-alt"),this.srcEl.on("keydown",function(a){return function(b){var c;if(13===b.which&&!a.target.hasClass("uploading"))return b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()}}(this)),this.srcEl.on("blur",function(a){return function(b){return a._loadImage(a.srcEl.val())}}(this)),this.el.find(".image-size").on("blur",function(b){return function(c){return b._resizeImg(a(c.currentTarget)),b.el.data("popover").refresh()}}(this)),this.el.find(".image-size").on("keyup",function(b){return function(c){var d;return d=a(c.currentTarget),13!==c.which&&27!==c.which&&9!==c.which?b._resizeImg(d,!0):void 0}}(this)),this.el.find(".image-size").on("keydown",function(b){return function(c){var d,e,f;return e=a(c.currentTarget),13===c.which||27===c.which?(c.preventDefault(),13===c.which?b._resizeImg(e):b._restoreImg(),d=b.target,b.hide(),f=document.createRange(),b.button.editor.selection.setRangeAfter(d,f)):9===c.which?b.el.data("popover").refresh():void 0}}(this)),this.altEl.on("keydown",function(a){return function(b){var c;return 13===b.which?(b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()):void 0}}(this)),this.altEl.on("keyup",function(a){return function(b){return 13!==b.which&&27!==b.which&&9!==b.which?(a.alt=a.altEl.val(),a.target.attr("alt",a.alt)):void 0}}(this)),this.el.find(".btn-restore").on("click",function(a){return function(b){return a._restoreImg(),a.el.data("popover").refresh()}}(this)),this.editor.on("valuechanged",function(a){return function(b){return a.active?a.refresh():void 0}}(this)),this._initUploader()},c.prototype._initUploader=function(){var b,c;return b=this.el.find(".btn-upload"),null==this.editor.uploader?void b.remove():(c=function(c){return function(){return c.input&&c.input.remove(),c.input=a("<input/>",{type:"file",title:c._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),c(),this.el.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),this.el.on("change","input[type=file]",function(a){return function(b){return a.editor.uploader.upload(a.input,{inline:!0,img:a.target}),c()}}(this)))},c.prototype._resizeImg=function(b,c){var d,e,f;return null==c&&(c=!1),e=1*b.val(),this.target&&(a.isNumeric(e)||0>e)?(b.is(this.widthEl)?(f=e,d=this.height*e/this.width,this.heightEl.val(d)):(d=e,f=this.width*e/this.height,this.widthEl.val(f)),c?void 0:(this.target.attr({width:f,height:d}),this.editor.trigger("valuechanged"))):void 0},c.prototype._restoreImg=function(){var a,b;return b=(null!=(a=this.target.data("image-size"))?a.split(","):void 0)||[this.width,this.height],this.target.attr({width:1*b[0],height:1*b[1]}),this.widthEl.val(b[0]),this.heightEl.val(b[1]),this.editor.trigger("valuechanged")},c.prototype._loadImage=function(a,b){if(/^data:image/.test(a)&&!this.editor.uploader)return void(b&&b(!1));if(this.target.attr("src")!==a)return this.button.loadImage(this.target,a,function(c){return function(d){var e;if(d)return c.active&&(c.width=d.width,c.height=d.height,c.widthEl.val(c.width),c.heightEl.val(c.height)),/^data:image/.test(a)?(e=c.editor.util.dataURLtoBlob(a),e.name="Base64 Image.png",c.editor.uploader.upload(e,{inline:!0,img:c.target})):c.editor.trigger("valuechanged"),b?b(d):void 0}}(this))},c.prototype.show=function(){var a,b;return b=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,b),a=this.target,this.width=a.width(),this.height=a.height(),this.alt=a.attr("alt"),a.hasClass("uploading")?this.srcEl.val(this._t("uploading")).prop("disabled",!0):(this.srcEl.val(a.attr("src")).prop("disabled",!1),this.widthEl.val(this.width),this.heightEl.val(this.height),this.altEl.val(this.alt))},c}(B),D.Toolbar.addButton(p),r=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="indent",b.prototype.icon="indent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent()},b}(h),D.Toolbar.addButton(r),A=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="outdent",b.prototype.icon="outdent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Shift + Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent(!0)},b}(h),D.Toolbar.addButton(A),o=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="hr",c.prototype.icon="minus",c.prototype.htmlTag="hr",c.prototype._status=function(){},c.prototype.command=function(){var b,c,d,e;return e=this.editor.selection.rootNodes().first(),d=e.next(),d.length>0?this.editor.selection.save():c=a("<p/>").append(this.editor.util.phBr),b=a("<hr/>").insertAfter(e),c?(c.insertAfter(b),this.editor.selection.setRangeAtStartOf(c)):this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(o),F=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="table",c.prototype.icon="table",c.prototype.htmlTag="table",c.prototype.disableTag="pre, li, blockquote",c.prototype.menu=!0,c.prototype._init=function(){return c.__super__._init.call(this),a.merge(this.editor.formatter._allowedTags,["thead","th","tbody","tr","td","colgroup","col"]),a.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]}),a.extend(this.editor.formatter._allowedStyles,{td:["text-align"],th:["text-align"]}),this._initShortcuts(),this.editor.on("decorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.decorate(a(d))})}}(this)),this.editor.on("undecorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.undecorate(a(d))})}}(this)),this.editor.on("selectionchanged.table",function(a){return function(b){var c,d;return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active"),(d=a.editor.selection.range())?(c=a.editor.selection.containerNode(),d.collapsed&&c.is(".simditor-table")&&(c=a.editor.selection.rangeAtStartOf(c)?c.find("th:first"):c.find("td:last"),a.editor.selection.setRangeAtEndOf(c)),c.closest("td, th",a.editor.body).addClass("active")):void 0}}(this)),this.editor.on("blur.table",function(a){return function(b){return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active")}}(this)),this.editor.keystroke.add("up","td",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("up","th",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("down","td",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this)),this.editor.keystroke.add("down","th",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this))},c.prototype._tdNav=function(a,b){var c,d,e,f,g,h,i;return null==b&&(b="up"),e="up"===b?"prev":"next",i="up"===b?["tbody","thead"]:["thead","tbody"],h=i[0],f=i[1],d=a.parent("tr"),c=this["_"+e+"Row"](d),c.length>0?(g=d.find("td, th").index(a),this.editor.selection.setRangeAtEndOf(c.find("td, th").eq(g))):!0},c.prototype._nextRow=function(a){var b;return b=a.next("tr"),b.length<1&&a.parent("thead").length>0&&(b=a.parent("thead").next("tbody").find("tr:first")),b},c.prototype._prevRow=function(a){var b;return b=a.prev("tr"),b.length<1&&a.parent("tbody").length>0&&(b=a.parent("tbody").prev("thead").find("tr")),b},c.prototype.initResize=function(b){var c,d,e;return e=b.parent(".simditor-table"),c=b.find("colgroup"),c.length<1&&(c=a("<colgroup/>").prependTo(b),b.find("thead tr th").each(function(b,d){var e;return e=a("<col/>").appendTo(c)}),this.refreshTableWidth(b)),d=a("<div />",{"class":"simditor-resize-handle",contenteditable:"false"}).appendTo(e),e.on("mousemove","td, th",function(b){var f,g,h,i,j,k;if(!e.hasClass("resizing"))return g=a(b.currentTarget),k=b.pageX-a(b.currentTarget).offset().left,5>k&&g.prev().length>0&&(g=g.prev()),g.next("td, th").length<1?void d.hide():(null!=(i=d.data("td"))?i.is(g):void 0)?void d.show():(h=g.parent().find("td, th").index(g),f=c.find("col").eq(h),(null!=(j=d.data("col"))?j.is(f):void 0)?void d.show():d.css("left",g.position().left+g.outerWidth()-5).data("td",g).data("col",f).show())}),e.on("mouseleave",function(a){return d.hide()}),e.on("mousedown",".simditor-resize-handle",function(b){var c,d,f,g,h,i,j,k,l,m,n;return c=a(b.currentTarget),f=c.data("td"),d=c.data("col"),h=f.next("td, th"),g=d.next("col"),m=b.pageX,k=1*f.outerWidth(),l=1*h.outerWidth(),j=parseFloat(c.css("left")),n=f.closest("table").width(),i=50,a(document).on("mousemove.simditor-resize-table",function(a){var b,e,f;return b=a.pageX-m,e=k+b,f=l-b,i>e?(e=i,b=i-k,f=l-b):i>f&&(f=i,b=l-i,e=k+b),d.attr("width",e/n*100+"%"),g.attr("width",f/n*100+"%"),c.css("left",j+b)}),a(document).one("mouseup.simditor-resize-table",function(b){return a(document).off(".simditor-resize-table"),e.removeClass("resizing")}),e.addClass("resizing"),!1})},c.prototype._initShortcuts=function(){return this.editor.hotkeys.add("ctrl+alt+up",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowAbove]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+down",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowBelow]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+left",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColLeft]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+right",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColRight]").click(),!1}}(this))},c.prototype.decorate=function(b){var c,d,e;return b.parent(".simditor-table").length>0&&this.undecorate(b),b.wrap('<div class="simditor-table"></div>'),b.find("thead").length<1&&(e=a("<thead />"),c=b.find("tr").first(),e.append(c),this._changeCellTag(c,"th"),d=b.find("tbody"),d.length>0?d.before(e):b.prepend(e)),this.initResize(b),b.parent()},c.prototype.undecorate=function(a){return a.parent(".simditor-table").length>0?a.parent().replaceWith(a):void 0},c.prototype.renderMenu=function(){var b;return a('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n <ul>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteRow">\n <span>'+this._t("deleteRow")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowAbove">\n <span>'+this._t("insertRowAbove")+' ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowBelow">\n <span>'+this._t("insertRowBelow")+' ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteCol">\n <span>'+this._t("deleteColumn")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColLeft">\n <span>'+this._t("insertColumnLeft")+' ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColRight">\n <span>'+this._t("insertColumnRight")+' ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteTable">\n <span>'+this._t("deleteTable")+"</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper),this.createMenu=this.menuWrapper.find(".menu-create-table"),this.editMenu=this.menuWrapper.find(".menu-edit-table"),b=this.createTable(6,6).appendTo(this.createMenu),this.createMenu.on("mouseenter","td, th",function(c){return function(d){var e,f,g,h;return c.createMenu.find("td, th").removeClass("selected"),e=a(d.currentTarget),f=e.parent(),h=f.find("td, th").index(e)+1,g=f.prevAll("tr").addBack(),f.parent().is("tbody")&&(g=g.add(b.find("thead tr"))),g.find("td:lt("+h+"), th:lt("+h+")").addClass("selected")}}(this)),this.createMenu.on("mouseleave",function(b){return a(b.currentTarget).find("td, th").removeClass("selected")}),this.createMenu.on("mousedown","td, th",function(c){return function(d){var e,f,g,h,i;return c.wrapper.removeClass("menu-on"),c.editor.inputManager.focused?(f=a(d.currentTarget),g=f.parent(),h=g.find("td").index(f)+1,i=g.prevAll("tr").length+1,g.parent().is("tbody")&&(i+=1),b=c.createTable(i,h,!0),e=c.editor.selection.blockNodes().last(),c.editor.util.isEmptyNode(e)?e.replaceWith(b):e.after(b),c.decorate(b),c.editor.selection.setRangeAtStartOf(b.find("th:first")), |
|
25 |
+c.editor.trigger("valuechanged"),!1):void 0}}(this))},c.prototype.createTable=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(e=a("<table/>"),h=a("<thead/>").appendTo(e),f=a("<tbody/>").appendTo(e),m=k=0,n=b;n>=0?n>k:k>n;m=n>=0?++k:--k)for(i=a("<tr/>"),i.appendTo(0===m?h:f),j=l=0,o=c;o>=0?o>l:l>o;j=o>=0?++l:--l)g=a(0===m?"<th/>":"<td/>").appendTo(i),d&&g.append(this.editor.util.phBr);return e},c.prototype.refreshTableWidth=function(b){var c,d;return d=b.width(),c=b.find("col"),b.find("thead tr th").each(function(b,e){var f;return f=c.eq(b),f.attr("width",a(e).outerWidth()/d*100+"%")})},c.prototype.setActive=function(a){return c.__super__.setActive.call(this,a),a?(this.createMenu.hide(),this.editMenu.show()):(this.createMenu.show(),this.editMenu.hide())},c.prototype._changeCellTag=function(b,c){return b.find("td, th").each(function(b,d){var e;return e=a(d),e.replaceWith("<"+c+">"+e.html()+"</"+c+">")})},c.prototype.deleteRow=function(a){var b,c,d;return c=a.parent("tr"),c.closest("table").find("tr").length<1?this.deleteTable(a):(b=this._nextRow(c),b.length>0||(b=this._prevRow(c)),d=c.find("td, th").index(a),c.parent().is("thead")&&(b.appendTo(c.parent()),this._changeCellTag(b,"th")),c.remove(),this.editor.selection.setRangeAtEndOf(b.find("td, th").eq(d)))},c.prototype.insertRow=function(b,c){var d,e,f,g,h,i,j,k,l;for(null==c&&(c="after"),f=b.parent("tr"),e=f.closest("table"),h=0,e.find("tr").each(function(b,c){return h=Math.max(h,a(c).find("td").length)}),j=f.find("td, th").index(b),d=a("<tr/>"),g="td","after"===c&&f.parent().is("thead")?f.parent().next("tbody").prepend(d):"before"===c&&f.parent().is("thead")?(f.before(d),f.parent().next("tbody").prepend(f),this._changeCellTag(f,"td"),g="th"):f[c](d),i=k=1,l=h;l>=1?l>=k:k>=l;i=l>=1?++k:--k)a("<"+g+"/>").append(this.editor.util.phBr).appendTo(d);return this.editor.selection.setRangeAtStartOf(d.find("td, th").eq(j))},c.prototype.deleteCol=function(b){var c,d,e,f,g,h;return e=b.parent("tr"),h=e.closest("table").find("tr").length<2,g=b.siblings("td, th").length<1,h&&g?this.deleteTable(b):(f=e.find("td, th").index(b),c=b.next("td, th"),c.length>0||(c=e.prev("td, th")),d=e.closest("table"),d.find("col").eq(f).remove(),d.find("tr").each(function(b,c){return a(c).find("td, th").eq(f).remove()}),this.refreshTableWidth(d),this.editor.selection.setRangeAtEndOf(c))},c.prototype.insertCol=function(b,c){var d,e,f,g,h,i,j,k;return null==c&&(c="after"),h=b.parent("tr"),i=h.find("td, th").index(b),g=b.closest("table"),d=g.find("col").eq(i),g.find("tr").each(function(b){return function(d,e){var f,g;return g=a(e).parent().is("thead")?"th":"td",f=a("<"+g+"/>").append(b.editor.util.phBr),a(e).find("td, th").eq(i)[c](f)}}(this)),e=a("<col/>"),d[c](e),j=g.width(),k=Math.max(parseFloat(d.attr("width"))/2,50/j*100),d.attr("width",k+"%"),e.attr("width",k+"%"),this.refreshTableWidth(g),f="after"===c?b.next("td, th"):b.prev("td, th"),this.editor.selection.setRangeAtStartOf(f)},c.prototype.deleteTable=function(a){var b,c;return c=a.closest(".simditor-table"),b=c.next("p"),c.remove(),b.length>0?this.editor.selection.setRangeAtStartOf(b):void 0},c.prototype.command=function(a){var b;if(b=this.editor.selection.containerNode().closest("td, th"),b.length>0){if("deleteRow"===a)this.deleteRow(b);else if("insertRowAbove"===a)this.insertRow(b,"before");else if("insertRowBelow"===a)this.insertRow(b);else if("deleteCol"===a)this.deleteCol(b);else if("insertColLeft"===a)this.insertCol(b,"before");else if("insertColRight"===a)this.insertCol(b);else{if("deleteTable"!==a)return;this.deleteTable(b)}return this.editor.trigger("valuechanged")}},c}(h),D.Toolbar.addButton(F),E=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="strikethrough",c.prototype.icon="strikethrough",c.prototype.htmlTag="strike",c.prototype.disableTag="pre",c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("strikethrough")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("strikethrough"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(E),e=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="alignment",b.prototype.icon="align-left",b.prototype.htmlTag="p, h1, h2, h3, h4, td, th",b.prototype._init=function(){return this.menu=[{name:"left",text:this._t("alignLeft"),icon:"align-left",param:"left"},{name:"center",text:this._t("alignCenter"),icon:"align-center",param:"center"},{name:"right",text:this._t("alignRight"),icon:"align-right",param:"right"}],b.__super__._init.call(this)},b.prototype.setActive=function(a,c){return null==c&&(c="left"),"left"!==c&&"center"!==c&&"right"!==c&&(c="left"),"left"===c?b.__super__.setActive.call(this,!1):b.__super__.setActive.call(this,a),this.el.removeClass("align-left align-center align-right"),a&&this.el.addClass("align-"+c),this.setIcon("align-"+c),this.menuEl.find(".menu-item").show().end().find(".menu-item-"+c).hide()},b.prototype._status=function(){return this.nodes=this.editor.selection.nodes().filter(this.htmlTag),this.nodes.length<1?(this.setDisabled(!0),this.setActive(!1)):(this.setDisabled(!1),this.setActive(!0,this.nodes.first().css("text-align")))},b.prototype.command=function(a){if("left"!==a&&"center"!==a&&"right"!==a)throw new Error("simditor alignment button: invalid align "+a);return this.nodes.css({"text-align":"left"===a?"":a}),this.editor.trigger("valuechanged"),this.editor.inputManager.throttledSelectionChanged()},b}(h),D.Toolbar.addButton(e),D});(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-checklist",["jquery","simditor"],function(a0,b1){return(root["ChecklistButton"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["ChecklistButton"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var ChecklistButton,extend=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},hasProp={}.hasOwnProperty,slice=[].slice;ChecklistButton=(function(superClass){extend(ChecklistButton,superClass);ChecklistButton.prototype.type="ul.simditor-checklist";ChecklistButton.prototype.name="checklist";ChecklistButton.prototype.icon="checklist";ChecklistButton.prototype.htmlTag="li";ChecklistButton.prototype.disableTag="pre, table";function ChecklistButton(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ChecklistButton.__super__.constructor.apply(this,args);if("input"&&$.inArray("input",this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push("input")}$.extend(this.editor.formatter._allowedAttributes,{input:["type","checked"]})}ChecklistButton.prototype._init=function(){ChecklistButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("ul > li input[type=checkbox]").each(function(i,checkbox){return _this._decorate($(checkbox))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find(".simditor-checklist > li").each(function(i,node){return _this._undecorate($(node))})}})(this));this.editor.body.on("click",".simditor-checklist > li",(function(_this){return function(e){var $node,range;e.preventDefault();e.stopPropagation();$node=$(e.currentTarget);range=document.createRange();_this.editor.selection.save();range.setStart($node[0],0);range.setEnd($node[0],_this.editor.util.getNodeLength($node[0]));_this.editor.selection.range(range);document.execCommand("strikethrough");$node.attr("checked",!$node.attr("checked"));_this.editor.selection.restore();return _this.editor.trigger("valuechanged")}})(this));return this.editor.keystroke.add("13","li",(function(_this){return function(e,$node){return setTimeout(function(){var $li;$li=_this.editor.selection.blockNodes().last().next();if($li.length){$li[0].removeAttribute("checked");if(document.queryCommandState("strikethrough")){return document.execCommand("strikethrough")}}},0)}})(this))};ChecklistButton.prototype._status=function(){var $node;ChecklistButton.__super__._status.call(this);$node=this.editor.selection.rootNodes();if($node.is(".simditor-checklist")){this.editor.toolbar.findButton("ul").setActive(false);this.editor.toolbar.findButton("ol").setActive(false);this.editor.toolbar.findButton("ul").setDisabled(true);return this.editor.toolbar.findButton("ol").setDisabled(true)}else{return this.editor.toolbar.findButton("checklist").setActive(false)}};ChecklistButton.prototype.command=function(param){var $list,$rootNodes;$rootNodes=this.editor.selection.blockNodes();this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||!$.contains(document,node)){return}if($node.is(".simditor-checklist")){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is("ul, ol")){return $('<ul class="simditor-checklist" />').append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$('<ul class="simditor-checklist"><li></li></ul>');$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};ChecklistButton.prototype._decorate=function($checkbox){var $node,checked;checked=!!$checkbox.attr("checked");$node=$checkbox.closest("li");$checkbox.remove();$node.attr("checked",checked);return $node.closest("ul").addClass("simditor-checklist")};ChecklistButton.prototype._undecorate=function($node){var $checkbox,checked;checked=!!$node.attr("checked");$checkbox=$('<input type="checkbox">').attr("checked",checked);return $node.attr("checked","").prepend($checkbox)};return ChecklistButton})(Simditor.Button);Simditor.Toolbar.addButton(ChecklistButton);return ChecklistButton})); |
@@ -0,0 +1,32 @@ |
||
1 |
+/*! |
|
2 |
+* Simditor v2.3.6 |
|
3 |
+* http://simditor.tower.im/ |
|
4 |
+* 2015-12-21 |
|
5 |
+*/ |
|
6 |
+(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor",["jquery","simple-module","simple-hotkeys","simple-uploader"],function($,SimpleModule,simpleHotkeys,simpleUploader){return(root["Simditor"]=factory($,SimpleModule,simpleHotkeys,simpleUploader))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader"))}else{root["Simditor"]=factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader)}}}(this,function($,SimpleModule,simpleHotkeys,simpleUploader){var AlignmentButton,BlockquoteButton,BoldButton,Button,Clipboard,CodeButton,CodePopover,ColorButton,FontScaleButton,Formatter,HrButton,ImageButton,ImagePopover,IndentButton,Indentation,InputManager,ItalicButton,Keystroke,LinkButton,LinkPopover,ListButton,OrderListButton,OutdentButton,Popover,Selection,Simditor,StrikethroughButton,TableButton,TitleButton,Toolbar,UnderlineButton,UndoManager,UnorderListButton,Util,extend=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},hasProp={}.hasOwnProperty,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;i<l;i++){if(i in this&&this[i]===item){return i}}return -1},slice=[].slice;Selection=(function(superClass){extend(Selection,superClass);function Selection(){return Selection.__super__.constructor.apply(this,arguments)}Selection.pluginName="Selection";Selection.prototype._range=null;Selection.prototype._startNodes=null;Selection.prototype._endNodes=null;Selection.prototype._containerNode=null;Selection.prototype._nodes=null;Selection.prototype._blockNodes=null;Selection.prototype._rootNodes=null;Selection.prototype._init=function(){this.editor=this._module;this._selection=document.getSelection();this.editor.on("selectionchanged",(function(_this){return function(e){_this.reset();return _this._range=_this._selection.getRangeAt(0)}})(this));return this.editor.on("blur",(function(_this){return function(e){return _this.reset()}})(this))};Selection.prototype.reset=function(){this._range=null;this._startNodes=null;this._endNodes=null;this._containerNode=null;this._nodes=null;this._blockNodes=null;return this._rootNodes=null};Selection.prototype.clear=function(){var e;try{this._selection.removeAllRanges()}catch(_error){e=_error}return this.reset()};Selection.prototype.range=function(range){var ffOrIE;if(range){this.clear();this._selection.addRange(range);this._range=range;ffOrIE=this.editor.util.browser.firefox||this.editor.util.browser.msie;if(!this.editor.inputManager.focused&&ffOrIE){this.editor.body.focus()}}else{if(!this._range&&this.editor.inputManager.focused&&this._selection.rangeCount){this._range=this._selection.getRangeAt(0)}}return this._range};Selection.prototype.startNodes=function(){if(this._range){this._startNodes||(this._startNodes=(function(_this){return function(){var startNodes;startNodes=$(_this._range.startContainer).parentsUntil(_this.editor.body).get();startNodes.unshift(_this._range.startContainer);return $(startNodes)}})(this)())}return this._startNodes};Selection.prototype.endNodes=function(){var endNodes;if(this._range){this._endNodes||(this._endNodes=this._range.collapsed?this.startNodes():(endNodes=$(this._range.endContainer).parentsUntil(this.editor.body).get(),endNodes.unshift(this._range.endContainer),$(endNodes)))}return this._endNodes};Selection.prototype.containerNode=function(){if(this._range){this._containerNode||(this._containerNode=$(this._range.commonAncestorContainer))}return this._containerNode};Selection.prototype.nodes=function(){if(this._range){this._nodes||(this._nodes=(function(_this){return function(){var nodes;nodes=[];if(_this.startNodes().first().is(_this.endNodes().first())){nodes=_this.startNodes().get()}else{_this.startNodes().each(function(i,node){var $endNode,$node,$nodes,endIndex,index,sharedIndex,startIndex;$node=$(node);if(_this.endNodes().index($node)>-1){return nodes.push(node)}else{if($node.parent().is(_this.editor.body)||(sharedIndex=_this.endNodes().index($node.parent()))>-1){if(sharedIndex&&sharedIndex>-1){$endNode=_this.endNodes().eq(sharedIndex-1)}else{$endNode=_this.endNodes().last()}$nodes=$node.parent().contents();startIndex=$nodes.index($node);endIndex=$nodes.index($endNode);return $.merge(nodes,$nodes.slice(startIndex,endIndex).get())}else{$nodes=$node.parent().contents();index=$nodes.index($node);return $.merge(nodes,$nodes.slice(index).get())}}});_this.endNodes().each(function(i,node){var $node,$nodes,index;$node=$(node);if($node.parent().is(_this.editor.body)||_this.startNodes().index($node.parent())>-1){nodes.push(node);return false}else{$nodes=$node.parent().contents();index=$nodes.index($node);return $.merge(nodes,$nodes.slice(0,index+1))}})}return $($.unique(nodes))} |
|
7 |
+})(this)())}return this._nodes};Selection.prototype.blockNodes=function(){if(!this._range){return}this._blockNodes||(this._blockNodes=(function(_this){return function(){return _this.nodes().filter(function(i,node){return _this.editor.util.isBlockNode(node)})}})(this)());return this._blockNodes};Selection.prototype.rootNodes=function(){if(!this._range){return}this._rootNodes||(this._rootNodes=(function(_this){return function(){return _this.nodes().filter(function(i,node){var $parent;$parent=$(node).parent();return $parent.is(_this.editor.body)||$parent.is("blockquote")})}})(this)());return this._rootNodes};Selection.prototype.rangeAtEndOf=function(node,range){var afterLastNode,beforeLastNode,endNode,endNodeLength,lastNodeIsBr,result;if(range==null){range=this.range()}if(!(range&&range.collapsed)){return}node=$(node)[0];endNode=range.endContainer;endNodeLength=this.editor.util.getNodeLength(endNode);beforeLastNode=range.endOffset===endNodeLength-1;lastNodeIsBr=$(endNode).contents().last().is("br");afterLastNode=range.endOffset===endNodeLength;if(!((beforeLastNode&&lastNodeIsBr)||afterLastNode)){return false}if(node===endNode){return true}else{if(!$.contains(node,endNode)){return false}}result=true;$(endNode).parentsUntil(node).addBack().each(function(i,n){var $lastChild,beforeLastbr,isLastNode,nodes;nodes=$(n).parent().contents().filter(function(){return !(this!==n&&this.nodeType===3&&!this.nodeValue)});$lastChild=nodes.last();isLastNode=$lastChild.get(0)===n;beforeLastbr=$lastChild.is("br")&&$lastChild.prev().get(0)===n;if(!(isLastNode||beforeLastbr)){result=false;return false}});return result};Selection.prototype.rangeAtStartOf=function(node,range){var result,startNode;if(range==null){range=this.range()}if(!(range&&range.collapsed)){return}node=$(node)[0];startNode=range.startContainer;if(range.startOffset!==0){return false}if(node===startNode){return true}else{if(!$.contains(node,startNode)){return false}}result=true;$(startNode).parentsUntil(node).addBack().each(function(i,n){var nodes;nodes=$(n).parent().contents().filter(function(){return !(this!==n&&this.nodeType===3&&!this.nodeValue)});if(nodes.first().get(0)!==n){return result=false}});return result};Selection.prototype.insertNode=function(node,range){if(range==null){range=this.range()}if(!range){return}node=$(node)[0];range.insertNode(node);return this.setRangeAfter(node,range)};Selection.prototype.setRangeAfter=function(node,range){if(range==null){range=this.range()}if(range==null){return}node=$(node)[0];range.setEndAfter(node);range.collapse(false);return this.range(range)};Selection.prototype.setRangeBefore=function(node,range){if(range==null){range=this.range()}if(range==null){return}node=$(node)[0];range.setEndBefore(node);range.collapse(false);return this.range(range)};Selection.prototype.setRangeAtStartOf=function(node,range){if(range==null){range=this.range()}node=$(node).get(0);range.setEnd(node,0);range.collapse(false);return this.range(range)};Selection.prototype.setRangeAtEndOf=function(node,range){var $lastNode,$node,contents,lastChild,lastChildLength,lastText,nodeLength;if(range==null){range=this.range()}$node=$(node);node=$node[0];if($node.is("pre")){contents=$node.contents();if(contents.length>0){lastChild=contents.last();lastText=lastChild.text();lastChildLength=this.editor.util.getNodeLength(lastChild[0]);if(lastText.charAt(lastText.length-1)==="\n"){range.setEnd(lastChild[0],lastChildLength-1)}else{range.setEnd(lastChild[0],lastChildLength)}}else{range.setEnd(node,0)}}else{nodeLength=this.editor.util.getNodeLength(node);if(node.nodeType!==3&&nodeLength>0){$lastNode=$(node).contents().last();if($lastNode.is("br")){nodeLength-=1}else{if($lastNode[0].nodeType!==3&&this.editor.util.isEmptyNode($lastNode)){$lastNode.append(this.editor.util.phBr);node=$lastNode[0];nodeLength=0}}}range.setEnd(node,nodeLength)}range.collapse(false);return this.range(range)};Selection.prototype.deleteRangeContents=function(range){var atEndOfBody,atStartOfBody,endRange,startRange;if(range==null){range=this.range()}startRange=range.cloneRange();endRange=range.cloneRange();startRange.collapse(true);endRange.collapse(false);atStartOfBody=this.rangeAtStartOf(this.editor.body,startRange);atEndOfBody=this.rangeAtEndOf(this.editor.body,endRange);if(!range.collapsed&&atStartOfBody&&atEndOfBody){this.editor.body.empty();range.setStart(this.editor.body[0],0);range.collapse(true);this.range(range)}else{range.deleteContents()}return range};Selection.prototype.breakBlockEl=function(el,range){var $el;if(range==null){range=this.range()}$el=$(el);if(!range.collapsed){return $el}range.setStartBefore($el.get(0));if(range.collapsed){return $el}return $el.before(range.extractContents())};Selection.prototype.save=function(range){var endCaret,endRange,startCaret;if(range==null){range=this.range()}if(this._selectionSaved){return}endRange=range.cloneRange();endRange.collapse(false);startCaret=$("<span/>").addClass("simditor-caret-start");endCaret=$("<span/>").addClass("simditor-caret-end"); |
|
8 |
+endRange.insertNode(endCaret[0]);range.insertNode(startCaret[0]);this.clear();return this._selectionSaved=true};Selection.prototype.restore=function(){var endCaret,endContainer,endOffset,range,startCaret,startContainer,startOffset;if(!this._selectionSaved){return false}startCaret=this.editor.body.find(".simditor-caret-start");endCaret=this.editor.body.find(".simditor-caret-end");if(startCaret.length&&endCaret.length){startContainer=startCaret.parent();startOffset=startContainer.contents().index(startCaret);endContainer=endCaret.parent();endOffset=endContainer.contents().index(endCaret);if(startContainer[0]===endContainer[0]){endOffset-=1}range=document.createRange();range.setStart(startContainer.get(0),startOffset);range.setEnd(endContainer.get(0),endOffset);startCaret.remove();endCaret.remove();this.range(range)}else{startCaret.remove();endCaret.remove()}this._selectionSaved=false;return range};return Selection})(SimpleModule);Formatter=(function(superClass){extend(Formatter,superClass);function Formatter(){return Formatter.__super__.constructor.apply(this,arguments)}Formatter.pluginName="Formatter";Formatter.prototype.opts={allowedTags:[],allowedAttributes:{},allowedStyles:{}};Formatter.prototype._init=function(){this.editor=this._module;this._allowedTags=$.merge(["br","span","a","img","b","strong","i","strike","u","font","p","ul","ol","li","blockquote","pre","code","h1","h2","h3","h4","hr"],this.opts.allowedTags);this._allowedAttributes=$.extend({img:["src","alt","width","height","data-non-image"],a:["href","target"],font:["color"],code:["class"]},this.opts.allowedAttributes);this._allowedStyles=$.extend({span:["color","font-size"],b:["color"],i:["color"],strong:["color"],strike:["color"],u:["color"],p:["margin-left","text-align"],h1:["margin-left","text-align"],h2:["margin-left","text-align"],h3:["margin-left","text-align"],h4:["margin-left","text-align"]},this.opts.allowedStyles);return this.editor.body.on("click","a",function(e){return false})};Formatter.prototype.decorate=function($el){if($el==null){$el=this.editor.body}this.editor.trigger("decorate",[$el]);return $el};Formatter.prototype.undecorate=function($el){if($el==null){$el=this.editor.body.clone()}this.editor.trigger("undecorate",[$el]);return $el};Formatter.prototype.autolink=function($el){var $link,$node,findLinkNode,k,lastIndex,len,linkNodes,match,re,replaceEls,subStr,text,uri;if($el==null){$el=this.editor.body}linkNodes=[];findLinkNode=function($parentNode){return $parentNode.contents().each(function(i,node){var $node,text;$node=$(node);if($node.is("a")||$node.closest("a, pre",$el).length){return}if(!$node.is("iframe")&&$node.contents().length){return findLinkNode($node)}else{if((text=$node.text())&&/https?:\/\/|www\./ig.test(text)){return linkNodes.push($node)}}})};findLinkNode($el);re=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/ig;for(k=0,len=linkNodes.length;k<len;k++){$node=linkNodes[k];text=$node.text();replaceEls=[];match=null;lastIndex=0;while((match=re.exec(text))!==null){subStr=text.substring(lastIndex,match.index);replaceEls.push(document.createTextNode(subStr));lastIndex=re.lastIndex;uri=/^(http(s)?:\/\/|\/)/.test(match[0])?match[0]:"http://"+match[0];$link=$('<a href="'+uri+'" rel="nofollow"></a>').text(match[0]);replaceEls.push($link[0])}replaceEls.push(document.createTextNode(text.substring(lastIndex)));$node.replaceWith($(replaceEls))}return $el};Formatter.prototype.format=function($el){var $node,blockNode,k,l,len,len1,n,node,ref,ref1;if($el==null){$el=this.editor.body}if($el.is(":empty")){$el.append("<p>"+this.editor.util.phBr+"</p>");return $el}ref=$el.contents();for(k=0,len=ref.length;k<len;k++){n=ref[k];this.cleanNode(n,true)}ref1=$el.contents();for(l=0,len1=ref1.length;l<len1;l++){node=ref1[l];$node=$(node);if($node.is("br")){if(typeof blockNode!=="undefined"&&blockNode!==null){blockNode=null}$node.remove()}else{if(this.editor.util.isBlockNode(node)){if($node.is("li")){if(blockNode&&blockNode.is("ul, ol")){blockNode.append(node)}else{blockNode=$("<ul/>").insertBefore(node);blockNode.append(node)}}else{blockNode=null}}else{if(!blockNode||blockNode.is("ul, ol")){blockNode=$("<p/>").insertBefore(node)}blockNode.append(node);if(this.editor.util.isEmptyNode(blockNode)){blockNode.append(this.editor.util.phBr)}}}}return $el};Formatter.prototype.cleanNode=function(node,recursive){var $blockEls,$childImg,$node,$p,$td,allowedAttributes,attr,contents,isDecoration,k,l,len,len1,n,ref,ref1,text,textNode;$node=$(node);if(!($node.length>0)){return}if($node[0].nodeType===3){text=$node.text().replace(/(\r\n|\n|\r)/gm,"");if(text){textNode=document.createTextNode(text);$node.replaceWith(textNode)}else{$node.remove()}return}contents=$node.is("iframe")?null:$node.contents();isDecoration=this.editor.util.isDecoratedNode($node);if($node.is(this._allowedTags.join(","))||isDecoration){if($node.is("a")&&($childImg=$node.find("img")).length>0){$node.replaceWith($childImg);$node=$childImg;contents=null}if($node.is("td")&&($blockEls=$node.find(this.editor.util.blockNodes.join(","))).length>0){$blockEls.each((function(_this){return function(i,blockEl){return $(blockEl).contents().unwrap() |
|
9 |
+}})(this));contents=$node.contents()}if($node.is("img")&&$node.hasClass("uploading")){$node.remove()}if(!isDecoration){allowedAttributes=this._allowedAttributes[$node[0].tagName.toLowerCase()];ref=$.makeArray($node[0].attributes);for(k=0,len=ref.length;k<len;k++){attr=ref[k];if(attr.name==="style"){continue}if(!((allowedAttributes!=null)&&(ref1=attr.name,indexOf.call(allowedAttributes,ref1)>=0))){$node.removeAttr(attr.name)}}this._cleanNodeStyles($node);if($node.is("span")&&$node[0].attributes.length===0){$node.contents().first().unwrap()}}}else{if($node[0].nodeType===1&&!$node.is(":empty")){if($node.is("div, article, dl, header, footer, tr")){$node.append("<br/>");contents.first().unwrap()}else{if($node.is("table")){$p=$("<p/>");$node.find("tr").each(function(i,tr){return $p.append($(tr).text()+"<br/>")});$node.replaceWith($p);contents=null}else{if($node.is("thead, tfoot")){$node.remove();contents=null}else{if($node.is("th")){$td=$("<td/>").append($node.contents());$node.replaceWith($td)}else{contents.first().unwrap()}}}}}else{$node.remove();contents=null}}if(recursive&&(contents!=null)&&!$node.is("pre")){for(l=0,len1=contents.length;l<len1;l++){n=contents[l];this.cleanNode(n,true)}}return null};Formatter.prototype._cleanNodeStyles=function($node){var allowedStyles,k,len,pair,ref,ref1,style,styleStr,styles;styleStr=$node.attr("style");if(!styleStr){return}$node.removeAttr("style");allowedStyles=this._allowedStyles[$node[0].tagName.toLowerCase()];if(!(allowedStyles&&allowedStyles.length>0)){return $node}styles={};ref=styleStr.split(";");for(k=0,len=ref.length;k<len;k++){style=ref[k];style=$.trim(style);pair=style.split(":");if(!(pair.length=2)){continue}if(ref1=pair[0],indexOf.call(allowedStyles,ref1)>=0){styles[$.trim(pair[0])]=$.trim(pair[1])}}if(Object.keys(styles).length>0){$node.css(styles)}return $node};Formatter.prototype.clearHtml=function(html,lineBreak){var container,contents,result;if(lineBreak==null){lineBreak=true}container=$("<div/>").append(html);contents=container.contents();result="";contents.each((function(_this){return function(i,node){var $node,children;if(node.nodeType===3){return result+=node.nodeValue}else{if(node.nodeType===1){$node=$(node);children=$node.is("iframe")?null:$node.contents();if(children&&children.length>0){result+=_this.clearHtml(children)}if(lineBreak&&i<contents.length-1&&$node.is("br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header")){return result+="\n"}}}}})(this));return result};Formatter.prototype.beautify=function($contents){var uselessP;uselessP=function($el){return !!($el.is("p")&&!$el.text()&&$el.children(":not(br)").length<1)};return $contents.each(function(i,el){var $el,invalid;$el=$(el);invalid=$el.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty');if(invalid||uselessP($el)){$el.remove()}return $el.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove()})};return Formatter})(SimpleModule);InputManager=(function(superClass){extend(InputManager,superClass);function InputManager(){return InputManager.__super__.constructor.apply(this,arguments)}InputManager.pluginName="InputManager";InputManager.prototype._modifierKeys=[16,17,18,91,93,224];InputManager.prototype._arrowKeys=[37,38,39,40];InputManager.prototype._init=function(){var selectAllKey,submitKey;this.editor=this._module;this.throttledValueChanged=this.editor.util.throttle((function(_this){return function(params){return setTimeout(function(){return _this.editor.trigger("valuechanged",params)},10)}})(this),300);this.throttledSelectionChanged=this.editor.util.throttle((function(_this){return function(){return _this.editor.trigger("selectionchanged")}})(this),50);$(document).on("selectionchange.simditor"+this.editor.id,(function(_this){return function(e){var triggerEvent;if(!(_this.focused&&!_this.editor.clipboard.pasting)){return}triggerEvent=function(){if(_this._selectionTimer){clearTimeout(_this._selectionTimer);_this._selectionTimer=null}if(_this.editor.selection._selection.rangeCount>0){return _this.throttledSelectionChanged()}else{return _this._selectionTimer=setTimeout(function(){_this._selectionTimer=null;if(_this.focused){return triggerEvent()}},10)}};return triggerEvent()}})(this));this.editor.on("valuechanged",(function(_this){return function(){var $rootBlocks;_this.lastCaretPosition=null;$rootBlocks=_this.editor.body.children().filter(function(i,node){return _this.editor.util.isBlockNode(node)});if(_this.focused&&$rootBlocks.length===0){_this.editor.selection.save();_this.editor.formatter.format();_this.editor.selection.restore()}_this.editor.body.find("hr, pre, .simditor-table").each(function(i,el){var $el,formatted;$el=$(el);if($el.parent().is("blockquote")||$el.parent()[0]===_this.editor.body[0]){formatted=false;if($el.next().length===0){$("<p/>").append(_this.editor.util.phBr).insertAfter($el);formatted=true}if($el.prev().length===0){$("<p/>").append(_this.editor.util.phBr).insertBefore($el);formatted=true}if(formatted){return _this.throttledValueChanged() |
|
10 |
+}}});_this.editor.body.find("pre:empty").append(_this.editor.util.phBr);if(!_this.editor.util.support.onselectionchange&&_this.focused){return _this.throttledSelectionChanged()}}})(this));this.editor.body.on("keydown",$.proxy(this._onKeyDown,this)).on("keypress",$.proxy(this._onKeyPress,this)).on("keyup",$.proxy(this._onKeyUp,this)).on("mouseup",$.proxy(this._onMouseUp,this)).on("focus",$.proxy(this._onFocus,this)).on("blur",$.proxy(this._onBlur,this)).on("drop",$.proxy(this._onDrop,this)).on("input",$.proxy(this._onInput,this));if(this.editor.util.browser.firefox){this.editor.hotkeys.add("cmd+left",(function(_this){return function(e){e.preventDefault();_this.editor.selection._selection.modify("move","backward","lineboundary");return false}})(this));this.editor.hotkeys.add("cmd+right",(function(_this){return function(e){e.preventDefault();_this.editor.selection._selection.modify("move","forward","lineboundary");return false}})(this));selectAllKey=this.editor.util.os.mac?"cmd+a":"ctrl+a";this.editor.hotkeys.add(selectAllKey,(function(_this){return function(e){var $children,firstBlock,lastBlock,range;$children=_this.editor.body.children();if(!($children.length>0)){return}firstBlock=$children.first().get(0);lastBlock=$children.last().get(0);range=document.createRange();range.setStart(firstBlock,0);range.setEnd(lastBlock,_this.editor.util.getNodeLength(lastBlock));_this.editor.selection.range(range);return false}})(this))}submitKey=this.editor.util.os.mac?"cmd+enter":"ctrl+enter";return this.editor.hotkeys.add(submitKey,(function(_this){return function(e){_this.editor.el.closest("form").find("button:submit").click();return false}})(this))};InputManager.prototype._onFocus=function(e){if(this.editor.clipboard.pasting){return}this.editor.el.addClass("focus").removeClass("error");this.focused=true;return setTimeout((function(_this){return function(){var $blockEl,range;range=_this.editor.selection._selection.getRangeAt(0);if(range.startContainer===_this.editor.body[0]){if(_this.lastCaretPosition){_this.editor.undoManager.caretPosition(_this.lastCaretPosition)}else{$blockEl=_this.editor.body.children().first();range=document.createRange();_this.editor.selection.setRangeAtStartOf($blockEl,range)}}_this.lastCaretPosition=null;_this.editor.triggerHandler("focus");if(!_this.editor.util.support.onselectionchange){return _this.throttledSelectionChanged()}}})(this),0)};InputManager.prototype._onBlur=function(e){var ref;if(this.editor.clipboard.pasting){return}this.editor.el.removeClass("focus");this.editor.sync();this.focused=false;this.lastCaretPosition=(ref=this.editor.undoManager.currentState())!=null?ref.caret:void 0;return this.editor.triggerHandler("blur")};InputManager.prototype._onMouseUp=function(e){if(!this.editor.util.support.onselectionchange){return this.throttledSelectionChanged()}};InputManager.prototype._onKeyDown=function(e){var ref,ref1;if(this.editor.triggerHandler(e)===false){return false}if(this.editor.hotkeys.respondTo(e)){return}if(this.editor.keystroke.respondTo(e)){this.throttledValueChanged();return false}if((ref=e.which,indexOf.call(this._modifierKeys,ref)>=0)||(ref1=e.which,indexOf.call(this._arrowKeys,ref1)>=0)){return}if(this.editor.util.metaKey(e)&&e.which===86){return}if(!this.editor.util.support.oninput){this.throttledValueChanged(["typing"])}return null};InputManager.prototype._onKeyPress=function(e){if(this.editor.triggerHandler(e)===false){return false}};InputManager.prototype._onKeyUp=function(e){var p,ref;if(this.editor.triggerHandler(e)===false){return false}if(!this.editor.util.support.onselectionchange&&(ref=e.which,indexOf.call(this._arrowKeys,ref)>=0)){this.throttledValueChanged();return}if((e.which===8||e.which===46)&&this.editor.util.isEmptyNode(this.editor.body)){this.editor.body.empty();p=$("<p/>").append(this.editor.util.phBr).appendTo(this.editor.body);this.editor.selection.setRangeAtStartOf(p)}};InputManager.prototype._onDrop=function(e){if(this.editor.triggerHandler(e)===false){return false}return this.throttledValueChanged()};InputManager.prototype._onInput=function(e){return this.throttledValueChanged(["oninput"])};return InputManager})(SimpleModule);Keystroke=(function(superClass){extend(Keystroke,superClass);function Keystroke(){return Keystroke.__super__.constructor.apply(this,arguments)}Keystroke.pluginName="Keystroke";Keystroke.prototype._init=function(){this.editor=this._module;this._keystrokeHandlers={};return this._initKeystrokeHandlers()};Keystroke.prototype.add=function(key,node,handler){key=key.toLowerCase();key=this.editor.hotkeys.constructor.aliases[key]||key;if(!this._keystrokeHandlers[key]){this._keystrokeHandlers[key]={}}return this._keystrokeHandlers[key][node]=handler};Keystroke.prototype.respondTo=function(e){var base,key,ref,result;key=(ref=this.editor.hotkeys.constructor.keyNameMap[e.which])!=null?ref.toLowerCase():void 0;if(!key){return}if(key in this._keystrokeHandlers){result=typeof(base=this._keystrokeHandlers[key])["*"]==="function"?base["*"](e):void 0; |
|
11 |
+if(!result){this.editor.selection.startNodes().each((function(_this){return function(i,node){var handler,ref1;if(node.nodeType!==Node.ELEMENT_NODE){return}handler=(ref1=_this._keystrokeHandlers[key])!=null?ref1[node.tagName.toLowerCase()]:void 0;result=typeof handler==="function"?handler(e,$(node)):void 0;if(result===true||result===false){return false}}})(this))}if(result){return true}}};Keystroke.prototype._initKeystrokeHandlers=function(){var titleEnterHandler;if(this.editor.util.browser.safari){this.add("enter","*",(function(_this){return function(e){var $blockEl,$br;if(!e.shiftKey){return}$blockEl=_this.editor.selection.blockNodes().last();if($blockEl.is("pre")){return}$br=$("<br/>");if(_this.editor.selection.rangeAtEndOf($blockEl)){_this.editor.selection.insertNode($br);_this.editor.selection.insertNode($("<br/>"));_this.editor.selection.setRangeBefore($br)}else{_this.editor.selection.insertNode($br)}return true}})(this))}if(this.editor.util.browser.webkit||this.editor.util.browser.msie){titleEnterHandler=(function(_this){return function(e,$node){var $p;if(!_this.editor.selection.rangeAtEndOf($node)){return}$p=$("<p/>").append(_this.editor.util.phBr).insertAfter($node);_this.editor.selection.setRangeAtStartOf($p);return true}})(this);this.add("enter","h1",titleEnterHandler);this.add("enter","h2",titleEnterHandler);this.add("enter","h3",titleEnterHandler);this.add("enter","h4",titleEnterHandler);this.add("enter","h5",titleEnterHandler);this.add("enter","h6",titleEnterHandler)}this.add("backspace","*",(function(_this){return function(e){var $blockEl,$prevBlockEl,$rootBlock,isWebkit;$rootBlock=_this.editor.selection.rootNodes().first();$prevBlockEl=$rootBlock.prev();if($prevBlockEl.is("hr")&&_this.editor.selection.rangeAtStartOf($rootBlock)){_this.editor.selection.save();$prevBlockEl.remove();_this.editor.selection.restore();return true}$blockEl=_this.editor.selection.blockNodes().last();isWebkit=_this.editor.util.browser.webkit;if(isWebkit&&_this.editor.selection.rangeAtStartOf($blockEl)){_this.editor.selection.save();_this.editor.formatter.cleanNode($blockEl,true);_this.editor.selection.restore();return null}}})(this));this.add("enter","li",(function(_this){return function(e,$node){var $cloneNode,listEl,newBlockEl,newListEl;$cloneNode=$node.clone();$cloneNode.find("ul, ol").remove();if(!(_this.editor.util.isEmptyNode($cloneNode)&&$node.is(_this.editor.selection.blockNodes().last()))){return}listEl=$node.parent();if($node.next("li").length>0){if(!_this.editor.util.isEmptyNode($node)){return}if(listEl.parent("li").length>0){newBlockEl=$("<li/>").append(_this.editor.util.phBr).insertAfter(listEl.parent("li"));newListEl=$("<"+listEl[0].tagName+"/>").append($node.nextAll("li"));newBlockEl.append(newListEl)}else{newBlockEl=$("<p/>").append(_this.editor.util.phBr).insertAfter(listEl);newListEl=$("<"+listEl[0].tagName+"/>").append($node.nextAll("li"));newBlockEl.after(newListEl)}}else{if(listEl.parent("li").length>0){newBlockEl=$("<li/>").insertAfter(listEl.parent("li"));if($node.contents().length>0){newBlockEl.append($node.contents())}else{newBlockEl.append(_this.editor.util.phBr)}}else{newBlockEl=$("<p/>").append(_this.editor.util.phBr).insertAfter(listEl);if($node.children("ul, ol").length>0){newBlockEl.after($node.children("ul, ol"))}}}if($node.prev("li").length){$node.remove()}else{listEl.remove()}_this.editor.selection.setRangeAtStartOf(newBlockEl);return true}})(this));this.add("enter","pre",(function(_this){return function(e,$node){var $p,breakNode,range;e.preventDefault();if(e.shiftKey){$p=$("<p/>").append(_this.editor.util.phBr).insertAfter($node);_this.editor.selection.setRangeAtStartOf($p);return true}range=_this.editor.selection.range();breakNode=null;range.deleteContents();if(!_this.editor.util.browser.msie&&_this.editor.selection.rangeAtEndOf($node)){breakNode=document.createTextNode("\n\n");range.insertNode(breakNode);range.setEnd(breakNode,1)}else{breakNode=document.createTextNode("\n");range.insertNode(breakNode);range.setStartAfter(breakNode)}range.collapse(false);_this.editor.selection.range(range);return true}})(this));this.add("enter","blockquote",(function(_this){return function(e,$node){var $closestBlock,range;$closestBlock=_this.editor.selection.blockNodes().last();if(!($closestBlock.is("p")&&!$closestBlock.next().length&&_this.editor.util.isEmptyNode($closestBlock))){return}$node.after($closestBlock);range=document.createRange();_this.editor.selection.setRangeAtStartOf($closestBlock,range);return true}})(this));this.add("backspace","li",(function(_this){return function(e,$node){var $br,$childList,$newLi,$prevChildList,$prevNode,$textNode,isFF,range,text;$childList=$node.children("ul, ol");$prevNode=$node.prev("li");if(!($childList.length>0&&$prevNode.length>0)){return false}text="";$textNode=null;$node.contents().each(function(i,n){if(n.nodeType===1&&/UL|OL/.test(n.nodeName)){return false}if(n.nodeType===1&&/BR/.test(n.nodeName)){return}if(n.nodeType===3&&n.nodeValue){text+=n.nodeValue}else{if(n.nodeType===1){text+=$(n).text() |
|
12 |
+}}return $textNode=$(n)});isFF=_this.editor.util.browser.firefox&&!$textNode.next("br").length;if($textNode&&text.length===1&&isFF){$br=$(_this.editor.util.phBr).insertAfter($textNode);$textNode.remove();_this.editor.selection.setRangeBefore($br);return true}else{if(text.length>0){return false}}range=document.createRange();$prevChildList=$prevNode.children("ul, ol");if($prevChildList.length>0){$newLi=$("<li/>").append(_this.editor.util.phBr).appendTo($prevChildList);$prevChildList.append($childList.children("li"));$node.remove();_this.editor.selection.setRangeAtEndOf($newLi,range)}else{_this.editor.selection.setRangeAtEndOf($prevNode,range);$prevNode.append($childList);$node.remove();_this.editor.selection.range(range)}return true}})(this));this.add("backspace","pre",(function(_this){return function(e,$node){var $newNode,codeStr,range;if(!_this.editor.selection.rangeAtStartOf($node)){return}codeStr=$node.html().replace("\n","<br/>")||_this.editor.util.phBr;$newNode=$("<p/>").append(codeStr).insertAfter($node);$node.remove();range=document.createRange();_this.editor.selection.setRangeAtStartOf($newNode,range);return true}})(this));return this.add("backspace","blockquote",(function(_this){return function(e,$node){var $firstChild,range;if(!_this.editor.selection.rangeAtStartOf($node)){return}$firstChild=$node.children().first().unwrap();range=document.createRange();_this.editor.selection.setRangeAtStartOf($firstChild,range);return true}})(this))};return Keystroke})(SimpleModule);UndoManager=(function(superClass){extend(UndoManager,superClass);function UndoManager(){return UndoManager.__super__.constructor.apply(this,arguments)}UndoManager.pluginName="UndoManager";UndoManager.prototype._index=-1;UndoManager.prototype._capacity=20;UndoManager.prototype._startPosition=null;UndoManager.prototype._endPosition=null;UndoManager.prototype._init=function(){var redoShortcut,undoShortcut;this.editor=this._module;this._stack=[];if(this.editor.util.os.mac){undoShortcut="cmd+z";redoShortcut="shift+cmd+z"}else{if(this.editor.util.os.win){undoShortcut="ctrl+z";redoShortcut="ctrl+y"}else{undoShortcut="ctrl+z";redoShortcut="shift+ctrl+z"}}this.editor.hotkeys.add(undoShortcut,(function(_this){return function(e){e.preventDefault();_this.undo();return false}})(this));this.editor.hotkeys.add(redoShortcut,(function(_this){return function(e){e.preventDefault();_this.redo();return false}})(this));this.throttledPushState=this.editor.util.throttle((function(_this){return function(){return _this._pushUndoState()}})(this),2000);this.editor.on("valuechanged",(function(_this){return function(e,src){if(src==="undo"||src==="redo"){return}return _this.throttledPushState()}})(this));this.editor.on("selectionchanged",(function(_this){return function(e){_this.resetCaretPosition();return _this.update()}})(this));this.editor.on("focus",(function(_this){return function(e){if(_this._stack.length===0){return _this._pushUndoState()}}})(this));return this.editor.on("blur",(function(_this){return function(e){return _this.resetCaretPosition()}})(this))};UndoManager.prototype.resetCaretPosition=function(){this._startPosition=null;return this._endPosition=null};UndoManager.prototype.startPosition=function(){if(this.editor.selection._range){this._startPosition||(this._startPosition=this._getPosition("start"))}return this._startPosition};UndoManager.prototype.endPosition=function(){if(this.editor.selection._range){this._endPosition||(this._endPosition=(function(_this){return function(){var range;range=_this.editor.selection.range();if(range.collapsed){return _this._startPosition}return _this._getPosition("end")}})(this)())}return this._endPosition};UndoManager.prototype._pushUndoState=function(){var caret;if(this.editor.triggerHandler("pushundostate")===false){return}caret=this.caretPosition();if(!caret.start){return}this._index+=1;this._stack.length=this._index;this._stack.push({html:this.editor.body.html(),caret:this.caretPosition()});if(this._stack.length>this._capacity){this._stack.shift();return this._index-=1}};UndoManager.prototype.currentState=function(){if(this._stack.length&&this._index>-1){return this._stack[this._index]}else{return null}};UndoManager.prototype.undo=function(){var state;if(this._index<1||this._stack.length<2){return}this.editor.hidePopover();this._index-=1;state=this._stack[this._index];this.editor.body.get(0).innerHTML=state.html;this.caretPosition(state.caret);this.editor.body.find(".selected").removeClass("selected");this.editor.sync();return this.editor.trigger("valuechanged",["undo"])};UndoManager.prototype.redo=function(){var state;if(this._index<0||this._stack.length<this._index+2){return}this.editor.hidePopover();this._index+=1;state=this._stack[this._index];this.editor.body.get(0).innerHTML=state.html;this.caretPosition(state.caret);this.editor.body.find(".selected").removeClass("selected");this.editor.sync();return this.editor.trigger("valuechanged",["redo"])};UndoManager.prototype.update=function(){var currentState;currentState=this.currentState(); |
|
13 |
+if(!currentState){return}currentState.html=this.editor.body.html();return currentState.caret=this.caretPosition()};UndoManager.prototype._getNodeOffset=function(node,index){var $parent,merging,offset;if($.isNumeric(index)){$parent=$(node)}else{$parent=$(node).parent()}offset=0;merging=false;$parent.contents().each(function(i,child){if(node===child||(index===i&&i===0)){return false}if(child.nodeType===Node.TEXT_NODE){if(!merging&&child.nodeValue.length>0){offset+=1;merging=true}}else{offset+=1;merging=false}if(index-1===i){return false}return null});return offset};UndoManager.prototype._getPosition=function(type){var $nodes,node,nodes,offset,position,prevNode,range;if(type==null){type="start"}range=this.editor.selection.range();offset=range[type+"Offset"];$nodes=this.editor.selection[type+"Nodes"]();node=$nodes.first()[0];if(node.nodeType===Node.TEXT_NODE){prevNode=node.previousSibling;while(prevNode&&prevNode.nodeType===Node.TEXT_NODE){node=prevNode;offset+=this.editor.util.getNodeLength(prevNode);prevNode=prevNode.previousSibling}nodes=$nodes.get();nodes[0]=node;$nodes=$(nodes)}else{offset=this._getNodeOffset(node,offset)}position=[offset];$nodes.each((function(_this){return function(i,node){return position.unshift(_this._getNodeOffset(node))}})(this));return position};UndoManager.prototype._getNodeByPosition=function(position){var child,childNodes,i,k,len,node,offset,ref;node=this.editor.body[0];ref=position.slice(0,position.length-1);for(i=k=0,len=ref.length;k<len;i=++k){offset=ref[i];childNodes=node.childNodes;if(offset>childNodes.length-1){if(i===position.length-2&&$(node).is("pre:empty")){child=document.createTextNode("");node.appendChild(child);childNodes=node.childNodes}else{node=null;break}}node=childNodes[offset]}return node};UndoManager.prototype.caretPosition=function(caret){var endContainer,endOffset,range,startContainer,startOffset;if(!caret){range=this.editor.selection.range();caret=this.editor.inputManager.focused&&(range!=null)?{start:this.startPosition(),end:this.endPosition(),collapsed:range.collapsed}:{};return caret}else{if(!caret.start){return}startContainer=this._getNodeByPosition(caret.start);startOffset=caret.start[caret.start.length-1];if(caret.collapsed){endContainer=startContainer;endOffset=startOffset}else{endContainer=this._getNodeByPosition(caret.end);endOffset=caret.start[caret.start.length-1]}if(!startContainer||!endContainer){if(typeof console!=="undefined"&&console!==null){if(typeof console.warn==="function"){console.warn("simditor: invalid caret state")}}return}range=document.createRange();range.setStart(startContainer,startOffset);range.setEnd(endContainer,endOffset);return this.editor.selection.range(range)}};return UndoManager})(SimpleModule);Util=(function(superClass){extend(Util,superClass);function Util(){return Util.__super__.constructor.apply(this,arguments)}Util.pluginName="Util";Util.prototype._init=function(){this.editor=this._module;if(this.browser.msie&&this.browser.version<11){return this.phBr=""}};Util.prototype.phBr="<br/>";Util.prototype.os=(function(){var os;os={};if(/Mac/.test(navigator.appVersion)){os.mac=true}else{if(/Linux/.test(navigator.appVersion)){os.linux=true}else{if(/Win/.test(navigator.appVersion)){os.win=true}else{if(/X11/.test(navigator.appVersion)){os.unix=true}}}}if(/Mobi/.test(navigator.appVersion)){os.mobile=true}return os})();Util.prototype.browser=(function(){var chrome,edge,firefox,ie,ref,ref1,ref2,ref3,ref4,safari,ua;ua=navigator.userAgent;ie=/(msie|trident)/i.test(ua);chrome=/chrome|crios/i.test(ua);safari=/safari/i.test(ua)&&!chrome;firefox=/firefox/i.test(ua);edge=/edge/i.test(ua);if(ie){return{msie:true,version:((ref=ua.match(/(msie |rv:)(\d+(\.\d+)?)/i))!=null?ref[2]:void 0)*1}}else{if(edge){return{edge:true,webkit:true,version:((ref1=ua.match(/edge\/(\d+(\.\d+)?)/i))!=null?ref1[1]:void 0)*1}}else{if(chrome){return{webkit:true,chrome:true,version:((ref2=ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i))!=null?ref2[1]:void 0)*1}}else{if(safari){return{webkit:true,safari:true,version:((ref3=ua.match(/version\/(\d+(\.\d+)?)/i))!=null?ref3[1]:void 0)*1}}else{if(firefox){return{mozilla:true,firefox:true,version:((ref4=ua.match(/firefox\/(\d+(\.\d+)?)/i))!=null?ref4[1]:void 0)*1}}else{return{}}}}}}})();Util.prototype.support=(function(){return{onselectionchange:(function(){var e,onselectionchange;onselectionchange=document.onselectionchange;if(onselectionchange!==void 0){try{document.onselectionchange=0;return document.onselectionchange===null}catch(_error){e=_error}finally{document.onselectionchange=onselectionchange}}return false})(),oninput:(function(){return !/(msie|trident)/i.test(navigator.userAgent)})()}})();Util.prototype.reflow=function(el){if(el==null){el=document}return $(el)[0].offsetHeight};Util.prototype.metaKey=function(e){var isMac;isMac=/Mac/.test(navigator.userAgent);if(isMac){return e.metaKey}else{return e.ctrlKey}};Util.prototype.isEmptyNode=function(node){var $node;$node=$(node);return $node.is(":empty")||(!$node.text()&&!$node.find(":not(br, span, div)").length) |
|
14 |
+};Util.prototype.isDecoratedNode=function(node){return $(node).is('[class^="simditor-"]')};Util.prototype.blockNodes=["div","p","ul","ol","li","blockquote","hr","pre","h1","h2","h3","h4","h5","table"];Util.prototype.isBlockNode=function(node){node=$(node)[0];if(!node||node.nodeType===3){return false}return new RegExp("^("+(this.blockNodes.join("|"))+")$").test(node.nodeName.toLowerCase())};Util.prototype.getNodeLength=function(node){node=$(node)[0];switch(node.nodeType){case 7:case 10:return 0;case 3:case 8:return node.length;default:return node.childNodes.length}};Util.prototype.dataURLtoBlob=function(dataURL){var BlobBuilder,arrayBuffer,bb,blobArray,byteString,hasArrayBufferViewSupport,hasBlobConstructor,i,intArray,k,mimeString,ref,supportBlob;hasBlobConstructor=window.Blob&&(function(){var e;try{return Boolean(new Blob())}catch(_error){e=_error;return false}})();hasArrayBufferViewSupport=hasBlobConstructor&&window.Uint8Array&&(function(){var e;try{return new Blob([new Uint8Array(100)]).size===100}catch(_error){e=_error;return false}})();BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;supportBlob=hasBlobConstructor||BlobBuilder;if(!(supportBlob&&window.atob&&window.ArrayBuffer&&window.Uint8Array)){return false}if(dataURL.split(",")[0].indexOf("base64")>=0){byteString=atob(dataURL.split(",")[1])}else{byteString=decodeURIComponent(dataURL.split(",")[1])}arrayBuffer=new ArrayBuffer(byteString.length);intArray=new Uint8Array(arrayBuffer);for(i=k=0,ref=byteString.length;0<=ref?k<=ref:k>=ref;i=0<=ref?++k:--k){intArray[i]=byteString.charCodeAt(i)}mimeString=dataURL.split(",")[0].split(":")[1].split(";")[0];if(hasBlobConstructor){blobArray=hasArrayBufferViewSupport?intArray:arrayBuffer;return new Blob([blobArray],{type:mimeString})}bb=new BlobBuilder();bb.append(arrayBuffer);return bb.getBlob(mimeString)};Util.prototype.throttle=function(func,wait){var args,call,ctx,last,rtn,throttled,timeoutID;last=0;timeoutID=0;ctx=args=rtn=null;call=function(){timeoutID=0;last=+new Date();rtn=func.apply(ctx,args);ctx=null;return args=null};throttled=function(){var delta;ctx=this;args=arguments;delta=new Date()-last;if(!timeoutID){if(delta>=wait){call()}else{timeoutID=setTimeout(call,wait-delta)}}return rtn};throttled.clear=function(){if(!timeoutID){return}clearTimeout(timeoutID);return call()};return throttled};Util.prototype.formatHTML=function(html){var cursor,indentString,lastMatch,level,match,re,repeatString,result,str;re=/<(\/?)(.+?)(\/?)>/g;result="";level=0;lastMatch=null;indentString=" ";repeatString=function(str,n){return new Array(n+1).join(str)};while((match=re.exec(html))!==null){match.isBlockNode=$.inArray(match[2],this.blockNodes)>-1;match.isStartTag=match[1]!=="/"&&match[3]!=="/";match.isEndTag=match[1]==="/"||match[3]==="/";cursor=lastMatch?lastMatch.index+lastMatch[0].length:0;if((str=html.substring(cursor,match.index)).length>0&&$.trim(str)){result+=str}if(match.isBlockNode&&match.isEndTag&&!match.isStartTag){level-=1}if(match.isBlockNode&&match.isStartTag){if(!(lastMatch&&lastMatch.isBlockNode&&lastMatch.isEndTag)){result+="\n"}result+=repeatString(indentString,level)}result+=match[0];if(match.isBlockNode&&match.isEndTag){result+="\n"}if(match.isBlockNode&&match.isStartTag){level+=1}lastMatch=match}return $.trim(result)};return Util})(SimpleModule);Toolbar=(function(superClass){extend(Toolbar,superClass);function Toolbar(){return Toolbar.__super__.constructor.apply(this,arguments)}Toolbar.pluginName="Toolbar";Toolbar.prototype.opts={toolbar:true,toolbarFloat:true,toolbarHidden:false,toolbarFloatOffset:0};Toolbar.prototype._tpl={wrapper:'<div class="simditor-toolbar"><ul></ul></div>',separator:'<li><span class="separator"></span></li>'};Toolbar.prototype._init=function(){var floatInitialized,initToolbarFloat,toolbarHeight;this.editor=this._module;if(!this.opts.toolbar){return}if(!$.isArray(this.opts.toolbar)){this.opts.toolbar=["bold","italic","underline","strikethrough","|","ol","ul","blockquote","code","|","link","image","|","indent","outdent"]}this._render();this.list.on("click",function(e){return false});this.wrapper.on("mousedown",(function(_this){return function(e){return _this.list.find(".menu-on").removeClass(".menu-on")}})(this));$(document).on("mousedown.simditor"+this.editor.id,(function(_this){return function(e){return _this.list.find(".menu-on").removeClass(".menu-on")}})(this));if(!this.opts.toolbarHidden&&this.opts.toolbarFloat){this.wrapper.css("top",this.opts.toolbarFloatOffset);toolbarHeight=0;initToolbarFloat=(function(_this){return function(){_this.wrapper.css("position","static");_this.wrapper.width("auto");_this.editor.util.reflow(_this.wrapper);_this.wrapper.width(_this.wrapper.outerWidth());_this.wrapper.css("left",_this.editor.util.os.mobile?_this.wrapper.position().left:_this.wrapper.offset().left);_this.wrapper.css("position","");_this.editor.wrapper.width(_this.wrapper.outerWidth());toolbarHeight=_this.wrapper.outerHeight();_this.editor.placeholderEl.css("top",toolbarHeight); |
|
15 |
+return true}})(this);floatInitialized=null;$(window).on("resize.simditor-"+this.editor.id,function(e){return floatInitialized=initToolbarFloat()});$(window).on("scroll.simditor-"+this.editor.id,(function(_this){return function(e){var bottomEdge,scrollTop,topEdge;if(!_this.wrapper.is(":visible")){return}topEdge=_this.editor.wrapper.offset().top;bottomEdge=topEdge+_this.editor.wrapper.outerHeight()-80;scrollTop=$(document).scrollTop()+_this.opts.toolbarFloatOffset;if(scrollTop<=topEdge||scrollTop>=bottomEdge){_this.editor.wrapper.removeClass("toolbar-floating").css("padding-top","");if(_this.editor.util.os.mobile){return _this.wrapper.css("top",_this.opts.toolbarFloatOffset)}}else{floatInitialized||(floatInitialized=initToolbarFloat());_this.editor.wrapper.addClass("toolbar-floating").css("padding-top",toolbarHeight);if(_this.editor.util.os.mobile){return _this.wrapper.css("top",scrollTop-topEdge+_this.opts.toolbarFloatOffset)}}}})(this))}this.editor.on("destroy",(function(_this){return function(){return _this.buttons.length=0}})(this));return $(document).on("mousedown.simditor-"+this.editor.id,(function(_this){return function(e){return _this.list.find("li.menu-on").removeClass("menu-on")}})(this))};Toolbar.prototype._render=function(){var k,len,name,ref;this.buttons=[];this.wrapper=$(this._tpl.wrapper).prependTo(this.editor.wrapper);this.list=this.wrapper.find("ul");ref=this.opts.toolbar;for(k=0,len=ref.length;k<len;k++){name=ref[k];if(name==="|"){$(this._tpl.separator).appendTo(this.list);continue}if(!this.constructor.buttons[name]){throw new Error("simditor: invalid toolbar button "+name);continue}this.buttons.push(new this.constructor.buttons[name]({editor:this.editor}))}if(this.opts.toolbarHidden){return this.wrapper.hide()}};Toolbar.prototype.findButton=function(name){var button;button=this.list.find(".toolbar-item-"+name).data("button");return button!=null?button:null};Toolbar.addButton=function(btn){return this.buttons[btn.prototype.name]=btn};Toolbar.buttons={};return Toolbar})(SimpleModule);Indentation=(function(superClass){extend(Indentation,superClass);function Indentation(){return Indentation.__super__.constructor.apply(this,arguments)}Indentation.pluginName="Indentation";Indentation.prototype.opts={tabIndent:true};Indentation.prototype._init=function(){this.editor=this._module;return this.editor.keystroke.add("tab","*",(function(_this){return function(e){var codeButton;codeButton=_this.editor.toolbar.findButton("code");if(!(_this.opts.tabIndent||(codeButton&&codeButton.active))){return}return _this.indent(e.shiftKey)}})(this))};Indentation.prototype.indent=function(isBackward){var $blockNodes,$endNodes,$startNodes,nodes,result;$startNodes=this.editor.selection.startNodes();$endNodes=this.editor.selection.endNodes();$blockNodes=this.editor.selection.blockNodes();nodes=[];$blockNodes=$blockNodes.each(function(i,node){var include,j,k,len,n;include=true;for(j=k=0,len=nodes.length;k<len;j=++k){n=nodes[j];if($.contains(node,n)){include=false;break}else{if($.contains(n,node)){nodes.splice(j,1,node);include=false;break}}}if(include){return nodes.push(node)}});$blockNodes=$(nodes);result=false;$blockNodes.each((function(_this){return function(i,blockEl){var r;r=isBackward?_this.outdentBlock(blockEl):_this.indentBlock(blockEl);if(r){return result=r}}})(this));return result};Indentation.prototype.indentBlock=function(blockEl){var $blockEl,$childList,$nextTd,$nextTr,$parentLi,$pre,$td,$tr,marginLeft,tagName;$blockEl=$(blockEl);if(!$blockEl.length){return}if($blockEl.is("pre")){$pre=this.editor.selection.containerNode();if(!($pre.is($blockEl)||$pre.closest("pre").is($blockEl))){return}this.indentText(this.editor.selection.range())}else{if($blockEl.is("li")){$parentLi=$blockEl.prev("li");if($parentLi.length<1){return}this.editor.selection.save();tagName=$blockEl.parent()[0].tagName;$childList=$parentLi.children("ul, ol");if($childList.length>0){$childList.append($blockEl)}else{$("<"+tagName+"/>").append($blockEl).appendTo($parentLi)}this.editor.selection.restore()}else{if($blockEl.is("p, h1, h2, h3, h4")){marginLeft=parseInt($blockEl.css("margin-left"))||0;marginLeft=(Math.round(marginLeft/this.opts.indentWidth)+1)*this.opts.indentWidth;$blockEl.css("margin-left",marginLeft)}else{if($blockEl.is("table")||$blockEl.is(".simditor-table")){$td=this.editor.selection.containerNode().closest("td, th");$nextTd=$td.next("td, th");if(!($nextTd.length>0)){$tr=$td.parent("tr");$nextTr=$tr.next("tr");if($nextTr.length<1&&$tr.parent().is("thead")){$nextTr=$tr.parent("thead").next("tbody").find("tr:first")}$nextTd=$nextTr.find("td:first, th:first")}if(!($td.length>0&&$nextTd.length>0)){return}this.editor.selection.setRangeAtEndOf($nextTd)}else{return false}}}}return true};Indentation.prototype.indentText=function(range){var text,textNode;text=range.toString().replace(/^(?=.+)/mg,"\u00A0\u00A0");textNode=document.createTextNode(text||"\u00A0\u00A0");range.deleteContents();range.insertNode(textNode);if(text){range.selectNode(textNode); |
|
16 |
+return this.editor.selection.range(range)}else{return this.editor.selection.setRangeAfter(textNode)}};Indentation.prototype.outdentBlock=function(blockEl){var $blockEl,$parent,$parentLi,$pre,$prevTd,$prevTr,$td,$tr,marginLeft,range;$blockEl=$(blockEl);if(!($blockEl&&$blockEl.length>0)){return}if($blockEl.is("pre")){$pre=this.editor.selection.containerNode();if(!($pre.is($blockEl)||$pre.closest("pre").is($blockEl))){return}this.outdentText(range)}else{if($blockEl.is("li")){$parent=$blockEl.parent();$parentLi=$parent.parent("li");this.editor.selection.save();if($parentLi.length<1){range=document.createRange();range.setStartBefore($parent[0]);range.setEndBefore($blockEl[0]);$parent.before(range.extractContents());$("<p/>").insertBefore($parent).after($blockEl.children("ul, ol")).append($blockEl.contents());$blockEl.remove()}else{if($blockEl.next("li").length>0){$("<"+$parent[0].tagName+"/>").append($blockEl.nextAll("li")).appendTo($blockEl)}$blockEl.insertAfter($parentLi);if($parent.children("li").length<1){$parent.remove()}}this.editor.selection.restore()}else{if($blockEl.is("p, h1, h2, h3, h4")){marginLeft=parseInt($blockEl.css("margin-left"))||0;marginLeft=Math.max(Math.round(marginLeft/this.opts.indentWidth)-1,0)*this.opts.indentWidth;$blockEl.css("margin-left",marginLeft===0?"":marginLeft)}else{if($blockEl.is("table")||$blockEl.is(".simditor-table")){$td=this.editor.selection.containerNode().closest("td, th");$prevTd=$td.prev("td, th");if(!($prevTd.length>0)){$tr=$td.parent("tr");$prevTr=$tr.prev("tr");if($prevTr.length<1&&$tr.parent().is("tbody")){$prevTr=$tr.parent("tbody").prev("thead").find("tr:first")}$prevTd=$prevTr.find("td:last, th:last")}if(!($td.length>0&&$prevTd.length>0)){return}this.editor.selection.setRangeAtEndOf($prevTd)}else{return false}}}}return true};Indentation.prototype.outdentText=function(range){};return Indentation})(SimpleModule);Clipboard=(function(superClass){extend(Clipboard,superClass);function Clipboard(){return Clipboard.__super__.constructor.apply(this,arguments)}Clipboard.pluginName="Clipboard";Clipboard.prototype.opts={pasteImage:false,cleanPaste:false};Clipboard.prototype._init=function(){this.editor=this._module;if(this.opts.pasteImage&&typeof this.opts.pasteImage!=="string"){this.opts.pasteImage="inline"}return this.editor.body.on("paste",(function(_this){return function(e){var range;if(_this.pasting||_this._pasteBin){return}if(_this.editor.triggerHandler(e)===false){return false}range=_this.editor.selection.deleteRangeContents();if(_this.editor.body.html()){if(!range.collapsed){range.collapse(true)}}else{_this.editor.formatter.format();_this.editor.selection.setRangeAtStartOf(_this.editor.body.find("p:first"))}if(_this._processPasteByClipboardApi(e)){return false}_this.editor.inputManager.throttledValueChanged.clear();_this.editor.inputManager.throttledSelectionChanged.clear();_this.editor.undoManager.throttledPushState.clear();_this.editor.selection.reset();_this.editor.undoManager.resetCaretPosition();_this.pasting=true;return _this._getPasteContent(function(pasteContent){_this._processPasteContent(pasteContent);_this._pasteInBlockEl=null;_this._pastePlainText=null;return _this.pasting=false})}})(this))};Clipboard.prototype._processPasteByClipboardApi=function(e){var imageFile,pasteItem,ref,uploadOpt;if(this.editor.util.browser.edge){return}if(e.originalEvent.clipboardData&&e.originalEvent.clipboardData.items&&e.originalEvent.clipboardData.items.length>0){pasteItem=e.originalEvent.clipboardData.items[0];if(/^image\//.test(pasteItem.type)){imageFile=pasteItem.getAsFile();if(!((imageFile!=null)&&this.opts.pasteImage)){return}if(!imageFile.name){imageFile.name="Clipboard Image.png"}if(this.editor.triggerHandler("pasting",[imageFile])===false){return}uploadOpt={};uploadOpt[this.opts.pasteImage]=true;if((ref=this.editor.uploader)!=null){ref.upload(imageFile,uploadOpt)}return true}}};Clipboard.prototype._getPasteContent=function(callback){var state;this._pasteBin=$('<div contenteditable="true" />').addClass("simditor-paste-bin").attr("tabIndex","-1").appendTo(this.editor.el);state={html:this.editor.body.html(),caret:this.editor.undoManager.caretPosition()};this._pasteBin.focus();return setTimeout((function(_this){return function(){var pasteContent;_this.editor.hidePopover();_this.editor.body.get(0).innerHTML=state.html;_this.editor.undoManager.caretPosition(state.caret);_this.editor.body.focus();_this.editor.selection.reset();_this.editor.selection.range();_this._pasteInBlockEl=_this.editor.selection.blockNodes().last();_this._pastePlainText=_this.opts.cleanPaste||_this._pasteInBlockEl.is("pre, table");if(_this._pastePlainText){pasteContent=_this.editor.formatter.clearHtml(_this._pasteBin.html(),true)}else{pasteContent=$("<div/>").append(_this._pasteBin.contents());pasteContent.find("table colgroup").remove();_this.editor.formatter.format(pasteContent);_this.editor.formatter.decorate(pasteContent);_this.editor.formatter.beautify(pasteContent.children());pasteContent=pasteContent.contents() |
|
17 |
+}_this._pasteBin.remove();_this._pasteBin=null;return callback(pasteContent)}})(this),0)};Clipboard.prototype._processPasteContent=function(pasteContent){var $blockEl,$img,blob,children,insertPosition,k,l,lastLine,len,len1,len2,len3,len4,line,lines,m,node,o,q,ref,ref1,ref2,uploadOpt;if(this.editor.triggerHandler("pasting",[pasteContent])===false){return}$blockEl=this._pasteInBlockEl;if(!pasteContent){return}else{if(this._pastePlainText){if($blockEl.is("table")){lines=pasteContent.split("\n");lastLine=lines.pop();for(k=0,len=lines.length;k<len;k++){line=lines[k];this.editor.selection.insertNode(document.createTextNode(line));this.editor.selection.insertNode($("<br/>"))}this.editor.selection.insertNode(document.createTextNode(lastLine))}else{pasteContent=$("<div/>").text(pasteContent);ref=pasteContent.contents();for(l=0,len1=ref.length;l<len1;l++){node=ref[l];this.editor.selection.insertNode($(node)[0])}}}else{if($blockEl.is(this.editor.body)){for(m=0,len2=pasteContent.length;m<len2;m++){node=pasteContent[m];this.editor.selection.insertNode(node)}}else{if(pasteContent.length<1){return}else{if(pasteContent.length===1){if(pasteContent.is("p")){children=pasteContent.contents();if(children.length===1&&children.is("img")){$img=children;if(/^data:image/.test($img.attr("src"))){if(!this.opts.pasteImage){return}blob=this.editor.util.dataURLtoBlob($img.attr("src"));blob.name="Clipboard Image.png";uploadOpt={};uploadOpt[this.opts.pasteImage]=true;if((ref1=this.editor.uploader)!=null){ref1.upload(blob,uploadOpt)}return}else{if($img.is('img[src^="webkit-fake-url://"]')){return}}}for(o=0,len3=children.length;o<len3;o++){node=children[o];this.editor.selection.insertNode(node)}}else{if($blockEl.is("p")&&this.editor.util.isEmptyNode($blockEl)){$blockEl.replaceWith(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}else{if(pasteContent.is("ul, ol")){if(pasteContent.find("li").length===1){pasteContent=$("<div/>").text(pasteContent.text());ref2=pasteContent.contents();for(q=0,len4=ref2.length;q<len4;q++){node=ref2[q];this.editor.selection.insertNode($(node)[0])}}else{if($blockEl.is("li")){$blockEl.parent().after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}else{$blockEl.after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}}}else{$blockEl.after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}}}}else{if($blockEl.is("li")){$blockEl=$blockEl.parent()}if(this.editor.selection.rangeAtStartOf($blockEl)){insertPosition="before"}else{if(this.editor.selection.rangeAtEndOf($blockEl)){insertPosition="after"}else{this.editor.selection.breakBlockEl($blockEl);insertPosition="before"}}$blockEl[insertPosition](pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent.last())}}}}}return this.editor.inputManager.throttledValueChanged()};return Clipboard})(SimpleModule);Simditor=(function(superClass){extend(Simditor,superClass);function Simditor(){return Simditor.__super__.constructor.apply(this,arguments)}Simditor.connect(Util);Simditor.connect(InputManager);Simditor.connect(Selection);Simditor.connect(UndoManager);Simditor.connect(Keystroke);Simditor.connect(Formatter);Simditor.connect(Toolbar);Simditor.connect(Indentation);Simditor.connect(Clipboard);Simditor.count=0;Simditor.prototype.opts={textarea:null,placeholder:"",defaultImage:"images/image.png",params:{},upload:false,indentWidth:40};Simditor.prototype._init=function(){var e,editor,form,uploadOpts;this.textarea=$(this.opts.textarea);this.opts.placeholder=this.opts.placeholder||this.textarea.attr("placeholder");if(!this.textarea.length){throw new Error("simditor: param textarea is required.");return}editor=this.textarea.data("simditor");if(editor!=null){editor.destroy()}this.id=++Simditor.count;this._render();if(simpleHotkeys){this.hotkeys=simpleHotkeys({el:this.body})}else{throw new Error("simditor: simple-hotkeys is required.");return}if(this.opts.upload&&simpleUploader){uploadOpts=typeof this.opts.upload==="object"?this.opts.upload:{};this.uploader=simpleUploader(uploadOpts)}form=this.textarea.closest("form");if(form.length){form.on("submit.simditor-"+this.id,(function(_this){return function(){return _this.sync()}})(this));form.on("reset.simditor-"+this.id,(function(_this){return function(){return _this.setValue("")}})(this))}this.on("initialized",(function(_this){return function(){if(_this.opts.placeholder){_this.on("valuechanged",function(){return _this._placeholder()})}_this.setValue(_this.textarea.val().trim()||"");if(_this.textarea.attr("autofocus")){return _this.focus()}}})(this));if(this.util.browser.mozilla){this.util.reflow();try{document.execCommand("enableObjectResizing",false,false);return document.execCommand("enableInlineTableEditing",false,false)}catch(_error){e=_error}}};Simditor.prototype._tpl='<div class="simditor">\n <div class="simditor-wrapper">\n <div class="simditor-placeholder"></div>\n <div class="simditor-body" contenteditable="true">\n </div>\n </div>\n</div>';Simditor.prototype._render=function(){var key,ref,results,val; |
|
18 |
+this.el=$(this._tpl).insertBefore(this.textarea);this.wrapper=this.el.find(".simditor-wrapper");this.body=this.wrapper.find(".simditor-body");this.placeholderEl=this.wrapper.find(".simditor-placeholder").append(this.opts.placeholder);this.el.data("simditor",this);this.wrapper.append(this.textarea);this.textarea.data("simditor",this).blur();this.body.attr("tabindex",this.textarea.attr("tabindex"));if(this.util.os.mac){this.el.addClass("simditor-mac")}else{if(this.util.os.linux){this.el.addClass("simditor-linux")}}if(this.util.os.mobile){this.el.addClass("simditor-mobile")}if(this.opts.params){ref=this.opts.params;results=[];for(key in ref){val=ref[key];results.push($("<input/>",{type:"hidden",name:key,value:val}).insertAfter(this.textarea))}return results}};Simditor.prototype._placeholder=function(){var children;children=this.body.children();if(children.length===0||(children.length===1&&this.util.isEmptyNode(children)&&parseInt(children.css("margin-left")||0)<this.opts.indentWidth)){return this.placeholderEl.show()}else{return this.placeholderEl.hide()}};Simditor.prototype.setValue=function(val){this.hidePopover();this.textarea.val(val);this.body.get(0).innerHTML=val;this.formatter.format();this.formatter.decorate();this.util.reflow(this.body);this.inputManager.lastCaretPosition=null;return this.trigger("valuechanged")};Simditor.prototype.getValue=function(){return this.sync()};Simditor.prototype.sync=function(){var children,cloneBody,emptyP,firstP,lastP,val;cloneBody=this.body.clone();this.formatter.undecorate(cloneBody);this.formatter.format(cloneBody);this.formatter.autolink(cloneBody);children=cloneBody.children();lastP=children.last("p");firstP=children.first("p");while(lastP.is("p")&&this.util.isEmptyNode(lastP)){emptyP=lastP;lastP=lastP.prev("p");emptyP.remove()}while(firstP.is("p")&&this.util.isEmptyNode(firstP)){emptyP=firstP;firstP=lastP.next("p");emptyP.remove()}cloneBody.find("img.uploading").remove();val=$.trim(cloneBody.html());this.textarea.val(val);return val};Simditor.prototype.focus=function(){var $blockEl,range;if(!(this.body.is(":visible")&&this.body.is("[contenteditable]"))){this.el.find("textarea:visible").focus();return}if(this.inputManager.lastCaretPosition){this.undoManager.caretPosition(this.inputManager.lastCaretPosition);return this.inputManager.lastCaretPosition=null}else{$blockEl=this.body.children().last();if(!$blockEl.is("p")){$blockEl=$("<p/>").append(this.util.phBr).appendTo(this.body)}range=document.createRange();return this.selection.setRangeAtEndOf($blockEl,range)}};Simditor.prototype.blur=function(){if(this.body.is(":visible")&&this.body.is("[contenteditable]")){return this.body.blur()}else{return this.body.find("textarea:visible").blur()}};Simditor.prototype.hidePopover=function(){return this.el.find(".simditor-popover").each(function(i,popover){popover=$(popover).data("popover");if(popover.active){return popover.hide()}})};Simditor.prototype.destroy=function(){this.triggerHandler("destroy");this.textarea.closest("form").off(".simditor .simditor-"+this.id);this.selection.clear();this.inputManager.focused=false;this.textarea.insertBefore(this.el).hide().val("").removeData("simditor");this.el.remove();$(document).off(".simditor-"+this.id);$(window).off(".simditor-"+this.id);return this.off()};return Simditor})(SimpleModule);Simditor.i18n={"zh-CN":{"blockquote":"引用","bold":"加粗文字","code":"插入代码","color":"文字颜色","coloredText":"彩色文字","hr":"分隔线","image":"插入图片","externalImage":"外链图片","uploadImage":"上传图片","uploadFailed":"上传失败了","uploadError":"上传出错了","imageUrl":"图片地址","imageSize":"图片尺寸","imageAlt":"图片描述","restoreImageSize":"还原图片尺寸","uploading":"正在上传","indent":"向右缩进","outdent":"向左缩进","italic":"斜体文字","link":"插入链接","linkText":"链接文字","linkUrl":"链接地址","linkTarget":"打开方式","openLinkInCurrentWindow":"在新窗口中打开","openLinkInNewWindow":"在当前窗口中打开","removeLink":"移除链接","ol":"有序列表","ul":"无序列表","strikethrough":"删除线文字","table":"表格","deleteRow":"删除行","insertRowAbove":"在上面插入行","insertRowBelow":"在下面插入行","deleteColumn":"删除列","insertColumnLeft":"在左边插入列","insertColumnRight":"在右边插入列","deleteTable":"删除表格","title":"标题","normalText":"普通文本","underline":"下划线文字","alignment":"水平对齐","alignCenter":"居中","alignLeft":"居左","alignRight":"居右","selectLanguage":"选择程序语言","fontScale":"字体大小","fontScaleXLarge":"超大字体","fontScaleLarge":"大号字体","fontScaleNormal":"正常大小","fontScaleSmall":"小号字体","fontScaleXSmall":"超小字体"},"en-US":{"blockquote":"Block Quote","bold":"Bold","code":"Code","color":"Text Color","coloredText":"Colored Text","hr":"Horizontal Line","image":"Insert Image","externalImage":"External Image","uploadImage":"Upload Image","uploadFailed":"Upload failed","uploadError":"Error occurs during upload","imageUrl":"Url","imageSize":"Size","imageAlt":"Alt","restoreImageSize":"Restore Origin Size","uploading":"Uploading","indent":"Indent","outdent":"Outdent","italic":"Italic","link":"Insert Link","linkText":"Text","linkUrl":"Url","linkTarget":"Target","openLinkInCurrentWindow":"Open link in current window","openLinkInNewWindow":"Open link in new window","removeLink":"Remove Link","ol":"Ordered List","ul":"Unordered List","strikethrough":"Strikethrough","table":"Table","deleteRow":"Delete Row","insertRowAbove":"Insert Row Above","insertRowBelow":"Insert Row Below","deleteColumn":"Delete Column","insertColumnLeft":"Insert Column Left","insertColumnRight":"Insert Column Right","deleteTable":"Delete Table","title":"Title","normalText":"Text","underline":"Underline","alignment":"Alignment","alignCenter":"Align Center","alignLeft":"Align Left","alignRight":"Align Right","selectLanguage":"Select Language","fontScale":"Font Size","fontScaleXLarge":"X Large Size","fontScaleLarge":"Large Size","fontScaleNormal":"Normal Size","fontScaleSmall":"Small Size","fontScaleXSmall":"X Small Size"}}; |
|
19 |
+Button=(function(superClass){extend(Button,superClass);Button.prototype._tpl={item:'<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',menuWrapper:'<div class="toolbar-menu"></div>',menuItem:'<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',separator:'<li><span class="separator"></span></li>'};Button.prototype.name="";Button.prototype.icon="";Button.prototype.title="";Button.prototype.text="";Button.prototype.htmlTag="";Button.prototype.disableTag="";Button.prototype.menu=false;Button.prototype.active=false;Button.prototype.disabled=false;Button.prototype.needFocus=true;Button.prototype.shortcut=null;function Button(opts){this.editor=opts.editor;this.title=this._t(this.name);Button.__super__.constructor.call(this,opts)}Button.prototype._init=function(){var k,len,ref,tag;this.render();this.el.on("mousedown",(function(_this){return function(e){var exceed,noFocus,param;e.preventDefault();noFocus=_this.needFocus&&!_this.editor.inputManager.focused;if(_this.el.hasClass("disabled")||noFocus){return false}if(_this.menu){_this.wrapper.toggleClass("menu-on").siblings("li").removeClass("menu-on");if(_this.wrapper.is(".menu-on")){exceed=_this.menuWrapper.offset().left+_this.menuWrapper.outerWidth()+5-_this.editor.wrapper.offset().left-_this.editor.wrapper.outerWidth();if(exceed>0){_this.menuWrapper.css({"left":"auto","right":0})}_this.trigger("menuexpand")}return false}param=_this.el.data("param");_this.command(param);return false}})(this));this.wrapper.on("click","a.menu-item",(function(_this){return function(e){var btn,noFocus,param;e.preventDefault();btn=$(e.currentTarget);_this.wrapper.removeClass("menu-on");noFocus=_this.needFocus&&!_this.editor.inputManager.focused;if(btn.hasClass("disabled")||noFocus){return false}_this.editor.toolbar.wrapper.removeClass("menu-on");param=btn.data("param");_this.command(param);return false}})(this));this.wrapper.on("mousedown","a.menu-item",function(e){return false});this.editor.on("blur",(function(_this){return function(){var editorActive;editorActive=_this.editor.body.is(":visible")&&_this.editor.body.is("[contenteditable]");if(!(editorActive&&!_this.editor.clipboard.pasting)){return}_this.setActive(false);return _this.setDisabled(false)}})(this));if(this.shortcut!=null){this.editor.hotkeys.add(this.shortcut,(function(_this){return function(e){_this.el.mousedown();return false}})(this))}ref=this.htmlTag.split(",");for(k=0,len=ref.length;k<len;k++){tag=ref[k];tag=$.trim(tag);if(tag&&$.inArray(tag,this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push(tag)}}return this.editor.on("selectionchanged",(function(_this){return function(e){if(_this.editor.inputManager.focused){return _this._status()}}})(this))};Button.prototype.iconClassOf=function(icon){if(icon){return"simditor-icon simditor-icon-"+icon}else{return""}};Button.prototype.setIcon=function(icon){return this.el.find("span").removeClass().addClass(this.iconClassOf(icon)).text(this.text)};Button.prototype.render=function(){this.wrapper=$(this._tpl.item).appendTo(this.editor.toolbar.list);this.el=this.wrapper.find("a.toolbar-item");this.el.attr("title",this.title).addClass("toolbar-item-"+this.name).data("button",this);this.setIcon(this.icon);if(!this.menu){return}this.menuWrapper=$(this._tpl.menuWrapper).appendTo(this.wrapper);this.menuWrapper.addClass("toolbar-menu-"+this.name);return this.renderMenu()};Button.prototype.renderMenu=function(){var $menuBtnEl,$menuItemEl,k,len,menuItem,ref,ref1,results;if(!$.isArray(this.menu)){return}this.menuEl=$("<ul/>").appendTo(this.menuWrapper);ref=this.menu;results=[];for(k=0,len=ref.length;k<len;k++){menuItem=ref[k];if(menuItem==="|"){$(this._tpl.separator).appendTo(this.menuEl);continue}$menuItemEl=$(this._tpl.menuItem).appendTo(this.menuEl);$menuBtnEl=$menuItemEl.find("a.menu-item").attr({"title":(ref1=menuItem.title)!=null?ref1:menuItem.text,"data-param":menuItem.param}).addClass("menu-item-"+menuItem.name);if(menuItem.icon){results.push($menuBtnEl.find("span").addClass(this.iconClassOf(menuItem.icon)))}else{results.push($menuBtnEl.find("span").text(menuItem.text))}}return results};Button.prototype.setActive=function(active){if(active===this.active){return}this.active=active;return this.el.toggleClass("active",this.active)};Button.prototype.setDisabled=function(disabled){if(disabled===this.disabled){return}this.disabled=disabled;return this.el.toggleClass("disabled",this.disabled)};Button.prototype._disableStatus=function(){var disabled,endNodes,startNodes;startNodes=this.editor.selection.startNodes();endNodes=this.editor.selection.endNodes();disabled=startNodes.filter(this.disableTag).length>0||endNodes.filter(this.disableTag).length>0;this.setDisabled(disabled);if(this.disabled){this.setActive(false)}return this.disabled};Button.prototype._activeStatus=function(){var active,endNode,endNodes,startNode,startNodes;startNodes=this.editor.selection.startNodes(); |
|
20 |
+endNodes=this.editor.selection.endNodes();startNode=startNodes.filter(this.htmlTag);endNode=endNodes.filter(this.htmlTag);active=startNode.length>0&&endNode.length>0&&startNode.is(endNode);this.node=active?startNode:null;this.setActive(active);return this.active};Button.prototype._status=function(){this._disableStatus();if(this.disabled){return}return this._activeStatus()};Button.prototype.command=function(param){};Button.prototype._t=function(){var args,ref,result;args=1<=arguments.length?slice.call(arguments,0):[];result=Button.__super__._t.apply(this,args);if(!result){result=(ref=this.editor)._t.apply(ref,args)}return result};return Button})(SimpleModule);Simditor.Button=Button;Popover=(function(superClass){extend(Popover,superClass);Popover.prototype.offset={top:4,left:0};Popover.prototype.target=null;Popover.prototype.active=false;function Popover(opts){this.button=opts.button;this.editor=opts.button.editor;Popover.__super__.constructor.call(this,opts)}Popover.prototype._init=function(){this.el=$('<div class="simditor-popover"></div>').appendTo(this.editor.el).data("popover",this);this.render();this.el.on("mouseenter",(function(_this){return function(e){return _this.el.addClass("hover")}})(this));return this.el.on("mouseleave",(function(_this){return function(e){return _this.el.removeClass("hover")}})(this))};Popover.prototype.render=function(){};Popover.prototype._initLabelWidth=function(){var $fields;$fields=this.el.find(".settings-field");if(!($fields.length>0)){return}this._labelWidth=0;$fields.each((function(_this){return function(i,field){var $field,$label;$field=$(field);$label=$field.find("label");if(!($label.length>0)){return}return _this._labelWidth=Math.max(_this._labelWidth,$label.width())}})(this));return $fields.find("label").width(this._labelWidth)};Popover.prototype.show=function($target,position){if(position==null){position="bottom"}if($target==null){return}this.el.siblings(".simditor-popover").each(function(i,popover){popover=$(popover).data("popover");if(popover.active){return popover.hide()}});if(this.active&&this.target){this.target.removeClass("selected")}this.target=$target.addClass("selected");if(this.active){this.refresh(position);return this.trigger("popovershow")}else{this.active=true;this.el.css({left:-9999}).show();if(!this._labelWidth){this._initLabelWidth()}this.editor.util.reflow();this.refresh(position);return this.trigger("popovershow")}};Popover.prototype.hide=function(){if(!this.active){return}if(this.target){this.target.removeClass("selected")}this.target=null;this.active=false;this.el.hide();return this.trigger("popoverhide")};Popover.prototype.refresh=function(position){var editorOffset,left,maxLeft,targetH,targetOffset,top;if(position==null){position="bottom"}if(!this.active){return}editorOffset=this.editor.el.offset();targetOffset=this.target.offset();targetH=this.target.outerHeight();if(position==="bottom"){top=targetOffset.top-editorOffset.top+targetH}else{if(position==="top"){top=targetOffset.top-editorOffset.top-this.el.height()}}maxLeft=this.editor.wrapper.width()-this.el.outerWidth()-10;left=Math.min(targetOffset.left-editorOffset.left,maxLeft);return this.el.css({top:top+this.offset.top,left:left+this.offset.left})};Popover.prototype.destroy=function(){this.target=null;this.active=false;this.editor.off(".linkpopover");return this.el.remove()};Popover.prototype._t=function(){var args,ref,result;args=1<=arguments.length?slice.call(arguments,0):[];result=Popover.__super__._t.apply(this,args);if(!result){result=(ref=this.button)._t.apply(ref,args)}return result};return Popover})(SimpleModule);Simditor.Popover=Popover;TitleButton=(function(superClass){extend(TitleButton,superClass);function TitleButton(){return TitleButton.__super__.constructor.apply(this,arguments)}TitleButton.prototype.name="title";TitleButton.prototype.htmlTag="h1, h2, h3, h4, h5";TitleButton.prototype.disableTag="pre, table";TitleButton.prototype._init=function(){this.menu=[{name:"normal",text:this._t("normalText"),param:"p"},"|",{name:"h1",text:this._t("title")+" 1",param:"h1"},{name:"h2",text:this._t("title")+" 2",param:"h2"},{name:"h3",text:this._t("title")+" 3",param:"h3"},{name:"h4",text:this._t("title")+" 4",param:"h4"},{name:"h5",text:this._t("title")+" 5",param:"h5"}];return TitleButton.__super__._init.call(this)};TitleButton.prototype.setActive=function(active,param){TitleButton.__super__.setActive.call(this,active);if(active){param||(param=this.node[0].tagName.toLowerCase())}this.el.removeClass("active-p active-h1 active-h2 active-h3 active-h4 active-h5");if(active){return this.el.addClass("active active-"+param)}};TitleButton.prototype.command=function(param){var $rootNodes;$rootNodes=this.editor.selection.rootNodes();this.editor.selection.save();$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote")||$node.is(param)||$node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)){return}return $("<"+param+"/>").append($node.contents()).replaceAll($node) |
|
21 |
+}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};return TitleButton})(Button);Simditor.Toolbar.addButton(TitleButton);FontScaleButton=(function(superClass){extend(FontScaleButton,superClass);function FontScaleButton(){return FontScaleButton.__super__.constructor.apply(this,arguments)}FontScaleButton.prototype.name="fontScale";FontScaleButton.prototype.icon="font";FontScaleButton.prototype.disableTag="pre";FontScaleButton.prototype.htmlTag="span";FontScaleButton.prototype.sizeMap={"x-large":"1.5em","large":"1.25em","small":".75em","x-small":".5em"};FontScaleButton.prototype._init=function(){this.menu=[{name:"150%",text:this._t("fontScaleXLarge"),param:"5"},{name:"125%",text:this._t("fontScaleLarge"),param:"4"},{name:"100%",text:this._t("fontScaleNormal"),param:"3"},{name:"75%",text:this._t("fontScaleSmall"),param:"2"},{name:"50%",text:this._t("fontScaleXSmall"),param:"1"}];return FontScaleButton.__super__._init.call(this)};FontScaleButton.prototype._activeStatus=function(){var active,endNode,endNodes,range,startNode,startNodes;range=this.editor.selection.range();startNodes=this.editor.selection.startNodes();endNodes=this.editor.selection.endNodes();startNode=startNodes.filter('span[style*="font-size"]');endNode=endNodes.filter('span[style*="font-size"]');active=startNodes.length>0&&endNodes.length>0&&startNode.is(endNode);this.setActive(active);return this.active};FontScaleButton.prototype.command=function(param){var $scales,containerNode,range;range=this.editor.selection.range();if(range.collapsed){return}document.execCommand("styleWithCSS",false,true);document.execCommand("fontSize",false,param);document.execCommand("styleWithCSS",false,false);this.editor.selection.reset();this.editor.selection.range();containerNode=this.editor.selection.containerNode();if(containerNode[0].nodeType===Node.TEXT_NODE){$scales=containerNode.closest('span[style*="font-size"]')}else{$scales=containerNode.find('span[style*="font-size"]')}$scales.each((function(_this){return function(i,n){var $span,size;$span=$(n);size=n.style.fontSize;if(/large|x-large|small|x-small/.test(size)){return $span.css("fontSize",_this.sizeMap[size])}else{if(size==="medium"){return $span.replaceWith($span.contents())}}}})(this));return this.editor.trigger("valuechanged")};return FontScaleButton})(Button);Simditor.Toolbar.addButton(FontScaleButton);BoldButton=(function(superClass){extend(BoldButton,superClass);function BoldButton(){return BoldButton.__super__.constructor.apply(this,arguments)}BoldButton.prototype.name="bold";BoldButton.prototype.icon="bold";BoldButton.prototype.htmlTag="b, strong";BoldButton.prototype.disableTag="pre";BoldButton.prototype.shortcut="cmd+b";BoldButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + b )"}else{this.title=this.title+" ( Ctrl + b )";this.shortcut="ctrl+b"}return BoldButton.__super__._init.call(this)};BoldButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("bold")===true;this.setActive(active);return this.active};BoldButton.prototype.command=function(){document.execCommand("bold");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return BoldButton})(Button);Simditor.Toolbar.addButton(BoldButton);ItalicButton=(function(superClass){extend(ItalicButton,superClass);function ItalicButton(){return ItalicButton.__super__.constructor.apply(this,arguments)}ItalicButton.prototype.name="italic";ItalicButton.prototype.icon="italic";ItalicButton.prototype.htmlTag="i";ItalicButton.prototype.disableTag="pre";ItalicButton.prototype.shortcut="cmd+i";ItalicButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + i )"}else{this.title=this.title+" ( Ctrl + i )";this.shortcut="ctrl+i"}return ItalicButton.__super__._init.call(this)};ItalicButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("italic")===true;this.setActive(active);return this.active};ItalicButton.prototype.command=function(){document.execCommand("italic");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return ItalicButton})(Button);Simditor.Toolbar.addButton(ItalicButton);UnderlineButton=(function(superClass){extend(UnderlineButton,superClass);function UnderlineButton(){return UnderlineButton.__super__.constructor.apply(this,arguments)}UnderlineButton.prototype.name="underline";UnderlineButton.prototype.icon="underline";UnderlineButton.prototype.htmlTag="u";UnderlineButton.prototype.disableTag="pre";UnderlineButton.prototype.shortcut="cmd+u";UnderlineButton.prototype.render=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + u )"}else{this.title=this.title+" ( Ctrl + u )";this.shortcut="ctrl+u"}return UnderlineButton.__super__.render.call(this)};UnderlineButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("underline")===true; |
|
22 |
+this.setActive(active);return this.active};UnderlineButton.prototype.command=function(){document.execCommand("underline");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return UnderlineButton})(Button);Simditor.Toolbar.addButton(UnderlineButton);ColorButton=(function(superClass){extend(ColorButton,superClass);function ColorButton(){return ColorButton.__super__.constructor.apply(this,arguments)}ColorButton.prototype.name="color";ColorButton.prototype.icon="tint";ColorButton.prototype.disableTag="pre";ColorButton.prototype.menu=true;ColorButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return ColorButton.__super__.render.apply(this,args)};ColorButton.prototype.renderMenu=function(){$('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper);this.menuWrapper.on("mousedown",".color-list",function(e){return false});return this.menuWrapper.on("click",".font-color",(function(_this){return function(e){var $link,$p,hex,range,rgb,textNode;_this.wrapper.removeClass("menu-on");$link=$(e.currentTarget);if($link.hasClass("font-color-default")){$p=_this.editor.body.find("p, li");if(!($p.length>0)){return}rgb=window.getComputedStyle($p[0],null).getPropertyValue("color");hex=_this._convertRgbToHex(rgb)}else{rgb=window.getComputedStyle($link[0],null).getPropertyValue("background-color");hex=_this._convertRgbToHex(rgb)}if(!hex){return}range=_this.editor.selection.range();if(!$link.hasClass("font-color-default")&&range.collapsed){textNode=document.createTextNode(_this._t("coloredText"));range.insertNode(textNode);range.selectNodeContents(textNode);_this.editor.selection.range(range)}document.execCommand("styleWithCSS",false,true);document.execCommand("foreColor",false,hex);document.execCommand("styleWithCSS",false,false);if(!_this.editor.util.support.oninput){return _this.editor.trigger("valuechanged")}}})(this))};ColorButton.prototype._convertRgbToHex=function(rgb){var match,re,rgbToHex;re=/rgb\((\d+),\s?(\d+),\s?(\d+)\)/g;match=re.exec(rgb);if(!match){return""}rgbToHex=function(r,g,b){var componentToHex;componentToHex=function(c){var hex;hex=c.toString(16);if(hex.length===1){return"0"+hex}else{return hex}};return"#"+componentToHex(r)+componentToHex(g)+componentToHex(b)};return rgbToHex(match[1]*1,match[2]*1,match[3]*1)};return ColorButton})(Button);Simditor.Toolbar.addButton(ColorButton);ListButton=(function(superClass){extend(ListButton,superClass);function ListButton(){return ListButton.__super__.constructor.apply(this,arguments)}ListButton.prototype.type="";ListButton.prototype.disableTag="pre, table";ListButton.prototype.command=function(param){var $list,$rootNodes,anotherType;$rootNodes=this.editor.selection.blockNodes();anotherType=this.type==="ul"?"ol":"ul";this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)||!$.contains(document,node)){return}if($node.is(_this.type)){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is(anotherType)){return $("<"+_this.type+"/>").append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$("<"+_this.type+"><li></li></"+_this.type+">");$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};return ListButton})(Button);OrderListButton=(function(superClass){extend(OrderListButton,superClass);function OrderListButton(){return OrderListButton.__super__.constructor.apply(this,arguments)}OrderListButton.prototype.type="ol";OrderListButton.prototype.name="ol";OrderListButton.prototype.icon="list-ol";OrderListButton.prototype.htmlTag="ol";OrderListButton.prototype.shortcut="cmd+/";OrderListButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + / )"}else{this.title=this.title+" ( ctrl + / )";this.shortcut="ctrl+/"}return OrderListButton.__super__._init.call(this) |
|
23 |
+};return OrderListButton})(ListButton);UnorderListButton=(function(superClass){extend(UnorderListButton,superClass);function UnorderListButton(){return UnorderListButton.__super__.constructor.apply(this,arguments)}UnorderListButton.prototype.type="ul";UnorderListButton.prototype.name="ul";UnorderListButton.prototype.icon="list-ul";UnorderListButton.prototype.htmlTag="ul";UnorderListButton.prototype.shortcut="cmd+.";UnorderListButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + . )"}else{this.title=this.title+" ( Ctrl + . )";this.shortcut="ctrl+."}return UnorderListButton.__super__._init.call(this)};return UnorderListButton})(ListButton);Simditor.Toolbar.addButton(OrderListButton);Simditor.Toolbar.addButton(UnorderListButton);BlockquoteButton=(function(superClass){extend(BlockquoteButton,superClass);function BlockquoteButton(){return BlockquoteButton.__super__.constructor.apply(this,arguments)}BlockquoteButton.prototype.name="blockquote";BlockquoteButton.prototype.icon="quote-left";BlockquoteButton.prototype.htmlTag="blockquote";BlockquoteButton.prototype.disableTag="pre, table";BlockquoteButton.prototype.command=function(){var $rootNodes,clearCache,nodeCache;$rootNodes=this.editor.selection.rootNodes();$rootNodes=$rootNodes.filter(function(i,node){return !$(node).parent().is("blockquote")});this.editor.selection.save();nodeCache=[];clearCache=(function(_this){return function(){if(nodeCache.length>0){$("<"+_this.htmlTag+"/>").insertBefore(nodeCache[0]).append(nodeCache);return nodeCache.length=0}}})(this);$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if(!$node.parent().is(_this.editor.body)){return}if($node.is(_this.htmlTag)){clearCache();return $node.children().unwrap()}else{if($node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)){return clearCache()}else{return nodeCache.push(node)}}}})(this));clearCache();this.editor.selection.restore();return this.editor.trigger("valuechanged")};return BlockquoteButton})(Button);Simditor.Toolbar.addButton(BlockquoteButton);CodeButton=(function(superClass){extend(CodeButton,superClass);function CodeButton(){return CodeButton.__super__.constructor.apply(this,arguments)}CodeButton.prototype.name="code";CodeButton.prototype.icon="code";CodeButton.prototype.htmlTag="pre";CodeButton.prototype.disableTag="ul, ol, table";CodeButton.prototype._init=function(){CodeButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("pre").each(function(i,pre){return _this.decorate($(pre))})}})(this));return this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find("pre").each(function(i,pre){return _this.undecorate($(pre))})}})(this))};CodeButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];CodeButton.__super__.render.apply(this,args);return this.popover=new CodePopover({button:this})};CodeButton.prototype._checkMode=function(){var $blockNodes,range;range=this.editor.selection.range();if(($blockNodes=$(range.cloneContents()).find(this.editor.util.blockNodes.join(",")))>0||(range.collapsed&&this.editor.selection.startNodes().filter("code").length===0)){this.inlineMode=false;return this.htmlTag="pre"}else{this.inlineMode=true;return this.htmlTag="code"}};CodeButton.prototype._status=function(){this._checkMode();CodeButton.__super__._status.call(this);if(this.inlineMode){return}if(this.active){return this.popover.show(this.node)}else{return this.popover.hide()}};CodeButton.prototype.decorate=function($pre){var $code,lang,ref,ref1;$code=$pre.find("> code");if($code.length>0){lang=(ref=$code.attr("class"))!=null?(ref1=ref.match(/lang-(\S+)/))!=null?ref1[1]:void 0:void 0;$code.contents().unwrap();if(lang){return $pre.attr("data-lang",lang)}}};CodeButton.prototype.undecorate=function($pre){var $code,lang;lang=$pre.attr("data-lang");$code=$("<code/>");if(lang&&lang!==-1){$code.addClass("lang-"+lang)}return $pre.wrapInner($code).removeAttr("data-lang")};CodeButton.prototype.command=function(){if(this.inlineMode){return this._inlineCommand()}else{return this._blockCommand()}};CodeButton.prototype._blockCommand=function(){var $rootNodes,clearCache,nodeCache,resultNodes;$rootNodes=this.editor.selection.rootNodes();nodeCache=[];resultNodes=[];clearCache=(function(_this){return function(){var $pre;if(!(nodeCache.length>0)){return}$pre=$("<"+_this.htmlTag+"/>").insertBefore(nodeCache[0]).text(_this.editor.formatter.clearHtml(nodeCache));resultNodes.push($pre[0]);return nodeCache.length=0}})(this);$rootNodes.each((function(_this){return function(i,node){var $node,$p;$node=$(node);if($node.is(_this.htmlTag)){clearCache();$p=$("<p/>").append($node.html().replace("\n","<br/>")).replaceAll($node);return resultNodes.push($p[0])}else{if($node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)||$node.is("blockquote")){return clearCache()}else{return nodeCache.push(node)}}}})(this));clearCache(); |
|
24 |
+this.editor.selection.setRangeAtEndOf($(resultNodes).last());return this.editor.trigger("valuechanged")};CodeButton.prototype._inlineCommand=function(){var $code,$contents,range;range=this.editor.selection.range();if(this.active){range.selectNodeContents(this.node[0]);this.editor.selection.save(range);this.node.contents().unwrap();this.editor.selection.restore()}else{$contents=$(range.extractContents());$code=$("<"+this.htmlTag+"/>").append($contents.contents());range.insertNode($code[0]);range.selectNodeContents($code[0]);this.editor.selection.range(range)}return this.editor.trigger("valuechanged")};return CodeButton})(Button);CodePopover=(function(superClass){extend(CodePopover,superClass);function CodePopover(){return CodePopover.__super__.constructor.apply(this,arguments)}CodePopover.prototype.render=function(){var $option,k,lang,len,ref;this._tpl='<div class="code-settings">\n <div class="settings-field">\n <select class="select-lang">\n <option value="-1">'+(this._t("selectLanguage"))+"</option>\n </select>\n </div>\n</div>";this.langs=this.editor.opts.codeLanguages||[{name:"Bash",value:"bash"},{name:"C++",value:"c++"},{name:"C#",value:"cs"},{name:"CSS",value:"css"},{name:"Erlang",value:"erlang"},{name:"Less",value:"less"},{name:"Sass",value:"sass"},{name:"Diff",value:"diff"},{name:"CoffeeScript",value:"coffeescript"},{name:"HTML,XML",value:"html"},{name:"JSON",value:"json"},{name:"Java",value:"java"},{name:"JavaScript",value:"js"},{name:"Markdown",value:"markdown"},{name:"Objective C",value:"oc"},{name:"PHP",value:"php"},{name:"Perl",value:"parl"},{name:"Python",value:"python"},{name:"Ruby",value:"ruby"},{name:"SQL",value:"sql"}];this.el.addClass("code-popover").append(this._tpl);this.selectEl=this.el.find(".select-lang");ref=this.langs;for(k=0,len=ref.length;k<len;k++){lang=ref[k];$option=$("<option/>",{text:lang.name,value:lang.value}).appendTo(this.selectEl)}this.selectEl.on("change",(function(_this){return function(e){var selected;_this.lang=_this.selectEl.val();selected=_this.target.hasClass("selected");_this.target.removeClass().removeAttr("data-lang");if(_this.lang!==-1){_this.target.attr("data-lang",_this.lang)}if(selected){_this.target.addClass("selected")}return _this.editor.trigger("valuechanged")}})(this));return this.editor.on("valuechanged",(function(_this){return function(e){if(_this.active){return _this.refresh()}}})(this))};CodePopover.prototype.show=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];CodePopover.__super__.show.apply(this,args);this.lang=this.target.attr("data-lang");if(this.lang!=null){return this.selectEl.val(this.lang)}else{return this.selectEl.val(-1)}};return CodePopover})(Popover);Simditor.Toolbar.addButton(CodeButton);LinkButton=(function(superClass){extend(LinkButton,superClass);function LinkButton(){return LinkButton.__super__.constructor.apply(this,arguments)}LinkButton.prototype.name="link";LinkButton.prototype.icon="link";LinkButton.prototype.htmlTag="a";LinkButton.prototype.disableTag="pre";LinkButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];LinkButton.__super__.render.apply(this,args);return this.popover=new LinkPopover({button:this})};LinkButton.prototype._status=function(){LinkButton.__super__._status.call(this);if(this.active&&!this.editor.selection.rangeAtEndOf(this.node)){return this.popover.show(this.node)}else{return this.popover.hide()}};LinkButton.prototype.command=function(){var $contents,$link,$newBlock,linkText,range,txtNode;range=this.editor.selection.range();if(this.active){txtNode=document.createTextNode(this.node.text());this.node.replaceWith(txtNode);range.selectNode(txtNode)}else{$contents=$(range.extractContents());linkText=this.editor.formatter.clearHtml($contents.contents(),false);$link=$("<a/>",{href:"http://www.example.com",target:"_blank",text:linkText||this._t("linkText")});if(this.editor.selection.blockNodes().length>0){range.insertNode($link[0])}else{$newBlock=$("<p/>").append($link);range.insertNode($newBlock[0])}range.selectNodeContents($link[0]);this.popover.one("popovershow",(function(_this){return function(){if(linkText){_this.popover.urlEl.focus();return _this.popover.urlEl[0].select()}else{_this.popover.textEl.focus();return _this.popover.textEl[0].select()}}})(this))}this.editor.selection.range(range);return this.editor.trigger("valuechanged")};return LinkButton})(Button);LinkPopover=(function(superClass){extend(LinkPopover,superClass);function LinkPopover(){return LinkPopover.__super__.constructor.apply(this,arguments)}LinkPopover.prototype.render=function(){var tpl;tpl='<div class="link-settings">\n <div class="settings-field">\n <label>'+(this._t("linkText"))+'</label>\n <input class="link-text" type="text"/>\n <a class="btn-unlink" href="javascript:;" title="'+(this._t("removeLink"))+'"\n tabindex="-1">\n <span class="simditor-icon simditor-icon-unlink"></span>\n </a>\n </div>\n <div class="settings-field">\n <label>'+(this._t("linkUrl"))+'</label>\n <input class="link-url" type="text"/>\n </div>\n <div class="settings-field">\n <label>'+(this._t("linkTarget"))+'</label>\n <select class="link-target">\n <option value="_blank">'+(this._t("openLinkInNewWindow"))+' (_blank)</option>\n <option value="_self">'+(this._t("openLinkInCurrentWindow"))+" (_self)</option>\n </select>\n </div>\n</div>"; |
|
25 |
+this.el.addClass("link-popover").append(tpl);this.textEl=this.el.find(".link-text");this.urlEl=this.el.find(".link-url");this.unlinkEl=this.el.find(".btn-unlink");this.selectTarget=this.el.find(".link-target");this.textEl.on("keyup",(function(_this){return function(e){if(e.which===13){return}_this.target.text(_this.textEl.val());return _this.editor.inputManager.throttledValueChanged()}})(this));this.urlEl.on("keyup",(function(_this){return function(e){var val;if(e.which===13){return}val=_this.urlEl.val();if(!(/https?:\/\/|^\//ig.test(val)||!val)){val="http://"+val}_this.target.attr("href",val);return _this.editor.inputManager.throttledValueChanged()}})(this));$([this.urlEl[0],this.textEl[0]]).on("keydown",(function(_this){return function(e){var range;if(e.which===13||e.which===27||(!e.shiftKey&&e.which===9&&$(e.target).hasClass("link-url"))){e.preventDefault();range=document.createRange();_this.editor.selection.setRangeAfter(_this.target,range);_this.hide();return _this.editor.inputManager.throttledValueChanged()}}})(this));this.unlinkEl.on("click",(function(_this){return function(e){var range,txtNode;txtNode=document.createTextNode(_this.target.text());_this.target.replaceWith(txtNode);_this.hide();range=document.createRange();_this.editor.selection.setRangeAfter(txtNode,range);return _this.editor.inputManager.throttledValueChanged()}})(this));return this.selectTarget.on("change",(function(_this){return function(e){_this.target.attr("target",_this.selectTarget.val());return _this.editor.inputManager.throttledValueChanged()}})(this))};LinkPopover.prototype.show=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];LinkPopover.__super__.show.apply(this,args);this.textEl.val(this.target.text());return this.urlEl.val(this.target.attr("href"))};return LinkPopover})(Popover);Simditor.Toolbar.addButton(LinkButton);ImageButton=(function(superClass){extend(ImageButton,superClass);function ImageButton(){return ImageButton.__super__.constructor.apply(this,arguments)}ImageButton.prototype.name="image";ImageButton.prototype.icon="picture-o";ImageButton.prototype.htmlTag="img";ImageButton.prototype.disableTag="pre, table";ImageButton.prototype.defaultImage="";ImageButton.prototype.needFocus=false;ImageButton.prototype._init=function(){var item,k,len,ref;if(this.editor.opts.imageButton){if(Array.isArray(this.editor.opts.imageButton)){this.menu=[];ref=this.editor.opts.imageButton;for(k=0,len=ref.length;k<len;k++){item=ref[k];this.menu.push({name:item+"-image",text:this._t(item+"Image")})}}else{this.menu=false}}else{if(this.editor.uploader!=null){this.menu=[{name:"upload-image",text:this._t("uploadImage")},{name:"external-image",text:this._t("externalImage")}]}else{this.menu=false}}this.defaultImage=this.editor.opts.defaultImage;this.editor.body.on("click","img:not([data-non-image])",(function(_this){return function(e){var $img,range;$img=$(e.currentTarget);range=document.createRange();range.selectNode($img[0]);_this.editor.selection.range(range);if(!_this.editor.util.support.onselectionchange){_this.editor.trigger("selectionchanged")}return false}})(this));this.editor.body.on("mouseup","img:not([data-non-image])",function(e){return false});this.editor.on("selectionchanged.image",(function(_this){return function(){var $contents,$img,range;range=_this.editor.selection.range();if(range==null){return}$contents=$(range.cloneContents()).contents();if($contents.length===1&&$contents.is("img:not([data-non-image])")){$img=$(range.startContainer).contents().eq(range.startOffset);return _this.popover.show($img)}else{return _this.popover.hide()}}})(this));this.editor.on("valuechanged.image",(function(_this){return function(){var $masks;$masks=_this.editor.wrapper.find(".simditor-image-loading");if(!($masks.length>0)){return}return $masks.each(function(i,mask){var $img,$mask,file;$mask=$(mask);$img=$mask.data("img");if(!($img&&$img.parent().length>0)){$mask.remove();if($img){file=$img.data("file");if(file){_this.editor.uploader.cancel(file);if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file])}}}}})}})(this));return ImageButton.__super__._init.call(this)};ImageButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ImageButton.__super__.render.apply(this,args);this.popover=new ImagePopover({button:this});if(this.editor.opts.imageButton==="upload"){return this._initUploader(this.el)}};ImageButton.prototype.renderMenu=function(){ImageButton.__super__.renderMenu.call(this);return this._initUploader()};ImageButton.prototype._initUploader=function($uploadItem){var $input,createInput,uploadProgress;if($uploadItem==null){$uploadItem=this.menuEl.find(".menu-item-upload-image")}if(this.editor.uploader==null){this.el.find(".btn-upload").remove();return}$input=null;createInput=(function(_this){return function(){if($input){$input.remove()}return $input=$("<input/>",{type:"file",title:_this._t("uploadImage"),multiple:true,accept:"image/*"}).appendTo($uploadItem) |
|
26 |
+}})(this);createInput();$uploadItem.on("click mousedown","input[type=file]",function(e){return e.stopPropagation()});$uploadItem.on("change","input[type=file]",(function(_this){return function(e){if(_this.editor.inputManager.focused){_this.editor.uploader.upload($input,{inline:true});createInput()}else{_this.editor.one("focus",function(e){_this.editor.uploader.upload($input,{inline:true});return createInput()});_this.editor.focus()}return _this.wrapper.removeClass("menu-on")}})(this));this.editor.uploader.on("beforeupload",(function(_this){return function(e,file){var $img;if(!file.inline){return}if(file.img){$img=$(file.img)}else{$img=_this.createImage(file.name);file.img=$img}$img.addClass("uploading");$img.data("file",file);return _this.editor.uploader.readImageFile(file.obj,function(img){var src;if(!$img.hasClass("uploading")){return}src=img?img.src:_this.defaultImage;return _this.loadImage($img,src,function(){if(_this.popover.active){_this.popover.refresh();return _this.popover.srcEl.val(_this._t("uploading")).prop("disabled",true)}})})}})(this));uploadProgress=$.proxy(this.editor.util.throttle(function(e,file,loaded,total){var $img,$mask,percent;if(!file.inline){return}$mask=file.img.data("mask");if(!$mask){return}$img=$mask.data("img");if(!($img.hasClass("uploading")&&$img.parent().length>0)){$mask.remove();return}percent=loaded/total;percent=(percent*100).toFixed(0);if(percent>99){percent=99}return $mask.find(".progress").height((100-percent)+"%")},500),this);this.editor.uploader.on("uploadprogress",uploadProgress);this.editor.uploader.on("uploadsuccess",(function(_this){return function(e,file,result){var $img,img_path,msg;if(!file.inline){return}$img=file.img;if(!($img.hasClass("uploading")&&$img.parent().length>0)){return}if(typeof result!=="object"){try{result=$.parseJSON(result)}catch(_error){e=_error;result={success:false}}}if(result.success===false){msg=result.msg||_this._t("uploadFailed");alert(msg);img_path=_this.defaultImage}else{img_path=result.file_path}_this.loadImage($img,img_path,function(){var $mask;$img.removeData("file");$img.removeClass("uploading").removeClass("loading");$mask=$img.data("mask");if($mask){$mask.remove()}$img.removeData("mask");_this.editor.trigger("valuechanged");if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file,result])}});if(_this.popover.active){_this.popover.srcEl.prop("disabled",false);return _this.popover.srcEl.val(result.file_path)}}})(this));return this.editor.uploader.on("uploaderror",(function(_this){return function(e,file,xhr){var $img,msg,result;if(!file.inline){return}if(xhr.statusText==="abort"){return}if(xhr.responseText){try{result=$.parseJSON(xhr.responseText);msg=result.msg}catch(_error){e=_error;msg=_this._t("uploadError")}alert(msg)}$img=file.img;if(!($img.hasClass("uploading")&&$img.parent().length>0)){return}_this.loadImage($img,_this.defaultImage,function(){var $mask;$img.removeData("file");$img.removeClass("uploading").removeClass("loading");$mask=$img.data("mask");if($mask){$mask.remove()}return $img.removeData("mask")});if(_this.popover.active){_this.popover.srcEl.prop("disabled",false);_this.popover.srcEl.val(_this.defaultImage)}_this.editor.trigger("valuechanged");if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file,result])}}})(this))};ImageButton.prototype._status=function(){return this._disableStatus()};ImageButton.prototype.loadImage=function($img,src,callback){var $mask,img,positionMask;positionMask=(function(_this){return function(){var imgOffset,wrapperOffset;imgOffset=$img.offset();wrapperOffset=_this.editor.wrapper.offset();return $mask.css({top:imgOffset.top-wrapperOffset.top,left:imgOffset.left-wrapperOffset.left,width:$img.width(),height:$img.height()}).show()}})(this);$img.addClass("loading");$mask=$img.data("mask");if(!$mask){$mask=$('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper);positionMask();$img.data("mask",$mask);$mask.data("img",$img)}img=new Image();img.onload=(function(_this){return function(){var height,width;if(!$img.hasClass("loading")&&!$img.hasClass("uploading")){return}width=img.width;height=img.height;$img.attr({src:src,width:width,height:height,"data-image-size":width+","+height}).removeClass("loading");if($img.hasClass("uploading")){_this.editor.util.reflow(_this.editor.body);positionMask()}else{$mask.remove();$img.removeData("mask")}if($.isFunction(callback)){return callback(img)}}})(this);img.onerror=function(){if($.isFunction(callback)){callback(false)}$mask.remove();return $img.removeData("mask").removeClass("loading")};return img.src=src};ImageButton.prototype.createImage=function(name){var $img,range;if(name==null){name="Image"}if(!this.editor.inputManager.focused){this.editor.focus()}range=this.editor.selection.range();range.deleteContents();this.editor.selection.range(range);$img=$("<img/>").attr("alt",name);range.insertNode($img[0]); |
|
27 |
+this.editor.selection.setRangeAfter($img,range);this.editor.trigger("valuechanged");return $img};ImageButton.prototype.command=function(src){var $img;$img=this.createImage();return this.loadImage($img,src||this.defaultImage,(function(_this){return function(){_this.editor.trigger("valuechanged");_this.editor.util.reflow($img);$img.click();return _this.popover.one("popovershow",function(){_this.popover.srcEl.focus();return _this.popover.srcEl[0].select()})}})(this))};return ImageButton})(Button);ImagePopover=(function(superClass){extend(ImagePopover,superClass);function ImagePopover(){return ImagePopover.__super__.constructor.apply(this,arguments)}ImagePopover.prototype.offset={top:6,left:-4};ImagePopover.prototype.render=function(){var tpl;tpl='<div class="link-settings">\n <div class="settings-field">\n <label>'+(this._t("imageUrl"))+'</label>\n <input class="image-src" type="text" tabindex="1" />\n <a class="btn-upload" href="javascript:;"\n title="'+(this._t("uploadImage"))+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-upload"></span>\n </a>\n </div>\n <div class=\'settings-field\'>\n <label>'+(this._t("imageAlt"))+'</label>\n <input class="image-alt" id="image-alt" type="text" tabindex="1" />\n </div>\n <div class="settings-field">\n <label>'+(this._t("imageSize"))+'</label>\n <input class="image-size" id="image-width" type="text" tabindex="2" />\n <span class="times">×</span>\n <input class="image-size" id="image-height" type="text" tabindex="3" />\n <a class="btn-restore" href="javascript:;"\n title="'+(this._t("restoreImageSize"))+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-undo"></span>\n </a>\n </div>\n</div>';this.el.addClass("image-popover").append(tpl);this.srcEl=this.el.find(".image-src");this.widthEl=this.el.find("#image-width");this.heightEl=this.el.find("#image-height");this.altEl=this.el.find("#image-alt");this.srcEl.on("keydown",(function(_this){return function(e){var range;if(!(e.which===13&&!_this.target.hasClass("uploading"))){return}e.preventDefault();range=document.createRange();_this.button.editor.selection.setRangeAfter(_this.target,range);return _this.hide()}})(this));this.srcEl.on("blur",(function(_this){return function(e){return _this._loadImage(_this.srcEl.val())}})(this));this.el.find(".image-size").on("blur",(function(_this){return function(e){_this._resizeImg($(e.currentTarget));return _this.el.data("popover").refresh()}})(this));this.el.find(".image-size").on("keyup",(function(_this){return function(e){var inputEl;inputEl=$(e.currentTarget);if(!(e.which===13||e.which===27||e.which===9)){return _this._resizeImg(inputEl,true)}}})(this));this.el.find(".image-size").on("keydown",(function(_this){return function(e){var $img,inputEl,range;inputEl=$(e.currentTarget);if(e.which===13||e.which===27){e.preventDefault();if(e.which===13){_this._resizeImg(inputEl)}else{_this._restoreImg()}$img=_this.target;_this.hide();range=document.createRange();return _this.button.editor.selection.setRangeAfter($img,range)}else{if(e.which===9){return _this.el.data("popover").refresh()}}}})(this));this.altEl.on("keydown",(function(_this){return function(e){var range;if(e.which===13){e.preventDefault();range=document.createRange();_this.button.editor.selection.setRangeAfter(_this.target,range);return _this.hide()}}})(this));this.altEl.on("keyup",(function(_this){return function(e){if(e.which===13||e.which===27||e.which===9){return}_this.alt=_this.altEl.val();return _this.target.attr("alt",_this.alt)}})(this));this.el.find(".btn-restore").on("click",(function(_this){return function(e){_this._restoreImg();return _this.el.data("popover").refresh()}})(this));this.editor.on("valuechanged",(function(_this){return function(e){if(_this.active){return _this.refresh()}}})(this));return this._initUploader()};ImagePopover.prototype._initUploader=function(){var $uploadBtn,createInput;$uploadBtn=this.el.find(".btn-upload");if(this.editor.uploader==null){$uploadBtn.remove();return}createInput=(function(_this){return function(){if(_this.input){_this.input.remove()}return _this.input=$("<input/>",{type:"file",title:_this._t("uploadImage"),multiple:true,accept:"image/*"}).appendTo($uploadBtn)}})(this);createInput();this.el.on("click mousedown","input[type=file]",function(e){return e.stopPropagation()});return this.el.on("change","input[type=file]",(function(_this){return function(e){_this.editor.uploader.upload(_this.input,{inline:true,img:_this.target});return createInput()}})(this))};ImagePopover.prototype._resizeImg=function(inputEl,onlySetVal){var height,value,width;if(onlySetVal==null){onlySetVal=false}value=inputEl.val()*1;if(!(this.target&&($.isNumeric(value)||value<0))){return}if(inputEl.is(this.widthEl)){width=value;height=this.height*value/this.width;this.heightEl.val(height)}else{height=value;width=this.width*value/this.height;this.widthEl.val(width)}if(!onlySetVal){this.target.attr({width:width,height:height});return this.editor.trigger("valuechanged") |
|
28 |
+}};ImagePopover.prototype._restoreImg=function(){var ref,size;size=((ref=this.target.data("image-size"))!=null?ref.split(","):void 0)||[this.width,this.height];this.target.attr({width:size[0]*1,height:size[1]*1});this.widthEl.val(size[0]);this.heightEl.val(size[1]);return this.editor.trigger("valuechanged")};ImagePopover.prototype._loadImage=function(src,callback){if(/^data:image/.test(src)&&!this.editor.uploader){if(callback){callback(false)}return}if(this.target.attr("src")===src){return}return this.button.loadImage(this.target,src,(function(_this){return function(img){var blob;if(!img){return}if(_this.active){_this.width=img.width;_this.height=img.height;_this.widthEl.val(_this.width);_this.heightEl.val(_this.height)}if(/^data:image/.test(src)){blob=_this.editor.util.dataURLtoBlob(src);blob.name="Base64 Image.png";_this.editor.uploader.upload(blob,{inline:true,img:_this.target})}else{_this.editor.trigger("valuechanged")}if(callback){return callback(img)}}})(this))};ImagePopover.prototype.show=function(){var $img,args;args=1<=arguments.length?slice.call(arguments,0):[];ImagePopover.__super__.show.apply(this,args);$img=this.target;this.width=$img.width();this.height=$img.height();this.alt=$img.attr("alt");if($img.hasClass("uploading")){return this.srcEl.val(this._t("uploading")).prop("disabled",true)}else{this.srcEl.val($img.attr("src")).prop("disabled",false);this.widthEl.val(this.width);this.heightEl.val(this.height);return this.altEl.val(this.alt)}};return ImagePopover})(Popover);Simditor.Toolbar.addButton(ImageButton);IndentButton=(function(superClass){extend(IndentButton,superClass);function IndentButton(){return IndentButton.__super__.constructor.apply(this,arguments)}IndentButton.prototype.name="indent";IndentButton.prototype.icon="indent";IndentButton.prototype._init=function(){this.title=this._t(this.name)+" (Tab)";return IndentButton.__super__._init.call(this)};IndentButton.prototype._status=function(){};IndentButton.prototype.command=function(){return this.editor.indentation.indent()};return IndentButton})(Button);Simditor.Toolbar.addButton(IndentButton);OutdentButton=(function(superClass){extend(OutdentButton,superClass);function OutdentButton(){return OutdentButton.__super__.constructor.apply(this,arguments)}OutdentButton.prototype.name="outdent";OutdentButton.prototype.icon="outdent";OutdentButton.prototype._init=function(){this.title=this._t(this.name)+" (Shift + Tab)";return OutdentButton.__super__._init.call(this)};OutdentButton.prototype._status=function(){};OutdentButton.prototype.command=function(){return this.editor.indentation.indent(true)};return OutdentButton})(Button);Simditor.Toolbar.addButton(OutdentButton);HrButton=(function(superClass){extend(HrButton,superClass);function HrButton(){return HrButton.__super__.constructor.apply(this,arguments)}HrButton.prototype.name="hr";HrButton.prototype.icon="minus";HrButton.prototype.htmlTag="hr";HrButton.prototype._status=function(){};HrButton.prototype.command=function(){var $hr,$newBlock,$nextBlock,$rootBlock;$rootBlock=this.editor.selection.rootNodes().first();$nextBlock=$rootBlock.next();if($nextBlock.length>0){this.editor.selection.save()}else{$newBlock=$("<p/>").append(this.editor.util.phBr)}$hr=$("<hr/>").insertAfter($rootBlock);if($newBlock){$newBlock.insertAfter($hr);this.editor.selection.setRangeAtStartOf($newBlock)}else{this.editor.selection.restore()}return this.editor.trigger("valuechanged")};return HrButton})(Button);Simditor.Toolbar.addButton(HrButton);TableButton=(function(superClass){extend(TableButton,superClass);function TableButton(){return TableButton.__super__.constructor.apply(this,arguments)}TableButton.prototype.name="table";TableButton.prototype.icon="table";TableButton.prototype.htmlTag="table";TableButton.prototype.disableTag="pre, li, blockquote";TableButton.prototype.menu=true;TableButton.prototype._init=function(){TableButton.__super__._init.call(this);$.merge(this.editor.formatter._allowedTags,["thead","th","tbody","tr","td","colgroup","col"]);$.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]});$.extend(this.editor.formatter._allowedStyles,{td:["text-align"],th:["text-align"]});this._initShortcuts();this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("table").each(function(i,table){return _this.decorate($(table))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find("table").each(function(i,table){return _this.undecorate($(table))})}})(this));this.editor.on("selectionchanged.table",(function(_this){return function(e){var $container,range;_this.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active");range=_this.editor.selection.range();if(!range){return}$container=_this.editor.selection.containerNode();if(range.collapsed&&$container.is(".simditor-table")){if(_this.editor.selection.rangeAtStartOf($container)){$container=$container.find("th:first")}else{$container=$container.find("td:last") |
|
29 |
+}_this.editor.selection.setRangeAtEndOf($container)}return $container.closest("td, th",_this.editor.body).addClass("active")}})(this));this.editor.on("blur.table",(function(_this){return function(e){return _this.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active")}})(this));this.editor.keystroke.add("up","td",(function(_this){return function(e,$node){_this._tdNav($node,"up");return true}})(this));this.editor.keystroke.add("up","th",(function(_this){return function(e,$node){_this._tdNav($node,"up");return true}})(this));this.editor.keystroke.add("down","td",(function(_this){return function(e,$node){_this._tdNav($node,"down");return true}})(this));return this.editor.keystroke.add("down","th",(function(_this){return function(e,$node){_this._tdNav($node,"down");return true}})(this))};TableButton.prototype._tdNav=function($td,direction){var $anotherTr,$tr,action,anotherTag,index,parentTag,ref;if(direction==null){direction="up"}action=direction==="up"?"prev":"next";ref=direction==="up"?["tbody","thead"]:["thead","tbody"],parentTag=ref[0],anotherTag=ref[1];$tr=$td.parent("tr");$anotherTr=this["_"+action+"Row"]($tr);if(!($anotherTr.length>0)){return true}index=$tr.find("td, th").index($td);return this.editor.selection.setRangeAtEndOf($anotherTr.find("td, th").eq(index))};TableButton.prototype._nextRow=function($tr){var $nextTr;$nextTr=$tr.next("tr");if($nextTr.length<1&&$tr.parent("thead").length>0){$nextTr=$tr.parent("thead").next("tbody").find("tr:first")}return $nextTr};TableButton.prototype._prevRow=function($tr){var $prevTr;$prevTr=$tr.prev("tr");if($prevTr.length<1&&$tr.parent("tbody").length>0){$prevTr=$tr.parent("tbody").prev("thead").find("tr")}return $prevTr};TableButton.prototype.initResize=function($table){var $colgroup,$resizeHandle,$wrapper;$wrapper=$table.parent(".simditor-table");$colgroup=$table.find("colgroup");if($colgroup.length<1){$colgroup=$("<colgroup/>").prependTo($table);$table.find("thead tr th").each(function(i,td){var $col;return $col=$("<col/>").appendTo($colgroup)});this.refreshTableWidth($table)}$resizeHandle=$("<div />",{"class":"simditor-resize-handle",contenteditable:"false"}).appendTo($wrapper);$wrapper.on("mousemove","td, th",function(e){var $col,$td,index,ref,ref1,x;if($wrapper.hasClass("resizing")){return}$td=$(e.currentTarget);x=e.pageX-$(e.currentTarget).offset().left;if(x<5&&$td.prev().length>0){$td=$td.prev()}if($td.next("td, th").length<1){$resizeHandle.hide();return}if((ref=$resizeHandle.data("td"))!=null?ref.is($td):void 0){$resizeHandle.show();return}index=$td.parent().find("td, th").index($td);$col=$colgroup.find("col").eq(index);if((ref1=$resizeHandle.data("col"))!=null?ref1.is($col):void 0){$resizeHandle.show();return}return $resizeHandle.css("left",$td.position().left+$td.outerWidth()-5).data("td",$td).data("col",$col).show()});$wrapper.on("mouseleave",function(e){return $resizeHandle.hide()});return $wrapper.on("mousedown",".simditor-resize-handle",function(e){var $handle,$leftCol,$leftTd,$rightCol,$rightTd,minWidth,startHandleLeft,startLeftWidth,startRightWidth,startX,tableWidth;$handle=$(e.currentTarget);$leftTd=$handle.data("td");$leftCol=$handle.data("col");$rightTd=$leftTd.next("td, th");$rightCol=$leftCol.next("col");startX=e.pageX;startLeftWidth=$leftTd.outerWidth()*1;startRightWidth=$rightTd.outerWidth()*1;startHandleLeft=parseFloat($handle.css("left"));tableWidth=$leftTd.closest("table").width();minWidth=50;$(document).on("mousemove.simditor-resize-table",function(e){var deltaX,leftWidth,rightWidth;deltaX=e.pageX-startX;leftWidth=startLeftWidth+deltaX;rightWidth=startRightWidth-deltaX;if(leftWidth<minWidth){leftWidth=minWidth;deltaX=minWidth-startLeftWidth;rightWidth=startRightWidth-deltaX}else{if(rightWidth<minWidth){rightWidth=minWidth;deltaX=startRightWidth-minWidth;leftWidth=startLeftWidth+deltaX}}$leftCol.attr("width",(leftWidth/tableWidth*100)+"%");$rightCol.attr("width",(rightWidth/tableWidth*100)+"%");return $handle.css("left",startHandleLeft+deltaX)});$(document).one("mouseup.simditor-resize-table",function(e){$(document).off(".simditor-resize-table");return $wrapper.removeClass("resizing")});$wrapper.addClass("resizing");return false})};TableButton.prototype._initShortcuts=function(){this.editor.hotkeys.add("ctrl+alt+up",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertRowAbove]").click();return false}})(this));this.editor.hotkeys.add("ctrl+alt+down",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertRowBelow]").click();return false}})(this));this.editor.hotkeys.add("ctrl+alt+left",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertColLeft]").click();return false}})(this));return this.editor.hotkeys.add("ctrl+alt+right",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertColRight]").click();return false}})(this))};TableButton.prototype.decorate=function($table){var $headRow,$tbody,$thead; |
|
30 |
+if($table.parent(".simditor-table").length>0){this.undecorate($table)}$table.wrap('<div class="simditor-table"></div>');if($table.find("thead").length<1){$thead=$("<thead />");$headRow=$table.find("tr").first();$thead.append($headRow);this._changeCellTag($headRow,"th");$tbody=$table.find("tbody");if($tbody.length>0){$tbody.before($thead)}else{$table.prepend($thead)}}this.initResize($table);return $table.parent()};TableButton.prototype.undecorate=function($table){if(!($table.parent(".simditor-table").length>0)){return}return $table.parent().replaceWith($table)};TableButton.prototype.renderMenu=function(){var $table;$('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n <ul>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteRow">\n <span>'+(this._t("deleteRow"))+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowAbove">\n <span>'+(this._t("insertRowAbove"))+' ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowBelow">\n <span>'+(this._t("insertRowBelow"))+' ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteCol">\n <span>'+(this._t("deleteColumn"))+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColLeft">\n <span>'+(this._t("insertColumnLeft"))+' ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColRight">\n <span>'+(this._t("insertColumnRight"))+' ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteTable">\n <span>'+(this._t("deleteTable"))+"</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper);this.createMenu=this.menuWrapper.find(".menu-create-table");this.editMenu=this.menuWrapper.find(".menu-edit-table");$table=this.createTable(6,6).appendTo(this.createMenu);this.createMenu.on("mouseenter","td, th",(function(_this){return function(e){var $td,$tr,$trs,num;_this.createMenu.find("td, th").removeClass("selected");$td=$(e.currentTarget);$tr=$td.parent();num=$tr.find("td, th").index($td)+1;$trs=$tr.prevAll("tr").addBack();if($tr.parent().is("tbody")){$trs=$trs.add($table.find("thead tr"))}return $trs.find("td:lt("+num+"), th:lt("+num+")").addClass("selected")}})(this));this.createMenu.on("mouseleave",function(e){return $(e.currentTarget).find("td, th").removeClass("selected")});return this.createMenu.on("mousedown","td, th",(function(_this){return function(e){var $closestBlock,$td,$tr,colNum,rowNum;_this.wrapper.removeClass("menu-on");if(!_this.editor.inputManager.focused){return}$td=$(e.currentTarget);$tr=$td.parent();colNum=$tr.find("td").index($td)+1;rowNum=$tr.prevAll("tr").length+1;if($tr.parent().is("tbody")){rowNum+=1}$table=_this.createTable(rowNum,colNum,true);$closestBlock=_this.editor.selection.blockNodes().last();if(_this.editor.util.isEmptyNode($closestBlock)){$closestBlock.replaceWith($table)}else{$closestBlock.after($table)}_this.decorate($table);_this.editor.selection.setRangeAtStartOf($table.find("th:first"));_this.editor.trigger("valuechanged");return false}})(this))};TableButton.prototype.createTable=function(row,col,phBr){var $table,$tbody,$td,$thead,$tr,c,k,l,r,ref,ref1;$table=$("<table/>");$thead=$("<thead/>").appendTo($table);$tbody=$("<tbody/>").appendTo($table);for(r=k=0,ref=row;0<=ref?k<ref:k>ref;r=0<=ref?++k:--k){$tr=$("<tr/>");$tr.appendTo(r===0?$thead:$tbody);for(c=l=0,ref1=col;0<=ref1?l<ref1:l>ref1;c=0<=ref1?++l:--l){$td=$(r===0?"<th/>":"<td/>").appendTo($tr);if(phBr){$td.append(this.editor.util.phBr)}}}return $table};TableButton.prototype.refreshTableWidth=function($table){var cols,tableWidth;tableWidth=$table.width();cols=$table.find("col");return $table.find("thead tr th").each(function(i,td){var $col;$col=cols.eq(i);return $col.attr("width",($(td).outerWidth()/tableWidth*100)+"%")})};TableButton.prototype.setActive=function(active){TableButton.__super__.setActive.call(this,active);if(active){this.createMenu.hide();return this.editMenu.show()}else{this.createMenu.show();return this.editMenu.hide()}};TableButton.prototype._changeCellTag=function($tr,tagName){return $tr.find("td, th").each(function(i,cell){var $cell;$cell=$(cell);return $cell.replaceWith("<"+tagName+">"+($cell.html())+"</"+tagName+">")})};TableButton.prototype.deleteRow=function($td){var $newTr,$tr,index;$tr=$td.parent("tr"); |
|
31 |
+if($tr.closest("table").find("tr").length<1){return this.deleteTable($td)}else{$newTr=this._nextRow($tr);if(!($newTr.length>0)){$newTr=this._prevRow($tr)}index=$tr.find("td, th").index($td);if($tr.parent().is("thead")){$newTr.appendTo($tr.parent());this._changeCellTag($newTr,"th")}$tr.remove();return this.editor.selection.setRangeAtEndOf($newTr.find("td, th").eq(index))}};TableButton.prototype.insertRow=function($td,direction){var $newTr,$table,$tr,cellTag,colNum,i,index,k,ref;if(direction==null){direction="after"}$tr=$td.parent("tr");$table=$tr.closest("table");colNum=0;$table.find("tr").each(function(i,tr){return colNum=Math.max(colNum,$(tr).find("td").length)});index=$tr.find("td, th").index($td);$newTr=$("<tr/>");cellTag="td";if(direction==="after"&&$tr.parent().is("thead")){$tr.parent().next("tbody").prepend($newTr)}else{if(direction==="before"&&$tr.parent().is("thead")){$tr.before($newTr);$tr.parent().next("tbody").prepend($tr);this._changeCellTag($tr,"td");cellTag="th"}else{$tr[direction]($newTr)}}for(i=k=1,ref=colNum;1<=ref?k<=ref:k>=ref;i=1<=ref?++k:--k){$("<"+cellTag+"/>").append(this.editor.util.phBr).appendTo($newTr)}return this.editor.selection.setRangeAtStartOf($newTr.find("td, th").eq(index))};TableButton.prototype.deleteCol=function($td){var $newTd,$table,$tr,index,noOtherCol,noOtherRow;$tr=$td.parent("tr");noOtherRow=$tr.closest("table").find("tr").length<2;noOtherCol=$td.siblings("td, th").length<1;if(noOtherRow&&noOtherCol){return this.deleteTable($td)}else{index=$tr.find("td, th").index($td);$newTd=$td.next("td, th");if(!($newTd.length>0)){$newTd=$tr.prev("td, th")}$table=$tr.closest("table");$table.find("col").eq(index).remove();$table.find("tr").each(function(i,tr){return $(tr).find("td, th").eq(index).remove()});this.refreshTableWidth($table);return this.editor.selection.setRangeAtEndOf($newTd)}};TableButton.prototype.insertCol=function($td,direction){var $col,$newCol,$newTd,$table,$tr,index,tableWidth,width;if(direction==null){direction="after"}$tr=$td.parent("tr");index=$tr.find("td, th").index($td);$table=$td.closest("table");$col=$table.find("col").eq(index);$table.find("tr").each((function(_this){return function(i,tr){var $newTd,cellTag;cellTag=$(tr).parent().is("thead")?"th":"td";$newTd=$("<"+cellTag+"/>").append(_this.editor.util.phBr);return $(tr).find("td, th").eq(index)[direction]($newTd)}})(this));$newCol=$("<col/>");$col[direction]($newCol);tableWidth=$table.width();width=Math.max(parseFloat($col.attr("width"))/2,50/tableWidth*100);$col.attr("width",width+"%");$newCol.attr("width",width+"%");this.refreshTableWidth($table);$newTd=direction==="after"?$td.next("td, th"):$td.prev("td, th");return this.editor.selection.setRangeAtStartOf($newTd)};TableButton.prototype.deleteTable=function($td){var $block,$table;$table=$td.closest(".simditor-table");$block=$table.next("p");$table.remove();if($block.length>0){return this.editor.selection.setRangeAtStartOf($block)}};TableButton.prototype.command=function(param){var $td;$td=this.editor.selection.containerNode().closest("td, th");if(!($td.length>0)){return}if(param==="deleteRow"){this.deleteRow($td)}else{if(param==="insertRowAbove"){this.insertRow($td,"before")}else{if(param==="insertRowBelow"){this.insertRow($td)}else{if(param==="deleteCol"){this.deleteCol($td)}else{if(param==="insertColLeft"){this.insertCol($td,"before")}else{if(param==="insertColRight"){this.insertCol($td)}else{if(param==="deleteTable"){this.deleteTable($td)}else{return}}}}}}}return this.editor.trigger("valuechanged")};return TableButton})(Button);Simditor.Toolbar.addButton(TableButton);StrikethroughButton=(function(superClass){extend(StrikethroughButton,superClass);function StrikethroughButton(){return StrikethroughButton.__super__.constructor.apply(this,arguments)}StrikethroughButton.prototype.name="strikethrough";StrikethroughButton.prototype.icon="strikethrough";StrikethroughButton.prototype.htmlTag="strike";StrikethroughButton.prototype.disableTag="pre";StrikethroughButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("strikethrough")===true;this.setActive(active);return this.active};StrikethroughButton.prototype.command=function(){document.execCommand("strikethrough");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return StrikethroughButton})(Button);Simditor.Toolbar.addButton(StrikethroughButton);AlignmentButton=(function(superClass){extend(AlignmentButton,superClass);function AlignmentButton(){return AlignmentButton.__super__.constructor.apply(this,arguments)}AlignmentButton.prototype.name="alignment";AlignmentButton.prototype.icon="align-left";AlignmentButton.prototype.htmlTag="p, h1, h2, h3, h4, td, th";AlignmentButton.prototype._init=function(){this.menu=[{name:"left",text:this._t("alignLeft"),icon:"align-left",param:"left"},{name:"center",text:this._t("alignCenter"),icon:"align-center",param:"center"},{name:"right",text:this._t("alignRight"),icon:"align-right",param:"right"}]; |
|
32 |
+return AlignmentButton.__super__._init.call(this)};AlignmentButton.prototype.setActive=function(active,align){if(align==null){align="left"}if(align!=="left"&&align!=="center"&&align!=="right"){align="left"}if(align==="left"){AlignmentButton.__super__.setActive.call(this,false)}else{AlignmentButton.__super__.setActive.call(this,active)}this.el.removeClass("align-left align-center align-right");if(active){this.el.addClass("align-"+align)}this.setIcon("align-"+align);return this.menuEl.find(".menu-item").show().end().find(".menu-item-"+align).hide()};AlignmentButton.prototype._status=function(){this.nodes=this.editor.selection.nodes().filter(this.htmlTag);if(this.nodes.length<1){this.setDisabled(true);return this.setActive(false)}else{this.setDisabled(false);return this.setActive(true,this.nodes.first().css("text-align"))}};AlignmentButton.prototype.command=function(align){if(align!=="left"&&align!=="center"&&align!=="right"){throw new Error("simditor alignment button: invalid align "+align)}this.nodes.css({"text-align":align==="left"?"":align});this.editor.trigger("valuechanged");return this.editor.inputManager.throttledSelectionChanged()};return AlignmentButton})(Button);Simditor.Toolbar.addButton(AlignmentButton);return Simditor})); |
@@ -0,0 +1,789 @@ |
||
1 |
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.toMarkdown = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
|
2 |
+/* |
|
3 |
+ * to-markdown - an HTML to Markdown converter |
|
4 |
+ * |
|
5 |
+ * Copyright 2011+, Dom Christie |
|
6 |
+ * Licenced under the MIT licence |
|
7 |
+ * |
|
8 |
+ */ |
|
9 |
+ |
|
10 |
+'use strict' |
|
11 |
+ |
|
12 |
+var toMarkdown |
|
13 |
+var converters |
|
14 |
+var mdConverters = require('./lib/md-converters') |
|
15 |
+var gfmConverters = require('./lib/gfm-converters') |
|
16 |
+var HtmlParser = require('./lib/html-parser') |
|
17 |
+var collapse = require('collapse-whitespace') |
|
18 |
+ |
|
19 |
+/* |
|
20 |
+ * Utilities |
|
21 |
+ */ |
|
22 |
+ |
|
23 |
+var blocks = ['address', 'article', 'aside', 'audio', 'blockquote', 'body', |
|
24 |
+ 'canvas', 'center', 'dd', 'dir', 'div', 'dl', 'dt', 'fieldset', 'figcaption', |
|
25 |
+ 'figure', 'footer', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', |
|
26 |
+ 'header', 'hgroup', 'hr', 'html', 'isindex', 'li', 'main', 'menu', 'nav', |
|
27 |
+ 'noframes', 'noscript', 'ol', 'output', 'p', 'pre', 'section', 'table', |
|
28 |
+ 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul' |
|
29 |
+] |
|
30 |
+ |
|
31 |
+function isBlock (node) { |
|
32 |
+ return blocks.indexOf(node.nodeName.toLowerCase()) !== -1 |
|
33 |
+} |
|
34 |
+ |
|
35 |
+var voids = [ |
|
36 |
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', |
|
37 |
+ 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr' |
|
38 |
+] |
|
39 |
+ |
|
40 |
+function isVoid (node) { |
|
41 |
+ return voids.indexOf(node.nodeName.toLowerCase()) !== -1 |
|
42 |
+} |
|
43 |
+ |
|
44 |
+function htmlToDom (string) { |
|
45 |
+ var tree = new HtmlParser().parseFromString(string, 'text/html') |
|
46 |
+ collapse(tree.documentElement, isBlock) |
|
47 |
+ return tree |
|
48 |
+} |
|
49 |
+ |
|
50 |
+/* |
|
51 |
+ * Flattens DOM tree into single array |
|
52 |
+ */ |
|
53 |
+ |
|
54 |
+function bfsOrder (node) { |
|
55 |
+ var inqueue = [node] |
|
56 |
+ var outqueue = [] |
|
57 |
+ var elem |
|
58 |
+ var children |
|
59 |
+ var i |
|
60 |
+ |
|
61 |
+ while (inqueue.length > 0) { |
|
62 |
+ elem = inqueue.shift() |
|
63 |
+ outqueue.push(elem) |
|
64 |
+ children = elem.childNodes |
|
65 |
+ for (i = 0; i < children.length; i++) { |
|
66 |
+ if (children[i].nodeType === 1) inqueue.push(children[i]) |
|
67 |
+ } |
|
68 |
+ } |
|
69 |
+ outqueue.shift() |
|
70 |
+ return outqueue |
|
71 |
+} |
|
72 |
+ |
|
73 |
+/* |
|
74 |
+ * Contructs a Markdown string of replacement text for a given node |
|
75 |
+ */ |
|
76 |
+ |
|
77 |
+function getContent (node) { |
|
78 |
+ var text = '' |
|
79 |
+ for (var i = 0; i < node.childNodes.length; i++) { |
|
80 |
+ if (node.childNodes[i].nodeType === 1) { |
|
81 |
+ text += node.childNodes[i]._replacement |
|
82 |
+ } else if (node.childNodes[i].nodeType === 3) { |
|
83 |
+ text += node.childNodes[i].data |
|
84 |
+ } else continue |
|
85 |
+ } |
|
86 |
+ return text |
|
87 |
+} |
|
88 |
+ |
|
89 |
+/* |
|
90 |
+ * Returns the HTML string of an element with its contents converted |
|
91 |
+ */ |
|
92 |
+ |
|
93 |
+function outer (node, content) { |
|
94 |
+ return node.cloneNode(false).outerHTML.replace('><', '>' + content + '<') |
|
95 |
+} |
|
96 |
+ |
|
97 |
+function canConvert (node, filter) { |
|
98 |
+ if (typeof filter === 'string') { |
|
99 |
+ return filter === node.nodeName.toLowerCase() |
|
100 |
+ } |
|
101 |
+ if (Array.isArray(filter)) { |
|
102 |
+ return filter.indexOf(node.nodeName.toLowerCase()) !== -1 |
|
103 |
+ } else if (typeof filter === 'function') { |
|
104 |
+ return filter.call(toMarkdown, node) |
|
105 |
+ } else { |
|
106 |
+ throw new TypeError('`filter` needs to be a string, array, or function') |
|
107 |
+ } |
|
108 |
+} |
|
109 |
+ |
|
110 |
+function isFlankedByWhitespace (side, node) { |
|
111 |
+ var sibling |
|
112 |
+ var regExp |
|
113 |
+ var isFlanked |
|
114 |
+ |
|
115 |
+ if (side === 'left') { |
|
116 |
+ sibling = node.previousSibling |
|
117 |
+ regExp = / $/ |
|
118 |
+ } else { |
|
119 |
+ sibling = node.nextSibling |
|
120 |
+ regExp = /^ / |
|
121 |
+ } |
|
122 |
+ |
|
123 |
+ if (sibling) { |
|
124 |
+ if (sibling.nodeType === 3) { |
|
125 |
+ isFlanked = regExp.test(sibling.nodeValue) |
|
126 |
+ } else if (sibling.nodeType === 1 && !isBlock(sibling)) { |
|
127 |
+ isFlanked = regExp.test(sibling.textContent) |
|
128 |
+ } |
|
129 |
+ } |
|
130 |
+ return isFlanked |
|
131 |
+} |
|
132 |
+ |
|
133 |
+function flankingWhitespace (node, content) { |
|
134 |
+ var leading = '' |
|
135 |
+ var trailing = '' |
|
136 |
+ |
|
137 |
+ if (!isBlock(node)) { |
|
138 |
+ var hasLeading = /^[ \r\n\t]/.test(content) |
|
139 |
+ var hasTrailing = /[ \r\n\t]$/.test(content) |
|
140 |
+ |
|
141 |
+ if (hasLeading && !isFlankedByWhitespace('left', node)) { |
|
142 |
+ leading = ' ' |
|
143 |
+ } |
|
144 |
+ if (hasTrailing && !isFlankedByWhitespace('right', node)) { |
|
145 |
+ trailing = ' ' |
|
146 |
+ } |
|
147 |
+ } |
|
148 |
+ |
|
149 |
+ return { leading: leading, trailing: trailing } |
|
150 |
+} |
|
151 |
+ |
|
152 |
+/* |
|
153 |
+ * Finds a Markdown converter, gets the replacement, and sets it on |
|
154 |
+ * `_replacement` |
|
155 |
+ */ |
|
156 |
+ |
|
157 |
+function process (node) { |
|
158 |
+ var replacement |
|
159 |
+ var content = getContent(node) |
|
160 |
+ |
|
161 |
+ // Remove blank nodes |
|
162 |
+ if (!isVoid(node) && !/A|TH|TD/.test(node.nodeName) && /^\s*$/i.test(content)) { |
|
163 |
+ node._replacement = '' |
|
164 |
+ return |
|
165 |
+ } |
|
166 |
+ |
|
167 |
+ for (var i = 0; i < converters.length; i++) { |
|
168 |
+ var converter = converters[i] |
|
169 |
+ |
|
170 |
+ if (canConvert(node, converter.filter)) { |
|
171 |
+ if (typeof converter.replacement !== 'function') { |
|
172 |
+ throw new TypeError( |
|
173 |
+ '`replacement` needs to be a function that returns a string' |
|
174 |
+ ) |
|
175 |
+ } |
|
176 |
+ |
|
177 |
+ var whitespace = flankingWhitespace(node, content) |
|
178 |
+ |
|
179 |
+ if (whitespace.leading || whitespace.trailing) { |
|
180 |
+ content = content.trim() |
|
181 |
+ } |
|
182 |
+ replacement = whitespace.leading + |
|
183 |
+ converter.replacement.call(toMarkdown, content, node) + |
|
184 |
+ whitespace.trailing |
|
185 |
+ break |
|
186 |
+ } |
|
187 |
+ } |
|
188 |
+ |
|
189 |
+ node._replacement = replacement |
|
190 |
+} |
|
191 |
+ |
|
192 |
+toMarkdown = function (input, options) { |
|
193 |
+ options = options || {} |
|
194 |
+ |
|
195 |
+ if (typeof input !== 'string') { |
|
196 |
+ throw new TypeError(input + ' is not a string') |
|
197 |
+ } |
|
198 |
+ |
|
199 |
+ if (input === '') { |
|
200 |
+ return '' |
|
201 |
+ } |
|
202 |
+ |
|
203 |
+ // Escape potential ol triggers |
|
204 |
+ input = input.replace(/(\d+)\. /g, '$1\\. ') |
|
205 |
+ |
|
206 |
+ var clone = htmlToDom(input).body |
|
207 |
+ var nodes = bfsOrder(clone) |
|
208 |
+ var output |
|
209 |
+ |
|
210 |
+ converters = mdConverters.slice(0) |
|
211 |
+ if (options.gfm) { |
|
212 |
+ converters = gfmConverters.concat(converters) |
|
213 |
+ } |
|
214 |
+ |
|
215 |
+ if (options.converters) { |
|
216 |
+ converters = options.converters.concat(converters) |
|
217 |
+ } |
|
218 |
+ |
|
219 |
+ // Process through nodes in reverse (so deepest child elements are first). |
|
220 |
+ for (var i = nodes.length - 1; i >= 0; i--) { |
|
221 |
+ process(nodes[i]) |
|
222 |
+ } |
|
223 |
+ output = getContent(clone) |
|
224 |
+ |
|
225 |
+ return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g, '') |
|
226 |
+ .replace(/\n\s+\n/g, '\n\n') |
|
227 |
+ .replace(/\n{3,}/g, '\n\n') |
|
228 |
+} |
|
229 |
+ |
|
230 |
+toMarkdown.isBlock = isBlock |
|
231 |
+toMarkdown.isVoid = isVoid |
|
232 |
+toMarkdown.outer = outer |
|
233 |
+ |
|
234 |
+module.exports = toMarkdown |
|
235 |
+ |
|
236 |
+},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){ |
|
237 |
+'use strict' |
|
238 |
+ |
|
239 |
+function cell (content, node) { |
|
240 |
+ var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node) |
|
241 |
+ var prefix = ' ' |
|
242 |
+ if (index === 0) prefix = '| ' |
|
243 |
+ return prefix + content + ' |' |
|
244 |
+} |
|
245 |
+ |
|
246 |
+var highlightRegEx = /highlight highlight-(\S+)/ |
|
247 |
+ |
|
248 |
+module.exports = [ |
|
249 |
+ { |
|
250 |
+ filter: 'br', |
|
251 |
+ replacement: function () { |
|
252 |
+ return '\n' |
|
253 |
+ } |
|
254 |
+ }, |
|
255 |
+ { |
|
256 |
+ filter: ['del', 's', 'strike'], |
|
257 |
+ replacement: function (content) { |
|
258 |
+ return '~~' + content + '~~' |
|
259 |
+ } |
|
260 |
+ }, |
|
261 |
+ |
|
262 |
+ { |
|
263 |
+ filter: function (node) { |
|
264 |
+ return node.type === 'checkbox' && node.parentNode.nodeName === 'LI' |
|
265 |
+ }, |
|
266 |
+ replacement: function (content, node) { |
|
267 |
+ return (node.checked ? '[x]' : '[ ]') + ' ' |
|
268 |
+ } |
|
269 |
+ }, |
|
270 |
+ |
|
271 |
+ { |
|
272 |
+ filter: ['th', 'td'], |
|
273 |
+ replacement: function (content, node) { |
|
274 |
+ return cell(content, node) |
|
275 |
+ } |
|
276 |
+ }, |
|
277 |
+ |
|
278 |
+ { |
|
279 |
+ filter: 'tr', |
|
280 |
+ replacement: function (content, node) { |
|
281 |
+ var borderCells = '' |
|
282 |
+ var alignMap = { left: ':--', right: '--:', center: ':-:' } |
|
283 |
+ |
|
284 |
+ if (node.parentNode.nodeName === 'THEAD') { |
|
285 |
+ for (var i = 0; i < node.childNodes.length; i++) { |
|
286 |
+ var align = node.childNodes[i].attributes.align |
|
287 |
+ var border = '---' |
|
288 |
+ |
|
289 |
+ if (align) border = alignMap[align.value] || border |
|
290 |
+ |
|
291 |
+ borderCells += cell(border, node.childNodes[i]) |
|
292 |
+ } |
|
293 |
+ } |
|
294 |
+ return '\n' + content + (borderCells ? '\n' + borderCells : '') |
|
295 |
+ } |
|
296 |
+ }, |
|
297 |
+ |
|
298 |
+ { |
|
299 |
+ filter: 'table', |
|
300 |
+ replacement: function (content) { |
|
301 |
+ return '\n\n' + content + '\n\n' |
|
302 |
+ } |
|
303 |
+ }, |
|
304 |
+ |
|
305 |
+ { |
|
306 |
+ filter: ['thead', 'tbody', 'tfoot'], |
|
307 |
+ replacement: function (content) { |
|
308 |
+ return content |
|
309 |
+ } |
|
310 |
+ }, |
|
311 |
+ |
|
312 |
+ // Fenced code blocks |
|
313 |
+ { |
|
314 |
+ filter: function (node) { |
|
315 |
+ return node.nodeName === 'PRE' && |
|
316 |
+ node.firstChild && |
|
317 |
+ node.firstChild.nodeName === 'CODE' |
|
318 |
+ }, |
|
319 |
+ replacement: function (content, node) { |
|
320 |
+ return '\n\n```\n' + node.firstChild.textContent + '\n```\n\n' |
|
321 |
+ } |
|
322 |
+ }, |
|
323 |
+ |
|
324 |
+ // Syntax-highlighted code blocks |
|
325 |
+ { |
|
326 |
+ filter: function (node) { |
|
327 |
+ return node.nodeName === 'PRE' && |
|
328 |
+ node.parentNode.nodeName === 'DIV' && |
|
329 |
+ highlightRegEx.test(node.parentNode.className) |
|
330 |
+ }, |
|
331 |
+ replacement: function (content, node) { |
|
332 |
+ var language = node.parentNode.className.match(highlightRegEx)[1] |
|
333 |
+ return '\n\n```' + language + '\n' + node.textContent + '\n```\n\n' |
|
334 |
+ } |
|
335 |
+ }, |
|
336 |
+ |
|
337 |
+ { |
|
338 |
+ filter: function (node) { |
|
339 |
+ return node.nodeName === 'DIV' && |
|
340 |
+ highlightRegEx.test(node.className) |
|
341 |
+ }, |
|
342 |
+ replacement: function (content) { |
|
343 |
+ return '\n\n' + content + '\n\n' |
|
344 |
+ } |
|
345 |
+ } |
|
346 |
+] |
|
347 |
+ |
|
348 |
+},{}],3:[function(require,module,exports){ |
|
349 |
+/* |
|
350 |
+ * Set up window for Node.js |
|
351 |
+ */ |
|
352 |
+ |
|
353 |
+var _window = (typeof window !== 'undefined' ? window : this) |
|
354 |
+ |
|
355 |
+/* |
|
356 |
+ * Parsing HTML strings |
|
357 |
+ */ |
|
358 |
+ |
|
359 |
+function canParseHtmlNatively () { |
|
360 |
+ var Parser = _window.DOMParser |
|
361 |
+ var canParse = false |
|
362 |
+ |
|
363 |
+ // Adapted from https://gist.github.com/1129031 |
|
364 |
+ // Firefox/Opera/IE throw errors on unsupported types |
|
365 |
+ try { |
|
366 |
+ // WebKit returns null on unsupported types |
|
367 |
+ if (new Parser().parseFromString('', 'text/html')) { |
|
368 |
+ canParse = true |
|
369 |
+ } |
|
370 |
+ } catch (e) {} |
|
371 |
+ |
|
372 |
+ return canParse |
|
373 |
+} |
|
374 |
+ |
|
375 |
+function createHtmlParser () { |
|
376 |
+ var Parser = function () {} |
|
377 |
+ |
|
378 |
+ // For Node.js environments |
|
379 |
+ if (typeof document === 'undefined') { |
|
380 |
+ var jsdom = require('jsdom') |
|
381 |
+ Parser.prototype.parseFromString = function (string) { |
|
382 |
+ return jsdom.jsdom(string, { |
|
383 |
+ features: { |
|
384 |
+ FetchExternalResources: [], |
|
385 |
+ ProcessExternalResources: false |
|
386 |
+ } |
|
387 |
+ }) |
|
388 |
+ } |
|
389 |
+ } else { |
|
390 |
+ if (!shouldUseActiveX()) { |
|
391 |
+ Parser.prototype.parseFromString = function (string) { |
|
392 |
+ var doc = document.implementation.createHTMLDocument('') |
|
393 |
+ doc.open() |
|
394 |
+ doc.write(string) |
|
395 |
+ doc.close() |
|
396 |
+ return doc |
|
397 |
+ } |
|
398 |
+ } else { |
|
399 |
+ Parser.prototype.parseFromString = function (string) { |
|
400 |
+ var doc = new window.ActiveXObject('htmlfile') |
|
401 |
+ doc.designMode = 'on' // disable on-page scripts |
|
402 |
+ doc.open() |
|
403 |
+ doc.write(string) |
|
404 |
+ doc.close() |
|
405 |
+ return doc |
|
406 |
+ } |
|
407 |
+ } |
|
408 |
+ } |
|
409 |
+ return Parser |
|
410 |
+} |
|
411 |
+ |
|
412 |
+function shouldUseActiveX () { |
|
413 |
+ var useActiveX = false |
|
414 |
+ |
|
415 |
+ try { |
|
416 |
+ document.implementation.createHTMLDocument('').open() |
|
417 |
+ } catch (e) { |
|
418 |
+ if (window.ActiveXObject) useActiveX = true |
|
419 |
+ } |
|
420 |
+ |
|
421 |
+ return useActiveX |
|
422 |
+} |
|
423 |
+ |
|
424 |
+module.exports = canParseHtmlNatively() ? _window.DOMParser : createHtmlParser() |
|
425 |
+ |
|
426 |
+},{"jsdom":6}],4:[function(require,module,exports){ |
|
427 |
+'use strict' |
|
428 |
+ |
|
429 |
+module.exports = [ |
|
430 |
+ { |
|
431 |
+ filter: 'p', |
|
432 |
+ replacement: function (content) { |
|
433 |
+ return '\n\n' + content + '\n\n' |
|
434 |
+ } |
|
435 |
+ }, |
|
436 |
+ |
|
437 |
+ { |
|
438 |
+ filter: 'br', |
|
439 |
+ replacement: function () { |
|
440 |
+ return ' \n' |
|
441 |
+ } |
|
442 |
+ }, |
|
443 |
+ |
|
444 |
+ { |
|
445 |
+ filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], |
|
446 |
+ replacement: function (content, node) { |
|
447 |
+ var hLevel = node.nodeName.charAt(1) |
|
448 |
+ var hPrefix = '' |
|
449 |
+ for (var i = 0; i < hLevel; i++) { |
|
450 |
+ hPrefix += '#' |
|
451 |
+ } |
|
452 |
+ return '\n\n' + hPrefix + ' ' + content + '\n\n' |
|
453 |
+ } |
|
454 |
+ }, |
|
455 |
+ |
|
456 |
+ { |
|
457 |
+ filter: 'hr', |
|
458 |
+ replacement: function () { |
|
459 |
+ return '\n\n* * *\n\n' |
|
460 |
+ } |
|
461 |
+ }, |
|
462 |
+ |
|
463 |
+ { |
|
464 |
+ filter: ['em', 'i'], |
|
465 |
+ replacement: function (content) { |
|
466 |
+ return '_' + content + '_' |
|
467 |
+ } |
|
468 |
+ }, |
|
469 |
+ |
|
470 |
+ { |
|
471 |
+ filter: ['strong', 'b'], |
|
472 |
+ replacement: function (content) { |
|
473 |
+ return '**' + content + '**' |
|
474 |
+ } |
|
475 |
+ }, |
|
476 |
+ |
|
477 |
+ // Inline code |
|
478 |
+ { |
|
479 |
+ filter: function (node) { |
|
480 |
+ var hasSiblings = node.previousSibling || node.nextSibling |
|
481 |
+ var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings |
|
482 |
+ |
|
483 |
+ return node.nodeName === 'CODE' && !isCodeBlock |
|
484 |
+ }, |
|
485 |
+ replacement: function (content) { |
|
486 |
+ return '`' + content + '`' |
|
487 |
+ } |
|
488 |
+ }, |
|
489 |
+ |
|
490 |
+ { |
|
491 |
+ filter: function (node) { |
|
492 |
+ return node.nodeName === 'A' && node.getAttribute('href') |
|
493 |
+ }, |
|
494 |
+ replacement: function (content, node) { |
|
495 |
+ var titlePart = node.title ? ' "' + node.title + '"' : '' |
|
496 |
+ return '[' + content + '](' + node.getAttribute('href') + titlePart + ')' |
|
497 |
+ } |
|
498 |
+ }, |
|
499 |
+ |
|
500 |
+ { |
|
501 |
+ filter: 'img', |
|
502 |
+ replacement: function (content, node) { |
|
503 |
+ var alt = node.alt || '' |
|
504 |
+ var src = node.getAttribute('src') || '' |
|
505 |
+ var title = node.title || '' |
|
506 |
+ var titlePart = title ? ' "' + title + '"' : '' |
|
507 |
+ return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : '' |
|
508 |
+ } |
|
509 |
+ }, |
|
510 |
+ |
|
511 |
+ // Code blocks |
|
512 |
+ { |
|
513 |
+ filter: function (node) { |
|
514 |
+ return node.nodeName === 'PRE' && node.firstChild.nodeName === 'CODE' |
|
515 |
+ }, |
|
516 |
+ replacement: function (content, node) { |
|
517 |
+ return '\n\n ' + node.firstChild.textContent.replace(/\n/g, '\n ') + '\n\n' |
|
518 |
+ } |
|
519 |
+ }, |
|
520 |
+ |
|
521 |
+ { |
|
522 |
+ filter: 'blockquote', |
|
523 |
+ replacement: function (content) { |
|
524 |
+ content = content.trim() |
|
525 |
+ content = content.replace(/\n{3,}/g, '\n\n') |
|
526 |
+ content = content.replace(/^/gm, '> ') |
|
527 |
+ return '\n\n' + content + '\n\n' |
|
528 |
+ } |
|
529 |
+ }, |
|
530 |
+ |
|
531 |
+ { |
|
532 |
+ filter: 'li', |
|
533 |
+ replacement: function (content, node) { |
|
534 |
+ content = content.replace(/^\s+/, '').replace(/\n/gm, '\n ') |
|
535 |
+ var prefix = '* ' |
|
536 |
+ var parent = node.parentNode |
|
537 |
+ var index = Array.prototype.indexOf.call(parent.children, node) + 1 |
|
538 |
+ |
|
539 |
+ prefix = /ol/i.test(parent.nodeName) ? index + '. ' : '* ' |
|
540 |
+ return prefix + content |
|
541 |
+ } |
|
542 |
+ }, |
|
543 |
+ |
|
544 |
+ { |
|
545 |
+ filter: ['ul', 'ol'], |
|
546 |
+ replacement: function (content, node) { |
|
547 |
+ var strings = [] |
|
548 |
+ for (var i = 0; i < node.childNodes.length; i++) { |
|
549 |
+ strings.push(node.childNodes[i]._replacement) |
|
550 |
+ } |
|
551 |
+ |
|
552 |
+ if (/li/i.test(node.parentNode.nodeName)) { |
|
553 |
+ return '\n' + strings.join('\n') |
|
554 |
+ } |
|
555 |
+ return '\n\n' + strings.join('\n') + '\n\n' |
|
556 |
+ } |
|
557 |
+ }, |
|
558 |
+ |
|
559 |
+ { |
|
560 |
+ filter: function (node) { |
|
561 |
+ return this.isBlock(node) |
|
562 |
+ }, |
|
563 |
+ replacement: function (content, node) { |
|
564 |
+ return '\n\n' + this.outer(node, content) + '\n\n' |
|
565 |
+ } |
|
566 |
+ }, |
|
567 |
+ |
|
568 |
+ // Anything else! |
|
569 |
+ { |
|
570 |
+ filter: function () { |
|
571 |
+ return true |
|
572 |
+ }, |
|
573 |
+ replacement: function (content, node) { |
|
574 |
+ return this.outer(node, content) |
|
575 |
+ } |
|
576 |
+ } |
|
577 |
+] |
|
578 |
+ |
|
579 |
+},{}],5:[function(require,module,exports){ |
|
580 |
+/** |
|
581 |
+ * This file automatically generated from `build.js`. |
|
582 |
+ * Do not manually edit. |
|
583 |
+ */ |
|
584 |
+ |
|
585 |
+module.exports = [ |
|
586 |
+ "address", |
|
587 |
+ "article", |
|
588 |
+ "aside", |
|
589 |
+ "audio", |
|
590 |
+ "blockquote", |
|
591 |
+ "canvas", |
|
592 |
+ "dd", |
|
593 |
+ "div", |
|
594 |
+ "dl", |
|
595 |
+ "fieldset", |
|
596 |
+ "figcaption", |
|
597 |
+ "figure", |
|
598 |
+ "footer", |
|
599 |
+ "form", |
|
600 |
+ "h1", |
|
601 |
+ "h2", |
|
602 |
+ "h3", |
|
603 |
+ "h4", |
|
604 |
+ "h5", |
|
605 |
+ "h6", |
|
606 |
+ "header", |
|
607 |
+ "hgroup", |
|
608 |
+ "hr", |
|
609 |
+ "main", |
|
610 |
+ "nav", |
|
611 |
+ "noscript", |
|
612 |
+ "ol", |
|
613 |
+ "output", |
|
614 |
+ "p", |
|
615 |
+ "pre", |
|
616 |
+ "section", |
|
617 |
+ "table", |
|
618 |
+ "tfoot", |
|
619 |
+ "ul", |
|
620 |
+ "video" |
|
621 |
+]; |
|
622 |
+ |
|
623 |
+},{}],6:[function(require,module,exports){ |
|
624 |
+ |
|
625 |
+},{}],7:[function(require,module,exports){ |
|
626 |
+'use strict'; |
|
627 |
+ |
|
628 |
+var voidElements = require('void-elements'); |
|
629 |
+Object.keys(voidElements).forEach(function (name) { |
|
630 |
+ voidElements[name.toUpperCase()] = 1; |
|
631 |
+}); |
|
632 |
+ |
|
633 |
+var blockElements = {}; |
|
634 |
+require('block-elements').forEach(function (name) { |
|
635 |
+ blockElements[name.toUpperCase()] = 1; |
|
636 |
+}); |
|
637 |
+ |
|
638 |
+/** |
|
639 |
+ * isBlockElem(node) determines if the given node is a block element. |
|
640 |
+ * |
|
641 |
+ * @param {Node} node |
|
642 |
+ * @return {Boolean} |
|
643 |
+ */ |
|
644 |
+function isBlockElem(node) { |
|
645 |
+ return !!(node && blockElements[node.nodeName]); |
|
646 |
+} |
|
647 |
+ |
|
648 |
+/** |
|
649 |
+ * isVoid(node) determines if the given node is a void element. |
|
650 |
+ * |
|
651 |
+ * @param {Node} node |
|
652 |
+ * @return {Boolean} |
|
653 |
+ */ |
|
654 |
+function isVoid(node) { |
|
655 |
+ return !!(node && voidElements[node.nodeName]); |
|
656 |
+} |
|
657 |
+ |
|
658 |
+/** |
|
659 |
+ * whitespace(elem [, isBlock]) removes extraneous whitespace from an |
|
660 |
+ * the given element. The function isBlock may optionally be passed in |
|
661 |
+ * to determine whether or not an element is a block element; if none |
|
662 |
+ * is provided, defaults to using the list of block elements provided |
|
663 |
+ * by the `block-elements` module. |
|
664 |
+ * |
|
665 |
+ * @param {Node} elem |
|
666 |
+ * @param {Function} blockTest |
|
667 |
+ */ |
|
668 |
+function collapseWhitespace(elem, isBlock) { |
|
669 |
+ if (!elem.firstChild || elem.nodeName === 'PRE') return; |
|
670 |
+ |
|
671 |
+ if (typeof isBlock !== 'function') { |
|
672 |
+ isBlock = isBlockElem; |
|
673 |
+ } |
|
674 |
+ |
|
675 |
+ var prevText = null; |
|
676 |
+ var prevVoid = false; |
|
677 |
+ |
|
678 |
+ var prev = null; |
|
679 |
+ var node = next(prev, elem); |
|
680 |
+ |
|
681 |
+ while (node !== elem) { |
|
682 |
+ if (node.nodeType === 3) { |
|
683 |
+ // Node.TEXT_NODE |
|
684 |
+ var text = node.data.replace(/[ \r\n\t]+/g, ' '); |
|
685 |
+ |
|
686 |
+ if ((!prevText || / $/.test(prevText.data)) && !prevVoid && text[0] === ' ') { |
|
687 |
+ text = text.substr(1); |
|
688 |
+ } |
|
689 |
+ |
|
690 |
+ // `text` might be empty at this point. |
|
691 |
+ if (!text) { |
|
692 |
+ node = remove(node); |
|
693 |
+ continue; |
|
694 |
+ } |
|
695 |
+ |
|
696 |
+ node.data = text; |
|
697 |
+ prevText = node; |
|
698 |
+ } else if (node.nodeType === 1) { |
|
699 |
+ // Node.ELEMENT_NODE |
|
700 |
+ if (isBlock(node) || node.nodeName === 'BR') { |
|
701 |
+ if (prevText) { |
|
702 |
+ prevText.data = prevText.data.replace(/ $/, ''); |
|
703 |
+ } |
|
704 |
+ |
|
705 |
+ prevText = null; |
|
706 |
+ prevVoid = false; |
|
707 |
+ } else if (isVoid(node)) { |
|
708 |
+ // Avoid trimming space around non-block, non-BR void elements. |
|
709 |
+ prevText = null; |
|
710 |
+ prevVoid = true; |
|
711 |
+ } |
|
712 |
+ } else { |
|
713 |
+ node = remove(node); |
|
714 |
+ continue; |
|
715 |
+ } |
|
716 |
+ |
|
717 |
+ var nextNode = next(prev, node); |
|
718 |
+ prev = node; |
|
719 |
+ node = nextNode; |
|
720 |
+ } |
|
721 |
+ |
|
722 |
+ if (prevText) { |
|
723 |
+ prevText.data = prevText.data.replace(/ $/, ''); |
|
724 |
+ if (!prevText.data) { |
|
725 |
+ remove(prevText); |
|
726 |
+ } |
|
727 |
+ } |
|
728 |
+} |
|
729 |
+ |
|
730 |
+/** |
|
731 |
+ * remove(node) removes the given node from the DOM and returns the |
|
732 |
+ * next node in the sequence. |
|
733 |
+ * |
|
734 |
+ * @param {Node} node |
|
735 |
+ * @return {Node} node |
|
736 |
+ */ |
|
737 |
+function remove(node) { |
|
738 |
+ var next = node.nextSibling || node.parentNode; |
|
739 |
+ |
|
740 |
+ node.parentNode.removeChild(node); |
|
741 |
+ |
|
742 |
+ return next; |
|
743 |
+} |
|
744 |
+ |
|
745 |
+/** |
|
746 |
+ * next(prev, current) returns the next node in the sequence, given the |
|
747 |
+ * current and previous nodes. |
|
748 |
+ * |
|
749 |
+ * @param {Node} prev |
|
750 |
+ * @param {Node} current |
|
751 |
+ * @return {Node} |
|
752 |
+ */ |
|
753 |
+function next(prev, current) { |
|
754 |
+ if (prev && prev.parentNode === current || current.nodeName === 'PRE') { |
|
755 |
+ return current.nextSibling || current.parentNode; |
|
756 |
+ } |
|
757 |
+ |
|
758 |
+ return current.firstChild || current.nextSibling || current.parentNode; |
|
759 |
+} |
|
760 |
+ |
|
761 |
+module.exports = collapseWhitespace; |
|
762 |
+ |
|
763 |
+},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){ |
|
764 |
+/** |
|
765 |
+ * This file automatically generated from `pre-publish.js`. |
|
766 |
+ * Do not manually edit. |
|
767 |
+ */ |
|
768 |
+ |
|
769 |
+module.exports = { |
|
770 |
+ "area": true, |
|
771 |
+ "base": true, |
|
772 |
+ "br": true, |
|
773 |
+ "col": true, |
|
774 |
+ "embed": true, |
|
775 |
+ "hr": true, |
|
776 |
+ "img": true, |
|
777 |
+ "input": true, |
|
778 |
+ "keygen": true, |
|
779 |
+ "link": true, |
|
780 |
+ "menuitem": true, |
|
781 |
+ "meta": true, |
|
782 |
+ "param": true, |
|
783 |
+ "source": true, |
|
784 |
+ "track": true, |
|
785 |
+ "wbr": true |
|
786 |
+}; |
|
787 |
+ |
|
788 |
+},{}]},{},[1])(1) |
|
789 |
+}); |
@@ -0,0 +1,3 @@ |
||
1 |
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else{if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else{if(typeof global!=="undefined"){g=global}else{if(typeof self!=="undefined"){g=self}else{g=this}}}g.toMarkdown=f()}}})(function(){var define,module,exports;return(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){return a(o,!0)}if(i){return i(o,!0)}var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++){s(r[o])}return s})({1:[function(require,module,exports){var toMarkdown;var converters;var mdConverters=require("./lib/md-converters");var gfmConverters=require("./lib/gfm-converters");var HtmlParser=require("./lib/html-parser");var collapse=require("collapse-whitespace");var blocks=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function isBlock(node){return blocks.indexOf(node.nodeName.toLowerCase())!==-1}var voids=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function isVoid(node){return voids.indexOf(node.nodeName.toLowerCase())!==-1}function htmlToDom(string){var tree=new HtmlParser().parseFromString(string,"text/html");collapse(tree.documentElement,isBlock);return tree}function bfsOrder(node){var inqueue=[node];var outqueue=[];var elem;var children;var i;while(inqueue.length>0){elem=inqueue.shift();outqueue.push(elem);children=elem.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){inqueue.push(children[i])}}}outqueue.shift();return outqueue}function getContent(node){var text="";for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType===1){text+=node.childNodes[i]._replacement}else{if(node.childNodes[i].nodeType===3){text+=node.childNodes[i].data}else{continue}}}return text}function outer(node,content){return node.cloneNode(false).outerHTML.replace("><",">"+content+"<")}function canConvert(node,filter){if(typeof filter==="string"){return filter===node.nodeName.toLowerCase()}if(Array.isArray(filter)){return filter.indexOf(node.nodeName.toLowerCase())!==-1}else{if(typeof filter==="function"){return filter.call(toMarkdown,node)}else{throw new TypeError("`filter` needs to be a string, array, or function")}}}function isFlankedByWhitespace(side,node){var sibling;var regExp;var isFlanked;if(side==="left"){sibling=node.previousSibling;regExp=/ $/}else{sibling=node.nextSibling;regExp=/^ /}if(sibling){if(sibling.nodeType===3){isFlanked=regExp.test(sibling.nodeValue)}else{if(sibling.nodeType===1&&!isBlock(sibling)){isFlanked=regExp.test(sibling.textContent)}}}return isFlanked}function flankingWhitespace(node,content){var leading="";var trailing="";if(!isBlock(node)){var hasLeading=/^[ \r\n\t]/.test(content);var hasTrailing=/[ \r\n\t]$/.test(content);if(hasLeading&&!isFlankedByWhitespace("left",node)){leading=" "}if(hasTrailing&&!isFlankedByWhitespace("right",node)){trailing=" "}}return{leading:leading,trailing:trailing}}function process(node){var replacement;var content=getContent(node);if(!isVoid(node)&&!/A|TH|TD/.test(node.nodeName)&&/^\s*$/i.test(content)){node._replacement="";return}for(var i=0;i<converters.length;i++){var converter=converters[i];if(canConvert(node,converter.filter)){if(typeof converter.replacement!=="function"){throw new TypeError("`replacement` needs to be a function that returns a string")}var whitespace=flankingWhitespace(node,content);if(whitespace.leading||whitespace.trailing){content=content.trim()}replacement=whitespace.leading+converter.replacement.call(toMarkdown,content,node)+whitespace.trailing;break}}node._replacement=replacement}toMarkdown=function(input,options){options=options||{};if(typeof input!=="string"){throw new TypeError(input+" is not a string")}if(input===""){return""}input=input.replace(/(\d+)\. /g,"$1\\. ");var clone=htmlToDom(input).body;var nodes=bfsOrder(clone);var output;converters=mdConverters.slice(0);if(options.gfm){converters=gfmConverters.concat(converters)}if(options.converters){converters=options.converters.concat(converters)}for(var i=nodes.length-1;i>=0;i--){process(nodes[i])}output=getContent(clone);return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")};toMarkdown.isBlock=isBlock;toMarkdown.isVoid=isVoid;toMarkdown.outer=outer;module.exports=toMarkdown},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){function cell(content,node){var index=Array.prototype.indexOf.call(node.parentNode.childNodes,node); |
|
2 |
+var prefix=" ";if(index===0){prefix="| "}return prefix+content+" |"}var highlightRegEx=/highlight highlight-(\S+)/;module.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(content){return"~~"+content+"~~"}},{filter:function(node){return node.type==="checkbox"&&node.parentNode.nodeName==="LI"},replacement:function(content,node){return(node.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(content,node){return cell(content,node)}},{filter:"tr",replacement:function(content,node){var borderCells="";var alignMap={left:":--",right:"--:",center:":-:"};if(node.parentNode.nodeName==="THEAD"){for(var i=0;i<node.childNodes.length;i++){var align=node.childNodes[i].attributes.align;var border="---";if(align){border=alignMap[align.value]||border}borderCells+=cell(border,node.childNodes[i])}}return"\n"+content+(borderCells?"\n"+borderCells:"")}},{filter:"table",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(content){return content}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n```\n"+node.firstChild.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="PRE"&&node.parentNode.nodeName==="DIV"&&highlightRegEx.test(node.parentNode.className)},replacement:function(content,node){var language=node.parentNode.className.match(highlightRegEx)[1];return"\n\n```"+language+"\n"+node.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="DIV"&&highlightRegEx.test(node.className)},replacement:function(content){return"\n\n"+content+"\n\n"}}]},{}],3:[function(require,module,exports){var _window=(typeof window!=="undefined"?window:this);function canParseHtmlNatively(){var Parser=_window.DOMParser;var canParse=false;try{if(new Parser().parseFromString("","text/html")){canParse=true}}catch(e){}return canParse}function createHtmlParser(){var Parser=function(){};if(typeof document==="undefined"){var jsdom=require("jsdom");Parser.prototype.parseFromString=function(string){return jsdom.jsdom(string,{features:{FetchExternalResources:[],ProcessExternalResources:false}})}}else{if(!shouldUseActiveX()){Parser.prototype.parseFromString=function(string){var doc=document.implementation.createHTMLDocument("");doc.open();doc.write(string);doc.close();return doc}}else{Parser.prototype.parseFromString=function(string){var doc=new window.ActiveXObject("htmlfile");doc.designMode="on";doc.open();doc.write(string);doc.close();return doc}}}return Parser}function shouldUseActiveX(){var useActiveX=false;try{document.implementation.createHTMLDocument("").open()}catch(e){if(window.ActiveXObject){useActiveX=true}}return useActiveX}module.exports=canParseHtmlNatively()?_window.DOMParser:createHtmlParser()},{"jsdom":6}],4:[function(require,module,exports){module.exports=[{filter:"p",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(content,node){var hLevel=node.nodeName.charAt(1);var hPrefix="";for(var i=0;i<hLevel;i++){hPrefix+="#"}return"\n\n"+hPrefix+" "+content+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(content){return"_"+content+"_"}},{filter:["strong","b"],replacement:function(content){return"**"+content+"**"}},{filter:function(node){var hasSiblings=node.previousSibling||node.nextSibling;var isCodeBlock=node.parentNode.nodeName==="PRE"&&!hasSiblings;return node.nodeName==="CODE"&&!isCodeBlock},replacement:function(content){return"`"+content+"`"}},{filter:function(node){return node.nodeName==="A"&&node.getAttribute("href")},replacement:function(content,node){var titlePart=node.title?' "'+node.title+'"':"";return"["+content+"]("+node.getAttribute("href")+titlePart+")"}},{filter:"img",replacement:function(content,node){var alt=node.alt||"";var src=node.getAttribute("src")||"";var title=node.title||"";var titlePart=title?' "'+title+'"':"";return src?"!["+alt+"]"+"("+src+titlePart+")":""}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n "+node.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(content){content=content.trim();content=content.replace(/\n{3,}/g,"\n\n");content=content.replace(/^/gm,"> ");return"\n\n"+content+"\n\n"}},{filter:"li",replacement:function(content,node){content=content.replace(/^\s+/,"").replace(/\n/gm,"\n ");var prefix="* ";var parent=node.parentNode;var index=Array.prototype.indexOf.call(parent.children,node)+1;prefix=/ol/i.test(parent.nodeName)?index+". ":"* ";return prefix+content}},{filter:["ul","ol"],replacement:function(content,node){var strings=[];for(var i=0;i<node.childNodes.length;i++){strings.push(node.childNodes[i]._replacement) |
|
3 |
+}if(/li/i.test(node.parentNode.nodeName)){return"\n"+strings.join("\n")}return"\n\n"+strings.join("\n")+"\n\n"}},{filter:function(node){return this.isBlock(node)},replacement:function(content,node){return"\n\n"+this.outer(node,content)+"\n\n"}},{filter:function(){return true},replacement:function(content,node){return this.outer(node,content)}}]},{}],5:[function(require,module,exports){module.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],6:[function(require,module,exports){},{}],7:[function(require,module,exports){var voidElements=require("void-elements");Object.keys(voidElements).forEach(function(name){voidElements[name.toUpperCase()]=1});var blockElements={};require("block-elements").forEach(function(name){blockElements[name.toUpperCase()]=1});function isBlockElem(node){return !!(node&&blockElements[node.nodeName])}function isVoid(node){return !!(node&&voidElements[node.nodeName])}function collapseWhitespace(elem,isBlock){if(!elem.firstChild||elem.nodeName==="PRE"){return}if(typeof isBlock!=="function"){isBlock=isBlockElem}var prevText=null;var prevVoid=false;var prev=null;var node=next(prev,elem);while(node!==elem){if(node.nodeType===3){var text=node.data.replace(/[ \r\n\t]+/g," ");if((!prevText||/ $/.test(prevText.data))&&!prevVoid&&text[0]===" "){text=text.substr(1)}if(!text){node=remove(node);continue}node.data=text;prevText=node}else{if(node.nodeType===1){if(isBlock(node)||node.nodeName==="BR"){if(prevText){prevText.data=prevText.data.replace(/ $/,"")}prevText=null;prevVoid=false}else{if(isVoid(node)){prevText=null;prevVoid=true}}}else{node=remove(node);continue}}var nextNode=next(prev,node);prev=node;node=nextNode}if(prevText){prevText.data=prevText.data.replace(/ $/,"");if(!prevText.data){remove(prevText)}}}function remove(node){var next=node.nextSibling||node.parentNode;node.parentNode.removeChild(node);return next}function next(prev,current){if(prev&&prev.parentNode===current||current.nodeName==="PRE"){return current.nextSibling||current.parentNode}return current.firstChild||current.nextSibling||current.parentNode}module.exports=collapseWhitespace},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){module.exports={"area":true,"base":true,"br":true,"col":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"menuitem":true,"meta":true,"param":true,"source":true,"track":true,"wbr":true}},{}]},{},[1])(1)}); |
@@ -0,0 +1,261 @@ |
||
1 |
+(function (root, factory) { |
|
2 |
+ if (typeof define === 'function' && define.amd) { |
|
3 |
+ // AMD. Register as an anonymous module unless amdModuleId is set |
|
4 |
+ define('simple-uploader', ["jquery","simple-module"], function ($, SimpleModule) { |
|
5 |
+ return (root['uploader'] = factory($, SimpleModule)); |
|
6 |
+ }); |
|
7 |
+ } else if (typeof exports === 'object') { |
|
8 |
+ // Node. Does not work with strict CommonJS, but |
|
9 |
+ // only CommonJS-like environments that support module.exports, |
|
10 |
+ // like Node. |
|
11 |
+ module.exports = factory(require("jquery"),require("simple-module")); |
|
12 |
+ } else { |
|
13 |
+ root.simple = root.simple || {}; |
|
14 |
+ root.simple['uploader'] = factory(jQuery,SimpleModule); |
|
15 |
+ } |
|
16 |
+}(this, function ($, SimpleModule) { |
|
17 |
+ |
|
18 |
+var Uploader, uploader, |
|
19 |
+ extend = 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; }, |
|
20 |
+ hasProp = {}.hasOwnProperty; |
|
21 |
+ |
|
22 |
+Uploader = (function(superClass) { |
|
23 |
+ extend(Uploader, superClass); |
|
24 |
+ |
|
25 |
+ function Uploader() { |
|
26 |
+ return Uploader.__super__.constructor.apply(this, arguments); |
|
27 |
+ } |
|
28 |
+ |
|
29 |
+ Uploader.count = 0; |
|
30 |
+ |
|
31 |
+ Uploader.prototype.opts = { |
|
32 |
+ url: '', |
|
33 |
+ params: null, |
|
34 |
+ fileKey: 'upload_file', |
|
35 |
+ connectionCount: 3 |
|
36 |
+ }; |
|
37 |
+ |
|
38 |
+ Uploader.prototype._init = function() { |
|
39 |
+ this.files = []; |
|
40 |
+ this.queue = []; |
|
41 |
+ this.id = ++Uploader.count; |
|
42 |
+ this.on('uploadcomplete', (function(_this) { |
|
43 |
+ return function(e, file) { |
|
44 |
+ _this.files.splice($.inArray(file, _this.files), 1); |
|
45 |
+ if (_this.queue.length > 0 && _this.files.length < _this.opts.connectionCount) { |
|
46 |
+ return _this.upload(_this.queue.shift()); |
|
47 |
+ } else { |
|
48 |
+ return _this.uploading = false; |
|
49 |
+ } |
|
50 |
+ }; |
|
51 |
+ })(this)); |
|
52 |
+ return $(window).on('beforeunload.uploader-' + this.id, (function(_this) { |
|
53 |
+ return function(e) { |
|
54 |
+ if (!_this.uploading) { |
|
55 |
+ return; |
|
56 |
+ } |
|
57 |
+ e.originalEvent.returnValue = _this._t('leaveConfirm'); |
|
58 |
+ return _this._t('leaveConfirm'); |
|
59 |
+ }; |
|
60 |
+ })(this)); |
|
61 |
+ }; |
|
62 |
+ |
|
63 |
+ Uploader.prototype.generateId = (function() { |
|
64 |
+ var id; |
|
65 |
+ id = 0; |
|
66 |
+ return function() { |
|
67 |
+ return id += 1; |
|
68 |
+ }; |
|
69 |
+ })(); |
|
70 |
+ |
|
71 |
+ Uploader.prototype.upload = function(file, opts) { |
|
72 |
+ var f, i, key, len; |
|
73 |
+ if (opts == null) { |
|
74 |
+ opts = {}; |
|
75 |
+ } |
|
76 |
+ if (file == null) { |
|
77 |
+ return; |
|
78 |
+ } |
|
79 |
+ if ($.isArray(file) || file instanceof FileList) { |
|
80 |
+ for (i = 0, len = file.length; i < len; i++) { |
|
81 |
+ f = file[i]; |
|
82 |
+ this.upload(f, opts); |
|
83 |
+ } |
|
84 |
+ } else if ($(file).is('input:file')) { |
|
85 |
+ key = $(file).attr('name'); |
|
86 |
+ if (key) { |
|
87 |
+ opts.fileKey = key; |
|
88 |
+ } |
|
89 |
+ this.upload($.makeArray($(file)[0].files), opts); |
|
90 |
+ } else if (!file.id || !file.obj) { |
|
91 |
+ file = this.getFile(file); |
|
92 |
+ } |
|
93 |
+ if (!(file && file.obj)) { |
|
94 |
+ return; |
|
95 |
+ } |
|
96 |
+ $.extend(file, opts); |
|
97 |
+ if (this.files.length >= this.opts.connectionCount) { |
|
98 |
+ this.queue.push(file); |
|
99 |
+ return; |
|
100 |
+ } |
|
101 |
+ if (this.triggerHandler('beforeupload', [file]) === false) { |
|
102 |
+ return; |
|
103 |
+ } |
|
104 |
+ this.files.push(file); |
|
105 |
+ this._xhrUpload(file); |
|
106 |
+ return this.uploading = true; |
|
107 |
+ }; |
|
108 |
+ |
|
109 |
+ Uploader.prototype.getFile = function(fileObj) { |
|
110 |
+ var name, ref, ref1; |
|
111 |
+ if (fileObj instanceof window.File || fileObj instanceof window.Blob) { |
|
112 |
+ name = (ref = fileObj.fileName) != null ? ref : fileObj.name; |
|
113 |
+ } else { |
|
114 |
+ return null; |
|
115 |
+ } |
|
116 |
+ return { |
|
117 |
+ id: this.generateId(), |
|
118 |
+ url: this.opts.url, |
|
119 |
+ params: this.opts.params, |
|
120 |
+ fileKey: this.opts.fileKey, |
|
121 |
+ name: name, |
|
122 |
+ size: (ref1 = fileObj.fileSize) != null ? ref1 : fileObj.size, |
|
123 |
+ ext: name ? name.split('.').pop().toLowerCase() : '', |
|
124 |
+ obj: fileObj |
|
125 |
+ }; |
|
126 |
+ }; |
|
127 |
+ |
|
128 |
+ Uploader.prototype._xhrUpload = function(file) { |
|
129 |
+ var formData, k, ref, v; |
|
130 |
+ formData = new FormData(); |
|
131 |
+ formData.append(file.fileKey, file.obj); |
|
132 |
+ formData.append("original_filename", file.name); |
|
133 |
+ if (file.params) { |
|
134 |
+ ref = file.params; |
|
135 |
+ for (k in ref) { |
|
136 |
+ v = ref[k]; |
|
137 |
+ formData.append(k, v); |
|
138 |
+ } |
|
139 |
+ } |
|
140 |
+ return file.xhr = $.ajax({ |
|
141 |
+ url: file.url, |
|
142 |
+ data: formData, |
|
143 |
+ processData: false, |
|
144 |
+ contentType: false, |
|
145 |
+ type: 'POST', |
|
146 |
+ headers: { |
|
147 |
+ 'X-File-Name': encodeURIComponent(file.name) |
|
148 |
+ }, |
|
149 |
+ xhr: function() { |
|
150 |
+ var req; |
|
151 |
+ req = $.ajaxSettings.xhr(); |
|
152 |
+ if (req) { |
|
153 |
+ req.upload.onprogress = (function(_this) { |
|
154 |
+ return function(e) { |
|
155 |
+ return _this.progress(e); |
|
156 |
+ }; |
|
157 |
+ })(this); |
|
158 |
+ } |
|
159 |
+ return req; |
|
160 |
+ }, |
|
161 |
+ progress: (function(_this) { |
|
162 |
+ return function(e) { |
|
163 |
+ if (!e.lengthComputable) { |
|
164 |
+ return; |
|
165 |
+ } |
|
166 |
+ return _this.trigger('uploadprogress', [file, e.loaded, e.total]); |
|
167 |
+ }; |
|
168 |
+ })(this), |
|
169 |
+ error: (function(_this) { |
|
170 |
+ return function(xhr, status, err) { |
|
171 |
+ return _this.trigger('uploaderror', [file, xhr, status]); |
|
172 |
+ }; |
|
173 |
+ })(this), |
|
174 |
+ success: (function(_this) { |
|
175 |
+ return function(result) { |
|
176 |
+ _this.trigger('uploadprogress', [file, file.size, file.size]); |
|
177 |
+ _this.trigger('uploadsuccess', [file, result]); |
|
178 |
+ return $(document).trigger('uploadsuccess', [file, result, _this]); |
|
179 |
+ }; |
|
180 |
+ })(this), |
|
181 |
+ complete: (function(_this) { |
|
182 |
+ return function(xhr, status) { |
|
183 |
+ return _this.trigger('uploadcomplete', [file, xhr.responseText]); |
|
184 |
+ }; |
|
185 |
+ })(this) |
|
186 |
+ }); |
|
187 |
+ }; |
|
188 |
+ |
|
189 |
+ Uploader.prototype.cancel = function(file) { |
|
190 |
+ var f, i, len, ref; |
|
191 |
+ if (!file.id) { |
|
192 |
+ ref = this.files; |
|
193 |
+ for (i = 0, len = ref.length; i < len; i++) { |
|
194 |
+ f = ref[i]; |
|
195 |
+ if (f.id === file * 1) { |
|
196 |
+ file = f; |
|
197 |
+ break; |
|
198 |
+ } |
|
199 |
+ } |
|
200 |
+ } |
|
201 |
+ this.trigger('uploadcancel', [file]); |
|
202 |
+ if (file.xhr) { |
|
203 |
+ file.xhr.abort(); |
|
204 |
+ } |
|
205 |
+ return file.xhr = null; |
|
206 |
+ }; |
|
207 |
+ |
|
208 |
+ Uploader.prototype.readImageFile = function(fileObj, callback) { |
|
209 |
+ var fileReader, img; |
|
210 |
+ if (!$.isFunction(callback)) { |
|
211 |
+ return; |
|
212 |
+ } |
|
213 |
+ img = new Image(); |
|
214 |
+ img.onload = function() { |
|
215 |
+ return callback(img); |
|
216 |
+ }; |
|
217 |
+ img.onerror = function() { |
|
218 |
+ return callback(); |
|
219 |
+ }; |
|
220 |
+ if (window.FileReader && FileReader.prototype.readAsDataURL && /^image/.test(fileObj.type)) { |
|
221 |
+ fileReader = new FileReader(); |
|
222 |
+ fileReader.onload = function(e) { |
|
223 |
+ return img.src = e.target.result; |
|
224 |
+ }; |
|
225 |
+ return fileReader.readAsDataURL(fileObj); |
|
226 |
+ } else { |
|
227 |
+ return callback(); |
|
228 |
+ } |
|
229 |
+ }; |
|
230 |
+ |
|
231 |
+ Uploader.prototype.destroy = function() { |
|
232 |
+ var file, i, len, ref; |
|
233 |
+ this.queue.length = 0; |
|
234 |
+ ref = this.files; |
|
235 |
+ for (i = 0, len = ref.length; i < len; i++) { |
|
236 |
+ file = ref[i]; |
|
237 |
+ this.cancel(file); |
|
238 |
+ } |
|
239 |
+ $(window).off('.uploader-' + this.id); |
|
240 |
+ return $(document).off('.uploader-' + this.id); |
|
241 |
+ }; |
|
242 |
+ |
|
243 |
+ Uploader.i18n = { |
|
244 |
+ 'zh-CN': { |
|
245 |
+ leaveConfirm: '正在上传文件,如果离开上传会自动取消' |
|
246 |
+ } |
|
247 |
+ }; |
|
248 |
+ |
|
249 |
+ Uploader.locale = 'zh-CN'; |
|
250 |
+ |
|
251 |
+ return Uploader; |
|
252 |
+ |
|
253 |
+})(SimpleModule); |
|
254 |
+ |
|
255 |
+uploader = function(opts) { |
|
256 |
+ return new Uploader(opts); |
|
257 |
+}; |
|
258 |
+ |
|
259 |
+return uploader; |
|
260 |
+ |
|
261 |
+})); |
@@ -0,0 +1,7 @@ |
||
1 |
+!function(a,b){"function"==typeof define&&define.amd? |
|
2 |
+// AMD. Register as an anonymous module unless amdModuleId is set |
|
3 |
+define("simple-uploader",["jquery","simple-module"],function(c,d){return a.uploader=b(c,d)}):"object"==typeof exports? |
|
4 |
+// Node. Does not work with strict CommonJS, but |
|
5 |
+// only CommonJS-like environments that support module.exports, |
|
6 |
+// like Node. |
|
7 |
+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=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(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)||b instanceof FileList)for(e=0,g=b.length;g>e;e++)d=b[e],this.upload(d,c);else a(b).is("input:file")?(f=a(b).attr("name"),f&&(c.fileKey=f),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){e=b.params;for(d in e)f=e[d],c.append(d,f)}return b.xhr=a.ajax({url:b.url,data:c,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,e){return a.trigger("uploaderror",[b,c,d])}}(this),success:function(c){return function(d){return c.trigger("uploadprogress",[b,b.size,b.size]),c.trigger("uploadsuccess",[b,d]),a(document).trigger("uploadsuccess",[b,d,c])}}(this),complete:function(a){return function(c,d){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)}}); |
@@ -0,0 +1,34 @@ |
||
1 |
+(function() { |
|
2 |
+ var djangoJQuery; |
|
3 |
+ if (typeof jQuery == 'undefined' && typeof django == 'undefined') { |
|
4 |
+ console.error('ERROR django-simditor missing jQuery. Set SIMDITOR_JQUERY_URL or provide jQuery in the template.'); |
|
5 |
+ } else if (typeof django != 'undefined') { |
|
6 |
+ djangoJQuery = django.jQuery; |
|
7 |
+ } |
|
8 |
+ |
|
9 |
+ var $ = jQuery || djangoJQuery; |
|
10 |
+ $(function() { |
|
11 |
+ |
|
12 |
+ initialiseSimditor(); |
|
13 |
+ function initialiseSimditor() { |
|
14 |
+ $('textarea[data-type=simditortype]').each(function() { |
|
15 |
+ |
|
16 |
+ if($(this).data('processed') == "0" && $(this).attr('data-id').indexOf('__prefix__') == -1){ |
|
17 |
+ $(this).data('processed', "1"); |
|
18 |
+ var dataConfig = $(this).data('config'); |
|
19 |
+ new Simditor({ |
|
20 |
+ textarea: $(this), |
|
21 |
+ upload: dataConfig.upload, |
|
22 |
+ cleanPaste: dataConfig.cleanPaste, |
|
23 |
+ tabIndent: dataConfig.tabIndent, |
|
24 |
+ pasteImage: dataConfig.pasteImage, |
|
25 |
+ toolbar: dataConfig.toolbar, |
|
26 |
+ emoji: dataConfig.emoji |
|
27 |
+ }); |
|
28 |
+ } |
|
29 |
+ }); |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ }); |
|
33 |
+ |
|
34 |
+})(); |
@@ -0,0 +1,696 @@ |
||
1 |
+@charset "UTF-8"; |
|
2 |
+ |
|
3 |
+$simditor-button-height: 40px; |
|
4 |
+$simditor-button-width: 46px; |
|
5 |
+ |
|
6 |
+.simditor { |
|
7 |
+ position: relative; |
|
8 |
+ border: 1px solid #c9d8db; |
|
9 |
+ |
|
10 |
+ .simditor-wrapper { |
|
11 |
+ position: relative; |
|
12 |
+ background: #ffffff; |
|
13 |
+ |
|
14 |
+ & > textarea { |
|
15 |
+ display: none !important; |
|
16 |
+ width: 100%; |
|
17 |
+ box-sizing: border-box; |
|
18 |
+ font-family: monaco; |
|
19 |
+ font-size: 16px; |
|
20 |
+ line-height: 1.6; |
|
21 |
+ border: none; |
|
22 |
+ padding: 22px 15px 40px; |
|
23 |
+ min-height: 300px; |
|
24 |
+ outline: none; |
|
25 |
+ background: transparent; |
|
26 |
+ resize: none; |
|
27 |
+ } |
|
28 |
+ |
|
29 |
+ .simditor-placeholder { |
|
30 |
+ display: none; |
|
31 |
+ position: absolute; |
|
32 |
+ left: 0; |
|
33 |
+ z-index: 0; |
|
34 |
+ padding: 22px 15px; |
|
35 |
+ font-size: 16px; |
|
36 |
+ font-family: arial, sans-serif; |
|
37 |
+ line-height: 1.5; |
|
38 |
+ color: #999999; |
|
39 |
+ background: transparent; |
|
40 |
+ } |
|
41 |
+ |
|
42 |
+ &.toolbar-floating { |
|
43 |
+ .simditor-toolbar { |
|
44 |
+ position: fixed; |
|
45 |
+ top: 0; |
|
46 |
+ z-index: 10; |
|
47 |
+ box-shadow: 0 0 6px rgba(0,0,0,0.1); |
|
48 |
+ } |
|
49 |
+ } |
|
50 |
+ |
|
51 |
+ .simditor-image-loading { |
|
52 |
+ width: 100%; |
|
53 |
+ height: 100%; |
|
54 |
+ position: absolute; |
|
55 |
+ top: 0; |
|
56 |
+ left: 0; |
|
57 |
+ z-index: 2; |
|
58 |
+ |
|
59 |
+ .progress { |
|
60 |
+ width: 100%; |
|
61 |
+ height: 100%; |
|
62 |
+ background: rgba(0,0,0,0.4); |
|
63 |
+ position: absolute; |
|
64 |
+ bottom: 0; |
|
65 |
+ left: 0; |
|
66 |
+ } |
|
67 |
+ } |
|
68 |
+ } |
|
69 |
+ |
|
70 |
+ .simditor-body { |
|
71 |
+ padding: 22px 15px 40px; |
|
72 |
+ min-height: 300px; |
|
73 |
+ outline: none; |
|
74 |
+ cursor: text; |
|
75 |
+ position: relative; |
|
76 |
+ z-index: 1; |
|
77 |
+ background: transparent; |
|
78 |
+ |
|
79 |
+ a.selected { |
|
80 |
+ background: #b3d4fd; |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ a.simditor-mention { |
|
84 |
+ cursor: pointer; |
|
85 |
+ } |
|
86 |
+ |
|
87 |
+ .simditor-table { |
|
88 |
+ position: relative; |
|
89 |
+ |
|
90 |
+ &.resizing { |
|
91 |
+ cursor: col-resize; |
|
92 |
+ } |
|
93 |
+ |
|
94 |
+ .simditor-resize-handle { |
|
95 |
+ position: absolute; |
|
96 |
+ left: 0; |
|
97 |
+ top: 0; |
|
98 |
+ width: 10px; |
|
99 |
+ height: 100%; |
|
100 |
+ cursor: col-resize; |
|
101 |
+ } |
|
102 |
+ } |
|
103 |
+ |
|
104 |
+ pre { |
|
105 |
+ /*min-height: 28px;*/ |
|
106 |
+ box-sizing: border-box; |
|
107 |
+ -moz-box-sizing: border-box; |
|
108 |
+ word-wrap: break-word!important; |
|
109 |
+ white-space: pre-wrap!important; |
|
110 |
+ } |
|
111 |
+ |
|
112 |
+ img { |
|
113 |
+ cursor: pointer; |
|
114 |
+ |
|
115 |
+ &.selected { |
|
116 |
+ box-shadow: 0 0 0 4px #cccccc; |
|
117 |
+ } |
|
118 |
+ } |
|
119 |
+ } |
|
120 |
+ |
|
121 |
+ .simditor-paste-bin { |
|
122 |
+ position: fixed; |
|
123 |
+ bottom: 10px; |
|
124 |
+ right: 10px; |
|
125 |
+ width: 1px; |
|
126 |
+ height: 20px; |
|
127 |
+ font-size: 1px; |
|
128 |
+ line-height: 1px; |
|
129 |
+ overflow: hidden; |
|
130 |
+ padding: 0; |
|
131 |
+ margin: 0; |
|
132 |
+ opacity: 0; |
|
133 |
+ -webkit-user-select: text; |
|
134 |
+ } |
|
135 |
+ |
|
136 |
+ .simditor-toolbar { |
|
137 |
+ border-bottom: 1px solid #eeeeee; |
|
138 |
+ background: #ffffff; |
|
139 |
+ width: 100%; |
|
140 |
+ |
|
141 |
+ & > ul { |
|
142 |
+ margin: 0; |
|
143 |
+ padding: 0 0 0 6px; |
|
144 |
+ list-style: none; |
|
145 |
+ |
|
146 |
+ & > li { |
|
147 |
+ position: relative; |
|
148 |
+ display: inline-block; |
|
149 |
+ font-size: 0; |
|
150 |
+ |
|
151 |
+ & > span.separator { |
|
152 |
+ display: inline-block; |
|
153 |
+ background: #cfcfcf; |
|
154 |
+ width: 1px; |
|
155 |
+ height: 18px; |
|
156 |
+ margin: ($simditor-button-height - 18px) / 2 15px; |
|
157 |
+ vertical-align: middle; |
|
158 |
+ } |
|
159 |
+ |
|
160 |
+ & > .toolbar-item { |
|
161 |
+ display: inline-block; |
|
162 |
+ width: $simditor-button-width; |
|
163 |
+ height: $simditor-button-height; |
|
164 |
+ outline: none; |
|
165 |
+ color: #333333; |
|
166 |
+ font-size: 15px; |
|
167 |
+ line-height: $simditor-button-height; |
|
168 |
+ vertical-align: middle; |
|
169 |
+ text-align: center; |
|
170 |
+ text-decoration: none; |
|
171 |
+ |
|
172 |
+ span { |
|
173 |
+ opacity: 0.6; |
|
174 |
+ |
|
175 |
+ &.simditor-icon { |
|
176 |
+ display: inline; |
|
177 |
+ line-height: normal; |
|
178 |
+ } |
|
179 |
+ } |
|
180 |
+ |
|
181 |
+ &:hover span { |
|
182 |
+ opacity: 1; |
|
183 |
+ } |
|
184 |
+ |
|
185 |
+ &.active { |
|
186 |
+ background: #eeeeee; |
|
187 |
+ |
|
188 |
+ span { |
|
189 |
+ opacity: 1; |
|
190 |
+ } |
|
191 |
+ } |
|
192 |
+ |
|
193 |
+ &.disabled { |
|
194 |
+ cursor: default; |
|
195 |
+ |
|
196 |
+ span { |
|
197 |
+ opacity: 0.3; |
|
198 |
+ } |
|
199 |
+ } |
|
200 |
+ |
|
201 |
+ &.toolbar-item-title { |
|
202 |
+ span:before { |
|
203 |
+ content: "H"; |
|
204 |
+ font-size: 19px; |
|
205 |
+ font-weight: bold; |
|
206 |
+ font-family: 'Times New Roman'; |
|
207 |
+ } |
|
208 |
+ |
|
209 |
+ &.active-h1 span:before { |
|
210 |
+ content: 'H1'; |
|
211 |
+ font-size: 18px; |
|
212 |
+ } |
|
213 |
+ |
|
214 |
+ &.active-h2 span:before { |
|
215 |
+ content: 'H2'; |
|
216 |
+ font-size: 18px; |
|
217 |
+ } |
|
218 |
+ |
|
219 |
+ &.active-h3 span:before { |
|
220 |
+ content: 'H3'; |
|
221 |
+ font-size: 18px; |
|
222 |
+ } |
|
223 |
+ } |
|
224 |
+ |
|
225 |
+ &.toolbar-item-image { |
|
226 |
+ position: relative; |
|
227 |
+ overflow: hidden; |
|
228 |
+ |
|
229 |
+ & > input[type=file] { |
|
230 |
+ position: absolute; |
|
231 |
+ right: 0px; |
|
232 |
+ top: 0px; |
|
233 |
+ opacity: 0; |
|
234 |
+ font-size: 100px; |
|
235 |
+ cursor: pointer; |
|
236 |
+ } |
|
237 |
+ } |
|
238 |
+ } |
|
239 |
+ |
|
240 |
+ &.menu-on { |
|
241 |
+ .toolbar-item { |
|
242 |
+ position: relative; |
|
243 |
+ z-index: 20; |
|
244 |
+ background: #ffffff; |
|
245 |
+ box-shadow: 0 1px 4px rgba(0,0,0,0.3); |
|
246 |
+ |
|
247 |
+ span { |
|
248 |
+ opacity: 1; |
|
249 |
+ } |
|
250 |
+ } |
|
251 |
+ |
|
252 |
+ .toolbar-menu { |
|
253 |
+ display: block; |
|
254 |
+ } |
|
255 |
+ } |
|
256 |
+ } |
|
257 |
+ } |
|
258 |
+ |
|
259 |
+ .toolbar-menu { |
|
260 |
+ display: none; |
|
261 |
+ position: absolute; |
|
262 |
+ top: $simditor-button-height; |
|
263 |
+ left: 0; |
|
264 |
+ z-index: 21; |
|
265 |
+ background: #ffffff; |
|
266 |
+ text-align: left; |
|
267 |
+ box-shadow: 0 0 4px rgba(0,0,0,0.3); |
|
268 |
+ |
|
269 |
+ &:before { |
|
270 |
+ content: ''; |
|
271 |
+ display: block; |
|
272 |
+ width: $simditor-button-width; |
|
273 |
+ height: 4px; |
|
274 |
+ background: #ffffff; |
|
275 |
+ position: absolute; |
|
276 |
+ top: -3px; |
|
277 |
+ left: 0; |
|
278 |
+ } |
|
279 |
+ |
|
280 |
+ ul { |
|
281 |
+ min-width: 160px; |
|
282 |
+ list-style: none; |
|
283 |
+ margin: 0; |
|
284 |
+ padding: 10px 1px; |
|
285 |
+ |
|
286 |
+ & > li { |
|
287 |
+ |
|
288 |
+ .menu-item { |
|
289 |
+ display: block; |
|
290 |
+ font-size:16px; |
|
291 |
+ line-height: 2em; |
|
292 |
+ padding: 0 10px; |
|
293 |
+ text-decoration: none; |
|
294 |
+ color: #666666; |
|
295 |
+ |
|
296 |
+ &:hover { |
|
297 |
+ background: #f6f6f6; |
|
298 |
+ } |
|
299 |
+ |
|
300 |
+ &.menu-item-h1 { |
|
301 |
+ font-size: 24px; |
|
302 |
+ color: #333333; |
|
303 |
+ } |
|
304 |
+ |
|
305 |
+ &.menu-item-h2 { |
|
306 |
+ font-size: 22px; |
|
307 |
+ color: #333333; |
|
308 |
+ } |
|
309 |
+ |
|
310 |
+ &.menu-item-h3 { |
|
311 |
+ font-size: 20px; |
|
312 |
+ color: #333333; |
|
313 |
+ } |
|
314 |
+ |
|
315 |
+ &.menu-item-h4 { |
|
316 |
+ font-size: 18px; |
|
317 |
+ color: #333333; |
|
318 |
+ } |
|
319 |
+ |
|
320 |
+ &.menu-item-h5 { |
|
321 |
+ font-size: 16px; |
|
322 |
+ color: #333333; |
|
323 |
+ } |
|
324 |
+ } |
|
325 |
+ |
|
326 |
+ .separator { |
|
327 |
+ display: block; |
|
328 |
+ border-top: 1px solid #cccccc; |
|
329 |
+ height: 0; |
|
330 |
+ line-height: 0; |
|
331 |
+ font-size: 0; |
|
332 |
+ margin: 6px 0; |
|
333 |
+ } |
|
334 |
+ } |
|
335 |
+ |
|
336 |
+ } |
|
337 |
+ |
|
338 |
+ &.toolbar-menu-color { |
|
339 |
+ width: 96px; |
|
340 |
+ |
|
341 |
+ .color-list { |
|
342 |
+ height: 40px; |
|
343 |
+ margin: 10px 6px 6px 10px; |
|
344 |
+ padding: 0; |
|
345 |
+ |
|
346 |
+ min-width: 0; |
|
347 |
+ |
|
348 |
+ li { |
|
349 |
+ float: left; |
|
350 |
+ margin: 0 4px 4px 0; |
|
351 |
+ |
|
352 |
+ .font-color { |
|
353 |
+ display: block; |
|
354 |
+ width: 16px; |
|
355 |
+ height: 16px; |
|
356 |
+ background: #dfdfdf; |
|
357 |
+ border-radius: 2px; |
|
358 |
+ |
|
359 |
+ &:hover { |
|
360 |
+ opacity: 0.8; |
|
361 |
+ } |
|
362 |
+ |
|
363 |
+ &.font-color-default { |
|
364 |
+ background: #333333; |
|
365 |
+ } |
|
366 |
+ } |
|
367 |
+ |
|
368 |
+ $font-colors: #E33737 #e28b41 #c8a732 #209361 #418caf #aa8773 #999999; |
|
369 |
+ $i: 1; |
|
370 |
+ @each $color in $font-colors { |
|
371 |
+ .font-color-#{$i} { |
|
372 |
+ background: $color; |
|
373 |
+ } |
|
374 |
+ $i: $i + 1; |
|
375 |
+ } |
|
376 |
+ } |
|
377 |
+ } |
|
378 |
+ } |
|
379 |
+ |
|
380 |
+ &.toolbar-menu-table { |
|
381 |
+ .menu-create-table { |
|
382 |
+ background: #ffffff; |
|
383 |
+ padding: 1px; |
|
384 |
+ |
|
385 |
+ table { |
|
386 |
+ border: none; |
|
387 |
+ border-collapse: collapse; |
|
388 |
+ border-spacing: 0; |
|
389 |
+ table-layout: fixed; |
|
390 |
+ |
|
391 |
+ td { |
|
392 |
+ padding: 0; |
|
393 |
+ cursor: pointer; |
|
394 |
+ |
|
395 |
+ &:before { |
|
396 |
+ width: 16px; |
|
397 |
+ height: 16px; |
|
398 |
+ border: 1px solid #ffffff; |
|
399 |
+ background: #f3f3f3; |
|
400 |
+ display: block; |
|
401 |
+ content: '' |
|
402 |
+ } |
|
403 |
+ |
|
404 |
+ &.selected:before { |
|
405 |
+ background: #cfcfcf; |
|
406 |
+ } |
|
407 |
+ } |
|
408 |
+ } |
|
409 |
+ } |
|
410 |
+ |
|
411 |
+ .menu-edit-table { |
|
412 |
+ display: none; |
|
413 |
+ |
|
414 |
+ ul { |
|
415 |
+ li { |
|
416 |
+ white-space: nowrap; |
|
417 |
+ } |
|
418 |
+ } |
|
419 |
+ } |
|
420 |
+ } |
|
421 |
+ |
|
422 |
+ &.toolbar-menu-image { |
|
423 |
+ .menu-item-upload-image { |
|
424 |
+ position: relative; |
|
425 |
+ overflow: hidden; |
|
426 |
+ |
|
427 |
+ input[type=file] { |
|
428 |
+ position: absolute; |
|
429 |
+ right: 0px; |
|
430 |
+ top: 0px; |
|
431 |
+ opacity: 0; |
|
432 |
+ font-size: 100px; |
|
433 |
+ cursor: pointer; |
|
434 |
+ } |
|
435 |
+ } |
|
436 |
+ } |
|
437 |
+ |
|
438 |
+ &.toolbar-menu-alignment { |
|
439 |
+ width: 100%; |
|
440 |
+ ul { |
|
441 |
+ min-width: 100%; |
|
442 |
+ } |
|
443 |
+ .menu-item { |
|
444 |
+ text-align: center; |
|
445 |
+ } |
|
446 |
+ } |
|
447 |
+ } |
|
448 |
+ } |
|
449 |
+ |
|
450 |
+ .simditor-popover { |
|
451 |
+ display: none; |
|
452 |
+ padding: 5px 8px 0; |
|
453 |
+ background: #ffffff; |
|
454 |
+ box-shadow: 0 1px 4px rgba(0,0,0,0.4); |
|
455 |
+ border-radius: 2px; |
|
456 |
+ position: absolute; |
|
457 |
+ z-index: 2; |
|
458 |
+ |
|
459 |
+ .settings-field { |
|
460 |
+ margin: 0 0 5px 0; |
|
461 |
+ font-size: 12px; |
|
462 |
+ height: 25px; |
|
463 |
+ line-height: 25px; |
|
464 |
+ |
|
465 |
+ label { |
|
466 |
+ display: inline-block; |
|
467 |
+ margin: 0 5px 0 0; |
|
468 |
+ } |
|
469 |
+ |
|
470 |
+ input[type=text] { |
|
471 |
+ display: inline-block; |
|
472 |
+ width: 200px; |
|
473 |
+ box-sizing: border-box; |
|
474 |
+ font-size: 12px; |
|
475 |
+ |
|
476 |
+ &.image-size { |
|
477 |
+ width: 83px; |
|
478 |
+ } |
|
479 |
+ } |
|
480 |
+ |
|
481 |
+ .times { |
|
482 |
+ display: inline-block; |
|
483 |
+ width: 26px; |
|
484 |
+ font-size: 12px; |
|
485 |
+ text-align: center; |
|
486 |
+ } |
|
487 |
+ } |
|
488 |
+ |
|
489 |
+ &.link-popover .btn-unlink, |
|
490 |
+ &.image-popover .btn-upload, |
|
491 |
+ &.image-popover .btn-restore { |
|
492 |
+ display: inline-block; |
|
493 |
+ margin: 0 0 0 5px; |
|
494 |
+ color: #333333; |
|
495 |
+ font-size: 14px; |
|
496 |
+ outline: 0; |
|
497 |
+ |
|
498 |
+ span { |
|
499 |
+ opacity: 0.6; |
|
500 |
+ } |
|
501 |
+ |
|
502 |
+ &:hover span { |
|
503 |
+ opacity: 1; |
|
504 |
+ } |
|
505 |
+ } |
|
506 |
+ |
|
507 |
+ &.image-popover .btn-upload { |
|
508 |
+ position: relative; |
|
509 |
+ display: inline-block; |
|
510 |
+ overflow: hidden; |
|
511 |
+ vertical-align: middle; |
|
512 |
+ |
|
513 |
+ input[type=file] { |
|
514 |
+ position: absolute; |
|
515 |
+ right: 0px; |
|
516 |
+ top: 0px; |
|
517 |
+ opacity: 0; |
|
518 |
+ height: 100%; |
|
519 |
+ width: 28px; |
|
520 |
+ } |
|
521 |
+ } |
|
522 |
+ } |
|
523 |
+ |
|
524 |
+ &.simditor-mobile { |
|
525 |
+ .simditor-wrapper.toolbar-floating .simditor-toolbar { |
|
526 |
+ position: absolute; |
|
527 |
+ top: 0; |
|
528 |
+ z-index: 10; |
|
529 |
+ box-shadow: 0 0 6px rgba(0,0,0,0.1); |
|
530 |
+ } |
|
531 |
+ } |
|
532 |
+} |
|
533 |
+ |
|
534 |
+ |
|
535 |
+ |
|
536 |
+.simditor .simditor-body, .editor-style { |
|
537 |
+ font-size: 16px; |
|
538 |
+ font-family: arial, sans-serif; |
|
539 |
+ line-height: 1.6; |
|
540 |
+ color: #333; |
|
541 |
+ outline: none; |
|
542 |
+ word-wrap: break-word; |
|
543 |
+ |
|
544 |
+ & > :first-child { |
|
545 |
+ margin-top: 0!important; |
|
546 |
+ } |
|
547 |
+ |
|
548 |
+ a{ color: #4298BA; text-decoration: none; word-break: break-all;} |
|
549 |
+ a:visited{ color: #4298BA; } |
|
550 |
+ a:hover{ color: #0F769F; } |
|
551 |
+ a:active{ color:#9E792E; } |
|
552 |
+ a:hover, a:active{ outline: 0; } |
|
553 |
+ |
|
554 |
+ h1,h2,h3,h4,h5,h6 { |
|
555 |
+ font-weight: normal; |
|
556 |
+ margin: 40px 0 20px; |
|
557 |
+ color: #000000; |
|
558 |
+ } |
|
559 |
+ |
|
560 |
+ h1 { font-size: 24px; } |
|
561 |
+ h2 { font-size: 22px; } |
|
562 |
+ h3 { font-size: 20px; } |
|
563 |
+ h4 { font-size: 18px; } |
|
564 |
+ h5 { font-size: 16px; } |
|
565 |
+ h6 { font-size: 16px; } |
|
566 |
+ |
|
567 |
+ p, div { |
|
568 |
+ word-wrap: break-word; |
|
569 |
+ margin: 0 0 15px 0; |
|
570 |
+ color: #333; |
|
571 |
+ word-wrap: break-word; |
|
572 |
+ } |
|
573 |
+ |
|
574 |
+ b, strong { |
|
575 |
+ font-weight: bold; |
|
576 |
+ } |
|
577 |
+ |
|
578 |
+ i, em { |
|
579 |
+ font-style: italic; |
|
580 |
+ } |
|
581 |
+ |
|
582 |
+ u { |
|
583 |
+ text-decoration: underline; |
|
584 |
+ } |
|
585 |
+ |
|
586 |
+ strike, del { |
|
587 |
+ text-decoration: line-through; |
|
588 |
+ } |
|
589 |
+ |
|
590 |
+ ul, ol { |
|
591 |
+ list-style:disc outside none; |
|
592 |
+ margin: 15px 0; |
|
593 |
+ padding: 0 0 0 40px; |
|
594 |
+ line-height: 1.6; |
|
595 |
+ |
|
596 |
+ ul, ol { |
|
597 |
+ padding-left: 30px; |
|
598 |
+ } |
|
599 |
+ |
|
600 |
+ ul { |
|
601 |
+ list-style: circle outside none; |
|
602 |
+ |
|
603 |
+ ul { |
|
604 |
+ list-style: square outside none; |
|
605 |
+ } |
|
606 |
+ } |
|
607 |
+ } |
|
608 |
+ |
|
609 |
+ ol { |
|
610 |
+ list-style:decimal; |
|
611 |
+ } |
|
612 |
+ |
|
613 |
+ blockquote { |
|
614 |
+ border-left: 6px solid #ddd; |
|
615 |
+ padding: 5px 0 5px 10px; |
|
616 |
+ margin: 15px 0 15px 15px; |
|
617 |
+ |
|
618 |
+ & > :first-child { |
|
619 |
+ margin-top: 0; |
|
620 |
+ } |
|
621 |
+ } |
|
622 |
+ |
|
623 |
+ code { |
|
624 |
+ display: inline-block; |
|
625 |
+ padding: 0 4px; |
|
626 |
+ margin: 0 5px; |
|
627 |
+ background: #eeeeee; |
|
628 |
+ border-radius: 3px; |
|
629 |
+ font-size: 13px; |
|
630 |
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace; |
|
631 |
+ } |
|
632 |
+ |
|
633 |
+ pre { |
|
634 |
+ padding: 10px 5px 10px 10px; |
|
635 |
+ margin: 15px 0; |
|
636 |
+ display: block; |
|
637 |
+ line-height: 18px; |
|
638 |
+ background: #F0F0F0; |
|
639 |
+ border-radius: 3px; |
|
640 |
+ font-size:13px; |
|
641 |
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace; |
|
642 |
+ white-space: pre; |
|
643 |
+ word-wrap: normal; |
|
644 |
+ overflow-x: auto; |
|
645 |
+ |
|
646 |
+ code { |
|
647 |
+ display: block; |
|
648 |
+ padding: 0; |
|
649 |
+ margin: 0; |
|
650 |
+ background: none; |
|
651 |
+ border-radius: 0; |
|
652 |
+ } |
|
653 |
+ } |
|
654 |
+ |
|
655 |
+ hr { |
|
656 |
+ display: block; |
|
657 |
+ height: 0px; |
|
658 |
+ border: 0; |
|
659 |
+ border-top: 1px solid #ccc; |
|
660 |
+ margin: 15px 0; |
|
661 |
+ padding: 0; |
|
662 |
+ } |
|
663 |
+ |
|
664 |
+ table { |
|
665 |
+ width: 100%; |
|
666 |
+ table-layout: fixed; |
|
667 |
+ border-collapse: collapse; |
|
668 |
+ border-spacing: 0; |
|
669 |
+ margin: 15px 0; |
|
670 |
+ |
|
671 |
+ thead { |
|
672 |
+ background-color: #f9f9f9; |
|
673 |
+ } |
|
674 |
+ |
|
675 |
+ td, th { |
|
676 |
+ min-width: 40px; |
|
677 |
+ height: 30px; |
|
678 |
+ border: 1px solid #ccc; |
|
679 |
+ vertical-align: top; |
|
680 |
+ padding: 2px 4px; |
|
681 |
+ text-align: left; |
|
682 |
+ box-sizing: border-box; |
|
683 |
+ |
|
684 |
+ &.active { |
|
685 |
+ background-color: #ffffee; |
|
686 |
+ } |
|
687 |
+ } |
|
688 |
+ } |
|
689 |
+ |
|
690 |
+ |
|
691 |
+ img { |
|
692 |
+ margin: 0 5px; |
|
693 |
+ vertical-align: middle; |
|
694 |
+ } |
|
695 |
+ |
|
696 |
+} |
@@ -0,0 +1 @@ |
||
1 |
+@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,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) format('woff');font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'} |
@@ -0,0 +1,25 @@ |
||
1 |
+.simditor .simditor-body .simditor-checklist { |
|
2 |
+ margin: 15px 0; |
|
3 |
+ padding: 0 0 0 40px; |
|
4 |
+ line-height: 1.6; |
|
5 |
+ list-style-type: none; |
|
6 |
+} |
|
7 |
+ |
|
8 |
+.simditor .simditor-body .simditor-checklist > li { |
|
9 |
+ margin: 0; |
|
10 |
+ pointer-events: none; |
|
11 |
+} |
|
12 |
+.simditor .simditor-body .simditor-checklist > li::before { |
|
13 |
+ content: ''; |
|
14 |
+ pointer-events: all; |
|
15 |
+ display: inline-block; |
|
16 |
+ margin: 0 5px 0 -25px; |
|
17 |
+ width: 20px; |
|
18 |
+ height: 20px; |
|
19 |
+ cursor: default; |
|
20 |
+ vertical-align: middle; |
|
21 |
+ background-image: url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw=="); |
|
22 |
+} |
|
23 |
+.simditor .simditor-body .simditor-checklist > li[checked]::before { |
|
24 |
+ background-image: url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw=="); |
|
25 |
+} |
@@ -0,0 +1 @@ |
||
1 |
+.simditor .simditor-body .simditor-checklist{margin:15px 0;padding:0 0 0 40px;line-height:1.6;list-style-type:none}.simditor .simditor-body .simditor-checklist>li{margin:0;pointer-events:none}.simditor .simditor-body .simditor-checklist>li::before{content:'';pointer-events:all;display:inline-block;margin:0 5px 0 -25px;width:20px;height:20px;cursor:default;vertical-align:middle;background-image:url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw==")}.simditor .simditor-body .simditor-checklist>li[checked]::before{background-image:url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw==")} |
@@ -0,0 +1,37 @@ |
||
1 |
+@font-face { |
|
2 |
+ font-family: 'icomoon'; |
|
3 |
+ src: url("../fonts/icomoon.eot?4vkjot"); |
|
4 |
+ src: url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"), url("../fonts/icomoon.ttf?4vkjot") format("truetype"), url("../fonts/icomoon.woff?4vkjot") format("woff"), url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg"); |
|
5 |
+ font-weight: normal; |
|
6 |
+ font-style: normal; |
|
7 |
+} |
|
8 |
+[class^="icon-"], [class*=" icon-"] { |
|
9 |
+ font-family: 'icomoon'; |
|
10 |
+ speak: none; |
|
11 |
+ font-style: normal; |
|
12 |
+ font-weight: normal; |
|
13 |
+ font-variant: normal; |
|
14 |
+ text-transform: none; |
|
15 |
+ line-height: 1; |
|
16 |
+ /* Better Font Rendering =========== */ |
|
17 |
+ -webkit-font-smoothing: antialiased; |
|
18 |
+ -moz-osx-font-smoothing: grayscale; |
|
19 |
+} |
|
20 |
+ |
|
21 |
+.icon-fullscreen:before { |
|
22 |
+ content: "\e600"; |
|
23 |
+} |
|
24 |
+ |
|
25 |
+.simditor-fullscreen { |
|
26 |
+ overflow: hidden; |
|
27 |
+} |
|
28 |
+.simditor-fullscreen .simditor { |
|
29 |
+ position: fixed; |
|
30 |
+ top: 0; |
|
31 |
+ left: 0; |
|
32 |
+ z-index: 9999; |
|
33 |
+ width: 100%; |
|
34 |
+} |
|
35 |
+.simditor-fullscreen .simditor .simditor-body { |
|
36 |
+ overflow: auto; |
|
37 |
+} |
@@ -0,0 +1 @@ |
||
1 |
+@font-face{font-family:'icomoon';src:url("../fonts/icomoon.eot?4vkjot");src:url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"),url("../fonts/icomoon.ttf?4vkjot") format("truetype"),url("../fonts/icomoon.woff?4vkjot") format("woff"),url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg");font-weight:normal;font-style:normal}[class^="icon-"],[class*=" icon-"]{font-family:'icomoon';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-fullscreen:before{content:"\e600"}.simditor-fullscreen{overflow:hidden}.simditor-fullscreen .simditor{position:fixed;top:0;left:0;z-index:9999;width:100%}.simditor-fullscreen .simditor .simditor-body{overflow:auto} |
@@ -0,0 +1,28 @@ |
||
1 |
+.simditor .markdown-editor { |
|
2 |
+ display: none; |
|
3 |
+} |
|
4 |
+.simditor .markdown-editor textarea { |
|
5 |
+ display: block; |
|
6 |
+ width: 100%; |
|
7 |
+ min-height: 200px; |
|
8 |
+ box-sizing: border-box; |
|
9 |
+ padding: 22px 15px 40px; |
|
10 |
+ border: none; |
|
11 |
+ border-bottom: 1px solid #dfdfdf; |
|
12 |
+ resize: none; |
|
13 |
+ outline: none; |
|
14 |
+ font-size: 16px; |
|
15 |
+} |
|
16 |
+.simditor.simditor-markdown .markdown-editor { |
|
17 |
+ display: block; |
|
18 |
+} |
|
19 |
+.simditor.simditor-markdown .simditor-body { |
|
20 |
+ min-height: 100px; |
|
21 |
+ background: #f3f3f3; |
|
22 |
+} |
|
23 |
+.simditor.simditor-markdown .simditor-placeholder { |
|
24 |
+ display: none !important; |
|
25 |
+} |
|
26 |
+.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon { |
|
27 |
+ font-size: 18px; |
|
28 |
+} |
@@ -0,0 +1 @@ |
||
1 |
+.simditor .markdown-editor{display:none}.simditor .markdown-editor textarea{display:block;width:100%;min-height:200px;box-sizing:border-box;padding:22px 15px 40px;border:0;border-bottom:1px solid #dfdfdf;resize:none;outline:0;font-size:16px}.simditor.simditor-markdown .markdown-editor{display:block}.simditor.simditor-markdown .simditor-body{min-height:100px;background:#f3f3f3}.simditor.simditor-markdown .simditor-placeholder{display:none!important}.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon{font-size:18px} |
@@ -0,0 +1,746 @@ |
||
1 |
+/*! |
|
2 |
+* Simditor v2.3.6 |
|
3 |
+* http://simditor.tower.im/ |
|
4 |
+* 2015-12-21 |
|
5 |
+*/ |
|
6 |
+@font-face { |
|
7 |
+ font-family: 'Simditor'; |
|
8 |
+ src: url(data:application/font-woff;charset=utf-8;base64,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) format("woff"); |
|
9 |
+ font-weight: normal; |
|
10 |
+ font-style: normal; |
|
11 |
+} |
|
12 |
+.simditor-icon { |
|
13 |
+ display: inline-block; |
|
14 |
+ font: normal normal normal 14px/1 'Simditor'; |
|
15 |
+ font-size: inherit; |
|
16 |
+ text-rendering: auto; |
|
17 |
+ -webkit-font-smoothing: antialiased; |
|
18 |
+ -moz-osx-font-smoothing: grayscale; |
|
19 |
+ transform: translate(0, 0); |
|
20 |
+} |
|
21 |
+ |
|
22 |
+.simditor-icon-code:before { |
|
23 |
+ content: '\f000'; |
|
24 |
+} |
|
25 |
+ |
|
26 |
+.simditor-icon-bold:before { |
|
27 |
+ content: '\f001'; |
|
28 |
+} |
|
29 |
+ |
|
30 |
+.simditor-icon-italic:before { |
|
31 |
+ content: '\f002'; |
|
32 |
+} |
|
33 |
+ |
|
34 |
+.simditor-icon-underline:before { |
|
35 |
+ content: '\f003'; |
|
36 |
+} |
|
37 |
+ |
|
38 |
+.simditor-icon-times:before { |
|
39 |
+ content: '\f004'; |
|
40 |
+} |
|
41 |
+ |
|
42 |
+.simditor-icon-strikethrough:before { |
|
43 |
+ content: '\f005'; |
|
44 |
+} |
|
45 |
+ |
|
46 |
+.simditor-icon-list-ol:before { |
|
47 |
+ content: '\f006'; |
|
48 |
+} |
|
49 |
+ |
|
50 |
+.simditor-icon-list-ul:before { |
|
51 |
+ content: '\f007'; |
|
52 |
+} |
|
53 |
+ |
|
54 |
+.simditor-icon-quote-left:before { |
|
55 |
+ content: '\f008'; |
|
56 |
+} |
|
57 |
+ |
|
58 |
+.simditor-icon-table:before { |
|
59 |
+ content: '\f009'; |
|
60 |
+} |
|
61 |
+ |
|
62 |
+.simditor-icon-link:before { |
|
63 |
+ content: '\f00a'; |
|
64 |
+} |
|
65 |
+ |
|
66 |
+.simditor-icon-picture-o:before { |
|
67 |
+ content: '\f00b'; |
|
68 |
+} |
|
69 |
+ |
|
70 |
+.simditor-icon-minus:before { |
|
71 |
+ content: '\f00c'; |
|
72 |
+} |
|
73 |
+ |
|
74 |
+.simditor-icon-indent:before { |
|
75 |
+ content: '\f00d'; |
|
76 |
+} |
|
77 |
+ |
|
78 |
+.simditor-icon-outdent:before { |
|
79 |
+ content: '\f00e'; |
|
80 |
+} |
|
81 |
+ |
|
82 |
+.simditor-icon-unlink:before { |
|
83 |
+ content: '\f00f'; |
|
84 |
+} |
|
85 |
+ |
|
86 |
+.simditor-icon-caret-down:before { |
|
87 |
+ content: '\f010'; |
|
88 |
+} |
|
89 |
+ |
|
90 |
+.simditor-icon-caret-right:before { |
|
91 |
+ content: '\f011'; |
|
92 |
+} |
|
93 |
+ |
|
94 |
+.simditor-icon-upload:before { |
|
95 |
+ content: '\f012'; |
|
96 |
+} |
|
97 |
+ |
|
98 |
+.simditor-icon-undo:before { |
|
99 |
+ content: '\f013'; |
|
100 |
+} |
|
101 |
+ |
|
102 |
+.simditor-icon-smile-o:before { |
|
103 |
+ content: '\f014'; |
|
104 |
+} |
|
105 |
+ |
|
106 |
+.simditor-icon-tint:before { |
|
107 |
+ content: '\f015'; |
|
108 |
+} |
|
109 |
+ |
|
110 |
+.simditor-icon-font:before { |
|
111 |
+ content: '\f016'; |
|
112 |
+} |
|
113 |
+ |
|
114 |
+.simditor-icon-html5:before { |
|
115 |
+ content: '\f017'; |
|
116 |
+} |
|
117 |
+ |
|
118 |
+.simditor-icon-mark:before { |
|
119 |
+ content: '\f018'; |
|
120 |
+} |
|
121 |
+ |
|
122 |
+.simditor-icon-align-center:before { |
|
123 |
+ content: '\f019'; |
|
124 |
+} |
|
125 |
+ |
|
126 |
+.simditor-icon-align-left:before { |
|
127 |
+ content: '\f01a'; |
|
128 |
+} |
|
129 |
+ |
|
130 |
+.simditor-icon-align-right:before { |
|
131 |
+ content: '\f01b'; |
|
132 |
+} |
|
133 |
+ |
|
134 |
+.simditor-icon-font-minus:before { |
|
135 |
+ content: '\f01c'; |
|
136 |
+} |
|
137 |
+ |
|
138 |
+.simditor-icon-markdown:before { |
|
139 |
+ content: '\f01d'; |
|
140 |
+} |
|
141 |
+ |
|
142 |
+.simditor-icon-checklist:before { |
|
143 |
+ content: '\f01e'; |
|
144 |
+} |
|
145 |
+ |
|
146 |
+.simditor { |
|
147 |
+ position: relative; |
|
148 |
+ border: 1px solid #c9d8db; |
|
149 |
+} |
|
150 |
+.simditor .simditor-wrapper { |
|
151 |
+ position: relative; |
|
152 |
+ background: #ffffff; |
|
153 |
+} |
|
154 |
+.simditor .simditor-wrapper > textarea { |
|
155 |
+ display: none !important; |
|
156 |
+ width: 100%; |
|
157 |
+ box-sizing: border-box; |
|
158 |
+ font-family: monaco; |
|
159 |
+ font-size: 16px; |
|
160 |
+ line-height: 1.6; |
|
161 |
+ border: none; |
|
162 |
+ padding: 22px 15px 40px; |
|
163 |
+ min-height: 300px; |
|
164 |
+ outline: none; |
|
165 |
+ background: transparent; |
|
166 |
+ resize: none; |
|
167 |
+} |
|
168 |
+.simditor .simditor-wrapper .simditor-placeholder { |
|
169 |
+ display: none; |
|
170 |
+ position: absolute; |
|
171 |
+ left: 0; |
|
172 |
+ z-index: 0; |
|
173 |
+ padding: 22px 15px; |
|
174 |
+ font-size: 16px; |
|
175 |
+ font-family: arial, sans-serif; |
|
176 |
+ line-height: 1.5; |
|
177 |
+ color: #999999; |
|
178 |
+ background: transparent; |
|
179 |
+} |
|
180 |
+.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar { |
|
181 |
+ position: fixed; |
|
182 |
+ top: 0; |
|
183 |
+ z-index: 10; |
|
184 |
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.1); |
|
185 |
+} |
|
186 |
+.simditor .simditor-wrapper .simditor-image-loading { |
|
187 |
+ width: 100%; |
|
188 |
+ height: 100%; |
|
189 |
+ position: absolute; |
|
190 |
+ top: 0; |
|
191 |
+ left: 0; |
|
192 |
+ z-index: 2; |
|
193 |
+} |
|
194 |
+.simditor .simditor-wrapper .simditor-image-loading .progress { |
|
195 |
+ width: 100%; |
|
196 |
+ height: 100%; |
|
197 |
+ background: rgba(0, 0, 0, 0.4); |
|
198 |
+ position: absolute; |
|
199 |
+ bottom: 0; |
|
200 |
+ left: 0; |
|
201 |
+} |
|
202 |
+.simditor .simditor-body { |
|
203 |
+ padding: 22px 15px 40px; |
|
204 |
+ min-height: 300px; |
|
205 |
+ outline: none; |
|
206 |
+ cursor: text; |
|
207 |
+ position: relative; |
|
208 |
+ z-index: 1; |
|
209 |
+ background: transparent; |
|
210 |
+} |
|
211 |
+.simditor .simditor-body a.selected { |
|
212 |
+ background: #b3d4fd; |
|
213 |
+} |
|
214 |
+.simditor .simditor-body a.simditor-mention { |
|
215 |
+ cursor: pointer; |
|
216 |
+} |
|
217 |
+.simditor .simditor-body .simditor-table { |
|
218 |
+ position: relative; |
|
219 |
+} |
|
220 |
+.simditor .simditor-body .simditor-table.resizing { |
|
221 |
+ cursor: col-resize; |
|
222 |
+} |
|
223 |
+.simditor .simditor-body .simditor-table .simditor-resize-handle { |
|
224 |
+ position: absolute; |
|
225 |
+ left: 0; |
|
226 |
+ top: 0; |
|
227 |
+ width: 10px; |
|
228 |
+ height: 100%; |
|
229 |
+ cursor: col-resize; |
|
230 |
+} |
|
231 |
+.simditor .simditor-body pre { |
|
232 |
+ /*min-height: 28px;*/ |
|
233 |
+ box-sizing: border-box; |
|
234 |
+ -moz-box-sizing: border-box; |
|
235 |
+ word-wrap: break-word !important; |
|
236 |
+ white-space: pre-wrap !important; |
|
237 |
+} |
|
238 |
+.simditor .simditor-body img { |
|
239 |
+ cursor: pointer; |
|
240 |
+} |
|
241 |
+.simditor .simditor-body img.selected { |
|
242 |
+ box-shadow: 0 0 0 4px #cccccc; |
|
243 |
+} |
|
244 |
+.simditor .simditor-paste-bin { |
|
245 |
+ position: fixed; |
|
246 |
+ bottom: 10px; |
|
247 |
+ right: 10px; |
|
248 |
+ width: 1px; |
|
249 |
+ height: 20px; |
|
250 |
+ font-size: 1px; |
|
251 |
+ line-height: 1px; |
|
252 |
+ overflow: hidden; |
|
253 |
+ padding: 0; |
|
254 |
+ margin: 0; |
|
255 |
+ opacity: 0; |
|
256 |
+ -webkit-user-select: text; |
|
257 |
+} |
|
258 |
+.simditor .simditor-toolbar { |
|
259 |
+ border-bottom: 1px solid #eeeeee; |
|
260 |
+ background: #ffffff; |
|
261 |
+ width: 100%; |
|
262 |
+} |
|
263 |
+.simditor .simditor-toolbar > ul { |
|
264 |
+ margin: 0; |
|
265 |
+ padding: 0 0 0 6px; |
|
266 |
+ list-style: none; |
|
267 |
+} |
|
268 |
+.simditor .simditor-toolbar > ul > li { |
|
269 |
+ position: relative; |
|
270 |
+ display: inline-block; |
|
271 |
+ font-size: 0; |
|
272 |
+} |
|
273 |
+.simditor .simditor-toolbar > ul > li > span.separator { |
|
274 |
+ display: inline-block; |
|
275 |
+ background: #cfcfcf; |
|
276 |
+ width: 1px; |
|
277 |
+ height: 18px; |
|
278 |
+ margin: 11px 15px; |
|
279 |
+ vertical-align: middle; |
|
280 |
+} |
|
281 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item { |
|
282 |
+ display: inline-block; |
|
283 |
+ width: 46px; |
|
284 |
+ height: 40px; |
|
285 |
+ outline: none; |
|
286 |
+ color: #333333; |
|
287 |
+ font-size: 15px; |
|
288 |
+ line-height: 40px; |
|
289 |
+ vertical-align: middle; |
|
290 |
+ text-align: center; |
|
291 |
+ text-decoration: none; |
|
292 |
+} |
|
293 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item span { |
|
294 |
+ opacity: 0.6; |
|
295 |
+} |
|
296 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item span.simditor-icon { |
|
297 |
+ display: inline; |
|
298 |
+ line-height: normal; |
|
299 |
+} |
|
300 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item:hover span { |
|
301 |
+ opacity: 1; |
|
302 |
+} |
|
303 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.active { |
|
304 |
+ background: #eeeeee; |
|
305 |
+} |
|
306 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.active span { |
|
307 |
+ opacity: 1; |
|
308 |
+} |
|
309 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled { |
|
310 |
+ cursor: default; |
|
311 |
+} |
|
312 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled span { |
|
313 |
+ opacity: 0.3; |
|
314 |
+} |
|
315 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title span:before { |
|
316 |
+ content: "H"; |
|
317 |
+ font-size: 19px; |
|
318 |
+ font-weight: bold; |
|
319 |
+ font-family: 'Times New Roman'; |
|
320 |
+} |
|
321 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h1 span:before { |
|
322 |
+ content: 'H1'; |
|
323 |
+ font-size: 18px; |
|
324 |
+} |
|
325 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h2 span:before { |
|
326 |
+ content: 'H2'; |
|
327 |
+ font-size: 18px; |
|
328 |
+} |
|
329 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h3 span:before { |
|
330 |
+ content: 'H3'; |
|
331 |
+ font-size: 18px; |
|
332 |
+} |
|
333 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image { |
|
334 |
+ position: relative; |
|
335 |
+ overflow: hidden; |
|
336 |
+} |
|
337 |
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image > input[type=file] { |
|
338 |
+ position: absolute; |
|
339 |
+ right: 0px; |
|
340 |
+ top: 0px; |
|
341 |
+ opacity: 0; |
|
342 |
+ font-size: 100px; |
|
343 |
+ cursor: pointer; |
|
344 |
+} |
|
345 |
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item { |
|
346 |
+ position: relative; |
|
347 |
+ z-index: 20; |
|
348 |
+ background: #ffffff; |
|
349 |
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); |
|
350 |
+} |
|
351 |
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item span { |
|
352 |
+ opacity: 1; |
|
353 |
+} |
|
354 |
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-menu { |
|
355 |
+ display: block; |
|
356 |
+} |
|
357 |
+.simditor .simditor-toolbar .toolbar-menu { |
|
358 |
+ display: none; |
|
359 |
+ position: absolute; |
|
360 |
+ top: 40px; |
|
361 |
+ left: 0; |
|
362 |
+ z-index: 21; |
|
363 |
+ background: #ffffff; |
|
364 |
+ text-align: left; |
|
365 |
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.3); |
|
366 |
+} |
|
367 |
+.simditor .simditor-toolbar .toolbar-menu:before { |
|
368 |
+ content: ''; |
|
369 |
+ display: block; |
|
370 |
+ width: 46px; |
|
371 |
+ height: 4px; |
|
372 |
+ background: #ffffff; |
|
373 |
+ position: absolute; |
|
374 |
+ top: -3px; |
|
375 |
+ left: 0; |
|
376 |
+} |
|
377 |
+.simditor .simditor-toolbar .toolbar-menu ul { |
|
378 |
+ min-width: 160px; |
|
379 |
+ list-style: none; |
|
380 |
+ margin: 0; |
|
381 |
+ padding: 10px 1px; |
|
382 |
+} |
|
383 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item { |
|
384 |
+ display: block; |
|
385 |
+ font-size: 16px; |
|
386 |
+ line-height: 2em; |
|
387 |
+ padding: 0 10px; |
|
388 |
+ text-decoration: none; |
|
389 |
+ color: #666666; |
|
390 |
+} |
|
391 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item:hover { |
|
392 |
+ background: #f6f6f6; |
|
393 |
+} |
|
394 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h1 { |
|
395 |
+ font-size: 24px; |
|
396 |
+ color: #333333; |
|
397 |
+} |
|
398 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h2 { |
|
399 |
+ font-size: 22px; |
|
400 |
+ color: #333333; |
|
401 |
+} |
|
402 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h3 { |
|
403 |
+ font-size: 20px; |
|
404 |
+ color: #333333; |
|
405 |
+} |
|
406 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h4 { |
|
407 |
+ font-size: 18px; |
|
408 |
+ color: #333333; |
|
409 |
+} |
|
410 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h5 { |
|
411 |
+ font-size: 16px; |
|
412 |
+ color: #333333; |
|
413 |
+} |
|
414 |
+.simditor .simditor-toolbar .toolbar-menu ul > li .separator { |
|
415 |
+ display: block; |
|
416 |
+ border-top: 1px solid #cccccc; |
|
417 |
+ height: 0; |
|
418 |
+ line-height: 0; |
|
419 |
+ font-size: 0; |
|
420 |
+ margin: 6px 0; |
|
421 |
+} |
|
422 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color { |
|
423 |
+ width: 96px; |
|
424 |
+} |
|
425 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list { |
|
426 |
+ height: 40px; |
|
427 |
+ margin: 10px 6px 6px 10px; |
|
428 |
+ padding: 0; |
|
429 |
+ min-width: 0; |
|
430 |
+} |
|
431 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li { |
|
432 |
+ float: left; |
|
433 |
+ margin: 0 4px 4px 0; |
|
434 |
+} |
|
435 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color { |
|
436 |
+ display: block; |
|
437 |
+ width: 16px; |
|
438 |
+ height: 16px; |
|
439 |
+ background: #dfdfdf; |
|
440 |
+ border-radius: 2px; |
|
441 |
+} |
|
442 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover { |
|
443 |
+ opacity: 0.8; |
|
444 |
+} |
|
445 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default { |
|
446 |
+ background: #333333; |
|
447 |
+} |
|
448 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1 { |
|
449 |
+ background: #E33737; |
|
450 |
+} |
|
451 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2 { |
|
452 |
+ background: #e28b41; |
|
453 |
+} |
|
454 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3 { |
|
455 |
+ background: #c8a732; |
|
456 |
+} |
|
457 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4 { |
|
458 |
+ background: #209361; |
|
459 |
+} |
|
460 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5 { |
|
461 |
+ background: #418caf; |
|
462 |
+} |
|
463 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6 { |
|
464 |
+ background: #aa8773; |
|
465 |
+} |
|
466 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7 { |
|
467 |
+ background: #999999; |
|
468 |
+} |
|
469 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table { |
|
470 |
+ background: #ffffff; |
|
471 |
+ padding: 1px; |
|
472 |
+} |
|
473 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table { |
|
474 |
+ border: none; |
|
475 |
+ border-collapse: collapse; |
|
476 |
+ border-spacing: 0; |
|
477 |
+ table-layout: fixed; |
|
478 |
+} |
|
479 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td { |
|
480 |
+ padding: 0; |
|
481 |
+ cursor: pointer; |
|
482 |
+} |
|
483 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before { |
|
484 |
+ width: 16px; |
|
485 |
+ height: 16px; |
|
486 |
+ border: 1px solid #ffffff; |
|
487 |
+ background: #f3f3f3; |
|
488 |
+ display: block; |
|
489 |
+ content: ""; |
|
490 |
+} |
|
491 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before { |
|
492 |
+ background: #cfcfcf; |
|
493 |
+} |
|
494 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table { |
|
495 |
+ display: none; |
|
496 |
+} |
|
497 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li { |
|
498 |
+ white-space: nowrap; |
|
499 |
+} |
|
500 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image { |
|
501 |
+ position: relative; |
|
502 |
+ overflow: hidden; |
|
503 |
+} |
|
504 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file] { |
|
505 |
+ position: absolute; |
|
506 |
+ right: 0px; |
|
507 |
+ top: 0px; |
|
508 |
+ opacity: 0; |
|
509 |
+ font-size: 100px; |
|
510 |
+ cursor: pointer; |
|
511 |
+} |
|
512 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment { |
|
513 |
+ width: 100%; |
|
514 |
+} |
|
515 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul { |
|
516 |
+ min-width: 100%; |
|
517 |
+} |
|
518 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item { |
|
519 |
+ text-align: center; |
|
520 |
+} |
|
521 |
+.simditor .simditor-popover { |
|
522 |
+ display: none; |
|
523 |
+ padding: 5px 8px 0; |
|
524 |
+ background: #ffffff; |
|
525 |
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); |
|
526 |
+ border-radius: 2px; |
|
527 |
+ position: absolute; |
|
528 |
+ z-index: 2; |
|
529 |
+} |
|
530 |
+.simditor .simditor-popover .settings-field { |
|
531 |
+ margin: 0 0 5px 0; |
|
532 |
+ font-size: 12px; |
|
533 |
+ height: 25px; |
|
534 |
+ line-height: 25px; |
|
535 |
+} |
|
536 |
+.simditor .simditor-popover .settings-field label { |
|
537 |
+ display: inline-block; |
|
538 |
+ margin: 0 5px 0 0; |
|
539 |
+} |
|
540 |
+.simditor .simditor-popover .settings-field input[type=text] { |
|
541 |
+ display: inline-block; |
|
542 |
+ width: 200px; |
|
543 |
+ box-sizing: border-box; |
|
544 |
+ font-size: 12px; |
|
545 |
+} |
|
546 |
+.simditor .simditor-popover .settings-field input[type=text].image-size { |
|
547 |
+ width: 83px; |
|
548 |
+} |
|
549 |
+.simditor .simditor-popover .settings-field .times { |
|
550 |
+ display: inline-block; |
|
551 |
+ width: 26px; |
|
552 |
+ font-size: 12px; |
|
553 |
+ text-align: center; |
|
554 |
+} |
|
555 |
+.simditor .simditor-popover.link-popover .btn-unlink, .simditor .simditor-popover.image-popover .btn-upload, .simditor .simditor-popover.image-popover .btn-restore { |
|
556 |
+ display: inline-block; |
|
557 |
+ margin: 0 0 0 5px; |
|
558 |
+ color: #333333; |
|
559 |
+ font-size: 14px; |
|
560 |
+ outline: 0; |
|
561 |
+} |
|
562 |
+.simditor .simditor-popover.link-popover .btn-unlink span, .simditor .simditor-popover.image-popover .btn-upload span, .simditor .simditor-popover.image-popover .btn-restore span { |
|
563 |
+ opacity: 0.6; |
|
564 |
+} |
|
565 |
+.simditor .simditor-popover.link-popover .btn-unlink:hover span, .simditor .simditor-popover.image-popover .btn-upload:hover span, .simditor .simditor-popover.image-popover .btn-restore:hover span { |
|
566 |
+ opacity: 1; |
|
567 |
+} |
|
568 |
+.simditor .simditor-popover.image-popover .btn-upload { |
|
569 |
+ position: relative; |
|
570 |
+ display: inline-block; |
|
571 |
+ overflow: hidden; |
|
572 |
+ vertical-align: middle; |
|
573 |
+} |
|
574 |
+.simditor .simditor-popover.image-popover .btn-upload input[type=file] { |
|
575 |
+ position: absolute; |
|
576 |
+ right: 0px; |
|
577 |
+ top: 0px; |
|
578 |
+ opacity: 0; |
|
579 |
+ height: 100%; |
|
580 |
+ width: 28px; |
|
581 |
+} |
|
582 |
+.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar { |
|
583 |
+ position: absolute; |
|
584 |
+ top: 0; |
|
585 |
+ z-index: 10; |
|
586 |
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.1); |
|
587 |
+} |
|
588 |
+ |
|
589 |
+.simditor .simditor-body, .editor-style { |
|
590 |
+ font-size: 16px; |
|
591 |
+ font-family: arial, sans-serif; |
|
592 |
+ line-height: 1.6; |
|
593 |
+ color: #333; |
|
594 |
+ outline: none; |
|
595 |
+ word-wrap: break-word; |
|
596 |
+} |
|
597 |
+.simditor .simditor-body > :first-child, .editor-style > :first-child { |
|
598 |
+ margin-top: 0 !important; |
|
599 |
+} |
|
600 |
+.simditor .simditor-body a, .editor-style a { |
|
601 |
+ color: #4298BA; |
|
602 |
+ text-decoration: none; |
|
603 |
+ word-break: break-all; |
|
604 |
+} |
|
605 |
+.simditor .simditor-body a:visited, .editor-style a:visited { |
|
606 |
+ color: #4298BA; |
|
607 |
+} |
|
608 |
+.simditor .simditor-body a:hover, .editor-style a:hover { |
|
609 |
+ color: #0F769F; |
|
610 |
+} |
|
611 |
+.simditor .simditor-body a:active, .editor-style a:active { |
|
612 |
+ color: #9E792E; |
|
613 |
+} |
|
614 |
+.simditor .simditor-body a:hover, .simditor .simditor-body a:active, .editor-style a:hover, .editor-style a:active { |
|
615 |
+ outline: 0; |
|
616 |
+} |
|
617 |
+.simditor .simditor-body h1, .simditor .simditor-body h2, .simditor .simditor-body h3, .simditor .simditor-body h4, .simditor .simditor-body h5, .simditor .simditor-body h6, .editor-style h1, .editor-style h2, .editor-style h3, .editor-style h4, .editor-style h5, .editor-style h6 { |
|
618 |
+ font-weight: normal; |
|
619 |
+ margin: 40px 0 20px; |
|
620 |
+ color: #000000; |
|
621 |
+} |
|
622 |
+.simditor .simditor-body h1, .editor-style h1 { |
|
623 |
+ font-size: 24px; |
|
624 |
+} |
|
625 |
+.simditor .simditor-body h2, .editor-style h2 { |
|
626 |
+ font-size: 22px; |
|
627 |
+} |
|
628 |
+.simditor .simditor-body h3, .editor-style h3 { |
|
629 |
+ font-size: 20px; |
|
630 |
+} |
|
631 |
+.simditor .simditor-body h4, .editor-style h4 { |
|
632 |
+ font-size: 18px; |
|
633 |
+} |
|
634 |
+.simditor .simditor-body h5, .editor-style h5 { |
|
635 |
+ font-size: 16px; |
|
636 |
+} |
|
637 |
+.simditor .simditor-body h6, .editor-style h6 { |
|
638 |
+ font-size: 16px; |
|
639 |
+} |
|
640 |
+.simditor .simditor-body p, .simditor .simditor-body div, .editor-style p, .editor-style div { |
|
641 |
+ word-wrap: break-word; |
|
642 |
+ margin: 0 0 15px 0; |
|
643 |
+ color: #333; |
|
644 |
+ word-wrap: break-word; |
|
645 |
+} |
|
646 |
+.simditor .simditor-body b, .simditor .simditor-body strong, .editor-style b, .editor-style strong { |
|
647 |
+ font-weight: bold; |
|
648 |
+} |
|
649 |
+.simditor .simditor-body i, .simditor .simditor-body em, .editor-style i, .editor-style em { |
|
650 |
+ font-style: italic; |
|
651 |
+} |
|
652 |
+.simditor .simditor-body u, .editor-style u { |
|
653 |
+ text-decoration: underline; |
|
654 |
+} |
|
655 |
+.simditor .simditor-body strike, .simditor .simditor-body del, .editor-style strike, .editor-style del { |
|
656 |
+ text-decoration: line-through; |
|
657 |
+} |
|
658 |
+.simditor .simditor-body ul, .simditor .simditor-body ol, .editor-style ul, .editor-style ol { |
|
659 |
+ list-style: disc outside none; |
|
660 |
+ margin: 15px 0; |
|
661 |
+ padding: 0 0 0 40px; |
|
662 |
+ line-height: 1.6; |
|
663 |
+} |
|
664 |
+.simditor .simditor-body ul ul, .simditor .simditor-body ul ol, .simditor .simditor-body ol ul, .simditor .simditor-body ol ol, .editor-style ul ul, .editor-style ul ol, .editor-style ol ul, .editor-style ol ol { |
|
665 |
+ padding-left: 30px; |
|
666 |
+} |
|
667 |
+.simditor .simditor-body ul ul, .simditor .simditor-body ol ul, .editor-style ul ul, .editor-style ol ul { |
|
668 |
+ list-style: circle outside none; |
|
669 |
+} |
|
670 |
+.simditor .simditor-body ul ul ul, .simditor .simditor-body ol ul ul, .editor-style ul ul ul, .editor-style ol ul ul { |
|
671 |
+ list-style: square outside none; |
|
672 |
+} |
|
673 |
+.simditor .simditor-body ol, .editor-style ol { |
|
674 |
+ list-style: decimal; |
|
675 |
+} |
|
676 |
+.simditor .simditor-body blockquote, .editor-style blockquote { |
|
677 |
+ border-left: 6px solid #ddd; |
|
678 |
+ padding: 5px 0 5px 10px; |
|
679 |
+ margin: 15px 0 15px 15px; |
|
680 |
+} |
|
681 |
+.simditor .simditor-body blockquote > :first-child, .editor-style blockquote > :first-child { |
|
682 |
+ margin-top: 0; |
|
683 |
+} |
|
684 |
+.simditor .simditor-body code, .editor-style code { |
|
685 |
+ display: inline-block; |
|
686 |
+ padding: 0 4px; |
|
687 |
+ margin: 0 5px; |
|
688 |
+ background: #eeeeee; |
|
689 |
+ border-radius: 3px; |
|
690 |
+ font-size: 13px; |
|
691 |
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace; |
|
692 |
+} |
|
693 |
+.simditor .simditor-body pre, .editor-style pre { |
|
694 |
+ padding: 10px 5px 10px 10px; |
|
695 |
+ margin: 15px 0; |
|
696 |
+ display: block; |
|
697 |
+ line-height: 18px; |
|
698 |
+ background: #F0F0F0; |
|
699 |
+ border-radius: 3px; |
|
700 |
+ font-size: 13px; |
|
701 |
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace; |
|
702 |
+ white-space: pre; |
|
703 |
+ word-wrap: normal; |
|
704 |
+ overflow-x: auto; |
|
705 |
+} |
|
706 |
+.simditor .simditor-body pre code, .editor-style pre code { |
|
707 |
+ display: block; |
|
708 |
+ padding: 0; |
|
709 |
+ margin: 0; |
|
710 |
+ background: none; |
|
711 |
+ border-radius: 0; |
|
712 |
+} |
|
713 |
+.simditor .simditor-body hr, .editor-style hr { |
|
714 |
+ display: block; |
|
715 |
+ height: 0px; |
|
716 |
+ border: 0; |
|
717 |
+ border-top: 1px solid #ccc; |
|
718 |
+ margin: 15px 0; |
|
719 |
+ padding: 0; |
|
720 |
+} |
|
721 |
+.simditor .simditor-body table, .editor-style table { |
|
722 |
+ width: 100%; |
|
723 |
+ table-layout: fixed; |
|
724 |
+ border-collapse: collapse; |
|
725 |
+ border-spacing: 0; |
|
726 |
+ margin: 15px 0; |
|
727 |
+} |
|
728 |
+.simditor .simditor-body table thead, .editor-style table thead { |
|
729 |
+ background-color: #f9f9f9; |
|
730 |
+} |
|
731 |
+.simditor .simditor-body table td, .simditor .simditor-body table th, .editor-style table td, .editor-style table th { |
|
732 |
+ min-width: 40px; |
|
733 |
+ height: 30px; |
|
734 |
+ border: 1px solid #ccc; |
|
735 |
+ vertical-align: top; |
|
736 |
+ padding: 2px 4px; |
|
737 |
+ text-align: left; |
|
738 |
+ box-sizing: border-box; |
|
739 |
+} |
|
740 |
+.simditor .simditor-body table td.active, .simditor .simditor-body table th.active, .editor-style table td.active, .editor-style table th.active { |
|
741 |
+ background-color: #ffffee; |
|
742 |
+} |
|
743 |
+.simditor .simditor-body img, .editor-style img { |
|
744 |
+ margin: 0 5px; |
|
745 |
+ vertical-align: middle; |
|
746 |
+} |
@@ -0,0 +1,8 @@ |
||
1 |
+/*! |
|
2 |
+* Simditor v2.3.6 |
|
3 |
+* http://simditor.tower.im/ |
|
4 |
+* 2015-12-21 |
|
5 |
+*/@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,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) format("woff");font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'}.simditor{position:relative;border:1px solid #c9d8db}.simditor .simditor-wrapper{position:relative;background:#fff}.simditor .simditor-wrapper>textarea{display:none!important;width:100%;box-sizing:border-box;font-family:monaco;font-size:16px;line-height:1.6;border:0;padding:22px 15px 40px;min-height:300px;outline:0;background:transparent;resize:none}.simditor .simditor-wrapper .simditor-placeholder{display:none;position:absolute;left:0;z-index:0;padding:22px 15px;font-size:16px;font-family:arial,sans-serif;line-height:1.5;color:#999;background:transparent}.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar{position:fixed;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-wrapper .simditor-image-loading{width:100%;height:100%;position:absolute;top:0;left:0;z-index:2}.simditor .simditor-wrapper .simditor-image-loading .progress{width:100%;height:100%;background:rgba(0,0,0,0.4);position:absolute;bottom:0;left:0}.simditor .simditor-body{padding:22px 15px 40px;min-height:300px;outline:0;cursor:text;position:relative;z-index:1;background:transparent}.simditor .simditor-body a.selected{background:#b3d4fd}.simditor .simditor-body a.simditor-mention{cursor:pointer}.simditor .simditor-body .simditor-table{position:relative}.simditor .simditor-body .simditor-table.resizing{cursor:col-resize}.simditor .simditor-body .simditor-table .simditor-resize-handle{position:absolute;left:0;top:0;width:10px;height:100%;cursor:col-resize}.simditor .simditor-body pre{box-sizing:border-box;-moz-box-sizing:border-box;word-wrap:break-word!important;white-space:pre-wrap!important}.simditor .simditor-body img{cursor:pointer}.simditor .simditor-body img.selected{box-shadow:0 0 0 4px #ccc}.simditor .simditor-paste-bin{position:fixed;bottom:10px;right:10px;width:1px;height:20px;font-size:1px;line-height:1px;overflow:hidden;padding:0;margin:0;opacity:0;-webkit-user-select:text}.simditor .simditor-toolbar{border-bottom:1px solid #eee;background:#fff;width:100%}.simditor .simditor-toolbar>ul{margin:0;padding:0 0 0 6px;list-style:none}.simditor .simditor-toolbar>ul>li{position:relative;display:inline-block;font-size:0}.simditor .simditor-toolbar>ul>li>span.separator{display:inline-block;background:#cfcfcf;width:1px;height:18px;margin:11px 15px;vertical-align:middle} |
|
6 |
+.simditor .simditor-toolbar>ul>li>.toolbar-item{display:inline-block;width:46px;height:40px;outline:0;color:#333;font-size:15px;line-height:40px;vertical-align:middle;text-align:center;text-decoration:none}.simditor .simditor-toolbar>ul>li>.toolbar-item span{opacity:.6}.simditor .simditor-toolbar>ul>li>.toolbar-item span.simditor-icon{display:inline;line-height:normal}.simditor .simditor-toolbar>ul>li>.toolbar-item:hover span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.active{background:#eee}.simditor .simditor-toolbar>ul>li>.toolbar-item.active span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled{cursor:default}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled span{opacity:.3}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title span:before{content:"H";font-size:19px;font-weight:bold;font-family:'Times New Roman'}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h1 span:before{content:'H1';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h2 span:before{content:'H2';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h3 span:before{content:'H3';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image{position:relative;overflow:hidden}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image>input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item{position:relative;z-index:20;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item span{opacity:1}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-menu{display:block}.simditor .simditor-toolbar .toolbar-menu{display:none;position:absolute;top:40px;left:0;z-index:21;background:#fff;text-align:left;box-shadow:0 0 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar .toolbar-menu:before{content:'';display:block;width:46px;height:4px;background:#fff;position:absolute;top:-3px;left:0}.simditor .simditor-toolbar .toolbar-menu ul{min-width:160px;list-style:none;margin:0;padding:10px 1px}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item{display:block;font-size:16px;line-height:2em;padding:0 10px;text-decoration:none;color:#666}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item:hover{background:#f6f6f6}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h1{font-size:24px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h2{font-size:22px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h3{font-size:20px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h4{font-size:18px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h5{font-size:16px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .separator{display:block;border-top:1px solid #ccc;height:0;line-height:0;font-size:0;margin:6px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color{width:96px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list{height:40px;margin:10px 6px 6px 10px;padding:0;min-width:0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li{float:left;margin:0 4px 4px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color{display:block;width:16px;height:16px;background:#dfdfdf;border-radius:2px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover{opacity:.8}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default{background:#333}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1{background:#e33737}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2{background:#e28b41}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3{background:#c8a732}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4{background:#209361}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5{background:#418caf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6{background:#aa8773}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7{background:#999}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table{background:#fff;padding:1px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table{border:0;border-collapse:collapse;border-spacing:0;table-layout:fixed}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td{padding:0;cursor:pointer} |
|
7 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before{width:16px;height:16px;border:1px solid #fff;background:#f3f3f3;display:block;content:""}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before{background:#cfcfcf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table{display:none}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li{white-space:nowrap}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image{position:relative;overflow:hidden}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment{width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul{min-width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item{text-align:center}.simditor .simditor-popover{display:none;padding:5px 8px 0;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.4);border-radius:2px;position:absolute;z-index:2}.simditor .simditor-popover .settings-field{margin:0 0 5px 0;font-size:12px;height:25px;line-height:25px}.simditor .simditor-popover .settings-field label{display:inline-block;margin:0 5px 0 0}.simditor .simditor-popover .settings-field input[type=text]{display:inline-block;width:200px;box-sizing:border-box;font-size:12px}.simditor .simditor-popover .settings-field input[type=text].image-size{width:83px}.simditor .simditor-popover .settings-field .times{display:inline-block;width:26px;font-size:12px;text-align:center}.simditor .simditor-popover.link-popover .btn-unlink,.simditor .simditor-popover.image-popover .btn-upload,.simditor .simditor-popover.image-popover .btn-restore{display:inline-block;margin:0 0 0 5px;color:#333;font-size:14px;outline:0}.simditor .simditor-popover.link-popover .btn-unlink span,.simditor .simditor-popover.image-popover .btn-upload span,.simditor .simditor-popover.image-popover .btn-restore span{opacity:.6}.simditor .simditor-popover.link-popover .btn-unlink:hover span,.simditor .simditor-popover.image-popover .btn-upload:hover span,.simditor .simditor-popover.image-popover .btn-restore:hover span{opacity:1}.simditor .simditor-popover.image-popover .btn-upload{position:relative;display:inline-block;overflow:hidden;vertical-align:middle}.simditor .simditor-popover.image-popover .btn-upload input[type=file]{position:absolute;right:0;top:0;opacity:0;height:100%;width:28px}.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar{position:absolute;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-body,.editor-style{font-size:16px;font-family:arial,sans-serif;line-height:1.6;color:#333;outline:0;word-wrap:break-word}.simditor .simditor-body>:first-child,.editor-style>:first-child{margin-top:0!important}.simditor .simditor-body a,.editor-style a{color:#4298ba;text-decoration:none;word-break:break-all}.simditor .simditor-body a:visited,.editor-style a:visited{color:#4298ba}.simditor .simditor-body a:hover,.editor-style a:hover{color:#0f769f}.simditor .simditor-body a:active,.editor-style a:active{color:#9e792e}.simditor .simditor-body a:hover,.simditor .simditor-body a:active,.editor-style a:hover,.editor-style a:active{outline:0}.simditor .simditor-body h1,.simditor .simditor-body h2,.simditor .simditor-body h3,.simditor .simditor-body h4,.simditor .simditor-body h5,.simditor .simditor-body h6,.editor-style h1,.editor-style h2,.editor-style h3,.editor-style h4,.editor-style h5,.editor-style h6{font-weight:normal;margin:40px 0 20px;color:#000}.simditor .simditor-body h1,.editor-style h1{font-size:24px}.simditor .simditor-body h2,.editor-style h2{font-size:22px}.simditor .simditor-body h3,.editor-style h3{font-size:20px}.simditor .simditor-body h4,.editor-style h4{font-size:18px}.simditor .simditor-body h5,.editor-style h5{font-size:16px}.simditor .simditor-body h6,.editor-style h6{font-size:16px}.simditor .simditor-body p,.simditor .simditor-body div,.editor-style p,.editor-style div{word-wrap:break-word;margin:0 0 15px 0;color:#333;word-wrap:break-word}.simditor .simditor-body b,.simditor .simditor-body strong,.editor-style b,.editor-style strong{font-weight:bold}.simditor .simditor-body i,.simditor .simditor-body em,.editor-style i,.editor-style em{font-style:italic}.simditor .simditor-body u,.editor-style u{text-decoration:underline}.simditor .simditor-body strike,.simditor .simditor-body del,.editor-style strike,.editor-style del{text-decoration:line-through}.simditor .simditor-body ul,.simditor .simditor-body ol,.editor-style ul,.editor-style ol{list-style:disc outside none;margin:15px 0;padding:0 0 0 40px;line-height:1.6}.simditor .simditor-body ul ul,.simditor .simditor-body ul ol,.simditor .simditor-body ol ul,.simditor .simditor-body ol ol,.editor-style ul ul,.editor-style ul ol,.editor-style ol ul,.editor-style ol ol{padding-left:30px} |
|
8 |
+.simditor .simditor-body ul ul,.simditor .simditor-body ol ul,.editor-style ul ul,.editor-style ol ul{list-style:circle outside none}.simditor .simditor-body ul ul ul,.simditor .simditor-body ol ul ul,.editor-style ul ul ul,.editor-style ol ul ul{list-style:square outside none}.simditor .simditor-body ol,.editor-style ol{list-style:decimal}.simditor .simditor-body blockquote,.editor-style blockquote{border-left:6px solid #ddd;padding:5px 0 5px 10px;margin:15px 0 15px 15px}.simditor .simditor-body blockquote>:first-child,.editor-style blockquote>:first-child{margin-top:0}.simditor .simditor-body code,.editor-style code{display:inline-block;padding:0 4px;margin:0 5px;background:#eee;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace}.simditor .simditor-body pre,.editor-style pre{padding:10px 5px 10px 10px;margin:15px 0;display:block;line-height:18px;background:#f0f0f0;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace;white-space:pre;word-wrap:normal;overflow-x:auto}.simditor .simditor-body pre code,.editor-style pre code{display:block;padding:0;margin:0;background:0;border-radius:0}.simditor .simditor-body hr,.editor-style hr{display:block;height:0;border:0;border-top:1px solid #ccc;margin:15px 0;padding:0}.simditor .simditor-body table,.editor-style table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:15px 0}.simditor .simditor-body table thead,.editor-style table thead{background-color:#f9f9f9}.simditor .simditor-body table td,.simditor .simditor-body table th,.editor-style table td,.editor-style table th{min-width:40px;height:30px;border:1px solid #ccc;vertical-align:top;padding:2px 4px;text-align:left;box-sizing:border-box}.simditor .simditor-body table td.active,.simditor .simditor-body table th.active,.editor-style table td.active,.editor-style table th.active{background-color:#ffe}.simditor .simditor-body img,.editor-style img{margin:0 5px;vertical-align:middle}.simditor .markdown-editor{display:none}.simditor .markdown-editor textarea{display:block;width:100%;min-height:200px;box-sizing:border-box;padding:22px 15px 40px;border:0;border-bottom:1px solid #dfdfdf;resize:none;outline:0;font-size:16px}.simditor.simditor-markdown .markdown-editor{display:block}.simditor.simditor-markdown .simditor-body{min-height:100px;background:#f3f3f3}.simditor.simditor-markdown .simditor-placeholder{display:none!important}.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon{font-size:18px}.simditor .simditor-body .simditor-checklist{margin:15px 0;padding:0 0 0 40px;line-height:1.6;list-style-type:none}.simditor .simditor-body .simditor-checklist>li{margin:0;pointer-events:none}.simditor .simditor-body .simditor-checklist>li::before{content:'';pointer-events:all;display:inline-block;margin:0 5px 0 -25px;width:20px;height:20px;cursor:default;vertical-align:middle;background-image:url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw==")}.simditor .simditor-body .simditor-checklist>li[checked]::before{background-image:url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw==")}@font-face{font-family:'icomoon';src:url("../fonts/icomoon.eot?4vkjot");src:url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"),url("../fonts/icomoon.ttf?4vkjot") format("truetype"),url("../fonts/icomoon.woff?4vkjot") format("woff"),url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg");font-weight:normal;font-style:normal}[class^="icon-"],[class*=" icon-"]{font-family:'icomoon';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-fullscreen:before{content:"\e600"}.simditor-fullscreen{overflow:hidden}.simditor-fullscreen .simditor{position:fixed;top:0;left:0;z-index:9999;width:100%}.simditor-fullscreen .simditor .simditor-body{overflow:auto} |
@@ -0,0 +1,8 @@ |
||
1 |
+/*! |
|
2 |
+* Simditor v2.3.6 |
|
3 |
+* http://simditor.tower.im/ |
|
4 |
+* 2015-12-21 |
|
5 |
+*/@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,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) format("woff");font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'}.simditor{position:relative;border:1px solid #c9d8db}.simditor .simditor-wrapper{position:relative;background:#fff}.simditor .simditor-wrapper>textarea{display:none!important;width:100%;box-sizing:border-box;font-family:monaco;font-size:16px;line-height:1.6;border:0;padding:22px 15px 40px;min-height:300px;outline:0;background:transparent;resize:none}.simditor .simditor-wrapper .simditor-placeholder{display:none;position:absolute;left:0;z-index:0;padding:22px 15px;font-size:16px;font-family:arial,sans-serif;line-height:1.5;color:#999;background:transparent}.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar{position:fixed;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-wrapper .simditor-image-loading{width:100%;height:100%;position:absolute;top:0;left:0;z-index:2}.simditor .simditor-wrapper .simditor-image-loading .progress{width:100%;height:100%;background:rgba(0,0,0,0.4);position:absolute;bottom:0;left:0}.simditor .simditor-body{padding:22px 15px 40px;min-height:300px;outline:0;cursor:text;position:relative;z-index:1;background:transparent}.simditor .simditor-body a.selected{background:#b3d4fd}.simditor .simditor-body a.simditor-mention{cursor:pointer}.simditor .simditor-body .simditor-table{position:relative}.simditor .simditor-body .simditor-table.resizing{cursor:col-resize}.simditor .simditor-body .simditor-table .simditor-resize-handle{position:absolute;left:0;top:0;width:10px;height:100%;cursor:col-resize}.simditor .simditor-body pre{box-sizing:border-box;-moz-box-sizing:border-box;word-wrap:break-word!important;white-space:pre-wrap!important}.simditor .simditor-body img{cursor:pointer}.simditor .simditor-body img.selected{box-shadow:0 0 0 4px #ccc}.simditor .simditor-paste-bin{position:fixed;bottom:10px;right:10px;width:1px;height:20px;font-size:1px;line-height:1px;overflow:hidden;padding:0;margin:0;opacity:0;-webkit-user-select:text}.simditor .simditor-toolbar{border-bottom:1px solid #eee;background:#fff;width:100%}.simditor .simditor-toolbar>ul{margin:0;padding:0 0 0 6px;list-style:none}.simditor .simditor-toolbar>ul>li{position:relative;display:inline-block;font-size:0}.simditor .simditor-toolbar>ul>li>span.separator{display:inline-block;background:#cfcfcf;width:1px;height:18px;margin:11px 15px;vertical-align:middle} |
|
6 |
+.simditor .simditor-toolbar>ul>li>.toolbar-item{display:inline-block;width:46px;height:40px;outline:0;color:#333;font-size:15px;line-height:40px;vertical-align:middle;text-align:center;text-decoration:none}.simditor .simditor-toolbar>ul>li>.toolbar-item span{opacity:.6}.simditor .simditor-toolbar>ul>li>.toolbar-item span.simditor-icon{display:inline;line-height:normal}.simditor .simditor-toolbar>ul>li>.toolbar-item:hover span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.active{background:#eee}.simditor .simditor-toolbar>ul>li>.toolbar-item.active span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled{cursor:default}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled span{opacity:.3}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title span:before{content:"H";font-size:19px;font-weight:bold;font-family:'Times New Roman'}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h1 span:before{content:'H1';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h2 span:before{content:'H2';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h3 span:before{content:'H3';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image{position:relative;overflow:hidden}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image>input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item{position:relative;z-index:20;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item span{opacity:1}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-menu{display:block}.simditor .simditor-toolbar .toolbar-menu{display:none;position:absolute;top:40px;left:0;z-index:21;background:#fff;text-align:left;box-shadow:0 0 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar .toolbar-menu:before{content:'';display:block;width:46px;height:4px;background:#fff;position:absolute;top:-3px;left:0}.simditor .simditor-toolbar .toolbar-menu ul{min-width:160px;list-style:none;margin:0;padding:10px 1px}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item{display:block;font-size:16px;line-height:2em;padding:0 10px;text-decoration:none;color:#666}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item:hover{background:#f6f6f6}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h1{font-size:24px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h2{font-size:22px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h3{font-size:20px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h4{font-size:18px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h5{font-size:16px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .separator{display:block;border-top:1px solid #ccc;height:0;line-height:0;font-size:0;margin:6px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color{width:96px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list{height:40px;margin:10px 6px 6px 10px;padding:0;min-width:0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li{float:left;margin:0 4px 4px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color{display:block;width:16px;height:16px;background:#dfdfdf;border-radius:2px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover{opacity:.8}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default{background:#333}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1{background:#e33737}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2{background:#e28b41}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3{background:#c8a732}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4{background:#209361}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5{background:#418caf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6{background:#aa8773}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7{background:#999}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table{background:#fff;padding:1px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table{border:0;border-collapse:collapse;border-spacing:0;table-layout:fixed}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td{padding:0;cursor:pointer} |
|
7 |
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before{width:16px;height:16px;border:1px solid #fff;background:#f3f3f3;display:block;content:""}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before{background:#cfcfcf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table{display:none}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li{white-space:nowrap}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image{position:relative;overflow:hidden}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment{width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul{min-width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item{text-align:center}.simditor .simditor-popover{display:none;padding:5px 8px 0;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.4);border-radius:2px;position:absolute;z-index:2}.simditor .simditor-popover .settings-field{margin:0 0 5px 0;font-size:12px;height:25px;line-height:25px}.simditor .simditor-popover .settings-field label{display:inline-block;margin:0 5px 0 0}.simditor .simditor-popover .settings-field input[type=text]{display:inline-block;width:200px;box-sizing:border-box;font-size:12px}.simditor .simditor-popover .settings-field input[type=text].image-size{width:83px}.simditor .simditor-popover .settings-field .times{display:inline-block;width:26px;font-size:12px;text-align:center}.simditor .simditor-popover.link-popover .btn-unlink,.simditor .simditor-popover.image-popover .btn-upload,.simditor .simditor-popover.image-popover .btn-restore{display:inline-block;margin:0 0 0 5px;color:#333;font-size:14px;outline:0}.simditor .simditor-popover.link-popover .btn-unlink span,.simditor .simditor-popover.image-popover .btn-upload span,.simditor .simditor-popover.image-popover .btn-restore span{opacity:.6}.simditor .simditor-popover.link-popover .btn-unlink:hover span,.simditor .simditor-popover.image-popover .btn-upload:hover span,.simditor .simditor-popover.image-popover .btn-restore:hover span{opacity:1}.simditor .simditor-popover.image-popover .btn-upload{position:relative;display:inline-block;overflow:hidden;vertical-align:middle}.simditor .simditor-popover.image-popover .btn-upload input[type=file]{position:absolute;right:0;top:0;opacity:0;height:100%;width:28px}.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar{position:absolute;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-body,.editor-style{font-size:16px;font-family:arial,sans-serif;line-height:1.6;color:#333;outline:0;word-wrap:break-word}.simditor .simditor-body>:first-child,.editor-style>:first-child{margin-top:0!important}.simditor .simditor-body a,.editor-style a{color:#4298ba;text-decoration:none;word-break:break-all}.simditor .simditor-body a:visited,.editor-style a:visited{color:#4298ba}.simditor .simditor-body a:hover,.editor-style a:hover{color:#0f769f}.simditor .simditor-body a:active,.editor-style a:active{color:#9e792e}.simditor .simditor-body a:hover,.simditor .simditor-body a:active,.editor-style a:hover,.editor-style a:active{outline:0}.simditor .simditor-body h1,.simditor .simditor-body h2,.simditor .simditor-body h3,.simditor .simditor-body h4,.simditor .simditor-body h5,.simditor .simditor-body h6,.editor-style h1,.editor-style h2,.editor-style h3,.editor-style h4,.editor-style h5,.editor-style h6{font-weight:normal;margin:40px 0 20px;color:#000}.simditor .simditor-body h1,.editor-style h1{font-size:24px}.simditor .simditor-body h2,.editor-style h2{font-size:22px}.simditor .simditor-body h3,.editor-style h3{font-size:20px}.simditor .simditor-body h4,.editor-style h4{font-size:18px}.simditor .simditor-body h5,.editor-style h5{font-size:16px}.simditor .simditor-body h6,.editor-style h6{font-size:16px}.simditor .simditor-body p,.simditor .simditor-body div,.editor-style p,.editor-style div{word-wrap:break-word;margin:0 0 15px 0;color:#333;word-wrap:break-word}.simditor .simditor-body b,.simditor .simditor-body strong,.editor-style b,.editor-style strong{font-weight:bold}.simditor .simditor-body i,.simditor .simditor-body em,.editor-style i,.editor-style em{font-style:italic}.simditor .simditor-body u,.editor-style u{text-decoration:underline}.simditor .simditor-body strike,.simditor .simditor-body del,.editor-style strike,.editor-style del{text-decoration:line-through}.simditor .simditor-body ul,.simditor .simditor-body ol,.editor-style ul,.editor-style ol{list-style:disc outside none;margin:15px 0;padding:0 0 0 40px;line-height:1.6}.simditor .simditor-body ul ul,.simditor .simditor-body ul ol,.simditor .simditor-body ol ul,.simditor .simditor-body ol ol,.editor-style ul ul,.editor-style ul ol,.editor-style ol ul,.editor-style ol ol{padding-left:30px} |
|
8 |
+.simditor .simditor-body ul ul,.simditor .simditor-body ol ul,.editor-style ul ul,.editor-style ol ul{list-style:circle outside none}.simditor .simditor-body ul ul ul,.simditor .simditor-body ol ul ul,.editor-style ul ul ul,.editor-style ol ul ul{list-style:square outside none}.simditor .simditor-body ol,.editor-style ol{list-style:decimal}.simditor .simditor-body blockquote,.editor-style blockquote{border-left:6px solid #ddd;padding:5px 0 5px 10px;margin:15px 0 15px 15px}.simditor .simditor-body blockquote>:first-child,.editor-style blockquote>:first-child{margin-top:0}.simditor .simditor-body code,.editor-style code{display:inline-block;padding:0 4px;margin:0 5px;background:#eee;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace}.simditor .simditor-body pre,.editor-style pre{padding:10px 5px 10px 10px;margin:15px 0;display:block;line-height:18px;background:#f0f0f0;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace;white-space:pre;word-wrap:normal;overflow-x:auto}.simditor .simditor-body pre code,.editor-style pre code{display:block;padding:0;margin:0;background:0;border-radius:0}.simditor .simditor-body hr,.editor-style hr{display:block;height:0;border:0;border-top:1px solid #ccc;margin:15px 0;padding:0}.simditor .simditor-body table,.editor-style table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:15px 0}.simditor .simditor-body table thead,.editor-style table thead{background-color:#f9f9f9}.simditor .simditor-body table td,.simditor .simditor-body table th,.editor-style table td,.editor-style table th{min-width:40px;height:30px;border:1px solid #ccc;vertical-align:top;padding:2px 4px;text-align:left;box-sizing:border-box}.simditor .simditor-body table td.active,.simditor .simditor-body table th.active,.editor-style table td.active,.editor-style table th.active{background-color:#ffe}.simditor .simditor-body img,.editor-style img{margin:0 5px;vertical-align:middle} |
@@ -0,0 +1,4 @@ |
||
1 |
+@charset "UTF-8"; |
|
2 |
+ |
|
3 |
+@import 'fonticon'; |
|
4 |
+@import 'editor'; |
@@ -0,0 +1,3 @@ |
||
1 |
+<div class="django-simditor-widget" data-field-id="{{id}}" style="display: inline-block;"> |
|
2 |
+ <textarea{{ final_attrs|safe }} data-processed="0" data-config='{{config|safe}}' data-id="{{id}}" data-type="simditortype">{{ value }}</textarea> |
|
3 |
+</div> |
@@ -0,0 +1,39 @@ |
||
1 |
+"""simditor urls.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+import django |
|
5 |
+ |
|
6 |
+from django.conf import settings |
|
7 |
+from django.conf.urls import url, static |
|
8 |
+from django.contrib.admin.views.decorators import staff_member_required |
|
9 |
+ |
|
10 |
+from . import views |
|
11 |
+ |
|
12 |
+if django.VERSION >= (2, 0): |
|
13 |
+ # pylint disable=C0103 |
|
14 |
+ from django.urls import path |
|
15 |
+ urlpatterns = [ |
|
16 |
+ path('upload/', staff_member_required(views.UPLOAD), |
|
17 |
+ name='simditor_upload'), |
|
18 |
+ ] |
|
19 |
+elif django.VERSION >= (1, 8): |
|
20 |
+ # pylint disable=C0103 |
|
21 |
+ urlpatterns = [ |
|
22 |
+ url(r'^upload/', staff_member_required(views.UPLOAD), |
|
23 |
+ name='simditor_upload'), |
|
24 |
+ ] |
|
25 |
+else: |
|
26 |
+ from django.conf.urls import patterns # pylint disable=C0411 |
|
27 |
+ |
|
28 |
+ # pylint disable=C0103 |
|
29 |
+ urlpatterns = patterns( |
|
30 |
+ '', |
|
31 |
+ url(r'^upload/', staff_member_required(views.UPLOAD), |
|
32 |
+ name='simditor_upload'), |
|
33 |
+ ) |
|
34 |
+ |
|
35 |
+if settings.DEBUG: |
|
36 |
+ urlpatterns += static.static(settings.MEDIA_URL, |
|
37 |
+ document_root=settings.MEDIA_ROOT) |
|
38 |
+ urlpatterns += static.static(settings.STATIC_URL, |
|
39 |
+ document_root=settings.STATIC_ROOT) |
@@ -0,0 +1,46 @@ |
||
1 |
+"""simditor utils.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+import os.path |
|
5 |
+import random |
|
6 |
+ |
|
7 |
+import string |
|
8 |
+ |
|
9 |
+from django.core.files.storage import default_storage |
|
10 |
+from django.template.defaultfilters import slugify |
|
11 |
+ |
|
12 |
+ |
|
13 |
+class NotAnImageException(Exception): |
|
14 |
+ pass |
|
15 |
+ |
|
16 |
+ |
|
17 |
+def get_random_string(): |
|
18 |
+ """Get random string.""" |
|
19 |
+ return ''.join(random.sample(string.ascii_lowercase * 6, 6)) |
|
20 |
+ |
|
21 |
+ |
|
22 |
+def get_slugified_name(filename): |
|
23 |
+ """get_slugified_name.""" |
|
24 |
+ slugified = slugify(filename) |
|
25 |
+ return slugified or get_random_string() |
|
26 |
+ |
|
27 |
+ |
|
28 |
+def slugify_filename(filename): |
|
29 |
+ """ Slugify filename """ |
|
30 |
+ name, ext = os.path.splitext(filename) |
|
31 |
+ slugified = get_slugified_name(name) |
|
32 |
+ return slugified + ext |
|
33 |
+ |
|
34 |
+ |
|
35 |
+def get_media_url(path): |
|
36 |
+ """ |
|
37 |
+ Determine system file's media URL. |
|
38 |
+ """ |
|
39 |
+ return default_storage.url(path) |
|
40 |
+ |
|
41 |
+ |
|
42 |
+def is_valid_image_extension(file_path): |
|
43 |
+ """is_valid_image_extension.""" |
|
44 |
+ valid_extensions = ['.jpeg', '.jpg', '.gif', '.png'] |
|
45 |
+ _, extension = os.path.splitext(file_path) |
|
46 |
+ return extension.lower() in valid_extensions |
@@ -0,0 +1,84 @@ |
||
1 |
+"""simditor views.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+import os |
|
5 |
+from datetime import datetime |
|
6 |
+ |
|
7 |
+from django.conf import settings |
|
8 |
+from django.core.files.storage import default_storage |
|
9 |
+ |
|
10 |
+from django.http import JsonResponse |
|
11 |
+ |
|
12 |
+from django.views import generic |
|
13 |
+from django.views.decorators.csrf import csrf_exempt |
|
14 |
+ |
|
15 |
+from . import utils, image_processing |
|
16 |
+ |
|
17 |
+ |
|
18 |
+def get_upload_filename(upload_name): |
|
19 |
+ # Generate date based path to put uploaded file. |
|
20 |
+ date_path = datetime.now().strftime('%Y/%m/%d') |
|
21 |
+ |
|
22 |
+ # Complete upload path (upload_path + date_path). |
|
23 |
+ upload_path = os.path.join(settings.SIMDITOR_UPLOAD_PATH, date_path) |
|
24 |
+ |
|
25 |
+ if getattr(settings, 'SIMDITOR_UPLOAD_SLUGIFY_FILENAME', True): |
|
26 |
+ upload_name = utils.slugify_filename(upload_name) |
|
27 |
+ |
|
28 |
+ return default_storage.get_available_name(os.path.join(upload_path, upload_name)) |
|
29 |
+ |
|
30 |
+ |
|
31 |
+def upload_handler(request): |
|
32 |
+ files = request.FILES |
|
33 |
+ |
|
34 |
+ upload_config = settings.SIMDITOR_CONFIGS.get( |
|
35 |
+ 'upload', {'fileKey': 'upload'}) |
|
36 |
+ filekey = upload_config.get('fileKey', 'upload') |
|
37 |
+ |
|
38 |
+ uploaded_file = files.get(filekey) |
|
39 |
+ |
|
40 |
+ if not uploaded_file: |
|
41 |
+ retdata = {'file_path': '', 'success': False, |
|
42 |
+ 'msg': '图片上传失败,无法获取到图片对象!'} |
|
43 |
+ return JsonResponse(retdata) |
|
44 |
+ |
|
45 |
+ image_size = upload_config.get('image_size') |
|
46 |
+ if image_size and uploaded_file.size > image_size: |
|
47 |
+ retdata = {'file_path': '', 'success': False, |
|
48 |
+ 'msg': '上传失败,已超出图片最大限制!'} |
|
49 |
+ return JsonResponse(retdata) |
|
50 |
+ |
|
51 |
+ backend = image_processing.get_backend() |
|
52 |
+ |
|
53 |
+ if not getattr(settings, 'SIMDITOR_ALLOW_NONIMAGE_FILES', True): |
|
54 |
+ try: |
|
55 |
+ backend.image_verify(uploaded_file) |
|
56 |
+ except utils.NotAnImageException: |
|
57 |
+ retdata = {'file_path': '', 'success': False, |
|
58 |
+ 'msg': '图片格式错误!'} |
|
59 |
+ return JsonResponse(retdata) |
|
60 |
+ |
|
61 |
+ filename = get_upload_filename(uploaded_file.name) |
|
62 |
+ saved_path = default_storage.save(filename, uploaded_file) |
|
63 |
+ |
|
64 |
+ url = utils.get_media_url(saved_path) |
|
65 |
+ |
|
66 |
+ is_api = settings.SIMDITOR_CONFIGS.get('is_api', False) |
|
67 |
+ url = request.META.get('HTTP_ORIGIN') + url if is_api else url |
|
68 |
+ |
|
69 |
+ retdata = {'file_path': url, 'success': True, 'msg': '上传成功!'} |
|
70 |
+ |
|
71 |
+ return JsonResponse(retdata) |
|
72 |
+ |
|
73 |
+ |
|
74 |
+class ImageUploadView(generic.View): |
|
75 |
+ """ImageUploadView.""" |
|
76 |
+ |
|
77 |
+ http_method_names = ['post'] |
|
78 |
+ |
|
79 |
+ def post(self, request, **kwargs): |
|
80 |
+ """Post.""" |
|
81 |
+ return upload_handler(request) |
|
82 |
+ |
|
83 |
+ |
|
84 |
+UPLOAD = csrf_exempt(ImageUploadView.as_view()) |
@@ -0,0 +1,170 @@ |
||
1 |
+"""simditor widgets.""" |
|
2 |
+from __future__ import absolute_import |
|
3 |
+ |
|
4 |
+from django import forms |
|
5 |
+from django.conf import settings |
|
6 |
+from django.core.exceptions import ImproperlyConfigured |
|
7 |
+from django.core.serializers.json import DjangoJSONEncoder |
|
8 |
+ |
|
9 |
+from django.template.loader import render_to_string |
|
10 |
+from django.utils.encoding import force_text |
|
11 |
+from django.utils.safestring import mark_safe |
|
12 |
+from django.utils.html import conditional_escape |
|
13 |
+from django.utils.functional import Promise |
|
14 |
+ |
|
15 |
+try: |
|
16 |
+ # Django >=2.1 |
|
17 |
+ from django.forms.widgets import get_default_renderer |
|
18 |
+ IS_NEW_WIDGET = True |
|
19 |
+except ImportError: |
|
20 |
+ IS_NEW_WIDGET = False |
|
21 |
+ |
|
22 |
+try: |
|
23 |
+ # Django >=1.7 |
|
24 |
+ from django.forms.utils import flatatt |
|
25 |
+except ImportError: |
|
26 |
+ # Django <1.7 |
|
27 |
+ from django.forms.util import flatatt # pylint disable=E0611, E0401 |
|
28 |
+ |
|
29 |
+ |
|
30 |
+class LazyEncoder(DjangoJSONEncoder): |
|
31 |
+ """LazyEncoder.""" |
|
32 |
+ |
|
33 |
+ # pylint disable=E0202 |
|
34 |
+ def default(self, obj): |
|
35 |
+ if isinstance(obj, Promise): |
|
36 |
+ return force_text(obj) |
|
37 |
+ return super(LazyEncoder, self).default(obj) |
|
38 |
+ |
|
39 |
+ |
|
40 |
+JSON_ENCODE = LazyEncoder().encode |
|
41 |
+ |
|
42 |
+ |
|
43 |
+FULL_TOOLBAR = [ |
|
44 |
+ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', |
|
45 |
+ 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', |
|
46 |
+ 'image', 'hr', '|', 'indent', 'outdent', 'alignment', 'checklist', |
|
47 |
+ 'markdown', 'fullscreen' |
|
48 |
+] |
|
49 |
+ |
|
50 |
+DEFAULT_TOOLBAR = [ |
|
51 |
+ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', |
|
52 |
+ 'color', '|', 'ol', 'ul', 'blockquote', 'table', '|', 'link', |
|
53 |
+ 'image', 'hr', '|', 'indent', 'outdent', 'alignment' |
|
54 |
+] |
|
55 |
+ |
|
56 |
+DEFAULT_CONFIG = { |
|
57 |
+ 'toolbar': DEFAULT_TOOLBAR, |
|
58 |
+ 'cleanPaste': True, |
|
59 |
+ 'tabIndent': True, |
|
60 |
+ 'pasteImage': True, |
|
61 |
+ 'upload': { |
|
62 |
+ 'url': '/', |
|
63 |
+ 'fileKey': 'file' |
|
64 |
+ } |
|
65 |
+} |
|
66 |
+ |
|
67 |
+ |
|
68 |
+class SimditorWidget(forms.Textarea): |
|
69 |
+ """ |
|
70 |
+ Widget providing Simditor for Rich Text Editing.abs |
|
71 |
+ Supports direct image uploads and embed. |
|
72 |
+ """ |
|
73 |
+ class Media: |
|
74 |
+ """Media.""" |
|
75 |
+ |
|
76 |
+ css_list = [ |
|
77 |
+ 'simditor/styles/simditor.min.css' |
|
78 |
+ ] |
|
79 |
+ |
|
80 |
+ if 'emoji' in settings.SIMDITOR_TOOLBAR: |
|
81 |
+ css_list.append('simditor/styles/simditor-emoji.css') |
|
82 |
+ |
|
83 |
+ if 'fullscreen' in settings.SIMDITOR_TOOLBAR: |
|
84 |
+ css_list.append('simditor/styles/simditor-fullscreen.min.css') |
|
85 |
+ |
|
86 |
+ if 'checklist' in settings.SIMDITOR_TOOLBAR: |
|
87 |
+ css_list.append('simditor/styles/simditor-checklist.min.css') |
|
88 |
+ |
|
89 |
+ if 'markdown' in settings.SIMDITOR_TOOLBAR: |
|
90 |
+ css_list.append('simditor/styles/simditor-markdown.min.css') |
|
91 |
+ |
|
92 |
+ css = {'all': tuple(settings.STATIC_URL + url for url in css_list)} |
|
93 |
+ |
|
94 |
+ jquery_list = ['simditor/scripts/jquery.min.js', |
|
95 |
+ 'simditor/scripts/module.min.js', |
|
96 |
+ 'simditor/scripts/hotkeys.min.js', |
|
97 |
+ 'simditor/scripts/uploader.min.js', |
|
98 |
+ 'simditor/scripts/simditor.min.js'] |
|
99 |
+ |
|
100 |
+ if 'fullscreen' in settings.SIMDITOR_TOOLBAR: |
|
101 |
+ jquery_list.append('simditor/scripts/simditor-fullscreen.min.js') |
|
102 |
+ |
|
103 |
+ if 'checklist' in settings.SIMDITOR_TOOLBAR: |
|
104 |
+ jquery_list.append('simditor/scripts/simditor-checklist.min.js') |
|
105 |
+ |
|
106 |
+ if 'markdown' in settings.SIMDITOR_TOOLBAR: |
|
107 |
+ jquery_list.append('simditor/scripts/marked.min.js') |
|
108 |
+ jquery_list.append('simditor/scripts/to-markdown.min.js') |
|
109 |
+ jquery_list.append('simditor/scripts/simditor-markdown.min.js') |
|
110 |
+ |
|
111 |
+ if 'image' in settings.SIMDITOR_TOOLBAR: |
|
112 |
+ jquery_list.append('simditor/scripts/simditor-dropzone.min.js') |
|
113 |
+ |
|
114 |
+ if 'emoji' in settings.SIMDITOR_TOOLBAR: |
|
115 |
+ jquery_list.append('simditor/scripts/simditor-emoji.js') |
|
116 |
+ |
|
117 |
+ js = tuple(settings.STATIC_URL + url for url in jquery_list) |
|
118 |
+ |
|
119 |
+ try: |
|
120 |
+ |
|
121 |
+ js += (settings.STATIC_URL + 'simditor/simditor-init.js',) |
|
122 |
+ except AttributeError: |
|
123 |
+ raise ImproperlyConfigured("django-simditor requires \ |
|
124 |
+ SIMDITOR_MEDIA_PREFIX setting. This setting specifies a \ |
|
125 |
+ URL prefix to the ckeditor JS and CSS media (not \ |
|
126 |
+ uploaded media). Make sure to use a trailing slash: \ |
|
127 |
+ SIMDITOR_MEDIA_PREFIX = '/media/simditor/'") |
|
128 |
+ |
|
129 |
+ def __init__(self, *args, **kwargs): |
|
130 |
+ super(SimditorWidget, self).__init__(*args, **kwargs) |
|
131 |
+ # Setup config from defaults. |
|
132 |
+ self.config = DEFAULT_CONFIG.copy() |
|
133 |
+ |
|
134 |
+ # Try to get valid config from settings. |
|
135 |
+ configs = getattr(settings, 'SIMDITOR_CONFIGS', None) |
|
136 |
+ if configs: |
|
137 |
+ if isinstance(configs, dict): |
|
138 |
+ self.config.update(configs) |
|
139 |
+ else: |
|
140 |
+ raise ImproperlyConfigured( |
|
141 |
+ 'SIMDITOR_CONFIGS setting must be a dictionary type.') |
|
142 |
+ |
|
143 |
+ def build_attrs(self, base_attrs, extra_attrs=None, **kwargs): |
|
144 |
+ """ |
|
145 |
+ Helper function for building an attribute dictionary. |
|
146 |
+ This is combination of the same method from Django<=1.10 and Django1.11 |
|
147 |
+ """ |
|
148 |
+ attrs = dict(base_attrs, **kwargs) |
|
149 |
+ if extra_attrs: |
|
150 |
+ attrs.update(extra_attrs) |
|
151 |
+ return attrs |
|
152 |
+ |
|
153 |
+ def render(self, name, value, attrs=None, renderer=None): |
|
154 |
+ if value is None: |
|
155 |
+ value = '' |
|
156 |
+ final_attrs = self.build_attrs(self.attrs, attrs, name=name) |
|
157 |
+ |
|
158 |
+ params = ('simditor/widget.html', { |
|
159 |
+ 'final_attrs': flatatt(final_attrs), |
|
160 |
+ 'value': conditional_escape(force_text(value)), |
|
161 |
+ 'id': final_attrs['id'], |
|
162 |
+ 'config': JSON_ENCODE(self.config) |
|
163 |
+ }) |
|
164 |
+ |
|
165 |
+ if renderer is None and IS_NEW_WIDGET: |
|
166 |
+ renderer = get_default_renderer() |
|
167 |
+ |
|
168 |
+ data = renderer.render(*params) if IS_NEW_WIDGET else render_to_string(*params) |
|
169 |
+ |
|
170 |
+ return mark_safe(data) |