The powerful javascript library for connecting form components with backend protocols.
composer install
typings install
npm install
webpack
Start webpack-dev-server
webpack-dev-server --config webpack.server.config.js
Setup action-js.dev
virtual host for running ActionKit in PHP.
Install typescript
sudo npm install typescript -g
sudo npm link typescript
Install typings (tsd was deprecated)
sudo npm install typings -g
sudo link typings
Install types for jquery, mocha
typings install dt~jquery --global --save
typings install dt~mocha --global --save
Rename all files from *.js to *.ts
fsrename -match ".js" -replace ".ts"
Create tsconfig.json file for typescript compiler
{
"compilerOptions": {
"target": "es5",
"sourceMap": true,
"outDir": "build/"
},
"exclude": ["node_modules"],
"files": [
"typings/index.d.ts",
"src/entry.ts"
]
}
Install ts-loader
for webpack
npm install ts-loader --save-dev
Define ts-loader in webpack.config.js:
module: {
loaders: [{
test: /\.(js|jsx)$/,
loaders: ['babel'],
exclude: [nodeModulesPath]
}, { test: /\.tsx?$/, loader: 'ts-loader' }],
} ...
Export symbols to window:
(<any>window).myFunc
Migrate old prototype based class to ES6 class
Add property names to class definition.
class Action {
actionName: string;
plugins: Array<Object>;
formEl: any;
options: ActionSettings;
...
}
Use JQueryAjaxSettings to ajaxSettings property
class ... {
ajaxSettings: JQueryAjaxSettings;
}
Cast element from getElementById function call to HTMLElement types, e.g.
var i = <HTMLIFrameElement>document.getElementById(id);
Fix AIM, the onComplete property setting. Change
i.onComplete = c.onComplete;
to:
i['onComplete'] = c.onComplete;
Functions return jQuery Deferred should be defined with JQueryDeferred<T>
in the prototype:
var doSubmit = (payload): JQueryDeferred<any> => {
...
};
Abstract config structure into interface (quality depends on how you define the types):
interface ActionSettings {
// optional property
plugins?: Array<ActionPlugin>;
confirm?: string;
disableInput?: boolean;
// optional function
onSubmit? ():any;
beforeSubmit? ():any;
beforeUpload? ():any;
}