wire/modules/Page/PageFrontEdit/PageFrontEdit.js
/**
	 * Event for when the "save" button is clicked
	 * 
	 */
Event for when the "save" button is clicked
Event for when the " save " button is clicked
function inlineSaveClickEvent() {
		if(busy) return;
		setBusy(true);
		var pageID = parseInt($('#Inputfield_id').val());
		var langID = parseInt($('#pw-edit-lang').val());
		var btnSave = $('.pw-edit-save');
		var btnCancel = $('.pw-edit-cancel');
		var btnSaving = $('.pw-edit-saving');
		var btnSaved = $('.pw-edit-saved');
		var edited = $('.pw-changed');
		var postData = {
			action: 'PageFrontEditSave',
			id: pageID,
			language: langID,
			fields: {}
		};
		var postToken = $('input._post_token');
		var csrfName = postToken.attr('name');
		var csrfValue = postToken.val();
		postData[csrfName] = csrfValue;
		edited.each(function() {
			var t = $(this);
			var name = t.attr('data-name');
			var page = parseInt(t.attr('data-page'));
			var orig = t.children('.pw-edit-orig');
			var copy = t.children('.pw-edit-copy');
			var key = page + '__' + name;
			if(t.hasClass('pw-edit-InputfieldCKEditor')) {
				var editor = ckeditors[copy.attr('id')];
				editor.getSelection().reset();
				editor.getSelection().removeAllRanges();
				postData.fields[key] = editor.getData();
			} else {
				var textarea = document.createElement('textarea');
				textarea.innerHTML = copy[0].innerHTML;
				postData.fields[key] = textarea.value;
			}
		});
		btnSave.hide();
		btnCancel.hide();
		btnSaving.show();
		$.post(ProcessWire.config.PageFrontEdit.pageURL, postData, function(data) {
			btnSaving.hide();
			if(data.status > 0) {
				edited.each(function() {
					var t = $(this);
					var name = t.attr('data-name');
					var page = t.attr('data-page');
					var orig = t.children('.pw-edit-orig');
					var copy = t.children('.pw-edit-copy');
					var key = page + '__' + name;
					t.removeClass('pw-editing pw-edited pw-changed');
					orig.html(data.formatted[key]);
					copy.html(data.unformatted[key]);
					copy.data('prev', null);
					copy.hide().trigger('pw-reloaded');
					orig.show().trigger('pw-reloaded');
				});
				btnSaved.show();
				setTimeout(function() {
					buttons.fadeOut('fast', function() {
						btnSaved.hide();
						btnSave.show();
						btnCancel.show();
						setBusy(false);
					});
				}, 1000);
			} else {
				setBusy(false);
				alert(data.error);
				btnSave.show();
				btnCancel.show();
				buttons.hide();
				$('.pw-editing, .pw-edited').each(function() {
					var t = $(this);
					t.removeClass('pw-editing, pw-edited, pw-changed');
					var orig = t.children('.pw-edit-orig');
					var copy = t.children('.pw-edit-copy');
					copy.hide();
					orig.show();
				});
			}
			for(var copyID in ckeditors) {
				var instance = ckeditors[copyID];
				instance.destroy();
			}
			ckeditors = {};
		});
	}
function inlineSaveClickEvent ( ) { if ( busy ) return ; setBusy ( true ) ; var pageID = parseInt ( $ ( '#Inputfield_id' ) . val ( ) ) ; var langID = parseInt ( $ ( '#pw-edit-lang' ) . val ( ) ) ; var btnSave = $ ( '.pw-edit-save' ) ; var btnCancel = $ ( '.pw-edit-cancel' ) ; var btnSaving = $ ( '.pw-edit-saving' ) ; var btnSaved = $ ( '.pw-edit-saved' ) ; var edited = $ ( '.pw-changed' ) ; var postData = { action : 'PageFrontEditSave' , id : pageID , language : langID , fields : { } } ; var postToken = $ ( 'input._post_token' ) ; var csrfName = postToken . attr ( 'name' ) ; var csrfValue = postToken . val ( ) ; postData [ csrfName ] = csrfValue ; edited . each ( function ( ) { var t = $ ( this ) ; var name = t . attr ( 'data-name' ) ; var page = parseInt ( t . attr ( 'data-page' ) ) ; var orig = t . children ( '.pw-edit-orig' ) ; var copy = t . children ( '.pw-edit-copy' ) ; var key = page + '__' + name ; if ( t . hasClass ( 'pw-edit-InputfieldCKEditor' ) ) { var editor = ckeditors [ copy . attr ( 'id' ) ] ; editor . getSelection ( ) . reset ( ) ; editor . getSelection ( ) . removeAllRanges ( ) ; postData . fields [ key ] = editor . getData ( ) ; } else { var textarea = document . createElement ( 'textarea' ) ; textarea . innerHTML = copy [ 0 ] . innerHTML ; postData . fields [ key ] = textarea . value ; } } ) ; btnSave . hide ( ) ; btnCancel . hide ( ) ; btnSaving . show ( ) ; $ . post ( ProcessWire . config . PageFrontEdit . pageURL , postData , function ( data ) { btnSaving . hide ( ) ; if ( data . status > 0 ) { edited . each ( function ( ) { var t = $ ( this ) ; var name = t . attr ( 'data-name' ) ; var page = t . attr ( 'data-page' ) ; var orig = t . children ( '.pw-edit-orig' ) ; var copy = t . children ( '.pw-edit-copy' ) ; var key = page + '__' + name ; t . removeClass ( 'pw-editing pw-edited pw-changed' ) ; orig . html ( data . formatted [ key ] ) ; copy . html ( data . unformatted [ key ] ) ; copy . data ( 'prev' , null ) ; copy . hide ( ) . trigger ( 'pw-reloaded' ) ; orig . show ( ) . trigger ( 'pw-reloaded' ) ; } ) ; btnSaved . show ( ) ; setTimeout ( function ( ) { buttons . fadeOut ( 'fast' , function ( ) { btnSaved . hide ( ) ; btnSave . show ( ) ; btnCancel . show ( ) ; setBusy ( false ) ; } ) ; } , 1000 ) ; } else { setBusy ( false ) ; alert ( data . error ) ; btnSave . show ( ) ; btnCancel . show ( ) ; buttons . hide ( ) ; $ ( '.pw-editing, .pw-edited' ) . each ( function ( ) { var t = $ ( this ) ; t . removeClass ( 'pw-editing, pw-edited, pw-changed' ) ; var orig = t . children ( '.pw-edit-orig' ) ; var copy = t . children ( '.pw-edit-copy' ) ; copy . hide ( ) ; orig . show ( ) ; } ) ; } for ( var copyID in ckeditors ) { var instance = ckeditors [ copyID ] ; instance . destroy ( ) ; } ckeditors = { } ; } ) ; }
Event for when the "save" button is clicked
Event for when the " save " button is clicked
/*
				if(editor.focusManager.hasFocus) {
					// CKEditor has documented bug that causes JS error on editor.getData(), so this prevents it
					editor.focusManager.focus(true);
					editor.focus();
				}
				*/ // post save data to server // success // error	