wire/modules/Page/PageFrontEdit/PageFrontEdit.js
/**
	 * Initialize an editable region
	 * 
	 * @param t The editable region with class "pw-edit"
	 * 
	 */
Initialize an editable region

@param t The editable region with class "pw-edit"
Initialize an editable region @param t The editable region with class " pw - edit "
function inlineInitEditableRegion(t) {
		var orig = t.children('.pw-edit-orig');
		var copy = t.children('.pw-edit-copy');
		var name = t.attr('data-name');
		copy.hide();
		if(isTouch) orig.on('pwdoubletap', function(e) {
			inlineEditEvent(e, t, orig, copy);
			return false;
		});
		orig.dblclick(function(e) {
			inlineEditEvent(e, t, orig, copy);
			return false;
		});
		if(t.is('span')) { 
			copy.keydown(function(e) {
				if(e.keyCode == 13){
					e.preventDefault();
					$(this).blur();
				}
			});
		}
		if(orig.find('a').length) {
			var clicks = 0, timer = null, allowClick = false;
			orig.on('click', 'a', function() {
				var $a = jQuery(this);
				if(allowClick) {
					allowClick = false;
					return true;
				}
				clicks++;
				if(clicks === 1) {
					timer = setTimeout(function() {
						clicks = 0;
						allowClick = true;
						$a[0].click();
						return true;
					}, 700);
				} else {
					clearTimeout(timer); 
					allowClick = false;
					clicks = 0;
					orig.trigger('dblclick');
				}
				return false;
			});
			orig.on('dblclick', 'a', function() {
				return false;
			});
		}
		if(!t.hasClass('pw-edit-InputfieldCKEditor')) {
			copy.blur(function() {
				var copy = $(this);
				var t = copy.closest('.pw-editing');
				if(t.length == 0) return;
				if(copy.html() != copy.data('prev')) {
					t.addClass('pw-changed');
				}
				t.removeClass('pw-editing');
			});
		}
	}
function inlineInitEditableRegion ( t ) { var orig = t . children ( '.pw-edit-orig' ) ; var copy = t . children ( '.pw-edit-copy' ) ; var name = t . attr ( 'data-name' ) ; copy . hide ( ) ; if ( isTouch ) orig . on ( 'pwdoubletap' , function ( e ) { inlineEditEvent ( e , t , orig , copy ) ; return false ; } ) ; orig . dblclick ( function ( e ) { inlineEditEvent ( e , t , orig , copy ) ; return false ; } ) ; if ( t . is ( 'span' ) ) { copy . keydown ( function ( e ) { if ( e . keyCode == 13 ) { e . preventDefault ( ) ; $ ( this ) . blur ( ) ; } } ) ; } if ( orig . find ( 'a' ) . length ) { var clicks = 0 , timer = null , allowClick = false ; orig . on ( 'click' , 'a' , function ( ) { var $a = jQuery ( this ) ; if ( allowClick ) { allowClick = false ; return true ; } clicks ++ ; if ( clicks === 1 ) { timer = setTimeout ( function ( ) { clicks = 0 ; allowClick = true ; $a [ 0 ] . click ( ) ; return true ; } , 700 ) ; } else { clearTimeout ( timer ) ; allowClick = false ; clicks = 0 ; orig . trigger ( 'dblclick' ) ; } return false ; } ) ; orig . on ( 'dblclick' , 'a' , function ( ) { return false ; } ) ; } if ( ! t . hasClass ( 'pw-edit-InputfieldCKEditor' ) ) { copy . blur ( function ( ) { var copy = $ ( this ) ; var t = copy . closest ( '.pw-editing' ) ; if ( t . length == 0 ) return ; if ( copy . html ( ) != copy . data ( 'prev' ) ) { t . addClass ( 'pw-changed' ) ; } t . removeClass ( 'pw-editing' ) ; } ) ; } }
Initialize an editable region
Initialize an editable region
// single-line text // via @canrau // check if orig has clickable links within it // if so, differentiate between single and double clicks // so that we can enable those links to still work while also supporting dblclick // prevent single-click action // handler for non-cke blur event // console.log('changed');