Use placeholder attribute for Comment message

- Remove global aStr.comment
- Remove global window.commentEmptyText
- Remove head.tpl $comment parameter
This commit is contained in:
Hypolite Petovan 2017-01-08 02:13:55 +11:00
parent b6ce646d71
commit b50f1f970f
20 changed files with 37 additions and 59 deletions

View file

@ -971,7 +971,6 @@ class App {
'$local_user' => local_user(),
'$generator' => 'Friendica' . ' ' . FRIENDICA_VERSION,
'$delitem' => t('Delete this item?'),
'$comment' => t('Comment'),
'$showmore' => t('show more'),
'$showfewer' => t('show fewer'),
'$update_interval' => $interval,

View file

@ -17,7 +17,7 @@
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
</div>
<div class="comment-edit-photo-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});" >
<option value=""></option>

View file

@ -72,8 +72,7 @@
return true;
}
function commentOpen(obj,id) {
if(obj.value == '{{$comment}}') {
obj.value = '';
if (obj.value == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).show();
@ -83,8 +82,7 @@
return false;
}
function commentClose(obj,id) {
if(obj.value == '') {
obj.value = '{{$comment}}';
if (obj.value == "") {
$("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
$("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).hide();
@ -97,8 +95,7 @@
function commentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == '{{$comment}}') {
tmpStr = '';
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);
@ -113,8 +110,7 @@
function qCommentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == '{{$comment}}') {
tmpStr = '';
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);

View file

@ -20,7 +20,7 @@
<div id="mod-cmnt-url-lbl-{{$id}}" class="mod-cmnt-url-lbl">{{$lbl_modurl}}</div>
<input type="text" id="mod-cmnt-url-{{$id}}" class="mod-cmnt-url" name="mod-cmnt-url" value="{{$modurl|escape:'html'}}" />
</div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
<div class="comment-edit-text-end"></div>
<div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-{{$id}}" style="display: none;">

View file

@ -44,7 +44,7 @@
data-role="insert-formatting" data-comment="{{$comment}}" data-bbcode="video" data-id="{{$id}}"></a></li>
</ul>
<div class="comment-edit-bb-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen(this, {{$id}});" onBlur="commentClose(this,{{$id}});cmtBbClose(this,{{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
<option value=""></option>

View file

@ -47,7 +47,7 @@
onclick="insertFormatting('{{$comment}}','video', {{$id}});"></a></li>
</ul>
<div class="comment-edit-bb-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
<div class="comment-edit-text-end"></div>
<div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-{{$id}}" style="display: none;">

View file

@ -121,8 +121,7 @@ var FileBrowser = {
// work as expected (we need a way to wait until commentOpenUI would be finished).
// As for now we insert pieces of this function here
if ((commentElm !== null) && (typeof commentElm !== "undefined")) {
if (commentElm.value == aStr.comment){
commentElm.value = "";
if (commentElm.value == "") {
$("#comment-edit-text-" + FileBrowser.id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
$("#comment-edit-submit-wrapper-" + FileBrowser.id).show();
$("#comment-edit-text-" + FileBrowser.id).attr('tabindex','9');

View file

@ -61,8 +61,7 @@ function commentExpand(id) {
}
function commentClose(obj,id) {
if(obj.value == '') {
obj.value = aStr.comment;
if (obj.value == '') {
$("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
$("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).hide();
@ -85,8 +84,7 @@ function commentOpenUI(obj, id) {
$(document).unbind( "click.commentOpen", handler );
var handler = function() {
if(obj.value == aStr.comment) {
obj.value = '';
if (obj.value == '') {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
// Choose an arbitrary tab index that's greater than what we're using in jot (3 of them)
// The submit button gets tabindex + 1
@ -105,8 +103,7 @@ function commentCloseUI(obj, id) {
$(document).unbind( "click.commentClose", handler );
var handler = function() {
if(obj.value === '') {
obj.value = aStr.comment;
if (obj.value === '') {
$("#comment-edit-text-" + id).removeClass("comment-edit-text-full").addClass("comment-edit-text-empty");
$("#comment-edit-text-" + id).removeAttr('tabindex');
$("#comment-edit-submit-" + id).removeAttr('tabindex');
@ -136,8 +133,7 @@ function jotTextCloseUI(obj) {
}
function commentOpen(obj,id) {
if(obj.value == aStr.comment) {
obj.value = '';
if (obj.value == '') {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).show();
@ -149,8 +145,7 @@ function commentOpen(obj,id) {
function commentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == aStr.comment) {
tmpStr = '';
if (tmpStr == '') {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);
@ -165,8 +160,7 @@ function commentInsert(obj,id) {
function qCommentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == aStr.comment) {
tmpStr = '';
if (tmpStr == '') {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);

View file

@ -14,7 +14,7 @@
<input type="hidden" name="post_id_random" value="{{$rand_num}}" />
<div class="bb form-group">
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" onFocus="commentOpenUI(this,{{$id}});" onBlur="commentCloseUI(this,{{$id}});">{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty form-control text-autosize" name="body" placeholder="{{$comment}}" onFocus="commentOpenUI(this,{{$id}});" onBlur="commentCloseUI(this,{{$id}});"></textarea>
</div>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">

View file

@ -8,7 +8,6 @@ They are loaded into the html <head> so that js functions can use them *}}
var localUser = {{if $local_user}}{{$local_user}}{{else}}false{{/if}};
var aStr = {
'delitem' : "{{$delitem}}",
'comment' : "{{$comment}}"
};
{{* Create an object with the data which is needed for infinite scroll.

View file

@ -376,8 +376,7 @@ function itemFiler(id) {
* Comments
*/
function commentOpen(obj,id) {
if(obj.value == window.commentEmptyText) {
obj.value = "";
if (obj.value == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).show();
@ -385,8 +384,7 @@ function commentOpen(obj,id) {
}
}
function commentClose(obj,id) {
if(obj.value == "") {
obj.value = window.commentEmptyText;
if (obj.value == "") {
$("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
$("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).hide();
@ -397,8 +395,7 @@ function commentClose(obj,id) {
function commentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == window.commentEmptyText) {
tmpStr = "";
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);
@ -413,8 +410,7 @@ function commentInsert(obj,id) {
function qCommentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == window.commentEmptyText) {
tmpStr = "";
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);

View file

@ -25,8 +25,8 @@
<li><a class="editicon codebb shadow"
style="cursor: pointer;" title="{{$edcode}}"
data-role="insert-formatting" data-comment="{{$comment}}" data-bbcode="code" data-id="{{$id}}"></a></li>
</ul>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" >{{$comment}}</textarea>
</ul>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
<option value=""></option>

View file

@ -17,7 +17,6 @@
<script>
window.delItem = "{{$delitem}}";
window.commentEmptyText = "{{$comment}}";
window.showMore = "{{$showmore}}";
window.showFewer = "{{$showfewer}}";
var updateInterval = {{$update_interval}};

View file

@ -47,7 +47,7 @@
onclick="insertFormatting('{{$comment}}','video', {{$id}});"></a></li>
</ul>
<div class="comment-edit-bb-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
<div class="comment-edit-text-end"></div>
<div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-{{$id}}" style="display: none;">

View file

@ -835,8 +835,7 @@ function cmtBbClose(id) {
}
function commentOpen(obj,id) {
if(obj.value == window.commentEmptyText) {
obj.value = "";
if (obj.value == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).show();
@ -844,8 +843,7 @@ function commentOpen(obj,id) {
}
}
function commentClose(obj,id) {
if(obj.value == "") {
obj.value = window.commentEmptyText;
if (obj.value == "") {
$("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
$("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
$("#mod-cmnt-wrap-" + id).hide();
@ -856,8 +854,7 @@ function commentClose(obj,id) {
function commentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == window.commentEmptyText) {
tmpStr = "";
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);
@ -872,8 +869,7 @@ function commentInsert(obj,id) {
function qCommentInsert(obj,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == window.commentEmptyText) {
tmpStr = "";
if (tmpStr == "") {
$("#comment-edit-text-" + id).addClass("comment-edit-text-full");
$("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
openMenu("comment-edit-submit-wrapper-" + id);

View file

@ -34,8 +34,8 @@
<li><a class="editicon videobb shadow"
style="cursor: pointer;" title="{{$edvideo}}"
data-role="insert-formatting" data-comment="{{$comment}}" data-bbcode="video" data-id="{{$id}}"></a></li>
</ul>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" >{{$comment}}</textarea>
</ul>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
<option value=""></option>

View file

@ -19,7 +19,6 @@
<script>
window.delItem = "{{$delitem}}";
window.commentEmptyText = "{{$comment}}";
window.showMore = "{{$showmore}}";
window.showFewer = "{{$showfewer}}";
var updateInterval = {{$update_interval}};

View file

@ -47,7 +47,7 @@
onclick="insertFormatting('{{$comment}}','video', {{$id}});"></a></li>
</ul>
<div class="comment-edit-bb-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});" >{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});cmtBbOpen({{$id}});" onBlur="commentClose(this,{{$id}});"></textarea>
<div class="comment-edit-text-end"></div>
<div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-{{$id}}" style="display: none;">

View file

@ -37,11 +37,12 @@
<li><a class="editicon videobb shadow"
style="cursor: pointer;" title="{{$edvideo}}"
data-role="insert-formatting" data-comment="{{$comment}}" data-bbcode="video" data-id="{{$id}}"></a></li>
</ul>
<textarea id="comment-edit-text-{{$id}}"
class="comment-edit-text-empty"
name="body"
onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});" >{{$comment}}</textarea>
</ul>
<textarea id="comment-edit-text-{{$id}}"
class="comment-edit-text-empty"
name="body"
placeholder="{{$comment}}"
onFocus="commentOpen(this,{{$id}}) && cmtBbOpen({{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
<option value=""></option>

View file

@ -17,7 +17,7 @@
<a class="comment-edit-photo-link" href="{{$mylink}}" title="{{$mytitle}}"><img class="my-comment-photo" src="{{$myphoto}}" alt="{{$mytitle}}" title="{{$mytitle}}" /></a>
</div>
<div class="comment-edit-photo-end"></div>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,{{$id}});">{{$comment}}</textarea>
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text-empty" name="body" placeholder="{{$comment}}" onFocus="commentOpen(this,{{$id}});"></textarea>
{{if $qcomment}}
<select id="qcomment-select-{{$id}}" name="qcomment-{{$id}}" class="qcomment" onchange="qCommentInsert(this,{{$id}});">
<option value=""></option>