| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- 'use strict';
- var ps = require('../main')
- , psInstances = require('../plugin/instances');
- function mountJQuery(jQuery) {
- jQuery.fn.perfectScrollbar = function (settingOrCommand, updateSettings) {
- return this.each(function () {
- if (typeof settingOrCommand === 'object' ||
- typeof settingOrCommand === 'undefined') {
- // If it's an object or none, initialize.
- var settings = settingOrCommand;
- if (!psInstances.get(this)) {
- ps.initialize(this, settings);
- }
- } else {
- // Unless, it may be a command.
- var command = settingOrCommand;
- if (command === 'update') {
- ps.update(this, updateSettings);
- } else if (command === 'destroy') {
- ps.destroy(this);
- }
- }
- return jQuery(this);
- });
- };
- }
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as an anonymous module.
- define(['jquery'], mountJQuery);
- } else {
- var jq = window.jQuery ? window.jQuery : window.$;
- if (typeof jq !== 'undefined') {
- mountJQuery(jq);
- }
- }
- module.exports = mountJQuery;
|