jquery-bridget

WebJar for jquery-bridget

License

License

MIT
GroupId

GroupId

org.webjars.bower
ArtifactId

ArtifactId

jquery-bridget
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

jquery-bridget
WebJar for jquery-bridget
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/desandro/jquery-bridget

Download jquery-bridget

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bower/jquery-bridget/ -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>jquery-bridget</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bower/jquery-bridget/
implementation 'org.webjars.bower:jquery-bridget:2.0.0'
// https://jarcasting.com/artifacts/org.webjars.bower/jquery-bridget/
implementation ("org.webjars.bower:jquery-bridget:2.0.0")
'org.webjars.bower:jquery-bridget:jar:2.0.0'
<dependency org="org.webjars.bower" name="jquery-bridget" rev="2.0.0">
  <artifact name="jquery-bridget" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bower', module='jquery-bridget', version='2.0.0')
)
libraryDependencies += "org.webjars.bower" % "jquery-bridget" % "2.0.0"
[org.webjars.bower/jquery-bridget "2.0.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.bower : jquery jar [1.4.2,4)

Project Modules

There are no modules declared in this project.

Bridget makes jQuery plugins

Bridget makes a jQuery plugin out of a constructor 🏭

It's based off of the jQuery UI widget factory. Used for Masonry, Isotope, Packery, Flickity, Infinite Scroll, and Draggabilly.

Plugin constructor

A plugin constructor uses Prototypal pattern. It needs to have a ._init() method used for its main logic.

// plugin constructor
// accepts two argments, element and options object
function NiceGreeter( element, options ) {
  this.element = $( element );
  this.options = $.extend( true, {}, this.options, options );
  this._init();
}
// defaults for plugin options
NiceGreeter.prototype.options = {
  greeting: 'hello',
  recipient: 'world'
};
// main plugin logic
NiceGreeter.prototype._init = function() {
  var message = this.getMessage();
  this.element.text( message );
};
// getter method
NiceGreeter.prototype.getMessage = function() {
  return this.options.greeting + ' ' + this.options.recipient;
};

Usage

Bridget can make this constructor work as a jQuery plugin. The namespace is the plugin method - $elem.namespace().

// convert constructor to jQuery plugin
jQueryBridget( 'niceGreeter', NiceGreeter );
// optional: pass in jQuery variable
jQueryBridget( 'niceGreeter', NiceGreeter, jQuery );

// now the constructor can be used as a jQuery plugin
var $elem = $('#elem');
$elem.niceGreeter();
// >> h1 text will be 'hello world'

// set options
$elem.niceGreeter({
  greeting: 'bonjour',
  recipient: 'mon ami'
});
// >> text will be 'bonjour mon ami'

// access constructor instance via .data()
var myGreeter = $elem.data('niceGreeter');

Getter methods can still be used. For jQuery objects with multiple elements, getter methods will return the value of the first element.

Package managers

Install with npm npm install jquery-bridget

Install with Yarn yarn add jquery-bridget

MIT license

Bridget is released under the MIT license.

Versions

Version
2.0.0
1.1.0