templates/mobile/jquery.mobile.js in compass-jquery-plugin-0.3.2.5 vs templates/mobile/jquery.mobile.js in compass-jquery-plugin-0.3.2.6

- old
+ new

@@ -1472,52 +1472,12 @@ SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91 // COMMAND - } - }); - - //define vars for interal use - var $window = $(window), - $html = $("html"), - $head = $("head"), - - //loading div which appears during Ajax requests - //will not appear if $.mobile.loadingMessage is false - $loader = $.mobile.loadingMessage ? - $("<div class='ui-loader ui-body-a ui-corner-all'>" + - "<span class='ui-icon ui-icon-loading spin'></span>" + - "<h1>" + $.mobile.loadingMessage + "</h1>" + - "</div>") - : undefined; - - //expose some core utilities - $.extend($.mobile, { - - // turn on/off page loading message. - pageLoading: function (done) { - if (done) { - $html.removeClass("ui-loading"); - } else { - if ($.mobile.loadingMessage) { - var activeBtn = $("." + $.mobile.activeBtnClass).first(); - - $loader - .appendTo($.mobile.pageContainer) - //position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top - .css({ - top: $.support.scrollTop && $(window).scrollTop() + $(window).height() / 2 || - activeBtn.length && activeBtn.offset().top || 100 - }); - } - - $html.addClass("ui-loading"); - } }, - //scroll page vertically: scroll to 0 to hide iOS address bar, or pass a Y value silentScroll: function(ypos) { ypos = ypos || 0; // prevent scrollstart and scrollstop events $.event.special.scrollstart.enabled = false; @@ -1651,10 +1611,35 @@ //wipe urls ahead of active index clearForward: function() { urlHistory.stack = urlHistory.stack.slice(0, urlHistory.activeIndex + 1); }, + directHashChange: function(opts) { + var back , forward, newActiveIndex; + + // check if url isp in history and if it's ahead or behind current page + $.each(urlHistory.stack, function(i, historyEntry) { + + //if the url is in the stack, it's a forward or a back + if (opts.currentUrl === historyEntry.url) { + //define back and forward by whether url is older or newer than current page + back = i < urlHistory.activeIndex; + forward = !back; + newActiveIndex = i; + } + }); + + // save new page index, null check to prevent falsey 0 result + this.activeIndex = newActiveIndex !== undefined ? newActiveIndex : this.activeIndex; + + if (back) { + opts.isBack(); + } else if (forward) { + opts.isForward(); + } + }, + //disable hashchange event listener internally to ignore one change //toggled internally when location.hash is updated to match the url of a successful page load ignoreNextHashChange: true }, @@ -1712,11 +1697,11 @@ //define base element, for use in routing asset urls that are referenced in Ajax-requested markup element: ($base.length ? $base : $("<base>", { href: docBase }).prependTo($head)), //set the generated BASE element's href attribute to a new page's base path set: function(href) { - base.element.attr('href', docBase + path.get(href)); + base.element.attr('href', docBase + path.get(href).replace(/^\//, "")); }, //set the generated BASE element's href attribute to a new page's base path reset: function() { base.element.attr('href', docBase); @@ -1758,10 +1743,11 @@ return $(this).one('webkitAnimationEnd', callback); } else { // defer execution for consistency between webkit/non webkit setTimeout(callback, 0); + return $(this); } }; /* exposed $.mobile methods */ @@ -1815,39 +1801,29 @@ return; } isPageTransitioning = true; - // if the changePage was sent from a hashChange event - // guess if it came from the history menu + // if the changePage was sent from a hashChange event guess if it came from the history menu + // and match the transition accordingly if (fromHashChange) { - - // check if url is in history and if it's ahead or behind current page - $.each(urlHistory.stack, function(i) { - //if the url is in the stack, it's a forward or a back - if (this.url === url) { - urlIndex = i; - //define back and forward by whether url is older or newer than current page - back = i < urlHistory.activeIndex; - //forward set to opposite of back - forward = !back; - //reset activeIndex to this one - urlHistory.activeIndex = i; + urlHistory.directHashChange({ + currentUrl: url, + isBack: function() { + forward = !(back = true); + reverse = true; + transition = transition || currPage.transition; + }, + isForward: function() { + forward = !(back = false); + transition = transition || urlHistory.getActive().transition; } }); - //if it's a back, use reverse animation - if (back) { - reverse = true; - transition = transition || currPage.transition; - } - else if (forward) { - transition = transition || urlHistory.getActive().transition; - } + //TODO forward = !back was breaking for some reason } - if (toIsObject && to.url) { url = to.url; data = to.data; type = to.type; isFormRequest = true; @@ -2046,10 +2022,11 @@ $.ajax({ url: fileUrl, type: type, data: data, + dataType: "html", success: function(html) { //pre-parse html to check for a data-url, //use it as the new fileUrl, base path, etc var all = $("<div></div>"), redirectLoc, @@ -2251,19 +2228,38 @@ var to = path.stripHash(location.hash), //transition is false if it's the first page, undefined otherwise (and may be overridden by default) transition = $.mobile.urlHistory.stack.length === 0 ? false : undefined; //if listening is disabled (either globally or temporarily), or it's a dialog hash - if (!$.mobile.hashListeningEnabled || !urlHistory.ignoreNextHashChange || - (urlHistory.stack.length > 1 && to.indexOf(dialogHashKey) > -1 && !$.mobile.activePage.is(".ui-dialog")) - ) { + if (!$.mobile.hashListeningEnabled || !urlHistory.ignoreNextHashChange) { if (!urlHistory.ignoreNextHashChange) { urlHistory.ignoreNextHashChange = true; } + return; } + // special case for dialogs requires heading back or forward until we find a non dialog page + if (urlHistory.stack.length > 1 && + to.indexOf(dialogHashKey) > -1 && + !$.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(); + } + }); + + return; + } + //if to is defined, load it if (to) { $.mobile.changePage(to, transition, undefined, false, true); } //there's no hash, go to the first page in the dom @@ -2407,11 +2403,11 @@ stickyFooter = footer; footer = stickyFooter.clone(); // footer placeholder stickyFooter.addClass('ui-sticky-footer').before(footer); } footer.addClass('ui-footer-duplicate'); - stickyFooter.appendTo($.pageContainer).css('top', 0); + stickyFooter.appendTo($.mobile.pageContainer).css('top', 0); setTop(stickyFooter); } }); //after page is shown, append footer to new page @@ -2552,10 +2548,11 @@ }; })(); })(jQuery); + /* * jQuery Mobile Framework : "checkboxradio" plugin * Copyright (c) jQuery Project * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license @@ -2603,20 +2600,25 @@ "touchmove": function(event) { var oe = event.originalEvent.touches[0]; if (label.data("movestart")) { if (Math.abs(label.data("movestart")[0] - oe.pageX) > 10 || - Math.abs(abel.data("movestart")[1] - oe.pageY) > 10) { + Math.abs(label.data("movestart")[1] - oe.pageY) > 10) { label.data("moved", true); } } else { label.data("movestart", [ parseFloat(oe.pageX), parseFloat(oe.pageY) ]); } }, "touchend mouseup": function(event) { + if (input.is(":disabled")) { + event.preventDefault(); + return; + } + label.removeData("movestart"); if (label.data("etype") && label.data("etype") !== event.type || label.data("moved")) { label.removeData("etype").removeData("moved"); if (label.data("moved")) { label.removeData("moved"); @@ -3507,11 +3509,12 @@ }) .insertBefore($el) .append($el.addClass('ui-btn-hidden')); //add hidden input during submit - if ($el.attr('type') !== 'reset') { + var type = $el.attr('type'); + if (type !== 'button' && type !== 'reset') { $el.click(function() { var $buttonPlaceholder = $("<input>", {type: "hidden", name: $el.attr("name"), value: $el.attr("value")}) .insertBefore($el); @@ -4393,21 +4396,35 @@ search = $("<input>", { placeholder: "Filter results...", "data-type": "search" }) .bind("keyup change", function() { - var val = this.value.toLowerCase(); - ; - list.children().show(); + var val = this.value.toLowerCase(), + listItems = list.children(); + listItems.show(); if (val) { - list.children().filter( - function() { - return $(this).text().toLowerCase().indexOf(val) === -1; - }).hide(); - } + // This handles hiding regular rows without the text we search for + // and any list dividers without regular rows shown under it + var childItems = false, + item; - //listview._numberItems(); + for (var i = listItems.length; i >= 0; i--) { + item = $(listItems[i]); + if (item.is("li[data-role=list-divider]")) { + if (!childItems) { + item.hide(); + } + // New bucket! + childItems = false; + } else if (item.text().toLowerCase().indexOf(val) === -1) { + item.hide(); + } else { + // There's a shown item in the bucket + childItems = true; + } + } + } }) .appendTo(wrapper) .textinput(); wrapper.insertBefore(list); @@ -4584,19 +4601,71 @@ (function($, window, undefined) { var $html = $("html"), $head = $("head"), $window = $(window); + //trigger mobileinit event - useful hook for configuring $.mobile settings before they're used + $(window.document).trigger("mobileinit"); + + //support conditions + //if device support condition(s) aren't met, leave things as they are -> a basic, usable experience, + //otherwise, proceed with the enhancements + if (!$.mobile.gradeA()) { + return; + } + + //add mobile, initial load "rendering" classes to docEl + $html.addClass("ui-mobile ui-mobile-rendering"); + + //define & prepend meta viewport tag, if content is defined + $.mobile.metaViewportContent ? $("<meta>", { name: "viewport", content: $.mobile.metaViewportContent}).prependTo($head) : undefined; + + //loading div which appears during Ajax requests + //will not appear if $.mobile.loadingMessage is false + var $loader = $.mobile.loadingMessage ? + $("<div class='ui-loader ui-body-a ui-corner-all'>" + + "<span class='ui-icon ui-icon-loading spin'></span>" + + "<h1>" + $.mobile.loadingMessage + "</h1>" + + "</div>") + : undefined; + + $.extend($.mobile, { + // turn on/off page loading message. + pageLoading: function (done) { + if (done) { + $html.removeClass("ui-loading"); + } else { + if ($.mobile.loadingMessage) { + var activeBtn = $("." + $.mobile.activeBtnClass).first(); + + $loader + .appendTo($.mobile.pageContainer) + //position at y center (if scrollTop supported), above the activeBtn (if defined), or just 100px from top + .css({ + top: $.support.scrollTop && $(window).scrollTop() + $(window).height() / 2 || + activeBtn.length && activeBtn.offset().top || 100 + }); + } + + $html.addClass("ui-loading"); + } + }, + // find and enhance the pages in the dom and transition to the first page. initializePage: function() { //find present pages var $pages = $("[data-role='page']"); //add dialogs, set data-url attrs $pages.add("[data-role='dialog']").each(function() { - $(this).attr("data-url", $(this).attr("id")); + var $this = $(this); + + // unless the data url is already set set it to the id + if (!$this.data('url')) { + $this.attr("data-url", $this.attr("id")); + } }); //define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback) $.mobile.firstPage = $pages.first(); @@ -4614,25 +4683,9 @@ else { $window.trigger("hashchange", [ true ]); } } }); - - //trigger mobileinit event - useful hook for configuring $.mobile settings before they're used - $(window.document).trigger("mobileinit"); - - //support conditions - //if device support condition(s) aren't met, leave things as they are -> a basic, usable experience, - //otherwise, proceed with the enhancements - if (!$.mobile.gradeA()) { - return; - } - - //add mobile, initial load "rendering" classes to docEl - $html.addClass("ui-mobile ui-mobile-rendering"); - - //define & prepend meta viewport tag, if content is defined - $.mobile.metaViewportContent ? $("<meta>", { name: "viewport", content: $.mobile.metaViewportContent}).prependTo($head) : undefined; //dom-ready inits $($.mobile.initializePage); //window load event