Browse Source

use model to toggle emoticon panel

Andrew Dolgov 5 months ago
parent
commit
06b39a7206
2 changed files with 8 additions and 3 deletions
  1. 2 2
      index.php
  2. 6 1
      js/tt-irc.js

+ 2 - 2
index.php

@@ -305,7 +305,7 @@
 
 				<span class="text-muted glyphicon glyphicon-piggy-bank"
 					title="<?php echo __("Toggle emoticons (Alt+E)") ?>"
-					onclick="$('#emoticons').fadeToggle()" id="emoticon-prompt"> </span>
+					onclick="toggle_emoticons()" data-bind="css: { 'text-success': emoticons_visible }"> </span>
 
 				<span class="text-muted glyphicon glyphicon-plus-sign"
 					title="<?php echo __("Join channel (Alt+J)") ?>"
@@ -326,7 +326,7 @@
 		</div> <!-- userlist -->
 	</div> <!-- sidebar-inner -->
 
-	<div style="display : none" id="emoticons"><?php echo render_emoticons() ?></div>
+	<div id="emoticons" data-bind="visible: emoticons_visible"><?php echo render_emoticons() ?></div>
 
 	</div> <!-- sidebar -->
 

+ 6 - 1
js/tt-irc.js

@@ -571,6 +571,7 @@ function Model() {
 	self.new_highlights = ko.observable(0);
 	self.alerts_enabled = ko.observable(true);
 	self.away_visible = ko.observable(false);
+	self.emoticons_visible = ko.observable(false);
 
 	self.connections = ko.observableArray([]);
 	self._activeChannel = ko.observable("");
@@ -2563,7 +2564,7 @@ function hotkey_handler(e) {
 	}
 
 	if (keycode == 69 && e.altKey) {
-		$('#emoticons').fadeToggle();
+		toggle_emoticons();
 		return false;
 	}
 
@@ -2793,6 +2794,10 @@ function update_emoticon_popup(str) {
 
 }
 
+function toggle_emoticons() {
+	model.emoticons_visible(!model.emoticons_visible());
+}
+
 /* exported toggle_alerts */
 function toggle_alerts() {
 	model.alerts_enabled(!model.alerts_enabled());