Integrated ButtonHelper for FancyBox2

git-svn-id: https://svn.libreccm.org/ccm/trunk@2665 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-06-04 10:49:14 +00:00
parent 1c04f489fe
commit ebede11827
7 changed files with 503 additions and 474 deletions

View File

@ -46,188 +46,200 @@ import org.apache.log4j.Logger;
*/ */
public final class AssignedTaskSection extends Section { public final class AssignedTaskSection extends Section {
private static final Logger s_log = Logger.getLogger(AssignedTaskSection.class); private static final Logger s_log = Logger.getLogger(AssignedTaskSection.class);
private final WorkflowRequestLocal m_workflow; private final WorkflowRequestLocal m_workflow;
private final WorkflowFacade m_facade; private final WorkflowFacade m_facade;
public AssignedTaskSection(final WorkflowRequestLocal workflow, public AssignedTaskSection(final WorkflowRequestLocal workflow,
final Component subject) { final Component subject) {
super(gz("cms.ui.workflow.task.assigned")); super(gz("cms.ui.workflow.task.assigned"));
m_workflow = workflow; m_workflow = workflow;
m_facade = new WorkflowFacade(m_workflow); m_facade = new WorkflowFacade(m_workflow);
final ActionGroup group = new ActionGroup(); final ActionGroup group = new ActionGroup();
setBody(group); setBody(group);
group.setSubject(subject); group.setSubject(subject);
group.addAction(new RestartLink()); group.addAction(new RestartLink());
group.addAction(new LockLink()); group.addAction(new LockLink());
group.addAction(new UnlockLink()); group.addAction(new UnlockLink());
} }
@Override @Override
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_workflow.getWorkflow(state) != null; return m_workflow.getWorkflow(state) != null;
} }
private class RestartLink extends ActionLink { private class RestartLink extends ActionLink {
RestartLink() { RestartLink() {
super(new Label(gz("cms.ui.workflow.restart_stopped_workflow"))); super(new Label(gz("cms.ui.workflow.restart_stopped_workflow")));
addActionListener(new Listener()); addActionListener(new Listener());
} }
@Override @Override
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.INIT) || m_facade.workflowState(state, Workflow.STOPPED); return m_facade.workflowState(state, Workflow.INIT) || m_facade.workflowState(state,
} Workflow.STOPPED);
}
private class Listener implements ActionListener { private class Listener implements ActionListener {
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
m_facade.restartWorkflow(e.getPageState()); m_facade.restartWorkflow(e.getPageState());
} }
}
}
private class LockLink extends ActionLink { }
LockLink() { }
super(new Label(gz("cms.ui.workflow.task.assigned.lock_all")));
addActionListener(new Listener()); private class LockLink extends ActionLink {
}
@Override LockLink() {
public final boolean isVisible(final PageState state) { super(new Label(gz("cms.ui.workflow.task.assigned.lock_all")));
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state) && !m_facade.tasksLocked(state);
}
private class Listener implements ActionListener { addActionListener(new Listener());
}
public final void actionPerformed(final ActionEvent e) { @Override
m_facade.lockTasks(e.getPageState()); public final boolean isVisible(final PageState state) {
} return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state)
} && !m_facade.tasksLocked(state);
} }
private class UnlockLink extends ActionLink { private class Listener implements ActionListener {
UnlockLink() { public final void actionPerformed(final ActionEvent e) {
super(new Label(gz("cms.ui.workflow.task.assigned.unlock_all"))); m_facade.lockTasks(e.getPageState());
}
addActionListener(new UnlockLink.Listener()); }
}
@Override }
public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state) && m_facade.tasksLocked(state);
}
private class Listener implements ActionListener { private class UnlockLink extends ActionLink {
public final void actionPerformed(final ActionEvent e) { UnlockLink() {
m_facade.unlockTasks(e.getPageState()); super(new Label(gz("cms.ui.workflow.task.assigned.unlock_all")));
}
}
}
private class WorkflowFacade { addActionListener(new UnlockLink.Listener());
}
private final WorkflowRequestLocal m_flow; @Override
private final TaskListRequestLocal m_tasks; public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state)
&& m_facade.tasksLocked(state);
}
WorkflowFacade(final WorkflowRequestLocal flow) { private class Listener implements ActionListener {
m_flow = flow;
m_tasks = new TaskListRequestLocal();
}
private class TaskListRequestLocal extends RequestLocal { public final void actionPerformed(final ActionEvent e) {
m_facade.unlockTasks(e.getPageState());
}
@Override }
protected final Object initialValue(final PageState state) {
final Workflow workflow = m_flow.getWorkflow(state);
final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
return engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID());
}
final ArrayList getTasks(final PageState state) { }
return (ArrayList) get(state);
}
}
final void restartWorkflow(final PageState state) { private class WorkflowFacade {
final Workflow workflow = m_flow.getWorkflow(state);
workflow.start(Web.getWebContext().getUser());
workflow.save();
// Lock tasks if not locked private final WorkflowRequestLocal m_flow;
if (!tasksLocked(state)) { private final TaskListRequestLocal m_tasks;
lockTasks(state);
}
}
final void lockTasks(final PageState state) { WorkflowFacade(final WorkflowRequestLocal flow) {
final Iterator iter = m_tasks.getTasks(state).iterator(); m_flow = flow;
m_tasks = new TaskListRequestLocal();
}
while (iter.hasNext()) { private class TaskListRequestLocal extends RequestLocal {
final CMSTask task = (CMSTask) iter.next();
if (relevant(task) && !task.isLocked()) { @Override
task.lock(Web.getWebContext().getUser()); protected final Object initialValue(final PageState state) {
task.save(); final Workflow workflow = m_flow.getWorkflow(state);
} final Engine engine = Engine.getInstance(CMSEngine.CMS_ENGINE_TYPE);
} return engine.getEnabledTasks(Web.getWebContext().getUser(), workflow.getID());
} }
final void unlockTasks(final PageState state) { final ArrayList getTasks(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator(); return (ArrayList) get(state);
}
while (iter.hasNext()) { }
final CMSTask task = (CMSTask) iter.next();
if (relevant(task) && task.isLocked()) { final void restartWorkflow(final PageState state) {
task.unlock(Web.getWebContext().getUser()); final Workflow workflow = m_flow.getWorkflow(state);
task.save(); workflow.start(Web.getWebContext().getUser());
} workflow.save();
}
}
final boolean tasksLocked(final PageState state) { // Lock tasks if not locked
final Iterator iter = m_tasks.getTasks(state).iterator(); if (!tasksLocked(state)) {
lockTasks(state);
}
}
while (iter.hasNext()) { final void lockTasks(final PageState state) {
final CMSTask task = (CMSTask) iter.next(); final Iterator iter = m_tasks.getTasks(state).iterator();
if (relevant(task) && !task.isLocked()) { while (iter.hasNext()) {
return false; final CMSTask task = (CMSTask) iter.next();
}
}
return true; if (relevant(task) && !task.isLocked()) {
} task.lock(Web.getWebContext().getUser());
task.save();
}
}
}
final boolean workflowState(final PageState state, int processState) { final void unlockTasks(final PageState state) {
return m_flow.getWorkflow(state).getProcessState() == processState; final Iterator iter = m_tasks.getTasks(state).iterator();
}
final boolean tasksExist(final PageState state) { while (iter.hasNext()) {
return !m_tasks.getTasks(state).isEmpty(); final CMSTask task = (CMSTask) iter.next();
}
private boolean relevant(final CMSTask task) { if (relevant(task) && task.isLocked()) {
return task.getTaskType().getID().equals(CMSTaskType.AUTHOR) task.unlock(Web.getWebContext().getUser());
|| task.getTaskType().getID().equals(CMSTaskType.EDIT); task.save();
} }
} }
}
protected final static GlobalizedMessage gz(final String key) { final boolean tasksLocked(final PageState state) {
return GlobalizationUtil.globalize(key); final Iterator iter = m_tasks.getTasks(state).iterator();
}
while (iter.hasNext()) {
final CMSTask task = (CMSTask) iter.next();
if (relevant(task) && !task.isLocked()) {
return false;
}
}
return true;
}
final boolean workflowState(final PageState state, int processState) {
return m_flow.getWorkflow(state).getProcessState() == processState;
}
final boolean tasksExist(final PageState state) {
return !m_tasks.getTasks(state).isEmpty();
}
private boolean relevant(final CMSTask task) {
return task.getTaskType().getID().equals(CMSTaskType.AUTHOR)
|| task.getTaskType().getID().equals(CMSTaskType.EDIT);
}
}
protected final static GlobalizedMessage gz(final String key) {
return GlobalizationUtil.globalize(key);
}
protected final static String lz(final String key) {
return (String) gz(key).localize();
}
protected final static String lz(final String key) {
return (String) gz(key).localize();
}
} }

