Data win Bind style properties winJS - winjs

How to bind Style Properties in winJS ? ?
<div data-win-bind="background: bindingClass;">
this doesnt seem to work
But
<div data-win-bind="innerHTML: bindtext;">
This seem to work even textContent seem to Bind.

Nice one . Clear topic winJs :)
Here's the code
<div data-win-bind="style.background: bindingColor; innerHTML : bindingText">
So both can be accomodated :)

Related

Is it possible to create a modularized reusable component in Umbraco 9?

I'm looking to create a reusable, modularized component in Umbraco 9. I've never worked with any Umbraco before. The example I'll use is a text widget/component that has an image on the left and text on the right, with the ability to set whether you want to swap this to be image right, text left.
I come from the Sitecore world where creating a component like this would mean creating a definition with the fields in the back office, creating an MVC controller and an action, and pointing that back office definition at the controller/action combo. Then, anywhere I've deemed a component hot spot, I can click an "add component" and it'd display the available components I've created (Text + Image Block, in our example).
Our team has been researching how to do something like this in Umbraco. We've been using element types. I've got it working where I can create a list of element types, but we couldn't figure out how to add a controller/action/view to this process to really control what gets displayed.
We've looked into the Grid Type Editor. That requires some Angular work that wasn't exactly playing nice, for some reason it was seeing our image fields as null even though they had an image.
We also tried messing with the Block List editor, and are currently investigating macros.
We've been spinning our wheels and I'm hoping to get some assistance on how to do something like this in Umbraco. Perhaps I'm searching/using the wrong terminology?
Most of our components are super simple, and rather than create a reusable component, we can just use the grid editor. In our example above, we could create a 50/50 grid row and put an image in the left column and the text in the right. This would work, but we'd like to have a little more of a reusable package. Furthermore, a few of the components will require some controller functionality to be able to hit an API and massage some data before passing it to the presentation layer.
We will keep investigating, but ultimately I'm hoping someone can clear up if we're going down the wrong path, or just missing some crucial point here.
Sure! Two ways come to mind for me. One would be make a simple doctype like the screenshot below and let layout decide how to stack them
This sample uses bootstrap which of course you don't have to use, and in my case I have them in a nested content element so I basically just loop through them and alternate putting flex-row-reverse on the row.
#{
var i = 0
foreach(var contentBlock in Model.ContentBlocks)
{
<div class="d-flex flex-wrap align-items-center #(i %2 != 0 ? "flex-row-reverse" : null)">
<div class="block-left col-sm-7">
<h5>#contentBlock.SectionHeading</h5>
#Html.Raw(contentBlock.SectionDescription.ToString())
</div>
#if(contentBlock.HasValue("sectionImage") && contentBlock.SectionImage != null)
{
<div class="block1-right col-sm-5 ml-auto">
<figure class="hover">
<img id="#contentBlock.SectionImage.Name.Trim().Replace(" ", "-")" src="#contentBlock.SectionImage.Url">
</figure>
</div>
}
</div>
i++;
}
}
The other way (as you asked for) is to give the content editor the choice with a toggle, add a toggle to the doctype
and instead of this line
<div class="d-flex flex-wrap align-items-center #(i %2 != 0 ? "flex-row-reverse" : null)">
you could use this line
<div class="d-flex flex-wrap align-items-center #(contentBlock.SectionAlignment == true ? "flex-row-reverse":null)">
Or even something like this where you just assign your own class and write the CSS separately
<div class="d-flex flex-wrap align-items-center #(contentBlock.SectionAlignment == true ? "block-right":"block-left")">
Hope that helps get you going in the right direction. I'm sure you'll have to adapt this for your situation and this code is not tested.
Happy to help if you have any issues.

Material design lite masonry layout with cards

I'm trying to create a "Pinterest" style layout with Material Design Lite. The big issue is that so far, I'm only able to create it with the cards being the same height.
I have been able to do it with CSS and column count (without MDL), but I'd like to use the styling MDL provides. If I use column-count with MDL, it cause some weird layout. My cards vary in size, and it looks bad when they have huge gaps inside them because the gridlayout evens them out in height. I hope it makes sense. I can paste my Wordpress theme code if necessary, but I'm not sure if it's to any help.
I hope someone can help me out :-)
you can use this lightweight javascript http://masonry.desandro.com/ in order to do that. use it like this.
<div class="mdl-grid masonry-grid">
<div class="mdl-cell mdl-cell--4-col-desktop masonry-grid-item">
</div>
<div class="mdl-cell mdl-cell--4-col-desktop masonry-grid-item">
</div>
</div>
<script src="https://unpkg.com/masonry-layout#4/dist/masonry.pkgd.min.js"></script>
<script>
var elem = document.querySelector('.masonry-grid');
var msnry = new Masonry( elem, {
// options
itemSelector: '.masonry-grid-item'
});
</script>

