VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-form__js__dom__IdentTextInput.js
/*** module: node_modules/absol-form/js/dom/IdentTextInput.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _FCore = _interopRequireWildcard(require("../core/FCore"));

var _Text = require("absol/src/HTML5/Text");

var _stringFormat = require("absol/src/String/stringFormat");



/***
 * @augments HTMLInputElement
 * @augments AElement
 * @augments PreInput
 * @constructor
 */
function IdentTextInput() {
  this.on('keydown', this.eventHandler.identTextKeyDown).on('paste', this.applyData ? this.eventHandler.identTextPaste : this.eventHandler.identTextPaste1);
}

IdentTextInput.tag = 'IdentTextInput'.toLowerCase();

IdentTextInput.render = function () {
  return (0, _FCore._)('input[type="text"]');
};

IdentTextInput.eventHandler = {};

IdentTextInput.prototype.getSelectionStart = function () {
  var start = 0;

  if (this.getSelectPosition) {
    start = this.getSelectPosition().start;
  } else {
    if (this.selectionStart || this.selectionStart === 0) start = this.selectionStart;
  }

  return start;
};

IdentTextInput.prototype.getSelectionEnd = function () {
  var start = 0;

  if (this.getSelectPosition) {
    start = this.getSelectPosition().end;
  } else {
    if (this.selectionEnd || this.selectionEnd === 0) start = this.selectionEnd;
  }

  return start;
};

IdentTextInput.prototype._filterHistory = function () {
  if (!this.history) return;
  var temp = this.history.filter(function (t) {
    return !t.text.match(/(^[^a-zA-Z_$])|([^a-zA-Z$_0-9]+)/);
  });
  this.history.splice(0, this.history.length);
  this.history.push.apply(this.history, temp);
};

IdentTextInput.prototype._setNewText = function (text, caretPos) {
  this._filterHistory();

  if (typeof caretPos !== "number") caretPos = text.length;
  caretPos = Math.max(0, Math.min(text.length, caretPos >> 0));

  if (this.applyData) {
    this.applyData(text, {
      start: caretPos,
      end: caretPos,
      direction: 'forward'
    });
  } else {
    this.value = text;
    (0, _Text.setCaretPosition)(this, caretPos);
  }
};

IdentTextInput.eventHandler.identTextKeyDown = function (event) {
  var selectedPositionStart;
  var key = event.key;

  if (key === ' ') {
    event.preventDefault();
  } else if (key === 'Enter') {
    event.preventDefault();
    this.blur();
  } else if (key === "Escape") {
    this.value = this._prevValue || '';
    this.blur();
  } else if (!event.ctrlKey && !event.altKey && key.length === 1) {// if (key.match(/[a-zA-Z$_0-9]/)) {
    //     selectedPositionStart = this.getSelectionStart();
    //     if (selectedPositionStart === 0 && key.match(/[0-9]/)) {
    //         event.preventDefault();
    //     }
    // }
    // else {
    //     event.preventDefault();
    // }
  }

  if (!this.applyData) {
    var prevValue = this.value;
    setTimeout(function () {
      if (this.value !== prevValue) {
        this.emit('change', {}, this);
      }
    }.bind(this), 10);
  }
};

IdentTextInput.eventHandler.identTextPaste = function (event) {
  var prevValue = this.value;
  var startPos = this.getSelectionStart();
  var endPos = this.getSelectionEnd();
  setTimeout(function () {
    var newValue = this.value;
    var newEndPos = endPos + newValue.length - prevValue.length;
    var pastedText = (0, _stringFormat.nonAccentVietnamese)(newValue).substr(startPos, newEndPos - startPos).replace(/(^[^a-zA-Z_$])|([^a-zA-Z$_0-9]+)/g, '');
    var newValue1 = newValue.substr(0, startPos) + pastedText + newValue.substr(newEndPos);

    if (!newValue1 !== newValue) {
      this._setNewText(newValue1, startPos + pastedText.length);
    }
  }.bind(this), 0);
};

IdentTextInput.eventHandler.identTextPaste1 = function (event) {
  var clipboardData = event.clipboardData || window.clipboardData;
  var pastedText = clipboardData.getData('text/plain');
  var pastedText1 = (0, _stringFormat.nonAccentVietnamese)(pastedText).replace(/(^[^a-zA-Z_$])|([^a-zA-Z$_0-9]+)/g, '');

  if (pastedText !== pastedText1) {
    document.execCommand("insertText", false, pastedText1);
    event.preventDefault();
  }
};

_FCore.default.install(IdentTextInput);

var _default = IdentTextInput; // Core

exports.default = _default;

VaKeR 2022