Current Path : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/client/ |
Current File : /var/www/www-root/data/www/info.monolith-realty.ru/bitrix/js/landing/client/unsplash.min.js |
(function(){"use strict";BX.namespace("BX.Landing.Client");BX.Landing.Client.Unsplash=function(){if(BX.Landing.Client.Unsplash.instance){return BX.Landing.Client.Unsplash.instance}this.host="https://api.unsplash.com";this.clientId="2f2daddc0c0ea9983e1edd64ef83925faae6d6ab6bf35fe4eb64c2bcfc76fb75";this.perPage=31};BX.Landing.Client.Unsplash.getInstance=function(){return BX.Landing.Client.Unsplash.instance||(BX.Landing.Client.Unsplash.instance=new BX.Landing.Client.Unsplash)};BX.Landing.Client.Unsplash.prototype={makeUrl:function(n,e){e=typeof e==="object"?e:{};e.client_id=this.clientId;return BX.util.add_url_param(this.host+n,e)},download:function(n){var e=BX.util.add_url_param(n.links.download_location,{client_id:this.clientId});return new Promise(function(n){BX.ajax({url:e,method:"GET",headers:[{name:"Authorization",value:"Client-ID "+this.clientId}],onsuccess:function(e){try{var t=JSON.parse(e);n(t.url)}catch(e){n("");console.error(e)}}})}.bind(this))},request:function(n,e){return new Promise(function(t){BX.ajax({url:this.makeUrl(n,e),method:"GET",data:e,headers:[{name:"Authorization",value:"Client-ID "+this.clientId}],onsuccess:function(n){var e;try{e=JSON.parse(n);e="results"in e?e.results:e}catch(n){e=[];console.error(n)}t(e)}})}.bind(this))},popular:function(n){n=BX.type.isNumber(n)?n:1;return this.request("/photos",{order_by:"popular",per_page:this.perPage,page:n})},search:function(n,e){e=BX.type.isNumber(e)?e:1;return this.request("/search/photos",{per_page:this.perPage,page:e,query:encodeURI(n)})}}})();