
Ext.namespace('Ext.ux');

Ext.ux.NumberFieldTrigger = function(config) {
	Ext.ux.NumberFieldTrigger.superclass.constructor.call(this, config);
}

Ext.ux.NumberFieldTrigger = Ext.extend(Ext.form.TriggerField, {

	allowDecimals : Ext.form.NumberField.prototype.allowDecimals,
	allowNegative : Ext.form.NumberField.prototype.allowNegative,

	baseChars : Ext.form.NumberField.prototype.baseChars,
	decimalPrecision : Ext.form.NumberField.prototype.decimalPrecision,
	decimalSeparator : Ext.form.NumberField.prototype.decimalSeparator,
	fieldClass : Ext.form.NumberField.prototype.fieldClass,
	maxText : Ext.form.NumberField.prototype.maxText,
	maxValue : Ext.form.NumberField.prototype.maxValue,
	minText : Ext.form.NumberField.prototype.minText,
	minValue : Ext.form.NumberField.prototype.minValue,
	nanText : Ext.form.NumberField.prototype.nanText,

	beforeBlur : Ext.form.NumberField.prototype.beforeBlur,
	fixPrecision : Ext.form.NumberField.prototype.fixPrecision,
	getValue : Ext.form.NumberField.prototype.getValue,
	initEvents : Ext.form.NumberField.prototype.initEvents,
	parseValue : Ext.form.NumberField.prototype.parseValue,
	setValue : Ext.form.NumberField.prototype.setValue,
	validateValue : Ext.form.NumberField.prototype.validateValue,
	
	initComponent : Ext.form.TwinTriggerField.prototype.initComponent,
	getTrigger : Ext.form.TwinTriggerField.prototype.getTrigger,
	initTrigger    : Ext.form.TwinTriggerField.prototype.initTrigger,
	trigger1Class    :    'x-form-UP-trigger',
//	hideTrigger1 : true ,
	trigger2Class    :    'x-form-trigger',
	//triggerClass : 'x-form-clear-trigger',
	hideTrigger : false,

	onTrigger2Click : function(a,z,cd,sf,f,gt,u) {
		
		this.setValue(this.getValue()-32)
		

	},
	onTrigger1Click : function(){ 
        this.setValue(this.getValue()+32)
      } 

});




