I'd like to extend a jQuery plugin.
In this paste of the plugin I want to extend, I've hidden everything else apart from the main structure, what I believe is relevant to what I want to do (I'm probably wrong) and one particular method I want to extend:
(function (factory) {
if (typeof exports === 'object') {
// CommonJS
module.exports = factory(require('jquery'));
} else if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
/**
* Kontrol library
*/
"use strict";
/**
* Definition of globals and core
*/
var k = {}, // kontrol
// ...
k.c = {};
k.c.d = $(document);
k.c.t = function (e) {
return e.originalEvent.touches.length - 1;
};
/**
* Kontrol Object
*
* Definition of an abstract UI control
*
* Each concrete component must call this one.
* <code>
* k.o.call(this);
* </code>
*/
k.o = function () {
// ...
};
/**
* k.Dial
*/
k.Dial = function () {
// ...
// this is one of the methods I want to extend:
this.change = function (v) {
this.cv = v;
this.$.val(this.o.format(v));
};
// ...
};
$.fn.dial = $.fn.knob = function (o) {
return this.each(
function () {
var d = new k.Dial();
d.o = o;
d.$ = $(this);
d.run();
}
).parent();
};
}));
Ideally I would like to better understand what is going on there in terms of architecture but I'd be happy if anyone could point me out any direction on how to extend the change() method.
I've seen answers like this one, but what would be the Namespace and pluginName in my case?