Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:microweber/microweber into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-mw committed Jun 20, 2022
2 parents d380c10 + 0993e0e commit dbd37dd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
9 changes: 5 additions & 4 deletions userfiles/modules/microweber/api/libs/cssjson/cssjson.js
Expand Up @@ -180,14 +180,14 @@ var CSSJSON = new function () {
*/
base.toCSS = function (node, depth, breaks) {
var cssString = '';
if (typeof depth == 'undefined') {
if (typeof depth === 'undefined') {
depth = 0;
}
if (typeof breaks == 'undefined') {
if (typeof breaks === 'undefined') {
breaks = false;
}
if (node.attributes) {
for (i in node.attributes) {
for (var i in node.attributes) {
var att = node.attributes[i];
if (att instanceof Array) {
for (var j = 0; j < att.length; j++) {
Expand All @@ -200,7 +200,8 @@ var CSSJSON = new function () {
}
if (node.children) {
var first = true;
for (i in node.children) {
for (var i in node.children) {
console.log(node.children[i])
if (breaks && !first) {
cssString += '\n';
} else {
Expand Down
23 changes: 23 additions & 0 deletions userfiles/modules/microweber/api/stylesheet.editor.js
Expand Up @@ -42,6 +42,7 @@ mw.liveeditCSSEditor = function (config) {


this._cssTemp = function (json) {

var css = CSSJSON.toCSS(json);
if(!mw.liveedit._cssTemp) {
mw.liveedit._cssTemp = mw.tools.createStyle('#mw-liveedit-dynamic-temp-style', css, document.body);
Expand All @@ -51,9 +52,20 @@ mw.liveeditCSSEditor = function (config) {
}
};

var removeSheetRuleProperty = function (selector, property) {
var sheet = document.querySelector('link#mw-template-settings').sheet;
var i = 0, l = sheet.cssRules.length;
for ( ; i < l ; i++) {
if(sheet.cssRules[i].selectorText === selector) {
sheet.cssRules[i].style.removeProperty(property);
}
}
};

this.changed = false;
this._temp = {children: {}, attributes: {}};
this.temp = function (node, prop, val) {
val = (val || '').trim();
this.changed = true;
if(node.length) {
node = node[0];
Expand All @@ -65,7 +77,18 @@ mw.liveeditCSSEditor = function (config) {
if (!this._temp.children[sel].attributes ) {
this._temp.children[sel].attributes = {};
}


this._temp.children[sel].attributes[prop] = val;

if(val === '' || val === '!important') {
this._temp.children[sel].attributes[prop] = '';
// delete this._temp.children[sel].attributes[prop];
removeSheetRuleProperty (sel, prop);

}


this._cssTemp(this._temp);
};

Expand Down
Expand Up @@ -396,7 +396,14 @@ interface: 'shadow',



var isbg = prev.prev().find('.mw-field-color-indicator-display');
if(isbg.length) {
isbg.css('backgroundColor', val);
}



prev.val(val);
prev.find('input').val(val);
var n = parseFloat(val)
$('.mw-range.ui-slider', prev).slider('value', !isNaN(n) ? n : 0)
Expand Down

0 comments on commit dbd37dd

Please sign in to comment.