Author: hannes
Date: 2008-12-17 22:54:35 +0100 (Wed, 17 Dec 2008)
New Revision: 9440
Added:
apps/gobi/trunk/code/Global/components/
apps/gobi/trunk/code/Global/components/menu.js
apps/gobi/trunk/code/Global/components/menu.skin
Modified:
apps/gobi/trunk/code/Page/Manage.js
apps/gobi/trunk/code/Page/PageCore.js
apps/gobi/trunk/code/Page/PageMacros.js
apps/gobi/trunk/code/Page/Permissions.js
apps/gobi/trunk/code/Page/skins/controlbar.skin
apps/gobi/trunk/code/Page/skins/javascript.skin
apps/gobi/trunk/code/Page/skins/stylesheet.skin
apps/gobi/trunk/code/Root/Root.js
Log:
Move manage links into a new html dropdown menu component.
Details at http://dev.helma.org/trac/helma/changeset/9440
Added: apps/gobi/trunk/code/Global/components/menu.js
Added: apps/gobi/trunk/code/Global/components/menu.skin
Modified: apps/gobi/trunk/code/Page/Manage.js
===================================================================
--- apps/gobi/trunk/code/Page/Manage.js 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/Manage.js 2008-12-17 21:54:35 UTC (rev 9440)
@@ -18,6 +18,19 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/**
+ * Return a list of admin screen names (tabs)
+ */
+function getAdminActions() {
+ return [["manage.permissions", "set permissions"],
+ ["manage.forms", "set form"],
+ ["manage.skins", "set skin"],
+ ["manage.owner", "set owner"],
+ ["manage.members", "manage members"],
+ ["manage.admins", "manage administrators"],
+ ["move", "move page"],
+ ["delete", "delete page"]];
+}
/**
* Read the form data from a submitted manage page.
@@ -84,15 +97,30 @@
}
}
+function manage_permissions_action() {
+ this.manage("permissions");
+}
+
+function manage_forms_action() {
+ this.manage("forms");
+}
+
+function manage_owner_action() {
+ this.manage("owner");
+}
+
+function manage_members_action() {
+ this.manage("members");
+}
+
+function manage_admins_action() {
+ this.manage("admins");
+}
/**
* Manage this page.
*/
-function manage_action() {
- var screens = this.getAdminScreens();
- var screen = req.data.screen;
- if (!screen)
- screen = screens[0];
-
+function manage(screen) {
+
if (req.data.save || req.data.reset) {
this.readManageForm();
this.modifier = session.user;
@@ -101,24 +129,11 @@
res.redirect(this.href("manage")+"?screen="+screen);
}
res.push();
- var found = false;
- for (var i in screens) {
- if (i > 0) res.write(" | ");
- if (screen == screens[i]) {
- res.write(screen.bold());
- found = true;
- } else {
- Html.link({href: this.href("manage")+"?screen="+screens[i]},
- screens[i]);
- }
+ if (screen == "permissions") {
+ this.permissionsEditor();
+ }else {
+ this.renderSkin("admin#"+screen);
}
- // if not found the screen isn't allowed
- if (found) {
- if (screen == "permissions")
- this.permissionsEditor();
- else
- this.renderSkin("admin#"+screen);
- }
res.data.body = res.pop();
this.renderSkin("page");
}
Modified: apps/gobi/trunk/code/Page/PageCore.js
===================================================================
--- apps/gobi/trunk/code/Page/PageCore.js 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/PageCore.js 2008-12-17 21:54:35 UTC (rev 9440)
@@ -150,13 +150,6 @@
}
/**
- * Return a list of admin screen names (tabs)
- */
-function getAdminScreens() {
- return ["permissions", "forms", "skins", "owner", "admins", "members"];
-}
-
-/**
* Return true if the current user may create a new page of this type
*/
function isSettableType() {
Modified: apps/gobi/trunk/code/Page/PageMacros.js
===================================================================
--- apps/gobi/trunk/code/Page/PageMacros.js 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/PageMacros.js 2008-12-17 21:54:35 UTC (rev 9440)
@@ -90,7 +90,13 @@
}
}
+function adminlinks_macro(param) {
+ if (this.checkPermission(ADMIN)) {
+ new HtmlMenu("manage", this.getAdminActions()).render();
+ }
+}
+
/**
* Macro to display links to actions in this page as dropdown box
*/
Modified: apps/gobi/trunk/code/Page/Permissions.js
===================================================================
--- apps/gobi/trunk/code/Page/Permissions.js 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/Permissions.js 2008-12-17 21:54:35 UTC (rev 9440)
@@ -45,9 +45,9 @@
new Action("comment", {category: COMMENT}),
new Action("attach", {category: WRITE, label: "Attachments"}),
new Action("create", {category: WRITE, label: "New Page"}),
- new Action("move", {category: MANAGE, label: "Move Page"}),
- new Action("delete", {category: MANAGE, label: "Delete Page"}),
- new Action("manage", {category: MANAGE, label: "Manage Page"}),
+ new Action("move", {category: MANAGE}),
+ new Action("delete", {category: MANAGE}),
+ new Action("manage", {category: MANAGE}),
new Action("link", {category: MANAGE }),
]);
Modified: apps/gobi/trunk/code/Page/skins/controlbar.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/controlbar.skin 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/skins/controlbar.skin 2008-12-17 21:54:35 UTC (rev 9440)
@@ -10,6 +10,7 @@
<table class="tabsLeft">
<tr>
<% this.actionlinks skin="iconlink" active="-sel" %>
+ <% this.adminlinks prefix="<td class='tab'>" suffix="</td>" %>
</tr>
</table>
</div>
Modified: apps/gobi/trunk/code/Page/skins/javascript.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/javascript.skin 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/skins/javascript.skin 2008-12-17 21:54:35 UTC (rev 9440)
@@ -1,6 +1,23 @@
var baseUri = "<% this.href %>";
+ // currently showing menu id
+ var currentMenu;
+
+ document.onmousedown = function(event) {
+ if (currentMenu) {
+ event = event || window.event;
+ var elem = event.target || event.srcElement;
+ while (elem) {
+ if (elem.id == currentMenu) return true;
+ elem = elem.parentNode;
+ }
+ showElement(currentMenu, false);
+ currentMenu = null;
+ }
+ return true;
+ }
+
function openPopup(url, name, width, height) {
if (isNaN(width)) width = 300;
if (isNaN(height)) height = 350;
@@ -68,6 +85,11 @@
return false;
}
+ function toggleMenu(id) {
+ currentMenu = currentMenu != id && id;
+ return toggleElement(id);
+ }
+
function toggleCommentForm(link) {
try{
link.style.display = "none";
@@ -165,6 +187,30 @@
openPopup(url, name, width, height);
}
+ function addClass(elem, clazz) {
+ if (elem) {
+ var className = elem.className || "";
+ var classes = elem.split(" ");
+ for (var i = 0; i < classes.length; i++) {
+ if (classes[i] == clazz) return;
+ }
+ elem.className = classes.join(" ");;
+ }
+ }
+
+ function removeClass(elem, clazz) {
+ if (elem) {
+ var className = elem.className || "";
+ var classes = elem.split(" ");
+ for (var i = classes.length - 1; i >= 0; i--) {
+ if (classes[i] == clazz) {
+ classes.splice(i, 1);
+ };
+ }
+ elem.className = classes.join(" ");;
+ }
+ }
+
/**
* Create a XMLHttpRequest instance
*/
@@ -246,15 +292,15 @@
* Catch F2 for asynchronously saving the page.
* FIXME: not finished/working, should use async HTTP request.
*/
- function handleKeyPress(evt) {
- if (!evt)
- evt = window.event;
- if (evt && evt.target && evt.keyCode == 113) {
- var text = evt.target.firstChild.nodeValue;
+ function handleKeyPress(event) {
+ event = event || window.event;
+ var target = event.target || event.srcElement;
+ if (event && target && event.keyCode == 113) {
+ var text = target.firstChild.nodeValue;
callAsyncRequest(baseUri + "edit.autosave", null, "POST",
- evt.target.name + "=" + encodeURIComponent(text));
+ target.name + "=" + encodeURIComponent(text));
}
- return false;
+ return true;
}
function initDocument() {
Modified: apps/gobi/trunk/code/Page/skins/stylesheet.skin
===================================================================
--- apps/gobi/trunk/code/Page/skins/stylesheet.skin 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Page/skins/stylesheet.skin 2008-12-17 21:54:35 UTC (rev 9440)
@@ -15,6 +15,25 @@
border-collapse:collapse;
}
+ a:link {
+ color: #0000ff;
+ }
+
+ a:visited {
+ color: #0000cc;
+ }
+
+ .main a:hover {
+ color: #cc3333;
+ }
+
+ a.undefinedLink {
+ color: #669;
+ text-decoration: none;
+ border-bottom: 1px dotted #669;
+ }
+
+
h1, h2, h3 {
color: #333;
font-weight: bold;
@@ -125,12 +144,12 @@
bottom: -1px;
}
- .tabs .tabsLeft {
+ .tabsLeft {
margin-left: 10%;
margin-right: auto;
}
- .tabs .tabsRight {
+ .tabsRight {
float: right;
margin-right: 10px;
}
@@ -143,7 +162,7 @@
padding: 0;
}
- .tabs .tab-sel {
+ .tab-sel {
background-color: #fff;
border: 1px solid #669;
border-bottom: 0;
@@ -155,12 +174,12 @@
padding: 0.1em 0.6em;
}
- .tabs .tab a, .tabs .tab a:visited, .tabsRight a, .tabsRight a:visited {
+ .tab a, .tab a:visited, .tab:link, .tabsRight a, .tabsRight a:visited, .tabsright a:link {
text-decoration: none;
color: #eef;
}
- .tabs .tab-sel a, .tabs .tab-sel a:visited {
+ .tab-sel a, .tab-sel a:visited {
color: #333;
}
@@ -178,24 +197,6 @@
text-align: center;
}
- a:link {
- color: #0000ff;
- }
-
- a:visited {
- color: #0000cc;
- }
-
- .main a:hover {
- color: #cc3333;
- }
-
- a.undefinedLink {
- color: #669;
- text-decoration: none;
- border-bottom: 1px dotted #669;
- }
-
.horizontalFill {
width: 90%;
}
@@ -339,7 +340,27 @@
.navlink-0-active, .navlink-1-active, .navlink-2-active, .navlink-3-active, navlink-4-active {
font-weight: bold;
}
-
+
+ .menu {
+ position: absolute;
+ border: 1px solid #999;
+ }
+
+ .menu a, .menu a:visited, .menu a:link {
+ text-decoration: none;
+ background-color: #fff;
+ color: #000;
+ display: block;
+ padding-left: 5px;
+ padding-top: 3px;
+ padding-bottom: 3px;
+ border-bottom: 1px dotted #ddd;
+ }
+
+ .menu a:hover {
+ background-color: #ddd
+ }
+
.linkEditorBox {
width: 89%;
padding: 4px;
Modified: apps/gobi/trunk/code/Root/Root.js
===================================================================
--- apps/gobi/trunk/code/Root/Root.js 2008-12-17 15:01:33 UTC (rev 9439)
+++ apps/gobi/trunk/code/Root/Root.js 2008-12-17 21:54:35 UTC (rev 9440)
@@ -19,9 +19,10 @@
*/
// this prototype's actions - clone actions from Page minus "move" and "delete"
-var actions = Page.prototype._actions.clone();
-actions.remove("move", "delete");
-this._actions = actions;
+function getAdminActions() {
+ var actions = Page.prototype.getAdminActions.apply(this);
+ return actions.slice(0, actions.length - 2);
+}
function hasPrevNextNavigation() {
return 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.