Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function () {
- datePicker.translations();
- datePicker.init();
- zipcodeMask.init();
- mobileMenu.init();
- sidebarDropdowns.init();
- knowledgeBase.init('.allKnowledgeItems ');
- knowledgeBase.init('.highlightedKnowledgeItems ');
- categoriesFAQDropdown.init();
- printPage.init();
- departmentSearch.init();
- changeLoginDetailsChoice.init();
- wysiwyg.init();
- /* THIS IS FOR TESTING ONLY
- ============================================================== */
- debug.menuOnLoad();
- });
- /* DatePicker Translations And Init
- ============================================================== */
- var datePicker = {
- /* Translations */
- translations: function () {
- $.datepicker.regional['nl'] = {
- closeText: 'Sluiten',
- prevText: '←',
- nextText: '→',
- currentText: 'Vandaag',
- monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
- 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
- monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
- 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
- dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
- dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
- dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
- weekHeader: 'Wk',
- dateFormat: 'dd-mm-yy',
- firstDay: 1,
- isRTL: false,
- showMonthAfterYear: false,
- yearSuffix: ''
- };
- $.datepicker.setDefaults($.datepicker.regional['nl']);
- },
- /* Init */
- init: function () {
- $('.datepicker').datepicker({
- changeMonth: true,
- changeYear: true,
- yearRange: '1920:+0'
- });
- }
- }
- /* Zipcode input field mask init and auto uppercase
- ============================================================== */
- var zipcodeMask = {
- init: function() {
- $('#zipcode').mask('9999 aa');
- $('#zipcode').bind('blur', function () {
- $(this).val($(this).val().toUpperCase());
- });
- }
- }
- /* Mobile Menu and Mobile Sidebar Dropdown
- ============================================================== */
- var mobileMenu = {
- /* Init
- ========== */
- init: function () {
- /* Open Menu */
- $('.showMenu .hamburger').on('click', function () {
- mobileMenu.show('menu');
- });
- /* Open Sidebar */
- $('.showMenu .profile').on('click', function () {
- mobileMenu.show('sidebar');
- });
- /* Close menu through close icon */
- $('.closeMenu').on('click', function () {
- mobileMenu.hide('menu');
- mobileMenu.hide('sidebar');
- });
- /* Close menu through clicking outside menu */
- $('.menuOverlay').on('click', function () {
- mobileMenu.hide('menu');
- mobileMenu.hide('sidebar');
- });
- },
- /* Show
- ========== */
- show: function (elem) {
- /* If main menu, open main menu */
- if (elem == 'menu') {
- $('.menuColumn').show(0);
- $('body').addClass('menuOpen');
- }
- /* If sidebar, open sidebar */
- else if (elem == 'sidebar') {
- $('.sidebar').show(0);
- $('body').addClass('sidebarOpen');
- }
- $('.menuOverlay').fadeIn(300);
- },
- /* Hide
- ========== */
- hide: function (elem) {
- /* If main menu, close main menu */
- if (elem == 'menu') {
- setTimeout(function () {
- $('.menuColumn').hide(0);
- }, 300);
- $('body').removeClass('menuOpen');
- }
- /* If sidebar, close sidebar */
- else if (elem == 'sidebar') {
- setTimeout(function () {
- $('.sidebar').hide(0);
- }, 300);
- $('body').removeClass('sidebarOpen');
- }
- $('.menuOverlay').fadeOut(300);
- }
- }
- /* Sidebar Dropdowns
- ============================================================== */
- var sidebarDropdowns = {
- init: function () {
- // Hide dropdowns on page load (needed to show dropdown content to non-javascript users)
- $('ul.dropdownList').hide(0);
- $('div.dropdownContent').hide(0);
- // Prime first type of dropdowns for click events
- $('.myDepartmentList > .hasDropdown .title').on('click', function () {
- $(this).parent().toggleClass('open');
- $(this).parent().find('.dropdownList').slideToggle();
- });
- // Prime second type of dropdowns for click events
- $('.sidebarDropdown h4').on('click', function () {
- $(this).toggleClass('open');
- $(this).parent().find('.dropdownContent').slideToggle();
- });
- }
- }
- /* Knowledge Base Dropdowns
- ============================================================== */
- var knowledgeBase = {
- // Run URL hashtag recognition + prime click events on page load. Hide dropdowns on page load (needed to show dropdown content to non-javascript users).
- init: function (parent) {
- $(parent + '.knowledgeBaseDropdownContent').hide(0);
- $(parent + '.knowledgeBaseDropdownHead').on('click', function () {
- knowledgeBase.executeDropdown($(this), parent);
- });
- knowledgeBase.processHash();
- },
- // Animate dropdowns and add corresponding open class
- executeDropdown: function (elem, parent) {
- if (!elem.hasClass('open')) {
- $(parent + '.knowledgeBaseDropdownContent').slideUp();
- $(parent + '.knowledgeBaseDropdownHead').removeClass('open');
- elem.addClass('open');
- elem.parent().find('.knowledgeBaseDropdownContent').slideDown();
- } else {
- elem.parent().find('.knowledgeBaseDropdownContent').slideUp();
- elem.removeClass('open');
- }
- knowledgeBase.textToHash(elem);
- },
- // Get title from dropdown and strip it from uppercase characters, special characters and whitespace.
- textToHash: function (elem) {
- var headText = elem.text();
- var strippedText = headText.replace(/[^a-zA-Z ]/g, '').replace(/ /g, '-').toLowerCase();
- var hashText = '#' + strippedText;
- var currentHash = window.location.hash;
- // Call function to push new (or empty) hashtag
- if (currentHash != hashText) {
- knowledgeBase.setHash(hashText);
- } else {
- knowledgeBase.setHash(' ');
- }
- },
- // Push hash to URL by using history states. Fallback for older browsers. Gets rid of native browser scrolling on setting hash
- setHash: function (hash) {
- if (history.replaceState) {
- history.replaceState(null, null, hash);
- }
- else {
- location.hash = hash;
- }
- },
- // On page load, open correct dropdown based on hash in URL
- processHash: function () {
- var currentHash = window.location.hash;
- if (currentHash != '') {
- $(currentHash).find('.knowledgeBaseDropdownContent').show(0);
- $(currentHash).find('.knowledgeBaseDropdownHead').addClass('open');
- }
- }
- }
- /* Print button
- ============================================================== */
- var printPage = {
- init: function () {
- $('.printButton').on('click', function () {
- window.print();
- return false;
- });
- }
- }
- /* FAQ category dropdown
- ============================================================== */
- var categoriesFAQDropdown = {
- init: function () {
- $('.categoriesFAQ .categoriesSubTitle').on('click', function () {
- $(this).parent().find('ul').slideToggle();
- });
- }
- }
- /* Search departments
- ============================================================== */
- var departmentSearch = {
- init: function () {
- var searchValue = getQueryVarByName('searchTerm');
- var province = getQueryVarByName('provinceSelect');
- if (searchValue != '' && searchValue != null) {
- $('#searchTerm').val(searchValue);
- $('.searchTermText').text(searchValue);
- } else {
- // DEBUG ONLY
- $('.searchResults').hide(0);
- }
- if (province != '' && province != null) {
- $('#provinceSelect').val(province);
- }
- }
- }
- /* Choose to change password or emailaddress
- ============================================================== */
- var changeLoginDetailsChoice = {
- init: function () {
- $('.tabsContainer .tab').hide(0);
- $('.tabsContainer .tab:first-of-type').show(0);
- $('.tabsContainer .tabsHead li').on('click', function () {
- $('.tabsContainer .tabsHead li').removeClass('active');
- $(this).addClass('active');
- var targetTab = $(this).find('a').data('href');
- $('.tabsContainer .tab').hide(0);
- $('.tabsContainer .tab#' + targetTab).show(0);
- });
- }
- }
- /* TinyMCE Init with config options
- ============================================================== */
- var wysiwyg = {
- init: function () {
- tinymce.init({
- selector: 'textarea.rte',
- height: 300,
- theme: 'modern',
- language: 'nl',
- plugins: [
- 'advlist autolink lists link image charmap pagebreak media table searchreplace visualchars paste textpattern imagetools'
- ],
- menubar: false,
- toolbar1: 'cut copy paste | undo redo | link bullist numlist table charmap',
- toolbar2: 'bold italic underline | alignleft aligncenter alignright alignjustify | image media'
- });
- }
- }
- /* Get Query Vars
- ============================================================== */
- function getQueryVarByName(name, url) {
- if (!url) {
- url = window.location.href;
- }
- name = name.replace(/[\[\]]/g, "\\$&");
- var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
- results = regex.exec(url);
- if (!results) return null;
- if (!results[2]) return '';
- return decodeURIComponent(results[2].replace(/\+/g, " "));
- }
- /* THIS IS FOR TESTING ONLY
- ============================================================== */
- var debug = {
- menuOnClick: function () {
- $('nav > ul > li > a').on('click', function () {
- $('nav > ul > li').removeClass('active');
- $(this).parent().addClass('active');
- });
- $('nav > ul > li > ul a').on('click', function () {
- $('nav > ul > li > ul li').removeClass('active');
- $(this).parent().addClass('active');
- });
- },
- menuOnLoad: function () {
- // Get current page by URL
- var currentPage = location.pathname;
- if (location.pathname.slice(-1) != '/') {
- currentPage = currentPage + '/';
- }
- // Set active menu item based on current page
- if (currentPage == '/Pages/Nieuws/' || currentPage == '/Pages/NieuwsDetail/' || currentPage == '/Pages/ContentpaginaIframe/') {
- $('.navMenu > nav > ul > li:nth-child(1)').addClass('active');
- if (currentPage == '/Pages/Nieuws/') {
- $('.navMenu > nav > ul > li:nth-child(1) li:nth-child(1)').addClass('active');
- }
- else if (currentPage == '/Pages/ContentpaginaIframe/') {
- $('.navMenu > nav > ul > li:nth-child(1) li:nth-child(2)').addClass('active');
- }
- }
- else if (currentPage == '/Pages/Kennisbank/' || currentPage == '/Pages/KennisbankDetail/') {
- $('.navMenu > nav > ul > li:nth-child(2)').addClass('active');
- $('#content').removeClass('withSubmenu');
- }
- else if (currentPage == '/Pages/Cursussen/' || currentPage == '/Pages/CursusDetail/' || currentPage == '/Pages/CursusInschrijving/') {
- $('.navMenu > nav > ul > li:nth-child(3)').addClass('active');
- $('#content').removeClass('withSubmenu');
- }
- else if (currentPage == '/Pages/AgendaOverzicht/' || currentPage == '/Pages/AgendaDetail/' || currentPage == '/Pages/AgendaArchief/') {
- $('.navMenu > nav > ul > li:nth-child(4)').addClass('active');
- if (currentPage == '/Pages/AgendaOverzicht/') {
- $('.navMenu > nav > ul > li:nth-child(4) li:nth-child(1)').addClass('active');
- }
- else if (currentPage == '/Pages/AgendaArchief/') {
- $('.navMenu > nav > ul > li:nth-child(4) li:nth-child(2)').addClass('active');
- }
- }
- else {
- $('#content').removeClass('withSubmenu');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement