source: branches/version-2_5-dev/html/user_data/packages/admin/js/file_manager.js @ 19909

Revision 19909, 6.3 KB checked in by uemoto, 13 years ago (diff)

#382(管理画面XHTMLに変更)

  • デザインを刷新
Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved.
5 *
6 * http://www.lockon.co.jp/
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23var tree = "";                      // 生成HTML格納
24var count = 0;                      // ループカウンタ
25var arrTreeStatus = new Array();    // ツリー状態保持
26var old_select_id = '';             // 前回選択していたファイル
27var selectFileHidden = "";          // 選択したファイルのhidden名
28var treeStatusHidden = "";          // ツリー状態保存用のhidden名
29var modeHidden = "";                // modeセットhidden名
30
31// ツリー表示
32function fnTreeView(view_id, arrTree, openFolder, selectHidden, treeHidden, mode) {
33    selectFileHidden = selectHidden;
34    treeStatusHidden = treeHidden;
35    modeHidden = mode;
36
37    for(i = 0; i < arrTree.length; i++) {
38
39        id = arrTree[i][0];
40        level = arrTree[i][3];
41
42        if(i == 0) {
43            old_id = "0";
44            old_level = 0;
45        } else {
46            old_id = arrTree[i-1][0];
47            old_level = arrTree[i-1][3];
48        }
49
50        // 階層上へ戻る
51        if(level <= (old_level - 1)) {
52            tmp_level = old_level - level;
53            for(up_roop = 0; up_roop <= tmp_level; up_roop++) {
54                tree += '</div>';
55            }
56        }
57
58        // 同一階層で次のフォルダへ
59        if(id != old_id && level == old_level) tree += '</div>';
60
61        // 階層の分だけスペースを入れる
62        for(space_cnt = 0; space_cnt < arrTree[i][3]; space_cnt++) {
63            tree += "&nbsp;&nbsp;&nbsp;";
64        }
65
66        // 階層画像の表示・非表示処理
67        if(arrTree[i][4]) {
68            if(arrTree[i][1] == '_parent') {
69                rank_img = IMG_MINUS;
70            } else {
71                rank_img = IMG_NORMAL;
72            }
73            // 開き状態を保持
74            arrTreeStatus.push(arrTree[i][2]);
75            display = 'block';
76        } else {
77            if(arrTree[i][1] == '_parent') {
78                rank_img = IMG_PLUS;
79            } else {
80                rank_img = IMG_NORMAL;
81            }
82            display = 'none';
83        }
84
85        arrFileSplit = arrTree[i][2].split("/");
86        file_name = arrFileSplit[arrFileSplit.length-1];
87
88        // フォルダの画像を選択
89        if(arrTree[i][2] == openFolder) {
90            folder_img = IMG_FOLDER_OPEN;
91            file_name = "<b>" + file_name + "</b>";
92        } else {
93            folder_img = IMG_FOLDER_CLOSE;
94        }
95
96        // 階層画像に子供がいたらオンクリック処理をつける
97        if(rank_img != IMG_NORMAL) {
98            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 +'">';
99        } else {
100            tree += '<img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">';
101        }
102        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/>';
103        tree += '<div id="tree'+ i +'" style="display:'+ display +'">';
104
105    }
106    fnDrow(view_id, tree);
107    //document.tree_form.tree_test2.focus();
108}
109
110// Tree状態をhiddenにセット
111function setTreeStatus(name) {
112    var tree_status = "";
113    for(i=0; i < arrTreeStatus.length ;i++) {
114        if(i != 0) tree_status += '|';
115        tree_status += arrTreeStatus[i];
116    }
117    document.form1[name].value = tree_status;
118}
119
120// Tree状態を削除する(閉じる状態へ)
121function fnDelTreeStatus(path) {
122    for(i=0; i < arrTreeStatus.length ;i++) {
123        if(arrTreeStatus[i] == path) {
124            arrTreeStatus[i] = "";
125        }
126    }
127}
128// ツリー描画
129function fnDrow(id, tree) {
130    // ブラウザ取得
131    MyBR = fnGetMyBrowser();
132    // ブラウザ事に処理を切り分け
133    switch(myBR) {
134        // IE4の時の表示
135        case 'I4':
136            document.all(id).innerHTML = tree;
137            break;
138        // NN4の時の表示
139        case 'N4':
140            document.layers[id].document.open();
141            document.layers[id].document.write("<div>");
142            document.layers[id].document.write(tree);
143            document.layers[id].document.write("</div>");
144            document.layers[id].document.close();
145            break;
146        default:
147            document.getElementById(id).innerHTML=tree;
148            break;
149    }
150}
151
152// 階層ツリーメニュー表示・非表示処理
153function fnTreeMenu(tName, imgName, path) {
154
155    tMenu = $("#" + tName);
156
157    if(tMenu.css("display") == 'none') {
158        fnChgImg(IMG_MINUS, imgName);
159        tMenu.show();
160        // 階層の開いた状態を保持
161        arrTreeStatus.push(path);
162
163    } else {
164        fnChgImg(IMG_PLUS, imgName);
165        tMenu.hide();
166        // 閉じ状態を保持
167        fnDelTreeStatus(path);
168    }
169}
170
171// ファイルリストダブルクリック処理
172function fnDbClick(arrTree, path, is_dir, now_dir, is_parent) {
173
174    if(is_dir) {
175        if(!is_parent) {
176            for(cnt = 0; cnt < arrTree.length; cnt++) {
177                if(now_dir == arrTree[cnt][2]) {
178                    open_flag = false;
179                    for(status_cnt = 0; status_cnt < arrTreeStatus.length; status_cnt++) {
180                        if(arrTreeStatus[status_cnt] == arrTree[cnt][2]) open_flag = true;
181                    }
182                    if(!open_flag) fnTreeMenu('tree'+cnt, 'rank_img'+cnt, arrTree[cnt][2]);
183                }
184            }
185        }
186        fnFolderOpen(path);
187    } else {
188        // Download
189        fnModeSubmit('download','','');
190    }
191}
192
193// フォルダオープン処理
194function fnFolderOpen(path) {
195
196    // クリックしたフォルダ情報を保持
197    document.form1[selectFileHidden].value = path;
198    // treeの状態をセット
199    setTreeStatus(treeStatusHidden);
200    // submit
201    fnModeSubmit(modeHidden,'','');
202}
203
204
205// 閲覧ブラウザ取得
206function fnGetMyBrowser() {
207    myOP = window.opera;            // OP
208    myN6 = document.getElementById; // N6
209    myIE = document.all;            // IE
210    myN4 = document.layers;         // N4
211    if      (myOP) myBR="O6";       // OP6以上
212    else if (myIE) myBR="I4";       // IE4以上
213    else if (myN6) myBR="N6";       // NS6以上
214    else if (myN4) myBR="N4";       // NN4
215    else           myBR="";         // その他
216
217    return myBR;
218}
219
220// imgタグの画像変更
221function fnChgImg(fileName,imgName){
222    $("#" + imgName).attr("src", fileName);
223}
224
225// ファイル選択
226function fnSelectFile(id, val) {
227    old_select_id = id;
228}
Note: See TracBrowser for help on using the repository browser.