2015-05-01 09:48:52 -04:00
|
|
|
/*
|
2015-10-15 17:16:35 -04:00
|
|
|
* Apllication Controller
|
|
|
|
*
|
|
|
|
*/
|
2015-05-01 09:48:52 -04:00
|
|
|
|
2015-10-16 14:12:03 -04:00
|
|
|
angularIO.directive('bold', function ($timeout) {
|
|
|
|
return {
|
|
|
|
scope: { bold: '=bold' },
|
|
|
|
link: postLink
|
|
|
|
};
|
|
|
|
function postLink (scope, element) {
|
|
|
|
var bold = typeof scope.bold === 'string'
|
|
|
|
? [ scope.bold ]
|
|
|
|
: scope.bold;
|
|
|
|
$timeout(function () {
|
|
|
|
var html = element.html();
|
|
|
|
angular.forEach(bold, function (bold) {
|
|
|
|
html = html.replace(new RegExp(bold.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"), 'g'), '<b>$&</b>');
|
|
|
|
});
|
|
|
|
html = html.replace(/\n/g, '<br>');
|
|
|
|
html = html.replace(/ /g, ' ');
|
|
|
|
element.html(html);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-11-06 07:56:03 -05:00
|
|
|
angularIO.controller('AppCtrl', [ '$scope', '$mdDialog', '$timeout', '$http', '$sce', function ($scope, $mdDialog, $timeout, $http, $sce) {
|
2015-11-03 11:41:38 -05:00
|
|
|
|
|
|
|
$http.get('/resources/js/app-data.json').then(function(response) {
|
|
|
|
$scope.apiList = response.data;
|
|
|
|
});
|
|
|
|
|
2015-11-06 07:56:03 -05:00
|
|
|
$http.get('/resources/js/cheatsheet.json').then(function(response) {
|
|
|
|
$scope.cheatsheet = response.data;
|
|
|
|
});
|
|
|
|
|
2015-05-01 09:48:52 -04:00
|
|
|
$scope.showDocsNav = false;
|
|
|
|
$scope.showMainNav = false;
|
2015-10-15 17:16:35 -04:00
|
|
|
$scope.showMenu = false;
|
2015-05-01 09:48:52 -04:00
|
|
|
|
|
|
|
// TOGGLE MAIN NAV (TOP) ON MOBILE
|
2015-10-15 17:16:35 -04:00
|
|
|
$scope.toggleDocsMenu = function () {
|
2015-05-01 09:48:52 -04:00
|
|
|
$scope.showDocsNav = !$scope.showDocsNav;
|
|
|
|
};
|
|
|
|
|
|
|
|
// TOGGLE DOCS NAV
|
2015-10-15 17:16:35 -04:00
|
|
|
$scope.toggleMainMenu = function () {
|
2015-05-01 09:48:52 -04:00
|
|
|
$scope.showMainNav = !$scope.showMainNav;
|
|
|
|
};
|
|
|
|
|
|
|
|
// TOGGLE DOCS VERSION & LANGUAGE
|
2015-10-15 17:16:35 -04:00
|
|
|
$scope.toggleVersionMenu = function () {
|
2015-05-01 09:48:52 -04:00
|
|
|
$scope.showMenu = !$scope.showMenu;
|
|
|
|
};
|
|
|
|
|
2015-10-15 17:16:35 -04:00
|
|
|
$scope.setType = function (type) {
|
|
|
|
if (type === $scope.apiType) $scope.apiType = '';
|
|
|
|
else $scope.apiType = type;
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.apiSections = [
|
2015-11-03 11:41:38 -05:00
|
|
|
{ name: 'angular2/core', title: 'Core' },
|
|
|
|
{ name: 'angular2/http', title: 'HTTP' },
|
|
|
|
{ name: 'angular2/lifecycle_hooks', title: 'Lifecycle Hooks' },
|
|
|
|
{ name: 'angular2/router', title: 'Router' },
|
|
|
|
{ name: 'angular2/test', title: 'Test' }
|
2015-10-15 17:16:35 -04:00
|
|
|
];
|
|
|
|
$scope.apiType = '';
|
|
|
|
$scope.apiFilter = '';
|
|
|
|
|
2015-11-06 07:56:03 -05:00
|
|
|
$scope.getSafeHtml = function(html) {
|
|
|
|
return $sce.trustAsHtml(html);
|
|
|
|
};
|
2015-10-16 14:12:03 -04:00
|
|
|
|
2015-05-03 22:09:25 -04:00
|
|
|
/*
|
2015-10-15 17:16:35 -04:00
|
|
|
* Prettify Code
|
|
|
|
*
|
|
|
|
* Finish Rendereding code directives then prettify code
|
|
|
|
*/
|
2015-05-03 22:09:25 -04:00
|
|
|
|
2015-05-03 23:28:21 -04:00
|
|
|
// GRAB ALL TAGS NOT USING DIRECTIVES
|
|
|
|
var preTags = angular.element(document.body).find('pre');
|
|
|
|
|
|
|
|
// LOOP THROUGH AND ADD PRETTIFY CLASS
|
2015-10-15 17:16:35 -04:00
|
|
|
_.each(preTags, function (element) {
|
2015-05-03 23:28:21 -04:00
|
|
|
var preTag = angular.element(element);
|
|
|
|
|
|
|
|
// IF NOT FORMATTED, ADD PRETTY PRINT
|
2015-10-15 17:16:35 -04:00
|
|
|
if (!preTag.hasClass('prettyprint')) {
|
2015-05-03 23:29:54 -04:00
|
|
|
preTag.addClass('prettyprint linenums');
|
2015-05-03 23:28:21 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// TRIGGER PRETTYPRINT AFTER DIGEST LOOP COMPLETE
|
2015-05-03 22:09:25 -04:00
|
|
|
$timeout(prettyPrint, 1);
|
2015-10-15 17:16:35 -04:00
|
|
|
} ]);
|