How do I get emmet to add an attribute with a value into a div tag?

I am using the emmet.vim plugin.
How do you write emmet shorthand to account for attributes with no values?
This is what I write:
div.contain-to-grid.sticky>nav.topbar[data-topbar]
This is what I want to happen:
<div class="contain-to-grid sticky">
<nav class="topbar" data-topbar></nav>
</div>
This is what I get:
<div class="contain-to-grid sticky">
<nav class="topbar" data-topbar=""></nav>
</div>
Instead of creating an attribute without a value:
data-topbar
it is creating an empty value:
data-topbar=""
Is there a work around for this? If not then I can live with it. It would be nice to know if it can be done. Thanks
The behaviour of Emmet-vim was changed to be as expected from documentation:
You don’t have to specify attribute values: td[colspan title] will
produce <td colspan="" title=""> with tabstops inside each empty
attribute (if your editor supports them).
So no. You can follow this request here: Attributes without values not being expanded.
Possible crude workaround could be to change the line 220 in autoload/emmet/lang/html.vim from
let current.attr[atts] = ''
to
let current.attr[atts] = function('emmet#types#true')
I just copy the comment by #Alexander Nied to make it more noticeable, which says
While the documentation does not seem to reflect it, this closed issue indicates that support for boolean attributes has been added to Emmet with the syntax of div[my-attribute.], which should expand to This worked for me in Sublime Text
this work for me too, in Intellij idea
As of today (Feb 17, 2023), you can expand foo[bar.] into <foo bar></foo>
So,
div.contain-to-grid.sticky>nav.topbar[data-topbar.]
will be expanded to
<div class="contain-to-grid sticky">
<nav class="topbar" data-topbar></nav>
</div>

Can't click "through" fixed div menu

I'm having problems with my fixed menu. As you can see of the example beneath it's not possible to click the links "Vingårde, Dyrkning..." because of the div box with the fixed menu on top of it. I've tried ordering the layers with z-index but I just can't get it to work. Can anybody help me out?
http://itu.dk/people/mbul/humlum/
And if anyone by the way have a method on auto adjusting the height of the page so it covers the whole viewport I would be very glad to hear from you :-) In the website version above I've set the height manually to 1000px which is not preferable
Thank you!
You need to put all the wrappers' elements outside of it and put them after the left-page container and before the right-page container. Finally, remove the wrapper, it seems unnecessary for the page in order to work.
I fixed it through Chrome's dev tools, but I assume it should work if you modify the html that way.
The body should look like this:
<div id="left_page_container">...</div>
<div class="nav_humlunvim">...</div>
<div class="nav_butik">...</div>
<div class="nav_blog">...</div>
<div class="nav_kontakt">...</div>
<div id="right_page_container">...</div>
Hope it helps; as an extra observation it is more common to use "hyphen-separated-names" for selectors than to use "snake_case_names" :)

audio file does not autoplay within template

Issues when using Meteor with default Handlebars template.
When I move the tag below into the html body, it autoplays just fine. But in the context of a handlebars template, I see the controls but it does not autoplay. Any way to overcome this??
<template name="showMedia">
<div class="background_audio">
<audio controls autoplay>
<source src="assets/screenDisplayAlert.wav">
</audio>
</div>
</template>
Use Template.showMedia.rendered to execute some code after Meteor has rendered the template. For instance, you could call audio.play() or re-apply any missing autoplay attributes.
The reason this isn't working may have something to do with when the browser hooks up autoplay. Being re-rendered by Meteor may not invoke those same hooks. Personally, I feel like that should "just work". If you can't get it fixed, you might consider filing a bug on Github to see if the devs can reproduce or figure out what's going on.
You could try adding some javascript inside a Meteor.startup() block on the client. For reference see Starting and Stopping Audio in Javascript and how can I play a sound clip on page load?.
I don't know why it works outside a template and not inside, but I'm pretty sure the JS will work, and discretion is the better part of valor :)

Resources