diff options
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/imageviewer.js | 4 | ||||
-rw-r--r-- | javascript/ui.js | 39 |
2 files changed, 41 insertions, 2 deletions
diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index 95b8108d..880f1183 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -70,8 +70,8 @@ function showGalleryImage(){ e.style.cursor='pointer' e.addEventListener('click', function (evt) { - showModal(evt) - + if(!opts.js_modal_lightbox) return; + showModal(evt) },true); } }); diff --git a/javascript/ui.js b/javascript/ui.js index c39e96a1..f3860d2e 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -59,3 +59,42 @@ function ask_for_style_name(_, prompt_text, negative_prompt_text) { name_ = prompt('Style name:') return name_ === null ? [null, null, null]: [name_, prompt_text, negative_prompt_text] } + +opts = {} +function apply_settings(jsdata){ + console.log(jsdata) + + opts = JSON.parse(jsdata) + + return jsdata +} + +onUiUpdate(function(){ + if(Object.keys(opts).length != 0) return; + + json_elem = gradioApp().getElementById('settings_json') + if(json_elem == null) return; + + textarea = json_elem.querySelector('textarea') + jsdata = textarea.value + opts = JSON.parse(jsdata) + + + Object.defineProperty(textarea, 'value', { + set: function(newValue) { + var valueProp = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value'); + var oldValue = valueProp.get.call(textarea); + valueProp.set.call(textarea, newValue); + + if (oldValue != newValue) { + opts = JSON.parse(textarea.value) + } + }, + get: function() { + var valueProp = Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, 'value'); + return valueProp.get.call(textarea); + } + }); + + json_elem.parentElement.style.display="none" +}) |