gentelella-rtl
Version:
Gentelella RTL Admin is a free to use Bootstrap admin template
1,947 lines (1,641 loc) • 165 kB
JavaScript
/**
* Resize function without multiple trigger
*
* Usage:
* $(window).smartresize(function(){
* // code here
* });
*/
(function ($, sr) {
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced() {
var obj = this, args = arguments;
function delayed() {
if (!execAsap)
func.apply(obj, args);
timeout = null;
}
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100);
};
};
// smartresize
jQuery.fn[sr] = function (fn) {
return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr);
};
})(jQuery, 'smartresize');
/**
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
var CURRENT_URL = window.location.href.split('#')[0].split('?')[0],
$BODY = $('body'),
$MENU_TOGGLE = $('#menu_toggle'),
$SIDEBAR_MENU = $('#sidebar-menu'),
$SIDEBAR_FOOTER = $('.sidebar-footer'),
$LEFT_COL = $('.left_col'),
$RIGHT_COL = $('.right_col'),
$NAV_MENU = $('.nav_menu'),
$FOOTER = $('footer');
// Sidebar
function init_sidebar() {
// TODO: This is some kind of easy fix, maybe we can improve this
var setContentHeight = function () {
// reset height
$RIGHT_COL.css('min-height', $(window).height());
var bodyHeight = $BODY.outerHeight(),
footerHeight = $BODY.hasClass('footer_fixed') ? -10 : $FOOTER.height(),
leftColHeight = $LEFT_COL.eq(1).height() + $SIDEBAR_FOOTER.height(),
contentHeight = bodyHeight < leftColHeight ? leftColHeight : bodyHeight;
// normalize content
contentHeight -= $NAV_MENU.height() + footerHeight;
$RIGHT_COL.css('min-height', contentHeight);
};
$SIDEBAR_MENU.find('a').on('click', function (ev) {
console.log('clicked - sidebar_menu');
var $li = $(this).parent();
if ($li.is('.active')) {
$li.removeClass('active active-sm');
$('ul:first', $li).slideUp(function () {
setContentHeight();
});
} else {
// prevent closing menu if we are on child menu
if (!$li.parent().is('.child_menu')) {
$SIDEBAR_MENU.find('li').removeClass('active active-sm');
$SIDEBAR_MENU.find('li ul').slideUp();
} else {
if ($BODY.is(".nav-sm")) {
$li.parent().find("li").removeClass("active active-sm");
$li.parent().find("li ul").slideUp();
}
}
$li.addClass('active');
$('ul:first', $li).slideDown(function () {
setContentHeight();
});
}
});
// toggle small or large menu
$MENU_TOGGLE.on('click', function () {
console.log('clicked - menu toggle');
if ($BODY.hasClass('nav-md')) {
$SIDEBAR_MENU.find('li.active ul').hide();
$SIDEBAR_MENU.find('li.active').addClass('active-sm').removeClass('active');
} else {
$SIDEBAR_MENU.find('li.active-sm ul').show();
$SIDEBAR_MENU.find('li.active-sm').addClass('active').removeClass('active-sm');
}
$BODY.toggleClass('nav-md nav-sm');
setContentHeight();
});
// check active menu
$SIDEBAR_MENU.find('a[href="' + CURRENT_URL + '"]').parent('li').addClass('current-page');
$SIDEBAR_MENU.find('a').filter(function () {
return this.href == CURRENT_URL;
}).parent('li').addClass('current-page').parents('ul').slideDown(function () {
setContentHeight();
}).parent().addClass('active');
// recompute content when resizing
$(window).smartresize(function () {
setContentHeight();
});
setContentHeight();
// fixed sidebar
if ($.fn.mCustomScrollbar) {
$('.menu_fixed').mCustomScrollbar({
autoHideScrollbar: true,
theme: 'minimal',
mouseWheel: {preventDefault: true}
});
}
};
// /Sidebar
var randNum = function () {
return (Math.floor(Math.random() * (1 + 40 - 20))) + 20;
};
// Panel toolbox
$(document).ready(function () {
$('.collapse-link').on('click', function () {
var $BOX_PANEL = $(this).closest('.x_panel'),
$ICON = $(this).find('i'),
$BOX_CONTENT = $BOX_PANEL.find('.x_content');
// fix for some div with hardcoded fix class
if ($BOX_PANEL.attr('style')) {
$BOX_CONTENT.slideToggle(200, function () {
$BOX_PANEL.removeAttr('style');
});
} else {
$BOX_CONTENT.slideToggle(200);
$BOX_PANEL.css('height', 'auto');
}
$ICON.toggleClass('fa-chevron-up fa-chevron-down');
});
$('.close-link').click(function () {
var $BOX_PANEL = $(this).closest('.x_panel');
$BOX_PANEL.remove();
});
});
// /Panel toolbox
// Tooltip
$(document).ready(function () {
$('[data-toggle="tooltip"]').tooltip({
container: 'body'
});
});
// /Tooltip
// Progressbar
if ($(".progress .progress-bar")[0]) {
$('.progress .progress-bar').progressbar();
}
// /Progressbar
// Switchery
$(document).ready(function () {
if ($(".js-switch")[0]) {
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function (html) {
var switchery = new Switchery(html, {
color: '#26B99A'
});
});
}
});
// /Switchery
// iCheck
$(document).ready(function () {
if ($("input.flat")[0]) {
$(document).ready(function () {
$('input.flat').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass: 'iradio_flat-green'
});
});
}
});
// /iCheck
// Table
$('table input').on('ifChecked', function () {
checkState = '';
$(this).parent().parent().parent().addClass('selected');
countChecked();
});
$('table input').on('ifUnchecked', function () {
checkState = '';
$(this).parent().parent().parent().removeClass('selected');
countChecked();
});
var checkState = '';
$('.bulk_action input').on('ifChecked', function () {
checkState = '';
$(this).parent().parent().parent().addClass('selected');
countChecked();
});
$('.bulk_action input').on('ifUnchecked', function () {
checkState = '';
$(this).parent().parent().parent().removeClass('selected');
countChecked();
});
$('.bulk_action input#check-all').on('ifChecked', function () {
checkState = 'all';
countChecked();
});
$('.bulk_action input#check-all').on('ifUnchecked', function () {
checkState = 'none';
countChecked();
});
function countChecked() {
if (checkState === 'all') {
$(".bulk_action input[name='table_records']").iCheck('check');
}
if (checkState === 'none') {
$(".bulk_action input[name='table_records']").iCheck('uncheck');
}
var checkCount = $(".bulk_action input[name='table_records']:checked").length;
if (checkCount) {
$('.column-title').hide();
$('.bulk-actions').show();
$('.action-cnt').html(checkCount + ' انتخاب شده');
} else {
$('.column-title').show();
$('.bulk-actions').hide();
}
}
// Accordion
$(document).ready(function () {
$(".expand").on("click", function () {
$(this).next().slideToggle(200);
$expand = $(this).find(">:first-child");
if ($expand.text() == "+") {
$expand.text("-");
} else {
$expand.text("+");
}
});
});
// NProgress
if (typeof NProgress != 'undefined') {
$(document).ready(function () {
NProgress.start();
});
$(window).load(function () {
NProgress.done();
});
}
//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;
}
console.log('init_flot_chart');
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) {
console.log('Plot1');
$.plot($("#chart_plot_01"), [arr_data1, arr_data2], chart_plot_01_settings);
}
if ($("#chart_plot_02").length) {
console.log('Plot2');
$.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) {
console.log('Plot3');
$.plot($("#chart_plot_03"), [{
label: "ثبتنامها",
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;
}
console.log('init_starrr');
$(".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() {
//console.log('check init_JQVmap [' + typeof (VectorCanvas) + '][' + typeof (jQuery.fn.vectorMap) + ']' );
if (typeof (jQuery.fn.vectorMap) === 'undefined') {
return;
}
console.log('init_JQVmap');
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 ($('#iran_map').length) {
$('#iran_map').vectorMap({
map: 'iran_ir',
backgroundColor: null,
color: '#ffffff',
hoverOpacity: 0.7,
selectedColor: '#666666',
enableZoom: true,
showTooltip: true,
values: {
"15": "16.63",
"16": "11.58",
"17": "158.97",
"18": "85.81",
"19": "1.1",
"20": "351.02",
"21": "8.83",
"22": "1219.72",
"23": "366.26",
"24": "52.17",
"25": "7.54",
"26": "21.73",
"27": "105.4",
"28": "3.96",
"29": "52.89",
"30": "461.33",
"31": "1.43",
"32": "6.49",
"33": "1.4",
"34": "19.18",
"35": "16.2",
"36": "12.5",
"37": "2023.53",
"38": "11.96",
"39": "44.84",
"40": "8.67",
"41": "1.47",
"42": "11.36",
"43": "21.88",
"44": "1563.66",
"45": "1.57",
"46": "2.11",
},
scaleColors: ['#E6F2F0', '#149B7E'],
normalizeFunction: 'polynomial'
});
}
};
function init_skycons() {
if (typeof (Skycons) === 'undefined') {
return;
}
console.log('init_skycons');
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;
}
console.log('init_chart_doughnut');
if ($('.canvasDoughnut').length) {
var chart_doughnut_settings = {
type: 'doughnut',
tooltipFillColor: "rgba(51, 51, 51, 0.55)",
data: {
labels: [
"سیمبین",
"بلک بری",
"دیگر",
"اندروید",
"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);
});
}
}
function init_gauge() {
if (typeof (Gauge) === 'undefined') {
return;
}
console.log('init_gauge [' + $('.gauge-chart').length + ']');
console.log('init_gauge');
var chart_gauge_settings = {
lines: 12,
angle: 0,
lineWidth: 0.4,
pointer: {
length: 0.75,
strokeWidth: 0.042,
color: '#1D212A'
},
limitMax: 'false',
colorStart: '#1ABC9C',
colorStop: '#1ABC9C',
strokeColor: '#F0F3F3',
generateGradient: true,
maxValue: 80
};
if ($('#chart_gauge_01').length) {
var chart_gauge_01_elem = document.getElementById('chart_gauge_01');
var chart_gauge_01 = new Gauge(chart_gauge_01_elem).setOptions(chart_gauge_settings);
}
if ($('#gauge-text').length) {
chart_gauge_01.maxValue = 6000;
chart_gauge_01.animationSpeed = 32;
chart_gauge_01.set(3200);
chart_gauge_01.setTextField(document.getElementById("gauge-text"));
}
if ($('#chart_gauge_02').length) {
var chart_gauge_02_elem = document.getElementById('chart_gauge_02');
var chart_gauge_02 = new Gauge(chart_gauge_02_elem).setOptions(chart_gauge_settings);
}
if ($('#gauge-text2').length) {
chart_gauge_02.maxValue = 9000;
chart_gauge_02.animationSpeed = 32;
chart_gauge_02.set(2400);
chart_gauge_02.setTextField(document.getElementById("gauge-text2"));
}
}
/* SPARKLINES */
function init_sparklines() {
if (typeof (jQuery.fn.sparkline) === 'undefined') {
return;
}
console.log('init_sparklines');
$(".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: '100%',
height: '125',
lineColor: '#26B99A',
fillColor: 'rgba(223, 223, 223, 0.57)',
lineWidth: 2,
spotColor: '#26B99A',
minSpotColor: '#26B99A'
});
$(".sparkline_four").sparkline([2, 4, 3, 4, 5, 4, 5, 4, 3, 4, 5, 6, 7, 5, 4, 3, 5, 6], {
type: 'line',
height: '40',
width: '200',
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 (autocomplete) === 'undefined') {
return;
}
console.log('init_autocomplete');
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;
}
console.log('init_parsley');
$/*.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;
}
console.log('init_toolbox');
$(".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;
}
console.log('init_wysiwyg');
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 {
console.log("error uploading file", reason, detail);
}
$('<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;
}
console.log('init_cropper');
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) {
console.log(e.type);
},
'built.cropper': function (e) {
console.log(e.type);
},
'cropstart.cropper': function (e) {
console.log(e.type, e.action);
},
'cropmove.cropper': function (e) {
console.log(e.type, e.action);
},
'cropend.cropper': function (e) {
console.log(e.type, e.action);
},
'crop.cropper': function (e) {
console.log(e.type, e.x, e.y, e.width, e.height, e.rotate, e.scaleX, e.scaleY);
},
'zoom.cropper': function (e) {
console.log(e.type, e.ratio);
}
}).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) {
console.log(e.message);
}
}
}
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) {
console.log(e.message);
}
}
}
});
// 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;
}
console.log('init_knob');
$(".knob").knob({
change: function (value) {
//console.log("change : " + value);
},
release: function (value) {
//console.log(this.$.attr('value'));
console.log("release : " + value);
},
cancel: function () {
console.log("cancel : ", this);
},
/*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;
}
console.log('init_InputMask');
$(":input").inputmask();
};
/* COLOR PICKER */
function init_ColorPicker() {
if (typeof ($.fn.colorpicker) === 'undefined') {
return;
}
console.log('init_ColorPicker');
$('.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;
}
console.log('init_IonRangeSlider');
$("#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;
}
console.log('init_daterangepicker');
var cb = function (start, end, label) {
console.log(start.toISOString(), end.toISOString(), label);
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'));
};
var optionSet1 = {
startDate: moment().subtract(29, 'days'),
endDate: moment(),
minDate: '01/01/2012',
maxDate: '12/31/2015',
dateLimit: {
days: 60
},
showDropdowns: true,
showWeekNumbers: true,
timePicker: false,
timePickerIncrement: 1,
timePicker12Hour: true,
ranges: {
'امروز': [moment(), moment()],
'دیروز': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'۷ روز قبل': [moment().subtract(6, 'days'), moment()],
'۳۰ روز قبل': [moment().subtract(29, 'days'), moment()],
'این ماه': [moment().startOf('month'), moment().endOf('month')],
'ماه قبل': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
opens: 'r