PageRenderTime 38ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/artissime/html/js/artissime.js

http://mbideasproject.googlecode.com/
JavaScript | 235 lines | 184 code | 30 blank | 21 comment | 23 complexity | 67d345533590868bd9515c8c45ea2824 MD5 | raw file
Possible License(s): GPL-2.0
  1. /*******************************************************************************
  2. jquery.mb.components
  3. Copyright (c) 2001-2010. Matteo Bicocchi (Pupunzi); Open lab srl, Firenze - Italy
  4. email: info@pupunzi.com
  5. site: http://pupunzi.com
  6. Licences: MIT, GPL
  7. ******************************************************************************/
  8. (function($){
  9. $.fn.mbCloseBox=function(t,c){
  10. $(this).css({height: $(this).outerHeight(), minHeight: "0px"});
  11. $(this).slideUp(t,c);
  12. };
  13. $.fn.mbOpenBox=function(t,c){
  14. $(this).css({height: $(this).outerHeight(), minHeight: "0px"});
  15. $(this).slideDown(t,c);
  16. };
  17. $.fn.mbEqualizeCols = function(){
  18. var height = 0;
  19. return this.css("height","auto").each(function(){
  20. height = Math.max( height, $(this).outerHeight() );
  21. }).css("minHeight", height);
  22. };
  23. $.fn.buildSubMenu=function(options){
  24. this.options={
  25. menuVoces:"subMenu",
  26. elements:"a",
  27. alwaysOpen:false
  28. };
  29. $.extend (this.options, options);
  30. var submenu=this;
  31. var el=$(this).find(this.options.elements);
  32. var menuvoices=$("#"+this.options.menuVoces);
  33. submenu.actualMenu=false;
  34. //menuvoices.children().css({position:"absolute",display:"block", height:"100%", width:"100%"}).hide();
  35. var menuSel=false;
  36. var subMenuSel=false;
  37. el.each(function(){
  38. if ($.metadata){
  39. $.metadata.setType("class");
  40. var menu= $(this).metadata().menu;
  41. menuSel=$(this).metadata().isSel && !menuSel?$(this):menuSel;
  42. }
  43. buildSubMenuCat($("#"+menu).find("a"));
  44. if(menuSel)
  45. subMenuSel=menuSel.find(".sel");
  46. $("#"+menu).hoverIntent(function(){
  47. if (menu!= submenu.actualMenu) $("#"+menu).fadeOut("slow");
  48. $(document).stopTime("closeSubMenu");
  49. },function(){
  50. $(document).oneTime(1000, "closeSubMenu",function(){
  51. el.removeClass("sel");
  52. if(!menuSel) menuvoices.slideUp(500);
  53. menuvoices.children().hide();
  54. if(menuSel)
  55. onMenuSel(menuSel,subMenuSel);
  56. });
  57. });
  58. $(this).hoverIntent(function(){
  59. $(document).stopTime("closeSubMenu");
  60. el.removeClass("sel");
  61. $(this).addClass("sel");
  62. if (menu!= submenu.actualMenu){
  63. submenu.actualMenu=menu;
  64. menuvoices.children().hide();
  65. }
  66. $("#"+menu).fadeIn(500);
  67. menuvoices.show();
  68. },function(){
  69. $(document).oneTime(1000, "closeSubMenu",function(){
  70. // if (submenu.actualMenu==menu) {return;}
  71. el.removeClass("sel");
  72. if(!menuSel) menuvoices.slideUp(500);
  73. menuvoices.children().hide();
  74. submenu.actualMenu=false;
  75. if(menuSel)
  76. onMenuSel(menuSel,subMenuSel);
  77. });
  78. });
  79. });
  80. function onMenuSel(menuSel, submenuSel){
  81. if(menuSel){
  82. var openedMenu=menuSel.metadata().menu;
  83. $("#"+openedMenu).fadeIn(500);
  84. menuvoices.show();
  85. submenu.actualMenu=openedMenu;
  86. menuSel.addClass("sel");
  87. }
  88. if(submenuSel){
  89. submenuSel.addClass("sel");
  90. }
  91. }
  92. function buildSubMenuCat(ele){
  93. ele.each(function(){
  94. $(this).mouseover(function(){$("#submenuCat").remove();});
  95. if ($.metadata){
  96. $.metadata.setType("class");
  97. var menuUrl= $(this).metadata().subMenuCat?$(this).metadata().subMenuCat:false;
  98. var menuData= $(this).metadata().data?$(this).metadata().data:false;
  99. }
  100. if(menuUrl){
  101. var subVoice=$(this);
  102. subVoice.hover (
  103. function(){
  104. $(document).stopTime("closeSubMenu");
  105. $(document).stopTime("closeSubMenuCat");
  106. $("#submenuCat").remove();
  107. var color=subVoice.css("background-color");
  108. if(!subVoice.hasClass("sel")){
  109. subVoice.addClass("sel");
  110. }else{
  111. subVoice.attr("actual",true);
  112. }
  113. var cat=$("<div/>").attr("id","submenuCat").hide();
  114. color="#333";
  115. cat.css({position:"absolute", top:subVoice.offset().top+31, left:subVoice.offset().left, backgroundColor:color});
  116. $("body").append(cat);
  117. cat.load(menuUrl,menuData,function(){$(this).slideDown("fast");});
  118. cat.hover(
  119. function(){
  120. subVoice.addClass("menuSel");
  121. setTimeout(function(){$(document).stopTime("closeSubMenu");},300);
  122. $(document).stopTime("closeSubMenuCat");
  123. },
  124. function(){
  125. cat.remove();
  126. // if(subVoice.attr("actual")!="true")
  127. subVoice.removeClass("menuSel");
  128. $(document).oneTime(1000, "closeSubMenu",function(){
  129. el.removeClass("sel");
  130. if(!menuSel) menuvoices.slideUp(500);
  131. menuvoices.children().hide();
  132. submenu.actualMenu=false;
  133. if(menuSel)
  134. onMenuSel(menuSel,subMenuSel);
  135. });
  136. }
  137. );
  138. },
  139. function(){
  140. if(subVoice.attr("actual")!="true") subVoice.removeClass("sel");
  141. $(document).oneTime(50, "closeSubMenuCat",function(){
  142. $("#submenuCat").remove();});
  143. });
  144. }
  145. });
  146. }
  147. onMenuSel(menuSel,subMenuSel);
  148. };
  149. })(jQuery);
  150. function changeHeader(additionalLogo,cleanHeader, littleHeaderUrl, defaultHeaderUrl){
  151. if (additionalLogo){
  152. if (!cleanHeader) $("#header").css({background:"url("+littleHeaderUrl+")"});
  153. }else{
  154. $("#header_baseline").css({left:18, top:58});
  155. $("#additionalLogotype").remove();
  156. $("#header").css({background:"url("+defaultHeaderUrl+")"});
  157. }
  158. }
  159. $.blockUI.defaults.overlayCSS = {};
  160. $.blockUI.defaults.css = {};
  161. $(function(){
  162. $(".spectacles.label").html("Spect");
  163. $(".museum.label").html("Mus?¨e");
  164. $(".public.label").html("Publique");
  165. $(".travel.label").html("S?Šjours");
  166. /*
  167. Submenu
  168. */
  169. $("#navMenu").buildSubMenu();
  170. /* Highlights */
  171. $(".highlightHover").hoverIntent(
  172. function(){
  173. $(this).addClass("selected");
  174. if($.browser.msie) $(this).find(".elementHover").show();
  175. else
  176. $(this).find(".elementHover").fadeIn("fast");
  177. },
  178. function(){
  179. $(this).removeClass("selected");
  180. if($.browser.msie) $(this).find(".elementHover").hide();
  181. else
  182. $(this).find(".elementHover").fadeOut("fast");
  183. }
  184. ).click(function(){
  185. var url= $(this).find("a.eventUrl").attr("href");
  186. if (url) self.location.href=url;
  187. else
  188. alert("url not found");
  189. });
  190. $(".highlightHover div").css({position:"relative"});
  191. $(".highlightHover").prepend("<div class='elementHover'><\/div>");
  192. // Form datepicker
  193. $("input.date").datepick();
  194. /*
  195. just show the show_more box the first time this user get the site.
  196. */
  197. if ($.cookie('ARTISSIME_SHOW_MORE_BOX')!="not"){
  198. setTimeout(function(){$('#show_more').mbOpenBox('slow','');$('#services_btn').hide();},2000);
  199. /*
  200. * Set cookie for show_more box
  201. */
  202. var options = { expires: 1 };
  203. $.cookie('ARTISSIME_SHOW_MORE_BOX', "not", options);
  204. }
  205. });