JQM horizontal height auto-adjust (listview and buttons) - jquery-mobile

I'm using:
jquery-1.8.2 and jquery-mobile-1.2.0 (generated with all options checked)
Targeted devices are iPhone 4/4s/5 and iPad.
The current data-role="listview":
Test link
The current code:
<div data-role="page">
<div data-role="header" data-position="fixed">
<h1>Test</h1>
</div>
<div data-role="content">
<div class="content-primary">
<ul data-role="listview" data-split-icon="gear" data-split-theme="d">
<li><a href="index.html">
<img src="pics/paul_jones.jpg" />
<h3>First Element</h3>
<p>First</p>
</a></a>Test
</li>
<li><a href="index.html">
<img src="pics/ray_moore.jpg" />
<h3>Second Element</h3>
<p>Second</p>
</a>Test
</li>
<li><a href="index.html">
<img src="pics/lisa_wong.jpg" />
<h3>Third Element</h3>
<p>Third</p>
</a>Test
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
</pre>
What is the best way to make each item auto-adjust its height to stretch to full screen vertically (I see that the framework handles very well horizontal stretching), so that each row is 33% of the screen in this case, and have the images resize accordingly? Obviously this would have to work when there are four or more items.
In my site main page I would instead like to have three or four "image buttons" that I styled this way.
<b>#button_id .ui-btn-inner</b>
background: url("../img/button_image.png") no-repeat rgba(0, 0, 0, 0.4);
background-size: 100% 100%;
fill the screen vertically autoresizing themselves.

Related

Jquery Mobile not displaying data-icons (correctly)

So, I'm adding a popup menu off the header and it works... works quite well actually except for one small thing. For the life of me I can't get it to display the icons the way I want them!
In the first <li> I brute force the data-icon into the <li> and it shows but its not positioned to the left. In the others, I left the data-icon where I'm accustomed to leaving them (where they work correctly everywhere else) and they don't display at all.
Any suggestions?
<div id="header" data-role="header" data-theme="b">
<h1>MyApp</h1>
Menu
<div data-role="popup" id="popupMenu" data-theme="b">
<ul data-role="listview" data-inset="true">
<li data-icon="gear" data-iconpos="left">Settings</li>
<li>GPS</li>
<li>About</li>
</ul>
</div>
</div>
<!-- /header -->
JSFiddle
The data-iconpos attribute not defined for regular list items, works only when the < li> item is inside a navbar widget: http://www.w3schools.com/jquerymobile/jquerymobile_ref_data.asp
Please, take a look to the fiddle I made: https://jsfiddle.net/xbo8npng/1/
I have placed the icons to the left using css:
<div id="header" data-role="header" data-theme="b">
<h1>MyApp</h1>
Menu
<div data-role="popup" id="popupMenu" data-theme="b">
<ul data-role="listview" data-inset="true">
<li class="left" data-icon="gear">Settings</li>
<li class="left">GPS</li>
<li class="left">About</li>
</ul>
</div>
</div>
and the styles:
.left a{
padding-left: 2.5em !important;
padding-right: 1em !important;
}
.left a:after{
left: 2px;
right: auto;
}
I hope this helps you!

How do I make my jpg in the jquery mobile header adjust to the size of the window its being viewed on?

I am able to insert an image inside the header of the jQuery mobile data role, but when I change my browser size the jpg does not change with it. Can someone tell me a quick fix for this please?
Here is my code
<div data-role="page">
<div data-role="header" class="page_header" >
<img src="header_bg.jpg" >
</div><!-- /header -->
<div data-role="content">
<ul data-role="listview" data-inset="true">
<li>Products</li>
<li>About Us</li>
<li>Contact Us</li>
</ul>
</div><!-- /content -->
</div><!-- /page -->
If you just want to fill the background of the header with your image, try this:
<div data-role="header" class="page_header" >
<h1>Header</h1>
</div>
Use CSS for your page_header class to set the background image sized by percentage:
.page_header {
background-image: url("http://lorempixel.com/1400/50/abstract/");
background-repeat:no-repeat;
background-size: 100% 100%;
}
Here is a DEMO
If you really want to use an image tag like in your example, set the width of the image to 100%:
.page_header img {
width: 100%;
}

input fields in jquery mobile dont expand to fill the screen

