semantic_ui_rails 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +4 -0
- data/Rakefile +1 -0
- data/app/assets/fonts/semantic/icons.eot +0 -0
- data/app/assets/fonts/semantic/icons.svg +450 -0
- data/app/assets/fonts/semantic/icons.ttf +0 -0
- data/app/assets/fonts/semantic/icons.woff +0 -0
- data/app/assets/images/semantic/loader-large-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-large.gif +0 -0
- data/app/assets/images/semantic/loader-medium-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-medium.gif +0 -0
- data/app/assets/images/semantic/loader-mini-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-mini.gif +0 -0
- data/app/assets/images/semantic/loader-small-inverted.gif +0 -0
- data/app/assets/images/semantic/loader-small.gif +0 -0
- data/app/assets/javascript/semantic/accordion.js +411 -0
- data/app/assets/javascript/semantic/behavior/api.js +666 -0
- data/app/assets/javascript/semantic/behavior/colorize.js +271 -0
- data/app/assets/javascript/semantic/behavior/form.js +703 -0
- data/app/assets/javascript/semantic/behavior/state.js +752 -0
- data/app/assets/javascript/semantic/chatroom.js +766 -0
- data/app/assets/javascript/semantic/checkbox.js +348 -0
- data/app/assets/javascript/semantic/dimmer.js +524 -0
- data/app/assets/javascript/semantic/dropdown.js +707 -0
- data/app/assets/javascript/semantic/modal.js +478 -0
- data/app/assets/javascript/semantic/nag.js +542 -0
- data/app/assets/javascript/semantic/popup.js +721 -0
- data/app/assets/javascript/semantic/rating.js +358 -0
- data/app/assets/javascript/semantic/search.js +769 -0
- data/app/assets/javascript/semantic/shape.js +776 -0
- data/app/assets/javascript/semantic/sidebar.js +489 -0
- data/app/assets/javascript/semantic/tab.js +674 -0
- data/app/assets/javascript/semantic/transition.js +650 -0
- data/app/assets/javascript/semantic/video.js +459 -0
- data/app/assets/stylesheets/semantic/accordion.css +97 -0
- data/app/assets/stylesheets/semantic/breadcrumb.css +66 -0
- data/app/assets/stylesheets/semantic/button.css +993 -0
- data/app/assets/stylesheets/semantic/chatroom.css +242 -0
- data/app/assets/stylesheets/semantic/checkbox.css +300 -0
- data/app/assets/stylesheets/semantic/comment.css +178 -0
- data/app/assets/stylesheets/semantic/dimmer.css +185 -0
- data/app/assets/stylesheets/semantic/divider.css +155 -0
- data/app/assets/stylesheets/semantic/dropdown.css +415 -0
- data/app/assets/stylesheets/semantic/feed.css +126 -0
- data/app/assets/stylesheets/semantic/form.css +427 -0
- data/app/assets/stylesheets/semantic/grid.css +561 -0
- data/app/assets/stylesheets/semantic/header.css +277 -0
- data/app/assets/stylesheets/semantic/icon.css +811 -0
- data/app/assets/stylesheets/semantic/image.css +143 -0
- data/app/assets/stylesheets/semantic/input.css +225 -0
- data/app/assets/stylesheets/semantic/item.css +564 -0
- data/app/assets/stylesheets/semantic/label.css +687 -0
- data/app/assets/stylesheets/semantic/list.css +418 -0
- data/app/assets/stylesheets/semantic/loader.css +148 -0
- data/app/assets/stylesheets/semantic/menu.css +1409 -0
- data/app/assets/stylesheets/semantic/message.css +242 -0
- data/app/assets/stylesheets/semantic/modal.css +123 -0
- data/app/assets/stylesheets/semantic/nag.css +130 -0
- data/app/assets/stylesheets/semantic/popup.css +209 -0
- data/app/assets/stylesheets/semantic/progress.css +257 -0
- data/app/assets/stylesheets/semantic/rating.css +120 -0
- data/app/assets/stylesheets/semantic/reveal.css +283 -0
- data/app/assets/stylesheets/semantic/search.css +222 -0
- data/app/assets/stylesheets/semantic/segment.css +362 -0
- data/app/assets/stylesheets/semantic/shape.css +87 -0
- data/app/assets/stylesheets/semantic/sidebar.css +100 -0
- data/app/assets/stylesheets/semantic/step.css +240 -0
- data/app/assets/stylesheets/semantic/tab.css +52 -0
- data/app/assets/stylesheets/semantic/table.css +468 -0
- data/app/assets/stylesheets/semantic/transition.css +867 -0
- data/app/assets/stylesheets/semantic/video.css +81 -0
- data/lib/semantic_ui_rails/version.rb +3 -0
- data/lib/semantic_ui_rails.rb +7 -0
- data/semantic_ui_rails.gemspec +23 -0
- metadata +149 -0
| @@ -0,0 +1,766 @@ | |
| 1 | 
            +
            /*  ******************************
         | 
| 2 | 
            +
              Module -  Chat Room
         | 
| 3 | 
            +
              Author: Jack Lukic
         | 
| 4 | 
            +
              Notes: First Commit Aug 8, 2012
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              Designed as a simple modular chat component
         | 
| 7 | 
            +
            ******************************  */
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ;(function ($, window, document, undefined) {
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            $.fn.chatroom = function(parameters) {
         | 
| 12 | 
            +
              var
         | 
| 13 | 
            +
                settings  = $.extend(true, {}, $.fn.chatroom.settings, parameters),
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                className = settings.className,
         | 
| 16 | 
            +
                namespace = settings.namespace,
         | 
| 17 | 
            +
                selector  = settings.selector,
         | 
| 18 | 
            +
                error     = settings.error,
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                // hoist arguments
         | 
| 21 | 
            +
                moduleArguments = arguments || false
         | 
| 22 | 
            +
              ;
         | 
| 23 | 
            +
              $(this)
         | 
| 24 | 
            +
                .each(function() {
         | 
| 25 | 
            +
                  var
         | 
| 26 | 
            +
                    $module         = $(this),
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                    $expandButton   = $module.find(selector.expandButton),
         | 
| 29 | 
            +
                    $userListButton = $module.find(selector.userListButton),
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                    $userList       = $module.find(selector.userList),
         | 
| 32 | 
            +
                    $room           = $module.find(selector.room),
         | 
| 33 | 
            +
                    $userCount      = $module.find(selector.userCount),
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                    $log            = $module.find(selector.log),
         | 
| 36 | 
            +
                    $message        = $module.find(selector.message),
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    $messageInput   = $module.find(selector.messageInput),
         | 
| 39 | 
            +
                    $messageButton  = $module.find(selector.messageButton),
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                    instance        = $module.data('module'),
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                    html            = '',
         | 
| 44 | 
            +
                    users           = {},
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                    channel,
         | 
| 47 | 
            +
                    loggedInUser,
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    message,
         | 
| 50 | 
            +
                    count,
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                    height,
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                    pusher,
         | 
| 55 | 
            +
                    module
         | 
| 56 | 
            +
                  ;
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  module = {
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                    width: {
         | 
| 61 | 
            +
                      log      : $log.width(),
         | 
| 62 | 
            +
                      userList : $userList.outerWidth()
         | 
| 63 | 
            +
                    },
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    initialize: function() {
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                      // check error conditions
         | 
| 68 | 
            +
                      if(Pusher === undefined) {
         | 
| 69 | 
            +
                        module.error(error.pusher);
         | 
| 70 | 
            +
                      }
         | 
| 71 | 
            +
                      if(settings.key === undefined || settings.channelName === undefined) {
         | 
| 72 | 
            +
                        module.error(error.key);
         | 
| 73 | 
            +
                        return false;
         | 
| 74 | 
            +
                      }
         | 
| 75 | 
            +
                      else if( !(settings.endpoint.message || settings.endpoint.authentication) ) {
         | 
| 76 | 
            +
                        module.error(error.endpoint);
         | 
| 77 | 
            +
                        return false;
         | 
| 78 | 
            +
                      }
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                      // define pusher
         | 
| 81 | 
            +
                      pusher                       = new Pusher(settings.key);
         | 
| 82 | 
            +
                      Pusher.channel_auth_endpoint = settings.endpoint.authentication;
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                      channel = pusher.subscribe(settings.channelName);
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                      channel.bind('pusher:subscription_succeeded', module.user.list.create);
         | 
| 87 | 
            +
                      channel.bind('pusher:subscription_error', module.error);
         | 
| 88 | 
            +
                      channel.bind('pusher:member_added', module.user.joined);
         | 
| 89 | 
            +
                      channel.bind('pusher:member_removed', module.user.left);
         | 
| 90 | 
            +
                      channel.bind('update_messages', module.message.receive);
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                      $.each(settings.customEvents, function(label, value) {
         | 
| 93 | 
            +
                        channel.bind(label, value);
         | 
| 94 | 
            +
                      });
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                      // bind module events
         | 
| 97 | 
            +
                      $userListButton
         | 
| 98 | 
            +
                        .on('click.' +  namespace, module.event.toggleUserList)
         | 
| 99 | 
            +
                      ;
         | 
| 100 | 
            +
                      $expandButton
         | 
| 101 | 
            +
                        .on('click.'   +  namespace, module.event.toggleExpand)
         | 
| 102 | 
            +
                      ;
         | 
| 103 | 
            +
                      $messageInput
         | 
| 104 | 
            +
                        .on('keydown.' +  namespace, module.event.input.keydown)
         | 
| 105 | 
            +
                        .on('keyup.'   +  namespace, module.event.input.keyup)
         | 
| 106 | 
            +
                      ;
         | 
| 107 | 
            +
                      $messageButton
         | 
| 108 | 
            +
                        .on('mouseenter.' +  namespace, module.event.hover)
         | 
| 109 | 
            +
                        .on('mouseleave.' +  namespace, module.event.hover)
         | 
| 110 | 
            +
                        .on('click.' +  namespace, module.event.submit)
         | 
| 111 | 
            +
                      ;
         | 
| 112 | 
            +
                      // scroll to bottom of chat log
         | 
| 113 | 
            +
                      $log
         | 
| 114 | 
            +
                        .animate({
         | 
| 115 | 
            +
                          scrollTop: $log.prop('scrollHeight')
         | 
| 116 | 
            +
                        }, 400)
         | 
| 117 | 
            +
                      ;
         | 
| 118 | 
            +
                      $module
         | 
| 119 | 
            +
                        .data('module', module)
         | 
| 120 | 
            +
                        .addClass(className.loading)
         | 
| 121 | 
            +
                      ;
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                    },
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                    // refresh module
         | 
| 126 | 
            +
                    refresh: function() {
         | 
| 127 | 
            +
                      // reset width calculations
         | 
| 128 | 
            +
                      $userListButton
         | 
| 129 | 
            +
                        .removeClass(className.active)
         | 
| 130 | 
            +
                      ;
         | 
| 131 | 
            +
                      module.width = {
         | 
| 132 | 
            +
                        log      : $log.width(),
         | 
| 133 | 
            +
                        userList : $userList.outerWidth()
         | 
| 134 | 
            +
                      };
         | 
| 135 | 
            +
                      if( $userListButton.hasClass(className.active) ) {
         | 
| 136 | 
            +
                        module.user.list.hide();
         | 
| 137 | 
            +
                      }
         | 
| 138 | 
            +
                      $module.data('module', module);
         | 
| 139 | 
            +
                    },
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                    user: {
         | 
| 142 | 
            +
             | 
| 143 | 
            +
                      updateCount: function() {
         | 
| 144 | 
            +
                        if(settings.userCount) {
         | 
| 145 | 
            +
                          users = $module.data('users');
         | 
| 146 | 
            +
                          count = 0;
         | 
| 147 | 
            +
                          $.each(users, function() {
         | 
| 148 | 
            +
                            count++;
         | 
| 149 | 
            +
                          });
         | 
| 150 | 
            +
                          $userCount
         | 
| 151 | 
            +
                            .html( settings.templates.userCount(count) )
         | 
| 152 | 
            +
                          ;
         | 
| 153 | 
            +
                        }
         | 
| 154 | 
            +
                      },
         | 
| 155 | 
            +
             | 
| 156 | 
            +
                      // add user to user list
         | 
| 157 | 
            +
                      joined: function(member) {
         | 
| 158 | 
            +
                        users = $module.data('users');
         | 
| 159 | 
            +
                        if(member.id != 'anonymous' && users[ member.id ] === undefined ) {
         | 
| 160 | 
            +
                          users[ member.id ] = member.info;
         | 
| 161 | 
            +
                          if(settings.randomColor && member.info.color === undefined) {
         | 
| 162 | 
            +
                            member.info.color = settings.templates.color(member.id);
         | 
| 163 | 
            +
                          }
         | 
| 164 | 
            +
                          html = settings.templates.userList(member.info);
         | 
| 165 | 
            +
                          if(member.info.isAdmin) {
         | 
| 166 | 
            +
                            $(html)
         | 
| 167 | 
            +
                              .prependTo($userList)
         | 
| 168 | 
            +
                            ;
         | 
| 169 | 
            +
                          }
         | 
| 170 | 
            +
                          else {
         | 
| 171 | 
            +
                            $(html)
         | 
| 172 | 
            +
                              .appendTo($userList)
         | 
| 173 | 
            +
                            ;
         | 
| 174 | 
            +
                          }
         | 
| 175 | 
            +
                          if(settings.partingMessages) {
         | 
| 176 | 
            +
                            $log
         | 
| 177 | 
            +
                              .append( settings.templates.joined(member.info) )
         | 
| 178 | 
            +
                            ;
         | 
| 179 | 
            +
                            module.message.scroll.test();
         | 
| 180 | 
            +
                          }
         | 
| 181 | 
            +
                          module.user.updateCount();
         | 
| 182 | 
            +
                        }
         | 
| 183 | 
            +
                      },
         | 
| 184 | 
            +
             | 
| 185 | 
            +
                      // remove user from user list
         | 
| 186 | 
            +
                      left: function(member) {
         | 
| 187 | 
            +
                        users = $module.data('users');
         | 
| 188 | 
            +
                        if(member !== undefined && member.id !== 'anonymous') {
         | 
| 189 | 
            +
                          delete users[ member.id ];
         | 
| 190 | 
            +
                          $module
         | 
| 191 | 
            +
                            .data('users', users)
         | 
| 192 | 
            +
                          ;
         | 
| 193 | 
            +
                          $userList
         | 
| 194 | 
            +
                            .find('[data-id='+ member.id + ']')
         | 
| 195 | 
            +
                              .remove()
         | 
| 196 | 
            +
                          ;
         | 
| 197 | 
            +
                          if(settings.partingMessages) {
         | 
| 198 | 
            +
                            $log
         | 
| 199 | 
            +
                              .append( settings.templates.left(member.info) )
         | 
| 200 | 
            +
                            ;
         | 
| 201 | 
            +
                            module.message.scroll.test();
         | 
| 202 | 
            +
                          }
         | 
| 203 | 
            +
                          module.user.updateCount();
         | 
| 204 | 
            +
                        }
         | 
| 205 | 
            +
                      },
         | 
| 206 | 
            +
             | 
| 207 | 
            +
                      list: {
         | 
| 208 | 
            +
             | 
| 209 | 
            +
                        // receives list of members and generates user list
         | 
| 210 | 
            +
                        create: function(members) {
         | 
| 211 | 
            +
                          users = {};
         | 
| 212 | 
            +
                          members.each(function(member) {
         | 
| 213 | 
            +
                            if(member.id !== 'anonymous' && member.id !== 'undefined') {
         | 
| 214 | 
            +
                              if(settings.randomColor && member.info.color === undefined) {
         | 
| 215 | 
            +
                                member.info.color = settings.templates.color(member.id);
         | 
| 216 | 
            +
                              }
         | 
| 217 | 
            +
                              // sort list with admin first
         | 
| 218 | 
            +
                              html = (member.info.isAdmin)
         | 
| 219 | 
            +
                                ? settings.templates.userList(member.info) + html
         | 
| 220 | 
            +
                                : html + settings.templates.userList(member.info)
         | 
| 221 | 
            +
                              ;
         | 
| 222 | 
            +
                              users[ member.id ] = member.info;
         | 
| 223 | 
            +
                            }
         | 
| 224 | 
            +
                          });
         | 
| 225 | 
            +
                          $module
         | 
| 226 | 
            +
                            .data('users', users)
         | 
| 227 | 
            +
                            .data('user', users[members.me.id] )
         | 
| 228 | 
            +
                            .removeClass(className.loading)
         | 
| 229 | 
            +
                          ;
         | 
| 230 | 
            +
                          $userList
         | 
| 231 | 
            +
                            .html(html)
         | 
| 232 | 
            +
                          ;
         | 
| 233 | 
            +
                          module.user.updateCount();
         | 
| 234 | 
            +
                          $.proxy(settings.onJoin, $userList.children())();
         | 
| 235 | 
            +
                        },
         | 
| 236 | 
            +
             | 
| 237 | 
            +
                        // shows user list
         | 
| 238 | 
            +
                        show: function() {
         | 
| 239 | 
            +
                          $log
         | 
| 240 | 
            +
                            .animate({
         | 
| 241 | 
            +
                              width: (module.width.log - module.width.userList)
         | 
| 242 | 
            +
                            }, {
         | 
| 243 | 
            +
                              duration : settings.speed,
         | 
| 244 | 
            +
                              easing   : settings.easing,
         | 
| 245 | 
            +
                              complete : module.message.scroll.move
         | 
| 246 | 
            +
                            })
         | 
| 247 | 
            +
                          ;
         | 
| 248 | 
            +
                        },
         | 
| 249 | 
            +
             | 
| 250 | 
            +
                        // hides user list
         | 
| 251 | 
            +
                        hide: function() {
         | 
| 252 | 
            +
                          $log
         | 
| 253 | 
            +
                            .stop()
         | 
| 254 | 
            +
                            .animate({
         | 
| 255 | 
            +
                              width: (module.width.log)
         | 
| 256 | 
            +
                            }, {
         | 
| 257 | 
            +
                              duration : settings.speed,
         | 
| 258 | 
            +
                              easing   : settings.easing,
         | 
| 259 | 
            +
                              complete : module.message.scroll.move
         | 
| 260 | 
            +
                            })
         | 
| 261 | 
            +
                          ;
         | 
| 262 | 
            +
                        }
         | 
| 263 | 
            +
             | 
| 264 | 
            +
                      }
         | 
| 265 | 
            +
             | 
| 266 | 
            +
                    },
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                    message: {
         | 
| 269 | 
            +
             | 
| 270 | 
            +
                      // handles scrolling of chat log
         | 
| 271 | 
            +
                      scroll: {
         | 
| 272 | 
            +
                        test: function() {
         | 
| 273 | 
            +
                          height = $log.prop('scrollHeight') - $log.height();
         | 
| 274 | 
            +
                          if( Math.abs($log.scrollTop() - height) < settings.scrollArea) {
         | 
| 275 | 
            +
                            module.message.scroll.move();
         | 
| 276 | 
            +
                          }
         | 
| 277 | 
            +
                        },
         | 
| 278 | 
            +
             | 
| 279 | 
            +
                        move: function() {
         | 
| 280 | 
            +
                          height = $log.prop('scrollHeight') - $log.height();
         | 
| 281 | 
            +
                          $log
         | 
| 282 | 
            +
                            .scrollTop(height)
         | 
| 283 | 
            +
                          ;
         | 
| 284 | 
            +
                        }
         | 
| 285 | 
            +
                      },
         | 
| 286 | 
            +
             | 
| 287 | 
            +
                      // sends chat message
         | 
| 288 | 
            +
                      send: function(message) {
         | 
| 289 | 
            +
                        if( !module.utils.emptyString(message) ) {
         | 
| 290 | 
            +
                          $.api({
         | 
| 291 | 
            +
                            url    : settings.endpoint.message,
         | 
| 292 | 
            +
                            method : 'POST',
         | 
| 293 | 
            +
                            data   : {
         | 
| 294 | 
            +
                              'message': {
         | 
| 295 | 
            +
                                content   : message,
         | 
| 296 | 
            +
                                timestamp : new Date().getTime()
         | 
| 297 | 
            +
                              }
         | 
| 298 | 
            +
                            }
         | 
| 299 | 
            +
                          });
         | 
| 300 | 
            +
                        }
         | 
| 301 | 
            +
                      },
         | 
| 302 | 
            +
             | 
| 303 | 
            +
                      // receives chat response and processes
         | 
| 304 | 
            +
                      receive: function(response) {
         | 
| 305 | 
            +
                        message      = response.data;
         | 
| 306 | 
            +
                        users        = $module.data('users');
         | 
| 307 | 
            +
                        loggedInUser = $module.data('user');
         | 
| 308 | 
            +
                        if(users[ message.userID] !== undefined) {
         | 
| 309 | 
            +
                          // logged in user's messages already pushed instantly
         | 
| 310 | 
            +
                          if(loggedInUser === undefined || loggedInUser.id != message.userID) {
         | 
| 311 | 
            +
                            message.user = users[ message.userID ];
         | 
| 312 | 
            +
                            module.message.display(message);
         | 
| 313 | 
            +
                          }
         | 
| 314 | 
            +
                        }
         | 
| 315 | 
            +
                      },
         | 
| 316 | 
            +
             | 
| 317 | 
            +
                      // displays message in chat log
         | 
| 318 | 
            +
                      display: function(message) {
         | 
| 319 | 
            +
                        $log
         | 
| 320 | 
            +
                          .append( settings.templates.message(message) )
         | 
| 321 | 
            +
                        ;
         | 
| 322 | 
            +
                        module.message.scroll.test();
         | 
| 323 | 
            +
                        $.proxy(settings.onMessage, $log.children().last() )();
         | 
| 324 | 
            +
                      }
         | 
| 325 | 
            +
             | 
| 326 | 
            +
                    },
         | 
| 327 | 
            +
             | 
| 328 | 
            +
                    expand: function() {
         | 
| 329 | 
            +
                      $module
         | 
| 330 | 
            +
                        .addClass(className.expand)
         | 
| 331 | 
            +
                      ;
         | 
| 332 | 
            +
                      $.proxy(settings.onExpand, $module )();
         | 
| 333 | 
            +
                      module.refresh();
         | 
| 334 | 
            +
                    },
         | 
| 335 | 
            +
             | 
| 336 | 
            +
                    contract: function() {
         | 
| 337 | 
            +
                      $module
         | 
| 338 | 
            +
                        .removeClass(className.expand)
         | 
| 339 | 
            +
                      ;
         | 
| 340 | 
            +
                      $.proxy(settings.onContract, $module )();
         | 
| 341 | 
            +
                      module.refresh();
         | 
| 342 | 
            +
                    },
         | 
| 343 | 
            +
             | 
| 344 | 
            +
                    event: {
         | 
| 345 | 
            +
             | 
| 346 | 
            +
                      input: {
         | 
| 347 | 
            +
             | 
| 348 | 
            +
                        keydown: function(event) {
         | 
| 349 | 
            +
                          if(event.which == 13) {
         | 
| 350 | 
            +
                            $messageButton
         | 
| 351 | 
            +
                              .addClass(className.down)
         | 
| 352 | 
            +
                            ;
         | 
| 353 | 
            +
                          }
         | 
| 354 | 
            +
                        },
         | 
| 355 | 
            +
             | 
| 356 | 
            +
                        keyup: function(event) {
         | 
| 357 | 
            +
                          if(event.which == 13) {
         | 
| 358 | 
            +
                            $messageButton
         | 
| 359 | 
            +
                              .removeClass(className.down)
         | 
| 360 | 
            +
                            ;
         | 
| 361 | 
            +
                            module.event.submit();
         | 
| 362 | 
            +
                          }
         | 
| 363 | 
            +
                        }
         | 
| 364 | 
            +
             | 
| 365 | 
            +
                      },
         | 
| 366 | 
            +
             | 
| 367 | 
            +
                      // handles message form submit
         | 
| 368 | 
            +
                      submit: function() {
         | 
| 369 | 
            +
                        var
         | 
| 370 | 
            +
                          message      = $messageInput.val(),
         | 
| 371 | 
            +
                          loggedInUser = $module.data('user')
         | 
| 372 | 
            +
                        ;
         | 
| 373 | 
            +
                        if(loggedInUser !== undefined && !module.utils.emptyString(message)) {
         | 
| 374 | 
            +
                          module.message.send(message);
         | 
| 375 | 
            +
                          // display immediately
         | 
| 376 | 
            +
                          module.message.display({
         | 
| 377 | 
            +
                            user: loggedInUser,
         | 
| 378 | 
            +
                            text: message
         | 
| 379 | 
            +
                          });
         | 
| 380 | 
            +
                          module.message.scroll.move();
         | 
| 381 | 
            +
                          $messageInput
         | 
| 382 | 
            +
                            .val('')
         | 
| 383 | 
            +
                          ;
         | 
| 384 | 
            +
             | 
| 385 | 
            +
                        }
         | 
| 386 | 
            +
                      },
         | 
| 387 | 
            +
             | 
| 388 | 
            +
                      // handles button click on expand button
         | 
| 389 | 
            +
                      toggleExpand: function() {
         | 
| 390 | 
            +
                        if( !$module.hasClass(className.expand) ) {
         | 
| 391 | 
            +
                          $expandButton
         | 
| 392 | 
            +
                            .addClass(className.active)
         | 
| 393 | 
            +
                          ;
         | 
| 394 | 
            +
                          module.expand();
         | 
| 395 | 
            +
                        }
         | 
| 396 | 
            +
                        else {
         | 
| 397 | 
            +
                          $expandButton
         | 
| 398 | 
            +
                            .removeClass(className.active)
         | 
| 399 | 
            +
                          ;
         | 
| 400 | 
            +
                          module.contract();
         | 
| 401 | 
            +
                        }
         | 
| 402 | 
            +
                      },
         | 
| 403 | 
            +
             | 
| 404 | 
            +
                      // handles button click on user list button
         | 
| 405 | 
            +
                      toggleUserList: function() {
         | 
| 406 | 
            +
                        if( !$log.is(':animated') ) {
         | 
| 407 | 
            +
                          if( !$userListButton.hasClass(className.active) ) {
         | 
| 408 | 
            +
                            $userListButton
         | 
| 409 | 
            +
                              .addClass(className.active)
         | 
| 410 | 
            +
                            ;
         | 
| 411 | 
            +
                            module.user.list.show();
         | 
| 412 | 
            +
                          }
         | 
| 413 | 
            +
                          else {
         | 
| 414 | 
            +
                            $userListButton
         | 
| 415 | 
            +
                              .removeClass('active')
         | 
| 416 | 
            +
                            ;
         | 
| 417 | 
            +
                            module.user.list.hide();
         | 
| 418 | 
            +
                          }
         | 
| 419 | 
            +
                        }
         | 
| 420 | 
            +
             | 
| 421 | 
            +
                      }
         | 
| 422 | 
            +
                    },
         | 
| 423 | 
            +
             | 
| 424 | 
            +
                    utils: {
         | 
| 425 | 
            +
             | 
| 426 | 
            +
                      emptyString: function(string) {
         | 
| 427 | 
            +
                        if(typeof string == 'string') {
         | 
| 428 | 
            +
                          return (string.search(/\S/) == -1);
         | 
| 429 | 
            +
                        }
         | 
| 430 | 
            +
                        return false;
         | 
| 431 | 
            +
                      }
         | 
| 432 | 
            +
             | 
| 433 | 
            +
                    },
         | 
| 434 | 
            +
             | 
| 435 | 
            +
             | 
| 436 | 
            +
             | 
| 437 | 
            +
                  setting: function(name, value) {
         | 
| 438 | 
            +
                    if(value !== undefined) {
         | 
| 439 | 
            +
                      if( $.isPlainObject(name) ) {
         | 
| 440 | 
            +
                        $.extend(true, settings, name);
         | 
| 441 | 
            +
                      }
         | 
| 442 | 
            +
                      else {
         | 
| 443 | 
            +
                        settings[name] = value;
         | 
| 444 | 
            +
                      }
         | 
| 445 | 
            +
                    }
         | 
| 446 | 
            +
                    else {
         | 
| 447 | 
            +
                      return settings[name];
         | 
| 448 | 
            +
                    }
         | 
| 449 | 
            +
                  },
         | 
| 450 | 
            +
                  internal: function(name, value) {
         | 
| 451 | 
            +
                    if(value !== undefined) {
         | 
| 452 | 
            +
                      if( $.isPlainObject(name) ) {
         | 
| 453 | 
            +
                        $.extend(true, module, name);
         | 
| 454 | 
            +
                      }
         | 
| 455 | 
            +
                      else {
         | 
| 456 | 
            +
                        module[name] = value;
         | 
| 457 | 
            +
                      }
         | 
| 458 | 
            +
                    }
         | 
| 459 | 
            +
                    else {
         | 
| 460 | 
            +
                      return module[name];
         | 
| 461 | 
            +
                    }
         | 
| 462 | 
            +
                  },
         | 
| 463 | 
            +
                  debug: function() {
         | 
| 464 | 
            +
                    if(settings.debug) {
         | 
| 465 | 
            +
                      if(settings.performance) {
         | 
| 466 | 
            +
                        module.performance.log(arguments);
         | 
| 467 | 
            +
                      }
         | 
| 468 | 
            +
                      else {
         | 
| 469 | 
            +
                        module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
         | 
| 470 | 
            +
                        module.debug.apply(console, arguments);
         | 
| 471 | 
            +
                      }
         | 
| 472 | 
            +
                    }
         | 
| 473 | 
            +
                  },
         | 
| 474 | 
            +
                  verbose: function() {
         | 
| 475 | 
            +
                    if(settings.verbose && settings.debug) {
         | 
| 476 | 
            +
                      if(settings.performance) {
         | 
| 477 | 
            +
                        module.performance.log(arguments);
         | 
| 478 | 
            +
                      }
         | 
| 479 | 
            +
                      else {
         | 
| 480 | 
            +
                        module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
         | 
| 481 | 
            +
                        module.verbose.apply(console, arguments);
         | 
| 482 | 
            +
                      }
         | 
| 483 | 
            +
                    }
         | 
| 484 | 
            +
                  },
         | 
| 485 | 
            +
                  error: function() {
         | 
| 486 | 
            +
                    module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
         | 
| 487 | 
            +
                    module.error.apply(console, arguments);
         | 
| 488 | 
            +
                  },
         | 
| 489 | 
            +
                  performance: {
         | 
| 490 | 
            +
                    log: function(message) {
         | 
| 491 | 
            +
                      var
         | 
| 492 | 
            +
                        currentTime,
         | 
| 493 | 
            +
                        executionTime,
         | 
| 494 | 
            +
                        previousTime
         | 
| 495 | 
            +
                      ;
         | 
| 496 | 
            +
                      if(settings.performance) {
         | 
| 497 | 
            +
                        currentTime   = new Date().getTime();
         | 
| 498 | 
            +
                        previousTime  = time || currentTime;
         | 
| 499 | 
            +
                        executionTime = currentTime - previousTime;
         | 
| 500 | 
            +
                        time          = currentTime;
         | 
| 501 | 
            +
                        performance.push({
         | 
| 502 | 
            +
                          'Element'        : element,
         | 
| 503 | 
            +
                          'Name'           : message[0],
         | 
| 504 | 
            +
                          'Arguments'      : [].slice.call(message, 1) || '',
         | 
| 505 | 
            +
                          'Execution Time' : executionTime
         | 
| 506 | 
            +
                        });
         | 
| 507 | 
            +
                      }
         | 
| 508 | 
            +
                      clearTimeout(module.performance.timer);
         | 
| 509 | 
            +
                      module.performance.timer = setTimeout(module.performance.display, 100);
         | 
| 510 | 
            +
                    },
         | 
| 511 | 
            +
                    display: function() {
         | 
| 512 | 
            +
                      var
         | 
| 513 | 
            +
                        title = settings.name + ':',
         | 
| 514 | 
            +
                        totalTime = 0
         | 
| 515 | 
            +
                      ;
         | 
| 516 | 
            +
                      time = false;
         | 
| 517 | 
            +
                      clearTimeout(module.performance.timer);
         | 
| 518 | 
            +
                      $.each(performance, function(index, data) {
         | 
| 519 | 
            +
                        totalTime += data['Execution Time'];
         | 
| 520 | 
            +
                      });
         | 
| 521 | 
            +
                      title += ' ' + totalTime + 'ms';
         | 
| 522 | 
            +
                      if(moduleSelector) {
         | 
| 523 | 
            +
                        title += ' \'' + moduleSelector + '\'';
         | 
| 524 | 
            +
                      }
         | 
| 525 | 
            +
                      title += ' ' + '(' + $allDropdowns.size() + ')';
         | 
| 526 | 
            +
                      if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
         | 
| 527 | 
            +
                        console.groupCollapsed(title);
         | 
| 528 | 
            +
                        if(console.table) {
         | 
| 529 | 
            +
                          console.table(performance);
         | 
| 530 | 
            +
                        }
         | 
| 531 | 
            +
                        else {
         | 
| 532 | 
            +
                          $.each(performance, function(index, data) {
         | 
| 533 | 
            +
                            console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
         | 
| 534 | 
            +
                          });
         | 
| 535 | 
            +
                        }
         | 
| 536 | 
            +
                        console.groupEnd();
         | 
| 537 | 
            +
                      }
         | 
| 538 | 
            +
                      performance = [];
         | 
| 539 | 
            +
                    }
         | 
| 540 | 
            +
                  },
         | 
| 541 | 
            +
                  invoke: function(query, passedArguments, context) {
         | 
| 542 | 
            +
                    var
         | 
| 543 | 
            +
                      maxDepth,
         | 
| 544 | 
            +
                      found
         | 
| 545 | 
            +
                    ;
         | 
| 546 | 
            +
                    passedArguments = passedArguments || queryArguments;
         | 
| 547 | 
            +
                    context         = element         || context;
         | 
| 548 | 
            +
                    if(typeof query == 'string' && instance !== undefined) {
         | 
| 549 | 
            +
                      query    = query.split(/[\. ]/);
         | 
| 550 | 
            +
                      maxDepth = query.length - 1;
         | 
| 551 | 
            +
                      $.each(query, function(depth, value) {
         | 
| 552 | 
            +
                        if( $.isPlainObject( instance[value] ) && (depth != maxDepth) ) {
         | 
| 553 | 
            +
                          instance = instance[value];
         | 
| 554 | 
            +
                        }
         | 
| 555 | 
            +
                        else if( instance[value] !== undefined ) {
         | 
| 556 | 
            +
                          found = instance[value];
         | 
| 557 | 
            +
                        }
         | 
| 558 | 
            +
                        else {
         | 
| 559 | 
            +
                          module.error(error.method);
         | 
| 560 | 
            +
                        }
         | 
| 561 | 
            +
                      });
         | 
| 562 | 
            +
                    }
         | 
| 563 | 
            +
                    if ( $.isFunction( found ) ) {
         | 
| 564 | 
            +
                      return found.apply(context, passedArguments);
         | 
| 565 | 
            +
                    }
         | 
| 566 | 
            +
                    return found || false;
         | 
| 567 | 
            +
                  }
         | 
| 568 | 
            +
                };
         | 
| 569 | 
            +
             | 
| 570 | 
            +
                if(methodInvoked) {
         | 
| 571 | 
            +
                  if(instance === undefined) {
         | 
| 572 | 
            +
                    module.initialize();
         | 
| 573 | 
            +
                  }
         | 
| 574 | 
            +
                  invokedResponse = module.invoke(query);
         | 
| 575 | 
            +
                }
         | 
| 576 | 
            +
                else {
         | 
| 577 | 
            +
                  if(instance !== undefined) {
         | 
| 578 | 
            +
                    module.destroy();
         | 
| 579 | 
            +
                  }
         | 
| 580 | 
            +
                  module.initialize();
         | 
| 581 | 
            +
                }
         | 
| 582 | 
            +
              })
         | 
| 583 | 
            +
            ;
         | 
| 584 | 
            +
             | 
| 585 | 
            +
              return (invokedResponse)
         | 
| 586 | 
            +
                ? invokedResponse
         | 
| 587 | 
            +
                : this
         | 
| 588 | 
            +
              ;
         | 
| 589 | 
            +
            };
         | 
| 590 | 
            +
             | 
| 591 | 
            +
              $.fn.chatroom.settings = {
         | 
| 592 | 
            +
             | 
| 593 | 
            +
                name            : 'Chat',
         | 
| 594 | 
            +
                debug           : false,
         | 
| 595 | 
            +
                namespace       : 'chat',
         | 
| 596 | 
            +
             | 
| 597 | 
            +
                channel         : 'present-chat',
         | 
| 598 | 
            +
             | 
| 599 | 
            +
                onJoin          : function(){},
         | 
| 600 | 
            +
                onMessage       : function(){},
         | 
| 601 | 
            +
                onExpand        : function(){},
         | 
| 602 | 
            +
                onContract      : function(){},
         | 
| 603 | 
            +
             | 
| 604 | 
            +
                customEvents    : {},
         | 
| 605 | 
            +
             | 
| 606 | 
            +
                partingMessages : false,
         | 
| 607 | 
            +
                userCount       : true,
         | 
| 608 | 
            +
                randomColor     : true,
         | 
| 609 | 
            +
             | 
| 610 | 
            +
                speed           : 300,
         | 
| 611 | 
            +
                easing          : 'easeOutQuint',
         | 
| 612 | 
            +
             | 
| 613 | 
            +
                // pixels from bottom of chat log that should trigger auto scroll to bottom
         | 
| 614 | 
            +
                scrollArea      : 9999,
         | 
| 615 | 
            +
             | 
| 616 | 
            +
                endpoint        : {
         | 
| 617 | 
            +
                  message        : false,
         | 
| 618 | 
            +
                  authentication : false
         | 
| 619 | 
            +
                },
         | 
| 620 | 
            +
             | 
| 621 | 
            +
                error: {
         | 
| 622 | 
            +
                  method   : 'The method you called is not defined',
         | 
| 623 | 
            +
                  endpoint : 'Please define a message and authentication endpoint.',
         | 
| 624 | 
            +
                  key      : 'You must specify a pusher key and channel.',
         | 
| 625 | 
            +
                  pusher   : 'You must include the Pusher library.'
         | 
| 626 | 
            +
                },
         | 
| 627 | 
            +
             | 
| 628 | 
            +
                className   : {
         | 
| 629 | 
            +
                  expand  : 'expand',
         | 
| 630 | 
            +
                  active  : 'active',
         | 
| 631 | 
            +
                  hover   : 'hover',
         | 
| 632 | 
            +
                  down    : 'down',
         | 
| 633 | 
            +
                  loading : 'loading'
         | 
| 634 | 
            +
                },
         | 
| 635 | 
            +
             | 
| 636 | 
            +
                selector    : {
         | 
| 637 | 
            +
                  userCount      : '.actions .message',
         | 
| 638 | 
            +
                  userListButton : '.actions .list.button',
         | 
| 639 | 
            +
                  expandButton   : '.actions .expand.button',
         | 
| 640 | 
            +
                  room           : '.room',
         | 
| 641 | 
            +
                  userList       : '.room .list',
         | 
| 642 | 
            +
                  log            : '.room .log',
         | 
| 643 | 
            +
                  message        : '.room .log .message',
         | 
| 644 | 
            +
                  author         : '.room log .message .author',
         | 
| 645 | 
            +
                  messageInput   : '.talk input',
         | 
| 646 | 
            +
                  messageButton  : '.talk .send.button'
         | 
| 647 | 
            +
                },
         | 
| 648 | 
            +
             | 
| 649 | 
            +
                templates: {
         | 
| 650 | 
            +
             | 
| 651 | 
            +
                  userCount: function(number) {
         | 
| 652 | 
            +
                    return number + ' users in chat';
         | 
| 653 | 
            +
                  },
         | 
| 654 | 
            +
             | 
| 655 | 
            +
                  color: function(userID) {
         | 
| 656 | 
            +
                    var
         | 
| 657 | 
            +
                      colors = [
         | 
| 658 | 
            +
                        '#000000',
         | 
| 659 | 
            +
                        '#333333',
         | 
| 660 | 
            +
                        '#666666',
         | 
| 661 | 
            +
                        '#999999',
         | 
| 662 | 
            +
                        '#CC9999',
         | 
| 663 | 
            +
                        '#CC6666',
         | 
| 664 | 
            +
                        '#CC3333',
         | 
| 665 | 
            +
                        '#993333',
         | 
| 666 | 
            +
                        '#663333',
         | 
| 667 | 
            +
                        '#CC6633',
         | 
| 668 | 
            +
                        '#CC9966',
         | 
| 669 | 
            +
                        '#CC9933',
         | 
| 670 | 
            +
                        '#999966',
         | 
| 671 | 
            +
                        '#CCCC66',
         | 
| 672 | 
            +
                        '#99CC66',
         | 
| 673 | 
            +
                        '#669933',
         | 
| 674 | 
            +
                        '#669966',
         | 
| 675 | 
            +
                        '#33A3CC',
         | 
| 676 | 
            +
                        '#336633',
         | 
| 677 | 
            +
                        '#33CCCC',
         | 
| 678 | 
            +
                        '#339999',
         | 
| 679 | 
            +
                        '#336666',
         | 
| 680 | 
            +
                        '#336699',
         | 
| 681 | 
            +
                        '#6666CC',
         | 
| 682 | 
            +
                        '#9966CC',
         | 
| 683 | 
            +
                        '#333399',
         | 
| 684 | 
            +
                        '#663366',
         | 
| 685 | 
            +
                        '#996699',
         | 
| 686 | 
            +
                        '#993366',
         | 
| 687 | 
            +
                        '#CC6699'
         | 
| 688 | 
            +
                      ]
         | 
| 689 | 
            +
                    ;
         | 
| 690 | 
            +
                    return colors[ Math.floor( Math.random() * colors.length) ];
         | 
| 691 | 
            +
                  },
         | 
| 692 | 
            +
             | 
| 693 | 
            +
                  message: function(message) {
         | 
| 694 | 
            +
                    var
         | 
| 695 | 
            +
                      html = ''
         | 
| 696 | 
            +
                    ;
         | 
| 697 | 
            +
                    if(message.user.isAdmin) {
         | 
| 698 | 
            +
                      message.user.color = '#55356A';
         | 
| 699 | 
            +
                      html += '<div class="admin message">';
         | 
| 700 | 
            +
                      html += '<span class="quirky ui flag team"></span>';
         | 
| 701 | 
            +
                    }
         | 
| 702 | 
            +
                    /*
         | 
| 703 | 
            +
                    else if(message.user.isPro) {
         | 
| 704 | 
            +
                      html += '<div class="indent message">';
         | 
| 705 | 
            +
                      html += '<span class="quirky ui flag pro"></span>';
         | 
| 706 | 
            +
                    }
         | 
| 707 | 
            +
                    */
         | 
| 708 | 
            +
                    else {
         | 
| 709 | 
            +
                      html += '<div class="message">';
         | 
| 710 | 
            +
                    }
         | 
| 711 | 
            +
                    html += '<p>';
         | 
| 712 | 
            +
                    if(message.user.color !== undefined) {
         | 
| 713 | 
            +
                      html += '<span class="author" style="color: ' + message.user.color + ';">' + message.user.name + '</span>: ';
         | 
| 714 | 
            +
                    }
         | 
| 715 | 
            +
                    else {
         | 
| 716 | 
            +
                      html += '<span class="author">' + message.user.name + '</span>: ';
         | 
| 717 | 
            +
                    }
         | 
| 718 | 
            +
                    html += ''
         | 
| 719 | 
            +
                      +   message.text
         | 
| 720 | 
            +
                      + ' </p>'
         | 
| 721 | 
            +
                      + '</div>'
         | 
| 722 | 
            +
                    ;
         | 
| 723 | 
            +
                    return html;
         | 
| 724 | 
            +
                  },
         | 
| 725 | 
            +
             | 
| 726 | 
            +
                  joined: function(member) {
         | 
| 727 | 
            +
                    return (typeof member.name !== undefined)
         | 
| 728 | 
            +
                      ? '<div class="status">' + member.name + ' has joined the chat.</div>'
         | 
| 729 | 
            +
                      : false
         | 
| 730 | 
            +
                    ;
         | 
| 731 | 
            +
                  },
         | 
| 732 | 
            +
                  left: function(member) {
         | 
| 733 | 
            +
                    return (typeof member.name !== undefined)
         | 
| 734 | 
            +
                      ? '<div class="status">' + member.name + ' has left the chat.</div>'
         | 
| 735 | 
            +
                      : false
         | 
| 736 | 
            +
                    ;
         | 
| 737 | 
            +
                  },
         | 
| 738 | 
            +
             | 
| 739 | 
            +
                  userList: function(member) {
         | 
| 740 | 
            +
                    var
         | 
| 741 | 
            +
                      html = ''
         | 
| 742 | 
            +
                    ;
         | 
| 743 | 
            +
                    if(member.isAdmin) {
         | 
| 744 | 
            +
                      member.color = '#55356A';
         | 
| 745 | 
            +
                    }
         | 
| 746 | 
            +
                    html +=  ''
         | 
| 747 | 
            +
                      + '<div class="user" data-id="' + member.id + '">'
         | 
| 748 | 
            +
                      + ' <div class="image">'
         | 
| 749 | 
            +
                      + '   <img src="' + member.avatarURL + '">'
         | 
| 750 | 
            +
                      + ' </div>'
         | 
| 751 | 
            +
                    ;
         | 
| 752 | 
            +
                    if(member.color !== undefined) {
         | 
| 753 | 
            +
                      html += ' <p><a href="/users/' + member.id + '" target="_blank" style="color: ' + member.color + ';">' + member.name + '</a></p>';
         | 
| 754 | 
            +
                    }
         | 
| 755 | 
            +
                    else {
         | 
| 756 | 
            +
                      html += ' <p><a href="/users/' + member.id + '" target="_blank">' + member.name + '</a></p>';
         | 
| 757 | 
            +
                    }
         | 
| 758 | 
            +
                    html += '</div>';
         | 
| 759 | 
            +
                    return html;
         | 
| 760 | 
            +
                  }
         | 
| 761 | 
            +
             | 
| 762 | 
            +
                }
         | 
| 763 | 
            +
             | 
| 764 | 
            +
              };
         | 
| 765 | 
            +
             | 
| 766 | 
            +
            })( jQuery, window , document );
         |