(function(){"use strict";var e=new RegExp(/\{[^\}]*\}/g);u8.Base.Widgets.FormFrame=function(e,t){if(!u8.tools.isInstanceOfClass(t.parameters,"Model")){t.parameters=new u8.Base.Model(t.parameters&&t.parameters.properties?t.parameters:{properties:t.parameters})}if(!u8.tools.isInstanceOfClass(t.placeholders,"Model")){t.placeholders=new u8.Base.Model(t.placeholders&&t.placeholders.properties?t.placeholders:{properties:t.placeholders})}this.Widget(e,$.extend({},u8.Base.Widgets.FormFrame.defaults,t));this._create()};u8.Base.Widgets.FormFrame.makeClass({name:"FormFrame",deriveFrom:u8.Base.Widgets.Widget,attributes:{tagName:"iframe"}});u8.Base.Widgets.FormFrame.defaults={src:null};$.extend(u8.Base.Widgets.FormFrame.prototype,{setSrc:function(e){if(this.src===e){return}this.src=e;this._parseUrl();this._update()},getSrc:function(){return this.src},update:function(){this._update()},_create:function(){this.$(this.element).addClass("u8-formframe");this._parseUrl();this._setInitialPlaceholders();this._update();var e=u8.Base.Binding.getContext(this);if(e&&e instanceof u8.Base.Model){e.bind("PropertyChange",this._onContextPropertyChange.bind(this))}var t=this._onPropertyChange.bind(this);this.parameters.bind("PropertyChange",t);this.placeholders.bind("PropertyChange",t)},_update:function(){this._updateWindowName();var e=this._buildUrl();if(e==this._lastSrc){return}this._lastSrc=e;var t=this.$(this.element);t.empty().attr("src",e)},_updateWindowName:function(){var e=this._getWindowName();if(e){this.element.name=e;var t=this.element.contentWindow;if(u8.Base.CORS.isSameOrigin(t)){t.name=e}}},_getWindowName:function(){var e=this.name;if(!e){var t=u8.Base.Widgets.Tools.closest(this,"Form");e=t&&t.getWidgetId(this)}return e},_buildUrl:function(){var r=this.src;if(!r){return r}var s=this.placeholders;r=r.replace(e,function(e){e=e.substr(1,e.length-2);var r=s.get(e)||"";return encodeURIComponent(t(r))});var a=new u8.Base.Uri(r);var i=this.parameters.getProperties();for(var n in i){var o=i[n];if(o||o===0){a.params[n]=t(o)}else{delete a.params[o]}}return this.page.resolveUrl(a.toString_())},_parseUrl:function(){var t=this.src;var r={};if(t){t.replace(e,function(e){e=e.substr(1,e.length-2);r[e]=true;return""})}this._placeholders=r},_setInitialPlaceholders:function(){var e=u8.Base.Binding.getContext(this);if(e&&e instanceof u8.Base.Model){for(var t in this._placeholders){var r=e.get(t);if(typeof r!="undefined"){this.placeholders.set(t,r)}}}},_onContextPropertyChange:function(e,t){var r=t.propertyName;if(r in this._placeholders){this.placeholders.set(r,t.value)}},_onPropertyChange:function(){this.update()}});function t(e){if(e&&typeof e=="object"&&e.infoAreaId&&e.recordId&&u8.recordUidToString){return u8.recordUidToString(e)}return e}})();