Actualiza el plugin Additionals a 3.0.2-master

This commit is contained in:
Manuel Cillero 2021-03-20 11:12:56 +01:00
parent 3b6a41320c
commit cfa0d58b18
164 changed files with 2027 additions and 58190 deletions

File diff suppressed because one or more lines are too long

View file

@ -32,3 +32,61 @@ function formatFontawesomeText(icon) {
return icon.text;
}
}
/* exported observeLiveSearchField */
function observeLiveSearchField(fieldId, targetId, target_url) {
$('#'+fieldId).each(function() {
var $this = $(this);
$this.addClass('autocomplete');
$this.attr('data-search-was', $this.val());
var check = function() {
var val = $this.val();
if ($this.attr('data-search-was') != val){
$this.attr('data-search-was', val);
var form = $('#query_form'); // grab the form wrapping the search bar.
var formData;
var url;
form.find('[name="c[]"] option').each(function(i, elem) {
$(elem).attr('selected', true);
});
if (typeof target_url === 'undefined') {
url = form.attr('action');
formData = form.serialize();
} else {
url = target_url;
formData = { q: val };
}
form.find('[name="c[]"] option').each(function(i, elem) {
$(elem).attr('selected', false);
});
$.ajax({
url: url,
type: 'get',
data: formData,
success: function(data){ if(targetId) $('#'+targetId).html(data); },
beforeSend: function(){ $this.addClass('ajax-loading'); },
complete: function(){ $this.removeClass('ajax-loading'); }
});
}
};
/* see https://stackoverflow.com/questions/1909441/how-to-delay-the-keyup-handler-until-the-user-stops-typing */
var search_delay = function(callback) {
var timer = 0;
return function() {
var context = this, args = arguments;
clearTimeout(timer);
timer = setTimeout(function () {
callback.apply(context, args);
}, 400 || 0);
};
};
$this.keyup(search_delay(check));
});
}

View file

@ -1,52 +0,0 @@
// see https://github.com/splendeo/jquery.observe_field
(function($) {
'use strict';
$.fn.live_observe_field = function(frequency, callback) {
frequency = frequency * 100; // translate to milliseconds
return this.each(function() {
var $this = $(this);
var prev = $this.val();
var prevChecked = $this.prop('checked');
var check = function() {
if (removed()) {
// if removed clear the interval and don't fire the callback
if (ti)
clearInterval(ti);
return;
}
var val = $this.val();
var checked = $this.prop('checked');
if (prev != val || checked != prevChecked) {
prev = val;
prevChecked = checked;
$this.map(callback); // invokes the callback on $this
}
};
var removed = function() {
return $this.closest('html').length == 0;
};
var reset = function() {
if (ti) {
clearInterval(ti);
ti = setInterval(check, frequency);
}
};
check();
var ti = setInterval(check, frequency); // invoke check periodically
// reset counter after user interaction
$this.bind('keyup click mousemove', reset); // mousemove is for selects
});
};
})(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,16 @@
$(function() {
mermaid.initialize({ startOnLoad: true,
theme: 'default',
themeVariables: { 'fontSize': '12px' } });
if (globalThis !== undefined && globalThis.mermaidTheme !== undefined) {
var mermaidTheme = globalThis.mermaidTheme;
} else {
var mermaidTheme = 'default';
}
if (globalThis !== undefined && globalThis.mermaidThemeVariables !== undefined) {
var mermaidThemeVariables = globalThis.mermaidThemeVariables;
} else {
var mermaidThemeVariables = { 'fontSize': '12px' };
}
mermaid.initialize({
startOnLoad: true,
theme: mermaidTheme,
themeVariables: mermaidThemeVariables });
});

View file

@ -14,7 +14,7 @@ function filterAdditionalsFormatState (opt) {
function additionals_transform_to_select2(field){
var field_format = availableFilters[field]['field_format'];
var initialized_select2 = $('#tr_' + field + ' .values .select2');
if (initialized_select2.length == 0 && $.inArray(field_format, additionals_field_formats) >= 0) {
if (initialized_select2.length == 0 && (typeof additionals_field_formats !== 'undefined') && $.inArray(field_format, additionals_field_formats) >= 0) {
$('#tr_' + field + ' .toggle-multiselect').hide();
$('#tr_' + field + ' .values .value').attr('multiple', 'multiple');
$('#tr_' + field + ' .values .value').select2({
@ -32,7 +32,7 @@ function additionals_transform_to_select2(field){
},
placeholder: ' ',
minimumInputLength: 1,
width: '60%',
width: '90%',
templateResult: filterAdditionalsFormatState
}).on('select2:open', function (e) {
$(this).parent('span').find('.select2-search__field').val(' ').trigger($.Event('input', { which: 13 })).val('');
@ -168,7 +168,7 @@ function buildSelect2Options(options) {
allowClear: !!options['allow_clear'],
minimumInputLength: options['min_input_length'] || 0,
templateResult: window[options['format_state']],
width: options['width'] || '60%'
width: options['width'] || '90%'
};
addDataSourceOptions(result, options);