Beispiel #1
0
var MenuBackdrop = (function () {
    function MenuBackdrop(_menuCtrl, elementRef) {
        this._menuCtrl = _menuCtrl;
        this.elementRef = elementRef;
        _menuCtrl.backdrop = this;
    }
    /**
     * @private
     */
    MenuBackdrop.prototype.clicked = function (ev) {
        void 0;
        ev.preventDefault();
        ev.stopPropagation();
        this._menuCtrl.close();
    };
    MenuBackdrop = __decorate([
        core_1.Directive({
            selector: '.backdrop',
            host: {
                '(click)': 'clicked($event)',
            }
        }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [Menu, core_1.ElementRef])
    ], MenuBackdrop);
    return MenuBackdrop;
}());
var NgSelectOption = (function () {
    function NgSelectOption(_element, _renderer, _select) {
        this._element = _element;
        this._renderer = _renderer;
        this._select = _select;
        if (lang_1.isPresent(this._select))
            this.id = this._select._registerOption();
    }
    Object.defineProperty(NgSelectOption.prototype, "ngValue", {
        set: function (value) {
            if (this._select == null)
                return;
            this._select._optionMap.set(this.id, value);
            this._setElementValue(_buildValueString(this.id, value));
            this._select.writeValue(this._select.value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgSelectOption.prototype, "value", {
        set: function (value) {
            this._setElementValue(value);
            if (lang_1.isPresent(this._select))
                this._select.writeValue(this._select.value);
        },
        enumerable: true,
        configurable: true
    });
    /** @internal */
    NgSelectOption.prototype._setElementValue = function (value) {
        this._renderer.setElementProperty(this._element.nativeElement, 'value', value);
    };
    NgSelectOption.prototype.ngOnDestroy = function () {
        if (lang_1.isPresent(this._select)) {
            this._select._optionMap.delete(this.id);
            this._select.writeValue(this._select.value);
        }
    };
    __decorate([
        core_1.Input('ngValue'), 
        __metadata('design:type', Object), 
        __metadata('design:paramtypes', [Object])
    ], NgSelectOption.prototype, "ngValue", null);
    __decorate([
        core_1.Input('value'), 
        __metadata('design:type', Object), 
        __metadata('design:paramtypes', [Object])
    ], NgSelectOption.prototype, "value", null);
    NgSelectOption = __decorate([
        core_1.Directive({ selector: 'option' }),
        __param(2, core_1.Optional()),
        __param(2, core_1.Host()), 
        __metadata('design:paramtypes', [(typeof (_a = typeof core_1.ElementRef !== 'undefined' && core_1.ElementRef) === 'function' && _a) || Object, (typeof (_b = typeof core_1.Renderer !== 'undefined' && core_1.Renderer) === 'function' && _b) || Object, SelectControlValueAccessor])
    ], NgSelectOption);
    return NgSelectOption;
    var _a, _b;
}());
Beispiel #3
0
var TabNavBarAnchor = (function () {
    function TabNavBarAnchor(tabs, viewContainerRef) {
        tabs.navbarContainerRef = viewContainerRef;
    }
    TabNavBarAnchor = __decorate([
        core_1.Directive({ selector: 'template[navbar-anchor]' }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [Tabs, core_1.ViewContainerRef])
    ], TabNavBarAnchor);
    return TabNavBarAnchor;
}());
Beispiel #4
0
var NgSwitchDefault = (function () {
    function NgSwitchDefault(viewContainer, templateRef, sswitch) {
        sswitch._registerView(_WHEN_DEFAULT, new SwitchView(viewContainer, templateRef));
    }
    NgSwitchDefault = __decorate([
        core_1.Directive({ selector: '[ngSwitchDefault]' }),
        __param(2, core_1.Host()), 
        __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])
    ], NgSwitchDefault);
    return NgSwitchDefault;
})();
var Bar = (function () {
    function Bar(progress) {
        this.progress = progress;
        this.percent = 0;
    }
    Object.defineProperty(Bar.prototype, "value", {
        get: function () {
            return this._value;
        },
        set: function (v) {
            if (!v && v !== 0) {
                return;
            }
            this._value = v;
            this.recalculatePercentage();
        },
        enumerable: true,
        configurable: true
    });
    Bar.prototype.ngOnInit = function () {
        this.progress.addBar(this);
    };
    Bar.prototype.ngOnDestroy = function () {
        this.progress.removeBar(this);
    };
    Bar.prototype.recalculatePercentage = function () {
        this.percent = +(100 * this.value / this.progress.max).toFixed(2);
        var totalPercentage = this.progress.bars.reduce(function (total, bar) {
            return total + bar.percent;
        }, 0);
        if (totalPercentage > 100) {
            this.percent -= totalPercentage - 100;
        }
    };
    __decorate([
        core_1.Input(), 
        __metadata('design:type', String)
    ], Bar.prototype, "type", void 0);
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Number)
    ], Bar.prototype, "value", null);
    Bar = __decorate([
        core_1.Component({
            selector: 'bar, [bar]',
            directives: [common_1.NgClass, common_1.NgStyle],
            template: "\n  <div class=\"progress-bar\"\n    style=\"min-width: 0;\"\n    role=\"progressbar\"\n    [ngClass]=\"type && 'progress-bar-' + type\"\n    [ngStyle]=\"{width: (percent < 100 ? percent : 100) + '%', transition: transition}\"\n    aria-valuemin=\"0\"\n    [attr.aria-valuenow]=\"value\"\n    [attr.aria-valuetext]=\"percent.toFixed(0) + '%'\"\n    [attr.aria-valuemax]=\"max\"\n    ><ng-content></ng-content></div>\n"
        }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [progress_directive_1.Progress])
    ], Bar);
    return Bar;
}());
var DropdownToggle = (function () {
    function DropdownToggle(dropdown, el) {
        this.disabled = false;
        this.addClass = true;
        this.dropdown = dropdown;
        this.el = el;
    }
    DropdownToggle.prototype.ngOnInit = function () {
        this.dropdown.dropDownToggle = this;
    };
    Object.defineProperty(DropdownToggle.prototype, "isOpen", {
        get: function () {
            return this.dropdown.isOpen;
        },
        enumerable: true,
        configurable: true
    });
    DropdownToggle.prototype.toggleDropdown = function (event) {
        event.stopPropagation();
        if (!this.disabled) {
            this.dropdown.toggle();
        }
        return false;
    };
    __decorate([
        core_1.HostBinding('class.disabled'),
        core_1.Input(), 
        __metadata('design:type', Boolean)
    ], DropdownToggle.prototype, "disabled", void 0);
    __decorate([
        core_1.HostBinding('class.dropdown-toggle'),
        core_1.HostBinding('attr.aria-haspopup'), 
        __metadata('design:type', Boolean)
    ], DropdownToggle.prototype, "addClass", void 0);
    __decorate([
        core_1.HostBinding('attr.aria-expanded'), 
        __metadata('design:type', Boolean)
    ], DropdownToggle.prototype, "isOpen", null);
    __decorate([
        core_1.HostListener('click', ['$event']), 
        __metadata('design:type', Function), 
        __metadata('design:paramtypes', [MouseEvent]), 
        __metadata('design:returntype', Boolean)
    ], DropdownToggle.prototype, "toggleDropdown", null);
    DropdownToggle = __decorate([
        core_1.Directive({ selector: '[dropdownToggle]' }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [dropdown_directive_1.Dropdown, core_1.ElementRef])
    ], DropdownToggle);
    return DropdownToggle;
}());
var NgSelectOption = (function () {
    function NgSelectOption(_element, _renderer, _select) {
        this._element = _element;
        this._renderer = _renderer;
        this._select = _select;
        if (lang_1.isPresent(this._select))
            this.id = this._select._registerOption();
    }
    Object.defineProperty(NgSelectOption.prototype, "ngValue", {
        set: function (value) {
            if (this._select == null)
                return;
            this._select._optionMap.set(this.id, value);
            this._setElementValue(_buildValueString(this.id, value));
            this._select.writeValue(this._select.value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgSelectOption.prototype, "value", {
        set: function (value) {
            this._setElementValue(value);
            if (lang_1.isPresent(this._select))
                this._select.writeValue(this._select.value);
        },
        enumerable: true,
        configurable: true
    });
    /** @internal */
    NgSelectOption.prototype._setElementValue = function (value) {
        this._renderer.setElementProperty(this._element.nativeElement, 'value', value);
    };
    NgSelectOption.prototype.ngOnDestroy = function () {
        if (lang_1.isPresent(this._select)) {
            this._select._optionMap.delete(this.id);
            this._select.writeValue(this._select.value);
        }
    };
    __decorate([
        core_1.Input('ngValue')
    ], NgSelectOption.prototype, "ngValue", null);
    __decorate([
        core_1.Input('value')
    ], NgSelectOption.prototype, "value", null);
    NgSelectOption = __decorate([
        core_1.Directive({ selector: 'option' }),
        __param(2, core_1.Optional()),
        __param(2, core_1.Host())
    ], NgSelectOption);
    return NgSelectOption;
})();
Beispiel #8
0
var MdDialogContent = (function () {
    function MdDialogContent(dialogContainer, elementRef) {
        dialogContainer.contentRef = elementRef;
    }
    MdDialogContent = __decorate([
        core_1.Directive({
            selector: 'md-dialog-content'
        }),
        __param(0, core_1.Host()),
        __param(0, core_1.SkipSelf()), 
        __metadata('design:paramtypes', [MdDialogContainer, core_1.ElementRef])
    ], MdDialogContent);
    return MdDialogContent;
}());
var DropdownMenu = (function () {
    function DropdownMenu(dropdown, el) {
        this.dropdown = dropdown;
        this.el = el;
    }
    DropdownMenu.prototype.ngOnInit = function () {
        this.dropdown.dropDownMenu = this;
    };
    DropdownMenu = __decorate([
        core_1.Directive({ selector: '[dropdownMenu]' }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [dropdown_directive_1.Dropdown, core_1.ElementRef])
    ], DropdownMenu);
    return DropdownMenu;
}());
Beispiel #10
0
var Slide = (function () {
    function Slide(elementRef, slides) {
        this.ele = elementRef.nativeElement;
        this.ele.classList.add('swiper-slide');
        slides.rapidUpdate();
    }
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Object)
    ], Slide.prototype, "zoom", void 0);
    Slide = __decorate([
        core_1.Component({
            selector: 'ion-slide',
            template: '<div class="slide-zoom"><ng-content></ng-content></div>'
        }),
        __param(1, core_1.Host()), 
        __metadata('design:paramtypes', [core_1.ElementRef, Slides])
    ], Slide);
    return Slide;
})();
Beispiel #11
0
var NgSwitchWhen = (function () {
    function NgSwitchWhen(viewContainer, templateRef, ngSwitch) {
        // `_WHEN_DEFAULT` is used as a marker for a not yet initialized value
        /** @internal */
        this._value = _WHEN_DEFAULT;
        this._switch = ngSwitch;
        this._view = new SwitchView(viewContainer, templateRef);
    }
    Object.defineProperty(NgSwitchWhen.prototype, "ngSwitchWhen", {
        set: function (value) {
            this._switch._onWhenValueChanged(this._value, value, this._view);
            this._value = value;
        },
        enumerable: true,
        configurable: true
    });
    NgSwitchWhen = __decorate([
        core_1.Directive({ selector: '[ngSwitchWhen]', inputs: ['ngSwitchWhen'] }),
        __param(2, core_1.Host()), 
        __metadata('design:paramtypes', [core_1.ViewContainerRef, core_1.TemplateRef, NgSwitch])
    ], NgSwitchWhen);
    return NgSwitchWhen;
})();
     */
    get control() { return this.formDirective.getControlGroup(this); }
    /**
     * Get the path to this control group.
     */
    get path() { return controlPath(this.name, this._parent); }
    /**
     * Get the {@link Form} to which this group belongs.
     */
    get formDirective() { return this._parent.formDirective; }
    get validator() { return composeValidators(this._validators); }
    get asyncValidator() { return composeAsyncValidators(this._asyncValidators); }
};
NgControlGroup = __decorate([
    Directive({
        selector: '[ngControlGroup]',
        providers: [controlGroupProvider],
        inputs: ['name: ngControlGroup'],
        exportAs: 'ngForm'
    }),
    __param(0, Host()),
    __param(0, SkipSelf()),
    __param(1, Optional()),
    __param(1, Self()),
    __param(1, Inject(NG_VALIDATORS)),
    __param(2, Optional()),
    __param(2, Self()),
    __param(2, Inject(NG_ASYNC_VALIDATORS)), 
    __metadata('design:paramtypes', [ControlContainer, Array, Array])
], NgControlGroup);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmdfY29udHJvbF9ncm91cC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImFuZ3VsYXIyL3NyYy9jb21tb24vZm9ybXMvZGlyZWN0aXZlcy9uZ19jb250cm9sX2dyb3VwLnRzIl0sIm5hbWVzIjpbIk5nQ29udHJvbEdyb3VwIiwiTmdDb250cm9sR3JvdXAuY29uc3RydWN0b3IiLCJOZ0NvbnRyb2xHcm91cC5uZ09uSW5pdCIsIk5nQ29udHJvbEdyb3VwLm5nT25EZXN0cm95IiwiTmdDb250cm9sR3JvdXAuY29udHJvbCIsIk5nQ29udHJvbEdyb3VwLnBhdGgiLCJOZ0NvbnRyb2xHcm91cC5mb3JtRGlyZWN0aXZlIiwiTmdDb250cm9sR3JvdXAudmFsaWRhdG9yIiwiTmdDb250cm9sR3JvdXAuYXN5bmNWYWxpZGF0b3IiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztPQUFPLEVBR0wsU0FBUyxFQUNULFFBQVEsRUFDUixNQUFNLEVBQ04sSUFBSSxFQUNKLFFBQVEsRUFDUixVQUFVLEVBQ1YsUUFBUSxFQUNSLElBQUksRUFDTCxNQUFNLGVBQWU7T0FDZixFQUFDLFVBQV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ICAgKi9cbiAgZ2V0IHBhdGgoKTogc3RyaW5nW10geyByZXR1cm4gY29udHJvbFBhdGgodGhpcy5uYW1lLCB0aGlzLl9wYXJlbnQpOyB9XG5cbiAgLyoqXG4gICAqIEdldCB0aGUge0BsaW5rIEZvcm19IHRvIHdoaWNoIHRoaXMgZ3JvdXAgYmVsb25ncy5cbiAgICovXG4gIGdldCBmb3JtRGlyZWN0aXZlKCk6IEZvcm0geyByZXR1cm4gdGhpcy5fcGFyZW50LmZvcm1EaXJlY3RpdmU7IH1cblxuICBnZXQgdmFsaWRhdG9yKCk6IEZ1bmN0aW9uIHsgcmV0dXJuIGNvbXBvc2VWYWxpZGF0b3JzKHRoaXMuX3ZhbGlkYXRvcnMpOyB9XG5cbiAgZ2V0IGFzeW5jVmFsaWRhdG9yKCk6IEZ1bmN0aW9uIHsgcmV0dXJuIGNvbXBvc2VBc3luY1ZhbGlkYXRvcnModGhpcy5fYXN5bmNWYWxpZGF0b3JzKTsgfVxufVxuIl19
Beispiel #13
0
var InfiniteScroll = (function () {
    function InfiniteScroll(_content, _zone, _elementRef) {
        this._content = _content;
        this._zone = _zone;
        this._elementRef = _elementRef;
        this._lastCheck = 0;
        this._highestY = 0;
        this._thr = '15%';
        this._thrPx = 0;
        this._thrPc = 0.15;
        this._init = false;
        this.state = STATE_ENABLED;
        /**
         * @output {event} The expression to call when the scroll reaches
         * the threshold distance. From within your infinite handler,
         * you must call the infinite scroll's `complete()` method when
         * your async operation has completed.
         */
        this.infinite = new core_1.EventEmitter();
        _content.addCssClass('has-infinite-scroll');
    }
    Object.defineProperty(InfiniteScroll.prototype, "threshold", {
        /**
         * @input {string} The threshold distance from the bottom
         * of the content to call the `infinite` output event when scrolled.
         * The threshold value can be either a percent, or
         * in pixels. For example, use the value of `10%` for the `infinite`
         * output event to get called when the user has scrolled 10%
         * from the bottom of the page. Use the value `100px` when the
         * scroll is within 100 pixels from the bottom of the page.
         * Default is `15%`.
         */
        get: function () {
            return this._thr;
        },
        set: function (val) {
            this._thr = val;
            if (val.indexOf('%') > -1) {
                this._thrPx = 0;
                this._thrPc = (parseFloat(val) / 100);
            }
            else {
                this._thrPx = parseFloat(val);
                this._thrPc = 0;
            }
        },
        enumerable: true,
        configurable: true
    });
    InfiniteScroll.prototype._onScroll = function (ev) {
        var _this = this;
        if (this.state === STATE_LOADING || this.state === STATE_DISABLED) {
            return 1;
        }
        var now = Date.now();
        if (this._lastCheck + 32 > now) {
            // no need to check less than every XXms
            return 2;
        }
        this._lastCheck = now;
        var infiniteHeight = this._elementRef.nativeElement.scrollHeight;
        if (!infiniteHeight) {
            // if there is no height of this element then do nothing
            return 3;
        }
        var d = this._content.getContentDimensions();
        if (d.scrollTop <= this._highestY) {
            // don't bother if scrollY is less than the highest Y seen
            return 4;
        }
        this._highestY = d.scrollTop;
        var reloadY = d.contentHeight;
        if (this._thrPc) {
            reloadY += (reloadY * this._thrPc);
        }
        else {
            reloadY += this._thrPx;
        }
        var distanceFromInfinite = ((d.scrollHeight - infiniteHeight) - d.scrollTop) - reloadY;
        if (distanceFromInfinite < 0) {
            this._zone.run(function () {
                void 0;
                _this.state = STATE_LOADING;
                _this.infinite.emit(_this);
            });
            return 5;
        }
        return 6;
    };
    /**
     * Call `complete()` within the `infinite` output event handler when
     * your async operation has completed. For example, the `loading`
     * state is while the app is performing an asynchronous operation,
     * such as receiving more data from an AJAX request to add more items
     * to a data list. Once the data has been received and UI updated, you
     * then call this method to signify that the loading has completed.
     * This method will change the infinite scroll's state from `loading`
     * to `enabled`.
     */
    InfiniteScroll.prototype.complete = function () {
        this.state = STATE_ENABLED;
    };
    /**
     * Call `enable(false)` to disable the infinite scroll from actively
     * trying to receive new data while scrolling. This method is useful
     * when it is known that there is no more data that can be added, and
     * the infinite scroll is no longer needed.
     * @param {boolean} shouldEnable  If the infinite scroll should be enabled or not. Setting to `false` will remove scroll event listeners and hide the display.
     */
    InfiniteScroll.prototype.enable = function (shouldEnable) {
        this.state = (shouldEnable ? STATE_ENABLED : STATE_DISABLED);
        this._setListeners(shouldEnable);
    };
    InfiniteScroll.prototype._setListeners = function (shouldListen) {
        var _this = this;
        if (this._init) {
            if (shouldListen) {
                if (!this._scLsn) {
                    this._zone.runOutsideAngular(function () {
                        _this._scLsn = _this._content.addScrollListener(_this._onScroll.bind(_this));
                    });
                }
            }
            else {
                this._scLsn && this._scLsn();
                this._scLsn = null;
            }
        }
    };
    /**
     * @private
     */
    InfiniteScroll.prototype.ngAfterContentInit = function () {
        this._init = true;
        this._setListeners(this.state !== STATE_DISABLED);
    };
    /**
     * @private
     */
    InfiniteScroll.prototype.ngOnDestroy = function () {
        this._setListeners(false);
    };
    __decorate([
        core_1.Input(), 
        __metadata('design:type', String)
    ], InfiniteScroll.prototype, "threshold", null);
    __decorate([
        core_1.Output(), 
        __metadata('design:type', core_1.EventEmitter)
    ], InfiniteScroll.prototype, "infinite", void 0);
    InfiniteScroll = __decorate([
        core_1.Directive({
            selector: 'ion-infinite-scroll'
        }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [content_1.Content, core_1.NgZone, core_1.ElementRef])
    ], InfiniteScroll);
    return InfiniteScroll;
})();
Beispiel #14
0
export let NgSwitchWhen = class {
    constructor(viewContainer, templateRef, ngSwitch) {
        // `_WHEN_DEFAULT` is used as a marker for a not yet initialized value
        /** @internal */
        this._value = _WHEN_DEFAULT;
        this._switch = ngSwitch;
        this._view = new SwitchView(viewContainer, templateRef);
    }
    set ngSwitchWhen(value) {
        this._switch._onWhenValueChanged(this._value, value, this._view);
        this._value = value;
    }
};
NgSwitchWhen = __decorate([
    Directive({ selector: '[ngSwitchWhen]', inputs: ['ngSwitchWhen'] }),
    __param(2, Host()), 
    __metadata('design:paramtypes', [ViewContainerRef, TemplateRef, NgSwitch])
], NgSwitchWhen);
/**
 * Default case statements are displayed when no match expression matches the switch expression
 * value.
 *
 * See {@link NgSwitch} for more details and example.
 */
