YUI的佈局dialog

shangyuorg.js

var shangyuorg = function(){
    var dialog, showBtn, layout;
    return {
        init : function(){
          showBtn = new Ext.Button('button', {showtext: "選擇機構",handler: this.showDialog});
        },
        showDialog : function(btn,showtext,personnel,department){ //此處的btn是標識從哪個按鈕點擊觸發的事件
             this.showtext=showtext;
             this.department=department;
             if(!dialog){
                dialog = new Ext.LayoutDialog("shangyu-org-dlg", {  //org-dg爲id
                        modal: false,
                        width: 660,
                        height: 480,
                        shadow: false,
                        minWidth:700,
                        minHeight:500,
                     center: {
                         autoScroll: true
                     },                    
                        east: {
                         split: false,
                         initialSize: 180,
                         minSize: 100,
                         maxSize: 250,
                         titlebar: true,
                         collapsible: true,
                         animate: true
                     }                    
                });
                dialog.moveTo(0,0);//改變彈出框位置
                dialog.addKeyListener(27, dialog.hide, dialog);
                dialog.addButton('確定', shangyuorg.choice, dialog);
                dialog.addButton('取消', dialog.hide, dialog);

                var innerLayout = new Ext.BorderLayout('center', {
                    center: {
                        autoScroll: true
                    },
                    south: {
                        initialSize: 130,
                        autoScroll: false,
                        split: true
                    }
                });
                layout = dialog.getLayout();
            }
            dialog.show(btn);
        },
       
                choice : function(){
         var text = Ext.get(shangyuorg.showtext).dom;  //此處的showtext是定義自showDialog這個方法裏面
         alert(text);
         alert(Ext.get(shangyuorg.department).dom);
         dialog.hide();
        } 
    };
}();
//Ext.onReady(org.init, org, true);
 

 

shangyu_org.html:

<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  <title>tree</title>
  <!-- 導入公用包 -->
  <link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
  <link rel="stylesheet" type="text/css" href="resources/css/ytheme-aero.css" />
  <script type="text/javascript" src="yui-utilities.js"></script>
  <script type="text/javascript" src="ext-yui-adapter.js"></script>
  <script type="text/javascript" src="ext-all.js"></script>

  
               <script type="text/javascript" src="shangyuorg.js"></script>
  
  

 </head>
 <body>
  <!-- dialog-->
     <div id="shangyu-org-dlg" style="visibility:hidden;">        <!--id對應org.js中定義的org-dlg-->
      <div class="x-dlg-hd">選擇機構1</div>         <!--彈出窗口顯示的標題-->
      <div class="x-dlg-bd">
       <div id="center" class="x-layout-inactive-content" style="overflow:auto; height:100%; width:100%;">
     <!-- orgtree -->
         
       </div>
      
        <!-- grid -->
       <div id="south" class="x-layout-inactive-content">
    
       </div>
      
       <div id="east" class="x-layout-inactive-content" style="overflow:auto; height:100%; width:100%;">
    
           </div>
       </div>
      </div>
  </div>
     <br><br>

     <input type="button" id="select1" value="選擇部門和人員" onClick="shangyuorg.showDialog(this,choice_text,choice_personnel,choice_department)">
  <br>
  名稱:<br><textarea cols="50" name="choice_text" rows="3"></textarea><br>
  人員ID:<br><textarea cols="50" name="choice_personnel" rows="3"></textarea><br>
  部門ID:<br><textarea cols="50" name="choice_department" rows="3"></textarea>

 </body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章