|
338 | 338 | } |
339 | 339 | } |
340 | 340 |
|
| 341 | + /** |
| 342 | + * Remove progress bar without finishing |
| 343 | + * |
| 344 | + * @api private |
| 345 | + * @method _kill |
| 346 | + */ |
| 347 | + function _kill() { |
| 348 | + var target = this._targetElement[0]; |
| 349 | + if(!target) return; |
| 350 | + var progressjsId = parseInt(target.getAttribute('data-progressjs')); |
| 351 | + |
| 352 | + for (var i = 0, elmsLength = this._targetElement.length; i < elmsLength; i++) { |
| 353 | + var currentElement = this._targetElement[i]; |
| 354 | + var percentElement = _getPercentElement(currentElement); |
| 355 | + |
| 356 | + if (!percentElement) |
| 357 | + return; |
| 358 | + |
| 359 | + //I believe I should handle this situation with eventListener and `transitionend` event but I'm not sure |
| 360 | + //about compatibility with IEs. Should be fixed in further versions. |
| 361 | + (function(percentElement, currentElement) { |
| 362 | + percentElement.parentNode.className += " progressjs-end"; |
| 363 | + |
| 364 | + setTimeout(function() { |
| 365 | + //remove the percent element from page |
| 366 | + percentElement.parentNode.parentNode.removeChild(percentElement.parentNode); |
| 367 | + //and remove the attribute |
| 368 | + currentElement.removeAttribute("data-progressjs"); |
| 369 | + }, 1000); |
| 370 | + })(percentElement, currentElement); |
| 371 | + } |
| 372 | + |
| 373 | + //clean the setInterval for autoIncrease function |
| 374 | + if (window._progressjsIntervals[progressjsId]) { |
| 375 | + //`delete` keyword has some problems in IE |
| 376 | + try { |
| 377 | + clearInterval(window._progressjsIntervals[progressjsId]); |
| 378 | + window._progressjsIntervals[progressjsId] = null; |
| 379 | + delete window._progressjsIntervals[progressjsId]; |
| 380 | + } catch(ex) { } |
| 381 | + } |
| 382 | + } |
| 383 | + |
341 | 384 | /** |
342 | 385 | * Create the progress bar container |
343 | 386 | * |
|
491 | 534 | _end.call(this); |
492 | 535 | return this; |
493 | 536 | }, |
| 537 | + kill: function() { |
| 538 | + _kill.call(this); |
| 539 | + return this; |
| 540 | + }, |
494 | 541 | onbeforeend: function(providedCallback) { |
495 | 542 | if (typeof (providedCallback) === 'function') { |
496 | 543 | this._onBeforeEndCallback = providedCallback; |
|
0 commit comments