123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041 |
- (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.urlIsLocal(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) {
- return !Drupal.urlIsLocal(url);
- };
- Drupal.overlay.getInternalUrl = function (path) {
- var url = Drupal.settings.basePath + path;
- if (Drupal.urlIsLocal(url)) {
- return 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')
- ? this.getInternalUrl($.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 internalUrl = null;
- var state = $.bbq.getState('overlay');
- if (state) {
- internalUrl = this.getInternalUrl(state);
- }
- if (internalUrl) {
-
-
- var url = $.param.querystring(internalUrl, { 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);
|