示例#1
0
文件: forms.py 项目: dli7428/reahl
 def add_as_addon(self, addon, position):
     if isinstance(addon, six.string_types):
         addon = Span(self.view, text=addon)
     span = Span(self.view)
     span.add_child(addon)
     span.append_class('input-group-%s' % position)
     addon.append_class('input-group-text')
     return self.div.add_child(span)
示例#2
0
    def add_bordering_link_for(self, menu, short_description, long_description, start_page_number, disabled):
        link = A.from_bookmark(self.view, self.get_bookmark(start_page_number=start_page_number, 
                                                            disabled=disabled))

        link.add_child(Span(self.view, text=short_description)).set_attribute('aria-hidden', 'true');
        link.add_child(Span(self.view, text=long_description)).append_class('sr-only');
        link.set_attribute('aria-label', long_description);
        link.set_active(not disabled)
        item = menu.add_a(link)
        item.html_representation.add_attribute_source(AccessRightAttributes(link))
        self.add_styling_to_menu_item(item)
示例#3
0
    def add_control(self, previous=False):
        control_a = self.carousel_panel.add_child(A(self.view, self.url))
        control_a.append_class('carousel-control-prev' if previous else 'carousel-control-next')
        control_a.set_attribute('role', 'button')
        control_a.set_attribute('data-slide', 'prev' if previous else 'next')

        span_icon = control_a.add_child(Span(self.view))
        span_icon.append_class('carousel-control-%s-icon' % ('prev' if previous else 'next'))
        span_icon.set_attribute('aria-hidden', 'true')

        span_text = control_a.add_child(Span(self.view, text=_('Previous') if previous else _('Next')))
        span_text.append_class('sr-only')

        return control_a
示例#4
0
    def __init__(self, form, bound_field):
        file_input = FileInputButton(form, bound_field)
        super(FileInput, self).__init__(file_input)

        self.input_group = self.add_child(Div(self.view))
        self.input_group.append_class('input-group')
        self.input_group.append_class('reahl-bootstrapfileinput')
        self.set_html_representation(self.input_group)

        span = self.input_group.add_child(Span(form.view))
        span.append_class('input-group-btn')
        span.add_child(file_input)

        filename_input = self.input_group.add_child(
            Span(self.view, text=_('No files chosen')))
        filename_input.append_class('form-control')
示例#5
0
    def add_dropdown(self,
                     title,
                     dropdown_menu,
                     drop_up=False,
                     query_arguments={}):
        """Adds the dropdown_menu :class:`DropdownMenu` to this Nav. It appears as the
        top-level item with text `title`.

        :keyword drop_up: If True, the dropdown will drop upwards from its item, instead of down.
        :keyword query_arguments: (For internal use)
        """
        if self.open_item == title:
            extra_query_arguments = {'open_item': ''}
        else:
            extra_query_arguments = {'open_item': title}
        extra_query_arguments.update(query_arguments)

        bookmark = Bookmark.for_widget(
            title, query_arguments=extra_query_arguments).on_view(self.view)
        submenu = MenuItem(self.view, A.from_bookmark(self.view, bookmark))
        self.menu_items.append(submenu)

        li = self.add_html_for_item(submenu)
        li.add_child(dropdown_menu)

        if self.open_item == title:
            li.append_class('open')
        submenu.a.append_class('dropdown-toggle')
        submenu.a.set_attribute('data-toggle', 'dropdown')
        submenu.a.set_attribute('data-target', '-')
        submenu.a.add_child(Span(self.view)).append_class('caret')
        li.append_class('drop%s' % ('up' if drop_up else 'down'))
        return submenu
示例#6
0
文件: files.py 项目: xmonader/reahl
 def __init__(self, form, remove_event, persisted_file, css_id=None):
     super().__init__(form.view, css_id=css_id)
     self.set_attribute('class', 'reahl-bootstrap-file-upload-li')
     self.add_child(
         Button(
             form,
             remove_event.with_arguments(filename=persisted_file.filename)))
     self.add_child(Span(self.view, persisted_file.filename))
示例#7
0
文件: navbar.py 项目: smohaorg/reahl
    def __init__(self, view, target_widget, text=None):
        super().__init__(view, 'button', children_allowed=True)
        self.set_attribute('type', 'button')

        self.target_widget = target_widget
        self.append_class('navbar-toggler')
        self.set_attribute('data-toggle', 'collapse')
        self.set_attribute('data-target', '#%s' % target_widget.css_id)
        self.set_attribute('aria-controls', '%s' % target_widget.css_id)
        self.set_attribute('aria-label', _('Toggle navigation'))

        if text is None:
            collapse_toggle_widget = Span(self.view)
            collapse_toggle_widget.append_class('navbar-toggler-icon')
        else:
            collapse_toggle_widget = TextNode(view, text)
        self.add_child(collapse_toggle_widget)
示例#8
0
 def add_upload_controls(self):
     controls_panel = self.upload_form.add_child(Div(self.view)).use_layout(FormLayout())
     file_input = controls_panel.layout.add_input(FileInput(self.upload_form.form, self.fields.uploaded_file), hide_label=True)
     
     button_addon = file_input.html_representation.add_child(Span(self.view))
     button_addon.append_class('input-group-append')
     button_addon.add_child(Button(self.upload_form.form, self.events.upload_file))
     return controls_panel
示例#9
0
 def add_validation_error_to(self, form_group, html_input):
     error_text = form_group.add_child(
         Span(self.view, text=html_input.validation_error.message))
     error_text.append_class('invalid-feedback')
     error_text.set_attribute(
         'data-generated-for',
         html_input.name)  # need for our custom bootstrapfileuploadpanel.js
     error_text.set_attribute('generated', 'true')
     return error_text
示例#10
0
文件: files.py 项目: smohaorg/reahl
    def __init__(self, form, bound_field):
        label = Label(form.view)
        self.simple_input = label.add_child(_UnstyledHTMLFileInput(form, bound_field))
        self.simple_input.html_representation.append_class('btn-secondary')
        label.add_child(Span(form.view, text=_('Choose file(s)')))
        super().__init__(self.simple_input)
        self.add_child(label)

        label.append_class('reahl-bootstrapfileinputbutton')
        label.append_class('btn')
        label.append_class('btn-primary')
        self.set_html_representation(label)
示例#11
0
文件: navbar.py 项目: smohaorg/reahl
    def add(self, widget):
        """Adds the given Form or Nav `widget` to the Navbar.

        :param widget: A :class:`~reahl.web.bootstrap.navs.Nav`, :class:`~reahl.web.bootstrap.ui.Form` or
                       :class:`~reahl.web.bootstrap.ui.TextNode` to add.
        """
        if isinstance(widget, reahl.web.bootstrap.navs.Nav):
            widget.append_class('navbar-nav')
        if isinstance(widget, Form):
            widget.append_class('form-inline')
        if isinstance(widget, TextNode):
            span = Span(self.view)
            span.add_child(widget)
            span.append_class('navbar-text')
            widget = span
        return self.contents_container.add_child(widget)
示例#12
0
 def display_result(self, controls):
     if self.calculator.result is not None:
         message = '= %s' % self.calculator.result
     else:
         message = '= ---'
     controls.add_child(Span(self.view, text=message))
示例#13
0
文件: forms.py 项目: dli7428/reahl
 def create_help_text_widget(self, help_text):
     return Span(self.view, text=help_text)