source: branches/feature-module-update/html/js/file_manager.js @ 15078

Revision 15078, 6.4 KB checked in by nanasess, 17 years ago (diff)

r15064 から svn cp
とりあえず暫定コミット.

  • UTF-8 に変更
  • slib.php, glib.php のクラス化
  • LC_Page の抽象化(一部)
Line 
1/*
2 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
3 *
4 * http://www.lockon.co.jp/
5 */
6var IMG_FOLDER_CLOSE   = "../../img/admin/contents/folder_close.gif";       // フォルダクローズ時画像
7var IMG_FOLDER_OPEN    = "../../img/admin/contents/folder_open.gif";        // フォルダオープン時画像
8var IMG_PLUS           = "../../img/admin/contents/plus.gif";               // プラスライン
9var IMG_MINUS          = "../../img/admin/contents/minus.gif";              // マイナスライン
10var IMG_NORMAL         = "../../img/admin/contents/space.gif";              // スペース
11
12var tree = "";                      // 生成HTML格納
13var count = 0;                      // ループカウンタ
14var arrTreeStatus = new Array();    // ツリー状態保持
15var old_select_id = '';             // 前回選択していたファイル
16var selectFileHidden = "";          // 選択したファイルのhidden名
17var treeStatusHidden = "";          // ツリー状態保存用のhidden名
18var modeHidden = "";                // modeセットhidden名
19
20// ツリー表示
21function fnTreeView(view_id, arrTree, openFolder, selectHidden, treeHidden, mode) {
22    selectFileHidden = selectHidden;
23    treeStatusHidden = treeHidden;
24    modeHidden = mode;
25   
26    for(i = 0; i < arrTree.length; i++) {
27       
28        id = arrTree[i][0];
29        level = arrTree[i][3];
30       
31        if(i == 0) {
32            old_id = "0";
33            old_level = 0;
34        } else {
35            old_id = arrTree[i-1][0];
36            old_level = arrTree[i-1][3];
37        }
38   
39        // 階層上へ戻る
40        if(level <= (old_level - 1)) {
41            tmp_level = old_level - level;
42            for(up_roop = 0; up_roop <= tmp_level; up_roop++) {
43                tree += '</div>';
44            }
45        }
46       
47        // 同一階層で次のフォルダへ
48        if(id != old_id && level == old_level) tree += '</div>';
49   
50        // 階層の分だけスペースを入れる
51        for(space_cnt = 0; space_cnt < arrTree[i][3]; space_cnt++) {
52            tree += "&nbsp;&nbsp;&nbsp;";
53        }
54
55        // 階層画像の表示・非表示処理
56        if(arrTree[i][4]) {
57            if(arrTree[i][1] == '_parent') {
58                rank_img = IMG_MINUS;
59            } else {
60                rank_img = IMG_NORMAL;
61            }
62            // 開き状態を保持
63            arrTreeStatus.push(arrTree[i][2]);
64            display = 'block';
65        } else {
66            if(arrTree[i][1] == '_parent') {
67                rank_img = IMG_PLUS;
68            } else {
69                rank_img = IMG_NORMAL;
70            }
71            display = 'none';
72        }
73
74        arrFileSplit = arrTree[i][2].split("/");
75        file_name = arrFileSplit[arrFileSplit.length-1];
76
77        // フォルダの画像を選択
78        if(arrTree[i][2] == openFolder) {
79            folder_img = IMG_FOLDER_OPEN;
80            file_name = "<b>" + file_name + "</b>";
81        } else {
82            folder_img = IMG_FOLDER_CLOSE;
83        }
84
85        // 階層画像に子供がいたらオンクリック処理をつける
86        if(rank_img != IMG_NORMAL) {
87            tree += '<a href="javascript:fnTreeMenu(\'tree'+ i +'\',\'rank_img'+ i +'\',\''+ arrTree[i][2] +'\')"><img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">';
88        } else {
89            tree += '<img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">';
90        }
91        tree += '<a href="javascript:fnFolderOpen(\''+ arrTree[i][2] +'\')"><img src="'+ folder_img +'" border="0" name="tree_img'+ i +'" id="tree_img'+ i +'">&nbsp;'+ file_name +'</a><br/>';
92        tree += '<div id="tree'+ i +'" style="display:'+ display +'">';
93   
94    }
95    fnDrow(view_id, tree);
96    //document.tree_form.tree_test2.focus();   
97}
98
99// Tree状態をhiddenにセット
100function setTreeStatus(name) {
101    var tree_status = "";
102    for(i=0; i < arrTreeStatus.length ;i++) {
103        if(i != 0) tree_status += '|';
104        tree_status += arrTreeStatus[i];
105    }
106    document.form1[name].value = tree_status;
107}
108
109// Tree状態を削除する(閉じる状態へ)
110function fnDelTreeStatus(path) {
111    for(i=0; i < arrTreeStatus.length ;i++) {
112        if(arrTreeStatus[i] == path) {
113            arrTreeStatus[i] = "";
114        }
115    }
116}
117// ツリー描画
118function fnDrow(id, tree) {
119    // ブラウザ取得
120    MyBR = fnGetMyBrowser();
121    // ブラウザ事に処理を切り分け
122    switch(myBR) {
123        // IE4の時の表示
124        case 'I4':
125            document.all(id).innerHTML = tree;
126            break;
127        // NN4の時の表示
128        case 'N4':
129            document.layers[id].document.open();
130            document.layers[id].document.write("<div>");
131            document.layers[id].document.write(tree);
132            document.layers[id].document.write("</div>");
133            document.layers[id].document.close();
134            break;
135        default:
136            document.getElementById(id).innerHTML=tree;
137            break;
138    }
139}
140
141// 階層ツリーメニュー表示・非表示処理
142function fnTreeMenu(tName, imgName, path) {
143
144    tMenu = document.all[tName].style;
145
146    if(tMenu.display == 'none') {
147        fnChgImg(IMG_MINUS, imgName);
148        tMenu.display = "block";
149        // 階層の開いた状態を保持
150        arrTreeStatus.push(path);
151
152    } else {
153        fnChgImg(IMG_PLUS, imgName);
154        tMenu.display = "none";
155        // 閉じ状態を保持
156        fnDelTreeStatus(path);
157    }
158}
159
160// ファイルリストダブルクリック処理
161function fnDbClick(arrTree, path, is_dir, now_dir, is_parent) {
162
163    if(is_dir) {
164        if(!is_parent) {
165            for(cnt = 0; cnt < arrTree.length; cnt++) {
166                if(now_dir == arrTree[cnt][2]) {
167                    open_flag = false;
168                    for(status_cnt = 0; status_cnt < arrTreeStatus.length; status_cnt++) {
169                        if(arrTreeStatus[status_cnt] == arrTree[cnt][2]) open_flag = true;
170                    }
171                    if(!open_flag) fnTreeMenu('tree'+cnt, 'rank_img'+cnt, arrTree[cnt][2]);
172                }
173            }
174        }
175        fnFolderOpen(path);
176    } else {
177        // Download
178        fnModeSubmit('download','','');
179    }
180}
181
182// フォルダオープン処理
183function fnFolderOpen(path) {
184
185    // クリックしたフォルダ情報を保持
186    document.form1[selectFileHidden].value = path;
187    // treeの状態をセット
188    setTreeStatus(treeStatusHidden);
189    // submit
190    fnModeSubmit(modeHidden,'','');
191}
192
193
194// 閲覧ブラウザ取得
195function fnGetMyBrowser() {
196    myOP = window.opera;            // OP
197    myN6 = document.getElementById; // N6
198    myIE = document.all;            // IE
199    myN4 = document.layers;         // N4
200    if      (myOP) myBR="O6";       // OP6以上
201    else if (myIE) myBR="I4";       // IE4以上
202    else if (myN6) myBR="N6";       // NS6以上
203    else if (myN4) myBR="N4";       // NN4
204    else           myBR="";         // その他
205       
206    return myBR;
207}
208
209// imgタグの画像変更
210function fnChgImg(fileName,imgName){
211    document.getElementById(imgName).src = fileName;
212}
213
214// ファイル選択
215function fnSelectFile(id, val) {
216    if(old_select_id != '') document.getElementById(old_select_id).style.backgroundColor = '';
217    document.getElementById(id).style.backgroundColor = val;
218    old_select_id = id;
219}
220
221// 背景色を変える
222function fnChangeBgColor(id, val) {
223    if (old_select_id != id) {
224        document.getElementById(id).style.backgroundColor = val;
225    }
226}
227
228// test
229function view_test(id) {
230    document.getElementById(id).value=tree
231}
Note: See TracBrowser for help on using the repository browser.