Ext.onReady(function (){
					  
					  
	Ext.QuickTips.init();
	Ext.form.Field.prototype.msgTarget = 'side';
	
	Ext.BLANK_IMAGE_URL = "../../../multimedia/ext/resources/images/default/s.gif"  ;
	
	
	var formtag = new Ext.ux.NumberFieldTrigger(
												 {fieldLabel:"Height",//文本框标
												  
												  name:"ch3",
												  id:"Formh",
												  labelSeparator: ':',
												  minValue : rule.section.h.Rmin,
												  maxValue : rule.section.h.Rmax,
												  //minText : '允许最小值为'+rule.section.h.Rmin,
												  //maxText : '允许最大值为'+rule.section.h.Rmax,
												  allowDomMove:true ,
												  allowBlank: false,
												  allowDecimals: false, // 允许小数点
												  allowNegative: false, // 允许负数
												  invalidText:'您输入的数字必须符合生产加工模数',
												  validator: function (_value){
													  	return mode32(_value,offset)
													  }
												
												})

	  
    
////form1
    var fp = new Ext.FormPanel({
        frame: true,
       // title:'安装方式',
        labelWidth: 70,
		width: 200,
		//baseCls: 'x-plain',
       	renderTo:'basicset',
        bodyStyle: 'padding:0 10px 0;',
        layout : "fit",	
		buttonAlign:'center',
		items: [{
            	//baseCls: 'x-plain',
				xtype:'fieldset',
				title: 'Basic Setting',
				autoHeight: true,
				//checkboxToggle:true,
				collapsible: true,
				//collapsed: true,
				
				items: [
					{
					  fieldLabel:"Width",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"w",
					  id:"boxw",
					  minValue : rule.boxSize.w.Rmin,
					  maxValue : rule.boxSize.w.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.w.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.w.Rmax,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},{
					  fieldLabel:"Height",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"h",
					  id:"boxh",
					  labelSeparator: ':',
					  minValue : rule.boxSize.h.Rmin,
					  maxValue : rule.boxSize.h.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.h.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.h.Rmax,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},{
					  fieldLabel:"Depth",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"d",
					  id:"boxd",
					  labelSeparator: ':',
					  minValue : rule.boxSize.d.Rmin,
					  maxValue : rule.boxSize.d.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.d.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.d.Rmax,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					}
					/*,{xtype: 'radiogroup',
						  fieldLabel: '第七扇门',
						  items: [
							  {boxLabel: '前滑轨', name: 'hg7', inputValue: 1},
							  {boxLabel: '后滑轨', name: 'hg7', inputValue: 0}// checked: true
		  
						  ]
				   
					  }*/
				
				
					]
      		  },{
            	//baseCls: 'x-plain',
				xtype:'fieldset',
				title: 'Fill Setting',
				autoHeight: true,
				//checkboxToggle:true,
				collapsible: true,
				//collapsed: true,
				items: [
					{
					  fieldLabel:"Left Fill",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"ud17",
					  id:"boxLfill",
					  labelSeparator: ':',
					  minValue : rule.boxSize.fill.Rmin,
					  maxValue : rule.boxSize.fill.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.fill.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.fill.Rmax,
					  //allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},{
					  fieldLabel:"Right Fill",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"ud18",
					  id:"boxRfill",
					  labelSeparator: ':',
					  minValue : rule.boxSize.fill.Rmin,
					  maxValue : rule.boxSize.fill.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.fill.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.fill.Rmax,
					  //allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},{
					  fieldLabel:"Top Fill",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"h3",
					  id:"boxTfill",
					  labelSeparator: ':',
					  minValue : rule.boxSize.Tfill.Rmin,
					  maxValue : rule.boxSize.Tfill.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.Tfill.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.Tfill.Rmax,
					  //allowBlank: false,
					  allowDecimals: false, // 允许小数点
					  allowNegative: false // 允许负数
		  
					}/*,{
						  xtype: 'radiogroup',
						  fieldLabel: '第七扇门',
						  items: [
							  {boxLabel: '前滑轨', name: 'hg7', inputValue: 1},
							  {boxLabel: '后滑轨', name: 'hg7', inputValue: 0}// checked: true
		  
						  ]
				   
					  }*/
				
				
				]
     		   },{
            	//baseCls: 'x-plain',
				name:"ANMOD",
				id:"ANMOD",
				//itemId :"ANMOD",
				xtype:'fieldset',
				title: 'Collision',
				autoHeight: true,
				checkboxToggle:true,
				//collapsible: true,
				//collapsed: true,
				items: [
					{
					  fieldLabel:"Front Collision",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"ud1",
					  id:"Fclear",
					  labelSeparator: ':',
					  minValue : rule.boxSize.Fclear.Rmin,
					  maxValue : rule.boxSize.Fclear.Rmax,
					  //minText : '允许最小值为'+rule.boxSize.Fclear.Rmin,
					  //maxText : '允许最大值为'+rule.boxSize.Fclear.Rmax,
					  //allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					}
				
				
				]
    		    }
		],
        
        buttons: [{
            text: 'Ok',
            handler: function(){
				var _newvar={},_oldvar={}
				var _formValue=fp.getForm().getValues()
				_oldvar.h=Pvar.boxSize.h
				_oldvar.d=Pvar.boxSize.d
				_newvar.h=_formValue.h
				_newvar.d=_formValue.d
				
				
               if(fp.getForm().isValid()){
				   //var ANVar=fp.getForm().getValues(true).split(/&/g);
				   var ANVar=fp.getForm().getValues(true).replace(/&/g,';');
				   
				   setFormToPvar(_formValue ,FormRelPvar)
				   syncSectionHD(_newvar,_oldvar)
				   updata(	 ANVar)
/*                    Ext.Msg.alert('Submitted Values', 'The following will be sent to the server: <br />'+ 
                        fp.getForm().getValues(true).replace(/&/g,', '));*/
                }else{
					Ext.Msg.alert('prompt', 'data is error！')
					
					}
            }
        },{
            text: 'Cancel',
            handler: function(){
				fp.getForm().setValues(getPvarToFrom(FormRelPvar))
                //fp.getForm().reset();
            }
        }]
    });


//////大窗体
  view=new Ext.Viewport({ 
         enableTabScroll:true, 
         layout:"border", 
         items:[ 
            { 
                 title:'',
				 region:'center',
				  layout : "fit",
				 //contentEl: 'CDiv',
				 items: [
						 {	xtype : "tabpanel",
							 activeTab:0,
						 	items : [
									 {	xtype : "panel",
									 	title : "Basic setting",
										id:"az",
										layout : "fit",
										//contentEl:'anzhuang',
										items: [fp],
										//html:fp,
										autoScroll: true,
										listeners:{
											"activate":function() {   
								                                    //aa
																	fp.getForm().setValues(getPvarToFrom(FormRelPvar))
																	//fp.setValues(tt[boxw.id]);   
																	//alert(11)
											},
											deactivate:function (a,b,c,s,d,f,g,h){
												
													//alert(1111)
												}
										}
									 },
									 {	xtype : "panel",
									 	frame: true,
										id:"Section_Panel",
									 	title : "Section Setting",
										contentEl:'Section_she',
										//bodyStyle: 'padding:0px 10px 0;',
										autoScroll: true,
										listeners:{
											"activate":function(_obj) {   
								                                   var _Psize=_obj.getSize()
																   
																   initPsize(_Psize.width-container.Rw,_Psize.height-container.Rh);
																	sectionInit()
											}
										},bbar:[
												{xtype:"tbtext",
											  text:'Attention：Double click elevation section adjust section size!',
											  style: 'color: #F00;',
											  pressed : false
											  
											}
												
												]

									  },
									 {	xtype : "panel",
									 	title : "Help",
										layout : "fit",
										//autoLoad :{ url: '帮助说明.htm'} ,
										//url:'帮助说明.htm',
										 html:' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="移门录像/移门录像_demo.htm"> </iframe>',
										autoScroll: true
										
									 }
									 ]
						}
						],
				 
				 				
				tbar:[ 
				  {xtype:"tbtext",
					text:'Number of Section :'
				  },
				{
					text:"",
					xtype : "combo",
					store: [1,2,3,4,5,6,7],
					typeAhead: false,
					mode: 'local',
					triggerAction: 'all',
					emptyText:'Please select...',
					width:80,
					minChars:4,
					editable:false,
					listeners :{
							select : function (_combo,_record,_index){
								
										Pvar.ncfg=_record.data.field1;
										try {
										var _Psize=Ext.get("Section_Panel").getSize()
										
										initPsize(_Psize.width-container.Rw,_Psize.height-container.Rh);
										sectionInit()
										}catch(err)
											{
											
											}

										updata("ncfg="+Pvar.ncfg)
										/*updata("nfd1="+_record.data.field1)
										
										 
										
										for (var i=0; i<7 ; i++){
											var fpp=fp.findByType("radiogroup")[i].getEl().up('.x-form-item');
											fpp.setVisibilityMode(Ext.Element.DISPLAY);
											if (i>=_record.data.field1){
												fpp.hide();
											}else{
												fpp.show();
												}
											 
										 var radioval=doordefset[_record.data.field1].substring(i,(i+1))
										// alert(radioval)
										fp.findByType("radiogroup")[i].setValue( ("hg"+(1+i)),radioval);
		//								 Ext.MessageBox.alert(doordefset[_record.data.field1].substring(i,i+1));
										
										} */
									
									//debuger;
									}
						
						}
				
				} 
			 ]// ,bbar
				 
				/*bbar:[
					  {xtype:"tbtext",
					text:'注意：设计移门时请打开移门及抽屉检查碰撞情况。',
					style: 'color: #F00;',
					pressed : false
					
				  }
					  
					  ]*/
                
               
             } 
         ] 

		})
  
  
  
  	//////气球		
/*	var _tip = new Ext.slider.Tip({
        getText: function(thumb){
            return String.format('<b>{0} 宽</b>', thumb.value);
        }
    });*/
	

	//滚动条
/*   slider = new Ext.Slider({
        renderTo: 'multi-slider-horizontal',
        width   : 600,
        minValue: 0,
        maxValue: boxSize.Sw,
        values  : VSection.w.slide,
		decimalPrecision:0,
		keyIncrement:50, 
		clickToChange: false,
        plugins : _tip,
		listeners:{
					dragend :	function(s,e){
							
							_Sdata=s.getValues()
							_Cw=0
							
							for(i=0;i<maxncfg;i++){
								var _Unit=Ext.get("basic"+i)
								if(i<_Sdata.length){
									
									_Unit.setWidth((_Sdata[i]-_Cw)/boxSize._Wbi,true);
									_Unit.dom.innerHTML="宽"+(_Sdata[i]-_Cw)+"<BR>"+"高"+_UnitSize.Sh
									_Cw=_Sdata[i]
								
								}else if (i==_Sdata.length){
									
									_Unit.setWidth((boxSize.Sw-_Cw)/boxSize._Wbi,true);
									_Unit.dom.innerHTML="宽"+(boxSize.Sw-_Cw)+"<BR>"+"高"+_UnitSize.Sh
								}else {
									_Unit.setWidth(0,false);
									_Unit.dom.innerHTML=""	
								}
							}
							
							
						}
					}	
    });*/

	///弹出窗体
			  Sectionform = new Ext.form.FormPanel({
			  baseCls: 'x-plain',
			  //frame: true,
			  //defaultType: 'textfield',
			  labelWidth: 70,
			  width: 400,
	  
			  items: [
					{
					  fieldLabel:"Auto calculate the width",//文本框标
					  xtype:"checkbox",//表单文本框
					  name:"Wauto",
					  id:"FormwAuto",
					  labelSeparator: ':',
					  //checked:true,
					  listeners:{
						  check :function (_this,_checked){
							  var _Formw=Sectionform.findById("Formw")
							  if(_checked){
								 _Formw.disable()
								 _Formw.setValue("")
								  
							  }else{
								  _Formw.enable()
								  _Formw.setValue(Pvar.sectionSize[VSection.controlId].w)
							  }
							  	
							  }
						  }
					},{fieldLabel:"Width",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"cfw2",
					  id:"Formw",
					  minValue : rule.section.w.Rmin,
					  maxValue : rule.section.w.Rmax,
					  //minText : '允许最小值为'+rule.section.w.Rmin,
					  //maxText : '允许最大值为'+rule.section.w.Rmax,
					  //allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},/*{
					  fieldLabel:"高　　度",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"ch3",
					  id:"Formh",
					  labelSeparator: ':',
					  minValue : rule.section.h.Rmin,
					  maxValue : rule.section.h.Rmax,
					  minText : '允许最小值为'+rule.section.h.Rmin,
					  maxText : '允许最大值为'+rule.section.h.Rmax,
					  allowDomMove:true ,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false, // 允许负数
					  hideTrigger : false//
					},*/formtag,{
					  fieldLabel:"Depth",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"cfd1",
					  id:"Formd",
					  labelSeparator: ':',
					  minValue : rule.section.d.Rmin,
					  maxValue : rule.section.d.Rmax,
					  //minText : '允许最小值为'+rule.section.d.Rmin,
					  //maxText : '允许最大值为'+rule.section.d.Rmax,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					},{
					  fieldLabel:"Back clearance",//文本框标
					  xtype:"numberfield",//表单文本框
					  name:"cfd2",
					  id:"Formhkj",
					  labelSeparator: ':',
					  minValue : rule.section.bc.Rmin,
					  maxValue : rule.section.bc.Rmax,
					  //minText : '允许最小值为'+rule.section.bc.Rmin,
					  //maxText : '允许最大值为'+rule.section.bc.Rmax,
					  allowBlank: false,
				      allowDecimals: false, // 允许小数点
  					  allowNegative: false // 允许负数
					}]
		  });


		  Sectionwindow = new Ext.Window({
			  title: 'Section Setting',
			  width: 300,
			  height:250,
			  minWidth: 300,
			  minHeight: 250,
			  //layout: 'fit',
			  plain:true,
			  closeAction : 'hide',
			  bodyStyle:'padding:5px;',
			  buttonAlign:'center',
			  items: Sectionform,
	  		  listeners:{
					show:function (){
						
							Sectionwindow.setTitle("NO."+(1+parseInt(VSection.controlId))+"Section Setting")
							Sectionform.getForm().setValues(getSectionVar (VSection.controlId))
						}
			  },
			  buttons: [{
				  text: 'Ok',
				  handler:function (){
						
							
							setSectionVar (VSection.controlId)
							var _Psize=Ext.get("Section_Panel").getSize()
							initPsize(_Psize.width-container.Rw,_Psize.height-container.Rh);
							sectionInit()
							Sectionwindow.hide()
						}
			 	
			  },{
				  text: 'Cancel',
				  handler:function (){
						
							
							Sectionform.getForm().setValues(getSectionVar (VSection.controlId))
						}
			  }]
		  });
			
////////初始化

//sectionInit();


	//设置默认值
var topcombo=view.items.items[0].topToolbar.findByType("combo");
topcombo[0].setValue(Pvar.ncfg);
//aa
//slider.setValue([100,200,300,400,500,600],true)
//topcombo[1].setValue(dcn.num[0]);
//topcombo[1].fireEvent("select");
			
////////取消屏幕遮罩			
document.getElementById('loading-mask').style.display = 'none';
document.getElementById('loading').style.display = 'none';




})

