18 lines
3.0 KiB
JavaScript
18 lines
3.0 KiB
JavaScript
var RokTabsIcons=new Class({Implements:[Options,Events],initialize:function(){this.Path=SitePath+"/";this.selects=$$(".icons select");this.pathEl=document.id("jform_params_tabs_iconpath");
|
|
if(this.pathEl){this.pathEl.addEvent("keyup",function(){this.Path=SitePath+"/"+this.pathEl.value;this.Path=this.Path.replace("__template__",TemplatePath);
|
|
this.Path=this.Path.replace("__module__",ModulePath);if(this.Path[this.Path.length-1]!="/"){this.Path+="/";}}.bind(this));this.Path=SitePath+"/"+this.pathEl.value;
|
|
this.Path=this.Path.replace("__template__",TemplatePath);this.Path=this.Path.replace("__module__",ModulePath);if(this.Path[this.Path.length-1]!="/"){this.Path+="/";
|
|
}}this.selects.each(function(b){this.selectEvent(b,this);},this);this.adds=$$(".icons .controls .add");this.removes=$$(".icons .controls .remove");var a=this;
|
|
this.adds.each(function(b){b.addEvent("click",function(){a.add(this);});});this.removes.each(function(b){b.addEvent("click",function(){a.remove(this);});
|
|
});},selectEvent:function(a,b){var d=a.options[a.selectedIndex].value;var e=a.getPrevious();var c=this;if(e.getElement("img")){e.getElement("img").src=b.Path+d;
|
|
}else{new Asset.image(b.Path+d).inject(e);}if(d=="__none__"){e.getElement("img").setStyle("display","none");}else{e.getElement("img").setStyle("display","block");
|
|
}a.getElements("option").addEvents({mouseenter:function(){if(this.value=="__none__"){e.getElement("img").setStyle("display","none");}else{e.getElement("img").setStyle("display","block");
|
|
}e.getElement("img").src=b.Path+this.value;},mouseleave:function(){if(this.value=="__none__"){e.getElement("img").setStyle("display","none");}else{e.getElement("img").setStyle("display","block");
|
|
}e.getElement("img").src=b.Path+d;}});a.addEvent("change",function(){d=a.options[a.selectedIndex].value;if(d=="__none__"){e.getElement("img").setStyle("display","none");
|
|
}else{e.getElement("img").setStyle("display","block");}e.getElement("img").src=b.Path+d;var f=[];c.selects.each(function(g){f.push(g.value);});document.id("jform_params_tabs_icon").value=f.join(",");
|
|
});},add:function(c){var d=c.getParent().getParent();var f=d.clone(true).inject(d,"after");var b=f.getElement("select");var e=f.getElement(".add");var a=f.getElement(".remove").setStyle("display","block");
|
|
e.addEvent("click",function(){this.add(e);}.bind(this));a.addEvent("click",function(){this.remove(a);}.bind(this));this.selectEvent(b,this);this.rearrange();
|
|
},remove:function(a){var b=a.getParent().getParent();b.empty().dispose();this.rearrange();},rearrange:function(){this.removes=$$(".icons .controls .add");
|
|
this.adds=$$(".icons .controls .remove");this.selects=$$(".icons select");var a=[];this.selects.each(function(b,d){var e=b.getPrevious();var c=e.getPrevious();
|
|
e.className="preview_tabs_icon"+(d+1)+" icons_previews";c.set("html","Tab "+(d+1)+": ");a.push(b.value);});if(this.selects.length==1){this.selects[0].getNext().getElement(".remove").setStyle("display","none");
|
|
}else{this.selects[0].getNext().getElement(".remove").setStyle("display","block");}document.id("jform_params_tabs_icon").value=a.join(",");}}); |