Skip to content

Commit

Permalink
changed preact to knockout
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Jan 16, 2018
1 parent 7533793 commit 8149e64
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/angular/SurveyNG.tsx → src/angular/SurveyNG.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import * as React from "react";
import * as ReactDOM from "react-dom";
import * as ko from "knockout";
import { SurveyModel } from "../survey";
import { Survey } from "../react/reactSurvey";
import { SurveyWindow } from "../react/reactSurveyWindow";
import { Survey } from "../knockout/kosurvey";
import { SurveyWindow } from "../knockout/koSurveyWindow";

export class SurveyNG {
public static render(elementId: string | Element, props) {
var element: Element =
typeof elementId === "string"
? document.getElementById(elementId)
: elementId;
ReactDOM.render(<Survey {...props} />, element);
props.model.render(element);
}
}

Expand All @@ -20,7 +19,8 @@ export class SurveyWindowNG {
typeof elementId === "string"
? document.getElementById(elementId)
: elementId;
ReactDOM.render(<SurveyWindow {...props} />, element);
var survey = new SurveyWindow(...props);
survey.show();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/entries/angular.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./react";
export * from "./knockout";
export { SurveyNG } from "../angular/SurveyNG";
export { SurveyWindowNG } from "../angular/SurveyNG";
24 changes: 24 additions & 0 deletions src/entries/jquery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as ko from "knockout";
import { SurveyModel } from "../survey";
import { Survey } from "../knockout/kosurvey";
import { SurveyWindow } from "../knockout/koSurveyWindow";
import jQuery from "jquery";

jQuery["fn"].extend({
Survey: function(props) {
this.each(function() {
props.model.render(this);
});
},

SurveyWindow: function(props) {
this.each(function() {
var survey = new SurveyWindow(...props);
survey.show();
});
}
});

SurveyModel.platform = "jquery";

export * from "./knockout";
24 changes: 0 additions & 24 deletions src/entries/jquery.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/knockout/koSurveyWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class SurveyWindow extends SurveyWindowModel {
koExpanded: any;
koExpandedCss: any;
doExpand: any;
constructor(jsonObj: any) {
constructor(jsonObj: any = null) {
super(jsonObj);
this.koExpanded = ko.observable(false);
this.koExpandedCss = ko.observable(this.getButtonCss());
Expand Down
13 changes: 10 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ var platformOptions = {
}
},
keywords: ["react", "react-component"],
peerDependencies: { react: ">=15.0.1 || ^16.2.0", "react-dom": ">=15.0.1 || ^16.2.0" }
peerDependencies: {
react: ">=15.0.1 || ^16.2.0",
"react-dom": ">=15.0.1 || ^16.2.0"
}
},
knockout: {
externals: {
Expand All @@ -64,12 +67,16 @@ var platformOptions = {
}
},
keywords: ["jquery", "jquery-plugin"],
dependencies: { jquery: ">=1.12.4", "@types/react": ">=15.0.35 || ^16.0.34" }
dependencies: {
jquery: ">=1.12.4",
knockout: "^3.4.0",
"@types/knockout": "3.4.46"
}
},
angular: {
externals: {},
keywords: ["angular", "angular-component"],
dependencies: { "@types/react": ">=15.0.35 || ^16.0.34" }
dependencies: { knockout: "^3.4.0", "@types/knockout": "3.4.46" }
},
vue: {
externals: {
Expand Down

0 comments on commit 8149e64

Please sign in to comment.