Example #1
0
class MultiColTextForm(PlusPluginFormBase):
    STYLE_CHOICES = 'MOD_COL_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    @staticmethod
    def _get_col_choice_field(dev):
        if dev == 'xs':
            choices = [
                ('', '1 (default)'),
            ]
        else:
            choices = [
                ('', 'inherit'),
            ]
        choices.extend(list(cps.TX_COL_CHOICES))

        field_name = 'col_%s' % dev
        field = forms.ChoiceField(label=u'%s No. of Cols' %
                                  cps.DEVICE_MAP[dev],
                                  required=False,
                                  choices=choices,
                                  initial='')
        return field_name, field

    @classmethod
    def extend_col_fields(cls):
        for dev in cps.DEVICES:
            field_name, field = cls._get_col_choice_field(dev)
            cls.declared_fields[field_name] = field
Example #2
0
class OsmForm(PlusPluginFormBase):
    latitude = forms.FloatField(
        label=_('Center Latitude'),
        required=True,
        help_text='Map center latitude, e.g. 47.798740')
    longitude = forms.FloatField(
        label=_('Center Longitude'),
        required=True,
        help_text='Map center longitude, e.g. 9.621890')
    zoom = forms.IntegerField(label=_('Zoom'),
                              required=True,
                              initial=15,
                              help_text='Maps initial zoom.')
    map_height = forms.CharField(label=_('Height'),
                                 required=True,
                                 initial='30vh',
                                 help_text='Height of Map in px or rem or vh.')
    scroll_wheel_zoom = forms.BooleanField(
        label=_('Scroll Wheel Zoom'),
        required=False,
        initial=True,
        help_text='Map zoom via mouse scroll wheel?')

    layer = forms.ChoiceField(
        label=_('Custom Layer'),
        required=False,
        initial='',
        choices=cps.MAP_LAYER_CHOICES,
        help_text=_('Adds a custom (colored) layer to the map.'),
    )

    STYLE_CHOICES = 'OSM_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #3
0
class BootstrapContainerForm(PlusPluginFormBase):

    FLUID_CHOICES = (
        ('container', _('Fixed')),
        ('container-fluid', _('Fluid')),
    )
    fluid = forms.ChoiceField(
        label=_('Container Type'),
        initial='container',
        required=True,
        choices=FLUID_CHOICES,
        widget=forms.widgets.RadioSelect,
        help_text=_('Changing your container from "fixed content with fluid '
                    'margin" to "fluid content with fixed margin".'))

    background_color = forms.ChoiceField(
        choices=cps.BG_COLOR_CHOICES,
        label=_("Background Color"),
        required=False,
        help_text=_('Select a background color.'))

    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.CNT_BOTTOM_MARGIN_CHOICES,
        initial='',
        help_text='Select the default bottom margin to be applied?')

    STYLE_CHOICES = 'MOD_CONTAINER_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #4
0
class SvgImageForm(LinkFormBase):

    image_file = PlusFilerFileSearchField(
        label=_('SVG Image File'),
        required=True,
    )

    image_title = forms.CharField(
        label=_('Image Title'),
        required=False,
        help_text=_('Caption text added to the "title" attribute of the '
                    '<img> element.'),
    )

    image_alt = forms.CharField(
        label=_('Alternative Description'),
        required=False,
        help_text=_('Textual description of the image added to the "alt" '
                    'tag of the <img> element.'),
    )

    require_link = False
    STYLE_CHOICES = 'SVG_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #5
0
class IconForm(LinkFormBase):
    require_link = False

    STYLE_CHOICES = 'MOD_ICON_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    icon = IconField(required=True)
