diff --git a/karma.conf.js b/karma.conf.js index 73149f50f..ed75118d7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -43,6 +43,7 @@ module.exports = function(config) { 'static/js/**/*.ts': ['webpack'], }, webpack: { + resolve: webpackConfig.resolve, module: webpackConfig.module, }, webpackMiddleware: { diff --git a/static/js/services/angular-view-array/angular-view-array.spec.ts b/static/js/services/angular-view-array/angular-view-array.spec.ts index ce30f9268..2ec39ea7a 100644 --- a/static/js/services/angular-view-array/angular-view-array.spec.ts +++ b/static/js/services/angular-view-array/angular-view-array.spec.ts @@ -1,4 +1,5 @@ import IInjectorService = angular.auto.IInjectorService; +// import { ViewArrayImpl } from './view-array.impl'; describe("Service: AngularViewArray", () => { diff --git a/static/js/services/angular-view-array/angular-view-array.ts b/static/js/services/angular-view-array/angular-view-array.ts index 1a8fe7a73..795fb7e77 100644 --- a/static/js/services/angular-view-array/angular-view-array.ts +++ b/static/js/services/angular-view-array/angular-view-array.ts @@ -16,93 +16,11 @@ AngularViewArrayFactory.$inject = [ '$interval' ]; -export default function AngularViewArrayFactory($interval) { - var ADDTIONAL_COUNT = 20; - - function _ViewArray() { - this.isVisible = false; - this.visibleEntries = null; - this.hasEntries = false; - this.entries = []; - this.hasHiddenEntries = false; - - this.timerRef_ = null; - this.currentIndex_ = 0; - } - - _ViewArray.prototype.length = function(): number { - return this.entries.length; - }; - - _ViewArray.prototype.get = function(index: number): any { - return this.entries[index]; - }; - - _ViewArray.prototype.push = function(elem: any): void { - this.entries.push(elem); - this.hasEntries = true; - - if (this.isVisible) { - this.startTimer_(); +export default function AngularViewArrayFactory($interval): any { + return { + create: function(): ViewArray { + return new ViewArrayImpl($interval, 20); } }; - - _ViewArray.prototype.toggle = function(): void { - this.setVisible(!this.isVisible); - }; - - _ViewArray.prototype.setVisible = function(newState: boolean): void { - this.isVisible = newState; - - this.visibleEntries = []; - this.currentIndex_ = 0; - - if (newState) { - this.showAdditionalEntries_(); - this.startTimer_(); - } - else { - this.stopTimer_(); - } - }; - - _ViewArray.prototype.showAdditionalEntries_ = function(): void { - var i: number = 0; - for (i = this.currentIndex_; i < (this.currentIndex_ + ADDTIONAL_COUNT) && i < this.entries.length; ++i) { - this.visibleEntries.push(this.entries[i]); - } - - this.currentIndex_ = i; - this.hasHiddenEntries = this.currentIndex_ < this.entries.length; - if (this.currentIndex_ >= this.entries.length) { - this.stopTimer_(); - } - }; - - _ViewArray.prototype.startTimer_ = function(): void { - if (this.timerRef_) { - return; - } - - var that = this; - this.timerRef_ = $interval(function() { - that.showAdditionalEntries_(); - }, 10); - }; - - _ViewArray.prototype.stopTimer_ = function(): void { - if (this.timerRef_) { - $interval.cancel(this.timerRef_); - this.timerRef_ = null; - } - }; - - var service: any = { - create: function(): any { - return new _ViewArray(); - } - }; - - return service; }