Changeset 11437 for main/waeup.kofa/trunk/src/waeup/kofa/browser
- Timestamp:
- 26 Feb 2014, 07:54:30 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/layout.py
r11254 r11437 69 69 class KofaAction(Action): 70 70 71 def __init__(self, label, style='', **options):71 def __init__(self, label, style='', tooltip='', warning='', **options): 72 72 super(KofaAction, self).__init__(label, **options) 73 73 self.style = style 74 self.tooltip = tooltip 75 self.warning = warning 74 76 if style == '': 75 77 self.style = 'default' 76 77 78 78 79 def render(self): … … 82 83 if isinstance(label, Message): 83 84 label = translate(self.label, context=self.form.request) 84 return ('<input type="submit" id="%s" name="%s" value="%s"' 85 ' class="btn btn-%s"/>' % 86 (self.__name__, self.__name__, escape(label, quote=True), 87 self.style)) 85 if self.warning: 86 warning = translate(self.warning, context=self.form.request) 87 self.warning = ' onclick="return window.confirm(\'%s\')"' % warning 88 if self.tooltip: 89 tooltip = translate(self.tooltip, context=self.form.request) 90 self.tooltip = ' data-toggle="tooltip" title="%s"' % tooltip 91 if self.style: 92 style = ' class="btn btn-%s"' % self.style 93 else: 94 style = ' class="btn btn-default"' 95 html = ('<input type="submit" id="%s" name="%s" value="%s"' % 96 (self.__name__, self.__name__, escape(label, quote=True)) 97 + style + self.tooltip + self.warning 98 + ' />') 99 return html 88 100 89 101 class jsaction(grok.action): 90 102 103 msg = _('Are you sure?') 104 91 105 def __call__(self, success): 92 action = JSAction(self.label, success=success, **self.options) 106 action = KofaAction(self.label, 107 success=success, warning=self.msg, 108 **self.options) 93 109 self.actions.append(action) 94 110 return action 95 96 class JSAction(Action):97 98 msg = _('\'Are you sure?\'')99 100 def __init__(self, label, style='', **options):101 super(JSAction, self).__init__(label, **options)102 self.style = style103 if style == '':104 self.style = 'default'105 106 def render(self):107 if not self.available():108 return ''109 label = self.label110 if isinstance(label, Message):111 label = translate(self.label, context=self.form.request)112 msg = translate(self.msg, context=self.form.request)113 return ('<input type="submit" id="%s" name="%s" value="%s"'114 ' class="btn btn-%s" onclick="return window.confirm(%s)" />' %115 (self.__name__, self.__name__, escape(label, quote=True),116 self.style, msg)117 )118 111 119 112 def NullValidator(*args, **kw):
Note: See TracChangeset for help on using the changeset viewer.