Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

available() accepts array with permissions

if available(permissions) is an array, all permissions in this array must exist
  • Loading branch information...
commit 5074ed26a2250a5ba2205cb87ef7cc3e9d80e9f4 1 parent 5334c4d
@schakko authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 jquery.inherited-permissions.js
View
19 jquery.inherited-permissions.js
@@ -24,15 +24,24 @@ jQuery.inheritedPermissions = function () {
/**
* Checks if the permission in the current context or one of the top contexts are available
- * @param string permission name
+ * @param string|array permission name
* @param string optional; context to check, if not defined: current context
* @returns true if permission is in context available.
*/
- self.available = function (permission, context) {
+ self.available = function (permissions, context) {
var allPerms = self.all(context)
- var r = jQuery.inArray(permission, allPerms)
- return r !== -1;
+ if (!jQuery.isArray(permissions)) {
+ permissions = [permissions]
+ }
+
+ for (var i = 0, m = permissions.length; i < m; i++) {
+ if (-1 === jQuery.inArray(permissions[i], allPerms)) {
+ return false
+ }
+ }
+
+ return true;
};
/**
@@ -233,4 +242,4 @@ jQuery.inheritedPermissions = function () {
}
return self
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.