Skip to content

Commit

Permalink
impr: implemented new video model properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnnyTheTank committed Dec 24, 2015
1 parent d570bc9 commit 2c005ac
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Jonathan Hornung <[email protected]>"
],
"version": "0.6.0",
"version": "0.6.1",
"description": "facebook plugin for apiNG",
"main": "dist/angular-plugin-facebook.min.js",
"moduleType": [],
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<body ng-app="app">

<aping
model="social"
model="video"
items="20"
aping-facebook="[{'page':'freundevonniemand'}]">
</aping>
Expand Down
4 changes: 2 additions & 2 deletions dist/aping-plugin-facebook.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aping-plugin-facebook",
"version": "0.6.0",
"version": "0.6.1",
"description": "facebook plugin for apiNG",
"main": "Gruntfile.js",
"scripts": {
Expand Down
2 changes: 0 additions & 2 deletions src/aping-facebook-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ var jjtApingFacebook = angular.module("jtt_aping_facebook", ['jtt_facebook'])
replace: 'false',
link: function (scope, element, attrs, apingController) {

var platform = "facebook";

var appSettings = apingController.getAppSettings();

var requests = apingUtilityHelper.parseJsonFromAttributes(attrs.apingFacebook, apingFacebookHelper.getThisPlattformString(), appSettings);
Expand Down
48 changes: 43 additions & 5 deletions src/aping-facebook-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,34 @@ jjtApingFacebook.service('apingFacebookHelper', ['apingModels', 'apingTimeHelper
return "https://facebook.com/";
};

/**
* returns object with attributes "width" and "height" of video
*
* @param _format {Object}
* @returns {Object}
*/
this.getRatioFromFormatObject = function (_format) {
var ratio = {
width:undefined,
height:undefined,
};
if (typeof _format !== "undefined" && _format.constructor === Array) {
angular.forEach(_format, function (value, key) {
if(typeof value.filter !== "undefined") {
if(value.filter === "native") {
if(typeof value.width !== "undefined") {
ratio.width = value.width;
}
if(typeof value.height !== "undefined") {
ratio.height = value.height;
}
}
}
});
return ratio;
}
};

this.getObjectByJsonData = function (_data, _helperObject) {
var requestResults = [];
if (_data) {
Expand Down Expand Up @@ -148,12 +176,22 @@ jjtApingFacebook.service('apingFacebookHelper', ['apingModels', 'apingTimeHelper

videoObject.date_time = new Date(videoObject.timestamp);

if (_item.format.length > 0) {
if(typeof _item.format !== "undefined") {
if (_item.format.length > 0) {

if (_item.format.length >= 3) {
videoObject.img_url = _item.format[2].picture;
} else {
videoObject.img_url = _item.format[_item.format.length - 1].picture;
if (_item.format.length >= 3) {
videoObject.img_url = _item.format[2].picture;
} else {
videoObject.img_url = _item.format[_item.format.length - 1].picture;
}

var ratio = this.getRatioFromFormatObject(_item.format);
if(typeof ratio.width !== "undefined") {
videoObject.width = ratio.width;
}
if(typeof ratio.height !== "undefined") {
videoObject.height = ratio.height;
}
}
}

Expand Down

0 comments on commit 2c005ac

Please sign in to comment.