diff --git a/client/document.js b/client/document.js index 351088e3..64b84926 100644 --- a/client/document.js +++ b/client/document.js @@ -1,36 +1,17 @@ -var app = angular.module("hudozhka.document", ["ngRoute", "hudozhka.data"]); +var app = angular.module("hudozhka.document", [ + "hudozhka.data", + "angulartics", + "angulartics.google.analytics" +]); -app.config(function ($locationProvider, $sceDelegateProvider, $routeProvider) { - $locationProvider.html5Mode(true); - //$routeProvider - // .when("/document/:doc", { - // controller: "DocumentPageController" - // }) - // .otherwise({ - // redirectTo: "/" - // }); - - $sceDelegateProvider.resourceUrlWhitelist([ - "self", - "http://static.shburg.org/**", - "http://static.shlisselburg.org/**" - ]); -}); - -//app.factory("document", function () { -// var document; -// return { -// init:function(doc) { -// document = doc; -// }, -// -// document: document -// }; -//}); - -app.controller("DocumentPageController", function ($scope) { +app.controller("DocumentController", function ($scope, $location, docs) { $scope.pageClass = "page-document"; -}); + $scope.showControls = false; -require("./ui/pdf")(app); -require("./ui/doc-controller")(app); + var abs = $location.absUrl(); + var doc_uri = /\/([\w-]+)$/.exec(abs); + + if(doc_uri.length >= 2) { + $scope.document = docs.doc(doc_uri[1]); + } +}); \ No newline at end of file diff --git a/client/ui/doc-controller.js b/client/ui/doc-controller.js deleted file mode 100644 index 8753121a..00000000 --- a/client/ui/doc-controller.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Created by tmshv on 24/11/14. - */ - -module.exports = function (app) { - app.controller("DocumentController", function ($scope, $location, docs) { - $scope.showControls = false; - - var doc_uri = $location.$$path.replace("/document/", ""); - $scope.document = docs.doc(doc_uri); - //$scope.document.currentPage = 0; - // - //$scope.totalPages = $scope.document.url.length; - //$scope.currentPage = 1; - // - //$scope.prevPage = function () { - // var i = $scope.currentPage - 1; - // if (i > 0) { - // $scope.currentPage = i; - // $scope.document.currentPage = i - 1; - // } - //}; - // - //$scope.nextPage = function () { - // var i = $scope.currentPage + 1; - // if (i <= $scope.totalPages) { - // $scope.currentPage = i; - // $scope.document.currentPage = i - 1; - // } - //}; - // - //$scope.update = function () { - // var i = $scope.currentPage; - // if (i > 0 && i <= $scope.totalPages) { - // $scope.currentPage = i; - // $scope.document.currentPage = i - 1; - // } - //}; - }); -}; \ No newline at end of file diff --git a/client/ui/pdf.js b/client/ui/pdf.js deleted file mode 100644 index 21bc15fa..00000000 --- a/client/ui/pdf.js +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Created by tmshv on 24/11/14. - */ - -module.exports = function (app) { - app.directive("pdf", function () { - return { - scope: { - document: "=" - }, - templateUrl: "/views/pdf.html", - link: function (scope, element, attrs) { - - }, - - controller: function ($scope) { - var doc = $scope.document; - if (doc.extra && doc.extra.style) { - angular.element("head").append(''); - } - - $scope.$watch( - function () { - return $scope.document.currentPage; - }, - function (value) { - value = parseInt(value); - try{ - $scope.pageURL = $scope.document.url[value]; - }catch (error){ - $scope.pageURL = ""; - } - } - ); - - //const PAGES = []; - //var currentPageIndex = 0; - //var doc = new Document(location.pathname.replace(/\/\d+$/, "")); - - //$(document).ready(function(){ - // try{ - // var hrefPage = /\/(\d+)$/.exec(location.href)[1]; - // currentPageIndex = parseInt(hrefPage) - 1; - // }catch(error){ - // - // } - - //$("#buttonNext").click(function(event){ - // loadNext(); - //}); - // - //$("#buttonPrev").click(function(event){ - // loadPrevious(); - //}); - // - //$("#page-container .pf").each(function(index, elem){ - // var url = $(elem).data("page-url"); - // doc.pages.push(url); - //}); - // - //$("#currentPage").attr("max", doc.pages.length); - //$("#totalPages").text(doc.pages.length); - //$("#currentPage").change(function(){ - // var i = parseInt($(this).val()) - 1; - // if(i && doc.hasPage(i)){ - // loadPage(i); - // } - //}); - // - //$("#page-container").html(""); - //loadPage(currentPageIndex); - // - //window.addEventListener("popstate", function(event){ - // console.log("pops"); - // console.log(event); - // var i = event.state; - // loadPage(i); - //}); - //}); - - //function loadNext(){ - // var i = currentPageIndex + 1; - // if(doc.hasPage(i)){ - // loadPage(i); - // }else{ - // - // } - //} - // - //function loadPrevious(){ - // var i = currentPageIndex - 1; - // if(doc.hasPage(i)){ - // loadPage(i); - // }else{ - // - // } - //} - // - //function loadPage(index){ - // if(doc.hasPage(index)){ - // var url = doc.pages[index]; - // // $.ajax( - // // url, - // - // // { - // // xhrFields: { - // // crossDomain: true, - // // withCredentials: true - // // }, - // - // // success: function(data, status){ - // // currentPageIndex = index; - // // $("#currentPage").val(doc.page(currentPageIndex)); - // // $("#page-container").html(data); - // - // // var p = doc.page(currentPageIndex); - // // console.log("look at page ", p); - // // window.history.pushState( - // // currentPageIndex, - // // "State 2013 — " + p, - // // doc.getPageURL(p) - // // ); - // // }, - // - // // error: function(xhr, aaa, error){ - // // console.log(error); - // // } - // // } - // // ); - // $.get(url, function(data){ - // currentPageIndex = index; - // $("#currentPage").val(doc.page(currentPageIndex)); - // $("#page-container").html(data); - // - // var p = doc.page(currentPageIndex); - // console.log("look at page ", p); - // window.history.pushState( - // currentPageIndex, - // "State 2013 — " + p, - // doc.getPageURL(p) - // ); - // }); - // } - //} - } - }; - }); -}; \ No newline at end of file diff --git a/templates/document.html b/templates/document.html index f5421de0..47babc19 100644 --- a/templates/document.html +++ b/templates/document.html @@ -1,20 +1,39 @@ - + + - - + + + + + - +
- - - - - - \ No newline at end of file diff --git a/templates/views/pdf.html b/templates/views/pdf.html deleted file mode 100644 index 7424b180..00000000 --- a/templates/views/pdf.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
\ No newline at end of file