def __init__(self, *args, **kwargs): super(Search, self).__init__(*args, **kwargs) self.startSearchEvent = EventDispatcher("startSearch") self.addClass("flr-search") self.searchLbl = html5.H2() self.searchLbl.appendChild(html5.TextNode(translate("Fulltext search"))) self.searchLbl.addClass("flr-search-label") self.appendChild(self.searchLbl) self.searchInput = Input() self.searchInput["type"] = "text" self.appendChild(self.searchInput) self.btn = Button(translate("Search"), callback=self.doSearch) self.appendChild(self.btn) self.sinkEvent("onKeyDown") self.last_search = ""
class Search(html5.Div): def __init__(self, *args, **kwargs): super(Search, self).__init__(*args, **kwargs) self.startSearchEvent = EventDispatcher("startSearch") self.addClass("flr-search") self.searchLbl = html5.H2() self.searchLbl.appendChild(html5.TextNode( translate("Fulltext search"))) self.searchLbl.addClass("flr-search-label") self.appendChild(self.searchLbl) self.searchInput = Input() self.searchInput["type"] = "text" self.appendChild(self.searchInput) self.btn = Button(translate("Search"), callback=self.doSearch) self.appendChild(self.btn) self.sinkEvent("onKeyDown") self.last_search = "" def doSearch(self, *args, **kwargs): if self.searchInput["value"] != self.last_search: if len(self.searchInput["value"]): self.startSearchEvent.fire(self.searchInput["value"]) else: self.resetSearch() self.last_search = self.searchInput["value"] def resetSearch(self): self.startSearchEvent.fire(None) def onKeyDown(self, event): if html5.isReturn(event): self.doSearch() event.preventDefault() event.stopPropagation() def resetLoadingState(self): if "is-loading" in self.btn["class"]: self.btn.removeClass("is-loading") def reevaluate(self): self.doSearch() def focus(self): self.searchInput.focus()
def __init__(self, bone, widgetFactory: callable, **kwargs): super().__init__(""" <div [name]="widgets" class="flr-bone-widgets"></div> <div [name]="actions" class="flr-bone-actions input-group"></div> """) languages = bone.skelStructure[bone.boneName]["languages"] assert languages, "This parameter must not be empty!" self.bone = bone self.languages = languages self._languageWidgets = {} # Create widget for every language for lang in self.languages: assert not any([ch in lang for ch in "<>\"'/" ]), "This is not a valid language identifier!" langBtn = Button(lang, callback=self.onLangBtnClick) langBtn.addClass("btn--lang", "btn--lang-" + lang) if lang == conf["defaultLanguage"]: langBtn.addClass("is-active") self.actions.appendChild(langBtn) kwargs["language"] = lang langWidget = widgetFactory(self.bone, **kwargs) if lang != conf["defaultLanguage"]: langWidget.hide() self.widgets.appendChild(langWidget) self._languageWidgets[lang] = (langBtn, langWidget)
def __init__(self, preview, *args, **kwargs): super(FileImagePopup, self).__init__(title=preview.currentFile.get("name", translate("Unnamed Image")), className="image-viewer", *args, **kwargs) self.sinkEvent("onClick") self.preview = preview img = html5.Img() img["src"] = getImagePreview(preview.currentFile, size=None) self.popupBody.appendChild(img) btn = Button(translate("Download"), self.onDownloadBtnClick) btn.addClass("btn--download") self.popupFoot.appendChild(btn) btn = Button(translate("Close"), self.onClick) btn.addClass("btn--close") self.popupFoot.appendChild(btn)