/**打印预览或另存为PDF功能,需要依赖:*../plugin/printThis.js*/;(function ( global, base_factory ) { 'use strict'; if ( typeof define !== 'undefined' && define.amd ) { //exportasAMD...define(['jquery','GooFlow'],base_factory);}elseif(typeofmodule!=='undefined'&&module.exports){// ...or as browserifybase_factory(require('jquery'),require('GooFlow'));}elsebase_factory(global.$,global.GooFlow);}(typeofwindow!=='undefined'?window:this,function($,GooFlow){if(GooFlow.prototype.print&&typeofGooFlow.prototype.print==='function'){return;//防止多次载入}/* * printThis v1.12.2 * @desc Printing plug-in for jQuery * @author Jason Day * 精简版 only for GooFlow */(function($){functionappendContent($el,content){if(!content)return;// Simple test for a jQuery element$el.append(content.jquery?content.clone():content);}functionappendBody($body,$element,opt){// Clone for safety and convenience// Calls clone(withDataAndEvents = true) to copy form values.var$content=$element.clone();if(opt.printContainer){// grab $.selector as container$content.appendTo($body);}else{// otherwise just print interior elements of container$content.each(function(){$(this).children().appendTo($body)});}}varopt;$.fn.printThis=function(options){opt=$.extend({},$.fn.printThis.defaults,options);var$element=thisinstanceofjQuery?this:$(this);varstrFrameName="printThis-"+(newDate()).getTime();if(window.location.hostname!==document.domain&&navigator.userAgent.match(/msie/i)){// Ugly IE hacks due to IE not inheriting document.domain from parent// checks if document.domain is set by comparing the host name against document.domainvariframeSrc='javascript:document.write("<head><script>document.domain="'+document.domain+'";</script></head><body></body>")';varprintI=document.createElement('iframe');printI.name="printIframe";printI.id=strFrameName;printI.className="MSIE";document.body.appendChild(printI);printI.src=iframeSrc;}else{// other browsers inherit document.domain, and IE works if document.domain is not explicitly setvar$frame=$("<iframe id='"+strFrameName+"' name='printIframe' />");$frame.appendTo("body");}var$iframe=$("#"+strFrameName);// show frame if in debug modeif(!opt.debug)$iframe.css({position:"absolute",width:"0px",height:"0px",left:"-600px",top:"-600px"});// $iframe.ready() and $iframe.load were inconsistent between browserssetTimeout(function(){// Add doctype to fix the style difference between printing and renderfunctionsetDocType($iframe,doctype){varwin,doc;win=$iframe.get(0);win=win.contentWindow||win.contentDocument||win;doc=win.document||win.contentDocument||win;doc.open();doc.write(doctype);doc.close();}if(opt.doctypeString){setDocType($iframe,opt.doctypeString);}var$doc=$iframe.contents(),$head=$doc.find("head"),$body=$doc.find("body"),$base=$('base'),baseURL;$body.css({height:'auto',margin:'0',padding:'0',background:'#fff'});// add base tag to ensure elements use the parent domainif(opt.base===true&&$base.length>0){// take the base tag from the original pagebaseURL=$base.attr('href');}elseif(typeofopt.base==='string'){// An exact base string is providedbaseURL=opt.base;}else{// Use the page URL as the basebaseURL=document.location.protocol+'//'+document.location.host;}$head.append('<base href="'+baseURL+'">');$("link[rel=stylesheet]").each(function(){varhref=$(this).attr("href");if(href){varmedia=$(this).attr("media")||"all";$head.append("<link type='text/css' rel='stylesheet' href='"+href+"' media='"+media+"'>");}});// add title of the pageif(opt.pageTitle)$head.append("<title>"+opt.pageTitle+"</title>");// print headerappendContent($body,opt.header);appendBody($body,$element,opt);// print "footer"appendContent($body,opt.footer);setTimeout(function(){if($iframe.hasClass("MSIE")){// check if the iframe was created with the ugly hack// and perform another ugly hack out of neccessitywindow.frames["printIframe"].focus();$head.append("<script> window.print(); </s"+"cript>");}else{// proper methodif(document.queryCommandSupported("print")){$iframe[0].contentWindow.document.execCommand("print",false,null);}else{$iframe[0].contentWindow.focus();$iframe[0].contentWindow.print();}}// remove iframe after printif(!opt.debug){setTimeout(function(){$iframe.remove();},1000);}},opt.printDelay);},333);};// defaults$.fn.printThis.defaults={debug:false,// show the iframe for debuggingprintContainer:true,// print outer container/$.selectorpageTitle:"",// add title to print pageprintDelay:333,// variable print delayheader:null,// prefix to htmlfooter:null,// postfix to htmlbase:false,// preserve the BASE tag, or accept a string for the URLdoctypeString:'<!DOCTYPE html>'// html doctype};})($);////////////////printThis.js END!//扩展定义打印预览或另存为PDF功能的方法GooFlow.prototype.print=function(scale){varmax=this._suitSize();if(!scale)scale=1.0;max.width+=100;max.height+=100;varprintDiv=this.$workArea.clone();printDiv.css({width:max.width+"px",height:max.height+"px"});printDiv.children(".GooFlow_work_group").css({width:max.width+"px",height:max.height+"px"});printDiv.children("svg").css({width:max.width+"px",height:max.height+"px"});printDiv.children(".GooFlow_work_vml").css({width:max.width+"px",height:max.height+"px"});printDiv=printDiv.wrap('<div class="GooFlow GooFlow_work" style="width:'+max.width+'px;height:'+max.height+'px; overflow:hidden"></div>').parent();if(GooFlow.color.font){printDiv.css("color",GooFlow.color.font);}printDiv.css({"transform-origin":"top left",transform:"scale("+scale+")"}).printThis({base:document.URL,pageTitle:this.$title});};returnGooFlow;}));