From dceee050e7170ed4e0e531f46990cc6e3421533f Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Sun, 8 May 2016 01:31:30 +0200 Subject: [PATCH] head.tpl move strings to js strings into the html
so we can move the js scripts out of the template --- js/textedit.js | 82 +++++++++++++++++++++++++++++++++++++- templates/comment_item.tpl | 36 ----------------- templates/head.tpl | 55 ++----------------------- templates/js_strings.tpl | 13 ++++++ 4 files changed, 98 insertions(+), 88 deletions(-) create mode 100644 templates/js_strings.tpl diff --git a/js/textedit.js b/js/textedit.js index f7d5ee57f..be4cd770a 100644 --- a/js/textedit.js +++ b/js/textedit.js @@ -63,7 +63,7 @@ function commentExpand(id) { function commentClose(obj,id) { if(obj.value == '') { - obj.value = '{{$comment}}'; + obj.value = aStr.comment; $("#comment-edit-text-" + id).removeClass("comment-edit-text-full"); $("#comment-edit-text-" + id).addClass("comment-edit-text-empty"); $("#mod-cmnt-wrap-" + id).hide(); @@ -81,3 +81,83 @@ function showHideCommentBox(id) { $('#comment-edit-form-' + id).show(); } } + +function commentOpenUI(obj, id) { + $(document).unbind( "click.commentOpen", handler ); + + var handler = function() { + if(obj.value == aStr.comment) { + 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 + $("#comment-edit-text-" + id).attr('tabindex','9'); + $("#comment-edit-submit-" + id).attr('tabindex','10'); + $("#comment-edit-submit-wrapper-" + id).show(); + } + }; + + $(document).bind( "click.commentOpen", handler ); +} + +function commentCloseUI(obj, id) { + $(document).unbind( "click.commentClose", handler ); + + var handler = function() { + if(obj.value === '') { + obj.value = aStr.comment; + $("#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'); + $("#comment-edit-submit-wrapper-" + id).hide(); + } + }; + + $(document).bind( "click.commentClose", handler ); +} +function commentOpen(obj,id) { + if(obj.value == aStr.comment) { + 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(); + openMenu("comment-edit-submit-wrapper-" + id); + return true; + } + return false; +} + +function commentInsert(obj,id) { + var tmpStr = $("#comment-edit-text-" + id).val(); + if(tmpStr == aStr.comment) { + 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); + } + var ins = $(obj).html(); + ins = ins.replace('<','<'); + ins = ins.replace('>','>'); + ins = ins.replace('&','&'); + ins = ins.replace('"','"'); + $("#comment-edit-text-" + id).val(tmpStr + ins); +} + +function qCommentInsert(obj,id) { + var tmpStr = $("#comment-edit-text-" + id).val(); + if(tmpStr == aStr.comment) { + 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); + } + var ins = $(obj).val(); + ins = ins.replace('<','<'); + ins = ins.replace('>','>'); + ins = ins.replace('&','&'); + ins = ins.replace('"','"'); + $("#comment-edit-text-" + id).val(tmpStr + ins); + $(obj).val(''); +} + +function confirmDelete() { return confirm(aStr.delitem); } diff --git a/templates/comment_item.tpl b/templates/comment_item.tpl index b430ff7e6..116a7b7d4 100644 --- a/templates/comment_item.tpl +++ b/templates/comment_item.tpl @@ -1,39 +1,3 @@ - {{if $threaded}}