Skip to content

Commit

Permalink
#46 $.extend change to pure javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
AgriyaDev5 committed Feb 16, 2021
1 parent ad33f45 commit d73a0de
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
21 changes: 21 additions & 0 deletions src/editor/components/jgraduate/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,25 @@ 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;
}
12 changes: 7 additions & 5 deletions src/editor/components/jgraduate/jQuery.jPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* eslint-disable max-len */
import ColorValuePicker from './ColorValuePicker.js';
import Slider from './Slider.js';
import {findPos} from './Util.js';
import {findPos,mergeDeep} from './Util.js';

/**
* @external Math
Expand Down Expand Up @@ -367,8 +367,7 @@ export const jPicker = /** @lends external:jQuery.jPicker */ {
changeEvents = null;
}
let r, g, b, a, h, s, v, changeEvents = [];

$.extend(true, that, {
Object.assign(that, {
// public properties and methods
val,
bind,
Expand Down Expand Up @@ -612,10 +611,13 @@ const {Color, List, ColorMethods} = jPicker; // local copies for YUI compressor
* @returns {void}
*/
export function jPickerMethod (elem, options, commitCallback, liveCallback, cancelCallback) {
let sets = mergeDeep({}, jPickerDefaults); // local copies for YUI compressor
sets = mergeDeep(sets, options);

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
$.extend(true, settings, {
Object.assign(settings, {
window: {
bindToInput: true,
expandable: true,
Expand Down

0 comments on commit d73a0de

Please sign in to comment.