File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/wwwroot/packages/komma/kms/js/main.js
(function ($) {
/*
// Tabs
function openTab(tabSlug){
var originalTabSlug = tabSlug;
if(! tabSlug) return;
$('#tab-slug').val(tabSlug);
var tabSlugs = tabSlug.split('/');
if(tabSlugs.length > 1) {
var subTabSlug = tabSlugs.pop();
tabSlug = tabSlugs.join('/');
}
$('.tab-content').css('display','none');
$('.sub-tab-content').css('display','none');
$('.entity-tabs > .nav-tabs > li').removeClass('active');
$('.sub-tabs > .nav-tabs > li').removeClass('active');
$('#tab-content-'+tabSlug).css('display','block');
$('.entity-tabs > .nav-tabs > li a[href="#'+tabSlug+'"]').parent().addClass('active');
if(subTabSlug)
{
$('#tab-content-'+tabSlug+' #sub-tab-content-'+subTabSlug).css('display','block');
$('#tab-content-'+tabSlug+' .sub-tabs > .nav-tabs > li a[href="#'+originalTabSlug+'"]').parent().addClass('active');
}else{
$('#tab-content-'+tabSlug+' .sub-tab-content:first').css('display','block');
$('#tab-content-'+tabSlug+' .sub-tabs > .nav-tabs > li:first').addClass('active');
}
}
// Tabs
$(window).on('hashchange load', function() {
tabSlug = window.location.hash.substring(1);
if(tabSlug) openTab(window.location.hash.substring(1));
openTab($('#tab-slug').val());
});
*/
//mobile dash
$('section#mobile .numbers').hide();
$('section#mobile .entity-attribute-title').click(function () {
$(this).parent().find('.numbers').toggle();
});
// Save button
$('#save-button').click(function (e) {
$('#entity-form').find('input, textarea').attr('disabled', false);
$('#entity-form').submit();
});
// TinyMCE
tinymce.init({
selector: 'textarea.tiny-mce',
skin: 'kms',
menubar: false,
statusbar: false,
plugins: ['code', 'paste', 'link'],
// toolbar: 'styleselect | bold italic underline | bullist numlist | link image | code',
height: '200',
paste_as_text: true,
convert_urls: false,
style_formats: [{title: 'Titel', block: 'h2'}]
});
// Hierarchical list
$('.entities-list-item .dropdown-icon').click(function (e) {
e.preventDefault();
if ($(this).parent().parent().hasClass('open')) {
//$('.animate-to-triangle', this)[0].beginElement();
$(this).parent().parent().removeClass('open');
} else {
//$('.animate-to-minus', this)[0].beginElement();
$(this).parent().parent().addClass('open');
}
});
var toggled = true;
// Scroll to active item in list
$(window).load(function () {
if ($('#entity-form .lock').hasClass('open')) {
toggled = false;
$('#entity-form').find('input, textarea').attr('disabled', toggled);
}
//Set the container var
var $container = $('#entities .entities-list');
//Get the first active element
var $activeListItem = $('li.entities-list-item.active', $container).first();
//No active element, return
if ($activeListItem.length == 0) return;
//Top offset from the active item
var top = $activeListItem.offset().top;
//The top offset of the surrounding DIV
var rootOffset = $('div#tree-root').offset().top;
$container.scrollTop(top - rootOffset);
});
//error accordian
$('.error-accordion .collapsible-ul').hide();
$('.error-accordion h3').click(function () {
$(this).parent().find('.collapsible-ul').toggle();
});
$('.order-status.selectize').selectize();
// Product category selector
$('#productCategorySelector').selectize();
$('#selectYearAndMonthForm select').selectize();
$('#selectYearAndMonthForm select').change(function () {
var location = '/kms/orders/voltooid?month=' + $('#selectYearAndMonthForm select#orderMonthSelector').val() + '&year=' + $('#selectYearAndMonthForm select#orderYearSelector').val();
window.location = location;
})
$('#productCategorySelector').change(function () {
window.location = '/kms/products?current_product_category=' + encodeURIComponent(this.value);
});
// Flash messages
var hideFlashMessage = function () {
$('#flash-messages').fadeOut();
};
$('#flash-messages').click(function () {
hideFlashMessage();
});
setTimeout(function () {
hideFlashMessage();
}, 5000);
//var toggled = true;
$('#entity-form .lock').click(function () {
$(this).toggleClass('open')
toggled = !toggled;
$(this).parents('#entity-form').find('input, textarea').attr('disabled', toggled);
})
})(jQuery);