From 573dea42d0b71a360d8630ab20783dba13768a49 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 13 May 2016 16:22:43 +0200 Subject: instead of radio buttons use select to choose between public and restricted acl. if restricted is selected acl is set to default. if there is no default acl will be set to self. if public is selected acl-list will be hidden and acl-info is visible. --- view/js/acl.js | 99 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 42 deletions(-) (limited to 'view/js') diff --git a/view/js/acl.js b/view/js/acl.js index 162ada764..a04cf9d86 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -11,30 +11,44 @@ function ACL(backend_url, preset) { that.deny_cid = (preset[2] || []); that.deny_gid = (preset[3] || []); that.group_uids = []; - that.nw = 4; //items per row. should be calulated from #acl-list.width + that.info = $("#acl-info"); + that.list = $("#acl-list"); that.list_content = $("#acl-list-content"); that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html()); that.showall = $("#acl-showall"); that.showlimited = $("#acl-showlimited"); + that.acl_select = $("#acl-select"); + + that.preset = preset; + that.self = []; // set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes. that.on_submit(); - if (preset.length === 0) that.showall.removeClass("btn-default").addClass("btn-warning"); - /*events*/ $(document).ready(function() { - that.showall.click(that.on_showall); - that.showlimited.click(that.on_showlimited); - $(document).on('click','.acl-button-show',that.on_button_show); - $(document).on('click','.acl-button-hide',that.on_button_hide); - $("#acl-search").keypress(that.on_search); - - /* startup! */ - that.get(0,15000); - that.on_submit(); + + that.acl_select.change(function(event) { + var option = that.acl_select.val(); + + if(option == 'option1') { // public + that.on_showall(event); + } + + if(option == 'option2') { // restricted + that.on_showlimited(event); + } + }); + + $(document).on('click','.acl-button-show',that.on_button_show); + $(document).on('click','.acl-button-hide',that.on_button_hide); + $("#acl-search").keypress(that.on_search); + + /* startup! */ + that.get(0,15000); + that.on_submit(); }); } @@ -73,15 +87,9 @@ ACL.prototype.on_search = function(event) { }; ACL.prototype.on_showall = function(event) { - // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton event.stopPropagation(); - if (that.showall.hasClass("btn-warning")) { - return false; - } - that.showall.removeClass("btn-default").addClass("btn-warning"); - that.allow_cid = []; that.allow_gid = []; that.deny_cid = []; @@ -94,11 +102,22 @@ ACL.prototype.on_showall = function(event) { }; ACL.prototype.on_showlimited = function(event) { - // Prevent the radiobutton from being selected, as the showlimited radiobutton - // option is selected only by selecting show or hide options on channels or groups. - event.preventDefault(); + // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton event.stopPropagation(); - return false; + + if(that.preset[0].length === 0 && that.preset[1].length === 0 && that.preset[2].length === 0 && that.preset[3].length === 0) { + that.preset[0] = [that.self[0]]; + } + + that.allow_cid = (that.preset[0] || []); + that.allow_gid = (that.preset[1] || []); + that.deny_cid = (that.preset[2] || []); + that.deny_gid = (that.preset[3] || []); + + that.update_view(); + that.on_submit(); + + return true; // return true so that state changes from update_view() will be applied } ACL.prototype.on_selectall = function(event) { @@ -199,29 +218,26 @@ ACL.prototype.set_deny = function(itemid) { that.update_view(); }; -ACL.prototype.update_radiobuttons = function(isPublic) { - - that.showall.prop('checked', isPublic); - that.showlimited.prop('checked', !isPublic); - that.showlimited.prop('disabled', isPublic); +ACL.prototype.update_select = function(isPublic) { + that.showall.prop('selected', isPublic); + that.showlimited.prop('selected', !isPublic); }; ACL.prototype.update_view = function() { - if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && - that.deny_gid.length === 0 && that.deny_cid.length === 0) { - // btn-warning indicates that the permissions are public, it was chosen because - // that.showall used to be a normal button, which btn-warning is a bootstrap style for. - that.showall.removeClass("btn-default").addClass("btn-warning"); - that.update_radiobuttons(true); - - /* jot acl */ - $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); - $('#jot-public').show(); - $('.profile-jot-net input').attr('disabled', false); + if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { + that.list.hide(); //hide acl-list + that.info.show(); //show acl-info + that.update_select(true); + + /* jot acl */ + $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); + $('#jot-public').show(); + $('.profile-jot-net input').attr('disabled', false); } else { - that.showall.removeClass("btn-warning").addClass("btn-default"); - that.update_radiobuttons(false); + that.list.show(); //show acl-list + that.info.hide(); //hide acl-info + that.update_select(false); /* jot acl */ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); @@ -300,12 +316,11 @@ ACL.prototype.get = function(start, count, search) { }; ACL.prototype.populate = function(data) { - var height = Math.ceil(data.items.length / that.nw) * 42; - that.list_content.height(height); $(data.items).each(function(){ html = "
"+that.item_tpl+"
"; html = html.format(this.photo, this.name, this.type, this.xid, '', this.self, this.link, this.taggable); if (this.uids !== undefined) that.group_uids[this.xid] = this.uids; + if (this.self === 'abook-self') that.self[0] = this.xid; //console.log(html); that.list_content.append(html); }); -- cgit v1.2.3 From 0f5eb6521010b6cd41b07b1f4a1dea2c40d4ebae Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 19 May 2016 23:35:19 +0200 Subject: provide an acl select option for only me --- view/js/acl.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 13 deletions(-) (limited to 'view/js') diff --git a/view/js/acl.js b/view/js/acl.js index a04cf9d86..92a80e3d1 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -17,8 +17,10 @@ function ACL(backend_url, preset) { that.list_content = $("#acl-list-content"); that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html()); that.showall = $("#acl-showall"); + that.onlyme = $("#acl-onlyme"); that.showlimited = $("#acl-showlimited"); that.acl_select = $("#acl-select"); + that.showacl = $("#show-acl"); that.preset = preset; that.self = []; @@ -33,17 +35,22 @@ function ACL(backend_url, preset) { that.acl_select.change(function(event) { var option = that.acl_select.val(); - if(option == 'option1') { // public + if(option == 'public') { // public that.on_showall(event); } - if(option == 'option2') { // restricted + if(option == 'onlyme') { // limited to one self + that.on_onlyme(event); + } + + if(option == 'limited') { // limited to custom selection that.on_showlimited(event); } }); $(document).on('click','.acl-button-show',that.on_button_show); $(document).on('click','.acl-button-hide',that.on_button_hide); + $("#acl-search").keypress(that.on_search); /* startup! */ @@ -86,6 +93,21 @@ ACL.prototype.on_search = function(event) { that.kp_timer = setTimeout( that.search, 1000); }; +ACL.prototype.on_onlyme = function(event) { + // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton + event.stopPropagation(); + + that.allow_cid = [that.self[0]]; + that.allow_gid = []; + that.deny_cid = []; + that.deny_gid = []; + + that.update_view(event.target.value); + that.on_submit(); + + return true; // return true so that state changes from update_view() will be applied +}; + ACL.prototype.on_showall = function(event) { // preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton event.stopPropagation(); @@ -95,7 +117,7 @@ ACL.prototype.on_showall = function(event) { that.deny_cid = []; that.deny_gid = []; - that.update_view(); + that.update_view(event.target.value); that.on_submit(); return true; // return true so that state changes from update_view() will be applied @@ -114,7 +136,7 @@ ACL.prototype.on_showlimited = function(event) { that.deny_cid = (that.preset[2] || []); that.deny_gid = (that.preset[3] || []); - that.update_view(); + that.update_view(event.target.value); that.on_submit(); return true; // return true so that state changes from update_view() will be applied @@ -218,30 +240,46 @@ ACL.prototype.set_deny = function(itemid) { that.update_view(); }; -ACL.prototype.update_select = function(isPublic) { - that.showall.prop('selected', isPublic); - that.showlimited.prop('selected', !isPublic); +ACL.prototype.update_select = function(preset) { + that.showall.prop('selected', preset === 'public'); + that.onlyme.prop('selected', preset === 'onlyme'); + that.showlimited.prop('selected', preset === 'limited'); }; -ACL.prototype.update_view = function() { +ACL.prototype.update_view = function(value) { + if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { that.list.hide(); //hide acl-list + that.showacl.hide(); //hide showacl button that.info.show(); //show acl-info - that.update_select(true); + that.update_select('public'); /* jot acl */ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-lock').addClass('fa-unlock'); - $('#jot-public').show(); $('.profile-jot-net input').attr('disabled', false); - } else { + } + + // if value != 'onlyme' we should fall through this one + else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'onlyme') { + that.list.hide(); //hide acl-list if + that.showacl.show(); //show showacl button + that.info.hide(); //show acl-info + that.update_select('onlyme'); + + /* jot acl */ + $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); + $('.profile-jot-net input').attr('disabled', 'disabled'); + } + + else { that.list.show(); //show acl-list + that.showacl.hide(); //hide showacl button that.info.hide(); //hide acl-info - that.update_select(false); + that.update_select('limited'); /* jot acl */ $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock'); - $('#jot-public').hide(); $('.profile-jot-net input').attr('disabled', 'disabled'); } -- cgit v1.2.3 From 9908a7193ae9ef79536540693e505a9c2d813425 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 25 May 2016 14:31:58 +0200 Subject: remove the add others button for now - after some research it turned out not beeing so useful --- view/js/acl.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'view/js') diff --git a/view/js/acl.js b/view/js/acl.js index 92a80e3d1..79699c589 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -20,7 +20,6 @@ function ACL(backend_url, preset) { that.onlyme = $("#acl-onlyme"); that.showlimited = $("#acl-showlimited"); that.acl_select = $("#acl-select"); - that.showacl = $("#show-acl"); that.preset = preset; that.self = []; @@ -250,7 +249,6 @@ ACL.prototype.update_view = function(value) { if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) { that.list.hide(); //hide acl-list - that.showacl.hide(); //hide showacl button that.info.show(); //show acl-info that.update_select('public'); @@ -263,7 +261,6 @@ ACL.prototype.update_view = function(value) { // if value != 'onlyme' we should fall through this one else if (that.allow_gid.length === 0 && that.allow_cid.length === 1 && that.allow_cid[0] === that.self[0] && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'onlyme') { that.list.hide(); //hide acl-list if - that.showacl.show(); //show showacl button that.info.hide(); //show acl-info that.update_select('onlyme'); @@ -274,7 +271,6 @@ ACL.prototype.update_view = function(value) { else { that.list.show(); //show acl-list - that.showacl.hide(); //hide showacl button that.info.hide(); //hide acl-info that.update_select('limited'); -- cgit v1.2.3 From c0d80a58284baa7dc4ac05b5628a43e8743ac4f0 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 5 Jun 2016 22:38:44 -0700 Subject: adjust the autocomplete regex slightly to account for emoji names --- view/js/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 33d825b55..59a9ed355 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -183,7 +183,7 @@ function string2bb(element) { }; smilies = { - match: /(^|\s)(:[a-z]{2,})$/, + match: /(^|\s)(:[a-z_:]{2,})$/, index: 2, search: function(term, callback) { $.getJSON('/smilies/json').done(function(data) { callback($.map(data, function(entry) { return entry.text.indexOf(term) === 0 ? entry : null; })); }); }, template: function(item) { return item.icon + item.text; }, -- cgit v1.2.3 From ee5372784e129ed7a162c7433f56fa3a1e877a67 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 9 Jun 2016 16:45:53 -0700 Subject: remove the automatic ajax page load on pgdn key; it can load content much faster than you can page and potentially lead to memory exhaustion. --- view/js/main.js | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 15a6b4b8d..f279417d9 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -321,22 +321,6 @@ $(function() { return false; } } - if(event.keyCode == '34') { - if((pageHasMoreContent) && (! loadingPage)) { - $('#more').hide(); - $('#no-more').hide(); - - next_page++; - scroll_next = true; - loadingPage = true; - - if(($('.directory-end').length == 0) && ($('.photos-end').length == 0)) - liveUpdate(); - else - pageUpdate(); - return true; - } - } if(event.keyCode == '19' || (event.ctrlKey && event.which == '32')) { event.preventDefault(); -- cgit v1.2.3