From 2c45769464b83c824eb4a9e5173122d0f6ac36ed Mon Sep 17 00:00:00 2001 From: Jonathan Hornung Date: Mon, 7 Mar 2016 21:49:20 +0100 Subject: [PATCH] finally fixed the inline template issue --- bower.json | 2 +- demos/jsonloader/index.html | 1 - dist/aping.js | 3 ++- dist/aping.min.js | 4 ++-- package.json | 2 +- src/aping-directive.js | 1 + 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 9ac2cc6..6e60804 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "apiNG", - "version": "1.2.8", + "version": "1.2.9", "homepage": "https://github.com/JohnnyTheTank/apiNG", "authors": [ "Jonathan Hornung " diff --git a/demos/jsonloader/index.html b/demos/jsonloader/index.html index e2884d2..20a3225 100644 --- a/demos/jsonloader/index.html +++ b/demos/jsonloader/index.html @@ -5,7 +5,6 @@ apiNG Demo - diff --git a/dist/aping.js b/dist/aping.js index 6242845..2ecefe0 100644 --- a/dist/aping.js +++ b/dist/aping.js @@ -1,6 +1,6 @@ /** @name: aping - @version: 1.2.8 (07-03-2016) + @version: 1.2.9 (07-03-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/apiNG @license: MIT @@ -62,6 +62,7 @@ angular.module('jtt_aping') }); } else { transcludeFn(scope, function (clone, innerScope) { + element.html(""); element.append(clone); $compile(clone)(innerScope); }); diff --git a/dist/aping.min.js b/dist/aping.min.js index 4ff6ba1..c6c576c 100644 --- a/dist/aping.min.js +++ b/dist/aping.min.js @@ -1,8 +1,8 @@ /** @name: aping - @version: 1.2.8 (07-03-2016) + @version: 1.2.9 (07-03-2016) @author: Jonathan Hornung @url: https://github.com/JohnnyTheTank/apiNG @license: MIT */ -"use strict";angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array","jtt_aping_local_storage"]),angular.module("jtt_aping").config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).value("apingResults",{}).directive("aping",["apingResults","apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d,e){return{restrict:"E",transclude:!0,template:"",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@",mergeDoubles:"@",idBy:"@",resultProperty:"@",valueName:"@"},link:function(a,c,f,g,h){function i(b){angular.isDefined(b)&&"$NONE"!==b?d(b).then(function(b){var d=angular.element(b);c.empty().append(d),e(d)(a)}):h(a,function(a,b){c.append(a),e(a)(b)}),a.$broadcast("apiNG.templateRendered")}var j=a.templateUrl;a.$watch("templateUrl",function(){i(a.templateUrl)}),angular.isUndefined(j)&&angular.isDefined(b.templateUrl)&&(j=b.templateUrl,i(j))},controller:["$scope",function(d){angular.isUndefined(d.resultProperty)&&(d.resultProperty="results"),d[d.resultProperty]=[],d.payload=d.payloadJson?c.replaceSingleQuotesAndParseJson(d.payloadJson):{},this.getAppSettings=function(){var a,c,e,f,g,h,i,j,k;return j=angular.isDefined(d.valueName)?d.valueName:void 0,a=angular.isDefined(d.items)?d.items:angular.isDefined(b.items)?b.items:void 0,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,e=angular.isDefined(d.getNativeData)?d.getNativeData:angular.isDefined(b.getNativeData)?b.getNativeData:!1,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,g=angular.isDefined(d.orderBy)?d.orderBy:angular.isDefined(b.orderBy)?b.orderBy:void 0,f=angular.isDefined(d.orderReverse)?d.orderReverse:angular.isDefined(b.orderReverse)?b.orderReverse:!1,h=angular.isDefined(d.removeDoubles)?d.removeDoubles:angular.isDefined(b.removeDoubles)?b.removeDoubles:!1,i=angular.isDefined(d.mergeDoubles)?d.mergeDoubles:angular.isDefined(b.mergeDoubles)?b.mergeDoubles:!1,k=angular.isDefined(d.idBy)?d.idBy:angular.isDefined(b.idBy)?b.idBy:void 0,{model:d.model||b.model||"native",getNativeData:e,items:a,maxItems:c,orderBy:g,orderReverse:f,removeDoubles:h,mergeDoubles:i,idBy:k,valueName:j}},this.concatToResults=function(b){angular.isUndefined(d.resultProperty)&&(d.resultProperty="results");var e=d[d.resultProperty].concat(b),f=this.getAppSettings();angular.isDefined(f.idBy)&&(e=c.createIdByPropertiesForArray(e,f.idBy),f.mergeDoubles!==!0&&"true"!==f.mergeDoubles||(e=c.mergeDuplicateObjectsFromArray(e,f.orderBy===!1||"false"===f.orderBy||"$NONE"===f.orderBy))),f.removeDoubles!==!0&&"true"!==f.removeDoubles||f.mergeDoubles!==!0&&"true"!==f.mergeDoubles&&(e=c.removeDuplicateObjectsFromArray(e,f.orderBy===!1||"false"===f.orderBy||"$NONE"===f.orderBy,angular.isDefined(f.idBy))),angular.isDefined(f.orderBy)&&f.orderBy!==!1&&"false"!==f.orderBy&&"$NONE"!==f.orderBy&&("$RANDOM"===f.orderBy?e=c.shuffleArray(e):e.sort(c.sortArrayByProperty(f.orderBy))),f.orderReverse!==!0&&"true"!==f.orderReverse||"$RANDOM"===f.orderBy||e.reverse(),f.maxItems>-1&&e.length>f.maxItems&&(e=e.splice(0,f.maxItems)),angular.isDefined(f.valueName)&&(a[f.valueName]=e),d[d.resultProperty]=e,d.$broadcast("apiNG.resultMerged",{resultProperty:d.resultProperty})},this.apply=function(){d.$apply()}}]}}]),angular.module("jtt_aping").service("apingTimeHelper",function(){this.getTimestampFromDateString=function(a,b,c){if((angular.isUndefined(b)||isNaN(b))&&(b=1),(angular.isUndefined(c)||isNaN(c))&&(c=0),"string"==typeof a){var d=a.split(/[^0-9]/);try{return parseInt(Math.round(new Date(d[0],d[1]-1,d[2],d[3],d[4],d[5])/1e3*b)+c,10)}catch(e){return 0}}return 0}}).service("apingUtilityHelper",["apingInputObjects","apingDefaultSettings",function(a,b){this.getApiCredentials=function(a,c){return b.apingApiKeys&&b.apingApiKeys[a]?b.apingApiKeys[a][Math.floor(Math.random()*b.apingApiKeys[a].length)][c]:!1},this.parseJsonFromAttributes=function(a,b,c){return this.parseRequestsFromAttributes(a,b,c)},this.getDifference=function(a,b){return a>b?a-b:b-a},this.parseRequestsFromAttributes=function(b,c,d){if("string"!=typeof b||!b)return[];var e=[],f=this.replaceSingleQuotesAndParseJson(b);return angular.forEach(f,function(b,f){b.platform=c,d&&(angular.isUndefined(b.items)&&angular.isDefined(d.items)&&(b.items=d.items),angular.isUndefined(b.model)&&angular.isDefined(d.model)&&(b.model=d.model));var g=a.getNew("request",b);e.push(g)}),e},this.replaceSingleQuotesAndParseJson=function(a){return angular.fromJson(a.replace(/'/g,'"'))},this.sortArrayByProperty=function(a){var b=1;return"-"===a[0]&&(b=-1,a=a.substr(1)),function(c,d){var e=c[a]d[a]?1:0;return e*b}},this.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},this.removeNullIn=function(a,b){var c=b[a];if(null===c||void 0===c)delete b[a];else if("object"==typeof c)for(var d in c)this.removeNullIn(d,c)},this.removeNull=function(a){for(var b in a)this.removeNullIn(b,a)},this.removeDuplicateObjectsFromArray=function(a,b,c){var d,e=[];d=c?"aping_id":"apingStringified";var f="apingTempOrder";if(1===a.length)return a;angular.forEach(a,function(a,g){c||(a.$$hashKey=void 0,a[d]=JSON.stringify(a)),b===!0&&(a[f]=g),e.push(a)}),e.sort(this.sortArrayByProperty(d));var g,h=[];return angular.forEach(e,function(a,b){angular.isDefined(g)?angular.isDefined(a[d])&&a[d]!==g&&h.push(a):h.push(a),g=a[d],c||(a[d]=void 0)}),b===!0&&(h.sort(this.sortArrayByProperty(f)),angular.forEach(h,function(a,b){a[f]=void 0})),h},this.mergeDuplicateObjectsFromArray=function(a,b){var c=this,d=[],e="aping_id",f="apingTempOrder";if(1===a.length)return a;angular.forEach(a,function(a,c){b===!0&&(a[f]=c),d.push(a)}),d.sort(this.sortArrayByProperty(e));var g,h=[];return angular.forEach(d,function(a,b){c.removeNull(a),angular.isDefined(g)?angular.isDefined(a[e])&&a[e]!==g?h.push(a):h[h.length-1]=angular.merge(h[h.length-1],h[h.length-1],a):h.push(a),g=a[e]}),b===!0&&(h.sort(this.sortArrayByProperty(f)),angular.forEach(h,function(a,b){a[f]=void 0})),h},this.getTextFromHtml=function(a){return a=a.replace(/<br ?\/\>|<br ?\/&rt;|\
/g," "),a=a.replace(/<(?:.|\n)*?>/gm,"")},this.getFirstImageFromHtml=function(a){var b=/]+src="([^">]+)/g;return b.exec(a)},this.parseParametersFromUrl=function(a){var b={};return"string"==typeof a&&(b=JSON.parse('{"'+decodeURI(a.replace(/&/g,'","').replace(/=/g,'":"'))+'"}')),b},this.createIdByPropertiesForArray=function(a,b,c){var d=this;return!angular.isUndefined(c)&&angular.isString(c)||(c="aping_id"),angular.isDefined(a)&&angular.isArray(a)&&angular.forEach(a,function(a,e){a[c]=d.getIdByPropertiesForObject(a,b)}),a},this.getIdByPropertiesForObject=function(a,b){var c=this,d="";if(angular.isDefined(a)&&angular.isObject(a)){var e=[];"["===b.substr(0,1)?e=this.replaceSingleQuotesAndParseJson(b):e.push(b),angular.forEach(e,function(b,e){d+=c.getValueFromObjectByPropertyString(a,b)})}return d},this.getValueFromObjectByPropertyString=function(a,b,c){var d="";if(angular.isDefined(a)&&angular.isObject(a)){var e=b.split("."),f=a;angular.forEach(e,function(a,b){angular.isDefined(f[a])&&(f=f[a])}),angular.isDefined(f)&&(d=c&&angular.isObject(f)?JSON.stringify(f):f)}return d}}]),angular.module("jtt_aping").service("apingInputObjects",["apingDefaultSettings",function(a){this.getNew=function(b,c){var d={};switch(b){case"request":d=angular.extend({model:a.model},c)}return d}}]),angular.module("jtt_aping").service("apingModels",[function(){this.getNew=function(a,b){var c={};switch(a){case"social":c={platform:b};break;case"video":c={platform:b};break;case"image":c={platform:b};break;case"event":c={platform:b};break;case"repo":c={platform:b};break;case"weather":c={platform:b}}return c}}]),angular.module("jtt_aping_jsonloader",[]).directive("apingJsonloader",["apingUtilityHelper","jsonloaderFactory",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingJsonloader,"jsonloader",g);h.forEach(function(c){if(c.path){var d={path:c.path};if(c.format&&"jsonp"===c.format.toLowerCase()?d.format="jsonp":d.format="json",angular.isUndefined(c.items)&&(c.items=g.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0),angular.isDefined(c.orderBy)&&!angular.isString(c.orderBy)&&(c.orderBy=void 0),!angular.isDefined(c.orderReverse)||c.orderReverse!==!0&&"true"!==c.orderReverse||(c.orderReverse=!0),b.getJsonData(d).then(function(b){var d=[];if(b.data){var e=b.data;angular.isDefined(c.resultProperty)&&(e=a.getValueFromObjectByPropertyString(b.data,c.resultProperty,!1)),b.data.constructor!==Array?d.push(e):(angular.extend(d,e),angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isUndefined(c.items)?d=e:c.items>0&&d.length>c.items&&(d=d.splice(0,c.items)))}f.concatToResults(d)})}})}}}]).factory("jsonloaderFactory",["$http",function(a){var b={};return b.getJsonData=function(b){var c={};return"jsonp"===b.format?a.jsonp(b.path,{method:"GET",params:{callback:"JSON_CALLBACK"}}):a({method:"GET",url:b.path,params:c})},b}]),angular.module("jtt_aping_ng_array",[]).directive("apingNgArray",["apingUtilityHelper",function(a){return{require:"?aping",restrict:"A",replace:"false",link:function(b,c,d,e){var f=e.getAppSettings(),g=a.parseJsonFromAttributes(d.apingNgArray,"ngArray",f);g.forEach(function(c){if(c.name&&b[c.name]){if(angular.isUndefined(c.items)&&(c.items=f.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0);var d=[];b[c.name].constructor===Array?(d=b[c.name],angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isDefined(c.items)&&c.items>0&&d.length>c.items&&(d=d.splice(0,c.items))):"object"==typeof b[c.name]&&null!==b[c.name]&&d.push(b[c.name]),d.length>0&&e.concatToResults(d)}})}}}]),angular.module("jtt_aping_local_storage",[]).directive("apingLocalStorage",["apingUtilityHelper","apingLocalStorage",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingLocalStorage,"localStorage",g);h.forEach(function(c){if(c.key){if(angular.isUndefined(c.items)&&(c.items=g.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0),angular.isDefined(c.orderBy)&&!angular.isString(c.orderBy)&&(c.orderBy=void 0),!angular.isDefined(c.orderReverse)||c.orderReverse!==!0&&"true"!==c.orderReverse||(c.orderReverse=!0),b.get(c.key).then(function(b){var d=[];if(b){var e=b;angular.isDefined(c.resultProperty)&&(e=a.getValueFromObjectByPropertyString(b,c.resultProperty,!1)),angular.isArray(b)?(d=e,angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isUndefined(c.items)?d=e:c.items>0&&d.length>c.items&&(d=d.splice(0,c.items))):d.push(e)}f.concatToResults(d)})}})}}}]).factory("apingLocalStorage",["$window","$q",function(a,b){var c=function(c,d){var e=b.defer();return e.resolve(a.localStorage&&a.localStorage.setItem(c,angular.toJson(d))),e.promise},d=function(c){var d=b.defer();return d.resolve(a.localStorage&&angular.fromJson(a.localStorage.getItem(c))),d.promise};return{set:c,get:d}}]); \ No newline at end of file +"use strict";angular.module("jtt_aping",["jtt_aping_jsonloader","jtt_aping_ng_array","jtt_aping_local_storage"]),angular.module("jtt_aping").config(["$provide",function(a){a.value("apingDefaultSettings",{apingApiKeys:{}})}]).value("apingResults",{}).directive("aping",["apingResults","apingDefaultSettings","apingUtilityHelper","$templateRequest","$compile",function(a,b,c,d,e){return{restrict:"E",transclude:!0,template:"",scope:{model:"@",getNativeData:"@",items:"@",maxItems:"@",orderBy:"@",orderReverse:"@",templateUrl:"@",payloadJson:"@",removeDoubles:"@",mergeDoubles:"@",idBy:"@",resultProperty:"@",valueName:"@"},link:function(a,c,f,g,h){function i(b){angular.isDefined(b)&&"$NONE"!==b?d(b).then(function(b){var d=angular.element(b);c.empty().append(d),e(d)(a)}):h(a,function(a,b){c.html(""),c.append(a),e(a)(b)}),a.$broadcast("apiNG.templateRendered")}var j=a.templateUrl;a.$watch("templateUrl",function(){i(a.templateUrl)}),angular.isUndefined(j)&&angular.isDefined(b.templateUrl)&&(j=b.templateUrl,i(j))},controller:["$scope",function(d){angular.isUndefined(d.resultProperty)&&(d.resultProperty="results"),d[d.resultProperty]=[],d.payload=d.payloadJson?c.replaceSingleQuotesAndParseJson(d.payloadJson):{},this.getAppSettings=function(){var a,c,e,f,g,h,i,j,k;return j=angular.isDefined(d.valueName)?d.valueName:void 0,a=angular.isDefined(d.items)?d.items:angular.isDefined(b.items)?b.items:void 0,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,e=angular.isDefined(d.getNativeData)?d.getNativeData:angular.isDefined(b.getNativeData)?b.getNativeData:!1,c=angular.isDefined(d.maxItems)?d.maxItems:angular.isDefined(b.maxItems)?b.maxItems:void 0,g=angular.isDefined(d.orderBy)?d.orderBy:angular.isDefined(b.orderBy)?b.orderBy:void 0,f=angular.isDefined(d.orderReverse)?d.orderReverse:angular.isDefined(b.orderReverse)?b.orderReverse:!1,h=angular.isDefined(d.removeDoubles)?d.removeDoubles:angular.isDefined(b.removeDoubles)?b.removeDoubles:!1,i=angular.isDefined(d.mergeDoubles)?d.mergeDoubles:angular.isDefined(b.mergeDoubles)?b.mergeDoubles:!1,k=angular.isDefined(d.idBy)?d.idBy:angular.isDefined(b.idBy)?b.idBy:void 0,{model:d.model||b.model||"native",getNativeData:e,items:a,maxItems:c,orderBy:g,orderReverse:f,removeDoubles:h,mergeDoubles:i,idBy:k,valueName:j}},this.concatToResults=function(b){angular.isUndefined(d.resultProperty)&&(d.resultProperty="results");var e=d[d.resultProperty].concat(b),f=this.getAppSettings();angular.isDefined(f.idBy)&&(e=c.createIdByPropertiesForArray(e,f.idBy),f.mergeDoubles!==!0&&"true"!==f.mergeDoubles||(e=c.mergeDuplicateObjectsFromArray(e,f.orderBy===!1||"false"===f.orderBy||"$NONE"===f.orderBy))),f.removeDoubles!==!0&&"true"!==f.removeDoubles||f.mergeDoubles!==!0&&"true"!==f.mergeDoubles&&(e=c.removeDuplicateObjectsFromArray(e,f.orderBy===!1||"false"===f.orderBy||"$NONE"===f.orderBy,angular.isDefined(f.idBy))),angular.isDefined(f.orderBy)&&f.orderBy!==!1&&"false"!==f.orderBy&&"$NONE"!==f.orderBy&&("$RANDOM"===f.orderBy?e=c.shuffleArray(e):e.sort(c.sortArrayByProperty(f.orderBy))),f.orderReverse!==!0&&"true"!==f.orderReverse||"$RANDOM"===f.orderBy||e.reverse(),f.maxItems>-1&&e.length>f.maxItems&&(e=e.splice(0,f.maxItems)),angular.isDefined(f.valueName)&&(a[f.valueName]=e),d[d.resultProperty]=e,d.$broadcast("apiNG.resultMerged",{resultProperty:d.resultProperty})},this.apply=function(){d.$apply()}}]}}]),angular.module("jtt_aping").service("apingTimeHelper",function(){this.getTimestampFromDateString=function(a,b,c){if((angular.isUndefined(b)||isNaN(b))&&(b=1),(angular.isUndefined(c)||isNaN(c))&&(c=0),"string"==typeof a){var d=a.split(/[^0-9]/);try{return parseInt(Math.round(new Date(d[0],d[1]-1,d[2],d[3],d[4],d[5])/1e3*b)+c,10)}catch(e){return 0}}return 0}}).service("apingUtilityHelper",["apingInputObjects","apingDefaultSettings",function(a,b){this.getApiCredentials=function(a,c){return b.apingApiKeys&&b.apingApiKeys[a]?b.apingApiKeys[a][Math.floor(Math.random()*b.apingApiKeys[a].length)][c]:!1},this.parseJsonFromAttributes=function(a,b,c){return this.parseRequestsFromAttributes(a,b,c)},this.getDifference=function(a,b){return a>b?a-b:b-a},this.parseRequestsFromAttributes=function(b,c,d){if("string"!=typeof b||!b)return[];var e=[],f=this.replaceSingleQuotesAndParseJson(b);return angular.forEach(f,function(b,f){b.platform=c,d&&(angular.isUndefined(b.items)&&angular.isDefined(d.items)&&(b.items=d.items),angular.isUndefined(b.model)&&angular.isDefined(d.model)&&(b.model=d.model));var g=a.getNew("request",b);e.push(g)}),e},this.replaceSingleQuotesAndParseJson=function(a){return angular.fromJson(a.replace(/'/g,'"'))},this.sortArrayByProperty=function(a){var b=1;return"-"===a[0]&&(b=-1,a=a.substr(1)),function(c,d){var e=c[a]d[a]?1:0;return e*b}},this.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},this.removeNullIn=function(a,b){var c=b[a];if(null===c||void 0===c)delete b[a];else if("object"==typeof c)for(var d in c)this.removeNullIn(d,c)},this.removeNull=function(a){for(var b in a)this.removeNullIn(b,a)},this.removeDuplicateObjectsFromArray=function(a,b,c){var d,e=[];d=c?"aping_id":"apingStringified";var f="apingTempOrder";if(1===a.length)return a;angular.forEach(a,function(a,g){c||(a.$$hashKey=void 0,a[d]=JSON.stringify(a)),b===!0&&(a[f]=g),e.push(a)}),e.sort(this.sortArrayByProperty(d));var g,h=[];return angular.forEach(e,function(a,b){angular.isDefined(g)?angular.isDefined(a[d])&&a[d]!==g&&h.push(a):h.push(a),g=a[d],c||(a[d]=void 0)}),b===!0&&(h.sort(this.sortArrayByProperty(f)),angular.forEach(h,function(a,b){a[f]=void 0})),h},this.mergeDuplicateObjectsFromArray=function(a,b){var c=this,d=[],e="aping_id",f="apingTempOrder";if(1===a.length)return a;angular.forEach(a,function(a,c){b===!0&&(a[f]=c),d.push(a)}),d.sort(this.sortArrayByProperty(e));var g,h=[];return angular.forEach(d,function(a,b){c.removeNull(a),angular.isDefined(g)?angular.isDefined(a[e])&&a[e]!==g?h.push(a):h[h.length-1]=angular.merge(h[h.length-1],h[h.length-1],a):h.push(a),g=a[e]}),b===!0&&(h.sort(this.sortArrayByProperty(f)),angular.forEach(h,function(a,b){a[f]=void 0})),h},this.getTextFromHtml=function(a){return a=a.replace(/<br ?\/\>|<br ?\/&rt;|\
/g," "),a=a.replace(/<(?:.|\n)*?>/gm,"")},this.getFirstImageFromHtml=function(a){var b=/]+src="([^">]+)/g;return b.exec(a)},this.parseParametersFromUrl=function(a){var b={};return"string"==typeof a&&(b=JSON.parse('{"'+decodeURI(a.replace(/&/g,'","').replace(/=/g,'":"'))+'"}')),b},this.createIdByPropertiesForArray=function(a,b,c){var d=this;return!angular.isUndefined(c)&&angular.isString(c)||(c="aping_id"),angular.isDefined(a)&&angular.isArray(a)&&angular.forEach(a,function(a,e){a[c]=d.getIdByPropertiesForObject(a,b)}),a},this.getIdByPropertiesForObject=function(a,b){var c=this,d="";if(angular.isDefined(a)&&angular.isObject(a)){var e=[];"["===b.substr(0,1)?e=this.replaceSingleQuotesAndParseJson(b):e.push(b),angular.forEach(e,function(b,e){d+=c.getValueFromObjectByPropertyString(a,b)})}return d},this.getValueFromObjectByPropertyString=function(a,b,c){var d="";if(angular.isDefined(a)&&angular.isObject(a)){var e=b.split("."),f=a;angular.forEach(e,function(a,b){angular.isDefined(f[a])&&(f=f[a])}),angular.isDefined(f)&&(d=c&&angular.isObject(f)?JSON.stringify(f):f)}return d}}]),angular.module("jtt_aping").service("apingInputObjects",["apingDefaultSettings",function(a){this.getNew=function(b,c){var d={};switch(b){case"request":d=angular.extend({model:a.model},c)}return d}}]),angular.module("jtt_aping").service("apingModels",[function(){this.getNew=function(a,b){var c={};switch(a){case"social":c={platform:b};break;case"video":c={platform:b};break;case"image":c={platform:b};break;case"event":c={platform:b};break;case"repo":c={platform:b};break;case"weather":c={platform:b}}return c}}]),angular.module("jtt_aping_jsonloader",[]).directive("apingJsonloader",["apingUtilityHelper","jsonloaderFactory",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingJsonloader,"jsonloader",g);h.forEach(function(c){if(c.path){var d={path:c.path};if(c.format&&"jsonp"===c.format.toLowerCase()?d.format="jsonp":d.format="json",angular.isUndefined(c.items)&&(c.items=g.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0),angular.isDefined(c.orderBy)&&!angular.isString(c.orderBy)&&(c.orderBy=void 0),!angular.isDefined(c.orderReverse)||c.orderReverse!==!0&&"true"!==c.orderReverse||(c.orderReverse=!0),b.getJsonData(d).then(function(b){var d=[];if(b.data){var e=b.data;angular.isDefined(c.resultProperty)&&(e=a.getValueFromObjectByPropertyString(b.data,c.resultProperty,!1)),b.data.constructor!==Array?d.push(e):(angular.extend(d,e),angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isUndefined(c.items)?d=e:c.items>0&&d.length>c.items&&(d=d.splice(0,c.items)))}f.concatToResults(d)})}})}}}]).factory("jsonloaderFactory",["$http",function(a){var b={};return b.getJsonData=function(b){var c={};return"jsonp"===b.format?a.jsonp(b.path,{method:"GET",params:{callback:"JSON_CALLBACK"}}):a({method:"GET",url:b.path,params:c})},b}]),angular.module("jtt_aping_ng_array",[]).directive("apingNgArray",["apingUtilityHelper",function(a){return{require:"?aping",restrict:"A",replace:"false",link:function(b,c,d,e){var f=e.getAppSettings(),g=a.parseJsonFromAttributes(d.apingNgArray,"ngArray",f);g.forEach(function(c){if(c.name&&b[c.name]){if(angular.isUndefined(c.items)&&(c.items=f.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0);var d=[];b[c.name].constructor===Array?(d=b[c.name],angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isDefined(c.items)&&c.items>0&&d.length>c.items&&(d=d.splice(0,c.items))):"object"==typeof b[c.name]&&null!==b[c.name]&&d.push(b[c.name]),d.length>0&&e.concatToResults(d)}})}}}]),angular.module("jtt_aping_local_storage",[]).directive("apingLocalStorage",["apingUtilityHelper","apingLocalStorage",function(a,b){return{require:"?aping",restrict:"A",replace:"false",link:function(c,d,e,f){var g=f.getAppSettings(),h=a.parseJsonFromAttributes(e.apingLocalStorage,"localStorage",g);h.forEach(function(c){if(c.key){if(angular.isUndefined(c.items)&&(c.items=g.items),0===c.items||"0"===c.items)return!1;(c.items<0||isNaN(c.items))&&(c.items=void 0),angular.isDefined(c.orderBy)&&!angular.isString(c.orderBy)&&(c.orderBy=void 0),!angular.isDefined(c.orderReverse)||c.orderReverse!==!0&&"true"!==c.orderReverse||(c.orderReverse=!0),b.get(c.key).then(function(b){var d=[];if(b){var e=b;angular.isDefined(c.resultProperty)&&(e=a.getValueFromObjectByPropertyString(b,c.resultProperty,!1)),angular.isArray(b)?(d=e,angular.isDefined(c.orderBy)&&("$RANDOM"===c.orderBy?d=a.shuffleArray(d):d.sort(a.sortArrayByProperty(c.orderBy))),angular.isDefined(c.orderReverse)&&c.orderReverse===!0&&"$RANDOM"!==c.orderBy&&d.reverse(),angular.isUndefined(c.items)?d=e:c.items>0&&d.length>c.items&&(d=d.splice(0,c.items))):d.push(e)}f.concatToResults(d)})}})}}}]).factory("apingLocalStorage",["$window","$q",function(a,b){var c=function(c,d){var e=b.defer();return e.resolve(a.localStorage&&a.localStorage.setItem(c,angular.toJson(d))),e.promise},d=function(c){var d=b.defer();return d.resolve(a.localStorage&&angular.fromJson(a.localStorage.getItem(c))),d.promise};return{set:c,get:d}}]); \ No newline at end of file diff --git a/package.json b/package.json index ee65eaa..0f256f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aping", - "version": "1.2.8", + "version": "1.2.9", "description": "apiNG is an AngularJS directive that enables you to receive, aggregate, limit, order and display data from one or more sources. The complete setup is dead simple, just by adding data-attributes to your html", "main": "dist/aping.min.js", "scripts": { diff --git a/src/aping-directive.js b/src/aping-directive.js index 1e1a308..65dd1b0 100644 --- a/src/aping-directive.js +++ b/src/aping-directive.js @@ -51,6 +51,7 @@ angular.module('jtt_aping') }); } else { transcludeFn(scope, function (clone, innerScope) { + element.html(""); element.append(clone); $compile(clone)(innerScope); });