/* https://github.com/jonbri/ui5query v0.0.1 Fri Mar 10 15:25:43 EST 2017 */ !function(){"use strict";function t(t){var n=b=h(t).filter(function(t){return null!==t.sIdMatch||null!==t.sNameMatch});return console.log(b.length+" search results"),m(n),c(n)}function n(){var t=b=h();return m(t),c(t)}function e(t){return l(t)}function r(){y={},y=jQuery.extend({},{},P),b=[]}function o(t){return b=t.map(function(t){return{$element:jQuery(t),sIdMatch:void 0,sNameMatch:void 0}}),p()}function a(n){return t(n,y),p()}function i(t,n,e){var r={name:t,fnFirstPass:n,fnLastPass:e};w[t]=!1,v.push(r),M[t]=function(n){return jQuery.isArray(n)?(g(r,b),n):a(n)[t]().toArray()}}function u(t){return t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function c(t){return t.map(function(t){return t.$element.control()[0]})}function l(t){var n;if("object"==typeof t)for(n in t)t.hasOwnProperty(n)&&(y[n]=t[n]);return y}function s(){return jQuery("*[id]").toArray().map(function(t){return jQuery(t)}).filter(function(t){return t.control().length>0&&t.attr("id")===t.control()[0].getId()})}function f(t,n){for(var e in n)n.hasOwnProperty(e)&&t.css(e,n[e])}function h(t){var n;void 0===t&&(t=/.*/);try{n=t instanceof RegExp?t:new RegExp(t,"i")}catch(e){n=new RegExp(u(t),"i")}return s().map(function(t){return{$element:t,idMatch:t.attr("id").match(n),controlNameMatch:t.control()[0].getMetadata().getName().match(n)}}).map(function(t){return{$element:t.$element,sIdMatch:null!==t.idMatch?t.idMatch[0]:null,sNameMatch:null!==t.controlNameMatch?t.controlNameMatch[0]:null}})}function d(){M.target=void 0,delete M.target,[0,1,2,3,4,5,6,7,8,9].forEach(function(t){M["target"+t]=void 0,delete M["target"+t]})}function m(t){d(),t.length>0&&(M.target=t[0].$element.control()[0],t.slice(0,10).forEach(function(t,n){M["target"+n]=t.$element.control()[0]}))}function p(){var t={toArray:function(){return b.map(function(t){return t.$element.get(0)})},pipe:a};return v.forEach(function(n){t[n.name]=function(){return g(n,b),p()}}),t}function g(t,n){return w[t.name]===!1&&(w[t.name]=!0,Promise.all(n.map(function(n){var e={idMatch:n.sIdMatch,nameMatch:n.sNameMatch};return n=n.$element,t.fnFirstPass.call(e,n),new Promise(function(r){setTimeout(function(){t.fnLastPass.call(e,n),r()},y.standoutDelay)})})).then(function(){w[t.name]=!1})),n}var y,M=function(t){return a(t)},v=[],$=["popup","highlight"],b=[],w={},P={standoutDelay:3e3,labelStyle:{border:"1px solid #c2d6d6",backgroundColor:"#FFF",color:"#000",fontSize:"10px",position:"absolute"},controlStyle:{border:"2px solid #00FF00"}};i("popup",function(t){var n=t.offset(),e=jQuery("").addClass("ui5query_label").css("left",n.left).css("top",n.top);f(e,y.labelStyle),e.html([t.attr("id").replace(new RegExp("("+this.idMatch+")"),"$1"),t.control()[0].getMetadata().getName().replace(new RegExp("("+this.nameMatch+")"),"$1")].reduce(function(t,n){return t+"
"+n})).appendTo(document.body),this.$label=e},function(t){this.$label.remove()}),i("highlight",function(t){this.sOrigBorder=t.css("border"),f(t,y.controlStyle),t.addClass("ui5query_match")},function(t){t.css("border",this.sOrigBorder),t.removeClass("ui5query_match")}),i("standout",function(t){var n=this;$.forEach(function(e){v.filter(function(t){return t.name===e})[0].fnFirstPass.call(n,t)})},function(t){var n=this;$.forEach(function(e){v.filter(function(t){return t.name===e})[0].fnLastPass.call(n,t)})}),r(),M.pipe=a,M.search=t,M.all=n,M.config=e,M.reset=r,M.plugin=i,M.toPipeline=o,window.ui$=M,window.ui5Query=M}();