As the title says,
When i use a input field in a jquery mobile page, it doesnt expand the input fields to the full width of the screen.
If you use a small screen device, it fits fine but when you view the page in a desktop browser, the input fields only appears 2/3 of the width of the browser.
Is there a way to set it to expand to whatever the browser/screens width is?
here is my code:
http://jsfiddle.net/B8JDt/2/
<body>
<div data-role="page" id="page" onLoad="initialiseFields()">
<div data-role="header" data-position="fixed" data-theme="b" data-tap-toggle="false" data-transition="none" > Back
<h1>New Claim</h1>
</div>
<div data-role="content">
<ul class="ui-li" data-role="listview" id="list" data-inset="true" data-scroll="true">
<li data-role="list-divider">
<h2 id="itemTitle">Title</h2>
</li>
<li>
<h3>Journey From:</h3>
<div data-role="fieldcontain">
<input type="text" name="claimTitle" id="textFieldJourneyFrom" value="" />
</div>
</li>
<li>
<h3>Journey To:</h3>
<div data-role="fieldcontain">
<input type="text" name="claimTitle" id="textFieldJourneyTo" value="" />
</div>
</li>
</ul>
<div data-role="navbar">
<ul>
<li>Save</li>
</ul>
</div>
</div>
</div>
</body>
jQuery Mobile has a buggy implementation of box-resizing CSS3 rule.
To fix this problem use this CSS:
#media all and (min-width: 28em){
.ui-input-text {
box-sizing: none !important;
-moz-box-sizing: none !important;
-webkit-box-sizing: none !important;
width: 100% !important;
display: inline-block !important;
}
}
Fist box-sizing: none don't exist but it will override default value and it is better to override it like this then to remove it manually from a css file.
Working example: http://jsfiddle.net/B8JDt/3/

iScrollview - JQuery mobile problems

I am currently trying to build a Facebook-styled web App using jQuery mobile. My main problem is that users are not able to scroll both navigation-bar and content at the same time. I tried many css based solutions but whereas my normal browser displays everything correct all my mobile devices refuse to display two scroll bars at the same time.
So I tried to implement iScroll with iScrollview. It works just perfectly with every content but with my slideable menu-bar. I have no idea where the problem might be. As soon as a page is added iScrollview seems to ignore the data-iscroll attribute.
<body class="ui-mobile-viewport">
<div id="menu" data-role="content" data-iscroll> <!--Menu-->
<div id="memberDetails">
<h3>Username</h3>
</div>
<ul>
<li class="menuDivider" >MENUDIVIDER</li>
<li class="active"><span class="icon" id="home"></span><span class="text">Home</span></li>
<li></span><span class="text">Page One</span></li>
<li></span><span class="text">Page Two</span></li>
<li></span><span class="text">Page Three</span></li>
<li></span><span class="text">Page Eight</span></li>
<li class="menuDivider" >MENUDIVIDER</li>
</ul>
</div>
<!--/Menu-->
<!--page Home-->
<div data-role="page" class="pages ui-page ui-body-c ui-page-active" id="home" data-url="home" tabindex="0" style="margin-left: 0px; min-height: 882px; ">
<div data-role="header" class="ui-header ui-bar-a" role="banner"> <span class="ui-btn-inner ui-btn-corner-all" aria-hidden="true"><span class="ui-btn-text">Menu</span></span>
<h1 class="ui-title" tabindex="0" role="heading" aria-level="1">Home</h1>
</div>
<!-- /header -->
<div id="logo"><img src="files/images/wig_logo.png" alt="wig-logo" width="54" height="25"></div>
<!-- /logo -->
<div data-role="content" class="ui-content" role="main">
<p>Text</p>
</div>
<!-- /content -->
</div>
<!-- /page Home-->
</body>
I am using jQuery 1.8.2, JQM 1.2.0. The slideeffect is done by basically setting the content's margin to the menu's width. Let me know if you need any further information.

How to use mask images for icons in fixed footer?

Here is my footer:
<div data-role="footer" data-id="footer" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar" data-iconpos="top">
<ul>
<li>Home</li>
<li>Nearby</li>
<li>Search</li>
</ul>
</div>
</div>
And here is my custom icon using a mask image:
.ui-icon-nearby {-webkit-mask-image: url(../i/nearby.png); -moz-mask-image: url(../i/nearby.png); background-color: #ffffff}
I get a white square on the Nearby item in the navbar, no icon...
BUT if I add data-visible-on-page-show="false" in the footer div, I see the icon but the footer is not fixed anymore, it goes at the bottom of the page...
Thanks!

Resources