diff --git a/Gruntfile.js b/Gruntfile.js index 8731c43..810148d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -27,12 +27,18 @@ module.exports = function(grunt) { // Concatenates the javascript source files to the javascripts folder. concat: { - build: { - src: [ - 'sources/javascripts/concat/*.js' - ], - dest: 'javascripts/application.js' - } + global: { + src: [ + 'sources/javascripts/concat/global/*.js' + ], + dest: 'javascripts/application.js' + }, + editmode: { + src: [ + 'sources/javascripts/concat/editmode/*.js' + ], + dest: 'javascripts/editmode.js' + }, }, // Minifies the javascript files. @@ -228,8 +234,8 @@ module.exports = function(grunt) { }, js_concat: { - files: 'sources/javascripts/concat/*.js', - tasks: ['concat:build', 'uglify:build', 'exec:kitmanifest', 'exec:kit:javascripts/*.js'] + files: 'sources/javascripts/concat/**/*.js', + tasks: ['concat', 'uglify:build', 'exec:kitmanifest', 'exec:kit:javascripts/*.js'] }, css_main: { @@ -276,7 +282,7 @@ module.exports = function(grunt) { require('load-grunt-tasks')(grunt); - grunt.registerTask('default', ['clean:reset', 'modernizr_builder', 'concat', 'uglify', 'sass', 'postcss:main_styles', 'cssmin', 'imagemin', 'postcss:custom_styles', 'copy', 'clean:remove']); + grunt.registerTask('default', ['clean:reset', 'modernizr_builder', 'concat', 'copy:javascripts', 'uglify', 'sass', 'postcss:main_styles', 'cssmin', 'imagemin', 'postcss:custom_styles', 'copy', 'clean:remove']); grunt.event.on('watch', function(action, filepath, target) { if (target == 'voog') { diff --git a/assets/ico-delete.svg b/assets/ico-delete.svg new file mode 100644 index 0000000..84770d3 --- /dev/null +++ b/assets/ico-delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/ico-expand.svg b/assets/ico-expand.svg new file mode 100644 index 0000000..55116b8 --- /dev/null +++ b/assets/ico-expand.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/ico-placeholder.svg b/assets/ico-placeholder.svg new file mode 100644 index 0000000..3b00a17 --- /dev/null +++ b/assets/ico-placeholder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/ico-settings.svg b/assets/ico-settings.svg new file mode 100644 index 0000000..eb0c5de --- /dev/null +++ b/assets/ico-settings.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/components/content-item.tpl b/components/content-item.tpl new file mode 100644 index 0000000..3c64895 --- /dev/null +++ b/components/content-item.tpl @@ -0,0 +1,72 @@ +{% if _imageData == blank %} + {% assign item_image_state = "without-image" %} +{% else %} + {% assign item_image_state = "with-image" %} +{% endif %} + +{% if _entityData.data.image_crop_state %} + {% assign image_crop_state = _entityData.data.image_crop_state %} +{% else %} + {% assign image_crop_state = "not-cropped" %} +{% endif %} + +{% if editmode %} +
+ + + {% include "image-src-variable", _data: _imageData, _targetWidth: _targetWidth %} + +
+
+
+
+{% else %} + +
+
+ {% if _imageData != blank %} +
+ {%- assign imageClass = "item-image " | append: image_crop_state -%} + {% include "lazy-image", _altAttr: _entityData.data.image_alt_attr, _data: _imageData, _targetWidth: _targetWidth, _className: imageClass %} + {% else %} +
+ {% endif %} +
+
+
+{% endif %} diff --git a/components/edicy-tools-variables.tpl b/components/edicy-tools-variables.tpl index 0591910..1ff3f4f 100644 --- a/components/edicy-tools-variables.tpl +++ b/components/edicy-tools-variables.tpl @@ -7,6 +7,13 @@ {% assign flags_state = site.data.flags_state %} {% endif %} + {%- comment -%}Assign variables for ecommerce layouts{%- endcomment -%} + {% assign product_list_layout = "Product list" %} + {% assign product_layout = "Product" %} + + {%- comment -%}Sets product related pages in main menu{%- endcomment -%} + {% assign show_product_related_pages_in_main_menu = site.data.settings_root_item.show_product_related_pages_in_main_menu %} + {% comment %}Assign variables based on page type.{% endcomment %} {% assign fallback_cover_image = page.data.cover_image %} {% assign fallback_cover_color = page.data.cover_color %} @@ -267,4 +274,29 @@ {% capture edy_intro_add_lang %}{% if editmode %}data-edy-intro-popover="edy-add-lang"{% endif %}{% endcapture %} {% capture edy_intro_edit_text %}{% if editmode %}data-edy-intro-popover="edy-edit-text"{% endif %}{% endcapture %} + {% capture base_number_of_columns_set %} + [ + { + "title": "2", + "value": "50%" + }, + { + "title": "3", + "value": "33.3%" + }, + { + "title": "4", + "value": "25%" + }, + { + "title": "5", + "value": "20%" + }, + { + "title": "6", + "value": "16.6%" + } + ] + {% endcapture %} + {% endcapture %} diff --git a/components/edicy-tools.tpl b/components/edicy-tools.tpl index 99c149e..29ad753 100644 --- a/components/edicy-tools.tpl +++ b/components/edicy-tools.tpl @@ -30,5 +30,23 @@ }); site.bindCustomTexteditorStyles('{{ "button" | lc: editor_locale }}'); + + {%- if page.layout_title == product_layout -%} + {%- assign dropAreaPlaceholder = "drag_picture_for_product_here" | lce | escape -%} + site.bindProductListeners("{{ dropAreaPlaceholder }}", {{ page.id }}); + {%- else -%} + {%- assign dropAreaPlaceholder = "drag_picture_here" | lce | escape -%} + + {% if site.data.settings_root_item %} + rootItemValuesObj = {{ site.data.settings_root_item | json }}; + {% else %} + rootItemValuesObj = {}; + {% endif %} + + template.bindRootItemSettings(rootItemValuesObj); + {%- endif -%} + + site.bindContentItemImgDropAreas('{{ dropAreaPlaceholder }}', "item_image", "image_crop_state"); + site.bindContentItemImageCropToggle("image_crop_state"); {% endeditorjsblock %} diff --git a/components/html-head.tpl b/components/html-head.tpl index fc1e9bb..20aaf2a 100644 --- a/components/html-head.tpl +++ b/components/html-head.tpl @@ -42,11 +42,13 @@ {% include "template-cs-content-content" %} {% include "template-cs-button-content" %} {% include "template-cs-table-content" %} + {%- if page.layout_title == product_list_layout -%} + {% include "template-cs-product-list" %} + {%- endif -%} {% include "template-cs-form-content" %} {% include "template-cs-footer-content" %} {% endif %} - {% include "template-cs-style-rules" %} {% endcustomstyle %} @@ -60,7 +62,11 @@ {% include "template-meta" %} {% comment %}BREADCRUMBS{% endcomment %} -{% sd_breadcrumbs %} +{%- capture breadcrumbsScript -%} + {%- sd_breadcrumbs -%} +{%- endcapture -%} + +{{ breadcrumbsScript }} {% if blog %}{{ blog.rss_link }}{% endif %} {{ site.stats_header }} diff --git a/components/image-src-variable.tpl b/components/image-src-variable.tpl new file mode 100644 index 0000000..6fc69dd --- /dev/null +++ b/components/image-src-variable.tpl @@ -0,0 +1,18 @@ +{%- if _data.content_type != blank -%} + {%- assign imageSizes = "sizes" -%} + {%- assign urlKey = "schemeless_url" -%} +{%- else -%} + {%- assign imageSizes = "imageSizes" -%} + {%- assign urlKey = "url" -%} +{%- endif -%} + +{%- assign _src = _data[imageSizes].first[urlKey] -%} + +{%- assign _maxWidth = _targetWidth | to_num -%} + +{%- for image in _data[imageSizes] -%} + {%- if image.width <= _maxWidth -%} + {% break %} + {%- endif -%} + {%- assign _src = image[urlKey] -%} +{%- endfor -%} diff --git a/components/javascripts.tpl b/components/javascripts.tpl index 1245af4..8977a26 100644 --- a/components/javascripts.tpl +++ b/components/javascripts.tpl @@ -1,8 +1,15 @@ {% comment %}SITE WIDE JAVASCRIPTS{% endcomment %} - + + + + {% sitejs_include %} +{%- if editmode -%} + +{%- endif -%} + {% comment %}Site search related javascript components.{% endcomment %} {% if site.search.enabled %} diff --git a/components/lazy-image.tpl b/components/lazy-image.tpl new file mode 100644 index 0000000..4242b21 --- /dev/null +++ b/components/lazy-image.tpl @@ -0,0 +1,30 @@ +{%- comment -%} + Product image & background picker image object have different keys +{%- endcomment -%} + +{%- if _targetWidth != blank -%} + {%- assign _maxWidth = _targetWidth | to_num -%} + {%- assign sizes = "(min-width: " | append: _targetWidth | append: "px) " | append: _targetWidth | append: "px" -%} +{%- else -%} + {%- assign _maxWidth = _data.width -%} + {%- assign sizes = "100vw" -%} +{%- endif -%} + +{% include "image-src-variable", _data: _data, _targetWidth: _maxWidth %} + +{{ _altAttr  | escape_once }}= 1 %} + data-srcset=" + {%- for image in _data[imageSizes] -%} + {{ image[urlKey] }} {{ image.width }}w + {%- unless forloop.last -%} + , + {%- endunless -%} + {%- endfor -%} + " + {%- endif -%} + {%- endif -%} +/> diff --git a/components/menu-breadcrumbs.tpl b/components/menu-breadcrumbs.tpl new file mode 100644 index 0000000..4f547ab --- /dev/null +++ b/components/menu-breadcrumbs.tpl @@ -0,0 +1,42 @@ +{%- assign breadcrumbsString = breadcrumbsScript | replace: '", "" | replace: site.url, "" | replace: "@", "" -%} +{%- assign breadcrumbsObj = breadcrumbsString | json_parse -%} + + diff --git a/components/menu-level-1-link.tpl b/components/menu-level-1-link.tpl new file mode 100644 index 0000000..4680a1b --- /dev/null +++ b/components/menu-level-1-link.tpl @@ -0,0 +1,3 @@ + diff --git a/components/menu-level-1.tpl b/components/menu-level-1.tpl index d2c98b5..55a4102 100644 --- a/components/menu-level-1.tpl +++ b/components/menu-level-1.tpl @@ -6,9 +6,21 @@ {% endunless %} {% for item in site.visible_menuitems %} - + {% if site.root_item.layout_title == product_list_layout %} + {% if editmode %} + {% include "menu-level-1-link" render_hidden_categories: true %} + {% else %} + {% unless show_product_related_pages_in_main_menu %} + {% unless item.layout_title == product_list_layout or item.layout_title == product_layout %} + {% include "menu-level-1-link" %} + {% endunless %} + {% else %} + {% include "menu-level-1-link" %} + {% endunless %} + {% endif %} + {% else %} + {% include "menu-level-1-link" %} + {% endif %} {% endfor %} {% if editmode %} diff --git a/components/menu-level-2.tpl b/components/menu-level-2.tpl index 1f97e2b..5df0488 100644 --- a/components/menu-level-2.tpl +++ b/components/menu-level-2.tpl @@ -6,7 +6,9 @@