npmtest-perfect-scrollbar (v0.0.1)

Code coverage report for node-npmtest-perfect-scrollbar/node_modules/perfect-scrollbar/src/js/adaptor/jquery.js

Statements: 10% (2 / 20)      Branches: 0% (0 / 18)      Functions: 0% (0 / 3)      Lines: 10% (2 / 20)      Ignored: none     

All files » node-npmtest-perfect-scrollbar/node_modules/perfect-scrollbar/src/js/adaptor/ » jquery.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43    2     1                                                                          
'use strict';
 
var ps = require('../main');
var psInstances = require('../plugin/instances');
 
function mountJQuery(jQuery) {
  jQuery.fn.perfectScrollbar = function (settingOrCommand) {
    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);
        } else if (command === 'destroy') {
          ps.destroy(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;