Skip to content

Commit

Permalink
iconOff
Browse files Browse the repository at this point in the history
  • Loading branch information
Standarduser committed Jan 15, 2025
1 parent eb82cc1 commit 26f314a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 11 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ The widgets are designed for VIS 1.x.
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**

* All tiles: added icon for state off
* Optimized CSS for indicator

### 0.4.0 (2025-01-14)

* Added Pinpad-Dialog
Expand Down
10 changes: 5 additions & 5 deletions widgets/vis-homekittiles.html
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
</div>
</div>
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktDatepicker;oid/id;icon/image;iconRound/checkbox;iconColored/checkbox;showLikeActive[true]/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator;"
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktDatepicker;oid/id;icon/image;iconOff/image;iconRound/checkbox;iconColored/checkbox;showLikeActive[true]/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator;"
data-vis-attrs0="group.labelGroup1;label[Datepicker];dateformat[dd.mm.yy]/select,dd.mm.yy,yy-mm-dd;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;oidIncrement/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
Expand Down Expand Up @@ -383,7 +383,7 @@
oid/id;
valueOn[true];
valueOff[false];
icon/image;iconRound/checkbox;iconColored/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
icon/image;iconOff/image;iconRound/checkbox;iconColored/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs0="group.labelGroup1;label[Switch];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;oidIncrement/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
Expand Down Expand Up @@ -504,7 +504,7 @@
</div>
</div>
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktViewInWidgetDialog;oidActive/id;icon/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktViewInWidgetDialog;oidActive/id;icon/image;iconOff/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs0="group.labelGroup1;label[Dialog];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;oidIncrement/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
Expand Down Expand Up @@ -551,7 +551,7 @@
</div>
</div>
</div>'
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktHtmlDialog;oidActive/id;icon/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs="description/custom,vis-homekittiles.infoText,hktHtmlDialog;oidActive/id;icon/image;iconOff/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs0="group.labelGroup1;label[Dialog];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.increment;oidIncrement/id;incrementPlusShow/checkbox;incrementMinusShow/checkbox;incrementPlusValue[1];incrementMinusValue[-1];incrementValueMax[100];incrementValueMin[0];incrementShowOnlyIfTrue/checkbox;"
Expand Down Expand Up @@ -831,7 +831,7 @@
pinWrongSetOid/id;
pinWrongString[WRONG];
pinCorrectAutoclose[true]/checkbox;
oidActive/id;icon/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
oidActive/id;icon/image;iconOff/image;iconRound/checkbox;iconColored/checkbox;showLikeActive/checkbox;displaystyle[tile]/select,tile,tile big,tile small,indicator,tile iconOnly,tile textonly/iconShowHideInputfields();"
data-vis-attrs0="group.labelGroup1;label[Login];label2pre;label2oid/id;label2unit;label2post;label2decimals[1];label2factor[1];label2comma[true]/checkbox;label2tdp/checkbox;"
data-vis-attrs1="group.labelGroup2;label3pre;label3oid/id;label3unit;label3post;label3decimals[1];label3factor[1];label3comma[true]/checkbox;label3tdp/checkbox;label4pre;label4oid/id;label4unit;label4post;label4decimals[1];label4factor[1];label4comma[true]/checkbox;label4tdp/checkbox;label5pre;label5oid/id;label5unit;label5post;label5decimals[1];label5factor[1];label5comma[true]/checkbox;label5tdp/checkbox;"
data-vis-attrs2="group.pinpadDialog;
Expand Down
6 changes: 4 additions & 2 deletions widgets/vis-homekittiles/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,8 @@
border-radius: 15px;
}
.homekitTiles.indicator .labelGroup1 {
bottom: 8px;
top: 50%;
transform: translateY(-50%);
left: 40px;
right: 1px;
position: absolute;
Expand Down Expand Up @@ -395,7 +396,8 @@
.homekitTiles.indicator .tileIcon {
width: 20px;
height: 20px;
top: 5px;
top: 50%;
transform: translateY(-50%);
left: 10px;
position: absolute;
}
Expand Down
53 changes: 49 additions & 4 deletions widgets/vis-homekittiles/js/vis-homekittiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ $.extend(
"icon_": { "en": "Icon button ", "de": "Icon Schaltfläche " },
"iconButton_": { "en": "Icon button ", "de": "Icon Schaltfläche " },
"iconLowBat": { "en": "Icon for low battery", "de": "Icon für Batterie schwach" },
"iconOff": { "en": "Icon for OFF", "de": "Icon für AUS" },
"iconOn": { "en": "Icon for ON", "de": "Icon für EIN" },
"iconUnreach": { "en": "Icon for unreach", "de": "Icon für nicht erreichbar" },
"incrementPlusShow": { "en": "Show (+)-Button", "de": "Zeige (+)-Button" },
"incrementMinusShow": { "en": "Show (-)-Button", "de": "Zeige (-)-Button" },
Expand Down Expand Up @@ -400,11 +402,13 @@ vis.binds["vis-homekittiles"] = {
let val = data.displaystyle;

if (val == 'tile textonly') {
vis.hideShowAttr('icon', false);
vis.hideShowAttr('iconOn', false);
vis.hideShowAttr('iconOff', false);
vis.hideShowAttr('iconRound', false);
vis.hideShowAttr('iconColored', false);
} else {
vis.hideShowAttr('icon', true);
vis.hideShowAttr('iconOn', true);
vis.hideShowAttr('iconOff', true);
vis.hideShowAttr('iconRound', true);
vis.hideShowAttr('iconColored', true);
}
Expand Down Expand Up @@ -1711,9 +1715,50 @@ vis.binds["vis-homekittiles"] = {
var $this = $(el);
var html = '';

if (data.icon !== '' && data.icon !== undefined) html += `<img class="` + (data.iconRound ? 'round' : '') + `" src="${data.icon}">`;
function icon(state) {
//get state
if (state == undefined) state = $this.parent().parent().hasClass('state-active');

//check configuration
var icon = false;
var iconOn = false;
var iconOff = false;
if (data.icon !== '' && data.icon !== undefined) icon = true;
if (data.iconOn !== '' && data.iconOn !== undefined) iconOn = true;
if (data.iconOff !== '' && data.iconOff !== undefined) iconOff = true;

//set icon
var iconSrc = '';
if (state) {
if (iconOn) { iconSrc = data.iconOn; }
else if (icon && iconOff) { iconSrc = data.icon; } //for compatibility if widget was placed when there was no iconOn/Off function
else if (iconOff) { iconSrc = data.iconOff; }
else if (icon) { iconSrc = data.icon; }
else { iconSrc = ''; }
} else {
if (iconOff) { iconSrc = data.iconOff; }
else if (iconOn) { iconSrc = data.iconOn; }
else if (icon) { iconSrc = data.icon; }
else { iconSrc = ''; }
}

$this.html(html);
if (icon || iconOn || iconOff) {
html = `<img class="` + (data.iconRound ? 'round' : '') + `" src="${iconSrc}">`;
}
$this.html(html);
}

//set correct icon on startup
icon();

// subscribe on updates of values
var oid;
if (data.oidActive) {
oid = data.oidActive;
} else if (data.oid) {
oid = data.oid;
}
if (oid) vis.states.bind(oid + '.val', function (e, newVal, oldVal){ icon(newVal); });
},
addLabelGroup1: function (el, data) {
var $this = $(el);
Expand Down

0 comments on commit 26f314a

Please sign in to comment.