From: Jason Skomorowski Date: Mon, 2 Feb 2015 15:58:52 +0000 (-0500) Subject: Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/mkws X-Git-Url: http://git.indexdata.com/?p=mkws-moved-to-github.git;a=commitdiff_plain;h=38168b75a739c506f0a8f03687cc2cd5c40f518a;hp=d9d6f150818986a40943603683be709d75508522 Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/mkws --- diff --git a/doc/index.markdown b/doc/index.markdown index 25df2a4..64070b1 100644 --- a/doc/index.markdown +++ b/doc/index.markdown @@ -106,6 +106,7 @@ Here are the files that this web-site provides: since it doesn't like to be hotlinked. * Local copy of [jquery-1.10.0.min.js](jquery-1.10.0.min.js) * Local copy of [jquery.json-2.4.js](jquery.json-2.4.js) +* Local copy of [jsnlog.min.js](jsnlog.min.js) * [mkws-complete.js](mkws-complete.js) -- A single large JavaScript file containing everything needed for MKWS to work: the widget-set itself, the API library, and diff --git a/src/mkws-core.js b/src/mkws-core.js index 719e3e0..ade2ed6 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -48,6 +48,11 @@ window.mkws = { "Location": "Ort", "Records": "Datensätze", "Targets": "Datenbanken", + "State": "Status", + "relevance": "Relevanz", + "title": "Titel", + "newest": "Neueste", + "oldest": "Älteste", "dummy": "dummy" }, @@ -77,6 +82,11 @@ window.mkws = { "Location": "Lokation", "Records": "Poster", "Targets": "Baser", + "State": "Status", + "relevance": "Relevans", + "title": "Titel", + "newest": "Nyeste", + "oldest": "Ældste", "dummy": "dummy" } @@ -162,7 +172,7 @@ mkws.registerWidgetType = function(name, fn) { mkws.aliasWidgetType = function(newName, oldName) { mkws.widgetType2function[newName] = mkws.widgetType2function[oldName]; mkws.info("aliased widget-type '" + newName + "' to '" + oldName + "'"); - + }; mkws.promotionFunction = function(name) { @@ -538,7 +548,7 @@ mkws.info("Using window.name '" + window.name + "'"); // or a selector string you would like to constrain the search for widgets to. // // This function has no side effects if run again on an operating session, - // even if the element/selector passed causes existing widgets to be reparsed: + // even if the element/selector passed causes existing widgets to be reparsed: // // (TODO: that last bit isn't true and we currently have to avoid reinitialising // widgets, MKWS-261) @@ -549,7 +559,7 @@ mkws.info("Using window.name '" + window.name + "'"); mkws.init = function(message, rootsel) { var greet = "MKWS initialised"; if (rootsel) greet += " (limited to " + rootsel + ")" - if (message) greet += " :: " + message; + if (message) greet += " :: " + message; mkws.info(greet); // MKWS is not active until init() has been run against an object with widget nodes. @@ -662,7 +672,7 @@ mkws.info("Using window.name '" + window.name + "'"); mkws.teams[teamName].queue("authenticated").publish(); } } - + mkws.isActive = true; return true; }; diff --git a/src/mkws-widget-facets.js b/src/mkws-widget-facets.js index 520faca..fbf0e47 100644 --- a/src/mkws-widget-facets.js +++ b/src/mkws-widget-facets.js @@ -73,7 +73,6 @@ mkws.registerWidgetType('facet', function() { that.node.html(template({ name: name, caption: caption, - query: that.config.query, terms: terms })); }); diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index a20e270..8fad7d9 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -259,7 +259,7 @@ mkws.registerWidgetType('ranking', function() { var cur = {}; var opt = this.config.sort_options[i]; cur.key = opt[0]; - cur.label = opt.length == 1 ? opt[0] : opt[1]; + cur.label = opt.length == 1 ? opt[0] : mkws.M(opt[1]); if (order == cur.key || order == cur.label) cur.selected = true; output.sort.push(cur); } diff --git a/src/mkws-widget.js b/src/mkws-widget.js index 0ea1e0f..4cace29 100644 --- a/src/mkws-widget.js +++ b/src/mkws-widget.js @@ -104,17 +104,9 @@ mkws.makeWidget = function($, team, type, node) { var that = this; var query = this.config.autosearch; if (query) { - var old = this.team.config.query; - if (!old) { - // Stash this for subsequent inspection - this.team.config.query = query; - } else if (old === query) { - this.warn("duplicate autosearch: '" + query + "': ignoring"); - return; - } else { - this.warn("conflicting autosearch: '" + query + "' vs '" + old + "': ignoring"); - return; - } + // Should do this more elegantly with message passing + var widget = this.team.widget('query'); + if (widget) { widget.node.val(query); } this.team.queue("ready").subscribe(function() { // Postpone testing for the configuration items: these are not diff --git a/src/templates/facet.handlebars b/src/templates/facet.handlebars index 7a4eedf..22877f3 100644 --- a/src/templates/facet.handlebars +++ b/src/templates/facet.handlebars @@ -10,7 +10,7 @@ terms: field - for the xtargets facet ONLY, the opaque identifier of the target }} -
{{caption}}
+
{{{mkws-translate caption}}}
{{#each terms}}
{{term}} {{count}} diff --git a/src/templates/navi.handlebars b/src/templates/navi.handlebars index 5139fd7..fd56157 100644 --- a/src/templates/navi.handlebars +++ b/src/templates/navi.handlebars @@ -7,7 +7,7 @@ filters click - handler script to remove limit }} {{#each filters}} - {{{mkws-translate facet}}}: {{value}} + {{{mkws-translate facet}}}: {{value}} {{#unless @last}}|{{/unless}} {{/each}} diff --git a/src/templates/pager.handlebars b/src/templates/pager.handlebars index 61768ed..0b3f953 100644 --- a/src/templates/pager.handlebars +++ b/src/templates/pager.handlebars @@ -14,9 +14,9 @@ pages: click - script to go to this page unless it is the current one }}
- {{mkws-translate "Displaying"}}: - {{first}} {{mkws-translate "to"}} {{last}} - {{mkws-translate "of"}} {{count}} ({{{mkws-translate "found"}}}: {{found}}) + {{mkws-translate "Displaying"}}: + {{first}} {{mkws-translate "to"}} {{last}} + {{mkws-translate "of"}} {{count}} ({{{mkws-translate "found"}}}: {{found}})
diff --git a/src/templates/ranking.handlebars b/src/templates/ranking.handlebars index 890e29a..6e02ecc 100644 --- a/src/templates/ranking.handlebars +++ b/src/templates/ranking.handlebars @@ -14,7 +14,7 @@ perPage }}
{{~#if showSort~}} - {{{mkws-translate "Sort by"}}} + {{{mkws-translate "Sort by"}}} {{~/if~}} {{~#if showPerPage}} - {{{mkws-translate "and show"}}} + {{{mkws-translate "and show"}}} - {{{mkws-translate "per page"}}} + {{{mkws-translate "per page"}}} {{~/if~}}
diff --git a/test/Makefile b/test/Makefile index ad50888..2d3e8bb 100644 --- a/test/Makefile +++ b/test/Makefile @@ -65,9 +65,9 @@ _phantomjs: phantomjs-all p-all: ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-local-popup.html - ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-popup.html - ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-cms-popup.html - ${MAKE} phantomjs PHANTOMJS_PATH=jasmine.html + ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-popup.html?lang=de + ${MAKE} phantomjs PHANTOMJS_PATH=jasmine-cms-popup.html?lang=en + ${MAKE} phantomjs PHANTOMJS_PATH=jasmine.html?lang=da mike-test: $(MAKE) _phantomjs PHANTOMJS_URL=http://x.example.indexdata.com/jasmine-popup.html diff --git a/test/spec/mkws-pazpar2.js b/test/spec/mkws-pazpar2.js index ab1f380..f0870e7 100644 --- a/test/spec/mkws-pazpar2.js +++ b/test/spec/mkws-pazpar2.js @@ -526,6 +526,142 @@ describe("Check switch menu Records/Targets", function () { }); }); +describe("Check translations", function () { + var $ = mkws.$; + + // handle html entities, "Zurück" => "Zurück" + var M = function (string) { + var text = $("").html(mkws.M(string)).text() + debug("translate check for: " + text); + return text; + }; + var lang = function () { + return mkws.config.lang + }; + + function check_translation(list, text) { + expect(list.length).toBe(text.length); + + for (var i = 0; i < text.length; i++) { + expect($(list[i]).text()).toBe(M(text[i])); + } + } + + it("check language", function () { + var lang = mkws.config.lang; + debug("lang: " + lang); + expect(lang).toMatch(/^(de|da|)$/); + }); + +/* + locale_lang: { + "de": { + "Authors": "Autoren", + "Subjects": "Schlagwörter", + "Sources": "Daten und Quellen", + "source": "datenquelle", + "Facets": "Termlisten", + "Next": "Weiter", + "Prev": "Zurück", + "Search": "Suche", + "Sort by": "Sortieren nach", + "and show": "und zeige", + "per page": "pro Seite", + "Displaying": "Zeige", + "to": "von", + "of": "aus", + "found": "gefunden", + "Title": "Titel", + "Author": "Autor", + "author": "autor", + "Date": "Datum", + "Subject": "Schlagwort", + "subject": "schlagwort", + "Location": "Ort", + "Records": "Datensätze", + "Targets": "Datenbanken", + "relevance": "Relevanz", + "title": "Titel", + "newest": "Neueste", + "oldest": "Älteste", + + "dummy": "dummy" + }, +*/ + + it("search button", function () { + var list = $(".mkws-pager-desc > span"); + expect($("form > input[type=submit]").attr("value")).toBe(M("Search")); + }); + + it("switch", function () { + var list = $(".mkws-switch > a") + var text = ["Records", "Targets"]; + + check_translation(list, text); + }); + + + it("ranking form", function () { + var list = $(".mkws-ranking > form > span"); + var text = ["Sort by", "and show", "per page"]; + + check_translation(list, text); + + // double check + if (lang == "de") { + expect("Sortieren nach").toBe(M("Sort by")); + expect("Sortieren nach").toBe($(list[0]).text()); + } else if (lang == "da") { + expect("Sorter efter").toBe(M("Sort by")); + expect("Sorter efter").toBe($(list[0]).text()); + } + + + expect($("select.mkws-sort > option[selected=selected]").text()).toBe(M("relevance")); + }); + + it("facets sidebar", function () { + var list = $(".mkws-facet-title"); + var text = ["Sources", "Subjects", "Authors"]; + + check_translation(list, text); + }); + + it("facets navigation/filter", function () { + var list = $(".mkws-navi > span"); + var text = ["source", "author"]; + + check_translation(list, text); + }); + + it("navigation", function () { + var list = $(".mkws-pager-desc > span"); + var text = ["Displaying", "to", "of", "found"]; + + check_translation(list, text); + + expect($(".mkws-next").text()).toBe(M("Next")); + expect($(".mkws-prev").text()).toBe(M("Prev")); + }); + + it("record details", function () { + var text = ["Title", "Date", "Author"]; // , "Subject", "Locations"]; + var list = $("div.mkws-details table > tbody > tr > th"); + + // compare only the first 3 elements + list = list.splice(0, text.length) + + check_translation(list, text); + }); + +/* not tested + * + * Status line: -- Active clients : 0/1 -- Retrieved records : 4/4 + * + */ +}); + describe("Check status client counter", function () { var $ = mkws.$; @@ -667,7 +803,7 @@ describe("Check per page options", function () { describe("Check SortBy options", function () { var $ = mkws.$; - it("show per page", function () { + it("sort by title", function () { if (!jasmine_config.check_sortby) { debug("ignore check for sort by"); return; @@ -738,7 +874,8 @@ describe("Check SortBy options", function () { }); }); -describe("Check async widget discovery", function () { + +xdescribe("Check async widget discovery", function () { var $ = mkws.$; it("initialises a new widget", function () { $("div.mkws-search").after('
');