Project

General

Profile

« Previous | Next » 

Revision 1103

Added by Matthias over 15 years ago

Fixed some display issues in argos_theme (Thanks to Argos)

View differences:

trunk/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
------------------------------------- 2.8.0 -------------------------------------
14
6-Aug-2009 Matthias Gallas
15
#	Fixed some display issues in argos_theme (Thanks to Argos)
14 16
30-July-2009 Ruud Eisinga (Ruud)
15 17
#	Fixed a bug in the /admin/media resizer parameters for dirs with whitespaces (thnx to tiesy)
16 18
#	Fixed a bug in FCKeditor include.php. Now the editor can be used from other 
trunk/wb/admin/pages/sections.php
195 195
				$edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$section['section_id'].'">'.$module_name.'</a>';
196 196
				$input_attribute = 'input_normal';
197 197
				$template->set_var(array(
198
						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility: visible;"',
198
						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility:visible;"',
199 199
						'NAME_SIZE' => 180,
200 200
						'INPUT_ATTRIBUTE' => $input_attribute,
201 201
						'VAR_SECTION_ID' => $section['section_id'],
......
221 221
				$edit_page ='<a name="'.$section['section_id'].'" href="'.ADMIN_URL.'/pages/modify.php?page_id='.$page_id.'#'.$section['section_id'].'">'.$module_name.'</a>';
222 222
				$input_attribute = 'input_small';
223 223
				$template->set_var(array(
224
						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="visibility: hidden;"',
224
						'STYLE_DISPLAY_SECTION_BLOCK' => ' style="display:none;"',
225 225
						'NAME_SIZE' => 270,
226 226
						'INPUT_ATTRIBUTE' => $input_attribute,
227 227
						'VAR_SECTION_ID' => $section['section_id'],
trunk/wb/templates/argos_theme/theme.css
88 88

  
89 89
table.pages_view {width:900px;}
90 90
table.pages_view tr {background:#f0f0f0;}
91
table.pages_view tr:hover {background:#eaeff6;}
91
table.pages_view tr:hover, tr.sectionrow:hover {background:#eaeff6;}
92 92

  
93 93
.page_list {display:none;}
94 94
.page_list_show li {display:block;}
......
99 99
.header_list_page_ID{width:40px;text-align:left;}
100 100
.header_list_actions {text-align:left;width:120px;}
101 101

  
102
.header_list_type {text-align:left;width:px;}
102
.header_list_type {text-align:left;}
103 103
.header_list_block {text-align:left;width:180px;}
104 104
.header_list_pubdate_start {text-align:left;width:200px;}
105 105
.header_list_pubdate_end {text-align:left;width:200px;}
106
.header_list_section_ID {width:55px;text-align: right;}
107 106
.header_list_sections_actions {text-align:left;width:60px;}
107
.header_list_section_ID {width:55px;text-align:left;}
108 108

  
109 109
.list_page_title {text-align:left;}
110 110
.list_menu_title {width:300px;text-align:left;}
111 111
.list_page_id {width:40px;text-align:left;}
112 112
.list_actions {width:20px;}
113
.list_type {text-align:left;width:px;}
114
.list_block {text-align:left;width:180px;}
115
.list_section_id {width:55px;text-align: right;}
116 113
.list_pubdate_start {text-align:left;width:200px;}
117
.list_pubdate_end {text-align:left;width:200px;}

114
.list_pubdate_end {text-align:left;width:200px;}
trunk/wb/templates/argos_theme/templates/pages_sections.htt
14 14
</table>
15 15

  
16 16
        <form name="section_properties" action="{ADMIN_URL}/pages/sections_save.php?page_id={VAR_PAGE_ID}" method="post">
17
		<table cellpadding="0" cellspacing="0" border="0" width="100%">
17
		
18
        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="img_noborder">
18 19
			<tr class="pages_list">
19 20
				<td class="header_list_type">{TEXT_TYPE}</td>
20
				<td class="header_list_block" {STYLE_DISPLAY_SECTION_BLOCK}>{TEXT_BLOCK}</td>
21
				<td class="header_list_block"><span {STYLE_DISPLAY_SECTION_BLOCK}>{TEXT_BLOCK}&nbsp;</span></td>
21 22
				<td class="header_list_pubdate_start">{TEXT_PUBL_START_DATE}</td>
22 23
				<td class="header_list_pubdate_end">{TEXT_PUBL_END_DATE}</td>
23
				<td class="header_list_sections_actions">{TEXT_ACTIONS}</td>
24
				<td class="header_list_section_ID">SID</td>
24
				<td class="header_list_sections_actions" colspan="3">{TEXT_ACTIONS}</td>
25
				<td class="header_list_section_ID">{TEXT_SID}</td>
26
				<td {DISPLAY_DEBUG}>{TEXT_PID}</td>
25 27
			</tr>
26
		</table>
27
		
28
        <table cellpadding="0" cellspacing="0" border="0" width="100%" class="img_noborder">
29 28
<!-- BEGIN section_block -->
30
            	<tr>
31
    				<td align="right" style="display:none;" width="5">
29
            	<tr class="sectionrow">
30
    				<td align="right" style="display:none;">
32 31
                      <input type="hidden" name="page_id" value="{VAR_PAGE_ID}"  />
33 32
                      <input type="hidden" name="section_id" value="{VAR_SECTION_ID}"  />
34 33
                      {VAR_SECTION_ID}
35 34
                    </td>
36
                    <td class="list_type">{LINK_MODIFY_URL_VAR_MODUL_NAME}</td>
37
                    <td class="list_block {INPUT_ATTRIBUTE}" {STYLE_DISPLAY_SECTION_BLOCK}>
35
					
36
                    <td>{LINK_MODIFY_URL_VAR_MODUL_NAME}</td>
37
					
38
                    <td class="{INPUT_ATTRIBUTE}"><span {STYLE_DISPLAY_SECTION_BLOCK}>
38 39
                    	<select name="block{VAR_SECTION_ID}" class="input_normal">
39 40
                        {SET_NONE_DISPLAY_OPTION}
40 41
                    	<!-- BEGIN block_block -->
41 42
                    		<option value="{VALUE}"{SELECTED}>{NAME}</option>
42 43
                    	<!-- END block_block -->
43
                    	</select>
44
                    	</select></span>&nbsp;
44 45
                    </td>
45
                    <td class="list_pubdate_start"><input type="text" id="start_date{VAR_SECTION_ID}" name="start_date{VAR_SECTION_ID}" value="{VALUE_PUBL_START}" class="input_normal" />
46
					
47
                    <td><input type="text" id="start_date{VAR_SECTION_ID}" name="start_date{VAR_SECTION_ID}" value="{VALUE_PUBL_START}" class="input_normal" />
46 48
                        <img src="{THEME_URL}/images/{CLOCK_16_PNG}" id="trigger_start{VAR_SECTION_ID}" style="cursor:pointer;" title="{TEXT_CALENDAR}" alt="{TEXT_CALENDAR}"  />
47 49
                        <img src="{THEME_URL}/images/{CLOCK_DEL_16_PNG}" style="cursor:pointer;" alt="{TEXT_DELETE_DATE}" title="{TEXT_DELETE_DATE}" onclick="document.section_properties.start_date{VAR_SECTION_ID}.value=''" />
48 50
                    </td>
49
                    <td class="list_pubdate_end"><input type="text" id="end_date{VAR_SECTION_ID}" name="end_date{VAR_SECTION_ID}" value="{VALUE_PUBL_END}" class="input_normal" />
51
					
52
                    <td><input type="text" id="end_date{VAR_SECTION_ID}" name="end_date{VAR_SECTION_ID}" value="{VALUE_PUBL_END}" class="input_normal" />
50 53
                        <img src="{THEME_URL}/images/{CLOCK_16_PNG}" id="trigger_stop{VAR_SECTION_ID}" alt="{TEXT_CALENDAR}" style="cursor: pointer;" title="{TEXT_CALENDAR}"  />
51 54
                        <img src="{THEME_URL}/images/{CLOCK_DEL_16_PNG}" style="cursor:pointer;" alt="{TEXT_DELETE_DATE}" title="{TEXT_DELETE_DATE}" onclick="document.section_properties.end_date{VAR_SECTION_ID}.value=''" />
52 55
                    </td>
53 56

  
54
					<td class="list_actions">{VAR_MOVE_UP_URL}</td>
55
                    <td class="list_actions">{VAR_MOVE_DOWN_URL}</td>
56
                    <td class="list_actions">
57
					<td>{VAR_MOVE_UP_URL}</td>
58
					
59
                    <td>{VAR_MOVE_DOWN_URL}</td>
60
					
61
                    <td>
57 62
                        <a href="javascript: confirm_link('{TEXT_ARE_YOU_SURE}', '{ADMIN_URL}/pages/sections.php?page_id={VAR_PAGE_ID}&amp;section_id={VAR_SECTION_ID}');">
58 63
                        <img src="{THEME_URL}/images/{DELETE_16_PNG}" alt="{TEXT_DELETE}" border="0" />
59 64
                        </a>
60 65
                    </td>
61
                    <td class="list_section_id">{VAR_SECTION_ID}</td>
66
					
67
                    <td>{VAR_SECTION_ID}</td>
68
					
62 69
                    <td {DISPLAY_DEBUG}>{POSITION}</td>
63 70
                </tr>
64

  
65 71
<!-- END section_block -->
66 72
                <tr>
67 73
                    <td align="left" colspan="{DEBUG_COLSPAN_SIZE}">
trunk/wb/modules/jsadmin/js/dragdrop.js
1
// Copyright 2006 Stepan Riha
2
// www.nonplus.net
3
// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $
4
/**
5
* -----------------------------------------------------------------------------------------
6
*  MODIFICATON FOR THE JSADMIN MODULE
7
* -----------------------------------------------------------------------------------------
8
*	MODIFICATION HISTORY:
9
*   Swen Uth; 01/24/2008
10
*   +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS
11
*
12
**/
13
JsAdmin.DD = {};
14
JsAdmin.movable_rows = {};
15
	
16
JsAdmin.init_drag_drop = function() {
17

  
18
	// There seems to be many different ways the ordering is set up
19
	//		pages/index.php has UL/LI containing tables with single row
20
	//		pages/sections.php has a TABLE with many rows
21
	//		pages/modify.php for manuals is completely weird...
22
	// So we only want to deal with pages & sections...
23

  
24
	var page_type = '';
25
	var is_tree = false;
26

  
27
	if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
28
		page_type = 'pages';
29
		is_tree = true;
30

  
31
		// This page uses duplicate IDs and incorrectly nested lists:
32
		// <ul id="p1">
33
		//		<li id="p1"><table /></li>
34
		//		<ul>... sub items ...</ul>
35
		// </ul>
36
		//
37
		// We need to fix that to the following:
38
		// <ul id="p1">
39
		//		<li id="uniqueID"><table />
40
		//		<ul>... sub items ...</ul>
41
		//		</li>
42
		// </ul>
43

  
44
		// Stash all UL ids
45
		var ids = {};
46
		var lists = document.getElementsByTagName('ul');
47
		for(var i = 0; i < lists.length; i++) {
48
			if(lists[i].id) {
49
				ids[lists[i].id] = true;
50
			}
51
		}
52

  
53
		// Now fix all LIs
54
		var items = document.getElementsByTagName('li');
55
 		for(var i = 0; i < items.length; i++) {
56
			var item = items[i];
57

  
58
			// Fix duplicate ID
59
			if(ids[item.id]) {
60
				item.id =  JsAdmin.util.getUniqueId();
61
			}
62

  
63
			// Fix UL parented by UL
64
			var ul = JsAdmin.util.getNextSiblingNode(item, 'ul');
65
			if(ul) {
66
				var lis = ul.getElementsByTagName('li');
67
 				if(!lis || lis.length == 0) {
68
					// Remove list without items
69
					ul.parentNode.removeChild(ul);
70
				} else {
71
					// Make list child of list item
72
					item.appendChild(ul);
73
				}
74
			}
75
		}
76

  
77
	} else if(document.URL.indexOf("/admin/pages/sections.php") > 0) {
78
		page_type = 'sections';
79
	} else {
80
		// We don't do any other pages
81
		return;
82
	}
83

  
84
	var links = document.getElementsByTagName('a');
85
	var reImg = /(.*)move_(down|up)\.php(.*)/;
86

  
87
	for(var i = 0; i < links.length; i++) {
88
		var link = links[i];
89
		var href = link.href || '';
90
		var match = href.match(reImg);
91
		if(!match) {
92
			continue;
93
		}
94
		var url = match[1];
95
		var op = match[2];
96
		var params = match[3];
97
		var tr = JsAdmin.util.getAncestorNode(link, 'tr');
98
		var item = is_tree ? JsAdmin.util.getAncestorNode(tr, 'li') : tr;
99
		if(!item) {
100
			continue;
101
		}
102

  
103
		// Make sure we have a unique id
104
		if(!item.id || YAHOO.util.Dom.get(item.id) != item) {
105
			item.id = JsAdmin.util.getUniqueId();
106
		}
107

  
108
		if(is_tree) {
109
			var parent = JsAdmin.util.getAncestorNode(item, 'ul');
110
			new JsAdmin.DD.liDDSwap(item.id, (parent && parent.id) ? parent.id : 'top');
111
		} else {
112
			new JsAdmin.DD.trDDSwap(item.id);
113
		}
114
		item.className += " jsadmin_drag";
115

  
116
		this.movable_rows[item.id] = { item: item, tr : tr, url : url, params : params };
117
	}
118
};
119

  
120
//==========================================================================
121
// Drag-drop utils
122
//==========================================================================
123

  
124
JsAdmin.DD.dragee = null;
125

  
126
JsAdmin.DD.addMoveButton = function(tr, cell, op) {
127
	if(op == 'down') {
128
		cell++;
129
	}
130
	var item = JsAdmin.movable_rows[tr.id];
131
	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
132
		var rows = tr.getElementsByTagName('tr');
133
		tr = rows[0];
134
	}
135
	
136
	var html = '<a href="' + item.url + 'move_' + op + '.php' + item.params
137
				+ '"><img src="' + JsAdminTheme.THEME_URL + '/images/' + op
138
				+ '_16.png" border="0" alt="' + op + '" /></a>';
139
	tr.cells[cell].innerHTML = html;
140
};
141

  
142
JsAdmin.DD.deleteMoveButton = function(tr, cell, op) {
143
	if(op == 'down') {
144
		cell++;
145
	}
146
	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
147
		var rows = tr.getElementsByTagName('tr');
148
		tr = rows[0];
149
	}
150
	
151
	tr.cells[cell].innerHTML = "";
152
};
153

  
154
//==========================================================================
155
// Drag-drop handling for table rows
156
//==========================================================================
157

  
158
JsAdmin.DD.trDDSwap = function(id, sGroup) {
159
    this.init(id, sGroup);
160
	this.addInvalidHandleType('a');
161
	this.addInvalidHandleType('input');
162
	this.addInvalidHandleType('select');
163
    this.initFrame();
164
	this.buttonCell = buttonCell;//, by Swen Uth
165
	
166
	// For Connection
167
	this.scope = this;
168
};
169

  
170
JsAdmin.DD.trDDSwap.prototype = new YAHOO.util.DDProxy();
171

  
172
JsAdmin.DD.trDDSwap.prototype.startDrag = function(x, y) {
173
	if (JsAdmin.DD.dragee != this) {
174
		this.rowIndex = this.getEl().rowIndex;
175
		this.numRows = this.getEl().parentNode.rows.length;
176
		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
177
		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
178
		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
179
		YAHOO.util.Dom.setStyle(this.getEl(), "background", "#dde");
180
	}
181
	JsAdmin.DD.dragee = this;
182
};
183

  
184
JsAdmin.DD.trDDSwap.prototype.onDragEnter = function(e, id) {
185
  var elt = id ? YAHOO.util.Dom.get(id) : null;
186
	var item = JsAdmin.movable_rows[this.getEl().id];
187
	var rows = item.tr.parentNode.rows;
188
	var wasFirst = item.tr.rowIndex == 1;
189
	var wasLast = item.tr.rowIndex == this.numRows - 2;
190
	if(elt.rowIndex < item.tr.rowIndex) {
191
		elt.parentNode.insertBefore(item.tr, elt);
192
	} else {
193
		elt.parentNode.insertBefore(elt, item.tr);
194
	}
195
	// Fixup buttons
196
	var isFirst = item.tr.rowIndex == 1;
197
	var isLast = item.tr.rowIndex == this.numRows - 2;
198

  
199
	if(wasFirst != isFirst) {
200
		if(isFirst) {
201
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
202
			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.tr), this.buttonCell, 'up');
203
		} else {
204
			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'up');
205
			JsAdmin.DD.deleteMoveButton(rows[1], this.buttonCell, 'up');
206
		}
207
	}
208
	if(wasLast != isLast) {
209
		if(isLast) {
210
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
211
			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.tr), this.buttonCell, 'down');
212
		} else {
213
			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'down');
214
			JsAdmin.DD.deleteMoveButton(rows[rows.length-2], this.buttonCell, 'down');
215
		}
