├── .gitignore
├── package.json
├── LICENSE
├── README.md
├── jquery.print.js
├── index.js
└── jquery.min.js
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules/
3 | # /dist/
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 |
8 | # Editor directories and files
9 | .idea
10 | .vscode
11 | *.suo
12 | *.ntvs*
13 | *.njsproj
14 | *.sln
15 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "cesium-print",
3 | "version": "1.0.7",
4 | "description": "cesium print plugin",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/richard1015/cesium-print.git"
12 | },
13 | "keywords": [
14 | "cesium",
15 | "cesium-print",
16 | "cesium-plugin"
17 | ],
18 | "author": "richard1015",
19 | "license": "ISC",
20 | "bugs": {
21 | "url": "https://github.com/richard1015/cesium-print/issues"
22 | },
23 | "homepage": "https://github.com/richard1015/cesium-print#readme",
24 | "dependencies": {
25 | "html2canvas": "^1.0.0-rc.1"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 richard1015
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # cesium-print Plugin
3 | Cesium 动态打印插件
4 | cesium-print is a plugin for cesium printing
5 |
6 | 
7 |
8 | ## Usage
9 |
10 | Include it in your code after importing npm, like:
11 |
12 | ```
13 | npm install cesium-print -dev
14 | ```
15 |
16 | Use it like:
17 |
18 | ```js
19 | import CesiumPrint from "cesium-print";
20 | ```
21 |
22 | ```js
23 |
24 | viewer = new Cesium.Viewer("cesiumContainer", {
25 | contextOptions: {
26 | id: "cesiumCanvas",//must
27 | webgl: {
28 | preserveDrawingBuffer: true
29 | }
30 | }
31 | }
32 |
33 | //打印cesium canvas dom
34 | CesiumPrint.drawArea("cesiumCanvas", {
35 | penColor: "yellow", //画笔颜色
36 | strokeWidth: 1 //单位 px
37 | })
38 | .then(base64url => {
39 | //base64url is images
40 | //print drawArea dom
41 | CesiumPrint.print(base64url);
42 | })
43 | .catch(error => {
44 | console.error(error);
45 | });
46 | ```
47 |
48 | You can submit the options object like:
49 | ```js
50 | //打印cesium canvas dom
51 | CesiumPrint.drawArea("cesiumCanvas", {
52 | penColor: "yellow", //画笔颜色
53 | strokeWidth: 1 //单位 px
54 | })
55 | .then(base64url => {
56 | //自定义打印(设置纸张大小,打印标题)
57 | // 高 宽
58 | // A0:1189mm * 841mm
59 | // A1:841mm * 594mm
60 | // A2:594mm * 420mm
61 | // A3:420mm * 297mm
62 | // A4:297mm * 210mm
63 | // 页边距: 0.75 inch
64 | // A1: 23.39x33.11 inch
65 | // 打印机DPI:300DPI
66 | // 屏幕DPI : 96DPI
67 | // width = (23.39 - 0.75 * 2) * 96 = 2101 px
68 | // height = (33.11 - 0.75 * 2)* 96 = 3034 px
69 | // A4: 8.27x11.69 inch
70 | // 打印机DPI:300DPI
71 | // 屏幕DPI : 96DPI
72 | // width = (8.27 - 0.75 * 2) * 96 = 650 px
73 | // height = (11.69 - 0.75 * 2)* 96 = 978 px
74 | // 所以,当
的width=650px, height=978px时,用IE 打印时,刚好能打印一页的A4纸.
75 | // //a1横向打印尺寸
76 | // var a1 = { width: "3034", height: "2101" };
77 | // //a4横向打印尺寸
78 | var a4 = { width: "978", height: "650" };
79 | let printOptions = {
80 | title: "打印标题(print title)",
81 | width: a4.width,
82 | height: a4.height,
83 | fontSize: "30",
84 | downLoadEnable: true //是否下载打印文件
85 | };
86 | CesiumPrint.print(base64url, printOptions);
87 | });
88 | })
89 | .catch(error => {
90 | console.error(error);
91 | });
92 | ```
93 |
94 | Currently this plugin supports the following options:
95 |
96 | #### penColor
97 |
98 | - Default: `red`
99 | - Acceptable-Values: color string
100 | - Function Desc: pen Color
101 |
102 | #### strokeWidth
103 |
104 | - Default: `1`
105 | - Acceptable-Values: number
106 | - Function: stroke width ( unit px )
107 |
108 | #### width
109 |
110 | - Default: `978`
111 | - Acceptable-Values: number
112 | - Function: print width ( unit px )
113 |
114 | #### height
115 |
116 | - Default: `650`, creates a hidden iframe if no-vaild iframe selector is passed
117 | - Acceptable-Values: number
118 | - Function: print width ( unit px )
119 |
120 | #### fontSize
121 |
122 | - Default: `32`
123 | - Acceptable-Values: number
124 | - Function: print title font size ( unit px )
125 |
126 | #### downLoadEnable
127 |
128 | - Default: `true`
129 | - Acceptable-Values: Boolean
130 | - Function: down load print file enable
131 |
132 |
133 | #### title
134 |
135 | - Default: `print`, uses the host page title
136 | - Acceptable-Values: Any single-line string
137 | - Function: To change the printed title
138 |
139 |
140 |
141 | ### Browsers
142 | * Google Chrome - v ...
143 | * Firefox - v ...
144 |
145 | ## License
146 | ....
147 |
148 | ## Demo
149 | [cesium plugin /demo](https://richard1015.github.io/cesium/)
150 | # Code Demo
151 | [https://github.com/richard1015/cesium-vue-example /(cesium-print,cesium-navigation-es6)](https://github.com/richard1015/cesium-vue-example/blob/master/src/components/CesiumViewer.vue)
152 |
153 | ## Other Cesium Plugin
154 | [cesium-navigation-es6 /github](https://github.com/richard1015/cesium-navigation-es6)
155 |
156 | ---------------------------------------
157 | Like our [work](https://github.com/richard1015)? [Get in touch 51844712@qq.com!](mailto:51844712@qq.com)
158 |
--------------------------------------------------------------------------------
/jquery.print.js:
--------------------------------------------------------------------------------
1 | /* @license
2 | * jQuery.print, version 1.6.0
3 | * (c) Sathvik Ponangi, Doers' Guild
4 | * Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
5 | *--------------------------------------------------------------------------*/
6 | (function ($) {
7 | "use strict";
8 | // A nice closure for our definitions
9 |
10 | function jQueryCloneWithSelectAndTextAreaValues(elmToClone, withDataAndEvents, deepWithDataAndEvents) {
11 | // Replacement jQuery clone that also clones the values in selects and textareas as jQuery doesn't for performance reasons - https://stackoverflow.com/questions/742810/clone-isnt-cloning-select-values
12 | // Based on https://github.com/spencertipping/jquery.fix.clone
13 | var $elmToClone = $(elmToClone),
14 | $result = $elmToClone.clone(withDataAndEvents, deepWithDataAndEvents),
15 | $myTextareas = $elmToClone.find('textarea').add($elmToClone.filter('textarea')),
16 | $resultTextareas = $result.find('textarea').add($result.filter('textarea')),
17 | $mySelects = $elmToClone.find('select').add($elmToClone.filter('select')),
18 | $resultSelects = $result.find('select').add($result.filter('select')),
19 | i, l, j, m;
20 |
21 | for (i = 0, l = $myTextareas.length; i < l; ++i) {
22 | $($resultTextareas[i]).val($($myTextareas[i]).val());
23 | }
24 | for (i = 0, l = $mySelects.length; i < l; ++i) {
25 | for (j = 0, m = $mySelects[i].options.length; j < m; ++j) {
26 | if ($mySelects[i].options[j].selected === true) {
27 | $resultSelects[i].options[j].selected = true;
28 | }
29 | }
30 | }
31 | return $result;
32 | }
33 |
34 | function getjQueryObject(string) {
35 | // Make string a vaild jQuery thing
36 | var jqObj = $("");
37 | try {
38 | jqObj = jQueryCloneWithSelectAndTextAreaValues(string);
39 | } catch (e) {
40 | jqObj = $("")
41 | .html(string);
42 | }
43 | return jqObj;
44 | }
45 |
46 | function printFrame(frameWindow, content, options) {
47 | // Print the selected window/iframe
48 | var def = $.Deferred();
49 | try {
50 | frameWindow = frameWindow.contentWindow || frameWindow.contentDocument || frameWindow;
51 | var wdoc = frameWindow.document || frameWindow.contentDocument || frameWindow;
52 |
53 | if (options.doctype) {
54 | wdoc.write(options.doctype);
55 | }
56 | wdoc.write(content);
57 | //按照指定宽高
58 | wdoc.childNodes[1].childNodes[1].style = "width: " + options.width + "px;height: " + options.height + "px;";
59 |
60 | wdoc.close();
61 | var printed = false,
62 | callPrint = function () {
63 | if (printed) {
64 | return;
65 | }
66 | // Fix for IE : Allow it to render the iframe
67 | frameWindow.focus();
68 | try {
69 | // Fix for IE11 - printng the whole page instead of the iframe content
70 | if (!frameWindow.document.execCommand('print', false, null)) {
71 | // document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891
72 | frameWindow.print();
73 | }
74 | // focus body as it is losing focus in iPad and content not getting printed
75 | $('body').focus();
76 | } catch (e) {
77 | frameWindow.print();
78 | }
79 | frameWindow.close();
80 | printed = true;
81 | def.resolve();
82 | };
83 | // Print once the frame window loads - seems to work for the new-window option but unreliable for the iframe
84 | $(frameWindow).on("load", callPrint);
85 | // Fallback to printing directly if the frame doesn't fire the load event for whatever reason
86 | setTimeout(callPrint, options.timeout);
87 | } catch (err) {
88 | def.reject(err);
89 | }
90 | return def;
91 | }
92 |
93 | function printContentInIFrame(content, options) {
94 | var $iframe = $(options.iframe + "");
95 | var iframeCount = $iframe.length;
96 | if (iframeCount === 0) {
97 | // Create a new iFrame if none is given
98 | $iframe = $('')
99 | .prependTo('body')
100 | .css({
101 | "position": "absolute",
102 | "top": -999,
103 | "left": -999
104 | });
105 | }
106 | var frameWindow = $iframe.get(0);
107 | return printFrame(frameWindow, content, options)
108 | .done(function () {
109 | // Success
110 | setTimeout(function () {
111 | // Wait for IE
112 | if (iframeCount === 0) {
113 | // Destroy the iframe if created here
114 | $iframe.remove();
115 | }
116 | }, 1000);
117 | })
118 | .fail(function (err) {
119 | // Use the pop-up method if iframe fails for some reason
120 | console.error("Failed to print from iframe", err);
121 | printContentInNewWindow(content, options);
122 | })
123 | .always(function () {
124 | try {
125 | options.deferred.resolve();
126 | } catch (err) {
127 | console.warn('Error notifying deferred', err);
128 | }
129 | });
130 | }
131 |
132 | function printContentInNewWindow(content, options) {
133 | // Open a new window and print selected content
134 | var frameWindow = window.open();
135 | return printFrame(frameWindow, content, options)
136 | .always(function () {
137 | try {
138 | options.deferred.resolve();
139 | } catch (err) {
140 | console.warn('Error notifying deferred', err);
141 | }
142 | });
143 | }
144 |
145 | function isNode(o) {
146 | /* http://stackoverflow.com/a/384380/937891 */
147 | return !!(typeof Node === "object" ? o instanceof Node : o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string");
148 | }
149 | $.print = $.fn.print = function () {
150 | // Print a given set of elements
151 | var options, $this, self = this;
152 | // console.log("Printing", this, arguments);
153 | if (self instanceof $) {
154 | // Get the node if it is a jQuery object
155 | self = self.get(0);
156 | }
157 | if (isNode(self)) {
158 | // If `this` is a HTML element, i.e. for
159 | // $(selector).print()
160 | $this = $(self);
161 | if (arguments.length > 0) {
162 | options = arguments[0];
163 | }
164 | } else {
165 | if (arguments.length > 0) {
166 | // $.print(selector,options)
167 | $this = $(arguments[0]);
168 | if (isNode($this[0])) {
169 | if (arguments.length > 1) {
170 | options = arguments[1];
171 | }
172 | } else {
173 | // $.print(options)
174 | options = arguments[0];
175 | $this = $("html");
176 | }
177 | } else {
178 | // $.print()
179 | $this = $("html");
180 | }
181 | }
182 | // Default options
183 | var defaults = {
184 | globalStyles: true,
185 | mediaPrint: false,
186 | stylesheet: null,
187 | noPrintSelector: ".no-print",
188 | iframe: true,
189 | append: null,
190 | prepend: null,
191 | manuallyCopyFormValues: true,
192 | deferred: $.Deferred(),
193 | timeout: 750,
194 | title: null,
195 | doctype: ''
196 | };
197 | // Merge with user-options
198 | options = $.extend({}, defaults, (options || {}));
199 | var $styles = $("");
200 | if (options.globalStyles) {
201 | // Apply the stlyes from the current sheet to the printed page
202 | $styles = $("style, link, meta, base, title");
203 | } else if (options.mediaPrint) {
204 | // Apply the media-print stylesheet
205 | $styles = $("link[media=print]");
206 | }
207 | if (options.stylesheet) {
208 | // Add a custom stylesheet if given
209 | $styles = $.merge($styles, $(''));
210 | }
211 | // Create a copy of the element to print
212 | var copy = jQueryCloneWithSelectAndTextAreaValues($this);
213 | // Wrap it in a span to get the HTML markup string
214 | copy = $("")
215 | .append(copy);
216 | // Remove unwanted elements
217 | copy.find(options.noPrintSelector)
218 | .remove();
219 | // Add in the styles
220 | copy.append(jQueryCloneWithSelectAndTextAreaValues($styles));
221 | // Update title
222 | if (options.title) {
223 | var title = $("title", copy);
224 | if (title.length === 0) {
225 | title = $("");
226 | copy.append(title);
227 | }
228 | title.text(options.title);
229 | }
230 | // Appedned content
231 | copy.append(getjQueryObject(options.append));
232 | // Prepended content
233 | copy.prepend(getjQueryObject(options.prepend));
234 | if (options.manuallyCopyFormValues) {
235 | // Manually copy form values into the HTML for printing user-modified input fields
236 | // http://stackoverflow.com/a/26707753
237 | copy.find("input")
238 | .each(function () {
239 | var $field = $(this);
240 | if ($field.is("[type='radio']") || $field.is("[type='checkbox']")) {
241 | if ($field.prop("checked")) {
242 | $field.attr("checked", "checked");
243 | }
244 | } else {
245 | $field.attr("value", $field.val());
246 | }
247 | });
248 | copy.find("select").each(function () {
249 | var $field = $(this);
250 | $field.find(":selected").attr("selected", "selected");
251 | });
252 | copy.find("textarea").each(function () {
253 | // Fix for https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
254 | var $field = $(this);
255 | $field.text($field.val());
256 | });
257 | }
258 | // Get the HTML markup string
259 | var content = copy.html();
260 | // Notify with generated markup & cloned elements - useful for logging, etc
261 | try {
262 | options.deferred.notify('generated_markup', content, copy);
263 | } catch (err) {
264 | console.warn('Error notifying deferred', err);
265 | }
266 | // Destroy the copy
267 | copy.remove();
268 | if (options.iframe) {
269 | // Use an iframe for printing
270 | try {
271 | printContentInIFrame(content, options);
272 | } catch (e) {
273 | // Use the pop-up method if iframe fails for some reason
274 | console.error("Failed to print from iframe", e.stack, e.message);
275 | printContentInNewWindow(content, options);
276 | }
277 | } else {
278 | // Use a new window for printing
279 | printContentInNewWindow(content, options);
280 | }
281 | return this;
282 | };
283 | })(jQuery);
284 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @Description: Custom Printing 自定义打印工具类
3 | * @Author: richard1015
4 | * @Date: 2019-01-02 10:03:25
5 | * @LastEditTime: 2019-05-21 13:47:00
6 | * @LastEditors: Please set LastEditors
7 | */
8 | /* eslint-disable */
9 |
10 | var $ = require("./jquery.min.js");
11 | window.jQuery = $;
12 | window.$ = $;
13 | require("./jquery.print.js");
14 | require('./jquery.jcanvas.js');
15 | import html2canvas from "html2canvas";
16 | export default {
17 | //鼠标开始x
18 | start_x: 0,
19 | //鼠标开始y
20 | start_y: 0,
21 | //最终区域宽
22 | area_width: 0,
23 | //最终区域高
24 | area_height: 0,
25 | //默认画笔线宽
26 | defaultStrokeWidth: 1,
27 | //默认画笔颜色
28 | defaultPenColor: "red",
29 | //进行打印的canvas dom
30 | printCanvasDom: {},
31 | //是否打印指北针
32 | defaultAddCompass:true,
33 | //绘制打印区域
34 | drawArea: function (documentId, options) {
35 | if (typeof documentId === "string") {
36 | var dom = document.getElementById(documentId);
37 | if (dom.tagName == "CANVAS") {
38 | this.printCanvasDom = dom;
39 | return this.drawRect(options);
40 | } else {
41 | throw Error('documentId tag must is Canvas !')
42 | }
43 | } else {
44 | throw Error('documentId must string and is Canvas tag!')
45 | }
46 | },
47 | /**
48 | * 绘制(选择打印区域)
49 | * @param {object} options 绘制自定义参数
50 | * @return {Pormise} 返回选定区域坐标
51 | */
52 | drawRect: function (options) {
53 | var that = this;
54 | return new Promise((resolve, reject) => {
55 | try {
56 | that.penColor = options.penColor || that.defaultPenColor;
57 | that.penWidth = options.strokeWidth || that.defaultStrokeWidth;
58 | //创建全屏打印区域
59 | var canvas = document.createElement('canvas');
60 | // 网页可见区域宽设置
61 | canvas.width = document.body.clientWidth
62 | // 网页可见区域高设置
63 | canvas.height = document.body.clientHeight
64 | canvas.style = "position: absolute;left: 0;top: 0;"
65 | document.body.appendChild(canvas);
66 |
67 | //canvas 的矩形框
68 | var canvasRect = canvas.getBoundingClientRect();
69 | //矩形框的左上角坐标
70 | var canvasLeft = canvasRect.left;
71 | var canvasTop = canvasRect.top;
72 |
73 | var x = 0;
74 | var y = 0;
75 |
76 | //鼠标点击按下事件,画图准备
77 | canvas.onmousedown = function (e) {
78 | //添加屏幕缩放比例window.devicePixelRatio
79 | that.start_x = e.clientX*window.devicePixelRatio + that.defaultStrokeWidth
80 | that.start_y = e.clientY*window.devicePixelRatio + that.defaultStrokeWidth
81 | //设置画笔颜色和宽度
82 | var color = that.penColor;
83 | var penWidth = that.penWidth;
84 |
85 | x = e.clientX - canvasLeft;
86 | y = e.clientY - canvasTop;
87 | $(canvas).addLayer({
88 | type: 'rectangle',
89 | strokeStyle: color,
90 | strokeWidth: penWidth,
91 | name: 'areaLayer',
92 | fromCenter: false,
93 | x: x, y: y,
94 | width: 1,
95 | height: 1
96 | });
97 |
98 | $(canvas).drawLayers();
99 | $(canvas).saveCanvas();
100 | //鼠标移动事件,画图
101 | canvas.onmousemove = function (e) {
102 | that.area_width = e.clientX*window.devicePixelRatio - that.start_x - that.defaultStrokeWidth
103 | that.area_height = e.clientY*window.devicePixelRatio - that.start_y - that.defaultStrokeWidth
104 | var width = e.clientX - canvasLeft - x;
105 | var height = e.clientY - canvasTop - y;
106 | $(canvas).removeLayer('areaLayer');
107 |
108 | $(canvas).addLayer({
109 | type: 'rectangle',
110 | strokeStyle: color,
111 | strokeWidth: penWidth,
112 | name: 'areaLayer',
113 | fromCenter: false,
114 | x: x, y: y,
115 | width: width,
116 | height: height
117 | });
118 |
119 | $(canvas).drawLayers();
120 | }
121 | };
122 | //鼠标抬起
123 | canvas.onmouseup = function (e) {
124 |
125 | var color = that.penColor;
126 | var penWidth = that.penWidth;
127 |
128 | canvas.onmousemove = null;
129 | //添加屏幕缩放比例window.devicePixelRatio
130 | var width = e.clientX*window.devicePixelRatio - canvasLeft - x;
131 | var height = e.clientY*window.devicePixelRatio - canvasTop - y;
132 |
133 | $(canvas).removeLayer('areaLayer');
134 |
135 | $(canvas).addLayer({
136 | type: 'rectangle',
137 | strokeStyle: color,
138 | strokeWidth: penWidth,
139 | name: 'areaLayer',
140 | fromCenter: false,
141 | x: x, y: y,
142 | width: width,
143 | height: height
144 | });
145 |
146 | $(canvas).drawLayers();
147 | $(canvas).saveCanvas();
148 | $(canvas).removeLayer('areaLayer');
149 | //删除画笔区域
150 | document.body.removeChild(canvas);
151 |
152 | resolve(that.printClip());
153 | }
154 | } catch (error) {
155 | reject(error)
156 | }
157 | });
158 | },
159 |
160 | /**
161 | * 将需要打印的canvas进行裁剪,在drawRect方法我们已经 得到 裁剪坐标
162 | * @returns {string} clipImgBase64
163 | */
164 | printClip() {
165 | var that = this;
166 | console.log(`print canvas dom area width : ${that.printCanvasDom.width} height: ${that.printCanvasDom.height}`)
167 | //创建裁剪canvas
168 | var clipCanvas = document.createElement('canvas')
169 | console.log('实际打印区域', that.start_x, that.start_y, that.area_width, that.area_height)
170 | //设置实际打印区域宽高
171 | clipCanvas.width = that.area_width
172 | clipCanvas.height = that.area_height
173 | //按坐标进行裁剪
174 | clipCanvas.getContext('2d').drawImage(that.printCanvasDom, that.start_x, that.start_y, that.area_width, that.area_height, 0, 0, that.area_width, that.area_height)
175 | //实际打印 imgbase64码
176 | return clipCanvas.toDataURL();
177 | },
178 | /**
179 | * 设置打印参数
180 | * @param {*} clipImgBase64
181 | */
182 | print(clipImgBase64, options) {
183 | var that = this;
184 | //打印dom外壳创建
185 | var div = document.createElement("div");
186 |
187 | var clipImg = new Image()
188 | clipImg.src = clipImgBase64;
189 | // clipImg.style = `width:${that.area_width}px;height:${that.area_height}px;`
190 | // 宽大于高 > 则把宽度放到100% 进行等比例缩放 , 高大于宽 > 则把高放到90% (10%预留指北针 和 标题区域) 进行等比例缩放;
191 | if (that.area_width > that.area_height) {
192 | clipImg.style = `width: 100%;
193 | height:auto;
194 | max-width: 100%;
195 | max-height: 100%;`;
196 | } else {
197 | clipImg.style = `width: auto;
198 | height: 90%;
199 | max-width: 100%;
200 | max-height: 100%;`;
201 | }
202 | //添加实际打印图
203 | div.appendChild(clipImg);
204 | //获取 cesium-navigation 插件,目的将指北针拼接打印
205 | //此处获取 指北针dom元素进行 拼接打印
206 | let isAddCompass =
207 | options.isAddCompass === undefined || options.isAddCompass === null
208 | ? that.defaultAddCompass
209 | : options.isAddCompass;
210 |
211 | if (navigationDom.length && isAddCompass) {
212 | html2canvas(navigationDom[0], {
213 | scale: 1,
214 | allowTaint: false,
215 | logging: true,
216 | useCORS: true
217 | }).then(canvas => {
218 | let img = canvas.toDataURL("image/jpeg")
219 | img = img.replace('data:image/jpeg;base64,', '')
220 | let finalImageSrc = 'data:image/jpeg;base64,' + img
221 | var clipImg1 = new Image()
222 | clipImg1.src = finalImageSrc;
223 | clipImg1.style = "position: absolute;right: 0px;top: 0px;width:8%;height:auto;";
224 | //打印壳子添加指北针图
225 | div.appendChild(clipImg1);
226 | that.printCustomSize(div, options);
227 | });
228 | } else {
229 | that.printCustomSize(div, options);
230 | }
231 | },
232 | printCustomSize(div, options) {
233 | // 高 宽
234 | // A0:1189mm * 841mm
235 | // A1:841mm * 594mm
236 | // A2:594mm * 420mm
237 | // A3:420mm * 297mm
238 | // A4:297mm * 210mm
239 |
240 | // 页边距: 0.75 inch
241 |
242 | // A1: 23.39x33.11 inch
243 | // 打印机DPI:300DPI
244 | // 屏幕DPI : 96DPI
245 | // width = (23.39 - 0.75 * 2) * 96 = 2101 px
246 | // height = (33.11 - 0.75 * 2)* 96 = 3034 px
247 |
248 | // A4: 8.27x11.69 inch
249 | // 打印机DPI:300DPI
250 | // 屏幕DPI : 96DPI
251 | // width = (8.27 - 0.75 * 2) * 96 = 650 px
252 | // height = (11.69 - 0.75 * 2)* 96 = 978 px
253 |
254 | // 所以,当 的width=650px, height=978px时,用IE 打印时,刚好能打印一页的A4纸.
255 |
256 | //a1横向打印尺寸
257 | // var a1 = { width: "3034", height: "2101" };
258 | //a4横向打印尺寸
259 | var a4 = { width: "978", height: "650" };
260 | if (typeof options.downLoadEnable !== 'boolean') {
261 | options.downLoadEnable = true;
262 | }
263 | var pageWidth = options.width || a4.width,
264 | pageHeight = options.height || a4.height,
265 | title = options.title || 'printTitle',
266 | downLoadEnable = options.downLoadEnable,
267 | fontSize = options.fontSize || '28';
268 | div.style = `width: ${pageWidth}px;
269 | height: ${pageHeight}px;
270 | display: flex;
271 | flex-direction: column;
272 | align-items: center;
273 | justify-content: center;
274 | position: relative;`;
275 | var h1 = document.createElement('h1')
276 | h1.innerHTML = title;
277 | h1.style = `font-size:${fontSize}px;margin:10px 0;text-align:center;width:100%;`;
278 | div.insertBefore(h1, div.firstChild);
279 |
280 | if (downLoadEnable) {
281 | this.downLoadFile(div, title, pageWidth, pageHeight);
282 | } else {
283 | // 打印文档
284 | $(div).print({
285 | globalStyles: false,
286 | width: pageWidth,
287 | height: pageHeight,
288 | });
289 | }
290 | },
291 | downLoadFile(obj, filename, pageWidth, pageHeight) {
292 | var that = this;
293 | return new Promise((resolve, reject) => {
294 | document.body.appendChild(obj);
295 | html2canvas(obj).then(canvas => {
296 | //删除画笔区域
297 | document.body.removeChild(obj);
298 | var base64Img = canvas.toDataURL("image/png"); //base64数据
299 | //打印下载后的图片
300 | var printImgObj = new Image()
301 | printImgObj.src = base64Img;
302 | printImgObj.style = `width: ${pageWidth}px;height: ${pageHeight}px;`
303 | printImgObj.onload = function () {
304 | $(this).print({
305 | width: pageWidth,
306 | height: pageHeight,
307 | globalStyles: false,
308 | });
309 | }
310 | resolve(true)
311 | //由于base64过长,转blob进行a标签下载
312 | that.dataURIToBlob(base64Img, function (blob) {
313 | var a = document.createElement('a');
314 | a.download = filename + '.png';
315 | a.innerHTML = 'download';
316 | // the string representation of the object URL will be small enough to workaround the browser's limitations
317 | a.href = URL.createObjectURL(blob);
318 |
319 | // you must revoke the object URL,
320 | // but since we can't know when the download occured, we have to attach it on the click handler..
321 | // a.onclick = function () {
322 | // // ..and to wait a frame
323 | // requestAnimationFrame(function () {
324 | // URL.revokeObjectURL(a.href);
325 | // });
326 | // a.removeAttribute('href')
327 | // };
328 |
329 | var event = document.createEvent('MouseEvents');
330 | event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
331 | a.dispatchEvent(event);
332 | });
333 |
334 |
335 |
336 | });
337 | })
338 |
339 | },
340 | // 解决base64文件过大时 图片下载失败问题
341 | // edited from https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob#Polyfill
342 | dataURIToBlob(dataURI, callback) {
343 | var binStr = atob(dataURI.split(',')[1]),
344 | len = binStr.length,
345 | arr = new Uint8Array(len);
346 |
347 | for (var i = 0; i < len; i++) {
348 | arr[i] = binStr.charCodeAt(i);
349 | }
350 |
351 | callback(new Blob([arr]));
352 | }
353 | }
--------------------------------------------------------------------------------
/jquery.min.js:
--------------------------------------------------------------------------------
1 | /*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */
2 | !function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,""],col:[2,""],tr:[2,""],td:[3,""],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/