Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ceskaexpedice/kramerius
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-stastny committed Sep 21, 2015
2 parents 1041869 + 0576440 commit 7263602
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 44 deletions.
14 changes: 6 additions & 8 deletions client/src/main/webapp/js/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,13 @@ ClientAPIDev.prototype = {
* Search first pid to display and navigate browser to this item.
* @method
*/
gotoDisplayingItemPage : function(hash, q) {
var parts = hash.split(";");
var pid = parts[0];
var remainder = "";
if(parts.length > 1){
remainder = hash.substring(pid.length);
}
gotoDisplayingItemPage : function(newhash, q) {
var hash = hashParser(newhash);
var pid = hash.pid;

this.searchItemAndExploreChildren(pid, _.bind(function(data) {
this.gotoItemPage(data + remainder, q);
hash.pid = data;
this.gotoItemPage(jsonToHash(hash), q);
}, this));
},

Expand Down
9 changes: 5 additions & 4 deletions client/src/main/webapp/js/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ BreadCrumbs.prototype = {
if(cpid !== hash.pid){
span.addClass('link')
span.click(function(){
var cpid = $(this).data("pid");
var model = $(this).data("model");
var histDeep = getHistoryDeep() + 1;
K5.api.gotoDisplayingItemPage(cpid + ";hist=" + histDeep + ";pmodel=" + $(this).data("model"), $("#q").val());
var hash2 = hashParser();
hash2.pid = $(this).data("pid");
hash2.pmodel = $(this).data("model");
hash2.hist = getHistoryDeep() + 1;
K5.api.gotoDisplayingItemPage(jsonToHash(hash2), $("#q").val());
});
}
this.elem.append(span);
Expand Down
10 changes: 6 additions & 4 deletions client/src/main/webapp/js/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ K5.eventsHandler.addHandler(function(type, configuration) {
}
if (type === "widow/url/hash") {
if (K5.gui.page && K5.gui.page ==="doc") {
var phash = location.hash;
var pid = phash.startsWith("#!") ? phash.substring(2) : phash.substring(1);
// var phash = location.hash;
// var pid = phash.startsWith("#!") ? phash.substring(2) : phash.substring(1);
var pid = hashParser().pid;
if (K5.api.ctx.item && K5.api.ctx.item[pid]) {
if (K5.api.ctx.item[pid].pid) {
var data = K5.api.ctx.item[pid];
Expand Down Expand Up @@ -63,8 +64,9 @@ K5.eventsHandler.addHandler(function(type, configuration) {

});

var phash = location.hash;
var pid = phash.startsWith("#!") ? phash.substring(2) : phash.substring(1);
//var phash = location.hash;
//var pid = phash.startsWith("#!") ? phash.substring(2) : phash.substring(1);
var pid = hashParser().pid;
if (pid) K5.api.askForItem(pid);

var maxwidth = $('html').css('max-width');
Expand Down
21 changes: 15 additions & 6 deletions client/src/main/webapp/js/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ K5.eventsHandler.addHandler(function(type, configuration) {
var Results = function(elem) {

this.elem = elem;
this.displayStyle = "display";
this._init();
};

Expand All @@ -44,9 +45,9 @@ Results.prototype = {
}, this));

this.getDocs();
var hash = window.location.hash;
if (hash.length > 1) {
if (hash.substring(1) === "asrow")
var hash = hashParser();
if (hash.hasOwnProperty(this.displayStyle) > 1) {
if (hash[this.displayStyle] === "asrow")
this.setRowStyle();
}
this.touchStart = 0;
Expand Down Expand Up @@ -160,7 +161,9 @@ Results.prototype = {
var w = $(this).parent().width() - $(this).prev().width() - 20;
$(this).css('width', w);
});
window.location.hash = "asrow";
var hash = hashParser();
hash[this.displayStyle] = "asrow";
window.location.hash = jsonToHash(hash);
},
setHeader: function(numFound) {
var key = 'common.title.plural_2';
Expand All @@ -178,7 +181,10 @@ Results.prototype = {
setThumbsStyle: function() {
$('#search_results').removeClass('as_row');
$('.search_result>div.thumb>div.info').css('width', '');
window.location.hash = "asthumb";

var hash = hashParser();
hash[this.displayStyle] = "asthumb";
window.location.hash = jsonToHash(hash);
}
};

Expand Down Expand Up @@ -333,7 +339,10 @@ Result.prototype = {


thumb.click(function() {
K5.api.gotoDisplayingItemPage(linkpid, $("#q").val());
var hash = hashParser();
hash.pid = linkpid;
//hash.pmodel = typtitulu;
K5.api.gotoDisplayingItemPage(jsonToHash(hash), $("#q").val());
});

},
Expand Down
10 changes: 5 additions & 5 deletions client/src/main/webapp/js/rows.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ YearRow.prototype = {
if (doc["dc.creator"]) {
creator = '<div class="autor">' + doc["dc.creator"] + '</div>';
}
title = '<div class="title">' + title + '</div>';
var titletag = '<div class="title">' + title + '</div>';
if(title !== dctitle){
title = title + '<div class="dctitle">' + dctitle + '</div>';
shortTitle = shortTitle + '<div class="dctitle">' + dctitle + '</div>';
titletag = titletag + '<div class="dctitle">' + dctitle + '</div>';
shortTitle = shortTitle + '<div class="dctitle">' + dctitle.substring(Math.min(30, dctitle.length)) + '</div>';
}
var modeltag = '<div class="title">' + K5.i18n.translatable('fedora.model.' + model) + '</div>';
thumb.data("pid", pid);
Expand All @@ -301,9 +301,9 @@ YearRow.prototype = {
}
thumb.append(policy);
if (showToolTip) {
thumb.attr("title", title + creator + modeltag);
thumb.attr("title", titletag + creator + modeltag);
thumb.tooltip({
content: title + creator,
content: titletag + creator,
position: {my: "left bottom-1", at: "right-1 bottom"}
});
}
Expand Down
45 changes: 30 additions & 15 deletions client/src/main/webapp/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,24 @@ function backToResults(){
window.history.go(0 - histDeep - 1);
}

function hashParser(){
var hash = window.location.hash;
function hashParser(hash){
if(!hash){
hash = window.location.hash;
}else if(!hash.startsWith("#")){
hash = "#" + hash;
}
if(hash.length > 1){
var parts = hash.substring(1).split(";");
hash = hash.startsWith("#!") ? hash.substring(2) : hash.substring(1);
var parts = hash.split(";");
var ret = {};
ret.pid = parts[0];
for(var i = 1; i<parts.length; i++){
//ret.pid = parts[0];
for(var i = 0; i<parts.length; i++){
var part = parts[i].split("=");
if(part.length>1){
ret[part[0]] = part[1];
}else if(i===0){
// je to prvni a bez =
ret.pid = parts[0];
}else{
ret["key"+i] = part[0];
}
Expand All @@ -333,17 +341,24 @@ function hashParser(){

function jsonToHash(json){
var hash = "";
if(json.hasOwnProperty("pid")){
hash = json.pid;
}

if(json.hasOwnProperty("hist")){
hash += ";hist=" + json.hist;
$.each(json, function(item, val){
hash += ";"+item+"=" + val;
});
//
// if(json.hasOwnProperty("pid")){
// hash = json.pid;
// }
//
// if(json.hasOwnProperty("hist")){
// hash += ";hist=" + json.hist;
// }
//
// if(json.hasOwnProperty("pmodel")){
// hash += ";pmodel=" + json.pmodel;
// }
if(hash.length>1){
hash = hash.substring(1);
}

if(json.hasOwnProperty("pmodel")){
hash += ";pmodel=" + json.pmodel;
}

return hash;
}
8 changes: 6 additions & 2 deletions client/src/main/webapp/js/viewers/itemthumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ ItemThumbs.prototype = {
addThumb: function(index) {
var pid = this.thumbs[index].pid ? this.thumbs[index].pid : this.thumbs[index].PID;
var model = this.thumbs[index].model;
var datanode = this.thumbs[index].datanode;

var imgsrc = 'api/item/' + pid + '/thumb';
var img = $('<img/>', {src: "images/empty.gif"});
Expand Down Expand Up @@ -365,8 +366,11 @@ ItemThumbs.prototype = {
hash.pid = pid;
var histDeep = getHistoryDeep() + 1;
hash.hist = histDeep;

hash.pmodel = model;
if(datanode){
//hash.pmodel = model;
}else{
hash.pmodel = model;
}
K5.api.gotoDisplayingItemPage(jsonToHash(hash), $("#q").val());

});
Expand Down

0 comments on commit 7263602

Please sign in to comment.