Created
November 6, 2014 18:53
-
-
Save alexcasalboni/7b7aac3413dc74ee3c4e to your computer and use it in GitHub Desktop.
Protected channels (only moderators' posts)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$(function(){ | |
//on domready | |
muut(function(app){ //on forum load | |
//retrieve DOM element | |
var createInput = $('.m-form.m-create'); | |
var only_admin_channels = ['Your Channel 1', 'Your Channel 2']; // list of channel-titles | |
var is_moderator = app.is_signed && app.user.is_admin; | |
//on load and update events | |
app.on('load update', function (_, e) { | |
//if channel page and not a moderator and protected channel | |
if(e.type == 'page' && !is_moderator && -1!==$.inArray(e.title, only_admin_channels)){ | |
createInput.hide(); | |
}else{ | |
createInput.show(); //this won't collide with 'display: none !important' | |
} | |
}); | |
}); | |
}); | |
})(window.jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment