PageSourceSearch

https://forum.awd.ru/styles/prosilver/template/js/active-forums.js

js awd.ru collected 2026-10-02 03:22:58 UTC 14,894 bytes, 514 lines download raw bytes

1var FlagMovingIsInited = false;
2var FlagMoving = false;
3var ForumsIsConfig = false;
4var ForumsIsConfigIsInited = false;
5
6var SortContainer = ".forum-container";
7var SortForumsSequence = '';
8
9var ResponsePage = "ajax/active-forums.php";
10
11var ErrorShortDisable = 'Ошибка: Не удалось сохранить порядок форумов. Пожалуйста, обратитесь к администратору.';
12var ErrorVisibilityDisable = 'Ошибка: Не удалось сохранить состояние форума (скрытие). Пожалуйста, обратитесь к администратору.';
13var ErrorStatusesDisable = 'Ошибка: Не удалось сохранить состояние форума (отключение). Пожалуйста, обратитесь к администратору.';
14
15var anchar_pic_1 = IMAGESET_PATH + '/active-forums-anchor.gif';
16var anchar_pic_2 = IMAGESET_PATH + '/active-forums-anchor-2.gif';
17var show_pic = IMAGESET_PATH + '/active-forums-show.gif';
18var hide_pic = IMAGESET_PATH + '/active-forums-hide.gif';
19var hide_d_pic = IMAGESET_PATH + '/active-forums-hide-disable.gif';
20var close_pic = IMAGESET_PATH + '/active-forums-close.gif';
21var close_d_pic = IMAGESET_PATH + '/active-forums-close-disable.gif';
22var open_pic = IMAGESET_PATH + '/active-forums-start.gif';
23var config_pic_1 = IMAGESET_PATH + '/active-forums-config.gif';
24var config_pic_2 = IMAGESET_PATH + '/active-forums-config-2.gif';
25
26var current_forum = null;
27var forum_control_hide_show_icon = null;
28var forum_control_open_close_icon = null;
29
30var background_position_ie_fix = null;
31
32$(function() {
33		   if(!$( SortContainer ).sortable)
34		   	   return;
35	// ======================================================================
36	// Категории
37	// ======================================================================
38		   		   
39	// -------------------------------------
40	// Настройка перемещения форумов
41	// -------------------------------------
42	
43	$( SortContainer ).sortable({
44		axis: 'y',
45		cursor: 'crosshair',
46		opacity: 0.8,
47		scroll: true,
48		handle: '.drag-handle',
49		distance: 0,
50		
51		update: function(event, ui) {
52			SortForumsSequence = '';
53			
54			$( SortContainer + ' *[category_id]').each( function( i ) {
55				var category_id = $( this ).attr('category_id');
56				
57				if ( SortForumsSequence == '' ) {
58					SortForumsSequence += category_id;
59				} else {
60					SortForumsSequence += ',' + category_id;
61				}
62			});
63			
64			$.post( 
65				ResponsePage,
66				{ 
67					'IsAjax': "yes", 
68					'Action': "Sort",
69					'SortForumsSequence': SortForumsSequence
70				},
71				function(data){
72					if ( data != '1' ) {
73						alert( ErrorShortDisable );
74					}
75				}
76			);
77		}
78	
79	});
80	
81	$( SortContainer ).sortable( 'disable' );
82	
83	$( SortContainer ).disableSelection();
84
85	// ------------------------------------------
86	// Скрытие и отображение форумов
87	// ------------------------------------------
88	$('.show-hide-icon').each( function( i ) {
89										
90		$( this ).click( function () {
91			var src = $( this ).attr( 'src' );
92			var category_id = GetCategory( this ).attr('category_id'); 
93			var category_content = GetCategoryContent( this ); 
94			var category_cab_be_fliped = GetCategory( this ).attr('can_be_fliped');  
95
96			if ( src == show_pic  ) {
97
98				$( this ).attr( 'src', hide_pic );
99				SetVisibility( category_content, true, true ); 
100				hidden_categories_count -= 1;
101				var state = 'on'; 
102				SaveState( "Visibility", category_id, 0, state );
103				
104			} else {
105				if ( category_cab_be_fliped == 'yes' ) {
106					$( this ).attr( 'src', show_pic );
107					SetVisibility( category_content, false, true );  
108					hidden_categories_count += 1;
109					var state = 'off';
110					SaveState( "Visibility", category_id, 0, state );
111				}				
112			}
113			
114			$('#active-forums-hidden-cat').text( hidden_categories_count );			
115		});
116		
117	});
118	
119	// ------------------------------------------
120	// Закрытие форумов
121	// ------------------------------------------
122	$('.close-open-icon').each( function( i ) {
123										
124		$( this ).click( function () {
125			var src = $( this ).attr( 'src' );
126			var category = GetCategory( this ); 
127			
128			if ( category ) {
129				
130				var category_id = category.attr('category_id'); 
131				var category_status = category.attr('category_status');
132				var category_cab_be_deleted = category.attr('can_be_deleted');  
133				
134				if ( showing_all_forums ) {
135					
136					if ( category_status == 'closed' ) {
137						$( this ).attr( 'src', close_pic );
138						category.removeClass('category-invisible');	
139						category.attr('category_status', 'opened');
140						closed_categories_count -= 1;
141						var state = 'on'; 
142						SaveState( "Statuses", category_id, 0, state );
143						
144					} else {
145						if ( category_cab_be_deleted == 'yes' ) {
146							$( this ).attr( 'src', open_pic );
147							category.addClass('category-invisible');
148							category.attr('category_status', 'closed');
149							closed_categories_count += 1;
150							var state = 'off'; 
151							SaveState( "Statuses", category_id, 0, state );
152						}
153					}
154					
155				} else {
156					if ( category_cab_be_deleted == 'yes' ) {
157						category.css('display', 'none');
158						category.attr('category_status', 'closed');
159						closed_categories_count += 1;
160						SaveState( "Statuses", category_id, 0, state );
161					}
162				}
163								
164			}			
165			
166			$('#active-forums-closed-cat').text( closed_categories_count );			
167			
168		});
169	});
170	
171	// ------------------------------------------
172	// Перемещение форумов
173	// ------------------------------------------
174	$('.drag-icon').each( function( i ) {
175		$( this ).click( function () {
176			if ( ( FlagMoving == true ) || ( FlagMovingIsInited == false ) ) {
177				
178				FlagMoving = false;
179				FlagMovingIsInited = true;
180				
181				$('.drag-icon').attr( 'src', anchar_pic_2 );
182				
183				$( 'ul.forums' ).each( function() {
184					SetVisibility( this, false, false );
185				})
186				
187				$(".forum-container").sortable( 'enable' );
188				
189				$('.show-hide-icon').addClass( 'icon-hidden' );
190				$('.close-open-icon').addClass( 'icon-hidden' );
191				$('.drag-handle').removeClass( 'icon-hidden' );
192				$('.drag-handle2').removeClass( 'icon-hidden' );
193				
194			} else {
195				
196				FlagMoving = true;
197				
198				$('.drag-icon').attr( 'src', anchar_pic_1 );
199								
200				$( 'ul.forums' ).each( function() {
201					SetVisibility( this, true, false );
202				})
203				
204				$(".forum-container").sortable( 'disable' );
205				
206				$('.show-hide-icon').removeClass( 'icon-hidden' );
207				$('.close-open-icon').removeClass( 'icon-hidden' );
208				$('.drag-handle').addClass( 'icon-hidden' );
209				$('.drag-handle2').addClass( 'icon-hidden' );
210
211			}
212		});
213	});
214	
215	// ------------------------------------------
216	// Конфигурирование
217	// ------------------------------------------
218	$('.config-icon').each( function( i ) {
219		$( this ).click( function () {
220
221			if ( ( ForumsIsConfig == false ) || ( ForumsIsConfigIsInited == false ) ) {
222				
223				ForumsIsConfig = true;
224				ForumsIsConfigIsInited = true;
225				
226				$('.config-icon').attr( 'src', config_pic_2 );
227				
228			} else {
229
230				ForumsIsConfig = false;
231				$(".forum-container .af-fly-control").css('display', 'none');
232				$('.config-icon').attr( 'src', config_pic_1 );
233				
234			}
235		});
236	});
237	
238	// ======================================================================
239	// Форумы/Подкатегории
240	// ======================================================================
241
242	// -------------------------------------
243	// Плавующая панель управления
244	// -------------------------------------
245	
246	$('li.row').each( function() {
247		$( this ).hover(
248			function() {
249				current_forum = $( this );
250
251				if ( ForumsIsConfig )
252					DisplayForumControls( this ); 
253								
254			},
255			function() {}
256		)
257	});
258	
259	// -------------------------------------
260	// Кнопка сворачивания/разворачивания	
261	// -------------------------------------
262	
263	$(".forum-container .af-fly-control .forum-show-hide-icon").click( function() {
264		if ( current_forum ) {
265			
266			var content_visibility = current_forum.attr('forum_content_visibility');
267			
268			var can_be_fliped = current_forum.attr('can_be_fliped');
269			
270			var forum_id = current_forum.attr('forum_id'); 
271			var category_id = current_forum.attr('category_id'); 	
272			
273			if ( !content_visibility || content_visibility == 'yes' ) {
274				if ( can_be_fliped == 'yes' ) {
275					CloseForum( current_forum );
276					forum_control_open_close_icon.attr( 'src', show_pic );	
277					var state = 'off'; 
278					hidden_forums_count += 1;
279				}
280			} else {
281				Openforum( current_forum );
282				forum_control_open_close_icon.attr( 'src', hide_pic );
283				var state = 'on'; 
284				hidden_forums_count -= 1;
285			}
286			
287			$('#active-forums-hidden-for').text( hidden_forums_count );	
288			SaveState( "Visibility", forum_id, category_id, state );
289			
290		}
291	});
292	
293	forum_control_open_close_icon = $(".forum-container .af-fly-control .forum-show-hide-icon");
294	
295	// -------------------------------------
296	// Кнопка удаления/отображения	
297	// -------------------------------------
298	
299	$(".forum-container .af-fly-control .forum-close-open-icon").click( function() {
300		if ( current_forum ) {
301			
302			var forum_visibility = current_forum.attr('forum_visibility');
303			
304			var can_be_deleted = current_forum.attr('can_be_deleted');
305			
306			var forum_id = current_forum.attr('forum_id'); 
307			var category_id = current_forum.attr('category_id');
308			
309			if ( !forum_visibility || forum_visibility == 'yes' ) {
310				if ( can_be_deleted == 'yes' ) {
311					forum_control_hide_show_icon.attr( 'src', close_pic );
312					HideForum( current_forum );
313					var state = 'off'; 
314					closed_forums_count += 1;
315				}
316			} else {
317				forum_control_hide_show_icon.attr( 'src', open_pic );
318				ShowForum( current_forum );
319				var state = 'on'; 
320				closed_forums_count -= 1;
321			}
322			
323			SaveState( "Statuses", forum_id, category_id, state );
324			
325			$('#active-forums-closed-for').text( closed_forums_count );	
326			
327		}
328	});
329	
330
331	forum_control_hide_show_icon = $(".forum-container .af-fly-control .forum-close-open-icon");
332
333});
334
335// ---
336// Получение категории по любому вложенному объекту
337// ---
338function GetCategory( obj ) {
339	obj = $( obj );
340	if ( obj ) {
341		var parent = obj.parent();
342		while ( parent ) {
343			if ( parent.attr( 'category_id' ) ) break;
344			parent = parent.parent();
345		}
346		if ( parent ) return parent;
347	}
348	return null;
349}
350
351// ---
352// Получение категории по любому вложенному объекту
353// ---
354function GetCategoryContent( obj ) {
355	var category = GetCategory( obj );
356	if ( category ) return category.find( '.forums' );
357	return null;
358}
359
360// ---
361// Устанвока видимости объекта
362// ---
363function SetVisibility( obj, state, force ) {
364	
365	if ( obj ) {
366		
367		obj = $( obj );
368		
369		var display = 'none';
370		var visibility_attr = 'no';
371		
372		if ( state ) {
373			display = 'block';
374			visibility_attr = 'yes';
375		}
376		
377		if ( force ) {
378			
379			obj.attr( 'item_visibility', visibility_attr );
380			obj.css( 'display', display );
381			
382		} else {
383			
384			visibility_attr = obj.attr( 'item_visibility' );
385			var force_state = ( visibility_attr == 'yes' ) ? true : false;
386			
387			if ( force_state ) {
388				obj.css( 'display', display );	
389			}
390			
391		}
392	}
393	
394}
395
396// -------------------------------------
397// Форумы/Подкатегории
398// -------------------------------------
399
400// ---
401// Позиционирование элемента управления формумом
402// ---
403function DisplayForumControls( forum ) {
404	var forum = $( forum );
405	
406	var coords = forum.offset();
407	var title = forum.find('dt');
408	
409	var can_be_deleted = forum.attr('can_be_deleted');
410	var can_be_fliped = forum.attr('can_be_fliped');
411
412	
413	$(".forum-container .af-fly-control")
414		.css( {'top': coords.top})
415		.css('left', coords.left + title.width() - 15 )
416		.css('display', 'block');
417		
418	var forum_content_visibility = current_forum.attr('forum_content_visibility');
419
420	if ( !forum_content_visibility || forum_content_visibility == 'yes' ) {
421		if ( can_be_deleted == 'yes' ) {
422			forum_control_open_close_icon.attr( 'src', hide_pic );
423		} else {
424			forum_control_open_close_icon.attr( 'src', hide_d_pic );
425		}
426	} else {
427		forum_control_open_close_icon.attr( 'src', show_pic );	
428	}
429	
430	var forum_visibility = current_forum.attr('forum_visibility');
431
432	if ( !forum_visibility || forum_visibility == 'yes' ) {
433		if ( can_be_deleted == 'yes' ) {
434			forum_control_hide_show_icon.attr( 'src', close_pic );
435		} else {
436			forum_control_hide_show_icon.attr( 'src', close_d_pic );
437		}
438	} else {
439		forum_control_hide_show_icon.attr( 'src', open_pic );	
440	}
441}
442
443function CloseForum( forum ) {
444	var forum = $( forum );
445	
446	forum.find('dt div, dd').each( function() {
447		if ( !$( this ).hasClass('forumtitle') ) $( this ).css('display','none');
448	});
449	
450	forum.find('.icon')
451		.css( 'background-position', '-200px' )
452		.css( 'min-height', '18px' )
453		.css( 'height', '18px' );
454		
455	forum.attr('forum_content_visibility', 'no');
456}
457
458function Openforum( forum ) {
459	var forum = $( forum );
460
461	forum.find('dt div, dd').each( function() {
462		if ( !$( this ).hasClass('forumtitle') ) $( this ).css('display','block');
463	});
464	
465	forum.find('.icon')
466		.css( 'background-position', '10px' )
467		.css( 'overflow', 'hidden' )
468		.css( 'min-height', '35px' )
469		.css( 'height', '' );
470		
471	forum.attr('forum_content_visibility', 'yes');
472}
473
474function HideForum( forum ) {
475	var forum = $( forum );
476	
477	if ( showing_all_forums ) {
478		forum.addClass('forum-invisible');
479		forum.attr('forum_visibility', 'no');
480	} else {
481		forum.css('display', 'none');
482		$(".forum-container .af-fly-control").css('display', 'none');
483		forum.attr('forum_visibility', 'no');
484	}
485}
486
487function ShowForum( forum ) {
488	var forum = $( forum );
489	
490	forum.removeClass('forum-invisible');
491	forum.attr('forum_visibility', 'yes');
492}
493
494// -------------------------------------
495// Ajax-функции
496// -------------------------------------
497
498function SaveState( Action, ForumID, ParentID, State ) {
499	$.post( 
500		ResponsePage,
501		{ 
502			'IsAjax': "yes", 
503			'Action': Action,
504			'ForumID': ForumID,
505			'ParentID': ParentID,
506			'State': State
507		},
508		function(data){
509			if ( data != '1' ) {
510				alert( data );
511			}
512		}
513	);
514}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.