This plugin includes (if you want) all the needed resources to work :
- jquery 1.7.1
- jquery ui 1.8.18
- twitter bootstrap 2.0
... but, you can include your global resources.
First, you need to define mavenRepo on config/BuildConfig.groovy in repositories section:
mavenRepo "https://raw.github.com/maleficarum/mavenrepo/master/releases"
Then, install plugin
grails install-plugin mx.com.maleficarum:grails-support-chat:0.1
To embbed a support chat window on your grails application you need to modify some files:
supportChat { supportEntity = com.enterprise.Admin.class userEntity = com.enterprise.SingleUser.class }
supportEntity : This is the entity that represents a logged valid user as moderator.
userEntity : This is the common user in the application.
Note: If your application not uses logged clients/users, use an Expando instance in every client session.
<input type="button" id="openChat" /> (1) <mm:jquery /> (2) <mm:jqueryui /> (3) <mm:supportChat /> (4) <srcipt> $('#openChat').click(function(e) { $( "#mmsupportchatw" ).dialog( "open" ); (5) }); </srcipt>
- Add a button to launch the chat
- If you include directly jquery.js, omit this sentence.
- If you include directly jqueryui.js (and other neede resources, as templates, omit this sentence)
- Include main chat support window in your view.
- Add a listener for the previous button to fire open event in chat window
def index() { //If user is admin user, or moderator, then def user = new Admin() user.setScAdmin(true) //If user is not an admin, or not a moderator, then user.setScAdmin(false) }
Note: The plugin add the method setScAdmin(boolean) in metaclass for the configured classes in the first step.