{"id":16410523,"url":"https://github.com/skipperbent/jquery.page.js","last_synced_at":"2025-08-07T14:39:36.498Z","repository":{"id":58234757,"uuid":"82957862","full_name":"skipperbent/jquery.page.js","owner":"skipperbent","description":"Simple turbolink-like functionality for jQuery.","archived":false,"fork":false,"pushed_at":"2018-03-16T03:15:57.000Z","size":2037,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T03:05:30.636Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skipperbent.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-23T18:23:11.000Z","updated_at":"2018-03-16T03:15:44.000Z","dependencies_parsed_at":"2022-08-31T11:41:32.330Z","dependency_job_id":null,"html_url":"https://github.com/skipperbent/jquery.page.js","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skipperbent%2Fjquery.page.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skipperbent%2Fjquery.page.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skipperbent%2Fjquery.page.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skipperbent%2Fjquery.page.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skipperbent","download_url":"https://codeload.github.com/skipperbent/jquery.page.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240415267,"owners_count":19797603,"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-11T06:43:11.225Z","updated_at":"2025-02-24T04:15:48.592Z","avatar_url":"https://github.com/skipperbent.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# page.js\nSimple turbolink-like helper for jQuery.\n\n## Example\n\n```js\n// Intiailize plugin\n\nvar page = new $p.page({\n    container: '#content'\n}).on('preload', function() {\n\n    // Fires before ajax request\n\n}).on('progress', function(e) {\n\n    // Fires on progress\n\n}).on('pushstate', function(data) {\n\n    // Save data on state\n    data.activeMenuElement = 'whatever';\n\n}).on('load', function(e) {\n\n    // Fire Google Analytics on page-load\n    ga('set', { page: location.pathname.substr(1) + location.search, title: window.title });\n    ga('send', 'pageview');\n\n});\n\n// Use page.js when clicking url\n\n$(document).on('click.page.link', ' a:not([data-ajax=\"false\"])', function (e) {\n    // Ignore ctrl + click\n    if (!e.metaKey \u0026\u0026 !e.ctrlKey) {\n        var href = $(this).attr('href');\n\n        if (href === (location.pathname + location.search)) {\n            e.preventDefault();\n            page.reload();\n            return;\n        }\n\n        if (href !== null \u0026\u0026 href.indexOf('/') === 0) {\n            e.preventDefault();\n            page.go(href);\n        }\n    }\n});\n\n```\n\nEvents added on `page.on()` will fire each time the event is trigged. If you only want to fire an event once, you can use the ` page.bind()` instead.\n\nIn your master template add `id=\"content\"` to the element where you want your ajax-requests to be displayed.\n```html\n\u003cdiv id=\"content\"\u003e\n    This content will be replaced by page.js when loading an url\n\u003c/div\u003e\n```\n\n## Events\n\n- ready\n- preload\n- load\n- progress\n- error\n- pushstate\n- statechange\n\n## Ajax request\n\nYou can call `page.js` in the template of your ajax-request.\n\n**Example:**\n\n```js\n\u003c!-- Your HTML --\u003e\n\n\u003cscript\u003e\n    // Set the page title\n    page.setTitle('My loaded page');\n\n    // Add styles to \u003chead\u003e if not already present\n    page.loadStyles([\n      '/css/specific-style.css'\n    ]);\n\n    // Add scripts to \u003chead\u003e if not already present\n    page.loadScripts([\n      '//code.jquery.com/jquery-3.1.1.slim.min.js'\n    ]);\n\n    // Fires when page and scripts is fully loaded\n    page.ready(function() {\n\n    });\n\u003c/script\u003e\n```\nScript or styles loaded through `page.loadScripts` or `page.loadStyles` will automaticially be added to the `\u003chead\u003e` of your page, if they aren't already present.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskipperbent%2Fjquery.page.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskipperbent%2Fjquery.page.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskipperbent%2Fjquery.page.js/lists"}