new document views; + pdf view; documents model update

This commit is contained in:
tmshv committed 2014-11-24 16:40:27 +03:00
1 parent 3f4b07e6c9
commit 164975f21f
12 files changed
+349 -235

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

-1
View File
@@ -6,7 +6,6 @@
&.ng-enter {
animation: scaleUp 0.3s both ease-in
// animation: slideInUp 0.5s both ease-in;
}
}
+65 -57
View File
@@ -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;
}
+1 -1
View File
@@ -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;
}
+21 -137
View File
@@ -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)
// );
// });
// }
// }
//})();
require("./ui/pdf")(app);
require("./ui/doc-controller")(app);
+52
View File
@@ -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;
}
};
});
};
+148
View File
@@ -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('<link href="' + doc.extra.style + '" rel="stylesheet">');
}
$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)
// );
// });
// }
//}
}
};
});
};
+34 -34
View File
@@ -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"
}
+1
View File
@@ -0,0 +1 @@
<img ng-src="{{url}}" alt="" ng-repeat="url in document.url"/>
+1
View File
@@ -0,0 +1 @@
<pdf document="document"></pdf>
+23 -5
View File
@@ -16,21 +16,39 @@
</head>
<body ng-app="document.hudozhka" ng-controller="DocumentPageController">
<div class="document-block">
<div class="document-block" ng-controller="DocumentController">
<div class="menu transparent">
<div class="panel">
<h1>
<span class="bold">ДХШ</span>
<span class="norm">Шлиссельбурга</span> ,
<span class="norm">{{doc.title}}</span>
<span class="norm">{{document.title}}</span>
</h1>
</div>
<div class="panel right">
<div class="controls" ng-show="showControls">
<p class="block">
<span>Страница</span>
<input ng-model="currentPage" ng-change="update()" type="text" pattern="[0-9]{,3}">
из
<span>{{totalPages}}</span>
</p>
<p class="block">
<button ng-click="prevPage()">←</button>
<button ng-click="nextPage()">→</button>
</p>
<p class="block">
<a class="download" href="{{document.download}}"></a>
</p>
</div>
</div>
</div>
<div class="document">
<div class="page {{pageClass}}">
<img ng-src="{{url}}" alt="" ng-repeat="url in doc.url"/>
</div>
<div class="page {{pageClass}}" ng-include="viewDocument()"></div>
</div>
</div>
+3
View File
@@ -0,0 +1,3 @@
<div id="page-container" ng-include="pageURL">
</div>