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

Updated for materialize-css ^1.0.0 #441

Open
wants to merge 4 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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ branches:
notifications:
email: false
node_js:
- '6'
- '10'
before_install:
# - npm i -g npm
- npm i -g @angular/cli
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"postsemantic-release": "semantic-release post"
},
"peerDependencies": {
"materialize-css": "^0.100.1",
"materialize-css": "^1.0.0",
"@angular/common": "^5.0.0"
},
"config": {
Expand Down Expand Up @@ -62,7 +62,7 @@
"gulp-typescript": "3.1.6",
"hammerjs": "^2.0.8",
"jquery": "^2.2.4",
"materialize-css": "^0.100.1",
"materialize-css": "^1.0.0",
"rollup": "^0.41.6",
"run-sequence": "1.2.2",
"rxjs": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"hammerjs": "^2.0.8",
"intl": "1.2.5",
"jquery": "^2.2.4",
"materialize-css": "^0.100.1",
"materialize-css": "^1.0.0",
"rxjs": "^5.1.0",
"web-animations-js": "2.2.4",
"zone.js": "0.8.7"
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export {MaterializeDirective,MaterializeAction} from "./materialize-directive";
export {MaterializeModule} from "./materialize-module";

if (!("Materialize" 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 (!("M" in window)) {
throw new Error("Couldn't find M object on window. It is created by the materialize-css library. Please import materialize-css before importing angular2-materialize.");
}
if (!("Waves" in window)) {
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.");
Expand Down
16 changes: 8 additions & 8 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 @@ -245,19 +245,19 @@ export class MaterializeDirective implements AfterViewInit,DoCheck,OnChanges,OnD
jQueryElement[functionName]();
}
} else {
// fallback to running this function on the global Materialize object
if (Materialize[functionName]) {
// fallback to running this function on the global M object
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.");
throw new Error("Couldn't find materialize function ''" + functionName + "' on element or the global M object.");
}
}

Expand Down