diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index cc060a227..22fa1d688 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -624,19 +624,22 @@ class LeftAndMain extends Controller implements PermissionProvider { } // getChildrenAsUL is a flexible and complex way of traversing the tree - $titleEval = ' - "
  • ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" . - " " . - "Link("show"), $child->ID) . "\" title=\"' - . _t('LeftAndMain.PAGETYPE','Page type: ') - . '".$child->class."\" > " . ($child->TreeTitle) . - "" - '; - + $controller = $this; + $recordController = ($this->stat('tree_class') == 'SiteTree') ? singleton('CMSPageEditController') : $this; + $titleFn = function(&$child) use(&$controller, &$recordController) { + $classes = $child->CMSTreeClasses(); + if($controller->isCurrentPage($child)) $classes .= " current"; + return "
  • ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $classes . "\">" . + " " . + "Link("show"), $child->ID) . "\" title=\"' + . _t('LeftAndMain.PAGETYPE','Page type: ') + . '".$child->class."\" > " . ($child->TreeTitle) . + ""; + }; $html = $obj->getChildrenAsUL( "", - $titleEval, - singleton('CMSPageEditController'), + $titleFn, + singleton('CMSPagesController'), true, $childrenMethod, $numChildrenMethod, diff --git a/admin/css/screen.css b/admin/css/screen.css index 4c65f18b8..e3efff62a 100644 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -263,8 +263,8 @@ body.cms { overflow: hidden; } .cms-content-header h2 { padding: 8px 8px 0 8px; font-size: 14px; line-height: 24px; font-weight: bold; text-shadow: #bfcad2 1px 1px 0; margin: 0; display: table-cell; vertical-align: top; width: 100%; } .cms-content-header h2 .breadcrumbs-wrapper { display: table-row; } .cms-content-header h2 .breadcrumbs-wrapper .crumb { display: table-cell; line-height: 26px; } -.cms-content-header div { display: table-row; } -.cms-content-header div .cms_backlink { display: table-cell; vertical-align: middle; width: auto; } +.cms-content-header > div { display: table; } +.cms-content-header > div .cms_backlink { display: table-cell; vertical-align: middle; width: auto; } .cms-content-header .cms-content-header-tabs { display: table-cell; white-space: nowrap; width: 100%; } .cms-content-header .cms-content-header-tabs .ui-tabs-nav { float: right; margin-right: 32px; } .cms-content-header .cms-content-header-tabs .ui-tabs-nav li a { font-weight: bold; line-height: 16px; padding: 12px 20px 12px; } diff --git a/admin/javascript/LeftAndMain.Content.js b/admin/javascript/LeftAndMain.Content.js index 2a5a9104e..f361e052f 100644 --- a/admin/javascript/LeftAndMain.Content.js +++ b/admin/javascript/LeftAndMain.Content.js @@ -222,21 +222,20 @@ var url = $(node).find('a:first').attr('href'); if(url && url != '#') { + // Ensure URL is absolute (important for IE) if($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href')); - // Reload only edit form if it exists (side-by-side view of tree and edit view), otherwise reload whole panel - if(container.find('.cms-edit-form').length) { - container.entwine('ss').loadPanel(url, null, {selector: '.cms-edit-form', pjax: 'CurrentForm'}); - } else { - container.entwine('ss').loadPanel(url); - } + // Retain search parameters + if(document.location.search) url = $.path.addSearchParams(url, document.location.search.replace(/^\?/, '')); + // Load new page + container.entwine('ss').loadPanel(url); } else { self.removeForm(); } }); } }); - - $('.cms-content.loading,.cms-edit-form.loading').entwine({ + + $('.cms-content.loading,.cms-edit-form.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({ onmatch: function() { this.append('
    '); }, diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index b8cf28723..702b5db47 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -610,6 +610,55 @@ jQuery.noConflict(); } } }); + + /** + * Lightweight wrapper around jQuery UI tabs. + * Ensures that anchor links are set properly, + * and any nested tabs are scrolled if they have + * their height explicitly set. This is important + * for forms inside the CMS layout. + */ + $('.cms-tabset').entwine({ + onmatch: function() { + // Can't name redraw() as it clashes with other CMS entwine classes + this.redrawTabs(); + this._super(); + }, + + redrawTabs: function() { + this.rewriteHashlinks(); + + var id = this.attr('id'), cookieId = 'ui-tabs-' + id, + selectedTab = this.find('ul:first .ui-state-selected'); + + // Fix for wrong cookie storage of deselected tabs + if($.cookie && id && $.cookie(cookieId) == -1) $.cookie(cookieId, 0); + this.tabs({ + cookie: ($.cookie && id) ? { expires: 30, path: '/', name: cookieId } : false, + ajaxOptions: { + // Overwrite ajax loading to use CMS logic instead + beforeSend: function(xhr, settings) { + $('.cms-container').entwine('ss').loadPanel(settings.url); + return false; + } + }, + selected: (selectedTab.index() != -1) ? selectedTab.index() : 0 + }); + }, + + /** + * Replace prefixes for all hashlinks in tabs. + * SSViewer rewrites them from "#Root_MyTab" to + * e.g. "/admin/#Root_MyTab" which makes them + * unusable for jQuery UI. + */ + rewriteHashlinks: function() { + $(this).find('ul a').each(function() { + var href = $(this).attr('href').replace(/.*(#.*)/, '$1'); + if(href) $(this).attr('href', href); + }); + } + }); }(jQuery)); diff --git a/admin/scss/_style.scss b/admin/scss/_style.scss index 749d676a5..5da7b6b43 100644 --- a/admin/scss/_style.scss +++ b/admin/scss/_style.scss @@ -126,9 +126,9 @@ body.cms { } } - & div { - display:table-row; - & .cms_backlink { + & > div { + display:table; + .cms_backlink { display:table-cell; vertical-align:middle; width:auto; diff --git a/admin/scss/_uitheme.scss b/admin/scss/_uitheme.scss index adc8efc94..62ddf95da 100644 --- a/admin/scss/_uitheme.scss +++ b/admin/scss/_uitheme.scss @@ -39,7 +39,6 @@ .ui-tabs-panel { background: transparent; // default it's white - padding: 0; } } diff --git a/filesystem/Folder.php b/filesystem/Folder.php index bf2b0d3db..8f5b98f1e 100644 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -433,15 +433,12 @@ class Folder extends File { /** * @return String */ - function CMSTreeClasses($controller) { + function CMSTreeClasses() { $classes = sprintf('class-%s', $this->class); if(!$this->canDelete()) $classes .= " nodelete"; - if($controller->isCurrentPage($this)) - $classes .= " current"; - if(!$this->canEdit()) $classes .= " disabled";