216
	}
217

  
218
	this.DDM.refreshCache(this.groups);
219
};
220

  
221
JsAdmin.DD.trDDSwap.prototype.endDrag = function(e) {
222
	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
223
	YAHOO.util.Dom.setStyle(this.getEl(), "background", "white");
224
	
225
	JsAdmin.DD.dragee = null;
226

  
227
	var newIndex = this.getEl().rowIndex;
228
	if(newIndex != this.rowIndex) {
229
		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
230
		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + newIndex;
231
		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
232
		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
233
	}
234
};
235

  
236
JsAdmin.DD.trDDSwap.prototype.success = function(o) {
237
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
238
};
239

  
240
JsAdmin.DD.trDDSwap.prototype.failure = function(o) {
241
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
242
};
243

  
244
//==========================================================================
245
// Drag-drop handling for list items
246
//==========================================================================
247

  
248
JsAdmin.DD.liDDSwap = function(id, sGroup) {
249
    this.init(id, sGroup);
250
	this.addInvalidHandleType('a');
251
	this.addInvalidHandleType('input');
252
	this.addInvalidHandleType('select');
253
    this.initFrame();
254
 this.buttonCell = buttonCell;//, by Swen Uth
255
	this.counter = 0;
256
};
257

  
258
JsAdmin.DD.liDDSwap.prototype = new YAHOO.util.DDProxy();
259

  
260
JsAdmin.DD.liDDSwap.prototype.startDrag = function(x, y) {
261
	// On IE, startDrag is sometimes called twice
262
	if(JsAdmin.DD.dragee && JsAdmin.DD.dragee != this) {
263
		JsAdmin.DD.dragee.endDrag(null);
264
	}
265
	if(JsAdmin.DD.dragee != this) {
266
		this.rowIndex = JsAdmin.util.getItemIndex(this.getEl());
267
		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
268
		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
269
		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
270

  
271
		this.list = JsAdmin.util.getAncestorNode(this.getEl(), "ul");
272
		this.list.className += " jsadmin_drag_area";
273
	}
274
	JsAdmin.DD.dragee = this;
275
};
276

  
277
JsAdmin.DD.liDDSwap.prototype.onDragEnter = function(e, id) {
278
	// Swap with other element
279
	var elt = id ? YAHOO.util.Dom.get(id) : null;
280
	var item = JsAdmin.movable_rows[this.getEl().id];
281
	var eltRowIndex = JsAdmin.util.getItemIndex(elt);
282
	var rowIndex = JsAdmin.util.getItemIndex(this.getEl());
283
	var wasFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
284
	var wasLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
285

  
286
	if(eltRowIndex < rowIndex) {
287
		elt.parentNode.insertBefore(this.getEl(), elt);
288
	} else {
289
		elt.parentNode.insertBefore(elt, this.getEl());
290
	}
291
	// Fixup buttons
292
	var isFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
293
	var isLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
294

  
295
	if(wasFirst != isFirst) {
296
		if(isFirst) {
297
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
298
			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.item), this.buttonCell, 'up');
299
		} else {
300
			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'up');
