Permalink
Browse files

progressing with navigation and hashchange

  • Loading branch information...
1 parent 755d54f commit 7d3e8ac465501cce817ce619c2144f9f095f4482 @frequent committed Apr 18, 2012
Showing with 172,962 additions and 1,983 deletions.
  1. BIN Private/Multiview Plugin.doc
  2. +242 −0 Private/QS/panelHash.js
  3. +242 −0 Private/QS/panelHash.txt
  4. +499 −0 Private/SAFE/bin/customselect.js
  5. +122 −0 Private/SAFE/bin/dummy1.html
  6. +797 −0 Private/SAFE/bin/dummy2.html
  7. +178 −0 Private/SAFE/bin/dummy3.html
  8. +60 −0 Private/SAFE/bin/dummy4.html
  9. +9,050 −0 Private/SAFE/bin/jq.js
  10. +55 −0 Private/SAFE/bin/jqm-Docs.js
  11. +2 −0 Private/SAFE/bin/jqmrc3.css
  12. +1,892 −0 Private/SAFE/bin/jquery.mobile-1.0rc2.css
  13. +99 −0 Private/SAFE/bin/junk.js
  14. +132 −0 Private/SAFE/bin/junk2.js
  15. +6,957 −0 Private/SAFE/bin/rc3.js
  16. +172 −0 Private/SAFE/bin/rc3docs.min.js
  17. +342 −0 Private/SAFE/bin/some.css
  18. +38 −0 Private/SAFE/bin/themeswitcher.js
  19. +7,112 −0 Private/SAFE/jquery.mobile-1.0/jquery.mobile-1.0multiview_2011-11-30_broken.js
  20. BIN Private/SAFE/jquery.mobile-1.0rc1/images/Thumbs.db
  21. BIN Private/SAFE/jquery.mobile-1.0rc1/images/ajax-loader.png
  22. BIN Private/SAFE/jquery.mobile-1.0rc1/images/icons-18-black.png
  23. BIN Private/SAFE/jquery.mobile-1.0rc1/images/icons-18-white.png
  24. BIN Private/SAFE/jquery.mobile-1.0rc1/images/icons-36-black.png
  25. BIN Private/SAFE/jquery.mobile-1.0rc1/images/icons-36-white.png
  26. +1,749 −0 Private/SAFE/jquery.mobile-1.0rc1/jquery.mobile-1.0rc1.css
  27. +6,769 −0 Private/SAFE/jquery.mobile-1.0rc1/jquery.mobile-1.0rc1.js
  28. +6,964 −0 Private/SAFE/jquery.mobile-1.0rc1/jquery.mobile-1.0rc1MOD2splitview.js
  29. +7,047 −0 Private/SAFE/jquery.mobile-1.0rc2/jquery.mobile-1.0rc2MOD2splitview_2011-11-12.js
  30. +7,112 −0 Private/SAFE/jquery.mobile-1.0rc2/jquery.mobile-1.0rc2MOD2splitview_2011-11-16.js
  31. +390 −0 Private/SAFE/plugins/jquery-mobile-overrides.js
  32. +1,452 −0 Private/SAFE/plugins/jquery.mobile.multiviewMOD2.js
  33. +892 −0 Private/SAFE/plugins/jquery.mobile.multiviewMOD2_2011-11-08.js
  34. +884 −0 Private/SAFE/plugins/jquery.mobile.multiviewMOD2_2011-11-12-NC version.js
  35. +1,673 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-22.js
  36. +1,712 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-22_redo-trigger-create.js
  37. +1,772 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-23_createobject.js
  38. +1,684 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-25
  39. +1,684 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-25.js
  40. +1,663 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-26
  41. +1,663 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-26.js
  42. +1,662 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-29-v2.js.js
  43. +1,662 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-29.js
  44. +1,631 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-30_broken.js.js
  45. +1,703 −0 Private/SAFE/plugins/jquery.mobile.multiview_2011-11-30_save
  46. +639 −0 Private/SAFE/plugins/jquery.mobile.splitviewRC1.js
  47. +7,114 −0 Private/SAFE/safetys/2011-11-30/jquery.mobile-1.0multiview.js
  48. +325 −0 Private/SAFE/safetys/2011-11-30/jquery.mobile.multiview.css
  49. +1,649 −0 Private/SAFE/safetys/2011-11-30/jquery.mobile.multiview.js
  50. +318 −0 Private/SAFE/safetys/2011-12-01/jquery.mobile.multiview_2011-12-01broken.css
  51. +7,114 −0 Private/SAFE/safetys/2011-12-04/jquery.mobile-1.0multiview_2011-12-04.js
  52. +243 −0 Private/SAFE/safetys/2011-12-04/jquery.mobile.multiview_2011-12-04.css
  53. +1,691 −0 Private/SAFE/safetys/2011-12-04/jquery.mobile.multiview_2011-12-04.js
  54. +7,128 −0 Private/SAFE/safetys/2011-12-07/jquery.mobile-1.0multiview_2011-12-07.js
  55. +1,778 −0 Private/SAFE/safetys/2011-12-07/jquery.mobile.multiview_2011-12-07.js
  56. +1,810 −0 Private/SAFE/safetys/2011-12-07/jquery.mobile.multiview_2011-12-07B.js
  57. +7,128 −0 Private/SAFE/safetys/2011-12-14/jquery.mobile-1.0multiview.js
  58. +243 −0 Private/SAFE/safetys/2011-12-14/jquery.mobile.multiview.css
  59. +1,810 −0 Private/SAFE/safetys/2011-12-14/jquery.mobile.multiview.js
  60. +802 −0 Private/SAFE/safetys/2011-12-14/jquery.mobile.scrollview.js
  61. +134 −0 Private/SAFE/style/jquery.mobile.multiview_2011-11-27.css
  62. +253 −0 Private/SAFE/style/jquery.mobile.multiview_2011-11-29.css
  63. +253 −0 Private/SAFE/style/jquery.mobile.multiview_2011-11-29a.css
  64. +255 −0 Private/SAFE/style/jquery.mobile.multiview_2011-11-29broken.css
  65. BIN Private/kin/ajax-loader.png
  66. +874 −0 Private/kin/custom.css
  67. BIN Private/kin/icons-18-black.png
  68. BIN Private/kin/icons-18-white.png
  69. BIN Private/kin/icons-36-black.png
  70. BIN Private/kin/icons-36-white.png
  71. +4 −0 Private/kin/jquery-1.7.1.min.js
  72. +177 −0 Private/kin/jquery.mobile-1.0.1.min.js
  73. +7,508 −0 Private/kin/jquery.mobile-1.0.1multiview.js
  74. +1,992 −0 Private/kin/multiview.js
  75. +270 −0 Private/kin/plugins.css
  76. +143 −0 Private/kin/sample.html
  77. +742 −0 Private/kin/structure.css
  78. +874 −0 Safe/2012-04-10/custom.css
  79. BIN Safe/2012-04-10/images/Thumbs.db
  80. BIN Safe/2012-04-10/images/ajax-loader.png
  81. BIN Safe/2012-04-10/images/icons-18-black.png
  82. BIN Safe/2012-04-10/images/icons-18-white.png
  83. BIN Safe/2012-04-10/images/icons-36-black.png
  84. BIN Safe/2012-04-10/images/icons-36-white.png
  85. +4 −0 Safe/2012-04-10/jquery-1.7.1.min.js
  86. +177 −0 Safe/2012-04-10/jquery.mobile-1.0.1.min.js
  87. +7,508 −0 Safe/2012-04-10/jquery.mobile-1.0.1multiview.js
  88. +2,053 −0 Safe/2012-04-10/jquery.mobile-1.1.0-rc.2.css
  89. +7,551 −0 Safe/2012-04-10/jquery.mobile-1.1.0.rc2.js
  90. +16 −0 Safe/2012-04-10/jquery.mobile.extension.fixed-toolbars.css
  91. +90 −0 Safe/2012-04-10/jquery.mobile.extension.fixed-toolbars.js
  92. +2,053 −0 Safe/2012-04-10/jquery.mobile.structure-1.1.0-rc.2.css
  93. +228 −0 Safe/2012-04-10/multiview.css
  94. +2,588 −0 Safe/2012-04-10/multiview.js
  95. +222 −0 Safe/2012-04-10/sample.html
  96. +742 −0 Safe/2012-04-10/structure.css
  97. BIN Safe/2012-04-16/images/Thumbs.db
  98. BIN Safe/2012-04-16/images/ajax-loader.png
  99. BIN Safe/2012-04-16/images/icons-18-black.png
  100. BIN Safe/2012-04-16/images/icons-18-white.png
  101. BIN Safe/2012-04-16/images/icons-36-black.png
  102. BIN Safe/2012-04-16/images/icons-36-white.png
  103. +4 −0 Safe/2012-04-16/jquery-1.7.1.min.js
  104. +2,053 −0 Safe/2012-04-16/jquery.mobile-1.1.0-rc.2.css
  105. +7,552 −0 Safe/2012-04-16/jquery.mobile-1.1.0.rc2.js
  106. +200 −0 Safe/2012-04-16/multiview.css
  107. +2,894 −0 Safe/2012-04-16/multiview.js
  108. +304 −0 Safe/2012-04-16/sample-fixed.html
  109. +314 −0 Safe/2012-04-16/sample-headwrap.html
  110. +307 −0 Safe/2012-04-16/sample-nav.html
  111. +303 −0 Safe/2012-04-16/sample-over.html
  112. +304 −0 Safe/2012-04-16/sample-yield.html
  113. +304 −0 Safe/2012-04-16/sample.html
  114. +1,860 −1,803 multiview JQM 1.0.1/jquery.mobile.multiview.js
  115. +288 −176 multiview JQM 1.1.RC2/multiview.js
  116. +1 −1 multiview JQM 1.1.RC2/sample-headwrap.html
  117. +10 −1 multiview JQM 1.1.RC2/sample-nav.html
  118. +2 −2 multiview JQM 1.1.RC2/sample.html
