source: temp/trunk/html/drecomcms/sidefunc_order.js @ 1328

Revision 1328, 25.0 KB checked in by naka, 20 years ago (diff)

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**
2 *
3 * ƒTƒCƒhƒo[•ҏW JavaScript
4 *
5 * Copyright (c) 2003-2004 DRECOM CO.,LTD. All rights reserved.
6 *
7 * [email protected]
8 * http://www.drecom.co.jp/
9 */
10
11
12//---------------------------------------------------------------------------------
13// Ý’è
14//---------------------------------------------------------------------------------
15
16// *** ‰ŠúÝ’è•ϐ” *** //
17
18var gSidefuncOrderForm = null;
19var SIDEFUNC_ORDER_FORM_NAME = "SidefuncOrderForm";
20
21
22// 2004-04-13  Takanori Ishikawa 
23// ------------------------------------------------------------------------
24//
25// Mac ‚Ì IE5 ‚͍À•WŠÖ˜A‚Ì‹@”\i‚¾‚¯‚¶‚á‚È‚¢‚¯‚ǁj‚Ì‘½‚­‚ª‹¶‚Á‚Ä‚¢‚é
26// ‚̂œK“–‚ɑΉž
27//
28// ŽQlF
29// Mac ‚̐H‚¦‚È‚¢–ì˜Y‚Ç‚à
30// http://www.din.or.jp/~hagi3/JavaScript/JSTips/ProbMac5.htm
31// Microsoft
32// http://www.microsoft.com/
33//
34var MAC_IE5_PITCH_X;
35var MAC_IE5_PITCH_Y;
36
37MAC_IE5_PITCH_X = MAC_IE5_PITCH_Y = 0;  /* BITCH */
38if (XBSUtil.macIE && XBSUtil.macIE.major >= 5) {
39    MAC_IE5_PITCH_X = -10;
40    MAC_IE5_PITCH_Y = 0;
41}
42
43
44// *** CheckLine *** //
45var CHECKLINE_ID = 'checkline';
46
47
48// --- Panel ---
49// ޝ•ÊŽq
50var PANEL_NAME_DISABLE  = 'DISABLE';    // ŠO‹@”\BOX‚ÌID
51var PANEL_NAME_LEFT     = 'LEFT';       // “àE¶‹@”\BOX‚ÌID
52var PANEL_NAME_RIGHT    = 'RIGHT';      // “àE‰E‹@”\BOX‚ÌID
53
54//‚·‚×‚Ä‚Ì Panel ‚ðƒvƒƒpƒeƒB‚É‚à‚ƒIƒuƒWƒFƒNƒg
55// key ‚Í name
56var gAllPanels         = new Object();
57
58// ¶‚©‚ç‚̏‡”Ô
59var gPanelNames         = [PANEL_NAME_DISABLE, PANEL_NAME_LEFT, PANEL_NAME_RIGHT];
60
61
62// --- Box ---
63var BOX_ID_PREFIX       = 'f';          // Box ‚Ì ID ƒvƒŠƒtƒBƒbƒNƒX
64var BoxConfig = {
65    width:      120,    // Box •
66    height:     20,     // Box ‚‚³
67    padding:    10,     // Box ŠÔ‚̃Xƒy[ƒX
68    marginTop:  5,      // ˆê”ԏã‚ÌBox‚Ɛeƒpƒlƒ‹‚Ƃ̃Xƒy[ƒX
69    marginLeft: 5       // Box ‚Ɛeƒpƒlƒ‹‚̍¶‘¤‚̃Xƒy[ƒX
70};
71
72// Box ”z’u—̈æ‚̍ŏ¬‚‚³
73var MIN_BOXIES_HEIGHT   = 200;
74
75// ‚·‚×‚Ä‚Ì Box ‚ðƒvƒƒpƒeƒB‚É‚à‚ƒIƒuƒWƒFƒNƒg
76var gAllBoxes           = new Object();
77
78/**
79 * ƒpƒlƒ‹‚ÉŠi”[‚Å‚«‚éÅ‘å Box ”‚ð‹L˜^‚µ‚½ƒIƒuƒWƒFƒNƒg
80 *
81 * key: ƒpƒlƒ‹–¼ value: ƒpƒlƒ‹‚ÉŠi”[‚Å‚«‚éÅ‘å Box ”
82 *
83 */
84
85BoxConfig.maxNBoxes = new Object();
86BoxConfig.maxNBoxes[PANEL_NAME_DISABLE] = OEMBlogGlobal.PANEL_DISABLE_MAX_NBOXES;   // uŽg—p‚µ‚È‚¢‹@”\v
87BoxConfig.maxNBoxes[PANEL_NAME_LEFT]    = OEMBlogGlobal.PANEL_LEFT_MAX_NBOXES;      // uŽg—p‚·‚é‹@”\v¶
88BoxConfig.maxNBoxes[PANEL_NAME_RIGHT]   = OEMBlogGlobal.PANEL_RIGHT_MAX_NBOXES;     // uŽg—p‚·‚é‹@”\v‰E
89
90/**
91 * ƒy[ƒW“ǂݍž‚ÝŽž‚Ì”z’uƒf[ƒ^
92 */
93gInitialBoxPositionsData = null;
94
95//---------------------------------------------------------
96// ”z’u‚È‚Ç
97//---------------------------------------------------------
98/**
99 * HTML ‚Ì hidden input —v‘f‚©‚獀–Ú‚Ì”z’u‚Ȃǂ̏î•ñ‚ð“ǂݎæ‚éƒIƒuƒWƒFƒNƒg
100 *
101 * @author Takanori Ishikawa
102 * @version 2004/04/23
103 */
104SFSettings = new Object();
105
106/**
107 * HTML ‚Ì hidden input —v‘f‚©‚çÝ’è’l‚ð“ǂݎæ‚é
108 */
109SFSettings.loadBoxPositions = function()
110{
111    var positions = new Object();
112    var orders       = new Array();
113    var panelNames   = new Array();
114   
115    // hidden‚©‚çbox_position‚ðŽæ“¾
116    positions[PANEL_NAME_DISABLE]   = new Array();
117    positions[PANEL_NAME_LEFT]      = new Array();
118    positions[PANEL_NAME_RIGHT]     = new Array();
119    for (var i = 0; i < gSidefuncOrderForm.elements.length; ++i) {
120        var elem = gSidefuncOrderForm.elements[i];
121       
122        if(Box.ORDER_PROPERTY_NAME == elem.name) {
123            orders[orders.length] = elem.value;
124        } else if(Box.POSITION_PROPERTY_NAME == elem.name) {
125            var idx = XBSUtil.parseIntNoError(elem.value);
126            panelNames[panelNames.length] = gPanelNames[idx];
127        } else if (Box.ID_PROPERTY_NAME == elem.name) {
128            ;
129        }
130    }
131    for (var i = 0; i < orders.length; i++) {
132        var pnm = panelNames[i];
133        var bid = i;
134        var ord = orders[i];
135       
136        positions[pnm][bid] = ord;
137    }
138   
139    orders     = null;
140    panelNames = null;
141    return positions;
142}
143
144/**
145 * Œ»Ý‚̏ó‘Ô‚ð’Pˆê‚̃IƒuƒWƒFƒNƒg‚ɃGƒ“ƒR[ƒh‚µ‚ĕԂ·B
146 */
147SFSettings.getObjectForPersistent = function()
148{
149    var orders = new Array();
150    var pidxes = new Array();
151    var result = '';
152   
153    if (gSidefuncOrderForm == null) {
154        return result;
155    }
156    for (var i = 0; i < gSidefuncOrderForm.elements.length; ++i) {
157        var elem = gSidefuncOrderForm.elements[i];
158       
159        if(Box.ORDER_PROPERTY_NAME == elem.name) {
160            orders[orders.length] = elem.value;
161        } else if(Box.POSITION_PROPERTY_NAME == elem.name) {
162            pidxes[pidxes.length] = XBSUtil.parseIntNoError(elem.value);
163        }
164    }
165    result += pidxes.join('');
166    result += orders.join('');
167    pidxes = null;
168    orders = null;
169   
170    return result;
171}
172
173//---------------------------------------------------------
174// ContentsChangedListener
175//---------------------------------------------------------
176/**
177 * ƒTƒCƒhƒo[‚̕ύX‚ðŠÄŽ‹‚·‚éƒIƒuƒWƒFƒNƒg
178 * ContentsChangedListener ‚̃TƒuƒNƒ‰ƒX
179 *
180 * @author Takanori Ishikawa
181 * @version 2004/04/23
182 */
183function SFChangedListener(/* Optional */ aName) /* extends ContentsChangedListener */
184{
185}
186SFChangedListener.prototype = new ContentsChangedListener();
187SFChangedListener.prototype.setChanged = function(b)
188{
189    var persistent = SFSettings.getObjectForPersistent();
190   
191    // 2004-04-23  Takanori Ishikawa
192    // ------------------------------------------------------------------------
193    // ‚±‚±‚Å prototype ‚̃ƒ\ƒbƒh‚ðŒÄ‚яo‚µ‚Ä‚à‚¤‚Ü‚­‚¢‚©‚È‚¢B
194
195    this.changed = (gInitialBoxPositionsData != persistent);
196}
197
198//---------------------------------------------------------
199// Drag & Drop: SFDragManager (Sidebar Function DragManager)
200//---------------------------------------------------------
201/**
202 * ƒhƒ‰ƒbƒOˆ—‚Ì—LŒø‰»A“r’†‚̏ó‘Ô‚ð•ÛŽ‚·‚邽‚߂̃IƒuƒWƒFƒNƒg
203 * ƒhƒ‰ƒbƒOˆ—‚͈ê“x‚ɂЂƂ‚µ‚©‹N‚±‚ç‚È‚¢‚̂ŁA‚¢‚܂̂Ƃ±‚ë
204 * Singleton ‚Æ‚µ‚ÄŽÀ‘•
205 *
206 * For example:
207 * <pre>
208 * // prepare for dragging, enable event handler.
209 * SFDragManager.enableEventHandler();
210 * </pre>
211 *
212 * @author  Takanori Ishikawa
213 * @version 1.0
214 */
215SFDragManager = new Object();
216
217// *** Event Handler *** //
218SFDragManager.ondrop = null;  // ”z’u‚ª•ύX‚³‚ꂽ
219
220
221// ƒhƒ‰ƒbƒOˆ—‚É—˜—p‚·‚é document ‚̃Cƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ðÝ’è
222SFDragManager.enableEventHandler = function ()
223{
224    document.onmousemove = function(e) {
225        if (SFDragManager.box != null)
226            SFDragManager.moveBox(e);
227    };
228   
229    document.onmouseup = function(e) {
230        if (SFDragManager.box != null)
231            SFDragManager.downBox(e);
232    };
233   
234    for (var key in gAllBoxes) {
235        var box = gAllBoxes[key];
236        var src = box ? box.getHTMLElement() : null;
237       
238        if (src != null) {
239            src.onmousedown = SFDragManager.pickUpBox;
240        }
241    }
242}
243
244// ƒhƒ‰ƒbƒOˆ—‚É—˜—p‚·‚é document ‚̃Cƒxƒ“ƒgƒnƒ“ƒhƒ‰‚ð‰ðœ
245SFDragManager.disbleEventHandler= function()
246{
247    document.onmousemove    = '';
248    document.onmouseup      = '';
249}
250
251
252//ƒhƒ‰ƒbƒO’†‚̃IƒuƒWƒFƒNƒg
253
254SFDragManager.destination = null;   /* ˆÚ“®æ Panel */
255SFDragManager.source      = null;   /* ˆÚ“®Œ³ Panel */
256SFDragManager.box         = null;   /* ƒhƒ‰ƒbƒO’†‚Ì Panel */
257
258/**
259 * ƒTƒCƒhƒo[€–ڂ̕ύX‚ðŠÄŽ‹‚·‚éƒIƒuƒWƒFƒNƒg‚ð•Ô‚·B
260 */
261SFDragManager.getChangedListener = function()
262{
263    if (SFDragManager.getChangedListener.$instance == null) {
264       
265        SFDragManager.getChangedListener.$instance =
266            new SFChangedListener("[Sidebar Function Order]");
267    }
268    return SFDragManager.getChangedListener.$instance;
269}
270SFDragManager.setUpContentsChangedListener = function()
271{
272    // 2004-04-23  Takanori Ishikawa 
273    // ------------------------------------------------------------------------
274    // ƒTƒCƒhƒo[‚Ì”z’u‚ª•ύX‚³‚ꂽ‚©‚Ç‚¤‚©‚ð‹L˜^
275   
276    var listener = SFDragManager.getChangedListener();
277   
278    listener.listenEvent(SFDragManager, 'ondrop');
279    OEMBlogGlobal.watchOtherLinks(document, listener);
280}
281
282/**
283  * setOnLoad()
284  *
285  * ƒy[ƒW“ǂݍž‚ÝŽž‚̏‰Šúˆ—
286  */
287SFDragManager.loaded = false;
288SFDragManager.onload = function()
289{
290    // ƒtƒH[ƒ€‰Šú‰»
291    gSidefuncOrderForm = UtilKit.getPropertyNotNull(document, SIDEFUNC_ORDER_FORM_NAME);
292   
293    // Še Panel, Box ƒIƒuƒWƒFƒNƒg¶¬
294    var boxPositions = SFSettings.loadBoxPositions();
295    gInitialBoxPositionsData = SFSettings.getObjectForPersistent();
296    for (var i = 0; i < gPanelNames.length; i++) {
297        var nm = gPanelNames[i];
298        var panel;
299       
300        panel = new Panel(nm, boxPositions[nm]);
301       
302        for(var key in panel.box_position) {
303            gAllBoxes[key] = new Box(key);
304        }
305       
306        // Box ‚̏‰Šú”z’u
307        panel.setBoxPosition();
308        Panel[nm] = panel;
309       
310        gAllPanels[nm] = panel;
311    }
312   
313   
314    // ƒhƒ‰ƒbƒOˆ—‚̏€”õ
315    SFDragManager.setUpContentsChangedListener();
316    SFDragManager.enableEventHandler();
317   
318    // onload ‚àƒCƒxƒ“ƒg
319    resetPositionsInEventHandler();
320    window.onresize = resetPositionsInEventHandler;
321   
322    SFDragManager.loaded = true;
323    // 2004-04-20  Takanori Ishikawa 
324    // ------------------------------------------------------------------------
325    // Opera ‚Å‚Í onload Žž“_‚ŃŒƒCƒ„[‚̍ĕ`‰æ‚ªŠÔ‚ɍ‡‚í‚È‚¢B
326    // ‚±‚̊֐”‚ðŽg‚Á‚āA–³—‚â‚èÄ•`‰æ‚·‚éB
327    if (window.opera) {
328        SFDragManager.loaded = false;
329        setTimeout("refreshDisplay()", 0.8*1000);
330    }
331   
332}
333
334
335//---------------------------------------------------------
336// ƒCƒxƒ“ƒgˆ—
337//---------------------------------------------------------
338// CheckLine
339/**
340 *  ƒhƒ‰ƒbƒO’†‚Ì Box ‚ª‘}“ü‚³‚ê‚é‰ÓŠ‚ðŽw‚µŽ¦‚·‚½‚߂̃‰ƒCƒ“
341 *
342 * @return XBSLayer
343 * @see xbs.js
344 */
345function getCheckLineLayer()
346{
347    if (null == getCheckLineLayer.layer) {
348        getCheckLineLayer.layer = XBSLayer.makeLayer(CHECKLINE_ID);
349    }
350    return getCheckLineLayer.layer;
351}
352function getPanelAtPosition(x, y)
353{
354    var panel = null;
355   
356    for (var key in gAllPanels) {
357        panel = gAllPanels[key];
358           
359        if (x > panel.panel_section['left']  &&
360            x < panel.panel_section['right'] &&
361            y > panel.panel_section['top']   &&
362            y < panel.panel_section['under'])
363        { break; }
364    }
365    return panel;
366}
367
368// 2004-04-13  Takanori Ishikawa 
369// ------------------------------------------------------------------------
370// Mac IE ‚ł̓Cƒxƒ“ƒgƒnƒ“ƒhƒ‰‚Ì’†‚ōÀ•WŠÖŒW‚Ì‘€ì‚ðs‚¤‚Æ‚¤‚Ü‚­‚¢‚©‚È‚¢‚Ì‚Å
371// ‚·‚±‚µ’x‚点‚ÄŽÀs
372function resetPositionsInEventHandler()
373{
374    if (XBSUtil.macIE && XBSUtil.macIE.major >= 5) {
375        setTimeout("resetPositions()", 1*1000);
376    } else {
377        resetPositions();
378    }
379}
380
381// *** Reset *** //
382/**
383  * ‚·‚×‚Ä‚Ì Box ‚ðÄ”z’u
384  */
385function resetPositions()
386{
387    var panel;
388   
389    for (var key in gAllPanels) {
390        panel = gAllPanels[key];
391        if (panel != null) {
392            panel.setSections();
393            panel.setBoxPosition();
394        }
395    }
396}
397
398/**
399 * ‚·‚×‚Ä‚Ì Box ‚ðˆê“xÁ‚µA‚·‚®‚É‚·‚ׂĕ\ަ
400 */
401function refreshDisplay()
402{
403    var panel;
404   
405    for (var key in gAllPanels) {
406        panel = gAllPanels[key];
407        if (panel != null) {
408            panel.setBoxVisible(false);
409            panel.setBoxVisible(true);     
410        }
411    }
412    SFDragManager.loaded = true;
413}
414
415// -----------------------------------------------------------------
416// ƒ{ƒbƒNƒX‚̃hƒ‰ƒbƒO•ƒhƒƒbƒv
417// -----------------------------------------------------------------
418
419/**
420  * pickUpBox()
421  * theEvent: ƒCƒxƒ“ƒg
422  *
423  * Box‚ðŽ‚¿ã‚°‚½(ƒNƒŠƒbƒN‚³‚ꂽ)Žž‚̏ˆ—‚ð‚·‚éŠÖ”
424  */
425SFDragManager.pickUpBox = function(theEvent) {
426    if (null == theEvent) {
427        theEvent = window.event;
428    }
429    if (SFDragManager.box != null || SFDragManager.loaded == false)
430        return;
431   
432    // ƒ}ƒEƒXˆÊ’uŽæ“¾
433    var mouse_x     = XBSEvent.getMouseX(theEvent);
434    var mouse_y     = XBSEvent.getMouseY(theEvent);
435    var pickedPanel = getPanelAtPosition(mouse_x, mouse_y);
436
437    if (null == pickedPanel)
438        return;
439
440    // ‘I‘ð‚³‚ê‚½Box‚Ì•À‚я‡”ԍ†‚Æ id ‚ðŽæ“¾
441    var beforeId = pickedPanel.orderIndexOfBoxAt(mouse_x, mouse_y);
442    var funcId  = UtilKit.getKeyForValue(pickedPanel.box_position, beforeId);
443   
444    if (null == funcId)
445        return;
446   
447    //BoxƒGƒŒƒƒ“ƒgŽæ“¾Eˆ—
448    var selected = new XBSLayer(BOX_ID_PREFIX + funcId);
449    if (null == selected)
450        return;
451
452    selected.setZIndex(selected.getZIndex() +1);
453
454    //‘I‘ð‚³‚ê‚½Box‚ÌX,YÀ•W‚ð•Û‘¶
455    before_box_x    = selected.getX() + MAC_IE5_PITCH_X;
456    before_box_y    = selected.getY() + MAC_IE5_PITCH_Y;
457
458    //ƒ}ƒEƒX‚ÆBoxŒ´“_‚̍·
459    box_to_mouse_x  = mouse_x - before_box_x;
460    box_to_mouse_y  = mouse_y - before_box_y;
461   
462    // ƒhƒ‰ƒbƒOŠJŽn
463    SFDragManager.box = selected;
464    SFDragManager.source = pickedPanel;
465    before_order_id = beforeId;
466    function_id = funcId;
467}
468
469
470/**
471 *
472 * Box‚ðˆÚ“®‚·‚éŠÖ”
473 *
474 * @param theEvent mousemove ƒCƒxƒ“ƒg
475 */
476SFDragManager.moveBox = function(theEvent) {
477    var selected = SFDragManager.box;
478   
479    if (null == selected || SFDragManager.loaded == false)
480        return;
481    if (null == theEvent) {
482        theEvent = window.event;
483    }
484    //
485    // ƒhƒ‰ƒbƒO’†AƒEƒBƒ“ƒhƒE‚©‚ço‚鎞ƒŠƒZƒbƒg‚µ‚ďI‚í‚é
486    //
487    if (false == Box.canMoveWithEvent(theEvent)) {
488        gAllBoxes[function_id].setPosition(before_box_x, before_box_y);
489        clearMove();
490       
491        return;
492    }
493
494    var mouse_x  = XBSEvent.getMouseX(theEvent);
495    var mouse_y  = XBSEvent.getMouseY(theEvent);
496    var curPanel = getPanelAtPosition(mouse_x, mouse_y);
497    if (null == curPanel)
498        return;
499   
500    if (curPanel.canDropAtPosition(SFDragManager.source, selected, mouse_x, mouse_y)) {
501        // ƒ`ƒFƒbƒNƒ‰ƒCƒ“•\ަ
502        curPanel.showCheckLineAtPosition(mouse_x, mouse_y);
503    }
504
505    //BoxˆÚ“®
506    move_to_x = mouse_x - box_to_mouse_x;
507    move_to_y = mouse_y - box_to_mouse_y;
508   
509    selected.setLeftTopPosition(move_to_x, move_to_y);
510}
511
512
513
514/**
515 * Box ‚ð‰º‚ë‚µ‚½Žž‚̏ˆ—
516 *
517 * @param theEvent ƒCƒxƒ“ƒg
518 */
519SFDragManager.downBox = function(theEvent)
520{
521    if (SFDragManager.loaded == false) {
522        return;
523    }
524    if (null == theEvent) {
525        theEvent = window.event;
526    }
527    // ƒ`ƒFƒbƒNƒ‰ƒCƒ“‚ðÁ‚·
528    getCheckLineLayer().setVisible(false);
529
530    // ƒ}ƒEƒXˆÊ’uŽæ“¾
531    var mouse_x = XBSEvent.getMouseX(theEvent);
532    var mouse_y = XBSEvent.getMouseY(theEvent);
533   
534    // -------------------------------------
535    // ˆÚ“®—̈æ“à‚©ŠO‚©ƒ`ƒFƒbƒN
536    // -------------------------------------
537    // ˆÚ“®æ‚̃pƒlƒ‹‚ðŽæ“¾‚µAƒhƒ‰ƒbƒOî•ñ‚ðXV
538    // ƒhƒ‰ƒbƒO‘OŒã‚̃pƒlƒ‹
539    var beforePanel = SFDragManager.source;
540    var afterPanel  = getPanelAtPosition(mouse_x, mouse_y);
541   
542    SFDragManager.destination = afterPanel;
543    if (null == beforePanel) {
544        throw ASSERT_EXCEPTION + 'SFDragManager.source must be not null';
545    }
546   
547    var droppedBox = gAllBoxes[function_id];
548    var after_order_id = afterPanel.orderIndexOfMovingAt(mouse_x, mouse_y);
549   
550    // ƒhƒƒbƒv‚Å‚«‚È‚¢ê‡ABox ‚ð–ß‚µ‚āAƒhƒ‰ƒbƒOˆ—‚ðI—¹‚·‚é
551    if (false == afterPanel.canDropAtPosition(beforePanel, droppedBox, mouse_x, mouse_y)) {
552        droppedBox.setPosition(before_box_x, before_box_y);
553        clearMove();
554        return;
555    }
556
557    // ˆÚ“®‚·‚éBox‚ðƒpƒlƒ‹‚©‚çíœ‚µA‡”Ԃ𐮗‚·‚é
558    delete beforePanel.box_position[function_id];   
559    for (key in beforePanel.box_position) {
560        if (before_order_id < beforePanel.box_position[key]) {
561            --beforePanel.box_position[key];
562        }
563    }
564
565    //after_order_id‚̏ˆ—
566    if (!(beforePanel.equals(afterPanel) && before_order_id <= after_order_id)) {
567        ++after_order_id;
568    }
569
570
571    // Å‘å‚̃Cƒ“ƒfƒbƒNƒX‚ðXV
572    if (after_order_id > afterPanel.getMaxOrderIndex() + 1) {
573        after_order_id = afterPanel.getMaxOrderIndex() + 1;
574    }
575
576    //‘}“ü‚·‚éŠÔ‚ð‚‚­‚èA‘}“ü‚·‚é
577    for (key in afterPanel.box_position) {
578        if (after_order_id <= afterPanel.box_position[key]) {
579            ++afterPanel.box_position[key];
580        }
581    }
582    afterPanel.box_position[function_id] = after_order_id;
583
584    //BoxÄ”z’u
585    if (false == beforePanel.equals(afterPanel)) {
586        beforePanel.setBoxPosition();
587    }
588    afterPanel.setBoxPosition();
589
590    // HTML‚Ìhidden’l•ύX
591    for (var nm in gAllPanels) {
592        var p = gAllPanels[nm];
593
594        for (key in p.box_position) {
595            gSidefuncOrderForm.elements['order'][key].value = p.box_position[key];
596            gSidefuncOrderForm.elements['position'][key].value = p.getPosition();
597        }
598    }
599
600    // ˆÚ“®‚̉ðœ
601    clearMove();
602    if (SFDragManager.ondrop != null && typeof SFDragManager.ondrop == 'function') {
603        SFDragManager.ondrop();
604    }   
605}
606
607
608/**
609  * clearMove()
610  *
611  * BoxˆÚ“®‚ðI—¹‚·‚éŠÖ”
612  */
613function clearMove() {
614    var selected = SFDragManager.box;
615   
616    selected.setZIndex(selected.getZIndex() -1);
617    SFDragManager.box = null;
618}
619
620
621
622
623//---------------------------------------------------------------------------------
624// Panel
625//---------------------------------------------------------------------------------
626/**
627  * ŒÂX‚̃hƒ‰ƒbƒO‰Â”\‚ȍ€–Ú‚ð•ÛŽ‚·‚é—̈æ
628  *
629  * ‚¢‚܂̂Ƃ±‚ëA¶‚©‚çuŽg—p‚µ‚È‚¢‹@”\vuŽg—p‚·‚é‹@”\E¶vuŽg—p‚·‚é‹@”\E‰Ev
630  *
631  * @param aPanelName    ƒpƒlƒ‹‚Ì–¼‘O
632  * @param aPositionArray Box‚Ì”z’uî•ñ”z—ñ
633  *
634  * @author Yusuke Saito
635  * @version 2003/10/10
636  *
637  * @author Takanori Ishikawa
638  * @version 2004/04/20
639  */
640function Panel(aPanelName, aPositionArray)
641{
642    this.name              = aPanelName;                        // ƒpƒlƒ‹‚Ì–¼‘O(div‚Ìid)
643    this.box_position      = aPositionArray;                    // Box‚Ì”z’uî•ñ”z—ñ
644    this.box_limit_number  = BoxConfig.maxNBoxes[aPanelName];   // ƒpƒlƒ‹“à‚̍őåBox”
645   
646    this.position = -1;
647    for (var i = 0; i < gPanelNames.length; i++) {
648        if (this.name == gPanelNames[i]) {
649            this.position = i;
650            break;
651        }
652    }
653   
654    // ƒpƒlƒ‹Eƒ{ƒbƒNƒXEˆÚ“®‚ÌŠe—̈æ‚ðÝ’è
655    this.setSections();
656}
657
658/**
659 * Box ‚Ì Y offset
660 *
661 * @param anIndex order index
662 */
663Panel.getBoxSectionOffsetY = function(anIndex)
664{
665    if (Panel.box_section_y == null) {  // Box ˆÊ’uÝ’è
666        var nboxs = BoxConfig.maxNBoxes[PANEL_NAME_DISABLE];
667        Panel.box_section_y = new Array(nboxs);
668       
669        for (var i = 0; i < nboxs; ++i) {
670            Panel.box_section_y[i] = (BoxConfig.height + BoxConfig.padding) * i + BoxConfig.marginTop;
671        }
672    }
673    return Panel.box_section_y[anIndex];
674}
675
676Panel.prototype.getPosition = function() {
677    return this.position;
678}
679
680/**
681 * description
682 */
683Panel.prototype.toString = function()
684{
685    return '[Panel] ' + this.name;
686}
687
688/**
689 * ”äŠr
690 *
691 * @param aPanel ƒpƒlƒ‹
692 */
693Panel.prototype.equals = function(aPanel)
694{
695    // 2004-04-23  Takanori Ishikawa
696    // ------------------------------------------------------------------------
697    // instanceof ‚Í IE 6 ‚Å‚à–¢ƒTƒ|[ƒg   
698    if (aPanel == null || /*false == (aPanel instanceof Panel)*/ typeof aPanel.name == 'undefined') {
699        return false;
700    }   
701    return this.name == aPanel.name;
702}
703
704
705/**
706  * setSections()
707  *
708  * ƒEƒBƒ“ƒhƒE‚ðŒ´“_‚Æ‚µ‚½ƒpƒlƒ‹‚Ì‚S•Ó‚ÌX,YÀ•W‚ðÝ’è‚·‚éŠÖ”
709  * left:¶•ÓX right:‰E•ÓX top:ã•ÓY under:‰º•ÓY
710  */
711Panel.prototype.setSections = function() {
712
713    // eƒŒƒCƒ„[‚̈ʒuŽæ“¾
714    this.setUpPanelSections();
715
716    //Box—̈æ‚̐ݒè
717    this.setBoxSection();
718
719    //BoxˆÚ“®æ—̈æ‚̐ݒè
720    this.setMoveSection();
721}
722
723
724/**
725  * setUpPanelSections()
726  *
727  * ƒEƒBƒ“ƒhƒE‚ðŒ´“_‚Æ‚µ‚½ƒpƒlƒ‹‚Ì‚S•Ó‚ÌX,YÀ•W‚ðÝ’è‚·‚éŠÖ”
728  * left:¶•ÓX right:‰E•ÓX top:ã•ÓY under:‰º•ÓY
729  */
730Panel.prototype.setUpPanelSections = function()
731{
732    var psec    = new Object;
733    var lyer = XBSLayer.makeLayer(this.name);
734   
735    psec['left'] = MAC_IE5_PITCH_X;
736    psec['top']  = MAC_IE5_PITCH_Y;
737   
738    psec['right'] = lyer.getWidth();
739    psec['under'] = lyer.getHeight();
740    while (lyer != null && lyer.isValid() && lyer.hasID()) {
741       
742        psec['left'] += lyer.getX();   
743        psec['top']  += lyer.getY();
744        lyer = lyer.getParent();
745    }
746    psec['right'] += psec['left'];
747    psec['under'] += psec['top'];
748
749    this.panel_section = psec;
750}
751
752/**
753  * setBoxSection()
754  *
755  * Box‚ÌŽû‚Ü‚é—̈æ‚ðÝ’è‚·‚éŠÖ”
756  * box_section[•À‚я‡”ԍ†] => (left => ¶•ÓX, right => ‰E•ÓX, top => ã•ÓY, under => ‰º•ÓY)
757  */
758Panel.prototype.setBoxSection = function() {
759
760    //Box—̈æ‚̐ݒè
761    this.box_section_left_x     = this.panel_section['left'] + BoxConfig.marginLeft;
762    this.box_section_right_x    = this.box_section_left_x + BoxConfig.width
763
764    this.box_section            = new Array(this.box_limit_number);
765
766    for(i = 0; i < this.box_limit_number; ++i) {
767        this.box_section[i]             = new Array(4);
768        this.box_section[i]['left']     = this.box_section_left_x;
769        this.box_section[i]['right']    = this.box_section_right_x;
770        this.box_section[i]['top']      = Panel.getBoxSectionOffsetY(i) + this.panel_section['top'];
771        this.box_section[i]['under']    = this.box_section[i]['top'] + BoxConfig.height;
772    }
773}
774
775/**
776 * ƒpƒlƒ‹‚Ì’†‚ňê”Ô‰º‚Ì Box ‚̃Cƒ“ƒfƒbƒNƒX‚ð•Ô‚·
777 *
778 * @return ˆê”Ô‰º‚Ì Box ‚̃Cƒ“ƒfƒbƒNƒXB
779 */
780Panel.prototype.getMaxOrderIndex = function()
781{
782    var max = -1;
783    for(key in this.box_position) {
784        max = (max < this.box_position[key]) ? this.box_position[key] : max;
785    }
786    return Number(max);
787}
788
789/**
790 * Žw’肳‚ꂽˆÊ’u‚ɍłà‹ß‚¢ABox ‚ð‘}“ü‰Â”\‚È‰ÓŠ‚Éƒ`ƒFƒbƒNƒ‰ƒCƒ“‚ð•\ަ‚·‚éB
791 *
792 * @param x x À•W
793 * @param y y À•W
794 */
795Panel.prototype.showCheckLineAtPosition = function(x, y)
796{
797    if (typeof x != typeof 0 || typeof y != typeof 0) {
798        throw ASSERT_EXCEPTION + 'x or y arg';
799    }
800   
801    var moveOrderId   = this.orderIndexOfMovingAt(x, y);
802    var maxOrderIndex = this.getMaxOrderIndex();
803   
804    if (null == moveOrderId)
805        return;
806   
807    if (maxOrderIndex < moveOrderId) {
808        moveOrderId = maxOrderIndex;
809    }
810    if (moveOrderId < this.box_limit_number) {
811        // ƒ`ƒFƒbƒNƒ‰ƒCƒ“ˆÚ“®
812        var check_line_left = this.panel_section['left'];
813        var check_line_top = this.move_section[moveOrderId]['top'];
814
815        // ˆê’Uƒ`ƒFƒbƒNƒ‰ƒCƒ“‚ðÁ‚·
816        getCheckLineLayer().setVisible(false);
817        getCheckLineLayer().setLeftTopPosition(check_line_left, check_line_top);
818        getCheckLineLayer().setVisible(true);
819    }
820}
821
822
823/**
824  * setMoveSection()
825  *
826  * Box‚ðˆÚ“®‚Å‚«‚é—̈æ‚ðÝ’è‚·‚éŠÖ”
827  * move_section[•À‚я‡”ԍ†] => (left => ¶•ÓX, right => ‰E•ÓX, top => ã•ÓY, under => ‰º•ÓY)
828  */
829Panel.prototype.setMoveSection = function() {
830
831    //ˆÚ“®—̈æ‚̐ݒè
832    this.move_section_left_x    = this.panel_section['left'];
833    this.move_section_right_x   = this.move_section_left_x + BoxConfig.width + (BoxConfig.marginLeft * 2);
834    this.move_section           = new Array(this.box_limit_number + 1);
835
836    this.move_section[-1]           = new Array(4);
837    this.move_section[-1]['left']   = this.move_section_left_x;
838    this.move_section[-1]['right']  = this.move_section_right_x;
839    this.move_section[-1]['top']    = this.panel_section['top'] - 7;
840    this.move_section[-1]['under']  = this.panel_section['top'] + (BoxConfig.marginTop / 2) + BoxConfig.height;
841
842    for(i = 0; i < this.box_limit_number; ++i) {
843        this.move_section[i]            = new Array(4);
844        this.move_section[i]['left']    = this.move_section_left_x;
845        this.move_section[i]['right']   = this.move_section_right_x;
846        this.move_section[i]['top']     = this.move_section[i - 1]['under'];
847        this.move_section[i]['under']   = this.move_section[i]['top'] + BoxConfig.height + BoxConfig.padding;
848    }
849}
850
851
852
853Panel.prototype.canDropAtPosition = function(aSourcePanel, aBox, x, y)
854{
855    var orderIndex = this.orderIndexOfMovingAt(x, y);
856    var maxIndex = this.getMaxOrderIndex() + 1;
857
858    // ƒpƒlƒ‹‚©‚çŠO‚ꂽA
859    // ƒpƒlƒ‹‚̍őå Box ”‚ð’´‚¦‚é = false
860    return (orderIndex != null && (this.equals(aSourcePanel) || this.box_limit_number > maxIndex));
861}
862
863/**
864 * ˆÚ“®’†A‘}“ü‚³‚ê‚é‰ÓŠ‚̃Cƒ“ƒfƒbƒNƒX‚ð•Ô‚·B
865 *
866 * @param x x À•W
867 * @param y y À•W
868 * @return ‘}“ü‚³‚ê‚éƒCƒ“ƒfƒbƒNƒXA‚È‚¯‚ê‚Î null
869 */
870Panel.prototype.orderIndexOfMovingAt = function(x, y)
871{
872    return this.findOrderIndexOf_(this.move_section, x, y);
873}
874Panel.prototype.orderIndexOfBoxAt = function(x, y)
875{
876    return this.findOrderIndexOf_(this.box_section, x, y);
877}
878// private
879Panel.prototype.findOrderIndexOf_ = function(sectionDataArray, x, y)
880{
881    for (var i = -1; i < sectionDataArray.length; i++) {
882        var sec = sectionDataArray[i];
883        if (sec == null)
884            continue;
885       
886        if (x >= sec['left'] && x <= sec['right'] &&
887            y >= sec['top']  && y <= sec['under']) {
888   
889            return i
890        }
891    }
892    return null;
893}
894
895/**
896  * setBoxPosition()
897  *
898  * Box‚ðÄ”z’u‚·‚éŠÖ”
899  */
900Panel.prototype.setBoxPosition = function() {
901    for (key in this.box_position) {
902        gAllBoxes[key].setPosition(
903            this.panel_section['left'] + BoxConfig.marginLeft,
904            this.panel_section['top']  + Panel.getBoxSectionOffsetY(this.box_position[key]) );
905    }
906}
907
908Panel.prototype.setBoxVisible = function(flag)
909{
910    for (key in this.box_position) {
911        gAllBoxes[key].setVisible(flag);
912    }
913}
914
915
916
917//---------------------------------------------------------------------------------
918// Box
919//---------------------------------------------------------------------------------
920/**
921 * ŒÂX‚̃hƒ‰ƒbƒO‚ňړ®‰Â”\‚ȍ€–Ú
922 *
923 * @param anId HTML —v‘f‚Ì id ‘®«
924 *
925 * @author Yusuke Saito
926 * @version 2003/10/10
927 *
928 * @author Takanori Ishikawa
929 * @version 2004/04/21
930 */
931function Box(anId)
932{   
933    this.uniqID     = anId;
934    this.srcElement = XBSLayer.getLayerImpById(BOX_ID_PREFIX + anId);
935
936    this.setUpSize();
937    this.x = this.y = 0;   
938}
939
940Box.prototype.getFormID = function() { return this.uniqID; }
941Box.prototype.getHTMLElement = function() { return this.srcElement; }
942
943/**
944 * HTML ‚Ì hidden input —v‘f‚Å“n‚³‚ê‚éƒvƒƒpƒeƒB‚Ì–¼‘O
945 */
946Box.POSITION_PROPERTY_NAME = "position";
947Box.ORDER_PROPERTY_NAME    = "order";
948Box.NAME_PROPERTY_NAME     = "sidefuncName";
949Box.AUTHOR_PROPERTY_NAME   = "authorCd";
950Box.ID_PROPERTY_NAME       = "sidefuncId";
951
952
953/**
954 * ƒhƒ‰ƒbƒOˆ—‚̍Œ†‚ɌĂ΂ê‚éB
955 *
956 * @param theEvent mousemove
957 * @return ƒhƒ‰ƒbƒOˆ—‚ðƒLƒƒƒ“ƒZƒ‹‚·‚éê‡‚́Afalse ‚ð•Ô‚·B
958 */
959Box.MOVABLE_INSET = 5;  /* ƒhƒLƒ…ƒƒ“ƒg‚Ì’[ - Box.MOVABLE_INSET = ƒhƒ‰ƒbƒO‰Â”\‚ȗ̈æ */
960Box.canMoveWithEvent = function(theEvent)
961{
962    // ‘Š‘Î“I‚Ȉʒu‚ª‚Ù‚µ‚¢‚̂ŁAXBSDocument.getPageOffsetX/Y() ‚ðˆø‚­
963    var mouse_x = XBSEvent.getMouseX(theEvent) - XBSDocument.getPageOffsetX();
964    var mouse_y = XBSEvent.getMouseY(theEvent) - XBSDocument.getPageOffsetY();
965   
966    if (mouse_x < Box.MOVABLE_INSET || mouse_y < Box.MOVABLE_INSET) {
967        return false;
968    }
969   
970    var maxX = XBSDocument.getWidth() - Box.MOVABLE_INSET;
971    var maxY = XBSDocument.getHeight() - Box.MOVABLE_INSET;
972   
973    if (mouse_x > maxX || mouse_y > maxY) {
974        return false;
975    }
976   
977    return true;
978}
979
980/**
981  * setUpSize()
982  *
983  * Box‚̑傫‚³‚ðÝ’è‚·‚éŠÖ”
984  */
985Box.prototype.setUpSize = function()
986{
987    var imp = this.getHTMLElement();
988   
989    // style.height ‚łȂ¢‚Æ opera ‚Å‚¤‚Ü‚­‚¢‚©‚È‚¢
990    if (XBSUtil.DOM == NN6 || XBSUtil.DOM == IE5) {
991        imp.style.height = BoxConfig.height;   
992        imp.style.width = BoxConfig.width; 
993    } else {
994        XBSLayer.setHeightWithLayerImp(imp, BoxConfig.height);
995        XBSLayer.setWidthWithLayerImp(imp, BoxConfig.width);
996    }
997    XBSLayer.setCursorWithLayerImp(imp, 'move');
998}
999
1000/**
1001  * Box‚̈ʒu‚ðÝ’è
1002  *
1003  * @param left x
1004  * @param top  y
1005  */
1006Box.prototype.setPosition = function(left, top)
1007{
1008    var imp = this.getHTMLElement();
1009    XBSLayer.initPositionStyle(imp);
1010    XBSLayer.setLeftTopPositionWithLayerImp(imp, left, top);
1011    this.x = left; this.y = top;
1012}
1013/**
1014 * Box ‚̉Ž‹‘®«‚ðÝ’è
1015 */
1016Box.prototype.setVisible = function(flag)
1017{
1018    var imp = this.getHTMLElement();
1019    XBSLayer.setVisibilityWithLayerImp(imp, flag ? XBSLayer.VISIBLE : XBSLayer.HIDDEN);
1020}
Note: See TracBrowser for help on using the repository browser.