| Línea 270... |
Línea 270... |
| 270 |
/**
|
270 |
/**
|
| 271 |
* Called (from PHP) to initialise the plugin. Should usually not be
|
271 |
* Called (from PHP) to initialise the plugin. Should usually not be
|
| 272 |
* overridden by child plugin.
|
272 |
* overridden by child plugin.
|
| 273 |
*
|
273 |
*
|
| 274 |
* @method init
|
274 |
* @method init
|
| 275 |
* @param {String} component Component name e.g. 'availability_date'
|
275 |
* @param {String} component Component name e.g. 'availability_date'.
|
| - |
|
276 |
* @param {boolean} allowAdd Indicates whether adding new instances of the plugin is permitted.
|
| - |
|
277 |
* @param {Object} params Additional parameters.
|
| - |
|
278 |
* @param {boolean} displayMode Whether the eye icon is show or hide. True for "Hide", false for "Show".
|
| 276 |
*/
|
279 |
*/
|
| 277 |
init: function(component, allowAdd, params) {
|
280 |
init: function(component, allowAdd, params, displayMode) {
|
| 278 |
var name = component.replace(/^availability_/, '');
|
281 |
var name = component.replace(/^availability_/, '');
|
| 279 |
this.allowAdd = allowAdd;
|
282 |
this.allowAdd = allowAdd;
|
| 280 |
M.core_availability.form.plugins[name] = this;
|
283 |
M.core_availability.form.plugins[name] = this;
|
| 281 |
this.initInner.apply(this, params);
|
284 |
this.initInner.apply(this, params);
|
| - |
|
285 |
this.displayMode = displayMode;
|
| 282 |
},
|
286 |
},
|
| Línea 283... |
Línea 287... |
| 283 |
|
287 |
|
| 284 |
/**
|
288 |
/**
|
| 285 |
* Init method for plugin to override. (Default does nothing.)
|
289 |
* Init method for plugin to override. (Default does nothing.)
|
| Línea 371... |
Línea 375... |
| 371 |
this.node = Y.Node.create('<div class="availability-list"><h3 class="accesshide"></h3>' +
|
375 |
this.node = Y.Node.create('<div class="availability-list"><h3 class="accesshide"></h3>' +
|
| 372 |
'<div class="availability-inner">' +
|
376 |
'<div class="availability-inner">' +
|
| 373 |
'<div class="availability-header mb-1"><span>' +
|
377 |
'<div class="availability-header mb-1"><span>' +
|
| 374 |
M.util.get_string('listheader_sign_before', 'availability') + '</span>' +
|
378 |
M.util.get_string('listheader_sign_before', 'availability') + '</span>' +
|
| 375 |
' <label><span class="accesshide">' + M.util.get_string('label_sign', 'availability') +
|
379 |
' <label><span class="accesshide">' + M.util.get_string('label_sign', 'availability') +
|
| 376 |
' </span><select class="availability-neg custom-select mx-1"' +
|
380 |
' </span><select class="availability-neg form-select mx-1"' +
|
| 377 |
' title="' + M.util.get_string('label_sign', 'availability') + '">' +
|
381 |
' title="' + M.util.get_string('label_sign', 'availability') + '">' +
|
| 378 |
'<option value="">' + M.util.get_string('listheader_sign_pos', 'availability') + '</option>' +
|
382 |
'<option value="">' + M.util.get_string('listheader_sign_pos', 'availability') + '</option>' +
|
| 379 |
'<option value="!">' + M.util.get_string('listheader_sign_neg', 'availability') + '</option></select></label> ' +
|
383 |
'<option value="!">' + M.util.get_string('listheader_sign_neg', 'availability') + '</option></select></label> ' +
|
| 380 |
'<span class="availability-single">' + M.util.get_string('listheader_single', 'availability') + '</span>' +
|
384 |
'<span class="availability-single">' + M.util.get_string('listheader_single', 'availability') + '</span>' +
|
| 381 |
'<span class="availability-multi">' + M.util.get_string('listheader_multi_before', 'availability') +
|
385 |
'<span class="availability-multi">' + M.util.get_string('listheader_multi_before', 'availability') +
|
| 382 |
' <label><span class="accesshide">' + M.util.get_string('label_multi', 'availability') + ' </span>' +
|
386 |
' <label><span class="accesshide">' + M.util.get_string('label_multi', 'availability') + ' </span>' +
|
| 383 |
'<select class="availability-op custom-select mx-1"' +
|
387 |
'<select class="availability-op form-select mx-1"' +
|
| 384 |
' title="' + M.util.get_string('label_multi', 'availability') + '"><option value="&">' +
|
388 |
' title="' + M.util.get_string('label_multi', 'availability') + '"><option value="&">' +
|
| 385 |
M.util.get_string('listheader_multi_and', 'availability') + '</option>' +
|
389 |
M.util.get_string('listheader_multi_and', 'availability') + '</option>' +
|
| 386 |
'<option value="|">' + M.util.get_string('listheader_multi_or', 'availability') + '</option></select></label> ' +
|
390 |
'<option value="|">' + M.util.get_string('listheader_multi_or', 'availability') + '</option></select></label> ' +
|
| 387 |
M.util.get_string('listheader_multi_after', 'availability') + '</span></div>' +
|
391 |
M.util.get_string('listheader_multi_after', 'availability') + '</span></div>' +
|
| 388 |
'<div class="availability-children"></div>' +
|
392 |
'<div class="availability-children"></div>' +
|
| Línea 756... |
Línea 760... |
| 756 |
width: '450px'
|
760 |
width: '450px'
|
| 757 |
};
|
761 |
};
|
| 758 |
dialogRef.dialog = new M.core.dialogue(config);
|
762 |
dialogRef.dialog = new M.core.dialogue(config);
|
| 759 |
dialogRef.dialog.show();
|
763 |
dialogRef.dialog.show();
|
| 760 |
cancel.on('click', function() {
|
764 |
cancel.on('click', function() {
|
| 761 |
dialogRef.dialog.destroy();
|
765 |
dialogRef.dialog.hide();
|
| 762 |
// Focus the button they clicked originally.
|
766 |
// Focus the button they clicked originally.
|
| 763 |
this.inner.one('> .availability-button').one('button').focus();
|
767 |
this.inner.one('> .availability-button').one('button').focus();
|
| 764 |
}, this);
|
768 |
}, this);
|
| 765 |
};
|
769 |
};
|
| Línea 774... |
Línea 778... |
| 774 |
* @return {Function} Add handler function to call when adding that thing
|
778 |
* @return {Function} Add handler function to call when adding that thing
|
| 775 |
*/
|
779 |
*/
|
| 776 |
M.core_availability.List.prototype.getAddHandler = function(type, dialogRef) {
|
780 |
M.core_availability.List.prototype.getAddHandler = function(type, dialogRef) {
|
| 777 |
return function() {
|
781 |
return function() {
|
| 778 |
var newItem;
|
782 |
var newItem;
|
| - |
|
783 |
var displayMode = true;
|
| - |
|
784 |
// Check if we have changed the eye icon in the manage restriction to hidden.
|
| - |
|
785 |
if (type && M.core_availability.form.plugins[type].displayMode) {
|
| - |
|
786 |
displayMode = false;
|
| - |
|
787 |
}
|
| 779 |
if (type) {
|
788 |
if (type) {
|
| 780 |
// Create an Item object to represent the child.
|
789 |
// Create an Item object to represent the child.
|
| 781 |
newItem = new M.core_availability.Item({type: type, creating: true}, this.root);
|
790 |
newItem = new M.core_availability.Item({type: type, creating: true, showc: displayMode}, this.root);
|
| 782 |
} else {
|
791 |
} else {
|
| 783 |
// Create a new List object to represent the child.
|
792 |
// Create a new List object to represent the child.
|
| 784 |
newItem = new M.core_availability.List({c: [], showc: true}, false, this.root);
|
793 |
newItem = new M.core_availability.List({c: [], showc: displayMode}, false, this.root);
|
| 785 |
}
|
794 |
}
|
| 786 |
// Add to list.
|
795 |
// Add to list.
|
| 787 |
this.addChild(newItem);
|
796 |
this.addChild(newItem);
|
| 788 |
// Update the form and list HTML.
|
797 |
// Update the form and list HTML.
|
| 789 |
M.core_availability.form.update();
|
798 |
M.core_availability.form.update();
|
| 790 |
M.core_availability.form.rootList.renumber();
|
799 |
M.core_availability.form.rootList.renumber();
|
| 791 |
this.updateHtml();
|
800 |
this.updateHtml();
|
| 792 |
// Hide dialog.
|
801 |
// Hide dialog.
|
| 793 |
dialogRef.dialog.destroy();
|
802 |
dialogRef.dialog.hide();
|
| 794 |
newItem.focusAfterAdd();
|
803 |
newItem.focusAfterAdd();
|
| 795 |
};
|
804 |
};
|
| 796 |
};
|
805 |
};
|
| Línea 797... |
Línea 806... |
| 797 |
|
806 |
|