{"id":13411404,"url":"https://github.com/garciaguimeras/TypeScriptTools","last_synced_at":"2025-03-14T17:30:43.414Z","repository":{"id":152798151,"uuid":"172961009","full_name":"garciaguimeras/TypeScriptTools","owner":"garciaguimeras","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-21T13:38:01.000Z","size":86,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:45:47.122Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garciaguimeras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-27T17:38:46.000Z","updated_at":"2020-05-21T13:38:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"eaffa7f5-4820-4283-8fe6-4e89d9deec3f","html_url":"https://github.com/garciaguimeras/TypeScriptTools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciaguimeras%2FTypeScriptTools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciaguimeras%2FTypeScriptTools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciaguimeras%2FTypeScriptTools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garciaguimeras%2FTypeScriptTools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garciaguimeras","download_url":"https://codeload.github.com/garciaguimeras/TypeScriptTools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243618600,"owners_count":20320264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:13.443Z","updated_at":"2025-03-14T17:30:43.401Z","avatar_url":"https://github.com/garciaguimeras.png","language":"TypeScript","funding_links":[],"categories":["Web Development"],"sub_categories":["Javascript"],"readme":"# TypeScriptTools (TST)\n\nAre you\n\n- Fan of TypeScript?\n- Bored of using jQuery on your web apps?\n- Thinking that jQuery programming generates confusing and hard to maintain code?\n- Needing/Wanting not to use Angular or React?\n\nOk, you can use **glue**!!\n\n## glue Controllers\n\nSuppose you need to manage a web page fragment like that:\n\n``` html\n\u003cdiv id=\"person-form\"\u003e\n    Write your name:\n    \u003cinput type=\"text\" id=\"person-name\" /\u003e\n    \u003cbutton id=\"accept-button\"\u003eAccept\u003c/button\u003e\n\u003c/div\u003e\n```\n\nUsing **glue**, you could write some code like that:\n\n``` ts\n@Controller('person-form')\nclass PersonFormController {\n\n    @Outlet('person-name')\n    personName: Element;\n\n    @Action('accept-button', 'click')\n    onAcceptButtonClick() {\n        let name = personName.getAttribute('value');\n        console.log('Person name is ' + name);\n    }\n\n}\n```\n\nYou can add some jQuery flavour to your code, including **glue-jquery**:\n\n``` ts\n@Controller('person-form')\nclass PersonFormController {\n\n    @JQueryOutlet()\n    @Outlet('person-name')\n    personName: JQuery;\n\n    @Action('accept-button', 'click')\n    onAcceptButtonClick() {\n        let name = personName.val();\n        console.log('Person name is ' + name);\n    }\n\n}\n```\n\nDo you need to use another controller's instance on your code?\n\n``` ts\n@Controller('foo')\nclass FooController {\n    ...\n}\n\n@Controller('bar')\nclass BarController {\n    ...\n    @Inject('foo')\n    foo: FooController;\n    ...\n}\n```\n\nAnd if you need to capture the on-load event?\n\n``` ts\n@Controller('foo')\nclass FooController {\n    ...\n    @LoadMethod()\n    didLoad() {\n        ...\n    }\n    ...\n}\n\n```\n\n## glue Templates\n\nYou can create a controller template using TSX, including the **react-jsx-polyfill**:\n\n``` tsx\nlet template: Element = (\n    \u003cdiv\u003e\n        Write your name:\n        \u003cinput type=\"text\" id=\"person-name\" /\u003e\n        \u003cbutton id=\"accept-button\"\u003eAccept\u003c/button\u003e\n    \u003c/div\u003e\n)\n```\n\n``` ts\n@Template(template)\nclass PersonFormTemplate {\n\n    @Outlet('person-name')\n    personName: Element;\n\n    someData: string;\n\n    @Action('accept-button', 'click')\n    onAcceptButtonClick() {\n        let name = personName.getAttribute('value');\n        console.log('Person name is ' + name);\n    }\n\n}\n```\n\nInject it dynamically into the DOM using **glue-methods**:\n\n``` ts\nGlueMethods.templateToController(parentController, PersonFormTemplate, 'person-form', 'parent-div');\n```\n\nor\n\n``` ts\nGlueMethods.templateToController('parent-controller-id', PersonFormTemplate, 'person-form', 'parent-div');\n```\n\nor even injecting it somo initialization data\n\n``` ts\nvar params = {  \n    someData: 'some value'    \n}\nGlueMethods.templateToController(parentController, PersonFormTemplate, 'person-form', 'parent-div', params);\n```\n\nand remove the controller dynamically from DOM:\n\n``` ts\nGlueMethods.removeController('person-form');\n```\n\n## Using glue with require.js\n\nInclude require.js on your web page:\n\n``` html\n\u003cscript src=\"require.js\" data-main=\"require-main\"\u003e\u003c/script\u003e\n```\n\nIn your main script, write something like that:\n\n``` js\nvar requirements = ['glue', 'my-controller'];\nrequire(requirements, function (glue) {\n    glue.$glue.bootstrap();\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarciaguimeras%2FTypeScriptTools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarciaguimeras%2FTypeScriptTools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarciaguimeras%2FTypeScriptTools/lists"}