Advertisement
Guest User

Content management

a guest
Aug 31st, 2012
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var modAliases = new Array();
  2. var modDefault = null;
  3.  
  4. function initSite($){
  5. (...)
  6. //Site Navigation scripts (DOM)
  7. $('img#logo').click(function(){window.location.hash = 'slideshow';});
  8. $('div#mtile1>div.tilespacer').click(function(){window.location.hash = 'static|about';});
  9. $('div#mtile2>div.tilespacer').click(function(){window.location.hash = 'static|inspiration';});
  10. $('div#mtile3>div.tilespacer').click(function(){window.location.hash = 'static|references';});
  11. $('div#mtile4>div.tilespacer').click(function(){window.location.hash = 'static|selfdevelopment';});
  12. $('div#mtile5>div.tilespacer').click(function(){window.location.hash = 'static|press';});
  13. $('div#mtile6>div.tilespacer').click(function(){window.location.hash = 'static|contact';});
  14. (...)
  15. }
  16.  
  17. //Slideshow
  18. function C_slideshow(params){
  19.     var self = this;
  20.     this.getName = function(){return 'slideshow'};
  21.     this.destroy = function(fncallback){
  22.         $('div#c_lsh').fadeOut(500, function(){
  23.             $('img.lslide_ch').attr('class', 'lslide');
  24.             $('img.lslide_active').attr('class', 'lslide');
  25.             alert("SLIDESHOW DESTROYED");
  26.             fncallback();
  27.         });
  28.         clearInterval(self.shtimer);
  29.     }
  30.    
  31.     this.slideshow_shine = function(){
  32.         $('img#lshshine').stop();
  33.         $('img#lshshine').css('margin-top', 853);
  34.         $('img#lshshine').animate({'margin-top': -1200}, 1000);
  35.     }
  36.    
  37.     this.nextSlide = function(){  
  38.         var ac = self.activeslide;
  39.         var ne = self.activeslide.next('img.lslide');
  40.         if(ne.length == 0){
  41.             ne = $('img.lslide').first();
  42.         }
  43.         ne.attr('class', 'lslide_ch');
  44.         self.activeslide.fadeOut(499,function(){
  45.             ac.attr('class', 'lslide');
  46.             ne.attr('class', 'lslide_active');
  47.             ac.fadeIn(0);
  48.         });
  49.         self.activeslide = ne;
  50.     }
  51.    
  52.     this.activeslide = $('img.lslide').first();
  53.     this.activeslide.attr('class', 'lslide_active');
  54.     this.shtimer = setInterval(this.nextSlide, 5000);
  55.    
  56.     $('div#c_lsh').fadeIn(500, this.slideshow_shine);
  57. }
  58. modAliases['slideshow'] = C_slideshow;
  59. modDefault = C_slideshow;
  60.  
  61. //Static content
  62. function C_staticcontent(params){
  63.     this.failure = function(){window.location = "404.htm";}
  64.     this.cid = null;
  65.     if(params != null && params.length>0){
  66.         this.cid = params[0];
  67.     } else this.failure();
  68.    
  69.     this.getName = function(){return 'static'};
  70.     this.getcid = function(){return this.cid};
  71.    
  72.     this.destroy = function(fncallback){
  73.         alert("STATIC DESTROYED: " + this.cid);
  74.         this.cdiv.fadeOut(500, fncallback);
  75.     }
  76.    
  77.     this.cdiv = $('div#c_static_'+this.cid);
  78.     if(this.cdiv.length == 0) this.failure();
  79.     if(this.cdiv.length == 0){
  80.         this.cid = 'about';
  81.         this.cdiv = $('div#c_static_'+this.cid);      
  82.     }
  83.    
  84.     this.stdiv = this.cdiv.children('div.stext');
  85.     var div_mleft = this.stdiv.css('margin-left');
  86.     var div_width = this.stdiv.css('width');
  87.    
  88.     this.stdiv.css('margin-left', div_width).animate({'margin-left': div_mleft});
  89.     this.cdiv.fadeIn(500);
  90. }
  91. modAliases['static'] = C_staticcontent;
  92.  
  93. //Module manager
  94. function ModuleMGR(){
  95.     var self = this;
  96.     this.if_cc = false;
  97.     this.contObj = null;
  98.     this.nextModule = null;
  99.    
  100.     this.setModule = function(fn, params){
  101.             self.nextModule = fn;
  102.             if(!self.if_cc){
  103.                 if(self.contObj == null){
  104.                     self.contObj = new self.nextModule(params);
  105.                 } else {
  106.                     var self2 = this;
  107.                     self.contObj.destroy(function(){self2.contObj = self2.nextModule(params); self2.if_cc = false;})
  108.                     self.if_cc = true;
  109.                     alert("DEBUG MESSAGE: NOT NULL");
  110.                 }
  111.             }
  112.     }
  113.    
  114.     this.hashChange = function(){
  115.         var hashparts = window.location.hash.split("|")
  116.         var malias = hashparts[0].substr(1);
  117.         if(typeof modAliases[malias] == "undefined"){
  118.             self.setModule(modDefault, null);
  119.         } else {
  120.             self.setModule(modAliases[malias], hashparts.slice(1));
  121.         }
  122.     }
  123. }
  124. var mMGR = new ModuleMGR();
  125.  
  126. //Nav.Handler
  127. $(window).hashchange(function(m){return m.hashChange;}(mMGR));
  128.  
  129.  
  130.  
  131. initSite(jQuery);
  132. $(window).hashchange();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement