
GeoExt.Lang.add("ru",{"GeoExt.ux.PrintPreview.prototype":{paperSizeText:"Размер листа:",resolutionText:"Разрешение:",formatText:"Формат:",printText:"Печать",emptyTitleText:"Заголовок:",includeLegendText:"Печать легенды",emptyCommentText:"Комментарии:",creatingPdfText:"Создание карты..."}});Ext.namespace("GeoExt.ux");GeoExt.ux.PrintPreview=Ext.extend(Ext.Container,{printProvider:null,sourceMap:null,printMapPanel:null,mapTitleField:"mapTitle",commentField:"comment",legend:null,includeLegend:false,mapTitle:null,comment:null,addMapOverlay:true,busyMask:null,form:null,commentForm:null,autoEl:"center",cls:"x-panel-body x-panel-body-noheader",initComponent:function(){var printMapPanelOptions={sourceMap:this.sourceMap,printProvider:this.printProvider};if(this.printMapPanel){if(!(this.printMapPanel instanceof GeoExt.PrintMapPanel)){printMapPanelOptions.xtype="gx_printmappanel"
this.printMapPanel=new GeoExt.PrintMapPanel(Ext.applyIf(this.printMapPanel,printMapPanelOptions));}}else{this.printMapPanel=new GeoExt.PrintMapPanel(printMapPanelOptions);}
this.sourceMap=this.printMapPanel.sourceMap;this.printProvider=this.printMapPanel.printProvider;this.form=this.createForm();this.commentForm=this.createCommentForm();if(!this.items){this.items=[];}
this.items.push(this.createToolbar(),{xtype:"container",cls:"gx-printpreview",autoHeight:this.autoHeight,autoWidth:this.autoWidth,items:[this.form,this.printMapPanel,this.commentForm]});GeoExt.ux.PrintPreview.superclass.initComponent.call(this);this.addMapOverlay&&this.printMapPanel.add(this.createMapOverlay());this.printMapPanel.on({"resize":this.updateSize,scope:this});this.on({"render":function(){if(!this.busyMask){this.busyMask=new Ext.LoadMask(this.getEl(),{msg:locale.labels.printPreview.creatingMapText+"..."});var interval=window.setInterval(function(){if($('.olControlZoomOutItemInactive')){$(".olControlZoomOutItemInactive").css("margin",0);$(".olControlZoomOutItemInactive").css("border",0);$(".olControlZoomOutItemInactive").css("background","url("+OVROOT+"/externals/ext/resources/images/gray/panel/tool-sprites.gif)");$(".olControlZoomOutItemInactive").css("background-position","15px -255px");window.clearInterval(interval);}},200);}
this.printProvider.on({"beforeprint":this.busyMask.show,"print":this.busyMask.hide,"printexception":this.busyMask.hide,scope:this.busyMask});},scope:this});},createToolbar:function(){var items=[];this.printProvider.layouts.getCount()>1&&items.push(locale.labels.printPreview.sheetSizeText,{xtype:"combo",width:98,plugins:new GeoExt.plugins.PrintProviderField({printProvider:this.printProvider}),store:this.printProvider.layouts,displayField:"name",typeAhead:true,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true},"&nbsp;");this.printProvider.dpis.getCount()>1&&items.push(locale.labels.printPreview.resolutionText+":",{xtype:"combo",width:62,plugins:new GeoExt.plugins.PrintProviderField({printProvider:this.printProvider}),store:this.printProvider.dpis,displayField:"name",tpl:'<tpl for="."><div class="x-combo-list-item">{name} dpi</div></tpl>',typeAhead:true,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,setValue:function(v){v=parseInt(v)+" dpi";Ext.form.ComboBox.prototype.setValue.apply(this,arguments);}},"&nbsp;");this.printProvider.formats.getCount()>1&&items.push(locale.labels.printPreview.formatText+":",{xtype:"combo",width:45,plugins:new GeoExt.plugins.PrintProviderField({printProvider:this.printProvider}),store:this.printProvider.formats,displayField:"name",typeAhead:true,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true},"&nbsp;");items.push("->",{text:locale.labels.printPreview.printText,iconCls:"icon-print",handler:function(){this.printMapPanel.print(this.includeLegend&&{legend:this.legend});},scope:this});return{xtype:"toolbar",items:items};},createForm:function(){var titleCfg={xtype:"textfield",name:this.mapTitleField,value:this.mapTitle,emptyText:locale.labels.printPreview.titleText+":",margins:"0 5 0 0",flex:1,anchor:"100%",hideLabel:true,plugins:new GeoExt.plugins.PrintProviderField({printProvider:this.printProvider})};if(this.legend){var legendCheckbox=new Ext.form.Checkbox({name:"legend",checked:this.includeLegend,boxLabel:locale.labels.printPreview.includeLegendText,hideLabel:true,ctCls:"gx-item-nowrap",handler:function(cb,checked){this.includeLegend=checked;},scope:this});}
return new Ext.form.FormPanel({autoHeight:true,border:false,defaults:{anchor:"100%"},items:[this.legend?{xtype:"container",layout:"hbox",cls:"x-form-item",items:[titleCfg,legendCheckbox]}:titleCfg]});},createCommentForm:function(){return new Ext.form.FormPanel({autoHeight:true,border:false,bodyStyle:"margin:5px 0 0 0",defaults:{anchor:"100%"},items:[{xtype:"textarea",name:this.commentField,value:this.comment,emptyText:locale.labels.printPreview.commentText,hideLabel:true,plugins:new GeoExt.plugins.PrintProviderField({printProvider:this.printProvider})}]});},createMapOverlay:function(){return new Ext.Panel({cls:"gx-map-overlay",layout:"column",width:110,bodyStyle:"padding:5px",items:[{xtype:"container",layout:"form",style:"padding: .2em 0 0 0;",columnWidth:1,cls:"x-small-editor x-form-item",items:{xtype:"combo",name:"scale",anchor:"100%",hideLabel:true,store:this.printMapPanel.previewScales,displayField:"name",typeAhead:true,mode:"local",forceSelection:true,triggerAction:"all",selectOnFocus:true,getListParent:function(){return this.el.up(".x-window")||document.body;},plugins:new GeoExt.plugins.PrintPageField({printPage:this.printMapPanel.printPage})}}],listeners:{"render":function(){function stop(evt){evt.stopPropagation();}
this.getEl().on({"click":stop,"dblclick":stop,"mousedown":stop});}}});},updateSize:function(){this.suspendEvents();var mapWidth=this.printMapPanel.getWidth();this.form.setWidth(mapWidth);this.form.items.get(0).setWidth(mapWidth);var minWidth=this.initialConfig.minWidth||0;this.items.get(0).setWidth(this.form.ownerCt.el.getPadding("lr")+Math.max(mapWidth,minWidth));var parent=this.ownerCt;if(parent&&parent instanceof Ext.Window){this.ownerCt.syncShadow();}
this.resumeEvents();},beforeDestroy:function(){if(this.busyMask){this.printProvider.un("beforeprint",this.busyMask.show,this.busyMask);this.printProvider.un("print",this.busyMask.hide,this.busyMask);}
this.printMapPanel.un("resize",this.updateSize,this);GeoExt.ux.PrintPreview.superclass.beforeDestroy.apply(this,arguments);}});Ext.reg("gxux_printpreview",GeoExt.ux.PrintPreview);