From ecd958c04a55a2df5c5033ecdc49a1e6fa3ef933 Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Sun, 4 Jun 2017 07:19:08 +0100 Subject: [PATCH 01/14] Fixed version mismatch Closes #84 --- README.md | 2 +- demo/src/app/pages/getting-started/getting-started.page.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a2de6a3a8..eb9a90e0d 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Now you're good to go! ## Dependencies -* [Angular](https://angular.io) (^4.0.0) +* [Angular](https://angular.io) (^4.1.0) * [Semantic UI CSS](http://semantic-ui.com/) (jQuery is **not** required) ## Components diff --git a/demo/src/app/pages/getting-started/getting-started.page.html b/demo/src/app/pages/getting-started/getting-started.page.html index 8806d559d..c63f1374b 100644 --- a/demo/src/app/pages/getting-started/getting-started.page.html +++ b/demo/src/app/pages/getting-started/getting-started.page.html @@ -33,7 +33,7 @@

Installation

Dependencies

-
Angular (^4.0.0)
+
Angular (^4.1.0)
Semantic UI CSS (jQuery is not required)
From ca50fadd34f1921b99eedb6abf709f70104a509c Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Sun, 4 Jun 2017 07:20:43 +0100 Subject: [PATCH 02/14] Fixed favicon --- demo/src/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/src/index.html b/demo/src/index.html index d25b9ce70..8f0b91a69 100644 --- a/demo/src/index.html +++ b/demo/src/index.html @@ -5,7 +5,7 @@ - + From 9aef10058c4e52cfabdce00f711511811891f6fd Mon Sep 17 00:00:00 2001 From: Ed Carroll Date: Sun, 4 Jun 2017 07:30:10 +0100 Subject: [PATCH 03/14] Stopped global defaults working for popup examples --- demo/src/app/pages/popup/popup.page.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/demo/src/app/pages/popup/popup.page.ts b/demo/src/app/pages/popup/popup.page.ts index 9a19292fa..e58cc8d60 100644 --- a/demo/src/app/pages/popup/popup.page.ts +++ b/demo/src/app/pages/popup/popup.page.ts @@ -1,5 +1,6 @@ -import {Component, Input} from '@angular/core'; +import {Component, Input, OnInit, OnDestroy} from '@angular/core'; import {ApiDefinition} from "../../components/api/api.component"; +import {SuiPopupConfig} from '../../../../../components/popup/popup.service'; const exampleStandardTemplate = ` - + + `; @@ -153,7 +153,7 @@ export class MyComponent { public open(dynamicContent:string = "Example") { const config = new TemplateModalConfig(this.modalTemplate); - config.isClosable = false; + config.closeResult = "closed!"; config.context = { data: dynamicContent }; this.modalService @@ -195,8 +195,8 @@ export class ConfirmModal extends ComponentModalConfig alert("accepted!")) - .onDeny(() => alert("denied!")); + .onApprove(() => alert("User has accepted.")) + .onDeny(() => alert("User has denied.")); `; } @@ -215,13 +215,13 @@ export class ModalExampleTemplate { public open(dynamicContent:string = "Example") { const config = new TemplateModalConfig<{ data:string }, string, string>(this.modalTemplate); - config.isClosable = false; + config.closeResult = "dismissed"; config.context = { data: dynamicContent }; this.modalService .open(config) - .onApprove(r => alert(r)) - .onDeny(r => alert(r)); + .onApprove(r => alert(`Accepted with result: '${r}'.`)) + .onDeny(r => alert(`Denied with result: '${r}'.`)); } } @@ -258,8 +258,8 @@ export class ModalExampleComponent { public open() { this.modalService .open(new ConfirmModal("Are you sure?", "Are you sure about accepting this?")) - .onApprove(() => alert("accepted!")) - .onDeny(() => alert("denied!")); + .onApprove(() => alert("User has accepted.")) + .onDeny(() => alert("User has denied.")); } } From df8a199b059bb425917d09f11fc5c1c4305897d9 Mon Sep 17 00:00:00 2001 From: Edward Carroll Date: Mon, 5 Jun 2017 23:14:05 +0100 Subject: [PATCH 13/14] Commented new modal scrolling functionality --- components/modal/modal.ts | 9 +++++++-- demo/src/app/pages/modal/modal.page.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/modal/modal.ts b/components/modal/modal.ts index 6f9faa90e..d2ec40729 100644 --- a/components/modal/modal.ts +++ b/components/modal/modal.ts @@ -104,6 +104,7 @@ export class SuiModal implements OnInit, AfterViewInit { public set mustScroll(mustScroll:boolean) { this._mustScroll = mustScroll; + // 'Cache' value in _mustAlwaysScroll so that if `true`, _mustScroll isn't ever auto-updated. this._mustAlwaysScroll = mustScroll; this.updateScroll(); } @@ -207,14 +208,18 @@ export class SuiModal implements OnInit, AfterViewInit { } } + // Decides whether the modal needs to reposition to allow scrolling. private updateScroll() { + // Semantic UI modal margin is 3.5rem, which is relative to the global font size, so for compatibility: const fontSize = parseFloat(window.getComputedStyle(document.documentElement, null).getPropertyValue('font-size')); const margin = fontSize * 3.5; - if (this._modalElement) { + // _mustAlwaysScroll works by stopping _mustScroll from being automatically updated, so it stays `true`. + if (!this._mustAlwaysScroll && this._modalElement) { const element = this._modalElement.nativeElement as Element; - this._mustScroll = !this._mustAlwaysScroll && window.innerHeight < element.clientHeight + margin * 2; + // The modal must scroll if the window height is smaller than the modal height + both margins. + this._mustScroll = window.innerHeight < element.clientHeight + margin * 2; } } diff --git a/demo/src/app/pages/modal/modal.page.ts b/demo/src/app/pages/modal/modal.page.ts index 5ddc356fa..e5ec13a45 100644 --- a/demo/src/app/pages/modal/modal.page.ts +++ b/demo/src/app/pages/modal/modal.page.ts @@ -242,6 +242,7 @@ export class ConfirmModal extends ComponentModalConfig Date: Mon, 5 Jun 2017 23:19:27 +0100 Subject: [PATCH 14/14] Removed `mustScroll` from confirm modal demo --- demo/src/app/pages/modal/modal.page.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/demo/src/app/pages/modal/modal.page.ts b/demo/src/app/pages/modal/modal.page.ts index e5ec13a45..5ddc356fa 100644 --- a/demo/src/app/pages/modal/modal.page.ts +++ b/demo/src/app/pages/modal/modal.page.ts @@ -242,7 +242,6 @@ export class ConfirmModal extends ComponentModalConfig