source: extensions/simple_themes/simple/js/scripts.js @ 13546

Last change on this file since 13546 was 13546, checked in by plg, 12 years ago

import theme Simple, version 2.0

  • adaptation of the theme for Piwigo 2.1
File size: 4.7 KB
Line 
1jQuery.noConflict();
2
3jQuery(document).ready(function($){
4  $("#theComments h3").click(function () {
5    $("#theComments > div").toggle("slow");
6  });
7
8  $("#menuswitcher").click(function(){
9    if ($("#menubar").is(":hidden")) {
10      $("#menubar").show("slow");
11      $.cookie('side-menu', 'showing', {path: "/"});
12      return false;
13    } else {
14      $("#menubar").hide("slow");
15      $.cookie('side-menu', 'hiding', {path: "/"});
16      return false;
17    }
18  });
19
20  // creates a variable with the contents of the cookie side-menu
21  var sidemenu = $.cookie('side-menu');
22  // if cookie says the menu is hiding, keep it hidden!
23  if (sidemenu == 'hiding') {
24    $("#menubar").hide();
25  }
26  if (sidemenu == 'showing') {
27    $("#menubar").show();
28  };
29});
30
31/**
32 * Cookie plugin
33 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
34 * Dual licensed under the MIT and GPL licenses:
35 */
36jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options=$.extend({},options);options.expires=-1;}
37var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
38expires='; expires='+date.toUTCString();}
39var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}
40return cookieValue;}};
41
42/**
43 * Piwigo scripts
44 */
45function phpWGOpenWindow(theURL,winName,features)
46{img=new Image();img.src=theURL;if(img.complete)
47{var width=img.width+40;var height=img.height+40;}
48else
49{var width=640;var height=480;img.onload=resizeWindowToFit;}
50newWin=window.open(theURL,winName,features+',left=2,top=1,width='+width+',height='+height);}
51function resizeWindowToFit()
52{newWin.resizeTo(img.width+50,img.height+100);}
53function popuphelp(url)
54{window.open(url,'dc_popup','alwaysRaised=yes,dependent=yes,toolbar=no,height=420,width=500,menubar=no,resizable=yes,scrollbars=yes,status=no');}
55Function.prototype.pwgBind=function(){var __method=this,object=arguments[0],args=new Array();for(var i=1;i<arguments.length;i++)
56args[i-1]=arguments[i];return function(){return __method.apply(object,args);}}
57function PwgWS(urlRoot)
58{this.urlRoot=urlRoot;this.options={method:"GET",async:true,onFailure:null,onSuccess:null};};PwgWS.prototype={callService:function(method,parameters,options)
59{if(options)
60{for(var property in options)
61this.options[property]=options[property];}
62try{this.transport=new XMLHttpRequest();}
63catch(e){try{this.transport=new ActiveXObject('Msxml2.XMLHTTP');}
64catch(e){try{this.transport=new ActiveXObject('Microsoft.XMLHTTP');}
65catch(e){dispatchError(0,"Cannot create request object");}}}
66this.transport.onreadystatechange=this.onStateChange.pwgBind(this);var url=this.urlRoot+"ws.php?format=json";var body="method="+method;if(parameters)
67{for(var property in parameters)
68{if(typeof parameters[property]=='object'&&parameters[property])
69{for(var i=0;i<parameters[property].length;i++)
70body+="&"+property+"[]="+encodeURIComponent(parameters[property][i]);}
71else
72body+="&"+property+"="+encodeURIComponent(parameters[property]);}}
73if(this.options.method=="POST")
74{this.transport.open(this.options.method,url,this.options.async);this.transport.setRequestHeader("Content-Type","application/x-www-form-urlencoded");this.transport.send(body);}
75else
76{url+="&"+body;this.transport.open(this.options.method,url,this.options.async);this.transport.send(null);}},onStateChange:function(){var readyState=this.transport.readyState;if(readyState==4)
77this.respondToReadyState(this.transport.readyState);},dispatchError:function(httpCode,text)
78{!this.options.onFailure||this.options.onFailure(httpCode,text);},respondToReadyState:function(readyState)
79{var transport=this.transport;if(readyState==4&&transport.status==200)
80{var resp;try{eval('resp = '+transport.responseText);}
81catch(e){this.dispatchError(200,e.message+'\n'+transport.responseText.substr(0,512));}
82if(resp!=null)
83{if(resp.stat==null)
84this.dispatchError(200,"Invalid response");else if(resp.stat=='ok')
85{if(this.options.onSuccess)this.options.onSuccess(resp.result);}
86else
87this.dispatchError(200,resp.err+" "+resp.message);}}
88if(readyState==4&&transport.status!=200)
89this.dispatchError(transport.status,transport.statusText);},transport:null,urlRoot:null,options:{}}
Note: See TracBrowser for help on using the repository browser.