{"id":15789935,"url":"https://github.com/gettocat/items","last_synced_at":"2026-01-11T01:31:10.299Z","repository":{"id":36317359,"uuid":"40622012","full_name":"gettocat/items","owner":"gettocat","description":"minimalistic js library to manage items list.","archived":false,"fork":false,"pushed_at":"2015-11-27T07:27:17.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-05T22:04:13.437Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/gettocat.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":"2015-08-12T20:14:11.000Z","updated_at":"2015-08-13T09:15:40.000Z","dependencies_parsed_at":"2022-09-09T07:21:49.995Z","dependency_job_id":null,"html_url":"https://github.com/gettocat/items","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/gettocat%2Fitems","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fitems/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fitems/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gettocat%2Fitems/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gettocat","download_url":"https://codeload.github.com/gettocat/items/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246516949,"owners_count":20790325,"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-10-04T22:04:15.840Z","updated_at":"2026-01-11T01:31:10.269Z","avatar_url":"https://github.com/gettocat.png","language":"HTML","readme":"# items lib\nMinimalistic js library to manage items list. [View live demo](http://gettocat.github.io/items/)\n\n![Items preview](/preview.png)\n\n### Installation\n* add to you page items.css and items.js\n* init library:\n```js\nvar itms = new items();\n```\n* add class item to listed elements. \n* add item-header and item-footer, if this need.\n\nFor example:\n```html\n\u003cdiv id='list1'\u003e\n  \u003cdiv class=\"item-header\"\u003e\n    \u003ca href=\"#\" onclick=\"return itms.selectAll()\" class=\"btn btn-primary\"\u003eSelect all\u003c/a\u003e\n    \u003ca href=\"#\" onclick=\"return itms.unselectAll()\" class=\"btn btn-primary\"\u003eClear selection\u003c/a\u003e\n    \u003ca href=\"#\" onclick=\"itms.getSelected(function(el) { $(el).remove(); });\" class=\"hideOnEmptySelection hide btn btn-danger\"\u003eDelete selected\u003c/a\u003e\n  \u003c/div\u003e\n  \u003cdiv class='item' data-id='1'\u003eitem 1\u003c/div\u003e\n  \u003cdiv class='item' data-id='2'\u003eitem 2\u003c/div\u003e\n  \u003cdiv class='item' data-id='3'\u003eitem 3\u003c/div\u003e\n  \u003cdiv class=\"item-footer\"\u003e\u003c/div\u003e\n\u003c/div\u003e\n```\n\n### Methods\n```js\nitms.select(el); // select element\nitms.unselect(el); //remove selection on element \nitms.selectAll(); //select all elements\nitms.unselectAll(); //remove selection from all elements\n```\n### Callbacks\n```js\nitms.onHasSelected(function() {\n  //action on one or more selected items\n});\n\nitms.onHasNoSelected(function() {\n  //action on zero selected items\n});\n\nitms.onSelect(function() {\n  //action on new selected item\n});\n\nitms.onUnSelect(function() {\n  //action on new onselected item\n});\n\nitms.getSelected(function(el) { // this callback will be triggered on each selected item\n    var id = $(el).data(\"id\"); //for example - get id of item from data-id\n    \n    fake_ajax(function(resp) {//send async query\n        itms2.unselect(el);//unselect item\n        if (resp.status == 1)\n            $(el).remove();//and remove it from list\n    });\n\n});\n\nitms.getAllSelected(function(arr){\n    //arr is Array of $(element);\n});\n\nitms.getAllSelectedAttr('id', function(arr){\n    //arr is Array of value data-id of elements\n});\n```\n\n### Advanced usage\nIf you need a more then one list on page, use this code:\n```js\nvar itm11 = new items(\"#tags\");//#tag its a selector, where search elements of this list, by default - document.\nvar itms2 = new items(\"#categoryes\");\n```\n\n### Constructor params\n```js\nvar itm1 = new items(\"#tags\", {\n  scope: \"Selected items: \",//text of footer items. \n  item_selector: '.item',//selector of one item\n  active_item_class: 'item-selected', //class, adding to selected item\n  header_selector: \".item-header\",//list header selector\n  footer_selector: \".item-footer\",//list footer selector\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fitems","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgettocat%2Fitems","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgettocat%2Fitems/lists"}