mirror of
https://github.com/jonom/silverstripe-betternavigator.git
synced 2024-10-22 14:05:51 +02:00
parent
e23a257b37
commit
bfa6a310b6
@ -26,6 +26,7 @@ span[class^='bn-icon'], span[class*=' bn-icon'] { display: inline-block; }
|
||||
|
||||
#BetterNavigator { position: fixed; top: 0; right: 0; z-index: 99999; max-height: 100%; overflow: auto; font-family: Helvetica, Arial, sans-serif; font-size: 12px; line-height: 16px; text-align: left; }
|
||||
#BetterNavigator a { text-decoration: none; }
|
||||
#BetterNavigator form { display: none; }
|
||||
#BetterNavigator.collapsed { box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.5); -moz-transform-origin: right top; -ms-transform-origin: right top; -webkit-transform-origin: right top; transform-origin: right top; -moz-transform: rotate(90deg) translate(100%, 0); -ms-transform: rotate(90deg) translate(100%, 0); -webkit-transform: rotate(90deg) translate(100%, 0); transform: rotate(90deg) translate(100%, 0); border-width: 0 1px 1px 0; }
|
||||
#BetterNavigator.collapsed #BetterNavigatorStatus { border-width: 0 1px 1px 0; }
|
||||
#BetterNavigator.collapsed #BetterNavigatorStatus .bn-icon-close { display: none; }
|
||||
|
@ -1,4 +1,4 @@
|
||||
//For reading cookies
|
||||
// For reading cookies
|
||||
function getCookie(cname) {
|
||||
var name = cname + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
@ -15,21 +15,29 @@ function getCookie(cname) {
|
||||
}
|
||||
|
||||
function initialiseBetterNavigator() {
|
||||
//Dom elements
|
||||
// Dom elements
|
||||
var BetterNavigator = document.getElementById("BetterNavigator");
|
||||
var BetterNavigatorStatus = document.getElementById("BetterNavigatorStatus");
|
||||
var BetterNavigatorLogoutLink = document.getElementById("BetterNavigatorLogoutLink");
|
||||
var BetterNavigatorLogoutForm = document.getElementById("LogoutForm_BetterNavigatorLogoutForm");
|
||||
|
||||
//Toggle visibility of menu by clicking status
|
||||
// Toggle visibility of menu by clicking status
|
||||
BetterNavigatorStatus.onclick = function () {
|
||||
BetterNavigator.className = BetterNavigator.className === 'collapsed' ? 'open' : 'collapsed';
|
||||
//Set cookie to remember state
|
||||
document.cookie = "BetterNavigator=" + BetterNavigator.className + ";path=/";
|
||||
};
|
||||
|
||||
//Restore menu state
|
||||
// Restore menu state
|
||||
if (getCookie('BetterNavigator') === 'open') {
|
||||
BetterNavigator.className = 'open';
|
||||
}
|
||||
|
||||
// Upgrade logout link to directly log users out instead of redirecting to logout form
|
||||
BetterNavigatorLogoutLink.onclick = function (e) {
|
||||
e.preventDefault();
|
||||
BetterNavigatorLogoutForm.submit();
|
||||
};
|
||||
}
|
||||
|
||||
if (document.addEventListener && document.readyState === 'loading') {
|
||||
|
@ -27,6 +27,10 @@ span[class^='bn-icon'],span[class*=' bn-icon']{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
form {
|
||||
display:none;
|
||||
}
|
||||
|
||||
//Toggle states
|
||||
|
||||
&.collapsed {
|
||||
@ -164,7 +168,7 @@ $archiveColor: #6f6f6f;
|
||||
}
|
||||
}
|
||||
|
||||
//Some hlep for debugging info
|
||||
//Some help for debugging info
|
||||
body > p.message {
|
||||
text-align: left;
|
||||
background: #fff;
|
||||
|
@ -7,6 +7,8 @@ use SilverStripe\Security\Permission;
|
||||
use SilverStripe\CMS\Controllers\SilverStripeNavigator;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Security\LogoutForm;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
@ -66,8 +68,9 @@ class BetterNavigatorExtension extends DataExtension {
|
||||
'Member' => $member,
|
||||
'Stage' => Versioned::get_stage(),
|
||||
'Viewing' => $viewing, // What we're viewing doesn't necessarily align with the active Stage
|
||||
'LoginLink' => Controller::join_links(Director::absoluteBaseURL(), Config::inst()->get('Security', 'login_url'), $backURL),
|
||||
'LogoutLink' => Controller::join_links(Director::absoluteBaseURL() . 'Security/logout', $backURL),
|
||||
'LoginLink' => Controller::join_links(Director::absoluteBaseURL(), Security::config()->login_url, $backURL),
|
||||
'LogoutLink' => Controller::join_links(Director::absoluteBaseURL() . Security::config()->logout_url, $backURL),
|
||||
'LogoutForm' => LogoutForm::create($this->owner)->setName('BetterNavigatorLogoutForm'),
|
||||
'EditLink' => $editLink,
|
||||
'Mode' => Director::get_environment_type(),
|
||||
'IsDeveloper' => $isDeveloper
|
||||
|
@ -37,7 +37,8 @@
|
||||
<% end_if %>
|
||||
|
||||
<% if $Member %>
|
||||
<a href="$LogoutLink"><span class="bn-icon-user"></span>Log out<% if $Member.FirstName %><span class="light"> ($Member.FirstName)</span><% end_if %></a>
|
||||
$LogoutForm
|
||||
<a href="$LogoutLink" id="BetterNavigatorLogoutLink"><span class="bn-icon-user"></span>Log out<% if $Member.FirstName %><span class="light"> ($Member.FirstName)</span><% end_if %></a>
|
||||
<% else %>
|
||||
<a href="$LoginLink"><span class="bn-icon-user"></span>Log in</a>
|
||||
<% end_if %>
|
||||
|
Loading…
Reference in New Issue
Block a user