From 85ca132c3e0cd9c835b47616ba38dd3cf1ca0b2b Mon Sep 17 00:00:00 2001 From: Roman Timashev Date: Sun, 1 Mar 2015 18:23:46 +0300 Subject: [PATCH] document title; --- client/document.js | 33 +++++++++++++++++++++++---------- templates/document.html | 7 ++++--- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/client/document.js b/client/document.js index 64b84926..3a3bc71c 100644 --- a/client/document.js +++ b/client/document.js @@ -4,14 +4,27 @@ var app = angular.module("hudozhka.document", [ "angulartics.google.analytics" ]); -app.controller("DocumentController", function ($scope, $location, docs) { - $scope.pageClass = "page-document"; - $scope.showControls = false; - - var abs = $location.absUrl(); - var doc_uri = /\/([\w-]+)$/.exec(abs); - - if(doc_uri.length >= 2) { - $scope.document = docs.doc(doc_uri[1]); +app.factory("docname", function ($location) { + return function(){ + var abs = $location.absUrl(); + var doc_uri = /\/([\w-]+)$/.exec(abs); + if(doc_uri.length >= 2) { + return doc_uri[1]; + }else{ + return null; + } } -}); \ No newline at end of file +}); + +app.controller("DocumentController", function ($rootScope, $scope, docs, docname) { + $scope.pageClass = "page-document"; + + var n = docname(); + if(n) { + var d = docs.doc(n); + $scope.document = d; + $rootScope.title = d.title; + } +}); + +require("./filters/uppercase-first")(app); \ No newline at end of file diff --git a/templates/document.html b/templates/document.html index 47babc19..aba43ed0 100644 --- a/templates/document.html +++ b/templates/document.html @@ -1,12 +1,13 @@ - + - + + @@ -33,7 +34,7 @@ - +