Skip to content

Commit

Permalink
Display system Fonts List fontman/fontman-desktop-core#11
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsandaruwan committed Feb 3, 2017
1 parent ea282f2 commit 48a54b5
Show file tree
Hide file tree
Showing 6 changed files with 186 additions and 259 deletions.
2 changes: 1 addition & 1 deletion app/fontman.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fontmanApp
controller: "comparisonController"
})
.when("/typecases", {
templateUrl: "views/typecases.html",
templateUrl: "views/typecase.html",
controller: "typecasesController"
})
.otherwise("/");
Expand Down
46 changes: 24 additions & 22 deletions app/ng-modules/fontsModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ fontsModule
.controller("fontsController", function ($http, $mdDialog, $scope, $timeout, fontSelectorService) {
$scope.fontsList = null;
$scope.fontBucket = null;
$scope.selectedFont = {};
$scope.textSize = 50;
$scope.viewId = {id: 2};
$scope.viewMethods = [
{id: 1, value: "Numerals"},
{id: 2, value: "Font name"},
{id: 3, value: "Phrase"},
{id: 4, value: "Paragraph"}
];
$scope.selectedFont = {};
$scope.textSize = 50;

// chnage font view
// change font view
$scope.$watch('viewId.id', function () {
if ($scope.viewId.id === 1) {
angular.forEach($scope.fontsList, function (font) {
Expand Down Expand Up @@ -220,11 +220,32 @@ fontsModule

$timeout(function () {
getFontBucket();
getFontsList();
}, 300);


};

// remove from temp choices
$scope.removeFromBucket = function (font) {
$scope.json_data = {is_chosen: false};

$http.post("http://127.0.0.1:5000/fonts/" + font.font_id + "/update", $scope.json_data)
.then(function onSuccess(response) {
if (response.data) {
font.chosen = false;
}
})
.catch(function onError(response) {
alert("FMS connection failed");
});

$timeout(function () {
getFontBucket();
getFontsList();
}, 300);
};

$scope.flushFontBucket = function () {
var json_data = {is_chosen: false};
$http.post("http://127.0.0.1:5000/fonts/update", json_data)
Expand Down Expand Up @@ -307,25 +328,6 @@ fontsModule
})
};

// remove from temp choices
$scope.removeFromBucket = function (font) {
$scope.json_data = {is_chosen: false};

$http.post("http://127.0.0.1:5000/fonts/" + font.font_id + "/update", $scope.json_data)
.then(function onSuccess(response) {
if (response.data) {
font.chosen = false;
}
})
.catch(function onError(response) {
alert("FMS connection failed");
});

$timeout(function () {
getFontBucket();
}, 300);
};

// set selected font data
$scope.selectFont = function (font) {
fontSelectorService.selectFont(font);
Expand Down
105 changes: 0 additions & 105 deletions app/ng-modules/ng-templates/add_font.html

This file was deleted.

154 changes: 70 additions & 84 deletions app/ng-modules/typecasesModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,94 +7,80 @@ var typecasesModule = angular.module("typecasesModule", []);


typecasesModule
.controller("typecasesController", function ($http, $mdDialog, $scope) {
$scope.myFonts = undefined;

$scope.addNewFontDialog = function (ev) {
$mdDialog.show({
controller: addNewFontController,
templateUrl: "ng-modules/ng-templates/add_font.html",
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
fullscreen: $scope.customFullscreen
})
.then(function () {
refreshMyFontsList();
.controller("typecasesController", function ($http, $mdDialog, $scope, $timeout) {
$scope.fontsList = undefined;
$scope.viewId = {id: 2};
$scope.textSize = 50;
$scope.viewMethods = [
{id: 1, value: "Numerals"},
{id: 2, value: "Font name"},
{id: 3, value: "Phrase"},
{id: 4, value: "Paragraph"}
];

// change font view
$scope.$watch('viewId.id', function () {
if ($scope.viewId.id === 1) {
angular.forEach($scope.fontsList, function (font) {
font.displayText = "1 2 3 4 5 6 7 8 9 0";
});

$scope.textSize = 40;

} else if ($scope.viewId.id === 2) {
angular.forEach($scope.fontsList, function (font) {
font.displayText = font.name;
});

$scope.textSize = 30;

} else if ($scope.viewId.id === 3) {
$scope.displayTexts = [
"Nymphs blitz quick vex dwarf jog.",
"DJs flock by when MTV ax quiz prog.",
"Big fjords vex quick waltz nymph.",
"Junk MTV quiz graced by fox whelps.",
"Vamp fox held quartz duck just by wing."
];
$scope.phraseIndex = 0;

angular.forEach($scope.fontsList, function (font) {
font.displayText = $scope.displayTexts[$scope.phraseIndex%5];
$scope.phraseIndex++;
});

$scope.textSize = 30;

} else if($scope.viewId.id === 4) {
angular.forEach($scope.fontsList, function (font) {
font.displayText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris risus ex, maximus vel dignissim et, auctor et lectus. Integer aliquet quam augue, eget venenatis ante fermentum in. Integer semper cursus nisi, non mattis ipsum pellentesque id. Donec auctor eros eu nunc vehicula posuere. Vivamus pharetra pulvinar molestie. Phasellus ullamcorper dui pretium, faucibus leo vel, hendrerit nisi. Etiam sed condimentum metus, quis vehicula nisl. Suspendisse sodales est lorem, eget luctus nisi egestas nec. Pellentesque rhoncus mi sed purus malesuada, quis laoreet lorem molestie. Sed nec purus elit. Nullam ut tortor congue, feugiat eros hendrerit, feugiat turpis.";
});

$scope.textSize = 16;
}
});

// get active fonts list
var getActiveFontsList = function () {
$http.get("http://127.0.0.1:5000/system/fonts")
.then(function onSuccess(response) {
$scope.fontsList = response.data;
})
.catch(function onError(response) {
});
};

var addNewFontController = function ($http, $mdDialog, $scope) {
$scope.channelsList = undefined;
$scope.inProgress = false;
$scope.newFont = {
channel_id: undefined,
ghPagesBranch: undefined,
gitRepository: undefined,
ghPagesFontDir: undefined,
gitUser: undefined,
name: undefined,
type: "Public"
};
$scope.selectedIndex = 0;
$scope.types = [{"id": 1, "type": "Public"}];

$scope.cancel = function() {
$mdDialog.hide();
};

$scope.clearFields = function () {
$scope.newFont.ghPagesBranch = undefined;
$scope.newFont.ghPagesFontDir = undefined;
$scope.newFont.gitRepository = undefined;
$scope.newFont.gitUser = undefined;
$scope.newFont.name = undefined;
};

$scope.addNewFont = function () {
$scope.inProgress = true;

$http.post("http://127.0.0.1:5000/fonts/new", $scope.newFont)
.then(function onSuccess(response) {
if (response.data === true) {
$scope.inProgress = false;
$scope.cancel();
} else {
$scope.inProgress = false;
alert(response.data.error);
}
})
.catch(function onError() {
$scope.inProgress = false;
alert("FMS connection failed!")
});
};

// set channels list
var setChannelsList = function () {
$http.get("http://127.0.0.1:5000/channels")
.then(function onSuccess(response) {
$scope.channelsList = response.data;
$scope.newFont.channel_id = $scope.channelsList[0].channel_id;
})
.catch(function () {
alert("FMS connection failed!");
})
};

setChannelsList();
/* option display on mouse hover */
$scope.hoverIn = function () {
this.hoverEdit = true;
};

// get my fonts list
var refreshMyFontsList = function () {
$http.get("http://127.0.0.1:5000/fonts/admin")
.then(function onSuccess(response) {
$scope.myFonts = response.data;
})
.catch(function onError() {
alert("FMS connection failed!");
})
$scope.hoverOut = function () {
this.hoverEdit = false;
};

refreshMyFontsList();
});
$timeout(function () {
getActiveFontsList();
}, 100);

});
Loading

0 comments on commit 48a54b5

Please sign in to comment.