301
			var first, prev = JsAdmin.util.getPreviousSiblingNode(item.item);
302
			while(prev) {
303
				first = prev;
304
				prev = JsAdmin.util.getPreviousSiblingNode(prev);
305
			}
306
			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[first.id].tr, this.buttonCell, 'up');
307
		}
308
	}
309
	if(wasLast != isLast) {
310
		if(isLast) {
311
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
312
			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.item), this.buttonCell, 'down');
313
		} else {
314
			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'down');
315
			var last, next = JsAdmin.util.getNextSiblingNode(item.item);
316
			while(next) {
317
				last = next;
318
				next = JsAdmin.util.getNextSiblingNode(next);
319
			}
320
			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[last.id].tr, this.buttonCell, 'down');
321
		}
322
	}
323

  
324
	this.DDM.refreshCache(this.groups);
325
};
326

  
327
JsAdmin.DD.liDDSwap.prototype.endDrag = function(e) {
328
	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
329
	this.list.className = String(this.list.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1");
330
	JsAdmin.DD.dragee = null;
331
	var newIndex = JsAdmin.util.getItemIndex(this.getEl());
332
	if(newIndex != this.rowIndex) {
333
		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
334
		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + (newIndex+1);
335
		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
336
		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
337
	}
338
};
339

  
340
JsAdmin.DD.liDDSwap.prototype.success = function(o) {
341
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
342
};
343

  
344
JsAdmin.DD.liDDSwap.prototype.failure = function(o) {
345
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
346
};
1
// Copyright 2006 Stepan Riha
2
// www.nonplus.net
3
// $Id: dragdrop.js 2 2006-04-18 03:04:39Z stepan $
4
/**
5
* -----------------------------------------------------------------------------------------
6
*  MODIFICATON FOR THE JSADMIN MODULE
7
* -----------------------------------------------------------------------------------------
8
*	MODIFICATION HISTORY:
9
*   Swen Uth; 01/24/2008
10
*   +INCLUDE VARIABLE buttonCell FOR ADAPTATION TO LATER LAYOUTS
11
*
12
**/
13
JsAdmin.DD = {};
14
JsAdmin.movable_rows = {};
15
	
16
JsAdmin.init_drag_drop = function() {
17

  
18
	// There seems to be many different ways the ordering is set up
19
	//		pages/index.php has UL/LI containing tables with single row
20
	//		pages/sections.php has a TABLE with many rows
21
	//		pages/modify.php for manuals is completely weird...
22
	// So we only want to deal with pages & sections...
23

  
24
	var page_type = '';
25
	var is_tree = false;
26

  
27
	if(document.URL.indexOf(JsAdmin.ADMIN_URL + "/pages/index.php") > -1) {
28
		page_type = 'pages';
29
		is_tree = true;
30

  
31
		// This page uses duplicate IDs and incorrectly nested lists:
32
		// <ul id="p1">
33
		//		<li id="p1"><table /></li>
34
		//		<ul>... sub items ...</ul>
35
		// </ul>
36
		//
37
		// We need to fix that to the following:
38
		// <ul id="p1">
39
		//		<li id="uniqueID"><table />
40
		//		<ul>... sub items ...</ul>
41
		//		</li>
42
		// </ul>
43

  
44
		// Stash all UL ids
45
		var ids = {};
46
		var lists = document.getElementsByTagName('ul');
47
		for(var i = 0; i < lists.length; i++) {
48
			if(lists[i].id) {
49
				ids[lists[i].id] = true;
50
			}
51
		}
52

  
53
		// Now fix all LIs
54
		var items = document.getElementsByTagName('li');
55
 		for(var i = 0; i < items.length; i++) {
56
			var item = items[i];
57

  
58
			// Fix duplicate ID
59
			if(ids[item.id]) {
60
				item.id =  JsAdmin.util.getUniqueId();
61
			}
62

  
63
			// Fix UL parented by UL
64
			var ul = JsAdmin.util.getNextSiblingNode(item, 'ul');
65
			if(ul) {
66
				var lis = ul.getElementsByTagName('li');
67
 				if(!lis || lis.length == 0) {
68
					// Remove list without items
69
					ul.parentNode.removeChild(ul);
70
				} else {
71
					// Make list child of list item
72
					item.appendChild(ul);
73
				}
74
			}
75
		}
76

  
77
	} else if(document.URL.indexOf("/admin/pages/sections.php") > 0) {
78
		page_type = 'sections';
79
	} else {
80
		// We don't do any other pages
81
		return;
82
	}
83

  
84
	var links = document.getElementsByTagName('a');
85
	var reImg = /(.*)move_(down|up)\.php(.*)/;
86

  
87
	for(var i = 0; i < links.length; i++) {
88
		var link = links[i];
89
		var href = link.href || '';
90
		var match = href.match(reImg);
91
		if(!match) {
92
			continue;
93
		}
94
		var url = match[1];
95
		var op = match[2];
96
		var params = match[3];
97
		var tr = JsAdmin.util.getAncestorNode(link, 'tr');
98
		var item = is_tree ? JsAdmin.util.getAncestorNode(tr, 'li') : tr;
99
		if(!item) {
100
			continue;
101
		}
102

  
103
		// Make sure we have a unique id
104
		if(!item.id || YAHOO.util.Dom.get(item.id) != item) {
105
			item.id = JsAdmin.util.getUniqueId();
106
		}
107

  
108
		if(is_tree) {
109
			var parent = JsAdmin.util.getAncestorNode(item, 'ul');
110
			new JsAdmin.DD.liDDSwap(item.id, (parent && parent.id) ? parent.id : 'top');
111
		} else {
112
			new JsAdmin.DD.trDDSwap(item.id);
113
		}
114
		item.className += " jsadmin_drag";
115

  
116
		this.movable_rows[item.id] = { item: item, tr : tr, url : url, params : params };
117
	}
118
};
119

  
120
//==========================================================================
121
// Drag-drop utils
122
//==========================================================================
123

  
124
JsAdmin.DD.dragee = null;
125

  
126
JsAdmin.DD.addMoveButton = function(tr, cell, op) {
127
	if(op == 'down') {
128
		cell++;
129
	}
130
	var item = JsAdmin.movable_rows[tr.id];
131
	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
132
		var rows = tr.getElementsByTagName('tr');
133
		tr = rows[0];
134
	}
135
	
136
	var html = '<a href="' + item.url + 'move_' + op + '.php' + item.params
137
				+ '"><img src="' + JsAdminTheme.THEME_URL + '/images/' + op
138
				+ '_16.png" border="0" alt="' + op + '" /></a>';
139
	tr.cells[cell].innerHTML = html;
140
};
141

  
142
JsAdmin.DD.deleteMoveButton = function(tr, cell, op) {
143
	if(op == 'down') {
144
		cell++;
145
	}
146
	if(!JsAdmin.util.isNodeType(tr, 'tr')) {
147
		var rows = tr.getElementsByTagName('tr');
148
		tr = rows[0];
149
	}
150
	
151
	tr.cells[cell].innerHTML = "";
152
};
153

  
154
//==========================================================================
155
// Drag-drop handling for table rows
156
//==========================================================================
157

  
158
JsAdmin.DD.trDDSwap = function(id, sGroup) {
159
    this.init(id, sGroup);
160
	this.addInvalidHandleType('a');
161
	this.addInvalidHandleType('input');
162
	this.addInvalidHandleType('select');
163
    this.initFrame();
164
	this.buttonCell = buttonCell;//, by Swen Uth
165
	
166
	// For Connection
167
	this.scope = this;
168
};
169

  
170
JsAdmin.DD.trDDSwap.prototype = new YAHOO.util.DDProxy();
171

  
172
JsAdmin.DD.trDDSwap.prototype.startDrag = function(x, y) {
173
	if (JsAdmin.DD.dragee != this) {
174
		this.rowIndex = this.getEl().rowIndex;
175
		this.numRows = this.getEl().parentNode.rows.length;
176
		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
177
		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
178
		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
179
		YAHOO.util.Dom.setStyle(this.getEl(), "background", "#dde");
180
	}
181
	JsAdmin.DD.dragee = this;
182
};
183

  
184
JsAdmin.DD.trDDSwap.prototype.onDragEnter = function(e, id) {
185
  var elt = id ? YAHOO.util.Dom.get(id) : null;
186
	var item = JsAdmin.movable_rows[this.getEl().id];
187
	var rows = item.tr.parentNode.rows;
188
	var wasFirst = item.tr.rowIndex == 1;
189
	var wasLast = item.tr.rowIndex == this.numRows - 2;
190
	if(elt.rowIndex < item.tr.rowIndex) {
191
		elt.parentNode.insertBefore(item.tr, elt);
192
	} else {
193
		elt.parentNode.insertBefore(elt, item.tr);
194
	}
195
	// Fixup buttons
196
	var isFirst = item.tr.rowIndex == 1;
197
	var isLast = item.tr.rowIndex == this.numRows - 2;
198

  
199
	if(wasFirst != isFirst) {
200
		if(isFirst) {
201
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
202
			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.tr), this.buttonCell, 'up');
203
		} else {
204
			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'up');
