gentelella
Version:
Gentelella Admin is a free to use Bootstrap admin template
1,718 lines (1,338 loc) • 135 kB
JavaScript
//hover and retain popover when on popover content
var originalLeave = $.fn.popover.Constructor.prototype.leave;
$.fn.popover.Constructor.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type);
var container, timeout;
originalLeave.call(this, obj);
if (obj.currentTarget) {
container = $(obj.currentTarget).siblings('.popover');
timeout = self.timeout;
container.one('mouseenter', function () {
//We entered the actual popover – call off the dogs
clearTimeout(timeout);
//Let's monitor popover content instead
container.one('mouseleave', function () {
$.fn.popover.Constructor.prototype.leave.call(self, self);
});
});
}
};
$('body').popover({
selector: '[data-popover]',
trigger: 'click hover',
delay: {
show: 50,
hide: 400
}
});
function gd(year, month, day) {
return new Date(year, month - 1, day).getTime();
}
function init_flot_chart() {
if (typeof ($.plot) === 'undefined') { return; }
var randNum = function () {
return (Math.floor(Math.random() * (1 + 40 - 20))) + 20;
};
var arr_data1 = [
[gd(2012, 1, 1), 17],
[gd(2012, 1, 2), 74],
[gd(2012, 1, 3), 6],
[gd(2012, 1, 4), 39],
[gd(2012, 1, 5), 20],
[gd(2012, 1, 6), 85],
[gd(2012, 1, 7), 7]
];
var arr_data2 = [
[gd(2012, 1, 1), 82],
[gd(2012, 1, 2), 23],
[gd(2012, 1, 3), 66],
[gd(2012, 1, 4), 9],
[gd(2012, 1, 5), 119],
[gd(2012, 1, 6), 6],
[gd(2012, 1, 7), 9]
];
var arr_data3 = [
[0, 1],
[1, 9],
[2, 6],
[3, 10],
[4, 5],
[5, 17],
[6, 6],
[7, 10],
[8, 7],
[9, 11],
[10, 35],
[11, 9],
[12, 12],
[13, 5],
[14, 3],
[15, 4],
[16, 9]
];
var chart_plot_02_data = [];
var chart_plot_03_data = [
[0, 1],
[1, 9],
[2, 6],
[3, 10],
[4, 5],
[5, 17],
[6, 6],
[7, 10],
[8, 7],
[9, 11],
[10, 35],
[11, 9],
[12, 12],
[13, 5],
[14, 3],
[15, 4],
[16, 9]
];
for (var i = 0; i < 30; i++) {
chart_plot_02_data.push([new Date(Date.today().add(i).days()).getTime(), randNum() + i + i + 10]);
}
var chart_plot_01_settings = {
series: {
lines: {
show: false,
fill: true
},
splines: {
show: true,
tension: 0.4,
lineWidth: 1,
fill: 0.4
},
points: {
radius: 0,
show: true
},
shadowSize: 2
},
grid: {
verticalLines: true,
hoverable: true,
clickable: true,
tickColor: "#d5d5d5",
borderWidth: 1,
color: '#fff'
},
colors: ["rgba(38, 185, 154, 0.38)", "rgba(3, 88, 106, 0.38)"],
xaxis: {
tickColor: "rgba(51, 51, 51, 0.06)",
mode: "time",
tickSize: [1, "day"],
//tickLength: 10,
axisLabel: "Date",
axisLabelUseCanvas: true,
axisLabelFontSizePixels: 12,
axisLabelFontFamily: 'Verdana, Arial',
axisLabelPadding: 10
},
yaxis: {
ticks: 8,
tickColor: "rgba(51, 51, 51, 0.06)",
},
tooltip: false
}
var chart_plot_02_settings = {
grid: {
show: true,
aboveData: true,
color: "#3f3f3f",
labelMargin: 10,
axisMargin: 0,
borderWidth: 0,
borderColor: null,
minBorderMargin: 5,
clickable: true,
hoverable: true,
autoHighlight: true,
mouseActiveRadius: 100
},
series: {
lines: {
show: true,
fill: true,
lineWidth: 2,
steps: false
},
points: {
show: true,
radius: 4.5,
symbol: "circle",
lineWidth: 3.0
}
},
legend: {
position: "ne",
margin: [0, -25],
noColumns: 0,
labelBoxBorderColor: null,
labelFormatter: function (label, series) {
return label + ' ';
},
width: 40,
height: 1
},
colors: ['#96CA59', '#3F97EB', '#72c380', '#6f7a8a', '#f7cb38', '#5a8022', '#2c7282'],
shadowSize: 0,
tooltip: true,
tooltipOpts: {
content: "%s: %y.0",
xDateFormat: "%d/%m",
shifts: {
x: -30,
y: -50
},
defaultTheme: false
},
yaxis: {
min: 0
},
xaxis: {
mode: "time",
minTickSize: [1, "day"],
timeformat: "%d/%m/%y",
min: chart_plot_02_data[0][0],
max: chart_plot_02_data[20][0]
}
};
var chart_plot_03_settings = {
series: {
curvedLines: {
apply: true,
active: true,
monotonicFit: true
}
},
colors: ["#26B99A"],
grid: {
borderWidth: {
top: 0,
right: 0,
bottom: 1,
left: 1
},
borderColor: {
bottom: "#7F8790",
left: "#7F8790"
}
}
};
if ($("#chart_plot_01").length) {
$.plot($("#chart_plot_01"), [arr_data1, arr_data2], chart_plot_01_settings);
}
if ($("#chart_plot_02").length) {
$.plot($("#chart_plot_02"),
[{
label: "Email Sent",
data: chart_plot_02_data,
lines: {
fillColor: "rgba(150, 202, 89, 0.12)"
},
points: {
fillColor: "#fff"
}
}], chart_plot_02_settings);
}
if ($("#chart_plot_03").length) {
$.plot($("#chart_plot_03"), [{
label: "Registrations",
data: chart_plot_03_data,
lines: {
fillColor: "rgba(150, 202, 89, 0.12)"
},
points: {
fillColor: "#fff"
}
}], chart_plot_03_settings);
};
}
/* STARRR */
function init_starrr() {
if (typeof (starrr) === 'undefined') { return; }
$(".stars").starrr();
$('.stars-existing').starrr({
rating: 4
});
$('.stars').on('starrr:change', function (e, value) {
$('.stars-count').html(value);
});
$('.stars-existing').on('starrr:change', function (e, value) {
$('.stars-count-existing').html(value);
});
};
function init_JQVmap() {
//
if (typeof (jQuery.fn.vectorMap) === 'undefined') { return; }
if ($('#world-map-gdp').length) {
$('#world-map-gdp').vectorMap({
map: 'world_en',
backgroundColor: null,
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#666666',
enableZoom: true,
showTooltip: true,
values: sample_data,
scaleColors: ['#E6F2F0', '#149B7E'],
normalizeFunction: 'polynomial'
});
}
if ($('#usa_map').length) {
$('#usa_map').vectorMap({
map: 'usa_en',
backgroundColor: null,
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#666666',
enableZoom: true,
showTooltip: true,
values: sample_data,
scaleColors: ['#E6F2F0', '#149B7E'],
normalizeFunction: 'polynomial'
});
}
};
function init_skycons() {
if (typeof (Skycons) === 'undefined') { return; }
var icons = new Skycons({
"color": "#73879C"
}),
list = [
"clear-day", "clear-night", "partly-cloudy-day",
"partly-cloudy-night", "cloudy", "rain", "sleet", "snow", "wind",
"fog"
],
i;
for (i = list.length; i--;)
icons.set(list[i], list[i]);
icons.play();
}
function init_chart_doughnut() {
if (typeof (Chart) === 'undefined') { return; }
if ($('.canvasDoughnut').length) {
var chart_doughnut_settings = {
type: 'doughnut',
tooltipFillColor: "rgba(51, 51, 51, 0.55)",
data: {
labels: [
"Symbian",
"Blackberry",
"Other",
"Android",
"IOS"
],
datasets: [{
data: [15, 20, 30, 10, 30],
backgroundColor: [
"#BDC3C7",
"#9B59B6",
"#E74C3C",
"#26B99A",
"#3498DB"
],
hoverBackgroundColor: [
"#CFD4D8",
"#B370CF",
"#E95E4F",
"#36CAAB",
"#49A9EA"
]
}]
},
options: {
legend: false,
responsive: false
}
}
$('.canvasDoughnut').each(function () {
var chart_element = $(this);
var chart_doughnut = new Chart(chart_element, chart_doughnut_settings);
});
}
}
/* SPARKLINES */
function init_sparklines() {
if (typeof (jQuery.fn.sparkline) === 'undefined') { return; }
$(".sparkline_one").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 4, 5, 6, 3, 5, 4, 5, 4, 5, 4, 3, 4, 5, 6, 7, 5, 4, 3, 5, 6], {
type: 'bar',
height: '125',
barWidth: 13,
colorMap: {
'7': '#a1a1a1'
},
barSpacing: 2,
barColor: '#26B99A'
});
$(".sparkline_two").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 7, 5, 4, 3, 5, 6], {
type: 'bar',
height: '40',
barWidth: 9,
colorMap: {
'7': '#a1a1a1'
},
barSpacing: 2,
barColor: '#26B99A'
});
$(".sparkline_three").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 7, 5, 4, 3, 5, 6], {
type: 'line',
width: '200',
height: '40',
lineColor: '#26B99A',
fillColor: 'rgba(223, 223, 223, 0.57)',
lineWidth: 2,
spotColor: '#26B99A',
minSpotColor: '#26B99A'
});
$(".sparkline11").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 6, 2, 4, 3, 4, 5, 4, 5, 4, 3], {
type: 'bar',
height: '40',
barWidth: 8,
colorMap: {
'7': '#a1a1a1'
},
barSpacing: 2,
barColor: '#26B99A'
});
$(".sparkline22").sparkline([2, 4, 3, 4, 7, 5, 4, 3, 5, 6, 2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 6], {
type: 'line',
height: '40',
width: '200',
lineColor: '#26B99A',
fillColor: '#ffffff',
lineWidth: 3,
spotColor: '#34495E',
minSpotColor: '#34495E'
});
$(".sparkline_bar").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 4, 5, 6, 3, 5], {
type: 'bar',
colorMap: {
'7': '#a1a1a1'
},
barColor: '#26B99A'
});
$(".sparkline_area").sparkline([5, 6, 7, 9, 9, 5, 3, 2, 2, 4, 6, 7], {
type: 'line',
lineColor: '#26B99A',
fillColor: '#26B99A',
spotColor: '#4578a0',
minSpotColor: '#728fb2',
maxSpotColor: '#6d93c4',
highlightSpotColor: '#ef5179',
highlightLineColor: '#8ba8bf',
spotRadius: 2.5,
width: 85
});
$(".sparkline_line").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 4, 5, 6, 3, 5], {
type: 'line',
lineColor: '#26B99A',
fillColor: '#ffffff',
width: 85,
spotColor: '#34495E',
minSpotColor: '#34495E'
});
$(".sparkline_pie").sparkline([1, 1, 2, 1], {
type: 'pie',
sliceColors: ['#26B99A', '#ccc', '#75BCDD', '#D66DE2']
});
$(".sparkline_discreet").sparkline([4, 6, 7, 7, 4, 3, 2, 1, 4, 4, 2, 4, 3, 7, 8, 9, 7, 6, 4, 3], {
type: 'discrete',
barWidth: 3,
lineColor: '#26B99A',
width: '85',
});
};
/* AUTOCOMPLETE */
function init_autocomplete() {
if (typeof ($.fn.autocomplete) === 'undefined') { return; }
var countries = { AD: "Andorra", A2: "Andorra Test", AE: "United Arab Emirates", AF: "Afghanistan", AG: "Antigua and Barbuda", AI: "Anguilla", AL: "Albania", AM: "Armenia", AN: "Netherlands Antilles", AO: "Angola", AQ: "Antarctica", AR: "Argentina", AS: "American Samoa", AT: "Austria", AU: "Australia", AW: "Aruba", AX: "Åland Islands", AZ: "Azerbaijan", BA: "Bosnia and Herzegovina", BB: "Barbados", BD: "Bangladesh", BE: "Belgium", BF: "Burkina Faso", BG: "Bulgaria", BH: "Bahrain", BI: "Burundi", BJ: "Benin", BL: "Saint Barthélemy", BM: "Bermuda", BN: "Brunei", BO: "Bolivia", BQ: "British Antarctic Territory", BR: "Brazil", BS: "Bahamas", BT: "Bhutan", BV: "Bouvet Island", BW: "Botswana", BY: "Belarus", BZ: "Belize", CA: "Canada", CC: "Cocos [Keeling] Islands", CD: "Congo - Kinshasa", CF: "Central African Republic", CG: "Congo - Brazzaville", CH: "Switzerland", CI: "Côte d'Ivoire", CK: "Cook Islands", CL: "Chile", CM: "Cameroon", CN: "China", CO: "Colombia", CR: "Costa Rica", CS: "Serbia and Montenegro", CT: "Canton and Enderbury Islands", CU: "Cuba", CV: "Cape Verde", CX: "Christmas Island", CY: "Cyprus", CZ: "Czech Republic", DD: "East Germany", DE: "Germany", DJ: "Djibouti", DK: "Denmark", DM: "Dominica", DO: "Dominican Republic", DZ: "Algeria", EC: "Ecuador", EE: "Estonia", EG: "Egypt", EH: "Western Sahara", ER: "Eritrea", ES: "Spain", ET: "Ethiopia", FI: "Finland", FJ: "Fiji", FK: "Falkland Islands", FM: "Micronesia", FO: "Faroe Islands", FQ: "French Southern and Antarctic Territories", FR: "France", FX: "Metropolitan France", GA: "Gabon", GB: "United Kingdom", GD: "Grenada", GE: "Georgia", GF: "French Guiana", GG: "Guernsey", GH: "Ghana", GI: "Gibraltar", GL: "Greenland", GM: "Gambia", GN: "Guinea", GP: "Guadeloupe", GQ: "Equatorial Guinea", GR: "Greece", GS: "South Georgia and the South Sandwich Islands", GT: "Guatemala", GU: "Guam", GW: "Guinea-Bissau", GY: "Guyana", HK: "Hong Kong SAR China", HM: "Heard Island and McDonald Islands", HN: "Honduras", HR: "Croatia", HT: "Haiti", HU: "Hungary", ID: "Indonesia", IE: "Ireland", IL: "Israel", IM: "Isle of Man", IN: "India", IO: "British Indian Ocean Territory", IQ: "Iraq", IR: "Iran", IS: "Iceland", IT: "Italy", JE: "Jersey", JM: "Jamaica", JO: "Jordan", JP: "Japan", JT: "Johnston Island", KE: "Kenya", KG: "Kyrgyzstan", KH: "Cambodia", KI: "Kiribati", KM: "Comoros", KN: "Saint Kitts and Nevis", KP: "North Korea", KR: "South Korea", KW: "Kuwait", KY: "Cayman Islands", KZ: "Kazakhstan", LA: "Laos", LB: "Lebanon", LC: "Saint Lucia", LI: "Liechtenstein", LK: "Sri Lanka", LR: "Liberia", LS: "Lesotho", LT: "Lithuania", LU: "Luxembourg", LV: "Latvia", LY: "Libya", MA: "Morocco", MC: "Monaco", MD: "Moldova", ME: "Montenegro", MF: "Saint Martin", MG: "Madagascar", MH: "Marshall Islands", MI: "Midway Islands", MK: "Macedonia", ML: "Mali", MM: "Myanmar [Burma]", MN: "Mongolia", MO: "Macau SAR China", MP: "Northern Mariana Islands", MQ: "Martinique", MR: "Mauritania", MS: "Montserrat", MT: "Malta", MU: "Mauritius", MV: "Maldives", MW: "Malawi", MX: "Mexico", MY: "Malaysia", MZ: "Mozambique", NA: "Namibia", NC: "New Caledonia", NE: "Niger", NF: "Norfolk Island", NG: "Nigeria", NI: "Nicaragua", NL: "Netherlands", NO: "Norway", NP: "Nepal", NQ: "Dronning Maud Land", NR: "Nauru", NT: "Neutral Zone", NU: "Niue", NZ: "New Zealand", OM: "Oman", PA: "Panama", PC: "Pacific Islands Trust Territory", PE: "Peru", PF: "French Polynesia", PG: "Papua New Guinea", PH: "Philippines", PK: "Pakistan", PL: "Poland", PM: "Saint Pierre and Miquelon", PN: "Pitcairn Islands", PR: "Puerto Rico", PS: "Palestinian Territories", PT: "Portugal", PU: "U.S. Miscellaneous Pacific Islands", PW: "Palau", PY: "Paraguay", PZ: "Panama Canal Zone", QA: "Qatar", RE: "Réunion", RO: "Romania", RS: "Serbia", RU: "Russia", RW: "Rwanda", SA: "Saudi Arabia", SB: "Solomon Islands", SC: "Seychelles", SD: "Sudan", SE: "Sweden", SG: "Singapore", SH: "Saint Helena", SI: "Slovenia", SJ: "Svalbard and Jan Mayen", SK: "Slovakia", SL: "Sierra Leone", SM: "San Marino", SN: "Senegal", SO: "Somalia", SR: "Suriname", ST: "São Tomé and Príncipe", SU: "Union of Soviet Socialist Republics", SV: "El Salvador", SY: "Syria", SZ: "Swaziland", TC: "Turks and Caicos Islands", TD: "Chad", TF: "French Southern Territories", TG: "Togo", TH: "Thailand", TJ: "Tajikistan", TK: "Tokelau", TL: "Timor-Leste", TM: "Turkmenistan", TN: "Tunisia", TO: "Tonga", TR: "Turkey", TT: "Trinidad and Tobago", TV: "Tuvalu", TW: "Taiwan", TZ: "Tanzania", UA: "Ukraine", UG: "Uganda", UM: "U.S. Minor Outlying Islands", US: "United States", UY: "Uruguay", UZ: "Uzbekistan", VA: "Vatican City", VC: "Saint Vincent and the Grenadines", VD: "North Vietnam", VE: "Venezuela", VG: "British Virgin Islands", VI: "U.S. Virgin Islands", VN: "Vietnam", VU: "Vanuatu", WF: "Wallis and Futuna", WK: "Wake Island", WS: "Samoa", YD: "People's Democratic Republic of Yemen", YE: "Yemen", YT: "Mayotte", ZA: "South Africa", ZM: "Zambia", ZW: "Zimbabwe", ZZ: "Unknown or Invalid Region" };
var countriesArray = $.map(countries, function (value, key) {
return {
value: value,
data: key
};
});
// initialize autocomplete with custom appendTo
$('#autocomplete-custom-append').autocomplete({
lookup: countriesArray
});
};
/* AUTOSIZE */
function init_autosize() {
if (typeof $.fn.autosize !== 'undefined') {
autosize($('.resizable_textarea'));
}
};
/* PARSLEY */
function init_parsley() {
if (typeof (parsley) === 'undefined') { return; }
$/*.listen*/('parsley:field:validate', function () {
validateFront();
});
$('#demo-form .btn').on('click', function () {
$('#demo-form').parsley().validate();
validateFront();
});
var validateFront = function () {
if (true === $('#demo-form').parsley().isValid()) {
$('.bs-callout-info').removeClass('hidden');
$('.bs-callout-warning').addClass('hidden');
} else {
$('.bs-callout-info').addClass('hidden');
$('.bs-callout-warning').removeClass('hidden');
}
};
$/*.listen*/('parsley:field:validate', function () {
validateFront();
});
$('#demo-form2 .btn').on('click', function () {
$('#demo-form2').parsley().validate();
validateFront();
});
var validateFront = function () {
if (true === $('#demo-form2').parsley().isValid()) {
$('.bs-callout-info').removeClass('hidden');
$('.bs-callout-warning').addClass('hidden');
} else {
$('.bs-callout-info').addClass('hidden');
$('.bs-callout-warning').removeClass('hidden');
}
};
try {
hljs.initHighlightingOnLoad();
} catch (err) { }
};
/* INPUTS */
function onAddTag(tag) {
alert("Added a tag: " + tag);
}
function onRemoveTag(tag) {
alert("Removed a tag: " + tag);
}
function onChangeTag(input, tag) {
alert("Changed a tag: " + tag);
}
//tags input
function init_TagsInput() {
if (typeof $.fn.tagsInput !== 'undefined') {
$('#tags_1').tagsInput({
width: 'auto'
});
}
};
/* SELECT2 */
function init_select2() {
if (typeof (select2) === 'undefined') { return; }
$(".select2_single").select2({
placeholder: "Select a state",
allowClear: true
});
$(".select2_group").select2({});
$(".select2_multiple").select2({
maximumSelectionLength: 4,
placeholder: "With Max Selection limit 4",
allowClear: true
});
};
/* WYSIWYG EDITOR */
function init_wysiwyg() {
if (typeof ($.fn.wysiwyg) === 'undefined') { return; }
function init_ToolbarBootstrapBindings() {
var fonts = ['Serif', 'Sans', 'Arial', 'Arial Black', 'Courier',
'Courier New', 'Comic Sans MS', 'Helvetica', 'Impact', 'Lucida Grande', 'Lucida Sans', 'Tahoma', 'Times',
'Times New Roman', 'Verdana'
],
fontTarget = $('[title=Font]').siblings('.dropdown-menu');
$.each(fonts, function (idx, fontName) {
fontTarget.append($('<li><a data-edit="fontName ' + fontName + '" style="font-family:\'' + fontName + '\'">' + fontName + '</a></li>'));
});
$('a[title]').tooltip({
container: 'body'
});
$('.dropdown-menu input').click(function () {
return false;
})
.change(function () {
$(this).parent('.dropdown-menu').siblings('.dropdown-toggle').dropdown('toggle');
})
.keydown('esc', function () {
this.value = '';
$(this).change();
});
$('[data-role=magic-overlay]').each(function () {
var overlay = $(this),
target = $(overlay.data('target'));
overlay.css('opacity', 0).css('position', 'absolute').offset(target.offset()).width(target.outerWidth()).height(target.outerHeight());
});
if ("onwebkitspeechchange" in document.createElement("input")) {
var editorOffset = $('#editor').offset();
$('.voiceBtn').css('position', 'absolute').offset({
top: editorOffset.top,
left: editorOffset.left + $('#editor').innerWidth() - 35
});
} else {
$('.voiceBtn').hide();
}
}
function showErrorAlert(reason, detail) {
var msg = '';
if (reason === 'unsupported-file-type') {
msg = "Unsupported format " + detail;
} else {
}
$('<div class="alert"> <button type="button" class="close" data-dismiss="alert">×</button>' +
'<strong>File upload error</strong> ' + msg + ' </div>').prependTo('#alerts');
}
$('.editor-wrapper').each(function () {
var id = $(this).attr('id'); //editor-one
$(this).wysiwyg({
toolbarSelector: '[data-target="#' + id + '"]',
fileUploadError: showErrorAlert
});
});
window.prettyPrint;
prettyPrint();
};
/* CROPPER */
function init_cropper() {
if (typeof ($.fn.cropper) === 'undefined') { return; }
var $image = $('#image');
var $download = $('#download');
var $dataX = $('#dataX');
var $dataY = $('#dataY');
var $dataHeight = $('#dataHeight');
var $dataWidth = $('#dataWidth');
var $dataRotate = $('#dataRotate');
var $dataScaleX = $('#dataScaleX');
var $dataScaleY = $('#dataScaleY');
var options = {
aspectRatio: 16 / 9,
preview: '.img-preview',
crop: function (e) {
$dataX.val(Math.round(e.x));
$dataY.val(Math.round(e.y));
$dataHeight.val(Math.round(e.height));
$dataWidth.val(Math.round(e.width));
$dataRotate.val(e.rotate);
$dataScaleX.val(e.scaleX);
$dataScaleY.val(e.scaleY);
}
};
// Tooltip
$('[data-toggle="tooltip"]').tooltip();
// Cropper
$image.on({
'build.cropper': function (e) {
},
'built.cropper': function (e) {
},
'cropstart.cropper': function (e) {
},
'cropmove.cropper': function (e) {
},
'cropend.cropper': function (e) {
},
'crop.cropper': function (e) {
},
'zoom.cropper': function (e) {
}
}).cropper(options);
// Buttons
if (!$.isFunction(document.createElement('canvas').getContext)) {
$('button[data-method="getCroppedCanvas"]').prop('disabled', true);
}
if (typeof document.createElement('cropper').style.transition === 'undefined') {
$('button[data-method="rotate"]').prop('disabled', true);
$('button[data-method="scale"]').prop('disabled', true);
}
// Download
if (typeof $download[0].download === 'undefined') {
$download.addClass('disabled');
}
// Options
$('.docs-toggles').on('change', 'input', function () {
var $this = $(this);
var name = $this.attr('name');
var type = $this.prop('type');
var cropBoxData;
var canvasData;
if (!$image.data('cropper')) {
return;
}
if (type === 'checkbox') {
options[name] = $this.prop('checked');
cropBoxData = $image.cropper('getCropBoxData');
canvasData = $image.cropper('getCanvasData');
options.built = function () {
$image.cropper('setCropBoxData', cropBoxData);
$image.cropper('setCanvasData', canvasData);
};
} else if (type === 'radio') {
options[name] = $this.val();
}
$image.cropper('destroy').cropper(options);
});
// Methods
$('.docs-buttons').on('click', '[data-method]', function () {
var $this = $(this);
var data = $this.data();
var $target;
var result;
if ($this.prop('disabled') || $this.hasClass('disabled')) {
return;
}
if ($image.data('cropper') && data.method) {
data = $.extend({}, data); // Clone a new one
if (typeof data.target !== 'undefined') {
$target = $(data.target);
if (typeof data.option === 'undefined') {
try {
data.option = JSON.parse($target.val());
} catch (e) {
}
}
}
result = $image.cropper(data.method, data.option, data.secondOption);
switch (data.method) {
case 'scaleX':
case 'scaleY':
$(this).data('option', -data.option);
break;
case 'getCroppedCanvas':
if (result) {
// Bootstrap's Modal
$('#getCroppedCanvasModal').modal().find('.modal-body').html(result);
if (!$download.hasClass('disabled')) {
$download.attr('href', result.toDataURL());
}
}
break;
}
if ($.isPlainObject(result) && $target) {
try {
$target.val(JSON.stringify(result));
} catch (e) {
}
}
}
});
// Keyboard
$(document.body).on('keydown', function (e) {
if (!$image.data('cropper') || this.scrollTop > 300) {
return;
}
switch (e.which) {
case 37:
e.preventDefault();
$image.cropper('move', -1, 0);
break;
case 38:
e.preventDefault();
$image.cropper('move', 0, -1);
break;
case 39:
e.preventDefault();
$image.cropper('move', 1, 0);
break;
case 40:
e.preventDefault();
$image.cropper('move', 0, 1);
break;
}
});
// Import image
var $inputImage = $('#inputImage');
var URL = window.URL || window.webkitURL;
var blobURL;
if (URL) {
$inputImage.change(function () {
var files = this.files;
var file;
if (!$image.data('cropper')) {
return;
}
if (files && files.length) {
file = files[0];
if (/^image\/\w+$/.test(file.type)) {
blobURL = URL.createObjectURL(file);
$image.one('built.cropper', function () {
// Revoke when load complete
URL.revokeObjectURL(blobURL);
}).cropper('reset').cropper('replace', blobURL);
$inputImage.val('');
} else {
window.alert('Please choose an image file.');
}
}
});
} else {
$inputImage.prop('disabled', true).parent().addClass('disabled');
}
};
/* CROPPER --- end */
/* KNOB */
function init_knob() {
if (typeof ($.fn.knob) === 'undefined') { return; }
$(".knob").knob({
change: function (value) {
//
},
release: function (value) {
//
},
cancel: function () {
},
/*format : function (value) {
return value + '%';
},*/
draw: function () {
// "tron" case
if (this.$.data('skin') == 'tron') {
this.cursorExt = 0.3;
var a = this.arc(this.cv) // Arc
,
pa // Previous arc
, r = 1;
this.g.lineWidth = this.lineWidth;
if (this.o.displayPrevious) {
pa = this.arc(this.v);
this.g.beginPath();
this.g.strokeStyle = this.pColor;
this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, pa.s, pa.e, pa.d);
this.g.stroke();
}
this.g.beginPath();
this.g.strokeStyle = r ? this.o.fgColor : this.fgColor;
this.g.arc(this.xy, this.xy, this.radius - this.lineWidth, a.s, a.e, a.d);
this.g.stroke();
this.g.lineWidth = 2;
this.g.beginPath();
this.g.strokeStyle = this.o.fgColor;
this.g.arc(this.xy, this.xy, this.radius - this.lineWidth + 1 + this.lineWidth * 2 / 3, 0, 2 * Math.PI, false);
this.g.stroke();
return false;
}
}
});
// Example of infinite knob, iPod click wheel
var v, up = 0,
down = 0,
i = 0,
$idir = $("div.idir"),
$ival = $("div.ival"),
incr = function () {
i++;
$idir.show().html("+").fadeOut();
$ival.html(i);
},
decr = function () {
i--;
$idir.show().html("-").fadeOut();
$ival.html(i);
};
$("input.infinite").knob({
min: 0,
max: 20,
stopper: false,
change: function () {
if (v > this.cv) {
if (up) {
decr();
up = 0;
} else {
up = 1;
down = 0;
}
} else {
if (v < this.cv) {
if (down) {
incr();
down = 0;
} else {
down = 1;
up = 0;
}
}
}
v = this.cv;
}
});
};
/* INPUT MASK */
function init_InputMask() {
if (typeof ($.fn.inputmask) === 'undefined') { return; }
$(":input").inputmask();
};
/* COLOR PICKER */
function init_ColorPicker() {
if (typeof ($.fn.colorpicker) === 'undefined') { return; }
$('.demo1').colorpicker();
$('.demo2').colorpicker();
$('#demo_forceformat').colorpicker({
format: 'rgba',
horizontal: true
});
$('#demo_forceformat3').colorpicker({
format: 'rgba',
});
$('.demo-auto').colorpicker();
};
/* ION RANGE SLIDER */
function init_IonRangeSlider() {
if (typeof ($.fn.ionRangeSlider) === 'undefined') { return; }
$("#range_27").ionRangeSlider({
type: "double",
min: 1000000,
max: 2000000,
grid: true,
force_edges: true
});
$("#range").ionRangeSlider({
hide_min_max: true,
keyboard: true,
min: 0,
max: 5000,
from: 1000,
to: 4000,
type: 'double',
step: 1,
prefix: "$",
grid: true
});
$("#range_25").ionRangeSlider({
type: "double",
min: 1000000,
max: 2000000,
grid: true
});
$("#range_26").ionRangeSlider({
type: "double",
min: 0,
max: 10000,
step: 500,
grid: true,
grid_snap: true
});
$("#range_31").ionRangeSlider({
type: "double",
min: 0,
max: 100,
from: 30,
to: 70,
from_fixed: true
});
$(".range_min_max").ionRangeSlider({
type: "double",
min: 0,
max: 100,
from: 30,
to: 70,
max_interval: 50
});
$(".range_time24").ionRangeSlider({
min: +moment().subtract(12, "hours").format("X"),
max: +moment().format("X"),
from: +moment().subtract(6, "hours").format("X"),
grid: true,
force_edges: true,
prettify: function (num) {
var m = moment(num, "X");
return m.format("Do MMMM, HH:mm");
}
});
};
/* DATERANGEPICKER */
function init_daterangepicker() {
if (typeof ($.fn.daterangepicker) === 'undefined') { return; }
var cb = function (start, end, label) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
};
var optionSet1 = {
startDate: dayjs().subtract(29, 'days'),
endDate: dayjs(),
minDate: '01/01/2012',
maxDate: '12/31/2025',
maxSpan: {
days: 60
},
showDropdowns: true,
showWeekNumbers: true,
timePicker: false,
timePickerIncrement: 1,
timePicker12Hour: true,
ranges: {
'Today': [dayjs(), dayjs()],
'Yesterday': [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
'Last 7 Days': [dayjs().subtract(6, 'days'), dayjs()],
'Last 30 Days': [dayjs().subtract(29, 'days'), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
'Last Month': [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')]
},
opens: 'left',
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary',
locale: {
format: 'MM/DD/YYYY',
separator: ' to ',
applyLabel: 'Submit',
cancelLabel: 'Clear',
fromLabel: 'From',
toLabel: 'To',
customRangeLabel: 'Custom',
daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
firstDay: 1
}
};
$('#reportrange span').html(dayjs().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + dayjs().format('MMMM D, YYYY'));
$('#reportrange').daterangepicker(optionSet1, cb);
$('#reportrange').on('show.daterangepicker', function () {
});
$('#reportrange').on('hide.daterangepicker', function () {
});
$('#reportrange').on('apply.daterangepicker', function (ev, picker) {
});
$('#reportrange').on('cancel.daterangepicker', function (ev, picker) {
});
$('#options1').click(function () {
$('#reportrange').data('daterangepicker').setOptions(optionSet1, cb);
});
$('#options2').click(function () {
$('#reportrange').data('daterangepicker').setOptions(optionSet2, cb);
});
$('#destroy').click(function () {
$('#reportrange').data('daterangepicker').remove();
});
}
function init_daterangepicker_right() {
if (typeof ($.fn.daterangepicker) === 'undefined') { return; }
var cb = function (start, end, label) {
$('#reportrange_right span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
};
var optionSet1 = {
startDate: dayjs().subtract(29, 'days'),
endDate: dayjs(),
minDate: '01/01/2012',
maxDate: '12/31/2025',
maxSpan: {
days: 60
},
showDropdowns: true,
showWeekNumbers: true,
timePicker: false,
timePickerIncrement: 1,
timePicker12Hour: true,
ranges: {
'Today': [dayjs(), dayjs()],
'Yesterday': [dayjs().subtract(1, 'days'), dayjs().subtract(1, 'days')],
'Last 7 Days': [dayjs().subtract(6, 'days'), dayjs()],
'Last 30 Days': [dayjs().subtract(29, 'days'), dayjs()],
'This Month': [dayjs().startOf('month'), dayjs().endOf('month')],
'Last Month': [dayjs().subtract(1, 'month').startOf('month'), dayjs().subtract(1, 'month').endOf('month')]
},
opens: 'right',
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary',
locale: {
format: 'MM/DD/YYYY',
separator: ' to ',
applyLabel: 'Submit',
cancelLabel: 'Clear',
fromLabel: 'From',
toLabel: 'To',
customRangeLabel: 'Custom',
daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
firstDay: 1
}
};
$('#reportrange_right span').html(dayjs().subtract(29, 'days').format('MMMM D, YYYY') + ' - ' + dayjs().format('MMMM D, YYYY'));
$('#reportrange_right').daterangepicker(optionSet1, cb);
$('#reportrange_right').on('show.daterangepicker', function () {
});
$('#reportrange_right').on('hide.daterangepicker', function () {
});
$('#reportrange_right').on('apply.daterangepicker', function (ev, picker) {
});
$('#reportrange_right').on('cancel.daterangepicker', function (ev, picker) {
});
$('#options1').click(function () {
$('#reportrange_right').data('daterangepicker').setOptions(optionSet1, cb);
});
$('#options2').click(function () {
$('#reportrange_right').data('daterangepicker').setOptions(optionSet2, cb);
});
$('#destroy').click(function () {
$('#reportrange_right').data('daterangepicker').remove();
});
}
function init_daterangepicker_single_call() {
if (typeof ($.fn.daterangepicker) === 'undefined') { return; }
$('#single_cal1').daterangepicker({
singleDatePicker: true,
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
$('#single_cal2').daterangepicker({
singleDatePicker: true,
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
$('#single_cal3').daterangepicker({
singleDatePicker: true,
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
$('#single_cal4').daterangepicker({
singleDatePicker: true,
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
}
function init_daterangepicker_reservation() {
if (typeof ($.fn.daterangepicker) === 'undefined') { return; }
$('#reservation').daterangepicker({
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
$('#reservation-time').daterangepicker({
timePicker: true,
timePickerIncrement: 30,
locale: {
format: 'MM/DD/YYYY hh:mm A'
},
buttonClasses: 'btn btn-secondary',
applyButtonClasses: 'btn-primary',
cancelButtonClasses: 'btn-secondary'
}, function (start, end, label) {
});
}
/* TEMPUS DOMINUS DATETIMEPICKER */
function init_datetimepicker() {
if (typeof TempusDominus === 'undefined') { return; }
// Initialize basic datepickers
try {
var pickers = document.querySelectorAll('[id^="myDatepicker"]');
pickers.forEach(function(picker) {
new TempusDominus(picker, {
display: {
components: {
clock: false
}
},
localization: {
format: 'MM/dd/yyyy'
}
});
});
} catch (error) {
console.warn('Basic datepicker initialization failed:', error);
}
// Initialize datetime pickers
try {
var datetimePickers = document.querySelectorAll('[id^="datetimepicker"]');
datetimePickers.forEach(function(picker) {
new TempusDominus(picker, {
display: {
components: {
clock: true,
date: true
}
},
localization: {
format: 'MM/dd/yyyy HH:mm'
}
});
});
} catch (error) {
console.warn('DateTime picker initialization failed:', error);
}
// Initialize date-picker class elements
try {
var datePickers = document.querySelectorAll('.date-picker');
datePickers.forEach(function(picker) {
new TempusDominus(picker, {
display: {
components: {
clock: false
}
},
localization: {
format: 'MM/dd/yyyy'
}
});
});
} catch (error) {
console.warn('Date picker class initialization failed:', error);
}
}
/* SMART WIZARD */
function init_SmartWizard() {
if (typeof ($.fn.smartWizard) === 'undefined') { return; }
$('#wizard').smartWizard();
$('#wizard_verticle').smartWizard({
transitionEffect: 'slide'
});
$('.buttonNext').addClass('btn btn-success');
$('.buttonPrevious').addClass('btn btn-primary');
$('.buttonFinish').addClass('btn btn-default');
};
/* VALIDATOR */
function init_validator() {
if (typeof (validator) === 'undefined') { return; }
// initialize the validator function
validator.message.date = 'not a real date';
// validate a field on "blur" event, a 'select' on 'change' event & a '.reuired' classed multifield on 'keyup':
$('form')
.on('blur', 'input[required], input.optional, select.required', validator.checkField)
.on('change', 'select.required', validator.checkField)
.on('keypress', 'input[required][pattern]', validator.keypress);
$('.multi.required').on('keyup blur', 'input', function () {
validator.checkField.apply($(this).siblings().last()[0]);
});
$('form').submit(function (e) {
e.preventDefault();
var submit = true;
// evaluate the form using generic validaing
if (!validator.checkAll($(this))) {
submit = false;
}
if (submit)
this.submit();
return false;
});
};
/* PNotify */
function init_PNotify() {
if (typeof (PNotify) === 'undefined') { return; }
};
/* CUSTOM NOTIFICATION */
function init_CustomNotification() {
if (typeof (CustomTabs) === 'undefined') { return; }
var cnt = 10;
TabbedNotification = function (options) {
var message = "<div id='ntf" + cnt + "' class='text alert-" + options.type + "' style='display:none'><h2><i class='fa fa-bell'></i> " + options.title +
"</h2><div class='close'><a href='javascript:;' class='notification_close'><i class='fa fa-close'></i></a></div><p>" + options.text + "</p></div>";
if (!document.getElementById('custom_notifications')) {
alert('doesnt exists');
} else {
$('#custom_notifications ul.notifications').append("<li><a id='ntlink" + cnt + "' class='alert-" + options.type + "' href='#ntf" + cnt + "'><i class='fa fa-bell animated shake'></i></a></li>");
$('#custom_notifications #notif-group').append(message);
cnt++;
CustomTabs(options);
}
};
CustomTabs = function (options) {
$('.tabbed_notifications > div').hide();
$('.tabbed_notifications > div:first-of-type').show();
$('#custom_notifications').removeClass('dsp_none');
$('.notifications a').click(function (e) {
e.preventDefault();
var $this = $(this),
tabbed_notifications = '#' + $this.parents('.notifications').data('tabbed_notifications'),
others = $this.closest('li').siblings().children('a'),
target = $this.attr('href');
others.removeClass('active');
$this.addClass('active');
$(tabbed_notifications).children('div').hide();
$(target).show();
});
};
CustomTabs();
var tabid = idname = '';
$(document).on('click', '.notification_close', function (e) {
idname = $(this).parent().parent().attr("id");
tabid = idname.substr(-2);
$('#ntf' + tabid).remove();
$('#ntlink' + tabid).parent().remove();
$('.notifications a').first().addClass('active');
$('#notif-group div').first().css('display', 'block');
});
};
/* EASYPIECHART */
function init_EasyPieChart() {
if (typeof ($.fn.easyPieChart) === 'undefined') { return; }
$('.chart').easyPieChart({
easing: 'easeOutElastic',
delay: 3000,
barColor: '#26B99A',
trackColor: '#fff',
scaleColor: false,
lineWidth: 20,
trackWidth: 16,
lineCap: 'butt',
onStep: function (from, to, percent) {
$(this.el).find('.percent').text(Math.round(percent));
}
});
var chart = window.chart = $('.chart').data('easyPieChart');
$('.js_update').on('click', function () {
chart.update(Math.random() * 200 - 100);
});
//hover and retain popover when on popover content
var originalLeave = $.fn.popover.Constructor.prototype.leave;
$.fn.popover.Constructor.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type);
var container, timeout;
originalLeave.call(this, obj);
if (obj.currentTarget) {
container = $(obj.currentTarget).siblings('.popover');
timeout = self.timeout;
container.one('mouseenter', function () {
//We entered the actual popover – call off the dogs
clearTimeout(timeout);
//Let's monitor popover content instead
container.one('mouseleave', function () {
$.fn.popover.Constructor.prototype.leave.call(self, self);
});
});
}
};
$('body').popover({
selector: '[data-popover]',
trigger: 'click hover',
delay: {
show: 50,
hide: 400
}
});
};
function init_charts() {
if (typeof (Chart) === 'undefined') { return; }
Chart.defaults.global.legend = {
enabled: false
};
if ($('#canvas_line').length) {
var canvas_line_00 = new Chart(document.getElementById("canvas_line"), {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: "My First dataset",
backgroundColor: "rgba(38, 185, 154, 0.31)",
borderColor: "rgba(38, 185, 154, 0.7)",
pointBorderColor: "rgba(38, 185, 154, 0.7)",
pointBackgroundColor: "rgba(38, 185, 154, 0.7)",
pointHoverBackgroundColor: "#fff",
pointHoverBorderColor: "rgba(220,220,220,1)",
pointBorderWidth: 1,
data: [31, 74, 6, 39, 20, 85, 7]
}, {