demo20230512/Scripts/kendo/2014.2.716/kendo.mobile.application.min.js
2023-05-12 10:20:28 +08:00

16 lines
8.5 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.pane.min","./kendo.router.min"],e)}(function(){return function(e,t){function n(e,t){var n=[];return p&&n.push("km-on-"+p.name),n.push(e.skin?"km-"+e.skin:"ios"==e.name&&e.majorVersion>6?"km-ios7":"km-"+e.name),("ios"==e.name&&7>e.majorVersion||"ios"!=e.name)&&n.push("km-"+e.name+e.majorVersion),n.push("km-"+e.majorVersion),n.push("km-m"+(e.minorVersion?e.minorVersion[0]:0)),e.variant&&(e.skin&&e.skin===e.name||!e.skin)&&n.push("km-"+(e.skin?e.skin:e.name)+"-"+e.variant),e.cordova&&n.push("km-cordova"),n.push(e.appMode?"km-app":"km-web"),t&&t.statusBarStyle&&n.push("km-"+t.statusBarStyle+"-status-bar"),n.join(" ")}function i(){return 0===parseInt(e("<div style='background: Background' />").css("background-color").split(",")[1],10)?"dark":"light"}function r(e){return p.wp?"-kendo-landscape"==e.css("animation-name"):Math.abs(window.orientation)/90==1}function o(e){return r(e)?w:g}function a(e){e.parent().addBack().css("min-height",window.innerHeight)}function s(){e("meta[name=viewport]").remove(),F.append(k({height:", width=device-width"+(r()?", height="+window.innerHeight+"px":c.mobileOS.flatVersion>=600&&700>c.mobileOS.flatVersion?", height="+window.innerWidth+"px":", height=device-height")}))}var l=window.kendo,d=l.mobile,c=l.support,u=d.ui.Pane,h="ios7",p=c.mobileOS,f="blackberry"==p.device&&p.flatVersion>=600&&1e3>p.flatVersion&&p.appMode,g="km-vertical",m="chrome"===p.browser,v=p.ios&&p.flatVersion>=700&&(p.appMode||m),_=Math.abs(window.orientation)/90==1,w="km-horizontal",y={ios7:{ios:!0,browser:"default",device:"iphone",flatVersion:"700",majorVersion:"7",minorVersion:"0.0",name:"ios",tablet:!1},ios:{ios:!0,browser:"default",device:"iphone",flatVersion:"612",majorVersion:"6",minorVersion:"1.2",name:"ios",tablet:!1},android:{android:!0,browser:"default",device:"android",flatVersion:"442",majorVersion:"4",minorVersion:"4.2",name:"android",tablet:!1},blackberry:{blackberry:!0,browser:"default",device:"blackberry",flatVersion:"710",majorVersion:"7",minorVersion:"1.0",name:"blackberry",tablet:!1},meego:{meego:!0,browser:"default",device:"meego",flatVersion:"850",majorVersion:"8",minorVersion:"5.0",name:"meego",tablet:!1},wp:{wp:!0,browser:"default",device:"wp",flatVersion:"800",majorVersion:"8",minorVersion:"0.0",name:"wp",tablet:!1}},k=l.template('<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no#=data.height#" name="viewport" />',{usedWithBlock:!1}),b=l.template('<meta name="apple-mobile-web-app-capable" content="#= data.webAppCapable === false ? \'no\' : \'yes\' #" /> <meta name="apple-mobile-web-app-status-bar-style" content="#=data.statusBarStyle#" /> <meta name="msapplication-tap-highlight" content="no" /> ',{usedWithBlock:!1}),x=l.template("<style>.km-view { clip: rect(0 #= data.width #px #= data.height #px 0); }</style>",{usedWithBlock:!1}),C=p.android&&"chrome"!=p.browser||p.blackberry,T=k({height:""}),S=l.template('<link rel="apple-touch-icon'+(p.android?"-precomposed":"")+'" # if(data.size) { # sizes="#=data.size#" #}# href="#=data.icon#" />',{usedWithBlock:!1}),D=("iphone"==p.device||"ipod"==p.device)&&7>p.majorVersion,A=("iphone"==p.device||"ipod"==p.device)&&p.majorVersion>=7,E=A?"none":null,I="mobilesafari"==p.browser?60:0,P=20,M=e(window),z=window.screen,F=e("head"),L="init",R=e.proxy,H=l.Observable.extend({init:function(t,n){var i=this;d.application=i,i.options=e.extend({hideAddressBar:!0,useNativeScrolling:!1,statusBarStyle:"black",transition:"",historyTransition:E,modelScope:window,updateDocumentTitle:!0},n),l.Observable.fn.init.call(i,i.options),i.bind(i.events,i.options),e(function(){t=e(t),i.element=t[0]?t:e(document.body),i._setupPlatform(),i._attachMeta(),i._setupElementClass(),i._attachHideBarHandlers(),i.pane=new u(i.element,i.options),i.pane.navigateToInitial(),i.options.updateDocumentTitle&&i._setupDocumentTitle(),i._startHistory(),i.trigger(L)})},events:[L],navigate:function(e,t){this.pane.navigate(e,t)},replace:function(e,t){this.pane.replace(e,t)},scroller:function(){return this.view().scroller},hideLoading:function(){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider activating loading in the application init event handler.");this.pane.hideLoading()},showLoading:function(){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider activating loading in the application init event handler.");this.pane.showLoading()},changeLoadingMessage:function(e){if(!this.pane)throw Error("The mobile application instance is not fully instantiated. Please consider changing the message in the application init event handler.");this.pane.changeLoadingMessage(e)},view:function(){return this.pane.view()},skin:function(e){var t=this;return arguments.length?(t.options.skin=e||"",t.element[0].className="km-pane",t._setupPlatform(),t._setupElementClass(),t.options.skin):t.options.skin},destroy:function(){this.pane.destroy(),this.router.destroy()},_setupPlatform:function(){var t=this,r=t.options.platform,o=t.options.skin,a=[],s=p||y[h];r&&("string"==typeof r?(a=r.split("-"),s=e.extend({variant:a[1]},s,y[a[0]])):s=r),o&&(a=o.split("-"),s=e.extend({},s,{skin:a[0],variant:a[1]})),s.variant||(s.variant="dark"),t.os=s,t.osCssClass=n(t.os,t.options),s.wp&&(t.refreshBackgroundColorProxy||(t.refreshBackgroundColorProxy=e.proxy(function(){(t.os.variant&&t.os.skin&&t.os.skin===t.os.name||!t.os.skin)&&t.element.removeClass("km-wp-dark km-wp-light").addClass("km-wp-"+i())},t)),e(window).off("focusin",t.refreshBackgroundColorProxy),e(document).off("resume",t.refreshBackgroundColorProxy),s.skin||(t.element.parent().css("overflow","hidden"),e(window).on("focusin",t.refreshBackgroundColorProxy),e(document).on("resume",t.refreshBackgroundColorProxy),t.refreshBackgroundColorProxy()))},_startHistory:function(){this.router=new l.Router({pushState:this.options.pushState,root:this.options.root,hashBang:this.options.hashBang}),this.pane.bindToRouter(this.router),this.router.start()},_resizeToScreenHeight:function(){var t,n=e("meta[name=apple-mobile-web-app-status-bar-style]").attr("content").match(/black-translucent|hidden/),i=this.element;t=m?window.innerHeight:r(i)?n?_?z.availWidth+P:z.availWidth:_?z.availWidth:z.availWidth-P:n?_?z.availHeight:z.availHeight+P:_?z.availHeight-P:z.availHeight,i.height(t)},_setupElementClass:function(){var t,n=this,i=n.element;i.parent().addClass("km-root km-"+(n.os.tablet?"tablet":"phone")),i.addClass(n.osCssClass+" "+o(i)),this.options.useNativeScrolling&&i.parent().addClass("km-native-scrolling"),m&&i.addClass("km-ios-chrome"),c.wpDevicePixelRatio&&i.parent().css("font-size",c.wpDevicePixelRatio+"em"),f&&s(),n.options.useNativeScrolling?i.parent().addClass("km-native-scrolling"):C&&(t=(screen.availWidth>screen.availHeight?screen.availWidth:screen.availHeight)+200,e(x({width:t,height:t})).appendTo(F)),v&&n._resizeToScreenHeight(),l.onResize(function(){i.removeClass("km-horizontal km-vertical").addClass(o(i)),n.options.useNativeScrolling&&a(i),v&&n._resizeToScreenHeight(),f&&s(),l.resize(i)})},_clearExistingMeta:function(){F.find("meta").filter("[name|='apple-mobile-web-app'],[name|='msapplication-tap'],[name='viewport']").remove()},_attachMeta:function(){var e,t=this.options,n=t.icon;if(this._clearExistingMeta(),f||F.prepend(T),F.prepend(b(t)),n){"string"==typeof n&&(n={"":n});for(e in n)F.prepend(S({icon:n[e],size:e}))}t.useNativeScrolling&&a(this.element)},_attachHideBarHandlers:function(){var e=this,t=R(e,"_hideBar");!c.mobileOS.appMode&&e.options.hideAddressBar&&D&&!e.options.useNativeScrolling&&(e._initialHeight={},M.on("load",t),l.onResize(function(){setTimeout(window.scrollTo,0,0,1)}))},_setupDocumentTitle:function(){var e=this,n=document.title;e.pane.bind("viewShow",function(e){var i=e.view.title;document.title=i!==t?i:n})},_hideBar:function(){var t=this,n=t.element;n.height(l.support.transforms.css+"calc(100% + "+I+"px)"),e(window).trigger(l.support.resize)}});l.mobile.Application=H}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});