export let NgSwitchDefault = class {
    constructor(viewContainer, templateRef, sswitch) {
        sswitch._registerView(_WHEN_DEFAULT, new SwitchView(viewContainer, templateRef));
    }
};
NgSwitchDefault = __decorate([
    Directive({ selector: '[ngSwitchDefault]' }),
Beispiel #15
0
var NgControlName = (function (_super) {
    __extends(NgControlName, _super);
    function NgControlName(_parent, _validators, _asyncValidators, valueAccessors) {
        _super.call(this);
        this._parent = _parent;
        this._validators = _validators;
        this._asyncValidators = _asyncValidators;
        /** @internal */
        this.update = new async_1.EventEmitter();
        this._added = false;
        this.valueAccessor = shared_1.selectValueAccessor(this, valueAccessors);
    }
    NgControlName.prototype.ngOnChanges = function (changes) {
        if (!this._added) {
            this.formDirective.addControl(this);
            this._added = true;
        }
        if (shared_1.isPropertyUpdated(changes, this.viewModel)) {
            this.viewModel = this.model;
            this.formDirective.updateModel(this, this.model);
        }
    };
    NgControlName.prototype.ngOnDestroy = function () { this.formDirective.removeControl(this); };
    NgControlName.prototype.viewToModelUpdate = function (newValue) {
        this.viewModel = newValue;
        async_1.ObservableWrapper.callEmit(this.update, newValue);
    };
    Object.defineProperty(NgControlName.prototype, "path", {
        get: function () { return shared_1.controlPath(this.name, this._parent); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlName.prototype, "formDirective", {
        get: function () { return this._parent.formDirective; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlName.prototype, "validator", {
        get: function () { return shared_1.composeValidators(this._validators); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlName.prototype, "asyncValidator", {
        get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlName.prototype, "control", {
        get: function () { return this.formDirective.getControl(this); },
        enumerable: true,
        configurable: true
    });
    NgControlName = __decorate([
        core_1.Directive({
            selector: '[ngControl]',
            bindings: [controlNameBinding],
            inputs: ['name: ngControl', 'model: ngModel'],
            outputs: ['update: ngModelChange'],
            exportAs: 'ngForm'
        }),
        __param(0, core_1.Host()),
        __param(0, core_1.SkipSelf()),
        __param(1, core_1.Optional()),
        __param(1, core_1.Self()),
        __param(1, core_1.Inject(validators_1.NG_VALIDATORS)),
        __param(2, core_1.Optional()),
        __param(2, core_1.Self()),
        __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)),
        __param(3, core_1.Optional()),
        __param(3, core_1.Self()),
        __param(3, core_1.Inject(control_value_accessor_1.NG_VALUE_ACCESSOR)), 
        __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array, Array])
    ], NgControlName);
    return NgControlName;
}(ng_control_1.NgControl));
Beispiel #16
0
var Refresher = (function () {
    function Refresher(_content, _zone, elementRef) {
        this._content = _content;
        this._zone = _zone;
        this._appliedStyles = false;
        this._lastStart = 0;
        this._lastCheck = 0;
        this._isEnabled = true;
        /**
         * The current state which the refresher is in. The refresher's states include:
         *
         * - `inactive` - The refresher is not being pulled down or refreshing and is currently hidden.
         * - `pulling` - The user is actively pulling down the refresher, but has not reached the point yet that if the user lets go, it'll refresh.
         * - `cancelling` - The user pulled down the refresher and let go, but did not pull down far enough to kick off the `refreshing` state. After letting go, the refresher is in the `cancelling` state while it is closing, and will go back to the `inactive` state once closed.
         * - `ready` - The user has pulled down the refresher far enough that if they let go, it'll begin the `refreshing` state.
         * - `refreshing` - The refresher is actively waiting on the async operation to end. Once the refresh handler calls `complete()` it will begin the `completing` state.
         * - `completing` - The `refreshing` state has finished and the refresher is in the process of closing itself. Once closed, the refresher will go back to the `inactive` state.
         */
        this.state = STATE_INACTIVE;
        /**
         * The Y coordinate of where the user started to the pull down the content.
         */
        this.startY = null;
        /**
         * The current touch or mouse event's Y coordinate.
         */
        this.currentY = null;
        /**
         * The distance between the start of the pull and the current touch or
         * mouse event's Y coordinate.
         */
        this.deltaY = null;
        /**
         * A number representing how far down the user has pulled.
         * The number `0` represents the user hasn't pulled down at all. The
         * number `1`, and anything greater than `1`, represents that the user
         * has pulled far enough down that when they let go then the refresh will
         * happen. If they let go and the number is less than `1`, then the
         * refresh will not happen, and the content will return to it's original
         * position.
         */
        this.progress = 0;
        /**
         * @input {number} The min distance the user must pull down until the
         * refresher can go into the `refreshing` state. Default is `60`.
         */
        this.pullMin = 60;
        /**
         * @input {number} The maximum distance of the pull until the refresher
         * will automatically go into the `refreshing` state. By default, the pull
         * maximum will be the result of `pullMin + 60`.
         */
        this.pullMax = null;
        /**
         * @input {number} How many milliseconds it takes to close the refresher. Default is `280`.
         */
        this.closeDuration = 280;
        /**
         * @input {number} How many milliseconds it takes the refresher to to snap back to the `refreshing` state. Default is `280`.
         */
        this.snapbackDuration = 280;
        /**
         * @output {event} When the user lets go and has pulled down far enough, which would be
         * farther than the `pullMin`, then your refresh hander if fired and the state is
         * updated to `refreshing`. From within your refresh handler, you must call the
         * `complete()` method when your async operation has completed.
         */
        this.refresh = new core_1.EventEmitter();
        /**
         * @output {event} While the user is pulling down the content and exposing the refresher.
         */
        this.pulling = new core_1.EventEmitter();
        /**
         * @output {event} When the user begins to start pulling down.
         */
        this.start = new core_1.EventEmitter();
        _content.addCssClass('has-refresher');
        // deprecated warning
        var ele = elementRef.nativeElement;
        var deprecatedAttrs = ['pullingIcon', 'pullingText', 'refreshingIcon', 'refreshingText', 'spinner'];
        deprecatedAttrs.forEach(function (attrName) {
            if (ele.hasAttribute(attrName)) {
                void 0;
            }
        });
        if (!ele.children.length) {
            void 0;
        }
    }
    Object.defineProperty(Refresher.prototype, "enabled", {
        /**
         * @input {boolean} If the refresher is enabled or not. Default is `true`.
         */
        get: function () {
            return this._isEnabled;
        },
        set: function (val) {
            this._isEnabled = util_1.isTrueProperty(val);
            this._setListeners(this._isEnabled);
        },
        enumerable: true,
        configurable: true
    });
    Refresher.prototype._onStart = function (ev) {
        // if multitouch then get out immediately
        if (ev.touches && ev.touches.length > 1) {
            return 1;
        }
        var coord = dom_1.pointerCoord(ev);
        void 0;
        var now = Date.now();
        if (this._lastStart + 100 > now) {
            return 2;
        }
        this._lastStart = now;
        if (ev.type === 'mousedown' && !this._mMove) {
            this._mMove = this._content.addMouseMoveListener(this._onMove.bind(this));
        }
        this.startY = this.currentY = coord.y;
        this.progress = 0;
        if (!this.pullMax) {
            this.pullMax = (this.pullMin + 60);
        }
    };
    Refresher.prototype._onMove = function (ev) {
        var _this = this;
        // this method can get called like a bazillion times per second,
        // so it's built to be as efficient as possible, and does its
        // best to do any DOM read/writes only when absolutely necessary
        void 0;
        // if multitouch then get out immediately
        if (ev.touches && ev.touches.length > 1) {
            return 1;
        }
        // do nothing if it's actively refreshing
        // or it's in the process of closing
        // or this was never a startY
        if (this.startY === null || this.state === STATE_REFRESHING || this.state === STATE_CANCELLING || this.state === STATE_COMPLETING) {
            return 2;
        }
        // if we just updated stuff less than 16ms ago
        // then don't check again, just chillout plz
        var now = Date.now();
        if (this._lastCheck + 16 > now) {
            return 3;
        }
        // remember the last time we checked all this
        this._lastCheck = now;
        // get the current pointer coordinates
        var coord = dom_1.pointerCoord(ev);
        this.currentY = coord.y;
        // it's now possible they could be pulling down the content
        // how far have they pulled so far?
        this.deltaY = (coord.y - this.startY);
        // don't bother if they're scrolling up
        // and have not already started dragging
        if (this.deltaY <= 0) {
            // the current Y is higher than the starting Y
            // so they scrolled up enough to be ignored
            this.progress = 0;
            if (this.state !== STATE_INACTIVE) {
                this._zone.run(function () {
                    _this.state = STATE_INACTIVE;
                });
            }
            if (this._appliedStyles) {
                // reset the styles only if they were applied
                this._setCss(0, '', false, '');
                return 5;
            }
            return 6;
        }
        if (this.state === STATE_INACTIVE) {
            // this refresh is not already actively pulling down
            // get the content's scrollTop
            var scrollHostScrollTop = this._content.getContentDimensions().scrollTop;
            // if the scrollTop is greater than zero then it's
            // not possible to pull the content down yet
            if (scrollHostScrollTop > 0) {
                this.progress = 0;
                this.startY = null;
                return 7;
            }
            // content scrolled all the way to the top, and dragging down
            this.state = STATE_PULLING;
        }
        // prevent native scroll events
        ev.preventDefault();
        // the refresher is actively pulling at this point
        // move the scroll element within the content element
        this._setCss(this.deltaY, '0ms', true, '');
        if (!this.deltaY) {
            // don't continue if there's no delta yet
            this.progress = 0;
            return 8;
        }
        // so far so good, let's run this all back within zone now
        this._zone.run(function () {
            _this._onMoveInZone();
        });
    };
    Refresher.prototype._onMoveInZone = function () {
        // set pull progress
        this.progress = (this.deltaY / this.pullMin);
        // emit "start" if it hasn't started yet
        if (!this._didStart) {
            this._didStart = true;
            this.start.emit(this);
        }
        // emit "pulling" on every move
        this.pulling.emit(this);
        // do nothing if the delta is less than the pull threshold
        if (this.deltaY < this.pullMin) {
            // ensure it stays in the pulling state, cuz its not ready yet
            this.state = STATE_PULLING;
            return 2;
        }
        if (this.deltaY > this.pullMax) {
            // they pulled farther than the max, so kick off the refresh
            this._beginRefresh();
            return 3;
        }
        // pulled farther than the pull min!!
        // it is now in the `ready` state!!
        // if they let go then it'll refresh, kerpow!!
        this.state = STATE_READY;
        return 4;
    };
    Refresher.prototype._onEnd = function (ev) {
        // only run in a zone when absolutely necessary
        var _this = this;
        if (this.state === STATE_READY) {
            this._zone.run(function () {
                // they pulled down far enough, so it's ready to refresh
                _this._beginRefresh();
            });
        }
        else if (this.state === STATE_PULLING) {
            this._zone.run(function () {
                // they were pulling down, but didn't pull down far enough
                // set the content back to it's original location
                // and close the refresher
                // set that the refresh is actively cancelling
                _this.cancel();
            });
        }
        // reset on any touchend/mouseup
        this.startY = null;
        if (this._mMove) {
            // we don't want to always listen to mousemoves
            // remove it if we're still listening
            this._mMove();
            this._mMove = null;
        }
    };
    Refresher.prototype._beginRefresh = function () {
        // assumes we're already back in a zone
        // they pulled down far enough, so it's ready to refresh
        this.state = STATE_REFRESHING;
        // place the content in a hangout position while it thinks
        this._setCss(this.pullMin, (this.snapbackDuration + 'ms'), true, '');
        // emit "refresh" because it was pulled down far enough
        // and they let go to begin refreshing
        this.refresh.emit(this);
    };
    /**
     * Call `complete()` when your async operation has completed.
     * For example, the `refreshing` state is while the app is performing
     * an asynchronous operation, such as receiving more data from an
     * AJAX request. Once the data has been received, you then call this
     * method to signify that the refreshing has completed and to close
     * the refresher. This method also changes the refresher's state from
     * `refreshing` to `completing`.
     */
    Refresher.prototype.complete = function () {
        this._close(STATE_COMPLETING, '120ms');
    };
    /**
     * Changes the refresher's state from `refreshing` to `cancelling`.
     */
    Refresher.prototype.cancel = function () {
        this._close(STATE_CANCELLING, '');
    };
    Refresher.prototype._close = function (state, delay) {
        var timer;
        function close(ev) {
            // closing is done, return to inactive state
            if (ev) {
                clearTimeout(timer);
            }
            this.state = STATE_INACTIVE;
            this.progress = 0;
            this._didStart = this.startY = this.currentY = this.deltaY = null;
            this._setCss(0, '0ms', false, '');
        }
        // create fallback timer incase something goes wrong with transitionEnd event
        timer = setTimeout(close.bind(this), 600);
        // create transition end event on the content's scroll element
        this._content.onScrollElementTransitionEnd(close.bind(this));
        // reset set the styles on the scroll element
        // set that the refresh is actively cancelling/completing
        this.state = state;
        this._setCss(0, '', true, delay);
        if (this._mMove) {
            // always remove the mousemove event
            this._mMove();
            this._mMove = null;
        }
    };
    Refresher.prototype._setCss = function (y, duration, overflowVisible, delay) {
        this._appliedStyles = (y > 0);
        var content = this._content;
        content.setScrollElementStyle(dom_1.CSS.transform, ((y > 0) ? 'translateY(' + y + 'px) translateZ(0px)' : 'translateZ(0px)'));
        content.setScrollElementStyle(dom_1.CSS.transitionDuration, duration);
        content.setScrollElementStyle(dom_1.CSS.transitionDelay, delay);
        content.setScrollElementStyle('overflow', (overflowVisible ? 'hidden' : ''));
    };
    Refresher.prototype._setListeners = function (shouldListen) {
        var self = this;
        var content = self._content;
        if (shouldListen) {
            // add listener outside of zone
            // touch handlers
            self._zone.runOutsideAngular(function () {
                if (!self._tStart) {
                    self._tStart = content.addTouchStartListener(self._onStart.bind(self));
                }
                if (!self._tMove) {
                    self._tMove = content.addTouchMoveListener(self._onMove.bind(self));
                }
                if (!self._tEnd) {
                    self._tEnd = content.addTouchEndListener(self._onEnd.bind(self));
                }
                // mouse handlers
                // mousemove does not get added until mousedown fires
                if (!self._mDown) {
                    self._mDown = content.addMouseDownListener(self._onStart.bind(self));
                }
                if (!self._mUp) {
                    self._mUp = content.addMouseUpListener(self._onEnd.bind(self));
                }
            });
        }
        else {
            // unregister event listeners from content element
            self._mDown && self._mDown();
            self._mMove && self._mMove();
            self._mUp && self._mUp();
            self._tStart && self._tStart();
            self._tMove && self._tMove();
            self._tEnd && self._tEnd();
            self._mDown = self._mMove = self._mUp = self._tStart = self._tMove = self._tEnd = null;
        }
    };
    /**
     * @private
     */
    Refresher.prototype.ngOnInit = function () {
        // bind event listeners
        // save the unregister listener functions to use onDestroy
        this._setListeners(this._isEnabled);
    };
    /**
     * @private
     */
    Refresher.prototype.ngOnDestroy = function () {
        this._setListeners(false);
    };
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Number)
    ], Refresher.prototype, "pullMin", void 0);
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Number)
    ], Refresher.prototype, "pullMax", void 0);
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Number)
    ], Refresher.prototype, "closeDuration", void 0);
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Number)
    ], Refresher.prototype, "snapbackDuration", void 0);
    __decorate([
        core_1.Input(), 
        __metadata('design:type', Boolean)
    ], Refresher.prototype, "enabled", null);
    __decorate([
        core_1.Output(), 
        __metadata('design:type', core_1.EventEmitter)
    ], Refresher.prototype, "refresh", void 0);
    __decorate([
        core_1.Output(), 
        __metadata('design:type', core_1.EventEmitter)
    ], Refresher.prototype, "pulling", void 0);
    __decorate([
        core_1.Output(), 
        __metadata('design:type', core_1.EventEmitter)
    ], Refresher.prototype, "start", void 0);
    Refresher = __decorate([
        core_1.Directive({
            selector: 'ion-refresher',
            host: {
                '[class.refresher-active]': 'state !== "inactive"'
            }
        }),
        __param(0, core_1.Host()), 
        __metadata('design:paramtypes', [content_1.Content, core_1.NgZone, core_1.ElementRef])
    ], Refresher);
    return Refresher;
})();
var NgControlGroup = (function (_super) {
    __extends(NgControlGroup, _super);
    function NgControlGroup(parent, _validators, _asyncValidators) {
        _super.call(this);
        this._validators = _validators;
        this._asyncValidators = _asyncValidators;
        this._parent = parent;
    }
    NgControlGroup.prototype.ngOnInit = function () { this.formDirective.addControlGroup(this); };
    NgControlGroup.prototype.ngOnDestroy = function () { this.formDirective.removeControlGroup(this); };
    Object.defineProperty(NgControlGroup.prototype, "control", {
        /**
         * Get the {@link ControlGroup} backing this binding.
         */
        get: function () { return this.formDirective.getControlGroup(this); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlGroup.prototype, "path", {
        /**
         * Get the path to this control group.
         */
        get: function () { return shared_1.controlPath(this.name, this._parent); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlGroup.prototype, "formDirective", {
        /**
         * Get the {@link Form} to which this group belongs.
         */
        get: function () { return this._parent.formDirective; },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlGroup.prototype, "validator", {
        get: function () { return shared_1.composeValidators(this._validators); },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NgControlGroup.prototype, "asyncValidator", {
        get: function () { return shared_1.composeAsyncValidators(this._asyncValidators); },
        enumerable: true,
        configurable: true
    });
    NgControlGroup = __decorate([
        core_1.Directive({
            selector: '[ngControlGroup]',
            providers: [controlGroupProvider],
            inputs: ['name: ngControlGroup'],
            exportAs: 'ngForm'
        }),
        __param(0, core_1.Host()),
        __param(0, core_1.SkipSelf()),
        __param(1, core_1.Optional()),
        __param(1, core_1.Self()),
        __param(1, core_1.Inject(validators_1.NG_VALIDATORS)),
        __param(2, core_1.Optional()),
        __param(2, core_1.Self()),
        __param(2, core_1.Inject(validators_1.NG_ASYNC_VALIDATORS)), 
        __metadata('design:paramtypes', [control_container_1.ControlContainer, Array, Array])
    ], NgControlGroup);
    return NgControlGroup;
}(control_container_1.ControlContainer));
Beispiel #18
0
var MdMessages = (function () {
    function MdMessages(messages, form) {
        this.messages = messages;
        this.form = form;
        this._unsubscribe = null;
    }
    Object.defineProperty(MdMessages.prototype, "valid", {
        get: function () {
            if (this.property instanceof common_1.NgControlName) {
                var ctrl_1 = this.property;
                return !!ctrl_1.valid;
            }
            var prop = this.property;
            var group = this.form.control;
            var ctrl = group.controls[prop];
            return ctrl && ctrl.valid;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(MdMessages.prototype, "isTouched", {
        get: function () {
            if (this.property instanceof common_1.NgControlName) {
                return this.property.touched;
            }
            var prop = this.property;
            var group = this.form.control;
            var ctrl = group.controls[prop];
            return ctrl && ctrl.touched;
        },
        enumerable: true,
        configurable: true
    });
    MdMessages.prototype.ngOnInit = function () {
        if (this.property instanceof common_1.NgControlName) {
            var ctrl = this.property;
            this.form = ctrl.formDirective;
            this._unsubscribe = ctrl.update.subscribe(this._valueChanged.bind(this));
        }
        else {
            if (!this.form) {
                throw new Error('md-messages cannot bind to text property without a parent NgFormModel');
            }
            var prop = this.property;
            var group = this.form.control;
            if (!group) {
                throw new Error('md-messages cannot bind to text property without a ControlGroup');
            }
            var ctrl = group.controls[prop];
            if (!ctrl) {
                throw new Error("md-messages cannot find property(" + prop + ") in ControlGroup!");
            }
            this._unsubscribe = ctrl.valueChanges.subscribe(this._valueChanged.bind(this));
        }
    };
    MdMessages.prototype.ngOnDestroy = function () {
        this._unsubscribe.unsubscribe();
    };
    MdMessages.prototype._valueChanged = function () {
        var errors = null;
        if (this.property instanceof common_1.NgControlName) {
            var ctrl = this.property;
            errors = ctrl.errors;
        }
        else {
            var prop = this.property;
            var group = this.form.control;
            var ctrl = group.controls[prop];
            errors = ctrl.errors;
        }
        if (errors) {
            this.messages.toArray().forEach(function (m) {
                m.okay = !m.errorKey ? !errors : !lang_1.isPresent(errors[m.errorKey]);
            });
        }
    };
    __decorate([
        core_1.Input('md-messages'), 
        __metadata('design:type', Object)
    ], MdMessages.prototype, "property", void 0);
    MdMessages = __decorate([
        core_1.Directive({
            selector: '[md-messages]',
            host: {
                'md-messages': '',
                '[style.display]': '(valid || !isTouched) ? "none" : "inherit"',
                '[class.md-valid]': 'valid && isTouched',
                '[class.md-invalid]': '!valid && isTouched'
            }
        }),
        __param(0, core_1.Query(MdMessage)),
        __param(1, core_1.Optional()),
        __param(1, core_1.SkipSelf()),
        __param(1, core_1.Host()), 
        __metadata('design:paramtypes', [core_1.QueryList, common_1.NgFormModel])
    ], MdMessages);
    return MdMessages;
}());
Beispiel #19
0
var MdRadioButton = (function () {
    function MdRadioButton(radioGroup, id, value, checked, tabindex, radioDispatcher) {
        var _this = this;
        this.radioGroup = radioGroup;
        this.radioDispatcher = radioDispatcher;
        this.value = value ? value : null;
        this.checked = lang_1.isPresent(checked) ? true : false;
        this.id = lang_1.isPresent(id) ? id : "md-radio-" + _uniqueIdCounter++;
        radioDispatcher.listen(function (name) {
            if (name === _this.name) {
                _this.checked = false;
            }
        });
        if (lang_1.isPresent(radioGroup)) {
            this.name = radioGroup.getName();
            this.radioGroup.register(this);
            if (this.checked) {
                this.radioGroup.updateValue(this.value, this.id);
            }
        }
        if (!lang_1.isPresent(radioGroup)) {
            this.tabindex = util_1.parseTabIndexAttribute(tabindex);
        }
        else {
            this.tabindex = -1;
        }
    }
    MdRadioButton.prototype.ngOnInit = function () {
        if (lang_1.isPresent(this.radioGroup)) {
            this.name = this.radioGroup.getName();
        }
    };
    MdRadioButton.prototype.ngOnDestroy = function () {
        if (lang_1.isPresent(this.radioGroup)) {
            this.radioGroup.unregister(this);
        }
    };
    MdRadioButton.prototype.isDisabled = function () {
        return this.disabled || (lang_1.isPresent(this.disabled) && lang_1.StringWrapper.equals(this.disabled, '')) ||
            (lang_1.isPresent(this.radioGroup) && this.radioGroup.disabled);
    };
    Object.defineProperty(MdRadioButton.prototype, "disabled", {
        get: function () {
            return this.disabled_ || (this.radioGroup && this.radioGroup.disabled);
        },
        set: function (value) {
            this.disabled_ = lang_1.isPresent(value) && value !== false;
        },
        enumerable: true,
        configurable: true
    });
    MdRadioButton.prototype.select = function (event) {
        if (this.isDisabled()) {
            event.stopPropagation();
            return;
        }
        this.radioDispatcher.notify(this.name);
        this.checked = true;
        if (lang_1.isPresent(this.radioGroup)) {
            this.radioGroup.updateValue(this.value, this.id);
        }
    };
    MdRadioButton.prototype.onKeydown = function (event) {
        if (event.keyCode === key_codes_1.KeyCodes.SPACE) {
            event.preventDefault();
            this.select(event);
        }
    };
    MdRadioButton = __decorate([
        core_1.Component({
            selector: 'md-radio-button',
            inputs: ['id', 'name', 'value', 'checked', 'disabled'],
            host: {
                'role': 'radio',
                '[id]': 'id',
                '[tabindex]': 'tabindex',
                '[attr.aria-checked]': 'checked',
                '[attr.disabled]': 'disabled ? "" : undefined',
                '[attr.aria-disabled]': 'disabled',
                '(keydown)': 'onKeydown($event)',
                '(click)': 'select($event)'
            },
            template: "\n    <label role=\"radio\" class=\"md-radio-root\" [class.md-radio-checked]=\"checked\">\n      <div class=\"md-radio-container\">\n        <div class=\"md-radio-off\"></div>\n        <div class=\"md-radio-on\"></div>\n      </div>\n      <div class=\"md-radio-label\">\n        <ng-content></ng-content>\n      </div>\n    </label>",
            directives: [],
            encapsulation: core_1.ViewEncapsulation.None
        }),
        __param(0, core_1.Optional()),
        __param(0, core_1.SkipSelf()),
        __param(0, core_1.Host()),
        __param(1, core_1.Attribute('id')),
        __param(2, core_1.Attribute('value')),
        __param(3, core_1.Attribute('checked')),
        __param(4, core_1.Attribute('tabindex')), 
        __metadata('design:paramtypes', [MdRadioGroup, String, String, String, String, radio_dispatcher_1.MdRadioDispatcher])
    ], MdRadioButton);
    return MdRadioButton;
}());