causeway-standard-theme
Version:
1,546 lines (1,321 loc) • 70.7 kB
JavaScript
/*!
*********************************************************************************************
* CausewayStyle v3.1.9-3
* Copyright 1998-2018 Causeway Software Solutions Limited.
* Author: Vijay Sharma
*********************************************************************************************
*/
(function (window, $) {
'use strict';
window.Causeway = {};
// Detect IE8 (we don't support lowers versions)
window.Causeway.isIe8 = false;
window.Causeway.isIe9 = false;
window.Causeway.isIe10 = false;
window.Causeway.isIe11 = false;
var html = $(html);
switch (true) {
case (navigator.appVersion.indexOf('MSIE 8.') !== -1):
window.Causeway.isIe8 = true;
html.addClass(' ie8');
break;
case (navigator.appVersion.indexOf('MSIE 9.') !== -1):
window.Causeway.isIe9 = true;
html.addClass(' ie9');
break;
case (!!navigator.userAgent.match(/MSIE 10/)):
window.Causeway.isIe10 = true;
html.addClass(' ie10');
break;
case (!!navigator.userAgent.match(/Trident.*rv[ :]*11\./)):
window.Causeway.isIe11 = true;
break;
}
window.Causeway.getDevice = function() {
var device = '',
innerWidth = window.innerWidth;
switch (true) {
case (innerWidth <= 480):
device = "mobile";
window.Causeway.isDevice = true;
break;
case (innerWidth > 480 && innerWidth <= 768):
device = "tablet";
window.Causeway.isDevice = true;
break;
case (innerWidth > 768 && innerWidth < 1200):
device = "desktop";
window.Causeway.isDevice = false;
break;
case (innerWidth >= 1200):
device = "lg-desktop";
window.Causeway.isDevice = false;
break;
default:
device = "not found";
}
return device;
};
window.Causeway.isDevice = false;
window.Causeway.getDevice();
}(window, jQuery));
(function (window, document, jQuery) {
'use strict';
jQuery('input, textarea').placeholder({classname: 'placeholder-style'});
/**
* Read-only Fields
*/
var hideCSS = {
visibility: 'hidden',
position: 'absolute',
left: '-9999px'
};
// Email
jQuery('input[type=email][readonly=readonly]').each(function (index, element) {
var $this = jQuery(element),
link = '',
email = $this.val();
if (email && email.match(/^.+@.+\..{2,}$/)) {
link = jQuery('<a>').append(email)
.addClass('form-control')
.addClass('readonly')
.addClass('readonly-email')
.attr('href', 'mailto:' + email);
}
$this.css(hideCSS).before(link);
});
// Url
jQuery('input[type=url][readonly=readonly]').each(function (index, element) {
var $this = jQuery(element),
titleId = $this.attr('id') + '-title',
$titleLabel = jQuery('label[for=\'' + titleId + '\']'),
$title = jQuery('#' + titleId),
$spacer = $this.siblings('.form-control-spacer'),
link = '',
url = $this.val(),
title = $title.val() || url;
if (url && title && url.match(/^.+:\/\/.*\..{2,}$/)) {
link = jQuery('<a>').append(title)
.addClass('form-control')
.addClass('readonly')
.addClass('readonly-url')
.attr('href', url);
}
$title.css(hideCSS);
$titleLabel.hide();
$spacer.hide();
$this.css(hideCSS);
if (link) {
$this.before(link);
}
});
/**
* Select boxes
*/
jQuery(document).on('focus', 'select', function () {
var $this = jQuery(this);
$this.parent('.control-input.select').addClass('active');
});
jQuery(document).on('blur', 'select', function () {
var $this = jQuery(this);
$this.parent('.control-input.select').removeClass('active');
});
var multiSelects = jQuery('select[multiple]');
multiSelects.each(function () {
var $this = jQuery(this);
$this.parent('.control-input.select').addClass('multiple');
});
/**
* Datepickers (http://eternicode.github.io/bootstrap-datepicker)
*/
var focusProxy = function ($element) {
$element.next().click(function (event) {
event.preventDefault();
$element.focus();
});
};
Causeway.datePicker = {};
Causeway.datePicker.init = function() {
var datepickerOptions = {
format: 'dd M yyyy',
orientation: 'right',
todayHighlight: true,
autoclose: true
};
jQuery('.form-group.date:not(.disabled,.readonly)').find('input[type=text]').each(function (index, element) {
var $this = jQuery(element),
$datesDisabled = $this.siblings('input.dates-disabled').first(),
options = datepickerOptions;
options.datesDisabled = $datesDisabled.val();
var parent = $this.parents('.navigation-content-wrapper, .sub-pane-content-wrapper');
var modalParent = $this.parents('.modal-body');
if(parent.length > 0) {
options['container'] = parent[0];
options['orientation'] = 'auto';
}
if(modalParent.length > 0) {
options['container'] = modalParent[0];
options['orientation'] = 'auto';
}
if(window.Causeway.getDevice() !== 'lg-desktop' && window.Causeway.getDevice() !== 'desktop') {
$this.datepicker(options)
.on('show', function () {
$('.datepicker').css({
'width': '100%',
'bottom': '0',
'position': 'fixed',
'left': '0',
'top': 'auto'
});
});
} else {
$this.datepicker(options)
.on('show', function () {
if(parent.length > 0) {
$('.datepicker').css({
'left': '10px',
'right': '20px'
});
}
});
}
focusProxy($this);
});
jQuery('.date-range:not(.disabled,.readonly)').each(function (index, element) {
var $this = jQuery(element),
$start = $this.find('input.date-range-start').first(),
$end = $this.find('input.date-range-end').first(),
$datesDisabled = $this.find('input.dates-disabled').first(),
options = datepickerOptions;
options.datesDisabled = $datesDisabled.val();
options.inputs = [
$start,
$end
];
var parent = $this.parents('.navigation-content-wrapper, .sub-pane-content-wrapper');
var modalParent = $this.parents('.modal-body');
if(parent.length > 0) {
options['container'] = parent[0];
options['orientation'] = 'auto';
}
if(modalParent.length > 0) {
options['container'] = modalParent[0];
options['orientation'] = 'auto';
}
if ($start && $end) {
$this.datepicker(options)
.on('show', function () {
if(parent.length > 0) {
$('.datepicker').css({
'left': '10px',
'right': '20px'
});
}
});
focusProxy($start);
focusProxy($end);
}
});
};
Causeway.datePicker.init();
/**
* Timepickers (https://github.com/jdewit/bootstrap-timepicker)
*/
Causeway.timePicker = {};
Causeway.timePicker.init = function () {
var timepickerOptions = {
showMeridian: false,
orientation: 'right'
};
jQuery('.form-group.time:not(.disabled,.readonly)').find('input[type=text]').each(function (index, element) {
var $this = jQuery(element),
$timesDisabled = $this.siblings('input.times-disabled').first();
timepickerOptions.timesDisabled = $timesDisabled.val();
$this.timepicker(timepickerOptions);
focusProxy($this);
});
};
Causeway.timePicker.init();
/**
* Tooltips
*/
jQuery('.has-tooltip').each(function (index, element) {
var $this = jQuery(element),
$parent = $this.parent(),
$outerParent = $this.parents('.navigation-pane-right, .navigation-pane-left, .container.page'),
$parentOuterRect = $outerParent[0] ? $outerParent[0].getBoundingClientRect() : '',
$thisRect = $this[0].getBoundingClientRect(),
bottomOffset = Math.abs($parentOuterRect.bottom - $thisRect.bottom);
if (bottomOffset < 50) {
$this.tooltip({
animation: false,
container: $parent,
placement: 'top'
});
} else {
$this.tooltip({
animation: false,
container: $parent,
placement: 'bottom'
});
}
$this.on('shown.bs.tooltip', function () {
var $parentOuter = $this.parents('.navigation-pane-right, .navigation-pane-left, .container.page'),
$parentOuterRect = $parentOuter[0] ? $parentOuter[0].getBoundingClientRect() : '',
$thisRect = $this[0].getBoundingClientRect(),
leftOffset = Math.abs($parentOuterRect.left - $thisRect.left),
rightOffset = Math.abs($parentOuterRect.right - $thisRect.right);
if (leftOffset < 150 && rightOffset < 150) {
$parent.find('.tooltip').css({
position: 'absolute'
});
} else if (leftOffset < 130) {
$parent.find('.tooltip').css({
left: $thisRect.left,
top: $thisRect.bottom,
right: 'auto'
});
} else if (rightOffset < 130) {
$parent.find('.tooltip').css({
left: $thisRect.right - $parent.find('.tooltip').width(),
top: $thisRect.bottom
});
}
});
jQuery(window).on('scroll', function () {
$this.tooltip('hide');
});
});
//Destroy Tooltips and enable native tooltip
Causeway.nativeTooltip = function() {
var tooltipEls = jQuery('.has-tooltip');
tooltipEls.tooltip('destroy');
tooltipEls.each(function() {
var title = $(this).attr('data-title');
$(this).attr('title', title);
});
return true;
};
/**
* Files
*/
var fileSelector = '.file-input .file-input-file, .image-input .file-input-image',
textSelector = '.file-input .file-input-text',
removeSelector = '.file-input .file-input-remove',
buttonChooseSelector = '.btn-file-choose',
buttonRemoveSelector = '.btn-file-remove';
function fileChange(el) {
var $this = jQuery(el),
value = $this.val();
$this.siblings(textSelector).val(value);
if (value === '') {
$this.closest('.form-group').removeClass('file-exists');
$this.siblings(removeSelector).val('1');
} else {
$this.closest('.form-group').addClass('file-exists');
$this.siblings(removeSelector).val('0');
}
}
function fileTextClick(el) {
var $this = jQuery(el),
$button;
if (!$this.closest('.form-group').hasClass('disabled')) {
if ($this.val() === '') {
$button = $this.siblings(buttonChooseSelector);
} else {
$button = $this.siblings(buttonRemoveSelector);
}
$button.focus().click();
}
}
jQuery(document).on('click', buttonRemoveSelector, function () {
if (!jQuery(this).closest('.form-group').hasClass('disabled')) {
var $file = jQuery(this).parent().siblings(fileSelector);
if (window.Causeway.isIe11) {
$file.val('');
} else {
$file.wrap('<form>').closest('form').get(0).reset();
$file.unwrap();
}
$file.change();
}
});
jQuery(document).on('focus', textSelector + ', ' + fileSelector, function () {
var $this = jQuery(this),
$button;
if ($this.closest('.form-group').hasClass('file-exists')) {
$button = $this.siblings(buttonRemoveSelector);
} else {
$button = $this.siblings(buttonChooseSelector);
}
$button.focus();
});
jQuery(document).on('change', fileSelector, function (){
fileChange(jQuery(this));
});
//jQuery(document).on('click', textSelector, function () {
// fileTextClick(jQuery(this));
//});
/**
* Checkboxes and radiobuttons
*/
jQuery(document).on('click', '.checkbox > label, .checkbox .checkbox-icon, .checkbox-inline > label, .checkbox-inline .checkbox-icon', function (event) {
updateControl(event, 'checkbox', this);
});
jQuery(document).on('change', '.checkbox input[type="checkbox"], .checkbox-inline input[type="checkbox"]', function (event) {
updateLabel(event, 'checkbox', this);
});
jQuery(document).on('click', '.radio > label, .radio .radio-icon, .radio-inline > label, .radio-inline .radio-icon', function (event) {
updateControl(event, 'radio', this);
});
jQuery(document).on('change', '.radio input[type="radio"], .radio-inline input[type="radio"]', function (event) {
updateLabel(event, 'radio', this);
});
jQuery(document).on('click', '.tristate > label, .tristate .checkbox-icon', function (event) {
updateControl(event, 'tristate', this);
});
jQuery(document).on('change', '.tristate input[type="checkbox"]', function (event) {
updateLabel(event, 'tristate', this);
});
var updateControl = function (event, type, that) {
event.preventDefault();
if (event.target !== that) {
return;
}
var $this = jQuery(that);
var selector = type;
if (type === 'tristate') {
selector = 'checkbox';
}
var $label;
if ($this.hasClass(selector + '-icon')) {
$label = $this.closest('label');
} else {
$label = $this;
}
var $input = $label.prev('input[type=' + selector + ']').first();
// Only make a change when the item being clicked is not disabled
if ($input.prop('disabled') || $input.prop('readonly')) {
return;
}
if (type === 'checkbox') {
updateCheckbox($input, $label);
} else if (type === 'radio') {
updateRadio($input, $label);
} else if (type === 'tristate') {
updateTristate($input, $label);
}
$input.change();
};
function updateCheckbox($input, $label) {
$input.get(0).checked = !$label.hasClass('checked');
}
function updateRadio($input) {
var $linkedLabels = jQuery('input[type="radio"][name="' + $input.prop('name') + '"]').next('label');
$linkedLabels.each(function () {
this.checked = false;
});
$input.get(0).checked = true;
}
function updateTristate($input, $label) {
var value = $input.siblings('.value').val(),
altvalue = $input.siblings('.altvalue').val();
if ($label.hasClass('checked')) {
$input.get(0).checked = false;
} else if ($label.hasClass('altstate')) {
$input.val(value);
$input.get(0).checked = true;
} else {
$input.val(altvalue);
$input.get(0).checked = true;
}
}
var updateLabel = function (event, type, that) {
var $input = jQuery(that);
// Only make a change when the item being clicked is not disabled
if ($input.prop('disabled') || $input.prop('readonly')) {
return;
}
var $label = $input.next('label').first();
if (type === 'checkbox') {
updateCheckboxLabel($label);
} else if (type === 'radio') {
updateRadioLabel($input, $label);
} else if (type === 'tristate') {
updateTristateLabel($input, $label);
}
};
function updateCheckboxLabel($label) {
if ($label.hasClass('checked')) {
$label.removeClass('checked');
} else {
$label.addClass('checked');
}
}
function updateRadioLabel($input, $label) {
var $linkedLabels = jQuery('input[type="radio"][name="' + $input.prop('name') + '"]').next('label');
$linkedLabels.removeClass('checked');
$label.addClass('checked');
}
function updateTristateLabel($input, $label) {
var value = $input.siblings('.value').val(),
altvalue = $input.siblings('.altvalue').val();
if ($label.hasClass('checked')) {
$label.removeClass('altstate');
$label.removeClass('checked');
} else if ($label.hasClass('altstate')) {
$label.removeClass('altstate');
$label.addClass('checked');
} else {
$label.addClass('altstate');
$label.removeClass('checked');
}
}
// Checkbox setup
if (!window.Causeway.isIe8) {
var checkboxLabelSelector = '.checkbox > label, .radio > label, .tristate > label';
jQuery(document).on('mousedown', checkboxLabelSelector, function () {
var $label = jQuery(this).closest('label');
$label.addClass('mousedown');
});
jQuery(document).on('mouseup', function () {
jQuery(checkboxLabelSelector).removeClass('mousedown');
});
}
jQuery('.checkbox input[type="checkbox"]').each(function () {
if (this.checked) {
jQuery(this).next('label').addClass('checked');
}
});
// Radiobutton setup
jQuery('.radio input[type="radio"]').each(function () {
if (this.checked) {
jQuery(this).next('label').addClass('checked');
}
});
// Tristate setup
jQuery('.tristate input[type="checkbox"]').each(function () {
var $input = jQuery(this),
$label = $input.next('label');
if ($input.val() === $input.siblings('.altvalue').val()) {
$label.addClass('altstate');
} else if (this.checked) {
$label.addClass('checked');
}
});
if (window.Causeway.isIe8) {
/**
* Files
*/
jQuery(fileSelector).change(function (){
fileChange(jQuery(this));
});
jQuery(textSelector).click(function () {
fileTextClick(jQuery(this));
});
}
///**
// * Sidebars
// */
//
//if (window.Causeway.isIe8) {
// if (typeof String.prototype.trim !== 'function') {
// String.prototype.trim = function () {
// return this.replace(/^\s+|\s+$/g, '');
// };
// }
//}
//
//var sidebarTrigger = '.sidebar-trigger';
//
//window.Causeway.sidebar = {};
//
//window.Causeway.sidebar.animateSidebar = function (element, direction) {
// var $element = jQuery(element);
//
// if ($element.children().length < 1 && $element.text().trim() === '' && !$element.hasClass('animating') && !$element.hasClass('open')) {
// return $element;
// }
//
// if ($element.hasClass('animating')) {
// return $element;
// }
//
// var leftRight = $element.hasClass('sidebar-left') ? 'left' : 'right',
// property = {},
// sidebarSlideComplete = function () {
// jQuery(this).removeClass('animating');
// };
//
// if (direction) {
// if ((direction === 'open' && $element.hasClass('open')) ||
// (direction === 'close' && $element.hasClass('open') === false)) {
// return $element;
// }
// } else {
// if ($element.hasClass('open')) {
// direction = 'close';
// } else {
// direction = 'open';
// }
// }
//
// if (direction === 'close') {
// property[leftRight] = ($element.outerWidth() * -1) + 'px';
// } else {
// property[leftRight] = 0;
// }
//
// $element.addClass('animating').toggleClass('open').animate(property, {
// duration: 500,
// complete: sidebarSlideComplete
// });
//
// return $element;
//};
//
//window.Causeway.sidebar.toggleSidebar = function () {
// var $this = jQuery(this),
// sidebarSelector = '.sidebar-overlay.' + $this.data('toggle'),
// $elements = jQuery(sidebarSelector);
//
// $elements.each(function (index, element) {
// window.Causeway.sidebar.animateSidebar(element).toggleClass('button-mode');
// });
//};
//
//jQuery(document).on('click', sidebarTrigger, window.Causeway.sidebar.toggleSidebar);
//
//jQuery(document).mousemove(function (event) {
// // These could be set on an object and update when they change but might not save much
// var hitArea = 10, docWidth = jQuery(document).width(),
// $leftSideBar = jQuery('.sidebar-overlay.sidebar-left'),
// $rightSideBar = jQuery('.sidebar-overlay.sidebar-right'),
// leftSideBarWidth = $leftSideBar.outerWidth() + 10, // An arbitrary tolerance
// rightSideBarWidth = $rightSideBar.outerWidth() + 10;
//
// if (docWidth - event.pageX < hitArea) { // Open right-hand side
// if (!window.Causeway.sidebar.timer) {
// window.Causeway.sidebar.timer = setTimeout(function () {
// return window.Causeway.sidebar.animateSidebar($rightSideBar, 'open');
// }, 500);
// }
//
// } else if (event.pageX < hitArea) { // open left-hand side
// if (!window.Causeway.sidebar.timer) {
// window.Causeway.sidebar.timer = setTimeout(function () {
// return window.Causeway.sidebar.animateSidebar($leftSideBar, 'open');
// }, 500);
// }
// } else if (event.pageX > leftSideBarWidth && event.pageX < docWidth - rightSideBarWidth) { // between sidebars so close them
// if (window.Causeway.sidebar.timer) {
// clearTimeout(window.Causeway.sidebar.timer);
// delete(window.Causeway.sidebar.timer);
// }
// if ($leftSideBar.hasClass('button-mode') === false) {
// window.Causeway.sidebar.animateSidebar($leftSideBar, 'close');
// }
// if ($rightSideBar.hasClass('button-mode') === false) {
// window.Causeway.sidebar.animateSidebar($rightSideBar, 'close');
// }
// } else if (event.pageX > hitArea && event.pageX < docWidth - hitArea) {
// if (window.Causeway.sidebar.timer) {
// clearTimeout(window.Causeway.sidebar.timer);
// delete(window.Causeway.sidebar.timer);
// }
// }
//});
/**
* Selectpickers in tables having issue with overflow hidden of its parent table-wrapper
*/
// window.Causeway.selectPickersInTable = {};
// window.Causeway.selectPickersInTable.elements = (function(){
// return jQuery('.btn-group.bootstrap-select', jQuery('table')).filter(':visible');
// }());
// window.Causeway.selectPickersInTable.reposition = function() {
// window.Causeway.selectPickersInTable.elements.each(function(){
// var left = jQuery(this)[0].getBoundingClientRect().left,
// top = jQuery(this)[0].getBoundingClientRect().top,
// width = jQuery(this)[0].getBoundingClientRect().width;
// jQuery('.dropdown-menu.open', jQuery(this)).css({
// 'position': 'fixed',
// 'left': left,
// 'top': jQuery(this).hasClass('dropup') ? 'auto' : top + 26,
// 'bottom': jQuery(this).hasClass('dropup') ? document.documentElement.clientHeight - top : 'auto',
// 'width': width,
// 'min-width': 0
// });
// });
// };
// window.Causeway.selectPickersInTable.reposition();
// jQuery(window).on('resize scroll' , function(){
// window.Causeway.selectPickersInTable.reposition();
// });
/**
* Dividers
*/
window.Causeway.divider = {};
window.Causeway.divider.direction = '';
window.Causeway.divider.element = null;
window.Causeway.divider.prevElement = null;
window.Causeway.divider.nextElement = null;
window.Causeway.divider.init = function (event) {
var $document = jQuery(document);
var $this = jQuery(this);
window.Causeway.divider.element = this;
window.Causeway.divider.prevElement = $this.prev().get(0);
window.Causeway.divider.nextElement = $this.next().get(0);
if ($this.hasClass('divider-vertical')) {
window.Causeway.divider.direction = 'horizontal';
window.Causeway.divider.elementLeft = parseInt($this.css('left'), 10);
window.Causeway.divider.prevWidth = parseInt(jQuery(window.Causeway.divider.prevElement).css('width'), 10);
window.Causeway.divider.nextWidth = parseInt(jQuery(window.Causeway.divider.nextElement).css('width'), 10);
window.Causeway.divider.currentX = event.screenX;
} else if ($this.hasClass('twopane-divider-horizontal')) {
window.Causeway.divider.direction = 'twoPaneVertical';
window.Causeway.divider.elementTop = parseInt(window.Causeway.divider.element.offsetTop, 10);
window.Causeway.divider.prevHeight = parseInt(jQuery(window.Causeway.divider.prevElement).css('height'), 10);
window.Causeway.divider.nextHeight = parseInt(jQuery(window.Causeway.divider.nextElement).css('height'), 10);
window.Causeway.divider.currentY = event.screenY;
} else if ($this.hasClass('divider-horizontal')) {
window.Causeway.divider.direction = 'vertical';
window.Causeway.divider.elementTop = parseInt($this.css('top'), 10);
window.Causeway.divider.prevHeight = parseInt(jQuery(window.Causeway.divider.prevElement).css('height'), 10);
window.Causeway.divider.nextHeight = parseInt(jQuery(window.Causeway.divider.nextElement).css('height'), 10);
window.Causeway.divider.currentY = event.screenY;
} else if ($this.hasClass('divider-navigation')) {
window.Causeway.divider.direction = 'horizontalNavigation';
window.Causeway.divider.elementLeft = parseInt($this.css('left'), 10);
window.Causeway.divider.prevWidth = parseInt(jQuery(window.Causeway.divider.prevElement).css('width'), 10);
window.Causeway.divider.nextWidth = parseInt(jQuery(window.Causeway.divider.nextElement).css('width'), 10);
window.Causeway.divider.currentX = event.screenX;
}
$document.on('mouseup', window.Causeway.divider.destroy);
$document.on('mousemove', window.Causeway.divider.move);
};
window.Causeway.divider.destroy = function () {
var $document = jQuery(document);
window.Causeway.divider.direction = '';
window.Causeway.divider.element = null;
window.Causeway.divider.prevElement = null;
window.Causeway.divider.nextElement = null;
$document.off('mousemove', window.Causeway.divider.move);
$document.off('mouseup', window.Causeway.divider.destroy);
};
window.Causeway.divider.moveHorizontal = function (screenX) {
if (window.Causeway.divider.currentX <= window.Causeway.divider.prevWidth + window.Causeway.divider.nextWidth) {
var offsetX = screenX - window.Causeway.divider.currentX,
threshold = (document.documentElement.clientWidth * 20) / 100;
if (window.Causeway.divider.prevWidth + offsetX >= threshold && window.Causeway.divider.nextWidth - offsetX >= threshold) {
window.Causeway.divider.elementLeft = window.Causeway.divider.elementLeft + offsetX;
window.Causeway.divider.prevWidth = window.Causeway.divider.prevWidth + offsetX;
window.Causeway.divider.nextWidth = window.Causeway.divider.nextWidth - offsetX;
window.Causeway.divider.element.style.left = window.Causeway.divider.prevWidth / (window.Causeway.divider.prevWidth + window.Causeway.divider.nextWidth) * 100 + '%';
window.Causeway.divider.prevElement.style.width = window.Causeway.divider.prevWidth / (window.Causeway.divider.prevWidth + window.Causeway.divider.nextWidth) * 100 + '%';
window.Causeway.divider.nextElement.style.width = window.Causeway.divider.nextWidth / (window.Causeway.divider.prevWidth + window.Causeway.divider.nextWidth) * 100 + '%';
}
}
window.Causeway.divider.currentX = screenX;
};
window.Causeway.divider.moveHorizontalNavigation = function (screenX) {
if (window.Causeway.divider.currentX <= window.Causeway.divider.prevWidth + window.Causeway.divider.nextWidth) {
var offsetX = screenX - window.Causeway.divider.currentX,
leftThreshold = 25,
rightThreshold = (document.documentElement.clientWidth * 65) / 100;
if (window.Causeway.divider.prevWidth + offsetX >= leftThreshold && window.Causeway.divider.nextWidth - offsetX >= rightThreshold) {
window.Causeway.divider.elementLeft = window.Causeway.divider.elementLeft + offsetX;
window.Causeway.divider.prevWidth = window.Causeway.divider.prevWidth + offsetX;
window.Causeway.divider.nextWidth = window.Causeway.divider.nextWidth - offsetX;
window.Causeway.divider.element.style.left = window.Causeway.divider.elementLeft + 'px';
window.Causeway.divider.prevElement.style.width = window.Causeway.divider.prevWidth + 'px';
window.Causeway.divider.nextElement.style.marginLeft = window.Causeway.divider.prevWidth + 'px';
}
}
window.Causeway.divider.currentX = screenX;
};
window.Causeway.divider.moveVertical = function (screenY) {
if (window.Causeway.divider.currentY <= window.Causeway.divider.prevHeight + window.Causeway.divider.nextHeight) {
var offsetY = screenY - window.Causeway.divider.currentY;
if (window.Causeway.divider.prevHeight + offsetY >= 0 && window.Causeway.divider.nextHeight - offsetY >= 0) {
window.Causeway.divider.elementTop = window.Causeway.divider.elementTop + offsetY;
window.Causeway.divider.prevHeight = window.Causeway.divider.prevHeight + offsetY;
window.Causeway.divider.nextHeight = window.Causeway.divider.nextHeight - offsetY;
window.Causeway.divider.element.style.top = window.Causeway.divider.elementTop + 'px';
window.Causeway.divider.prevElement.style.height = window.Causeway.divider.prevHeight + 'px';
window.Causeway.divider.nextElement.style.height = window.Causeway.divider.nextHeight + 'px';
}
}
window.Causeway.divider.currentY = screenY;
};
window.Causeway.divider.moveVerticalTwoPane = function (screenY) {
if (window.Causeway.divider.currentY <= window.Causeway.divider.prevHeight + window.Causeway.divider.nextHeight) {
var offsetY = screenY - window.Causeway.divider.currentY,
panelDraggingLimit = 200;
if (window.Causeway.divider.prevHeight + offsetY >= panelDraggingLimit && window.Causeway.divider.nextHeight - offsetY >= panelDraggingLimit) {
window.Causeway.divider.elementTop = window.Causeway.divider.elementTop + offsetY;
window.Causeway.divider.prevHeight = window.Causeway.divider.prevHeight + offsetY;
window.Causeway.divider.nextHeight = window.Causeway.divider.nextHeight - offsetY;
//window.Causeway.divider.element.style.top = window.Causeway.divider.elementTop + 'px';
window.Causeway.divider.prevElement.style.height = window.Causeway.divider.prevHeight / (window.Causeway.divider.prevHeight + window.Causeway.divider.nextHeight) * 100 + '%';
window.Causeway.divider.nextElement.style.height = window.Causeway.divider.nextHeight / (window.Causeway.divider.prevHeight + window.Causeway.divider.nextHeight) * 100 + '%';
}
}
window.Causeway.divider.currentY = screenY;
};
window.Causeway.divider.move = function (event) {
event.preventDefault();
jQuery(window).trigger('left-shell-resize');
if (window.Causeway.divider.direction === 'horizontal') {
window.Causeway.divider.moveHorizontal(event.screenX);
} else if (window.Causeway.divider.direction === 'vertical') {
window.Causeway.divider.moveVertical(event.screenY);
} else if (window.Causeway.divider.direction === 'horizontalNavigation' && window.Causeway.divider.prevWidth !== 0) {
window.Causeway.divider.moveHorizontalNavigation(event.screenX);
} else if (window.Causeway.divider.direction === 'twoPaneVertical') {
window.Causeway.divider.moveVerticalTwoPane(event.screenY);
}
};
jQuery(document).on('mousedown', '.divider', window.Causeway.divider.init);
// jQuery('.pane-wrapper').scrollbar();
// Fix readonly fields
var readonlyTextFields = jQuery('input[type=text][readonly]');
readonlyTextFields.each(function () {
var val = jQuery(this).val();
if (this.offsetWidth < this.scrollWidth) {
jQuery(this).addClass('has-tooltip').attr('data-toggle', 'tooltip').attr('data-title', val).tooltip();
}
});
// Custom scroll bars
// Explicit Loader
var expLoader = jQuery('.explicit-loader');
expLoader.each(function () {
var $this = jQuery(this);
$this.modal({
'show': false,
'backdrop': 'static'
});
});
// Additional Menu
var additionalThreeLineMenu = jQuery('.additional-menu');
additionalThreeLineMenu.each(function () {
var dropMenu = jQuery('> .dropdown-menu', jQuery(this)),
dropMenuWidth = dropMenu.width(),
offsetLeft = jQuery(this).offset().left;
if (offsetLeft < dropMenuWidth) {
dropMenu.css({
'left': 0,
'right': 'auto'
});
} else if (offsetLeft > dropMenuWidth) {
jQuery(' > .dropdown-menu .dropdown-submenu >.dropdown-menu', jQuery(this)).css({
'left': '-100%'
});
}
});
var height = jQuery('.page').height(),
induceFullHeight = function (height) {
var pane = jQuery('.side-image-container').parents('.pane');
pane.css('minHeight', height);
};
induceFullHeight(height);
jQuery(window).resize(function () {
induceFullHeight('auto');
var height = jQuery('.page').height();
induceFullHeight(height);
});
// Notification sidebar
window.Causeway.notification = {};
window.Causeway.notification.drawerBtn = jQuery('.site-notification');
window.Causeway.notification.drawer = jQuery('.notification-content-right');
window.Causeway.notification.open = function () {
var $that = window.Causeway.notification.drawer;
$that.animate({
right: 0
}).addClass('open');
window.Causeway.notification.drawerBtn.addClass('open');
jQuery(document).trigger('nf-open');
};
window.Causeway.notification.close = function () {
var $that = window.Causeway.notification.drawer;
$that.animate({
right: '-100%'
}).removeClass('open');
window.Causeway.notification.drawerBtn.removeClass('open');
};
window.Causeway.notification.initToggle = function (evt) {
evt.stopImmediatePropagation();
if (window.Causeway.notification.drawer.hasClass('open')) {
window.Causeway.notification.close();
jQuery(document).trigger('nf-close');
} else {
window.Causeway.notification.open();
}
};
jQuery(document).on('click', function (e) {
// e.stopImmediatePropagation();
var $that = window.Causeway.notification.drawer,
target = jQuery(e.target);
if (!target.parents('.notification-content-right').hasClass('open') && $that.hasClass('open')) {
jQuery(document).trigger('nf-close');
}
});
jQuery(document).on('nf-close', function () {
window.Causeway.notification.close();
});
jQuery(document).on('click', '.site-notification', window.Causeway.notification.initToggle);
// jQuery('.notification-content').scrollbar();
jQuery('.close', jQuery('.notification-top-bar')).on('click', function () {
jQuery(this).parents('.notification-top-bar').removeClass('show');
});
// Form Error Messages
// Inline hover messages
jQuery('.error-hover .error-message').tooltip({
title: function () {
var $this = jQuery(this);
return $this.text();
}
});
// Site Notifications
window.Causeway.topNotification = {};
window.Causeway.topNotification.show = function (Options) {
window.Causeway.topNotification.hide();
var LocalOptions = Options ? Options : {};
LocalOptions.autoClose = LocalOptions.autoClose ? LocalOptions.autoClose : false;
LocalOptions.duration = LocalOptions.duration ? LocalOptions.duration : 5000;
LocalOptions.type = LocalOptions.type ? LocalOptions.type : '';
LocalOptions.message = LocalOptions.message ? LocalOptions.message : '<p>This is a default ' + LocalOptions.type + ' notification message</p>';
if(LocalOptions.type === 'cookie') LocalOptions.autoClose = false;
var template = jQuery('<div>', {
'class': 'notification-top-bar ' + LocalOptions.type,
'html': jQuery('<a>', {
'href': '#',
'class': 'close glyphicon glyphicon-close',
'click': function (e) {
e.preventDefault();
jQuery(this).parents('.notification-top-bar').fadeOut().removeClass('show').remove();
if(window.innerWidth >= 992){
$('.sub-pane').css('margin-top','-22px');
}
}
})
}).fadeIn().addClass('show').append(LocalOptions.message);
template.insertBefore('.pane');
if (LocalOptions.autoClose) {
var timeout = setTimeout(function () {
template.fadeOut().removeClass('show').remove();
template.trigger('ns-hidden');
}, LocalOptions.duration);
template.on('ns-hidden', function () {
clearTimeout(timeout);
});
}
if(jQuery('.navigation-pane-left').length > 0 && (window.innerWidth >= 992)) {
jQuery('.notification-top-bar.cookie').css({
'left': jQuery('.navigation-pane-left').css('width')
});
}
jQuery(window).on('left-shell-resize', function () {
jQuery('.notification-top-bar.cookie').css({
'left': jQuery('.navigation-pane-left').css('width')
});
});
};
window.Causeway.topNotification.hide = function () {
var notifications = jQuery('.notification-top-bar.show').not('.notification-top-bar.cookie.show');
if (notifications.length > 0) {
notifications.fadeOut().removeClass('show').remove();
notifications.trigger('ns-hidden');
}
};
// Spinbox
jQuery('.spin-box input[type=text]').each(function () {
var $this = jQuery(this);
var Options = {
minimum: $this.data('spin-min'),
maximum: $this.data('spin-max'),
step: $this.data('spin-steps'),
value: $this.data('spin-value'),
numberOfDecimals: $this.data('spin-decimals')
};
$this.spinedit(Options);
});
// disabled
jQuery('.spin-box.disabled').each(function () {
jQuery('.icon-chevron-up,.icon-chevron-down', jQuery(this)).off();
});
// Color Box
var colors = jQuery('.color');
colors.each(function () {
var $this = jQuery(this);
var colorPicker = jQuery('.color-picker', $this),
colorDrop = jQuery('.color-drop', $this),
inputColor = jQuery('input[type=text]', $this),
defaultColor = inputColor.val(),
colorSet = (inputColor.data('color-set')) ? inputColor.data('color-set').colors.split(', ') : false;
var Options = {
defaultColor: defaultColor,
columns: 10,
boxWidth: '100%',
boxHeight: '100%',
displayCSS: {
'border': '1px solid #a4a6a9'
},
livePreview: true,
onSelect: function (hex) {
var regex = /^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
if(regex.test(hex)) {
inputColor.val('#' + hex);
} else {
inputColor.val(hex);
}
}
};
if (colorSet) {
Options.colors = colorSet;
}
colorPicker.simpleColor(Options);
colorDrop.on('click', function (e) {
var colDisplay = jQuery('.simpleColorDisplay', $this);
colDisplay.trigger(e);
});
//colorPicker.setColor(inputValue);
inputColor.on('change', function () {
var hex = jQuery(this).val();
colorPicker.setColor(hex);
});
});
// Currencies
var currencySelectors = jQuery('.currency input[type=text]');
currencySelectors.each(function () {
var $this = jQuery(this);
var Currency = $this.data('available-currencies');
var addOn = jQuery('<span class="add-on">');
var select = jQuery('<select>');
var length = 0,
currentCurrency;
for (var currency in Currency) {
if(Currency.hasOwnProperty(currency)) {
select.append('<option>' + currency + '</option>');
currentCurrency = currency;
length++;
}
}
if (length <= 1) {
addOn.append(currentCurrency);
} else {
addOn.addClass('select')
.append(select);
}
if ($this.is(':disabled')) {
select.attr('disabled', 'disabled');
}
addOn.insertAfter($this);
$this.data('currency', select.val());
select.bind('change', function () {
$this.data('currency', jQuery(this).val());
});
});
// Accordion
jQuery(document).on('click', '.panel-heading', function () {
var $this = jQuery(this),
glyph = jQuery('.fa', $this),
accordion = $this.parents('.ca-accordion'),
otherGlyphs = $('.fa', accordion).not(glyph);
if (glyph.hasClass('fa-chevron-down')) {
glyph.removeClass('fa-chevron-down').addClass('fa-chevron-right');
} else {
glyph.removeClass('fa-chevron-right').addClass('fa-chevron-down');
otherGlyphs.removeClass('fa-chevron-down').addClass('fa-chevron-right');
}
});
// Advanced List Box
var advancedListBox = jQuery('.advanced-listbox');
advancedListBox.each(function () {
var $this = jQuery(this),
selector = jQuery('select', $this);
selector.selectpicker({
liveSearch: true
});
var search = jQuery('.bs-searchbox', $this),
searchField = jQuery('input[type=text]', search),
glyph = jQuery('<span class="glyphicon glyphicon-search"></span>');
search.append(glyph);
searchField.on('keyup', function () {
if (jQuery(this).val()) {
glyph.removeClass('glyphicon-search').addClass('glyphicon-close');
} else {
glyph.removeClass('glyphicon-close').addClass('glyphicon-search');
}
});
glyph.on('click', function () {
if (jQuery(this).hasClass('glyphicon-close')) {
searchField.val('').keyup();
selector.selectpicker('refresh');
}
});
if (selector.is(':disabled')) {
searchField.prop('disabled', 'disabled');
}
});
// Select Shuttle
var selectShuttle = jQuery('.select-shuttle select');
selectShuttle.each(function () {
var $this = jQuery(this);
$this.bootstrapDualListbox({
nonSelectedListLabel: 'Available',
selectedListLabel: 'Selected',
preserveSelectionOnMove: 'moved',
moveOnSelect: false,
infoText: false,
selectorMinimalHeight: 250
});
});
// Extend Tab.js
jQuery('.nav li.disabled a').click(function () {
return false;
});
}(window, document, jQuery));
(function (window, jQuery) {
'use strict';
// Left Navigation Height
var adjustNavHeight = function () {
if (window.innerWidth < 992) {
return false;
}
var clientHeight = document.documentElement.clientHeight;
jQuery('.navigation-pane-left').css('height', clientHeight);
// jQuery('.navigation-content-wrapper').scrollbar();
};
adjustNavHeight();
jQuery(window).resize(adjustNavHeight);
// Click to close left shell
var handle = jQuery('.handle', jQuery('.divider-navigation'));
var leftShellWidth = 350;
handle.on('click', function () {
if (window.innerWidth < 992) {
return false;
}
var $this = jQuery(this),
divider = $this.parent(),
leftShell = divider.prev('.navigation-pane-left'),
rightPane = divider.next('.navigation-pane-right');
leftShellWidth = (parseInt(leftShell.width(), 10) === 0) ? leftShellWidth : parseInt(leftShell.width(), 10);
if (leftShell.hasClass('closed')) {
leftShell.animate({
'width': leftShellWidth
});
divider.animate({
'left': leftShellWidth
});
rightPane.animate({
'margin-left': leftShellWidth
});
$this.removeClass('closed');
leftShell.removeClass('closed');
} else {
leftShell.animate({
'width': 0
});
divider.animate({
'left': 0
});
rightPane.animate({
'margin-left': 0
});
$this.addClass('closed');
leftShell.addClass('closed');
}
});
}(window, jQuery));
(function (window, $) {
'use strict';
// Lightbox modal -- change overlay color to white by adding a class name to the body.
var lightbox = $('.modal.lightbox');
var getPromptModal = function (message) {
return $("<div class='modal fade' id='alert_lightbox' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>" +
"<div class='modal-dialog'>" +
"<div class='modal-content'>" +
"<div class='modal-header'>" +
"<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>" +
"<h4 id='myModalLabel' class='modal-title'>Dialogue Title</h4>" +
"</div>" +
"<div class='modal-body'>" +
message +
"</div>" +
"<div class='modal-footer'>" +
"<a href='javascript:void(0);' data-dismiss='modal'>No</a>" +
"<button type='button' data-dismiss-lightbox='lightbox' class='btn btn-default'>" +
"Yes" +
"</button>" +
"</div>" +
"</div>" +
"</div>" +
"</div>");
};
lightbox.each(function () {
var $this = $(this);
if ($this.data('close-background') === false) {
$this.modal({
'show': false,
'backdrop': 'static'
});
}
var cancelBtn = $('[data-close-prompt]', $this),
promptMessage = (cancelBtn.length > 0) ? cancelBtn.data('close-prompt') : '',
promptModal = getPromptModal(promptMessage),
promptYesBtn = $('[data-dismiss-lightbox]', promptModal);
if (cancelBtn.length > 0) {
cancelBtn.on('click', function () {
promptModal.modal('show');
});
promptModal.on('show.bs.modal', function () {
promptYesBtn = $('[data-dismiss-lightbox]');
});
promptYesBtn.on('click', function () {
$('.modal').modal('hide');
});
}
});
$(document).on('show.bs.modal', lightbox, function () {
$('body').addClass('lightbox-modal');
});
var getModalBodyHeight = function (el) {
return $('.modal-body', el)[0].scrollHeight;
};
var modalBodyHeight = 0;
var lightboxCustomScroll = function () {
var thisEl = $('.modal.lightbox:visible');
if (thisEl.length > 0) {
var modalDialogHeight = $('.modal-dialog', thisEl)[0].clientHeight - 165;
modalBodyHeight = !!modalBodyHeight ? modalBodyHeight : $('.modal-body', thisEl)[0].clientHeight;
if (modalBodyHeight > modalDialogHeight) {
$('.modal-content', thisEl).css('height', '100%');
} else {
$('.modal-content', thisEl).css('height', 'auto');
}
}
};
Causeway.lightboxCustomScroll = lightboxCustomScroll;
$(document).on('shown.bs.modal', lightbox, function (e) {
modalBodyHeight = getModalBodyHeight(e.target);
lightboxCustomScroll();
$('.has-tooltip').each(function (index, element) {
var $this = $(element),
$parent = $this.parent();
$this.tooltip({
container: $parent,
placement: 'bottom',
delay: {
show: 300,
hide: 300
}
});
});
// Causeway.initPostDynamic();
});
$(document).on('hidden.bs.modal', lightbox, function () {
// $('.lightbox .modal-body').scrollbar('destroy');
$('body').removeClass('lightbox-modal');
});
// $(window).resize(lightboxCustomScroll);
}(window, jQuery));
(function ($, window) {
'use strict';
if (window.Causeway.isIe8) {
/**
* Tables
*/
var $tables = jQuery('table.table tbody');
$tables.find('tr:nth-child(2n)').addClass('even');
$tables.find('tr:nth-child(2n+1)').addClass('odd');
}
// Custom scroll bars
// For Tables
window.Causeway.tableScroll = {};
window.Causeway.tableScroll.init = function () {
var tableContent = jQuery('.table-content');
tableContent.each(function () {
var $this = jQuery(this),
tableToGetScrollbar = jQuery('.table', $this);
if (window.Causeway.isIe9) {
var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g'),
tableHtml = $this.html();
tableHtml = tableHtml.replace(expr, '><');
$this.html(tableHtml);
}
if (tableToGetScrollbar.width() > $this.width() && !tableToGetScrollbar.hasClass('fixed-header')) {
$this.scrollbar();
}
if($this[0].scrollHeight>$this.height() || $this[0].scrollWidth>$this.width()){
$this.addClass('MobScroll');
}
});
};
// window.Causeway.tableScroll.init();
// Table filter toggle
window.Causeway.tableFilter = {};
window.Causeway.tableFilter.init = function () {
window.Causeway.tableFilter.filterButton = jQuery('.btn-filter');
window.Causeway.tableFilter.filterRow = function (el) {
var parents = el.parents('.table-toolbar');
return parents.next('.table-content').find('tr.filter')
.add(parents.find('.toolbar-filter'))
.add(parents.next('.table').find('tr.filter'));
};
window.Causeway.tableFilter.filterButtonOn = false;
var that = this;
that.filterButton.each(function () {
window.Causeway.tableFilter.filterButtonOn = false;
var $this = jQuery(this);
var filter_row = that.filterRow($this),
formFilterFields = filter_row.find('select, input');
filter_row.hide();
formFilterFields.each(function () {
var $this = jQuery(this);
if ($this.attr('type') === 'checkbox' || $this.attr('type') === 'radio') {
that.filterButtonOn = that.filterButtonOn ? true : !!$this.is(':checked');
} else {
that.filterButtonOn = that.filterButtonOn ? true : !!$this.val().trim();
}
});
if (that.filterButtonOn) {
filter_row = that.filterRow($this);
$this.addClass('selected');
filter_row.toggle();
}
$this.on('click', function () {
filter_row = that.filterRow($this);
$this.toggleClass('selected');
filter_row.toggle();
});
});
};
window.Causeway.tableFilter.init();
// Table Fixed Header
window.Causeway.fixedTableHeader = {};
window.Causeway.fixedTableHeader.init = function () {
window.Causeway.fixedTableHeader.tables = jQuery('.table.fixed-header');
var $that = window.Causeway.fixedTableHeader.tables;
$that.each(function () {
var $this = jQuery(this),
$tableContent = $this.parent('.table-content');
$this.tableHeadFixer({
'left' : 0,
'head' : true,
'foot': true
});
// $tableContent.addClass('scrollbar-outer').scrollbar();
});
return true;
};
window.Causeway.fixedTableHeader.init();
//Table Sort
var tableToSort = jQuery('.table-sort');
tableToSort.each(function () {
var $this = jQuery(this),
tableSortOptions = {},
header = jQuery("thead > tr:not('.filter'):last > th", $this),
disabled = header.has('[class$=-disabled]');
tableSortOptions.headers = {};
disabled.each(function () {
var index = header.index(jQuery(this));