#46 $.extend change to pure javascript
This commit is contained in:
@@ -14,3 +14,24 @@ export function findPos (obj) {
|
|||||||
}
|
}
|
||||||
return {left: curleft, top: curtop};
|
return {left: curleft, top: curtop};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isObject(item) {
|
||||||
|
return (item && typeof item === 'object' && !Array.isArray(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mergeDeep(target, source) {
|
||||||
|
let output = Object.assign({}, target);
|
||||||
|
if (isObject(target) && isObject(source)) {
|
||||||
|
Object.keys(source).forEach(key => {
|
||||||
|
if (isObject(source[key])) {
|
||||||
|
if (!(key in target))
|
||||||
|
Object.assign(output, { [key]: source[key] });
|
||||||
|
else
|
||||||
|
output[key] = mergeDeep(target[key], source[key]);
|
||||||
|
} else {
|
||||||
|
Object.assign(output, { [key]: source[key] });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
import ColorValuePicker from './ColorValuePicker.js';
|
import ColorValuePicker from './ColorValuePicker.js';
|
||||||
import Slider from './Slider.js';
|
import Slider from './Slider.js';
|
||||||
import {findPos} from './Util.js';
|
import {findPos,mergeDeep} from './Util.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @external Math
|
* @external Math
|
||||||
@@ -367,8 +367,7 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
|
|||||||
changeEvents = null;
|
changeEvents = null;
|
||||||
}
|
}
|
||||||
let r, g, b, a, h, s, v, changeEvents = [];
|
let r, g, b, a, h, s, v, changeEvents = [];
|
||||||
|
Object.assign(that, {
|
||||||
$.extend(true, that, {
|
|
||||||
// public properties and methods
|
// public properties and methods
|
||||||
val,
|
val,
|
||||||
bind,
|
bind,
|
||||||
@@ -612,10 +611,13 @@ const {Color, List, ColorMethods} = jPicker; // local copies for YUI compressor
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
export function jPickerMethod (elem, options, commitCallback, liveCallback, cancelCallback) {
|
export function jPickerMethod (elem, options, commitCallback, liveCallback, cancelCallback) {
|
||||||
|
let sets = mergeDeep({}, jPickerDefaults); // local copies for YUI compressor
|
||||||
|
sets = mergeDeep(sets, options);
|
||||||
|
|
||||||
const that = elem,
|
const that = elem,
|
||||||
settings = $.extend(true, {}, jPickerDefaults, options); // local copies for YUI compressor
|
settings = sets;
|
||||||
if (that.nodeName.toLowerCase() === 'input') { // Add color picker icon if binding to an input element and bind the events to the input
|
if (that.nodeName.toLowerCase() === 'input') { // Add color picker icon if binding to an input element and bind the events to the input
|
||||||
$.extend(true, settings, {
|
Object.assign(settings, {
|
||||||
window: {
|
window: {
|
||||||
bindToInput: true,
|
bindToInput: true,
|
||||||
expandable: true,
|
expandable: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user