Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Fixed controller contexts in LeftAndMain->SiteTreeAsUL() - need…

…s different context for edit links and determining "current page" (not applicable for CMSPagesController)
  • Loading branch information...
commit 473d3a66b8be0540bcf92fb1e879a1c1d90ae05d 1 parent 761bae3
@chillu chillu authored
View
25 admin/code/LeftAndMain.php
@@ -624,19 +624,22 @@ function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $num
}
// getChildrenAsUL is a flexible and complex way of traversing the tree
- $titleEval = '
- "<li id=\"record-$child->ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
- "<ins class=\"jstree-icon\">&nbsp;</ins>" .
- "<a href=\"" . Controller::join_links($extraArg->Link("show"), $child->ID) . "\" title=\"'
- . _t('LeftAndMain.PAGETYPE','Page type: ')
- . '".$child->class."\" ><ins class=\"jstree-icon\">&nbsp;</ins><span class=\"text\">" . ($child->TreeTitle) .
- "</span></a>"
- ';
-
+ $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 "<li id=\"record-$child->ID\" data-id=\"$child->ID\" data-ssclass=\"$child->ClassName\" class=\"" . $classes . "\">" .
+ "<ins class=\"jstree-icon\">&nbsp;</ins>" .
+ "<a href=\"" . Controller::join_links($recordController->Link("show"), $child->ID) . "\" title=\"'
+ . _t('LeftAndMain.PAGETYPE','Page type: ')
+ . '".$child->class."\" ><ins class=\"jstree-icon\">&nbsp;</ins><span class=\"text\">" . ($child->TreeTitle) .
+ "</span></a>";
+ };
$html = $obj->getChildrenAsUL(
"",
- $titleEval,
- singleton('CMSPageEditController'),
+ $titleFn,
+ singleton('CMSPagesController'),
true,
$childrenMethod,
$numChildrenMethod,
View
4 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; }
View
15 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('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
},
View
49 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));
View
6 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;
View
1  admin/scss/_uitheme.scss
@@ -39,7 +39,6 @@
.ui-tabs-panel {
background: transparent; // default it's white
- padding: 0;
}
}
View
5 filesystem/Folder.php
@@ -433,15 +433,12 @@ function ChildFolders() {
/**
* @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";
Please sign in to comment.
Something went wrong with that request. Please try again.