/** * stara se o obsah z WYSIWYG editoru * - nastavi obrazky jako klikatelne * - zobrazi popisky obrazku pres obrazek * */ var WYSIWYGContent = function(aContentID) { this.showAlt = true; this.contID = aContentID; this.elem = fLib.getElementById(this.contID); this.linkBase = "media.php?a=image&s=big"; this.viewer = new QuickShow(); }; WYSIWYGContent.prototype.init = function() { if(this.elem != null) { //najit obrazky var elems = this.elem.getElementsByTagName("img"); for(var i in elems) { if(elems[i].attributes != undefined && elems[i].hasAttribute("data-description") && this.showAlt) { this.putText(elems[i], elems[i].getAttribute("data-description")); } if(elems[i].src != undefined && elems[i].src.search(/media.php\?(.*?)id=[0-9]+/i) != -1) { if(elems[i].parentNode.tagName != "A") { elems[i].style.cursor = "pointer"; var id = elems[i].src.match(/id=([0-9]+)/i)[1]; this.showImage(elems[i], id); } } } } }; WYSIWYGContent.prototype.showImage = function(elem, id) { var link = this.linkBase + "&id=" + id; this.viewer.addImage(link); var self = this; fLib.addEvent("click", function() { self.viewer.display(link); }, elem); }; /** * vlozit pres obrazek hladinu s textem * * @param imgElem * @param text * @return */ WYSIWYGContent.prototype.putText = function(imgElem, text) { if(text != "") { var parent = imgElem.parentNode; var newNode = document.createElement("div"); var infoNode = document.createElement("div"); infoNode.innerHTML = text; parent.insertBefore(newNode, imgElem); newNode.style.position = "relative"; newNode.style.cssFloat = imgElem.style.cssFloat; newNode.style.styleFloat = imgElem.style.styleFloat; newNode.style.marginTop = fLib.getStyle(imgElem, "margin-top"); newNode.style.marginRight = fLib.getStyle(imgElem, "margin-right"); newNode.style.marginBottom = fLib.getStyle(imgElem, "margin-bottom"); newNode.style.marginLeft = fLib.getStyle(imgElem, "margin-left"); imgElem.style.margin = "0px"; newNode.style.clear = "both"; newNode.style.display = "inline-block"; infoNode.style.position = "absolute"; infoNode.style.bottom = "10px"; infoNode.style.padding = "5px"; infoNode.style.backgroundColor = "#303030"; infoNode.style.color = "#FFFFFF"; newNode.appendChild(infoNode); newNode.appendChild(imgElem); } };