From: <pb...@fe...> - 2012-12-18 23:13:26
|
Author: pboy Date: 2012-12-18 23:13:16 +0000 (Tue, 18 Dec 2012) New Revision: 2427 Modified: trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js Log: Further improvements Xinha OpenCCM plugin (version 0.5). (on behalf of quasimodo) Modified: trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html =================================================================== --- trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html 2012-12-18 22:51:03 UTC (rev 2426) +++ trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.html 2012-12-18 23:13:16 UTC (rev 2427) @@ -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,18 +133,16 @@ <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)"/> + <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> - <label class="key" for="[gallery]"> - <l10n>Enable Gallery:</l10n> - </label> - <div class="value"> - <input type="checkbox" name="[gallery]" id="[gallery]" title="_(Enable gallery)"/> - </div> </fieldset> <fieldset id="[dimensions]"> Modified: trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js =================================================================== --- trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js 2012-12-18 22:51:03 UTC (rev 2426) +++ trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/images/images.js 2012-12-18 23:13:16 UTC (rev 2427) @@ -17,8 +17,11 @@ width : "", height : "", caption : "", - zoom : "", - gallery : "", + + alignment : "", + caption : "", + fancybox : "", + aspect : "" }; @@ -33,7 +36,7 @@ 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 @@ 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 @@ href : "", rel : "", class : "" - }; var divAttr = @@ -181,20 +198,18 @@ } // 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 @@ // 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 @@ { img.setAttribute(attr, imgAttr[attr]); } - if(values.zoom || values.gallery) + if(values.fancybox.value != "none") { link.appendChild(img); } @@ -358,11 +373,15 @@ { 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 @@ 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"; }; Modified: trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js =================================================================== --- trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js 2012-12-18 22:51:03 UTC (rev 2426) +++ trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/de.js 2012-12-18 23:13:16 UTC (rev 2427) @@ -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" } Modified: trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js =================================================================== --- trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js 2012-12-18 22:51:03 UTC (rev 2426) +++ trunk/ccm-cms/web/assets/xinha/plugins/OpenCCM/lang/en.js 2012-12-18 23:13:16 UTC (rev 2427) @@ -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" } |