PageSourceSearch

https://elianchali.com/_js/cargo.following.package.js

js elianchali.com collected 2026-10-04 20:13:40 UTC 11,189 bytes, 318 lines download raw bytes

1var isIE = testIE();
2var BOXW = 220;
3var BOXH = 195;
4var pageW = 0;
5var cols = 0;
6var main_top = 0;
7var first_run = true;
8var windowWidth = $(window).width();
9var projectFullHeight = 0;
10///////////////////////////////////////////////////////////////////////////////////////////////////
11/**
12 *	Creates a class for the following
13 *	Currently, only paginations is handled by this class
14 *	@todo: convert the rest of this file
15 */
16Cargo.Following = {
17	"Data" :  {
18		"limit" 		: 80,
19		"page" 			: 0
20	},
21	
22	/*
23	 *	Sets the click for the pages
24	 */
25	PreparePagination : function() { 
26		if($("#total_pages").val() > 1) {
27			if($("#follow_type").val() == "followed-list") {
28				ajax_route = "following/followedlist/"+$("#url").val();
29			
30			} else {
31				ajax_route = "following/followinglist/"+$("#url").val();
32			}
33			
34			Cargo.AutoPagination.Init( {
35				"ajax_route" 		: ajax_route,
36				"more_load_handle"	: "#moreload",
37				"offset"			: (Cargo.Following.Data.page * Cargo.Following.Data.limit),
38				"limit"				: Cargo.Following.Data.limit,
39				"height_selector"   : "#follow_page_wrapper"
40			});
41			
42				
43		} // end if more then one page
44	}
45}
46
47
48$(document).ready(function() {
49	if( $("#items_container").length > 0) {
50		$(document).trigger("keyboardShortcuts");
51	}
52	$(document).trigger("contentResize");
53	$(document).trigger("followingFilterMenu");
54	stickyFooter();
55	
56	$(window).resize(function() {
57		// Adjust the width of items container on window resize
58    	windowWidth = $(window).width();
59    	// Update the about margin
60    	var aboutMargin = windowWidth - $("#about_popup").outerWidth();
61			aboutMargin = aboutMargin / 2;
62		$("#about_popup").css("left", aboutMargin);
63    	if($("#maincontainer.page_container").length == 0) {
64    		$(document).trigger("contentResize");
65    	}
66    });
67    
68    // Following view toggle switch
69    
70    $("#following_view_toggle a").click(function() {
71    	$(this).addClass("active");
72    	$("#items_container, #imgWrapper").animate({opacity: "0.5"},100);
73    	setTimeout('$("#following_view_toggle_loadspin").show()', 100);
74    	setTimeout('window.location = "'+$(this).attr("href")+'"', 500);
75    	return false;
76    });
77    
78	$("a#following_view_toggle_projects").click(function() {
79		$("#following_view_toggle_images").removeClass("active");
80		$("#following_view_toggle_highlight").animate({"left" : "1px"}, 100);
81	});
82	
83	$("a#following_view_toggle_images").click(function() {
84		$("#following_view_toggle_projects").removeClass("active");
85		$("#following_view_toggle_highlight").animate({"left" : "72px"}, 100);
86	});
87	
88	$(document).trigger("loadSearch");
89	
90	// About link popup
91	var aboutToggle = "0";
92	$("#about_link").click(function() {
93		windowWidth = $(window).width();
94		var aboutMargin = windowWidth - $("#about_popup").outerWidth();
95		aboutMargin = aboutMargin / 2;
96		$("#about_popup").css("left", aboutMargin).show();
97		aboutToggle = "1";
98		return false;
99	});	
100
101	$(document).click(function() {
102		if(aboutToggle > 0) {
103			aboutToggle = 0;
104			$("#about_popup").hide();
105		}
106	});
107	
108});
109/////////////////////////////////////////////////////////////////////////////////////////////////
110function paginate(new_page,show_first_project) {
111	var next_page = parseInt($("#current_page").val())+1;
112	var current_page = parseInt($("#current_page").val());
113	var total_pages = parseInt($("#total_pages").val());
114	
115	if($("#page_"+next_page).length == 0 && current_page < total_pages) {
116		$("#pagination_loadspin").show();
117		$("#following_view_toggle_loadspin").show();
118		$("#items_container, #imgWrapper").animate({opacity: "0.5"},100);
119		
120		if($("#current_open").val() != "none") {
121			$(".project_index a").click();
122		}
123		var full_url = Cargo.Location.GetDomain() + Cargo.Config.get('dispatch_url');
124		full_url += '?r={"c":"following","a":"following","g":["'+$("#follow_url").val()+'","'+$("#follow_sort").val()+'","'+new_page+'"]}';
125		$.post(full_url, 
126			function(data) { 
127				$("#items").append(data);
128				//this line is messing things up
129				changePage(next_page,$("input#limit").val());
130				//followLoadHistory();
131				
132				Cargo.History.Init("following");
133				
134				$("#following_view_toggle_loadspin").hide();
135				$("#items_container, #imgWrapper").animate({opacity: "1"},100);
136				
137				if(show_first_project) {
138					$(document).trigger("showNextProjectFollowing", [true]);
139				}
140		});
141	
142	} else if(current_page < total_pages) {
143		changePage(next_page,$("input#limit").val());
144		if(show_first_project) {
145			$(document).trigger("showNextProjectFollowing", [true]);
146		}
147	
148	} else {
149		changePage(1,$("input#limit").val());
150		$("#current_open").val("none");
151		$(document).trigger("showNextProjectFollowing", [true]);
152	}
153}
154/////////////////////////////////////////////////////////////////////////////////////////////////
155$(document).bind("followingFilterMenu", function(e) {
156	var followingFilterVisible = 0;
157	
158	$(".following_filter_menu a:first").addClass("following_filter_menu_first");
159	$(".following_filter_menu a:last").addClass("following_filter_menu_last");
160	
161	$(".show_filter_menu").click(function() {
162		followingFilterVisible = 1;
163		$(".following_filter_menu").show();
164	});
165		
166	$(document).click(function() { 
167		if(followingFilterVisible == 1){
168			followingFilterVisible = 0;
169		} else {
170			$(".following_filter_menu").hide();
171		}
172	});
173});
174/////////////////////////////////////////////////////////////////////////////////////////////////
175function hidefollowingFilterMenu() {
176	var followingFilterVisible = 0;
177	$(".following_filter_menu").hide();
178}
179///////////////////////////////////////////////////////////////////////////////////////////////////
180function getColumnCount() {
181	var minCols = 4;
182	var bodyWidth = $("body").width();
183		if ($("#imgWrapper").length != 0) {
184			bodyWidth = bodyWidth - 60;
185		} else {
186			bodyWidth = bodyWidth - 120;
187		}
188	
189	
190	var this_page = ($("#page_"+$("#current_page").val()).length > 0) ? $("#current_page").val() : 1;
191
192	if($(".box").length > 0) {
193		var thumbWidth = $(".box").outerWidth(true);
194		if($(".sitegallery").length == 0) {
195			// If this is the image gallery on following
196			thumbWidth += 10;
197		}
198		
199	} else {
200		var thumbWidth = $("#page_"+this_page+" .project_feed_thumb, .module").outerWidth(true);
201	}
202	var thumbCols = Math.floor(bodyWidth / thumbWidth);
203		thumbCols = thumbCols < minCols ? minCols : thumbCols;
204	
205	return Array(thumbCols,thumbWidth,bodyWidth,minCols);
206}
207///////////////////////////////////////////////////////////////////////////////////////////////////
208$(document).bind("contentResize", function(e, is_new) {
209	// Adjust the width of the #items_container incrementally
210	// to allow fluid width while retaining center position.
211	var columnCount = getColumnCount();
212	thumbCols = columnCount[0];
213	thumbWidth = columnCount[1];
214	bodyWidth = columnCount[2];
215	minCols = columnCount[3];
216	
217	$("div[id^=page_]").each(function() { // select the proper page
218		if($(this).css("display") != "none" && $(this).attr("id") != "page_footer") this_page = $(this);
219	});
220	var thumbBorderStyle = $(".project_feed_thumb").css("borderRight");
221	var new_entry_width = thumbWidth * thumbCols - thumbWidth - 23;
222	
223	if(new_entry_width != $("#items_container").width()) {
224		var items_width = (windowWidth < thumbWidth * minCols) ? (thumbWidth * minCols) : (thumbWidth * thumbCols);
225		if(thumbWidth > 100) {
226			$(".entry").css("width", new_entry_width);
227			if ($("#imgWrapper").length != 0) {
228				$("#following_header_wrapper, .recent_following_wrapper, #following_section_note, #note").css("width", items_width - 30);
229				$("#imgWrapper").css("width", items_width);
230			} else {
231				$("#following_header_wrapper, .follow_container, #following_section_note, #note, .recent_following_wrapper,  #items_container, #page_footer").css("width", items_width);
232			}
233			var final_size = thumbWidth * thumbCols - 30;
234			$(".project_feed_full").css("width", final_size);
235		}
236	}
237	
238	$("body").css("visibility","visible");
239	
240	var dataObj = Array();
241	dataObj['thumbCols'] = thumbCols;
242	dataObj['is_new'] = is_new;
243	$(document).trigger("projectOpenOrder", [ dataObj ]);
244	if(typeof railScroll == 'function') { railScroll(); }
245});
246///////////////////////////////////////////////////////////////////////////////////////////////////
247function stickyFooter() {
248    	// Grab the height of the doc + window, subtract height of footer
249    	var footerOffset = 100;
250    	var winHeight = $(window).height();
251    	    winHeight = winHeight;
252    	var docHeight = $(document).height();
253    	    docHeight = docHeight;
254    	
255    	// If smaller, add fixed_pos class, otherwise remove if exists.
256    	if(winHeight >= docHeight) {
257    	    // alert("the doc is smaller than the window | doc:"+docHeight+" | Win: "+winHeight);
258    	    $("#page_footer_container").addClass("fixed_pos");
259    	} else {
260    	    //alert("the doc is taller than the window | doc:"+docHeight+" | Win: "+winHeight);
261    	    $("#page_footer_container").removeClass("fixed_pos");
262    	}    
263    }
264///////////////////////////////////////////////////////////////////////////////////////////////////
265$(document).bind("initNextProjectFollowing", function(e){
266	$(".project_next a").live("click", function() { 
267		if(pr_list.length > 1) $(document).trigger("showNextProjectFollowing",[false]);
268		return false;
269	});
270});
271/////////////////////////////////////////////////////////////////////////////////////////////////
272$(document).bind("showNextProjectFollowing", function(e, show_first){
273	var cur = ($("#current_open").val() != "none") ? parseInt($("#current_open").val()) : pr_list[0];
274	
275	if($("#load_"+cur).css("display") == "block") var fail;
276	else {
277		var next_id = ($("#item_"+cur).nextAll().length > 0) ? $("#item_"+cur).nextAll().attr("id").replace("item_","") : false;
278
279		if(show_first === true) {
280			next_id = $("#page_"+$("#current_page").val()+" .project_feed_thumb:first").attr("id").replace("item_","");
281		} 
282		
283		if(!next_id) {
284			var new_page = parseInt($("input#current_page").val())*parseInt($("input#limit").val());
285			paginate(new_page,true);
286		
287		} else {
288			var next_purl = Cargo.History.GetPurlFromPid(next_id);
289			Cargo.History.Load( next_purl );
290		}
291	}
292});
293/////////////////////////////////////////////////////////////////////////////////////////////////
294$(document).bind("showPrevProjectFollowing", function(e, show_last){
295	var cur = ($("#current_open").val() != "none") ? parseInt($("#current_open").val()) : pr_list[0];
296	
297	if($("#load_"+cur).css("display") == "block") var fail;
298	else {
299		var next_id = ($("#item_"+cur).prevAll().length > 0) ? $("#item_"+cur).prevAll().attr("id").replace("item_","") : false;
300		if($("#item_"+cur).prevAll().attr("id") == "maincontainer") {
301			next_id = ($("#item_"+cur).prevAll().prevAll().length > 0) ? $("#item_"+cur).prevAll().prevAll().attr("id").replace("item_","") : false;
302		}
303		if(show_last === true) {
304			next_id = $("#page_"+$("#current_page").val()+" .project_feed_thumb:last").attr("id").replace("item_","");
305		}
306		
307		if(!next_id) {
308			var new_page = parseInt($("input#current_page").val())-1;
309			changePage(new_page,$("input#limit").val());
310			$(document).trigger("showPrevProjectFollowing", [true]);
311		
312		} else {
313			var next_purl = Cargo.History.GetPurlFromPid(next_id);
314			Cargo.History.Load( next_purl );
315			
316		}
317	}
318});

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.