2015-12-17 13:07:40 -05:00
|
|
|
//-- Turn off Dropzone autodetection.
|
|
|
|
//Dropzone.autoDiscover = false;
|
|
|
|
|
2015-05-08 11:55:03 -04:00
|
|
|
//-- Activate anything Mods for HESK needs, such as tooltips.
|
2014-06-07 16:16:39 -04:00
|
|
|
var loadJquery = function()
|
|
|
|
{
|
|
|
|
//-- Activate tooltips
|
2015-02-05 20:39:43 -05:00
|
|
|
$('[data-toggle="tooltip"]').tooltip({
|
|
|
|
container: 'body'
|
|
|
|
});
|
2014-06-28 00:15:32 -04:00
|
|
|
|
2015-01-01 16:08:59 -05:00
|
|
|
//-- Activate popovers
|
2014-06-28 00:15:32 -04:00
|
|
|
$('[data-toggle="popover"]').popover({
|
2014-12-28 23:56:02 -05:00
|
|
|
trigger: 'hover',
|
|
|
|
container: 'body'
|
2014-12-24 01:47:05 -05:00
|
|
|
});
|
|
|
|
|
2015-01-01 16:08:59 -05:00
|
|
|
//-- Activate HTML popovers
|
|
|
|
$('[data-toggle="htmlpopover"]').popover({
|
|
|
|
trigger: 'hover',
|
|
|
|
container: 'body',
|
|
|
|
html: 'true'
|
2015-05-15 01:34:37 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
//-- Activate HTML on-click popovers
|
|
|
|
$('[data-toggle="htmlpopover-onclick"]').popover({
|
|
|
|
container: 'body',
|
|
|
|
html: 'true'
|
2015-01-01 16:08:59 -05:00
|
|
|
});
|
|
|
|
|
2016-01-16 22:32:58 -05:00
|
|
|
//-- Activate Bootstrap Datepicker
|
2014-12-24 01:47:05 -05:00
|
|
|
$(function() {
|
2014-12-27 22:25:20 -05:00
|
|
|
$('.datepicker').datepicker({
|
|
|
|
todayBtn: "linked",
|
|
|
|
clearBtn: true,
|
|
|
|
autoclose: true,
|
2014-12-27 23:57:46 -05:00
|
|
|
todayHighlight: true,
|
|
|
|
format: "yyyy-mm-dd"
|
2014-12-27 22:25:20 -05:00
|
|
|
});
|
2014-12-24 01:47:05 -05:00
|
|
|
});
|
2015-04-30 22:02:03 -04:00
|
|
|
|
|
|
|
$('[data-toggle="iconpicker"]').iconpicker({
|
2015-05-07 22:31:38 -04:00
|
|
|
iconset: ['fontawesome', 'octicon'],
|
2015-05-08 11:55:03 -04:00
|
|
|
selectedClass: "btn-warning",
|
|
|
|
labelNoIcon: $('#no-icon').text(),
|
|
|
|
searchText: $('#search-icon').text(),
|
|
|
|
labelFooter: $('#footer-icon').text()
|
2015-04-30 22:02:03 -04:00
|
|
|
});
|
2016-01-16 22:32:58 -05:00
|
|
|
|
2016-01-17 21:59:47 -05:00
|
|
|
$('.clockpicker').clockpicker();
|
2016-02-15 21:11:50 -05:00
|
|
|
|
|
|
|
// Set the proper text color for background-volatile elements
|
|
|
|
$('.background-volatile').each(function() {
|
|
|
|
$this = $(this);
|
|
|
|
var background = $this.css('background-color');
|
|
|
|
|
2016-03-16 03:16:21 +00:00
|
|
|
if (background !== 'rgba(0, 0, 0, 0)'
|
|
|
|
&& background !== 'transparent') {
|
2016-02-15 21:11:50 -05:00
|
|
|
var grayCount = calculateGrayCount(background);
|
|
|
|
|
|
|
|
if (grayCount > 186) {
|
|
|
|
$this.css('color', '#000');
|
|
|
|
} else {
|
|
|
|
$this.css('color', '#fff');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-04-30 21:17:30 -04:00
|
|
|
|
|
|
|
// Initialize colorpicker
|
2016-05-14 22:15:34 -04:00
|
|
|
$('.colorpicker-trigger').colorpicker({
|
2016-04-30 21:17:30 -04:00
|
|
|
format: 'hex'
|
|
|
|
});
|
2016-05-23 12:47:50 -04:00
|
|
|
|
|
|
|
// Generic select/deselect all. Use this instead of selectAll()/deselctAll()
|
|
|
|
$('[data-select-all]').click(function() {
|
|
|
|
var toggle = $(this).attr('data-select-all');
|
|
|
|
$('[data-select-target="' + toggle + '"]').prop('checked', true)
|
|
|
|
.prop('selected', true)
|
|
|
|
.trigger('change');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('[data-deselect-all]').click(function() {
|
|
|
|
var toggle = $(this).attr('data-deselect-all');
|
|
|
|
$('[data-select-target="' + toggle + '"]').prop('checked', false)
|
|
|
|
.prop('selected', false)
|
|
|
|
.trigger('change');
|
|
|
|
});
|
2016-11-30 12:51:50 -05:00
|
|
|
|
|
|
|
$('.box-header h1.box-title').click(function() {
|
|
|
|
$(this).parent().find('[data-widget="collapse"]').click();
|
|
|
|
});
|
2016-12-31 23:20:19 -05:00
|
|
|
|
|
|
|
$('[data-show]').click(function() {
|
|
|
|
var show = $(this).attr('data-show');
|
|
|
|
$('#' + show).show();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('[data-hide]').click(function() {
|
|
|
|
var hide = $(this).attr('data-hide');
|
|
|
|
$('#' + hide).hide();
|
|
|
|
})
|
2014-06-07 16:16:39 -04:00
|
|
|
};
|
|
|
|
|
2016-02-15 21:11:50 -05:00
|
|
|
function calculateGrayCount(background) {
|
|
|
|
var parts = background.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
|
|
|
var red = parts[1];
|
|
|
|
var green = parts[2];
|
|
|
|
var blue = parts[3];
|
|
|
|
|
|
|
|
return red*0.299 + green*0.587 + blue*0.114;
|
|
|
|
}
|
|
|
|
|
2015-05-08 11:55:03 -04:00
|
|
|
var setIcon = function(icon) {
|
|
|
|
$('[data-toggle="iconpicker"]').iconpicker('setIcon', icon);
|
2016-12-31 23:20:19 -05:00
|
|
|
};
|
2015-05-08 11:55:03 -04:00
|
|
|
|
2016-05-23 12:47:50 -04:00
|
|
|
// Deprecated. Use data-select-all="id" instead
|
2015-01-02 00:52:35 -05:00
|
|
|
function selectAll(id) {
|
|
|
|
$('#' + id + ' option').prop('selected', true);
|
|
|
|
}
|
|
|
|
|
2016-05-23 12:47:50 -04:00
|
|
|
// Deprecated. Use data-deselect-all="id" instead
|
2015-01-02 00:52:35 -05:00
|
|
|
function deselectAll(id) {
|
|
|
|
$('#' + id + ' option').prop('selected', false);
|
|
|
|
}
|
|
|
|
|
2014-06-28 16:11:06 -04:00
|
|
|
function toggleRow(id) {
|
|
|
|
if ($('#' + id).hasClass('danger'))
|
|
|
|
{
|
|
|
|
$('#' + id).removeClass('danger');
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
$('#' + id).addClass('danger');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-27 22:14:49 -04:00
|
|
|
function toggleChildrenForm(show) {
|
|
|
|
if (show) {
|
|
|
|
$('#childrenForm').show();
|
|
|
|
$('#addChildText').hide();
|
|
|
|
} else {
|
|
|
|
$('#childrenForm').hide();
|
|
|
|
$('#addChildText').show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-29 22:05:31 -05:00
|
|
|
function toggleContainers(showIds, hideIds) {
|
|
|
|
showIds.forEach(function (entry) {
|
|
|
|
$('#' + entry).show();
|
|
|
|
});
|
|
|
|
hideIds.forEach(function (entry) {
|
|
|
|
$('#' + entry).hide();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-03-09 00:04:59 -04:00
|
|
|
function disableIfEmpty(sourceId, destinationId) {
|
|
|
|
if ($('#' + sourceId).val().length > 0) {
|
|
|
|
$('#' + destinationId).attr('disabled', false);
|
|
|
|
} else {
|
|
|
|
if ($('#' + destinationId).is(':checkbox')) {
|
|
|
|
$('#' + destinationId).attr('checked', false);
|
|
|
|
}
|
|
|
|
$('#' + destinationId).attr('disabled', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-11 22:25:43 -04:00
|
|
|
function changeText(id, checkedValue, uncheckedValue, object) {
|
|
|
|
if (object.checked) {
|
|
|
|
$('#'+id).text(checkedValue);
|
|
|
|
} else {
|
|
|
|
$('#'+id).text(uncheckedValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-23 22:27:56 -04:00
|
|
|
function requestUserLocation(yourLocationText, unableToDetermineText) {
|
2015-05-19 22:05:50 -04:00
|
|
|
if (navigator.geolocation) {
|
|
|
|
navigator.geolocation.getCurrentPosition(function(position) {
|
2015-05-23 22:27:56 -04:00
|
|
|
var latitude = position.coords.latitude;
|
|
|
|
var longitude = position.coords.longitude;
|
|
|
|
setLatLon(latitude, longitude);
|
|
|
|
$('#console').hide();
|
2015-06-27 16:35:07 -04:00
|
|
|
$('#map').show();
|
2015-05-23 22:27:56 -04:00
|
|
|
initializeMapForCustomer(latitude, longitude, yourLocationText);
|
2015-05-19 22:05:50 -04:00
|
|
|
}, function(error) {
|
2015-05-23 22:27:56 -04:00
|
|
|
$('#console').text(unableToDetermineText).show();
|
2015-05-19 22:05:50 -04:00
|
|
|
switch(error.code) {
|
|
|
|
case error.PERMISSION_DENIED:
|
|
|
|
setLatLon('E-1','E-1');
|
|
|
|
break;
|
|
|
|
case error.POSITION_UNAVAILABLE:
|
|
|
|
setLatLon('E-2','E-2');
|
|
|
|
break;
|
|
|
|
case error.TIMEOUT:
|
|
|
|
setLatLon('E-3','E-3');
|
|
|
|
break;
|
|
|
|
case error.UNKNOWN_ERROR:
|
|
|
|
setLatLon('E-4','E-4');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2015-05-23 23:55:52 -04:00
|
|
|
$('#console').text(unableToDetermineText).show();
|
2015-05-19 22:05:50 -04:00
|
|
|
setLatLon('E-5','E-5');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setLatLon(lat, lon) {
|
|
|
|
$('#latitude').val(lat);
|
|
|
|
$('#longitude').val(lon);
|
|
|
|
}
|
|
|
|
|
2015-05-23 14:53:38 -04:00
|
|
|
var marker;
|
|
|
|
var map;
|
|
|
|
function resetLatLon(lat, lon) {
|
|
|
|
map.setView([lat, lon], 15);
|
|
|
|
marker.setLatLng(L.latLng(lat, lon));
|
|
|
|
}
|
|
|
|
|
2015-05-23 20:34:45 -04:00
|
|
|
function closeAndReset(lat, lon) {
|
|
|
|
$('#save-group').hide();
|
|
|
|
$('#close-button').show();
|
2015-05-23 23:47:10 -04:00
|
|
|
$('#friendly-location').show();
|
|
|
|
$('#save-for-address').hide();
|
2015-05-23 20:34:45 -04:00
|
|
|
resetLatLon(lat, lon);
|
|
|
|
}
|
|
|
|
|
2015-05-23 22:27:56 -04:00
|
|
|
function initializeMapForCustomer(latitude, longitude, yourLocationText) {
|
|
|
|
map = L.map('map').setView([latitude, longitude], 15);
|
2016-04-26 13:14:55 -04:00
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
2015-05-23 22:27:56 -04:00
|
|
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map);
|
|
|
|
marker = L.marker([latitude, longitude], {draggable: true})
|
|
|
|
.addTo(map)
|
|
|
|
.bindPopup(yourLocationText);
|
|
|
|
|
|
|
|
marker.on('dragend', function(event) {
|
|
|
|
setLatLon(event.target.getLatLng().lat, event.target.getLatLng().lng);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-05-23 14:53:38 -04:00
|
|
|
function initializeMapForStaff(latitude, longitude, usersLocationText) {
|
|
|
|
map = L.map('map').setView([latitude, longitude], 15);
|
2016-04-26 13:14:55 -04:00
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
2015-05-23 14:53:38 -04:00
|
|
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
|
|
}).addTo(map);
|
|
|
|
marker = L.marker([latitude, longitude], {draggable: true})
|
|
|
|
.addTo(map)
|
|
|
|
.bindPopup(usersLocationText);
|
|
|
|
|
|
|
|
marker.on('dragend', function(event) {
|
|
|
|
setLatLon(event.target.getLatLng().lat, event.target.getLatLng().lng);
|
|
|
|
$('#save-group').show();
|
|
|
|
$('#close-button').hide();
|
2015-05-23 23:46:10 -04:00
|
|
|
$('#friendly-location').hide();
|
|
|
|
$('#save-for-address').show();
|
2015-05-23 14:53:38 -04:00
|
|
|
});
|
|
|
|
|
2017-04-03 22:21:58 -04:00
|
|
|
$('#more-modal').on('shown.bs.modal', function(){
|
2015-05-23 14:53:38 -04:00
|
|
|
setTimeout(function() {
|
|
|
|
map.invalidateSize();
|
|
|
|
}, 10);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-05-23 23:46:10 -04:00
|
|
|
function getFriendlyLocation(latitude, longitude) {
|
2016-04-26 13:14:55 -04:00
|
|
|
var URL = 'https://nominatim.openstreetmap.org/reverse?format=json&lat='+ latitude +'&lon='+ longitude +'&zoom=15&addressdetails=1';
|
2015-05-23 23:46:10 -04:00
|
|
|
$.getJSON(URL, function(data) {
|
|
|
|
$('#friendly-location').text(data.display_name);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-12-28 12:47:51 -05:00
|
|
|
function outputAttachmentIdHolder(value, id) {
|
|
|
|
$('#attachment-holder-' + id).append('<input type="hidden" name="attachment-ids[]" value="' + value + '">');
|
2015-12-21 13:11:12 -05:00
|
|
|
}
|
|
|
|
|
2015-12-22 22:20:30 -05:00
|
|
|
function removeAttachment(id) {
|
|
|
|
$('input[name="attachment-ids[]"][value="' + id + '"]').remove();
|
|
|
|
$.ajax({
|
|
|
|
url: getHelpdeskUrl() + '/internal-api/ticket/delete-attachment.php?id=' + id,
|
2016-06-06 12:44:35 -04:00
|
|
|
method: 'GET'
|
2015-12-22 22:20:30 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-06-07 16:16:39 -04:00
|
|
|
jQuery(document).ready(loadJquery);
|