diff --git a/datacenterlight/cms_models.py b/datacenterlight/cms_models.py index df54589e..214a2e90 100644 --- a/datacenterlight/cms_models.py +++ b/datacenterlight/cms_models.py @@ -200,3 +200,38 @@ class DCLSectionImagePluginModel(CMSPlugin): max_length=100, null=True, blank=True, help_text='Optional caption for the image.' ) + + +class DCLSectionPromoPluginModel(CMSPlugin): + background_image = FilerImageField( + on_delete=models.CASCADE, null=True, blank=True, + help_text=('Optional background image for the Promo Section'), + related_name="dcl_section_promo_promo", + ) + heading = models.CharField( + blank=True, null=True, max_length=100, + help_text='An optional heading for the Promo Section', + ) + subheading = models.CharField( + blank=True, null=True, max_length=200, + help_text='An optional subheading for the Promo Section', + ) + content = HTMLField() + html_id = models.SlugField( + blank=True, null=True, + help_text=( + 'An optional html id for the Section. Required to set as target ' + 'of a link on page' + ) + ) + plain_heading = models.BooleanField( + default=False, + help_text='Select to keep the heading style simpler.' + ) + center_on_mobile = models.BooleanField( + default=False, + help_text='Select to center align content on small screens.' + ) + + def __str__(self): + return '#' + self.html_id if self.html_id else str(self.pk) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 60992889..42e8719f 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -5,7 +5,8 @@ from .cms_models import ( DCLBannerItemPluginModel, DCLBannerListPluginModel, DCLContactPluginModel, DCLFooterPluginModel, DCLLinkPluginModel, DCLNavbarDropdownPluginModel, DCLSectionIconPluginModel, DCLSectionImagePluginModel, - DCLSectionPluginModel, DCLNavbarPluginModel + DCLSectionPluginModel, DCLNavbarPluginModel, + DCLSectionPromoPluginModel ) from .models import VMTemplate @@ -18,7 +19,24 @@ class DCLSectionPlugin(CMSPluginBase): render_template = "datacenterlight/cms/section.html" cache = False allow_children = True - child_classes = ['DCLSectionIconPlugin', 'DCLSectionImagePlugin'] + child_classes = [ + 'DCLSectionIconPlugin', 'DCLSectionImagePlugin', + 'DCLSectionPromoPlugin', 'UngleichHTMLPlugin' + ] + + def render(self, context, instance, placeholder): + context = super(DCLSectionPlugin, self).render( + context, instance, placeholder + ) + context['children_to_right'] = [] + context['children_to_left'] = [] + if instance.child_plugin_instances is not None: + for child in instance.child_plugin_instances: + if child.__class__.__name__ == 'DCLSectionImagePluginModel': + context['children_to_right'].append(child) + else: + context['children_to_left'].append(child) + return context @plugin_pool.register_plugin @@ -41,6 +59,15 @@ class DCLSectionImagePlugin(CMSPluginBase): require_parent = True +@plugin_pool.register_plugin +class DCLSectionPromoPlugin(CMSPluginBase): + module = "Datacenterlight" + name = "DCL Section Promo Plugin" + model = DCLSectionPromoPluginModel + render_template = "datacenterlight/cms/section_promo.html" + cache = False + + @plugin_pool.register_plugin class DCLCalculatorPlugin(CMSPluginBase): module = "Datacenterlight" diff --git a/datacenterlight/static/datacenterlight/js/main.js b/datacenterlight/static/datacenterlight/js/main.js index 10412824..5e919045 100644 --- a/datacenterlight/static/datacenterlight/js/main.js +++ b/datacenterlight/static/datacenterlight/js/main.js @@ -107,10 +107,14 @@ var href = $(this).attr('href'); $('.navbar-collapse').removeClass('in'); $('.navbar-collapse').addClass('collapsing'); - if ($(href).length) { - $('html, body').animate({ - scrollTop: $(href).offset().top - 50 - }, 1000); + if (href[0] === "#") { + if ($(href).length) { + $('html, body').animate({ + scrollTop: $(href).offset().top - 50 + }, 1000); + } + } else if (href) { + window.location = href; } }); } diff --git a/datacenterlight/templates/datacenterlight/cms/calculator.html b/datacenterlight/templates/datacenterlight/cms/calculator.html index 5ea97e84..27d1f89c 100644 --- a/datacenterlight/templates/datacenterlight/cms/calculator.html +++ b/datacenterlight/templates/datacenterlight/cms/calculator.html @@ -1,21 +1,8 @@