Toggle media thumbnail selection based on insert type
authorMatthias Schmidt <gravatronics@live.com>
Tue, 5 Jul 2016 18:51:17 +0000 (20:51 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 5 Jul 2016 18:51:20 +0000 (20:51 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Editor.js

index e18ec177d24eeafdc6c5e9cee0ceb6281f8920a1..d0b6fe44ec47654d111489bcd1dbbbd93f35dad5 100644 (file)
@@ -76,7 +76,7 @@ define(['Core', 'Dictionary', 'Dom/Traverse', 'Language', 'Ui/Dialog', 'WoltLab/
                                        + '</select>'
                                + '</dd>'
                        + '</dl>' : '')
-                       + '<dl>'
+                       + '<dl class="thumbnailSizeSelection">'
                                + '<dt>' + Language.get('wcf.media.insert.imageSize') + '</dt>'
                                + '<dd>'
                                        + '<select name="thumbnailSize">'
@@ -97,6 +97,20 @@ define(['Core', 'Dictionary', 'Dom/Traverse', 'Language', 'Ui/Dialog', 'WoltLab/
                                                        onClose: this._editorClose.bind(this),
                                                        onSetup: function(content) {
                                                                elByClass('buttonPrimary', content)[0].addEventListener(WCF_CLICK_EVENT, this._insertMedia.bind(this));
+                                                               
+                                                               // toggle thumbnail size selection based on selected insert type
+                                                               var insertType = elBySel('select[name=insertType]', content);
+                                                               if (insertType !== null) {
+                                                                       var thumbnailSelection = elByClass('thumbnailSizeSelection', content)[0];
+                                                                       insertType.addEventListener('change', function(event) {
+                                                                               if (event.currentTarget.value === 'gallery') {
+                                                                                       elHide(thumbnailSelection);
+                                                                               }
+                                                                               else {
+                                                                                       elShow(thumbnailSelection);
+                                                                               }
+                                                                       });
+                                                               }
                                                        }.bind(this),
                                                        title: Language.get('wcf.media.insert')
                                                },