(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 = $('
'); 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 }); })));