View File

@ -1,431 +1,441 @@
OpenCCM.prototype.showImageDialog = function(image) OpenCCM.prototype.showImageDialog = function(image)
{ {
if (!this.dialogs["images"]) if (!this.dialogs["images"])
{
this.prepareImageDialog();
}
var editor = this.editor;
this.image = image;
var data =
{
src : "",
name : "",
alt : "",
title : "",
width : "",
height : "",
caption : "",
alignment : "",
caption : "",
fancybox : "",
aspect : ""
};
if (typeof image == "undefined" )
{
image = editor.getParentElement();
if ( image && image.tagName.toLowerCase() != "img" )
{ {
image = null; this.prepareImageDialog();
} }
}
this.image = image; var editor = this.editor;
this.image = image;
if (image && image.tagName.toLowerCase() == "img") var data =
{ {
data.src = this.editor.fixRelativeLinks(image.getAttribute("src")); src: "",
data.alt = image.getAttribute("alt"); name: "",
data.name = image.getAttribute("name"); alt: "",
data.title = image.getAttribute("title"); title: "",
data.width = image.getAttribute("width"); width: "",
data.height = image.getAttribute("height"); height: "",
caption: "",
alignment: "",
caption : "",
fancybox: "",
aspect: ""
};
if (image.parentNode.tagName.toLowerCase() == "div") if (typeof image == "undefined")
{ {
// Parent node is not a link, so there is not zoom or gallery function image = editor.getParentElement();
alignment = image.parentNode.getAttribute("class"); if (image && image.tagName.toLowerCase() != "img")
if (alignment != "image none") {
{ image = null;
data.alignment = alignment.substring(alignment.indexOf(" ") + 1); }
} }
else
{
data.alignment = "none";
}
data.caption = (image.nextSibling.tagName.toLowerCase() == "span" && image.nextSibling.firstChild) ? image.nextSibling.firstChild.nodeValue : "";
data.fancybox = "none"; this.image = image;
if (image && image.tagName.toLowerCase() == "img")
{
data.src = this.editor.fixRelativeLinks(image.getAttribute("src"));
data.alt = image.getAttribute("alt");
data.name = image.getAttribute("name");
data.title = image.getAttribute("title");
data.width = image.getAttribute("width");
data.height = image.getAttribute("height");
if (image.parentNode.tagName.toLowerCase() == "div")
{
// Parent node is not a link, so there is not zoom or gallery function
alignment = image.parentNode.getAttribute("class");
if (alignment != "image none")
{
data.alignment = alignment.substring(alignment.indexOf(" ") + 1);
}
else
{
data.alignment = "none";
}
data.caption = (image.nextSibling.tagName.toLowerCase() == "span" && image.nextSibling.firstChild) ? image.nextSibling.firstChild.nodeValue : "";
data.fancybox = "none";
// data.galleryName = ""; // data.galleryName = "";
}
else
{
// Parent node is a link
alignment = image.parentNode.parentNode.getAttribute("class");
if (alignment != "image none")
{
data.alignment = alignment.substring(alignment.indexOf(" ") + 1);
}
else
{
data.alignment = "none";
}
data.fancybox = image.parentNode.getAttribute("class");
// data.galleryName = (image.parentNode.getAttribute("class") == "imageGallery") ? image.parentNode.getAttribute("rel") : "";
data.caption = (image.parentNode.nextSibling.tagName.toLowerCase() == "span" && image.parentNode.nextSibling.firstChild) ? image.parentNode.nextSibling.firstChild.nodeValue : "";
}
// Calculate aspect ratio
data.aspect = data.width / data.height;
} }
else else
{ {
// Parent node is a link data.alignment = "none";
alignment = image.parentNode.parentNode.getAttribute("class");
if (alignment != "image none")
{
data.alignment = alignment.substring(alignment.indexOf(" ") + 1);
}
else
{
data.alignment="none";
}
data.fancybox = image.parentNode.getAttribute("class");
// data.galleryName = (image.parentNode.getAttribute("class") == "imageGallery") ? image.parentNode.getAttribute("rel") : "";
data.caption = (image.parentNode.nextSibling.tagName.toLowerCase() == "span" && image.parentNode.nextSibling.firstChild) ? image.parentNode.nextSibling.firstChild.nodeValue : "";
}
// Calculate aspect ratio
data.aspect = data.width / data.height;
}
else
{
data.alignment = "none";
// data.caption = ""; // data.caption = "";
data.fancybox = "none"; data.fancybox = "none";
// data.galleryName = ""; // data.galleryName = "";
} }
// now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog
this.dialogs["images"].show(data);
// If image set, show preview // now calling the show method of the Xinha.Dialog object to set the values and show the actual dialog
if(data.src != "") this.dialogs["images"].show(data);
{
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src; // If image set, show preview
this.resizePreview(this.dialogs["images"]); if (data.src != "")
this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "block"; {
} this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src;
else this.resizePreview(this.dialogs["images"]);
{ this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "block";
// Preview dekativieren }
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = "about:blank"; else
this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "none"; {
} // Preview dekativieren
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = "about:blank";
this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "none";
}
}; };
OpenCCM.prototype.prepareImageDialog = function() OpenCCM.prototype.prepareImageDialog = function()
{ {
var self = this; var self = this;
var editor = this.editor; var editor = this.editor;
var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha',{width:410})
// Connect the OK and Cancel buttons var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha', {width: 410})
dialog.getElementById("ok").onclick = function() {self.imageApply();}
dialog.getElementById("remove").onclick = function() { self.imageRemove(); };
dialog.getElementById("cancel").onclick = function() { self.dialogs["images"].hide(); };
// Connect the Select button // Connect the OK and Cancel buttons
dialog.getElementById("browse").onclick = function() { self.imageBrowse(window); }; dialog.getElementById("ok").onclick = function() {
self.imageApply();
}
dialog.getElementById("remove").onclick = function() {
self.imageRemove();
};
dialog.getElementById("cancel").onclick = function() {
self.dialogs["images"].hide();
};
// Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio // Connect the Select button
dialog.getElementById("width").onkeyup = function() { self.calcHeight(); }; dialog.getElementById("browse").onclick = function() {
dialog.getElementById("height").onkeyup = function() { self.calcWidth(); }; self.imageBrowse(window);
};
// OnResize // Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio
this.dialogs["images"].onresize = function () dialog.getElementById("width").onkeyup = function() {
{ self.calcHeight();
self.resizeDialog(this); };
}; dialog.getElementById("height").onkeyup = function() {
self.calcWidth();
};
this.imageDialogReady = true; // OnResize
this.dialogs["images"].onresize = function()
{
self.resizeDialog(this);
};
this.imageDialogReady = true;
}; };
// Write HTML code // Write HTML code
OpenCCM.prototype.imageApply = function() OpenCCM.prototype.imageApply = function()
{ {
var values = this.dialogs["images"].hide(); var values = this.dialogs["images"].hide();
var image = this.image; var image = this.image;
var editor = this.editor; var editor = this.editor;
var modifyImage = (image != null && image.tagName.toLowerCase() == "img"); var modifyImage = (image != null && image.tagName.toLowerCase() == "img");
var imgAttr =
{
src : "",
alt : "",
title : "",
name : "",
width : "",
height : ""
};
var spanAttr = var imgAttr =
{ {
class : "caption", src: "",
style : "", alt: "",
} title: "",
name: "",
width: "",
height: ""
};
var linkAttr = var spanAttr =
{ {
href : "", class: "caption",
title : "", style: "",
rel : "", }
class : ""
};
var divAttr = var linkAttr =
{ {
class : "image" href: "",
}; title: "",
rel: "",
class: ""
};
// If not all mandatory informations are set var divAttr =
if (!values.src) {
{ class: "image"
// don't do anything at all };
return false;
}
// Read form values for image // If not all mandatory informations are set
imgAttr.src = values.src; if (!values.src)
imgAttr.alt = values.alt;
imgAttr.name = values.name;
imgAttr.title = values.title;
imgAttr.width = values.width;
imgAttr.height = values.height;
// Read form values for caption
if(values.caption)
{
spanAttr.style = "width:" + imgAttr.width + "px";
}
// Read form values for link
if(values.fancybox.value == "imageZoom")
{
linkAttr.href = values.src;
linkAttr.title = values.title;
linkAttr.rel = "";
linkAttr.class = "imageZoom";
}
else if(values.fancybox.value == "imageGallery")
{
linkAttr.href = values.src;
linkAttr.title = values.title;
linkAttr.rel = "imageGallery";
linkAttr.class = "imageGallery";
}
// Read form values for div
if(values.alignment.value != "")
{
divAttr.class += " " + values.alignment.value;
}
var div;
// Modify Image
if(modifyImage)
{
// Get the parent for img node
div = image.parentNode;
// if the tagname of div is "a"
if(div.tagName.toLowerCase() == "a")
{ {
// go up one level to find the real div // don't do anything at all
div = div.parentNode; return false;
} }
// remove all childs from div.image // Read form values for image
while (div.childNodes.length > 0) imgAttr.src = values.src;
imgAttr.alt = values.alt;
imgAttr.name = values.name;
imgAttr.title = values.title;
imgAttr.width = values.width;
imgAttr.height = values.height;
// Read form values for caption
if (values.caption)
{ {
div.removeChild(div.firstChild); spanAttr.style = "width:" + imgAttr.width + "px";
} }
}
// Add Image
else
{
// create new div.image
div = document.createElement("div");
}
// set attributes for div // Read form values for link
for(var attr in divAttr) if (values.fancybox.value == "imageZoom")
{
div.setAttribute(attr, divAttr[attr]);
}
// the folling has to be done for both cases
// insert link, if fancybox features are activated
if(values.fancybox.value != "none")
{
link = document.createElement("a");
for(var attr in linkAttr)
{ {
link.setAttribute(attr, linkAttr[attr]); linkAttr.href = values.src;
linkAttr.title = values.title;
linkAttr.rel = "";
linkAttr.class = "imageZoom";
} }
div.appendChild(link);
}
// insert the image, obviously else if (values.fancybox.value == "imageGallery")
var img = document.createElement("img");
for(var attr in imgAttr)
{
img.setAttribute(attr, imgAttr[attr]);
}
if(values.fancybox.value != "none")
{
link.appendChild(img);
}
else
{
div.appendChild(img);
}
// insert caption if selected
if(values.caption)
{
var span = document.createElement("span");
for(var attr in spanAttr)
{ {
span.setAttribute(attr, spanAttr[attr]); linkAttr.href = values.src;
linkAttr.title = values.title;
linkAttr.rel = "imageGallery";
linkAttr.class = "imageGallery";
} }
span.appendChild(document.createTextNode(imgAttr.title));
div.appendChild(span);
}
// insert new div only if we not modifying an image // Read form values for div
if(!modifyImage) { if (values.alignment.value != "")
editor.insertNodeAtSelection(div); {
} divAttr.class += " " + values.alignment.value;
}
// set cursor after div var div;
this.editor.selectNodeContents(div.nextSibling, 0);
// Modify Image
if (modifyImage)
{
// Get the parent for img node
div = image.parentNode;
// if the tagname of div is "a"
if (div.tagName.toLowerCase() == "a")
{
// go up one level to find the real div
div = div.parentNode;
}
// remove all childs from div.image
while (div.childNodes.length > 0)
{
div.removeChild(div.firstChild);
}
}
// Add Image
else
{
// create new div.image
div = document.createElement("div");
}
// set attributes for div
for (var attr in divAttr)
{
div.setAttribute(attr, divAttr[attr]);
}
// the folling has to be done for both cases
// insert link, if fancybox features are activated
if (values.fancybox.value != "none")
{
link = document.createElement("a");
for (var attr in linkAttr)
{
link.setAttribute(attr, linkAttr[attr]);
}
div.appendChild(link);
}
// insert the image, obviously
var img = document.createElement("img");
for (var attr in imgAttr)
{
img.setAttribute(attr, imgAttr[attr]);
}
if (values.fancybox.value != "none")
{
link.appendChild(img);
}
else
{
div.appendChild(img);
}
// insert caption if selected
if (values.caption)
{
var span = document.createElement("span");
for (var attr in spanAttr)
{
span.setAttribute(attr, spanAttr[attr]);
}
span.appendChild(document.createTextNode(imgAttr.title));
div.appendChild(span);
}
// insert new div only if we not modifying an image
if (!modifyImage) {
editor.insertNodeAtSelection(div);
}
// set cursor after div
this.editor.selectNodeContents(div.nextSibling, 0);
}; };
OpenCCM.prototype.imageRemove = function() OpenCCM.prototype.imageRemove = function()
{ {
// Close the dialog // Close the dialog
this.dialogs["images"].hide(); this.dialogs["images"].hide();
// Get the parent div for img node // Get the parent div for img node
var div = this.image.parentNode; var div = this.image.parentNode;
// if the tagname of div is "a" // if the tagname of div is "a"
if(div.tagName.toLowerCase() == "a") if (div.tagName.toLowerCase() == "a")
{ {
// go up one level to find the real div // go up one level to find the real div
div = div.parentNode; div = div.parentNode;
} }
// remove this div // remove this div
div.parentNode.removeChild(div); div.parentNode.removeChild(div);
return true; return true;
}; };
OpenCCM.prototype.imageBrowse = function(window) OpenCCM.prototype.imageBrowse = function(window)
{ {
var baseURL = window.location.href; var baseURL = window.location.href;
var offset = baseURL.lastIndexOf("/"); var offset = baseURL.lastIndexOf("/");
var destURL = baseURL.slice(0, offset+1) + "image_select.jsp"; var destURL = baseURL.slice(0, offset + 1) + "image_select.jsp";
// var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true}); // var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true});
// searchDialog.show(); // searchDialog.show();
var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no"); var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no");
window.openCCM = this; window.openCCM = this;
return false; return false;
}; };
OpenCCM.prototype.imageSet = function(imageData) OpenCCM.prototype.imageSet = function(imageData)
{ {
var dialog = this.dialogs["images"]; var dialog = this.dialogs["images"];
dialog.getElementById(dialog.id["src"]).value = imageData.src; dialog.getElementById(dialog.id["src"]).value = imageData.src;
dialog.getElementById(dialog.id["ipreview"]).src = imageData.src; dialog.getElementById(dialog.id["ipreview"]).src = imageData.src;
dialog.getElementById(dialog.id["width"]).value = imageData.width; dialog.getElementById(dialog.id["width"]).value = imageData.width;
dialog.getElementById(dialog.id["height"]).value = imageData.height; dialog.getElementById(dialog.id["height"]).value = imageData.height;
dialog.getElementById(dialog.id["name"]).value = imageData.name; dialog.getElementById(dialog.id["name"]).value = imageData.name;
dialog.getElementById(dialog.id["aspect"]).value = imageData.width / imageData.height; dialog.getElementById(dialog.id["aspect"]).value = imageData.width / imageData.height;
if(imageData.src != "") if (imageData.src != "")
{ {
// this.resizePreview(dialog); // this.resizePreview(dialog);
dialog.getElementById(dialog.id["preview"]).style.display = "block"; dialog.getElementById(dialog.id["preview"]).style.display = "block";
this.resizeDialog(dialog); this.resizeDialog(dialog);
} else { } else {
dialog.getElementById(dialog.id["preview"]).style.display = "none"; dialog.getElementById(dialog.id["preview"]).style.display = "none";
} }
}; };
OpenCCM.prototype._getCombinedComponentHeight = function() OpenCCM.prototype._getCombinedComponentHeight = function()
{ {
var dialog = this.dialogs["images"]; var dialog = this.dialogs["images"];
return dialog.getElementById(dialog.id["h1"]).offsetHeight + return dialog.getElementById(dialog.id["h1"]).offsetHeight +
dialog.getElementById(dialog.id["common"]).offsetHeight + dialog.getElementById(dialog.id["common"]).offsetHeight +
dialog.getElementById(dialog.id["layout"]).offsetHeight + dialog.getElementById(dialog.id["layout"]).offsetHeight +
dialog.getElementById(dialog.id["dimensions"]).offsetHeight + dialog.getElementById(dialog.id["dimensions"]).offsetHeight +
dialog.getElementById(dialog.id["buttons"]).offsetHeight + dialog.getElementById(dialog.id["buttons"]).offsetHeight +
parseInt(dialog.rootElem.style.paddingBottom,10) + parseInt(dialog.rootElem.style.paddingBottom, 10) +
10; 10;
}; };
OpenCCM.prototype.resizeDialog = function(dialog) OpenCCM.prototype.resizeDialog = function(dialog)
{ {
if(dialog.getElementById(dialog.id["preview"]).style.display == "block") if (dialog.getElementById(dialog.id["preview"]).style.display == "block")
{ {
// Recalculate height of preview // Recalculate height of preview
dialog.getElementById(dialog.id["preview"]).style.height = Math.min(Math.max(0, dialog.height - this._getCombinedComponentHeight() - 20), Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight())) + "px"; dialog.getElementById(dialog.id["preview"]).style.height = Math.min(Math.max(0, dialog.height - this._getCombinedComponentHeight() - 20), Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight())) + "px";
// Resize preview image // Resize preview image
this.resizePreview(dialog); this.resizePreview(dialog);
} }
dialog.width = Math.min(Math.max(10, dialog.width), Math.round((window.innerWidth * 0.8))); dialog.width = Math.min(Math.max(10, dialog.width), Math.round((window.innerWidth * 0.8)));
dialog.height = Math.min(Math.max(10, dialog.height), Math.round((window.innerHeight * 0.8))); dialog.height = Math.min(Math.max(10, dialog.height), Math.round((window.innerHeight * 0.8)));
}; };
OpenCCM.prototype.resizePreview = function(dialog) OpenCCM.prototype.resizePreview = function(dialog)
{ {
var layoutElem = dialog.getElementById(dialog.id["layout"]); var layoutElem = dialog.getElementById(dialog.id["layout"]);
var previewElem = dialog.getElementById(dialog.id["preview"]); var previewElem = dialog.getElementById(dialog.id["preview"]);
var maxWidth = layoutElem.offsetWidth - 5;
var maxHeight = previewElem.offsetHeight && previewElem.offsetHeight - 15 < Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight())
? previewElem.offsetHeight - 15
: Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight());
dialog.getElementById(dialog.id["ipreview"]).style.width = "auto"; var maxWidth = layoutElem.offsetWidth - 5;
dialog.getElementById(dialog.id["ipreview"]).style.height = "auto"; var maxHeight = previewElem.offsetHeight && previewElem.offsetHeight - 15 < Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight())
? previewElem.offsetHeight - 15
: Math.round((window.innerHeight * 0.8) - this._getCombinedComponentHeight());
var width = parseInt(dialog.getElementById(dialog.id["ipreview"]).width,10); dialog.getElementById(dialog.id["ipreview"]).style.width = "auto";
var height = parseInt(dialog.getElementById(dialog.id["ipreview"]).height,10); dialog.getElementById(dialog.id["ipreview"]).style.height = "auto";
var width = parseInt(dialog.getElementById(dialog.id["ipreview"]).width, 10);
var height = parseInt(dialog.getElementById(dialog.id["ipreview"]).height, 10);
// alert("W: " + maxWidth +" "+ width + "H: " + maxHeight +" "+ height); // alert("W: " + maxWidth +" "+ width + "H: " + maxHeight +" "+ height);
var zoom = height > 0 var zoom = height > 0
? Math.min(maxWidth / width, maxHeight / height) ? Math.min(maxWidth / width, maxHeight / height)
: maxWidth / width; : maxWidth / width;
// alert("Zoom: " + zoom); // alert("Zoom: " + zoom);
var w = dialog.getElementById(dialog.id["ipreview"]).style.width = Math.round(width * zoom) + "px"; var w = dialog.getElementById(dialog.id["ipreview"]).style.width = Math.round(width * zoom) + "px";
var h = dialog.getElementById(dialog.id["ipreview"]).style.height = Math.round(height * zoom) + "px"; var h = dialog.getElementById(dialog.id["ipreview"]).style.height = Math.round(height * zoom) + "px";
}; };
OpenCCM.prototype.calcWidth = function() OpenCCM.prototype.calcWidth = function()
{ {
var dialog = this.dialogs["images"]; var dialog = this.dialogs["images"];
dialog.getElementById(dialog.id["width"]).value = dialog.getElementById(dialog.id["width"]).value =
Math.round(dialog.getElementById("height").value * dialog.getElementById("aspect").value); Math.round(dialog.getElementById("height").value * dialog.getElementById("aspect").value);
}; };
OpenCCM.prototype.calcHeight = function() OpenCCM.prototype.calcHeight = function()
{ {
var dialog = this.dialogs["images"]; var dialog = this.dialogs["images"];
dialog.getElementById(dialog.id["height"]).value = dialog.getElementById(dialog.id["height"]).value =
Math.round(dialog.getElementById("width").value / dialog.getElementById("aspect").value); Math.round(dialog.getElementById("width").value / dialog.getElementById("aspect").value);
}; };

