var SCRUTARI_HTML = {
_name:'none',
structure:{
'area-input':'
',
'area-result':' {{result-subsearch}}
{{result-poweredby}}
',
'panel-base':'
',
'panel-category':'
',
'panel-corpus':'
',
'panel-lang':'
',
'panel-options':'',
'area-parameters':' {{panel-options}} {{panel-corpus}} {{panel-base}} {{panel-lang}} {{panel-category}}
',
'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':'',
'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':'
',
'categoryfichedisplay':' {{for array}} category.phraseMap.description}}"{{/if}} data-scrutari-category="{{:category.name}}"> {{>category.title}} ({{:fichestat}}) {{/for}}
{{for array}} {{/for}}',
'corpus':'
',
'emptyfichedisplay':'{{>~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}}',
'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}} ',
'ficheloading':' {{>~scrutari_loc(\'_ loading_pagination\')}}',
'history':'
',
'lang':'
',
'tabs':'',
'uniquefichedisplay':' '
}
};
/* global Scrutari */
function SCRUTARI_FRAMEWORKINIT (scrutariClient) {
scrutariClient.functions.modalAction = function ($modal, action) {
switch(action) {
case 'show':
if (!$modal.data("overlayId")) {
var overlayId = Scrutari.Overlay.start({
header: $modal.children("header").html(),
content: $modal.children("div").html(),
footer: $modal.children("footer").html(),
closeTooltip: scrutariClient.loc("_ button_close"),
afterEnd: function () {
$modal.data("overlayId", null);
}
});
$modal.data("overlayId", overlayId);
}
break;
case 'hide':
Scrutari.Overlay.end($modal);
break;
}
};
}
Scrutari.Overlay = {};
Scrutari.Overlay.idNumber = 1;
Scrutari.Overlay.activeInfoArray = new Array();
$(document).on('keydown.overlay', function(event) {
if (event.which === 27) {
var length = Scrutari.Overlay.activeInfoArray.length;
if (length > 0) {
var overlayInfo = Scrutari.Overlay.activeInfoArray[length - 1];
if (overlayInfo.escapeClose) {
Scrutari.Overlay.end(overlayInfo.overlayId);
}
}
}
});
Scrutari.Overlay.Info = function (overlayId, escapeClose) {
this.overlayId = overlayId;
this.escapeClose = escapeClose;
};
Scrutari.Overlay.start = function (settings) {
var closeTooltip = "Close";
if (settings.closeTooltip) {
closeTooltip = settings.closeTooltip;
}
var overlayIdNumber = Scrutari.Overlay.idNumber;
Scrutari.Overlay.idNumber++;
var overlayId = "none-overlay_" + overlayIdNumber;
Scrutari.Overlay.activeInfoArray.push(new Scrutari.Overlay.Info(overlayId, _checkSetting("escapeClose")));
var $overlayBlocker = $("").attr("id", overlayId).attr("class", _getClass("Blocker")).attr("data-role", "overlay");
var $overlayDialog = $("").attr("class", _getClass("Dialog")).appendTo($overlayBlocker);
$overlayDialog.data("overlayId", overlayId);
$("body")
.append($overlayBlocker)
.css('overflow','hidden');
var overlayBody = _getDiv("Header") + _getDiv("Content") + _getDiv("Footer");
var includeForm = false;
if (settings.formAttrs || settings.ajaxForm || settings.formSubmit) {
includeForm = true;
var $form = $("");
if (settings.formAttrs) {
for(var prop in settings.formAttrs) {
$form.attr(prop, settings.formAttrs[prop]);
}
}
if (settings.ajaxForm) {
var initialBeforeSubmit = settings.ajaxForm.beforeSubmit;
settings.ajaxForm.beforeSubmit = function (arr, $form, options) {
if ((initialBeforeSubmit) && (initialBeforeSubmit(arr, $form, options) === false)) {
return false;
}
_startWaiting();
};
var initialSuccess = settings.ajaxForm.success;
settings.ajaxForm.success = function (data, textStatus, jqXHR, $form) {
_endWaiting();
initialSuccess(data, textStatus, jqXHR, $form);
};
$form.ajaxForm(settings.ajaxForm);
} else if (settings.formSubmit) {
$form.submit(function () {
return settings.formSubmit($(this));
});
}
$overlayDialog.append($form.html(overlayBody));
$form.data("overlayId", overlayId);
} else {
$overlayDialog.html(overlayBody);
}
_setContent("Header", settings.header);
_setContent("Content", settings.content);
_setContent("Footer", settings.footer);
var clickClose = _checkSetting("clickClose");
var showClose = _checkSetting("showClose");
$overlayBlocker
.click(function() {
if (clickClose) {
Scrutari.Overlay.end(overlayId);
}
})
.data("beforeEnd", settings.beforeEnd)
.data("afterEnd", settings.afterEnd)
.css("z-index", 10000 + overlayIdNumber);
if (showClose) {
$overlayDialog
.append("")
.on("click.overlay", "[data-role='close']", function () {
Scrutari.Overlay.end(overlayId);
});
}
$overlayDialog
.click(function (event) {
event.stopPropagation();
});
if (settings.isWaiting) {
_startWaiting();
}
$overlayBlocker.fadeIn(function () {
$overlayDialog.show();
if (settings.afterStart) {
settings.afterStart($overlayDialog);
} else if (includeForm) {
$overlayDialog.find(":input").filter("[type!='hidden']").first().trigger("focus");
}
});
return overlayId;
function _checkSetting(propName) {
if (settings.hasOwnProperty(propName)) {
return settings[propName];
}
return true;
}
function _setContent (name, content) {
let $element = $("#" + _getId(name));
if (!content) {
$element.empty();
} else if (content.jquery) {
$element.empty().append(content);
} else {
$element.empty().html(content);
}
}
function _startWaiting() {
$overlayBlocker.find("[type='submit']").prop("disabled", true);
$overlayBlocker.addClass(_getClass("Waiting"));
}
function _endWaiting() {
$overlayBlocker.find("[type='submit']").prop("disabled", false);
$overlayBlocker.removeClass(_getClass("Waiting"));
}
function _getDiv(name) {
return "";
}
function _getId(name) {
return overlayId + "_" + name;
}
function _getClass(suffix) {
let prefix = "none-overlay-";
if (settings.classPrefix) {
prefix = settings.classPrefix;
}
return prefix + suffix;
}
};
Scrutari.Overlay.end = function (overlayId, callback) {
if (overlayId.jquery) {
overlayId = overlayId.data("overlayId");
}
if (!overlayId) {
return;
}
var $overlayBlocker = $("#" + overlayId);
var beforeEnd = $overlayBlocker.data("beforeEnd");
if (beforeEnd) {
var result = beforeEnd($overlayBlocker.children("div"));
if (result === false) {
return;
}
}
_pop();
$overlayBlocker.empty();
var afterEnd = $overlayBlocker.data("afterEnd");
$overlayBlocker.fadeOut(function() {
$("#" + overlayId).remove();
if ($("body").children("[data-role='overlay']").length === 0) {
$("body").css('overflow','');
}
if (afterEnd) {
afterEnd();
}
if (callback) {
callback();
}
});
function _pop() {
for(var i = 0, len = Scrutari.Overlay.activeInfoArray.length; i < len; i++) {
var overlayInfo = Scrutari.Overlay.activeInfoArray[i];
if (overlayInfo.overlayId === overlayId) {
Scrutari.Overlay.activeInfoArray.splice(i, 1);
break;
}
}
}
};