'From Squeak3.8gamma of ''24 November 2004'' [latest update: #6662] on 24 June 2005 at 9:49:04 am'! WARzComponent subclass: #RzEditor instanceVariableNames: 'content rtid valueHolder' classVariableNames: '' poolDictionaries: '' category: 'Rezervace-Editor'! !RzEditor methodsFor: 'accessing' stamp: 'pk 12/21/2004 10:06'! content ^(content ifNil: ['']) ! ! !RzEditor methodsFor: 'accessing' stamp: 'pk 12/21/2004 09:21'! content: anObject content := anObject! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 1/25/2005 19:46'! formRoot ^ self iCanBeTheFormRoot! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 1/25/2005 21:00'! initialize super initialize. rtid := 'abcdefghijklmnopqrstuvwxyz' shuffled. valueHolder := 'abcdefghijklmnopqrstuvwxyz' shuffled. content = String new. self formRoot addAttribute: (#onSubmit -> 'updateRTEs();') category: #formAttributes ! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 4/5/2005 20:12'! renderButtonOn: html image: img atl: alt action: action html attributeAt: #alt put: alt; attributeAt: #src put: img; attributeAt: #title put: alt; attributeAt: #onClick put: 'FormatText(''', rtid, ''', ''', action, ''', '''')'; tag: #img. ! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 4/5/2005 15:52'! renderButtonsOn: html self renderButtonOn: html image: 'bold.gif' atl: 'tučně' action: 'bold'. self renderButtonOn: html image: 'italic.gif' atl: 'kurzíva' action: 'italic'. self renderButtonOn: html image: 'underline.gif' atl: 'podtrženì' action: 'underline'. self renderButtonOn: html image: 'left_just.gif' atl: 'vlevo' action: 'justifyleft'. self renderButtonOn: html image: 'centre.gif' atl: 'na střed' action: 'justifycenter'. self renderButtonOn: html image: 'right_just.gif' atl: 'vpravo' action: 'justifyright'. self renderButtonOn: html image: 'justifyfull.gif' atl: 'do bloku' action: 'justifyfull'. self renderButtonOn: html image: 'hr.gif' atl: 'horizontální oddìlovač' action: 'inserthorizontalrule'. self renderButtonOn: html image: 'numbered_list.gif' atl: 'číslovaný seznam' action: 'insertorderedlist'. self renderButtonOn: html image: 'list.gif' atl: 'seznam' action: 'insertunorderedlist'. self renderButtonOn: html image: 'outdent.gif' atl: 'přisadit' action: 'outdent'. self renderButtonOn: html image: 'indent.gif' atl: 'odsadit' action: 'indent'. ! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 1/25/2005 19:51'! renderContentOn: html self formOn: html with: [ html attributeAt: #id put: valueHolder; hiddenInputWithValue: self content callback: [:val | self content: val]. self renderButtonsOn: html. self renderIFrameOn: html. html html: ''. ]. html break. ! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 12/21/2004 17:48'! renderIFrameOn: html html attributeAt: #id put: rtid; attributeAt: #name put: rtid; attributeAt: #width put: '100%'; attributeAt: #height put: '100px'; tag: #iframe.! ! !RzEditor methodsFor: 'as yet unclassified' stamp: 'pk 12/21/2004 20:52'! script ^ '// Cross-Browser Rich Text Editor // http://www.kevinroth.com/rte/demo.htm // Written by Kevin Roth (kevin@NOSPAMkevinroth.com - remove NOSPAM) // Visit the support forums at http://www.kevinroth.com/forums/index.php?c=2 //init variables var rng; var currentRTE; var allRTEs = ""; var allValueHolders = ""; var isGecko; var isSafari; var isKonqueror; var cssFile; function initRTE(css) { //set browser vars var ua = navigator.userAgent.toLowerCase(); isGecko = (ua.indexOf("gecko") !!= -1); isSafari = (ua.indexOf("safari") !!= -1); isKonqueror = (ua.indexOf("konqueror") !!= -1); //set paths vars cssFile = css; } function registerRTE(rte, valueHolder) { if (allRTEs.length > 0) allRTEs += ";"; if (allRTEs.length > 0) allValueHolders += ";"; allRTEs += rte; allValueHolders += valueHolder; } function enableDesignMode(rte, readOnly, valueHolder) { var html = document.getElementById(valueHolder).value; var frameHtml = "\n"; frameHtml += "\n"; //to reference your stylesheet, set href property below to your stylesheet path and uncomment if (cssFile.length > 0) { frameHtml += "\n"; } else { frameHtml += "\n"; } frameHtml += "\n"; frameHtml += "\n"; frameHtml += html + "\n"; frameHtml += "\n"; frameHtml += ""; if (document.all) { var oRTE = frames[rte].document; oRTE.open(); oRTE.write(frameHtml); oRTE.close(); if (!!readOnly) oRTE.designMode = "On"; } else { try { if (!!readOnly) document.getElementById(rte).contentDocument.designMode = "on"; try { var oRTE = document.getElementById(rte).contentWindow.document; oRTE.open(); oRTE.write(frameHtml); oRTE.close(); if (isGecko && !!readOnly) { //attach a keyboard handler for gecko browsers to make keyboard shortcuts work oRTE.addEventListener("keypress", kb_handler, true); } } catch (e) { alert("Error preloading content."); } } catch (e) { //gecko may take some time to enable design mode. //Keep looping until able to set. if (isGecko) { var expr = "enableDesignMode(''" + rte + "'', " + readOnly + ", ''" + valueHolder + "'');"; setTimeout(expr, 10); } else { return false; } } } } function updateRTEs() { var vRTEs = allRTEs.split(";"); var vValueHolders = allValueHolders.split(";"); for (var i = 0; i < vRTEs.length; i++) { updateRTE(vRTEs[i], vValueHolders[i]); } } function updateRTE(rte, valueHolder) { //set message value var oHdnMessage = document.getElementById(valueHolder); var oRTE = document.getElementById(rte); var readOnly = false; //check for readOnly mode if (document.all) { if (frames[rte].document.designMode !!= "On") readOnly = true; } else { if (document.getElementById(rte).contentDocument.designMode !!= "on") readOnly = true; } //if viewing source, switch back to design view if (oHdnMessage.value == null) oHdnMessage.value = ""; if (document.all) { oHdnMessage.value = frames[rte].document.body.innerHTML; } else { oHdnMessage.value = oRTE.contentWindow.document.body.innerHTML; } //if there is no content (other than formatting) set value to nothing if (stripHTML(oHdnMessage.value.replace(" ", " ")) == "" && oHdnMessage.value.toLowerCase().search("]+)>)/ig,""); //replace carriage returns and line feeds newString = newString.replace(/\r\n/g," "); newString = newString.replace(/\n/g," "); newString = newString.replace(/\r/g," "); //trim string newString = trim(newString); return newString; } function trim(inputString) { // Removes leading and trailing spaces from the passed string. Also removes // consecutive spaces and replaces it with one space. If something besides // a string is passed in (null, custom object, etc.) then return the input. if (typeof inputString !!= "string") return inputString; var retValue = inputString; var ch = retValue.substring(0, 1); while (ch == " ") { // Check for spaces at the beginning of the string retValue = retValue.substring(1, retValue.length); ch = retValue.substring(0, 1); } ch = retValue.substring(retValue.length - 1, retValue.length); while (ch == " ") { // Check for spaces at the end of the string retValue = retValue.substring(0, retValue.length - 1); ch = retValue.substring(retValue.length - 1, retValue.length); } // Note that there are two spaces in the string - look for multiple spaces within the string while (retValue.indexOf(" ") !!= -1) { // Again, there are two spaces in each of the strings retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ") + 1, retValue.length); } return retValue; // Return the trimmed string back to the user } '! !