From 48a54b5db27ade0cf738b36c37296bd987a4cb41 Mon Sep 17 00:00:00 2001 From: Lahiru Pathirage Date: Fri, 3 Feb 2017 22:22:09 +0530 Subject: [PATCH] Display system Fonts List https://github.com/fontman/fontman-desktop-core/issues/11 --- app/fontman.js | 2 +- app/ng-modules/fontsModule.js | 46 +++---- app/ng-modules/ng-templates/add_font.html | 105 --------------- app/ng-modules/typecasesModule.js | 154 ++++++++++------------ app/views/typecase.html | 91 +++++++++++++ app/views/typecases.html | 47 ------- 6 files changed, 186 insertions(+), 259 deletions(-) delete mode 100755 app/ng-modules/ng-templates/add_font.html create mode 100644 app/views/typecase.html delete mode 100644 app/views/typecases.html diff --git a/app/fontman.js b/app/fontman.js index 0dc2879..1268dab 100755 --- a/app/fontman.js +++ b/app/fontman.js @@ -36,7 +36,7 @@ fontmanApp controller: "comparisonController" }) .when("/typecases", { - templateUrl: "views/typecases.html", + templateUrl: "views/typecase.html", controller: "typecasesController" }) .otherwise("/"); diff --git a/app/ng-modules/fontsModule.js b/app/ng-modules/fontsModule.js index 6169d24..4a4f6bc 100755 --- a/app/ng-modules/fontsModule.js +++ b/app/ng-modules/fontsModule.js @@ -12,6 +12,8 @@ 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"}, @@ -19,10 +21,8 @@ fontsModule {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) { @@ -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) @@ -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); diff --git a/app/ng-modules/ng-templates/add_font.html b/app/ng-modules/ng-templates/add_font.html deleted file mode 100755 index 3a5b225..0000000 --- a/app/ng-modules/ng-templates/add_font.html +++ /dev/null @@ -1,105 +0,0 @@ - - -
- - - -
-

My Fonts

- - - - close - -
- -
- - - -
- -
- - - -
-
Font name is required.
-
-
- - - - - - {{type.type}} - - - - - - - - - {{channel.name}} {{channel.type}} - - - - -
- - - - -
-
GitHub username/organization name is required.
-
-
- - - - -
-
Repository is required.
-
-
- - - - -
-
Branch name containing sample fonts is required.
-
-
- - - - -
-
Directory path containing sample fonts is required.
-
-
- -
- -
- -
- - - - - - - CLEAR - - - - ADD - - - - -
- -
diff --git a/app/ng-modules/typecasesModule.js b/app/ng-modules/typecasesModule.js index 08b09d7..101124a 100644 --- a/app/ng-modules/typecasesModule.js +++ b/app/ng-modules/typecasesModule.js @@ -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(); - }); \ No newline at end of file + $timeout(function () { + getActiveFontsList(); + }, 100); + + }); diff --git a/app/views/typecase.html b/app/views/typecase.html new file mode 100644 index 0000000..c157f3c --- /dev/null +++ b/app/views/typecase.html @@ -0,0 +1,91 @@ +
+ +
+ +
+ +
+ + + +
+ +
+ + + + {{view.value}} + + + +
+ +
+ +
+ +
+ +
    + +
  • + +
    + +
    +
    {{font.name}}
    +
    + +
    + +
    + +
    + +
    + + + +
    + +

    + {{font.displayText}} +

    + +
    + +
    + +
    +
    + + + + {{fontface.fontface}} + + +
    + +
    + +
    + +
    + SEE +
    + +
    + TEST +
    + +
    + +
  • + +
+ +
+ +
\ No newline at end of file diff --git a/app/views/typecases.html b/app/views/typecases.html deleted file mode 100644 index cc8d3ad..0000000 --- a/app/views/typecases.html +++ /dev/null @@ -1,47 +0,0 @@ -
- -
- -
- -
- -
- - - -
- -

New Font

-

Ship your font with Fontman

- -
- -
- - ADD - - -
- - - -
- -

{{font.name}}

-

{{font.type}}

- -
- -
- - ACTIONS - - -
- -
- -
- -
\ No newline at end of file