[MediaWiki-commits] [Gerrit] mediawiki...PageForms[master]: Adding placeholder emulation for hierarchy structure textarea

2017-10-02 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
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 extension.json
M libs/PF_CreateClass.js
M libs/PF_CreateTemplate.js
M specials/PF_CreateClass.php
M specials/PF_CreateTemplate.php
6 files changed, 84 insertions(+), 7 deletions(-)

Approvals:
  Yaron Koren: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PageForms.php b/PageForms.php
index 9d12d22..05d168f 100644
--- a/PageForms.php
+++ b/PageForms.php
@@ -450,12 +450,16 @@
),
'messages' => array(
'pf_blank_error',
+   'pf_createtemplate_hierarchystructureplaceholder',
),
),
'ext.pageforms.PF_CreateClass' => $wgPageFormsResourceTemplate + array(
'scripts' => array(
'libs/PF_CreateClass.js',
),
+   'messages' => array(
+   'pf_createtemplate_hierarchystructureplaceholder',
+   ),
),
'ext.pageforms.PF_CreateForm' => $wgPageFormsResourceTemplate + array(
'scripts' => array(
diff --git a/extension.json b/extension.json
index 3f2355d..1dcd240 100644
--- a/extension.json
+++ b/extension.json
@@ -372,12 +372,16 @@
"libs/PF_CreateTemplate.js"
],
"messages": [
-   "pf_blank_error"
+   "pf_blank_error",
+   
"pf_createtemplate_hierarchystructureplaceholder"
]
},
"ext.pageforms.PF_CreateClass": {
"scripts": [
"libs/PF_CreateClass.js"
+   ],
+   "messages": [
+   
"pf_createtemplate_hierarchystructureplaceholder"
]
},
"ext.pageforms.PF_CreateForm": {
diff --git a/libs/PF_CreateClass.js b/libs/PF_CreateClass.js
index 89fa021..b9cfdb1 100644
--- a/libs/PF_CreateClass.js
+++ b/libs/PF_CreateClass.js
@@ -1,9 +1,21 @@
 var rowNum = mediaWiki.config.get( '$numStartingRows');
+var hierarchyPlaceholder =  mediaWiki.msg( 
'pf_createtemplate_hierarchystructureplaceholder' );
 function createClassAddRow() {
rowNum++;
-   var newRow = jQuery('#starterRow').clone().css('display', '');
+   var newRow = jQuery('#starterRow').clone().css('display', 
'').removeAttr( 'id' );
var newHTML = newRow.html().replace(/starter/g, rowNum);
newRow.html(newHTML);
+   newRow.find( "input[name*='is_hierarchy_']" ).click( function () {
+   toggleHierarchyInput(jQuery( this ).closest( "tr" ));
+   } );
+   newRow.find( ".hierarchy_structure" ).blur( function () {
+   setHierarchyPlaceholder( jQuery( this ) );
+   } );
+   newRow.find( ".hierarchy_structure" ).click( function () {
+   if (jQuery( this ).attr( 'validInput' ) === undefined || 
jQuery( this ).attr( 'validInput' ) !== 'true') {
+   removeHierarchyPlaceholder( jQuery( this ) );
+   }
+   } );
jQuery('#mainTable').append(newRow);
 }
 
@@ -42,10 +54,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 +90,12 @@
jQuery( "input[name*='is_hierarchy_']" ).click( function () {

[MediaWiki-commits] [Gerrit] mediawiki...PageForms[master]: Adding placeholder emulation for hierarchy structure textarea

2017-09-15 Thread Fz-29 (Code Review)
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 @@

 END;
if ( defined( 'CARGO_VERSION' ) ) {
-   $hierarchyStructurePlaceholder = wfMessage( 
'pf_createtemplate_hierarchystructureplaceholder' )->escaped();
$text .= <<
+   
 END;
}
$text .= <

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits