MCPcopy
hub / github.com/GrapesJS/grapesjs / spectrum

Function spectrum

packages/core/src/utils/ColorPicker.ts:220–1019  ·  view source on GitHub ↗
(element, o)

Source from the content-addressed store, hash-verified

218 }
219
220 function spectrum(element, o) {
221 var opts = instanceOptions(o, element),
222 flat = opts.flat,
223 showSelectionPalette = opts.showSelectionPalette,
224 localStorageKey = opts.localStorageKey,
225 theme = opts.theme,
226 callbacks = opts.callbacks,
227 resize = throttle(reflow, 10),
228 visible = false,
229 isDragging = false,
230 isDefault = true,
231 dragWidth = 0,
232 dragHeight = 0,
233 dragHelperHeight = 0,
234 slideHeight = 0,
235 slideWidth = 0,
236 alphaWidth = 0,
237 alphaSlideHelperWidth = 0,
238 slideHelperHeight = 0,
239 currentHue = 0,
240 currentSaturation = 0,
241 currentValue = 0,
242 currentAlpha = 1,
243 palette = [],
244 paletteArray = [],
245 paletteLookup = {},
246 selectionPalette = opts.selectionPalette.slice(0),
247 maxSelectionSize = opts.maxSelectionSize,
248 draggingClass = 'sp-dragging',
249 shiftMovementDirection = null;
250
251 var doc = element.ownerDocument,
252 body = doc.body,
253 boundElement = $(element),
254 disabled = false,
255 container = $(markup, doc).addClass(theme),
256 pickerContainer = container.find('.sp-picker-container'),
257 dragger = container.find('.sp-color'),
258 dragHelper = container.find('.sp-dragger'),
259 slider = container.find('.sp-hue'),
260 slideHelper = container.find('.sp-slider'),
261 alphaSliderInner = container.find('.sp-alpha-inner'),
262 alphaSlider = container.find('.sp-alpha'),
263 alphaSlideHelper = container.find('.sp-alpha-handle'),
264 textInput = container.find('.sp-input'),
265 paletteContainer = container.find('.sp-palette'),
266 initialColorContainer = container.find('.sp-initial'),
267 cancelButton = container.find('.sp-cancel'),
268 clearButton = container.find('.sp-clear'),
269 chooseButton = container.find('.sp-choose'),
270 toggleButton = container.find('.sp-palette-toggle'),
271 isInput = boundElement.is('input'),
272 isInputTypeColor = isInput && boundElement.attr('type') === 'color' && inputTypeColorSupport(),
273 shouldReplace = isInput && !flat,
274 replacer = shouldReplace
275 ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName)
276 : $([]),
277 offsetElement = shouldReplace ? replacer : boundElement,

Callers 1

ColorPicker.tsFile · 0.85

Calls 9

instanceOptionsFunction · 0.85
throttleFunction · 0.85
inputTypeColorSupportFunction · 0.85
updateOriginalInputFunction · 0.85
isMethod · 0.80
initializeFunction · 0.70
setFunction · 0.70
addClassMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected