发新话题
打印

jatoolsPrinter 的 jquery 插件

jatoolsPrinter 的 jquery 插件

var jatools = { jobs: [] } function jatoolsPrinter() { if ($('#_jatoolsPrinter').length == 0) $('').appendTo($('body')); this.cached = false; this.print = function (cfg, prompt) { if (_jatoolsPrinter && typeof(_jatoolsPrinter.print) != 'undefined') { _jatoolsPrinter.print(this.normalize(cfg)); } else { this.cache(cfg); setTimeout("jatools.jobs[" + cfg.index + "].jatoolsPrinter.print(jatools.jobs[" + cfg.index + "]," + (prompt == true) + ")", 50); } } this.cache = function (cfg) { if (!this.cached) { this.cached = true; jatools.jobs.push(cfg); cfg.jatoolsPrinter = this; cfg.index = jatools.jobs.length - 1; } } this.normalize = function (cfg) { var _pages = [], pages = cfg.pages; if (pages.length == 0) throw '请正确指定要打印的内容!'; pages.each(function (e, it) { _pages.push(it); }) var result = { pages: _pages, settings: cfg, autoBreakPage: true, documents: document, copyrights: '杰创软件拥有版权 www.jatools.com' }; return result; } this.printPreview = function (cfg) { if (_jatoolsPrinter && typeof(_jatoolsPrinter.printPreview) != 'undefined') { _jatoolsPrinter.printPreview(this.normalize(cfg)); } else { this.cache(cfg); setTimeout("jatools.jobs[" + cfg.index + "].jatoolsPrinter.printPreview(jatools.jobs[" + cfg.index + "])", 50); } } }

TOP

发新话题