kz-ui-base 1.0.56 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/kztool/kztool.common.js +2339 -2346
- package/package.json +1 -1
package/kztool/kztool.common.js
CHANGED
|
@@ -110708,931 +110708,931 @@ module.exports = function (CONSTRUCTOR_NAME, wrapper, common) {
|
|
|
110708
110708
|
|
|
110709
110709
|
"use strict";
|
|
110710
110710
|
__webpack_require__.r(__webpack_exports__);
|
|
110711
|
-
/* WEBPACK VAR INJECTION */(function(global) {/**
|
|
110712
|
-
* A collection of shims that provide minimal functionality of the ES6 collections.
|
|
110713
|
-
*
|
|
110714
|
-
* These implementations are not meant to be used outside of the ResizeObserver
|
|
110715
|
-
* modules as they cover only a limited range of use cases.
|
|
110716
|
-
*/
|
|
110717
|
-
/* eslint-disable require-jsdoc, valid-jsdoc */
|
|
110718
|
-
var MapShim = (function () {
|
|
110719
|
-
if (typeof Map !== 'undefined') {
|
|
110720
|
-
return Map;
|
|
110721
|
-
}
|
|
110722
|
-
/**
|
|
110723
|
-
* Returns index in provided array that matches the specified key.
|
|
110724
|
-
*
|
|
110725
|
-
* @param {Array<Array>} arr
|
|
110726
|
-
* @param {*} key
|
|
110727
|
-
* @returns {number}
|
|
110728
|
-
*/
|
|
110729
|
-
function getIndex(arr, key) {
|
|
110730
|
-
var result = -1;
|
|
110731
|
-
arr.some(function (entry, index) {
|
|
110732
|
-
if (entry[0] === key) {
|
|
110733
|
-
result = index;
|
|
110734
|
-
return true;
|
|
110735
|
-
}
|
|
110736
|
-
return false;
|
|
110737
|
-
});
|
|
110738
|
-
return result;
|
|
110739
|
-
}
|
|
110740
|
-
return /** @class */ (function () {
|
|
110741
|
-
function class_1() {
|
|
110742
|
-
this.__entries__ = [];
|
|
110743
|
-
}
|
|
110744
|
-
Object.defineProperty(class_1.prototype, "size", {
|
|
110745
|
-
/**
|
|
110746
|
-
* @returns {boolean}
|
|
110747
|
-
*/
|
|
110748
|
-
get: function () {
|
|
110749
|
-
return this.__entries__.length;
|
|
110750
|
-
},
|
|
110751
|
-
enumerable: true,
|
|
110752
|
-
configurable: true
|
|
110753
|
-
});
|
|
110754
|
-
/**
|
|
110755
|
-
* @param {*} key
|
|
110756
|
-
* @returns {*}
|
|
110757
|
-
*/
|
|
110758
|
-
class_1.prototype.get = function (key) {
|
|
110759
|
-
var index = getIndex(this.__entries__, key);
|
|
110760
|
-
var entry = this.__entries__[index];
|
|
110761
|
-
return entry && entry[1];
|
|
110762
|
-
};
|
|
110763
|
-
/**
|
|
110764
|
-
* @param {*} key
|
|
110765
|
-
* @param {*} value
|
|
110766
|
-
* @returns {void}
|
|
110767
|
-
*/
|
|
110768
|
-
class_1.prototype.set = function (key, value) {
|
|
110769
|
-
var index = getIndex(this.__entries__, key);
|
|
110770
|
-
if (~index) {
|
|
110771
|
-
this.__entries__[index][1] = value;
|
|
110772
|
-
}
|
|
110773
|
-
else {
|
|
110774
|
-
this.__entries__.push([key, value]);
|
|
110775
|
-
}
|
|
110776
|
-
};
|
|
110777
|
-
/**
|
|
110778
|
-
* @param {*} key
|
|
110779
|
-
* @returns {void}
|
|
110780
|
-
*/
|
|
110781
|
-
class_1.prototype.delete = function (key) {
|
|
110782
|
-
var entries = this.__entries__;
|
|
110783
|
-
var index = getIndex(entries, key);
|
|
110784
|
-
if (~index) {
|
|
110785
|
-
entries.splice(index, 1);
|
|
110786
|
-
}
|
|
110787
|
-
};
|
|
110788
|
-
/**
|
|
110789
|
-
* @param {*} key
|
|
110790
|
-
* @returns {void}
|
|
110791
|
-
*/
|
|
110792
|
-
class_1.prototype.has = function (key) {
|
|
110793
|
-
return !!~getIndex(this.__entries__, key);
|
|
110794
|
-
};
|
|
110795
|
-
/**
|
|
110796
|
-
* @returns {void}
|
|
110797
|
-
*/
|
|
110798
|
-
class_1.prototype.clear = function () {
|
|
110799
|
-
this.__entries__.splice(0);
|
|
110800
|
-
};
|
|
110801
|
-
/**
|
|
110802
|
-
* @param {Function} callback
|
|
110803
|
-
* @param {*} [ctx=null]
|
|
110804
|
-
* @returns {void}
|
|
110805
|
-
*/
|
|
110806
|
-
class_1.prototype.forEach = function (callback, ctx) {
|
|
110807
|
-
if (ctx === void 0) { ctx = null; }
|
|
110808
|
-
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
|
|
110809
|
-
var entry = _a[_i];
|
|
110810
|
-
callback.call(ctx, entry[1], entry[0]);
|
|
110811
|
-
}
|
|
110812
|
-
};
|
|
110813
|
-
return class_1;
|
|
110814
|
-
}());
|
|
110711
|
+
/* WEBPACK VAR INJECTION */(function(global) {/**
|
|
110712
|
+
* A collection of shims that provide minimal functionality of the ES6 collections.
|
|
110713
|
+
*
|
|
110714
|
+
* These implementations are not meant to be used outside of the ResizeObserver
|
|
110715
|
+
* modules as they cover only a limited range of use cases.
|
|
110716
|
+
*/
|
|
110717
|
+
/* eslint-disable require-jsdoc, valid-jsdoc */
|
|
110718
|
+
var MapShim = (function () {
|
|
110719
|
+
if (typeof Map !== 'undefined') {
|
|
110720
|
+
return Map;
|
|
110721
|
+
}
|
|
110722
|
+
/**
|
|
110723
|
+
* Returns index in provided array that matches the specified key.
|
|
110724
|
+
*
|
|
110725
|
+
* @param {Array<Array>} arr
|
|
110726
|
+
* @param {*} key
|
|
110727
|
+
* @returns {number}
|
|
110728
|
+
*/
|
|
110729
|
+
function getIndex(arr, key) {
|
|
110730
|
+
var result = -1;
|
|
110731
|
+
arr.some(function (entry, index) {
|
|
110732
|
+
if (entry[0] === key) {
|
|
110733
|
+
result = index;
|
|
110734
|
+
return true;
|
|
110735
|
+
}
|
|
110736
|
+
return false;
|
|
110737
|
+
});
|
|
110738
|
+
return result;
|
|
110739
|
+
}
|
|
110740
|
+
return /** @class */ (function () {
|
|
110741
|
+
function class_1() {
|
|
110742
|
+
this.__entries__ = [];
|
|
110743
|
+
}
|
|
110744
|
+
Object.defineProperty(class_1.prototype, "size", {
|
|
110745
|
+
/**
|
|
110746
|
+
* @returns {boolean}
|
|
110747
|
+
*/
|
|
110748
|
+
get: function () {
|
|
110749
|
+
return this.__entries__.length;
|
|
110750
|
+
},
|
|
110751
|
+
enumerable: true,
|
|
110752
|
+
configurable: true
|
|
110753
|
+
});
|
|
110754
|
+
/**
|
|
110755
|
+
* @param {*} key
|
|
110756
|
+
* @returns {*}
|
|
110757
|
+
*/
|
|
110758
|
+
class_1.prototype.get = function (key) {
|
|
110759
|
+
var index = getIndex(this.__entries__, key);
|
|
110760
|
+
var entry = this.__entries__[index];
|
|
110761
|
+
return entry && entry[1];
|
|
110762
|
+
};
|
|
110763
|
+
/**
|
|
110764
|
+
* @param {*} key
|
|
110765
|
+
* @param {*} value
|
|
110766
|
+
* @returns {void}
|
|
110767
|
+
*/
|
|
110768
|
+
class_1.prototype.set = function (key, value) {
|
|
110769
|
+
var index = getIndex(this.__entries__, key);
|
|
110770
|
+
if (~index) {
|
|
110771
|
+
this.__entries__[index][1] = value;
|
|
110772
|
+
}
|
|
110773
|
+
else {
|
|
110774
|
+
this.__entries__.push([key, value]);
|
|
110775
|
+
}
|
|
110776
|
+
};
|
|
110777
|
+
/**
|
|
110778
|
+
* @param {*} key
|
|
110779
|
+
* @returns {void}
|
|
110780
|
+
*/
|
|
110781
|
+
class_1.prototype.delete = function (key) {
|
|
110782
|
+
var entries = this.__entries__;
|
|
110783
|
+
var index = getIndex(entries, key);
|
|
110784
|
+
if (~index) {
|
|
110785
|
+
entries.splice(index, 1);
|
|
110786
|
+
}
|
|
110787
|
+
};
|
|
110788
|
+
/**
|
|
110789
|
+
* @param {*} key
|
|
110790
|
+
* @returns {void}
|
|
110791
|
+
*/
|
|
110792
|
+
class_1.prototype.has = function (key) {
|
|
110793
|
+
return !!~getIndex(this.__entries__, key);
|
|
110794
|
+
};
|
|
110795
|
+
/**
|
|
110796
|
+
* @returns {void}
|
|
110797
|
+
*/
|
|
110798
|
+
class_1.prototype.clear = function () {
|
|
110799
|
+
this.__entries__.splice(0);
|
|
110800
|
+
};
|
|
110801
|
+
/**
|
|
110802
|
+
* @param {Function} callback
|
|
110803
|
+
* @param {*} [ctx=null]
|
|
110804
|
+
* @returns {void}
|
|
110805
|
+
*/
|
|
110806
|
+
class_1.prototype.forEach = function (callback, ctx) {
|
|
110807
|
+
if (ctx === void 0) { ctx = null; }
|
|
110808
|
+
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
|
|
110809
|
+
var entry = _a[_i];
|
|
110810
|
+
callback.call(ctx, entry[1], entry[0]);
|
|
110811
|
+
}
|
|
110812
|
+
};
|
|
110813
|
+
return class_1;
|
|
110814
|
+
}());
|
|
110815
110815
|
})();
|
|
110816
110816
|
|
|
110817
|
-
/**
|
|
110818
|
-
* Detects whether window and document objects are available in current environment.
|
|
110819
|
-
*/
|
|
110817
|
+
/**
|
|
110818
|
+
* Detects whether window and document objects are available in current environment.
|
|
110819
|
+
*/
|
|
110820
110820
|
var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
|
|
110821
110821
|
|
|
110822
|
-
// Returns global object of a current environment.
|
|
110823
|
-
var global$1 = (function () {
|
|
110824
|
-
if (typeof global !== 'undefined' && global.Math === Math) {
|
|
110825
|
-
return global;
|
|
110826
|
-
}
|
|
110827
|
-
if (typeof self !== 'undefined' && self.Math === Math) {
|
|
110828
|
-
return self;
|
|
110829
|
-
}
|
|
110830
|
-
if (typeof window !== 'undefined' && window.Math === Math) {
|
|
110831
|
-
return window;
|
|
110832
|
-
}
|
|
110833
|
-
// eslint-disable-next-line no-new-func
|
|
110834
|
-
return Function('return this')();
|
|
110822
|
+
// Returns global object of a current environment.
|
|
110823
|
+
var global$1 = (function () {
|
|
110824
|
+
if (typeof global !== 'undefined' && global.Math === Math) {
|
|
110825
|
+
return global;
|
|
110826
|
+
}
|
|
110827
|
+
if (typeof self !== 'undefined' && self.Math === Math) {
|
|
110828
|
+
return self;
|
|
110829
|
+
}
|
|
110830
|
+
if (typeof window !== 'undefined' && window.Math === Math) {
|
|
110831
|
+
return window;
|
|
110832
|
+
}
|
|
110833
|
+
// eslint-disable-next-line no-new-func
|
|
110834
|
+
return Function('return this')();
|
|
110835
110835
|
})();
|
|
110836
110836
|
|
|
110837
|
-
/**
|
|
110838
|
-
* A shim for the requestAnimationFrame which falls back to the setTimeout if
|
|
110839
|
-
* first one is not supported.
|
|
110840
|
-
*
|
|
110841
|
-
* @returns {number} Requests' identifier.
|
|
110842
|
-
*/
|
|
110843
|
-
var requestAnimationFrame$1 = (function () {
|
|
110844
|
-
if (typeof requestAnimationFrame === 'function') {
|
|
110845
|
-
// It's required to use a bounded function because IE sometimes throws
|
|
110846
|
-
// an "Invalid calling object" error if rAF is invoked without the global
|
|
110847
|
-
// object on the left hand side.
|
|
110848
|
-
return requestAnimationFrame.bind(global$1);
|
|
110849
|
-
}
|
|
110850
|
-
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
|
|
110837
|
+
/**
|
|
110838
|
+
* A shim for the requestAnimationFrame which falls back to the setTimeout if
|
|
110839
|
+
* first one is not supported.
|
|
110840
|
+
*
|
|
110841
|
+
* @returns {number} Requests' identifier.
|
|
110842
|
+
*/
|
|
110843
|
+
var requestAnimationFrame$1 = (function () {
|
|
110844
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
110845
|
+
// It's required to use a bounded function because IE sometimes throws
|
|
110846
|
+
// an "Invalid calling object" error if rAF is invoked without the global
|
|
110847
|
+
// object on the left hand side.
|
|
110848
|
+
return requestAnimationFrame.bind(global$1);
|
|
110849
|
+
}
|
|
110850
|
+
return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
|
|
110851
110851
|
})();
|
|
110852
110852
|
|
|
110853
|
-
// Defines minimum timeout before adding a trailing call.
|
|
110854
|
-
var trailingTimeout = 2;
|
|
110855
|
-
/**
|
|
110856
|
-
* Creates a wrapper function which ensures that provided callback will be
|
|
110857
|
-
* invoked only once during the specified delay period.
|
|
110858
|
-
*
|
|
110859
|
-
* @param {Function} callback - Function to be invoked after the delay period.
|
|
110860
|
-
* @param {number} delay - Delay after which to invoke callback.
|
|
110861
|
-
* @returns {Function}
|
|
110862
|
-
*/
|
|
110863
|
-
function throttle (callback, delay) {
|
|
110864
|
-
var leadingCall = false, trailingCall = false, lastCallTime = 0;
|
|
110865
|
-
/**
|
|
110866
|
-
* Invokes the original callback function and schedules new invocation if
|
|
110867
|
-
* the "proxy" was called during current request.
|
|
110868
|
-
*
|
|
110869
|
-
* @returns {void}
|
|
110870
|
-
*/
|
|
110871
|
-
function resolvePending() {
|
|
110872
|
-
if (leadingCall) {
|
|
110873
|
-
leadingCall = false;
|
|
110874
|
-
callback();
|
|
110875
|
-
}
|
|
110876
|
-
if (trailingCall) {
|
|
110877
|
-
proxy();
|
|
110878
|
-
}
|
|
110879
|
-
}
|
|
110880
|
-
/**
|
|
110881
|
-
* Callback invoked after the specified delay. It will further postpone
|
|
110882
|
-
* invocation of the original function delegating it to the
|
|
110883
|
-
* requestAnimationFrame.
|
|
110884
|
-
*
|
|
110885
|
-
* @returns {void}
|
|
110886
|
-
*/
|
|
110887
|
-
function timeoutCallback() {
|
|
110888
|
-
requestAnimationFrame$1(resolvePending);
|
|
110889
|
-
}
|
|
110890
|
-
/**
|
|
110891
|
-
* Schedules invocation of the original function.
|
|
110892
|
-
*
|
|
110893
|
-
* @returns {void}
|
|
110894
|
-
*/
|
|
110895
|
-
function proxy() {
|
|
110896
|
-
var timeStamp = Date.now();
|
|
110897
|
-
if (leadingCall) {
|
|
110898
|
-
// Reject immediately following calls.
|
|
110899
|
-
if (timeStamp - lastCallTime < trailingTimeout) {
|
|
110900
|
-
return;
|
|
110901
|
-
}
|
|
110902
|
-
// Schedule new call to be in invoked when the pending one is resolved.
|
|
110903
|
-
// This is important for "transitions" which never actually start
|
|
110904
|
-
// immediately so there is a chance that we might miss one if change
|
|
110905
|
-
// happens amids the pending invocation.
|
|
110906
|
-
trailingCall = true;
|
|
110907
|
-
}
|
|
110908
|
-
else {
|
|
110909
|
-
leadingCall = true;
|
|
110910
|
-
trailingCall = false;
|
|
110911
|
-
setTimeout(timeoutCallback, delay);
|
|
110912
|
-
}
|
|
110913
|
-
lastCallTime = timeStamp;
|
|
110914
|
-
}
|
|
110915
|
-
return proxy;
|
|
110916
|
-
}
|
|
110917
|
-
|
|
110918
|
-
// Minimum delay before invoking the update of observers.
|
|
110919
|
-
var REFRESH_DELAY = 20;
|
|
110920
|
-
// A list of substrings of CSS properties used to find transition events that
|
|
110921
|
-
// might affect dimensions of observed elements.
|
|
110922
|
-
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
|
|
110923
|
-
// Check if MutationObserver is available.
|
|
110924
|
-
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
|
|
110925
|
-
/**
|
|
110926
|
-
* Singleton controller class which handles updates of ResizeObserver instances.
|
|
110927
|
-
*/
|
|
110928
|
-
var ResizeObserverController = /** @class */ (function () {
|
|
110929
|
-
/**
|
|
110930
|
-
* Creates a new instance of ResizeObserverController.
|
|
110931
|
-
*
|
|
110932
|
-
* @private
|
|
110933
|
-
*/
|
|
110934
|
-
function ResizeObserverController() {
|
|
110935
|
-
/**
|
|
110936
|
-
* Indicates whether DOM listeners have been added.
|
|
110937
|
-
*
|
|
110938
|
-
* @private {boolean}
|
|
110939
|
-
*/
|
|
110940
|
-
this.connected_ = false;
|
|
110941
|
-
/**
|
|
110942
|
-
* Tells that controller has subscribed for Mutation Events.
|
|
110943
|
-
*
|
|
110944
|
-
* @private {boolean}
|
|
110945
|
-
*/
|
|
110946
|
-
this.mutationEventsAdded_ = false;
|
|
110947
|
-
/**
|
|
110948
|
-
* Keeps reference to the instance of MutationObserver.
|
|
110949
|
-
*
|
|
110950
|
-
* @private {MutationObserver}
|
|
110951
|
-
*/
|
|
110952
|
-
this.mutationsObserver_ = null;
|
|
110953
|
-
/**
|
|
110954
|
-
* A list of connected observers.
|
|
110955
|
-
*
|
|
110956
|
-
* @private {Array<ResizeObserverSPI>}
|
|
110957
|
-
*/
|
|
110958
|
-
this.observers_ = [];
|
|
110959
|
-
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
|
|
110960
|
-
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
|
|
110961
|
-
}
|
|
110962
|
-
/**
|
|
110963
|
-
* Adds observer to observers list.
|
|
110964
|
-
*
|
|
110965
|
-
* @param {ResizeObserverSPI} observer - Observer to be added.
|
|
110966
|
-
* @returns {void}
|
|
110967
|
-
*/
|
|
110968
|
-
ResizeObserverController.prototype.addObserver = function (observer) {
|
|
110969
|
-
if (!~this.observers_.indexOf(observer)) {
|
|
110970
|
-
this.observers_.push(observer);
|
|
110971
|
-
}
|
|
110972
|
-
// Add listeners if they haven't been added yet.
|
|
110973
|
-
if (!this.connected_) {
|
|
110974
|
-
this.connect_();
|
|
110975
|
-
}
|
|
110976
|
-
};
|
|
110977
|
-
/**
|
|
110978
|
-
* Removes observer from observers list.
|
|
110979
|
-
*
|
|
110980
|
-
* @param {ResizeObserverSPI} observer - Observer to be removed.
|
|
110981
|
-
* @returns {void}
|
|
110982
|
-
*/
|
|
110983
|
-
ResizeObserverController.prototype.removeObserver = function (observer) {
|
|
110984
|
-
var observers = this.observers_;
|
|
110985
|
-
var index = observers.indexOf(observer);
|
|
110986
|
-
// Remove observer if it's present in registry.
|
|
110987
|
-
if (~index) {
|
|
110988
|
-
observers.splice(index, 1);
|
|
110989
|
-
}
|
|
110990
|
-
// Remove listeners if controller has no connected observers.
|
|
110991
|
-
if (!observers.length && this.connected_) {
|
|
110992
|
-
this.disconnect_();
|
|
110993
|
-
}
|
|
110994
|
-
};
|
|
110995
|
-
/**
|
|
110996
|
-
* Invokes the update of observers. It will continue running updates insofar
|
|
110997
|
-
* it detects changes.
|
|
110998
|
-
*
|
|
110999
|
-
* @returns {void}
|
|
111000
|
-
*/
|
|
111001
|
-
ResizeObserverController.prototype.refresh = function () {
|
|
111002
|
-
var changesDetected = this.updateObservers_();
|
|
111003
|
-
// Continue running updates if changes have been detected as there might
|
|
111004
|
-
// be future ones caused by CSS transitions.
|
|
111005
|
-
if (changesDetected) {
|
|
111006
|
-
this.refresh();
|
|
111007
|
-
}
|
|
111008
|
-
};
|
|
111009
|
-
/**
|
|
111010
|
-
* Updates every observer from observers list and notifies them of queued
|
|
111011
|
-
* entries.
|
|
111012
|
-
*
|
|
111013
|
-
* @private
|
|
111014
|
-
* @returns {boolean} Returns "true" if any observer has detected changes in
|
|
111015
|
-
* dimensions of it's elements.
|
|
111016
|
-
*/
|
|
111017
|
-
ResizeObserverController.prototype.updateObservers_ = function () {
|
|
111018
|
-
// Collect observers that have active observations.
|
|
111019
|
-
var activeObservers = this.observers_.filter(function (observer) {
|
|
111020
|
-
return observer.gatherActive(), observer.hasActive();
|
|
111021
|
-
});
|
|
111022
|
-
// Deliver notifications in a separate cycle in order to avoid any
|
|
111023
|
-
// collisions between observers, e.g. when multiple instances of
|
|
111024
|
-
// ResizeObserver are tracking the same element and the callback of one
|
|
111025
|
-
// of them changes content dimensions of the observed target. Sometimes
|
|
111026
|
-
// this may result in notifications being blocked for the rest of observers.
|
|
111027
|
-
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
|
|
111028
|
-
return activeObservers.length > 0;
|
|
111029
|
-
};
|
|
111030
|
-
/**
|
|
111031
|
-
* Initializes DOM listeners.
|
|
111032
|
-
*
|
|
111033
|
-
* @private
|
|
111034
|
-
* @returns {void}
|
|
111035
|
-
*/
|
|
111036
|
-
ResizeObserverController.prototype.connect_ = function () {
|
|
111037
|
-
// Do nothing if running in a non-browser environment or if listeners
|
|
111038
|
-
// have been already added.
|
|
111039
|
-
if (!isBrowser || this.connected_) {
|
|
111040
|
-
return;
|
|
111041
|
-
}
|
|
111042
|
-
// Subscription to the "Transitionend" event is used as a workaround for
|
|
111043
|
-
// delayed transitions. This way it's possible to capture at least the
|
|
111044
|
-
// final state of an element.
|
|
111045
|
-
document.addEventListener('transitionend', this.onTransitionEnd_);
|
|
111046
|
-
window.addEventListener('resize', this.refresh);
|
|
111047
|
-
if (mutationObserverSupported) {
|
|
111048
|
-
this.mutationsObserver_ = new MutationObserver(this.refresh);
|
|
111049
|
-
this.mutationsObserver_.observe(document, {
|
|
111050
|
-
attributes: true,
|
|
111051
|
-
childList: true,
|
|
111052
|
-
characterData: true,
|
|
111053
|
-
subtree: true
|
|
111054
|
-
});
|
|
111055
|
-
}
|
|
111056
|
-
else {
|
|
111057
|
-
document.addEventListener('DOMSubtreeModified', this.refresh);
|
|
111058
|
-
this.mutationEventsAdded_ = true;
|
|
111059
|
-
}
|
|
111060
|
-
this.connected_ = true;
|
|
111061
|
-
};
|
|
111062
|
-
/**
|
|
111063
|
-
* Removes DOM listeners.
|
|
111064
|
-
*
|
|
111065
|
-
* @private
|
|
111066
|
-
* @returns {void}
|
|
111067
|
-
*/
|
|
111068
|
-
ResizeObserverController.prototype.disconnect_ = function () {
|
|
111069
|
-
// Do nothing if running in a non-browser environment or if listeners
|
|
111070
|
-
// have been already removed.
|
|
111071
|
-
if (!isBrowser || !this.connected_) {
|
|
111072
|
-
return;
|
|
111073
|
-
}
|
|
111074
|
-
document.removeEventListener('transitionend', this.onTransitionEnd_);
|
|
111075
|
-
window.removeEventListener('resize', this.refresh);
|
|
111076
|
-
if (this.mutationsObserver_) {
|
|
111077
|
-
this.mutationsObserver_.disconnect();
|
|
111078
|
-
}
|
|
111079
|
-
if (this.mutationEventsAdded_) {
|
|
111080
|
-
document.removeEventListener('DOMSubtreeModified', this.refresh);
|
|
111081
|
-
}
|
|
111082
|
-
this.mutationsObserver_ = null;
|
|
111083
|
-
this.mutationEventsAdded_ = false;
|
|
111084
|
-
this.connected_ = false;
|
|
111085
|
-
};
|
|
111086
|
-
/**
|
|
111087
|
-
* "Transitionend" event handler.
|
|
111088
|
-
*
|
|
111089
|
-
* @private
|
|
111090
|
-
* @param {TransitionEvent} event
|
|
111091
|
-
* @returns {void}
|
|
111092
|
-
*/
|
|
111093
|
-
ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
|
|
111094
|
-
var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
|
|
111095
|
-
// Detect whether transition may affect dimensions of an element.
|
|
111096
|
-
var isReflowProperty = transitionKeys.some(function (key) {
|
|
111097
|
-
return !!~propertyName.indexOf(key);
|
|
111098
|
-
});
|
|
111099
|
-
if (isReflowProperty) {
|
|
111100
|
-
this.refresh();
|
|
111101
|
-
}
|
|
111102
|
-
};
|
|
111103
|
-
/**
|
|
111104
|
-
* Returns instance of the ResizeObserverController.
|
|
111105
|
-
*
|
|
111106
|
-
* @returns {ResizeObserverController}
|
|
111107
|
-
*/
|
|
111108
|
-
ResizeObserverController.getInstance = function () {
|
|
111109
|
-
if (!this.instance_) {
|
|
111110
|
-
this.instance_ = new ResizeObserverController();
|
|
111111
|
-
}
|
|
111112
|
-
return this.instance_;
|
|
111113
|
-
};
|
|
111114
|
-
/**
|
|
111115
|
-
* Holds reference to the controller's instance.
|
|
111116
|
-
*
|
|
111117
|
-
* @private {ResizeObserverController}
|
|
111118
|
-
*/
|
|
111119
|
-
ResizeObserverController.instance_ = null;
|
|
111120
|
-
return ResizeObserverController;
|
|
110853
|
+
// Defines minimum timeout before adding a trailing call.
|
|
110854
|
+
var trailingTimeout = 2;
|
|
110855
|
+
/**
|
|
110856
|
+
* Creates a wrapper function which ensures that provided callback will be
|
|
110857
|
+
* invoked only once during the specified delay period.
|
|
110858
|
+
*
|
|
110859
|
+
* @param {Function} callback - Function to be invoked after the delay period.
|
|
110860
|
+
* @param {number} delay - Delay after which to invoke callback.
|
|
110861
|
+
* @returns {Function}
|
|
110862
|
+
*/
|
|
110863
|
+
function throttle (callback, delay) {
|
|
110864
|
+
var leadingCall = false, trailingCall = false, lastCallTime = 0;
|
|
110865
|
+
/**
|
|
110866
|
+
* Invokes the original callback function and schedules new invocation if
|
|
110867
|
+
* the "proxy" was called during current request.
|
|
110868
|
+
*
|
|
110869
|
+
* @returns {void}
|
|
110870
|
+
*/
|
|
110871
|
+
function resolvePending() {
|
|
110872
|
+
if (leadingCall) {
|
|
110873
|
+
leadingCall = false;
|
|
110874
|
+
callback();
|
|
110875
|
+
}
|
|
110876
|
+
if (trailingCall) {
|
|
110877
|
+
proxy();
|
|
110878
|
+
}
|
|
110879
|
+
}
|
|
110880
|
+
/**
|
|
110881
|
+
* Callback invoked after the specified delay. It will further postpone
|
|
110882
|
+
* invocation of the original function delegating it to the
|
|
110883
|
+
* requestAnimationFrame.
|
|
110884
|
+
*
|
|
110885
|
+
* @returns {void}
|
|
110886
|
+
*/
|
|
110887
|
+
function timeoutCallback() {
|
|
110888
|
+
requestAnimationFrame$1(resolvePending);
|
|
110889
|
+
}
|
|
110890
|
+
/**
|
|
110891
|
+
* Schedules invocation of the original function.
|
|
110892
|
+
*
|
|
110893
|
+
* @returns {void}
|
|
110894
|
+
*/
|
|
110895
|
+
function proxy() {
|
|
110896
|
+
var timeStamp = Date.now();
|
|
110897
|
+
if (leadingCall) {
|
|
110898
|
+
// Reject immediately following calls.
|
|
110899
|
+
if (timeStamp - lastCallTime < trailingTimeout) {
|
|
110900
|
+
return;
|
|
110901
|
+
}
|
|
110902
|
+
// Schedule new call to be in invoked when the pending one is resolved.
|
|
110903
|
+
// This is important for "transitions" which never actually start
|
|
110904
|
+
// immediately so there is a chance that we might miss one if change
|
|
110905
|
+
// happens amids the pending invocation.
|
|
110906
|
+
trailingCall = true;
|
|
110907
|
+
}
|
|
110908
|
+
else {
|
|
110909
|
+
leadingCall = true;
|
|
110910
|
+
trailingCall = false;
|
|
110911
|
+
setTimeout(timeoutCallback, delay);
|
|
110912
|
+
}
|
|
110913
|
+
lastCallTime = timeStamp;
|
|
110914
|
+
}
|
|
110915
|
+
return proxy;
|
|
110916
|
+
}
|
|
110917
|
+
|
|
110918
|
+
// Minimum delay before invoking the update of observers.
|
|
110919
|
+
var REFRESH_DELAY = 20;
|
|
110920
|
+
// A list of substrings of CSS properties used to find transition events that
|
|
110921
|
+
// might affect dimensions of observed elements.
|
|
110922
|
+
var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
|
|
110923
|
+
// Check if MutationObserver is available.
|
|
110924
|
+
var mutationObserverSupported = typeof MutationObserver !== 'undefined';
|
|
110925
|
+
/**
|
|
110926
|
+
* Singleton controller class which handles updates of ResizeObserver instances.
|
|
110927
|
+
*/
|
|
110928
|
+
var ResizeObserverController = /** @class */ (function () {
|
|
110929
|
+
/**
|
|
110930
|
+
* Creates a new instance of ResizeObserverController.
|
|
110931
|
+
*
|
|
110932
|
+
* @private
|
|
110933
|
+
*/
|
|
110934
|
+
function ResizeObserverController() {
|
|
110935
|
+
/**
|
|
110936
|
+
* Indicates whether DOM listeners have been added.
|
|
110937
|
+
*
|
|
110938
|
+
* @private {boolean}
|
|
110939
|
+
*/
|
|
110940
|
+
this.connected_ = false;
|
|
110941
|
+
/**
|
|
110942
|
+
* Tells that controller has subscribed for Mutation Events.
|
|
110943
|
+
*
|
|
110944
|
+
* @private {boolean}
|
|
110945
|
+
*/
|
|
110946
|
+
this.mutationEventsAdded_ = false;
|
|
110947
|
+
/**
|
|
110948
|
+
* Keeps reference to the instance of MutationObserver.
|
|
110949
|
+
*
|
|
110950
|
+
* @private {MutationObserver}
|
|
110951
|
+
*/
|
|
110952
|
+
this.mutationsObserver_ = null;
|
|
110953
|
+
/**
|
|
110954
|
+
* A list of connected observers.
|
|
110955
|
+
*
|
|
110956
|
+
* @private {Array<ResizeObserverSPI>}
|
|
110957
|
+
*/
|
|
110958
|
+
this.observers_ = [];
|
|
110959
|
+
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
|
|
110960
|
+
this.refresh = throttle(this.refresh.bind(this), REFRESH_DELAY);
|
|
110961
|
+
}
|
|
110962
|
+
/**
|
|
110963
|
+
* Adds observer to observers list.
|
|
110964
|
+
*
|
|
110965
|
+
* @param {ResizeObserverSPI} observer - Observer to be added.
|
|
110966
|
+
* @returns {void}
|
|
110967
|
+
*/
|
|
110968
|
+
ResizeObserverController.prototype.addObserver = function (observer) {
|
|
110969
|
+
if (!~this.observers_.indexOf(observer)) {
|
|
110970
|
+
this.observers_.push(observer);
|
|
110971
|
+
}
|
|
110972
|
+
// Add listeners if they haven't been added yet.
|
|
110973
|
+
if (!this.connected_) {
|
|
110974
|
+
this.connect_();
|
|
110975
|
+
}
|
|
110976
|
+
};
|
|
110977
|
+
/**
|
|
110978
|
+
* Removes observer from observers list.
|
|
110979
|
+
*
|
|
110980
|
+
* @param {ResizeObserverSPI} observer - Observer to be removed.
|
|
110981
|
+
* @returns {void}
|
|
110982
|
+
*/
|
|
110983
|
+
ResizeObserverController.prototype.removeObserver = function (observer) {
|
|
110984
|
+
var observers = this.observers_;
|
|
110985
|
+
var index = observers.indexOf(observer);
|
|
110986
|
+
// Remove observer if it's present in registry.
|
|
110987
|
+
if (~index) {
|
|
110988
|
+
observers.splice(index, 1);
|
|
110989
|
+
}
|
|
110990
|
+
// Remove listeners if controller has no connected observers.
|
|
110991
|
+
if (!observers.length && this.connected_) {
|
|
110992
|
+
this.disconnect_();
|
|
110993
|
+
}
|
|
110994
|
+
};
|
|
110995
|
+
/**
|
|
110996
|
+
* Invokes the update of observers. It will continue running updates insofar
|
|
110997
|
+
* it detects changes.
|
|
110998
|
+
*
|
|
110999
|
+
* @returns {void}
|
|
111000
|
+
*/
|
|
111001
|
+
ResizeObserverController.prototype.refresh = function () {
|
|
111002
|
+
var changesDetected = this.updateObservers_();
|
|
111003
|
+
// Continue running updates if changes have been detected as there might
|
|
111004
|
+
// be future ones caused by CSS transitions.
|
|
111005
|
+
if (changesDetected) {
|
|
111006
|
+
this.refresh();
|
|
111007
|
+
}
|
|
111008
|
+
};
|
|
111009
|
+
/**
|
|
111010
|
+
* Updates every observer from observers list and notifies them of queued
|
|
111011
|
+
* entries.
|
|
111012
|
+
*
|
|
111013
|
+
* @private
|
|
111014
|
+
* @returns {boolean} Returns "true" if any observer has detected changes in
|
|
111015
|
+
* dimensions of it's elements.
|
|
111016
|
+
*/
|
|
111017
|
+
ResizeObserverController.prototype.updateObservers_ = function () {
|
|
111018
|
+
// Collect observers that have active observations.
|
|
111019
|
+
var activeObservers = this.observers_.filter(function (observer) {
|
|
111020
|
+
return observer.gatherActive(), observer.hasActive();
|
|
111021
|
+
});
|
|
111022
|
+
// Deliver notifications in a separate cycle in order to avoid any
|
|
111023
|
+
// collisions between observers, e.g. when multiple instances of
|
|
111024
|
+
// ResizeObserver are tracking the same element and the callback of one
|
|
111025
|
+
// of them changes content dimensions of the observed target. Sometimes
|
|
111026
|
+
// this may result in notifications being blocked for the rest of observers.
|
|
111027
|
+
activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
|
|
111028
|
+
return activeObservers.length > 0;
|
|
111029
|
+
};
|
|
111030
|
+
/**
|
|
111031
|
+
* Initializes DOM listeners.
|
|
111032
|
+
*
|
|
111033
|
+
* @private
|
|
111034
|
+
* @returns {void}
|
|
111035
|
+
*/
|
|
111036
|
+
ResizeObserverController.prototype.connect_ = function () {
|
|
111037
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
111038
|
+
// have been already added.
|
|
111039
|
+
if (!isBrowser || this.connected_) {
|
|
111040
|
+
return;
|
|
111041
|
+
}
|
|
111042
|
+
// Subscription to the "Transitionend" event is used as a workaround for
|
|
111043
|
+
// delayed transitions. This way it's possible to capture at least the
|
|
111044
|
+
// final state of an element.
|
|
111045
|
+
document.addEventListener('transitionend', this.onTransitionEnd_);
|
|
111046
|
+
window.addEventListener('resize', this.refresh);
|
|
111047
|
+
if (mutationObserverSupported) {
|
|
111048
|
+
this.mutationsObserver_ = new MutationObserver(this.refresh);
|
|
111049
|
+
this.mutationsObserver_.observe(document, {
|
|
111050
|
+
attributes: true,
|
|
111051
|
+
childList: true,
|
|
111052
|
+
characterData: true,
|
|
111053
|
+
subtree: true
|
|
111054
|
+
});
|
|
111055
|
+
}
|
|
111056
|
+
else {
|
|
111057
|
+
document.addEventListener('DOMSubtreeModified', this.refresh);
|
|
111058
|
+
this.mutationEventsAdded_ = true;
|
|
111059
|
+
}
|
|
111060
|
+
this.connected_ = true;
|
|
111061
|
+
};
|
|
111062
|
+
/**
|
|
111063
|
+
* Removes DOM listeners.
|
|
111064
|
+
*
|
|
111065
|
+
* @private
|
|
111066
|
+
* @returns {void}
|
|
111067
|
+
*/
|
|
111068
|
+
ResizeObserverController.prototype.disconnect_ = function () {
|
|
111069
|
+
// Do nothing if running in a non-browser environment or if listeners
|
|
111070
|
+
// have been already removed.
|
|
111071
|
+
if (!isBrowser || !this.connected_) {
|
|
111072
|
+
return;
|
|
111073
|
+
}
|
|
111074
|
+
document.removeEventListener('transitionend', this.onTransitionEnd_);
|
|
111075
|
+
window.removeEventListener('resize', this.refresh);
|
|
111076
|
+
if (this.mutationsObserver_) {
|
|
111077
|
+
this.mutationsObserver_.disconnect();
|
|
111078
|
+
}
|
|
111079
|
+
if (this.mutationEventsAdded_) {
|
|
111080
|
+
document.removeEventListener('DOMSubtreeModified', this.refresh);
|
|
111081
|
+
}
|
|
111082
|
+
this.mutationsObserver_ = null;
|
|
111083
|
+
this.mutationEventsAdded_ = false;
|
|
111084
|
+
this.connected_ = false;
|
|
111085
|
+
};
|
|
111086
|
+
/**
|
|
111087
|
+
* "Transitionend" event handler.
|
|
111088
|
+
*
|
|
111089
|
+
* @private
|
|
111090
|
+
* @param {TransitionEvent} event
|
|
111091
|
+
* @returns {void}
|
|
111092
|
+
*/
|
|
111093
|
+
ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
|
|
111094
|
+
var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
|
|
111095
|
+
// Detect whether transition may affect dimensions of an element.
|
|
111096
|
+
var isReflowProperty = transitionKeys.some(function (key) {
|
|
111097
|
+
return !!~propertyName.indexOf(key);
|
|
111098
|
+
});
|
|
111099
|
+
if (isReflowProperty) {
|
|
111100
|
+
this.refresh();
|
|
111101
|
+
}
|
|
111102
|
+
};
|
|
111103
|
+
/**
|
|
111104
|
+
* Returns instance of the ResizeObserverController.
|
|
111105
|
+
*
|
|
111106
|
+
* @returns {ResizeObserverController}
|
|
111107
|
+
*/
|
|
111108
|
+
ResizeObserverController.getInstance = function () {
|
|
111109
|
+
if (!this.instance_) {
|
|
111110
|
+
this.instance_ = new ResizeObserverController();
|
|
111111
|
+
}
|
|
111112
|
+
return this.instance_;
|
|
111113
|
+
};
|
|
111114
|
+
/**
|
|
111115
|
+
* Holds reference to the controller's instance.
|
|
111116
|
+
*
|
|
111117
|
+
* @private {ResizeObserverController}
|
|
111118
|
+
*/
|
|
111119
|
+
ResizeObserverController.instance_ = null;
|
|
111120
|
+
return ResizeObserverController;
|
|
111121
111121
|
}());
|
|
111122
111122
|
|
|
111123
|
-
/**
|
|
111124
|
-
* Defines non-writable/enumerable properties of the provided target object.
|
|
111125
|
-
*
|
|
111126
|
-
* @param {Object} target - Object for which to define properties.
|
|
111127
|
-
* @param {Object} props - Properties to be defined.
|
|
111128
|
-
* @returns {Object} Target object.
|
|
111129
|
-
*/
|
|
111130
|
-
var defineConfigurable = (function (target, props) {
|
|
111131
|
-
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
111132
|
-
var key = _a[_i];
|
|
111133
|
-
Object.defineProperty(target, key, {
|
|
111134
|
-
value: props[key],
|
|
111135
|
-
enumerable: false,
|
|
111136
|
-
writable: false,
|
|
111137
|
-
configurable: true
|
|
111138
|
-
});
|
|
111139
|
-
}
|
|
111140
|
-
return target;
|
|
111123
|
+
/**
|
|
111124
|
+
* Defines non-writable/enumerable properties of the provided target object.
|
|
111125
|
+
*
|
|
111126
|
+
* @param {Object} target - Object for which to define properties.
|
|
111127
|
+
* @param {Object} props - Properties to be defined.
|
|
111128
|
+
* @returns {Object} Target object.
|
|
111129
|
+
*/
|
|
111130
|
+
var defineConfigurable = (function (target, props) {
|
|
111131
|
+
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
|
|
111132
|
+
var key = _a[_i];
|
|
111133
|
+
Object.defineProperty(target, key, {
|
|
111134
|
+
value: props[key],
|
|
111135
|
+
enumerable: false,
|
|
111136
|
+
writable: false,
|
|
111137
|
+
configurable: true
|
|
111138
|
+
});
|
|
111139
|
+
}
|
|
111140
|
+
return target;
|
|
111141
111141
|
});
|
|
111142
111142
|
|
|
111143
|
-
/**
|
|
111144
|
-
* Returns the global object associated with provided element.
|
|
111145
|
-
*
|
|
111146
|
-
* @param {Object} target
|
|
111147
|
-
* @returns {Object}
|
|
111148
|
-
*/
|
|
111149
|
-
var getWindowOf = (function (target) {
|
|
111150
|
-
// Assume that the element is an instance of Node, which means that it
|
|
111151
|
-
// has the "ownerDocument" property from which we can retrieve a
|
|
111152
|
-
// corresponding global object.
|
|
111153
|
-
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
|
111154
|
-
// Return the local global object if it's not possible extract one from
|
|
111155
|
-
// provided element.
|
|
111156
|
-
return ownerGlobal || global$1;
|
|
111143
|
+
/**
|
|
111144
|
+
* Returns the global object associated with provided element.
|
|
111145
|
+
*
|
|
111146
|
+
* @param {Object} target
|
|
111147
|
+
* @returns {Object}
|
|
111148
|
+
*/
|
|
111149
|
+
var getWindowOf = (function (target) {
|
|
111150
|
+
// Assume that the element is an instance of Node, which means that it
|
|
111151
|
+
// has the "ownerDocument" property from which we can retrieve a
|
|
111152
|
+
// corresponding global object.
|
|
111153
|
+
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
|
|
111154
|
+
// Return the local global object if it's not possible extract one from
|
|
111155
|
+
// provided element.
|
|
111156
|
+
return ownerGlobal || global$1;
|
|
111157
111157
|
});
|
|
111158
111158
|
|
|
111159
|
-
// Placeholder of an empty content rectangle.
|
|
111160
|
-
var emptyRect = createRectInit(0, 0, 0, 0);
|
|
111161
|
-
/**
|
|
111162
|
-
* Converts provided string to a number.
|
|
111163
|
-
*
|
|
111164
|
-
* @param {number|string} value
|
|
111165
|
-
* @returns {number}
|
|
111166
|
-
*/
|
|
111167
|
-
function toFloat(value) {
|
|
111168
|
-
return parseFloat(value) || 0;
|
|
111169
|
-
}
|
|
111170
|
-
/**
|
|
111171
|
-
* Extracts borders size from provided styles.
|
|
111172
|
-
*
|
|
111173
|
-
* @param {CSSStyleDeclaration} styles
|
|
111174
|
-
* @param {...string} positions - Borders positions (top, right, ...)
|
|
111175
|
-
* @returns {number}
|
|
111176
|
-
*/
|
|
111177
|
-
function getBordersSize(styles) {
|
|
111178
|
-
var positions = [];
|
|
111179
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
111180
|
-
positions[_i - 1] = arguments[_i];
|
|
111181
|
-
}
|
|
111182
|
-
return positions.reduce(function (size, position) {
|
|
111183
|
-
var value = styles['border-' + position + '-width'];
|
|
111184
|
-
return size + toFloat(value);
|
|
111185
|
-
}, 0);
|
|
111186
|
-
}
|
|
111187
|
-
/**
|
|
111188
|
-
* Extracts paddings sizes from provided styles.
|
|
111189
|
-
*
|
|
111190
|
-
* @param {CSSStyleDeclaration} styles
|
|
111191
|
-
* @returns {Object} Paddings box.
|
|
111192
|
-
*/
|
|
111193
|
-
function getPaddings(styles) {
|
|
111194
|
-
var positions = ['top', 'right', 'bottom', 'left'];
|
|
111195
|
-
var paddings = {};
|
|
111196
|
-
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
111197
|
-
var position = positions_1[_i];
|
|
111198
|
-
var value = styles['padding-' + position];
|
|
111199
|
-
paddings[position] = toFloat(value);
|
|
111200
|
-
}
|
|
111201
|
-
return paddings;
|
|
111202
|
-
}
|
|
111203
|
-
/**
|
|
111204
|
-
* Calculates content rectangle of provided SVG element.
|
|
111205
|
-
*
|
|
111206
|
-
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
|
|
111207
|
-
* to be calculated.
|
|
111208
|
-
* @returns {DOMRectInit}
|
|
111209
|
-
*/
|
|
111210
|
-
function getSVGContentRect(target) {
|
|
111211
|
-
var bbox = target.getBBox();
|
|
111212
|
-
return createRectInit(0, 0, bbox.width, bbox.height);
|
|
111213
|
-
}
|
|
111214
|
-
/**
|
|
111215
|
-
* Calculates content rectangle of provided HTMLElement.
|
|
111216
|
-
*
|
|
111217
|
-
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
|
|
111218
|
-
* @returns {DOMRectInit}
|
|
111219
|
-
*/
|
|
111220
|
-
function getHTMLElementContentRect(target) {
|
|
111221
|
-
// Client width & height properties can't be
|
|
111222
|
-
// used exclusively as they provide rounded values.
|
|
111223
|
-
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
|
|
111224
|
-
// By this condition we can catch all non-replaced inline, hidden and
|
|
111225
|
-
// detached elements. Though elements with width & height properties less
|
|
111226
|
-
// than 0.5 will be discarded as well.
|
|
111227
|
-
//
|
|
111228
|
-
// Without it we would need to implement separate methods for each of
|
|
111229
|
-
// those cases and it's not possible to perform a precise and performance
|
|
111230
|
-
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
|
|
111231
|
-
// gives wrong results for elements with width & height less than 0.5.
|
|
111232
|
-
if (!clientWidth && !clientHeight) {
|
|
111233
|
-
return emptyRect;
|
|
111234
|
-
}
|
|
111235
|
-
var styles = getWindowOf(target).getComputedStyle(target);
|
|
111236
|
-
var paddings = getPaddings(styles);
|
|
111237
|
-
var horizPad = paddings.left + paddings.right;
|
|
111238
|
-
var vertPad = paddings.top + paddings.bottom;
|
|
111239
|
-
// Computed styles of width & height are being used because they are the
|
|
111240
|
-
// only dimensions available to JS that contain non-rounded values. It could
|
|
111241
|
-
// be possible to utilize the getBoundingClientRect if only it's data wasn't
|
|
111242
|
-
// affected by CSS transformations let alone paddings, borders and scroll bars.
|
|
111243
|
-
var width = toFloat(styles.width), height = toFloat(styles.height);
|
|
111244
|
-
// Width & height include paddings and borders when the 'border-box' box
|
|
111245
|
-
// model is applied (except for IE).
|
|
111246
|
-
if (styles.boxSizing === 'border-box') {
|
|
111247
|
-
// Following conditions are required to handle Internet Explorer which
|
|
111248
|
-
// doesn't include paddings and borders to computed CSS dimensions.
|
|
111249
|
-
//
|
|
111250
|
-
// We can say that if CSS dimensions + paddings are equal to the "client"
|
|
111251
|
-
// properties then it's either IE, and thus we don't need to subtract
|
|
111252
|
-
// anything, or an element merely doesn't have paddings/borders styles.
|
|
111253
|
-
if (Math.round(width + horizPad) !== clientWidth) {
|
|
111254
|
-
width -= getBordersSize(styles, 'left', 'right') + horizPad;
|
|
111255
|
-
}
|
|
111256
|
-
if (Math.round(height + vertPad) !== clientHeight) {
|
|
111257
|
-
height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
|
|
111258
|
-
}
|
|
111259
|
-
}
|
|
111260
|
-
// Following steps can't be applied to the document's root element as its
|
|
111261
|
-
// client[Width/Height] properties represent viewport area of the window.
|
|
111262
|
-
// Besides, it's as well not necessary as the <html> itself neither has
|
|
111263
|
-
// rendered scroll bars nor it can be clipped.
|
|
111264
|
-
if (!isDocumentElement(target)) {
|
|
111265
|
-
// In some browsers (only in Firefox, actually) CSS width & height
|
|
111266
|
-
// include scroll bars size which can be removed at this step as scroll
|
|
111267
|
-
// bars are the only difference between rounded dimensions + paddings
|
|
111268
|
-
// and "client" properties, though that is not always true in Chrome.
|
|
111269
|
-
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
|
|
111270
|
-
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
|
|
111271
|
-
// Chrome has a rather weird rounding of "client" properties.
|
|
111272
|
-
// E.g. for an element with content width of 314.2px it sometimes gives
|
|
111273
|
-
// the client width of 315px and for the width of 314.7px it may give
|
|
111274
|
-
// 314px. And it doesn't happen all the time. So just ignore this delta
|
|
111275
|
-
// as a non-relevant.
|
|
111276
|
-
if (Math.abs(vertScrollbar) !== 1) {
|
|
111277
|
-
width -= vertScrollbar;
|
|
111278
|
-
}
|
|
111279
|
-
if (Math.abs(horizScrollbar) !== 1) {
|
|
111280
|
-
height -= horizScrollbar;
|
|
111281
|
-
}
|
|
111282
|
-
}
|
|
111283
|
-
return createRectInit(paddings.left, paddings.top, width, height);
|
|
111284
|
-
}
|
|
111285
|
-
/**
|
|
111286
|
-
* Checks whether provided element is an instance of the SVGGraphicsElement.
|
|
111287
|
-
*
|
|
111288
|
-
* @param {Element} target - Element to be checked.
|
|
111289
|
-
* @returns {boolean}
|
|
111290
|
-
*/
|
|
111291
|
-
var isSVGGraphicsElement = (function () {
|
|
111292
|
-
// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
|
|
111293
|
-
// interface.
|
|
111294
|
-
if (typeof SVGGraphicsElement !== 'undefined') {
|
|
111295
|
-
return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
|
|
111296
|
-
}
|
|
111297
|
-
// If it's so, then check that element is at least an instance of the
|
|
111298
|
-
// SVGElement and that it has the "getBBox" method.
|
|
111299
|
-
// eslint-disable-next-line no-extra-parens
|
|
111300
|
-
return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
|
|
111301
|
-
typeof target.getBBox === 'function'); };
|
|
111302
|
-
})();
|
|
111303
|
-
/**
|
|
111304
|
-
* Checks whether provided element is a document element (<html>).
|
|
111305
|
-
*
|
|
111306
|
-
* @param {Element} target - Element to be checked.
|
|
111307
|
-
* @returns {boolean}
|
|
111308
|
-
*/
|
|
111309
|
-
function isDocumentElement(target) {
|
|
111310
|
-
return target === getWindowOf(target).document.documentElement;
|
|
111311
|
-
}
|
|
111312
|
-
/**
|
|
111313
|
-
* Calculates an appropriate content rectangle for provided html or svg element.
|
|
111314
|
-
*
|
|
111315
|
-
* @param {Element} target - Element content rectangle of which needs to be calculated.
|
|
111316
|
-
* @returns {DOMRectInit}
|
|
111317
|
-
*/
|
|
111318
|
-
function getContentRect(target) {
|
|
111319
|
-
if (!isBrowser) {
|
|
111320
|
-
return emptyRect;
|
|
111321
|
-
}
|
|
111322
|
-
if (isSVGGraphicsElement(target)) {
|
|
111323
|
-
return getSVGContentRect(target);
|
|
111324
|
-
}
|
|
111325
|
-
return getHTMLElementContentRect(target);
|
|
111326
|
-
}
|
|
111327
|
-
/**
|
|
111328
|
-
* Creates rectangle with an interface of the DOMRectReadOnly.
|
|
111329
|
-
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
|
|
111330
|
-
*
|
|
111331
|
-
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
|
|
111332
|
-
* @returns {DOMRectReadOnly}
|
|
111333
|
-
*/
|
|
111334
|
-
function createReadOnlyRect(_a) {
|
|
111335
|
-
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
111336
|
-
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
|
|
111337
|
-
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
|
|
111338
|
-
var rect = Object.create(Constr.prototype);
|
|
111339
|
-
// Rectangle's properties are not writable and non-enumerable.
|
|
111340
|
-
defineConfigurable(rect, {
|
|
111341
|
-
x: x, y: y, width: width, height: height,
|
|
111342
|
-
top: y,
|
|
111343
|
-
right: x + width,
|
|
111344
|
-
bottom: height + y,
|
|
111345
|
-
left: x
|
|
111346
|
-
});
|
|
111347
|
-
return rect;
|
|
111348
|
-
}
|
|
111349
|
-
/**
|
|
111350
|
-
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
|
|
111351
|
-
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
|
|
111352
|
-
*
|
|
111353
|
-
* @param {number} x - X coordinate.
|
|
111354
|
-
* @param {number} y - Y coordinate.
|
|
111355
|
-
* @param {number} width - Rectangle's width.
|
|
111356
|
-
* @param {number} height - Rectangle's height.
|
|
111357
|
-
* @returns {DOMRectInit}
|
|
111358
|
-
*/
|
|
111359
|
-
function createRectInit(x, y, width, height) {
|
|
111360
|
-
return { x: x, y: y, width: width, height: height };
|
|
111361
|
-
}
|
|
111362
|
-
|
|
111363
|
-
/**
|
|
111364
|
-
* Class that is responsible for computations of the content rectangle of
|
|
111365
|
-
* provided DOM element and for keeping track of it's changes.
|
|
111366
|
-
*/
|
|
111367
|
-
var ResizeObservation = /** @class */ (function () {
|
|
111368
|
-
/**
|
|
111369
|
-
* Creates an instance of ResizeObservation.
|
|
111370
|
-
*
|
|
111371
|
-
* @param {Element} target - Element to be observed.
|
|
111372
|
-
*/
|
|
111373
|
-
function ResizeObservation(target) {
|
|
111374
|
-
/**
|
|
111375
|
-
* Broadcasted width of content rectangle.
|
|
111376
|
-
*
|
|
111377
|
-
* @type {number}
|
|
111378
|
-
*/
|
|
111379
|
-
this.broadcastWidth = 0;
|
|
111380
|
-
/**
|
|
111381
|
-
* Broadcasted height of content rectangle.
|
|
111382
|
-
*
|
|
111383
|
-
* @type {number}
|
|
111384
|
-
*/
|
|
111385
|
-
this.broadcastHeight = 0;
|
|
111386
|
-
/**
|
|
111387
|
-
* Reference to the last observed content rectangle.
|
|
111388
|
-
*
|
|
111389
|
-
* @private {DOMRectInit}
|
|
111390
|
-
*/
|
|
111391
|
-
this.contentRect_ = createRectInit(0, 0, 0, 0);
|
|
111392
|
-
this.target = target;
|
|
111393
|
-
}
|
|
111394
|
-
/**
|
|
111395
|
-
* Updates content rectangle and tells whether it's width or height properties
|
|
111396
|
-
* have changed since the last broadcast.
|
|
111397
|
-
*
|
|
111398
|
-
* @returns {boolean}
|
|
111399
|
-
*/
|
|
111400
|
-
ResizeObservation.prototype.isActive = function () {
|
|
111401
|
-
var rect = getContentRect(this.target);
|
|
111402
|
-
this.contentRect_ = rect;
|
|
111403
|
-
return (rect.width !== this.broadcastWidth ||
|
|
111404
|
-
rect.height !== this.broadcastHeight);
|
|
111405
|
-
};
|
|
111406
|
-
/**
|
|
111407
|
-
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
|
|
111408
|
-
* from the corresponding properties of the last observed content rectangle.
|
|
111409
|
-
*
|
|
111410
|
-
* @returns {DOMRectInit} Last observed content rectangle.
|
|
111411
|
-
*/
|
|
111412
|
-
ResizeObservation.prototype.broadcastRect = function () {
|
|
111413
|
-
var rect = this.contentRect_;
|
|
111414
|
-
this.broadcastWidth = rect.width;
|
|
111415
|
-
this.broadcastHeight = rect.height;
|
|
111416
|
-
return rect;
|
|
111417
|
-
};
|
|
111418
|
-
return ResizeObservation;
|
|
111159
|
+
// Placeholder of an empty content rectangle.
|
|
111160
|
+
var emptyRect = createRectInit(0, 0, 0, 0);
|
|
111161
|
+
/**
|
|
111162
|
+
* Converts provided string to a number.
|
|
111163
|
+
*
|
|
111164
|
+
* @param {number|string} value
|
|
111165
|
+
* @returns {number}
|
|
111166
|
+
*/
|
|
111167
|
+
function toFloat(value) {
|
|
111168
|
+
return parseFloat(value) || 0;
|
|
111169
|
+
}
|
|
111170
|
+
/**
|
|
111171
|
+
* Extracts borders size from provided styles.
|
|
111172
|
+
*
|
|
111173
|
+
* @param {CSSStyleDeclaration} styles
|
|
111174
|
+
* @param {...string} positions - Borders positions (top, right, ...)
|
|
111175
|
+
* @returns {number}
|
|
111176
|
+
*/
|
|
111177
|
+
function getBordersSize(styles) {
|
|
111178
|
+
var positions = [];
|
|
111179
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
111180
|
+
positions[_i - 1] = arguments[_i];
|
|
111181
|
+
}
|
|
111182
|
+
return positions.reduce(function (size, position) {
|
|
111183
|
+
var value = styles['border-' + position + '-width'];
|
|
111184
|
+
return size + toFloat(value);
|
|
111185
|
+
}, 0);
|
|
111186
|
+
}
|
|
111187
|
+
/**
|
|
111188
|
+
* Extracts paddings sizes from provided styles.
|
|
111189
|
+
*
|
|
111190
|
+
* @param {CSSStyleDeclaration} styles
|
|
111191
|
+
* @returns {Object} Paddings box.
|
|
111192
|
+
*/
|
|
111193
|
+
function getPaddings(styles) {
|
|
111194
|
+
var positions = ['top', 'right', 'bottom', 'left'];
|
|
111195
|
+
var paddings = {};
|
|
111196
|
+
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
111197
|
+
var position = positions_1[_i];
|
|
111198
|
+
var value = styles['padding-' + position];
|
|
111199
|
+
paddings[position] = toFloat(value);
|
|
111200
|
+
}
|
|
111201
|
+
return paddings;
|
|
111202
|
+
}
|
|
111203
|
+
/**
|
|
111204
|
+
* Calculates content rectangle of provided SVG element.
|
|
111205
|
+
*
|
|
111206
|
+
* @param {SVGGraphicsElement} target - Element content rectangle of which needs
|
|
111207
|
+
* to be calculated.
|
|
111208
|
+
* @returns {DOMRectInit}
|
|
111209
|
+
*/
|
|
111210
|
+
function getSVGContentRect(target) {
|
|
111211
|
+
var bbox = target.getBBox();
|
|
111212
|
+
return createRectInit(0, 0, bbox.width, bbox.height);
|
|
111213
|
+
}
|
|
111214
|
+
/**
|
|
111215
|
+
* Calculates content rectangle of provided HTMLElement.
|
|
111216
|
+
*
|
|
111217
|
+
* @param {HTMLElement} target - Element for which to calculate the content rectangle.
|
|
111218
|
+
* @returns {DOMRectInit}
|
|
111219
|
+
*/
|
|
111220
|
+
function getHTMLElementContentRect(target) {
|
|
111221
|
+
// Client width & height properties can't be
|
|
111222
|
+
// used exclusively as they provide rounded values.
|
|
111223
|
+
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
|
|
111224
|
+
// By this condition we can catch all non-replaced inline, hidden and
|
|
111225
|
+
// detached elements. Though elements with width & height properties less
|
|
111226
|
+
// than 0.5 will be discarded as well.
|
|
111227
|
+
//
|
|
111228
|
+
// Without it we would need to implement separate methods for each of
|
|
111229
|
+
// those cases and it's not possible to perform a precise and performance
|
|
111230
|
+
// effective test for hidden elements. E.g. even jQuery's ':visible' filter
|
|
111231
|
+
// gives wrong results for elements with width & height less than 0.5.
|
|
111232
|
+
if (!clientWidth && !clientHeight) {
|
|
111233
|
+
return emptyRect;
|
|
111234
|
+
}
|
|
111235
|
+
var styles = getWindowOf(target).getComputedStyle(target);
|
|
111236
|
+
var paddings = getPaddings(styles);
|
|
111237
|
+
var horizPad = paddings.left + paddings.right;
|
|
111238
|
+
var vertPad = paddings.top + paddings.bottom;
|
|
111239
|
+
// Computed styles of width & height are being used because they are the
|
|
111240
|
+
// only dimensions available to JS that contain non-rounded values. It could
|
|
111241
|
+
// be possible to utilize the getBoundingClientRect if only it's data wasn't
|
|
111242
|
+
// affected by CSS transformations let alone paddings, borders and scroll bars.
|
|
111243
|
+
var width = toFloat(styles.width), height = toFloat(styles.height);
|
|
111244
|
+
// Width & height include paddings and borders when the 'border-box' box
|
|
111245
|
+
// model is applied (except for IE).
|
|
111246
|
+
if (styles.boxSizing === 'border-box') {
|
|
111247
|
+
// Following conditions are required to handle Internet Explorer which
|
|
111248
|
+
// doesn't include paddings and borders to computed CSS dimensions.
|
|
111249
|
+
//
|
|
111250
|
+
// We can say that if CSS dimensions + paddings are equal to the "client"
|
|
111251
|
+
// properties then it's either IE, and thus we don't need to subtract
|
|
111252
|
+
// anything, or an element merely doesn't have paddings/borders styles.
|
|
111253
|
+
if (Math.round(width + horizPad) !== clientWidth) {
|
|
111254
|
+
width -= getBordersSize(styles, 'left', 'right') + horizPad;
|
|
111255
|
+
}
|
|
111256
|
+
if (Math.round(height + vertPad) !== clientHeight) {
|
|
111257
|
+
height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
|
|
111258
|
+
}
|
|
111259
|
+
}
|
|
111260
|
+
// Following steps can't be applied to the document's root element as its
|
|
111261
|
+
// client[Width/Height] properties represent viewport area of the window.
|
|
111262
|
+
// Besides, it's as well not necessary as the <html> itself neither has
|
|
111263
|
+
// rendered scroll bars nor it can be clipped.
|
|
111264
|
+
if (!isDocumentElement(target)) {
|
|
111265
|
+
// In some browsers (only in Firefox, actually) CSS width & height
|
|
111266
|
+
// include scroll bars size which can be removed at this step as scroll
|
|
111267
|
+
// bars are the only difference between rounded dimensions + paddings
|
|
111268
|
+
// and "client" properties, though that is not always true in Chrome.
|
|
111269
|
+
var vertScrollbar = Math.round(width + horizPad) - clientWidth;
|
|
111270
|
+
var horizScrollbar = Math.round(height + vertPad) - clientHeight;
|
|
111271
|
+
// Chrome has a rather weird rounding of "client" properties.
|
|
111272
|
+
// E.g. for an element with content width of 314.2px it sometimes gives
|
|
111273
|
+
// the client width of 315px and for the width of 314.7px it may give
|
|
111274
|
+
// 314px. And it doesn't happen all the time. So just ignore this delta
|
|
111275
|
+
// as a non-relevant.
|
|
111276
|
+
if (Math.abs(vertScrollbar) !== 1) {
|
|
111277
|
+
width -= vertScrollbar;
|
|
111278
|
+
}
|
|
111279
|
+
if (Math.abs(horizScrollbar) !== 1) {
|
|
111280
|
+
height -= horizScrollbar;
|
|
111281
|
+
}
|
|
111282
|
+
}
|
|
111283
|
+
return createRectInit(paddings.left, paddings.top, width, height);
|
|
111284
|
+
}
|
|
111285
|
+
/**
|
|
111286
|
+
* Checks whether provided element is an instance of the SVGGraphicsElement.
|
|
111287
|
+
*
|
|
111288
|
+
* @param {Element} target - Element to be checked.
|
|
111289
|
+
* @returns {boolean}
|
|
111290
|
+
*/
|
|
111291
|
+
var isSVGGraphicsElement = (function () {
|
|
111292
|
+
// Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
|
|
111293
|
+
// interface.
|
|
111294
|
+
if (typeof SVGGraphicsElement !== 'undefined') {
|
|
111295
|
+
return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
|
|
111296
|
+
}
|
|
111297
|
+
// If it's so, then check that element is at least an instance of the
|
|
111298
|
+
// SVGElement and that it has the "getBBox" method.
|
|
111299
|
+
// eslint-disable-next-line no-extra-parens
|
|
111300
|
+
return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
|
|
111301
|
+
typeof target.getBBox === 'function'); };
|
|
111302
|
+
})();
|
|
111303
|
+
/**
|
|
111304
|
+
* Checks whether provided element is a document element (<html>).
|
|
111305
|
+
*
|
|
111306
|
+
* @param {Element} target - Element to be checked.
|
|
111307
|
+
* @returns {boolean}
|
|
111308
|
+
*/
|
|
111309
|
+
function isDocumentElement(target) {
|
|
111310
|
+
return target === getWindowOf(target).document.documentElement;
|
|
111311
|
+
}
|
|
111312
|
+
/**
|
|
111313
|
+
* Calculates an appropriate content rectangle for provided html or svg element.
|
|
111314
|
+
*
|
|
111315
|
+
* @param {Element} target - Element content rectangle of which needs to be calculated.
|
|
111316
|
+
* @returns {DOMRectInit}
|
|
111317
|
+
*/
|
|
111318
|
+
function getContentRect(target) {
|
|
111319
|
+
if (!isBrowser) {
|
|
111320
|
+
return emptyRect;
|
|
111321
|
+
}
|
|
111322
|
+
if (isSVGGraphicsElement(target)) {
|
|
111323
|
+
return getSVGContentRect(target);
|
|
111324
|
+
}
|
|
111325
|
+
return getHTMLElementContentRect(target);
|
|
111326
|
+
}
|
|
111327
|
+
/**
|
|
111328
|
+
* Creates rectangle with an interface of the DOMRectReadOnly.
|
|
111329
|
+
* Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
|
|
111330
|
+
*
|
|
111331
|
+
* @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
|
|
111332
|
+
* @returns {DOMRectReadOnly}
|
|
111333
|
+
*/
|
|
111334
|
+
function createReadOnlyRect(_a) {
|
|
111335
|
+
var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
111336
|
+
// If DOMRectReadOnly is available use it as a prototype for the rectangle.
|
|
111337
|
+
var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
|
|
111338
|
+
var rect = Object.create(Constr.prototype);
|
|
111339
|
+
// Rectangle's properties are not writable and non-enumerable.
|
|
111340
|
+
defineConfigurable(rect, {
|
|
111341
|
+
x: x, y: y, width: width, height: height,
|
|
111342
|
+
top: y,
|
|
111343
|
+
right: x + width,
|
|
111344
|
+
bottom: height + y,
|
|
111345
|
+
left: x
|
|
111346
|
+
});
|
|
111347
|
+
return rect;
|
|
111348
|
+
}
|
|
111349
|
+
/**
|
|
111350
|
+
* Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
|
|
111351
|
+
* Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
|
|
111352
|
+
*
|
|
111353
|
+
* @param {number} x - X coordinate.
|
|
111354
|
+
* @param {number} y - Y coordinate.
|
|
111355
|
+
* @param {number} width - Rectangle's width.
|
|
111356
|
+
* @param {number} height - Rectangle's height.
|
|
111357
|
+
* @returns {DOMRectInit}
|
|
111358
|
+
*/
|
|
111359
|
+
function createRectInit(x, y, width, height) {
|
|
111360
|
+
return { x: x, y: y, width: width, height: height };
|
|
111361
|
+
}
|
|
111362
|
+
|
|
111363
|
+
/**
|
|
111364
|
+
* Class that is responsible for computations of the content rectangle of
|
|
111365
|
+
* provided DOM element and for keeping track of it's changes.
|
|
111366
|
+
*/
|
|
111367
|
+
var ResizeObservation = /** @class */ (function () {
|
|
111368
|
+
/**
|
|
111369
|
+
* Creates an instance of ResizeObservation.
|
|
111370
|
+
*
|
|
111371
|
+
* @param {Element} target - Element to be observed.
|
|
111372
|
+
*/
|
|
111373
|
+
function ResizeObservation(target) {
|
|
111374
|
+
/**
|
|
111375
|
+
* Broadcasted width of content rectangle.
|
|
111376
|
+
*
|
|
111377
|
+
* @type {number}
|
|
111378
|
+
*/
|
|
111379
|
+
this.broadcastWidth = 0;
|
|
111380
|
+
/**
|
|
111381
|
+
* Broadcasted height of content rectangle.
|
|
111382
|
+
*
|
|
111383
|
+
* @type {number}
|
|
111384
|
+
*/
|
|
111385
|
+
this.broadcastHeight = 0;
|
|
111386
|
+
/**
|
|
111387
|
+
* Reference to the last observed content rectangle.
|
|
111388
|
+
*
|
|
111389
|
+
* @private {DOMRectInit}
|
|
111390
|
+
*/
|
|
111391
|
+
this.contentRect_ = createRectInit(0, 0, 0, 0);
|
|
111392
|
+
this.target = target;
|
|
111393
|
+
}
|
|
111394
|
+
/**
|
|
111395
|
+
* Updates content rectangle and tells whether it's width or height properties
|
|
111396
|
+
* have changed since the last broadcast.
|
|
111397
|
+
*
|
|
111398
|
+
* @returns {boolean}
|
|
111399
|
+
*/
|
|
111400
|
+
ResizeObservation.prototype.isActive = function () {
|
|
111401
|
+
var rect = getContentRect(this.target);
|
|
111402
|
+
this.contentRect_ = rect;
|
|
111403
|
+
return (rect.width !== this.broadcastWidth ||
|
|
111404
|
+
rect.height !== this.broadcastHeight);
|
|
111405
|
+
};
|
|
111406
|
+
/**
|
|
111407
|
+
* Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
|
|
111408
|
+
* from the corresponding properties of the last observed content rectangle.
|
|
111409
|
+
*
|
|
111410
|
+
* @returns {DOMRectInit} Last observed content rectangle.
|
|
111411
|
+
*/
|
|
111412
|
+
ResizeObservation.prototype.broadcastRect = function () {
|
|
111413
|
+
var rect = this.contentRect_;
|
|
111414
|
+
this.broadcastWidth = rect.width;
|
|
111415
|
+
this.broadcastHeight = rect.height;
|
|
111416
|
+
return rect;
|
|
111417
|
+
};
|
|
111418
|
+
return ResizeObservation;
|
|
111419
111419
|
}());
|
|
111420
111420
|
|
|
111421
|
-
var ResizeObserverEntry = /** @class */ (function () {
|
|
111422
|
-
/**
|
|
111423
|
-
* Creates an instance of ResizeObserverEntry.
|
|
111424
|
-
*
|
|
111425
|
-
* @param {Element} target - Element that is being observed.
|
|
111426
|
-
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
|
|
111427
|
-
*/
|
|
111428
|
-
function ResizeObserverEntry(target, rectInit) {
|
|
111429
|
-
var contentRect = createReadOnlyRect(rectInit);
|
|
111430
|
-
// According to the specification following properties are not writable
|
|
111431
|
-
// and are also not enumerable in the native implementation.
|
|
111432
|
-
//
|
|
111433
|
-
// Property accessors are not being used as they'd require to define a
|
|
111434
|
-
// private WeakMap storage which may cause memory leaks in browsers that
|
|
111435
|
-
// don't support this type of collections.
|
|
111436
|
-
defineConfigurable(this, { target: target, contentRect: contentRect });
|
|
111437
|
-
}
|
|
111438
|
-
return ResizeObserverEntry;
|
|
111421
|
+
var ResizeObserverEntry = /** @class */ (function () {
|
|
111422
|
+
/**
|
|
111423
|
+
* Creates an instance of ResizeObserverEntry.
|
|
111424
|
+
*
|
|
111425
|
+
* @param {Element} target - Element that is being observed.
|
|
111426
|
+
* @param {DOMRectInit} rectInit - Data of the element's content rectangle.
|
|
111427
|
+
*/
|
|
111428
|
+
function ResizeObserverEntry(target, rectInit) {
|
|
111429
|
+
var contentRect = createReadOnlyRect(rectInit);
|
|
111430
|
+
// According to the specification following properties are not writable
|
|
111431
|
+
// and are also not enumerable in the native implementation.
|
|
111432
|
+
//
|
|
111433
|
+
// Property accessors are not being used as they'd require to define a
|
|
111434
|
+
// private WeakMap storage which may cause memory leaks in browsers that
|
|
111435
|
+
// don't support this type of collections.
|
|
111436
|
+
defineConfigurable(this, { target: target, contentRect: contentRect });
|
|
111437
|
+
}
|
|
111438
|
+
return ResizeObserverEntry;
|
|
111439
111439
|
}());
|
|
111440
111440
|
|
|
111441
|
-
var ResizeObserverSPI = /** @class */ (function () {
|
|
111442
|
-
/**
|
|
111443
|
-
* Creates a new instance of ResizeObserver.
|
|
111444
|
-
*
|
|
111445
|
-
* @param {ResizeObserverCallback} callback - Callback function that is invoked
|
|
111446
|
-
* when one of the observed elements changes it's content dimensions.
|
|
111447
|
-
* @param {ResizeObserverController} controller - Controller instance which
|
|
111448
|
-
* is responsible for the updates of observer.
|
|
111449
|
-
* @param {ResizeObserver} callbackCtx - Reference to the public
|
|
111450
|
-
* ResizeObserver instance which will be passed to callback function.
|
|
111451
|
-
*/
|
|
111452
|
-
function ResizeObserverSPI(callback, controller, callbackCtx) {
|
|
111453
|
-
/**
|
|
111454
|
-
* Collection of resize observations that have detected changes in dimensions
|
|
111455
|
-
* of elements.
|
|
111456
|
-
*
|
|
111457
|
-
* @private {Array<ResizeObservation>}
|
|
111458
|
-
*/
|
|
111459
|
-
this.activeObservations_ = [];
|
|
111460
|
-
/**
|
|
111461
|
-
* Registry of the ResizeObservation instances.
|
|
111462
|
-
*
|
|
111463
|
-
* @private {Map<Element, ResizeObservation>}
|
|
111464
|
-
*/
|
|
111465
|
-
this.observations_ = new MapShim();
|
|
111466
|
-
if (typeof callback !== 'function') {
|
|
111467
|
-
throw new TypeError('The callback provided as parameter 1 is not a function.');
|
|
111468
|
-
}
|
|
111469
|
-
this.callback_ = callback;
|
|
111470
|
-
this.controller_ = controller;
|
|
111471
|
-
this.callbackCtx_ = callbackCtx;
|
|
111472
|
-
}
|
|
111473
|
-
/**
|
|
111474
|
-
* Starts observing provided element.
|
|
111475
|
-
*
|
|
111476
|
-
* @param {Element} target - Element to be observed.
|
|
111477
|
-
* @returns {void}
|
|
111478
|
-
*/
|
|
111479
|
-
ResizeObserverSPI.prototype.observe = function (target) {
|
|
111480
|
-
if (!arguments.length) {
|
|
111481
|
-
throw new TypeError('1 argument required, but only 0 present.');
|
|
111482
|
-
}
|
|
111483
|
-
// Do nothing if current environment doesn't have the Element interface.
|
|
111484
|
-
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
111485
|
-
return;
|
|
111486
|
-
}
|
|
111487
|
-
if (!(target instanceof getWindowOf(target).Element)) {
|
|
111488
|
-
throw new TypeError('parameter 1 is not of type "Element".');
|
|
111489
|
-
}
|
|
111490
|
-
var observations = this.observations_;
|
|
111491
|
-
// Do nothing if element is already being observed.
|
|
111492
|
-
if (observations.has(target)) {
|
|
111493
|
-
return;
|
|
111494
|
-
}
|
|
111495
|
-
observations.set(target, new ResizeObservation(target));
|
|
111496
|
-
this.controller_.addObserver(this);
|
|
111497
|
-
// Force the update of observations.
|
|
111498
|
-
this.controller_.refresh();
|
|
111499
|
-
};
|
|
111500
|
-
/**
|
|
111501
|
-
* Stops observing provided element.
|
|
111502
|
-
*
|
|
111503
|
-
* @param {Element} target - Element to stop observing.
|
|
111504
|
-
* @returns {void}
|
|
111505
|
-
*/
|
|
111506
|
-
ResizeObserverSPI.prototype.unobserve = function (target) {
|
|
111507
|
-
if (!arguments.length) {
|
|
111508
|
-
throw new TypeError('1 argument required, but only 0 present.');
|
|
111509
|
-
}
|
|
111510
|
-
// Do nothing if current environment doesn't have the Element interface.
|
|
111511
|
-
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
111512
|
-
return;
|
|
111513
|
-
}
|
|
111514
|
-
if (!(target instanceof getWindowOf(target).Element)) {
|
|
111515
|
-
throw new TypeError('parameter 1 is not of type "Element".');
|
|
111516
|
-
}
|
|
111517
|
-
var observations = this.observations_;
|
|
111518
|
-
// Do nothing if element is not being observed.
|
|
111519
|
-
if (!observations.has(target)) {
|
|
111520
|
-
return;
|
|
111521
|
-
}
|
|
111522
|
-
observations.delete(target);
|
|
111523
|
-
if (!observations.size) {
|
|
111524
|
-
this.controller_.removeObserver(this);
|
|
111525
|
-
}
|
|
111526
|
-
};
|
|
111527
|
-
/**
|
|
111528
|
-
* Stops observing all elements.
|
|
111529
|
-
*
|
|
111530
|
-
* @returns {void}
|
|
111531
|
-
*/
|
|
111532
|
-
ResizeObserverSPI.prototype.disconnect = function () {
|
|
111533
|
-
this.clearActive();
|
|
111534
|
-
this.observations_.clear();
|
|
111535
|
-
this.controller_.removeObserver(this);
|
|
111536
|
-
};
|
|
111537
|
-
/**
|
|
111538
|
-
* Collects observation instances the associated element of which has changed
|
|
111539
|
-
* it's content rectangle.
|
|
111540
|
-
*
|
|
111541
|
-
* @returns {void}
|
|
111542
|
-
*/
|
|
111543
|
-
ResizeObserverSPI.prototype.gatherActive = function () {
|
|
111544
|
-
var _this = this;
|
|
111545
|
-
this.clearActive();
|
|
111546
|
-
this.observations_.forEach(function (observation) {
|
|
111547
|
-
if (observation.isActive()) {
|
|
111548
|
-
_this.activeObservations_.push(observation);
|
|
111549
|
-
}
|
|
111550
|
-
});
|
|
111551
|
-
};
|
|
111552
|
-
/**
|
|
111553
|
-
* Invokes initial callback function with a list of ResizeObserverEntry
|
|
111554
|
-
* instances collected from active resize observations.
|
|
111555
|
-
*
|
|
111556
|
-
* @returns {void}
|
|
111557
|
-
*/
|
|
111558
|
-
ResizeObserverSPI.prototype.broadcastActive = function () {
|
|
111559
|
-
// Do nothing if observer doesn't have active observations.
|
|
111560
|
-
if (!this.hasActive()) {
|
|
111561
|
-
return;
|
|
111562
|
-
}
|
|
111563
|
-
var ctx = this.callbackCtx_;
|
|
111564
|
-
// Create ResizeObserverEntry instance for every active observation.
|
|
111565
|
-
var entries = this.activeObservations_.map(function (observation) {
|
|
111566
|
-
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
|
|
111567
|
-
});
|
|
111568
|
-
this.callback_.call(ctx, entries, ctx);
|
|
111569
|
-
this.clearActive();
|
|
111570
|
-
};
|
|
111571
|
-
/**
|
|
111572
|
-
* Clears the collection of active observations.
|
|
111573
|
-
*
|
|
111574
|
-
* @returns {void}
|
|
111575
|
-
*/
|
|
111576
|
-
ResizeObserverSPI.prototype.clearActive = function () {
|
|
111577
|
-
this.activeObservations_.splice(0);
|
|
111578
|
-
};
|
|
111579
|
-
/**
|
|
111580
|
-
* Tells whether observer has active observations.
|
|
111581
|
-
*
|
|
111582
|
-
* @returns {boolean}
|
|
111583
|
-
*/
|
|
111584
|
-
ResizeObserverSPI.prototype.hasActive = function () {
|
|
111585
|
-
return this.activeObservations_.length > 0;
|
|
111586
|
-
};
|
|
111587
|
-
return ResizeObserverSPI;
|
|
111441
|
+
var ResizeObserverSPI = /** @class */ (function () {
|
|
111442
|
+
/**
|
|
111443
|
+
* Creates a new instance of ResizeObserver.
|
|
111444
|
+
*
|
|
111445
|
+
* @param {ResizeObserverCallback} callback - Callback function that is invoked
|
|
111446
|
+
* when one of the observed elements changes it's content dimensions.
|
|
111447
|
+
* @param {ResizeObserverController} controller - Controller instance which
|
|
111448
|
+
* is responsible for the updates of observer.
|
|
111449
|
+
* @param {ResizeObserver} callbackCtx - Reference to the public
|
|
111450
|
+
* ResizeObserver instance which will be passed to callback function.
|
|
111451
|
+
*/
|
|
111452
|
+
function ResizeObserverSPI(callback, controller, callbackCtx) {
|
|
111453
|
+
/**
|
|
111454
|
+
* Collection of resize observations that have detected changes in dimensions
|
|
111455
|
+
* of elements.
|
|
111456
|
+
*
|
|
111457
|
+
* @private {Array<ResizeObservation>}
|
|
111458
|
+
*/
|
|
111459
|
+
this.activeObservations_ = [];
|
|
111460
|
+
/**
|
|
111461
|
+
* Registry of the ResizeObservation instances.
|
|
111462
|
+
*
|
|
111463
|
+
* @private {Map<Element, ResizeObservation>}
|
|
111464
|
+
*/
|
|
111465
|
+
this.observations_ = new MapShim();
|
|
111466
|
+
if (typeof callback !== 'function') {
|
|
111467
|
+
throw new TypeError('The callback provided as parameter 1 is not a function.');
|
|
111468
|
+
}
|
|
111469
|
+
this.callback_ = callback;
|
|
111470
|
+
this.controller_ = controller;
|
|
111471
|
+
this.callbackCtx_ = callbackCtx;
|
|
111472
|
+
}
|
|
111473
|
+
/**
|
|
111474
|
+
* Starts observing provided element.
|
|
111475
|
+
*
|
|
111476
|
+
* @param {Element} target - Element to be observed.
|
|
111477
|
+
* @returns {void}
|
|
111478
|
+
*/
|
|
111479
|
+
ResizeObserverSPI.prototype.observe = function (target) {
|
|
111480
|
+
if (!arguments.length) {
|
|
111481
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
111482
|
+
}
|
|
111483
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
111484
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
111485
|
+
return;
|
|
111486
|
+
}
|
|
111487
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
111488
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
111489
|
+
}
|
|
111490
|
+
var observations = this.observations_;
|
|
111491
|
+
// Do nothing if element is already being observed.
|
|
111492
|
+
if (observations.has(target)) {
|
|
111493
|
+
return;
|
|
111494
|
+
}
|
|
111495
|
+
observations.set(target, new ResizeObservation(target));
|
|
111496
|
+
this.controller_.addObserver(this);
|
|
111497
|
+
// Force the update of observations.
|
|
111498
|
+
this.controller_.refresh();
|
|
111499
|
+
};
|
|
111500
|
+
/**
|
|
111501
|
+
* Stops observing provided element.
|
|
111502
|
+
*
|
|
111503
|
+
* @param {Element} target - Element to stop observing.
|
|
111504
|
+
* @returns {void}
|
|
111505
|
+
*/
|
|
111506
|
+
ResizeObserverSPI.prototype.unobserve = function (target) {
|
|
111507
|
+
if (!arguments.length) {
|
|
111508
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
111509
|
+
}
|
|
111510
|
+
// Do nothing if current environment doesn't have the Element interface.
|
|
111511
|
+
if (typeof Element === 'undefined' || !(Element instanceof Object)) {
|
|
111512
|
+
return;
|
|
111513
|
+
}
|
|
111514
|
+
if (!(target instanceof getWindowOf(target).Element)) {
|
|
111515
|
+
throw new TypeError('parameter 1 is not of type "Element".');
|
|
111516
|
+
}
|
|
111517
|
+
var observations = this.observations_;
|
|
111518
|
+
// Do nothing if element is not being observed.
|
|
111519
|
+
if (!observations.has(target)) {
|
|
111520
|
+
return;
|
|
111521
|
+
}
|
|
111522
|
+
observations.delete(target);
|
|
111523
|
+
if (!observations.size) {
|
|
111524
|
+
this.controller_.removeObserver(this);
|
|
111525
|
+
}
|
|
111526
|
+
};
|
|
111527
|
+
/**
|
|
111528
|
+
* Stops observing all elements.
|
|
111529
|
+
*
|
|
111530
|
+
* @returns {void}
|
|
111531
|
+
*/
|
|
111532
|
+
ResizeObserverSPI.prototype.disconnect = function () {
|
|
111533
|
+
this.clearActive();
|
|
111534
|
+
this.observations_.clear();
|
|
111535
|
+
this.controller_.removeObserver(this);
|
|
111536
|
+
};
|
|
111537
|
+
/**
|
|
111538
|
+
* Collects observation instances the associated element of which has changed
|
|
111539
|
+
* it's content rectangle.
|
|
111540
|
+
*
|
|
111541
|
+
* @returns {void}
|
|
111542
|
+
*/
|
|
111543
|
+
ResizeObserverSPI.prototype.gatherActive = function () {
|
|
111544
|
+
var _this = this;
|
|
111545
|
+
this.clearActive();
|
|
111546
|
+
this.observations_.forEach(function (observation) {
|
|
111547
|
+
if (observation.isActive()) {
|
|
111548
|
+
_this.activeObservations_.push(observation);
|
|
111549
|
+
}
|
|
111550
|
+
});
|
|
111551
|
+
};
|
|
111552
|
+
/**
|
|
111553
|
+
* Invokes initial callback function with a list of ResizeObserverEntry
|
|
111554
|
+
* instances collected from active resize observations.
|
|
111555
|
+
*
|
|
111556
|
+
* @returns {void}
|
|
111557
|
+
*/
|
|
111558
|
+
ResizeObserverSPI.prototype.broadcastActive = function () {
|
|
111559
|
+
// Do nothing if observer doesn't have active observations.
|
|
111560
|
+
if (!this.hasActive()) {
|
|
111561
|
+
return;
|
|
111562
|
+
}
|
|
111563
|
+
var ctx = this.callbackCtx_;
|
|
111564
|
+
// Create ResizeObserverEntry instance for every active observation.
|
|
111565
|
+
var entries = this.activeObservations_.map(function (observation) {
|
|
111566
|
+
return new ResizeObserverEntry(observation.target, observation.broadcastRect());
|
|
111567
|
+
});
|
|
111568
|
+
this.callback_.call(ctx, entries, ctx);
|
|
111569
|
+
this.clearActive();
|
|
111570
|
+
};
|
|
111571
|
+
/**
|
|
111572
|
+
* Clears the collection of active observations.
|
|
111573
|
+
*
|
|
111574
|
+
* @returns {void}
|
|
111575
|
+
*/
|
|
111576
|
+
ResizeObserverSPI.prototype.clearActive = function () {
|
|
111577
|
+
this.activeObservations_.splice(0);
|
|
111578
|
+
};
|
|
111579
|
+
/**
|
|
111580
|
+
* Tells whether observer has active observations.
|
|
111581
|
+
*
|
|
111582
|
+
* @returns {boolean}
|
|
111583
|
+
*/
|
|
111584
|
+
ResizeObserverSPI.prototype.hasActive = function () {
|
|
111585
|
+
return this.activeObservations_.length > 0;
|
|
111586
|
+
};
|
|
111587
|
+
return ResizeObserverSPI;
|
|
111588
111588
|
}());
|
|
111589
111589
|
|
|
111590
|
-
// Registry of internal observers. If WeakMap is not available use current shim
|
|
111591
|
-
// for the Map collection as it has all required methods and because WeakMap
|
|
111592
|
-
// can't be fully polyfilled anyway.
|
|
111593
|
-
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
|
|
111594
|
-
/**
|
|
111595
|
-
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
|
|
111596
|
-
* exposing only those methods and properties that are defined in the spec.
|
|
111597
|
-
*/
|
|
111598
|
-
var ResizeObserver = /** @class */ (function () {
|
|
111599
|
-
/**
|
|
111600
|
-
* Creates a new instance of ResizeObserver.
|
|
111601
|
-
*
|
|
111602
|
-
* @param {ResizeObserverCallback} callback - Callback that is invoked when
|
|
111603
|
-
* dimensions of the observed elements change.
|
|
111604
|
-
*/
|
|
111605
|
-
function ResizeObserver(callback) {
|
|
111606
|
-
if (!(this instanceof ResizeObserver)) {
|
|
111607
|
-
throw new TypeError('Cannot call a class as a function.');
|
|
111608
|
-
}
|
|
111609
|
-
if (!arguments.length) {
|
|
111610
|
-
throw new TypeError('1 argument required, but only 0 present.');
|
|
111611
|
-
}
|
|
111612
|
-
var controller = ResizeObserverController.getInstance();
|
|
111613
|
-
var observer = new ResizeObserverSPI(callback, controller, this);
|
|
111614
|
-
observers.set(this, observer);
|
|
111615
|
-
}
|
|
111616
|
-
return ResizeObserver;
|
|
111617
|
-
}());
|
|
111618
|
-
// Expose public methods of ResizeObserver.
|
|
111619
|
-
[
|
|
111620
|
-
'observe',
|
|
111621
|
-
'unobserve',
|
|
111622
|
-
'disconnect'
|
|
111623
|
-
].forEach(function (method) {
|
|
111624
|
-
ResizeObserver.prototype[method] = function () {
|
|
111625
|
-
var _a;
|
|
111626
|
-
return (_a = observers.get(this))[method].apply(_a, arguments);
|
|
111627
|
-
};
|
|
111590
|
+
// Registry of internal observers. If WeakMap is not available use current shim
|
|
111591
|
+
// for the Map collection as it has all required methods and because WeakMap
|
|
111592
|
+
// can't be fully polyfilled anyway.
|
|
111593
|
+
var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
|
|
111594
|
+
/**
|
|
111595
|
+
* ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
|
|
111596
|
+
* exposing only those methods and properties that are defined in the spec.
|
|
111597
|
+
*/
|
|
111598
|
+
var ResizeObserver = /** @class */ (function () {
|
|
111599
|
+
/**
|
|
111600
|
+
* Creates a new instance of ResizeObserver.
|
|
111601
|
+
*
|
|
111602
|
+
* @param {ResizeObserverCallback} callback - Callback that is invoked when
|
|
111603
|
+
* dimensions of the observed elements change.
|
|
111604
|
+
*/
|
|
111605
|
+
function ResizeObserver(callback) {
|
|
111606
|
+
if (!(this instanceof ResizeObserver)) {
|
|
111607
|
+
throw new TypeError('Cannot call a class as a function.');
|
|
111608
|
+
}
|
|
111609
|
+
if (!arguments.length) {
|
|
111610
|
+
throw new TypeError('1 argument required, but only 0 present.');
|
|
111611
|
+
}
|
|
111612
|
+
var controller = ResizeObserverController.getInstance();
|
|
111613
|
+
var observer = new ResizeObserverSPI(callback, controller, this);
|
|
111614
|
+
observers.set(this, observer);
|
|
111615
|
+
}
|
|
111616
|
+
return ResizeObserver;
|
|
111617
|
+
}());
|
|
111618
|
+
// Expose public methods of ResizeObserver.
|
|
111619
|
+
[
|
|
111620
|
+
'observe',
|
|
111621
|
+
'unobserve',
|
|
111622
|
+
'disconnect'
|
|
111623
|
+
].forEach(function (method) {
|
|
111624
|
+
ResizeObserver.prototype[method] = function () {
|
|
111625
|
+
var _a;
|
|
111626
|
+
return (_a = observers.get(this))[method].apply(_a, arguments);
|
|
111627
|
+
};
|
|
111628
111628
|
});
|
|
111629
111629
|
|
|
111630
|
-
var index = (function () {
|
|
111631
|
-
// Export existing implementation if available.
|
|
111632
|
-
if (typeof global$1.ResizeObserver !== 'undefined') {
|
|
111633
|
-
return global$1.ResizeObserver;
|
|
111634
|
-
}
|
|
111635
|
-
return ResizeObserver;
|
|
111630
|
+
var index = (function () {
|
|
111631
|
+
// Export existing implementation if available.
|
|
111632
|
+
if (typeof global$1.ResizeObserver !== 'undefined') {
|
|
111633
|
+
return global$1.ResizeObserver;
|
|
111634
|
+
}
|
|
111635
|
+
return ResizeObserver;
|
|
111636
111636
|
})();
|
|
111637
111637
|
|
|
111638
111638
|
/* harmony default export */ __webpack_exports__["default"] = (index);
|
|
@@ -121838,224 +121838,224 @@ __webpack_require__("a732");
|
|
|
121838
121838
|
/* unused harmony export __importDefault */
|
|
121839
121839
|
/* unused harmony export __classPrivateFieldGet */
|
|
121840
121840
|
/* unused harmony export __classPrivateFieldSet */
|
|
121841
|
-
/*! *****************************************************************************
|
|
121842
|
-
Copyright (c) Microsoft Corporation.
|
|
121843
|
-
|
|
121844
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
121845
|
-
purpose with or without fee is hereby granted.
|
|
121846
|
-
|
|
121847
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
121848
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
121849
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
121850
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
121851
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
121852
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
121853
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
121854
|
-
***************************************************************************** */
|
|
121855
|
-
/* global Reflect, Promise */
|
|
121856
|
-
|
|
121857
|
-
var extendStatics = function(d, b) {
|
|
121858
|
-
extendStatics = Object.setPrototypeOf ||
|
|
121859
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
121860
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
121861
|
-
return extendStatics(d, b);
|
|
121862
|
-
};
|
|
121863
|
-
|
|
121864
|
-
function __extends(d, b) {
|
|
121865
|
-
extendStatics(d, b);
|
|
121866
|
-
function __() { this.constructor = d; }
|
|
121867
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
121868
|
-
}
|
|
121869
|
-
|
|
121870
|
-
var __assign = function() {
|
|
121871
|
-
__assign = Object.assign || function __assign(t) {
|
|
121872
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
121873
|
-
s = arguments[i];
|
|
121874
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
121875
|
-
}
|
|
121876
|
-
return t;
|
|
121877
|
-
}
|
|
121878
|
-
return __assign.apply(this, arguments);
|
|
121879
|
-
}
|
|
121880
|
-
|
|
121881
|
-
function __rest(s, e) {
|
|
121882
|
-
var t = {};
|
|
121883
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
121884
|
-
t[p] = s[p];
|
|
121885
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
121886
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
121887
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
121888
|
-
t[p[i]] = s[p[i]];
|
|
121889
|
-
}
|
|
121890
|
-
return t;
|
|
121891
|
-
}
|
|
121892
|
-
|
|
121893
|
-
function __decorate(decorators, target, key, desc) {
|
|
121894
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
121895
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
121896
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
121897
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
121898
|
-
}
|
|
121899
|
-
|
|
121900
|
-
function __param(paramIndex, decorator) {
|
|
121901
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
121902
|
-
}
|
|
121903
|
-
|
|
121904
|
-
function __metadata(metadataKey, metadataValue) {
|
|
121905
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
121906
|
-
}
|
|
121907
|
-
|
|
121908
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
121909
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
121910
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
121911
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
121912
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
121913
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
121914
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
121915
|
-
});
|
|
121916
|
-
}
|
|
121917
|
-
|
|
121918
|
-
function __generator(thisArg, body) {
|
|
121919
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
121920
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
121921
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
121922
|
-
function step(op) {
|
|
121923
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
121924
|
-
while (_) try {
|
|
121925
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
121926
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
121927
|
-
switch (op[0]) {
|
|
121928
|
-
case 0: case 1: t = op; break;
|
|
121929
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
121930
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
121931
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
121932
|
-
default:
|
|
121933
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
121934
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
121935
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
121936
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
121937
|
-
if (t[2]) _.ops.pop();
|
|
121938
|
-
_.trys.pop(); continue;
|
|
121939
|
-
}
|
|
121940
|
-
op = body.call(thisArg, _);
|
|
121941
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
121942
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
121943
|
-
}
|
|
121944
|
-
}
|
|
121945
|
-
|
|
121946
|
-
function __createBinding(o, m, k, k2) {
|
|
121947
|
-
if (k2 === undefined) k2 = k;
|
|
121948
|
-
o[k2] = m[k];
|
|
121949
|
-
}
|
|
121950
|
-
|
|
121951
|
-
function __exportStar(m, exports) {
|
|
121952
|
-
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
121953
|
-
}
|
|
121954
|
-
|
|
121955
|
-
function __values(o) {
|
|
121956
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
121957
|
-
if (m) return m.call(o);
|
|
121958
|
-
if (o && typeof o.length === "number") return {
|
|
121959
|
-
next: function () {
|
|
121960
|
-
if (o && i >= o.length) o = void 0;
|
|
121961
|
-
return { value: o && o[i++], done: !o };
|
|
121962
|
-
}
|
|
121963
|
-
};
|
|
121964
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
121965
|
-
}
|
|
121966
|
-
|
|
121967
|
-
function __read(o, n) {
|
|
121968
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
121969
|
-
if (!m) return o;
|
|
121970
|
-
var i = m.call(o), r, ar = [], e;
|
|
121971
|
-
try {
|
|
121972
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
121973
|
-
}
|
|
121974
|
-
catch (error) { e = { error: error }; }
|
|
121975
|
-
finally {
|
|
121976
|
-
try {
|
|
121977
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
121978
|
-
}
|
|
121979
|
-
finally { if (e) throw e.error; }
|
|
121980
|
-
}
|
|
121981
|
-
return ar;
|
|
121982
|
-
}
|
|
121983
|
-
|
|
121984
|
-
function __spread() {
|
|
121985
|
-
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
121986
|
-
ar = ar.concat(__read(arguments[i]));
|
|
121987
|
-
return ar;
|
|
121988
|
-
}
|
|
121989
|
-
|
|
121990
|
-
function __spreadArrays() {
|
|
121991
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
121992
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
121993
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
121994
|
-
r[k] = a[j];
|
|
121995
|
-
return r;
|
|
121996
|
-
};
|
|
121997
|
-
|
|
121998
|
-
function __await(v) {
|
|
121999
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
122000
|
-
}
|
|
122001
|
-
|
|
122002
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
122003
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
122004
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
122005
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
122006
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
122007
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
122008
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
122009
|
-
function fulfill(value) { resume("next", value); }
|
|
122010
|
-
function reject(value) { resume("throw", value); }
|
|
122011
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
122012
|
-
}
|
|
122013
|
-
|
|
122014
|
-
function __asyncDelegator(o) {
|
|
122015
|
-
var i, p;
|
|
122016
|
-
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
122017
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
122018
|
-
}
|
|
122019
|
-
|
|
122020
|
-
function __asyncValues(o) {
|
|
122021
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
122022
|
-
var m = o[Symbol.asyncIterator], i;
|
|
122023
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
122024
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
122025
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
122026
|
-
}
|
|
122027
|
-
|
|
122028
|
-
function __makeTemplateObject(cooked, raw) {
|
|
122029
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
122030
|
-
return cooked;
|
|
122031
|
-
};
|
|
122032
|
-
|
|
122033
|
-
function __importStar(mod) {
|
|
122034
|
-
if (mod && mod.__esModule) return mod;
|
|
122035
|
-
var result = {};
|
|
122036
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
122037
|
-
result.default = mod;
|
|
122038
|
-
return result;
|
|
122039
|
-
}
|
|
122040
|
-
|
|
122041
|
-
function __importDefault(mod) {
|
|
122042
|
-
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
122043
|
-
}
|
|
122044
|
-
|
|
122045
|
-
function __classPrivateFieldGet(receiver, privateMap) {
|
|
122046
|
-
if (!privateMap.has(receiver)) {
|
|
122047
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
122048
|
-
}
|
|
122049
|
-
return privateMap.get(receiver);
|
|
122050
|
-
}
|
|
122051
|
-
|
|
122052
|
-
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
122053
|
-
if (!privateMap.has(receiver)) {
|
|
122054
|
-
throw new TypeError("attempted to set private field on non-instance");
|
|
122055
|
-
}
|
|
122056
|
-
privateMap.set(receiver, value);
|
|
122057
|
-
return value;
|
|
122058
|
-
}
|
|
121841
|
+
/*! *****************************************************************************
|
|
121842
|
+
Copyright (c) Microsoft Corporation.
|
|
121843
|
+
|
|
121844
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
121845
|
+
purpose with or without fee is hereby granted.
|
|
121846
|
+
|
|
121847
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
121848
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
121849
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
121850
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
121851
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
121852
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
121853
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
121854
|
+
***************************************************************************** */
|
|
121855
|
+
/* global Reflect, Promise */
|
|
121856
|
+
|
|
121857
|
+
var extendStatics = function(d, b) {
|
|
121858
|
+
extendStatics = Object.setPrototypeOf ||
|
|
121859
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
121860
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
121861
|
+
return extendStatics(d, b);
|
|
121862
|
+
};
|
|
121863
|
+
|
|
121864
|
+
function __extends(d, b) {
|
|
121865
|
+
extendStatics(d, b);
|
|
121866
|
+
function __() { this.constructor = d; }
|
|
121867
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
121868
|
+
}
|
|
121869
|
+
|
|
121870
|
+
var __assign = function() {
|
|
121871
|
+
__assign = Object.assign || function __assign(t) {
|
|
121872
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
121873
|
+
s = arguments[i];
|
|
121874
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
121875
|
+
}
|
|
121876
|
+
return t;
|
|
121877
|
+
}
|
|
121878
|
+
return __assign.apply(this, arguments);
|
|
121879
|
+
}
|
|
121880
|
+
|
|
121881
|
+
function __rest(s, e) {
|
|
121882
|
+
var t = {};
|
|
121883
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
121884
|
+
t[p] = s[p];
|
|
121885
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
121886
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
121887
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
121888
|
+
t[p[i]] = s[p[i]];
|
|
121889
|
+
}
|
|
121890
|
+
return t;
|
|
121891
|
+
}
|
|
121892
|
+
|
|
121893
|
+
function __decorate(decorators, target, key, desc) {
|
|
121894
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
121895
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
121896
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
121897
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
121898
|
+
}
|
|
121899
|
+
|
|
121900
|
+
function __param(paramIndex, decorator) {
|
|
121901
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
121902
|
+
}
|
|
121903
|
+
|
|
121904
|
+
function __metadata(metadataKey, metadataValue) {
|
|
121905
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
121906
|
+
}
|
|
121907
|
+
|
|
121908
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
121909
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
121910
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
121911
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
121912
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
121913
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
121914
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
121915
|
+
});
|
|
121916
|
+
}
|
|
121917
|
+
|
|
121918
|
+
function __generator(thisArg, body) {
|
|
121919
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
121920
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
121921
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
121922
|
+
function step(op) {
|
|
121923
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
121924
|
+
while (_) try {
|
|
121925
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
121926
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
121927
|
+
switch (op[0]) {
|
|
121928
|
+
case 0: case 1: t = op; break;
|
|
121929
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
121930
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
121931
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
121932
|
+
default:
|
|
121933
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
121934
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
121935
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
121936
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
121937
|
+
if (t[2]) _.ops.pop();
|
|
121938
|
+
_.trys.pop(); continue;
|
|
121939
|
+
}
|
|
121940
|
+
op = body.call(thisArg, _);
|
|
121941
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
121942
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
121943
|
+
}
|
|
121944
|
+
}
|
|
121945
|
+
|
|
121946
|
+
function __createBinding(o, m, k, k2) {
|
|
121947
|
+
if (k2 === undefined) k2 = k;
|
|
121948
|
+
o[k2] = m[k];
|
|
121949
|
+
}
|
|
121950
|
+
|
|
121951
|
+
function __exportStar(m, exports) {
|
|
121952
|
+
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
121953
|
+
}
|
|
121954
|
+
|
|
121955
|
+
function __values(o) {
|
|
121956
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
121957
|
+
if (m) return m.call(o);
|
|
121958
|
+
if (o && typeof o.length === "number") return {
|
|
121959
|
+
next: function () {
|
|
121960
|
+
if (o && i >= o.length) o = void 0;
|
|
121961
|
+
return { value: o && o[i++], done: !o };
|
|
121962
|
+
}
|
|
121963
|
+
};
|
|
121964
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
121965
|
+
}
|
|
121966
|
+
|
|
121967
|
+
function __read(o, n) {
|
|
121968
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
121969
|
+
if (!m) return o;
|
|
121970
|
+
var i = m.call(o), r, ar = [], e;
|
|
121971
|
+
try {
|
|
121972
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
121973
|
+
}
|
|
121974
|
+
catch (error) { e = { error: error }; }
|
|
121975
|
+
finally {
|
|
121976
|
+
try {
|
|
121977
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
121978
|
+
}
|
|
121979
|
+
finally { if (e) throw e.error; }
|
|
121980
|
+
}
|
|
121981
|
+
return ar;
|
|
121982
|
+
}
|
|
121983
|
+
|
|
121984
|
+
function __spread() {
|
|
121985
|
+
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
121986
|
+
ar = ar.concat(__read(arguments[i]));
|
|
121987
|
+
return ar;
|
|
121988
|
+
}
|
|
121989
|
+
|
|
121990
|
+
function __spreadArrays() {
|
|
121991
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
121992
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
121993
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
121994
|
+
r[k] = a[j];
|
|
121995
|
+
return r;
|
|
121996
|
+
};
|
|
121997
|
+
|
|
121998
|
+
function __await(v) {
|
|
121999
|
+
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
122000
|
+
}
|
|
122001
|
+
|
|
122002
|
+
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
122003
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
122004
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
122005
|
+
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
122006
|
+
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
122007
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
122008
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
122009
|
+
function fulfill(value) { resume("next", value); }
|
|
122010
|
+
function reject(value) { resume("throw", value); }
|
|
122011
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
122012
|
+
}
|
|
122013
|
+
|
|
122014
|
+
function __asyncDelegator(o) {
|
|
122015
|
+
var i, p;
|
|
122016
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
122017
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
122018
|
+
}
|
|
122019
|
+
|
|
122020
|
+
function __asyncValues(o) {
|
|
122021
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
122022
|
+
var m = o[Symbol.asyncIterator], i;
|
|
122023
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
122024
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
122025
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
122026
|
+
}
|
|
122027
|
+
|
|
122028
|
+
function __makeTemplateObject(cooked, raw) {
|
|
122029
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
122030
|
+
return cooked;
|
|
122031
|
+
};
|
|
122032
|
+
|
|
122033
|
+
function __importStar(mod) {
|
|
122034
|
+
if (mod && mod.__esModule) return mod;
|
|
122035
|
+
var result = {};
|
|
122036
|
+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
122037
|
+
result.default = mod;
|
|
122038
|
+
return result;
|
|
122039
|
+
}
|
|
122040
|
+
|
|
122041
|
+
function __importDefault(mod) {
|
|
122042
|
+
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
122043
|
+
}
|
|
122044
|
+
|
|
122045
|
+
function __classPrivateFieldGet(receiver, privateMap) {
|
|
122046
|
+
if (!privateMap.has(receiver)) {
|
|
122047
|
+
throw new TypeError("attempted to get private field on non-instance");
|
|
122048
|
+
}
|
|
122049
|
+
return privateMap.get(receiver);
|
|
122050
|
+
}
|
|
122051
|
+
|
|
122052
|
+
function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
122053
|
+
if (!privateMap.has(receiver)) {
|
|
122054
|
+
throw new TypeError("attempted to set private field on non-instance");
|
|
122055
|
+
}
|
|
122056
|
+
privateMap.set(receiver, value);
|
|
122057
|
+
return value;
|
|
122058
|
+
}
|
|
122059
122059
|
|
|
122060
122060
|
|
|
122061
122061
|
/***/ }),
|
|
@@ -125269,13 +125269,6 @@ function install (Vue) {
|
|
|
125269
125269
|
}
|
|
125270
125270
|
});
|
|
125271
125271
|
|
|
125272
|
-
Object.defineProperty(Vue.prototype, '$router', {
|
|
125273
|
-
get: function get () { return this._routerRoot._router }
|
|
125274
|
-
});
|
|
125275
|
-
|
|
125276
|
-
Object.defineProperty(Vue.prototype, '$route', {
|
|
125277
|
-
get: function get () { return this._routerRoot._route }
|
|
125278
|
-
});
|
|
125279
125272
|
|
|
125280
125273
|
Vue.component('RouterView', View);
|
|
125281
125274
|
Vue.component('RouterLink', Link);
|
|
@@ -159948,1224 +159941,1224 @@ module.exports = Array.isArray || function isArray(argument) {
|
|
|
159948
159941
|
/***/ "e8bf":
|
|
159949
159942
|
/***/ (function(module, exports, __webpack_require__) {
|
|
159950
159943
|
|
|
159951
|
-
|
|
159952
|
-
/**
|
|
159953
|
-
@Name:layer v3.0.1 Web弹层组件
|
|
159954
|
-
@Author:贤心
|
|
159955
|
-
@Site:http://layer.layui.com
|
|
159956
|
-
@License:LGPL
|
|
159957
|
-
|
|
159958
|
-
*/
|
|
159959
|
-
__webpack_require__("5566");
|
|
159960
|
-
|
|
159961
|
-
"use strict";
|
|
159962
|
-
|
|
159963
|
-
var isLayui = window.layui && layui.define, $, win, ready = {
|
|
159964
|
-
getPath: function(){
|
|
159965
|
-
var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
|
|
159966
|
-
if(script.getAttribute('merge')) return;
|
|
159967
|
-
return jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
|
|
159968
|
-
}(),
|
|
159969
|
-
|
|
159970
|
-
config: {}, end: {}, minIndex: 0, minLeft: [],
|
|
159971
|
-
btn: ['确定', '取消'],
|
|
159972
|
-
|
|
159973
|
-
//五种原始层模式
|
|
159974
|
-
type: ['dialog', 'page', 'iframe', 'loading', 'tips']
|
|
159975
|
-
};
|
|
159976
|
-
|
|
159977
|
-
//默认内置方法。
|
|
159978
|
-
var layer = {
|
|
159979
|
-
v: '3.0.1',
|
|
159980
|
-
ie: function(){ //ie版本
|
|
159981
|
-
var agent = navigator.userAgent.toLowerCase();
|
|
159982
|
-
return (!!window.ActiveXObject || "ActiveXObject" in window) ? (
|
|
159983
|
-
(agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识
|
|
159984
|
-
) : false;
|
|
159985
|
-
}(),
|
|
159986
|
-
index: (window.layer && window.layer.v) ? 100000 : 0,
|
|
159987
|
-
path: ready.getPath,
|
|
159988
|
-
config: function(options, fn){
|
|
159989
|
-
options = options || {};
|
|
159990
|
-
layer.cache = ready.config = $.extend({}, ready.config, options);
|
|
159991
|
-
layer.path = ready.config.path || layer.path;
|
|
159992
|
-
typeof options.extend === 'string' && (options.extend = [options.extend]);
|
|
159993
|
-
|
|
159994
|
-
if(ready.config.path) layer.ready();
|
|
159995
|
-
|
|
159996
|
-
if(!options.extend) return this;
|
|
159997
|
-
|
|
159998
|
-
isLayui
|
|
159999
|
-
? layui.addcss('modules/layer/' + options.extend)
|
|
160000
|
-
: layer.link('skin/' + options.extend);
|
|
160001
|
-
|
|
160002
|
-
return this;
|
|
160003
|
-
},
|
|
160004
|
-
|
|
160005
|
-
//载入CSS配件
|
|
160006
|
-
link: function(href, fn, cssname){
|
|
160007
|
-
|
|
160008
|
-
//未设置路径,则不主动加载css
|
|
160009
|
-
if(!layer.path) return;
|
|
160010
|
-
|
|
160011
|
-
var head = $('head')[0], link = document.createElement('link');
|
|
160012
|
-
if(typeof fn === 'string') cssname = fn;
|
|
160013
|
-
var app = (cssname || href).replace(/\.|\//g, '');
|
|
160014
|
-
var id = 'layuicss-'+app, timeout = 0;
|
|
160015
|
-
|
|
160016
|
-
link.rel = 'stylesheet';
|
|
160017
|
-
link.href = layer.path + href;
|
|
160018
|
-
link.id = id;
|
|
160019
|
-
|
|
160020
|
-
if(!$('#'+ id)[0]){
|
|
160021
|
-
head.appendChild(link);
|
|
160022
|
-
}
|
|
160023
|
-
|
|
160024
|
-
if(typeof fn !== 'function') return;
|
|
160025
|
-
|
|
160026
|
-
//轮询css是否加载完毕
|
|
160027
|
-
(function poll() {
|
|
160028
|
-
if(++timeout > 8 * 1000 / 100){
|
|
160029
|
-
return window.console && console.error('layer.css: Invalid');
|
|
160030
|
-
};
|
|
160031
|
-
parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100);
|
|
160032
|
-
}());
|
|
160033
|
-
},
|
|
160034
|
-
|
|
160035
|
-
ready: function(callback){
|
|
160036
|
-
var cssname = 'skinlayercss', ver = '1110';
|
|
160037
|
-
isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname)
|
|
160038
|
-
: layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname);
|
|
160039
|
-
return this;
|
|
160040
|
-
},
|
|
160041
|
-
|
|
160042
|
-
//各种快捷引用
|
|
160043
|
-
alert: function(content, options, yes){
|
|
160044
|
-
var type = typeof options === 'function';
|
|
160045
|
-
if(type) yes = options;
|
|
160046
|
-
return layer.open($.extend({
|
|
160047
|
-
content: content,
|
|
160048
|
-
yes: yes
|
|
160049
|
-
}, type ? {} : options));
|
|
160050
|
-
},
|
|
160051
|
-
|
|
160052
|
-
confirm: function(content, options, yes, cancel){
|
|
160053
|
-
var type = typeof options === 'function';
|
|
160054
|
-
if(type){
|
|
160055
|
-
cancel = yes;
|
|
160056
|
-
yes = options;
|
|
160057
|
-
}
|
|
160058
|
-
return layer.open($.extend({
|
|
160059
|
-
content: content,
|
|
160060
|
-
btn: ready.btn,
|
|
160061
|
-
yes: yes,
|
|
160062
|
-
btn2: cancel
|
|
160063
|
-
}, type ? {} : options));
|
|
160064
|
-
},
|
|
160065
|
-
|
|
160066
|
-
msg: function(content, options, end){ //最常用提示层
|
|
160067
|
-
var type = typeof options === 'function', rskin = ready.config.skin;
|
|
160068
|
-
var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg';
|
|
160069
|
-
var anim = doms.anim.length - 1;
|
|
160070
|
-
if(type) end = options;
|
|
160071
|
-
return layer.open($.extend({
|
|
160072
|
-
content: content,
|
|
160073
|
-
time: 3000,
|
|
160074
|
-
shade: false,
|
|
160075
|
-
skin: skin,
|
|
160076
|
-
title: false,
|
|
160077
|
-
closeBtn: false,
|
|
160078
|
-
btn: false,
|
|
160079
|
-
resize: false,
|
|
160080
|
-
end: end
|
|
160081
|
-
}, (type && !ready.config.skin) ? {
|
|
160082
|
-
skin: skin + ' layui-layer-hui',
|
|
160083
|
-
anim: anim
|
|
160084
|
-
} : function(){
|
|
160085
|
-
options = options || {};
|
|
160086
|
-
if(options.icon === -1 || options.icon === undefined && !ready.config.skin){
|
|
160087
|
-
options.skin = skin + ' ' + (options.skin||'layui-layer-hui');
|
|
160088
|
-
}
|
|
160089
|
-
return options;
|
|
160090
|
-
}()));
|
|
160091
|
-
},
|
|
160092
|
-
|
|
160093
|
-
load: function(icon, options){
|
|
160094
|
-
return layer.open($.extend({
|
|
160095
|
-
type: 3,
|
|
160096
|
-
icon: icon || 0,
|
|
160097
|
-
resize: false,
|
|
160098
|
-
shade: 0.01
|
|
160099
|
-
}, options));
|
|
160100
|
-
},
|
|
160101
|
-
|
|
160102
|
-
tips: function(content, follow, options){
|
|
160103
|
-
return layer.open($.extend({
|
|
160104
|
-
type: 4,
|
|
160105
|
-
content: [content, follow],
|
|
160106
|
-
closeBtn: false,
|
|
160107
|
-
time: 3000,
|
|
160108
|
-
shade: false,
|
|
160109
|
-
resize: false,
|
|
160110
|
-
fixed: false,
|
|
160111
|
-
maxWidth: 210
|
|
160112
|
-
}, options));
|
|
160113
|
-
}
|
|
160114
|
-
};
|
|
160115
|
-
|
|
160116
|
-
var Class = function(setings){
|
|
160117
|
-
var that = this;
|
|
160118
|
-
that.index = ++layer.index;
|
|
160119
|
-
that.config = $.extend({}, that.config, ready.config, setings);
|
|
160120
|
-
document.body ? that.creat() : setTimeout(function(){
|
|
160121
|
-
that.creat();
|
|
160122
|
-
}, 50);
|
|
160123
|
-
};
|
|
160124
|
-
|
|
160125
|
-
Class.pt = Class.prototype;
|
|
160126
|
-
|
|
160127
|
-
//缓存常用字符
|
|
160128
|
-
var doms = ['layui-layer', '.layui-layer-title', '.layui-layer-main', '.layui-layer-dialog', 'layui-layer-iframe', 'layui-layer-content', 'layui-layer-btn', 'layui-layer-close'];
|
|
160129
|
-
doms.anim = ['layer-anim', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06'];
|
|
160130
|
-
|
|
160131
|
-
//默认配置
|
|
160132
|
-
Class.pt.config = {
|
|
160133
|
-
type: 0,
|
|
160134
|
-
shade: 0.3,
|
|
160135
|
-
fixed: true,
|
|
160136
|
-
move: doms[1],
|
|
160137
|
-
title: '信息',
|
|
160138
|
-
offset: 'auto',
|
|
160139
|
-
area: 'auto',
|
|
160140
|
-
closeBtn: 1,
|
|
160141
|
-
time: 0, //0表示不自动关闭
|
|
160142
|
-
zIndex: 19891014,
|
|
160143
|
-
maxWidth: 360,
|
|
160144
|
-
anim: 0,
|
|
160145
|
-
icon: -1,
|
|
160146
|
-
moveType: 1,
|
|
160147
|
-
resize: true,
|
|
160148
|
-
scrollbar: true, //是否允许浏览器滚动条
|
|
160149
|
-
tips: 2
|
|
160150
|
-
};
|
|
160151
|
-
|
|
160152
|
-
//容器
|
|
160153
|
-
Class.pt.vessel = function(conType, callback){
|
|
160154
|
-
var that = this, times = that.index, config = that.config;
|
|
160155
|
-
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
|
160156
|
-
var ismax = config.maxmin && (config.type === 1 || config.type === 2);
|
|
160157
|
-
var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">'
|
|
160158
|
-
+ (titype ? config.title[0] : config.title)
|
|
160159
|
-
+ '</div>' : '');
|
|
160160
|
-
|
|
160161
|
-
config.zIndex = zIndex;
|
|
160162
|
-
callback([
|
|
160163
|
-
//遮罩
|
|
160164
|
-
config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '',
|
|
160165
|
-
|
|
160166
|
-
//主体
|
|
160167
|
-
'<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">'
|
|
160168
|
-
+ (conType && config.type != 2 ? '' : titleHTML)
|
|
160169
|
-
+ '<div id="'+ (config.id||'') +'" class="layui-layer-content'+ ((config.type == 0 && config.icon !== -1) ? ' layui-layer-padding' :'') + (config.type == 3 ? ' layui-layer-loading'+config.icon : '') +'">'
|
|
160170
|
-
+ (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico'+ config.icon +'"></i>' : '')
|
|
160171
|
-
+ (config.type == 1 && conType ? '' : (config.content||''))
|
|
160172
|
-
+ '</div>'
|
|
160173
|
-
+ '<span class="layui-layer-setwin">'+ function(){
|
|
160174
|
-
var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : '';
|
|
160175
|
-
config.closeBtn && (closebtn += '<a class="layui-layer-ico '+ doms[7] +' '+ doms[7] + (config.title ? config.closeBtn : (config.type == 4 ? '1' : '2')) +'" href="javascript:;"></a>');
|
|
160176
|
-
return closebtn;
|
|
160177
|
-
}() + '</span>'
|
|
160178
|
-
+ (config.btn ? function(){
|
|
160179
|
-
var button = '';
|
|
160180
|
-
typeof config.btn === 'string' && (config.btn = [config.btn]);
|
|
160181
|
-
for(var i = 0, len = config.btn.length; i < len; i++){
|
|
160182
|
-
button += '<a class="'+ doms[6] +''+ i +'">'+ config.btn[i] +'</a>'
|
|
160183
|
-
}
|
|
160184
|
-
return '<div class="'+ doms[6] +' layui-layer-btn-'+ (config.btnAlign||'') +'">'+ button +'</div>'
|
|
160185
|
-
}() : '')
|
|
160186
|
-
+ (config.resize ? '<span class="layui-layer-resize"></span>' : '')
|
|
160187
|
-
+ '</div>'
|
|
160188
|
-
], titleHTML, $('<div class="layui-layer-move"></div>'));
|
|
160189
|
-
return that;
|
|
160190
|
-
};
|
|
160191
|
-
|
|
160192
|
-
//创建骨架
|
|
160193
|
-
Class.pt.creat = function(){
|
|
160194
|
-
var that = this
|
|
160195
|
-
,config = that.config
|
|
160196
|
-
,times = that.index, nodeIndex
|
|
160197
|
-
,content = config.content
|
|
160198
|
-
,conType = typeof content === 'object'
|
|
160199
|
-
,body = $('body');
|
|
160200
|
-
|
|
160201
|
-
if($('#'+config.id)[0]) return;
|
|
160202
|
-
|
|
160203
|
-
if(typeof config.area === 'string'){
|
|
160204
|
-
config.area = config.area === 'auto' ? ['', ''] : [config.area, ''];
|
|
160205
|
-
}
|
|
160206
|
-
|
|
160207
|
-
//anim兼容旧版shift
|
|
160208
|
-
if(config.shift){
|
|
160209
|
-
config.anim = config.shift;
|
|
160210
|
-
}
|
|
160211
|
-
|
|
160212
|
-
if(layer.ie == 6){
|
|
160213
|
-
config.fixed = false;
|
|
160214
|
-
}
|
|
160215
|
-
|
|
160216
|
-
switch(config.type){
|
|
160217
|
-
case 0:
|
|
160218
|
-
config.btn = ('btn' in config) ? config.btn : ready.btn[0];
|
|
160219
|
-
layer.closeAll('dialog');
|
|
160220
|
-
break;
|
|
160221
|
-
case 2:
|
|
160222
|
-
var content = config.content = conType ? config.content : [config.content||'http://layer.layui.com', 'auto'];
|
|
160223
|
-
config.content = '<iframe scrolling="'+ (config.content[1]||'auto') +'" allowtransparency="true" id="'+ doms[4] +''+ times +'" name="'+ doms[4] +''+ times +'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + config.content[0] + '"></iframe>';
|
|
160224
|
-
break;
|
|
160225
|
-
case 3:
|
|
160226
|
-
delete config.title;
|
|
160227
|
-
delete config.closeBtn;
|
|
160228
|
-
config.icon === -1 && (config.icon === 0);
|
|
160229
|
-
layer.closeAll('loading');
|
|
160230
|
-
break;
|
|
160231
|
-
case 4:
|
|
160232
|
-
conType || (config.content = [config.content, 'body']);
|
|
160233
|
-
config.follow = config.content[1];
|
|
160234
|
-
config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>';
|
|
160235
|
-
delete config.title;
|
|
160236
|
-
config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true];
|
|
160237
|
-
config.tipsMore || layer.closeAll('tips');
|
|
160238
|
-
break;
|
|
160239
|
-
}
|
|
160240
|
-
|
|
160241
|
-
//建立容器
|
|
160242
|
-
that.vessel(conType, function(html, titleHTML, moveElem){
|
|
160243
|
-
body.append(html[0]);
|
|
160244
|
-
conType ? function(){
|
|
160245
|
-
(config.type == 2 || config.type == 4) ? function(){
|
|
160246
|
-
$('body').append(html[1]);
|
|
160247
|
-
}() : function(){
|
|
160248
|
-
if(!content.parents('.'+doms[0])[0]){
|
|
160249
|
-
content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]);
|
|
160250
|
-
$('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML);
|
|
160251
|
-
}
|
|
160252
|
-
}();
|
|
160253
|
-
}() : body.append(html[1]);
|
|
160254
|
-
$('.layui-layer-move')[0] || body.append(ready.moveElem = moveElem);
|
|
160255
|
-
that.layero = $('#'+ doms[0] + times);
|
|
160256
|
-
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
|
160257
|
-
}).auto(times);
|
|
160258
|
-
|
|
160259
|
-
config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]);
|
|
160260
|
-
|
|
160261
|
-
//坐标自适应浏览器窗口尺寸
|
|
160262
|
-
config.type == 4 ? that.tips() : that.offset();
|
|
160263
|
-
if(config.fixed){
|
|
160264
|
-
win.on('resize', function(){
|
|
160265
|
-
that.offset();
|
|
160266
|
-
(/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times);
|
|
160267
|
-
config.type == 4 && that.tips();
|
|
160268
|
-
});
|
|
160269
|
-
}
|
|
160270
|
-
|
|
160271
|
-
config.time <= 0 || setTimeout(function(){
|
|
160272
|
-
layer.close(that.index)
|
|
160273
|
-
}, config.time);
|
|
160274
|
-
that.move().callback();
|
|
160275
|
-
|
|
160276
|
-
//为兼容jQuery3.0的css动画影响元素尺寸计算
|
|
160277
|
-
if(doms.anim[config.anim]){
|
|
160278
|
-
that.layero.addClass(doms.anim[config.anim]).data('anim', true);
|
|
160279
|
-
};
|
|
160280
|
-
};
|
|
160281
|
-
|
|
160282
|
-
//自适应
|
|
160283
|
-
Class.pt.auto = function(index){
|
|
160284
|
-
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
|
160285
|
-
if(config.area[0] === '' && config.maxWidth > 0){
|
|
160286
|
-
//为了修复IE7下一个让人难以理解的bug
|
|
160287
|
-
if(layer.ie && layer.ie < 8 && config.btn){
|
|
160288
|
-
layero.width(layero.innerWidth());
|
|
160289
|
-
}
|
|
160290
|
-
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
|
160291
|
-
}
|
|
160292
|
-
var area = [layero.innerWidth(), layero.innerHeight()];
|
|
160293
|
-
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
|
160294
|
-
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
|
160295
|
-
function setHeight(elem){
|
|
160296
|
-
elem = layero.find(elem);
|
|
160297
|
-
elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0));
|
|
160298
|
-
}
|
|
160299
|
-
switch(config.type){
|
|
160300
|
-
case 2:
|
|
160301
|
-
setHeight('iframe');
|
|
160302
|
-
break;
|
|
160303
|
-
default:
|
|
160304
|
-
if(config.area[1] === ''){
|
|
160305
|
-
if(config.fixed && area[1] >= win.height()){
|
|
160306
|
-
area[1] = win.height();
|
|
160307
|
-
setHeight('.'+doms[5]);
|
|
160308
|
-
}
|
|
160309
|
-
} else {
|
|
160310
|
-
setHeight('.'+doms[5]);
|
|
160311
|
-
}
|
|
160312
|
-
break;
|
|
160313
|
-
}
|
|
160314
|
-
return that;
|
|
160315
|
-
};
|
|
160316
|
-
|
|
160317
|
-
//计算坐标
|
|
160318
|
-
Class.pt.offset = function(){
|
|
160319
|
-
var that = this, config = that.config, layero = that.layero;
|
|
160320
|
-
var area = [layero.outerWidth(), layero.outerHeight()];
|
|
160321
|
-
var type = typeof config.offset === 'object';
|
|
160322
|
-
that.offsetTop = (win.height() - area[1])/2;
|
|
160323
|
-
that.offsetLeft = (win.width() - area[0])/2;
|
|
160324
|
-
|
|
160325
|
-
if(type){
|
|
160326
|
-
that.offsetTop = config.offset[0];
|
|
160327
|
-
that.offsetLeft = config.offset[1]||that.offsetLeft;
|
|
160328
|
-
} else if(config.offset !== 'auto'){
|
|
160329
|
-
|
|
160330
|
-
if(config.offset === 't'){ //上
|
|
160331
|
-
that.offsetTop = 0;
|
|
160332
|
-
} else if(config.offset === 'r'){ //右
|
|
160333
|
-
that.offsetLeft = win.width() - area[0];
|
|
160334
|
-
} else if(config.offset === 'b'){ //下
|
|
160335
|
-
that.offsetTop = win.height() - area[1];
|
|
160336
|
-
} else if(config.offset === 'l'){ //左
|
|
160337
|
-
that.offsetLeft = 0;
|
|
160338
|
-
} else if(config.offset === 'lt'){ //左上角
|
|
160339
|
-
that.offsetTop = 0;
|
|
160340
|
-
that.offsetLeft = 0;
|
|
160341
|
-
} else if(config.offset === 'lb'){ //左下角
|
|
160342
|
-
that.offsetTop = win.height() - area[1];
|
|
160343
|
-
that.offsetLeft = 0;
|
|
160344
|
-
} else if(config.offset === 'rt'){ //右上角
|
|
160345
|
-
that.offsetTop = 0;
|
|
160346
|
-
that.offsetLeft = win.width() - area[0];
|
|
160347
|
-
} else if(config.offset === 'rb'){ //右下角
|
|
160348
|
-
that.offsetTop = win.height() - area[1];
|
|
160349
|
-
that.offsetLeft = win.width() - area[0];
|
|
160350
|
-
} else {
|
|
160351
|
-
that.offsetTop = config.offset;
|
|
160352
|
-
}
|
|
160353
|
-
|
|
160354
|
-
}
|
|
160355
|
-
|
|
160356
|
-
if(!config.fixed){
|
|
160357
|
-
that.offsetTop = /%$/.test(that.offsetTop) ?
|
|
160358
|
-
win.height()*parseFloat(that.offsetTop)/100
|
|
160359
|
-
: parseFloat(that.offsetTop);
|
|
160360
|
-
that.offsetLeft = /%$/.test(that.offsetLeft) ?
|
|
160361
|
-
win.width()*parseFloat(that.offsetLeft)/100
|
|
160362
|
-
: parseFloat(that.offsetLeft);
|
|
160363
|
-
that.offsetTop += win.scrollTop();
|
|
160364
|
-
that.offsetLeft += win.scrollLeft();
|
|
160365
|
-
}
|
|
160366
|
-
|
|
160367
|
-
if(layero.attr('minLeft')){
|
|
160368
|
-
that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0);
|
|
160369
|
-
that.offsetLeft = layero.css('left');
|
|
160370
|
-
}
|
|
160371
|
-
|
|
160372
|
-
layero.css({top: that.offsetTop, left: that.offsetLeft});
|
|
160373
|
-
};
|
|
160374
|
-
|
|
160375
|
-
//Tips
|
|
160376
|
-
Class.pt.tips = function(){
|
|
160377
|
-
var that = this, config = that.config, layero = that.layero;
|
|
160378
|
-
var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow);
|
|
160379
|
-
if(!follow[0]) follow = $('body');
|
|
160380
|
-
var goal = {
|
|
160381
|
-
width: follow.outerWidth(),
|
|
160382
|
-
height: follow.outerHeight(),
|
|
160383
|
-
top: follow.offset().top,
|
|
160384
|
-
left: follow.offset().left
|
|
160385
|
-
}, tipsG = layero.find('.layui-layer-TipsG');
|
|
160386
|
-
|
|
160387
|
-
var guide = config.tips[0];
|
|
160388
|
-
config.tips[1] || tipsG.remove();
|
|
160389
|
-
|
|
160390
|
-
goal.autoLeft = function(){
|
|
160391
|
-
if(goal.left + layArea[0] - win.width() > 0){
|
|
160392
|
-
goal.tipLeft = goal.left + goal.width - layArea[0];
|
|
160393
|
-
tipsG.css({right: 12, left: 'auto'});
|
|
160394
|
-
} else {
|
|
160395
|
-
goal.tipLeft = goal.left;
|
|
160396
|
-
};
|
|
160397
|
-
};
|
|
160398
|
-
|
|
160399
|
-
//辨别tips的方位
|
|
160400
|
-
goal.where = [function(){ //上
|
|
160401
|
-
goal.autoLeft();
|
|
160402
|
-
goal.tipTop = goal.top - layArea[1] - 10;
|
|
160403
|
-
tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]);
|
|
160404
|
-
}, function(){ //右
|
|
160405
|
-
goal.tipLeft = goal.left + goal.width + 10;
|
|
160406
|
-
goal.tipTop = goal.top;
|
|
160407
|
-
tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]);
|
|
160408
|
-
}, function(){ //下
|
|
160409
|
-
goal.autoLeft();
|
|
160410
|
-
goal.tipTop = goal.top + goal.height + 10;
|
|
160411
|
-
tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]);
|
|
160412
|
-
}, function(){ //左
|
|
160413
|
-
goal.tipLeft = goal.left - layArea[0] - 10;
|
|
160414
|
-
goal.tipTop = goal.top;
|
|
160415
|
-
tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]);
|
|
160416
|
-
}];
|
|
160417
|
-
goal.where[guide-1]();
|
|
160418
|
-
|
|
160419
|
-
/* 8*2为小三角形占据的空间 */
|
|
160420
|
-
if(guide === 1){
|
|
160421
|
-
goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2]();
|
|
160422
|
-
} else if(guide === 2){
|
|
160423
|
-
win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]()
|
|
160424
|
-
} else if(guide === 3){
|
|
160425
|
-
(goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0]();
|
|
160426
|
-
} else if(guide === 4){
|
|
160427
|
-
layArea[0] + 8*2 - goal.left > 0 && goal.where[1]()
|
|
160428
|
-
}
|
|
160429
|
-
|
|
160430
|
-
layero.find('.'+doms[5]).css({
|
|
160431
|
-
'background-color': config.tips[1],
|
|
160432
|
-
'padding-right': (config.closeBtn ? '30px' : '')
|
|
160433
|
-
});
|
|
160434
|
-
layero.css({
|
|
160435
|
-
left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0),
|
|
160436
|
-
top: goal.tipTop - (config.fixed ? win.scrollTop() : 0)
|
|
160437
|
-
});
|
|
160438
|
-
}
|
|
160439
|
-
|
|
160440
|
-
//拖拽层
|
|
160441
|
-
Class.pt.move = function(){
|
|
160442
|
-
var that = this
|
|
160443
|
-
,config = that.config
|
|
160444
|
-
,_DOC = $(document)
|
|
160445
|
-
,layero = that.layero
|
|
160446
|
-
,moveElem = layero.find(config.move)
|
|
160447
|
-
,resizeElem = layero.find('.layui-layer-resize')
|
|
160448
|
-
,dict = {};
|
|
160449
|
-
|
|
160450
|
-
if(config.move){
|
|
160451
|
-
moveElem.css('cursor', 'move');
|
|
160452
|
-
}
|
|
160453
|
-
|
|
160454
|
-
moveElem.on('mousedown', function(e){
|
|
160455
|
-
e.preventDefault();
|
|
160456
|
-
if(config.move){
|
|
160457
|
-
dict.moveStart = true;
|
|
160458
|
-
dict.offset = [
|
|
160459
|
-
e.clientX - parseFloat(layero.css('left'))
|
|
160460
|
-
,e.clientY - parseFloat(layero.css('top'))
|
|
160461
|
-
];
|
|
160462
|
-
ready.moveElem.css('cursor', 'move').show();
|
|
160463
|
-
}
|
|
160464
|
-
});
|
|
160465
|
-
|
|
160466
|
-
resizeElem.on('mousedown', function(e){
|
|
160467
|
-
e.preventDefault();
|
|
160468
|
-
dict.resizeStart = true;
|
|
160469
|
-
dict.offset = [e.clientX, e.clientY];
|
|
160470
|
-
dict.area = [
|
|
160471
|
-
layero.outerWidth()
|
|
160472
|
-
,layero.outerHeight()
|
|
160473
|
-
];
|
|
160474
|
-
ready.moveElem.css('cursor', 'se-resize').show();
|
|
160475
|
-
});
|
|
160476
|
-
|
|
160477
|
-
_DOC.on('mousemove', function(e){
|
|
160478
|
-
|
|
160479
|
-
//拖拽移动
|
|
160480
|
-
if(dict.moveStart){
|
|
160481
|
-
var X = e.clientX - dict.offset[0]
|
|
160482
|
-
,Y = e.clientY - dict.offset[1]
|
|
160483
|
-
,fixed = layero.css('position') === 'fixed';
|
|
160484
|
-
|
|
160485
|
-
e.preventDefault();
|
|
160486
|
-
|
|
160487
|
-
dict.stX = fixed ? 0 : win.scrollLeft();
|
|
160488
|
-
dict.stY = fixed ? 0 : win.scrollTop();
|
|
160489
|
-
|
|
160490
|
-
//控制元素不被拖出窗口外
|
|
160491
|
-
if(!config.moveOut){
|
|
160492
|
-
var setRig = win.width() - layero.outerWidth() + dict.stX
|
|
160493
|
-
,setBot = win.height() - layero.outerHeight() + dict.stY;
|
|
160494
|
-
X < dict.stX && (X = dict.stX);
|
|
160495
|
-
X > setRig && (X = setRig);
|
|
160496
|
-
Y < dict.stY && (Y = dict.stY);
|
|
160497
|
-
Y > setBot && (Y = setBot);
|
|
160498
|
-
}
|
|
160499
|
-
|
|
160500
|
-
layero.css({
|
|
160501
|
-
left: X
|
|
160502
|
-
,top: Y
|
|
160503
|
-
});
|
|
160504
|
-
}
|
|
160505
|
-
|
|
160506
|
-
//Resize
|
|
160507
|
-
if(config.resize && dict.resizeStart){
|
|
160508
|
-
var X = e.clientX - dict.offset[0]
|
|
160509
|
-
,Y = e.clientY - dict.offset[1];
|
|
160510
|
-
|
|
160511
|
-
e.preventDefault();
|
|
160512
|
-
|
|
160513
|
-
layer.style(that.index, {
|
|
160514
|
-
width: dict.area[0] + X
|
|
160515
|
-
,height: dict.area[1] + Y
|
|
160516
|
-
})
|
|
160517
|
-
dict.isResize = true;
|
|
160518
|
-
}
|
|
160519
|
-
}).on('mouseup', function(e){
|
|
160520
|
-
if(dict.moveStart){
|
|
160521
|
-
delete dict.moveStart;
|
|
160522
|
-
ready.moveElem.hide();
|
|
160523
|
-
config.moveEnd && config.moveEnd();
|
|
160524
|
-
}
|
|
160525
|
-
if(dict.resizeStart){
|
|
160526
|
-
delete dict.resizeStart;
|
|
160527
|
-
ready.moveElem.hide();
|
|
160528
|
-
}
|
|
160529
|
-
});
|
|
160530
|
-
|
|
160531
|
-
return that;
|
|
160532
|
-
};
|
|
160533
|
-
|
|
160534
|
-
Class.pt.callback = function(){
|
|
160535
|
-
var that = this, layero = that.layero, config = that.config;
|
|
160536
|
-
that.openLayer();
|
|
160537
|
-
if(config.success){
|
|
160538
|
-
if(config.type == 2){
|
|
160539
|
-
layero.find('iframe').on('load', function(){
|
|
160540
|
-
config.success(layero, that.index);
|
|
160541
|
-
});
|
|
160542
|
-
} else {
|
|
160543
|
-
config.success(layero, that.index);
|
|
160544
|
-
}
|
|
160545
|
-
}
|
|
160546
|
-
layer.ie == 6 && that.IE6(layero);
|
|
160547
|
-
|
|
160548
|
-
//按钮
|
|
160549
|
-
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
|
160550
|
-
var index = $(this).index();
|
|
160551
|
-
if(index === 0){
|
|
160552
|
-
if(config.yes){
|
|
160553
|
-
config.yes(that.index, layero)
|
|
160554
|
-
} else if(config['btn1']){
|
|
160555
|
-
config['btn1'](that.index, layero)
|
|
160556
|
-
} else {
|
|
160557
|
-
layer.close(that.index);
|
|
160558
|
-
}
|
|
160559
|
-
} else {
|
|
160560
|
-
var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero);
|
|
160561
|
-
close === false || layer.close(that.index);
|
|
160562
|
-
}
|
|
160563
|
-
});
|
|
160564
|
-
|
|
160565
|
-
//取消
|
|
160566
|
-
function cancel(){
|
|
160567
|
-
var close = config.cancel && config.cancel(that.index, layero);
|
|
160568
|
-
close === false || layer.close(that.index);
|
|
160569
|
-
}
|
|
160570
|
-
|
|
160571
|
-
//右上角关闭回调
|
|
160572
|
-
layero.find('.'+ doms[7]).on('click', cancel);
|
|
160573
|
-
|
|
160574
|
-
//点遮罩关闭
|
|
160575
|
-
if(config.shadeClose){
|
|
160576
|
-
$('#layui-layer-shade'+ that.index).on('click', function(){
|
|
160577
|
-
layer.close(that.index);
|
|
160578
|
-
});
|
|
160579
|
-
}
|
|
160580
|
-
|
|
160581
|
-
//最小化
|
|
160582
|
-
layero.find('.layui-layer-min').on('click', function(){
|
|
160583
|
-
var min = config.min && config.min(layero);
|
|
160584
|
-
min === false || layer.min(that.index, config);
|
|
160585
|
-
});
|
|
160586
|
-
|
|
160587
|
-
//全屏/还原
|
|
160588
|
-
layero.find('.layui-layer-max').on('click', function(){
|
|
160589
|
-
if($(this).hasClass('layui-layer-maxmin')){
|
|
160590
|
-
layer.restore(that.index);
|
|
160591
|
-
config.restore && config.restore(layero);
|
|
160592
|
-
} else {
|
|
160593
|
-
layer.full(that.index, config);
|
|
160594
|
-
setTimeout(function(){
|
|
160595
|
-
config.full && config.full(layero);
|
|
160596
|
-
}, 100);
|
|
160597
|
-
}
|
|
160598
|
-
});
|
|
160599
|
-
|
|
160600
|
-
config.end && (ready.end[that.index] = config.end);
|
|
160601
|
-
};
|
|
160602
|
-
|
|
160603
|
-
//for ie6 恢复select
|
|
160604
|
-
ready.reselect = function(){
|
|
160605
|
-
$.each($('select'), function(index , value){
|
|
160606
|
-
var sthis = $(this);
|
|
160607
|
-
if(!sthis.parents('.'+doms[0])[0]){
|
|
160608
|
-
(sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show();
|
|
160609
|
-
}
|
|
160610
|
-
sthis = null;
|
|
160611
|
-
});
|
|
160612
|
-
};
|
|
160613
|
-
|
|
160614
|
-
Class.pt.IE6 = function(layero){
|
|
160615
|
-
//隐藏select
|
|
160616
|
-
$('select').each(function(index , value){
|
|
160617
|
-
var sthis = $(this);
|
|
160618
|
-
if(!sthis.parents('.'+doms[0])[0]){
|
|
160619
|
-
sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide();
|
|
160620
|
-
}
|
|
160621
|
-
sthis = null;
|
|
160622
|
-
});
|
|
160623
|
-
};
|
|
160624
|
-
|
|
160625
|
-
//需依赖原型的对外方法
|
|
160626
|
-
Class.pt.openLayer = function(){
|
|
160627
|
-
var that = this;
|
|
160628
|
-
|
|
160629
|
-
//置顶当前窗口
|
|
160630
|
-
layer.zIndex = that.config.zIndex;
|
|
160631
|
-
layer.setTop = function(layero){
|
|
160632
|
-
var setZindex = function(){
|
|
160633
|
-
layer.zIndex++;
|
|
160634
|
-
layero.css('z-index', layer.zIndex + 1);
|
|
160635
|
-
};
|
|
160636
|
-
layer.zIndex = parseInt(layero[0].style.zIndex);
|
|
160637
|
-
layero.on('mousedown', setZindex);
|
|
160638
|
-
return layer.zIndex;
|
|
160639
|
-
};
|
|
160640
|
-
};
|
|
160641
|
-
|
|
160642
|
-
ready.record = function(layero){
|
|
160643
|
-
var area = [
|
|
160644
|
-
layero.width(),
|
|
160645
|
-
layero.height(),
|
|
160646
|
-
layero.position().top,
|
|
160647
|
-
layero.position().left + parseFloat(layero.css('margin-left'))
|
|
160648
|
-
];
|
|
160649
|
-
layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
|
|
160650
|
-
layero.attr({area: area});
|
|
160651
|
-
};
|
|
160652
|
-
|
|
160653
|
-
ready.rescollbar = function(index){
|
|
160654
|
-
if(doms.html.attr('layer-full') == index){
|
|
160655
|
-
if(doms.html[0].style.removeProperty){
|
|
160656
|
-
doms.html[0].style.removeProperty('overflow');
|
|
160657
|
-
} else {
|
|
160658
|
-
doms.html[0].style.removeAttribute('overflow');
|
|
160659
|
-
}
|
|
160660
|
-
doms.html.removeAttr('layer-full');
|
|
160661
|
-
}
|
|
160662
|
-
};
|
|
160663
|
-
|
|
160664
|
-
/** 内置成员 */
|
|
160665
|
-
|
|
160666
|
-
window.layer = layer;
|
|
160667
|
-
|
|
160668
|
-
//获取子iframe的DOM
|
|
160669
|
-
layer.getChildFrame = function(selector, index){
|
|
160670
|
-
index = index || $('.'+doms[4]).attr('times');
|
|
160671
|
-
return $('#'+ doms[0] + index).find('iframe').contents().find(selector);
|
|
160672
|
-
};
|
|
160673
|
-
|
|
160674
|
-
//得到当前iframe层的索引,子iframe时使用
|
|
160675
|
-
layer.getFrameIndex = function(name){
|
|
160676
|
-
return $('#'+ name).parents('.'+doms[4]).attr('times');
|
|
160677
|
-
};
|
|
160678
|
-
|
|
160679
|
-
//iframe层自适应宽高
|
|
160680
|
-
layer.iframeAuto = function(index){
|
|
160681
|
-
if(!index) return;
|
|
160682
|
-
var heg = layer.getChildFrame('html', index).outerHeight();
|
|
160683
|
-
var layero = $('#'+ doms[0] + index);
|
|
160684
|
-
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
|
160685
|
-
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
|
160686
|
-
layero.css({height: heg + titHeight + btnHeight});
|
|
160687
|
-
layero.find('iframe').css({height: heg});
|
|
160688
|
-
};
|
|
160689
|
-
|
|
160690
|
-
//重置iframe url
|
|
160691
|
-
layer.iframeSrc = function(index, url){
|
|
160692
|
-
$('#'+ doms[0] + index).find('iframe').attr('src', url);
|
|
160693
|
-
};
|
|
160694
|
-
|
|
160695
|
-
//设定层的样式
|
|
160696
|
-
layer.style = function(index, options, limit){
|
|
160697
|
-
var layero = $('#'+ doms[0] + index)
|
|
160698
|
-
,contElem = layero.find('.layui-layer-content')
|
|
160699
|
-
,type = layero.attr('type')
|
|
160700
|
-
,titHeight = layero.find(doms[1]).outerHeight() || 0
|
|
160701
|
-
,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0
|
|
160702
|
-
,minLeft = layero.attr('minLeft');
|
|
160703
|
-
|
|
160704
|
-
if(type === ready.type[3] || type === ready.type[4]){
|
|
160705
|
-
return;
|
|
160706
|
-
}
|
|
160707
|
-
|
|
160708
|
-
if(!limit){
|
|
160709
|
-
if(parseFloat(options.width) <= 260){
|
|
160710
|
-
options.width = 260;
|
|
160711
|
-
};
|
|
160712
|
-
|
|
160713
|
-
if(parseFloat(options.height) - titHeight - btnHeight <= 64){
|
|
160714
|
-
options.height = 64 + titHeight + btnHeight;
|
|
160715
|
-
};
|
|
160716
|
-
}
|
|
160717
|
-
|
|
160718
|
-
layero.css(options);
|
|
160719
|
-
btnHeight = layero.find('.'+doms[6]).outerHeight();
|
|
160720
|
-
|
|
160721
|
-
if(type === ready.type[2]){
|
|
160722
|
-
layero.find('iframe').css({
|
|
160723
|
-
height: parseFloat(options.height) - titHeight - btnHeight
|
|
160724
|
-
});
|
|
160725
|
-
} else {
|
|
160726
|
-
contElem.css({
|
|
160727
|
-
height: parseFloat(options.height) - titHeight - btnHeight
|
|
160728
|
-
- parseFloat(contElem.css('padding-top'))
|
|
160729
|
-
- parseFloat(contElem.css('padding-bottom'))
|
|
160730
|
-
})
|
|
160731
|
-
}
|
|
160732
|
-
};
|
|
160733
|
-
|
|
160734
|
-
//最小化
|
|
160735
|
-
layer.min = function(index, options){
|
|
160736
|
-
var layero = $('#'+ doms[0] + index)
|
|
160737
|
-
,titHeight = layero.find(doms[1]).outerHeight() || 0
|
|
160738
|
-
,left = layero.attr('minLeft') || (181*ready.minIndex)+'px'
|
|
160739
|
-
,position = layero.css('position');
|
|
160740
|
-
|
|
160741
|
-
ready.record(layero);
|
|
160742
|
-
|
|
160743
|
-
if(ready.minLeft[0]){
|
|
160744
|
-
left = ready.minLeft[0];
|
|
160745
|
-
ready.minLeft.shift();
|
|
160746
|
-
}
|
|
160747
|
-
|
|
160748
|
-
layero.attr('position', position);
|
|
160749
|
-
|
|
160750
|
-
layer.style(index, {
|
|
160751
|
-
width: 180
|
|
160752
|
-
,height: titHeight
|
|
160753
|
-
,left: left
|
|
160754
|
-
,top: win.height() - titHeight
|
|
160755
|
-
,position: 'fixed'
|
|
160756
|
-
,overflow: 'hidden'
|
|
160757
|
-
}, true);
|
|
160758
|
-
|
|
160759
|
-
layero.find('.layui-layer-min').hide();
|
|
160760
|
-
layero.attr('type') === 'page' && layero.find(doms[4]).hide();
|
|
160761
|
-
ready.rescollbar(index);
|
|
160762
|
-
|
|
160763
|
-
if(!layero.attr('minLeft')){
|
|
160764
|
-
ready.minIndex++;
|
|
160765
|
-
}
|
|
160766
|
-
layero.attr('minLeft', left);
|
|
160767
|
-
};
|
|
160768
|
-
|
|
160769
|
-
//还原
|
|
160770
|
-
layer.restore = function(index){
|
|
160771
|
-
var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(',');
|
|
160772
|
-
var type = layero.attr('type');
|
|
160773
|
-
layer.style(index, {
|
|
160774
|
-
width: parseFloat(area[0]),
|
|
160775
|
-
height: parseFloat(area[1]),
|
|
160776
|
-
top: parseFloat(area[2]),
|
|
160777
|
-
left: parseFloat(area[3]),
|
|
160778
|
-
position: layero.attr('position'),
|
|
160779
|
-
overflow: 'visible'
|
|
160780
|
-
}, true);
|
|
160781
|
-
layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
|
|
160782
|
-
layero.find('.layui-layer-min').show();
|
|
160783
|
-
layero.attr('type') === 'page' && layero.find(doms[4]).show();
|
|
160784
|
-
ready.rescollbar(index);
|
|
160785
|
-
};
|
|
160786
|
-
|
|
160787
|
-
//全屏
|
|
160788
|
-
layer.full = function(index){
|
|
160789
|
-
var layero = $('#'+ doms[0] + index), timer;
|
|
160790
|
-
ready.record(layero);
|
|
160791
|
-
if(!doms.html.attr('layer-full')){
|
|
160792
|
-
doms.html.css('overflow','hidden').attr('layer-full', index);
|
|
160793
|
-
}
|
|
160794
|
-
clearTimeout(timer);
|
|
160795
|
-
timer = setTimeout(function(){
|
|
160796
|
-
var isfix = layero.css('position') === 'fixed';
|
|
160797
|
-
layer.style(index, {
|
|
160798
|
-
top: isfix ? 0 : win.scrollTop(),
|
|
160799
|
-
left: isfix ? 0 : win.scrollLeft(),
|
|
160800
|
-
width: win.width(),
|
|
160801
|
-
height: win.height()
|
|
160802
|
-
}, true);
|
|
160803
|
-
layero.find('.layui-layer-min').hide();
|
|
160804
|
-
}, 100);
|
|
160805
|
-
};
|
|
160806
|
-
|
|
160807
|
-
//改变title
|
|
160808
|
-
layer.title = function(name, index){
|
|
160809
|
-
var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]);
|
|
160810
|
-
title.html(name);
|
|
160811
|
-
};
|
|
160812
|
-
|
|
160813
|
-
//关闭layer总方法
|
|
160814
|
-
layer.close = function(index){
|
|
160815
|
-
var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close';
|
|
160816
|
-
if(!layero[0]) return;
|
|
160817
|
-
var WRAP = 'layui-layer-wrap', remove = function(){
|
|
160818
|
-
if(type === ready.type[1] && layero.attr('conType') === 'object'){
|
|
160819
|
-
layero.children(':not(.'+ doms[5] +')').remove();
|
|
160820
|
-
var wrap = layero.find('.'+WRAP);
|
|
160821
|
-
for(var i = 0; i < 2; i++){
|
|
160822
|
-
wrap.unwrap();
|
|
160823
|
-
}
|
|
160824
|
-
wrap.css('display', wrap.data('display')).removeClass(WRAP);
|
|
160825
|
-
} else {
|
|
160826
|
-
//低版本IE 回收 iframe
|
|
160827
|
-
if(type === ready.type[2]){
|
|
160828
|
-
try {
|
|
160829
|
-
var iframe = $('#'+doms[4]+index)[0];
|
|
160830
|
-
iframe.contentWindow.document.write('');
|
|
160831
|
-
iframe.contentWindow.close();
|
|
160832
|
-
layero.find('.'+doms[5])[0].removeChild(iframe);
|
|
160833
|
-
} catch(e){}
|
|
160834
|
-
}
|
|
160835
|
-
layero[0].innerHTML = '';
|
|
160836
|
-
layero.remove();
|
|
160837
|
-
}
|
|
160838
|
-
typeof ready.end[index] === 'function' && ready.end[index]();
|
|
160839
|
-
delete ready.end[index];
|
|
160840
|
-
};
|
|
160841
|
-
|
|
160842
|
-
if(layero.data('anim')){
|
|
160843
|
-
layero.addClass(closeAnim);
|
|
160844
|
-
}
|
|
160845
|
-
|
|
160846
|
-
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
|
|
160847
|
-
layer.ie == 6 && ready.reselect();
|
|
160848
|
-
ready.rescollbar(index);
|
|
160849
|
-
|
|
160850
|
-
if(layero.attr('minLeft')){
|
|
160851
|
-
ready.minIndex--;
|
|
160852
|
-
ready.minLeft.push(layero.attr('minLeft'));
|
|
160853
|
-
}
|
|
160854
|
-
setTimeout(function(){
|
|
160855
|
-
remove();
|
|
160856
|
-
}, ((layer.ie && layer.ie < 10) || !layero.data('anim')) ? 0 : 200);
|
|
160857
|
-
};
|
|
160858
|
-
|
|
160859
|
-
//关闭所有层
|
|
160860
|
-
layer.closeAll = function(type){
|
|
160861
|
-
$.each($('.'+doms[0]), function(){
|
|
160862
|
-
var othis = $(this);
|
|
160863
|
-
var is = type ? (othis.attr('type') === type) : 1;
|
|
160864
|
-
is && layer.close(othis.attr('times'));
|
|
160865
|
-
is = null;
|
|
160866
|
-
});
|
|
160867
|
-
};
|
|
160868
|
-
|
|
160869
|
-
/**
|
|
160870
|
-
|
|
160871
|
-
拓展模块,layui开始合并在一起
|
|
160872
|
-
|
|
160873
|
-
*/
|
|
160874
|
-
|
|
160875
|
-
var cache = layer.cache||{}, skin = function(type){
|
|
160876
|
-
return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : '');
|
|
160877
|
-
};
|
|
160878
|
-
|
|
160879
|
-
//仿系统prompt
|
|
160880
|
-
layer.prompt = function(options, yes){
|
|
160881
|
-
var style = '';
|
|
160882
|
-
options = options || {};
|
|
160883
|
-
|
|
160884
|
-
if(typeof options === 'function') yes = options;
|
|
160885
|
-
|
|
160886
|
-
if(options.area){
|
|
160887
|
-
var area = options.area;
|
|
160888
|
-
style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"';
|
|
160889
|
-
delete options.area;
|
|
160890
|
-
}
|
|
160891
|
-
var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){
|
|
160892
|
-
return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">';
|
|
160893
|
-
}();
|
|
160894
|
-
|
|
160895
|
-
return layer.open($.extend({
|
|
160896
|
-
type: 1
|
|
160897
|
-
,btn: ['确定','取消']
|
|
160898
|
-
,content: content
|
|
160899
|
-
,skin: 'layui-layer-prompt' + skin('prompt')
|
|
160900
|
-
,maxWidth: win.width()
|
|
160901
|
-
,success: function(layero){
|
|
160902
|
-
prompt = layero.find('.layui-layer-input');
|
|
160903
|
-
prompt.focus();
|
|
160904
|
-
}
|
|
160905
|
-
,resize: false
|
|
160906
|
-
,yes: function(index){
|
|
160907
|
-
var value = prompt.val();
|
|
160908
|
-
if(value === ''){
|
|
160909
|
-
prompt.focus();
|
|
160910
|
-
} else if(value.length > (options.maxlength||500)) {
|
|
160911
|
-
layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1});
|
|
160912
|
-
} else {
|
|
160913
|
-
yes && yes(value, index, prompt);
|
|
160914
|
-
}
|
|
160915
|
-
}
|
|
160916
|
-
}, options));
|
|
160917
|
-
};
|
|
160918
|
-
|
|
160919
|
-
//tab层
|
|
160920
|
-
layer.tab = function(options){
|
|
160921
|
-
options = options || {};
|
|
160922
|
-
var tab = options.tab || {};
|
|
160923
|
-
return layer.open($.extend({
|
|
160924
|
-
type: 1,
|
|
160925
|
-
skin: 'layui-layer-tab' + skin('tab'),
|
|
160926
|
-
resize: false,
|
|
160927
|
-
title: function(){
|
|
160928
|
-
var len = tab.length, ii = 1, str = '';
|
|
160929
|
-
if(len > 0){
|
|
160930
|
-
str = '<span class="layui-layer-tabnow">'+ tab[0].title +'</span>';
|
|
160931
|
-
for(; ii < len; ii++){
|
|
160932
|
-
str += '<span>'+ tab[ii].title +'</span>';
|
|
160933
|
-
}
|
|
160934
|
-
}
|
|
160935
|
-
return str;
|
|
160936
|
-
}(),
|
|
160937
|
-
content: '<ul class="layui-layer-tabmain">'+ function(){
|
|
160938
|
-
var len = tab.length, ii = 1, str = '';
|
|
160939
|
-
if(len > 0){
|
|
160940
|
-
str = '<li class="layui-layer-tabli xubox_tab_layer">'+ (tab[0].content || 'no content') +'</li>';
|
|
160941
|
-
for(; ii < len; ii++){
|
|
160942
|
-
str += '<li class="layui-layer-tabli">'+ (tab[ii].content || 'no content') +'</li>';
|
|
160943
|
-
}
|
|
160944
|
-
}
|
|
160945
|
-
return str;
|
|
160946
|
-
}() +'</ul>',
|
|
160947
|
-
success: function(layero){
|
|
160948
|
-
var btn = layero.find('.layui-layer-title').children();
|
|
160949
|
-
var main = layero.find('.layui-layer-tabmain').children();
|
|
160950
|
-
btn.on('mousedown', function(e){
|
|
160951
|
-
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
|
|
160952
|
-
var othis = $(this), index = othis.index();
|
|
160953
|
-
othis.addClass('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow');
|
|
160954
|
-
main.eq(index).show().siblings().hide();
|
|
160955
|
-
typeof options.change === 'function' && options.change(index);
|
|
160956
|
-
});
|
|
160957
|
-
}
|
|
160958
|
-
}, options));
|
|
160959
|
-
};
|
|
160960
|
-
|
|
160961
|
-
//相册层
|
|
160962
|
-
layer.photos = function(options, loop, key){
|
|
160963
|
-
var dict = {};
|
|
160964
|
-
options = options || {};
|
|
160965
|
-
if(!options.photos) return;
|
|
160966
|
-
var type = options.photos.constructor === Object;
|
|
160967
|
-
var photos = type ? options.photos : {}, data = photos.data || [];
|
|
160968
|
-
var start = photos.start || 0;
|
|
160969
|
-
dict.imgIndex = (start|0) + 1;
|
|
160970
|
-
|
|
160971
|
-
options.img = options.img || 'img';
|
|
160972
|
-
|
|
160973
|
-
if(!type){ //页面直接获取
|
|
160974
|
-
var parent = $(options.photos), pushData = function(){
|
|
160975
|
-
data = [];
|
|
160976
|
-
parent.find(options.img).each(function(index){
|
|
160977
|
-
var othis = $(this);
|
|
160978
|
-
othis.attr('layer-index', index);
|
|
160979
|
-
data.push({
|
|
160980
|
-
alt: othis.attr('alt'),
|
|
160981
|
-
pid: othis.attr('layer-pid'),
|
|
160982
|
-
src: othis.attr('layer-src') || othis.attr('src'),
|
|
160983
|
-
thumb: othis.attr('src')
|
|
160984
|
-
});
|
|
160985
|
-
})
|
|
160986
|
-
};
|
|
160987
|
-
|
|
160988
|
-
pushData();
|
|
160989
|
-
|
|
160990
|
-
if (data.length === 0) return;
|
|
160991
|
-
|
|
160992
|
-
loop || parent.on('click', options.img, function(){
|
|
160993
|
-
var othis = $(this), index = othis.attr('layer-index');
|
|
160994
|
-
layer.photos($.extend(options, {
|
|
160995
|
-
photos: {
|
|
160996
|
-
start: index,
|
|
160997
|
-
data: data,
|
|
160998
|
-
tab: options.tab
|
|
160999
|
-
},
|
|
161000
|
-
full: options.full
|
|
161001
|
-
}), true);
|
|
161002
|
-
pushData();
|
|
161003
|
-
})
|
|
161004
|
-
|
|
161005
|
-
//不直接弹出
|
|
161006
|
-
if(!loop) return;
|
|
161007
|
-
|
|
161008
|
-
} else if (data.length === 0){
|
|
161009
|
-
return layer.msg('没有图片');
|
|
161010
|
-
}
|
|
161011
|
-
|
|
161012
|
-
//上一张
|
|
161013
|
-
dict.imgprev = function(key){
|
|
161014
|
-
dict.imgIndex--;
|
|
161015
|
-
if(dict.imgIndex < 1){
|
|
161016
|
-
dict.imgIndex = data.length;
|
|
161017
|
-
}
|
|
161018
|
-
dict.tabimg(key);
|
|
161019
|
-
};
|
|
161020
|
-
|
|
161021
|
-
//下一张
|
|
161022
|
-
dict.imgnext = function(key,errorMsg){
|
|
161023
|
-
dict.imgIndex++;
|
|
161024
|
-
if(dict.imgIndex > data.length){
|
|
161025
|
-
dict.imgIndex = 1;
|
|
161026
|
-
if (errorMsg) {return};
|
|
161027
|
-
}
|
|
161028
|
-
dict.tabimg(key)
|
|
161029
|
-
};
|
|
161030
|
-
|
|
161031
|
-
//方向键
|
|
161032
|
-
dict.keyup = function(event){
|
|
161033
|
-
if(!dict.end){
|
|
161034
|
-
var code = event.keyCode;
|
|
161035
|
-
event.preventDefault();
|
|
161036
|
-
if(code === 37){
|
|
161037
|
-
dict.imgprev(true);
|
|
161038
|
-
} else if(code === 39) {
|
|
161039
|
-
dict.imgnext(true);
|
|
161040
|
-
} else if(code === 27) {
|
|
161041
|
-
layer.close(dict.index);
|
|
161042
|
-
}
|
|
161043
|
-
}
|
|
161044
|
-
}
|
|
161045
|
-
|
|
161046
|
-
//切换
|
|
161047
|
-
dict.tabimg = function(key){
|
|
161048
|
-
if(data.length <= 1) return;
|
|
161049
|
-
photos.start = dict.imgIndex - 1;
|
|
161050
|
-
layer.close(dict.index);
|
|
161051
|
-
layer.photos(options, true, key);
|
|
161052
|
-
}
|
|
161053
|
-
|
|
161054
|
-
//一些动作
|
|
161055
|
-
dict.event = function(){
|
|
161056
|
-
dict.bigimg.hover(function(){
|
|
161057
|
-
dict.imgsee.show();
|
|
161058
|
-
}, function(){
|
|
161059
|
-
dict.imgsee.hide();
|
|
161060
|
-
});
|
|
161061
|
-
|
|
161062
|
-
dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){
|
|
161063
|
-
event.preventDefault();
|
|
161064
|
-
dict.imgprev();
|
|
161065
|
-
});
|
|
161066
|
-
|
|
161067
|
-
dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){
|
|
161068
|
-
event.preventDefault();
|
|
161069
|
-
dict.imgnext();
|
|
161070
|
-
});
|
|
161071
|
-
|
|
161072
|
-
$(document).on('keyup', dict.keyup);
|
|
161073
|
-
};
|
|
161074
|
-
|
|
161075
|
-
//图片预加载
|
|
161076
|
-
function loadImage(url, callback, error) {
|
|
161077
|
-
var img = new Image();
|
|
161078
|
-
img.src = url;
|
|
161079
|
-
if(img.complete){
|
|
161080
|
-
return callback(img);
|
|
161081
|
-
}
|
|
161082
|
-
img.onload = function(){
|
|
161083
|
-
img.onload = null;
|
|
161084
|
-
callback(img);
|
|
161085
|
-
};
|
|
161086
|
-
img.onerror = function(e){
|
|
161087
|
-
img.onerror = null;
|
|
161088
|
-
error(e);
|
|
161089
|
-
};
|
|
161090
|
-
};
|
|
161091
|
-
|
|
161092
|
-
dict.loadi = layer.load(1, {
|
|
161093
|
-
shade: 'shade' in options ? false : 0.9,
|
|
161094
|
-
scrollbar: false
|
|
161095
|
-
});
|
|
161096
|
-
loadImage(data[start].src, function(img){
|
|
161097
|
-
layer.close(dict.loadi);
|
|
161098
|
-
dict.index = layer.open($.extend({
|
|
161099
|
-
type: 1,
|
|
161100
|
-
area: function(){
|
|
161101
|
-
var imgarea = [img.width, img.height];
|
|
161102
|
-
var winarea = [$(window).width() - 100, $(window).height() - 100];
|
|
161103
|
-
|
|
161104
|
-
//如果 实际图片的宽或者高比 屏幕大(那么进行缩放)
|
|
161105
|
-
if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){
|
|
161106
|
-
var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例
|
|
161107
|
-
if(wh[0] > wh[1]){//取缩放比例最大的进行缩放
|
|
161108
|
-
imgarea[0] = imgarea[0]/wh[0];
|
|
161109
|
-
imgarea[1] = imgarea[1]/wh[0];
|
|
161110
|
-
} else if(wh[0] < wh[1]){
|
|
161111
|
-
imgarea[0] = imgarea[0]/wh[1];
|
|
161112
|
-
imgarea[1] = imgarea[1]/wh[1];
|
|
161113
|
-
}
|
|
161114
|
-
}
|
|
161115
|
-
|
|
161116
|
-
return [imgarea[0]+'px', imgarea[1]+'px'];
|
|
161117
|
-
}(),
|
|
161118
|
-
title: false,
|
|
161119
|
-
shade: 0.9,
|
|
161120
|
-
shadeClose: true,
|
|
161121
|
-
closeBtn: false,
|
|
161122
|
-
move: '.layui-layer-phimg img',
|
|
161123
|
-
moveType: 1,
|
|
161124
|
-
scrollbar: false,
|
|
161125
|
-
moveOut: true,
|
|
161126
|
-
anim: Math.random()*5|0,
|
|
161127
|
-
skin: 'layui-layer-photos' + skin('photos'),
|
|
161128
|
-
content: '<div class="layui-layer-phimg">'
|
|
161129
|
-
+'<img src="'+ data[start].src +'" alt="'+ (data[start].alt||'') +'" layer-pid="'+ data[start].pid +'">'
|
|
161130
|
-
+'<div class="layui-layer-imgsee">'
|
|
161131
|
-
+(data.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : '')
|
|
161132
|
-
+'<div class="layui-layer-imgbar" style="display:'+ (key ? 'block' : '') +'"><span class="layui-layer-imgtit"><a href="javascript:;">'+ (data[start].alt||'') +'</a><em>'+ dict.imgIndex +'/'+ data.length +'</em></span></div>'
|
|
161133
|
-
+'</div>'
|
|
161134
|
-
+'</div>',
|
|
161135
|
-
success: function(layero, index){
|
|
161136
|
-
dict.bigimg = layero.find('.layui-layer-phimg');
|
|
161137
|
-
dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar');
|
|
161138
|
-
dict.event(layero);
|
|
161139
|
-
options.tab && options.tab(data[start], layero);
|
|
161140
|
-
}, end: function(){
|
|
161141
|
-
dict.end = true;
|
|
161142
|
-
$(document).off('keyup', dict.keyup);
|
|
161143
|
-
}
|
|
161144
|
-
}, options));
|
|
161145
|
-
}, function(){
|
|
161146
|
-
layer.close(dict.loadi);
|
|
161147
|
-
layer.msg('当前图片地址异常<br>是否继续查看下一张?', {
|
|
161148
|
-
time: 30000,
|
|
161149
|
-
btn: ['下一张', '不看了'],
|
|
161150
|
-
yes: function(){
|
|
161151
|
-
data.length > 1 && dict.imgnext(true,true);
|
|
161152
|
-
}
|
|
161153
|
-
});
|
|
161154
|
-
});
|
|
161155
|
-
};
|
|
161156
|
-
|
|
161157
|
-
//主入口
|
|
161158
|
-
ready.run = function(_$){
|
|
161159
|
-
$ = _$;
|
|
161160
|
-
win = $(window);
|
|
161161
|
-
doms.html = $('html');
|
|
161162
|
-
layer.open = function(deliver){
|
|
161163
|
-
var o = new Class(deliver);
|
|
161164
|
-
return o.index;
|
|
161165
|
-
};
|
|
161166
|
-
};
|
|
161167
|
-
ready.run(jQuery);
|
|
161168
|
-
//加载方式
|
|
159944
|
+
|
|
159945
|
+
/**
|
|
159946
|
+
@Name:layer v3.0.1 Web弹层组件
|
|
159947
|
+
@Author:贤心
|
|
159948
|
+
@Site:http://layer.layui.com
|
|
159949
|
+
@License:LGPL
|
|
159950
|
+
|
|
159951
|
+
*/
|
|
159952
|
+
__webpack_require__("5566");
|
|
159953
|
+
|
|
159954
|
+
"use strict";
|
|
159955
|
+
|
|
159956
|
+
var isLayui = window.layui && layui.define, $, win, ready = {
|
|
159957
|
+
getPath: function(){
|
|
159958
|
+
var js = document.scripts, script = js[js.length - 1], jsPath = script.src;
|
|
159959
|
+
if(script.getAttribute('merge')) return;
|
|
159960
|
+
return jsPath.substring(0, jsPath.lastIndexOf("/") + 1);
|
|
159961
|
+
}(),
|
|
159962
|
+
|
|
159963
|
+
config: {}, end: {}, minIndex: 0, minLeft: [],
|
|
159964
|
+
btn: ['确定', '取消'],
|
|
159965
|
+
|
|
159966
|
+
//五种原始层模式
|
|
159967
|
+
type: ['dialog', 'page', 'iframe', 'loading', 'tips']
|
|
159968
|
+
};
|
|
159969
|
+
|
|
159970
|
+
//默认内置方法。
|
|
159971
|
+
var layer = {
|
|
159972
|
+
v: '3.0.1',
|
|
159973
|
+
ie: function(){ //ie版本
|
|
159974
|
+
var agent = navigator.userAgent.toLowerCase();
|
|
159975
|
+
return (!!window.ActiveXObject || "ActiveXObject" in window) ? (
|
|
159976
|
+
(agent.match(/msie\s(\d+)/) || [])[1] || '11' //由于ie11并没有msie的标识
|
|
159977
|
+
) : false;
|
|
159978
|
+
}(),
|
|
159979
|
+
index: (window.layer && window.layer.v) ? 100000 : 0,
|
|
159980
|
+
path: ready.getPath,
|
|
159981
|
+
config: function(options, fn){
|
|
159982
|
+
options = options || {};
|
|
159983
|
+
layer.cache = ready.config = $.extend({}, ready.config, options);
|
|
159984
|
+
layer.path = ready.config.path || layer.path;
|
|
159985
|
+
typeof options.extend === 'string' && (options.extend = [options.extend]);
|
|
159986
|
+
|
|
159987
|
+
if(ready.config.path) layer.ready();
|
|
159988
|
+
|
|
159989
|
+
if(!options.extend) return this;
|
|
159990
|
+
|
|
159991
|
+
isLayui
|
|
159992
|
+
? layui.addcss('modules/layer/' + options.extend)
|
|
159993
|
+
: layer.link('skin/' + options.extend);
|
|
159994
|
+
|
|
159995
|
+
return this;
|
|
159996
|
+
},
|
|
159997
|
+
|
|
159998
|
+
//载入CSS配件
|
|
159999
|
+
link: function(href, fn, cssname){
|
|
160000
|
+
|
|
160001
|
+
//未设置路径,则不主动加载css
|
|
160002
|
+
if(!layer.path) return;
|
|
160003
|
+
|
|
160004
|
+
var head = $('head')[0], link = document.createElement('link');
|
|
160005
|
+
if(typeof fn === 'string') cssname = fn;
|
|
160006
|
+
var app = (cssname || href).replace(/\.|\//g, '');
|
|
160007
|
+
var id = 'layuicss-'+app, timeout = 0;
|
|
160008
|
+
|
|
160009
|
+
link.rel = 'stylesheet';
|
|
160010
|
+
link.href = layer.path + href;
|
|
160011
|
+
link.id = id;
|
|
160012
|
+
|
|
160013
|
+
if(!$('#'+ id)[0]){
|
|
160014
|
+
head.appendChild(link);
|
|
160015
|
+
}
|
|
160016
|
+
|
|
160017
|
+
if(typeof fn !== 'function') return;
|
|
160018
|
+
|
|
160019
|
+
//轮询css是否加载完毕
|
|
160020
|
+
(function poll() {
|
|
160021
|
+
if(++timeout > 8 * 1000 / 100){
|
|
160022
|
+
return window.console && console.error('layer.css: Invalid');
|
|
160023
|
+
};
|
|
160024
|
+
parseInt($('#'+id).css('width')) === 1989 ? fn() : setTimeout(poll, 100);
|
|
160025
|
+
}());
|
|
160026
|
+
},
|
|
160027
|
+
|
|
160028
|
+
ready: function(callback){
|
|
160029
|
+
var cssname = 'skinlayercss', ver = '1110';
|
|
160030
|
+
isLayui ? layui.addcss('modules/layer/default/layer.css?v='+layer.v+ver, callback, cssname)
|
|
160031
|
+
: layer.link('skin/default/layer.css?v='+layer.v+ver, callback, cssname);
|
|
160032
|
+
return this;
|
|
160033
|
+
},
|
|
160034
|
+
|
|
160035
|
+
//各种快捷引用
|
|
160036
|
+
alert: function(content, options, yes){
|
|
160037
|
+
var type = typeof options === 'function';
|
|
160038
|
+
if(type) yes = options;
|
|
160039
|
+
return layer.open($.extend({
|
|
160040
|
+
content: content,
|
|
160041
|
+
yes: yes
|
|
160042
|
+
}, type ? {} : options));
|
|
160043
|
+
},
|
|
160044
|
+
|
|
160045
|
+
confirm: function(content, options, yes, cancel){
|
|
160046
|
+
var type = typeof options === 'function';
|
|
160047
|
+
if(type){
|
|
160048
|
+
cancel = yes;
|
|
160049
|
+
yes = options;
|
|
160050
|
+
}
|
|
160051
|
+
return layer.open($.extend({
|
|
160052
|
+
content: content,
|
|
160053
|
+
btn: ready.btn,
|
|
160054
|
+
yes: yes,
|
|
160055
|
+
btn2: cancel
|
|
160056
|
+
}, type ? {} : options));
|
|
160057
|
+
},
|
|
160058
|
+
|
|
160059
|
+
msg: function(content, options, end){ //最常用提示层
|
|
160060
|
+
var type = typeof options === 'function', rskin = ready.config.skin;
|
|
160061
|
+
var skin = (rskin ? rskin + ' ' + rskin + '-msg' : '')||'layui-layer-msg';
|
|
160062
|
+
var anim = doms.anim.length - 1;
|
|
160063
|
+
if(type) end = options;
|
|
160064
|
+
return layer.open($.extend({
|
|
160065
|
+
content: content,
|
|
160066
|
+
time: 3000,
|
|
160067
|
+
shade: false,
|
|
160068
|
+
skin: skin,
|
|
160069
|
+
title: false,
|
|
160070
|
+
closeBtn: false,
|
|
160071
|
+
btn: false,
|
|
160072
|
+
resize: false,
|
|
160073
|
+
end: end
|
|
160074
|
+
}, (type && !ready.config.skin) ? {
|
|
160075
|
+
skin: skin + ' layui-layer-hui',
|
|
160076
|
+
anim: anim
|
|
160077
|
+
} : function(){
|
|
160078
|
+
options = options || {};
|
|
160079
|
+
if(options.icon === -1 || options.icon === undefined && !ready.config.skin){
|
|
160080
|
+
options.skin = skin + ' ' + (options.skin||'layui-layer-hui');
|
|
160081
|
+
}
|
|
160082
|
+
return options;
|
|
160083
|
+
}()));
|
|
160084
|
+
},
|
|
160085
|
+
|
|
160086
|
+
load: function(icon, options){
|
|
160087
|
+
return layer.open($.extend({
|
|
160088
|
+
type: 3,
|
|
160089
|
+
icon: icon || 0,
|
|
160090
|
+
resize: false,
|
|
160091
|
+
shade: 0.01
|
|
160092
|
+
}, options));
|
|
160093
|
+
},
|
|
160094
|
+
|
|
160095
|
+
tips: function(content, follow, options){
|
|
160096
|
+
return layer.open($.extend({
|
|
160097
|
+
type: 4,
|
|
160098
|
+
content: [content, follow],
|
|
160099
|
+
closeBtn: false,
|
|
160100
|
+
time: 3000,
|
|
160101
|
+
shade: false,
|
|
160102
|
+
resize: false,
|
|
160103
|
+
fixed: false,
|
|
160104
|
+
maxWidth: 210
|
|
160105
|
+
}, options));
|
|
160106
|
+
}
|
|
160107
|
+
};
|
|
160108
|
+
|
|
160109
|
+
var Class = function(setings){
|
|
160110
|
+
var that = this;
|
|
160111
|
+
that.index = ++layer.index;
|
|
160112
|
+
that.config = $.extend({}, that.config, ready.config, setings);
|
|
160113
|
+
document.body ? that.creat() : setTimeout(function(){
|
|
160114
|
+
that.creat();
|
|
160115
|
+
}, 50);
|
|
160116
|
+
};
|
|
160117
|
+
|
|
160118
|
+
Class.pt = Class.prototype;
|
|
160119
|
+
|
|
160120
|
+
//缓存常用字符
|
|
160121
|
+
var doms = ['layui-layer', '.layui-layer-title', '.layui-layer-main', '.layui-layer-dialog', 'layui-layer-iframe', 'layui-layer-content', 'layui-layer-btn', 'layui-layer-close'];
|
|
160122
|
+
doms.anim = ['layer-anim', 'layer-anim-01', 'layer-anim-02', 'layer-anim-03', 'layer-anim-04', 'layer-anim-05', 'layer-anim-06'];
|
|
160123
|
+
|
|
160124
|
+
//默认配置
|
|
160125
|
+
Class.pt.config = {
|
|
160126
|
+
type: 0,
|
|
160127
|
+
shade: 0.3,
|
|
160128
|
+
fixed: true,
|
|
160129
|
+
move: doms[1],
|
|
160130
|
+
title: '信息',
|
|
160131
|
+
offset: 'auto',
|
|
160132
|
+
area: 'auto',
|
|
160133
|
+
closeBtn: 1,
|
|
160134
|
+
time: 0, //0表示不自动关闭
|
|
160135
|
+
zIndex: 19891014,
|
|
160136
|
+
maxWidth: 360,
|
|
160137
|
+
anim: 0,
|
|
160138
|
+
icon: -1,
|
|
160139
|
+
moveType: 1,
|
|
160140
|
+
resize: true,
|
|
160141
|
+
scrollbar: true, //是否允许浏览器滚动条
|
|
160142
|
+
tips: 2
|
|
160143
|
+
};
|
|
160144
|
+
|
|
160145
|
+
//容器
|
|
160146
|
+
Class.pt.vessel = function(conType, callback){
|
|
160147
|
+
var that = this, times = that.index, config = that.config;
|
|
160148
|
+
var zIndex = config.zIndex + times, titype = typeof config.title === 'object';
|
|
160149
|
+
var ismax = config.maxmin && (config.type === 1 || config.type === 2);
|
|
160150
|
+
var titleHTML = (config.title ? '<div class="layui-layer-title" style="'+ (titype ? config.title[1] : '') +'">'
|
|
160151
|
+
+ (titype ? config.title[0] : config.title)
|
|
160152
|
+
+ '</div>' : '');
|
|
160153
|
+
|
|
160154
|
+
config.zIndex = zIndex;
|
|
160155
|
+
callback([
|
|
160156
|
+
//遮罩
|
|
160157
|
+
config.shade ? ('<div class="layui-layer-shade" id="layui-layer-shade'+ times +'" times="'+ times +'" style="'+ ('z-index:'+ (zIndex-1) +'; background-color:'+ (config.shade[1]||'#000') +'; opacity:'+ (config.shade[0]||config.shade) +'; filter:alpha(opacity='+ (config.shade[0]*100||config.shade*100) +');') +'"></div>') : '',
|
|
160158
|
+
|
|
160159
|
+
//主体
|
|
160160
|
+
'<div class="'+ doms[0] + (' layui-layer-'+ready.type[config.type]) + (((config.type == 0 || config.type == 2) && !config.shade) ? ' layui-layer-border' : '') + ' ' + (config.skin||'') +'" id="'+ doms[0] + times +'" type="'+ ready.type[config.type] +'" times="'+ times +'" showtime="'+ config.time +'" conType="'+ (conType ? 'object' : 'string') +'" style="z-index: '+ zIndex +'; width:'+ config.area[0] + ';height:' + config.area[1] + (config.fixed ? '' : ';position:absolute;') +'">'
|
|
160161
|
+
+ (conType && config.type != 2 ? '' : titleHTML)
|
|
160162
|
+
+ '<div id="'+ (config.id||'') +'" class="layui-layer-content'+ ((config.type == 0 && config.icon !== -1) ? ' layui-layer-padding' :'') + (config.type == 3 ? ' layui-layer-loading'+config.icon : '') +'">'
|
|
160163
|
+
+ (config.type == 0 && config.icon !== -1 ? '<i class="layui-layer-ico layui-layer-ico'+ config.icon +'"></i>' : '')
|
|
160164
|
+
+ (config.type == 1 && conType ? '' : (config.content||''))
|
|
160165
|
+
+ '</div>'
|
|
160166
|
+
+ '<span class="layui-layer-setwin">'+ function(){
|
|
160167
|
+
var closebtn = ismax ? '<a class="layui-layer-min" href="javascript:;"><cite></cite></a><a class="layui-layer-ico layui-layer-max" href="javascript:;"></a>' : '';
|
|
160168
|
+
config.closeBtn && (closebtn += '<a class="layui-layer-ico '+ doms[7] +' '+ doms[7] + (config.title ? config.closeBtn : (config.type == 4 ? '1' : '2')) +'" href="javascript:;"></a>');
|
|
160169
|
+
return closebtn;
|
|
160170
|
+
}() + '</span>'
|
|
160171
|
+
+ (config.btn ? function(){
|
|
160172
|
+
var button = '';
|
|
160173
|
+
typeof config.btn === 'string' && (config.btn = [config.btn]);
|
|
160174
|
+
for(var i = 0, len = config.btn.length; i < len; i++){
|
|
160175
|
+
button += '<a class="'+ doms[6] +''+ i +'">'+ config.btn[i] +'</a>'
|
|
160176
|
+
}
|
|
160177
|
+
return '<div class="'+ doms[6] +' layui-layer-btn-'+ (config.btnAlign||'') +'">'+ button +'</div>'
|
|
160178
|
+
}() : '')
|
|
160179
|
+
+ (config.resize ? '<span class="layui-layer-resize"></span>' : '')
|
|
160180
|
+
+ '</div>'
|
|
160181
|
+
], titleHTML, $('<div class="layui-layer-move"></div>'));
|
|
160182
|
+
return that;
|
|
160183
|
+
};
|
|
160184
|
+
|
|
160185
|
+
//创建骨架
|
|
160186
|
+
Class.pt.creat = function(){
|
|
160187
|
+
var that = this
|
|
160188
|
+
,config = that.config
|
|
160189
|
+
,times = that.index, nodeIndex
|
|
160190
|
+
,content = config.content
|
|
160191
|
+
,conType = typeof content === 'object'
|
|
160192
|
+
,body = $('body');
|
|
160193
|
+
|
|
160194
|
+
if($('#'+config.id)[0]) return;
|
|
160195
|
+
|
|
160196
|
+
if(typeof config.area === 'string'){
|
|
160197
|
+
config.area = config.area === 'auto' ? ['', ''] : [config.area, ''];
|
|
160198
|
+
}
|
|
160199
|
+
|
|
160200
|
+
//anim兼容旧版shift
|
|
160201
|
+
if(config.shift){
|
|
160202
|
+
config.anim = config.shift;
|
|
160203
|
+
}
|
|
160204
|
+
|
|
160205
|
+
if(layer.ie == 6){
|
|
160206
|
+
config.fixed = false;
|
|
160207
|
+
}
|
|
160208
|
+
|
|
160209
|
+
switch(config.type){
|
|
160210
|
+
case 0:
|
|
160211
|
+
config.btn = ('btn' in config) ? config.btn : ready.btn[0];
|
|
160212
|
+
layer.closeAll('dialog');
|
|
160213
|
+
break;
|
|
160214
|
+
case 2:
|
|
160215
|
+
var content = config.content = conType ? config.content : [config.content||'http://layer.layui.com', 'auto'];
|
|
160216
|
+
config.content = '<iframe scrolling="'+ (config.content[1]||'auto') +'" allowtransparency="true" id="'+ doms[4] +''+ times +'" name="'+ doms[4] +''+ times +'" onload="this.className=\'\';" class="layui-layer-load" frameborder="0" src="' + config.content[0] + '"></iframe>';
|
|
160217
|
+
break;
|
|
160218
|
+
case 3:
|
|
160219
|
+
delete config.title;
|
|
160220
|
+
delete config.closeBtn;
|
|
160221
|
+
config.icon === -1 && (config.icon === 0);
|
|
160222
|
+
layer.closeAll('loading');
|
|
160223
|
+
break;
|
|
160224
|
+
case 4:
|
|
160225
|
+
conType || (config.content = [config.content, 'body']);
|
|
160226
|
+
config.follow = config.content[1];
|
|
160227
|
+
config.content = config.content[0] + '<i class="layui-layer-TipsG"></i>';
|
|
160228
|
+
delete config.title;
|
|
160229
|
+
config.tips = typeof config.tips === 'object' ? config.tips : [config.tips, true];
|
|
160230
|
+
config.tipsMore || layer.closeAll('tips');
|
|
160231
|
+
break;
|
|
160232
|
+
}
|
|
160233
|
+
|
|
160234
|
+
//建立容器
|
|
160235
|
+
that.vessel(conType, function(html, titleHTML, moveElem){
|
|
160236
|
+
body.append(html[0]);
|
|
160237
|
+
conType ? function(){
|
|
160238
|
+
(config.type == 2 || config.type == 4) ? function(){
|
|
160239
|
+
$('body').append(html[1]);
|
|
160240
|
+
}() : function(){
|
|
160241
|
+
if(!content.parents('.'+doms[0])[0]){
|
|
160242
|
+
content.data('display', content.css('display')).show().addClass('layui-layer-wrap').wrap(html[1]);
|
|
160243
|
+
$('#'+ doms[0] + times).find('.'+doms[5]).before(titleHTML);
|
|
160244
|
+
}
|
|
160245
|
+
}();
|
|
160246
|
+
}() : body.append(html[1]);
|
|
160247
|
+
$('.layui-layer-move')[0] || body.append(ready.moveElem = moveElem);
|
|
160248
|
+
that.layero = $('#'+ doms[0] + times);
|
|
160249
|
+
config.scrollbar || doms.html.css('overflow', 'hidden').attr('layer-full', times);
|
|
160250
|
+
}).auto(times);
|
|
160251
|
+
|
|
160252
|
+
config.type == 2 && layer.ie == 6 && that.layero.find('iframe').attr('src', content[0]);
|
|
160253
|
+
|
|
160254
|
+
//坐标自适应浏览器窗口尺寸
|
|
160255
|
+
config.type == 4 ? that.tips() : that.offset();
|
|
160256
|
+
if(config.fixed){
|
|
160257
|
+
win.on('resize', function(){
|
|
160258
|
+
that.offset();
|
|
160259
|
+
(/^\d+%$/.test(config.area[0]) || /^\d+%$/.test(config.area[1])) && that.auto(times);
|
|
160260
|
+
config.type == 4 && that.tips();
|
|
160261
|
+
});
|
|
160262
|
+
}
|
|
160263
|
+
|
|
160264
|
+
config.time <= 0 || setTimeout(function(){
|
|
160265
|
+
layer.close(that.index)
|
|
160266
|
+
}, config.time);
|
|
160267
|
+
that.move().callback();
|
|
160268
|
+
|
|
160269
|
+
//为兼容jQuery3.0的css动画影响元素尺寸计算
|
|
160270
|
+
if(doms.anim[config.anim]){
|
|
160271
|
+
that.layero.addClass(doms.anim[config.anim]).data('anim', true);
|
|
160272
|
+
};
|
|
160273
|
+
};
|
|
160274
|
+
|
|
160275
|
+
//自适应
|
|
160276
|
+
Class.pt.auto = function(index){
|
|
160277
|
+
var that = this, config = that.config, layero = $('#'+ doms[0] + index);
|
|
160278
|
+
if(config.area[0] === '' && config.maxWidth > 0){
|
|
160279
|
+
//为了修复IE7下一个让人难以理解的bug
|
|
160280
|
+
if(layer.ie && layer.ie < 8 && config.btn){
|
|
160281
|
+
layero.width(layero.innerWidth());
|
|
160282
|
+
}
|
|
160283
|
+
layero.outerWidth() > config.maxWidth && layero.width(config.maxWidth);
|
|
160284
|
+
}
|
|
160285
|
+
var area = [layero.innerWidth(), layero.innerHeight()];
|
|
160286
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
|
160287
|
+
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
|
160288
|
+
function setHeight(elem){
|
|
160289
|
+
elem = layero.find(elem);
|
|
160290
|
+
elem.height(area[1] - titHeight - btnHeight - 2*(parseFloat(elem.css('padding'))|0));
|
|
160291
|
+
}
|
|
160292
|
+
switch(config.type){
|
|
160293
|
+
case 2:
|
|
160294
|
+
setHeight('iframe');
|
|
160295
|
+
break;
|
|
160296
|
+
default:
|
|
160297
|
+
if(config.area[1] === ''){
|
|
160298
|
+
if(config.fixed && area[1] >= win.height()){
|
|
160299
|
+
area[1] = win.height();
|
|
160300
|
+
setHeight('.'+doms[5]);
|
|
160301
|
+
}
|
|
160302
|
+
} else {
|
|
160303
|
+
setHeight('.'+doms[5]);
|
|
160304
|
+
}
|
|
160305
|
+
break;
|
|
160306
|
+
}
|
|
160307
|
+
return that;
|
|
160308
|
+
};
|
|
160309
|
+
|
|
160310
|
+
//计算坐标
|
|
160311
|
+
Class.pt.offset = function(){
|
|
160312
|
+
var that = this, config = that.config, layero = that.layero;
|
|
160313
|
+
var area = [layero.outerWidth(), layero.outerHeight()];
|
|
160314
|
+
var type = typeof config.offset === 'object';
|
|
160315
|
+
that.offsetTop = (win.height() - area[1])/2;
|
|
160316
|
+
that.offsetLeft = (win.width() - area[0])/2;
|
|
160317
|
+
|
|
160318
|
+
if(type){
|
|
160319
|
+
that.offsetTop = config.offset[0];
|
|
160320
|
+
that.offsetLeft = config.offset[1]||that.offsetLeft;
|
|
160321
|
+
} else if(config.offset !== 'auto'){
|
|
160322
|
+
|
|
160323
|
+
if(config.offset === 't'){ //上
|
|
160324
|
+
that.offsetTop = 0;
|
|
160325
|
+
} else if(config.offset === 'r'){ //右
|
|
160326
|
+
that.offsetLeft = win.width() - area[0];
|
|
160327
|
+
} else if(config.offset === 'b'){ //下
|
|
160328
|
+
that.offsetTop = win.height() - area[1];
|
|
160329
|
+
} else if(config.offset === 'l'){ //左
|
|
160330
|
+
that.offsetLeft = 0;
|
|
160331
|
+
} else if(config.offset === 'lt'){ //左上角
|
|
160332
|
+
that.offsetTop = 0;
|
|
160333
|
+
that.offsetLeft = 0;
|
|
160334
|
+
} else if(config.offset === 'lb'){ //左下角
|
|
160335
|
+
that.offsetTop = win.height() - area[1];
|
|
160336
|
+
that.offsetLeft = 0;
|
|
160337
|
+
} else if(config.offset === 'rt'){ //右上角
|
|
160338
|
+
that.offsetTop = 0;
|
|
160339
|
+
that.offsetLeft = win.width() - area[0];
|
|
160340
|
+
} else if(config.offset === 'rb'){ //右下角
|
|
160341
|
+
that.offsetTop = win.height() - area[1];
|
|
160342
|
+
that.offsetLeft = win.width() - area[0];
|
|
160343
|
+
} else {
|
|
160344
|
+
that.offsetTop = config.offset;
|
|
160345
|
+
}
|
|
160346
|
+
|
|
160347
|
+
}
|
|
160348
|
+
|
|
160349
|
+
if(!config.fixed){
|
|
160350
|
+
that.offsetTop = /%$/.test(that.offsetTop) ?
|
|
160351
|
+
win.height()*parseFloat(that.offsetTop)/100
|
|
160352
|
+
: parseFloat(that.offsetTop);
|
|
160353
|
+
that.offsetLeft = /%$/.test(that.offsetLeft) ?
|
|
160354
|
+
win.width()*parseFloat(that.offsetLeft)/100
|
|
160355
|
+
: parseFloat(that.offsetLeft);
|
|
160356
|
+
that.offsetTop += win.scrollTop();
|
|
160357
|
+
that.offsetLeft += win.scrollLeft();
|
|
160358
|
+
}
|
|
160359
|
+
|
|
160360
|
+
if(layero.attr('minLeft')){
|
|
160361
|
+
that.offsetTop = win.height() - (layero.find(doms[1]).outerHeight() || 0);
|
|
160362
|
+
that.offsetLeft = layero.css('left');
|
|
160363
|
+
}
|
|
160364
|
+
|
|
160365
|
+
layero.css({top: that.offsetTop, left: that.offsetLeft});
|
|
160366
|
+
};
|
|
160367
|
+
|
|
160368
|
+
//Tips
|
|
160369
|
+
Class.pt.tips = function(){
|
|
160370
|
+
var that = this, config = that.config, layero = that.layero;
|
|
160371
|
+
var layArea = [layero.outerWidth(), layero.outerHeight()], follow = $(config.follow);
|
|
160372
|
+
if(!follow[0]) follow = $('body');
|
|
160373
|
+
var goal = {
|
|
160374
|
+
width: follow.outerWidth(),
|
|
160375
|
+
height: follow.outerHeight(),
|
|
160376
|
+
top: follow.offset().top,
|
|
160377
|
+
left: follow.offset().left
|
|
160378
|
+
}, tipsG = layero.find('.layui-layer-TipsG');
|
|
160379
|
+
|
|
160380
|
+
var guide = config.tips[0];
|
|
160381
|
+
config.tips[1] || tipsG.remove();
|
|
160382
|
+
|
|
160383
|
+
goal.autoLeft = function(){
|
|
160384
|
+
if(goal.left + layArea[0] - win.width() > 0){
|
|
160385
|
+
goal.tipLeft = goal.left + goal.width - layArea[0];
|
|
160386
|
+
tipsG.css({right: 12, left: 'auto'});
|
|
160387
|
+
} else {
|
|
160388
|
+
goal.tipLeft = goal.left;
|
|
160389
|
+
};
|
|
160390
|
+
};
|
|
160391
|
+
|
|
160392
|
+
//辨别tips的方位
|
|
160393
|
+
goal.where = [function(){ //上
|
|
160394
|
+
goal.autoLeft();
|
|
160395
|
+
goal.tipTop = goal.top - layArea[1] - 10;
|
|
160396
|
+
tipsG.removeClass('layui-layer-TipsB').addClass('layui-layer-TipsT').css('border-right-color', config.tips[1]);
|
|
160397
|
+
}, function(){ //右
|
|
160398
|
+
goal.tipLeft = goal.left + goal.width + 10;
|
|
160399
|
+
goal.tipTop = goal.top;
|
|
160400
|
+
tipsG.removeClass('layui-layer-TipsL').addClass('layui-layer-TipsR').css('border-bottom-color', config.tips[1]);
|
|
160401
|
+
}, function(){ //下
|
|
160402
|
+
goal.autoLeft();
|
|
160403
|
+
goal.tipTop = goal.top + goal.height + 10;
|
|
160404
|
+
tipsG.removeClass('layui-layer-TipsT').addClass('layui-layer-TipsB').css('border-right-color', config.tips[1]);
|
|
160405
|
+
}, function(){ //左
|
|
160406
|
+
goal.tipLeft = goal.left - layArea[0] - 10;
|
|
160407
|
+
goal.tipTop = goal.top;
|
|
160408
|
+
tipsG.removeClass('layui-layer-TipsR').addClass('layui-layer-TipsL').css('border-bottom-color', config.tips[1]);
|
|
160409
|
+
}];
|
|
160410
|
+
goal.where[guide-1]();
|
|
160411
|
+
|
|
160412
|
+
/* 8*2为小三角形占据的空间 */
|
|
160413
|
+
if(guide === 1){
|
|
160414
|
+
goal.top - (win.scrollTop() + layArea[1] + 8*2) < 0 && goal.where[2]();
|
|
160415
|
+
} else if(guide === 2){
|
|
160416
|
+
win.width() - (goal.left + goal.width + layArea[0] + 8*2) > 0 || goal.where[3]()
|
|
160417
|
+
} else if(guide === 3){
|
|
160418
|
+
(goal.top - win.scrollTop() + goal.height + layArea[1] + 8*2) - win.height() > 0 && goal.where[0]();
|
|
160419
|
+
} else if(guide === 4){
|
|
160420
|
+
layArea[0] + 8*2 - goal.left > 0 && goal.where[1]()
|
|
160421
|
+
}
|
|
160422
|
+
|
|
160423
|
+
layero.find('.'+doms[5]).css({
|
|
160424
|
+
'background-color': config.tips[1],
|
|
160425
|
+
'padding-right': (config.closeBtn ? '30px' : '')
|
|
160426
|
+
});
|
|
160427
|
+
layero.css({
|
|
160428
|
+
left: goal.tipLeft - (config.fixed ? win.scrollLeft() : 0),
|
|
160429
|
+
top: goal.tipTop - (config.fixed ? win.scrollTop() : 0)
|
|
160430
|
+
});
|
|
160431
|
+
}
|
|
160432
|
+
|
|
160433
|
+
//拖拽层
|
|
160434
|
+
Class.pt.move = function(){
|
|
160435
|
+
var that = this
|
|
160436
|
+
,config = that.config
|
|
160437
|
+
,_DOC = $(document)
|
|
160438
|
+
,layero = that.layero
|
|
160439
|
+
,moveElem = layero.find(config.move)
|
|
160440
|
+
,resizeElem = layero.find('.layui-layer-resize')
|
|
160441
|
+
,dict = {};
|
|
160442
|
+
|
|
160443
|
+
if(config.move){
|
|
160444
|
+
moveElem.css('cursor', 'move');
|
|
160445
|
+
}
|
|
160446
|
+
|
|
160447
|
+
moveElem.on('mousedown', function(e){
|
|
160448
|
+
e.preventDefault();
|
|
160449
|
+
if(config.move){
|
|
160450
|
+
dict.moveStart = true;
|
|
160451
|
+
dict.offset = [
|
|
160452
|
+
e.clientX - parseFloat(layero.css('left'))
|
|
160453
|
+
,e.clientY - parseFloat(layero.css('top'))
|
|
160454
|
+
];
|
|
160455
|
+
ready.moveElem.css('cursor', 'move').show();
|
|
160456
|
+
}
|
|
160457
|
+
});
|
|
160458
|
+
|
|
160459
|
+
resizeElem.on('mousedown', function(e){
|
|
160460
|
+
e.preventDefault();
|
|
160461
|
+
dict.resizeStart = true;
|
|
160462
|
+
dict.offset = [e.clientX, e.clientY];
|
|
160463
|
+
dict.area = [
|
|
160464
|
+
layero.outerWidth()
|
|
160465
|
+
,layero.outerHeight()
|
|
160466
|
+
];
|
|
160467
|
+
ready.moveElem.css('cursor', 'se-resize').show();
|
|
160468
|
+
});
|
|
160469
|
+
|
|
160470
|
+
_DOC.on('mousemove', function(e){
|
|
160471
|
+
|
|
160472
|
+
//拖拽移动
|
|
160473
|
+
if(dict.moveStart){
|
|
160474
|
+
var X = e.clientX - dict.offset[0]
|
|
160475
|
+
,Y = e.clientY - dict.offset[1]
|
|
160476
|
+
,fixed = layero.css('position') === 'fixed';
|
|
160477
|
+
|
|
160478
|
+
e.preventDefault();
|
|
160479
|
+
|
|
160480
|
+
dict.stX = fixed ? 0 : win.scrollLeft();
|
|
160481
|
+
dict.stY = fixed ? 0 : win.scrollTop();
|
|
160482
|
+
|
|
160483
|
+
//控制元素不被拖出窗口外
|
|
160484
|
+
if(!config.moveOut){
|
|
160485
|
+
var setRig = win.width() - layero.outerWidth() + dict.stX
|
|
160486
|
+
,setBot = win.height() - layero.outerHeight() + dict.stY;
|
|
160487
|
+
X < dict.stX && (X = dict.stX);
|
|
160488
|
+
X > setRig && (X = setRig);
|
|
160489
|
+
Y < dict.stY && (Y = dict.stY);
|
|
160490
|
+
Y > setBot && (Y = setBot);
|
|
160491
|
+
}
|
|
160492
|
+
|
|
160493
|
+
layero.css({
|
|
160494
|
+
left: X
|
|
160495
|
+
,top: Y
|
|
160496
|
+
});
|
|
160497
|
+
}
|
|
160498
|
+
|
|
160499
|
+
//Resize
|
|
160500
|
+
if(config.resize && dict.resizeStart){
|
|
160501
|
+
var X = e.clientX - dict.offset[0]
|
|
160502
|
+
,Y = e.clientY - dict.offset[1];
|
|
160503
|
+
|
|
160504
|
+
e.preventDefault();
|
|
160505
|
+
|
|
160506
|
+
layer.style(that.index, {
|
|
160507
|
+
width: dict.area[0] + X
|
|
160508
|
+
,height: dict.area[1] + Y
|
|
160509
|
+
})
|
|
160510
|
+
dict.isResize = true;
|
|
160511
|
+
}
|
|
160512
|
+
}).on('mouseup', function(e){
|
|
160513
|
+
if(dict.moveStart){
|
|
160514
|
+
delete dict.moveStart;
|
|
160515
|
+
ready.moveElem.hide();
|
|
160516
|
+
config.moveEnd && config.moveEnd();
|
|
160517
|
+
}
|
|
160518
|
+
if(dict.resizeStart){
|
|
160519
|
+
delete dict.resizeStart;
|
|
160520
|
+
ready.moveElem.hide();
|
|
160521
|
+
}
|
|
160522
|
+
});
|
|
160523
|
+
|
|
160524
|
+
return that;
|
|
160525
|
+
};
|
|
160526
|
+
|
|
160527
|
+
Class.pt.callback = function(){
|
|
160528
|
+
var that = this, layero = that.layero, config = that.config;
|
|
160529
|
+
that.openLayer();
|
|
160530
|
+
if(config.success){
|
|
160531
|
+
if(config.type == 2){
|
|
160532
|
+
layero.find('iframe').on('load', function(){
|
|
160533
|
+
config.success(layero, that.index);
|
|
160534
|
+
});
|
|
160535
|
+
} else {
|
|
160536
|
+
config.success(layero, that.index);
|
|
160537
|
+
}
|
|
160538
|
+
}
|
|
160539
|
+
layer.ie == 6 && that.IE6(layero);
|
|
160540
|
+
|
|
160541
|
+
//按钮
|
|
160542
|
+
layero.find('.'+ doms[6]).children('a').on('click', function(){
|
|
160543
|
+
var index = $(this).index();
|
|
160544
|
+
if(index === 0){
|
|
160545
|
+
if(config.yes){
|
|
160546
|
+
config.yes(that.index, layero)
|
|
160547
|
+
} else if(config['btn1']){
|
|
160548
|
+
config['btn1'](that.index, layero)
|
|
160549
|
+
} else {
|
|
160550
|
+
layer.close(that.index);
|
|
160551
|
+
}
|
|
160552
|
+
} else {
|
|
160553
|
+
var close = config['btn'+(index+1)] && config['btn'+(index+1)](that.index, layero);
|
|
160554
|
+
close === false || layer.close(that.index);
|
|
160555
|
+
}
|
|
160556
|
+
});
|
|
160557
|
+
|
|
160558
|
+
//取消
|
|
160559
|
+
function cancel(){
|
|
160560
|
+
var close = config.cancel && config.cancel(that.index, layero);
|
|
160561
|
+
close === false || layer.close(that.index);
|
|
160562
|
+
}
|
|
160563
|
+
|
|
160564
|
+
//右上角关闭回调
|
|
160565
|
+
layero.find('.'+ doms[7]).on('click', cancel);
|
|
160566
|
+
|
|
160567
|
+
//点遮罩关闭
|
|
160568
|
+
if(config.shadeClose){
|
|
160569
|
+
$('#layui-layer-shade'+ that.index).on('click', function(){
|
|
160570
|
+
layer.close(that.index);
|
|
160571
|
+
});
|
|
160572
|
+
}
|
|
160573
|
+
|
|
160574
|
+
//最小化
|
|
160575
|
+
layero.find('.layui-layer-min').on('click', function(){
|
|
160576
|
+
var min = config.min && config.min(layero);
|
|
160577
|
+
min === false || layer.min(that.index, config);
|
|
160578
|
+
});
|
|
160579
|
+
|
|
160580
|
+
//全屏/还原
|
|
160581
|
+
layero.find('.layui-layer-max').on('click', function(){
|
|
160582
|
+
if($(this).hasClass('layui-layer-maxmin')){
|
|
160583
|
+
layer.restore(that.index);
|
|
160584
|
+
config.restore && config.restore(layero);
|
|
160585
|
+
} else {
|
|
160586
|
+
layer.full(that.index, config);
|
|
160587
|
+
setTimeout(function(){
|
|
160588
|
+
config.full && config.full(layero);
|
|
160589
|
+
}, 100);
|
|
160590
|
+
}
|
|
160591
|
+
});
|
|
160592
|
+
|
|
160593
|
+
config.end && (ready.end[that.index] = config.end);
|
|
160594
|
+
};
|
|
160595
|
+
|
|
160596
|
+
//for ie6 恢复select
|
|
160597
|
+
ready.reselect = function(){
|
|
160598
|
+
$.each($('select'), function(index , value){
|
|
160599
|
+
var sthis = $(this);
|
|
160600
|
+
if(!sthis.parents('.'+doms[0])[0]){
|
|
160601
|
+
(sthis.attr('layer') == 1 && $('.'+doms[0]).length < 1) && sthis.removeAttr('layer').show();
|
|
160602
|
+
}
|
|
160603
|
+
sthis = null;
|
|
160604
|
+
});
|
|
160605
|
+
};
|
|
160606
|
+
|
|
160607
|
+
Class.pt.IE6 = function(layero){
|
|
160608
|
+
//隐藏select
|
|
160609
|
+
$('select').each(function(index , value){
|
|
160610
|
+
var sthis = $(this);
|
|
160611
|
+
if(!sthis.parents('.'+doms[0])[0]){
|
|
160612
|
+
sthis.css('display') === 'none' || sthis.attr({'layer' : '1'}).hide();
|
|
160613
|
+
}
|
|
160614
|
+
sthis = null;
|
|
160615
|
+
});
|
|
160616
|
+
};
|
|
160617
|
+
|
|
160618
|
+
//需依赖原型的对外方法
|
|
160619
|
+
Class.pt.openLayer = function(){
|
|
160620
|
+
var that = this;
|
|
160621
|
+
|
|
160622
|
+
//置顶当前窗口
|
|
160623
|
+
layer.zIndex = that.config.zIndex;
|
|
160624
|
+
layer.setTop = function(layero){
|
|
160625
|
+
var setZindex = function(){
|
|
160626
|
+
layer.zIndex++;
|
|
160627
|
+
layero.css('z-index', layer.zIndex + 1);
|
|
160628
|
+
};
|
|
160629
|
+
layer.zIndex = parseInt(layero[0].style.zIndex);
|
|
160630
|
+
layero.on('mousedown', setZindex);
|
|
160631
|
+
return layer.zIndex;
|
|
160632
|
+
};
|
|
160633
|
+
};
|
|
160634
|
+
|
|
160635
|
+
ready.record = function(layero){
|
|
160636
|
+
var area = [
|
|
160637
|
+
layero.width(),
|
|
160638
|
+
layero.height(),
|
|
160639
|
+
layero.position().top,
|
|
160640
|
+
layero.position().left + parseFloat(layero.css('margin-left'))
|
|
160641
|
+
];
|
|
160642
|
+
layero.find('.layui-layer-max').addClass('layui-layer-maxmin');
|
|
160643
|
+
layero.attr({area: area});
|
|
160644
|
+
};
|
|
160645
|
+
|
|
160646
|
+
ready.rescollbar = function(index){
|
|
160647
|
+
if(doms.html.attr('layer-full') == index){
|
|
160648
|
+
if(doms.html[0].style.removeProperty){
|
|
160649
|
+
doms.html[0].style.removeProperty('overflow');
|
|
160650
|
+
} else {
|
|
160651
|
+
doms.html[0].style.removeAttribute('overflow');
|
|
160652
|
+
}
|
|
160653
|
+
doms.html.removeAttr('layer-full');
|
|
160654
|
+
}
|
|
160655
|
+
};
|
|
160656
|
+
|
|
160657
|
+
/** 内置成员 */
|
|
160658
|
+
|
|
160659
|
+
window.layer = layer;
|
|
160660
|
+
|
|
160661
|
+
//获取子iframe的DOM
|
|
160662
|
+
layer.getChildFrame = function(selector, index){
|
|
160663
|
+
index = index || $('.'+doms[4]).attr('times');
|
|
160664
|
+
return $('#'+ doms[0] + index).find('iframe').contents().find(selector);
|
|
160665
|
+
};
|
|
160666
|
+
|
|
160667
|
+
//得到当前iframe层的索引,子iframe时使用
|
|
160668
|
+
layer.getFrameIndex = function(name){
|
|
160669
|
+
return $('#'+ name).parents('.'+doms[4]).attr('times');
|
|
160670
|
+
};
|
|
160671
|
+
|
|
160672
|
+
//iframe层自适应宽高
|
|
160673
|
+
layer.iframeAuto = function(index){
|
|
160674
|
+
if(!index) return;
|
|
160675
|
+
var heg = layer.getChildFrame('html', index).outerHeight();
|
|
160676
|
+
var layero = $('#'+ doms[0] + index);
|
|
160677
|
+
var titHeight = layero.find(doms[1]).outerHeight() || 0;
|
|
160678
|
+
var btnHeight = layero.find('.'+doms[6]).outerHeight() || 0;
|
|
160679
|
+
layero.css({height: heg + titHeight + btnHeight});
|
|
160680
|
+
layero.find('iframe').css({height: heg});
|
|
160681
|
+
};
|
|
160682
|
+
|
|
160683
|
+
//重置iframe url
|
|
160684
|
+
layer.iframeSrc = function(index, url){
|
|
160685
|
+
$('#'+ doms[0] + index).find('iframe').attr('src', url);
|
|
160686
|
+
};
|
|
160687
|
+
|
|
160688
|
+
//设定层的样式
|
|
160689
|
+
layer.style = function(index, options, limit){
|
|
160690
|
+
var layero = $('#'+ doms[0] + index)
|
|
160691
|
+
,contElem = layero.find('.layui-layer-content')
|
|
160692
|
+
,type = layero.attr('type')
|
|
160693
|
+
,titHeight = layero.find(doms[1]).outerHeight() || 0
|
|
160694
|
+
,btnHeight = layero.find('.'+doms[6]).outerHeight() || 0
|
|
160695
|
+
,minLeft = layero.attr('minLeft');
|
|
160696
|
+
|
|
160697
|
+
if(type === ready.type[3] || type === ready.type[4]){
|
|
160698
|
+
return;
|
|
160699
|
+
}
|
|
160700
|
+
|
|
160701
|
+
if(!limit){
|
|
160702
|
+
if(parseFloat(options.width) <= 260){
|
|
160703
|
+
options.width = 260;
|
|
160704
|
+
};
|
|
160705
|
+
|
|
160706
|
+
if(parseFloat(options.height) - titHeight - btnHeight <= 64){
|
|
160707
|
+
options.height = 64 + titHeight + btnHeight;
|
|
160708
|
+
};
|
|
160709
|
+
}
|
|
160710
|
+
|
|
160711
|
+
layero.css(options);
|
|
160712
|
+
btnHeight = layero.find('.'+doms[6]).outerHeight();
|
|
160713
|
+
|
|
160714
|
+
if(type === ready.type[2]){
|
|
160715
|
+
layero.find('iframe').css({
|
|
160716
|
+
height: parseFloat(options.height) - titHeight - btnHeight
|
|
160717
|
+
});
|
|
160718
|
+
} else {
|
|
160719
|
+
contElem.css({
|
|
160720
|
+
height: parseFloat(options.height) - titHeight - btnHeight
|
|
160721
|
+
- parseFloat(contElem.css('padding-top'))
|
|
160722
|
+
- parseFloat(contElem.css('padding-bottom'))
|
|
160723
|
+
})
|
|
160724
|
+
}
|
|
160725
|
+
};
|
|
160726
|
+
|
|
160727
|
+
//最小化
|
|
160728
|
+
layer.min = function(index, options){
|
|
160729
|
+
var layero = $('#'+ doms[0] + index)
|
|
160730
|
+
,titHeight = layero.find(doms[1]).outerHeight() || 0
|
|
160731
|
+
,left = layero.attr('minLeft') || (181*ready.minIndex)+'px'
|
|
160732
|
+
,position = layero.css('position');
|
|
160733
|
+
|
|
160734
|
+
ready.record(layero);
|
|
160735
|
+
|
|
160736
|
+
if(ready.minLeft[0]){
|
|
160737
|
+
left = ready.minLeft[0];
|
|
160738
|
+
ready.minLeft.shift();
|
|
160739
|
+
}
|
|
160740
|
+
|
|
160741
|
+
layero.attr('position', position);
|
|
160742
|
+
|
|
160743
|
+
layer.style(index, {
|
|
160744
|
+
width: 180
|
|
160745
|
+
,height: titHeight
|
|
160746
|
+
,left: left
|
|
160747
|
+
,top: win.height() - titHeight
|
|
160748
|
+
,position: 'fixed'
|
|
160749
|
+
,overflow: 'hidden'
|
|
160750
|
+
}, true);
|
|
160751
|
+
|
|
160752
|
+
layero.find('.layui-layer-min').hide();
|
|
160753
|
+
layero.attr('type') === 'page' && layero.find(doms[4]).hide();
|
|
160754
|
+
ready.rescollbar(index);
|
|
160755
|
+
|
|
160756
|
+
if(!layero.attr('minLeft')){
|
|
160757
|
+
ready.minIndex++;
|
|
160758
|
+
}
|
|
160759
|
+
layero.attr('minLeft', left);
|
|
160760
|
+
};
|
|
160761
|
+
|
|
160762
|
+
//还原
|
|
160763
|
+
layer.restore = function(index){
|
|
160764
|
+
var layero = $('#'+ doms[0] + index), area = layero.attr('area').split(',');
|
|
160765
|
+
var type = layero.attr('type');
|
|
160766
|
+
layer.style(index, {
|
|
160767
|
+
width: parseFloat(area[0]),
|
|
160768
|
+
height: parseFloat(area[1]),
|
|
160769
|
+
top: parseFloat(area[2]),
|
|
160770
|
+
left: parseFloat(area[3]),
|
|
160771
|
+
position: layero.attr('position'),
|
|
160772
|
+
overflow: 'visible'
|
|
160773
|
+
}, true);
|
|
160774
|
+
layero.find('.layui-layer-max').removeClass('layui-layer-maxmin');
|
|
160775
|
+
layero.find('.layui-layer-min').show();
|
|
160776
|
+
layero.attr('type') === 'page' && layero.find(doms[4]).show();
|
|
160777
|
+
ready.rescollbar(index);
|
|
160778
|
+
};
|
|
160779
|
+
|
|
160780
|
+
//全屏
|
|
160781
|
+
layer.full = function(index){
|
|
160782
|
+
var layero = $('#'+ doms[0] + index), timer;
|
|
160783
|
+
ready.record(layero);
|
|
160784
|
+
if(!doms.html.attr('layer-full')){
|
|
160785
|
+
doms.html.css('overflow','hidden').attr('layer-full', index);
|
|
160786
|
+
}
|
|
160787
|
+
clearTimeout(timer);
|
|
160788
|
+
timer = setTimeout(function(){
|
|
160789
|
+
var isfix = layero.css('position') === 'fixed';
|
|
160790
|
+
layer.style(index, {
|
|
160791
|
+
top: isfix ? 0 : win.scrollTop(),
|
|
160792
|
+
left: isfix ? 0 : win.scrollLeft(),
|
|
160793
|
+
width: win.width(),
|
|
160794
|
+
height: win.height()
|
|
160795
|
+
}, true);
|
|
160796
|
+
layero.find('.layui-layer-min').hide();
|
|
160797
|
+
}, 100);
|
|
160798
|
+
};
|
|
160799
|
+
|
|
160800
|
+
//改变title
|
|
160801
|
+
layer.title = function(name, index){
|
|
160802
|
+
var title = $('#'+ doms[0] + (index||layer.index)).find(doms[1]);
|
|
160803
|
+
title.html(name);
|
|
160804
|
+
};
|
|
160805
|
+
|
|
160806
|
+
//关闭layer总方法
|
|
160807
|
+
layer.close = function(index){
|
|
160808
|
+
var layero = $('#'+ doms[0] + index), type = layero.attr('type'), closeAnim = 'layer-anim-close';
|
|
160809
|
+
if(!layero[0]) return;
|
|
160810
|
+
var WRAP = 'layui-layer-wrap', remove = function(){
|
|
160811
|
+
if(type === ready.type[1] && layero.attr('conType') === 'object'){
|
|
160812
|
+
layero.children(':not(.'+ doms[5] +')').remove();
|
|
160813
|
+
var wrap = layero.find('.'+WRAP);
|
|
160814
|
+
for(var i = 0; i < 2; i++){
|
|
160815
|
+
wrap.unwrap();
|
|
160816
|
+
}
|
|
160817
|
+
wrap.css('display', wrap.data('display')).removeClass(WRAP);
|
|
160818
|
+
} else {
|
|
160819
|
+
//低版本IE 回收 iframe
|
|
160820
|
+
if(type === ready.type[2]){
|
|
160821
|
+
try {
|
|
160822
|
+
var iframe = $('#'+doms[4]+index)[0];
|
|
160823
|
+
iframe.contentWindow.document.write('');
|
|
160824
|
+
iframe.contentWindow.close();
|
|
160825
|
+
layero.find('.'+doms[5])[0].removeChild(iframe);
|
|
160826
|
+
} catch(e){}
|
|
160827
|
+
}
|
|
160828
|
+
layero[0].innerHTML = '';
|
|
160829
|
+
layero.remove();
|
|
160830
|
+
}
|
|
160831
|
+
typeof ready.end[index] === 'function' && ready.end[index]();
|
|
160832
|
+
delete ready.end[index];
|
|
160833
|
+
};
|
|
160834
|
+
|
|
160835
|
+
if(layero.data('anim')){
|
|
160836
|
+
layero.addClass(closeAnim);
|
|
160837
|
+
}
|
|
160838
|
+
|
|
160839
|
+
$('#layui-layer-moves, #layui-layer-shade' + index).remove();
|
|
160840
|
+
layer.ie == 6 && ready.reselect();
|
|
160841
|
+
ready.rescollbar(index);
|
|
160842
|
+
|
|
160843
|
+
if(layero.attr('minLeft')){
|
|
160844
|
+
ready.minIndex--;
|
|
160845
|
+
ready.minLeft.push(layero.attr('minLeft'));
|
|
160846
|
+
}
|
|
160847
|
+
setTimeout(function(){
|
|
160848
|
+
remove();
|
|
160849
|
+
}, ((layer.ie && layer.ie < 10) || !layero.data('anim')) ? 0 : 200);
|
|
160850
|
+
};
|
|
160851
|
+
|
|
160852
|
+
//关闭所有层
|
|
160853
|
+
layer.closeAll = function(type){
|
|
160854
|
+
$.each($('.'+doms[0]), function(){
|
|
160855
|
+
var othis = $(this);
|
|
160856
|
+
var is = type ? (othis.attr('type') === type) : 1;
|
|
160857
|
+
is && layer.close(othis.attr('times'));
|
|
160858
|
+
is = null;
|
|
160859
|
+
});
|
|
160860
|
+
};
|
|
160861
|
+
|
|
160862
|
+
/**
|
|
160863
|
+
|
|
160864
|
+
拓展模块,layui开始合并在一起
|
|
160865
|
+
|
|
160866
|
+
*/
|
|
160867
|
+
|
|
160868
|
+
var cache = layer.cache||{}, skin = function(type){
|
|
160869
|
+
return (cache.skin ? (' ' + cache.skin + ' ' + cache.skin + '-'+type) : '');
|
|
160870
|
+
};
|
|
160871
|
+
|
|
160872
|
+
//仿系统prompt
|
|
160873
|
+
layer.prompt = function(options, yes){
|
|
160874
|
+
var style = '';
|
|
160875
|
+
options = options || {};
|
|
160876
|
+
|
|
160877
|
+
if(typeof options === 'function') yes = options;
|
|
160878
|
+
|
|
160879
|
+
if(options.area){
|
|
160880
|
+
var area = options.area;
|
|
160881
|
+
style = 'style="width: '+ area[0] +'; height: '+ area[1] + ';"';
|
|
160882
|
+
delete options.area;
|
|
160883
|
+
}
|
|
160884
|
+
var prompt, content = options.formType == 2 ? '<textarea class="layui-layer-input"' + style +'>' + (options.value||'') +'</textarea>' : function(){
|
|
160885
|
+
return '<input type="'+ (options.formType == 1 ? 'password' : 'text') +'" class="layui-layer-input" value="'+ (options.value||'') +'">';
|
|
160886
|
+
}();
|
|
160887
|
+
|
|
160888
|
+
return layer.open($.extend({
|
|
160889
|
+
type: 1
|
|
160890
|
+
,btn: ['确定','取消']
|
|
160891
|
+
,content: content
|
|
160892
|
+
,skin: 'layui-layer-prompt' + skin('prompt')
|
|
160893
|
+
,maxWidth: win.width()
|
|
160894
|
+
,success: function(layero){
|
|
160895
|
+
prompt = layero.find('.layui-layer-input');
|
|
160896
|
+
prompt.focus();
|
|
160897
|
+
}
|
|
160898
|
+
,resize: false
|
|
160899
|
+
,yes: function(index){
|
|
160900
|
+
var value = prompt.val();
|
|
160901
|
+
if(value === ''){
|
|
160902
|
+
prompt.focus();
|
|
160903
|
+
} else if(value.length > (options.maxlength||500)) {
|
|
160904
|
+
layer.tips('最多输入'+ (options.maxlength || 500) +'个字数', prompt, {tips: 1});
|
|
160905
|
+
} else {
|
|
160906
|
+
yes && yes(value, index, prompt);
|
|
160907
|
+
}
|
|
160908
|
+
}
|
|
160909
|
+
}, options));
|
|
160910
|
+
};
|
|
160911
|
+
|
|
160912
|
+
//tab层
|
|
160913
|
+
layer.tab = function(options){
|
|
160914
|
+
options = options || {};
|
|
160915
|
+
var tab = options.tab || {};
|
|
160916
|
+
return layer.open($.extend({
|
|
160917
|
+
type: 1,
|
|
160918
|
+
skin: 'layui-layer-tab' + skin('tab'),
|
|
160919
|
+
resize: false,
|
|
160920
|
+
title: function(){
|
|
160921
|
+
var len = tab.length, ii = 1, str = '';
|
|
160922
|
+
if(len > 0){
|
|
160923
|
+
str = '<span class="layui-layer-tabnow">'+ tab[0].title +'</span>';
|
|
160924
|
+
for(; ii < len; ii++){
|
|
160925
|
+
str += '<span>'+ tab[ii].title +'</span>';
|
|
160926
|
+
}
|
|
160927
|
+
}
|
|
160928
|
+
return str;
|
|
160929
|
+
}(),
|
|
160930
|
+
content: '<ul class="layui-layer-tabmain">'+ function(){
|
|
160931
|
+
var len = tab.length, ii = 1, str = '';
|
|
160932
|
+
if(len > 0){
|
|
160933
|
+
str = '<li class="layui-layer-tabli xubox_tab_layer">'+ (tab[0].content || 'no content') +'</li>';
|
|
160934
|
+
for(; ii < len; ii++){
|
|
160935
|
+
str += '<li class="layui-layer-tabli">'+ (tab[ii].content || 'no content') +'</li>';
|
|
160936
|
+
}
|
|
160937
|
+
}
|
|
160938
|
+
return str;
|
|
160939
|
+
}() +'</ul>',
|
|
160940
|
+
success: function(layero){
|
|
160941
|
+
var btn = layero.find('.layui-layer-title').children();
|
|
160942
|
+
var main = layero.find('.layui-layer-tabmain').children();
|
|
160943
|
+
btn.on('mousedown', function(e){
|
|
160944
|
+
e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true;
|
|
160945
|
+
var othis = $(this), index = othis.index();
|
|
160946
|
+
othis.addClass('layui-layer-tabnow').siblings().removeClass('layui-layer-tabnow');
|
|
160947
|
+
main.eq(index).show().siblings().hide();
|
|
160948
|
+
typeof options.change === 'function' && options.change(index);
|
|
160949
|
+
});
|
|
160950
|
+
}
|
|
160951
|
+
}, options));
|
|
160952
|
+
};
|
|
160953
|
+
|
|
160954
|
+
//相册层
|
|
160955
|
+
layer.photos = function(options, loop, key){
|
|
160956
|
+
var dict = {};
|
|
160957
|
+
options = options || {};
|
|
160958
|
+
if(!options.photos) return;
|
|
160959
|
+
var type = options.photos.constructor === Object;
|
|
160960
|
+
var photos = type ? options.photos : {}, data = photos.data || [];
|
|
160961
|
+
var start = photos.start || 0;
|
|
160962
|
+
dict.imgIndex = (start|0) + 1;
|
|
160963
|
+
|
|
160964
|
+
options.img = options.img || 'img';
|
|
160965
|
+
|
|
160966
|
+
if(!type){ //页面直接获取
|
|
160967
|
+
var parent = $(options.photos), pushData = function(){
|
|
160968
|
+
data = [];
|
|
160969
|
+
parent.find(options.img).each(function(index){
|
|
160970
|
+
var othis = $(this);
|
|
160971
|
+
othis.attr('layer-index', index);
|
|
160972
|
+
data.push({
|
|
160973
|
+
alt: othis.attr('alt'),
|
|
160974
|
+
pid: othis.attr('layer-pid'),
|
|
160975
|
+
src: othis.attr('layer-src') || othis.attr('src'),
|
|
160976
|
+
thumb: othis.attr('src')
|
|
160977
|
+
});
|
|
160978
|
+
})
|
|
160979
|
+
};
|
|
160980
|
+
|
|
160981
|
+
pushData();
|
|
160982
|
+
|
|
160983
|
+
if (data.length === 0) return;
|
|
160984
|
+
|
|
160985
|
+
loop || parent.on('click', options.img, function(){
|
|
160986
|
+
var othis = $(this), index = othis.attr('layer-index');
|
|
160987
|
+
layer.photos($.extend(options, {
|
|
160988
|
+
photos: {
|
|
160989
|
+
start: index,
|
|
160990
|
+
data: data,
|
|
160991
|
+
tab: options.tab
|
|
160992
|
+
},
|
|
160993
|
+
full: options.full
|
|
160994
|
+
}), true);
|
|
160995
|
+
pushData();
|
|
160996
|
+
})
|
|
160997
|
+
|
|
160998
|
+
//不直接弹出
|
|
160999
|
+
if(!loop) return;
|
|
161000
|
+
|
|
161001
|
+
} else if (data.length === 0){
|
|
161002
|
+
return layer.msg('没有图片');
|
|
161003
|
+
}
|
|
161004
|
+
|
|
161005
|
+
//上一张
|
|
161006
|
+
dict.imgprev = function(key){
|
|
161007
|
+
dict.imgIndex--;
|
|
161008
|
+
if(dict.imgIndex < 1){
|
|
161009
|
+
dict.imgIndex = data.length;
|
|
161010
|
+
}
|
|
161011
|
+
dict.tabimg(key);
|
|
161012
|
+
};
|
|
161013
|
+
|
|
161014
|
+
//下一张
|
|
161015
|
+
dict.imgnext = function(key,errorMsg){
|
|
161016
|
+
dict.imgIndex++;
|
|
161017
|
+
if(dict.imgIndex > data.length){
|
|
161018
|
+
dict.imgIndex = 1;
|
|
161019
|
+
if (errorMsg) {return};
|
|
161020
|
+
}
|
|
161021
|
+
dict.tabimg(key)
|
|
161022
|
+
};
|
|
161023
|
+
|
|
161024
|
+
//方向键
|
|
161025
|
+
dict.keyup = function(event){
|
|
161026
|
+
if(!dict.end){
|
|
161027
|
+
var code = event.keyCode;
|
|
161028
|
+
event.preventDefault();
|
|
161029
|
+
if(code === 37){
|
|
161030
|
+
dict.imgprev(true);
|
|
161031
|
+
} else if(code === 39) {
|
|
161032
|
+
dict.imgnext(true);
|
|
161033
|
+
} else if(code === 27) {
|
|
161034
|
+
layer.close(dict.index);
|
|
161035
|
+
}
|
|
161036
|
+
}
|
|
161037
|
+
}
|
|
161038
|
+
|
|
161039
|
+
//切换
|
|
161040
|
+
dict.tabimg = function(key){
|
|
161041
|
+
if(data.length <= 1) return;
|
|
161042
|
+
photos.start = dict.imgIndex - 1;
|
|
161043
|
+
layer.close(dict.index);
|
|
161044
|
+
layer.photos(options, true, key);
|
|
161045
|
+
}
|
|
161046
|
+
|
|
161047
|
+
//一些动作
|
|
161048
|
+
dict.event = function(){
|
|
161049
|
+
dict.bigimg.hover(function(){
|
|
161050
|
+
dict.imgsee.show();
|
|
161051
|
+
}, function(){
|
|
161052
|
+
dict.imgsee.hide();
|
|
161053
|
+
});
|
|
161054
|
+
|
|
161055
|
+
dict.bigimg.find('.layui-layer-imgprev').on('click', function(event){
|
|
161056
|
+
event.preventDefault();
|
|
161057
|
+
dict.imgprev();
|
|
161058
|
+
});
|
|
161059
|
+
|
|
161060
|
+
dict.bigimg.find('.layui-layer-imgnext').on('click', function(event){
|
|
161061
|
+
event.preventDefault();
|
|
161062
|
+
dict.imgnext();
|
|
161063
|
+
});
|
|
161064
|
+
|
|
161065
|
+
$(document).on('keyup', dict.keyup);
|
|
161066
|
+
};
|
|
161067
|
+
|
|
161068
|
+
//图片预加载
|
|
161069
|
+
function loadImage(url, callback, error) {
|
|
161070
|
+
var img = new Image();
|
|
161071
|
+
img.src = url;
|
|
161072
|
+
if(img.complete){
|
|
161073
|
+
return callback(img);
|
|
161074
|
+
}
|
|
161075
|
+
img.onload = function(){
|
|
161076
|
+
img.onload = null;
|
|
161077
|
+
callback(img);
|
|
161078
|
+
};
|
|
161079
|
+
img.onerror = function(e){
|
|
161080
|
+
img.onerror = null;
|
|
161081
|
+
error(e);
|
|
161082
|
+
};
|
|
161083
|
+
};
|
|
161084
|
+
|
|
161085
|
+
dict.loadi = layer.load(1, {
|
|
161086
|
+
shade: 'shade' in options ? false : 0.9,
|
|
161087
|
+
scrollbar: false
|
|
161088
|
+
});
|
|
161089
|
+
loadImage(data[start].src, function(img){
|
|
161090
|
+
layer.close(dict.loadi);
|
|
161091
|
+
dict.index = layer.open($.extend({
|
|
161092
|
+
type: 1,
|
|
161093
|
+
area: function(){
|
|
161094
|
+
var imgarea = [img.width, img.height];
|
|
161095
|
+
var winarea = [$(window).width() - 100, $(window).height() - 100];
|
|
161096
|
+
|
|
161097
|
+
//如果 实际图片的宽或者高比 屏幕大(那么进行缩放)
|
|
161098
|
+
if(!options.full && (imgarea[0]>winarea[0]||imgarea[1]>winarea[1])){
|
|
161099
|
+
var wh = [imgarea[0]/winarea[0],imgarea[1]/winarea[1]];//取宽度缩放比例、高度缩放比例
|
|
161100
|
+
if(wh[0] > wh[1]){//取缩放比例最大的进行缩放
|
|
161101
|
+
imgarea[0] = imgarea[0]/wh[0];
|
|
161102
|
+
imgarea[1] = imgarea[1]/wh[0];
|
|
161103
|
+
} else if(wh[0] < wh[1]){
|
|
161104
|
+
imgarea[0] = imgarea[0]/wh[1];
|
|
161105
|
+
imgarea[1] = imgarea[1]/wh[1];
|
|
161106
|
+
}
|
|
161107
|
+
}
|
|
161108
|
+
|
|
161109
|
+
return [imgarea[0]+'px', imgarea[1]+'px'];
|
|
161110
|
+
}(),
|
|
161111
|
+
title: false,
|
|
161112
|
+
shade: 0.9,
|
|
161113
|
+
shadeClose: true,
|
|
161114
|
+
closeBtn: false,
|
|
161115
|
+
move: '.layui-layer-phimg img',
|
|
161116
|
+
moveType: 1,
|
|
161117
|
+
scrollbar: false,
|
|
161118
|
+
moveOut: true,
|
|
161119
|
+
anim: Math.random()*5|0,
|
|
161120
|
+
skin: 'layui-layer-photos' + skin('photos'),
|
|
161121
|
+
content: '<div class="layui-layer-phimg">'
|
|
161122
|
+
+'<img src="'+ data[start].src +'" alt="'+ (data[start].alt||'') +'" layer-pid="'+ data[start].pid +'">'
|
|
161123
|
+
+'<div class="layui-layer-imgsee">'
|
|
161124
|
+
+(data.length > 1 ? '<span class="layui-layer-imguide"><a href="javascript:;" class="layui-layer-iconext layui-layer-imgprev"></a><a href="javascript:;" class="layui-layer-iconext layui-layer-imgnext"></a></span>' : '')
|
|
161125
|
+
+'<div class="layui-layer-imgbar" style="display:'+ (key ? 'block' : '') +'"><span class="layui-layer-imgtit"><a href="javascript:;">'+ (data[start].alt||'') +'</a><em>'+ dict.imgIndex +'/'+ data.length +'</em></span></div>'
|
|
161126
|
+
+'</div>'
|
|
161127
|
+
+'</div>',
|
|
161128
|
+
success: function(layero, index){
|
|
161129
|
+
dict.bigimg = layero.find('.layui-layer-phimg');
|
|
161130
|
+
dict.imgsee = layero.find('.layui-layer-imguide,.layui-layer-imgbar');
|
|
161131
|
+
dict.event(layero);
|
|
161132
|
+
options.tab && options.tab(data[start], layero);
|
|
161133
|
+
}, end: function(){
|
|
161134
|
+
dict.end = true;
|
|
161135
|
+
$(document).off('keyup', dict.keyup);
|
|
161136
|
+
}
|
|
161137
|
+
}, options));
|
|
161138
|
+
}, function(){
|
|
161139
|
+
layer.close(dict.loadi);
|
|
161140
|
+
layer.msg('当前图片地址异常<br>是否继续查看下一张?', {
|
|
161141
|
+
time: 30000,
|
|
161142
|
+
btn: ['下一张', '不看了'],
|
|
161143
|
+
yes: function(){
|
|
161144
|
+
data.length > 1 && dict.imgnext(true,true);
|
|
161145
|
+
}
|
|
161146
|
+
});
|
|
161147
|
+
});
|
|
161148
|
+
};
|
|
161149
|
+
|
|
161150
|
+
//主入口
|
|
161151
|
+
ready.run = function(_$){
|
|
161152
|
+
$ = _$;
|
|
161153
|
+
win = $(window);
|
|
161154
|
+
doms.html = $('html');
|
|
161155
|
+
layer.open = function(deliver){
|
|
161156
|
+
var o = new Class(deliver);
|
|
161157
|
+
return o.index;
|
|
161158
|
+
};
|
|
161159
|
+
};
|
|
161160
|
+
ready.run(jQuery);
|
|
161161
|
+
//加载方式
|
|
161169
161162
|
module.exports = layer;
|
|
161170
161163
|
|
|
161171
161164
|
/***/ }),
|