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

@ -81,7 +81,8 @@ public final class AssignedTaskSection extends Section {
@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 {
@ -89,7 +90,9 @@ public final class AssignedTaskSection extends Section {
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 { private class LockLink extends ActionLink {
@ -102,7 +105,8 @@ public final class AssignedTaskSection extends Section {
@Override @Override
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state) && !m_facade.tasksLocked(state); return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state)
&& !m_facade.tasksLocked(state);
} }
private class Listener implements ActionListener { private class Listener implements ActionListener {
@ -110,7 +114,9 @@ public final class AssignedTaskSection extends Section {
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
m_facade.lockTasks(e.getPageState()); m_facade.lockTasks(e.getPageState());
} }
} }
} }
private class UnlockLink extends ActionLink { private class UnlockLink extends ActionLink {
@ -123,7 +129,8 @@ public final class AssignedTaskSection extends Section {
@Override @Override
public final boolean isVisible(final PageState state) { public final boolean isVisible(final PageState state) {
return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state) && m_facade.tasksLocked(state); return m_facade.workflowState(state, Workflow.STARTED) && m_facade.tasksExist(state)
&& m_facade.tasksLocked(state);
} }
private class Listener implements ActionListener { private class Listener implements ActionListener {
@ -131,7 +138,9 @@ public final class AssignedTaskSection extends Section {
public final void actionPerformed(final ActionEvent e) { public final void actionPerformed(final ActionEvent e) {
m_facade.unlockTasks(e.getPageState()); m_facade.unlockTasks(e.getPageState());
} }
} }
} }
private class WorkflowFacade { private class WorkflowFacade {
@ -156,6 +165,7 @@ public final class AssignedTaskSection extends Section {
final ArrayList getTasks(final PageState state) { final ArrayList getTasks(final PageState state) {
return (ArrayList) get(state); return (ArrayList) get(state);
} }
} }
final void restartWorkflow(final PageState state) { final void restartWorkflow(final PageState state) {
@ -221,6 +231,7 @@ public final class AssignedTaskSection extends Section {
return task.getTaskType().getID().equals(CMSTaskType.AUTHOR) return task.getTaskType().getID().equals(CMSTaskType.AUTHOR)
|| task.getTaskType().getID().equals(CMSTaskType.EDIT); || task.getTaskType().getID().equals(CMSTaskType.EDIT);
} }
} }
protected final static GlobalizedMessage gz(final String key) { protected final static GlobalizedMessage gz(final String key) {
@ -230,4 +241,5 @@ public final class AssignedTaskSection extends Section {
protected final static String lz(final String key) { protected final static String lz(final String key) {
return (String) gz(key).localize(); return (String) gz(key).localize();
} }
} }

View File

@ -10,25 +10,23 @@ OpenCCM.prototype.showImageDialog = function(image)
var data = var data =
{ {
src : "", src: "",
name : "", name: "",
alt : "", alt: "",
title : "", title: "",
width : "", width: "",
height : "", height: "",
caption: "",
alignment: "",
caption : "", caption : "",
fancybox: "",
alignment : "", aspect: ""
caption : "",
fancybox : "",
aspect : ""
}; };
if (typeof image == "undefined" ) if (typeof image == "undefined")
{ {
image = editor.getParentElement(); image = editor.getParentElement();
if ( image && image.tagName.toLowerCase() != "img" ) if (image && image.tagName.toLowerCase() != "img")
{ {
image = null; image = null;
} }
@ -72,7 +70,7 @@ OpenCCM.prototype.showImageDialog = function(image)
} }
else else
{ {
data.alignment="none"; data.alignment = "none";
} }
data.fancybox = image.parentNode.getAttribute("class"); data.fancybox = image.parentNode.getAttribute("class");
@ -96,7 +94,7 @@ OpenCCM.prototype.showImageDialog = function(image)
this.dialogs["images"].show(data); this.dialogs["images"].show(data);
// If image set, show preview // If image set, show preview
if(data.src != "") if (data.src != "")
{ {
this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src; this.dialogs["images"].getElementById(this.dialogs["images"].id["ipreview"]).src = data.src;
this.resizePreview(this.dialogs["images"]); this.resizePreview(this.dialogs["images"]);
@ -116,22 +114,34 @@ 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}) var dialog = this.dialogs["images"] = new Xinha.Dialog(editor, OpenCCM.imagesHtml, 'Xinha', {width: 410})
// Connect the OK and Cancel buttons // Connect the OK and Cancel buttons
dialog.getElementById("ok").onclick = function() {self.imageApply();} dialog.getElementById("ok").onclick = function() {
dialog.getElementById("remove").onclick = function() { self.imageRemove(); }; self.imageApply();
dialog.getElementById("cancel").onclick = function() { self.dialogs["images"].hide(); }; }
dialog.getElementById("remove").onclick = function() {
self.imageRemove();
};
dialog.getElementById("cancel").onclick = function() {
self.dialogs["images"].hide();
};
// Connect the Select button // Connect the Select button
dialog.getElementById("browse").onclick = function() { self.imageBrowse(window); }; dialog.getElementById("browse").onclick = function() {
self.imageBrowse(window);
};
// Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio // Connect onkeyup event handler with dimension filed to recalculate the size according to aspect ratio
dialog.getElementById("width").onkeyup = function() { self.calcHeight(); }; dialog.getElementById("width").onkeyup = function() {
dialog.getElementById("height").onkeyup = function() { self.calcWidth(); }; self.calcHeight();
};
dialog.getElementById("height").onkeyup = function() {
self.calcWidth();
};
// OnResize // OnResize
this.dialogs["images"].onresize = function () this.dialogs["images"].onresize = function()
{ {
self.resizeDialog(this); self.resizeDialog(this);
}; };
@ -150,31 +160,31 @@ OpenCCM.prototype.imageApply = function()
var imgAttr = var imgAttr =
{ {
src : "", src: "",
alt : "", alt: "",
title : "", title: "",
name : "", name: "",
width : "", width: "",
height : "" height: ""
}; };
var spanAttr = var spanAttr =
{ {
class : "caption", class: "caption",
style : "", style: "",
} }
var linkAttr = var linkAttr =
{ {
href : "", href: "",
title : "", title: "",
rel : "", rel: "",
class : "" class: ""
}; };
var divAttr = var divAttr =
{ {
class : "image" class: "image"
}; };
// If not all mandatory informations are set // If not all mandatory informations are set
@ -193,13 +203,13 @@ OpenCCM.prototype.imageApply = function()
imgAttr.height = values.height; imgAttr.height = values.height;
// Read form values for caption // Read form values for caption
if(values.caption) if (values.caption)
{ {
spanAttr.style = "width:" + imgAttr.width + "px"; spanAttr.style = "width:" + imgAttr.width + "px";
} }
// Read form values for link // Read form values for link
if(values.fancybox.value == "imageZoom") if (values.fancybox.value == "imageZoom")
{ {
linkAttr.href = values.src; linkAttr.href = values.src;
linkAttr.title = values.title; linkAttr.title = values.title;
@ -207,7 +217,7 @@ OpenCCM.prototype.imageApply = function()
linkAttr.class = "imageZoom"; linkAttr.class = "imageZoom";
} }
else if(values.fancybox.value == "imageGallery") else if (values.fancybox.value == "imageGallery")
{ {
linkAttr.href = values.src; linkAttr.href = values.src;
linkAttr.title = values.title; linkAttr.title = values.title;
@ -216,7 +226,7 @@ OpenCCM.prototype.imageApply = function()
} }
// Read form values for div // Read form values for div
if(values.alignment.value != "") if (values.alignment.value != "")
{ {
divAttr.class += " " + values.alignment.value; divAttr.class += " " + values.alignment.value;
} }
@ -224,13 +234,13 @@ OpenCCM.prototype.imageApply = function()
var div; var div;
// Modify Image // Modify Image
if(modifyImage) if (modifyImage)
{ {
// Get the parent for img node // Get the parent for img node
div = image.parentNode; div = 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;
@ -251,17 +261,17 @@ OpenCCM.prototype.imageApply = function()
} }
// set attributes for div // set attributes for div
for(var attr in divAttr) for (var attr in divAttr)
{ {
div.setAttribute(attr, divAttr[attr]); div.setAttribute(attr, divAttr[attr]);
} }
// the folling has to be done for both cases // the folling has to be done for both cases
// insert link, if fancybox features are activated // insert link, if fancybox features are activated
if(values.fancybox.value != "none") if (values.fancybox.value != "none")
{ {
link = document.createElement("a"); link = document.createElement("a");
for(var attr in linkAttr) for (var attr in linkAttr)
{ {
link.setAttribute(attr, linkAttr[attr]); link.setAttribute(attr, linkAttr[attr]);
} }
@ -270,11 +280,11 @@ OpenCCM.prototype.imageApply = function()
// insert the image, obviously // insert the image, obviously
var img = document.createElement("img"); var img = document.createElement("img");
for(var attr in imgAttr) for (var attr in imgAttr)
{ {
img.setAttribute(attr, imgAttr[attr]); img.setAttribute(attr, imgAttr[attr]);
} }
if(values.fancybox.value != "none") if (values.fancybox.value != "none")
{ {
link.appendChild(img); link.appendChild(img);
} }
@ -284,10 +294,10 @@ OpenCCM.prototype.imageApply = function()
} }
// insert caption if selected // insert caption if selected
if(values.caption) if (values.caption)
{ {
var span = document.createElement("span"); var span = document.createElement("span");
for(var attr in spanAttr) for (var attr in spanAttr)
{ {
span.setAttribute(attr, spanAttr[attr]); span.setAttribute(attr, spanAttr[attr]);
} }
@ -297,7 +307,7 @@ OpenCCM.prototype.imageApply = function()
} }
// insert new div only if we not modifying an image // insert new div only if we not modifying an image
if(!modifyImage) { if (!modifyImage) {
editor.insertNodeAtSelection(div); editor.insertNodeAtSelection(div);
} }
@ -315,7 +325,7 @@ OpenCCM.prototype.imageRemove = function()
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;
@ -331,7 +341,7 @@ 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();
@ -350,7 +360,7 @@ OpenCCM.prototype.imageSet = function(imageData)
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";
@ -368,13 +378,13 @@ OpenCCM.prototype._getCombinedComponentHeight = function()
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")
{ {
@ -400,8 +410,8 @@ OpenCCM.prototype.resizePreview = function(dialog)
dialog.getElementById(dialog.id["ipreview"]).style.width = "auto"; dialog.getElementById(dialog.id["ipreview"]).style.width = "auto";
dialog.getElementById(dialog.id["ipreview"]).style.height = "auto"; dialog.getElementById(dialog.id["ipreview"]).style.height = "auto";
var width = parseInt(dialog.getElementById(dialog.id["ipreview"]).width,10); var width = parseInt(dialog.getElementById(dialog.id["ipreview"]).width, 10);
var height = parseInt(dialog.getElementById(dialog.id["ipreview"]).height,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);

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"/>