diff --git a/squelettes/content/scrutarijs.html b/squelettes/content/scrutarijs.html
index 137f910..e8a8921 100644
--- a/squelettes/content/scrutarijs.html
+++ b/squelettes/content/scrutarijs.html
@@ -1,46 +1,8 @@
-[===============================================================(#REM)
-Configuration du client Scrutari
-]
-
-
-
[===============================================================(#REM)
Déclaration du bloc destiné à recevoir le client
]
-
+
+
+[===============================================================(#REM)
+Structure du client
+]
+
+
+
+
+
+
+
+
+
+
+
+
Votre historique :
+
+
+
+
+
+
+
+
+
+
+
+
Vos résultats
+
+
+
+
+
+
+
+
@@ -61,32 +125,6 @@ Déclaration du bloc destiné à recevoir le client
Partie consacrée à la réécriture des gabarits
voir https://framagit.org/Scrutari/scrutarijs/-/wikis/adaptation#reformuler-un-%C3%A9lement-de-structure-et-de-gabarit
]
-
-
-
-
-
-
+
+
+
+
diff --git a/squelettes/head_js/scrutarijs.html b/squelettes/head_js/scrutarijs.html
index b986d31..0109bd8 100644
--- a/squelettes/head_js/scrutarijs.html
+++ b/squelettes/head_js/scrutarijs.html
@@ -1,3 +1,6 @@
+[(#REM) Version 2.4.2 de Lity (à supprimer à la migration vers Spip 4.1)]
+[]
+
[(#REM) Version 1.0.7 de JsRender]
[]
@@ -8,9 +11,12 @@
[(#REM) Version française]
[]
-[(#REM) Structure et gabarits correspondant à l'absence de framework]
-[]
+[(#REM) Client spécial LAV, c'est lui qui doit recevoir les modifications et adaptations]
+[]
+[(#REM) Structure et gabarits par défaut]
+[]
+
+[]
[]
-[]
[]
diff --git a/squelettes/javascript/lity/lity.css b/squelettes/javascript/lity/lity.css
new file mode 100644
index 0000000..c2ef965
--- /dev/null
+++ b/squelettes/javascript/lity/lity.css
@@ -0,0 +1,200 @@
+/*! Lity - v2.4.1 - 2020-04-26
+* http://sorgalla.com/lity/
+* Copyright (c) 2015-2020 Jan Sorgalla; Licensed MIT */
+.lity {
+ z-index: 9990;
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ white-space: nowrap;
+ background: #0b0b0b;
+ background: rgba(0, 0, 0, 0.9);
+ outline: none !important;
+ opacity: 0;
+ -webkit-transition: opacity 0.3s ease;
+ -o-transition: opacity 0.3s ease;
+ transition: opacity 0.3s ease;
+}
+.lity.lity-opened {
+ opacity: 1;
+}
+.lity.lity-closed {
+ opacity: 0;
+}
+.lity * {
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.lity-wrap {
+ z-index: 9990;
+ position: fixed;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ text-align: center;
+ outline: none !important;
+}
+.lity-wrap:before {
+ content: '';
+ display: inline-block;
+ height: 100%;
+ vertical-align: middle;
+ margin-right: -0.25em;
+}
+.lity-loader {
+ z-index: 9991;
+ color: #fff;
+ position: absolute;
+ top: 50%;
+ margin-top: -0.8em;
+ width: 100%;
+ text-align: center;
+ font-size: 14px;
+ font-family: Arial, Helvetica, sans-serif;
+ opacity: 0;
+ -webkit-transition: opacity 0.3s ease;
+ -o-transition: opacity 0.3s ease;
+ transition: opacity 0.3s ease;
+}
+.lity-loading .lity-loader {
+ opacity: 1;
+}
+.lity-container {
+ z-index: 9992;
+ position: relative;
+ text-align: left;
+ vertical-align: middle;
+ display: inline-block;
+ white-space: normal;
+ max-width: 100%;
+ max-height: 100%;
+ outline: none !important;
+}
+.lity-content {
+ z-index: 9993;
+ width: 100%;
+ -webkit-transform: scale(1);
+ -ms-transform: scale(1);
+ -o-transform: scale(1);
+ transform: scale(1);
+ -webkit-transition: -webkit-transform 0.3s ease;
+ transition: -webkit-transform 0.3s ease;
+ -o-transition: -o-transform 0.3s ease;
+ transition: transform 0.3s ease;
+ transition: transform 0.3s ease, -webkit-transform 0.3s ease, -o-transform 0.3s ease;
+}
+.lity-loading .lity-content,
+.lity-closed .lity-content {
+ -webkit-transform: scale(0.8);
+ -ms-transform: scale(0.8);
+ -o-transform: scale(0.8);
+ transform: scale(0.8);
+}
+.lity-content:after {
+ content: '';
+ position: absolute;
+ left: 0;
+ top: 0;
+ bottom: 0;
+ display: block;
+ right: 0;
+ width: auto;
+ height: auto;
+ z-index: -1;
+ -webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
+}
+.lity-close {
+ z-index: 9994;
+ width: 35px;
+ height: 35px;
+ position: fixed;
+ right: 0;
+ top: 0;
+ -webkit-appearance: none;
+ cursor: pointer;
+ text-decoration: none;
+ text-align: center;
+ padding: 0;
+ color: #fff;
+ font-style: normal;
+ font-size: 35px;
+ font-family: Arial, Baskerville, monospace;
+ line-height: 35px;
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
+ border: 0;
+ background: none;
+ outline: none;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+}
+.lity-close::-moz-focus-inner {
+ border: 0;
+ padding: 0;
+}
+.lity-close:hover,
+.lity-close:focus,
+.lity-close:active,
+.lity-close:visited {
+ text-decoration: none;
+ text-align: center;
+ padding: 0;
+ color: #fff;
+ font-style: normal;
+ font-size: 35px;
+ font-family: Arial, Baskerville, monospace;
+ line-height: 35px;
+ text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
+ border: 0;
+ background: none;
+ outline: none;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+}
+.lity-close:active {
+ top: 1px;
+}
+/* Image */
+.lity-image img {
+ max-width: 100%;
+ display: block;
+ line-height: 0;
+ border: 0;
+}
+/* iFrame */
+.lity-iframe .lity-container,
+.lity-youtube .lity-container,
+.lity-vimeo .lity-container,
+.lity-facebookvideo .lity-container,
+.lity-googlemaps .lity-container {
+ width: 100%;
+ max-width: 964px;
+}
+.lity-iframe-container {
+ width: 100%;
+ height: 0;
+ padding-top: 56.25%;
+ overflow: auto;
+ pointer-events: auto;
+ -webkit-transform: translateZ(0);
+ transform: translateZ(0);
+ -webkit-overflow-scrolling: touch;
+}
+.lity-iframe-container iframe {
+ position: absolute;
+ display: block;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ -webkit-box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
+ background: #000;
+}
+.lity-hide {
+ display: none;
+}
diff --git a/squelettes/javascript/lity/lity.js b/squelettes/javascript/lity/lity.js
new file mode 100644
index 0000000..950ae78
--- /dev/null
+++ b/squelettes/javascript/lity/lity.js
@@ -0,0 +1,638 @@
+/*! Lity - v2.4.1 - 2020-04-26
+* http://sorgalla.com/lity/
+* Copyright (c) 2015-2020 Jan Sorgalla; Licensed MIT */
+(function(window, factory) {
+ if (typeof define === 'function' && define.amd) {
+ define(['jquery'], function($) {
+ return factory(window, $);
+ });
+ } else if (typeof module === 'object' && typeof module.exports === 'object') {
+ module.exports = factory(window, require('jquery'));
+ } else {
+ window.lity = factory(window, window.jQuery || window.Zepto);
+ }
+}(typeof window !== "undefined" ? window : this, function(window, $) {
+ 'use strict';
+
+ var document = window.document;
+
+ var _win = $(window);
+ var _deferred = $.Deferred;
+ var _html = $('html');
+ var _instances = [];
+
+ var _attrAriaHidden = 'aria-hidden';
+ var _dataAriaHidden = 'lity-' + _attrAriaHidden;
+
+ var _focusableElementsSelector = 'a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,[contenteditable],[tabindex]:not([tabindex^="-"])';
+
+ var _defaultOptions = {
+ esc: true,
+ handler: null,
+ handlers: {
+ image: imageHandler,
+ inline: inlineHandler,
+ youtube: youtubeHandler,
+ vimeo: vimeoHandler,
+ googlemaps: googlemapsHandler,
+ facebookvideo: facebookvideoHandler,
+ iframe: iframeHandler
+ },
+ template: '
'
+ };
+
+ var _imageRegexp = /(^data:image\/)|(\.(png|jpe?g|gif|svg|webp|bmp|ico|tiff?)(\?\S*)?$)/i;
+ var _youtubeRegex = /(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i;
+ var _vimeoRegex = /(vimeo(pro)?.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/;
+ var _googlemapsRegex = /((maps|www)\.)?google\.([^\/\?]+)\/?((maps\/?)?\?)(.*)/i;
+ var _facebookvideoRegex = /(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i;
+
+ var _transitionEndEvent = (function() {
+ var el = document.createElement('div');
+
+ var transEndEventNames = {
+ WebkitTransition: 'webkitTransitionEnd',
+ MozTransition: 'transitionend',
+ OTransition: 'oTransitionEnd otransitionend',
+ transition: 'transitionend'
+ };
+
+ for (var name in transEndEventNames) {
+ if (el.style[name] !== undefined) {
+ return transEndEventNames[name];
+ }
+ }
+
+ return false;
+ })();
+
+ function transitionEnd(element) {
+ var deferred = _deferred();
+
+ if (!_transitionEndEvent || !element.length) {
+ deferred.resolve();
+ } else {
+ element.one(_transitionEndEvent, deferred.resolve);
+ setTimeout(deferred.resolve, 500);
+ }
+
+ return deferred.promise();
+ }
+
+ function settings(currSettings, key, value) {
+ if (arguments.length === 1) {
+ return $.extend({}, currSettings);
+ }
+
+ if (typeof key === 'string') {
+ if (typeof value === 'undefined') {
+ return typeof currSettings[key] === 'undefined'
+ ? null
+ : currSettings[key];
+ }
+
+ currSettings[key] = value;
+ } else {
+ $.extend(currSettings, key);
+ }
+
+ return this;
+ }
+
+ function parseQueryParams(params) {
+ var pairs = decodeURI(params.split('#')[0]).split('&');
+ var obj = {}, p;
+
+ for (var i = 0, n = pairs.length; i < n; i++) {
+ if (!pairs[i]) {
+ continue;
+ }
+
+ p = pairs[i].split('=');
+ obj[p[0]] = p[1];
+ }
+
+ return obj;
+ }
+
+ function appendQueryParams(url, params) {
+ return url + (url.indexOf('?') > -1 ? '&' : '?') + $.param(params);
+ }
+
+ function transferHash(originalUrl, newUrl) {
+ var pos = originalUrl.indexOf('#');
+
+ if (-1 === pos) {
+ return newUrl;
+ }
+
+ if (pos > 0) {
+ originalUrl = originalUrl.substr(pos);
+ }
+
+ return newUrl + originalUrl;
+ }
+
+ function error(msg) {
+ return $('').append(msg);
+ }
+
+ function imageHandler(target, instance) {
+ var desc = (instance.opener() && instance.opener().data('lity-desc')) || 'Image with no description';
+ var img = $('');
+ var deferred = _deferred();
+ var failed = function() {
+ deferred.reject(error('Failed loading image'));
+ };
+
+ img
+ .on('load', function() {
+ if (this.naturalWidth === 0) {
+ return failed();
+ }
+
+ deferred.resolve(img);
+ })
+ .on('error', failed)
+ ;
+
+ return deferred.promise();
+ }
+
+ imageHandler.test = function(target) {
+ return _imageRegexp.test(target);
+ };
+
+ function inlineHandler(target, instance) {
+ var el, placeholder, hasHideClass;
+
+ try {
+ el = $(target);
+ } catch (e) {
+ return false;
+ }
+
+ if (!el.length) {
+ return false;
+ }
+
+ placeholder = $('');
+ hasHideClass = el.hasClass('lity-hide');
+
+ instance
+ .element()
+ .one('lity:remove', function() {
+ placeholder
+ .before(el)
+ .remove()
+ ;
+
+ if (hasHideClass && !el.closest('.lity-content').length) {
+ el.addClass('lity-hide');
+ }
+ })
+ ;
+
+ return el
+ .removeClass('lity-hide')
+ .after(placeholder)
+ ;
+ }
+
+ function youtubeHandler(target) {
+ var matches = _youtubeRegex.exec(target);
+
+ if (!matches) {
+ return false;
+ }
+
+ return iframeHandler(
+ transferHash(
+ target,
+ appendQueryParams(
+ 'https://www.youtube' + (matches[2] || '') + '.com/embed/' + matches[4],
+ $.extend(
+ {
+ autoplay: 1
+ },
+ parseQueryParams(matches[5] || '')
+ )
+ )
+ )
+ );
+ }
+
+ function vimeoHandler(target) {
+ var matches = _vimeoRegex.exec(target);
+
+ if (!matches) {
+ return false;
+ }
+
+ return iframeHandler(
+ transferHash(
+ target,
+ appendQueryParams(
+ 'https://player.vimeo.com/video/' + matches[3],
+ $.extend(
+ {
+ autoplay: 1
+ },
+ parseQueryParams(matches[4] || '')
+ )
+ )
+ )
+ );
+ }
+
+ function facebookvideoHandler(target) {
+ var matches = _facebookvideoRegex.exec(target);
+
+ if (!matches) {
+ return false;
+ }
+
+ if (0 !== target.indexOf('http')) {
+ target = 'https:' + target;
+ }
+
+ return iframeHandler(
+ transferHash(
+ target,
+ appendQueryParams(
+ 'https://www.facebook.com/plugins/video.php?href=' + target,
+ $.extend(
+ {
+ autoplay: 1
+ },
+ parseQueryParams(matches[4] || '')
+ )
+ )
+ )
+ );
+ }
+
+ function googlemapsHandler(target) {
+ var matches = _googlemapsRegex.exec(target);
+
+ if (!matches) {
+ return false;
+ }
+
+ return iframeHandler(
+ transferHash(
+ target,
+ appendQueryParams(
+ 'https://www.google.' + matches[3] + '/maps?' + matches[6],
+ {
+ output: matches[6].indexOf('layer=c') > 0 ? 'svembed' : 'embed'
+ }
+ )
+ )
+ );
+ }
+
+ function iframeHandler(target) {
+ return '';
+ }
+
+ function winHeight() {
+ return document.documentElement.clientHeight
+ ? document.documentElement.clientHeight
+ : Math.round(_win.height());
+ }
+
+ function keydown(e) {
+ var current = currentInstance();
+
+ if (!current) {
+ return;
+ }
+
+ // ESC key
+ if (e.keyCode === 27 && !!current.options('esc')) {
+ current.close();
+ }
+
+ // TAB key
+ if (e.keyCode === 9) {
+ handleTabKey(e, current);
+ }
+ }
+
+ function handleTabKey(e, instance) {
+ var focusableElements = instance.element().find(_focusableElementsSelector);
+ var focusedIndex = focusableElements.index(document.activeElement);
+
+ if (e.shiftKey && focusedIndex <= 0) {
+ focusableElements.get(focusableElements.length - 1).focus();
+ e.preventDefault();
+ } else if (!e.shiftKey && focusedIndex === focusableElements.length - 1) {
+ focusableElements.get(0).focus();
+ e.preventDefault();
+ }
+ }
+
+ function resize() {
+ $.each(_instances, function(i, instance) {
+ instance.resize();
+ });
+ }
+
+ function registerInstance(instanceToRegister) {
+ if (1 === _instances.unshift(instanceToRegister)) {
+ _html.addClass('lity-active');
+
+ _win
+ .on({
+ resize: resize,
+ keydown: keydown
+ })
+ ;
+ }
+
+ $('body > *').not(instanceToRegister.element())
+ .addClass('lity-hidden')
+ .each(function() {
+ var el = $(this);
+
+ if (undefined !== el.data(_dataAriaHidden)) {
+ return;
+ }
+
+ el.data(_dataAriaHidden, el.attr(_attrAriaHidden) || null);
+ })
+ .attr(_attrAriaHidden, 'true')
+ ;
+ }
+
+ function removeInstance(instanceToRemove) {
+ var show;
+
+ instanceToRemove
+ .element()
+ .attr(_attrAriaHidden, 'true')
+ ;
+
+ if (1 === _instances.length) {
+ _html.removeClass('lity-active');
+
+ _win
+ .off({
+ resize: resize,
+ keydown: keydown
+ })
+ ;
+ }
+
+ _instances = $.grep(_instances, function(instance) {
+ return instanceToRemove !== instance;
+ });
+
+ if (!!_instances.length) {
+ show = _instances[0].element();
+ } else {
+ show = $('.lity-hidden');
+ }
+
+ show
+ .removeClass('lity-hidden')
+ .each(function() {
+ var el = $(this), oldAttr = el.data(_dataAriaHidden);
+
+ if (!oldAttr) {
+ el.removeAttr(_attrAriaHidden);
+ } else {
+ el.attr(_attrAriaHidden, oldAttr);
+ }
+
+ el.removeData(_dataAriaHidden);
+ })
+ ;
+ }
+
+ function currentInstance() {
+ if (0 === _instances.length) {
+ return null;
+ }
+
+ return _instances[0];
+ }
+
+ function factory(target, instance, handlers, preferredHandler) {
+ var handler = 'inline', content;
+
+ var currentHandlers = $.extend({}, handlers);
+
+ if (preferredHandler && currentHandlers[preferredHandler]) {
+ content = currentHandlers[preferredHandler](target, instance);
+ handler = preferredHandler;
+ } else {
+ // Run inline and iframe handlers after all other handlers
+ $.each(['inline', 'iframe'], function(i, name) {
+ delete currentHandlers[name];
+
+ currentHandlers[name] = handlers[name];
+ });
+
+ $.each(currentHandlers, function(name, currentHandler) {
+ // Handler might be "removed" by setting callback to null
+ if (!currentHandler) {
+ return true;
+ }
+
+ if (
+ currentHandler.test &&
+ !currentHandler.test(target, instance)
+ ) {
+ return true;
+ }
+
+ content = currentHandler(target, instance);
+
+ if (false !== content) {
+ handler = name;
+ return false;
+ }
+ });
+ }
+
+ return {handler: handler, content: content || ''};
+ }
+
+ function Lity(target, options, opener, activeElement) {
+ var self = this;
+ var result;
+ var isReady = false;
+ var isClosed = false;
+ var element;
+ var content;
+
+ options = $.extend(
+ {},
+ _defaultOptions,
+ options
+ );
+
+ element = $(options.template);
+
+ // -- API --
+
+ self.element = function() {
+ return element;
+ };
+
+ self.opener = function() {
+ return opener;
+ };
+
+ self.options = $.proxy(settings, self, options);
+ self.handlers = $.proxy(settings, self, options.handlers);
+
+ self.resize = function() {
+ if (!isReady || isClosed) {
+ return;
+ }
+
+ content
+ .css('max-height', winHeight() + 'px')
+ .trigger('lity:resize', [self])
+ ;
+ };
+
+ self.close = function() {
+ if (!isReady || isClosed) {
+ return;
+ }
+
+ isClosed = true;
+
+ removeInstance(self);
+
+ var deferred = _deferred();
+
+ // We return focus only if the current focus is inside this instance
+ if (
+ activeElement &&
+ (
+ document.activeElement === element[0] ||
+ $.contains(element[0], document.activeElement)
+ )
+ ) {
+ try {
+ activeElement.focus();
+ } catch (e) {
+ // Ignore exceptions, eg. for SVG elements which can't be
+ // focused in IE11
+ }
+ }
+
+ content.trigger('lity:close', [self]);
+
+ element
+ .removeClass('lity-opened')
+ .addClass('lity-closed')
+ ;
+
+ transitionEnd(content.add(element))
+ .always(function() {
+ content.trigger('lity:remove', [self]);
+ element.remove();
+ element = undefined;
+ deferred.resolve();
+ })
+ ;
+
+ return deferred.promise();
+ };
+
+ // -- Initialization --
+
+ result = factory(target, self, options.handlers, options.handler);
+
+ element
+ .attr(_attrAriaHidden, 'false')
+ .addClass('lity-loading lity-opened lity-' + result.handler)
+ .appendTo('body')
+ .focus()
+ .on('click', '[data-lity-close]', function(e) {
+ if ($(e.target).is('[data-lity-close]')) {
+ self.close();
+ }
+ })
+ .trigger('lity:open', [self])
+ ;
+
+ registerInstance(self);
+
+ $.when(result.content)
+ .always(ready)
+ ;
+
+ function ready(result) {
+ content = $(result)
+ .css('max-height', winHeight() + 'px')
+ ;
+
+ element
+ .find('.lity-loader')
+ .each(function() {
+ var loader = $(this);
+
+ transitionEnd(loader)
+ .always(function() {
+ loader.remove();
+ })
+ ;
+ })
+ ;
+
+ element
+ .removeClass('lity-loading')
+ .find('.lity-content')
+ .empty()
+ .append(content)
+ ;
+
+ isReady = true;
+
+ content
+ .trigger('lity:ready', [self])
+ ;
+ }
+ }
+
+ function lity(target, options, opener) {
+ if (!target.preventDefault) {
+ opener = $(opener);
+ } else {
+ target.preventDefault();
+ opener = $(this);
+ target = opener.data('lity-target') || opener.attr('href') || opener.attr('src');
+ }
+
+ var instance = new Lity(
+ target,
+ $.extend(
+ {},
+ opener.data('lity-options') || opener.data('lity'),
+ options
+ ),
+ opener,
+ document.activeElement
+ );
+
+ if (!target.preventDefault) {
+ return instance;
+ }
+ }
+
+ lity.version = '2.4.1';
+ lity.options = $.proxy(settings, lity, _defaultOptions);
+ lity.handlers = $.proxy(settings, lity, _defaultOptions.handlers);
+ lity.current = currentInstance;
+
+ $(document).on('click.lity', '[data-lity]', lity);
+
+ return lity;
+}));
diff --git a/squelettes/javascript/scrutarijs/Scrutari.Lav.js b/squelettes/javascript/scrutarijs/Scrutari.Lav.js
new file mode 100644
index 0000000..6edb104
--- /dev/null
+++ b/squelettes/javascript/scrutarijs/Scrutari.Lav.js
@@ -0,0 +1,246 @@
+/* global Scrutari */
+
+/**
+ * Surcharge et complément du client ScrutariJs pour le site librevous.org
+ */
+
+Scrutari.Lav = {};
+
+/**
+ * Adresse du serveur Scrutari
+ */
+Scrutari.Lav.SCRUTARI_URL = "https://sct2.scrutari.net/sct/april_libreavous/";
+/**
+ * Nombre de fiches dans une pagination
+ */
+Scrutari.Lav.PAGINATION_LENGTH = 20;
+/**
+ * Tableau des différentes paginations, la première est la pagination sur la totalité des sites, les autres sont les paginations par site
+ */
+Scrutari.Lav.PAGINATION_ARRAY = ["", "libreavous", "librealire"];
+/**
+ * Indication s'il s'agit de la version de développement
+ */
+Scrutari.Lav.DEV = false;
+
+/**
+ * Fonction utilitaire de formatage de la séquence de recherche pour l'affichage
+ */
+Scrutari.Lav.formatSearchSequence = function (client, scrutariResult) {
+ var q = scrutariResult.getQ();
+ q = q.replace(/\&\&/g, '@%et%@');
+ q = q.replace(/\|\|/g, '@%ou%@');
+ q = q.replace(/\*/g, '@%*%@');
+ q = Scrutari.escape(q);
+ q = q.replace(/@%/g, '');
+ q = q.replace(/%@/g, '');
+ return q;
+};
+
+
+/**
+ * Fonction principale d'initialisation du client. Remplace Scrutari.DefaultUi.init
+ */
+Scrutari.Lav.init = function (client) {
+ var scrutariMeta = client.scrutariMeta;
+ client.lav = {}; //propriété lav pour conserver des données propres à ce client
+ _initLav();
+ if (Scrutari.Lav.DEV) { //Code propre à la version de développement, en production la structure est en dur dans le squelette Spip
+ $("#" + client.clientId).html(client.compileStructure("main"));
+ $("#zone").html(client.compileStructure("main", {
+ noLoc: true,
+ withIndent: true,
+ withPath: true
+ }));
+ }
+ client.initForms();
+ client.initButtons(Scrutari.Lav.actionHandler);
+ client.initChangeListeners(Scrutari.Lav.changeHandler);
+ client.checkInitialQuery();
+
+ function _initLav() {
+ let paginationArray = new Array();
+ for(let name of Scrutari.Lav.PAGINATION_ARRAY) {
+ let active = false;
+ let suffix = "-" + name;
+ let radio = name;
+ if (!name) { // valeurs particulières pour « tous »
+ active = true;
+ suffix = "";
+ radio = "tous";
+ }
+ paginationArray.push({
+ name: name,
+ active: active,
+ suffix: suffix,
+ radio: radio
+ });
+ }
+ client.lav.paginationArray = paginationArray;
+ }
+
+}
+
+
+/**
+ * Fonction d'enrichissement du processus d'affichage des résultats.
+ * la méthode addPaginisations de la classe Scrutari.Process est remplacée pour que trois paginations
+ * soient créés : celle, normale, de toutes les fiches et une par site
+ * Remplace Scrutari.DefaultUi.newResultProcess
+ */
+Scrutari.Lav.newResultProcess = function (client, scrutariResult, searchOrigin) {
+ var resultProcess = new Scrutari.Process(client, scrutariResult, searchOrigin);
+ resultProcess.addPaginations = function ($paginationBlock) {
+ _addPaginations($paginationBlock);
+ };
+ var libreavousArray = new Array();
+ var librealireArray = new Array();
+ var length = scrutariResult.ficheGroupArray.length;
+ if (length > 0) {
+ for(let fiche of scrutariResult.ficheGroupArray[0].ficheArray) {
+ if (fiche.codecorpus === 1222) {
+ libreavousArray.push(fiche);
+ } else {
+ librealireArray.push(fiche);
+ }
+ }
+ }
+ var arrays = {
+ libreavous: libreavousArray,
+ librealire: librealireArray
+ };
+ return resultProcess;
+
+ function _addPaginations($paginationBlock) {
+ $paginationBlock.html(client.render("pagination_lav", {array: client.lav.paginationArray}));
+ client.$count("total-tous", 'update', scrutariResult.getFicheCount());
+ for(let config of client.lav.paginationArray) {
+ let pagination = new Scrutari.Pagination(client, config.name);
+ if (config.name) {
+ client.$count("total-" + config.name, 'update', arrays[config.name].length);
+ pagination.getPaginationFicheArray = function (scrutariResult, paginationNumber) {
+ return _getPaginationFicheArray(config.name, pagination.paginationLength, paginationNumber);
+ };
+ }
+ client.putPagination(config.name, pagination);
+ pagination.change(1);
+ }
+ }
+
+ function _getPaginationFicheArray(name, paginationLength, paginationNumber) {
+ let array = arrays[name];
+ return Scrutari.Utils.extractFicheArray(array, paginationLength, paginationNumber);
+ }
+};
+
+/**
+ * Personnalisation des actions sur les boutons, passée à client.initButtons()
+ */
+Scrutari.Lav.actionHandler = function (client, button, action, target) {
+ switch(action) {
+ case 'copyPermalink':
+ navigator.clipboard.writeText($(button).attr("href"));
+ break;
+ default:
+ return false;
+ }
+ return true;
+};
+
+/**
+ * Personnalisation des écouteurs actions sur les boutons, passée à client.initButtons()
+ */
+Scrutari.Lav.changeHandler = function (client, element, name) {
+ switch(name) {
+ case 'lav-site':
+ if (element.checked) {
+ _setSiteFilter(element.value);
+ }
+ return true;
+ default:
+ return false;
+ }
+
+ function _setSiteFilter (value) {
+ let suffix = "";
+ for(let pagination of client.lav.paginationArray) {
+ if (value === pagination.radio) {
+ pagination.active = true;
+ suffix = pagination.suffix;
+ } else {
+ pagination.active = false;
+ }
+ }
+ let activeBlockName = "ficheGroup" + suffix;
+ client.$block("ficheGroup", "*").each(function (index, element) {
+ if (element.dataset.scrutariBlock === activeBlockName) {
+ client.show(element);
+ } else {
+ client.hide(element);
+ }
+ });
+ }
+};
+
+/**
+ * Objet définissant les points d'entrée (hook) particuliers, transmis à la configuration
+ */
+Scrutari.Lav.HOOKS = {
+ completeFiche : function (scrutariResult, fiche, categoryName) { //Extrait le numéro du titre
+ let start = fiche.mtitre[0];
+ let numero = "";
+ if (start.startsWith("#")) {
+ let idx = start.indexOf("-");
+ if (idx > 0) {
+ numero = start.substring(0, idx).trim();
+ fiche.mtitre[0] = start.substring(idx + 1);
+ }
+ }
+ fiche._numero = numero;
+ }
+};
+
+/**
+ * Objet centralisant les fonctions surchargées du client
+ */
+Scrutari.Lav.FUNCTIONS = {
+ uiInit: function (client) {
+ Scrutari.Lav.init(client);
+ },
+ ignoreElement: null,
+ isFilterEnable: null,
+ mainsearchResultCallback: function (client, scrutariResult) {
+ $("#scrutari_lav_sequence").html(Scrutari.Lav.formatSearchSequence(client, scrutariResult));
+ },
+ mainsearchErrorCallback: null,
+ subsearchResultCallback: null,
+ subsearchErrorCallback: null,
+ initFilterByQuery: null,
+ newResultProcess: function (client, scrutariResult, searchOrigin) {
+ return Scrutari.Lav.newResultProcess(client, scrutariResult, searchOrigin);
+ }
+};
+
+/**
+ * Initialisation du client
+ */
+$(function () {
+ var scrutariConfig = new Scrutari.Config("libreavous", Scrutari.Lav.SCRUTARI_URL, "fr", "site", {
+ paginationLength: Scrutari.Lav.PAGINATION_LENGTH,
+ limit: -1
+ });
+ Scrutari.Client.init(scrutariConfig, "scrutari_client", {
+ withCorpus: false,
+ ficheTarget: "_blank",
+ ficheBodyList: "fiche_mtitre,fiche_msoustitre,libreavous_start_ul,fiche_primaryattributearray,fiche_mcomplementarray,fiche_secondaryattributearray,fiche_motclearray,fiche_bythesaurusarray,libreavous_end_ul", //Ajout de libreavous_start_ul et libreavous_end_ul, retrait de fiche_year
+ initialQuery: "",
+ initialQId: "",
+ ignoreList: "area-title,area-stats,modal-*", //Utilisé en mode développement
+ permalinkPattern: "https://www.libreavous.org/spip.php?page=scrutarijs&qid=$QID",
+ hooks: Scrutari.Lav.HOOKS,
+ functions: Scrutari.Lav.FUNCTIONS
+
+ }, function (client) {
+
+ });
+});
diff --git a/squelettes/javascript/scrutarijs/frameworks/_default.js b/squelettes/javascript/scrutarijs/frameworks/_default.js
new file mode 100644
index 0000000..b810dad
--- /dev/null
+++ b/squelettes/javascript/scrutarijs/frameworks/_default.js
@@ -0,0 +1,52 @@
+var SCRUTARI_HTML = {
+_name:'_default',
+structure:{
+'area-input':'
',
+'area-parameters':' {{panel-options}} {{panel-corpus}} {{panel-base}} {{panel-lang}} {{panel-category}}
',
+'area-result':' {{result-links}}
{{result-history}}
{{result-subsearch}}
{{result-poweredby}}
',
+'area-stats':' {{stats-table}}
',
+'area-title':' ',
+'main-form':'',
+'main':'{{area-title}} {{main-form}} {{area-stats}} {{area-result}} {{modal-*}}',
+'modal-help_mode':'',
+'modal-help_periode':'',
+'modal-help_ponderation':'',
+'modal-loading':'',
+'panel-base':' _ title_filter_base _ filter_off
',
+'panel-category':' _ title_filter_category _ filter_off
',
+'panel-corpus':' _ title_filter_corpus _ filter_off
',
+'panel-lang':' _ title_filter_lang _ filter_off
',
+'panel-options':'',
+'result-history':'',
+'result-links':'_ title_share
_ title_download
ods csv
_ title_feed
atom
',
+'result-poweredby':' _ link_poweredby
',
+'result-subsearch':'',
+'stats-filter':' _ stats_filter_short | | |
',
+'stats-global':' _ stats_global_short | |
',
+'stats-result':' _ stats_result_short | |
',
+'stats-table':' {{stats-global}} {{stats-filter}} {{stats-result}}
'
+},
+templates:{
+'base':'
',
+'category':'
',
+'corpus':'
',
+'fiche':' {{include tmpl="fiche_icon" /}}
{{for _bodyTemplateArray ~fiche=#data}} {{include ~fiche tmpl=~scrutari_client.getTemplate(#data) /}} {{/for}}
',
+'fiche_attribute':'{{if type!=="block"}} {{>title}}{{>~scrutari_loc("_ colon")}} {{for valueArray ~len=valueArray.length}} {{:~scrutari_mark(#data)}}{{if #index != (~len -1)}}, {{/if}} {{/for}}
{{else}} {{>title}}{{>~scrutari_loc("_ colon")}}
{{for valueArray ~len=valueArray.length}}
{{:~scrutari_mark(#data)}}
{{/for}}
{{/if}}',
+'fiche_bythesaurusarray':'{{if _bythesaurusArray}} {{for _bythesaurusArray}} {{> thesaurus.title}}{{>~scrutari_loc("_ colon")}} {{for motcleArray ~len=motcleArray.length}} {{if mlabelArray}}{{for mlabelArray}}{{if #index > 0}}/{{/if}}{{:~scrutari_mark(mvalue)}}{{/for}}{{/if}}{{if #index != (~len -1)}}, {{/if}} {{/for}}
{{/for}} {{/if}} ',
+'fiche_icon':'{{if _thumbnail}} {{if _icon}}
{{/if}}
{{else _icon}} {{/if}} ',
+'fiche_mcomplementarray':'{{if mcomplementArray}} {{for mcomplementArray}} {{>title}}{{>~scrutari_loc("_ colon")}} {{:~scrutari_mark(mvalue)}}
{{/for}} {{/if}} ',
+'fiche_motclearray':'{{if _motcleArray}} {{if _motcleArray.length == 1}} {{>~scrutari_loc("_ fiche_motscles_one")}} {{else}} {{>~scrutari_loc("_ fiche_motscles_many")}} {{/if}} {{for _motcleArray ~len=_motcleArray.length}} {{if mlabelArray}}{{for mlabelArray}}{{if #index > 0}}/{{/if}}{{:~scrutari_mark(mvalue)}}{{/for}}{{/if}}{{if #index != (~len -1)}}, {{/if}} {{/for}}
{{/if}} ',
+'fiche_msoustitre':'{{if msoustitre}} {{:~scrutari_mark(msoustitre)}}
{{/if}} ',
+'fiche_mtitre':' {{if mtitre}} {{:~scrutari_mark(mtitre)}} {{else}} {{:href}} {{/if}}
',
+'fiche_primaryattributearray':'{{if _primaryAttributeArray}} {{for _primaryAttributeArray tmpl="fiche_attribute" /}} {{/if}} ',
+'fiche_secondaryattributearray':'{{if _secondaryAttributeArray}} {{for _secondaryAttributeArray tmpl="fiche_attribute" /}} {{/if}} ',
+'fiche_year':'{{if year}} {{:year}}
{{/if}} ',
+'history':'
',
+'lang':'
',
+'loading':' {{>~scrutari_loc(\'_ loading_pagination\')}}',
+'pagination_empty':'{{>~scrutari_loc("_ result_none")}}
{{if withFilter}} {{>~scrutari_loc("_ result_fitlerwarning")}}
{{else scrutariResult.searchMeta.reportArray.length > 0}} Analyse des termes de la recherche{{>~scrutari_loc("_ colon")}}
{{for scrutariResult.searchMeta.reportArray}} - {{> text}}
{{if canonicalArray.length > 0}} Correspondances trouvées (entre parenthèses, le nombre d\'occurrences par langue):
{{for canonicalArray}} - {{> canonical}} ({{for langreportArray}}{{if #index > 0}}, {{/if}}{{:lang}}={{:ficheCount}}{{/for}})
{{/for}}
{{/if}} {{if neighbourArray.length > 0}} Pas de correspondances trouvées. Termes se rapprochant (entre parenthèses, le code des langues concernées) :
{{for neighbourArray}} - {{> neighbour}} ({{for langArray}}{{if #index > 0}}, {{/if}}{{:#data}}{{/for}})
{{/for}}
{{/if}} {{if canonicalArray.length == 0 && neighbourArray.length == 0}} Aucune correspondance ou terme voisin trouvé
{{/if}}
{{/for}}
{{/if}}',
+'pagination_groups':' {{for array}} description}}"{{/if}} data-scrutari-target="{{:name}}"> {{>title}} ({{:fichestat}}) {{/for}}
{{for array}} {{/for}}',
+'pagination_unique':' ',
+'tabs':''
+}
+};
\ No newline at end of file
diff --git a/squelettes/javascript/scrutarijs/perso.css b/squelettes/javascript/scrutarijs/perso.css
index 170cf9c..19b03da 100644
--- a/squelettes/javascript/scrutarijs/perso.css
+++ b/squelettes/javascript/scrutarijs/perso.css
@@ -1,118 +1,9 @@
-/*****************************************************
-* .none-input
-******************************************************/
-
-.none-input-Container {
-}
-
-.none-input-Parameters {
-}
-
-.none-input-Search {
-}
-
-.none-input-Submit {
-}
-
+/**
+ * pour Libre à vous
+ */
/*****************************************************
-* .none-option
-******************************************************/
-
-.none-option-Help {
-}
-
-.none-option-Legend {
-}
-
-.none-option-Title {
-}
-
-/*****************************************************
-* .none-overlay
-******************************************************/
-
-.none-overlay-Blocker {
- background-color: rgba(0,0,0, 0.75);
-}
-
-.none-overlay-Close {
- background-color: #000;
- color: #fff;
-}
-
-.none-overlay-Close:hover {
- background-color: #ddd;
-}
-
-.none-overlay-Content {
-}
-
-.none-overlay-Dialog {
- background-color: #fff;
- box-shadow: 0 0 10px #000;
-}
-
-.none-overlay-Footer {
-}
-
-.none-overlay-Header {
- border-bottom-color: #ddd;
- background-color: #f5f5f5;
-}
-
-.none-overlay-Waiting {
-}
-
-
-/*****************************************************
-* .none-panel
-******************************************************/
-
-.none-panel-ButtonGroup {
-}
-
-.none-panel-Columns {
- padding: 5px;
-}
-
-.none-panel-Header {
- border-bottom-color: #ddd;
- background-color: #f5f5f5;
-}
-
-.none-panel-ListBody {
-}
-
-.none-panel-Section {
- border-color: #ddd;
-}
-
-.texte_content h1.none-panel-Title {
- font-size: 1.0rem;
- padding: 3px;
-}
-
-.none-panel-Toolbar {
-}
-
-
-/*****************************************************
-* .none-result
-******************************************************/
-
-.none-result-Container {
-}
-
-.none-result-FicheDisplay {
-}
-
-.none-result-Sidebar {
-}
-
-
-/*****************************************************
-* .scrutari
+* .scrutari- : Surcharge de classes Scrutari par défaut
******************************************************/
.scrutari-Mark {
@@ -124,11 +15,11 @@
}
.scrutari-fiche-Titre {
- font-size: 1.3rem;
+ font-size: 1.15rem;
}
.scrutari-fiche-Titre .num_emission {
- font-size: 1.4rem;
+ font-size: 1.3rem;
margin-right: 0.5rem;
padding: 0.2rem;
width: inherit;
@@ -138,6 +29,10 @@
background-color: #ffe9e0;
}
+.scrutari-history-Block {
+ display: inline-block;
+}
+
.scrutari-history-Load {
background-color: #ffe9e0;
font-family: 'Lato',sans-serif;
@@ -146,3 +41,58 @@
color: #005184;
text-rendering: geometricPrecision;
}
+
+.scrutari-input-Text {
+ background-color: #edf1f5;
+ color: #005184;
+}
+
+.scrutari-pagination-Current {
+ background-color: #648bab;
+ color: #fff;
+}
+
+.scrutari-pagination-TabList {
+ text-align: center;
+ font-size: 1.1em;
+}
+
+
+/*****************************************************
+* .scrutari-lav- : Classes spécifiques à la version
+* pour Libre à vous
+******************************************************/
+
+.scrutari-lav-Filtre {
+ display: inline-block;
+ margin-left: 5px;
+}
+
+.scrutari-lav-Operateur {
+ color: #acd0f9;
+}
+
+.scrutari-lav-Sequence {
+ font-size: 2.5em;
+}
+
+.scrutari-lav-Total {
+ font-size: 0.85em;
+}
+
+.scrutari-lav-history-Container {
+ display: flex;
+ align-items: baseline;
+}
+
+.scrutari-lav-history-List {
+ flex-grow: 1;
+}
+
+.scrutari-lav-history-Label {
+ flex-shrink: 0;
+}
+
+.scrutari-lav-history-Clear {
+ flex-shrink: 0;
+}
diff --git a/squelettes/javascript/scrutarijs/scrutarijs.css b/squelettes/javascript/scrutarijs/scrutarijs.css
index 2333f1f..73dbc83 100644
--- a/squelettes/javascript/scrutarijs/scrutarijs.css
+++ b/squelettes/javascript/scrutarijs/scrutarijs.css
@@ -49,18 +49,18 @@ text-align: right;
* .scrutari-category
******************************************************/
-.scrutari-category-Tab {
+.scrutari-group-Tab {
display: inline-block;
padding-left: 4px;
padding-right: 4px;
cursor: pointer;
}
-.scrutari-category-Tab:hover {
+.scrutari-group-Tab:hover {
background-color: #e9e9e9;
}
-.scrutari-category-Tab.scrutari-On {
+.scrutari-group-Tab.scrutari-On {
cursor: auto;
background-color: #e9e9e9;
}
@@ -332,7 +332,7 @@ font-weight: bold;
* .scrutari-pagination
******************************************************/
-.scrutari-pagination-List {
+.scrutari-pagination-TabList {
margin-top: 15px;
margin-bottom: 15px;
}
diff --git a/squelettes/javascript/scrutarijs/scrutarijs.js b/squelettes/javascript/scrutarijs/scrutarijs.js
index cb654dc..92e0f23 100644
--- a/squelettes/javascript/scrutarijs/scrutarijs.js
+++ b/squelettes/javascript/scrutarijs/scrutarijs.js
@@ -1,4 +1,4 @@
-/* version: 1.3.2 */
+/* version: r4191 */
var Scrutari = {};
Scrutari.log = function (msg) {
if ((console) && (console.log)) {
@@ -132,7 +132,8 @@ Scrutari.Config = function (name, engineUrl, lang, origin, options) {
motcleFields: null,
paginationLength: 50,
subsearchThreshold: 250,
- groupSortFunction: _ficheCountSort
+ groupSortFunction: _ficheCountSort,
+ limit: 0
};
if (options) {
for(var key in options) {
@@ -195,6 +196,13 @@ Scrutari.Config.prototype.getPermalinkUrl = function (qId, permalinkPattern) {
permalink = permalink.replace("$QID", qId);
return permalink;
};
+Scrutari.Config.prototype.getLimit = function () {
+ if (this.options.limit) {
+ return this.options.limit;
+ } else {
+ return this.options.paginationLength * 2;
+ }
+};
Scrutari.Ajax = {};
Scrutari.Ajax.loadBaseArray = function (scrutariConfig, requestParameters, baseArrayCallback) {
if (!requestParameters) {
@@ -368,7 +376,7 @@ Scrutari.Ajax.loadFicheSearchResult = function (scrutariConfig, requestParameter
Scrutari.Ajax.check(requestParameters, "warnings", 1);
Scrutari.Ajax.check(requestParameters, "version", 3);
Scrutari.Ajax.check(requestParameters, "start", 1);
- Scrutari.Ajax.check(requestParameters, "limit", scrutariConfig.options.paginationLength * 2);
+ Scrutari.Ajax.check(requestParameters, "limit", scrutariConfig.getLimit());
Scrutari.Ajax.check(requestParameters, "starttype", "in_all");
$.ajax({
url: scrutariConfig.getJsonUrl(),
@@ -394,7 +402,7 @@ Scrutari.Ajax.loadExistingFicheSearchResult = function (scrutariConfig, requestP
Scrutari.Ajax.check(requestParameters, "warnings", 1);
Scrutari.Ajax.check(requestParameters, "version", 3);
Scrutari.Ajax.check(requestParameters, "start", 1);
- Scrutari.Ajax.check(requestParameters, "limit", scrutariConfig.options.paginationLength * 2);
+ Scrutari.Ajax.check(requestParameters, "limit", scrutariConfig.getLimit());
$.ajax({
url: scrutariConfig.getJsonUrl(),
dataType: scrutariConfig.options.dataType,
@@ -859,11 +867,20 @@ Scrutari.Result.prototype.getQ = function () {
return "";
}
};
-Scrutari.Result.prototype.getFicheCount = function () {
- if (this.searchMeta) {
- return this.searchMeta.ficheCount;
+Scrutari.Result.prototype.getFicheCount = function (ficheGroupName) {
+ if (ficheGroupName) {
+ for(let group of this.ficheGroupArray) {
+ if ((group.category) && (group.category.name === ficheGroupName)) {
+ return group.ficheCount;
+ }
+ }
+ return 0;
} else {
- return -1;
+ if (this.searchMeta) {
+ return this.searchMeta.ficheCount;
+ } else {
+ return -1;
+ }
}
};
Scrutari.Result.prototype.getFicheGroupType = function () {
@@ -879,29 +896,23 @@ Scrutari.Result.prototype.getUniqueFicheArray = function () {
}
return this.ficheGroupArray[0].ficheArray;
};
-Scrutari.Result.prototype.selectUniqueFicheArray = function (paginationLength, paginationNumber) {
- var selectionArray = new Array();
- if (this.ficheGroupArray.length === 0) {
- return selectionArray;
+Scrutari.Result.prototype.isPaginationLoaded = function (paginationLength, paginationNumber, ficheGroupName) {
+ var ficheArray;
+ var ficheCount;
+ if (ficheGroupName) {
+ let group = this.getFicheGroup(ficheGroupName);
+ if (!group) {
+ return true;
+ }
+ ficheCount = group.ficheCount;
+ ficheArray = group.ficheArray;
+ } else {
+ if (this.ficheGroupArray.length === 0) {
+ return true;
+ }
+ ficheCount = this.getFicheCount();
+ ficheArray = this.ficheGroupArray[0].ficheArray;
}
- var ficheArray = this.ficheGroupArray[0].ficheArray;
- var startIndex = paginationLength * (paginationNumber - 1);
- var length = ficheArray.length;
- if (startIndex >= length) {
- return selectionArray;
- }
- var min = Math.min(ficheArray.length, startIndex + paginationLength);
- for(let i = startIndex; i < min; i++) {
- selectionArray.push(ficheArray[i]);
- }
- return selectionArray;
-};
-Scrutari.Result.prototype.isUniquePaginationLoaded = function (paginationLength, paginationNumber) {
- if (this.ficheGroupArray.length === 0) {
- return true;
- }
- var ficheCount = this.getFicheCount();
- var ficheArray = this.ficheGroupArray[0].ficheArray;
var length = ficheArray.length;
if (length === ficheCount) {
return true;
@@ -912,134 +923,81 @@ Scrutari.Result.prototype.isUniquePaginationLoaded = function (paginationLength,
}
return false;
};
-Scrutari.Result.prototype.loadUniquePagination = function (scrutariConfig, paginationLength, paginationNumber, callback) {
- if (this.ficheGroupArray.length === 0) {
- return true;
+Scrutari.Result.prototype.loadPagination = function (scrutariConfig, paginationLength, paginationNumber, ficheGroupName, callback) {
+ var group;
+ var ficheCount;
+ var ficheArray;
+ var isWithGroup;
+ if (ficheGroupName) {
+ group = this.getFicheGroup(ficheGroupName);
+ if (!group) {
+ return true;
+ }
+ ficheCount = group.ficheCount;
+ ficheArray = group.ficheArray;
+ isWithGroup = true;
+ } else {
+ if (this.ficheGroupArray.length === 0) {
+ return true;
+ }
+ group = this.ficheGroupArray[0];
+ ficheCount = this.getFicheCount();
+ isWithGroup = false;
}
- var group = this.ficheGroupArray[0];
- if (!group) {
- return;
- }
- var ficheCount = this.getFicheCount();
- var ficheArray = group.ficheArray;
var length = ficheArray.length;
if (length === ficheCount) {
return;
}
- var _existingFicheSearchResultCallback = function (ficheSearchResult) {
- var newCount = ficheSearchResult.ficheGroupArray.length;
- if (newCount > 0) {
- group.ficheArray = group.ficheArray.concat(ficheSearchResult.ficheGroupArray[0].ficheArray);
- }
- if (callback) {
- callback();
- }
- };
var requestParameters = {
qid: this.getQId(),
start: length +1,
limit: (paginationLength * (paginationNumber + 2)) - length
};
- Scrutari.Ajax.loadExistingFicheSearchResult(scrutariConfig, requestParameters, _existingFicheSearchResultCallback);
-};
-Scrutari.Result.prototype.isCategoryPaginationLoaded = function (categoryName, paginationLength, paginationNumber) {
- var group = this.getFicheGroupByCategoryName(categoryName);
- if (!group) {
- return true;
+ if (isWithGroup) {
+ requestParameters.starttype = "in:" + ficheGroupName;
}
- var categoryFicheCount = group.ficheCount;
- var ficheArray = group.ficheArray;
- var length = ficheArray.length;
- if (length === categoryFicheCount) {
- return true;
- }
- var endIndex = (paginationLength * paginationNumber) - 1;
- if (endIndex < length) {
- return true;
- }
- return false;
-};
-Scrutari.Result.prototype.loadCategoryPagination = function (scrutariConfig, categoryName, paginationLength, paginationNumber, callback) {
- var group = this.getFicheGroupByCategoryName(categoryName);
- if (!group) {
- return;
- }
- var categoryFicheCount = group.ficheCount;
- var ficheArray = group.ficheArray;
- var length = ficheArray.length;
- if (length === categoryFicheCount) {
- return;
- }
- var requestParameters = {
- qid: this.getQId(),
- start: length +1,
- limit: (paginationLength * (paginationNumber + 2)) - length,
- starttype: "in:" + categoryName
- };
- Scrutari.Ajax.loadExistingFicheSearchResult(scrutariConfig, requestParameters, _existingFicheSearchResultCallback);
- function _existingFicheSearchResultCallback(ficheSearchResult) {
- for(let newGroup of ficheSearchResult.ficheGroupArray) {
- if (newGroup.category.name === group.category.name) {
- group.ficheArray = group.ficheArray.concat(newGroup.ficheArray);
+ Scrutari.Ajax.loadExistingFicheSearchResult(scrutariConfig, requestParameters, function (ficheSearchResult) {
+ if (isWithGroup) {
+ for(let newGroup of ficheSearchResult.ficheGroupArray) {
+ if (newGroup.category.name === group.category.name) {
+ group.ficheArray = group.ficheArray.concat(newGroup.ficheArray);
+ }
+ }
+ } else {
+ var newCount = ficheSearchResult.ficheGroupArray.length;
+ if (newCount > 0) {
+ group.ficheArray = group.ficheArray.concat(ficheSearchResult.ficheGroupArray[0].ficheArray);
}
}
- callback();
+ if (callback) {
+ callback();
+ }
+ });
+};
+Scrutari.Result.prototype.extractFicheArray = function (paginationLength, paginationNumber, ficheGroupName) {
+ var ficheArray;
+ if (ficheGroupName) {
+ let group = this.getFicheGroup(ficheGroupName);
+ if (!group) {
+ return new Array();
+ }
+ ficheArray = group.ficheArray;
+ } else {
+ if (this.ficheGroupArray.length === 0) {
+ return new Array();
+ }
+ ficheArray = this.ficheGroupArray[0].ficheArray;
}
+ return Scrutari.Utils.extractFicheArray(ficheArray, paginationLength, paginationNumber);
};
-Scrutari.Result.prototype.selectCategoryFicheArray = function (categoryName, paginationLength, paginationNumber) {
- var selectionArray = new Array();
- var ficheArray = this.getCategoryFicheArrayByName(categoryName);
- var startIndex = paginationLength * (paginationNumber - 1);
- var length = ficheArray.length;
- if (startIndex >= length) {
- return selectionArray;
- }
- var min = Math.min(ficheArray.length, startIndex + paginationLength);
- for(let i = startIndex; i < min; i++) {
- selectionArray.push(ficheArray[i]);
- }
- return selectionArray;
-};
-Scrutari.Result.prototype.getCategoryCount = function () {
- return this.ficheGroupArray.length;
-};
-Scrutari.Result.prototype.getCategory = function (index) {
- return this.ficheGroupArray[index].category;
-};
-Scrutari.Result.prototype.getFicheGroupByCategoryName = function (categoryName) {
- var groupCount = this.ficheGroupArray.length;
- for(let i = 0; i < groupCount; i++) {
- let group = this.ficheGroupArray[i];
- if ((group.category) && (group.category.name === categoryName)) {
- return group;
+Scrutari.Result.prototype.getFicheGroup = function (ficheGroupName) {
+ for(let ficheGroup of this.ficheGroupArray) {
+ if ((ficheGroup.category) && (ficheGroup.category.name === ficheGroupName)) {
+ return ficheGroup;
}
}
return null;
};
-Scrutari.Result.prototype.getCategoryFicheCount = function (index) {
- return this.ficheGroupArray[index].ficheCount;
-};
-Scrutari.Result.prototype.getCategoryFicheCountByName = function (categoryName) {
- for(let group of this.ficheGroupArray) {
- if ((group.category) && (group.category.name === categoryName)) {
- return group.ficheCount;
- }
- }
- return 0;
-};
-Scrutari.Result.prototype.getCategoryFicheArray = function (index) {
- return this.ficheGroupArray[index].ficheArray;
-};
-Scrutari.Result.prototype.getCategoryFicheArrayByName = function (categoryName) {
- var categoryCount = this.getCategoryCount();
- for(let i = 0; i < categoryCount; i++) {
- let category = this.getCategory(i);
- if (category.name === categoryName) {
- return this.getCategoryFicheArray(i);
- }
- }
- return new Array();
-};
Scrutari.Result.prototype.getMotcle = function (code) {
var key = "code_" + code;
if (this.motcleMap.hasOwnProperty(key)) {
@@ -1562,6 +1520,37 @@ Scrutari.Utils.checkKey = function (type, value) {
}
return value;
};
+Scrutari.Utils.hasFilter = function (requestParameters) {
+ for(let prop in requestParameters) {
+ switch(prop) {
+ case "baselist":
+ case "corpuslist":
+ case "categorylist":
+ case "langlist":
+ var value = requestParameters[prop];
+ if (value) {
+ return true;
+ }
+ }
+ if (prop.indexOf("flt") === 0) {
+ return true;
+ }
+ }
+ return false;
+};
+Scrutari.Utils.extractFicheArray = function (ficheArray, paginationLength, paginationNumber) {
+ var startIndex = paginationLength * (paginationNumber - 1);
+ var length = ficheArray.length;
+ var extractArray = new Array();
+ if (startIndex >= length) {
+ return extractArray;
+ }
+ var min = Math.min(ficheArray.length, startIndex + paginationLength);
+ for(let i = startIndex; i < min; i++) {
+ extractArray.push(ficheArray[i]);
+ }
+ return extractArray;
+};
Scrutari.Loc = function (map) {
if (map) {
this.map = map;
@@ -1719,14 +1708,101 @@ Scrutari.Stats.Unit.prototype.check = function (filterState) {
}
return this.value;
};
+Scrutari.History = function (client) {
+ this.client = client;
+ this.currentScrutariResult = null;
+ this.mainCurrentScrutariResult = null;
+ this._historyNumber = 0;
+ this._scrutariResultMap = new Map();
+};
+Scrutari.History.prototype.setCurrentResult = function (scrutariResult, searchOrigin) {
+ var history = this;
+ var client = this.client;
+ this.currentScrutariResult = scrutariResult;
+ if (searchOrigin === "mainsearch") {
+ history.mainCurrentScrutariResult = scrutariResult;
+ _addToHistory();
+ } else if (searchOrigin === "subsearch") {
+ let subsearchText = "+ " + Scrutari.Utils.formatSearchSequence(client, scrutariResult) + " = " + scrutariResult.getFicheCount();
+ if (history.currentHistoryName) {
+ client.$component(client.$block(history.currentHistoryName), "subsearch").text(subsearchText);
+ }
+ }
+ function _addToHistory () {
+ let $historyListBlock = client.$block("historyList");
+ if (!Scrutari.exists($historyListBlock)) {
+ return;
+ }
+ if (history.currentHistoryName) {
+ var $historyBlock = client.$block(history.currentHistoryName);
+ $historyBlock.removeClass(client.cssClasses.activeHistory);
+ client.$component($historyBlock, "subsearch").empty();
+ }
+ let historyName = "history_" + history.newHistoryNumber();
+ history.updateCurrent(historyName);
+ history.storeResult(historyName, scrutariResult);
+ let contextObj = {
+ scrutariResult: scrutariResult,
+ name: historyName,
+ fichestat: scrutariResult.getFicheCount(),
+ sequence: Scrutari.Utils.formatSearchSequence(client, scrutariResult)
+ };
+ $historyListBlock.prepend(client.render("history", contextObj));
+ }
+};
+Scrutari.History.prototype.removeHistory = function (historyName) {
+ this.unstoreResult(historyName);
+ this.client.$block(historyName).remove();
+};
+Scrutari.History.prototype.loadHistory = function (historyName) {
+ var history = this;
+ var client = this.client;
+ var historyScrutariResult = history.getResult(historyName);
+ if (historyScrutariResult) {
+ let $historyBlock = client.$block(historyName);
+ history.currentScrutariResult = historyScrutariResult;
+ history.mainCurrentScrutariResult = historyScrutariResult;
+ history.updateCurrent(historyName);
+ $historyBlock.addClass(client.cssClasses.activeHistory);
+ client.processResult(historyScrutariResult);
+ if (client.functions.mainsearchResultCallback) {
+ client.functions.mainsearchResultCallback(client, historyScrutariResult);
+ }
+ }
+};
+Scrutari.History.prototype.updateCurrent = function (historyName) {
+ var client = this.client;
+ if (this.currentHistoryName) {
+ let $historyBlock = client.$block(this.currentHistoryName);
+ $historyBlock.removeClass(client.cssClasses.activeHistory);
+ client.$component($historyBlock, "subsearch").empty();
+ }
+ this.currentHistoryName = historyName;
+};
+Scrutari.History.prototype.newHistoryNumber = function () {
+ this._historyNumber++;
+ return this._historyNumber;
+};
+Scrutari.History.prototype.storeResult = function (historyName, scrutariResult) {
+ this._scrutariResultMap.set(historyName, scrutariResult);
+};
+Scrutari.History.prototype.unstoreResult = function (historyName) {
+ this._scrutariResultMap.delete(historyName);
+};
+Scrutari.History.prototype.getResult = function (historyName) {
+ return this._scrutariResultMap.get(historyName);
+};
+Scrutari.History.prototype.clear = function () {
+ this._scrutariResultMap.clear();
+ this.client.$block("historyList").empty();
+};
Scrutari.Client = function (scrutariConfig, clientId) {
this.scrutariConfig = scrutariConfig;
this.clientId = clientId;
+ this.history = new Scrutari.History(this);
this.scrutariMeta = null;
this.stats = null;
this.isWaiting = false;
- this.mainCurrentScrutariResult = null;
- this.currentScrutariResult = null;
this.options = {
withCorpus: false,
baseSort: "fiche-count",
@@ -1742,7 +1818,36 @@ Scrutari.Client = function (scrutariConfig, clientId) {
ignoreThumbnail: false,
ficheBodyList: null,
mainTitle: null,
- hooks: {}
+ hooks: {},
+ functions: {
+ uiInit: null
+ },
+ cssClasses: {
+ }
+ };
+ this.functions = {
+ ignoreElement: Scrutari.DefaultUi.ignoreElement,
+ isFilterEnable: Scrutari.DefaultUi.isFilterEnable,
+ mainsearchResultCallback: Scrutari.DefaultUi.mainsearchResultCallback,
+ mainsearchErrorCallback: null,
+ subsearchResultCallback: Scrutari.DefaultUi.subsearchResultCallback,
+ subsearchErrorCallback: null,
+ initFilterByQuery: Scrutari.DefaultUi.initFilterByQuery,
+ displayError: Scrutari.DefaultUi.displayError,
+ modalAction: null,
+ newResultProcess: Scrutari.DefaultUi.newResultProcess
+ };
+ this.cssClasses = {
+ disabled: "scrutari-Disabled",
+ hidden: "scrutari-Hidden",
+ mark: "scrutari-Mark",
+ on: "scrutari-On",
+ activeHistory: "scrutari-history-Active",
+ activePanel: "scrutari-panel-Active",
+ excludedPanel: "scrutari-panel-Excluded",
+ filterStat: "scrutari-stats-Filter",
+ noneStat: "scrutari-stats-None",
+ disabledPanelColumn: "scrutari-panel-ColumnDisabled"
};
this._locInstance = new Scrutari.Loc();
this._ignoreArray = new Array();
@@ -1756,11 +1861,9 @@ Scrutari.Client = function (scrutariConfig, clientId) {
"fiche_motclearray",
"fiche_bythesaurusarray"
];
- this._structureMap = {};
- this._templateMap = {};
- this._scrutariResultMap = {};
- this._historyNumber = 0;
- this.functions = {};
+ this._structureMap = new Map();
+ this._templateMap = new Map();
+ this._paginationMap = new Map();
if (typeof SCRUTARI_L10N !== 'undefined') {
this._locInstance.putAll(SCRUTARI_L10N);
}
@@ -1780,25 +1883,27 @@ Scrutari.Client.prototype.toPermalink = function (qId) {
}
return null;
};
-Scrutari.Client.prototype.storeResult = function (historyName, scrutariResult) {
- this._scrutariResultMap[historyName] = scrutariResult;
-};
-Scrutari.Client.prototype.unstoreResult = function (historyName) {
- this._scrutariResultMap[historyName] = null;
-};
-Scrutari.Client.prototype.getResult = function (historyName) {
- if (this._scrutariResultMap.hasOwnProperty(historyName)) {
- return this._scrutariResultMap[historyName];
- } else {
- return null;
- }
-};
-Scrutari.Client.prototype.newHistoryNumber = function () {
- this._historyNumber++;
- return this._historyNumber;
-};
Scrutari.Client.prototype.ignoreElement = function (elementName) {
- return $.inArray(elementName, this._ignoreArray) > -1;
+ for(let ignorable of this._ignoreArray) {
+ if (ignorable.mode === "start") {
+ if (elementName.startsWith(ignorable.token)) {
+ return true;
+ }
+ } else {
+ if (elementName === ignorable.token) {
+ return true;
+ }
+ }
+ }
+ if (this._ignoreArray.indexOf(elementName) > -1) {
+ return true;
+ }
+ if (this.functions.ignoreElement) {
+ if (this.functions.ignoreElement(elementName)) {
+ return true;
+ }
+ }
+ return false;
};
Scrutari.Client.prototype.getTemplate = function (templateName) {
var template = this.hook("getTemplate", templateName);
@@ -1857,7 +1962,7 @@ Scrutari.Client.prototype.$area = function (name, action) {
if (action) {
switch(action) {
case 'show':
- this.show ($area);
+ this.show($area);
break;
case 'hide':
this.hide($area);
@@ -1866,17 +1971,14 @@ Scrutari.Client.prototype.$area = function (name, action) {
}
return $area;
};
-Scrutari.Client.prototype.$block = function (name, action) {
- var $block = this.$({scrutariBlock: name});
- if (action) {
- switch(action) {
- case 'show':
- this.show ($block);
- break;
- case 'hide':
- this.hide($block);
- break;
- }
+Scrutari.Client.prototype.$block = function (name, suffix) {
+ var $block;
+ if (suffix === '*') {
+ $block = this.$({"scrutariBlock|": name});
+ } else if (suffix) {
+ $block = this.$({scrutariBlock: name + "-" + suffix});
+ } else {
+ $block = this.$({scrutariBlock: name});
}
return $block;
};
@@ -1887,6 +1989,9 @@ Scrutari.Client.prototype.$button = function (name, target) {
return this.$({scrutariButton: name});
}
};
+Scrutari.Client.prototype.$component = function ($parent, name) {
+ return Scrutari.$($parent, {scrutariComponent: name});
+};
Scrutari.Client.prototype.$count = function (name, action, value) {
var $count = this.$({scrutariCount: name});
if (action) {
@@ -1895,7 +2000,7 @@ Scrutari.Client.prototype.$count = function (name, action, value) {
if (!value) {
value = 0;
}
- Scrutari.$($count, {scrutariRole: "value"}).html(this.formatNumber(value));
+ this.$component($count, "value").html(this.formatNumber(value));
break;
}
}
@@ -1943,7 +2048,7 @@ Scrutari.Client.prototype.$link = function (name) {
};
Scrutari.Client.prototype.$modal = function (name, action) {
var $modal = this.$({scrutariModal: name});
- if ((action) && (this.functions.hasOwnProperty("modalAction"))) {
+ if ((action) && (this.functions.modalAction)) {
this.functions.modalAction($modal, action);
}
return $modal;
@@ -1962,34 +2067,20 @@ Scrutari.Client.prototype.$panel = function (name, action) {
}
return $panel;
};
-Scrutari.Client.prototype.$title = function (name, action) {
- var $title = this.$({scrutariTitle: name});
- if (action) {
- switch(action) {
- case 'show':
- this.show ($title);
- break;
- case 'hide':
- this.hide($title);
- break;
- }
- }
- return $title;
-};
Scrutari.Client.prototype.show = function (jqArgument) {
var $elements = Scrutari.convert(jqArgument);
- $elements.removeClass("scrutari-Hidden");
+ $elements.removeClass(this.cssClasses.hidden);
};
Scrutari.Client.prototype.hide = function (jqArgument) {
var $elements = Scrutari.convert(jqArgument);
- $elements.addClass("scrutari-Hidden");
+ $elements.addClass(this.cssClasses.hidden);
};
Scrutari.Client.prototype.scrollToResult = function () {
$(window).scrollTop(this.$area('result').offset().top);
};
Scrutari.Client.prototype.getStructureHtml = function (name) {
- if (this._structureMap.hasOwnProperty(name)) {
- return this._structureMap[name];
+ if (this._structureMap.has(name)) {
+ return this._structureMap.get(name);
} else {
Scrutari.log("Unknown structure: " + name);
return "";
@@ -1997,14 +2088,330 @@ Scrutari.Client.prototype.getStructureHtml = function (name) {
};
Scrutari.Client.prototype.getStructureNameArray = function () {
var result = new Array();
- for(let prop in this._structureMap) {
- result.push(prop);
+ for(let key of this._structureMap.keys()) {
+ result.push(key);
}
return result;
};
+Scrutari.Client.prototype.compileStructure = function (name, options) {
+ var client = this;
+ var includedTexts = new Map();
+ var noLoc = false;
+ var withIndent = false;
+ var withPath = false;
+ if (options) {
+ noLoc = options.noLoc;
+ withIndent = options.withIndent;
+ withPath = options.withPath;
+ }
+ var html = _getText(name, "", "");
+ if (!noLoc) {
+ html = html.replace(/_ [-_\.a-z0-9]+/g, function(match) {
+ return client.loc(match);
+ });
+ }
+ return html;
+ function _getText(name, path, indent) {
+ let currentPath = (path)?path + "." + name:name;
+ if (name.endsWith('*')) {
+ return _getTextByPrefix(name.substring(0, name.length - 1), currentPath, indent);
+ }
+ if (includedTexts.has(name)) {
+ Scrutari.log("Already included: " + name);
+ return "";
+ } else if (client.ignoreElement(name)) {
+ return "";
+ }
+ includedTexts.set(name, true);
+ var text = client.getStructureHtml(name);
+ text = text.replace(/([ \t]*){{([-a-zA-z0-9_]+\*?)}}[\n]?/g, function (match, p1, p2) {
+ return _getText(p2, currentPath, p1);
+ });
+ if ((text.length > 0) && (!text.endsWith("\n"))) {
+ text = text + "\n";
+ }
+ if (withPath) {
+ text = "\n" + text + "\n";
+ }
+ if (withIndent) {
+ let lines = text.split(/\n/);
+ let newText = "";
+ let next = false;
+ for(let line of lines) {
+ if (next) {
+ newText += "\n";
+ } else {
+ next = true;
+ }
+ if (line.length > 0) {
+ newText = newText + indent + line;
+ }
+ }
+ text = newText;
+ }
+ return text;
+ }
+ function _getTextByPrefix(namePrefix, path, indent) {
+ let result = "";
+ for(let name of client.getStructureNameArray()) {
+ if (name.startsWith(namePrefix)) {
+ result = result + _getText(name, path, indent);
+ }
+ }
+ return result;
+ }
+};
+Scrutari.Client.prototype.initForms = function () {
+ var client = this;
+ client.$form('mainsearch').submit(function () {
+ let q = this["q"].value.trim();
+ if (q.length > 0) {
+ let requestParameters = client.buildRequestParameters();
+ requestParameters["log"] = "all";
+ requestParameters["q"] = q;
+ client.$modal("loading", 'show');
+ client.hook("newSearch", requestParameters, "mainsearch");
+ Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, function (scrutariResult) {client.mainsearchResultCallback(scrutariResult);}, function (error) {client.mainsearchErrorCallback(error);});
+ }
+ return false;
+ });
+ client.$form('subsearch').submit(function () {
+ let q = this["q"].value.trim();
+ if ((q.length > 0) && (client.history.mainCurrentScrutariResult)) {
+ let requestParameters = client.buildRequestParameters();
+ requestParameters["q"] = q;
+ requestParameters["flt-qid"] = client.history.mainCurrentScrutariResult.getQId();
+ client.$modal("loading", 'show');
+ client.hook("newSearch", requestParameters, "subsearch");
+ Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, function (scrutariResult) {client.subsearchResultCallback(scrutariResult);}, function (error) {client.subsearchErrorCallback(error);});
+ }
+ return false;
+ });
+};
+Scrutari.Client.prototype.initButtons = function (actionHandler) {
+ var client = this;
+ if (!actionHandler) {
+ actionHandler = _noneHandler;
+ }
+ $("#" + client.clientId).on("click", Scrutari.toCssQuery({scrutariButton: true}), function () {
+ let button = this;
+ let action = this.dataset.scrutariButton;
+ let target = this.dataset.scrutariTarget;
+ let done = actionHandler(client, button, action, target);
+ if (!done) {
+ switch(action) {
+ case 'showModal':
+ client.$modal(target, 'show');
+ break;
+ case 'removeHistory':
+ client.history.removeHistory(target);
+ break;
+ case 'loadHistory':
+ client.history.loadHistory(target);
+ break;
+ case 'clearHistory':
+ client.history.clear();
+ break;
+ case 'toggleBlock':
+ if (Scrutari.Utils.toggle($(button), "scrutariState") === 'on') {
+ client.show(client.$block(target));
+ } else {
+ client.hide(client.$block(target));
+ }
+ break;
+ case 'ficheGroupTab':
+ _ficheGroupTab(target);
+ break;
+ case 'paginationTab':
+ _paginationTab(button);
+ break;
+ default:
+ Scrutari.log("Unknown action: " + action);
+ }
+ }
+ if ((this.tagName) && (this.tagName.toLowerCase() === 'a')) {
+ return false;
+ }
+ });
+ function _noneHandler() {
+ return false;
+ }
+ function _ficheGroupTab (target) {
+ let activeBlockName = "ficheGroup" + "-" + target;
+ client.$block("ficheGroup", "*").each(function (index, element) {
+ if (element.dataset.scrutariBlock === activeBlockName) {
+ client.show(element);
+ } else {
+ client.hide(element);
+ }
+ });
+ client.$button("ficheGroupTab").each(function (index, element) {
+ let onClass = client.cssClasses.on;
+ if (element.dataset.scrutariTarget === target) {
+ element.classList.add(onClass);
+ } else {
+ element.classList.remove(onClass);
+ }
+ });
+ }
+ function _paginationTab (button) {
+ let newPaginationNumber = parseInt(button.dataset.scrutariNumber);
+ let pagination = client.getPagination(button.dataset.scrutariFicheGroupName);
+ if (pagination) {
+ pagination.change(newPaginationNumber);
+ if (button.dataset.scrutariPosition === "bottom") {
+ client.scrollToResult();
+ }
+ }
+ }
+};
+Scrutari.Client.prototype.initChangeListeners = function (changeHandler) {
+ var client = this;
+ if (!changeHandler) {
+ changeHandler = _noneHandler;
+ }
+ $("#" + client.clientId).on("input", "input", function () {
+ let element = this;
+ let name = this.name;
+ if (name) {
+ let done = changeHandler(client, element, name);
+ if (!done) {
+ switch(name) {
+ case 'q-mode':
+ if (this.value === 'operation') {
+ Scrutari.Utils.disable("input[name='wildchar']");
+ } else {
+ Scrutari.Utils.enable("input[name='wildchar']");
+ }
+ break;
+ }
+ }
+ }
+ });
+ function _noneHandler() {
+ return false;
+ }
+};
+Scrutari.Client.prototype.mainsearchResultCallback = function (scrutariResult) {
+ var client = this;
+ client.processResult(scrutariResult, "mainsearch");
+ client.$modal("loading", 'hide');
+ if (client.functions.mainsearchResultCallback) {
+ client.functions.mainsearchResultCallback(client, scrutariResult);
+ }
+};
+Scrutari.Client.prototype.mainsearchErrorCallback = function (error) {
+ var client = this;
+ if (client.functions.displayError) {
+ client.functions.displayError(client, error, "mainsearch");
+ }
+ client.$modal("loading", 'hide');
+ if (client.functions.mainsearchErrorCallback) {
+ client.functions.mainsearchErrorCallback(client, error);
+ }
+};
+Scrutari.Client.prototype.subsearchResultCallback = function (scrutariResult) {
+ var client = this;
+ client.processResult(scrutariResult, "subsearch");
+ client.$modal("loading", 'hide');
+ if (client.functions.subsearchResultCallback) {
+ client.functions.subsearchResultCallback(client, scrutariResult);
+ }
+};
+Scrutari.Client.prototype.subsearchErrorCallback = function (error) {
+ var client = this;
+ if (client.functions.displayError) {
+ client.functions.displayError(client, error, "subsearch");
+ }
+ client.$modal("loading", 'hide');
+ if (client.functions.subsearchErrorCallback) {
+ client.functions.subsearchErrorCallback(client, error);
+ }
+};
+Scrutari.Client.prototype.checkInitialQuery = function () {
+ var client = this;
+ var initialQuery = client.options.initialQuery;
+ var initialQId = client.options.initialQId;
+ if (initialQuery) {
+ var $mainSearchForm = client.$form('mainsearch');
+ if (Scrutari.exists($mainSearchForm)) {
+ $mainSearchForm.find("input[name='q']").val(initialQuery);
+ $mainSearchForm.submit();
+ }
+ } else if (initialQId) {
+ var requestParameters = client.buildRequestParameters();
+ requestParameters["qid"] = initialQId;
+ client.$modal("loading", 'show');
+ client.hook("newSearch", requestParameters, "qidsearch");
+ Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, function (scrutariResult) {
+ var $mainSearchForm = client.$form('mainsearch');
+ $mainSearchForm.find("input[name='q']").val(scrutariResult.searchMeta.q);
+ $mainSearchForm.find("input[name='q-mode'][value='operation']").click();
+ if (client.functions.initFilterByQuery) {
+ client.functions.initFilterByQuery(client, scrutariResult);
+ }
+ client.mainsearchResultCallback(scrutariResult);
+ }, function (error) {client.mainsearchErrorCallback(error);});
+ }
+};
+Scrutari.Client.prototype.buildRequestParameters = function () {
+ var client = this;
+ var requestParameters = new Object();
+ _checkFilter("baselist", "base");
+ _checkFilter("corpuslist", "corpus");
+ _checkFilter("categorylist", "category");
+ _checkFilter("langlist", "lang");
+ requestParameters["q-mode"] = client.$input_checked("q-mode").val();
+ var ponderation = client.$input_checked("ponderation").val();
+ if (ponderation === 'date') {
+ requestParameters.ponderation = '10,80,5,5';
+ }
+ var periode = $.trim(client.$input("periode").val());
+ if (periode) {
+ requestParameters["flt-date"] = periode;
+ }
+ if (Scrutari.exists(client.$input_checked("wildchar", "end"))) {
+ requestParameters.wildchar = "end";
+ } else {
+ requestParameters.wildchar = "none";
+ }
+ return requestParameters;
+ function _checkFilter (paramName, target) {
+ if ((client.functions.isFilterEnable) && (client.functions.isFilterEnable(client, target))) {
+ var $inputs = client.$input_checked(target);
+ var value = "";
+ for(var i = 0; i < $inputs.length; i++) {
+ if (i > 0) {
+ value += ",";
+ }
+ value += $inputs[i].value;
+ }
+ if (value.length > 0) {
+ requestParameters[paramName] = value;
+ }
+ }
+ }
+};
+Scrutari.Client.prototype.buildFilterState = function () {
+ var client = this;
+ var filterState = new Scrutari.FilterState();
+ _check("base");
+ _check("corpus");
+ _check("category");
+ _check("lang");
+ return filterState;
+ function _check (target) {
+ if (!((client.functions.isFilterEnable) && (client.functions.isFilterEnable(client, target)))) {
+ return;
+ }
+ client.$input_checked(target).each(function (index,element) {
+ filterState.add(target, element.value, element.dataset.scrutariTitle);
+ });
+ }
+};
Scrutari.Client.prototype.getTemplateHtml = function (name) {
- if (this._templateMap.hasOwnProperty(name)) {
- return this._templateMap[name];
+ if (this._templateMap.has(name)) {
+ return this._templateMap.get(name);
} else {
Scrutari.log("Unknown template: " + name);
return "";
@@ -2017,34 +2424,81 @@ Scrutari.Client.prototype.formatNumber = function (number) {
return number;
}
};
+Scrutari.Client.prototype.completeFiche = function(scrutariResult, fiche, categoryName) {
+ if (fiche._isCompleted) {
+ return fiche;
+ }
+ var client = this;
+ var scrutariMeta = client.scrutariMeta;
+ var options = client.options;
+ Scrutari.Complete.complementTitle(fiche, scrutariMeta);
+ Scrutari.Complete.motcleArray(fiche, _motcleProvider);
+ Scrutari.Complete.bythesaurusArray(fiche, scrutariMeta, _motcleProvider);
+ if (Scrutari.Complete.hasMarkedAttribute(fiche)) {
+ Scrutari.Complete.markedAttributeArray(fiche, scrutariMeta, "primary");
+ Scrutari.Complete.markedAttributeArray(fiche, scrutariMeta, "secondary");
+ }
+ if (!options.ignoreThumbnail) {
+ Scrutari.Complete.thumbnail(fiche);
+ }
+ if (!options.ignoreIcon) {
+ Scrutari.Complete.icon(fiche);
+ }
+ if (options.ficheTarget) {
+ Scrutari.Complete.target(fiche, options.ficheTarget);
+ }
+ fiche._bodyTemplateArray = client.getFicheBodyTemplateArray(fiche, categoryName);
+ fiche._isCompleted = true;
+ client.hook("completeFiche", scrutariResult, fiche, categoryName);
+ return fiche;
+ function _motcleProvider(code) {
+ return scrutariResult.getMotcle(code);
+ }
+};
+Scrutari.Client.prototype.getPagination = function (ficheGroupName) {
+ if (!ficheGroupName) {
+ ficheGroupName = "";
+ }
+ return this._paginationMap.get(ficheGroupName);
+};
+Scrutari.Client.prototype.putPagination = function (ficheGroupName, pagination) {
+ if (!ficheGroupName) {
+ ficheGroupName = "";
+ }
+ this._paginationMap.set(ficheGroupName, pagination);
+};
+Scrutari.Client.prototype.clearPagination = function () {
+ this._paginationMap.clear();
+};
+Scrutari.Client.prototype.processResult = function (scrutariResult, searchOrigin) {
+ var client = this;
+ var resultProcess;
+ if (client.functions.newResultProcess) {
+ resultProcess = client.functions.newResultProcess(client, scrutariResult, searchOrigin);
+ }
+ if (!resultProcess) {
+ resultProcess = new Scrutari.Process(client, scrutariResult, searchOrigin);
+ }
+ resultProcess.run();
+};
Scrutari.Client.init = function (scrutariConfig, clientId, options, callback) {
if (!$.templates) {
throw new Error("JsRender is not installed");
}
- $.views.helpers("scrutari_mark", function(markArray) {
- return Scrutari.Utils.mark(markArray);
- });
+ var uiInitFunction = Scrutari.DefaultUi.init;
Scrutari.Meta.load(scrutariConfig, function (scrutariMeta) {
var client = new Scrutari.Client(scrutariConfig, clientId);
- $.views.helpers({
- scrutari_client: client,
- scrutari_loc: function(key, ...values) {
- return client.loc(key, values);
- },
- scrutari_format: function(number) {
- return client.formatNumber(number);
- }
- });
client.scrutariMeta = scrutariMeta;
client.stats = new Scrutari.Stats(scrutariMeta);
- _checkOptions(client, options, scrutariMeta);
+ _checkOptions(client, scrutariMeta);
+ _initHelpers(client);
_initMaps(client);
- Scrutari.Client.Ui.init(client);
+ uiInitFunction(client);
if (callback) {
callback(client);
}
});
- function _checkOptions (client, options, scrutariMeta) {
+ function _checkOptions (client, scrutariMeta) {
var defaultOptions = scrutariMeta.getDefaultOptions();
for(let key in defaultOptions) {
client.options[key] = defaultOptions[key];
@@ -2053,6 +2507,22 @@ Scrutari.Client.init = function (scrutariConfig, clientId, options, callback) {
for(let key in options) {
client.options[key] = options[key];
}
+ if (options.functions) {
+ for(let functionKey in options.functions) {
+ switch(functionKey) {
+ case "uiInit":
+ uiInitFunction = options.functions[functionKey];
+ break;
+ default:
+ client.functions[functionKey] = options.functions[functionKey];
+ }
+ }
+ }
+ if (options.cssClasses) {
+ for(let cssKey in options.cssClasses) {
+ client.cssClasses[cssKey] = options.cssClasses[cssKey];
+ }
+ }
if (options.locMap) {
client._locInstance.putAll(options.locMap);
}
@@ -2066,7 +2536,12 @@ Scrutari.Client.init = function (scrutariConfig, clientId, options, callback) {
}
if (ignoreArray) {
for(let ignore of ignoreArray) {
- client._ignoreArray.push(ignore.trim());
+ let token = ignore.trim();
+ if (token.endsWith('*')) {
+ client._ignoreArray.push({token: token.substring(0, token.length - 1), mode:"start"})
+ } else {
+ client._ignoreArray.push({token: token, mode:"equal"})
+ }
}
}
}
@@ -2093,452 +2568,267 @@ Scrutari.Client.init = function (scrutariConfig, clientId, options, callback) {
}
}
}
- function _initHtmlObject (client, htmlObject) {
- if (htmlObject) {
- if (htmlObject.structure) {
- for(var key in htmlObject.structure) {
- client._structureMap[key] = htmlObject.structure[key];
- }
+ function _initHelpers (client) {
+ $.views.helpers({
+ scrutari_client: client,
+ scrutari_loc: function(key, ...values) {
+ return client.loc(key, values);
+ },
+ scrutari_format: function(number) {
+ return client.formatNumber(number);
+ },
+ scrutari_mark: function (markArray) {
+ return Scrutari.Utils.mark(markArray, client.cssClasses.mark);
}
- if (htmlObject.templates) {
- for(var key in htmlObject.templates) {
- client._templateMap[key] = htmlObject.templates[key];
- }
- }
- }
+ });
}
function _initMaps (client) {
- _initHtmlObject(client, client._htmlObject);
- _initHtmlObject(client, options.htmlObject);
+ __initHtmlObject(client._htmlObject);
+ __initHtmlObject(options.htmlObject);
$("script[type='text/x-scrutari-structure']").each(function (index, element) {
- client._structureMap[element.dataset.name] = $(element).html();
+ client._structureMap.set(element.dataset.name, $(element).html());
});
$("script[type='text/x-scrutari-template']").each(function (index, element) {
- client._templateMap[element.dataset.name] = $(element).html();
+ client._templateMap.set(element.dataset.name, $(element).html());
});
- for(var name in client._templateMap) {
- var templateText = client._templateMap[name];
+ for(let entries of client._templateMap.entries()) {
+ let templateText = entries[1];
templateText = templateText.replace(/tmpl=\"([-_0-9a-z]+)\"/g, 'tmpl="scrutari:$1"');
- $.templates("scrutari:" + name, templateText);
+ $.templates("scrutari:" + entries[0], templateText);
}
- }
-};
-Scrutari.Client.Result = {};
-Scrutari.Client.Result.show = function (client, scrutariResult, searchOrigin) {
- client.$hidden("start", 'show');
- var ficheCount = scrutariResult.getFicheCount();
- client.$count("stats-result", 'update', ficheCount);
- var $ficheDisplayBlock = client.$block('ficheDisplay');
- $ficheDisplayBlock.empty();
- client.currentScrutariResult = scrutariResult;
- if (searchOrigin === "mainsearch") {
- Scrutari.Client.Result.setCurrentMain(client, scrutariResult);
- Scrutari.Client.Result.addToHistory(client, scrutariResult);
- } else if (searchOrigin === "subsearch") {
- let subsearchText = "+ " + Scrutari.Utils.formatSearchSequence(client, scrutariResult) + " = " + scrutariResult.getFicheCount();
- if (client.currentHistoryName) {
- Scrutari.$(client.$block(client.currentHistoryName), {scrutariRole: "subsearch"}).text(subsearchText);
+ function __initHtmlObject (htmlObject) {
+ if (htmlObject) {
+ if (htmlObject.structure) {
+ for(let key in htmlObject.structure) {
+ client._structureMap.set(key, htmlObject.structure[key]);
+ }
+ }
+ if (htmlObject.templates) {
+ for(let key in htmlObject.templates) {
+ client._templateMap.set(key, htmlObject.templates[key]);
+ }
+ }
+ }
}
}
- if (ficheCount === 0) {
- client.$hidden("empty", 'hide');
- let withFilter;
- if (searchOrigin === "subsearch") {
- withFilter = true;
- } else {
- withFilter = _hasFilter(scrutariResult.requestParameters);
- }
- $ficheDisplayBlock.html(client.render("emptyfichedisplay", {withFilter: withFilter, scrutariResult: scrutariResult}));
+};
+Scrutari.Pagination = function (client, ficheGroupName) {
+ this.client = client;
+ this.ficheGroupName = ficheGroupName;
+ this.paginationLength = client.scrutariConfig.options.paginationLength;
+};
+Scrutari.Pagination.prototype.change = function (paginationNumber) {
+ var client = this.client;
+ var ficheGroupName = this.ficheGroupName;
+ var scrutariResult = client.history.currentScrutariResult;
+ var paginationFicheArray = this.getPaginationFicheArray(scrutariResult, paginationNumber);
+ if (!paginationFicheArray) {
return;
}
- client.$hidden("empty", 'show');
+ this.updateFicheList(scrutariResult, paginationFicheArray);
+ this.updateTabs(this.getFicheCount(scrutariResult), paginationNumber);
+ var hookParams = {
+ paginationNumber:paginationNumber
+ };
+ if (ficheGroupName) {
+ hookParams.ficheGroupName = ficheGroupName;
+ hookParams.categoryName = ficheGroupName;
+ }
+ client.hook("paginationChange", paginationFicheArray, hookParams);
+};
+Scrutari.Pagination.prototype.getPaginationFicheArray = function (scrutariResult, paginationNumber) {
+ var pagination = this;
+ var client = this.client;
+ var paginationLength = this.paginationLength;
+ var ficheGroupName = this.ficheGroupName;
+ if (!scrutariResult.isPaginationLoaded(paginationLength, paginationNumber, ficheGroupName)) {
+ if (client.isWaiting) {
+ return;
+ }
+ client.$block("ficheList", ficheGroupName).html(client.render("loading", {scrutariResult: scrutariResult}));
+ client.isWaiting = true;
+ scrutariResult.loadPagination(client.scrutariConfig, paginationLength, paginationNumber, ficheGroupName, function () {
+ client.isWaiting = false;
+ pagination.change(paginationNumber);
+ });
+ return false;
+ }
+ return scrutariResult.extractFicheArray(paginationLength, paginationNumber, ficheGroupName);
+};
+Scrutari.Pagination.prototype.getFicheCount = function (scrutariResult) {
+ return scrutariResult.getFicheCount(this.ficheGroupName);
+};
+Scrutari.Pagination.prototype.updateFicheList = function (scrutariResult, paginationFicheArray) {
+ var client = this.client;
+ var html = "";
+ var ficheTemplate = client.getTemplate("fiche");
+ for(let fiche of paginationFicheArray) {
+ html += ficheTemplate(client.completeFiche(scrutariResult, fiche));
+ }
+ client.$block("ficheList", this.ficheGroupName).html(html);
+};
+Scrutari.Pagination.prototype.updateTabs = function (ficheCount, paginationNumber) {
+ var client = this.client;
+ var ficheGroupName = this.ficheGroupName;
+ var tabArray = Scrutari.Utils.getTabArray(ficheCount, this.paginationLength, paginationNumber);
+ var topBlock = "topTabs" ;
+ var bottomBlock = "bottomTabs";
+ var type = "unique";
+ if (ficheGroupName) {
+ topBlock = topBlock + "-" + ficheGroupName;
+ bottomBlock = bottomBlock + "-" + ficheGroupName;
+ type = "group";
+ }
+ var template = client.getTemplate("tabs");
+ client.$block(topBlock).html(template({
+ tabArray: tabArray,
+ type: type,
+ ficheGroupName: ficheGroupName,
+ position: "top"
+ }));
+ client.$block(bottomBlock).html(template({
+ tabArray: tabArray,
+ type: type,
+ ficheGroupName: ficheGroupName,
+ position: "bottom"
+ }));
+};
+Scrutari.Process = function (client, scrutariResult, searchOrigin) {
+ this.client = client;
+ this.scrutariResult = scrutariResult;
+ this.searchOrigin = searchOrigin;
+};
+Scrutari.Process.prototype.run = function () {
+ var client = this.client;
+ var scrutariResult = this.scrutariResult;
+ var searchOrigin = this.searchOrigin;
+ client.hook("processResult", scrutariResult, searchOrigin);
+ client.history.setCurrentResult(scrutariResult, searchOrigin);
+ client.clearPagination();
+ var ficheCount = scrutariResult.getFicheCount();
+ var $paginationBlock = this.getPaginationBlock();
+ if (!this.checkNotEmpty(ficheCount, $paginationBlock)) {
+ return;
+ }
+ this.checkThreshold(ficheCount);
+ this.updateLinks();
+ this.addPaginations($paginationBlock);
+ client.hook("showResult", scrutariResult, searchOrigin);
+};
+Scrutari.Process.prototype.getPaginationBlock = function () {
+ var $paginationBlock = this.client.$block("paginationBlock");
+ $paginationBlock.empty();
+ return $paginationBlock;
+};
+Scrutari.Process.prototype.checkNotEmpty = function (ficheCount, $paginationBlock) {
+ var client = this.client;
+ client.$hidden("start", 'show');
+ if (ficheCount === 0) {
+ this.processEmpty($paginationBlock);
+ return false;
+ } else {
+ this.client.$hidden("empty", 'show');
+ return true;
+ }
+};
+Scrutari.Process.prototype.processEmpty = function ($paginationBlock) {
+ var client = this.client;
+ var scrutariResult = this.scrutariResult;
+ client.$hidden("empty", 'hide');
+ let withFilter;
+ if (searchOrigin === "subsearch") {
+ withFilter = true;
+ } else {
+ withFilter = Scrutari.Utils.hasFilter(scrutariResult.requestParameters);
+ }
+ $paginationBlock.html(client.render("pagination_empty", {withFilter: withFilter, scrutariResult: scrutariResult}));
+};
+Scrutari.Process.prototype.checkThreshold = function (ficheCount) {
+ var client = this.client;
if (ficheCount >= client.scrutariConfig.options.subsearchThreshold) {
client.$hidden("threshold", 'show');
} else {
client.$hidden("threshold", 'hide');
}
- var qId = scrutariResult.getQId();
+};
+Scrutari.Process.prototype.updateLinks = function () {
+ var client = this.client;
+ var qId = this.scrutariResult.getQId();
var permalink = client.toPermalink(qId);
if (permalink) {
- client.$link("permalink").attr("href", permalink).html(permalink);
+ client.$link("permalink").attr("href", permalink);
+ client.$label("permalinkValue").html(permalink);
}
_updateDownloadHref("ods");
_updateDownloadHref("csv");
_updateDownloadHref("atom");
- if (scrutariResult.getFicheGroupType() === 'category') {
- var contextObj = {
- scrutariResult: scrutariResult,
- array: new Array()
- };
- var categoryCount = scrutariResult.getCategoryCount();
- for(let i = 0; i < categoryCount; i++) {
- let category = scrutariResult.getCategory(i);
- let metaCategory = client.scrutariMeta.getCategory(category.name);
- if (metaCategory) {
- category = metaCategory;
- } else {
- category.phraseMap = {};
- category.attrMap = {};
- }
- contextObj.array.push({
- category: category,
- active: (i === 0),
- fichestat: scrutariResult.getCategoryFicheCount(i)
- });
- }
- $ficheDisplayBlock.html(client.render("categoryfichedisplay", contextObj));
- for(let i = 0; i < categoryCount; i++) {
- let category = scrutariResult.getCategory(i);
- Scrutari.Client.Result.categoryPaginationChange(client, category.name, 1);
- }
- } else {
- $ficheDisplayBlock.html(client.render("uniquefichedisplay", {scrutariResult: scrutariResult}));
- Scrutari.Client.Result.uniquePaginationChange(client, 1);
- }
- client.hook("showResult", scrutariResult, searchOrigin);
function _updateDownloadHref(extension) {
client.$link(extension).attr("href", client.scrutariConfig.getDownloadUrl(qId, extension));
}
- function _hasFilter(requestParameters) {
- for(var prop in requestParameters) {
- switch(prop) {
- case "baselist":
- case "corpuslist":
- case "categorylist":
- case "langlist":
- var value = requestParameters[prop];
- if (value) {
- return true;
- }
- }
- if (prop.indexOf("flt") === 0) {
- return true;
- }
- }
- return false;
- }
};
-Scrutari.Client.Result.displayError = function (client, error, searchOrigin) {
- if (error.parameter !== "q") {
- Scrutari.logError(error);
- return;
- }
- var title = client.loc(error.key);
- if (title !== error.key) {
- var alertMessage = title;
- if (error.hasOwnProperty("array")) {
- alertMessage += client.loc('_ colon');
- for(var i = 0; i < error.array.length; i++) {
- alertMessage += "\n";
- var obj = error.array[i];
- alertMessage += "- ";
- alertMessage += client.loc(obj.key);
- if (obj.hasOwnProperty("value")) {
- alertMessage += client.loc('_ colon');
- alertMessage += " ";
- alertMessage += obj.value;
- }
- }
- }
- alert(alertMessage);
+Scrutari.Process.prototype.addPaginations = function ($paginationBlock) {
+ Scrutari.log("original");
+ if (this.scrutariResult.getFicheGroupType() === 'category') {
+ this.addCategoryPaginations($paginationBlock);
} else {
- Scrutari.logError(error);
+ this.addUniquePagination($paginationBlock);
}
};
-Scrutari.Client.Result.uniquePaginationChange = function (client, paginationNumber) {
- var paginationLength = client.scrutariConfig.options.paginationLength;
- var scrutariResult = client.currentScrutariResult;
- var html = "";
- if (!scrutariResult.isUniquePaginationLoaded(paginationLength, paginationNumber)) {
- if (client.isWaiting) {
- return;
- }
- client.$block("fiches").html(client.render("ficheloading", {scrutariResult: scrutariResult}));
- client.isWaiting = true;
- scrutariResult.loadUniquePagination(client.scrutariConfig, paginationLength, paginationNumber, _paginationCallback);
- return;
- }
- var paginationFicheArray = scrutariResult.selectUniqueFicheArray(paginationLength, paginationNumber);
- var ficheTemplate = client.getTemplate("fiche");
- for(let fiche of paginationFicheArray) {
- html += ficheTemplate(Scrutari.Client.Result.completeFiche(client, scrutariResult, fiche));
- }
- client.$block("fiches").html(html);
- var tabArray = Scrutari.Utils.getTabArray(scrutariResult.getFicheCount(), paginationLength, paginationNumber);
- var template = client.getTemplate("tabs");
- client.$block("topPagination").html(template({
- tabArray: tabArray,
- type: "unique",
- position: "top"
- }));
- client.$block("bottomPagination").html(template({
- tabArray: tabArray,
- type: "unique",
- position: "bottom"
- }));
- client.hook("paginationChange", paginationFicheArray, {paginationNumber:paginationNumber});
- function _paginationCallback () {
- client.isWaiting = false;
- Scrutari.Client.Result.uniquePaginationChange(client, paginationNumber);
- }
-};
-Scrutari.Client.Result.categoryPaginationChange = function (client, categoryName, paginationNumber) {
- var paginationLength = client.scrutariConfig.options.paginationLength;
- var scrutariResult = client.currentScrutariResult;
- var html = "";
- if (!scrutariResult.isCategoryPaginationLoaded(categoryName, paginationLength, paginationNumber)) {
- client.$block("fiches_" + categoryName).html(client.render("ficheloading", {scrutariResult: scrutariResult}));
- if (client.isWaiting) {
- return;
- }
- client.isWaiting = true;
- scrutariResult.loadCategoryPagination(client.scrutariConfig, categoryName, paginationLength, paginationNumber, _paginationCallback);
- return;
- }
- var paginationFicheArray = scrutariResult.selectCategoryFicheArray(categoryName, paginationLength, paginationNumber);
- var ficheTemplate = client.getTemplate("fiche");
- for(let fiche of paginationFicheArray) {
- html += ficheTemplate(Scrutari.Client.Result.completeFiche(client, scrutariResult, fiche, categoryName));
- }
- client.$block("fiches_" + categoryName).html(html);
- var tabArray = Scrutari.Utils.getTabArray(scrutariResult.getCategoryFicheCountByName(categoryName), paginationLength, paginationNumber);
- var template = client.getTemplate("tabs");
- client.$block("topPagination_" + categoryName).html(template({
- tabArray: tabArray,
- type: "category",
- category: categoryName,
- position: "top"
- }));
- client.$block("bottomPagination_" + categoryName).html(template({
- tabArray: tabArray,
- type: "category",
- category: categoryName,
- position: "bottom"
- }));
- client.hook("paginationChange", paginationFicheArray, {categoryName: categoryName, paginationNumber:paginationNumber});
- function _paginationCallback () {
- client.isWaiting = false;
- Scrutari.Client.Result.categoryPaginationChange(client, categoryName, paginationNumber);
- }
-};
-Scrutari.Client.Result.addToHistory = function (client, scrutariResult) {
- var $historyListBlock = client.$block("historyList");
- if (!Scrutari.exists($historyListBlock)) {
- return;
- }
- if (client.currentHistoryName) {
- var $historyBlock = client.$block(client.currentHistoryName);
- $historyBlock.removeClass("scrutari-history-Active");
- Scrutari.$($historyBlock, {scrutariRole: "subsearch"}).empty();
- client.show(Scrutari.$($historyBlock, {scrutariRole: "remove"}));
- }
- var historyName = "history_" + client.newHistoryNumber();
- Scrutari.Client.Result.setCurrentHistory(client, historyName);
- client.storeResult(historyName, scrutariResult);
+Scrutari.Process.prototype.addCategoryPaginations = function ($paginationBlock) {
+ var client = this.client;
+ var scrutariResult = this.scrutariResult;
var contextObj = {
scrutariResult: scrutariResult,
- name: historyName,
- fichestat: scrutariResult.getFicheCount(),
- sequence: Scrutari.Utils.formatSearchSequence(client, scrutariResult)
+ array: new Array()
};
- $historyListBlock.prepend(client.render("history", contextObj));
-};
-Scrutari.Client.Result.loadHistory = function (client, historyName) {
- var historyScrutariResult = client.getResult(historyName);
- if (historyScrutariResult) {
- var $historyBlock = client.$block(historyName);
- client.currentScrutariResult = historyScrutariResult;
- Scrutari.Client.Result.setCurrentMain(client, historyScrutariResult);
- Scrutari.Client.Result.setCurrentHistory(client, historyName);
- $historyBlock.addClass("scrutari-history-Active");
- client.hide(Scrutari.$($historyBlock, {scrutariRole: "remove"}));
- Scrutari.Client.Result.show(client, historyScrutariResult);
- }
-};
-Scrutari.Client.Result.setCurrentHistory = function (client, historyName) {
- if (client.currentHistoryName) {
- var $historyBlock = client.$block(client.currentHistoryName);
- $historyBlock.removeClass("scrutari-history-Active");
- Scrutari.$($historyBlock, {scrutariRole: "subsearch"}).empty();
- client.show (Scrutari.$($historyBlock, {scrutariRole: "remove"}));
- }
- client.currentHistoryName = historyName;
-};
-Scrutari.Client.Result.setCurrentMain = function (client, scrutariResult) {
- client.mainCurrentScrutariResult = scrutariResult;
- client.$block("currentSearchSequence").text(Scrutari.Utils.formatSearchSequence(client, scrutariResult) + " (" + scrutariResult.getFicheCount() + ")");
-};
-Scrutari.Client.Result.completeFiche = function(client, scrutariResult, fiche, categoryName) {
- var scrutariMeta = client.scrutariMeta;
- var options = client.options;
- Scrutari.Complete.complementTitle(fiche, scrutariMeta);
- Scrutari.Complete.motcleArray(fiche, _motcleProvider);
- Scrutari.Complete.bythesaurusArray(fiche, scrutariMeta, _motcleProvider);
- if (Scrutari.Complete.hasMarkedAttribute(fiche)) {
- Scrutari.Complete.markedAttributeArray(fiche, scrutariMeta, "primary");
- Scrutari.Complete.markedAttributeArray(fiche, scrutariMeta, "secondary");
- }
- if (!options.ignoreThumbnail) {
- Scrutari.Complete.thumbnail(fiche);
- }
- if (!options.ignoreIcon) {
- Scrutari.Complete.icon(fiche);
- }
- if (options.ficheTarget) {
- Scrutari.Complete.target(fiche, options.ficheTarget);
- }
- fiche._bodyTemplateArray = client.getFicheBodyTemplateArray(fiche, categoryName);
- client.hook("completeFiche", scrutariResult, fiche, categoryName);
- return fiche;
- function _motcleProvider(code) {
- return scrutariResult.getMotcle(code);
- }
-};
-Scrutari.Client.Ui = {};
-Scrutari.Client.Ui.filterChange = function (client) {
- var globalFicheCount = client.scrutariMeta.getGlobalFicheCount();
- var filterState = Scrutari.Client.Ui.buildFilterState(client);
- var filterFicheCount;
- if (filterState.empty) {
- filterFicheCount = client.scrutariMeta.getGlobalFicheCount();
- } else {
- filterFicheCount = -1;
- }
- client.stats.update(filterState);
- if (!_checkFilterFicheCount("base")) {
- if (!_checkFilterFicheCount("corpus")) {
- if (!_checkFilterFicheCount("category")) {
- _checkFilterFicheCount("lang");
- }
- }
- }
- _updateState("base");
- _updateState("corpus");
- _updateState("category");
- _updateState("lang");
- var filterTitlesArray = new Array();
- _addFilterTitles("base", "_ label_base_one", "_ label_base_many");
- _addFilterTitles("corpus", "_ label_corpus_one", "_ label_corpus_many");
- _addFilterTitles("lang", "_ label_lang_one", "_ label_lang_many");
- _addFilterTitles("category", "_ label_category_one", "_ label_category_many");
- var $filterFicheCount = client.$count('stats-filter', 'update', filterFicheCount);
- var $filterValue = Scrutari.$($filterFicheCount, {scrutariRole: "value"});
- if (filterFicheCount === globalFicheCount) {
- $filterValue.removeClass("scrutari-stats-Filter").removeClass("scrutari-stats-None");
- client.$hidden('filter', 'hide');
- } else if (filterFicheCount === 0) {
- $filterValue.removeClass("scrutari-stats-Filter").addClass("scrutari-stats-None");
- client.$hidden('filter', 'show');
- } else {
- $filterValue.addClass("scrutari-stats-Filter").removeClass("scrutari-stats-None");
- client.$hidden('filter', 'show');
- }
- var $filterTitles = Scrutari.$($filterFicheCount, {scrutariRole: "titles"});
- if (filterTitlesArray.length > 0) {
- $filterTitles.html(filterTitlesArray.join(" | "));
- } else {
- $filterTitles.html("");
- }
- function _checkFilterFicheCount(type) {
- var $stat = client.$({scrutariStatType: type});
- if ($stat.length > 0) {
- filterFicheCount = 0;
- $stat.each(function (index, element) {
- let key = element.dataset.scrutariStatKey;
- filterFicheCount += client.stats.getFicheCount(type, key);
- });
- return true;
+ let active = true;
+ for(let ficheGroup of scrutariResult.ficheGroupArray) {
+ let category = ficheGroup.category;
+ let metaCategory = client.scrutariMeta.getCategory(category.name);
+ if (metaCategory) {
+ category = metaCategory;
} else {
- return false;
+ category.phraseMap = {};
+ category.attrMap = {};
}
- }
- function _updateState(type) {
- client.$({scrutariStatType: type}).each(function (index, element) {
- var $el = $(element);
- var key = element.dataset.scrutariStatKey;
- var ficheCount = client.stats.getFicheCount(type, key);
- var $statTitle = Scrutari.$parents($el, {scrutariRole: "stat-text"});
- if (ficheCount != element.dataset.scrutariStatDefault) {
- if (ficheCount === 0) {
- $el.html("");
- $statTitle.addClass("scrutari-panel-Excluded");
- } else {
- $statTitle.removeClass("scrutari-panel-Excluded");
- $el.html(client.formatNumber(ficheCount) + " / ");
- }
- } else {
- $el.html("");
- $statTitle.removeClass("scrutari-panel-Excluded");
- }
+ let description = "";
+ if (category.phraseMap.description) {
+ description = category.phraseMap.description;
+ }
+ contextObj.array.push({
+ category: category,
+ name: category.name,
+ title: category.title,
+ description: description,
+ active: active,
+ fichestat: ficheGroup.ficheCount
});
+ active = false;
}
- function _addFilterTitles(type, oneLocKey, manyLocKey) {
- var array = filterState.titles[type];
- if (array.length > 0) {
- var locKey = (array.length === 1)?oneLocKey:manyLocKey;
- filterTitlesArray.push(client.loc(locKey) + client.loc('_ colon') + " " + array.join(", "));
- }
+ $paginationBlock.html(client.render("pagination_groups", contextObj));
+ for(let group of contextObj.array) {
+ let ficheGroupName = group.name;
+ let pagination = new Scrutari.Pagination(client, ficheGroupName);
+ client.putPagination(ficheGroupName, pagination);
+ pagination.change(1);
}
};
-Scrutari.Client.Ui.buildRequestParameters = function (client) {
- var requestParameters = new Object();
- _checkFilter("baselist", "base");
- _checkFilter("corpuslist", "corpus");
- _checkFilter("categorylist", "category");
- _checkFilter("langlist", "lang");
- requestParameters["q-mode"] = client.$input_checked("q-mode").val();
- var ponderation = client.$input_checked("ponderation").val();
- if (ponderation === 'date') {
- requestParameters.ponderation = '10,80,5,5';
- }
- var periode = $.trim(client.$input("periode").val());
- if (periode) {
- requestParameters["flt-date"] = periode;
- }
- if (Scrutari.exists(client.$input_checked("wildchar"))) {
- requestParameters.wildchar = "end";
- } else {
- requestParameters.wildchar = "none";
- }
- return requestParameters;
- function _checkFilter (paramName, target) {
- if (client.$button("enablePanel", target).data("scrutariState") === "on") {
- var $inputs = client.$input_checked(target);
- var value = "";
- for(var i = 0; i < $inputs.length; i++) {
- if (i > 0) {
- value += ",";
- }
- value += $inputs[i].value;
- }
- if (value.length > 0) {
- requestParameters[paramName] = value;
- }
- }
- }
+Scrutari.Process.prototype.addUniquePagination = function ($paginationBlock) {
+ var client = this.client;
+ var scrutariResult = this.scrutariResult;
+ $paginationBlock.html(client.render("pagination_unique", {scrutariResult: scrutariResult}));
+ let uniquePagination = new Scrutari.Pagination(client);
+ client.putPagination("", uniquePagination);
+ uniquePagination.change(1);
};
-Scrutari.Client.Ui.buildFilterState = function (client) {
- var filterState = new Scrutari.FilterState();
- _check("base");
- _check("corpus");
- _check("category");
- _check("lang");
- return filterState;
- function _check (target) {
- if (client.$button("enablePanel", target).data("scrutariState") !== "on") {
- return;
- }
- client.$input_checked(target).each(function (index,element) {
- filterState.add(target, element.value, element.dataset.scrutariTitle);
- });
- }
-};
-Scrutari.Client.Ui.init = function (client) {
+Scrutari.DefaultUi = {};
+Scrutari.DefaultUi.init = function (client) {
var scrutariMeta = client.scrutariMeta;
- Scrutari.Client.Ui.initHtml(client);
- Scrutari.Client.Ui.initForms(client);
- Scrutari.Client.Ui.initClicks(client);
- Scrutari.Client.Ui.initMainTitle(client);
+ $("#" + client.clientId).html(client.compileStructure("main"));
+ client.initForms();
+ client.initButtons(Scrutari.DefaultUi.actionHandler);
+ client.initChangeListeners(Scrutari.DefaultUi.changeHandler);
+ Scrutari.DefaultUi.initMainTitle(client);
client.$count('stats-global', 'update', scrutariMeta.getGlobalFicheCount());
client.$hidden('init', 'show');
client.show(client.$button('parametersDisplay'));
@@ -2590,248 +2880,125 @@ Scrutari.Client.Ui.init = function (client) {
_initFilter("categorylist", "category");
_initFilter("langlist", "lang");
}
- var initialQuery = client.options.initialQuery;
- var initialQId = client.options.initialQId;
- if (initialQuery) {
- var $mainSearchForm = client.$form('mainsearch');
- if (Scrutari.exists($mainSearchForm)) {
- $mainSearchForm.find("input[name='q']").val(initialQuery);
- $mainSearchForm.submit();
- }
- } else if (initialQId) {
- var requestParameters = Scrutari.Client.Ui.buildRequestParameters(client);
- requestParameters["qid"] = initialQId;
- client.$modal("loading", 'show');
- client.hook("newSearch", requestParameters, "qidsearch");
- Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, _mainsearchScrutariResultCallback, _mainScrutariErrorCallback);
- }
+ client.checkInitialQuery();
function _initFilter (optionName, target) {
if (!initialFilters.hasOwnProperty(optionName)) {
return;
}
- Scrutari.Client.Ui.initFilter(client, target, initialFilters[optionName].split(","));
+ Scrutari.DefaultUi.initFilter(client, target, initialFilters[optionName].split(","));
+ }
+};
+Scrutari.DefaultUi.initFilterByQuery = function (client, scrutariResult) {
+ var searchOptions = scrutariResult.searchMeta.options;
+ if (searchOptions) {
+ _initFilterByQuery(searchOptions.baselist, "base");
+ _initFilterByQuery(searchOptions.corpuslist, "corpus");
+ _initFilterByQuery(searchOptions.categorylist, "category");
+ _initFilterByQuery(searchOptions.langlist, "lang");
}
function _initFilterByQuery (list, target) {
if (list) {
- Scrutari.Client.Ui.initFilter(client, target, list.array);
+ Scrutari.DefaultUi.initFilter(client, target, list.array);
}
}
- function _mainsearchScrutariResultCallback (scrutariResult) {
- var $mainSearchForm = client.$form('mainsearch');
- $mainSearchForm.find("input[name='q']").val(scrutariResult.searchMeta.q);
- $mainSearchForm.find("input[name='q-mode'][value='operation']").click();
- var searchOptions = scrutariResult.searchMeta.options;
- if (searchOptions) {
- _initFilterByQuery(searchOptions.baselist, "base");
- _initFilterByQuery(searchOptions.corpuslist, "corpus");
- _initFilterByQuery(searchOptions.categorylist, "category");
- _initFilterByQuery(searchOptions.langlist, "lang");
- }
- Scrutari.Client.Result.show(client, scrutariResult, "mainsearch");
- client.$modal("loading", 'hide');
- var $parametersDisplayButton = client.$button('parametersDisplay');
- if ($parametersDisplayButton.data("scrutariState") === "on") {
- $parametersDisplayButton.click();
- }
- }
- function _mainScrutariErrorCallback (error) {
- Scrutari.Client.Result.displayError(client, error, "mainsearch");
- client.$modal("loading", 'hide');
- }
};
-Scrutari.Client.Ui.initHtml = function (client) {
- var includedTexts = {};
- var html = _getText("main");
- html = html.replace(/_ [-_\.a-z0-9]+/g, function(match) {
- return client.loc(match);
- });
- $("#" + client.clientId).html(html);
- function _getText(name) {
- if (name.endsWith('*')) {
- return _getTextByPrefix(name.substring(0, name.length - 1));
- }
- if (includedTexts.hasOwnProperty(name)) {
- Scrutari.log("Already included: " + name);
- return "";
- } else if (client.ignoreElement(name)) {
- return "";
- } else if ((name === "panel-base") && (client.options.withCorpus)) {
- return "";
- } else if ((name === "panel-corpus") && (!client.options.withCorpus)) {
- return "";
- } else if ((name === "result-share") && (!client.options.permalinkPattern)) {
- return "";
- }
- includedTexts[name] = true;
- var text = client.getStructureHtml(name);
- text = text.replace(/{{([-a-zA-z0-9_]+\*?)}}/g, function (match, p1) {
- return _getText(p1);
- });
- return text;
+Scrutari.DefaultUi.ignoreElement = function (client, name) {
+ switch(name) {
+ case "panel-base":
+ return (client.options.withCorpus);
+ case "panel-corpus":
+ return (!client.options.withCorpus);
+ case "result-share":
+ return (!client.options.permalinkPattern);
}
- function _getTextByPrefix(namePrefix) {
- var result = "";
- for(let name of client.getStructureNameArray()) {
- if (name.startsWith(namePrefix)) {
- let text = _getText(name);
- if (text.length > 0) {
- if (result.length > 0) {
- result = result + "\n";
- }
- result = result + text;
+ return false;
+};
+Scrutari.DefaultUi.isFilterEnable = function (client, target) {
+ return (client.$button("enablePanel", target).data("scrutariState") === "on");
+};
+Scrutari.DefaultUi.mainsearchResultCallback = function (client, scrutariResult) {
+ client.$count("stats-result", 'update', scrutariResult.getFicheCount());
+ var $parametersDisplayButton = client.$button('parametersDisplay');
+ if ($parametersDisplayButton.data("scrutariState") === "on") {
+ $parametersDisplayButton.click();
+ }
+};
+Scrutari.DefaultUi.subsearchResultCallback = function (client, scrutariResult) {
+ client.$count("stats-result", 'update', scrutariResult.getFicheCount());
+};
+Scrutari.DefaultUi.displayError = function (client, error, searchOrigin) {
+ if (error.parameter !== "q") {
+ Scrutari.logError(error);
+ return;
+ }
+ var title = client.loc(error.key);
+ if (title !== error.key) {
+ var alertMessage = title;
+ if (error.hasOwnProperty("array")) {
+ alertMessage += client.loc('_ colon');
+ for(var i = 0; i < error.array.length; i++) {
+ alertMessage += "\n";
+ var obj = error.array[i];
+ alertMessage += "- ";
+ alertMessage += client.loc(obj.key);
+ if (obj.hasOwnProperty("value")) {
+ alertMessage += client.loc('_ colon');
+ alertMessage += " ";
+ alertMessage += obj.value;
}
}
}
- return result;
+ alert(alertMessage);
+ } else {
+ Scrutari.logError(error);
}
};
-Scrutari.Client.Ui.initForms = function (client) {
- client.$form('mainsearch').submit(function () {
- var q = this["q"].value.trim();
- if (q.length > 0) {
- var requestParameters = Scrutari.Client.Ui.buildRequestParameters(client);
- requestParameters["log"] = "all";
- requestParameters["q"] = q;
- client.$modal("loading", 'show');
- client.hook("newSearch", requestParameters, "mainsearch");
- Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, _mainsearchScrutariResultCallback, _mainScrutariErrorCallback);
- }
- return false;
- });
- client.$form('subsearch').submit(function () {
- var q = this["q"].value.trim();
- if ((q.length > 0) && (client.mainCurrentScrutariResult)) {
- var requestParameters = Scrutari.Client.Ui.buildRequestParameters(client);
- requestParameters["q"] = q;
- requestParameters["flt-qid"] = client.mainCurrentScrutariResult.getQId();
- client.$modal("loading", 'show');
- client.hook("newSearch", requestParameters, "subsearch");
- Scrutari.Result.newSearch(client.scrutariConfig, requestParameters, _subsearchScrutariResultCallback, _subsearchScrutariErrorCallback);
- }
- return false;
- });
- function _mainsearchScrutariResultCallback (scrutariResult) {
- Scrutari.Client.Result.show(client, scrutariResult, "mainsearch");
- client.$modal("loading", 'hide');
- var $parametersDisplayButton = client.$button('parametersDisplay');
- if ($parametersDisplayButton.data("scrutariState") === "on") {
- $parametersDisplayButton.click();
- }
- }
- function _mainScrutariErrorCallback (error) {
- Scrutari.Client.Result.displayError(client, error, "mainsearch");
- client.$modal("loading", 'hide');
- }
- function _subsearchScrutariResultCallback (scrutariResult) {
- Scrutari.Client.Result.show(client, scrutariResult, "subsearch");
- client.$modal("loading", 'hide');
- }
- function _subsearchScrutariErrorCallback (error) {
- Scrutari.Client.Result.displayError(client, error, "subsearch");
- client.$modal("loading", 'hide');
- }
+Scrutari.DefaultUi.newResultProcess = function (client, scrutariResult, searchOrigin) {
+ return new Scrutari.Process(client, scrutariResult, searchOrigin);
};
-Scrutari.Client.Ui.initClicks = function (client) {
- $("#" + client.clientId).on("click", Scrutari.toCssQuery({scrutariButton: true}), function () {
- var $this = $(this);
- var action = this.dataset.scrutariButton;
- var target = this.dataset.scrutariTarget;
- switch(action) {
- case 'enablePanel':
- _enablePanel(this, target);
- break;
- case 'checkAll':
- _checkAll(target);
- break;
- case 'uncheckAll':
- _uncheckAll(target);
- break;
- case 'showModal':
- client.$modal(target, 'show');
- break;
- case 'parametersDisplay':
- let state = Scrutari.Utils.toggle($this, "scrutariState");
- Scrutari.Utils.toggle.classes($this, state, "Scrutari-On", "");
- if (state === 'on') {
- client.$area('parameters', 'show');
- } else {
- client.$area('parameters', 'hide');
- }
- break;
- case 'toggleBlock':
- if (Scrutari.Utils.toggle($this, "scrutariState") === 'on') {
- client.$block(target, 'show');
- } else {
- client.$block(target, 'hide');
- }
- break;
- case 'removeHistory':
- _removeHistory(target);
- break;
- case 'loadHistory':
- _loadHistory(target);
- break;
- case 'categoryTab':
- _categoryTab(this.dataset.scrutariCategory);
- break;
- case 'ficheTab':
- _ficheTab(this);
- break;
- default:
- Scrutari.log("Unknown action: " + action);
- }
- if ((this.tagName) && (this.tagName.toLowerCase() === 'a')) {
+Scrutari.DefaultUi.actionHandler = function (client, button, action, target) {
+ var $button = $(button);
+ switch(action) {
+ case 'enablePanel':
+ _enablePanel();
+ break;
+ case 'checkAll':
+ _checkAll();
+ break;
+ case 'uncheckAll':
+ _uncheckAll();
+ break;
+ case 'parametersDisplay':
+ let state = Scrutari.Utils.toggle($button, "scrutariState");
+ Scrutari.Utils.toggle.classes($button, state, client.cssClasses.on, "");
+ if (state === 'on') {
+ client.$area('parameters', 'show');
+ } else {
+ client.$area('parameters', 'hide');
+ }
+ break;
+ default:
return false;
- }
- });
- $("#" + client.clientId).on("click", "input", function () {
- var name = this.name;
- if (name) {
- switch(name) {
- case 'q-mode':
- if (this.value === 'operation') {
- Scrutari.Utils.disable("input[name='wildchar']");
- } else {
- Scrutari.Utils.enable("input[name='wildchar']");
- }
- break;
- case 'lang':
- case 'category':
- case 'base':
- case 'corpus':
- _checkClick(name);
- break;
- }
- }
- });
- function _checkClick (target) {
- var $button = client.$button("enablePanel", target);
- if ($button.data('scrutariState') === 'off') {
- $button.click();
- $(this).focus();
- } else {
- Scrutari.Client.Ui.filterChange(client);
- }
}
- function _checkAll (target) {
+ return true;
+ function _checkAll () {
Scrutari.Utils.check("input[name='" + target + "']");
- Scrutari.Client.Ui.filterChange(client);
+ Scrutari.DefaultUi.filterChange(client);
}
- function _uncheckAll (target) {
+ function _uncheckAll () {
Scrutari.Utils.uncheck("input[name='" + target + "']");
- Scrutari.Client.Ui.filterChange(client);
+ Scrutari.DefaultUi.filterChange(client);
}
- function _enablePanel (button, target) {
- var $button = $(button);
+ function _enablePanel () {
var state = Scrutari.Utils.toggle($button, "scrutariState");
_enableChekButtons();
- Scrutari.Utils.toggle.classes($button, state, "scrutari-On", "");
- Scrutari.Utils.toggle.classes(client.$group(target + "Columns"), state, "", "scrutari-panel-ColumnDisabled");
+ Scrutari.Utils.toggle.classes($button, state, client.cssClasses.on, "");
+ Scrutari.Utils.toggle.classes(client.$group(target + "Columns"), state, "", client.cssClasses.disabledPanelColumn);
Scrutari.Utils.toggle.text($button.children("span"), "scrutariAlternate");
var $filterLabel = client.$label(target + "Filter");
Scrutari.Utils.toggle.text($filterLabel, "scrutariAlternate");
- Scrutari.Utils.toggle.classes($filterLabel, state, "scrutari-panel-Active", "scrutari-Disabled");
- Scrutari.Client.Ui.filterChange(client);
+ Scrutari.Utils.toggle.classes($filterLabel, state, client.cssClasses.activePanel, client.cssClasses.disabled);
+ Scrutari.DefaultUi.filterChange(client);
function _enableChekButtons () {
let disabled = false;
if (state === 'off') {
@@ -2841,42 +3008,29 @@ Scrutari.Client.Ui.initClicks = function (client) {
client.$button("uncheckAll", target).prop('disabled', disabled);
}
}
- function _removeHistory (historyName) {
- client.unstoreResult(historyName);
- client.$block(historyName).remove();
+};
+Scrutari.DefaultUi.changeHandler = function (client, element, name) {
+ switch(name) {
+ case 'lang':
+ case 'category':
+ case 'base':
+ case 'corpus':
+ _checkClick(name);
+ return true;
+ default:
+ return false;
}
- function _loadHistory (historyName) {
- Scrutari.Client.Result.loadHistory(client, historyName);
- }
- function _categoryTab (categoryName) {
- client.$({scrutariRole: "category-content"}).each(function (index, element) {
- if (element.dataset.scrutariCategory === categoryName) {
- client.show(element);
- } else {
- client.hide(element);
- }
- });
- client.$({scrutariRole: "category-tab"}).each(function (index, element) {
- if (element.dataset.scrutariCategory === categoryName) {
- element.classList.add("scrutari-On");
- } else {
- element.classList.remove("scrutari-On");
- }
- });
- }
- function _ficheTab (button) {
- var newPaginationNumber = parseInt(button.dataset.scrutariNumber);
- if (button.dataset.scrutariType === "unique") {
- Scrutari.Client.Result.uniquePaginationChange(client, newPaginationNumber);
+ function _checkClick (target) {
+ var $button = client.$button("enablePanel", target);
+ if ($button.data('scrutariState') === 'off') {
+ $button.click();
+ $(this).focus();
} else {
- Scrutari.Client.Result.categoryPaginationChange(client, button.dataset.scrutariCategory, newPaginationNumber);
- }
- if (button.dataset.scrutariPosition === "bottom") {
- client.scrollToResult();
+ Scrutari.DefaultUi.filterChange(client);
}
}
};
-Scrutari.Client.Ui.initMainTitle = function (client) {
+Scrutari.DefaultUi.initMainTitle = function (client) {
var html = "";
var mainTitle = client.options.mainTitle;
if ((mainTitle) || (mainTitle === "")) {
@@ -2897,9 +3051,9 @@ Scrutari.Client.Ui.initMainTitle = function (client) {
html += "]";
}
}
- client.$title('main').html(html);
+ client.$label('mainTitle').html(html);
};
-Scrutari.Client.Ui.initFilter = function (client, target, checkedArray) {
+Scrutari.DefaultUi.initFilter = function (client, target, checkedArray) {
var done = false;
for(var i = 0, len = checkedArray.length; i < len; i++) {
var $input = client.$input(target, checkedArray[i]);
@@ -2911,4 +3065,92 @@ Scrutari.Client.Ui.initFilter = function (client, target, checkedArray) {
if (done) {
client.$button("enablePanel", target).click();
}
+};
+Scrutari.DefaultUi.filterChange = function (client) {
+ var globalFicheCount = client.scrutariMeta.getGlobalFicheCount();
+ var filterState = client.buildFilterState();
+ var filterFicheCount;
+ if (filterState.empty) {
+ filterFicheCount = client.scrutariMeta.getGlobalFicheCount();
+ } else {
+ filterFicheCount = -1;
+ }
+ client.stats.update(filterState);
+ if (!_checkFilterFicheCount("base")) {
+ if (!_checkFilterFicheCount("corpus")) {
+ if (!_checkFilterFicheCount("category")) {
+ _checkFilterFicheCount("lang");
+ }
+ }
+ }
+ _updateState("base");
+ _updateState("corpus");
+ _updateState("category");
+ _updateState("lang");
+ var filterTitlesArray = new Array();
+ _addFilterTitles("base", "_ label_base_one", "_ label_base_many");
+ _addFilterTitles("corpus", "_ label_corpus_one", "_ label_corpus_many");
+ _addFilterTitles("lang", "_ label_lang_one", "_ label_lang_many");
+ _addFilterTitles("category", "_ label_category_one", "_ label_category_many");
+ var $filterFicheCount = client.$count('stats-filter', 'update', filterFicheCount);
+ var $filterValue = client.$component($filterFicheCount, "value");
+ let filterClass = client.cssClasses.filterStat;
+ let noneClass = client.cssClasses.noneStat;
+ if (filterFicheCount === globalFicheCount) {
+ $filterValue.removeClass(filterClass).removeClass(noneClass);
+ client.$hidden('filter', 'hide');
+ } else if (filterFicheCount === 0) {
+ $filterValue.removeClass(filterClass).addClass(noneClass);
+ client.$hidden('filter', 'show');
+ } else {
+ $filterValue.addClass(filterClass).removeClass(noneClass);
+ client.$hidden('filter', 'show');
+ }
+ var $filterTitles = client.$component($filterFicheCount, "titles");
+ if (filterTitlesArray.length > 0) {
+ $filterTitles.html(filterTitlesArray.join(" | "));
+ } else {
+ $filterTitles.html("");
+ }
+ function _checkFilterFicheCount(type) {
+ var $stat = client.$({scrutariStatType: type});
+ if ($stat.length > 0) {
+ filterFicheCount = 0;
+ $stat.each(function (index, element) {
+ let key = element.dataset.scrutariStatKey;
+ filterFicheCount += client.stats.getFicheCount(type, key);
+ });
+ return true;
+ } else {
+ return false;
+ }
+ }
+ function _updateState(type) {
+ client.$({scrutariStatType: type}).each(function (index, element) {
+ var $el = $(element);
+ var key = element.dataset.scrutariStatKey;
+ var ficheCount = client.stats.getFicheCount(type, key);
+ var $statTitle = Scrutari.$parents($el, {scrutariComponent: "stat-text"});
+ let excludedPanelClass = client.cssClasses.excludedPanel;
+ if (ficheCount != element.dataset.scrutariStatDefault) {
+ if (ficheCount === 0) {
+ $el.html("");
+ $statTitle.addClass(excludedPanelClass);
+ } else {
+ $statTitle.removeClass(excludedPanelClass);
+ $el.html(client.formatNumber(ficheCount) + " / ");
+ }
+ } else {
+ $el.html("");
+ $statTitle.removeClass(excludedPanelClass);
+ }
+ });
+ }
+ function _addFilterTitles(type, oneLocKey, manyLocKey) {
+ var array = filterState.titles[type];
+ if (array.length > 0) {
+ var locKey = (array.length === 1)?oneLocKey:manyLocKey;
+ filterTitlesArray.push(client.loc(locKey) + client.loc('_ colon') + " " + array.join(", "));
+ }
+ }
};
\ No newline at end of file