text: "use strict";angular.module("jtt_aping_flickr",["jtt_flickr"]).directive("apingFlickr",["apingFlickrHelper","apingUtilityHelper","flickrFactory",function(s,n,o){return{require:"?aping",restrict:"A",replace:"false",link:function(t,e,i,a){var r=a.getAppSettings();n.parseJsonFromAttributes(i.apingFlickr,s.getThisPlatformString(),r).forEach(function(t){var e={model:r.model};if(void 0!==t.items?e.items=t.items:e.items=r.items,void 0!==r.getNativeData?e.getNativeData=r.getNativeData:e.getNativeData=!1,0===e.items||"0"===e.items)return!1;(e.items<0||isNaN(e.items))&&(e.items=void 0),20<e.items&&(e.items=20);var i={items:e.items};void 0!==t.language&&(i.lang=t.language),t.userId?(i.id=t.userId,o.getImagesFromUserById(i).then(function(t){a.concatToResults(s.getObjectByJsonData(t,e))})):t.tags&&(i.tags=t.tags,t.tagmode&&(i.tagmode=t.tagmode),o.getImagesByTags(i).then(function(t){a.concatToResults(s.getObjectByJsonData(t,e))}))})}}}]),angular.module("jtt_aping_flickr").service("apingFlickrHelper",["apingModels","apingTimeHelper","apingUtilityHelper",function(i,a,r){this.getThisPlatformString=function(){return"flickr"},this.getThisPlatformLink=function(){return"http://flickr.com/"},this.getUserNameFromString=function(t){var e=t.replace("nobody@flickr.com (","");return e=e.substr(0,e.length-1)},this.removeOverHeadFromDescription=function(t){if(angular.isDefined(t)&&"string"==typeof t){var e=t.split("posted a photo:");1<e.length&&(t=e[1].trim()),""===t&&(t=void 0)}return t},this.getObjectByJsonData=function(t,a){var r=[];if(t){var s=this;t.data&&t.data.items&&angular.forEach(t.data.items,function(t,e){if(angular.isUndefined(a.items)||0<a.items&&r.length<a.items){var i=s.getItemByJsonData(t,a);i&&r.push(i)}})}return r},this.getItemByJsonData=function(t,e){var i={};if(t&&e.model)if(!0===e.getNativeData||"true"===e.getNativeData)i=this.getNativeItemByJsonData(t);else switch(e.model){case"social":i=this.getSocialItemByJsonData(t);break;case"image":i=this.getImageItemByJsonData(t);break;default:return!1}return i},this.getSocialItemByJsonData=function(t){var e=i.getNew("social",this.getThisPlatformString());return angular.extend(e,{blog_name:t.author?this.getUserNameFromString(t.author):void 0,blog_id:t.author_id||void 0,blog_link:t.author_id?this.getThisPlatformLink()+t.author_id:void 0,timestamp:a.getTimestampFromDateString(t.published,1e3,36e5),post_url:t.link,intern_id:2<=t.link.split("flickr.com").length?t.link.split("flickr.com")[1]:void 0,thumb_url:t.media?t.media.m:void 0,img_url:t.media?t.media.m.replace("_m.","."):void 0}),e.native_url=e.img_url,e.text=t.description?this.removeOverHeadFromDescription(r.getTextFromHtml(t.description)):void 0,t.title&&(e.text?e.caption=t.title:e.text=t.title),e.date_time=new Date(e.timestamp),-1<t.description.indexOf("posted a photo")&&(e.type="image",e)},this.getImageItemByJsonData=function(t){var e=i.getNew("image",this.getThisPlatformString());return angular.extend(e,{blog_name:t.author?this.getUserNameFromString(t.author):void 0,blog_id:t.author_id||void 0,blog_link:t.author_id?this.getThisPlatformLink()+t.author_id:void 0,timestamp:a.getTimestampFromDateString(t.published,1e3,36e5),post_url:t.link,intern_id:2<=t.link.split("flickr.com").length?t.link.split("flickr.com")[1]:void 0,thumb_url:t.media?t.media.m:void 0,img_url:t.media?t.media.m.replace("_m.","."):void 0}),e.native_url=e.img_url,e.text=t.description?this.removeOverHeadFromDescription(r.getTextFromHtml(t.description)):void 0,t.title&&"untitled"!==t.title.toLowerCase()&&(e.text?e.caption=t.title:e.text=t.title),e.date_time=new Date(e.timestamp),!(t.description.indexOf("posted a photo")<=0)&&e},this.getNativeItemByJsonData=function(t){return!(t.description.indexOf("posted a photo")<=0)&&t}}]),angular.module("jtt_flickr",[]).factory("flickrFactory",["$http","flickrSearchDataService",function(i,a){var t={getImagesFromUserById:function(t){var e=a.getNew("imagesFromUserById",t);return i({method:"JSONP",url:e.url,params:e.object})},getImagesFromGroupOfUsersByIds:function(t){var e=a.getNew("imagesFromGroupOfUsersByIds",t);return i({method:"JSONP",url:e.url,params:e.object})},getImagesByTags:function(t){var e=a.getNew("imagesByTags",t);return i({method:"JSONP",url:e.url,params:e.object})}};return t}]).service("flickrSearchDataService",function(){this.getApiBaseUrl=function(t){return"https://api.flickr.com/services/feeds/photos_public.gne"},this.fillDataInObjectByList=function(i,a,t){return angular.forEach(t,function(t,e){angular.isDefined(a[t])&&(i.object[t]=a[t])}),i},this.getNew=function(t,e){var i={object:{jsoncallback:"JSON_CALLBACK",format:"json"},url:""};switch(t){case"imagesFromUserById":(i=this.fillDataInObjectByList(i,e,["lang","id"])).url=this.getApiBaseUrl();break;case"imagesFromGroupOfUsersByIds":(i=this.fillDataInObjectByList(i,e,["lang","ids"])).url=this.getApiBaseUrl();break;case"imagesByTags":(i=this.fillDataInObjectByList(i,e,["lang","tags","tagmode"])).url=this.getApiBaseUrl()}return i}});