Fz-29 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/378277 )
Change subject: Adding placeholder emulation for hierarchy structure textarea ...................................................................... Adding placeholder emulation for hierarchy structure textarea Change-Id: Ic8f39fff95fb5cd86ea4b29c405a7bb768daf243 --- M PageForms.php M libs/PF_CreateClass.js M specials/PF_CreateClass.php 3 files changed, 34 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageForms refs/changes/77/378277/1 diff --git a/PageForms.php b/PageForms.php index 9d12d22..8cef744 100644 --- a/PageForms.php +++ b/PageForms.php @@ -456,6 +456,9 @@ 'scripts' => array( 'libs/PF_CreateClass.js', ), + 'messages' => array( + 'pf_createtemplate_hierarchystructureplaceholder', + ), ), 'ext.pageforms.PF_CreateForm' => $wgPageFormsResourceTemplate + array( 'scripts' => array( diff --git a/libs/PF_CreateClass.js b/libs/PF_CreateClass.js index 89fa021..9df0ca7 100644 --- a/libs/PF_CreateClass.js +++ b/libs/PF_CreateClass.js @@ -1,4 +1,5 @@ var rowNum = mediaWiki.config.get( '$numStartingRows'); +var hierarchyPlaceholder = '*replace\n**placeholder\n***using\n*i18n'; //mediaWiki.msg( 'pf_createtemplate_hierarchystructureplaceholder' ); function createClassAddRow() { rowNum++; var newRow = jQuery('#starterRow').clone().css('display', ''); @@ -42,10 +43,27 @@ if (containerElement.find( "input[name*='is_hierarchy_']" ).prop('checked')) { containerElement.find( "input[name*='allowed_values_']" ).hide('medium'); containerElement.find( "textarea[name*='hierarchy_structure_']" ).show('medium'); + if (containerElement.find( "textarea[name*='hierarchy_structure_']" ).val() === "") { + setHierarchyPlaceholder( containerElement.find( "textarea[name*='hierarchy_structure_']" ) ); + } } else { containerElement.find( "textarea[name*='hierarchy_structure_']" ).hide('medium'); containerElement.find( "input[name*='allowed_values_']" ).show('medium'); } +} + +function setHierarchyPlaceholder( textareaElement ) { + if (textareaElement.val() === "") { + textareaElement.val( hierarchyPlaceholder ); + textareaElement.css( 'color', 'gray' ); + textareaElement.attr( 'validInput', 'false' ); + } +} + +function removeHierarchyPlaceholder( textareaElement ) { + textareaElement.val( '' ); + textareaElement.css( 'color', 'black' ); + textareaElement.attr( 'validInput', 'true' ); } jQuery( document ).ready( function () { @@ -61,4 +79,15 @@ jQuery( "input[name*='is_hierarchy_']" ).click( function () { toggleHierarchyInput(jQuery( this ).closest( "tr" )); } ); -} ); + jQuery( "input[name*='is_hierarchy_']" ).click( function () { + toggleHierarchyInput(jQuery( this ).closest( "tr" )); + } ); + jQuery( "textarea[name*='hierarchy_structure_']" ).blur( function () { + setHierarchyPlaceholder( jQuery( this ) ); + } ); + jQuery( "textarea[name*='hierarchy_structure_']" ).click( function () { + if (jQuery( this ).attr( 'validInput' ) === undefined || jQuery( this ).attr( 'validInput' ) !== 'true') { + removeHierarchyPlaceholder( jQuery( this ) ); + } + } ); +} ); \ No newline at end of file diff --git a/specials/PF_CreateClass.php b/specials/PF_CreateClass.php index f52d308..93d9132 100644 --- a/specials/PF_CreateClass.php +++ b/specials/PF_CreateClass.php @@ -384,9 +384,8 @@ <input type="text" size="25" name="allowed_values_$n" /> END; if ( defined( 'CARGO_VERSION' ) ) { - $hierarchyStructurePlaceholder = wfMessage( 'pf_createtemplate_hierarchystructureplaceholder' )->escaped(); $text .= <<<END - <textarea rows="10" cols="20" name="hierarchy_structure_$n" placeholder="$hierarchyStructurePlaceholder" style="display: none;"></textarea> + <textarea rows="10" cols="20" name="hierarchy_structure_$n" style="display: none;"></textarea> END; } $text .= <<<END -- To view, visit https://gerrit.wikimedia.org/r/378277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic8f39fff95fb5cd86ea4b29c405a7bb768daf243 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/PageForms Gerrit-Branch: master Gerrit-Owner: Fz-29 <f29ah...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits