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-acomp__js__TabBar.js
/*** module: node_modules/absol-acomp/js/TabBar.js ***/
"use strict";

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

require("../css/tabview.css");

var _ACore = _interopRequireDefault(require("../ACore"));

var _TabButton = _interopRequireDefault(require("./TabButton"));


var _ = _ACore.default._;
var $ = _ACore.default.$;
/***
 * @extends HScroller
 * @constructor
 */

function TabBar() {
  this.$parent = null;
  this.$addBtn = _({
    tag: 'button',
    class: 'as-tab-bar-add-btn',
    child: 'span.mdi.mdi-plus',
    on: {
      click: function () {
        if (this.$parent) {
          this.$parent.emit('pressaddtab', {
            type: 'pressaddtab',
            target: this.$parent
          }, this.$parent);
        }
      }.bind(this)
    }
  });
  this.addChild(this.$addBtn);
  this.defineEvent(['active', 'close']);
  this.on('wheel', function (event) {
    var lastLeft = this.$viewport.scrollLeft;

    if (event.deltaY > 1) {
      this.$viewport.scrollLeft += 50;
    } else if (event.deltaY < -1) {
      this.$viewport.scrollLeft -= 50;
    }

    if (lastLeft != this.$viewport.scrollLeft) event.preventDefault();
  });
  this._tabs = [];
}

TabBar.tag = 'tabbar';

TabBar.render = function () {
  return _('hscroller.absol-tabbar');
};

TabBar.prototype.getAllTabButtons = function () {
  var buttons = [];
  $('tabbutton', this, function (e) {
    buttons.push(e);
  });
  return buttons;
};
/***
 *
 * @param {string} ident
 * @return {TabButton}
 */


TabBar.prototype.getButtonByIdent = function (ident) {
  return $('tabbutton#tabbuton-' + ident, this);
};

TabBar.property = {};
TabBar.property.tabs = {
  set: function (value) {
    this.clearChild();
    this._tabs = [];
    (value || []).forEach(this.addTab.bind(this));
  },
  get: function () {
    //each hold item data
    return this._tabs || [];
  }
};
/***
 *
 * @param {{text}}
 * @return {tabbar}
 */

TabBar.prototype.addTab = function (value) {
  var self = this;
  var props = {};

  if (typeof value == "string") {
    props.name = value;
  } else {
    if (value.name) {
      props.name = value.name;
    } else {
      throw new Error('Tab must has name attribute');
    }

    if (value.desc) props.desc = value.desc;

    if (value.tabIcon) {
      props.icon = value.tabIcon;
    }

    if (value.preventClosing) {
      props.preventClosing = value.preventClosing;
    }
  }

  var tabButton = _({
    tag: 'tabbutton',
    props: props,
    on: {
      active: function (event, sender) {
        var prevented = false;
        self.emit('active', {
          target: this,
          value: value,
          preventDefault: function () {
            prevented = true;
          }
        }, self);

        if (!prevented) {
          self.getAllTabButtons().forEach(function (e) {
            e.active = false;
          });
          this.active = true;
        }
      },
      close: function (event, sender) {
        var prevented = false;
        self.emit('close', {
          target: this,
          value: value,
          preventDefault: function () {
            prevented = true;
          }
        }, self);

        if (!prevented) {
          //todo:active other
          this.remove();
        }
      }
    }
  });

  this.addChildBefore(tabButton, this.$addBtn);
  if (value.id) tabButton.attr('id', 'tabbuton-' + value.id);

  this._tabs.push(tabButton);

  this.requestUpdateSize();
  return tabButton;
};

TabBar.prototype.removeTab = function (id) {
  this._tabs = this._tabs.filter(function (value) {
    return value == id;
  });
  $('#tabbuton-' + id, this).remove();
  this.requestUpdateSize();
};

TabBar.prototype.activeTab = function (id) {
  var self = this;
  var activedbtn = $('.absol-tabbar-button-active', this);

  if (activedbtn && activedbtn.attr('id') != id) {
    activedbtn.active = false;
  }

  var mButton = $('#tabbuton-' + id, this);

  if (mButton) {
    mButton.active = true;
    setTimeout(function () {
      self.scrollInto(mButton);
    }, 30);
  }
};

TabBar.prototype.setModified = function (ident, flag) {
  var bt = this.getButtonByIdent(ident);

  if (bt) {
    bt.modified = flag;
  }
};

_ACore.default.install(TabBar);

var _default = TabBar;
exports.default = _default;

VaKeR 2022