Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Added search roster plugin. #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions searchroster/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (C) 2014 Mojo Lingo LLC

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 changes: 19 additions & 0 deletions searchroster/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Search Roster

A plugin for Candy Chat to allow you to search the roster when using the StaticLobby plugin.

## Dependencies

Assumes you're using the StaticLobby plugin.

## Usage
Include the JavaScript file:
```HTML
<script type="text/javascript" src="candyshop/searchroster/searchroster.js"></script>
```

To enable this plugin, add its `init` method after you `init` Candy:
```JavaScript
CandyShop.SearchRoster.init();
Candy.connect();
```
59 changes: 59 additions & 0 deletions searchroster/searchroster.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/** File: candy.js
* Candy - Chats are not dead yet.
*
* Authors:
* - Jason Deegan <[email protected]>
*
* Copyright:
* (c) 2014 Power Home Remodeling Group. All rights reserved.
*/
var CandyShop = (function(self) { return self; }(CandyShop || {}));

/** Class: CandyShop.SearchRoster
* Allows for completion of a name in the roster
*/
CandyShop.SearchRoster = (function(self, Candy, $) {
/** String: _selector
* The selector for the visible message box
*/
var _selector = '#search-roster-value';

/** String: _clearbtn
* The button for clearing the search input box
*/
var _clearbtn= '#search-roster-value-btn';

/** Function: init
* Initialize the SearchRoster plugin
*
* Parameters:
* None
*/
self.init = function() {
// initialize tooltip help
$(_selector).tooltip();

// listen for keyup when someone wants to search
$(document).on('keyup', _selector, function() {
var searchCriteria = $(this).val().toLowerCase();
if (searchCriteria === ''){
CandyShop.StaticLobby.GlobalRoster.Display();
return;
}
$('.user').hide();
$('.user').filter(function(i,el){
return $(el).data('nick').toLowerCase().indexOf(searchCriteria) >= 0 || $(el).data('jid').toLowerCase().indexOf(searchCriteria) >= 0;
}).show();
});

// on search 'Clear' button press do: Show all users, clear search field and give search field focus
$(document).on('click', _clearbtn, function() {
$('.user').show();
$(this).closest('div').find( 'input' ).val('');
$(this).closest('div').find( 'input' ).focus();
CandyShop.StaticLobby.GlobalRoster.Display();
});
};

return self;
}(CandyShop.NameComplete || {}, Candy, jQuery));