Skip to content

Commit 08d2e7b

Browse files
authored
Merge pull request #1 from samber/feat-merge-last-prs
Merges PRs from inital repo
2 parents 9bd4534 + 49c0faf commit 08d2e7b

File tree

11 files changed

+136
-110
lines changed

11 files changed

+136
-110
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Angular2 Materialize
22

3-
[![travis build](https://img.shields.io/travis/InfomediaLtd/angular2-materialize.svg?style=flat-square)](https://travis-ci.org/InfomediaLtd/angular2-materialize)
4-
[![version](https://img.shields.io/npm/v/angular2-materialize.svg?style=flat-square)](https://www.npmjs.com/package/angular2-materialize)
5-
[![downloads](https://img.shields.io/npm/dm/angular2-materialize.svg?style=flat-square)](https://www.npmjs.com/package/angular2-materialize)
6-
[![MIT Licence](https://img.shields.io/npm/l/angular2-materialize.svg?style=flat-square)](https://opensource.org/licenses/MIT)
3+
**This repo is a fork from [InfomediaLtd/angular2-materialize](https://github.com/InfomediaLtd/angular2-materialize) that is not maintained on a regular basis.**
4+
5+
[![travis build](https://img.shields.io/travis/samber/angular2-materialize.svg?style=flat-square)](https://travis-ci.org/samber/angular2-materialize)
6+
[![version](https://img.shields.io/npm/v/@samuelberthe/angular2-materialize.svg?style=flat-square)](https://www.npmjs.com/package/@samuelberthe/angular2-materialize)
7+
[![downloads](https://img.shields.io/npm/dm/@samuelberthe/angular2-materialize.svg?style=flat-square)](https://www.npmjs.com/package/@samuelberthe/angular2-materialize)
8+
[![MIT Licence](https://img.shields.io/npm/l/@samuelberthe/angular2-materialize.svg?style=flat-square)](https://opensource.org/licenses/MIT)
79
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
810
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
911
[![PRs Welcome](https://img.shields.io/badge/prs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
1012

11-
[![NPM](https://nodei.co/npm/angular2-materialize.png?downloads=true)](https://www.npmjs.com/package/angular2-materialize)
12-
[![NPM](https://nodei.co/npm-dl/angular2-materialize.png?height=2&months=12)](https://www.npmjs.com/package/angular2-materialize)
13+
[![NPM](https://nodei.co/npm/@samuelberthe/angular2-materialize.png?downloads=true)](https://www.npmjs.com/package/@samuelberthe/angular2-materialize)
14+
[![NPM](https://nodei.co/npm-dl/@samuelberthe/angular2-materialize.png?height=2&months=12)](https://www.npmjs.com/package/@samuelberthe/angular2-materialize)
1315

1416
Angular 2 support for Materialize CSS framework [http://materializecss.com/](http://materializecss.com/)
1517

@@ -70,14 +72,14 @@ Apply an empty [MaterializeDirective](https://github.com/InfomediaLtd/angular2-m
7072
</form>
7173
```
7274

73-
The [MaterializeDirective](https://github.com/InfomediaLtd/angular2-materialize/blob/master/src/materialize-directive.ts) attribute directive (**materialize**) accepts any MaterializeCSS initialization call to apply to the element. The list of supported functions are provided by MaterializeCSS. Examples: collapsible, modal, tooltip, dropdown, tabs, material_select, sideNav, etc.
75+
The [MaterializeDirective](https://github.com/@samuelberthe/angular2-materialize/blob/master/src/materialize-directive.ts) attribute directive (**materialize**) accepts any MaterializeCSS initialization call to apply to the element. The list of supported functions are provided by MaterializeCSS. Examples: collapsible, modal, tooltip, dropdown, tabs, material_select, sideNav, etc.
7476

7577
For example, to apply tooltip:
7678
```html
7779
<a materialize="tooltip" class="btn tooltipped" data-position="bottom" data-delay="50" data-tooltip="I am tooltip">Hover me!</a>
7880
```
7981

80-
The [Materialize](https://github.com/InfomediaLtd/angular2-materialize/blob/master/src/materialize.ts) attribute directive also allows specifying parameters to be passed to the function, but providing a **materializeParams** attribute returning an array of params. Use it with a function call or even by inlining the params in the HTML.
82+
The [Materialize](https://github.com/@samuelberthe/angular2-materialize/blob/master/src/materialize.ts) attribute directive also allows specifying parameters to be passed to the function, but providing a **materializeParams** attribute returning an array of params. Use it with a function call or even by inlining the params in the HTML.
8183

8284
Another useful option is emitting actions on an element. You may want to do that for calling Materialize functions, like closing a modal dialog or triggering a toast. You can do that by setting the **materializeActions** attribute, which accepts an [EventEmitter](https://angular.io/docs/ts/latest/api/core/index/EventEmitter-class.html). The emitted events can either be a "string" type action (Materialize function call) or a structure with action and parameters:
8385

@@ -214,4 +216,3 @@ Another thing you would need to confirm is being able to load web fonts properly
214216
Notice that the url-loader is required for this to work (npm install it).
215217
216218
The following example project is a fork of the angular2-webpack-starter with the addition of angular2-materialize: [InfomediaLtd/angular2-webpack-starter](https://github.com/InfomediaLtd/angular2-webpack-starter)
217-

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
2-
"name": "angular2-materialize",
2+
"name": "@samuelberthe/angular2-materialize",
33
"description": "Angular 2 support for Materialize CSS framework",
44
"repository": {
55
"type": "git",
6-
"url": "https://github.com/InfomediaLtd/angular2-materialize.git"
6+
"url": "https://github.com/samber/angular2-materialize.git"
77
},
8+
"version": "1.0.0-rc.2",
89
"keywords": [
910
"angular",
1011
"angular2",
@@ -19,9 +20,9 @@
1920
"author": "Ruby Boyarski <rubyboy@gmail.com>",
2021
"license": "MIT",
2122
"bugs": {
22-
"url": "https://github.com/InfomediaLtd/angular2-materialize/issues"
23+
"url": "https://github.com/samber/angular2-materialize/issues"
2324
},
24-
"homepage": "https://github.com/InfomediaLtd/angular2-materialize#readme",
25+
"homepage": "https://github.com/samber/angular2-materialize#readme",
2526
"main": "dist/index.js",
2627
"types": "./dist/index.d.ts",
2728
"scripts": {
@@ -32,8 +33,8 @@
3233
"postsemantic-release": "semantic-release post"
3334
},
3435
"peerDependencies": {
35-
"materialize-css": "^0.100.1",
36-
"@angular/common": "^5.0.0"
36+
"materialize-css": "1.0.0-rc.2",
37+
"@angular/common": ">=4.0.0"
3738
},
3839
"config": {
3940
"commitizen": {
@@ -62,7 +63,7 @@
6263
"gulp-typescript": "3.1.6",
6364
"hammerjs": "^2.0.8",
6465
"jquery": "^2.2.4",
65-
"materialize-css": "^0.100.1",
66+
"materialize-css": "1.0.0-rc.1",
6667
"rollup": "^0.41.6",
6768
"run-sequence": "1.2.2",
6869
"rxjs": "^5.1.0",

sample/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
"hammerjs": "^2.0.8",
2424
"intl": "1.2.5",
2525
"jquery": "^2.2.4",
26-
"materialize-css": "^0.100.1",
27-
"rxjs": "^5.1.0",
28-
"web-animations-js": "2.2.4",
29-
"zone.js": "0.8.7"
26+
"materialize-css": "^1.0.0-rc.2",
27+
"rxjs": "^5.1.0",
28+
"web-animations-js": "2.2.4",
29+
"zone.js": "0.8.7"
3030
},
3131
"devDependencies": {
3232
"@angular/cli": "1.0.3",

sample/src/app/buttons/buttons.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<i class="material-icons right">send</i>
1111
</button>
1212
<br/><br/>
13-
<a class="waves-effect waves-light btn no-upper-case" (click)="updateTextFields()">Call Materialize.updateTextFields()</a>
13+
<a class="waves-effect waves-light btn no-upper-case" (click)="updateTextFields()">Call M.updateTextFields()</a>
1414

1515
<br/>
1616
<br/>
@@ -40,4 +40,3 @@ <h5>Title</h5>
4040
<p>A bunch of text</p>
4141
</div>
4242
</div>
43-

sample/src/app/buttons/buttons.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Component, EventEmitter, OnInit } from '@angular/core';
22
import { Router } from "@angular/router";
33
import {MaterializeAction} from "angular2-materialize"
44

5-
declare var Materialize:any;
5+
declare var M:any;
66

77
@Component({
88
selector: 'app-buttons',
@@ -23,7 +23,7 @@ export class ButtonsComponent implements OnInit {
2323
}
2424

2525
updateTextFields() {
26-
Materialize.updateTextFields();
26+
M.updateTextFields();
2727
console.log("updateTextFields called");
2828
}
2929

sample/src/app/components/datepicker.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Component, EventEmitter} from '@angular/core';
22
import {MaterializeAction} from '../../../lib/materialize-directive';
33
import {FormBuilder, FormGroup, FormControl} from '@angular/forms';
4-
declare var Materialize: any;
4+
declare var M: any;
55

66
@Component({
77
selector: "datePicker",
@@ -19,35 +19,35 @@ declare var Materialize: any;
1919
<div class="col s6">
2020
<label for="birthtime">Birthtime {{birthTime}}</label>
2121
<input id="birthtime" name="birthtime" [(ngModel)]="birthTime"
22-
materialize="pickatime"
22+
materialize="pickatime"
2323
[materializeActions]="birthTimeActions"
2424
[materializeParams]="[{twelvehour: false}]"
2525
placeholder="00:00" class="validate" type="text">
2626
</div>
27-
27+
2828
</div>
2929
<div class="row">
3030
<div class="col s6">
3131
<a class="waves-effect waves-light btn" (click)="openDatePicker()">Open Date Picker</a>
3232
</div>
33-
33+
3434
<div class="col s3">
3535
<a class="waves-effect waves-light btn" (click)="setTime('01:15')">Set Time to 01:15</a>
3636
</div>
3737
<div class="col s3">
3838
<a class="waves-effect waves-light btn" (click)="openTimePicker()">Open Time Picker</a>
3939
</div>
4040
</div>
41-
41+
4242
<div class="row"></div>
4343
<div class="row"></div>
44-
44+
4545
<div class="row"><h4>Form Binding</h4></div>
46-
46+
4747
<form [formGroup]="form" materialize class="col s12">
4848
<div class="row">
4949
<div class="col s4">
50-
50+
5151
<label for="birthdate2">Birthdate {{form.value.fromDate}}</label>
5252
<input id="birthdate2" name="birthdate2" formControlName="fromDate"
5353
materialize="pickadate"

sample/src/app/components/dialogs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import {Component,EventEmitter} from "@angular/core"
4242
<br/><br/>
4343
4444
<!-- toast -->
45-
<a class="btn" onclick="Materialize.toast('I am a toast', 4000)">Toast 1!</a>
46-
<a class="btn" (click)="triggerToast()" materialize [materializeParams]="['I am also a toast',4000]" [materializeActions]="globalActions">Toast 2!</a>
45+
<a class="btn" onclick="M.toast('I am a toast', 4000)">Toast 1!</a>
46+
<a class="btn" (click)="triggerToast()" materialize [materializeParams]="['I am also a toast',4000]" [materializeActions]="globalActions">Toast 2!</a>
4747
`
4848
})
4949
export class Dialogs {

sample/src/app/components/model-bindings/model-bindings.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {Option} from "./option";
33
import {MaterialInput} from "./input";
44
import {MaterialSelect} from "./select";
55
import {MaterializeDirective} from "angular2-materialize";
6-
import * as Materialize from "angular2-materialize";
6+
import * as M from "angular2-materialize";
77
import "rxjs";
88
import {Observable} from "rxjs/Observable";
99

@@ -86,11 +86,11 @@ export class ModelBindings {
8686
}
8787

8888
onInputValChange(val){
89-
Materialize.toast(`parent input: ${val}`, 500)
89+
M.toast(`parent input: ${val}`, 500)
9090
}
9191

9292
onSelectValChange(val){
93-
Materialize.toast(`parent select: ${val}`, 2000)
93+
M.toast(`parent select: ${val}`, 2000)
9494
}
9595

9696
onCountryChange(e) {

src/custom-event-polyfill.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function CustomEvent ( type, detail = undefined, params = { bubbles: fals
33
event.initCustomEvent( type, params.bubbles, params.cancelable, detail );
44
return event;
55
}
6-
if ("Event" in window) {
6+
if ("undefined"!=typeof window && "Event" in window) {
77
CustomEvent.prototype = (window as any).Event.prototype;
88
}
99

src/index.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1-
export {MaterializeDirective,MaterializeAction} from "./materialize-directive";
2-
export {MaterializeModule} from "./materialize-module";
1+
export { MaterializeDirective, MaterializeAction } from "./materialize-directive";
2+
export { MaterializeModule } from "./materialize-module";
33

4-
if (!("Materialize" in window)) {
5-
throw new Error("Couldn't find Materialize object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
6-
}
7-
if (!("Waves" in window)) {
8-
throw new Error("Couldn't find Waves object on window. It is supposed to be created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
9-
}
104

11-
declare var Waves:any;
12-
Waves.displayEffect();
5+
declare var Waves: any;
6+
declare var M: any;
7+
8+
if ("undefined" != typeof window) {
9+
if (!("M" in window)) {
10+
throw new Error("Couldn't find Materialize object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
11+
}
12+
if (!("Waves" in window)) {
13+
throw new Error("Couldn't find Waves object on window. It is supposed to be created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
14+
}
1315

14-
declare var Materialize:any;
16+
Waves.displayEffect();
17+
// polyfill remove any elem in DOM - https://github.com/InfomediaLtd/angular2-materialize/issues/377 (IE)
18+
if (!Element.prototype.remove) {
19+
Element.prototype.remove = function remove() {
20+
if (this.parentNode) {
21+
this.parentNode.removeChild(this);
22+
}
23+
};
24+
}
25+
}
1526

1627
export function toast(...args) {
17-
Materialize.toast(...args);
28+
M.toast(...args);
1829
}
19-
20-
// polyfill remove any elem in DOM - https://github.com/InfomediaLtd/angular2-materialize/issues/377 (IE)
21-
if (!Element.prototype.remove) {
22-
Element.prototype.remove = function remove() {
23-
if (this.parentNode) {
24-
this.parentNode.removeChild(this);
25-
}
26-
};
27-
}

0 commit comments

Comments
 (0)