Binary file not shown.
View
@@ -0,0 +1,242 @@
+
+
+// ------------ Panel-History Routine -------------------
+
+// Currently my pageContainer-history routine is setup inside JQM RC2 _mobileHashChange (see below - 2.)
+// I want to remove it from there and put it into the plugin's panelHash function (below 1.)
+
+// PROBLEM:
+// I cannot call panelHash, either by binding to something or by calling it from
+// inside _handleHashChange
+
+// DETAILS:
+// JQM calls _handleHashChange on two occasions:
+// (a) hashchange event handler
+// (b) pushstate handle
+
+// in my current setup I just hooked into _handleHashChange and did my rountine there.
+// When I remove my rountine into a stand-alone function inside my plugin I need to
+// find a way to fire this plugin-function alongside _handleHashChange
+
+// I tried (a) binding to $window.bind( "hashchange", function( e, triggered ), but this
+// seems to fire on every pagechange if set inside my plugin, plus I cannot capture
+// the pushState firing (b)
+
+// Therefore I now want to fire panelHash from inside _mobileHashChange by checking for
+// n>0 (panels on the page). If n>0 I call the panelHash function, if not , JQM continues
+// as normal.
+// I don't like this AND I can't get it to work.
+
+// QUESTION: Is there a way to bind to "_handleHashChange being fired" (preferred) or how
+// can I call a public function in widget-factory plugin 1 from inside widget-factory plugin 2?
+
+// THANKS FOR HELP!
+
+
+
+// 1. plugin panel hash function (nothing special):
+
+ panelHash: function( hash ) {
+
+ console.log("panelHash fired");
+
+ // make function public
+ $.mobile.multiview.panelHash = panelHash;
+ },
+
+
+
+
+
+// 2. modified JQM _handleHashChange (with comments... notes of changes @ XXX FREQUENT)
+
+$.mobile._handleHashChange = function( hash ) {
+
+
+ //find first page via hash
+ var to = path.stripHash( hash ),
+
+ // XXX FREQUENT: panel-transition routine, activates if panels on the page with data-hash="history"
+ $panels = $('div:jqmData(hash="history")'),
+ n = $panels.length,
+
+ //transition is false if it's the first page, undefined otherwise (and may be overridden by default)
+ transition = ( $.mobile.urlHistory.stack.length === 0 || n == 0 ) ? "none" : undefined,
+
+ // default options for the changPage calls made after examining the current state
+ // of the page and the hash
+ // XXX FREQUENT: added pageContainer as new option
+ changePageOptions = {
+ transition: transition,
+ changeHash: false,
+ fromHashChange: true,
+ pageContainer: null,
+ };
+
+ //if listening is disabled (either globally or temporarily), or it's a dialog hash
+ if( !$.mobile.hashListeningEnabled || urlHistory.ignoreNextHashChange ) {
+ urlHistory.ignoreNextHashChange = false;
+ return;
+ }
+
+ // special case for dialogs
+ if( urlHistory.stack.length > 1 && to.indexOf( dialogHashKey ) > -1 ) {
+
+ // If current active page is not a dialog skip the dialog and continue
+ // in the same direction
+ if(!$.mobile.activePage.is( ".ui-dialog" )) {
+ //determine if we're heading forward or backward and continue accordingly past
+ //the current dialog
+ urlHistory.directHashChange({
+ currentUrl: to,
+ isBack: function() { window.history.back(); },
+ isForward: function() { window.history.forward(); }
+ });
+
+ // prevent changePage()
+ return;
+ } else {
+ // if the current active page is a dialog and we're navigating
+ // to a dialog use the dialog objected saved in the stack
+ urlHistory.directHashChange({
+ currentUrl: to,
+
+ // regardless of the direction of the history change
+ // do the following
+ either: function( isBack ) {
+ var active = $.mobile.urlHistory.getActive();
+
+ to = active.pageUrl;
+
+ // make sure to set the role, transition and reversal
+ // as most of this is lost by the domCache cleaning
+ $.extend( changePageOptions, {
+ role: active.role,
+ transition: active.transition,
+ reverse: isBack
+ });
+ }
+ });
+ }
+ }
+
+ // XXX FREQUENT
+ // ------------ RELOCATE TO PLUGIN -------------------
+ // create combined array of highest panel-history stacks
+ // (if 3 stacks with 2 entries each, the combo-array
+ // longest[] will contain 3 arrays [array1, array2, array3]
+ // and each array will contain two entries
+ //
+ // entries are made by stackUp() function in multiview plugin
+ // TODO: recheck
+
+ var longest = [],
+ longestLen = 0;
+
+ $panels.each(function(){
+ var data = $(this).data("stack");
+ if(data.length > longestLen){
+ longest = [data];
+ longestLen = data.length;
+ }
+ else if(data.length == longestLen) {
+ longest.push(data);
+ }
+ });
+
+ // prepare cleanup, add stackTrigger class
+ $panels.each(function() {
+ if ( $(this).data("stack").length == longestLen ) {
+ $(this).addClass("stackTrigger");
+ }
+ });
+
+ // ------------ END -------------------
+
+ //if to is defined, load it
+ if ( to ) {
+ // At this point, 'to' can be one of 3 things, a cached page element from
+ // a history stack entry, an id, or site-relative/absolute URL. If 'to' is
+ // an id, we need to resolve it against the documentBase, not the location.href,
+ // since the hashchange could've been the result of a forward/backward navigation
+ // that crosses from an external page/dialog to an internal page/dialog.
+ to = ( typeof to === "string" && !path.isPath( to ) ) ? ( path.makeUrlAbsolute( '#' + to, documentBase ) ) : to;
+
+ // XXX - FREQUENT - panel history-stack routine
+ // ------------ REMOVE INTO PLUGIN -------------------
+ // TODO: check for n>0 here, if yes, preventdefault() and reroute to plugin panelHash
+ // TODO: panelHash last option should be regular hashChange call in case all panels are in basic setup
+
+ // only override JQM-history if panels are used and [removed for now] all panels are not in basic setup (all panels at stack height = 1)
+ if ( n>0 ) {
+ // if ( n>0 && longest.length/n != 1 ) {
+
+ // [ok] single highest panel can only be a popover or fullwidth panel, as menu and main increase together
+ if (longest.length == 1 ) {
+ var gotoPage = longest[0][longestLen-2].toString();
+ }
+
+ if (longest.length == 2 ) {
+ var $last0 = longest[0][longestLen-1].toString(),
+ $last1 = longest[1][longestLen-1].toString();
+
+ //[ok] main/menu (increase simultaneously - passive entry = "yield")
+ // backwards transition should be made to last entry not being yield
+ // starting from stackHeight-1 (otherwise result will be currently
+ // active page
+ if ( $last0 == "yield" ) {
+ for (i = longestLen-2; i>=0; i--) {
+ if ( longest[1][i].toString() != "yield") {
+ var gotoPage = longest[1][i].toString();
+ break;
+ }
+ }
+ } else if ($last1 == "yield" ) {
+ for (i = longestLen-2; i>=0; i--) {
+ if ( longest[0][i].toString() != "yield") {
+ var gotoPage = longest[0][i].toString();
+ break;
+ }
+ }
+ } else {
+ // TODO: fullwidth/popover (popover always goes first until in basic mode)
+ // if ( $( $last0 ).closest(':jqmData(role="panel")') != "popover" || $( $last1 ).closest(':jqmData(role="panel")') == "popover" )
+ }
+
+ }
+
+ if (longest.length >= 3) {
+ // 3 panels with same stack height, should always be a popover (with main/menu at same stack-height = popover goes first
+ // TODO: doesn't work if menu/main stack height > popover stack height...
+ // TODO: change logic so that popover always goes first until it's back to setup-level, then change back on main/menu
+ var $last = [];
+ for ( var i = 0; i < longest.length; i++) {
+ $last.push( longest[i][ longest[i].length - 1 ] );
+ if ( $( $last[i] ).closest(':jqmData(role="panel")').jqmData('panel') == "popover" ) {
+ var gotoPage = $last[i];
+ }
+ }
+ }
+
+ // declare fromPage, because otherwise JQM removes .ui-page-active from the wrong panel (= active page in main panel);
+ var fromPage = $( gotoPage ).closest(':jqmData(role="panel")').find('.ui-page-active'),
+ changePageOptions = { fromPage: fromPage, pageContainer: $( gotoPage ).closest('div:jqmData(role="panel")'), fromHashChange: true };
+
+ $.mobile.changePage ( gotoPage, changePageOptions );
+
+ // cleanUp
+ $('.stackTrigger').each(function() {
+ $(this).data('stack').pop();
+ });
+ $('.stackTrigger').removeClass('stackTrigger');
+
+ } else {
+ // TODO: not working
+ $.mobile.changePage( to, changePageOptions );
+ }
+ // ------------ END -------------------
+ } else {
+ //there's no hash, go to the first page in the dom
+ $.mobile.changePage( $.mobile.firstPage, changePageOptions );
+ }
+ };
Oops, something went wrong.

0 comments on commit 7d3e8ac

Please sign in to comment.