Added image.php to permit fully dynamic image path
[ldapsaisie.git] / public_html / includes / js / LSformElement_url.js
1 var LSformElement_url = new Class({
2     initialize: function(){
3       this.initialiseLSformElement_url();
4       if (typeof(varLSform) != "undefined") {
5         varLSform.addModule("LSformElement_url",this);
6       }
7     },
8     
9     initialiseLSformElement_url: function(el) {
10       if (typeof(el) == 'undefined') {
11         el = document;
12       }
13       el.getElements('input.LSformElement_url').each(function(input) {
14         this.addBtnAfter.bind(this)(input);
15       }, this);
16       el.getElements('a.LSformElement_url').each(function(a) {
17         this.addBtnAfter.bind(this)(a);
18       }, this);
19     },
20     
21     addBtnAfter: function(el) {
22       var btn_go = new Element('img');
23       btn_go.setProperties({
24         src:    varLSdefault.imagePath('url_go')
25       });
26       btn_go.addClass('btn');
27       btn_go.injectAfter(el);
28       btn_go.addEvent('click',this.onGoBtnClick.bind(this,btn_go));
29       varLSdefault.addHelpInfo(btn_go,'LSformElement_url','go');
30       
31       if (this.isAddFavoriteSupportedBrowser()) {
32         var btn_fav = new Element('img');
33         btn_fav.setProperties({
34           src:    varLSdefault.imagePath('url_add')
35         });
36         btn_fav.addClass('btn');
37         btn_fav.injectAfter(btn_go);
38         btn_fav.addEvent('click',this.onAddFavoriteBtnClick.bind(this,btn_fav));
39         varLSdefault.addHelpInfo(btn_fav,'LSformElement_url','fav');
40       }
41     },
42     
43     reinitialize: function(el) {
44       varLSform.initializeModule('LSformElement_text',el);
45       this.initialiseLSformElement_url(el);
46     },
47     
48     onGoBtnClick: function(btn) {
49       var href = btn.getParent().getFirst().href;
50       if (typeof(href)=="undefined") {
51         href = btn.getParent().getFirst().value;
52       }
53       if (href!="") {
54         window.open(href,'_blank');
55       }
56     },
57     
58     onAddFavoriteBtnClick: function(btn) {
59       var href = btn.getParent().getFirst().value;
60       if (typeof(href)=="undefined") {
61         href = btn.getParent().getFirst().href;
62       }
63       if (href!="") {
64         var name = href;
65         if (window.sidebar) {
66           window.sidebar.addPanel(name,href,'');
67         }
68         else if(window.external) {
69           window.external.AddFavorite(href,name);
70         }
71       }
72     },
73     
74     isAddFavoriteSupportedBrowser: function() {
75       if (window.sidebar || window.external) {
76         return 1;
77       }
78       return;
79     }
80 });
81 window.addEvent(window.ie ? 'load' : 'domready', function() {
82   varLSformElement_url = new LSformElement_url();
83 });