Version 0.5 vom Xinha-Plugin

* Fehler #1340 korrigiert

git-svn-id: https://svn.libreccm.org/ccm/trunk@1899 8810af33-2d31-482b-a856-94f89814c4df
master
quasi 2012-10-29 12:17:27 +00:00
parent 54f8d95812
commit 663f9fb064
4 changed files with 94 additions and 42 deletions

View File

@ -121,7 +121,7 @@
</label>
<div class="value">
<select size="1" name="[alignment]" id="[alignment]" title="_(Positioning of this image)">
<option value="" ><l10n>Not set</l10n></option>
<option value="none" ><l10n>Not set</l10n></option>
<option value="left" ><l10n>Left</l10n></option>
<option value="center"><l10n>Center</l10n></option>
<option value="right" ><l10n>Right</l10n></option>
@ -133,17 +133,15 @@
<div class="value">
<input type="checkbox" name="[caption]" id="[caption]" title="_(Show caption)" checked="checked"/>
</div>
<label class="key" for="[zoom]">
<l10n>Enable Zoom:</l10n>
<label class="key" for="[fancybox]">
<l10n>Fancybox:</l10n>
</label>
<div class="value">
<input type="checkbox" name="[zoom]" id="[zoom]" title="_(Enable zoom)"/>
</div>
<label class="key" for="[gallery]">
<l10n>Enable Gallery:</l10n>
</label>
<div class="value">
<input type="checkbox" name="[gallery]" id="[gallery]" title="_(Enable gallery)"/>
<select size="1" name="[fancybox]" id="[fancybox]" title="_()">
<option value="none" ><l10n>None</l10n></option>
<option value="imageZoom" ><l10n>Zoom</l10n></option>
<option value="imageGallery"><l10n>Gallery</l10n></option>
</select>
</div>
</fieldset>

View File

@ -17,8 +17,11 @@ OpenCCM.prototype.showImageDialog = function(image)
width : "",
height : "",
caption : "",
zoom : "",
gallery : "",
alignment : "",
caption : "",
fancybox : "",
aspect : ""
};
@ -33,7 +36,7 @@ OpenCCM.prototype.showImageDialog = function(image)
this.image = image;
if(image && image.tagName.toLowerCase() == "img")
if (image && image.tagName.toLowerCase() == "img")
{
data.src = this.editor.fixRelativeLinks(image.getAttribute("src"));
data.alt = image.getAttribute("alt");
@ -42,35 +45,50 @@ OpenCCM.prototype.showImageDialog = function(image)
data.width = image.getAttribute("width");
data.height = image.getAttribute("height");
if(image.parentNode.tagName.toLowerCase() == "div")
if (image.parentNode.tagName.toLowerCase() == "div")
{
// Parent node is not a link, so there is not zoom or gallery function
data.alignment = image.parentNode.getAttribute("class").substring(image.parentNode.getAttribute("class").indexOf(" "));
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.zoom = "";
data.gallery = "";
data.fancybox = "none";
// data.galleryName = "";
}
else
{
// Parent node is a link
data.alignment = image.parentNode.parentNode.getAttribute("class").substring(image.parentNode.getAttribute("class").indexOf(" "));
data.zoom = (image.parentNode.getAttribute("class") == "imageZoom") ? "on" : "";
data.gallery = (image.parentNode.getAttribute("class") == "imageGallery") ? "on" : "";
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 = "";
data.alignment = "none";
// data.caption = "";
data.zoom = "";
data.gallery = "";
data.fancybox = "none";
// data.galleryName = "";
}
@ -151,7 +169,6 @@ OpenCCM.prototype.imageApply = function()
href : "",
rel : "",
class : ""
};
var divAttr =
@ -181,20 +198,18 @@ OpenCCM.prototype.imageApply = function()
}
// Read form values for link
if(values.zoom || values.gallery)
if(values.fancybox.value == "imageZoom")
{
linkAttr.href = values.src;
if(values.zoom)
{
linkAttr.rel = "";
linkAttr.class = "imageZoom";
}
linkAttr.rel = "";
linkAttr.class = "imageZoom";
}
else if(values.gallery)
{
linkAttr.rel = "imageGallery";
linkAttr.class = "imageGallery";
}
else if(values.fancybox.value == "imageGallery")
{
linkAttr.href = values.src;
linkAttr.rel = "imageGallery";
linkAttr.class = "imageGallery";
}
// Read form values for div
@ -240,7 +255,7 @@ OpenCCM.prototype.imageApply = function()
// the folling has to be done for both cases
// insert link, if fancybox features are activated
if(values.zoom || values.gallery)
if(values.fancybox.value != "none")
{
link = document.createElement("a");
for(var attr in linkAttr)
@ -256,7 +271,7 @@ OpenCCM.prototype.imageApply = function()
{
img.setAttribute(attr, imgAttr[attr]);
}
if(values.zoom || values.gallery)
if(values.fancybox.value != "none")
{
link.appendChild(img);
}
@ -358,11 +373,15 @@ OpenCCM.prototype.resizeDialog = function(dialog)
{
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)));
};
OpenCCM.prototype.resizePreview = function(dialog)
@ -374,16 +393,21 @@ OpenCCM.prototype.resizePreview = function(dialog)
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";
var width = parseInt(dialog.getElementById(dialog.id["ipreview"]).width,10);
var height = parseInt(dialog.getElementById(dialog.id["ipreview"]).height,10);
var zoom = Math.min(maxWidth / width,
maxHeight / height);
// alert("W: " + maxWidth +" "+ width + "H: " + maxHeight +" "+ height);
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";
};

View File

@ -3,4 +3,19 @@
{
"OpenCCMInsertLink" : "Link einfügen / bearbeiten",
"OpenCCMInsertImage" : "Bild einfügen / bearbeiten",
"Name:" : "Name:",
"Alternate:" : "Alt-Text",
"Title:" : "Titel:",
"Layout" : "Darstellung",
"Alignment:" : "Ausrichtung:",
"Center" : "zentriert",
"Show Caption:" : "Zeige Bildunterschrift:",
"Fancybox" : "Fancybox:",
"Disabled" : "Deaktiviert",
"Zoom" : "Zoom",
"Gallery" : "Gallerie",
"Dimension" : "Dimensionen",
"Width:" : "Breite:",
"Height:" : "Höhe:",
"Preview" : "Vorschau"
}

View File

@ -3,4 +3,19 @@
{
"OpenCCMInsertLink" : "Create / modify link",
"OpenCCMInsertImage" : "Insert / modify image",
"Name:" : "Name:",
"Alternate:" : "Alternate",
"Title:" : "Title:",
"Layout" : "Layout",
"Alignment:" : "Alignment:",
"Center" : "zentriert",
"Show Caption:" : "Show Caption:",
"Fancybox" : "Fancybox:",
"Disabled" : "Disabled",
"Zoom" : "Zoom",
"Gallery" : "Gallery",
"Dimension" : "Dimension",
"Width:" : "Width:",
"Height:" : "Height:",
"Preview" : "Preview"
}