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 {
private static final Logger s_log = Logger.getLogger(AssignedTaskSection.class);
private final WorkflowRequestLocal m_workflow;
private final WorkflowFacade m_facade;
private static final Logger s_log = Logger.getLogger(AssignedTaskSection.class);
private final WorkflowRequestLocal m_workflow;
private final WorkflowFacade m_facade;
public AssignedTaskSection(final WorkflowRequestLocal workflow,
final Component subject) {
super(gz("cms.ui.workflow.task.assigned"));
public AssignedTaskSection(final WorkflowRequestLocal workflow,
final Component subject) {
super(gz("cms.ui.workflow.task.assigned"));
m_workflow = workflow;
m_facade = new WorkflowFacade(m_workflow);
m_workflow = workflow;
m_facade = new WorkflowFacade(m_workflow);
final ActionGroup group = new ActionGroup();
setBody(group);
final ActionGroup group = new ActionGroup();
setBody(group);
group.setSubject(subject);
group.addAction(new RestartLink());
group.addAction(new LockLink());
group.addAction(new UnlockLink());
}
group.setSubject(subject);
group.addAction(new RestartLink());
group.addAction(new LockLink());
group.addAction(new UnlockLink());
}
@Override
public final boolean isVisible(final PageState state) {
return m_workflow.getWorkflow(state) != null;
}
@Override
public final boolean isVisible(final PageState state) {
return m_workflow.getWorkflow(state) != null;
}
private class RestartLink extends ActionLink {
private class RestartLink extends ActionLink {
RestartLink() {
super(new Label(gz("cms.ui.workflow.restart_stopped_workflow")));
RestartLink() {
super(new Label(gz("cms.ui.workflow.restart_stopped_workflow")));
addActionListener(new Listener());
}
addActionListener(new Listener());
}
@Override
public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.INIT) || m_facade.workflowState(state, Workflow.STOPPED);
}
@Override
public final boolean isVisible(final PageState state) {
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) {
m_facade.restartWorkflow(e.getPageState());
}
}
}
public final void actionPerformed(final ActionEvent e) {
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
public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state) && !m_facade.tasksLocked(state);
}
LockLink() {
super(new Label(gz("cms.ui.workflow.task.assigned.lock_all")));
private class Listener implements ActionListener {
addActionListener(new Listener());
}
public final void actionPerformed(final ActionEvent e) {
m_facade.lockTasks(e.getPageState());
}
}
}
@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 UnlockLink extends ActionLink {
private class Listener implements ActionListener {
UnlockLink() {
super(new Label(gz("cms.ui.workflow.task.assigned.unlock_all")));
public final void actionPerformed(final ActionEvent e) {
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) {
m_facade.unlockTasks(e.getPageState());
}
}
}
UnlockLink() {
super(new Label(gz("cms.ui.workflow.task.assigned.unlock_all")));
private class WorkflowFacade {
addActionListener(new UnlockLink.Listener());
}
private final WorkflowRequestLocal m_flow;
private final TaskListRequestLocal m_tasks;
@Override
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) {
m_flow = flow;
m_tasks = new TaskListRequestLocal();
}
private class Listener implements ActionListener {
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) {
final Workflow workflow = m_flow.getWorkflow(state);
workflow.start(Web.getWebContext().getUser());
workflow.save();
private class WorkflowFacade {
// Lock tasks if not locked
if (!tasksLocked(state)) {
lockTasks(state);
}
}
private final WorkflowRequestLocal m_flow;
private final TaskListRequestLocal m_tasks;
final void lockTasks(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator();
WorkflowFacade(final WorkflowRequestLocal flow) {
m_flow = flow;
m_tasks = new TaskListRequestLocal();
}
while (iter.hasNext()) {
final CMSTask task = (CMSTask) iter.next();
private class TaskListRequestLocal extends RequestLocal {
if (relevant(task) && !task.isLocked()) {
task.lock(Web.getWebContext().getUser());
task.save();
}
}
}
@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 void unlockTasks(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator();
final ArrayList getTasks(final PageState state) {
return (ArrayList) get(state);
}
while (iter.hasNext()) {
final CMSTask task = (CMSTask) iter.next();
}
if (relevant(task) && task.isLocked()) {
task.unlock(Web.getWebContext().getUser());
task.save();
}
}
}
final void restartWorkflow(final PageState state) {
final Workflow workflow = m_flow.getWorkflow(state);
workflow.start(Web.getWebContext().getUser());
workflow.save();
final boolean tasksLocked(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator();
// Lock tasks if not locked
if (!tasksLocked(state)) {
lockTasks(state);
}
}
while (iter.hasNext()) {
final CMSTask task = (CMSTask) iter.next();
final void lockTasks(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator();
if (relevant(task) && !task.isLocked()) {
return false;
}
}
while (iter.hasNext()) {
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) {
return m_flow.getWorkflow(state).getProcessState() == processState;
}
final void unlockTasks(final PageState state) {
final Iterator iter = m_tasks.getTasks(state).iterator();
final boolean tasksExist(final PageState state) {
return !m_tasks.getTasks(state).isEmpty();
}
while (iter.hasNext()) {
final CMSTask task = (CMSTask) iter.next();
private boolean relevant(final CMSTask task) {
return task.getTaskType().getID().equals(CMSTaskType.AUTHOR)
|| task.getTaskType().getID().equals(CMSTaskType.EDIT);
}
}
if (relevant(task) && task.isLocked()) {
task.unlock(Web.getWebContext().getUser());
task.save();
}
}
}
protected final static GlobalizedMessage gz(final String key) {
return GlobalizationUtil.globalize(key);
}
final boolean tasksLocked(final PageState state) {
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)
{
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" )
if (!this.dialogs["images"])
{
image = null;
this.prepareImageDialog();
}
}
this.image = image;
var editor = this.editor;
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");
var data =
{
src: "",
name: "",
alt: "",
title: "",
width: "",
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
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 : "";
image = editor.getParentElement();
if (image && image.tagName.toLowerCase() != "img")
{
image = null;
}
}
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 = "";
}
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
{
// 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 : "";
data.alignment = "none";
// data.caption = "";
data.fancybox = "none";
// data.galleryName = "";
}
// Calculate aspect ratio
data.aspect = data.width / data.height;
}
else
{
data.alignment = "none";
// data.caption = "";
data.fancybox = "none";
// 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);
// 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
if(data.src != "")
{
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src;
this.resizePreview(this.dialogs["images"]);
this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "block";
}
else
{
// 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";
}
// If image set, show preview
if (data.src != "")
{
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src;
this.resizePreview(this.dialogs["images"]);
this.dialogs["images"].getElementById(this.dialogs["images"].id["preview"]).style.display = "block";
}
else
{
// 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()
{
var self = this;
var editor = this.editor;
var self = this;
var editor = this.editor;
var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha',{width:410})
var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha', {width: 410})
// Connect the OK and Cancel buttons
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 OK and Cancel buttons
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
dialog.getElementById("browse").onclick = function() { self.imageBrowse(window); };
// Connect the Select button
dialog.getElementById("browse").onclick = function() {
self.imageBrowse(window);
};
// Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio
dialog.getElementById("width").onkeyup = function() { self.calcHeight(); };
dialog.getElementById("height").onkeyup = function() { self.calcWidth(); };
// Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio
dialog.getElementById("width").onkeyup = function() {
self.calcHeight();
};
dialog.getElementById("height").onkeyup = function() {
self.calcWidth();
};
// OnResize
this.dialogs["images"].onresize = function ()
{
self.resizeDialog(this);
};
// OnResize
this.dialogs["images"].onresize = function()
{
self.resizeDialog(this);
};
this.imageDialogReady = true;
this.imageDialogReady = true;
};
// Write HTML code
OpenCCM.prototype.imageApply = function()
{
var values = this.dialogs["images"].hide();
var image = this.image;
var editor = this.editor;
var modifyImage = (image != null && image.tagName.toLowerCase() == "img");
var values = this.dialogs["images"].hide();
var image = this.image;
var editor = this.editor;
var modifyImage = (image != null && image.tagName.toLowerCase() == "img");
var imgAttr =
{
src : "",
alt : "",
title : "",
name : "",
width : "",
height : ""
};
var imgAttr =
{
src: "",
alt: "",
title: "",
name: "",
width: "",
height: ""
};
var spanAttr =
{
class : "caption",
style : "",
}
var spanAttr =
{
class: "caption",
style: "",
}
var linkAttr =
{
href : "",
title : "",
rel : "",
class : ""
};
var linkAttr =
{
href: "",
title: "",
rel: "",
class: ""
};
var divAttr =
{
class : "image"
};
var divAttr =
{
class: "image"
};
// If not all mandatory informations are set
if (!values.src)
{
// don't do anything at all
return false;
}
// Read form values for image
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)
{
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")
// If not all mandatory informations are set
if (!values.src)
{
// go up one level to find the real div
div = div.parentNode;
// don't do anything at all
return false;
}
// remove all childs from div.image
while (div.childNodes.length > 0)
// Read form values for image
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
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)
// Read form values for link
if (values.fancybox.value == "imageZoom")
{
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
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)
else if (values.fancybox.value == "imageGallery")
{
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);
}
// Read form values for div
if (values.alignment.value != "")
{
divAttr.class += " " + values.alignment.value;
}
// insert new div only if we not modifying an image
if(!modifyImage) {
editor.insertNodeAtSelection(div);
}
var div;
// set cursor after 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()
{
// Close the dialog
this.dialogs["images"].hide();
// Close the dialog
this.dialogs["images"].hide();
// Get the parent div for img node
var div = this.image.parentNode;
// Get the parent div for img node
var div = this.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;
}
// 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 this div
div.parentNode.removeChild(div);
// remove this div
div.parentNode.removeChild(div);
return true;
return true;
};
OpenCCM.prototype.imageBrowse = function(window)
{
var baseURL = window.location.href;
var offset = baseURL.lastIndexOf("/");
var destURL = baseURL.slice(0, offset+1) + "image_select.jsp";
var baseURL = window.location.href;
var offset = baseURL.lastIndexOf("/");
var destURL = baseURL.slice(0, offset + 1) + "image_select.jsp";
// var searchDialog = new Xinha.Dialog(this.editor, destURL, '');//,{width:800, height:600}, {'closable':true});
// searchDialog.show();
var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no");
window.openCCM = this;
return false;
var selectWindow = window.open(destURL, "_blank", "scrollbars=yes,directories=no,toolbar=no,width=800,height=600,status=no,menubar=no");
window.openCCM = this;
return false;
};
OpenCCM.prototype.imageSet = function(imageData)
{
var dialog = this.dialogs["images"];
dialog.getElementById(dialog.id["src"]).value = imageData.src;
dialog.getElementById(dialog.id["ipreview"]).src = imageData.src;
dialog.getElementById(dialog.id["width"]).value = imageData.width;
dialog.getElementById(dialog.id["height"]).value = imageData.height;
dialog.getElementById(dialog.id["name"]).value = imageData.name;
dialog.getElementById(dialog.id["aspect"]).value = imageData.width / imageData.height;
var dialog = this.dialogs["images"];
dialog.getElementById(dialog.id["src"]).value = imageData.src;
dialog.getElementById(dialog.id["ipreview"]).src = imageData.src;
dialog.getElementById(dialog.id["width"]).value = imageData.width;
dialog.getElementById(dialog.id["height"]).value = imageData.height;
dialog.getElementById(dialog.id["name"]).value = imageData.name;
dialog.getElementById(dialog.id["aspect"]).value = imageData.width / imageData.height;
if(imageData.src != "")
{
if (imageData.src != "")
{
// this.resizePreview(dialog);
dialog.getElementById(dialog.id["preview"]).style.display = "block";
this.resizeDialog(dialog);
} else {
dialog.getElementById(dialog.id["preview"]).style.display = "none";
}
dialog.getElementById(dialog.id["preview"]).style.display = "block";
this.resizeDialog(dialog);
} else {
dialog.getElementById(dialog.id["preview"]).style.display = "none";
}
};
OpenCCM.prototype._getCombinedComponentHeight = function()
{
var dialog = this.dialogs["images"];
return dialog.getElementById(dialog.id["h1"]).offsetHeight +
dialog.getElementById(dialog.id["common"]).offsetHeight +
dialog.getElementById(dialog.id["layout"]).offsetHeight +
dialog.getElementById(dialog.id["dimensions"]).offsetHeight +
dialog.getElementById(dialog.id["buttons"]).offsetHeight +
parseInt(dialog.rootElem.style.paddingBottom,10) +
10;
var dialog = this.dialogs["images"];
return dialog.getElementById(dialog.id["h1"]).offsetHeight +
dialog.getElementById(dialog.id["common"]).offsetHeight +
dialog.getElementById(dialog.id["layout"]).offsetHeight +
dialog.getElementById(dialog.id["dimensions"]).offsetHeight +
dialog.getElementById(dialog.id["buttons"]).offsetHeight +
parseInt(dialog.rootElem.style.paddingBottom, 10) +
10;
};
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
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
this.resizePreview(dialog);
}
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)));
// 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";
// Resize preview image
this.resizePreview(dialog);
}
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)));
};
OpenCCM.prototype.resizePreview = function(dialog)
{
var layoutElem = dialog.getElementById(dialog.id["layout"]);
var previewElem = dialog.getElementById(dialog.id["preview"]);
var layoutElem = dialog.getElementById(dialog.id["layout"]);
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());
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";
dialog.getElementById(dialog.id["ipreview"]).style.height = "auto";
dialog.getElementById(dialog.id["ipreview"]).style.width = "auto";
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);
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);
var zoom = height > 0
? Math.min(maxWidth / width, maxHeight / height)
: maxWidth / width;
var zoom = height > 0
? Math.min(maxWidth / width, maxHeight / height)
: maxWidth / width;
// alert("Zoom: " + zoom);
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 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";
};
OpenCCM.prototype.calcWidth = function()
{
var dialog = this.dialogs["images"];
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()
{
var dialog = this.dialogs["images"];
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"
prettyName="Scientific CMS"
version="2.3.0"
release="devel-SNAPSHOT-r2620"
release="devel-SNAPSHOT-r2664"
webxml="sci-web.xml"
portletxml="sci-portlet.xml"
webapp="libreccm"

View File

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

View File

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

View File

@ -29,6 +29,7 @@
<usePageTitle/>
</title>
<useCSSLoader/>
<useJQuery/>
<useFancybox/>
<useMathJax/>
<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-container-*.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/castor" includes="**/*.jar"/>