Add CommonJS support for the jQuery adaptor.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ps = require('../plugin/ps');
|
||||
var ps = require('../main');
|
||||
|
||||
window.PerfectScrollbar = ps;
|
||||
if (typeof window.Ps === 'undefined') {
|
||||
|
||||
Vendored
+30
-21
@@ -3,30 +3,39 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ps = require('../plugin/ps')
|
||||
var ps = require('../main')
|
||||
, psInstances = require('../plugin/instances');
|
||||
|
||||
$.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;
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Unless, it may be a command.
|
||||
var command = settingOrCommand;
|
||||
|
||||
if (command === 'update') {
|
||||
ps.update(this);
|
||||
} else if (command === 'destroy') {
|
||||
ps.destroy(this);
|
||||
}
|
||||
}
|
||||
return $(this);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
return $(this);
|
||||
});
|
||||
};
|
||||
var jq = window.jQuery ? window.jQuery : window.$;
|
||||
if (typeof jq !== 'undefined') {
|
||||
mountJQuery(jq);
|
||||
}
|
||||
|
||||
module.exports = mountJQuery;
|
||||
|
||||
+9
-1
@@ -3,4 +3,12 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./plugin/ps');
|
||||
var destroy = require('./plugin/destroy')
|
||||
, initialize = require('./plugin/initialize')
|
||||
, update = require('./plugin/update');
|
||||
|
||||
module.exports = {
|
||||
initialize: initialize,
|
||||
update: update,
|
||||
destroy: destroy
|
||||
};
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
|
||||
* Licensed under the MIT License
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var destroy = require('./destroy')
|
||||
, initialize = require('./initialize')
|
||||
, update = require('./update');
|
||||
|
||||
module.exports = {
|
||||
initialize: initialize,
|
||||
update: update,
|
||||
destroy: destroy
|
||||
};
|
||||
Reference in New Issue
Block a user