@@ -, +, @@ --- .../opac-tmpl/bootstrap/en/includes/greybox.inc | 7 + koha-tmpl/opac-tmpl/lib/greybox/AJS.js | 525 ++++++++ koha-tmpl/opac-tmpl/lib/greybox/AJS_fx.js | 136 ++ koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5.zip | Bin 0 -> 180408 bytes .../opac-tmpl/lib/greybox/GreyBox_v5_5/LGPL.txt | 504 +++++++ .../opac-tmpl/lib/greybox/GreyBox_v5_5/about.html | 50 + .../GreyBox_v5_5/adobe_images/nav_buttons.psd | Bin 0 -> 165140 bytes .../lib/greybox/GreyBox_v5_5/advance_usage.html | 182 +++ .../opac-tmpl/lib/greybox/GreyBox_v5_5/combiner.py | 134 ++ .../greybox/GreyBox_v5_5/compressing_greybox.html | 55 + .../GreyBox_v5_5/compression_lib/AJS_minify.py | 255 ++++ .../GreyBox_v5_5/compression_lib/__init__.py | 1 + .../lib/greybox/GreyBox_v5_5/examples.html | 95 ++ .../GreyBox_v5_5/greybox_source/auto_deco.js | 67 + .../GreyBox_v5_5/greybox_source/base/AJS.js | 1371 ++++++++++++++++++++ .../GreyBox_v5_5/greybox_source/base/AJS_fx.js | 194 +++ .../GreyBox_v5_5/greybox_source/base/base.css | 32 + .../GreyBox_v5_5/greybox_source/base/base.js | 192 +++ .../GreyBox_v5_5/greybox_source/base/indicator.gif | Bin 0 -> 8238 bytes .../greybox_source/base/loader_frame.html | 104 ++ .../greybox_source/gallery/g_close.gif | Bin 0 -> 541 bytes .../greybox_source/gallery/gallery.css | 51 + .../GreyBox_v5_5/greybox_source/gallery/gallery.js | 114 ++ .../GreyBox_v5_5/greybox_source/set/next.gif | Bin 0 -> 528 bytes .../GreyBox_v5_5/greybox_source/set/prev.gif | Bin 0 -> 525 bytes .../GreyBox_v5_5/greybox_source/set/set.css | 20 + .../greybox/GreyBox_v5_5/greybox_source/set/set.js | 101 ++ .../greybox_source/window/header_bg.gif | Bin 0 -> 1188 bytes .../GreyBox_v5_5/greybox_source/window/w_close.gif | Bin 0 -> 74 bytes .../GreyBox_v5_5/greybox_source/window/window.css | 39 + .../GreyBox_v5_5/greybox_source/window/window.js | 109 ++ .../lib/greybox/GreyBox_v5_5/installation.html | 49 + .../lib/greybox/GreyBox_v5_5/normal_usage.html | 126 ++ .../lib/greybox/GreyBox_v5_5/static_files/help.css | 93 ++ .../lib/greybox/GreyBox_v5_5/static_files/help.js | 52 + .../lib/greybox/GreyBox_v5_5/static_files/logo.gif | Bin 0 -> 4514 bytes .../GreyBox_v5_5/static_files/night_valley.jpg | Bin 0 -> 46740 bytes .../static_files/night_valley_thumb.gif | Bin 0 -> 4410 bytes .../static_files/night_valley_thumb.jpg | Bin 0 -> 2524 bytes .../lib/greybox/GreyBox_v5_5/static_files/salt.jpg | Bin 0 -> 54124 bytes .../GreyBox_v5_5/static_files/salt_thumb.gif | Bin 0 -> 3061 bytes koha-tmpl/opac-tmpl/lib/greybox/g_close.gif | Bin 0 -> 541 bytes koha-tmpl/opac-tmpl/lib/greybox/gb_scripts.js | 436 +++++++ koha-tmpl/opac-tmpl/lib/greybox/gb_styles.css | 158 +++ koha-tmpl/opac-tmpl/lib/greybox/header_bg.gif | Bin 0 -> 1188 bytes koha-tmpl/opac-tmpl/lib/greybox/indicator.gif | Bin 0 -> 8238 bytes koha-tmpl/opac-tmpl/lib/greybox/loader_frame.html | 104 ++ koha-tmpl/opac-tmpl/lib/greybox/next.gif | Bin 0 -> 528 bytes koha-tmpl/opac-tmpl/lib/greybox/prev.gif | Bin 0 -> 525 bytes koha-tmpl/opac-tmpl/lib/greybox/w_close.gif | Bin 0 -> 74 bytes 50 files changed, 5356 insertions(+), 0 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/includes/greybox.inc create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/AJS.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/AJS_fx.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5.zip create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/LGPL.txt create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/about.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/adobe_images/nav_buttons.psd create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/advance_usage.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/combiner.py create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compressing_greybox.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/AJS_minify.py create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/__init__.py create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/examples.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/auto_deco.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS_fx.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/indicator.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/loader_frame.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/g_close.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/next.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/prev.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/header_bg.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/w_close.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/installation.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/normal_usage.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/logo.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/night_valley.jpg create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/night_valley_thumb.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/night_valley_thumb.jpg create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/salt.jpg create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/salt_thumb.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/g_close.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/gb_scripts.js create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/gb_styles.css create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/header_bg.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/indicator.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/loader_frame.html create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/next.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/prev.gif create mode 100644 koha-tmpl/opac-tmpl/lib/greybox/w_close.gif --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/greybox.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/greybox.inc @@ -0,0 +1,7 @@ + + + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/AJS.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/AJS.js @@ -0,0 +1,525 @@ +AJS={BASE_URL:"",drag_obj:null,drag_elm:null,_drop_zones:[],_cur_pos:null,join:function(_1,_2){ +try{ +return _2.join(_1); +} +catch(e){ +var r=_2[0]||""; +AJS.map(_2,function(_4){ +r+=_1+_4; +},1); +return r+""; +} +},getScrollTop:function(){ +var t; +if(document.documentElement&&document.documentElement.scrollTop){ +t=document.documentElement.scrollTop; +}else{ +if(document.body){ +t=document.body.scrollTop; +} +} +return t; +},addClass:function(){ +var _6=AJS.forceArray(arguments); +var _7=_6.pop(); +var _8=function(o){ +if(!new RegExp("(^|\\s)"+_7+"(\\s|$)").test(o.className)){ +o.className+=(o.className?" ":"")+_7; +} +}; +AJS.map(_6,function(_a){ +_8(_a); +}); +},setStyle:function(){ +var _b=AJS.forceArray(arguments); +var _c=_b.pop(); +var _d=_b.pop(); +AJS.map(_b,function(_e){ +_e.style[_d]=AJS.getCssDim(_c); +}); +},_getRealScope:function(fn,_10,_11,_12){ +var _13=window; +_10=AJS.$A(_10); +if(fn._cscope){ +_13=fn._cscope; +} +return function(){ +var _14=[]; +var i=0; +if(_11){ +i=1; +} +AJS.map(arguments,function(arg){ +_14.push(arg); +},i); +_14=_14.concat(_10); +if(_12){ +_14=_14.reverse(); +} +return fn.apply(_13,_14); +}; +},preloadImages:function(){ +AJS.AEV(window,"load",AJS.$p(function(_17){ +AJS.map(_17,function(src){ +var pic=new Image(); +pic.src=src; +}); +},arguments)); +},_createDomShortcuts:function(){ +var _1a=["ul","li","td","tr","th","tbody","table","input","span","b","a","div","img","button","h1","h2","h3","br","textarea","form","p","select","option","iframe","script","center","dl","dt","dd","small","pre"]; +var _1b=function(elm){ +var _1d="return AJS.createDOM.apply(null, ['"+elm+"', arguments]);"; +var _1e="function() { "+_1d+" }"; +eval("AJS."+elm.toUpperCase()+"="+_1e); +}; +AJS.map(_1a,_1b); +AJS.TN=function(_1f){ +return document.createTextNode(_1f); +}; +},documentInsert:function(elm){ +if(typeof (elm)=="string"){ +elm=AJS.HTML2DOM(elm); +} +document.write(""); +AJS.swapDOM(AJS.$("dummy_holder"),elm); +},getWindowSize:function(doc){ +doc=doc||document; +var _22,_23; +if(self.innerHeight){ +_22=self.innerWidth; +_23=self.innerHeight; +}else{ +if(doc.documentElement&&doc.documentElement.clientHeight){ +_22=doc.documentElement.clientWidth; +_23=doc.documentElement.clientHeight; +}else{ +if(doc.body){ +_22=doc.body.clientWidth; +_23=doc.body.clientHeight; +} +} +} +return {"w":_22,"h":_23}; +},flattenList:function(_24){ +var r=[]; +var _26=function(r,l){ +AJS.map(l,function(o){ +if(o==null){ +}else{ +if(AJS.isArray(o)){ +_26(r,o); +}else{ +r.push(o); +} +} +}); +}; +_26(r,_24); +return r; +},setEventKey:function(e){ +e.key=e.keyCode?e.keyCode:e.charCode; +if(window.event){ +e.ctrl=window.event.ctrlKey; +e.shift=window.event.shiftKey; +}else{ +e.ctrl=e.ctrlKey; +e.shift=e.shiftKey; +} +switch(e.key){ +case 63232: +e.key=38; +break; +case 63233: +e.key=40; +break; +case 63235: +e.key=39; +break; +case 63234: +e.key=37; +break; +} +},removeElement:function(){ +var _2b=AJS.forceArray(arguments); +AJS.map(_2b,function(elm){ +AJS.swapDOM(elm,null); +}); +},_unloadListeners:function(){ +if(AJS.listeners){ +AJS.map(AJS.listeners,function(elm,_2e,fn){ +AJS.REV(elm,_2e,fn); +}); +} +AJS.listeners=[]; +},partial:function(fn){ +var _31=AJS.forceArray(arguments); +return AJS.$b(fn,null,_31.slice(1,_31.length).reverse(),false,true); +},getIndex:function(elm,_33,_34){ +for(var i=0;i<_33.length;i++){ +if(_34&&_34(_33[i])||elm==_33[i]){ +return i; +} +} +return -1; +},isDefined:function(o){ +return (o!="undefined"&&o!=null); +},isArray:function(obj){ +return obj instanceof Array; +},setLeft:function(){ +var _38=AJS.forceArray(arguments); +_38.splice(_38.length-1,0,"left"); +AJS.setStyle.apply(null,_38); +},appendChildNodes:function(elm){ +if(arguments.length>=2){ +AJS.map(arguments,function(n){ +if(AJS.isString(n)){ +n=AJS.TN(n); +} +if(AJS.isDefined(n)){ +elm.appendChild(n); +} +},1); +} +return elm; +},isOpera:function(){ +return (navigator.userAgent.toLowerCase().indexOf("opera")!=-1); +},isString:function(obj){ +return (typeof obj=="string"); +},hideElement:function(elm){ +var _3d=AJS.forceArray(arguments); +AJS.map(_3d,function(elm){ +elm.style.display="none"; +}); +},setOpacity:function(elm,p){ +elm.style.opacity=p; +elm.style.filter="alpha(opacity="+p*100+")"; +},setHeight:function(){ +var _41=AJS.forceArray(arguments); +_41.splice(_41.length-1,0,"height"); +AJS.setStyle.apply(null,_41); +},setWidth:function(){ +var _42=AJS.forceArray(arguments); +_42.splice(_42.length-1,0,"width"); +AJS.setStyle.apply(null,_42); +},createArray:function(v){ +if(AJS.isArray(v)&&!AJS.isString(v)){ +return v; +}else{ +if(!v){ +return []; +}else{ +return [v]; +} +} +},isDict:function(o){ +var _45=String(o); +return _45.indexOf(" Object")!=-1; +},isMozilla:function(){ +return (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1&&navigator.productSub>=20030210); +},_listenOnce:function(elm,_47,fn){ +var _49=function(){ +AJS.removeEventListener(elm,_47,_49); +fn(arguments); +}; +return _49; +},addEventListener:function(elm,_4b,fn,_4d,_4e){ +if(!_4e){ +_4e=false; +} +var _4f=AJS.$A(elm); +AJS.map(_4f,function(_50){ +if(_4d){ +fn=AJS._listenOnce(_50,_4b,fn); +} +if(AJS.isIn(_4b,["submit","load","scroll","resize"])){ +var old=elm["on"+_4b]; +elm["on"+_4b]=function(){ +if(old){ +fn(arguments); +return old(arguments); +}else{ +return fn(arguments); +} +}; +return; +} +if(AJS.isIn(_4b,["keypress","keydown","keyup","click"])){ +var _52=fn; +fn=function(e){ +AJS.setEventKey(e); +return _52.apply(null,arguments); +}; +} +if(_50.attachEvent){ +_50.attachEvent("on"+_4b,fn); +}else{ +if(_50.addEventListener){ +_50.addEventListener(_4b,fn,_4e); +} +} +AJS.listeners=AJS.$A(AJS.listeners); +AJS.listeners.push([_50,_4b,fn]); +}); +},createDOM:function(_54,_55){ +var i=0,_57; +elm=document.createElement(_54); +if(AJS.isDict(_55[i])){ +for(k in _55[0]){ +_57=_55[0][k]; +if(k=="style"){ +elm.style.cssText=_57; +}else{ +if(k=="class"||k=="className"){ +elm.className=_57; +}else{ +elm.setAttribute(k,_57); +} +} +} +i++; +} +if(_55[0]==null){ +i=1; +} +AJS.map(_55,function(n){ +if(n){ +if(AJS.isString(n)||AJS.isNumber(n)){ +n=AJS.TN(n); +} +elm.appendChild(n); +} +},i); +return elm; +},setTop:function(){ +var _59=AJS.forceArray(arguments); +_59.splice(_59.length-1,0,"top"); +AJS.setStyle.apply(null,_59); +},getElementsByTagAndClassName:function(_5a,_5b,_5c){ +var _5d=[]; +if(!AJS.isDefined(_5c)){ +_5c=document; +} +if(!AJS.isDefined(_5a)){ +_5a="*"; +} +var els=_5c.getElementsByTagName(_5a); +var _5f=els.length; +var _60=new RegExp("(^|\\s)"+_5b+"(\\s|$)"); +for(i=0,j=0;i<_5f;i++){ +if(_60.test(els[i].className)||_5b==null){ +_5d[j]=els[i]; +j++; +} +} +return _5d; +},removeClass:function(){ +var _61=AJS.forceArray(arguments); +var cls=_61.pop(); +var _63=function(o){ +o.className=o.className.replace(new RegExp("\\s?"+cls,"g"),""); +}; +AJS.map(_61,function(elm){ +_63(elm); +}); +},bindMethods:function(_66){ +for(var k in _66){ +var _68=_66[k]; +if(typeof (_68)=="function"){ +_66[k]=AJS.$b(_68,_66); +} +} +},log:function(o){ +if(AJS.isMozilla()){ +console.log(o); +}else{ +var div=AJS.DIV({"style":"color: green"}); +AJS.ACN(AJS.getBody(),AJS.setHTML(div,""+o)); +} +},isNumber:function(obj){ +return (typeof obj=="number"); +},map:function(_6c,fn,_6e,_6f){ +var i=0,l=_6c.length; +if(_6e){ +i=_6e; +} +if(_6f){ +l=_6f; +} +for(i;i0){ +var fn=_9b.pop(); +var _9e=fn(_9c,req); +if(_9e){ +_9c=_9e; +} +} +},callback:function(){ +this.excCallbackSeq(this.req,this.callbacks); +},errback:function(){ +if(this.errbacks.length==0){ +alert("Error encountered:\n"+this.req.responseText); +} +this.excCallbackSeq(this.req,this.errbacks); +},addErrback:function(fn){ +this.errbacks.unshift(fn); +},addCallback:function(fn){ +this.callbacks.unshift(fn); +},addCallbacks:function(fn1,fn2){ +this.addCallback(fn1); +this.addErrback(fn2); +},sendReq:function(_a3){ +if(AJS.isObject(_a3)){ +this.req.send(AJS.queryArguments(_a3)); +}else{ +if(AJS.isDefined(_a3)){ +this.req.send(_a3); +}else{ +this.req.send(""); +} +} +}}; +script_loaded=true; + + +script_loaded=true; --- a/koha-tmpl/opac-tmpl/lib/greybox/AJS_fx.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/AJS_fx.js @@ -0,0 +1,136 @@ +AJS.fx={_shades:{0:"ffffff",1:"ffffee",2:"ffffdd",3:"ffffcc",4:"ffffbb",5:"ffffaa",6:"ffff99"},highlight:function(_1,_2){ +var _3=new AJS.fx.Base(); +_3.elm=AJS.$(_1); +_3.setOptions(_2); +_3.options.duration=600; +AJS.update(_3,{increase:function(){ +if(this.now==7){ +_1.style.backgroundColor="transparent"; +}else{ +_1.style.backgroundColor="#"+AJS.fx._shades[Math.floor(this.now)]; +} +}}); +return _3.custom(6,0); +},fadeIn:function(_4,_5){ +_5=_5||{}; +if(!_5.from){ +_5.from=0; +AJS.setOpacity(_4,0); +} +if(!_5.to){ +_5.to=1; +} +var s=new AJS.fx.Style(_4,"opacity",_5); +return s.custom(_5.from,_5.to); +},fadeOut:function(_7,_8){ +_8=_8||{}; +if(!_8.from){ +_8.from=1; +} +if(!_8.to){ +_8.to=0; +} +_8.duration=300; +var s=new AJS.fx.Style(_7,"opacity",_8); +return s.custom(_8.from,_8.to); +},setWidth:function(_a,_b){ +var s=new AJS.fx.Style(_a,"width",_b); +return s.custom(_b.from,_b.to); +},setHeight:function(_d,_e){ +var s=new AJS.fx.Style(_d,"height",_e); +return s.custom(_e.from,_e.to); +}}; +AJS.fx.Base=new AJS.Class({init:function(){ +AJS.bindMethods(this); +},setOptions:function(_10){ +this.options=AJS.update({onStart:function(){ +},onComplete:function(){ +},transition:AJS.fx.Transitions.sineInOut,duration:500,wait:true,fps:50},_10||{}); +},step:function(){ +var _11=new Date().getTime(); +if(_11 + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/about.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/about.html @@ -0,0 +1,50 @@ + + + + GreyBox - About + + + + + + + + + + + + + + + + +

+GreyBox is copyrighted work by Amir Salihefendic. +

+ +

+It is based on AJS JavaScript library. +

+ +

+It is realesed under LGPL. +

+ +

Links

+ + +

Need help?

+ + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/advance_usage.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/advance_usage.html @@ -0,0 +1,182 @@ + + + + GreyBox - Advance usage + + + + + + + + + + + + + + + +

Methods for showing windows

+ +

GB_show

+ +

Signature:

+ + +

Example:

+ + +

Example rendered:

+Visit Google + + +

GB_showCenter

+ +

Signature:

+ + +

Example:

+ + +

Example rendered:

+Visit Google + + +

GB_showFullScreen

+ +

Signature:

+ + +

Example:

+ + +

Example rendered:

+Visit Google + +

Methods for showing overlays

+ +

GB_showImage

+

Signature:

+ + +

Example:

+ + +

Example rendered:

+A flower in my hand + +

GB_showPage

+

Signature:

+ + +

Example:

+ + +

Example rendered:

+Show Google in another layout + + +

Methods for showing sets

+ +

GB_showFullScreenSet

+

Signature:

+ + +

Example:

+ + +

Example rendered:

+ +Show first page in page_set + +

GB_showImageSet

+

Signature:

+ + +

Example:

+ + +

Example rendered:

+ +Show first picture in image_set + + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/combiner.py +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/combiner.py @@ -0,0 +1,134 @@ +#!/usr/bin/env python +""" +Used to combine the different parts of GreyBox. +- Python 2.4 required +- Java 1.4+ required +- Dojo's JavaScript compressor (http://dojotoolkit.org/docs/compressor_system.html). Place it under compression_lib/custom_rhino.jar +""" +import os, sys, shutil +from compression_lib import AJS_minify + + +if __name__ == '__main__': + args = sys.argv + + if len(args) < 2: + print """ +Usage is: + python combiner.py [full|gallery|window] +Example usage: + python combiner.py full +The files will be store in greybox_dist/* depending on the dist. type +""" + sys.exit(0) + + type = args[1] + output_dir = 'greybox' + + ## + # Config file list + # + js = [] + css = [] + static = [] + + append = lambda l, x: l.append('greybox_source/%s' % x) + + def appendBase(): + append(js, 'base/base.js') + append(js, 'auto_deco.js') + append(css, 'base/base.css') + append(static, 'base/indicator.gif') + append(static, 'base/loader_frame.html') + + def appendSet(): + append(js, 'set/set.js') + append(css, 'set/set.css') + append(static, 'set/next.gif') + append(static, 'set/prev.gif') + + def appendGallery(): + append(js, 'gallery/gallery.js') + append(css, 'gallery/gallery.css') + append(static, 'gallery/g_close.gif') + + def appendWindow(): + append(js, 'window/window.js') + append(css, 'window/window.css') + append(static, 'window/header_bg.gif') + append(static, 'window/w_close.gif') + + appendBase() + + if type == 'full': + appendGallery() + appendSet() + appendWindow() + elif type == 'gallery': + appendGallery() + appendSet() + elif type == 'window': + appendWindow() + else: + sys.exit('Uknown type') + + print 'Follwoing styles are used:' + for style in css: + print ' %s' % style + + print 'Follwoing JavaScript is used:' + for script in js: + print ' %s' % script + + ## + # Copy the files + # + try: + shutil.rmtree(output_dir) + except: + pass + os.mkdir(output_dir) + + def concatFiles(f_list): + data = [] + for f in f_list: + data.append(open(f, 'r').read()) + return '\n\n'.join(data) + + def copyFiles(f_list): + for f in f_list: + shutil.copy(f, output_dir) + + copyFiles(static) + fp = open('%s/%s' % (output_dir, 'gb_styles.css'), 'w') + fp.write(concatFiles(css)) + fp.close() + print 'Compressed styles in %s' % ('greybox/gb_styles.css') + + ## + # Concat js + # + fp = open('%s/%s' % (output_dir, 'gb_scripts_tmp.js'), 'w') + fp.write(concatFiles(js)) + fp.close() + + AJS_minify.AJS_SRC = 'greybox_source/base/AJS.js' + AJS_minify.AJS_MINI_SRC = 'greybox/AJS_tmp.js' + files = ['greybox/gb_scripts_tmp.js', 'greybox_source/base/AJS_fx.js', 'static_files/help.js'] + code_analyzer = AJS_minify.ExternalCodeAnalyzer(files) + composer = AJS_minify.AjsComposer(code_analyzer.findFunctions()) + composer.writeToOutput() + + os.popen('java -jar compression_lib/custom_rhino.jar -c greybox/AJS_tmp.js > greybox/AJS.js') + os.remove('greybox/AJS_tmp.js') + os.popen('java -jar compression_lib/custom_rhino.jar -c greybox_source/base/AJS_fx.js > greybox/AJS_fx.js') + print 'Compressed AJS.js and AJS.js into greybox/' + + os.popen('java -jar compression_lib/custom_rhino.jar -c greybox/gb_scripts_tmp.js > greybox/gb_scripts.js') + os.remove('greybox/gb_scripts_tmp.js') + print 'Compressed JavaScript in %s' % ('greybox/gb_scripts.css') + + #Append script_loaded + open('greybox/AJS.js', 'a').write('\nscript_loaded=true;') + open('greybox/AJS_fx.js', 'a').write('\nscript_loaded=true;') + open('greybox/gb_scripts.js', 'a').write('\nscript_loaded=true;') --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compressing_greybox.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compressing_greybox.html @@ -0,0 +1,55 @@ + + + + GreyBox - Compressing GreyBox + + + + + + + + + + + + + + + +

Code structure

+
    +
  • greybox: Generated and compressed JavaScript and CSS is located here
  • +
  • greybox_source: CSS and JavaScript structured in directories.
  • +
+It's not recommend that you alter code in the greybox directory, since it's computer generated and very unreadable! + + +

Download Dojo ShrinkSafe

+To make the filesize as small as possible GreyBox JavaScript is compressed down using Dojo ShrinkSafe. This library requires Java, so make sure you got Java installed. Download following JAR file: + +Place custom_rhino.jar in GreyBox's compression_lib directory. + + +

Compressing GreyBox

+Now, you are ready to compress GreyBox. This is done by running a Python script called combiner.py. I.e. you need to download and install Pyhton. + +

+You can run combiner.py in following ways: +

+ +
    +
  • python combiner.py full: Compress everything
  • +
  • python combiner.py gallery: Compress only gallery related CSS and JavaScript
  • +
  • python combiner.py window: Compress only window related CSS and JavaScript
  • +
+ + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/AJS_minify.py +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/AJS_minify.py @@ -0,0 +1,255 @@ +#!/usr/bin/env python +#Last-update: 08/05/07 12:39:17 +import re +import sys +from sets import Set + +## +# External files +# +AJS_SRC = 'AJS.js' +AJS_MINI_SRC = 'AJS_compressed.js' + + +## +# Standard stuff that may change in the future +# +DOM_SHORTCUTS = [ + "ul", "li", "td", "tr", "th", + "tbody", "table", "input", "span", "b", + "a", "div", "img", "button", "h1", + "h2", "h3", "br", "textarea", "form", + "p", "select", "option", "iframe", "script", + "center", "dl", "dt", "dd", "small", + "pre", "tn" +] + +FN_SHORTCUTS = { + '$': 'getElement', + '$$': 'getElements', + '$f': 'getFormElement', + '$b': 'bind', + '$p': 'partial', + '$A': 'createArray', + 'DI': 'documentInsert', + 'ACN': 'appendChildNodes', + 'RCN': 'replaceChildNodes', + 'AEV': 'addEventListener', + 'REV': 'removeEventListener', + '$bytc': 'getElementsByTagAndClassName' +} + +AJS_TEMPLATE = """//AJS JavaScript library (minify'ed version) +//Copyright (c) 2006 Amir Salihefendic. All rights reserved. +//Copyright (c) 2005 Bob Ippolito. All rights reserved. +//License: http://www.opensource.org/licenses/mit-license.php +//Visit http://orangoo.com/AmiNation/AJS for full version. +AJS = { +BASE_URL: "", +drag_obj: null, +drag_elm: null, +_drop_zones: [], +_cur_pos: null, + +%(functions)s +} + +AJS.$ = AJS.getElement; +AJS.$$ = AJS.getElements; +AJS.$f = AJS.getFormElement; +AJS.$p = AJS.partial; +AJS.$b = AJS.bind; +AJS.$A = AJS.createArray; +AJS.DI = AJS.documentInsert; +AJS.ACN = AJS.appendChildNodes; +AJS.RCN = AJS.replaceChildNodes; +AJS.AEV = AJS.addEventListener; +AJS.REV = AJS.removeEventListener; +AJS.$bytc = AJS.getElementsByTagAndClassName; + +AJS.addEventListener(window, 'unload', AJS._unloadListeners); +AJS._createDomShortcuts(); + +%(AJSClass)s + +%(AJSDeferred)s +script_loaded = true; +""" + + +def getAjsCode(): + return open(AJS_SRC).read() + +def writeAjsMini(code): + open(AJS_MINI_SRC, "w").write(code) + + +class AjsAnalyzer: + + def __init__(self): + self.code = getAjsCode() + self.ajs_fns = {} + self.ajs_deps = {} + self._parseAJS() + self._findDeps() + + def _parseAJS(self): + ajs_code = re.search("AJS =(.|\n)*\n}\n", self.code).group(0) + fns = re.findall("\s+((\w*?):.*?{(.|\n)*?\n\s*})(,|\n+})\n", ajs_code) + for f in fns: + self.ajs_fns[f[1]] = f[0] + + def getFnCode(self, fn_name, caller=None): + """ + Returns the code of function and it's dependencies as a list + """ + fn_name = self._unfoldFn(fn_name) + r = [] + if self.ajs_fns.get(fn_name): + r.append(self.ajs_fns[fn_name]) + for dep_fn in self.ajs_deps[fn_name]: + if fn_name != dep_fn and dep_fn != caller: + r.extend(self.getFnCode(dep_fn, fn_name)) + elif fn_name not in ['listeners', 'Class']: + print 'Could not find "%s"' % fn_name + return r + + def getAjsClassCode(self): + return re.search("AJS.Class =(.|\n)*\n};\n", self.code).group(0) + + def getAjsDeferredCode(self): + return re.search("AJSDeferred =(.|\n)*\n};\n", self.code).group(0) + + def _findDeps(self): + """ + Parses AJS and for every function it finds dependencies for the other functions. + """ + for fn_name, fn_code in self.ajs_fns.items(): + self.ajs_deps[fn_name] = self._findFns(fn_code) + + def _findFns(self, inner): + """ + Searches after AJS.fnX( in inner and returns all the fnX in a Set. + """ + s = re.findall("AJS\.([\w_$]*?)(?:\(|,|\.)", inner) + s = list(Set(s)) + return self._unfoldFns(s) + + def _unfoldFns(self, list): + """ + Unfolds: + AJS.B, AJS.H1 etc. to _createDomShortcuts + AJS.$ to AJS.getElement etc. + """ + return [self._unfoldFn(n) for n in list] + + def _unfoldFn(self, fn_name): + if fn_name.lower() in DOM_SHORTCUTS: + return "_createDomShortcuts" + elif FN_SHORTCUTS.get(fn_name): + return FN_SHORTCUTS[fn_name] + else: + return fn_name + + +class ExternalCodeAnalyzer: + + def __init__(self, files): + self.found_ajs_fns = [] + self.files = files + + def findFunctions(self): + for f in self.files: + self.found_ajs_fns.extend( self._parseFile(f) ) + return list(Set(self.found_ajs_fns)) + + def _parseFile(self, f): + """ + Parses the file, looks for AJS functions and returns all the found functions. + """ + code = open(f).read() + return re.findall("AJS\.([\w_$]*?)\(", code) + + + +class AjsComposer: + + def __init__(self, fn_list): + self.code = getAjsCode() + self.analyzer = AjsAnalyzer() + self.fn_list = fn_list + + #Append standard functions + req = ['_unloadListeners', 'createDOM', '_createDomShortcuts', 'log', 'addEventListener'] + self.fn_list.extend(req) + + #Append AJSDeferred only if needed + in_list = lambda x: x in self.fn_list + if in_list('getRequest') or in_list('loadJSONDoc'): + self.deferred = self._minify(self.analyzer.getAjsDeferredCode()) + self.fn_list.append('isObject') + else: + self.deferred = '' + + def writeToOutput(self): + fns = self._getFns() + d = {} + d['functions'] = ",\n".join(fns) + d['AJSDeferred'] = self.deferred + d['AJSClass'] = self.analyzer.getAjsClassCode() + + mini_code = AJS_TEMPLATE % d + writeAjsMini(mini_code) + + def _minify(self, code): + new_lines = [] + for l in code.split("\n"): + if l not in ['\n', '']: + new_lines.append(l.lstrip()) + return "\n".join(new_lines) + + def _getFns(self): + """ + Returns a list with real code of functions + """ + r = [] + for fn in self.fn_list: + r.extend(self.analyzer.getFnCode(fn)) + + r = list(Set(r)) + return [self._minify(fn) for fn in r] + + +if __name__ == '__main__': + args = sys.argv + + if len(args) < 3: + print """Usage is: + python AJS_minify.py [-o output_file] ajs_file js_file.js html_using_ajs.html ... +Example usage: + Using relative paths: + python AJS_minify.py -o AJS_mini.js AJS.js test.js index.html + This will create AJS_mini.js from test.js and index.html. + Using absolute paths: + python AJS_minify.py ~/Desktop/AJS/AJS.js ~/Desktop/GreyBox_v3_42/greybox/greybox.js + This will create a new file called '%s' that has the needed AJS functions.""" % AJS_MINI_SRC + + sys.exit(0) + + if sys.argv[1] == '-o': + AJS_MINI_SRC = sys.argv[2] + AJS_SRC = sys.argv[3] + FILES = sys.argv[4:] + else: + AJS_SRC = sys.argv[1] + FILES = sys.argv[2:] + + print 'Parsing through:\n %s' % "\n ".join(FILES) + + code_analyzer = ExternalCodeAnalyzer(FILES) + found_fns = code_analyzer.findFunctions() + print 'Found following AJS functions:\n %s' % ("\n ".join(found_fns)) + + composer = AjsComposer(found_fns) + composer.writeToOutput() + print "Written the minified code to '%s'" % AJS_MINI_SRC --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/__init__.py +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/compression_lib/__init__.py @@ -0,0 +1, @@ +# --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/examples.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/examples.html @@ -0,0 +1,95 @@ + + + + GreyBox - Examples + + + + + + + + + + + + + + + + +

One website

+ + +

Website gallery

+ + +

Image gallery

+ + + + +

Without loading

+ + + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/auto_deco.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/auto_deco.js @@ -0,0 +1,67 @@ +var GB_SETS = {}; +function decoGreyboxLinks() { + var as = AJS.$bytc('a'); + AJS.map(as, function(a) { + if(a.getAttribute('href') && a.getAttribute('rel')) { + var rel = a.getAttribute('rel'); + if(rel.indexOf('gb_') == 0) { + var name = rel.match(/\w+/)[0]; + var attrs = rel.match(/\[(.*)\]/)[1]; + var index = 0; + + var item = { + 'caption': a.title || '', + 'url': a.href + } + + //Set up GB_SETS + if(name == 'gb_pageset' || name == 'gb_imageset') { + if(!GB_SETS[attrs]) { GB_SETS[attrs] = []; } + GB_SETS[attrs].push(item); + index = GB_SETS[attrs].length; + } + + //Append onclick + if(name == 'gb_pageset') { + a.onclick = function() { + GB_showFullScreenSet(GB_SETS[attrs], index); + return false; + }; + } + if(name == 'gb_imageset') { + a.onclick = function() { + GB_showImageSet(GB_SETS[attrs], index); + return false; + }; + } + if(name == 'gb_image') { + a.onclick = function() { + GB_showImage(item.caption, item.url); + return false; + }; + } + if(name == 'gb_page') { + a.onclick = function() { + var sp = attrs.split(/, ?/); + GB_show(item.caption, item.url, parseInt(sp[1]), parseInt(sp[0])); + return false; + }; + } + if(name == 'gb_page_fs') { + a.onclick = function() { + GB_showFullScreen(item.caption, item.url); + return false; + }; + } + if(name == 'gb_page_center') { + a.onclick = function() { + var sp = attrs.split(/, ?/); + GB_showCenter(item.caption, item.url, parseInt(sp[1]), parseInt(sp[0])); + return false; + }; + } + } + }}); +} + +AJS.AEV(window, 'load', decoGreyboxLinks); --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS.js @@ -0,0 +1,1371 @@ +/* +Last Modified: 29/01/07 14:16:09 + +AJS JavaScript library + A very small library with a lot of functionality +AUTHOR + 4mir Salihefendic (http://amix.dk) - amix@amix.dk +LICENSE + Copyright (c) 2006 Amir Salihefendic. All rights reserved. + Copyright (c) 2005 Bob Ippolito. All rights reserved. + http://www.opensource.org/licenses/mit-license.php +VERSION + 3.7 +SITE + http://orangoo.com/AmiNation/AJS +**/ +if(!AJS) { +var AJS = { + BASE_URL: "", + + drag_obj: null, + drag_elm: null, + _drop_zones: [], + _drag_zones: [], + _cur_pos: null, + + ajaxErrorHandler: null, + +//// +// General accessor functions +//// + getQueryArgument: function(var_name) { + var query = window.location.search.substring(1); + var vars = query.split("&"); + for (var i=0;i= 20030210); + }, + + +//// +// Array functions +//// + //Shortcut: AJS.$A + createArray: function(v) { + if(AJS.isArray(v) && !AJS.isString(v)) + return v; + else if(!v) + return []; + else + return [v]; + }, + + forceArray: function(args) { + var r = []; + AJS.map(args, function(elm) { + r.push(elm); + }); + return r; + }, + + join: function(delim, list) { + try { + return list.join(delim); + } + catch(e) { + var r = list[0] || ''; + AJS.map(list, function(elm) { + r += delim + elm; + }, 1); + return r + ''; + } + }, + + isIn: function(elm, list) { + var i = AJS.getIndex(elm, list); + if(i != -1) + return true; + else + return false; + }, + + getIndex: function(elm, list/*optional*/, eval_fn) { + for(var i=0; i < list.length; i++) + if(eval_fn && eval_fn(list[i]) || elm == list[i]) + return i; + return -1; + }, + + getFirst: function(list) { + if(list.length > 0) + return list[0]; + else + return null; + }, + + getLast: function(list) { + if(list.length > 0) + return list[list.length-1]; + else + return null; + }, + + update: function(l1, l2) { + for(var i in l2) + l1[i] = l2[i]; + return l1; + }, + + flattenList: function(list) { + var r = []; + var _flatten = function(r, l) { + AJS.map(l, function(o) { + if(o == null) {} + else if (AJS.isArray(o)) + _flatten(r, o); + else + r.push(o); + }); + } + _flatten(r, list); + return r; + }, + + +//// +// Functional programming +//// + map: function(list, fn,/*optional*/ start_index, end_index) { + var i = 0, l = list.length; + if(start_index) + i = start_index; + if(end_index) + l = end_index; + for(i; i < l; i++) + fn.apply(null, [list[i], i]); + }, + + rmap: function(list, fn) { + var i = list.length-1, l = 0; + for(i; i >= l; i--) + fn.apply(null, [list[i], i]); + }, + + filter: function(list, fn, /*optional*/ start_index, end_index) { + var r = []; + AJS.map(list, function(elm) { + if(fn(elm)) + r.push(elm); + }, start_index, end_index); + return r; + }, + + partial: function(fn) { + var args = AJS.forceArray(arguments); + return AJS.$b(fn, null, args.slice(1, args.length).reverse(), false, true); + }, + + +//// +// DOM functions +//// + //Shortcut: AJS.$ + getElement: function(id) { + if(AJS.isString(id) || AJS.isNumber(id)) + return document.getElementById(id); + else + return id; + }, + + //Shortcut: AJS.$$ + getElements: function(/*id1, id2, id3*/) { + var args = AJS.forceArray(arguments); + var elements = new Array(); + for (var i = 0; i < args.length; i++) { + var element = AJS.getElement(args[i]); + elements.push(element); + } + return elements; + }, + + //Shortcut: AJS.$bytc + getElementsByTagAndClassName: function(tag_name, class_name, /*optional*/ parent) { + var class_elements = []; + if(!AJS.isDefined(parent)) + parent = document; + if(!AJS.isDefined(tag_name)) + tag_name = '*'; + + var els = parent.getElementsByTagName(tag_name); + var els_len = els.length; + var pattern = new RegExp("(^|\\s)" + class_name + "(\\s|$)"); + + for (i = 0, j = 0; i < els_len; i++) { + if ( pattern.test(els[i].className) || class_name == null ) { + class_elements[j] = els[i]; + j++; + } + } + return class_elements; + }, + + _nodeWalk: function(elm, tag_name, class_name, fn_next_elm) { + var p = fn_next_elm(elm); + + var checkFn; + if(tag_name && class_name) { + checkFn = function(p) { + return AJS.nodeName(p) == tag_name && AJS.hasClass(p, class_name); + } + } + else if(tag_name) { + checkFn = function(p) { return AJS.nodeName(p) == tag_name; } + } + else { + checkFn = function(p) { return AJS.hasClass(p, class_name); } + } + + while(p) { + if(checkFn(p)) + return p; + p = fn_next_elm(p); + } + return null; + }, + + getParentBytc: function(elm, tag_name, class_name) { + return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.parentNode; }); + }, + + getPreviousSiblingBytc: function(elm, tag_name, class_name) { + return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.previousSibling; }); + }, + + getNextSiblingBytc: function(elm, tag_name, class_name) { + return AJS._nodeWalk(elm, tag_name, class_name, function(m) { return m.nextSibling; }); + }, + + //Shortcut: AJS.$f + getFormElement: function(form, name) { + form = AJS.$(form); + var r = null; + AJS.map(form.elements, function(elm) { + if(elm.name && elm.name == name) + r = elm; + }); + return r; + }, + + formContents: function(form) { + var form = AJS.$(form); + var r = {}; + var fn = function(elms) { + AJS.map(elms, function(e) { + if(e.name) + r[e.name] = e.value || ''; + }); + } + fn(AJS.$bytc('input', null, form)); + fn(AJS.$bytc('textarea', null, form)); + return r; + }, + + getBody: function() { + return AJS.$bytc('body')[0] + }, + + nodeName: function(elm) { + return elm.nodeName.toLowerCase(); + }, + + hasParent: function(elm, parent_to_consider, max_look_up) { + if(elm == parent_to_consider) + return true; + if(max_look_up == 0) + return false; + return AJS.hasParent(elm.parentNode, parent_to_consider, max_look_up-1); + }, + + isElementHidden: function(elm) { + return elm.style.visibility == "hidden"; + }, + + //Shortcut: AJS.DI + documentInsert: function(elm) { + if(typeof(elm) == 'string') + elm = AJS.HTML2DOM(elm); + document.write(''); + AJS.swapDOM(AJS.$('dummy_holder'), elm); + }, + + cloner: function(element) { + return function() { + return element.cloneNode(true); + } + }, + + appendToTop: function(elm/*, elms...*/) { + var args = AJS.forceArray(arguments).slice(1); + if(args.length >= 1) { + var first_child = elm.firstChild; + if(first_child) { + while(true) { + var t_elm = args.shift(); + if(t_elm) + AJS.insertBefore(t_elm, first_child); + else + break; + } + } + else { + AJS.ACN.apply(null, arguments); + } + } + return elm; + }, + + //Shortcut: AJS.ACN + appendChildNodes: function(elm/*, elms...*/) { + if(arguments.length >= 2) { + AJS.map(arguments, function(n) { + if(AJS.isString(n)) + n = AJS.TN(n); + if(AJS.isDefined(n)) + elm.appendChild(n); + }, 1); + } + return elm; + }, + + //Shortcut: AJS.RCN + replaceChildNodes: function(elm/*, elms...*/) { + var child; + while ((child = elm.firstChild)) + elm.removeChild(child); + if (arguments.length < 2) + return elm; + else + return AJS.appendChildNodes.apply(null, arguments); + return elm; + }, + + insertAfter: function(elm, reference_elm) { + reference_elm.parentNode.insertBefore(elm, reference_elm.nextSibling); + return elm; + }, + + insertBefore: function(elm, reference_elm) { + reference_elm.parentNode.insertBefore(elm, reference_elm); + return elm; + }, + + showElement: function(/*elms...*/) { + var args = AJS.forceArray(arguments); + AJS.map(args, function(elm) { elm.style.display = ''}); + }, + + hideElement: function(elm) { + var args = AJS.forceArray(arguments); + AJS.map(args, function(elm) { elm.style.display = 'none'}); + }, + + swapDOM: function(dest, src) { + dest = AJS.getElement(dest); + var parent = dest.parentNode; + if (src) { + src = AJS.getElement(src); + parent.replaceChild(src, dest); + } else { + parent.removeChild(dest); + } + return src; + }, + + removeElement: function(/*elm1, elm2...*/) { + var args = AJS.forceArray(arguments); + AJS.map(args, function(elm) { AJS.swapDOM(elm, null); }); + }, + + createDOM: function(name, attrs) { + var i=0, attr; + elm = document.createElement(name); + + if(AJS.isDict(attrs[i])) { + for(k in attrs[0]) { + attr = attrs[0][k]; + if(k == "style") + elm.style.cssText = attr; + else if(k == "class" || k == 'className') + elm.className = attr; + else { + elm.setAttribute(k, attr); + } + } + i++; + } + + if(attrs[0] == null) + i = 1; + + AJS.map(attrs, function(n) { + if(n) { + if(AJS.isString(n) || AJS.isNumber(n)) + n = AJS.TN(n); + elm.appendChild(n); + } + }, i); + return elm; + }, + + _createDomShortcuts: function() { + var elms = [ + "ul", "li", "td", "tr", "th", + "tbody", "table", "input", "span", "b", + "a", "div", "img", "button", "h1", + "h2", "h3", "br", "textarea", "form", + "p", "select", "option", "iframe", "script", + "center", "dl", "dt", "dd", "small", + "pre" + ]; + var extends_ajs = function(elm) { + var c_dom = "return AJS.createDOM.apply(null, ['" + elm + "', arguments]);"; + var c_fun_dom = 'function() { ' + c_dom + ' }'; + eval("AJS." + elm.toUpperCase() + "=" + c_fun_dom); + } + AJS.map(elms, extends_ajs); + AJS.TN = function(text) { return document.createTextNode(text) }; + }, + + getCssDim: function(dim) { + if(AJS.isString(dim)) + return dim; + else + return dim + "px"; + }, + getCssProperty: function(elm, prop) { + elm = AJS.$(elm); + var y; + if(elm.currentStyle) + y = elm.currentStyle[prop]; + else if (window.getComputedStyle) + y = document.defaultView.getComputedStyle(elm,null).getPropertyValue(prop); + return y; + }, + + setStyle: function(/*elm1, elm2..., property, new_value*/) { + var args = AJS.forceArray(arguments); + var new_val = args.pop(); + var property = args.pop(); + AJS.map(args, function(elm) { + elm.style[property] = AJS.getCssDim(new_val); + }); + }, + + setWidth: function(/*elm1, elm2..., width*/) { + var args = AJS.forceArray(arguments); + args.splice(args.length-1, 0, 'width'); + AJS.setStyle.apply(null, args); + }, + setHeight: function(/*elm1, elm2..., height*/) { + var args = AJS.forceArray(arguments); + args.splice(args.length-1, 0, 'height'); + AJS.setStyle.apply(null, args); + }, + setLeft: function(/*elm1, elm2..., left*/) { + var args = AJS.forceArray(arguments); + args.splice(args.length-1, 0, 'left'); + AJS.setStyle.apply(null, args); + }, + setTop: function(/*elm1, elm2..., top*/) { + var args = AJS.forceArray(arguments); + args.splice(args.length-1, 0, 'top'); + AJS.setStyle.apply(null, args); + }, + setClass: function(/*elm1, elm2..., className*/) { + var args = AJS.forceArray(arguments); + var c = args.pop(); + AJS.map(args, function(elm) { elm.className = c}); + }, + addClass: function(/*elm1, elm2..., className*/) { + var args = AJS.forceArray(arguments); + var cls = args.pop(); + var add_class = function(o) { + if(!new RegExp("(^|\\s)" + cls + "(\\s|$)").test(o.className)) + o.className += (o.className ? " " : "") + cls; + }; + AJS.map(args, function(elm) { add_class(elm); }); + }, + hasClass: function(elm, cls) { + if(!elm.className) + return false; + return elm.className == cls || + elm.className.search(new RegExp(" " + cls)) != -1 + }, + removeClass: function(/*elm1, elm2..., className*/) { + var args = AJS.forceArray(arguments); + var cls = args.pop(); + var rm_class = function(o) { + o.className = o.className.replace(new RegExp("\\s?" + cls, 'g'), ""); + }; + AJS.map(args, function(elm) { rm_class(elm); }); + }, + + setHTML: function(elm, html) { + elm.innerHTML = html; + return elm; + }, + + RND: function(tmpl, ns, scope) { + scope = scope || window; + var fn = function(w, g) { + g = g.split("|"); + var cnt = ns[g[0]]; + for(var i=1; i < g.length; i++) + cnt = scope[g[i]](cnt); + if(cnt == '') + return ''; + if(cnt == 0 || cnt == -1) + cnt += ''; + return cnt || w; + }; + return tmpl.replace(/%\(([A-Za-z0-9_|.]*)\)/g, fn); + }, + + HTML2DOM: function(html,/*optional*/ first_child) { + var d = AJS.DIV(); + d.innerHTML = html; + if(first_child) + return d.childNodes[0]; + else + return d; + }, + + preloadImages: function(/*img_src1, ..., img_srcN*/) { + AJS.AEV(window, 'load', AJS.$p(function(args) { + AJS.map(args, function(src) { + var pic = new Image(); + pic.src = src; + }); + }, arguments)); + }, + + +//// +// Effects +//// + setOpacity: function(elm, p) { + elm.style.opacity = p; + elm.style.filter = "alpha(opacity="+ p*100 +")"; + }, + + +//// +// Ajax functions +//// + getXMLHttpRequest: function() { + var try_these = [ + function () { return new XMLHttpRequest(); }, + function () { return new ActiveXObject('Msxml2.XMLHTTP'); }, + function () { return new ActiveXObject('Microsoft.XMLHTTP'); }, + function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); }, + function () { throw "Browser does not support XMLHttpRequest"; } + ]; + for (var i = 0; i < try_these.length; i++) { + var func = try_these[i]; + try { + return func(); + } catch (e) { + } + } + }, + + getRequest: function(url, data, type) { + if(!type) + type = "POST"; + var req = AJS.getXMLHttpRequest(); + + if(url.indexOf("http://") == -1) { + if(AJS.BASE_URL != '') { + if(AJS.BASE_URL.lastIndexOf('/') != AJS.BASE_URL.length-1) + AJS.BASE_URL += '/'; + url = AJS.BASE_URL + url; + } + else + url = window.location + url; + } + + req.open(type, url, true); + if(type == "POST") + req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); + return AJS._sendXMLHttpRequest(req); + }, + + _sendXMLHttpRequest: function(req, data) { + var d = new AJSDeferred(req); + + var onreadystatechange = function () { + if (req.readyState == 4) { + var status = ''; + try { + status = req.status; + } + catch(e) {}; + if(status == 200 || status == 304 || req.responseText == null) { + d.callback(); + } + else { + if(AJS.ajaxErrorHandler) + AJS.ajaxErrorHandler(req.responseText, req); + else + d.errback(); + } + } + } + req.onreadystatechange = onreadystatechange; + return d; + }, + + _reprString: function(o) { + return ('"' + o.replace(/(["\\])/g, '\\$1') + '"' + ).replace(/[\f]/g, "\\f" + ).replace(/[\b]/g, "\\b" + ).replace(/[\n]/g, "\\n" + ).replace(/[\t]/g, "\\t" + ).replace(/[\r]/g, "\\r"); + }, + + serializeJSON: function(o) { + var objtype = typeof(o); + if (objtype == "undefined") { + return "undefined"; + } else if (objtype == "number" || objtype == "boolean") { + return o + ""; + } else if (o === null) { + return "null"; + } + if (objtype == "string") { + return AJS._reprString(o); + } + var me = arguments.callee; + if (objtype != "function" && typeof(o.length) == "number") { + var res = []; + for (var i = 0; i < o.length; i++) { + var val = me(o[i]); + if (typeof(val) != "string") { + val = "undefined"; + } + res.push(val); + } + return "[" + res.join(",") + "]"; + } + // it's a function with no adapter, bad + if (objtype == "function") + return null; + res = []; + for (var k in o) { + var useKey; + if (typeof(k) == "number") { + useKey = '"' + k + '"'; + } else if (typeof(k) == "string") { + useKey = AJS._reprString(k); + } else { + // skip non-string or number keys + continue; + } + val = me(o[k]); + if (typeof(val) != "string") { + // skip non-serializable values + continue; + } + res.push(useKey + ":" + val); + } + return "{" + res.join(",") + "}"; + }, + + loadJSONDoc: function(url) { + var d = AJS.getRequest(url); + var eval_req = function(data, req) { + var text = req.responseText; + if(text == "Error") + d.errback(req); + else + return AJS.evalTxt(text); + }; + d.addCallback(eval_req); + return d; + }, + + evalTxt: function(txt) { + try { + return eval('('+ txt + ')'); + } + catch(e) { + return eval(txt); + } + }, + + evalScriptTags: function(html) { + var script_data = html.match(/((\n|\r|.)*?)<\/script>/g); + if(script_data != null) { + for(var i=0; i < script_data.length; i++) { + var script_only = script_data[i].replace(//g, ""); + script_only = script_only.replace(/<\/script>/g, ""); + eval(script_only); + } + } + }, + + queryArguments: function(data) { + var post_data = []; + for(k in data) + post_data.push(k + "=" + AJS.urlencode(data[k])); + return post_data.join("&"); + }, + + +//// +// Position and size +//// + getMousePos: function(e) { + var posx = 0; + var posy = 0; + if (!e) var e = window.event; + if (e.pageX || e.pageY) + { + posx = e.pageX; + posy = e.pageY; + } + else if (e.clientX || e.clientY) + { + posx = e.clientX + document.body.scrollLeft; + posy = e.clientY + document.body.scrollTop; + } + return {x: posx, y: posy}; + }, + + getScrollTop: function() { + //From: http://www.quirksmode.org/js/doctypes.html + var t; + if (document.documentElement && document.documentElement.scrollTop) + t = document.documentElement.scrollTop; + else if (document.body) + t = document.body.scrollTop; + return t; + }, + + absolutePosition: function(elm) { + var posObj = {'x': elm.offsetLeft, 'y': elm.offsetTop}; + if(elm.offsetParent) { + var temp_pos = AJS.absolutePosition(elm.offsetParent); + posObj.x += temp_pos.x; + posObj.y += temp_pos.y; + } + // safari bug + if (AJS.isSafari() && elm.style.position == 'absolute' ) { + posObj.x -= document.body.offsetLeft; + posObj.y -= document.body.offsetTop; + } + return posObj; + }, + + getWindowSize: function(doc) { + doc = doc || document; + var win_w, win_h; + if (self.innerHeight) { + win_w = self.innerWidth; + win_h = self.innerHeight; + } else if (doc.documentElement && doc.documentElement.clientHeight) { + win_w = doc.documentElement.clientWidth; + win_h = doc.documentElement.clientHeight; + } else if (doc.body) { + win_w = doc.body.clientWidth; + win_h = doc.body.clientHeight; + } + return {'w': win_w, 'h': win_h}; + }, + + isOverlapping: function(elm1, elm2) { + var pos_elm1 = AJS.absolutePosition(elm1); + var pos_elm2 = AJS.absolutePosition(elm2); + + var top1 = pos_elm1.y; + var left1 = pos_elm1.x; + var right1 = left1 + elm1.offsetWidth; + var bottom1 = top1 + elm1.offsetHeight; + var top2 = pos_elm2.y; + var left2 = pos_elm2.x; + var right2 = left2 + elm2.offsetWidth; + var bottom2 = top2 + elm2.offsetHeight; + var getSign = function(v) { + if(v > 0) return "+"; + else if(v < 0) return "-"; + else return 0; + } + + if ((getSign(top1 - bottom2) != getSign(bottom1 - top2)) && + (getSign(left1 - right2) != getSign(right1 - left2))) + return true; + return false; + }, + + +//// +// Events +//// + getEventElm: function(e) { + if(e && !e.type && !e.keyCode) + return e + var targ; + if (!e) var e = window.event; + if (e.target) targ = e.target; + else if (e.srcElement) targ = e.srcElement; + if (targ.nodeType == 3) // defeat Safari bug + targ = targ.parentNode; + return targ; + }, + + _getRealScope: function(fn, /*optional*/ extra_args, dont_send_event, rev_extra_args) { + var scope = window; + extra_args = AJS.$A(extra_args); + if(fn._cscope) + scope = fn._cscope; + + return function() { + //Append all the orginal arguments + extra_args + var args = []; + var i = 0; + if(dont_send_event) + i = 1; + + AJS.map(arguments, function(arg) { args.push(arg) }, i); + args = args.concat(extra_args); + if(rev_extra_args) + args = args.reverse(); + return fn.apply(scope, args); + }; + }, + + _unloadListeners: function() { + if(AJS.listeners) + AJS.map(AJS.listeners, function(elm, type, fn) { AJS.REV(elm, type, fn) }); + AJS.listeners = []; + }, + + setEventKey: function(e) { + e.key = e.keyCode ? e.keyCode : e.charCode; + + if(window.event) { + e.ctrl = window.event.ctrlKey; + e.shift = window.event.shiftKey; + } + else { + e.ctrl = e.ctrlKey; + e.shift = e.shiftKey; + } + switch(e.key) { + case 63232: + e.key = 38; + break; + case 63233: + e.key = 40; + break; + case 63235: + e.key = 39; + break; + case 63234: + e.key = 37; + break; + } + }, + + //Shortcut: AJS.AEV + addEventListener: function(elm, type, fn, /*optional*/listen_once, cancle_bubble) { + if(!cancle_bubble) + cancle_bubble = false; + + var elms = AJS.$A(elm); + AJS.map(elms, function(elmz) { + if(listen_once) + fn = AJS._listenOnce(elmz, type, fn); + + //Hack since it does not work in all browsers + if(AJS.isIn(type, ['submit', 'load', 'scroll', 'resize'])) { + var old = elm['on' + type]; + elm['on' + type] = function() { + if(old) { + fn(arguments); + return old(arguments); + } + else + return fn(arguments); + }; + return; + } + + //Fix keyCode + if(AJS.isIn(type, ['keypress', 'keydown', 'keyup', 'click'])) { + var old_fn = fn; + fn = function(e) { + AJS.setEventKey(e); + return old_fn.apply(null, arguments); + } + } + + if (elmz.attachEvent) { + //FIXME: We ignore cancle_bubble for IE... could be a problem? + elmz.attachEvent("on" + type, fn); + } + else if(elmz.addEventListener) + elmz.addEventListener(type, fn, cancle_bubble); + + AJS.listeners = AJS.$A(AJS.listeners); + AJS.listeners.push([elmz, type, fn]); + }); + }, + + //Shortcut: AJS.REV + removeEventListener: function(elm, type, fn, /*optional*/cancle_bubble) { + if(!cancle_bubble) + cancle_bubble = false; + if(elm.removeEventListener) { + elm.removeEventListener(type, fn, cancle_bubble); + if(AJS.isOpera()) + elm.removeEventListener(type, fn, !cancle_bubble); + } + else if(elm.detachEvent) + elm.detachEvent("on" + type, fn); + }, + + //Shortcut: AJS.$b + bind: function(fn, scope, /*optional*/ extra_args, dont_send_event, rev_extra_args) { + fn._cscope = scope; + return AJS._getRealScope(fn, extra_args, dont_send_event, rev_extra_args); + }, + + bindMethods: function(self) { + for (var k in self) { + var func = self[k]; + if (typeof(func) == 'function') { + self[k] = AJS.$b(func, self); + } + } + }, + + _listenOnce: function(elm, type, fn) { + var r_fn = function() { + AJS.removeEventListener(elm, type, r_fn); + fn(arguments); + } + return r_fn; + }, + + callLater: function(fn, interval) { + var fn_no_send = function() { + fn(); + }; + window.setTimeout(fn_no_send, interval); + }, + + preventDefault: function(e) { + if(AJS.isIe()) + window.event.returnValue = false; + else + e.preventDefault(); + }, + + +//// +// Drag and drop +//// + dragAble: function(elm, /*optional*/ handler, args) { + if(!args) + args = {}; + if(!AJS.isDefined(args['move_x'])) + args['move_x'] = true; + if(!AJS.isDefined(args['move_y'])) + args['move_y'] = true; + if(!AJS.isDefined(args['moveable'])) + args['moveable'] = false; + if(!AJS.isDefined(args['hide_on_move'])) + args['hide_on_move'] = true; + if(!AJS.isDefined(args['on_mouse_up'])) + args['on_mouse_up'] = null; + if(!AJS.isDefined(args['cursor'])) + args['cursor'] = 'move'; + if(!AJS.isDefined(args['max_move'])) + args['max_move'] = {'top': null, 'left': null}; + + elm = AJS.$(elm); + + if(!handler) + handler = elm; + + handler = AJS.$(handler); + var old_cursor = handler.style.cursor; + handler.style.cursor = args['cursor']; + elm.style.position = 'relative'; + + AJS.addClass(handler, '_ajs_handler'); + handler._args = args; + handler._elm = elm; + AJS.AEV(handler, 'mousedown', AJS._dragStart); + }, + + _dragStart: function(e) { + var handler = AJS.getEventElm(e); + if(!AJS.hasClass(handler, '_ajs_handler')) { + handler = AJS.getParentBytc(handler, null, '_ajs_handler'); + } + if(handler) + AJS._dragInit(e, handler._elm, handler._args); + }, + + dropZone: function(elm, args) { + elm = AJS.$(elm); + var item = {elm: elm}; + AJS.update(item, args); + AJS._drop_zones.push(item); + }, + + removeDragAble: function(elm) { + AJS.REV(elm, 'mousedown', AJS._dragStart); + elm.style.cursor = ''; + }, + + removeDropZone: function(elm) { + var i = AJS.getIndex(elm, AJS._drop_zones, function(item) { + if(item.elm == elm) return true; + }); + if(i != -1) { + AJS._drop_zones.splice(i, 1); + } + }, + + _dragInit: function(e, click_elm, args) { + AJS.drag_obj = new Object(); + AJS.drag_obj.args = args; + + AJS.drag_obj.click_elm = click_elm; + AJS.drag_obj.mouse_pos = AJS.getMousePos(e); + AJS.drag_obj.click_elm_pos = AJS.absolutePosition(click_elm); + + AJS.AEV(document, 'mousemove', AJS._dragMove, false, true); + AJS.AEV(document, 'mouseup', AJS._dragStop, false, true); + + if (AJS.isIe()) + window.event.cancelBubble = true; + AJS.preventDefault(e); + }, + + _initDragElm: function(elm) { + if(AJS.drag_elm && AJS.drag_elm.style.display == 'none') + AJS.removeElement(AJS.drag_elm); + + if(!AJS.drag_elm) { + AJS.drag_elm = AJS.DIV(); + var d = AJS.drag_elm; + AJS.insertBefore(d, AJS.getBody().firstChild); + AJS.setHTML(d, elm.innerHTML); + + d.className = elm.className; + d.style.cssText = elm.style.cssText; + + d.style.position = 'absolute'; + d.style.zIndex = 10000; + + var t = AJS.absolutePosition(elm); + AJS.setTop(d, t.y); + AJS.setLeft(d, t.x); + + if(AJS.drag_obj.args.on_init) { + AJS.drag_obj.args.on_init(elm); + } + } + }, + + _dragMove: function(e) { + var drag_obj = AJS.drag_obj; + var click_elm = drag_obj.click_elm; + + AJS._initDragElm(click_elm); + var drag_elm = AJS.drag_elm; + + if(drag_obj.args['hide_on_move']) + click_elm.style.visibility = 'hidden'; + + var cur_pos = AJS.getMousePos(e); + + var mouse_pos = drag_obj.mouse_pos; + + var click_elm_pos = drag_obj.click_elm_pos; + + AJS.map(AJS._drop_zones, function(d_z) { + if(AJS.isOverlapping(d_z['elm'], drag_elm)) { + if(d_z['elm'] != drag_elm) { + var on_hover = d_z['on_hover']; + if(on_hover) + on_hover(d_z['elm'], click_elm, drag_elm); + } + } + }); + + if(drag_obj.args['on_drag']) + drag_obj.args['on_drag'](click_elm, e); + + var max_move_top = drag_obj.args['max_move']['top']; + var max_move_left = drag_obj.args['max_move']['left']; + var p; + if(drag_obj.args['move_x']) { + p = cur_pos.x - (mouse_pos.x - click_elm_pos.x); + if(max_move_left == null || max_move_left <= p) + AJS.setLeft(elm, p); + } + + if(drag_obj.args['move_y']) { + p = cur_pos.y - (mouse_pos.y - click_elm_pos.y); + if(max_move_top == null || max_move_top <= p) + AJS.setTop(elm, p); + } + if(AJS.isIe()) { + window.event.cancelBubble = true; + window.event.returnValue = false; + } + else + e.preventDefault(); + }, + + _dragStop: function(e) { + var drag_obj = AJS.drag_obj; + var drag_elm = AJS.drag_elm; + var click_elm = drag_obj.click_elm; + + AJS.REV(document, "mousemove", AJS._dragMove, true); + AJS.REV(document, "mouseup", AJS._dragStop, true); + + var dropped = false; + AJS.map(AJS._drop_zones, function(d_z) { + if(AJS.isOverlapping(d_z['elm'], click_elm)) { + if(d_z['elm'] != click_elm) { + var on_drop = d_z['on_drop']; + if(on_drop) { + dropped = true; + on_drop(d_z['elm'], click_elm); + } + } + } + }); + + if(drag_obj.args['moveable']) { + var t = parseInt(click_elm.style.top) || 0; + var l = parseInt(click_elm.style.left) || 0; + var drag_elm_xy = AJS.absolutePosition(drag_elm); + var click_elm_xy = AJS.absolutePosition(click_elm); + AJS.setTop(click_elm, t + drag_elm_xy.y - click_elm_xy.y); + AJS.setLeft(click_elm, l + drag_elm_xy.x - click_elm_xy.x); + } + + if(!dropped && drag_obj.args['on_mouse_up']) + drag_obj.args['on_mouse_up'](click_elm, e); + + if(drag_obj.args['hide_on_move']) + drag_obj.click_elm.style.visibility = 'visible'; + + if(drag_obj.args.on_end) { + drag_obj.args.on_end(click_elm); + } + + AJS._dragObj = null; + if(drag_elm) + AJS.hideElement(drag_elm); + AJS.drag_elm = null; + }, + + +//// +// Misc. +//// + keys: function(obj) { + var rval = []; + for (var prop in obj) { + rval.push(prop); + } + return rval; + }, + + values: function(obj) { + var rval = []; + for (var prop in obj) { + rval.push(obj[prop]); + } + return rval; + }, + + urlencode: function(str) { + return encodeURIComponent(str.toString()); + }, + + isDefined: function(o) { + return (o != "undefined" && o != null) + }, + + isArray: function(obj) { + return obj instanceof Array; + }, + + isString: function(obj) { + return (typeof obj == 'string'); + }, + + isNumber: function(obj) { + return (typeof obj == 'number'); + }, + + isObject: function(obj) { + return (typeof obj == 'object'); + }, + + isFunction: function(obj) { + return (typeof obj == 'function'); + }, + + isDict: function(o) { + var str_repr = String(o); + return str_repr.indexOf(" Object") != -1; + }, + + exportToGlobalScope: function() { + for(e in AJS) + eval(e + " = AJS." + e); + }, + + log: function(o) { + if(AJS.isMozilla()) + console.log(o); + else { + var div = AJS.DIV({'style': 'color: green'}); + AJS.ACN(AJS.getBody(), AJS.setHTML(div, ''+o)); + } + } + +} + +AJS.Class = function(members) { + var fn = function() { + if(arguments[0] != 'no_init') { + return this.init.apply(this, arguments); + } + } + fn.prototype = members; + AJS.update(fn, AJS.Class.prototype); + return fn; +} +AJS.Class.prototype = { + extend: function(members) { + var parent = new this('no_init'); + for(k in members) { + var prev = parent[k]; + var cur = members[k]; + if (prev && prev != cur && typeof cur == 'function') { + cur = this._parentize(cur, prev); + } + parent[k] = cur; + } + return new AJS.Class(parent); + }, + + implement: function(members) { + AJS.update(this.prototype, members); + }, + + _parentize: function(cur, prev) { + return function(){ + this.parent = prev; + return cur.apply(this, arguments); + } + } +}; + +//Shortcuts +AJS.$ = AJS.getElement; +AJS.$$ = AJS.getElements; +AJS.$f = AJS.getFormElement; +AJS.$b = AJS.bind; +AJS.$p = AJS.partial; +AJS.$FA = AJS.forceArray; +AJS.$A = AJS.createArray; +AJS.DI = AJS.documentInsert; +AJS.ACN = AJS.appendChildNodes; +AJS.RCN = AJS.replaceChildNodes; +AJS.AEV = AJS.addEventListener; +AJS.REV = AJS.removeEventListener; +AJS.$bytc = AJS.getElementsByTagAndClassName; + +AJSDeferred = function(req) { + this.callbacks = []; + this.errbacks = []; + this.req = req; +} +AJSDeferred.prototype = { + excCallbackSeq: function(req, list) { + var data = req.responseText; + while (list.length > 0) { + var fn = list.pop(); + var new_data = fn(data, req); + if(new_data) + data = new_data; + } + }, + + callback: function () { + this.excCallbackSeq(this.req, this.callbacks); + }, + + errback: function() { + if(this.errbacks.length == 0) + alert("Error encountered:\n" + this.req.responseText); + + this.excCallbackSeq(this.req, this.errbacks); + }, + + addErrback: function(fn) { + this.errbacks.unshift(fn); + }, + + addCallback: function(fn) { + this.callbacks.unshift(fn); + }, + + addCallbacks: function(fn1, fn2) { + this.addCallback(fn1); + this.addErrback(fn2); + }, + + sendReq: function(data) { + if(AJS.isObject(data)) { + this.req.send(AJS.queryArguments(data)); + } + else if(AJS.isDefined(data)) + this.req.send(data); + else { + this.req.send(""); + } + } +}; + +//Prevent memory-leaks +AJS.addEventListener(window, 'unload', AJS._unloadListeners); +AJS._createDomShortcuts() +} + +script_loaded = true; --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS_fx.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/AJS_fx.js @@ -0,0 +1,194 @@ +/* +Last Modified: 25/12/06 18:26:30 + +AJS effects + A very small library with a lot of functionality +AUTHOR + 4mir Salihefendic (http://amix.dk) - amix@amix.dk +LICENSE + Copyright (c) 2006 Amir Salihefendic. All rights reserved. + Copyright (c) 2005 Bob Ippolito. All rights reserved. + Copyright (c) 2006 Valerio Proietti, http://www.mad4milk.net + http://www.opensource.org/licenses/mit-license.php +VERSION + 3.6 +SITE + http://orangoo.com/AmiNation/AJS +**/ +AJS.fx = { + _shades: {0: 'ffffff', 1: 'ffffee', 2: 'ffffdd', + 3: 'ffffcc', 4: 'ffffbb', 5: 'ffffaa', + 6: 'ffff99'}, + + highlight: function(elm, options) { + var base = new AJS.fx.Base(); + base.elm = AJS.$(elm); + base.setOptions(options); + base.options.duration = 600; + + AJS.update(base, { + increase: function(){ + if(this.now == 7) + elm.style.backgroundColor = 'transparent'; + else + elm.style.backgroundColor = '#' + AJS.fx._shades[Math.floor(this.now)]; + } + }); + return base.custom(6, 0); + }, + + fadeIn: function(elm, options) { + options = options || {}; + if(!options.from) { + options.from = 0; + AJS.setOpacity(elm, 0); + } + if(!options.to) options.to = 1; + var s = new AJS.fx.Style(elm, 'opacity', options); + return s.custom(options.from, options.to); + }, + + fadeOut: function(elm, options) { + options = options || {}; + if(!options.from) options.from = 1; + if(!options.to) options.to = 0; + options.duration = 300; + var s = new AJS.fx.Style(elm, 'opacity', options); + return s.custom(options.from, options.to); + }, + + setWidth: function(elm, options) { + var s = new AJS.fx.Style(elm, 'width', options); + return s.custom(options.from, options.to); + }, + + setHeight: function(elm, options) { + var s = new AJS.fx.Style(elm, 'height', options); + return s.custom(options.from, options.to); + } +} + + +//From moo.fx +AJS.fx.Base = new AJS.Class({ + init: function() { + AJS.bindMethods(this); + }, + + setOptions: function(options){ + this.options = AJS.update({ + onStart: function(){}, + onComplete: function(){}, + transition: AJS.fx.Transitions.sineInOut, + duration: 500, + wait: true, + fps: 50 + }, options || {}); + }, + + step: function(){ + var time = new Date().getTime(); + if (time < this.time + this.options.duration){ + this.cTime = time - this.time; + this.setNow(); + } else { + setTimeout(AJS.$b(this.options.onComplete, this, [this.elm]), 10); + this.clearTimer(); + this.now = this.to; + } + this.increase(); + }, + + setNow: function(){ + this.now = this.compute(this.from, this.to); + }, + + compute: function(from, to){ + var change = to - from; + return this.options.transition(this.cTime, from, change, this.options.duration); + }, + + clearTimer: function(){ + clearInterval(this.timer); + this.timer = null; + return this; + }, + + _start: function(from, to){ + if (!this.options.wait) this.clearTimer(); + if (this.timer) return; + setTimeout(AJS.$p(this.options.onStart, this.elm), 10); + this.from = from; + this.to = to; + this.time = new Date().getTime(); + this.timer = setInterval(this.step, Math.round(1000/this.options.fps)); + return this; + }, + + custom: function(from, to){ + return this._start(from, to); + }, + + set: function(to){ + this.now = to; + this.increase(); + return this; + }, + + setStyle: function(elm, property, val) { + if(this.property == 'opacity') + AJS.setOpacity(elm, val); + else + AJS.setStyle(elm, property, val); + } +}); + +AJS.fx.Style = AJS.fx.Base.extend({ + init: function(elm, property, options) { + this.parent(); + this.elm = elm; + this.setOptions(options); + this.property = property; + }, + + increase: function(){ + this.setStyle(this.elm, this.property, this.now); + } +}); + +AJS.fx.Styles = AJS.fx.Base.extend({ + init: function(elm, options){ + this.parent(); + this.elm = AJS.$(elm); + this.setOptions(options); + this.now = {}; + }, + + setNow: function(){ + for (p in this.from) + this.now[p] = this.compute(this.from[p], this.to[p]); + }, + + custom: function(obj){ + if (this.timer && this.options.wait) return; + var from = {}; + var to = {}; + for (p in obj){ + from[p] = obj[p][0]; + to[p] = obj[p][1]; + } + return this._start(from, to); + }, + + increase: function(){ + for (var p in this.now) this.setStyle(this.elm, p, this.now[p]); + } +}); + +//Transitions (c) 2003 Robert Penner (http://www.robertpenner.com/easing/), BSD License. +AJS.fx.Transitions = { + linear: function(t, b, c, d) { return c*t/d + b; }, + sineInOut: function(t, b, c, d) { return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; } +}; + +script_loaded = true; --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.css @@ -0,0 +1,32 @@ +/* Last-Modified: 28/06/06 00:08:22 */ +#GB_overlay { + background-color: #000; + position: absolute; + margin: auto; + top: 0; + left: 0; + z-index: 100; +} + +#GB_window { + left: 0; + top: 0; + font-size: 1px; + position: absolute; + overflow: visible; + z-index: 150; +} + +#GB_window .content { + width: auto; + margin: 0; + padding: 0; +} + +#GB_frame { + border: 0; + margin: 0; + padding: 0; + overflow: auto; + white-space: nowrap; +} --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/base.js @@ -0,0 +1,192 @@ +var GB_CURRENT = null; + +GB_hide = function() { + GB_CURRENT.hide(); +} + +GreyBox = new AJS.Class({ + init: function(options) { + this.use_fx = AJS.fx; + this.type = "page"; + this.overlay_click_close = false; + this.salt = 0; + this.root_dir = GB_ROOT_DIR; + this.callback_fns = []; + this.reload_on_close = false; + this.src_loader = this.root_dir + 'loader_frame.html'; + + //Solve the www issue + var h_www = window.location.hostname.indexOf('www'); + var src_www = this.src_loader.indexOf('www'); + if(h_www != -1 && src_www == -1) + this.src_loader = this.src_loader.replace('://', '://www.'); + + if(h_www == -1 && src_www != -1) + this.src_loader = this.src_loader.replace('://www.', '://'); + + this.show_loading = true; + AJS.update(this, options); + }, + + addCallback: function(fn) { + if(fn) this.callback_fns.push(fn); + }, + + show: function(url) { + GB_CURRENT = this; + this.url = url; + + var elms = [AJS.$bytc("object"), AJS.$bytc("select")]; + AJS.map(AJS.flattenList(elms), function(elm) { + elm.style.visibility = "hidden"; + }); + + this.createElements(); + return false; + }, + + hide: function() { + var c_bs = this.callback_fns; + if(c_bs != []) { + AJS.map(c_bs, function(fn) { + fn(); + }); + } + + this.onHide(); + if(this.use_fx) { + var elm = this.overlay; + AJS.fx.fadeOut(this.overlay, { + onComplete: function() { + AJS.removeElement(elm); + elm = null; + }, + duration: 300 + }); + AJS.removeElement(this.g_window); + } + else { + AJS.removeElement(this.g_window, this.overlay); + } + + this.removeFrame(); + + AJS.REV(window, "scroll", _GB_setOverlayDimension); + AJS.REV(window, "resize", _GB_update); + + var elms = [AJS.$bytc("object"), AJS.$bytc("select")]; + AJS.map(AJS.flattenList(elms), function(elm) { + elm.style.visibility = "visible"; + }); + + GB_CURRENT = null; + + if(this.reload_on_close) + window.location.reload(); + }, + + update: function() { + this.setOverlayDimension(); + this.setFrameSize(); + this.setWindowPosition(); + }, + + createElements: function() { + this.initOverlay(); + + this.g_window = AJS.DIV({'id': 'GB_window'}); + AJS.hideElement(this.g_window); + AJS.getBody().insertBefore(this.g_window, this.overlay.nextSibling); + + this.initFrame(); + this.initHook(); + this.update(); + + var me = this; + if(this.use_fx) { + AJS.fx.fadeIn(this.overlay, { + duration: 300, + to: 0.7, + onComplete: function() { + me.onShow(); + AJS.showElement(me.g_window); + me.startLoading(); + } + }); + } + else { + AJS.setOpacity(this.overlay, 0.7); + AJS.showElement(this.g_window); + this.onShow(); + this.startLoading(); + } + + AJS.AEV(window, "scroll", _GB_setOverlayDimension); + AJS.AEV(window, "resize", _GB_update); + }, + + removeFrame: function() { + try{ AJS.removeElement(this.iframe); } + catch(e) {} + + this.iframe = null; + }, + + startLoading: function() { + this.iframe.src = this.src_loader + '?s='+this.salt++; + AJS.showElement(this.iframe); + }, + + setOverlayDimension: function() { + var page_size = AJS.getWindowSize(); + if(AJS.isMozilla() || AJS.isOpera()) + AJS.setWidth(this.overlay, "100%"); + else + AJS.setWidth(this.overlay, page_size.w); + + var max_height = Math.max(AJS.getScrollTop()+page_size.h, AJS.getScrollTop()+this.height); + + if(max_height < AJS.getScrollTop()) + AJS.setHeight(this.overlay, max_height); + else + AJS.setHeight(this.overlay, AJS.getScrollTop()+page_size.h); + }, + + initOverlay: function() { + this.overlay = AJS.DIV({'id': 'GB_overlay'}); + + if(this.overlay_click_close) + AJS.AEV(this.overlay, "click", GB_hide); + + AJS.setOpacity(this.overlay, 0); + AJS.getBody().insertBefore(this.overlay, AJS.getBody().firstChild); + }, + + initFrame: function() { + if(!this.iframe) { + var d = {'name': 'GB_frame', 'class': 'GB_frame', 'frameBorder': 0}; + this.iframe = AJS.IFRAME(d); + this.middle_cnt = AJS.DIV({'class': 'content'}, this.iframe); + + this.top_cnt = AJS.DIV(); + this.bottom_cnt = AJS.DIV(); + + AJS.ACN(this.g_window, this.top_cnt, this.middle_cnt, this.bottom_cnt); + } + }, + + /* Can be implemented */ + onHide: function() {}, + onShow: function() {}, + setFrameSize: function() {}, + setWindowPosition: function() {}, + initHook: function() {} + +}); + +_GB_update = function() { if(GB_CURRENT) GB_CURRENT.update(); } +_GB_setOverlayDimension = function() { if(GB_CURRENT) GB_CURRENT.setOverlayDimension(); } + +AJS.preloadImages(GB_ROOT_DIR+'indicator.gif'); + +script_loaded = true; --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/loader_frame.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/base/loader_frame.html @@ -0,0 +1,104 @@ + + + + + + + + +
+ +
+ + + + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.css @@ -0,0 +1,51 @@ +.GB_Gallery { + margin: 0 22px 0 22px; +} + +.GB_Gallery .content { + background-color: #fff; + border: 3px solid #ddd; +} + +.GB_header { + top: 10px; + left: 0; + margin: 0; + z-index: 500; + position: absolute; + border-bottom: 2px solid #555; + border-top: 2px solid #555; +} + +.GB_header .inner { + background-color: #333; + font-family: Arial, Verdana, sans-serif; + padding: 2px 20px 2px 20px; +} + +.GB_header table { + margin: 0; + width: 100%; + border-collapse: collapse; +} + +.GB_header .caption { + text-align: left; + color: #eee; + white-space: nowrap; + font-size: 20px; +} + +.GB_header .close { + text-align: right; +} + +.GB_header .close img { + z-index: 500; + cursor: pointer; +} + +.GB_header .middle { + white-space: nowrap; + text-align: center; +} --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/gallery/gallery.js @@ -0,0 +1,114 @@ +GB_showImage = function(caption, url, callback_fn) { + var options = { + width: 300, + height: 300, + type: 'image', + + fullscreen: false, + center_win: true, + caption: caption, + callback_fn: callback_fn + } + var win = new GB_Gallery(options); + return win.show(url); +} + +GB_showPage = function(caption, url, callback_fn) { + var options = { + type: 'page', + + caption: caption, + callback_fn: callback_fn, + fullscreen: true, + center_win: false + } + var win = new GB_Gallery(options); + return win.show(url); +} + +GB_Gallery = GreyBox.extend({ + init: function(options) { + this.parent({}); + this.img_close = this.root_dir + 'g_close.gif'; + AJS.update(this, options); + this.addCallback(this.callback_fn); + }, + + initHook: function() { + AJS.addClass(this.g_window, 'GB_Gallery'); + + var inner = AJS.DIV({'class': 'inner'}); + this.header = AJS.DIV({'class': 'GB_header'}, inner); + AJS.setOpacity(this.header, 0); + AJS.getBody().insertBefore(this.header, this.overlay.nextSibling); + + var td_caption = AJS.TD({'id': 'GB_caption', 'class': 'caption', 'width': '40%'}, this.caption); + var td_middle = AJS.TD({'id': 'GB_middle', 'class': 'middle', 'width': '20%'}); + + var img_close = AJS.IMG({'src': this.img_close}); + AJS.AEV(img_close, 'click', GB_hide); + var td_close = AJS.TD({'class': 'close', 'width': '40%'}, img_close); + + var tbody = AJS.TBODY(AJS.TR(td_caption, td_middle, td_close)); + + var table = AJS.TABLE({'cellspacing': '0', 'cellpadding': 0, 'border': 0}, tbody); + AJS.ACN(inner, table); + + if(this.fullscreen) + AJS.AEV(window, 'scroll', AJS.$b(this.setWindowPosition, this)); + else + AJS.AEV(window, 'scroll', AJS.$b(this._setHeaderPos, this)); + }, + + setFrameSize: function() { + var overlay_w = this.overlay.offsetWidth; + var page_size = AJS.getWindowSize(); + + if(this.fullscreen) { + this.width = overlay_w-40; + this.height = page_size.h-80; + } + AJS.setWidth(this.iframe, this.width); + AJS.setHeight(this.iframe, this.height); + + AJS.setWidth(this.header, overlay_w); + }, + + _setHeaderPos: function() { + AJS.setTop(this.header, AJS.getScrollTop()+10); + }, + + setWindowPosition: function() { + var overlay_w = this.overlay.offsetWidth; + var page_size = AJS.getWindowSize(); + AJS.setLeft(this.g_window, ((overlay_w - 50 - this.width)/2)); + + var header_top = AJS.getScrollTop()+55; + if(!this.center_win) { + AJS.setTop(this.g_window, header_top); + } + else { + var fl = ((page_size.h - this.height) /2) + 20 + AJS.getScrollTop(); + if(fl < 0) fl = 0; + if(header_top > fl) { + fl = header_top; + } + AJS.setTop(this.g_window, fl); + } + this._setHeaderPos(); + }, + + onHide: function() { + AJS.removeElement(this.header); + AJS.removeClass(this.g_window, 'GB_Gallery'); + }, + + onShow: function() { + if(this.use_fx) + AJS.fx.fadeIn(this.header, {to: 1}); + else + AJS.setOpacity(this.header, 1); + } +}); + +AJS.preloadImages(GB_ROOT_DIR+'g_close.gif'); --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.css @@ -0,0 +1,20 @@ +#GB_middle { + color: #eee; +} + +#GB_middle img { + cursor: pointer; + vertical-align: middle; +} + +#GB_middle .disabled { + cursor: default; +} + +#GB_middle .left { + padding-right: 10px; +} + +#GB_middle .right { + padding-left: 10px; +} --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/set/set.js @@ -0,0 +1,101 @@ +GB_showFullScreenSet = function(set, start_index, callback_fn) { + var options = { + type: 'page', + fullscreen: true, + center_win: false + } + var gb_sets = new GB_Sets(options, set); + gb_sets.addCallback(callback_fn); + gb_sets.showSet(start_index-1); + return false; +} + +GB_showImageSet = function(set, start_index, callback_fn) { + var options = { + type: 'image', + fullscreen: false, + center_win: true, + width: 300, + height: 300 + } + var gb_sets = new GB_Sets(options, set); + gb_sets.addCallback(callback_fn); + gb_sets.showSet(start_index-1); + return false; +} + +GB_Sets = GB_Gallery.extend({ + init: function(options, set) { + this.parent(options); + if(!this.img_next) this.img_next = this.root_dir + 'next.gif'; + if(!this.img_prev) this.img_prev = this.root_dir + 'prev.gif'; + this.current_set = set; + }, + + showSet: function(start_index) { + this.current_index = start_index; + + var item = this.current_set[this.current_index]; + this.show(item.url); + this._setCaption(item.caption); + + this.btn_prev = AJS.IMG({'class': 'left', src: this.img_prev}); + this.btn_next = AJS.IMG({'class': 'right', src: this.img_next}); + + AJS.AEV(this.btn_prev, 'click', AJS.$b(this.switchPrev, this)); + AJS.AEV(this.btn_next, 'click', AJS.$b(this.switchNext, this)); + + GB_STATUS = AJS.SPAN({'class': 'GB_navStatus'}); + AJS.ACN(AJS.$('GB_middle'), this.btn_prev, GB_STATUS, this.btn_next); + + this.updateStatus(); + }, + + updateStatus: function() { + AJS.setHTML(GB_STATUS, (this.current_index + 1) + ' / ' + this.current_set.length); + if(this.current_index == 0) { + AJS.addClass(this.btn_prev, 'disabled'); + } + else { + AJS.removeClass(this.btn_prev, 'disabled'); + } + + if(this.current_index == this.current_set.length-1) { + AJS.addClass(this.btn_next, 'disabled'); + } + else { + AJS.removeClass(this.btn_next, 'disabled'); + } + }, + + _setCaption: function(caption) { + AJS.setHTML(AJS.$('GB_caption'), caption); + }, + + updateFrame: function() { + var item = this.current_set[this.current_index]; + this._setCaption(item.caption); + this.url = item.url; + this.startLoading(); + }, + + switchPrev: function() { + if(this.current_index != 0) { + this.current_index--; + this.updateFrame(); + this.updateStatus(); + } + }, + + switchNext: function() { + if(this.current_index != this.current_set.length-1) { + this.current_index++ + this.updateFrame(); + this.updateStatus(); + } + } +}); + +AJS.AEV(window, 'load', function() { + AJS.preloadImages(GB_ROOT_DIR+'next.gif', GB_ROOT_DIR+'prev.gif'); +}); --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.css @@ -0,0 +1,39 @@ +.GB_Window .content { + background-color: #fff; + border: 3px solid #ccc; + border-top: none; +} + +.GB_Window .header { + border-bottom: 1px solid #aaa; + border-top: 1px solid #999; + border-left: 3px solid #ccc; + border-right: 3px solid #ccc; + margin: 0; + + height: 22px; + font-size: 12px; + padding: 3px 0; + color: #333; +} + +.GB_Window .caption { + font-size: 12px; + text-align: left; + font-weight: bold; + white-space: nowrap; + padding-right: 20px; +} + +.GB_Window .close { text-align: right; } +.GB_Window .close span { + font-size: 12px; + cursor: pointer; +} +.GB_Window .close img { + cursor: pointer; + padding: 0 3px 0 0; +} + +.GB_Window .on { border-bottom: 1px solid #333; } +.GB_Window .click { border-bottom: 1px solid red; } --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/greybox_source/window/window.js @@ -0,0 +1,109 @@ +GB_show = function(caption, url, /* optional */ height, width, callback_fn) { + var options = { + caption: caption, + height: height || 500, + width: width || 500, + fullscreen: false, + callback_fn: callback_fn + } + var win = new GB_Window(options); + return win.show(url); +} + +GB_showCenter = function(caption, url, /* optional */ height, width, callback_fn) { + var options = { + caption: caption, + center_win: true, + height: height || 500, + width: width || 500, + fullscreen: false, + callback_fn: callback_fn + } + var win = new GB_Window(options); + return win.show(url); +} + +GB_showFullScreen = function(caption, url, callback_fn) { + var options = { + caption: caption, + fullscreen: true, + callback_fn: callback_fn + } + var win = new GB_Window(options); + return win.show(url); +} + +GB_Window = GreyBox.extend({ + init: function(options) { + this.parent({}); + this.img_header = this.root_dir+"header_bg.gif"; + this.img_close = this.root_dir+"w_close.gif"; + this.show_close_img = true; + AJS.update(this, options); + this.addCallback(this.callback_fn); + }, + + initHook: function() { + AJS.addClass(this.g_window, 'GB_Window'); + + this.header = AJS.TABLE({'class': 'header'}); + this.header.style.backgroundImage = "url("+ this.img_header +")"; + + var td_caption = AJS.TD({'class': 'caption'}, this.caption); + var td_close = AJS.TD({'class': 'close'}); + + if(this.show_close_img) { + var img_close = AJS.IMG({'src': this.img_close}); + var span = AJS.SPAN('Close'); + + var btn = AJS.DIV(img_close, span); + + AJS.AEV([img_close, span], 'mouseover', function() { AJS.addClass(span, 'on'); }); + AJS.AEV([img_close, span], 'mouseout', function() { AJS.removeClass(span, 'on'); }); + AJS.AEV([img_close, span], 'mousedown', function() { AJS.addClass(span, 'click'); }); + AJS.AEV([img_close, span], 'mouseup', function() { AJS.removeClass(span, 'click'); }); + AJS.AEV([img_close, span], 'click', GB_hide); + + AJS.ACN(td_close, btn); + } + + tbody_header = AJS.TBODY(); + AJS.ACN(tbody_header, AJS.TR(td_caption, td_close)); + + AJS.ACN(this.header, tbody_header); + AJS.ACN(this.top_cnt, this.header); + + if(this.fullscreen) + AJS.AEV(window, 'scroll', AJS.$b(this.setWindowPosition, this)); + }, + + setFrameSize: function() { + if(this.fullscreen) { + var page_size = AJS.getWindowSize(); + overlay_h = page_size.h; + this.width = Math.round(this.overlay.offsetWidth - (this.overlay.offsetWidth/100)*10); + this.height = Math.round(overlay_h - (overlay_h/100)*10); + } + + AJS.setWidth(this.header, this.width+6); //6 is for the left+right border + AJS.setWidth(this.iframe, this.width); + AJS.setHeight(this.iframe, this.height); + }, + + setWindowPosition: function() { + var page_size = AJS.getWindowSize(); + AJS.setLeft(this.g_window, ((page_size.w - this.width)/2)-13); + + if(!this.center_win) { + AJS.setTop(this.g_window, AJS.getScrollTop()); + } + else { + var fl = ((page_size.h - this.height) /2) - 20 + AJS.getScrollTop(); + if(fl < 0) + fl = 0; + AJS.setTop(this.g_window, fl); + } + } +}); + +AJS.preloadImages(GB_ROOT_DIR+'w_close.gif', GB_ROOT_DIR+'header_bg.gif'); --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/installation.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/installation.html @@ -0,0 +1,49 @@ + + + + GreyBox - Installation + + + + + + + + + + +
    +
  1. +Append following to your header section (in between <header>...</header>). +
    +GB_ROOT_DIR is the URL where static files are located: +
    +<script type="text/javascript">
    +    var GB_ROOT_DIR = "http://mydomain.com/greybox/";
    +</script>
    +
    +
  2. +GB_ROOT_DIR should be absolute. + +
  3. +Append also following scripts and one stylesheet: +
    +<script type="text/javascript" src="greybox/AJS.js"></script>
    +<script type="text/javascript" src="greybox/AJS_fx.js"></script>
    +<script type="text/javascript" src="greybox/gb_scripts.js"></script>
    +<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" />
    +
    + +AJS_fx.js is optional, it's used for effects. If you don't wish effects, then don't include AJS_fx.js in your header section. +
  4. + +
  5. +That's it, you are now ready to use GreyBox! +
  6. +
+ + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/normal_usage.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/normal_usage.html @@ -0,0 +1,126 @@ + + + + GreyBox - Normal usage + + + + + + + + + + + + + + + + +

Showing images

+ +

Showing one image:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_image[]">HTML</a>
+
+ +

Example:

+
+<a href="http://static.flickr.com/119/294309231_a3d2a339b9.jpg" title="Flower" rel="gb_image[]">Show flower</a>
+
+ +

Example rendered:

+Show flower + + +

Showing a group of images:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_imageset[NAME]">HTML</a>
+<a href="URL" title="CAPTION" rel="gb_imageset[NAME]">HTML</a>
+
+ +

Example:

+
+<a href="static_files/salt.jpg" rel="gb_imageset[nice_pics]" title="Salt flats in Chile">Salt flats</a>
+<a href="static_files/night_valley.jpg" rel="gb_imageset[nice_pics]" title="Night valley">Night valley</a>
+
+ +

Example rendered:

+Salt flats +Night valley + + +

Showing pages

+ +

Showing one page:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_page[WIDTH, HEIGHT]">HTML</a>
+
+ +

Example:

+
+<a href="http://google.com/" title="Google" rel="gb_page[500, 500]">Launch Google.com</a>
+
+ +

Example rendered:

+Launch Google.com + + +

Showing one page as center window:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_page_center[WIDTH, HEIGHT]">HTML</a>
+
+ +

Example:

+
+<a href="http://google.com/" title="Google" rel="gb_page_center[500, 500]">Launch Google.com</a>
+
+ +

Example rendered:

+Launch Google.com + + +

Showing one page in fullscreen:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_page_fs[]">HTML</a>
+
+ +

Example:

+
+<a href="http://google.com/" title="Google" rel="gb_page_fs[]">Launch Google.com</a>
+
+ +

Example rendered:

+Launch Google.com + +

Showing a group of pages:

+

Syntax:

+
+<a href="URL" title="CAPTION" rel="gb_pageset[NAME]">HTML</a>
+<a href="URL" title="CAPTION" rel="gb_pageset[NAME]">HTML</a>
+
+ +

Example:

+
+<a href="http://google.com/" title="Google" rel="gb_pageset[search_sites]">Launch Google search</a>
+<a href="http://search.yahoo.com/" rel="gb_pageset[search_sites]">Launch Yahoo search</a>
+
+ +

Example rendered:

+Launch Google search +Launch Yahoo search + + + + --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.css @@ -0,0 +1,93 @@ +body { + font-family: helvetica, verdana, sans-serif; + font-size: 12px; + background-color: #fff; + padding: 10px 35px 35px 35px; + width: 800px; + margin: auto; +} + +#top { + text-align: center; +} + +h2 { + font-size: 18px; + color: #333; + margin: 35px 0 10px 0; +} + +h3 { + color: #333; + border-bottom: 1px solid #999; + font-size: 15px; + margin: 30px 0 3px 0; +} + +.first { + margin-top: 20px; +} + +h4 { + color: black; + font-size: 13px; + margin: 10px 0 5px 0; +} + +pre { + font-size: 11px; + margin-top: 5px; + padding: 4px; + background-color: #e3e2c6; + border: 1px solid #999; +} + +.hl { + background-color: #ffffcc; +} + +ol { + margin: 0; + padding: 0 0px 0 20px; +} + +li { + padding: 5px 0 5px 0; +} + +img { + border: 0; +} + +/* + * Menu + */ +#menu { + border-bottom: 1px solid #999; + margin: 20px 0px; + padding: 10px 0pt 5px; + text-align: center; +} + +#menu li { + display: inline; + margin: 0px; + padding: 0px; +} + +#menu a { + background: #ddd none repeat; + border: 1px solid #999; + margin: 0 5px 0 5px; + padding: 5px; +} + +#menu a.current { + background: #fff none repeat; + border-bottom: 1px solid #fff; +} + +#menu a { + color: black; + text-decoration: none; +} --- a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/GreyBox_v5_5/static_files/help.js @@ -0,0 +1,52 @@ +var tmpl_header = AJS.join('', [ + '

', + 'A pop-up window that doesn\'t suck.', + '
' +]); + +function insertHeader() { + AJS.DI(tmpl_header); +} + +var LINKS = { + 'installation': 'installation.html', + 'examples': 'examples.html', + 'nrm_usage': 'normal_usage.html', + 'adv_usage': 'advance_usage.html', + 'cmpr': 'compressing_greybox.html', + 'about': 'about.html' +} + +function insertMenu(current_page) { + var menu = AJS.UL({id: 'menu'}); + var create_item = function(cls, name) { + var item = AJS.LI({'class': cls}); + AJS.ACN(item, AJS.A({href: LINKS[cls]}, name)); + return item; + } + var items = [ + create_item('installation', 'Installation'), + create_item('examples', 'Examples'), + create_item('nrm_usage', 'Normal usage'), + create_item('adv_usage', 'Advance usage'), + create_item('cmpr', 'Compressing GreyBox'), + create_item('about', 'About') + ]; + + AJS.map(items, function(item) { + if(item.className == current_page) { + AJS.addClass(AJS.$bytc('a', null, item)[0], 'current'); + } + AJS.ACN(menu, item); + }); + AJS.DI(menu); +} + +function insertCode() { + var code = AJS.join('\n', arguments); + var result = '
';
+    code = code.replace(//g, '>');
+    result += code;
+    result += '
'; + document.write(result); +} --- a/koha-tmpl/opac-tmpl/lib/greybox/gb_scripts.js +++ a/koha-tmpl/opac-tmpl/lib/greybox/gb_scripts.js @@ -0,0 +1,436 @@ +var GB_CURRENT=null; +GB_hide=function(){ +GB_CURRENT.hide(); +}; +GreyBox=new AJS.Class({init:function(_1){ +this.use_fx=AJS.fx; +this.type="page"; +this.overlay_click_close=false; +this.salt=0; +this.root_dir=GB_ROOT_DIR; +this.callback_fns=[]; +this.reload_on_close=false; +this.src_loader=this.root_dir+"loader_frame.html"; +var _2=window.location.hostname.indexOf("www"); +var _3=this.src_loader.indexOf("www"); +if(_2!=-1&&_3==-1){ +this.src_loader=this.src_loader.replace("://","://www."); +} +if(_2==-1&&_3!=-1){ +this.src_loader=this.src_loader.replace("://www.","://"); +} +this.show_loading=true; +AJS.update(this,_1); +},addCallback:function(fn){ +if(fn){ +this.callback_fns.push(fn); +} +},show:function(_5){ +GB_CURRENT=this; +this.url=_5; +var _6=[AJS.$bytc("object"),AJS.$bytc("select")]; +AJS.map(AJS.flattenList(_6),function(_7){ +_7.style.visibility="hidden"; +}); +this.createElements(); +return false; +},hide:function(){ +var _8=this.callback_fns; +if(_8!=[]){ +AJS.map(_8,function(fn){ +fn(); +}); +} +this.onHide(); +if(this.use_fx){ +var _a=this.overlay; +AJS.fx.fadeOut(this.overlay,{onComplete:function(){ +AJS.removeElement(_a); +_a=null; +},duration:300}); +AJS.removeElement(this.g_window); +}else{ +AJS.removeElement(this.g_window,this.overlay); +} +this.removeFrame(); +AJS.REV(window,"scroll",_GB_setOverlayDimension); +AJS.REV(window,"resize",_GB_update); +var _b=[AJS.$bytc("object"),AJS.$bytc("select")]; +AJS.map(AJS.flattenList(_b),function(_c){ +_c.style.visibility="visible"; +}); +GB_CURRENT=null; +if(this.reload_on_close){ +window.location.reload(); +} +},update:function(){ +this.setOverlayDimension(); +this.setFrameSize(); +this.setWindowPosition(); +},createElements:function(){ +this.initOverlay(); +this.g_window=AJS.DIV({"id":"GB_window"}); +AJS.hideElement(this.g_window); +AJS.getBody().insertBefore(this.g_window,this.overlay.nextSibling); +this.initFrame(); +this.initHook(); +this.update(); +var me=this; +if(this.use_fx){ +AJS.fx.fadeIn(this.overlay,{duration:300,to:0.7,onComplete:function(){ +me.onShow(); +AJS.showElement(me.g_window); +me.startLoading(); +}}); +}else{ +AJS.setOpacity(this.overlay,0.7); +AJS.showElement(this.g_window); +this.onShow(); +this.startLoading(); +} +AJS.AEV(window,"scroll",_GB_setOverlayDimension); +AJS.AEV(window,"resize",_GB_update); +},removeFrame:function(){ +try{ +AJS.removeElement(this.iframe); +} +catch(e){ +} +this.iframe=null; +},startLoading:function(){ +this.iframe.src=this.src_loader+"?s="+this.salt++; +AJS.showElement(this.iframe); +},setOverlayDimension:function(){ +var _e=AJS.getWindowSize(); +if(AJS.isMozilla()||AJS.isOpera()){ +AJS.setWidth(this.overlay,"100%"); +}else{ +AJS.setWidth(this.overlay,_e.w); +} +var _f=Math.max(AJS.getScrollTop()+_e.h,AJS.getScrollTop()+this.height); +if(_ffl){ +fl=_30; +} +AJS.setTop(this.g_window,fl); +} +this._setHeaderPos(); +},onHide:function(){ +AJS.removeElement(this.header); +AJS.removeClass(this.g_window,"GB_Gallery"); +},onShow:function(){ +if(this.use_fx){ +AJS.fx.fadeIn(this.header,{to:1}); +}else{ +AJS.setOpacity(this.header,1); +} +}}); +AJS.preloadImages(GB_ROOT_DIR+"g_close.gif"); +GB_showFullScreenSet=function(set,_33,_34){ +var _35={type:"page",fullscreen:true,center_win:false}; +var _36=new GB_Sets(_35,set); +_36.addCallback(_34); +_36.showSet(_33-1); +return false; +}; +GB_showImageSet=function(set,_38,_39){ +var _3a={type:"image",fullscreen:false,center_win:true,width:300,height:300}; +var _3b=new GB_Sets(_3a,set); +_3b.addCallback(_39); +_3b.showSet(_38-1); +return false; +}; +GB_Sets=GB_Gallery.extend({init:function(_3c,set){ +this.parent(_3c); +if(!this.img_next){ +this.img_next=this.root_dir+"next.gif"; +} +if(!this.img_prev){ +this.img_prev=this.root_dir+"prev.gif"; +} +this.current_set=set; +},showSet:function(_3e){ +this.current_index=_3e; +var _3f=this.current_set[this.current_index]; +this.show(_3f.url); +this._setCaption(_3f.caption); +this.btn_prev=AJS.IMG({"class":"left",src:this.img_prev}); +this.btn_next=AJS.IMG({"class":"right",src:this.img_next}); +AJS.AEV(this.btn_prev,"click",AJS.$b(this.switchPrev,this)); +AJS.AEV(this.btn_next,"click",AJS.$b(this.switchNext,this)); +GB_STATUS=AJS.SPAN({"class":"GB_navStatus"}); +AJS.ACN(AJS.$("GB_middle"),this.btn_prev,GB_STATUS,this.btn_next); +this.updateStatus(); +},updateStatus:function(){ +AJS.setHTML(GB_STATUS,(this.current_index+1)+" / "+this.current_set.length); +if(this.current_index==0){ +AJS.addClass(this.btn_prev,"disabled"); +}else{ +AJS.removeClass(this.btn_prev,"disabled"); +} +if(this.current_index==this.current_set.length-1){ +AJS.addClass(this.btn_next,"disabled"); +}else{ +AJS.removeClass(this.btn_next,"disabled"); +} +},_setCaption:function(_40){ +AJS.setHTML(AJS.$("GB_caption"),_40); +},updateFrame:function(){ +var _41=this.current_set[this.current_index]; +this._setCaption(_41.caption); +this.url=_41.url; +this.startLoading(); +},switchPrev:function(){ +if(this.current_index!=0){ +this.current_index--; +this.updateFrame(); +this.updateStatus(); +} +},switchNext:function(){ +if(this.current_index!=this.current_set.length-1){ +this.current_index++; +this.updateFrame(); +this.updateStatus(); +} +}}); +AJS.AEV(window,"load",function(){ +AJS.preloadImages(GB_ROOT_DIR+"next.gif",GB_ROOT_DIR+"prev.gif"); +}); +GB_show=function(_42,url,_44,_45,_46){ +var _47={caption:_42,height:_44||500,width:_45||500,fullscreen:false,callback_fn:_46}; +var win=new GB_Window(_47); +return win.show(url); +}; +GB_showCenter=function(_49,url,_4b,_4c,_4d){ +var _4e={caption:_49,center_win:true,height:_4b||500,width:_4c||500,fullscreen:false,callback_fn:_4d}; +var win=new GB_Window(_4e); +return win.show(url); +}; +GB_showFullScreen=function(_50,url,_52){ +var _53={caption:_50,fullscreen:true,callback_fn:_52}; +var win=new GB_Window(_53); +return win.show(url); +}; +GB_Window=GreyBox.extend({init:function(_55){ +this.parent({}); +this.img_header=this.root_dir+"header_bg.gif"; +this.img_close=this.root_dir+"w_close.gif"; +this.show_close_img=true; +AJS.update(this,_55); +this.addCallback(this.callback_fn); +},initHook:function(){ +AJS.addClass(this.g_window,"GB_Window"); +this.header=AJS.TABLE({"class":"header"}); +this.header.style.backgroundImage="url("+this.img_header+")"; +var _56=AJS.TD({"class":"caption"},this.caption); +var _57=AJS.TD({"class":"close"}); +if(this.show_close_img){ +var _58=AJS.IMG({"src":this.img_close}); +var _59=AJS.SPAN("Close"); +var btn=AJS.DIV(_58,_59); +AJS.AEV([_58,_59],"mouseover",function(){ +AJS.addClass(_59,"on"); +}); +AJS.AEV([_58,_59],"mouseout",function(){ +AJS.removeClass(_59,"on"); +}); +AJS.AEV([_58,_59],"mousedown",function(){ +AJS.addClass(_59,"click"); +}); +AJS.AEV([_58,_59],"mouseup",function(){ +AJS.removeClass(_59,"click"); +}); +AJS.AEV([_58,_59],"click",GB_hide); +AJS.ACN(_57,btn); +} +tbody_header=AJS.TBODY(); +AJS.ACN(tbody_header,AJS.TR(_56,_57)); +AJS.ACN(this.header,tbody_header); +AJS.ACN(this.top_cnt,this.header); +if(this.fullscreen){ +AJS.AEV(window,"scroll",AJS.$b(this.setWindowPosition,this)); +} +},setFrameSize:function(){ +if(this.fullscreen){ +var _5b=AJS.getWindowSize(); +overlay_h=_5b.h; +this.width=Math.round(this.overlay.offsetWidth-(this.overlay.offsetWidth/100)*10); +this.height=Math.round(overlay_h-(overlay_h/100)*10); +} +AJS.setWidth(this.header,this.width+6); +AJS.setWidth(this.iframe,this.width); +AJS.setHeight(this.iframe,this.height); +},setWindowPosition:function(){ +var _5c=AJS.getWindowSize(); +AJS.setLeft(this.g_window,((_5c.w-this.width)/2)-13); +if(!this.center_win){ +AJS.setTop(this.g_window,AJS.getScrollTop()); +}else{ +var fl=((_5c.h-this.height)/2)-20+AJS.getScrollTop(); +if(fl<0){ +fl=0; +} +AJS.setTop(this.g_window,fl); +} +}}); +AJS.preloadImages(GB_ROOT_DIR+"w_close.gif",GB_ROOT_DIR+"header_bg.gif"); + + +script_loaded=true; --- a/koha-tmpl/opac-tmpl/lib/greybox/gb_styles.css +++ a/koha-tmpl/opac-tmpl/lib/greybox/gb_styles.css @@ -0,0 +1,158 @@ +/* Last-Modified: 28/06/06 00:08:22 */ +#GB_overlay { + background-color: #000; + position: absolute; + margin: auto; + top: 0; + left: 0; + z-index: 100; +} + +#GB_window { + left: 0; + top: 0; + font-size: 1px; + position: absolute; + overflow: visible; + z-index: 150; +} + +#GB_window .content { + width: auto; + margin: 0; + padding: 0; +} + +#GB_frame { + border: 0; + margin: 0; + padding: 0; + overflow: auto; + white-space: nowrap; +} + + +.GB_Gallery { + margin: 0 22px 0 22px; +} + +.GB_Gallery .content { + background-color: #fff; + border: 3px solid #ddd; +} + +.GB_header { + top: 10px; + left: 0; + margin: 0; + z-index: 500; + position: absolute; + border-bottom: 2px solid #555; + border-top: 2px solid #555; +} + +.GB_header .inner { + background-color: #333; + font-family: Arial, Verdana, sans-serif; + padding: 2px 20px 2px 20px; +} + +.GB_header table { + margin: 0; + width: 100%; + border-collapse: separate; + border-right: 0px; + border-top: 0px; +} + +.GB_header td { + background-color: #333333; + border-bottom: 0px; + border-left: 0px; + padding: 0em 0em; +} + +.GB_header .caption { + text-align: left; + color: #eee; + white-space: nowrap; + font-size: 20px; + border-collapse: separate; +} + +.GB_header .close { + text-align: right; +} + +.GB_header .close img { + z-index: 500; + cursor: pointer; +} + +.GB_header .middle { + white-space: nowrap; + text-align: center; +} + + +#GB_middle { + color: #eee; +} + +#GB_middle img { + cursor: pointer; + vertical-align: middle; +} + +#GB_middle .disabled { + cursor: default; +} + +#GB_middle .left { + padding-right: 10px; +} + +#GB_middle .right { + padding-left: 10px; +} + + +.GB_Window .content { + background-color: #fff; + border: 3px solid #ccc; + border-top: none; +} + +.GB_Window .header { + border-bottom: 1px solid #aaa; + border-top: 1px solid #999; + border-left: 3px solid #ccc; + border-right: 3px solid #ccc; + margin: 0; + + height: 22px; + font-size: 12px; + padding: 3px 0; + color: #333; +} + +.GB_Window .caption { + font-size: 12px; + text-align: left; + font-weight: bold; + white-space: nowrap; + padding-right: 20px; +} + +.GB_Window .close { text-align: right; } +.GB_Window .close span { + font-size: 12px; + cursor: pointer; +} +.GB_Window .close img { + cursor: pointer; + padding: 0 3px 0 0; +} + +.GB_Window .on { border-bottom: 1px solid #333; } +.GB_Window .click { border-bottom: 1px solid red; } --- a/koha-tmpl/opac-tmpl/lib/greybox/loader_frame.html +++ a/koha-tmpl/opac-tmpl/lib/greybox/loader_frame.html @@ -0,0 +1,104 @@ + + + + + + + + +
+ +
+ + + + + +