{"id":13548989,"url":"https://github.com/desandro/jquery-bridget","last_synced_at":"2025-04-06T09:08:13.160Z","repository":{"id":6121897,"uuid":"7350005","full_name":"desandro/jquery-bridget","owner":"desandro","description":":bridge_at_night: bridget makes jQuery plugins","archived":false,"fork":false,"pushed_at":"2023-07-19T00:51:53.000Z","size":194,"stargazers_count":107,"open_issues_count":2,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-30T08:08:01.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/desandro.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2012-12-28T04:37:00.000Z","updated_at":"2025-01-24T09:44:30.000Z","dependencies_parsed_at":"2024-01-19T06:56:37.439Z","dependency_job_id":"341af193-7e86-4614-a022-ab98d6bcb151","html_url":"https://github.com/desandro/jquery-bridget","commit_stats":{"total_commits":60,"total_committers":4,"mean_commits":15.0,"dds":0.25,"last_synced_commit":"3aa66938ec7fb217a42572c9973b11fe86c4004a"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fjquery-bridget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fjquery-bridget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fjquery-bridget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/desandro%2Fjquery-bridget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/desandro","download_url":"https://codeload.github.com/desandro/jquery-bridget/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457801,"owners_count":20941906,"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-08-01T12:01:16.931Z","updated_at":"2025-04-06T09:08:13.142Z","avatar_url":"https://github.com/desandro.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Bridget makes jQuery plugins\n\nBridget makes a jQuery plugin out of a constructor :factory:\n\nIt's based off of the [jQuery UI widget factory](https://jqueryui.com/widget/). Used for [Masonry](https://masonry.desandro.com), [Isotope](https://isotope.metafizzy.co), [Packery](https://packery.metafizzy.co), [Flickity](https://flickity.metafizzy.co), [Infinite Scroll](https://infinite-scroll.com), and [Draggabilly](https://draggabilly.desandro.com).\n\n## Plugin constructor\n\nA plugin constructor uses Prototypal pattern. It needs to have a `._init()` method used for its main logic.\n\n``` js\n// plugin constructor\n// accepts two argments, element and options object\nfunction NiceGreeter( element, options ) {\n  this.element = $( element );\n  this.options = $.extend( true, {}, this.options, options );\n  this._init();\n}\n// defaults for plugin options\nNiceGreeter.prototype.options = {\n  greeting: 'hello',\n  recipient: 'world'\n};\n// main plugin logic\nNiceGreeter.prototype._init = function() {\n  var message = this.getMessage();\n  this.element.text( message );\n};\n// getter method\nNiceGreeter.prototype.getMessage = function() {\n  return this.options.greeting + ' ' + this.options.recipient;\n};\n```\n\n## Usage\n\nBridget can make this constructor work as a jQuery plugin. The `namespace` is the plugin method - `$elem.namespace()`.\n\n``` js\n// convert constructor to jQuery plugin\njQueryBridget( 'niceGreeter', NiceGreeter );\n// optional: pass in jQuery variable\njQueryBridget( 'niceGreeter', NiceGreeter, jQuery );\n\n// now the constructor can be used as a jQuery plugin\nvar $elem = $('#elem');\n$elem.niceGreeter();\n// \u003e\u003e h1 text will be 'hello world'\n\n// set options\n$elem.niceGreeter({\n  greeting: 'bonjour',\n  recipient: 'mon ami'\n});\n// \u003e\u003e text will be 'bonjour mon ami'\n\n// access constructor instance via .data()\nvar myGreeter = $elem.data('niceGreeter');\n```\n\nGetter methods can still be used. For jQuery objects with multiple elements, getter methods will return the value of the first element.\n\n## Package managers\n\nInstall with npm `npm install jquery-bridget`\n\nInstall with Yarn `yarn add jquery-bridget`\n\n## MIT license\n\nBridget is released under the [MIT license](https://desandro.mit-license.org).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesandro%2Fjquery-bridget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdesandro%2Fjquery-bridget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdesandro%2Fjquery-bridget/lists"}