205
			JsAdmin.DD.deleteMoveButton(rows[1], this.buttonCell, 'up');
206
		}
207
	}
208
	if(wasLast != isLast) {
209
		if(isLast) {
210
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
211
			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.tr), this.buttonCell, 'down');
212
		} else {
213
			JsAdmin.DD.addMoveButton(item.tr, this.buttonCell, 'down');
214
			JsAdmin.DD.deleteMoveButton(rows[rows.length-2], this.buttonCell, 'down');
215
		}
216
	}
217

  
218
	this.DDM.refreshCache(this.groups);
219
};
220

  
221
JsAdmin.DD.trDDSwap.prototype.endDrag = function(e) {
222
	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
223
	YAHOO.util.Dom.setStyle(this.getEl(), "background", "transparent");
224
	
225
	JsAdmin.DD.dragee = null;
226

  
227
	var newIndex = this.getEl().rowIndex;
228
	if(newIndex != this.rowIndex) {
229
		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
230
		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + newIndex;
231
		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
232
		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
233
	}
234
};
235

  
236
JsAdmin.DD.trDDSwap.prototype.success = function(o) {
237
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
238
};
239

  
240
JsAdmin.DD.trDDSwap.prototype.failure = function(o) {
241
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
242
};
243

  
244
//==========================================================================
245
// Drag-drop handling for list items
246
//==========================================================================
247

  
248
JsAdmin.DD.liDDSwap = function(id, sGroup) {
249
    this.init(id, sGroup);
250
	this.addInvalidHandleType('a');
251
	this.addInvalidHandleType('input');
252
	this.addInvalidHandleType('select');
253
    this.initFrame();
254
 this.buttonCell = buttonCell;//, by Swen Uth
255
	this.counter = 0;
256
};
257

  
258
JsAdmin.DD.liDDSwap.prototype = new YAHOO.util.DDProxy();
259

  
260
JsAdmin.DD.liDDSwap.prototype.startDrag = function(x, y) {
261
	// On IE, startDrag is sometimes called twice
262
	if(JsAdmin.DD.dragee && JsAdmin.DD.dragee != this) {
263
		JsAdmin.DD.dragee.endDrag(null);
264
	}
265
	if(JsAdmin.DD.dragee != this) {
266
		this.rowIndex = JsAdmin.util.getItemIndex(this.getEl());
267
		this.opacity = YAHOO.util.Dom.getStyle(this.getEl(), "opacity");
268
		this.background = YAHOO.util.Dom.getStyle(this.getEl(), "background");
269
		YAHOO.util.Dom.setStyle(this.getEl(), "opacity", 0.5);
270

  
271
		this.list = JsAdmin.util.getAncestorNode(this.getEl(), "ul");
272
		this.list.className += " jsadmin_drag_area";
273
	}
274
	JsAdmin.DD.dragee = this;
275
};
276

  
277
JsAdmin.DD.liDDSwap.prototype.onDragEnter = function(e, id) {
278
	// Swap with other element
279
	var elt = id ? YAHOO.util.Dom.get(id) : null;
280
	var item = JsAdmin.movable_rows[this.getEl().id];
281
	var eltRowIndex = JsAdmin.util.getItemIndex(elt);
282
	var rowIndex = JsAdmin.util.getItemIndex(this.getEl());
283
	var wasFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
284
	var wasLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
285

  
286
	if(eltRowIndex < rowIndex) {
287
		elt.parentNode.insertBefore(this.getEl(), elt);
288
	} else {
289
		elt.parentNode.insertBefore(elt, this.getEl());
290
	}
291
	// Fixup buttons
292
	var isFirst = !JsAdmin.util.getPreviousSiblingNode(this.getEl());
293
	var isLast = !JsAdmin.util.getNextSiblingNode(this.getEl());
294

  
295
	if(wasFirst != isFirst) {
296
		if(isFirst) {
297
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'up');
298
			JsAdmin.DD.addMoveButton(JsAdmin.util.getNextSiblingNode(item.item), this.buttonCell, 'up');
299
		} else {
300
			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'up');
301
			var first, prev = JsAdmin.util.getPreviousSiblingNode(item.item);
302
			while(prev) {
303
				first = prev;
304
				prev = JsAdmin.util.getPreviousSiblingNode(prev);
305
			}
306
			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[first.id].tr, this.buttonCell, 'up');
