/*!
 * SAP UI development toolkit for HTML5 (SAPUI5/OpenUI5)
 * (c) Copyright 2009-2015 SAP SE or an SAP affiliate company.
 * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
 */
sap.ui.define(['jquery.sap.global','sap/ui/core/DeclarativeSupport','sap/ui/core/RenderManager','sap/ui/core/library','./View'],function(q,D,R,l,V){"use strict";var H=V.extend("sap.ui.core.mvc.HTMLView",{metadata:{library:"sap.ui.core"}});sap.ui.htmlview=function(i,v){return sap.ui.view(i,v,sap.ui.core.mvc.ViewType.HTML);};H._sType=sap.ui.core.mvc.ViewType.HTML;H._mTemplates={};H._mAllowedSettings={"viewName":true,"controller":true,"viewContent":true,"controllerName":true,"resourceBundleName":true,"resourceBundleUrl":true,"resourceBundleLocale":true,"resourceBundleAlias":true};H._getTemplate=function(t){var u=this._getViewUrl(t);var h=this._mTemplates[u];if(!h){h=this._loadTemplate(t);this._mTemplates[u]=h;}return h;};H.prototype.getControllerName=function(){return this._controllerName;};H._getViewUrl=function(t){return q.sap.getModulePath(t,".view.html");};H._loadTemplate=function(t){var r=q.sap.getResourceName(t,".view.html");return q.sap.loadResource(r);};H.prototype.initViewSettings=function(s){if(!s){throw new Error("mSettings must be given");}if(s.viewName&&s.viewContent){throw new Error("View name and view content are given. There is no point in doing this, so please decide.");}else if(!s.viewName&&!s.viewContent){throw new Error("Neither view name nor view content is given. One of them is required.");}var h=s.viewContent||H._getTemplate(s.viewName);this._oTemplate=document.createElement("div");if(typeof h==="string"){this._oTemplate.innerHTML=h;}else{var n=h;var f=document.createDocumentFragment();for(var i=0;i<n.length;i++){f.appendChild(n.item(i));}this._oTemplate.appendChild(f);}var m=this._oTemplate.getElementsByTagName("template")[0];var p=this.getMetadata().getAllProperties();if(m){var t=this;var a=D;q.each(m.attributes,function(I,A){var N=a.convertAttributeToSettingName(A.name,t.getId());var v=A.value;var P=p[N];if(!s[N]){if(P){s[N]=a.convertValueToType(a.getPropertyDataType(P),v);}else if(H._mAllowedSettings[N]){s[N]=v;}}});this._oTemplate=m;}if(this._oTemplate.content){var f=this._oTemplate.content;this._oTemplate=document.createElement("div");this._oTemplate.appendChild(f);}if(s.controllerName){this._controllerName=s.controllerName;}if((s.resourceBundleName||s.resourceBundleUrl)&&(!s.models||!s.models[s.resourceBundleAlias])){var b=new sap.ui.model.resource.ResourceModel({bundleName:s.resourceBundleName,bundleUrl:s.resourceBundleUrl,bundleLocale:s.resourceBundleLocale});this.setModel(b,s.resourceBundleAlias);}};H.prototype.onControllerConnected=function(c){var t=this;sap.ui.base.ManagedObject.runWithPreprocessors(function(){D.compile(t._oTemplate,t);},{settings:this._fnSettingsPreprocessor});};H.prototype.exit=function(){this._oTemplate=null;V.prototype.exit.call(this);if(this._connectedControls){for(var i=0;i<this._connectedControls.length;i++){this._connectedControls[i].destroy();}this._connectedControls=null;}};H.prototype.connectControl=function(c){this._connectedControls=this._connectedControls||[];this._connectedControls.push(c);};return H;},true);
