// Fireworks JavaScript Command // Copy to Fireworks/Configuration/Commands/ // 2007 Aaron Beall - http://fireworks.abeall.com // Version 1.0 // Requires CS3+ var dom = fw.getDocumentDOM(); var sel = [].concat(fw.selection); function ChangeCase(textCase){ if(!dom) return; var texts = []; for(var s in sel){ if(sel[s] == "[object Text]") texts.push(sel[s]); } if(!texts.length) return alert("Please select at least one text box or some text."); if(texts.length > 1){ for(var t in texts) setTextChars(texts[t],texts[t].textChars[textCase]()); }else{ var selIndex = fw.textInsertionIndex; var selLength = fw.textInsertionLength; if(selIndex == -1){ setTextChars(texts[0],texts[0].textChars[textCase]()); }else{ if(selLength == 0) return alert("Select some text, or select the entire text box."); var chars = texts[0].textChars; setTextChars( texts[0],chars.substring(0,selIndex) + chars.substring(selIndex,selIndex+selLength)[textCase]() + chars.substring(selIndex+selLength,chars.length) ); } } // replace the characters in a text box while preserving textRuns function setTextChars(text,txt){ //text.textChars = txt; // almost so easy! but it breaks undo //dom.changeCurrentPage(dom.currentPageNum); // hack to force refresh the screen, because changing textChars doesn't refresh the screen var runs = text.textRuns, run, charCount = 0; for(var i=0; i