def __init__(self, ctx, restWriter, key, srcId): self.restWriter = restWriter form = iforms.IForm( ctx ) u = widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ).child('_submit') self.destId=srcId + '-dest' formId=srcId + '-form' stan = T.html()[ T.head()[ T.script(type="text/javascript")[""" function ReSTTranslate() { dest = document.getElementById('%(destId)s'); form = document.getElementById('%(formId)s'); src = parent.document.getElementById('%(srcId)s'); dest.value = src.value; form.submit(); } """%{'srcId':srcId, 'destId':self.destId, 'formId':formId}] ], T.body()[ T.form(id=formId, method="POST", action=u)[ T.input(type="hidden", name=self.destId, id=self.destId) ], T.script(type="text/javascript")["ReSTTranslate();"], ], ] self.docFactory = loaders.stan(stan)
def __init__(self, ctx, restWriter, key, srcId): self.restWriter = restWriter form = iformal.IForm(ctx) u = widgetResourceURLFromContext( ctx, form.name).child(key).child(srcId).child('_submit') self.destId = srcId + '-dest' formId = srcId + '-form' stan = T.html( )[T.head()[T.script(type="text/javascript")[""" function ReSTTranslate() { dest = document.getElementById('%(destId)s'); form = document.getElementById('%(formId)s'); src = parent.document.getElementById('%(srcId)s'); dest.value = src.value; form.submit(); } """ % { 'srcId': srcId, 'destId': self.destId, 'formId': formId }]], T.body( )[T.form(id=formId, method="POST", action=u )[T.input(type="hidden", name=self.destId, id=self.destId)], T.script(type="text/javascript")["ReSTTranslate();"], ], ] self.docFactory = loaders.stan(stan)
def _renderTag(self, ctx, key, value, readonly): tag = T.invisible() ta = T.textarea(name=key, id=render_cssid(key), cols=self.cols, rows=self.rows)[value or ""] if readonly: ta(class_="readonly", readonly="readonly") tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iformal.IForm(ctx) srcId = render_cssid(key) previewDiv = render_cssid(key, "preview-div") frameId = render_cssid(key, "preview-frame") targetURL = widgetResourceURLFromContext(ctx, form.name).child(key).child(srcId) tag[T.br()] onclick = ["return Forms.Util.previewShow('", previewDiv, "', '", frameId, "', '", targetURL, "');"] tag[T.button(onclick=onclick)["Preview ..."]] tag[ T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onclick=["return Forms.Util.previewHide('", previewDiv, "');"])["Close"], ] ] return tag
def _renderReSTTag(self, ctx, content, key, readonly): namer = self._namer(key) tag=T.invisible() ta=T.textarea(name=namer('content'), id=keytocssid(namer('content')), cols=self.cols, rows=self.rows)[content or ''] if readonly: ta(class_='readonly', readonly='readonly') tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iforms.IForm( ctx ) srcId = keytocssid(namer('content')) previewDiv = srcId + ['-preview-div'] frameId = srcId + ['-preview-frame'] targetURL = widgetResourceURLFromContext(ctx, form.name).child(key).child( srcId ) tag[T.br()] tag[T.button(onClick=["return Forms.Util.previewShow('",previewDiv,"', '",frameId,"', '",targetURL,"');"] )['Preview ...']] if self.withImagePicker: tag[T.button(onclick=["return Cms.Forms.ImagePicker.popup('",srcId,"','tag')"])['Choose image ...']] if self.withItemSelection: if self.itemSelectionTemplates: itemSelectionTemplates = ','.join(self.itemSelectionTemplates) else: itemSelectionTemplates = '' if self.itemSelectionTypes: itemSelectionTypes = encodeTypes(self.itemSelectionTypes) else: itemSelectionTypes = '' tag[T.button(onclick=["return Cms.Forms.ItemSelection.popupForReST('",srcId,"', '",itemSelectionTypes,"', 'rest')"])['Choose items ...']] tag[T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onClick="return Forms.Util.previewHide('%s');"%(previewDiv))['Close'] ] ] return tag
def _renderTag(self, ctx, key, value, readonly): tag = T.invisible() ta = T.textarea(name=key, id=render_cssid(key), cols=self.cols, rows=self.rows)[value or ''] if readonly: ta(class_='readonly', readonly='readonly') tag[ta] if not readonly: try: import docutils except ImportError: raise else: form = iformal.IForm(ctx) srcId = render_cssid(key) previewDiv = render_cssid(key, 'preview-div') frameId = render_cssid(key, 'preview-frame') targetURL = widgetResourceURLFromContext( ctx, form.name).child(key).child(srcId) tag[T.br()] onclick = [ "return Forms.Util.previewShow('", previewDiv, "', '", frameId, "', '", targetURL, "');" ] tag[T.button(onclick=onclick)['Preview ...']] tag[T.div(id=previewDiv, class_="preview-hidden")[ T.iframe(class_="preview-frame", name=frameId, id=frameId), T.br(), T.button(onclick=[ "return Forms.Util.previewHide('", previewDiv, "');" ])['Close']]] return tag