aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js')
-rw-r--r--view/js/acl.js128
-rw-r--r--view/js/autocomplete.js13
-rw-r--r--view/js/main.js23
-rw-r--r--view/js/mod_connections.js12
-rw-r--r--view/js/mod_network.js2
-rw-r--r--view/js/mod_settings.js35
6 files changed, 126 insertions, 87 deletions
diff --git a/view/js/acl.js b/view/js/acl.js
index 411190ac9..c11997c43 100644
--- a/view/js/acl.js
+++ b/view/js/acl.js
@@ -13,6 +13,8 @@ function ACL(backend_url) {
that.deny_gid = [];
that.group_uids = [];
+ that.group_ids = [];
+ that.selected_id = '';
that.info = $("#acl-info");
that.list = $("#acl-list");
@@ -20,7 +22,7 @@ function ACL(backend_url) {
that.item_tpl = unescape($(".acl-list-item[rel=acl-template]").html());
that.showall = $("#acl-showall");
that.onlyme = $("#acl-onlyme");
- that.showlimited = $("#acl-showlimited");
+ that.custom = $("#acl-custom");
that.acl_select = $("#acl-select");
// set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes.
@@ -33,6 +35,10 @@ function ACL(backend_url) {
that.acl_select.change(function(event) {
var option = that.acl_select.val();
+ if(option != 'public' && option != 'onlyme' && option != 'custom') { // limited to one selected group
+ that.on_showgroup(event);
+ }
+
if(option == 'public') { // public
that.on_showall(event);
}
@@ -41,8 +47,8 @@ function ACL(backend_url) {
that.on_onlyme(event);
}
- if(option == 'limited') { // limited to custom selection
- that.on_showlimited(event);
+ if(option == 'custom') { // limited to custom selection
+ that.on_custom(event);
}
});
@@ -62,7 +68,7 @@ function ACL(backend_url) {
}
-ACL.prototype.get_form_data = function(event) {
+ACL.prototype.get_form_data = function(event) {
form_id = $(this).data('form_id');
that.form_id = $('#' + form_id);
@@ -94,13 +100,6 @@ ACL.prototype.on_submit = function() {
$(that.deny_cid).each(function(i,v) {
that.form_id.append("<input class='acl-field' type='hidden' name='contact_deny[]' value='"+v+"'>");
});
-
- var formfields = $('.profile-jot-net input').serializeArray();
-
- $.each(formfields, function(i, field) {
- that.form_id.append("<input class='acl-field' type='hidden' name='"+field.name+"' value='"+field.value+"'>");
- });
-
};
ACL.prototype.search = function() {
@@ -126,7 +125,7 @@ ACL.prototype.on_onlyme = function(event) {
that.deny_gid = [];
- that.update_view(event.target.value);
+ that.update_view();
that.on_submit();
return true; // return true so that state changes from update_view() will be applied
@@ -141,56 +140,44 @@ ACL.prototype.on_showall = function(event) {
that.deny_cid = [];
that.deny_gid = [];
- that.update_view(event.target.value);
+ that.update_view();
that.on_submit();
return true; // return true so that state changes from update_view() will be applied
};
-ACL.prototype.on_showlimited = function(event) {
+ACL.prototype.on_showgroup = function(event) {
+ var xid = that.acl_select.children(":selected").val();
+
// preventDefault() isn't called here as we want state changes from update_view() to be applied to the radiobutton
event.stopPropagation();
- if(that.allow_cid.length === 0 && that.allow_gid.length === 0 && that.deny_cid.length === 0 && that.deny_gid.length === 0) {
- that.allow_cid = [that.self[0]];
- }
-
- that.allow_cid = (that.allow_cid || []);
- that.allow_gid = (that.allow_gid || []);
- that.deny_cid = (that.deny_cid || []);
- that.deny_gid = (that.deny_gid || []);
+ that.allow_cid = [];
+ that.allow_gid = [xid];
+ that.deny_cid = [];
+ that.deny_gid = [];
- that.update_view(event.target.value);
+ 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) {
- event.preventDefault();
- event.stopPropagation();
+};
- /* This function has not yet been completed. */
- /* The goal is to select all ACL "show" entries with one action. */
-
- $('.acl-button-show').each(function(){});
- if (that.showall.hasClass("btn-warning")) {
- return false;
- }
- that.showall.removeClass("btn-default").addClass("btn-warning");
+ACL.prototype.on_custom = 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.allow_gid = [];
that.deny_cid = [];
that.deny_gid = [];
- that.update_view();
+ that.update_view('custom');
that.on_submit();
- return false;
-};
-
+ return true; // return true so that state changes from update_view() will be applied
+}
ACL.prototype.on_button_show = function(event) {
event.preventDefault();
@@ -237,7 +224,7 @@ ACL.prototype.set_allow = function(itemid) {
if (that.deny_cid.indexOf(id)>=0) that.deny_cid.remove(id);
break;
}
- that.update_view();
+ that.update_view('custom');
};
ACL.prototype.set_deny = function(itemid) {
@@ -261,16 +248,20 @@ ACL.prototype.set_deny = function(itemid) {
if (that.allow_cid.indexOf(id)>=0) that.allow_cid.remove(id);
break;
}
- that.update_view();
+ that.update_view('custom');
};
ACL.prototype.update_select = function(set) {
+ if(set != 'public' && set != 'onlyme' && set != 'custom') {
+ $('#' + set).prop('selected', true );
+ }
that.showall.prop('selected', set === 'public');
that.onlyme.prop('selected', set === 'onlyme');
- that.showlimited.prop('selected', set === 'limited');
+ that.custom.prop('selected', set === 'custom');
};
ACL.prototype.update_view = function(value) {
+
if(that.form_id) {
that.form_id.data('allow_cid', that.allow_cid);
that.form_id.data('allow_gid', that.allow_gid);
@@ -278,41 +269,64 @@ ACL.prototype.update_view = function(value) {
that.form_id.data('deny_gid', that.deny_gid);
}
- if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0) {
+ if (that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value !== 'custom') {
that.list.hide(); //hide acl-list
that.info.show(); //show acl-info
that.update_select('public');
/* jot acl */
- $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-lock').addClass('fa-unlock');
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock');
+ $('#dbtn-jotnets').show();
$('.profile-jot-net input').attr('disabled', false);
}
+ else if (that.allow_gid.length === 1 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value !== 'custom') {
+ that.list.hide(); //hide acl-list
+ that.info.hide(); //show acl-info
+ that.selected_id = that.group_ids[that.allow_gid[0]];
+ that.update_select(that.selected_id);
+
+ /* jot acl */
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('#dbtn-jotnets').hide();
+ $('.profile-jot-net input').attr('disabled', 'disabled');
+ }
+
// 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 !== 'limited') {
+ 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 !== 'custom') {
that.list.hide(); //hide acl-list
that.info.hide(); //show acl-info
that.update_select('onlyme');
/* jot acl */
- $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('#dbtn-jotnets').hide();
$('.profile-jot-net input').attr('disabled', 'disabled');
}
else {
that.list.show(); //show acl-list
that.info.hide(); //hide acl-info
- that.update_select('limited');
+ that.update_select('custom');
/* jot acl */
- $('#jot-perms-icon, #dialog-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
- $('.profile-jot-net input').attr('disabled', 'disabled');
-
+ if(that.allow_gid.length === 0 && that.allow_cid.length === 0 && that.deny_gid.length === 0 && that.deny_cid.length === 0 && value === 'custom') {
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock');
+ $('#dbtn-jotnets').show();
+ $('.profile-jot-net input').attr('disabled', false);
+ }
+ else {
+ $('#jot-perms-icon, #dialog-perms-icon, #' + that.form_id[0].id + ' .jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
+ $('#dbtn-jotnets').hide();
+ $('.profile-jot-net input').attr('disabled', 'disabled');
+ }
}
+
$("#acl-list-content .acl-list-item").each(function() {
$(this).removeClass("groupshow grouphide");
});
+
$("#acl-list-content .acl-list-item").each(function() {
itemid = $(this).attr('id');
type = itemid[0];
@@ -384,15 +398,19 @@ ACL.prototype.populate = function(data) {
$(data.items).each(function(){
html = "<div class='acl-list-item {4} {7} {5}' title='{6}' id='{2}{3}'>"+that.item_tpl+"</div>";
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);
+ if (this.uids !== undefined) {
+ that.group_uids[this.xid] = this.uids;
+ that.group_ids[this.xid] = this.id;
+ }
+ if (this.self === 'abook-self') {
+ that.self[0] = this.xid;
+ }
that.list_content.append(html);
});
+
$("#acl-list-content .acl-list-item img[data-src]").each(function(i, el) {
// Replace data-src attribute with src attribute for every image
$(el).attr('src', $(el).data("src"));
$(el).removeAttr("data-src");
});
- //that.update_view();
};
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 63f1e9a13..62a3b6f06 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -102,8 +102,8 @@ function submit_form(e) {
function getWord(text, caretPos) {
var index = text.indexOf(caretPos);
- var postText = text.substring(caretPos, caretPos+8);
- if ((postText.indexOf('[/list]') > 0) || postText.indexOf('[/ul]') > 0 || postText.indexOf('[/ol]') > 0 || postText.indexOf('[/dl]') > 0) {
+ var postText = text.substring(caretPos, caretPos+13);
+ if (postText.indexOf('[/list]') > 0 || postText.indexOf('[/checklist]') > 0 || postText.indexOf('[/ul]') > 0 || postText.indexOf('[/ol]') > 0 || postText.indexOf('[/dl]') > 0) {
return postText;
}
}
@@ -140,10 +140,11 @@ function listNewLineAutocomplete(id) {
var text = document.getElementById(id);
var caretPos = getCaretPosition(text)
var word = getWord(text.value, caretPos);
+
if (word != null) {
var textBefore = text.value.substring(0, caretPos);
var textAfter = text.value.substring(caretPos, text.length);
- var textInsert = (word.indexOf('[/dl]') > 0) ? '\r\n[*=] ' : '\r\n[*] ';
+ var textInsert = (word.indexOf('[/dl]') > 0) ? '\r\n[*=] ' : (word.indexOf('[/checklist]') > 0) ? '\r\n[] ' : '\r\n[*] ';
var caretPositionDiff = (word.indexOf('[/dl]') > 0) ? 3 : 1;
$('#' + id).val(textBefore + textInsert + textAfter);
@@ -268,7 +269,7 @@ function string2bb(element) {
$.fn.bbco_autocomplete = function(type) {
if(type=='bbcode') {
- var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer'];
+ var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'open', 'spoiler', 'map', 'nobb', 'list', 'checklist', 'ul', 'ol', 'dl', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer'];
var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ];
var elements = open_close_elements.concat(open_elements);
@@ -300,7 +301,9 @@ function string2bb(element) {
element = string2bb(element);
if(open_elements.indexOf(element) < 0) {
if(element === 'list' || element === 'ol' || element === 'ul') {
- return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]'];
+ return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]'];
+ } else if(element === 'checklist') {
+ return ['\[' + element + '\]' + '\n\[\] ', '\n\[/' + element + '\]'];
} else if (element === 'dl') {
return ['\[' + element + '\]' + '\n\[*=Item name\] ', '\n\[/' + element + '\]'];
} else if(element === 'table') {
diff --git a/view/js/main.js b/view/js/main.js
index 21157bdfe..5435dfd87 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -250,6 +250,7 @@ var last_filestorage_id = null;
var mediaPlaying = false;
var contentHeightDiff = 0;
+
$(function() {
$.ajaxSetup({cache: false});
@@ -650,6 +651,19 @@ function updateConvItems(mode,data) {
collapseHeight();
}
+ // auto-scroll to a particular comment in a thread (designated by mid) when in single-thread mode
+ if($('.item_' + bParam_mid.substring(0,32)).length && !$('.item_' + bParam_mid.substring(0,32)).hasClass('toplevel_item') && mode == 'replace') {
+ if($('.collapsed-comments').length) {
+ var scrolltoid = $('.collapsed-comments').attr('id').substring(19);
+ $('#collapsed-comments-' + scrolltoid + ' .autotime').timeago();
+ $('#collapsed-comments-' + scrolltoid).show();
+ $('#hide-comments-' + scrolltoid).html(aStr.showfewer);
+ $('#hide-comments-total-' + scrolltoid).hide();
+ }
+ $('html, body').animate({ scrollTop: $('.item_' + bParam_mid.substring(0,32)).offset().top - $('nav').outerHeight() }, 'slow');
+ $('.item_' + bParam_mid.substring(0,32)).addClass('item-highlight');
+ }
+
}
function collapseHeight() {
@@ -840,6 +854,7 @@ function pageUpdate() {
scroll_next = false;
updatePageItems(update_mode,data);
$("#page-spinner").spin(false);
+ $(".autotime").timeago();
in_progress = false;
});
}
@@ -847,7 +862,7 @@ function pageUpdate() {
function justifyPhotos(id) {
justifiedGalleryActive = true;
$('#' + id).justifiedGallery({
- selector: '> a, > div:not(.spinner, #page-end)',
+ selector: 'a, div:not(.spinner, #page-end)',
margins: 3,
border: 0,
sizeRangeSuffixes: {
@@ -1247,12 +1262,6 @@ Array.prototype.remove = function(item) {
return this.push.apply(this, rest);
};
-function previewTheme(elm) {
- theme = $(elm).val();
- $.getJSON('pretheme?f=&theme=' + theme,function(data) {
- $('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" style="max-width:100%; max-height:300px" alt="' + theme + '"></a>');
- });
-}
$(document).ready(function() {
diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js
index 112204a5a..68add4eed 100644
--- a/view/js/mod_connections.js
+++ b/view/js/mod_connections.js
@@ -4,13 +4,13 @@ $(document).ready(function() {
});
$("#contacts-search").keyup(function(event){
- if(event.keyCode == 13){
- $("#contacts-search").click();
- }
+ if(event.keyCode == 13){
+ $("#contacts-search").click();
+ }
});
$(".autocomplete-w1 .selected").keyup(function(event){
- if(event.keyCode == 13){
- $("#contacts-search").click();
- }
+ if(event.keyCode == 13){
+ $("#contacts-search").click();
+ }
});
diff --git a/view/js/mod_network.js b/view/js/mod_network.js
index cbdb82c75..cd36786df 100644
--- a/view/js/mod_network.js
+++ b/view/js/mod_network.js
@@ -1,5 +1,5 @@
$(document).ready(function() {
- $("#search-text").contact_autocomplete(baseurl + '/search_ac');
+ $("#search-text").contact_autocomplete(baseurl + '/search_ac','',true);
$('.jslider-scale ins').addClass('hidden-xs');
});
diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js
index 0f45e0d16..db321ae70 100644
--- a/view/js/mod_settings.js
+++ b/view/js/mod_settings.js
@@ -3,11 +3,13 @@
*/
$(document).ready(function() {
- $('form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); // Warn user about unsaved settings
+ $('#settings-form').areYouSure({'addRemoveFieldsMarksDirty':true, 'message': aStr['leavethispage'] }); // Warn user about unsaved settings
$('.token-mirror').html($('#id_token').val());
$('#id_token').keyup( function() { $('.token-mirror').html($('#id_token').val()); });
+ previewTheme($('#id_theme')[0]);
+
$("#id_permissions_role").change(function() {
var role = $("#id_permissions_role").val();
if(role == 'custom')
@@ -15,20 +17,27 @@ $(document).ready(function() {
else
$('#advanced-perm').hide();
});
+});
+
+
+function setTheme(elm) {
+ $('#settings-form').submit();
+}
+
- $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
- var selstr;
- $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
- selstr = $(this).text();
- $('#jot-perms-icon').removeClass('fa-unlock').addClass('fa-lock');
- $('#jot-public').hide();
+function previewTheme(elm) {
+ theme = $(elm).val();
+ $.getJSON('theme_info/' + theme,function(data) {
+ $('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" style="max-width:100%; max-height:300px" alt="' + theme + '"></a>');
+ $('#id_schema').empty();
+ $(data.schemas).each(function(index,item) {
+ $('<option/>',{value:item['key'],text:item['val']}).appendTo('#id_schema');
});
- if(selstr === null) {
- $('#jot-perms-icon').removeClass('fa-lock').addClass('fa-unlock');
- $('#jot-public').show();
- }
- }).trigger('change');
-});
+ $('#custom-settings-content .section-content-tools-wrapper').html(data.config);
+ });
+}
+
+
/**
* 0 nobody