# -*- coding: utf-8 -*- """ This file contains spellchecking widgets. SpellCheckable is a text area and spellcheck button """ from jToolkit.web import server from jToolkit.widgets import widgets from jToolkit import spellcheck # Copyright 2002, 2003 St James Software # # This file is part of jToolkit. # # jToolkit is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # jToolkit is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with jToolkit; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA class SpellingStandby(widgets.PlainContents): """ a simple 'loading...' screen """ def __init__(self): html = """
checking... |
" % (fontWeight,fontStyle) + htmltext + "" #finish the javascript jswordlistarray = 'Array(%s)'%(','.join(words)) #this is the short version of the above code, but can be incorrect if the words are out of order: #text = text.replace(word,"" + word + "",1) #body of the javascript jstext = """ """ % (jswordlistarray,spellcheckfield) #CSS to handle word wrapping css = widgets.PlainContents(""" """) #create the javascript autorunscript = widgets.PlainContents(jstext) javascript = widgets.Script('text/javascript', '', newattribs={'src': js_url}) #finish the page widgets.Page.__init__(self,contents=[htmltext], newattribs={'includeheading':False,'bgcolor':'#D5E6F7'}, headerwidgets=[css,autorunscript,javascript]) class SpellCheckable(widgets.PlainContents): """ a text area with spellcheck button """ def __init__(self, newattribs, readonly = 0, contents = "", standby_url=None, target_url=None, js_url=None): if standby_url is None: standby_url = "spellingstandby.htm" if target_url is None: target_url = "spellcheck.htm" if js_url is None: js_url = "js/spellui.js" textarea = widgets.TextArea(newattribs, readonly, contents) textareaname = textarea.attribs['name'] include_script = widgets.Script('text/javascript', '', newattribs={'src': js_url}) if "." in textareaname: onclickscript = "ToggleSpellChecker(this.form['%s'], this)" % textareaname else: onclickscript = "ToggleSpellChecker(this.form.%s, this)" % textareaname spellcheckbutton = widgets.Input({'type': "button", 'value': "spellcheck", 'onclick': onclickscript}) layertext = """