Commit 86b59510 authored by cygnet's avatar cygnet

changes for show and hiiden on user page

parent 8652f11c
...@@ -24,7 +24,6 @@ yarn-error.log ...@@ -24,7 +24,6 @@ yarn-error.log
phpunit.txt phpunit.txt
public/css public/css
public/js/*.js public/js/*.js
public/js/plugins public/js/plugins
public/js/skins public/js/skins
public/js/themes public/js/themes
......
$(function() { window.onload = function () {
$(".show-permissions").click(function(e) { document.querySelectorAll(".show-permissions").forEach(function(element){
e.preventDefault(); element.onclick = function(event){
var $this = $(this); event.preventDefault();
var role = $this.data('role'); var $this = this;
var permissions = $(".permission-list[data-role='"+role+"']"); var role = $this.getAttribute("data-role");
var hideText = $this.find('.hide-text');
var showText = $this.find('.show-text'); var permissions = document.querySelector(".permission-list[data-role='"+role+"']");
// console.log(permissions); // for debugging var hideText = $this.querySelector('.hide-text');
var showText = $this.querySelector('.show-text');
// show permission list
permissions.toggleClass('hidden'); // show permission list
Backend.Utils.toggleClass(permissions,'hidden');
// toggle the text Show/Hide for the link
hideText.toggleClass('hidden'); // toggle the text Show/Hide for the link
showText.toggleClass('hidden'); Backend.Utils.toggleClass(hideText,'hidden');
Backend.Utils.toggleClass(showText,'hidden');
};
}); });
});
};
var Backend = { //common functionalities for all the javascript featueres
var Backend = {}; // common variable used in all the files of the backend
(function()
{
Backend = {
Utils:{
toggleClass :function(element,className){
if (element.classList) {
element.classList.toggle(className);
} else {
var classes = element.className.split(' ');
var existingIndex = classes.indexOf(className);
if (existingIndex >= 0)
classes.splice(existingIndex, 1);
else
classes.push(className);
element.className = classes.join(' ');
}
}
},
/** /**
* Pages * Pages
* *
*/ */
...@@ -20,21 +42,24 @@ var Backend = { ...@@ -20,21 +42,24 @@ var Backend = {
Access: Access:
{ {
selectors: { selectors: {
select2: jQuery(".select2"), select2: $(".select2"),
}, },
init: function () init: function ()
{ {
this.setSelectors();
this.addHandlers(); this.addHandlers();
}, },
setSelectors:function(){
this.selectors.select2 = $(".select2");
},
addHandlers: function () addHandlers: function ()
{ {
this.selectors.select2.select2(); this.selectors.select2.select2();
} }
}, },
/** /**
* Blog * Blog
* *
...@@ -42,18 +67,24 @@ var Backend = { ...@@ -42,18 +67,24 @@ var Backend = {
Blog: Blog:
{ {
selectors: { selectors: {
tags: jQuery(".tags"), tags: document.querySelector(".tags"),
categories : jQuery(".categories"), categories : document.querySelector(".categories"),
toDisplay :jQuery(".toDisplay"), toDisplay :document.querySelector(".toDisplay"),
status : jQuery(".status"), status : document.querySelector(".status"),
}, },
init: function () init: function ()
{ {
this.setSelectors();
this.addHandlers(); this.addHandlers();
Backend.tinyMCE.init(); Backend.tinyMCE.init();
}, },
setSelectors:function(){
tags= document.querySelector(".tags");
categories = document.querySelector(".categories");
toDisplay =document.querySelector(".toDisplay");
status = document.querySelector(".status");
},
addHandlers: function () addHandlers: function ()
{ {
this.selectors.tags.select2({ this.selectors.tags.select2({
...@@ -117,7 +148,7 @@ var Backend = { ...@@ -117,7 +148,7 @@ var Backend = {
emailTemplate: { emailTemplate: {
selectors: { selectors: {
emailtemplateSelection: jQuery(".select2") emailtemplateSelection: document.querySelector(".select2")
}, },
init: function () { init: function () {
...@@ -147,12 +178,14 @@ var Backend = { ...@@ -147,12 +178,14 @@ var Backend = {
// ! Backend.emailTemplate.showPreview // ! Backend.emailTemplate.showPreview
showPreview: function (event) { showPreview: function (event) {
jQuery( ".modal-body" ).html(tinyMCE.get('txtBody').getContent());
$(".model-wrapper").modal('show'); document.querySelector( ".modal-body" ).innerHTML = tinyMCE.get('txtBody').getContent();
document.querySelector( ".modal-body" ).modal('show');
}, },
}, },
/** /**
* Faq * Faq
* *
*/ */
...@@ -173,95 +206,138 @@ var Backend = { ...@@ -173,95 +206,138 @@ var Backend = {
} }
}, },
/**
* Profile
*
*/
Profile:
{
selectors: {
state: jQuery(".st"),
cities : jQuery(".ct"),
},
init: function () /**
* Profile
*
*/
Profile:
{ {
this.addHandlers(); init: function ()
{
this.setSelectors();
this.addHandlers();
},
setSelectors:function(){
this.selectors.state = document.querySelector(".st");
this.selectors.cities = document.querySelector(".ct");
},
addHandlers: function ()
{
this.selectors.state.select2();
this.selectors.cities.select2();
}
}, },
addHandlers: function () /**
{ * for all datatables
this.selectors.state.select2(); *
this.selectors.cities.select2(); */
} DataTableSearch: { //functionalities related to datable search at all the places
}, selector:{
},
DataTableSearch: { init: function (dataTable) {
init: function (dataTable) {
// Header All search columns this.setSelectors();
$("div.dataTables_filter input").unbind(); this.addHandlers();
$("div.dataTables_filter input").keypress( function (e)
{ },
if (e.keyCode == 13) setSelectors:function(){
{ this.selector.searchInput = document.querySelector("div.dataTables_filter input");
dataTable.fnFilter( this.value ); this.selector.columnSearchInput = document.querySelectorAll(".search-input-text");
this.selector.columnSelectInput = document.querySelectorAll('search-input-select');
this.selector.restButton = document.querySelectorAll('.reset-data');
this.setSelectors.copyButton = document.getElementById("copyButton");
this.setSelectors.csvButton = document.getElementById("csvButton");
this.setSelectors.excelButton = document.getElementById("excelButton");
this.setSelectors.pdfButton = document.getElementById("pdfButton");
this.setSelectors.printButton = document.getElementById("printButton");
},
cloneElement:function(element,callback){
var clone = element.cloneNode();
while (element.firstChild) {
clone.appendChild(element.lastChild);
} }
}); element.parentNode.replaceChild(clone, element);
Backend.DataTableSearch.setSelectors();
// Individual columns search callback(this.selector.searchInput);
$('.search-input-text').on( 'keypress', function (e) { },
addHandlers:function(){
// get the datatable search input and on its key press check if we hit enter then search with datatable
this.cloneElement(this.selector.searchInput,function(element){ //cloning done to remove any binding of the events
element.onkeypress = function(event){
if(event.keyCode==13){
dataTable.fnFilter( this.value );
}
};
}); // to remove all the listinerers
// for text boxes // for text boxes
if (e.keyCode == 13) //column input search if search box on the column of the datatable given with enter then search with datatable
{ if(this.selector.columnSearchInput.length>0){
var i =$(this).attr('data-column'); // getting column index this.selector.columnSearchInput.forEach(function(element){
var v =$(this).val(); // getting search input value element.onkeypress = function(event){
dataTable.api().columns(i).search(v).draw(); if (event.keyCode == 13){
var i =element.getAttribute("data-column") // getting column index
var v =element.value; // getting search input value
dataTable.api().columns(i).search(v).draw();
}
};
});
} }
});
// Individual columns search
if(this.selector.columnSelectInput.length>>0){
this.selector.columnSelectInput.forEach(function(element){
element.onchange = function(event){
var i =element.getAttribute("data-column"); // getting column index
var v =element.value; // getting search input value
dataTable.api().columns(i).search(v).draw();
};
});
}
// Individual columns reset
if(this.selector.restButton.length>>0){
this.selector.restButton.forEach(function(element){
element.onclick = function(event){
var inputelement = this.previousElementSibling;
var i = inputelement.getAttribute("data-column");
inputelement.value = "";
dataTable.api().columns(i).search("").draw();
};
});
}
this.setSelectors.copyButton.onclick = function(element){
document.querySelector(".copyButton").click();
};
this.setSelectors.csvButton.onclick = function(element){
document.querySelector(".csvButton").click();
};
this.setSelectors.excelButton.onclick = function(element){
document.querySelector(".excelButton").click();
};
this.setSelectors.pdfButton.onclick = function(element){
document.querySelector(".pdfButton").click();
};
this.setSelectors.printButton.onclick = function(element){
document.querySelector(".printButton").click();
};
}
}
};
})();
// Individual columns search
$('.search-input-select').on( 'change', function (e) {
// for dropdown
var i =$(this).attr('data-column'); // getting column index
var v =$(this).val(); // getting search input value
dataTable.api().columns(i).search(v).draw();
});
// Individual columns reset
$('.reset-data').on( 'click', function (e) {
var textbox = $(this).prev('input'); // Getting closest input field
var i =textbox.attr('data-column'); // Getting column index
$(this).prev('input').val(''); // Blank the serch value
dataTable.api().columns(i).search("").draw();
});
//Copy button
$('#copyButton').click(function(){
$('.copyButton').trigger('click');
});
//Download csv
$('#csvButton').click(function(){
$('.csvButton').trigger('click');
});
//Download excelButton
$('#excelButton').click(function(){
$('.excelButton').trigger('click');
});
//Download pdf
$('#pdfButton').click(function(){
$('.pdfButton').trigger('click');
});
//Download printButton
$('#printButton').click(function(){
$('.printButton').trigger('click');
});
var id = $('.table-responsive .dataTables_filter').attr('id');
$('#'+id+' label').append('<a class="reset-data" id="input-sm-reset" href="javascript:void(0)"><i class="fa fa-times"></i></a>');
$(document).on('click', "#"+id+" label #input-sm-reset", function(){
dataTable.fnFilter('');
});
},
}
}
\ No newline at end of file
...@@ -43,8 +43,7 @@ mix.sass('resources/assets/sass/frontend/app.scss', 'public/css/frontend.css') ...@@ -43,8 +43,7 @@ mix.sass('resources/assets/sass/frontend/app.scss', 'public/css/frontend.css')
"public/js/bootstrap-datetimepicker.min.js", "public/js/bootstrap-datetimepicker.min.js",
"public/js/backend/custom-file-input.js", "public/js/backend/custom-file-input.js",
"public/js/backend/notification.js", "public/js/backend/notification.js",
//"public/js/backend/admin.js" "public/js/backend/admin.js"
"public/js/backend/mainbackend.js"
], 'public/js/backend-custom.js') ], 'public/js/backend-custom.js')
//Datatable js //Datatable js
.scripts([ .scripts([
......
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