| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
-
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined'
- ? factory(exports)
- : typeof define === 'function' && define.amd
- ? define(['exports'], factory)
- : (global = global || self, factory(global.adminlte = {}));
- // ReSharper disable once ThisInGlobalContext
- }(this,
- (function (exports) {
- 'use strict';
- var abp = window.abp || {};
- var SeparateBar;
-
- SeparateBar = function ($) {
- var NAME = 'SeparateBar';
- var DATA_KEY = 'iwb.separate_bar';
- var EVENT_KEY = "." + DATA_KEY;
- var JQUERY_NO_CONFLICT = $.fn[NAME];
- var ClassNames =
- {
- VerticalLine: 'VerticalLine',
- HorizontalLine: 'HorizontalLine'
- }
- var ALLOW_METHOD = [
- 'isShow'
- ];
- var Default = {
- direction: 'V',
- //moveDom: "",
- move2Dom: "",
- borderStyle: "",
- mouseMoveDom: "body",
- moveEvent: function (moveDom, mouseMoveDom, move2Dom) { }
- }
- var SeparateBar = function () {
- function SeparateBar(element, config) {
- this._element = element;
- this._config = config;
- this.isMouseDown = false;
- this.createDom = null;
- $.metPageCss("/Content/css/separateBar.css", "separateBar-css");
- this._init();
- }
- var _proto = SeparateBar.prototype;
- _proto._init = function () {
- var _this = this, $this = $(_this._element);
- this._create();
- }
- _proto._create = function () {
- var option = this._config;
- var direction = option.direction;
- let $moveDom =
- $(this._element); //typeof (option.moveDom) === 'string' ? $('#' + option.moveDom) : $(option.moveDom);
- let $move2Dom = typeof (option.move2Dom) === 'string'
- ? $('#' + option.move2Dom)
- : $(option.move2Dom);
- var $mouseMoveDom = typeof (option.mouseMoveDom) === 'string'
- ? (option.mouseMoveDom === 'body' ? $('' + option.mouseMoveDom) : $('#' + option.mouseMoveDom))
- : $(option.mouseMoveDom);
- if ($moveDom.css("position") !== "relative") {
- $moveDom.css("position", "relative");
- }
- var $reDiv = $('<div>');
- if (direction === 'V') {
- $reDiv.addClass(ClassNames.VerticalLine);
- $moveDom.append($reDiv);
- this.BindEvent($moveDom, $mouseMoveDom, $move2Dom);
- }
- if (direction === 'H') {
- $reDiv.addClass(ClassNames.HorizontalLine);
- $moveDom.append($reDiv);
- this.BindEvent($moveDom, $mouseMoveDom, $move2Dom);
- }
- this.createDom = $reDiv;
- }
- _proto.isShow = function (b) {
- var _this = this;
- var $dom = $(_this.createDom);
- b ? $dom.show() : $dom.hide();
- }
- _proto.BindEvent = function ($moveDom, $mouseMoveDom, $move2Dom) {
- var isMouseDown = this.isMouseDown;
- var option = this._config;
- $moveDom.find('.' + ClassNames.VerticalLine).off('mousedown' + EVENT_KEY).on(
- 'mousedown' + EVENT_KEY,
- function () {
- isMouseDown = true;
- $moveDom.css('cursor', 'n-resize');
- });
- $mouseMoveDom.off('mousemove' + EVENT_KEY).on(
- 'mousemove' + EVENT_KEY,
- function (e) {
- if (isMouseDown) {
- let offset = $moveDom.offset();
- //let offset2 = $move2Dom.offset();
- //let upPreHeight = $moveDom.height();
- //let downPreHeight = $move2Dom.height();
- if (option.direction === 'V') {
- var upNewHeight = e.pageY - offset.top;
- $moveDom.height(upNewHeight + 'px');
- }
- if (option.direction === 'H') {
- var upNewWidth = e.pageX - offset.left;
- $moveDom.width(upNewWidth + 'px');
- }
- //var downNewHeight = downPreHeight + (upPreHeight - upNewHeight);
- //$move2Dom.height(downNewHeight + 'px');
- //upPreHeight = upNewHeight;
- //downPreHeight = downNewHeight;
- option.moveEvent($moveDom, $mouseMoveDom, $move2Dom);
- }
- });
- $mouseMoveDom.off('mouseup' + EVENT_KEY).on(
- 'mouseup' + EVENT_KEY,
- function () {
- isMouseDown = false;
- $moveDom.css('cursor', 'auto');
- });
- }
- SeparateBar._jQueryInterface = function _jQueryInterface(option) {
- var value, args = Array.prototype.slice.call(arguments, 1);
- this.each(function () {
- var $this = $(this);
- var data = $this.data(DATA_KEY);
- if (typeof option === 'string') {
- if ($.inArray(option, ALLOW_METHOD) < 0) {
- throw new Error("Unknown method: " + option);
- }
- if (!data) {
- return;
- }
- value = data[option].apply(data, args);
- }
- if (!data) {
- var options = $.extend({}, Default, $(this).data(), typeof option === 'object' && option);
- data = new SeparateBar(this, options);
- $this.data(DATA_KEY, data);
- }
- });
- return typeof value === 'undefined' ? this : value;
- };
- return SeparateBar;
- }();
- /**
- * jQuery API
- * ====================================================
- */
- $.fn[NAME] = SeparateBar._jQueryInterface;
- $.fn[NAME].Constructor = SeparateBar;
- $.fn[NAME].noConflict = function () {
- $.fn[NAME] = JQUERY_NO_CONFLICT;
- return SeparateBar._jQueryInterface;
- };
- return SeparateBar;
- }(jQuery);
-
- exports.SeparateBar = SeparateBar;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
|