Integrate perfect-scrollbar to make tests happy
[friendica.git/.git] / library / perfect-scrollbar / src / js / adaptor / jquery.js
1 'use strict';
2
3 var ps = require('../main');
4 var psInstances = require('../plugin/instances');
5
6 function mountJQuery(jQuery) {
7   jQuery.fn.perfectScrollbar = function (settingOrCommand) {
8     return this.each(function () {
9       if (typeof settingOrCommand === 'object' ||
10           typeof settingOrCommand === 'undefined') {
11         // If it's an object or none, initialize.
12         var settings = settingOrCommand;
13
14         if (!psInstances.get(this)) {
15           ps.initialize(this, settings);
16         }
17       } else {
18         // Unless, it may be a command.
19         var command = settingOrCommand;
20
21         if (command === 'update') {
22           ps.update(this);
23         } else if (command === 'destroy') {
24           ps.destroy(this);
25         }
26       }
27     });
28   };
29 }
30
31 if (typeof define === 'function' && define.amd) {
32   // AMD. Register as an anonymous module.
33   define(['jquery'], mountJQuery);
34 } else {
35   var jq = window.jQuery ? window.jQuery : window.$;
36   if (typeof jq !== 'undefined') {
37     mountJQuery(jq);
38   }
39 }
40
41 module.exports = mountJQuery;