Git Product home page Git Product logo

jquerymobile-splitview's Introduction

jQuery Mobile Splitview plugin

demo at: asyraf9.github.com/jquery-mobile/

This is a plugin for jQuery Mobile that detects your device's browser width and renders pages accordingly - e.g. splitview for desktop and tablets, and standard jqm for mobile phones.

NOTE: as of jQueryMobile 1.2 RC, you will have to use the modified version of JQuerymobile provided in the /jquery-mobile folder of my repo. jquerymobile v1.2.1 will incorporate some changes that will allow this plugin to work out of the box. sorry for the inconvenience NOTE (2): I've only recently began supporting JQM > 1.0 so do expect a lot of bugs and would appreciate if you could submit some pull requests to help me fix it.

Features

  1. auto-detection: automatically decides how to render for the browser you are using.
  2. independent panel scrolling (still a lot more to work on here)
  3. orientation and resize aware - renders the side panel in a popover fashion when in portrait mode
  4. context awareness - can be programmed so that opening a page on the side panel also opens a page on the main panel
  5. deep-link (and history) awareness - linking to a specific page in the main panel works, and hitting on the back and forward button on your browser also works (only for the main panel pages)
  6. panel specific links - links on the side panel can affect pages in the main panel, or in the side panel itself.

Anatomy of a Splitview page

the anatomy of a splitview page can be seen at the demo page above. It is very important that jquery.mobile.splitview.js is loaded before the modified version of jquery mobile, as you can see below. Basically, you need to position your pages in the following order:

<!DOCTYPE html> 
	<html> 
		<head> 
			<title>Page Title</title> 
			
			<meta name="viewport" content="width=device-width, initial-scale=1"> 

		    <link rel="stylesheet" href="stylesheets/jquery.mobile-1.0b2.min.css" />
		    <link rel="stylesheet" href="../../compiled/jquery.mobile-1.0b2pre.css" />
		    <link rel="stylesheet" href="jquery.mobile.splitview.css" />
		    <link rel="stylesheet"  href="jquery.mobile.scrollview.css" />
		    <link rel="stylesheet"  href="jquery.mobile.grids.collapsible.css" />
		    <script type="text/javascript" src="jquery-1.6.2.js"></script>
		    <script type="text/javascript" src="jquery.mobile.splitview.js"></script>
		    <script type="text/javascript" src="../../compiled/jquery.mobile-1.0b2pre.js"></script>
		    <script type="text/javascript" src="jquery.easing.1.3.js"></script>
		    <script type="text/javascript" src="jquery.mobile.scrollview.js"></script>
		</head> 
		<body> 
			<div data-role="panel" data-id="menu">
				<!-- Start of first page -->
				<div data-role="page" id="foo">

					<div data-role="header">
						<h1>Foo</h1>
					</div><!-- /header -->

					<div data-role="content">	
						<p>I'm first in the source order so I'm shown as the page.</p>		
						<p>View internal page called <a href="#bar">bar</a></p>	
					</div><!-- /content -->

					<div data-role="footer">
						<h4>Page Footer</h4>
					</div><!-- /footer -->
				</div><!-- /page -->
				<!-- other side panel pages here -->
			</div>
			<div data-role="panel" data-id="main">
				<!-- Start of second page -->
				<div data-role="page" id="bar">

					<div data-role="header">
						<h1>Bar</h1>
					</div><!-- /header -->

					<div data-role="content">	
						<p>I'm first in the source order so I'm shown as the page.</p>		
						<p><a href="#foo">Back to foo</a></p>	
					</div><!-- /content -->

					<div data-role="footer">
						<h4>Page Footer</h4>
					</div><!-- /footer -->
				</div><!-- /page -->
				<!-- other main panel pages here -->
			</div>
		</body>
	</html> 

NOTE: although with this beta2 release I've managed to minimize the amount of changes made in jqm core, there are still about 3 lines of code I needed to add. make sure you use the version provided in this fork of jqm by running 'make' in a terminal, and finding the jquerymobile js and css files in the /compiled folder created by 'make'. (also make sure to run this in the beta2 branch, or you won't get the most up to date files)

pages can also be loaded dynamically provided you specify the panel it needs to load into (as explained below). you need to preload two pages - one for each panel, to avoid an empty page on either of your panels.

Splitview Links

splitview links work just like the links in jQuery Mobile. the only difference is, you can define the panel you want the page that link points to load into using the 'data-panel' attribute. for example:

<a href="some_other_page" data-panel="main">

this method also loads ajax pages.

Panel settings

there are two settings for panel divs:

  1. data-hash - takes the following values: true(default), false, and crumbs this attribute tells splitview to track history for the panel or not (true and false), or to set a 'crumb' (crumbs) button at the top left portion of the header for each page.

  2. data-context - takes a jQuery selector value, or a hash of the following: url, panel, refresh. data-context tells splitview to load another page whose link can be found in the active page by the jQuery selector value, or a page which is pointed to by the hash. example:

     <div data-role="panel" data-id="menu" data-hash="crumbs" data-context="a#default">
    

    OR

     <div data-role="panel" data-id="menu" data-hash="crumbs" data-context='{"url":"#bar", "panel":"main", "refresh":false}'>
    

    NOTE: this attribute, if used on a page, overrides panel data-context attributes. example:

     <div data-role="page" data-context="a#default">
    

that's about it! splitview does everything else for you... enjoy it, and let me know if you have any issues with it! thanks!

jquerymobile-splitview's People

Contributors

ashleyjsands avatar asyraf9 avatar jkrehm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquerymobile-splitview's Issues

