コード例 #1
0
ファイル: richtext.py プロジェクト: timparkin/into-the-light
    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)
コード例 #2
0
ファイル: restwidget.py プロジェクト: zeus911/vpnease-l2tp
    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)
コード例 #3
0
ファイル: restwidget.py プロジェクト: bne/squeal
    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
コード例 #4
0
ファイル: richtext.py プロジェクト: timparkin/into-the-light
    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
コード例 #5
0
ファイル: restwidget.py プロジェクト: zeus911/vpnease-l2tp
    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