Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports materializecss v1.0.0 now #435

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"postsemantic-release": "semantic-release post"
},
"peerDependencies": {
"materialize-css": "^0.100.1",
"materialize-css": "1.0.0-rc.1",
"@angular/common": "^4.0.0"
},
"config": {
Expand Down Expand Up @@ -61,7 +61,7 @@
"gulp-typescript": "3.1.6",
"hammerjs": "^2.0.8",
"jquery": "^2.2.4",
"materialize-css": "^0.100.1",
"materialize-css": "1.0.0-rc.1",
"rollup": "^0.41.6",
"run-sequence": "1.2.2",
"rxjs": "^5.1.0",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export {MaterializeDirective,MaterializeAction} from "./materialize-directive";
export {MaterializeModule} from "./materialize-module";

if (!("Materialize" in window)) {
if (!("M" in window)) {
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.");
}
if (!("Waves" in window)) {
Expand All @@ -11,10 +11,10 @@ if (!("Waves" in window)) {
declare var Waves:any;
Waves.displayEffect();

declare var Materialize:any;
declare var M:any;

export function toast(...args) {
Materialize.toast(...args);
M.toast(...args);
}

// polyfill remove any elem in DOM - https://github.com/InfomediaLtd/angular2-materialize/issues/377 (IE)
Expand Down
12 changes: 6 additions & 6 deletions src/materialize-directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import {CustomEvent} from './custom-event-polyfill';

declare var $: any;
declare var Materialize: any;
declare var M: any;

// export type MaterializeOptions =
// "collapsible" |
Expand Down Expand Up @@ -136,8 +136,8 @@ export class MaterializeDirective implements AfterViewInit,DoCheck,OnChanges,OnD

private performElementUpdates() {
// it should have been created by now, but confirm anyway
if (Materialize && Materialize.updateTextFields) {
Materialize.updateTextFields();
if (M && M.updateTextFields) {
M.updateTextFields();
}

// handle select changes from the HTML
Expand Down Expand Up @@ -246,15 +246,15 @@ export class MaterializeDirective implements AfterViewInit,DoCheck,OnChanges,OnD
}
} else {
// fallback to running this function on the global Materialize object
if (Materialize[functionName]) {
if (M[functionName]) {
if (params) {
if (params instanceof Array) {
Materialize[functionName](...params);
M[functionName](...params);
} else {
throw new Error("Params has to be an array.");
}
} else {
Materialize[functionName]();
M[functionName]();
}
} else {
throw new Error("Couldn't find materialize function ''" + functionName + "' on element or the global Materialize object.");
Expand Down