Space between panels after refresh

Not sure if anyone else experiences the same issue, but when I open http://asyraf9.github.com/jquerymobile-splitview/#badz on IPAD, and then refresh the page, I get space between left and right panels.

I traced it down to the following code in function splitView()

$main.addClass('ui-panel-right')
.width(function(){
return $(window).width()-$('div:jqmData(id="menu")').width();
});

On IPAD $(window).width() returns 768, so the math doesn't work.

I set width to 75% and it seem to work fine now (not sure if there's better solution)
$main.addClass('ui-panel-right').css('width','75%');

Also, if the page switches to landscape and menu is opened, menu panel is moved left 10px in function popover() .css($.mobile.menuBtnSide, '10px');

But when orientation changes to landscape, left position doesn't get reset. I fixed it by adding .css($.mobile.menuBtnSide, '0') in function splitView right before setting width

Hope this help someone...

BTW, thank you for the life saving widget. Out of all split view/multiview implementations, this is the most stable. And with the above 2 fixed, it's even better :-)

Demo crashes on IE8 and IE9

The page renders blank. Here is the javascript error message in IE8 on Win7:
Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.1.4322; InfoPath.2; MS-RTC LM 8; .NET4.0C; .NET4.0E) Timestamp: Wed, 31 Oct 2012 18:09:57 UTC Message: 'body' is null or not an object Line: 9221 Char: 7 Code: 0 URI: file:///path/to/splitview/jquery-1.7.1.js

In IE9, the error is:
SCRIPT5007: Unable to get value of the property 'scrollWidth': object is null or undefined
jquery-1.7.1.js, line 9221 character 7

Right to Left feature request

Hi asyraf9,

I'm struggling on changing the orientation of splitview overlay to rtl.
Your assistance will be much appreciated.

Great project btw

Flickering effect during page change.

I have pages in different html files.When i link a page to a panel both the panels gets refreshed and i have a flickering effect. When i click on a button in the left panel both the panel have a flickering effect.
This problem is only in landscape mode and works fine in browser but not on ipad or any phone.
Can u plx help me out with it asap.It will be of great help.

Right panel blinks with jquerymobile 1.3

Hi,
first of all I would like to thank you for creating splitview.

I have noticed that switching to newest jquery mobile creates bad blink effect on right panel when animation ends. I have tested it with the demo - http://asyraf9.github.com/jquerymobile-splitview just by changing the line 11 from jquery.mobile.js into http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.js

Can you help me with this problem?
I need some features from jquery mobile 1.3 - that are tables and input for files.

Listview back button failing after a http post changePage call

Hi,

We are using the asyraf9 / jquerymobile-splitview in our application. At the left side panel we have a jqm listview. At the right panel we are displaying some details about the items located at the left panel listview. We also have some buttons at the right panel which performs some actions on the item displayed at the right panel. Those buttons trigger some java script actions where we call some pages (there are actually ASP.NET MVC action url's) by using the "http post" method. The thing is that those "post" callPage invokations broke the listview "back" button functionality (you have to click the back button twice to go the listview previous level)

Any idea about what may be going wrong?

Thanks in advance for your help!

Can not add phonegap deviceready event

Tested it side by side with the unedited jquery mobile 1.2 + phonegap and I have a working split view

In jqm 1.2 deviceready is fired, using the split view it isn't.

Column size not constant

I have found that at times the content of the left < td > (SplitViewContainer_leftpagepanel) can cause it to be wider than its default width of 400px. I was able to overcome this by setting the width of its inner div (SplitViewContainer_leftcontainer) in the javascript file and leaving the width of the < td > unspecified.

problem with select menu with many "option"-elements

hi!

< div data-role="fieldcontain">
< label for="select-choice-3" class="select">Your state:
< select name="select-choice-3" id="select-choice-3" data-native-menu="false">
< option value="AL">Alabama
< option value="AK">Alaska
< option value="AZ">Arizona
< option value="AR">Arkansas
...


page-dialog with options-list doesn't open, as on official jqm-demo..

Left column disappear

Hi, I added a html5 video tag in the right column and it play succesfully, nevertheless if i make full screen with the video when I come back, the left column disappears. If I turn my ipad vertically and I turn it horizontally again, the right column come back. I would like to know how can i prevent this, or how can i make some view refresh to see the left column all the time.
Thankyou

On IPAD, textarea/input - sliding keyboard issue

Struggling to figure this one out...

On IPAD, when page is in landscape mode and focus fall on an input or a textarea, the keyboard appears. When keyboard gets dismissed, the whole page resizes to 1/3 of it's normal size. Keyboard doesn't trigger window resize event, so not exactly sure why it happens.

Thanks

It is not working with jQuery1.10 or 2.0

Just wanted to check if anybody uses it with latest version of jQuery. For me it is not displaying anything on page when used with jQuery1.10 or 2.0. I did not test it on Mobile device but I have tested it on Chrome and Mozilla Firefox.

Link on window (like base target = _top)

Hello,

thanks for your work !

I have many links in both panels, which have to be loaded on "_top" like ..
Is there a way ?

meta tag "base" is not working.
data-context="_top" also not.

Thansk for your answer.

Remote Pages Error

Hi
I have to refresh the page to display the page correctly
my application has 2 pages the index page contain a link which navigate to the other page which contain the plugin.
BUT
This plugin works great if the the split view on the index page but if I have a link to navigate to another page I get this error "Cannot call method '_trigger' of undefined "
and when I'm added the page and the script on the other page and set the link data-rel="external"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.