diff options
Diffstat (limited to 'src/fields/Document.ts')
-rw-r--r-- | src/fields/Document.ts | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/src/fields/Document.ts b/src/fields/Document.ts index 538d4ada9..3f26abbda 100644 --- a/src/fields/Document.ts +++ b/src/fields/Document.ts @@ -34,33 +34,20 @@ export class Document extends Field { } } - public Width = () => { - return this.GetNumber(KeyStore.Width, 0); - }; - public Height = () => { - return this.GetNumber( - KeyStore.Height, - this.GetNumber(KeyStore.NativeWidth, 0) - ? (this.GetNumber(KeyStore.NativeHeight, 0) / - this.GetNumber(KeyStore.NativeWidth, 0)) * - this.GetNumber(KeyStore.Width, 0) - : 0 - ); - }; - public Scale = () => { - return this.GetNumber(KeyStore.Scale, 1); - }; + public Width = () => this.GetNumber(KeyStore.Width, 0) + public Height = () => this.GetNumber(KeyStore.Height, this.GetNumber(KeyStore.NativeWidth, 0) ? (this.GetNumber(KeyStore.NativeHeight, 0) / this.GetNumber(KeyStore.NativeWidth, 0)) * this.GetNumber(KeyStore.Width, 0) : 0); + public Scale = () => this.GetNumber(KeyStore.Scale, 1) @computed public get Title(): string { let title = this.Get(KeyStore.Title, true); if (title) - if (title != FieldWaiting && title instanceof TextField) + if (title !== FieldWaiting && title instanceof TextField) return title.Data; else return "-waiting-"; let parTitle = this.GetT(KeyStore.Title, TextField); if (parTitle) - if (parTitle != FieldWaiting) return parTitle.Data + ".alias"; + if (parTitle !== FieldWaiting) return parTitle.Data + ".alias"; else return "-waiting-.alias"; return "-untitled-"; } @@ -106,7 +93,7 @@ export class Document extends Field { } } else { let doc: FieldValue<Document> = this; - while (doc && doc != FieldWaiting && field != FieldWaiting) { + while (doc && field !== FieldWaiting) { let curField = doc.fields.get(key.Id); let curProxy = doc._proxies.get(key.Id); if (!curField || (curProxy && curField.field.Id !== curProxy)) { @@ -137,7 +124,7 @@ export class Document extends Field { break; } } - if (doc == FieldWaiting) field = FieldWaiting; + if (doc === FieldWaiting) field = FieldWaiting; } return field; @@ -191,7 +178,7 @@ export class Document extends Field { if (callback) { fn(callback); } else { - return new Promise(res => fn(res)); + return new Promise(fn); } } @@ -237,7 +224,7 @@ export class Document extends Field { ignoreProto: boolean = false ): FieldValue<T> { var getfield = this.Get(key, ignoreProto); - if (getfield != FieldWaiting) { + if (getfield !== FieldWaiting) { return Cast(getfield, ctor); } return FieldWaiting; @@ -249,7 +236,7 @@ export class Document extends Field { ignoreProto: boolean = false ): T { const field = this.GetT(key, ctor, ignoreProto); - if (field && field != FieldWaiting) { + if (field && field !== FieldWaiting) { return field; } const newField = new ctor(); @@ -356,7 +343,7 @@ export class Document extends Field { GetAllPrototypes(): Document[] { let protos: Document[] = []; let doc: FieldValue<Document> = this; - while (doc && doc != FieldWaiting) { + while (doc && doc !== FieldWaiting) { protos.push(doc); doc = doc.GetPrototype(); } @@ -401,7 +388,7 @@ export class Document extends Field { let fields: [string, string][] = []; this._proxies.forEach((field, key) => { if (field) { - fields.push([key, field as string]); + fields.push([key, field]); } }); |