はじまりの大地

This commit is contained in:
miteruzo
2024-07-08 03:32:47 +09:00
commit c616a96f53
7749 changed files with 478270 additions and 0 deletions
@@ -0,0 +1,11 @@
/**
* Init datepicker for all date fields
*/
jQuery(function(){
jQuery('.bureaucracy__plugin .datepicker').datepicker({
dateFormat: "yy-mm-dd",
changeMonth: true,
changeYear: true
});
});
@@ -0,0 +1,84 @@
/**
* Handle display of dependent, i. e. optional fieldsets
*
* Fieldsets may be defined as dependent on the value of a certain input. In
* this case they contain a p element with the CSS class “bureaucracy_depends”.
* This p element holds a span with the class “bureaucracy_depends_fname”
* and optionally another span with “bureaucracy_depends_fvalue”. They
* specify the target input (fname) and the target value for which the fieldset
* is to be shown.
*
* This function adds onchange handlers to the relevant inputs for showing and
* heading the respective fieldsets.
*
* @author Adrian Lang <dokuwiki@cosmocode.de>
**/
jQuery(function () {
jQuery('form.bureaucracy__plugin').each(function () {
//show/hide fieldset and trigger depending children
function updateFieldset(input) {
jQuery.each(jQuery(input).data('dparray'), function (i, dp) {
var showOrHide =
input.parentNode.parentNode.style.display !== 'none' && // input/checkbox is displayed AND
((input.checked === dp.tval) || // ( checkbox is checked
(input.type !== 'checkbox' && (dp.tval === true && input.value !== '')) || // OR no checkbox, but input is set
input.value === dp.tval); // OR input === dp.tval )
dp.fset.toggle(showOrHide);
dp.fset.find('input,select')
.each(function () {
//toggle required attribute
var $inputelem = jQuery(this);
if($inputelem.hasClass('required')) {
if(showOrHide) {
$inputelem.attr('required', 'required');
} else {
$inputelem.removeAttr('required')
}
}
//update dependencies
if ($inputelem.data('dparray')) {
$inputelem.change();
}
});
});
}
//look for p (with info about controller) in depending fieldsets
jQuery('p.bureaucracy_depends', this)
.each(function () {
//get controller info
var fname = jQuery(this).find('span.bureaucracy_depends_fname').html(),
fvalue = jQuery(this).find('span.bureaucracy_depends_fvalue');
fvalue = (fvalue.length ? fvalue.html() : true);
//get controller field and add info and change event to the input that controls depending fieldset
var fieldsetinfo = {
fset: jQuery(this).parent(),
tval: fvalue
};
jQuery("label")
.has(":first-child:contains('" + fname + "')").first()
.find("select,input:last") //yesno field contains first a hidden input
.each(function () {
if (!jQuery(this).data('dparray')) {
jQuery(this).data('dparray', [fieldsetinfo]);
} else {
jQuery(this).data('dparray').push(fieldsetinfo);
}
})
.bind('change keyup', function () {
updateFieldset(this);
})
.change();
})
.hide(); //hide p.bureaucracy_depends in fieldset
});
});
+90
View File
@@ -0,0 +1,90 @@
/**
* Provides a list of matching user names while user inputs into a userpicker
*
* @author Adrian Lang <lang@cosmocode.de>
* @author Gerrit Uitslag <klapinklapin@gmail.com>
*/
jQuery(function () {
/**
* Ajax request for user suggestions
*
* @param {Object} request object, with single 'term' property
* @param {Function} response callback, argument: the data array to suggest to the user.
* @param {Function} getterm callback, argument: the request Object, returns: search term
*/
function ajaxsource(request, response, getterm) {
jQuery.getJSON(
DOKU_BASE + 'lib/exe/ajax.php', {
call: 'bureaucracy_user_field',
search: getterm(request)
}, function (data) {
response(jQuery.map(data, function (name, user) {
return {
label: name + ' (' + user + ')',
value: user
}
}))
}
);
}
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
/**
* pick one user
*/
jQuery(".userpicker").autocomplete({
source: function (request, response) {
ajaxsource(request, response, function (req) {
return req.term
})
}
});
/**
* pick one or more users
*/
jQuery(".userspicker")
// don't navigate away from the field on tab when selecting an item
.bind("keydown", function (event) {
if (event.keyCode === jQuery.ui.keyCode.TAB &&
jQuery(this).data("ui-autocomplete").menu.active) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function (request, response) {
ajaxsource(request, response, function (req) {
return extractLast(req.term)
})
},
search: function () {
// custom minLength
var term = extractLast(this.value);
return term.length >= 2;
},
focus: function () {
// prevent value inserted on focus
return false;
},
select: function (event, ui) {
var terms = split(this.value);
// remove the current input
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(", ");
return false;
}
});
});