mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-17 22:36:35 +00:00
Add markdown to persistent notifications (#128)
* Add micromarkdown.js and update persistent notifications * Fixed my way wrong logic * change to stateObj in call * Move micromarkdown to bower. Update importHref. * Add properties for importHref * Fix importHref properties and add logging. * Fix computeContent function * Fix travis * Fix computeContent function * Fix markdown script * Fix all markdown code. * Add mmd.css * Correct imports of stylesheets * Fix Travis * Move micromarkdown to HA * Fix requests * Fix importHref script location
This commit is contained in:
parent
8c5b547141
commit
78c7756aa1
@ -18,8 +18,8 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<ha-card header="[[computeTitle(stateObj)]]">
|
<ha-card header='[[computeTitle(stateObj)]]'>
|
||||||
<div class='content'>[[stateObj.state]]</div>
|
<div id='pnContent' class='content'></div>
|
||||||
<paper-button on-tap='dismissTap'>DISMISS</paper-button>
|
<paper-button on-tap='dismissTap'>DISMISS</paper-button>
|
||||||
</ha-card>
|
</ha-card>
|
||||||
</template>
|
</template>
|
||||||
@ -37,12 +37,51 @@ Polymer({
|
|||||||
stateObj: {
|
stateObj: {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
scriptLoaded: {
|
||||||
|
type: Boolean,
|
||||||
|
value: false,
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
observers: [
|
||||||
|
'computeContent(stateObj, scriptLoaded)',
|
||||||
|
],
|
||||||
|
|
||||||
computeTitle: function (stateObj) {
|
computeTitle: function (stateObj) {
|
||||||
return stateObj.attributes.title || stateObj.entityDisplay;
|
return stateObj.attributes.title || stateObj.entityDisplay;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadScript: function () {
|
||||||
|
var success = function () {
|
||||||
|
this.scriptLoaded = true;
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
var error = function () {
|
||||||
|
console.error('Micromarkdown was not loaded.');
|
||||||
|
};
|
||||||
|
|
||||||
|
this.importHref(
|
||||||
|
'/static/micromarkdown-js.html',
|
||||||
|
success, error
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
computeContent: function (stateObj, scriptLoaded) {
|
||||||
|
var el = '';
|
||||||
|
var message = '';
|
||||||
|
if (scriptLoaded) {
|
||||||
|
el = this.$.pnContent;
|
||||||
|
message = micromarkdown.parse(stateObj.state);
|
||||||
|
el.innerHTML = message;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
|
ready: function () {
|
||||||
|
this.loadScript();
|
||||||
|
},
|
||||||
|
|
||||||
dismissTap: function (ev) {
|
dismissTap: function (ev) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user