Zurb Foundation 4 How to maintain columns when printing - zurb-foundation

I am using Foundation 4.2.3 from Zurb, but when I print pages, the grid layout is always not maintained.
For example,
<div class="row">
<div class="small-3 columns">
XXX
</div>
<div class="small-9 columns">
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
</div>
</div>
This renders as
but it becomes this when printed.
Is there a fix to this so that the grid layout is maintained?

I added this to my .scss file at the end:
#media print {
div.columns {
float:left!important;
padding-left:0.9375em!important;
padding-right:0.9375em!important;
width:8.3333333333%!important;
}
}

The issue ist that ".large-XXX .columns" in the grid is only defined for "#media screen":
foundation/_variables.scss:98
$small: "only screen and (min-width: #{$small-screen})";
foundation/components/_grid.scss:153
#media #{$small} {
#for $i from 1 through $total-columns {
.large#{-$i} { #include grid-column($columns:$i,$collapse:null,$float:false); }
}
...
}
So what I did was add a line after foundation/_variables.scss is included that overrides this:
// This includes all of the foundation global elements that are needed to work with any of the other files.
#import "foundation/variables";
$small: "screen and (min-width: #{$small-screen}), print";
Of course, this only works if you don't auto-include all of foundation by way of #import "foundation", but instead include all of them manually (i.e., uncomment the respective lines in _foundation.scss).

I did this in the variables.scss file for Foundation 5, although it's not perfect.
// $screen: "only screen";
$screen: "print, screen";

Related

swiftui TextView with action text

Hi everyone I am creating a text editor and I would like to know if there is the possibility to insert a Uibutton in the middle of the text. I am not referring to a url but to a real button.
For now I am creating the editor with a UIViewRepresentable and then with a regex I look for the part of the text to be transformed
Lorem ipsum dolor sit amet, <button id = "4"> consectetur adipiscing elit. Maecenas ornare </button> eget sapien vel gravida.
My goal is to transform the text between the <button> tag into a UIButton or in any case into a tappable text that can perform an action. To understand the equivalent of
Button (action: {
self.mode = "normal"
}) {
Text ("title")
}
some idea? Is it possible to achieve this?
Thank you!

Remove accordion slide animation on page load

When my page loads the active accordion item slides open which causes the other elements on the page to also move for a second.
I'd like the active accordion item to render "already opened", but still retain the animation for when a user clicks on another accordion item, or even the originally opened item in cases where the user selects another item and then the original.
I cant find any css being used to do this, so maybe its something in the javascript? If so, how would I go about overriding this.
Any suggestions on how to accomplish this would be greatly appreciated!
Foundation Accordion: http://foundation.zurb.com/sites/docs/accordion.html
There's no simple solution from what I know, but you can override some attributes on load so that the active item is displayed by default. You'd have to begin with an accordion none of the items are active i.e. none of the accordion items have a class of .is-active:
Html:
<ul class="accordion" data-accordion data-allow-all-closed='true'>
<li class="accordion-item" data-accordion-item>
Accordion 1
<div class="accordion-content" data-tab-content>
Panel 1. Lorem ipsum dolor
</div>
</li>
<li class="accordion-item" data-accordion-item>
Accordion 2
<div class="accordion-content" data-tab-content>
Panel 2. Lorem ipsum dolor
</div>
</li>
<li class="accordion-item" data-accordion-item>
Accordion 3
<div class="accordion-content" data-tab-content>
Panel 3. Lorem ipsum dolor
</div>
</li>
</ul>
jQuery:
//Initialise the Foundation plugins
$(document).foundation();
function activateWithoutAnimation(itemIndex) {
//Get the accordion item according to its index (0 based)
var $accordionItem = $('.accordion-title:eq(' + itemIndex + ')');
//Set the aria attributes of the accordion item you want to appear
$accordionItem.attr('aria-expanded', 'true');
$accordionItem.attr('aria-selected', 'true');
//Set the attributes of the content.
$accordionItem.next().attr('aria-hidden', 'false');
$accordionItem.next().css('display', 'block');
//This is essential as it lets foundation know that the item is active (to re-allow toggling)
$accordionItem.trigger('click');
}
//Call the function.
activateWithoutAnimation(0);
There might be a better way to do the above, but from what I've read, there's no option that allows the animation to be disabled. I've tried overriding the defaults that Foundation provides to no avail.
Fiddle Demo
CSS Solution
If using the default helper class .is-active on initial load then some plain css can eliminate the slide open animation.
.is-active .accordion-content {
display: block;
}
https://jsfiddle.net/r6jvbohu/
CSS only (without losing the animation)
To always open the first item immediately while still keeping the animation, you can use the following code.
.accordion-item:first-of-type .accordion-content {
display: block;
}
The first item should still have the .is-active class to be consistent, but this removes the initial animation because we overwrite the display value from none to block. The JS still overwrites this state when another accordion item is clicked, resulting in the animation we want to keep.

Unable to access nested JSON properties from handle bars template

