Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ready] [medium] Fix various issues with listelements and fabrikmodalrepeat form fields. #1960

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var FabrikModalRepeat = new Class({
this.field[id] = target.getNext('input');
if (!c) {
// Joomla 3
c = target.getParent('div.control-group');
c = document.id(this.elid);
}
this.origContainer = c;
tbl = c.getElement('table');
Expand Down Expand Up @@ -233,7 +233,8 @@ var FabrikModalRepeat = new Class({
// Chosen reset
clone.getElements('select').removeClass('chzn-done').show();

// Assign random id
// Sophist - Chosen is only active on open modals - rows already have unique ids
// and this may be screwing up finding the elements to update options
clone.getElements('select').each(function (c) {
c.id = c.id + '_' + (Math.random() * 10000000).toInt();
});
Expand Down
29 changes: 15 additions & 14 deletions administrator/components/com_fabrik/models/fields/listfields.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var ListFieldsElement = new Class({
}.bind(this));
} else {
if (typeOf(document.id(this.options.conn)) === 'null') {
this.cnnperiodical = this.getCnn.periodical(500, this);
this.cnnperiodical = this.getCnn.periodical(100, this);
} else {
this.setUp();
}
Expand Down Expand Up @@ -99,6 +99,8 @@ var ListFieldsElement = new Class({
this.el = document.id(this.el);
if (this.options.mode === 'gui') {
this.select = this.el.getParent().getElement('select.elements');
var len = this.el.value.length;
this.setSelection(this.el, len, len);
}

document.id(this.options.conn).addEvent('change', function () {
Expand All @@ -111,7 +113,7 @@ var ListFieldsElement = new Class({
// See if there is a connection selected
var v = document.id(this.options.conn).get('value');
if (v !== '' && v !== -1) {
this.periodical = this.updateMe.periodical(500, this);
this.periodical = this.updateMe.periodical(100, this);
}
this.watchAdd();
},
Expand All @@ -120,10 +122,11 @@ var ListFieldsElement = new Class({
if (this.addWatched === true) {
return;
}
console.log('watch add', this);
this.addWatched = true;
var add = this.el.getParent().getElement('button');

// Sophist: Unclear why we do this on mousedown rather than click but unwilling
// to change to click until it is clear that there won't be consequences
if (typeOf(add) !== 'null') {
add.addEvent('mousedown', function (e) {
e.stop();
Expand Down Expand Up @@ -165,7 +168,7 @@ var ListFieldsElement = new Class({
var els;

// Googlemap inside repeat group & modal repeat
if (typeOf(document.id(this.strEl)) !== null) {
if (typeOf(document.id(this.strEl)) !== 'null') {
this.el = document.id(this.strEl);
}
if (this.options.mode === 'gui') {
Expand Down Expand Up @@ -286,19 +289,17 @@ var ListFieldsElement = new Class({

insertTextAtCaret: function (el, text) {
var pos = this.getInputSelection(el).end;
var val = el.value;
// Intelligent insertion e.g. on databasejoin / advanced / add description adding whitespace as appropriate depending on caret position
if (pos != 0 && val.substring(pos-1,1) != ' ') {
text = ' ' + text;
}
if (pos != val.length && val.substring(pos,1) != ' ') {
text += ' ';
}
var newPos = pos + text.length;
var val = el.value;
el.value = val.slice(0, pos) + text + val.slice(pos);
this.setSelection(el, newPos, newPos);
}
});



/*
function insertTextAtCaret(el, text) {

}

var textarea = document.getElementById("your_textarea");
insertTextAtCaret(textarea, "[INSERTED]");*/