Przeglądaj źródła

[assist] Add KO binding for vertical resize of assist panel panels

Johan Ahlen 10 lat temu
rodzic
commit
303caae

+ 31 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -840,6 +840,37 @@
     }
     }
   };
   };
 
 
+  ko.bindingHandlers.assistVerticalResizer = {
+    init: function (element, valueAccessor) {
+      var $resizer = $(element);
+      var $above = $resizer.prev();
+      var $below = $resizer.next();
+
+      $resizer.parent().height();
+
+      var aboveInitialHeight = ($resizer.parent().height() - $resizer.height()) / 2;
+      var belowInitialHeight = aboveInitialHeight;
+
+      $above.css("height", aboveInitialHeight + 'px');
+      $below.css("height", belowInitialHeight + 'px');
+
+      $resizer.draggable({
+        axis: "y",
+        drag: function (event, ui) {
+          var currentHeight = ui.offset.top - 81;
+          $above.css("height", currentHeight + 'px');
+          $below.css("height", ($resizer.parent().height() - currentHeight - $resizer.height()))
+          ui.offset.top = 0;
+          ui.position.top = 0;
+        },
+        stop: function (event, ui) {
+          ui.offset.top = 0;
+          ui.position.top = 0;
+        }
+      });
+    }
+  };
+
   ko.bindingHandlers.aceResizer = {
   ko.bindingHandlers.aceResizer = {
     init: function (element, valueAccessor) {
     init: function (element, valueAccessor) {
       var options = ko.unwrap(valueAccessor());
       var options = ko.unwrap(valueAccessor());