Browse Source

mini emoticon helper popup

Andrew Dolgov 2 years ago
parent
commit
3ee7b151c4
4 changed files with 88 additions and 0 deletions
  1. 0 0
      css/default.css
  2. 34 0
      css/default.less
  3. 1 0
      index.php
  4. 53 0
      js/tt-irc.js

File diff suppressed because it is too large
+ 0 - 0
css/default.css


+ 34 - 0
css/default.less

@@ -72,6 +72,40 @@ div#errorBox textarea {
 		text-align : left;
 	}
 
+	.emoticons-popup {
+		position : absolute;
+		bottom : 28px;
+		list-style-type : none;
+		font-size : 12px;
+		padding : 0px;
+		text-align : left;
+
+		li {
+			cursor : pointer;
+			margin : 0px;
+			padding : 2px 4px;
+			margin-right : 4px;
+			display : inline-block;
+			width : 100px;
+			background : white;
+			box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
+			border : 1px solid @panel-border;
+
+			img {
+				max-height : 16px;
+				max-width : 16px;
+				height : auto;
+				width : auto;
+			}
+
+			span {
+				text-align : right;
+				display : inline-block;
+				width : 80%;
+			}
+		}
+	}
+
 	textarea.expanded {
 		bottom : 0px;
 		position : absolute;

+ 1 - 0
index.php

@@ -303,6 +303,7 @@
 	<div id="nick" onclick="change_nick()" data-bind="text: activeNick, css: { away: isAway }"></div>
 
 	<div id="input"><div class="wrapper">
+		<ul class="emoticons-popup" style="display : none"></ul>
 		<textarea data-bind="enable: activeStatus() == 2"
 			class="form-control" rows="1" id="input-prompt"/></textarea>
 	</div></div>

+ 53 - 0
js/tt-irc.js

@@ -863,6 +863,9 @@ function init_second_stage(params) {
 
 			return hotkey_handler(e);
 		})
+		.on('keyup', function(e) {
+			update_emoticon_popup($(this).val());
+		})
 		.on('keypress', function(e) {
 			return send(e);
 		})
@@ -2574,6 +2577,56 @@ function update_alerts_indicator() {
 
 }
 
+function update_emoticon_popup(str) {
+	var tmp = str.split(" ");
+	var query = tmp[tmp.length-1];
+
+	if (query && query.length > 2 && query[0] == ":") {
+		//$(".emoticons-popup").html(word).show();
+
+		var list = $(".emoticons-popup");
+
+		list.html("");
+
+		var found = 0;
+		$.each(Object.keys(emoticons_map), function(i, k) {
+			if (k.indexOf(query) == 0) {
+				++found;
+
+				var li = $("<li>")
+					.on("click", function() {
+						var emot_name = $(this).find("span").html();
+						var input = $("#input-prompt");
+						var v = input.val();
+
+						v = v.substring(0, v.lastIndexOf(query)) + emot_name;
+						input.val(v);
+
+					})
+					.append($("<img>")
+						.attr("src", "emoticons/" + emoticons_map[k].file))
+					.append($("<span>")
+						.html(k))
+
+
+				list.append(li);
+			}
+
+			if (found == 5)
+				return false;
+		});
+
+		if (found > 0)
+			list.fadeIn();
+		else
+			list.hide();
+
+	} else {
+		$(".emoticons-popup").hide();
+	}
+
+}
+
 function toggle_alerts() {
 	alerts_enabled = !alerts_enabled;
 	localforage.setItem("ttirc.alerts-disabled", !alerts_enabled);

Some files were not shown because too many files changed in this diff