Example #6
0
class EmbedForm(PlusPluginFormBase):

    url = forms.URLField(
        label=_("Media URL"),
        widget=widgets.URLInput(attrs={'size': 50}),
        help_text=_(
            'Video Url to an external service w/o query params such as YouTube, Vimeo or others, '
            'e.g.: '
            'https://www.youtube.com/embed/vZw35VUBdzo'),
    )

    ASPECT_RATIO_CHOICES = [
        ('embed-responsive-21by9', _("Responsive 21:9")),
        ('embed-responsive-16by9', _("Responsive 16:9")),
        ('embed-responsive-4by3', _("Responsive 4:3")),
        ('embed-responsive-1by1', _("Responsive 1:1")),
    ]
    aspect_ratio = forms.ChoiceField(
        label=_("Aspect Ratio"),
        choices=ASPECT_RATIO_CHOICES,
        widget=widgets.RadioSelect,
        required=False,
        initial=ASPECT_RATIO_CHOICES[1][0],
    )

    allow_fullscreen = forms.BooleanField(
        label=_("Allow Fullscreen"),
        required=False,
        initial=True,
    )

    autoplay = forms.BooleanField(
        label=_("Autoplay"),
        required=False,
    )

    controls = forms.BooleanField(
        label=_("Display Controls"),
        required=False,
    )

    loop = forms.BooleanField(
        label=_("Enable Looping"),
        required=False,
        help_text=_('Inifinte loop playing.'),
    )

    rel = forms.BooleanField(
        label=_("Show related"),
        required=False,
        help_text=_('Show related media content'),
    )

    STYLE_CHOICES = 'EMBED_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #7
0
class FigureForm(PlusPluginFormBase):

    caption = forms.CharField(
        label=_("Figure Caption"),
        widget=forms.widgets.TextInput(
            attrs={'style': 'width: 100%; padding-right: 0;'}),
    )

    STYLE_CHOICES = 'FIGURE_CAPTION_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #8
0
class BootstrapRowForm(PlusPluginFormBase):

    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.ROW_BOTTOM_MARGIN_CHOICES,
        initial=cps.ROW_BOTTOM_MARGIN_CHOICES[0][0],
        help_text='Select the default bottom margin to be applied?')

    STYLE_CHOICES = 'MOD_ROW_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #9
0
class TextLinkForm(LinkFormBase):
    link_content = forms.CharField(
        label=_("Link Content"),
        widget=forms.widgets.TextInput(attrs={'id': 'id_name'}),  # replace
        # auto-generated id so that CKEditor automatically transfers the text into
        # this input field
        required=False,
        help_text=_("Content of Link"),
    )

    STYLE_CHOICES = 'LINK_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #10
0
class BootstrapButtonForm(LinkFormBase):
    content = forms.CharField(
        label=_('Content'),
        required=False,
        help_text=
        'Button content, e.g.: Click me, or nothing for icon only button')

    BUTTON_SIZES = [
        ('btn-lg', _("Large button")),
        ('', _("Default button")),
        ('btn-sm', _("Small button")),
    ]

    button_size = forms.ChoiceField(label=_("Button Size"),
                                    choices=BUTTON_SIZES,
                                    initial='',
                                    required=False,
                                    help_text=_("Button Size to use."))

    button_block = forms.ChoiceField(
        label=_("Button Block"),
        choices=[
            ('', _('No')),
            ('btn-block', _('Block level button')),
        ],
        required=False,
        initial='',
        help_text=_("Use button block option (span left to right)?"))

    icon_position = forms.ChoiceField(
        label=_("Icon position"),
        choices=[
            ('icon-top', _("Icon top")),
            ('icon-right', _("Icon right")),
            ('icon-left', _("Icon left")),
        ],
        initial='icon-right',
        help_text=_("Select icon position related to content."),
    )

    icon = IconField(required=False)

    STYLE_CHOICES = 'BOOTSTRAP_BUTTON_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #11
0
class VerticalRatioSpacerForm(PlusPluginFormBase):

    landscape_height = SizeField(
        label=_('Height for landscape screen ratio.'),
        required=True,
        allowed_units=['px', '%', 'rem', 'vw', 'vh'],
        initial='',
    )
    portrait_height = SizeField(
        label=_('Height for portrait screen ratio.'),
        required=True,
        allowed_units=['px', '%', 'rem', 'vw', 'vh'],
        initial='',
    )

    STYLE_CHOICES = 'VERTICAL_RATIO_SPACER_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #12
