238 |
238 |
*/
|
239 |
239 |
process_okcancel: function( ok_or_cancel ) {
|
240 |
240 |
if ( 'ok' === ok_or_cancel ) {
|
|
241 |
console.log('going');
|
|
242 |
console.log(self.$jcw_half);
|
|
243 |
console.log(self.$jcw_half.find('.editable-content'));
|
241 |
244 |
var cleaned_content = self.clean_content( self.$jcw_half.find( '.editable-content' ).html() );
|
242 |
245 |
// Copy new content to hidden input
|
243 |
246 |
self.$jcw_half.find( '.editable-content-stash' ).val( cleaned_content );
|
... | ... | |
274 |
277 |
// followed immediately by an HTML tag)
|
275 |
278 |
clean_content = clean_content.replace( /\n([^<])/g, " $1" );
|
276 |
279 |
|
|
280 |
// Remove quotes and escape chars.
|
|
281 |
clean_content = $('<div />').text(clean_content).html();
|
|
282 |
|
277 |
283 |
return clean_content;
|
278 |
284 |
},
|
279 |
285 |
|
... | ... | |
495 |
501 |
}
|
496 |
502 |
|
497 |
503 |
// Activate editable fields
|
498 |
|
self.$w.find( 'article.editable-content' ).css( 'min-height', '2em' ).attr( 'contenteditable', 'true' );
|
|
504 |
self.$w.find( 'article.editable-content' ).css( 'min-height', '2em' ).attr( 'contenteditable', 'true' ).keydown(function(e){
|
|
505 |
if ( 222 === event.which ) {
|
|
506 |
e.preventDefault();
|
|
507 |
$apostropheContainer = $(this);
|
|
508 |
$apostropheContainer.html( $apostropheContainer.html() + "'" );
|
|
509 |
self.placeCaretAtEnd(this);
|
|
510 |
}
|
|
511 |
});
|
499 |
512 |
|
500 |
513 |
// Add section IDs
|
501 |
514 |
self.$w.find( '.cacap-widget-title' ).attr( 'id', self.wid + '-title' );
|
... | ... | |
756 |
769 |
$about_you_gloss.addClass( class_to_add );
|
757 |
770 |
},
|
758 |
771 |
|
|
772 |
|
|
773 |
placeCaretAtEnd: function(el) {
|
|
774 |
el.focus();
|
|
775 |
if (typeof window.getSelection != "undefined"
|
|
776 |
&& typeof document.createRange != "undefined") {
|
|
777 |
var range = document.createRange();
|
|
778 |
range.selectNodeContents(el);
|
|
779 |
range.collapse(false);
|
|
780 |
var sel = window.getSelection();
|
|
781 |
sel.removeAllRanges();
|
|
782 |
sel.addRange(range);
|
|
783 |
} else if (typeof document.body.createTextRange != "undefined") {
|
|
784 |
var textRange = document.body.createTextRange();
|
|
785 |
textRange.moveToElementText(el);
|
|
786 |
textRange.collapse(false);
|
|
787 |
textRange.select();
|
|
788 |
}
|
|
789 |
},
|
|
790 |
|
759 |
791 |
// Init methods to run after document is ready
|
760 |
792 |
init: function() {
|
761 |
793 |
self = this;
|