# vim:fileencoding=utf-8 # License: GPL v3 Copyright: 2015, Kovid Goyal from dom import build_rule from elementmaker import E from book_list.theme import get_color def create_button(text, icon=None, action=None, tooltip=None): cls = '' if icon: cls = str.format('fa fa-{} fa-lg', icon) text = '\xa0' + text ans = E.button(E.i(class_=cls), text, class_='calibre-push-button', type='button', title=tooltip or '') if action is not None: ans.addEventListener('click', def(event): event.preventDefault(), action(event);) return ans create_button.style = build_rule('button.calibre-push-button', border_radius='1em', background_clip='padding-box', background_color=get_color('button-start'), background_image=str.format('linear-gradient(to bottom, {}, {})', get_color('button-start'), get_color('button-end')), padding='1ex 1em', color=get_color('button-text'), cursor='pointer', font_size='inherit' ) create_button.style += build_rule('button.calibre-push-button:hover', transform='scale(1.2)') create_button.style += build_rule('button.calibre-push-button:active', transform='scale(2)') create_button.style += build_rule('button.calibre-push-button:focus', outline='none') create_button.style += build_rule('button.calibre-push-button::-moz-focus-inner', border='0') def create_spinner(): return E.i(class_='fa fa-spin fa-spinner') def get_widget_css(): ans = create_button.style return ans