فهرست منبع

[core] Add KO binding for selecting content with one click

By adding data-bind="oneClickSelect" the user will be able to select all the contents of that element with one click.
Johan Åhlén 10 سال پیش
والد
کامیت
c05366d
1فایلهای تغییر یافته به همراه15 افزوده شده و 0 حذف شده
  1. 15 0
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

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

@@ -630,6 +630,21 @@ ko.bindingHandlers.daterangepicker = {
   }
 }
 
+ko.bindingHandlers.oneClickSelect = {
+  init: function (element) {
+    $(element).click(function() {
+      if (document.selection) {
+        var range = document.body.createTextRange();
+        range.moveToElementText(element);
+        range.select();
+      } else if (window.getSelection) {
+        var range = document.createRange();
+        range.selectNode(element);
+        window.getSelection().addRange(range);
+      }
+    });
+  }
+};
 
 ko.bindingHandlers.augmenthtml = {
   render: function (element, valueAccessor, allBindingsAccessor, viewModel) {