-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjqmNavigator-min.js
18 lines (18 loc) · 3.39 KB
/
jqmNavigator-min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2012 Piotr Walczyszyn (http://outof.me | @pwalczyszyn)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//////////////////////////////////////////////////////////////////////////////////////
(function(e,t){typeof define=="function"&&define.amd?define(["jquery"],t):t(jQuery)})(this,function(e){e(document).bind("mobileinit",function(){e.mobile.linkBindingEnabled=!1,e.mobile.ajaxEnabled=!1,e.mobile.hashListeningEnabled=!1,e.mobile.pushStateEnabled=!1,e.mobile.autoInitializePage=!1,e.extend(e.mobile,{jqmNavigator:{VERSION:"1.0.0",_containers:[],defaultPageContainer:null,pushView:function(n,r){var i=this._getPageContainerViews(r);i.views.push(n),i.pageContainer.append(n.el),n.render(),e.mobile.firstPage?e.mobile.changePage(n.$el,e.extend({role:"page",changeHash:!1,pageContainer:i.pageContainer},r)):(n.$el.attr("data-role","page"),e.mobile.autoInitializePage||e.mobile.initializePage())},popView:function(n){var r=this._getPageContainerViews(n);if(r.views.length>1){var i=r.views.pop();toView=r.views[r.views.length-1],i.$el.one("pagehide",function(e){i.$el.detach()}),e.mobile.changePage(toView.$el,e.extend({role:"page",reverse:!0,changeHash:!1,pageContainer:r.pageContainer},n))}else console.log("Can't pop first view, you can replace it instead!")},popToFirst:function(n){var r=this._getPageContainerViews(n);if(r.views.length>1){var i=r.views[r.views.length-1],s=r.views[0],o=r.views.splice(1,r.views.length-1);i.$el.one("pagehide",function(e){o.forEach(function(e){e.$el.detach()},this)}),e.mobile.changePage(s.$el,e.extend({role:"page",reverse:!0,changeHash:!1,pageContainer:r.pageContainer},n))}else console.log("Can't pop first view, you can replace it instead!")},replaceView:function(n,r){var i=this._getPageContainerViews(r);if(i.views.length>=1){var s=i.views.pop();s.$el.one("pagehide",function(e){s.$el.detach()}),i.views.push(n),i.pageContainer.append(n.el),n.render(),e.mobile.changePage(n.$el,e.extend({role:"page",changeHash:!1,pageContainer:i.pageContainer},r))}},replaceAll:function(n,r){var i=this._getPageContainerViews(r);if(i.views.length>=1){var s=i.views[i.views.length-1],o=i.views.splice(0,i.views.length);s.$el.one("pagehide",function(e){o.forEach(function(e){e.$el.detach()},this)}),i.views.push(n),i.pageContainer.append(n.el),n.render(),e.mobile.changePage(n.$el,e.extend({role:"page",changeHash:!1,pageContainer:i.pageContainer},r))}},_getPageContainerViews:function(t){var n=t&&t.pageContainer?t.pageContainer:e.mobile.pageContainer||this.defaultPageContainer||e("body"),r;return this._containers.some(function(e){if(e.pageContainer[0]===n[0])return r=e,!0},this),r||this._containers.push(r={pageContainer:n,views:[]}),r},getViews:function(n){var r,i=n?n[0]:e.mobile.pageContainer?e.mobile.pageContainer[0]:null;return this._containers.some(function(e){if(e.pageContainer[0]===i)return r=e.views,!0},this),r}}})})});