jqwidgets-ng 17.0.0 → 17.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/jqxgantt/angular_jqxgantt.mjs +1385 -0
- package/esm2020/jqxgantt/angular_jqxgantt.module.mjs +21 -0
- package/esm2020/jqxgantt/index.mjs +1 -0
- package/esm2020/jqxgantt/jqwidgets-ng-jqxgantt.mjs +4 -0
- package/esm2020/jqxgantt/public_api.mjs +2 -0
- package/fesm2015/jqwidgets-ng-jqxgantt.mjs +1413 -0
- package/fesm2020/jqwidgets-ng-jqxgantt.mjs +1413 -0
- package/jqwidgets/jqx-all.js +9 -7
- package/jqwidgets/jqxangular.js +1 -1
- package/jqwidgets/jqxbarcode.js +1 -1
- package/jqwidgets/jqxbargauge.js +1 -1
- package/jqwidgets/jqxbulletchart.js +1 -1
- package/jqwidgets/jqxbuttongroup.js +1 -1
- package/jqwidgets/jqxbuttons.js +1 -1
- package/jqwidgets/jqxcalendar.js +1 -1
- package/jqwidgets/jqxchart.annotations.js +1 -1
- package/jqwidgets/jqxchart.api.js +1 -1
- package/jqwidgets/jqxchart.core.js +1 -1
- package/jqwidgets/jqxchart.js +1 -1
- package/jqwidgets/jqxchart.rangeselector.js +1 -1
- package/jqwidgets/jqxchart.waterfall.js +1 -1
- package/jqwidgets/jqxcheckbox.js +2 -2
- package/jqwidgets/jqxcheckboxgroup.js +1 -1
- package/jqwidgets/jqxcolorpicker.js +1 -1
- package/jqwidgets/jqxcombobox.js +1 -1
- package/jqwidgets/jqxcomplexinput.js +1 -1
- package/jqwidgets/jqxcore.js +1 -1
- package/jqwidgets/jqxdata.export.js +1 -1
- package/jqwidgets/jqxdata.js +1 -1
- package/jqwidgets/jqxdatatable.js +2 -2
- package/jqwidgets/jqxdate.js +1 -1
- package/jqwidgets/jqxdatetimeinput.js +1 -1
- package/jqwidgets/jqxdocking.js +1 -1
- package/jqwidgets/jqxdockinglayout.js +1 -1
- package/jqwidgets/jqxdockpanel.js +1 -1
- package/jqwidgets/jqxdragdrop.js +1 -1
- package/jqwidgets/jqxdraw.js +1 -1
- package/jqwidgets/jqxdropdownbutton.js +1 -1
- package/jqwidgets/jqxdropdownlist.js +1 -1
- package/jqwidgets/jqxeditor.js +2 -2
- package/jqwidgets/jqxexpander.js +1 -1
- package/jqwidgets/jqxfileupload.js +1 -1
- package/jqwidgets/jqxform.js +1 -1
- package/jqwidgets/jqxformattedinput.js +1 -1
- package/jqwidgets/jqxgantt.api.js +382 -0
- package/jqwidgets/jqxgantt.js +9 -0
- package/jqwidgets/jqxgauge.js +1 -1
- package/jqwidgets/jqxgrid.aggregates.js +1 -1
- package/jqwidgets/jqxgrid.columnsreorder.js +1 -1
- package/jqwidgets/jqxgrid.columnsresize.js +1 -1
- package/jqwidgets/jqxgrid.edit.js +1 -1
- package/jqwidgets/jqxgrid.export.js +1 -1
- package/jqwidgets/jqxgrid.filter.js +1 -1
- package/jqwidgets/jqxgrid.grouping.js +1 -1
- package/jqwidgets/jqxgrid.js +2 -2
- package/jqwidgets/jqxgrid.pager.js +1 -1
- package/jqwidgets/jqxgrid.selection.js +1 -1
- package/jqwidgets/jqxgrid.sort.js +1 -1
- package/jqwidgets/jqxgrid.storage.js +1 -1
- package/jqwidgets/jqxheatmap.js +1 -1
- package/jqwidgets/jqxinput.js +1 -1
- package/jqwidgets/jqxkanban.js +1 -1
- package/jqwidgets/jqxknob.js +1 -1
- package/jqwidgets/jqxknockout.js +1 -1
- package/jqwidgets/jqxlayout.js +1 -1
- package/jqwidgets/jqxlistbox.js +1 -1
- package/jqwidgets/jqxlistmenu.js +1 -1
- package/jqwidgets/jqxloader.js +1 -1
- package/jqwidgets/jqxmaskedinput.js +1 -1
- package/jqwidgets/jqxmenu.js +1 -1
- package/jqwidgets/jqxnavbar.js +1 -1
- package/jqwidgets/jqxnavigationbar.js +1 -1
- package/jqwidgets/jqxnotification.js +1 -1
- package/jqwidgets/jqxnumberinput.js +1 -1
- package/jqwidgets/jqxpanel.js +1 -1
- package/jqwidgets/jqxpasswordinput.js +1 -1
- package/jqwidgets/jqxpivot.js +1 -1
- package/jqwidgets/jqxpivotdesigner.js +1 -1
- package/jqwidgets/jqxpivotgrid.js +1 -1
- package/jqwidgets/jqxpopover.js +1 -1
- package/jqwidgets/jqxprogressbar.js +1 -1
- package/jqwidgets/jqxqrcode.js +1 -1
- package/jqwidgets/jqxradiobutton.js +1 -1
- package/jqwidgets/jqxradiobuttongroup.js +1 -1
- package/jqwidgets/jqxrangeselector.js +1 -1
- package/jqwidgets/jqxrating.js +1 -1
- package/jqwidgets/jqxresponsivepanel.js +1 -1
- package/jqwidgets/jqxribbon.js +2 -2
- package/jqwidgets/jqxrichtextarea.js +2453 -0
- package/jqwidgets/jqxscheduler.api.js +1 -1
- package/jqwidgets/jqxscheduler.js +2 -2
- package/jqwidgets/jqxscrollbar.js +1 -1
- package/jqwidgets/jqxscrollview.js +1 -1
- package/jqwidgets/jqxslider.js +1 -1
- package/jqwidgets/jqxsortable.js +1 -1
- package/jqwidgets/jqxsplitlayout.js +2445 -6
- package/jqwidgets/jqxsplitter.js +1 -1
- package/jqwidgets/jqxswitchbutton.js +1 -1
- package/jqwidgets/jqxtabs.js +1 -1
- package/jqwidgets/jqxtagcloud.js +1 -1
- package/jqwidgets/jqxtextarea.js +1 -1
- package/jqwidgets/jqxtimepicker.js +1 -1
- package/jqwidgets/jqxtoolbar.js +1 -1
- package/jqwidgets/jqxtooltip.js +1 -1
- package/jqwidgets/jqxtouch.js +1 -1
- package/jqwidgets/jqxtree.js +1 -1
- package/jqwidgets/jqxtreegrid.js +1 -1
- package/jqwidgets/jqxtreemap.js +1 -1
- package/jqwidgets/jqxvalidator.js +1 -1
- package/jqwidgets/jqxwindow.js +1 -1
- package/jqwidgets/styles/gantt/font/jqx-icons.eot +0 -0
- package/jqwidgets/styles/gantt/font/jqx-icons.svg +332 -0
- package/jqwidgets/styles/gantt/font/jqx-icons.ttf +0 -0
- package/jqwidgets/styles/gantt/font/jqx-icons.woff +0 -0
- package/jqwidgets/styles/gantt/font/jqx-icons.woff2 +0 -0
- package/jqwidgets/styles/gantt/jqx.gantt.css +18668 -0
- package/jqwidgets/styles/jqx.base.css +18 -1
- package/jqwidgets/styles/jqx.fluent.css +5 -0
- package/jqwidgets/styles/scss/jqx.fluent.scss +5 -0
- package/jqwidgets.d.ts +153 -0
- package/jqxgantt/angular_jqxgantt.d.ts +316 -0
- package/jqxgantt/angular_jqxgantt.module.d.ts +8 -0
- package/jqxgantt/index.d.ts +1 -0
- package/jqxgantt/jqwidgets-ng-jqxgantt.d.ts +5 -0
- package/jqxgantt/package.json +13 -0
- package/jqxgantt/public_api.d.ts +2 -0
- package/package.json +2 -1
|
@@ -0,0 +1,2453 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
(function ($) {
|
|
4
|
+
$.jqx.jqxWidget("jqxRichTextArea", "", {});
|
|
5
|
+
$.extend($.jqx._jqxRichTextArea.prototype, {
|
|
6
|
+
defineInstance: function () {
|
|
7
|
+
var settings = {
|
|
8
|
+
width: null,
|
|
9
|
+
height: null,
|
|
10
|
+
disabled: false,
|
|
11
|
+
pasteMode: "html",
|
|
12
|
+
editable: true,
|
|
13
|
+
lineBreak: "default",
|
|
14
|
+
changeType: null,
|
|
15
|
+
toolbarPosition: "top",
|
|
16
|
+
fontFamily: "sans-serif",
|
|
17
|
+
commands:
|
|
18
|
+
{
|
|
19
|
+
"bold": { tooltip: "Bold", command: "bold", type: 'toggleButton' },
|
|
20
|
+
"italic": { tooltip: "Italic", command: "italic", type: 'toggleButton' },
|
|
21
|
+
"underline": { tooltip: "Underline", command: "underline", type: 'toggleButton' },
|
|
22
|
+
"format": {
|
|
23
|
+
placeHolder: "Format Block", tooltip: "Format Block", command: "formatblock",
|
|
24
|
+
value: [
|
|
25
|
+
{ value: 'p', label: 'Paragraph' },
|
|
26
|
+
{ value: 'h1', label: 'Header 1' },
|
|
27
|
+
{ value: 'h2', label: 'Header 2' },
|
|
28
|
+
{ value: 'h3', label: 'Header 3' },
|
|
29
|
+
{ value: 'h4', label: 'Header 4' }
|
|
30
|
+
], type: 'list', width: 120, dropDownWidth: 190, height: 25
|
|
31
|
+
},
|
|
32
|
+
"font": {
|
|
33
|
+
placeHolder: "Font", tooltip: "Font Name", command: "fontname",
|
|
34
|
+
value:
|
|
35
|
+
[
|
|
36
|
+
{ label: 'Arial', value: 'Arial, Helvetica, sans-serif' },
|
|
37
|
+
{ label: 'Comic Sans MS', value: '"Comic Sans MS", cursive, sans-serif' },
|
|
38
|
+
{ label: 'Courier New', value: '"Courier New", Courier, monospace' },
|
|
39
|
+
{ label: 'Georgia', value: "Georgia,serif" },
|
|
40
|
+
{ label: "Impact", value: "Impact,Charcoal,sans-serif" },
|
|
41
|
+
{ label: "Lucida Console", value: "'Lucida Console',Monaco,monospace" },
|
|
42
|
+
{ label: 'Tahoma', value: 'Tahoma,Geneva,sans-serif' },
|
|
43
|
+
{ label: "Times New Roman", value: "'Times New Roman',Times,serif" },
|
|
44
|
+
{ label: 'Trebuchet MS', value: '"Trebuchet MS",Helvetica,sans-serif' },
|
|
45
|
+
{ label: 'Verdana', value: "Verdana,Geneva,sans-serif" }
|
|
46
|
+
],
|
|
47
|
+
|
|
48
|
+
type: 'list', width: 160, height: 25, dropDownWidth: 160
|
|
49
|
+
},
|
|
50
|
+
"left": { tooltip: "Align Left", command: "justifyleft", type: 'toggleButton' },
|
|
51
|
+
"center": { tooltip: "Align Center", command: "justifycenter", type: 'toggleButton' },
|
|
52
|
+
"right": { tooltip: "Align Right", command: "justifyright", type: 'toggleButton' },
|
|
53
|
+
"outdent": { tooltip: "Indent Less", command: "outdent", type: 'button' },
|
|
54
|
+
"indent": { tooltip: "Indent More", command: "indent", type: 'button' },
|
|
55
|
+
"ul": { tooltip: "Insert unordered list", command: "insertunorderedlist", type: 'toggleButton' },
|
|
56
|
+
"ol": { tooltip: "Insert ordered list", command: "insertorderedlist", type: 'toggleButton' },
|
|
57
|
+
"clean": { tooltip: "Remove Formatting", command: "removeformat", type: 'button' }
|
|
58
|
+
},
|
|
59
|
+
createCommand: null,
|
|
60
|
+
defaultLocalization:
|
|
61
|
+
{
|
|
62
|
+
"bold": "Bold",
|
|
63
|
+
"italic": "Italic",
|
|
64
|
+
"underline": "Underline",
|
|
65
|
+
"format": "Format Block",
|
|
66
|
+
"font": "Font Name",
|
|
67
|
+
"size": "Font Size",
|
|
68
|
+
"color": "Text Color",
|
|
69
|
+
"background": "Fill Color",
|
|
70
|
+
"left": "Align Left",
|
|
71
|
+
"center": "Align Center",
|
|
72
|
+
"right": "Align Right",
|
|
73
|
+
"outdent": "Indent Less",
|
|
74
|
+
"indent": "Indent More",
|
|
75
|
+
"ul": "Insert unordered list",
|
|
76
|
+
"ol": "Insert ordered list",
|
|
77
|
+
"image": "Insert image",
|
|
78
|
+
"link": "Insert link",
|
|
79
|
+
"html": "View source",
|
|
80
|
+
"clean": "Remove Formatting",
|
|
81
|
+
"Remove": "Remove",
|
|
82
|
+
"Ok": "Ok",
|
|
83
|
+
"Cancel": "Cancel",
|
|
84
|
+
"Change": "Change",
|
|
85
|
+
"Go to link": "Go to link",
|
|
86
|
+
"Open in a new window/tab": "Open in a new window/tab",
|
|
87
|
+
"Align": "Align",
|
|
88
|
+
"VSpace": "VSpace",
|
|
89
|
+
"HSpace": "HSpace",
|
|
90
|
+
"Width": "Width",
|
|
91
|
+
"Height": "Height",
|
|
92
|
+
"Title": "Title",
|
|
93
|
+
"URL": "URL",
|
|
94
|
+
"Insert Image": "Insert Image",
|
|
95
|
+
"Insert Link": "Insert Link",
|
|
96
|
+
"Alt Text": "Alt Text",
|
|
97
|
+
"not set": "<not set>",
|
|
98
|
+
"Left": "Left",
|
|
99
|
+
"Right": "Right",
|
|
100
|
+
"Paragraph": "Paragraph",
|
|
101
|
+
"Header": "Header",
|
|
102
|
+
"Arial": "Arial",
|
|
103
|
+
"Comic Sans MS": "Comic Sans MS",
|
|
104
|
+
"Courier New": "Courier New",
|
|
105
|
+
"Georgia": "Georgia",
|
|
106
|
+
"Impact": "Impact",
|
|
107
|
+
"Lucida Console": "Lucida Console",
|
|
108
|
+
"Tahoma": "Tahoma",
|
|
109
|
+
"Times New Roman": "Times New Roman",
|
|
110
|
+
"Trebuchet MS": "Trebuchet MS",
|
|
111
|
+
"Verdana": "Verdana"
|
|
112
|
+
},
|
|
113
|
+
localization: null,
|
|
114
|
+
tools: "bold italic underline | format | left center right | outdent indent | ul ol | clean ",
|
|
115
|
+
readOnly: false,
|
|
116
|
+
stylesheets: new Array(),
|
|
117
|
+
keyPressed: null,
|
|
118
|
+
events: ['change']
|
|
119
|
+
}
|
|
120
|
+
if (this === $.jqx._jqxRichTextArea.prototype) {
|
|
121
|
+
return settings;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
$.extend(true, this, settings);
|
|
125
|
+
this.localization = this.defaultLocalization;
|
|
126
|
+
return settings;
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
createInstance: function (args) {
|
|
130
|
+
var that = this;
|
|
131
|
+
that.textArea = that.host;
|
|
132
|
+
var isContentEditable = that.host.attr('contenteditable');
|
|
133
|
+
that.host.addClass(that.toThemeProperty('jqx-widget'));
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
var editor = $("<div class='jqx-editor'><div class='jqx-editor-container'><div class='jqx-editor-toolbar-container' aria-label='Formatting options' role='toolbar'><div class='jqx-editor-toolbar'></div></div><div class='jqx-editor-content'><iframe src='javascript:\"<html></html>\"' allowtransparency='true' frameborder='0'></iframe></div></div></div>");
|
|
137
|
+
that.widget = editor;
|
|
138
|
+
that.widget[0].className = that.widget[0].className + " " + that.element.className;
|
|
139
|
+
try {
|
|
140
|
+
that.widget[0].style = that.element.style;
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
var content = $.trim(that.host.html()) + "​";
|
|
146
|
+
if (that.lineBreak == "default" || that.lineBreak == "div") {
|
|
147
|
+
content = "<div>" + content + "</div>";
|
|
148
|
+
}
|
|
149
|
+
else if (that.lineBreak == "p") {
|
|
150
|
+
content = "<p>" + content + "</p>";
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
content = content.replace(/</ig, '<');
|
|
154
|
+
content = content.replace(/>/ig, '>');
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
that.host.css('display', 'none');
|
|
158
|
+
that.host.after(editor);
|
|
159
|
+
editor.find('iframe').after(that.host);
|
|
160
|
+
that.container = editor.find('.jqx-editor-container');
|
|
161
|
+
that.toolbarContainer = editor.find('.jqx-editor-toolbar-container');
|
|
162
|
+
that.toolbar = editor.find('.jqx-editor-toolbar');
|
|
163
|
+
that.iframe = editor.find('iframe');
|
|
164
|
+
that.content = editor.find('.jqx-editor-content');
|
|
165
|
+
|
|
166
|
+
var initIFrame = function () {
|
|
167
|
+
that.editorDocument = that.iframe[0].contentWindow.document;
|
|
168
|
+
that.selection = new jqxSelection(that.editorDocument);
|
|
169
|
+
var loaded = 0;
|
|
170
|
+
that.addHandler(that.iframe, 'load', function () {
|
|
171
|
+
loaded++;
|
|
172
|
+
if (loaded > 1) {
|
|
173
|
+
that.iframe.off('load');
|
|
174
|
+
that.content.find("iframe").remove();
|
|
175
|
+
var iframe = $("<iframe src='javascript:\"<html></html>\"' allowtransparency='true' frameborder='0'></iframe>").appendTo(that.content);
|
|
176
|
+
that.iframe = editor.find('iframe');
|
|
177
|
+
initIFrame();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (!$.jqx.browser.mozilla) {
|
|
182
|
+
that.editorDocument.designMode = 'On';
|
|
183
|
+
}
|
|
184
|
+
that.editorDocument.open();
|
|
185
|
+
var rtlStyle = that.rtl ? "direction:rtl;" : "";
|
|
186
|
+
var selectionStyle = $.jqx.browser.msie ? "::selection{color: #fff; background: #328EFD;};" +
|
|
187
|
+
"::-moz-selection{color: #fff; background: #328eD;};" +
|
|
188
|
+
"::selection:window-inactive {background: #c7c7c7; color: #000;}" +
|
|
189
|
+
"::-moz-selection:window-inactive {background: #c7c7c7; color: #000;}" +
|
|
190
|
+
"html{font-size:13px; height:100%;}body{padding-top:1px;margin-top:-1px; padding-right: 1px; overflow-x: hidden;" +
|
|
191
|
+
"word-wrap: break-word;-webkit-nbsp-mode: space;-webkit-line-break: after-white-space;"
|
|
192
|
+
: "";
|
|
193
|
+
that.editorDocument.write(
|
|
194
|
+
"<!DOCTYPE html><html><head>" +
|
|
195
|
+
"<meta charset='utf-8' />" +
|
|
196
|
+
"<style>" +
|
|
197
|
+
"html,body{padding:0; margin:0; font-size: 13px; font-family: " + that.fontFamily + "; background:#fff; min-height:100%; " + rtlStyle + "}" +
|
|
198
|
+
selectionStyle +
|
|
199
|
+
"}" +
|
|
200
|
+
"h1{font-size:2em;margin:.67em 0}" +
|
|
201
|
+
"h2{font-size: 1.5em; margin: .75em 0}" +
|
|
202
|
+
"h3{font-size: 1.17em; margin: .83em 0}" +
|
|
203
|
+
"h4{font-size:1em; margin: 1.12em 0 }" +
|
|
204
|
+
"h5{font-size: .83em; margin: 1.5em 0}" +
|
|
205
|
+
"h6{font-size: .75em; margin: 1.67em 0}" +
|
|
206
|
+
"p{margin: 0px;padding:0 .2em}" +
|
|
207
|
+
"ul,ol{padding-left:2.5em}" +
|
|
208
|
+
"a{color:#00a}" +
|
|
209
|
+
"code{font-size:1.23em}" +
|
|
210
|
+
".jqx-editor-paste-element {position: absolute; left: -1000px; height: 1px; overflow: hidden; top: -1000px;}" +
|
|
211
|
+
".jqx-editor-focus {border: 1px solid #aaa !important;}" +
|
|
212
|
+
"</style>" +
|
|
213
|
+
$.map(that.stylesheets, function (href) {
|
|
214
|
+
return "<link rel='stylesheet' href='" + href + "'>";
|
|
215
|
+
}).join("") +
|
|
216
|
+
"</head><body autocorrect='off' contenteditable='true'></body></html>"
|
|
217
|
+
);
|
|
218
|
+
that.contentEditableElement = that.editorDocument.body;
|
|
219
|
+
|
|
220
|
+
that._textArea = that.element;
|
|
221
|
+
var hostData = that.host.data();
|
|
222
|
+
hostData.jqxRichTextArea.host = editor;
|
|
223
|
+
hostData.jqxRichTextArea.element = editor[0];
|
|
224
|
+
|
|
225
|
+
that.element = editor[0];
|
|
226
|
+
editor[0].id = that._textArea.id;
|
|
227
|
+
that._textArea.id = that._textArea.id + "TextArea";
|
|
228
|
+
$(that.element).addClass(that.toThemeProperty('jqx-widget'));
|
|
229
|
+
that.host = $(that.element);
|
|
230
|
+
that.host.data(hostData);
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
that.editorDocument.execCommand("useCSS", false, false);
|
|
234
|
+
that.editorDocument.execCommand("enableInlineTableEditing", null, false);
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
that.editorDocument.execCommand("styleWithCSS", 0, true);
|
|
240
|
+
}
|
|
241
|
+
catch (e) {
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
that.editorDocument.close();
|
|
245
|
+
that.editor = $(that.editorDocument.body);
|
|
246
|
+
that.editor.html(content).attr('spellcheck', false).attr('autocorrect', 'off');
|
|
247
|
+
}
|
|
248
|
+
initIFrame();
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
focus: function () {
|
|
252
|
+
var that = this;
|
|
253
|
+
if ($.jqx.browser.mozilla) {
|
|
254
|
+
if (!that.focused) {
|
|
255
|
+
if (that.iframe) {
|
|
256
|
+
that.iframe.focus();
|
|
257
|
+
}
|
|
258
|
+
that.selection.selectNode(that.editor[0].firstChild, true);
|
|
259
|
+
that.selection.getRange().collapse(true);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
that.editor.focus();
|
|
263
|
+
var range = that.range != null ? that.range : that.getRange();
|
|
264
|
+
that.selectRange(range);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
refresh: function (initialRefresh) {
|
|
268
|
+
var that = this;
|
|
269
|
+
$.each(this.defaultLocalization, function (index, value) {
|
|
270
|
+
if (!that.localization[index]) {
|
|
271
|
+
that.localization[index] = value;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
that._removeHandlers();
|
|
275
|
+
that.toolbar.addClass(that.toThemeProperty('jqx-widget-header'));
|
|
276
|
+
if (that.content) {
|
|
277
|
+
that.widget.css('width', that.width);
|
|
278
|
+
that.widget.css('height', that.height);
|
|
279
|
+
that.widget.addClass(that.toThemeProperty("jqx-editor"));
|
|
280
|
+
that.widget.addClass(that.toThemeProperty("jqx-widget"));
|
|
281
|
+
that.widget.addClass(that.toThemeProperty("jqx-rc-all"));
|
|
282
|
+
that.widget.addClass(that.toThemeProperty("jqx-widget-header"));
|
|
283
|
+
that.content.addClass(that.toThemeProperty('jqx-widget-content'));
|
|
284
|
+
that.container.addClass(that.toThemeProperty('jqx-editor-container'));
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
that.toolbarContainer.addClass(that.toThemeProperty('jqx-widget-header'));
|
|
288
|
+
that.toolbarContainer.addClass(that.toThemeProperty("jqx-editor-toolbar-inline"));
|
|
289
|
+
that.toolbarContainer.addClass(that.toThemeProperty("jqx-widget"));
|
|
290
|
+
that.toolbarContainer.addClass(that.toThemeProperty("jqx-rc-all"));
|
|
291
|
+
that.toolbarContainer.hide();
|
|
292
|
+
that.toolbarContainer.css('position', 'absolute');
|
|
293
|
+
that.editor.addClass(that.toThemeProperty("jqx-editor-inline"));
|
|
294
|
+
that.toolbarContainer.css('width', that.host.outerWidth() + 'px');
|
|
295
|
+
}
|
|
296
|
+
var index = that.toolbarContainer.index();
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
var toolsValue = that.tools;
|
|
300
|
+
// render toolbar.
|
|
301
|
+
if (toolsValue !== false) {
|
|
302
|
+
var tools = toolsValue.split(" ");
|
|
303
|
+
var toolGroups = toolsValue.split(" | ");
|
|
304
|
+
|
|
305
|
+
var addTools = function (ownerElement, tools) {
|
|
306
|
+
$.each(tools, function (index, value) {
|
|
307
|
+
var tool = that.commands[this];
|
|
308
|
+
if (!tool) {
|
|
309
|
+
if (that.createCommand) {
|
|
310
|
+
tool = that.createCommand(this.toString());
|
|
311
|
+
if (!tool) {
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
if (!that.commands[this]) {
|
|
315
|
+
that.commands[this] = tool;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (that.createCommand) {
|
|
323
|
+
var toolExt = that.createCommand(this.toString());
|
|
324
|
+
tool = $.extend(tool, toolExt);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
if (that.localization[this]) {
|
|
328
|
+
tool.tooltip = that.localization[this];
|
|
329
|
+
}
|
|
330
|
+
switch (tool.type) {
|
|
331
|
+
case 'list':
|
|
332
|
+
if (tool.widget) {
|
|
333
|
+
tool.widget.jqxDropDownList('destroy');
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
var rendererFunc = function (index, label, value) {
|
|
337
|
+
if (tool.command == "formatblock") {
|
|
338
|
+
return '<' + value + ' unselectable="on" style="padding: 0px; margin: 0px;">' + label + '</' + value + '>';
|
|
339
|
+
}
|
|
340
|
+
else if (tool.command == "fontname") {
|
|
341
|
+
return '<span unselectable="on" style="font-family: ' + value + ';">' + label + '<span>';
|
|
342
|
+
}
|
|
343
|
+
else if (tool.command == "fontsize") {
|
|
344
|
+
return '<span unselectable="on" style="font-size: ' + value + ';">' + label + '<span>';
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
var selectionRendererFunc = function () {
|
|
348
|
+
var iconClass = that.toThemeProperty('jqx-editor-toolbar-icon') + " " + that.toThemeProperty('jqx-editor-toolbar-icon-' + tool.command);
|
|
349
|
+
var icon = "<div unselectable='on' style='margin-top: 0px; padding:0px;' class='" + iconClass + "'></div>";
|
|
350
|
+
return icon;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
var fontRelated = tool.command == "formatblock" || tool.command == "fontname" || tool.command == "fontsize";
|
|
354
|
+
|
|
355
|
+
var dataValue = tool.value || [];
|
|
356
|
+
var dataSource = new Array();
|
|
357
|
+
var placeHolder = tool.placeHolder || "Please Choose:";
|
|
358
|
+
|
|
359
|
+
if (tool.command == "fontname") {
|
|
360
|
+
$.each(dataValue, function () {
|
|
361
|
+
var label = that.localization[this.label];
|
|
362
|
+
dataSource.push({ label: label, value: this.value });
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
else if (tool.command == "formatblock") {
|
|
366
|
+
placeHolder = that.localization["format"];
|
|
367
|
+
$.each(dataValue, function () {
|
|
368
|
+
if (this.label.indexOf("Header") >= 0) {
|
|
369
|
+
var label = this.label.replace("Header", that.localization["Header"]);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
var label = that.localization[this.label];
|
|
373
|
+
}
|
|
374
|
+
dataSource.push({ label: label, value: this.value });
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
dataSource = dataValue;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
var settings = {
|
|
382
|
+
enableBrowserBoundsDetection: true,
|
|
383
|
+
touchMode: that.touchMode,
|
|
384
|
+
width: tool.width || 100,
|
|
385
|
+
height: tool.height || 25,
|
|
386
|
+
dropDownWidth: tool.dropDownWidth || 'auto',
|
|
387
|
+
autoDropDownHeight: (tool.value && tool.value.length) < 12 ? true : false,
|
|
388
|
+
placeHolder: placeHolder,
|
|
389
|
+
source: dataSource,
|
|
390
|
+
theme: that.theme,
|
|
391
|
+
hint: false,
|
|
392
|
+
keyboardSelection: false,
|
|
393
|
+
focusable: false,
|
|
394
|
+
disabled: that.disabled,
|
|
395
|
+
rtl: that.rtl,
|
|
396
|
+
selectionRenderer: tool.command == "fontsize" ? selectionRendererFunc : null,
|
|
397
|
+
renderer: fontRelated ? rendererFunc : null
|
|
398
|
+
}
|
|
399
|
+
var listClass = 'jqx-disableselect ' + that.toThemeProperty('jqx-editor-dropdownlist') + " " + that.toThemeProperty('jqx-editor-toolbar-item');
|
|
400
|
+
var widget = $("<div unselectable='on' class='" + listClass + "'></div>");
|
|
401
|
+
widget.appendTo(ownerElement);
|
|
402
|
+
widget.jqxDropDownList(settings);
|
|
403
|
+
if (tool.init) {
|
|
404
|
+
tool.init(widget);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
var value = null;
|
|
408
|
+
var newValue = null;
|
|
409
|
+
var closeType = "";
|
|
410
|
+
that.addHandler(widget, "mousedown", function (event) {
|
|
411
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
412
|
+
$('.jqx-editor-dropdownpicker').jqxDropDownButton('close');
|
|
413
|
+
}
|
|
414
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
415
|
+
var lists = $('.jqx-editor-dropdownlist');
|
|
416
|
+
$.each(lists, function (index, value) {
|
|
417
|
+
if (value != widget[0]) {
|
|
418
|
+
$(value).jqxDropDownList('close');
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
that.addHandler(widget, "open", function (event) {
|
|
425
|
+
if (!that.focused) {
|
|
426
|
+
that.focus();
|
|
427
|
+
}
|
|
428
|
+
that.updating = true;
|
|
429
|
+
that.activeElement = widget;
|
|
430
|
+
value = widget.val();
|
|
431
|
+
closeType = "";
|
|
432
|
+
});
|
|
433
|
+
that.addHandler(widget, "change", function (event) {
|
|
434
|
+
that.updating = false;
|
|
435
|
+
that.activeElement = null;
|
|
436
|
+
newValue = widget.val();
|
|
437
|
+
closeType = event.args.type;
|
|
438
|
+
if ($.jqx.browser.msie && $.jqx.browser.version < 9) {
|
|
439
|
+
that.focus();
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
that.addHandler(widget, "close", function (event) {
|
|
443
|
+
that.updating = false;
|
|
444
|
+
that.activeElement = null;
|
|
445
|
+
|
|
446
|
+
if (value != newValue) {
|
|
447
|
+
if (closeType == "mouse" || closeType == "keyboard") {
|
|
448
|
+
that._refreshTools();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
that._addCommandHandler(widget, 'change', tool.command, null, tool);
|
|
453
|
+
break;
|
|
454
|
+
case 'colorPicker':
|
|
455
|
+
if (tool.widget) {
|
|
456
|
+
$(tool.colorPicker).remove();
|
|
457
|
+
tool.widget.jqxDropDownButton('destroy');
|
|
458
|
+
}
|
|
459
|
+
var picker = $('<div unselectable="on" style="padding-top: 4px;"></div>').attr('id', 'picker-' + tool.command);
|
|
460
|
+
var listClass = 'jqx-disableselect ' + that.toThemeProperty('jqx-editor-dropdownpicker') + " " + that.toThemeProperty('jqx-editor-toolbar-item');
|
|
461
|
+
var widget = $("<div unselectable='on' class='" + listClass + "'></div>");
|
|
462
|
+
widget.appendTo(ownerElement);
|
|
463
|
+
widget.append(picker);
|
|
464
|
+
widget.jqxDropDownButton({
|
|
465
|
+
hint: false,
|
|
466
|
+
touchMode: that.touchMode,
|
|
467
|
+
disabled: that.disabled,
|
|
468
|
+
enableBrowserBoundsDetection: true,
|
|
469
|
+
width: tool.width || 45,
|
|
470
|
+
height: tool.height || 25,
|
|
471
|
+
rtl: that.rtl,
|
|
472
|
+
focusable: false,
|
|
473
|
+
theme: that.theme
|
|
474
|
+
});
|
|
475
|
+
var content = $('<div unselectable="on" style="z-index: 55;">');
|
|
476
|
+
var iconClass = that.toThemeProperty('jqx-editor-toolbar-icon') + " " + that.toThemeProperty('jqx-editor-toolbar-icon-' + tool.command);
|
|
477
|
+
var icon = $("<div unselectable='on' class='" + iconClass + "'></div>");
|
|
478
|
+
content.append(icon);
|
|
479
|
+
var bar = $('<div unselectable="on" class="jqx-editor-color-bar">').attr('id', 'bar-' + tool.command).css('background-color', tool.value);
|
|
480
|
+
content.append(bar);
|
|
481
|
+
widget.jqxDropDownButton('setContent', content);
|
|
482
|
+
picker.append($(that.colorPickerTemplate));
|
|
483
|
+
tool.colorPicker = picker;
|
|
484
|
+
if (tool.init) {
|
|
485
|
+
tool.init(widget);
|
|
486
|
+
}
|
|
487
|
+
picker.find('tr').attr('role', 'row').attr('unselectable', 'on');
|
|
488
|
+
picker.find('td').attr('role', 'gridcell').attr('unselectable', 'on').css('-webkit-user-select', 'none');
|
|
489
|
+
picker.find('div').attr('unselectable', 'on');
|
|
490
|
+
|
|
491
|
+
that.addHandler(widget, "mousedown", function (event) {
|
|
492
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
493
|
+
$('.jqx-editor-dropdownlist').jqxDropDownList('close');
|
|
494
|
+
}
|
|
495
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
496
|
+
var lists = $('.jqx-editor-dropdownpicker');
|
|
497
|
+
$.each(lists, function (index, value) {
|
|
498
|
+
if (value != widget[0]) {
|
|
499
|
+
$(value).jqxDropDownButton('close');
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
that.addHandler(widget, "open", function () {
|
|
506
|
+
if (!that.focused) {
|
|
507
|
+
that.focus();
|
|
508
|
+
}
|
|
509
|
+
that.updating = true;
|
|
510
|
+
that.activeElement = picker;
|
|
511
|
+
});
|
|
512
|
+
that.addHandler(widget, "close", function (event) {
|
|
513
|
+
that.updating = false;
|
|
514
|
+
that.activeElement = null;
|
|
515
|
+
if (value != newValue) {
|
|
516
|
+
if (closeType == "mouse" || closeType == "keyboard") {
|
|
517
|
+
that._refreshTools();
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
that.addHandler(picker, "keydown", function (event) {
|
|
522
|
+
var key = event.keyCode;
|
|
523
|
+
var activeColor = $(picker).find('.jqx-editor-color-picker-selected-cell');
|
|
524
|
+
var rows = picker.find('tr');
|
|
525
|
+
var rowsCount = rows.length;
|
|
526
|
+
var columnsCount = activeColor.parent().children().length;
|
|
527
|
+
var columnIndex = activeColor.index();
|
|
528
|
+
var rowIndex = -999;
|
|
529
|
+
var row = activeColor.parent();
|
|
530
|
+
$.each(rows, function (index, value) {
|
|
531
|
+
if (this == row[0]) {
|
|
532
|
+
rowIndex = index;
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
switch (key) {
|
|
538
|
+
case 27: // esc
|
|
539
|
+
widget.jqxDropDownButton('close');
|
|
540
|
+
break;
|
|
541
|
+
case 13: // esc
|
|
542
|
+
$(activeColor).trigger('mousedown');
|
|
543
|
+
break;
|
|
544
|
+
case 38: // up
|
|
545
|
+
rowIndex--;
|
|
546
|
+
break;
|
|
547
|
+
case 40: // down
|
|
548
|
+
rowIndex++;
|
|
549
|
+
break;
|
|
550
|
+
case 39: // right
|
|
551
|
+
columnIndex++;
|
|
552
|
+
break;
|
|
553
|
+
case 37: // left
|
|
554
|
+
columnIndex--;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
if (rowIndex >= 0 && rowIndex <= rowsCount) {
|
|
558
|
+
if (columnIndex >= 0 && columnIndex <= columnsCount) {
|
|
559
|
+
var row = picker.find('tr')[rowIndex];
|
|
560
|
+
var cell = $(row).children()[columnIndex];
|
|
561
|
+
var color = $(cell).children().css('background-color');
|
|
562
|
+
tool.val(color);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
});
|
|
567
|
+
var pickerColors = $(picker).find('td');
|
|
568
|
+
|
|
569
|
+
tool.val = function (color) {
|
|
570
|
+
var hexColor = that._rgbToHex(color);
|
|
571
|
+
$.each(pickerColors, function () {
|
|
572
|
+
var color = $(this).children().css('background-color');
|
|
573
|
+
var pickerColor = that._rgbToHex(color);
|
|
574
|
+
if (pickerColor == hexColor) {
|
|
575
|
+
pickerColors.removeClass('jqx-editor-color-picker-selected-cell');
|
|
576
|
+
$(this).addClass('jqx-editor-color-picker-selected-cell');
|
|
577
|
+
$('#bar-' + tool.command).css('background', color);
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
tool.val(tool.value);
|
|
583
|
+
that._addCommandHandler(pickerColors, 'mousedown', tool.command, null, tool);
|
|
584
|
+
break;
|
|
585
|
+
case "button":
|
|
586
|
+
case "toggleButton":
|
|
587
|
+
default:
|
|
588
|
+
if (tool.widget) {
|
|
589
|
+
if (tool.type == "button") {
|
|
590
|
+
tool.widget.jqxButton('destroy');
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
tool.widget.jqxToggleButton('destroy');
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
var command = tool.command;
|
|
598
|
+
var action = tool.action;
|
|
599
|
+
var iconClass = that.toThemeProperty('jqx-editor-toolbar-icon') + " " + that.toThemeProperty('jqx-editor-toolbar-icon-' + command);
|
|
600
|
+
var icon = $("<div unselectable='on' class='" + iconClass + "'></div>");
|
|
601
|
+
var widget = $("<div unselectable='on'></div>").addClass('jqx-disableselect').addClass(that.toThemeProperty('jqx-editor-toolbar-button'));
|
|
602
|
+
if (!tool.init) {
|
|
603
|
+
widget.append(icon);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
if (command) {
|
|
607
|
+
widget.append(icon);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
widget.appendTo(ownerElement);
|
|
612
|
+
if (tool.type == "button") {
|
|
613
|
+
widget.jqxButton({
|
|
614
|
+
disabled: that.disabled,
|
|
615
|
+
rtl: that.rtl,
|
|
616
|
+
theme: that.theme
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
else if (tool.type == "toggleButton") {
|
|
620
|
+
widget.jqxToggleButton({
|
|
621
|
+
disabled: that.disabled,
|
|
622
|
+
rtl: that.rtl,
|
|
623
|
+
uiToggle: false,
|
|
624
|
+
theme: that.theme
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
if (tool.init) {
|
|
629
|
+
tool.init(widget);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
tool.toggled = false;
|
|
633
|
+
tool.toggle = function () {
|
|
634
|
+
tool.toggled = !tool.toggled;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
that.addHandler(widget, 'mousedown', function (event) {
|
|
638
|
+
if (event.preventDefault) {
|
|
639
|
+
event.preventDefault();
|
|
640
|
+
}
|
|
641
|
+
if (event.stopPropagation) {
|
|
642
|
+
event.stopPropagation();
|
|
643
|
+
}
|
|
644
|
+
return false;
|
|
645
|
+
});
|
|
646
|
+
if (!$.jqx.mobile.isTouchDevice()) {
|
|
647
|
+
that._addCommandHandler(widget, 'click', command, action, tool);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
that._addCommandHandler(widget, 'mousedown', command, action, tool);
|
|
651
|
+
}
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
tool.widget = widget;
|
|
656
|
+
if (widget) {
|
|
657
|
+
try {
|
|
658
|
+
if (tool.tooltip != "") {
|
|
659
|
+
tool.widget.attr('title', tool.tooltip);
|
|
660
|
+
tool.widget.attr('data-tooltip', tool.tooltip);
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
if (tool.command) {
|
|
664
|
+
tool.widget.attr('data-command', tool.command);
|
|
665
|
+
}
|
|
666
|
+
tool.widget.attr('aria-label', tool.tooltip);
|
|
667
|
+
}
|
|
668
|
+
catch (error) {
|
|
669
|
+
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
if (tool.type == "button" || tool.type == "toggleButton") {
|
|
673
|
+
if (tools.length > 2) {
|
|
674
|
+
if (index == 0) {
|
|
675
|
+
widget.css('border-right-radius', '0px');
|
|
676
|
+
widget.addClass(that.toThemeProperty('jqx-rc-l'));
|
|
677
|
+
}
|
|
678
|
+
else if (index == tools.length - 1) {
|
|
679
|
+
widget.css('border-left-radius', '0px');
|
|
680
|
+
widget.addClass(that.toThemeProperty('jqx-rc-r'));
|
|
681
|
+
}
|
|
682
|
+
widget.removeClass(that.toThemeProperty('jqx-rc-all'));
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
if (index != 0 && index != tools.length - 1 && tools.length > 2) {
|
|
686
|
+
widget.css('border-left-radius', '0px');
|
|
687
|
+
widget.css('border-right-radius', '0px');
|
|
688
|
+
widget.removeClass(that.toThemeProperty('jqx-rc-all'));
|
|
689
|
+
}
|
|
690
|
+
else if (tools.length == 2) {
|
|
691
|
+
if (index == 0) {
|
|
692
|
+
widget.css('border-right-radius', '0px');
|
|
693
|
+
widget.addClass(that.toThemeProperty('jqx-rc-l'));
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
widget.css('border-left-radius', '0px');
|
|
697
|
+
widget.addClass(that.toThemeProperty('jqx-rc-r'));
|
|
698
|
+
}
|
|
699
|
+
widget.removeClass(that.toThemeProperty('jqx-rc-all'));
|
|
700
|
+
}
|
|
701
|
+
else if (tools.length == 1) {
|
|
702
|
+
widget.css('margin-right', '0px');
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
that.toolbar.css('direction', !this.rtl ? 'ltr' : 'rtl');
|
|
710
|
+
|
|
711
|
+
if (toolGroups.length == 0) {
|
|
712
|
+
addTools(that.toolbar, tools);
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
for (var i = 0; i < toolGroups.length; i++) {
|
|
716
|
+
var toolGroup = toolGroups[i];
|
|
717
|
+
var tools = toolGroup.split(" ");
|
|
718
|
+
var groupClass = that.toThemeProperty('jqx-editor-toolbar-group') + " " + that.toThemeProperty('jqx-fill-state-normal');
|
|
719
|
+
var ownerElement = $("<div class='" + groupClass + "'></div>");
|
|
720
|
+
ownerElement.addClass(that.toThemeProperty('jqx-rc-all'));
|
|
721
|
+
that.toolbar.append(ownerElement);
|
|
722
|
+
addTools(ownerElement, tools);
|
|
723
|
+
}
|
|
724
|
+
var groups = that.toolbar.find('.jqx-editor-toolbar-group')
|
|
725
|
+
var groupsLength = groups.length;
|
|
726
|
+
for (var i = 0; i < groupsLength; i++) {
|
|
727
|
+
if ($(groups[i]).children().length == 0) {
|
|
728
|
+
$(groups[i]).remove();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
if ($.jqx.browser.msie && $.jqx.browser.version < 8) {
|
|
733
|
+
$(".jqx-editor-toolbar-group").css('float', 'left');
|
|
734
|
+
$(".jqx-editor-toolbar-group").children().css('float', 'left');
|
|
735
|
+
$(".jqx-editor-toolbar-group").css('zoom', '1');
|
|
736
|
+
$(".jqx-editor-toolbar-group").children().css('zoom', '1');
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
that._arrange();
|
|
741
|
+
that._addHandlers();
|
|
742
|
+
},
|
|
743
|
+
|
|
744
|
+
_arrange: function () {
|
|
745
|
+
var that = this;
|
|
746
|
+
if (that.content) {
|
|
747
|
+
if (that.tools == "" || that.tools == false) {
|
|
748
|
+
that.content.height(that.container.outerHeight() - parseInt(that.container.css('padding-top')) - parseInt(that.container.css('padding-bottom')) - 6);
|
|
749
|
+
that.content.css('margin-top', '4px');
|
|
750
|
+
that.toolbar.hide();
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
that.toolbar.show();
|
|
754
|
+
that.content.css('margin-top', '0px');
|
|
755
|
+
that.content.height(that.container.outerHeight() - that.toolbar.outerHeight() - parseInt(that.container.css('padding-top')) - parseInt(that.container.css('padding-bottom')) - 2);
|
|
756
|
+
if (that.toolbarPosition != "top") {
|
|
757
|
+
that.content.css('margin-top', '4px');
|
|
758
|
+
that.content.css('margin-bottom', '0px');
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if ($.jqx.browser.msie && $.jqx.browser.version < 8) {
|
|
762
|
+
that.content.css('margin-top', '4px');
|
|
763
|
+
that.content.height(that.container.height() - that.toolbar.outerHeight() - 2 * parseInt(that.container.css('padding-bottom')) - 10);
|
|
764
|
+
that.content.width(that.container.width() - 2 * parseInt(that.container.css('padding-left')) - 2);
|
|
765
|
+
}
|
|
766
|
+
if (that.editor.height() < that.content.height()) {
|
|
767
|
+
that.editor.height(that.content.height());
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
},
|
|
771
|
+
|
|
772
|
+
propertyChangedHandler: function (object, key, oldvalue, value) {
|
|
773
|
+
var that = object;
|
|
774
|
+
if (that.isInitialized == undefined || that.isInitialized == false)
|
|
775
|
+
return;
|
|
776
|
+
|
|
777
|
+
if (key == "pasteMode" || key == "lineBreak" || key == "editable") {
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
if (key == "disabled") {
|
|
782
|
+
object._refreshTools();
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
if (key == "width" || key == "height" || key == "toolbarPosition") {
|
|
786
|
+
object._arrange();
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
if (key == "theme") {
|
|
791
|
+
$.jqx.utilities.setTheme(oldvalue, value, object.host);
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
object.refresh();
|
|
795
|
+
},
|
|
796
|
+
|
|
797
|
+
selectRange: function (range) {
|
|
798
|
+
var that = this;
|
|
799
|
+
if (!range) range = that.getRange();
|
|
800
|
+
that.selection.selectRange(range);
|
|
801
|
+
},
|
|
802
|
+
|
|
803
|
+
getRange: function () {
|
|
804
|
+
var that = this;
|
|
805
|
+
return that.selection.getRange();
|
|
806
|
+
},
|
|
807
|
+
|
|
808
|
+
getSelectedElement: function () {
|
|
809
|
+
var range, root, start, end;
|
|
810
|
+
var that = this;
|
|
811
|
+
try {
|
|
812
|
+
if (that.editorDocument.getSelection) {
|
|
813
|
+
var selection = that.editorDocument.getSelection();
|
|
814
|
+
range = selection.getRangeAt(selection.rangeCount - 1);
|
|
815
|
+
start = range.startContainer;
|
|
816
|
+
end = range.endContainer;
|
|
817
|
+
root = range.commonAncestorContainer;
|
|
818
|
+
if (start.nodeName == "#text") root = root.parentNode;
|
|
819
|
+
if (start.nodeName == "#text") start = start.parentNode;
|
|
820
|
+
if (start.nodeName.toLowerCase() == "body") start = start.firstChild;
|
|
821
|
+
if (end.nodeName == "#text") end = end.parentNode;
|
|
822
|
+
if (end.nodeName.toLowerCase() == "body") end = end.lastChild;
|
|
823
|
+
if (start == end) root = start;
|
|
824
|
+
|
|
825
|
+
return end;
|
|
826
|
+
} else if (that.editorDocument.selection) {
|
|
827
|
+
range = that.editorDocument.selection.createRange()
|
|
828
|
+
if (!range.duplicate) return null;
|
|
829
|
+
root = range.parentElement();
|
|
830
|
+
var r1 = range.duplicate();
|
|
831
|
+
var r2 = range.duplicate();
|
|
832
|
+
r1.collapse(true);
|
|
833
|
+
r2.moveToElementText(r1.parentElement());
|
|
834
|
+
r2.setEndPoint("EndToStart", r1);
|
|
835
|
+
start = r1.parentElement();
|
|
836
|
+
r1 = range.duplicate();
|
|
837
|
+
r2 = range.duplicate();
|
|
838
|
+
r2.collapse(false);
|
|
839
|
+
r1.moveToElementText(r2.parentElement());
|
|
840
|
+
r1.setEndPoint("StartToEnd", r2);
|
|
841
|
+
end = r2.parentElement();
|
|
842
|
+
if (start.nodeName.toLowerCase() == "body") start = start.firstChild;
|
|
843
|
+
if (end.nodeName.toLowerCase() == "body") end = end.lastChild;
|
|
844
|
+
|
|
845
|
+
if (start == end) root = start;
|
|
846
|
+
return end;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
catch (error) {
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return null;
|
|
854
|
+
},
|
|
855
|
+
|
|
856
|
+
val: function (value) {
|
|
857
|
+
if (value != undefined && typeof value != 'object') {
|
|
858
|
+
this.editor.html(value)
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
if (this._documentMode === "source") {
|
|
863
|
+
return this.editor.find('pre:first').html();
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
return this.editor.html();
|
|
867
|
+
},
|
|
868
|
+
|
|
869
|
+
_addHandlers: function () {
|
|
870
|
+
var that = this;
|
|
871
|
+
that.addHandler(that.toolbar, "mousedown.editor" + that.element.id, function (event) {
|
|
872
|
+
if (event.preventDefault)
|
|
873
|
+
event.preventDefault();
|
|
874
|
+
if (event.stopPropagation)
|
|
875
|
+
event.stopPropagation();
|
|
876
|
+
|
|
877
|
+
return false;
|
|
878
|
+
});
|
|
879
|
+
|
|
880
|
+
var blur = function () {
|
|
881
|
+
if (that._textArea) {
|
|
882
|
+
if (!that.updating) {
|
|
883
|
+
that._textArea.value = that.val();
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
if (that.changed) {
|
|
888
|
+
that._raiseEvent("change");
|
|
889
|
+
that.changed = false;
|
|
890
|
+
}
|
|
891
|
+
that.focused = false;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
var focus = function () {
|
|
895
|
+
that.focused = true;
|
|
896
|
+
if (that.inline) {
|
|
897
|
+
that.host.addClass(that.toThemeProperty('jqx-fill-state-focus'));
|
|
898
|
+
that.host.addClass(that.toThemeProperty('jqx-editor-inline-focus'));
|
|
899
|
+
that.host.addClass(that.toThemeProperty('jqx-rc-all'));
|
|
900
|
+
if (that.tools == "" || that.tools == null)
|
|
901
|
+
return;
|
|
902
|
+
that.toolbarContainer.fadeIn('fast');
|
|
903
|
+
var location = that.host.coord();
|
|
904
|
+
if (that.toolbarPosition != "bottom") {
|
|
905
|
+
that.toolbarContainer.offset({ left: location.left, top: location.top - that.toolbarContainer.outerHeight() - 5 });
|
|
906
|
+
}
|
|
907
|
+
else {
|
|
908
|
+
that.toolbarContainer.offset({ left: location.left, top: location.top + 5 + that.host.height() });
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
if ($.jqx.browser.mozilla) {
|
|
914
|
+
this.addHandler($(document), "mousedown.editor" + that.element.id, function (event) {
|
|
915
|
+
blur();
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
that.addHandler(that.editor, "blur.editor" + that.element.id, function (event) {
|
|
920
|
+
blur();
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
that.addHandler(that.editor, "focus.editor" + that.element.id, function (event) {
|
|
924
|
+
focus();
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
that.addHandler(that.editor, "beforedeactivate.editor" + that.element.id, function (event) {
|
|
928
|
+
that.range = that.getRange();
|
|
929
|
+
});
|
|
930
|
+
|
|
931
|
+
that.addHandler(that.editor, "mousedown.editor" + that.element.id, function (event) {
|
|
932
|
+
if (!event.target.href) {
|
|
933
|
+
if (that.linkPopup) that.linkPopup.remove();
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
that.range = that.getRange();
|
|
937
|
+
if ($.jqx.browser.mozilla) {
|
|
938
|
+
focus();
|
|
939
|
+
event.stopPropagation();
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
943
|
+
$('.jqx-editor-dropdownpicker').jqxDropDownButton('close');
|
|
944
|
+
}
|
|
945
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
946
|
+
$('.jqx-editor-dropdownlist').jqxDropDownList('close');
|
|
947
|
+
}
|
|
948
|
+
if (that.inline) {
|
|
949
|
+
that.editor.focus();
|
|
950
|
+
}
|
|
951
|
+
});
|
|
952
|
+
if ($.jqx.mobile.isTouchDevice()) {
|
|
953
|
+
that.addHandler($(that.editorDocument), "selectionchange.editor" + that.element.id, function () {
|
|
954
|
+
if (that.editorDocument.activeElement != that.editor[0]) {
|
|
955
|
+
setTimeout(function () {
|
|
956
|
+
if (that.iframe) {
|
|
957
|
+
that.iframe[0].contentWindow.focus();
|
|
958
|
+
}
|
|
959
|
+
}, 500);
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
that.addHandler($(that.editorDocument), "touchstart.editor" + that.element.id, function () {
|
|
963
|
+
setTimeout(function () {
|
|
964
|
+
if (that.iframe) {
|
|
965
|
+
that.iframe[0].contentWindow.focus();
|
|
966
|
+
}
|
|
967
|
+
}, 500);
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
that.addHandler(that.editor, "mouseup.editor" + that.element.id, function (event) {
|
|
971
|
+
if (that._documentMode == "source")
|
|
972
|
+
return true;
|
|
973
|
+
|
|
974
|
+
that.range = that.getRange();
|
|
975
|
+
that._refreshTools(null, true);
|
|
976
|
+
});
|
|
977
|
+
that.addHandler(that.editor, "keydown.editor" + that.element.id, function (event) {
|
|
978
|
+
if (that.keyPressed) {
|
|
979
|
+
that.keyPressed(event);
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
if (that._documentMode == "source")
|
|
983
|
+
return true;
|
|
984
|
+
|
|
985
|
+
if ($.jqx.browser.mozilla) {
|
|
986
|
+
if (!that.focused) {
|
|
987
|
+
focus();
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
that.changeType = "keyboard";
|
|
992
|
+
|
|
993
|
+
if (that.disabled) {
|
|
994
|
+
if (event.preventDefault) {
|
|
995
|
+
event.preventDefault();
|
|
996
|
+
}
|
|
997
|
+
return false;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
if (that.updating) {
|
|
1001
|
+
if (that.activeElement) {
|
|
1002
|
+
var e = $.Event("keydown");
|
|
1003
|
+
$.extend(e, event);
|
|
1004
|
+
that.activeElement.trigger(e);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
if (event.preventDefault) {
|
|
1008
|
+
event.preventDefault();
|
|
1009
|
+
}
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
var ev = event || window.event;
|
|
1013
|
+
var key = ev.keyCode;
|
|
1014
|
+
var keyChar = String.fromCharCode(key).toLowerCase();
|
|
1015
|
+
|
|
1016
|
+
if (!that.editable) {
|
|
1017
|
+
var selectionCodes = [9, 33, 34, 35, 36, 37, 38, 39, 40, 40, 45];
|
|
1018
|
+
if ($.inArray(ev.keyCode, selectionCodes) == -1 && !(ev.ctrlKey && keyChar == "c") && !(ev.ctrlKey && keyChar == "a"))
|
|
1019
|
+
event.preventDefault();
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
if (that.selection.getText().length > 0 || that.linkPopup) {
|
|
1023
|
+
var selectionCodes = [8, 9, 13, 33, 34, 35, 36, 37, 38, 39, 40, 40, 45, 46];
|
|
1024
|
+
|
|
1025
|
+
if (!$.inArray(ev.keyCode, selectionCodes) != -1
|
|
1026
|
+
|| (ev.keyCode == 65 && ev.ctrlKey && !ev.altKey && !ev.shiftKey)) {
|
|
1027
|
+
if (that._refreshToolsTimer) clearTimeout(that._refreshToolsTimer);
|
|
1028
|
+
that._refreshToolsTimer = setTimeout(function () {
|
|
1029
|
+
that._refreshTools(null, true, ev.keyCode);
|
|
1030
|
+
}, 10);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (key == 13 && that.lineBreak != "default") {
|
|
1034
|
+
var selectedElement = that.getSelectedElement();
|
|
1035
|
+
if (selectedElement) {
|
|
1036
|
+
var nodeName = selectedElement.nodeName.toLowerCase();
|
|
1037
|
+
switch (nodeName) {
|
|
1038
|
+
case "pre":
|
|
1039
|
+
case "li":
|
|
1040
|
+
case "ul":
|
|
1041
|
+
case "ol":
|
|
1042
|
+
case "h1":
|
|
1043
|
+
case "h2":
|
|
1044
|
+
case "h3":
|
|
1045
|
+
case "h4":
|
|
1046
|
+
case "h5":
|
|
1047
|
+
case "h6":
|
|
1048
|
+
return true;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
var parent = selectedElement;
|
|
1052
|
+
while (parent != null) {
|
|
1053
|
+
if (parent.nodeName == "#document") {
|
|
1054
|
+
parent = that.editorDocument.body;
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1057
|
+
if (parent.parentNode == that.editorDocument.body || parent == that.editorDocument.body)
|
|
1058
|
+
break;
|
|
1059
|
+
|
|
1060
|
+
parent = parent.parentNode;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (parent) {
|
|
1064
|
+
var range = that.getRange();
|
|
1065
|
+
if (that.editorDocument.body.innerHTML == "<div></div>" && that.lineBreak != "br") {
|
|
1066
|
+
that.selection.insertContent("​");
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
if (that.lineBreak == "div") {
|
|
1070
|
+
if (parent == that.editorDocument.body) {
|
|
1071
|
+
$(parent).append("<div>​</div>" + "<span id='INSERTION_MARKER'> </span>");
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
$("<div>​</div>" + "<span id='INSERTION_MARKER'> </span>").insertAfter(parent);
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
else if (that.lineBreak == "p") {
|
|
1078
|
+
if (parent == that.editorDocument.body) {
|
|
1079
|
+
$(parent).append("<p>​</p>" + "<span id='INSERTION_MARKER'> </span>");
|
|
1080
|
+
}
|
|
1081
|
+
else {
|
|
1082
|
+
$("<p>​</p>" + "<span id='INSERTION_MARKER'> </span>").insertAfter(parent);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
that.execute("insertHTML", "<br/>​" + "<span id='INSERTION_MARKER'> </span>");
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
that.selectRange(range);
|
|
1090
|
+
var marker = $(that.editorDocument).find("#INSERTION_MARKER");
|
|
1091
|
+
if (that.lineBreak != "br") {
|
|
1092
|
+
that.selection.selectNode($(marker).prev()[0], true);
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
that.selection.selectNode(marker[0], true);
|
|
1096
|
+
if (that.getRange().setStartAfter) {
|
|
1097
|
+
that.getRange().setStartAfter(marker[0]);
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
marker.remove();
|
|
1102
|
+
that.selection.collapse(false);
|
|
1103
|
+
|
|
1104
|
+
if (parent && parent.nodeName && that.lineBreak == "br") {
|
|
1105
|
+
if (parent.nodeName.toLowerCase() != "#text") {
|
|
1106
|
+
that.selection.selectNode(parent, true);
|
|
1107
|
+
if (that.getRange().setStartAfter) {
|
|
1108
|
+
that.getRange().setStartAfter(parent);
|
|
1109
|
+
}
|
|
1110
|
+
that.selection.collapse(false);
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
|
|
1114
|
+
if (that.lineBreak != "br") {
|
|
1115
|
+
range = that.getRange();
|
|
1116
|
+
if (range.select) {
|
|
1117
|
+
range.select();
|
|
1118
|
+
}
|
|
1119
|
+
}
|
|
1120
|
+
if (event.preventDefault) {
|
|
1121
|
+
event.preventDefault();
|
|
1122
|
+
}
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
if (ev.ctrlKey && (keyChar == "k" || keyChar == "u" || keyChar == "b" || keyChar == "i")) {
|
|
1127
|
+
if (event.preventDefault) {
|
|
1128
|
+
event.preventDefault();
|
|
1129
|
+
}
|
|
1130
|
+
var command = null;
|
|
1131
|
+
switch (keyChar) {
|
|
1132
|
+
case "k":
|
|
1133
|
+
command = 'link';
|
|
1134
|
+
break;
|
|
1135
|
+
case "u":
|
|
1136
|
+
command = 'underline';
|
|
1137
|
+
break;
|
|
1138
|
+
case "b":
|
|
1139
|
+
command = 'bold';
|
|
1140
|
+
break;
|
|
1141
|
+
case "i":
|
|
1142
|
+
command = 'italic';
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
if (that.commands[command].widget) {
|
|
1146
|
+
that.commands[command].widget.trigger('click');
|
|
1147
|
+
}
|
|
1148
|
+
return false;
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
|
|
1152
|
+
|
|
1153
|
+
that.addHandler(that.editor, "paste.editor" + that.element.id, function (event) {
|
|
1154
|
+
if (that._documentMode == "source")
|
|
1155
|
+
return true;
|
|
1156
|
+
|
|
1157
|
+
if (that.readOnly)
|
|
1158
|
+
return true;
|
|
1159
|
+
|
|
1160
|
+
that.updating = true;
|
|
1161
|
+
that.readOnly = true;
|
|
1162
|
+
|
|
1163
|
+
var e = event;
|
|
1164
|
+
try {
|
|
1165
|
+
var cleanHtml = function (html, plain) {
|
|
1166
|
+
if (plain) {
|
|
1167
|
+
if (!that.paragraphise) {
|
|
1168
|
+
html = html.replace(/\n/g, "<br />");
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
html = "<p>" + html + "<\/p>";
|
|
1172
|
+
html = html.replace(/\n/g, "<\/p><p>");
|
|
1173
|
+
html = html.replace(/<p>\s<\/p>/gi, '');
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
else {
|
|
1177
|
+
// remove body and html tag
|
|
1178
|
+
html = html.replace(/<html[^>]*?>(.*)/gim, "$1");
|
|
1179
|
+
html = html.replace(/<\/html>/gi, '');
|
|
1180
|
+
html = html.replace(/<body[^>]*?>(.*)/gi, "$1");
|
|
1181
|
+
html = html.replace(/<\/body>/gi, '');
|
|
1182
|
+
|
|
1183
|
+
// remove style, meta and link tags
|
|
1184
|
+
html = html.replace(/<style[^>]*?>[\s\S]*?<\/style[^>]*>/gi, '');
|
|
1185
|
+
html = html.replace(/<(?:meta|link)[^>]*>\s*/gi, '');
|
|
1186
|
+
|
|
1187
|
+
// remove XML elements and declarations
|
|
1188
|
+
html = html.replace(/<\\?\?xml[^>]*>/gi, '');
|
|
1189
|
+
|
|
1190
|
+
// remove w: tags with contents.
|
|
1191
|
+
html = html.replace(/<w:[^>]*>[\s\S]*?<\/w:[^>]*>/gi, '');
|
|
1192
|
+
|
|
1193
|
+
// remove tags with XML namespace declarations: <o:p><\/o:p>
|
|
1194
|
+
html = html.replace(/<o:p>\s*<\/o:p>/g, '');
|
|
1195
|
+
html = html.replace(/<o:p>[\s\S]*?<\/o:p>/g, ' ');
|
|
1196
|
+
html = html.replace(/<\/?\w+:[^>]*>/gi, '');
|
|
1197
|
+
|
|
1198
|
+
// remove comments [SF BUG-1481861].
|
|
1199
|
+
html = html.replace(/<\!--[\s\S]*?-->/g, '');
|
|
1200
|
+
html = html.replace(/<\!\[[\s\S]*?\]>/g, '');
|
|
1201
|
+
|
|
1202
|
+
// remove mso-xxx styles.
|
|
1203
|
+
html = html.replace(/\s*mso-[^:]+:[^;"']+;?/gi, '');
|
|
1204
|
+
|
|
1205
|
+
// remove styles.
|
|
1206
|
+
html = html.replace(/<(\w[^>]*) style='([^\']*)'([^>]*)/gim, "<$1$3");
|
|
1207
|
+
html = html.replace(/<(\w[^>]*) style="([^\"]*)"([^>]*)/gim, "<$1$3");
|
|
1208
|
+
|
|
1209
|
+
// remove margin styles.
|
|
1210
|
+
html = html.replace(/\s*margin: 0cm 0cm 0pt\s*;/gi, '');
|
|
1211
|
+
html = html.replace(/\s*margin: 0cm 0cm 0pt\s*"/gi, "\"");
|
|
1212
|
+
|
|
1213
|
+
html = html.replace(/\s*text-indent: 0cm\s*;/gi, '');
|
|
1214
|
+
html = html.replace(/\s*text-indent: 0cm\s*"/gi, "\"");
|
|
1215
|
+
|
|
1216
|
+
html = html.replace(/\s*text-align: [^\s;]+;?"/gi, "\"");
|
|
1217
|
+
|
|
1218
|
+
html = html.replace(/\s*page-break-before: [^\s;]+;?"/gi, "\"");
|
|
1219
|
+
|
|
1220
|
+
html = html.replace(/\s*font-variant: [^\s;]+;?"/gi, "\"");
|
|
1221
|
+
|
|
1222
|
+
html = html.replace(/\s*tab-stops:[^;"']*;?/gi, '');
|
|
1223
|
+
html = html.replace(/\s*tab-stops:[^"']*/gi, '');
|
|
1224
|
+
|
|
1225
|
+
// remove font face attributes.
|
|
1226
|
+
html = html.replace(/\s*face="[^"']*"/gi, '');
|
|
1227
|
+
html = html.replace(/\s*face=[^ >]*/gi, '');
|
|
1228
|
+
|
|
1229
|
+
html = html.replace(/\s*font-family:[^;"']*;?/gi, '');
|
|
1230
|
+
html = html.replace(/\s*font-size:[^;"']*;?/gi, '');
|
|
1231
|
+
|
|
1232
|
+
// remove class attributes
|
|
1233
|
+
html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
|
|
1234
|
+
|
|
1235
|
+
// remove "display:none" attributes.
|
|
1236
|
+
html = html.replace(/<(\w+)[^>]*\sstyle="[^"']*display\s?:\s?none[\s \S]*?<\/\1>/ig, '');
|
|
1237
|
+
|
|
1238
|
+
// remove empty styles.
|
|
1239
|
+
html = html.replace(/\s*style='\s*'/gi, '');
|
|
1240
|
+
html = html.replace(/\s*style="\s*"/gi, '');
|
|
1241
|
+
|
|
1242
|
+
html = html.replace(/<span\s*[^>]*>\s* \s*<\/span>/gi, ' ');
|
|
1243
|
+
|
|
1244
|
+
html = html.replace(/<span\s*[^>]*><\/span>/gi, '');
|
|
1245
|
+
|
|
1246
|
+
// remove align attributes
|
|
1247
|
+
html = html.replace(/<(\w[^>]*) align=([^ |>]*)([^>]*)/gi, "<$1$3");
|
|
1248
|
+
|
|
1249
|
+
// remove lang attributes
|
|
1250
|
+
html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
|
|
1251
|
+
|
|
1252
|
+
html = html.replace(/<span([^>]*)>([\s\S]*?)<\/span>/gi, '$2');
|
|
1253
|
+
|
|
1254
|
+
html = html.replace(/<font\s*>([\s\S]*?)<\/font>/gi, '$1');
|
|
1255
|
+
|
|
1256
|
+
html = html.replace(/<(u|i|strike)> <\/\1>/gi, ' ');
|
|
1257
|
+
|
|
1258
|
+
html = html.replace(/<h\d>\s*<\/h\d>/gi, '');
|
|
1259
|
+
|
|
1260
|
+
// remove language attributes
|
|
1261
|
+
html = html.replace(/<(\w[^>]*) language=([^ |>]*)([^>]*)/gi, "<$1$3");
|
|
1262
|
+
|
|
1263
|
+
// remove onmouseover and onmouseout events (from MS word comments effect)
|
|
1264
|
+
html = html.replace(/<(\w[^>]*) onmouseover="([^\"']*)"([^>]*)/gi, "<$1$3");
|
|
1265
|
+
html = html.replace(/<(\w[^>]*) onmouseout="([^\"']*)"([^>]*)/gi, "<$1$3");
|
|
1266
|
+
|
|
1267
|
+
// the original <Hn> tag sent from word is something like this: <Hn style="margin-top:0px;margin-bottom:0px">
|
|
1268
|
+
html = html.replace(/<h(\d)([^>]*)>/gi, '<h$1>');
|
|
1269
|
+
|
|
1270
|
+
// word likes to insert extra <font> tags, when using IE. (Weird).
|
|
1271
|
+
html = html.replace(/<(h\d)><font[^>]*>([\s\S]*?)<\/font><\/\1>/gi, '<$1>$2<\/$1>');
|
|
1272
|
+
html = html.replace(/<(h\d)><em>([\s\S]*?)<\/em><\/\1>/gi, '<$1>$2<\/$1>');
|
|
1273
|
+
|
|
1274
|
+
// i -> em, b -> strong - doesn't match nested tags e.g <b><i>some text</i></b> - not possible in regexp
|
|
1275
|
+
html = html.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>');
|
|
1276
|
+
html = html.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi, '<em>$1</em>');
|
|
1277
|
+
|
|
1278
|
+
// remove "bad" tags
|
|
1279
|
+
html = html.replace(/<\s+[^>]*>/gi, '');
|
|
1280
|
+
|
|
1281
|
+
// remove empty <span>s (ie. no attributes, no reason for span in pasted text)
|
|
1282
|
+
// done twice for nested spans
|
|
1283
|
+
html = html.replace(/<span>([\s\S]*?)<\/span>/gi, '$1');
|
|
1284
|
+
html = html.replace(/<span>([\s\S]*?)<\/span>/gi, '$1');
|
|
1285
|
+
|
|
1286
|
+
// remove empty <div>s (see span)
|
|
1287
|
+
html = html.replace(/<div>([\s\S]*?)<\/div>/gi, '$1');
|
|
1288
|
+
html = html.replace(/<div>([\s\S]*?)<\/div>/gi, '$1');
|
|
1289
|
+
|
|
1290
|
+
// remove empty tags (three times, just to be sure - for nested empty tags).
|
|
1291
|
+
// This also removes any empty anchors
|
|
1292
|
+
html = html.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '');
|
|
1293
|
+
html = html.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '');
|
|
1294
|
+
html = html.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '');
|
|
1295
|
+
|
|
1296
|
+
if (html.trim) {
|
|
1297
|
+
html = html.trim();
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
// Convert <p> to <br />
|
|
1301
|
+
if (!that.paragraphise) {
|
|
1302
|
+
html.replace(/<p>/gi, '<br />');
|
|
1303
|
+
html.replace(/<\/p>/gi, '');
|
|
1304
|
+
}
|
|
1305
|
+
// Check if in paragraph - this fixes FF3.6 and it's <br id=""> issue
|
|
1306
|
+
else {
|
|
1307
|
+
var check = html.substr(0, 2);
|
|
1308
|
+
if ('<p' !== check) {
|
|
1309
|
+
html = '<p>' + html + '</p>';
|
|
1310
|
+
// Replace breaks with paragraphs
|
|
1311
|
+
html = html.replace(/\n/g, "<\/p><p>");
|
|
1312
|
+
html = html.replace(/<br[^>]*>/gi, '<\/p><p>');
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
// Make it valid xhtml
|
|
1317
|
+
html = html.replace(/<br>/gi, '<br />');
|
|
1318
|
+
|
|
1319
|
+
// remove <br>'s that end a paragraph here.
|
|
1320
|
+
html = html.replace(/<br[^>]*><\/p>/gim, '</p>');
|
|
1321
|
+
|
|
1322
|
+
// remove empty paragraphs - with just a (or whitespace) in (and tags again for good measure)
|
|
1323
|
+
html = html.replace(/<p> <\/p>/gi, '');
|
|
1324
|
+
html = html.replace(/<p>\s<\/p>/gi, '');
|
|
1325
|
+
html = html.replace(/<([^\s>]+)(\s[^>]*)?>\s*<\/\1>/g, '');
|
|
1326
|
+
|
|
1327
|
+
html = html.replace(/MsoNormal/gi, "");
|
|
1328
|
+
html = html.replace(/<\/?meta[^>]*>/gi, "");
|
|
1329
|
+
html = html.replace(/<\/?xml[^>]*>/gi, "");
|
|
1330
|
+
html = html.replace(/<\?xml[^>]*\/>/gi, "");
|
|
1331
|
+
html = html.replace(/<!--(.*)-->/gi, "");
|
|
1332
|
+
html = html.replace(/<!--(.*)>/gi, "");
|
|
1333
|
+
html = html.replace(/<!(.*)-->/gi, "");
|
|
1334
|
+
html = html.replace(/<w:[^>]*>(.*)<\/w:[^>]*>/gi, '');
|
|
1335
|
+
html = html.replace(/<w:[^>]*\/>/gi, '');
|
|
1336
|
+
html = html.replace(/<\/?w:[^>]*>/gi, "");
|
|
1337
|
+
html = html.replace(/<m:[^>]*\/>/gi, '');
|
|
1338
|
+
html = html.replace(/<m:[^>]>(.*)<\/m:[^>]*>/gi, '');
|
|
1339
|
+
html = html.replace(/<o:[^>]*>(.*)<\/o:[^>]*>/gi, '');
|
|
1340
|
+
html = html.replace(/<o:[^>]*\/>/gi, '');
|
|
1341
|
+
html = html.replace(/<\/?m:[^>]*>/gi, "");
|
|
1342
|
+
html = html.replace(/style=\"([^>]*)\"/gi, "");
|
|
1343
|
+
html = html.replace(/style=\'([^>]*)\'/gi, "");
|
|
1344
|
+
html = html.replace(/class=\"(.*)\"/gi, "");
|
|
1345
|
+
html = html.replace(/class=\'(.*)\'/gi, "");
|
|
1346
|
+
html = html.replace(/<b>/gi, '<strong>');
|
|
1347
|
+
html = html.replace(/<\/b>/gi, '<\/strong>');
|
|
1348
|
+
html = html.replace(/<p[^>]*>/gi, '<p>');
|
|
1349
|
+
html = html.replace(/<\/p[^>]*>/gi, '<\/p>');
|
|
1350
|
+
html = html.replace(/<span[^>]*>/gi, '');
|
|
1351
|
+
html = html.replace(/<\/span[^>]*>/gi, '');
|
|
1352
|
+
html = html.replace(/<st1:[^>]*>/gi, '');
|
|
1353
|
+
html = html.replace(/<\/st1:[^>]*>/gi, '');
|
|
1354
|
+
html = html.replace(/<font[^>]*>/gi, '');
|
|
1355
|
+
html = html.replace(/<\/font[^>]*>/gi, '');
|
|
1356
|
+
html = html.replace(' ', '');
|
|
1357
|
+
html = html.replace(/<strong><\/strong>/gi, '');
|
|
1358
|
+
html = html.replace(/<p><\/p>/gi, '');
|
|
1359
|
+
html = html.replace(/\/\*(.*)\*\//gi, '');
|
|
1360
|
+
html = html.replace(/<!--/gi, "");
|
|
1361
|
+
html = html.replace(/-->/gi, "");
|
|
1362
|
+
html = html.replace(/<style[^>]*>[^<]*<\/style[^>]*>/gi, '');
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
html = html.trim();
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
return html;
|
|
1369
|
+
};
|
|
1370
|
+
|
|
1371
|
+
var oldRange = that.getRange();
|
|
1372
|
+
if (that.pasteMode == "text" && !$.jqx.browser.mozilla) {
|
|
1373
|
+
that.selection.insertContent('<textarea cols="50" contenteditable="false" class="jqx-editor-paste-element"></textarea>');
|
|
1374
|
+
}
|
|
1375
|
+
else {
|
|
1376
|
+
that.selection.insertContent('<div class="jqx-editor-paste-element"> </div>');
|
|
1377
|
+
}
|
|
1378
|
+
var scroll = $(window).scrollTop();
|
|
1379
|
+
|
|
1380
|
+
var marker = $(that.editorDocument).find(".jqx-editor-paste-element");
|
|
1381
|
+
marker.css('top', scroll + "px");
|
|
1382
|
+
if (that.editor[0].createTextRange) {
|
|
1383
|
+
event.preventDefault();
|
|
1384
|
+
var textRange = that.editor[0].createTextRange();
|
|
1385
|
+
textRange.moveToElementText(marker[0]);
|
|
1386
|
+
textRange.execCommand('Paste');
|
|
1387
|
+
}
|
|
1388
|
+
else {
|
|
1389
|
+
var range = that.editorDocument.createRange();
|
|
1390
|
+
range.selectNodeContents(marker[0]);
|
|
1391
|
+
that.selectRange(range);
|
|
1392
|
+
}
|
|
1393
|
+
if (that.pasteMode == "text" && !$.jqx.browser.mozilla) {
|
|
1394
|
+
marker.select();
|
|
1395
|
+
}
|
|
1396
|
+
that.marker = marker;
|
|
1397
|
+
|
|
1398
|
+
setTimeout(function () {
|
|
1399
|
+
that.selectRange(oldRange);
|
|
1400
|
+
|
|
1401
|
+
var buildFragment = function (html) {
|
|
1402
|
+
var container = that.editorDocument.createElement('div');
|
|
1403
|
+
var fragment = that.editorDocument.createDocumentFragment();
|
|
1404
|
+
container.innerHTML = html;
|
|
1405
|
+
|
|
1406
|
+
while (container.firstChild) {
|
|
1407
|
+
fragment.appendChild(container.firstChild);
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
return fragment;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
if (that.pasteMode != "text") {
|
|
1414
|
+
var fragment = buildFragment(that.marker.html());
|
|
1415
|
+
|
|
1416
|
+
if (fragment.firstChild && fragment.firstChild.className === "jqx-editor-paste-element") {
|
|
1417
|
+
var fragmentsHtml = [];
|
|
1418
|
+
for (var i = 0, l = fragment.childNodes.length; i < l; i++) {
|
|
1419
|
+
fragmentsHtml.push(fragment.childNodes[i].innerHTML);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
fragment = buildFragment(fragmentsHtml.join('<br />'));
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
var div = document.createElement('div');
|
|
1426
|
+
div.appendChild(fragment.cloneNode(true));
|
|
1427
|
+
var html = div.innerHTML;
|
|
1428
|
+
}
|
|
1429
|
+
else {
|
|
1430
|
+
var html = that.marker.val();
|
|
1431
|
+
if (that.marker.html() != "" && that.marker.val().indexOf('\n') == -1) {
|
|
1432
|
+
var html = that.marker.html();
|
|
1433
|
+
html = html.replace(/ /gm, "");
|
|
1434
|
+
html = html.replace(/\n\n/gm, "\n");
|
|
1435
|
+
html = html.replace(/<br[^>]*>/gi, '\n');
|
|
1436
|
+
html = html.replace(/<li[^>]*>/gi, '\n');
|
|
1437
|
+
html = html.replace(/<p[^>]*>/gi, '\n');
|
|
1438
|
+
that.marker.html(html);
|
|
1439
|
+
var html = that.marker.text();
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
var txtPastetClean = cleanHtml(html, that.pasteMode == "text");
|
|
1443
|
+
var range = that.getRange();
|
|
1444
|
+
that.selection.insertContent(txtPastetClean + "<span id='INSERTION_MARKER'> </span>");
|
|
1445
|
+
that.marker.remove();
|
|
1446
|
+
var marker = $(that.editorDocument).find("#INSERTION_MARKER");
|
|
1447
|
+
that.selection.selectNode(marker[0], true);
|
|
1448
|
+
if (that.getRange().setStartAfter) {
|
|
1449
|
+
that.getRange().setStartAfter(marker[0]);
|
|
1450
|
+
}
|
|
1451
|
+
marker.remove();
|
|
1452
|
+
that.selection.collapse(false);
|
|
1453
|
+
marker.removeAttr('id');
|
|
1454
|
+
that._refreshTools();
|
|
1455
|
+
that.changed = true;
|
|
1456
|
+
}, 100);
|
|
1457
|
+
|
|
1458
|
+
that.updating = false;
|
|
1459
|
+
that.readOnly = false;
|
|
1460
|
+
}
|
|
1461
|
+
catch (error) {
|
|
1462
|
+
if (console) {
|
|
1463
|
+
console.log(error);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
that.addHandler(that.editor, "keyup.editor" + that.element.id, function (event) {
|
|
1469
|
+
if (that._documentMode == "source")
|
|
1470
|
+
return true;
|
|
1471
|
+
|
|
1472
|
+
if (that.updating || that.disabled || !that.editable) {
|
|
1473
|
+
if (event.preventDefault) {
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
}
|
|
1476
|
+
if (event.stopPropagation) {
|
|
1477
|
+
event.stopPropagation();
|
|
1478
|
+
}
|
|
1479
|
+
return false;
|
|
1480
|
+
}
|
|
1481
|
+
|
|
1482
|
+
that.range = that.getRange();
|
|
1483
|
+
that.changed = true;
|
|
1484
|
+
var ev = event || window.event;
|
|
1485
|
+
var key = ev.keyCode;
|
|
1486
|
+
var selectionCodes = [8, 9, 13, 33, 34, 35, 36, 37, 38, 39, 40, 40, 45, 46];
|
|
1487
|
+
|
|
1488
|
+
if ($.inArray(ev.keyCode, selectionCodes) != -1
|
|
1489
|
+
|| (ev.keyCode == 65 && ev.ctrlKey && !ev.altKey && !ev.shiftKey)) {
|
|
1490
|
+
that._refreshTools(null, true, ev.keyCode);
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
|
|
1494
|
+
that.addHandler(that.editor, "click.editor" + that.element.id, function (event) {
|
|
1495
|
+
if (that._documentMode == "source")
|
|
1496
|
+
return true;
|
|
1497
|
+
|
|
1498
|
+
if (that.editImage) {
|
|
1499
|
+
$(that.editImage).removeClass('jqx-editor-focus');
|
|
1500
|
+
that.editImage = null;
|
|
1501
|
+
}
|
|
1502
|
+
if (event.target.tagName.toLowerCase() == 'img') {
|
|
1503
|
+
var image = event.target;
|
|
1504
|
+
that.editImage = image;
|
|
1505
|
+
$(that.editImage).addClass('jqx-editor-focus');
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
that.addHandler(that.editor, "dblclick.editor" + that.element.id, function (event) {
|
|
1509
|
+
if (that._documentMode == "source")
|
|
1510
|
+
return true;
|
|
1511
|
+
|
|
1512
|
+
if (event.target.tagName.toLowerCase() == 'img') {
|
|
1513
|
+
var image = event.target;
|
|
1514
|
+
if ($("#" + "imageWindow" + this.element.id).length > 0) {
|
|
1515
|
+
that.editImage = image;
|
|
1516
|
+
that._updateImageWindow();
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
},
|
|
1521
|
+
|
|
1522
|
+
|
|
1523
|
+
_removeHandlers: function () {
|
|
1524
|
+
var that = this;
|
|
1525
|
+
if (that.editor) {
|
|
1526
|
+
that.removeHandler(that.editor, "paste.editor" + that.element.id);
|
|
1527
|
+
that.removeHandler(that.editor, 'blur.editor' + that.element.id);
|
|
1528
|
+
that.removeHandler(that.editor, 'focus.editor' + that.element.id);
|
|
1529
|
+
that.removeHandler(that.editor, 'click.editor' + that.element.id);
|
|
1530
|
+
that.removeHandler(that.editor, 'mousedown.editor' + that.element.id);
|
|
1531
|
+
that.removeHandler(that.editor, 'mouseup.editor' + that.element.id);
|
|
1532
|
+
that.removeHandler(that.editor, 'keyup.editor' + that.element.id);
|
|
1533
|
+
that.removeHandler(that.editor, 'keydown.editor' + that.element.id);
|
|
1534
|
+
that.removeHandler(that.editor, 'beforedeactivate.editor' + that.element.id);
|
|
1535
|
+
that.removeHandler(that.editor, 'dblclick.editor' + that.element.id);
|
|
1536
|
+
}
|
|
1537
|
+
if (that.toolbar) {
|
|
1538
|
+
that.removeHandler(that.toolbar, 'mousedown.editor' + that.element.id);
|
|
1539
|
+
}
|
|
1540
|
+
},
|
|
1541
|
+
|
|
1542
|
+
getParentByTag: function (a, b) {
|
|
1543
|
+
var b = b.toLowerCase(), c = a;
|
|
1544
|
+
do
|
|
1545
|
+
if (b == "" || c.nodeName.toLowerCase() == b)
|
|
1546
|
+
return c;
|
|
1547
|
+
while (c = c.parentNode);
|
|
1548
|
+
return a
|
|
1549
|
+
},
|
|
1550
|
+
|
|
1551
|
+
isStyleProperty: function (a, b, c, d) {
|
|
1552
|
+
var b = b.toLowerCase(), e = a;
|
|
1553
|
+
do
|
|
1554
|
+
if (e.nodeName.toLowerCase() == b && e.style[c] == d)
|
|
1555
|
+
return !0;
|
|
1556
|
+
while (e = e.parentNode);
|
|
1557
|
+
return !1
|
|
1558
|
+
},
|
|
1559
|
+
|
|
1560
|
+
setStyleProperty: function (a, b) {
|
|
1561
|
+
this.style[b] = !1;
|
|
1562
|
+
var c = this.getParentByTag(a, b);
|
|
1563
|
+
c && c.tagName.toLowerCase() == b && (this.style[b] = !0);
|
|
1564
|
+
if (b == "del" && this.getParentByTag(a, "strike") && this.getParentByTag(a, "strike").tagName.toLowerCase() == "strike")
|
|
1565
|
+
this.style.del = !0
|
|
1566
|
+
},
|
|
1567
|
+
|
|
1568
|
+
_rgbToHex: function (color) {
|
|
1569
|
+
if (color) {
|
|
1570
|
+
if (color.substr(0, 1) === "#") {
|
|
1571
|
+
if (color.length == 4) {
|
|
1572
|
+
var r = color.substr(1, 1);
|
|
1573
|
+
var g = color.substr(2, 1);
|
|
1574
|
+
var b = color.substr(3, 1);
|
|
1575
|
+
return "#" + r + r + g + g + b + b;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
return color;
|
|
1579
|
+
}
|
|
1580
|
+
var nums = /(.*?)rgb\((\d+),\s*(\d+),\s*(\d+)\)/i.exec(color);
|
|
1581
|
+
if (!nums) {
|
|
1582
|
+
return null;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
var r = parseInt(nums[2], 10).toString(16);
|
|
1586
|
+
var g = parseInt(nums[3], 10).toString(16);
|
|
1587
|
+
var b = parseInt(nums[4], 10).toString(16);
|
|
1588
|
+
return "#" + (
|
|
1589
|
+
(r.length == 1 ? "0" + r : r) +
|
|
1590
|
+
(g.length == 1 ? "0" + g : g) +
|
|
1591
|
+
(b.length == 1 ? "0" + b : b)
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
return null;
|
|
1595
|
+
},
|
|
1596
|
+
|
|
1597
|
+
updateStyle: function (el) {
|
|
1598
|
+
var that = this;
|
|
1599
|
+
var el = that.getSelectedElement() ? that.getSelectedElement() : el;
|
|
1600
|
+
if (!el || !that.setStyleProperty) return;
|
|
1601
|
+
try {
|
|
1602
|
+
if (window.getComputedStyle) {
|
|
1603
|
+
if (el.nodeName.toLowerCase() == "#text") el = that.editor[0];
|
|
1604
|
+
|
|
1605
|
+
var st = window.getComputedStyle(el, null);
|
|
1606
|
+
var fw = ((st.getPropertyValue("font-weight") == 401) ? 700 : st.getPropertyValue("font-weight"));
|
|
1607
|
+
that.style = {
|
|
1608
|
+
fontStyle: st.getPropertyValue("font-style"),
|
|
1609
|
+
fontSize: st.getPropertyValue("font-size"),
|
|
1610
|
+
textDecoration: st.getPropertyValue("text-decoration"),
|
|
1611
|
+
fontWeight: fw,
|
|
1612
|
+
fontFamily: st.getPropertyValue("font-family"),
|
|
1613
|
+
textAlign: st.getPropertyValue("text-align"),
|
|
1614
|
+
color: that._rgbToHex(st.color),
|
|
1615
|
+
backColor: that._rgbToHex(st.backgroundColor)
|
|
1616
|
+
};
|
|
1617
|
+
that.style.fontStyle = st.getPropertyValue("font-style");
|
|
1618
|
+
that.style.vAlign = st.getPropertyValue("vertical-align");
|
|
1619
|
+
that.style.del = that.isStyleProperty(el, "span", "textDecoration", "line-through");
|
|
1620
|
+
that.style.u = that.isStyleProperty(el, "span", "textDecoration", "underline");
|
|
1621
|
+
|
|
1622
|
+
var getActualBackgroundColor = function (elem) {
|
|
1623
|
+
var transparentColor = "transparent";
|
|
1624
|
+
var rgba = "rgba(0, 0, 0, 0)";
|
|
1625
|
+
while (elem && (window.getComputedStyle(elem).backgroundColor == transparentColor || window.getComputedStyle(elem).backgroundColor == rgba))
|
|
1626
|
+
elem = elem.parentNode;
|
|
1627
|
+
return elem ? window.getComputedStyle(elem).backgroundColor : transparentColor;
|
|
1628
|
+
}
|
|
1629
|
+
if (!that.style.backColor) {
|
|
1630
|
+
that.style.backColor = that._rgbToHex(getActualBackgroundColor(el));
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
else {
|
|
1634
|
+
var st = el.currentStyle;
|
|
1635
|
+
that.style = {
|
|
1636
|
+
fontStyle: st.fontStyle,
|
|
1637
|
+
fontSize: st.fontSize,
|
|
1638
|
+
textDecoration: st.textDecoration,
|
|
1639
|
+
fontWeight: st.fontWeight,
|
|
1640
|
+
fontFamily: st.fontFamily,
|
|
1641
|
+
textAlign: st.textAlign,
|
|
1642
|
+
color: that._rgbToHex(st.color),
|
|
1643
|
+
backColor: that._rgbToHex(st.backgroundColor)
|
|
1644
|
+
};
|
|
1645
|
+
}
|
|
1646
|
+
that.setStyleProperty(el, "h1");
|
|
1647
|
+
that.setStyleProperty(el, "h2");
|
|
1648
|
+
that.setStyleProperty(el, "h3");
|
|
1649
|
+
that.setStyleProperty(el, "h4");
|
|
1650
|
+
that.setStyleProperty(el, "h5");
|
|
1651
|
+
that.setStyleProperty(el, "h6");
|
|
1652
|
+
that.setStyleProperty(el, "del");
|
|
1653
|
+
that.setStyleProperty(el, "sub");
|
|
1654
|
+
that.setStyleProperty(el, "sup");
|
|
1655
|
+
that.setStyleProperty(el, "u");
|
|
1656
|
+
if (el.nodeName.toLowerCase() == "a") {
|
|
1657
|
+
if (that.style.textDecoration == "underline") {
|
|
1658
|
+
that.style.u = true;
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
if (that.style.h1 || that.style.h2 || that.style.h3 || that.style.h4 || that.style.h5 || that.style.h6)
|
|
1663
|
+
that.style.heading = true;
|
|
1664
|
+
}
|
|
1665
|
+
catch (e) { return null }
|
|
1666
|
+
},
|
|
1667
|
+
|
|
1668
|
+
_refreshTools: function (el, navigate, key) {
|
|
1669
|
+
var that = this;
|
|
1670
|
+
if (that.updating)
|
|
1671
|
+
return;
|
|
1672
|
+
|
|
1673
|
+
var el = that.getSelectedElement() ? that.getSelectedElement() : el;
|
|
1674
|
+
if (!el || !that.setStyleProperty) return;
|
|
1675
|
+
that.updateStyle(el);
|
|
1676
|
+
|
|
1677
|
+
var s = that.readOnly;
|
|
1678
|
+
that.readOnly = true;
|
|
1679
|
+
|
|
1680
|
+
if (that.tools !== false) {
|
|
1681
|
+
var tools = that.tools.split(" ");
|
|
1682
|
+
var toolGroups = that.tools.split(" | ");
|
|
1683
|
+
|
|
1684
|
+
var resetTools = function (tools) {
|
|
1685
|
+
$.each(tools, function (index, value) {
|
|
1686
|
+
var tool = that.commands[this];
|
|
1687
|
+
if (!tool) {
|
|
1688
|
+
return true;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
switch (tool.type) {
|
|
1692
|
+
case 'list':
|
|
1693
|
+
tool.widget.jqxDropDownList('clearSelection');
|
|
1694
|
+
tool.widget.jqxDropDownList({ disabled: that.disabled });
|
|
1695
|
+
break;
|
|
1696
|
+
case 'colorPicker':
|
|
1697
|
+
tool.val(tool.value);
|
|
1698
|
+
tool.widget.jqxDropDownButton({ disabled: that.disabled });
|
|
1699
|
+
break;
|
|
1700
|
+
case "toggleButton":
|
|
1701
|
+
tool.widget.jqxToggleButton('unCheck');
|
|
1702
|
+
tool.widget.jqxToggleButton({ disabled: that.disabled });
|
|
1703
|
+
break;
|
|
1704
|
+
case "button":
|
|
1705
|
+
default:
|
|
1706
|
+
tool.widget.jqxButton({ disabled: that.disabled });
|
|
1707
|
+
break;
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
if (toolGroups.length == 0) {
|
|
1713
|
+
resetTools(tools);
|
|
1714
|
+
}
|
|
1715
|
+
else {
|
|
1716
|
+
for (var i = 0; i < toolGroups.length; i++) {
|
|
1717
|
+
var toolGroup = toolGroups[i];
|
|
1718
|
+
var tools = toolGroup.split(" ");
|
|
1719
|
+
resetTools(tools);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
if (that.style) {
|
|
1724
|
+
var updateTools = function (tools) {
|
|
1725
|
+
$.each(tools, function (index, value) {
|
|
1726
|
+
var tool = that.commands[this];
|
|
1727
|
+
if (!tool) {
|
|
1728
|
+
return true;
|
|
1729
|
+
}
|
|
1730
|
+
if (tool.refresh) {
|
|
1731
|
+
tool.refresh(tool.widget, that.style);
|
|
1732
|
+
return true;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
switch (tool.type) {
|
|
1736
|
+
case 'list':
|
|
1737
|
+
if (tool.command == "fontname") {
|
|
1738
|
+
var fontNameIndex = -1;
|
|
1739
|
+
var oldValueIndex = 999;
|
|
1740
|
+
for (var i = 0; i < tool.value.length; i++) {
|
|
1741
|
+
var value = tool.value[i].label.toLowerCase();
|
|
1742
|
+
var valueIndex = that.style.fontFamily.toLowerCase().indexOf(value);
|
|
1743
|
+
|
|
1744
|
+
if (valueIndex >= 0) {
|
|
1745
|
+
if (valueIndex < oldValueIndex) {
|
|
1746
|
+
fontNameIndex = i;
|
|
1747
|
+
}
|
|
1748
|
+
oldValueIndex = Math.min(oldValueIndex, valueIndex);
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
tool.widget.jqxDropDownList('selectIndex', fontNameIndex);
|
|
1752
|
+
}
|
|
1753
|
+
else if (tool.command == "formatblock") {
|
|
1754
|
+
var value = null;
|
|
1755
|
+
if (that.style.h1) value = "h1";
|
|
1756
|
+
else if (that.style.h2) value = "h2";
|
|
1757
|
+
else if (that.style.h3) value = "h3";
|
|
1758
|
+
else if (that.style.h4) value = "h4";
|
|
1759
|
+
else if (that.style.h5) value = "h5";
|
|
1760
|
+
else if (that.style.h6) value = "h6";
|
|
1761
|
+
tool.widget.jqxDropDownList('selectItem', value);
|
|
1762
|
+
}
|
|
1763
|
+
else if (tool.command == "fontsize") {
|
|
1764
|
+
var fontSizes = 'xx-small,x-small,small,medium,large,x-large,xx-large'.split(',');
|
|
1765
|
+
var size = -1;
|
|
1766
|
+
try {
|
|
1767
|
+
var size = el.getAttribute('size') - 1;
|
|
1768
|
+
if (size == -1) size = that.editorDocument.queryCommandValue(tool.command) - 1;
|
|
1769
|
+
}
|
|
1770
|
+
catch (er) {
|
|
1771
|
+
}
|
|
1772
|
+
var fontSize = fontSizes[size];
|
|
1773
|
+
tool.widget.val(fontSize);
|
|
1774
|
+
}
|
|
1775
|
+
break;
|
|
1776
|
+
case "toggleButton":
|
|
1777
|
+
if (tool.command == "viewsource") {
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
if (!tool.command) {
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
var formatted = false;
|
|
1785
|
+
var toggled = that.editorDocument.queryCommandState(tool.command) && that.editorDocument.queryCommandEnabled(tool.command);
|
|
1786
|
+
|
|
1787
|
+
if (tool.command == "bold") {
|
|
1788
|
+
if (that.style.fontWeight && (that.style.fontWeight >= 600 || that.style.fontWeight == "bold")) {
|
|
1789
|
+
formatted = true;
|
|
1790
|
+
}
|
|
1791
|
+
if (that.selection.isCollapsed()) {
|
|
1792
|
+
tool.toggled = toggled;
|
|
1793
|
+
}
|
|
1794
|
+
else {
|
|
1795
|
+
tool.toggled = toggled || formatted;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
toggled = tool.toggled;
|
|
1799
|
+
}
|
|
1800
|
+
else if (tool.command == "italic") {
|
|
1801
|
+
if (that.style.fontStyle && that.style.fontStyle == "italic") {
|
|
1802
|
+
formatted = true;
|
|
1803
|
+
}
|
|
1804
|
+
if (!navigate) {
|
|
1805
|
+
toggled = tool.toggled;
|
|
1806
|
+
}
|
|
1807
|
+
else tool.toggled = toggled;
|
|
1808
|
+
}
|
|
1809
|
+
else if (tool.command == "underline") {
|
|
1810
|
+
if (that.style.u) {
|
|
1811
|
+
formatted = true;
|
|
1812
|
+
}
|
|
1813
|
+
if (!navigate) {
|
|
1814
|
+
toggled = tool.toggled;
|
|
1815
|
+
}
|
|
1816
|
+
else tool.toggled = toggled;
|
|
1817
|
+
}
|
|
1818
|
+
else if (tool.command == "justifyleft") {
|
|
1819
|
+
if (that.style.textAlign == "left") {
|
|
1820
|
+
formatted = true;
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
else if (tool.command == "justifyright") {
|
|
1824
|
+
if (that.style.textAlign == "right") {
|
|
1825
|
+
formatted = true;
|
|
1826
|
+
}
|
|
1827
|
+
}
|
|
1828
|
+
else if (tool.command == "justifycenter") {
|
|
1829
|
+
if (that.style.textAlign == "center") {
|
|
1830
|
+
formatted = true;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
else if (tool.command == "justifyfull") {
|
|
1834
|
+
if (that.style.textAlign == "justify") {
|
|
1835
|
+
formatted = true;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
else $.each(that.style, function (index, value) {
|
|
1839
|
+
if (tool.command == index.toLowerCase()) {
|
|
1840
|
+
formatted = true;
|
|
1841
|
+
}
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
var isActive = toggled;
|
|
1845
|
+
|
|
1846
|
+
if (formatted && tool.command.indexOf('justify') != -1) {
|
|
1847
|
+
tool.widget.jqxToggleButton('check');
|
|
1848
|
+
}
|
|
1849
|
+
else {
|
|
1850
|
+
if (isActive) {
|
|
1851
|
+
tool.widget.jqxToggleButton('check');
|
|
1852
|
+
}
|
|
1853
|
+
else if (formatted && that.range.collapsed === false) {
|
|
1854
|
+
tool.widget.jqxToggleButton('check');
|
|
1855
|
+
}
|
|
1856
|
+
else if ($.jqx.browser.msie && $.jqx.browser.version < 9 && formatted && !that.selection.isCollapsed()) {
|
|
1857
|
+
tool.widget.jqxToggleButton('check');
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
break;
|
|
1862
|
+
case "button":
|
|
1863
|
+
default:
|
|
1864
|
+
if (tool.refresh) {
|
|
1865
|
+
tool.refresh(tool.widget, that.style);
|
|
1866
|
+
}
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
});
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
if (toolGroups.length == 0) {
|
|
1873
|
+
updateTools(tools);
|
|
1874
|
+
}
|
|
1875
|
+
else {
|
|
1876
|
+
for (var i = 0; i < toolGroups.length; i++) {
|
|
1877
|
+
var toolGroup = toolGroups[i];
|
|
1878
|
+
var tools = toolGroup.split(" ");
|
|
1879
|
+
updateTools(tools);
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
that.readOnly = s;
|
|
1886
|
+
},
|
|
1887
|
+
|
|
1888
|
+
_preventDefault: function (event, close) {
|
|
1889
|
+
if (close !== false) {
|
|
1890
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
1891
|
+
$('.jqx-editor-dropdownpicker').jqxDropDownButton('close');
|
|
1892
|
+
}
|
|
1893
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
1894
|
+
$('.jqx-editor-dropdownlist').jqxDropDownList('close');
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
|
|
1898
|
+
if (event.preventDefault) {
|
|
1899
|
+
event.preventDefault();
|
|
1900
|
+
}
|
|
1901
|
+
if (event.stopPropagation) {
|
|
1902
|
+
event.stopPropagation();
|
|
1903
|
+
}
|
|
1904
|
+
event.cancelBubble = true;
|
|
1905
|
+
event.returnValue = false;
|
|
1906
|
+
},
|
|
1907
|
+
|
|
1908
|
+
_addCommandHandler: function (item, event, cmd, data, tool) {
|
|
1909
|
+
var that = this;
|
|
1910
|
+
var action;
|
|
1911
|
+
|
|
1912
|
+
if (!cmd && tool.init) {
|
|
1913
|
+
cmd = "custom";
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
switch (cmd) {
|
|
1917
|
+
case 'custom':
|
|
1918
|
+
switch (tool.type) {
|
|
1919
|
+
case "list":
|
|
1920
|
+
action = function (event) {
|
|
1921
|
+
if (that._documentMode != "source") {
|
|
1922
|
+
if (event.args.type != "none") {
|
|
1923
|
+
tool.value = $(this).val();
|
|
1924
|
+
that.execute("custom", tool);
|
|
1925
|
+
if (!that.readOnly) {
|
|
1926
|
+
that._refreshTools();
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
that._preventDefault(event, false);
|
|
1931
|
+
}
|
|
1932
|
+
break;
|
|
1933
|
+
case "colorPicker":
|
|
1934
|
+
action = function (event) {
|
|
1935
|
+
if (that._documentMode != "source") {
|
|
1936
|
+
var pickerColors = $(tool.colorPicker).find('td').removeClass('jqx-editor-color-picker-selected-cell');
|
|
1937
|
+
if (event.target.nodeName.toLowerCase() == "div") {
|
|
1938
|
+
var color = $(event.target).css('background-color');
|
|
1939
|
+
$(event.target).parent().addClass('jqx-editor-color-picker-selected-cell');
|
|
1940
|
+
}
|
|
1941
|
+
else {
|
|
1942
|
+
var color = $(event.target).find('div').css('background-color');
|
|
1943
|
+
$(event.target).addClass('jqx-editor-color-picker-selected-cell');
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
|
|
1947
|
+
$('#bar-' + cmd).css('background', color);
|
|
1948
|
+
tool.widget.val = function () {
|
|
1949
|
+
var toColor = function (input) {
|
|
1950
|
+
if (typeof input != "number") {
|
|
1951
|
+
return input;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return "rgb(" + (input & 0xFF) + ", " +
|
|
1955
|
+
((input & 0xFF00) >> 8) + ", " +
|
|
1956
|
+
((input & 0xFF0000) >> 16) + ")";
|
|
1957
|
+
}
|
|
1958
|
+
var c = toColor(color);
|
|
1959
|
+
var hexColor = that._rgbToHex(c);
|
|
1960
|
+
return hexColor;
|
|
1961
|
+
}
|
|
1962
|
+
tool.widget.jqxDropDownButton('close');
|
|
1963
|
+
that.execute("custom", tool);
|
|
1964
|
+
}
|
|
1965
|
+
that._preventDefault(event);
|
|
1966
|
+
return false;
|
|
1967
|
+
}
|
|
1968
|
+
break;
|
|
1969
|
+
case "button":
|
|
1970
|
+
case "toggleButton":
|
|
1971
|
+
default:
|
|
1972
|
+
action = function (event) {
|
|
1973
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
1974
|
+
$('.jqx-editor-dropdownpicker').jqxDropDownButton('close');
|
|
1975
|
+
}
|
|
1976
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
1977
|
+
$('.jqx-editor-dropdownlist').jqxDropDownList('close');
|
|
1978
|
+
}
|
|
1979
|
+
|
|
1980
|
+
that._preventDefault(event);
|
|
1981
|
+
|
|
1982
|
+
var command = $(this).attr('data-command');
|
|
1983
|
+
var obj = this;
|
|
1984
|
+
|
|
1985
|
+
if (that._documentMode != "source") {
|
|
1986
|
+
if (tool.toggle) {
|
|
1987
|
+
tool.toggle();
|
|
1988
|
+
}
|
|
1989
|
+
that.execute("custom", tool);
|
|
1990
|
+
that._refreshTools();
|
|
1991
|
+
}
|
|
1992
|
+
return false;
|
|
1993
|
+
};
|
|
1994
|
+
break;
|
|
1995
|
+
}
|
|
1996
|
+
break;
|
|
1997
|
+
case 'formatblock':
|
|
1998
|
+
action = function (event) {
|
|
1999
|
+
if (that._documentMode != "source") {
|
|
2000
|
+
if (event.args.type != "none") {
|
|
2001
|
+
that.execute($(this).attr('data-command'), "<" + $(this).val() + ">", tool);
|
|
2002
|
+
if (!that.readOnly) {
|
|
2003
|
+
that.commands["bold"].toggled = false;
|
|
2004
|
+
that._refreshTools();
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
that._preventDefault(event, false);
|
|
2009
|
+
}
|
|
2010
|
+
break;
|
|
2011
|
+
case 'fontsize':
|
|
2012
|
+
action = function (event) {
|
|
2013
|
+
if (that._documentMode != "source") {
|
|
2014
|
+
if (event.args.type != "none") {
|
|
2015
|
+
var val = $(this).val();
|
|
2016
|
+
var fontSizes = 'xx-small,x-small,small,medium,large,x-large,xx-large'.split(',');
|
|
2017
|
+
|
|
2018
|
+
var fontSize = $(this).jqxDropDownList('getSelectedIndex') + 1;
|
|
2019
|
+
var fontSize = 1 + fontSizes.indexOf(val);
|
|
2020
|
+
that.execute($(this).attr('data-command'), fontSize, tool);
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
that._preventDefault(event, false);
|
|
2024
|
+
}
|
|
2025
|
+
break;
|
|
2026
|
+
case 'fontname':
|
|
2027
|
+
action = function (event) {
|
|
2028
|
+
if (that._documentMode != "source") {
|
|
2029
|
+
if (event.args.type != "none") {
|
|
2030
|
+
var val = $(this).val();
|
|
2031
|
+
that.execute($(this).attr('data-command'), val, tool);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
that._preventDefault(event, false);
|
|
2035
|
+
}
|
|
2036
|
+
break;
|
|
2037
|
+
default:
|
|
2038
|
+
action = function (event) {
|
|
2039
|
+
if ($('.jqx-editor-dropdownpicker').length > 0) {
|
|
2040
|
+
$('.jqx-editor-dropdownpicker').jqxDropDownButton('close');
|
|
2041
|
+
}
|
|
2042
|
+
if ($('.jqx-editor-dropdownlist').length > 0) {
|
|
2043
|
+
$('.jqx-editor-dropdownlist').jqxDropDownList('close');
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
that._preventDefault(event);
|
|
2047
|
+
|
|
2048
|
+
var command = $(this).attr('data-command');
|
|
2049
|
+
var obj = this;
|
|
2050
|
+
|
|
2051
|
+
if (that._documentMode != "source") {
|
|
2052
|
+
if (command == "underline") {
|
|
2053
|
+
if (that.getSelectedElement()) {
|
|
2054
|
+
var selectedElement = that.getSelectedElement();
|
|
2055
|
+
if (selectedElement && selectedElement.nodeName.toLowerCase() == "a") {
|
|
2056
|
+
if (tool.toggled) {
|
|
2057
|
+
$(selectedElement).css('text-decoration', "none");
|
|
2058
|
+
}
|
|
2059
|
+
else {
|
|
2060
|
+
$(selectedElement).css('text-decoration', "underline");
|
|
2061
|
+
}
|
|
2062
|
+
tool.toggle();
|
|
2063
|
+
that._refreshTools();
|
|
2064
|
+
return false;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
if (tool.toggle) {
|
|
2069
|
+
tool.toggle();
|
|
2070
|
+
}
|
|
2071
|
+
that.execute(command, $(this).val(), tool);
|
|
2072
|
+
that._refreshTools();
|
|
2073
|
+
}
|
|
2074
|
+
return false;
|
|
2075
|
+
};
|
|
2076
|
+
break;
|
|
2077
|
+
}
|
|
2078
|
+
that.addHandler(item, event, action);
|
|
2079
|
+
return false;
|
|
2080
|
+
},
|
|
2081
|
+
|
|
2082
|
+
execute: function (cmd, args, tool) {
|
|
2083
|
+
var that = this;
|
|
2084
|
+
if (!that.readOnly) {
|
|
2085
|
+
var doc = that.editorDocument;
|
|
2086
|
+
if (that._documentMode == "source") {
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
that.changeType = "mouse";
|
|
2090
|
+
if (that.linkPopup) that.linkPopup.remove();
|
|
2091
|
+
that.editor.focus();
|
|
2092
|
+
if ($.jqx.browser.mozilla) {
|
|
2093
|
+
// that.focus();
|
|
2094
|
+
}
|
|
2095
|
+
if ($.jqx.mobile.isTouchDevice()) {
|
|
2096
|
+
setTimeout(function () {
|
|
2097
|
+
// that.focus();
|
|
2098
|
+
}, 25);
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
var performAction = function (action) {
|
|
2102
|
+
try {
|
|
2103
|
+
if (action.command && action.command.toLowerCase() == "inserthtml") {
|
|
2104
|
+
var range = that.getRange();
|
|
2105
|
+
var htmlString = action.value;
|
|
2106
|
+
if (htmlString.toString().indexOf('<') == -1) {
|
|
2107
|
+
htmlString = "<span>" + action.value + "</span>";
|
|
2108
|
+
}
|
|
2109
|
+
that.selection.insertContent("" + htmlString + "<span id='INSERTION_MARKER'> </span>");
|
|
2110
|
+
that.selectRange(range);
|
|
2111
|
+
setTimeout(function () {
|
|
2112
|
+
var marker = $(that.editorDocument).find("#INSERTION_MARKER");
|
|
2113
|
+
that.selection.selectNode($(marker).prev()[0], true);
|
|
2114
|
+
marker.remove();
|
|
2115
|
+
that.selection.collapse(false);
|
|
2116
|
+
}, 10);
|
|
2117
|
+
}
|
|
2118
|
+
else if (action.command) {
|
|
2119
|
+
if (doc.queryCommandEnabled(action.command)) {
|
|
2120
|
+
doc.execCommand(action.command, false, action.value);
|
|
2121
|
+
}
|
|
2122
|
+
else {
|
|
2123
|
+
return false;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
else {
|
|
2127
|
+
if (doc.queryCommandEnabled(action)) {
|
|
2128
|
+
doc.execCommand(action, false, action);
|
|
2129
|
+
}
|
|
2130
|
+
else {
|
|
2131
|
+
return false;
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
catch (er) {
|
|
2136
|
+
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
if (cmd == "custom") {
|
|
2141
|
+
var action = args.action(args.widget, that.editor);
|
|
2142
|
+
if (action) {
|
|
2143
|
+
performAction(action);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
else {
|
|
2147
|
+
try {
|
|
2148
|
+
if (tool && tool.action) {
|
|
2149
|
+
var action = tool.action(tool.widget, that.editor);
|
|
2150
|
+
performAction(action);
|
|
2151
|
+
}
|
|
2152
|
+
else {
|
|
2153
|
+
if (doc.queryCommandEnabled(cmd)) {
|
|
2154
|
+
doc.execCommand(cmd, false, args);
|
|
2155
|
+
}
|
|
2156
|
+
else if (cmd == "insertHTML") {
|
|
2157
|
+
that.selection.insertContent(args);
|
|
2158
|
+
}
|
|
2159
|
+
else {
|
|
2160
|
+
return false;
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
catch (er) {
|
|
2165
|
+
if (cmd == "insertHTML") {
|
|
2166
|
+
that.selection.insertContent(args);
|
|
2167
|
+
}
|
|
2168
|
+
else {
|
|
2169
|
+
return false;
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
if ($.jqx.mobile.isTouchDevice()) {
|
|
2175
|
+
setTimeout(function () {
|
|
2176
|
+
if (that.iframe) {
|
|
2177
|
+
that.iframe[0].contentWindow.focus();
|
|
2178
|
+
}
|
|
2179
|
+
}, 500);
|
|
2180
|
+
}
|
|
2181
|
+
|
|
2182
|
+
that._raiseEvent("change", {
|
|
2183
|
+
command: cmd,
|
|
2184
|
+
args: args
|
|
2185
|
+
});
|
|
2186
|
+
that.changed = true;
|
|
2187
|
+
that.range = that.getRange();
|
|
2188
|
+
}
|
|
2189
|
+
},
|
|
2190
|
+
|
|
2191
|
+
destroy: function () {
|
|
2192
|
+
var that = this;
|
|
2193
|
+
that._removeHandlers();
|
|
2194
|
+
var tools = that.tools.split(" ");
|
|
2195
|
+
var toolGroups = that.tools.split(" | ");
|
|
2196
|
+
$.jqx.utilities.resize(this.host, null, true);
|
|
2197
|
+
|
|
2198
|
+
var destroyTools = function (tools) {
|
|
2199
|
+
$.each(tools, function (index, value) {
|
|
2200
|
+
var tool = that.commands[this];
|
|
2201
|
+
if (!tool) {
|
|
2202
|
+
return true;
|
|
2203
|
+
}
|
|
2204
|
+
|
|
2205
|
+
switch (tool.type) {
|
|
2206
|
+
case 'list':
|
|
2207
|
+
tool.widget.jqxDropDownList('destroy');
|
|
2208
|
+
break;
|
|
2209
|
+
case 'colorPicker':
|
|
2210
|
+
tool.colorPicker.remove();
|
|
2211
|
+
tool.widget.jqxDropDownButton('destroy');
|
|
2212
|
+
break;
|
|
2213
|
+
case "toggleButton":
|
|
2214
|
+
tool.widget.jqxToggleButton('destroy');
|
|
2215
|
+
break;
|
|
2216
|
+
case "custom":
|
|
2217
|
+
if (that.destroyTool) that.destroyTool(this);
|
|
2218
|
+
break;
|
|
2219
|
+
case "button":
|
|
2220
|
+
default:
|
|
2221
|
+
tool.widget.jqxToggleButton('destroy');
|
|
2222
|
+
if (tool.command === "insertimage") {
|
|
2223
|
+
if ($("#imageWindow" + that.element.id).length > 0) {
|
|
2224
|
+
$("#imageWindow" + that.element.id).find('.jqx-editor-align').jqxDropDownList("destroy");
|
|
2225
|
+
$("#imageWindow" + that.element.id).find('button').jqxButton('destroy');
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
else if (tool.command === "createlink") {
|
|
2229
|
+
if ($("#linkWindow" + that.element.id).length > 0) {
|
|
2230
|
+
$("#linkWindow" + that.element.id).find('.jqx-editor-align').jqxDropDownList("destroy");
|
|
2231
|
+
$("#linkWindow" + that.element.id).find('button').jqxButton('destroy');
|
|
2232
|
+
$("#linkWindow" + that.element.id).find('.jqx-editor-link-checkbox').jqxCheckBox('destroy');
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
break;
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
if (toolGroups.length == 0) {
|
|
2241
|
+
destroyTools(tools);
|
|
2242
|
+
}
|
|
2243
|
+
else {
|
|
2244
|
+
for (var i = 0; i < toolGroups.length; i++) {
|
|
2245
|
+
var toolGroup = toolGroups[i];
|
|
2246
|
+
var tools = toolGroup.split(" ");
|
|
2247
|
+
destroyTools(tools);
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
var linkWindow = $("#" + "linkWindow" + this.element.id);
|
|
2251
|
+
var imageWindow = $("#" + "imageWindow" + this.element.id);
|
|
2252
|
+
if (linkWindow && linkWindow.length > 0) {
|
|
2253
|
+
linkWindow.jqxWindow('destroy');
|
|
2254
|
+
}
|
|
2255
|
+
if (imageWindow && imageWindow.length > 0) {
|
|
2256
|
+
imageWindow.jqxWindow('destroy');
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2259
|
+
if (that.inline) {
|
|
2260
|
+
that.toolbar.remove();
|
|
2261
|
+
}
|
|
2262
|
+
else {
|
|
2263
|
+
that.widget.remove();
|
|
2264
|
+
that.host.remove();
|
|
2265
|
+
}
|
|
2266
|
+
that.iframe.remove();
|
|
2267
|
+
that.iframe = null;
|
|
2268
|
+
that.selection = null;
|
|
2269
|
+
that.editorDocument = null;
|
|
2270
|
+
that.contentEditableElement = null;
|
|
2271
|
+
},
|
|
2272
|
+
|
|
2273
|
+
_raiseEvent: function (id, arg) {
|
|
2274
|
+
if (arg == undefined)
|
|
2275
|
+
arg = { owner: null };
|
|
2276
|
+
|
|
2277
|
+
if (this._documentMode == "source")
|
|
2278
|
+
return true;
|
|
2279
|
+
|
|
2280
|
+
var evt = id;
|
|
2281
|
+
arg.type = this.changeType;
|
|
2282
|
+
this.changeType = null;
|
|
2283
|
+
var args = arg;
|
|
2284
|
+
args.owner = this;
|
|
2285
|
+
|
|
2286
|
+
var event = new $.Event(evt);
|
|
2287
|
+
event.owner = this;
|
|
2288
|
+
event.args = args;
|
|
2289
|
+
if (this._textArea) {
|
|
2290
|
+
var result = $(this._textArea).trigger(event);
|
|
2291
|
+
}
|
|
2292
|
+
else {
|
|
2293
|
+
var result = this.host.trigger(event);
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
// save the new event arguments.
|
|
2297
|
+
arg = event.args;
|
|
2298
|
+
return result;
|
|
2299
|
+
}
|
|
2300
|
+
});
|
|
2301
|
+
|
|
2302
|
+
var jqxSelection = function (document) {
|
|
2303
|
+
var selection = {
|
|
2304
|
+
initialize: function (document) {
|
|
2305
|
+
this.document = document;
|
|
2306
|
+
},
|
|
2307
|
+
|
|
2308
|
+
getSelection: function () {
|
|
2309
|
+
return (this.document.getSelection) ? this.document.getSelection() : this.document.selection;
|
|
2310
|
+
},
|
|
2311
|
+
|
|
2312
|
+
getRange: function () {
|
|
2313
|
+
var s = this.getSelection();
|
|
2314
|
+
|
|
2315
|
+
if (!s) return null;
|
|
2316
|
+
|
|
2317
|
+
try {
|
|
2318
|
+
return s.rangeCount > 0 ? s.getRangeAt(0) : (this.document.createRange ? this.document.createRange() : this.document.selection.createRange());
|
|
2319
|
+
} catch (e) {
|
|
2320
|
+
// IE bug when used in frameset
|
|
2321
|
+
return this.document.body.createTextRange();
|
|
2322
|
+
}
|
|
2323
|
+
},
|
|
2324
|
+
|
|
2325
|
+
selectRange: function (range) {
|
|
2326
|
+
if (range.select) {
|
|
2327
|
+
range.select();
|
|
2328
|
+
} else {
|
|
2329
|
+
var s = this.getSelection();
|
|
2330
|
+
if (s.addRange) {
|
|
2331
|
+
s.removeAllRanges();
|
|
2332
|
+
s.addRange(range);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
},
|
|
2336
|
+
|
|
2337
|
+
selectNode: function (node, collapse) {
|
|
2338
|
+
var r = this.getRange();
|
|
2339
|
+
var s = this.getSelection();
|
|
2340
|
+
|
|
2341
|
+
if (r.moveToElementText) {
|
|
2342
|
+
r.moveToElementText(node);
|
|
2343
|
+
r.select();
|
|
2344
|
+
} else if (s.addRange) {
|
|
2345
|
+
try {
|
|
2346
|
+
collapse ? r.selectNodeContents(node) : r.selectNode(node);
|
|
2347
|
+
s.removeAllRanges();
|
|
2348
|
+
s.addRange(r);
|
|
2349
|
+
}
|
|
2350
|
+
catch (error) {
|
|
2351
|
+
var er = error;
|
|
2352
|
+
}
|
|
2353
|
+
} else {
|
|
2354
|
+
s.setBaseAndExtent(node, 0, node, 1);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
return node;
|
|
2358
|
+
},
|
|
2359
|
+
|
|
2360
|
+
isCollapsed: function () {
|
|
2361
|
+
var r = this.getRange();
|
|
2362
|
+
if (r.item) return false;
|
|
2363
|
+
return r.boundingWidth == 0 || this.getSelection().isCollapsed;
|
|
2364
|
+
},
|
|
2365
|
+
|
|
2366
|
+
collapse: function (toStart) {
|
|
2367
|
+
var r = this.getRange();
|
|
2368
|
+
var s = this.getSelection();
|
|
2369
|
+
|
|
2370
|
+
if (r.select) {
|
|
2371
|
+
r.collapse(toStart);
|
|
2372
|
+
r.select();
|
|
2373
|
+
} else {
|
|
2374
|
+
toStart ? s.collapseToStart() : s.collapseToEnd();
|
|
2375
|
+
}
|
|
2376
|
+
},
|
|
2377
|
+
|
|
2378
|
+
getContent: function () {
|
|
2379
|
+
var r = this.getRange();
|
|
2380
|
+
var body = $('<div>')[0];
|
|
2381
|
+
|
|
2382
|
+
if (this.isCollapsed()) return '';
|
|
2383
|
+
|
|
2384
|
+
if (r.cloneContents) {
|
|
2385
|
+
body.appendChild(r.cloneContents());
|
|
2386
|
+
} else if (r.item != undefined || r.htmlText != undefined) {
|
|
2387
|
+
$(body).html(r.item ? r.item(0).outerHTML : r.htmlText);
|
|
2388
|
+
} else {
|
|
2389
|
+
$(body).html(r.toString());
|
|
2390
|
+
}
|
|
2391
|
+
|
|
2392
|
+
var content = $(body).html();
|
|
2393
|
+
return content;
|
|
2394
|
+
},
|
|
2395
|
+
|
|
2396
|
+
getText: function () {
|
|
2397
|
+
var r = this.getRange();
|
|
2398
|
+
var s = this.getSelection();
|
|
2399
|
+
return this.isCollapsed() ? '' : r.text || (s.toString ? s.toString() : '');
|
|
2400
|
+
},
|
|
2401
|
+
|
|
2402
|
+
getNode: function () {
|
|
2403
|
+
var r = this.getRange();
|
|
2404
|
+
|
|
2405
|
+
if (!$.jqx.browser.msie || $.jqx.browser.version >= 9) {
|
|
2406
|
+
var el = null;
|
|
2407
|
+
|
|
2408
|
+
if (r) {
|
|
2409
|
+
el = r.commonAncestorContainer;
|
|
2410
|
+
|
|
2411
|
+
// Handle selection a image or other control like element such as anchors
|
|
2412
|
+
if (!r.collapsed)
|
|
2413
|
+
if (r.startContainer == r.endContainer)
|
|
2414
|
+
if (r.startOffset - r.endOffset < 2)
|
|
2415
|
+
if (r.startContainer.hasChildNodes())
|
|
2416
|
+
el = r.startContainer.childNodes[r.startOffset];
|
|
2417
|
+
|
|
2418
|
+
while (typeof (el) != 'element') el = el.parentNode;
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
return document.id(el);
|
|
2422
|
+
}
|
|
2423
|
+
|
|
2424
|
+
return document.id(r.item ? r.item(0) : r.parentElement());
|
|
2425
|
+
},
|
|
2426
|
+
|
|
2427
|
+
insertContent: function (content) {
|
|
2428
|
+
var r = this.getRange();
|
|
2429
|
+
if (r.pasteHTML) {
|
|
2430
|
+
r.pasteHTML(content);
|
|
2431
|
+
r.collapse(false);
|
|
2432
|
+
r.select();
|
|
2433
|
+
} else if (r.insertNode) {
|
|
2434
|
+
r.deleteContents();
|
|
2435
|
+
if (r.createContextualFragment) {
|
|
2436
|
+
r.insertNode(r.createContextualFragment(content));
|
|
2437
|
+
} else {
|
|
2438
|
+
var doc = this.document;
|
|
2439
|
+
var fragment = doc.createDocumentFragment();
|
|
2440
|
+
var temp = doc.createElement('div');
|
|
2441
|
+
fragment.appendChild(temp);
|
|
2442
|
+
temp.outerHTML = content;
|
|
2443
|
+
r.insertNode(fragment);
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
}
|
|
2447
|
+
};
|
|
2448
|
+
selection.initialize(document);
|
|
2449
|
+
return selection;
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
})(jqxBaseFramework);
|
|
2453
|
+
|