Source: widgets/SpwHeader.js

Retour à la documentation
/**
 * @class spw.widgets.SpwHeader
 */
define(["dojo/_base/declare", "spw/api/SpwBaseTemplatedWidget", "dojo/dom-construct", "dojo/_base/window",
        "dojo/_base/lang", "dojo/text!./templates/SpwHeader.html", "esri/domUtils", "dojo/dom-attr"],
		function(declare, SpwBaseTemplatedWidget, domConstruct, win, lang, SpwHeaderTmpl, domUtils, domAttr){

	return declare("spw.api.SpwHeader", [SpwBaseTemplatedWidget], /** @lends spw.widgets.SpwHeader.prototype */{

		templateString: SpwHeaderTmpl,
		
		postCreate: function(){
			this.inherited(arguments);
			
			this.initHeader();
		},
	
		initHeader: function(){
			this.headerTitle.innerHTML = this.viewerTitle;
			win.doc.title = this.viewerTitle;
			
			this.domNode.style.height = this.height;
			this.domNode.style.backgroundImage = "url('" + this.repeatedBackgroundImagePath + "')";
			this.headerWrapper.style.backgroundImage = "url(" + this.noRepeatBackgroundImagePath + ")";
			
			if(this.topLinks != null){
				for(var i=0; i<this.topLinks.length; i++){				
					domConstruct.create("a", {
						href:this.topLinks[i].link,
						innerHTML:this.topLinks[i].label,
						alt:this.topLinks[i].label, title:this.topLinks[i].label,
						target:this.topLinks[i].target != null ? this.topLinks[i].target : "_self"
					}, this.topQuickHeader);
					if(i < this.topLinks.length-1){
						domConstruct.create("span", {innerHTML:this.topLinksSeparator}, this.topQuickHeader);
					}
				}
			}
			if(this.languages != null){
				for(var i=0; i<this.languages.length; i++){
					var link = null;
					link = domConstruct.create("a", {
						href:"javascript:void(0);",
						innerHTML:this.languages[i].label,
						alt:this.languages[i].code, title:this.languages[i].label,
						onclick:lang.hitch(this, function(){
							this.spwViewer.setLang(domAttr.get(link, "alt"));
							window.location.reload(true);
						})
					}, this.chooseLangHeader);
					if(i < this.languages.length-1){
						domConstruct.create("span", {innerHTML:this.languagesSeparator}, this.chooseLangHeader);
					}
				}
			}
			if(this.specialContent != null){
				domConstruct.place(this.specialContent, this.domNode);
			}
		}
	});
});