0
class SnippetForm(PlusPluginFormBase):

    html = forms.CharField(
        label=_('HTML'),
        widget=forms.Textarea(
            attrs={
                'rows': 15,
                'data-editor': True,
                'data-mode': 'html',
                'data-theme': 'default',
                'style': 'max-height: initial',
                'class': 'c-border'
            }),
    )

    STYLE_CHOICES = 'SNIPPET_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #13
0
class HeadingForm(PlusPluginFormBase):
    TAG_TYPES = [('h{}'.format(k), _("Heading {}").format(k))
                 for k in range(1, 7)]

    tag_type = forms.ChoiceField(
        choices=TAG_TYPES,
        label=_("HTML element tag"),
        help_text=_('Choose a tag type for this HTML element.'))

    content = forms.CharField(
        label=_("Heading content"),
        widget=forms.widgets.TextInput(
            attrs={
                'style':
                'width: 100%; padding-right: 0; font-weight: bold; font-size: 125%;'
            }),
    )

    background_color = forms.ChoiceField(
        choices=cps.BG_COLOR_CHOICES,
        label=_("Background Color"),
        required=False,
        help_text=_('Select a background color.'))

    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.CNT_BOTTOM_MARGIN_CHOICES,
        initial='',
        help_text='Select the default bottom margin to be applied?')

    element_id = forms.CharField(label=_('Element ID'),
                                 max_length=255,
                                 required=False)

    STYLE_CHOICES = 'HEADING_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #14
0
class BootstrapColumnForm(PlusPluginFormBase):

    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.COL_BOTTOM_MARGIN_CHOICES,
        initial=cps.COL_BOTTOM_MARGIN_CHOICES[0][0],
        help_text='Select the default bottom margin to be applied')

    STYLE_CHOICES = 'MOD_COL_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    # offset and width fields are dynamically added with _extend_form_fields
    # method below

    @staticmethod
    def get_column_keys(for_attrs=None):
        keys = []
        attrs = for_attrs or ['offset', 'width', 'order', 'display']
        for attr in attrs:
            for dev in cps.DEVICES:
                keys.append('col_%s_%s' % (attr, dev))
        return keys

    # noinspection GrazieInspection
    @classmethod
    def extend_form_fields(cls, col_helper):
        """ Because column size form fields have to be added dynamically
        to reflect the devices: xs - xl, xxl, ... configured in app_settings
        we get the form ready here. This method is called from
        module level below.
        """
        # add column size fields col_offset_xs ..., col_width_xs ...,
        # col_order_xs.., col_display_xs .. col_display_xl
        for field_name, field in col_helper.get_column_form_fields():
            cls.declared_fields[field_name] = field
Example #15
0
class BackgroundVideoForm(PlusPluginFormBase):

    video_file = PlusFilerFileSearchField(
        label='Video file',
        help_text=_("An internal link onto an video file"),
    )

    image_filter = forms.ChoiceField(
        label='Image Filter',
        required=False,
        choices=cps.BGIMG_FILTER_CHOICES,
        initial='',
        help_text='The color filter to be applied over the unhovered video.')

    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.CNT_BOTTOM_MARGIN_CHOICES,
        initial='',
        help_text='Select the default bottom margin to be applied?')

    STYLE_CHOICES = 'BACKGROUND_VIDEO_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #16
0
class SlideForm(LinkFormBase):
    require_link = False

    STYLE_CHOICES = 'SLIDE_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)
