/* cms Objekt */ function Cms (site, path, session) { var __construct = function (site, path, session) { if (window.cms) { new Dot (site).updateAll (); onload (); new CmsAjax (top.cms.path + "/html/html_action.php", "action=frame&site="+site+"&target="+encodeURIComponent(window.cms.activeSection.id)).run (); } else { // cms Klasse auf top top.cms = top.cms ? top.cms : function () {}; top.cms.path = path; window.cms = window.cms ? window.cms : function () {}; window.cms.session = session; window.cms.reload = reload; // d (); // Debug Ausgabe initialesieren // Statuszeile initialesieren window.defaultStatus = "spitfire - Content Management System"; // Dots initialesieren new Dot (site).init (); // Kontextmenu initialesieren new Kontextmenu ().init (); // EditWindow initialesieren new Action ().init (); window.addEvent ("onload", onload); } } var onload = function () { // letzte Scrollposition wieder herstellen if (top.cms.scrollNode) { var node = top.cms.scrollNode.document ? top.cms.scrollNode.document.body : top.cms.scrollNode; if (node) { node.scrollTop = top.cms.scrollTop; node.scrollLeft = top.cms.scrollLeft; top.cms.scrollNode = null; } } new Action ().request ("", "status", site); window.cms.loaded = true; } // Seite neu laden und alte Scrollposition (für wieder herstellung) speichern var reload = function () { var section = window.cms.activeSection; if (window.cms.activeDotId) { var node = document.getElementById (window.cms.activeDotId); if (node.location) { node.location.href = node.href; return; } while (node && (node = node.parentNode)) { if (node.location) { section = node; break; } } } if (section && !section.body) { top.cms.scrollNode = section; top.cms.scrollTop = section.scrollTop; top.cms.scrollLeft = section.scrollLeft; section.location.reload (); } else { top.cms.scrollNode = window; top.cms.scrollTop = document.body.scrollTop; top.cms.scrollLeft = document.body.scrollLeft; window.location.reload (); } } // Eventhandler hinzufügen Node.prototype.addEvent = function (event, aktion) { if (this.attachEvent) { this.attachEvent (event, aktion); } else { this.addEventListener (event.substr (2), aktion, false); } }; window.addEvent = Node.prototype.addEvent; top.addEvent = Node.prototype.addEvent; // Event Verarbeitung beenden Node.prototype.cancelEvent = function (e) { if (e.preventDefault) { e.preventDefault (); } e.returnValue = false; e.cancelBubble = true; }; // tag-Attribut auslesen Node.prototype.getString = function (name) { return this.getAttribute (name) ? this.getAttribute (name) : ""; }; Node.prototype.getInt = function (name) { return this.getAttribute (name) ? eval(this.getAttribute (name)) : 0; }; Node.prototype.getBool = function (name) { try {return this.getAttribute (name) ? (eval(this.getAttribute (name)) ? true : false) : false; } catch (e) {return true;}}; // tag-Attribute kopieren Node.prototype.copyAttributes = function (srcNode) { for (var i=0; i\n"; if (this.nextSibling) { text += this.nextSibling.xmlText (spacer); } return text; }; __construct (site, path, session); } /** * Ein Kontextmenu anzeigen */ function Kontextmenu (parent, dotId) { var self = this; var parent = parent; var submenu = null; var id = 0; var dotId = dotId; this.over = false; this.name = ""; this.init = function () { // Kontextmenu Struktur laden var request = new CmsAjax (top.cms.path + "/html/html_action.php", "action=kontextmenu"); request.onCompletion = function (response) { xml = document.createElement("xml"); xml.innerHTML = response; top.cms.kontextmenu = xml.firstChild; //d (top.cms.kontextmenu.xmlText ()); } request.run (); window.addEvent ("onload", onload); } var onload = function () { // Abdecker für hervorhebung der gewählten Elemente var mask = document.createElement("div"); mask.id = "cms_mask"; document.body.appendChild (mask); } // Menü erstellen und platzieren this.showMenu = function (name, event) { this.name = name; // Menue zusammenbauen var node = document.createElement("kontextmenu"); id = document.getElementsByTagName ("kontextmenu").length + 1; node.id = "cms_kontextmenu_" + id; node.setAttribute ("name", name); node.className = "cms_kontextmenu"; node.appendChild (menu (name)); document.body.appendChild (node); /* // menu im iFrame var m = menu (name); var inode = document.createElement("iframe"); inode.id = "cms_kontextmenu_iframe_" + id; inode.style.width = "100%"; inode.style.height = "100%"; inode.src = "about:blank"; inode.onload = function () {this.contentDocument.body.appendChild (m);}; node.appendChild (inode); document.body.appendChild (node); */ // Menue positionieren var node_width = node.offsetWidth; var node_height = node.offsetHeight; if (event) { // wenn parent ein Dot ist var node_left = event.pageX; var node_top = event.pageY; } else { // wenn parent ein Menue ist var node_left = parent.offsetWidth; var node_top = -2; for (obj = parent; obj; obj = obj.parentNode) { node_left += ((obj.offsetLeft)) ? obj.offsetLeft : 0; node_top += ((obj.offsetTop)) ? obj.offsetTop : 0; if (obj.nodeName == "KONTEXTMENU" || obj.nodeName == "DOT") { break; } } } // verhindern das kontext unterhalb/rechts des Fensters liegt var body_height = Math.max(document.body.clientHeight, document.documentElement.clientHeight); if ((body_height + document.body.scrollTop) < (node_top + node_height)) node_top = (body_height + document.body.scrollTop) - node_height; if ((document.body.clientWidth + document.body.scrollLeft) < (node_left + node_width)) node_left -= parent.offsetWidth + node_width; if (document.body.scrollTop > node_top) node_top = document.body.scrollTop; if (document.body.scrollLeft > node_left) node_left = document.body.scrollLeft; node.style.top = node_top+"px"; node.style.left = node_left+"px"; // Kontext menue ausblenden wenn Focus verloren geht var focusElement = document.getElementById ("cms_menu_focuselement"); if (!focusElement) { focusElement = document.createElement("a"); node.appendChild (focusElement); focusElement.id = "cms_menu_focuselement"; focusElement.href = ""; focusElement.focus (); } focusElement.addEvent ("onblur", onblur); }; // Menü entfernen this.destroy = function () { if (!self.over && document) { var node = document.getElementById ("cms_kontextmenu_"+id); if (node) { document.body.removeChild (node); id = 0; } if (submenu) { submenu.destroy (); } if (parent.className == "cms_hover") { parent.className = "cms_normal"; } this.name = ""; clearTimeout (window.cms.showRangeTimeout); hideMenu (false); showRange (false); } }; // Menü Liste (alle Menü Zeilen aneinander hängen) var menu = function (name) { var table = document.createElement("table"); table.setAttribute ("cellpadding", 1); table.setAttribute ("cellspacing", 0); // aktive Menue in xml-Quelle suchen surce = top.cms.kontextmenu.firstChild; active = document.getElementsByTagName ("kontextmenu"); for (i=0; i"+icon (icon_name)+""+text+""+icon_submenu+""; tr = table.firstChild.firstChild; tr.copyAttributes (surce); tr.addEvent ("onclick", onclick); tr.addEvent ("onmouseover", onmouseover); tr.addEvent ("onmouseout", onmouseout); tr.setAttribute ('list_id', listRow ? listRow['id'] : (parent.getString ('list_id') ? parent.getString ('list_id') : "")); break; case "SEPERATOR": table.innerHTML = "
"; tr = table.firstChild.firstChild; tr.addEvent ("onclick", onclick); tr.addEvent ("onmouseover", onmouseover); tr.addEvent ("onmouseout", onmouseout); break; } tr.setAttribute ('dot_id', dotId); if (!enable) { // Inaktive Elemente tr.removeAttribute ("name"); tr.removeAttribute ("action"); tr.removeAttribute ("submenu"); } return tr; }; // Symbol das am Anfang der Menüzeile angezeigt wird var icon = function (icon_name) { return (icon_name) ? ("
") : ""; } // wenn ein menüpunkt angeklickt wird var onclick = function () { var action = this.getString ("action"); if (action) { if (this.getBool ("window")) { //Edit Fenster öffnen new Action ().showWindow (action, this.getString ("dot_id"), this.getString ("list_id")+this.getString ("actionvalue"), !this.getBool ("nosidebar")); } else { // Aktion im Hintergrund ausführen (über Ajax) new Action ().request (this.getString ("dot_id"), action, this.getString ("list_id")); } } self.over = false; self.destroy (); } var onmouseover = function () { self.over = true; var name = this.getString ("name") // Menüpunkt hervorheben if (name) { this.className = "cms_hover"; } if (!submenu || (submenu && submenu.name != name)) { // altes Submenü schliessen if (submenu) { submenu.destroy (); submenu = null; } // Submenü öffnen if (this.getBool ("submenu")) { submenu = new Kontextmenu (this, dotId); submenu.showMenu (name); } } // Betroffene Elemente hervorheben showRange (dotId, this.getString ("highlight_content")); }; var onmouseout = function () { var name = this.getString ("name") self.over = false; // Menüpunkt normal anzeigen if (name && !submenu) { this.className = "cms_normal"; } // Hervorhebung aufheben showRange (false); }; var onblur = function () { self.destroy (); }; // gewählten Bereich hervorheben var showRange = function (dotId, range, now) { var mask = true; clearTimeout (window.cms.showRangeTimeout); if (dotId && range) { // Betroffene Elemente zusammensuchen und im dot-Objekt speichern document.getElementById (dotId).getDependency (); // getDependency (dotId); // alte Hervorhebung beenden if (window.cms.showRangeLastDotId) { showRange (false); } // Zeitversetzte Hervorhebung if (!now) { window.cms.showRangeTimeout = setTimeout (function () {showRange (dotId, range, true);}, 2000); return; } window.cms.showRangeLastDotId = dotId; window.cms.showRangeLastRange = range; } if (!dotId) { // Hervorhebung aufheben mask = false; dotId = window.cms.showRangeLastDotId; range = window.cms.showRangeLastRange; window.cms.showRangeLastDotId = ""; window.cms.showRangeLastRange = ""; } if (dotId && range) { var dot = document.getElementById (dotId); if (!dot.dependency || !dot.dependency[range]) { // server Request (für dependency) wurde noch nicht beantwortet window.cms.showRangeTimeout = setTimeout (function () {showRange (dotId, range);}, 500); return; } // Menue ausblenden hideMenu (mask); // Elemente hervorheben // Alles Maskieren document.getElementById ("cms_mask").className = (mask) ? "cms_mask" : ""; // betroffene Dots entmaskieren var dep = dot.dependency[range]; var nodes = document.getElementsByTagName ("cms:dot"); for (var i=0; i 5) { level -= level/10; window.cms.hideMenuTimeout = setTimeout (function () {hideMenu (true, level);}, 100); } var menues = document.getElementsByTagName ("kontextmenu"); for (i=0; i" : ""; } dot.innerHTML = "" + html + ""; // Events if (!dot.events) { dot.addEvent ("onmouseover", onmouseover); dot.addEvent ("onmouseout", onmouseout); dot.addEvent ("onclick", onclick); dot.addEvent ("oncontextmenu", oncontextmenu); dot.events = true; // Events für Elemente var names = xml.getString ("names").split (','); for (i in names) { var element = document.getElementById ("cms_element_"+dot.getAttribute ("group")+"_"+names[i]); if (element) { element.dot = dot; element.addEvent ("ondblclick", onclick); if (top.cms.status && !top.cms.status['disable_element_contextmenu']) { element.addEvent ("oncontextmenu", oncontextmenu); } } } } // Child Knoten in dot-Objekt übertragen element = xml.firstChild; for (element = xml.firstChild; element; element = element.nextSibling) { name = element.nodeName.toLowerCase(); dot[name] = Array (); var j = 0; for (group = element.firstChild; group; group = group.nextSibling) { dot[name][j] = Array (); for (i=0; i 400) { console.group (message.substr (0,100).replace (/\s{2,}|\n/g, " ") + "..."); } // console.log (message); element = window.document.createElement ("xml"); element.innerHTML = message; console.dirxml (element); if (message.length > 400) { console.groupEnd (); } } } } catch (e) { /* if (window.location.href.indexOf(".test") == -1 && window.location.href.indexOf(".stroebele") == -1) { // return; } if (!top._debug) { top._debug = top.open ("", "Debug", "width=1000, height=460, left=0, top=0, status=no, toolbar=no, scrollbars=yes"); if (!top._debug) { return; } top._debug.document.title = "Debug"; } if (!top._debug.closed) { if (!window._debug) { window._debug = top._debug; element = top._debug.document.createElement ("hr"); top._debug.document.body.insertBefore (element, top._debug.document.body.firstChild); date = new Date(); element = top._debug.document.createTextNode (date.toLocaleString ()); top._debug.document.body.insertBefore (element, top._debug.document.body.firstChild); if (!message) { return; } } if (setFocus) { top._debug.focus (); } if (/error|notice/i.test (message)) { element = top._debug.document.createElement ("span"); element.innerHTML = message; } else { element = top._debug.document.createElement ("pre"); textnode = top._debug.document.createTextNode (message); element.appendChild (textnode); } top._debug.document.body.insertBefore (element, top._debug.document.body.firstChild); } */ } }