X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=view%2Fjs%2Facl.js;h=b50dbaec8d947abb7eb1d42c34b86719136af450;hb=22598fc7e8a2833ecddcafe8ac052d5d9055f71f;hp=257e2c158fe867694cfc21c0a6b0df50a878500f;hpb=c845415a99ebc348103815a7b2c55b15c75cdd24;p=friendica.git diff --git a/view/js/acl.js b/view/js/acl.js index 257e2c158f..b50dbaec8d 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -1,3 +1,4 @@ +// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later function ACL(backend_url, preset, automention, is_mobile){ this.url = backend_url; @@ -42,9 +43,6 @@ function ACL(backend_url, preset, automention, is_mobile){ /* add/remove mentions */ this.element = $("#profile-jot-text"); this.htmlelm = this.element.get()[0]; - - /* startup! */ - this.get(0,100); } ACL.prototype.remove_mention = function(id) { @@ -111,7 +109,14 @@ ACL.prototype.search = function(){ ACL.prototype.on_search = function(event){ if (this.kp_timer) clearTimeout(this.kp_timer); - this.kp_timer = setTimeout( this.search.bind(this), 1000); + + // Triggers an immediate search while preventing form submission + if (event.key === 'Enter') { + this.search(); + event.preventDefault(); + } else { + this.kp_timer = setTimeout( this.search.bind(this), 500); + } }; ACL.prototype.on_showall = function(event){ @@ -227,30 +232,41 @@ ACL.prototype.is_show_all = function() { this.deny_gid.length==0 && this.deny_cid.length==0); }; -ACL.prototype.update_view = function(){ - if (this.is_show_all()){ - this.showall.addClass("selected"); - /* jot acl */ - $('#jot-perms-icon').removeClass('lock').addClass('unlock'); - $('#jot-public').show(); - $('.profile-jot-net input').attr('disabled', false); - if(typeof editor != 'undefined' && editor != false) { - $('#profile-jot-desc').html(ispublic); - } +ACL.prototype.update_view = function () { + if (this.is_show_all()) { + this.showall.addClass("selected"); + /* jot acl */ + $('#jot-perms-icon').removeClass('lock').addClass('unlock'); + $('#jot-public').show(); + $('.profile-jot-net input[type=checkbox]').each(function() { + // Restores checkbox state if it had been saved + if ($(this).attr('data-checked') !== undefined) { + $(this).prop('checked', $(this).attr('data-checked') === 'true'); + } + }); + $('.profile-jot-net input').attr('disabled', false); + if (typeof editor != 'undefined' && editor != false) { + $('#profile-jot-desc').html(ispublic); + } } else { - this.showall.removeClass("selected"); - /* jot acl */ - $('#jot-perms-icon').removeClass('unlock').addClass('lock'); - $('#jot-public').hide(); - $('.profile-jot-net input').attr('disabled', 'disabled'); - $('#profile-jot-desc').html(' '); + this.showall.removeClass("selected"); + /* jot acl */ + $('#jot-perms-icon').removeClass('unlock').addClass('lock'); + $('#jot-public').hide(); + $('.profile-jot-net input[type=checkbox]').each(function() { + // Saves current checkbox state + $(this) + .attr('data-checked', $(this).prop('checked')) + .prop('checked', false); + }); + $('.profile-jot-net input').attr('disabled', 'disabled'); + $('#profile-jot-desc').html(' '); } - $("#acl-list-content .acl-list-item").each(function(){ + + $("#acl-list-content .acl-list-item").each(function (index, element) { $(this).removeClass("groupshow grouphide"); - }); - $("#acl-list-content .acl-list-item").each(function(index, element){ itemid = $(element).attr('id'); type = itemid[0]; id = parseInt(itemid.substr(1)); @@ -258,40 +274,40 @@ ACL.prototype.update_view = function(){ btshow = $(element).children(".acl-button-show").removeClass("selected"); bthide = $(element).children(".acl-button-hide").removeClass("selected"); - switch(type){ + switch (type) { case "g": var uclass = ""; - if (this.allow_gid.indexOf(id)>=0){ + if (this.allow_gid.indexOf(id) >= 0) { btshow.addClass("selected"); bthide.removeClass("selected"); - uclass="groupshow"; + uclass = "groupshow"; } - if (this.deny_gid.indexOf(id)>=0){ + if (this.deny_gid.indexOf(id) >= 0) { btshow.removeClass("selected"); bthide.addClass("selected"); - uclass="grouphide"; + uclass = "grouphide"; } - $(this.group_uids[id]).each(function(i,v) { - if(uclass == "grouphide") - $("#c"+v).removeClass("groupshow"); - if(uclass != "") { - var cls = $("#c"+v).attr('class'); - if( cls == undefined) + $(this.group_uids[id]).each(function (i, v) { + if (uclass == "grouphide") + $("#c" + v).removeClass("groupshow"); + 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); + if (hiding == -1) + $("#c" + v).addClass(uclass); } }); break; case "c": - if (this.allow_cid.indexOf(id)>=0){ + if (this.allow_cid.indexOf(id) >= 0) { btshow.addClass("selected"); bthide.removeClass("selected"); } - if (this.deny_cid.indexOf(id)>=0){ + if (this.deny_cid.indexOf(id) >= 0) { btshow.removeClass("selected"); bthide.addClass("selected"); } @@ -299,7 +315,7 @@ ACL.prototype.update_view = function(){ }.bind(this)); -} +}; ACL.prototype.get = function(start,count, search){ var postdata = { @@ -344,7 +360,7 @@ ACL.prototype.populate = function(data){ /** * @brief Deselect previous selected contact. - * + * * @param {int} id The contact ID. * @returns {void} */ @@ -357,3 +373,4 @@ ACL.prototype.deselectCid = function(id) { } this.remove_mention(id); }; +// @license-end