From 131cdb776598296c25761d36b94931efa792895b Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Fri, 6 Nov 2015 12:56:03 +0000 Subject: [PATCH] api-web-app: convert to using dynamically generated cheatsheet data Closes #348 --- public/docs/ts/latest/guide/cheatsheet.jade | 9 +- public/resources/css/module/_cheatsheet.scss | 10 + .../js/controllers/app-controller.js | 341 +----------------- 3 files changed, 22 insertions(+), 338 deletions(-) diff --git a/public/docs/ts/latest/guide/cheatsheet.jade b/public/docs/ts/latest/guide/cheatsheet.jade index ba5125bd38..cd22178a1a 100644 --- a/public/docs/ts/latest/guide/cheatsheet.jade +++ b/public/docs/ts/latest/guide/cheatsheet.jade @@ -18,10 +18,9 @@ article(class="l-content-small grid-fluid docs-content") table(ng-repeat='section in cheatsheet' ng-cloak) tr - th {{section.syntax}} - th - code {{section.description}} - tr(ng-repeat='child in section.children') + th {{section.name}} + th(ng-bind-html="getSafeHtml(section.description)") + tr(ng-repeat='child in section.items') td code(bold='child.bold') {{child.syntax}} - td {{child.description}} + td(ng-bind-html="getSafeHtml(child.description)") diff --git a/public/resources/css/module/_cheatsheet.scss b/public/resources/css/module/_cheatsheet.scss index 74fe342fe0..eb400914ac 100644 --- a/public/resources/css/module/_cheatsheet.scss +++ b/public/resources/css/module/_cheatsheet.scss @@ -61,6 +61,16 @@ vertical-align: top; border: none; } + + td p, th p { + margin: 0; + font-size: inherit; + font-weight: inherit; + opacity: inherit; + line-height: inherit; + padding: 0; + } + tr:nth-child(odd) { background: #E7EBEE; } diff --git a/public/resources/js/controllers/app-controller.js b/public/resources/js/controllers/app-controller.js index 579a417b7b..96a8eea085 100644 --- a/public/resources/js/controllers/app-controller.js +++ b/public/resources/js/controllers/app-controller.js @@ -24,12 +24,16 @@ angularIO.directive('bold', function ($timeout) { } }); -angularIO.controller('AppCtrl', [ '$scope', '$mdDialog', '$timeout', '$http', function ($scope, $mdDialog, $timeout, $http) { +angularIO.controller('AppCtrl', [ '$scope', '$mdDialog', '$timeout', '$http', '$sce', function ($scope, $mdDialog, $timeout, $http, $sce) { $http.get('/resources/js/app-data.json').then(function(response) { $scope.apiList = response.data; }); + $http.get('/resources/js/cheatsheet.json').then(function(response) { + $scope.cheatsheet = response.data; + }); + $scope.showDocsNav = false; $scope.showMainNav = false; $scope.showMenu = false; @@ -64,338 +68,9 @@ angularIO.controller('AppCtrl', [ '$scope', '$mdDialog', '$timeout', '$http', fu $scope.apiType = ''; $scope.apiFilter = ''; - $scope.cheatsheet = [ - { - "syntax": "Bootstrapping", - "description": "import {bootstrap} from 'angular2/angular2';", - "children": [ - { - "syntax": "", - "description": "Binds property value to the result of expression firstName.", - bold: '[value]' - }, - { - "syntax": "
", - "description": "Binds attribute role to the result of expression myAriaRole.", - bold: '[attr.role]' - }, - { - "syntax": "
", - "description": "Binds the presence of the css class extra-sparkle on the element to the truthiness of the expression isDelightful.", - bold: '[class.extra-sparkle]' - }, - { - "syntax": "
", - "description": "Binds style property width to the result of expression mySize in pixels. Units are optional.", - bold: '[style.width.px]' - }, - { - "syntax": "