/***************************************************************************** * * Copyright (c) 2003-2005 Kupu Contributors. All rights reserved. * * This software is distributed under the terms of the Kupu * License. See LICENSE.txt for license text. For a list of Kupu * Contributors see CREDITS.txt. * *****************************************************************************/ // $Id: kupuploneui.js,v 1.1 2005/08/30 17:10:22 dwinter Exp $ function PloneKupuUI(textstyleselectid) { this.tsselect = getFromSelector(textstyleselectid); this.otherstyle = null; this.styles = {}; var styles = this.styles; // use an object here so we can use the 'in' operator later on function cleanStyles(options) { for (var i=0; i < options.length; i++) { var style = options[i].value; if (style.indexOf('|') > -1) { var split = style.split('|'); style = split[0].toLowerCase() + "|" + split[1]; }; styles[style] = i; }; } cleanStyles(this.tsselect.options); this.nodeStyle = function(node) { var currnode = node; var index = -1; var styles = this.styles; var options = this.tsselect.options; this.styletag = undefined; this.classname = ''; while (currnode) { if (currnode.nodeType==1) { var tag = currnode.tagName; if (tag=='BODY') { if (!this.styletag) { // Force style setting this.setTextStyle(options[0].value, true); return 0; } break; } tag = tag.toLowerCase(); if (/p|div|h.|t.|ul|ol|dl|menu|dir|pre|blockquote|address|center/.test(tag)) { var className = currnode.className; this.styletag = tag; this.classname = className; var style = tag+'|'+className; if (style in styles) { index = styles[style]; } else if (!className && tag in styles) { index = styles[tag]; } } } currnode = currnode.parentNode; } return index; } this.updateState = function(selNode) { /* set the text-style pulldown */ // first get the nearest style // search the list of nodes like in the original one, break if we encounter a match, // this method does some more than the original one since it can handle commands in // the form of '