Sebschlicht2 has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/342646 )

Change subject: placeholders
......................................................................


placeholders

Placeholders have been added to all form controls.
Placeholders are localized using the MW message API.
To use these messages in dynamically created lists, a data
attribute has been used.

Change-Id: Id297af1ecff0a327c043837fa103ff5205d37da0
---
M i18n/de.json
M i18n/en.json
M i18n/qqq.json
M includes/rendering/MoocContentRenderer.php
M includes/rendering/MoocLessonRenderer.php
M includes/rendering/MoocOverviewRenderer.php
M resources/js/ext.mooc.edit.js
7 files changed, 45 insertions(+), 11 deletions(-)



diff --git a/i18n/de.json b/i18n/de.json
index 97d3373..84c9a78 100644
--- a/i18n/de.json
+++ b/i18n/de.json
@@ -49,5 +49,13 @@
   "mooc-section-units-empty-description": "Dieser Lektion wurden noch keine 
Lerneinheiten hinzugefügt.",
   "mooc-section-units-empty-edit-link": "Klicken Sie auf \"Lerneinheit 
hinzufügen\", um eine Lerneinheit hinzuzufügen.",
   "_mooc-comment-button-...": "// Label für allgemeine Schaltflächen der 
Benutzeroberfläche.",
-  "mooc-button-expand-section": "Hier klicken zum Ausklappen"
+  "mooc-button-expand-section": "Hier klicken zum Ausklappen",
+
+  "mooc-overview-add-lesson-modal-placeholder-name": "Name der neuen Lektion",
+  "mooc-lesson-add-unit-modal-placeholder-name": "Name der neuen Lerneinheit",
+  "mooc-unit-edit-learning-goals-modal-placeholder-value": "Neues Lernziel",
+  "mooc-unit-edit-video-modal-placeholder-value": "Dateiname des Videos",
+  "mooc-unit-edit-script-modal-placeholder-value": "Skript-Inhalt (Wikitext)",
+  "mooc-unit-edit-quiz-modal-placeholder-value": "Quiz-Inhalt (Wikitext)",
+  "mooc-unit-edit-further-reading-modal-placeholder-value": "Neuer 
Literatureintrag"
 }
diff --git a/i18n/en.json b/i18n/en.json
index 2c51583..c285d2c 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -49,5 +49,13 @@
   "mooc-section-units-empty-description": "No units have been added to this 
lesson yet.",
   "mooc-section-units-empty-edit-link": "Use the button \"Add Unit\" to add a 
unit.",
   "_mooc-comment-button-...": "// Labels for general UI buttons.",
-  "mooc-button-expand-section": "Click to expand"
+  "mooc-button-expand-section": "Click to expand",
+
+  "mooc-overview-add-lesson-modal-placeholder-name": "Name of the new lesson",
+  "mooc-lesson-add-unit-modal-placeholder-name": "Name of the new unit",
+  "mooc-unit-edit-learning-goals-modal-placeholder-value": "New learning goal",
+  "mooc-unit-edit-video-modal-placeholder-value": "Video file name",
+  "mooc-unit-edit-script-modal-placeholder-value": "Script content (Wikitext)",
+  "mooc-unit-edit-quiz-modal-placeholder-value": "Quiz content (Wikitext)",
+  "mooc-unit-edit-further-reading-modal-placeholder-value": "New further 
reading entry"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index d136f4e..16c7dbd 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -50,5 +50,13 @@
   "mooc-section-lessons-empty-edit-link": "Text of the link to encourage 
viewers to add lessons.",
   "mooc-section-units-empty-description": "Placeholder shown when the units 
section is empty.",
   "mooc-section-units-empty-edit-link": "Text of the link to encourage viewers 
to add units.",
-  "mooc-button-expand-section": "Label of the button that expands the section."
+  "mooc-button-expand-section": "Label of the button that expands the 
section.",
+
+  "mooc-overview-add-lesson-modal-placeholder-name": "Placeholder of the 
control to enter the name of a lesson that's being created.",
+  "mooc-lesson-add-unit-modal-placeholder-name": "Placeholder of the control 
to enter the name of an unit that's being created.",
+  "mooc-unit-edit-learning-goals-modal-placeholder-value": "Placeholder of the 
control to enter a new learning goal for the unit that's being edited.",
+  "mooc-unit-edit-video-modal-placeholder-value": "Placeholder of the control 
to enter a video file name for the unit that's being edited.",
+  "mooc-unit-edit-script-modal-placeholder-value": "Placeholder of the control 
to enter the script for the unit that's being edited.",
+  "mooc-unit-edit-quiz-modal-placeholder-value": "Placeholder of the control 
to enter the quiz for the unit that's being edited.",
+  "mooc-unit-edit-further-reading-modal-placeholder-value": "Placeholder of 
the control to enter a new further reading for the unit that's being edited."
 }
diff --git a/includes/rendering/MoocContentRenderer.php 
b/includes/rendering/MoocContentRenderer.php
index f5f273a..4aa980f 100644
--- a/includes/rendering/MoocContentRenderer.php
+++ b/includes/rendering/MoocContentRenderer.php
@@ -468,22 +468,28 @@
             // video
             case self::SECTION_KEY_VIDEO:
                 // simple text input field
