Skip to content

Commit

Permalink
Fix confusing and broken button to show/hide the left-hand tree pane (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dataflake authored and Michael Howitz committed Jan 31, 2019
1 parent c5176ba commit aa2072a
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 53 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Expand Up @@ -14,6 +14,9 @@ https://github.com/zopefoundation/Zope/blob/4.0a6/CHANGES.rst
Fixes
+++++

- Improved showing/hiding of the left-hand tree pane
(`#457 <https://github.com/zopefoundation/Zope/issues/457>`_)

- Recreate ``App.version_txt.getZopeVersion``
(`#411 <https://github.com/zopefoundation/Zope/issues/411>`_)

Expand Down
43 changes: 26 additions & 17 deletions src/App/dtml/manage.dtml
@@ -1,24 +1,33 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html>
<!DOCTYPE html>
<head>
<title>Zope on &dtml-BASE0;</title>
<title>Zope on &dtml-BASE0;</title>

<link rel="shortcut icon" type="image/x-icon" href="/++resource++zmi/logo/favicon/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/++resource++zmi/logo/favicon/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/++resource++zmi/logo/favicon/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/++resource++zmi/logo/favicon/favicon-16x16.png" />
<link rel="manifest" href="/++resource++zmi/logo/favicon/site.webmanifest" />
<link rel="mask-icon" href="/++resource++zmi/logo/favicon/safari-pinned-tab.svg" color="#5bbad5" />
<meta name="msapplication-config" content="/++resource++zmi/logo/favicon/browserconfig.xml"/>
<meta name="msapplication-TileColor" content="#2d89ef" />
<meta name="theme-color" content="#ffffff" />

</head>

<frameset cols="250, *">
<frame src="<dtml-var "REQUEST.URL1" html_quote>/manage_menu"
name="manage_menu"
marginwidth="2" marginheight="2"
/>
<frame src="<dtml-var "REQUEST.URL1" html_quote>/manage_workspace"
name="manage_main"
marginwidth="2" marginheight="2"
/>
<noframes>
<body>
<p>Management interfaces require the use of a <b>frames-capable</b> web
browser.</p>
</body>
</noframes>
<frame src="<dtml-var "REQUEST.URL1" html_quote>/manage_menu"
name="manage_menu"
marginwidth="2" marginheight="2"
/>
<frame src="<dtml-var "REQUEST.get('came_from',None)!=None and REQUEST.get('came_from',None) or '%s/manage_workspace'%(REQUEST.URL1)" html_quote>"
name="manage_main"
marginwidth="2" marginheight="2"
/>
<noframes>
<body>
<p>Management interfaces require the use of a <em>frames-capable</em> web browser.</p>
</body>
</noframes>
</frameset>

</html>
2 changes: 1 addition & 1 deletion src/App/dtml/manage_navbar.dtml
Expand Up @@ -19,7 +19,7 @@
data-title_inactive="STATUS INACTIVE: Tree Menu Button is only active on List Views. Navigate up a level to show the tree view again."
data-is_folderish="<dtml-var "(manage_main != manage) and 1 or 0">"
>
<a href="#" target="_parent">
<a href="<dtml-var "(manage_main != manage) and './' or '../'">manage?came_from=<dtml-var URL>" target="_parent" onclick="javascript:if ( manage_menu ) {window.parent.frames[0].menu_toggle();return false;} else { return true; }">
<i class="fa fa-sitemap"></i>
</a>
</li>
Expand Down
7 changes: 7 additions & 0 deletions src/App/dtml/manage_page_footer.dtml
@@ -1,4 +1,11 @@
<dtml-unless "REQUEST.get('zmi_dialog','window')=='modal'">
</body>
<dtml-unless "'/manage_menu' in REQUEST.URL">
<script>
// Helpers for Menu Handling <dtml-var "REQUEST.URL">
var manage_menu = typeof window.parent.frames!="undefined"&&typeof window.parent.frames.manage_menu!="undefined";
window.parent.history.replaceState('','Main','<dtml-var URL>')
</script>
</dtml-unless>
</html>
</dtml-unless>
2 changes: 1 addition & 1 deletion src/App/dtml/manage_page_header.dtml
Expand Up @@ -14,7 +14,7 @@
<link rel="stylesheet" type="text/css" href="&dtml-sequence-item;" />
</dtml-in>
<dtml-in js_urls>
<script src="&dtml-sequence-item;"></script>
<script src="&dtml-sequence-item;"></script>
</dtml-in>

<link rel="shortcut icon" type="image/x-icon" href="/++resource++zmi/logo/favicon/favicon.ico" />
Expand Down
33 changes: 33 additions & 0 deletions src/App/dtml/menu.dtml
Expand Up @@ -58,5 +58,38 @@
></dtml-if>

</main>

<script src="/++resource++zmi/zmi.localstorage.api.js"></script>
<script>
function menu_resize(init) {
var key = "ZMI.manage_menu.width";
$(window).resize(function() {
$ZMILocalStorageAPI.set(key,window.innerWidth);
});
var frmwidth = $ZMILocalStorageAPI.get(key,250);
var frmset = parent.document.getElementsByTagName('frameset');
var colval = frmwidth + ",*";
frmset[0].cols=colval;
}
function menu_toggle() {
var menu_width = "ZMI.manage_menu.width";
var menu_width_saved = "ZMI.manage_menu.width.saved";
if ( $ZMILocalStorageAPI.get(menu_width,0)==0 ) {
$ZMILocalStorageAPI.set(menu_width,$ZMILocalStorageAPI.get(menu_width_saved,250));
} else {
$ZMILocalStorageAPI.set(menu_width_saved,$ZMILocalStorageAPI.get(menu_width,250));
$ZMILocalStorageAPI.set(menu_width,0);
}
var frmwidth = $ZMILocalStorageAPI.get(menu_width,250);
var frmset = parent.document.getElementsByTagName('frameset');
var colval = frmwidth + ",*";
frmset[0].cols=colval;
}

$(function(){
menu_resize();
});
</script>

<dtml-var manage_page_footer>

120 changes: 120 additions & 0 deletions src/zmi/styles/resources/zmi.localstorage.api.js
@@ -0,0 +1,120 @@
/**
* $ZMILocalStorageAPI
*
* @see http://fortuito.us/diveintohtml5/storage.html
*/
ZMILocalStorageAPI = function() {
};
ZMILocalStorageAPI.prototype._clear = function(cb) {
for (var k in localStorage) {
if (!(k.indexOf("_")==0)) {
delete localStorage[k];
}
}
}
ZMILocalStorageAPI.prototype.keys = function() {
var l = [];
for (var k in localStorage) {
l.push(k);
}
l.sort();
return l;
}
ZMILocalStorageAPI.prototype.get = function(k,d) {
var v = d;
var l = this.keys();
var done = [];
for (var i=0; i < l.length; i++) {
var lsk = l[i];
var nv = null;
if (lsk.indexOf(k+".")==0) {
var nk = lsk.substr((k+".").length);
if (nk.indexOf(".") > 0) {
nk = nk.substr(0,nk.indexOf("."));
if ($.inArray(k+"."+nk,done)<0) {
nv = $ZMILocalStorageAPI.get(k+"."+nk);
done.push(k+"."+nk);
}
}
else {
nv = localStorage[lsk];
}
if (nv != null) {
if (isNaN(nk)) {
if (typeof v == "undefined") {
v = {};
}
v[nk] = nv;
}
else {
if (typeof v == "undefined") {
v = [];
}
v.push(nv);
}
}
}
else if (lsk==k) {
nv = localStorage[lsk];
if (typeof nv != "undefined") {
v = nv;
}
}
}
return v;
}
ZMILocalStorageAPI.prototype._set = function(k,v) {
if (typeof v == "object") {
if (Array.isArray(v)) {
for (var i = 0; i < v.length; i++) {
this._set(k+"."+i,v[i]);
}
}
else {
for (var i in v) {
this._set(k+"."+i,v[i]);
}
}
}
else {
localStorage[k] = v;
}
}
ZMILocalStorageAPI.prototype.set = function(k,v,r) {
this._set(k,v);
if (r) {
self.location.reload();
}
}
ZMILocalStorageAPI.prototype._del = function(k) {
var l = this.keys();
for (var i=0; i < l.length; i++) {
var lsk = l[i];
if (lsk==k || lsk.indexOf(k+".")==0) {
delete localStorage[lsk];
}
}
}
ZMILocalStorageAPI.prototype.del = function(k,r) {
this._del(k);
if (r) {
self.location.reload();
}
}
ZMILocalStorageAPI.prototype.toggle = function(k,r) {
if (this.get(k,null)==null) {
this.set(k,"1",r);
}
else {
this.del(k,r);
}
}
ZMILocalStorageAPI.prototype.replace = function(k,v,r) {
this._del(k);
this._set(k,v);
if (r) {
self.location.reload();
}
}

$ZMILocalStorageAPI = new ZMILocalStorageAPI();
35 changes: 1 addition & 34 deletions src/zmi/styles/resources/zmi_base.js
Expand Up @@ -2,39 +2,7 @@

// NAVBAR-FUNCTIONS

function setupShowHideTreeView() {
/*
Disable the show sidebar button if the sidebar cannot be shown
without navigating away from the current view.
It would be cool to get rid of this, but that would require
reworking the TreeTagView to understand that it could show the
elements above the current object if it is not a folderish thing.
*/
var $li = $('#toggle_menu');
if (0 === $li.length) {
return // no menu toggle on this page
}

var $a = $li.find('a');
// var isInFrameset = window.parent.location.href.endsWith('/manage');
var isShowingFrameset = window !== window.parent;
var isFolderish = !! $li.data().is_folderish
if (isShowingFrameset) {
$a.attr('href', 'manage_main')
}
else {
if ( isFolderish ) {
$a.attr('href', 'manage')
}
else {
$li.attr('title', $li.attr('data-title_inactive'));
$a.addClass('disabled');
}
}
}

// [2] Add New Object Item (with Modal Dialog)
// Add New Object Item (with Modal Dialog)
function addItem( elm, base_url ) {
// e.g. manage_addProduct/OFSP/folderAdd
var url_action = elm.options[elm.selectedIndex].value;
Expand Down Expand Up @@ -235,7 +203,6 @@ $(function() {
$('#addItemSelect').attr( 'title', $('#addItemSelect').attr('data-title-inactive') );
}

setupShowHideTreeView()

if (!window.matchMedia || (window.matchMedia("(max-width: 767px)").matches)) {
$('.zmi header.navbar li.zmi-authenticated_user').tooltip({'placement':'bottom'});
Expand Down

0 comments on commit aa2072a

Please sign in to comment.