most of the way through making the wcm tinymce extensions available from create html. still need to address:

- IE issues
- how to handle uploaded files from the create html context
- break out the filepicker backing code into its own bean (it's mingled into the XFormsBean at the moment)

also reorganizing and pruning the xforms unit test tree.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5613 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-05-03 21:26:41 +00:00
parent 5c0ece107f
commit 9c3197d467
13 changed files with 362 additions and 287 deletions

View File

@@ -787,6 +787,16 @@ public class CreateWebContentWizard extends BaseContentWizard
{ {
return this.startWorkflow; return this.startWorkflow;
} }
/**
* Provides the url to the preview sandbox containing the asset currently
* being edited.
*/
public String getPreviewSandboxUrl()
{
return AVMConstants.buildWebappUrl(AVMConstants.getCorrespondingPreviewStoreName(this.avmBrowseBean.getSandbox()),
this.avmBrowseBean.getWebapp());
}
public String getSummary() public String getSummary()
{ {

View File

@@ -68,6 +68,7 @@ public class XFormsProcessor
? "dojo.js.uncompressed.js" ? "dojo.js.uncompressed.js"
: "dojo.js"), : "dojo.js"),
"/scripts/ajax/ajax_helper.js", "/scripts/ajax/ajax_helper.js",
"/scripts/ajax/tiny_mce_wcm_extensions.js",
"/scripts/ajax/xforms.js", "/scripts/ajax/xforms.js",
"/scripts/ajax/file_picker_widget.js", "/scripts/ajax/file_picker_widget.js",
"/scripts/upload_helper.js", "/scripts/upload_helper.js",
@@ -211,7 +212,7 @@ public class XFormsProcessor
} }
final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance()); final ResourceBundle bundle = Application.getBundle(FacesContext.getCurrentInstance());
js.append("alfresco.xforms.constants.resources = {\n"); js.append("alfresco.resources = {\n");
for (String k : BUNDLE_KEYS) for (String k : BUNDLE_KEYS)
{ {
js.append(k). js.append(k).

View File

@@ -1,4 +1,4 @@
<%-- <!--
* Copyright (C) 2005-2007 Alfresco Software Limited. * Copyright (C) 2005-2007 Alfresco Software Limited.
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@@ -20,46 +20,83 @@
* and Open Source Software ("FLOSS") applications as described in Alfresco's * and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing * FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here: * the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing" * http://www.alfresco.com/legal/licensing
--%> -->
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <jsp:root version="1.2"
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> xmlns:jsp="http://java.sun.com/JSP/Page"
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> xmlns:c="http://java.sun.com/jsp/jstl/core"
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> xmlns:pr="http://www.alfresco.org/alfresco/pr"
xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<f:verbatim> <jsp:output doctype-root-element="html"
<script language="javascript" type="text/javascript" src="<%=request.getContextPath()%>/scripts/tiny_mce/tiny_mce.js"></script> doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
<script language="javascript" type="text/javascript"> doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<%-- Init the Tiny MCE in-line HTML editor --%> <jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
tinyMCE.init({ <jsp:directive.page isELIgnored="false"/>
theme : "advanced", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/tiny_mce.js">&#160;</script>
mode : "exact", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/tiny_mce_wcm_extensions.js">&#160;</script>
elements : "editor", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/file_picker_widget.js">&#160;</script>
save_callback : "saveContent", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/ajax_helper.js">&#160;</script>
plugins : "table", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/dojo/dojo.js">&#160;</script>
theme_advanced_toolbar_location : "top", <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/upload_helper.js">&#160;</script>
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,forecolor,backcolor",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_disable: "styleselect",
extended_valid_elements : "a[href|target|name],font[face|size|color|style],span[class|align|style]"
});
function saveContent(id, content)
{
document.getElementById("wizard:wizard-body:editor-output").value = content;
}
var isIE = (document.all);
</script>
<div id='editor' style='width:100%; height:360px'> <script language="javascript" type="text/javascript">
</f:verbatim> if (!String.prototype.startsWith)
<h:outputText value="#{WizardManager.bean.content}" escape="false" /> {
<f:verbatim> String.prototype.startsWith = function(s)
</div> {
</f:verbatim> return this.indexOf(s) == 0;
<h:inputHidden id="editor-output" value="#{WizardManager.bean.content}" /> }
}
<!-- Init the Tiny MCE in-line HTML editor -->
var alfresco = typeof alfresco == "undefined" ? {} : alfresco;
alfresco.constants = typeof alfresco.constants == "undefined" ? {} : alfresco.constants;
alfresco.constants.WEBAPP_CONTEXT = "${pageContext.request.contextPath}";
alfresco.constants.AVM_WEBAPP_URL = "${WizardManager.bean.previewSandboxUrl}";
alfresco.resources = {
loading: "${msg.loading}",
ide: "${msg.idle}",
add_content: "${msg.add_content}",
go_up: "${msg.go_up}",
upload: "${msg.upload}",
path: "${msg.path}",
cancel: "${msg.cancel}"
};
tinyMCE.init({
theme : "advanced",
mode : "exact",
elements : "editor",
save_callback : "saveContent",
plugins : "table",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "separator,forecolor,backcolor",
theme_advanced_buttons3_add_before : "tablecontrols,separator",
theme_advanced_disable: "styleselect",
extended_valid_elements : "a[href|target|name],font[face|size|color|style],span[class|align|style]",
urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback",
execcommand_callback: "alfresco_TinyMCE_execcommand_callback",
});
function saveContent(id, content)
{
document.getElementById("wizard:wizard-body:editor-output").value = content;
}
var isIE = (document.all);
</script>
<div id='editor' style='width:100%; height:360px'>
<h:outputText value="#{WizardManager.bean.content}" escape="false" />
</div>
<h:inputHidden id="editor-output" value="#{WizardManager.bean.content}" />
</jsp:root>

View File

@@ -41,9 +41,6 @@
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/utils/mctabs.js">&#160;</script> <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/utils/mctabs.js">&#160;</script>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/utils/form_utils.js">&#160;</script> <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/utils/form_utils.js">&#160;</script>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/themes/advanced/jscripts/image.js">&#160;</script> <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/tiny_mce/themes/advanced/jscripts/image.js">&#160;</script>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/dojo/dojo.js">&#160;</script>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/ajax_helper.js">&#160;</script>
<script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/scripts/ajax/file_picker_widget.js">&#160;</script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/xforms.css">&#160;</link> <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/xforms.css">&#160;</link>
<script type="text/javascript"> <script type="text/javascript">
alfresco = tinyMCEPopup.windowOpener.alfresco; alfresco = tinyMCEPopup.windowOpener.alfresco;

View File

@@ -105,8 +105,8 @@ alfresco.AjaxHelper._updateLoaderDisplay = function()
{ {
var ajaxLoader = alfresco.AjaxHelper._getLoaderElement(); var ajaxLoader = alfresco.AjaxHelper._getLoaderElement();
ajaxLoader.innerHTML = (alfresco.AjaxHelper._requests.length == 0 ajaxLoader.innerHTML = (alfresco.AjaxHelper._requests.length == 0
? alfresco.xforms.constants.resources["idle"] ? alfresco.resources["idle"]
: (alfresco.xforms.constants.resources["loading"] + : (alfresco.resources["loading"] +
(alfresco.AjaxHelper._requests.length > 1 (alfresco.AjaxHelper._requests.length > 1
? " (" + alfresco.AjaxHelper._requests.length + ")" ? " (" + alfresco.AjaxHelper._requests.length + ")"
: "..."))); : "...")));

View File

@@ -329,7 +329,7 @@ _showPicker: function(data)
addContentImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/add.gif"); addContentImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/add.gif");
addContentLink.appendChild(addContentImage); addContentLink.appendChild(addContentImage);
addContentLink.appendChild(d.createTextNode(alfresco.xforms.constants.resources["add_content"])); addContentLink.appendChild(d.createTextNode(alfresco.resources["add_content"]));
var navigateToParentLink = d.createElement("a"); var navigateToParentLink = d.createElement("a");
headerRightDiv.appendChild(navigateToParentLink); headerRightDiv.appendChild(navigateToParentLink);
@@ -358,7 +358,7 @@ _showPicker: function(data)
navigateToParentNodeImage.align = "absmiddle"; navigateToParentNodeImage.align = "absmiddle";
navigateToParentNodeImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/up.gif"); navigateToParentNodeImage.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + "/images/icons/up.gif");
navigateToParentLink.appendChild(navigateToParentNodeImage); navigateToParentLink.appendChild(navigateToParentNodeImage);
navigateToParentLink.appendChild(d.createTextNode(alfresco.xforms.constants.resources["go_up"])); navigateToParentLink.appendChild(d.createTextNode(alfresco.resources["go_up"]));
headerRightDiv.style.position = "absolute"; headerRightDiv.style.position = "absolute";
headerRightDiv.style.height = headerDiv.style.height; headerRightDiv.style.height = headerDiv.style.height;
@@ -380,7 +380,7 @@ _showPicker: function(data)
cancelButton.type = "button"; cancelButton.type = "button";
cancelButton.filePickerWidget = this; cancelButton.filePickerWidget = this;
cancelButton.value = alfresco.xforms.constants.resources["cancel"]; cancelButton.value = alfresco.resources["cancel"];
footerDiv.appendChild(cancelButton); footerDiv.appendChild(cancelButton);
cancelButton.style.margin = ((.5 * footerDiv.offsetHeight) - cancelButton.style.margin = ((.5 * footerDiv.offsetHeight) -
@@ -547,7 +547,7 @@ _showAddContent: function(currentPath)
dojo.dom.removeChildren(w.addContentDiv); dojo.dom.removeChildren(w.addContentDiv);
var fileName = event.target.value.replace(/.*[\/\\]([^\/\\]+)/, "$1"); var fileName = event.target.value.replace(/.*[\/\\]([^\/\\]+)/, "$1");
w.addContentDiv.appendChild(d.createTextNode(alfresco.xforms.constants.resources["upload"] + ": " + fileName)); w.addContentDiv.appendChild(d.createTextNode(alfresco.resources["upload"] + ": " + fileName));
var img = d.createElement("img"); var img = d.createElement("img");
img.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT + img.setAttribute("src", alfresco.constants.WEBAPP_CONTEXT +
"/images/icons/process_animation.gif"); "/images/icons/process_animation.gif");
@@ -661,7 +661,7 @@ _openParentPathMenu: function(target, path)
pathTextDiv.style.fontWeight = "bold"; pathTextDiv.style.fontWeight = "bold";
pathTextDiv.style.paddingLeft = "5px"; pathTextDiv.style.paddingLeft = "5px";
pathTextDiv.appendChild(d.createTextNode(alfresco.xforms.constants.resources["path"])); pathTextDiv.appendChild(d.createTextNode(alfresco.resources["path"]));
this.parentPathMenu.appendChild(pathTextDiv); this.parentPathMenu.appendChild(pathTextDiv);
var currentPathNodes = []; var currentPathNodes = [];
for (var i = 0; i < parentNodes.length; i++) for (var i = 0; i < parentNodes.length; i++)

View File

@@ -0,0 +1,225 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
////////////////////////////////////////////////////////////////////////////////
// TinyMCE extensions for wcm
//
// This script provides callbacks used for overriding the default image and
// link dialogs for presenting a file picker to browse the repository.
//
// This script requires tiny_mce.js, and some alfresco.constants to be
// loaded in advance.
////////////////////////////////////////////////////////////////////////////////
function alfresco_TinyMCE_urlconverter_callback(href, element, onsave)
{
// dojo.debug("request to convert " + href + " onsave = " + onsave);
if (onsave)
{
return (href && href.startsWith(alfresco.constants.AVM_WEBAPP_URL)
? href.substring(alfresco.constants.AVM_WEBAPP_URL.length)
: href);
}
else
{
return (href && href.startsWith("/")
? alfresco.constants.AVM_WEBAPP_URL + href
: href);
}
}
function alfresco_TinyMCE_execcommand_callback(editor_id, elm, command, user_interface, value)
{
if (command == "mceLink")
{
// BEGIN COPIED FROM ADVANCED THEME editor_template_src.js
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
var selectedText = (tinyMCE.isMSIE
? doc.selection.createRange().text
: inst.getSel().toString());
if (!tinyMCE.linkElement &&
tinyMCE.selectedElement.nodeName.toLowerCase() != "img" &&
selectedText.length <= 0)
{
return true;
}
var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
{
tinyMCE.linkElement = tinyMCE.selectedElement;
}
// Is anchor not a link
if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
{
tinyMCE.linkElement = null;
}
if (tinyMCE.linkElement)
{
href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
// Try old onclick to if copy/pasted content
if (onclick == "")
{
onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
}
onclick = tinyMCE.cleanupEventStr(onclick);
href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
// Use mce_href if defined
mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
if (mceRealHref != "")
{
href = mceRealHref;
if (tinyMCE.getParam('convert_urls'))
{
href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
}
}
action = "update";
}
var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_link_dialog.jsp",
width: 510 + tinyMCE.getLang('lang_insert_link_delta_width', 0),
height: 400 + tinyMCE.getLang('lang_insert_link_delta_height', 0) };
var dialog_props = { href: href,
target: target,
title: title,
onclick: onclick,
action: action,
className: style_class,
inline: "yes" };
tinyMCE.openWindow(window_props, dialog_props);
return true;
}
else if (command == "mceImage")
{
var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "",
title = "", onmouseover = "", onmouseout = "", action = "insert";
var img = tinyMCE.imgElement;
var inst = tinyMCE.getInstanceById(editor_id);
if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
{
img = tinyMCE.selectedElement;
tinyMCE.imgElement = img;
}
if (img)
{
// Is it a internal MCE visual aid image, then skip this one.
if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
{
return true;
}
src = tinyMCE.getAttrib(img, 'src');
alt = tinyMCE.getAttrib(img, 'alt');
// Try polling out the title
if (alt == "")
{
alt = tinyMCE.getAttrib(img, 'title');
}
// Fix width/height attributes if the styles is specified
if (tinyMCE.isGecko)
{
var w = img.style.width;
if (w != null && w.length != 0)
{
img.setAttribute("width", w);
}
var h = img.style.height;
if (h != null && h.length != 0)
{
img.setAttribute("height", h);
}
}
border = tinyMCE.getAttrib(img, 'border');
hspace = tinyMCE.getAttrib(img, 'hspace');
vspace = tinyMCE.getAttrib(img, 'vspace');
width = tinyMCE.getAttrib(img, 'width');
height = tinyMCE.getAttrib(img, 'height');
align = tinyMCE.getAttrib(img, 'align');
onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
title = tinyMCE.getAttrib(img, 'title');
// Is realy specified?
if (tinyMCE.isMSIE)
{
width = img.attributes['width'].specified ? width : "";
height = img.attributes['height'].specified ? height : "";
}
//onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
//onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
// Use mce_src if defined
mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
if (mceRealSrc != "")
{
src = mceRealSrc;
if (tinyMCE.getParam('convert_urls'))
{
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
}
}
action = "update";
}
var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_image_dialog.jsp",
width: 510 + tinyMCE.getLang('lang_insert_image_delta_width', 0),
height: 400 + (tinyMCE.isMSIE ? 25 : 0) + tinyMCE.getLang('lang_insert_image_delta_height', 0) };
var dialog_props = { src: src,
alt: alt,
border: border,
hspace: hspace,
vspace: vspace,
width: width,
height: height,
align: align,
title: title,
onmouseover: onmouseover,
onmouseout: onmouseout,
action: action,
inline: "yes" };
tinyMCE.openWindow(window_props, dialog_props);
return true;
}
else
{
return false;
}
}

View File

@@ -20,8 +20,8 @@
// //
// This script communicates with the XFormBean to produce and manage an xform. // This script communicates with the XFormBean to produce and manage an xform.
// //
// This script requires dojo.js, tiny_mce.js, and upload_helper.js to be // This script requires dojo.js, tiny_mce.js, tiny_mce_wcm_extensions.js, and
// loaded in advance. // upload_helper.js to be loaded in advance.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -988,9 +988,9 @@ dojo.declare("alfresco.xforms.RichTextEditor",
{ {
this.hoverLayer = document.createElement("div"); this.hoverLayer = document.createElement("div");
dojo.html.setClass(this.hoverLayer, "xformsRichTextEditorHoverLayer"); dojo.html.setClass(this.hoverLayer, "xformsRichTextEditorHoverLayer");
this.hoverLayer.appendChild(document.createTextNode(alfresco.xforms.constants.resources["click_to_edit"])); this.hoverLayer.appendChild(document.createTextNode(alfresco.resources["click_to_edit"]));
} }
if (!this.hoverLayer.parentNode) if (this.hoverLayer.parentNode != this.widget)
{ {
this.widget.appendChild(this.hoverLayer); this.widget.appendChild(this.hoverLayer);
this.hoverLayer.style.lineHeight = this.hoverLayer.offsetHeight + "px"; this.hoverLayer.style.lineHeight = this.hoverLayer.offsetHeight + "px";
@@ -1009,7 +1009,7 @@ dojo.declare("alfresco.xforms.RichTextEditor",
_hoverLayer_mouseoutHandler: function(event) _hoverLayer_mouseoutHandler: function(event)
{ {
if (this.hoverLayer.parentNode) if (this.hoverLayer.parentNode == this.widget)
{ {
this.widget.removeChild(this.hoverLayer); this.widget.removeChild(this.hoverLayer);
} }
@@ -1017,7 +1017,7 @@ dojo.declare("alfresco.xforms.RichTextEditor",
_hoverLayer_clickHandler: function(event) _hoverLayer_clickHandler: function(event)
{ {
if (this.hoverLayer.parentNode) if (this.hoverLayer.parentNode == this.widget)
{ {
this.widget.removeChild(this.hoverLayer); this.widget.removeChild(this.hoverLayer);
this._createTinyMCE(); this._createTinyMCE();
@@ -1260,7 +1260,7 @@ dojo.declare("alfresco.xforms.ListSelect",
} }
} }
this._commitValueChange(); this._commitValueChange();
}, }
}); });
/** /**
@@ -1522,7 +1522,7 @@ dojo.declare("alfresco.xforms.DatePicker",
: null); : null);
// XXXarielb - change to a static // XXXarielb - change to a static
this._noValueSet = (alfresco.xforms.constants.resources["eg"] + " " + this._noValueSet = (alfresco.resources["eg"] + " " +
dojo.date.format(new Date(), dojo.date.format(new Date(),
{datePattern: alfresco.xforms.constants.DATE_FORMAT, {datePattern: alfresco.xforms.constants.DATE_FORMAT,
selector: 'dateOnly'})); selector: 'dateOnly'}));
@@ -1692,7 +1692,7 @@ dojo.declare("alfresco.xforms.TimePicker",
function(xform, xformsNode) function(xform, xformsNode)
{ {
dojo.require("dojo.widget.TimePicker"); dojo.require("dojo.widget.TimePicker");
this._noValueSet = (alfresco.xforms.constants.resources["eg"] + " " + this._noValueSet = (alfresco.resources["eg"] + " " +
dojo.date.format(new Date(), dojo.date.format(new Date(),
{timePattern: alfresco.xforms.constants.TIME_FORMAT, {timePattern: alfresco.xforms.constants.TIME_FORMAT,
selector: "timeOnly"})); selector: "timeOnly"}));
@@ -1864,7 +1864,7 @@ dojo.declare("alfresco.xforms.DateTimePicker",
dojo.require("dojo.widget.DatePicker"); dojo.require("dojo.widget.DatePicker");
dojo.require("dojo.widget.TimePicker"); dojo.require("dojo.widget.TimePicker");
this._noValueSet = (alfresco.xforms.constants.resources["eg"] + " " + this._noValueSet = (alfresco.resources["eg"] + " " +
dojo.date.format(new Date(), dojo.date.format(new Date(),
{datePattern: alfresco.xforms.constants.DATE_TIME_FORMAT, {datePattern: alfresco.xforms.constants.DATE_TIME_FORMAT,
selector: "dateOnly"})); selector: "dateOnly"}));
@@ -4411,7 +4411,7 @@ dojo.declare("alfresco.xforms.XForm",
{ {
this.submitWidget = null; this.submitWidget = null;
var invalid = this.rootWidget.getWidgetsInvalidForSubmit(); var invalid = this.rootWidget.getWidgetsInvalidForSubmit();
_show_error(document.createTextNode(alfresco.xforms.constants.resources["validation_provide_values_for_required_fields"])); _show_error(document.createTextNode(alfresco.resources["validation_provide_values_for_required_fields"]));
var error_list = document.createElement("ul"); var error_list = document.createElement("ul");
for (var j = 0; j < invalid.length; j++) for (var j = 0; j < invalid.length; j++)
{ {
@@ -4635,6 +4635,7 @@ dojo.html.toCamelCase = function(str)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// tiny mce integration // tiny mce integration
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
tinyMCE.init({ tinyMCE.init({
theme: "advanced", theme: "advanced",
mode: "exact", mode: "exact",
@@ -4654,267 +4655,71 @@ tinyMCE.init({
urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback" urlconverter_callback: "alfresco_TinyMCE_urlconverter_callback"
}); });
function alfresco_TinyMCE_urlconverter_callback(href, element, onsave)
{
dojo.debug("request to convert " + href + " onsave = " + onsave);
if (onsave)
{
return (href && href.startsWith(alfresco.constants.AVM_WEBAPP_URL)
? href.substring(alfresco.constants.AVM_WEBAPP_URL.length)
: href);
}
else
{
return (href && href.startsWith("/")
? alfresco.constants.AVM_WEBAPP_URL + href
: href);
}
}
function alfresco_TinyMCE_execcommand_callback(editor_id, elm, command, user_interface, value)
{
if (command == "mceLink")
{
// BEGIN COPIED FROM ADVANCED THEME editor_template_src.js
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
var selectedText = (tinyMCE.isMSIE
? doc.selection.createRange().text
: inst.getSel().toString());
if (!tinyMCE.linkElement &&
tinyMCE.selectedElement.nodeName.toLowerCase() != "img" &&
selectedText.length <= 0)
{
return true;
}
var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
{
tinyMCE.linkElement = tinyMCE.selectedElement;
}
// Is anchor not a link
if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
{
tinyMCE.linkElement = null;
}
if (tinyMCE.linkElement)
{
href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
// Try old onclick to if copy/pasted content
if (onclick == "")
{
onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
}
onclick = tinyMCE.cleanupEventStr(onclick);
href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
// Use mce_href if defined
mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
if (mceRealHref != "")
{
href = mceRealHref;
if (tinyMCE.getParam('convert_urls'))
{
href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
}
}
action = "update";
}
var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_link_dialog.jsp",
width: 510 + tinyMCE.getLang('lang_insert_link_delta_width', 0),
height: 400 + tinyMCE.getLang('lang_insert_link_delta_height', 0) };
var dialog_props = { href: href,
target: target,
title: title,
onclick: onclick,
action: action,
className: style_class,
inline: "yes" };
tinyMCE.openWindow(window_props, dialog_props);
return true;
}
else if (command == "mceImage")
{
var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "",
title = "", onmouseover = "", onmouseout = "", action = "insert";
var img = tinyMCE.imgElement;
var inst = tinyMCE.getInstanceById(editor_id);
if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
{
img = tinyMCE.selectedElement;
tinyMCE.imgElement = img;
}
if (img)
{
// Is it a internal MCE visual aid image, then skip this one.
if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
{
return true;
}
src = tinyMCE.getAttrib(img, 'src');
alt = tinyMCE.getAttrib(img, 'alt');
// Try polling out the title
if (alt == "")
{
alt = tinyMCE.getAttrib(img, 'title');
}
// Fix width/height attributes if the styles is specified
if (tinyMCE.isGecko)
{
var w = img.style.width;
if (w != null && w.length != 0)
{
img.setAttribute("width", w);
}
var h = img.style.height;
if (h != null && h.length != 0)
{
img.setAttribute("height", h);
}
}
border = tinyMCE.getAttrib(img, 'border');
hspace = tinyMCE.getAttrib(img, 'hspace');
vspace = tinyMCE.getAttrib(img, 'vspace');
width = tinyMCE.getAttrib(img, 'width');
height = tinyMCE.getAttrib(img, 'height');
align = tinyMCE.getAttrib(img, 'align');
onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
title = tinyMCE.getAttrib(img, 'title');
// Is realy specified?
if (tinyMCE.isMSIE)
{
width = img.attributes['width'].specified ? width : "";
height = img.attributes['height'].specified ? height : "";
}
//onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
//onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
// Use mce_src if defined
mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
if (mceRealSrc != "")
{
src = mceRealSrc;
if (tinyMCE.getParam('convert_urls'))
{
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
}
}
action = "update";
}
var window_props = { file: alfresco.constants.WEBAPP_CONTEXT + "/jsp/wcm/tiny_mce_image_dialog.jsp",
width: 510 + tinyMCE.getLang('lang_insert_image_delta_width', 0),
height: 400 + (tinyMCE.isMSIE ? 25 : 0) + tinyMCE.getLang('lang_insert_image_delta_height', 0) };
var dialog_props = { src: src,
alt: alt,
border: border,
hspace: hspace,
vspace: vspace,
width: width,
height: height,
align: align,
title: title,
onmouseover: onmouseover,
onmouseout: onmouseout,
action: action,
inline: "yes" };
tinyMCE.openWindow(window_props, dialog_props);
return true;
}
else
{
return false;
}
}
alfresco.xforms.widgetConfig = alfresco.xforms.widgetConfig =
{ {
"xf:group": "xf:group":
{ {
"*": { "minimal": { "className": alfresco.xforms.HGroup }, "*": { "className": alfresco.xforms.VGroup }} "*": { "minimal": { className: alfresco.xforms.HGroup }, "*": { className: alfresco.xforms.VGroup }}
}, },
"xf:repeat": "xf:repeat":
{ {
"*": { "*": { "className": alfresco.xforms.Repeat } } "*": { "*": { className: alfresco.xforms.Repeat } }
}, },
"xf:textarea": "xf:textarea":
{ {
"*": { "minimal": { "className": alfresco.xforms.PlainTextEditor }, "*":
"*": { "className": alfresco.xforms.RichTextEditor, params: [ "bold,italic,underline,separator,forecolor,backcolor,separator,link,unlink,image", "", "" ] }, {
"full": { "className": alfresco.xforms.RichTextEditor, params: ["bold,italic,underline,strikethrough,separator,fontselect,fontsizeselect", "link,unlink,image,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,forecolor,backcolor", "" ] }}, "minimal": { className: alfresco.xforms.PlainTextEditor },
"*": { className: alfresco.xforms.RichTextEditor, params: [ "bold,italic,underline,separator,forecolor,backcolor,separator,link,unlink,image", "", "" ] },
"full": { className: alfresco.xforms.RichTextEditor, params: ["bold,italic,underline,strikethrough,separator,fontselect,fontsizeselect", "link,unlink,image,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,separator,undo,redo,separator,forecolor,backcolor", "" ] }
}
}, },
"xf:upload": "xf:upload":
{ {
"*": { "*": { "className": alfresco.xforms.FilePicker } } "*": { "*": { className: alfresco.xforms.FilePicker } }
}, },
"xf:range": "xf:range":
{ {
"*": { "*": { "className": alfresco.xforms.NumericalRange } } "*": { "*": { className: alfresco.xforms.NumericalRange } }
}, },
"xf:input": "xf:input":
{ {
"date": { "*": { "className": alfresco.xforms.DatePicker }}, "date": { "*": { className: alfresco.xforms.DatePicker }},
"time": { "*": { "className": alfresco.xforms.TimePicker }}, "time": { "*": { className: alfresco.xforms.TimePicker }},
"gDay": { "*": { "className": alfresco.xforms.DayPicker }}, "gDay": { "*": { className: alfresco.xforms.DayPicker }},
"gMonth": { "*": { "className": alfresco.xforms.MonthPicker }}, "gMonth": { "*": { className: alfresco.xforms.MonthPicker }},
"gYear": { "*": { "className": alfresco.xforms.YearPicker }}, "gYear": { "*": { className: alfresco.xforms.YearPicker }},
"gMonthDay": { "*": { "className": alfresco.xforms.MonthDayPicker }}, "gMonthDay": { "*": { className: alfresco.xforms.MonthDayPicker }},
"gYearMonth": { "*": { "className": alfresco.xforms.YearMonthPicker }}, "gYearMonth": { "*": { className: alfresco.xforms.YearMonthPicker }},
"dateTime": { "*": { "className": alfresco.xforms.DateTimePicker }}, "dateTime": { "*": { className: alfresco.xforms.DateTimePicker }},
"*": { "*": { "className": alfresco.xforms.TextField }} "*": { "*": { className: alfresco.xforms.TextField }}
}, },
"xf:select1": "xf:select1":
{ {
"boolean": { "*": { "className": alfresco.xforms.Checkbox }}, "boolean": { "*": { className: alfresco.xforms.Checkbox }},
"*": { "full": { "className": alfresco.xforms.RadioSelect1}, "*": { "full": { className: alfresco.xforms.RadioSelect1},
"*": { "className": alfresco.xforms.ComboboxSelect1 }} "*": { className: alfresco.xforms.ComboboxSelect1 }}
}, },
"xf:select": "xf:select":
{ {
"*": { "full": { "className": alfresco.xforms.CheckboxSelect}, "*": { "full": { className: alfresco.xforms.CheckboxSelect},
"*": { "className": alfresco.xforms.ListSelect }} "*": { className: alfresco.xforms.ListSelect }}
}, },
"xf:submit": "xf:submit":
{ {
"*": { "*": { "className": alfresco.xforms.Submit } } "*": { "*": { className: alfresco.xforms.Submit } }
}, },
"xf:trigger": "xf:trigger":
{ {
"*": { "*": { "className": alfresco.xforms.Trigger }} "*": { "*": { className: alfresco.xforms.Trigger }}
}, },
"xf:switch": "xf:switch":
{ {
"*": { "*": { "className": alfresco.xforms.SwitchGroup } } "*": { "*": { className: alfresco.xforms.SwitchGroup } }
}, },
"xf:case": "xf:case":
{ {
"*": { "*": { "className": alfresco.xforms.CaseGroup }} "*": { "*": { className: alfresco.xforms.CaseGroup }}
}, },
"chiba:data": { "*": { "*": null } }, "chiba:data": { "*": { "*": null } },
"xf:label": { "*": { "*": null } }, "xf:label": { "*": { "*": null } },