16 lines
5.3 KiB
JavaScript
16 lines
5.3 KiB
JavaScript
/**
|
|
* Copyright 2014 Telerik AD
|
|
*
|
|
* 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,define){define(["./kendo.mobile.view.min","./kendo.mobile.loader.min"],e)}(function(){return function(e,t){var n=window.kendo,i=n.mobile,r=n.roleSelector,o=i.ui,a=o.Widget,s=i.ViewEngine,l=o.View,u=i.ui.Loader,c="external",d="href",f="#!",p="navigate",h="viewShow",g="sameViewRequested",m=n.support.mobileOS,v=m.ios&&!m.appMode&&m.flatVersion>=700,_=/popover|actionsheet|modalview|drawer/,w="#:back",y=n.attrValue,b="button backbutton detailbutton listview-link",k="tab",x=a.extend({init:function(e,t){var i=this;a.fn.init.call(i,e,t),t=i.options,e=i.element,e.addClass("km-pane"),i.options.collapsible&&e.addClass("km-collapsible-pane"),this.history=[],this.historyCallback=function(e,t,n){var r=i.transition;return i.transition=null,v&&n&&(r="none"),i.viewEngine.showView(e,r,t)},this._historyNavigate=function(e){if(e===w){if(1===i.history.length)return;i.history.pop(),e=i.history[i.history.length-1]}else i.history.push(e);i.historyCallback(e,n.parseQueryStringParams(e))},this._historyReplace=function(e){var t=n.parseQueryStringParams(e);i.history[i.history.length-1]=e,i.historyCallback(e,t)},i.loader=new u(e,{loading:i.options.loading}),i.viewEngine=new s({container:e,transition:t.transition,modelScope:t.modelScope,rootNeeded:!t.initial,serverNavigation:t.serverNavigation,remoteViewURLPrefix:t.root||"",layout:t.layout,loader:i.loader}),i.viewEngine.bind("showStart",function(){i.loader.transition(),i.closeActiveDialogs()}),i.viewEngine.bind("after",function(){i.loader.transitionDone()}),i.viewEngine.bind(h,function(e){i.trigger(h,e)}),i.viewEngine.bind("loadStart",function(){i.loader.show()}),i.viewEngine.bind("loadComplete",function(){i.loader.hide()}),i.viewEngine.bind(g,function(){i.trigger(g)}),i.viewEngine.bind("viewTypeDetermined",function(e){e.remote&&i.options.serverNavigation||i.trigger(p,{url:e.url})}),this._setPortraitWidth(),n.onResize(function(){i._setPortraitWidth()}),i._setupAppLinks()},closeActiveDialogs:function(){var t=this.element.find(r("actionsheet popover modalview")).filter(":visible");t.each(function(){n.widgetInstance(e(this),o).close()})},navigateToInitial:function(){var e=this.options.initial;e&&this.navigate(e)},options:{name:"Pane",portraitWidth:"",transition:"",layout:"",collapsible:!1,initial:null,modelScope:window,loading:"<h1>Loading...</h1>"},events:[p,h,g],append:function(e){return this.viewEngine.append(e)},destroy:function(){a.fn.destroy.call(this),this.viewEngine.destroy(),this.userEvents.destroy()},navigate:function(e,t){e instanceof l&&(e=e.id),this.transition=t,this._historyNavigate(e)},replace:function(e,t){e instanceof l&&(e=e.id),this.transition=t,this._historyReplace(e)},bindToRouter:function(e){var t=this,i=t.options,r=i.initial,o=this.viewEngine;e.bind("init",function(t){var i=t.url,a=e.pushState?i:"/";o.rootView.attr(n.attr("url"),a),"/"===i&&r&&(e.navigate(r,!0),t.preventDefault())}),e.bind("routeMissing",function(e){t.historyCallback(e.url,e.params,e.backButtonPressed)||e.preventDefault()}),e.bind("same",function(){t.trigger(g)}),t._historyNavigate=function(t){e.navigate(t)},t._historyReplace=function(t){e.replace(t)}},hideLoading:function(){this.loader.hide()},showLoading:function(){this.loader.show()},changeLoadingMessage:function(e){this.loader.changeMessage(e)},view:function(){return this.viewEngine.view()},_setPortraitWidth:function(){var e,t=this.options.portraitWidth;t&&(e=n.mobile.application.element.is(".km-vertical")?t:"auto",this.element.css("width",e))},_setupAppLinks:function(){var e=this;this.element.handler(this).on("down",r(k),"_mouseup").on("click",r(k+" "+b),"_appLinkClick"),this.userEvents=new n.UserEvents(this.element,{filter:r(b),tap:function(t){t.event.currentTarget=t.touch.currentTarget,e._mouseup(t.event)}})},_appLinkClick:function(t){var n=e(t.currentTarget).attr("href"),i=n&&"#"!==n[0]&&this.options.serverNavigation;i||y(e(t.currentTarget),"rel")==c||t.preventDefault()},_mouseup:function(r){if(!(r.which>1||r.isDefaultPrevented())){var a=this,s=e(r.currentTarget),l=y(s,"transition"),u=y(s,"rel")||"",p=y(s,"target"),h=s.attr(d),g=v&&0===s[0].offsetHeight,m=h&&"#"!==h[0]&&this.options.serverNavigation;g||m||u===c||t===h||h===f||(s.attr(d,f),setTimeout(function(){s.attr(d,h)}),u.match(_)?(n.widgetInstance(e(h),o).openFor(s),("actionsheet"===u||"drawer"===u)&&r.stopPropagation()):("_top"===p?a=i.application.pane:p&&(a=e("#"+p).data("kendoMobilePane")),a.navigate(h,l)),r.preventDefault())}}});x.wrap=function(e){e.is(r("view"))||(e=e.wrap("<div data-"+n.ns+'role="view" data-stretch="true"></div>').parent());var t=e.wrap('<div class="km-pane-wrapper"><div></div></div>').parent(),i=new x(t);return i.navigate(""),i},o.plugin(x)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()}); |