Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

156 lines
5.9 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * VERSION: 0.6.2
  3. * DATE: 2018-05-30
  4. * UPDATES AND DOCS AT: http://greensock.com
  5. *
  6. * @license Copyright (c) 2008-2019, GreenSock. All rights reserved.
  7. * This work is subject to the terms at http://greensock.com/standard-license or for
  8. * Club GreenSock members, the software agreement that was issued with your membership.
  9. *
  10. * @author: Jack Doyle, jack@greensock.com
  11. */
  12. /* eslint-disable */
  13. import { _gsScope } from "./TweenLite.js";
  14. var _getText = function(e) {
  15. var type = e.nodeType,
  16. result = "";
  17. if (type === 1 || type === 9 || type === 11) {
  18. if (typeof(e.textContent) === "string") {
  19. return e.textContent;
  20. } else {
  21. for ( e = e.firstChild; e; e = e.nextSibling ) {
  22. result += _getText(e);
  23. }
  24. }
  25. } else if (type === 3 || type === 4) {
  26. return e.nodeValue;
  27. }
  28. return result;
  29. },
  30. _emoji = "[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2694-\u2697]|\uD83E[\uDD10-\uDD5D]|[\uD800-\uDBFF][\uDC00-\uDFFF]",
  31. _emojiExp = new RegExp(_emoji),
  32. _emojiAndCharsExp = new RegExp(_emoji + "|.", "g"),
  33. _emojiSafeSplit = function(text, delimiter) {
  34. return ((delimiter === "" || !delimiter) && _emojiExp.test(text)) ? text.match(_emojiAndCharsExp) : text.split(delimiter || "");
  35. },
  36. /* //previous emoji-related splitting. New method above is faster and more concise.
  37. _emojiStart = 0xD800,
  38. _emojiEnd = 0xDBFF,
  39. _emojiLowStart = 0xDC00,
  40. _emojiRegionStart = 0x1F1E6,
  41. _emojiRegionEnd = 0x1F1FF,
  42. _emojiModStart = 0x1f3fb,
  43. _emojiModEnd = 0x1f3ff,
  44. _emojiPairCode = function(s) {
  45. return ((s.charCodeAt(0) - _emojiStart) << 10) + (s.charCodeAt(1) - _emojiLowStart) + 0x10000;
  46. },
  47. _emojiSafeSplit = function(text, delimiter) { //like calling String.split(delimiter) except that it keeps emoji characters together.
  48. if (delimiter !== "") {
  49. return text.split(delimiter);
  50. }
  51. var l = text.length,
  52. a = [],
  53. character, i, emojiPair1, emojiPair2, j;
  54. for (i = 0; i < l; i++) {
  55. character = text.charAt(i);
  56. if ((character.charCodeAt(0) >= _emojiStart && character.charCodeAt(0) <= _emojiEnd) || (text.charCodeAt(i+1) >= 0xFE00 && text.charCodeAt(i+1) <= 0xFE0F)) { //special emoji characters use 2 or 4 unicode characters that we must keep together.
  57. emojiPair1 = _emojiPairCode(text.substr(i, 2));
  58. emojiPair2 = _emojiPairCode(text.substr(i + 2, 2));
  59. j = ((emojiPair1 >= _emojiRegionStart && emojiPair1 <= _emojiRegionEnd && emojiPair2 >= _emojiRegionStart && emojiPair2 <= _emojiRegionEnd) || (emojiPair2 >= _emojiModStart && emojiPair2 <= _emojiModEnd)) ? 4 : 2;
  60. a.push(text.substr(i, j));
  61. i += j - 1;
  62. } else {
  63. a.push(character);
  64. }
  65. }
  66. return a;
  67. },
  68. */
  69. TextPlugin = _gsScope._gsDefine.plugin({
  70. propName: "text",
  71. API: 2,
  72. version:"0.6.2",
  73. //called when the tween renders for the first time. This is where initial values should be recorded and any setup routines should run.
  74. init: function(target, value, tween, index) {
  75. var i = target.nodeName.toUpperCase(),
  76. shrt;
  77. if (typeof(value) === "function") {
  78. value = value(index, target);
  79. }
  80. this._svg = (target.getBBox && (i === "TEXT" || i === "TSPAN"));
  81. if (!("innerHTML" in target) && !this._svg) {
  82. return false;
  83. }
  84. this._target = target;
  85. if (typeof(value) !== "object") {
  86. value = {value:value};
  87. }
  88. if (value.value === undefined) {
  89. this._text = this._original = [""];
  90. return true;
  91. }
  92. this._delimiter = value.delimiter || "";
  93. this._original = _emojiSafeSplit(_getText(target).replace(/\s+/g, " "), this._delimiter);
  94. this._text = _emojiSafeSplit(value.value.replace(/\s+/g, " "), this._delimiter);
  95. this._runBackwards = (tween.vars.runBackwards === true);
  96. if (this._runBackwards) {
  97. i = this._original;
  98. this._original = this._text;
  99. this._text = i;
  100. }
  101. if (typeof(value.newClass) === "string") {
  102. this._newClass = value.newClass;
  103. this._hasClass = true;
  104. }
  105. if (typeof(value.oldClass) === "string") {
  106. this._oldClass = value.oldClass;
  107. this._hasClass = true;
  108. }
  109. i = this._original.length - this._text.length;
  110. shrt = (i < 0) ? this._original : this._text;
  111. this._fillChar = value.fillChar || (value.padSpace ? "&nbsp;" : "");
  112. if (i < 0) {
  113. i = -i;
  114. }
  115. while (--i > -1) {
  116. shrt.push(this._fillChar);
  117. }
  118. return true;
  119. },
  120. //called each time the values should be updated, and the ratio gets passed as the only parameter (typically it's a value between 0 and 1, but it can exceed those when using an ease like Elastic.easeOut or Back.easeOut, etc.)
  121. set: function(ratio) {
  122. if (ratio > 1) {
  123. ratio = 1;
  124. } else if (ratio < 0) {
  125. ratio = 0;
  126. }
  127. if (this._runBackwards) {
  128. ratio = 1 - ratio;
  129. }
  130. var l = this._text.length,
  131. i = (ratio * l + 0.5) | 0,
  132. applyNew, applyOld, str;
  133. if (this._hasClass) {
  134. applyNew = (this._newClass && i !== 0);
  135. applyOld = (this._oldClass && i !== l);
  136. str = (applyNew ? "<span class='" + this._newClass + "'>" : "") + this._text.slice(0, i).join(this._delimiter) + (applyNew ? "</span>" : "") + (applyOld ? "<span class='" + this._oldClass + "'>" : "") + this._delimiter + this._original.slice(i).join(this._delimiter) + (applyOld ? "</span>" : "");
  137. } else {
  138. str = this._text.slice(0, i).join(this._delimiter) + this._delimiter + this._original.slice(i).join(this._delimiter);
  139. }
  140. if (this._svg) { //SVG text elements don't have an "innerHTML" in Microsoft browsers.
  141. this._target.textContent = str;
  142. } else {
  143. this._target.innerHTML = (this._fillChar === "&nbsp;" && str.indexOf(" ") !== -1) ? str.split(" ").join("&nbsp;&nbsp;") : str;
  144. }
  145. }
  146. }),
  147. p = TextPlugin.prototype;
  148. p._newClass = p._oldClass = p._delimiter = "";
  149. export { TextPlugin, TextPlugin as default };