From 6f823c643cd0b94794332f0c9527bbf5af415e90 Mon Sep 17 00:00:00 2001 From: Stefano Bagnara Date: Sat, 21 May 2022 12:21:26 +0200 Subject: [PATCH] data-ko-height (extresizable) now supports the min/max options from the linked integer widget definition. --- src/js/bindings/extresizable.js | 11 +++++------ src/js/converter/parser.js | 7 ++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/js/bindings/extresizable.js b/src/js/bindings/extresizable.js index 2197da9a2..486e6f289 100644 --- a/src/js/bindings/extresizable.js +++ b/src/js/bindings/extresizable.js @@ -19,6 +19,11 @@ // Simple Resizable Implementation // binding that updates (function or observable) ko.bindingHandlers.extresizable = { + options: { + minHeight: 2, + maxHeight: 1000, + autoHide: false + }, init: function(element, valueAccessor, allBindingsAccessor, data, bindingContext) { var value = unwrap(valueAccessor()) || {}, options = value.options || {}, @@ -33,10 +38,6 @@ //get reference to drop method value = "data" in value ? value.data : valueAccessor(); - // TODO we probably should get this from parameters - options.minHeight = 2; - options.maxHeight = 1000; - options.autoHide = false; // options.helper = $("
"); // options.ghost = true; options.start = function(event, ui) { @@ -94,8 +95,6 @@ }); } - }, - options: { } }; diff --git a/src/js/converter/parser.js b/src/js/converter/parser.js index 5b8b98a97..4ba9c2caa 100644 --- a/src/js/converter/parser.js +++ b/src/js/converter/parser.js @@ -167,7 +167,12 @@ var processBlock = function(element, defs, themeUpdater, blockPusher, templateUr // var bindingValue = bindingProvider(heightVar, value, false, 'wysiwyg'); var bindingValue = bindingProvider(heightVar); - var resizingBinding = "extresizable: { data: " + bindingValue + ", options: { handles: 's', resizing: $root.resizing } }, attr: { 'data-size': ko.utils.unwrapObservable(" + bindingValue + ")+'px' } "; + + var resizableOptions = ''; + if (typeof defs[bindingValue] !== 'undefined' && typeof defs[bindingValue]._min !== 'undefined') resizableOptions += ', minHeight: '+defs[bindingValue]._min; + if (typeof defs[bindingValue] !== 'undefined' && typeof defs[bindingValue]._max !== 'undefined') resizableOptions += ', maxHeight: '+defs[bindingValue]._max; + + var resizingBinding = "extresizable: { data: " + bindingValue + ", options: { handles: 's'" + resizableOptions + ", resizing: $root.resizing } }, attr: { 'data-size': ko.utils.unwrapObservable(" + bindingValue + ")+'px' } "; var resizingDiv = $('
')[0]; domutils.setAttribute(resizingDiv, 'data-bind', resizingBinding);