Build a rudimentary placeholder engine into the editor
This commit is contained in:
@@ -33,17 +33,6 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#gollum-editor-title-field input {
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gollum-editor-title-field.active {
|
|
||||||
border-bottom: 1px solid #ddd;
|
|
||||||
display: block;
|
|
||||||
margin: 0 0 0.3em 0;
|
|
||||||
padding: 0 0 0.5em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gollum-editor .singleline {
|
#gollum-editor .singleline {
|
||||||
display: block;
|
display: block;
|
||||||
margin: 0 0 0.7em 0;
|
margin: 0 0 0.7em 0;
|
||||||
@@ -66,6 +55,21 @@
|
|||||||
color: #999;
|
color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#gollum-editor-title-field input {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gollum-editor-title-field.active {
|
||||||
|
border-bottom: 1px solid #ddd;
|
||||||
|
display: block;
|
||||||
|
margin: 0 0 0.3em 0;
|
||||||
|
padding: 0 0 0.5em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#gollum-editor-title-field input#gollum-editor-page-title.ph {
|
||||||
|
color: #000;
|
||||||
|
}
|
||||||
|
|
||||||
/* @control editor-view-tab */
|
/* @control editor-view-tab */
|
||||||
#gollum-editor #gollum-editor-type-switcher {
|
#gollum-editor #gollum-editor-type-switcher {
|
||||||
display: none;
|
display: none;
|
||||||
|
|||||||
@@ -25,18 +25,18 @@
|
|||||||
*/
|
*/
|
||||||
$.GollumEditor = function( IncomingOptions ) {
|
$.GollumEditor = function( IncomingOptions ) {
|
||||||
|
|
||||||
ActiveOptions = $.extend( DefaultOptions, IncomingOptions );
|
ActiveOptions = $.extend( DefaultOptions, IncomingOptions );
|
||||||
|
|
||||||
|
|
||||||
debug('GollumEditor loading');
|
debug('GollumEditor loading');
|
||||||
|
|
||||||
if ( EditorHas.baseEditorMarkup() ) {
|
if ( EditorHas.baseEditorMarkup() ) {
|
||||||
|
|
||||||
if ( ActiveOptions.NewFile ) {
|
if ( EditorHas.titleDisplayed() ) {
|
||||||
$('#gollum-editor-title-field').addClass('active');
|
$('#gollum-editor-title-field').addClass('active');
|
||||||
$('#gollum-editor-title-field input').focus(function() {
|
}
|
||||||
$(this)[0].select();
|
|
||||||
});
|
if ( EditorHas.editSummaryMarkup() ) {
|
||||||
|
Placeholder.add( $('#gollum-editor-edit-summary input') )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the function bar by loading proper definitions
|
// Initialize the function bar by loading proper definitions
|
||||||
@@ -238,6 +238,10 @@
|
|||||||
return ( ua.test( navigator.userAgent ) );
|
return ( ua.test( navigator.userAgent ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editSummaryMarkup: function() {
|
||||||
|
return ( $('input#gollum-editor-message-field').length > 0 );
|
||||||
|
},
|
||||||
|
|
||||||
titleDisplayed: function() {
|
titleDisplayed: function() {
|
||||||
return ( ActiveOptions.NewFile );
|
return ( ActiveOptions.NewFile );
|
||||||
}
|
}
|
||||||
@@ -609,5 +613,55 @@
|
|||||||
$.GollumEditor.replaceSelection = function( repText ) {
|
$.GollumEditor.replaceSelection = function( repText ) {
|
||||||
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
|
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var Placeholder = {
|
||||||
|
|
||||||
|
_PLACEHOLDERS : [],
|
||||||
|
|
||||||
|
_p : function( $field ) {
|
||||||
|
|
||||||
|
this.fieldObject = $field;
|
||||||
|
this.placeholderText = $field.val();
|
||||||
|
var placeholderText = $field.val();
|
||||||
|
|
||||||
|
$field.addClass('ph');
|
||||||
|
|
||||||
|
$field.blur(function() {
|
||||||
|
if ( $(this).val() == '' ) {
|
||||||
|
$(this).val( placeholderText );
|
||||||
|
$(this).addClass('ph');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$field.focus(function() {
|
||||||
|
$(this).removeClass('ph');
|
||||||
|
if ( $(this).val() == placeholderText ) {
|
||||||
|
$(this).val('');
|
||||||
|
} else {
|
||||||
|
$(this)[0].select();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
add : function( $field ) {
|
||||||
|
Placeholder._PLACEHOLDERS.push( new Placeholder._p( $field ) );
|
||||||
|
},
|
||||||
|
|
||||||
|
clearAll: function() {
|
||||||
|
for ( var i=0; i < Placeholder._PLACEHOLDERS.length; i++ ) {
|
||||||
|
if ( Placeholder._PLACEHOLDERS[i].fieldObject.val() ==
|
||||||
|
Placeholder._PLACEHOLDERS[i].placeholderText ) {
|
||||||
|
Placeholder._PLACEHOLDERS[i].fieldObject.val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
exists : function() {
|
||||||
|
return ( _PLACEHOLDERS.length );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// })(jQuery);
|
// })(jQuery);
|
||||||
|
|||||||
Reference in New Issue
Block a user