Example #17
0
class BootstrapImageForm(LinkFormBase):

    image_file, image_title, image_alt = get_image_form_fields(required=True)

    STYLE_CHOICES = 'IMAGE_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    require_link = False

    SHAPE_CHOICES = [
        ('', _('None')),
        ('rounded', _('Rounded')),
        ('rounded-circle', _('Circle')),
        ('img-thumbnail', _('Thumbnail')),
    ]
    image_shapes = forms.ChoiceField(label=_("Image Shapes"),
                                     choices=SHAPE_CHOICES,
                                     required=False,
                                     initial='')

    ALIGNMENT_OPTIONS = [
        ('', _("None")),
        ('float-left', _("Left")),
        ('float-right', _("Right")),
        ('mx-auto', _("Center")),
    ]
    image_alignment = forms.ChoiceField(
        label=_("Image Alignment"),
        choices=ALIGNMENT_OPTIONS,
        required=False,
        initial='',
        help_text=
        _("How to align the image (this choice only applies if the image is fixed size (none repsonsive)."
          ),
    )

    # fixed width and height fields are added with _extend_form_fields below

    RESIZE_OPTIONS = [
        ('crop', _("Crop image")),
        ('upscale', _("Upscale image")),
    ]
    resize_options = forms.MultipleChoiceField(
        label=_("Resize Options"),
        choices=RESIZE_OPTIONS,
        widget=forms.widgets.CheckboxSelectMultiple,
        required=True,
        initial=['crop'],
        help_text=
        _("Options to use when calculating the cached size device specific version of the image."
          ),
    )

    # img_dev_width fields are added with _extend_form_fields below

    @classmethod
    def extend_form_fields(cls):
        for field_name, field in get_fixed_dim_fields('width'):
            cls.declared_fields[field_name] = field
        for field_name, field in get_fixed_dim_fields('height'):
            cls.declared_fields[field_name] = field
        for field_name, field in get_img_dev_width_fields():
            cls.declared_fields[field_name] = field
Example #18
0
class CardForm(CardChildBaseForm):
    STYLE_CHOICES = 'CARD_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(STYLE_CHOICES)
Example #19
0
class BackgroundImageForm(PlusPluginFormBase):

    image_file = PlusFilerImageSearchField(
        label=_('Background Image File'),
        required=True,
    )

    image_title = forms.CharField(
        label=_('Background Image Title'),
        required=False,
        help_text=_('Caption text added to the "title" attribute of the '
                    '<div> background image container element.'),
    )

    image_filter = forms.ChoiceField(
        label='Image Filter',
        required=False,
        choices=cps.BGIMG_FILTER_CHOICES,
        initial='',
        help_text='The color filter to be applied over the unhovered image.')

    do_thumbnail = forms.BooleanField(
        label=_('Do thumbnail'),
        initial=True,
        required=None,
        help_text=_(
            'Scale (thumbnail) image according to given device sizes below.'))

    crop = forms.BooleanField(
        label=_('Crop'),
        initial=True,
        required=False,
        help_text=_('Cut image before scale to given device size.'))

    crop_spec = forms.CharField(
        label=_('Crop Specifiaction'),
        initial='',
        required=False,
        help_text=
        _('Specifiy cropping, e.g.: smart | scale | 0,10 | ,0) - leave empty for default behavior.'
          ))

    upscale = forms.BooleanField(
        label=_('Upscale'),
        initial=False,
        required=False,
        help_text=_('Upscale image during scaling to given device size.'))

    # img_dev_width - fields are added below
    bottom_margin = forms.ChoiceField(
        label=u'Bottom Margin',
        required=False,
        choices=cps.CNT_BOTTOM_MARGIN_CHOICES,
        initial='',
        help_text='Select the default bottom margin to be applied?')

    STYLE_CHOICES = 'BACKGROUND_IMAGE_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    @classmethod
    def extend_form_fields(cls):
        for field_name, field in get_img_dev_width_fields():
            cls.declared_fields[field_name] = field
