Skip to content
Snippets Groups Projects
Commit e6cb9507e074 authored by Laure Bourgois's avatar Laure Bourgois
Browse files

comment cancel (javascript solution)

parent 480ce788c1b1
No related branches found
No related tags found
No related merge requests found
......@@ -147,7 +147,8 @@
id = 'inlinecommentform'
title = None # hidden
requires = ('Comment',)
accepts = ('Comment',)
__selectors__ = (kwargs_selector,)
expected_kwargs = ('commented',)
EDITION_BODY = u"""
......@@ -150,8 +151,7 @@
__selectors__ = (kwargs_selector,)
expected_kwargs = ('commented',)
EDITION_BODY = u"""
<div id="comment%(eid)sSlot">%(attrform)s
<div id="comment%(eid)sbbar"><button onclick="%(onclick)s" tabindex="%(tabindex1)s">%(validate)s</button>
......@@ -155,8 +155,9 @@
<div id="comment%(eid)sSlot">%(attrform)s
<div id="comment%(eid)sbbar"><button onclick="%(onclick)s" tabindex="%(tabindex1)s">%(validate)s</button>
<button onclick="javascript:window.history.go(-1)" tabindex="%(tabindex2)s">%(cancel)s</button>
<button onclick="%(oncancelclick)s" tabindex="%(tabindex2)s">%(cancel)s</button>
</div>
</div>
"""
def call(self, commented):
......@@ -159,8 +160,8 @@
</div>
</div>
"""
def call(self, commented):
self.req.add_js('cubes.comment.js')
self.req.add_js('cubicweb.ajax.js','cubes.comment.js')
newcomment = self.vreg.etype_class('Comment')(self.req, None, None)
newcomment.eid = 'INLINE'
# hack to avoid tabindex conflicts caused by Ajax requests
......@@ -168,7 +169,8 @@
self._hiddens = []
attrform = self.attributes_form(newcomment, {})
onclick = html_escape("processComment(%s, 'add_comment')" % dumps(commented.eid))
self.w(self.EDITION_BODY % dict(attrform=attrform, onclick=onclick,
oncancelclick = html_escape("processComment(%s, '')" % dumps(commented.eid))
self.w(self.EDITION_BODY % dict(attrform=attrform, onclick=onclick, oncancelclick=oncancelclick,
eid=commented.eid,
tabindex1=self.req.next_tabindex(),
tabindex2=self.req.next_tabindex(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment