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

Revision 22856, 7.3 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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    }
105    fnDrow(view_id, tree);
106    //document.tree_form.tree_test2.focus();
107}
108
109// Tree状態をhiddenにセット
110function setTreeStatus(name) {
111    var tree_status = "";
112    for(i=0; i < arrTreeStatus.length ;i++) {
113        if(i != 0) tree_status += '|';
114        tree_status += arrTreeStatus[i];
115    }
116    document.form1[name].value = tree_status;
117}
118
119// Tree状態を削除する(閉じる状態へ)
120function fnDelTreeStatus(path) {
121    for(i=0; i < arrTreeStatus.length ;i++) {
122        if(arrTreeStatus[i] == path) {
123            arrTreeStatus[i] = "";
124        }
125    }
126}
127// ツリー描画
128function fnDrow(id, tree) {
129    // ブラウザ取得
130    MyBR = fnGetMyBrowser();
131    // ブラウザ事に処理を切り分け
132    switch(myBR) {
133        // IE4の時の表示
134        case 'I4':
135            document.all(id).innerHTML = tree;
136            break;
137        // NN4の時の表示
138        case 'N4':
139            document.layers[id].document.open();
140            document.layers[id].document.write("<div>");
141            document.layers[id].document.write(tree);
142            document.layers[id].document.write("</div>");
143            document.layers[id].document.close();
144            break;
145        default:
146            document.getElementById(id).innerHTML=tree;
147            break;
148    }
149}
150
151// 階層ツリーメニュー表示・非表示処理
152function fnTreeMenu(tName, imgName, path) {
153    tMenu = $("#" + tName);
154
155    if(tMenu.css("display") == 'none') {
156        fnChgImg(IMG_MINUS, imgName);
157        tMenu.show();
158        // 階層の開いた状態を保持
159        arrTreeStatus.push(path);
160
161    } else {
162        fnChgImg(IMG_PLUS, imgName);
163        tMenu.hide();
164        // 閉じ状態を保持
165        fnDelTreeStatus(path);
166    }
167}
168
169// ファイルリストダブルクリック処理
170function fnDbClick(arrTree, path, is_dir, now_dir, is_parent) {
171    if(is_dir) {
172        if(!is_parent) {
173            for(cnt = 0; cnt < arrTree.length; cnt++) {
174                if(now_dir == arrTree[cnt][2]) {
175                    open_flag = false;
176                    for(status_cnt = 0; status_cnt < arrTreeStatus.length; status_cnt++) {
177                        if(arrTreeStatus[status_cnt] == arrTree[cnt][2]) open_flag = true;
178                    }
179                    if(!open_flag) fnTreeMenu('tree'+cnt, 'rank_img'+cnt, arrTree[cnt][2]);
180                }
181            }
182        }
183        fnFolderOpen(path);
184    } else {
185        // Download
186        fnModeSubmit('download','','');
187    }
188}
189
190// フォルダオープン処理
191function fnFolderOpen(path) {
192    // クリックしたフォルダ情報を保持
193    document.form1[selectFileHidden].value = path;
194    // treeの状態をセット
195    setTreeStatus(treeStatusHidden);
196    // submit
197    fnModeSubmit(modeHidden,'','');
198}
199
200// 閲覧ブラウザ取得
201function fnGetMyBrowser() {
202    myOP = window.opera;            // OP
203    myN6 = document.getElementById; // N6
204    myIE = document.all;            // IE
205    myN4 = document.layers;         // N4
206    if      (myOP) myBR="O6";       // OP6以上
207    else if (myIE) myBR="I4";       // IE4以上
208    else if (myN6) myBR="N6";       // NS6以上
209    else if (myN4) myBR="N4";       // NN4
210    else           myBR="";         // その他
211
212    return myBR;
213}
214
215// imgタグの画像変更
216function fnChgImg(fileName,imgName){
217    $("#" + imgName).attr("src", fileName);
218}
219
220// ファイル選択
221function fnSelectFile(id, val) {
222    old_select_id = id;
223}
Note: See TracBrowser for help on using the repository browser.