source: branches/version-2_13_0/html/user_data/packages/admin/js/file_manager.js @ 23103

Revision 23103, 7.3 KB checked in by h_yoshimoto, 11 years ago (diff)

#2342 一旦戻した内容を再度適用

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
Line 
1/*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2013 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        id = arrTree[i][0];
39        level = arrTree[i][3];
40
41        if(i == 0) {
42            old_id = "0";
43            old_level = 0;
44        } else {
45            old_id = arrTree[i-1][0];
46            old_level = arrTree[i-1][3];
47        }
48
49        // 階層上へ戻る
50        if(level <= (old_level - 1)) {
51            tmp_level = old_level - level;
52            for(up_roop = 0; up_roop <= tmp_level; up_roop++) {
53                tree += '</div>';
54            }
55        }
56
57        // 同一階層で次のフォルダへ
58        if(id != old_id && level == old_level) tree += '</div>';
59
60        // 階層の分だけスペースを入れる
61        for(space_cnt = 0; space_cnt < arrTree[i][3]; space_cnt++) {
62            tree += "&nbsp;&nbsp;&nbsp;";
63        }
64
65        // 階層画像の表示・非表示処理
66        if(arrTree[i][4]) {
67            if(arrTree[i][1] == '_parent') {
68                rank_img = IMG_MINUS;
69            } else {
70                rank_img = IMG_NORMAL;
71            }
72            // 開き状態を保持
73            arrTreeStatus.push(arrTree[i][2]);
74            display = 'block';
75        } else {
76            if(arrTree[i][1] == '_parent') {
77                rank_img = IMG_PLUS;
78            } else {
79                rank_img = IMG_NORMAL;
80            }
81            display = 'none';
82        }
83
84        arrFileSplit = arrTree[i][2].split("/");
85        file_name = arrFileSplit[arrFileSplit.length-1];
86
87        // フォルダの画像を選択
88        if(arrTree[i][2] == openFolder) {
89            folder_img = IMG_FOLDER_OPEN;
90            file_name = "<b>" + file_name + "</b>";
91        } else {
92            folder_img = IMG_FOLDER_CLOSE;
93        }
94
95        // 階層画像に子供がいたらオンクリック処理をつける
96        if(rank_img != IMG_NORMAL) {
97            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 +'">';
98        } else {
99            tree += '<img src="'+ rank_img +'" border="0" name="rank_img'+ i +'" id="rank_img'+ i +'">';
100        }
101        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/>';
102        tree += '<div id="tree'+ i +'" style="display:'+ display +'">';
103    }
104    fnDrow(view_id, tree);
105    //document.tree_form.tree_test2.focus();
106}
107
108// Tree状態をhiddenにセット
109function setTreeStatus(name) {
110    var tree_status = "";
111    for(i=0; i < arrTreeStatus.length ;i++) {
112        if(i != 0) tree_status += '|';
113        tree_status += arrTreeStatus[i];
114    }
115    document.form1[name].value = tree_status;
116}
117
118// Tree状態を削除する(閉じる状態へ)
119function fnDelTreeStatus(path) {
120    for(i=0; i < arrTreeStatus.length ;i++) {
121        if(arrTreeStatus[i] == path) {
122            arrTreeStatus[i] = "";
123        }
124    }
125}
126// ツリー描画
127function fnDrow(id, tree) {
128    // ブラウザ取得
129    MyBR = fnGetMyBrowser();
130    // ブラウザ事に処理を切り分け
131    switch(myBR) {
132        // IE4の時の表示
133        case 'I4':
134            document.all(id).innerHTML = tree;
135            break;
136        // NN4の時の表示
137        case 'N4':
138            document.layers[id].document.open();
139            document.layers[id].document.write("<div>");
140            document.layers[id].document.write(tree);
141            document.layers[id].document.write("</div>");
142            document.layers[id].document.close();
143            break;
144        default:
145            document.getElementById(id).innerHTML=tree;
146            break;
147    }
148}
149
150// 階層ツリーメニュー表示・非表示処理
151function fnTreeMenu(tName, imgName, path) {
152    tMenu = $("#" + tName);
153
154    if(tMenu.css("display") == 'none') {
155        fnChgImg(IMG_MINUS, imgName);
156        tMenu.show();
157        // 階層の開いた状態を保持
158        arrTreeStatus.push(path);
159    } else {
160        fnChgImg(IMG_PLUS, imgName);
161        tMenu.hide();
162        // 閉じ状態を保持
163        fnDelTreeStatus(path);
164    }
165}
166
167// ファイルリストダブルクリック処理
168function fnDbClick(arrTree, path, is_dir, now_dir, is_parent) {
169    if(is_dir) {
170        if(!is_parent) {
171            for(cnt = 0; cnt < arrTree.length; cnt++) {
172                if(now_dir == arrTree[cnt][2]) {
173                    open_flag = false;
174                    for(status_cnt = 0; status_cnt < arrTreeStatus.length; status_cnt++) {
175                        if(arrTreeStatus[status_cnt] == arrTree[cnt][2]) open_flag = true;
176                    }
177                    if(!open_flag) fnTreeMenu('tree'+cnt, 'rank_img'+cnt, arrTree[cnt][2]);
178                }
179            }
180        }
181        fnFolderOpen(path);
182    } else {
183        // Download
184        eccube.setModeAndSubmit('download','','');
185    }
186}
187
188// フォルダオープン処理
189function fnFolderOpen(path) {
190    // クリックしたフォルダ情報を保持
191    document.form1[selectFileHidden].value = path;
192    // treeの状態をセット
193    setTreeStatus(treeStatusHidden);
194    // submit
195    eccube.setModeAndSubmit(modeHidden,'','');
196}
197
198// 閲覧ブラウザ取得
199function fnGetMyBrowser() {
200    myOP = window.opera;            // OP
201    myN6 = document.getElementById; // N6
202    myIE = document.all;            // IE
203    myN4 = document.layers;         // N4
204    if      (myOP) myBR="O6";       // OP6以上
205    else if (myIE) myBR="I4";       // IE4以上
206    else if (myN6) myBR="N6";       // NS6以上
207    else if (myN4) myBR="N4";       // NN4
208    else           myBR="";         // その他
209
210    return myBR;
211}
212
213// imgタグの画像変更
214function fnChgImg(fileName,imgName){
215    $("#" + imgName).attr("src", fileName);
216}
217
218// ファイル選択
219function fnSelectFile(id, val) {
220    old_select_id = id;
221}
Note: See TracBrowser for help on using the repository browser.