307
		}
308
	}
309
	if(wasLast != isLast) {
310
		if(isLast) {
311
			JsAdmin.DD.deleteMoveButton(item.tr, this.buttonCell, 'down');
312
			JsAdmin.DD.addMoveButton(JsAdmin.util.getPreviousSiblingNode(item.item), this.buttonCell, 'down');
313
		} else {
314
			JsAdmin.DD.addMoveButton(item.item, this.buttonCell, 'down');
315
			var last, next = JsAdmin.util.getNextSiblingNode(item.item);
316
			while(next) {
317
				last = next;
318
				next = JsAdmin.util.getNextSiblingNode(next);
319
			}
320
			JsAdmin.DD.deleteMoveButton(JsAdmin.movable_rows[last.id].tr, this.buttonCell, 'down');
321
		}
322
	}
323

  
324
	this.DDM.refreshCache(this.groups);
325
};
326

  
327
JsAdmin.DD.liDDSwap.prototype.endDrag = function(e) {
328
	YAHOO.util.Dom.setStyle(this.getEl(), "opacity", this.opacity);
329
	this.list.className = String(this.list.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1");
330
	JsAdmin.DD.dragee = null;
331
	var newIndex = JsAdmin.util.getItemIndex(this.getEl());
332
	if(newIndex != this.rowIndex) {
333
		var url = JsAdmin.WB_URL + "/modules/jsadmin/move_to.php";
334
		url += JsAdmin.movable_rows[this.getEl().id].params + "&position=" + (newIndex+1);
335
		document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_busy";
336
		YAHOO.util.Connect.asyncRequest('GET', url, this, null);
337
	}
338
};
339

  
340
JsAdmin.DD.liDDSwap.prototype.success = function(o) {
341
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/g, "$1") + " jsadmin_success";
342
};
343

  
344
JsAdmin.DD.liDDSwap.prototype.failure = function(o) {
345
	document.body.className = String(document.body.className).replace(/(\s*)jsadmin_([a-z]+)/, "$1") + " jsadmin_failure";
346
};

Also available in: Unified diff