Skip to content

Commit

Permalink
Add factory method Modal#build(...) (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper committed Aug 4, 2016
1 parent 165981d commit c82ae77
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
3 changes: 3 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,8 @@ Use the `Modal`-object to display content as modal windows (in front of all othe
```java
class Modal implements Identifiable

static Modal build(Map<String, AnyObject> properties)

property Point origin
property double duration
property double weight
Expand All @@ -431,6 +433,7 @@ class Modal implements Identifiable
end
```

- `build(Map<String, AnyObject> properties)` builds a modal with the specified properties and returns it, `origin` should be a function that receives the frame for the modal as the only argument and returns a `Point`-object which will be set as the origin
- `origin` dynamic property for the origin of the modal, the enclosed properties are read-only so you must pass an object for this property, by default `(0, 0)`
- `duration` property for the duration (in seconds) before automatically closing the modal, if the duration is set to `0` the modal will remain open until closed, by default `0`
- `weight` dynamic property for the weight of the modal (in points), by default `24`
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Release: dd.mm.yyyy

#### Modal

- New: Function `build(Map<String, AnyObject> properties)` builds a modal with the specified properties and returns it, `origin` should be a function that receives the frame for the modal as the only argument and returns a `Point`-object which will be set as the origin ([#126](https://github.com/kasper/phoenix/issues/126)).
- New: Dynamic property `weight` defines the weight of the modal (in points), by default `24` ([#126](https://github.com/kasper/phoenix/issues/126)).
- New: Property `appearance` defines the appearance of the modal (`dark|light|transparent`), by default `dark` ([#126](https://github.com/kasper/phoenix/issues/126)).
- New: Dynamic property `icon` defines the icon displayed in the modal ([#126](https://github.com/kasper/phoenix/issues/126)).
Expand Down
2 changes: 1 addition & 1 deletion Phoenix/phoenix-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions jshint.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
"unused": true,
"validthis": true,
"globals": {
"_": true,
"Event": true,
"Key": true,
"Modal": true,
"Task": true,
"Timer": true,
"Window": true
Expand Down
15 changes: 15 additions & 0 deletions library/src/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

/* Modal */

(function (scope) {

scope.build = function (properties) {
var modal = new Modal();
_(properties).chain().omit('origin').each(function (value, key) {
modal[key] = value;
});
modal.origin = properties.origin(modal.frame());
return modal;
}
})(Modal);

0 comments on commit c82ae77

Please sign in to comment.