Example #20
0
class MagicWrapperForm(PlusPluginFormBase):

    TAG_CHOICES = [(cls, _("<{}> – Element").format(cls))
                   for cls in ['div', 'span', 'section', 'article']]

    tag_type = forms.ChoiceField(
        choices=TAG_CHOICES,
        label=_("HTML element tag"),
        help_text=_('Choose a tag type for this HTML element.'))

    background_color = forms.ChoiceField(
        choices=cps.BG_COLOR_CHOICES,
        label=_("Background Color"),
        required=False,
        help_text=_('Select a background color.'))

    # margin and padding fields are added in _extend_form_fields below

    element_id = forms.CharField(label=_('Element ID'),
                                 max_length=255,
                                 required=False)

    STYLE_CHOICES = 'MAGIC_WRAPPER_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)

    def __init__(self, *args, **kwargs):
        super(MagicWrapperForm, self).__init__(*args, **kwargs)

    @staticmethod
    def get_margin_keys(for_dev=None):
        keys = []
        devs = for_dev or cps.DEVICES
        for dev in devs:
            for s in ['ml', 'mr', 'mt', 'mb']:
                keys.append('%s_%s' % (s, dev))
        return keys

    @staticmethod
    def get_padding_keys(for_dev=None):
        keys = []
        devs = for_dev or cps.DEVICES
        for dev in devs:
            for s in ['pl', 'pr', 'pt', 'pb']:
                keys.append('%s_%s' % (s, dev))
        return keys

    @classmethod
    def _extend_form_fields(cls):
        """ Because margin and padding form fields have to be added dynamically
        to reflect the devices: xs - xl, xxl, ... configured in app_settings
        we get the MagicWrapperForm ready here.This method is called from
        module level below.
        """
        # add margin fields mt_xs, mr_xs ... ml_xl
        for field_name, field in get_margin_choice_fields():
            cls.declared_fields[field_name] = field

        # add padding fields pt_xs, pr_xs ... pl_xl
        for field_name, field in get_padding_choice_fields():
            cls.declared_fields[field_name] = field
Example #21
0
class SliderForm(PlusPluginFormBase):
    n_slides_xl, n_slides_lg, n_slides_md, n_slides_sm, n_slides_xs = get_visible_slides_fields(
    )

    TYPE_CHOICES = (
        ('carousel', 'Carousel'),
        ('slider', 'Slider'),
    )
    type = forms.ChoiceField(
        label=_('Slider type'),
        initial='carousel',
        choices=TYPE_CHOICES,
        help_text=_(
            'slider: rewinds slider to the start/end, carousel: circles.'),
    )

    gap = forms.IntegerField(
        label=_('Gap'),
        initial=10,
        help_text=_('Gap (px - default: 10) between slides.'))

    autoplay = forms.IntegerField(
        label=_('Autoplay'),
        initial=0,
        required=False,
        help_text=
        _('Duration (msec - default: 0) for infinite autoplay of slides (0 -> No autoplay.'
          ),
    )

    animation_duration = forms.IntegerField(
        label=_('Animation Duration'),
        initial=400,
        required=False,
        help_text=
        _('Animation duration (msec - default: 400) - time between start and end of a slide change.'
          ),
    )

    TIMING_FUNC_CHOICES = (
        ('cubic-bezier(0.165, 0.840, 0.440, 1.000)', 'Default'),
        ('linear', 'Linear'),
        ('ease', 'Ease'),
        ('ease-in', 'Ease In'),
        ('ease-out', 'Ease Out'),
        ('ease-in-out', 'Ease In/Out'),
        ('Bounce', 'Bounce'),
    )
    animation_timing_func = forms.ChoiceField(
        label=_('Animation Timing'),
        initial='cubic-bezier(0.165, 0.840, 0.440, 1.000)',
        choices=TIMING_FUNC_CHOICES,
        help_text=_('Animation timing, e.g.: Start: quick - end: slow.'),
    )

    hoverpause = forms.BooleanField(
        label=_('Hoverpause'),
        initial=True,
        required=False,
        help_text=_('Stop autoplay on mouse over.'),
    )

    peek = forms.IntegerField(
        label=_('Peek'),
        initial=0,
        help_text=_('Preview width (px) of next and previous hided slides.'),
    )

    STYLE_CHOICES = 'SLIDER_STYLES'
    extra_style, extra_classes, label, extra_css = get_style_form_fields(
        STYLE_CHOICES)