| 
									
										
										
										
											2019-02-12 10:29:50 +00:00
										 |  |  | // @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | function ACL(backend_url, preset, automention, is_mobile){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.url = backend_url; | 
					
						
							|  |  |  | 	this.automention = automention; | 
					
						
							|  |  |  | 	this.is_mobile = is_mobile; | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.kp_timer = null; | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 	if (preset == undefined) { | 
					
						
							|  |  |  | 		preset = []; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.allow_cid = (preset[0] || []); | 
					
						
							|  |  |  | 	this.allow_gid = (preset[1] || []); | 
					
						
							|  |  |  | 	this.deny_cid  = (preset[2] || []); | 
					
						
							|  |  |  | 	this.deny_gid  = (preset[3] || []); | 
					
						
							|  |  |  | 	this.group_uids = []; | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 	this.forumCache = null; | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if (this.is_mobile) { | 
					
						
							|  |  |  | 		this.nw = 1; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		this.nw = 4; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.list_content = $("#acl-list-content"); | 
					
						
							|  |  |  | 	this.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html()); | 
					
						
							|  |  |  | 	this.showall = $("#acl-showall"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 	if (preset.length==0) { | 
					
						
							|  |  |  | 		this.showall.addClass("selected"); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	/*events*/ | 
					
						
							| 
									
										
										
										
											2016-02-05 17:43:46 +00:00
										 |  |  | 	this.showall.click(this.on_showall.bind(this)); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$(document).on("click", ".acl-button-show", this.on_button_show.bind(this)); | 
					
						
							|  |  |  | 	$(document).on("click", ".acl-button-hide", this.on_button_hide.bind(this)); | 
					
						
							|  |  |  | 	$("#acl-search").keypress(this.on_search.bind(this)); | 
					
						
							|  |  |  | 	$("#acl-wrapper").parents("form").submit(this.on_submit.bind(this)); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | 	/* add/remove mentions  */ | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.element = $("#profile-jot-text"); | 
					
						
							|  |  |  | 	this.htmlelm = this.element.get()[0]; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 15:48:09 +00:00
										 |  |  | ACL.prototype.remove_mention = function(id) { | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	if (!this.automention) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	var nick = this.data[id].nick; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	var addr = this.data[id].addr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (addr != "") { | 
					
						
							| 
									
										
										
										
											2017-11-03 05:07:19 +00:00
										 |  |  | 		var searchText = "!" + addr + " "; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2017-11-03 05:07:19 +00:00
										 |  |  | 		var searchText = "!" + nick + "+" + id + " "; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	var start = this.element.val().indexOf(searchText); | 
					
						
							|  |  |  | 	if (start < 0) { | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	var end = start + searchText.length; | 
					
						
							|  |  |  | 	this.element.setSelection(start, end).replaceSelectedText('').collapseSelection(false); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 15:48:09 +00:00
										 |  |  | ACL.prototype.add_mention = function(id) { | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	if (!this.automention) { | 
					
						
							|  |  |  | 		return; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	var nick = this.data[id].nick; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	var addr = this.data[id].addr; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (addr != "") { | 
					
						
							| 
									
										
										
										
											2017-11-03 05:07:19 +00:00
										 |  |  | 		var searchText = "!" + addr + " "; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2017-11-03 05:07:19 +00:00
										 |  |  | 		var searchText = "!" + nick + "+" + id + " "; | 
					
						
							| 
									
										
										
										
											2017-08-27 20:39:15 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	if (this.element.val().indexOf( searchText) >= 0 ) { | 
					
						
							|  |  |  | 		return; | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-04-19 02:04:23 +00:00
										 |  |  | 	this.element.val(searchText + this.element.val()).trigger('change'); | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | ACL.prototype.on_submit = function(){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 	var aclfields = $("#acl-fields").html(""); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$(this.allow_gid).each(function(i,v){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 		aclfields.append("<input type='hidden' name='group_allow[]' value='"+v+"'>"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$(this.allow_cid).each(function(i,v){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 		aclfields.append("<input type='hidden' name='contact_allow[]' value='"+v+"'>"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$(this.deny_gid).each(function(i,v){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 		aclfields.append("<input type='hidden' name='group_deny[]' value='"+v+"'>"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$(this.deny_cid).each(function(i,v){ | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 		aclfields.append("<input type='hidden' name='contact_deny[]' value='"+v+"'>"); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.search = function(){ | 
					
						
							|  |  |  | 	var srcstr = $("#acl-search").val(); | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.list_content.html(""); | 
					
						
							|  |  |  | 	this.get(0,100, srcstr); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.on_search = function(event){ | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	if (this.kp_timer) clearTimeout(this.kp_timer); | 
					
						
							|  |  |  | 	this.kp_timer = setTimeout( this.search.bind(this), 1000); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.on_showall = function(event){ | 
					
						
							| 
									
										
										
										
											2011-09-15 09:05:09 +00:00
										 |  |  | 	event.preventDefault() | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	event.stopPropagation(); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	if (this.showall.hasClass("selected")){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		return false; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.showall.addClass("selected"); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.allow_cid = []; | 
					
						
							|  |  |  | 	this.allow_gid = []; | 
					
						
							|  |  |  | 	this.deny_cid  = []; | 
					
						
							|  |  |  | 	this.deny_gid  = []; | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.update_view(); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.on_button_show = function(event){ | 
					
						
							| 
									
										
										
										
											2011-09-15 09:05:09 +00:00
										 |  |  | 	event.preventDefault() | 
					
						
							|  |  |  | 	event.stopImmediatePropagation() | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	event.stopPropagation(); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:43:46 +00:00
										 |  |  | 	this.set_allow($(event.target).parent().attr('id')); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | ACL.prototype.on_button_hide = function(event){ | 
					
						
							| 
									
										
										
										
											2011-09-15 09:05:09 +00:00
										 |  |  | 	event.preventDefault() | 
					
						
							|  |  |  | 	event.stopImmediatePropagation() | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	event.stopPropagation(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-05 17:43:46 +00:00
										 |  |  | 	this.set_deny($(event.target).parent().attr('id')); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return false; | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | ACL.prototype.set_allow = function(itemid) { | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	type = itemid[0]; | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 	id   = parseInt(itemid.substr(1)); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 	switch (type){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		case "g": | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 			if (this.allow_gid.indexOf(id) < 0) { | 
					
						
							|  |  |  | 				this.allow_gid.push(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			}else { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				this.allow_gid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 			if (this.deny_gid.indexOf(id) >= 0) { | 
					
						
							|  |  |  | 				this.deny_gid.remove(id); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case "c": | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 			if (this.allow_cid.indexOf(id) < 0){ | 
					
						
							|  |  |  | 				this.allow_cid.push(id); | 
					
						
							|  |  |  | 				if (this.data[id].forum == "1") { | 
					
						
							|  |  |  | 					// If we have select already a forum,
 | 
					
						
							|  |  |  | 					// we need to remove the old one (because friendica does
 | 
					
						
							|  |  |  | 					// allow only one forum as receiver).
 | 
					
						
							|  |  |  | 					if (this.forumCache !== null && this.forumCache !== id) { | 
					
						
							|  |  |  | 						this.deselectCid(this.forumCache); | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					// Update the forum cache.
 | 
					
						
							|  |  |  | 					this.forumCache = id; | 
					
						
							|  |  |  | 					this.add_mention(id); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				this.allow_cid.remove(id); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | 				if (this.data[id].forum == "1") { | 
					
						
							|  |  |  | 					this.remove_mention(id); | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			if (this.deny_cid.indexOf(id) >=0 ) { | 
					
						
							|  |  |  | 				this.deny_cid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.update_view(); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.set_deny = function(itemid){ | 
					
						
							|  |  |  | 	type = itemid[0]; | 
					
						
							| 
									
										
										
										
											2013-12-18 15:17:38 +00:00
										 |  |  | 	id     = parseInt(itemid.substr(1)); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	switch(type){ | 
					
						
							|  |  |  | 		case "g": | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			if (this.deny_gid.indexOf(id)<0){ | 
					
						
							|  |  |  | 				this.deny_gid.push(id) | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				this.deny_gid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			if (this.allow_gid.indexOf(id)>=0) this.allow_gid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 		case "c": | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			if (this.data[id].forum=="1") this.remove_mention(id); | 
					
						
							|  |  |  | 			if (this.deny_cid.indexOf(id)<0){ | 
					
						
							|  |  |  | 				this.deny_cid.push(id) | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				this.deny_cid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			if (this.allow_cid.indexOf(id)>=0) this.allow_cid.remove(id); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			break; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.update_view(); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 15:48:09 +00:00
										 |  |  | ACL.prototype.is_show_all = function() { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	return (this.allow_gid.length==0 && this.allow_cid.length==0 && | 
					
						
							|  |  |  | 		this.deny_gid.length==0 && this.deny_cid.length==0); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-12-18 15:48:09 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-15 09:05:09 +00:00
										 |  |  | ACL.prototype.update_view = function(){ | 
					
						
							| 
									
										
										
										
											2013-12-18 15:48:09 +00:00
										 |  |  | 	if (this.is_show_all()){ | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			this.showall.addClass("selected"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			/* jot acl */ | 
					
						
							|  |  |  | 				$('#jot-perms-icon').removeClass('lock').addClass('unlock'); | 
					
						
							|  |  |  | 				$('#jot-public').show(); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 				$('.profile-jot-net input').attr('disabled', false); | 
					
						
							| 
									
										
										
										
											2011-09-15 09:05:09 +00:00
										 |  |  | 				if(typeof editor != 'undefined' && editor != false) { | 
					
						
							| 
									
										
										
										
											2011-07-29 03:44:35 +00:00
										 |  |  | 					$('#profile-jot-desc').html(ispublic); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 			this.showall.removeClass("selected"); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 			/* jot acl */ | 
					
						
							|  |  |  | 				$('#jot-perms-icon').removeClass('unlock').addClass('lock'); | 
					
						
							|  |  |  | 				$('#jot-public').hide(); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 				$('.profile-jot-net input').attr('disabled', 'disabled'); | 
					
						
							| 
									
										
										
										
											2011-07-29 03:44:35 +00:00
										 |  |  | 				$('#profile-jot-desc').html(' '); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-12-21 03:11:46 +00:00
										 |  |  | 	$("#acl-list-content .acl-list-item").each(function(){ | 
					
						
							|  |  |  | 		$(this).removeClass("groupshow grouphide"); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	$("#acl-list-content .acl-list-item").each(function(index, element){ | 
					
						
							|  |  |  | 		itemid = $(element).attr('id'); | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		type = itemid[0]; | 
					
						
							|  |  |  | 		id 	 = parseInt(itemid.substr(1)); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 		btshow = $(element).children(".acl-button-show").removeClass("selected"); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 		bthide = $(element).children(".acl-button-hide").removeClass("selected"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		switch(type){ | 
					
						
							|  |  |  | 			case "g": | 
					
						
							|  |  |  | 				var uclass = ""; | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				if (this.allow_gid.indexOf(id)>=0){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 					btshow.addClass("selected"); | 
					
						
							|  |  |  | 					bthide.removeClass("selected"); | 
					
						
							|  |  |  | 					uclass="groupshow"; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				if (this.deny_gid.indexOf(id)>=0){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 					btshow.removeClass("selected"); | 
					
						
							|  |  |  | 					bthide.addClass("selected"); | 
					
						
							|  |  |  | 					uclass="grouphide"; | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				$(this.group_uids[id]).each(function(i,v) { | 
					
						
							| 
									
										
										
										
											2011-12-21 03:11:46 +00:00
										 |  |  | 					if(uclass == "grouphide") | 
					
						
							|  |  |  | 						$("#c"+v).removeClass("groupshow"); | 
					
						
							| 
									
										
										
										
											2011-12-22 02:04:24 +00:00
										 |  |  | 					if(uclass != "") { | 
					
						
							|  |  |  | 						var cls = $("#c"+v).attr('class'); | 
					
						
							|  |  |  | 						if( cls == undefined) | 
					
						
							|  |  |  | 							return true; | 
					
						
							|  |  |  | 						var hiding = cls.indexOf('grouphide'); | 
					
						
							|  |  |  | 						if(hiding == -1) | 
					
						
							|  |  |  | 							$("#c"+v).addClass(uclass); | 
					
						
							|  |  |  | 					} | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 				}); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			case "c": | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				if (this.allow_cid.indexOf(id)>=0){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 					btshow.addClass("selected"); | 
					
						
							|  |  |  | 					bthide.removeClass("selected"); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 				if (this.deny_cid.indexOf(id)>=0){ | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 					btshow.removeClass("selected"); | 
					
						
							|  |  |  | 					bthide.addClass("selected"); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 				} | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	}.bind(this)); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.get = function(start,count, search){ | 
					
						
							|  |  |  | 	var postdata = { | 
					
						
							|  |  |  | 		start:start, | 
					
						
							|  |  |  | 		count:count, | 
					
						
							|  |  |  | 		search:search, | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	$.ajax({ | 
					
						
							|  |  |  | 		type:'POST', | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 		url: this.url, | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 		data: postdata, | 
					
						
							|  |  |  | 		dataType: 'json', | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 		success:this.populate.bind(this) | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-07-19 14:17:58 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | ACL.prototype.populate = function(data){ | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	var height = Math.ceil(data.tot / this.nw) * 42; | 
					
						
							|  |  |  | 	this.list_content.height(height); | 
					
						
							|  |  |  | 	this.data = {}; | 
					
						
							| 
									
										
										
										
											2017-07-23 06:49:31 +00:00
										 |  |  | 	$(data.items).each(function(index, item) { | 
					
						
							|  |  |  | 		if (item.separator != undefined) { | 
					
						
							|  |  |  | 			html = "<hr class='clear'>"; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			html = "<div class='acl-list-item {4} {5} type{2}' title='{6}' id='{2}{3}'>"+this.item_tpl+"</div>"; | 
					
						
							|  |  |  | 			html = html.format(item.photo, item.name, item.type, item.id, (item.forum=='1'?'forum':''), item.network, item.link); | 
					
						
							|  |  |  | 			if (item.uids != undefined) { | 
					
						
							|  |  |  | 				this.group_uids[item.id] = item.uids; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 		this.list_content.append(html); | 
					
						
							|  |  |  | 		this.data[item.id] = item; | 
					
						
							|  |  |  | 	}.bind(this)); | 
					
						
							|  |  |  | 	$(".acl-list-item img[data-src]", this.list_content).each(function(i, el){ | 
					
						
							| 
									
										
										
										
											2013-01-02 13:28:13 +00:00
										 |  |  | 		// Add src attribute for images with a data-src attribute
 | 
					
						
							| 
									
										
										
										
											2012-12-29 22:44:26 +00:00
										 |  |  | 		$(el).attr('src', $(el).data("src")); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2017-01-27 03:50:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-03 13:03:00 +00:00
										 |  |  | 	this.update_view(); | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  |  * @brief Deselect previous selected contact. | 
					
						
							| 
									
										
										
										
											2018-08-14 01:01:36 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2017-11-28 00:08:03 +00:00
										 |  |  |  * @param {int} id The contact ID. | 
					
						
							|  |  |  |  * @returns {void} | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | ACL.prototype.deselectCid = function(id) { | 
					
						
							|  |  |  | 	if (this.allow_cid.indexOf(id) >= 0) { | 
					
						
							|  |  |  | 		this.allow_cid.remove(id); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (this.deny_cid.indexOf(id) >=0 ) { | 
					
						
							|  |  |  | 		this.deny_cid.remove(id); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	this.remove_mention(id); | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2019-02-12 10:29:50 +00:00
										 |  |  | // @license-end
 |