369 lines
11 KiB
JavaScript
369 lines
11 KiB
JavaScript
// Nestable
|
|
$('.iq-save-bar').closest('form').find(':input, select, textarea').change(function() {
|
|
showIqSaveBar($(this).closest('form'));
|
|
});
|
|
|
|
$('.iq-save-bar').closest('form').find(':input, select, textarea').keydown(function() {
|
|
showIqSaveBar($(this).closest('form'));
|
|
});
|
|
|
|
|
|
|
|
$(function () {
|
|
// Initialize sidenav togglers
|
|
$('body').on('click', '.layout-sidenav-toggle', function (e) {
|
|
e.preventDefault();
|
|
window.layoutHelpers.toggleCollapsed();
|
|
//custom save to Cookie!
|
|
Cookies.set('layout.sidenav.toggle', window.layoutHelpers.isCollapsed(), { expires:30 });
|
|
});
|
|
if(!Cookies.get('layout.sidenav.toggle') || Cookies.get('layout.sidenav.toggle') === "false"){
|
|
window.layoutHelpers.toggleCollapsed();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
(function($) {
|
|
|
|
$.dragYScroll = function() {
|
|
|
|
var clicked = false,
|
|
viewY, speed;
|
|
|
|
var updateScrollPos = function(e, el) {
|
|
var $el = $(el);
|
|
speed = false;
|
|
if(e.clientY < 20){
|
|
speed = parseInt((e.clientY - 20)/10) -1;
|
|
}
|
|
if((viewY - e.clientY) < 20){
|
|
speed = parseInt((e.clientY - viewY + 20)/10) + 1;
|
|
}
|
|
speed && $el.scrollTop($el.scrollTop() + (speed));
|
|
};
|
|
|
|
$(document).on({
|
|
'mousemove': function(e) {
|
|
clicked && updateScrollPos(e, this);
|
|
},
|
|
'mousedown': function(e) {
|
|
clicked = true;
|
|
viewY = window.innerHeight;
|
|
},
|
|
'mouseup': function() {
|
|
clicked = false;
|
|
}
|
|
});
|
|
}
|
|
}(jQuery));
|
|
|
|
|
|
function showIqSaveBar(form){
|
|
if(!$(form).data('save-bar')){
|
|
$(form).find('.iq-save-bar').show(300);
|
|
$(form).data('save-bar', 1)
|
|
}
|
|
}
|
|
|
|
$(function() {
|
|
if($('#netstable-content-tree').length){
|
|
function updateNetstableOutput(e) {
|
|
|
|
var list = e.length ? e : $(e.target);
|
|
var output = list.data('output');
|
|
|
|
output.val(window.JSON ? window.JSON.stringify(list.nestable('serialize')) :
|
|
'JSON browser support required for this demo.');
|
|
};
|
|
|
|
$('#netstable-content-tree').nestable();
|
|
|
|
$('#netstable-content-tree').nestable().on('change', function(){
|
|
showIqSaveBar($('#netstable-content-tree').closest('form'));
|
|
updateNetstableOutput($('#netstable-content-tree'));
|
|
});
|
|
|
|
// output initial serialised data
|
|
updateNetstableOutput($('#netstable-content-tree').data('output', $('#nestable-output')));
|
|
|
|
$('#nestable-menu-collapse').on('click', function(e) {
|
|
$('.dd').nestable('collapseAll');
|
|
});
|
|
$('#nestable-menu-expand').on('click', function(e) {
|
|
$('.dd').nestable('expandAll');
|
|
});
|
|
}
|
|
});
|
|
|
|
$(function() {
|
|
// Drag handle
|
|
dragula([$('#dragula-drag-handles')[0]], {
|
|
moves: function (el, container, handle) {
|
|
showIqSaveBar(el.closest('form'));
|
|
return handle.classList.contains('handle');
|
|
},
|
|
});
|
|
});
|
|
|
|
$(function () {
|
|
function initModalInner() {
|
|
$('[data-toggle="reloadModal"]').off().on('click', function(event) {
|
|
event.preventDefault();
|
|
button = $(this);
|
|
var data = {};
|
|
data.id = button.data('id');
|
|
data.model = button.data('model');
|
|
data.action = button.data('action');
|
|
data.request = button.data('request');
|
|
data.route = button.data('route');
|
|
data.target = button.data('target');
|
|
console.log(data);
|
|
loadModalInner(this, data);
|
|
});
|
|
|
|
}
|
|
function loadModalInner(self, data){
|
|
|
|
var url = data.route,
|
|
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
$.ajax({
|
|
url: url,
|
|
data: data,
|
|
type: "POST",
|
|
dataType: "json",
|
|
cache: false,
|
|
contentType: contentType,
|
|
encode: true,
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
},
|
|
success: function(data) {
|
|
console.log(data);
|
|
$(data.response.target).find('.modal-dialog').html(data.html);
|
|
$('.selectpicker').selectpicker('refresh');
|
|
initModalInner();
|
|
},
|
|
error: function(xhr, status, errorThrown) {
|
|
console.log(xhr);
|
|
console.log(xhr.responseText);
|
|
console.log(errorThrown);
|
|
console.log("Sorry, there was a problem!");
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#modals-load-content').on('show.bs.modal', function (event) {
|
|
var button = $(event.relatedTarget);
|
|
if (!button.data('id')) {
|
|
return;
|
|
}
|
|
var data = {};
|
|
data.id = button.data('id');
|
|
data.model = button.data('model');
|
|
data.action = button.data('action');
|
|
data.request = button.data('request');
|
|
data.route = button.data('route');
|
|
data.target = button.data('target');
|
|
console.log(data);
|
|
loadModalInner(this, data);
|
|
|
|
});
|
|
});
|
|
|
|
function update_modal_data_show(e, $ele) {
|
|
e.preventDefault();
|
|
|
|
var ele = $ele,
|
|
url = ele.data('url'),
|
|
data = {id:ele.data('data')} ,
|
|
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
|
|
console.log(data);
|
|
console.log(url);
|
|
$.ajax({
|
|
url: url,
|
|
data: data,
|
|
type: "POST",
|
|
dataType: "html",
|
|
cache: false,
|
|
contentType: contentType,
|
|
encode: true,
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
},
|
|
success: function(data) {
|
|
// do what ever you want here. add content to <div> if it was not 1 .
|
|
console.log(data);
|
|
$('#update-modal-content').html(data);
|
|
$('.selectpicker').selectpicker(["refresh"]);
|
|
$('.input-daterange').datepicker({toggleActive: true,format: 'dd.mm.yyyy'});
|
|
// $.Nestable.init();
|
|
$('#updateModalShow').modal('show');
|
|
},
|
|
error: function(xhr, status, errorThrown) {
|
|
console.log(xhr);
|
|
console.log(xhr.responseText);
|
|
console.log(status);
|
|
console.log("Sorry, there was a problem!");
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
function update_modal_data_load(e, $ele) {
|
|
var ele = $ele,
|
|
url = ele.data('url'),
|
|
data = {data:ele.data('data'), target:ele.data('target')} ,
|
|
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
|
|
console.log(data);
|
|
console.log(url);
|
|
$.ajax({
|
|
url: url,
|
|
data: data,
|
|
type: "POST",
|
|
dataType: "json",
|
|
cache: false,
|
|
contentType: contentType,
|
|
encode: true,
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
},
|
|
success: function(data) {
|
|
// do what ever you want here. add content to <div> if it was not 1 .
|
|
$(data.target).find('.modal-content').html(data.response);
|
|
// $('.selectpicker').selectpicker(["refresh"]);
|
|
// $('.input-daterange').datepicker({toggleActive: true,format: 'dd.mm.yyyy'});
|
|
$(data.target).modal('show');
|
|
},
|
|
error: function(xhr, status, errorThrown) {
|
|
console.log(xhr);
|
|
console.log(xhr.responseText);
|
|
console.log(status);
|
|
console.log("Sorry, there was a problem!");
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
function iq_update_data_load(e, $ele) {
|
|
var ele = $ele,
|
|
url = ele.data('url'),
|
|
data = {action:ele.data('action'), target:ele.data('target'), data:ele.data('data')} ,
|
|
contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
|
|
|
|
console.log(data);
|
|
console.log(url);
|
|
$.ajax({
|
|
url: url,
|
|
data: data,
|
|
type: "POST",
|
|
dataType: "json",
|
|
cache: false,
|
|
contentType: contentType,
|
|
encode: true,
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
},
|
|
success: function(response) {
|
|
console.log(response);
|
|
if(response.success === 'tree-node-active'){
|
|
if(response.data === true){
|
|
ele.find('i').addClass('fa-eye').addClass('text-success').removeClass('fa-eye-slash').removeClass('text-danger');
|
|
}
|
|
if(response.data === false){
|
|
ele.find('i').addClass('fa-eye-slash').addClass('text-danger').removeClass('fa-eye').removeClass('text-success');
|
|
}
|
|
$.growl({
|
|
title: "Gespeichert",
|
|
message: "Änderung gespeichert",
|
|
location: 'tr'
|
|
});
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, errorThrown) {
|
|
console.log(xhr);
|
|
console.log(xhr.responseText);
|
|
console.log(status);
|
|
console.log("Sorry, there was a problem!");
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
|
|
jQuery(document).ready(function() {
|
|
$(".update_modal_data_load").on('click', function (e) {
|
|
e.preventDefault();
|
|
update_modal_data_load(e, $(this));
|
|
});
|
|
|
|
$(".iq_update_data_load").on('click', function (e) {
|
|
e.preventDefault();
|
|
iq_update_data_load(e, $(this));
|
|
});
|
|
|
|
$(document).on('show.bs.modal', '.modal', function (event) {
|
|
var zIndex = 2040 + (10 * $('.modal:visible').length);
|
|
$(this).css('z-index', zIndex);
|
|
setTimeout(function() {
|
|
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
|
|
}, 0);
|
|
});
|
|
});
|
|
|
|
jQuery.each(jQuery('textarea.autoExpand'), function() {
|
|
var offset = this.offsetHeight - this.clientHeight;
|
|
var resizeTextarea = function(el) {
|
|
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
|
|
};
|
|
jQuery(this).on('keyup input', function() { resizeTextarea(this); }).removeClass('autoExpand');
|
|
resizeTextarea(this);
|
|
});
|
|
|
|
$(function() {
|
|
|
|
$('.datepicker-range').datepicker({
|
|
calendarWeeks: true,
|
|
orientation: 'auto left',
|
|
format: 'dd.mm.yyyy',
|
|
language: 'de',
|
|
daysOfWeekHighlighted: '0,6',
|
|
clearBtn: true,
|
|
|
|
});
|
|
|
|
|
|
$('.datepicker-base').datepicker({
|
|
calendarWeeks: true,
|
|
todayBtn: 'linked',
|
|
// daysOfWeekDisabled: '1',
|
|
todayHighlight: true,
|
|
multidate: false,
|
|
daysOfWeekHighlighted: '0,6',
|
|
autoclose: true,
|
|
format: 'dd.mm.yyyy',
|
|
language: 'de',
|
|
clearBtn: true,
|
|
|
|
});
|
|
|
|
$('.datepicker-birthday').datepicker({
|
|
todayBtn: 'linked',
|
|
daysOfWeekDisabled: '1',
|
|
multidate: false,
|
|
daysOfWeekHighlighted: '0,6',
|
|
autoclose: true,
|
|
format: 'dd.mm.yyyy',
|
|
language: 'de',
|
|
clearBtn: true,
|
|
startView: 2,
|
|
|
|
});
|
|
});
|