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.

434 lines
17 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
  19. </span> * @class Ext.Element
  20. */
  21. <span id='Ext-Element-static-property-VISIBILITY'>/**
  22. </span> * Visibility mode constant for use with {@link #setVisibilityMode}. Use visibility to hide element
  23. * @static
  24. * @type Number
  25. */
  26. Ext.Element.VISIBILITY = 1;
  27. <span id='Ext-Element-static-property-DISPLAY'>/**
  28. </span> * Visibility mode constant for use with {@link #setVisibilityMode}. Use display to hide element
  29. * @static
  30. * @type Number
  31. */
  32. Ext.Element.DISPLAY = 2;
  33. <span id='Ext-Element-static-property-OFFSETS'>/**
  34. </span> * Visibility mode constant for use with {@link #setVisibilityMode}. Use offsets (x and y positioning offscreen)
  35. * to hide element.
  36. * @static
  37. * @type Number
  38. */
  39. Ext.Element.OFFSETS = 3;
  40. Ext.Element.ASCLASS = 4;
  41. <span id='Ext-Element-static-property-visibilityCls'>/**
  42. </span> * Defaults to 'x-hide-nosize'
  43. * @static
  44. * @type String
  45. */
  46. Ext.Element.visibilityCls = 'x-hide-nosize';
  47. Ext.Element.addMethods(function(){
  48. var El = Ext.Element,
  49. OPACITY = &quot;opacity&quot;,
  50. VISIBILITY = &quot;visibility&quot;,
  51. DISPLAY = &quot;display&quot;,
  52. HIDDEN = &quot;hidden&quot;,
  53. OFFSETS = &quot;offsets&quot;,
  54. ASCLASS = &quot;asclass&quot;,
  55. NONE = &quot;none&quot;,
  56. NOSIZE = 'nosize',
  57. ORIGINALDISPLAY = 'originalDisplay',
  58. VISMODE = 'visibilityMode',
  59. ISVISIBLE = 'isVisible',
  60. data = El.data,
  61. getDisplay = function(dom){
  62. var d = data(dom, ORIGINALDISPLAY);
  63. if(d === undefined){
  64. data(dom, ORIGINALDISPLAY, d = '');
  65. }
  66. return d;
  67. },
  68. getVisMode = function(dom){
  69. var m = data(dom, VISMODE);
  70. if(m === undefined){
  71. data(dom, VISMODE, m = 1);
  72. }
  73. return m;
  74. };
  75. return {
  76. <span id='Ext-Element-property-originalDisplay'> /**
  77. </span> * The element's default display mode (defaults to &quot;&quot;)
  78. * @type String
  79. */
  80. originalDisplay : &quot;&quot;,
  81. visibilityMode : 1,
  82. <span id='Ext-Element-method-setVisibilityMode'> /**
  83. </span> * Sets the element's visibility mode. When setVisible() is called it
  84. * will use this to determine whether to set the visibility or the display property.
  85. * @param {Number} visMode Ext.Element.VISIBILITY or Ext.Element.DISPLAY
  86. * @return {Ext.Element} this
  87. */
  88. setVisibilityMode : function(visMode){
  89. data(this.dom, VISMODE, visMode);
  90. return this;
  91. },
  92. <span id='Ext-Element-method-animate'> /**
  93. </span> * Perform custom animation on this element.
  94. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  95. * &lt;li&gt;&lt;u&gt;Animation Properties&lt;/u&gt;&lt;/li&gt;
  96. *
  97. * &lt;p&gt;The Animation Control Object enables gradual transitions for any member of an
  98. * element's style object that takes a numeric value including but not limited to
  99. * these properties:&lt;/p&gt;&lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  100. * &lt;li&gt;&lt;tt&gt;bottom, top, left, right&lt;/tt&gt;&lt;/li&gt;
  101. * &lt;li&gt;&lt;tt&gt;height, width&lt;/tt&gt;&lt;/li&gt;
  102. * &lt;li&gt;&lt;tt&gt;margin, padding&lt;/tt&gt;&lt;/li&gt;
  103. * &lt;li&gt;&lt;tt&gt;borderWidth&lt;/tt&gt;&lt;/li&gt;
  104. * &lt;li&gt;&lt;tt&gt;opacity&lt;/tt&gt;&lt;/li&gt;
  105. * &lt;li&gt;&lt;tt&gt;fontSize&lt;/tt&gt;&lt;/li&gt;
  106. * &lt;li&gt;&lt;tt&gt;lineHeight&lt;/tt&gt;&lt;/li&gt;
  107. * &lt;/ul&gt;&lt;/div&gt;
  108. *
  109. *
  110. * &lt;li&gt;&lt;u&gt;Animation Property Attributes&lt;/u&gt;&lt;/li&gt;
  111. *
  112. * &lt;p&gt;Each Animation Property is a config object with optional properties:&lt;/p&gt;
  113. * &lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  114. * &lt;li&gt;&lt;tt&gt;by&lt;/tt&gt;* : relative change - start at current value, change by this value&lt;/li&gt;
  115. * &lt;li&gt;&lt;tt&gt;from&lt;/tt&gt; : ignore current value, start from this value&lt;/li&gt;
  116. * &lt;li&gt;&lt;tt&gt;to&lt;/tt&gt;* : start at current value, go to this value&lt;/li&gt;
  117. * &lt;li&gt;&lt;tt&gt;unit&lt;/tt&gt; : any allowable unit specification&lt;/li&gt;
  118. * &lt;p&gt;* do not specify both &lt;tt&gt;to&lt;/tt&gt; and &lt;tt&gt;by&lt;/tt&gt; for an animation property&lt;/p&gt;
  119. * &lt;/ul&gt;&lt;/div&gt;
  120. *
  121. * &lt;li&gt;&lt;u&gt;Animation Types&lt;/u&gt;&lt;/li&gt;
  122. *
  123. * &lt;p&gt;The supported animation types:&lt;/p&gt;&lt;div&gt;&lt;ul class=&quot;mdetail-params&quot;&gt;
  124. * &lt;li&gt;&lt;tt&gt;'run'&lt;/tt&gt; : Default
  125. * &lt;pre&gt;&lt;code&gt;
  126. var el = Ext.get('complexEl');
  127. el.animate(
  128. // animation control object
  129. {
  130. borderWidth: {to: 3, from: 0},
  131. opacity: {to: .3, from: 1},
  132. height: {to: 50, from: el.getHeight()},
  133. width: {to: 300, from: el.getWidth()},
  134. top : {by: - 100, unit: 'px'},
  135. },
  136. 0.35, // animation duration
  137. null, // callback
  138. 'easeOut', // easing method
  139. 'run' // animation type ('run','color','motion','scroll')
  140. );
  141. * &lt;/code&gt;&lt;/pre&gt;
  142. * &lt;/li&gt;
  143. * &lt;li&gt;&lt;tt&gt;'color'&lt;/tt&gt;
  144. * &lt;p&gt;Animates transition of background, text, or border colors.&lt;/p&gt;
  145. * &lt;pre&gt;&lt;code&gt;
  146. el.animate(
  147. // animation control object
  148. {
  149. color: { to: '#06e' },
  150. backgroundColor: { to: '#e06' }
  151. },
  152. 0.35, // animation duration
  153. null, // callback
  154. 'easeOut', // easing method
  155. 'color' // animation type ('run','color','motion','scroll')
  156. );
  157. * &lt;/code&gt;&lt;/pre&gt;
  158. * &lt;/li&gt;
  159. *
  160. * &lt;li&gt;&lt;tt&gt;'motion'&lt;/tt&gt;
  161. * &lt;p&gt;Animates the motion of an element to/from specific points using optional bezier
  162. * way points during transit.&lt;/p&gt;
  163. * &lt;pre&gt;&lt;code&gt;
  164. el.animate(
  165. // animation control object
  166. {
  167. borderWidth: {to: 3, from: 0},
  168. opacity: {to: .3, from: 1},
  169. height: {to: 50, from: el.getHeight()},
  170. width: {to: 300, from: el.getWidth()},
  171. top : {by: - 100, unit: 'px'},
  172. points: {
  173. to: [50, 100], // go to this point
  174. control: [ // optional bezier way points
  175. [ 600, 800],
  176. [-100, 200]
  177. ]
  178. }
  179. },
  180. 3000, // animation duration (milliseconds!)
  181. null, // callback
  182. 'easeOut', // easing method
  183. 'motion' // animation type ('run','color','motion','scroll')
  184. );
  185. * &lt;/code&gt;&lt;/pre&gt;
  186. * &lt;/li&gt;
  187. * &lt;li&gt;&lt;tt&gt;'scroll'&lt;/tt&gt;
  188. * &lt;p&gt;Animate horizontal or vertical scrolling of an overflowing page element.&lt;/p&gt;
  189. * &lt;pre&gt;&lt;code&gt;
  190. el.animate(
  191. // animation control object
  192. {
  193. scroll: {to: [400, 300]}
  194. },
  195. 0.35, // animation duration
  196. null, // callback
  197. 'easeOut', // easing method
  198. 'scroll' // animation type ('run','color','motion','scroll')
  199. );
  200. * &lt;/code&gt;&lt;/pre&gt;
  201. * &lt;/li&gt;
  202. * &lt;/ul&gt;&lt;/div&gt;
  203. *
  204. * &lt;/ul&gt;&lt;/div&gt;
  205. *
  206. * @param {Object} args The animation control args
  207. * @param {Float} duration (optional) How long the animation lasts in seconds (defaults to &lt;tt&gt;.35&lt;/tt&gt;)
  208. * @param {Function} onComplete (optional) Function to call when animation completes
  209. * @param {String} easing (optional) {@link Ext.Fx#easing} method to use (defaults to &lt;tt&gt;'easeOut'&lt;/tt&gt;)
  210. * @param {String} animType (optional) &lt;tt&gt;'run'&lt;/tt&gt; is the default. Can also be &lt;tt&gt;'color'&lt;/tt&gt;,
  211. * &lt;tt&gt;'motion'&lt;/tt&gt;, or &lt;tt&gt;'scroll'&lt;/tt&gt;
  212. * @return {Ext.Element} this
  213. */
  214. animate : function(args, duration, onComplete, easing, animType){
  215. this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
  216. return this;
  217. },
  218. /*
  219. * @private Internal animation call
  220. */
  221. anim : function(args, opt, animType, defaultDur, defaultEase, cb){
  222. animType = animType || 'run';
  223. opt = opt || {};
  224. var me = this,
  225. anim = Ext.lib.Anim[animType](
  226. me.dom,
  227. args,
  228. (opt.duration || defaultDur) || .35,
  229. (opt.easing || defaultEase) || 'easeOut',
  230. function(){
  231. if(cb) cb.call(me);
  232. if(opt.callback) opt.callback.call(opt.scope || me, me, opt);
  233. },
  234. me
  235. );
  236. opt.anim = anim;
  237. return anim;
  238. },
  239. // private legacy anim prep
  240. preanim : function(a, i){
  241. return !a[i] ? false : (typeof a[i] == 'object' ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
  242. },
  243. <span id='Ext-Element-method-isVisible'> /**
  244. </span> * Checks whether the element is currently visible using both visibility and display properties.
  245. * @return {Boolean} True if the element is currently visible, else false
  246. */
  247. isVisible : function() {
  248. var me = this,
  249. dom = me.dom,
  250. visible = data(dom, ISVISIBLE);
  251. if(typeof visible == 'boolean'){ //return the cached value if registered
  252. return visible;
  253. }
  254. //Determine the current state based on display states
  255. visible = !me.isStyle(VISIBILITY, HIDDEN) &amp;&amp;
  256. !me.isStyle(DISPLAY, NONE) &amp;&amp;
  257. !((getVisMode(dom) == El.ASCLASS) &amp;&amp; me.hasClass(me.visibilityCls || El.visibilityCls));
  258. data(dom, ISVISIBLE, visible);
  259. return visible;
  260. },
  261. <span id='Ext-Element-method-setVisible'> /**
  262. </span> * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use
  263. * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.
  264. * @param {Boolean} visible Whether the element is visible
  265. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  266. * @return {Ext.Element} this
  267. */
  268. setVisible : function(visible, animate){
  269. var me = this, isDisplay, isVisibility, isOffsets, isNosize,
  270. dom = me.dom,
  271. visMode = getVisMode(dom);
  272. // hideMode string override
  273. if (typeof animate == 'string'){
  274. switch (animate) {
  275. case DISPLAY:
  276. visMode = El.DISPLAY;
  277. break;
  278. case VISIBILITY:
  279. visMode = El.VISIBILITY;
  280. break;
  281. case OFFSETS:
  282. visMode = El.OFFSETS;
  283. break;
  284. case NOSIZE:
  285. case ASCLASS:
  286. visMode = El.ASCLASS;
  287. break;
  288. }
  289. me.setVisibilityMode(visMode);
  290. animate = false;
  291. }
  292. if (!animate || !me.anim) {
  293. if(visMode == El.ASCLASS ){
  294. me[visible?'removeClass':'addClass'](me.visibilityCls || El.visibilityCls);
  295. } else if (visMode == El.DISPLAY){
  296. return me.setDisplayed(visible);
  297. } else if (visMode == El.OFFSETS){
  298. if (!visible){
  299. me.hideModeStyles = {
  300. position: me.getStyle('position'),
  301. top: me.getStyle('top'),
  302. left: me.getStyle('left')
  303. };
  304. me.applyStyles({position: 'absolute', top: '-10000px', left: '-10000px'});
  305. } else {
  306. me.applyStyles(me.hideModeStyles || {position: '', top: '', left: ''});
  307. delete me.hideModeStyles;
  308. }
  309. }else{
  310. me.fixDisplay();
  311. dom.style.visibility = visible ? &quot;visible&quot; : HIDDEN;
  312. }
  313. }else{
  314. // closure for composites
  315. if(visible){
  316. me.setOpacity(.01);
  317. me.setVisible(true);
  318. }
  319. me.anim({opacity: { to: (visible?1:0) }},
  320. me.preanim(arguments, 1),
  321. null,
  322. .35,
  323. 'easeIn',
  324. function(){
  325. visible || me.setVisible(false).setOpacity(1);
  326. });
  327. }
  328. data(dom, ISVISIBLE, visible); //set logical visibility state
  329. return me;
  330. },
  331. <span id='Ext-Element-method-hasMetrics'> /**
  332. </span> * @private
  333. * Determine if the Element has a relevant height and width available based
  334. * upon current logical visibility state
  335. */
  336. hasMetrics : function(){
  337. var dom = this.dom;
  338. return this.isVisible() || (getVisMode(dom) == El.VISIBILITY);
  339. },
  340. <span id='Ext-Element-method-toggle'> /**
  341. </span> * Toggles the element's visibility or display, depending on visibility mode.
  342. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  343. * @return {Ext.Element} this
  344. */
  345. toggle : function(animate){
  346. var me = this;
  347. me.setVisible(!me.isVisible(), me.preanim(arguments, 0));
  348. return me;
  349. },
  350. <span id='Ext-Element-method-setDisplayed'> /**
  351. </span> * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.
  352. * @param {Mixed} value Boolean value to display the element using its default display, or a string to set the display directly.
  353. * @return {Ext.Element} this
  354. */
  355. setDisplayed : function(value) {
  356. if(typeof value == &quot;boolean&quot;){
  357. value = value ? getDisplay(this.dom) : NONE;
  358. }
  359. this.setStyle(DISPLAY, value);
  360. return this;
  361. },
  362. // private
  363. fixDisplay : function(){
  364. var me = this;
  365. if(me.isStyle(DISPLAY, NONE)){
  366. me.setStyle(VISIBILITY, HIDDEN);
  367. me.setStyle(DISPLAY, getDisplay(this.dom)); // first try reverting to default
  368. if(me.isStyle(DISPLAY, NONE)){ // if that fails, default to block
  369. me.setStyle(DISPLAY, &quot;block&quot;);
  370. }
  371. }
  372. },
  373. <span id='Ext-Element-method-hide'> /**
  374. </span> * Hide this element - Uses display mode to determine whether to use &quot;display&quot; or &quot;visibility&quot;. See {@link #setVisible}.
  375. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  376. * @return {Ext.Element} this
  377. */
  378. hide : function(animate){
  379. // hideMode override
  380. if (typeof animate == 'string'){
  381. this.setVisible(false, animate);
  382. return this;
  383. }
  384. this.setVisible(false, this.preanim(arguments, 0));
  385. return this;
  386. },
  387. <span id='Ext-Element-method-show'> /**
  388. </span> * Show this element - Uses display mode to determine whether to use &quot;display&quot; or &quot;visibility&quot;. See {@link #setVisible}.
  389. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  390. * @return {Ext.Element} this
  391. */
  392. show : function(animate){
  393. // hideMode override
  394. if (typeof animate == 'string'){
  395. this.setVisible(true, animate);
  396. return this;
  397. }
  398. this.setVisible(true, this.preanim(arguments, 0));
  399. return this;
  400. }
  401. };
  402. }());</pre>
  403. </body>
  404. </html>