84b6da1f076927d0b011356301bfb359bb439413
[ldapsaisie.git] / public_html / includes / js / LSformElement_xmpp.js
1 var LSformElement_xmpp = new Class({
2     initialize: function(){
3       this.initialiseLSformElement_xmpp();
4       if (typeof(varLSform) != "undefined") {
5         varLSform.addModule("LSformElement_xmpp",this);
6       }
7     },
8     
9     initialiseLSformElement_xmpp: function(el) {
10       if (typeof(el) == 'undefined') {
11         el = document;
12       }
13       el.getElements('input.LSformElement_xmpp').each(function(input) {
14         this.addBtnAfter.bind(this)(input);
15       }, this);
16       el.getElements('a.LSformElement_xmpp').each(function(a) {
17         this.addBtnAfter.bind(this)(a);
18       }, this);
19     },
20     
21     addBtnAfter: function(el) {
22       var btn = new Element('img');
23       btn.setProperties({
24         src:    varLSdefault.imagePath('xmpp.png'),
25         alt:    'Chat'
26       });
27       btn.addClass('btn');
28       btn.injectAfter(el);
29       btn.addEvent('click',this.onBtnClick.bind(this,btn));
30       varLSdefault.addHelpInfo(btn,'LSformElement_xmpp','chat');
31     },
32     
33     reinitialize: function(el) {
34       varLSform.initializeModule('LSformElement_text',el);
35       this.initialiseLSformElement_xmpp(el);
36     },
37     
38     onBtnClick: function(btn) {
39       var href = btn.getParent().getFirst().href;
40       if (typeof(href)=="undefined") {
41         href = 'xmpp:'+btn.getParent().getFirst().value;
42       }
43       if ((href!="")&&(href!="xmpp:")) {
44         location.href = href;
45       }
46     }
47 });
48 window.addEvent(window.ie ? 'load' : 'domready', function() {
49   varLSformElement_xmpp = new LSformElement_xmpp();
50 });