View File

@ -9,7 +9,7 @@
name="ScientificCMS" name="ScientificCMS"
prettyName="Scientific CMS" prettyName="Scientific CMS"
version="2.3.0" version="2.3.0"
release="devel-SNAPSHOT-r2620" release="devel-SNAPSHOT-r2664"
webxml="sci-web.xml" webxml="sci-web.xml"
portletxml="sci-portlet.xml" portletxml="sci-portlet.xml"
webapp="libreccm" webapp="libreccm"

View File

@ -73,7 +73,12 @@
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
$("a.imageZoom").fancybox({'type':'image'}); $("a.imageZoom").fancybox({'type':'image'});
$("a.imageGallery").fancybox({'type':'image'}); $("a.imageGallery").fancybox({
'type': 'image',
'helpers': {
buttons: {}
}
});
}); });
</script> </script>
<!-- <!--

View File

@ -29,6 +29,7 @@
<usePageTitle/> <usePageTitle/>
</title> </title>
<useCSSLoader/> <useCSSLoader/>
<useJQuery/>
<useFancybox/> <useFancybox/>
<useMathJax/> <useMathJax/>
</head> </head>

View File

@ -29,6 +29,7 @@
<usePageTitle/> <usePageTitle/>
</title> </title>
<useCSSLoader/> <useCSSLoader/>
<useJQuery/>
<useFancybox/> <useFancybox/>
<useMathJax/> <useMathJax/>
<useJqueryUi/> <useJqueryUi/>

View File

@ -34,7 +34,7 @@
<fileset dir="${ccm.tools.lib.dir}" includes="pluto-util-*.jar"/> <fileset dir="${ccm.tools.lib.dir}" includes="pluto-util-*.jar"/>
<fileset dir="${ccm.tools.lib.dir}" includes="pluto-container-*.jar"/> <fileset dir="${ccm.tools.lib.dir}" includes="pluto-container-*.jar"/>
<fileset dir="${ccm.tools.lib.dir}" includes="pluto-container-api-*.jar"/> <fileset dir="${ccm.tools.lib.dir}" includes="pluto-container-api-*.jar"/>
<fileset dir="${app.server.webapp.dir}/pluto/WEB-INF/lib" includes="**/*.jar"/> <!--<fileset dir="${app.server.webapp.dir}/pluto/WEB-INF/lib" includes="**/*.jar"/>-->
<!-- <!--
<fileset dir="/path/to/commons-logging" includes="**/*.jar"/> <fileset dir="/path/to/commons-logging" includes="**/*.jar"/>
<fileset dir="/path/to/castor" includes="**/*.jar"/> <fileset dir="/path/to/castor" includes="**/*.jar"/>