summaryrefslogtreecommitdiff
path: root/examples/filebrowser
diff options
context:
space:
mode:
authorianb <devnull@localhost>2005-07-20 03:33:56 +0000
committerianb <devnull@localhost>2005-07-20 03:33:56 +0000
commitdc3235a2328c0db64781e00a1b808c059c97e77c (patch)
treefd4cff1613ed3ce348c88e4ae2250a32fd3cba36 /examples/filebrowser
parent979128c8d058daf30c747f1730a5f6fc88a3603e (diff)
downloadpaste-dc3235a2328c0db64781e00a1b808c059c97e77c.tar.gz
Added method for javascript link confirmation, and Xinha stylesheet setup
Diffstat (limited to 'examples/filebrowser')
-rw-r--r--examples/filebrowser/sitepage.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/filebrowser/sitepage.py b/examples/filebrowser/sitepage.py
index 64f842c..a5a300a 100644
--- a/examples/filebrowser/sitepage.py
+++ b/examples/filebrowser/sitepage.py
@@ -81,6 +81,10 @@ class SitePage(Servlet):
html.append('<script type="text/javascript">')
html.append('_editor_url = %r;' % base_url)
html.append('_editor_lang = "en";')
+ stylesheets = self.pathcontext.stylesheets()
+ if stylesheets:
+ html.append('xinha_stylesheets = %r;'
+ % [str(self.pathurl(s.path)) for s in stylesheets])
html.append('</script>')
html.append('<script type="text/javascript" src="%s"></script>'
% (base_url + 'htmlarea.js'))
@@ -123,6 +127,8 @@ class URL(object):
path_info = self.path_info
if add and '=' in add:
name, value = add.split('=', 1)
+ if name == 'confirm':
+ return ConfirmLink(self, urllib.unquote_plus(value))
vars[name] = value
elif add and add.startswith('/'):
path_info = add
@@ -206,6 +212,16 @@ class JSToggle(JSRemote):
javascript = property(javascript)
+class ConfirmLink(object):
+
+ def __init__(self, link, confirm):
+ self.link = link
+ self.confirm = confirm
+
+ def __str__(self):
+ return ("if (window.confirm(%r)) {location.href=%r}; return false"
+ % (self.confirm, str(self.link)))
+
def html_attrs(kw):
if not kw:
return ''