Primo commit: trasferimento del progetto PPEasy
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
/**
|
||||
* Theme: Crovex - Responsive Bootstrap 4 Admin Dashboard
|
||||
* Author: Mannatthemes
|
||||
* Module/App: Main Js
|
||||
*/
|
||||
|
||||
|
||||
(function ($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
function initSlimscroll() {
|
||||
$('.slimscroll').slimscroll({
|
||||
height: 'auto',
|
||||
position: 'right',
|
||||
size: "7px",
|
||||
color: '#a2b1d021',
|
||||
opacity: 1,
|
||||
wheelStep: 5,
|
||||
touchScrollStep: 50
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initMetisMenu() {
|
||||
//metis menu
|
||||
$(".metismenu").metisMenu();
|
||||
$( window ).resize(function() {
|
||||
initEnlarge();
|
||||
});
|
||||
}
|
||||
|
||||
function initLeftMenuCollapse() {
|
||||
// Left menu collapse
|
||||
$('.button-menu-mobile').on('click', function (event) {
|
||||
event.preventDefault();
|
||||
$("body").toggleClass("enlarge-menu");
|
||||
initSlimscroll();
|
||||
});
|
||||
}
|
||||
|
||||
function initEnlarge() {
|
||||
if ($(window).width() < 1025) {
|
||||
$('body').addClass('enlarge-menu enlarge-menu-all');
|
||||
} else {
|
||||
// if ($('body').data('keep-enlarged') != true)
|
||||
$('body').removeClass('enlarge-menu enlarge-menu-all');
|
||||
}
|
||||
}
|
||||
|
||||
function initTooltipPlugin(){
|
||||
$.fn.tooltip && $('[data-toggle="tooltip"]').tooltip()
|
||||
}
|
||||
|
||||
function initMainIconTabMenu() {
|
||||
$('.main-icon-menu .nav-link').on('click', function(e){
|
||||
$("body").removeClass("enlarge-menu");
|
||||
e.preventDefault();
|
||||
$(this).addClass('active');
|
||||
$(this).siblings().removeClass('active');
|
||||
$('.main-menu-inner').addClass('active');
|
||||
var targ = $(this).attr('href');
|
||||
$(targ).addClass('active');
|
||||
$(targ).siblings().removeClass('active');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initActiveMenu() {
|
||||
// === following js will activate the menu in left side bar based on url ====
|
||||
$(".leftbar-tab-menu a, .left-sidenav a").each(function () {
|
||||
var pageUrl = window.location.href.split(/[?#]/)[0];
|
||||
if (this.href == pageUrl) {
|
||||
$(this).addClass("active");
|
||||
$(this).parent().addClass("active"); // add active to li of the current link
|
||||
$(this).parent().parent().addClass("in");
|
||||
$(this).parent().parent().addClass("mm-show");
|
||||
$(this).parent().parent().parent().addClass("mm-active");
|
||||
$(this).parent().parent().prev().addClass("active"); // add active class to an anchor
|
||||
$(this).parent().parent().parent().addClass("active");
|
||||
$(this).parent().parent().parent().parent().addClass("mm-show"); // add active to li of the current link
|
||||
$(this).parent().parent().parent().parent().parent().addClass("mm-active");
|
||||
var menu = $(this).closest('.main-icon-menu-pane').attr('id');
|
||||
$("a[href='#"+menu+"']").addClass('active');
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initFeatherIcon() {
|
||||
feather.replace()
|
||||
}
|
||||
// Auto complate
|
||||
|
||||
function initAutoComplate() {
|
||||
$(document).ready(function() {
|
||||
BindControls();
|
||||
});
|
||||
|
||||
function BindControls() {
|
||||
var Countries = ['Forms',
|
||||
'Tables',
|
||||
'Charts',
|
||||
'Icones',
|
||||
'Maps'];
|
||||
|
||||
$('#AllCompo').autocomplete({
|
||||
source: Countries,
|
||||
minLength: 0,
|
||||
scroll: true
|
||||
}).focus(function() {
|
||||
$(this).autocomplete("search", "");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function initMainIconMenu() {
|
||||
$(".navigation-menu a").each(function () {
|
||||
var pageUrl = window.location.href.split(/[?#]/)[0];
|
||||
if (this.href == pageUrl) {
|
||||
$(this).parent().addClass("active"); // add active to li of the current link
|
||||
$(this).parent().parent().parent().addClass("active"); // add active class to an anchor
|
||||
$(this).parent().parent().parent().parent().parent().addClass("active"); // add active class to an anchor
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initTopbarMenu() {
|
||||
$('.navbar-toggle').on('click', function (event) {
|
||||
$(this).toggleClass('open');
|
||||
$('#navigation').slideToggle(400);
|
||||
});
|
||||
|
||||
$('.navigation-menu>li').slice(-2).addClass('last-elements');
|
||||
|
||||
$('.navigation-menu li.has-submenu a[href="#"]').on('click', function (e) {
|
||||
if ($(window).width() < 992) {
|
||||
e.preventDefault();
|
||||
$(this).parent('li').toggleClass('open').find('.submenu:first').toggleClass('open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init() {
|
||||
initSlimscroll();
|
||||
initMetisMenu();
|
||||
initLeftMenuCollapse();
|
||||
initEnlarge();
|
||||
initTooltipPlugin();
|
||||
initMainIconTabMenu();
|
||||
initActiveMenu();
|
||||
initFeatherIcon();
|
||||
initAutoComplate();
|
||||
initMainIconMenu();
|
||||
initTopbarMenu();
|
||||
Waves.init();
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
})(jQuery)
|
||||
@@ -0,0 +1,48 @@
|
||||
var as = {};
|
||||
|
||||
as.toggleSidebar = function () {
|
||||
$(".sidebar").toggleClass('expanded');
|
||||
};
|
||||
|
||||
as.hideNotifications = function () {
|
||||
$(".alert-notification").slideUp(600, function () {
|
||||
$(this).remove();
|
||||
})
|
||||
};
|
||||
|
||||
as.updateSidebarSize = function () {
|
||||
if (window.innerWidth >= 992 && window.innerWidth <= 1199) {
|
||||
window.document.body.classList.add("sidebar-collapsed");
|
||||
} else {
|
||||
window.document.body.classList.remove("sidebar-collapsed");
|
||||
}
|
||||
};
|
||||
|
||||
as.init = function () {
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }
|
||||
});
|
||||
|
||||
$("#sidebar-toggle").click(as.toggleSidebar);
|
||||
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
$('[data-toggle="popover"]').popover();
|
||||
|
||||
$(".alert-notification .close").click(as.hideNotifications);
|
||||
|
||||
setTimeout(as.hideNotifications, 3500);
|
||||
|
||||
$("a[data-toggle=loader], button[data-toggle=loader]").click(function () {
|
||||
if ($(this).parents('form').valid()) {
|
||||
as.btn.loading($(this), $(this).data('loading-text'));
|
||||
$(this).parents('form').submit();
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(as.updateSidebarSize);
|
||||
};
|
||||
|
||||
as.updateSidebarSize();
|
||||
|
||||
$(document).ready(as.init);
|
||||
@@ -0,0 +1,19 @@
|
||||
as.btn = {};
|
||||
|
||||
as.btn.loading = function(button, text) {
|
||||
var oldText = button.text();
|
||||
var newText = typeof text == "undefined" ? '' : text;
|
||||
|
||||
var html = '<i class="fa fa-spinner fa-spin"></i> ' + newText;
|
||||
button.data("old-text", oldText)
|
||||
.html(html)
|
||||
.addClass("disabled")
|
||||
.attr('disabled', "disabled");
|
||||
};
|
||||
|
||||
as.btn.stopLoading = function (button) {
|
||||
var oldText = button.data('old-text');
|
||||
button.text(oldText)
|
||||
.removeClass("disabled")
|
||||
.removeAttr("disabled");
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
as.dashboard = {};
|
||||
|
||||
as.dashboard.initChart = function () {
|
||||
var data = {
|
||||
labels: months,
|
||||
datasets: [
|
||||
{
|
||||
label: trans.chartLabel,
|
||||
backgroundColor: "transparent",
|
||||
borderColor: "#179970",
|
||||
pointBackgroundColor: "#179970",
|
||||
data: users
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var ctx = document.getElementById("myChart").getContext("2d");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
gridLines: {
|
||||
display: false,
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
gridLines: {
|
||||
color: "#f6f6f6",
|
||||
zeroLineColor: '#f6f6f6',
|
||||
drawBorder: false
|
||||
},
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
callback: function(value) {if (value % 1 === 0) {return value;}}
|
||||
}
|
||||
}]
|
||||
},
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
titleMarginBottom: 15,
|
||||
callbacks: {
|
||||
label: function(tooltipItem, data) {
|
||||
var value = tooltipItem.yLabel,
|
||||
suffix = trans.new + " " + (value == 1 ? trans.user : trans.users);
|
||||
|
||||
return " " + value + " " + suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
as.dashboard.initChart();
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
as.dashboard = {};
|
||||
|
||||
as.dashboard.initChart = function () {
|
||||
var data = {
|
||||
labels: labels,
|
||||
datasets: [
|
||||
{
|
||||
label: trans.chartLabel,
|
||||
backgroundColor: "transparent",
|
||||
borderColor: "#179970",
|
||||
pointBackgroundColor: "#179970",
|
||||
data: activities
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
var ctx = document.getElementById("myChart").getContext("2d");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: data,
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
gridLines: {
|
||||
display: false,
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
gridLines: {
|
||||
color: "#f6f6f6",
|
||||
zeroLineColor: '#f6f6f6',
|
||||
drawBorder: false
|
||||
},
|
||||
ticks: {
|
||||
beginAtZero: true,
|
||||
callback: function(value) {if (value % 1 === 0) {return value;}}
|
||||
}
|
||||
}]
|
||||
},
|
||||
responsive: true,
|
||||
legend: {
|
||||
display: false
|
||||
},
|
||||
maintainAspectRatio: false,
|
||||
tooltips: {
|
||||
titleMarginBottom: 15,
|
||||
callbacks: {
|
||||
label: function(tooltipItem, data) {
|
||||
var value = tooltipItem.yLabel,
|
||||
suffix = value == 1 ? trans.action : trans.actions;
|
||||
|
||||
return " " + value + " " + suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
$(document).ready(function () {
|
||||
as.dashboard.initChart();
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
var valid = false;
|
||||
|
||||
$("#login-form").submit(function (e) {
|
||||
var $form = $(this);
|
||||
|
||||
if (! $form.valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
as.btn.loading($("#btn-login"));
|
||||
|
||||
return true;
|
||||
});
|
||||
@@ -0,0 +1,174 @@
|
||||
$("#avatar-form").submit(function () {
|
||||
$(".avatar-controls .btn").attr('disabled', 'disabled');
|
||||
as.btn.loading($("#save-photo"), 'Saving...');
|
||||
|
||||
var points = $("#avatar").croppie('get').points;
|
||||
$("#points_x1").val(points[0]);
|
||||
$("#points_y1").val(points[1]);
|
||||
$("#points_x2").val(points[2]);
|
||||
$("#points_y2").val(points[3]);
|
||||
});
|
||||
|
||||
$('#birthday').datepicker({
|
||||
orientation: 'bottom',
|
||||
startView: 'years',
|
||||
format: 'yyyy-mm-dd'
|
||||
});
|
||||
|
||||
var vHeight = 202,
|
||||
image = null,
|
||||
croppie = null;
|
||||
|
||||
function initCroppie() {
|
||||
var avatar = $('#avatar');
|
||||
var width = $(".avatar-wrapper").width(),
|
||||
bWidth = width * 82/100,
|
||||
vWidth = bWidth * 53/100;
|
||||
|
||||
if (vWidth > 160) {
|
||||
vWidth = 160;
|
||||
}
|
||||
|
||||
avatar.croppie('destroy');
|
||||
croppie = avatar.croppie({
|
||||
viewport: {
|
||||
width: vWidth,
|
||||
height: vWidth,
|
||||
type: 'circle'
|
||||
},
|
||||
boundary: {
|
||||
width: bWidth,
|
||||
height: vHeight
|
||||
}
|
||||
});
|
||||
|
||||
if (image) {
|
||||
croppie.croppie('bind', {
|
||||
url: image
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var timer;
|
||||
|
||||
$(window).resize(function () {
|
||||
if (croppie) {
|
||||
timer && clearTimeout(timer);
|
||||
timer = setTimeout(initCroppie, 100);
|
||||
}
|
||||
});
|
||||
|
||||
function readFile(input) {
|
||||
if (input.files && input.files[0]) {
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
image = e.target.result;
|
||||
hideCurrentImage();
|
||||
initCroppie();
|
||||
hideSpinner();
|
||||
}
|
||||
|
||||
closeChooseModal();
|
||||
makeCurrentImageInvisible();
|
||||
hideChangePictureButton();
|
||||
showAvatarControlButtons();
|
||||
showSpinner();
|
||||
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
else {
|
||||
swal("Sorry - you're browser doesn't support the FileReader API");
|
||||
}
|
||||
}
|
||||
|
||||
$("#cancel-upload").click(function () {
|
||||
croppie = null;
|
||||
$('#avatar').croppie('destroy');
|
||||
$("#avatar").removeClass('croppie-container');
|
||||
hideAvatarControlButtons();
|
||||
showChangePictureButton();
|
||||
makeCurrentImageVisible();
|
||||
showCurrentImage();
|
||||
});
|
||||
|
||||
function showAvatarControlButtons() {
|
||||
$(".avatar-controls").removeClass('d-none').addClass('d-flex');
|
||||
}
|
||||
|
||||
function hideAvatarControlButtons() {
|
||||
$(".avatar-controls").removeClass('d-flex').addClass('d-none');
|
||||
}
|
||||
|
||||
function showChangePictureButton() {
|
||||
$("#change-picture").show();
|
||||
}
|
||||
|
||||
function hideChangePictureButton() {
|
||||
$("#change-picture").hide();
|
||||
}
|
||||
|
||||
function closeChooseModal() {
|
||||
$("#choose-modal").modal('hide');
|
||||
}
|
||||
|
||||
function hideCurrentImage() {
|
||||
$(".avatar-wrapper .avatar-preview").hide();
|
||||
}
|
||||
|
||||
function showCurrentImage() {
|
||||
$(".avatar-wrapper .avatar-preview").show();
|
||||
}
|
||||
|
||||
function makeCurrentImageInvisible() {
|
||||
$(".avatar-wrapper .avatar-preview").css({visibility: 'hidden'});
|
||||
}
|
||||
|
||||
function makeCurrentImageVisible() {
|
||||
$(".avatar-wrapper .avatar-preview").css({visibility: 'visible'});
|
||||
}
|
||||
|
||||
function showSpinner() {
|
||||
$(".avatar-wrapper .spinner").css({opacity: 1});
|
||||
}
|
||||
|
||||
function hideSpinner() {
|
||||
$(".avatar-wrapper .spinner").css({opacity: 0});
|
||||
}
|
||||
|
||||
function updateAvatarFromSource(url, imageUrl) {
|
||||
var form =
|
||||
$('<form>', {
|
||||
'method': 'POST',
|
||||
'action': url
|
||||
});
|
||||
|
||||
var hiddenInput =
|
||||
$('<input>', {
|
||||
'name': 'url',
|
||||
'type': 'hidden',
|
||||
'value': imageUrl
|
||||
});
|
||||
|
||||
var token =
|
||||
$("<input>", {
|
||||
'name': '_token',
|
||||
'type': 'hidden',
|
||||
'value': $('meta[name="csrf-token"]').attr('content')
|
||||
});
|
||||
|
||||
form.append(token, hiddenInput)
|
||||
.appendTo('body')
|
||||
.submit();
|
||||
}
|
||||
|
||||
$('#avatar-upload').on('change', function () { readFile(this); });
|
||||
|
||||
$(".source-external img").click(function () {
|
||||
var imageUrl = $(this).attr('src');
|
||||
updateAvatarFromSource($(this).parent().data('url'), imageUrl);
|
||||
});
|
||||
|
||||
$("#no-photo img").click(function () {
|
||||
updateAvatarFromSource($(this).parent().data('url'), null);
|
||||
});
|
||||
@@ -0,0 +1,36 @@
|
||||
var timer;
|
||||
var $btn = $("#resend-token");
|
||||
|
||||
/**
|
||||
* Start timeout which will show the "Resend Token" button
|
||||
* after 60 seconds.
|
||||
*/
|
||||
function startTimer() {
|
||||
timer = setTimeout(function () {
|
||||
$btn.removeClass('d-none');
|
||||
}, 60 * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resend phone verification token.
|
||||
*/
|
||||
function resendToken() {
|
||||
as.btn.loading($btn, $btn.data('loading-text'));
|
||||
|
||||
$.post("/two-factor/resend", user ? {user: user} : {})
|
||||
.then(handleResendResponse)
|
||||
.catch(handleResendResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle response received from the server after
|
||||
* resend token request was sent.
|
||||
*/
|
||||
function handleResendResponse() {
|
||||
as.btn.stopLoading($btn);
|
||||
$btn.addClass('d-none');
|
||||
startTimer();
|
||||
}
|
||||
|
||||
$btn.click(resendToken);
|
||||
startTimer();
|
||||
+7
File diff suppressed because one or more lines are too long
Vendored
+7
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
+10
File diff suppressed because one or more lines are too long
@@ -0,0 +1,79 @@
|
||||
(function() {
|
||||
|
||||
var laravel = {
|
||||
initialize: function() {
|
||||
this.registerEvents();
|
||||
},
|
||||
|
||||
registerEvents: function() {
|
||||
$('body').on('click', 'a[data-method]', this.handleMethod);
|
||||
},
|
||||
|
||||
handleMethod: function(e) {
|
||||
var link = $(this);
|
||||
var httpMethod = link.data('method').toUpperCase();
|
||||
var form;
|
||||
|
||||
// If the data-method attribute is not PUT or DELETE,
|
||||
// then we don't know what to do. Just ignore.
|
||||
if ( $.inArray(httpMethod, ['PUT', 'DELETE']) === - 1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allow user to optionally provide data-confirm="Are you sure?"
|
||||
if ( link.data('confirm-text') ) {
|
||||
laravel.verifyConfirm(link, function (t) {
|
||||
if (! t) return false;
|
||||
|
||||
form = laravel.createForm(link);
|
||||
form.submit();
|
||||
})
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
},
|
||||
|
||||
verifyConfirm: function(link, callback) {
|
||||
swal({
|
||||
title: link.data('confirm-title'),
|
||||
text: link.data('confirm-text'),
|
||||
type: 'warning',
|
||||
button: link.data('confirm-delete') ? link.data('confirm-delete') : "Yes, delete it!",
|
||||
}).then(function (t) {
|
||||
callback(t)
|
||||
});
|
||||
},
|
||||
|
||||
getCsrfToken: function () {
|
||||
return $('meta[name="csrf-token"]').attr('content');
|
||||
},
|
||||
|
||||
createForm: function(link) {
|
||||
var form =
|
||||
$('<form>', {
|
||||
'method': 'POST',
|
||||
'action': link.attr('href')
|
||||
});
|
||||
|
||||
var token =
|
||||
$('<input>', {
|
||||
'name': '_token',
|
||||
'type': 'hidden',
|
||||
'value': laravel.getCsrfToken()
|
||||
});
|
||||
|
||||
var hiddenInput =
|
||||
$('<input>', {
|
||||
'name': '_method',
|
||||
'type': 'hidden',
|
||||
'value': link.data('method')
|
||||
});
|
||||
|
||||
return form.append(token, hiddenInput)
|
||||
.appendTo('body');
|
||||
}
|
||||
};
|
||||
|
||||
laravel.initialize();
|
||||
|
||||
})();
|
||||
Vendored
+13
File diff suppressed because one or more lines are too long
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+13
File diff suppressed because one or more lines are too long
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Theme: Crovex - Responsive Bootstrap 4 Admin Dashboard
|
||||
* Author: Mannatthemes
|
||||
* Module/App: Core Js
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Components
|
||||
*/
|
||||
!function($) {
|
||||
"use strict";
|
||||
|
||||
var Components = function() {};
|
||||
|
||||
|
||||
//initializing popover
|
||||
Components.prototype.initPopoverPlugin = function() {
|
||||
$.fn.popover && $('[data-toggle="popover"]').popover()
|
||||
},
|
||||
|
||||
|
||||
//initializing Slimscroll
|
||||
Components.prototype.initSlimScrollPlugin = function() {
|
||||
//You can change the color of scroll bar here
|
||||
$.fn.slimScroll && $(".slimscroll-alt").slimScroll({ position: 'right',size: "5px", color: '#98a6ad',wheelStep: 10});
|
||||
},
|
||||
|
||||
//range slider
|
||||
Components.prototype.initRangeSlider = function() {
|
||||
$.fn.slider && $('[data-plugin="range-slider"]').slider({});
|
||||
},
|
||||
|
||||
/* -------------
|
||||
* Form related controls
|
||||
*/
|
||||
|
||||
|
||||
|
||||
Components.prototype.initCounterUp = function() {
|
||||
var delay = $(this).attr('data-delay')?$(this).attr('data-delay'):100; //default is 100
|
||||
var time = $(this).attr('data-time')?$(this).attr('data-time'):1200; //default is 1200
|
||||
$('[data-plugin="counterup"]').each(function(idx, obj) {
|
||||
$(this).counterUp({
|
||||
delay: 100,
|
||||
time: 1200
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
//toast
|
||||
Components.prototype.initToast = function() {
|
||||
$.fn.toast && $('[data-toggle="toast"]').toast()
|
||||
},
|
||||
|
||||
// Accordion-bg
|
||||
Components.prototype.initAccordionBg = function() {
|
||||
// Add minus icon for collapse element which is open by default
|
||||
$(".collapse.show").each(function(){
|
||||
$(this).prev(".card-header") .addClass("custom-accordion");
|
||||
});
|
||||
|
||||
// Toggle plus minus icon on show hide of collapse element
|
||||
$(".collapse").on('show.bs.collapse', function(){
|
||||
$(this).prev(".card-header").addClass("custom-accordion");
|
||||
}).on('hide.bs.collapse', function(){
|
||||
$(this).prev(".card-header").removeClass("custom-accordion");
|
||||
});
|
||||
},
|
||||
|
||||
//bootstrap validation
|
||||
Components.prototype.initValidation = function() {
|
||||
window.addEventListener('load', function() {
|
||||
// Fetch all the forms we want to apply custom Bootstrap validation styles to
|
||||
var forms = document.getElementsByClassName('needs-validation');
|
||||
// Loop over them and prevent submission
|
||||
var validation = Array.prototype.filter.call(forms, function(form) {
|
||||
form.addEventListener('submit', function(event) {
|
||||
if (form.checkValidity() === false) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}
|
||||
form.classList.add('was-validated');
|
||||
}, false);
|
||||
});
|
||||
}, false);
|
||||
},
|
||||
//initilizing
|
||||
Components.prototype.init = function() {
|
||||
var $this = this;
|
||||
this.initPopoverPlugin(),
|
||||
this.initSlimScrollPlugin(),
|
||||
this.initRangeSlider(),
|
||||
this.initCounterUp(),
|
||||
this.initToast(),
|
||||
this.initAccordionBg(),
|
||||
this.initValidation()
|
||||
},
|
||||
|
||||
$.Components = new Components, $.Components.Constructor = Components
|
||||
|
||||
}(window.jQuery),
|
||||
//initializing main application module
|
||||
function($) {
|
||||
"use strict";
|
||||
$.Components.init();
|
||||
}(window.jQuery);
|
||||
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
+16
@@ -0,0 +1,16 @@
|
||||
/*! Copyright (c) 2011 Piotr Rochala (http://rocha.la)
|
||||
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||
*
|
||||
* Version: 1.3.8
|
||||
*
|
||||
*/
|
||||
(function(e){e.fn.extend({slimScroll:function(f){var a=e.extend({width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:!1,disableFadeOut:!1,railVisible:!1,railColor:"#333",railOpacity:.2,railDraggable:!0,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:!1,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"},f);this.each(function(){function v(d){if(r){d=d||window.event;
|
||||
var c=0;d.wheelDelta&&(c=-d.wheelDelta/120);d.detail&&(c=d.detail/3);e(d.target||d.srcTarget||d.srcElement).closest("."+a.wrapperClass).is(b.parent())&&n(c,!0);d.preventDefault&&!k&&d.preventDefault();k||(d.returnValue=!1)}}function n(d,g,e){k=!1;var f=b.outerHeight()-c.outerHeight();g&&(g=parseInt(c.css("top"))+d*parseInt(a.wheelStep)/100*c.outerHeight(),g=Math.min(Math.max(g,0),f),g=0<d?Math.ceil(g):Math.floor(g),c.css({top:g+"px"}));l=parseInt(c.css("top"))/(b.outerHeight()-c.outerHeight());g=
|
||||
l*(b[0].scrollHeight-b.outerHeight());e&&(g=d,d=g/b[0].scrollHeight*b.outerHeight(),d=Math.min(Math.max(d,0),f),c.css({top:d+"px"}));b.scrollTop(g);b.trigger("slimscrolling",~~g);w();p()}function x(){u=Math.max(b.outerHeight()/b[0].scrollHeight*b.outerHeight(),30);c.css({height:u+"px"});var a=u==b.outerHeight()?"none":"block";c.css({display:a})}function w(){x();clearTimeout(B);l==~~l?(k=a.allowPageScroll,C!=l&&b.trigger("slimscroll",0==~~l?"top":"bottom")):k=!1;C=l;u>=b.outerHeight()?k=!0:(c.stop(!0,
|
||||
!0).fadeIn("fast"),a.railVisible&&m.stop(!0,!0).fadeIn("fast"))}function p(){a.alwaysVisible||(B=setTimeout(function(){a.disableFadeOut&&r||y||z||(c.fadeOut("slow"),m.fadeOut("slow"))},1E3))}var r,y,z,B,A,u,l,C,k=!1,b=e(this);if(b.parent().hasClass(a.wrapperClass)){var q=b.scrollTop(),c=b.siblings("."+a.barClass),m=b.siblings("."+a.railClass);x();if(e.isPlainObject(f)){if("height"in f&&"auto"==f.height){b.parent().css("height","auto");b.css("height","auto");var h=b.parent().parent().height();b.parent().css("height",
|
||||
h);b.css("height",h)}else"height"in f&&(h=f.height,b.parent().css("height",h),b.css("height",h));if("scrollTo"in f)q=parseInt(a.scrollTo);else if("scrollBy"in f)q+=parseInt(a.scrollBy);else if("destroy"in f){c.remove();m.remove();b.unwrap();return}n(q,!1,!0)}}else if(!(e.isPlainObject(f)&&"destroy"in f)){a.height="auto"==a.height?b.parent().height():a.height;q=e("<div></div>").addClass(a.wrapperClass).css({position:"relative",overflow:"hidden",width:a.width,height:a.height});b.css({overflow:"hidden",
|
||||
width:a.width,height:a.height});var m=e("<div></div>").addClass(a.railClass).css({width:a.size,height:"100%",position:"absolute",top:0,display:a.alwaysVisible&&a.railVisible?"block":"none","border-radius":a.railBorderRadius,background:a.railColor,opacity:a.railOpacity,zIndex:90}),c=e("<div></div>").addClass(a.barClass).css({background:a.color,width:a.size,position:"absolute",top:0,opacity:a.opacity,display:a.alwaysVisible?"block":"none","border-radius":a.borderRadius,BorderRadius:a.borderRadius,MozBorderRadius:a.borderRadius,
|
||||
WebkitBorderRadius:a.borderRadius,zIndex:99}),h="right"==a.position?{right:a.distance}:{left:a.distance};m.css(h);c.css(h);b.wrap(q);b.parent().append(c);b.parent().append(m);a.railDraggable&&c.bind("mousedown",function(a){var b=e(document);z=!0;t=parseFloat(c.css("top"));pageY=a.pageY;b.bind("mousemove.slimscroll",function(a){currTop=t+a.pageY-pageY;c.css("top",currTop);n(0,c.position().top,!1)});b.bind("mouseup.slimscroll",function(a){z=!1;p();b.unbind(".slimscroll")});return!1}).bind("selectstart.slimscroll",
|
||||
function(a){a.stopPropagation();a.preventDefault();return!1});m.hover(function(){w()},function(){p()});c.hover(function(){y=!0},function(){y=!1});b.hover(function(){r=!0;w();p()},function(){r=!1;p()});b.bind("touchstart",function(a,b){a.originalEvent.touches.length&&(A=a.originalEvent.touches[0].pageY)});b.bind("touchmove",function(b){k||b.originalEvent.preventDefault();b.originalEvent.touches.length&&(n((A-b.originalEvent.touches[0].pageY)/a.touchScrollStep,!0),A=b.originalEvent.touches[0].pageY)});
|
||||
x();"bottom"===a.start?(c.css({top:b.outerHeight()-c.outerHeight()}),n(0,!0)):"top"!==a.start&&(n(e(a.start).position().top,null,!0),a.alwaysVisible||c.hide());window.addEventListener?(this.addEventListener("DOMMouseScroll",v,!1),this.addEventListener("mousewheel",v,!1)):document.attachEvent("onmousewheel",v)}});return this}});e.fn.extend({slimscroll:e.fn.slimScroll})})(jQuery);
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
* metismenu https://github.com/onokumus/metismenu#readme
|
||||
* A jQuery menu plugin
|
||||
* @version 3.0.4
|
||||
* @author Osman Nuri Okumus <onokumus@gmail.com> (https://github.com/onokumus)
|
||||
* @license: MIT
|
||||
*/
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],n):(e=e||self).metisMenu=n(e.jQuery)}(this,function(o){"use strict";function s(){return(s=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}var a=function(i){var n="transitionend",r={TRANSITION_END:"mmTransitionEnd",triggerTransitionEnd:function(e){i(e).trigger(n)},supportsTransitionEnd:function(){return Boolean(n)}};function e(e){var n=this,t=!1;return i(this).one(r.TRANSITION_END,function(){t=!0}),setTimeout(function(){t||r.triggerTransitionEnd(n)},e),this}return i.fn.mmEmulateTransitionEnd=e,i.event.special[r.TRANSITION_END]={bindType:n,delegateType:n,handle:function(e){if(i(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}},r}(o=o&&o.hasOwnProperty("default")?o.default:o),e="metisMenu",g="metisMenu",n="."+g,t=o.fn[e],h={toggle:!0,preventDefault:!0,triggerElement:"a",parentTrigger:"li",subMenu:"ul"},l={SHOW:"show"+n,SHOWN:"shown"+n,HIDE:"hide"+n,HIDDEN:"hidden"+n,CLICK_DATA_API:"click"+n+".data-api"},i="metismenu",f="mm-active",u="mm-show",d="mm-collapse",c="mm-collapsing",r=function(){function r(e,n){this.element=e,this.config=s({},h,n),this.transitioning=null,this.init()}var e=r.prototype;return e.init=function(){var s=this,a=this.config,e=o(this.element);e.addClass(i),e.find(a.parentTrigger+"."+f).children(a.triggerElement).attr("aria-expanded","true"),e.find(a.parentTrigger+"."+f).parents(a.parentTrigger).addClass(f),e.find(a.parentTrigger+"."+f).parents(a.parentTrigger).children(a.triggerElement).attr("aria-expanded","true"),e.find(a.parentTrigger+"."+f).has(a.subMenu).children(a.subMenu).addClass(d+" "+u),e.find(a.parentTrigger).not("."+f).has(a.subMenu).children(a.subMenu).addClass(d),e.find(a.parentTrigger).children(a.triggerElement).on(l.CLICK_DATA_API,function(e){var n=o(this);if("true"!==n.attr("aria-disabled")){a.preventDefault&&"#"===n.attr("href")&&e.preventDefault();var t=n.parent(a.parentTrigger),i=t.siblings(a.parentTrigger),r=i.children(a.triggerElement);t.hasClass(f)?(n.attr("aria-expanded","false"),s.removeActive(t)):(n.attr("aria-expanded","true"),s.setActive(t),a.toggle&&(s.removeActive(i),r.attr("aria-expanded","false"))),a.onTransitionStart&&a.onTransitionStart(e)}})},e.setActive=function(e){o(e).addClass(f);var n=o(e).children(this.config.subMenu);0<n.length&&!n.hasClass(u)&&this.show(n)},e.removeActive=function(e){o(e).removeClass(f);var n=o(e).children(this.config.subMenu+"."+u);0<n.length&&this.hide(n)},e.show=function(e){var n=this;if(!this.transitioning&&!o(e).hasClass(c)){var t=o(e),i=o.Event(l.SHOW);if(t.trigger(i),!i.isDefaultPrevented()){if(t.parent(this.config.parentTrigger).addClass(f),this.config.toggle){var r=t.parent(this.config.parentTrigger).siblings().children(this.config.subMenu+"."+u);this.hide(r)}t.removeClass(d).addClass(c).height(0),this.setTransitioning(!0);t.height(e[0].scrollHeight).one(a.TRANSITION_END,function(){n.config&&n.element&&(t.removeClass(c).addClass(d+" "+u).height(""),n.setTransitioning(!1),t.trigger(l.SHOWN))}).mmEmulateTransitionEnd(350)}}},e.hide=function(e){var n=this;if(!this.transitioning&&o(e).hasClass(u)){var t=o(e),i=o.Event(l.HIDE);if(t.trigger(i),!i.isDefaultPrevented()){t.parent(this.config.parentTrigger).removeClass(f),t.height(t.height())[0].offsetHeight,t.addClass(c).removeClass(d).removeClass(u),this.setTransitioning(!0);var r=function(){n.config&&n.element&&(n.transitioning&&n.config.onTransitionEnd&&n.config.onTransitionEnd(),n.setTransitioning(!1),t.trigger(l.HIDDEN),t.removeClass(c).addClass(d))};0===t.height()||"none"===t.css("display")?r():t.height(0).one(a.TRANSITION_END,r).mmEmulateTransitionEnd(350)}}},e.setTransitioning=function(e){this.transitioning=e},e.dispose=function(){o.removeData(this.element,g),o(this.element).find(this.config.parentTrigger).has(this.config.subMenu).children(this.config.triggerElement).off("click"),this.transitioning=null,this.config=null,this.element=null},r.jQueryInterface=function(i){return this.each(function(){var e=o(this),n=e.data(g),t=s({},h,e.data(),"object"==typeof i&&i?i:{});if(n||(n=new r(this,t),e.data(g,n)),"string"==typeof i){if(void 0===n[i])throw new Error('No method named "'+i+'"');n[i]()}})},r}();return o.fn[e]=r.jQueryInterface,o.fn[e].Constructor=r,o.fn[e].noConflict=function(){return o.fn[e]=t,r.jQueryInterface},r});
|
||||
//# sourceMappingURL=metisMenu.min.js.map
|
||||
Vendored
+7
File diff suppressed because one or more lines are too long
Vendored
+5
File diff suppressed because one or more lines are too long
Vendored
+10
File diff suppressed because one or more lines are too long
Vendored
+1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,600 @@
|
||||
/*!
|
||||
* Waves v0.7.6
|
||||
* http://fian.my.id/Waves
|
||||
*
|
||||
* Copyright 2014-2018 Alfiana E. Sibuea and other contributors
|
||||
* Released under the MIT license
|
||||
* https://github.com/fians/Waves/blob/master/LICENSE
|
||||
*/
|
||||
|
||||
;(function(window, factory) {
|
||||
'use strict';
|
||||
|
||||
// AMD. Register as an anonymous module. Wrap in function so we have access
|
||||
// to root via `this`.
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], function() {
|
||||
window.Waves = factory.call(window);
|
||||
return window.Waves;
|
||||
});
|
||||
}
|
||||
|
||||
// Node. Does not work with strict CommonJS, but only CommonJS-like
|
||||
// environments that support module.exports, like Node.
|
||||
else if (typeof exports === 'object') {
|
||||
module.exports = factory.call(window);
|
||||
}
|
||||
|
||||
// Browser globals.
|
||||
else {
|
||||
window.Waves = factory.call(window);
|
||||
}
|
||||
})(typeof global === 'object' ? global : this, function() {
|
||||
'use strict';
|
||||
|
||||
var Waves = Waves || {};
|
||||
var $$ = document.querySelectorAll.bind(document);
|
||||
var toString = Object.prototype.toString;
|
||||
var isTouchAvailable = 'ontouchstart' in window;
|
||||
|
||||
|
||||
// Find exact position of element
|
||||
function isWindow(obj) {
|
||||
return obj !== null && obj === obj.window;
|
||||
}
|
||||
|
||||
function getWindow(elem) {
|
||||
return isWindow(elem) ? elem : elem.nodeType === 9 && elem.defaultView;
|
||||
}
|
||||
|
||||
function isObject(value) {
|
||||
var type = typeof value;
|
||||
return type === 'function' || type === 'object' && !!value;
|
||||
}
|
||||
|
||||
function isDOMNode(obj) {
|
||||
return isObject(obj) && obj.nodeType > 0;
|
||||
}
|
||||
|
||||
function getWavesElements(nodes) {
|
||||
var stringRepr = toString.call(nodes);
|
||||
|
||||
if (stringRepr === '[object String]') {
|
||||
return $$(nodes);
|
||||
} else if (isObject(nodes) && /^\[object (Array|HTMLCollection|NodeList|Object)\]$/.test(stringRepr) && nodes.hasOwnProperty('length')) {
|
||||
return nodes;
|
||||
} else if (isDOMNode(nodes)) {
|
||||
return [nodes];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
function offset(elem) {
|
||||
var docElem, win,
|
||||
box = { top: 0, left: 0 },
|
||||
doc = elem && elem.ownerDocument;
|
||||
|
||||
docElem = doc.documentElement;
|
||||
|
||||
if (typeof elem.getBoundingClientRect !== typeof undefined) {
|
||||
box = elem.getBoundingClientRect();
|
||||
}
|
||||
win = getWindow(doc);
|
||||
return {
|
||||
top: box.top + win.pageYOffset - docElem.clientTop,
|
||||
left: box.left + win.pageXOffset - docElem.clientLeft
|
||||
};
|
||||
}
|
||||
|
||||
function convertStyle(styleObj) {
|
||||
var style = '';
|
||||
|
||||
for (var prop in styleObj) {
|
||||
if (styleObj.hasOwnProperty(prop)) {
|
||||
style += (prop + ':' + styleObj[prop] + ';');
|
||||
}
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var Effect = {
|
||||
|
||||
// Effect duration
|
||||
duration: 750,
|
||||
|
||||
// Effect delay (check for scroll before showing effect)
|
||||
delay: 200,
|
||||
|
||||
show: function(e, element, velocity) {
|
||||
|
||||
// Disable right click
|
||||
if (e.button === 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
element = element || this;
|
||||
|
||||
// Create ripple
|
||||
var ripple = document.createElement('div');
|
||||
ripple.className = 'waves-ripple waves-rippling';
|
||||
element.appendChild(ripple);
|
||||
|
||||
// Get click coordinate and element width
|
||||
var pos = offset(element);
|
||||
var relativeY = 0;
|
||||
var relativeX = 0;
|
||||
// Support for touch devices
|
||||
if('touches' in e && e.touches.length) {
|
||||
relativeY = (e.touches[0].pageY - pos.top);
|
||||
relativeX = (e.touches[0].pageX - pos.left);
|
||||
}
|
||||
//Normal case
|
||||
else {
|
||||
relativeY = (e.pageY - pos.top);
|
||||
relativeX = (e.pageX - pos.left);
|
||||
}
|
||||
// Support for synthetic events
|
||||
relativeX = relativeX >= 0 ? relativeX : 0;
|
||||
relativeY = relativeY >= 0 ? relativeY : 0;
|
||||
|
||||
var scale = 'scale(' + ((element.clientWidth / 100) * 3) + ')';
|
||||
var translate = 'translate(0,0)';
|
||||
|
||||
if (velocity) {
|
||||
translate = 'translate(' + (velocity.x) + 'px, ' + (velocity.y) + 'px)';
|
||||
}
|
||||
|
||||
// Attach data to element
|
||||
ripple.setAttribute('data-hold', Date.now());
|
||||
ripple.setAttribute('data-x', relativeX);
|
||||
ripple.setAttribute('data-y', relativeY);
|
||||
ripple.setAttribute('data-scale', scale);
|
||||
ripple.setAttribute('data-translate', translate);
|
||||
|
||||
// Set ripple position
|
||||
var rippleStyle = {
|
||||
top: relativeY + 'px',
|
||||
left: relativeX + 'px'
|
||||
};
|
||||
|
||||
ripple.classList.add('waves-notransition');
|
||||
ripple.setAttribute('style', convertStyle(rippleStyle));
|
||||
ripple.classList.remove('waves-notransition');
|
||||
|
||||
// Scale the ripple
|
||||
rippleStyle['-webkit-transform'] = scale + ' ' + translate;
|
||||
rippleStyle['-moz-transform'] = scale + ' ' + translate;
|
||||
rippleStyle['-ms-transform'] = scale + ' ' + translate;
|
||||
rippleStyle['-o-transform'] = scale + ' ' + translate;
|
||||
rippleStyle.transform = scale + ' ' + translate;
|
||||
rippleStyle.opacity = '1';
|
||||
|
||||
var duration = e.type === 'mousemove' ? 2500 : Effect.duration;
|
||||
rippleStyle['-webkit-transition-duration'] = duration + 'ms';
|
||||
rippleStyle['-moz-transition-duration'] = duration + 'ms';
|
||||
rippleStyle['-o-transition-duration'] = duration + 'ms';
|
||||
rippleStyle['transition-duration'] = duration + 'ms';
|
||||
|
||||
ripple.setAttribute('style', convertStyle(rippleStyle));
|
||||
},
|
||||
|
||||
hide: function(e, element) {
|
||||
element = element || this;
|
||||
|
||||
var ripples = element.getElementsByClassName('waves-rippling');
|
||||
|
||||
for (var i = 0, len = ripples.length; i < len; i++) {
|
||||
removeRipple(e, element, ripples[i]);
|
||||
}
|
||||
|
||||
if (isTouchAvailable) {
|
||||
element.removeEventListener('touchend', Effect.hide);
|
||||
element.removeEventListener('touchcancel', Effect.hide);
|
||||
}
|
||||
|
||||
element.removeEventListener('mouseup', Effect.hide);
|
||||
element.removeEventListener('mouseleave', Effect.hide);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Collection of wrapper for HTML element that only have single tag
|
||||
* like <input> and <img>
|
||||
*/
|
||||
var TagWrapper = {
|
||||
|
||||
// Wrap <input> tag so it can perform the effect
|
||||
input: function(element) {
|
||||
|
||||
var parent = element.parentNode;
|
||||
|
||||
// If input already have parent just pass through
|
||||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Put element class and style to the specified parent
|
||||
var wrapper = document.createElement('i');
|
||||
wrapper.className = element.className + ' waves-input-wrapper';
|
||||
element.className = 'waves-button-input';
|
||||
|
||||
// Put element as child
|
||||
parent.replaceChild(wrapper, element);
|
||||
wrapper.appendChild(element);
|
||||
|
||||
// Apply element color and background color to wrapper
|
||||
var elementStyle = window.getComputedStyle(element, null);
|
||||
var color = elementStyle.color;
|
||||
var backgroundColor = elementStyle.backgroundColor;
|
||||
|
||||
wrapper.setAttribute('style', 'color:' + color + ';background:' + backgroundColor);
|
||||
element.setAttribute('style', 'background-color:rgba(0,0,0,0);');
|
||||
|
||||
},
|
||||
|
||||
// Wrap <img> tag so it can perform the effect
|
||||
img: function(element) {
|
||||
|
||||
var parent = element.parentNode;
|
||||
|
||||
// If input already have parent just pass through
|
||||
if (parent.tagName.toLowerCase() === 'i' && parent.classList.contains('waves-effect')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Put element as child
|
||||
var wrapper = document.createElement('i');
|
||||
parent.replaceChild(wrapper, element);
|
||||
wrapper.appendChild(element);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide the effect and remove the ripple. Must be
|
||||
* a separate function to pass the JSLint...
|
||||
*/
|
||||
function removeRipple(e, el, ripple) {
|
||||
|
||||
// Check if the ripple still exist
|
||||
if (!ripple) {
|
||||
return;
|
||||
}
|
||||
|
||||
ripple.classList.remove('waves-rippling');
|
||||
|
||||
var relativeX = ripple.getAttribute('data-x');
|
||||
var relativeY = ripple.getAttribute('data-y');
|
||||
var scale = ripple.getAttribute('data-scale');
|
||||
var translate = ripple.getAttribute('data-translate');
|
||||
|
||||
// Get delay beetween mousedown and mouse leave
|
||||
var diff = Date.now() - Number(ripple.getAttribute('data-hold'));
|
||||
var delay = 350 - diff;
|
||||
|
||||
if (delay < 0) {
|
||||
delay = 0;
|
||||
}
|
||||
|
||||
if (e.type === 'mousemove') {
|
||||
delay = 150;
|
||||
}
|
||||
|
||||
// Fade out ripple after delay
|
||||
var duration = e.type === 'mousemove' ? 2500 : Effect.duration;
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
var style = {
|
||||
top: relativeY + 'px',
|
||||
left: relativeX + 'px',
|
||||
opacity: '0',
|
||||
|
||||
// Duration
|
||||
'-webkit-transition-duration': duration + 'ms',
|
||||
'-moz-transition-duration': duration + 'ms',
|
||||
'-o-transition-duration': duration + 'ms',
|
||||
'transition-duration': duration + 'ms',
|
||||
'-webkit-transform': scale + ' ' + translate,
|
||||
'-moz-transform': scale + ' ' + translate,
|
||||
'-ms-transform': scale + ' ' + translate,
|
||||
'-o-transform': scale + ' ' + translate,
|
||||
'transform': scale + ' ' + translate
|
||||
};
|
||||
|
||||
ripple.setAttribute('style', convertStyle(style));
|
||||
|
||||
setTimeout(function() {
|
||||
try {
|
||||
el.removeChild(ripple);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}, duration);
|
||||
|
||||
}, delay);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Disable mousedown event for 500ms during and after touch
|
||||
*/
|
||||
var TouchHandler = {
|
||||
|
||||
/* uses an integer rather than bool so there's no issues with
|
||||
* needing to clear timeouts if another touch event occurred
|
||||
* within the 500ms. Cannot mouseup between touchstart and
|
||||
* touchend, nor in the 500ms after touchend. */
|
||||
touches: 0,
|
||||
|
||||
allowEvent: function(e) {
|
||||
|
||||
var allow = true;
|
||||
|
||||
if (/^(mousedown|mousemove)$/.test(e.type) && TouchHandler.touches) {
|
||||
allow = false;
|
||||
}
|
||||
|
||||
return allow;
|
||||
},
|
||||
registerEvent: function(e) {
|
||||
var eType = e.type;
|
||||
|
||||
if (eType === 'touchstart') {
|
||||
|
||||
TouchHandler.touches += 1; // push
|
||||
|
||||
} else if (/^(touchend|touchcancel)$/.test(eType)) {
|
||||
|
||||
setTimeout(function() {
|
||||
if (TouchHandler.touches) {
|
||||
TouchHandler.touches -= 1; // pop after 500ms
|
||||
}
|
||||
}, 500);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Delegated click handler for .waves-effect element.
|
||||
* returns null when .waves-effect element not in "click tree"
|
||||
*/
|
||||
function getWavesEffectElement(e) {
|
||||
|
||||
if (TouchHandler.allowEvent(e) === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var element = null;
|
||||
var target = e.target || e.srcElement;
|
||||
|
||||
while (target.parentElement) {
|
||||
if ( (!(target instanceof SVGElement)) && target.classList.contains('waves-effect')) {
|
||||
element = target;
|
||||
break;
|
||||
}
|
||||
target = target.parentElement;
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bubble the click and show effect if .waves-effect elem was found
|
||||
*/
|
||||
function showEffect(e) {
|
||||
|
||||
// Disable effect if element has "disabled" property on it
|
||||
// In some cases, the event is not triggered by the current element
|
||||
// if (e.target.getAttribute('disabled') !== null) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
var element = getWavesEffectElement(e);
|
||||
|
||||
if (element !== null) {
|
||||
|
||||
// Make it sure the element has either disabled property, disabled attribute or 'disabled' class
|
||||
if (element.disabled || element.getAttribute('disabled') || element.classList.contains('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
TouchHandler.registerEvent(e);
|
||||
|
||||
if (e.type === 'touchstart' && Effect.delay) {
|
||||
|
||||
var hidden = false;
|
||||
|
||||
var timer = setTimeout(function () {
|
||||
timer = null;
|
||||
Effect.show(e, element);
|
||||
}, Effect.delay);
|
||||
|
||||
var hideEffect = function(hideEvent) {
|
||||
|
||||
// if touch hasn't moved, and effect not yet started: start effect now
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
Effect.show(e, element);
|
||||
}
|
||||
if (!hidden) {
|
||||
hidden = true;
|
||||
Effect.hide(hideEvent, element);
|
||||
}
|
||||
|
||||
removeListeners();
|
||||
};
|
||||
|
||||
var touchMove = function(moveEvent) {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
hideEffect(moveEvent);
|
||||
|
||||
removeListeners();
|
||||
};
|
||||
|
||||
element.addEventListener('touchmove', touchMove, false);
|
||||
element.addEventListener('touchend', hideEffect, false);
|
||||
element.addEventListener('touchcancel', hideEffect, false);
|
||||
|
||||
var removeListeners = function() {
|
||||
element.removeEventListener('touchmove', touchMove);
|
||||
element.removeEventListener('touchend', hideEffect);
|
||||
element.removeEventListener('touchcancel', hideEffect);
|
||||
};
|
||||
} else {
|
||||
|
||||
Effect.show(e, element);
|
||||
|
||||
if (isTouchAvailable) {
|
||||
element.addEventListener('touchend', Effect.hide, false);
|
||||
element.addEventListener('touchcancel', Effect.hide, false);
|
||||
}
|
||||
|
||||
element.addEventListener('mouseup', Effect.hide, false);
|
||||
element.addEventListener('mouseleave', Effect.hide, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Waves.init = function(options) {
|
||||
var body = document.body;
|
||||
|
||||
options = options || {};
|
||||
|
||||
if ('duration' in options) {
|
||||
Effect.duration = options.duration;
|
||||
}
|
||||
|
||||
if ('delay' in options) {
|
||||
Effect.delay = options.delay;
|
||||
}
|
||||
|
||||
if (isTouchAvailable) {
|
||||
body.addEventListener('touchstart', showEffect, false);
|
||||
body.addEventListener('touchcancel', TouchHandler.registerEvent, false);
|
||||
body.addEventListener('touchend', TouchHandler.registerEvent, false);
|
||||
}
|
||||
|
||||
body.addEventListener('mousedown', showEffect, false);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Attach Waves to dynamically loaded inputs, or add .waves-effect and other
|
||||
* waves classes to a set of elements. Set drag to true if the ripple mouseover
|
||||
* or skimming effect should be applied to the elements.
|
||||
*/
|
||||
Waves.attach = function(elements, classes) {
|
||||
|
||||
elements = getWavesElements(elements);
|
||||
|
||||
if (toString.call(classes) === '[object Array]') {
|
||||
classes = classes.join(' ');
|
||||
}
|
||||
|
||||
classes = classes ? ' ' + classes : '';
|
||||
|
||||
var element, tagName;
|
||||
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
|
||||
element = elements[i];
|
||||
tagName = element.tagName.toLowerCase();
|
||||
|
||||
if (['input', 'img'].indexOf(tagName) !== -1) {
|
||||
TagWrapper[tagName](element);
|
||||
element = element.parentElement;
|
||||
}
|
||||
|
||||
if (element.className.indexOf('waves-effect') === -1) {
|
||||
element.className += ' waves-effect' + classes;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Cause a ripple to appear in an element via code.
|
||||
*/
|
||||
Waves.ripple = function(elements, options) {
|
||||
elements = getWavesElements(elements);
|
||||
var elementsLen = elements.length;
|
||||
|
||||
options = options || {};
|
||||
options.wait = options.wait || 0;
|
||||
options.position = options.position || null; // default = centre of element
|
||||
|
||||
|
||||
if (elementsLen) {
|
||||
var element, pos, off, centre = {}, i = 0;
|
||||
var mousedown = {
|
||||
type: 'mousedown',
|
||||
button: 1
|
||||
};
|
||||
var hideRipple = function(mouseup, element) {
|
||||
return function() {
|
||||
Effect.hide(mouseup, element);
|
||||
};
|
||||
};
|
||||
|
||||
for (; i < elementsLen; i++) {
|
||||
element = elements[i];
|
||||
pos = options.position || {
|
||||
x: element.clientWidth / 2,
|
||||
y: element.clientHeight / 2
|
||||
};
|
||||
|
||||
off = offset(element);
|
||||
centre.x = off.left + pos.x;
|
||||
centre.y = off.top + pos.y;
|
||||
|
||||
mousedown.pageX = centre.x;
|
||||
mousedown.pageY = centre.y;
|
||||
|
||||
Effect.show(mousedown, element);
|
||||
|
||||
if (options.wait >= 0 && options.wait !== null) {
|
||||
var mouseup = {
|
||||
type: 'mouseup',
|
||||
button: 1
|
||||
};
|
||||
|
||||
setTimeout(hideRipple(mouseup, element), options.wait);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all ripples from an element.
|
||||
*/
|
||||
Waves.calm = function(elements) {
|
||||
elements = getWavesElements(elements);
|
||||
var mouseup = {
|
||||
type: 'mouseup',
|
||||
button: 1
|
||||
};
|
||||
|
||||
for (var i = 0, len = elements.length; i < len; i++) {
|
||||
Effect.hide(mouseup, elements[i]);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Deprecated API fallback
|
||||
*/
|
||||
Waves.displayEffect = function(options) {
|
||||
console.error('Waves.displayEffect() has been deprecated and will be removed in future version. Please use Waves.init() to initialize Waves effect');
|
||||
Waves.init(options);
|
||||
};
|
||||
|
||||
return Waves;
|
||||
});
|
||||
Reference in New Issue
Block a user