def result(): s = self.state.value if s is True: hdr = Html( '<button onclick="{0}" style="width: 100%; text-align: left">' .format(post_event_js_code_for_handler('clicked')), self.__header, '</button>') hdr = hdr.js_function_call( 'larch.controls.initButton', {'icons': { 'primary': 'ui-icon-minus' }}) hdr = hdr.with_event_handler('clicked', on_clicked) ct = Html('<div class="dropdown_expander_content">', self.__content, '</div>') return Html(hdr, ct) elif s is False: hdr = Html( '<button onclick="{0}" style="width: 100%; text-align: left">' .format(post_event_js_code_for_handler('clicked')), self.__header, '</button>') hdr = hdr.js_function_call( 'larch.controls.initButton', {'icons': { 'primary': 'ui-icon-plus' }}) hdr = hdr.with_event_handler('clicked', on_clicked) return hdr else: raise TypeError, 'drop down expander: state type unknown'
def iframe(self, width=None, height=None): p = Html('<div class="deck-container">').extend( self.__slides).append('</div>') p = p.js_function_call('init_deck_js').use_js(source=_deck_js) p = _deck_libs(p, self.__extensions, self.__style, self.__transition) p = PresIFrame(p, width, height) return p
def link(self, link_content): p = Html('<div class="deck-container">').extend( self.__slides).append('</div>') p = p.js_function_call('init_deck_js').use_js(source=_deck_js) p = _deck_libs(p, self.__extensions, self.__style, self.__transition) p = PresLink(p, link_content) return p
def pres(self, pres_ctx): textarea = Html(u'<textarea>{text}</textarea>'.format( text=Html.escape_str(self.__text))) textarea = textarea.js_function_call('larch.controls.initCodeMirror', self.__config, self.__immediate_events, self.__channel) p = Html('<div>', textarea, '</div>') p = p.use_css('/static/codemirror-3.14/lib/codemirror.css') p = p.use_js('/static/codemirror-3.14/lib/codemirror.js') for mode in self.__modes: p = p.use_js( '/static/codemirror-3.14/mode/{0}/{0}.js'.format(mode)) for addon in _addon_js: p = p.use_js('/static/codemirror-3.14/addon/{0}'.format(addon)) for addon in _addon_css: p = p.use_css('/static/codemirror-3.14/addon/{0}'.format(addon)) if _code_mirror_theme is not None: p = p.use_css('/static/codemirror-3.14/theme/{0}.css'.format( _code_mirror_theme)) p = p.use_js('/static/larch/larch_ui.js').use_css( '/static/larch/larch_ui.css') p = p.with_event_handler('code_mirror_edit', lambda event: self.edit(event, event.data)) p = p.with_event_handler('code_mirror_focus', self.focus) p = p.with_event_handler('code_mirror_blur', self.blur) return p
def pres(self, pres_ctx): spin = Html('<input name={0} value={1} />'.format( self.__input_name, self.__value)) spin = spin.js_function_call('larch.controls.initSpinner', self.__channel) spin = spin.with_event_handler("spinner_change", self.__on_spinner_change) spin = spin.use_js('/static/larch/larch_ui.js').use_css( '/static/larch/larch_ui.css') return spin
def pres(self, pres_ctx): if self.__width is None: div = Html('<div></div>') else: div = Html('<div style="width: {0};"></div>'.format(self.__width)) div = div.js_function_call('larch.controls.initSlider', True, self.__options, self.__channel) div = div.with_event_handler("slider_change", lambda event: self.release(event, event.data)) div = div.with_event_handler("slider_slide", lambda event: self.slide(event, event.data)) div = div.use_js('/static/larch/larch_ui.js').use_css('/static/larch/larch_ui.css') return div
def pres(self, pres_ctx): if self.__width is None: div = Html('<div></div>') else: div = Html('<div style="width: {0};"></div>'.format(self.__width)) div = div.js_function_call('larch.controls.initSlider', True, self.__options, self.__channel) div = div.with_event_handler("slider_change", lambda event: self.release(event, event.data)) div = div.with_event_handler("slider_slide", lambda event: self.slide(event, event.data)) div = div.use_js('/files/static/larch/larch_ui.js').use_css('/files/static/larch/larch_ui.css') return div
def pres(self, pres_ctx): contents = ['<div><ul>'] for i, (tab, content) in enumerate(self.__tab_label_and_content_pairs): contents.extend([ '<li><a href="#__larch_tabs_{0}_{1}">'.format( self.__tab_counter, i), tab, '</a></li>' ]) contents.append('</ul>') for i, (tab, content) in enumerate(self.__tab_label_and_content_pairs): contents.extend([ '<div id="__larch_tabs_{0}_{1}">'.format( self.__tab_counter, i), content, '</div>' ]) contents.append('</div>') tabs.__tab_counter += 1 t = Html(*contents) t = t.js_function_call('larch.controls.initTabs') t = t.use_js('/static/larch/larch_ui.js').use_css( '/static/larch/larch_ui.css') return t
def pres(self, pres_ctx): if self.__use_edit_button: p = Html( u'<div class="__larch_ui_ckeditor_edit_container"><div>{text}</div></div>' .format(text=self.__text)).js_function_call( 'larch.controls.initCKEditorWithEditButton', self.__config, self.__immediate_events, self.__channel) else: p = Html(u'<div contenteditable="true">{text}</div>'.format( text=self.__text)) p = p.js_function_call('larch.controls.initCKEditor', self.__config, self.__immediate_events, self.__channel) p = p.js_shutdown_function_call('larch.controls.shutdownCKEditor') p = p.use_js('/static/ckeditor/ckeditor.js') p = p.use_js('/static/larch/larch_ui.js').use_css( '/static/larch/larch_ui.css') p = p.with_event_handler('ckeditor_edit', lambda event: self.edit(event, event.data)) p = p.with_event_handler('ckeditor_focus', self.focus) p = p.with_event_handler('ckeditor_blur', self.blur) return p