diff --git includes/batch.inc includes/batch.inc index 3ffebdd..456bb33 100644 --- includes/batch.inc +++ includes/batch.inc @@ -109,11 +109,20 @@ function _batch_progress_page_js() { $current_set = _batch_current_set(); drupal_set_title($current_set['title'], PASS_THROUGH); + // Add ?id=x to the batch URL. + $url_options = $batch['url_options']; + if (isset($url_options['query'])) { + $url_options['query']['id'] = $batch['id']; + } + else { + $url_options['query'] = array('id' => $batch['id']); + } + $js_setting = array( 'batch' => array( 'errorMessage' => $current_set['error_message'] . '
' . $batch['error_message'], 'initMessage' => $current_set['init_message'], - 'uri' => url($batch['url'], array('query' => array('id' => $batch['id']))), + 'uri' => url($batch['url'], $url_options), ), ); drupal_add_js($js_setting, 'setting'); @@ -189,7 +198,17 @@ function _batch_progress_page_nojs() { ob_end_clean(); } - $url = url($batch['url'], array('query' => array('id' => $batch['id'], 'op' => $new_op))); + // Add ?id=x&op=y to the batch URL. + $url_options = $batch['url_options']; + if (isset($url_options['query'])) { + $url_options['query']['id'] = $batch['id']; + $url_options['query']['op'] = $new_op; + } + else { + $url_options['query'] = array('id' => $batch['id'], 'op' => $new_op); + } + + $url = url($batch['url'], $url_options); drupal_add_html_head(''); return theme('progress_bar', array('percent' => $percentage, 'message' => $message)); diff --git includes/form.inc includes/form.inc index bf91d98..141996a 100644 --- includes/form.inc +++ includes/form.inc @@ -3051,6 +3051,7 @@ function batch_process($redirect = NULL, $url = 'batch', $redirect_callback = 'd 'current_set' => 0, 'progressive' => TRUE, 'url' => $url, + 'url_options' => array(), 'source_page' => $_GET['q'], 'redirect' => $redirect, 'theme' => $GLOBALS['theme_key'], diff --git misc/drupal.js misc/drupal.js index f3a7d2b..4020031 100644 --- misc/drupal.js +++ misc/drupal.js @@ -344,4 +344,11 @@ Drupal.theme.prototype = { } }; +/** + * Check if the given variable is an object. + */ +Drupal.isObject = function(something) { + return (something !== null && typeof something === 'object'); +}; + })(jQuery); diff --git misc/tableheader.js misc/tableheader.js index 8a68266..09e2584 100644 --- misc/tableheader.js +++ misc/tableheader.js @@ -18,8 +18,9 @@ Drupal.behaviors.tableHeader = { var headers = []; $('table.sticky-enabled thead', context).once('tableheader', function () { - // Clone thead so it inherits original jQuery properties. - var headerClone = $(this).clone(true).insertBefore(this.parentNode).wrap('').parent().css({ + // Clone the table header so it inherits original jQuery properties. Hide + // the table to avoid a flash of the header clone upon page load. + var headerClone = $(this).clone(true).hide().insertBefore(this.parentNode).wrap('').parent().css({ position: 'fixed', top: '0px' }); @@ -32,6 +33,9 @@ Drupal.behaviors.tableHeader = { headerClone.table = table; // Finish initializing header positioning. tracker(headerClone); + // We hid the header to avoid it showing up erroneously on page load; + // we need to unhide it now so that it will show up when expected. + $(headerClone).children('thead').show(); $(table).addClass('sticky-table'); }); diff --git modules/dashboard/dashboard.css modules/dashboard/dashboard.css index 05980a8..69d38f8 100644 --- modules/dashboard/dashboard.css +++ modules/dashboard/dashboard.css @@ -64,9 +64,11 @@ border: 0; } -#dashboard .canvas-content input { +#dashboard .canvas-content a.button { float: right; margin: 0 0 0 10px; + color: #5a5a5a; + text-decoration: none; } #dashboard .region { diff --git modules/dashboard/dashboard.js modules/dashboard/dashboard.js index fedb542..2af23ad 100644 --- modules/dashboard/dashboard.js +++ modules/dashboard/dashboard.js @@ -65,7 +65,7 @@ Drupal.behaviors.dashboard = { * Helper for enterCustomizeMode; sets up drag-and-drop and close button. */ setupDrawer: function () { - $('div.customize .canvas-content').prepend(''); + $('div.customize .canvas-content').prepend('' + Drupal.t('Done') + ''); $('div.customize .canvas-content input').click(Drupal.behaviors.dashboard.exitCustomizeMode); // Initialize drag-and-drop. diff --git modules/locale/locale.test modules/locale/locale.test index ba92516..5760f44 100644 --- modules/locale/locale.test +++ modules/locale/locale.test @@ -237,7 +237,7 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase { $this->clickLink(t('edit')); // We save the lid from the path. $matches = array(); - preg_match('!admin/config/regional/translate/edit/(\d)+!', $this->getUrl(), $matches); + preg_match('!admin/config/regional/translate/edit/(\d+)!', $this->getUrl(), $matches); $lid = $matches[1]; // No t() here, it's surely not translated yet. $this->assertText($name, t('name found on edit screen.')); diff --git modules/overlay/overlay-child.js modules/overlay/overlay-child.js new file mode 100644 index 0000000..b27d775 --- /dev/null +++ modules/overlay/overlay-child.js @@ -0,0 +1,138 @@ +// $Id: child.js,v 1.1.4.3 2009/06/17 15:16:26 markuspetrux Exp $ + +(function ($) { + +/** + * Overlay object for child windows. + */ +Drupal.overlayChild = Drupal.overlayChild || { processed: false, behaviors: {} }; + +/** + * Attach the child dialog behavior to new content. + */ +Drupal.behaviors.overlayChild = { + attach: function (context, settings) { + var self = Drupal.overlayChild; + var settings = settings.overlayChild || {}; + + // Make sure this behavior is not processed more than once. + if (self.processed) { + return; + } + self.processed = true; + + // If we cannot reach the parent window, then we have nothing else to do + // here. + if (!Drupal.isObject(parent.Drupal) || !Drupal.isObject(parent.Drupal.overlay)) { + return; + } + + // If a form has been submitted successfully, then the server side script + // may have decided to tell us the parent window to close the popup dialog. + if (settings.closeOverlay) { + parent.Drupal.overlay.bindChild(window, true); + // Close the child window from a separate thread because the current + // one is busy processing Drupal behaviors. + setTimeout(function () { + // We need to store the parent variable locally because it will + // disappear as soon as we close the iframe. + var p = parent; + p.Drupal.overlay.close(settings.args, settings.statusMessages); + if (typeof settings.redirect == 'string') { + p.Drupal.overlay.redirect(settings.redirect); + } + }, 1); + return; + } + + // Ok, now we can tell the parent window we're ready. + parent.Drupal.overlay.bindChild(window); + + // Install onBeforeUnload callback, if module is present. + if (Drupal.isObject(Drupal.onBeforeUnload) && !Drupal.onBeforeUnload.callbackExists('overlayChild')) { + Drupal.onBeforeUnload.addCallback('overlayChild', function () { + // Tell the parent window we're unloading. + parent.Drupal.overlay.unbindChild(window); + }); + } + + // Attach child related behaviors to the iframe document. + self.attachBehaviors(context, settings); + } +}; + +/** + * Attach child related behaviors to the iframe document. + */ +Drupal.overlayChild.attachBehaviors = function (context, settings) { + $.each(this.behaviors, function () { + this(context, settings); + }); +}; + +/** + * Scroll to the top of the page. + * + * This makes the overlay visible to users even if it is not as tall as the + * previously shown overlay was. + */ +Drupal.overlayChild.behaviors.scrollToTop = function (context, settings) { + window.scrollTo(0, 0); +}; + +/** + * Modify links and forms depending on their relation to the overlay. + * + * By default, forms and links are assumed to keep the flow in the overlay. + * Thus their action and href attributes respectively get a ?render=overlay + * suffix. Non-administrative links should however close the overlay and + * redirect the parent page to the given link. This would include links in a + * content listing, where administration options are mixed with links to the + * actual content to be shown on the site out of the overlay. + * + * @see Drupal.overlay.isAdminLink() + */ +Drupal.overlayChild.behaviors.parseLinks = function (context, settings) { + $('a:not(.overlay-exclude)', context).once('overlay').each(function () { + // Non-admin links should close the overlay and open in the main window. + if (!parent.Drupal.overlay.isAdminLink(this.href)) { + $(this).click(function () { + // We need to store the parent variable locally because it will + // disappear as soon as we close the iframe. + var parentWindow = parent; + if (parentWindow.Drupal.overlay.close(false)) { + parentWindow.Drupal.overlay.redirect($(this).attr('href')); + } + return false; + }); + return; + } + else { + var href = $(this).attr('href'); + if (href.indexOf('http') > 0 || href.indexOf('https') > 0) { + $(this).attr('target', '_new'); + } + else { + $(this).click(function () { + var linkURL = parent.Drupal.overlay.addOverlayParam($(this).attr('href')); + parent.Drupal.overlay.load(linkURL); + return false; + }); + } + } + }); + $('form:not(.overlay-processed)', context).addClass('overlay-processed').each(function () { + // Obtain the action attribute of the form. + var action = $(this).attr('action'); + if (action.indexOf('http') != 0 && action.indexOf('https') != 0) { + // Keep internal forms in the overlay. + action += (action.indexOf('?') > -1 ? '&' : '?') + 'render=overlay'; + $(this).attr('action', action); + } + else { + $(this).attr('target', '_new'); + } + }); +}; + +})(jQuery); diff --git modules/overlay/overlay-parent.css modules/overlay/overlay-parent.css new file mode 100644 index 0000000..448c5bc --- /dev/null +++ modules/overlay/overlay-parent.css @@ -0,0 +1,123 @@ +/* $Id$ */ + +/** + * ui-dialog overlay. + */ +.ui-widget-overlay { + background-color: #000; + opacity: 0.7; + filter: alpha(opacity=80); + background-image: none; +} + +/** + * jQuery UI Dialog classes. + */ +.overlay { + padding-right: 26px; +} + +.overlay.ui-widget-content, .overlay .ui-widget-header { + background: none; + border: none; +} + +.overlay .ui-dialog-titlebar { + white-space: nowrap; + padding: 0 20px; +} + +.overlay .ui-dialog-title { + font-family: Verdana,sans-serif; + margin: 0; + padding: 0.3em 0; + color: #fff; + font-size: 20px; +} +.overlay .ui-dialog-title:active, +.overlay .ui-dialog-title:focus { + outline: 0; +} +.overlay .ui-dialog-titlebar-close, +.overlay .ui-dialog-titlebar-close:hover { + display: block; + right: -25px; + top: 100%; + margin: 0; + border: none; + padding: 0; + width: 26px; + height: 36px; + background: transparent url(images/close.png) no-repeat; + -moz-border-radius-topleft: 0; + -webkit-border-top-left-radius: 0; +} +.overlay .ui-dialog-titlebar-close span { + display: none; +} +.overlay .ui-dialog-content { + color: #292929; + background-color: #f8f8f8; +} + +/** + * Overlay content and shadows. + */ +.overlay #overlay-container { + margin: 0; + padding: 0; + overflow: visible; + background: #fff url(images/loading.gif) no-repeat 50% 50%; + -webkit-box-shadow: 8px 8px 8px rgba(0,0,0,.5); + -moz-box-shadow: 8px 8px 8px rgba(0,0,0,.5); + box-shadow: 8px 8px 8px rgba(0,0,0,.5); +} +.overlay #overlay-element { + overflow: hidden; +} + +/** + * Tabs on the overlay. + */ +.overlay .ui-dialog-titlebar ul { + position: absolute; + right: 20px; + bottom: 0; + margin: 0; + line-height: 27px; + text-transform: uppercase; +} +.overlay .ui-dialog-titlebar ul li { + display: inline-block; + list-style: none; + margin: 0 0 0 -3px; + padding: 0; +} +.overlay .ui-dialog-titlebar ul li a, +.overlay .ui-dialog-titlebar ul li a:active, +.overlay .ui-dialog-titlebar ul li a:visited, +.overlay .ui-dialog-titlebar ul li a:hover { + background-color: #a6a7a2; + -moz-border-radius: 8px 8px 0 0; + -webkit-border-top-left-radius: 8px; + -webkit-border-top-right-radius: 8px; + border-radius: 8px 8px 0 0; + color: #000; + font-weight: bold; + padding: 5px 14px; + text-decoration: none; + font-size: 11px; +} +.overlay .ui-dialog-titlebar ul li.active a, +.overlay .ui-dialog-titlebar ul li.active a.active, +.overlay .ui-dialog-titlebar ul li.active a:active, +.overlay .ui-dialog-titlebar ul li.active a:visited { + background-color: #fff; + padding-bottom: 7px; +} +.overlay .ui-dialog-titlebar ul li a:hover { + color: #fff; +} +.overlay .ui-dialog-titlebar ul li.active a:hover { + color: #000; +} diff --git modules/overlay/overlay-parent.js modules/overlay/overlay-parent.js new file mode 100644 index 0000000..3af30cc --- /dev/null +++ modules/overlay/overlay-parent.js @@ -0,0 +1,764 @@ +// $Id: parent.js,v 1.1.4.4 2009/06/19 15:32:57 markuspetrux Exp $ + +(function ($) { + +/** + * Open or modify overlay based on clicks of links marked with .to-overlay. + */ +Drupal.behaviors.overlayParent = { + attach: function (context, settings) { + // Attach on all admin links without the 'overlay-exclude' class. + $('a:not(.overlay-exclude)').filter(function () { + return Drupal.overlay.isAdminLink(this.href); + }) + // Respond to their click event. + .once('overlay').click(function () { + + // Append render variable, so the server side can choose the right + // rendering and add child modal frame code to the page if needed. + var linkURL = Drupal.overlay.addOverlayParam($(this).attr('href')); + + // If the modal frame is already open, replace the loaded document with + // this new one. Keeps browser history. + if (Drupal.overlay.isOpen) { + Drupal.overlay.load(linkURL); + return false; + } + + // There is not an overlay opened yet, we should open a new one. + var overlayOptions = { + url: linkURL, + + // Remove active class from all header buttons. + onOverlayClose: function () { + $('a.to-overlay').each(function () { + $(this).removeClass('active'); + }); + }, + draggable: false + }; + Drupal.overlay.open(overlayOptions); + + // Prevent default action of the link click event. + return false; + }); + + // Automatically open an overlay if defined in Drupal.settings.overlay.autoOpen. + if (Drupal.settings.overlay.autoOpen) { + var linkURL = Drupal.overlay.addOverlayParam(Drupal.settings.overlay.autoOpen); + + // Unset autoOpen to prevent looping. + delete Drupal.settings.overlay.autoOpen; + + // If the modal frame is already open, replace the loaded document with + // this new one. Keeps browser history. + if (Drupal.overlay.isOpen) { + Drupal.overlay.load(linkURL); + return false; + } + + // There is not an overlay opened yet, we should open a new one. + var overlayOptions = { + url: linkURL, + + // Remove active class from all header buttons. + onOverlayClose: function () { + $('a.to-overlay').each(function () { + $(this).removeClass('active'); + }); + }, + draggable: false + }; + Drupal.overlay.open(overlayOptions); + } + } +}; + +/** + * Overlay object for parent windows. + */ +Drupal.overlay = Drupal.overlay || { + options: {}, + iframe: { $container: null, $element: null }, + isOpen: false +}; + +/** + * Open an overlay. + * + * Ensure that only one overlay is opened ever. Use Drupal.overlay.load() if + * the overlay is already open but a new page needs to be opened. + * + * @param options + * Properties of the overlay to open: + * - url: the URL of the page to open in the overlay. + * - width: width of the overlay in pixels. + * - height: height of the overlay in pixels. + * - autoFit: boolean indicating whether the overlay should be resized to + * fit the contents of the document loaded. + * - onOverlayOpen: callback to invoke when the overlay is opened. + * - onOverlayCanClose: callback to allow external scripts decide if the + * overlay can be closed. + * - onOverlayClose: callback to invoke when the overlay is closed. + * - customDialogOptions: an object with custom jQuery UI Dialog options. + * + * @return + * If the overlay was opened true, otherwise false. + */ +Drupal.overlay.open = function (options) { + var self = this; + + // Just one overlay is allowed. + if (self.isOpen || $('#overlay-container').size()) { + return false; + } + + var defaultOptions = { + url: options.url, + width: options.width, + height: options.height, + autoFit: (options.autoFit == undefined || options.autoFit), + onOverlayOpen: options.onOverlayOpen, + onOverlayCanClose: options.onOverlayCanClose, + onOverlayClose: options.onOverlayClose, + customDialogOptions: options.customDialogOptions || {} + } + + self.options = $.extend(defaultOptions, options); + + // Create the dialog and related DOM elements. + self.create(); + + // Open the dialog offscreen where we can set its size, etc. + self.iframe.$container.dialog('option', { position: ['-999em', '-999em'] }).dialog('open'); + + return true; +}; + +/** + * Create the underlying markup and behaviors for the overlay. + * + * Reuses jQuery UI's dialog component to construct the overlay markup and + * behaviors, sanitizing the options previously set in self.options. + */ +Drupal.overlay.create = function () { + var self = this; + + // Note: We use scrolling="yes" for IE as a workaround to yet another IE bug + // where the horizontal scrollbar is always rendered no matter how wide the + // iframe element is defined. + self.iframe.$element = $('