-
Notifications
You must be signed in to change notification settings - Fork 151
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
Support batch requested moves #1888
Open
nardog
wants to merge
8
commits into
wikimedia-gadgets:master
Choose a base branch
from
nardog:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6546d15
Update morebits.js
nardog 05b0d1e
Update morebits.js
nardog 3f34791
Update twinklexfd.js
nardog 4f12885
Update twinklexfd.js
nardog 3cf651a
Update twinklexfd.js
nardog dfd0b73
Update twinklexfd.js
nardog 98690bb
Update morebits.js
nardog efca3a1
Update twinklexfd.js
nardog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -353,7 +353,7 @@ Morebits.quickForm.prototype.append = function QuickFormAppend(data) { | |
* - `number`: A number input box. | ||
* - Attributes: Everything the text `input` has, as well as: min, max, step, list | ||
* - `dyninput`: A set of text boxes with "Remove" buttons and an "Add" button. | ||
* - Attributes: name, label, min, max, sublabel, value, size, maxlength, event | ||
* - Attributes: name, label, min, max, inputs, sublabel, value, size, maxlength, event | ||
* - `hidden`: An invisible form field. | ||
* - Attributes: name, value | ||
* - `header`: A level 5 header. | ||
|
@@ -371,7 +371,7 @@ Morebits.quickForm.prototype.append = function QuickFormAppend(data) { | |
* There is some difference on how types handle the `label` attribute: | ||
* - `div`, `select`, `field`, `checkbox`/`radio`, `input`, `textarea`, `header`, and `dyninput` can accept an array of items, | ||
* and the label item(s) can be `Element`s. | ||
* - `option`, `optgroup`, `_dyninput_element`, `submit`, and `button` accept only a single string. | ||
* - `option`, `optgroup`, `_dyninput_cell`, `submit`, and `button` accept only a single string. | ||
* | ||
* @memberof Morebits.quickForm | ||
* @class | ||
|
@@ -730,14 +730,17 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute( | |
var moreButton = more[1]; | ||
|
||
var sublist = { | ||
type: '_dyninput_element', | ||
label: data.sublabel || data.label, | ||
name: data.name, | ||
value: data.value, | ||
size: data.size, | ||
type: '_dyninput_row', | ||
remove: false, | ||
maxlength: data.maxlength, | ||
event: data.event | ||
event: data.event, | ||
inputs: data.inputs || [{ | ||
// compatibility | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding, what's going on with the compatibility sub-section here? |
||
label: data.sublabel || data.label, | ||
name: data.name, | ||
value: data.value, | ||
size: data.size | ||
}] | ||
}; | ||
|
||
for (i = 0; i < min; ++i) { | ||
|
@@ -753,31 +756,13 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute( | |
moreButton.max = max - min; | ||
moreButton.counter = 0; | ||
break; | ||
case '_dyninput_element': // Private, similar to normal input | ||
case '_dyninput_row': // Private | ||
node = document.createElement('div'); | ||
|
||
if (data.label) { | ||
label = node.appendChild(document.createElement('label')); | ||
label.appendChild(document.createTextNode(data.label)); | ||
label.setAttribute('for', id); | ||
label.style.marginRight = '3px'; | ||
} | ||
|
||
subnode = node.appendChild(document.createElement('input')); | ||
if (data.value) { | ||
subnode.setAttribute('value', data.value); | ||
} | ||
subnode.setAttribute('name', data.name); | ||
subnode.setAttribute('type', 'text'); | ||
if (data.size) { | ||
subnode.setAttribute('size', data.size); | ||
} | ||
if (data.maxlength) { | ||
subnode.setAttribute('maxlength', data.maxlength); | ||
} | ||
if (data.event) { | ||
subnode.addEventListener('keyup', data.event, false); | ||
} | ||
data.inputs.forEach(function(subdata) { | ||
var cell = new Morebits.quickForm.element($.extend(subdata, { type: '_dyninput_cell' })); | ||
node.appendChild(cell.render()); | ||
}); | ||
if (data.remove) { | ||
var remove = this.compute({ | ||
type: 'button', | ||
|
@@ -800,6 +785,41 @@ Morebits.quickForm.element.prototype.compute = function QuickFormElementCompute( | |
removeButton.morebutton = data.morebutton; | ||
} | ||
break; | ||
case '_dyninput_cell': // Private, similar to normal input | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for my understanding, why did this case move down? |
||
node = document.createElement('span'); | ||
|
||
if (data.label) { | ||
label = node.appendChild(document.createElement('label')); | ||
label.appendChild(document.createTextNode(data.label)); | ||
label.setAttribute('for', id + '_input'); | ||
label.style.marginRight = '3px'; | ||
} | ||
|
||
subnode = node.appendChild(document.createElement('input')); | ||
subnode.setAttribute('id', id + '_input'); | ||
if (data.value) { | ||
subnode.setAttribute('value', data.value); | ||
} | ||
subnode.setAttribute('name', data.name); | ||
subnode.setAttribute('type', 'text'); | ||
subnode.setAttribute('data-dyninput', 'data-dyninput'); | ||
if (data.size) { | ||
subnode.setAttribute('size', data.size); | ||
} | ||
if (data.maxlength) { | ||
subnode.setAttribute('maxlength', data.maxlength); | ||
} | ||
if (data.required) { | ||
subnode.setAttribute('required', 'required'); | ||
} | ||
if (data.disabled) { | ||
subnode.setAttribute('required', 'disabled'); | ||
} | ||
if (data.event) { | ||
subnode.addEventListener('keyup', data.event, false); | ||
} | ||
node.style.marginRight = '3px'; | ||
break; | ||
case 'hidden': | ||
node = document.createElement('input'); | ||
node.setAttribute('type', 'hidden'); | ||
|
@@ -979,7 +999,12 @@ Morebits.quickForm.getInputData = function(form) { | |
break; | ||
case 'text': // falls through | ||
case 'textarea': | ||
result[fieldNameNorm] = field.value.trim(); | ||
if (field.dataset.dyninput) { | ||
result[fieldNameNorm] = result[fieldNameNorm] || []; | ||
result[fieldNameNorm].push(field.value.trim()); | ||
} else { | ||
result[fieldNameNorm] = field.value.trim(); | ||
} | ||
break; | ||
default: // could be select-one, date, number, email, etc | ||
if (field.value) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my understanding, what does _dyninput_cell do and why did its name change?