diff --git a/package.json b/package.json index 7f510c4..26a7f6f 100644 --- a/package.json +++ b/package.json @@ -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": { @@ -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", diff --git a/src/index.ts b/src/index.ts index 1230d66..269ace5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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)) { @@ -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) diff --git a/src/materialize-directive.ts b/src/materialize-directive.ts index 68365e6..8348116 100644 --- a/src/materialize-directive.ts +++ b/src/materialize-directive.ts @@ -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" | @@ -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 @@ -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.");