diff --git a/assets/graphics/download.png b/assets/graphics/download.png new file mode 100644 index 00000000..ea2552b0 Binary files /dev/null and b/assets/graphics/download.png differ diff --git a/assets/style/docs.scss b/assets/style/docs.scss index 99c1e7d0..d0b3d2de 100644 --- a/assets/style/docs.scss +++ b/assets/style/docs.scss @@ -6,7 +6,6 @@ &.ng-enter { animation: scaleUp 0.3s both ease-in -// animation: slideInUp 0.5s both ease-in; } } diff --git a/assets/style/document.scss b/assets/style/document.scss index 0f26f1c5..ff1a7767 100644 --- a/assets/style/document.scss +++ b/assets/style/document.scss @@ -9,10 +9,74 @@ background-color: white; box-shadow: 0 1px 5px 0 rgba(0, 0, 0, 0.5); + display: flex; + justify-content: space-between; + align-items: center; + &.transparent{ opacity: 0.95; } } + + .controls { + input { + width: 30px; + height: 30px; + margin: 0 2px; + text-align: center; + font-size: .9em; + } + + input:focus { + outline: 0; + } + + button { + height: 30px; + border-radius: 6px; + border: 1px solid #666; + background-color: white; + font-size: 1.25em; + line-height: 0; + text-align: center; + outline: none; + + &:hover { + border-color: #4d62d9; + color: #4d62d9; + } + + &:active { + border-color: #3d4fb2; + color: #3d4fb2; + } + } + } + + .controls .block { + display: inline-block; + margin: 0 5px; + vertical-align: middle; + } + + a.download { + height:30px; + width: 23px; + vertical-align: middle; + padding: 0 8px; + display: inline-block; + background: url(/graphics/download.png) no-repeat 50%; + border-radius: 6px; + border: 1px solid #666; + + &:hover{ + border-color: #4d62d9; + } + + &:active { + border-color: #3d4fb2; + } + } } .document { @@ -33,62 +97,6 @@ font-weight: 700; } -#page-container > div { - /* box-shadow: 1px 1px 3px 1px #333;*/ -} - -.controls { - display: inline-block; - margin-top: -4px; - /* vertical-align: middle;*/ - .block { - display: inline-block; - /* height: 100%;*/ - margin: 0px 5px; - vertical-align: middle; - } - input { - width: 30px; - height: 30px; - margin: 0 2px; - text-align: center; - font-size: .9em; - } - button { - display: inline-block; - height: 30px; - padding: 0 10px; - border-radius: 6px; - border: 2px solid #bbb; - color: #555; - background-color: white; - font-size: 1.3em; - text-align: center; - outline: none; - &:hover { - /* border: 1px solid #666;*/ - /* background-color: #eee;*/ - border: 2px solid #4d62d9; - color: #4d62d9; - } - &:active { - border: 2px solid #3d4fb2; - color: #3d4fb2; - background-color: rgba(61, 79, 178, 0.3); - } - } - a.download { - width: 22px; - height: 22px; - padding: 5px 8px; - display: inline-block; - background: #f3f3f3 url(download-icon.png) no-repeat; - background-position: 50%; - border-radius: 3px; - border: 1px solid #e0e0e0; - } -} - #page-container { background-color: #c3bfa3; transition: left 500ms; @@ -97,7 +105,7 @@ .pf { margin: 60px auto 20px; /* box-shadow: 1px 1px 3px 1px #333;*/ - box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.9); + box-shadow: 0 1px 4px 0px rgba(0, 0, 0, 0.9); border-collapse: separate; } diff --git a/assets/style/pdf.scss b/assets/style/pdf.scss index 2c74b295..5eeb6b80 100644 --- a/assets/style/pdf.scss +++ b/assets/style/pdf.scss @@ -5,6 +5,7 @@ margin: 0; padding: 0; border: 0; + z-index: -1; } @media screen { @@ -62,7 +63,6 @@ position: relative; background-color: white; overflow: hidden; - margin: 0; border: 0; } diff --git a/client/document.js b/client/document.js index f5c350fc..3c61d4cf 100644 --- a/client/document.js +++ b/client/document.js @@ -1,6 +1,6 @@ var app = angular.module("document.hudozhka", ["ngRoute", "data.hudozhka"]); -app.config(function ($locationProvider, $routeProvider) { +app.config(function ($locationProvider, $sceDelegateProvider, $routeProvider) { $locationProvider.html5Mode(true); //$routeProvider // .when("/document/:doc", { @@ -9,144 +9,28 @@ app.config(function ($locationProvider, $routeProvider) { // .otherwise({ // redirectTo: "/" // }); + + $sceDelegateProvider.resourceUrlWhitelist([ + "self", + "http://static.shburg.org/**", + "http://static.shlisselburg.org/**" + ]); }); -app.controller("DocumentPageController", function ($scope, $location, docs) { +//app.factory("document", function () { +// var document; +// return { +// init:function(doc) { +// document = doc; +// }, +// +// document: document +// }; +//}); + +app.controller("DocumentPageController", function ($scope) { $scope.pageClass = "page-document"; - - var doc = $location.$$path.replace("/document/", ""); - $scope.doc = docs.doc(doc); }); -//var Doc = (function(){ -// var Document = function(baseURL){ -// this.pages = []; -// this.baseURL = baseURL; -// } -// -// Document.prototype.hasPage = function(index){ -// return index >= 0 && index < this.pages.length; -// } -// -// Document.prototype.getPageURL = function(pageNumber){ -// var s = pageNumber <2 ? "" : "/" + pageNumber; -// return this.baseURL + s; -// } -// -// Document.prototype.page = function(index){ -// return index + 1; -// } -// -// return Document; -//})(); -// -//(function(){ -// const PAGES = []; -// var currentPageIndex = 0; -// var doc = new Doc(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 +require("./ui/pdf")(app); +require("./ui/doc-controller")(app); diff --git a/client/ui/doc-controller.js b/client/ui/doc-controller.js new file mode 100644 index 00000000..682b43d1 --- /dev/null +++ b/client/ui/doc-controller.js @@ -0,0 +1,52 @@ +/** + * 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.viewDocument = function () { + switch ($scope.document.viewer) { + case "img-sheet": + $scope.showControls = false; + return "/views/document-image.html"; + + default: + $scope.showControls = true; + return "/views/document-paper.html"; + } + }; + + $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 new file mode 100644 index 00000000..21bc15fa --- /dev/null +++ b/client/ui/pdf.js @@ -0,0 +1,148 @@ +/** + * 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/models/documents.json b/models/documents.json index 9d407089..1fe8daf2 100644 --- a/models/documents.json +++ b/models/documents.json @@ -3,47 +3,47 @@ "name": "statue-2013", "title": "устав школы за 2013 год", "path": "/document/statue-2013", - "preview": "/img/preview/statue-2013.png", + "preview": "http://static.shburg.org/art/graphics/statue-2013-preview.png", "download": "http://static.shburg.org/art/docs/hudozhka_statue-2013.pdf", "url": [ - "/f/hudozhka_statue-2013-1.page", - "/f/hudozhka_statue-2013-2.page", - "/f/hudozhka_statue-2013-3.page", - "/f/hudozhka_statue-2013-4.page", - "/f/hudozhka_statue-2013-5.page", - "/f/hudozhka_statue-2013-6.page", - "/f/hudozhka_statue-2013-7.page", - "/f/hudozhka_statue-2013-8.page", - "/f/hudozhka_statue-2013-9.page", - "/f/hudozhka_statue-2013-10.page", - "/f/hudozhka_statue-2013-11.page", - "/f/hudozhka_statue-2013-12.page", - "/f/hudozhka_statue-2013-13.page", - "/f/hudozhka_statue-2013-14.page", - "/f/hudozhka_statue-2013-15.page", - "/f/hudozhka_statue-2013-16.page", - "/f/hudozhka_statue-2013-17.page", - "/f/hudozhka_statue-2013-18.page", - "/f/hudozhka_statue-2013-19.page", - "/f/hudozhka_statue-2013-20.page", - "/f/hudozhka_statue-2013-21.page", - "/f/hudozhka_statue-2013-22.page", - "/f/hudozhka_statue-2013-23.page", - "/f/hudozhka_statue-2013-24.page", - "/f/hudozhka_statue-2013-25.page", - "/f/hudozhka_statue-2013-26.page", - "/f/hudozhka_statue-2013-27.page" + "http://static.shburg.org/art/html/hudozhka_statue-2013-1.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-2.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-3.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-4.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-5.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-6.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-7.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-8.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-9.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-10.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-11.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-12.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-13.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-14.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-15.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-16.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-17.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-18.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-19.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-20.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-21.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-22.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-23.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-24.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-25.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-26.page", + "http://static.shburg.org/art/html/hudozhka_statue-2013-27.page" ], "extra": { "style": ["http://static.shburg.org/art/docs/preview/hudozhka_statue-2013.css"] }, - "viewer": "default" + "viewer": "pdf" }, { "name": "edu-license", "title": "образовательная лицензия", "path": "/document/edu-license", - "preview": "/img/preview/license_edu.png", + "preview": "http://static.shburg.org/art/graphics/license_edu-preview.png", "url": [ "http://static.shburg.org/art/docs/hudozhka_license_edu.jpg", "http://static.shburg.org/art/docs/hudozhka_license_edu_back.jpg", @@ -55,7 +55,7 @@ "name": "gov-certificate", "title": "свидетельство о государственной регистрации права", "path": "/document/gov-certificate", - "preview": "/img/preview/certificate_gov.png", + "preview": "http://static.shburg.org/art/graphics/certificate_gov-preview.png", "url": ["http://static.shburg.org/art/docs/hudozhka_certificate_gov.jpg"], "viewer": "img-sheet" }, @@ -63,7 +63,7 @@ "name": "VAT", "title": "ИНН", "path": "/document/VAT", - "preview": "/img/preview/vatin.png", + "preview": "http://static.shburg.org/art/graphics/vatin-preview.png", "url": ["http://static.shburg.org/art/docs/hudozhka_vatin.jpg"], "viewer": "img-sheet" }, @@ -71,7 +71,7 @@ "name": "EGRYL1", "title": "свидетельство о внесении в «ЕГРЮЛ»", "path": "/document/EGRYL1", - "preview": "/img/preview/certificate_egryl1.png", + "preview": "http://static.shburg.org/art/graphics/certificate_egryl1-preview.png", "url": ["http://static.shburg.org/art/docs/hudozhka_certificate_egryl1.jpg"], "viewer": "img-sheet" }, @@ -79,7 +79,7 @@ "name": "EGRYL2", "title": "свидетельство о внесении в «ЕГРЮЛ»", "path": "/document/EGRYL2", - "preview": "/img/preview/certificate_egryl2.png", + "preview": "http://static.shburg.org/art/graphics/certificate_egryl2-preview.png", "url": ["http://static.shburg.org/art/docs/hudozhka_certificate_egryl2.jpg"], "viewer": "img-sheet" } diff --git a/views/document-image.html b/views/document-image.html new file mode 100644 index 00000000..3557469c --- /dev/null +++ b/views/document-image.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/document-paper.html b/views/document-paper.html new file mode 100644 index 00000000..b265e037 --- /dev/null +++ b/views/document-paper.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/views/document.html b/views/document.html index fb32e364..650c3178 100644 --- a/views/document.html +++ b/views/document.html @@ -16,21 +16,39 @@ -
+
-
- -
+
diff --git a/views/pdf.html b/views/pdf.html new file mode 100644 index 00000000..7424b180 --- /dev/null +++ b/views/pdf.html @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file