How to use _waitFunction method in chromy

Best JavaScript code snippet using chromy

materialize-directive.js

Source:materialize-directive.js Github

copy

Full Screen

1import { Directive, ElementRef, Input, Output, EventEmitter } from '@angular/core';2import { CustomEvent } from './custom-event-polyfill';3var MaterializeDirective = (function () {4 /**5 * @param {?} _el6 */7 function MaterializeDirective(_el) {8 this._el = _el;9 this._params = null;10 this._functionName = null;11 this.previousValue = null;12 this.previousDisabled = false;13 this._waitFunction = {};14 this.changeListenerShouldBeAdded = true;15 this.init = new EventEmitter();16 this.initialized = false;17 }18 Object.defineProperty(MaterializeDirective.prototype, "materializeParams", {19 /**20 * @param {?} params21 * @return {?}22 */23 set: function (params) {24 this._params = params;25 this.performElementUpdates();26 },27 enumerable: true,28 configurable: true29 });30 Object.defineProperty(MaterializeDirective.prototype, "materializeActions", {31 /**32 * @param {?} actions33 * @return {?}34 */35 set: function (actions) {36 var _this = this;37 actions.subscribe(function (action) {38 window.setTimeout(function () {39 if (typeof action === "string") {40 _this.performLocalElementUpdates(action);41 }42 else {43 _this.performLocalElementUpdates(action.action, action.params);44 }45 }, 1);46 });47 },48 enumerable: true,49 configurable: true50 });51 Object.defineProperty(MaterializeDirective.prototype, "materialize", {52 /**53 * @param {?} functionName54 * @return {?}55 */56 set: function (functionName) {57 this._functionName = functionName;58 },59 enumerable: true,60 configurable: true61 });62 Object.defineProperty(MaterializeDirective.prototype, "materializeSelectOptions", {63 /**64 * @param {?} options65 * @return {?}66 */67 set: function (options) {68 },69 enumerable: true,70 configurable: true71 });72 /**73 * @return {?}74 */75 MaterializeDirective.prototype.ngAfterViewInit = function () {76 this.performElementUpdates();77 };78 /**79 * @param {?=} _unused80 * @return {?}81 */82 MaterializeDirective.prototype.ngOnChanges = function (_unused) {83 var _this = this;84 if (this.isSelect()) {85 setTimeout(function () { return _this.performLocalElementUpdates(); }, 10);86 }87 };88 /**89 * @return {?}90 */91 MaterializeDirective.prototype.ngOnDestroy = function () {92 this.performElementRemotion();93 };94 /**95 * @return {?}96 */97 MaterializeDirective.prototype.ngDoCheck = function () {98 var /** @type {?} */ nativeElement = this._el.nativeElement;99 var /** @type {?} */ jQueryElement = $(nativeElement);100 if (this.isSelect()) {101 var /** @type {?} */ shouldUpdate = false;102 if (nativeElement.disabled != this.previousDisabled) {103 this.previousDisabled = nativeElement.disabled;104 shouldUpdate = true;105 }106 if (!jQueryElement.attr("multiple") && nativeElement.value != this.previousValue) {107 // handle select changes of the model108 this.previousValue = nativeElement.value;109 shouldUpdate = true;110 }111 if (shouldUpdate) {112 this.performLocalElementUpdates();113 }114 }115 else if (this.isTextarea()) {116 if (nativeElement.value != this.previousValue) {117 this.previousValue = nativeElement.value;118 this.performElementUpdates();119 }120 }121 return false;122 };123 /**124 * @return {?}125 */126 MaterializeDirective.prototype.performElementRemotion = function () {127 if (this.isTooltip()) {128 var /** @type {?} */ nativeElement = this._el.nativeElement;129 var /** @type {?} */ jQueryElement = $(nativeElement);130 var /** @type {?} */ tooltipId = jQueryElement.attr('data-tooltip-id');131 if (tooltipId) {132 $('#' + tooltipId).remove();133 }134 }135 };136 /**137 * @return {?}138 */139 MaterializeDirective.prototype.performElementUpdates = function () {140 var _this = this;141 // it should have been created by now, but confirm anyway142 if (Materialize && Materialize.updateTextFields) {143 Materialize.updateTextFields();144 }145 // handle select changes from the HTML146 if (this.isSelect() && this.changeListenerShouldBeAdded) {147 var /** @type {?} */ nativeElement_1 = this._el.nativeElement;148 var /** @type {?} */ jQueryElement = $(nativeElement_1);149 jQueryElement.on("change", function (e) {150 if (!e.originalEvent || !e.originalEvent.internalToMaterialize) {151 var /** @type {?} */ event_1 = document.createEvent("CustomEvent");152 //if (jQueryElement.attr("multiple")) {153 //event.initCustomEvent("input",false,false,undefined);154 //}155 //else {156 event_1.initCustomEvent("change", false, false, undefined);157 //}158 event_1.internalToMaterialize = true;159 nativeElement_1.dispatchEvent(event_1);160 }161 });162 this.changeListenerShouldBeAdded = false;163 }164 if (this.isAutocomplete()) {165 var /** @type {?} */ nativeElement_2 = this._el.nativeElement;166 var /** @type {?} */ jQueryElement = $(nativeElement_2);167 jQueryElement.on("change", function (e) { return nativeElement_2.dispatchEvent(((CustomEvent("input")))); });168 }169 if (this.isDatePicker()) {170 var /** @type {?} */ nativeElement_3 = this._el.nativeElement;171 var /** @type {?} */ jqueryPickerElement_1 = $(nativeElement_3);172 var /** @type {?} */ datePicker = jqueryPickerElement_1[this._functionName].apply(jqueryPickerElement_1, this._params);173 var /** @type {?} */ picker_1 = datePicker.pickadate('picker');174 setTimeout(function () {175 if (_this.ngModel) {176 picker_1.set('select', _this.ngModel);177 }178 else {179 var /** @type {?} */ value = jqueryPickerElement_1.val();180 if (value && value.length > 0) {181 picker_1.set('select', value);182 }183 }184 jqueryPickerElement_1.on('change', function (e) { return nativeElement_3.dispatchEvent(((CustomEvent("input")))); });185 });186 }187 if (this.isTimePicker()) {188 var /** @type {?} */ nativeElement_4 = this._el.nativeElement;189 var /** @type {?} */ jqueryPickerElement_2 = $(nativeElement_4);190 var /** @type {?} */ timePicker = jqueryPickerElement_2[this._functionName].apply(jqueryPickerElement_2, this._params);191 var /** @type {?} */ picker_2 = timePicker.pickatime('picker');192 setTimeout(function () {193 if (_this.ngModel) {194 picker_2.val(_this.ngModel);195 }196 else {197 picker_2.val(jqueryPickerElement_2.val());198 }199 jqueryPickerElement_2.on('change', function (e) { return nativeElement_4.dispatchEvent(((CustomEvent("input")))); });200 });201 }202 if (this.isChips()) {203 var /** @type {?} */ nativeElement_5 = this._el.nativeElement;204 var /** @type {?} */ jQueryElement = $(nativeElement_5);205 jQueryElement.on("chip.add", function (e, chip) { return nativeElement_5.dispatchEvent(((CustomEvent("chip.add", chip)))); });206 jQueryElement.on("chip.delete", function (e, chip) { return nativeElement_5.dispatchEvent(((CustomEvent("chip.delete", chip)))); });207 jQueryElement.on("chip.select", function (e, chip) { return nativeElement_5.dispatchEvent(((CustomEvent("chip.select", chip)))); });208 }209 if (this.isTextarea()) {210 this._el.nativeElement.dispatchEvent(((CustomEvent("autoresize", {211 bubbles: true,212 cancelable: false,213 detail: undefined214 }))));215 }216 this.performLocalElementUpdates();217 };218 /**219 * @param {?=} functionName220 * @param {?=} params221 * @return {?}222 */223 MaterializeDirective.prototype.performLocalElementUpdates = function (functionName, params) {224 var _this = this;225 if (functionName === void 0) { functionName = this._functionName; }226 if (params === void 0) { params = this._params; }227 if (this._waitFunction[functionName]) {228 return;229 }230 this._waitFunction[functionName] = true;231 $(document).ready(function () {232 _this._waitFunction[functionName] = false;233 if (functionName) {234 var /** @type {?} */ jQueryElement = $(_this._el.nativeElement);235 if (jQueryElement[functionName]) {236 if (params) {237 if (params instanceof Array) {238 jQueryElement[functionName].apply(jQueryElement, params);239 }240 else {241 throw new Error("Params has to be an array.");242 }243 }244 else {245 jQueryElement[functionName]();246 }247 }248 else {249 // fallback to running this function on the global Materialize object250 if (Materialize[functionName]) {251 if (params) {252 if (params instanceof Array) {253 Materialize[functionName].apply(Materialize, params);254 }255 else {256 throw new Error("Params has to be an array.");257 }258 }259 else {260 Materialize[functionName]();261 }262 }263 else {264 throw new Error("Couldn't find materialize function ''" + functionName + "' on element or the global Materialize object.");265 }266 }267 if (!_this.initialized) {268 _this.initialized = true;269 _this.init.emit();270 }271 }272 });273 };274 /**275 * @return {?}276 */277 MaterializeDirective.prototype.isTooltip = function () {278 return (this._functionName && this._functionName === "tooltip");279 };280 /**281 * @return {?}282 */283 MaterializeDirective.prototype.isSelect = function () {284 return (this._functionName && this._functionName === "material_select");285 };286 /**287 * @return {?}288 */289 MaterializeDirective.prototype.isDatePicker = function () {290 return (this._functionName && this._functionName === "pickadate");291 };292 /**293 * @return {?}294 */295 MaterializeDirective.prototype.isTimePicker = function () {296 return (this._functionName && this._functionName === "pickatime");297 };298 /**299 * @return {?}300 */301 MaterializeDirective.prototype.isChips = function () {302 return (this._functionName && this._functionName === "material_chip");303 };304 /**305 * @return {?}306 */307 MaterializeDirective.prototype.isAutocomplete = function () {308 return (this._functionName && this._functionName === "autocomplete");309 };310 /**311 * @return {?}312 */313 MaterializeDirective.prototype.isTextarea = function () {314 return this._el.nativeElement.nodeName == "TEXTAREA";315 };316 /**317 * @return {?}318 */319 MaterializeDirective.prototype.enableDPButtons = function () {320 $('.picker__clear').removeAttr("disabled");321 $('.picker__today').removeAttr("disabled");322 $('.picker__close').removeAttr("disabled");323 $('.picker__select--year').removeAttr("disabled");324 $('.picker__select--month').removeAttr("disabled");325 };326 return MaterializeDirective;327}());328export { MaterializeDirective };329MaterializeDirective.decorators = [330 { type: Directive, args: [{331 selector: '[materialize]'332 },] },333];334/**335 * @nocollapse336 */337MaterializeDirective.ctorParameters = function () { return [338 { type: ElementRef, },339]; };340MaterializeDirective.propDecorators = {341 'init': [{ type: Output },],342 'materializeParams': [{ type: Input },],343 'materializeActions': [{ type: Input },],344 'materialize': [{ type: Input },],345 'materializeSelectOptions': [{ type: Input },],346 'ngModel': [{ type: Input },],347};348function MaterializeDirective_tsickle_Closure_declarations() {349 /** @type {?} */350 MaterializeDirective.decorators;351 /**352 * @nocollapse353 * @type {?}354 */355 MaterializeDirective.ctorParameters;356 /** @type {?} */357 MaterializeDirective.propDecorators;358 /** @type {?} */359 MaterializeDirective.prototype._params;360 /** @type {?} */361 MaterializeDirective.prototype._functionName;362 /** @type {?} */363 MaterializeDirective.prototype.previousValue;364 /** @type {?} */365 MaterializeDirective.prototype.previousDisabled;366 /** @type {?} */367 MaterializeDirective.prototype._waitFunction;368 /** @type {?} */369 MaterializeDirective.prototype.changeListenerShouldBeAdded;370 /** @type {?} */371 MaterializeDirective.prototype.init;372 /** @type {?} */373 MaterializeDirective.prototype.initialized;374 /** @type {?} */375 MaterializeDirective.prototype.ngModel;376 /** @type {?} */377 MaterializeDirective.prototype._el;...

Full Screen

Full Screen

materialize-directive.ts

Source:materialize-directive.ts Github

copy

Full Screen

1import {2 Directive,3 ElementRef,4 Input,5 Output,6 DoCheck,7 OnChanges,8 OnDestroy,9 AfterViewInit,10 EventEmitter11} from '@angular/core';12import {CustomEvent} from "./custom-event-polyfill";13declare var $:any;14declare var Materialize:any;15// export type MaterializeOptions =16 // "collapsible" |17 // "dropdown" |18 // "materialbox" |19 // "tabs" |20 // "tooltip" |21 // "characterCounter" |22 // "material_select" |23 // "sideNav" |24 // "modal";25export interface MaterializeAction {26 action:string;27 params:[any];28}29@Directive({30 selector: '[materialize]'31})32export class MaterializeDirective implements AfterViewInit,DoCheck,OnChanges,OnDestroy {33 private _params:[any] = null;34 private _functionName:string = null;35 private previousValue = null;36 private previousDisabled = false;37 private _waitFunction: any = { };38 private changeListenerShouldBeAdded = true;39 @Output() public init = new EventEmitter<void>();40 private initialized = false;41 constructor(private _el: ElementRef) { }42 @Input() public set materializeParams(params:any) {43 this._params = params;44 this.performElementUpdates();45 }46 @Input() public set materializeActions(actions:EventEmitter<string|MaterializeAction>) {47 actions.subscribe((action:string|MaterializeAction) => {48 if (typeof action === "string") {49 this.performLocalElementUpdates(action);50 } else {51 this.performLocalElementUpdates(action.action,action.params);52 }53 })54 }55 @Input() public set materialize(functionName:string) {56 this._functionName = functionName;57 }58 // this is here to trigger change detection for select elements59 @Input() public set materializeSelectOptions(options:any) { }60 //used for the datepicker at the moment61 @Input() ngModel;62 public ngAfterViewInit() {63 this.performElementUpdates();64 }65 public ngOnChanges(_unused?) {66 if (this.isSelect()) {67 setTimeout(() => this.performLocalElementUpdates(), 10);68 }69 }70 public ngOnDestroy() {71 this.performElementRemotion();72 }73 public ngDoCheck() {74 const nativeElement = this._el.nativeElement;75 const jQueryElement = $(nativeElement);76 if (this.isSelect()) {77 let shouldUpdate = false;78 if (nativeElement.disabled != this.previousDisabled) {79 this.previousDisabled = nativeElement.disabled;80 shouldUpdate = true;81 }82 if (!jQueryElement.attr("multiple") && nativeElement.value!=this.previousValue) {83 // handle select changes of the model84 this.previousValue = nativeElement.value;85 shouldUpdate = true;86 }87 if (shouldUpdate) {88 this.performLocalElementUpdates();89 }90 } else if (this.isTextarea()) {91 if (nativeElement.value!=this.previousValue) {92 this.previousValue = nativeElement.value;93 this.performElementUpdates();94 }95 }96 return false;97 }98 private performElementRemotion() {99 if (this.isTooltip()) {100 const nativeElement = this._el.nativeElement;101 const jQueryElement = $(nativeElement);102 const tooltipId = jQueryElement.attr('data-tooltip-id');103 if (tooltipId) {104 $('#' + tooltipId).remove();105 }106 }107 }108 private performElementUpdates() {109 // it should have been created by now, but confirm anyway110 if (Materialize && Materialize.updateTextFields) {111 Materialize.updateTextFields();112 }113 // handle select changes from the HTML114 if (this.isSelect() && this.changeListenerShouldBeAdded) {115 const nativeElement = this._el.nativeElement;116 const jQueryElement = $(nativeElement);117 jQueryElement.on("change", e => {118 if (!e.originalEvent || !e.originalEvent.internalToMaterialize) {119 const event:any = document.createEvent("CustomEvent");120 //if (jQueryElement.attr("multiple")) {121 //event.initCustomEvent("input",false,false,undefined);122 //}123 //else {124 event.initCustomEvent("change",false,false,undefined);125 //}126 event.internalToMaterialize = true;127 nativeElement.dispatchEvent(event);128 }129 });130 this.changeListenerShouldBeAdded = false;131 }132 if (this.isAutocomplete()) {133 const nativeElement = this._el.nativeElement;134 const jQueryElement = $(nativeElement);135 jQueryElement.on("change", e => nativeElement.dispatchEvent((<any>CustomEvent("input"))));136 }137 if (this.isDatePicker()) {138 const nativeElement = this._el.nativeElement;139 const jqueryPickerElement = $(nativeElement);140 const datePicker = jqueryPickerElement[this._functionName](...this._params);141 const picker = datePicker.pickadate('picker');142 setTimeout(() => {143 picker.set('select', this.ngModel);144 jqueryPickerElement.on('change', e => nativeElement.dispatchEvent(new Event('input')));145 });146 }147 if (this.isTimePicker()) {148 const nativeElement = this._el.nativeElement;149 const jQueryElement = $(nativeElement);150 jQueryElement.on("change", e => nativeElement.dispatchEvent((<any>CustomEvent("input"))));151 }152 if (this.isChips()) {153 const nativeElement = this._el.nativeElement;154 const jQueryElement = $(nativeElement);155 jQueryElement.on("chip.add", (e,chip) => nativeElement.dispatchEvent((<any>CustomEvent("chip.add",chip))));156 jQueryElement.on("chip.delete", (e,chip) => nativeElement.dispatchEvent((<any>CustomEvent("chip.delete",chip))));157 jQueryElement.on("chip.select", (e,chip) => nativeElement.dispatchEvent((<any>CustomEvent("chip.select",chip))));158 }159 if (this.isTextarea()) {160 this._el.nativeElement.dispatchEvent((<any>CustomEvent("autoresize", {bubbles: true, cancelable: false, detail: undefined})));161 }162 this.performLocalElementUpdates();163 }164 private performLocalElementUpdates(functionName=this._functionName, params=this._params) {165 if (this._waitFunction[functionName]) {166 return;167 }168 this._waitFunction[functionName] = true;169 $(document).ready(() => {170 this._waitFunction[functionName] = false;171 if (functionName) {172 const jQueryElement = $(this._el.nativeElement);173 if (jQueryElement[functionName]) {174 if (params) {175 if (params instanceof Array) {176 jQueryElement[functionName](...params);177 } else {178 throw new Error("Params has to be an array.");179 }180 } else {181 jQueryElement[functionName]();182 }183 } else {184 // fallback to running this function on the global Materialize object185 if (Materialize[functionName]) {186 if (params) {187 if (params instanceof Array) {188 Materialize[functionName](...params);189 } else {190 throw new Error("Params has to be an array.");191 }192 } else {193 Materialize[functionName]();194 }195 } else {196 throw new Error("Couldn't find materialize function ''" + functionName + "' on element or the global Materialize object.");197 }198 }199 if (!this.initialized) {200 this.initialized = true;201 this.init.emit();202 }203 }204 });205 }206 private isTooltip(){207 return (this._functionName && this._functionName === "tooltip");208 }209 private isSelect() {210 return (this._functionName && this._functionName === "material_select");211 }212 private isDatePicker() {213 return (this._functionName && this._functionName === "pickadate");214 }215 private isTimePicker() {216 return (this._functionName && this._functionName === "pickatime");217 }218 private isChips() {219 return (this._functionName && this._functionName === "material_chip");220 }221 private isAutocomplete() {222 return (this._functionName && this._functionName === "autocomplete");223 }224 private isTextarea() {225 return this._el.nativeElement.nodeName == "TEXTAREA";226 }227 private enableDPButtons(){228 $('.picker__clear').removeAttr("disabled");229 $('.picker__today').removeAttr("disabled");230 $('.picker__close').removeAttr("disabled");231 $('.picker__select--year').removeAttr("disabled");232 $('.picker__select--month').removeAttr("disabled");233 }...

Full Screen

Full Screen

ng-materializecss.directive.ts

Source:ng-materializecss.directive.ts Github

copy

Full Screen

1import2 {3 AfterViewInit,4 Directive,5 DoCheck,6 ElementRef,7 EventEmitter, Input,8 OnChanges,9 OnDestroy,10 Output11 } from "@angular/core";12import { CustomEvent } from './custom-event-polyfill';13declare var $: any;14declare var M: any;15export interface NgMaterializecssAction16{17 action: string;18 params: any;19}20@Directive({21 selector: '[materialize]'22})23export class NgMaterializecssDirective implements AfterViewInit, DoCheck, OnChanges, OnDestroy24{25 private _params: any[] = [];26 private _functionName: string = '';27 private previousValue: any = null;28 private previousDisabled: boolean = false;29 private _waitFunction: any = {};30 private changeListenerShouldBeAdded: boolean = true;31 @Output() public init = new EventEmitter<void>();32 private initialized = false;33 constructor (private _el: ElementRef)34 {35 }36 37 @Input()38 public set materializeParams(params: any)39 {40 this._params = params;41 this.performElementUpdates();42 }43 44 @Input()45 public set materializeActions(actions: EventEmitter<string | NgMaterializecssAction>)46 {47 actions.subscribe((action: string | NgMaterializecssAction) =>48 {49 window.setTimeout(() =>50 {51 if (typeof action === "string")52 {53 this.performLocalElementUpdates(action);54 } else55 {56 this.performLocalElementUpdates(action.action, action.params);57 }58 }, 1);59 })60 }61 @Input()62 public set materialize(functionName: string)63 {64 this._functionName = functionName;65 }66 // this is here to trigger change detection for select elements67 @Input()68 public set materializeSelectOptions(options: any)69 {70 }71 //used for the datepicker at the moment72 @Input() ngModel:any;73 public ngAfterViewInit()74 {75 this.performElementUpdates();76 }77 public ngOnChanges(_unused?:any)78 {79 if (this.isSelect())80 {81 setTimeout(() => this.performLocalElementUpdates(), 30);82 }83 }84 public ngOnDestroy()85 {86 this.performElementRemotion();87 }88 public ngDoCheck()89 {90 const nativeElement = this._el.nativeElement;91 const jQueryElement = $(nativeElement);92 if (this.isSelect())93 {94 let shouldUpdate = false;95 if (nativeElement.disabled != this.previousDisabled)96 {97 this.previousDisabled = nativeElement.disabled;98 shouldUpdate = true;99 }100 if (!jQueryElement.attr("multiple") && nativeElement.value != this.previousValue)101 {102 // handle select changes of the model103 this.previousValue = nativeElement.value;104 shouldUpdate = true;105 }106 if (shouldUpdate)107 {108 this.performLocalElementUpdates();109 }110 } else if (this.isTextarea())111 {112 if (nativeElement.value != this.previousValue)113 {114 this.previousValue = nativeElement.value;115 this.performElementUpdates();116 }117 }118 return false;119 }120 private performElementRemotion()121 {122 if (this.isTooltip())123 {124 const nativeElement = this._el.nativeElement;125 const jQueryElement = $(nativeElement);126 const tooltipId = jQueryElement.attr('data-tooltip-id');127 if (tooltipId)128 {129 $('#' + tooltipId).remove();130 }131 }132 }133 private performElementUpdates()134 {135 // it should have been created by now, but confirm anyway136 if (M && M.updateTextFields)137 {138 M.updateTextFields();139 }140 // handle select changes from the HTML141 if (this.isSelect() && this.changeListenerShouldBeAdded)142 {143 const nativeElement = this._el.nativeElement;144 const jQueryElement = $(nativeElement);145 jQueryElement.on("change", (e:Event|any) =>146 {147 if (!e.originalEvent || !e.originalEvent.internalToMaterialize)148 {149 const event: any = document.createEvent("CustomEvent");150 //if (jQueryElement.attr("multiple")) {151 //event.initCustomEvent("input",false,false,undefined);152 //}153 //else {154 event.initCustomEvent("change", false, false, undefined);155 //}156 event.internalToMaterialize = true;157 nativeElement.dispatchEvent(event);158 }159 });160 this.changeListenerShouldBeAdded = false;161 }162 if (this.isAutocomplete())163 {164 const nativeElement = this._el.nativeElement;165 const jQueryElement = $(nativeElement);166 jQueryElement.on("change", (e:any) => nativeElement.dispatchEvent((<any>CustomEvent("input"))));167 }168 if (this.isDatePicker())169 {170 const nativeElement = this._el.nativeElement;171 const jqueryPickerElement = $(nativeElement);172 const datePicker = jqueryPickerElement[this._functionName](...this._params as any[]);173 const picker = datePicker.pickadate('picker');174 setTimeout(() =>175 {176 if (this.ngModel)177 { // PR 292 - 1178 picker.set('select', this.ngModel);179 } else180 {181 const value = jqueryPickerElement.val();182 if (value && value.length > 0)183 {184 picker.set('select', value);185 }186 }187 jqueryPickerElement.on('change', (e: any) => nativeElement.dispatchEvent((<any>CustomEvent("input"))));188 });189 }190 if (this.isTimePicker())191 {192 const nativeElement = this._el.nativeElement;193 const jqueryPickerElement = $(nativeElement);194 const timePicker = jqueryPickerElement[this._functionName](...this._params as any[]);195 const picker = timePicker.pickatime('picker');196 setTimeout(() =>197 {198 if (this.ngModel)199 {200 picker.val(this.ngModel);201 } else202 {203 picker.val(jqueryPickerElement.val());204 }205 jqueryPickerElement.on('change', (e: any) => nativeElement.dispatchEvent((<any>CustomEvent("input"))));206 });207 }208 if (this.isChips())209 {210 const nativeElement = this._el.nativeElement;211 const jQueryElement = $(nativeElement);212 jQueryElement.on("chip.add", (e:any, chip: any) => nativeElement.dispatchEvent((<any>CustomEvent("chip.add", chip))));213 jQueryElement.on("chip.delete", (e:any, chip: any) => nativeElement.dispatchEvent((<any>CustomEvent("chip.delete", chip))));214 jQueryElement.on("chip.select", (e:any, chip: any) => nativeElement.dispatchEvent((<any>CustomEvent("chip.select", chip))));215 }216 if (this.isTextarea())217 {218 this._el.nativeElement.dispatchEvent((CustomEvent("autoresize", {219 bubbles: true,220 cancelable: false,221 detail: undefined222 })));223 }224 this.performLocalElementUpdates();225 }226 private performLocalElementUpdates(functionName = this._functionName, params = this._params)227 {228 if (this._waitFunction[functionName])229 {230 return;231 }232 this._waitFunction[functionName] = true;233 $(document).ready(() =>234 {235 this._waitFunction[functionName] = false;236 if (functionName)237 {238 const jQueryElement = $(this._el.nativeElement);239 if (jQueryElement[functionName])240 {241 if (params)242 {243 if (params instanceof Array)244 {245 jQueryElement[functionName](...params);246 } else247 {248 throw new Error("Params has to be an array.");249 }250 } else251 {252 jQueryElement[functionName]();253 }254 } else255 {256 // fallback to running this function on the global Materialize object257 if (M[functionName])258 {259 if (params)260 {261 if (params instanceof Array)262 {263 new M[functionName](this._el.nativeElement, ...params);264 } else265 {266 throw new Error("Params has to be an array.");267 }268 } else269 {270 new M[functionName](this._el);271 }272 } else273 {274 throw new Error("Couldn't find materialize function ''" + functionName + "' on element or the global Materialize object.");275 }276 }277 if (!this.initialized)278 {279 this.initialized = true;280 this.init.emit();281 }282 }283 });284 }285 286 private isTooltip()287 {288 return (this._functionName && this._functionName === "tooltip");289 }290 291 private isSelect()292 {293 return (this._functionName && this._functionName === "material_select");294 }295 296 private isDatePicker()297 {298 return (this._functionName && this._functionName === "pickadate");299 }300 301 private isTimePicker()302 {303 return (this._functionName && this._functionName === "pickatime");304 }305 306 private isChips()307 {308 return (this._functionName && this._functionName === "material_chip");309 }310 311 private isAutocomplete()312 {313 return (this._functionName && this._functionName === "autocomplete");314 }315 316 private isTextarea()317 {318 return this._el.nativeElement.nodeName == "TEXTAREA";319 }320 321 private enableDPButtons()322 {323 $('.picker__clear').removeAttr("disabled");324 $('.picker__today').removeAttr("disabled");325 $('.picker__close').removeAttr("disabled");326 $('.picker__select--year').removeAttr("disabled");327 $('.picker__select--month').removeAttr("disabled");328 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var chromy = new Chromy({visible: true});2chromy.chain()3 .wait(5000)4 .evaluate(function() {5 return document.title;6 })7 .result(function(title) {8 console.log(title);9 })10 .end()11 .then(function() {12 console.log('Done!');13 });14var chromy = new Chromy({visible: true});15chromy.chain()16 .wait('#hplogo')17 .evaluate(function() {18 return document.title;19 })20 .result(function(title) {21 console.log(title);22 })23 .end()24 .then(function() {25 console.log('Done!');26 });27var chromy = new Chromy({visible: true});28chromy.chain()29 .wait('#hplogo')30 .evaluate(function() {31 return document.title;32 })33 .result(function(title) {34 console.log(title);35 })36 .end()37 .then(function() {38 console.log('Done!');39 });40var chromy = new Chromy({visible: true});41chromy.chain()42 .wait('#hplogo')43 .evaluate(function() {44 return document.title;45 })46 .result(function(title) {47 console.log(title);48 })49 .end()50 .then(function() {51 console.log('Done!');52 });53var chromy = new Chromy({visible: true});54chromy.chain()55 .wait('#hplogo')56 .evaluate(function() {57 return document.title;58 })59 .result(function(title) {60 console.log(title);

Full Screen

Using AI Code Generation

copy

Full Screen

1const chromy = new Chromy({waitTimeout: 2000, visible: true});2chromy.chain()3 .type('input[name="q"]', 'Chrome')4 .click('input[value="Google Search"]')5 .wait('h3')6 .evaluate(() => {7 return document.querySelectorAll('h3').length;8 })9 .result((r) => {10 console.log(r);11 })12 .end()13 .then(() => {14 chromy.close();15 });16const chromy = new Chromy({waitTimeout: 2000, visible: true});17chromy.chain()18 .type('input[name="q"]', 'Chrome')19 .click('input[value="Google Search"]')20 .wait('h3')21 .evaluate(() => {22 return document.querySelectorAll('h3').length;23 })24 .result((r) => {25 console.log(r);26 })27 .end()28 .then(() => {29 chromy.close();30 });

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy._waitFunction(function() {2 return document.querySelector('#someElement');3});4chromy._waitFunction(function() {5 return document.querySelector('#someElement');6}, {timeout: 1000, interval: 100});7chromy._waitUntilVisible('#someElement');8chromy._waitUntilNotVisible('#someElement');9chromy._waitUntilEnabled('#someElement');

Full Screen

Using AI Code Generation

copy

Full Screen

1var chromy = require('chromy');2chromy._waitFunction('return document.readyState == "complete"');3chromy._waitFunction('return document.readyState == "interactive"');4chromy._waitFunction('return document.readyState == "loading"');5chromy._waitFunction('return document.readyState == "loaded"');6var chromy = require('chromy');7chromy._waitFunction('return document.readyState == "complete"');8chromy._waitFunction('return document.readyState == "interactive"');9chromy._waitFunction('return document.readyState == "loading"');10chromy._waitFunction('return document.readyState == "loaded"');11var chromy = require('chromy');12chromy._waitFunction('return document.readyState == "complete"');13chromy._waitFunction('return document.readyState == "interactive"');14chromy._waitFunction('return document.readyState == "loading"');15chromy._waitFunction('return document.readyState == "loaded"');16var chromy = require('chromy');17chromy._waitFunction('return document.readyState == "complete"');18chromy._waitFunction('return document.readyState == "interactive"');19chromy._waitFunction('return document.readyState == "loading"');20chromy._waitFunction('return document.readyState == "loaded"');21var chromy = require('chromy');22chromy._waitFunction('return document.readyState == "complete"');23chromy._waitFunction('return document.readyState == "interactive"');24chromy._waitFunction('return document.readyState == "loading"');25chromy._waitFunction('return document.readyState == "loaded"');

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy._waitFunction(function() {2 return document.querySelector('body').innerText.indexOf('Hello World') !== -13})4chromy._wait(function() {5 return document.querySelector('body').innerText.indexOf('Hello World') !== -16})7chromy._wait(() => {8 return document.querySelector('body').innerText.indexOf('Hello World') !== -19})10chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1)11chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, 5000)12chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000')13chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')14chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, 5000, 'Hello World')15chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')16chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')17chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')18chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')19chromy._wait(() => document.querySelector('body').innerText.indexOf('Hello World') !== -1, '5000', 'Hello World')20chromy._wait(()

Full Screen

Using AI Code Generation

copy

Full Screen

1const chromy = new Chromy()2 .wait(function () {3 return document.querySelector('h1').textContent === 'Example Domain'4 }, 10000)5 .end()6 .then(function () {7 console.log('done')8 })9 .catch(function (err) {10 console.log(err)11 })12chromy.close()

Full Screen

Using AI Code Generation

copy

Full Screen

1chromy._waitFunction(function() {2 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;3}, 1000, 10000);4chromy._waitFunction(function() {5 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;6}, 1000, 10000);7chromy._waitFunction(function() {8 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;9}, 1000, 10000);10chromy._waitFunction(function() {11 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;12}, 1000, 10000);13chromy._waitFunction(function() {14 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;15}, 1000, 10000);16chromy._waitFunction(function() {17 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;18}, 1000, 10000);19chromy._waitFunction(function() {20 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;21}, 1000, 10000);22chromy._waitFunction(function() {23 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;24}, 1000, 10000);25chromy._waitFunction(function() {26 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;27}, 1000, 10000);28chromy._waitFunction(function() {29 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;30}, 1000, 10000);31chromy._waitFunction(function() {32 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;33}, 1000, 10000);34chromy._waitFunction(function() {35 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;36}, 1000, 10000);37chromy._waitFunction(function() {38 return document.querySelector('body').innerText.indexOf('Hello world') !== -1;39}, 1000, 10000);

Full Screen

Using AI Code Generation

copy

Full Screen

1const chromy = require('chromy')2async function run() {3 const chromy = new Chromy()4 await chromy.wait(() => document.querySelector('h1').innerText === 'Example Domain')5 await chromy.screenshot('example.png')6 await chromy.close()7}8run()9const chromy = require('chromy')10async function run() {11 const chromy = new Chromy()12 await chromy.wait(() => document.querySelector('h1').innerText === 'Example Domain')13 await chromy.screenshot('example.png')14 await chromy.close()15}16run()17const chromy = require('chromy')18async function run() {19 const chromy = new Chromy()20 await chromy.wait(() => document.querySelector('h1').innerText

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run chromy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful