aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2018-05-24 05:35:50 -0400
committerAndrew Manning <tamanning@zoho.com>2018-05-24 05:35:50 -0400
commitfc6b337bbbd2fd3b5412c8b957122830f73feb2d (patch)
treee8417e561ac7445a4018c0cf3bf722779493c430 /view/js
parent40d99c171678654817e392b7f59050dccce770a8 (diff)
parent9cf8931136c703c66d0bf83e4c6b8fb7f4d2cf0b (diff)
downloadvolse-hubzilla-fc6b337bbbd2fd3b5412c8b957122830f73feb2d.tar.gz
volse-hubzilla-fc6b337bbbd2fd3b5412c8b957122830f73feb2d.tar.bz2
volse-hubzilla-fc6b337bbbd2fd3b5412c8b957122830f73feb2d.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev
Diffstat (limited to 'view/js')
-rw-r--r--view/js/acl.js104
-rw-r--r--view/js/mod_new_channel.js95
2 files changed, 125 insertions, 74 deletions
diff --git a/view/js/acl.js b/view/js/acl.js
index a5fae19bc..730b515a0 100644
--- a/view/js/acl.js
+++ b/view/js/acl.js
@@ -326,59 +326,61 @@ ACL.prototype.update_view = function(value) {
}
}
- $("#acl-list-content .acl-list-item").each(function() {
- $(this).removeClass("groupshow grouphide");
- });
+ if(value === 'custom') {
+ $("#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];
- id = itemid.substr(1);
-
- btshow = $(this).children(".acl-button-show").removeClass("btn-success").addClass("btn-outline-success");
- bthide = $(this).children(".acl-button-hide").removeClass("btn-danger").addClass("btn-outline-danger");
-
- switch(type) {
- case "g":
- var uclass = "";
- if (that.allow_gid.indexOf(id)>=0) {
- btshow.removeClass("btn-outline-success").addClass("btn-success");
- bthide.removeClass("btn-danger").addClass("btn-outline-danger");
- uclass="groupshow";
- }
- if (that.deny_gid.indexOf(id)>=0) {
- btshow.removeClass("btn-success").addClass("btn-outline-success");
- bthide.removeClass("btn-outline-danger").addClass("btn-danger");
- uclass = "grouphide";
- }
- $(that.group_uids[id]).each(function(i, v) {
- if(uclass == "grouphide")
- // we need attr selection here because the id can include an @ (diaspora/friendica xchans)
- $('[id="c' + v + '"]').removeClass("groupshow");
- if(uclass !== "") {
- var cls = $('[id="c' + v + '"]').attr('class');
- if( cls === undefined)
- return true;
- var hiding = cls.indexOf('grouphide');
- if(hiding == -1)
- $('[id="c' + v + '"]').addClass(uclass);
- }
- });
- break;
- case "c":
- if (that.allow_cid.indexOf(id)>=0){
- if(!$(this).hasClass("grouphide") ) {
+ $("#acl-list-content .acl-list-item").each(function() {
+ itemid = $(this).attr('id');
+ type = itemid[0];
+ id = itemid.substr(1);
+
+ btshow = $(this).children(".acl-button-show").removeClass("btn-success").addClass("btn-outline-success");
+ bthide = $(this).children(".acl-button-hide").removeClass("btn-danger").addClass("btn-outline-danger");
+
+ switch(type) {
+ case "g":
+ var uclass = "";
+ if (that.allow_gid.indexOf(id)>=0) {
btshow.removeClass("btn-outline-success").addClass("btn-success");
bthide.removeClass("btn-danger").addClass("btn-outline-danger");
+ uclass="groupshow";
}
- }
- if (that.deny_cid.indexOf(id)>=0){
- btshow.removeClass("btn-success").addClass("btn-outline-success");
- bthide.removeClass("btn-outline-danger").addClass("btn-danger");
- $(this).removeClass("groupshow");
- }
- }
- });
+ if (that.deny_gid.indexOf(id)>=0) {
+ btshow.removeClass("btn-success").addClass("btn-outline-success");
+ bthide.removeClass("btn-outline-danger").addClass("btn-danger");
+ uclass = "grouphide";
+ }
+ $(that.group_uids[id]).each(function(i, v) {
+ if(uclass == "grouphide")
+ // we need attr selection here because the id can include an @ (diaspora/friendica xchans)
+ $('[id="c' + v + '"]').removeClass("groupshow");
+ if(uclass !== "") {
+ var cls = $('[id="c' + v + '"]').attr('class');
+ if( cls === undefined)
+ return true;
+ var hiding = cls.indexOf('grouphide');
+ if(hiding == -1)
+ $('[id="c' + v + '"]').addClass(uclass);
+ }
+ });
+ break;
+ case "c":
+ if (that.allow_cid.indexOf(id)>=0){
+ if(!$(this).hasClass("grouphide") ) {
+ btshow.removeClass("btn-outline-success").addClass("btn-success");
+ bthide.removeClass("btn-danger").addClass("btn-outline-danger");
+ }
+ }
+ if (that.deny_cid.indexOf(id)>=0){
+ btshow.removeClass("btn-success").addClass("btn-outline-success");
+ bthide.removeClass("btn-outline-danger").addClass("btn-danger");
+ $(this).removeClass("groupshow");
+ }
+ }
+ });
+ }
};
ACL.prototype.get = function(start, count, search) {
@@ -394,6 +396,10 @@ ACL.prototype.get = function(start, count, search) {
data: postdata,
dataType: 'json',
success: that.populate
+ })
+ .done(function() {
+ if(search !== undefined)
+ datasrc2src('#acl-list-content .list-group-item img[data-src]');
});
};
diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js
index e78de2596..10a94796c 100644
--- a/view/js/mod_new_channel.js
+++ b/view/js/mod_new_channel.js
@@ -1,43 +1,88 @@
$(document).ready(function() {
-
- $("#newchannel-submit-button").attr('disabled','disabled');
+ $("#id_name").focus();
$("#id_name").blur(function() {
- $("#name-spinner").show();
- var zreg_name = $("#id_name").val();
- $.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
- $("#id_nickname").val(data);
- if(data.error) {
- $("#help_name").html("");
- zFormError("#help_name",data.error);
- }
- else {
- $("#newchannel-submit-button").removeAttr('disabled');
- }
- $("#name-spinner").hide();
- });
+ if(validate_name()) {
+ var zreg_name = $("#id_name").val();
+ $("#name_help_loading").show();
+ $("#name_help_text").hide();
+ $.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
+ $("#id_nickname").val(data);
+ $("#id_nickname").addClass('is-validated');
+ $("#name_help_loading").hide();
+ $("#name_help_text").show();
+ });
+ }
});
- $("#id_nickname").click(function() {
- $("#newchannel-submit-button").attr('disabled','disabled');
+ $("#id_nickname").on('input', function() {
+ $("#id_nickname").removeClass('is-validated');
});
- });
+ $("#newchannel-form").on('submit', function(event) {
+ if(! validate_name()) {
+ $("#id_name").focus()
+ return false;
+ }
+
+ if(! validate_channel()) {
+ $("#id_nickname").focus()
+ return false;
+ }
+
+ if(! $("#id_nickname").hasClass('is-validated')) {
+ event.preventDefault();
+ }
+ });
+ });
function validate_channel() {
- $("#nick-spinner").show();
+ if($("#id_nickname").hasClass('is-validated'))
+ return true;
+
+ $("#nick_help_loading").show();
+ $("#nick_help_text").hide();
+ var zreg_name = $("#id_name").val();
var zreg_nick = $("#id_nickname").val();
- $.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) {
+ $.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick) + '&name=' + encodeURIComponent(zreg_name),function(data) {
$("#id_nickname").val(data);
- if(data.error) {
- $("#help_nickname").html("");
- zFormError("#help_nickname",data.error);
+ if(data !== zreg_nick) {
+ $("#id_nickname").addClass('is-validated');
+ $("#help_nickname").addClass('text-danger').removeClass('text-muted');
+ $("#help_nickname").html(aStr['nick_invld1'] + data + aStr['nick_invld2']);
+ $("#id_nickname").focus();
}
else {
- $("#newchannel-submit-button").removeAttr('disabled');
+ $("#id_nickname").addClass('is-validated');
+ $("#help_nickname").addClass('text-success').removeClass('text-muted').removeClass('text-danger');
+ $("#help_nickname").html(aStr['nick_valid']);
}
- $("#nick-spinner").hide();
+ $("#nick_help_loading").hide();
+ $("#nick_help_text").show();
+
});
+ return true;
+
+ }
+
+ function validate_name() {
+ if($("#id_name").hasClass('is-validated'))
+ return true;
+
+ var verbs = [ aStr['lovely'], aStr['wonderful'], aStr['fantastic'], aStr['great'] ];
+ var verb = verbs[Math.floor((Math.random() * 4) + 0)];
+ if(! $("#id_name").val()) {
+ $("#id_name").focus();
+ $("#help_name").addClass('text-danger').removeClass('text-muted');
+ $("#help_name").html(aStr['name_empty']);
+ return false;
+ }
+ else {
+ $("#help_name").addClass('text-success').removeClass('text-muted').removeClass('text-danger');
+ $("#help_name").html(aStr['name_ok1'] + verb + aStr['name_ok2']);
+ $("#id_name").addClass('is-validated');
+ return true;
+ }
}