Replace id's by css classes and cleanup
authorCory Chaplin <cory.chaplin@laposte.net>
Sun, 2 Mar 2014 18:53:16 +0000 (19:53 +0100)
committerCory Chaplin <cory.chaplin@laposte.net>
Sun, 2 Mar 2014 18:53:16 +0000 (19:53 +0100)
client/src/applets/chanlist.js

index e21e306341920599210ed2edcc6bbd19cd651d0b..edabf540867784a83f3b264e69c3db6695dde5f7 100644 (file)
@@ -3,16 +3,16 @@
     var View = Backbone.View.extend({\r
         events: {\r
             "click .chan": "chanClick",\r
-            "click #channel_name_title": "sortChannelsByNameClick",\r
-            "click #users_title": "sortChannelsByUsersClick"\r
+            "click .channel_name_title": "sortChannelsByNameClick",\r
+            "click .users_title": "sortChannelsByUsersClick"\r
         },\r
 \r
         \r
         \r
         initialize: function (options) {\r
             var text = {\r
-                channel_name: '<a id="channel_name_title">' + _kiwi.global.i18n.translate('client_applets_chanlist_channelname').fetch() + '</a>',\r
-                users: '<a id="users_title">' + _kiwi.global.i18n.translate('client_applets_chanlist_users').fetch() + '</a>',\r
+                channel_name: '<a class="channel_name_title">' + _kiwi.global.i18n.translate('client_applets_chanlist_channelname').fetch() + '</a>',\r
+                users: '<a class="users_title">' + _kiwi.global.i18n.translate('client_applets_chanlist_users').fetch() + '</a>',\r
                 topic: _kiwi.global.i18n.translate('client_applets_chanlist_topic').fetch()\r
             };\r
             this.$el = $(_.template($('#tmpl_channel_list').html().trim(), text));\r
             }\r
 \r
             // Clean the sorting icon and add the new one\r
-            $('.applet_chanlist #users_title').find('span').remove();\r
-            $('.applet_chanlist #channel_name_title').find('span').remove();\r
+            $('.applet_chanlist .users_title').find('span').remove();\r
+            $('.applet_chanlist .channel_name_title').find('span').remove();\r
             switch (this.order) {\r
                 case 'user_desc':\r
                 default:\r
-                    $('#users_title').append(icon_desc);\r
+                    $('.users_title').append(icon_desc);\r
                     break;\r
                 case 'user_asc':\r
-                    $('#users_title').append(icon_asc);\r
+                    $('.users_title').append(icon_asc);\r
                     break;\r
                 case 'name_asc':\r
-                    $('#channel_name_title').append(icon_asc);\r
+                    $('.channel_name_title').append(icon_asc);\r
                     break;\r
                 case 'name_desc':\r
-                    $('#channel_name_title').append(icon_desc);\r
+                    $('.channel_name_title').append(icon_desc);\r
                     break;\r
             }\r
             \r
         \r
         sortChannelsByNameClick: function (event) {\r
             // Revert the sorting to switch between orders\r
-            switch (this.order) {\r
-                case '':\r
-                case 'name_desc':\r
-                case 'user_asc':\r
-                case 'user_desc':\r
-                default:\r
-                    this.order = 'name_asc';\r
-                    break;\r
-                case 'name_asc':\r
-                    this.order = 'name_desc';\r
-                    break;\r
+            if (this.order == 'name_asc') {\r
+                this.order = 'name_desc';\r
+            } else {\r
+                this.order = 'name_asc';\r
             }\r
             \r
             this.sortChannelsClick(this.order);\r
         \r
         sortChannelsByUsersClick: function (event) {\r
             // Revert the sorting to switch between orders\r
-            switch (this.order) {\r
-                case 'user_asc':\r
-                case 'name_asc':\r
-                case 'name_desc':\r
-                default:\r
-                    this.order = 'user_desc';\r
-                    break;\r
-                case '':\r
-                case 'user_desc':\r
-                    this.order = 'user_asc';\r
-                    break;\r
+            if (this.order == 'user_desc') {\r
+                this.order = 'user_asc';\r
+            } else {\r
+                this.order = 'user_desc';\r
             }\r
             \r
             this.sortChannelsClick(this.order);\r