/*** * Museum Boerhaave * * Description: Generic userinterface enhancements * Author: Fabrique[brands, design & interaction] - http://fabrique.nl/ *         Anna, Ebelien, Marko, Matthe, Esther & Dodi * Date: 2011-04-19 * * * TOC * ##NAVIGATION * ##CLICKABLEBLOCKS * ##MOREOBJECTSTOGGLE * ##APPLICATION *//*** * ##NAVIGATION * Navigation behaviour */function Navigation() {}Navigation.prototype = {  items: [],  init: function() {    var that = this;    $('nav.nav-main .mainnav-item').each(function(index, el) {      that.setupItem(el);      that.items.push(el);    });    $('nav.subnav').fadeOut(1);  },  setupItem: function(el) {    var that = this;    var navName = $(el).attr('id');    if(!navName) {      return false;    }    navName = navName.replace('navitem-','');    $(el).mouseenter(function(e) {      that.showItem(navName);      e.stopPropagation();      e.preventDefault();    });    $('#subnav-'+navName).mouseleave(function(e) {      that.hideItems();      e.stopPropagation();      e.preventDefault();    });    $('#subnav-'+navName).css({ 'left': ($(el).offset().left - ((200 - $(el).width()) / 2)) + 'px' });  },  showItem: function(navName) {    this.hideItems();    $('#subnav-'+navName).fadeIn();      },  hideItems: function() {    for(var i=0, len=this.items.length; i < len; i++) {      var navName = $(this.items[i]).attr('id');      navName = navName.replace('navitem-','');      if(navName) {        $('#subnav-'+navName).fadeOut();      }    }  }};/* Navigation - end *//*** * ##CLICKABLEBLOCKS * ClickableBlocks behaviour */function ClickableBlocks() {}ClickableBlocks.prototype = {  items: [],  init: function() {    var that = this;    this.setupBlock('html.content-page section.nowinmuseum-section div.subsection');    this.setupBlock('section.related-articles-section div.subsection');    this.setupBlock('section.appearedinnews-section div.subsection');    this.setupBlock('section.competitors-section div.subsection');    this.setupBlock('section.contrasts-section div.subsection');    this.setupBlock('section.craftsman-section');    this.setupBlock('html.person-page section.objects-section div.subsection');    this.setupBlock('html.person-page section.relatedperson-section div.subsection');    this.setupBlock('html.person-page section.competitors-section div.subsection');    this.setupBlock('section.agenda-section div.agendaitem');    this.setupBlock('section.objectitems-section div.objectitem');    this.setupBlock('html.search-page div.mid div.subsection');    this.setupBlock('html.special-page section.objects-section div.subsection');  },  setupBlock: function(sel) {    $(sel).each(function(index, el) {      var anchors = $('a', el);      if(anchors.length >0 ) {          var blockLink = $(el).find('a');          $(el).click(function(e) {            document.location.href = blockLink.attr('href');            e.preventDefault();            e.stopPropagation();          });              }    });  }};/* ClickableBlocks - end *//*** * ##MOREOBJECTSTOGGLE * Toggle between showing more objects or not */function MoreObjectsToggle() {}MoreObjectsToggle.prototype = {  el: null,  toggleEl: null,  items: [],  defaultHeight: 0,  init: function() {    var that = this;    this.el = $('section.objects-section');    this.toggleEl = $('p.to-more-objects a');    if(!this.el || !this.toggleEl) {      return false;    }    this.items = $('div.more-objects', this.el);    for(var i=0, len =this.items.length; i<len; i++) {      that.items[i].defaultHeight = $(that.items[i]).height();      $(this.items[i]).height(0);    }    this.close();    this.toggleEl.click(function(e) {      if(that.el.hasClass('hide-more-objects')) {        that.open();      }      else {        location.hash = '';          that.close();      }      e.preventDefault();      e.stopPropagation();    });  },  open: function() {    this.el.removeClass('hide-more-objects');    location.hash = '#moreobjects_firstcolumn';    for(var i=0, len =this.items.length; i<len; i++) {      $(this.items[i]).animate({ 'height': this.items[i].defaultHeight }, 250);    }    $(this.toggleEl).text($(this.toggleEl).text().replace('meer','minder'));  },  close: function() {    this.el.addClass('hide-more-objects');    for(var i=0, len =this.items.length; i<len; i++) {      $(this.items[i]).animate({ 'height': 0 }, 250);    }    $(this.toggleEl).text($(this.toggleEl).text().replace('minder','meer'));  }};/* More objects toggle - end *//*** * ##MOREZAALFILTER TOGGLE * Toggle between showing more zaal filters bij zoeken of nie! */function MoreZaalFilterToggle() {}MoreZaalFilterToggle.prototype = {  el: null,  toggleEl: null,  items: [],  defaultHeight: 0,  init: function() {    var that = this;    this.el = $('#zaalfilters');    this.toggleEl = $('.to-more-zaalfilters');    if(!this.el || !this.toggleEl) {      return false;    }    this.items = $('ul.more-zaal-filters', this.el);    for(var i=0, len =this.items.length; i<len; i++) {      that.items[i].defaultHeight = $(that.items[i]).height();      $(this.items[i]).height(0);    }    this.close();    this.toggleEl.click(function(e) {      if(that.el.hasClass('hide-more-objects')) {        that.open();      }      else {        that.close();      }      e.preventDefault();      e.stopPropagation();    });  },  open: function() {    this.el.removeClass('hide-more-objects');    for(var i=0, len =this.items.length; i<len; i++) {      $(this.items[i]).animate({ 'height': this.items[i].defaultHeight }, 250);    }    $(this.toggleEl).text($(this.toggleEl).text().replace('+ meer','- minder'));  },  close: function() {    this.el.addClass('hide-more-objects');    for(var i=0, len =this.items.length; i<len; i++) {      $(this.items[i]).animate({ 'height': 0 }, 250);    }    $(this.toggleEl).text($(this.toggleEl).text().replace('- minder','+ meer'));  }};/* More zaalfilter toggle - end *//*** * ##ARTICLEDESCRIPTION * ArticleDescription behaviour */function ArticleDescription() {}ArticleDescription.prototype = {  el: null,  descriptionEl: null,  toggleEl: null,  minHeight: 144,  defaultHeight: 144,  init: function() {    var that = this;    this.descriptionEl = $('#beschrijving');    this.el = $('section.articledescription');    if($(this.el).hasClass('objectdescription')) {      this.minHeight = 240;    }    else if($(this.el).hasClass('specialdescription')) {      this.minHeight = 92;    }    if(!this.descriptionEl || !this.el || ($(this.descriptionEl).height() <= this.minHeight)) {      return false;    }    this.defaultHeight = $(this.descriptionEl).height();    $(this.el).append('<p class="to-readmore"><a href="#beschrijving" class="readmore">Lees meer</a></p>');    this.toggleEl = $('section.articledescription p.to-readmore a');    this.close();    $(this.toggleEl).click(function(e) {      if($(that.el).hasClass('hide-complete-description')) {        that.open();      }      else {        that.close();      }      e.preventDefault();      e.stopPropagation();    });  },  open: function() {    var that = this;    $(this.toggleEl).text('Beschrijving inklappen');    $(this.descriptionEl).animate({      'height': that.defaultHeight    }, 250, function() {      $(that.el).removeClass('hide-complete-description');    });  },  close: function() {    var that = this;    $(this.toggleEl).text('Lees volledige beschrijving');    $(this.descriptionEl).animate({      'height': that.minHeight    }, 250, function() {      $(that.el).addClass('hide-complete-description');    });  }};/* ArticleDescription - end *//*** * ##APPLICATION * Application start - public void main */function Application() {}Application.prototype = {  init: function() {    var that = this;    this.isIE();    this.clickableBlocks = new ClickableBlocks();    this.clickableBlocks.init();    this.artDescription = new ArticleDescription();    this.artDescription.init();    this.setupPrint();    this.setupExternalLinks();    this.setupScaleSpans();    this.setupSocialShare();    this.setupSubscribeForm();    this.setupPreviousPageLinks();    this.setupSpecialPageBreadcrumb();    $(window).resize(function() {      that.resizeHeight();    });  },  initOnLoaded: function() {    this.resizeHeight();    this.nav = new Navigation();    this.nav.init();    this.mot = new MoreObjectsToggle();    this.mot.init();    this.mozft = new MoreZaalFilterToggle();    this.mozft.init();  },  setupPrint: function() {    $('a.print').click(function(e) {      print();      e.preventDefault();      e.stopPropagation();    });  },  setupExternalLinks: function() {    $("a[rel='external']").each(function(index, el) {      $(el).attr('target','_blank');    });  },  setupScaleSpans: function() {    $("div.scale-score").each(function(index, el) {        $(el).mouseenter(function(e) {         $('#alegend').removeClass('activeshow');         $(this).children(".scalespan").addClass('scalehover');        });        $(el).mouseleave(function(e) {          $(this).children(".scalespan").removeClass('scalehover');          $('#alegend').addClass('activeshow');        });        });  },  setupSocialShare: function() {    $('.features-section div.subsection').each(function(index, el) {      $('#social-share-toggle').mouseenter(function(e) {        $(el).removeClass('social-share-hidden');        e.preventDefault();        e.stopPropagation();      });      $(el).mouseleave(function(e) {        $(el).addClass('social-share-hidden');        e.preventDefault();        e.stopPropagation();      });      $(el).addClass('social-share-hidden');    });  },  setupSubscribeForm: function() {    if($('div.form-has-errors').length > 0) {      document.location.hash = 'reservation-form-container';    }  },  setupPreviousPageLinks: function() {    $('a.to-previous-page').click(function(e) {      history.go(-1);      e.preventDefault();      e.stopPropagation();    });  },  setupSpecialPageBreadcrumb: function() {    if(!$('html').hasClass('special-page')) {      return false;    }    var mainVisual = $('html.special-page div.primary').css('background-image');    $('html.special-page div.primary div.breadcrumb p').css({      'background-image': mainVisual    });  },  resizeHeight: function() {    if($(window).height() < $(document.body).height()) {      $('nav.subnav').height($(document.body).height() - 1);    }    else {      $('nav.subnav').height($(window).height() - 1);    }  },  isIE: function() {    if($.browser.msie) {      $('html').addClass('ie');      $('html').addClass('ie' + parseInt($.browser.version));    }  }};/* Application - end */var app = new Application();$(document).ready(function() {  app.init();});$(window).load(function() {  app.initOnLoaded();});
