()
| 317 | } |
| 318 | |
| 319 | function initialize() { |
| 320 | if (IE) { |
| 321 | container.find('*:not(input)').attr('unselectable', 'on'); |
| 322 | } |
| 323 | |
| 324 | applyOptions(); |
| 325 | |
| 326 | if (shouldReplace) { |
| 327 | boundElement.after(replacer).hide(); |
| 328 | } |
| 329 | |
| 330 | if (!allowEmpty) { |
| 331 | clearButton.hide(); |
| 332 | } |
| 333 | |
| 334 | if (flat) { |
| 335 | boundElement.after(container).hide(); |
| 336 | } else { |
| 337 | var appendTo = opts.appendTo === 'parent' ? boundElement.parent() : $(opts.appendTo); |
| 338 | if (appendTo.length !== 1) { |
| 339 | appendTo = $('body'); |
| 340 | } |
| 341 | |
| 342 | appendTo.append(container); |
| 343 | } |
| 344 | |
| 345 | updateSelectionPaletteFromStorage(); |
| 346 | |
| 347 | offsetElement.bind('click.spectrum touchstart.spectrum', function (e) { |
| 348 | if (!disabled) { |
| 349 | toggle(); |
| 350 | } |
| 351 | |
| 352 | e.stopPropagation(); |
| 353 | |
| 354 | if (!$(e.target).is('input')) { |
| 355 | e.preventDefault(); |
| 356 | } |
| 357 | }); |
| 358 | |
| 359 | if (boundElement.is(':disabled') || opts.disabled === true) { |
| 360 | disable(); |
| 361 | } |
| 362 | |
| 363 | // Prevent clicks from bubbling up to document. This would cause it to be hidden. |
| 364 | container.click(stopPropagation); |
| 365 | |
| 366 | // Handle user typed input |
| 367 | textInput.change(setFromTextInput); |
| 368 | textInput.bind('paste', function () { |
| 369 | setTimeout(setFromTextInput, 1); |
| 370 | }); |
| 371 | textInput.keydown(function (e) { |
| 372 | if (e.keyCode == 13) { |
| 373 | setFromTextInput(); |
| 374 | } |
| 375 | }); |
| 376 |
no test coverage detected