UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines (2 loc) 9.61 kB
!function(e){"function"==typeof define&&define.amd?define(["kendo.core.min","kendo.fx.min","kendo.mobile.scroller.min","kendo.view.min"],e):e()}((function(){!function(e,t){var i=window.kendo,n=i.mobile,o=n.ui,r=i.attr,a=o.Widget,s=i.ViewClone,l="init",h="beforeShow",d="show",c="afterShow",u="beforeHide",p="transitionEnd",f="transitionStart",g="hide",m="destroy",v=i.attrValue,w=i.roleSelector,y=i.directiveSelector,_=i.compileMobileDirective;function b(e){var t,n,r=e.find(w("popover")),a=o.roles;for(t=0,n=r.length;t<n;t++)i.initWidget(r[t],{},a)}function x(e){i.triggeredByInput(e)||e.preventDefault()}var S=a.extend({init:function(t,i){a.fn.init.call(this,t,i),this.params={},e.extend(this,i),this.transition=this.transition||this.defaultTransition,this._id(),this.options.$angular?this._overlay():(this._layout(),this._overlay(),this._scroller(),this._model())},events:[l,h,d,c,u,g,m,f,p],options:{name:"View",title:"",layout:null,getLayout:e.noop,reload:!1,transition:"",defaultTransition:"",useNativeScrolling:!1,stretch:!1,zoom:!1,model:null,modelScope:window,scroller:{},initWidgets:!0},enable:function(e){void 0===e&&(e=!0),e?this.overlay.hide():this.overlay.show()},destroy:function(){this.layout&&this.layout.detach(this),this.trigger(m),a.fn.destroy.call(this),this.scroller&&this.scroller.destroy(),this.options.$angular&&this.element.scope().$destroy(),i.destroy(this.element)},purge:function(){this.destroy(),this.element.remove()},triggerBeforeShow:function(){return!this.trigger(h,{view:this})},triggerBeforeHide:function(){return!this.trigger(u,{view:this})},showStart:function(){var e=this.element;e.css("display",""),this.inited?this._invokeNgController():(this.inited=!0,this.trigger(l,{view:this})),this.layout&&this.layout.attach(this),this._padIfNativeScrolling(),this.trigger(d,{view:this}),i.resize(e)},showEnd:function(){this.trigger(c,{view:this}),this._padIfNativeScrolling()},hideEnd:function(){var e=this;e.element.hide(),e.trigger(g,{view:e}),e.layout&&e.layout.trigger(g,{view:e,layout:e.layout})},beforeTransition:function(e){this.trigger(f,{type:e})},afterTransition:function(e){this.trigger(p,{type:e})},_padIfNativeScrolling:function(){if(n.appLevelNativeScrolling()){var e=i.support.mobileOS&&i.support.mobileOS.android,t=n.application.skin()||"",o=n.application.os.android||t.indexOf("android")>-1,r="flat"===t||t.indexOf("material")>-1,a=!e&&!o||r?"header":"footer",s=!e&&!o||r?"footer":"header";this.content.css({paddingTop:this[a].height(),paddingBottom:this[s].height()})}},contentElement:function(){var e=this;return e.options.stretch?e.content:e.scrollerContent},clone:function(){return new s(this)},_scroller:function(){var t=this;n.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),i.support.kineticScrollNeeded&&(e(t.element).on("touchmove",".km-header",x),t.options.useNativeScrolling||t.options.stretch||e(t.element).on("touchmove",".km-content",x)))},_model:function(){var e=this,t=e.element,r=e.options.model;"string"==typeof r&&(r=i.getter(r)(e.options.modelScope)),e.model=r,b(t),e.element.css("display",""),e.options.initWidgets&&(r?i.bind(t,r,o,i.ui,i.dataviz.ui):n.init(t.children())),e.element.css("display","none")},_id:function(){var e=this.element,t=e.attr("id")||"";this.id=v(e,"url")||"#"+t,"#"==this.id&&(this.id=i.guid(),e.attr("id",this.id))},_layout:function(){var e=w("content"),t=this.element;t.addClass("km-view"),this.header=t.children(w("header")).addClass("km-header"),this.footer=t.children(w("footer")).addClass("km-footer"),t.children(e)[0]||t.wrapInner("<div "+r("role")+'="content"></div>'),this.content=t.children(w("content")).addClass("km-content"),this.element.prepend(this.header).append(this.footer),this.layout=this.options.getLayout(this.layout),this.layout&&this.layout.setup(this)},_overlay:function(){this.overlay=e('<div style="height: 100%; width: 100%; position: absolute; top: 0; left: 0; z-index: 20000; display: none"></div>').appendTo(this.element)},_invokeNgController:function(){var e,t;if(this.options.$angular&&(e=this.element.controller(),t=this.options.$angular[0],e)){var i=this._callController.bind(this,e,t);/^\$(digest|apply)$/.test(t.$$phase)?i():t.$apply(i)}},_callController:function(e,t){this.element.injector().invoke(e.constructor,e,{$scope:t})}});function V(t){t.each((function(){i.initWidget(e(this),{},o.roles)}))}var k=a.extend({init:function(e,t){a.fn.init.call(this,e,t),e=this.element,this.header=e.children(this._locate("header")).addClass("km-header"),this.footer=e.children(this._locate("footer")).addClass("km-footer"),this.elements=this.header.add(this.footer),b(e),this.options.$angular||i.mobile.init(this.element.children()),this.element.detach(),this.trigger(l,{layout:this})},_locate:function(e){return this.options.$angular?y(e):w(e)},options:{name:"Layout",id:null,platform:null},events:[l,d,g],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,i=t.currentView;i&&t.detach(i),e.header===t.header&&(t.header.detach(),e.element.children(w("header")).remove(),e.element.prepend(t.header)),e.footer===t.footer&&(t.footer.detach(),e.element.children(w("footer")).remove(),e.element.append(t.footer)),t.trigger(d,{layout:t,view:e}),t.currentView=e}}),C=i.Observable,$=/<body[^>]*>(([\u000a\u000d\u2028\u2029]|.)*)<\/body>/i,L="loadStart",N="loadComplete",T="showStart",E="sameViewRequested",I="viewShow",O="viewTypeDetermined",R="after",W=C.extend({init:function(t){var n,o,r,a,s=this;if(C.fn.init.call(s),e.extend(s,t),s.sandbox=e("<div />"),r=s.container,n=s._hideViews(r),s.rootView=n.first(),!s.rootView[0]&&t.rootNeeded)throw o=r[0]==i.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.',new Error(o);s.layouts={},s.viewContainer=new i.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(R,(function(){s.trigger(R)})),this.getLayoutProxy=this._getLayout.bind(this),s._setupLayouts(r),a=r.children(s._locate("modalview drawer")),s.$angular?(s.$angular[0].viewOptions={defaultTransition:s.transition,loader:s.loader,container:s.container,getLayout:s.getLayoutProxy},a.each((function(i,n){_(e(n),t.$angular[0])}))):V(a),this.bind(this.events,t)},events:[T,R,I,L,N,E,O],destroy:function(){for(var e in i.destroy(this.container),this.layouts)this.layouts[e].destroy()},view:function(){return this.viewContainer.view},showView:function(e,t,n){if(""===(e=e.replace(new RegExp("^"+this.remoteViewURLPrefix),""))&&this.remoteViewURLPrefix&&(e="/"),e.replace(/^#/,"")===this.url)return this.trigger(E),!1;this.trigger(T);var o=this,r=function(i){return o.viewContainer.show(i,t,e)},a=o._findViewElement(e),s=i.widgetInstance(a);return o.url=e.replace(/^#/,""),o.params=n,s&&s.reload&&(s.purge(),a=[]),this.trigger(O,{remote:0===a.length,url:e}),a[0]?(s||(s=o._createView(a)),r(s)):(this.serverNavigation?location.href=e:o._loadView(e,r),!0)},append:function(e,t){var i,n,o,a=this.sandbox,s=(t||"").split("?")[0],l=this.container;return $.test(e)&&(e=RegExp.$1),a[0].innerHTML=e,l.append(a.children("script, style")),(o=(i=this._hideViews(a)).first()).length||(i=o=a.wrapInner("<div data-role=view />").children()),s&&o.hide().attr(r("url"),s),this._setupLayouts(a),n=a.children(this._locate("modalview drawer")),l.append(a.children(this._locate("layout modalview drawer")).add(i)),V(n),this._createView(o)},_locate:function(e){return this.$angular?y(e):w(e)},_findViewElement:function(e){var t,i=e.split("?")[0];return i?((t=this.container.children("["+r("url")+"='"+i+"']"))[0]||-1!==i.indexOf("/")||(t=this.container.children("#"===i.charAt(0)?i:"#"+i)),t):this.rootView},_createView:function(e){return this.$angular?_(e,this.$angular[0]):i.initWidget(e,{defaultTransition:this.transition,loader:this.loader,container:this.container,getLayout:this.getLayoutProxy,modelScope:this.modelScope,reload:v(e,"reload")},o.roles)},_getLayout:function(e){return""===e?null:e?this.layouts[e]:this.layouts[this.layout]},_loadView:function(t,n){this._xhr&&this._xhr.abort(),this.trigger(L),this._xhr=e.get(i.absoluteURL(t,this.remoteViewURLPrefix),"html").always(this._xhrComplete.bind(this,n,t))},_xhrComplete:function(e,t,i){var n=!0;if("object"==typeof i&&0===i.status){if(!(i.responseText&&i.responseText.length>0))return;n=!0,i=i.responseText}this.trigger(N),n&&e(this.append(i,t))},_hideViews:function(e){return e.children(this._locate("view splitview")).hide()},_setupLayouts:function(t){var r,a=this;t.children(a._locate("layout")).each((function(){var t=(r=a.$angular?_(e(this),a.$angular[0]):i.initWidget(e(this),{},o.roles)).options.platform;t&&t!==n.application.os.name?r.destroy():a.layouts[r.options.id]=r}))}});i.mobile.ViewEngine=W,o.plugin(S),o.plugin(k)}(window.kendo.jQuery)})); //# sourceMappingURL=kendo.mobile.view.min.js.map