Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
VvvebJs updates
givanz34b9ace11dc5
diff --git a/public/css/vvvebjs-editor-helpers.css b/public/css/vvvebjs-editor-helpers.cssindex cd5b06a..83e9b40 100755--- a/public/css/vvvebjs-editor-helpers.css+++ b/public/css/vvvebjs-editor-helpers.css@@ -56,6 +56,7 @@ body {/*Prevents iframe mouse events that prevents clicking on the component*/+[data-component-oembed] > iframe,[data-component-video] > iframe,[data-component-maps] > iframe,[data-component-twitter] > iframe,@@ -68,6 +69,12 @@ Prevents iframe mouse events that prevents clicking on the component[contenteditable="true"]:focus-visible {outline: none; }+.is-dragged {+ pointer-events: none;+ opacity: 0.15;+ position: relative;+}+.vvveb-hidden {display: none !important; }diff --git a/public/js/admin.js b/public/js/admin.jsindex 23a6066..72ffac7 100755--- a/public/js/admin.js+++ b/public/js/admin.js@@ -78,7 +78,7 @@ function displayToast(bg, title, message, id = "bottom-toast") {$("#" + id + " .toast").addClass("showing");delay(() => $("#" + id + " .toast").addClass("show").removeClass("showing"), 500);delay(() => $("#" + id + " .toast").removeClass("show"), 5000);*/- let toast = new bootstrap.Toast(document.getElementById(id));+ let toast = new bootstrap.Toast(document.getElementById(id), {animation:false});toast.show()}diff --git a/public/js/admin/revisions.js b/public/js/admin/revisions.jsindex 2fb20b7..043ab8d 100644--- a/public/js/admin/revisions.js+++ b/public/js/admin/revisions.js@@ -32,18 +32,6 @@ $(".revisions").on("click", ".btn-load", function (e) {return false;});-$(".revisions").on("click", ".btn-compare", function (e) {- let data = revision(this);- let item = $(this).parents("[data-v-revision]")-- revisionAction("revision", data, function (data, text) {- item.remove();- });-- //e.preventDefault();- return false;-});-$(".revisions").on("click", ".btn-delete", function (e) {let data = revision(this);let item = $(this).parents("[data-v-revision]")diff --git a/public/js/app.js b/public/js/app.jsindex 067f93b..1d857af 100755--- a/public/js/app.js+++ b/public/js/app.js@@ -144,7 +144,7 @@ VvvebTheme.Cart = {VvvebTheme.Wishlist = {- module: 'cart/wishlist',+ module: 'user/wishlist',component: 'wishlist',component_id: '0',@@ -157,16 +157,11 @@ VvvebTheme.Wishlist = {},callback: function(data) {- /*- let miniWishlist = $("[data-v-component-wishlist]");- if (miniWishlist.length) {- miniWishlist[0].outerHTML = data;- }*/},- add: function(productId, quantity, element, selector, callback = false) {+ add: function(productId, element, selector, callback = false) {if (!callback) callback = this.callback;- return this.ajax('add',{'product_id':productId, 'quantity':quantity}, element, selector, callback);+ return this.ajax('add',{'product_id':productId}, element, selector, callback);},update: function(productId, quantity, element, selector, callback = false) {@@ -181,6 +176,40 @@ VvvebTheme.Wishlist = {}+VvvebTheme.Compare = {++ module: 'cart/compare',+ component: 'compare',+ component_id: '0',++ ajax: function(action, parameters, element, selector, callback) {+ parameters['module'] = this.module;+ parameters['action'] = action;+ parameters['component'] = this.component;+ parameters['component_id'] = this.component_id;+ VvvebTheme.Ajax.call(parameters, element, selector, callback);+ },++ callback: function(data) {+ },++ add: function(productId, element, selector, callback = false) {+ if (!callback) callback = this.callback;+ return this.ajax('add',{'product_id':productId}, element, selector, callback);+ },++ update: function(productId, quantity, element, selector, callback = false) {+ if (!callback) callback = this.callback;+ return this.ajax('update',{'product_id':productId}, element, selector, callback);+ },++ remove: function(productId, element, selector, callback = false) {+ if (!callback) callback = this.callback;+ return this.ajax('remove', {'product_id':productId}, element, selector, callback);+ }++}+VvvebTheme.Comments = {module: 'content/post',@@ -269,6 +298,19 @@ function objectSerialize(serializeArray) {return returnObject;}++function elementProduct(element) {+ let product = $(element).parents("[data-v-product]");+ if (!product.length) {+ product = $(element).parents("[data-v-component-product]");+ }+ if (!product.length) {+ product = $(element).parents("[data-v-cart-product]");+ }++ return product;+}+VvvebTheme.Gui = {init: function() {@@ -298,13 +340,8 @@ VvvebTheme.Gui = {},addToCart : function (e) {- let product = $(this).parents("[data-v-product]");- if (!product.length) {- product = $(this).parents("[data-v-component-product]");- }- if (!product.length) {- product = $(this).parents("[data-v-cart-product]");- }++ let product = elementProduct(this);let img = $("img[data-v-product-image], img[data-v-product-image-src], img[data-v-product-image]", product);let name = $("[data-v-product-name]:first", product).text();@@ -375,7 +412,7 @@ VvvebTheme.Gui = {}}- VvvebTheme.Cart.remove(id, this, selector, function(data) {+ VvvebTheme.Cart.add(id, {}, this, '.mini-cart', function() {VvvebTheme.Alert.show('<img height=50 src="' + img + '">   <strong>' + name +'</strong> was removed from cart');product.remove();});@@ -384,10 +421,40 @@ VvvebTheme.Gui = {},addToWishlist : function (e) {+ let product = elementProduct(this);+ let id = this.dataset.product_id;+ let img = $("[data-v-product-image],[data-v-product-image], [data-v-cart-product-image]", product).attr("src");++ if (!id) {+ id = product[0].dataset.product_id;+ if (!id) {+ id = $('input[name="product_id"]', product).val();+ }+ }++ VvvebTheme.Wishlist.add(id, this, false, function(data) {+ VvvebTheme.Alert.show('<img height=50 src="' + img + '">   <strong>' + name +'</strong> was added to wishlist');+ });+return false;},addToCompare : function (e) {+ let product = elementProduct(this);+ let id = this.dataset.product_id;+ let img = $("[data-v-product-image],[data-v-product-image], [data-v-cart-product-image]", product).attr("src");++ if (!id) {+ id = product[0].dataset.product_id;+ if (!id) {+ id = $('input[name="product_id"]', product).val();+ }+ }++ VvvebTheme.Wishlist.add(id, this, false, function(data) {+ VvvebTheme.Alert.show('<img height=50 src="' + img + '">   <strong>' + name +'</strong> was added to compare');+ });+return false;},diff --git a/public/js/vvvebjs/builder.js b/public/js/vvvebjs/builder.jsindex 81cccc1..37cff68 100755--- a/public/js/vvvebjs/builder.js+++ b/public/js/vvvebjs/builder.js@@ -79,7 +79,7 @@ Vvveb.preservePropertySections = true;//icon = use component icon when dragging | html = use component html to create draggable elementVvveb.dragIcon = 'icon';//if empty the html of the component is used to view dropping in real time but for large elements it can jump around for this you can set a html placeholder with this option-Vvveb.dragElementStyle = "background:limegreen;;width:100%;height:3px;border:1px solid limegreen;box-shadow:0px 0px 2px 1px rgba(0,0,0,0.14);overflow:hidden;";+Vvveb.dragElementStyle = "background:limegreen;width:100%;height:3px;border:1px solid limegreen;box-shadow:0px 0px 2px 1px rgba(0,0,0,0.14);overflow:hidden;";Vvveb.dragHtml = '<div style="' + Vvveb.dragElementStyle + '"></div>';Vvveb.baseUrl = document.currentScript?document.currentScript.src.replace(/[^\/]*?\.js$/,''):'';@@ -791,6 +791,10 @@ Vvveb.Builder = {self.leftPanelWidth = $("#left-panel").width();self.adjustListsHeight();++ $(window).on("scroll resize", function(event) {+ self.adjustListsHeight();+ });},/* controls */@@ -978,14 +982,11 @@ Vvveb.Builder = {function adjust(elements) {elements.each(function (i,e) {e.style.height = "";- maxOffset = Math.max(maxOffset, e.getBoundingClientRect()["top"]);+ maxOffset = Math.max(0, e.getBoundingClientRect()["top"]);e.style.height = (wHeight - maxOffset) + "px";});- /*- elements.each(function (i,e) {- e.style.height = (wHeight - maxOffset) + "px";- });*/}+adjust(lists);adjust(properties);},@@ -1061,8 +1062,6 @@ Vvveb.Builder = {//addSectionBox.hide();}- self.adjustListsHeight();-});Vvveb.WysiwygEditor.init(window.FrameDocument);@@ -1173,6 +1172,8 @@ Vvveb.Builder = {{$(node).parent().before(node);}++ Vvveb.Builder.selectNode(node);newParent = node.parentNode;newNextSibling = node.nextSibling;@@ -1204,6 +1205,8 @@ Vvveb.Builder = {$(node).parent().after(node);}+ Vvveb.Builder.selectNode(node);+newParent = node.parentNode;newNextSibling = node.nextSibling;@@ -1295,9 +1298,9 @@ Vvveb.Builder = {self.highlightEl = target = $(event.target);var offset = target.offset();var height = target.outerHeight();- var halfHeight = Math.max(height / 2, 50);+ var halfHeight = Math.max(height / 2, 5);var width = target.outerWidth();- var halfWidth = Math.max(width / 2, 50);+ var halfWidth = Math.max(width / 2, 5);var prepend = true;var x = event.originalEvent.x;@@ -1373,16 +1376,41 @@ Vvveb.Builder = {if (self.isDragging){var parent = self.highlightEl;-+ let parentTagName = parent[0].tagName.toLowerCase();++ let noChildren = {+ input: true,+ textarea: true,+ img: true,+ svg: true,+ iframe: true,+ embed: true,+ col: true,+ area: true,+ hr: true,+ br: true,+ wbr: true+ };+try {- if ((offset.top < (y - halfHeight)) || (offset.left < (x - halfWidth)))+ if ((offset.top < (event.originalEvent.pageY - halfHeight)) || (offset.left < (x - halfWidth))){+ if (noChildren[parentTagName]) {+ self.dragElement.insertAfter(parent);+ } else {self.dragElement.appendTo(parent);+ }+prepend = true;} else{- prepend = false;+ if (noChildren[parentTagName]) {+ self.dragElement.insertBefore(parent);+ } else {self.dragElement.prependTo(parent);+ }++ prepend = false;};if (self.designerMode)@@ -1463,19 +1491,18 @@ Vvveb.Builder = {{if (self.component.dragHtml || Vvveb.dragHtml) { //if dragHtml is set for dragging then set real component htmlif (self.component) {- newElement = $(self.component.html);- self.dragElement.replaceWith(newElement);- self.dragElement = newElement;- }+ newElement = $(self.component.html);+ self.dragElement.replaceWith(newElement);+ self.dragElement = newElement;+ }}if (self.component.afterDrop) self.dragElement = self.component.afterDrop(self.dragElement);} else {- self.dragElement.attr("style", "");+ self.dragElement.replaceWith(self.selectedEl.removeClass("is-dragged"));+ self.dragElement = self.selectedEl;}- self.dragElement.css("border", "");-node = self.dragElement.get(0);self.selectNode(node);self.loadNodeComponent(node);@@ -1569,11 +1596,20 @@ Vvveb.Builder = {var self = this;$("#drag-btn").on("mousedown", function(event) {- self.dragElement = self.selectedEl.attr("style",Vvveb.dragElementStyle);+ //self.dragElement = self.selectedEl.attr("style",Vvveb.dragElementStyle);self.isDragging = true;$("#section-actions, #highlight-name, #select-box").hide();- node = self.dragElement.get(0);++ if (self.designerMode) {+ self.dragElement = self.selectedEl;+ } else {+ self.selectedEl.css("position", "" ).css("top", "" ).css("left", "" );+ self.selectedEl.addClass("is-dragged");+ self.dragElement = $(Vvveb.dragHtml);+ }++ node = self.selectedEl.get(0);self.dragMoveMutation = {type: 'move',target: node,@@ -1660,15 +1696,40 @@ Vvveb.Builder = {//let value = selectedEl.outerHTML;Vvveb.ModalCodeEditor.show();Vvveb.ModalCodeEditor.setValue(value);++ let oldValue = value;$(window).one("vvveb.ModalCodeEditor.save", function(event, value) {selectedEl.innerHTML = value;//selectedEl.outerHTML = value;++ node = selectedEl;+ Vvveb.Undo.addMutation({type:'characterData',+ target: node,+ oldValue: oldValue,+ newValue: node.innerHTML});});return false;});+ $("#translate-code-btn").on("click", function(event) {+ let selectedEl = Vvveb.Builder.selectedEl.get(0);+ let value = selectedEl.innerHTML.trim();+ // uncomment to use outerHTML, not recommended+ //let value = selectedEl.outerHTML;+ Vvveb.ModalCodeEditor.show();+ Vvveb.ModalCodeEditor.setValue(value);++ //$(window).one("vvveb.ModalTranslateEditor.save", function(event, value) {+ $(window).one("vvveb.ModalCodeEditor.save", function(event, value) {+ selectedEl.innerHTML = value;+ //selectedEl.outerHTML = value;+ });++ return false;+ });+$("#delete-btn").on("click", function(event) {$("#select-box").hide();@@ -1718,9 +1779,9 @@ Vvveb.Builder = {addSectionBox.hide();});- function addSectionComponent(html, after = true)+ function addSectionComponent(component, after = true){- var node = $(html);+ var node = $(component.html);if (after){@@ -1730,8 +1791,14 @@ Vvveb.Builder = {addSectionElement.append(node);}+ if (component.afterDrop) {+ node = component.afterDrop(node);+ }+node = node.get(0);-+ self.selectNode(node);+ self.loadNodeComponent(node);+Vvveb.Undo.addMutation({type: 'childList',target: node.parentNode,addedNodes: [node],@@ -1739,7 +1806,7 @@ Vvveb.Builder = {}$(".components-list li ol li", addSectionBox).on("click", function(event) {- var html = Vvveb.Components.get(this.dataset.type).html;+ var html = Vvveb.Components.get(this.dataset.type);addSectionComponent(html, ($("[name='add-section-insert-mode']:checked").val() == "after"));@@ -1747,7 +1814,7 @@ Vvveb.Builder = {});$(".blocks-list li ol li", addSectionBox).on("click", function(event) {- var html = Vvveb.Blocks.get(this.dataset.type).html;+ var html = Vvveb.Blocks.get(this.dataset.type);addSectionComponent(html, ($("[name='add-section-insert-mode']:checked").val() == "after"));@@ -1756,7 +1823,7 @@ Vvveb.Builder = {$(".sections-list li ol li", addSectionBox).on("click", function(event) {- var html = Vvveb.Sections.get(this.dataset.type).html;+ var html = Vvveb.Sections.get(this.dataset.type);addSectionComponent(html, ($("[name='add-section-insert-mode']:checked").val() == "after"));@@ -1940,7 +2007,7 @@ Vvveb.Builder = {//set head html only if changed to avoid page flickerlet headHtml = getTag(html, "head");if (window.FrameDocument.head.innerHTML != headHtml) {- window.FrameDocument.head.innerHTML = getTag(html, "head");+ window.FrameDocument.head.innerHTML = headHtml;}},@@ -2340,8 +2407,17 @@ Vvveb.Gui = {e.preventDefault();- return Vvveb.Builder.saveAjax(data, function (data) {+ return Vvveb.Builder.saveAjax(data, function (savedData) {data.title = data.name;++ if (typeof savedData === 'object' && savedData !== null) {+ //Object.assign(data, savedData);+ data.name = savedData.name ?? data.name;+ data.url = savedData.url ?? data.url;+ data.file = savedData.file ?? data.file;+ data.title = savedData.title ?? data.title;+ }+Vvveb.FileManager.addPage(data.name, data);Vvveb.FileManager.loadPage(data.name);@@ -2354,7 +2430,7 @@ Vvveb.Gui = {setDesignerMode : function () {//aria-pressed attribute is updated after action is called and we check for false instead of true- var designerMode = this.attributes["aria-pressed"].value != "true";+ var designerMode = this.attributes["aria-pressed"].value == "true";Vvveb.Builder.setDesignerMode(designerMode);},//layout@@ -2415,7 +2491,7 @@ Vvveb.StyleManager = {var _style = false;//check if editor style is present- for (let i=0; i < doc.styleSheets.length; i++) {+ for (let i = 0; i < doc.styleSheets.length; i++) {_style = doc.styleSheets[i];if (_style.ownerNode.id && _style.ownerNode.id == "vvvebjs-styles") {style = _style;@@ -2431,7 +2507,7 @@ Vvveb.StyleManager = {}//if style exist then load all css styles for editor- for (let j=0; j < style.cssRules.length; j++) {+ for (let j = 0; j < style.cssRules.length; j++) {media = (typeof style.cssRules[j].media === "undefined") ?"desktop" : (style.cssRules[j].media[0] === "screen and (max-width: 1220px)")? "tablet" : (style.cssRules[j].media[0] === "screen and (max-width: 320px)")@@ -2441,21 +2517,21 @@ Vvveb.StyleManager = {styles = (media === "desktop") ? style.cssRules[j].style : style.cssRules[j].cssRules[0].style;if (media) {- this.styles[media] = {};- if (selector) {+ this.styles[media] = this.styles[media] ?? {};+ if (selector) {this.styles[media][selector] = {};- for (let k=0; k < styles.length; k++) {+ for (let k = 0; k < styles.length; k++) {- property = styles[k];- value = styles[property];+ property = styles[k];+ value = styles[property];this.styles[media][selector][property] = value;}}}}-+return this.cssContainer = $("#vvvebjs-styles", doc);}},@@ -2506,7 +2582,16 @@ Vvveb.StyleManager = {if (typeof(element) == "string") {selector = element;} else {- selector = this.getSelectorForElement(element.get(0));+ let node = element.get(0);++ //if propert is set with inline style attribute then override it and don't save to css+ //inline text editor sets properties like font-size inline that can't be later overriten from css+ if (node.style && node.style[styleProp]) {+ node.style[styleProp] = value;+ return element;+ }++ selector = this.getSelectorForElement(node);}media = $("#canvas").hasClass("tablet") ? "tablet" : $("#canvas").hasClass("mobile") ? "mobile" : "desktop";@@ -3232,6 +3317,12 @@ Vvveb.FileManager = {},loadPage: function(name, allowedComponents = false, disableCache = true, loadComponents = false) {+ let url = this.pages[name]['url'] ?? "";++ if (!url) {+ return;+ }+let page = $("[data-page='" + name + "']", this.tree);//remove active from current active page$("[data-page]", this.tree).removeClass("active");@@ -3241,7 +3332,6 @@ Vvveb.FileManager = {$("> input[type=checkbox]", $(page).parents("[data-folder]")).prop("checked", true);this.currentPage = name;- var url = this.pages[name]['url'];$(".btn-preview-url").attr("href", url);//allow event to change page or url or cancel by setting url to false@@ -3344,10 +3434,12 @@ Vvveb.Revisions = {updateRevisionsDropdown: function (revisions) {let dropdown = $(".revisions-dropdown").html("");- $(".revisions-count").html(revisions.length);+ let count = Object.keys(revisions).length;+ $(".revisions-count").html(count);+for (let i in revisions) {let revision = revisions[i];- revision['url'] = '' + revision['url'] + ".html";+ //revision['url'] = '' + revision['file'] + ".html";dropdown.append(tmpl('vvveb-revision-item', revision));}},@@ -3375,9 +3467,58 @@ Vvveb.Revisions = {return [name, url, data];});+ $(".revisions-dropdown").on("click", ".btn-revision-load", function (event) {+ let file = this.dataset.file;++ if (file) {+ $.ajax({+ type: "POST",+ url: revisionLoadUrl,//set your server side save script url+ data: {file},+ success: function (data, text) {+ Vvveb.Builder.setHtml(data);+ displayToast("bg-success", "Load", "Revision loaded");+ $("#top-panel .save-btn").removeAttr("disabled");+ },+ error: function (data) {+ displayToast("bg-danger", "Error", data.responseText);+ }+ });+ }+ });+$(".revisions-dropdown").on("click", ".btn-revision-delete", function (event) {- let item = $(this).parents(".dropdown-item");- item.remove();+ if (confirm("Are you sure?")) {++ let item = $(this).parents(".dropdown-item");+ let file = this.dataset.file;++ if (file) {+ $.ajax({+ type: "POST",+ url: revisionDeleteUrl,//set your server side save script url+ data: {file},+ success: function (data, text) {+ let bg = "bg-success";+ if (data.success) {+ item.remove();+ } else {+ bg = "bg-danger";+ }++ displayToast(bg, "Delete", data.message ?? data);++ $(".revisions-count").html(function (i, html) {+ let count = parseInt(html);+ return Math.max(0, count - 1);+ });+ },+ error: function (data) {+ displayToast("bg-danger", "Error", data.responseText);+ }+ });+ }+ }});}}diff --git a/public/js/vvvebjs/components-elements.js b/public/js/vvvebjs/components-elements.jsindex 166d4ab..8e94ae3 100755--- a/public/js/vvvebjs/components-elements.js+++ b/public/js/vvvebjs/components-elements.js@@ -370,7 +370,7 @@ Vvveb.Components.extend("_base","elements/svg-icon", {col:4,inline:true,section: style_section,- htmlAttr: "color",+ htmlAttr: "stroke",inputtype: ColorInput,}]});diff --git a/public/js/vvvebjs/components-html.js b/public/js/vvvebjs/components-html.jsindex ec6187f..0147760 100755--- a/public/js/vvvebjs/components-html.js+++ b/public/js/vvvebjs/components-html.js@@ -231,7 +231,7 @@ Vvveb.Components.extend("_base", "html/hr", {image: "icons/hr.svg",nodes: ["hr"],name: "Horizontal Rule",- html: "<hr>",+ html: '<hr class="border-primary border-4 opacity-25">',properties:[{name: "Type",key: "border-color",@@ -1364,4 +1364,4 @@ Vvveb.Components.extend("_base", "html/iframe", {child:"iframe",inputtype: CssUnitInput}]-});\ No newline at end of file+});