{"id":19388991,"url":"https://github.com/james2doyle/ki.extend.js","last_synced_at":"2025-07-12T03:07:02.209Z","repository":{"id":14110480,"uuid":"16815160","full_name":"james2doyle/ki.extend.js","owner":"james2doyle","description":"extend ki.js with some fancy prototypes","archived":false,"fork":false,"pushed_at":"2016-03-05T23:51:03.000Z","size":40,"stargazers_count":31,"open_issues_count":1,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-02T22:33:08.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/james2doyle.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}},"created_at":"2014-02-13T19:56:59.000Z","updated_at":"2024-09-24T11:28:03.000Z","dependencies_parsed_at":"2022-09-23T19:02:43.993Z","dependency_job_id":null,"html_url":"https://github.com/james2doyle/ki.extend.js","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/james2doyle%2Fki.extend.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fki.extend.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fki.extend.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james2doyle%2Fki.extend.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james2doyle","download_url":"https://codeload.github.com/james2doyle/ki.extend.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250532176,"owners_count":21446133,"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-11-10T10:14:18.314Z","updated_at":"2025-04-23T23:31:54.109Z","avatar_url":"https://github.com/james2doyle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"ki.extend.js\n============\n\nExtend [ki.js](https://github.com/dciccale/ki.js) with some fancy prototypes. Ironically built with [youmightnotneedjquery](http://youmightnotneedjquery.com/).\n\n### Included Prototypes\n\n* addClass\n* removeClass\n* toggleClass\n* hasClass\n* show\n* hide\n* css\n* attr\n* removeAttr\n* hasAttr\n* first\n* last\n* get\n* before\n* after\n* text\n* html\n* append\n* prepend\n* remove\n* parent\n* trigger\n* is\n\n### Included \"utilities\"\n\n*$.stop*\n\nStop events in ie8 and up.\n\n```javascript\n$('.btn').on('click', function(e){\n  $.stop(e);\n  console.log(this.href);\n  return false;\n});\n```\n\n*$.each*\n\nForEach function for arrays.\n\n*$.map*\n\nMap function for arrays. Returns an array, not $.\n\n*$.filter*\n\nFilter function for arrays. Returns an array, not $.\n\n*$.trim*\n\nTrim whitespace in string.\n\n*$.param*\n\nSerialize an object to be used in a *POST* request.\n\n*$.Deferred*\n\nYep. `$.Deferred` just like jQuery.\n\n```\nfunction late(n) {\n  var p = new $.Deferred();\n  setTimeout(function() {\n    p.resolve(n);\n  }, n);\n  return p.promise();\n}\n```\n\n*$.when*\n\nRun an array of `$.Deferred` functions in series. The functions must be promises. Calling `.then` on `$.when` will have the resolved values as the arguments.\n\n```\n$.when(late(1000), late(1200)).then(function(resolvedValue1, resolvedValue2) {\n  console.log(resolvedValue1, resolvedValue2); // 1000, 1200\n}, function() {\n  console.log('error');\n});\n```\n\n*$.ajax*\n\nThe beast. Easy ajax functions.\n\n**Note:** by default, deferred Ajax is included in the build. If you **are not using Deferred** then just uncomment the normal ajax lib and comment off Deferred and Ajax-Deferred.\n\nSimple `POST`. Data is automagically `$.param'd` and sent with a request header of `('Content-type', 'application/x-www-form-urlencoded')`.\n\n```javascript\n$.ajax('form.php', { id: 123 }, function(res){\n  console.log(res);\n});\n```\n\nSimple `GET`. If you do not pass an object, than the request is treated as a `GET` request.\n\n```javascript\n$.ajax('json.js', function(res) {\n  console.log(res);\n});\n```\n\nSimple error handling. The second argument in the callback is an error boolean.\n\n```javascript\n$.ajax('http://example.com/save', { id: 456 }, function(res, err) {\n  if(err) {\n    alert('Got an error, bro.');\n  } else {\n    console.log(res);\n  }\n});\n```\n\n---\n\nDeferred Examples\n\n```javascript\n$.ajax('form.php', { id: 123 }).done(function(res){\n  console.log(res);\n});\n```\n\nSimple `GET`. If you do not pass an object, than the request is treated as a `GET` request.\n\n```javascript\n$.ajax('json.js').done(function(res) {\n  console.log(res);\n});\n```\n\nSimple error handling. The second argument in the callback is an error callback.\n\n```javascript\n$.ajax('http://example.com/save', { id: 456 }).then(function(res) {\n  alert('I am ok!');\n},\nfunction(res) {\n  alert('Got an error, bro.');\n});\n```\n\nUsing `$.when`:\n\n```javascript\n$.when($.ajax('text.txt'), $.ajax('json.js')).then(function(res1, res2){\n  console.log(res1, res2);\n}, function(res){\n  console.log(res);\n});\n```\n\n### Building\n\nYou can choose to build a custom version of the extend lib. Just open the `gruntfile` and remove items from the concat task.\n\nHere is the default list:\n\n```\n'build/parts/header.js',\n'build/parts/each.js',\n'build/parts/classes.js',\n'build/parts/append-prepend.js',\n'build/parts/attr.js',\n'build/parts/before-after.js',\n'build/parts/css.js',\n'build/parts/first-last-get.js',\n'build/parts/html-text.js',\n'build/parts/parent.js',\n'build/parts/remove.js',\n'build/parts/trim.js',\n'build/parts/trigger.js',\n'build/parts/is.js',\n'build/parts/arrays.js',\n'build/parts/stop.js',\n'build/parts/ajax-deferred.js',\n// 'build/parts/ajax.js',\n'build/ki-deferred-js/deferred.js',\n'build/parts/footer.js'\n```\n\nThe `header.js` and `footer.js` must be set. They are used to open and close the **main function**. Everything else can be toggled and removed as needed.\n\n### Test\n\nThere isn't any *real* javascript testing. I just wrote some small HTML pages that you can open in your favourite browser to test in. You can also use them as examples on how to use the different prototypes.\n\nHere is the small list of test so far:\n\n```\najax\nattrs\nclasses\ncss\ndeferred\neach-arrays\nfirst-last-get-parent-remove\nhide-show\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fki.extend.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames2doyle%2Fki.extend.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames2doyle%2Fki.extend.js/lists"}