Skip to content

Commit

Permalink
Tidy writeDynaList() (joomla#12184)
Browse files Browse the repository at this point in the history
* Cleaned writeDynaList() in core.js

* Removed explanation comments

* removed all API changes

* updated compressed core.js
  • Loading branch information
milux authored and amone4 committed Apr 21, 2018
1 parent e59cc17 commit 8524a16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
22 changes: 7 additions & 15 deletions media/system/js/core-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,27 +534,19 @@ Joomla.editors.instances = Joomla.editors.instances || {
*/
window.writeDynaList = function ( selectParams, source, key, orig_key, orig_val, element ) {
var html = '<select ' + selectParams + '>',
hasSelection = key == orig_key,
i = 0,
selected, x, item;
hasSelection = key == orig_key, i, selected, item;

for ( x in source ) {
if (!source.hasOwnProperty(x)) { continue; }

item = source[ x ];
for (i = 0 ; i < source.length; i++) {
item = source[ i ];

if ( item[ 0 ] != key ) { continue; }

selected = '';
selected = hasSelection ? orig_val == item[ 1 ] : i === 0;

if ( ( hasSelection && orig_val == item[ 1 ] ) || ( !hasSelection && i === 0 ) ) {
selected = 'selected="selected"';
}

html += '<option value="' + item[ 1 ] + '" ' + selected + '>' + item[ 2 ] + '</option>';

i++;
html += '<option value="' + item[ 1 ] + '"' + (selected ? ' selected="selected"' : '') + '>'
+ item[ 2 ] + '</option>';
}

html += '</select>';

if (element) {
Expand Down
17 changes: 16 additions & 1 deletion media/system/js/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8524a16

Please sign in to comment.