Пример #1
0
class SlickSettingsExtender(object):
    adapts(IListingBlock)
    implements(IOrderableSchemaExtender)

    fields = [
        SlickSettingsField(
            'slick_settings',
            searchable=False,
            default=u'{"autoplay": true, "autoplaySpeed": 3000}',
            validators=('isValidSlickSettings', ),
            required=True,
            widget=StringWidget(
                label=_(u'label_slicksettings',
                        default=u'Settings for diashow'),
                description=_(
                    u'help_slicksettings',
                    default=u'Be careful changing. This is the configuration '
                    'for the diashow javascript. Available options: '
                    '<a href="https://github.com/kenwheeler/slick/#options">'
                    'github.com/kenwheeler/slick/#options</a> <br />If all '
                    'goes wrong, use the default: {"autoplay": true, '
                    '"autoplaySpeed": 3000}'),
            ),
        ),
    ]

    def __init__(self, context):
        self.context = context

    def getFields(self):
        return self.fields

    def getOrder(self, original):
        return original
Пример #2
0
class IContainerSchema(Schema):
    slick_config = schema.Text(
        title=_(u'slick_config_label', default=u'Configuration'),
        description=_(u'slick_config_description',
                      default=u'See http://kenwheeler.github.io/slick/'),
        required=False,
        default=u'''
            {"autoplay": true,
             "autoplaySpeed": 5000,
             "fade": true,
             "speed": 1500,
             "infinite": true}
        ''',
        constraint=validate_slick_config,
    )
Пример #3
0
class IPaneSchema(Schema):
    text = RichText(
        title=_(u'label_text', default=u'Text'),
        description=_(u'help_text', default=u''),
        required=False,
    )
    image = NamedImage(
        title=_(u'label_image', default='Image'),
        required=True,
    )
    form.widget(link=ContentTreeFieldWidget)
    link = schema.Choice(title=_(u'label_link', default=u'Link'),
                         description=_(u'help_link', default=u''),
                         required=False,
                         source=PathSourceBinder())
Пример #4
0
    def extend_translations(self, config):
        labels = {
            'play': _(u'label_slider_play', default=u'Play'),
            'pause': _(u'label_slider_pause', default=u'Pause'),
            'next': _(u'label_slider_next', default=u'Next'),
            'prev': _(u'label_slider_prev', default=u'Previous'),
        }

        user_config = config.get('labels', {})

        for label, message in labels.iteritems():
            if label not in user_config:
                user_config[label] = translate(message, context=self.request)

        config['labels'] = user_config

        return config
Пример #5
0
    def extend_translations(self, config):
        labels = {
            'play': _(u'label_slider_play', default=u'Play'),
            'pause': _(u'label_slider_pause', default=u'Pause'),
            'next': _(u'label_slider_next', default=u'Next'),
            'prev': _(u'label_slider_prev', default=u'Previous'),
        }

        user_config = config.get('labels', {})

        for label, message in labels.iteritems():
            if label not in user_config:
                user_config[label] = translate(message, context=self.request)

        config['labels'] = user_config

        return config
Пример #6
0
class IPaneSchema(Schema):

    title = schema.TextLine(
        title=_PMF(u'label_title', default=u'Title'),
        required=True
        )

    show_title = schema.Bool(
        title=_(u'label_show_title', default=u'Show title'),
        required=False,
        default=False,
        missing_value=False,
    )

    text = RichText(
        title=_(u'label_text', default=u'Text'),
        description=_(u'help_text', default=u''),
        required=False,
        )

    model.primary('image')
    image = NamedImage(
        title=_(u'label_image', default='Image'),
        required=True,
        )

    image_alt_text = schema.TextLine(
        title=_(u'label_image_alt_text', default=u'Image alt text'),
        required=False
        )

    form.widget(link=ReferenceWidgetFactory)
    link = schema.TextLine(
        title=_(u'label_link', default=u'Link'),
        description=_(u'help_link', default=u''),
        required=False,
        )

    external_url = schema.URI(
        title=_(u'label_external_url', default=u'External URL'),
        required=False,
    )

    @invariant
    def validate_links(data):
        """
        It is not allowed to add a link and an external url at the same time.
        """
        if data.link and data.external_url:
            raise Invalid(_(
                u'error_message_links',
                default=u'It\'s not possible to add a link and an '
                        u'external url at the same time')
            )
Пример #7
0
 def validate_links(data):
     """
     It is not allowed to add a link and an external url at the same time.
     """
     if data.link and data.external_url:
         raise Invalid(_(
             u'error_message_links',
             default=u'It\'s not possible to add a link and an '
                     u'external url at the same time')
         )
Пример #8
0
    def render(self):
        sliders = self.context.getFolderContents(
            contentFilter={'portal_type': 'ftw.slider.Container'})

        if len(sliders) > 0:
            IStatusMessage(self.request).add(
                _(u'There is already a slider pane in this context'),
                type='info')
            return self.request.response.redirect(sliders[0].getURL())
        return super(ContainerAddForm, self).render()
Пример #9
0
    def render(self):
        sliders = self.context.getFolderContents(
            contentFilter={'portal_type': 'ftw.slider.Container'})

        if len(sliders) > 0:
            IStatusMessage(self.request).add(
                _(u'There is already a slider pane in this context'),
                type='info')
            return self.request.response.redirect(sliders[0].getURL())
        return super(ContainerAddForm, self).render()