(function(){"use strict";var e={rep:t,record:r,catalogvalue:n};u8.Mobile.Application.registerAction("selector",function(t){var r=t.type;u8.log.info("selector: item of type '"+r+"' with key '"+JSON.stringify(t.key)+"' has been selected.");var n=e[r];if(!n){u8.log.warn("selector: unknown selector type '"+r+"'. ignoring selection!");return}var i=u8.Mobile.Popup.get(t.srcElement);var o=i&&i.srcElement;t.targetElement=o;var l=new n(t);var c={type:l.type,tag:l.tag};l.createSelection(c).done(function(e){var t=null,r=$(o).widgets("closest")[0];while(r){if(r["Selector.canSelect"]&&r["Selector.canSelect"](e)){t=r;break}r=r.parent}if(!t){u8.log.warn("selector: no selection target is available. ignoring selection!");return}var n=t["Selector.select"](e,l);if(u8.tools.isPromise(n)){n.done(s)}else{s()}});function s(){u8.Mobile.Popup.close()}});u8.Mobile.Application.registerAction("selectRecord",function(e){var t=new u8.Base.Uri("~/recordselector");var r=$.extend({},e);delete r.actionName;delete r.srcElement;var n=$(e.srcElement).widgets("closest")[0];while(n){if(n["getLinks"]){r.links=n.getLinks();break}n=n.parent}t.params=r;u8.application.execute("popup",{url:t,data:{},method:"GET",srcElement:e.srcElement})});function t(e){$.extend(this,e)}t.prototype={createSelection:function(e){$.extend(e,{repId:this.key,name:this.value});return $.Deferred().resolve(e).promise()}};function r(e){$.extend(this,e)}r.prototype={createSelection:function(e){$.extend(e,{fields:this.fields,links:[this.key]});return $.Deferred().resolve(e).promise()}};function n(e){$.extend(this,e)}n.prototype={createSelection:function(e){$.extend(e,{value:this.key,text:this.name});return $.Deferred().resolve(e).promise()}}})();