Author: andre
Date: 2009-07-07 17:09:39 +0200 (Tue, 07 Jul 2009)
New Revision: 36623
Modified:
openimages/trunk/src/main/webapp/editors/inc/form-create.jspx
openimages/trunk/src/main/webapp/editors/inc/form-delete.jspx
openimages/trunk/src/main/webapp/editors/inc/form-edit.jspx
openimages/trunk/src/main/webapp/login.jspx
openimages/trunk/src/main/webapp/mmbase/components/oip/user-mediatranslations.jspx
openimages/trunk/src/main/webapp/style/css/specific-styles.css
openimages/trunk/src/main/webapp/style/js/mmajaxeditor.js
Log:
rewrote major and simplefied major parts of mmajaxeditor to edit translations
in user pages, has to be tested in editors
Modified: openimages/trunk/src/main/webapp/editors/inc/form-create.jspx
===================================================================
--- openimages/trunk/src/main/webapp/editors/inc/form-create.jspx
2009-07-07 14:05:55 UTC (rev 36622)
+++ openimages/trunk/src/main/webapp/editors/inc/form-create.jspx
2009-07-07 15:09:39 UTC (rev 36623)
@@ -77,33 +77,33 @@
and related to <mm:node number="$nr"><mm:function name="gui"
escape="tagstripper" /></mm:node>
</c:if>.
</p>
+ <mm:import id="saved">OK</mm:import>
<mm:commit />
-
- <c:set var="saved" value="true" />
</mm:valid>
<mm:valid inverse="true">
<mm:cancel />
</mm:valid>
</mm:present>
-
- <c:if test="${!empty saved}">
- <c:choose>
- <c:when test="${mmajaxeditor eq 'yes'}">
- <div id="edit${new_node}" class="${type}">
- <mm:haspage page="/editors/inc/node.jspx">
- <mm:include page="/editors/inc/node.jspx"
referids="new_n...@nr,type?" />
- </mm:haspage>
- </div>
- </c:when>
- <c:otherwise>
- <mm:link page="${editor}" referids="new_n...@nr">
- <a href="${_}">edit</a>
- </mm:link>
- </c:otherwise>
- </c:choose>
- </c:if>
</mm:form>
+
+ <!-- put all mmajaxeditor msg stuff outside form -->
+ <c:if test="${!empty saved and !empty mmajaxeditor}">
+ <mm:node referid="new_node"> new
+ <mm:link page="/editors/inc/form-edit.jspx" referids="new_n...@nr">
+ <a href="${_}#node_${new_node}" class="mmajaxeditor">
+ <mm:field name="language"><mm:fieldinfo type="guivalue" /></mm:field>
+ - <mm:function name="gui" escape="tagstripper" />
+ </a>
+ </mm:link>
+ <mm:maydelete> |
+ <mm:link page="/editors/inc/form-delete.jspx" referids="new_n...@nr">
+ <a href="${_}#node_${new_node}" class="mmajaxeditor">delete</a>
+ </mm:link>
+ </mm:maydelete>
+ </mm:node>
+ </c:if>
+
</mm:cloud>
</mm:content>
</jsp:root>
Modified: openimages/trunk/src/main/webapp/editors/inc/form-delete.jspx
===================================================================
--- openimages/trunk/src/main/webapp/editors/inc/form-delete.jspx
2009-07-07 14:05:55 UTC (rev 36622)
+++ openimages/trunk/src/main/webapp/editors/inc/form-delete.jspx
2009-07-07 15:09:39 UTC (rev 36623)
@@ -24,10 +24,28 @@
<c:choose>
<c:when test="${delete eq 'Cancel'}">
<p class="msg">Canceled deletion.</p>
+ <mm:link page="/editors/inc/form-edit.jspx" referids="nr">
+ <a href="${_}#node_${nr}" class="mmajaxeditor">
+ <mm:field name="language"><mm:fieldinfo type="guivalue"
/></mm:field>
+ - <mm:function name="gui" />
+ </a>
+ </mm:link>
+ <mm:maydelete> -
+ <mm:link page="/editors/inc/form-delete.jspx" referids="nr">
+ <a href="${_}#node_${nr}" class="mmajaxeditor">delete</a>
+ </mm:link>
+ </mm:maydelete>
</c:when>
+
<c:when test="${delete eq 'OK'}">
<mm:maydelete inverse="true">
<p class="msg">Not enough priveleges.</p>
+ <mm:link page="/editors/inc/form-edit.jspx" referids="nr">
+ <a href="${_}#node_${nr}" class="mmajaxeditor">
+ <mm:field name="language"><mm:fieldinfo type="guivalue"
/></mm:field>
+ - <mm:function name="gui" />
+ </a>
+ </mm:link>
</mm:maydelete>
<mm:maydelete>
<mm:import externid="type" />
@@ -41,6 +59,7 @@
<mm:deletenode number="$node" deleterelations="true" />
</mm:maydelete>
</c:when>
+
<c:otherwise>
<mm:form id="formdelete_$nr">
<fieldset>
Modified: openimages/trunk/src/main/webapp/editors/inc/form-edit.jspx
===================================================================
--- openimages/trunk/src/main/webapp/editors/inc/form-edit.jspx 2009-07-07
14:05:55 UTC (rev 36622)
+++ openimages/trunk/src/main/webapp/editors/inc/form-edit.jspx 2009-07-07
15:09:39 UTC (rev 36623)
@@ -40,36 +40,49 @@
</mm:valid>
</mm:present>
- <c:choose>
- <c:when test="${!empty saved and mmajaxeditor eq 'yes'}">
- <mm:haspage page="/editors/inc/node.jspx">
- <mm:include page="/editors/inc/node.jspx" referids="nr" />
- </mm:haspage>
- </c:when>
- <c:otherwise>
- <c:if test="${mmajaxeditor eq 'yes'}">
- <mm:haspage page="/editors/inc/node.jspx">
- <mm:link page="/editors/inc/node.jspx" referids="nr">
- <a class="mmajaxeditor_close" title="cancel"
href="${_}#edit${nr}">cancel</a>
- </mm:link>
- </mm:haspage>
- </c:if>
- <mm:write referid="buffer" escape="none" />
- <mm:maywrite>
- <fieldset>
- <input name="nr" type="hidden" value="${nr}" />
- <mm:nodeinfo type="type"><input name="type" type="hidden"
value="${_}" /></mm:nodeinfo>
- <input name="mmajaxeditor" type="hidden" value="${mmajaxeditor}"
/>
- <div>
- <input type="submit" name="submit${nr}" value="Save"
class="submit" />
- </div>
- </fieldset>
- </mm:maywrite>
- </c:otherwise>
- </c:choose>
+ <c:if test="${empty saved}">
+
+ <mm:write referid="buffer" escape="none" />
+ <mm:maywrite>
+ <fieldset>
+ <input name="nr" type="hidden" value="${nr}" />
+ <mm:nodeinfo type="type"><input name="type" type="hidden"
value="${_}" /></mm:nodeinfo>
+ <input name="mmajaxeditor" type="hidden" value="${mmajaxeditor}" />
+ <div>
+ <input type="submit" name="submit${nr}" value="Save"
class="submit" />
+ </div>
+ </fieldset>
+ </mm:maywrite>
+
+ </c:if>
</mm:node>
</mm:form>
+
+ <!-- put all mmajaxeditor msg stuff outside form -->
+ <c:if test="${!empty saved and !empty mmajaxeditor}">
+ <mm:node number="$nr">
+
+ <mm:link page="/editors/inc/form-edit.jspx" referids="nr">
+ <a href="${_}#node_${nr}" class="mmajaxeditor">
+ <mm:field name="language"><mm:fieldinfo type="guivalue" /></mm:field>
+ - <mm:function name="gui" />
+ </a>
+ </mm:link>
+
+ <mm:maydelete> -
+ <mm:link page="/editors/inc/form-delete.jspx" referids="nr">
+ <a href="${_}#node_${nr}" class="mmajaxeditor">delete</a>
+ </mm:link>
+ </mm:maydelete>
+
+ <mm:haspage page="/editors/inc/node.jspx">
+ <mm:include page="/editors/inc/node.jspx" referids="nr" />
+ </mm:haspage>
+ </mm:node>
+ </c:if>
+
+
</mm:cloud>
</mm:content>
</jsp:root>
Modified: openimages/trunk/src/main/webapp/login.jspx
===================================================================
--- openimages/trunk/src/main/webapp/login.jspx 2009-07-07 14:05:55 UTC (rev
36622)
+++ openimages/trunk/src/main/webapp/login.jspx 2009-07-07 15:09:39 UTC (rev
36623)
@@ -12,8 +12,11 @@
<jsp:attribute name="body">
<div class="main-column">
+
<oip:h2><mm:field name="title" /></oip:h2>
- <mm:field name="description" escape="p" />
+ <mm:nodefunction name="translation">
+ <mm:field name="description" escape="paragraph" />
+ </mm:nodefunction>
<script type="text/javascript">
Widgets.prototype.labelsToInputs("#loginform label");
Modified:
openimages/trunk/src/main/webapp/mmbase/components/oip/user-mediatranslations.jspx
===================================================================
---
openimages/trunk/src/main/webapp/mmbase/components/oip/user-mediatranslations.jspx
2009-07-07 14:05:55 UTC (rev 36622)
+++
openimages/trunk/src/main/webapp/mmbase/components/oip/user-mediatranslations.jspx
2009-07-07 15:09:39 UTC (rev 36623)
@@ -33,15 +33,14 @@
<ul>
<mm:maycreate type="$ttype">
- <li>
+ <li id="create_${ttype}">
<mm:link page="/editors/inc/form-create.jspx">
<mm:param name="nr">${media}</mm:param>
<mm:param name="type">${ttype}</mm:param>
<mm:param name="role">langrel</mm:param>
<mm:param name="dir">destination</mm:param>
- <a class="mmajaxeditor" href="${_}#create_${ttype}">New
translation</a> ${ttype}
+ <a class="mmajaxeditor" href="${_}#create_${ttype}">New
translation</a>
</mm:link>
- <div id="create_${ttype}" class="hidden"> </div>
</li>
</mm:maycreate>
<mm:relatednodescontainer type="$ttype" role="langrel"
searchdirs="destination">
@@ -49,7 +48,7 @@
<li id="node_${translation}">
<mm:link page="/editors/inc/form-edit.jspx"
referids="translat...@nr">
- <a href="${_}#edit_${translation}"
class="mmajaxeditor">
+ <a href="${_}#node_${translation}"
class="mmajaxeditor">
<mm:field name="language"><mm:fieldinfo
type="guivalue" /></mm:field>
- <mm:function name="gui" />
</a>
@@ -57,18 +56,14 @@
<mm:maydelete> -
<mm:link page="/editors/inc/form-delete.jspx"
referids="translat...@nr">
- <a href="${_}#delete_${translation}"
class="mmajaxeditor">delete</a>
+ <a href="${_}#node_${translation}"
class="mmajaxeditor">delete</a>
</mm:link>
- <div id="delete_${translation}" class="hidden"> </div>
</mm:maydelete>
- <div id="edit_${translation}" class="hidden"> </div>
-
</li>
</mm:relatednodes>
</mm:relatednodescontainer>
-
- </ul>
+ </ul>
</mm:hasrelationmanager>
Modified: openimages/trunk/src/main/webapp/style/css/specific-styles.css
===================================================================
--- openimages/trunk/src/main/webapp/style/css/specific-styles.css
2009-07-07 14:05:55 UTC (rev 36622)
+++ openimages/trunk/src/main/webapp/style/css/specific-styles.css
2009-07-07 15:09:39 UTC (rev 36623)
@@ -369,8 +369,6 @@
div.right-column input, div.right-column textarea, div.right-column select {
width: 280px; }
div.right-column input.submit, div.right-column input.cancel { width: auto; }
-
-form#loginform { margin-top: 3em; }
form#loginform p { line-height: 3em; }
form#loginform a { color: #555; }
Modified: openimages/trunk/src/main/webapp/style/js/mmajaxeditor.js
===================================================================
--- openimages/trunk/src/main/webapp/style/js/mmajaxeditor.js 2009-07-07
14:05:55 UTC (rev 36622)
+++ openimages/trunk/src/main/webapp/style/js/mmajaxeditor.js 2009-07-07
15:09:39 UTC (rev 36623)
@@ -2,12 +2,16 @@
/*
* MMAjaxeditor attaches an event to a link to display a form.
- * When clicked the form is displayed using the links' parameters.
- * The link should have the parameters needed for the form to function
correctly,
- * f.e. the nodetype to create like 'form-create.jsp?type=alert#divid' and
- * the fragment (#) part should contain an id of an html element to display
everything.
+ * When clicked the form is displayed using the links' parameters. The link
contains all the
+ * parameters needed for the form to function correctly f.e. the nodetype to
create:
+ * 'form-create.jsp?type=news#create_id'.
+ * The fragment (#) part should contain the id of the html element in which to
display everything.
+ * If the id contains 'create' it is presumed we are creating: a new node will
be added with
+ * the same tag as this id (f.e. a 'li#node_345' below 'li#create_news'). If
not the contents of the
+ * element with that id (f.e. the element with '#node_345') are replaced with
the new content (the
+ * edited node).
*
- * @param anchor the link being clicked fo a form with the id of an html
element in the fragment (#)
+ * @param anchor link with paramaters for the editor and an id (f.e.
#node_345) of a target element
*
*/
function MMAjaxeditor(anchor) {
@@ -18,36 +22,33 @@
this.url = link.substring(0, link.indexOf("?"));
var query = link.substring(link.indexOf("?") + 1);
this.params = this.getParams(query);
- this.params.mmajaxeditor = "yes"; // indication to the form
- this.div = document.getElementById(this.id);
+ // indication to the form
+ if (this.params.mmajaxeditor == undefined) {
+ this.params.mmajaxeditor = "yes";
+ }
+ this.el = document.getElementById(this.id);
//console.log("url: " + this.url + ", query: " + query + ", id: " +
this.id);
-
- if ($(this.div).is('.mmajaxeditor')) {
- $(this.div).removeClass("mmajaxeditor");
- $(this.div).hide();
+
+ if ($(this.el).find('form').length > 0) {
+ $(this.el).find('form').remove();
} else {
- if ($(this.div).is(':hidden')) {
- var pos = $(anchor).position();
- var height = $(anchor).height();
- var cssObj = {
- //position: "absolute",
- top: pos.top + height + 0 + "px",
- left: pos.left + 0 + "px"
- }
- $(this.div).show().css(cssObj);
- }
- $(this.div).addClass("mmajaxeditor");
- this.addForm(this.div);
- }
+ this.addForm(this.el);
+ }
}
+/*
+ * Adds the form and passes it on.
+ */
MMAjaxeditor.prototype.addForm = function(el) {
var form = this.loadElement(this.url, this.params);
if ($(el).find('form').length > 0) $(el).find('form').remove();
- $(el).html(form); // replace everything
+ $(el).append(form);
this.bindFormEvents();
}
+/*
+ * Simply loads an element (a form you would expect) with ajax
+ */
MMAjaxeditor.prototype.loadElement = function(url, params) {
var result;
$.ajax({async: false, url: url, type: "GET", dataType: "xml", data: params,
@@ -64,6 +65,9 @@
return result;
}
+/*
+ * (re)binds events to the resulting form so that it uses jquery Form and
MMBaseValidator
+ */
MMAjaxeditor.prototype.bindFormEvents = function() {
var self = this;
var result;
@@ -75,34 +79,55 @@
} else {
result = $('<p class="err">Error: ' + response.status + ' - '
+ response.statusText + '</p>');
}
+ //console.log(result);
+ if (self.id.indexOf('create') > -1) {
+ $(self.el).find('form').remove();
+ var tag = document.createElement(self.el.tagName); //
create a new tag like this one
+ var newid = result.substring(result.indexOf('#node_') + 1,
result.indexOf('"', result.indexOf('#node_')));
+ tag.id = newid;
+ $(tag).html(result);
+ $(self.el).after(tag); // append it after this one
(create)
+ self.bindMMAjaxeditorEvents('#' + newid);
+ } else {
+ $(self.el).html(result); // replace everything (edit/delete)
+ }
- $(self.div).html(result);
- if ($(self.div).find('form input').length == 0) {
+ if ($(self.el).find('form input').length == 0) {
//console.log("No inputs left, we're finished editing.");
- var msg = $(self.div).find('.msg').text();
- self.reload(msg);
+ self.bindMMAjaxeditorEvents();
} else {
- $(self.div).find("form").ajaxForm(options);
+ $(self.el).find("form").ajaxForm(options);
if (typeof MMBaseValidator == "function") {
- self.validator = new MMBaseValidator(self.div);
+ self.validator = new MMBaseValidator(self.el);
}
- self.bindFormClose();
+ self.bindMMAjaxeditorEvents( $(self.el).find("form") );
}
}
};
- $(this.div).html(result);
- $(this.div).find("form").ajaxForm(options);
+ if (result != undefined) {
+ alert("when is this? i hope never...");
+ $(this.el).html(result); // replace everything (edit/delete)
+ }
+ $(this.el).find("form").ajaxForm(options);
if (typeof MMBaseValidator == "function") {
- this.validator = new MMBaseValidator(this.div);
+ this.validator = new MMBaseValidator(this.el);
}
- this.bindFormClose();
+ this.bindMMAjaxeditorEvents( $(this.el).find("form") );
}
/*
- * Binds a link with class 'mmajaxeditor_close' to close the form.
+ * Binds links with class 'mmajaxeditor' etc.
*/
-MMAjaxeditor.prototype.bindFormClose = function() {
- var editor = this;
+MMAjaxeditor.prototype.bindMMAjaxeditorEvents = function(el) {
+ if (el == undefined) el = this.el;
+
+ $(el).find('a.mmajaxeditor').click(function(ev) {
+ ev.preventDefault();
+ var anchor = ev.target;
+ new MMAjaxeditor(anchor);
+ });
+
+ /*
$("a.mmajaxeditor_close").click(function(ev) {
ev.preventDefault();
var link = ev.target.href;
@@ -110,15 +135,16 @@
//var query = link.substring(link.indexOf("?") + 1);
//var params = editor.getParams(query);
var html = editor.loadElement(link, null);
- $(editor.div).removeClass("mmajaxeditor");
- $(editor.div).html(html);
+ $(editor.el).removeClass("mmajaxeditor");
+ $(editor.el).html(html);
- $(editor.div).find("a.mmajaxeditor").click(function(ev) {
+ $(editor.el).find("a.mmajaxeditor").click(function(ev) {
ev.preventDefault();
var anchor = ev.target;
new MMAjaxeditor(anchor);
});
});
+ */
}
/*
@@ -129,26 +155,6 @@
}
*/
-MMAjaxeditor.prototype.reload = function(msg) {
- var loc = "" + document.location;
- //console.log("1 loc: " + loc);
- var pos = loc.indexOf('msg=');
- if (pos > -1) {
- var first = loc.substring(0, pos - 1);
- var epos = loc.indexOf(pos + 1, '&');
- if (epos == -1) epos = loc.length;
- var last = "";
- if (epos < loc.length) {
- last = loc.substring(epos + 1, loc.length);
- }
- loc = first + last;
- }
- //console.log("2 loc: " + loc);
- var connector = loc.indexOf('?') == -1 ? '?' : '&';
- loc = loc + connector + "msg=" + msg;
- //console.log("reloading: " + loc);
- // document.location = loc;
-}
/*
* Returns the parameters from a query string in an object.
@@ -176,7 +182,7 @@
}
function initHideMsg() {
- setTimeout("hideMsg();", 10000);
+ setTimeout("hideMsg();", 5000);
}
function hideMsg() {
@@ -185,6 +191,6 @@
$(document).ready(function() {
prepMMAjaxeditor();
- initHideMsg();
+ //initHideMsg();
});
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs