diff --git a/bin/Controls/Slider/PromosliderSettings.js b/bin/Controls/Slider/PromosliderSettings.js index 6db67a10b66ae3206837c89ac30f32a4c0685777..93091e76074b9613ae8a1e3dbfe086bd3cf88072 100644 --- a/bin/Controls/Slider/PromosliderSettings.js +++ b/bin/Controls/Slider/PromosliderSettings.js @@ -2,6 +2,8 @@ * @module package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettings * @author www.pcsg.de (Henning Leutz) * + * Inhaltseinstellung für Promoslider + * * @require qui/QUI * @require qui/controls/Control * @require qui/controls/windows/Confirm diff --git a/bin/Controls/Slider/PromosliderSettingsOnlyContent.js b/bin/Controls/Slider/PromosliderSettingsOnlyContent.js new file mode 100644 index 0000000000000000000000000000000000000000..3df4a95864f0b63c69d3767062b73f69cf671964 --- /dev/null +++ b/bin/Controls/Slider/PromosliderSettingsOnlyContent.js @@ -0,0 +1,567 @@ +/** + * + */ +define('package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettingsOnlyContent', [ + + 'qui/QUI', + 'qui/controls/Control', + 'qui/controls/windows/Confirm', + 'qui/controls/buttons/Button', + 'Locale', + 'Mustache', + 'controls/grid/Grid', + 'utils/Controls', + + 'text!package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettingsOnlyContentEntry.html', + 'css!package/quiqqer/bricks/bin/Controls/Slider/PromoSliderSettings.css' + +], function (QUI, QUIControl, QUIConfirm, QUIButton, QUILocale, + Mustache, Grid, ControlsUtils, templateEntry) { + "use strict"; + + var lg = 'quiqqer/bricks'; + + return new Class({ + + Extends: QUIControl, + Type : 'package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettings', + + Binds: [ + '$onImport', + '$openAddDialog', + '$openDeleteDialog', + '$openEditDialog' + ], + + initialize: function (options) { + this.parent(options); + + this.$Input = null; + this.$Grid = null; + + this.$data = []; + + this.addEvents({ + onImport: this.$onImport + }); + }, + + /** + * event: on import + */ + $onImport: function () { + this.$Input = this.getElm(); + + this.$Elm = new Element('div', { + 'class': 'quiqqer-bricks-promoslider-settings', + styles : { + clear : 'both', + 'float' : 'left', + height : 400, + overflow: 'hidden', + position: 'relative', + margin : '10px 0 0 0', + width : '100%' + } + }).wraps(this.$Input); + + // exist label? + var id = this.$Input.get('id'), + Label = document.getElement('label[for="' + id + '"]'); + + if (Label) { + var Cell = Label.getParent('td'), + OldCell = this.$Elm.getParent('td'); + + Cell.set('colspan', 2); + + this.$Elm.inject(Cell); + OldCell.destroy(); + } + + // grid and sizes + var size = this.$Elm.getSize(); + + var Desktop = new Element('div', { + styles: { + width: size.x + } + }).inject(this.$Elm); + + this.$Grid = new Grid(Desktop, { + height : 400, + width : size.x, + buttons : [{ + name : 'up', + icon : 'fa fa-angle-up', + disabled: true, + events : { + onClick: function () { + this.$Grid.moveup(); + this.$refreshSorting(); + }.bind(this) + } + }, { + name : 'down', + icon : 'fa fa-angle-down', + disabled: true, + events : { + onClick: function () { + this.$Grid.movedown(); + this.$refreshSorting(); + }.bind(this) + } + }, { + type: 'seperator' + }, { + name : 'add', + textimage: 'fa fa-plus', + text : QUILocale.get('quiqqer/system', 'add'), + events : { + onClick: this.$openAddDialog + } + }, { + type: 'seperator' + }, { + name : 'edit', + textimage: 'fa fa-edit', + text : QUILocale.get('quiqqer/system', 'edit'), + disabled : true, + events : { + onClick: this.$openEditDialog + } + }, { + name : 'delete', + textimage: 'fa fa-trash', + text : QUILocale.get('quiqqer/system', 'delete'), + disabled : true, + events : { + onClick: this.$openDeleteDialog + } + }], + columnModel: [{ + header : QUILocale.get('quiqqer/system', 'image'), + dataIndex: 'imagePreview', + dataType : 'node', + width : 60 + }, { + header : QUILocale.get(lg, 'quiqqer.products.control.promoslider.left'), + dataIndex: 'left', + dataType : 'code', + width : 300 + }, { + header : QUILocale.get(lg, 'quiqqer.products.control.promoslider.right'), + dataIndex: 'right', + dataType : 'code', + width : 300 + }, { + dataIndex: 'image', + dataType : 'string', + hidden : true + }] + }); + + this.$Grid.addEvents({ + onClick: function () { + var buttons = this.$Grid.getButtons(), + + Edit = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'edit'; + })[0], + + Up = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'up'; + })[0], + + Down = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'down'; + })[0], + + Delete = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'delete'; + })[0]; + + Up.enable(); + Down.enable(); + Edit.enable(); + Delete.enable(); + }.bind(this), + + onDblClick: this.$openEditDialog + }); + + this.$Grid.getElm().setStyles({ + position: 'absolute' + }); + + + try { + this.$data = JSON.decode(this.$Input.value); + + if (typeOf(this.$data) != 'array') { + this.$data = []; + } + + this.refresh(); + } catch (e) { + } + }, + + + /** + * Resize the control + * + * @return {Promise} + */ + resize: function () { + var size = this.getElm().getSize(); + + return this.$Grid.setWidth(size.x).then(function () { + this.$Grid.resize(); + }.bind(this)); + }, + + /** + * refresh the display + */ + refresh: function () { + var i, len, entry, insert; + var data = []; + + for (i = 0, len = this.$data.length; i < len; i++) { + entry = this.$data[i]; + insert = { + image : '', + imagePreview: new Element('span', {html: ' '}) + }; + + if ("image" in entry) { + insert.image = entry.image; + + insert.imagePreview = new Element('img', { + src: URL_DIR + insert.image + '&maxwidth=50&maxheight=50' + }); + } + + if ("left" in entry) { + insert.left = entry.left; + } + + if ("right" in entry) { + insert.right = entry.right; + } + + data.push(insert); + } + + this.$Grid.setData({ + data: data + }); + + var buttons = this.$Grid.getButtons(), + + Edit = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'edit'; + })[0], + + Up = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'up'; + })[0], + + Down = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'down'; + })[0], + + Delete = buttons.filter(function (Btn) { + return Btn.getAttribute('name') == 'delete'; + })[0]; + + Up.disable(); + Down.disable(); + Edit.disable(); + Delete.disable(); + }, + + /** + * Update the field + */ + update: function () { + this.$Input.value = JSON.encode(this.$data); + }, + + /** + * Add an entry + * + * @param {string} [left] - left content + * @param {string} [right] - right content + */ + add: function (left, right, image) { + this.$data.push({ + left : left || '', + right: right || '', + image: image || '' + }); + + this.refresh(); + this.update(); + }, + + /** + * Edit an entry + * + * @param {number} index + * @param {string} [left] - left content + * @param {string} [right] - right content + * @param {string} [image] - image path + */ + edit: function (index, left, right, image) { + if (typeof index === 'undefined') { + return; + } + + this.$data[index] = { + left : left || '', + right: right || '', + image: image || '' + }; + + this.refresh(); + this.update(); + }, + + /** + * Delete one entry or multiple entries + * + * @param {number|array} index + */ + del: function (index) { + var newList = []; + + if (typeOf(index) != 'array') { + index = [index]; + } + + for (var i = 0, len = this.$data.length; i < len; i++) { + if (!index.contains(i)) { + newList.push(this.$data[i]); + } + } + + this.$data = newList; + }, + + /** + * Set the used project + * + * @param {string|object} Project + */ + setProject: function (Project) { + this.setAttribute('project', Project); + + var controls = QUI.Controls.getControlsInElement(this.getElm()); + + controls.each(function (Control) { + if (Control == this) { + return; + } + + if ("setProject" in Control) { + Control.setProject(Project); + } + }.bind(this)); + }, + + /** + * Open edit dialog + * + * @retrun {Promise} + */ + $openEditDialog: function () { + var data = this.$Grid.getSelectedData(); + var index = this.$Grid.getSelectedIndices(); + + if (!data.length) { + return; + } + + data = data[0]; + index = index[0]; + + return this.$createDialog().then(function (Container) { + var CloseButton = Container.getElement( + '.quiqqer-bricks-promoslider-settings-entry-buttons button' + ); + + var Button = QUI.Controls.getById(CloseButton.get('data-quiid')); + var Form = Container.getElement('form'); + + var Left = Form.elements.left; + var Right = Form.elements.right; + var Image = Form.elements.image; + + Button.addEvent('click', function () { + this.edit(index, Left.value, Right.value, Image.value); + + moofx(Container).animate({ + opacity: 0, + top : -30 + }, { + duration: 250, + callback: function () { + Container.destroy(); + } + }); + }.bind(this)); + + Left.value = data.left; + Right.value = data.right; + Image.value = data.image; + + Image.fireEvent('change'); + }.bind(this)); + }, + + /** + * opens the delete dialog + * + * @return {Promise} + */ + $openDeleteDialog: function () { + new QUIConfirm({ + icon : 'fa fa-icon', + title : QUILocale.get(lg, 'quiqqer.products.control.delete.title'), + text : QUILocale.get(lg, 'quiqqer.products.control.delete.text'), + information: QUILocale.get(lg, 'quiqqer.products.control.delete.information'), + texticon : false, + maxWidth : 600, + maxHeight : 400, + ok_button : { + text : QUILocale.get('quiqqer/system', 'delete'), + textimage: 'fa fa-trash' + }, + events : { + onSubmit: function () { + var selected = this.$Grid.getSelectedIndices(); + + this.$Grid.deleteRows(selected); + this.del(selected); + this.update(); + }.bind(this) + } + }).open(); + }, + + /** + * + * @returns {Promise} + */ + $openAddDialog: function () { + return this.$createDialog().then(function (Container) { + var CloseButton = Container.getElement( + '.quiqqer-bricks-promoslider-settings-entry-buttons button' + ); + + var Button = QUI.Controls.getById(CloseButton.get('data-quiid')); + + Button.addEvent('click', function () { + var Form = Container.getElement('form'); + + var Left = Form.elements.left; + var Right = Form.elements.right; + var Image = Form.elements.image; + + this.add(Left.value, Right.value, Image.value); + + moofx(Container).animate({ + opacity: 0, + top : -30 + }, { + duration: 250, + callback: function () { + Container.destroy(); + } + }); + }.bind(this)); + }.bind(this)); + }, + + /** + * Create a edit / add entry dialog + * + * @return {Promise} + */ + $createDialog: function () { + return new Promise(function (resolve) { + var Container = new Element('div', { + html : Mustache.render(templateEntry, { + fieldLeft : QUILocale.get(lg, 'quiqqer.products.control.promoslider.left'), + fieldRight: QUILocale.get(lg, 'quiqqer.products.control.promoslider.right') + }), + 'class': 'quiqqer-bricks-promoslider-settings-entry' + }).inject(this.getElm()); + + var Close = Container.getElement( + '.quiqqer-bricks-promoslider-settings-entry-close' + ); + + var Buttons = Container.getElement( + '.quiqqer-bricks-promoslider-settings-entry-buttons' + ); + + var Text = Container.getElement('.field-description'); + + Text.getParent().setStyles({ + height: 100 + }); + + Close.addEvent('click', function () { + moofx(Container).animate({ + opacity: 0, + top : -30 + }, { + duration: 250, + callback: function () { + Container.destroy(); + } + }); + }); + + new QUIButton({ + text : QUILocale.get('quiqqer/system', 'accept'), + styles: { + 'float': 'none' + } + }).inject(Buttons); + + + QUI.parse(Container).then(function () { + return ControlsUtils.parse(Container); + }).then(function () { + + var controls = QUI.Controls.getControlsInElement(Container), + project = this.getAttribute('project'); + + controls.each(function (Control) { + if (Control == this) { + return; + } + + if ("setProject" in Control) { + Control.setProject(project); + } + }.bind(this)); + + moofx(Container).animate({ + opacity: 1, + top : 0 + }, { + duration: 250, + callback: function () { + resolve(Container); + } + }); + }.bind(this)); + }.bind(this)); + } + }); +}); \ No newline at end of file diff --git a/bin/Controls/Slider/PromosliderSettingsOnlyContentEntry.html b/bin/Controls/Slider/PromosliderSettingsOnlyContentEntry.html new file mode 100644 index 0000000000000000000000000000000000000000..42ddf7ca75542dea47f6089c3362103b08021372 --- /dev/null +++ b/bin/Controls/Slider/PromosliderSettingsOnlyContentEntry.html @@ -0,0 +1,38 @@ +<div class="quiqqer-bricks-promoslider-settings-entry-header"> + <div class="quiqqer-bricks-promoslider-settings-entry-close"> + <span class="fa fa-remove"></span> + </div> +</div> + +<form name="quiqqer-bricks-promoslider-settings-entry" + class="quiqqer-bricks-promoslider-settings-entry-form" +> + <label class="field-container"> + <span class="field-container-item"> + {{fieldImage}} + </span> + <span class="field-container-field"> + <input name="image" class="field-image media-image"/> + </span> + </label> + + <label class="field-container"> + <span class="field-container-item"> + {{fieldLeft}} + </span> + <input name="left" class="field-container-field field-description" + data-qui="controls/editors/Input" + /> + </label> + + <label class="field-container"> + <span class="field-container-item"> + {{fieldRight}} + </span> + <input name="right" class="field-container-field field-description" + data-qui="controls/editors/Input" + /> + </label> +</form> + +<div class="quiqqer-bricks-promoslider-settings-entry-buttons"></div> \ No newline at end of file diff --git a/bricks.xml b/bricks.xml index db6cc98e8d6796e5dc8be67ac2809c116c7b7ef2..d34bf040991779a2528f7a16e8ee126b958d0f8b 100644 --- a/bricks.xml +++ b/bricks.xml @@ -214,8 +214,8 @@ <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.mobileslides"/> </setting> </settings> - </brick> + <brick control="\QUI\Bricks\Controls\Slider\PromosliderWallpaper"> <title> <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper.title"/> @@ -310,7 +310,102 @@ <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.mobileslides"/> </setting> </settings> + </brick> + + <brick control="\QUI\Bricks\Controls\Slider\PromosliderWallpaper2Content"> + <title> + <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper2Content.title"/> + </title> + <description> + <locale group="quiqqer/bricks" var="brick.control.promosliderWallpaper2Content.description"/> + </description> + + <settings> + <setting name="pagefit" type="checkbox"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.pagefit"/> + </setting> + <setting name="pagefitcut" type="number"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.pagefitcut"/> + </setting> + <setting name="pagefitcutmobile" type="number"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.pagefitcutmobile"/> + </setting> + <setting name="autostart" type="checkbox"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.autostart"/> + </setting> + <setting name="delay" type="number"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.delay"/> + </setting> + <setting name="shownavigation" type="checkbox"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.shownavigation"/> + </setting> + + <setting type="select" name="position"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.image-wallpaper-position"/> + + <option value=""/> + <option value="top-left"> + <locale group="quiqqer/system" var="watermark.position.top.left"/> + </option> + <option value="top"> + <locale group="quiqqer/system" var="watermark.position.top"/> + </option> + <option value="top-right"> + <locale group="quiqqer/system" var="watermark.position.top.right"/> + </option> + <option value="left"> + <locale group="quiqqer/system" var="watermark.position.left"/> + </option> + <option value="center"> + <locale group="quiqqer/system" var="watermark.position.center"/> + </option> + <option value="right"> + <locale group="quiqqer/system" var="watermark.position.right"/> + </option> + <option value="bottom-left"> + <locale group="quiqqer/system" var="watermark.position.bottom.left"/> + </option> + <option value="bottom"> + <locale group="quiqqer/system" var="watermark.position.bottom"/> + </option> + <option value="bottom-right"> + <locale group="quiqqer/system" var="watermark.position.bottom.right"/> + </option> + </setting> + + <setting type="select" name="attachment"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.image-wallpaper-attachment"/> + + <option value=""/> + <option value="fixed"> + <locale group="quiqqer/bricks" + var="brick.control.promoslider.image-wallpaper-attachment.fixed"/> + </option> + </setting> + + <setting type="select" name="navigation-position"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.navigation-position"/> + <option value="outer"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.navigation-position-outer"/> + </option> + <option value="inner"> + <locale group="quiqqer/bricks" var="brick.control.promoslider.navigation-position-inner"/> + </option> + </setting> + + <setting name="desktopslides" type="hidden" + data-qui="package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettingsOnlyContent" + > + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.desktopslides"/> + </setting> + + <setting name="mobileslides" type="hidden" + data-qui="package/quiqqer/bricks/bin/Controls/Slider/PromosliderSettingsOnlyContent" + > + <locale group="quiqqer/bricks" var="brick.control.promoslider.settings.mobileslides"/> + </setting> + </settings> </brick> <!-- Children Listing Infnite --> diff --git a/locale.xml b/locale.xml index db6e75a12d992c3c1393a52c460319ca9e9ed16b..b2432941bf648518b4557a0fe51aa03b3b1cba59 100644 --- a/locale.xml +++ b/locale.xml @@ -294,6 +294,10 @@ <de><![CDATA[Bausteine: Promoslider Wallpaper]]></de> <en><![CDATA[Bricks: Promoslider Wallpaper]]></en> </locale> + <locale name="brick.control.promosliderWallpaper2Content.title"> + <de><![CDATA[Bausteine: Promoslider Wallpaper mit 2 Inhaltsbereichen]]></de> + <en><![CDATA[Bricks: Promoslider Wallpaper with two content areas]]></en> + </locale> <locale name="brick.control.promoslider.title"> <de><![CDATA[Bausteine: Promoslider]]></de> <en><![CDATA[Bricks: Promoslider]]></en> @@ -594,6 +598,15 @@ Möchten Sie die Bausteine aus der Bausteinzone entfernen?</p>]]></de> <en><![CDATA[Alignment]]></en> </locale> + <locale name="quiqqer.products.control.promoslider.left"> + <de><![CDATA[Linker Inhaltsbereich]]></de> + <en><![CDATA[Left content]]></en> + </locale> + <locale name="quiqqer.products.control.promoslider.right"> + <de><![CDATA[Rechter Inhaltsbereich]]></de> + <en><![CDATA[Right content]]></en> + </locale> + <locale name="quiqqer.products.control.delete.title"> <de><![CDATA[Slide wirklich löschen?]]></de> <en><![CDATA[Do you really want to remove this slide?]]></en> diff --git a/src/QUI/Bricks/Controls/Slider/AbstractPromoslider.php b/src/QUI/Bricks/Controls/Slider/AbstractPromoslider.php index 978bfc2d3eef2daf3089f6694eb4133a8b09783e..3ed757f09db8b87abf2d868cc7343684e078212c 100644 --- a/src/QUI/Bricks/Controls/Slider/AbstractPromoslider.php +++ b/src/QUI/Bricks/Controls/Slider/AbstractPromoslider.php @@ -127,6 +127,7 @@ public function addMobileSlide($image, $title, $text) } /** + * Parse slide params and add the slide * * @param mixed $slides * @param string $type diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.css b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.css index 18374668fb8fc3da74f23cc31237913a87791487..eca8f0594eafd0fbb99ebb4319d6499df1122c84 100644 --- a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.css +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.css @@ -9,7 +9,7 @@ .quiqqer-bricks-promoslider-wallpaper-container { left: 0; float: left; - height: calc(100% + 20px); + height: 100%; overflow: hidden; position: absolute; transform: translate3d(0, 0, 0); @@ -38,6 +38,7 @@ float: none; height: 100%; margin: 0 !important; + overflow: hidden; padding: 0 !important; position: relative; width: 100%; diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.html b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.html index ceb14d698ed6fe797eb9f5f638b139461b04b4f3..6472a1ea31550f516f8ae604278ee28bdc37dd23 100644 --- a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.html +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.html @@ -47,9 +47,12 @@ {/strip} </div> <div class="quiqqer-bricks-promoslider-wallpaper-dots"></div> + +{if count($desktopSlides) > 1} <div class="quiqqer-bricks-promoslider-wallpaper-prev hide-on-mobile"> <span class="fa fa-chevron-left"></span> </div> <div class="quiqqer-bricks-promoslider-wallpaper-next hide-on-mobile"> <span class="fa fa-chevron-right"></span> -</div> \ No newline at end of file +</div> +{/if} \ No newline at end of file diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.php b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.php index 067541ecc9bd97b13e54709326a27ba5e24f1703..25722559d2c99ada5581a19310974439f61b0645 100644 --- a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.php +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper.php @@ -34,7 +34,8 @@ public function __construct($attributes = array()) 'shownavigation' => false, 'attachment' => false, 'autostart' => false, - 'delay' => 5000 + 'delay' => 5000, + 'template' => dirname(__FILE__) . '/PromosliderWallpaper.html' )); $this->addCSSFile( @@ -198,6 +199,6 @@ public function getBody() 'Utils' => new Utils() )); - return $Engine->fetch(dirname(__FILE__) . '/PromosliderWallpaper.html'); + return $Engine->fetch($this->getAttribute('template')); } } diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css new file mode 100644 index 0000000000000000000000000000000000000000..77b0e2cb1402dca2de5f25eab86f1af9d43a5c06 --- /dev/null +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.css @@ -0,0 +1,16 @@ +/** text + ============================================= */ + +.quiqqer-bricks-promoslider-wallpaper2Content-left, +.quiqqer-bricks-promoslider-wallpaper2Content-right { + float: left; + padding: 20px 0; + width: 50%; +} + +@media screen and (max-width: 768px) { + .quiqqer-bricks-promoslider-wallpaper2Content-left, + .quiqqer-bricks-promoslider-wallpaper2Content-right { + width: 100%; + } +} diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html new file mode 100644 index 0000000000000000000000000000000000000000..5aa8cfb45aa59c724f0f65f06a1a9d30719ef975 --- /dev/null +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.html @@ -0,0 +1,43 @@ +<div class="quiqqer-bricks-promoslider-wallpaper-container"> + {strip} + <ul> + {foreach $desktopSlides as $key => $slide} + <li> + {assign var=extraStyle value=""} + {assign var=extraClass value=""} + + {if $key >= 1} + {assign var=extraStyle value="display: none;"} + {/if} + + <div class="quiqqer-bricks-promoslider-wallpaper-image" + style="{$extraStyle}background-image: url('{image image=$slide.image onlysrc=1 width=1900}')" + > </div> + + <div class="grid-container"> + <div class="quiqqer-bricks-promoslider-wallpaper2Content-left"> + {if isset($slide.left)} + {$slide.left} + {/if} + </div> + <div class="quiqqer-bricks-promoslider-wallpaper2Content-right"> + {if isset($slide.right)} + {$slide.right} + {/if} + </div> + </div> + </li> + {/foreach} + </ul> + {/strip} +</div> +<div class="quiqqer-bricks-promoslider-wallpaper-dots"></div> + +{if count($desktopSlides) > 1} +<div class="quiqqer-bricks-promoslider-wallpaper-prev hide-on-mobile"> + <span class="fa fa-chevron-left"></span> +</div> +<div class="quiqqer-bricks-promoslider-wallpaper-next hide-on-mobile"> + <span class="fa fa-chevron-right"></span> +</div> +{/if} \ No newline at end of file diff --git a/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.php b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.php new file mode 100644 index 0000000000000000000000000000000000000000..86f69550cbfcd62be7ca2e65ecb97b6506ee9e8c --- /dev/null +++ b/src/QUI/Bricks/Controls/Slider/PromosliderWallpaper2Content.php @@ -0,0 +1,159 @@ +<?php + +/** + * This file contains QUI\Bricks\Controls\Slider\PromosliderWallpaper2Content + */ + +namespace QUI\Bricks\Controls\Slider; + +use QUI; +use QUI\Projects\Media\Utils; + +/** + * Class PromosliderWallpaper2Content + * + * @package QUI\Bricks\Controls + */ +class PromosliderWallpaper2Content extends PromosliderWallpaper +{ + /** + * constructor + * + * @param array $attributes + */ + public function __construct($attributes = array()) + { + parent::__construct($attributes); + + // default options + $this->setAttributes(array( + 'title' => '', + 'text' => '', + 'class' => 'quiqqer-bricks-promoslider-wallpaper2Content', + 'nodeName' => 'section', + 'data-qui' => 'package/quiqqer/bricks/bin/Controls/Slider/PromosliderWallpaper', + 'role' => 'listbox', + 'shownavigation' => false, + 'attachment' => false, + 'autostart' => false, + 'delay' => 5000, + 'template' => dirname(__FILE__) . '/PromosliderWallpaper2Content.html' + )); + + $this->addCSSFile(dirname(__FILE__) . '/PromosliderWallpaper2Content.css'); + + $this->addCSSClass('grid-100'); + $this->addCSSClass('mobile-grid-100'); + $this->addCSSClass('quiqqer-bricks-promoslider-wallpaper'); + } + + + /** + * Add a slide for the desktop view + * + * @param string $image - image.php URL to an image + * @param string $left - Left text + * @param string $right - Right text + * @param string|bool $type - not exists, but we are from PromosliderWallpaper and AbstractPromoslider + */ + public function addSlide($image, $left, $right, $type = false) + { + $this->desktopSlides[] = $this->checkSlideParams($image, $left, $right); + } + + /** + * Add a slide for the mobile view + * + * @param string $image - image.php URL to an image + * @param string $left - Left text + * @param string $right - Right text + */ + public function addMobileSlide($image, $left, $right) + { + $this->mobileSlides[] = $this->checkSlideParams($image, $left, $right); + } + + /** + * Add a slide for the mobile view + * + * @param string $image - image.php URL to an image + * @param string $left - Left text + * @param string $right - Right text + * @return array + */ + protected function checkSlideParams($image, $left = '', $right = '') + { + if (Utils::isMediaUrl($image)) { + try { + $Image = Utils::getMediaItemByUrl($image); + + if (Utils::isImage($Image)) { + $image = $Image; + } else { + $image = false; + } + } catch (QUI\Exception $Exception) { + QUI\System\Log::addDebug($Exception->getMessage()); + $image = false; + } + } else { + $image = false; + } + + return array( + 'image' => $image, + 'left' => $left, + 'right' => $right + ); + } + + /** + * Parse slide params and add the slide + * + * @param mixed $slides + * @param string $type + */ + protected function parseSlides($slides, $type = 'desktop') + { + if (empty($slides)) { + return; + } + + // desktop slides + if (is_string($slides)) { + $slides = json_decode($slides, true); + } + + if (!is_array($slides)) { + return; + } + + $attributes = array('image', 'left', 'right'); + + foreach ($slides as $slide) { + foreach ($attributes as $attribute) { + if (!isset($slide[$attribute])) { + $slide[$attribute] = false; + } + } + + switch ($type) { + case 'desktop': + $this->addSlide( + $slide['image'], + $slide['left'], + $slide['right'] + ); + break; + + case 'mobile': + $this->addMobileSlide( + $slide['image'], + $slide['left'], + $slide['right'] + ); + break; + } + } + } +}