/*!
* UEditor
* version: ueditor
* build: Wed Dec 26 2018 17:24:52 GMT+0800 (CST)
*/
!(function () {
function getListener(a, b, c) {
var d
return (
(b = b.toLowerCase()),
(d = a.__allListeners || (c && (a.__allListeners = {}))) &&
(d[b] || (c && (d[b] = [])))
)
}
function getDomNode(a, b, c, d, e, f) {
var g,
h = d && a[b]
for (!h && (h = a[c]); !h && (g = (g || a).parentNode); ) {
if ('BODY' == g.tagName || (f && !f(g))) return null
h = g[c]
}
return h && e && !e(h) ? getDomNode(h, b, c, !1, e) : h
}
UEDITOR_CONFIG = window.UEDITOR_CONFIG || {}
var baidu = window.baidu || {}
;(window.baidu = baidu),
(window.UE = baidu.editor = window.UE || {}),
(UE.plugins = {}),
(UE.commands = {}),
(UE.instants = {}),
(UE.I18N = {}),
(UE._customizeUI = {}),
(UE.version = '1.4.3')
var dom = (UE.dom = {}),
browser = (UE.browser = (function () {
var a = navigator.userAgent.toLowerCase(),
b = window.opera,
c = {
ie: /(msie\s|trident.*rv:)([\w.]+)/.test(a),
opera: !!b && b.version,
webkit: a.indexOf(' applewebkit/') > -1,
mac: a.indexOf('macintosh') > -1,
quirks: 'BackCompat' == document.compatMode
}
c.gecko = 'Gecko' == navigator.product && !c.webkit && !c.opera && !c.ie
var d = 0
if (c.ie) {
var e = a.match(/(?:msie\s([\w.]+))/),
f = a.match(/(?:trident.*rv:([\w.]+))/)
;(d =
e && f && e[1] && f[1]
? Math.max(1 * e[1], 1 * f[1])
: e && e[1]
? 1 * e[1]
: f && f[1]
? 1 * f[1]
: 0),
(c.ie11Compat = 11 == document.documentMode),
(c.ie9Compat = 9 == document.documentMode),
(c.ie8 = !!document.documentMode),
(c.ie8Compat = 8 == document.documentMode),
(c.ie7Compat =
(7 == d && !document.documentMode) || 7 == document.documentMode),
(c.ie6Compat = d < 7 || c.quirks),
(c.ie9above = d > 8),
(c.ie9below = d < 9),
(c.ie11above = d > 10),
(c.ie11below = d < 11)
}
if (c.gecko) {
var g = a.match(/rv:([\d\.]+)/)
g &&
((g = g[1].split('.')),
(d = 1e4 * g[0] + 100 * (g[1] || 0) + 1 * (g[2] || 0)))
}
return (
/chrome\/(\d+\.\d)/i.test(a) && (c.chrome = +RegExp.$1),
/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(a) &&
!/chrome/i.test(a) &&
(c.safari = +(RegExp.$1 || RegExp.$2)),
c.opera && (d = parseFloat(b.version())),
c.webkit && (d = parseFloat(a.match(/ applewebkit\/(\d+)/)[1])),
(c.version = d),
(c.isCompatible =
!c.mobile &&
((c.ie && d >= 6) ||
(c.gecko && d >= 10801) ||
(c.opera && d >= 9.5) ||
(c.air && d >= 1) ||
(c.webkit && d >= 522) ||
!1)),
c
)
})()),
ie = browser.ie,
webkit = browser.webkit,
gecko = browser.gecko,
opera = browser.opera,
utils = (UE.utils = {
each: function (a, b, c) {
if (null != a)
if (a.length === +a.length) {
for (var d = 0, e = a.length; d < e; d++)
if (b.call(c, a[d], d, a) === !1) return !1
} else
for (var f in a)
if (a.hasOwnProperty(f) && b.call(c, a[f], f, a) === !1) return !1
},
makeInstance: function (a) {
var b = new Function()
return (b.prototype = a), (a = new b()), (b.prototype = null), a
},
extend: function (a, b, c) {
if (b) for (var d in b) (c && a.hasOwnProperty(d)) || (a[d] = b[d])
return a
},
extend2: function (a) {
for (var b = arguments, c = 1; c < b.length; c++) {
var d = b[c]
for (var e in d) a.hasOwnProperty(e) || (a[e] = d[e])
}
return a
},
inherits: function (a, b) {
var c = a.prototype,
d = utils.makeInstance(b.prototype)
return utils.extend(d, c, !0), (a.prototype = d), (d.constructor = a)
},
bind: function (a, b) {
return function () {
return a.apply(b, arguments)
}
},
defer: function (a, b, c) {
var d
return function () {
c && clearTimeout(d), (d = setTimeout(a, b))
}
},
indexOf: function (a, b, c) {
var d = -1
return (
(c = this.isNumber(c) ? c : 0),
this.each(a, function (a, e) {
if (e >= c && a === b) return (d = e), !1
}),
d
)
},
removeItem: function (a, b) {
for (var c = 0, d = a.length; c < d; c++)
a[c] === b && (a.splice(c, 1), c--)
},
trim: function (a) {
return a.replace(/(^[ \t\n\r]+)|([ \t\n\r]+$)/g, '')
},
listToMap: function (a) {
if (!a) return {}
a = utils.isArray(a) ? a : a.split(',')
for (var b, c = 0, d = {}; (b = a[c++]); ) d[b.toUpperCase()] = d[b] = 1
return d
},
unhtml: function (a, b) {
return a
? a.replace(
b || /[&<">'](?:(amp|lt|quot|gt|#39|nbsp|#\d+);)?/g,
function (a, b) {
return b
? a
: {
'<': '<',
'&': '&',
'"': '"',
'>': '>',
"'": '''
}[a]
}
)
: ''
},
unhtmlForUrl: function (a, b) {
return a
? a.replace(b || /[<">']/g, function (a) {
return {
'<': '<',
'&': '&',
'"': '"',
'>': '>',
"'": '''
}[a]
})
: ''
},
html: function (a) {
return a
? a.replace(/&((g|l|quo)t|amp|#39|nbsp);/g, function (a) {
return {
'<': '<',
'&': '&',
'"': '"',
'>': '>',
''': "'",
' ': ' '
}[a]
})
: ''
},
cssStyleToDomStyle: (function () {
var a = document.createElement('div').style,
b = {
float:
void 0 != a.cssFloat
? 'cssFloat'
: void 0 != a.styleFloat
? 'styleFloat'
: 'float'
}
return function (a) {
return (
b[a] ||
(b[a] = a.toLowerCase().replace(/-./g, function (a) {
return a.charAt(1).toUpperCase()
}))
)
}
})(),
loadFile: (function () {
function a(a, c) {
try {
for (var d, e = 0; (d = b[e++]); )
if (d.doc === a && d.url == (c.src || c.href)) return d
} catch (f) {
return null
}
}
var b = []
return function (c, d, e) {
var f = a(c, d)
if (f) return void (f.ready ? e && e() : f.funs.push(e))
if ((b.push({ doc: c, url: d.src || d.href, funs: [e] }), !c.body)) {
var g = []
for (var h in d) 'tag' != h && g.push(h + '="' + d[h] + '"')
return void c.write(
'<' + d.tag + ' ' + g.join(' ') + ' >' + d.tag + '>'
)
}
if (!d.id || !c.getElementById(d.id)) {
var i = c.createElement(d.tag)
delete d.tag
for (var h in d) i.setAttribute(h, d[h])
;(i.onload = i.onreadystatechange =
function () {
if (
!this.readyState ||
/loaded|complete/.test(this.readyState)
) {
if (((f = a(c, d)), f.funs.length > 0)) {
f.ready = 1
for (var b; (b = f.funs.pop()); ) b()
}
i.onload = i.onreadystatechange = null
}
}),
(i.onerror = function () {
throw Error(
'The load ' +
(d.href || d.src) +
' fails,check the url settings of file ueditor.config.js '
)
}),
c.getElementsByTagName('head')[0].appendChild(i)
}
}
})(),
isEmptyObject: function (a) {
if (null == a) return !0
if (this.isArray(a) || this.isString(a)) return 0 === a.length
for (var b in a) if (a.hasOwnProperty(b)) return !1
return !0
},
fixColor: function (a, b) {
if (/color/i.test(a) && /rgba?/.test(b)) {
var c = b.split(',')
if (c.length > 3) return ''
b = '#'
for (var d, e = 0; (d = c[e++]); )
(d = parseInt(d.replace(/[^\d]/gi, ''), 10).toString(16)),
(b += 1 == d.length ? '0' + d : d)
b = b.toUpperCase()
}
return b
},
optCss: function (a) {
function b(a, b) {
if (!a) return ''
var c = a.top,
d = a.bottom,
e = a.left,
f = a.right,
g = ''
if (c && e && d && f)
g +=
';' +
b +
':' +
(c == d && d == e && e == f
? c
: c == d && e == f
? c + ' ' + e
: e == f
? c + ' ' + e + ' ' + d
: c + ' ' + f + ' ' + d + ' ' + e) +
';'
else for (var h in a) g += ';' + b + '-' + h + ':' + a[h] + ';'
return g
}
var c, d
return (
(a = a.replace(
/(padding|margin|border)\-([^:]+):([^;]+);?/gi,
function (a, b, e, f) {
if (1 == f.split(' ').length)
switch (b) {
case 'padding':
return !c && (c = {}), (c[e] = f), ''
case 'margin':
return !d && (d = {}), (d[e] = f), ''
case 'border':
return 'initial' == f ? '' : a
}
return a
}
)),
(a += b(c, 'padding') + b(d, 'margin')),
a
.replace(/^[ \n\r\t;]*|[ \n\r\t]*$/, '')
.replace(/;([ \n\r\t]+)|\1;/g, ';')
.replace(/(&((l|g)t|quot|#39))?;{2,}/g, function (a, b) {
return b ? b + ';;' : ';'
})
)
},
clone: function (a, b) {
var c
b = b || {}
for (var d in a)
a.hasOwnProperty(d) &&
((c = a[d]),
'object' == typeof c
? ((b[d] = utils.isArray(c) ? [] : {}), utils.clone(a[d], b[d]))
: (b[d] = c))
return b
},
transUnitToPx: function (a) {
if (!/(pt|cm)/.test(a)) return a
var b
switch (
(a.replace(/([\d.]+)(\w+)/, function (c, d, e) {
;(a = d), (b = e)
}),
b)
) {
case 'cm':
a = 25 * parseFloat(a)
break
case 'pt':
a = Math.round((96 * parseFloat(a)) / 72)
}
return a + (a ? 'px' : '')
},
domReady: (function () {
function a(a) {
a.isReady = !0
for (var c; (c = b.pop()); c());
}
var b = []
return function (c, d) {
d = d || window
var e = d.document
c && b.push(c),
'complete' === e.readyState
? a(e)
: (e.isReady && a(e),
browser.ie && 11 != browser.version
? (!(function () {
if (!e.isReady) {
try {
e.documentElement.doScroll('left')
} catch (b) {
return void setTimeout(arguments.callee, 0)
}
a(e)
}
})(),
d.attachEvent('onload', function () {
a(e)
}))
: (e.addEventListener(
'DOMContentLoaded',
function () {
e.removeEventListener(
'DOMContentLoaded',
arguments.callee,
!1
),
a(e)
},
!1
),
d.addEventListener(
'load',
function () {
a(e)
},
!1
)))
}
})(),
cssRule:
browser.ie && 11 != browser.version
? function (a, b, c) {
var d, e
if (void 0 === b || (b && b.nodeType && 9 == b.nodeType)) {
if (
((c = b && b.nodeType && 9 == b.nodeType ? b : c || document),
(d = c.indexList || (c.indexList = {})),
(e = d[a]),
void 0 !== e)
)
return c.styleSheets[e].cssText
} else {
if (
((c = c || document),
(d = c.indexList || (c.indexList = {})),
(e = d[a]),
'' === b)
)
return (
void 0 !== e &&
((c.styleSheets[e].cssText = ''), delete d[a], !0)
)
void 0 !== e
? (sheetStyle = c.styleSheets[e])
: ((sheetStyle = c.createStyleSheet(
'',
(e = c.styleSheets.length)
)),
(d[a] = e)),
(sheetStyle.cssText = b)
}
}
: function (a, b, c) {
var d
return void 0 === b || (b && b.nodeType && 9 == b.nodeType)
? ((c = b && b.nodeType && 9 == b.nodeType ? b : c || document),
(d = c.getElementById(a)),
d ? d.innerHTML : void 0)
: ((c = c || document),
(d = c.getElementById(a)),
'' === b
? !!d && (d.parentNode.removeChild(d), !0)
: void (d
? (d.innerHTML = b)
: ((d = c.createElement('style')),
(d.id = a),
(d.innerHTML = b),
c.getElementsByTagName('head')[0].appendChild(d))))
},
sort: function (a, b) {
b =
b ||
function (a, b) {
return a.localeCompare(b)
}
for (var c = 0, d = a.length; c < d; c++)
for (var e = c, f = a.length; e < f; e++)
if (b(a[c], a[e]) > 0) {
var g = a[c]
;(a[c] = a[e]), (a[e] = g)
}
return a
},
serializeParam: function (a) {
var b = []
for (var c in a)
if ('method' != c && 'timeout' != c && 'async' != c)
if (
'function' != (typeof a[c]).toLowerCase() &&
'object' != (typeof a[c]).toLowerCase()
)
b.push(encodeURIComponent(c) + '=' + encodeURIComponent(a[c]))
else if (utils.isArray(a[c]))
for (var d = 0; d < a[c].length; d++)
b.push(
encodeURIComponent(c) + '[]=' + encodeURIComponent(a[c][d])
)
return b.join('&')
},
formatUrl: function (a) {
var b = a.replace(/&&/g, '&')
return (
(b = b.replace(/\?&/g, '?')),
(b = b.replace(/&$/g, '')),
(b = b.replace(//g, '#')),
(b = b.replace(/&+/g, '&'))
)
},
isCrossDomainUrl: function (a) {
var b = document.createElement('a')
return (
(b.href = a),
browser.ie && (b.href = b.href),
!(
b.protocol == location.protocol &&
b.hostname == location.hostname &&
(b.port == location.port ||
('80' == b.port && '' == location.port) ||
('' == b.port && '80' == location.port))
)
)
},
clearEmptyAttrs: function (a) {
for (var b in a) '' === a[b] && delete a[b]
return a
},
str2json: function (a) {
return utils.isString(a)
? window.JSON
? JSON.parse(a)
: new Function('return ' + utils.trim(a || ''))()
: null
},
json2str: (function () {
function a(a) {
return (
/["\\\x00-\x1f]/.test(a) &&
(a = a.replace(/["\\\x00-\x1f]/g, function (a) {
var b = e[a]
return b
? b
: ((b = a.charCodeAt()),
'\\u00' +
Math.floor(b / 16).toString(16) +
(b % 16).toString(16))
})),
'"' + a + '"'
)
}
function b(a) {
var b,
c,
d,
e = ['['],
f = a.length
for (c = 0; c < f; c++)
switch (((d = a[c]), typeof d)) {
case 'undefined':
case 'function':
case 'unknown':
break
default:
b && e.push(','), e.push(utils.json2str(d)), (b = 1)
}
return e.push(']'), e.join('')
}
function c(a) {
return a < 10 ? '0' + a : a
}
function d(a) {
return (
'"' +
a.getFullYear() +
'-' +
c(a.getMonth() + 1) +
'-' +
c(a.getDate()) +
'T' +
c(a.getHours()) +
':' +
c(a.getMinutes()) +
':' +
c(a.getSeconds()) +
'"'
)
}
if (window.JSON) return JSON.stringify
var e = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"': '\\"',
'\\': '\\\\'
}
return function (c) {
switch (typeof c) {
case 'undefined':
return 'undefined'
case 'number':
return isFinite(c) ? String(c) : 'null'
case 'string':
return a(c)
case 'boolean':
return String(c)
default:
if (null === c) return 'null'
if (utils.isArray(c)) return b(c)
if (utils.isDate(c)) return d(c)
var e,
f,
g = ['{'],
h = utils.json2str
for (var i in c)
if (Object.prototype.hasOwnProperty.call(c, i))
switch (((f = c[i]), typeof f)) {
case 'undefined':
case 'unknown':
case 'function':
break
default:
e && g.push(','), (e = 1), g.push(h(i) + ':' + h(f))
}
return g.push('}'), g.join('')
}
}
})()
})
utils.each(
['String', 'Function', 'Array', 'Number', 'RegExp', 'Object', 'Date'],
function (a) {
UE.utils['is' + a] = function (b) {
return Object.prototype.toString.apply(b) == '[object ' + a + ']'
}
}
)
var EventBase = (UE.EventBase = function () {})
EventBase.prototype = {
addListener: function (a, b) {
a = utils.trim(a).split(/\s+/)
for (var c, d = 0; (c = a[d++]); ) getListener(this, c, !0).push(b)
},
on: function (a, b) {
return this.addListener(a, b)
},
off: function (a, b) {
return this.removeListener(a, b)
},
trigger: function () {
return this.fireEvent.apply(this, arguments)
},
removeListener: function (a, b) {
a = utils.trim(a).split(/\s+/)
for (var c, d = 0; (c = a[d++]); )
utils.removeItem(getListener(this, c) || [], b)
},
fireEvent: function () {
var a = arguments[0]
a = utils.trim(a).split(' ')
for (var b, c = 0; (b = a[c++]); ) {
var d,
e,
f,
g = getListener(this, b)
if (g)
for (f = g.length; f--; )
if (g[f]) {
if (((e = g[f].apply(this, arguments)), e === !0)) return e
void 0 !== e && (d = e)
}
;(e = this['on' + b.toLowerCase()]) && (d = e.apply(this, arguments))
}
return d
}
}
var dtd = (dom.dtd = (function () {
function a(a) {
for (var b in a) a[b.toUpperCase()] = a[b]
return a
}
var b = utils.extend2,
c = a({ isindex: 1, fieldset: 1 }),
d = a({ input: 1, button: 1, select: 1, textarea: 1, label: 1 }),
e = b(a({ a: 1 }), d),
f = b({ iframe: 1 }, e),
g = a({
hr: 1,
ul: 1,
menu: 1,
div: 1,
blockquote: 1,
noscript: 1,
table: 1,
center: 1,
address: 1,
dir: 1,
pre: 1,
h5: 1,
dl: 1,
h4: 1,
noframes: 1,
h6: 1,
ol: 1,
h1: 1,
h3: 1,
h2: 1
}),
h = a({ ins: 1, del: 1, script: 1, style: 1 }),
i = b(
a({
b: 1,
acronym: 1,
bdo: 1,
var: 1,
'#': 1,
abbr: 1,
code: 1,
br: 1,
i: 1,
cite: 1,
kbd: 1,
u: 1,
strike: 1,
s: 1,
tt: 1,
strong: 1,
q: 1,
samp: 1,
em: 1,
dfn: 1,
span: 1
}),
h
),
j = b(
a({
sub: 1,
img: 1,
embed: 1,
object: 1,
sup: 1,
basefont: 1,
map: 1,
applet: 1,
font: 1,
big: 1,
small: 1
}),
i
),
k = b(a({ p: 1 }), j),
l = b(a({ iframe: 1 }), j, d),
m = a({
img: 1,
embed: 1,
noscript: 1,
br: 1,
kbd: 1,
center: 1,
button: 1,
basefont: 1,
h5: 1,
h4: 1,
samp: 1,
h6: 1,
ol: 1,
h1: 1,
h3: 1,
h2: 1,
form: 1,
font: 1,
'#': 1,
select: 1,
menu: 1,
ins: 1,
abbr: 1,
label: 1,
code: 1,
table: 1,
script: 1,
cite: 1,
input: 1,
iframe: 1,
strong: 1,
textarea: 1,
noframes: 1,
big: 1,
small: 1,
span: 1,
hr: 1,
sub: 1,
bdo: 1,
var: 1,
div: 1,
object: 1,
sup: 1,
strike: 1,
dir: 1,
map: 1,
dl: 1,
applet: 1,
del: 1,
isindex: 1,
fieldset: 1,
ul: 1,
b: 1,
acronym: 1,
a: 1,
blockquote: 1,
i: 1,
u: 1,
s: 1,
tt: 1,
address: 1,
q: 1,
pre: 1,
p: 1,
em: 1,
dfn: 1
}),
n = b(a({ a: 0 }), l),
o = a({ tr: 1 }),
p = a({ '#': 1 }),
q = b(a({ param: 1 }), m),
r = b(a({ form: 1 }), c, f, g, k),
s = a({ li: 1, ol: 1, ul: 1 }),
t = a({ style: 1, script: 1 }),
u = a({ base: 1, link: 1, meta: 1, title: 1 }),
v = b(u, t),
w = a({ head: 1, body: 1 }),
x = a({ html: 1 }),
y = a({
address: 1,
blockquote: 1,
center: 1,
dir: 1,
div: 1,
dl: 1,
fieldset: 1,
form: 1,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1,
hr: 1,
isindex: 1,
menu: 1,
noframes: 1,
ol: 1,
p: 1,
pre: 1,
table: 1,
ul: 1
}),
z = a({
area: 1,
base: 1,
basefont: 1,
br: 1,
col: 1,
command: 1,
dialog: 1,
embed: 1,
hr: 1,
img: 1,
input: 1,
isindex: 1,
keygen: 1,
link: 1,
meta: 1,
param: 1,
source: 1,
track: 1,
wbr: 1
})
return a({
$nonBodyContent: b(x, w, u),
$block: y,
$inline: n,
$inlineWithA: b(a({ a: 1 }), n),
$body: b(a({ script: 1, style: 1 }), y),
$cdata: a({ script: 1, style: 1 }),
$empty: z,
$nonChild: a({ iframe: 1, textarea: 1 }),
$listItem: a({ dd: 1, dt: 1, li: 1 }),
$list: a({ ul: 1, ol: 1, dl: 1 }),
$isNotEmpty: a({
table: 1,
ul: 1,
ol: 1,
dl: 1,
iframe: 1,
area: 1,
base: 1,
col: 1,
hr: 1,
img: 1,
embed: 1,
input: 1,
link: 1,
meta: 1,
param: 1,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1
}),
$removeEmpty: a({
a: 1,
abbr: 1,
acronym: 1,
address: 1,
b: 1,
bdo: 1,
big: 1,
cite: 1,
code: 1,
del: 1,
dfn: 1,
em: 1,
font: 1,
i: 1,
ins: 1,
label: 1,
kbd: 1,
q: 1,
s: 1,
samp: 1,
small: 1,
span: 1,
strike: 1,
strong: 1,
sub: 1,
sup: 1,
tt: 1,
u: 1,
var: 1
}),
$removeEmptyBlock: a({ p: 1, div: 1 }),
$tableContent: a({
caption: 1,
col: 1,
colgroup: 1,
tbody: 1,
td: 1,
tfoot: 1,
th: 1,
thead: 1,
tr: 1,
table: 1
}),
$notTransContent: a({ pre: 1, script: 1, style: 1, textarea: 1 }),
html: w,
head: v,
style: p,
script: p,
body: r,
base: {},
link: {},
meta: {},
title: p,
col: {},
tr: a({ td: 1, th: 1 }),
img: {},
embed: {},
colgroup: a({ thead: 1, col: 1, tbody: 1, tr: 1, tfoot: 1 }),
noscript: r,
td: r,
br: {},
th: r,
center: r,
kbd: n,
button: b(k, g),
basefont: {},
h5: n,
h4: n,
samp: n,
h6: n,
ol: s,
h1: n,
h3: n,
option: p,
h2: n,
form: b(c, f, g, k),
select: a({ optgroup: 1, option: 1 }),
font: n,
ins: n,
menu: s,
abbr: n,
label: n,
table: a({
thead: 1,
col: 1,
tbody: 1,
tr: 1,
colgroup: 1,
caption: 1,
tfoot: 1
}),
code: n,
tfoot: o,
cite: n,
li: r,
input: {},
iframe: r,
strong: n,
textarea: p,
noframes: r,
big: n,
small: n,
span: a({
'#': 1,
br: 1,
b: 1,
strong: 1,
u: 1,
i: 1,
em: 1,
sub: 1,
sup: 1,
strike: 1,
span: 1
}),
hr: n,
dt: n,
sub: n,
optgroup: a({ option: 1 }),
param: {},
bdo: n,
var: n,
div: r,
object: q,
sup: n,
dd: r,
strike: n,
area: {},
dir: s,
map: b(a({ area: 1, form: 1, p: 1 }), c, h, g),
applet: q,
dl: a({ dt: 1, dd: 1 }),
del: n,
isindex: {},
fieldset: b(a({ legend: 1 }), m),
thead: o,
ul: s,
acronym: n,
b: n,
a: b(a({ a: 1 }), l),
blockquote: b(a({ td: 1, tr: 1, tbody: 1, li: 1 }), r),
caption: n,
i: n,
u: n,
tbody: o,
s: n,
address: b(f, k),
tt: n,
legend: n,
q: n,
pre: b(i, e),
p: b(a({ a: 1 }), n),
em: n,
dfn: n
})
})()),
attrFix =
ie && browser.version < 9
? {
tabindex: 'tabIndex',
readonly: 'readOnly',
for: 'htmlFor',
class: 'className',
maxlength: 'maxLength',
cellspacing: 'cellSpacing',
cellpadding: 'cellPadding',
rowspan: 'rowSpan',
colspan: 'colSpan',
usemap: 'useMap',
frameborder: 'frameBorder'
}
: { tabindex: 'tabIndex', readonly: 'readOnly' },
styleBlock = utils.listToMap([
'-webkit-box',
'-moz-box',
'block',
'list-item',
'table',
'table-row-group',
'table-header-group',
'table-footer-group',
'table-row',
'table-column-group',
'table-column',
'table-cell',
'table-caption'
]),
domUtils = (dom.domUtils = {
NODE_ELEMENT: 1,
NODE_DOCUMENT: 9,
NODE_TEXT: 3,
NODE_COMMENT: 8,
NODE_DOCUMENT_FRAGMENT: 11,
POSITION_IDENTICAL: 0,
POSITION_DISCONNECTED: 1,
POSITION_FOLLOWING: 2,
POSITION_PRECEDING: 4,
POSITION_IS_CONTAINED: 8,
POSITION_CONTAINS: 16,
fillChar: ie && '6' == browser.version ? '\ufeff' : '',
keys: {
8: 1,
46: 1,
16: 1,
17: 1,
18: 1,
37: 1,
38: 1,
39: 1,
40: 1,
13: 1
},
getPosition: function (a, b) {
if (a === b) return 0
var c,
d = [a],
e = [b]
for (c = a; (c = c.parentNode); ) {
if (c === b) return 10
d.push(c)
}
for (c = b; (c = c.parentNode); ) {
if (c === a) return 20
e.push(c)
}
if ((d.reverse(), e.reverse(), d[0] !== e[0])) return 1
for (var f = -1; f++, d[f] === e[f]; );
for (a = d[f], b = e[f]; (a = a.nextSibling); ) if (a === b) return 4
return 2
},
getNodeIndex: function (a, b) {
for (var c = a, d = 0; (c = c.previousSibling); )
b && 3 == c.nodeType
? c.nodeType != c.nextSibling.nodeType && d++
: d++
return d
},
inDoc: function (a, b) {
return 10 == domUtils.getPosition(a, b)
},
findParent: function (a, b, c) {
if (a && !domUtils.isBody(a))
for (a = c ? a : a.parentNode; a; ) {
if (!b || b(a) || domUtils.isBody(a))
return b && !b(a) && domUtils.isBody(a) ? null : a
a = a.parentNode
}
return null
},
findParentByTagName: function (a, b, c, d) {
return (
(b = utils.listToMap(utils.isArray(b) ? b : [b])),
domUtils.findParent(
a,
function (a) {
return b[a.tagName] && !(d && d(a))
},
c
)
)
},
findParents: function (a, b, c, d) {
for (
var e = b && ((c && c(a)) || !c) ? [a] : [];
(a = domUtils.findParent(a, c));
)
e.push(a)
return d ? e : e.reverse()
},
insertAfter: function (a, b) {
return a.nextSibling
? a.parentNode.insertBefore(b, a.nextSibling)
: a.parentNode.appendChild(b)
},
remove: function (a, b) {
var c,
d = a.parentNode
if (d) {
if (b && a.hasChildNodes())
for (; (c = a.firstChild); ) d.insertBefore(c, a)
d.removeChild(a)
}
return a
},
getNextDomNode: function (a, b, c, d) {
return getDomNode(a, 'firstChild', 'nextSibling', b, c, d)
},
getPreDomNode: function (a, b, c, d) {
return getDomNode(a, 'lastChild', 'previousSibling', b, c, d)
},
isBookmarkNode: function (a) {
return 1 == a.nodeType && a.id && /^_baidu_bookmark_/i.test(a.id)
},
getWindow: function (a) {
var b = a.ownerDocument || a
return b.defaultView || b.parentWindow
},
getCommonAncestor: function (a, b) {
if (a === b) return a
for (var c = [a], d = [b], e = a, f = -1; (e = e.parentNode); ) {
if (e === b) return e
c.push(e)
}
for (e = b; (e = e.parentNode); ) {
if (e === a) return e
d.push(e)
}
for (c.reverse(), d.reverse(); f++, c[f] === d[f]; );
return 0 == f ? null : c[f - 1]
},
clearEmptySibling: function (a, b, c) {
function d(a, b) {
for (
var c;
a &&
!domUtils.isBookmarkNode(a) &&
(domUtils.isEmptyInlineElement(a) ||
!new RegExp('[^\t\n\r' + domUtils.fillChar + ']').test(
a.nodeValue
));
)
(c = a[b]), domUtils.remove(a), (a = c)
}
!b && d(a.nextSibling, 'nextSibling'),
!c && d(a.previousSibling, 'previousSibling')
},
split: function (a, b) {
var c = a.ownerDocument
if (browser.ie && b == a.nodeValue.length) {
var d = c.createTextNode('')
return domUtils.insertAfter(a, d)
}
var e = a.splitText(b)
if (browser.ie8) {
var f = c.createTextNode('')
domUtils.insertAfter(e, f), domUtils.remove(f)
}
return e
},
isWhitespace: function (a) {
return !new RegExp('[^ \t\n\r' + domUtils.fillChar + ']').test(
a.nodeValue
)
},
getXY: function (a) {
for (var b = 0, c = 0; a.offsetParent; )
(c += a.offsetTop), (b += a.offsetLeft), (a = a.offsetParent)
return { x: b, y: c }
},
on: function (a, b, c) {
var d = utils.isArray(b) ? b : utils.trim(b).split(/\s+/),
e = d.length
if (e)
for (; e--; )
if (((b = d[e]), a.addEventListener)) a.addEventListener(b, c, !1)
else {
c._d || (c._d = { els: [] })
var f = b + c.toString(),
g = utils.indexOf(c._d.els, a)
;(c._d[f] && g != -1) ||
(g == -1 && c._d.els.push(a),
c._d[f] ||
(c._d[f] = function (a) {
return c.call(a.srcElement, a || window.event)
}),
a.attachEvent('on' + b, c._d[f]))
}
a = null
},
un: function (a, b, c) {
var d = utils.isArray(b) ? b : utils.trim(b).split(/\s+/),
e = d.length
if (e)
for (; e--; )
if (((b = d[e]), a.removeEventListener))
a.removeEventListener(b, c, !1)
else {
var f = b + c.toString()
try {
a.detachEvent('on' + b, c._d ? c._d[f] : c)
} catch (g) {}
if (c._d && c._d[f]) {
var h = utils.indexOf(c._d.els, a)
h != -1 && c._d.els.splice(h, 1),
0 == c._d.els.length && delete c._d[f]
}
}
},
isSameElement: function (a, b) {
if (a.tagName != b.tagName) return !1
var c = a.attributes,
d = b.attributes
if (!ie && c.length != d.length) return !1
for (var e, f, g = 0, h = 0, i = 0; (e = c[i++]); ) {
if ('style' == e.nodeName) {
if ((e.specified && g++, domUtils.isSameStyle(a, b))) continue
return !1
}
if (ie) {
if (!e.specified) continue
g++, (f = d.getNamedItem(e.nodeName))
} else f = b.attributes[e.nodeName]
if (!f.specified || e.nodeValue != f.nodeValue) return !1
}
if (ie) {
for (i = 0; (f = d[i++]); ) f.specified && h++
if (g != h) return !1
}
return !0
},
isSameStyle: function (a, b) {
var c = a.style.cssText
.replace(/( ?; ?)/g, ';')
.replace(/( ?: ?)/g, ':'),
d = b.style.cssText.replace(/( ?; ?)/g, ';').replace(/( ?: ?)/g, ':')
if (browser.opera) {
if (((c = a.style), (d = b.style), c.length != d.length)) return !1
for (var e in c)
if (!/^(\d+|csstext)$/i.test(e) && c[e] != d[e]) return !1
return !0
}
if (!c || !d) return c == d
if (((c = c.split(';')), (d = d.split(';')), c.length != d.length))
return !1
for (var f, g = 0; (f = c[g++]); )
if (utils.indexOf(d, f) == -1) return !1
return !0
},
isBlockElm: function (a) {
return (
1 == a.nodeType &&
(dtd.$block[a.tagName] ||
styleBlock[domUtils.getComputedStyle(a, 'display')]) &&
!dtd.$nonChild[a.tagName]
)
},
isBody: function (a) {
return a && 1 == a.nodeType && 'body' == a.tagName.toLowerCase()
},
breakParent: function (a, b) {
var c,
d,
e,
f = a,
g = a
do {
for (
f = f.parentNode,
d
? ((c = f.cloneNode(!1)),
c.appendChild(d),
(d = c),
(c = f.cloneNode(!1)),
c.appendChild(e),
(e = c))
: ((d = f.cloneNode(!1)), (e = d.cloneNode(!1)));
(c = g.previousSibling);
)
d.insertBefore(c, d.firstChild)
for (; (c = g.nextSibling); ) e.appendChild(c)
g = f
} while (b !== f)
return (
(c = b.parentNode),
c.insertBefore(d, b),
c.insertBefore(e, b),
c.insertBefore(a, e),
domUtils.remove(b),
a
)
},
isEmptyInlineElement: function (a) {
if (1 != a.nodeType || !dtd.$removeEmpty[a.tagName]) return 0
for (a = a.firstChild; a; ) {
if (domUtils.isBookmarkNode(a)) return 0
if (
(1 == a.nodeType && !domUtils.isEmptyInlineElement(a)) ||
(3 == a.nodeType && !domUtils.isWhitespace(a))
)
return 0
a = a.nextSibling
}
return 1
},
trimWhiteTextNode: function (a) {
function b(b) {
for (
var c;
(c = a[b]) && 3 == c.nodeType && domUtils.isWhitespace(c);
)
a.removeChild(c)
}
b('firstChild'), b('lastChild')
},
mergeChild: function (a, b, c) {
for (
var d,
e = domUtils.getElementsByTagName(a, a.tagName.toLowerCase()),
f = 0;
(d = e[f++]);
)
if (d.parentNode && !domUtils.isBookmarkNode(d))
if ('span' != d.tagName.toLowerCase())
domUtils.isSameElement(a, d) && domUtils.remove(d, !0)
else {
if (
a === d.parentNode &&
(domUtils.trimWhiteTextNode(a), 1 == a.childNodes.length)
) {
;(a.style.cssText = d.style.cssText + ';' + a.style.cssText),
domUtils.remove(d, !0)
continue
}
if (
((d.style.cssText = a.style.cssText + ';' + d.style.cssText), c)
) {
var g = c.style
if (g) {
g = g.split(';')
for (var h, i = 0; (h = g[i++]); )
d.style[utils.cssStyleToDomStyle(h.split(':')[0])] =
h.split(':')[1]
}
}
domUtils.isSameStyle(d, a) && domUtils.remove(d, !0)
}
},
getElementsByTagName: function (a, b, c) {
if (c && utils.isString(c)) {
var d = c
c = function (a) {
return domUtils.hasClass(a, d)
}
}
b = utils
.trim(b)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
for (var e, f = [], g = 0; (e = b[g++]); )
for (var h, i = a.getElementsByTagName(e), j = 0; (h = i[j++]); )
(c && !c(h)) || f.push(h)
return f
},
mergeToParent: function (a) {
for (var b = a.parentNode; b && dtd.$removeEmpty[b.tagName]; ) {
if (b.tagName == a.tagName || 'A' == b.tagName) {
if (
(domUtils.trimWhiteTextNode(b),
('SPAN' == b.tagName && !domUtils.isSameStyle(b, a)) ||
('A' == b.tagName && 'SPAN' == a.tagName))
) {
if (b.childNodes.length > 1 || b !== a.parentNode) {
;(a.style.cssText = b.style.cssText + ';' + a.style.cssText),
(b = b.parentNode)
continue
}
;(b.style.cssText += ';' + a.style.cssText),
'A' == b.tagName && (b.style.textDecoration = 'underline')
}
if ('A' != b.tagName) {
b === a.parentNode && domUtils.remove(a, !0)
break
}
}
b = b.parentNode
}
},
mergeSibling: function (a, b, c) {
function d(a, b, c) {
var d
if (
(d = c[a]) &&
!domUtils.isBookmarkNode(d) &&
1 == d.nodeType &&
domUtils.isSameElement(c, d)
) {
for (; d.firstChild; )
'firstChild' == b
? c.insertBefore(d.lastChild, c.firstChild)
: c.appendChild(d.firstChild)
domUtils.remove(d)
}
}
!b && d('previousSibling', 'firstChild', a),
!c && d('nextSibling', 'lastChild', a)
},
unSelectable:
(ie && browser.ie9below) || browser.opera
? function (a) {
;(a.onselectstart = function () {
return !1
}),
(a.onclick =
a.onkeyup =
a.onkeydown =
function () {
return !1
}),
(a.unselectable = 'on'),
a.setAttribute('unselectable', 'on')
for (var b, c = 0; (b = a.all[c++]); )
switch (b.tagName.toLowerCase()) {
case 'iframe':
case 'textarea':
case 'input':
case 'select':
break
default:
;(b.unselectable = 'on'),
a.setAttribute('unselectable', 'on')
}
}
: function (a) {
a.style.MozUserSelect =
a.style.webkitUserSelect =
a.style.msUserSelect =
a.style.KhtmlUserSelect =
'none'
},
removeAttributes: function (a, b) {
b = utils.isArray(b)
? b
: utils
.trim(b)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
for (var c, d = 0; (c = b[d++]); ) {
switch ((c = attrFix[c] || c)) {
case 'className':
a[c] = ''
break
case 'style':
a.style.cssText = ''
var e = a.getAttributeNode('style')
!browser.ie && e && a.removeAttributeNode(e)
}
a.removeAttribute(c)
}
},
createElement: function (a, b, c) {
return domUtils.setAttributes(a.createElement(b), c)
},
setAttributes: function (a, b) {
for (var c in b)
if (b.hasOwnProperty(c)) {
var d = b[c]
switch (c) {
case 'class':
a.className = d
break
case 'style':
a.style.cssText = a.style.cssText + ';' + d
break
case 'innerHTML':
a[c] = d
break
case 'value':
a.value = d
break
default:
a.setAttribute(attrFix[c] || c, d)
}
}
return a
},
getComputedStyle: function (a, b) {
var c = 'width height top left'
if (c.indexOf(b) > -1)
return (
a[
'offset' +
b.replace(/^\w/, function (a) {
return a.toUpperCase()
})
] + 'px'
)
if (
(3 == a.nodeType && (a = a.parentNode),
browser.ie &&
browser.version < 9 &&
'font-size' == b &&
!a.style.fontSize &&
!dtd.$empty[a.tagName] &&
!dtd.$nonChild[a.tagName])
) {
var d = a.ownerDocument.createElement('span')
;(d.style.cssText = 'padding:0;border:0;font-family:simsun;'),
(d.innerHTML = '.'),
a.appendChild(d)
var e = d.offsetHeight
return a.removeChild(d), (d = null), e + 'px'
}
try {
var f =
domUtils.getStyle(a, b) ||
(window.getComputedStyle
? domUtils
.getWindow(a)
.getComputedStyle(a, '')
.getPropertyValue(b)
: (a.currentStyle || a.style)[utils.cssStyleToDomStyle(b)])
} catch (g) {
return ''
}
return utils.transUnitToPx(utils.fixColor(b, f))
},
removeClasses: function (a, b) {
b = utils.isArray(b)
? b
: utils
.trim(b)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
for (var c, d = 0, e = a.className; (c = b[d++]); )
e = e.replace(new RegExp('\\b' + c + '\\b'), '')
;(e = utils.trim(e).replace(/[ ]{2,}/g, ' ')),
e ? (a.className = e) : domUtils.removeAttributes(a, ['class'])
},
addClass: function (a, b) {
if (a) {
b = utils
.trim(b)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
for (var c, d = 0, e = a.className; (c = b[d++]); )
new RegExp('\\b' + c + '\\b').test(e) || (e += ' ' + c)
a.className = utils.trim(e)
}
},
hasClass: function (a, b) {
if (utils.isRegExp(b)) return b.test(a.className)
b = utils
.trim(b)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
for (var c, d = 0, e = a.className; (c = b[d++]); )
if (!new RegExp('\\b' + c + '\\b', 'i').test(e)) return !1
return d - 1 == b.length
},
preventDefault: function (a) {
a.preventDefault ? a.preventDefault() : (a.returnValue = !1)
},
removeStyle: function (a, b) {
browser.ie
? ('color' == b && (b = '(^|;)' + b),
(a.style.cssText = a.style.cssText.replace(
new RegExp(b + '[^:]*:[^;]+;?', 'ig'),
''
)))
: a.style.removeProperty
? a.style.removeProperty(b)
: a.style.removeAttribute(utils.cssStyleToDomStyle(b)),
a.style.cssText || domUtils.removeAttributes(a, ['style'])
},
getStyle: function (a, b) {
var c = a.style[utils.cssStyleToDomStyle(b)]
return utils.fixColor(b, c)
},
setStyle: function (a, b, c) {
;(a.style[utils.cssStyleToDomStyle(b)] = c),
utils.trim(a.style.cssText) || this.removeAttributes(a, 'style')
},
setStyles: function (a, b) {
for (var c in b) b.hasOwnProperty(c) && domUtils.setStyle(a, c, b[c])
},
removeDirtyAttr: function (a) {
for (var b, c = 0, d = a.getElementsByTagName('*'); (b = d[c++]); )
b.removeAttribute('_moz_dirty')
a.removeAttribute('_moz_dirty')
},
getChildCount: function (a, b) {
var c = 0,
d = a.firstChild
for (
b =
b ||
function () {
return 1
};
d;
)
b(d) && c++, (d = d.nextSibling)
return c
},
isEmptyNode: function (a) {
return (
!a.firstChild ||
0 ==
domUtils.getChildCount(a, function (a) {
return (
!domUtils.isBr(a) &&
!domUtils.isBookmarkNode(a) &&
!domUtils.isWhitespace(a)
)
})
)
},
clearSelectedArr: function (a) {
for (var b; (b = a.pop()); ) domUtils.removeAttributes(b, ['class'])
},
scrollToView: function (a, b, c) {
var d = function () {
var a = b.document,
c = 'CSS1Compat' == a.compatMode
return {
width:
(c ? a.documentElement.clientWidth : a.body.clientWidth) || 0,
height:
(c ? a.documentElement.clientHeight : a.body.clientHeight) || 0
}
},
e = function (a) {
if ('pageXOffset' in a)
return { x: a.pageXOffset || 0, y: a.pageYOffset || 0 }
var b = a.document
return {
x: b.documentElement.scrollLeft || b.body.scrollLeft || 0,
y: b.documentElement.scrollTop || b.body.scrollTop || 0
}
},
f = d().height,
g = f * -1 + c
g += a.offsetHeight || 0
var h = domUtils.getXY(a)
g += h.y
var i = e(b).y
;(g > i || g < i - f) && b.scrollTo(0, g + (g < 0 ? -20 : 20))
},
isBr: function (a) {
return 1 == a.nodeType && 'BR' == a.tagName
},
isFillChar: function (a, b) {
if (3 != a.nodeType) return !1
var c = a.nodeValue
return b
? new RegExp('^' + domUtils.fillChar).test(c)
: !c.replace(new RegExp(domUtils.fillChar, 'g'), '').length
},
isStartInblock: function (a) {
var b,
c = a.cloneRange(),
d = 0,
e = c.startContainer
if (1 == e.nodeType && e.childNodes[c.startOffset]) {
e = e.childNodes[c.startOffset]
for (var f = e.previousSibling; f && domUtils.isFillChar(f); )
(e = f), (f = f.previousSibling)
}
for (
this.isFillChar(e, !0) &&
1 == c.startOffset &&
(c.setStartBefore(e), (e = c.startContainer));
e && domUtils.isFillChar(e);
)
(b = e), (e = e.previousSibling)
for (
b && (c.setStartBefore(b), (e = c.startContainer)),
1 == e.nodeType &&
domUtils.isEmptyNode(e) &&
1 == c.startOffset &&
c.setStart(e, 0).collapse(!0);
!c.startOffset;
) {
if (
((e = c.startContainer),
domUtils.isBlockElm(e) || domUtils.isBody(e))
) {
d = 1
break
}
var g,
f = c.startContainer.previousSibling
if (f) {
for (; f && domUtils.isFillChar(f); )
(g = f), (f = f.previousSibling)
g ? c.setStartBefore(g) : c.setStartBefore(c.startContainer)
} else c.setStartBefore(c.startContainer)
}
return d && !domUtils.isBody(c.startContainer) ? 1 : 0
},
isEmptyBlock: function (a, b) {
if (a) {
if (1 != a.nodeType) return 0
if (
((b = b || new RegExp('[ \t\r\n' + domUtils.fillChar + ']', 'g')),
a[browser.ie ? 'innerText' : 'textContent'].replace(b, '').length >
0)
)
return 0
for (var c in dtd.$isNotEmpty)
if (a.getElementsByTagName(c).length) return 0
return 1
}
},
setViewportOffset: function (a, b) {
var c = 0 | parseInt(a.style.left),
d = 0 | parseInt(a.style.top),
e = a.getBoundingClientRect(),
f = b.left - e.left,
g = b.top - e.top
f && (a.style.left = c + f + 'px'), g && (a.style.top = d + g + 'px')
},
fillNode: function (a, b) {
var c = browser.ie
? a.createTextNode(domUtils.fillChar)
: a.createElement('br')
;(b.innerHTML = ''), b.appendChild(c)
},
moveChild: function (a, b, c) {
for (; a.firstChild; )
c && b.firstChild
? b.insertBefore(a.lastChild, b.firstChild)
: b.appendChild(a.firstChild)
},
hasNoAttributes: function (a) {
return browser.ie
? /^<\w+\s*?>/.test(a.outerHTML)
: 0 == a.attributes.length
},
isCustomeNode: function (a) {
return 1 == a.nodeType && a.getAttribute('_ue_custom_node_')
},
isTagNode: function (a, b) {
return (
1 == a.nodeType && new RegExp('\\b' + a.tagName + '\\b', 'i').test(b)
)
},
filterNodeList: function (a, b, c) {
var d = []
if (!utils.isFunction(b)) {
var e = b
b = function (a) {
return (
utils.indexOf(
utils.isArray(e) ? e : e.split(' '),
a.tagName.toLowerCase()
) != -1
)
}
}
return (
utils.each(a, function (a) {
b(a) && d.push(a)
}),
0 == d.length ? null : 1 != d.length && c ? d : d[0]
)
},
isInNodeEndBoundary: function (a, b) {
var c = a.startContainer
if (3 == c.nodeType && a.startOffset != c.nodeValue.length) return 0
if (1 == c.nodeType && a.startOffset != c.childNodes.length) return 0
for (; c !== b; ) {
if (c.nextSibling) return 0
c = c.parentNode
}
return 1
},
isBoundaryNode: function (a, b) {
for (var c; !domUtils.isBody(a); )
if (((c = a), (a = a.parentNode), c !== a[b])) return !1
return !0
},
fillHtml: browser.ie11below ? ' ' : ' '
}),
fillCharReg = new RegExp(domUtils.fillChar, 'g')
!(function () {
function a(a) {
a.collapsed =
a.startContainer &&
a.endContainer &&
a.startContainer === a.endContainer &&
a.startOffset == a.endOffset
}
function b(a) {
return (
!a.collapsed &&
1 == a.startContainer.nodeType &&
a.startContainer === a.endContainer &&
a.endOffset - a.startOffset == 1
)
}
function c(b, c, d, e) {
return (
1 == c.nodeType &&
(dtd.$empty[c.tagName] || dtd.$nonChild[c.tagName]) &&
((d = domUtils.getNodeIndex(c) + (b ? 0 : 1)), (c = c.parentNode)),
b
? ((e.startContainer = c),
(e.startOffset = d),
e.endContainer || e.collapse(!0))
: ((e.endContainer = c),
(e.endOffset = d),
e.startContainer || e.collapse(!1)),
a(e),
e
)
}
function d(a, b) {
var c,
d,
e = a.startContainer,
f = a.endContainer,
g = a.startOffset,
h = a.endOffset,
i = a.document,
j = i.createDocumentFragment()
if (
(1 == e.nodeType &&
(e = e.childNodes[g] || (c = e.appendChild(i.createTextNode('')))),
1 == f.nodeType &&
(f = f.childNodes[h] || (d = f.appendChild(i.createTextNode('')))),
e === f && 3 == e.nodeType)
)
return (
j.appendChild(i.createTextNode(e.substringData(g, h - g))),
b && (e.deleteData(g, h - g), a.collapse(!0)),
j
)
for (
var k,
l,
m = j,
n = domUtils.findParents(e, !0),
o = domUtils.findParents(f, !0),
p = 0;
n[p] == o[p];
)
p++
for (var q, r = p; (q = n[r]); r++) {
for (
k = q.nextSibling,
q == e
? c ||
(3 == a.startContainer.nodeType
? (m.appendChild(i.createTextNode(e.nodeValue.slice(g))),
b && e.deleteData(g, e.nodeValue.length - g))
: m.appendChild(b ? e : e.cloneNode(!0)))
: ((l = q.cloneNode(!1)), m.appendChild(l));
k && k !== f && k !== o[r];
)
(q = k.nextSibling), m.appendChild(b ? k : k.cloneNode(!0)), (k = q)
m = l
}
;(m = j),
n[p] || (m.appendChild(n[p - 1].cloneNode(!1)), (m = m.firstChild))
for (var s, r = p; (s = o[r]); r++) {
if (
((k = s.previousSibling),
s == f
? d ||
3 != a.endContainer.nodeType ||
(m.appendChild(i.createTextNode(f.substringData(0, h))),
b && f.deleteData(0, h))
: ((l = s.cloneNode(!1)), m.appendChild(l)),
r != p || !n[p])
)
for (; k && k !== e; )
(s = k.previousSibling),
m.insertBefore(b ? k : k.cloneNode(!0), m.firstChild),
(k = s)
m = l
}
return (
b &&
a
.setStartBefore(o[p] ? (n[p] ? o[p] : n[p - 1]) : o[p - 1])
.collapse(!0),
c && domUtils.remove(c),
d && domUtils.remove(d),
j
)
}
function e(a, b) {
try {
if (g && domUtils.inDoc(g, a))
if (g.nodeValue.replace(fillCharReg, '').length)
g.nodeValue = g.nodeValue.replace(fillCharReg, '')
else {
var c = g.parentNode
for (
domUtils.remove(g);
c &&
domUtils.isEmptyInlineElement(c) &&
(browser.safari
? !(domUtils.getPosition(c, b) & domUtils.POSITION_CONTAINS)
: !c.contains(b));
)
(g = c.parentNode), domUtils.remove(c), (c = g)
}
} catch (d) {}
}
function f(a, b) {
var c
for (a = a[b]; a && domUtils.isFillChar(a); )
(c = a[b]), domUtils.remove(a), (a = c)
}
var g,
h = 0,
i = domUtils.fillChar,
j = (dom.Range = function (a) {
var b = this
;(b.startContainer =
b.startOffset =
b.endContainer =
b.endOffset =
null),
(b.document = a),
(b.collapsed = !0)
})
j.prototype = {
cloneContents: function () {
return this.collapsed ? null : d(this, 0)
},
deleteContents: function () {
var a
return (
this.collapsed || d(this, 1),
browser.webkit &&
((a = this.startContainer),
3 != a.nodeType ||
a.nodeValue.length ||
(this.setStartBefore(a).collapse(!0), domUtils.remove(a))),
this
)
},
extractContents: function () {
return this.collapsed ? null : d(this, 2)
},
setStart: function (a, b) {
return c(!0, a, b, this)
},
setEnd: function (a, b) {
return c(!1, a, b, this)
},
setStartAfter: function (a) {
return this.setStart(a.parentNode, domUtils.getNodeIndex(a) + 1)
},
setStartBefore: function (a) {
return this.setStart(a.parentNode, domUtils.getNodeIndex(a))
},
setEndAfter: function (a) {
return this.setEnd(a.parentNode, domUtils.getNodeIndex(a) + 1)
},
setEndBefore: function (a) {
return this.setEnd(a.parentNode, domUtils.getNodeIndex(a))
},
setStartAtFirst: function (a) {
return this.setStart(a, 0)
},
setStartAtLast: function (a) {
return this.setStart(
a,
3 == a.nodeType ? a.nodeValue.length : a.childNodes.length
)
},
setEndAtFirst: function (a) {
return this.setEnd(a, 0)
},
setEndAtLast: function (a) {
return this.setEnd(
a,
3 == a.nodeType ? a.nodeValue.length : a.childNodes.length
)
},
selectNode: function (a) {
return this.setStartBefore(a).setEndAfter(a)
},
selectNodeContents: function (a) {
return this.setStart(a, 0).setEndAtLast(a)
},
cloneRange: function () {
var a = this
return new j(a.document)
.setStart(a.startContainer, a.startOffset)
.setEnd(a.endContainer, a.endOffset)
},
collapse: function (a) {
var b = this
return (
a
? ((b.endContainer = b.startContainer),
(b.endOffset = b.startOffset))
: ((b.startContainer = b.endContainer),
(b.startOffset = b.endOffset)),
(b.collapsed = !0),
b
)
},
shrinkBoundary: function (a) {
function b(a) {
return (
1 == a.nodeType &&
!domUtils.isBookmarkNode(a) &&
!dtd.$empty[a.tagName] &&
!dtd.$nonChild[a.tagName]
)
}
for (
var c, d = this, e = d.collapsed;
1 == d.startContainer.nodeType &&
(c = d.startContainer.childNodes[d.startOffset]) &&
b(c);
)
d.setStart(c, 0)
if (e) return d.collapse(!0)
if (!a)
for (
;
1 == d.endContainer.nodeType &&
d.endOffset > 0 &&
(c = d.endContainer.childNodes[d.endOffset - 1]) &&
b(c);
)
d.setEnd(c, c.childNodes.length)
return d
},
getCommonAncestor: function (a, c) {
var d = this,
e = d.startContainer,
f = d.endContainer
return e === f
? a && b(this) && ((e = e.childNodes[d.startOffset]), 1 == e.nodeType)
? e
: c && 3 == e.nodeType
? e.parentNode
: e
: domUtils.getCommonAncestor(e, f)
},
trimBoundary: function (a) {
this.txtToElmBoundary()
var b = this.startContainer,
c = this.startOffset,
d = this.collapsed,
e = this.endContainer
if (3 == b.nodeType) {
if (0 == c) this.setStartBefore(b)
else if (c >= b.nodeValue.length) this.setStartAfter(b)
else {
var f = domUtils.split(b, c)
b === e
? this.setEnd(f, this.endOffset - c)
: b.parentNode === e && (this.endOffset += 1),
this.setStartBefore(f)
}
if (d) return this.collapse(!0)
}
return (
a ||
((c = this.endOffset),
(e = this.endContainer),
3 == e.nodeType &&
(0 == c
? this.setEndBefore(e)
: (c < e.nodeValue.length && domUtils.split(e, c),
this.setEndAfter(e)))),
this
)
},
txtToElmBoundary: function (a) {
function b(a, b) {
var c = a[b + 'Container'],
d = a[b + 'Offset']
3 == c.nodeType &&
(d
? d >= c.nodeValue.length &&
a[
'set' +
b.replace(/(\w)/, function (a) {
return a.toUpperCase()
}) +
'After'
](c)
: a[
'set' +
b.replace(/(\w)/, function (a) {
return a.toUpperCase()
}) +
'Before'
](c))
}
return (
(!a && this.collapsed) || (b(this, 'start'), b(this, 'end')), this
)
},
insertNode: function (a) {
var b = a,
c = 1
11 == a.nodeType && ((b = a.firstChild), (c = a.childNodes.length)),
this.trimBoundary(!0)
var d = this.startContainer,
e = this.startOffset,
f = d.childNodes[e]
return (
f ? d.insertBefore(a, f) : d.appendChild(a),
b.parentNode === this.endContainer &&
(this.endOffset = this.endOffset + c),
this.setStartBefore(b)
)
},
setCursor: function (a, b) {
return this.collapse(!a).select(b)
},
createBookmark: function (a, b) {
var c,
d = this.document.createElement('span')
return (
(d.style.cssText = 'display:none;line-height:0px;'),
d.appendChild(this.document.createTextNode('')),
(d.id = '_baidu_bookmark_start_' + (b ? '' : h++)),
this.collapsed ||
((c = d.cloneNode(!0)),
(c.id = '_baidu_bookmark_end_' + (b ? '' : h++))),
this.insertNode(d),
c && this.collapse().insertNode(c).setEndBefore(c),
this.setStartAfter(d),
{ start: a ? d.id : d, end: c ? (a ? c.id : c) : null, id: a }
)
},
moveToBookmark: function (a) {
var b = a.id ? this.document.getElementById(a.start) : a.start,
c = a.end && a.id ? this.document.getElementById(a.end) : a.end
return (
this.setStartBefore(b),
domUtils.remove(b),
c ? (this.setEndBefore(c), domUtils.remove(c)) : this.collapse(!0),
this
)
},
enlarge: function (a, b) {
var c,
d,
e = domUtils.isBody,
f = this.document.createTextNode('')
if (a) {
for (
d = this.startContainer,
1 == d.nodeType
? d.childNodes[this.startOffset]
? (c = d = d.childNodes[this.startOffset])
: (d.appendChild(f), (c = d = f))
: (c = d);
;
) {
if (domUtils.isBlockElm(d)) {
for (d = c; (c = d.previousSibling) && !domUtils.isBlockElm(c); )
d = c
this.setStartBefore(d)
break
}
;(c = d), (d = d.parentNode)
}
for (
d = this.endContainer,
1 == d.nodeType
? ((c = d.childNodes[this.endOffset])
? d.insertBefore(f, c)
: d.appendChild(f),
(c = d = f))
: (c = d);
;
) {
if (domUtils.isBlockElm(d)) {
for (d = c; (c = d.nextSibling) && !domUtils.isBlockElm(c); )
d = c
this.setEndAfter(d)
break
}
;(c = d), (d = d.parentNode)
}
f.parentNode === this.endContainer && this.endOffset--,
domUtils.remove(f)
}
if (!this.collapsed) {
for (
;
!(
0 != this.startOffset ||
(b && b(this.startContainer)) ||
e(this.startContainer)
);
)
this.setStartBefore(this.startContainer)
for (
;
!(
this.endOffset !=
(1 == this.endContainer.nodeType
? this.endContainer.childNodes.length
: this.endContainer.nodeValue.length) ||
(b && b(this.endContainer)) ||
e(this.endContainer)
);
)
this.setEndAfter(this.endContainer)
}
return this
},
enlargeToBlockElm: function (a) {
for (; !domUtils.isBlockElm(this.startContainer); )
this.setStartBefore(this.startContainer)
if (!a)
for (; !domUtils.isBlockElm(this.endContainer); )
this.setEndAfter(this.endContainer)
return this
},
adjustmentBoundary: function () {
if (!this.collapsed) {
for (
;
!domUtils.isBody(this.startContainer) &&
this.startOffset ==
this.startContainer[
3 == this.startContainer.nodeType ? 'nodeValue' : 'childNodes'
].length &&
this.startContainer[
3 == this.startContainer.nodeType ? 'nodeValue' : 'childNodes'
].length;
)
this.setStartAfter(this.startContainer)
for (
;
!domUtils.isBody(this.endContainer) &&
!this.endOffset &&
this.endContainer[
3 == this.endContainer.nodeType ? 'nodeValue' : 'childNodes'
].length;
)
this.setEndBefore(this.endContainer)
}
return this
},
applyInlineStyle: function (a, b, c) {
if (this.collapsed) return this
this.trimBoundary()
.enlarge(!1, function (a) {
return 1 == a.nodeType && domUtils.isBlockElm(a)
})
.adjustmentBoundary()
for (
var d,
e,
f = this.createBookmark(),
g = f.end,
h = function (a) {
return 1 == a.nodeType
? 'br' != a.tagName.toLowerCase()
: !domUtils.isWhitespace(a)
},
i = domUtils.getNextDomNode(f.start, !1, h),
j = this.cloneRange();
i && domUtils.getPosition(i, g) & domUtils.POSITION_PRECEDING;
)
if (3 == i.nodeType || dtd[a][i.tagName]) {
for (
j.setStartBefore(i), d = i;
d && (3 == d.nodeType || dtd[a][d.tagName]) && d !== g;
)
(e = d),
(d = domUtils.getNextDomNode(
d,
1 == d.nodeType,
null,
function (b) {
return dtd[a][b.tagName]
}
))
var k,
l = j.setEndAfter(e).extractContents()
if (c && c.length > 0) {
var m, n
n = m = c[0].cloneNode(!1)
for (var o, p = 1; (o = c[p++]); )
m.appendChild(o.cloneNode(!1)), (m = m.firstChild)
k = m
} else k = j.document.createElement(a)
b && domUtils.setAttributes(k, b),
k.appendChild(l),
j.insertNode(c ? n : k)
var q
if (
('span' == a &&
b.style &&
/text\-decoration/.test(b.style) &&
(q = domUtils.findParentByTagName(k, 'a', !0))
? (domUtils.setAttributes(q, b),
domUtils.remove(k, !0),
(k = q))
: (domUtils.mergeSibling(k), domUtils.clearEmptySibling(k)),
domUtils.mergeChild(k, b),
(i = domUtils.getNextDomNode(k, !1, h)),
domUtils.mergeToParent(k),
d === g)
)
break
} else i = domUtils.getNextDomNode(i, !0, h)
return this.moveToBookmark(f)
},
removeInlineStyle: function (a) {
if (this.collapsed) return this
;(a = utils.isArray(a) ? a : [a]),
this.shrinkBoundary().adjustmentBoundary()
for (var b = this.startContainer, c = this.endContainer; ; ) {
if (1 == b.nodeType) {
if (utils.indexOf(a, b.tagName.toLowerCase()) > -1) break
if ('body' == b.tagName.toLowerCase()) {
b = null
break
}
}
b = b.parentNode
}
for (;;) {
if (1 == c.nodeType) {
if (utils.indexOf(a, c.tagName.toLowerCase()) > -1) break
if ('body' == c.tagName.toLowerCase()) {
c = null
break
}
}
c = c.parentNode
}
var d,
e,
f = this.createBookmark()
b &&
((e = this.cloneRange().setEndBefore(f.start).setStartBefore(b)),
(d = e.extractContents()),
e.insertNode(d),
domUtils.clearEmptySibling(b, !0),
b.parentNode.insertBefore(f.start, b)),
c &&
((e = this.cloneRange().setStartAfter(f.end).setEndAfter(c)),
(d = e.extractContents()),
e.insertNode(d),
domUtils.clearEmptySibling(c, !1, !0),
c.parentNode.insertBefore(f.end, c.nextSibling))
for (
var g,
h = domUtils.getNextDomNode(f.start, !1, function (a) {
return 1 == a.nodeType
});
h && h !== f.end;
)
(g = domUtils.getNextDomNode(h, !0, function (a) {
return 1 == a.nodeType
})),
utils.indexOf(a, h.tagName.toLowerCase()) > -1 &&
domUtils.remove(h, !0),
(h = g)
return this.moveToBookmark(f)
},
getClosedNode: function () {
var a
if (!this.collapsed) {
var c = this.cloneRange().adjustmentBoundary().shrinkBoundary()
if (b(c)) {
var d = c.startContainer.childNodes[c.startOffset]
d &&
1 == d.nodeType &&
(dtd.$empty[d.tagName] || dtd.$nonChild[d.tagName]) &&
(a = d)
}
}
return a
},
select: browser.ie
? function (a, b) {
var c
this.collapsed || this.shrinkBoundary()
var d = this.getClosedNode()
if (d && !b) {
try {
;(c = this.document.body.createControlRange()),
c.addElement(d),
c.select()
} catch (h) {}
return this
}
var j,
k = this.createBookmark(),
l = k.start
if (
((c = this.document.body.createTextRange()),
c.moveToElementText(l),
c.moveStart('character', 1),
this.collapsed)
) {
if (!a && 3 != this.startContainer.nodeType) {
var m = this.document.createTextNode(i),
n = this.document.createElement('span')
n.appendChild(this.document.createTextNode(i)),
l.parentNode.insertBefore(n, l),
l.parentNode.insertBefore(m, l),
e(this.document, m),
(g = m),
f(n, 'previousSibling'),
f(l, 'nextSibling'),
c.moveStart('character', -1),
c.collapse(!0)
}
} else {
var o = this.document.body.createTextRange()
;(j = k.end), o.moveToElementText(j), c.setEndPoint('EndToEnd', o)
}
this.moveToBookmark(k), n && domUtils.remove(n)
try {
c.select()
} catch (h) {}
return this
}
: function (a) {
function b(a) {
function b(b, c, d) {
3 == b.nodeType &&
b.nodeValue.length < c &&
(a[d + 'Offset'] = b.nodeValue.length)
}
b(a.startContainer, a.startOffset, 'start'),
b(a.endContainer, a.endOffset, 'end')
}
var c,
d = domUtils.getWindow(this.document),
h = d.getSelection()
if ((browser.gecko ? this.document.body.focus() : d.focus(), h)) {
if ((h.removeAllRanges(), this.collapsed && !a)) {
var j = this.startContainer,
k = j
1 == j.nodeType && (k = j.childNodes[this.startOffset]),
(3 == j.nodeType && this.startOffset) ||
(k
? k.previousSibling && 3 == k.previousSibling.nodeType
: j.lastChild && 3 == j.lastChild.nodeType) ||
((c = this.document.createTextNode(i)),
this.insertNode(c),
e(this.document, c),
f(c, 'previousSibling'),
f(c, 'nextSibling'),
(g = c),
this.setStart(c, browser.webkit ? 1 : 0).collapse(!0))
}
var l = this.document.createRange()
if (
this.collapsed &&
browser.opera &&
1 == this.startContainer.nodeType
) {
var k = this.startContainer.childNodes[this.startOffset]
if (k) {
for (
;
k &&
domUtils.isBlockElm(k) &&
1 == k.nodeType &&
k.childNodes[0];
)
k = k.childNodes[0]
k && this.setStartBefore(k).collapse(!0)
} else
(k = this.startContainer.lastChild),
k && domUtils.isBr(k) && this.setStartBefore(k).collapse(!0)
}
b(this),
l.setStart(this.startContainer, this.startOffset),
l.setEnd(this.endContainer, this.endOffset),
h.addRange(l)
}
return this
},
scrollToView: function (a, b) {
a = a ? window : domUtils.getWindow(this.document)
var c = this,
d = c.document.createElement('span')
return (
(d.innerHTML = ' '),
c.cloneRange().insertNode(d),
domUtils.scrollToView(d, a, b),
domUtils.remove(d),
c
)
},
inFillChar: function () {
var a = this.startContainer
return !(
!this.collapsed ||
3 != a.nodeType ||
a.nodeValue.replace(new RegExp('^' + domUtils.fillChar), '').length +
1 !=
a.nodeValue.length
)
},
createAddress: function (a, b) {
function c(a) {
for (
var c,
d = a ? e.startContainer : e.endContainer,
f = domUtils.findParents(d, !0, function (a) {
return !domUtils.isBody(a)
}),
g = [],
h = 0;
(c = f[h++]);
)
g.push(domUtils.getNodeIndex(c, b))
var i = 0
if (b)
if (3 == d.nodeType) {
for (var j = d.previousSibling; j && 3 == j.nodeType; )
(i += j.nodeValue.replace(fillCharReg, '').length),
(j = j.previousSibling)
i += a ? e.startOffset : e.endOffset
} else if ((d = d.childNodes[a ? e.startOffset : e.endOffset]))
i = domUtils.getNodeIndex(d, b)
else {
d = a ? e.startContainer : e.endContainer
for (var k = d.firstChild; k; )
if (domUtils.isFillChar(k)) k = k.nextSibling
else if ((i++, 3 == k.nodeType))
for (; k && 3 == k.nodeType; ) k = k.nextSibling
else k = k.nextSibling
}
else
i = a ? (domUtils.isFillChar(d) ? 0 : e.startOffset) : e.endOffset
return i < 0 && (i = 0), g.push(i), g
}
var d = {},
e = this
return (
(d.startAddress = c(!0)),
a || (d.endAddress = e.collapsed ? [].concat(d.startAddress) : c()),
d
)
},
moveToAddress: function (a, b) {
function c(a, b) {
for (
var c, e, f, g = d.document.body, h = 0, i = a.length;
h < i;
h++
)
if (((f = a[h]), (c = g), (g = g.childNodes[f]), !g)) {
e = f
break
}
b
? g
? d.setStartBefore(g)
: d.setStart(c, e)
: g
? d.setEndBefore(g)
: d.setEnd(c, e)
}
var d = this
return c(a.startAddress, !0), !b && a.endAddress && c(a.endAddress), d
},
equals: function (a) {
for (var b in this)
if (this.hasOwnProperty(b) && this[b] !== a[b]) return !1
return !0
},
traversal: function (a, b) {
if (this.collapsed) return this
for (
var c = this.createBookmark(),
d = c.end,
e = domUtils.getNextDomNode(c.start, !1, b);
e &&
e !== d &&
domUtils.getPosition(e, d) & domUtils.POSITION_PRECEDING;
) {
var f = domUtils.getNextDomNode(e, !1, b)
a(e), (e = f)
}
return this.moveToBookmark(c)
}
}
})(),
(function () {
function a(a, b) {
var c = domUtils.getNodeIndex
;(a = a.duplicate()), a.collapse(b)
var d = a.parentElement()
if (!d.hasChildNodes()) return { container: d, offset: 0 }
for (
var e,
f,
g = d.children,
h = a.duplicate(),
i = 0,
j = g.length - 1,
k = -1;
i <= j;
) {
;(k = Math.floor((i + j) / 2)), (e = g[k]), h.moveToElementText(e)
var l = h.compareEndPoints('StartToStart', a)
if (l > 0) j = k - 1
else {
if (!(l < 0)) return { container: d, offset: c(e) }
i = k + 1
}
}
if (k == -1) {
if (
(h.moveToElementText(d),
h.setEndPoint('StartToStart', a),
(f = h.text.replace(/(\r\n|\r)/g, '\n').length),
(g = d.childNodes),
!f)
)
return (
(e = g[g.length - 1]),
{ container: e, offset: e.nodeValue.length }
)
for (var m = g.length; f > 0; ) f -= g[--m].nodeValue.length
return { container: g[m], offset: -f }
}
if (
(h.collapse(l > 0),
h.setEndPoint(l > 0 ? 'StartToStart' : 'EndToStart', a),
(f = h.text.replace(/(\r\n|\r)/g, '\n').length),
!f)
)
return dtd.$empty[e.tagName] || dtd.$nonChild[e.tagName]
? { container: d, offset: c(e) + (l > 0 ? 0 : 1) }
: { container: e, offset: l > 0 ? 0 : e.childNodes.length }
for (; f > 0; )
try {
var n = e
;(e = e[l > 0 ? 'previousSibling' : 'nextSibling']),
(f -= e.nodeValue.length)
} catch (o) {
return { container: d, offset: c(n) }
}
return { container: e, offset: l > 0 ? -f : e.nodeValue.length + f }
}
function b(b, c) {
if (b.item) c.selectNode(b.item(0))
else {
var d = a(b, !0)
c.setStart(d.container, d.offset),
0 != b.compareEndPoints('StartToEnd', b) &&
((d = a(b, !1)), c.setEnd(d.container, d.offset))
}
return c
}
function c(a) {
var b
try {
b = a.getNative().createRange()
} catch (c) {
return null
}
var d = b.item ? b.item(0) : b.parentElement()
return (d.ownerDocument || d) === a.document ? b : null
}
var d = (dom.Selection = function (a) {
var b,
d = this
;(d.document = a),
browser.ie9below &&
((b = domUtils.getWindow(a).frameElement),
domUtils.on(b, 'beforedeactivate', function () {
d._bakIERange = d.getIERange()
}),
domUtils.on(b, 'activate', function () {
try {
!c(d) && d._bakIERange && d._bakIERange.select()
} catch (a) {}
d._bakIERange = null
})),
(b = a = null)
})
d.prototype = {
rangeInBody: function (a, b) {
var c =
browser.ie9below || b
? a.item
? a.item()
: a.parentElement()
: a.startContainer
return c === this.document.body || domUtils.inDoc(c, this.document)
},
getNative: function () {
var a = this.document
try {
return a
? browser.ie9below
? a.selection
: domUtils.getWindow(a).getSelection()
: null
} catch (b) {
return null
}
},
getIERange: function () {
var a = c(this)
return !a && this._bakIERange ? this._bakIERange : a
},
cache: function () {
this.clear(),
(this._cachedRange = this.getRange()),
(this._cachedStartElement = this.getStart()),
(this._cachedStartElementPath = this.getStartElementPath())
},
getStartElementPath: function () {
if (this._cachedStartElementPath) return this._cachedStartElementPath
var a = this.getStart()
return a ? domUtils.findParents(a, !0, null, !0) : []
},
clear: function () {
this._cachedStartElementPath =
this._cachedRange =
this._cachedStartElement =
null
},
isFocus: function () {
try {
if (browser.ie9below) {
var a = c(this)
return !(!a || !this.rangeInBody(a))
}
return !!this.getNative().rangeCount
} catch (b) {
return !1
}
},
getRange: function () {
function a(a) {
for (
var b = c.document.body.firstChild, d = a.collapsed;
b && b.firstChild;
)
a.setStart(b, 0), (b = b.firstChild)
a.startContainer || a.setStart(c.document.body, 0),
d && a.collapse(!0)
}
var c = this
if (null != c._cachedRange) return this._cachedRange
var d = new baidu.editor.dom.Range(c.document)
if (browser.ie9below) {
var e = c.getIERange()
if (e)
try {
b(e, d)
} catch (f) {
a(d)
}
else a(d)
} else {
var g = c.getNative()
if (g && g.rangeCount) {
var h = g.getRangeAt(0),
i = g.getRangeAt(g.rangeCount - 1)
d
.setStart(h.startContainer, h.startOffset)
.setEnd(i.endContainer, i.endOffset),
d.collapsed &&
domUtils.isBody(d.startContainer) &&
!d.startOffset &&
a(d)
} else {
if (
this._bakRange &&
domUtils.inDoc(this._bakRange.startContainer, this.document)
)
return this._bakRange
a(d)
}
}
return (this._bakRange = d)
},
getStart: function () {
if (this._cachedStartElement) return this._cachedStartElement
var a,
b,
c,
d,
e = browser.ie9below ? this.getIERange() : this.getRange()
if (browser.ie9below) {
if (!e) return this.document.body.firstChild
if (e.item) return e.item(0)
for (
a = e.duplicate(),
a.text.length > 0 && a.moveStart('character', 1),
a.collapse(1),
b = a.parentElement(),
d = c = e.parentElement();
(c = c.parentNode);
)
if (c == b) {
b = d
break
}
} else if (
(e.shrinkBoundary(),
(b = e.startContainer),
1 == b.nodeType &&
b.hasChildNodes() &&
(b =
b.childNodes[Math.min(b.childNodes.length - 1, e.startOffset)]),
3 == b.nodeType)
)
return b.parentNode
return b
},
getText: function () {
var a, b
return this.isFocus() && (a = this.getNative())
? ((b = browser.ie9below ? a.createRange() : a.getRangeAt(0)),
browser.ie9below ? b.text : b.toString())
: ''
},
clearRange: function () {
this.getNative()[browser.ie9below ? 'empty' : 'removeAllRanges']()
}
}
})(),
(function () {
function a(a, b) {
var c
if (b.textarea)
if (utils.isString(b.textarea)) {
for (
var d, e = 0, f = domUtils.getElementsByTagName(a, 'textarea');
(d = f[e++]);
)
if (d.id == 'ueditor_textarea_' + b.options.textarea) {
c = d
break
}
} else c = b.textarea
c ||
(a.appendChild(
(c = domUtils.createElement(document, 'textarea', {
name: b.options.textarea,
id: 'ueditor_textarea_' + b.options.textarea,
style: 'display:none'
}))
),
(b.textarea = c)),
!c.getAttribute('name') && c.setAttribute('name', b.options.textarea),
(c.value = b.hasContents()
? b.options.allHtmlEnabled
? b.getAllHtml()
: b.getContent(null, null, !0)
: '')
}
function b(a) {
for (var b in a) return b
}
function c(a) {
;(a.langIsReady = !0), a.fireEvent('langReady')
}
var d,
e = 0,
f = (UE.Editor = function (a) {
var d = this
;(d.uid = e++),
EventBase.call(d),
(d.commands = {}),
(d.options = utils.extend(
utils.clone(a || {}),
UEDITOR_CONFIG,
!0
)),
(d.shortcutkeys = {}),
(d.inputRules = []),
(d.outputRules = []),
d.setOpt(f.defaultOptions(d)),
d.loadServerConfig(),
utils.isEmptyObject(UE.I18N)
? utils.loadFile(
document,
{
src:
d.options.langPath +
d.options.lang +
'/' +
d.options.lang +
'.js',
tag: 'script',
type: 'text/javascript',
defer: 'defer'
},
function () {
UE.plugin.load(d), c(d)
}
)
: ((d.options.lang = b(UE.I18N)), UE.plugin.load(d), c(d)),
(UE.instants['ueditorInstant' + d.uid] = d)
})
;(f.prototype = {
registerCommand: function (a, b) {
this.commands[a] = b
},
ready: function (a) {
var b = this
a && (b.isReady ? a.apply(b) : b.addListener('ready', a))
},
setOpt: function (a, b) {
var c = {}
utils.isString(a) ? (c[a] = b) : (c = a),
utils.extend(this.options, c, !0)
},
getOpt: function (a) {
return this.options[a]
},
destroy: function () {
var a = this
a.fireEvent('destroy')
var b = a.container.parentNode,
c = a.textarea
c
? (c.style.display = '')
: ((c = document.createElement('textarea')),
b.parentNode.insertBefore(c, b)),
(c.style.width = a.iframe.offsetWidth + 'px'),
(c.style.height = a.iframe.offsetHeight + 'px'),
(c.value = a.getContent()),
(c.id = a.key),
(b.innerHTML = ''),
domUtils.remove(b)
var d = a.key
for (var e in a) a.hasOwnProperty(e) && delete this[e]
UE.delEditor(d)
},
render: function (a) {
var b = this,
c = b.options,
d = function (b) {
return parseInt(domUtils.getComputedStyle(a, b))
}
if ((utils.isString(a) && (a = document.getElementById(a)), a)) {
c.initialFrameWidth
? (c.minFrameWidth = c.initialFrameWidth)
: (c.minFrameWidth = c.initialFrameWidth = a.offsetWidth),
c.initialFrameHeight
? (c.minFrameHeight = c.initialFrameHeight)
: (c.initialFrameHeight = c.minFrameHeight = a.offsetHeight),
(a.style.width = /%$/.test(c.initialFrameWidth)
? '100%'
: c.initialFrameWidth -
d('padding-left') -
d('padding-right') +
'px'),
(a.style.height = /%$/.test(c.initialFrameHeight)
? '100%'
: c.initialFrameHeight -
d('padding-top') -
d('padding-bottom') +
'px'),
(a.style.zIndex = c.zIndex)
var e =
(ie && browser.version < 9 ? '' : '') +
"
" +
(c.iframeCssUrl
? ""
: '') +
(c.initialStyle ? '' : '') +
""
a.appendChild(
domUtils.createElement(document, 'iframe', {
id: 'ueditor_' + b.uid,
width: '100%',
height: '100%',
frameborder: '0',
src:
'javascript:void(function(){document.open();' +
(c.customDomain && document.domain != location.hostname
? 'document.domain="' + document.domain + '";'
: '') +
'document.write("' +
e +
'");document.close();}())'
})
),
(a.style.overflow = 'hidden'),
setTimeout(function () {
;/%$/.test(c.initialFrameWidth) &&
(c.minFrameWidth = c.initialFrameWidth = a.offsetWidth),
/%$/.test(c.initialFrameHeight) &&
((c.minFrameHeight = c.initialFrameHeight = a.offsetHeight),
(a.style.height = c.initialFrameHeight + 'px'))
})
}
},
_setup: function (b) {
var c = this,
d = c.options
ie
? ((b.body.disabled = !0),
(b.body.contentEditable = !0),
(b.body.disabled = !1))
: (b.body.contentEditable = !0),
(b.body.spellcheck = !1),
(c.document = b),
(c.window = b.defaultView || b.parentWindow),
(c.iframe = c.window.frameElement),
(c.body = b.body),
(c.selection = new dom.Selection(b))
var e
browser.gecko &&
(e = this.selection.getNative()) &&
e.removeAllRanges(),
this._initEvents()
for (
var f = this.iframe.parentNode;
!domUtils.isBody(f);
f = f.parentNode
)
if ('FORM' == f.tagName) {
;(c.form = f),
c.options.autoSyncData
? domUtils.on(c.window, 'blur', function () {
a(f, c)
})
: domUtils.on(f, 'submit', function () {
a(this, c)
})
break
}
if (d.initialContent)
if (d.autoClearinitialContent) {
var g = c.execCommand
;(c.execCommand = function () {
return (
c.fireEvent('firstBeforeExecCommand'), g.apply(c, arguments)
)
}),
this._setDefaultContent(d.initialContent)
} else this.setContent(d.initialContent, !1, !0)
domUtils.isEmptyNode(c.body) &&
(c.body.innerHTML = '
' + (browser.ie ? '' : ' ') + '
'),
d.focus &&
setTimeout(function () {
c.focus(c.options.focusInEnd),
!c.options.autoClearinitialContent && c._selectionChange()
}, 0),
c.container || (c.container = this.iframe.parentNode),
d.fullscreen && c.ui && c.ui.setFullScreen(!0)
try {
c.document.execCommand('2D-position', !1, !1)
} catch (h) {}
try {
c.document.execCommand('enableInlineTableEditing', !1, !1)
} catch (h) {}
try {
c.document.execCommand('enableObjectResizing', !1, !1)
} catch (h) {}
c._bindshortcutKeys(),
(c.isReady = 1),
c.fireEvent('ready'),
d.onready && d.onready.call(c),
browser.ie9below ||
domUtils.on(c.window, ['blur', 'focus'], function (a) {
if ('blur' == a.type) {
c._bakRange = c.selection.getRange()
try {
;(c._bakNativeRange = c.selection
.getNative()
.getRangeAt(0)),
c.selection.getNative().removeAllRanges()
} catch (a) {
c._bakNativeRange = null
}
} else
try {
c._bakRange && c._bakRange.select()
} catch (a) {}
}),
browser.gecko &&
browser.version <= 10902 &&
((c.body.contentEditable = !1),
setTimeout(function () {
c.body.contentEditable = !0
}, 100),
setInterval(function () {
c.body.style.height = c.iframe.offsetHeight - 20 + 'px'
}, 100)),
!d.isShow && c.setHide(),
d.readonly && c.setDisabled()
},
sync: function (b) {
var c = this,
d = b
? document.getElementById(b)
: domUtils.findParent(
c.iframe.parentNode,
function (a) {
return 'FORM' == a.tagName
},
!0
)
d && a(d, c)
},
setHeight: function (a, b) {
a !== parseInt(this.iframe.parentNode.style.height) &&
(this.iframe.parentNode.style.height = a + 'px'),
!b &&
(this.options.minFrameHeight = this.options.initialFrameHeight =
a),
(this.body.style.height = a + 'px'),
!b && this.trigger('setHeight')
},
addshortcutkey: function (a, b) {
var c = {}
b ? (c[a] = b) : (c = a), utils.extend(this.shortcutkeys, c)
},
_bindshortcutKeys: function () {
var a = this,
b = this.shortcutkeys
a.addListener('keydown', function (c, d) {
var e = d.keyCode || d.which
for (var f in b)
for (var g, h = b[f].split(','), i = 0; (g = h[i++]); ) {
g = g.split(':')
var j = g[0],
k = g[1]
;(/^(ctrl)(\+shift)?\+(\d+)$/.test(j.toLowerCase()) ||
/^(\d+)$/.test(j)) &&
((('ctrl' == RegExp.$1 ? d.ctrlKey || d.metaKey : 0) &&
('' != RegExp.$2 ? d[RegExp.$2.slice(1) + 'Key'] : 1) &&
e == RegExp.$3) ||
e == RegExp.$1) &&
(a.queryCommandState(f, k) != -1 && a.execCommand(f, k),
domUtils.preventDefault(d))
}
})
},
getContent: function (a, b, c, d, e) {
var f = this
if (
(a && utils.isFunction(a) && ((b = a), (a = '')),
b ? !b() : !this.hasContents())
)
return ''
f.fireEvent('beforegetcontent')
var g = UE.htmlparser(f.body.innerHTML, d)
return (
f.filterOutputRule(g),
f.fireEvent('aftergetcontent', a, g),
g.toHtml(e)
)
},
getAllHtml: function () {
var a = this,
b = []
if (
(a.fireEvent('getAllHtml', b), browser.ie && browser.version > 8)
) {
var c = ''
utils.each(a.document.styleSheets, function (a) {
c += a.href
? ''
: ''
}),
utils.each(
a.document.getElementsByTagName('script'),
function (a) {
c += a.outerHTML
}
)
}
return (
'' +
(a.options.charset
? ''
: '') +
(c || a.document.getElementsByTagName('head')[0].innerHTML) +
b.join('\n') +
'' +
a.getContent(null, null, !0) +
''
)
},
getPlainTxt: function () {
var a = new RegExp(domUtils.fillChar, 'g'),
b = this.body.innerHTML.replace(/[\n\r]/g, '')
return (
(b = b
.replace(/<(p|div)[^>]*>( | )<\/\1>/gi, '\n')
.replace(/ /gi, '\n')
.replace(/<[^>\/]+>/g, '')
.replace(/(\n)?<\/([^>]+)>/g, function (a, b, c) {
return dtd.$block[c] ? '\n' : b ? b : ''
})),
b
.replace(a, '')
.replace(/\u00a0/g, ' ')
.replace(/ /g, ' ')
)
},
getContentTxt: function () {
var a = new RegExp(domUtils.fillChar, 'g')
return this.body[browser.ie ? 'innerText' : 'textContent']
.replace(a, '')
.replace(/\u00a0/g, ' ')
},
setContent: function (b, c, d) {
function e(a) {
return 'DIV' == a.tagName && a.getAttribute('cdata_tag')
}
var f = this
f.fireEvent('beforesetcontent', b)
var g = UE.htmlparser(b)
if (
(f.filterInputRule(g),
(b = g.toHtml()),
(f.body.innerHTML = (c ? f.body.innerHTML : '') + b),
'p' == f.options.enterTag)
) {
var h,
i = this.body.firstChild
if (
!i ||
(1 == i.nodeType &&
(dtd.$cdata[i.tagName] || e(i) || domUtils.isCustomeNode(i)) &&
i === this.body.lastChild)
)
this.body.innerHTML =
'
' +
(browser.ie ? ' ' : ' ') +
'
' +
this.body.innerHTML
else
for (var j = f.document.createElement('p'); i; ) {
for (
;
i &&
(3 == i.nodeType ||
(1 == i.nodeType &&
dtd.p[i.tagName] &&
!dtd.$cdata[i.tagName]));
)
(h = i.nextSibling), j.appendChild(i), (i = h)
if (j.firstChild) {
if (!i) {
f.body.appendChild(j)
break
}
i.parentNode.insertBefore(j, i),
(j = f.document.createElement('p'))
}
i = i.nextSibling
}
}
f.fireEvent('aftersetcontent'),
f.fireEvent('contentchange'),
!d && f._selectionChange(),
(f._bakRange = f._bakIERange = f._bakNativeRange = null)
var k
browser.gecko &&
(k = this.selection.getNative()) &&
k.removeAllRanges(),
f.options.autoSyncData && f.form && a(f.form, f)
},
focus: function (a) {
try {
var b = this,
c = b.selection.getRange()
if (a) {
var d = b.body.lastChild
d &&
1 == d.nodeType &&
!dtd.$empty[d.tagName] &&
(domUtils.isEmptyBlock(d)
? c.setStartAtFirst(d)
: c.setStartAtLast(d),
c.collapse(!0)),
c.setCursor(!0)
} else {
if (
!c.collapsed &&
domUtils.isBody(c.startContainer) &&
0 == c.startOffset
) {
var d = b.body.firstChild
d &&
1 == d.nodeType &&
!dtd.$empty[d.tagName] &&
c.setStartAtFirst(d).collapse(!0)
}
c.select(!0)
}
this.fireEvent('focus selectionchange')
} catch (e) {}
},
isFocus: function () {
return this.selection.isFocus()
},
blur: function () {
var a = this.selection.getNative()
if (a.empty && browser.ie) {
var b = document.body.createTextRange()
b.moveToElementText(document.body),
b.collapse(!0),
b.select(),
a.empty()
} else a.removeAllRanges()
},
_initEvents: function () {
var a = this,
b = a.document,
c = a.window
;(a._proxyDomEvent = utils.bind(a._proxyDomEvent, a)),
domUtils.on(
b,
[
'click',
'contextmenu',
'mousedown',
'keydown',
'keyup',
'keypress',
'mouseup',
'mouseover',
'mouseout',
'selectstart'
],
a._proxyDomEvent
),
domUtils.on(c, ['focus', 'blur'], a._proxyDomEvent),
domUtils.on(a.body, 'drop', function (b) {
browser.gecko && b.stopPropagation && b.stopPropagation(),
a.fireEvent('contentchange')
}),
domUtils.on(b, ['mouseup', 'keydown'], function (b) {
;('keydown' == b.type &&
(b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) ||
(2 != b.button && a._selectionChange(250, b))
})
},
_proxyDomEvent: function (a) {
return (
this.fireEvent(
'before' + a.type.replace(/^on/, '').toLowerCase()
) !== !1 &&
this.fireEvent(a.type.replace(/^on/, ''), a) !== !1 &&
this.fireEvent('after' + a.type.replace(/^on/, '').toLowerCase())
)
},
_selectionChange: function (a, b) {
var c,
e,
f = this,
g = !1
if (browser.ie && browser.version < 9 && b && 'mouseup' == b.type) {
var h = this.selection.getRange()
h.collapsed || ((g = !0), (c = b.clientX), (e = b.clientY))
}
clearTimeout(d),
(d = setTimeout(function () {
if (f.selection && f.selection.getNative()) {
var a
if (g && 'None' == f.selection.getNative().type) {
a = f.document.body.createTextRange()
try {
a.moveToPoint(c, e)
} catch (d) {
a = null
}
}
var h
a &&
((h = f.selection.getIERange),
(f.selection.getIERange = function () {
return a
})),
f.selection.cache(),
h && (f.selection.getIERange = h),
f.selection._cachedRange &&
f.selection._cachedStartElement &&
(f.fireEvent('beforeselectionchange'),
f.fireEvent('selectionchange', !!b),
f.fireEvent('afterselectionchange'),
f.selection.clear())
}
}, a || 50))
},
_callCmdFn: function (a, b) {
var c,
d,
e = b[0].toLowerCase()
return (
(c = this.commands[e] || UE.commands[e]),
(d = c && c[a]),
(c && d) || 'queryCommandState' != a
? d
? d.apply(this, b)
: void 0
: 0
)
},
execCommand: function (a) {
a = a.toLowerCase()
var b,
c = this,
d = c.commands[a] || UE.commands[a]
return d && d.execCommand
? (d.notNeedUndo || c.__hasEnterExecCommand
? ((b = this._callCmdFn('execCommand', arguments)),
!c.__hasEnterExecCommand &&
!d.ignoreContentChange &&
!c._ignoreContentChange &&
c.fireEvent('contentchange'))
: ((c.__hasEnterExecCommand = !0),
c.queryCommandState.apply(c, arguments) != -1 &&
(c.fireEvent('saveScene'),
c.fireEvent.apply(
c,
['beforeexeccommand', a].concat(arguments)
),
(b = this._callCmdFn('execCommand', arguments)),
c.fireEvent.apply(
c,
['afterexeccommand', a].concat(arguments)
),
c.fireEvent('saveScene')),
(c.__hasEnterExecCommand = !1)),
!c.__hasEnterExecCommand &&
!d.ignoreContentChange &&
!c._ignoreContentChange &&
c._selectionChange(),
b)
: null
},
queryCommandState: function (a) {
return this._callCmdFn('queryCommandState', arguments)
},
queryCommandValue: function (a) {
return this._callCmdFn('queryCommandValue', arguments)
},
hasContents: function (a) {
if (a)
for (var b, c = 0; (b = a[c++]); )
if (this.document.getElementsByTagName(b).length > 0) return !0
if (!domUtils.isEmptyBlock(this.body)) return !0
for (a = ['div'], c = 0; (b = a[c++]); )
for (
var d, e = domUtils.getElementsByTagName(this.document, b), f = 0;
(d = e[f++]);
)
if (domUtils.isCustomeNode(d)) return !0
return !1
},
reset: function () {
this.fireEvent('reset')
},
setEnabled: function () {
var a,
b = this
if ('false' == b.body.contentEditable) {
;(b.body.contentEditable = !0), (a = b.selection.getRange())
try {
a.moveToBookmark(b.lastBk), delete b.lastBk
} catch (c) {
a.setStartAtFirst(b.body).collapse(!0)
}
a.select(!0),
b.bkqueryCommandState &&
((b.queryCommandState = b.bkqueryCommandState),
delete b.bkqueryCommandState),
b.bkqueryCommandValue &&
((b.queryCommandValue = b.bkqueryCommandValue),
delete b.bkqueryCommandValue),
b.fireEvent('selectionchange')
}
},
enable: function () {
return this.setEnabled()
},
setDisabled: function (a) {
var b = this
;(a = a ? (utils.isArray(a) ? a : [a]) : []),
'true' == b.body.contentEditable &&
(b.lastBk ||
(b.lastBk = b.selection.getRange().createBookmark(!0)),
(b.body.contentEditable = !1),
(b.bkqueryCommandState = b.queryCommandState),
(b.bkqueryCommandValue = b.queryCommandValue),
(b.queryCommandState = function (c) {
return utils.indexOf(a, c) != -1
? b.bkqueryCommandState.apply(b, arguments)
: -1
}),
(b.queryCommandValue = function (c) {
return utils.indexOf(a, c) != -1
? b.bkqueryCommandValue.apply(b, arguments)
: null
}),
b.fireEvent('selectionchange'))
},
disable: function (a) {
return this.setDisabled(a)
},
_setDefaultContent: (function () {
function a() {
var b = this
b.document.getElementById('initContent') &&
((b.body.innerHTML = '
' + (ie ? '' : ' ') + '
'),
b.removeListener('firstBeforeExecCommand focus', a),
setTimeout(function () {
b.focus(), b._selectionChange()
}, 0))
}
return function (b) {
var c = this
;(c.body.innerHTML = '
' + b + '
'),
c.addListener('firstBeforeExecCommand focus', a)
}
})(),
setShow: function () {
var a = this,
b = a.selection.getRange()
if ('none' == a.container.style.display) {
try {
b.moveToBookmark(a.lastBk), delete a.lastBk
} catch (c) {
b.setStartAtFirst(a.body).collapse(!0)
}
setTimeout(function () {
b.select(!0)
}, 100),
(a.container.style.display = '')
}
},
show: function () {
return this.setShow()
},
setHide: function () {
var a = this
a.lastBk || (a.lastBk = a.selection.getRange().createBookmark(!0)),
(a.container.style.display = 'none')
},
hide: function () {
return this.setHide()
},
getLang: function (a) {
if (!this.options) return ''
var b = UE.I18N[this.options.lang]
if (!b) throw Error('not import language file')
a = (a || '').split('.')
for (var c, d = 0; (c = a[d++]) && ((b = b[c]), b); );
return b
},
getContentLength: function (a, b) {
var c = this.getContent(!1, !1, !0).length
if (a) {
;(b = (b || []).concat(['hr', 'img', 'iframe'])),
(c = this.getContentTxt().replace(/[\t\r\n]+/g, '').length)
for (var d, e = 0; (d = b[e++]); )
c += this.document.getElementsByTagName(d).length
}
return c
},
addInputRule: function (a) {
this.inputRules.push(a)
},
filterInputRule: function (a) {
for (var b, c = 0; (b = this.inputRules[c++]); ) b.call(this, a)
},
addOutputRule: function (a) {
this.outputRules.push(a)
},
filterOutputRule: function (a) {
for (var b, c = 0; (b = this.outputRules[c++]); ) b.call(this, a)
},
getActionUrl: function (a) {
var b = this.getOpt(a) || a,
c = this.getOpt('imageUrl'),
d = this.getOpt('serverUrl')
return (
!d &&
c &&
(d = c.replace(/^(.*[\/]).+([\.].+)$/, '$1controller$2')),
d
? ((d =
d +
(d.indexOf('?') == -1 ? '?' : '&') +
'action=' +
(b || '')),
utils.formatUrl(d))
: ''
)
}
}),
utils.inherits(f, EventBase)
})(),
(UE.Editor.defaultOptions = function (a) {
var b = a.options.UEDITOR_HOME_URL
return {
isShow: !0,
initialContent: '',
initialStyle: '',
autoClearinitialContent: !1,
iframeCssUrl: b + 'themes/iframe.css',
textarea: 'editorValue',
focus: !1,
focusInEnd: !0,
autoClearEmptyNode: !0,
fullscreen: !1,
readonly: !1,
zIndex: 999,
imagePopup: !0,
enterTag: 'p',
customDomain: !1,
lang: 'zh-cn',
langPath: b + 'lang/',
theme: 'default',
themePath: b + 'themes/',
allHtmlEnabled: !1,
scaleEnabled: !1,
tableNativeEditInFF: !1,
autoSyncData: !0,
fileNameFormat: '{time}{rand:6}'
}
}),
(function () {
;(UE.Editor.prototype.loadServerConfig = function () {
function showErrorMsg(a) {
console && console.error(a)
}
var me = this
setTimeout(function () {
try {
me.options.imageUrl &&
me.setOpt(
'serverUrl',
me.options.imageUrl.replace(
/^(.*[\/]).+([\.].+)$/,
'$1controller$2'
)
)
var configUrl = me.getActionUrl('config'),
isJsonp = utils.isCrossDomainUrl(configUrl)
;(me._serverConfigLoaded = !1),
configUrl &&
UE.ajax.request(configUrl, {
method: 'GET',
dataType: isJsonp ? 'jsonp' : '',
onsuccess: function (r) {
try {
var config = isJsonp
? r
: eval('(' + r.responseText + ')')
utils.extend(me.options, config),
me.fireEvent('serverConfigLoaded'),
(me._serverConfigLoaded = !0)
} catch (e) {
showErrorMsg(me.getLang('loadconfigFormatError'))
}
},
onerror: function () {
showErrorMsg(me.getLang('loadconfigHttpError'))
}
})
} catch (e) {
showErrorMsg(me.getLang('loadconfigError'))
}
})
}),
(UE.Editor.prototype.isServerConfigLoaded = function () {
var a = this
return a._serverConfigLoaded || !1
}),
(UE.Editor.prototype.afterConfigReady = function (a) {
if (a && utils.isFunction(a)) {
var b = this,
c = function () {
a.apply(b, arguments), b.removeListener('serverConfigLoaded', c)
}
b.isServerConfigLoaded()
? a.call(b, 'serverConfigLoaded')
: b.addListener('serverConfigLoaded', c)
}
})
})(),
(UE.ajax = (function () {
function a(a) {
var b = []
for (var c in a)
if (
'method' != c &&
'timeout' != c &&
'async' != c &&
'dataType' != c &&
'callback' != c &&
void 0 != a[c] &&
null != a[c]
)
if (
'function' != (typeof a[c]).toLowerCase() &&
'object' != (typeof a[c]).toLowerCase()
)
b.push(encodeURIComponent(c) + '=' + encodeURIComponent(a[c]))
else if (utils.isArray(a[c]))
for (var d = 0; d < a[c].length; d++)
b.push(
encodeURIComponent(c) + '[]=' + encodeURIComponent(a[c][d])
)
return b.join('&')
}
function b(b, c) {
var d = f(),
e = !1,
g = {
method: 'POST',
timeout: 5e3,
async: !0,
data: {},
onsuccess: function () {},
onerror: function () {}
}
if (('object' == typeof b && ((c = b), (b = c.url)), d && b)) {
var h = c ? utils.extend(g, c) : g,
i = a(h)
utils.isEmptyObject(h.data) || (i += (i ? '&' : '') + a(h.data))
var j = setTimeout(function () {
4 != d.readyState && ((e = !0), d.abort(), clearTimeout(j))
}, h.timeout),
k = h.method.toUpperCase(),
l =
b +
(b.indexOf('?') == -1 ? '?' : '&') +
('POST' == k ? '' : i + '&noCache=' + +new Date())
d.open(k, l, h.async),
(d.onreadystatechange = function () {
4 == d.readyState &&
(e || 200 != d.status ? h.onerror(d) : h.onsuccess(d))
}),
'POST' == k
? (d.setRequestHeader(
'Content-Type',
'application/x-www-form-urlencoded'
),
d.send(i))
: d.send(null)
}
}
function c(b, c) {
function d(a, b, c) {
a.setAttribute('type', 'text/javascript'),
a.setAttribute('defer', 'defer'),
c && a.setAttribute('charset', c),
a.setAttribute('src', b),
document.getElementsByTagName('head')[0].appendChild(a)
}
function e(a) {
return function () {
try {
if (a) k.onerror && k.onerror()
else
try {
clearTimeout(g), i.apply(window, arguments)
} catch (b) {}
} catch (c) {
k.onerror && k.onerror.call(window, c)
} finally {
k.oncomplete && k.oncomplete.apply(window, arguments),
j.parentNode && j.parentNode.removeChild(j),
(window[f] = null)
try {
delete window[f]
} catch (b) {}
}
}
}
var f,
g,
h,
i = c.onsuccess || function () {},
j = document.createElement('SCRIPT'),
k = c || {},
l = k.charset,
m = k.jsonp || 'callback',
n = k.timeOut || 0,
o = new RegExp('(\\?|&)' + m + '=([^&]*)')
utils.isFunction(i)
? ((f =
'bd__editor__' +
Math.floor(2147483648 * Math.random()).toString(36)),
(window[f] = e(0)))
: utils.isString(i)
? (f = i)
: (h = o.exec(b)) && (f = h[2]),
(b = b.replace(o, '$1' + m + '=' + f)),
b.search(o) < 0 &&
(b += (b.indexOf('?') < 0 ? '?' : '&') + m + '=' + f)
var p = a(c)
utils.isEmptyObject(c.data) || (p += (p ? '&' : '') + a(c.data)),
p && (b = b.replace(/\?/, '?' + p + '&')),
(j.onerror = e(1)),
n && (g = setTimeout(e(1), n)),
d(j, b, l)
}
var d = 'XMLHttpRequest()'
try {
new ActiveXObject('Msxml2.XMLHTTP'),
(d = "ActiveXObject('Msxml2.XMLHTTP')")
} catch (e) {
try {
new ActiveXObject('Microsoft.XMLHTTP'),
(d = "ActiveXObject('Microsoft.XMLHTTP')")
} catch (e) {}
}
var f = new Function('return new ' + d)
return {
request: function (a, d) {
d && 'jsonp' == d.dataType ? c(a, d) : b(a, d)
},
getJSONP: function (a, b, d) {
var e = { data: b, oncomplete: d }
c(a, e)
}
}
})())
var filterWord = (UE.filterWord = (function () {
function a(a) {
return /(class="?Mso|style="[^"]*\bmso\-|w:WordDocument|<(v|o):|lang=)/gi.test(
a
)
}
function b(a) {
return (a = a.replace(/[\d.]+\w+/g, function (a) {
return utils.transUnitToPx(a)
}))
}
function c(a) {
return a
.replace(/[\t\r\n]+/g, ' ')
.replace(//gi, '')
.replace(/]*>[\s\S]*?.<\/v:shape>/gi, function (a) {
if (browser.opera) return ''
try {
if (/Bitmap/i.test(a)) return ''
var c = a.match(/width:([ \d.]*p[tx])/i)[1],
d = a.match(/height:([ \d.]*p[tx])/i)[1],
e = a.match(/src=\s*"([^"]*)"/i)[1]
return (
''
)
} catch (f) {
return ''
}
})
.replace(/<\/?div[^>]*>/g, '')
.replace(/v:\w+=(["']?)[^'"]+\1/g, '')
.replace(
/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|xml|meta|link|style|\w+:\w+)(?=[\s\/>]))[^>]*>/gi,
''
)
.replace(
/
]*class="?MsoHeading"?[^>]*>(.*?)<\/p>/gi,
'
$1
'
)
.replace(
/\s+(class|lang|align)\s*=\s*(['"]?)([\w-]+)\2/gi,
function (a, b, c, d) {
return 'class' == b && 'MsoListParagraph' == d ? a : ''
}
)
.replace(/<(font|span)[^>]*>(\s*)<\/\1>/gi, function (a, b, c) {
return c.replace(/[\t\r\n ]+/g, ' ')
})
.replace(
/(<[a-z][^>]*)\sstyle=(["'])([^\2]*?)\2/gi,
function (a, c, d, e) {
for (
var f,
g = [],
h = e
.replace(/^\s+|\s+$/, '')
.replace(/'/g, "'")
.replace(/"/gi, "'")
.replace(/[\d.]+(cm|pt)/g, function (a) {
return utils.transUnitToPx(a)
})
.split(/;\s*/g),
i = 0;
(f = h[i]);
i++
) {
var j,
k,
l = f.split(':')
if (2 == l.length) {
if (
((j = l[0].toLowerCase()),
(k = l[1].toLowerCase()),
(/^(background)\w*/.test(j) &&
0 == k.replace(/(initial|\s)/g, '').length) ||
(/^(margin)\w*/.test(j) && /^0\w+$/.test(k)))
)
continue
switch (j) {
case 'mso-padding-alt':
case 'mso-padding-top-alt':
case 'mso-padding-right-alt':
case 'mso-padding-bottom-alt':
case 'mso-padding-left-alt':
case 'mso-margin-alt':
case 'mso-margin-top-alt':
case 'mso-margin-right-alt':
case 'mso-margin-bottom-alt':
case 'mso-margin-left-alt':
case 'mso-height':
case 'mso-width':
case 'mso-vertical-align-alt':
;/
1 &&
(a(h, j, !0), b(h, j)),
c(k, h, i, j)
break
case 'text':
d(g, h)
break
case 'element':
e(g, h, i, j)
break
case 'comment':
f(g, h, i)
}
return h
}
function d(a, b) {
'pre' == a.parentNode.tagName
? b.push(a.data)
: b.push(
l[a.parentNode.tagName]
? utils.html(a.data)
: a.data.replace(/[ ]{2}/g, ' ')
)
}
function e(d, e, f, g) {
var h = ''
if (d.attrs) {
h = []
var i = d.attrs
for (var j in i)
h.push(
j +
(void 0 !== i[j]
? '="' +
(k[j]
? utils.html(i[j]).replace(/["]/g, function (a) {
return '"'
})
: utils.unhtml(i[j])) +
'"'
: '')
)
h = h.join(' ')
}
if (
(e.push(
'<' +
d.tagName +
(h ? ' ' + h : '') +
(dtd.$empty[d.tagName] ? '/' : '') +
'>'
),
f &&
!dtd.$inlineWithA[d.tagName] &&
'pre' != d.tagName &&
d.children &&
d.children.length &&
((g = a(e, g, !0)), b(e, g)),
d.children && d.children.length)
)
for (var l, m = 0; (l = d.children[m++]); )
f &&
'element' == l.type &&
!dtd.$inlineWithA[l.tagName] &&
m > 1 &&
(a(e, g), b(e, g)),
c(l, e, f, g)
dtd.$empty[d.tagName] ||
(f &&
!dtd.$inlineWithA[d.tagName] &&
'pre' != d.tagName &&
d.children &&
d.children.length &&
((g = a(e, g)), b(e, g)),
e.push('' + d.tagName + '>'))
}
function f(a, b) {
b.push('')
}
function g(a, b) {
var c
if ('element' == a.type && a.getAttr('id') == b) return a
if (a.children && a.children.length)
for (var d, e = 0; (d = a.children[e++]); ) if ((c = g(d, b))) return c
}
function h(a, b, c) {
if (
('element' == a.type && a.tagName == b && c.push(a),
a.children && a.children.length)
)
for (var d, e = 0; (d = a.children[e++]); ) h(d, b, c)
}
function i(a, b) {
if (a.children && a.children.length)
for (var c, d = 0; (c = a.children[d]); )
i(c, b),
c.parentNode &&
(c.children && c.children.length && b(c), c.parentNode && d++)
else b(a)
}
var j = (UE.uNode = function (a) {
;(this.type = a.type),
(this.data = a.data),
(this.tagName = a.tagName),
(this.parentNode = a.parentNode),
(this.attrs = a.attrs || {}),
(this.children = a.children)
}),
k = { href: 1, src: 1, _src: 1, _href: 1, cdata_data: 1 },
l = { style: 1, script: 1 },
m = ' ',
n = '\n'
;(j.createElement = function (a) {
return /[<>]/.test(a)
? UE.htmlparser(a).children[0]
: new j({ type: 'element', children: [], tagName: a })
}),
(j.createText = function (a, b) {
return new UE.uNode({
type: 'text',
data: b ? a : utils.unhtml(a || '')
})
}),
(j.prototype = {
toHtml: function (a) {
var b = []
return c(this, b, a, 0), b.join('')
},
innerHTML: function (a) {
if ('element' != this.type || dtd.$empty[this.tagName]) return this
if (utils.isString(a)) {
if (this.children)
for (var b, c = 0; (b = this.children[c++]); ) b.parentNode = null
this.children = []
for (var b, d = UE.htmlparser(a), c = 0; (b = d.children[c++]); )
this.children.push(b), (b.parentNode = this)
return this
}
var d = new UE.uNode({ type: 'root', children: this.children })
return d.toHtml()
},
innerText: function (a, b) {
if ('element' != this.type || dtd.$empty[this.tagName]) return this
if (a) {
if (this.children)
for (var c, d = 0; (c = this.children[d++]); ) c.parentNode = null
return (
(this.children = []), this.appendChild(j.createText(a, b)), this
)
}
return this.toHtml().replace(/<[^>]+>/g, '')
},
getData: function () {
return 'element' == this.type ? '' : this.data
},
firstChild: function () {
return this.children ? this.children[0] : null
},
lastChild: function () {
return this.children ? this.children[this.children.length - 1] : null
},
previousSibling: function () {
for (var a, b = this.parentNode, c = 0; (a = b.children[c]); c++)
if (a === this) return 0 == c ? null : b.children[c - 1]
},
nextSibling: function () {
for (var a, b = this.parentNode, c = 0; (a = b.children[c++]); )
if (a === this) return b.children[c]
},
replaceChild: function (a, b) {
if (this.children) {
a.parentNode && a.parentNode.removeChild(a)
for (var c, d = 0; (c = this.children[d]); d++)
if (c === b)
return (
this.children.splice(d, 1, a),
(b.parentNode = null),
(a.parentNode = this),
a
)
}
},
appendChild: function (a) {
if (
'root' == this.type ||
('element' == this.type && !dtd.$empty[this.tagName])
) {
this.children || (this.children = []),
a.parentNode && a.parentNode.removeChild(a)
for (var b, c = 0; (b = this.children[c]); c++)
if (b === a) {
this.children.splice(c, 1)
break
}
return this.children.push(a), (a.parentNode = this), a
}
},
insertBefore: function (a, b) {
if (this.children) {
a.parentNode && a.parentNode.removeChild(a)
for (var c, d = 0; (c = this.children[d]); d++)
if (c === b)
return this.children.splice(d, 0, a), (a.parentNode = this), a
}
},
insertAfter: function (a, b) {
if (this.children) {
a.parentNode && a.parentNode.removeChild(a)
for (var c, d = 0; (c = this.children[d]); d++)
if (c === b)
return (
this.children.splice(d + 1, 0, a), (a.parentNode = this), a
)
}
},
removeChild: function (a, b) {
if (this.children)
for (var c, d = 0; (c = this.children[d]); d++)
if (c === a) {
if (
(this.children.splice(d, 1),
(c.parentNode = null),
b && c.children && c.children.length)
)
for (var e, f = 0; (e = c.children[f]); f++)
this.children.splice(d + f, 0, e), (e.parentNode = this)
return c
}
},
getAttr: function (a) {
return this.attrs && this.attrs[a.toLowerCase()]
},
setAttr: function (a, b) {
if (!a) return void delete this.attrs
if ((this.attrs || (this.attrs = {}), utils.isObject(a)))
for (var c in a)
a[c] ? (this.attrs[c.toLowerCase()] = a[c]) : delete this.attrs[c]
else b ? (this.attrs[a.toLowerCase()] = b) : delete this.attrs[a]
},
getIndex: function () {
for (var a, b = this.parentNode, c = 0; (a = b.children[c]); c++)
if (a === this) return c
return -1
},
getNodeById: function (a) {
var b
if (this.children && this.children.length)
for (var c, d = 0; (c = this.children[d++]); )
if ((b = g(c, a))) return b
},
getNodesByTagName: function (a) {
a = utils
.trim(a)
.replace(/[ ]{2,}/g, ' ')
.split(' ')
var b = [],
c = this
return (
utils.each(a, function (a) {
if (c.children && c.children.length)
for (var d, e = 0; (d = c.children[e++]); ) h(d, a, b)
}),
b
)
},
getStyle: function (a) {
var b = this.getAttr('style')
if (!b) return ''
var c = new RegExp('(^|;)\\s*' + a + ':([^;]+)', 'i'),
d = b.match(c)
return d && d[0] ? d[2] : ''
},
setStyle: function (a, b) {
function c(a, b) {
var c = new RegExp('(^|;)\\s*' + a + ':([^;]+;?)', 'gi')
;(d = d.replace(c, '$1')),
b && (d = a + ':' + utils.unhtml(b) + ';' + d)
}
var d = this.getAttr('style')
if ((d || (d = ''), utils.isObject(a))) for (var e in a) c(e, a[e])
else c(a, b)
this.setAttr('style', utils.trim(d))
},
traversal: function (a) {
return this.children && this.children.length && i(this, a), this
}
})
})()
var htmlparser = (UE.htmlparser = function (a, b) {
function c(a, b) {
if (m[a.tagName]) {
var c = k.createElement(m[a.tagName])
a.appendChild(c), c.appendChild(k.createText(b)), (a = c)
} else a.appendChild(k.createText(b))
}
function d(a, b, c) {
var e
if ((e = l[b])) {
for (var f, h = a; 'root' != h.type; ) {
if (
utils.isArray(e)
? utils.indexOf(e, h.tagName) != -1
: e == h.tagName
) {
;(a = h), (f = !0)
break
}
h = h.parentNode
}
f || (a = d(a, utils.isArray(e) ? e[0] : e))
}
var i = new k({
parentNode: a,
type: 'element',
tagName: b.toLowerCase(),
children: dtd.$empty[b] ? null : []
})
if (c) {
for (var m, n = {}; (m = g.exec(c)); )
n[m[1].toLowerCase()] = j[m[1].toLowerCase()]
? m[2] || m[3] || m[4]
: utils.unhtml(m[2] || m[3] || m[4])
i.attrs = n
}
return a.children.push(i), dtd.$empty[b] ? a : i
}
function e(a, b) {
a.children.push(new k({ type: 'comment', data: b, parentNode: a }))
}
var f =
/<(?:(?:\/([^>]+)>)|(?:!--([\S|\s]*?)-->)|(?:([^\s\/<>]+)\s*((?:(?:"[^"]*")|(?:'[^']*')|[^"'<>])*)\/?>))/g,
g =
/([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g,
h = {
b: 1,
code: 1,
i: 1,
u: 1,
strike: 1,
s: 1,
tt: 1,
strong: 1,
q: 1,
samp: 1,
em: 1,
span: 1,
sub: 1,
img: 1,
sup: 1,
font: 1,
big: 1,
small: 1,
iframe: 1,
a: 1,
br: 1,
pre: 1
}
;(a = a.replace(new RegExp(domUtils.fillChar, 'g'), '')),
b ||
(a = a.replace(
new RegExp(
'[\\r\\t\\n' +
(b ? '' : ' ') +
']*?(\\w+)\\s*(?:[^>]*)>[\\r\\t\\n' +
(b ? '' : ' ') +
']*',
'g'
),
function (a, c) {
return c && h[c.toLowerCase()]
? a.replace(/(^[\n\r]+)|([\n\r]+$)/g, '')
: a
.replace(new RegExp('^[\\r\\n' + (b ? '' : ' ') + ']+'), '')
.replace(new RegExp('[\\r\\n' + (b ? '' : ' ') + ']+$'), '')
}
))
for (
var i,
j = { href: 1, src: 1 },
k = UE.uNode,
l = {
td: 'tr',
tr: ['tbody', 'thead', 'tfoot'],
tbody: 'table',
th: 'tr',
thead: 'table',
tfoot: 'table',
caption: 'table',
li: ['ul', 'ol'],
dt: 'dl',
dd: 'dl',
option: 'select'
},
m = { ol: 'li', ul: 'li' },
n = 0,
o = 0,
p = new k({ type: 'root', children: [] }),
q = p;
(i = f.exec(a));
) {
n = i.index
try {
if ((n > o && c(q, a.slice(o, n)), i[3]))
dtd.$cdata[q.tagName]
? c(q, i[0])
: (q = d(q, i[3].toLowerCase(), i[4]))
else if (i[1]) {
if ('root' != q.type)
if (dtd.$cdata[q.tagName] && !dtd.$cdata[i[1]]) c(q, i[0])
else {
for (
var r = q;
'element' == q.type && q.tagName != i[1].toLowerCase();
)
if (((q = q.parentNode), 'root' == q.type))
throw ((q = r), 'break')
q = q.parentNode
}
} else i[2] && e(q, i[2])
} catch (s) {}
o = f.lastIndex
}
return o < a.length && c(q, a.slice(o)), p
}),
filterNode = (UE.filterNode = (function () {
function a(b, c) {
switch (b.type) {
case 'text':
break
case 'element':
var d
if ((d = c[b.tagName]))
if ('-' === d) b.parentNode.removeChild(b)
else if (utils.isFunction(d)) {
var e = b.parentNode,
f = b.getIndex()
if ((d(b), b.parentNode)) {
if (b.children)
for (var g, h = 0; (g = b.children[h]); )
a(g, c), g.parentNode && h++
} else
for (var g, h = f; (g = e.children[h]); )
a(g, c), g.parentNode && h++
} else {
var i = d.$
if (i && b.attrs) {
var j,
k = {}
for (var l in i) {
if (
((j = b.getAttr(l)), 'style' == l && utils.isArray(i[l]))
) {
var m = []
utils.each(i[l], function (a) {
var c
;(c = b.getStyle(a)) && m.push(a + ':' + c)
}),
(j = m.join(';'))
}
j && (k[l] = j)
}
b.attrs = k
}
if (b.children)
for (var g, h = 0; (g = b.children[h]); )
a(g, c), g.parentNode && h++
}
else if (dtd.$cdata[b.tagName]) b.parentNode.removeChild(b)
else {
var e = b.parentNode,
f = b.getIndex()
b.parentNode.removeChild(b, !0)
for (var g, h = f; (g = e.children[h]); )
a(g, c), g.parentNode && h++
}
break
case 'comment':
b.parentNode.removeChild(b)
}
}
return function (b, c) {
if (utils.isEmptyObject(c)) return b
var d
;(d = c['-']) &&
utils.each(d.split(' '), function (a) {
c[a] = '-'
})
for (var e, f = 0; (e = b.children[f]); ) a(e, c), e.parentNode && f++
return b
}
})())
UE.plugin = (function () {
var a = {}
return {
register: function (b, c, d, e) {
d && utils.isFunction(d) && ((e = d), (d = null)),
(a[b] = { optionName: d || b, execFn: c, afterDisabled: e })
},
load: function (b) {
utils.each(a, function (a) {
var c = a.execFn.call(b)
b.options[a.optionName] !== !1
? c &&
utils.each(c, function (a, c) {
switch (c.toLowerCase()) {
case 'shortcutkey':
b.addshortcutkey(a)
break
case 'bindevents':
utils.each(a, function (a, c) {
b.addListener(c, a)
})
break
case 'bindmultievents':
utils.each(utils.isArray(a) ? a : [a], function (a) {
var c = utils.trim(a.type).split(/\s+/)
utils.each(c, function (c) {
b.addListener(c, a.handler)
})
})
break
case 'commands':
utils.each(a, function (a, c) {
b.commands[c] = a
})
break
case 'outputrule':
b.addOutputRule(a)
break
case 'inputrule':
b.addInputRule(a)
break
case 'defaultoptions':
b.setOpt(a)
}
})
: a.afterDisabled && a.afterDisabled.call(b)
}),
utils.each(UE.plugins, function (a) {
a.call(b)
})
},
run: function (b, c) {
var d = a[b]
d && d.exeFn.call(c)
}
}
})()
var keymap = (UE.keymap = {
Backspace: 8,
Tab: 9,
Enter: 13,
Shift: 16,
Control: 17,
Alt: 18,
CapsLock: 20,
Esc: 27,
Spacebar: 32,
PageUp: 33,
PageDown: 34,
End: 35,
Home: 36,
Left: 37,
Up: 38,
Right: 39,
Down: 40,
Insert: 45,
Del: 46,
NumLock: 144,
Cmd: 91,
'=': 187,
'-': 189,
b: 66,
i: 73,
z: 90,
y: 89,
v: 86,
x: 88,
s: 83,
n: 78
}),
LocalStorage = (UE.LocalStorage = (function () {
function a() {
var a = document.createElement('div')
return (
(a.style.display = 'none'),
a.addBehavior
? (a.addBehavior('#default#userdata'),
{
getItem: function (b) {
var d = null
try {
document.body.appendChild(a),
a.load(c),
(d = a.getAttribute(b)),
document.body.removeChild(a)
} catch (e) {}
return d
},
setItem: function (b, d) {
document.body.appendChild(a),
a.setAttribute(b, d),
a.save(c),
document.body.removeChild(a)
},
removeItem: function (b) {
document.body.appendChild(a),
a.removeAttribute(b),
a.save(c),
document.body.removeChild(a)
}
})
: null
)
}
var b = window.localStorage || a() || null,
c = 'localStorage'
return {
saveLocalData: function (a, c) {
return !(!b || !c) && (b.setItem(a, c), !0)
},
getLocalData: function (a) {
return b ? b.getItem(a) : null
},
removeItem: function (a) {
b && b.removeItem(a)
}
}
})())
!(function () {
var a = 'ueditor_preference'
;(UE.Editor.prototype.setPreferences = function (b, c) {
var d = {}
utils.isString(b) ? (d[b] = c) : (d = b)
var e = LocalStorage.getLocalData(a)
e && (e = utils.str2json(e)) ? utils.extend(e, d) : (e = d),
e && LocalStorage.saveLocalData(a, utils.json2str(e))
}),
(UE.Editor.prototype.getPreferences = function (b) {
var c = LocalStorage.getLocalData(a)
return c && (c = utils.str2json(c)) ? (b ? c[b] : c) : null
}),
(UE.Editor.prototype.removePreferences = function (b) {
var c = LocalStorage.getLocalData(a)
c && (c = utils.str2json(c)) && ((c[b] = void 0), delete c[b]),
c && LocalStorage.saveLocalData(a, utils.json2str(c))
})
})(),
(UE.plugins.defaultfilter = function () {
var a = this
a.setOpt({ allowDivTransToP: !0, disabledTableInTable: !0 }),
a.addInputRule(function (b) {
function c(a) {
for (; a && 'element' == a.type; ) {
if ('td' == a.tagName) return !0
a = a.parentNode
}
return !1
}
var d,
e = this.options.allowDivTransToP
b.traversal(function (b) {
if ('element' == b.type) {
if (
!dtd.$cdata[b.tagName] &&
a.options.autoClearEmptyNode &&
dtd.$inline[b.tagName] &&
!dtd.$empty[b.tagName] &&
(!b.attrs || utils.isEmptyObject(b.attrs))
)
return void (b.firstChild()
? 'span' != b.tagName ||
(b.attrs && !utils.isEmptyObject(b.attrs)) ||
b.parentNode.removeChild(b, !0)
: b.parentNode.removeChild(b))
switch (b.tagName) {
case 'style':
case 'script':
b.setAttr({
cdata_tag: b.tagName,
cdata_data: b.innerHTML() || '',
_ue_custom_node_: 'true'
}),
(b.tagName = 'div'),
b.innerHTML('')
break
case 'a':
;(d = b.getAttr('href')) && b.setAttr('_href', d)
break
case 'img':
if ((d = b.getAttr('src')) && /^data:/.test(d)) {
b.parentNode.removeChild(b)
break
}
b.setAttr('_src', b.getAttr('src'))
break
case 'span':
browser.webkit &&
(d = b.getStyle('white-space')) &&
/nowrap|normal/.test(d) &&
(b.setStyle('white-space', ''),
a.options.autoClearEmptyNode &&
utils.isEmptyObject(b.attrs) &&
b.parentNode.removeChild(b, !0)),
(d = b.getAttr('id')),
d &&
/^_baidu_bookmark_/i.test(d) &&
b.parentNode.removeChild(b)
break
case 'p':
;(d = b.getAttr('align')) &&
(b.setAttr('align'), b.setStyle('text-align', d)),
utils.each(b.children, function (a) {
if ('element' == a.type && 'p' == a.tagName) {
var c = a.nextSibling()
b.parentNode.insertAfter(a, b)
for (var d = a; c; ) {
var e = c.nextSibling()
b.parentNode.insertAfter(c, d), (d = c), (c = e)
}
return !1
}
}),
b.firstChild() ||
b.innerHTML(browser.ie ? ' ' : ' ')
break
case 'div':
if (b.getAttr('cdata_tag')) break
if (
((d = b.getAttr('class')), d && /^line number\d+/.test(d))
)
break
if (!e) break
for (
var f, g = UE.uNode.createElement('p');
(f = b.firstChild());
)
'text' != f.type && UE.dom.dtd.$block[f.tagName]
? g.firstChild()
? (b.parentNode.insertBefore(g, b),
(g = UE.uNode.createElement('p')))
: b.parentNode.insertBefore(f, b)
: g.appendChild(f)
g.firstChild() && b.parentNode.insertBefore(g, b),
b.parentNode.removeChild(b)
break
case 'dl':
b.tagName = 'ul'
break
case 'dt':
case 'dd':
b.tagName = 'li'
break
case 'li':
var h = b.getAttr('class')
;(h && /list\-/.test(h)) || b.setAttr()
var i = b.getNodesByTagName('ol ul')
UE.utils.each(i, function (a) {
b.parentNode.insertAfter(a, b)
})
break
case 'td':
case 'th':
case 'caption':
;(b.children && b.children.length) ||
b.appendChild(
browser.ie11below
? UE.uNode.createText(' ')
: UE.uNode.createElement('br')
)
break
case 'table':
a.options.disabledTableInTable &&
c(b) &&
(b.parentNode.insertBefore(
UE.uNode.createText(b.innerText()),
b
),
b.parentNode.removeChild(b))
}
}
})
}),
a.addOutputRule(function (b) {
var c
b.traversal(function (b) {
if ('element' == b.type) {
if (
a.options.autoClearEmptyNode &&
dtd.$inline[b.tagName] &&
!dtd.$empty[b.tagName] &&
(!b.attrs || utils.isEmptyObject(b.attrs))
)
return void (b.firstChild()
? 'span' != b.tagName ||
(b.attrs && !utils.isEmptyObject(b.attrs)) ||
b.parentNode.removeChild(b, !0)
: b.parentNode.removeChild(b))
switch (b.tagName) {
case 'div':
;(c = b.getAttr('cdata_tag')) &&
((b.tagName = c),
b.appendChild(UE.uNode.createText(b.getAttr('cdata_data'))),
b.setAttr({
cdata_tag: '',
cdata_data: '',
_ue_custom_node_: ''
}))
break
case 'a':
;(c = b.getAttr('_href')) &&
b.setAttr({ href: utils.html(c), _href: '' })
break
case 'span':
;(c = b.getAttr('id')),
c &&
/^_baidu_bookmark_/i.test(c) &&
b.parentNode.removeChild(b)
break
case 'img':
;(c = b.getAttr('_src')) &&
b.setAttr({ src: b.getAttr('_src'), _src: '' })
}
}
})
})
}),
(UE.commands.inserthtml = {
execCommand: function (a, b, c) {
var d,
e,
f = this
if (b && f.fireEvent('beforeinserthtml', b) !== !0) {
if (
((d = f.selection.getRange()),
(e = d.document.createElement('div')),
(e.style.display = 'inline'),
!c)
) {
var g = UE.htmlparser(b)
f.options.filterRules && UE.filterNode(g, f.options.filterRules),
f.filterInputRule(g),
(b = g.toHtml())
}
if (((e.innerHTML = utils.trim(b)), !d.collapsed)) {
var h = d.startContainer
if (
(domUtils.isFillChar(h) && d.setStartBefore(h),
(h = d.endContainer),
domUtils.isFillChar(h) && d.setEndAfter(h),
d.txtToElmBoundary(),
d.endContainer &&
1 == d.endContainer.nodeType &&
((h = d.endContainer.childNodes[d.endOffset]),
h && domUtils.isBr(h) && d.setEndAfter(h)),
0 == d.startOffset &&
((h = d.startContainer),
domUtils.isBoundaryNode(h, 'firstChild') &&
((h = d.endContainer),
d.endOffset ==
(3 == h.nodeType
? h.nodeValue.length
: h.childNodes.length) &&
domUtils.isBoundaryNode(h, 'lastChild') &&
((f.body.innerHTML =
'
' + (browser.ie ? '' : ' ') + '
'),
d.setStart(f.body.firstChild, 0).collapse(!0)))),
!d.collapsed && d.deleteContents(),
1 == d.startContainer.nodeType)
) {
var i,
j = d.startContainer.childNodes[d.startOffset]
if (
j &&
domUtils.isBlockElm(j) &&
(i = j.previousSibling) &&
domUtils.isBlockElm(i)
) {
for (
d.setEnd(i, i.childNodes.length).collapse();
j.firstChild;
)
i.appendChild(j.firstChild)
domUtils.remove(j)
}
}
}
var j,
k,
i,
l,
m,
n = 0
d.inFillChar() &&
((j = d.startContainer),
domUtils.isFillChar(j)
? (d.setStartBefore(j).collapse(!0), domUtils.remove(j))
: domUtils.isFillChar(j, !0) &&
((j.nodeValue = j.nodeValue.replace(fillCharReg, '')),
d.startOffset--,
d.collapsed && d.collapse(!0)))
var o = domUtils.findParentByTagName(d.startContainer, 'li', !0)
if (o) {
for (var p, q; (j = e.firstChild); ) {
for (
;
j &&
(3 == j.nodeType ||
!domUtils.isBlockElm(j) ||
'HR' == j.tagName);
)
(p = j.nextSibling),
d.insertNode(j).collapse(),
(q = j),
(j = p)
if (j)
if (/^(ol|ul)$/i.test(j.tagName)) {
for (; j.firstChild; )
(q = j.firstChild),
domUtils.insertAfter(o, j.firstChild),
(o = o.nextSibling)
domUtils.remove(j)
} else {
var r
;(p = j.nextSibling),
(r = f.document.createElement('li')),
domUtils.insertAfter(o, r),
r.appendChild(j),
(q = j),
(j = p),
(o = r)
}
}
;(o = domUtils.findParentByTagName(d.startContainer, 'li', !0)),
domUtils.isEmptyBlock(o) && domUtils.remove(o),
q && d.setStartAfter(q).collapse(!0).select(!0)
} else {
for (; (j = e.firstChild); ) {
if (n) {
for (
var s = f.document.createElement('p');
j && (3 == j.nodeType || !dtd.$block[j.tagName]);
)
(m = j.nextSibling), s.appendChild(j), (j = m)
s.firstChild && (j = s)
}
if (
(d.insertNode(j),
(m = j.nextSibling),
!n &&
j.nodeType == domUtils.NODE_ELEMENT &&
domUtils.isBlockElm(j) &&
((k = domUtils.findParent(j, function (a) {
return domUtils.isBlockElm(a)
})),
k &&
'body' != k.tagName.toLowerCase() &&
(!dtd[k.tagName][j.nodeName] || j.parentNode !== k)))
) {
if (dtd[k.tagName][j.nodeName])
for (l = j.parentNode; l !== k; ) (i = l), (l = l.parentNode)
else i = k
domUtils.breakParent(j, i || l)
var i = j.previousSibling
domUtils.trimWhiteTextNode(i),
i.childNodes.length || domUtils.remove(i),
!browser.ie &&
(p = j.nextSibling) &&
domUtils.isBlockElm(p) &&
p.lastChild &&
!domUtils.isBr(p.lastChild) &&
p.appendChild(f.document.createElement('br')),
(n = 1)
}
var p = j.nextSibling
if (!e.firstChild && p && domUtils.isBlockElm(p)) {
d.setStart(p, 0).collapse(!0)
break
}
d.setEndAfter(j).collapse()
}
if (
((j = d.startContainer),
m && domUtils.isBr(m) && domUtils.remove(m),
domUtils.isBlockElm(j) && domUtils.isEmptyNode(j))
)
if ((m = j.nextSibling))
domUtils.remove(j),
1 == m.nodeType &&
dtd.$block[m.tagName] &&
d.setStart(m, 0).collapse(!0).shrinkBoundary()
else
try {
j.innerHTML = browser.ie ? domUtils.fillChar : ' '
} catch (t) {
d.setStartBefore(j), domUtils.remove(j)
}
try {
d.select(!0)
} catch (t) {}
}
setTimeout(function () {
;(d = f.selection.getRange()),
d.scrollToView(
f.autoHeightEnabled,
f.autoHeightEnabled ? domUtils.getXY(f.iframe).y : 0
),
f.fireEvent('afterinserthtml', b)
}, 200)
}
}
}),
(UE.plugins.autotypeset = function () {
function a(a, b) {
return a && 3 != a.nodeType
? domUtils.isBr(a)
? 1
: a && a.parentNode && l[a.tagName.toLowerCase()]
? (g && g.contains(a)) || a.getAttribute('pagebreak')
? 0
: b
? !domUtils.isEmptyBlock(a)
: domUtils.isEmptyBlock(
a,
new RegExp('[\\s' + domUtils.fillChar + ']', 'g')
)
: void 0
: 0
}
function b(a) {
a.style.cssText ||
(domUtils.removeAttributes(a, ['style']),
'span' == a.tagName.toLowerCase() &&
domUtils.hasNoAttributes(a) &&
domUtils.remove(a, !0))
}
function c(c, f) {
var h,
l = this
if (f) {
if (!i.pasteFilter) return
;(h = l.document.createElement('div')), (h.innerHTML = f.html)
} else h = l.document.body
for (
var m, n = domUtils.getElementsByTagName(h, '*'), o = 0;
(m = n[o++]);
)
if (l.fireEvent('excludeNodeinautotype', m) !== !0) {
if (
(i.clearFontSize &&
m.style.fontSize &&
(domUtils.removeStyle(m, 'font-size'), b(m)),
i.clearFontFamily &&
m.style.fontFamily &&
(domUtils.removeStyle(m, 'font-family'), b(m)),
a(m))
) {
if (i.mergeEmptyline)
for (
var p, q = m.nextSibling, r = domUtils.isBr(m);
a(q) &&
((p = q),
(q = p.nextSibling),
!r || (q && (!q || domUtils.isBr(q))));
)
domUtils.remove(p)
if (
i.removeEmptyline &&
domUtils.inDoc(m, h) &&
!k[m.parentNode.tagName.toLowerCase()]
) {
if (
domUtils.isBr(m) &&
((q = m.nextSibling), q && !domUtils.isBr(q))
)
continue
domUtils.remove(m)
continue
}
}
if (
(a(m, !0) &&
'SPAN' != m.tagName &&
(i.indent && (m.style.textIndent = i.indentValue),
i.textAlign && (m.style.textAlign = i.textAlign)),
i.removeClass && m.className && !j[m.className.toLowerCase()])
) {
if (g && g.contains(m)) continue
domUtils.removeAttributes(m, ['class'])
}
if (
i.imageBlockLine &&
'img' == m.tagName.toLowerCase() &&
!m.getAttribute('emotion')
)
if (f) {
var s = m
switch (i.imageBlockLine) {
case 'left':
case 'right':
case 'none':
for (
var p, t, q, u = s.parentNode;
dtd.$inline[u.tagName] || 'A' == u.tagName;
)
u = u.parentNode
if (
((p = u),
'P' == p.tagName &&
'center' == domUtils.getStyle(p, 'text-align') &&
!domUtils.isBody(p) &&
1 ==
domUtils.getChildCount(p, function (a) {
return (
!domUtils.isBr(a) && !domUtils.isWhitespace(a)
)
}))
)
if (
((t = p.previousSibling),
(q = p.nextSibling),
t &&
q &&
1 == t.nodeType &&
1 == q.nodeType &&
t.tagName == q.tagName &&
domUtils.isBlockElm(t))
) {
for (t.appendChild(p.firstChild); q.firstChild; )
t.appendChild(q.firstChild)
domUtils.remove(p), domUtils.remove(q)
} else domUtils.setStyle(p, 'text-align', '')
domUtils.setStyle(s, 'float', i.imageBlockLine)
break
case 'center':
if ('center' != l.queryCommandValue('imagefloat')) {
for (
u = s.parentNode,
domUtils.setStyle(s, 'float', 'none'),
p = s;
u &&
1 ==
domUtils.getChildCount(u, function (a) {
return (
!domUtils.isBr(a) && !domUtils.isWhitespace(a)
)
}) &&
(dtd.$inline[u.tagName] || 'A' == u.tagName);
)
(p = u), (u = u.parentNode)
var v = l.document.createElement('p')
domUtils.setAttributes(v, { style: 'text-align:center' }),
p.parentNode.insertBefore(v, p),
v.appendChild(p),
domUtils.setStyle(p, 'float', '')
}
}
} else {
var w = l.selection.getRange()
w.selectNode(m).select(),
l.execCommand('imagefloat', i.imageBlockLine)
}
i.removeEmptyNode &&
i.removeTagNames[m.tagName.toLowerCase()] &&
domUtils.hasNoAttributes(m) &&
domUtils.isEmptyBlock(m) &&
domUtils.remove(m)
}
if (i.tobdc) {
var x = UE.htmlparser(h.innerHTML)
x.traversal(function (a) {
'text' == a.type && (a.data = e(a.data))
}),
(h.innerHTML = x.toHtml())
}
if (i.bdc2sb) {
var x = UE.htmlparser(h.innerHTML)
x.traversal(function (a) {
'text' == a.type && (a.data = d(a.data))
}),
(h.innerHTML = x.toHtml())
}
f && (f.html = h.innerHTML)
}
function d(a) {
for (var b = '', c = 0; c < a.length; c++) {
var d = a.charCodeAt(c)
b +=
d >= 65281 && d <= 65373
? String.fromCharCode(a.charCodeAt(c) - 65248)
: 12288 == d
? String.fromCharCode(a.charCodeAt(c) - 12288 + 32)
: a.charAt(c)
}
return b
}
function e(a) {
a = utils.html(a)
for (var b = '', c = 0; c < a.length; c++)
b +=
32 == a.charCodeAt(c)
? String.fromCharCode(12288)
: a.charCodeAt(c) < 127
? String.fromCharCode(a.charCodeAt(c) + 65248)
: a.charAt(c)
return b
}
function f() {
var a = h.getPreferences('autotypeset')
utils.extend(h.options.autotypeset, a)
}
this.setOpt({
autotypeset: {
mergeEmptyline: !0,
removeClass: !0,
removeEmptyline: !1,
textAlign: 'left',
imageBlockLine: 'center',
pasteFilter: !1,
clearFontSize: !1,
clearFontFamily: !1,
removeEmptyNode: !1,
removeTagNames: utils.extend({ div: 1 }, dtd.$removeEmpty),
indent: !1,
indentValue: '2em',
bdc2sb: !1,
tobdc: !1
}
})
var g,
h = this,
i = h.options.autotypeset,
j = { selectTdClass: 1, pagebreak: 1, anchorclass: 1 },
k = { li: 1 },
l = {
div: 1,
p: 1,
blockquote: 1,
center: 1,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1,
span: 1
}
i &&
(f(),
i.pasteFilter && h.addListener('beforepaste', c),
(h.commands.autotypeset = {
execCommand: function () {
h.removeListener('beforepaste', c),
i.pasteFilter && h.addListener('beforepaste', c),
c.call(h)
}
}))
}),
UE.plugin.register('autosubmit', function () {
return {
shortcutkey: { autosubmit: 'ctrl+13' },
commands: {
autosubmit: {
execCommand: function () {
var a = this,
b = domUtils.findParentByTagName(a.iframe, 'form', !1)
if (b) {
if (a.fireEvent('beforesubmit') === !1) return
a.sync(), b.submit()
}
}
}
}
}
}),
UE.plugin.register('background', function () {
function a(a) {
var b = {},
c = a.split(';')
return (
utils.each(c, function (a) {
var c = a.indexOf(':'),
d = utils.trim(a.substr(0, c)).toLowerCase()
d && (b[d] = utils.trim(a.substr(c + 1) || ''))
}),
b
)
}
function b(a) {
if (a) {
var b = []
for (var c in a) a.hasOwnProperty(c) && b.push(c + ':' + a[c] + '; ')
utils.cssRule(
e,
b.length ? 'body{' + b.join('') + '}' : '',
d.document
)
} else utils.cssRule(e, '', d.document)
}
var c,
d = this,
e = 'editor_background',
f = new RegExp('body[\\s]*\\{(.+)\\}', 'i'),
g = d.hasContents
return (
(d.hasContents = function () {
return !!d.queryCommandValue('background') || g.apply(d, arguments)
}),
{
bindEvents: {
getAllHtml: function (a, b) {
var c = this.body,
e = domUtils.getComputedStyle(c, 'background-image'),
f = ''
f =
e.indexOf(d.options.imagePath) > 0
? e
.substring(e.indexOf(d.options.imagePath), e.length - 1)
.replace(/"|\(|\)/gi, '')
: 'none' != e
? e.replace(/url\("?|"?\)/gi, '')
: ''
var g = ' '), b.push(g)
},
aftersetcontent: function () {
0 == c && b()
}
},
inputRule: function (d) {
;(c = !1),
utils.each(d.getNodesByTagName('p'), function (d) {
var e = d.getAttr('data-background')
e && ((c = !0), b(a(e)), d.parentNode.removeChild(d))
})
},
outputRule: function (a) {
var b = this,
c = (utils.cssRule(e, b.document) || '')
.replace(/[\n\r]+/g, '')
.match(f)
c &&
a.appendChild(
UE.uNode.createElement(
'
'
)
)
},
commands: {
background: {
execCommand: function (a, c) {
b(c)
},
queryCommandValue: function () {
var b = this,
c = (utils.cssRule(e, b.document) || '')
.replace(/[\n\r]+/g, '')
.match(f)
return c ? a(c[1]) : null
},
notNeedUndo: !0
}
}
}
)
}),
(UE.commands.imagefloat = {
execCommand: function (a, b) {
var c = this,
d = c.selection.getRange()
if (!d.collapsed) {
var e = d.getClosedNode()
if (e && 'IMG' == e.tagName)
switch (b) {
case 'left':
case 'right':
case 'none':
for (
var f, g, h, i = e.parentNode;
dtd.$inline[i.tagName] || 'A' == i.tagName;
)
i = i.parentNode
if (
((f = i),
'P' == f.tagName &&
'center' == domUtils.getStyle(f, 'text-align'))
) {
if (
!domUtils.isBody(f) &&
1 ==
domUtils.getChildCount(f, function (a) {
return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
})
)
if (
((g = f.previousSibling),
(h = f.nextSibling),
g &&
h &&
1 == g.nodeType &&
1 == h.nodeType &&
g.tagName == h.tagName &&
domUtils.isBlockElm(g))
) {
for (g.appendChild(f.firstChild); h.firstChild; )
g.appendChild(h.firstChild)
domUtils.remove(f), domUtils.remove(h)
} else domUtils.setStyle(f, 'text-align', '')
d.selectNode(e).select()
}
domUtils.setStyle(e, 'float', 'none' == b ? '' : b),
'none' == b && domUtils.removeAttributes(e, 'align')
break
case 'center':
if ('center' != c.queryCommandValue('imagefloat')) {
for (
i = e.parentNode,
domUtils.setStyle(e, 'float', ''),
domUtils.removeAttributes(e, 'align'),
f = e;
i &&
1 ==
domUtils.getChildCount(i, function (a) {
return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
}) &&
(dtd.$inline[i.tagName] || 'A' == i.tagName);
)
(f = i), (i = i.parentNode)
d.setStartBefore(f).setCursor(!1),
(i = c.document.createElement('div')),
i.appendChild(f),
domUtils.setStyle(f, 'float', ''),
c.execCommand(
'insertHtml',
'
' +
i.innerHTML +
'
'
),
(f = c.document.getElementById('_img_parent_tmp')),
f.removeAttribute('id'),
(f = f.firstChild),
d.selectNode(f).select(),
(h = f.parentNode.nextSibling),
h && domUtils.isEmptyNode(h) && domUtils.remove(h)
}
}
}
},
queryCommandValue: function () {
var a,
b,
c = this.selection.getRange()
return c.collapsed
? 'none'
: ((a = c.getClosedNode()),
a && 1 == a.nodeType && 'IMG' == a.tagName
? ((b =
domUtils.getComputedStyle(a, 'float') ||
a.getAttribute('align')),
'none' == b &&
(b =
'center' ==
domUtils.getComputedStyle(a.parentNode, 'text-align')
? 'center'
: b),
{ left: 1, right: 1, center: 1 }[b] ? b : 'none')
: 'none')
},
queryCommandState: function () {
var a,
b = this.selection.getRange()
return b.collapsed
? -1
: ((a = b.getClosedNode()),
a && 1 == a.nodeType && 'IMG' == a.tagName ? 0 : -1)
}
}),
(UE.commands.insertimage = {
execCommand: function (a, b) {
function c(a) {
utils.each(
'width,height,border,hspace,vspace'.split(','),
function (b) {
a[b] && (a[b] = parseInt(a[b], 10) || 0)
}
),
utils.each('src,_src'.split(','), function (b) {
a[b] && (a[b] = utils.unhtmlForUrl(a[b]))
}),
utils.each('title,alt'.split(','), function (b) {
a[b] && (a[b] = utils.unhtml(a[b]))
})
}
if (((b = utils.isArray(b) ? b : [b]), b.length)) {
var d = this,
e = d.selection.getRange(),
f = e.getClosedNode()
if (d.fireEvent('beforeinsertimage', b) !== !0) {
if (
!f ||
!/img/i.test(f.tagName) ||
('edui-faked-video' == f.className &&
f.className.indexOf('edui-upload-video') == -1) ||
f.getAttribute('word_img')
) {
var g,
h = [],
i = ''
if (((g = b[0]), 1 == b.length))
c(g),
(i =
''),
'center' == g.floatStyle &&
(i = '
' + i + '
'),
h.push(i)
else
for (var j = 0; (g = b[j++]); )
c(g),
(i =
''),
h.push(i)
d.execCommand('insertHtml', h.join(''))
} else {
var k = b.shift(),
l = k.floatStyle
delete k.floatStyle,
domUtils.setAttributes(f, k),
d.execCommand('imagefloat', l),
b.length > 0 &&
(e.setStartAfter(f).setCursor(!1, !0),
d.execCommand('insertimage', b))
}
d.fireEvent('afterinsertimage', b)
}
}
}
}),
(UE.plugins.justify = function () {
var a = domUtils.isBlockElm,
b = { left: 1, right: 1, center: 1, justify: 1 },
c = function (b, c) {
var d = b.createBookmark(),
e = function (a) {
return 1 == a.nodeType
? 'br' != a.tagName.toLowerCase() && !domUtils.isBookmarkNode(a)
: !domUtils.isWhitespace(a)
}
b.enlarge(!0)
for (
var f,
g = b.createBookmark(),
h = domUtils.getNextDomNode(g.start, !1, e),
i = b.cloneRange();
h &&
!(domUtils.getPosition(h, g.end) & domUtils.POSITION_FOLLOWING);
)
if (3 != h.nodeType && a(h)) h = domUtils.getNextDomNode(h, !0, e)
else {
for (i.setStartBefore(h); h && h !== g.end && !a(h); )
(f = h),
(h = domUtils.getNextDomNode(h, !1, null, function (b) {
return !a(b)
}))
i.setEndAfter(f)
var j = i.getCommonAncestor()
if (!domUtils.isBody(j) && a(j))
domUtils.setStyles(
j,
utils.isString(c) ? { 'text-align': c } : c
),
(h = j)
else {
var k = b.document.createElement('p')
domUtils.setStyles(
k,
utils.isString(c) ? { 'text-align': c } : c
)
var l = i.extractContents()
k.appendChild(l), i.insertNode(k), (h = k)
}
h = domUtils.getNextDomNode(h, !1, e)
}
return b.moveToBookmark(g).moveToBookmark(d)
}
UE.commands.justify = {
execCommand: function (a, b) {
var d,
e = this.selection.getRange()
return (
e.collapsed &&
((d = this.document.createTextNode('p')), e.insertNode(d)),
c(e, b),
d && (e.setStartBefore(d).collapse(!0), domUtils.remove(d)),
e.select(),
!0
)
},
queryCommandValue: function () {
var a = this.selection.getStart(),
c = domUtils.getComputedStyle(a, 'text-align')
return b[c] ? c : 'left'
},
queryCommandState: function () {
var a = this.selection.getStart(),
b =
a && domUtils.findParentByTagName(a, ['td', 'th', 'caption'], !0)
return b ? -1 : 0
}
}
}),
(UE.plugins.font = function () {
function a(a) {
for (
var b;
(b = a.parentNode) &&
'SPAN' == b.tagName &&
1 ==
domUtils.getChildCount(b, function (a) {
return !domUtils.isBookmarkNode(a) && !domUtils.isBr(a)
});
)
(b.style.cssText += a.style.cssText), domUtils.remove(a, !0), (a = b)
}
function b(a, b, c) {
if (
g[b] &&
(a.adjustmentBoundary(),
!a.collapsed && 1 == a.startContainer.nodeType)
) {
var d = a.startContainer.childNodes[a.startOffset]
if (d && domUtils.isTagNode(d, 'span')) {
var e = a.createBookmark()
utils.each(domUtils.getElementsByTagName(d, 'span'), function (a) {
a.parentNode &&
!domUtils.isBookmarkNode(a) &&
(('backcolor' == b &&
domUtils
.getComputedStyle(a, 'background-color')
.toLowerCase() === c) ||
(domUtils.removeStyle(a, g[b]),
0 == a.style.cssText.replace(/^\s+$/, '').length &&
domUtils.remove(a, !0)))
}),
a.moveToBookmark(e)
}
}
}
function c(c, d, e) {
var f,
g = c.collapsed,
h = c.createBookmark()
if (g)
for (f = h.start.parentNode; dtd.$inline[f.tagName]; )
f = f.parentNode
else f = domUtils.getCommonAncestor(h.start, h.end)
utils.each(domUtils.getElementsByTagName(f, 'span'), function (b) {
if (b.parentNode && !domUtils.isBookmarkNode(b)) {
if (/\s*border\s*:\s*none;?\s*/i.test(b.style.cssText))
return void (/^\s*border\s*:\s*none;?\s*$/.test(b.style.cssText)
? domUtils.remove(b, !0)
: domUtils.removeStyle(b, 'border'))
if (
(/border/i.test(b.style.cssText) &&
'SPAN' == b.parentNode.tagName &&
/border/i.test(b.parentNode.style.cssText) &&
(b.style.cssText = b.style.cssText.replace(
/border[^:]*:[^;]+;?/gi,
''
)),
'fontborder' != d || 'none' != e)
)
for (
var c = b.nextSibling;
c && 1 == c.nodeType && 'SPAN' == c.tagName;
)
if (domUtils.isBookmarkNode(c) && 'fontborder' == d)
b.appendChild(c), (c = b.nextSibling)
else {
if (
(c.style.cssText == b.style.cssText &&
(domUtils.moveChild(c, b), domUtils.remove(c)),
b.nextSibling === c)
)
break
c = b.nextSibling
}
if ((a(b), browser.ie && browser.version > 8)) {
var f = domUtils.findParent(b, function (a) {
return (
'SPAN' == a.tagName &&
/background-color/.test(a.style.cssText)
)
})
f &&
!/background-color/.test(b.style.cssText) &&
(b.style.backgroundColor = f.style.backgroundColor)
}
}
}),
c.moveToBookmark(h),
b(c, d, e)
}
var d = this,
e = {
forecolor: 'color',
backcolor: 'background-color',
fontsize: 'font-size',
fontfamily: 'font-family',
underline: 'text-decoration',
strikethrough: 'text-decoration',
fontborder: 'border'
},
f = { underline: 1, strikethrough: 1, fontborder: 1 },
g = {
forecolor: 'color',
backcolor: 'background-color',
fontsize: 'font-size',
fontfamily: 'font-family'
}
d.setOpt({
fontfamily: [
{ name: 'songti', val: '宋体,SimSun' },
{ name: 'yahei', val: '微软雅黑,Microsoft YaHei' },
{ name: 'kaiti', val: '楷体,楷体_GB2312, SimKai' },
{ name: 'heiti', val: '黑体, SimHei' },
{ name: 'lishu', val: '隶书, SimLi' },
{ name: 'andaleMono', val: 'andale mono' },
{ name: 'arial', val: 'arial, helvetica,sans-serif' },
{ name: 'arialBlack', val: 'arial black,avant garde' },
{ name: 'comicSansMs', val: 'comic sans ms' },
{ name: 'impact', val: 'impact,chicago' },
{ name: 'timesNewRoman', val: 'times new roman' }
],
fontsize: [10, 11, 12, 14, 16, 18, 20, 24, 36]
}),
d.addInputRule(function (a) {
utils.each(a.getNodesByTagName('u s del font strike'), function (a) {
if ('font' == a.tagName) {
var b = []
for (var c in a.attrs)
switch (c) {
case 'size':
b.push(
'font-size:' +
({
1: '10',
2: '12',
3: '16',
4: '18',
5: '24',
6: '32',
7: '48'
}[a.attrs[c]] || a.attrs[c]) +
'px'
)
break
case 'color':
b.push('color:' + a.attrs[c])
break
case 'face':
b.push('font-family:' + a.attrs[c])
break
case 'style':
b.push(a.attrs[c])
}
a.attrs = { style: b.join(';') }
} else {
var d = 'u' == a.tagName ? 'underline' : 'line-through'
a.attrs = {
style: (a.getAttr('style') || '') + 'text-decoration:' + d + ';'
}
}
a.tagName = 'span'
})
})
for (var h in e)
!(function (a, b) {
UE.commands[a] = {
execCommand: function (d, e) {
e =
e ||
(this.queryCommandState(d)
? 'none'
: 'underline' == d
? 'underline'
: 'fontborder' == d
? '1px solid #000'
: 'line-through')
var g,
h = this,
i = this.selection.getRange()
if ('default' == e)
i.collapsed &&
((g = h.document.createTextNode('font')),
i.insertNode(g).select()),
h.execCommand('removeFormat', 'span,a', b),
g && (i.setStartBefore(g).collapse(!0), domUtils.remove(g)),
c(i, d, e),
i.select()
else if (i.collapsed) {
var j = domUtils.findParentByTagName(
i.startContainer,
'span',
!0
)
if (
((g = h.document.createTextNode('font')),
!j ||
j.children.length ||
j[browser.ie ? 'innerText' : 'textContent'].replace(
fillCharReg,
''
).length)
) {
if (
(i.insertNode(g),
i.selectNode(g).select(),
(j = i.document.createElement('span')),
f[a])
) {
if (domUtils.findParentByTagName(g, 'a', !0))
return (
i.setStartBefore(g).setCursor(), void domUtils.remove(g)
)
h.execCommand('removeFormat', 'span,a', b)
}
if (
((j.style.cssText = b + ':' + e),
g.parentNode.insertBefore(j, g),
!browser.ie || (browser.ie && 9 == browser.version))
)
for (var k = j.parentNode; !domUtils.isBlockElm(k); )
'SPAN' == k.tagName &&
(j.style.cssText =
k.style.cssText + ';' + j.style.cssText),
(k = k.parentNode)
opera
? setTimeout(function () {
i.setStart(j, 0).collapse(!0), c(i, d, e), i.select()
})
: (i.setStart(j, 0).collapse(!0), c(i, d, e), i.select())
} else
i.insertNode(g),
f[a] &&
(i.selectNode(g).select(),
h.execCommand('removeFormat', 'span,a', b, null),
(j = domUtils.findParentByTagName(g, 'span', !0)),
i.setStartBefore(g)),
j && (j.style.cssText += ';' + b + ':' + e),
i.collapse(!0).select()
domUtils.remove(g)
} else
f[a] &&
h.queryCommandValue(a) &&
h.execCommand('removeFormat', 'span,a', b),
(i = h.selection.getRange()),
i.applyInlineStyle('span', { style: b + ':' + e }),
c(i, d, e),
i.select()
return !0
},
queryCommandValue: function (a) {
var c = this.selection.getStart()
if ('underline' == a || 'strikethrough' == a) {
for (
var d, e = c;
e && !domUtils.isBlockElm(e) && !domUtils.isBody(e);
) {
if (
1 == e.nodeType &&
((d = domUtils.getComputedStyle(e, b)), 'none' != d)
)
return d
e = e.parentNode
}
return 'none'
}
if ('fontborder' == a) {
for (var f, g = c; g && dtd.$inline[g.tagName]; ) {
if (
(f = domUtils.getComputedStyle(g, 'border')) &&
/1px/.test(f) &&
/solid/.test(f)
)
return f
g = g.parentNode
}
return ''
}
if ('FontSize' == a) {
var h = domUtils.getComputedStyle(c, b),
g = /^([\d\.]+)(\w+)$/.exec(h)
return g ? Math.floor(g[1]) + g[2] : h
}
return domUtils.getComputedStyle(c, b)
},
queryCommandState: function (a) {
if (!f[a]) return 0
var b = this.queryCommandValue(a)
return 'fontborder' == a
? /1px/.test(b) && /solid/.test(b)
: 'underline' == a
? /underline/.test(b)
: /line\-through/.test(b)
}
}
})(h, e[h])
}),
(UE.plugins.link = function () {
function a(a) {
var b = a.startContainer,
c = a.endContainer
;(b = domUtils.findParentByTagName(b, 'a', !0)) && a.setStartBefore(b),
(c = domUtils.findParentByTagName(c, 'a', !0)) && a.setEndAfter(c)
}
function b(b, c, d) {
var e = b.cloneRange(),
f = d.queryCommandValue('link')
a((b = b.adjustmentBoundary()))
var g = b.startContainer
if (
(1 == g.nodeType &&
f &&
((g = g.childNodes[b.startOffset]),
g &&
1 == g.nodeType &&
'A' == g.tagName &&
/^(?:https?|ftp|file)\s*:\s*\/\//.test(
g[browser.ie ? 'innerText' : 'textContent']
) &&
(g[browser.ie ? 'innerText' : 'textContent'] = utils.html(
c.textValue || c.href
))),
(e.collapsed && !f) ||
(b.removeInlineStyle('a'), (e = b.cloneRange())),
e.collapsed)
) {
var h = b.document.createElement('a'),
i = ''
c.textValue
? ((i = utils.html(c.textValue)), delete c.textValue)
: (i = utils.html(c.href)),
domUtils.setAttributes(h, c),
(g = domUtils.findParentByTagName(e.startContainer, 'a', !0)),
g &&
domUtils.isInNodeEndBoundary(e, g) &&
b.setStartAfter(g).collapse(!0),
(h[browser.ie ? 'innerText' : 'textContent'] = i),
b.insertNode(h).selectNode(h)
} else b.applyInlineStyle('a', c)
}
;(UE.commands.unlink = {
execCommand: function () {
var b,
c = this.selection.getRange()
;(c.collapsed &&
!domUtils.findParentByTagName(c.startContainer, 'a', !0)) ||
((b = c.createBookmark()),
a(c),
c.removeInlineStyle('a').moveToBookmark(b).select())
},
queryCommandState: function () {
return !this.highlight && this.queryCommandValue('link') ? 0 : -1
}
}),
(UE.commands.link = {
execCommand: function (a, c) {
var d
c._href && (c._href = utils.unhtml(c._href, /[<">]/g)),
c.href && (c.href = utils.unhtml(c.href, /[<">]/g)),
c.textValue &&
(c.textValue = utils.unhtml(c.textValue, /[<">]/g)),
b((d = this.selection.getRange()), c, this),
d.collapse().select(!0)
},
queryCommandValue: function () {
var a,
b = this.selection.getRange()
if (!b.collapsed) {
b.shrinkBoundary()
var c =
3 != b.startContainer.nodeType &&
b.startContainer.childNodes[b.startOffset]
? b.startContainer.childNodes[b.startOffset]
: b.startContainer,
d =
3 == b.endContainer.nodeType || 0 == b.endOffset
? b.endContainer
: b.endContainer.childNodes[b.endOffset - 1],
e = b.getCommonAncestor()
if (
((a = domUtils.findParentByTagName(e, 'a', !0)),
!a && 1 == e.nodeType)
)
for (
var f, g, h, i = e.getElementsByTagName('a'), j = 0;
(h = i[j++]);
)
if (
((f = domUtils.getPosition(h, c)),
(g = domUtils.getPosition(h, d)),
(f & domUtils.POSITION_FOLLOWING ||
f & domUtils.POSITION_CONTAINS) &&
(g & domUtils.POSITION_PRECEDING ||
g & domUtils.POSITION_CONTAINS))
) {
a = h
break
}
return a
}
if (
((a = b.startContainer),
(a = 1 == a.nodeType ? a : a.parentNode),
a &&
(a = domUtils.findParentByTagName(a, 'a', !0)) &&
!domUtils.isInNodeEndBoundary(b, a))
)
return a
},
queryCommandState: function () {
var a = this.selection.getRange().getClosedNode(),
b =
a &&
('edui-faked-video' == a.className ||
a.className.indexOf('edui-upload-video') != -1)
return b ? -1 : 0
}
})
}),
(UE.plugins.insertframe = function () {
function a() {
b._iframe && delete b._iframe
}
var b = this
b.addListener('selectionchange', function () {
a()
})
}),
(UE.commands.scrawl = {
queryCommandState: function () {
return browser.ie && browser.version <= 8 ? -1 : 0
}
}),
(UE.plugins.removeformat = function () {
var a = this
a.setOpt({
removeFormatTags:
'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var',
removeFormatAttributes:
'class,style,lang,width,height,align,hspace,valign'
}),
(a.commands.removeformat = {
execCommand: function (a, b, c, d, e) {
function f(a) {
if (3 == a.nodeType || 'span' != a.tagName.toLowerCase()) return 0
if (browser.ie) {
var b = a.attributes
if (b.length) {
for (var c = 0, d = b.length; c < d; c++)
if (b[c].specified) return 0
return 1
}
}
return !a.attributes.length
}
function g(a) {
var b = a.createBookmark()
if ((a.collapsed && a.enlarge(!0), !e)) {
var d = domUtils.findParentByTagName(a.startContainer, 'a', !0)
d && a.setStartBefore(d),
(d = domUtils.findParentByTagName(a.endContainer, 'a', !0)),
d && a.setEndAfter(d)
}
for (
h = a.createBookmark(), p = h.start;
(i = p.parentNode) && !domUtils.isBlockElm(i);
)
domUtils.breakParent(p, i), domUtils.clearEmptySibling(p)
if (h.end) {
for (p = h.end; (i = p.parentNode) && !domUtils.isBlockElm(i); )
domUtils.breakParent(p, i), domUtils.clearEmptySibling(p)
for (
var g, l = domUtils.getNextDomNode(h.start, !1, m);
l && l != h.end;
)
(g = domUtils.getNextDomNode(l, !0, m)),
dtd.$empty[l.tagName.toLowerCase()] ||
domUtils.isBookmarkNode(l) ||
(j.test(l.tagName)
? c
? (domUtils.removeStyle(l, c),
f(l) &&
'text-decoration' != c &&
domUtils.remove(l, !0))
: domUtils.remove(l, !0)
: dtd.$tableContent[l.tagName] ||
dtd.$list[l.tagName] ||
(domUtils.removeAttributes(l, k),
f(l) && domUtils.remove(l, !0))),
(l = g)
}
var n = h.start.parentNode
!domUtils.isBlockElm(n) ||
dtd.$tableContent[n.tagName] ||
dtd.$list[n.tagName] ||
domUtils.removeAttributes(n, k),
(n = h.end.parentNode),
h.end &&
domUtils.isBlockElm(n) &&
!dtd.$tableContent[n.tagName] &&
!dtd.$list[n.tagName] &&
domUtils.removeAttributes(n, k),
a.moveToBookmark(h).moveToBookmark(b)
for (
var o, p = a.startContainer, q = a.collapsed;
1 == p.nodeType &&
domUtils.isEmptyNode(p) &&
dtd.$removeEmpty[p.tagName];
)
(o = p.parentNode),
a.setStartBefore(p),
a.startContainer === a.endContainer && a.endOffset--,
domUtils.remove(p),
(p = o)
if (!q)
for (
p = a.endContainer;
1 == p.nodeType &&
domUtils.isEmptyNode(p) &&
dtd.$removeEmpty[p.tagName];
)
(o = p.parentNode),
a.setEndBefore(p),
domUtils.remove(p),
(p = o)
}
var h,
i,
j = new RegExp(
'^(?:' +
(b || this.options.removeFormatTags).replace(/,/g, '|') +
')$',
'i'
),
k = c
? []
: (d || this.options.removeFormatAttributes).split(','),
l = new dom.Range(this.document),
m = function (a) {
return 1 == a.nodeType
}
;(l = this.selection.getRange()), g(l), l.select()
}
})
}),
(UE.plugins.blockquote = function () {
function a(a) {
return domUtils.filterNodeList(
a.selection.getStartElementPath(),
'blockquote'
)
}
var b = this
b.commands.blockquote = {
execCommand: function (b, c) {
var d = this.selection.getRange(),
e = a(this),
f = dtd.blockquote,
g = d.createBookmark()
if (e) {
var h = d.startContainer,
i = domUtils.isBlockElm(h)
? h
: domUtils.findParent(h, function (a) {
return domUtils.isBlockElm(a)
}),
j = d.endContainer,
k = domUtils.isBlockElm(j)
? j
: domUtils.findParent(j, function (a) {
return domUtils.isBlockElm(a)
})
;(i = domUtils.findParentByTagName(i, 'li', !0) || i),
(k = domUtils.findParentByTagName(k, 'li', !0) || k),
'LI' == i.tagName ||
'TD' == i.tagName ||
i === e ||
domUtils.isBody(i)
? domUtils.remove(e, !0)
: domUtils.breakParent(i, e),
i !== k &&
((e = domUtils.findParentByTagName(k, 'blockquote')),
e &&
('LI' == k.tagName || 'TD' == k.tagName || domUtils.isBody(k)
? e.parentNode && domUtils.remove(e, !0)
: domUtils.breakParent(k, e)))
for (
var l,
m = domUtils.getElementsByTagName(this.document, 'blockquote'),
n = 0;
(l = m[n++]);
)
l.childNodes.length
? domUtils.getPosition(l, i) & domUtils.POSITION_FOLLOWING &&
domUtils.getPosition(l, k) & domUtils.POSITION_PRECEDING &&
domUtils.remove(l, !0)
: domUtils.remove(l)
} else {
for (
var o = d.cloneRange(),
p =
1 == o.startContainer.nodeType
? o.startContainer
: o.startContainer.parentNode,
q = p,
r = 1;
;
) {
if (domUtils.isBody(p)) {
q !== p
? d.collapsed
? (o.selectNode(q), (r = 0))
: o.setStartBefore(q)
: o.setStart(p, 0)
break
}
if (!f[p.tagName]) {
d.collapsed ? o.selectNode(q) : o.setStartBefore(q)
break
}
;(q = p), (p = p.parentNode)
}
if (r)
for (
q =
p =
p =
1 == o.endContainer.nodeType
? o.endContainer
: o.endContainer.parentNode;
;
) {
if (domUtils.isBody(p)) {
q !== p ? o.setEndAfter(q) : o.setEnd(p, p.childNodes.length)
break
}
if (!f[p.tagName]) {
o.setEndAfter(q)
break
}
;(q = p), (p = p.parentNode)
}
;(p = d.document.createElement('blockquote')),
domUtils.setAttributes(p, c),
p.appendChild(o.extractContents()),
o.insertNode(p)
for (
var s, t = domUtils.getElementsByTagName(p, 'blockquote'), n = 0;
(s = t[n++]);
)
s.parentNode && domUtils.remove(s, !0)
}
d.moveToBookmark(g).select()
},
queryCommandState: function () {
return a(this) ? 1 : 0
}
}
}),
(UE.commands.touppercase = UE.commands.tolowercase =
{
execCommand: function (a) {
var b = this,
c = b.selection.getRange()
if (c.collapsed) return c
for (
var d = c.createBookmark(),
e = d.end,
f = function (a) {
return !domUtils.isBr(a) && !domUtils.isWhitespace(a)
},
g = domUtils.getNextDomNode(d.start, !1, f);
g &&
domUtils.getPosition(g, e) & domUtils.POSITION_PRECEDING &&
(3 == g.nodeType &&
(g.nodeValue =
g.nodeValue[
'touppercase' == a ? 'toUpperCase' : 'toLowerCase'
]()),
(g = domUtils.getNextDomNode(g, !0, f)),
g !== e);
);
c.moveToBookmark(d).select()
}
}),
(UE.commands.indent = {
execCommand: function () {
var a = this,
b = a.queryCommandState('indent')
? '0em'
: a.options.indentValue || '2em'
a.execCommand('Paragraph', 'p', { style: 'text-indent:' + b })
},
queryCommandState: function () {
var a = domUtils.filterNodeList(
this.selection.getStartElementPath(),
'p h1 h2 h3 h4 h5 h6'
)
return a && a.style.textIndent && parseInt(a.style.textIndent) ? 1 : 0
}
}),
(UE.commands.print = {
execCommand: function () {
this.window.print()
},
notNeedUndo: 1
}),
(UE.commands.preview = {
execCommand: function () {
var a = window.open('', '_blank', ''),
b = a.document
b.open(),
b.write(
'
" +
this.getContent(null, null, !0) +
'
'
),
b.close()
},
notNeedUndo: 1
}),
(UE.plugins.selectall = function () {
var a = this
;(a.commands.selectall = {
execCommand: function () {
var a = this,
b = a.body,
c = a.selection.getRange()
c.selectNodeContents(b),
domUtils.isEmptyBlock(b) &&
(browser.opera &&
b.firstChild &&
1 == b.firstChild.nodeType &&
c.setStartAtFirst(b.firstChild),
c.collapse(!0)),
c.select(!0)
},
notNeedUndo: 1
}),
a.addshortcutkey({ selectAll: 'ctrl+65' })
}),
(UE.plugins.paragraph = function () {
var a = this,
b = domUtils.isBlockElm,
c = ['TD', 'LI', 'PRE'],
d = function (a, d, e, f) {
var g,
h = a.createBookmark(),
i = function (a) {
return 1 == a.nodeType
? 'br' != a.tagName.toLowerCase() && !domUtils.isBookmarkNode(a)
: !domUtils.isWhitespace(a)
}
a.enlarge(!0)
for (
var j,
k = a.createBookmark(),
l = domUtils.getNextDomNode(k.start, !1, i),
m = a.cloneRange();
l &&
!(domUtils.getPosition(l, k.end) & domUtils.POSITION_FOLLOWING);
)
if (3 != l.nodeType && b(l)) l = domUtils.getNextDomNode(l, !0, i)
else {
for (m.setStartBefore(l); l && l !== k.end && !b(l); )
(j = l),
(l = domUtils.getNextDomNode(l, !1, null, function (a) {
return !b(a)
}))
m.setEndAfter(j),
(g = a.document.createElement(d)),
e &&
(domUtils.setAttributes(g, e),
f &&
'customstyle' == f &&
e.style &&
(g.style.cssText = e.style)),
g.appendChild(m.extractContents()),
domUtils.isEmptyNode(g) && domUtils.fillChar(a.document, g),
m.insertNode(g)
var n = g.parentNode
b(n) &&
!domUtils.isBody(g.parentNode) &&
utils.indexOf(c, n.tagName) == -1 &&
((f && 'customstyle' == f) ||
(n.getAttribute('dir') &&
g.setAttribute('dir', n.getAttribute('dir')),
n.style.cssText &&
(g.style.cssText = n.style.cssText + ';' + g.style.cssText),
n.style.textAlign &&
!g.style.textAlign &&
(g.style.textAlign = n.style.textAlign),
n.style.textIndent &&
!g.style.textIndent &&
(g.style.textIndent = n.style.textIndent),
n.style.padding &&
!g.style.padding &&
(g.style.padding = n.style.padding)),
e && /h\d/i.test(n.tagName) && !/h\d/i.test(g.tagName)
? (domUtils.setAttributes(n, e),
f &&
'customstyle' == f &&
e.style &&
(n.style.cssText = e.style),
domUtils.remove(g, !0),
(g = n))
: domUtils.remove(g.parentNode, !0)),
(l = utils.indexOf(c, n.tagName) != -1 ? n : g),
(l = domUtils.getNextDomNode(l, !1, i))
}
return a.moveToBookmark(k).moveToBookmark(h)
}
a.setOpt('paragraph', {
p: '',
h1: '',
h2: '',
h3: '',
h4: '',
h5: '',
h6: ''
}),
(a.commands.paragraph = {
execCommand: function (a, b, c, e) {
var f = this.selection.getRange()
if (f.collapsed) {
var g = this.document.createTextNode('p')
if ((f.insertNode(g), browser.ie)) {
var h = g.previousSibling
h && domUtils.isWhitespace(h) && domUtils.remove(h),
(h = g.nextSibling),
h && domUtils.isWhitespace(h) && domUtils.remove(h)
}
}
if (
((f = d(f, b, c, e)),
g &&
(f.setStartBefore(g).collapse(!0),
(pN = g.parentNode),
domUtils.remove(g),
domUtils.isBlockElm(pN) &&
domUtils.isEmptyNode(pN) &&
domUtils.fillNode(this.document, pN)),
browser.gecko && f.collapsed && 1 == f.startContainer.nodeType)
) {
var i = f.startContainer.childNodes[f.startOffset]
i &&
1 == i.nodeType &&
i.tagName.toLowerCase() == b &&
f.setStart(i, 0).collapse(!0)
}
return f.select(), !0
},
queryCommandValue: function () {
var a = domUtils.filterNodeList(
this.selection.getStartElementPath(),
'p h1 h2 h3 h4 h5 h6'
)
return a ? a.tagName.toLowerCase() : ''
}
})
}),
(function () {
var a = domUtils.isBlockElm,
b = function (a) {
return domUtils.filterNodeList(
a.selection.getStartElementPath(),
function (a) {
return a && 1 == a.nodeType && a.getAttribute('dir')
}
)
},
c = function (c, d, e) {
var f,
g = function (a) {
return 1 == a.nodeType
? !domUtils.isBookmarkNode(a)
: !domUtils.isWhitespace(a)
},
h = b(d)
if (h && c.collapsed) return h.setAttribute('dir', e), c
;(f = c.createBookmark()), c.enlarge(!0)
for (
var i,
j = c.createBookmark(),
k = domUtils.getNextDomNode(j.start, !1, g),
l = c.cloneRange();
k &&
!(domUtils.getPosition(k, j.end) & domUtils.POSITION_FOLLOWING);
)
if (3 != k.nodeType && a(k)) k = domUtils.getNextDomNode(k, !0, g)
else {
for (l.setStartBefore(k); k && k !== j.end && !a(k); )
(i = k),
(k = domUtils.getNextDomNode(k, !1, null, function (b) {
return !a(b)
}))
l.setEndAfter(i)
var m = l.getCommonAncestor()
if (!domUtils.isBody(m) && a(m)) m.setAttribute('dir', e), (k = m)
else {
var n = c.document.createElement('p')
n.setAttribute('dir', e)
var o = l.extractContents()
n.appendChild(o), l.insertNode(n), (k = n)
}
k = domUtils.getNextDomNode(k, !1, g)
}
return c.moveToBookmark(j).moveToBookmark(f)
}
UE.commands.directionality = {
execCommand: function (a, b) {
var d = this.selection.getRange()
if (d.collapsed) {
var e = this.document.createTextNode('d')
d.insertNode(e)
}
return (
c(d, this, b),
e && (d.setStartBefore(e).collapse(!0), domUtils.remove(e)),
d.select(),
!0
)
},
queryCommandValue: function () {
var a = b(this)
return a ? a.getAttribute('dir') : 'ltr'
}
}
})(),
(UE.plugins.horizontal = function () {
var a = this
;(a.commands.horizontal = {
execCommand: function (a) {
var b = this
if (b.queryCommandState(a) !== -1) {
b.execCommand('insertHtml', '')
var c = b.selection.getRange(),
d = c.startContainer
if (1 == d.nodeType && !d.childNodes[c.startOffset]) {
var e
;(e = d.childNodes[c.startOffset - 1]) &&
1 == e.nodeType &&
'HR' == e.tagName &&
('p' == b.options.enterTag
? ((e = b.document.createElement('p')),
c.insertNode(e),
c.setStart(e, 0).setCursor())
: ((e = b.document.createElement('br')),
c.insertNode(e),
c.setStartBefore(e).setCursor()))
}
return !0
}
},
queryCommandState: function () {
return domUtils.filterNodeList(
this.selection.getStartElementPath(),
'table'
)
? -1
: 0
}
}),
a.addListener('delkeydown', function (a, b) {
var c = this.selection.getRange()
if ((c.txtToElmBoundary(!0), domUtils.isStartInblock(c))) {
var d = c.startContainer,
e = d.previousSibling
if (e && domUtils.isTagNode(e, 'hr'))
return (
domUtils.remove(e), c.select(), domUtils.preventDefault(b), !0
)
}
})
}),
(UE.commands.time = UE.commands.date =
{
execCommand: function (a, b) {
function c(a, b) {
var c = ('0' + a.getHours()).slice(-2),
d = ('0' + a.getMinutes()).slice(-2),
e = ('0' + a.getSeconds()).slice(-2)
return (
(b = b || 'hh:ii:ss'),
b.replace(/hh/gi, c).replace(/ii/gi, d).replace(/ss/gi, e)
)
}
function d(a, b) {
var c = ('000' + a.getFullYear()).slice(-4),
d = c.slice(-2),
e = ('0' + (a.getMonth() + 1)).slice(-2),
f = ('0' + a.getDate()).slice(-2)
return (
(b = b || 'yyyy-mm-dd'),
b
.replace(/yyyy/gi, c)
.replace(/yy/gi, d)
.replace(/mm/gi, e)
.replace(/dd/gi, f)
)
}
var e = new Date()
this.execCommand('insertHtml', 'time' == a ? c(e, b) : d(e, b))
}
}),
(UE.plugins.rowspacing = function () {
var a = this
a.setOpt({
rowspacingtop: ['5', '10', '15', '20', '25'],
rowspacingbottom: ['5', '10', '15', '20', '25']
}),
(a.commands.rowspacing = {
execCommand: function (a, b, c) {
return (
this.execCommand('paragraph', 'p', {
style: 'margin-' + c + ':' + b + 'px'
}),
!0
)
},
queryCommandValue: function (a, b) {
var c,
d = domUtils.filterNodeList(
this.selection.getStartElementPath(),
function (a) {
return domUtils.isBlockElm(a)
}
)
return d
? ((c = domUtils
.getComputedStyle(d, 'margin-' + b)
.replace(/[^\d]/g, '')),
c ? c : 0)
: 0
}
})
}),
(UE.plugins.lineheight = function () {
var a = this
a.setOpt({ lineheight: ['1', '1.5', '1.75', '2', '3', '4', '5'] }),
(a.commands.lineheight = {
execCommand: function (a, b) {
return (
this.execCommand('paragraph', 'p', {
style: 'line-height:' + ('1' == b ? 'normal' : b + 'em')
}),
!0
)
},
queryCommandValue: function () {
var a = domUtils.filterNodeList(
this.selection.getStartElementPath(),
function (a) {
return domUtils.isBlockElm(a)
}
)
if (a) {
var b = domUtils.getComputedStyle(a, 'line-height')
return 'normal' == b ? 1 : b.replace(/[^\d.]*/gi, '')
}
}
})
}),
(UE.plugins.insertcode = function () {
var a = this
a.ready(function () {
utils.cssRule(
'pre',
'pre{margin:.5em 0;padding:.4em .6em;border-radius:8px;background:#f8f8f8;}',
a.document
)
}),
a.setOpt('insertcode', {
as3: 'ActionScript3',
bash: 'Bash/Shell',
cpp: 'C/C++',
css: 'Css',
cf: 'CodeFunction',
'c#': 'C#',
delphi: 'Delphi',
diff: 'Diff',
erlang: 'Erlang',
groovy: 'Groovy',
html: 'Html',
java: 'Java',
jfx: 'JavaFx',
js: 'Javascript',
pl: 'Perl',
php: 'Php',
plain: 'Plain Text',
ps: 'PowerShell',
python: 'Python',
ruby: 'Ruby',
scala: 'Scala',
sql: 'Sql',
vb: 'Vb',
xml: 'Xml'
}),
(a.commands.insertcode = {
execCommand: function (a, b) {
var c = this,
d = c.selection.getRange(),
e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
if (e) e.className = 'brush:' + b + ';toolbar:false;'
else {
var f = ''
if (d.collapsed)
f =
browser.ie && browser.ie11below
? browser.version <= 8
? ' '
: ''
: ' '
else {
var g = d.extractContents(),
h = c.document.createElement('div')
h.appendChild(g),
utils.each(
UE.filterNode(
UE.htmlparser(h.innerHTML.replace(/[\r\t]/g, '')),
c.options.filterTxtRules
).children,
function (a) {
if (
browser.ie &&
browser.ie11below &&
browser.version > 8
)
'element' == a.type
? 'br' == a.tagName
? (f += '\n')
: dtd.$empty[a.tagName] ||
(utils.each(a.children, function (b) {
'element' == b.type
? 'br' == b.tagName
? (f += '\n')
: dtd.$empty[a.tagName] ||
(f += b.innerText())
: (f += b.data)
}),
/\n$/.test(f) || (f += '\n'))
: (f += a.data + '\n'),
!a.nextSibling() &&
/\n$/.test(f) &&
(f = f.replace(/\n$/, ''))
else if (browser.ie && browser.ie11below)
'element' == a.type
? 'br' == a.tagName
? (f += ' ')
: dtd.$empty[a.tagName] ||
(utils.each(a.children, function (b) {
'element' == b.type
? 'br' == b.tagName
? (f += ' ')
: dtd.$empty[a.tagName] ||
(f += b.innerText())
: (f += b.data)
}),
/br>$/.test(f) || (f += ' '))
: (f += a.data + ' '),
!a.nextSibling() &&
/ $/.test(f) &&
(f = f.replace(/ $/, ''))
else if (
((f +=
'element' == a.type
? dtd.$empty[a.tagName]
? ''
: a.innerText()
: a.data),
!/br\/?\s*>$/.test(f))
) {
if (!a.nextSibling()) return
f += ' '
}
}
)
}
c.execCommand(
'inserthtml',
'
' +
f +
'
',
!0
),
(e = c.document.getElementById('coder')),
domUtils.removeAttributes(e, 'id')
var i = e.previousSibling
i &&
((3 == i.nodeType &&
1 == i.nodeValue.length &&
browser.ie &&
6 == browser.version) ||
domUtils.isEmptyBlock(i)) &&
domUtils.remove(i)
var d = c.selection.getRange()
domUtils.isEmptyBlock(e)
? d.setStart(e, 0).setCursor(!1, !0)
: d.selectNodeContents(e).select()
}
},
queryCommandValue: function () {
var a = this.selection.getStartElementPath(),
b = ''
return (
utils.each(a, function (a) {
if ('PRE' == a.nodeName) {
var c = a.className.match(/brush:([^;]+)/)
return (b = c && c[1] ? c[1] : ''), !1
}
}),
b
)
}
}),
a.addInputRule(function (a) {
utils.each(a.getNodesByTagName('pre'), function (a) {
var b = a.getNodesByTagName('br')
if (b.length)
return void (
browser.ie &&
browser.ie11below &&
browser.version > 8 &&
utils.each(b, function (a) {
var b = UE.uNode.createText('\n')
a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
})
)
if (!(browser.ie && browser.ie11below && browser.version > 8)) {
var c = a.innerText().split(/\n/)
a.innerHTML(''),
utils.each(c, function (b) {
b.length && a.appendChild(UE.uNode.createText(b)),
a.appendChild(UE.uNode.createElement('br'))
})
}
})
}),
a.addOutputRule(function (a) {
utils.each(a.getNodesByTagName('pre'), function (a) {
var b = ''
utils.each(a.children, function (a) {
b +=
'text' == a.type
? a.data.replace(/[ ]/g, ' ').replace(/\n$/, '')
: 'br' == a.tagName
? '\n'
: dtd.$empty[a.tagName]
? a.innerText()
: ''
}),
a.innerText(b.replace(/( |\n)+$/, ''))
})
}),
(a.notNeedCodeQuery = {
help: 1,
undo: 1,
redo: 1,
source: 1,
print: 1,
searchreplace: 1,
fullscreen: 1,
preview: 1,
insertparagraph: 1,
elementpath: 1,
insertcode: 1,
inserthtml: 1,
selectall: 1
})
a.queryCommandState
;(a.queryCommandState = function (a) {
var b = this
return !b.notNeedCodeQuery[a.toLowerCase()] &&
b.selection &&
b.queryCommandValue('insertcode')
? -1
: UE.Editor.prototype.queryCommandState.apply(this, arguments)
}),
a.addListener('beforeenterkeydown', function () {
var b = a.selection.getRange(),
c = domUtils.findParentByTagName(b.startContainer, 'pre', !0)
if (c) {
if (
(a.fireEvent('saveScene'),
b.collapsed || b.deleteContents(),
!browser.ie || browser.ie9above)
) {
var c,
d = a.document.createElement('br')
b.insertNode(d).setStartAfter(d).collapse(!0)
var e = d.nextSibling
e || (browser.ie && !(browser.version > 10))
? b.setStartAfter(d)
: b.insertNode(d.cloneNode(!1)),
(c = d.previousSibling)
for (var f; c; )
if (
((f = c), (c = c.previousSibling), !c || 'BR' == c.nodeName)
) {
c = f
break
}
if (c) {
for (
var g = '';
c &&
'BR' != c.nodeName &&
new RegExp('^[\\s' + domUtils.fillChar + ']*$').test(
c.nodeValue
);
)
(g += c.nodeValue), (c = c.nextSibling)
if ('BR' != c.nodeName) {
var h = c.nodeValue.match(
new RegExp('^([\\s' + domUtils.fillChar + ']+)')
)
h && h[1] && (g += h[1])
}
g &&
((g = a.document.createTextNode(g)),
b.insertNode(g).setStartAfter(g))
}
b.collapse(!0).select(!0)
} else if (browser.version > 8) {
var i = a.document.createTextNode('\n'),
j = b.startContainer
if (0 == b.startOffset) {
var k = j.previousSibling
if (k) {
b.insertNode(i)
var l = a.document.createTextNode(' ')
b.setStartAfter(i)
.insertNode(l)
.setStart(l, 0)
.collapse(!0)
.select(!0)
}
} else {
b.insertNode(i).setStartAfter(i)
var l = a.document.createTextNode(' ')
;(j = b.startContainer.childNodes[b.startOffset]),
j && !/^\n/.test(j.nodeValue) && b.setStartBefore(i),
b.insertNode(l).setStart(l, 0).collapse(!0).select(!0)
}
} else {
var d = a.document.createElement('br')
b.insertNode(d),
b.insertNode(a.document.createTextNode(domUtils.fillChar)),
b.setStartAfter(d),
(c = d.previousSibling)
for (var f; c; )
if (
((f = c), (c = c.previousSibling), !c || 'BR' == c.nodeName)
) {
c = f
break
}
if (c) {
for (
var g = '';
c &&
'BR' != c.nodeName &&
new RegExp('^[ ' + domUtils.fillChar + ']*$').test(
c.nodeValue
);
)
(g += c.nodeValue), (c = c.nextSibling)
if ('BR' != c.nodeName) {
var h = c.nodeValue.match(
new RegExp('^([ ' + domUtils.fillChar + ']+)')
)
h && h[1] && (g += h[1])
}
;(g = a.document.createTextNode(g)),
b.insertNode(g).setStartAfter(g)
}
b.collapse(!0).select()
}
return a.fireEvent('saveScene'), !0
}
}),
a.addListener('tabkeydown', function (b, c) {
var d = a.selection.getRange(),
e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
if (e) {
if ((a.fireEvent('saveScene'), c.shiftKey));
else if (d.collapsed) {
var f = a.document.createTextNode(' ')
d.insertNode(f).setStartAfter(f).collapse(!0).select(!0)
} else {
for (
var g = d.createBookmark(), h = g.start.previousSibling;
h;
) {
if (e.firstChild === h && !domUtils.isBr(h)) {
e.insertBefore(a.document.createTextNode(' '), h)
break
}
if (domUtils.isBr(h)) {
e.insertBefore(
a.document.createTextNode(' '),
h.nextSibling
)
break
}
h = h.previousSibling
}
var i = g.end
for (
h = g.start.nextSibling,
e.firstChild === g.start &&
e.insertBefore(
a.document.createTextNode(' '),
h.nextSibling
);
h && h !== i;
) {
if (domUtils.isBr(h) && h.nextSibling) {
if (h.nextSibling === i) break
e.insertBefore(
a.document.createTextNode(' '),
h.nextSibling
)
}
h = h.nextSibling
}
d.moveToBookmark(g).select()
}
return a.fireEvent('saveScene'), !0
}
}),
a.addListener('beforeinserthtml', function (a, b) {
var c = this,
d = c.selection.getRange(),
e = domUtils.findParentByTagName(d.startContainer, 'pre', !0)
if (e) {
d.collapsed || d.deleteContents()
var f = ''
if (browser.ie && browser.version > 8) {
utils.each(
UE.filterNode(UE.htmlparser(b), c.options.filterTxtRules)
.children,
function (a) {
'element' == a.type
? 'br' == a.tagName
? (f += '\n')
: dtd.$empty[a.tagName] ||
(utils.each(a.children, function (b) {
'element' == b.type
? 'br' == b.tagName
? (f += '\n')
: dtd.$empty[a.tagName] || (f += b.innerText())
: (f += b.data)
}),
/\n$/.test(f) || (f += '\n'))
: (f += a.data + '\n'),
!a.nextSibling() &&
/\n$/.test(f) &&
(f = f.replace(/\n$/, ''))
}
)
var g = c.document.createTextNode(
utils.html(f.replace(/ /g, ' '))
)
d.insertNode(g).selectNode(g).select()
} else {
var h = c.document.createDocumentFragment()
utils.each(
UE.filterNode(UE.htmlparser(b), c.options.filterTxtRules)
.children,
function (a) {
'element' == a.type
? 'br' == a.tagName
? h.appendChild(c.document.createElement('br'))
: dtd.$empty[a.tagName] ||
(utils.each(a.children, function (b) {
'element' == b.type
? 'br' == b.tagName
? h.appendChild(c.document.createElement('br'))
: dtd.$empty[a.tagName] ||
h.appendChild(
c.document.createTextNode(
utils.html(
b.innerText().replace(/ /g, ' ')
)
)
)
: h.appendChild(
c.document.createTextNode(
utils.html(b.data.replace(/ /g, ' '))
)
)
}),
'BR' != h.lastChild.nodeName &&
h.appendChild(c.document.createElement('br')))
: h.appendChild(
c.document.createTextNode(
utils.html(a.data.replace(/ /g, ' '))
)
),
a.nextSibling() ||
'BR' != h.lastChild.nodeName ||
h.removeChild(h.lastChild)
}
),
d.insertNode(h).select()
}
return !0
}
}),
a.addListener('keydown', function (a, b) {
var c = this,
d = b.keyCode || b.which
if (40 == d) {
var e,
f = c.selection.getRange(),
g = f.startContainer
if (
f.collapsed &&
(e = domUtils.findParentByTagName(f.startContainer, 'pre', !0)) &&
!e.nextSibling
) {
for (var h = e.lastChild; h && 'BR' == h.nodeName; )
h = h.previousSibling
;(h === g ||
(f.startContainer === e &&
f.startOffset == e.childNodes.length)) &&
(c.execCommand('insertparagraph'), domUtils.preventDefault(b))
}
}
}),
a.addListener('delkeydown', function (b, c) {
var d = this.selection.getRange()
d.txtToElmBoundary(!0)
var e = d.startContainer
if (
domUtils.isTagNode(e, 'pre') &&
d.collapsed &&
domUtils.isStartInblock(d)
) {
var f = a.document.createElement('p')
return (
domUtils.fillNode(a.document, f),
e.parentNode.insertBefore(f, e),
domUtils.remove(e),
d.setStart(f, 0).setCursor(!1, !0),
domUtils.preventDefault(c),
!0
)
}
})
}),
(UE.commands.cleardoc = {
execCommand: function (a) {
var b = this,
c = b.options.enterTag,
d = b.selection.getRange()
'br' == c
? ((b.body.innerHTML = ' '), d.setStart(b.body, 0).setCursor())
: ((b.body.innerHTML = '
' + (ie ? '' : ' ') + '
'),
d.setStart(b.body.firstChild, 0).setCursor(!1, !0)),
setTimeout(function () {
b.fireEvent('clearDoc')
}, 0)
}
}),
UE.plugin.register('anchor', function () {
return {
bindEvents: {
ready: function () {
utils.cssRule(
'anchor',
".anchorclass{background: url('" +
this.options.themePath +
this.options.theme +
"/images/anchor.gif') no-repeat scroll left center transparent;cursor: auto;display: inline-block;height: 16px;width: 15px;}",
this.document
)
}
},
outputRule: function (a) {
utils.each(a.getNodesByTagName('img'), function (a) {
var b
;(b = a.getAttr('anchorname')) &&
((a.tagName = 'a'),
a.setAttr({ anchorname: '', name: b, class: '' }))
})
},
inputRule: function (a) {
utils.each(a.getNodesByTagName('a'), function (a) {
var b
;(b = a.getAttr('name')) &&
!a.getAttr('href') &&
((a.tagName = 'img'),
a.setAttr({
anchorname: a.getAttr('name'),
class: 'anchorclass'
}),
a.setAttr('name'))
})
},
commands: {
anchor: {
execCommand: function (a, b) {
var c = this.selection.getRange(),
d = c.getClosedNode()
if (d && d.getAttribute('anchorname'))
b
? d.setAttribute('anchorname', b)
: (c.setStartBefore(d).setCursor(), domUtils.remove(d))
else if (b) {
var e = this.document.createElement('img')
c.collapse(!0),
domUtils.setAttributes(e, {
anchorname: b,
class: 'anchorclass'
}),
c.insertNode(e).setStartAfter(e).setCursor(!1, !0)
}
}
}
}
}
}),
(UE.plugins.wordcount = function () {
var a = this
a.setOpt('wordCount', !0),
a.addListener('contentchange', function () {
a.fireEvent('wordcount')
})
var b
a.addListener('ready', function () {
var a = this
domUtils.on(a.body, 'keyup', function (c) {
var d = c.keyCode || c.which,
e = { 16: 1, 18: 1, 20: 1, 37: 1, 38: 1, 39: 1, 40: 1 }
d in e ||
(clearTimeout(b),
(b = setTimeout(function () {
a.fireEvent('wordcount')
}, 200)))
})
})
}),
(UE.plugins.pagebreak = function () {
function a(a) {
if (domUtils.isEmptyBlock(a)) {
for (
var b, d = a.firstChild;
d && 1 == d.nodeType && domUtils.isEmptyBlock(d);
)
(b = d), (d = d.firstChild)
!b && (b = a), domUtils.fillNode(c.document, b)
}
}
function b(a) {
return (
a &&
1 == a.nodeType &&
'HR' == a.tagName &&
'pagebreak' == a.className
)
}
var c = this,
d = ['td']
c.setOpt('pageBreakTag', '_ueditor_page_break_tag_'),
c.ready(function () {
utils.cssRule(
'pagebreak',
'.pagebreak{display:block;clear:both !important;cursor:default !important;width: 100% !important;margin:0;}',
c.document
)
}),
c.addInputRule(function (a) {
a.traversal(function (a) {
if ('text' == a.type && a.data == c.options.pageBreakTag) {
var b = UE.uNode.createElement(
''
)
a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
}
})
}),
c.addOutputRule(function (a) {
utils.each(a.getNodesByTagName('hr'), function (a) {
if ('pagebreak' == a.getAttr('class')) {
var b = UE.uNode.createText(c.options.pageBreakTag)
a.parentNode.insertBefore(b, a), a.parentNode.removeChild(a)
}
})
}),
(c.commands.pagebreak = {
execCommand: function () {
var e = c.selection.getRange(),
f = c.document.createElement('hr')
domUtils.setAttributes(f, {
class: 'pagebreak',
noshade: 'noshade',
size: '5'
}),
domUtils.unSelectable(f)
var g,
h = domUtils.findParentByTagName(e.startContainer, d, !0),
i = []
if (h)
switch (h.tagName) {
case 'TD':
if (((g = h.parentNode), g.previousSibling))
g.parentNode.insertBefore(f, g),
(i = domUtils.findParents(f))
else {
var j = domUtils.findParentByTagName(g, 'table')
j.parentNode.insertBefore(f, j),
(i = domUtils.findParents(f, !0))
}
;(g = i[1]),
f !== g && domUtils.breakParent(f, g),
c.fireEvent('afteradjusttable', c.document)
}
else {
if (!e.collapsed) {
e.deleteContents()
for (
var k = e.startContainer;
!domUtils.isBody(k) &&
domUtils.isBlockElm(k) &&
domUtils.isEmptyNode(k);
)
e.setStartBefore(k).collapse(!0),
domUtils.remove(k),
(k = e.startContainer)
}
e.insertNode(f)
for (var l, g = f.parentNode; !domUtils.isBody(g); )
domUtils.breakParent(f, g),
(l = f.nextSibling),
l && domUtils.isEmptyBlock(l) && domUtils.remove(l),
(g = f.parentNode)
l = f.nextSibling
var m = f.previousSibling
if ((b(m) ? domUtils.remove(m) : m && a(m), l))
b(l) ? domUtils.remove(l) : a(l), e.setEndAfter(f).collapse(!1)
else {
var n = c.document.createElement('p')
f.parentNode.appendChild(n),
domUtils.fillNode(c.document, n),
e.setStart(n, 0).collapse(!0)
}
e.select(!0)
}
}
})
}),
UE.plugin.register('wordimage', function () {
var a = this,
b = []
return {
commands: {
wordimage: {
execCommand: function () {
for (
var b,
c = domUtils.getElementsByTagName(a.body, 'img'),
d = [],
e = 0;
(b = c[e++]);
) {
var f = b.getAttribute('word_img')
f && d.push(f)
}
return d
},
queryCommandState: function () {
b = domUtils.getElementsByTagName(a.body, 'img')
for (var c, d = 0; (c = b[d++]); )
if (c.getAttribute('word_img')) return 1
return -1
},
notNeedUndo: !0
}
},
inputRule: function (b) {
utils.each(b.getNodesByTagName('img'), function (b) {
var c = b.attrs,
d = parseInt(c.width) < 128 || parseInt(c.height) < 43,
e = a.options,
f = e.UEDITOR_HOME_URL + 'themes/default/images/spacer.gif'
c.src &&
/^(?:(file:\/+))/.test(c.src) &&
b.setAttr({
width: c.width,
height: c.height,
alt: c.alt,
word_img: c.src,
src: f,
style:
'background:url(' +
(d
? e.themePath + e.theme + '/images/word.gif'
: e.langPath + e.lang + '/images/localimage.png') +
') no-repeat center center;border:1px solid #ddd'
})
})
}
}
}),
(UE.plugins.dragdrop = function () {
var a = this
a.ready(function () {
domUtils.on(this.body, 'dragend', function () {
var b = a.selection.getRange(),
c = b.getClosedNode() || a.selection.getStart()
if (c && 'IMG' == c.tagName) {
for (
var d, e = c.previousSibling;
(d = c.nextSibling) &&
1 == d.nodeType &&
'SPAN' == d.tagName &&
!d.firstChild;
)
domUtils.remove(d)
;((!e || 1 != e.nodeType || domUtils.isEmptyBlock(e)) && e) ||
(d && (!d || domUtils.isEmptyBlock(d))) ||
(e && 'P' == e.tagName && !domUtils.isEmptyBlock(e)
? (e.appendChild(c),
domUtils.moveChild(d, e),
domUtils.remove(d))
: d &&
'P' == d.tagName &&
!domUtils.isEmptyBlock(d) &&
d.insertBefore(c, d.firstChild),
e &&
'P' == e.tagName &&
domUtils.isEmptyBlock(e) &&
domUtils.remove(e),
d &&
'P' == d.tagName &&
domUtils.isEmptyBlock(d) &&
domUtils.remove(d),
b.selectNode(c).select(),
a.fireEvent('saveScene'))
}
})
}),
a.addListener('keyup', function (b, c) {
var d = c.keyCode || c.which
if (13 == d) {
var e,
f = a.selection.getRange()
;(e = domUtils.findParentByTagName(f.startContainer, 'p', !0)) &&
'center' == domUtils.getComputedStyle(e, 'text-align') &&
domUtils.removeStyle(e, 'text-align')
}
})
}),
(UE.plugins.undo = function () {
function a(a, b) {
if (a.length != b.length) return 0
for (var c = 0, d = a.length; c < d; c++) if (a[c] != b[c]) return 0
return 1
}
function b(b, c) {
return b.collapsed != c.collapsed
? 0
: a(b.startAddress, c.startAddress) && a(b.endAddress, c.endAddress)
? 1
: 0
}
function c() {
;(this.list = []),
(this.index = 0),
(this.hasUndo = !1),
(this.hasRedo = !1),
(this.undo = function () {
if (this.hasUndo) {
if (!this.list[this.index - 1] && 1 == this.list.length)
return void this.reset()
for (
;
this.list[this.index].content ==
this.list[this.index - 1].content;
)
if ((this.index--, 0 == this.index)) return this.restore(0)
this.restore(--this.index)
}
}),
(this.redo = function () {
if (this.hasRedo) {
for (
;
this.list[this.index].content ==
this.list[this.index + 1].content;
)
if ((this.index++, this.index == this.list.length - 1))
return this.restore(this.index)
this.restore(++this.index)
}
}),
(this.restore = function () {
var a = this.editor,
b = this.list[this.index],
c = UE.htmlparser(b.content.replace(h, ''))
;(a.options.autoClearEmptyNode = !1),
a.filterInputRule(c),
(a.options.autoClearEmptyNode = j),
(a.document.body.innerHTML = c.toHtml()),
a.fireEvent('afterscencerestore'),
browser.ie &&
utils.each(
domUtils.getElementsByTagName(a.document, 'td th caption p'),
function (b) {
domUtils.isEmptyNode(b) && domUtils.fillNode(a.document, b)
}
)
try {
var d = new dom.Range(a.document).moveToAddress(b.address)
d.select(i[d.startContainer.nodeName.toLowerCase()])
} catch (e) {}
this.update(), this.clearKey(), a.fireEvent('reset', !0)
}),
(this.getScene = function () {
var a = this.editor,
b = a.selection.getRange(),
c = b.createAddress(!1, !0)
a.fireEvent('beforegetscene')
var d = UE.htmlparser(a.body.innerHTML)
;(a.options.autoClearEmptyNode = !1),
a.filterOutputRule(d),
(a.options.autoClearEmptyNode = j)
var e = d.toHtml()
return a.fireEvent('aftergetscene'), { address: c, content: e }
}),
(this.save = function (a, c) {
clearTimeout(d)
var g = this.getScene(c),
h = this.list[this.index]
h && h.content != g.content && e.trigger('contentchange'),
(h &&
h.content == g.content &&
(a ? 1 : b(h.address, g.address))) ||
((this.list = this.list.slice(0, this.index + 1)),
this.list.push(g),
this.list.length > f && this.list.shift(),
(this.index = this.list.length - 1),
this.clearKey(),
this.update())
}),
(this.update = function () {
;(this.hasRedo = !!this.list[this.index + 1]),
(this.hasUndo = !!this.list[this.index - 1])
}),
(this.reset = function () {
;(this.list = []),
(this.index = 0),
(this.hasUndo = !1),
(this.hasRedo = !1),
this.clearKey()
}),
(this.clearKey = function () {
;(m = 0), (k = null)
})
}
var d,
e = this,
f = e.options.maxUndoCount || 20,
g = e.options.maxInputCount || 20,
h = new RegExp(domUtils.fillChar + '|', 'gi'),
i = { ol: 1, ul: 1, table: 1, tbody: 1, tr: 1, body: 1 },
j = e.options.autoClearEmptyNode
;(e.undoManger = new c()),
(e.undoManger.editor = e),
e.addListener('saveScene', function () {
var a = Array.prototype.splice.call(arguments, 1)
this.undoManger.save.apply(this.undoManger, a)
}),
e.addListener('reset', function (a, b) {
b || this.undoManger.reset()
}),
(e.commands.redo = e.commands.undo =
{
execCommand: function (a) {
this.undoManger[a]()
},
queryCommandState: function (a) {
return this.undoManger[
'has' + ('undo' == a.toLowerCase() ? 'Undo' : 'Redo')
]
? 0
: -1
},
notNeedUndo: 1
})
var k,
l = { 16: 1, 17: 1, 18: 1, 37: 1, 38: 1, 39: 1, 40: 1 },
m = 0,
n = !1
e.addListener('ready', function () {
domUtils.on(this.body, 'compositionstart', function () {
n = !0
}),
domUtils.on(this.body, 'compositionend', function () {
n = !1
})
}),
e.addshortcutkey({ Undo: 'ctrl+90', Redo: 'ctrl+89' })
var o = !0
e.addListener('keydown', function (a, b) {
function c(a) {
a.undoManger.save(!1, !0), a.fireEvent('selectionchange')
}
var e = this,
f = b.keyCode || b.which
if (!(l[f] || b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) {
if (n) return
if (!e.selection.getRange().collapsed)
return e.undoManger.save(!1, !0), void (o = !1)
0 == e.undoManger.list.length && e.undoManger.save(!0),
clearTimeout(d),
(d = setTimeout(function () {
if (n)
var a = setInterval(function () {
n || (c(e), clearInterval(a))
}, 300)
else c(e)
}, 200)),
(k = f),
m++,
m >= g && c(e)
}
}),
e.addListener('keyup', function (a, b) {
var c = b.keyCode || b.which
if (!(l[c] || b.ctrlKey || b.metaKey || b.shiftKey || b.altKey)) {
if (n) return
o || (this.undoManger.save(!1, !0), (o = !0))
}
}),
(e.stopCmdUndo = function () {
e.__hasEnterExecCommand = !0
}),
(e.startCmdUndo = function () {
e.__hasEnterExecCommand = !1
})
}),
UE.plugin.register('copy', function () {
function a() {
ZeroClipboard.config({
debug: !1,
swfPath:
b.options.UEDITOR_HOME_URL +
'third-party/zeroclipboard/ZeroClipboard.swf'
})
var a = (b.zeroclipboard = new ZeroClipboard())
a.on('copy', function (a) {
var c = a.client,
d = b.selection.getRange(),
e = document.createElement('div')
e.appendChild(d.cloneContents()),
c.setText(e.innerText || e.textContent),
c.setHtml(e.innerHTML),
d.select()
}),
a.on('mouseover mouseout', function (a) {
var b = a.target
'mouseover' == a.type
? domUtils.addClass(b, 'edui-state-hover')
: 'mouseout' == a.type &&
domUtils.removeClasses(b, 'edui-state-hover')
}),
a.on('wrongflash noflash', function () {
ZeroClipboard.destroy()
})
}
var b = this
return {
bindEvents: {
ready: function () {
browser.ie ||
(window.ZeroClipboard
? a()
: utils.loadFile(
document,
{
src:
b.options.UEDITOR_HOME_URL +
'third-party/zeroclipboard/ZeroClipboard.js',
tag: 'script',
type: 'text/javascript',
defer: 'defer'
},
function () {
a()
}
))
}
},
commands: {
copy: {
execCommand: function (a) {
b.document.execCommand('copy') || alert(b.getLang('copymsg'))
}
}
}
}
}),
(UE.plugins.paste = function () {
function a(a) {
var b = this.document
if (!b.getElementById('baidu_pastebin')) {
var c = this.selection.getRange(),
d = c.createBookmark(),
e = b.createElement('div')
;(e.id = 'baidu_pastebin'),
browser.webkit &&
e.appendChild(
b.createTextNode(domUtils.fillChar + domUtils.fillChar)
),
b.body.appendChild(e),
(d.start.style.display = ''),
(e.style.cssText =
'position:absolute;width:1px;height:1px;overflow:hidden;left:-1000px;white-space:nowrap;top:' +
domUtils.getXY(d.start).y +
'px'),
c.selectNodeContents(e).select(!0),
setTimeout(function () {
if (browser.webkit)
for (
var f, g = 0, h = b.querySelectorAll('#baidu_pastebin');
(f = h[g++]);
) {
if (!domUtils.isEmptyNode(f)) {
e = f
break
}
domUtils.remove(f)
}
try {
e.parentNode.removeChild(e)
} catch (i) {}
c.moveToBookmark(d).select(!0), a(e)
}, 0)
}
}
function b(a) {
return a.replace(/<(\/?)([\w\-]+)([^>]*)>/gi, function (a, b, c, d) {
return (
(c = c.toLowerCase()),
{ img: 1 }[c]
? a
: ((d = d.replace(
/([\w\-]*?)\s*=\s*(("([^"]*)")|('([^']*)')|([^\s>]+))/gi,
function (a, b, c) {
return { src: 1, href: 1, name: 1 }[b.toLowerCase()]
? b + '=' + c + ' '
: ''
}
)),
{ span: 1, div: 1 }[c]
? ''
: '<' + b + c + ' ' + utils.trim(d) + '>')
)
})
}
function c(a) {
var c
if (a.firstChild) {
for (
var h, i = domUtils.getElementsByTagName(a, 'span'), j = 0;
(h = i[j++]);
)
('_baidu_cut_start' != h.id && '_baidu_cut_end' != h.id) ||
domUtils.remove(h)
if (browser.webkit) {
for (
var k, l = a.querySelectorAll('div br'), j = 0;
(k = l[j++]);
) {
var m = k.parentNode
'DIV' == m.tagName &&
1 == m.childNodes.length &&
((m.innerHTML = '
'), domUtils.remove(m))
}
for (
var n, o = a.querySelectorAll('#baidu_pastebin'), j = 0;
(n = o[j++]);
) {
var p = d.document.createElement('p')
for (n.parentNode.insertBefore(p, n); n.firstChild; )
p.appendChild(n.firstChild)
domUtils.remove(n)
}
for (var q, r = a.querySelectorAll('meta'), j = 0; (q = r[j++]); )
domUtils.remove(q)
var l = a.querySelectorAll('br')
for (j = 0; (q = l[j++]); )
/^apple-/i.test(q.className) && domUtils.remove(q)
}
if (browser.gecko) {
var s = a.querySelectorAll('[_moz_dirty]')
for (j = 0; (q = s[j++]); ) q.removeAttribute('_moz_dirty')
}
if (!browser.ie)
for (
var q, t = a.querySelectorAll('span.Apple-style-span'), j = 0;
(q = t[j++]);
)
domUtils.remove(q, !0)
;(c = a.innerHTML), (c = UE.filterWord(c))
var u = UE.htmlparser(c)
if (
(d.options.filterRules && UE.filterNode(u, d.options.filterRules),
d.filterInputRule(u),
browser.webkit)
) {
var v = u.lastChild()
v && 'element' == v.type && 'br' == v.tagName && u.removeChild(v),
utils.each(d.body.querySelectorAll('div'), function (a) {
domUtils.isEmptyBlock(a) && domUtils.remove(a, !0)
})
}
if (
((c = { html: u.toHtml() }),
d.fireEvent('beforepaste', c, u),
!c.html)
)
return
;(u = UE.htmlparser(c.html, !0)),
1 === d.queryCommandState('pasteplain')
? d.execCommand(
'insertHtml',
UE.filterNode(u, d.options.filterTxtRules).toHtml(),
!0
)
: (UE.filterNode(u, d.options.filterTxtRules),
(e = u.toHtml()),
(f = c.html),
(g = d.selection.getRange().createAddress(!0)),
d.execCommand(
'insertHtml',
d.getOpt('retainOnlyLabelPasted') === !0 ? b(f) : f,
!0
)),
d.fireEvent('afterpaste', c)
}
}
var d = this
d.setOpt({ retainOnlyLabelPasted: !1 })
var e, f, g
d.addListener('pasteTransfer', function (a, c) {
if (g && e && f && e != f) {
var h = d.selection.getRange()
if ((h.moveToAddress(g, !0), !h.collapsed)) {
for (; !domUtils.isBody(h.startContainer); ) {
var i = h.startContainer
if (1 == i.nodeType) {
if (((i = i.childNodes[h.startOffset]), !i)) {
h.setStartBefore(h.startContainer)
continue
}
var j = i.previousSibling
j &&
3 == j.nodeType &&
new RegExp('^[\n\r\t ' + domUtils.fillChar + ']*$').test(
j.nodeValue
) &&
h.setStartBefore(j)
}
if (0 != h.startOffset) break
h.setStartBefore(h.startContainer)
}
for (; !domUtils.isBody(h.endContainer); ) {
var k = h.endContainer
if (1 == k.nodeType) {
if (((k = k.childNodes[h.endOffset]), !k)) {
h.setEndAfter(h.endContainer)
continue
}
var l = k.nextSibling
l &&
3 == l.nodeType &&
new RegExp('^[\n\r\t' + domUtils.fillChar + ']*$').test(
l.nodeValue
) &&
h.setEndAfter(l)
}
if (
h.endOffset !=
h.endContainer[
3 == h.endContainer.nodeType ? 'nodeValue' : 'childNodes'
].length
)
break
h.setEndAfter(h.endContainer)
}
}
h.deleteContents(), h.select(!0), (d.__hasEnterExecCommand = !0)
var m = f
2 === c ? (m = b(m)) : c && (m = e),
d.execCommand('inserthtml', m, !0),
(d.__hasEnterExecCommand = !1)
for (
var n = d.selection.getRange();
!domUtils.isBody(n.startContainer) &&
!n.startOffset &&
n.startContainer[
3 == n.startContainer.nodeType ? 'nodeValue' : 'childNodes'
].length;
)
n.setStartBefore(n.startContainer)
var o = n.createAddress(!0)
g.endAddress = o.startAddress
}
}),
d.addListener('ready', function () {
domUtils.on(d.body, 'cut', function () {
var a = d.selection.getRange()
!a.collapsed && d.undoManger && d.undoManger.save()
}),
domUtils.on(
d.body,
browser.ie || browser.opera ? 'keydown' : 'paste',
function (b) {
;((!browser.ie && !browser.opera) ||
((b.ctrlKey || b.metaKey) && '86' == b.keyCode)) &&
a.call(d, function (a) {
c(a)
})
}
)
}),
(d.commands.paste = {
execCommand: function (b) {
browser.ie
? (a.call(d, function (a) {
c(a)
}),
d.document.execCommand('paste'))
: alert(d.getLang('pastemsg'))
}
})
}),
(UE.plugins.pasteplain = function () {
var a = this
a.setOpt({
pasteplain: !1,
filterTxtRules: (function () {
function a(a) {
;(a.tagName = 'p'), a.setStyle()
}
function b(a) {
a.parentNode.removeChild(a, !0)
}
return {
'-': 'script style object iframe embed input select',
p: { $: {} },
br: { $: {} },
div: function (a) {
for (
var b, c = UE.uNode.createElement('p');
(b = a.firstChild());
)
'text' != b.type && UE.dom.dtd.$block[b.tagName]
? c.firstChild()
? (a.parentNode.insertBefore(c, a),
(c = UE.uNode.createElement('p')))
: a.parentNode.insertBefore(b, a)
: c.appendChild(b)
c.firstChild() && a.parentNode.insertBefore(c, a),
a.parentNode.removeChild(a)
},
ol: b,
ul: b,
dl: b,
dt: b,
dd: b,
li: b,
caption: a,
th: a,
tr: a,
h1: a,
h2: a,
h3: a,
h4: a,
h5: a,
h6: a,
td: function (a) {
var b = !!a.innerText()
b &&
a.parentNode.insertAfter(
UE.uNode.createText(' '),
a
),
a.parentNode.removeChild(a, a.innerText())
}
}
})()
})
var b = a.options.pasteplain
a.commands.pasteplain = {
queryCommandState: function () {
return b ? 1 : 0
},
execCommand: function () {
b = 0 | !b
},
notNeedUndo: 1
}
}),
(UE.plugins.list = function () {
function a(a) {
var b = []
for (var c in a) b.push(c)
return b
}
function b(a) {
var b = a.className
return domUtils.hasClass(a, /custom_/)
? b.match(/custom_(\w+)/)[1]
: domUtils.getStyle(a, 'list-style-type')
}
function c(a, c) {
utils.each(domUtils.getElementsByTagName(a, 'ol ul'), function (f) {
if (domUtils.inDoc(f, a)) {
var g = f.parentNode
if (g.tagName == f.tagName) {
var h = b(f) || ('OL' == f.tagName ? 'decimal' : 'disc'),
i = b(g) || ('OL' == g.tagName ? 'decimal' : 'disc')
if (h == i) {
var l = utils.indexOf(k[f.tagName], h)
;(l = l + 1 == k[f.tagName].length ? 0 : l + 1),
e(f, k[f.tagName][l])
}
}
var m = 0,
n = 2
domUtils.hasClass(f, /custom_/)
? (/[ou]l/i.test(g.tagName) && domUtils.hasClass(g, /custom_/)) ||
(n = 1)
: /[ou]l/i.test(g.tagName) &&
domUtils.hasClass(g, /custom_/) &&
(n = 3)
var o = domUtils.getStyle(f, 'list-style-type')
o && (f.style.cssText = 'list-style-type:' + o),
(f.className =
utils.trim(f.className.replace(/list-paddingleft-\w+/, '')) +
' list-paddingleft-' +
n),
utils.each(domUtils.getElementsByTagName(f, 'li'), function (a) {
if ((a.style.cssText && (a.style.cssText = ''), !a.firstChild))
return void domUtils.remove(a)
if (a.parentNode === f) {
if ((m++, domUtils.hasClass(f, /custom_/))) {
var c = 1,
d = b(f)
if ('OL' == f.tagName) {
if (d)
switch (d) {
case 'cn':
case 'cn1':
case 'cn2':
m > 10 && (m % 10 == 0 || (m > 10 && m < 20))
? (c = 2)
: m > 20 && (c = 3)
break
case 'num2':
m > 9 && (c = 2)
}
a.className =
'list-' + j[d] + m + ' list-' + d + '-paddingleft-' + c
} else
a.className =
'list-' + j[d] + ' list-' + d + '-paddingleft'
} else a.className = a.className.replace(/list-[\w\-]+/gi, '')
var e = a.getAttribute('class')
null === e ||
e.replace(/\s/g, '') ||
domUtils.removeAttributes(a, 'class')
}
}),
!c &&
d(
f,
f.tagName.toLowerCase(),
b(f) || domUtils.getStyle(f, 'list-style-type'),
!0
)
}
})
}
function d(a, d, e, f) {
var g = a.nextSibling
g &&
1 == g.nodeType &&
g.tagName.toLowerCase() == d &&
(b(g) ||
domUtils.getStyle(g, 'list-style-type') ||
('ol' == d ? 'decimal' : 'disc')) == e &&
(domUtils.moveChild(g, a),
0 == g.childNodes.length && domUtils.remove(g)),
g && domUtils.isFillChar(g) && domUtils.remove(g)
var h = a.previousSibling
h &&
1 == h.nodeType &&
h.tagName.toLowerCase() == d &&
(b(h) ||
domUtils.getStyle(h, 'list-style-type') ||
('ol' == d ? 'decimal' : 'disc')) == e &&
domUtils.moveChild(a, h),
h && domUtils.isFillChar(h) && domUtils.remove(h),
!f && domUtils.isEmptyBlock(a) && domUtils.remove(a),
b(a) && c(a.ownerDocument, !0)
}
function e(a, b) {
j[b] && (a.className = 'custom_' + b)
try {
domUtils.setStyle(a, 'list-style-type', b)
} catch (c) {}
}
function f(a) {
var b = a.previousSibling
b && domUtils.isEmptyBlock(b) && domUtils.remove(b),
(b = a.nextSibling),
b && domUtils.isEmptyBlock(b) && domUtils.remove(b)
}
function g(a) {
for (; a && !domUtils.isBody(a); ) {
if ('TABLE' == a.nodeName) return null
if ('LI' == a.nodeName) return a
a = a.parentNode
}
}
var h = this,
i = { TD: 1, PRE: 1, BLOCKQUOTE: 1 },
j = {
cn: 'cn-1-',
cn1: 'cn-2-',
cn2: 'cn-3-',
num: 'num-1-',
num1: 'num-2-',
num2: 'num-3-',
dash: 'dash',
dot: 'dot'
}
h.setOpt({
autoTransWordToList: !1,
insertorderedlist: {
num: '',
num1: '',
num2: '',
cn: '',
cn1: '',
cn2: '',
decimal: '',
'lower-alpha': '',
'lower-roman': '',
'upper-alpha': '',
'upper-roman': ''
},
insertunorderedlist: {
circle: '',
disc: '',
square: '',
dash: '',
dot: ''
},
listDefaultPaddingLeft: '30',
listiconpath: 'http://bs.baidu.com/listicon/',
maxListLevel: -1,
disablePInList: !1
})
var k = {
OL: a(h.options.insertorderedlist),
UL: a(h.options.insertunorderedlist)
},
l = h.options.listiconpath
for (var m in j)
h.options.insertorderedlist.hasOwnProperty(m) ||
h.options.insertunorderedlist.hasOwnProperty(m) ||
delete j[m]
h.ready(function () {
var a = []
for (var b in j) {
if ('dash' == b || 'dot' == b)
a.push(
'li.list-' + j[b] + '{background-image:url(' + l + j[b] + '.gif)}'
),
a.push(
'ul.custom_' +
b +
'{list-style:none;}ul.custom_' +
b +
' li{background-position:0 3px;background-repeat:no-repeat}'
)
else {
for (var c = 0; c < 99; c++)
a.push(
'li.list-' +
j[b] +
c +
'{background-image:url(' +
l +
'list-' +
j[b] +
c +
'.gif)}'
)
a.push(
'ol.custom_' +
b +
'{list-style:none;}ol.custom_' +
b +
' li{background-position:0 3px;background-repeat:no-repeat}'
)
}
switch (b) {
case 'cn':
a.push('li.list-' + b + '-paddingleft-1{padding-left:25px}'),
a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}'),
a.push('li.list-' + b + '-paddingleft-3{padding-left:55px}')
break
case 'cn1':
a.push('li.list-' + b + '-paddingleft-1{padding-left:30px}'),
a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}'),
a.push('li.list-' + b + '-paddingleft-3{padding-left:55px}')
break
case 'cn2':
a.push('li.list-' + b + '-paddingleft-1{padding-left:40px}'),
a.push('li.list-' + b + '-paddingleft-2{padding-left:55px}'),
a.push('li.list-' + b + '-paddingleft-3{padding-left:68px}')
break
case 'num':
case 'num1':
a.push('li.list-' + b + '-paddingleft-1{padding-left:25px}')
break
case 'num2':
a.push('li.list-' + b + '-paddingleft-1{padding-left:35px}'),
a.push('li.list-' + b + '-paddingleft-2{padding-left:40px}')
break
case 'dash':
a.push('li.list-' + b + '-paddingleft{padding-left:35px}')
break
case 'dot':
a.push('li.list-' + b + '-paddingleft{padding-left:20px}')
}
}
a.push('.list-paddingleft-1{padding-left:0}'),
a.push(
'.list-paddingleft-2{padding-left:' +
h.options.listDefaultPaddingLeft +
'px}'
),
a.push(
'.list-paddingleft-3{padding-left:' +
2 * h.options.listDefaultPaddingLeft +
'px}'
),
utils.cssRule(
'list',
'ol,ul{margin:0;pading:0;' +
(browser.ie ? '' : 'width:95%') +
'}li{clear:both;}' +
a.join('\n'),
h.document
)
}),
h.ready(function () {
domUtils.on(h.body, 'cut', function () {
setTimeout(function () {
var a,
b = h.selection.getRange()
if (
!b.collapsed &&
(a = domUtils.findParentByTagName(
b.startContainer,
'li',
!0
)) &&
!a.nextSibling &&
domUtils.isEmptyBlock(a)
) {
var c,
d = a.parentNode
if ((c = d.previousSibling))
domUtils.remove(d),
b.setStartAtLast(c).collapse(!0),
b.select(!0)
else if ((c = d.nextSibling))
domUtils.remove(d),
b.setStartAtFirst(c).collapse(!0),
b.select(!0)
else {
var e = h.document.createElement('p')
domUtils.fillNode(h.document, e),
d.parentNode.insertBefore(e, d),
domUtils.remove(d),
b.setStart(e, 0).collapse(!0),
b.select(!0)
}
}
})
})
}),
h.addListener('beforepaste', function (a, c) {
var d,
e = this,
f = e.selection.getRange(),
g = UE.htmlparser(c.html, !0)
if ((d = domUtils.findParentByTagName(f.startContainer, 'li', !0))) {
var h = d.parentNode,
i = 'OL' == h.tagName ? 'ul' : 'ol'
utils.each(g.getNodesByTagName(i), function (c) {
if (((c.tagName = h.tagName), c.setAttr(), c.parentNode === g))
a = b(h) || ('OL' == h.tagName ? 'decimal' : 'disc')
else {
var d = c.parentNode.getAttr('class')
;(a =
d && /custom_/.test(d)
? d.match(/custom_(\w+)/)[1]
: c.parentNode.getStyle('list-style-type')),
a || (a = 'OL' == h.tagName ? 'decimal' : 'disc')
}
var e = utils.indexOf(k[h.tagName], a)
c.parentNode !== g &&
(e = e + 1 == k[h.tagName].length ? 0 : e + 1)
var f = k[h.tagName][e]
j[f]
? c.setAttr('class', 'custom_' + f)
: c.setStyle('list-style-type', f)
})
}
c.html = g.toHtml()
}),
h.getOpt('disablePInList') === !0 &&
h.addOutputRule(function (a) {
utils.each(a.getNodesByTagName('li'), function (a) {
var b = [],
c = 0
utils.each(a.children, function (d) {
if ('p' == d.tagName) {
for (var e; (e = d.children.pop()); )
b.splice(c, 0, e), (e.parentNode = a), (lastNode = e)
if (
((e = b[b.length - 1]),
!e || 'element' != e.type || 'br' != e.tagName)
) {
var f = UE.uNode.createElement('br')
;(f.parentNode = a), b.push(f)
}
c = b.length
}
}),
b.length && (a.children = b)
})
}),
h.addInputRule(function (a) {
function b(a, b) {
var e = b.firstChild()
if (
e &&
'element' == e.type &&
'span' == e.tagName &&
/Wingdings|Symbol/.test(e.getStyle('font-family'))
) {
for (var f in d) if (d[f] == e.data) return f
return 'disc'
}
for (var f in c) if (c[f].test(a)) return f
}
if (
(utils.each(a.getNodesByTagName('li'), function (a) {
for (
var b, c = UE.uNode.createElement('p'), d = 0;
(b = a.children[d]);
)
'text' == b.type || dtd.p[b.tagName]
? c.appendChild(b)
: c.firstChild()
? (a.insertBefore(c, b),
(c = UE.uNode.createElement('p')),
(d += 2))
: d++
;((c.firstChild() && !c.parentNode) || !a.firstChild()) &&
a.appendChild(c),
c.firstChild() || c.innerHTML(browser.ie ? ' ' : ' ')
var e = a.firstChild(),
f = e.lastChild()
f && 'text' == f.type && /^\s*$/.test(f.data) && e.removeChild(f)
}),
h.options.autoTransWordToList)
) {
var c = {
num1: /^\d+\)/,
decimal: /^\d+\./,
'lower-alpha': /^[a-z]+\)/,
'upper-alpha': /^[A-Z]+\./,
cn: /^[\u4E00\u4E8C\u4E09\u56DB\u516d\u4e94\u4e03\u516b\u4e5d]+[\u3001]/,
cn2: /^\([\u4E00\u4E8C\u4E09\u56DB\u516d\u4e94\u4e03\u516b\u4e5d]+\)/
},
d = { square: 'n' }
utils.each(a.getNodesByTagName('p'), function (a) {
function d(a, b, d) {
if ('ol' == a.tagName)
if (browser.ie) {
var e = b.firstChild()
'element' == e.type &&
'span' == e.tagName &&
c[d].test(e.innerText()) &&
b.removeChild(e)
} else b.innerHTML(b.innerHTML().replace(c[d], ''))
else b.removeChild(b.firstChild())
var f = UE.uNode.createElement('li')
f.appendChild(b), a.appendChild(f)
}
if ('MsoListParagraph' == a.getAttr('class')) {
a.setStyle('margin', ''),
a.setStyle('margin-left', ''),
a.setAttr('class', '')
var e,
f = a,
g = a
if ('li' != a.parentNode.tagName && (e = b(a.innerText(), a))) {
var i = UE.uNode.createElement(
h.options.insertorderedlist.hasOwnProperty(e) ? 'ol' : 'ul'
)
for (
j[e]
? i.setAttr('class', 'custom_' + e)
: i.setStyle('list-style-type', e);
a && 'li' != a.parentNode.tagName && b(a.innerText(), a);
)
(f = a.nextSibling()),
f || a.parentNode.insertBefore(i, a),
d(i, a, e),
(a = f)
!i.parentNode &&
a &&
a.parentNode &&
a.parentNode.insertBefore(i, a)
}
var k = g.firstChild()
k &&
'element' == k.type &&
'span' == k.tagName &&
/^\s*( )+\s*$/.test(k.innerText()) &&
k.parentNode.removeChild(k)
}
})
}
}),
h.addListener('contentchange', function () {
c(h.document)
}),
h.addListener('keydown', function (a, b) {
function c() {
b.preventDefault ? b.preventDefault() : (b.returnValue = !1),
h.fireEvent('contentchange'),
h.undoManger && h.undoManger.save()
}
function d(a, b) {
for (; a && !domUtils.isBody(a); ) {
if (b(a)) return null
if (1 == a.nodeType && /[ou]l/i.test(a.tagName)) return a
a = a.parentNode
}
return null
}
var e = b.keyCode || b.which
if (13 == e && !b.shiftKey) {
var g = h.selection.getRange(),
i = domUtils.findParent(
g.startContainer,
function (a) {
return domUtils.isBlockElm(a)
},
!0
),
j = domUtils.findParentByTagName(g.startContainer, 'li', !0)
if (i && 'PRE' != i.tagName && !j) {
var k = i.innerHTML.replace(
new RegExp(domUtils.fillChar, 'g'),
''
)
;/^\s*1\s*\.[^\d]/.test(k) &&
((i.innerHTML = k.replace(/^\s*1\s*\./, '')),
g.setStartAtLast(i).collapse(!0).select(),
(h.__hasEnterExecCommand = !0),
h.execCommand('insertorderedlist'),
(h.__hasEnterExecCommand = !1))
}
var l = h.selection.getRange(),
m = d(l.startContainer, function (a) {
return 'TABLE' == a.tagName
}),
n = l.collapsed
? m
: d(l.endContainer, function (a) {
return 'TABLE' == a.tagName
})
if (m && n && m === n) {
if (!l.collapsed) {
if (
((m = domUtils.findParentByTagName(
l.startContainer,
'li',
!0
)),
(n = domUtils.findParentByTagName(l.endContainer, 'li', !0)),
!m || !n || m !== n)
) {
var o = l.cloneRange(),
p = o.collapse(!1).createBookmark()
l.deleteContents(), o.moveToBookmark(p)
var j = domUtils.findParentByTagName(
o.startContainer,
'li',
!0
)
return f(j), o.select(), void c()
}
if (
(l.deleteContents(),
(j = domUtils.findParentByTagName(
l.startContainer,
'li',
!0
)),
j && domUtils.isEmptyBlock(j))
)
return (
(v = j.previousSibling),
(next = j.nextSibling),
(s = h.document.createElement('p')),
domUtils.fillNode(h.document, s),
(q = j.parentNode),
v && next
? (l.setStart(next, 0).collapse(!0).select(!0),
domUtils.remove(j))
: ((v || next) && v
? j.parentNode.parentNode.insertBefore(
s,
q.nextSibling
)
: q.parentNode.insertBefore(s, q),
domUtils.remove(j),
q.firstChild || domUtils.remove(q),
l.setStart(s, 0).setCursor()),
void c()
)
}
if (
(j = domUtils.findParentByTagName(l.startContainer, 'li', !0))
) {
if (domUtils.isEmptyBlock(j)) {
p = l.createBookmark()
var q = j.parentNode
if (
(j !== q.lastChild
? (domUtils.breakParent(j, q), f(j))
: (q.parentNode.insertBefore(j, q.nextSibling),
domUtils.isEmptyNode(q) && domUtils.remove(q)),
!dtd.$list[j.parentNode.tagName])
)
if (domUtils.isBlockElm(j.firstChild))
domUtils.remove(j, !0)
else {
for (
s = h.document.createElement('p'),
j.parentNode.insertBefore(s, j);
j.firstChild;
)
s.appendChild(j.firstChild)
domUtils.remove(j)
}
l.moveToBookmark(p).select()
} else {
var r = j.firstChild
if (!r || !domUtils.isBlockElm(r)) {
var s = h.document.createElement('p')
for (
!j.firstChild && domUtils.fillNode(h.document, s);
j.firstChild;
)
s.appendChild(j.firstChild)
j.appendChild(s), (r = s)
}
var t = h.document.createElement('span')
l.insertNode(t), domUtils.breakParent(t, j)
var u = t.nextSibling
;(r = u.firstChild),
r ||
((s = h.document.createElement('p')),
domUtils.fillNode(h.document, s),
u.appendChild(s),
(r = s)),
domUtils.isEmptyNode(r) &&
((r.innerHTML = ''), domUtils.fillNode(h.document, r)),
l.setStart(r, 0).collapse(!0).shrinkBoundary().select(),
domUtils.remove(t)
var v = u.previousSibling
v &&
domUtils.isEmptyBlock(v) &&
((v.innerHTML = ''),
domUtils.fillNode(h.document, v.firstChild))
}
c()
}
}
}
if (
8 == e &&
((l = h.selection.getRange()),
l.collapsed &&
domUtils.isStartInblock(l) &&
((o = l.cloneRange().trimBoundary()),
(j = domUtils.findParentByTagName(l.startContainer, 'li', !0)),
j && domUtils.isStartInblock(o)))
) {
if (
((m = domUtils.findParentByTagName(l.startContainer, 'p', !0)),
m && m !== j.firstChild)
) {
var q = domUtils.findParentByTagName(m, ['ol', 'ul'])
return (
domUtils.breakParent(m, q),
f(m),
h.fireEvent('contentchange'),
l.setStart(m, 0).setCursor(!1, !0),
h.fireEvent('saveScene'),
void domUtils.preventDefault(b)
)
}
if (j && (v = j.previousSibling)) {
if (46 == e && j.childNodes.length) return
if (
(dtd.$list[v.tagName] && (v = v.lastChild),
h.undoManger && h.undoManger.save(),
(r = j.firstChild),
domUtils.isBlockElm(r))
)
if (domUtils.isEmptyNode(r))
for (
v.appendChild(r), l.setStart(r, 0).setCursor(!1, !0);
j.firstChild;
)
v.appendChild(j.firstChild)
else
(t = h.document.createElement('span')),
l.insertNode(t),
domUtils.isEmptyBlock(v) && (v.innerHTML = ''),
domUtils.moveChild(j, v),
l.setStartBefore(t).collapse(!0).select(!0),
domUtils.remove(t)
else if (domUtils.isEmptyNode(j)) {
var s = h.document.createElement('p')
v.appendChild(s), l.setStart(s, 0).setCursor()
} else
for (
l.setEnd(v, v.childNodes.length).collapse().select(!0);
j.firstChild;
)
v.appendChild(j.firstChild)
return (
domUtils.remove(j),
h.fireEvent('contentchange'),
h.fireEvent('saveScene'),
void domUtils.preventDefault(b)
)
}
if (j && !j.previousSibling) {
var q = j.parentNode,
p = l.createBookmark()
if (domUtils.isTagNode(q.parentNode, 'ol ul'))
q.parentNode.insertBefore(j, q),
domUtils.isEmptyNode(q) && domUtils.remove(q)
else {
for (; j.firstChild; )
q.parentNode.insertBefore(j.firstChild, q)
domUtils.remove(j),
domUtils.isEmptyNode(q) && domUtils.remove(q)
}
return (
l.moveToBookmark(p).setCursor(!1, !0),
h.fireEvent('contentchange'),
h.fireEvent('saveScene'),
void domUtils.preventDefault(b)
)
}
}
}),
h.addListener('keyup', function (a, c) {
var e = c.keyCode || c.which
if (8 == e) {
var f,
g = h.selection.getRange()
;(f = domUtils.findParentByTagName(
g.startContainer,
['ol', 'ul'],
!0
)) &&
d(
f,
f.tagName.toLowerCase(),
b(f) || domUtils.getComputedStyle(f, 'list-style-type'),
!0
)
}
}),
h.addListener('tabkeydown', function () {
function a(a) {
if (h.options.maxListLevel != -1) {
for (var b = a.parentNode, c = 0; /[ou]l/i.test(b.tagName); )
c++, (b = b.parentNode)
if (c >= h.options.maxListLevel) return !0
}
}
var c = h.selection.getRange(),
f = domUtils.findParentByTagName(c.startContainer, 'li', !0)
if (f) {
var g
if (!c.collapsed) {
h.fireEvent('saveScene'), (g = c.createBookmark())
for (var i, j, l = 0, m = domUtils.findParents(f); (j = m[l++]); )
if (domUtils.isTagNode(j, 'ol ul')) {
i = j
break
}
var n = f
if (g.end)
for (
;
n &&
!(
domUtils.getPosition(n, g.end) & domUtils.POSITION_FOLLOWING
);
)
if (a(n))
n = domUtils.getNextDomNode(n, !1, null, function (a) {
return a !== i
})
else {
var o = n.parentNode,
p = h.document.createElement(o.tagName),
q = utils.indexOf(
k[p.tagName],
b(o) || domUtils.getComputedStyle(o, 'list-style-type')
),
r = q + 1 == k[p.tagName].length ? 0 : q + 1,
s = k[p.tagName][r]
for (
e(p, s), o.insertBefore(p, n);
n &&
!(
domUtils.getPosition(n, g.end) &
domUtils.POSITION_FOLLOWING
);
) {
if (
((f = n.nextSibling),
p.appendChild(n),
!f || domUtils.isTagNode(f, 'ol ul'))
) {
if (f)
for (; (f = f.firstChild) && 'LI' != f.tagName; );
else
f = domUtils.getNextDomNode(
n,
!1,
null,
function (a) {
return a !== i
}
)
break
}
n = f
}
d(p, p.tagName.toLowerCase(), s), (n = f)
}
return (
h.fireEvent('contentchange'), c.moveToBookmark(g).select(), !0
)
}
if (a(f)) return !0
var o = f.parentNode,
p = h.document.createElement(o.tagName),
q = utils.indexOf(
k[p.tagName],
b(o) || domUtils.getComputedStyle(o, 'list-style-type')
)
q = q + 1 == k[p.tagName].length ? 0 : q + 1
var s = k[p.tagName][q]
if ((e(p, s), domUtils.isStartInblock(c)))
return (
h.fireEvent('saveScene'),
(g = c.createBookmark()),
o.insertBefore(p, f),
p.appendChild(f),
d(p, p.tagName.toLowerCase(), s),
h.fireEvent('contentchange'),
c.moveToBookmark(g).select(!0),
!0
)
}
}),
(h.commands.insertorderedlist = h.commands.insertunorderedlist =
{
execCommand: function (a, c) {
c ||
(c =
'insertorderedlist' == a.toLowerCase() ? 'decimal' : 'disc')
var f = this,
h = this.selection.getRange(),
j = function (a) {
return 1 == a.nodeType
? 'br' != a.tagName.toLowerCase()
: !domUtils.isWhitespace(a)
},
k = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
l = f.document.createDocumentFragment()
h.adjustmentBoundary().shrinkBoundary()
var m,
n,
o,
p,
q = h.createBookmark(!0),
r = g(f.document.getElementById(q.start)),
s = 0,
t = g(f.document.getElementById(q.end)),
u = 0
if (r || t) {
if (
(r && (m = r.parentNode),
q.end || (t = r),
t && (n = t.parentNode),
m === n)
) {
for (; r !== t; ) {
if (
((p = r),
(r = r.nextSibling),
!domUtils.isBlockElm(p.firstChild))
) {
for (
var v = f.document.createElement('p');
p.firstChild;
)
v.appendChild(p.firstChild)
p.appendChild(v)
}
l.appendChild(p)
}
if (
((p = f.document.createElement('span')),
m.insertBefore(p, t),
!domUtils.isBlockElm(t.firstChild))
) {
for (v = f.document.createElement('p'); t.firstChild; )
v.appendChild(t.firstChild)
t.appendChild(v)
}
l.appendChild(t),
domUtils.breakParent(p, m),
domUtils.isEmptyNode(p.previousSibling) &&
domUtils.remove(p.previousSibling),
domUtils.isEmptyNode(p.nextSibling) &&
domUtils.remove(p.nextSibling)
var w =
b(m) ||
domUtils.getComputedStyle(m, 'list-style-type') ||
('insertorderedlist' == a.toLowerCase()
? 'decimal'
: 'disc')
if (m.tagName.toLowerCase() == k && w == c) {
for (
var x, y = 0, z = f.document.createDocumentFragment();
(x = l.firstChild);
)
if (domUtils.isTagNode(x, 'ol ul')) z.appendChild(x)
else
for (; x.firstChild; )
z.appendChild(x.firstChild), domUtils.remove(x)
p.parentNode.insertBefore(z, p)
} else
(o = f.document.createElement(k)),
e(o, c),
o.appendChild(l),
p.parentNode.insertBefore(o, p)
return (
domUtils.remove(p),
o && d(o, k, c),
void h.moveToBookmark(q).select()
)
}
if (r) {
for (; r; ) {
if (((p = r.nextSibling), domUtils.isTagNode(r, 'ol ul')))
l.appendChild(r)
else {
for (
var A = f.document.createDocumentFragment(), B = 0;
r.firstChild;
)
domUtils.isBlockElm(r.firstChild) && (B = 1),
A.appendChild(r.firstChild)
if (B) l.appendChild(A)
else {
var C = f.document.createElement('p')
C.appendChild(A), l.appendChild(C)
}
domUtils.remove(r)
}
r = p
}
m.parentNode.insertBefore(l, m.nextSibling),
domUtils.isEmptyNode(m)
? (h.setStartBefore(m), domUtils.remove(m))
: h.setStartAfter(m),
(s = 1)
}
if (t && domUtils.inDoc(n, f.document)) {
for (r = n.firstChild; r && r !== t; ) {
if (((p = r.nextSibling), domUtils.isTagNode(r, 'ol ul')))
l.appendChild(r)
else {
for (
A = f.document.createDocumentFragment(), B = 0;
r.firstChild;
)
domUtils.isBlockElm(r.firstChild) && (B = 1),
A.appendChild(r.firstChild)
B
? l.appendChild(A)
: ((C = f.document.createElement('p')),
C.appendChild(A),
l.appendChild(C)),
domUtils.remove(r)
}
r = p
}
var D = domUtils.createElement(f.document, 'div', {
tmpDiv: 1
})
domUtils.moveChild(t, D),
l.appendChild(D),
domUtils.remove(t),
n.parentNode.insertBefore(l, n),
h.setEndBefore(n),
domUtils.isEmptyNode(n) && domUtils.remove(n),
(u = 1)
}
}
s || h.setStartBefore(f.document.getElementById(q.start)),
q.end && !u && h.setEndAfter(f.document.getElementById(q.end)),
h.enlarge(!0, function (a) {
return i[a.tagName]
}),
(l = f.document.createDocumentFragment())
for (
var E,
F = h.createBookmark(),
G = domUtils.getNextDomNode(F.start, !1, j),
H = h.cloneRange(),
I = domUtils.isBlockElm;
G &&
G !== F.end &&
domUtils.getPosition(G, F.end) & domUtils.POSITION_PRECEDING;
)
if (3 == G.nodeType || dtd.li[G.tagName]) {
if (1 == G.nodeType && dtd.$list[G.tagName]) {
for (; G.firstChild; ) l.appendChild(G.firstChild)
;(E = domUtils.getNextDomNode(G, !1, j)),
domUtils.remove(G),
(G = E)
continue
}
for (
E = G, H.setStartBefore(G);
G && G !== F.end && (!I(G) || domUtils.isBookmarkNode(G));
)
(E = G),
(G = domUtils.getNextDomNode(G, !1, null, function (a) {
return !i[a.tagName]
}))
G &&
I(G) &&
((p = domUtils.getNextDomNode(E, !1, j)),
p &&
domUtils.isBookmarkNode(p) &&
((G = domUtils.getNextDomNode(p, !1, j)), (E = p))),
H.setEndAfter(E),
(G = domUtils.getNextDomNode(E, !1, j))
var J = h.document.createElement('li')
if (
(J.appendChild(H.extractContents()),
domUtils.isEmptyNode(J))
) {
for (var E = h.document.createElement('p'); J.firstChild; )
E.appendChild(J.firstChild)
J.appendChild(E)
}
l.appendChild(J)
} else G = domUtils.getNextDomNode(G, !0, j)
h.moveToBookmark(F).collapse(!0),
(o = f.document.createElement(k)),
e(o, c),
o.appendChild(l),
h.insertNode(o),
d(o, k, c)
for (
var x, y = 0, K = domUtils.getElementsByTagName(o, 'div');
(x = K[y++]);
)
x.getAttribute('tmpDiv') && domUtils.remove(x, !0)
h.moveToBookmark(q).select()
},
queryCommandState: function (a) {
for (
var b,
c = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
d = this.selection.getStartElementPath(),
e = 0;
(b = d[e++]);
) {
if ('TABLE' == b.nodeName) return 0
if (c == b.nodeName.toLowerCase()) return 1
}
return 0
},
queryCommandValue: function (a) {
for (
var c,
d,
e = 'insertorderedlist' == a.toLowerCase() ? 'ol' : 'ul',
f = this.selection.getStartElementPath(),
g = 0;
(d = f[g++]);
) {
if ('TABLE' == d.nodeName) {
c = null
break
}
if (e == d.nodeName.toLowerCase()) {
c = d
break
}
}
return c
? b(c) || domUtils.getComputedStyle(c, 'list-style-type')
: null
}
})
}),
(function () {
var a = {
textarea: function (a, b) {
var c = b.ownerDocument.createElement('textarea')
return (
(c.style.cssText =
'position:absolute;resize:none;width:100%;height:100%;border:0;padding:0;margin:0;overflow-y:auto;'),
browser.ie &&
browser.version < 8 &&
((c.style.width = b.offsetWidth + 'px'),
(c.style.height = b.offsetHeight + 'px'),
(b.onresize = function () {
;(c.style.width = b.offsetWidth + 'px'),
(c.style.height = b.offsetHeight + 'px')
})),
b.appendChild(c),
{
setContent: function (a) {
c.value = a
},
getContent: function () {
return c.value
},
select: function () {
var a
browser.ie
? ((a = c.createTextRange()), a.collapse(!0), a.select())
: (c.setSelectionRange(0, 0), c.focus())
},
dispose: function () {
b.removeChild(c), (b.onresize = null), (c = null), (b = null)
}
}
)
},
codemirror: function (a, b) {
var c = window.CodeMirror(b, {
mode: 'text/html',
tabMode: 'indent',
lineNumbers: !0,
lineWrapping: !0
}),
d = c.getWrapperElement()
return (
(d.style.cssText =
'position:absolute;left:0;top:0;width:100%;height:100%;font-family:consolas,"Courier new",monospace;font-size:13px;'),
(c.getScrollerElement().style.cssText =
'position:absolute;left:0;top:0;width:100%;height:100%;'),
c.refresh(),
{
getCodeMirror: function () {
return c
},
setContent: function (a) {
c.setValue(a)
},
getContent: function () {
return c.getValue()
},
select: function () {
c.focus()
},
dispose: function () {
b.removeChild(d), (d = null), (c = null)
}
}
)
}
}
UE.plugins.source = function () {
function b(b) {
return a[
'codemirror' == f.sourceEditor && window.CodeMirror
? 'codemirror'
: 'textarea'
](e, b)
}
var c,
d,
e = this,
f = this.options,
g = !1
;(f.sourceEditor = browser.ie
? 'textarea'
: f.sourceEditor || 'codemirror'),
e.setOpt({ sourceEditorFirst: !1 })
var h, i, j
e.commands.source = {
execCommand: function () {
if ((g = !g)) {
;(j = e.selection.getRange().createAddress(!1, !0)),
e.undoManger && e.undoManger.save(!0),
browser.gecko && (e.body.contentEditable = !1),
(h = e.iframe.style.cssText),
(e.iframe.style.cssText +=
'position:absolute;left:-32768px;top:-32768px;'),
e.fireEvent('beforegetcontent')
var a = UE.htmlparser(e.body.innerHTML)
e.filterOutputRule(a),
a.traversal(function (a) {
if ('element' == a.type)
switch (a.tagName) {
case 'td':
case 'th':
case 'caption':
a.children &&
1 == a.children.length &&
'br' == a.firstChild().tagName &&
a.removeChild(a.firstChild())
break
case 'pre':
a.innerText(a.innerText().replace(/ /g, ' '))
}
}),
e.fireEvent('aftergetcontent')
var f = a.toHtml(!0)
;(c = b(e.iframe.parentNode)),
c.setContent(f),
(d = e.setContent),
(e.setContent = function (a) {
var b = UE.htmlparser(a)
e.filterInputRule(b), (a = b.toHtml()), c.setContent(a)
}),
setTimeout(function () {
c.select(),
e.addListener('fullscreenchanged', function () {
try {
c.getCodeMirror().refresh()
} catch (a) {}
})
}),
(i = e.getContent),
(e.getContent = function () {
return (
c.getContent() ||
'
' + (browser.ie ? '' : ' ') + '
'
)
})
} else {
e.iframe.style.cssText = h
var k =
c.getContent() || '
' + (browser.ie ? '' : ' ') + '
'
;(k = k.replace(
new RegExp('[\\r\\t\\n ]*?(\\w+)\\s*(?:[^>]*)>', 'g'),
function (a, b) {
return b && !dtd.$inlineWithA[b.toLowerCase()]
? a.replace(/(^[\n\r\t ]*)|([\n\r\t ]*$)/g, '')
: a.replace(/(^[\n\r\t]*)|([\n\r\t]*$)/g, '')
}
)),
(e.setContent = d),
e.setContent(k),
c.dispose(),
(c = null),
(e.getContent = i)
var l = e.body.firstChild
if (
(l ||
((e.body.innerHTML =
'
' + (browser.ie ? '' : ' ') + '
'),
(l = e.body.firstChild)),
e.undoManger && e.undoManger.save(!0),
browser.gecko)
) {
var m = document.createElement('input')
;(m.style.cssText = 'position:absolute;left:0;top:-32768px'),
document.body.appendChild(m),
(e.body.contentEditable = !1),
setTimeout(function () {
domUtils.setViewportOffset(m, { left: -32768, top: 0 }),
m.focus(),
setTimeout(function () {
;(e.body.contentEditable = !0),
e.selection.getRange().moveToAddress(j).select(!0),
domUtils.remove(m)
})
})
} else
try {
e.selection.getRange().moveToAddress(j).select(!0)
} catch (n) {}
}
this.fireEvent('sourcemodechanged', g)
},
queryCommandState: function () {
return 0 | g
},
notNeedUndo: 1
}
var k = e.queryCommandState
;(e.queryCommandState = function (a) {
return (
(a = a.toLowerCase()),
g
? a in { source: 1, fullscreen: 1 }
? 1
: -1
: k.apply(this, arguments)
)
}),
'codemirror' == f.sourceEditor &&
e.addListener('ready', function () {
utils.loadFile(
document,
{
src:
f.codeMirrorJsUrl ||
f.UEDITOR_HOME_URL + 'third-party/codemirror/codemirror.js',
tag: 'script',
type: 'text/javascript',
defer: 'defer'
},
function () {
f.sourceEditorFirst &&
setTimeout(function () {
e.execCommand('source')
}, 0)
}
),
utils.loadFile(document, {
tag: 'link',
rel: 'stylesheet',
type: 'text/css',
href:
f.codeMirrorCssUrl ||
f.UEDITOR_HOME_URL + 'third-party/codemirror/codemirror.css'
})
})
}
})(),
(UE.plugins.enterkey = function () {
var a,
b = this,
c = b.options.enterTag
b.addListener('keyup', function (c, d) {
var e = d.keyCode || d.which
if (13 == e) {
var f,
g = b.selection.getRange(),
h = g.startContainer
if (browser.ie) b.fireEvent('saveScene', !0, !0)
else {
if (/h\d/i.test(a)) {
if (browser.gecko) {
var i = domUtils.findParentByTagName(
h,
[
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'caption',
'table'
],
!0
)
i || (b.document.execCommand('formatBlock', !1, '
'), (f = 1))
} else if (1 == h.nodeType) {
var j,
k = b.document.createTextNode('')
if (
(g.insertNode(k),
(j = domUtils.findParentByTagName(k, 'div', !0)))
) {
for (var l = b.document.createElement('p'); j.firstChild; )
l.appendChild(j.firstChild)
j.parentNode.insertBefore(l, j),
domUtils.remove(j),
g.setStartBefore(k).setCursor(),
(f = 1)
}
domUtils.remove(k)
}
b.undoManger && f && b.undoManger.save()
}
browser.opera && g.select()
}
}
}),
b.addListener('keydown', function (d, e) {
var f = e.keyCode || e.which
if (13 == f) {
if (b.fireEvent('beforeenterkeydown'))
return void domUtils.preventDefault(e)
b.fireEvent('saveScene', !0, !0), (a = '')
var g = b.selection.getRange()
if (!g.collapsed) {
var h = g.startContainer,
i = g.endContainer,
j = domUtils.findParentByTagName(h, 'td', !0),
k = domUtils.findParentByTagName(i, 'td', !0)
if ((j && k && j !== k) || (!j && k) || (j && !k))
return void (e.preventDefault
? e.preventDefault()
: (e.returnValue = !1))
}
if ('p' == c)
browser.ie ||
((h = domUtils.findParentByTagName(
g.startContainer,
[
'ol',
'ul',
'p',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'blockquote',
'caption'
],
!0
)),
h || browser.opera
? ((a = h.tagName),
'p' == h.tagName.toLowerCase() &&
browser.gecko &&
domUtils.removeDirtyAttr(h))
: (b.document.execCommand('formatBlock', !1, '
'),
browser.gecko &&
((g = b.selection.getRange()),
(h = domUtils.findParentByTagName(
g.startContainer,
'p',
!0
)),
h && domUtils.removeDirtyAttr(h))))
else if (
(e.preventDefault ? e.preventDefault() : (e.returnValue = !1),
g.collapsed)
) {
;(m = g.document.createElement('br')), g.insertNode(m)
var l = m.parentNode
l.lastChild === m
? (m.parentNode.insertBefore(m.cloneNode(!0), m),
g.setStartBefore(m))
: g.setStartAfter(m),
g.setCursor()
} else if (
(g.deleteContents(),
(h = g.startContainer),
1 == h.nodeType && (h = h.childNodes[g.startOffset]))
) {
for (; 1 == h.nodeType; ) {
if (dtd.$empty[h.tagName])
return (
g.setStartBefore(h).setCursor(),
b.undoManger && b.undoManger.save(),
!1
)
if (!h.firstChild) {
var m = g.document.createElement('br')
return (
h.appendChild(m),
g.setStart(h, 0).setCursor(),
b.undoManger && b.undoManger.save(),
!1
)
}
h = h.firstChild
}
h === g.startContainer.childNodes[g.startOffset]
? ((m = g.document.createElement('br')),
g.insertNode(m).setCursor())
: g.setStart(h, 0).setCursor()
} else
(m = g.document.createElement('br')),
g.insertNode(m).setStartAfter(m).setCursor()
}
})
}),
(UE.plugins.keystrokes = function () {
var a = this,
b = !0
a.addListener('keydown', function (c, d) {
var e = d.keyCode || d.which,
f = a.selection.getRange()
if (
!f.collapsed &&
!(d.ctrlKey || d.shiftKey || d.altKey || d.metaKey) &&
((e >= 65 && e <= 90) ||
(e >= 48 && e <= 57) ||
(e >= 96 && e <= 111) ||
{ 13: 1, 8: 1, 46: 1 }[e])
) {
var g = f.startContainer
if (
(domUtils.isFillChar(g) && f.setStartBefore(g),
(g = f.endContainer),
domUtils.isFillChar(g) && f.setEndAfter(g),
f.txtToElmBoundary(),
f.endContainer &&
1 == f.endContainer.nodeType &&
((g = f.endContainer.childNodes[f.endOffset]),
g && domUtils.isBr(g) && f.setEndAfter(g)),
0 == f.startOffset &&
((g = f.startContainer),
domUtils.isBoundaryNode(g, 'firstChild') &&
((g = f.endContainer),
f.endOffset ==
(3 == g.nodeType
? g.nodeValue.length
: g.childNodes.length) &&
domUtils.isBoundaryNode(g, 'lastChild'))))
)
return (
a.fireEvent('saveScene'),
(a.body.innerHTML = '
' + (browser.ie ? '' : ' ') + '
'),
f.setStart(a.body.firstChild, 0).setCursor(!1, !0),
void a._selectionChange()
)
}
if (e == keymap.Backspace) {
if (
((f = a.selection.getRange()),
(b = f.collapsed),
a.fireEvent('delkeydown', d))
)
return
var h, i
if (
(f.collapsed &&
f.inFillChar() &&
((h = f.startContainer),
domUtils.isFillChar(h)
? (f.setStartBefore(h).shrinkBoundary(!0).collapse(!0),
domUtils.remove(h))
: ((h.nodeValue = h.nodeValue.replace(
new RegExp('^' + domUtils.fillChar),
''
)),
f.startOffset--,
f.collapse(!0).select(!0))),
(h = f.getClosedNode()))
)
return (
a.fireEvent('saveScene'),
f.setStartBefore(h),
domUtils.remove(h),
f.setCursor(),
a.fireEvent('saveScene'),
void domUtils.preventDefault(d)
)
if (
!browser.ie &&
((h = domUtils.findParentByTagName(f.startContainer, 'table', !0)),
(i = domUtils.findParentByTagName(f.endContainer, 'table', !0)),
(h && !i) || (!h && i) || h !== i)
)
return void d.preventDefault()
}
if (e == keymap.Tab) {
var j = { ol: 1, ul: 1, table: 1 }
if (a.fireEvent('tabkeydown', d))
return void domUtils.preventDefault(d)
var k = a.selection.getRange()
a.fireEvent('saveScene')
for (
var l = 0,
m = '',
n = a.options.tabSize || 4,
o = a.options.tabNode || ' ';
l < n;
l++
)
m += o
var p = a.document.createElement('span')
if (((p.innerHTML = m + domUtils.fillChar), k.collapsed))
k.insertNode(p.cloneNode(!0).firstChild).setCursor(!0)
else {
var q = function (a) {
return domUtils.isBlockElm(a) && !j[a.tagName.toLowerCase()]
}
if (
((h = domUtils.findParent(k.startContainer, q, !0)),
(i = domUtils.findParent(k.endContainer, q, !0)),
h && i && h === i)
)
k.deleteContents(),
k.insertNode(p.cloneNode(!0).firstChild).setCursor(!0)
else {
var r = k.createBookmark()
k.enlarge(!0)
for (
var s = k.createBookmark(),
t = domUtils.getNextDomNode(s.start, !1, q);
t &&
!(domUtils.getPosition(t, s.end) & domUtils.POSITION_FOLLOWING);
)
t.insertBefore(p.cloneNode(!0).firstChild, t.firstChild),
(t = domUtils.getNextDomNode(t, !1, q))
k.moveToBookmark(s).moveToBookmark(r).select()
}
}
domUtils.preventDefault(d)
}
if (
browser.gecko &&
46 == e &&
((k = a.selection.getRange()),
k.collapsed && ((h = k.startContainer), domUtils.isEmptyBlock(h)))
) {
for (
var u = h.parentNode;
1 == domUtils.getChildCount(u) && !domUtils.isBody(u);
)
(h = u), (u = u.parentNode)
return void (h === u.lastChild && d.preventDefault())
}
}),
a.addListener('keyup', function (a, c) {
var d,
e = c.keyCode || c.which,
f = this
if (e == keymap.Backspace) {
if (f.fireEvent('delkeyup')) return
if (((d = f.selection.getRange()), d.collapsed)) {
var g,
h = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6']
if (
(g = domUtils.findParentByTagName(d.startContainer, h, !0)) &&
domUtils.isEmptyBlock(g)
) {
var i = g.previousSibling
if (i && 'TABLE' != i.nodeName)
return (
domUtils.remove(g),
void d.setStartAtLast(i).setCursor(!1, !0)
)
var j = g.nextSibling
if (j && 'TABLE' != j.nodeName)
return (
domUtils.remove(g),
void d.setStartAtFirst(j).setCursor(!1, !0)
)
}
if (domUtils.isBody(d.startContainer)) {
var g = domUtils.createElement(f.document, 'p', {
innerHTML: browser.ie ? domUtils.fillChar : ' '
})
d.insertNode(g).setStart(g, 0).setCursor(!1, !0)
}
}
if (
!b &&
(3 == d.startContainer.nodeType ||
(1 == d.startContainer.nodeType &&
domUtils.isEmptyBlock(d.startContainer)))
)
if (browser.ie) {
var k = d.document.createElement('span')
d.insertNode(k).setStartBefore(k).collapse(!0),
d.select(),
domUtils.remove(k)
} else d.select()
}
})
}),
(UE.plugins.fiximgclick = (function () {
function a() {
;(this.editor = null),
(this.resizer = null),
(this.cover = null),
(this.doc = document),
(this.prePos = { x: 0, y: 0 }),
(this.startPos = { x: 0, y: 0 })
}
var b = !1
return (
(function () {
var c = [
[0, 0, -1, -1],
[0, 0, 0, -1],
[0, 0, 1, -1],
[0, 0, -1, 0],
[0, 0, 1, 0],
[0, 0, -1, 1],
[0, 0, 0, 1],
[0, 0, 1, 1]
]
a.prototype = {
init: function (a) {
var b = this
;(b.editor = a),
(b.startPos = this.prePos = { x: 0, y: 0 }),
(b.dragId = -1)
var c = [],
d = (b.cover = document.createElement('div')),
e = (b.resizer = document.createElement('div'))
for (
d.id = b.editor.ui.id + '_imagescale_cover',
d.style.cssText =
'position:absolute;display:none;z-index:' +
b.editor.options.zIndex +
';filter:alpha(opacity=0); opacity:0;background:#CCC;',
domUtils.on(d, 'mousedown click', function () {
b.hide()
}),
i = 0;
i < 8;
i++
)
c.push(
''
)
;(e.id = b.editor.ui.id + '_imagescale'),
(e.className = 'edui-editor-imagescale'),
(e.innerHTML = c.join('')),
(e.style.cssText +=
';display:none;border:1px solid #3b77ff;z-index:' +
b.editor.options.zIndex +
';'),
b.editor.ui.getDom().appendChild(d),
b.editor.ui.getDom().appendChild(e),
b.initStyle(),
b.initEvents()
},
initStyle: function () {
utils.cssRule(
'imagescale',
'.edui-editor-imagescale{display:none;position:absolute;border:1px solid #38B2CE;cursor:hand;-webkit-box-sizing: content-box;-moz-box-sizing: content-box;box-sizing: content-box;}.edui-editor-imagescale span{position:absolute;width:6px;height:6px;overflow:hidden;font-size:0px;display:block;background-color:#3C9DD0;}.edui-editor-imagescale .edui-editor-imagescale-hand0{cursor:nw-resize;top:0;margin-top:-4px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand1{cursor:n-resize;top:0;margin-top:-4px;left:50%;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand2{cursor:ne-resize;top:0;margin-top:-4px;left:100%;margin-left:-3px;}.edui-editor-imagescale .edui-editor-imagescale-hand3{cursor:w-resize;top:50%;margin-top:-4px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand4{cursor:e-resize;top:50%;margin-top:-4px;left:100%;margin-left:-3px;}.edui-editor-imagescale .edui-editor-imagescale-hand5{cursor:sw-resize;top:100%;margin-top:-3px;left:0;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand6{cursor:s-resize;top:100%;margin-top:-3px;left:50%;margin-left:-4px;}.edui-editor-imagescale .edui-editor-imagescale-hand7{cursor:se-resize;top:100%;margin-top:-3px;left:100%;margin-left:-3px;}'
)
},
initEvents: function () {
var a = this
;(a.startPos.x = a.startPos.y = 0), (a.isDraging = !1)
},
_eventHandler: function (a) {
var c = this
switch (a.type) {
case 'mousedown':
var d,
d = a.target || a.srcElement
d.className.indexOf('edui-editor-imagescale-hand') != -1 &&
c.dragId == -1 &&
((c.dragId = d.className.slice(-1)),
(c.startPos.x = c.prePos.x = a.clientX),
(c.startPos.y = c.prePos.y = a.clientY),
domUtils.on(
c.doc,
'mousemove',
c.proxy(c._eventHandler, c)
))
break
case 'mousemove':
c.dragId != -1 &&
(c.updateContainerStyle(c.dragId, {
x: a.clientX - c.prePos.x,
y: a.clientY - c.prePos.y
}),
(c.prePos.x = a.clientX),
(c.prePos.y = a.clientY),
(b = !0),
c.updateTargetElement())
break
case 'mouseup':
c.dragId != -1 &&
(c.updateContainerStyle(c.dragId, {
x: a.clientX - c.prePos.x,
y: a.clientY - c.prePos.y
}),
c.updateTargetElement(),
c.target.parentNode && c.attachTo(c.target),
(c.dragId = -1)),
domUtils.un(
c.doc,
'mousemove',
c.proxy(c._eventHandler, c)
),
b && ((b = !1), c.editor.fireEvent('contentchange'))
}
},
updateTargetElement: function () {
var a = this
domUtils.setStyles(a.target, {
width: a.resizer.style.width,
height: a.resizer.style.height
}),
(a.target.width = parseInt(a.resizer.style.width)),
(a.target.height = parseInt(a.resizer.style.height)),
a.attachTo(a.target)
},
updateContainerStyle: function (a, b) {
var d,
e = this,
f = e.resizer
0 != c[a][0] &&
((d = parseInt(f.style.left) + b.x),
(f.style.left = e._validScaledProp('left', d) + 'px')),
0 != c[a][1] &&
((d = parseInt(f.style.top) + b.y),
(f.style.top = e._validScaledProp('top', d) + 'px')),
0 != c[a][2] &&
((d = f.clientWidth + c[a][2] * b.x),
(f.style.width = e._validScaledProp('width', d) + 'px')),
0 != c[a][3] &&
((d = f.clientHeight + c[a][3] * b.y),
(f.style.height = e._validScaledProp('height', d) + 'px'))
},
_validScaledProp: function (a, b) {
var c = this.resizer,
d = document
switch (((b = isNaN(b) ? 0 : b), a)) {
case 'left':
return b < 0
? 0
: b + c.clientWidth > d.clientWidth
? d.clientWidth - c.clientWidth
: b
case 'top':
return b < 0
? 0
: b + c.clientHeight > d.clientHeight
? d.clientHeight - c.clientHeight
: b
case 'width':
return b <= 0
? 1
: b + c.offsetLeft > d.clientWidth
? d.clientWidth - c.offsetLeft
: b
case 'height':
return b <= 0
? 1
: b + c.offsetTop > d.clientHeight
? d.clientHeight - c.offsetTop
: b
}
},
hideCover: function () {
this.cover.style.display = 'none'
},
showCover: function () {
var a = this,
b = domUtils.getXY(a.editor.ui.getDom()),
c = domUtils.getXY(a.editor.iframe)
domUtils.setStyles(a.cover, {
width: a.editor.iframe.offsetWidth + 'px',
height: a.editor.iframe.offsetHeight + 'px',
top: c.y - b.y + 'px',
left: c.x - b.x + 'px',
position: 'absolute',
display: ''
})
},
show: function (a) {
var b = this
;(b.resizer.style.display = 'block'),
a && b.attachTo(a),
domUtils.on(
this.resizer,
'mousedown',
b.proxy(b._eventHandler, b)
),
domUtils.on(b.doc, 'mouseup', b.proxy(b._eventHandler, b)),
b.showCover(),
b.editor.fireEvent('afterscaleshow', b),
b.editor.fireEvent('saveScene')
},
hide: function () {
var a = this
a.hideCover(),
(a.resizer.style.display = 'none'),
domUtils.un(
a.resizer,
'mousedown',
a.proxy(a._eventHandler, a)
),
domUtils.un(a.doc, 'mouseup', a.proxy(a._eventHandler, a)),
a.editor.fireEvent('afterscalehide', a)
},
proxy: function (a, b) {
return function (c) {
return a.apply(b || this, arguments)
}
},
attachTo: function (a) {
var b = this,
c = (b.target = a),
d = this.resizer,
e = domUtils.getXY(c),
f = domUtils.getXY(b.editor.iframe),
g = domUtils.getXY(d.parentNode)
domUtils.setStyles(d, {
width: c.width + 'px',
height: c.height + 'px',
left:
f.x +
e.x -
b.editor.document.body.scrollLeft -
g.x -
parseInt(d.style.borderLeftWidth) +
'px',
top:
f.y +
e.y -
b.editor.document.body.scrollTop -
g.y -
parseInt(d.style.borderTopWidth) +
'px'
})
}
}
})(),
function () {
var b,
c = this
c.setOpt('imageScaleEnabled', !0),
!browser.ie &&
c.options.imageScaleEnabled &&
c.addListener('click', function (d, e) {
var f = c.selection.getRange(),
g = f.getClosedNode()
if (
g &&
'IMG' == g.tagName &&
'false' != c.body.contentEditable
) {
if (
g.className.indexOf('edui-faked-music') != -1 ||
g.getAttribute('anchorname') ||
domUtils.hasClass(g, 'loadingclass') ||
domUtils.hasClass(g, 'loaderrorclass')
)
return
if (!b) {
;(b = new a()),
b.init(c),
c.ui.getDom().appendChild(b.resizer)
var h,
i = function (a) {
b.hide(),
b.target &&
c.selection.getRange().selectNode(b.target).select()
},
j = function (a) {
var b = a.target || a.srcElement
!b ||
(void 0 !== b.className &&
b.className.indexOf('edui-editor-imagescale') !=
-1) ||
i(a)
}
c.addListener('afterscaleshow', function (a) {
c.addListener('beforekeydown', i),
c.addListener('beforemousedown', j),
domUtils.on(document, 'keydown', i),
domUtils.on(document, 'mousedown', j),
c.selection.getNative().removeAllRanges()
}),
c.addListener('afterscalehide', function (a) {
c.removeListener('beforekeydown', i),
c.removeListener('beforemousedown', j),
domUtils.un(document, 'keydown', i),
domUtils.un(document, 'mousedown', j)
var d = b.target
d.parentNode &&
c.selection.getRange().selectNode(d).select()
}),
domUtils.on(b.resizer, 'mousedown', function (a) {
c.selection.getNative().removeAllRanges()
var d = a.target || a.srcElement
d &&
d.className.indexOf('edui-editor-imagescale-hand') ==
-1 &&
(h = setTimeout(function () {
b.hide(),
b.target &&
c.selection.getRange().selectNode(d).select()
}, 200))
}),
domUtils.on(b.resizer, 'mouseup', function (a) {
var b = a.target || a.srcElement
b &&
b.className.indexOf('edui-editor-imagescale-hand') ==
-1 &&
clearTimeout(h)
})
}
b.show(g)
} else b && 'none' != b.resizer.style.display && b.hide()
}),
browser.webkit &&
c.addListener('click', function (a, b) {
if (
'IMG' == b.target.tagName &&
'false' != c.body.contentEditable
) {
var d = new dom.Range(c.document)
d.selectNode(b.target).select()
}
})
}
)
})()),
UE.plugin.register(
'autolink',
function () {
var a = 0
return browser.ie
? {}
: {
bindEvents: {
reset: function () {
a = 0
},
keydown: function (a, b) {
var c = this,
d = b.keyCode || b.which
if (32 == d || 13 == d) {
for (
var e,
f,
g = c.selection.getNative(),
h = g.getRangeAt(0).cloneRange(),
i = h.startContainer;
1 == i.nodeType &&
h.startOffset > 0 &&
(i = h.startContainer.childNodes[h.startOffset - 1]);
)
h.setStart(
i,
1 == i.nodeType
? i.childNodes.length
: i.nodeValue.length
),
h.collapse(!0),
(i = h.startContainer)
do {
if (0 == h.startOffset) {
for (
i = h.startContainer.previousSibling;
i && 1 == i.nodeType;
)
i = i.lastChild
if (!i || domUtils.isFillChar(i)) break
e = i.nodeValue.length
} else (i = h.startContainer), (e = h.startOffset)
h.setStart(i, e - 1), (f = h.toString().charCodeAt(0))
} while (160 != f && 32 != f)
if (
h
.toString()
.replace(new RegExp(domUtils.fillChar, 'g'), '')
.match(
/(?:https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)/i
)
) {
for (
;
h.toString().length &&
!/^(?:https?:\/\/|ssh:\/\/|ftp:\/\/|file:\/|www\.)/i.test(
h.toString()
);
)
try {
h.setStart(h.startContainer, h.startOffset + 1)
} catch (j) {
for (
var i = h.startContainer;
!(next = i.nextSibling);
) {
if (domUtils.isBody(i)) return
i = i.parentNode
}
h.setStart(next, 0)
}
if (
domUtils.findParentByTagName(h.startContainer, 'a', !0)
)
return
var k,
l = c.document.createElement('a'),
m = c.document.createTextNode(' ')
c.undoManger && c.undoManger.save(),
l.appendChild(h.extractContents()),
(l.href = l.innerHTML =
l.innerHTML.replace(/<[^>]+>/g, '')),
(k = l
.getAttribute('href')
.replace(new RegExp(domUtils.fillChar, 'g'), '')),
(k = /^(?:https?:\/\/)/gi.test(k) ? k : 'http://' + k),
l.setAttribute('_src', utils.html(k)),
(l.href = utils.html(k)),
h.insertNode(l),
l.parentNode.insertBefore(m, l.nextSibling),
h.setStart(m, 0),
h.collapse(!0),
g.removeAllRanges(),
g.addRange(h),
c.undoManger && c.undoManger.save()
}
}
}
}
}
},
function () {
function a(a) {
if (3 == a.nodeType) return null
if ('A' == a.nodeName) return a
for (var b = a.lastChild; b; ) {
if ('A' == b.nodeName) return b
if (3 == b.nodeType) {
if (domUtils.isWhitespace(b)) {
b = b.previousSibling
continue
}
return null
}
b = b.lastChild
}
}
var b = { 37: 1, 38: 1, 39: 1, 40: 1, 13: 1, 32: 1 }
browser.ie &&
this.addListener('keyup', function (c, d) {
var e = this,
f = d.keyCode
if (b[f]) {
var g = e.selection.getRange(),
h = g.startContainer
if (13 == f) {
for (; h && !domUtils.isBody(h) && !domUtils.isBlockElm(h); )
h = h.parentNode
if (h && !domUtils.isBody(h) && 'P' == h.nodeName) {
var i = h.previousSibling
if (i && 1 == i.nodeType) {
var i = a(i)
i && !i.getAttribute('_href') && domUtils.remove(i, !0)
}
}
} else if (32 == f)
3 == h.nodeType &&
/^\s$/.test(h.nodeValue) &&
((h = h.previousSibling),
h &&
'A' == h.nodeName &&
!h.getAttribute('_href') &&
domUtils.remove(h, !0))
else if (
((h = domUtils.findParentByTagName(h, 'a', !0)),
h && !h.getAttribute('_href'))
) {
var j = g.createBookmark()
domUtils.remove(h, !0), g.moveToBookmark(j).select(!0)
}
}
})
}
),
(UE.plugins.autoheight = function () {
function a() {
var a = this
clearTimeout(e),
f ||
((!a.queryCommandState ||
(a.queryCommandState && 1 != a.queryCommandState('source'))) &&
(e = setTimeout(function () {
for (var b = a.body.lastChild; b && 1 != b.nodeType; )
b = b.previousSibling
b &&
1 == b.nodeType &&
((b.style.clear = 'both'),
(d = Math.max(
domUtils.getXY(b).y + b.offsetHeight + 25,
Math.max(h.minFrameHeight, h.initialFrameHeight)
)),
d != g &&
(d !== parseInt(a.iframe.parentNode.style.height) &&
(a.iframe.parentNode.style.height = d + 'px'),
(a.body.style.height = d + 'px'),
(g = d)),
domUtils.removeStyle(b, 'clear'))
}, 50)))
}
var b = this
if (
((b.autoHeightEnabled = b.options.autoHeightEnabled !== !1),
b.autoHeightEnabled)
) {
var c,
d,
e,
f,
g = 0,
h = b.options
b.addListener('fullscreenchanged', function (a, b) {
f = b
}),
b.addListener('destroy', function () {
b.removeListener('contentchange afterinserthtml keyup mouseup', a)
}),
(b.enableAutoHeight = function () {
var b = this
if (b.autoHeightEnabled) {
var d = b.document
;(b.autoHeightEnabled = !0),
(c = d.body.style.overflowY),
(d.body.style.overflowY = 'hidden'),
b.addListener('contentchange afterinserthtml keyup mouseup', a),
setTimeout(
function () {
a.call(b)
},
browser.gecko ? 100 : 0
),
b.fireEvent('autoheightchanged', b.autoHeightEnabled)
}
}),
(b.disableAutoHeight = function () {
;(b.body.style.overflowY = c || ''),
b.removeListener('contentchange', a),
b.removeListener('keyup', a),
b.removeListener('mouseup', a),
(b.autoHeightEnabled = !1),
b.fireEvent('autoheightchanged', b.autoHeightEnabled)
}),
b.on('setHeight', function () {
b.disableAutoHeight()
}),
b.addListener('ready', function () {
b.enableAutoHeight()
var c
domUtils.on(
browser.ie ? b.body : b.document,
browser.webkit ? 'dragover' : 'drop',
function () {
clearTimeout(c),
(c = setTimeout(function () {
a.call(b)
}, 100))
}
)
var d
window.onscroll = function () {
null === d
? (d = this.scrollY)
: 0 == this.scrollY &&
0 != d &&
(b.window.scrollTo(0, 0), (d = null))
}
})
}
}),
(UE.plugins.autofloat = function () {
function a() {
return UE.ui ? 1 : (alert(g.autofloatMsg), 0)
}
function b() {
var a = document.body.style
;(a.backgroundImage = 'url("about:blank")'),
(a.backgroundAttachment = 'fixed')
}
function c() {
var a = domUtils.getXY(k),
b = domUtils.getComputedStyle(k, 'position'),
c = domUtils.getComputedStyle(k, 'left')
;(k.style.width = k.offsetWidth + 'px'),
(k.style.zIndex = 1 * f.options.zIndex + 1),
k.parentNode.insertBefore(q, k),
o || (p && browser.ie)
? ('absolute' != k.style.position &&
(k.style.position = 'absolute'),
(k.style.top =
(document.body.scrollTop ||
document.documentElement.scrollTop) -
l +
i +
'px'))
: (browser.ie7Compat &&
r &&
((r = !1),
(k.style.left =
domUtils.getXY(k).x -
document.documentElement.getBoundingClientRect().left +
2 +
'px')),
'fixed' != k.style.position &&
((k.style.position = 'fixed'),
(k.style.top = i + 'px'),
('absolute' == b || 'relative' == b) &&
parseFloat(c) &&
(k.style.left = a.x + 'px')))
}
function d() {
;(r = !0),
q.parentNode && q.parentNode.removeChild(q),
(k.style.cssText = j)
}
function e() {
var a = m(f.container),
b = f.options.toolbarTopOffset || 0
a.top < 0 && a.bottom - k.offsetHeight > b ? c() : d()
}
var f = this,
g = f.getLang()
f.setOpt({ topOffset: 0 })
var h = f.options.autoFloatEnabled !== !1,
i = f.options.topOffset
if (h) {
var j,
k,
l,
m,
n = UE.ui.uiUtils,
o = browser.ie && browser.version <= 6,
p = browser.quirks,
q = document.createElement('div'),
r = !0,
s = utils.defer(
function () {
e()
},
browser.ie ? 200 : 100,
!0
)
f.addListener('destroy', function () {
domUtils.un(window, ['scroll', 'resize'], e),
f.removeListener('keydown', s)
}),
f.addListener('ready', function () {
if (a(f)) {
if (!f.ui) return
;(m = n.getClientRect),
(k = f.ui.getDom('toolbarbox')),
(l = m(k).top),
(j = k.style.cssText),
(q.style.height = k.offsetHeight + 'px'),
o && b(),
domUtils.on(window, ['scroll', 'resize'], e),
f.addListener('keydown', s),
f.addListener('beforefullscreenchange', function (a, b) {
b && d()
}),
f.addListener('fullscreenchanged', function (a, b) {
b || e()
}),
f.addListener('sourcemodechanged', function (a, b) {
setTimeout(function () {
e()
}, 0)
}),
f.addListener('clearDoc', function () {
setTimeout(function () {
e()
}, 0)
})
}
})
}
}),
(UE.plugins.video = function () {
function a(a, b, d, e, f, g, h) {
;(a = utils.unhtmlForUrl(a)),
(f = utils.unhtml(f)),
(g = utils.unhtml(g).trim()),
(b = parseInt(b, 10) || 0),
(d = parseInt(d, 10) || 0)
var i
switch (h) {
case 'image':
i =
''
break
case 'embed':
i =
'