js with HandleBar, I have been using it for a couple of days now but I have hit a problem.
Basically i have the following json data:
{
"id":1009,
"parent_id":1007,
"template":"blog-post",
"path":"/blog-post/another-test-blog-post/",
"name":"another-test-blog-post",
"created":1389310922,
"modified":1389371901,
"created_users_id":41,
"modified_users_id":41,
"title":"Another Test Blog Post",
"headline":null,
"summary":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis lectus dui. ",
"image_caption":"Another Image Caption",
"images":{
"blog-sample-image-medium.png":{
"basename":"blog-sample-image-medium.png",
"description":"",
"tags":"",
"formatted":true,
"modified":1389352919,
"created":1389352919
}
},
"sub_heading":"Another Sub Heading"
}
It is valid data and I am able to obtain parameters and display within my handle bars template. However I am unable to access the properties within "images", I have tried also sorts of techniques and am unable to do so. Here is the part of my template in question:
{{#each item in model}}
<div class="media-element" {{#ifIsNthItem nth=3}} style="margin-right: 0px;" {{/ifIsNthItem}}>
<div style="skyiq-element-icon blog-element">
</div>
<div class="media-main-image grayscale" style="">
</div>
<p class="sub-heading">{{item.title}}</p>
<ul>
<li><i aria-hidden="true" class="skycon-user-profile"></i> By Liam Powell</li>
<li><i aria-hidden="true" class=" skycon-info"></i> 02/Dec/2013</li>
</ul>
<p>{{{item.summary}}}</p>
read more
<div class="skyiq-line"></div>
<i class=" skycon-share" aria-hidden="true"></i> Share
</div>
{{/each}}
So parameters such as item.summary display but I can not display item.images.1.basename for example.
Any help or a point in the right direction would be a great help.
Thanks in advance
Three things:
1) The way you're accessing it like this: {{item.images.1.basename}} makes me think you want to treat images like an array. You can't access items in an array using the index number in handlebars like you would in javascript. Ember provides helper properties called firstObject and lastObject on arrays that let you access the first and last object of the array. But, there isn't a secondObject which it looks like you want in the case you laid out. Typically the way you would access elements in an array is by iterating over them using an {{#each}}.
2) In the JSON you posted, images isn't an array but an object. So, you would access items on it like this: {{item.images.blog-sample-image-medium.png.basename}}.
3) Ember is likely going to not like the fact that the object key blog-sample-image-medium.png has a period in it, since that's how it figures out when it's time to access the next object. You should try and figure out how to get the period out of the keys name.

dojo: Show or hide divs based on selection in a list

Is there a simple way to accomplish this using dojo (jQuery would be easier for me but I have to use dojo): I have a simple unordered list. I don't want dojo to style the list (as it might if I used some widget). When I click a link on the list I want to show a div associated with the link. Then if I click another link in the list the first div hides and that one shows.
<div id="content">
<h2>Header</h2>
<ul>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
<div id="sub_content1" style="display:none;">
<h3>Sub Content Header 1</h3>
<p>Lorem ipsum veritas britas conflictum civa</p>
</div>
<div id="sub_content2" style="display:none;">
<h3>Sub Content Header 2</h3>
<p>Lorem ipsum mobius ceti</p>
</div>
<div id="sub_content3" style="display:none;">
<h3>Sub Content Header 3</h3>
<p>Lorem ipsum citrus pecto</p>
<ul>
<li>Lemons</li>
<li>Limes</li>
</ul>
</div>
</div><!-- end of #content -->
So in fact you're creating your own tabcontainer? If you really want to do it yourself you should probably need something like this:
require(["dojo/ready", "dojo/on", "dojo/dom-attr", "dojo/dom-style", "dojo/query", "dojo/NodeList-dom"], function(ready, on, domAttr, domStyle, query) {
ready(function() {
query("ul li a").forEach(function(node) {
query(domAttr.get(node, "href")).forEach(function(node) {
domStyle.set(node, "display", "none");
});
on(node, "click", function(e) {
query("ul li a").forEach(function(node) {
if (node == e.target) {
query(domAttr.get(node, "href")).forEach(function(node) {
domStyle.set(node, "display", "block");
});
} else {
query(domAttr.get(node, "href")).forEach(function(node) {
domStyle.set(node, "display", "none");
});
}
});
});
});
});
});
I'm not sure how familiar you are with Dojo, but it uses a query that will loop all links in lists (with the dojo/query and dojo/NodeList-dom modules) (you should provide a classname or something like that to make it easier). Then it will, for each link, retrieve the div corresponding to it and hide it, it will also connect a click event handler to it (with the dojo/on module).
When someone clicks the link, it will (again) loop all the links, but this time it's doing that to determine which node is the target one and which isn't (so it can hide/show the corresponding div).
I made a JSFiddle to show you this. If something is still not clear you should first try to look at the reference guide of Dojo since it really demonstrates the most common uses of most modules.
But since this behavior is quite similar to a TabContainer, I would recommend you to look at the TabContainer reference guide.

"Cannot call method 'extend' of undefined" when creating a view

I'm having my first play around with Ember.js, and am falling at the first hurdle. Been trying for ages to get this to work, but I keep getting the error "Cannot call method 'extend' of undefined "
In my HTML I have this:
<script type="text/x-handlebars">
{{#view App.MainView}}
<div class="hero-unit">
<h1>{{blogTitle}}</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur non neque a eros dapibus posuere. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
{{/view}}
</script>
And in my JS I have this:
var App = Ember.Application.create();
//define main view
App.MainView = Ember.View.extend({
blogTitle: 'Epic Blog'
});
According to the docs, this should just render the template fine, but no matter hoe hard I try I get the error...
Anyone know what I'm doing wrong?
What Ember.js version are you using? I've created a JSFiddle with your code using Ember.js 0.9.8.1 and it works, see http://jsfiddle.net/pangratz666/D3VuA/.
Also, you have to declare App as global variable by omitting the var. This is needed so bindings and paths in the templates work:
App = Ember.Application.create();
...