mindapp 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/generators/mindapp/USAGE +8 -0
- data/lib/generators/mindapp/install_generator.rb +134 -0
- data/lib/generators/mindapp/templates/app/assets/images/account.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/add.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/ajax-loader-circle.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/ajax-loader.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/anchor.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/application_double.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/application_form_edit.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/arrow_turn_right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/calendar.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cancel.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/chart_bar.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/clock.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cog.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/control_fastforward.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/control_play.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/cross.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/delete.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/external-link.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/help.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/house.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/logo_mindapp.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/logout.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/new.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/new.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_attach.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_green.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_output.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/page_pdf.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/pencil.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/printer.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/refresh.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/report.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/rssmall.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/tick.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/user.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/images/view_code.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/application.js +19 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/disable_enter_key.js +10 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll-wrapper.js +32 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/iscroll.js +1084 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery-1.7.1.js +9266 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.datebox.js +1772 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.js +7007 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/jquery.mobile.splitview.js +624 -0
- data/lib/generators/mindapp/templates/app/assets/javascripts/mindapp.js +14 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/application.css.scss +18 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bold.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_bolditalic.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/sarabun_italic.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew.css +47 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bold-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_bolditalic-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.eot +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.ttf +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/fonts/thsarabunnew_italic-webfont.woff +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ajax-loader.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/bg.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_blue.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/button_red.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/cancel.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/close.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/del2.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/deli4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/down-right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/fbook.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ff.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icon-search-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-18-white.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-black.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/icons-36-white.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/overlay.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/rss4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/search_bg.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble2.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/stumble4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-left.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tab-right.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/tech4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter3.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/twitter4.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-anim_basic_16x16.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_217bc0_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_469bdd_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_6da8d5_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_d8e7f3_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/images/ui-icons_f9bd01_256x240.png +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/indicator.gif +0 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.css +1855 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.datebox.css +65 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.grids.collapsible.css +122 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/jquery.mobile.splitview.css +130 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/mindapp.css +134 -0
- data/lib/generators/mindapp/templates/app/assets/stylesheets/sarabun.css +37 -0
- data/lib/generators/mindapp/templates/app/controllers/identities_controller.rb +5 -0
- data/lib/generators/mindapp/templates/app/controllers/mindapp_controller.rb +464 -0
- data/lib/generators/mindapp/templates/app/controllers/sessions_controller.rb +28 -0
- data/lib/generators/mindapp/templates/app/mailers/.gitkeep +0 -0
- data/lib/generators/mindapp/templates/app/mailers/mindapp_mailer.rb +7 -0
- data/lib/generators/mindapp/templates/app/mindapp/index.mm +85 -0
- data/lib/generators/mindapp/templates/app/mindapp/template/view.html.erb +21 -0
- data/lib/generators/mindapp/templates/app/models/.gitkeep +0 -0
- data/lib/generators/mindapp/templates/app/models/identity.rb +14 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/doc.rb +30 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/module.rb +10 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/notice.rb +11 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/role.rb +7 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/runseq.rb +24 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/service.rb +16 -0
- data/lib/generators/mindapp/templates/app/models/mindapp/xmain.rb +38 -0
- data/lib/generators/mindapp/templates/app/models/param.rb +41 -0
- data/lib/generators/mindapp/templates/app/models/user.rb +30 -0
- data/lib/generators/mindapp/templates/app/views/identities/new.html.erb +30 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_full.haml +39 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_head.html.erb +14 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_page.haml +16 -0
- data/lib/generators/mindapp/templates/app/views/layouts/_top.html.erb +10 -0
- data/lib/generators/mindapp/templates/app/views/layouts/application.haml +4 -0
- data/lib/generators/mindapp/templates/app/views/layouts/gmail.html.erb +9 -0
- data/lib/generators/mindapp/templates/app/views/layouts/mobile.html.erb +13 -0
- data/lib/generators/mindapp/templates/app/views/layouts/mobilejq.html.erb +31 -0
- data/lib/generators/mindapp/templates/app/views/layouts/print.html.erb +22 -0
- data/lib/generators/mindapp/templates/app/views/layouts/utf8.html.erb +21 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_activity.md +10 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu.haml +22 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_menu_mm.haml +30 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_model.md +5 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_modul.md +9 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_pending_home.haml +5 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_pending_page.haml +26 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_service.md +24 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/_static.haml +23 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/doc.md +37 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/feed.rss.builder +27 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/help.haml +20 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/index.html.haml +34 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/pending.haml +1 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/run_form.haml +37 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/search.haml +20 -0
- data/lib/generators/mindapp/templates/app/views/mindapp/status.haml +61 -0
- data/lib/generators/mindapp/templates/app/views/mindapp_mailer/gmail.html.erb +9 -0
- data/lib/generators/mindapp/templates/app/views/sessions/new.html.erb +11 -0
- data/lib/generators/mindapp/templates/mindapp.yml +10 -0
- data/lib/generators/mindapp/templates/seeds.rb +6 -0
- data/lib/mindapp.rb +6 -0
- data/lib/mindapp/helpers.rb +475 -0
- data/lib/mindapp/railtie.rb +18 -0
- data/lib/mindapp/version.rb +3 -0
- data/lib/tasks/mindapp.rake +191 -0
- data/mindapp.gemspec +19 -0
- metadata +239 -0
@@ -0,0 +1,624 @@
|
|
1
|
+
// TODO: reinstate replaceBackBtn - to include the case where people actually really want the back btn
|
2
|
+
(function($,window,undefined){
|
3
|
+
$( window.document ).bind('mobileinit', function(){
|
4
|
+
//some class for css to detect touchscreens
|
5
|
+
if($.support.touch){
|
6
|
+
$('html').addClass('touch');
|
7
|
+
}
|
8
|
+
var $query = $.mobile.media('screen and (min-width: 480px)') && ($.mobile.media('(-webkit-max-device-pixel-ratio: 1.2)') || $.mobile.media('(max--moz-device-pixel-ratio: 1.2)'));
|
9
|
+
$.support.splitview = ($query || ($.mobile.browser.ie && $(this).width() >= 480)) && $.mobile.ajaxEnabled;
|
10
|
+
if ($.support.splitview) {
|
11
|
+
$('html').addClass('splitview');
|
12
|
+
//on window.ready() execution:
|
13
|
+
$(function() {
|
14
|
+
$(document).unbind('.toolbar');
|
15
|
+
$('.ui-page').die('.toolbar');
|
16
|
+
$('div:jqmData(role="panel")').addClass('ui-mobile-viewport ui-panel');
|
17
|
+
var firstPageMain=$('div:jqmData(id="main") > div:jqmData(role="page"):first');
|
18
|
+
if( !$.mobile.hashListeningEnabled || !$.mobile.path.stripHash( location.hash ) ){
|
19
|
+
var $container=$('div:jqmData(id="main")');
|
20
|
+
$.mobile.firstPage = firstPageMain;
|
21
|
+
$.mobile.changePage(firstPageMain, {transition:'none', changeHash:false, pageContainer:$container});
|
22
|
+
$.mobile.activePage=undefined;
|
23
|
+
} //no need to trigger a hashchange here cause the other page is handled by core.
|
24
|
+
|
25
|
+
// setup the layout for splitview and jquerymobile will handle first page init
|
26
|
+
$(window).trigger('orientationchange');
|
27
|
+
setTimeout(function(){
|
28
|
+
$.mobile.firstPage = firstPageMain;
|
29
|
+
}, 100)
|
30
|
+
}); //end window.ready()
|
31
|
+
|
32
|
+
//----------------------------------------------------------------------------------
|
33
|
+
//Main event bindings: click, form submits, hashchange and orientationchange/resize(popover)
|
34
|
+
//----------------------------------------------------------------------------------
|
35
|
+
//existing base tag?
|
36
|
+
var $window = $( window ),
|
37
|
+
$html = $( 'html' ),
|
38
|
+
$head = $( 'head' ),
|
39
|
+
$base = $head.children( "base" ),
|
40
|
+
//tuck away the original document URL minus any fragment.
|
41
|
+
documentUrl = $.mobile.path.parseUrl( location.href ),
|
42
|
+
|
43
|
+
//if the document has an embedded base tag, documentBase is set to its
|
44
|
+
//initial value. If a base tag does not exist, then we default to the documentUrl.
|
45
|
+
documentBase = $base.length ? $.mobile.path.parseUrl( $.mobile.path.makeUrlAbsolute( $base.attr( "href" ), documentUrl.href ) ) : documentUrl;
|
46
|
+
|
47
|
+
function findClosestLink(ele)
|
48
|
+
{
|
49
|
+
while (ele){
|
50
|
+
if (ele.nodeName.toLowerCase() == "a"){
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
ele = ele.parentNode;
|
54
|
+
}
|
55
|
+
return ele;
|
56
|
+
}
|
57
|
+
|
58
|
+
// The base URL for any given element depends on the page it resides in.
|
59
|
+
function getClosestBaseUrl( ele )
|
60
|
+
{
|
61
|
+
// Find the closest page and extract out its url.
|
62
|
+
var url = $( ele ).closest( ".ui-page" ).jqmData( "url" ),
|
63
|
+
base = documentBase.hrefNoHash;
|
64
|
+
|
65
|
+
if ( !url || !$.mobile.path.isPath( url ) ) {
|
66
|
+
url = base;
|
67
|
+
}
|
68
|
+
|
69
|
+
return $.mobile.path.makeUrlAbsolute( url, base);
|
70
|
+
}
|
71
|
+
|
72
|
+
//simply set the active page's minimum height to screen height, depending on orientation
|
73
|
+
function getScreenHeight(){
|
74
|
+
var orientation = jQuery.event.special.orientationchange.orientation(),
|
75
|
+
port = orientation === "portrait",
|
76
|
+
winMin = port ? 480 : 320,
|
77
|
+
screenHeight = port ? screen.availHeight : screen.availWidth,
|
78
|
+
winHeight = Math.max( winMin, $( window ).height() ),
|
79
|
+
pageMin = Math.min( screenHeight, winHeight );
|
80
|
+
|
81
|
+
return pageMin;
|
82
|
+
}
|
83
|
+
|
84
|
+
function newResetActivePageHeight(){
|
85
|
+
var page=$( "." + $.mobile.activePageClass );
|
86
|
+
page.each(function(){
|
87
|
+
if($(this).closest(".panel-popover").length != 1){
|
88
|
+
$(this).css("min-height", getScreenHeight());
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
$(this).css("min-height", "100%")
|
92
|
+
}
|
93
|
+
});
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
//override _registerInternalEvents to bind to new methods below
|
98
|
+
$.mobile._registerInternalEvents = function(){
|
99
|
+
//DONE: bind form submit with this plugin
|
100
|
+
$("form").live('submit', function(event){
|
101
|
+
var $this = $( this );
|
102
|
+
if( !$.mobile.ajaxEnabled ||
|
103
|
+
$this.is( ":jqmData(ajax='false')" ) ){ return; }
|
104
|
+
|
105
|
+
var type = $this.attr("method"),
|
106
|
+
target = $this.attr("target"),
|
107
|
+
url = $this.attr( "action" ),
|
108
|
+
$currPanel=$this.parents('div:jqmData(role="panel")'),
|
109
|
+
$currPanelActivePage=$currPanel.children('div.'+$.mobile.activePageClass);
|
110
|
+
|
111
|
+
// If no action is specified, browsers default to using the
|
112
|
+
// URL of the document containing the form. Since we dynamically
|
113
|
+
// pull in pages from external documents, the form should submit
|
114
|
+
// to the URL for the source document of the page containing
|
115
|
+
// the form.
|
116
|
+
if ( !url ) {
|
117
|
+
// Get the @data-url for the page containing the form.
|
118
|
+
url = getClosestBaseUrl( $this );
|
119
|
+
if ( url === documentBase.hrefNoHash ) {
|
120
|
+
// The url we got back matches the document base,
|
121
|
+
// which means the page must be an internal/embedded page,
|
122
|
+
// so default to using the actual document url as a browser
|
123
|
+
// would.
|
124
|
+
url = documentUrl.hrefNoSearch;
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
url = $.mobile.path.makeUrlAbsolute( url, getClosestBaseUrl($this) );
|
129
|
+
|
130
|
+
//external submits use regular HTTP
|
131
|
+
if( $.mobile.path.isExternal( url ) || target ) {
|
132
|
+
return;
|
133
|
+
}
|
134
|
+
|
135
|
+
//temporarily put this here- eventually shud just set it immediately instead of an interim var.
|
136
|
+
$.mobile.activePage=$currPanelActivePage;
|
137
|
+
// $.mobile.pageContainer=$currPanel;
|
138
|
+
$.mobile.changePage(
|
139
|
+
url,
|
140
|
+
{
|
141
|
+
type: type && type.length && type.toLowerCase() || "get",
|
142
|
+
data: $this.serialize(),
|
143
|
+
transition: $this.jqmData("transition"),
|
144
|
+
direction: $this.jqmData("direction"),
|
145
|
+
reloadPage: true,
|
146
|
+
pageContainer:$currPanel
|
147
|
+
}
|
148
|
+
);
|
149
|
+
event.preventDefault();
|
150
|
+
});
|
151
|
+
|
152
|
+
//add active state on vclick
|
153
|
+
$( document ).bind( "vclick", function( event ) {
|
154
|
+
var link = findClosestLink( event.target );
|
155
|
+
if ( link ) {
|
156
|
+
if ( $.mobile.path.parseUrl( link.getAttribute( "href" ) || "#" ).hash !== "#" ) {
|
157
|
+
$( link ).closest( ".ui-btn" ).not( ".ui-disabled" ).addClass( $.mobile.activeBtnClass );
|
158
|
+
$( "." + $.mobile.activePageClass + " .ui-btn" ).not( link ).blur();
|
159
|
+
}
|
160
|
+
}
|
161
|
+
});
|
162
|
+
|
163
|
+
//DONE: link click event binding for changePage
|
164
|
+
//click routing - direct to HTTP or Ajax, accordingly
|
165
|
+
$(document).bind( "click", function(event) {
|
166
|
+
var link = findClosestLink(event.target);
|
167
|
+
if (!link){
|
168
|
+
return;
|
169
|
+
}
|
170
|
+
|
171
|
+
var $link = $(link),
|
172
|
+
//remove active link class if external (then it won't be there if you come back)
|
173
|
+
httpCleanup = function(){
|
174
|
+
window.setTimeout( function() { removeActiveLinkClass( true ); }, 200 );
|
175
|
+
};
|
176
|
+
|
177
|
+
//if there's a data-rel=back attr, go back in history
|
178
|
+
if( $link.is( ":jqmData(rel='back')" ) ) {
|
179
|
+
window.history.back();
|
180
|
+
return false;
|
181
|
+
}
|
182
|
+
|
183
|
+
//if ajax is disabled, exit early
|
184
|
+
if( !$.mobile.ajaxEnabled ){
|
185
|
+
httpCleanup();
|
186
|
+
//use default click handling
|
187
|
+
return;
|
188
|
+
}
|
189
|
+
|
190
|
+
var baseUrl = getClosestBaseUrl( $link ),
|
191
|
+
|
192
|
+
//get href, if defined, otherwise fall to null #
|
193
|
+
href = $.mobile.path.makeUrlAbsolute( $link.attr( "href" ) || "#", baseUrl );
|
194
|
+
|
195
|
+
// XXX_jblas: Ideally links to application pages should be specified as
|
196
|
+
// an url to the application document with a hash that is either
|
197
|
+
// the site relative path or id to the page. But some of the
|
198
|
+
// internal code that dynamically generates sub-pages for nested
|
199
|
+
// lists and select dialogs, just write a hash in the link they
|
200
|
+
// create. This means the actual URL path is based on whatever
|
201
|
+
// the current value of the base tag is at the time this code
|
202
|
+
// is called. For now we are just assuming that any url with a
|
203
|
+
// hash in it is an application page reference.
|
204
|
+
if ( href.search( "#" ) != -1 ) {
|
205
|
+
href = href.replace( /[^#]*#/, "" );
|
206
|
+
if ( !href ) {
|
207
|
+
//link was an empty hash meant purely
|
208
|
+
//for interaction, so we ignore it.
|
209
|
+
event.preventDefault();
|
210
|
+
return;
|
211
|
+
} else if ( $.mobile.path.isPath( href ) ) {
|
212
|
+
//we have apath so make it the href we want to load.
|
213
|
+
href = $.mobile.path.makeUrlAbsolute( href, baseUrl );
|
214
|
+
} else {
|
215
|
+
//we have a simple id so use the documentUrl as its base.
|
216
|
+
href = $.mobile.path.makeUrlAbsolute( "#" + href, documentUrl.hrefNoHash );
|
217
|
+
}
|
218
|
+
}
|
219
|
+
|
220
|
+
// Should we handle this link, or let the browser deal with it?
|
221
|
+
var useDefaultUrlHandling = $link.is( "[rel='external']" ) || $link.is( ":jqmData(ajax='false')" ) || $link.is( "[target]" ),
|
222
|
+
// Some embedded browsers, like the web view in Phone Gap, allow cross-domain XHR
|
223
|
+
// requests if the document doing the request was loaded via the file:// protocol.
|
224
|
+
// This is usually to allow the application to "phone home" and fetch app specific
|
225
|
+
// data. We normally let the browser handle external/cross-domain urls, but if the
|
226
|
+
// allowCrossDomainPages option is true, we will allow cross-domain http/https
|
227
|
+
// requests to go through our page loading logic.
|
228
|
+
isCrossDomainPageLoad = ( $.mobile.allowCrossDomainPages && documentUrl.protocol === "file:" && href.search( /^https?:/ ) != -1 ),
|
229
|
+
|
230
|
+
//check for protocol or rel and its not an embedded page
|
231
|
+
//TODO overlap in logic from isExternal, rel=external check should be
|
232
|
+
// moved into more comprehensive isExternalLink
|
233
|
+
isExternal = useDefaultUrlHandling || ( $.mobile.path.isExternal( href ) && !isCrossDomainPageLoad ),
|
234
|
+
|
235
|
+
isRefresh=$link.jqmData('refresh'),
|
236
|
+
$targetPanel=$link.jqmData('panel'),
|
237
|
+
$targetContainer=$('div:jqmData(id="'+$targetPanel+'")'),
|
238
|
+
$targetPanelActivePage=$targetContainer.children('div.'+$.mobile.activePageClass),
|
239
|
+
$currPanel=$link.parents('div:jqmData(role="panel")'),
|
240
|
+
//not sure we need this. if you want the container of the element that triggered this event, $currPanel
|
241
|
+
$currContainer=$.mobile.pageContainer,
|
242
|
+
$currPanelActivePage=$currPanel.children('div.'+$.mobile.activePageClass),
|
243
|
+
url=$.mobile.path.stripHash($link.attr("href")),
|
244
|
+
from = null;
|
245
|
+
|
246
|
+
//still need this hack apparently:
|
247
|
+
$('.ui-btn.'+$.mobile.activeBtnClass).removeClass($.mobile.activeBtnClass);
|
248
|
+
$activeClickedLink = $link.closest( ".ui-btn" ).addClass($.mobile.activeBtnClass);
|
249
|
+
|
250
|
+
if( isExternal ) {
|
251
|
+
httpCleanup();
|
252
|
+
//use default click handling
|
253
|
+
return;
|
254
|
+
}
|
255
|
+
|
256
|
+
//use ajax
|
257
|
+
var transitionVal = $link.jqmData( "transition" ),
|
258
|
+
direction = $link.jqmData("direction"),
|
259
|
+
reverseVal = (direction && direction === "reverse") ||
|
260
|
+
// deprecated - remove by 1.0
|
261
|
+
$link.jqmData( "back" ),
|
262
|
+
//this may need to be more specific as we use data-rel more
|
263
|
+
role = $link.attr( "data-" + $.mobile.ns + "rel" ) || undefined,
|
264
|
+
hash = $currPanel.jqmData('hash');
|
265
|
+
|
266
|
+
//if link refers to an already active panel, stop default action and return
|
267
|
+
if ($targetPanelActivePage.attr('data-url') == url || $currPanelActivePage.attr('data-url') == url) {
|
268
|
+
if (isRefresh) { //then changePage below because it's a pageRefresh request
|
269
|
+
$.mobile.changePage(href, {fromPage:from, transition:'fade', reverse:reverseVal, changeHash:false, pageContainer:$targetContainer, reloadPage:isRefresh});
|
270
|
+
}
|
271
|
+
else { //else preventDefault and return
|
272
|
+
event.preventDefault();
|
273
|
+
return;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
//if link refers to a page on another panel, changePage on that panel
|
277
|
+
else if ($targetPanel && $targetPanel!=$link.parents('div:jqmData(role="panel")')) {
|
278
|
+
var from=$targetPanelActivePage;
|
279
|
+
$.mobile.pageContainer=$targetContainer;
|
280
|
+
$.mobile.changePage(href, {fromPage:from, transition:transitionVal, reverse:reverseVal, pageContainer:$targetContainer});
|
281
|
+
}
|
282
|
+
//if link refers to a page inside the same panel, changePage on that panel
|
283
|
+
else {
|
284
|
+
var from=$currPanelActivePage;
|
285
|
+
$.mobile.pageContainer=$currPanel;
|
286
|
+
var hashChange= (hash == 'false' || hash == 'crumbs')? false : true;
|
287
|
+
$.mobile.changePage(href, {fromPage:from, transition:transitionVal, reverse:reverseVal, changeHash:hashChange, pageContainer:$currPanel});
|
288
|
+
//active page must always point to the active page in main - for history purposes.
|
289
|
+
$.mobile.activePage=$('div:jqmData(id="main") > div.'+$.mobile.activePageClass);
|
290
|
+
}
|
291
|
+
event.preventDefault();
|
292
|
+
});
|
293
|
+
|
294
|
+
//prefetch pages when anchors with data-prefetch are encountered
|
295
|
+
//TODO: insert pageContainer in here!
|
296
|
+
$( ".ui-page" ).live( "pageshow.prefetch", function(){
|
297
|
+
var urls = [],
|
298
|
+
$thisPageContainer = $(this).parents('div:jqmData(role="panel")');
|
299
|
+
$( this ).find( "a:jqmData(prefetch)" ).each(function(){
|
300
|
+
var url = $( this ).attr( "href" ),
|
301
|
+
panel = $(this).jqmData('panel'),
|
302
|
+
container = panel.length? $('div:jqmData(id="'+panel+'")') : $thisPageContainer;
|
303
|
+
if ( url && $.inArray( url, urls ) === -1 ) {
|
304
|
+
urls.push( url );
|
305
|
+
$.mobile.loadPage( url, {pageContainer: container} );
|
306
|
+
}
|
307
|
+
});
|
308
|
+
});
|
309
|
+
|
310
|
+
//DONE: bind hashchange with this plugin
|
311
|
+
//hashchanges are defined only for the main panel - other panels should not support hashchanges to avoid ambiguity
|
312
|
+
$.mobile._handleHashChange = function( hash ) {
|
313
|
+
var to = $.mobile.path.stripHash( hash ),
|
314
|
+
transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined,
|
315
|
+
$mainPanel=$('div:jqmData(id="main")'),
|
316
|
+
$mainPanelFirstPage=$mainPanel.children('div:jqmData(role="page"):first'),
|
317
|
+
$mainPanelActivePage=$mainPanel.children('div.ui-page-active'),
|
318
|
+
$menuPanel=$('div:jqmData(id="menu")'),
|
319
|
+
$menuPanelFirstPage=$menuPanel.children('div:jqmData(role="page"):first'),
|
320
|
+
$menuPanelActivePage=$menuPanel.children('div.ui-page-active'),
|
321
|
+
//FIX: temp var for dialogHashKey
|
322
|
+
dialogHashKey = "&ui-state=dialog",
|
323
|
+
|
324
|
+
// default options for the changPage calls made after examining the current state
|
325
|
+
// of the page and the hash
|
326
|
+
changePageOptions = {
|
327
|
+
transition: transition,
|
328
|
+
changeHash: false,
|
329
|
+
fromHashChange: true,
|
330
|
+
pageContainer: $mainPanel
|
331
|
+
};
|
332
|
+
|
333
|
+
if( !$.mobile.hashListeningEnabled || $.mobile.urlHistory.ignoreNextHashChange ){
|
334
|
+
$.mobile.urlHistory.ignoreNextHashChange = false;
|
335
|
+
return;
|
336
|
+
}
|
337
|
+
|
338
|
+
// special case for dialogs
|
339
|
+
if( $.mobile.urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 ) {
|
340
|
+
|
341
|
+
// If current active page is not a dialog skip the dialog and continue
|
342
|
+
// in the same direction
|
343
|
+
if(!$.mobile.activePage.is( ".ui-dialog" )) {
|
344
|
+
//determine if we're heading forward or backward and continue accordingly past
|
345
|
+
//the current dialog
|
346
|
+
$.mobile.urlHistory.directHashChange({
|
347
|
+
currentUrl: to,
|
348
|
+
isBack: function() { window.history.back(); },
|
349
|
+
isForward: function() { window.history.forward(); }
|
350
|
+
});
|
351
|
+
|
352
|
+
// prevent changepage
|
353
|
+
return;
|
354
|
+
} else {
|
355
|
+
// var setTo = function() { to = $.mobile.urlHistory.getActive().pageUrl; };
|
356
|
+
// if the current active page is a dialog and we're navigating
|
357
|
+
// to a dialog use the dialog objected saved in the stack
|
358
|
+
// urlHistory.directHashChange({ currentUrl: to, isBack: setTo, isForward: setTo });
|
359
|
+
urlHistory.directHashChange({
|
360
|
+
currentUrl: to,
|
361
|
+
|
362
|
+
// regardless of the direction of the history change
|
363
|
+
// do the following
|
364
|
+
either: function( isBack ) {
|
365
|
+
var active = $.mobile.urlHistory.getActive();
|
366
|
+
|
367
|
+
to = active.pageUrl;
|
368
|
+
|
369
|
+
// make sure to set the role, transition and reversal
|
370
|
+
// as most of this is lost by the domCache cleaning
|
371
|
+
$.extend( changePageOptions, {
|
372
|
+
role: active.role,
|
373
|
+
transition: active.transition,
|
374
|
+
reverse: isBack
|
375
|
+
});
|
376
|
+
}
|
377
|
+
});
|
378
|
+
}
|
379
|
+
}
|
380
|
+
|
381
|
+
//if to is defined, load it
|
382
|
+
if ( to ){
|
383
|
+
to = ( typeof to === "string" && !$.mobile.path.isPath( to ) ) ? ( $.mobile.path.makeUrlAbsolute( '#' + to, documentBase ) ) : to;
|
384
|
+
//if this is initial deep-linked page setup, then changePage sidemenu as well
|
385
|
+
if (!$('div.ui-page-active').length) {
|
386
|
+
$menuPanelFirstPage='#'+$menuPanelFirstPage.attr('id');
|
387
|
+
$.mobile.changePage($menuPanelFirstPage, {transition:'none', reverse:true, changeHash:false, fromHashChange:false, pageContainer:$menuPanel});
|
388
|
+
$.mobile.activePage=undefined;
|
389
|
+
}
|
390
|
+
$.mobile.activePage=$mainPanelActivePage.length? $mainPanelActivePage : undefined;
|
391
|
+
$.mobile.changePage(to, changePageOptions );
|
392
|
+
} else {
|
393
|
+
//there's no hash, go to the first page in the main panel.
|
394
|
+
$.mobile.activePage=$mainPanelActivePage? $mainPanelActivePage : undefined;
|
395
|
+
$.mobile.changePage( $mainPanelFirstPage, changePageOptions );
|
396
|
+
}
|
397
|
+
};
|
398
|
+
|
399
|
+
//hashchange event handler
|
400
|
+
$(window).bind( "hashchange", function( e, triggered ) {
|
401
|
+
$.mobile._handleHashChange( location.hash );
|
402
|
+
});
|
403
|
+
|
404
|
+
//set page min-heights to be device specific
|
405
|
+
$( document ).bind( "pageshow.resetPageHeight", newResetActivePageHeight );
|
406
|
+
$( window ).bind( "throttledresize.resetPageHeight", newResetActivePageHeight );
|
407
|
+
|
408
|
+
}; //end _registerInternalEvents
|
409
|
+
|
410
|
+
//DONE: bind orientationchange and resize - the popover
|
411
|
+
_orientationHandler = function(event){
|
412
|
+
var $menu=$('div:jqmData(id="menu")'),
|
413
|
+
$main=$('div:jqmData(id="main")'),
|
414
|
+
$mainHeader=$main.find('div.'+$.mobile.activePageClass+'> div:jqmData(role="header")'),
|
415
|
+
$window=$(window);
|
416
|
+
|
417
|
+
function popoverBtn(header) {
|
418
|
+
if(!header.children('.popover-btn').length){
|
419
|
+
if(header.children('a.ui-btn-left').length){
|
420
|
+
header.children('a.ui-btn-left').replaceWith('<a class="popover-btn">Menu</a>');
|
421
|
+
header.children('a.popover-btn').addClass('ui-btn-left').buttonMarkup();
|
422
|
+
}
|
423
|
+
else{
|
424
|
+
header.prepend('<a class="popover-btn">Menu</a>');
|
425
|
+
header.children('a.popover-btn').addClass('ui-btn-left').buttonMarkup()
|
426
|
+
}
|
427
|
+
}
|
428
|
+
}
|
429
|
+
|
430
|
+
function replaceBackBtn(header) {
|
431
|
+
if($.mobile.urlHistory.stack.length > 1 && !header.children('a:jqmData(rel="back")').length && header.jqmData('backbtn')!=false){
|
432
|
+
header.prepend("<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"rel='back' data-"+ $.mobile.ns +"icon='arrow-l'>Back</a>" );
|
433
|
+
header.children('a:jqmData(rel="back")').buttonMarkup();
|
434
|
+
}
|
435
|
+
};
|
436
|
+
|
437
|
+
function popover(){
|
438
|
+
$menu.addClass('panel-popover')
|
439
|
+
.removeClass('ui-panel-left')
|
440
|
+
.css({'width':'25%', 'min-width':'250px', 'display':'', 'overflow-x':'visible'});
|
441
|
+
if(!$menu.children('.popover_triangle').length){
|
442
|
+
$menu.prepend('<div class="popover_triangle"></div>');
|
443
|
+
}
|
444
|
+
$menu.children('.' + $.activePageClass).css('min-height', '100%');
|
445
|
+
$main.removeClass('ui-panel-right')
|
446
|
+
.css('width', '');
|
447
|
+
popoverBtn($mainHeader);
|
448
|
+
|
449
|
+
$main.undelegate('div:jqmData(role="page")', 'pagebeforeshow.splitview');
|
450
|
+
$main.delegate('div:jqmData(role="page")','pagebeforeshow.popover', function(){
|
451
|
+
var $thisHeader=$(this).children('div:jqmData(role="header")');
|
452
|
+
popoverBtn($thisHeader);
|
453
|
+
});
|
454
|
+
// TODO: unbind resetActivePageHeight for popover pages
|
455
|
+
|
456
|
+
};
|
457
|
+
|
458
|
+
function splitView(){
|
459
|
+
$menu.removeClass('panel-popover')
|
460
|
+
.addClass('ui-panel-left')
|
461
|
+
.css({'width':'25%', 'min-width':'250px', 'display':''});
|
462
|
+
$menu.children('.popover_triangle').remove();
|
463
|
+
$main.addClass('ui-panel-right')
|
464
|
+
.width(function(){
|
465
|
+
return $(window).width()-$('div:jqmData(id="menu")').width();
|
466
|
+
});
|
467
|
+
$mainHeader.children('.popover-btn').remove();
|
468
|
+
|
469
|
+
// replaceBackBtn($mainHeader);
|
470
|
+
|
471
|
+
$main.undelegate('div:jqmData(role="page")', 'pagebeforeshow.popover');
|
472
|
+
$main.delegate('div:jqmData(role="page")', 'pagebeforeshow.splitview', function(){
|
473
|
+
var $thisHeader=$(this).children('div:jqmData(role="header")');
|
474
|
+
$thisHeader.children('.popover-btn').remove();
|
475
|
+
// replaceBackBtn($thisHeader);
|
476
|
+
});
|
477
|
+
|
478
|
+
}
|
479
|
+
|
480
|
+
if(event.orientation){
|
481
|
+
if(event.orientation == 'portrait'){
|
482
|
+
popover();
|
483
|
+
}
|
484
|
+
else if(event.orientation == 'landscape') {
|
485
|
+
splitView();
|
486
|
+
}
|
487
|
+
}
|
488
|
+
else if($window.width() < 768 && $window.width() > 480){
|
489
|
+
popover();
|
490
|
+
}
|
491
|
+
else if($window.width() > 768){
|
492
|
+
splitView();
|
493
|
+
}
|
494
|
+
};
|
495
|
+
|
496
|
+
$(window).bind('orientationchange', _orientationHandler);
|
497
|
+
$(window).bind('throttledresize', _orientationHandler);
|
498
|
+
|
499
|
+
//popover button click handler - from http://www.cagintranet.com/archive/create-an-ipad-like-dropdown-popover/
|
500
|
+
$('.popover-btn').live('click', function(e){
|
501
|
+
e.preventDefault();
|
502
|
+
$('.panel-popover').fadeToggle('fast');
|
503
|
+
if ($('.popover-btn').hasClass($.mobile.activeBtnClass)) {
|
504
|
+
$('.popover-btn').removeClass($.mobile.activeBtnClass);
|
505
|
+
} else {
|
506
|
+
$('.popover-btn').addClass($.mobile.activeBtnClass);
|
507
|
+
}
|
508
|
+
});
|
509
|
+
|
510
|
+
$('body').live('click', function(event) {
|
511
|
+
if (!$(event.target).closest('.panel-popover').length && !$(event.target).closest('.popover-btn').length) {
|
512
|
+
$(".panel-popover").stop(true, true).hide();
|
513
|
+
$('.popover-btn').removeClass($.mobile.activeBtnClass);
|
514
|
+
};
|
515
|
+
});
|
516
|
+
|
517
|
+
|
518
|
+
//----------------------------------------------------------------------------------
|
519
|
+
//Other event bindings: scrollview, crumbs, data-context and content height adjustments
|
520
|
+
//----------------------------------------------------------------------------------
|
521
|
+
|
522
|
+
//DONE: pageshow binding for scrollview - now using IScroll4! hell yeah!
|
523
|
+
$('div:jqmData(role="page")').live('pagebeforeshow.scroll', function(event, ui){
|
524
|
+
if ($.support.touch && !$.support.touchOverflow) {
|
525
|
+
|
526
|
+
var $page = $(this),
|
527
|
+
$scrollArea = $page.find('div:jqmData(role="content")');
|
528
|
+
$scrAreaChildren = $scrollArea.children();
|
529
|
+
|
530
|
+
if ($scrAreaChildren.length > 1) {
|
531
|
+
$scrAreaChildren = $scrollArea.wrapInner("<div class='scrollable vertical'></div>").children();
|
532
|
+
}
|
533
|
+
$scrollArea.css({ 'width':'auto',
|
534
|
+
'height':'auto',
|
535
|
+
'overflow':'hidden'});
|
536
|
+
//TODO: if too many pages are in the DOM that have iscroll on, this might slow down the browser significantly,
|
537
|
+
//in which case we'll need to destroy() the iscroll as the page hides.
|
538
|
+
$scrollArea.iscroll();
|
539
|
+
}
|
540
|
+
});
|
541
|
+
|
542
|
+
//data-hash 'crumbs' handler
|
543
|
+
//now that data-backbtn is no longer defaulting to true, lets set crumbs to create itself even when backbtn is not available
|
544
|
+
$('div:jqmData(role="page")').live('pagebeforeshow.crumbs', function(event, data){
|
545
|
+
var $this = $(this);
|
546
|
+
if($this.jqmData('hash') == 'crumbs' || $this.parents('div:jqmData(role="panel")').data('hash') == 'crumbs'){
|
547
|
+
if($this.jqmData('hash')!=false && $this.find('.ui-crumbs').length < 1){
|
548
|
+
var $header=$this.find('div:jqmData(role="header")');
|
549
|
+
backBtn = $this.find('a:jqmData(rel="back")');
|
550
|
+
|
551
|
+
if(data.prevPage.jqmData('url') == $this.jqmData('url')){ //if it's a page refresh
|
552
|
+
var prevCrumb = data.prevPage.find('.ui-crumbs');
|
553
|
+
crumbify(backBtn, prevCrumb.attr('href'), prevCrumb.find('.ui-btn-text').html());
|
554
|
+
}
|
555
|
+
else if($.mobile.urlHistory.stack.length > 0) {
|
556
|
+
var text = data.prevPage.find('div:jqmData(role="header") .ui-title').html();
|
557
|
+
crumbify(backBtn, '#'+data.prevPage.jqmData('url'), text);
|
558
|
+
}
|
559
|
+
else if(backBtn.length && $.mobile.urlHistory.stack.length <= 1) {
|
560
|
+
backBtn.remove();
|
561
|
+
}
|
562
|
+
}
|
563
|
+
}
|
564
|
+
|
565
|
+
function crumbify(button, href, text){
|
566
|
+
if(!button.length) {
|
567
|
+
$this.find('div:jqmData(role="header")').prepend('<a class="ui-crumbs ui-btn-left" data-icon="arrow-l"></a>');
|
568
|
+
button=$header.children('.ui-crumbs').buttonMarkup();
|
569
|
+
}
|
570
|
+
button.removeAttr('data-rel')
|
571
|
+
.jqmData('direction','reverse')
|
572
|
+
.addClass('ui-crumbs')
|
573
|
+
.attr('href',href);
|
574
|
+
button.find('.ui-btn-text').html(text);
|
575
|
+
}
|
576
|
+
});
|
577
|
+
|
578
|
+
//data-context handler - a page with a link that has a data-context attribute will load that page after this page loads
|
579
|
+
//this still needs work - pageTransitionQueue messes everything up.
|
580
|
+
$('div:jqmData(role="panel")').live('pagechange.context', function(){
|
581
|
+
var $this=$(this),
|
582
|
+
$currPanelActivePage = $this.children('.' + $.mobile.activePageClass),
|
583
|
+
panelContextSelector = $this.jqmData('context'),
|
584
|
+
pageContextSelector = $currPanelActivePage.jqmData('context'),
|
585
|
+
contextSelector= pageContextSelector ? pageContextSelector : panelContextSelector;
|
586
|
+
//if you pass a hash into data-context, you need to specify panel, url and a boolean value for refresh
|
587
|
+
if($.type(contextSelector) === 'object') {
|
588
|
+
var $targetContainer=$('div:jqmData(id="'+contextSelector.panel+'")'),
|
589
|
+
$targetPanelActivePage=$targetContainer.children('div.'+$.mobile.activePageClass),
|
590
|
+
isRefresh = contextSelector.refresh === undefined ? false : contextSelector.refresh;
|
591
|
+
if(($targetPanelActivePage.jqmData('url') == contextSelector.url && contextSelector.refresh)||(!contextSelector.refresh && $targetPanelActivePage.jqmData('url') != contextSelector.url)){
|
592
|
+
$.mobile.changePage(contextSelector.url, options={transition:'fade', changeHash:false, pageContainer:$targetContainer, reloadPage:isRefresh});
|
593
|
+
}
|
594
|
+
}
|
595
|
+
else if(contextSelector && $currPanelActivePage.find(contextSelector).length){
|
596
|
+
$currPanelActivePage.find(contextSelector).trigger('click');
|
597
|
+
}
|
598
|
+
});
|
599
|
+
|
600
|
+
//this measures the height of header and footer and sets content to the appropriate height so
|
601
|
+
// that no content is concealed behind header and footer
|
602
|
+
$('div:jqmData(role="page")').live('pageshow.contentHeight', function(){
|
603
|
+
var $this=$(this),
|
604
|
+
$header=$this.children(':jqmData(role="header")'),
|
605
|
+
$footer=$this.children(':jqmData(role="footer")'),
|
606
|
+
thisHeaderHeight=$header.css('display') == 'none' ? 0 : $header.outerHeight(),
|
607
|
+
thisFooterHeight=$footer.css('display') == 'none' ? 0 : $footer.outerHeight();
|
608
|
+
// $this.children(':jqmData(role="content")').css({'top':thisHeaderHeight, 'bottom':thisFooterHeight});
|
609
|
+
})
|
610
|
+
|
611
|
+
//this allows panels to change their widths upon changepage - useful for pages that need a different width than the ones provided.
|
612
|
+
// $('div:jqmData(role="page")').live('')
|
613
|
+
}
|
614
|
+
else {
|
615
|
+
//removes all panels so the page behaves like a single panel jqm
|
616
|
+
$(function(){
|
617
|
+
$('div:jqmData(role="panel")').each(function(){
|
618
|
+
var $this = $(this);
|
619
|
+
$this.replaceWith($this.html());
|
620
|
+
})
|
621
|
+
});
|
622
|
+
}
|
623
|
+
});
|
624
|
+
})(jQuery,window);
|