Commit 63ac3c8e authored by cygnet's avatar cygnet

formatted admin js

parent 1810d16a
...@@ -104,33 +104,33 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -104,33 +104,33 @@ var Backend = {}; // common variable used in all the files of the backend
/** /**
* Roles management * Roles management
*/ */
Roles:{ Roles: {
selectors:{ selectors: {
associated:document.querySelector("select[name='associated_permissions']"), associated: document.querySelector("select[name='associated_permissions']"),
associated_container:document.getElementById("#available-permissions"), associated_container: document.getElementById("#available-permissions"),
}, },
init(page){ init(page) {
this.setSelectors(); this.setSelectors();
this.setRolepermission(page); this.setRolepermission(page);
this.addHandlers(); this.addHandlers();
}, },
setSelectors:function(){ setSelectors: function () {
this.selectors.associated=document.querySelector("select[name='associated_permissions']"); this.selectors.associated = document.querySelector("select[name='associated_permissions']");
this.selectors.associated_container=document.getElementById("available-permissions"); this.selectors.associated_container = document.getElementById("available-permissions");
}, },
addHandlers:function(){ addHandlers: function () {
var associated = this.selectors.associated; var associated = this.selectors.associated;
var associated_container = this.selectors.associated_container; var associated_container = this.selectors.associated_container;
if (associated_container != null) if (associated_container != null)
if (associated.value == "custom") if (associated.value == "custom")
Backend.Utils.removeClass(associated_container,"hidden"); Backend.Utils.removeClass(associated_container, "hidden");
else else
Backend.Utils.addClass(associated_container,'hidden'); Backend.Utils.addClass(associated_container, 'hidden');
associated.onchange = function(event){ associated.onchange = function (event) {
if (associated_container != null) if (associated_container != null)
if (associated.value == "custom") if (associated.value == "custom")
Backend.Utils.removeClass(associated_container, "hidden"); Backend.Utils.removeClass(associated_container, "hidden");
...@@ -138,7 +138,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -138,7 +138,7 @@ var Backend = {}; // common variable used in all the files of the backend
Backend.Utils.addClass(associated_container, 'hidden'); Backend.Utils.addClass(associated_container, 'hidden');
}; };
}, },
setRolepermission: function (page){ setRolepermission: function (page) {
Backend.Users.setSelectors(); Backend.Users.setSelectors();
Backend.Users.addHandlers(page); Backend.Users.addHandlers(page);
} }
...@@ -153,7 +153,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -153,7 +153,7 @@ var Backend = {}; // common variable used in all the files of the backend
selectors: { selectors: {
select2: $(".select2"), select2: $(".select2"),
getPremissionURL: "", getPremissionURL: "",
showPermission:document.querySelectorAll(".show-permissions") showPermission: document.querySelectorAll(".show-permissions")
}, },
init: function (page) { init: function (page) {
this.setSelectors(); this.setSelectors();
...@@ -222,7 +222,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -222,7 +222,7 @@ var Backend = {}; // common variable used in all the files of the backend
this.selectors.select2.select2(); this.selectors.select2.select2();
}, },
windowloadhandler:function(){ windowloadhandler: function () {
// scripts to be handeled on user create and edit when window is laoaded // scripts to be handeled on user create and edit when window is laoaded
Backend.Users.selectors.showPermission.forEach(function (element) { Backend.Users.selectors.showPermission.forEach(function (element) {
...@@ -250,8 +250,8 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -250,8 +250,8 @@ var Backend = {}; // common variable used in all the files of the backend
* *
*/ */
UserDeleted:{ UserDeleted: {
selectors:{ selectors: {
AlldeletePerms: document.querySelectorAll("a[name='delete_user_perm']"), AlldeletePerms: document.querySelectorAll("a[name='delete_user_perm']"),
AllrestorePerms: document.querySelectorAll("a[name='restore_user']"), AllrestorePerms: document.querySelectorAll("a[name='restore_user']"),
Areyousure: "", Areyousure: "",
...@@ -260,9 +260,9 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -260,9 +260,9 @@ var Backend = {}; // common variable used in all the files of the backend
cancel: "", cancel: "",
restore_user_confirm: "", restore_user_confirm: "",
}, },
setSelectors:function(){ setSelectors: function () {
this.selectors.AlldeletePerms= document.querySelectorAll("a[name='delete_user_perm']"); this.selectors.AlldeletePerms = document.querySelectorAll("a[name='delete_user_perm']");
this.selectors.AllrestorePerms= document.querySelectorAll("a[name='restore_user']"); this.selectors.AllrestorePerms = document.querySelectorAll("a[name='restore_user']");
}, },
windowloadhandler: function () { windowloadhandler: function () {
this.setSelectors(); this.setSelectors();
...@@ -294,7 +294,7 @@ var Backend = {}; // common variable used in all the files of the backend ...@@ -294,7 +294,7 @@ var Backend = {}; // common variable used in all the files of the backend
*/ */
this.selectors.AllrestorePerms.forEach(function (element) { this.selectors.AllrestorePerms.forEach(function (element) {
element.onclick = function (event,element) { element.onclick = function (event, element) {
event.preventDefault(); event.preventDefault();
var linkURL = this.getAttribute("href"); var linkURL = this.getAttribute("href");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment