YET another take on an alarm system

Here is a quick and dirty fix for the jscolor.js file:

Replace the two function:
onDocumentMouseDown and onDocumentTouchStart

onDocumentMouseDown : function (e) {

	if (!e) { e = window.event; }
	var path = (typeof(e.path) == 'object') ? e.path[0] : null;
	if(path == null){
		return null;
	}
	var hasKey = "_jscLinkedInstance" in path;
	var target = e.explicitOriginalTarget || path;
	if(hasKey == false){
		return null;
	}
	if (target._jscLinkedInstance) {
		if (target._jscLinkedInstance.showOnClick) {
			target._jscLinkedInstance.show();
		}
	} else if (target._jscControlName) {
		jsc.onControlPointerStart(e, target, target._jscControlName, 'mouse');
	} else {
		// Mouse is outside the picker controls -> hide the color picker!
		if (jsc.picker && jsc.picker.owner) {
			jsc.picker.owner.hide();
		}
	}
},


onDocumentTouchStart : function (e) {
	if (!e) { e = window.event; }
	var path = (typeof(e.path) == 'object') ? e.path[0] : null;
	if(path == null){
		return null;
	}
	var hasKey = "_jscLinkedInstance" in path;
	var target = e.explicitOriginalTarget || path;
	if(hasKey == false){
		return null;
	}
	if (target._jscLinkedInstance) {
		if (target._jscLinkedInstance.showOnClick) {

			target._jscLinkedInstance.show();
		}
	} else if (target._jscControlName) {
		jsc.onControlPointerStart(e, target, target._jscControlName, 'touch');
	} else {
		if (jsc.picker && jsc.picker.owner) {
			jsc.picker.owner.hide();
		}
	}
},
3 Likes