-                $this->out->addHTML( "<input type='text' class='value 
form-control' value='{$this->item->video}'/>" );
+                $this->out->addHTML( '<div class="input-group">' );
+                $this->out->addHTML( '<div 
class="input-group-addon">File:</div>' );
+                $placeholderVideoFile = $this->loadMessage( 
'unit-edit-video-modal-placeholder-value' );
+                $this->out->addHTML( "<input type='text' class='value 
form-control' value='{$this->item->video}' 
placeholder='$placeholderVideoFile'/>" );
+                $this->out->addHTML( '</div>' );
                 break;
 
             // ordered lists
             case self::SECTION_KEY_LEARNING_GOALS:
             case self::SECTION_KEY_FURTHER_READING:
-                $this->out->addHTML( '<ol class="value"></ol>' );
+                $placeholderList = $this->loadMessage( 
"unit-edit-$sectionKey-modal-placeholder-value" );
+                $this->out->addHTML( "<ol class='value' 
data-placeholder='$placeholderList'></ol>" );
                 break;
 
             // external resources
             case self::SECTION_KEY_SCRIPT:
             case self::SECTION_KEY_QUIZ:
                 // auto-growing textarea
+                $placeholderResourceContent = $this->loadMessage( 
"unit-edit-$sectionKey-modal-placeholder-value" );
                 $entity = ( $sectionKey === self::SECTION_KEY_SCRIPT ) ? 
$this->item->script : $this->item->quiz;
                 $textareaValue = ( $entity === null ) ? '' : $entity->content;
-                $this->out->addHTML( "<textarea class='value auto-grow 
form-control' rows='1'>$textareaValue</textarea>" );
+                $this->out->addHTML( "<textarea class='value auto-grow 
form-control' rows='1' 
placeholder='$placeholderResourceContent'>$textareaValue</textarea>" );
                 break;
 
             default:
diff --git a/includes/rendering/MoocLessonRenderer.php 
b/includes/rendering/MoocLessonRenderer.php
index 5156c5b..1c70b72 100644
--- a/includes/rendering/MoocLessonRenderer.php
+++ b/includes/rendering/MoocLessonRenderer.php
@@ -296,7 +296,8 @@
 
     protected function fillModalBoxForm( $sectionKey, $action ) {
         if ( $sectionKey == self::SECTION_KEY_UNITS && $action == 
self::ACTION_ADD ) {
-            $this->out->addHTML( '<input type="text" class="value 
form-control" />' );
+            $placeholderUnitName = $this->loadMessage( 
'lesson-add-unit-modal-placeholder-name' );
+            $this->out->addHTML( "<input type='text' class='value 
form-control' placeholder='$placeholderUnitName' />" );
         } else {
             parent::fillModalBoxForm( $sectionKey, $action );
         }
diff --git a/includes/rendering/MoocOverviewRenderer.php 
b/includes/rendering/MoocOverviewRenderer.php
index 5c2ff68..5e3f528 100644
--- a/includes/rendering/MoocOverviewRenderer.php
+++ b/includes/rendering/MoocOverviewRenderer.php
@@ -124,7 +124,8 @@
 
     protected function fillModalBoxForm( $sectionKey, $action ) {
         if ( $sectionKey == self::SECTION_KEY_LESSONS && $action == 
self::ACTION_ADD ) {
-            $this->out->addHTML( '<input type="text" class="value 
form-control" />' );
+            $placeholderLessonName = $this->loadMessage( 
'overview-add-lesson-modal-placeholder-name' );
+            $this->out->addHTML( "<input type='text' class='value 
form-control' placeholder='$placeholderLessonName'/>" );
         } else {
             parent::fillModalBoxForm( $sectionKey, $action );
         }
@@ -135,6 +136,7 @@
             // add button
             $titleAdd = $this->loadMessage( 'modal-button-title-add' );
             $this->out->addHTML( "<input type='submit' class='btn btn-add 
btn-submit' value='$titleAdd'/>" );
+            // cancel button
             $titleCancel = $this->loadMessage( 'modal-button-title-cancel' );
             $this->out->addHTML( "<input type='button' class='btn btn-cancel' 
value='$titleCancel'/>" );
         } else {
diff --git a/resources/js/ext.mooc.edit.js b/resources/js/ext.mooc.edit.js
index 65e5d15..4b375bc 100644
--- a/resources/js/ext.mooc.edit.js
+++ b/resources/js/ext.mooc.edit.js
@@ -407,11 +407,10 @@
     } else {
       addListItem( $list, '' );
     }
-    // TODO focus last input field and set cursor to end on showModal
   }
 
   /**
-   * Adds an item to a list.
+   * Adds an input field item to a list.
    * If there is a previous item specified, it will be inserted hereafter.
    * Otherwise it will be added to the end of the list.
    *
@@ -421,10 +420,12 @@
    * @returns {*} input field jQuery-element
    */
   function addListItem( $list, value, $prev ) {
+    var placeholder = $list.attr( 'data-placeholder' );
     var $input = $( '<input>', {
       'class': 'form-control value',
       'type': 'text',
-      'value': value
+      'value': value,
+      'placeholder': placeholder
     } );
     $input.on( 'keydown', onListItemInputKeyDown );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/342646
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id297af1ecff0a327c043837fa103ff5205d37da0
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/MOOC
Gerrit-Branch: master
Gerrit-Owner: Sebschlicht2 <sebschli...@uni-koblenz.de>
Gerrit-Reviewer: Sebschlicht2 <sebschli...@uni-koblenz.de>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to