1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015 |
- (function ($) {
- Drupal.behaviors.overlayParent = {
- attach: function (context, settings) {
- if (Drupal.overlay.isOpen) {
- Drupal.overlay.makeDocumentUntabbable(context);
- }
- if (this.processed) {
- return;
- }
- this.processed = true;
- $(window)
-
- .bind('hashchange.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOperateByURLFragment'))
-
-
- .triggerHandler('hashchange.drupal-overlay');
- $(document)
-
-
-
-
- .bind('click.drupal-overlay mouseup.drupal-overlay', $.proxy(Drupal.overlay, 'eventhandlerOverrideLink'));
- }
- };
- Drupal.overlay = Drupal.overlay || {
- isOpen: false,
- isOpening: false,
- isClosing: false,
- isLoading: false
- };
- Drupal.overlay.prototype = {};
- Drupal.overlay.open = function (url) {
-
- if (this.isOpen || this.isOpening) {
- return this.load(url);
- }
- this.isOpening = true;
-
- this.originalTitle = document.title;
-
- this.create();
- this.isOpening = false;
- this.isOpen = true;
- $(document.documentElement).addClass('overlay-open');
- this.makeDocumentUntabbable();
-
- $(document).trigger('drupalOverlayOpen');
- return this.load(url);
- };
- Drupal.overlay.create = function () {
- this.$container = $(Drupal.theme('overlayContainer'))
- .appendTo(document.body);
-
-
-
-
-
-
-
- this.activeFrame = this.$iframeA = $(Drupal.theme('overlayElement'))
- .appendTo(this.$container);
- this.inactiveFrame = this.$iframeB = $(Drupal.theme('overlayElement'))
- .appendTo(this.$container);
- this.$iframeA.bind('load.drupal-overlay', { self: this.$iframeA[0], sibling: this.$iframeB }, $.proxy(this, 'loadChild'));
- this.$iframeB.bind('load.drupal-overlay', { self: this.$iframeB[0], sibling: this.$iframeA }, $.proxy(this, 'loadChild'));
-
-
- var eventClass = '.drupal-overlay.drupal-overlay-open';
- $(window)
- .bind('resize' + eventClass, $.proxy(this, 'eventhandlerOuterResize'));
- $(document)
- .bind('drupalOverlayLoad' + eventClass, $.proxy(this, 'eventhandlerOuterResize'))
- .bind('drupalOverlayReady' + eventClass +
- ' drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerSyncURLFragment'))
- .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRefreshPage'))
- .bind('drupalOverlayBeforeClose' + eventClass +
- ' drupalOverlayBeforeLoad' + eventClass +
- ' drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerDispatchEvent'));
- if ($('.overlay-displace-top, .overlay-displace-bottom').length) {
- $(document)
- .bind('drupalOverlayResize' + eventClass, $.proxy(this, 'eventhandlerAlterDisplacedElements'))
- .bind('drupalOverlayClose' + eventClass, $.proxy(this, 'eventhandlerRestoreDisplacedElements'));
- }
- };
- Drupal.overlay.load = function (url) {
- if (!this.isOpen) {
- return false;
- }
-
- $(document).trigger('drupalOverlayBeforeLoad');
- $(document.documentElement).addClass('overlay-loading');
-
- var iframeDocument = this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document;
-
-
-
- iframeDocument.location.replace(url);
- return true;
- };
- Drupal.overlay.close = function () {
-
- if (!this.isOpen || this.isClosing) {
- return false;
- }
-
- var event = $.Event('drupalOverlayBeforeClose');
- $(document).trigger(event);
-
- if (event.isDefaultPrevented()) {
- return false;
- }
- this.isClosing = true;
- this.isOpen = false;
- $(document.documentElement).removeClass('overlay-open');
-
- document.title = this.originalTitle;
- this.makeDocumentTabbable();
-
- $(document).trigger('drupalOverlayClose');
-
-
- if (!this.isLoading) {
- this.destroy();
- this.isClosing = false;
- }
- return true;
- };
- Drupal.overlay.destroy = function () {
- $([document, window]).unbind('.drupal-overlay-open');
- this.$container.remove();
- this.$container = null;
- this.$iframeA = null;
- this.$iframeB = null;
- this.iframeWindow = null;
- };
- Drupal.overlay.redirect = function (url) {
-
- var link = $(url.link(url)).get(0);
-
- if (window.location.href == link.href) {
- $(window).triggerHandler('hashchange.drupal-overlay');
- }
- window.location.href = link.href;
- return true;
- };
- Drupal.overlay.bindChild = function (iframeWindow, isClosing) {
- this.iframeWindow = iframeWindow;
-
- if (isClosing || this.isClosing || !this.isOpen) {
- return;
- }
-
- $(document).trigger('drupalOverlayReady');
- };
- Drupal.overlay.loadChild = function (event) {
- var iframe = event.data.self;
- var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
- var iframeWindow = iframeDocument.defaultView || iframeDocument.parentWindow;
- if (iframeWindow.location == 'about:blank') {
- return;
- }
- this.isLoading = false;
- $(document.documentElement).removeClass('overlay-loading');
- event.data.sibling.removeClass('overlay-active').attr({ 'tabindex': -1 });
-
- if (this.isOpen && !this.isClosing) {
-
- if (iframeWindow.Drupal && iframeWindow.Drupal.overlayChild) {
-
- document.title = iframeWindow.document.title;
- this.activeFrame = $(iframe)
- .addClass('overlay-active')
-
- .attr('title', Drupal.t('@title dialog', { '@title': iframeWindow.jQuery('#overlay-title').text() })).removeAttr('tabindex');
- this.inactiveFrame = event.data.sibling;
-
- (this.inactiveFrame[0].contentDocument || this.inactiveFrame[0].contentWindow.document).location.replace('about:blank');
-
-
- this.activeFrame.focus();
- var skipLink = iframeWindow.jQuery('a:first');
- Drupal.overlay.setFocusBefore(skipLink, iframeWindow.document);
-
- $(document).trigger('drupalOverlayLoad');
- }
- else {
- window.location = iframeWindow.location.href.replace(/([?&]?)render=overlay&?/g, '$1').replace(/\?$/, '');
- }
- }
- else {
- this.destroy();
- }
- };
- Drupal.overlay.setFocusBefore = function ($element, document) {
-
- var placeholder = document.createElement('a');
- var $placeholder = $(placeholder).addClass('element-invisible').attr('href', '#');
-
- $placeholder.insertBefore($element);
- $placeholder.focus();
-
-
- $placeholder.one('blur', function () {
- $(this).remove();
- });
- };
- Drupal.overlay.isAdminLink = function (url) {
- if (Drupal.overlay.isExternalLink(url)) {
- return false;
- }
- var path = this.getPath(url);
-
- if (!this.adminPathRegExp) {
- var prefix = '';
- if (Drupal.settings.overlay.pathPrefixes.length) {
-
-
- prefix = '(' + Drupal.settings.overlay.pathPrefixes.join('/|') + '/|)';
- }
- var adminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, '|') + ')$';
- var nonAdminPaths = '^' + prefix + '(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, '|') + ')$';
- adminPaths = adminPaths.replace(/\*/g, '.*');
- nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
- this.adminPathRegExp = new RegExp(adminPaths);
- this.nonAdminPathRegExp = new RegExp(nonAdminPaths);
- }
- return this.adminPathRegExp.exec(path) && !this.nonAdminPathRegExp.exec(path);
- };
- Drupal.overlay.isExternalLink = function (url) {
- var re = RegExp('^((f|ht)tps?:)?//(?!' + window.location.host + ')');
- return re.test(url);
- };
- Drupal.overlay.eventhandlerOuterResize = function (event) {
-
- if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
- return;
- }
-
- if (typeof document.body.style.maxHeight != 'string') {
- this.activeFrame.height($(window).height());
- }
-
- $(document).trigger('drupalOverlayResize');
- };
- Drupal.overlay.eventhandlerAlterDisplacedElements = function (event) {
-
- if (!(this.isOpen || this.isOpening) || this.isClosing || !this.iframeWindow) {
- return;
- }
- $(this.iframeWindow.document.body).css({
- marginTop: Drupal.overlay.getDisplacement('top'),
- marginBottom: Drupal.overlay.getDisplacement('bottom')
- })
-
-
- .addClass('overlay-trigger-reflow').removeClass('overlay-trigger-reflow');
- var documentHeight = this.iframeWindow.document.body.clientHeight;
- var documentWidth = this.iframeWindow.document.body.clientWidth;
-
- var maxWidthName = (typeof document.body.style.maxWidth == 'string') ? 'maxWidth' : 'width';
- if (Drupal.overlay.leftSidedScrollbarOffset === undefined && $(document.documentElement).attr('dir') === 'rtl') {
-
-
-
-
-
-
- if ($.browser.opera) {
- Drupal.overlay.leftSidedScrollbarOffset = document.documentElement.clientWidth - this.iframeWindow.document.documentElement.clientWidth + this.iframeWindow.document.documentElement.clientLeft;
- }
- else if (this.iframeWindow.document.documentElement.clientLeft) {
- Drupal.overlay.leftSidedScrollbarOffset = this.iframeWindow.document.documentElement.clientLeft;
- }
- else {
- var el1 = $('<div style="direction: rtl; overflow: scroll;"></div>').appendTo(document.body);
- var el2 = $('<div></div>').appendTo(el1);
- Drupal.overlay.leftSidedScrollbarOffset = parseInt(el2[0].offsetLeft - el1[0].offsetLeft);
- el1.remove();
- }
- }
-
-
- $('.overlay-displace-top, .overlay-displace-bottom').each(function () {
- var data = $(this).data();
- var maxWidth = documentWidth;
-
- if (this.filters && this.filters.length && this.filters.item('DXImageTransform.Microsoft.Shadow')) {
- maxWidth -= 1;
- }
- if (Drupal.overlay.leftSidedScrollbarOffset) {
- $(this).css('left', Drupal.overlay.leftSidedScrollbarOffset);
- }
-
- var currentMaxWidth = parseInt($(this).css(maxWidthName));
- if ((data.drupalOverlay && data.drupalOverlay.maxWidth) || isNaN(currentMaxWidth) || currentMaxWidth > maxWidth || currentMaxWidth <= 0) {
- $(this).css(maxWidthName, maxWidth);
- (data.drupalOverlay = data.drupalOverlay || {}).maxWidth = true;
- }
-
-
- var offset = $(this).offset();
- var offsetRight = offset.left + $(this).outerWidth();
- if ((data.drupalOverlay && data.drupalOverlay.clip) || offsetRight > maxWidth) {
- if (Drupal.overlay.leftSidedScrollbarOffset) {
- $(this).css('clip', 'rect(auto, auto, ' + (documentHeight - offset.top) + 'px, ' + (Drupal.overlay.leftSidedScrollbarOffset + 2) + 'px)');
- }
- else {
- $(this).css('clip', 'rect(auto, ' + (maxWidth - offset.left) + 'px, ' + (documentHeight - offset.top) + 'px, auto)');
- }
- (data.drupalOverlay = data.drupalOverlay || {}).clip = true;
- }
- });
- };
- Drupal.overlay.eventhandlerRestoreDisplacedElements = function (event) {
- var $displacedElements = $('.overlay-displace-top, .overlay-displace-bottom');
- try {
- $displacedElements.css({ maxWidth: '', clip: '' });
- }
-
- catch (err) {
- $displacedElements.attr('style', function (index, attr) {
- return attr.replace(/clip\s*:\s*rect\([^)]+\);?/i, '');
- });
- }
- };
- Drupal.overlay.eventhandlerOverrideLink = function (event) {
-
-
- if ((event.type == 'click' && event.button == 2) || (event.type == 'mouseup' && event.button != 2)) {
- return;
- }
- var $target = $(event.target);
-
- if (!$target.is('a')) {
- $target = $target.closest('a');
- if (!$target.length) {
- return;
- }
- }
-
- if ($target.hasClass('overlay-exclude')) {
- return;
- }
-
- if ($target.hasClass('overlay-close')) {
-
- $.bbq.removeState('overlay');
- return;
- }
- var target = $target[0];
- var href = target.href;
-
- if (href != undefined && href != '' && target.protocol.match(/^https?\:/)) {
- var anchor = href.replace(target.ownerDocument.location.href, '');
-
- if (anchor.length == 0 || anchor.charAt(0) == '#') {
- return;
- }
-
- else if (this.isAdminLink(href)) {
-
-
- var parentLocation = ($target.hasClass('overlay-restore') && typeof $.bbq.getState('overlay-context') == 'string')
- ? Drupal.settings.basePath + $.bbq.getState('overlay-context')
- : null;
- href = this.fragmentizeLink($target.get(0), parentLocation);
-
-
-
- if (event.button == 0 && !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
-
- this.redirect(href);
-
- return false;
- }
-
-
- else {
- $target
-
- .one('blur mousedown', { target: target, href: target.href }, function (event) { $(event.data.target).attr('href', event.data.href); })
- .attr('href', href);
- }
- }
-
-
-
- else if (this.isOpen && target.ownerDocument === this.iframeWindow.document) {
-
-
- if (target.hostname != window.location.hostname) {
- if (!$target.attr('target')) {
- $target.attr('target', '_parent');
- }
- }
- else {
-
-
- if ($target[0].hash) {
-
-
- }
- else {
-
- $target.attr('href', $.param.fragment(href, { 'overlay-context': this.getPath(window.location) + window.location.search }));
- }
-
-
-
- var params = $.deparam.querystring(href);
- if (params.destination && this.isAdminLink(params.destination)) {
- var fragmentizedDestination = $.param.fragment(this.getPath(window.location), { overlay: params.destination });
- $target.attr('href', $.param.querystring(href, { destination: fragmentizedDestination }));
- }
-
-
- if (!$target.attr('target')) {
- $target.attr('target', '_parent');
- }
- }
- }
- }
- };
- Drupal.overlay.eventhandlerOperateByURLFragment = function (event) {
-
-
- if ($.data(window.location, window.location.href) === 'redirect') {
- $.data(window.location, window.location.href, null);
- return;
- }
-
- var state = $.bbq.getState('overlay');
- if (state) {
-
-
- var url = $.param.querystring(Drupal.settings.basePath + state, { render: 'overlay' });
- this.open(url);
- this.resetActiveClass(this.getPath(Drupal.settings.basePath + state));
- }
-
-
- else if (this.isOpen && !this.isClosing) {
- this.close();
- this.resetActiveClass(this.getPath(window.location));
- }
- };
- Drupal.overlay.eventhandlerSyncURLFragment = function (event) {
- if (this.isOpen) {
- var expected = $.bbq.getState('overlay');
-
- if (this.getPath(Drupal.settings.basePath + expected) != this.getPath(this.iframeWindow.document.location)) {
-
-
- var newLocation = Drupal.overlay.fragmentizeLink(this.iframeWindow.document.location);
-
-
- $.data(window.location, newLocation, 'redirect');
-
- window.location.replace(newLocation);
- }
- }
- else {
- $.bbq.removeState('overlay');
- }
- };
- Drupal.overlay.eventhandlerRefreshPage = function (event) {
- if (Drupal.overlay.refreshPage) {
- window.location.reload(true);
- }
- };
- Drupal.overlay.eventhandlerDispatchEvent = function (event) {
- if (this.iframeWindow && this.iframeWindow.document) {
- this.iframeWindow.jQuery(this.iframeWindow.document).trigger(event);
- }
- };
- Drupal.overlay.fragmentizeLink = function (link, parentLocation) {
-
- var params = $.deparam.fragment(link.href);
- if (params.overlay) {
- return link.href;
- }
-
-
-
- var path = this.getPath(link, true);
-
-
- var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
-
- return $.param.fragment(parentLocation || window.location.href, { overlay: destination });
- };
- Drupal.overlay.refreshRegions = function (data) {
- $.each(data, function () {
- var region_info = this;
- $.each(region_info, function (regionClass) {
- var regionName = region_info[regionClass];
- var regionSelector = '.' + regionClass;
-
- Drupal.detachBehaviors($(regionSelector));
- $.get(Drupal.settings.basePath + Drupal.settings.overlay.ajaxCallback + '/' + regionName, function (newElement) {
- $(regionSelector).replaceWith($(newElement));
- Drupal.attachBehaviors($(regionSelector), Drupal.settings);
- });
- });
- });
- };
- Drupal.overlay.resetActiveClass = function(activePath) {
- var self = this;
- var windowDomain = window.location.protocol + window.location.hostname;
- $('.overlay-displace-top, .overlay-displace-bottom')
- .find('a[href]')
-
- .removeClass('active')
-
- .each(function () {
- var linkDomain = this.protocol + this.hostname;
- var linkPath = self.getPath(this);
-
-
- if (linkDomain == windowDomain && (activePath + '/').indexOf(linkPath + '/') === 0 && (linkPath !== '' || activePath === '')) {
- $(this).addClass('active');
- }
- });
- };
- Drupal.overlay.getPath = function (link, ignorePathFromQueryString) {
- if (typeof link == 'string') {
-
- link = $(link.link(link)).get(0);
- }
- var path = link.pathname;
-
- if (path.charAt(0) != '/') {
- path = '/' + path;
- }
- path = path.replace(new RegExp(Drupal.settings.basePath + '(?:index.php)?'), '');
- if (path == '' && !ignorePathFromQueryString) {
-
-
- var match = new RegExp('([?&])q=(.+)([&#]|$)').exec(link.search);
- if (match && match.length == 4) {
- path = match[2];
- }
- }
- return path;
- };
- Drupal.overlay.getDisplacement = function (region) {
- var displacement = 0;
- var lastDisplaced = $('.overlay-displace-' + region + ':last');
- if (lastDisplaced.length) {
- displacement = lastDisplaced.offset().top + lastDisplaced.outerHeight();
-
-
- var cssBoxShadowValue = lastDisplaced.css('box-shadow');
- var boxShadow = (typeof cssBoxShadowValue !== 'undefined' && cssBoxShadowValue !== 'none');
-
-
- if (!boxShadow && /DXImageTransform\.Microsoft\.Shadow/.test(lastDisplaced.css('filter'))) {
- displacement -= lastDisplaced[0].filters.item('DXImageTransform.Microsoft.Shadow').strength;
- displacement = Math.max(0, displacement);
- }
- }
- return displacement;
- };
- Drupal.overlay.makeDocumentUntabbable = function (context) {
-
-
-
-
-
-
-
- if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
- $('#overlay-disable-message a', context).attr('tabindex', -1);
- return;
- }
- context = context || document.body;
- var $overlay, $tabbable, $hasTabindex;
-
- $hasTabindex = $('[tabindex] :not(.overlay-element)', context);
-
- $hasTabindex.each(Drupal.overlay._recordTabindex);
-
-
- Drupal.overlay._hasTabindex = $hasTabindex.add(Drupal.overlay._hasTabindex);
-
-
-
-
- $tabbable = $('a, area, button, input, object, select, textarea, iframe');
-
- $tabbable = $tabbable.add($hasTabindex);
-
- $overlay = $('.overlay-element, #overlay-container, .overlay-displace-top, .overlay-displace-bottom').find('*');
- $tabbable = $tabbable.not($overlay);
-
-
- $tabbable.attr('tabindex', -1);
- };
- Drupal.overlay.makeDocumentTabbable = function (context) {
-
-
-
- if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
- return;
- }
- var $needsTabindex;
- context = context || document.body;
-
-
- var $tabindex = $('[tabindex]', context);
- if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 8) {
-
-
- var i;
- var length = $tabindex.length;
- for (i = 0; i < length; i++) {
- $tabindex[i].removeAttribute('tabIndex');
- }
- }
- else {
- $tabindex.removeAttr('tabindex');
- }
-
- $needsTabindex = $(Drupal.overlay._hasTabindex, context);
- $needsTabindex.each(Drupal.overlay._restoreTabindex);
- Drupal.overlay._hasTabindex = Drupal.overlay._hasTabindex.not($needsTabindex);
- };
- Drupal.overlay._recordTabindex = function () {
- var $element = $(this);
- var tabindex = $(this).attr('tabindex');
- $element.data('drupalOverlayOriginalTabIndex', tabindex);
- };
- Drupal.overlay._restoreTabindex = function () {
- var $element = $(this);
- var tabindex = $element.data('drupalOverlayOriginalTabIndex');
- $element.attr('tabindex', tabindex);
- };
- Drupal.theme.prototype.overlayContainer = function () {
- return '<div id="overlay-container"><div class="overlay-modal-background"></div></div>';
- };
- Drupal.theme.prototype.overlayElement = function (url) {
- return '<iframe class="overlay-element" frameborder="0" scrolling="auto" allowtransparency="true"></iframe>';
- };
- })(jQuery);
|