Mercurial > hg > MPIWGWeb
view js/mpiwg.js @ 108:782477730916
CLOSED - # 57: Research/ Research Units: Karussell f?r die Projekte in einem Department
https://it-dev.mpiwg-berlin.mpg.de/tracs/webpage/ticket/57
author | casties |
---|---|
date | Mon, 27 May 2013 23:12:07 +0200 |
parents | 79a198e7b1b7 |
children | f8e914a4992d |
line wrap: on
line source
/* * Javascript for MPIWG website */ (function ($) { $.fn.AjaxSlider = function (opts) { var settings = $.extend({ dataUrl : null, dataSel : '', contentSel : '', scrollBy: '100px', }, opts); var url = settings.dataUrl + ' ' + settings.dataSel; var $slider = this; var sliderW = this.width(); var sliderH = this.height(); this.load(url, function () { // fix width and height and hide overflow $slider.css({'width':sliderW, 'height':sliderH, 'overflow':'hidden', 'position':'relative'}); // content will be moved var $content = $slider.find(settings.contentSel); $content.css({'position':'absolute', 'left':'0'}); $slider.find('.slidebutton.prev').show().on('click', function () { $content.animate({'left':'+='+settings.scrollBy}, 'fast'); }); $slider.find('.slidebutton.next').show().on('click', function () { $content.animate({'left':'-='+settings.scrollBy}, 'fast'); }); }); } }(jQuery)); $(document).ready(function() { /* * autosubmit forms */ $('form.autosubmit').find('.autosubmit').change(function() { this.form.submit(); }); // hide submit button $('form.autosubmit input[type="submit"].autosubmit').hide(); /* * foldout divs * * foldable: .foldable is ancestor of .fold_head and .fold_body * that are folded simultaneously. * * foldableById: .foldableById is ancestor of multiple .fold_head and .fold_body * where each pair has a common unique .foldId_xxx. * * Clicking on .fold_head folds and unfolds .fold_body. * * If .foldable has .initially_open .fold_body is initially shown, else its * initally hidden. */ $('.foldable').each(function () { var $this = $(this); var $head = $this.find('.fold_head'); var $img = $head.find('img'); var $body = $this.find('.fold_body'); $head.on('click', function () { $body.slideToggle('fast'); $img.toggle(); }).css('cursor', 'pointer'); if (! $this.hasClass('initially_open')) { // hide body initially $body.hide(); $img.toggle(); } }); $('.foldableById').each(function () { var $container = $(this); var io = $container.hasClass('initially_open'); var $heads = $container.find('.fold_head'); $heads.each(function () { var $this = $(this); var $img = $this.find('img'); var id = null; // find id in class var cls = $this.attr('class').split(' '); for (var i = 0; i < cls.length; ++i) { var c = cls[i]; if (c.startsWith('foldId_')) { id = c; break; } } if (id == null) return; // get body using id var $body = $container.find('.fold_body.'+id); $this.on('click', function () { $body.slideToggle('fast'); $img.toggle(); }); if (!io) { // hide body initially $body.hide(); $img.toggle(); } }).css('cursor', 'pointer'); }); });