reports: Fix id of custom date selector
[ninja.git] / application / media / js / jquery.easywidgets.min.js
blob0e21106c6b9284b5df187797935f1b78fe1c5fb2
1 /**\r
2  * Easy Widgets 2.0 for jQuery and jQuery UI\r
3  * David Esperalta <http://www.davidesperalta.com/>\r
4  */\r
5 (function(h){h.fn.EasyWidgets=function(u){l(u,false);return true};h.fn.AddEasyWidget=function(v,u,y){var x=true;var z=h(v);var w=h.extend(true,h.fn.EasyWidgets.defaults,y);if(h.isFunction(w.callbacks.onAddQuery)){x=w.callbacks.onAddQuery(z,u)}if(x){h("#"+u).append(v);l(w,true);if(h.isFunction(w.callbacks.onAdd)){w.callbacks.onAdd(z,u)};return true}else{return false}};h.fn.DisableEasyWidgets=function(v){var w=true;var u=h.extend(true,h.fn.EasyWidgets.defaults,v);if(h.isFunction(u.callbacks.onDisableQuery)){w=u.callbacks.onDisableQuery()}if(w){h(u.selectors.places).sortable("disable");h(u.selectors.widget).each(function(){var x=h(this);if(x.hasClass(u.options.movable)){x.find(u.selectors.header).css("cursor","default")}});if(h.isFunction(u.callbacks.onDisable)){u.callbacks.onDisable()}g(u.cookies.disableName,1,u);return true}else{return false}};h.fn.EnableEasyWidgets=function(v){var w=true;var u=h.extend(true,h.fn.EasyWidgets.defaults,v);if(h.isFunction(u.callbacks.onEnableQuery)){w=u.callbacks.onEnableQuery()}if(w){h(u.selectors.places).sortable("enable");h(u.selectors.widget).each(function(){var x=h(this);if(x.hasClass(u.options.movable)){x.find(u.selectors.header).css("cursor","move")}});if(h.isFunction(u.callbacks.onEnable)){u.callbacks.onEnable()}if(u.behaviour.useCookies){g(u.cookies.disableName,0,u)}return true}else{return false}};h.fn.HideEasyWidgets=function(v){var u=h.extend(true,h.fn.EasyWidgets.defaults,v);h(u.selectors.widget+":visible").each(function(){var y=true;var x=h(this);var w=x.attr("id");if(h.isFunction(u.callbacks.onHideQuery)){y=u.callbacks.onHideQuery(x)}if(y){q(x,u.effects.widgetHide,u.effects.effectDuration,false);if(u.behaviour.useCookies&&w){t(w,u.cookies.closeName,u)}if(h.isFunction(u.callbacks.onHide)){u.callbacks.onHide(x)}}});return true};h.fn.ShowEasyWidgets=function(v){var u=h.extend(true,h.fn.EasyWidgets.defaults,v);h(u.selectors.widget+":hidden").each(function(){var y=true;var x=h(this);var w=x.attr("id");var z=(h.trim(w)!="");if(h.isFunction(u.callbacks.onShowQuery)){y=u.callbacks.onShowQuery(x)}if(y){q(x,u.effects.widgetShow,u.effects.effectDuration,true);if(z&&u.behaviour.useCookies){f(w,u.cookies.closeName,u)}if(h.isFunction(u.callbacks.onShow)){u.callbacks.onShow(x)}}});return true};h.fn.ShowEasyWidget=function(w,v){var y=true;var x=h("#"+w);if(x.css("display")=="none"){var u=h.extend(true,h.fn.EasyWidgets.defaults,v);if(h.isFunction(u.callbacks.onShowQuery)){y=u.callbacks.onShowQuery(x)}if(y){q(x,u.effects.widgetShow,u.effects.effectDuration,true);if(u.behaviour.useCookies){f(w,u.cookies.closeName,u)}if(h.isFunction(u.callbacks.onShow)){u.callbacks.onShow(x)}return true}else{return false}}else{return false}};h.fn.HideEasyWidget=function(w,v){var y=true;var x=h("#"+w);if(x.css("display")!="none"){var u=h.extend(true,h.fn.EasyWidgets.defaults,v);if(h.isFunction(u.callbacks.onHideQuery)){y=u.callbacks.onHideQuery(x)}if(y){q(x,u.effects.widgetHide,u.effects.effectDuration,false);if(u.behaviour.useCookies){t(w,u.cookies.closeName,u)}if(h.isFunction(u.callbacks.onHide)){u.callbacks.onHide(x)}return true}else{return false}}else{return false}};h.fn.EasyWidgets.defaults={behaviour:{dragDelay:100,dragRevert:100,dragOpacity:0.8,useCookies:false},effects:{effectDuration:500,widgetShow:"none",widgetHide:"none",widgetClose:"none",widgetExtend:"none",widgetCollapse:"none",widgetOpenEdit:"none",widgetCloseEdit:"none",widgetCancelEdit:"none"},cookies:{path:"",domain:"",expires:90,secure:false,closeName:"ew-close",disableName:"ew-disable",positionName:"ew-position",collapseName:"ew-collapse"},options:{movable:"movable",editable:"editable",collapse:"collapse",removable:"removable",collapsable:"collapsable",closeConfirm:"closeconfirm"},callbacks:{onAdd:null,onEdit:null,onShow:null,onHide:null,onClose:null,onEnable:null,onExtend:null,onDisable:null,onDragStop:null,onCollapse:null,onAddQuery:null,onEditQuery:null,onShowQuery:null,onHideQuery:null,onCloseQuery:null,onCancelEdit:null,onEnableQuery:null,onExtendQuery:null,onDisableQuery:null,onCollapseQuery:null,onCancelEditQuery:null,onChangePositions:null,onRefreshPositions:null},selectors:{container:"div",widget:".widget",places:".widget-place",header:".widget-header",widgetMenu:".widget-menu",editbox:".widget-editbox",content:".widget-content",closeEdit:".widget-close-editbox",editLink:".widget-editlink",closeLink:".widget-closelink",placeHolder:"widget-placeholder",collapseLink:".widget-collapselink"},i18n:{editText:"Edit",closeText:"Close",extendText:"Extend",collapseText:"Collapse",cancelEditText:"Cancel",editTitle:"Edit this widget",closeTitle:"Close this widget",confirmMsg:"Remove this widget?",cancelEditTitle:"Cancel edition",extendTitle:"Extend this widget",collapseTitle:"Collapse this widget"}};function l(x,w){var u=w;var y=h.fn.EasyWidgets.defaults;var v=h.extend(true,y,x);h(v.selectors.widget).each(function(){r(h(this),u,v)});n(v);d(v);o(v,u);return true}function r(y,w,x){var C=x;var A=y.find(C.selectors.widgetMenu);if(A.html()==null){var z=y.attr("id");var B=(h.trim(z)!="");y.find(C.selectors.editbox).hide();if(w&&B&&C.behaviour.useCookies){f(z,C.cookies.closeName,C)}if(!w&&B&&C.behaviour.useCookies&&s(C.cookies.closeName)!=null){var u=s(C.cookies.closeName);if(u.indexOf(z)!=-1){y.hide()}}var v='<span class="'+C.selectors.widgetMenu.replace(/\./,"")+'"></span>';y.find(C.selectors.header).append(v);A=y.find(C.selectors.widgetMenu);c(y,A,C);a(y,A,C);k(y,A,C);return true}else{return false}}function n(w){var F=w;var B="";if(h.isFunction(F.callbacks.onRefreshPositions)){B=F.callbacks.onRefreshPositions()}if((h.trim(B)=="")&&F.behaviour.useCookies&&s(F.cookies.positionName)!=null){B=s(F.cookies.positionName)}if(h.trim(B)!=""){var u=B.split("|");var E=u.length;for(var A=0;A<E;A++){var x=u[A].split("=");if(x.length==2){var z="#"+x[0];var D=x[1].split(",");var v=D.length;for(var y=0;y<v;y++){if(h.trim(D[y])!=""){var C="#"+D[y];h(C).appendTo(z)}}}}}return true}function d(u){var v=m(u);e(v,u);b(v,u);return true}function m(w){var x="";var v=w;h(v.selectors.widget).each(function(y){if(!h(this).hasClass(v.options.movable)){if(!this.id){this.id="fixed-widget-id-"+y}if(x==""){x+="#"+this.id}else{x+=",#"+this.id}}});var u="";if(h.trim(x)==""){u="> "+v.selectors.container}else{u="> "+v.selectors.container+":not("+x+")"}return h(u,v.selectors.places)}function e(u,w){var v=w;u.find(v.selectors.header).css({cursor:"move"}).mousedown(function(y){var z=h(this);var x=z.parent();u.css({width:""})}).mouseup(function(){var y=h(this);var x=y.parent();if(!x.hasClass("dragging")){x.css({width:""})}else{h(v.selectors.places).sortable("disable")}});return true}function b(u,w){var v=w;h(v.selectors.places).sortable("destroy");h(v.selectors.places).sortable({items:u,containment:"document",forcePlaceholderSize:true,handle:v.selectors.header,delay:v.behaviour.dragDelay,revert:v.behaviour.dragRevert,opacity:v.behaviour.dragOpacity,connectWith:h(v.selectors.places),placeholder:v.selectors.placeHolder,start:function(y,x){h(x.helper).addClass("dragging");return true},stop:function(y,x){i(v);h(x.item).css({width:""});h(x.item).removeClass("dragging");h(v.selectors.places).sortable("enable");if(h.isFunction(v.callbacks.onDragStop)){v.callbacks.onDragStop(y,x)}return true}});if(v.behaviour.useCookies&&(s(v.cookies.disableName)==1)){h.fn.DisableEasyWidgets(v)}return true}function i(w){var v=w;var u="";h(v.selectors.places).each(function(){var z="";var x=h(this);var y=x.attr("id")+"=";x.children(v.selectors.widget).each(function(){var B=this;var A=B.id;var C=(h.trim(A)!="");if(C){if(z==""){z+=A}else{z+=","+A}}});y+=z;if(u==""){u+=y}else{u+="|"+y}});if(h.isFunction(v.callbacks.onChangePositions)){v.callbacks.onChangePositions(u)}if(v.behaviour.useCookies){if(s(v.cookies.positionName)!=u){g(v.cookies.positionName,u,v)}}return true}function c(w,y,v){var C=v;var A="";var x=w.attr("id");var B=h.trim(x)!="";var z=w.find(C.selectors.content);if(w.hasClass(C.options.collapsable)){if(w.hasClass(C.options.collapse)){A=p(C.i18n.extendText,C.i18n.extendTitle,C.selectors.collapseLink);z.hide()}else{A=p(C.i18n.collapseText,C.i18n.collapseTitle,C.selectors.collapseLink)}if(B&&C.behaviour.useCookies&&s(C.cookies.collapseName)!=null){var u=s(C.cookies.collapseName);if(u.indexOf(x)!=-1){A=p(C.i18n.extendText,C.i18n.extendTitle,C.selectors.collapseLink);z.hide()}}h(A).mousedown(function(D){D.stopPropagation()}).click(function(){var F=true;var E=true;var I=h(this);var J=I.parents(C.selectors.widget);var H=J.attr("id");var K=h.trim(H)!="";var G=J.find(C.selectors.content);var D=G.css("display")!="none";I.blur();if(D){if(h.isFunction(C.callbacks.onCollapseQuery)){E=C.callbacks.onCollapseQuery(I,J)}if(E){q(G,C.effects.widgetCollapse,C.effects.effectDuration,false);I.html(C.i18n.extendText);I.attr("title",C.i18n.extendTitle);if(C.behaviour.useCookies&&H){t(H,C.cookies.collapseName,C)}if(h.isFunction(C.callbacks.onCollapse)){C.callbacks.onCollapse(I,J)}}}else{if(h.isFunction(C.callbacks.onExtendQuery)){F=C.callbacks.onExtendQuery(I,J)}if(F){I.html(C.i18n.collapseText);I.attr("title",C.i18n.collapseTitle);q(G,C.effects.widgetExtend,C.effects.effectDuration,true);if(K&&C.behaviour.useCookies){f(H,C.cookies.collapseName,C)}if(h.isFunction(C.callbacks.onExtend)){C.callbacks.onExtend(I,J)}}}return false}).appendTo(y)}return true}function a(y,u,w){var v=w;var x="";if(y.hasClass(v.options.editable)){x=p(v.i18n.editText,v.i18n.editTitle,v.selectors.editLink);y.find(v.selectors.closeEdit).click(function(D){var B=h(this);var C=B.parents(v.selectors.widget);var z=C.find(v.selectors.editbox);var A=C.find(v.selectors.editLink);B.blur();q(z,v.effects.widgetCloseEdit,v.effects.effectDuration,false);A.html(v.i18n.editText);A.attr("title",v.i18n.editTitle);return false});h(x).mousedown(function(z){z.stopPropagation()}).click(function(){var B=h(this);var D=canHide=true;var C=B.parents(v.selectors.widget);var A=C.find(v.selectors.editbox);var z=A.css("display")!="none";B.blur();if(z){if(h.isFunction(v.callbacks.onCancelEditQuery)){canHide=v.callbacks.onCancelEditQuery(B,C)}if(canHide){q(A,v.effects.widgetCancelEdit,v.effects.effectDuration,false);B.html(v.i18n.editText);B.attr("title",v.i18n.editTitle);if(h.isFunction(v.callbacks.onCancelEdit)){v.callbacks.onCancelEdit(B,C)}}}else{if(h.isFunction(v.callbacks.onEditQuery)){D=v.callbacks.onEditQuery(B,C)}if(D){B.html(v.i18n.cancelEditText);B.attr("title",v.i18n.cancelEditTitle);q(A,v.effects.widgetOpenEdit,v.effects.effectDuration,true);if(h.isFunction(v.callbacks.onEdit)){v.callbacks.onEdit(B,C)}}}return false}).appendTo(u)}return true}function k(y,u,w){var v=w;var x="";if(y.hasClass(v.options.removable)){x=p(v.i18n.closeText,v.i18n.closeTitle,v.selectors.closeLink);h(x).mousedown(function(z){z.stopPropagation()}).click(function(){var B=h(this);var A=true;var C=B.parents(v.selectors.widget);var z=C.attr("id");var D=(h.trim(z)!="");B.blur();if(h.isFunction(v.callbacks.onCloseQuery)){A=v.callbacks.onCloseQuery(B,C)}if(A){if(!C.hasClass(v.options.closeConfirm)||confirm(v.i18n.confirmMsg)){if(D&&v.behaviour.useCookies){t(z,v.cookies.closeName,v)}q(C,v.effects.widgetClose,v.effects.effectDuration,false);if(h.isFunction(v.callbacks.onClose)){v.callbacks.onClose(B,C)}}}return false}).appendTo(u)}return true}function o(y,x){var F=y;var C=!x&&F.behaviour.useCookies&&(Math.ceil(Math.random()*3)==1);if(C){var z=j=0;var D=new Array(F.cookies.closeName,F.cookies.collapseName);var E=D.length;var u=new Array();h(F.selectors.widget).each(function(H){var G=h(this).attr("id");if(h.trim(G)!=""){u[H]=G}});for(z=0;z<E;z++){if(s(D[z])){var A="";var w="";var v=s(D[z]).split(",");var B=v.length;for(j=0;j<B;j++){A=h.trim(v[j]);if(h.inArray(A,u)!=-1){if(h.trim(w)==""){w+=A}else{w+=","+A}}}g(D[z],w,F)}}}return true}function s(w){var u=null;if(document.cookie&&h.trim(document.cookie)!=""){var z=document.cookie.split(";");var v=z.length;if(v>0){for(var y=0;y<v;y++){var x=h.trim(z[y]);if(x.substring(0,w.length+1)==(w+"=")){u=decodeURIComponent(x.substring(w.length+1));break}}}}return u}function g(v,B,y){var D=y;var w="";var A="number";if(D.cookies.expires&&(typeof D.cookies.expires==A)||D.cookies.expires.toUTCString){var x=null;if(typeof D.cookies.expires==A){x=new Date();x.setTime(x.getTime()+(D.cookies.expires*24*60*60*1000))}else{x=D.cookies.expires}w="; expires="+x.toUTCString()}var C=D.cookies.path?"; path="+D.cookies.path:"";var z=D.cookies.domain?"; domain="+D.cookies.domain:"";var u=D.cookies.secure?"; secure":"";document.cookie=[v,"=",encodeURIComponent(B),w,C,z,u].join("");return true}function f(v,x,u){var w=s(x);if(w!=null){if(w.indexOf(v)!=-1){w=w.replace(","+v,"");w=w.replace(v+",","");w=w.replace(v,"")}g(x,w,u)}return true}function t(v,x,u){var w=s(x);if(w==null){w=v}else{if(w.indexOf(v)==-1){w=w+","+v}}g(x,w,u);return true}function p(x,w,v){var u='<a href="#" title="TITLE" class="CLASS">TEXT</a>';u=u.replace(/TEXT/g,x);u=u.replace(/TITLE/g,w);u=u.replace(/CLASS/g,v.replace(/\./,""));return u}function q(v,x,z,u){var A="none",y="fade",w="slide";if(!u){if(x==A){v.hide()}else{if(x==y){v.fadeOut(z)}else{if(x==w){v.slideUp(z)}}}}else{if(x==A){v.show()}else{if(x==y){v.fadeIn(z)}else{if(x==w){v.slideDown(z)}}}}return true}})(jQuery);\r