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

16 lines
8.4 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.core.min","./kendo.fx.min","./kendo.mobile.scroller.min","./kendo.view.min"],e)}(function(){return function(e,t){function n(e){var t,n,i=e.find(k("popover")),r=s.roles;for(t=0,n=i.length;n>t;t++)o.initWidget(i[t],{},r)}function i(e){o.triggeredByInput(e)||e.preventDefault()}function r(t){t.each(function(){o.initWidget(e(this),{},s.roles)})}var o=window.kendo,a=o.mobile,s=a.ui,l=o.attr,u=s.Widget,c=o.ViewClone,d="init",f='<div style="height: 100%; width: 100%; position: absolute; top: 0; left: 0; z-index: 20000; display: none" />',p="beforeShow",h="show",g="afterShow",m="beforeHide",v="transitionEnd",_="transitionStart",w="hide",y="destroy",b=o.attrValue,k=o.roleSelector,x=u.extend({init:function(t,n){u.fn.init.call(this,t,n),this.params={},e.extend(this,n),this.transition=this.transition||this.defaultTransition,this._id(),this._layout(),this._overlay(),this._scroller(),this._model()},events:[d,p,h,g,m,w,y,_,v],options:{name:"View",title:"",reload:!1,transition:"",defaultTransition:"",useNativeScrolling:!1,stretch:!1,zoom:!1,model:null,modelScope:window,scroller:{},initWidgets:!0},enable:function(e){t===e&&(e=!0),e?this.overlay.hide():this.overlay.show()},destroy:function(){this.layout&&this.layout.detach(this),this.trigger(y),u.fn.destroy.call(this),this.scroller&&this.scroller.destroy(),o.destroy(this.element)},purge:function(){this.destroy(),this.element.remove()},triggerBeforeShow:function(){return this.trigger(p,{view:this})?!1:!0},showStart:function(){var e=this;e.element.css("display",""),e.inited||(e.inited=!0,e.trigger(d,{view:e})),e.layout&&e.layout.attach(e),e._padIfNativeScrolling(),e.trigger(h,{view:e}),o.resize(e.element)},showEnd:function(){this.trigger(g,{view:this}),this._padIfNativeScrolling()},hideStart:function(){this.trigger(m,{view:this})},hideEnd:function(){var e=this;e.element.hide(),e.trigger(w,{view:e}),e.layout&&e.layout.trigger(w,{view:e,layout:e.layout})},beforeTransition:function(e){this.trigger(_,{type:e})},afterTransition:function(e){this.trigger(v,{type:e})},_padIfNativeScrolling:function(){if(a.appLevelNativeScrolling()){var e=o.support.mobileOS&&o.support.mobileOS.android,t=e?"footer":"header",n=e?"header":"footer";this.content.css({paddingTop:this[t].height(),paddingBottom:this[n].height()})}},contentElement:function(){var e=this;return e.options.stretch?e.content:e.scrollerContent},clone:function(){return new c(this)},_scroller:function(){var t=this;a.appLevelNativeScrolling()||(t.options.stretch?t.content.addClass("km-stretched-view"):(t.content.kendoMobileScroller(e.extend(t.options.scroller,{zoom:t.options.zoom,useNative:t.options.useNativeScrolling})),t.scroller=t.content.data("kendoMobileScroller"),t.scrollerContent=t.scroller.scrollElement),o.support.kineticScrollNeeded&&(e(t.element).on("touchmove",".km-header",i),t.options.useNativeScrolling||e(t.element).on("touchmove",".km-content",i)))},_model:function(){var e=this,t=e.element,i=e.options.model;"string"==typeof i&&(i=o.getter(i)(e.options.modelScope)),e.model=i,n(t),e.element.css("display",""),e.options.initWidgets&&(i?o.bind(t,i,s,o.ui,o.dataviz.ui):a.init(t.children())),e.element.css("display","none")},_id:function(){var e=this.element,t=e.attr("id")||"";this.id=b(e,"url")||"#"+t,"#"==this.id&&(this.id=o.guid(),e.attr("id",this.id))},_layout:function(){var e=this,t=k("content"),n=e.element;n.addClass("km-view"),e.header=n.children(k("header")).addClass("km-header"),e.footer=n.children(k("footer")).addClass("km-footer"),n.children(t)[0]||n.wrapInner("<div "+l("role")+'="content"></div>'),e.content=n.children(k("content")).addClass("km-content"),e.element.prepend(e.header).append(e.footer),e.layout&&e.layout.setup(e)},_overlay:function(){this.overlay=e(f).appendTo(this.element)}}),C=u.extend({init:function(e,t){var i=this;u.fn.init.call(i,e,t),e=i.element,i.header=e.children(k("header")).addClass("km-header"),i.footer=e.children(k("footer")).addClass("km-footer"),i.elements=i.header.add(i.footer),n(e),o.mobile.init(i.element.children()),i.element.detach(),i.trigger(d,{layout:i})},options:{name:"Layout"},events:[d,h,w],setup:function(e){e.header[0]||(e.header=this.header),e.footer[0]||(e.footer=this.footer)},detach:function(e){var t=this;e.header===t.header&&t.header[0]&&e.element.prepend(t.header.detach()[0].cloneNode(!0)),e.footer===t.footer&&t.footer.length&&e.element.append(t.footer.detach()[0].cloneNode(!0))},attach:function(e){var t=this,n=t.currentView;n&&t.detach(n),e.header===t.header&&(t.header.detach(),e.element.children(k("header")).remove(),e.element.prepend(t.header)),e.footer===t.footer&&(t.footer.detach(),e.element.children(k("footer")).remove(),e.element.append(t.footer)),t.trigger(h,{layout:t,view:e}),t.currentView=e}}),T=o.Observable,S=/<body[^>]*>(([\u000a\u000d\u2028\u2029]|.)*)<\/body>/i,F="loadStart",D="loadComplete",E="showStart",M="sameViewRequested",I="viewShow",H="after",z=T.extend({init:function(t){var n,i,a,s=this;if(T.fn.init.call(s),e.extend(s,t),s.sandbox=e("<div />"),a=s.container,n=s._hideViews(a),s.rootView=n.first(),!s.rootView[0]&&t.rootNeeded)throw i=a[0]==o.mobile.application.element[0]?'Your kendo mobile application element does not contain any direct child elements with data-role="view" attribute set. Make sure that you instantiate the mobile application using the correct container.':'Your pane element does not contain any direct child elements with data-role="view" attribute set.',Error(i);s.layouts={},s.viewContainer=new o.ViewContainer(s.container),s.viewContainer.bind("accepted",function(e){e.view.params=s.params}),s.viewContainer.bind("complete",function(e){s.trigger(I,{view:e.view})}),s.viewContainer.bind(H,function(){s.trigger(H)}),s._setupLayouts(a),r(a.children(k("modalview drawer")))},destroy:function(){o.destroy(this.container);for(var e in this.layouts)this.layouts[e].destroy()},view:function(){return this.viewContainer.view},showView:function(e,t,n){if(e=e.replace(RegExp("^"+this.remoteViewURLPrefix),""),""===e&&this.remoteViewURLPrefix&&(e="/"),e===this.url)return this.trigger(M),!1;this.trigger(E);var i=this,r=function(n){return i.viewContainer.show(n,t,e)},a=i._findViewElement(e),s=o.widgetInstance(a);return i.url=e,i.params=n,s&&s.reload&&(s.purge(),a=[]),this.trigger("viewTypeDetermined",{remote:0===a.length,url:e}),a[0]?(s||(s=i._createView(a)),r(s)):(i._loadView(e,r),!0)},append:function(e,t){var n,i,o,a=this,s=a.sandbox,u=(t||"").split("?")[0],c=a.container;return S.test(e)&&(e=RegExp.$1),s[0].innerHTML=e,c.append(s.children("script, style")),n=a._hideViews(s),o=n.first(),o.length||(n=o=s.wrapInner("<div data-role=view />").children()),u&&o.hide().attr(l("url"),u),a._setupLayouts(s),i=s.children(k("modalview drawer")),c.append(s.children(k("layout modalview drawer")).add(n)),r(i),a._createView(o)},_findViewElement:function(e){var t,n=e.split("?")[0];return n?(t=this.container.children("["+l("url")+"='"+n+"']"),t[0]||-1!==n.indexOf("/")||(t=this.container.children("#"===n.charAt(0)?n:"#"+n)),t):this.rootView},_createView:function(e){var n,i=this,r=b(e,"layout");return t===r&&(r=i.layout),r&&(r=i.layouts[r]),n={defaultTransition:i.transition,loader:i.loader,container:i.container,layout:r,modelScope:i.modelScope,reload:b(e,"reload")},o.initWidget(e,n,s.roles)},_loadView:function(n,i){var r=this;return this.serverNavigation?(location.href=n,t):(r._xhr&&r._xhr.abort(),r.trigger(F),r._xhr=e.get(o.absoluteURL(n,r.remoteViewURLPrefix),function(e){r.trigger(D),i(r.append(e,n))},"html").fail(function(e){r.trigger(D),0===e.status&&e.responseText&&i(r.append(e.responseText,n))}),t)},_hideViews:function(e){return e.children(k("view splitview")).hide()},_setupLayouts:function(n){var i=this;n.children(k("layout")).each(function(){var n=e(this),r=b(n,"platform");(r===t||r===a.application.os.name)&&(i.layouts[o.attrValue(n,"id")]=o.initWidget(n,{},s.roles))})}});o.mobile.ViewEngine=z,s.plugin(x),s.plugin(C)}(window.kendo.jQuery),window.kendo},"function"==typeof define&&define.amd?define:function(e,t){t()});