vendor: 4,677 bytes, lines 1-7
1/*/csx/Vendor/jquery/jquery-ui/jquery-ui.min.js*/; 2/*! jQuery UI - v1.11.4 - 2015-09-24 3* http://jqueryui.com 4* Includes: core.js, widget.js, mouse.js, position.js, datepicker.js, tooltip.js 5* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ 6 7(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/^(input|select|textarea|button|object)$/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}function s(e){for(var t,i;e.length&&e[0]!==document;){if(t=e.css("position"),("absolute"===t||"relative"===t||"fixed"===t)&&(i=parseInt(e.css("zIndex"),10),!isNaN(i)&&0!==i))return i;e=e.parent()}return 0}function n(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},e.extend(this._defaults,this.regional[""]),this.regional.en=e.extend(!0,{},this.regional[""]),this.regional["en-US"]=e.extend(!0,{},this.regional.en),this.dpDiv=a(e("<div id='"+this._mainDivId+"' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"))}function a(t){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return t.delegate(i,"mouseout",function(){e(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",o)}function o(){e.datepicker._isDisabledDatepicker(d.inline?d.dpDiv.parent()[0]:d.input[0])||(e(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),e(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).addClass("ui-datepicker-next-hover"))}function r(t,i){e.extend(t,i);for(var s in i)null==i[s]&&(t[s]=i[s]);return t}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id
vendor: 4,237 bytes, line 7
7)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var h=0,l=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,n=l.call(arguments,1),a=0,o=n.length;o>a;a++)for(i in n[a])s=n[a][i],n[a].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(n){var a="string"==typeof n,o=l.call(arguments,1
vendor: 25,045 bytes, lines 7-8
7),r=this;return a?this.each(function(){var i,a=e.data(this,s);return"instance"===n?(r=a,!1):a?e.isFunction(a[n])&&"_"!==n.charAt(0)?(i=a[n].apply(a,o),i!==a&&void 0!==i?(r=i&&i.jquery?r.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+n+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+n+"'")}):(o.length&&(n=e.widget.extend.apply(null,[n].concat(o))),this.each(function(){var t=e.data(this,s);t?(t.option(n||{}),t._init&&t._init()):e.data(this,s,new i(n,this))})),r}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=h++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var u=!1;e(document).mouseup(function(){u=!1}),e.widget("ui.mouse",{version:"1.11.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!u){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),u=!0,!0)):!0}},_mouseMove:function(t){if(this._mouseMoved){if(e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button)return this._mouseUp(t);if(!t.which)return this._mouseUp(t)}return(t.which||t.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),u=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),function(){function t(e,t,i){return[parseFloat(e[0])*(p.test(e[0])?t/100:1),parseFloat(e[1])*(p.test(e[1])?i/100:1)]}function i(t,i){return parseInt(e.css(t,i),10)||0}function s(t){var i=t[0];return 9===i.nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(i)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var n,a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,u=/top|center|bottom/,d=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,p=/%$/,f=e.fn.position;e.position={scrollbarWidth:function(){if(void 0!==n)return n;var t,i,s=e("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),a=s.children()[0];return e("body").append(s),t=a.offsetWidth,s.css("overflow","scroll"),i=a.offsetWidth,t===i&&(i=s[0].clientWidth),s.remove(),n=t-i},getScrollInfo:function(t){var i=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),s=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),n="scroll"===i||"auto"===i&&t.width<t.element[0].scrollWidth,a="scroll"===s||"auto"===s&&t.height<t.element[0].scrollHeight;return{width:a?e.position.scrollbarWidth():0,height:n?e.position.scrollbarWidth():0}},getWithinInfo:function(t){var i=e(t||window),s=e.isWindow(i[0]),n=!!i[0]&&9===i[0].nodeType;return{element:i,isWindow:s,isDocument:n,offset:i.offset()||{left:0,top:0},scrollLeft:i.scrollLeft(),scrollTop:i.scrollTop(),width:s||n?i.width():i.outerWidth(),height:s||n?i.height():i.outerHeight()}}},e.fn.position=function(n){if(!n||!n.of)return f.apply(this,arguments);n=e.extend({},n);var p,m,g,v,y,b,_=e(n.of),x=e.position.getWithinInfo(n.within),w=e.position.getScrollInfo(x),k=(n.collision||"flip").split(" "),T={};return b=s(_),_[0].preventDefault&&(n.at="left top"),m=b.width,g=b.height,v=b.offset,y=e.extend({},v),e.each(["my","at"],function(){var e,t,i=(n[this]||"").split(" ");1===i.length&&(i=l.test(i[0])?i.concat(["center"]):u.test(i[0])?["center"].concat(i):["center","center"]),i[0]=l.test(i[0])?i[0]:"center",i[1]=u.test(i[1])?i[1]:"center",e=d.exec(i[0]),t=d.exec(i[1]),T[this]=[e?e[0]:0,t?t[0]:0],n[this]=[c.exec(i[0])[0],c.exec(i[1])[0]]}),1===k.length&&(k[1]=k[0]),"right"===n.at[0]?y.left+=m:"center"===n.at[0]&&(y.left+=m/2),"bottom"===n.at[1]?y.top+=g:"center"===n.at[1]&&(y.top+=g/2),p=t(T.at,m,g),y.left+=p[0],y.top+=p[1],this.each(function(){var s,l,u=e(this),d=u.outerWidth(),c=u.outerHeight(),f=i(this,"marginLeft"),b=i(this,"marginTop"),D=d+f+i(this,"marginRight")+w.width,S=c+b+i(this,"marginBottom")+w.height,N=e.extend({},y),M=t(T.my,u.outerWidth(),u.outerHeight());"right"===n.my[0]?N.left-=d:"center"===n.my[0]&&(N.left-=d/2),"bottom"===n.my[1]?N.top-=c:"center"===n.my[1]&&(N.top-=c/2),N.left+=M[0],N.top+=M[1],a||(N.left=h(N.left),N.top=h(N.top)),s={marginLeft:f,marginTop:b},e.each(["left","top"],function(t,i){e.ui.position[k[t]]&&e.ui.position[k[t]][i](N,{targetWidth:m,targetHeight:g,elemWidth:d,elemHeight:c,collisionPosition:s,collisionWidth:D,collisionHeight:S,offset:[p[0]+M[0],p[1]+M[1]],my:n.my,at:n.at,within:x,elem:u})}),n.using&&(l=function(e){var t=v.left-N.left,i=t+m-d,s=v.top-N.top,a=s+g-c,h={target:{element:_,left:v.left,top:v.top,width:m,height:g},element:{element:u,left:N.left,top:N.top,width:d,height:c},horizontal:0>i?"left":t>0?"right":"center",vertical:0>a?"top":s>0?"bottom":"middle"};d>m&&m>r(t+i)&&(h.horizontal="center"),c>g&&g>r(s+a)&&(h.vertical="middle"),h.important=o(r(t),r(i))>o(r(s),r(a))?"horizontal":"vertical",n.using.call(this,e,h)}),u.offset(e.extend(N,{using:l}))})},e.ui.position={fit:{left:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=e.left-t.collisionPosition.marginLeft,h=n-r,l=r+t.collisionWidth-a-n;t.collisionWidth>a?h>0&&0>=l?(i=e.left+h+t.collisionWidth-a-n,e.left+=h-i):e.left=l>0&&0>=h?n:h>l?n+a-t.collisionWidth:n:h>0?e.left+=h:l>0?e.left-=l:e.left=o(e.left-r,e.left)},top:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollTop:s.offset.top,a=t.within.height,r=e.top-t.collisionPosition.marginTop,h=n-r,l=r+t.collisionHeight-a-n;t.collisionHeight>a?h>0&&0>=l?(i=e.top+h+t.collisionHeight-a-n,e.top+=h-i):e.top=l>0&&0>=h?n:h>l?n+a-t.collisionHeight:n:h>0?e.top+=h:l>0?e.top-=l:e.top=o(e.top-r,e.top)}},flip:{left:function(e,t){var i,s,n=t.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-t.collisionPosition.marginLeft,u=l-h,d=l+t.collisionWidth-o-h,c="left"===t.my[0]?-t.elemWidth:"right"===t.my[0]?t.elemWidth:0,p="left"===t.at[0]?t.targetWidth:"right"===t.at[0]?-t.targetWidth:0,f=-2*t.offset[0];0>u?(i=e.left+c+p+f+t.collisionWidth-o-a,(0>i||r(u)>i)&&(e.left+=c+p+f)):d>0&&(s=e.left-t.collisionPosition.marginLeft+c+p+f-h,(s>0||d>r(s))&&(e.left+=c+p+f))},top:function(e,t){var i,s,n=t.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=e.top-t.collisionPosition.marginTop,u=l-h,d=l+t.collisionHeight-o-h,c="top"===t.my[1],p=c?-t.elemHeight:"bottom"===t.my[1]?t.elemHeight:0,f="top"===t.at[1]?t.targetHeight:"bottom"===t.at[1]?-t.targetHeight:0,m=-2*t.offset[1];0>u?(s=e.top+p+f+m+t.collisionHeight-o-a,(0>s||r(u)>s)&&(e.top+=p+f+m)):d>0&&(i=e.top-t.collisionPosition.marginTop+p+f+m-h,(i>0||d>r(i))&&(e.top+=p+f+m))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,i,s,n,o,r=document.getElementsByTagName("body")[0],h=document.createElement("div");t=document.createElement(r?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&e.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(o in s)t.style[o]=s[o];t.appendChild(h),i=r||document.documentElement,i.insertBefore(t,i.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",n=e(h).offset().left,a=n>10&&11>n,t.innerHTML="",i.removeChild(t)}()}(),e.ui.position,e.extend(e.ui,{datepicker:{version:"1.11.4"}});var d;e.extend(n.prototype,{markerClassName:"hasDatepicker",maxRows:4,_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(e){return r(this._defaults,e||{}),this},_attachDatepicker:function(t,i){var s,n,a;s=t.nodeName.toLowerCase(),n="div"===s||"span"===s,t.id||(this.uuid+=1,t.id="dp"+this.uuid),a=this._newInst(e(t),n),a.settings=e.extend({},i||{}),"input"===s?this._connectDatepicker(t,a):n&&this._inlineDatepicker(t,a)},_newInst:function(t,i){var s=t[0].id.replace(/([^A-Za-z0-9_\-])/g,"\\\\$1");return{id:s,input:t,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:i,dpDiv:i?a(e("<div class='"+this._inlineClass+" ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")):this.dpDiv}},_connectDatepicker:function(t,i){var s=e(t);i.append=e([]),i.trigger=e([]),s.hasClass(this.markerClassName)||(this._attachments(s,i),s.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp),this._autoSize(i),e.data(t,"datepicker",i),i.settings.disabled&&this._disableDatepicker(t))},_attachments:function(t,i){var s,n,a,o=this._get(i,"appendText"),r=this._get(i,"isRTL");i.append&&i.append.remove(),o&&(i.append=e("<span class='"+this._appendClass+"'>"+o+"</span>"),t[r?"before":"after"](i.append)),t.unbind("focus",this._showDatepicker),i.trigger&&i.trigger.remove(),s=this._get(i,"showOn"),("focus"===s||"both"===s)&&t.focus(this._showDatepicker),("button"===s||"both"===s)&&(n=this._get(i,"buttonText"),a=this._get(i,"buttonImage"),i.trigger=e(this._get(i,"buttonImageOnly")?e("<img/>").addClass(this._triggerClass).attr({src:a,alt:n,title:n}):e("<button type='button'></button>").addClass(this._triggerClass).html(a?e("<img/>").attr({src:a,alt:n,title:n}):n)),t[r?"before":"after"](i.trigger),i.trigger.click(function(){return e.datepicker._datepickerShowing&&e.datepicker._lastInput===t[0]?e.datepicker._hideDatepicker():e.datepicker._datepickerShowing&&e.datepicker._lastInput!==t[0]?(e.datepicker._hideDatepicker(),e.datepicker._showDatepicker(t[0])):e.datepicker._showDatepicker(t[0]),!1}))},_autoSize:function(e){if(this._get(e,"autoSize")&&!e.inline){var t,i,s,n,a=new Date(2009,11,20),o=this._get(e,"dateFormat");o.match(/[DM]/)&&(t=function(e){for(i=0,s=0,n=0;e.length>n;n++)e[n].length>i&&(i=e[n].length,s=n);return s},a.setMonth(t(this._get(e,o.match(/MM/)?"monthNames":"monthNamesShort"))),a.setDate(t(this._get(e,o.match(/DD/)?"dayNames":"dayNamesShort"))+20-a.getDay())),e.input.attr("size",this._formatDate(e,a).length)}},_inlineDatepicker:function(t,i){var s=e(t);s.hasClass(this.markerClassName)||(s.addClass(this.markerClassName).append(i.dpDiv),e.data(t,"datepicker",i),this._setDate(i,this._getDefaultDate(i),!0),this._updateDatepicker(i),this._updateAlternate(i),i.settings.disabled&&this._disableDatepicker(t),i.dpDiv.css("display","block"))},_dialogDatepicker:function(t,i,s,n,a){var o,h,l,u,d,c=this._dialogInst;return c||(this.uuid+=1,o="dp"+this.uuid,this._dialogInput=e("<input type='text' id='"+o+"' style='position: absolute; top: -100px; width: 0px;'/>"),this._dialogInput.keydown(this._doKeyDown),e("body").append(this._dialogInput),c=this._dialogInst=this._newInst(this._dialogInput,!1),c.settings={},e.data(this._dialogInput[0],"datepicker",c)),r(c.settings,n||{}),i=i&&i.constructor===Date?this._formatDate(c,i):i,this._dialogInput.val(i),this._pos=a?a.length?a:[a.pageX,a.pageY]:null,this._pos||(h=document.documentElement.clientWidth,l=document.documentElement.clientHeight,u=document.documentElement.scrollLeft||document.body.scrollLeft,d=document.documentElement.scrollTop||document.body.scrollTop,this._pos=[h/2-100+u,l/2-150+d]),this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px"),c.settings.onSelect=s,this._inDialog=!0,this.dpDiv.addClass(this._dialogClass),this._showDatepicker(this._dialogInput[0]),e.blockUI&&e.blockUI(this.dpDiv),e.data(this._dialogInput[0],"datepicker",c),this},_destroyDatepicker:function(t){var i,s=e(t),n=e.data(t,"datepicker");s.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),e.removeData(t,"datepicker"),"input"===i?(n.append.remove(),n.trigger.remove(),s.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)):("div"===i||"span"===i)&&s.removeClass(this.markerClassName).empty(),d===n&&(d=null))},_enableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!1,a.trigger.filter("button").each(function(){this.disabled=!1}).end().filter("img").css({opacity:"1.0",cursor:""})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().removeClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!1)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}))},_disableDatepicker:function(t){var i,s,n=e(t),a=e.data(t,"datepicker");n.hasClass(this.markerClassName)&&(i=t.nodeName.toLowerCase(),"input"===i?(t.disabled=!0,a.trigger.filter("button").each(function(){this.disabled=!0}).end().filter("img").css({opacity:"0.5",cursor:"default"})):("div"===i||"span"===i)&&(s=n.children("."+this._inlineClass),s.children().addClass("ui-state-disabled"),s.find("select.ui-datepicker-month, select.ui-datepicker-year").prop("disabled",!0)),this._disabledInputs=e.map(this._disabledInputs,function(e){return e===t?null:e}),this._disabledInputs[this._disabledInputs.length]=t)},_isDisabledDatepicker:function(e){if(!e)return!1;for(var t=0;this._disabledInputs.length>t;t++)if(this._disabledInputs[t]===e)return!0;return!1},_getInst:function(t){try{return e.data(t,"datepicker")}catch(i){throw"Missing instance data for this datepicker"}},_optionDatepicker:function(t,i,s){var n,a,o,h,l=this._getInst(t);return 2===arguments.length&&"string"==typeof i?"defaults"===i?e.extend({},e.datepicker._defaults):l?"all"===i?e.extend({},l.settings):this._get(l,i):null:(n=i||{},"string"==typeof i&&(n={},n[i]=s),l&&(this._curInst===l&&this._hideDatepicker(),a=this._getDateDatepicker(t,!0),o=this._getMinMaxDate(l,"min"),h=this._getMinMaxDate(l,"max"),r(l.settings,n),null!==o&&void 0!==n.dateFormat&&void 0===n.minDate&&(l.settings.minDate=this._formatDate(l,o)),null!==h&&void 0!==n.dateFormat&&void 0===n.maxDate&&(l.settings.maxDate=this._formatDate(l,h)),"disabled"in n&&(n.disabled?this._disableDatepicker(t):this._enableDatepicker(t)),this._attachments(e(t),l),this._autoSize(l),this._setDate(l,a),this._updateAlternate(l),this._updateDatepicker(l)),void 0)},_changeDatepicker:function(e,t,i){this._optionDatepicker(e,t,i)},_refreshDatepicker:function(e){var t=this._getInst(e);t&&this._updateDatepicker(t)},_setDateDatepicker:function(e,t){var i=this._getInst(e);i&&(this._setDate(i,t),this._updateDatepicker(i),this._updateAlternate(i))},_getDateDatepicker:function(e,t){var i=this._getInst(e);return i&&!i.inline&&this._setDateFromField(i,t),i?this._getDate(i):null},_doKeyDown:function(t){var i,s,n,a=e.datepicker._getInst(t.target),o=!0,r=a.dpDiv.is(".ui-datepicker-rtl");if(a._keyEvent=!0,e.datepicker._datepickerShowing)switch(t.keyCode){case 9:e.datepicker._hideDatepicker(),o=!1;break;case 13:return n=e("td."+e.datepicker._dayOverClass+":not(."+e.datepicker._currentClass+")",a.dpDiv),n[0]&&e.datepicker._selectDay(t.target,a.selectedMonth,a.selectedYear,n[0]),i=e.datepicker._get(a,"onSelect"),i?(s=e.datepicker._formatDate(a),i.apply(a.input?a.input[0]:null,[s,a])):e.datepicker._hideDatepicker(),!1;case 27:e.datepicker._hideDatepicker();break;case 33:e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 34:e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 35:(t.ctrlKey||t.metaKey)&&e.datepicker._clearDate(t.target),o=t.ctrlKey||t.metaKey;break;case 36:(t.ctrlKey||t.metaKey)&&e.datepicker._gotoToday(t.target),o=t.ctrlKey||t.metaKey;break;case 37:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?1:-1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?-e.datepicker._get(a,"stepBigMonths"):-e.datepicker._get(a,"stepMonths"),"M");break;case 38:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,-7,"D"),o=t.ctrlKey||t.metaKey;break;case 39:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,r?-1:1,"D"),o=t.ctrlKey||t.metaKey,t.originalEvent.altKey&&e.datepicker._adjustDate(t.target,t.ctrlKey?+e.datepicker._get(a,"stepBigMonths"):+e.datepicker._get(a,"stepMonths"),"M");break;case 40:(t.ctrlKey||t.metaKey)&&e.datepicker._adjustDate(t.target,7,"D"),o=t.ctrlKey||t.metaKey;break;default:o=!1}else 36===t.keyCode&&t.ctrlKey?e.datepicker._showDatepicker(this):o=!1;o&&(t.preventDefault(),t.stopPropagation())},_doKeyPress:function(t){var i,s,n=e.datepicker._getInst(t.target);return e.datepicker._get(n,"constrainInput")?(i=e.datepicker._possibleChars(e.datepicker._get(n,"dateFormat")),s=String.fromCharCode(null==t.charCode?t.keyCode:t.charCode),t.ctrlKey||t.metaKey||" ">s||!i||i.indexOf(s)>-1):void 0},_doKeyUp:function(t){var i,s=e.datepicker._getInst(t.target);if(s.input.val()!==s.lastVal)try{i=e.datepicker.parseDate(e.datepicker._get(s,"dateFormat"),s.input?s.input.val():null,e.datepicker._getFormatConfig(s)),i&&(e.datepicker._setDateFromField(s),e.datepicker._updateAlternate(s),e.datepicker._updateDatepicker(s)) 8}catch(n){}return!0},_showDatepicker:function(t){if(t=t.target||t,"input"!==t.nodeName.toLowerCase()&&(t=e("input",t.parentNode)[0]),!e.datepicker._isDisabledDatepicker(t)&&e.datepicker._lastInput!==t){var i,n,a,o,h,l,u;i=e.datepicker._getInst(t),e.datepicker._curInst&&e.datepicker._curInst!==i&&(e.datepicker._curInst.dpDiv.stop(!0,!0),i&&e.datepicker._datepickerShowing&&e.datepicker._hideDatepicker(e.datepicker._curInst.input[0])),n=e.datepicker._get(i,"beforeShow"),a=n?n.apply(t,[t,i]):{},a!==!1&&(r(i.settings,a),i.lastVal=null,e.datepicker._lastInput=t,e.datepicker._setDateFromField(i),e.datepicker._inDialog&&(t.value=""),e.datepicker._pos||(e.datepicker._pos=e.datepicker._findPos(t),e.datepicker._pos[1]+=t.offsetHeight),o=!1,e(t).parents().each(function(){return o|="fixed"===e(this).css("position"),!o}),h={left:e.datepicker._pos[0],top:e.datepicker._pos[1]},e.datepicker._pos=null,i.dpDiv.empty(),i.dpDiv.css({position:"absolute",display:"block",top:"-1000px"}),e.datepicker._updateDatepicker(i),h=e.datepicker._checkOffset(i,h,o),i.dpDiv.css({position:e.datepicker._inDialog&&e.blockUI?"static":o?"fixed":"absolute",display:"none",left:h.left+"px",top:h.top+"px"}),i.inline||(l=e.datepicker._get(i,"showAnim"),u=e.datepicker._get(i,"duration"),i.dpDiv.css("z-index",s(e(t))+1),e.datepicker._datepickerShowing=!0,e.effects&&e.effects.effect[l]?i.dpDiv.show(l,e.datepicker._get(i,"showOptions"),u):i.dpDiv[l||"show"](l?u:null),e.datepicker._shouldFocusInput(i)&&i.input.focus(),e.datepicker._curInst=i))}},_updateDatepicker:function(t){this.maxRows=4,d
vendor: 12,009 bytes, line 8
8=t,t.dpDiv.empty().append(this._generateHTML(t)),this._attachHandlers(t);var i,s=this._getNumberOfMonths(t),n=s[1],a=17,r=t.dpDiv.find("."+this._dayOverClass+" a");r.length>0&&o.apply(r.get(0)),t.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width(""),n>1&&t.dpDiv.addClass("ui-datepicker-multi-"+n).css("width",a*n+"em"),t.dpDiv[(1!==s[0]||1!==s[1]?"add":"remove")+"Class"]("ui-datepicker-multi"),t.dpDiv[(this._get(t,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl"),t===e.datepicker._curInst&&e.datepicker._datepickerShowing&&e.datepicker._shouldFocusInput(t)&&t.input.focus(),t.yearshtml&&(i=t.yearshtml,setTimeout(function(){i===t.yearshtml&&t.yearshtml&&t.dpDiv.find("select.ui-datepicker-year:first").replaceWith(t.yearshtml),i=t.yearshtml=null},0))},_shouldFocusInput:function(e){return e.input&&e.input.is(":visible")&&!e.input.is(":disabled")&&!e.input.is(":focus")},_checkOffset:function(t,i,s){var n=t.dpDiv.outerWidth(),a=t.dpDiv.outerHeight(),o=t.input?t.input.outerWidth():0,r=t.input?t.input.outerHeight():0,h=document.documentElement.clientWidth+(s?0:e(document).scrollLeft()),l=document.documentElement.clientHeight+(s?0:e(document).scrollTop());return i.left-=this._get(t,"isRTL")?n-o:0,i.left-=s&&i.left===t.input.offset().left?e(document).scrollLeft():0,i.top-=s&&i.top===t.input.offset().top+r?e(document).scrollTop():0,i.left-=Math.min(i.left,i.left+n>h&&h>n?Math.abs(i.left+n-h):0),i.top-=Math.min(i.top,i.top+a>l&&l>a?Math.abs(a+r):0),i},_findPos:function(t){for(var i,s=this._getInst(t),n=this._get(s,"isRTL");t&&("hidden"===t.type||1!==t.nodeType||e.expr.filters.hidden(t));)t=t[n?"previousSibling":"nextSibling"];return i=e(t).offset(),[i.left,i.top]},_hideDatepicker:function(t){var i,s,n,a,o=this._curInst;!o||t&&o!==e.data(t,"datepicker")||this._datepickerShowing&&(i=this._get(o,"showAnim"),s=this._get(o,"duration"),n=function(){e.datepicker._tidyDialog(o)},e.effects&&(e.effects.effect[i]||e.effects[i])?o.dpDiv.hide(i,e.datepicker._get(o,"showOptions"),s,n):o.dpDiv["slideDown"===i?"slideUp":"fadeIn"===i?"fadeOut":"hide"](i?s:null,n),i||n(),this._datepickerShowing=!1,a=this._get(o,"onClose"),a&&a.apply(o.input?o.input[0]:null,[o.input?o.input.val():"",o]),this._lastInput=null,this._inDialog&&(this._dialogInput.css({position:"absolute",left:"0",top:"-100px"}),e.blockUI&&(e.unblockUI(),e("body").append(this.dpDiv))),this._inDialog=!1)},_tidyDialog:function(e){e.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(t){if(e.datepicker._curInst){var i=e(t.target),s=e.datepicker._getInst(i[0]);(i[0].id!==e.datepicker._mainDivId&&0===i.parents("#"+e.datepicker._mainDivId).length&&!i.hasClass(e.datepicker.markerClassName)&&!i.closest("."+e.datepicker._triggerClass).length&&e.datepicker._datepickerShowing&&(!e.datepicker._inDialog||!e.blockUI)||i.hasClass(e.datepicker.markerClassName)&&e.datepicker._curInst!==s)&&e.datepicker._hideDatepicker()}},_adjustDate:function(t,i,s){var n=e(t),a=this._getInst(n[0]);this._isDisabledDatepicker(n[0])||(this._adjustInstDate(a,i+("M"===s?this._get(a,"showCurrentAtPos"):0),s),this._updateDatepicker(a))},_gotoToday:function(t){var i,s=e(t),n=this._getInst(s[0]);this._get(n,"gotoCurrent")&&n.currentDay?(n.selectedDay=n.currentDay,n.drawMonth=n.selectedMonth=n.currentMonth,n.drawYear=n.selectedYear=n.currentYear):(i=new Date,n.selectedDay=i.getDate(),n.drawMonth=n.selectedMonth=i.getMonth(),n.drawYear=n.selectedYear=i.getFullYear()),this._notifyChange(n),this._adjustDate(s)},_selectMonthYear:function(t,i,s){var n=e(t),a=this._getInst(n[0]);a["selected"+("M"===s?"Month":"Year")]=a["draw"+("M"===s?"Month":"Year")]=parseInt(i.options[i.selectedIndex].value,10),this._notifyChange(a),this._adjustDate(n)},_selectDay:function(t,i,s,n){var a,o=e(t);e(n).hasClass(this._unselectableClass)||this._isDisabledDatepicker(o[0])||(a=this._getInst(o[0]),a.selectedDay=a.currentDay=e("a",n).html(),a.selectedMonth=a.currentMonth=i,a.selectedYear=a.currentYear=s,this._selectDate(t,this._formatDate(a,a.currentDay,a.currentMonth,a.currentYear)))},_clearDate:function(t){var i=e(t);this._selectDate(i,"")},_selectDate:function(t,i){var s,n=e(t),a=this._getInst(n[0]);i=null!=i?i:this._formatDate(a),a.input&&a.input.val(i),this._updateAlternate(a),s=this._get(a,"onSelect"),s?s.apply(a.input?a.input[0]:null,[i,a]):a.input&&a.input.trigger("change"),a.inline?this._updateDatepicker(a):(this._hideDatepicker(),this._lastInput=a.input[0],"object"!=typeof a.input[0]&&a.input.focus(),this._lastInput=null)},_updateAlternate:function(t){var i,s,n,a=this._get(t,"altField");a&&(i=this._get(t,"altFormat")||this._get(t,"dateFormat"),s=this._getDate(t),n=this.formatDate(i,s,this._getFormatConfig(t)),e(a).each(function(){e(this).val(n)}))},noWeekends:function(e){var t=e.getDay();return[t>0&&6>t,""]},iso8601Week:function(e){var t,i=new Date(e.getTime());return i.setDate(i.getDate()+4-(i.getDay()||7)),t=i.getTime(),i.setMonth(0),i.setDate(1),Math.floor(Math.round((t-i)/864e5)/7)+1},parseDate:function(t,i,s){if(null==t||null==i)throw"Invalid arguments";if(i="object"==typeof i?""+i:i+"",""===i)return null;var n,a,o,r,h=0,l=(s?s.shortYearCutoff:null)||this._defaults.shortYearCutoff,u="string"!=typeof l?l:(new Date).getFullYear()%100+parseInt(l,10),d=(s?s.dayNamesShort:null)||this._defaults.dayNamesShort,c=(s?s.dayNames:null)||this._defaults.dayNames,p=(s?s.monthNamesShort:null)||this._defaults.monthNamesShort,f=(s?s.monthNames:null)||this._defaults.monthNames,m=-1,g=-1,v=-1,y=-1,b=!1,_=function(e){var i=t.length>n+1&&t.charAt(n+1)===e;return i&&n++,i},x=function(e){var t=_(e),s="@"===e?14:"!"===e?20:"y"===e&&t?4:"o"===e?3:2,n="y"===e?s:1,a=RegExp("^\\d{"+n+","+s+"}"),o=i.substring(h).match(a);if(!o)throw"Missing number at position "+h;return h+=o[0].length,parseInt(o[0],10)},w=function(t,s,n){var a=-1,o=e.map(_(t)?n:s,function(e,t){return[[t,e]]}).sort(function(e,t){return-(e[1].length-t[1].length)});if(e.each(o,function(e,t){var s=t[1];return i.substr(h,s.length).toLowerCase()===s.toLowerCase()?(a=t[0],h+=s.length,!1):void 0}),-1!==a)return a+1;throw"Unknown name at position "+h},k=function(){if(i.charAt(h)!==t.charAt(n))throw"Unexpected literal at position "+h;h++};for(n=0;t.length>n;n++)if(b)"'"!==t.charAt(n)||_("'")?k():b=!1;else switch(t.charAt(n)){case"d":v=x("d");break;case"D":w("D",d,c);break;case"o":y=x("o");break;case"m":g=x("m");break;case"M":g=w("M",p,f);break;case"y":m=x("y");break;case"@":r=new Date(x("@")),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"!":r=new Date((x("!")-this._ticksTo1970)/1e4),m=r.getFullYear(),g=r.getMonth()+1,v=r.getDate();break;case"'":_("'")?k():b=!0;break;default:k()}if(i.length>h&&(o=i.substr(h),!/^\s+/.test(o)))throw"Extra/unparsed characters found in date: "+o;if(-1===m?m=(new Date).getFullYear():100>m&&(m+=(new Date).getFullYear()-(new Date).getFullYear()%100+(u>=m?0:-100)),y>-1)for(g=1,v=y;;){if(a=this._getDaysInMonth(m,g-1),a>=v)break;g++,v-=a}if(r=this._daylightSavingAdjust(new Date(m,g-1,v)),r.getFullYear()!==m||r.getMonth()+1!==g||r.getDate()!==v)throw"Invalid date";return r},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:1e7*60*60*24*(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925)),formatDate:function(e,t,i){if(!t)return"";var s,n=(i?i.dayNamesShort:null)||this._defaults.dayNamesShort,a=(i?i.dayNames:null)||this._defaults.dayNames,o=(i?i.monthNamesShort:null)||this._defaults.monthNamesShort,r=(i?i.monthNames:null)||this._defaults.monthNames,h=function(t){var i=e.length>s+1&&e.charAt(s+1)===t;return i&&s++,i},l=function(e,t,i){var s=""+t;if(h(e))for(;i>s.length;)s="0"+s;return s},u=function(e,t,i,s){return h(e)?s[t]:i[t]},d="",c=!1;if(t)for(s=0;e.length>s;s++)if(c)"'"!==e.charAt(s)||h("'")?d+=e.charAt(s):c=!1;else switch(e.charAt(s)){case"d":d+=l("d",t.getDate(),2);break;case"D":d+=u("D",t.getDay(),n,a);break;case"o":d+=l("o",Math.round((new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(t.getFullYear(),0,0).getTime())/864e5),3);break;case"m":d+=l("m",t.getMonth()+1,2);break;case"M":d+=u("M",t.getMonth(),o,r);break;case"y":d+=h("y")?t.getFullYear():(10>t.getYear()%100?"0":"")+t.getYear()%100;break;case"@":d+=t.getTime();break;case"!":d+=1e4*t.getTime()+this._ticksTo1970;break;case"'":h("'")?d+="'":c=!0;break;default:d+=e.charAt(s)}return d},_possibleChars:function(e){var t,i="",s=!1,n=function(i){var s=e.length>t+1&&e.charAt(t+1)===i;return s&&t++,s};for(t=0;e.length>t;t++)if(s)"'"!==e.charAt(t)||n("'")?i+=e.charAt(t):s=!1;else switch(e.charAt(t)){case"d":case"m":case"y":case"@":i+="0123456789";break;case"D":case"M":return null;case"'":n("'")?i+="'":s=!0;break;default:i+=e.charAt(t)}return i},_get:function(e,t){return void 0!==e.settings[t]?e.settings[t]:this._defaults[t]},_setDateFromField:function(e,t){if(e.input.val()!==e.lastVal){var i=this._get(e,"dateFormat"),s=e.lastVal=e.input?e.input.val():null,n=this._getDefaultDate(e),a=n,o=this._getFormatConfig(e);try{a=this.parseDate(i,s,o)||n}catch(r){s=t?"":s}e.selectedDay=a.getDate(),e.drawMonth=e.selectedMonth=a.getMonth(),e.drawYear=e.selectedYear=a.getFullYear(),e.currentDay=s?a.getDate():0,e.currentMonth=s?a.getMonth():0,e.currentYear=s?a.getFullYear():0,this._adjustInstDate(e)}},_getDefaultDate:function(e){return this._restrictMinMax(e,this._determineDate(e,this._get(e,"defaultDate"),new Date))},_determineDate:function(t,i,s){var n=function(e){var t=new Date;return t.setDate(t.getDate()+e),t},a=function(i){try{return e.datepicker.parseDate(e.datepicker._get(t,"dateFormat"),i,e.datepicker._getFormatConfig(t))}catch(s){}for(var n=(i.toLowerCase().match(/^c/)?e.datepicker._getDate(t):null)||new Date,a=n.getFullYear(),o=n.getMonth(),r=n.getDate(),h=/([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,l=h.exec(i);l;){switch(l[2]||"d"){case"d":case"D":r+=parseInt(l[1],10);break;case"w":case"W":r+=7*parseInt(l[1],10);break;case"m":case"M":o+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o));break;case"y":case"Y":a+=parseInt(l[1],10),r=Math.min(r,e.datepicker._getDaysInMonth(a,o))}l=h.exec(i)}return new Date(a,o,r)},o=null==i||""===i?s:"string"==typeof i?a(i):"number"==typeof i?isNaN(i)?s:n(i):new Date(i.getTime());return o=o&&"Invalid Date"==""+o?s:o,o&&(o.setHours(0),o.setMinutes(0),o.setSeconds(0),o.setMilliseconds(0)),this._daylightSavingAdjust(o)},_daylightSavingAdjust:function(e){return e?(e.setHours(e.getHours()>12?e.getHours()+2:0),e):null},_setDate:function(e,t,i){var s=!t,n=e.selectedMonth,a=e.selectedYear,o=this._restrictMinMax(e,this._determineDate(e,t,new Date));e.selectedDay=e.currentDay=o.getDate(),e.drawMonth=e.selectedMonth=e.currentMonth=o.getMonth(),e.drawYear=e.selectedYear=e.currentYear=o.getFullYear(),n===e.selectedMonth&&a===e.selectedYear||i||this._notifyChange(e),this._adjustInstDate(e),e.input&&e.input.val(s?"":this._formatDate(e))},_getDate:function(e){var t=!e.currentYear||e.input&&""===e.input.val()?null:this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return t},_attachHandlers:function(t){var i=this._get(t,"stepMonths"),s="#"+t.id.replace(/\\\\/g,"\\");t.dpDiv.find("[data-handler]").map(function(){var t={prev:function(){e.datepicker._adjustDate(s,-i,"M")},next:function(){e.datepicker._adjustDate(s,+i,"M")},hide:function(){e.datepicker._hideDatepicker()},today:function(){e.datepicker._gotoToday(s)},selectDay:function(){return e.datepicker._selectDay(s,+this.getAttribute("data-month"),+this.getAttribute("data-year"),this),!1},selectMonth:function(){return e.datepicker._selectMonthYear(s,this,"M"),!1},selectYear:function(){return e.datepicker._selectMonthYear(s,this,"Y"),!1}};e(this).bind(this.getAttribute("data-event"),t[this.getAttribute("data-handler")])})},_generateHTML:function(e){var t,i,s,n,a,o,r,h,l,u,d,c,p,f,m,g,v,y,b,_,x,w,k,T,D,S,
vendor: 16,271 bytes, lines 8-41
8N,M,C,P,A,I,H,z,F,E,W,O,L,j=new Date,R=this._daylightSavingAdjust(new Date(j.getFullYear(),j.getMonth(),j.getDate())),Y=this._get(e,"isRTL"),J=this._get(e,"showButtonPanel"),B=this._get(e,"hideIfNoPrevNext"),K=this._get(e,"navigationAsDateFormat"),V=this._getNumberOfMonths(e),U=this._get(e,"showCurrentAtPos"),q=this._get(e,"stepMonths"),G=1!==V[0]||1!==V[1],X=this._daylightSavingAdjust(e.currentDay?new Date(e.currentYear,e.currentMonth,e.currentDay):new Date(9999,9,9)),Q=this._getMinMaxDate(e,"min"),$=this._getMinMaxDate(e,"max"),Z=e.drawMonth-U,et=e.drawYear;if(0>Z&&(Z+=12,et--),$)for(t=this._daylightSavingAdjust(new Date($.getFullYear(),$.getMonth()-V[0]*V[1]+1,$.getDate())),t=Q&&Q>t?Q:t;this._daylightSavingAdjust(new Date(et,Z,1))>t;)Z--,0>Z&&(Z=11,et--);for(e.drawMonth=Z,e.drawYear=et,i=this._get(e,"prevText"),i=K?this.formatDate(i,this._daylightSavingAdjust(new Date(et,Z-q,1)),this._getFormatConfig(e)):i,s=this._canAdjustMonth(e,-1,et,Z)?"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>":B?"":"<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+i+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"e":"w")+"'>"+i+"</span></a>",n=this._get(e,"nextText"),n=K?this.formatDate(n,this._daylightSavingAdjust(new Date(et,Z+q,1)),this._getFormatConfig(e)):n,a=this._canAdjustMonth(e,1,et,Z)?"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>":B?"":"<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+n+"'><span class='ui-icon ui-icon-circle-triangle-"+(Y?"w":"e")+"'>"+n+"</span></a>",o=this._get(e,"currentText"),r=this._get(e,"gotoCurrent")&&e.currentDay?X:R,o=K?this.formatDate(o,r,this._getFormatConfig(e)):o,h=e.inline?"":"<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>"+this._get(e,"closeText")+"</button>",l=J?"<div class='ui-datepicker-buttonpane ui-widget-content'>"+(Y?h:"")+(this._isInRange(e,r)?"<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'>"+o+"</button>":"")+(Y?"":h)+"</div>":"",u=parseInt(this._get(e,"firstDay"),10),u=isNaN(u)?0:u,d=this._get(e,"showWeek"),c=this._get(e,"dayNames"),p=this._get(e,"dayNamesMin"),f=this._get(e,"monthNames"),m=this._get(e,"monthNamesShort"),g=this._get(e,"beforeShowDay"),v=this._get(e,"showOtherMonths"),y=this._get(e,"selectOtherMonths"),b=this._getDefaultDate(e),_="",w=0;V[0]>w;w++){for(k="",this.maxRows=4,T=0;V[1]>T;T++){if(D=this._daylightSavingAdjust(new Date(et,Z,e.selectedDay)),S=" ui-corner-all",N="",G){if(N+="<div class='ui-datepicker-group",V[1]>1)switch(T){case 0:N+=" ui-datepicker-group-first",S=" ui-corner-"+(Y?"right":"left");break;case V[1]-1:N+=" ui-datepicker-group-last",S=" ui-corner-"+(Y?"left":"right");break;default:N+=" ui-datepicker-group-middle",S=""}N+="'>"}for(N+="<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix"+S+"'>"+(/all|left/.test(S)&&0===w?Y?a:s:"")+(/all|right/.test(S)&&0===w?Y?s:a:"")+this._generateMonthYearHeader(e,Z,et,Q,$,w>0||T>0,f,m)+"</div><table class='ui-datepicker-calendar'><thead>"+"<tr>",M=d?"<th class='ui-datepicker-week-col'>"+this._get(e,"weekHeader")+"</th>":"",x=0;7>x;x++)C=(x+u)%7,M+="<th scope='col'"+((x+u+6)%7>=5?" class='ui-datepicker-week-end'":"")+">"+"<span title='"+c[C]+"'>"+p[C]+"</span></th>";for(N+=M+"</tr></thead><tbody>",P=this._getDaysInMonth(et,Z),et===e.selectedYear&&Z===e.selectedMonth&&(e.selectedDay=Math.min(e.selectedDay,P)),A=(this._getFirstDayOfMonth(et,Z)-u+7)%7,I=Math.ceil((A+P)/7),H=G?this.maxRows>I?this.maxRows:I:I,this.maxRows=H,z=this._daylightSavingAdjust(new Date(et,Z,1-A)),F=0;H>F;F++){for(N+="<tr>",E=d?"<td class='ui-datepicker-week-col'>"+this._get(e,"calculateWeek")(z)+"</td>":"",x=0;7>x;x++)W=g?g.apply(e.input?e.input[0]:null,[z]):[!0,""],O=z.getMonth()!==Z,L=O&&!y||!W[0]||Q&&Q>z||$&&z>$,E+="<td class='"+((x+u+6)%7>=5?" ui-datepicker-week-end":"")+(O?" ui-datepicker-other-month":"")+(z.getTime()===D.getTime()&&Z===e.selectedMonth&&e._keyEvent||b.getTime()===z.getTime()&&b.getTime()===D.getTime()?" "+this._dayOverClass:"")+(L?" "+this._unselectableClass+" ui-state-disabled":"")+(O&&!v?"":" "+W[1]+(z.getTime()===X.getTime()?" "+this._currentClass:"")+(z.getTime()===R.getTime()?" ui-datepicker-today":""))+"'"+(O&&!v||!W[2]?"":" title='"+W[2].replace(/'/g,"'")+"'")+(L?"":" data-handler='selectDay' data-event='click' data-month='"+z.getMonth()+"' data-year='"+z.getFullYear()+"'")+">"+(O&&!v?" ":L?"<span class='ui-state-default'>"+z.getDate()+"</span>":"<a class='ui-state-default"+(z.getTime()===R.getTime()?" ui-state-highlight":"")+(z.getTime()===X.getTime()?" ui-state-active":"")+(O?" ui-priority-secondary":"")+"' href='#'>"+z.getDate()+"</a>")+"</td>",z.setDate(z.getDate()+1),z=this._daylightSavingAdjust(z);N+=E+"</tr>"}Z++,Z>11&&(Z=0,et++),N+="</tbody></table>"+(G?"</div>"+(V[0]>0&&T===V[1]-1?"<div class='ui-datepicker-row-break'></div>":""):""),k+=N}_+=k}return _+=l,e._keyEvent=!1,_},_generateMonthYearHeader:function(e,t,i,s,n,a,o,r){var h,l,u,d,c,p,f,m,g=this._get(e,"changeMonth"),v=this._get(e,"changeYear"),y=this._get(e,"showMonthAfterYear"),b="<div class='ui-datepicker-title'>",_="";if(a||!g)_+="<span class='ui-datepicker-month'>"+o[t]+"</span>";else{for(h=s&&s.getFullYear()===i,l=n&&n.getFullYear()===i,_+="<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>",u=0;12>u;u++)(!h||u>=s.getMonth())&&(!l||n.getMonth()>=u)&&(_+="<option value='"+u+"'"+(u===t?" selected='selected'":"")+">"+r[u]+"</option>");_+="</select>"}if(y||(b+=_+(!a&&g&&v?"":" ")),!e.yearshtml)if(e.yearshtml="",a||!v)b+="<span class='ui-datepicker-year'>"+i+"</span>";else{for(d=this._get(e,"yearRange").split(":"),c=(new Date).getFullYear(),p=function(e){var t=e.match(/c[+\-].*/)?i+parseInt(e.substring(1),10):e.match(/[+\-].*/)?c+parseInt(e,10):parseInt(e,10);return isNaN(t)?c:t},f=p(d[0]),m=Math.max(f,p(d[1]||"")),f=s?Math.max(f,s.getFullYear()):f,m=n?Math.min(m,n.getFullYear()):m,e.yearshtml+="<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";m>=f;f++)e.yearshtml+="<option value='"+f+"'"+(f===i?" selected='selected'":"")+">"+f+"</option>";e.yearshtml+="</select>",b+=e.yearshtml,e.yearshtml=null}return b+=this._get(e,"yearSuffix"),y&&(b+=(!a&&g&&v?"":" ")+_),b+="</div>"},_adjustInstDate:function(e,t,i){var s=e.drawYear+("Y"===i?t:0),n=e.drawMonth+("M"===i?t:0),a=Math.min(e.selectedDay,this._getDaysInMonth(s,n))+("D"===i?t:0),o=this._restrictMinMax(e,this._daylightSavingAdjust(new Date(s,n,a)));e.selectedDay=o.getDate(),e.drawMonth=e.selectedMonth=o.getMonth(),e.drawYear=e.selectedYear=o.getFullYear(),("M"===i||"Y"===i)&&this._notifyChange(e)},_restrictMinMax:function(e,t){var i=this._getMinMaxDate(e,"min"),s=this._getMinMaxDate(e,"max"),n=i&&i>t?i:t;return s&&n>s?s:n},_notifyChange:function(e){var t=this._get(e,"onChangeMonthYear");t&&t.apply(e.input?e.input[0]:null,[e.selectedYear,e.selectedMonth+1,e])},_getNumberOfMonths:function(e){var t=this._get(e,"numberOfMonths");return null==t?[1,1]:"number"==typeof t?[1,t]:t},_getMinMaxDate:function(e,t){return this._determineDate(e,this._get(e,t+"Date"),null)},_getDaysInMonth:function(e,t){return 32-this._daylightSavingAdjust(new Date(e,t,32)).getDate()},_getFirstDayOfMonth:function(e,t){return new Date(e,t,1).getDay()},_canAdjustMonth:function(e,t,i,s){var n=this._getNumberOfMonths(e),a=this._daylightSavingAdjust(new Date(i,s+(0>t?t:n[0]*n[1]),1));return 0>t&&a.setDate(this._getDaysInMonth(a.getFullYear(),a.getMonth())),this._isInRange(e,a)},_isInRange:function(e,t){var i,s,n=this._getMinMaxDate(e,"min"),a=this._getMinMaxDate(e,"max"),o=null,r=null,h=this._get(e,"yearRange");return h&&(i=h.split(":"),s=(new Date).getFullYear(),o=parseInt(i[0],10),r=parseInt(i[1],10),i[0].match(/[+\-].*/)&&(o+=s),i[1].match(/[+\-].*/)&&(r+=s)),(!n||t.getTime()>=n.getTime())&&(!a||t.getTime()<=a.getTime())&&(!o||t.getFullYear()>=o)&&(!r||r>=t.getFullYear())},_getFormatConfig:function(e){var t=this._get(e,"shortYearCutoff");return t="string"!=typeof t?t:(new Date).getFullYear()%100+parseInt(t,10),{shortYearCutoff:t,dayNamesShort:this._get(e,"dayNamesShort"),dayNames:this._get(e,"dayNames"),monthNamesShort:this._get(e,"monthNamesShort"),monthNames:this._get(e,"monthNames")}},_formatDate:function(e,t,i,s){t||(e.currentDay=e.selectedDay,e.currentMonth=e.selectedMonth,e.currentYear=e.selectedYear);var n=t?"object"==typeof t?t:this._daylightSavingAdjust(new Date(s,i,t)):this._daylightSavingAdjust(new Date(e.currentYear,e.currentMonth,e.currentDay));return this.formatDate(this._get(e,"dateFormat"),n,this._getFormatConfig(e))}}),e.fn.datepicker=function(t){if(!this.length)return this;e.datepicker.initialized||(e(document).mousedown(e.datepicker._checkExternalClick),e.datepicker.initialized=!0),0===e("#"+e.datepicker._mainDivId).length&&e("body").append(e.datepicker.dpDiv);var i=Array.prototype.slice.call(arguments,1);return"string"!=typeof t||"isDisabled"!==t&&"getDate"!==t&&"widget"!==t?"option"===t&&2===arguments.length&&"string"==typeof arguments[1]?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i)):this.each(function(){"string"==typeof t?e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this].concat(i)):e.datepicker._attachDatepicker(this,t)}):e.datepicker["_"+t+"Datepicker"].apply(e.datepicker,[this[0]].concat(i))},e.datepicker=new n,e.datepicker.initialized=!1,e.datepicker.uuid=(new Date).getTime(),e.datepicker.version="1.11.4",e.datepicker,e.widget("ui.tooltip",{version:"1.11.4",options:{content:function(){var t=e(this).attr("title")||"";return e("<a>").text(t).html()},hide:!0,items:"[title]:not([disabled])",position:{my:"left top+15",at:"left bottom",collision:"flipfit flip"},show:!0,tooltipClass:null,track:!1,close:null,open:null},_addDescribedBy:function(t,i){var s=(t.attr("aria-describedby")||"").split(/\s+/);s.push(i),t.data("ui-tooltip-id",i).attr("aria-describedby",e.trim(s.join(" ")))},_removeDescribedBy:function(t){var i=t.data("ui-tooltip-id"),s=(t.attr("aria-describedby")||"").split(/\s+/),n=e.inArray(i,s);-1!==n&&s.splice(n,1),t.removeData("ui-tooltip-id"),s=e.trim(s.join(" ")),s?t.attr("aria-describedby",s):t.removeAttr("aria-describedby")},_create:function(){this._on({mouseover:"open",focusin:"open"}),this.tooltips={},this.parents={},this.options.disabled&&this._disable(),this.liveRegion=e("<div>").attr({role:"log","aria-live":"assertive","aria-relevant":"additions"}).addClass("ui-helper-hidden-accessible").appendTo(this.document[0].body)},_setOption:function(t,i){var s=this;return"disabled"===t?(this[i?"_disable":"_enable"](),this.options[t]=i,void 0):(this._super(t,i),"content"===t&&e.each(this.tooltips,function(e,t){s._updateContent(t.element)}),void 0)},_disable:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur");n.target=n.currentTarget=s.element[0],t.close(n,!0)}),this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.is("[title]")&&t.data("ui-tooltip-title",t.attr("title")).removeAttr("title")})},_enable:function(){this.element.find(this.options.items).addBack().each(function(){var t=e(this);t.data("ui-tooltip-title")&&t.attr("title",t.data("ui-tooltip-title"))})},open:function(t){var i=this,s=e(t?t.target:this.element).closest(this.options.items);s.length&&!s.data("ui-tooltip-id")&&(s.attr("title")&&s.data("ui-tooltip-title",s.attr("title")),s.data("ui-tooltip-open",!0),t&&"mouseover"===t.type&&s.parents().each(function(){var t,s=e(this);s.data("ui-tooltip-open")&&(t=e.Event("blur"),t.target=t.currentTarget=this,i.close(t,!0)),s.attr("title")&&(s.uniqueId(),i.parents[this.id]={element:this,title:s.attr("title")},s.attr("title",""))}),this._registerCloseHandlers(t,s),this._updateContent(s,t))},_updateContent:function(e,t){var i,s=this.options.content,n=this,a=t?t.type:null;return"string"==typeof s?this._open(t,e,s):(i=s.call(e[0],function(i){n._delay(function(){e.data("ui-tooltip-open")&&(t&&(t.type=a),this._open(t,e,i))})}),i&&this._open(t,e,i),void 0)},_open:function(t,i,s){function n(e){l.of=e,o.is(":hidden")||o.position(l)}var a,o,r,h,l=e.extend({},this.options.position);if(s){if(a=this._find(i))return a.tooltip.find(".ui-tooltip-content").html(s),void 0;i.is("[title]")&&(t&&"mouseover"===t.type?i.attr("title",""):i.removeAttr("title")),a=this._tooltip(i),o=a.tooltip,this._addDescribedBy(i,o.attr("id")),o.find(".ui-tooltip-content").html(s),this.liveRegion.children().hide(),s.clone?(h=s.clone(),h.removeAttr("id").find("[id]").removeAttr("id")):h=s,e("<div>").html(h).appendTo(this.liveRegion),this.options.track&&t&&/^mouse/.test(t.type)?(this._on(this.document,{mousemove:n}),n(t)):o.position(e.extend({of:i},this.options.position)),o.hide(),this._show(o,this.options.show),this.options.show&&this.options.show.delay&&(r=this.delayedShow=setInterval(function(){o.is(":visible")&&(n(l.of),clearInterval(r))},e.fx.interval)),this._trigger("open",t,{tooltip:o})}},_registerCloseHandlers:function(t,i){var s={keyup:function(t){if(t.keyCode===e.ui.keyCode.ESCAPE){var s=e.Event(t);s.currentTarget=i[0],this.close(s,!0)}}};i[0]!==this.element[0]&&(s.remove=function(){this._removeTooltip(this._find(i).tooltip)}),t&&"mouseover"!==t.type||(s.mouseleave="close"),t&&"focusin"!==t.type||(s.focusout="close"),this._on(!0,i,s)},close:function(t){var i,s=this,n=e(t?t.currentTarget:this.element),a=this._find(n);return a?(i=a.tooltip,a.closing||(clearInterval(this.delayedShow),n.data("ui-tooltip-title")&&!n.attr("title")&&n.attr("title",n.data("ui-tooltip-title")),this._removeDescribedBy(n),a.hiding=!0,i.stop(!0),this._hide(i,this.options.hide,function(){s._removeTooltip(e(this))}),n.removeData("ui-tooltip-open"),this._off(n,"mouseleave focusout keyup"),n[0]!==this.element[0]&&this._off(n,"remove"),this._off(this.document,"mousemove"),t&&"mouseleave"===t.type&&e.each(this.parents,function(t,i){e(i.element).attr("title",i.title),delete s.parents[t]}),a.closing=!0,this._trigger("close",t,{tooltip:i}),a.hiding||(a.closing=!1)),void 0):(n.removeData("ui-tooltip-open"),void 0)},_tooltip:function(t){var i=e("<div>").attr("role","tooltip").addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content "+(this.options.tooltipClass||"")),s=i.uniqueId().attr("id");return e("<div>").addClass("ui-tooltip-content").appendTo(i),i.appendTo(this.document[0].body),this.tooltips[s]={element:t,tooltip:i}},_find:function(e){var t=e.data("ui-tooltip-id");return t?this.tooltips[t]:null},_removeTooltip:function(e){e.remove(),delete this.tooltips[e.attr("id")]},_destroy:function(){var t=this;e.each(this.tooltips,function(i,s){var n=e.Event("blur"),a=s.element;n.target=n.currentTarget=a[0],t.close(n,!0),e("#"+i).remove(),a.data("ui-tooltip-title")&&(a.attr("title")||a.attr("title",a.data("ui-tooltip-title")),a.removeData("ui-tooltip-title"))}),this.liveRegion.remove()}})});; 9/*/csx/src/Core/public/generic.js*/; 10if(typeof(TZR)=="undefined") TZR=new Object(); 11if(typeof(TZR._sharescripts)=="undefined") TZR._sharescripts="/scripts/"; 12if(typeof(TZR._sharetemplates)=="undefined") TZR._sharetemplates="/templates/"; 13TZR.isFormOk=true; 14TZR.formValidation=true; 15TZR.validator=new Array(); 16TZR.dependency=new Object(); 17TZR.onsubmit=new Array(); 18// validation des formulaires 19TZR.isShortTextValid = function (id,fmt,fieldlabel,color) { 20 var o = document.getElementById(id); 21 var phrase = o.value; 22 var resultat = fmt.test(phrase); 23 if(!resultat) { 24 TZR.setElementErrorState(o,false,color); 25 TZR.isFormOk=false; 26 return false; 27 } else { 28 TZR.setElementErrorState(o,true,color); 29 return true; 30 } 31} 32// champ doucment de la base doc 33TZR.isDocumentValid = function (val) { 34 35 var varid = val[0], color = val[3], inputid = val[5]; 36 var input = document.getElementById(inputid); 37 var doid = document.getElementById(varid).value; 38 if(doid=="") { 39 TZR.setElementErrorState(input,false,color); 40 TZR.isFormOk=false; 41 return false;
42 } else { 43 TZR.setElementErrorState(input,true,color); 44 return true; 45 } 46 47} 48 49// validation des formulaires des champs evalutaiton/rating 50TZR.isEvalValid = function (id,fmt,fieldlabel,color,linktext,listid) { 51 if (fmt != '/(.+)/'){ 52 return; 53 } 54 var o = jQuery("#container"+id); 55 if (o.data('clicked') != 1){ 56 TZR.setElementErrorState(o.parent(),false,color); 57 TZR.isFormOk=false; 58 return false; 59 } else { 60 TZR.setElementErrorState(o.parent(),true,color); 61 return true; 62 } 63} 64// Validation d'un champ user 65TZR.isUserFieldValid = function(inputid, fmt, fieldname, color, varid){ 66 TZR.UserSelector.isValid.call(TZR.UserSelector, varid, fmt, color); 67}; 68// validation des formulaires 69TZR.isLinkValid = function (id,fmt,fieldlabel,color,linktext,listid) { 70 if (typeof arguments[5] == "object" 71 && typeof arguments[5].treeviewmode != "undefined" 72 && arguments[5].treeviewmode === true) 73 return TZR.xlinkdef_treeview.isValid.call(TZR.xlinkdef_treeview, arguments[5].id, fmt, color); 74 75 var o = document.getElementById(id); 76 var typ=o.type; 77 // Cas "radio" ou "checkbox" 78 if(typ=="radio" || typ=="checkbox"){ 79 return TZR.isRadioValid(id,fmt,fieldlabel,color,linktext,listid); 80 }else{ 81 var resultat = true; 82 // Cas "un select" 83 if(fmt=='compselect'){ 84 resultat = false; 85 for(var i=0;i<o.options.length;i++){ 86 if(o.options[i]!=null && o.options[i].selected && o.options[i].value!=''){ 87 resultat=true; 88 break; 89 } 90 } 91 }else if(fmt=='') { // Cas "2 select non obligatoire" 92 for(var i=0;i<o.options.length;i++) if(o.options[i]!=null) o.options[i].selected=true; 93 } else if(fmt=='/(.+)/') { // Cas "2 select obligatoire" 94 if(o.options.length==0) resultat=false; 95 else for(var i=0;i<o.options.length;i++) if(o.options[i]!=null) o.options[i].selected=true; 96 } else if(document.getElementById("table"+id)!=undefined){ // Cas autocomplete multiple 97 if(document.getElementById("table"+id).tBodies[0].rows.length<2) resultat=false; 98 o=document.getElementById(linktext); 99 } else { // Autre cas : autocomplete, lien base doc... 100 var phrase = o.value; 101 var resultat = fmt.test(phrase); 102 if(linktext){ 103 o=document.getElementById(linktext); 104 } 105 } 106 if(!resultat) { 107 TZR.setElementErrorState(o,false,color); 108 TZR.isFormOk=false; 109 return false; 110 } else { 111 TZR.setElementErrorState(o,true,color); 112 return true; 113 } 114 } 115} 116TZR.isRadioValid = function (id,fmt,fieldlabel,color,linktext,listid) { 117 var resultat=false; 118 var o=document.getElementById(id); 119 var l=listid.length; 120 for(var i=0;i<l;i++){ 121 if(document.getElementById(listid[i]).checked){ 122 resultat=true; 123 break; 124 } 125 } 126 var tab=TZR.getParent(o,'TABLE'); 127 if(!resultat){ 128 TZR.setElementErrorState(o,false,color,tab); 129 TZR.isFormOk=false; 130 return false; 131 } else { 132 TZR.setElementErrorState(o,true,color,tab); 133 return true; 134 } 135} 136TZR.isThesaurusValid=function(id,fmt,fieldlabel,color){ 137 var o=document.getElementById("div"+id); 138 var ok=false; 139 jQuery('#table'+id+" input").each(function(i){ 140 if(this.value!=''){ 141 ok=true; 142 return false; 143 } 144 }); 145 if(!ok){ 146 TZR.setElementErrorState(o,false,color); 147 TZR.isFormOk=false; 148 return false; 149 } else { 150 TZR.setElementErrorState(o,true,color); 151 return true; 152 } 153} 154TZR.isConsentValid = function(id,label,color){ 155 var o=document.getElementById(id); 156 return o.checked; 157} 158TZR.isCaptchaValid = function(id,fmt,fieldlabel,color){ 159 var response=0; 160 o=document.getElementById(id); 161 jQuery.ajax({async:false, 162 url:TZR._sharescripts+"ajax8.php?class=_Seolan_Module_Table_Table&function=xmodtable_captcha", 163 cache:false, 164 data:{value:o.value,id:id}, 165 success:function(resp){response=resp;} 166 }); 167 if(response=='0') response=false; 168 else response=true; 169 if(!response) { 170 document.getElementById("ca"+id).onclick(); 171 document.getElementById(id).value=""; 172 TZR.setElementErrorState(o,false,color); 173 TZR.isFormOk=false; 174 return false; 175 } else {
176 TZR.setElementErrorState(o,true,color); 177 TZR.isFormOk=true; 178 return true; 179 } 180} 181TZR.isUploaderValid = function (id,fmt,fieldlabel,color,allow_externalfile) { 182 var compulsory = document.getElementById(id).dataset.compulsory; 183 var o=jQuery('#'+id+"_cont"); 184 var tocol = o; 185 var oldfile = document.getElementById(id+'-old'); 186 var external = allow_externalfile ? document.getElementById(id+'-external').value : ''; 187 // upload en cours ou 188 // obligatoire sans au moins un fichier et pas encore renseigné (old) 189 if((TZR.uploadInProgressFiles[id]>0) || (compulsory == '1' && !TZR.uploadXFileCompleted[id] && oldfile && oldfile.value == '' && external =='')) { 190 TZR.setElementErrorState(o,false,color,tocol); 191 TZR.isFormOk=false; 192 return false; 193 } 194 TZR.setElementErrorState(o,true,color,tocol); 195 return true; 196 } 197 198/** 199 * Conversion d'une taille de fichier en octets en unité de stockage correspondante 200 */ 201function sizeToString(size,precision) { 202 precision = precision || 0; 203 var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; 204 var bytes = Math.max(size, 0); 205 var pow = Math.min( Math.floor( (bytes ? Math.log(bytes) : 0) / Math.log(1024) ), units.length); 206 return Math.round(bytes >>= (10 * pow), precision) + ' ' + units[pow]; 207} 208 209/** 210 * Analyse le header d'un blob (ex: fichier) et retourne le mime type correspondant 211 */ 212function getFileMimeType(blob) { 213 var fileReader = new FileReader(); 214 fileReader.onloadend = function(e) { 215 var arr = (new Uint8Array(e.target.result)).subarray(0, 4); 216 var header = ''; 217 for(var i = 0; i < arr.length; i++) { 218 header += arr[i].toString(16); 219 } 220 var type = null; 221 switch (header) { 222 case '89504e47': 223 type = 'image/png'; 224 break; 225 case '47494638': 226 type = 'image/gif'; 227 break; 228 case '0000000c6a5020200d0a870a': 229 type = 'image/jp2'; 230 break; 231 case 'ffd8': 232 case 'ffd8ffe0': 233 type = 'image/jpeg'; 234 break; 235 case '424D': 236 type = 'image/bmp'; 237 break; 238 case '49492a00': 239 case '4d4d002a': 240 case '4d4d002b': 241 case '492049': 242 type = 'image/tiff'; 243 break; 244 case '52494646': 245 type = 'image/webp'; 246 break; 247 default: 248 type = blob.type; 249 break; 250 } 251 return type; 252 }; 253 fileReader.readAsArrayBuffer(blob); 254} 255TZR.isFileValid = function (id,fmt,fieldlabel,color,browsemods,allow_externalfile) { 256 // Exception : BO + Uploader Async OFF si AJAX_UPLOADER n'est pas défini 257 // (En BO, le Async est forcé donc pb de ciblage de fonction de validation : TZR.isFileValid => TZR.isUploaderValid) 258 if(document.getElementById(id + '_cont')) { 259 return TZR.isUploaderValid(id,fmt,fieldlabel,color,allow_externalfile); 260 } var o = document.getElementById(id); 261 var tocol = o; 262 // MaxSize + Mimes 263 if(o.files && o.files.length > 0) { 264 // MaxSize 265 var checkSize = true; 266 var maxSize = o.dataset.maxsize; 267 if(maxSize !== undefined && maxSize != '') { 268 var fileSize = o.files[0].size; 269 checkSize = fileSize === undefined || maxSize && fileSize < maxSize; 270 } 271 // Mimes 272 var accept = o.getAttribute('accept'); 273 var fileType = getFileMimeType(o.files[0]); 274 if(fileType === undefined) 275 fileType = o.files[0].type; 276 var checkType = accept === null || accept === '' || accept.indexOf(fileType) >= 0; 277 if( checkSize && checkType) { 278 TZR.setCustomValidityMess(id, ''); 279 TZR.setElementErrorState(o,true,color,tocol); 280 } else { 281 TZR.setElementErrorState(o,false,color,tocol); 282 TZR.isFormOk = false; 283 if (!checkType) 284 TZR.setCustomValidityMess(id, TZR.uploadFileAllowedType + accept); 285 else if (!checkSize) 286 TZR.setCustomValidityMess(id, TZR.uploadFileMaxSizeError + sizeToString(maxSize)); 287 return false; 288 } 289 } 290 // Obligatoire 291 var compulsory = o.dataset.compulsory; 292 if(compulsory == '1') { 293 o.isValid = false; 294 if (o.value != '' || document.getElementById(id+'-old').value != '') 295 o.isValid = true; 296 else if (browsemods && document.getElementById(id+'-from').value != '') 297 o.isValid = true; 298 else if (allow_externalfile && document.getElementById(id+'-external').value != '') 299 o.isValid = true; 300 else if (jQuery('#'+id+'_cont').length) { 301 tocol = jQuery('#'+id+'_cont'); 302 if(jQuery('#'+id+'_cont div.uploadQueueItem.uploadComplete:first').length) 303 o.isValid = true; 304 } 305 TZR.setElementErrorStyle(o,color,tocol); 306 if (!o.isValid) { 307 TZR.isFormOk = false;
308 } 309 } 310 return o.isValid; 311} 312TZR.isPassWordValid = function(val){ 313 var isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]); 314 var o1 = document.getElementById(val[0]); 315 if (isValid && val[5] == "1"){ // avec confirmation 316 if (typeof(val[6]) == 'string') 317 var o = document.getElementById(val[6]); 318 else 319 var o = document.getElementById(val[0]+'_HID'); 320 // check si le confirm était en erreur (donc saisi) pour refresh 321 if (o != null && typeof(o.isValid) != "undefined" && o.isValid == false){ 322 TZR.checkConfirmValid(o.getAttribute("id"), val[0], val[3]); 323 } 324 } 325 return isValid; 326} 327TZR.isConfirmValid=function(id, mainid, color){ 328 // validité du parent 329 if (!TZR.isIdValid(mainid)){ 330 return; 331 } 332 return TZR.checkConfirmValid(id, mainid, color); 333} 334TZR.checkConfirmValid = function(id, mainid, color){ 335 // égalité du contenu 336 var o = document.getElementById(id); 337 var reg = new RegExp('^'+RegExp.escape(document.getElementById(mainid).value)+'$'); 338 o.isValid = reg.test(o.value); 339 if (!o.isValid){ 340 TZR.isFormOk=false; 341 } 342 TZR.setElementErrorState(o,o.isValid,color); 343 return o.isValid; 344} 345TZR.setElementErrorState=function(o,state,color,tocol){ 346 o.isValid=state; 347 TZR.setElementErrorStyle(o,color,tocol); 348} 349TZR.setElementErrorStyle=function(o,color,tocol){ 350 if(!tocol) tocol=o; 351 tocol=jQuery(tocol); 352 if(!tocol[0]) return; 353 354 if(o.isValid==false){ 355 if(tocol[0].isError) return; 356 tocol[0].isError=true; 357 if(color.charAt(0)=='#') { 358 tocol[0].obackgroundColor=tocol[0].style.backgroundColor; 359 tocol.css('background-color',color); 360 } else { 361 tocol.addClass(color); 362 } 363 } else { 364 if(!tocol[0].isError) return; 365 tocol[0].isError=false; 366 if(color.charAt(0)=='#') { 367 if(tocol[0].obackgroundColor) tocol.css('background-color',tocol[0].obackgroundColor); 368 else tocol.css('background-color',''); 369 } else { 370 tocol.removeClass(color); 371 } 372 } 373} 374TZR.isFormValidWithAjax=function(f,method,overlay_target,color,callback){ 375 if(typeof f!=='object') f=document.getElementById(f); 376 // Vide les erreurs précédentes 377 var error_el=jQuery('div.error',f); 378 error_el.html(''); 379 // Prepare les données 380 var data=jQuery(f).serializeArray(); 381 for(var i in data){ 382 if(data[i].name=="function" || data[i].name=="_function") data[i].value=method; 383 if(data[i].name=="uniqid") delete data[i]; 384 } 385 data.push({name:'_raw', value:1}); 386 data.push({name:'_ajax', value:1}); 387 // fichier (tests types ....) 388 jQuery("input[type='file']", jQuery(f)).each(function(i, o){ 389 data.push({name:o.name, value:o.value}); 390 }); 391 // Overlay 392 if(overlay_target){ 393 if(overlay_target=='module-container') overlay_target=jQuery(f).parents('div.cv8-module-container'); 394 else overlay_target=jQuery(overlay_target); 395 var overlay=TZR.setOverlay(overlay_target); 396 }else{ 397 var overlay=null; 398 } 399 // Envoi 400 var ok=false; 401 jQuery.ajax({ 402 dataType:"json", 403 url:f.action, 404 data:data, 405 async:false, 406 type:f.method 407 }).done(function(data){ 408 if(overlay) TZR.unsetOverlay(overlay); 409 if(data.status=="success"){ 410 ok=true; 411 if(callback) callback(true,data); 412 }else{ 413 TZR.isFormOk=false; 414 if(callback){ 415 if(callback(false,data)===false) return; 416 } 417 if(data.error){ 418 for(var i in data.error){ 419 error_el.append('<div class="error_message">'+data.error[i]+'</div>'); 420 } 421 error_el.show(); 422 } 423 } 424 }); 425 return ok; 426} 427TZR.isIntervalValid = function (id,fmt,fieldlabel,color) { 428 var hiddenField = document.getElementById(id); 429 var pictoCalendar = jQuery('#pictoCalendar' + id); 430 var phrase = hiddenField.value; 431 var resultat = fmt.test(phrase); 432 if (!resultat) { 433 pictoCalendar.css("border", "1px solid red"); 434 TZR.isFormOk = false; 435 return false; 436 } 437 pictoCalendar.css("border", ""); 438 return true; 439} 440TZR.isJsonValid = function(id, color) { 441 var o = document.getElementById(id); 442 var str = o.value; 443 var isValid = true; 444 if(str !== "") { 445 try { 446 var json = JSON.parse(str); 447 isValid = (typeof str === 'string' && typeof json === 'object'); 448 } 449 catch(e) { 450 isValid = false;
451 } 452 } 453 TZR.setElementErrorState(o, isValid, color); 454 TZR.isFormOk = isValid; 455 return isValid; 456} 457TZR.actualizeCaptcha=function(url,id){ 458 document.getElementById('cimg'+id).src=url+"?id="+id+"&"+(new Date()).getTime(); 459} 460TZR.getUrlTitle=function(varid,color){ 461 var urlu=document.getElementById("url"+varid); 462 var urll=document.getElementById("label"+varid); 463 urlu.style.backgroundImage="url('/tzr/templates/ico/general/indicator.gif')"; 464 urlu.style.backgroundPosition="right center"; 465 urlu.style.backgroundRepeat="no-repeat"; 466 var reg=/^(((?!mailto)(?!\[)).+)$/; 467 if(!reg.test(urlu.value)){ // mail ou un alias console 468 urlu.obackgroundColor=urlu.style.backgroundColor; 469 urlu.style.backgroundColor=color; 470 }else{ 471 var title=TZR.file_get_contents(TZR._sharescripts+'ajax8.php?function=xurldef_getPageTitle&class=\\Seolan\\Field\\Url\\Url&url='+escape(urlu.value)); 472 if(title=="error"){ 473 urlu.obackgroundColor=urlu.style.backgroundColor; 474 urlu.style.backgroundColor=color; 475 }else{ 476 if(urlu.obackgroundColor) urlu.style.backgroundColor=urlu.obackgroundColor; 477 else urlu.style.backgroundColor=''; 478 urll.value=title; 479 } 480 } 481 urlu.style.backgroundImage=""; 482 urlu.style.backgroundPosition=""; 483 urlu.style.backgroundRepeat=""; 484} 485TZR.openPopup = function(url){ 486 window.open(url,'','menubar=no,status=no,resizable=1,scrollbars=1,width=700,height=500'); 487 return false; 488} 489TZR.validFormInPopup = function(f){ 490 var ret=TZR.isFormValidWithFocus(f,true); 491 if(ret){ 492 window.opener.name=TZR.uniqid('TZR'); 493 document.editform.target=window.opener.name; 494 f.submit(); 495 self.close(); 496 return false; 497 }else{ 498 return false; 499 } 500} 501TZR.isFormValid = function (f) { 502 return TZR.isFormValidWithFocus(f,false); 503} 504TZR.isFormValidWithFocus=function(f,foc) { 505 TZR.isFormOk=true; 506 TZR.errorGiveFocus=true; 507 for(var i=0;i<TZR.validator.length;i++){ 508 if (typeof TZR.validator[i][0] == "function")
509 var o = TZR.validator[i][0](TZR.validator[i]); 510 else if(typeof TZR.validator[i][0]!=='object') 511 var o=document.getElementById(TZR.validator[i][0]); 512 else 513 var o=TZR.validator[i][0]; // ? contrôle du formulaire en ajax 514 515 if(o!=null && (o==f || o.form==f) && !jQuery(o).prop('data-disabled')) { 516 if(TZR.validator[i][99]){ 517 TZR.isIdxValid(i); 518 if(foc) { 519 if(!TZR.isFormOk) { 520 if(!TZR.errorGiveFocus) return false; 521 if(TZR.validator[i][5]){ 522 if(typeof TZR.validator[i][5]=='string') o=document.getElementById(TZR.validator[i][5]); 523 else o=TZR.validator[i][5]; 524 } 525 jQuery(o).parents('fieldset.fieldsetAccordionClose').find('>legend').click(); 526 var tabid = jQuery(o).parents('.tzr-tabcontent').attr('id'); 527 if (typeof(tabid) != "undefined" ){ 528 jQuery('li>a[href="#'+tabid+'"]').click(); 529 } 530 jQuery(o).focus(); 531 if(jQuery(o).is(':not(:input),:hidden')) scrollToElement(jQuery(o).closest(':visible')); 532 return false; 533 } 534 } 535 } 536 }else if(!o){ 537 TZR.validator.splice(i,1); 538 i--; 539 } 540 } 541 nb=TZR.onsubmit.length; 542 for(i=0; i<nb; i++) { 543 eval(TZR.onsubmit[i]); 544 } 545 if(!TZR.isFormOk) { 546 if(typeof(TZR.customValid)!='undefined') 547 return TZR.customValid(f); 548 else 549 return confirm('Some data are not valid. Save anyway ?'); 550 } 551 return true; 552} 553TZR.isIdxValid = function (i) { 554 var isValid=false; 555 var val=TZR.validator[i]; 556 if(val[4]=='Form') 557 isValid=TZR.isFormValidWithAjax(val[0],val[1],val[2],val[3],val[6]); 558 else if(val[4]=='\Seolan\Field\ShortText\ShortText') 559 isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]); 560 else if(val[4]=='\Seolan\Field\Real\Real') 561 isValid=TZR.isShortTextValid(val[0],val[1],val[2],val[3]); 562 else if(val[4]=='\Seolan\Field\Rating\Rating') 563 isValid=TZR.isEvalValid(val[0],val[1],val[2],val[3]); 564 else if(val[4]=='\Seolan\Field\Password\Password') 565 isValid=TZR.isPassWordValid(val); 566 else if(val[4]=='Confirm') 567 isValid=TZR.isConfirmValid(val[0],val[5],val[3],i); 568 else if(val[4]=='\Seolan\Field\Document\Document') 569 isValid=TZR.isDocumentValid(val); 570 else if(val[4]=='\Seolan\Field\Link\Link') 571 isValid=TZR.isLinkValid(val[0],val[1],val[2],val[3],val[5],val[6]); 572 else if(val[4]=='\Seolan\Field\User\User') 573 isValid=TZR.isUserFieldValid(val[0],val[1],val[2],val[3],val[5],val[6]); 574 else if(val[4]=='\Seolan\Field\StringSet\StringSet') 575 isValid=TZR.isLinkValid(val[0],val[1],val[2],val[3],val[5],val[6]); 576 else if(val[4]=='\Seolan\Field\Thesaurus\Thesaurus') 577 isValid=TZR.isThesaurusValid(val[0],val[1],val[2],val[3]); 578 else if(val[4]=='Captcha') 579 isValid=TZR.isCaptchaValid(val[0],val[1],val[2],val[3]); 580 else if(val[4]=='XFileUploader') 581 isValid=TZR.isUploaderValid(val[0],val[1],val[2],val[3],val[7]); 582 else if(val[4]=='\Seolan\Field\File\File') 583 isValid=TZR.isFileValid(val[0],val[1],val[2],val[3],val[6],val[7]); 584 else if(val[4]=='\Seolan\Field\Interval\Interval') 585 isValid=TZR.isIntervalValid(val[0],val[1],val[2],val[3],val[6],val[7]); 586 else if (val[4]=='Consent') 587 isValid=TZR.isConsentValid(val[0],val[1],val[2],val[3]); 588 else if(val[4]=='\Seolan\Field\Serialize\Serialize') 589 isValid=TZR.isJsonValid(val[0],val[3]); 590 return isValid; 591} 592TZR.autoCompleteCache = {}; 593TZR.addAutoComplete=function(id) { 594 var acfield = jQuery("#_INPUT" + id), hiddenfield; 595 if (acfield.length) { 596 hiddenfield = document.getElementById(id); 597 } else { // cas shorttext edit 598 acfield = jQuery("#" + id); 599 } 600 // init/empty cache 601 TZR.autoCompleteCache[acfield.attr('id')] = {}; 602 var _minLength = acfield.data("autocomplete").minlength!=undefined?acfield.data("autocomplete").minlength:3; 603 acfield.keydown(function(event) { 604 if(event.keyCode!=13 && event.keyCode!=9 && hiddenfield) 605 hiddenfield.value=""; 606 }).autocomplete({ 607 autoFocus: true, 608 delay: 500, 609 minLength:_minLength, 610 source : function(request, response) { 611 var autocomplete = this.element.data('autocomplete'); 612 // check cache 613 var term = request.term.toLowerCase().trim(), 614 cache = TZR.autoCompleteCache[acfield.attr('id')]; 615 616 if (cache && cache[term]) { 617 response(cache[term]); 618 return; 619 } 620 for (cachedTerm in cache) { 621 try { 622 var regexp = new RegExp((autocomplete.params.prefixSearch ? '^' : '') + cachedTerm); 623 if (regexp.test(term) && !cache[cachedTerm]) { 624 response(); 625 return false;
626 } 627 } 628 catch (e) {} 629 } 630 631 jQuery.ajax({ 632 url: autocomplete.url + '&q=' + request.term, 633 dataType: "json", 634 data: autocomplete.params, 635 success: function(data) { 636 if (data !== null) { 637 for(var i=0; i<data.length; i++){ 638 // if not object value must be a string 639 if (typeof(data[i]) == "number"){ 640 data[i] = data[i].toString(); 641 } 642 } 643 } 644 TZR.autoCompleteCache[acfield.attr('id')][term] = data; 645 response(data); 646 } 647 }); 648 }, 649 select : function(event, ui) { 650 var autocomplete = jQuery(this).data('autocomplete'); 651 if (autocomplete.callback && typeof autocomplete.callback == 'function') { 652 autocomplete.callback(autocomplete.params.id, ui.item.value, ui.item.label); 653 } else { 654 if (hiddenfield) { 655 hiddenfield.value = ui.item.value; 656 } 657 acfield.val(ui.item.label); 658 } 659 jQuery(hiddenfield).change(); 660 return false; // job done 661 }, 662 open: function() { 663 jQuery('.ui-autocomplete').css({width:'300px', zIndex:99999}); 664 }, 665 focus: function( event, ui ) { 666 event.preventDefault(); 667 } 668 }).on('focus', function(e) { 669 if(_minLength==0) 670 jQuery(this).autocomplete( "search", "%" ); 671 }); 672} 673 674TZR.autoCompleteTagCache = {}; 675TZR.addAutoCompleteTag=function(id, options) { 676 options = jQuery.extend({count:2, list:false, textskey:'#'},options); 677 var hiddenfield = document.getElementById(id), 678 acfield = jQuery("#_INPUT"+id), 679 alive = false; 680 // init/empty cache 681 TZR.autoCompleteTagCache[acfield.attr('id')] = {}; 682 acfield.keydown(function(event) { 683 if(event.keyCode!=13 && event.keyCode!=9 && hiddenfield) hiddenfield.value=""; 684 if(event.keyCode==13) { 685 event.preventDefault(); 686 return false; 687 } 688 }).autocomplete({ 689 autoFocus: true, 690 delay: 500, 691 minLength: options.count, 692 create: function() { 693 if(options.list) { 694 var self = this; 695 jQuery(self).data('ui-autocomplete').close = function(e) { 696 if(alive) { 697 return false; 698 } 699 this.cancelSearch = true; 700 this._close( e ); 701 } 702 703 alive = true; 704 jQuery(jQuery(self).data('ui-autocomplete').bindings[1]).on('mouseenter', function(e) { 705 alive = true; 706 }); 707 jQuery(jQuery(self).data('ui-autocomplete').bindings[1]).on('mouseleave', function(e) { 708 alive = false; 709 setTimeout( 710 function(){ 711 if (!alive) { 712 jQuery(self).data('ui-autocomplete').close(); 713 } 714 }, 500 715 ); 716 }); 717 } 718 }, 719 source : function(request, response) { 720 // check cache 721 request.term = request.term.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); 722 var term = request.term.toLowerCase().trim(), 723 cache = TZR.autoCompleteTagCache[acfield.attr('id')]; 724 725 if (cache && cache[term]) { 726 response(cache[term]); 727 return; 728 } 729 var autocomplete = this.element.data('autocomplete'); 730 jQuery.ajax({ 731 url: autocomplete.url + '&q=' + request.term, 732 dataType: "json", 733 data: autocomplete.params, 734 success: function(data) { 735 if (!TZR.autoCompleteTagCache[acfield.attr('id')]) { 736 TZR.autoCompleteTagCache[acfield.attr('id')] = {}; 737 } 738 TZR.autoCompleteTagCache[acfield.attr('id')][term] = data; 739 response(data); 740 }, 741 }); 742 }, 743 select : function(event, ui) { 744 var autocomplete = jQuery(this).data('autocomplete'); 745 if (autocomplete.callback && typeof autocomplete.callback == 'function') { 746 autocomplete.callback(autocomplete.params.id, ui.item.value, ui.item.label, true); 747 } else { 748 if (hiddenfield) { 749 hiddenfield.value = ui.item.value; 750 } 751 acfield.val(ui.item.label); 752 } 753 jQuery(hiddenfield).change(); 754 return false; // job done 755 }, 756 open: function() { 757 jQuery('.ui-autocomplete').css({width: '300px'}); 758 }, 759 focus: function( event, ui ) { 760 event.preventDefault(); 761 } 762 }).on('focus click', function(e) { 763 jQuery(this).autocomplete( "search", "" ); 764 }); 765} 766 767TZR.autoCompleteTagSearchCache = {}; 768TZR.autoCompleteTagSearchCacheIdx = []; 769TZR.autoCompleteTagSearchCacheTerm = null; 770TZR.autoCompleteTagSearchInit = null; 771TZR.addAutoCompleteTagSearch=function(id, options) { 772 options = jQuery.extend({count:2, list:false, textskey:'#'},options); 773 var acfield = jQuery("#"+id), 774 alive = false;
775 TZR.autoCompleteTagSearchInit = options.init; 776 // init/empty cache 777 TZR.autoCompleteTagSearchCache[id] = {}; 778 acfield.on("keydown", function(event) { 779 var keyCode = jQuery.ui.keyCode; 780 switch(event.keyCode) { 781 case keyCode.ENTER: 782 if(!options.list){ 783 event.preventDefault(); 784 return false; 785 } 786 break; 787 } 788 }).autocomplete({ 789 autoFocus: true, 790 delay: 500, 791 minLength: options.count, 792 create: function() { 793 if (options.list) { 794 var self = this; 795 796 jQuery(self).data('ui-autocomplete').close = function(e) { 797 if(alive) { 798 return false; 799 } 800 this.cancelSearch = true; 801 this._close( e ); 802 } 803 804 alive = true; 805 jQuery(jQuery(self).data('ui-autocomplete').bindings[1]).on('mouseenter', function(e) { 806 alive = true; 807 }); 808 jQuery(jQuery(self).data('ui-autocomplete').bindings[1]).on('mouseleave', function(e) { 809 alive = false; 810 setTimeout( 811 function(){ 812 if (!alive) { 813 jQuery(self).data('ui-autocomplete').close(); 814 } 815 }, 500 816 ); 817 }); 818 } 819 }, 820 source : function(request, response) { 821 //Permet de ne pas afficher la liste des tags après un recherche 822 if (TZR.autoCompleteTagSearchInit === true) { 823 TZR.autoCompleteTagSearchInit = false; 824 response([]); 825 return; 826 } 827 828 request.term = request.term.normalize('NFD').replace(/[\u0300-\u036f]/g, ""); 829 var strings = request.term.split(' '); 830 var term = strings[strings.length-1].toLowerCase(), 831 cache = TZR.autoCompleteTagSearchCache[id]; 832 TZR.autoCompleteTagSearchCacheTerm = request.term; 833 if (cache && cache[term]) { 834 TZR.autoCompleteTagSearchCacheIdx[id] = -1; 835 response(cache[term]); 836 return; 837 } 838 var autocomplete = this.element.data('autocomplete'); 839 var url = autocomplete.url + '&q=' + term.replace(options.textskey,''); 840 jQuery.ajax({ 841 url: url, 842 dataType: "json", 843 data: autocomplete.params, 844 success: function(data) { 845 if (!TZR.autoCompleteTagSearchCache[id]) { 846 TZR.autoCompleteTagSearchCache[id] = {}; 847 } 848 TZR.autoCompleteTagSearchCache[id][term] = data; 849 TZR.autoCompleteTagSearchCacheIdx[id] = -1; 850 response(data); 851 }, 852 }); 853 }, 854 select : function(event, ui) { 855 var autocomplete = jQuery(this).data('autocomplete'); 856 if (autocomplete.callback && typeof autocomplete.callback == 'function') { 857 autocomplete.callback(autocomplete.params.id, ui.item.value, ui.item.label); 858 } else { 859 var strings = TZR.autoCompleteTagSearchCacheTerm.split(' '); 860 strings[strings.length-1] = options.textskey+ui.item.label; 861 acfield.val(strings.join(' ')); 862 //acfield.val(ui.item.label); 863 } 864 return false; // job done 865 }, 866 open: function() { 867 jQuery('.ui-autocomplete').css({width: '300px'}); 868 }, 869 focus: function( event, ui ) { 870 event.preventDefault(); 871 } 872 }).autocomplete("search"); 873} 874 875TZR.removeAutoCompleteTagSearch=function(id) { 876 var acfield = jQuery("#"+id); 877 // init/empty cache 878 TZR.autoCompleteTagSearchCache[id] = {}; 879 TZR.autoCompleteTagSearchCacheIdx = [id]; 880 TZR.autoCompleteTagSearchCacheTerm = null; 881 acfield.autocomplete("destroy"); 882} 883 884TZR.isAutoCompleteTagSearch=function(id) { 885 return jQuery("#"+id).autocomplete("instance") != undefined; 886} 887 888function getCharBeforeCaret (element) { 889 var input = element.get(0); 890 var pos = 0; 891 if (!input) return; // No (input) element found 892 if ('selectionStart' in input) { 893 // Standard-compliant browsers 894 pos = input.selectionStart; 895 } else if (document.selection) { 896 // IE 897 input.focus(); 898 var sel = document.selection.createRange(); 899 var selLen = document.selection.createRange().text.length; 900 sel.moveStart('character', -input.value.length); 901 pos = sel.text.length - selLen; 902 } 903 pos--; 904 if (pos >= 0) { 905 return element.val().substr(pos,1); 906 } else { 907 return ""; 908 } 909} 910 911function getCharBeforeCaretCKE(editor) { 912 var range = editor.getSelection().getRanges()[0], 913 startNode = range.startContainer; 914 915 if (startNode.type == CKEDITOR.NODE_TEXT && range.startOffset) 916 return startNode.getText()[range.startOffset - 1]; 917 else { 918 range.collapse(true); 919 range.setStartAt(editor.editable(), CKEDITOR.POSITION_AFTER_START); 920 921 var walker = new CKEDITOR.dom.walker(range),node; 922 923 while ((node = walker.previous())) { 924 if (node.type == CKEDITOR.NODE_TEXT) 925 return node.getText().slice(-1); 926 } 927 } 928 return ""; 929} 930TZR.tagAutoCompleteCallback = function(){ 931 if (typeof(add_input_tag) == "function"){ 932 return add_input_tag; 933 } else { 934 return null; 935 } 936} 937TZR.autoCompleteTagInputCache = {}; 938TZR.addAutoCompleteTagInput=function(id, options) { 939 options = jQuery.extend({users:false,texts:false,userskey:"@",textskey:"#"},options); 940 if (!options.users && !options.text){ 941 return; 942 } 943 var hiddenfield = document.getElementById("TAG_text"); 944 acfield = jQuery("#"+id); 945 // init/empty cache 946 TZR.autoCompleteTagInputCache[acfield.attr('id')] = {}; 947 acfield.keydown(function(event) { 948 // capture key if allowed 949 if (event.key==options.textskey && !options.texts) 950 return; 951 if (event.key==options.userskey && !options.users) 952 return; 953 if (event.key==options.userskey || event.key==options.textskey && (options.users || options.texts)) { 954 var usercomplete = 0; 955 var pos = jQuery("#"+id).caret('offset'); 956 var lastchar = getCharBeforeCaret(jQuery("#"+id));
957 if (event.key==options.userskey) { // user completion 958 if (lastchar.match(/\S/)) { // @ in a word : ignore 959 return; 960 } else { 961 usercomplete = 1; 962 } 963 } else if (!hiddenfield) { 964 return; 965 } 966 var text = document.getElementById("texttaginput"); 967 if (!text) { 968 text = document.createElement("input"); 969 text.id = "texttaginput"; 970 text.className = "texttaginput"; 971 text.onblur=function(){jQuery("#texttaginput").hide();}; 972 document.body.appendChild(text); 973 } 974 jQuery("#texttaginput").keydown(function(event){ 975 if(event.keyCode==13) { 976 event.preventDefault(); 977 jQuery("#texttaginput").hide(); 978 return false; 979 } 980 }).autocomplete({ 981 autoFocus: true, 982 delay: 500, 983 minLength: 3, 984 source : function(request, response) { 985 // check cache 986 var term = request.term.toLowerCase().trim(); 987 cache = TZR.autoCompleteTagInputCache[acfield.attr('id')]; 988 if (cache && cache[term]) { 989 response(cache[term]); 990 return; 991 } 992 var autocomplete = jQuery("#"+id).data('autocomplete'); 993 var acurl = autocomplete.url; 994 if (usercomplete) { 995 acurl = autocomplete.url2; 996 } 997 jQuery.ajax({ 998 url: acurl + '&q=' + escape(term), 999 dataType: "json", 1000 data: autocomplete.params, 1001 success: function(data) { 1002 if (!TZR.autoCompleteTagInputCache[acfield.attr('id')]) { 1003 TZR.autoCompleteTagInputCache[acfield.attr('id')] = {}; 1004 } 1005 TZR.autoCompleteTagInputCache[acfield.attr('id')][term] = data; 1006 response(data); 1007 }, 1008 }); 1009 }, 1010 select : function(event, ui) { 1011 var autocomplete = jQuery("#"+id).data('autocomplete'); 1012 var pid = jQuery("#texttaginput").attr("pid"); 1013 if (autocomplete.callback && typeof autocomplete.callback == 'function') { 1014 if (usercomplete) { 1015 autocomplete.callback(pid, ui.item.value, ui.item.label); 1016 } else { 1017 autocomplete.callback(pid, ui.item.value, ui.item.label, "TAG"); 1018 } 1019 } else { 1020 if (hiddenfield) { 1021 hiddenfield.value = ui.item.value; 1022 } 1023 acfield.val(ui.item.label); 1024 } 1025 jQuery(hiddenfield).change(); 1026 return false; // job done 1027 }, 1028 open: function() { 1029 jQuery('.ui-autocomplete').css({width: '300px'}); 1030 }, 1031 focus: function( event, ui ) { 1032 event.preventDefault(); 1033 } 1034 }); 1035 text.style.left = pos.left+"px"; 1036 text.style.top = pos.top+"px"; 1037 text.value = event.key; 1038 jQuery("#texttaginput").attr("pid",id); 1039 jQuery("#texttaginput").show(); 1040 text.focus(); 1041 text.setSelectionRange(1,1); 1042 return false; 1043 } 1044 }); 1045} 1046 1047TZR.autoCompleteTagCKECache = {}; 1048TZR.addAutoCompleteTagCKE=function(id, options) { 1049 options = jQuery.extend({users:false,texts:false,userskey:"@",textskey:"#"},options); 1050 var hiddenfield=document.getElementById("TAG_text"); 1051 acfield = jQuery("#"+id); 1052 // init/empty cache
1053 TZR.autoCompleteTagCKECache[acfield.attr('id')] = {}; 1054 CKEDITOR.instances[id].on( 'key', function(evt) { 1055 var key = evt.data.domEvent['$'].key; 1056 // capture key if allowed 1057 if (key==options.textskey && !options.texts) 1058 return; 1059 if (key==options.userskey && !options.users) 1060 return; 1061 if (key==options.userskey || key==options.textskey && (options.users || options.texts)) { 1062 var usercomplete = 0; 1063 var css_class = 'cketag'; 1064 if (key==options.userskey) { // user completion 1065 var lastchar = getCharBeforeCaretCKE(CKEDITOR.instances[id]); 1066 if (lastchar.match(/\S/)) { // @ in a word : ignore 1067 return; 1068 } else { 1069 usercomplete = 1; 1070 css_class = 'ckeusertag'; 1071 } 1072 } else if (!hiddenfield) { 1073 return; 1074 } 1075 var ifr = jQuery('#'+id).parent().find('.cke_wysiwyg_frame')[0]; 1076 var ckeid = "cke"+new Date().getTime(); 1077 this.insertHtml('<span id="'+ckeid+'" class="'+css_class+'">'+key+'</span> '); 1078 var pos = jQuery('body', ifr.contentDocument).caret('offset', {iframe: ifr}); 1079 if (pos) { 1080 var left = jQuery(ifr).offset().left + pos.left; 1081 var top = jQuery(ifr).offset().top + pos.top; 1082 var text = document.getElementById("texttaginput"); 1083 if (!text) { 1084 text = document.createElement("input"); 1085 text.id = "texttaginput"; 1086 text.className = "texttaginput"; 1087 text.onblur=function(){jQuery("#texttaginput").hide();}; 1088 document.body.appendChild(text); 1089 } 1090 jQuery("#texttaginput").keydown(function(event){ 1091 if(event.keyCode==13) { 1092 event.preventDefault(); 1093 jQuery("#texttaginput").hide(); 1094 return false; 1095 } 1096 }).autocomplete({ 1097 autoFocus: true, 1098 delay: 500, 1099 minLength: 2, 1100 source : function(request, response) { 1101 // check cache 1102 var term = request.term.toLowerCase().trim(); 1103 var cache = TZR.autoCompleteTagCKECache[acfield.attr('id')]; 1104 1105 if (cache && cache[term]) { 1106 response(cache[term]); 1107 return; 1108 } 1109 1110 var autocomplete = jQuery("#"+id).data('autocomplete'); 1111 var acurl = autocomplete.url; 1112 if (usercomplete) { 1113 acurl = autocomplete.url2; 1114 } 1115 jQuery.ajax({ 1116 url: acurl + '&q=' + escape(term), 1117 dataType: "json", 1118 data: autocomplete.params, 1119 success: function(data) { 1120 if (!TZR.autoCompleteTagCKECache[acfield.attr('id')]) { 1121 TZR.autoCompleteTagCKECache[acfield.attr('id')] = {}; 1122 } 1123 TZR.autoCompleteTagCKECache[acfield.attr('id')][term] = data; 1124 response(data); 1125 }, 1126 }); 1127 }, 1128 select : function(event, ui) { 1129 var autocomplete = jQuery("#"+id).data('autocomplete'); 1130 var pid = jQuery("#texttaginput").attr("pid"); 1131 if (autocomplete.callback && typeof autocomplete.callback == 'function') { 1132 if (usercomplete) { 1133 autocomplete.callback(pid, ui.item.value, ui.item.label); 1134 } else { 1135 autocomplete.callback(pid, ui.item.value, ui.item.label, "TAG"); 1136 } 1137 } else { 1138 if (hiddenfield) { 1139 hiddenfield.value = ui.item.value; 1140 } 1141 acfield.val(ui.item.label); 1142 } 1143 jQuery(hiddenfield).change(); 1144 return false; // job done 1145 }, 1146 open: function() { 1147 jQuery('.ui-autocomplete').css({width: '300px'}); 1148 }, 1149 focus: function( event, ui ) { 1150 event.preventDefault(); 1151 } 1152 }); 1153 text.style.left = left+"px"; 1154 text.style.top = top+"px"; 1155 text.value = ""; 1156 jQuery("#texttaginput").attr("pid",id); 1157 jQuery("#texttaginput").attr("ckeid",ckeid); 1158 jQuery("#texttaginput").show(); 1159 text.focus(); 1160 } 1161 } 1162 }); 1163} 1164 1165 1166TZR.autoCompleteMultipleFields = function (id, oid, v) { 1167 var autocomplete = jQuery('#' + id).data('autocomplete'), 1168 relatedFields = autocomplete.params.relatedFields.split(','), 1169 _values = v.split(', '); 1170 jQuery('#' + id).val(_values[0]); 1171 for (key in relatedFields) { 1172 jQuery(':input[name="' + relatedFields[key] + '"]').val(_values[parseInt(key) + 1]); 1173 } 1174}; 1175TZR.autoCompleteMultipleValue=function(id,oid,v){ 1176 if(jQuery('#table'+id).find('input[value="'+oid+'"]').length>0) return; 1177 var tr=TZR.addTableLine("table"+id,[undefined,v],0,false); 1178 jQuery('input',tr.cells[0]).val(oid); 1179 jQuery(tr).show(); 1180 jQuery('#_INPUT'+id).val(''); 1181}; 1182TZR.autoCompleteUsers = function(id, oid, label){ 1183 if (oid == '*no_result*') 1184 return; 1185 TZR.UserSelector.autoCompleteSelection.call(TZR.UserSelector, id, oid, label); 1186}; 1187TZR.isIdValid = function (id) { 1188 found=false; 1189 nb=TZR.validator.length; 1190 for(i=0;i<nb;i++) { 1191 if(id==TZR.validator[i][0]) { 1192 if(!TZR.isIdxValid(i)){ 1193 var valmess = jQuery("#"+id).data('pattern-error-message'); 1194 if (typeof valmess != "undefined") 1195 TZR.setCustomValidityMess(id, valmess); 1196 else 1197 TZR.setCustomValidityMess(id, ""); 1198 return false;
1199 } else { 1200 TZR.setCustomValidityMess(id, ""); 1201 } 1202 } 1203 } 1204 if(typeof(TZR.customOnBlur)!='undefined') 1205 return TZR.customOnBlur(id); 1206 return true; 1207} 1208TZR.setCustomValidityMess = function(id, valmess){ 1209 try { 1210 document.getElementById(id).setCustomValidity(valmess); 1211 document.getElementById(id).reportValidity(); 1212 if (typeof valmess != "undefined" && valmess.length) { 1213 jQuery('#'+id).addClass('error_field').focus(); 1214 } else { 1215 jQuery('#'+id).removeClass('error_field'); 1216 } 1217 } catch(except) { 1218 // IE9 1219 } 1220} 1221TZR.copyDivToHidden = function (idsrc, iddst) { 1222 var objsrc = document.getElementById(idsrc); 1223 var objdst = document.getElementById(iddst); 1224 if(objsrc.innerHTML=="...") objdst.value=""; 1225 else objdst.value = objsrc.innerHTML; 1226 return true; 1227} 1228 1229TZR.addOnSubmit=function (src) { 1230 nb=TZR.onsubmit.length; 1231 TZR.onsubmit[nb]=src; 1232} 1233TZR.addValidator=function(src){ 1234 var type = typeof src[0]; 1235 if(type!=='object'){ 1236 var o=document.getElementById(src[0]); 1237 } else { 1238 var o=src[0]; 1239 } 1240 if(!o) return false; 1241 if(!src[5] && src[4]=='Form') src[5]=jQuery('div.error:visible:first',o); 1242 if(src[99]===undefined) src[99]=true; 1243 var v=jQuery(o).data('validators'); 1244 if(!v) v=[src]; 1245 else v.push(src); 1246 jQuery(o).data('validators',v); 1247 TZR.validator.push(src); 1248 return true; 1249} 1250TZR.changeValidatorsState=function(id,active){ 1251 if(!active) active=false; 1252 var vs=jQuery('#'+id+',#url'+id).data('validators'); 1253 if(vs){ 1254 for(var i in vs){ 1255 vs[i][99]=active; 1256 } 1257 } 1258} 1259/* existe aussi TZR.Field.editSec */ 1260TZR.editSec=function (selfu, moid, oid, selectedfrom, _function) { 1261 if (typeof _function == 'undefined') { 1262 _function = 'secEditSimple'; 1263 } 1264 if(typeof(selectedfrom)!='undefined'){ 1265 if(typeof(selectedfrom)=='object'){ 1266 var f=document.forms['browse'+selectedfrom.uniqid]; 1267 }else{ 1268 var f=document.forms[selectedfrom]; 1269 } 1270 if(!f || !TZR.checkBoxesIsChecked(f)){ 1271 if(oid){ 1272 oid="oid="+oid; 1273 }else{ 1274 alert(TZR._noobjectselected); 1275 return; 1276 } 1277 }else{ 1278 oid=jQuery(f).find('input:checked[name^=_selected]').serialize()+'&_selectedok=ok'; 1279 } 1280 }else{ 1281 oid="oid="+oid; 1282 } 1283 TZR.Dialog.openURL(selfu+'&function='+_function+'&template=Core/Module.edit-sec.html&moid='+moid+'&tplentry=br&'+oid); 1284 return false; 1285} 1286 1287TZR.autocomplete_cb = function (suggestion) { 1288 if ( suggestion ) { 1289 var inp = TZR.autocomplete_field; 1290 var inp_enc = TZR.autocomplete_encoded_field; 1291 inp_enc.value=suggestion[0]; 1292 // IE 1293 if ( document.selection ) { 1294 var sel = document.selection.createRange(); 1295 sel.text = suggestion[1]; 1296 sel.move( 'character', -suggestion[1].length ); 1297 sel.findText( suggestion[1] ); 1298 sel.select(); 1299 } else { 1300 var preLength = inp.value.length; 1301 inp.value += suggestion[1]; 1302 inp.selectionStart = preLength; 1303 inp.selectionEnd = inp.value.length; 1304 } 1305 } 1306} 1307 1308TZR.autocomplete_running=false; 1309TZR.autocomplete_precheck = function ( tab, field, myform, e ) { 1310 // Check for alpha numeric keys 1311 TZR.autocomplete_field = myform.elements[field+'_HID']; 1312 TZR.autocomplete_encoded_field = myform.elements[field]; 1313 if ( ( e.keyCode >= 48 && e.keyCode <= 57 ) || ( e.keyCode >= 65 && e.keyCode <= 90 ) ) { 1314 x_xlinkdef_autocomplete( tab, field, TZR.autocomplete_field.value, TZR.autocomplete_cb); 1315 } 1316} 1317 1318// Inverse la coche de toutes les checkbox d'un formulaire 1319TZR.toggleCheckBoxes = function(src,startn,endn) { 1320 if(!startn) startn='selectstart'; 1321 var start=false; 1322 for(var i=0;i<src.elements.length;i++) { 1323 if(endn){ 1324 if(src.elements[i].value==endn) break; 1325 } 1326 if(start) src.elements[i].checked = !src.elements[i].checked; 1327 if(src.elements[i].value==startn) start=true; 1328 } 1329} 1330// Coche ou decoche toutes les checkbox d'un formulaire 1331TZR.checkBoxes = function(src,value,startn,endn) { 1332 if(!startn) startn='selectstart'; 1333 var start=false; 1334 for(var i=0;i<src.elements.length;i++) { 1335 if(endn){ 1336 if(src.elements[i].value==endn) break; 1337 } 1338 if(start && (src.elements[i].type=='checkbox')) src.elements[i].checked=value; 1339 if(src.elements[i].value==startn) start=true; 1340 } 1341} 1342// Retourne vrai si au moins une checkbox est coché dans le formulaire 1343TZR.checkBoxesIsChecked = function(src,startn,endn,nameregex) { 1344 if(!startn) startn='selectstart'; 1345 var start=false; 1346 for(var i=0;i<src.elements.length;i++) { 1347 if(endn){ 1348 if(src.elements[i].value==endn) break; 1349 } 1350 if(src.elements[i].value==startn){ 1351 start=true; 1352 continue; 1353 } 1354 if(nameregex && !nameregex.test(src.elements[i].name)) continue; 1355 if(start && src.elements[i].checked) return true; 1356 } 1357 return false;
1358} 1359 1360TZR.referer = function(markers,lang) { 1361 var maintenant = new Date(); 1362 var msg=maintenant.toLocaleString(); 1363 var n1=new Image(); 1364 n1.src=TZR._sharescripts+'marker.php?_marks='+markers+'&_lang='+lang+'&alea='+msg; 1365} 1366TZR.refererWithTotalOn = function(markers,lang,totalon) { 1367 var maintenant = new Date(); 1368 var msg=maintenant.toLocaleString(); 1369 var n1=new Image(); 1370 n1.src=TZR._sharescripts+'marker.php?_marks='+markers+'&_lang='+lang+'&_total='+totalon+'&alea='+msg; 1371} 1372 1373TZR.setDateEmpty = function(id) { 1374 document.getElementById(id).value=''; 1375 return false; 1376} 1377 1378TZR.selectDocument=function(selfu,moid,id,showfiles,title){ 1379 if(typeof(showfiles)=='undefined') showfiles=1; 1380 TZR.Dialog.openURL(selfu+'&function=index2Light&nosess=1&template=Module/DocumentManagement.modaltree.html&moid='+moid+'&tplentry=br&showfiles='+showfiles+'&_raw=1&_silent=1&___action=selectDoc&___target='+id+'&title='+escape(title), 1381 null, 1382 { 1383 initCallback:{ 1384 _function:"TZR.DocumentManagement.ModalTree.init", 1385 _param:{ 1386 selectedcb:function(oid, title){ 1387 TZR.DocumentManagement.ModalTree.selectDocument.call(TZR.DocumentManagement.ModalTree, oid, title); 1388 }, 1389 moid:moid, 1390 target:id, 1391 action:"selectDoc" 1392 } 1393 } 1394 } 1395 ); 1396}; 1397 1398TZR.setDocumentEmpty = function(id) { 1399 document.getElementById("id_"+id).value=''; 1400 document.getElementById("id_INPUT"+id).value=''; 1401 jQuery("#id_"+id).change(); 1402 return false; 1403} 1404 1405TZR.selectTopic = function(moid, selectedTopicOid, onUnloadCallback) { 1406 var params = { 1407 'function': 'home', 1408 'template': 'Module/InfoTree.popaction.html', 1409 'moid': moid, 1410 'tplentry': 'mit', 1411 'do': 'showtree', 1412 'action': 'selectTopic', 1413 'maxlevel': '5', 1414 '_selected': {} 1415 }; 1416 if (typeof(selectedTopicOid) == 'string' && selectedTopicOid.length > 0) 1417 params._selected[selectedTopicOid] = '1'; 1418 TZR.Dialog.openURL(TZR._self+jQuery.param(params), {}, {closeCallback:onUnloadCallback}); 1419} 1420 1421TZR.applySelected=function(func,form,message,template,tplentry,noselect) { 1422 if(TZR.checkBoxesIsChecked(form)){ 1423 form.target='_self'; 1424 form._function.value=func; 1425 form.message.value=message; 1426 if(template!==false){ 1427 form.template.value=template; 1428 if (form.elements['_next']){ 1429 form._next.value=""; 1430 } 1431 } 1432 if(tplentry!==false) form.tplentry.value=tplentry; 1433 if(!form.onsubmit || form.onsubmit()) form.submit(); 1434 }else{ 1435 alert(noselect); 1436 return; 1437 } 1438} 1439 1440TZR.doubleAdd = function(src,dst,morder) { 1441 var i=0; 1442 var changed = false; 1443 if(morder) { 1444 if (jQuery(dst).find('optgroup').length > 0) { // grouped options 1445 for (i=0; i<src.options.length; i++) { 1446 if (src.options[i].selected) { 1447 changed = true; 1448 order = parseInt(jQuery(src.options[i]).attr('order')); 1449 groupId = src.options[i].parentNode.id.replace(/(unselected_)?(.*)/, "$2"); 1450 dstGroup = jQuery(dst).find('optgroup[id$="'+groupId+'"]'); 1451 opts = jQuery(dstGroup).find('option'); 1452 for (j=0; j<opts.length; j++) { 1453 if (parseInt(jQuery(opts[j]).attr('order')) > order) 1454 break; 1455 } 1456 if (opts[j]) 1457 jQuery(opts[j]).before(src.options[i]); 1458 else 1459 jQuery(dstGroup).append(src.options[i]); 1460 i--; 1461 } 1462 } 1463 } else { // non grouped options 1464 for (i=0; i<src.options.length; i++) { 1465 if (src.options[i].selected) { 1466 changed = true; 1467 order = parseInt(jQuery(src.options[i]).attr('order')); 1468 for (j=0; j<dst.options.length; j++) { 1469 if (parseInt(jQuery(dst.options[j]).attr('order')) > order) 1470 break; 1471 } 1472 if (dst.options[j]) 1473 jQuery(dst.options[j]).before(src.options[i]); 1474 else 1475 jQuery(dst).append(src.options[i]); 1476 i--; 1477 } 1478 } 1479 } 1480 } else { 1481 for (i=src.options.length-1; i>=0; i--) { 1482 if (src.options[i].selected) { 1483 jQuery(dst).append(src.options[i]); 1484 changed = true; 1485 } 1486 } 1487 } 1488 jQuery(src).val(''); 1489 jQuery(dst).val(''); 1490 // trigger the change event for additionnal control (FO usage) 1491 // if change occured 1492 if (changed){ 1493 jQuery(dst).trigger('change', ['doubleboxchange']); 1494 jQuery(src).trigger('change', ['doubleboxchange']); 1495 } 1496} 1497 1498TZR.idxidx=10; 1499TZR.addTableLine = function(tableid,td,trtoclone,del) { 1500 if(td[1]=='--') return; 1501 if(typeof(trtoclone)=='undefined') trtoclone=0; 1502 if(typeof(del)=='undefined') del=true; 1503 var table = document.getElementById(tableid); 1504 var tbody = table.tBodies[0]; 1505 var tr = tbody.rows[trtoclone].cloneNode(true); 1506 if(del){ 1507 for(i=0;i<tr.cells.length; i++) { 1508 tr.cells[i].innerHTML=""; 1509 } 1510 } 1511 table.tBodies[0].appendChild(tr); 1512 var td3; 1513 for(i=0;i<td.length; i++) { 1514 if(td[i]!=undefined){ 1515 td3=td[i].replace(/xidxid/g,'xid'+TZR.idxidx); 1516 jQuery(tr.cells[i]).html(td3); 1517 } 1518 } 1519 TZR.idxidx++; 1520 return tr; 1521} 1522 1523/* ajout d'une valeur a partir d'une combo */ 1524TZR.addValueToShortText = function(text, multi, sep) { 1525 var text1 = document.getElementById(text); 1526 var combo1 = document.getElementById(text+'_H'); 1527 if(combo1.selectedIndex==0) return; 1528 if(multi) { 1529 if(text1.value=='') sep=''; 1530 text1.value+=sep+combo1.options[combo1.selectedIndex].text; 1531 } else { 1532 text1.value=combo1.options[combo1.selectedIndex].text; 1533 } 1534 jQuery(text1).trigger('change'); 1535 return; 1536} 1537 1538/* trouve le tag "parentTagName" parent de "element" */ 1539TZR.getParent = function(element, parentTagName) { 1540 if ( ! element ) return null; 1541 else if ( element.nodeType == 1 && element.tagName.toLowerCase() == parentTagName.toLowerCase() ) return element; 1542 else return TZR.getParent(element.parentNode, parentTagName); 1543} 1544 1545/* supprimer une ligne dans un tableau */ 1546TZR.delLine = function(link) { 1547 var td = link.parentNode; 1548 var table = TZR.getParent(td, 'TABLE'); 1549 var tbody = table.tBodies[0]; 1550 tbody.removeChild(TZR.getParent(td, 'TR')); 1551} 1552 1553// Recupere le contenu d'une url via ajax en synchrone 1554TZR.file_get_contents=function(url,nocache){ 1555 var req = null; 1556 try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { 1557 try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { 1558 try { req = new XMLHttpRequest(); } catch(e) {} 1559 } 1560 } 1561 if (req == null) throw new Error('XMLHttpRequest not supported'); 1562 if(typeof(nocache)!='undefined'){
1563 url += (url.match(/[?]+/) ? '&' : '?' ) + 'uniqid=' + TZR.uniqid(); 1564 } 1565 req.open("GET", url, false); 1566 req.send(null); 1567 return req.responseText; 1568} 1569TZR.winEditor = null; 1570TZR.openhtmlfileeditor = function(options){ 1571 var url = options.url+'&formid='+options.uniqid+'&editflag='+escape(options.editflag)+'&uploader='+escape(options.uploader)+'&downloader='+escape(options.downloader); 1572 try{ 1573 if(TZR.winEditor.closed) throw "Closed"; 1574 TZR.winEditor.location = url; 1575 TZR.winEditor.focus(); 1576 } catch(e){ 1577 TZR.winEditor = window.open(url, 'file editor', 'width=800px,height=700px;') 1578 } 1579} 1580// Génére un identifiant unique avec un prefix eventuel 1581TZR.uniqid=function(prefix){ 1582 if(typeof(prefix)=='undefined') prefix=""; 1583 var alea=Math.random()*1000000000; 1584 return prefix+alea.toString(); 1585} 1586TZR.addDependency=function(ftype,fd,f,vd,v,op,s,nochange){ 1587 if(typeof(TZR.dependency[fd])=='undefined'){ 1588 TZR.dependency[fd]=new Object(); 1589 TZR.dependency[fd]['_depfields']=new Object(); 1590 TZR.dependency[fd]['_=']=new Object(); 1591 TZR.dependency[fd]['_!=']=new Object(); 1592 } 1593 if(vd=='') vd='_empty'; 1594 if(op=='='){ 1595 if(typeof(TZR.dependency[fd]['_='][vd])=='undefined') 1596 TZR.dependency[fd]['_='][vd]=new Object(); 1597 }else{ 1598 if(typeof(TZR.dependency[fd]['_!='][vd])=='undefined') 1599 TZR.dependency[fd]['_!='][vd]=new Object(); 1600 } 1601 TZR.dependency[fd]['_depfields'][f]=1; 1602 if(op=='=') 1603 TZR.dependency[fd]['_='][vd][f]={field:f,ftype:ftype,value:v,style:s,op:op,nochange:nochange}; 1604 else 1605 TZR.dependency[fd]['_!='][vd][f]={field:f,ftype:ftype,value:v,style:s,op:op,nochange:nochange}; 1606} 1607TZR.activeDependency = function (f) { 1608 jQuery(":input", f).each(function (i, e) { 1609 jQuery(e).data('required', jQuery(e).prop('required')); 1610 }); 1611 jQuery(f).find('select').bind('change',{form:f},TZR.checkDependency); 1612 jQuery(f).find(':checkbox,:radio').bind("click",{form:f},TZR.checkDependency); 1613 var els=jQuery(f).find('select'); 1614 for(var i=0;i<els.length;i++){ 1615 var fd = jQuery(els[i]).attr('name'); 1616 if(fd) fd = fd.replace("[]",""); 1617 if(typeof(TZR.dependency[fd])!='undefined') 1618 jQuery(els[i]).triggerHandler("change"); 1619 } 1620 var oks=new Object(); 1621 var els=jQuery(f).find(':checkbox:checked,:radio:checked'); 1622 for(var i=0;i<els.length;i++){ 1623 jQuery(els[i]).triggerHandler("click"); 1624 oks[els[i].name]=1; 1625 } 1626 var els=jQuery(f).find(':checkbox,:radio'); 1627 for(var i=0;i<els.length;i++){ 1628 if(els[i].checked || oks[els[i].name]==1) continue; 1629 jQuery(els[i]).triggerHandler("click"); 1630 oks[els[i].name]=1; 1631 } 1632 // voir un generique tzrload ... (voir jcp) 1633 // + correction dans xmodtable/edit 1634 if (typeof(TZR.linkedfields) != "undefined"){ 1635 TZR.linkedfields.init(f); 1636} 1637} 1638// Dependance uniquement sur select simple, select multiple, radio et checkbox de booleen 1639TZR.checkDependency=function(e){ 1640 var t=e.target; 1641 var n = t.name; 1642 try { 1643 var valList = [].concat(jQuery(t).val()); 1644 } catch (e) { 1645 var valList = [].concat(t.value); 1646 } 1647 1648 if(typeof(n)=='undefined' || n=="") return; 1649 if(t.type=="hidden") return; 1650 if(t.type=="radio" && !t.checked) valList=[]; 1651 if(t.type=="checkbox"){ 1652 n=n.replace(/(\[.+\])$/g,""); 1653 n=n.replace(/(_HID)$/g,""); 1654 if(t.checked) valList=["1"]; 1655 else valList=["2"]; 1656 } 1657 if(t.type=="select-multiple"){ 1658 n=n.replace("[]",""); 1659 } 1660 if(valList.length==0 || (valList.length==1 && !valList[0])) valList=['_empty']; 1661 if(typeof(TZR.dependency[n])=='undefined') return; 1662 1663 for(var v in TZR.dependency[n]['_=']) { 1664 // Si la valeur dépendante (v) est dans la liste des val sélectionnées 1665 if(valList.indexOf(v)!=-1){ 1666 for(var i in TZR.dependency[n]['_='][v]){ 1667 var dep=TZR.dependency[n]['_='][v][i]; 1668 TZR.setDependencyValue(e.data.form,dep.field,dep.ftype,dep.value,dep.nochange); 1669 if(!e.data.nostyle) TZR.setDependencyStyle(dep.field,dep.style); 1670 } 1671 } 1672 } 1673 1674 for(var v2 in TZR.dependency[n]['_!=']){ 1675 // Si la valeur dépendante (v2) n'est pas dans la liste des val sélectionnées 1676 if(valList.indexOf(v2)==-1){ 1677 for(var i in TZR.dependency[n]['_!='][v2]){ 1678 var dep=TZR.dependency[n]['_!='][v2][i]; 1679 TZR.setDependencyValue(e.data.form,dep.field,dep.ftype,dep.value,dep.noc
1679hange); 1680 if(!e.data.nostyle) TZR.setDependencyStyle(dep.field,dep.style); 1681 } 1682 } 1683 } 1684} 1685 1686TZR.setDependencyStyle=function(field,style){ 1687 var toStyle=jQuery('[id="cont-'+field+'"]'); 1688 if(typeof(toStyle)=='undefined' || !toStyle || !toStyle.length){ 1689 toStyle=jQuery('[id="cv8d-displayobj-field-'+field+'"]'); 1690 } 1691 if(jQuery(toStyle).length > 1) { 1692 // On est dans un contexte de ss-module avec champs homonymes 1693 if(jQuery('.cv8-contenu-center .tzr-tabcontent.active').attr('id').match(/^sc-[0-9]+-[a-z0-9]+(-add)?$/)) { 1694 var tabId=jQuery('.cv8-contenu-center .tzr-tabcontent').filter(function(){ return this.id.match(/sc-[0-9]+-[a-z0-9]+-add/); }); 1695 toStyle=jQuery('#cont-'+field, tabId)[0]; 1696 if(typeof(toStyle)=='undefined' || !toStyle){ 1697 toStyle=jQuery('#cv8d-displayobj-field-'+field, tabId)[0]; 1698 } 1699 } 1700 } else { 1701 toStyle=toStyle[0]; 1702 } 1703 var input = jQuery(toStyle).find(":input"); 1704 if(typeof(toStyle)!='undefined' && toStyle){ 1705 if(style=='hidden'){ 1706 toStyle.style.display='none'; 1707 input.prop('data-disabled', true).prop('required', false); 1708 }else if(style=="invalid"){ 1709 input.attr('disabled', true).prop('data-disabled', true).prop('required', false); 1710 }else{ 1711 input.attr('disabled', false).prop('data-disabled', false).prop('required', input.data('required')); 1712 toStyle.style.display=''; 1713 } 1714 TZR.checkFieldsGroupsVisibility(toStyle); 1715 } 1716} 1717TZR.setDependencyValue=function(form,field,ftype,value,nochange){ 1718 if(!nochange || nochange=="0"){ 1719 TZR.setValue(form,field,ftype,value); 1720 if(typeof(TZR.dependency[field])=='undefined') return; 1721 TZR.checkDependency({target:{name:field,value:value},data:{nostyle:false,form:form}}); 1722 } 1723} 1724TZR.checkFieldsGroupsVisibility = function(field){ 1725 var group = jQuery(field).parents('fieldset.fieldsetAccordion, .cv8d-group'); 1726 var conts = jQuery("*[id^='cont-'], *[id^='cv8d-displayobj-field-']", jQuery(group)); 1727 if (conts.length > 0) { 1728 var show = false; 1729 conts.each(function(ii, o){ 1730 if (jQuery(o).css('display') != 'none'){ 1731 show = true; 1732 } 1733 }); 1734 if (show){ 1735 jQuery(group).show(); 1736 } else { 1737 jQuery(group).hide(); 1738 } 1739 } 1740} 1741TZR.setValue=function(form,field,ftype,value){ 1742 if(typeof(field)=='string' && !form){ 1743 fid=document.getElementById(field); 1744 field=fid.name; 1745 form=fid.form; 1746 }else if(typeof(field)=='string' && typeof(form)=='string'){ 1747 form=jQuery('form[name='+form+']').get(0); 1748 } 1749 1750 if(ftype=="\Seolan\Field\Link\Link" || ftype=="\Seolan\Field\Thesaurus\Thesaurus") TZR.setLinkValue(form,field,value); 1751 else TZR.setTextValue(form,field,value); 1752} 1753 1754// form (objet), field (string) 1755TZR.setLinkValue=function(form,field,value){ 1756 var cont=document.getElementById('cont-'+field); 1757 if(typeof(cont)=='undefined' || !cont){ 1758 cont=document.getElementById('cv8d-displayobj-field-'+field); 1759 } 1760 1761 var ret=jQuery(cont).find(":radio[name='"+field+"']").val([value]); 1762 if(ret.length==0) var ret=jQuery(cont).find("select[name='"+field+"']").val(value); 1763 if(ret.length==0) var ret=jQuery(cont).find("select[name='"+field+"[]']").val(value); 1764 if(ret.length==0) var ret=jQuery(cont).find(":checkbox[name^='"+field+"[']").val([value]); 1765 if(!value && ret.length==0) var ret=jQuery(cont).find("tr:not('.model') a.xthesaurus-del").click(); 1766} 1767TZR.setTextValue=function(form,field,value){ 1768 if(form.elements[field]) form.elements[field].value=value; 1769} 1770 1771// Affiche du contenu centré dans l'écran avec une div d'arriere plan pleine page 1772// content est soit du texte, soit l'id d'un objet deja existant 1773TZR.dispFullScreenContent=function(content,color,op){ 1774 if(!color) color="#000000"; 1775 if(!op) op=0.2; 1776 1777 var div=document.getElementById('fsoverlay'); 1778 if(!div){ 1779 jQuery("body").append('<div id="fsoverlay"></div>'); 1780 jQuery("#fsoverlay").css({position:"absolute", zIndex:99998, padding:0, margin:0, top:0, left:0, background:color, 1781 opacity:op, width:"100%", height:jQuery(document).height()}); 1782 } 1783 if(content.substr(0,1)!="#"){ 1784 jQuery("#fscontent").remove(); 1785 jQuery("body").append('<div id="fscontent"></div>'); 1786 jQuery("#fscontent").css({position:"absolute", zIndex:99999, padding:0, margin:0, top:0, left
1786:0}); 1787 jQuery("#fscontent").html(content); 1788 jQuery("#fscontent").css({top:(jQuery(window).height()-jQuery("#fscontent").outerHeight())/2+jQuery(window).scrollTop(), 1789 left:(jQuery(window).width()-jQuery("#fscontent").outerWidth())/2, visibility:"visible"}); 1790 }else{ 1791 jQuery(content).css({visibility:"visible", display:"block"}); 1792 jQuery(content).css({position:"absolute", zIndex:99999, padding:0, margin:0, 1793 top:(jQuery(window).height()-jQuery(content).outerHeight())/2+jQuery(window).scrollTop(), 1794 left:(jQuery(window).width()-jQuery(content).outerWidth())/2}); 1795 } 1796} 1797TZR.hideFullScreenContent=function(content){ 1798 jQuery("#fsoverlay").remove(); 1799 if(content!=undefined && content.substr(0,1)=="#"){ 1800 jQuery(content).css('display','none'); 1801 }else{ 1802 jQuery("#fscontent").remove(); 1803 } 1804} 1805 1806/* Fonctions pour faciliter la gestion des champs préremplis avec leur libellé */ 1807// Initialise les différentes propiétés du champ (o=objet, l=libellé) 1808function inputInit(o,l,cpltblur){ 1809 if(cpltblur==undefined) cpltblur=true; 1810 if(typeof o=="string") { o=document.getElementById(o); } 1811 if(o.type=="text" || o.type=="textarea" || o.type=="password"){ 1812 o.cpltblur=cpltblur; 1813 o.ovalue=l; 1814 if(o.value=="") o.value=l; 1815 o.onfocus=delValue; 1816 o.onblur=retablishValue; 1817 o.onchange=function(){}; 1818 }else if(o.type=="select-one"){ 1819 o.options[0].text=l; 1820 } 1821} 1822// Efface le contenu d'un champ (o=objet (se renseigne automatiquement sur un onfocus)) 1823function delValue(o){ 1824 if(o==undefined || o.type=="focus") o=this; 1825 if(o.value==o.ovalue){ 1826 o.value=""; 1827 }else{ 1828 var r=new RegExp("^"+o.ovalue+" : ",""); 1829 o.value=o.value.replace(r,""); 1830 } 1831} 1832// Rétabli le libellé si necessaire lors de la perte du focus (o=objet (se renseigne automatiquement sur un onblur)) 1833function retablishValue(o){ 1834 if(o==undefined || o.type=="blur") o=this; 1835 if(o.value==""){ 1836 o.value=o.ovalue; 1837 }else if(o.cpltblur){ 1838 o.value=o.ovalue+" : "+o.value; 1839 } 1840} 1841// A appeller sur le submit pour vider les champs non saisis 1842function checkFields(f){ 1843 l=f.elements.length; 1844 for(i=0;i<l;i++){ 1845 if((f.elements[i].type=="text" || f.elements[i].type=="textarea")){ 1846 if(f.elements[i].value==f.elements[i].ovalue){ 1847 f.elements[i].value = ""; 1848 }else{ 1849 var r = new RegExp("^" + f.elements[i].ovalue + " : ", ""); 1850 f.elements[i].value = f.elements[i].value.replace(r, ""); 1851 } 1852 } 1853 } 1854} 1855 1856/* Fonctions pour formater les champs date et heure/durée (besoin de jquery.ui.datepicker)*/ 1857TZR.formatDate=function(obj,fmt){ 1858 if(obj.value[0]=='=') return; 1859 if(fmt==undefined) fmt=jQuery(obj).datepicker('option','dateFormat'); 1860 if(fmt==undefined || fmt.length == 0) return; 1861 var val=obj.value; 1862 if(val=='') return false; 1863// val = val.replace('-','<>'); 1864// obj.value = val; 1865// return; 1866 // traitement interval 1867 fmt_re = fmt.replace(new RegExp('dd|mm|y','g'), '\\d{1,2}').replace(new RegExp('\/','g'),'[\/.-]'); 1868 range_pattern = new RegExp('('+fmt_re+')\\s*\<\>\\s*('+fmt_re+')'); 1869 matches = val.match(range_pattern); 1870 if (matches != null && matches.length == 3) 1871 dates = new Array(matches[1], matches[2]); 1872 else 1873 dates = new Array(val); 1874 values = new Array(); 1875 var fmttab=fmt.split(/[\/.-]/); 1876 for (i=0; i<dates.length; i++) { 1877 var tab=dates[i].split(/[\/.-]/); 1878 var date = jQuery(obj).datepicker('getDate'); 1879 for (j=0; j<fmttab.length; j++){ 1880 if((fmttab[j]=='dd' || fmttab[j]=='d') && tab[j]!=undefined && tab[j]!='') date.setDate(tab[j]); 1881 if((fmttab[j]=='mm' || fmttab[j]=='m') && tab[j]!=undefined && tab[j]!='') date.setMonth(tab[j]-1); 1882 if((fmttab[j]=='yy' || fmttab[j]=='y') && tab[j]!=undefined && tab[j]!=''){ 1883 if(tab[j].length==1) date.setYear("200"+tab[j]); 1884 else if(tab[j].length==2) date.setYear("20"+tab[j]); 1885 else if(tab[j].length==3) date.setYear("2"+tab[j]); 1886 else date.setYear(tab[j]); 1887 } 1888 } 1889 values[i] = jQuery.datepicker.formatDate(fmt,date); 1890 } 1891 obj.value = values.join(' <> '); 1892 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 1893 TZR.Table.saveSomeLangsCheckFields(obj); 1894 } 1895} 1896TZR.format2dates=function(obj,b,e,fmt){ 1897 if(fmt==undefined) fmt=jQuery.datepicker._defaults.dateFormat; 1898 var form=obj.form; 1899 var b=form.elements[b]; 1900 var e=form.elements[e]; 1901 TZR.formatDate(obj); 1902 var begindate=jQuery.datepicker.parseDate(fmt,b.value); 1903 var enddate=jQuery.datepicker.parseDate(fmt,e.value); 1904 if(obj==b && begindate>enddate) e.value=b.value; 1905 else if(obj==e && begindate>enddate) b.value=e.value; 1906} 1907TZR.formatHour=function(obj,n){ 1908 val=obj.value; 1909 tab=val.split(":"); 1910 var rtab=new Array(); 1911 1912 if(/^[0-9]$/.test(tab[0])) { 1913 rtab[0]="0"+tab[0]; 1914 }else if(/^[0-9]{2}$/.test(tab[0])) { 1915 rtab[0]=tab[0]; 1916 }else{ 1917 return; 1918 } 1919 if(n>1){ 1920 if(!tab[1]){ 1921 rtab[1]="00"; 1922 }else if(/^[0-9]$/.test(tab[1])){ 1923 rtab[1]="0"+tab[1]; 1924 }else if(/^[0-9]{2}$/.test(tab[1])) { 1925 rtab[1]=tab[1]; 1926 }else{ 1927 return; 1928 } 1929 } 1930 if(n>2){ 1931 if(!tab[2]){ 1932 rtab[2]="00"; 1933 }else if(/^[0-9]$/.test(tab[2])){ 1934 rtab[2]="0"+tab[2]; 1935 }else if(/^[0-9]{2}$/.test(tab[2])) { 1936 rtab[2]=tab[2]; 1937 }else{ 1938 return; 1939 } 1940 } 1941 obj.value=rtab.join(":"); 1942} 1943 1944TZR.format2hours=function(obj,n,b,e,bd,ed){ 1945 var form=obj.form; 1946 b=form.elements[b]; 1947 e=form.elements[e]; 1948 if(bd!=undefined) bd=form.elements[bd]; 1949 if(ed!=undefined) ed=form.elements[ed]; 1950 TZR.formatHour(obj,n); 1951 var reg=/^[0-9]{2}(:[0-9]{2})?(:[0-9]{2})?$/; 1952 var tab=obj.value.split(":"); 1953 if(obj.value==""){ 1954 b.value=""; 1955 e.value=""; 1956 }else if(obj==b && b.value>
1956e.value && (bd==undefined || ed==undefined || bd.value==ed.value) && reg.test(b.value)){ 1957 var hour=parseFloat(tab[0]); 1958 var minute=parseFloat(tab[1]); 1959 if(hour==23) e.value="23:59"; 1960 else e.value=(hour+1)+":"+minute; 1961 TZR.formatHour(e,n); 1962 }else if(obj==e && b.value>e.value && (bd==undefined || ed==undefined || bd.value==ed.value) && reg.test(e.value)){ 1963 var hour=parseFloat(tab[0]); 1964 var minute=parseFloat(tab[1]); 1965 if(hour==0) b.value="00:00"; 1966 else b.value=(hour-1)+":"+minute; 1967 TZR.formatHour(b,n); 1968 } 1969}; 1970 1971// fonctions des champs de geodesiccoordinates 1972TZR.geodesic = { 1973 geoSearch:null, 1974 dms2dd:function(inid, outid){ 1975 var dms = document.getElementById(inid).value; 1976 var exp = new RegExp(/[ ]*([0-9]{1,2})° ([0-9]{1,2})' ([0-9]{1,2}\.[0-9]{0,3})'' ([NS]{1})[ ]+([0-9]{1,3})° ([0-9]{1,2})' ([0-9]{1,2}\.[0-9]{0,3})'' ([WOE]{1})/); 1977 if (exp.test(dms)){ 1978 var dd = document.getElementById(outid); 1979 var dlng = RegExp.$5; 1980 var mlng = RegExp.$6; 1981 var slng = RegExp.$7; 1982 var lng = RegExp.$8; 1983 var dlat = RegExp.$1; 1984 var mlat = RegExp.$2; 1985 var slat = RegExp.$3; 1986 var lat = RegExp.$4; 1987 if (lat == 'S'){ 1988 lat = '-'; 1989 } else { 1990 lat = ''; 1991 } 1992 if (lng == 'W' || lng == 'O'){ 1993 lng = '-'; 1994 } else { 1995 lng = ''; 1996 } 1997 var ddlat = parseInt(dlat) + parseFloat(mlat/60) + parseFloat(slat/3600); 1998 var ddlng = parseInt(dlng) + parseFloat(mlng/60) + parseFloat(slng/3600); 1999 dd.value = lat+ddlat+';'+lng+ddlng; 2000 }else{ 2001 // var dd = document.getElementById('dd').value='####'; 2002 } 2003 }, 2004 setPointCoordinates:function(field, rawvalue, dmsvalue){ 2005 document.getElementById(field.fid).value = rawvalue; 2006 document.getElementById('dms'+field.fid).value = dmsvalue; 2007 document.getElementById(field.fid+'_autogc').checked = false; 2008 this.geocodeauto(document.getElementById(field.fid+'_autogc'), field.fid); 2009 }, 2010 geocodeauto:function(cb, fid){ 2011 if (cb.checked){ 2012 document.getElementById(fid+'_b1').style.display='block'; 2013 document.getElementById(fid+'_b2').style.display='block'; 2014 } else { 2015 document.getElementById(fid+'_b1').style.display='none'; 2016 document.getElementById(fid+'_b2').style.display='none'; 2017 document.getElementById(fid+'_unchanged').value = '0'; 2018 document.getElementById(fid+'_accuracy1').innerHTML = ''; 2019 document.getElementById(fid+'_upd').innerHTML = ''; 2020 document.getElementById(fid+'_accuracy2').value = 'N/A'; 2021 } 2022 2023 }, 2024 openGeoSearch:function( url, fname, fid, ftable, foptions){ 2025 var v = document.getElementById(fid).value; 2026 if (v != ';'){ 2027 var c = v.split(';'); 2028 var newp = false; 2029 var lat = c[0]; 2030 var lng = c[1]; 2031 } else { 2032 var newp = true; 2033 var lat = 0; 2034 var lng = 0; 2035 } 2036 try{ 2037 TZR.geodesic.geoSearch.setPoint({table:ftable, name:fname, id:fid, newpoint:newp, lat:lat, lng:lng, options:foptions}); 2038 TZR.geodesic.geoSearch.focus(); 2039 }catch(e){ 2040 var foptionsu = ''; 2041 for(o in foptions){ 2042 foptionsu = '&foptions['+o+']='+escape(foptions[o]); 2043 } 2044 TZR.geodesic.geoSearch = window.open(url+'&fid='+fid+'&ftable='+ftable+'&fname='+fname+'&flatlng='+escape(v)+foptionsu, 'GeoSearch',"resizable=no,width=700,height=530,left=100,top=100"); 2045 TZR.geodesic.geoSearch.focus(); 2046 } 2047 }, 2048 clear:function(fid){ 2049 document.getElementById(fid).value=''; 2050 document.getElementById('dms'+fid).value=''; 2051 document.getElementById(fid).value=''; 2052 document.getElementById(fid+'_accuracy1').innerHTML = ''; 2053 document.getElementById(fid+'_upd').innerHTML = ''; 2054 document.getElementById(fid+'_accuracy2').value = 'N/A'; 2055 }, 2056 openGeoView:function(coordstring, url, fname, fid, ftable, foptions){ 2057 var v = coordstring; 2058 if (v != ';'){ 2059 var c = v.split(';'); 2060 var newp = false; 2061 var lat = c[0]; 2062 var lng = c[1]; 2063 } else { 2064 var newp = true; 2065 var lat = 0; 2066 var lng = 0; 2067 } 2068 try{ 2069 TZR.geoSearch.setPoint({table:ftable, name:fname, id:fid, newpoint:newp, lat:lat, lng:lng, foptions:foptions}); 2070 TZR.geoSearch.focus(); 2071 }catch(e){ 2072 var foptionsu = ''; 2073 for(o in foptions){ 2074 foptionsu = '&foptions['+o+']='+escape(foptions[o]); 2075 } 2076 TZR.geoSearch = window.open(url+'&fid='+fid+'&ftable='+ftable+'&fname='+fname+'&flatlng='+escape(v)+foptionsu, 'GeoView',"resizable=no,width=700,height=530,left=100,top=100"); 2077 TZR.geoSearch.focus(); 2078 } 2079 } 2080}; 2081 2082// Applique une popup a des objets (obj est un objet jQuery) 2083TZR.applyHottip=function(obj,param){ 2084 param=jQuery.extend(true,{fill:'#F9F9F9',strokeStyle:'#4b4b4b',spikeLength:10,spikeGirth:10,padding:8,cornerRadius:0, 2085 cssStyles:{fontFamily:'"lucida grande",tahoma,verdana,arial,sans-serif',fontSize:'11px'}, 2086 closeWhenOthersOpen:true,closeButton:0,ajaxPath:["$(this).attr('bt-xpath')"],offsetParent:'body',overlap:-2},param); 2087 obj.tooltip(param); 2088 return obj; 2089} 2090 2091TZR.playPause = function(varid) { 2092 if (window['chrono'+varid].isRunning) { 2093 clearInterval(window['chrono'+varid].timer); 2094 window['chrono'+varid].isRunning = false;
2095 $('#btn'+varid+' .csico-triangle-right').css('display', 'none'); 2096 $('#btn'+varid+' .csico-square-filled').css('display', 'inline'); 2097 } else { 2098 $('#btn'+varid+' .csico-triangle-right').css('display', 'inline'); 2099 $('#btn'+varid+' .csico-square-filled').css('display', 'none'); 2100 TZR.initSecond(varid); 2101 window['chrono'+varid].timer = setInterval(() => {TZR.updateTime(varid);}, 1000); 2102 window['chrono'+varid].isRunning = true; 2103 } 2104 $('#btn'+varid).blur(); 2105}; 2106 2107TZR.initSecond = function(varid) { 2108 let inputValue = document.getElementById(varid).value; 2109 let explodeVal = inputValue.split(':'); 2110 window['chrono'+varid].seconds = parseInt(explodeVal[0])*3600 + parseInt(explodeVal[1]) * 60 + parseInt(explodeVal[2]); 2111}; 2112 2113TZR.updateTime = function(varid) { 2114 window['chrono'+varid].seconds++; 2115 TZR.updateDurationInput(varid); 2116}; 2117 2118TZR.updateDurationInput = function(varid) { 2119 const hours = Math.floor(window['chrono'+varid].seconds / 3600); 2120 const minutes = Math.floor((window['chrono'+varid].seconds % 3600) / 60); 2121 const seconds = window['chrono'+varid].seconds % 60; 2122 2123 document.getElementById(varid).value = `${String(hours).padStart(2, '0')}
2123:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`; 2124}; 2125 2126TZR.calcField = function (varid, formule, decimal) { 2127 const fieldsFormule = formule.match(/(%_\w+)/g); 2128 if (fieldsFormule.length) { 2129 for (let i = 0; i < fieldsFormule.length; ++i){ 2130 $('#'+varid).parents('form').find('[name='+fieldsFormule[i].replace('%_', '')+']').on('change', function() { 2131 TZR.updateCalcField(varid, formule, decimal); 2132 }) 2133 } 2134 } 2135}; 2136 2137TZR.updateCalcField = function (varid, formule, decimal) { 2138 const fieldsFormule = formule.match(/(%_\w+)/g); 2139 if (fieldsFormule.length) { 2140 for (let i = 0; i < fieldsFormule.length; ++i){ 2141 formule = formule.replace(fieldsFormule[i], $('#'+varid).parents('form').find('[name='+fieldsFormule[i].replace('%_', '')+']').val()); 2142 } 2143 } 2144 2145 $('#'+varid).val(parseFloat(eval(formule).toString()).toFixed(decimal)); 2146 $('#'+varid).change(); 2147}; 2148 2149// Fonction d'échapement des caractères spéciaux lors d'un RegExp.test(xxx) 2150if(typeof RegExp.escape !== "function"){ 2151 RegExp.escape = function(s) { 2152 return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); 2153 }; 2154} 2155 2156function scrollToElement(o,offset){ 2157 var dTop=jQuery(o).offset().top; 2158 var sTop=jQuery(window).scrollTop(); 2159 var wHeight=jQuery(window).height(); 2160 if(!offset) offset=20; 2161 if(sTop>dTop) jQuery(window).scrollTop(dTop-offset); 2162 else if(sTop+wHeight<dTop) jQuery(window).scrollTop(dTop-wHeight+jQuery(o).height()+offset); 2163} 2164 2165function showObj(objid){ 2166 var o = document.getElementById(objid); 2167 if(o){ 2168 o.style.visibility = "visible"; 2169 o.style.position = "relative"; 2170 } 2171} 2172function hideObj(objid){ 2173 var o = document.getElementById(objid); 2174 if(o){ 2175 o.style.visibility = "hidden"; 2176 o.style.position = "absolute"; 2177 } 2178} 2179function showHide(objid, height){ 2180 var o = document.getElementById(objid); 2181 if(o){ 2182 if(o.style.visibility == "hidden"){ 2183 o.style.visibility = "visible"; 2184 o.style.position = "relative"; 2185 o.style.height=null; 2186 }else{ 2187 if (height) 2188 o.style.height=height; 2189 o.style.visibility = "hidden"; 2190 o.style.position = "absolute"; 2191 } 2192 } 2193} 2194function showHideSize(objid, height){ 2195 showHide(objid); 2196 var o = document.getElementById(objid); 2197 if(o){ 2198 if(o.style.visibility == "hidden"){ 2199 o.style.height = ''; 2200 }else{ 2201 o.style.height = height; 2202 } 2203 } 2204} 2205 2206// Function appelé à la fin du chargment de la page 2207function onLoadComplete(){ 2208 // Correction des PNG sous IE 2209 if(window.attachEvent && window.correctPNG) correctPNG(); 2210} 2211 2212window.onload=onLoadComplete; 2213; 2214/*/csx/src/Core/public/generic8.js*/; 2215jQuery(function(){ 2216 jQuery.ajaxSettings.cache=false; 2217}); 2218 2219TZR.linkAlert=function(url ){ 2220 const reg=/&(_bdx|_raw|_ajax|_)=[^&]+/g; 2221 url = url.replace(reg,""); 2222 2223 const title = this.Locales.getLabel("Seolan_Core_General.getlink"); 2224 const closeb = this.Locales.getLabel("Seolan_Core_General.close"); 2225 const copyto = this.Locales.getLabel("Seolan_Core_General.copytoclipboard"); 2226 2227 TZR.Dialog.show(`<div class="title">${title}</div> 2228 <div>${url}</div> 2229 <div class="tzr-action"> 2230 <button class="btn btn-primary" data-dismiss="modal" type="button" onclick="TZR.copy2clipboard('${url}',false,false);">${copyto}</button> 2231 <button class="btn bt-default cvx-cancel" type="button" data-dismiss="modal">${closeb}</button></div> 2232 `); 2233 2234} 2235// Verifie si un lien demande une confirmation 2236TZR.checkLinkConfirm=function(a){ 2237 if(jQuery(a).attr('x-confirm')){ 2238 var self=a; 2239 eval(jQuery(a).attr('x-confirm')); 2240 if(!ret) return false; 2241 }; 2242 return true; 2243} 2244 2245/// Fonctions de gestion des evenements sur un container 2246TZR.Event=new Object(); 2247TZR.Event.events=new Object(); 2248// Ajoute un listener (id:uniqid, t:type de l'evenement, f:fonction, p:parametres 2249TZR.Event.add=function(id,t,f,p){ 2250 if(!TZR.Event.events[t]){ 2251 TZR.Event.events[t]={}; 2252 jQuery(document).bind(t,TZR.Event.execute); 2253 } 2254 if(!TZR.Event.events[t][id]) TZR.Event.events[t][id]=[]; 2255 TZR.Event.events[t][id].push({f:f,p:p}); 2256} 2257TZR.Event.execute=function(e){ 2258 var ret=true; 2259 for(id in TZR.Event.events[e.type]){ 2260 var evs=TZR.Event.events[e.type][id]; 2261 if(document.getElementById('cv8-uniqdiv-'+id)){ 2262 for(j in evs){ 2263 if(evs[j].f(e,id,evs[j].p)===false){ 2264 ret=false; 2265 break; 2266 } 2267 } 2268 }else{ 2269 delete TZR.Event.events[e.type][id]; 2270 } 2271 } 2272 return ret; 2273} 2274// Fonctions de nettoyage des objets 2275TZR.initObjCleaner=function(){ 2276 if(!TZR.objCleaner) TZR.objCleaner=setInterval(function(){TZR.checkObjCleaner();},TZR.cleanInterval); 2277} 2278TZR.stopObjCleaner=function(){ 2279 if(TZR.objCleaner) clearInterval(TZR.objCleaner); 2280} 2281TZR.addToObjCleaner=function(id,jso,f){ 2282 if(!TZR.objToClean) TZR.objToClean=new Object(); 2283 if(!f) f=TZR.cleanObj; 2284 TZR.objToClean[id]={o:jso,f:f}; 2285} 2286TZR.checkObjCleaner=function(){ 2287 for(var i in TZR.objToClean){ 2288 if(!document.getElementById(i)){ 2289 TZR.objToClean[i].f(TZR.objToClean[i].o); 2290 delete TZR.objToClean[i]; 2291 } 2292 } 2293} 2294TZR.cleanObj=function(o){ 2295 if (typeof(o.unbinds) !== "undefined"){ 2296 try{ 2297 o.unbinds.forEach(function(el){ 2298 jQuery(el.container).unbind(el.eventname); 2299 }); 2300 }catch(e){} 2301 } 2302 if(!delete o) o=undefined; 2303} 2304// Change le titre de la fenetre courante 2305TZR.setDocumentTitle=function(title,noprefix){ 2306 if(!TZR.title) TZR.title=document.title; 2307 if(noprefix) document.title=title; 2308 else document.title=TZR.title+" : "+title; 2309 if (TZR.maintitle != ''){ 2310 jQuery('#cs-maintitle').html(TZR.maintitle).show(); 2311 } else { 2312 jQuery('#cs-maintitle').html('').hide(); 2313 } 2314} 2315 2316// Redimensionne l'interface (width : taille de la zone centrale ou toggle pour switcher entre plein ecran/taille d'origine 2317TZR.resizeTo=function(width){ 2318 if(!width) return; 2319 var jc=jQuery('#cv8-content'); 2320 var jc2=jQuery('#cv8-container'); 2321 if(width=='toggle'){ 2322 var toadd=jQuery(window).width()-jc2.width(); 2323 toadd-=5; 2324 if(toadd!=0){ 2325 var w1=jc.width()+toadd; 2326 var w2=jc2.width()+toadd; 2327 } 2328 if(toadd==0 || w1<750){ 2329 var w1=''; 2330 var w2=''; 2331 } 2332 }else{ 2333 var w1=width; 2334 var w2=jc2.width()+width-jc.width();
2335 var sw=screen.availWidth; 2336 if(w1+jc.offset().left>sw){ 2337 TZR.resizeTo('toggle'); 2338 return; 2339 } 2340 } 2341 jc.width(w1); 2342 jc2.width(w2); 2343 jQuery('div.cv8-contenu-haut,#cv8-top').width('100%'); 2344 return w1; 2345} 2346 2347// Fonction pour appliquer l'alernance de couleur et le hover sur les tables .cv8_tablelist 2348TZR.applyAlternate=function(what,table){ 2349} 2350 2351 2352 2353// Met à jour le texte d'information 2354TZR.setInfoText=function(text){ 2355 if(text!==undefined && text!==null) jQuery('#cv8-infotext>div.cv8-infotextg>div.cv8-txtseul').html(text+' '); 2356} 2357// Recupère le texte d'information 2358TZR.getInfoText=function(){ 2359 return jQuery('#cv8-infotext>div.cv8-infotextg>div.cv8-txtseul').html(); 2360} 2361// Efface le chemin actuel 2362TZR.clearNav=function(){ 2363 jQuery('#cv8-path>ul>li:gt(0)').remove(); 2364} 2365// Ajoute une entrée au chemin 2366TZR.addNav=function(title,url){ 2367 jQuery('#cv8-path>ul').append('<li><a data-linkoptions=\'{"noautocreate":true}\' class="cv8-ajaxlink" href="'+url+'">'+title+'</a></li>'); 2368} 2369 2370 2371TZR.executeFunctionByName=function(functionName, context /*, args */) { 2372 var args = [].slice.call(arguments).splice(2); 2373 var namespaces = functionName.split("."); 2374 var func = namespaces.pop(); 2375 for(var i = 0; i < namespaces.length; i++) { 2376 context = context[namespaces[i]]; 2377 } 2378 if (typeof context[func] === "function") 2379 return context[func].apply(context, args); 2380} 2381// Fonction de chargement via jQuery.load avec callback de gestion de l'authentification,overlay automatique 2382// Parametres : url, target (cible du chargement et de l'overlay), cb (callback) 2383// noautocreate (par defaut, la fonction creee les div module-container si la cible est #cv8-content) 2384// nocheckauth (desactive la verification de l'authentification), mode (mode de chargement : load, post) 2385// noautoscroll (desactive le scroll automatique), nocache (desactivation du cache navigateur, true par defaut) 2386TZR.jQueryAjax=function(obj){ 2387 if(!TZR.ajaxQueue) TZR.ajaxQueue=0; 2388 TZR.ajaxQueue++; 2389 var url=obj.url.replace(/&/g, '&').replace(/%26amp%3B/g, '%26'); 2390 var data=obj.data; 2391 var cb=obj.cb; 2392 var cb_args=obj.cb_args; 2393 var cb_context=obj.cb_context; 2394 var mode=obj.mode; 2395 var nocheckauth=obj.nocheckauth; 2396 var noautocreate=obj.noautocreate; 2397 var noautoscroll=obj.noautoscroll; 2398 var dataType=obj.dataType; 2399 if(dataType==undefined) dataType="arraybuffer"; 2400 var nocache=obj.nocache; 2401 var statetarget=obj.statetarget; 2402 var nowaitcursor=obj.nowaitcursor; 2403 if(nocache==undefined) nocache=true; 2404 if(!obj.target) obj.target='#cv8-content'; 2405 var jt=jQuery(obj.target); 2406 if (jt==undefined) jt=JQuery('#cv8-content'); 2407 jt.context = 'document'; 2408 if(obj.overlay) var jo=jQuery(obj.overlay); 2409 else var jo=jt; 2410 if(!nowaitcursor) jQuery('body,a').css('cursor','progress'); 2411 // Ajoute un overlay le temps du chargement 2412 if(jt.attr('id')=='cv8-content'){ 2413 if(mode=="load" && !noautocreate){ 2414 jt.html('<div class="cv8-module" id="cv8-module-0"><div class="cv8-module-bg"><div class="cv8-module-container" id="cv8-module-container-0"></div></div></div>'); 2415 var jt=jQuery('#cv8-module-container-0'); 2416 } 2417 var overlay=TZR.setOverlay(jo); 2418 }else if(obj.overlay != "none") { 2419 if (typeof(obj.overlayOpts) != "undefined") 2420 var overlay=TZR.setOverlay(jo, obj.overlayOpts); 2421 else 2422 var overlay=TZR.setOverlay(jo); 2423 }else { 2424 var overlay=""; 2425 } 2426 // Overlay de confirmation sur un objet du DOM 2427 if(statetarget){ 2428 var stateoverlay=TZR.setOverlay(statetarget,{content:'<img src="/csx/public/jtree/spinner.gif">',oclass:'overlay-confirm',css:{opacity:0.8}}); 2429 } 2430 // Scroll le contenu si necessaire 2431 var pos = Number.MAX_VALUE; 2432 try{ 2433 pos=jt.position().top; 2434 } catch(e){} 2435 2436 if(!noautoscroll && jQuery(document).scrollTop()>pos) jQuery(document).scrollTop(pos); 2437 // Activation/desactivation du cache 2438 var currentajaxsettings=jQuery.extend({},jQuery.ajaxSettings); 2439 if(nocache) jQuery.ajaxSettings.cache=false; 2440 else jQuery.ajaxSettings.cache=true; 2441 // Options ajax selon contexte 2442 if(TZR.supportFormData() && data instanceof FormData){ 2443 jQuery.ajaxSettings.processData=false; 2444 jQuery.ajaxSettings.contentType=false; 2445 } 2446 // Complete l'url 2447 if(url.indexOf(' ')!=-1){ 2448 var url2=url.substr(url.indexOf(' ')); 2449 url=url.substr(0,url.indexOf(' ')); 2450 }else{ 2451 var url2=''; 2452 } 2453 if (url.indexOf('?') == -1) url += '?'; 2454 if(url==url.replace('_raw=','')) url+='&_raw=1'; 2455 if(url==url.replace('_ajax=','')) url+='&_ajax=1'; 2456 //skip history 2457 if(obj.skip) url+='&skip=1'; 2458 url=url+url2; 2459 if(typeof(data)=='function'){ 2460 cb=data; 2461 data=undefined; 2462 } 2463 // Construit la callback (desactivation overlay + callback personnalisable) 2464 var callback=function(responseText,textStatus,XMLHttpRequest){ 2465 TZR.ajaxQueue--; 2466 TZR.unsetOverlay(overlay); 2467 if(!nowaitcursor) jQuery('body,a').css('cursor',''); 2468 if(!nocheckauth){ 2469 if(XMLHttpRequest.status==401){ 2470 TZR.authAlert(TZR.jQueryAjax,obj); 2471 return false;
2472 } 2473 } 2474 // Overlay de confirmation sur un objet du DOM 2475 if(statetarget){ 2476 TZR.unsetOverlay(stateoverlay); 2477 stateoverlay=TZR.setOverlay(statetarget,{content:(textStatus=='success'?'OK':'ERROR'), 2478 oclass:(textStatus=='success'?'overlay-confirm':'overlay-error'),css:{opacity:0.8}}); 2479 setTimeout(function(){stateoverlay.fadeOut(800,function(){TZR.unsetOverlay(stateoverlay);})},500); 2480 } 2481 if (mode == "append"){ 2482 jt.append(responseText); 2483 } 2484 if(cb){ 2485 if (typeof(cb_args) === 'string') cb_args = cb_args.split(","); 2486 if(typeof(cb) === 'string'){ 2487 var args = [cb,window,responseText,textStatus,XMLHttpRequest]; 2488 if (typeof(cb_args) !== undefined) { // faux : c'est un string, toutjours 2489 var a = args.slice(0,2); 2490 var b = args.slice(2); 2491 args = a.concat(cb_args).concat(b); 2492 } 2493 return TZR.executeFunctionByName.apply(this,args); 2494 } 2495 if (typeof(cb) === 'function') { 2496 var args = [responseText,textStatus,XMLHttpRequest]; 2497 if (cb_args !== undefined && cb_args !== null) { 2498 var a = []; 2499 args = a.concat(cb_args).concat(args); 2500 } 2501 if (typeof cb_context == 'object'){ 2502 return cb.apply(cb_context,args); 2503 } else { 2504 // en v8 on avait appel direct de la cb donc , ici le this c'est ? 2505 return cb.apply(this,args); 2506 } 2507 } 2508 } 2509 } 2510 if(mode=="load") jt.load(url,data,callback); 2511 if(mode=="get") jQuery.ajax({dataType:dataType,type:'GET',data:data,url:url,success:callback}); 2512 if(mode=="post") jQuery.post(url,data,callback); 2513 if(mode=="native") { 2514 jQuery.ajax({dataType: 'native', type : 'POST', data:data, url: url,xhrFields: {responseType: dataType},success:callback}); 2515 }; 2516 if (mode == 'append'){ 2517 jQuery.ajax({dataType:"html",type:'GET',data:data,url:url,success:callback}); 2518 } 2519 jQuery.ajaxSettings=currentajaxsettings; 2520 return overlay; 2521} 2522TZR.jQueryAppendToTarget = function(obj){ 2523 obj.mode = 'append'; 2524 TZR.jQueryAjax(obj); 2525} 2526TZR.jQueryLoad=function(obj){ 2527 obj.mode="load"; 2528 TZR.jQueryAjax(obj); 2529} 2530TZR.jQueryPost=function(obj){ 2531 if(obj.mode == undefined) obj.mode="post"; 2532 TZR.jQueryAjax(obj); 2533} 2534// Soumet un formulaire via ajax (div : element cible pour l'overlay / loadresult : charge le resultat dans div) 2535TZR.ajaxSubmitForm=function(form,div,loadresult,cplt,confirmmessage){ 2536 if(TZR.ajaxSubmitFormOngoing==form) return true; 2537 if(confirmmessage && !confirm(confirmmessage)) return false; 2538 TZR.ajaxSubmitFormOngoing=form; 2539 if((form.enctype=="multipart/form-data" || form.ENCTYPE=="multipart/form-data") && !TZR.supportFormData()){ 2540 var ret=TZR.iframeSubmitForm(form,div,loadresult,cplt); 2541 if(ret) jQuery(form).submit(); 2542 return TZR.ajaxFormSubmitted(); 2543 } 2544 if(loadresult==undefined) loadresult=true; 2545 if(!TZR.isFormValidWithFocus(form,true)){ 2546 return TZR.ajaxFormSubmitted(); 2547 } 2548 if(div==undefined) div=jQuery(form).parents('div.cv8-module-container')[0]; 2549 var param={target:div,url:jQuery(form).attr('action')}; 2550 if(TZR.supportFormData()){ 2551 TZR.updateCKEditorElements(form); 2552 param.data=new FormData(form); 2553 }else{ 2554 param.data=jQuery(form).serializeArray(); 2555 } 2556 param.cb = jQuery(form).attr("data-cb"); 2557 param.cb_args = jQuery(form).attr("data-cb_args"); 2558 if (!param.cb && cplt && typeof cplt.cb != "undefined"){ 2559 param.cb = cplt.cb; 2560 param.cb_args = (typeof cplt.cb_args != "undefined")?cplt.cb_args:null; 2561 } 2562 if(cplt!=undefined) jQuery.extend(param,cplt); 2563 if(loadresult) TZR.jQueryLoad(param); 2564 else TZR.jQueryPost(param); 2565 return TZR.ajaxFormSubmitted(); 2566} 2567// Rétablit la configuration du précédent formulaire dans le cadre d'une soumission AJAX d'ajout de sous-fiche à une fiche en cours d'édition 2568TZR.ajaxFormSubmitted = function() { 2569 TZR.ajaxSubmitFormOngoing=''; 2570 // TZR.parentFormValidator est copié à partir de TZR.validator lors de l'ajout d'un onglet AJAX dans Module/Table.edit.html 2571 if (typeof TZR.parentFormValidator != 'undefined' && TZR.parentFormValidator != null) { 2572 jQuery.extend(TZR.validator, TZR.parentFormValidator); 2573 TZR.parentFormValidator = null; 2574 } 2575 return false;
2576} 2577// Soumet un formulaire via iframe (div : element cible pour l'overlay / loadresult : charge le resultat dans div) 2578TZR.iframeSubmitForm=function(form,div,loadresult,cplt){ 2579 if(loadresult==undefined) loadresult=true; 2580 if(div==undefined) div=jQuery(form).parents('div.cv8-module-container')[0]; 2581 if(cplt==undefined) cplt={}; 2582 var jdiv=jQuery(div); 2583 var nowaitcursor=cplt.nowaitcursor; 2584 var overlay=''; 2585 return TZR.iframeSubmitFormKernel.submit(form,{onStart:function(){ 2586 var ret=TZR.isFormValidWithFocus(form,true); 2587 if(!ret) return false; 2588 if(!nowaitcursor) jQuery('body,a').css('cursor','progress'); 2589 overlay=TZR.setOverlay(jdiv); 2590 return true; 2591 },onComplete:function(html){ 2592 if(!nowaitcursor) jQuery('body,a').css('cursor',''); 2593 if(loadresult){ 2594 if(html=="401 Unauthorized"){ 2595 TZR.unsetOverlay(overlay); 2596 cplt.force=true; 2597 TZR.authAlert(TZR.iframeSubmitForm,form,div,loadresult,cplt); 2598 }else{ 2599 jdiv.html(html); 2600 TZR.unsetOverlay(overlay); 2601 // Scroll le contenu si necessaire 2602 var pos = Number.MAX_VALUE; 2603 try{ 2604 pos=jdiv.position().top; 2605 }catch(e){} 2606 if(jQuery(document).scrollTop()>pos) jQuery(document).scrollTop(pos); 2607 } 2608 }else{ 2609 TZR.unsetOverlay(overlay); 2610 } 2611 if(cplt){ 2612 if(cplt.cb) cplt.cb(html); 2613 } 2614 },force:cplt.force}); 2615} 2616// Force la mise à jour de l'element recevant le texte de CKEditor 2617TZR.updateCKEditorElements=function(f){ 2618 if(typeof CKEDITOR !== 'undefined'){ // pas de console.log si pas de CKEDITOR 2619 try 2620 { 2621 for (instance in CKEDITOR.instances){ 2622 if(f && CKEDITOR.instances[instance].element.$.form!=f) continue; 2623 CKEDITOR.instances[instance].updateElement(); 2624 } 2625 }catch(e){ 2626 if (typeof console !== "undefined" || typeof console.log !== "undefined") { 2627 console.log(e); 2628 } 2629 } 2630} 2631} 2632// Teste si le navigateur support formData 2633TZR.supportFormData=function(){ 2634 return !!window.FormData; 2635} 2636// Ajout/suppression d'un overlay sur une div 2637if(!TZR.defaultOverlay){ 2638 TZR.defaultOverlay='<span class="glyphicon csico-loader csico-spin"></span>'; 2639} 2640TZR.setOverlay=function(o,opts){ 2641 if(!opts) opts=new Object(); 2642 if(!opts.css) opts.css=new Object(); 2643 if(!opts.content) opts.content=TZR.defaultOverlay; 2644 if(!opts.oclass) opts.oclass='overlay'; 2645 // Génération du HTML de l'overlay 2646 var jo=jQuery(o); 2647 if(jo.length==0) return; 2648 offset=jo.offset(); 2649 var overlay = jQuery(TZR.sprintf('<div class="%s" style="">%s</div>', opts.oclass, opts.content)); 2650 // CSS de l'overlay 2651 var w=jo.outerWidth(); 2652 var h=jo.outerHeight(); 2653 var css=jQuery.extend({position:'absolute',top:offset.top,left:offset.left,opacity:0.3,width:w,'z-index':1051},opts.css);//z-index d'une modal = 1050 2654 // CSS du fond 2655 var css2={opacity:css.opacity,width:'100%',height:'100%',position:'absolute',top:0,left:0}; 2656 delete css.opacity; 2657 // Applique les css 2658 overlay.css(css); 2659 jQuery('div:first',overlay).css(css2); 2660 // Aoute l'overlay et verifie la hauteur 2661 jQuery('body').append(overlay); 2662 var ch=overlay.height(); 2663 if(h>ch){ 2664 overlay.css({height:h,'line-height':h+'px'}); 2665 jQuery('span.cv8_inlineblock',overlay).css('line-height',h+'px'); 2666 } 2667 // Timer pour replacement automatique 2668 overlay.data('_timer',setInterval(function(){ 2669 var offset=jo.offset(); 2670 var h=jo.outerHeight(); 2671 var css3={top:offset.top,left:offset.left,width:jo.outerWidth()}; 2672 if(h>ch){ 2673 css3.height=h; 2674 css3['line-height']=h+'px'; 2675 } 2676 overlay.css(css3); 2677 },100)); 2678 // Timer pour eviter les deconnexion 2679 if(TZR._sessid){ 2680 overlay.data('_timersess',setInterval(function(){ 2681 TZR.keepAlive(); 2682 },300000)); 2683 } 2684 return overlay; 2685} 2686TZR.unsetOverlay=function(o){ 2687 var jo=jQuery(o); 2688 if(jo.length==0) return; 2689 clearInterval(jo.data('_timer')); 2690 if(TZR._sessid) clearInterval(jo.data('_timersess')); 2691 jo.remove(); 2692} 2693 2694 2695// Enregistre un cookie 2696TZR.setCookie=function(name,value,expire,path,domain,secure) { 2697 document.cookie=name+"="+escape(value)+((expire)?"; expires="+expire.toGMTString():"")+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":""); 2698} 2699// Recupere un cookie 2700TZR.getCookie=function(name,isfloat,isbool){ 2701 var deb=document.cookie.indexOf(name+"=") 2702 if(deb>=0) { 2703 deb+=name.length+1; 2704 var fin=document.cookie.indexOf(";",deb); 2705 if(fin<0) fin=document.cookie.length; 2706 var val=unescape(document.cookie.substring(deb,fin)); 2707 if(isbool){ 2708 if(!val || val=="false" || val=="0") return false;
2709 else return true; 2710 } 2711 if(isfloat) return parseFloat(val); 2712 return val; 2713 } 2714 return ""; 2715} 2716 2717// Accordeon sur des fieldset (obj=>noeud contenant les fieldset à traiter, open=index à ouvrir (0 par defaut, 'all' pour tout ouvrir)) 2718TZR.fieldsetAccordion=function(obj,open,selector){ 2719 if(!open) open=0 2720 if(!selector) selector='fieldset'; 2721 jQuery(obj).find(selector).addClass('fieldsetAccordion').each(function(i){ 2722 var jt=jQuery(this); 2723 jQuery('>legend',jt).click(function(){ 2724 var l=jQuery(this); 2725 var c=jQuery('>div,>table,>section',this.parentNode); 2726 var f=function(){ 2727 l.parents('fieldset:first').toggleClass('fieldsetAccordionClose fieldsetAccordionOpen'); 2728 c.slideToggle(200); 2729 }; 2730 if(!c.text() && l.attr('href')){ 2731 c.load(l.attr('href'),f); 2732 }else{ 2733 f(); 2734 } 2735 // ? chromium linux .... pas grave ? et a faire mieux de toute façon ? 2736 if (jQuery(this.parentNode).is(':visible')){ 2737 //TZR.resetXFileUploader(this.parentNode); 2738 } 2739 }); 2740 if(((open!='all' && i!=open) || jt.hasClass('fieldsetAccordionClose')) && !jt.hasClass('fieldsetAccordionOpen')){ 2741 jt.addClass('fieldsetAccordionClose'); 2742 jQuery('>div,>table,>section',jt).hide(); 2743 }else{ 2744 jt.addClass('fieldsetAccordionOpen'); 2745 } 2746 }); 2747} 2748 2749 2750/* Soumet un formulaire (peut avoir des champs fichier) sans rechargement de la page */ 2751/* Utilisation : TZR.iframeSubmitFormKernel.submit(form,{onStart:function,onComplete:function},true/false); */ 2752TZR.iframeSubmitFormKernel={ 2753 frame:function(c) { 2754 var n = 'iframe' + Math.floor(Math.random() * 99999); 2755 var d = document.createElement('DIV'); 2756 d.innerHTML='<iframe src="about:blank" initialized="0" style="display:none" id="'+n+'" name="'+n+'" onload="TZR.iframeSubmitFormKernel.loaded(\''+n+'\');"></iframe>'; 2757 document.body.appendChild(d); 2758 var i = document.getElementById(n); 2759 if (c && typeof(c.onComplete) == 'function') { 2760 i.onComplete = c.onComplete; 2761 } 2762 return n; 2763 }, 2764 form : function(f, name) { 2765 f.setAttribute('target',name); 2766 return name; 2767 }, 2768 submit : function(f, c) { 2769 var ret=false; 2770 if (c && typeof(c.onStart) == 'function') { 2771 ret=c.onStart(); 2772 } else { 2773 ret=true; 2774 } 2775 if(!ret) return false; 2776 var id=this.form(f, TZR.iframeSubmitFormKernel.frame(c)); 2777 jQuery(f).append('<input type="hidden" name="_iframeencode" value="1">'); 2778 document.getElementById(id).initialized=1; 2779 if(c.force) f.submit(); 2780 return true; 2781 }, 2782 loaded : function(id) { 2783 var i = document.getElementById(id); 2784 if(i.initialized!=1) return false; 2785 if (i.contentDocument) { 2786 var d = i.contentDocument; 2787 } else if (i.contentWindow) { 2788 var d = i.contentWindow.document; 2789 } else { 2790 var d = window.frames[id].document; 2791 } 2792 if(d.location.href != "about:blank" && typeof(i.onComplete) == 'function') { 2793 if(jQuery('#_iframeencode',d.body).length==1){ 2794 i.onComplete(jQuery('#_iframeencode',d.body).val()); 2795 }else{ 2796 i.onComplete(d.body.innerHTML); 2797 } 2798 } 2799 setTimeout(function(){jQuery(i).parent().remove()},500); 2800 } 2801} 2802 2803// Garde en vie la session en cours 2804TZR.keepAlive=function(url){ 2805 if(url) TZR.file_get_contents(url,true); 2806 else TZR.file_get_contents(TZR._sharescripts+'keepalive.php'); 2807} 2808 2809 2810/* selecteur du champ user */ 2811TZR.UserSelector = { 2812 activateField:function(widget) { 2813 var params = widget.data('params'); 2814 widget.simpleTree({ 2815 autoclose:false, 2816 drag:false, 2817 animate:true, 2818 closeroot:true, 2819 afterClick:function(node){ 2820 TZR.UserSelector.afterClick.call(TZR.UserSelector, node, params); 2821 }, 2822 afterAjax:function(node){ 2823 TZR.UserSelector.afterAjax.call(TZR.UserSelector, node, params); 2824 } 2825 }); 2826 }, 2827 afterClick:function(node, params){ 2828 var span=jQuery("span:first span:first", node); 2829 if(span.hasClass("selected")){ 2830 jQuery("span.selected",node).removeClass("hselected selected").addClass("unselected"); 2831 TZR.UserSelector.unSelectUser.call(TZR.UserSelector, node, params); 2832 }else{ 2833 jQuery("span.unselected,span.hselected",node).removeClass("hselected unselected").addClass("selected"); 2834 TZR.UserSelector.selectUser.call(TZR.UserSelector, node, params); 2835 } 2836 // maj des styles parents si nécessaire 2837 if(node.attr('x-type')=='doc'){ 2838 var pul=node.parents("ul:first"); 2839 var pli=node.parents("li:first"); 2840 var spans=jQuery("span:first span:first",pli); 2841 if(jQuery("span.unselected",pul).length==0) spans.removeClass("unselected hselected").addClass("selected"); 2842 else if(jQuery("span.selected",pul).length==0) spans.removeClass("selected hselected").addClass("unselected"); 2843 else spans.removeClass("selected unselected").addClass("hselected"); 2844 } 2845 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 2846 // à voir var container = jQuery("#selectedusers-"+params.varid); 2847 //TZR.Table.saveSomeLangsCheckFields(container.find('input')[0]); 2848 } 2849 }, 2850 afterAjax:function(node, params){ 2851 // applique la selection aux users si le groupe est selectionné lors du dépliage 2852 // ici node = le ul container 2853 var pli = node.parent() 2854 if(jQuery("span:first span:first",pli).hasClass('selected')){ 2855 jQuery("span.unselected",pli).each(function(i, o){ 2856 jQuery(o).trigger(TZR.click_event); 2857 }); 2858 } 2859 var listcontainer = this.getListContainer(this.getInput(params.varid)); 2860 // styles des éléments actuellement selectionnés 2861 var that = this; 2862 if(true /* le hselected est pas positionné sur ajout autocompletion */ 2863 || jQuery("span:first span:first",pli).hasClass('hselected')){ 2864 jQuery("li[x-type='doc']", node).each(function(i, o){ 2865 var oid = jQuery(this).attr('x-value'); 2866 var nodeli = jQuery(this);
2867 if (jQuery(TZR.sprintf("div[data-oid='%s']", oid), listcontainer).length>0){ 2868 if (typeof(params.multivalued) == "undefined" || params.multivalued != "1"){ 2869 nodeli.addClass("node-active"); 2870 jQuery("span>span", nodeli).addClass("selected").removeClass("unselected"); 2871 that.setHasSelected(params); 2872 } else { 2873 jQuery("span:first span:first", jQuery(this)).trigger(TZR.click_event); 2874 } 2875 } 2876 }); 2877 } 2878 }, 2879 getInput:function(id){ 2880 return jQuery("#_INPUT"+id+"autocomplete"); 2881 }, 2882 getListContainer:function(field){ 2883 return field.siblings("ul.selectedusers"); 2884 }, 2885 getTree:function(id){ 2886 return jQuery("#"+id); 2887 }, 2888 getTreeviewSelectedList:function(id){ 2889 var list = []; 2890 jQuery(`#${id}selected > div[data-oid]`).each(function(i,o){ 2891 list.push(jQuery(this).text()); 2892 }); 2893 return {names:list}; 2894 }, 2895 getSelectedList:function(id){ 2896 var container = this.getListContainer(this.getInput(id)); 2897 var list = []; 2898 jQuery("div[data-oid]", container).each(function(i,o){ 2899 list.push(jQuery(this).text()); 2900 }); 2901 return {names:list}; 2902 }, 2903 unSelectUserFromList:function(node, oid){ 2904 var field = node.siblings("input.tzr-link.ui-autocomplete-input").first(); 2905 var params = field.data("autocomplete").params; 2906 var tree = this.getTree(params.varid.replace('autocomplete','')); 2907 var nodeli = jQuery("li[x-value='"+oid+"']", tree); 2908 if (nodeli.length == 0){ 2909 // objet sélectionné pas chargé encore dans le treeview 2910 jQuery("div[data-oid='"+oid+"']", this.getListContainer(field)).remove(); 2911 } else { 2912 jQuery("span>span", nodeli).trigger('click'); 2913 } 2914 }, 2915 unSelectUser:function(node, params){ 2916 var field = this.getInput(params.varid); 2917 var oid = node.attr("x-value"); 2918 if (node.attr('x-type') == 'doc'){ 2919 node.removeClass('doc-active'); 2920 jQuery("div[data-oid='"+oid+"']", this.getListContainer(field)).remove(); 2921 jQuery("span>span.selected", node).removeClass('selected'); 2922 }else { 2923 node.removeClass('folder-active'); 2924 jQuery("li[x-type='doc']>span>span.selected", node).each(function(i, o){ 2925 jQuery(o).trigger(TZR.click_event); 2926 }); 2927 } 2928 }, 2929 // reset selection pour le cas monovalué 2930 resetSelected:function(params){ 2931 var container = this.getListContainer(this.getInput(params.varid)); 2932 var tree = this.getTree(params.varid.replace('autocomplete','')); 2933 var that = this; 2934 jQuery("div[data-oid]", container).each(function(i, o){ 2935 var oid = jQuery(this).data('oid'); 2936 jQuery(this).remove(); 2937 var nodeli = jQuery(TZR.sprintf("li[x-value='%s']", oid), tree); 2938 nodeli.removeClass("doc-active"); 2939 jQuery("span", nodeli).removeClass("selected").addClass("unselected"); 2940 }); 2941 that.setHasSelected(params); 2942 }, 2943 // has selected pour un dossier 2944 setHasSelected:function(params){ 2945 var tree = this.getTree(params.varid.replace('autocomplete','')); 2946 jQuery("li[x-type='folder']", tree).each(function(i, o){ 2947 var node = jQuery(this); 2948 var hasSelected = false; 2949 var hasAll = true; 2950 node.find("ul>li>span>span").each(function(i,o){ 2951 if (jQuery(this).hasClass('selected')) 2952 hasSelected = true; 2953 else 2954 hasAll = false; 2955 }); 2956 var span = node.find('>span>span'); 2957 if (hasSelected && hasAll) 2958 span.removeClass('hselected').addClass('selected'); 2959 else if (hasSelected) 2960 span.removeClass('selected').addClass('hselected'); 2961 else 2962 span.removeClass('selected').removeClass('hselected'); 2963 }); 2964 }, 2965 // nettoyage eventuel avant ajout 2966 prepareUserSelection:function(params){ 2967 if (typeof(params.multivalued) == "undefined" || params.multivalued != "1"){ 2968 this.resetSelected(params); 2969 } 2970 }, 2971 // user/groupe selectionné = un 'dest[]' avec son oid en valeur 2972 selectUser:function(node, params){ 2973 this.prepareUserSelection(params); 2974 var field = this.getInput(params.varid); 2975 if (node.attr('x-type') == 'doc'){ 2976 node.addClass('doc-active'); 2977 this.addToSelectedList(field, 2978 params.varid, 2979 node.attr('x-value'), 2980 node.find("span>
2980span").html()); 2981 } else if (params.multivalued){ 2982 node.addClass('folder-active'); 2983 var users = jQuery("ul>li[x-type='doc']", node); 2984 if (users.length>0){ 2985 jQuery("ul>li[x-type='doc']", node).each(function(i, o){ 2986 TZR.UserSelector.selectUser.call(TZR.UserSelector, jQuery(o), params); 2987 }); 2988 } else { 2989 // on charge et sélectionne le détail 2990 jQuery("img.trigger", node).trigger('click'); 2991 } 2992 } 2993 }, 2994 unSelectAll:function(elt){ 2995 var params = jQuery(elt).parents('ul.userSelector').data('params'); 2996 var container = this.getListContainer(this.getInput(params.varid)); 2997 jQuery("div[data-oid]>button", container).trigger('click'); 2998 this.setSelectedNumber(params.varid); 2999 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 3000 // à voir var container = jQuery("#selectedusers-"+params.varid); 3001 // à voir TZR.Table.saveSomeLangsCheckFields(container.find('input')[0]); 3002 } 3003 return; 3004 }, 3005 addToSelectedList:function(field, id, oid, label){ 3006 var container = this.getListContainer(field); 3007 if (container.find("div[data-oid='"+oid+"']").length>0) 3008 return; 3009 var fieldname = field.data('autocomplete').params.field; 3010 var button=" <button onclick=\"TZR.UserSelector.unSelectUserFromList.call(TZR.UserSelector, jQuery(this).parents('ul.selectedusers'), '"+oid+"');\" class=\"btn btn-default btn-md btn-inverse\" type=\"button\"><span class=\"glyphicon csico-delete\" aria-hidden=\"true\"></span></button>"; 3011 var input = TZR.sprintf("<input name=\"%s[]\" type=\"hidden\" value=\"%s\">", fieldname, oid); 3012 jQuery(container).append(TZR.sprintf("<div data-oid=\"%s\">%s %s %s</div>", oid, button, label, input)); 3013 3014 }, 3015 // sélection depuis la boite d'autocomplétion 3016 autoCompleteSelection:function(id, oid, label){ 3017 3018 var field = jQuery("#_INPUT"+id); 3019 field.val(''); 3020 3021 var params = field.data("autocomplete").params; 3022 3023 params.varid = id.replace('autocomplete',''); 3024 this.prepareUserSelection(params); 3025 3026 this.addToSelectedList(field, params.varid, oid, label); 3027 3028 var tree = this.getTree(params.varid); 3029 var nodeli = jQuery("li[x-value='"+oid+"']", tree); 3030 if (nodeli.length > 0) 3031 jQuery("span>span", nodeli).trigger('click'); 3032 }, 3033 isValid:function(id, fmt, color){ 3034 var selectedcontainer = this.getListContainer(this.getInput(id)); 3035 var selected = []; 3036 jQuery("div[data-oid]", selectedcontainer).each(function(){ 3037 selected.push(jQuery(this).data('oid')); 3038 }); 3039 selected = selected.join(); 3040 var exp = new RegExp(fmt); 3041 if (!exp.test(selected)){ 3042 TZR.setElementErrorState(jQuery(selectedcontainer).parent(),false,color); 3043 TZR.isFormOk = false; 3044 return false; 3045 } 3046 return true; 3047 } 3048}; 3049 3050/* Gestion des champs thesaurus */ 3051// Active le thesaurus 3052TZR.activeThesaurus=function(varid, optimizeWith) { 3053 var tree = jQuery("#treecontainer"+varid), 3054 form = tree.parents('form'), 3055 nodeData = tree.data(), 3056 filter; 3057 if (nodeData.quickquery == 1) 3058 filter = '' 3059 else { 3060 filter = []; 3061 jQuery('input[name^="'+optimizeWith+'"]', form).each(function(i, elt){ 3062 if (elt.value) 3063 filter.push(elt.value); 3064 }); 3065 filter.sort(); 3066 } 3067 tree.data({oldfilter: JSON.stringify(filter), cache: {}}); 3068 form.on('change', 'input[name^="'+optimizeWith+'"]', function(e){ 3069 jQuery("#treecontainer"+varid+">ul.treefiltered").show(); 3070 // timeout pour remove 3071 setTimeout(function(){ 3072 TZR.thesaurusRefrechFiltered(varid, false); 3073 }, 500); 3074 }) 3075} 3076TZR.thesaurusClick = function(varid, event) { 3077 jQuery.Event(event).stopPropagation(); 3078 var jsrc = jQuery(event.target || event.srcElement), 3079 li = (jsrc.is('li') ? jsrc : jsrc.parents('li:first')), 3080 oid = li.attr('tzroid'); 3081 if (jsrc.is('.root')) { 3082 if (jsrc.is('.close') && jsrc.parent().is('.quickquery')) 3083 return TZR.openThesaurusFolder(jsrc, varid, ''); 3084 jsrc.toggleClass('open').toggleClass('close').children('ul').toggle(); 3085 if (jsrc.is('.open') && jsrc.parent().is('.treefiltered')) 3086 return TZR.thesaurusRefrechFiltered(varid, true); 3087 return false;
3088 } 3089 if (oid == undefined) 3090 return false; 3091 if (jsrc.is('.ico, .trigger') && li.is('.folder')) 3092 return TZR.openThesaurusFolder(li, varid, oid); 3093 else 3094 return TZR.selectThesaurusItem(li, varid, oid); 3095} 3096TZR.thesaurusRefrechFiltered = function(varid, ajax) { 3097 var tree = jQuery("#treecontainer"+varid), 3098 nodeData = tree.data(), 3099 treefiltered = tree.children('.treefiltered'), 3100 filter = [], 3101 optimizeWithInputs = jQuery('input[name^="'+nodeData.optimizewith+'\[\]"]'); 3102 if (optimizeWithInputs.length) // optimizewith present 3103 optimizeWithInputs.each(function(i, elt){ 3104 if (elt.value) 3105 filter.push(elt.value); 3106 }); 3107 else //quickquery & optimizewith absent 3108 filter = nodeData.optimizevalues.split(' '); 3109 filter.sort(); 3110 var filterString = JSON.stringify(filter); 3111 if (nodeData.oldfilter != undefined && filterString != nodeData.oldfilter) { 3112 if (!filter.length && tree.children('.full').length) 3113 treefiltered.hide(); 3114 nodeData.cache[nodeData.oldfilter] = treefiltered.html(); 3115 if (nodeData.cache[filterString] != undefined) { 3116 treefiltered.html(nodeData.cache[filterString]); 3117 tree.data({oldfilter: filterString}) 3118 return; 3119 } 3120 if (!ajax) 3121 return jQuery("li.root", treefiltered).removeClass('open').addClass('close').children('ul').hide(); 3122 var values = []; 3123 jQuery('#table'+nodeData.varid+' input[name^="'+nodeData.field+'"]').each(function(i, elt){ 3124 if (elt.value) 3125 values.push(elt.value); 3126 }); 3127 jQuery('li.root ul:first', treefiltered).addClass('ajax').html('').show(); 3128 jQuery.ajax({ 3129 url:nodeData.reloadUrl, 3130 data: {value:values, filter:filter,justfiltered:1}, 3131 success: function(data){ 3132 if (data) { 3133 if (treefiltered.length == 0) 3134 tree.prepend(data); 3135 else 3136 treefiltered.replaceWith(data); 3137 } 3138 tree.data({oldfilter: filterString}); 3139 if (nodeData.quickquery) 3140 tree.find(">ul").addClass("treefiltered"); 3141 tree.find(">ul.treefiltered").show() 3142 .children("li.root").removeClass('close').addClass('open') 3143 .children('ul').show(); 3144 } 3145 }); 3146 } 3147} 3148// (un)select thesaurus entry 3149TZR.selectThesaurusItem = function(li, varid, oid) { 3150 // certains items ne sont pas séléctionnables bien qu'affichés 3151 var nosel = li.attr('data-notselectable'); 3152 if (nosel == 1) 3153 return; 3154 var parentDiv = li.parents('#div'+varid); 3155 var tree = jQuery("#treecontainer"+varid, parentDiv); 3156 var table = jQuery('#table'+varid.replace('filtered', ''), parentDiv); 3157 var span = jQuery("span:first span:first", li); 3158 if (span.hasClass("selected")) { 3159 jQuery('li[tzroid="'+oid+'"] > span > span.selected',"#div"+varid).removeClass("selected"); 3160 jQuery('input[value="'+oid+'"]',table).trigger('change').parents('tr:first').remove(); 3161 } else { 3162 if (jQuery('input[value="'+oid+'"]',table).length == 1){ 3163 return; 3164 } 3165 if(!tree.data('multivalued')){ 3166 TZR.thesaurusClick(varid,{target:tree.find('span.selected')}); 3167 } 3168 var tds = jQuery('tr.model',table).clone().appendTo(table).removeClass('model none').find('td'); 3169 if (tds.length==0) 3170 return; 3171 var parents = span.parentsUntil('li.root'); 3172 var text=''; 3173 jQuery('li[tzroid="'+oid+'"]>span>span',"#div"+varid).addClass("selected"); 3174 jQuery('input',tds[0]).val(oid).trigger('change'); 3175 for (var i=parents.length-1;i>=0;i--) { 3176 if (parents[i].nodeName == "LI") { 3177 text += jQuery('span:first span:first',parents[i]).html()+" > "; 3178 } 3179 } 3180 tds[1].innerHTML = text.substr(0,text.length-3); 3181 } 3182 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 3183 TZR.Table.saveSomeLangsCheckFields(table.find('input')[0]); 3184 } 3185 return false; 3186} 3187 3188// open thesaurus folder, if empty populate with json data 3189TZR.openThesaurusFolder = function(li, varid, oid) { 3190 var subNode = li.find('>ul').toggle(); 3191 li.toggleClass('open').toggleClass('close'); 3192 if (!subNode.length) 3193 return false; 3194 if (!subNode.html().length) { 3195 var tree = jQuery("#treecontainer"+varid), 3196 nodeData = tree.data(); 3197 if (li.is('.root') && nodeData.quickquery && nodeData.optimizewith) 3198 return TZR.thesaurusRefrechFiltered(varid, true); 3199 var values = []; 3200 jQuery('input[name^="'+nodeData.field+'"]').each(function(i, elt){ 3201 if (elt.value) 3202 values.push(elt.value); 3203 }); 3204 subNode.addClass('ajax').show(); 3205 jQuery.ajax({ 3206 url:nodeData.reloadUrl, 3207 data: {value:values, justfiltered:0, top:oid, quickquery:nodeData.quickquery}, 3208 success: function(data){ 3209 if (data) { 3210 subNode.removeClass('ajax').html(data); 3211 } 3212 } 3213 }); 3214 } 3215 return false;
3216}; 3217// 3218TZR.initThesaurusContextMenu = function(){ 3219 jQuery(document).on("contextmenu", '.thesaurustree', function(e){ 3220 var jTarget = jQuery(e.target), 3221 tree = jQuery(e.currentTarget); 3222 if(!tree.data('rw')) return; 3223 e.stopPropagation(); 3224 TZR.thesaurusMenu(jTarget); 3225 TZR.thesaurusShowMenu(jTarget, e); 3226 return false; 3227 }); 3228}; 3229// menu contextuel 3230jQuery(document).on("contextmenu", '.thesaurustree', function(e){ 3231 var jTarget = jQuery(e.target), 3232 tree = jQuery(e.currentTarget); 3233 if(!tree.data('rw')) return; 3234 3235 e.stopPropagation(); 3236 TZR.thesaurusMenu(jTarget); 3237 TZR.thesaurusShowMenu(jTarget, e); 3238 return false; 3239}); 3240 3241TZR.thesaurusShowMenu = function(node,e){ 3242 var event = jQuery.Event("mousedown"); 3243 event.button = 2; 3244 var event2 = jQuery.Event("mouseup"); 3245 event2.button = 2; 3246 event2.pageX=e.pageX; 3247 event2.pageY=e.pageY; 3248 node.trigger(event); 3249 node.trigger(event2); 3250 return false; 3251 setTimeout(function(){ 3252 node.trigger(event2); 3253 },50); 3254 return false; 3255} 3256TZR.thesaurusMenu = function(node) { 3257 if(jQuery(node).is('.hasContextMenu')) return; 3258 var nodeData = jQuery(node).parents('.thesaurustree').data(); 3259 var contextMenu = jQuery(node).contextMenu({ 3260 menu:'xthesaurusmenu', 3261 beforeShow:function(o) { 3262 var m=jQuery(node); 3263 if (!m.hasClass('simpleTree')) 3264 m = m.parents('ul.simpleTree:first'); 3265 if(jQuery(o).parents('li:first').hasClass('root')) { 3266 this.disableContextMenuItems('#del,#edit,#cut'); 3267 } else { 3268 this.enableContextMenuItems('#del,#edit,#cut'); 3269 } 3270 if (m.data('topaste')) { 3271 this.enableContextMenuItems('#paste'); 3272 } else { 3273 this.disableContextMenuItems('#paste'); 3274 } 3275 }}, 3276 function(action, el, pos) { 3277 if (action.lastIndexOf('#') !== -1) 3278 action = action.substr(action.lastIndexOf('#')+1); 3279 var jtree=el.parents('ul.simpleTree:first'); 3280 var tree=jtree[0]; 3281 var jli=el.parents('li:first'); 3282 var oid=jli.attr('tzroid'); 3283 // ajout un noeud, retourne le li 3284 var addNode = function() { 3285 if (jli.is(".folder")) { 3286 var tmpNode = jQuery('<li class="line"> </li><li class="doc"><div style="position:absolute;"><div class="ico"></div></div><span class="text"><span></span></span></li><li class="line"></li>'); 3287 tmpNode.prependTo(jQuery('>ul', jli)); 3288 jQuery('>ul', jli).show(); 3289 jli.removeClass('close').addClass('open'); 3290 var li = jQuery(tmpNode[1]); 3291 } else { 3292 if (!jli.is(".root")) 3293 jli.addClass("folder open").removeClass('doc'); 3294 var tmpNode = jQuery('<ul><li class="line"> </li><li class="doc last"><div style="position:absolute;"><div class="ico"></div></div><span class="text"><span></span></span></li><li class="line-last"></li></ul>'); 3295 tmpNode.appendTo(jli); 3296 var li = jQuery('li.doc', tmpNode); 3297 } 3298 return li; 3299 } 3300 var url = TZR._sharescripts+'ajax8.php'; 3301 var data = {'class':'Seolan_Field_Thesaurus_Thesaurus', 3302 'moid':nodeData.moid, 3303 'table':nodeData.xtable, 3304 'field':nodeData.field, 3305 'value':null, 3306 'parentoid':null, 3307 'oid':oid 3308 }; 3309 if (action == 'copy') { 3310 jtree.data('topaste',{oid:oid,text:el.text(),mode:'copy',node:jli}); 3311 } else if (action == 'cut') { 3312 jtree.data('topaste',{oid:oid,text:el.text(),mode:'cut',node:jli}); 3313 jli.addClass('tocut'); 3314 } else if (action == "paste") { 3315 var param = jtree.data('topaste'); 3316 data.value = param.value; 3317 data.parentoid = param.oid; 3318 data.oid = null; 3319 if (param.mode =='copy') { 3320 data['function'] = 'xthesaurusdef_copyvalue'; 3321 jQuery.ajax({url:url,async:false,data:data, success: function(data){ 3322 if (data) { 3323 var li = addNode(); 3324 li.attr('tzroid', data); 3325 jQuery('>span>span', li).html(param.text); 3326 } 3327 }}); 3328 } else { 3329 data['function']='xthesaurusdef_cutvalue'; 3330 jQuery.ajax({url:url,async:false,data:data,success:function(data){ 3331 if (data) { 3332 var li = addNode(); 3333 li.attr('tzroid', data); 3334 jQuery('>span>span', li).html(param.text); 3335 jQuery(param.node).remove(); 3336 } 3337 }}); 3338 } 3339 jtree.data('topaste',''); 3340 } else if(action == "del") { 3341 data['function'] = 'xthesaurusdef_delvalue'; 3342 jQuery.ajax({url:url,data:data,async:false,success:function(data){ 3343 if (data == "ok") { 3344 var parentLi = jli.parents('li:first'); 3345 TZR.removeThesaurusValue(nodeData.varid,oid); 3346 if (jQuery('.doc, .folder', parentLi).length == 1) 3347 parentLi.removeClass('folder').addClass('doc'); 3348 else if (jQuery('.doc, .folder', parentLi).length == 2) { 3349 jQuery('.doc, .folder', parentLi).addClass('last'); 3350 } 3351 jli.prev().remove(); 3352 jli.remove(); 3353 } 3354 }}); 3355 } else if (action == "edit") { 3356 var input=jQuery('<input type="text" name="value">'); 3357 input.val(el.html());
3358 input.keypress(function(e){ 3359 if (e.which==0 || e.which==27) { 3360 jQuery(this).parent().find('span:first').show(); 3361 jQuery(this).remove(); 3362 } else if (e.which==13) { 3363 var _this=this; 3364 data.value=this.value; 3365 data['function'] = 'xthesaurusdef_editvalue'; 3366 jQuery.ajax({url:url,data:data,success:function(data){ 3367 var span=jQuery(_this).parent().find('span:first'); 3368 var li=span.parents('li:first'); 3369 if(data=="ok"){ 3370 span.html(_this.value); 3371 span.click(); 3372 } 3373 span.show(); 3374 jQuery(_this).remove(); 3375 }}); 3376 return false; 3377 } 3378 }).bind('click dblclick mousedown mouseup mousemove',function(e){e.stopPropagation();}); 3379 el.hide().parent().append(input); 3380 input[0].focus(); 3381 } else if(action=='add') { 3382 var input=jQuery('<input type="text" name="value">'); 3383 input.keypress(function(e){ 3384 if (e.which==0) { 3385 jQuery(this).parent().parent().remove(); 3386 } else if(e.which==13) { 3387 var _this=this; 3388 data['function'] = 'xthesaurusdef_addvalue'; 3389 data.value = this.value; 3390 data.parentoid=el.parents('li:first').attr('tzroid'); 3391 jQuery.ajax({url:url,async:false,data:data,success:function(data){ 3392 if(data) { 3393 jQuery(_this).parent().html(_this.value).parents('li:first').attr('tzroid',data); 3394 jQuery(_this).remove(); 3395 } else { 3396 jQuery(_this).parent().parent().remove(); 3397 } 3398 }}); 3399 return false; 3400 } 3401 }).bind('click dblclick mousedown mouseup mousemove',function(e){e.stopPropagation();}); 3402 var li = addNode(); 3403 jQuery('>span>span', li).html(input); 3404 } 3405 }).addClass('hasContextMenu'); 3406} 3407// Supprime une valeur du thesaurus de la selection 3408TZR.removeThesaurusValue=function(varid,oid){ 3409 if(typeof(oid)=='object'){ 3410 var table = jQuery(oid).parents('#table'+varid); 3411 oid=jQuery(oid).parents('tr:first').find('input').val(); 3412 } else 3413 var table=jQuery('#table'+varid); 3414 jQuery('input[value="'+oid+'"]',table).change().parents('tr:first').remove(); 3415 jQuery('li[tzroid="'+oid+'"] span.selected',"#div"+varid).removeClass("selected"); 3416 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 3417 TZR.Table.saveSomeLangsCheckFields(table.find('input')[0]); 3418 } 3419} 3420// Ajoute une valeur suite à une saisie via le champ en autocomplete 3421TZR.autocompleteThesaurus=function(varid,oid,v){ 3422 if(oid && v){ 3423 var tree = jQuery("#treecontainer"+varid); 3424 if(!tree.data('multivalued')){ 3425 TZR.thesaurusClick(varid,{target:tree.find('span.selected')}); 3426 } 3427 var table=jQuery('#table'+varid); 3428 if(table.find('input[value="'+oid+'"]').length>0) return; 3429 var tds=jQuery('tr:first',table).clone().appendTo(table).show().find('td'); 3430 if(tds.length==0) return; 3431 jQuery('input',tds[0]).val(oid).trigger('change'); 3432 tds[1].innerHTML=v; 3433 jQuery('li[tzroid="'+oid+'"]>span>span',"#div"+varid).addClass("selected"); 3434 jQuery('#_INPUT'+varid).val(''); 3435 } 3436} 3437 3438// Fonctions d'ajout de ligne, de colonne et d'application de tablesorter à un champ \Seolan\Field\Table\Table 3439TZR.XTableAddLine=function(tableid,fname){ 3440 var jt=jQuery('#'+tableid); 3441 var tr=jt[0].tBodies[0].rows[jt[0].tBodies[0].rows.length-1]; 3442 var jnewtr=jQuery(tr).clone(true); 3443 var reg=new RegExp(fname+"\\[(\\d+)\\]","g"); 3444 var reg2=new RegExp("\\[_rlabels\\]\\[(\\d+)\\]","g"); 3445 var regres=reg.exec(tr.innerHTML); 3446 var newnum=parseInt(regres[1])+1; 3447 jnewtr.html(tr.innerHTML.replace(reg,fname+"["+newnum+"]").replace(reg2,"[_rlabels]["+newnum+"]").replace('>'+newnum+'</td>','>'+(newnum+1)+'</td>')); 3448 jnewtr.insertAfter(tr).find('input').keyup(function(){jQuery("#"+tableid).trigger("update");}).bind('click mousedown',function(e){e.stopPropagation();}).val(''); 3449 jt.trigger("update"); 3450} 3451TZR.XTableAddColumn=function(tableid,fname){ 3452 var jt=jQuery('#'+tableid); 3453 var trs=jt.find('tr') 3454 trs.each(function(i){ 3455 if(this.cells.length>1){ 3456 var reg=/(\[[^\]]+\])\[(\d+)\]/g; 3457 var td=this.cells[this.cells.length-2]; 3458 var jnewtd=jQuery(td).clone(true); 3459 var regres=reg.exec(td.innerHTML); 3460 var newnum=parseInt(regres[2])+1; 3461 jnewtd.html(td.innerHTML.replace(reg,"$1["+newnum+"]")); 3462 jnewtd.insertAfter(td).find('input').keyup(function(){jQuery("#"+tableid).trigger("update");}).bind('click mousedown',function(e){e.stopPropagation();}).val('');; 3463 } 3464 }); 3465 jt.trigger("update"); 3466} 3467TZR.XTableSorter=function(tableid){ 3468 jQuery('#'+tableid).find('input').keyup(function(){jQuery("#"+tableid).trigger("update");}).bind('click mousedown',function(e){e.stopPropagation();}); 3469 jQuery('#'+tableid).tablesorter({textExtraction:function(node){ 3470 var i=jQuery('input',node); 3471 if(i.length>0) return i[0].value; 3472 else return node.innerHTML; 3473 }}); 3474} 3475 3476/* Champ image */ 3477TZR.Image=new Object(); 3478 3479/* Agenda */ 3480TZR.Calendar=new Object(); 3481// Ajoute/deplace/supprime un evenement/note dans le tableau des evenements/notes selon l'heure de debut/fin 3482TZR.Calendar.orderEvent=function(uniqid,obj,tomove,del){ 3483 var found=false; 3484 var notes=obj.notes; 3485 var evs=obj.evs; 3486 var added=false; 3487 if(!tomove.allday || tomove.allday=='0'){ 3488 for(var i in evs){ 3489 var e=evs[i]; 3490 if(e.id==tomove.id){ 3491 evs.splice(i,1); 3492 break; 3493 } 3494 } 3495 if(del==undefined){ 3496 for(var i in evs){ 3497 var e=evs[i]; 3498 if(e._isod>tomove._isod || (e._isod==tomove._isod && (e._bh>tomove._bh || (e._bh==tomove._bh && e._eh>=tomove._eh) || e._bd>tomove._bd))){ 3499 evs.splice(i,0,tomove); 3500 added=true; 3501 break; 3502 } 3503 } 3504 if(!added) evs.push(tomove); 3505 } 3506 }else{ 3507 if(del){ 3508 for(var i in notes){ 3509 var n=notes[i]; 3510 if(n.id==tomove.id){ 3511 notes.splice(i,1); 3512 break; 3513 } 3514 } 3515 } 3516 } 3517}, 3518// Caclule la position et la taille des evenements (les evenements doivent etre trié par heure de debut) 3519TZR.Calendar.calculatePosition=function(uniqid,obj){ 3520 var dates=obj.dates; 3521 var evs=obj.evs; 3522 var max=obj.max; 3523 for(var num in dates){ 3524 var date=dates[num]; 3525 max[date]=0; 3526 } 3527 var rows=new Object(); 3528 var cols=new Object(); 3529 var groupinfos={max:1,rows:{},cols:{},end:-1,hour:0,date:"1000-01-01"}; 3530 for(var i in evs){ 3531 var e=evs[i]; 3532 var ok=false; 3533 var l=TZR.Calendar.getEventLimit(e); 3534 var ee=l.e; 3535 var eb=l.b; 3536 var nbcase=l.d; 3537 var c=0; 3538 if(groupinfos.hour<=eb || e._isod!=groupinfos.date){ 3539 groupinfos={max:1,rows:{},cols:{},hour:ee,date:e._isod}; 3540 var newgroup=true; 3541 }else{ 3542 var newgroup=false; 3543 } 3544 while(!ok && groupinfos.rows!=undefined && groupinfos.rows[eb]!=undefined && groupinfos.rows[eb][c]!=undefined){ 3545 ok=true; 3546 for(var j=0;j<nbcase;j++){ 3547 if(groupinfos.rows[eb+j]!=undefined && groupinfos.rows[eb+j][c]!=un
3547defined){ 3548 c++; 3549 ok=false; 3550 break; 3551 } 3552 } 3553 } 3554 if(!newgroup){ 3555 if(c+1>groupinfos.max) groupinfos.max=c+1; 3556 if(ee>groupinfos.hour) groupinfos.hour=ee; 3557 } 3558 e.groupinfos=groupinfos; 3559 e.col=c; 3560 e.row=eb; 3561 e.h=nbcase; 3562 e.w=1; 3563 for(j=0;j<nbcase;j++){ 3564 if(groupinfos.rows[eb+j]==undefined) groupinfos.rows[eb+j]=new Object(); 3565 if(groupinfos.cols[c]==undefined) groupinfos.cols[c]=new Object(); 3566 groupinfos.rows[eb+j][c]=e; 3567 groupinfos.cols[c][eb+j]=e; 3568 } 3569 } 3570 for(var i in evs){ 3571 e=evs[i]; 3572 var stop=false; 3573 var totest=new Array(); 3574 for(j=0;j<e.h;j++){ 3575 totest.push(e.row+j); 3576 } 3577 for(j=e.col+1;j<e.groupinfos.max;j++){ 3578 for(k in totest){ 3579 k=totest[k]; 3580 if(e.groupinfos.cols[j]!=undefined && e.groupinfos.cols[j][k]!=undefined){ 3581 stop=true; 3582 break; 3583 } 3584 } 3585 if(stop) break; 3586 e.w++; 3587 } 3588 } 3589} 3590// Lance la mise à jour de l'agenda 3591TZR.Calendar.drawAgenda=function(uniqid,obj){ 3592 for(var e in obj.notes){ 3593 e=obj.notes[e]; 3594 TZR.Calendar.createNoteDiv(uniqid,obj,e); 3595 } 3596 var nl=0; 3597 for(var i in obj.dates){ 3598 var l=jQuery('#agad'+obj.dates[i]+'-'+uniqid+'>div.note').length+1; 3599 if(l>nl){ 3600 document.getElementById('agallday'+uniqid).style.height=(l*obj.noteHeight)+"px"; 3601 nl=l; 3602 } 3603 } 3604 for(var e in obj.evs){ 3605 e=obj.evs[e]; 3606 TZR.Calendar.createEventDiv(uniqid,obj,e); 3607 } 3608} 3609 3610// Créé/met à jour la div d'une note 3611TZR.Calendar.createNoteDiv=function(uniqid,obj,e){ 3612 e.id=e.id.replace(':','_'); 3613 var ag=document.getElementById('agdaysallday-'+uniqid); 3614 var jdiv=jQuery('#'+e.id+"-"+uniqid); 3615 var div=jdiv[0]; 3616 if(div==undefined){ 3617 div=document.createElement("div"); 3618 div.innerHTML='<div class="event-w"></div><div class="event-e"'+(e.cat?' style="background-color:'+e.cat+';"':'')+'></div><div class="event-s"></div><div class="event-n"></div><div class="event-content"></div>'; 3619 div.style.backgroundColor=e.color; 3620 div.id=e.id+"-"+uniqid; 3621 div.style.height=obj.noteHeight+"px"; 3622 div.style.position="relative"; 3623 div.className="note"; 3624 document.getElementById('agad'+e._isod+"-"+uniqid).appendChild(div); 3625 jdiv=jQuery(div); 3626 div.tzrevent=e; 3627 // Setter : met à jour le texte html de l'evenement (heure + titre) 3628 div.setEventText=function(pos){ 3629 jQuery('.event-content',this).html(TZR.Calendar.getEventText(uniqid,obj,this.tzrevent,pos)); 3630 } 3631 // Active deplacement 3632 if(e.rw && e._obd==e._bd && e._oed==e._ed){ 3633 jdiv.draggable({grid:[1,999],containment:'parent',axis:"y",start:function(event,ui){ 3634 TZR.Calendar.startDrag(uniqid,obj,event); 3635 obj.actEvent="drag"; 3636 obj.actTarget=event.target; 3637 jQuery('div.agadday',ag).mouseenter(function(event){ 3638 jdiv.mousemove(function(){return false;}) 3639 jQuery(obj.actTarget).appendTo(this); 3640 obj.actTarget.tzrevent._isod=this.id.substr(4,10); 3641 setTimeout(function(){jdiv.unbind('mousemove');},100); 3642 }); 3643 },stop:function(event,ui){ 3644 TZR.Calendar.stopDrag(uniqid,obj,event); 3645 jQuery('div.agadday',ag).unbind('mouseenter'); 3646 }}); 3647 } 3648 // Tooltip 3649 TZR.Calendar.applyHottip(uniqid,obj,jdiv); 3650 jdiv.mousedown(function(event){ 3651 // Stoppe la propagation de l'evenement (sinon ie active le selected quand on veut le deplacer) 3652 event.stopPropagation(); 3653 }); 3654 } 3655 div.setEventText(); 3656} 3657 3658// Créé/met à jour la div d'un evenement 3659TZR.Calendar.createEventDiv=function(uniqid,obj,e){ 3660 e.id=e.id.replace(':','_'); 3661 var ag=document.getElementById('agdays-'+uniqid); 3662 var jdiv=jQuery('#'+e.id+"-"+uniqid); 3663 var div=jdiv[0]; 3664 if(div==undefined){ 3665 div=document.createElement("div"); 3666 div.innerHTML='<div class="event-w"></div><div class="event-e"'+(e.cat?' style="background-color:'+e.cat+';"':'')+'></div><div class="event-s"></div><div class="event-n"></div><div class="event-content"></div>'; 3667 div.style.backgroundColor=e.color; 3668 div.id=e.id+"-"+uniqid; 3669 div.className="event"; 3670 document.getElementById('ag'+e._isod+"-"+uniqid).appendChild(div); 3671 jdiv=jQuery(div); 3672 div.tzrevent=e; 3673 // Setter : met à jour le texte html de l'evenement (heure + titre) 3674 div.setEventText=function(pos){ 3675 jQuery('.event-content',this).html(TZR.Calendar.getEventText(uniqid,obj,this.tzrevent,pos)); 3676 } 3677 // Active deplacement 3678 if(e.rw && e._obd==e._bd && e._oed==e._ed){ 3679 jdiv.draggable({grid:[1,obj.lineHeight],containment:'parent',axis:"y",drag:function(event,ui){ 3680 event.target.setEventText(TZR.Calendar.positionToHour(uniqid,obj,event.target)); 3681 },start:function(event,ui){ 3682 TZR.Calendar.startDrag(uniqid,obj,event); 3683 obj.actEvent="drag"; 3684 obj.actTarget=event.target; 3685 event.target.style.width="100%"; 3686 event.target.style.left="0px"; 3687 jQuery('div.agday',ag).mouseenter(function(event){ 3688 jdiv.mousemove(function(){return false;}); 3689 jQuery(obj.actTarget).appendTo(this); 3690 obj.actTarget.tzrevent._isod=this.id.substr(2,10);
3691 setTimeout(function(){jdiv.unbind('mousemove');},100); 3692 }); 3693 },stop:function(event,ui){ 3694 TZR.Calendar.stopDrag(uniqid,obj,event); 3695 jQuery('div.agday',ag).unbind('mouseenter'); 3696 }}); 3697 } 3698 3699 // Active redimmenssionement 3700 if(e.rw && (e._obd==e._bd || e._oed==e._ed)){ 3701 if(e._obd==e._bd && e._oed==e._ed) var handles='s,n'; 3702 else if(e._obd==e._bd) var handles='n'; 3703 else if(e._oed==e._ed) var handles='s'; 3704 jdiv.resizable({grid:obj.lineHeight,containment:document.getElementById('ag'+e._isod+"-"+uniqid),handles:handles,start:function(event,ui){ 3705 obj.actEvent="resize"; 3706 TZR.Calendar.startDrag(uniqid,obj,event); 3707 },stop:function(event,ui){ 3708 TZR.Calendar.stopDrag(uniqid,obj,event); 3709 },resize:function(event,ui){ 3710 if(ui.size.height!=ui.originalSize.height){ 3711 var pos=""; 3712 if(obj.actEvent=="" || obj.actEvent=="resize"){ 3713 if(ui.position.top!=ui.originalPosition.top) obj.actEvent="resizen"; 3714 else obj.actEvent="resizes"; 3715 } 3716 if(obj.actEvent=="resizen") pos=TZR.Calendar.positionToHour(uniqid,obj,event.target,"begin"); 3717 else pos=TZR.Calendar.positionToHour(uniqid,obj,event.target,"end"); 3718 event.target.setEventText(pos); 3719 } 3720 }}); 3721 } 3722 // Tooltip 3723 TZR.Calendar.applyHottip(uniqid,obj,jdiv); 3724 jdiv.click(function(event){ 3725 var _now=new Date().getTime(); 3726 if(this.lastclick && _now-this.lastclick<300){ 3727 obj.vuniqid.jQueryLoad(e.url+"&display="+obj.display); 3728 return; 3729 } 3730 this.lastclick=_now; 3731 }).mousedown(function(event){ 3732 // Stoppe la propagation de l'evenement (sinon ie active le selected quand on veut le deplacer) et supprime un eventuel hottip 3733 event.stopPropagation(); 3734 }); 3735 } 3736 // Position 3737 var l=Math.floor(100/e.groupinfos.max)*e.col; 3738 if(e.col+e.w==e.groupinfos.max) var w=100-Math.floor(100/e.groupinfos.max)*e.col; 3739 else w=Math.floor(100/e.groupinfos.max)*e.w; 3740 div.style.position="absolute"; 3741 div.style.left=l+"%"; 3742 div.style.top=(e.row*obj.lineHeight-obj.agStart*obj.lineHeight*4)+"px"; 3743 div.style.width=w+'%'; 3744 div.style.height=(e.h*obj.lineHeight)+'px'; 3745 div.setEventText(); 3746} 3747 3748// Initialise un drag/resize : ecouteur touche pour annuler via ECHAP 3749TZR.Calendar.startDrag=function(uniqid,obj,e){ 3750 jQuery(jQuery.bt.vars.closeWhenOpenStack).btOff(); 3751 var o=e.target; 3752 var jo=jQuery(o); 3753 var pos=jo.position(); 3754 jQuery(document).bind('keydown',{parent:o.parentNode,target:o,top:jo.css('top'),left:jo.css('left'),width:jo.css('width'),height:jo.css('height'),obj:obj},TZR.Calendar.cancelDrag); 3755} 3756 3757// Termine un drag/resize : efface ecouteur touche pour annuler via ECHAP, sauvegarde des nouvelles heures/actualise agenda 3758TZR.Calendar.stopDrag=function(uniqid,obj,e){ 3759 var o=e.target; 3760 jQuery(document).unbind('keydown',TZR.Calendar.cancelDrag); 3761 if(obj.actEvent!=""){ 3762 if(!o.tzrevent.allday || o.tzrevent.allday=='0'){ 3763 var hours=TZR.Calendar.positionToHour(uniqid,obj,o); 3764 if(obj.actEvent!="resizes") o.tzrevent._bh=hours.b; 3765 if(obj.actEvent!="resizen") o.tzrevent._eh=hours.e; 3766 } 3767 TZR.Calendar.ajaxSaveEvent(uniqid,obj,o.tzrevent,true); 3768 } 3769 obj.actEvent=""; 3770} 3771 3772// Annule un drag/resize 3773TZR.Calendar.cancelDrag=function(event){ 3774 if(event.keyCode==27){ 3775 event.data.obj.actEvent=""; 3776 // La div a changée de colonne, on la remet 3777 if(event.data.target.parentNode!=event.data.parent){ 3778 jQuery(event.data.target).appendTo(event.data.parent); 3779 event.data.target.tzrevent._isod=event.data.parent.id.substr(2,10); 3780 } 3781 // Retablissement position dans la colonne 3782 jQuery(event.data.target).css({top:event.data.top,left:event.data.left,width:event.data.width,height:event.data.height}); 3783 jQuery(event.data.target).mouseup(); 3784 event.data.target.setEventText(); 3785 } 3786} 3787 3788// Annule une création 3789TZR.Calendar.cancelNew=function(event){ 3790 if(event.keyCode==27){ 3791 event.data.obj.actEvent=""; 3792 jQuery(event.data.target).mouseup(); 3793 } 3794} 3795 3796// Rafrachi l'agenda 3797TZR.Calendar.refreshAgenda=function(uniqid,obj,event,del){ 3798 if(del) jQuery(jQuery.bt.vars.closeWhenOpenStack).btOff(); 3799 if(event) TZR.Calendar.orderEvent(uniqid,obj,event,del); 3800 TZR.Calendar.calculatePosition(uniqid,obj); 3801 TZR.Calendar.drawAgenda(uniqid,obj); 3802 if(!del) jQuery(jQuery.bt.vars.closeWhenOpenStack).btOn(); 3803} 3804 3805// Sauvegarde un evenement. Envoi des données au serveur et le serveur renvoie les données enregistrées que l'on met dans event afin que le traitement js porte sur les vrai données 3806TZR.Calendar.ajaxSaveEvent=function(uniqid,obj,event,refresh,cb){ 3807 var reg=/<.?br.?.?>/; 3808 if(reg.test(event.descr)) 3809 event.descr=event.descr.replace(/\n/g,"").replace(/<.?br.?.?>/g,"\n"); 3810 3811 var param={oid:obj.oid,koid:event.oid,text:event.text,descr:event.descr,place:event.place,allday:event.allday}; 3812 if(!event.oid || event._obd==event._bd){ 3813 param["begin[date]"]=event._isod; 3814 param["begin[hour]"]=event._bh; 3815 } 3816 if(!event.oid || event._oed==event._ed){ 3817 param["end[date]"]=event._isod; 3818 param["end[hour]"]=event._eh; 3819 } 3820 param['skip']=1; 3821 jQuery.getJSON(TZR._self+"&moid="+obj.moid+"&function=ajaxEdit",param,function(data,status){ 3822 if(data){ 3823 jQuery.extend(event,data); 3824 if(refresh) TZR.Calendar.refreshAgenda(uniqid,obj,event); 3825 if(cb) cb.call(TZR.Calendar,uniqid,obj,event); 3826 }else{ 3827 alert('Error'); 3828 } 3829 }); 3830 return true; 3831} 3832 3833// Créer un evenement 3834TZR.Calendar.createEvent=function(uniqid,obj,event){ 3835 if(event.text==undefined) event.text=""; 3836 if(event.id==undefined) event.id="ev-"+obj.evs.length+"-"+event._isod; 3837 if(event.descr==undefined) event.descr=''; 3838 if(event.place==undefined) event.place=''; 3839 var l=TZR.Calendar.getEventLimit(event); 3840 event.col=0; 3841 event.w=1; 3842 event.groupinfos={max:1}
3842; 3843 event.row=l.b; 3844 event.h=l.d; 3845 event.rw=1; 3846 event.color=obj.color; 3847 event.dname=obj.name; 3848 event.create=1; 3849 TZR.Calendar.createEventDiv(uniqid,obj,event); 3850 var jdiv=jQuery('#'+event.id+"-"+uniqid); 3851 setTimeout(function(){ 3852 jdiv.click(); 3853 jQuery('#bt-edittext').triggerHandler('click'); 3854 },100); 3855} 3856 3857// Supprime un evenement sur le serveur 3858TZR.Calendar.ajaxDelEvent=function(uniqid,obj,event){ 3859 if(event.oid==undefined) return; 3860 jQuery.getJSON(TZR._self+"&moid="+obj.moid+"&function=ajaxDel&oid="+obj.oid+"&koid="+event.oid+"&noalert=1",function(data,status){ 3861 if(data!="ok"){ 3862 alert('Error'); 3863 }else{ 3864 TZR.Calendar.delEvent(uniqid,obj,event); 3865 } 3866 }); 3867 return true; 3868} 3869 3870// Supprime une div evenement 3871TZR.Calendar.delEvent=function(uniqid,obj,event){ 3872 jQuery(jQuery.bt.vars.closeWhenOpenStack).btOff(); 3873 jQuery('#'+event.id+'-'+uniqid).remove(); 3874 if(obj.display!="displayMonth") TZR.Calendar.refreshAgenda(uniqid,obj,event,true); 3875 TZR.Dialog.closeDialog(); 3876} 3877 3878// Ecouteur clavier pour un agenda 3879TZR.Calendar.keyListener=function(event){ 3880 var uniqid=event.data.uniqid; 3881 var monthly = event.data.monthly; 3882 var obj=event.data.obj; 3883 if (!monthly){ 3884 var ags=[document.getElementById('agenda'+uniqid), 3885 document.getElementById('agglobal'+uniqid), 3886 document.getElementById('agallday'+uniqid) 3887 ]; 3888 for(var ag=0; ag<ags.length; ag++) { 3889 if(!ags[ag]){ 3890 jQuery(document).unbind('keydown',TZR.Calendar.keyListener); 3891 return; 3892 } 3893 } 3894 } else { 3895 var ags=[document.getElementById('agenda'+uniqid)]; 3896 } 3897 if(event.keyCode==46 && obj.actEvent=="edit"){ 3898 jo=jQuery('div.event-selected',ags[ag]); 3899 if(jo.length==1 && confirm('Supprimer?')){ 3900 TZR.Calendar.ajaxDelEvent(uniqid,obj,jo[0].tzrevent); 3901 } 3902 }else if(event.keyCode==27 && obj.actEvent=="edit"){ 3903 jQuery('#bt-cancel').click(); 3904 } 3905 3906} 3907 3908// Retourne les limites et le durée d'un evenemtn au format decimal 3909TZR.Calendar.getEventLimit=function(e){ 3910 var foo=e._bh.split(':'); 3911 var bdec=parseFloat(foo[0])+parseFloat(foo[1])/60; 3912 var brounddec=Math.floor(bdec*4)/4; 3913 foo=e._eh.split(':'); 3914 var edec=parseFloat(foo[0])+parseFloat(foo[1])/60; 3915 var erounddec=Math.ceil(edec*4)/4; 3916 var eb=brounddec*4; 3917 var ee=erounddec*4; 3918 return {b:eb,e:ee,d:ee-eb}; 3919} 3920 3921// Recupere l'heure a afficher d'un evenement (en prenant en compte une eventuelle position calculée par positionToHour) 3922TZR.Calendar.getEventText=function(uniqid,obj,event,pos){ 3923 var ret="",b,e; 3924 if(!event.allday || event.allday=="0"){ 3925 if(typeof(pos)=='object'){ 3926 b=pos.b; 3927 e=pos.e; 3928 }else{ 3929 b=event._bh; 3930 e=event._eh; 3931 } 3932 if(event._obd!=event._bd && event._oed!=event._ed) ret=".. > .."; 3933 else if(event._obd!=event._bd) ret=".. > "+e; 3934 else if(event._oed!=event._ed) ret=b+" > .."; 3935 else ret=b+" > "+e; 3936 ret='<span class="event-hour">'+ret+'</span> <span class="event-title">'+event.text+'</span>'; 3937 }else{ 3938 ret='<span class="event-title">'+event.text+'</span>'; 3939 } 3940 return ret; 3941} 3942 3943// Initialise la tooltip d'une div evenement 3944TZR.Calendar.applyHottip=function(uniqid,obj,jo,cb){ 3945 jo.on("click", function(e) { 3946 var self = this; 3947 if(self.tzrevent.rw){ 3948 jQuery('.displayQuickInput').each(function(){jQuery(this).hide();}); 3949 jQuery('.editQuickInput').each(function(){jQuery(this).show();}); 3950 } else { 3951 jQuery('.displayQuickInput').each(function(){jQuery(this).show();}); 3952 jQuery('.editQuickInput').each(function(){jQuery(this).hide();}); 3953 } 3954 self.waitForDbClick = self.waitForDbClick ? false : true; 3955 if (jQuery(self).hasClass('event-selected') ) { 3956 TZR.Calendar.unselect(self); 3957 setTimeout( 3958 function() { 3959 if (!self.waitForDbClick) 3960 return; 3961 self.waitForDbClick = false; 3962 } , 400); 3963 } else { 3964 jQuery(self).addClass('event-selected'); 3965 setTimeout( 3966 function() { 3967 if (!self.waitForDbClick) 3968 return; 3969 self.waitForDbClick = false; 3970 var content = TZR.Calendar.getHottipContent(self); 3971 TZR.Dialog.show(content, {sizeClass:'modal-calendar', initCallback:null, closeCallback:{_function:'TZR.Calendar.unselect', _param:{uniqid:uniqid,obj:obj,target:jo[0]}}}); 3972 // Rend titre/descr/lieu de l'helper editable inline 3973 if(self.tzrevent.rw){ 3974 TZR.Calendar.applyEditable(uniqid,obj,self,cb); 3975 }else{ 3976 jQuery('#bt-modify, #bt-del, #bt-cancel, #bt-save, #bt-edit').hide(); 3977 } 3978 }, 3979 400); 3980 } 3981 }); 3982}, 3983 3984TZR.Calendar.unselect=function(parms) { 3985 parms = parms[0]; 3986 jQuery(parms.target).removeClass('event-selected'); 3987 var event = parms.target.tzrevent; 3988 if (!event || typeof(event.oid) == "undefined"){ 3989 jQuery(parms.target).remove(); 3990 } 3991 3992} 3993// Configure les contrôles de saisie d'un event (edition,consultation) 3994TZR.Calendar.applyEditable=function(uniqid,obj,div,cb){ 3995 var focus = false;
3996 var myFunction = function() { 3997 if(this.innerHTML=="") this.innerHTML=" "; 3998 obj.actEvent="edit"; 3999 this.oldvalue=this.innerHTML; 4000 if(this.innerHTML==" " || this.innerHTML==" ") this.innerHTML=""; 4001 var event = div.tzrevent; 4002 jQuery(this).find('input,select,textarea').attr('name',this.id.substr(7)); 4003 if(this.id=="bt-edittext"){ 4004 jQuery(this).find('input,select,textarea').val(event.text); 4005 } else if(this.id=="bt-editplace"){ 4006 // stringset versus texte court 4007 var inputs = jQuery(this).find('input[type=radio],input[type=checkbox]'); 4008 if (inputs.length != 0){ 4009 for (var i=0;i<inputs.length;i++){ 4010 if (inputs[i].value == event.place){ 4011 inputs[i].checked = true; 4012 } 4013 } 4014 } else { 4015 inputs = jQuery(this).find('option'); 4016 if (inputs.length != 0){ 4017 for (i=0;i<inputs.length;i++){ 4018 if (inputs[i].value == event.place){ 4019 inputs[i].selected = true; 4020 } 4021 } 4022 } else { 4023 inputs = jQuery(this).find('input[type=text]'); 4024 if (inputs.length != 0){ 4025 inputs.val(event.place); 4026 } 4027 } 4028 } 4029 }else{ 4030 jQuery(this).find('input,select,textarea').val(event.descr.replace(/<.?br.?.?>/g,"")); 4031 } 4032 if (!focus){ 4033 jQuery('input,textarea','#'+this.id).first().focus(); 4034 focus = true; 4035 } 4036 return true; 4037 }; 4038 // activer/désactiver les contrôles (champs, boutons) 4039 // #bt-edittext,#bt-editplace,#bt-editdescr 4040 // #bt-modify, #bt-del, #bt-view, #bt-cancel, #bt-save, #bt-edit 4041 if(div.tzrevent.create && typeof(div.tzrevent.oid) == "undefined"){ 4042 jQuery('#bt-edittext,#bt-editplace,#bt-editdescr').each(myFunction); 4043 jQuery('#bt-modify, #bt-del, #bt-view, #bt-cancel, #bt-edit').hide(); 4044 jQuery('#bt-save').show(); 4045 } else if(div.tzrevent.rw) { 4046 jQuery('#bt-edittext,#bt-editplace,#bt-editdescr').each(myFunction); 4047 jQuery('#bt-modify, #bt-view, #bt-cancel').hide(); 4048 jQuery('#bt-del,#bt-save,#bt-edit').show(); 4049 } else { 4050 jQuery('#bt-modify, #bt-del, #bt-view, #bt-cancel, #bt-save, #bt-edit').hide(); 4051 } 4052 jQuery('#bt-save').click(function(){ 4053 jQuery('#bt-edittext,#bt-editplace,#bt-editdescr').each(function(){ 4054 if(typeof(this.oldvalue)!="undefined"){ 4055 if (this.id == 'bt-editplace'){ 4056 inputs = $(this).find('input[type=radio],input[type=checkbox]'); 4057 if (inputs.length != 0){ 4058 for (i=0;i<inputs.length;i++){ 4059 if (inputs[i].checked){ 4060 val = inputs[i].value; 4061 break; 4062 } 4063 } 4064 } else { 4065 inputs = $(this).find('option'); 4066 for (i=0;i<inputs.length;i++){ 4067 if (inputs[i].selected){ 4068 val = inputs[i].value; 4069 break; 4070 } 4071 } 4072 } 4073 } else { 4074 val = jQuery('input,select,textarea',this).val(); 4075 } 4076 div.tzrevent[this.id.substr(7)]=val; 4077 this.innerHTML=this.oldvalue; 4078 } 4079 }); 4080 obj.actEvent=""; 4081 TZR.Calendar.ajaxSaveEvent(uniqid,obj,div.tzrevent,(obj.display!="displayMonth"),cb); 4082 }); 4083 return ; 4084} 4085 4086// Retourne le contenu de la tooltip d'un evenement 4087TZR.Calendar.getHottipContent=function(div){ 4088 var event = div.tzrevent, d=""; 4089 var txt = jQuery(div).parents('div.cv8-module-container:first').find('div.cv8-agendabtcontent:first').html(); 4090 if(event.allday && event.allday!="0"){ 4091 if(event._obd==event._oed) d=event._obd; 4092 else d=event._obd+" - "+event._oed; 4093 }else{ 4094 if(event._obd==event._oed) d=event._obd+" "+event._bh+" - "+event._eh; 4095 else d=event._obd+" "+event._bh+" - "+event._oed+" "+event._eh; 4096 } 4097 event.descr = event.descr.replace(/<.?br.?.?>/g,""); 4098 txt=txt.replace('_hour_',event.dname+" : "+d); 4099 txt=txt.replace('_title_',event.text).replace('_place_',event.placehtml).replace(/_descr_/g,event.descr).replace(/_url_/g,event.url).replace(/_bt/g,"bt"); 4100 if(!event.oid){ 4101 var tmpdiv=jQuery('<div>'+txt+'</div>'); 4102 tmpdiv.find('#bt-view,#bt-edit,#bt-del').remove(); 4103 tmpdiv.find('#bt-cancel').show(); 4104 txt=tmpdiv.html(); 4105 delete tmpdiv; 4106 } 4107 return txt; 4108} 4109 4110// Recupere la decimal d'un nombre 4111TZR.Calendar.decimal=function(num){ 4112 return num-Math.floor(num); 4113} 4114// Trasnforme un flaot en heur HH:mm 4115TZR.Calendar.floatToHour=function(num){ 4116 var h=Math.floor(num); 4117 if(h<10) h="0"+h; 4118 var m=TZR.Calendar.decimal(num)*60; 4119 if(m<10) m="0"+m; 4120 return h+":"+m; 4121} 4122// Transforme une position en heure HH:mm 4123TZR.Calendar.positionToHour=function(uniqid,obj,o,what){ 4124 var jo=jQuery(o); 4125 var t=parseInt(jo.css('top')); 4126 var h=parseInt(jo.css('height')); 4127 var dec=obj.agStart+(t/obj.lineHeight/4); 4128 if(what=='end') var b=o.tzrevent._bh; 4129 else var b=TZR.Calendar.floatToHour(dec); 4130 dec=dec+(h/obj.lineHeight/4); 4131 if(what=='begin') var e=o.tzrevent._eh; 4132 else var e=TZR.Calendar.floatToHour(dec); 4133 return {b:b,e:e}; 4134} 4135 4136// Création de la grille d'un agenda 4137TZR.Calendar.makeGrid=function(uniqid,obj){ 4138 var agglob=document.getElementById('agglobal'+uniqid); 4139 var aghead=document.getElementById('agdayshead'+uniqid); 4140 var agdays=document.getElementById('agdays'+uniqid); 4141 var aghour=document.getElementById('aghour'+uniqid); 4142 var agdaysallday=document.getElementById('agdaysallday'+uniqid); 4143 var div,div2,h,ht,date,i,num,date,l,w,agw,tmp; 4144 // Heures 4145 if(obj.dates.length==1){ 4146 tmp=document.getElementById('aghourallday'+uniqid); 4147 date=obj.dates[0]; 4148 tmp.innerHTML='<a class="cv8-ajaxlink" href="'+TZR._self+'oid='+obj.oid+'&function=addEvt&moid='+obj.moid+'&tplentry=br&template=Mo
4148dule/Calendar.addEvt.html&day='+date.substr(8,2)+'&month='+date.substr(5,2)+'&year='+date.substr(0,4)+'&display=displayDay&allday=1">'+tmp.innerHTML+'</a>'; 4149 } 4150 h=((obj.agEnd-obj.agStart)*4)*obj.lineHeight; 4151 agglob.style.height=(h+10)+"px"; 4152 agdays.style.height=h+"px"; 4153 for(i=obj.agStart;i<obj.agEnd;i=i+0.25){ 4154 if(Math.floor(i)==i){ 4155 ht=TZR.Calendar.floatToHour(i); 4156 div=document.createElement("div"); 4157 if(Math.floor(i+1)%2) div.className="bgodd"; 4158 else div.className="bgeven"; 4159 if(obj.dates.length==1){ 4160 date=obj.dates[0]; 4161 div.innerHTML='<a class="cv8-ajaxlink" href="'+TZR._self+'oid='+obj.oid+'&function=addEvt&moid='+obj.moid+'&tplentry=br&template=Module/Calendar.addEvt.html&day='+date.substr(8,2)+'&month='+date.substr(5,2)+'&year='+date.substr(0,4)+'&display=displayDay&hour='+ht+'">'+ht+'</a>'; 4162 }else{ 4163 div.innerHTML=ht; 4164 } 4165 aghour.appendChild(div); 4166 // Fonds 4167 div=document.createElement("div"); 4168 div.style.position="absolute"; 4169 div.style.left="0px"; 4170 div.style.top=(i*4*obj.lineHeight-obj.agStart*4*obj.lineHeight)+"px"; 4171 if(Math.floor(i+1)%2) div.className="bgodd"; 4172 else div.className="bgeven"; 4173 agdays.appendChild(div); 4174 } 4175 } 4176 // Colonnes dates 4177 agw=Math.floor(100/obj.dates.length); 4178 for(num in obj.dates){ 4179 num=parseInt(num); 4180 date=obj.dates[num]; 4181 if(num==obj.dates.length-1) w=(100-agw*num)+"%"; 4182 else w=agw+"%"; 4183 l=(num*agw)+"%"; 4184 // Div d'entete 4185 div=document.createElement("div"); 4186 div.className="aghead"; 4187 div.style.left=l; 4188 div.style.width=w; 4189 if(obj.dates.length>1){ 4190 div.innerHTML='<a class="cv8-ajaxlink" href="'+TZR._self+'oid='+obj.oid+'&function=addEvt&moid='+obj.moid+'&function=displayDay&tplentry=br&template=Module/Calendar.displayDay.html&day='+date.substr(8,2)+'&month='+date.substr(5,2)+'&year='+date.substr(0,4)+'">'+jQuery.datepicker.formatDate("D dd/mm",jQuery.datepicker.parseDate('yy-mm-dd',date))+'</a>'; 4191 }else{ 4192 div.innerHTML=jQuery.datepicker.formatDate("DD dd MM yy",jQuery.datepicker.parseDate('yy-mm-dd',date)); 4193 } 4194 aghead.appendChild(div); 4195 // Div des notes 4196 div=document.createElement("div"); 4197 if(num+1==obj.dates.length) div.className="agadday agaddaylast"; 4198 else div.className="agadday"; 4199 div.id="agad"+date+"-"+uniqid; 4200 div.style.left=l; 4201 div.style.width=w; 4202 agdaysallday.appendChild(div); 4203 // Div des evenements 4204 div=document.createElement("div"); 4205 if(num+1==obj.dates.length) div.className="agday agdaylast"; 4206 else div.className="agday"; 4207 div.id="ag"+date+"-"+uniqid; 4208 div.style.left=l; 4209 div.style.width=w; 4210 agdays.appendChild(div); 4211 4212 // Création de la grille (div selectionnable pour creation) 4213 for(i=obj.agStart;i<obj.agEnd;i=i+0.25){ 4214 div2=document.createElement("div"); 4215 div2.className="aggrid"; 4216 div2.id=date+"-"+TZR.Calendar.floatToHour(i)+"-"+uniqid; 4217 div2.setAttribute("x-dechour",i); 4218 div2.setAttribute("x-date",date); 4219 div.appendChild(div2); 4220 } 4221 4222 // Active la selection pour creation à la volée 4223 if(obj.rw){ 4224 jQuery(div).selectable({autoRefresh:true,filter:"div.aggrid",distance:2,start:function(event){ 4225 obj.actEvent="new"; 4226 obj.newStart=undefined; 4227 obj.newEnd=undefined; 4228 },stop:function(event,ui){ 4229 jQuery(document).unbind('keydown',TZR.Calendar.cancelNew); 4230 if(obj.actEvent!=""){ 4231 obj.newEnd+=0.25; 4232 TZR.Calendar.createEvent(uniqid,obj,{_bh:TZR.Calendar.floatToHour(obj.newStart),_eh:TZR.Calendar.floatToHour(obj.newEnd),_bd:obj.newDate,_ed:obj.newDate,_obd:obj.newDate,_oed:obj.newDate,_isod:obj.newDate}); 4233 } 4234 obj.actEvent=""; 4235 },selected:function(event,ui){ 4236 var t=ui.selected; 4237 var jt=jQuery(t); 4238 var dechour=parseFloat(jt.attr("x-dechour")); 4239 if(obj.newStart==undefined) obj.newStart=dechour; 4240 if(obj.newEnd==undefined || obj.newEnd<dechour) obj.newEnd=dechour; 4241 obj.newDate=jt.attr("x-date"); 4242 },selecting:function(event,ui){ 4243 jQuery(document).unbind('keydown',TZR.Calendar.cancelNew); 4244 jQuery(document).bind('keydown',{target:event.target,obj:obj},TZR.Calendar.cancelNew); 4245 jQuery('.ui-selectable-helper').css({"border":"0px solid black","background-color":"transparent"}); 4246 } 4247 }); 4248 } 4249 } 4250 4251 // Ecouteur pour supression 4252 if(obj.rw){ 4253 jQuery(document).unbind('keydown',TZR.Calendar.keyListener); 4254 jQuery(document).bind('keydown',{uniqid:uniqid,obj:obj},TZR.Calendar.keyListener); 4255 } 4256} 4257 4258// Créé une div pour l'affichage mensuel 4259TZR.Calendar.monthCreateDiv=function(uniqid,obj,e){ 4260 e.id=e.id.replace(':','_'); 4261 var div=document.getElementById(e.id+"-"+uniqid); 4262 if(!div){ 4263 div=document.createElement('div'); 4264 div.tzrevent=e; 4265 div.id=e.id+"-"+uniqid; 4266 div.className="tzr-cal-month-div"; 4267 div.style.backgroundColor=e.color; 4268 jQuery('#ag'+e._isod+"-"+uniqid).append(div); 4269 var jdiv=jQuery(div);
4270 TZR.Calendar.applyHottip(uniqid,obj,jdiv,TZR.Calendar.monthCreateDiv); 4271 if(e.rw && e._obd==e._oed){ 4272 jdiv.mousedown(function(event){ 4273 event.currentTarget.tzrevent.modified=false; 4274 jdiv.addClass('ui-draggable-dragging'); 4275 jQuery('.tzr-cal-display-in').mouseover(function(){ 4276 if(event.currentTarget.tzrevent._isod!=this.id.substr(2,10)){ 4277 jQuery(jQuery.bt.vars.closeWhenOpenStack).btOff(); 4278 jQuery(event.currentTarget).appendTo(this); 4279 event.currentTarget.tzrevent._isod=this.id.substr(2,10); 4280 event.currentTarget.tzrevent.modified=true; 4281 } 4282 }); 4283 jQuery(document).bind('mouseup',{jdiv:jdiv,uniqid:uniqid,obj:obj,event:event.currentTarget.tzrevent},TZR.Calendar.monthStopDrag).bind('keydown',{parent:div.parentNode,target:div},TZR.Calendar.monthCancelDrag); 4284 return false; 4285 }); 4286 } 4287 jdiv.click(function(event){ 4288 var _now=new Date().getTime(); 4289 if(this.lastclick && _now-this.lastclick<300){ 4290 obj.vuniqid.jQueryLoad(e.url+"&display="+obj.display); 4291 return; 4292 } 4293 this.lastclick=_now; 4294 }); 4295 } 4296 div.innerHTML='<div class="event-w"></div><div class="event-e"'+(e.cat?' style="background-color:'+e.cat+';"':'')+'></div><div class="event-s"></div><div class="event-n"></div><div class="tzr-cal-month-paddingdiv"><div class="tzr-cal-display-event-hour">'+TZR.Calendar.getEventText(null,null,e)+'</div></div>'; 4297} 4298TZR.Calendar.monthStopDrag=function(e){ 4299 if(e.data.event.modified) TZR.Calendar.ajaxSaveEvent(e.data.uniqid,e.data.obj,e.data.event,false); 4300 e.data.jdiv.removeClass('ui-draggable-dragging'); 4301 jQuery('.tzr-cal-display-in').unbind('mouseover'); 4302 jQuery(document).unbind('mouseup',TZR.Calendar.monthStopDrag); 4303 return false; 4304} 4305// Annule un drag dans l'affichage mensuel 4306TZR.Calendar.monthCancelDrag=function(e){ 4307 if(e.keyCode==27){ 4308 // La div a changée de colonne, on la remet 4309 if(e.data.target.parentNode!=e.data.parent){ 4310 jQuery(e.data.target).appendTo(e.data.parent); 4311 e.data.target.tzrevent._isod=e.data.parent.id.substr(2,10); 4312 } 4313 e.data.target.tzrevent.modified=false; 4314 jQuery(document).mouseup(); 4315 jQuery(document).unbind('keydown',TZR.Calendar.monthCancelDrag); 4316 } 4317} 4318// champs liens lies // 4319TZR.linkedfields = {notifsStack:[], stacktimeout:null, fields:{}}; 4320// traite les requetes de mise à jour 4321function link2field_popStack(){ 4322 // pile vide 4323 if (TZR.linkedfields.notifsStack.length == 0) 4324 return; 4325 // paquet suivant si paquet en cours vide 4326 if (TZR.linkedfields.notifsStack[0].length == 0){ 4327 TZR.linkedfields.notifsStack.shift(); 4328 TZR.linkedfields.stacktimeout = setTimeout(link2field_popStack, 1); 4329 return; 4330 } 4331 var dest = TZR.linkedfields.notifsStack[0].shift(); 4332 // appel du traitement pour le champ cible en cours 4333 dest.field.refresh(dest.value, dest.options); 4334 TZR.linkedfields.stacktimeout = setTimeout(link2field_popStack, 1); 4335} 4336TZR.linkedfields.init = function(f, reset){ 4337 reset=reset||false; 4338 for(var id in this.fields){ 4339 var el = document.getElementById(this.fields[id].properties.varid); 4340 // ne traiter que les champs du formulaire en cours 4341 if (el != null && el.form == f){ 4342 this.fields[id].init1(reset); 4343 } else { 4344 //champ lien parent des sous fiches (input hidden) 4345 //voir / autres champ ro ? 4346 var el = f.elements[this.fields[id].properties.field]; 4347 if (el != null && el.nodeName == 'INPUT' && el.getAttribute('type') == 'hidden' && el.value != ''){ 4348 this.fields[id].ro = true; 4349 this.fields[id].roElem = el; 4350 this.fields[id].roValue = el.value; 4351 this.fields[id].init1(reset); 4352 } 4353 } 4354 } 4355 // initialisation : force un change les champs déjà renseignées pour filter les dépendants 4356 if (!reset) { 4357 for (var id in this.fields){ 4358 if (this.fields[id].val().length != 0) { // ... val retourne un tableau 4359 this.fields[id].grouplocked = true; 4360 this.fields[id].triggerChange(); 4361 this.fields[id].grouplocked = false; 4362 } 4363 } 4364 } else { // refresh : reload pour les champs contraints par un champ ro 4365 for (var id in this.fields){ 4366 var field = this.fields[id]; 4367 for(var i=0; i<field.parentfields.length; i++){ 4368 var pfield = field.parentfields[i].field; 4369 if (pfield.ro && pfield.roValue != '') { 4370 pfield.grouplocked = true; 4371 pfield.triggerChange(); 4372 pfield.grouplocked = false;
4373 } 4374 } 4375 } 4376 } 4377}; 4378 4379// reset des champs liés 4380TZR.linkedfields.reset = function(ori){ 4381 var el = document.getElementById(ori.properties.varid); 4382 this.init(el.form, true); 4383} 4384TZR.linkedfields.add = function(params, linkedfields){ 4385 if (params.varid == ""){ 4386 console.log(['empty varid', params]); 4387 return; 4388 } 4389 var newfield = null; 4390 if (typeof(TZR.linkedfields.fields[params.varid]) == "undefined"){ 4391 TZR.linkedfields.fields[params.varid] = newfield = new link2field(params); 4392 }else{ 4393 newfield = TZR.linkedfields.fields[params.varid]; 4394 } 4395 newfield.addLinkedFields(linkedfields); 4396 linkedfields = newfield.linkedfields; 4397 newfield.linkedfields = []; 4398 // consolidation des champs parents 4399 for(var i=0; i<linkedfields.length; i++){ 4400 if (typeof(TZR.linkedfields.fields[linkedfields[i].properties.varid]) == "undefined"){ 4401 // ajout d'un nouveau champ à la liste complète 4402 TZR.linkedfields.fields[linkedfields[i].properties.varid] = linkedfields[i]; 4403 } else { 4404 // champ deja connu : ajout d'un parent 4405 var done = false; 4406 var f = TZR.linkedfields.fields[linkedfields[i].properties.varid]; 4407 for(var j=0; j<f.parentfields.length; j++){ 4408 if (f.parentfields[j].field.properties.varid == newfield.properties.varid){ 4409 done = true; 4410 break; 4411 } 4412 } 4413 if (!done) 4414 TZR.linkedfields.fields[linkedfields[i].properties.varid].parentfields.push({field:newfield, query:linkedfields[i].properties.query}); 4415 } 4416 newfield.linkedfields.push(TZR.linkedfields.fields[linkedfields[i].properties.varid]); 4417 } 4418} 4419// classe des champs liées 4420function link2field(params){ 4421 this.parentfields = []; 4422 this.grouplocked = false; 4423 this.properties = params; 4424 this.ui = params.uitype; 4425 this.ro = false; 4426 this.roValue = null; 4427 this.roElem = null; 4428 this.roParents = null; 4429 this.jqobj = jQuery("#"+params.varid); 4430 if (this.ui == 'double'){ 4431 this.jqobjUnselected = jQuery("#unselected"+params.varid); 4432 } 4433 this.linkedfields = []; 4434 this.addLinkedFields = link2field_addLinkedFields; 4435 this.init1 = link2field_init1; 4436 this.init2 = link2field_init2; 4437 this.refreshui = link2field_refreshui; 4438 this.refresh = link2field_refresh; 4439 this.change = link2field_change; 4440 this.addResetUi = link2field_addResetUi; 4441 if (this.ro){ 4442 this.val = link2field_ro_val; 4443 } else { 4444 if (this.ui == 'double'){ 4445 this.val = link2field_doublebox_val; 4446 } else { 4447 this.val = link2field_val; 4448 } 4449 } 4450 this.initialVal = link2field_initialVal; 4451 this.locked = link2field_locked; // ? 4452 this.groupLock = link2field_groupLock; 4453 this.isGroupLocked = link2field_isGroupLocked; 4454 this.triggerChange = link2field_triggerChange; 4455} 4456function link2field_triggerChange(){ 4457 if (this.ro){ 4458 this.change({}, {field:this}); 4459 } else { 4460 this.jqobj.change(); 4461 } 4462} 4463function link2field_addLinkedFields(linkedfields){ 4464 for(var i in linkedfields){ 4465 var newfield = new link2field(linkedfields[i]); 4466 newfield.parentfields.push({field:this, query:newfield.properties.query}); 4467 this.linkedfields.push(newfield); 4468 } 4469} 4470function link2field_locked(){ 4471 var resetobj = jQuery("#reset"+this.properties.varid); 4472 if (resetobj.length == 0) 4473 return false; 4474 var disp = resetobj.css('display'); 4475 return (disp != "none"); 4476} 4477function link2field_groupLock(v){ 4478 for(var i=0; i<this.parentfields.length; i++) 4479 this.parentfields[i].field.grouplocked = v; 4480 for(var i=0; i<this.linkedfields.length; i++) 4481 this.linkedfields[i].grouplocked = v; 4482 this.grouplock = v; 4483} 4484function link2field_isGroupLocked(){ 4485 return this.grouplocked; 4486} 4487function link2field_init1(reset){ 4488 this.refresh([], {init:reset?false:true, filter:'off'}); 4489 return; 4490 // init du champ tenant compte de la valeur en cours 4491 // valeurs initiales 4492 jQuery.ajax({method:"get", 4493 type: "POST", 4494 data:data, 4495 dataType:"json", 4496 context:this, 4497 async:false, 4498 url:this.properties.url, 4499 success:function(data, textstatus, xmltruc /*verifier cela*/){ 4500 this.refresh(data, {init:reset?false:true, filter:'off'}); 4501 }, 4502 error:function(){alert('Erreur initialisation des champs(1)');}}); 4503 4504} 4505function link2field_init2(){ 4506 if (this.ro){ 4507 return; 4508 } 4509 if (this.ui == 'double'){ 4510 // TZR.doubleAdd (generic.js) lance le change sur la dest 4511 // depuis le doubleclick avec des options (jquery) 4512 this.jqobj.on('change', {field:this}, function(event, options){ 4513 // les change natif sont ignorés 4514 if (options){ 4515 if (options == 'doubleboxchange'){ 4516 options = null; 4517 } 4518 options = options||{init:false}; 4519 event.data.field.change(event, options); 4520 } 4521 }); 4522 } else { 4523 this.jqobj.on('change', {field:this},function(event, options){ 4524 options = options||{init:false}; 4525 event.data.field.change(event, options); 4526 }); 4527 } 4528} 4529// recup des data du champ 4530function link2field_refresh(value, options){ 4531 if (this.ro){ 4532 return; 4533 } 4534 var filter = options.filter||'on'; 4535 var data = {table:this.properties.table, 4536 options:{fmoid:this.properties.fmoid}, 4537 field:this.properties.field, 4538 linkqueries:[] 4539 }; 4540 // recherche des valeurs des parents 4541 if (filter == 'on'){ 4542 for(var i=0; i<this.parentfields.length; i++){ 4543 var aparent = this.parentfields[i]; 4544 if (!options.fv || options.fv.field != aparent.field.properties.field){ 4545 var vals = aparent.field.val(); 4546 } else { 4547 var vals = options.fv.values; 4548 } 4549 // on pourrauit prendre tout (cas contraint) 4550 if (vals.length != 0) 4551 data.linkqueries.push({ 4552 field:aparent.field.properties.field, 4553 value:vals, 4554 query:aparent.query 4555 }); 4556 } 4557 } 4558 jQuery.ajax({ 4559 method: "POST", 4560 data:data, 4561 dataType:"json", 4562 async:false, 4563 context:this, 4564 url:this.properties.url, 4565 success:function(data, textstatus, xmlhttprequest/*?*/){ 4566 this.refreshui(data, options); 4567 }, 4568 error:function(){ 4569 alert('erreur initialisation des champs(2)'); 4570 }}); 4571} 4572// recupere les valeurs en cours du champ et retourne un tableau 4573function link2field_ro_val(){ 4574 return this.rovalue; 4575} 4576function link2field_doublebox_val(){ 4577 values = []; 4578 this.jqobj.find('option').each(function(i,o){ 4579 values.push(o.getAttribute('value')); 4580 }); 4581 return values; 4582} 4583function link2field_val(){ 4584 var val = this.jqobj.val(); 4585 if (val == null || val == "") 4586 return []; 4587 if (typeof val != 'object') 4588 return [val]; 4589 else 4590 return val; 4591} 4592function link2field_initialVal(){ 4593 if (this.ro){ 4594 return this.roValue; 4595 } 4596 var current = this.jqobj.attr('data-value'); 4597 if (current == null) 4598 current = ''; 4599 return current; 4600} 4601function link2field_refreshui(data, options){ 4602 if (this.ro){ 4603 return; 4604 } 4605 if (this.ui == "double"){ 4606 return refresh_ui_double.call(this, data, options); 4607 } 4608 return refresh_ui_select.call(this, data, options); 4609}; 4610function refresh_ui_double(data, options){ 4611 var target = this.jqobj; 4612 var selvals = this.val(); 4613 var current = ""; 4614 4615 this.jqobjUnselected.children().remove(); 4616 this.jqobj.children().remove(); 4617 4618 // ajout des autres champs ! cas champs multivalués 4619 if (options.init == true || (options.filter && options.filter=='off')){ 4620 current = this.initialVal(); 4621 if (options.init){ 4622 this.init2(); 4623 } 4624 } else { 4625 if (selvals.length > 0) 4626 current = selvals.join('||'); 4627 } 4628 4629 jQuery("#"+this.properties.varid+"_nb").html(" nb : "+data[0].items.length); 4630 var newvalues = []; 4631 for(var i in data[0].items){ 4632 var selected = ""; 4633 if (data[0].items[i].koid == current || current.indexOf(data[0].items[i].koid)>=0){ 4634 selected = "selected"; 4635 } 4636 newvalues.push(data[0].items[i].koid); 4637 if (selected){ 4638 this.jqobj.append("<option value=\""+data[0].items[i].koid+"\">"+data[0].items[i].label+"</option>"); 4639 } else { 4640 this.jqobjUnselected.append("<option value=\""+data[0].items[i].koid+"\">"+data[0].items[i].label+"</option>"); 4641 } 4642 } 4643 // répercution aux champs liés si pas déja concernés, avec mes valeurs en cours (data.items ...) 4644 for(var i=0; i<this.linkedfields.length; i++){ 4645 if (options.updfields && options.updfields.indexOf(this.linkedfields[i].properties.field) == -1){ 4646 this.linkedfields[i].refresh([], {updfields:options.updfields+";"+this.linkedfields[i].properties.field, 4647 filter:"on", fv:{field:this.properties.field, values:newvalues}}); 4648 4649 } 4650 } 4651}; 4652function refresh_ui_select(data, options){ 4653 var target = this.jqobj; 4654 var first = target.children(":first"); 4655 var selvals = this.val(); 4656 var current = ""; 4657 if (first.attr('value') != '') 4658 first = null; 4659 target.children().remove(); 4660 if (first != null) 4661 target.append(first); 4662 // ajout des autres champs ! cas champs multivalués 4663 if (options.init == true || (options.filter && options.filter=='off')){ 4664 current = this.initialVal(); 4665 if (current == '' && first != null){ 4666 first.attr('selected', 'selected'); 4667 } else { 4668 if (first != null) 4669 first.attr('selected', 'selected'); 4670 } 4671 if (options.init) 4672 this.init2(); 4673 } else { 4674 4675 if (selvals.length > 0) 4676 current = selvals.join('||'); 4677 } 4678 4679 jQuery("#"+this.properties.varid+"_nb").html(" nb : "+data[0].items.length); 4680 var newvalues = []; 4681 for(var i in data[0].items){ 4682 var selected = ""; 4683 if (data[0].items[i].koid == current || current.indexOf(data[0].items[i].koid)>=0){ 4684 selected = "selected"; 4685 } 4686 newvalues.push(data[0].items[i].koid); 4687 target.append("<option "+selected+" value=\""+data[0].items[i].koid+"\">"+data[0].items[i].label+"</option>"); 4688 } 4689 // répercution aux champs liés si pas déja concernés, avec mes valeurs en cours (data.items ...) 4690 for(var i=0; i<this.linkedfields.length; i++){ 4691 if (options.updfields && options.updfields.indexOf(this.linkedfields[i].properties.field) == -1){ 4692 this.linkedfields[i].refresh([], {updfields:options.updfields+";"+this.linkedfields[i].properties.field, filter:"on", fv:{field:this.properties.field, values:newvalues}}); 4693 4694 } 4695 } 4696} 4697function link2field_addResetUi(){ 4698 if(this.ui == "select"){ 4699 this.jqobj.after("<button title='Réinitialiser' id='reset"+this.properties.varid+"' class='btn btn-warning' type='button'><span style='background-color:transparent;' class='csico-reset glyphicon'></span></button>"); 4700 } else { 4701 var jtable = this.jqobj.parents('table.doublebox'); 4702 jQuery("<br><button type='button' title='Réinitialiser' id='reset"+this.properties.varid+"' class='btn btn-warning'><span class='csico-reset glyphicon'></span></button>").appendTo(jQuery("tr",this.jqobj.parents('table.doublebox')).children()[1]); 4703 } 4704} 4705function link2field_change(event, options){ 4706 var value = this.val(); 4707 var newstack = []; 4708 var linkedfieldslocked = false;
4709 var updfields = options.updfields||''; 4710 options.updfields = ''; 4711 updfields += this.properties.field; 4712 for(var i=0; i<this.linkedfields.length; i++) 4713 updfields += ";"+this.linkedfields[i].properties.field; 4714 4715 for(var i=0; i<this.linkedfields.length; i++){ 4716 if (this.linkedfields[i].isGroupLocked()) 4717 linkedfieldslocked = true; 4718 if (this.linkedfields[i].locked()) 4719 continue; 4720 options['updfields'] = updfields; 4721 newstack.push({field:this.linkedfields[i], 4722 value:value, 4723 options:options 4724 }); 4725 } 4726 if (newstack.length == 0) 4727 return; 4728 if (!this.isGroupLocked() && !linkedfieldslocked){ 4729 this.groupLock(true); 4730 var target = this.jqobj; 4731 var resetobj = jQuery("#reset"+this.properties.varid); 4732 if (resetobj.length == 0){ 4733 this.addResetUi(); 4734 jQuery("#reset"+this.properties.varid).bind('click', {field:this}, function(event){ 4735 jQuery("#reset"+event.data.field.properties.varid).css('display', 'none'); 4736 event.data.field.groupLock(false); 4737 TZR.linkedfields.reset(event.data.field); 4738 return false; 4739 }); 4740 } else { 4741 resetobj.css('display',''); 4742 } 4743 } 4744 TZR.linkedfields.notifsStack.push(newstack); 4745 TZR.linkedfields.stacktimeout = setTimeout(link2field_popStack, 1); 4746} 4747// </link2field> 4748 4749// Déplace une ou plusieurs options d'un select multiple vers le haut 4750TZR.doubleSelectOptionUp = function(selectObj) { 4751 var cancelMove = false; 4752 jQuery('option:selected', selectObj).each( function() { 4753 if (cancelMove) return; 4754 var newPos = jQuery('option', selectObj).index(this) - 1; 4755 if (newPos > -1) { 4756 jQuery('option', selectObj).eq(newPos).before("<option value='"+jQuery(this).val()+"' selected='selected'>"+jQuery(this).text()+"</option>"); 4757 jQuery(this).remove(); 4758 } else { 4759 cancelMove = true; 4760 return; 4761 } 4762 }); 4763}; 4764// Déplace une ou plusieurs options d'un select multiple vers le bas 4765TZR.doubleSelectOptionDown = function(selectObj) { 4766 var countOptions = jQuery('option', selectObj).size(); 4767 var countOptionsSelected = jQuery('option:selected', selectObj).size(); 4768 var cancelMove = false; 4769 jQuery(jQuery('option:selected', selectObj).get().reverse()).each( function() { 4770 if (cancelMove) return; 4771 var newPos = jQuery('option', selectObj).index(this) + 1; 4772 if (newPos < countOptions) { 4773 jQuery('option', selectObj).eq(newPos).after("<option value='"+jQuery(this).val()+"' selected='selected'>"+jQuery(this).text()+"</option>"); 4774 jQuery(this).remove(); 4775 } else { 4776 cancelMove = true; 4777 return; 4778 } 4779 }); 4780}; 4781// champ GmapPoint 4782TZR.geocode = function(id) { 4783 var address = jQuery("#gmap"+id+" .gmap-address").val(), 4784 geocoder = new google.maps.Geocoder(), 4785 error_div = jQuery("#gmap"+id+" .gmap-error"); 4786 error_div.html('').hide(); 4787 var latlng = /(\d+\.\d+),(\d+\.\d+)/.exec(address); 4788 if (latlng != null) { // we have latlng 4789 var loc = new google.maps.LatLng(latlng[1], latlng[2]); 4790 TZR.gmap.setCenter(loc); 4791 TZR.marker.setPosition(loc); 4792 return; 4793 } 4794 geocoder.geocode({'address': address}, function(results, status) { 4795 if (status == google.maps.GeocoderStatus.OK) { 4796 TZR.gmap.setCenter(results[0].geometry.location); 4797 TZR.marker.setPosition(results[0].geometry.location); 4798 } else { 4799 error_div.html("Geodode error: " + status).show(); 4800 } 4801 }); 4802} 4803TZR.osmGeocode = function(id, geocodingUrl) { 4804 var address = jQuery("#gmap"+id+" .gmap-address").val(), 4805 geocoder = new L.Control.Geocoder.Nominatim({serviceUrl : geocodingUrl}), 4806 error_div = jQuery("#gmap"+id+" .gmap-error"); 4807 error_div.html('').hide(); 4808 4809 var latlng = /(-?\d+\.-?\d+),(-?\d+\.-?\d+)/.exec(address); 4810 if (latlng != null) { // we have latlng 4811 var oLatLng = new L.LatLng(latlng[1], latlng[2]); 4812 TZR.osm.panTo(oLatLng); 4813 TZR.marker.setLatLng(oLatLng); 4814 return; 4815 } 4816 geocoder.geocode(address, function(results) { 4817 if (results.length > 0) { 4818 TZR.osm.panTo(results[0].center); 4819 TZR.marker.setLatLng(results[0].center); 4820 } else { 4821 error_div.html("Geodode error").show(); 4822 } 4823 }); 4824}; 4825gmaplocalize = function() { 4826 TZR.localize(TZR.gmap_options); 4827} 4828// display edit 4829TZR.localize = function(options) { 4830 TZR._gmap_api_key = options.gmap_key; 4831 if (window.google == undefined || google.maps == undefined) { 4832 var script = document.createElement("script"); 4833 script.type = "text/javascript";
4834 script.src = "https://maps.googleapis.com/maps/api/js?callback=gmaplocalize"; 4835 if (typeof TZR._gmap_api_key != 'undefined') 4836 script.src += "&key=" + TZR._gmap_api_key; 4837 document.body.appendChild(script); 4838 TZR.gmap_options = options; 4839 return false; 4840 } 4841 TZR.gmapremove(); 4842 var params = jQuery.extend({ 4843 edit: 0, 4844 }, options); 4845 TZR.input_lat = jQuery("#"+params.id+"-lat"); 4846 TZR.input_lng = jQuery("#"+params.id+"-lng"); 4847 var defaultLocation = params.defaultLocation.split(/,|;/), 4848 lat = TZR.input_lat.val(), 4849 lng = TZR.input_lng.val(), 4850 latlng, 4851 width = params.mapGeometry.split('x')[0], 4852 height = params.mapGeometry.split('x')[1], 4853 addrFields = jQuery("#"+params.id+"-addrFields").val(), 4854 address; 4855 if (params.edit) { 4856 if (lat != undefined && lat.length && lng != undefined && lng.length) 4857 address = lat+','+lng; 4858 else if (jQuery("#"+params.id+"-address").val()) // intable edit 4859 address = jQuery("#"+params.id+"-address").val(); 4860 else 4861 address = ''; 4862 var uiui = false; 4863 if (uiui){ 4864 TZR.gmap_div = jQuery('<div id="gmap'+params.id+'" class="gmap" style="height:'+height+'px;width:'+width+'px"><div class="close" onclick="jQuery(\'#gmap'+params.id+'\').remove()"></div><div class="move"></div><input type="button" value="OK" class="gmap-submit" onclick="TZR.gmapsetPosition();return false;"><div class="gmap-form"><input type="text" class="gmap-address" value="'+address+'"><input type="image" class="gmap-search" src="/tzr/templates/ico/general/query.png" onclick="TZR.geocode(\''+params.id+'\');return false;"></div><div id="map'+params.id+'" class="map-container" style="height:'+(height-30)+'px;width:'+width+'px"></div><div class="gmap-error"></div></div>'); 4865 } else { 4866 var htmlcontents = '<div class="google-map" id="gmap'+params.id+'"><div class="title">'+options.title+'</div><div class="form-group">'; 4867 htmlcontents += '<input type="text" class="gmap-address" value="'+address+'"><button class="btn btn-default" onclick="TZR.geocode(\''+params.id+'\');return false;"><span class="csico-search"></span></button></div>'; 4868 htmlcontents += '<div style="width:100%;height:'+height+'px" id="map'+params.id+'"></div></div>'; 4869 htmlcontents += '<div class="tzr-action"><div class="form-group"><button class="btn btn-primary" onclick="TZR.gmapsetPosition();TZR.Dialog.closeDialog();"><span class="csico-published"></span></button></div></div>'; 4870 } 4871 } else { 4872 if (uiui){ 4873 TZR.gmap_div = jQuery('<div id="gmap'+params.id+'" class="gmap" style="height:'+height+'px;width:'+width+'px" ><div class="close" onclick="jQuery(\'#gmap'+params.id+'\').remove()"></div><div class="move"></div><div id="map'+params.id+'" class="map-container" style="height:'+(height-30)+'px;width:'+width+'px"></div></div>'); 4874 } else { 4875 var htmlcontents = '<div class="google-map" id="gmap'+params.id+'"><div class="title">'+options.title+'</div>'; 4876 htmlcontents += '<div style="width:100%;height:'+height+'px" id="map'+params.id+'"></div></div>'; 4877 } 4878 } 4879 4880 if (uiui){ 4881 TZR.gmap_div.insertAfter('#'+params.id+'-loc'); 4882 4883 jQuery("#gmap"+params.id) 4884 .resizable({ 4885 minHeight: height-30, 4886 minWidth: width, 4887 stop: function(event, ui) { 4888 jQuery('.map-container', ui.element).css({height:(ui.size.height-30)+'px', width:ui.size.width+'px'}); 4889 google.maps.event.trigger(TZR.gmap, 'resize') 4890 }}) 4891 .draggable({containment:'document', handle: '.move'}) 4892 .css({position: 'absolute'}); 4893 } else { 4894 TZR.Dialog.show(htmlcontents, {allowMove:true,backdrop:true}); 4895 TZR.gmap_div = jQuery('#gmap'+params.id); 4896 } 4897 4898 if (lat != undefined && lat.length && lng != undefined && lng.length) { 4899 // existing position 4900 latlng = new google.maps.LatLng(lat, lng); 4901 } else { 4902 // default position 4903 latlng = new google.maps.LatLng(defaultLocation[0], defaultLocation[1]); 4904 if (params.edit) { 4905 if (addrFields != undefined) { // edit 4906 address = ''; 4907 jQuery.each(addrFields.split(','), function(index, value) { 4908 if (value.charAt(0) == "'") 4909 address += value.replace(/'/g, "") + ' '; 4910 else if (jQuery('input[name="_INPUT'+value+'"]').val()) // link 4911 address += jQuery('input[name="_INPUT'+value+'"]').val() + ' '; 4912 else if (jQuery('select[name="' + value + '"]').length) // select link 4913 address += jQuery('select[name="' + value + '"] option:selected').html() + ' '; 4914 else if (jQuery('textarea[name="'+value+'"]').val()) // text 4915 address += jQuery('textarea[name="'+value+'"]').val().replace(/\n/g, ' ') + ' '; 4916 else if (jQuery('input[name="'+value+'"]').val()) // shorttext 4917 address += jQuery('input[name="'+value+'"]').val() + ' '; 4918 }); 4919 } 4920 if (address.length) { 4921 TZR.gmap_div.find(".gmap-form").show().find(".gmap-address").val(address); 4922 TZR.geocode(params.id); 4923 } 4924 } 4925 } 4926 // Type d'affichage de la carte : ROADMAP|SATELLITE|HYBRID|TERRAIN 4927 var mapTypeId = ""; 4928 switch(params.mapTypeId){ 4929 case 'SATELLITE': 4930 mapTypeId = google.maps.MapTypeId.SATELLITE; 4931 break; 4932 case 'HYBRID': 4933 mapTypeId = google.maps.MapTypeId.HYBRID; 4934 break; 4935 case 'TERRAIN': 4936 mapTypeId = google.maps.MapTypeId.TERRAIN; 4937 break; 4938 default:
4939 mapTypeId = google.maps.MapTypeId.ROADMAP; 4940 break; 4941 } 4942 TZR.gmap = new google.maps.Map(document.getElementById('map'+params.id), { 4943 zoom: parseInt(params.zoom), 4944 center: latlng, 4945 mapTypeControl: true, 4946 mapTypeId: mapTypeId 4947 }); 4948 TZR.marker = new google.maps.Marker({ 4949 map: TZR.gmap, 4950 position: latlng 4951 }); 4952 if (params.edit) { 4953 TZR.marker.setDraggable(true); 4954 google.maps.event.addListener(TZR.marker, 'dblclick', function(event){ 4955 return TZR.gmapsetPosition(); 4956 }); 4957 } 4958 if (params.bounds) { 4959 var readBounds = function () { 4960 var bounds = TZR.gmap.getBounds(); 4961 jQuery("#"+params.id+"-bounds").val(bounds.getSouthWest().lat()+';'+bounds.getSouthWest().lng()+';'+bounds.getNorthEast().lat()+';'+bounds.getNorthEast().lng()); 4962 }; 4963 google.maps.event.addListener(TZR.gmap, 'idle', function(event){ 4964 readBounds(); 4965 }); 4966 google.maps.event.addListener(TZR.gmap, 'bounds_changed', function(event){ 4967 readBounds(); 4968 }); 4969 let coords = jQuery("#"+params.id+"-bounds").val(); 4970 coords = coords.split(';'); 4971 if (coords.length == 4) { 4972 let min = new google.maps.LatLng(coords[0], coords[1]); 4973 let max = new google.maps.LatLng(coords[2], coords[3]); 4974 let bounds = new google.maps.LatLngBounds(min, max); 4975 TZR.gmap.fitBounds(bounds); 4976 } 4977 } 4978 if (!uiui){ 4979 TZR.gmap_div.click(function(e){ 4980 e.stopPropagation(); 4981 }); 4982 setTimeout(function(){ 4983 jQuery("html").one('click.gmaplocalize', function(e){ 4984 TZR.gmapremove(); 4985 }) 4986 },10); 4987 } 4988 return false; 4989}; 4990TZR.localizeOSM = function(options) { 4991 if (window.L == undefined) { 4992 console.error('Leaflet manquant !'); 4993 return false; 4994 } 4995 4996 var params = jQuery.extend({ 4997 edit: 0, 4998 }, options); 4999 TZR.input_lat = jQuery("#"+params.id+"-lat"); 5000 TZR.input_lng = jQuery("#"+params.id+"-lng"); 5001 var defaultLocation = params.defaultLocation.split(/,|;/), 5002 lat = TZR.input_lat.val(), 5003 lng = TZR.input_lng.val(), 5004 height = params.mapGeometry.split('x')[1], 5005 addrFields = jQuery("#"+params.id+"-addrFields").val(), 5006 address; 5007 if (typeof(options.labels) == "undefined"){ 5008 var closebutton=null; 5009 var savebutton='<span class="csico-close"></span>'; 5010 } else { 5011 var closebutton=options.labels.close; 5012 var savebutton=options.labels.save; 5013 } 5014 if (params.edit) { 5015 if (lat != undefined && lat.length && lng != undefined && lng.length) 5016 address = lat+','+lng; 5017 else if (jQuery("#"+params.id+"-address").val()) // intable edit 5018 address = jQuery("#"+params.id+"-address").val(); 5019 else 5020 address = ''; 5021 var htmlcontents = '<div class="google-map" id="gmap'+params.id+'"><div class="title">'+options.title+'</div><div class="form-group">'; 5022 htmlcontents += '<input type="text" class="gmap-address" value="'+address+'"><button class="btn btn-default" onclick="TZR.osmGeocode(\''+params.id+'\', \''+params.geocodingUrl+'\');return false;"><span class="csico-search"></span></button></div>'; 5023 htmlcontents += '<div style="width:100%;height:'+height+'px" id="map'+params.id+'"></div></div>'; 5024 htmlcontents += '<div class="tzr-action"><div class="form-group">'; 5025 htmlcontents += '<button class="btn btn-primary" onclick="TZR.osmSetPosition();">'+savebutton+'</button>'; 5026 if (closebutton != null) 5027 htmlcontents += '<button data-dismiss="modal" class="btn btn-default">'+closebutton+'</button>'; 5028 htmlcontents += '</div></div>'; 5029 } else { 5030 var htmlcontents = '<div class="google-map" id="gmap'+params.id+'"><div class="title">'+options.title+'</div>'; 5031 htmlcontents += '<div style="width:100%;height:'+height+'px" id="map'+params.id+'"></div></div>'; 5032 if (closebutton != null) 5033 htmlcontents += '<div class="tzr-action"><button data-dismiss="modal" class="btn btn-default">'+closebutton+'</button></div>'; 5034 } 5035 5036 5037 TZR.Dialog.show(htmlcontents, {allowMove:true,backdrop:true}); 5038 TZR.gmap_div = jQuery('#gmap'+params.id); 5039 5040 var center = defaultLocation; 5041 5042 if (lat != undefined && lat.length && lng != undefined && lng.length) { 5043 // existing position 5044 center = [lat, lng]; 5045 } 5046 else { 5047 if (params.edit) { 5048 if (addrFields != undefined) { // edit 5049 address = ''; 5050 jQuery.each(addrFields.split(','), function(index, value) { 5051 if (value.charAt(0) == "'") 5052 address += value.replace(/'/g, "") + ' '; 5053 else if (jQuery('input[name="_INPUT'+value+'"]').val()) // link 5054 address += jQuery('input[name="_INPUT'+value+'"]').val() + ' '; 5055 else if (jQuery('select[name="' + value + '"]').length) // select link 5056 address += jQuery('select[name="' + value + '"] option:selected').html() + ' '; 5057 else if (jQuery('textarea[name="'+value+'"]').val()) // text 5058 address += jQuery('textarea[name="'+value+'"]').val().replace(/\n/g, ' ') + ' '; 5059 else if (jQuery('input[name="'+value+'"]').val()) // shorttext 5060 address += jQuery('input[name="'+value+'"]').val() + ' '; 5061 }); 5062 } 5063 if (address.length) { 5064 TZR.gmap_div.find(".gmap-form").show().find(".gmap-address").val(address); 5065 TZR.osmGeocode(params.id, params.geocodingUrl); 5066 } 5067 } 5068 } 5069
5070 TZR.osm = L.map('map'+params.id).setView(center, parseInt(params.zoom)); 5071 5072 TZR.osmFeatureGroup = L.featureGroup().addTo(TZR.osm); 5073 5074 L.tileLayer(params.tilesURL, { attribution : 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="https://opendatacommons.org/licenses/odbl/">ODbL</a>, Imagery © <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>' }).addTo(TZR.osm); 5075 5076 if (params.scrollWheelZoom) { 5077 TZR.osm.scrollWheelZoom.enable(); 5078 } else { 5079 TZR.osm.scrollWheelZoom.disable(); 5080 } 5081 5082 TZR.marker = L.marker(center); 5083 5084 TZR.marker.addTo(TZR.osmFeatureGroup); 5085 5086 if (params.edit) { 5087 TZR.marker.dragging.enable(); 5088 TZR.marker.addEventListener('dblclick', function(event) { 5089 return TZR.osmSetPosition(); 5090 }); 5091 } 5092 if (params.bounds) { 5093 var readBounds = function () { 5094 var bounds = TZR.osm.getBounds(); 5095 jQuery("#"+params.id+"-bounds").val(bounds.getSouthWest().lat+';'+bounds.getSouthWest().lng+';'+bounds.getNorthEast().lat+';'+bounds.getNorthEast().lng); 5096 }; 5097 TZR.osm.on('moveend', readBounds); 5098 TZR.osm.on('zoomend', readBounds); 5099 let coords = jQuery("#"+params.id+"-bounds").val(); 5100 coords = coords.split(';'); 5101 if (coords.length == 4) { 5102 TZR.osm.fitBounds([ 5103 [coords[0], coords[1]], 5104 [coords[2], coords[3]] 5105 ]); 5106 } else { 5107 readBounds(); 5108 } 5109 } 5110 TZR.gmap_div.click(function(e){ 5111 e.stopPropagation(); 5112 }); 5113 return false; 5114}; 5115 5116TZR.curPosOSM = function(options){ 5117 curLocOSM = function(pos){ 5118 options.defaultLocation = pos.coords.latitude+","+pos.coords.longitude; 5119 TZR.localizeOSM(options); 5120 } 5121 noCurLocOSM = function(pos){ 5122 TZR.localizeOSM(options); 5123 } 5124 navigator.geolocation.getCurrentPosition(curLocOSM,noCurLocOSM); 5125} 5126 5127TZR.curPos = function(options){ 5128 curLoc = function(pos){ 5129 options.defaultLocation = pos.coords.latitude+","+pos.coords.longitude; 5130 TZR.localize(options); 5131 } 5132 noCurLoc = function(pos){ 5133 TZR.localize(options); 5134 } 5135 navigator.geolocation.getCurrentPosition(curLoc,noCurLoc); 5136} 5137 5138TZR.gmapsetPosition = function() { 5139 var pos = TZR.marker.getPosition(); 5140 TZR.input_lat.val(pos.lat()).change(); 5141 TZR.input_lng.val(pos.lng()).change(); 5142 TZR.gmapremove(); 5143 return false; 5144}; 5145TZR.osmSetPosition = function(){ 5146 var pos = TZR.marker.getLatLng(); 5147 TZR.input_lat.val(pos.lat); 5148 TZR.input_lng.val(pos.lng); 5149 TZR.osmRemove(); 5150 return false; 5151}; 5152 5153TZR.gmapremove = function(){ 5154 if (TZR.gmap_div != undefined) { 5155 TZR.gmap_div.remove(); 5156 TZR.gmap_div = null; 5157 jQuery("html").unbind('click.gmaplocalize'); 5158 } 5159}; 5160TZR.osmRemove = function(){ 5161 if (TZR.gmap_div != undefined) { 5162 TZR.gmap_div.remove(); 5163 TZR.gmap_div = null; 5164 } 5165 TZR.Dialog.closeDialog(); 5166}; 5167/*sélection d'un objet en popup - champ mono*/ 5168TZR.xlinkdefCancelValue = function(varid, options){ 5169 TZR.xlinkdefValueSelected(varid, {tlink:"", oid:"", openeroptions:{multivalued:0}}); 5170} 5171TZR.xlinkdefValueSelected = function(varid, data){ 5172 data = jQuery.extend({objectproperties:null}, data); 5173 if (data.openeroptions.multivalued==1) 5174 TZR.xlinkdefMultipleValueSelected(varid, data); 5175 /*<%* mono valué *%>*/ 5176 var container = jQuery("#browsesourcelink"+varid); 5177 jQuery("#"+varid, container).val(data.oid); 5178 jQuery("span.title", container).html(data.tlink); 5179 if ( typeof(TZR.local_xlinkdef_value_selected) == 'function'){ 5180 TZR.local_xlinkdef_value_selected(varid, data); 5181 } 5182 if (data.oid != null && data.oid != ""){ 5183 jQuery("span.cancel", container).show(); 5184 } else { 5185 jQuery("span.cancel", container).hide(); 5186 } 5187 TZR.Dialog.closeDialog(); 5188}; 5189TZR.xlinkdefMultipleValueSelected = function(id, options){ 5190 if(jQuery('#table'+id).find('input[value="'+options.oid+'"]').length>0) return; 5191 var tr=TZR.addTableLine("table"+id,[undefined,options.tlink],0,false); 5192 jQuery('input',tr.cells[0]).val(options.oid); 5193 jQuery(tr).show(); 5194 TZR.Dialog.closeDialog(); 5195}; 5196TZR.xlinkdefSelectionPopup = function(options){ 5197 options.url += "&"+jQuery.param({'openeroptions':options}); 5198 TZR.Dialog.openURL(options.url); 5199} 5200// FO 5201gmapdisplay = function() { 5202 for (i=0; i<TZR.gmap_params.length; i++) 5203 TZR.gmapdisplay(TZR.gmap_params[i]); 5204} 5205TZR.gmapdisplay = function(params) { 5206 TZR._gmap_api_key = params.gmap_key; 5207 if (window.google == undefined || google.maps == undefined) { 5208 if (TZR.gmap_params == undefined) { 5209 TZR.gmap_params = [params]; 5210 var script = document.createElement("script"); 5211 script.type = "text/javascript";
5212 script.src = "https://maps.googleapis.com/maps/api/js?callback=gmapdisplay"; 5213 if (typeof TZR._gmap_api_key != 'undefined') 5214 script.src += "&key=" + TZR._gmap_api_key; 5215 document.body.appendChild(script); 5216 } 5217 else 5218 TZR.gmap_params.push(params); 5219 return false; 5220 } 5221 if (jQuery('#'+params.id).is(':visible')) 5222 TZR.gmapshow(params); 5223 else 5224 params.timer = setInterval(function(){TZR.gmapshow(params)}, 500); 5225 return false; 5226}; 5227TZR.osmDisplay = function(params) { 5228 if (window.L == undefined) { 5229 console.error('Leaflet manquant !'); 5230 return false; 5231 } 5232 5233 if (jQuery('#'+params.id).is(':visible')) 5234 TZR.osmShow(params); 5235 else 5236 params.timer = setInterval(function(){TZR.osmShow(params)}, 500); 5237 return false; 5238}; 5239TZR.gmapshow = function(params) { 5240 if (!jQuery('#'+params.id).is(':visible')) 5241 return; 5242 if (params.timer) 5243 clearInterval(params.timer); 5244 var location = params.defaultLocation.split(','), 5245 latlng = new google.maps.LatLng(location[0], location[1]); 5246 var gmap = new google.maps.Map(document.getElementById(params.id), { 5247 zoom: params.zoom, 5248 center: latlng, 5249 mapTypeControl: true, 5250 mapTypeId: google.maps.MapTypeId.ROADMAP 5251 }); 5252 var marker = new google.maps.Marker({ 5253 map: gmap, 5254 position: latlng 5255 }); 5256}; 5257TZR.osmShow = function(params) { 5258 if (!jQuery('#'+params.id).is(':visible')) 5259 return; 5260 if (params.timer) 5261 clearInterval(params.timer); 5262 var location = params.defaultLocation.split(','); 5263 5264 var osm = L.map(params.id).setView(location, parseInt(params.zoom)); 5265 5266 var osmFeatureGroup = L.featureGroup().addTo(osm); 5267 5268 L.tileLayer(params.tilesURL, { attribution : 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, <a href="https://opendatacommons.org/licenses/odbl/">ODbL</a>, Imagery © <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>' }).addTo(osm); 5269 5270 if (params.scrollWheelZoom) { 5271 osm.scrollWheelZoom.enable(); 5272 } else { 5273 osm.scrollWheelZoom.disable(); 5274 } 5275 5276 var marker = L.marker(location); 5277 5278 marker.addTo(osmFeatureGroup); 5279}; 5280 5281/* 5282 * Gestion du drag&drop de fichier 5283 * 5284 * TZR.addProperDragEventsTo active des évènements de DnD propres (properdragenter/properdragleave) sur un selecteur jQuery. 5285 * Ajoute aussi automatiquement la classe droppable aux éléments ainsi que la classe dragging au survol en mode DnD. 5286 * Ainsi properdragenter et properdragleave ne sont déclenchés qu'une seule fois à l'entrée/sortie sur l'élement (à l'image d'un mouseenter/mouseleave). 5287 * Si pour élément, lui ou un des fils a un écouteur sur dragenter ou dragleave avec un stopPropagation, alors les 2 évènements doivent avoir un écouteur avec stopPropagation, sinon le système ne fonctionne plus. 5288 * De plus, faire cela permet par exemple de rendre le DnD "actif" sur un element à la fois au sein d'une arborescence d'element 5289 * Exemple : On active les évènements propres sur body et une div 5290 * Par défaut : 5291 * Entrée sur la fenêtre : appel de body->
5291properdragenter 5292 * Entrée sur la div : appel de div->properdragenter 5293 * Sortie de la div : appel de div->properdragleave 5294 * Sortie de la fenêtre : appel de body->properdragleave 5295 * Avec stopPropagation sur dragenter et dragleave : 5296 * Entrée sur la fenêtre : appel de body->properdragenter 5297 * Entrée sur la div : appel de div->properdragenter et de body->properdragleave 5298 * Sortie de la div : appel de div->properdragleave et de body->properdragenter 5299 * Sortie de la fenêtre : appel de body->properdragleave 5300 */ 5301jQuery.event.props.push("dataTransfer"); 5302TZR.addProperDragEventsTo=function(el,addoverlay){ 5303 var $el=jQuery(el).addClass('droppable'); 5304 5305 $el.on('dragover.proper',function(e){ 5306 // Obligatoire pour pouvoir avoir un drop personnalisé 5307 e.preventDefault(); 5308 }).on('drop.proper',function(e){ 5309 // Obligatoire pour pouvoir avoir un drop personnalisé 5310 e.preventDefault(); 5311 $el.trigger('properdragleave'); 5312 }).on('dragenter.proper',function(e){ 5313 var cnt=jQuery(this).data('dragentercounter'); 5314 if(!cnt) cnt=0; 5315 cnt++; 5316 // Dans la théorie, pour chaque enter dans un fils, il y a un leave et un enter du parent. De ce fait le compteur ne peut pas dépasser 2. 5317 // Dans la pratique, il arrive que le leave du parent ne se fasse pas, d'ou la limitation par programme 5318 if(cnt>2) cnt=2; 5319 if(cnt==1) jQuery(this).trigger('properdragenter'); 5320 jQuery(this).data('dragentercounter',cnt); 5321 }).on('dragleave.proper',function(e){ 5322 var cnt=jQuery(this).data('dragentercounter'); 5323 cnt--; 5324 if(cnt<0) cnt=0; 5325 if(cnt==0) jQuery(this).triggerHandler('properdragleave'); 5326 jQuery(this).data('dragentercounter',cnt); 5327 }).on('properdragenter',function(e){ 5328 e.stopPropagation(); 5329 jQuery(this).addClass('dragging'); 5330 }).on('properdragleave',function(e){ 5331 e.stopPropagation(); 5332 jQuery(this).data('dragentercounter',0).removeClass('dragging'); 5333 }); 5334 5335 if(addoverlay){ 5336 if(typeof addoverlay!='string') addoverlay='Déposez vos fichiers dans la zone ci-dessous'; 5337 $el.append('<div class="dropoverlay"><div class="dropoverlay-content"><div class="dropoverlay-txt">'+addoverlay+'</div><div class="dropoverlay-fl"></div></div></div></div>'); 5338 } 5339 return $el; 5340} 5341// Vérifie si un evenement DnD concerne des fichiers 5342TZR.dragEventContainsFiles=function(e){ 5343 if(e.dataTransfer.types && e.dataTransfer.files && e.dataTransfer.files.length){ 5344 for(var i in e.dataTransfer.types){ 5345 if(e.dataTransfer.types[i]=="Files") return true; 5346 } 5347 } 5348 return false; 5349} 5350// Ajoute la gestion des evenements propres DnD sur body 5351jQuery(function(){ 5352 TZR.addProperDragEventsTo('body'); 5353}); 5354 5355 5356/* XFile */ 5357// Initiliase un champ dossier 5358TZR.addXFileUploader=function(table,field,uniqid,opts){ 5359 var $cont=jQuery('#'+uniqid+"_cont"); 5360 var $queue=$cont.find("div.uploadQueue"); 5361 var _opts={ 5362 drop_element:$cont[0], 5363 runtimes:"html5", 5364 url:TZR._sharescripts+'uploader.php?swf='+uniqid+'*'+table+'*'+field, 5365 browse_button:$cont.find("input.uploadAddButton")[0], 5366 file_data_name:'Filedata', 5367 init:{ 5368 FilesAdded:function(up,files){ 5369 if(typeof(TZR.uploadInProgressFiles[uniqid])=="undefined") TZR.uploadInProgressFiles[uniqid]=0; 5370 5371 if(!up.settings.multi_selection){ 5372 if($queue.find('>div.uploadQueueItem').length){ 5373 TZR.removeXFileFile(uniqid,$queue.find('>div.uploadQueueItem').attr('id')); 5374 } 5375 if(files.length>1){ 5376 files=files.slice(0,1); 5377 } 5378 } 5379 TZR.uploadInProgressFiles[uniqid]+=files.length; 5380 var size_total=0; 5381 plupload.each(files,function(file){ 5382 if(file.name.length>30) var name=file.name.substr(0,27)+'...'; 5383 else var name=file.name; 5384 size_total+=file.size; 5385 $queue.append('<div class="uploadQueueItem" id="'+file.id+'">'+ 5386 '<div class="uploadCancel"><a class="btn btn-default btn-md" href="#" onclick="TZR.removeXFileFile(\''+uniqid+'\',\''+file.id+'\',\''+file.size+'\',\''+file.name+'\'); return false;">'+ 5387 '<span class="glypicon csico-close"></span>'+ 5388 '</a></div>'+ 5389 '<span class="uploadFileName">'+name+' ('+plupload.formatSize(file.size)+')</span><span class="uploadPercentage"></span>'+ 5390 '<div class="uploadProgress"><div class="uploadProgressBar" style="width:0%;"></div></div>'+ 5391 '</div>'); 5392 }); 5393 up.start(); 5394 5395 if(TZR.uploadAutoSaveMessage && size_total>(10*1024*1024)) setTimeout(function(){TZR.uploadAutoSave=confirm(TZR.uploadAutoSaveMessage)},500); 5396 if(!TZR.uploadKeepAliveTimer) TZR.uploadKeepAliveTimer=setInterval(TZR.keepAlive,300000); 5397 }, 5398 FilesRemoved:function(up,files){ 5399 TZR.uploadInProgressFiles[uniqid]-=files.length; 5400 }, 5401 UploadFile:function(up,file){ 5402 file.percentagespan=jQuery('#'+file.id+' span.uploadPercentage'); 5403 file.progressbardiv=jQuery('#'+file.id+' div.uploadProgressBar'); 5404 if(up.runtime=="html4") var t='Uploading...'; 5405 else var t="0%"; 5406 file.percentagespan.html(" - "+t); 5407 }, 5408 UploadProgress:function(up,file){ 5409 file.percentagespan.html(" - "+file.percent+"%"); 5410 file.progressbardiv.css('width',file.percent+'%'); 5411 }, 5412 FileUploaded:function(up,file){ 5413 jQuery('#'+file.id).addClass('uploadComplete'); 5414 TZR.uploadXFileCompleted[uniqid] = true; 5415 file.percentagespan.html(" - Complete"); 5416 if(file.timer){ 5417 clearInterval(file.timer); 5418 delete file.timer; 5419 } 5420 TZR.uploadInProgressFiles[uniqid]--; 5421 const eventUploadCompleted = new CustomEvent("uploadCompleted", { detail: {uploaderId: uniqid+"_cont", fileId: file.id, fileSize: file.size },}); 5422 document.dispatchEvent(eventUploadCompleted); 5423 }, 5424 UploadComplete:function(up){ 5425 if(TZR.uploadKeepAliveTimer){ 5426 clearInterval(TZR.uploadKeepAliveTimer); 5427 delete TZR.uploadKeepAliveTimer; 5428 } 5429 5430 TZR.setElementErrorState(document.getElementById(`${uniqid}_cont`), 5431 true, 5432 "error_field"); 5433 5434 if(TZR.uploadAutoSave) { 5435 var $form=jQuery(up.settings.browse_button).closest('form'); 5436 $form.submit(); 5437 TZR.uploadAutoSave=false; 5438 } 5439 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields) { 5440 TZR.Table.saveSomeLangsCheckFields(jQuery(up.settings.browse_button).closest(".row").find("input")[0]); 5441 } 5442 }, 5443 Error:function(up,error){ 5444 if(error.file && error.file.percentagespan){ 5445 error.file.percentagespan.html(" - "+error.message).addClass('tzr-message'); 5446 try{ 5447 var mess = error.file.percentagespan.html(); 5448 error.file.percentagespan.html(mess+" "+error.code+" - "+error.status+""); 5449 console.log(error); 5450 }catch(noconsolelog){}; 5451 error.file.progressbardiv.css('width',0); 5452 jQuery('#'+error.file.id).addClass('uploadError'); 5453 }else{ 5454 var _alert = typeof TZR.alert == 'function' ? TZR.alert : alert; 5455 if(error.file){ 5456 if(error.code && error.code === plupload.FILE_SIZE_ERROR) { 5457 _alert(error.file.name+' : '+error.message+' '+plupload.formatSize(error.file.size)+' ('+ plupload.formatSize(opts.filters.max_file_size) +' max)'); 5458 }else{ 5459 _alert(error.file.name+' : '+error.message); 5460 } 5461 }else{ 5462 _alert(error.message); 5463 } 5464 } 5465 } 5466 } 5467 }; 5468 if(typeof opts=="object") jQuery.extend(_opts,opts); 5469 var uploader=new plupload.Uploader(_opts); 5470 $cont.data('uploader',uploader); 5471 uploader.init(); 5472 // Gestion du DnD 5473 TZR.addProperDragEventsTo($cont); 5474 // Stockage des uploads valides (un fichier au moins) et des uploads en cours 5475 if(typeof(TZR.uploadXFileCompleted)=="undefined") TZR.uploadXFileCompleted={}; 5476 if(typeof(TZR.uploadInProgressFiles)=="undefined") TZR.uploadInProgressFiles={}; 5477} 5478TZR.removeXFileFile=function(uniqid,fileId,fileSize,fileName){ 5479 if (fileSize == undefined) fileSize = 0; 5480 if (fileName == undefined) fileName = ""; 5481 var $cont=jQuery('#'+uniqid+"_cont"); 5482 var up = $cont.data('uploader'); 5483 var url; 5484 if ($cont.find('#'+fileId).hasClass("uploadComplete")) { 5485 const eventUploadRemoveCompleted = new CustomEvent("uploadRemoveCompleted", { detail: {uploaderId: uniqid+"_cont", fileId: fileId, fileSize: fileSize },}); 5486 document.dispatchEvent(eventUploadRemoveCompleted); 5487 5488 //modifier le catalog (le fichier n'est dans le catalogue qui si l'upload est complete) 5489 var fileIndex = 0; 5490 jQuery('.uploadQueueItem.uploadComplete').each(function(i, elem) { 5491 if (jQuery(elem).attr('id') == fileId) { 5492 fileIndex = i; 5493 return; 5494 } 5495 }); 5496 url=up.settings.url.replace("uploader.php","uploader-remove.php"); 5497 url+= '*'+fileIndex+'*'+fileName; 5498 TZR.jQueryPost({ 5499 'url':encodeURI(url), 5500 'type':'POST' 5501 }); 5502 } 5503 $cont.data('uploader').removeFile(fileId); 5504 $cont.find('#'+fileId).remove(); 5505} 5506TZR.resetXFileUploader=function(container){ 5507 var elements = jQuery("*", container).each(function(){ 5508 var elm = jQuery(this); 5509 if (elm.data('uploader')){ 5510 if (elm.is(':visible')){ 5511 var uploader = elm.data('uploader'); 5512 uploader.init(); 5513 } 5514 } 5515 }); 5516} 5517 5518TZR.Xinterval = {shiftKey: false, start: null, add: true}; 5519 5520TZR.Xinterval.init = function (varid, options){ 5521 if (!options) 5522 options = {title:''}; 5523 var interval = jQuery('#' + varid); 5524 interval.data('options', options); 5525 interval.data('initialval', interval.val()); 5526 interval.data('dates', interval.val().split(';').filter(function (v) { 5527 return v.length; 5528 })); 5529 interval.data('curinterval', []); 5530} 5531TZR.Xinterval.show = function (el, varid){ 5532 var options = jQuery('#' + varid).data('options'); 5533 var container = jQuery("#intervaldiv"+varid+"_"); 5534 var html = container.html(); 5535 var exp = new RegExp(varid+"_", "g"); 5536 html = '<div id="intervaldiv'+varid+'">'+html.replace(exp, varid)+'</div>'; 5537 // modal dédiée dans l'immédiat 5538 var elm = jQuery("#cvx-daterange-modal");
5539 jQuery(".modal-body", elm).html(html); 5540 jQuery(elm).modal({backdrop:false,show:false}); 5541 jQuery(elm).modal('show', {}); 5542 jQuery(".modal-header", elm).css('cursor','move'); 5543 elm.draggable({handle: "div.modal-header"}); 5544 5545 // reactiver le scroll d'une fenêtre modale parent 5546 jQuery(document).on('hidden.bs.modal', '.modal', function () { 5547 jQuery('.modal:visible').length && $(document.body).addClass('modal-open'); 5548 }); 5549 5550 jQuery("#intervaldiv"+varid).show(); 5551 if (options.title != '') 5552 jQuery(".modal-header>h4", elm).html(options.title); 5553 if (!jQuery('#datePicker' + varid).html().length) { 5554 TZR.Xinterval.datePicker(varid); 5555 } else { 5556 jQuery('#datePicker'+varid).datepicker("refresh"); 5557 } 5558 TZR.Xinterval.initKeysHandlers.call(TZR.Xinterval, varid); 5559} 5560TZR.Xinterval.initKeysHandlers = function(varid){ 5561 jQuery(document).off('.xinterval'); 5562 var that = this; 5563 jQuery(document).on('keydown.xinterval', function (e) { 5564 that.shiftKey = e.shiftKey; 5565 }); 5566 jQuery(document).on('keyup.xinterval', function (e) { 5567 that.keyUp(e, varid); 5568 }); 5569} 5570TZR.Xinterval.keyUp = function(e, varid){ 5571 this.shiftKey = false; 5572 var interval = jQuery('#' + varid); 5573 var date, index; 5574 for (i = 0; i < interval.data('curinterval').length; i++) { 5575 date = interval.data('curinterval')[i]; 5576 if (date == this.start) 5577 continue; 5578 index = interval.data('dates').indexOf(date); 5579 if (this.add) { 5580 if (index == -1) 5581 interval.data('dates').push(date); 5582 } else { 5583 interval.data('dates').splice(index, 1); 5584 } 5585 } 5586 jQuery('#datepicker' + varid).datepicker('refresh'); 5587 interval.data('curinterval', []); 5588 this.updateRecap(varid); 5589 this.start = null; 5590} 5591// Fonction de mise à jour du contenu texte 5592TZR.Xinterval.updateRecap = function (varid, init) { 5593 var interval = jQuery('#' + varid), recap = '', dates = interval.data('dates').sort(); 5594 interval.val(dates.join(';')); 5595 if(!init) { 5596 interval.change(); 5597 } 5598 // le recap 5599 var periods = TZR.datesToPeriods(dates); 5600 var dateFormat = interval.data('format') 5601 for (i in periods) { 5602 if (periods[i][0] == periods[i][1]) { 5603 recap += jQuery.datepicker.formatDate(dateFormat, new Date(periods[i][0])) + '<br>'; 5604 } else { 5605 recap += TZR.Xinterval.fromLabel +" "+ jQuery.datepicker.formatDate(dateFormat, new Date(periods[i][0])) 5606 + " " + TZR.Xinterval.toLabel + " " + jQuery.datepicker.formatDate(dateFormat, new Date(periods[i][1])) + '<br>'; 5607 } 5608 } 5609 jQuery('#recap' + varid).html(recap); 5610} 5611 5612// Initialisation global datepicker 5613TZR.Xinterval.datePicker = function (varid) { 5614 var interval = jQuery('#' + varid), 5615 nbMonths = parseInt(jQuery('#nbMonths' + varid).val()), 5616 numberOfMonths; 5617 if (nbMonths < 4) { 5618 numberOfMonths = nbMonths; 5619 } else { 5620 numberOfMonths = [Math.ceil(nbMonths / 4), 4]; 5621 } 5622 jQuery('#datePicker' + varid).datepicker("destroy").datepicker({ 5623 inline: true, 5624 showOtherMonths: true, 5625 selectOtherMonths: true, 5626 changeMonth:true, 5627 changeYear:true, 5628 minDate: new Date(interval.data('datemin')), 5629 maxDate: new Date(interval.data('datemax')), 5630 defaultDate: new Date(interval.data('dates')[0]), 5631 hideIfNoPrevNext: true, 5632 direction: "down", 5633 showAnim:"slideDown", 5634 showOn: "both", 5635 stepMonths: nbMonths > 4 ? 4 : 1, 5636 numberOfMonths: numberOfMonths, 5637 showButtonPanel: true, 5638 onSelect: function (dateText, inst) { 5639 if (interval.data('readonly')) 5640 return; 5641 var date = TZR.isoDate(new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay)); 5642 if (TZR.Xinterval.shiftKey && TZR.Xinterval.start != null) { 5643 TZR.Xinterval.pushInterval(varid, date); 5644 return; 5645 } 5646 var index = interval.data('dates').indexOf(date); 5647 TZR.Xinterval.start = date; 5648 if (index == -1) { 5649 interval.data('dates').push(date); 5650 TZR.Xinterval.add = true; 5651 } else { 5652 interval.data('dates').splice(index, 1); 5653 TZR.Xinterval.add = false; 5654 } 5655 TZR.Xinterval.updateRecap(varid); 5656 inst.dpDiv.datepicker('refresh'); 5657 return; 5658 }, 5659 beforeShowDay: function (date) { 5660 var isodate = TZR.isoDate(date); 5661 // On vérifie si le timestamp de la date courante est sélectionné 5662 var index = interval.data('dates').indexOf(isodate); 5663 var indexi = interval.data('curinterval').indexOf(isodate); 5664 if (isodate == TZR.Xinterval.start) { 5665 if (!TZR.Xinterval.add) 5666 return [true, '']; 5667 else 5668 return [true, 'dates-selected']; 5669 } 5670 if (indexi != -1) { 5671 if (!TZR.Xinterval.add) 5672 return [true, '']; 5673 else 5674 return [true, 'dates-selected']; 5675 } 5676 if (index != -1) 5677 return [true, 'dates-selected']; 5678 return [true, '']; 5679 } 5680 }); 5681} 5682 5683TZR.Xinterval.pushInterval = function (varid, date) { 5684 var interval = jQuery('#' + varid), 5685 dateStart = new Date(TZR.Xinterval.start < date ? TZR.Xinterval.start : date), 5686 endDate = new Date(TZR.Xinterval.start < date ? date : TZR.Xinterval.start); 5687 interval.data('curinterval', []); 5688 while (dateStart <= endDate) { 5689 interval.data('curinterval').push(TZR.isoDate(dateStart)); 5690 dateStart.setDate(dateStart.getDate() + 1); 5691 } 5692} 5693 5694// Fonction de ré-initialisation 5695TZR.Xinterval.reset = function (varid) { 5696 var interval = jQuery('#' + varid); 5697 interval.val(interval.data('initialval')); 5698 interval.data('dates', interval.val().split(';')); 5699 interval.data('curinterval', []); 5700 TZR.Xinterval.updateRecap(varid); 5701 jQuery('#datePicker' + varid).datepicker('refresh'); 5702} 5703TZR.Xinterval.clear = function (varid) { 5704 jQuery('#' + varid).data('dates', []); 5705 TZR.Xinterval.updateRecap(varid); 5706 jQuery('#datePicker' + varid + ':visible').datepicker('refresh'); 5707} 5708 5709TZR.datesToPeriods = function (dates) { 5710 dates.sort(); 5711 var periods = []; 5712 var startDate = dates[0], nextDate; 5713 for (i = 0; i < dates.length; i++) { 5714 nextDate = new Date(dates[i]); 5715 nextDate.setDate(nextDate.getDate() + 1); 5716 if (dates[i + 1] != TZR.isoDate(nextDate)) { 5717 periods.push([startDate, dates[i]]); 5718 startDate = dates[i + 1]; 5719 } 5720 } 5721 return periods; 5722} 5723 5724TZR.isoDate = function (date) { 5725 return date.getFullYear() + '-' + ('0' + (date.getMonth() + 1)).slice(-2) + '-' + ('0' + date.getDate()).slice(-2); 5726} 5727
5728//////////////////////////////// 5729TZR.updateModuleContainer=function(url,modulecontainer){ 5730 if (modulecontainer == undefined) 5731 modulecontainer = jQuery('div.cv8-module-container:first'); 5732 if (url == undefined || url.length==0) 5733 url=TZR._self; 5734 5735 var id = modulecontainer.find('div[id^=cv8-uniqdiv]').attr('id').replace(/cv8-uniqdiv-/g, ''); 5736 var current_tab = $('#tzr-tablist-'+id+' li.active').attr('id'); 5737 var ssmoid = null; 5738 if (current_tab) { 5739 ssmoid = current_tab.replace(/^li-([0-9]+)-[0-9a-zA-Z]+$/g, '$1'); 5740 } 5741 //Si l'action est edit et que des cases sont cochées dans l'onglet actif d'un sous module alors on fait une edition par lot des fiches du sous module. Sinon on edite la fiche en cours. 5742 if (url.indexOf('function=edit') > -1 && document.forms['editssmodform'+id+'-'+ssmoid] && TZR.checkBoxesIsChecked(document.forms['editssmodform'+id+'-'+ssmoid], 'selectstart_'+ssmoid, 'selectend_'+ssmoid, /_selected\[/)) { 5743 TZR.Table.applyfunction(id,"editSelection","",{ssmoid_editselection : ssmoid, template:"Module/Table.editSelection.html"},false,true); 5744 } else { 5745 TZR.jQueryLoad({target: modulecontainer, url: url}); 5746 } 5747 } 5748 5749/** 5750 * XSiteApp 5751 * Choix du sous-site administré 5752 * @constructor 5753 */ 5754TZR.XSiteApp = function() {}; 5755 5756/** 5757 * Ecouter les choix de sous-site à administrer. 5758 * @param select: Element HTML select permettant le choix de l'APP 5759 */ 5760TZR.XSiteApp.prototype.listenChoices = function(select) { 5761 var that = this; 5762 var $select = jQuery(select); 5763 5764 $select.change(function(){ 5765 var $option_selected = jQuery(jQuery('option:selected', $select)); 5766 var topic_manager_moid = $option_selected.data('xmodinfotree_moid'); 5767 that.setTopicManagerLink(topic_manager_moid); 5768 that.setForcedApp($select.val(), function(){ 5769 that.refreshContents(); 5770 }); 5771 }); 5772 5773 // On affiche dés le départ un lien vers le gestionnaire de rubrique 5774 var $option_selected = jQuery(jQuery('option:selected', $select)); 5775 var topic_manager_moid = $option_selected.data('xmodinfotree_moid'); 5776 that.setTopicManagerLink(topic_manager_moid); 5777}; 5778 5779/** 5780 * Notifie à Seolan le choix de l'app. 5781 * @param app_koid: KOID de l'app choisis. 5782 * @param callback: callback executé après l'appel ajax et si il as réussis 5783 */ 5784TZR.XSiteApp.prototype.setForcedApp = function (app_koid, callback) { 5785 jQuery.ajax({ 5786 url: "admin.php?class=\Seolan\Module\Application\Application&function=setForcedApps&apps_koids[]="+app_koid, 5787 context: document.body 5788 }).done(callback); 5789}; 5790 5791/** 5792 * Rafraichissement des différentes zones rafraichissables 5793 */ 5794TZR.XSiteApp.prototype.refreshContents = function () { 5795 jQuery('a.cv8-refresh').trigger('click'); 5796}; 5797 5798/** 5799 * Permet l'affichage d'un lien vers le gestionnaire de rubrique correspondant à l'app choisis. 5800 * @param topic_manager_moid_to_show: moid du gestionnaire de rubrique correspondant au sous-site choisis. 5801 */ 5802TZR.XSiteApp.prototype.setTopicManagerLink = function (topic_manager_moid_to_show) { 5803 jQuery('.cv8-subsite_current_topic_manager').remove(); 5804 var module_link = "/csx/scripts/admin.php?_bdx=5_3&moid="+topic_manager_moid_to_show+"&function=home&tplentry=mit&template=Module/InfoTree.index.html"; 5805 5806 var topic_manager_selected_menu_element = 5807 '<span class="cv8-subsite_current_topic_manager">' + 5808 '<li class="line"> </li>' + 5809 '<li id="node_CS8_sub_site_current_topic_manager_'+topic_manager_moid_to_show+'" data-oid="'+topic_manager_moid_to_show+'" class="doc">' + 5810 '<div style="position:absolute;">' + 5811 '<div class="ico">' + 5812 '</div>' + 5813 '</div>' + 5814 '<a href="'+module_link+'" onclick="home_viewmodule(this); return false;">Gestion des pages</a>' + 5815 '</li>' + 5816 '<li class="line-last"></li>' + 5817 '</span>' 5818 ; 5819 5820 jQuery(topic_manager_selected_menu_element).insertAfter(jQuery('span#cv8-infotreemenu')); 5821}; 5822// Label Field 5823TZR.FieldLabel = {}; 5824TZR.FieldLabel.ckeditor = function(id, fname, config){ 5825 var container = document.getElementById(id); 5826 var content = container.innerHTML; 5827 container.innerHTML = ''; 5828 document.getElementById(id+"_unchanged").remove(); 5829 jQuery(container).append("<textarea name='"+fname+"' id='ta"+id+"'>"+content+"</textarea>"); 5830 document.getElementById("edit"+id).disabled = true; 5831 CKEDITOR.replace("ta"+id,config); 5832}; 5833 5834// Securisation des videos 5835TZR.XFileDef = {}; 5836 5837TZR.XFileDef.defaultOptions = { 5838 table : 'T009', 5839 field : 'media', 5840 urlAjax : '', 5841 element : '' 5842}; 5843 5844TZR.XFileDef.options = {}; 5845 5846TZR.XFileDef.secureVideo = function (params) { 5847 TZR.XFileDef.options = jQuery.extend({}, TZR.XFileDef.defaultOptions, params); 5848 5849 var $element = jQuery(TZR.XFileDef.options.element); 5850 $element.on('play', function(event) { 5851 jQuery.ajax({ 5852 url : TZR.XFileDef.options.urlAjax, 5853 async : false, 5854 data : { 5855 class : '\\Seolan\\Field\\File\\File', 5856 function : 'xfiledef_enablePlay', 5857 table : TZR.XFileDef.options.table, 5858 field : TZR.XFileDef.options.field 5859 }, 5860 method : 'GET', 5861 success: function(data){ 5862 if (data != 1) { 5863 $element.get(0).remove(); 5864 $element.get(0).setSrc(''); 5865 } 5866 } 5867 }); 5868 }); 5869}; 5870TZR.XFileDef.markDel = function(varid, fname, fileid, fileindex, compulsory, color){ 5871 var chkb = document.getElementById(`${fname}_del_${fileid}_id`); 5872 const container = document.getElementById(`${varid}_editContainer`); 5873 if (chkb.value == ''){ 5874 if (compulsory != '0'){ 5875 const currentLines = document.querySelectorAll(`#${varid}_editContainer > table.list2 tr:not(.napp-dataline)`); 5876 var lines = currentLines.length; 5877 const newLines = document.querySelectorAll(`#${varid}_cont > div.uploadQueue > div.uploadQueueItem`); 5878 lines += newLines.length; 5879 if (lines <= 1){ 5880 TZR.setElementErrorState(document.getElementById(`${varid}_cont`),false,color, container); 5881 return; 5882 } else { 5883 TZR.setElementErrorState(document.getElementById(`${varid}_cont`),true,color,container); 5884 } 5885 } 5886 chkb.value=1; 5887 document.getElementById(`ffdocrow${fname}${fileindex}`).className+=' napp-dataline'; 5888 }else{ 5889 chkb.value=''; 5890 document.getElementById(`ffdocrow${fname}${fileindex}`).className = document.getElementById(`ffdocrow${fname}${fileindex}`).className.replace('napp-dataline', ''); 5891 } 5892 TZR.setElementErrorState(document.getElementById(`${varid}_cont`),true,color, container); 5893}; 5894// Crée une grille d'édition pour le champ de type Table. 5895TZR.SlickGrid = function(_fieldName, _columns, _data, _options, _pluginOptions) { 5896 // deep copy des données avec jQuery.extend pour éviter de modif les objet passés en paramètre 5897 var columns = jQuery.extend(true, [], _columns); 5898 var data = jQuery.extend(true, [], _data); 5899 var options = jQuery.extend(true, {}, _options); 5900 var pluginOptions = jQuery.extend(true, {}, _pluginOptions); 5901 var fieldName = _fieldName; 5902 var idGrid = "grid_"+fieldName; 5903 var idDatas = "datas_"+fieldName; 5904 var idContextMenu = "contextMenu_"+fieldName; 5905 var lastColNumber = columns.length; 5906 var grid; 5907 5908 // Il faut au moins un container ayant pour id "grid_"+fieldName 5909 if(!jQuery("#"+idGrid).length) return; 5910 5911 if(!options.length) { 5912 // Options générales 5913 options = { 5914 editable: true, 5915 enableCellNavigation: true, 5916 autoEdit: false, 5917 autoHeight: true, 5918 forceFitColumns: true, 5919 }; 5920 } 5921 5922 if(!pluginOptions.length) { 5923 // Options du plugin pour copier/coller depuis excel 5924 pluginOptions = { 5925 includeHeaderWhenCopying : false, 5926 bodyElement : document.getElementById(idGrid) 5927 }; 5928 } 5929 5930 options.editCommandHandler = function(item, column, editCommand){ grid.undoRedoBuffer.queueAndExecuteCommand.call(grid.undoRedoBuffer,editCommand); } 5931 pluginOptions.clipboardCommandHandler = function(editCommand){ grid.undoRedoBuffer.queueAndExecuteCommand.call(grid.undoRedoBuffer,editCommand); }, 5932 5933 grid = new Slick.Grid("#"+idGrid, data, columns, options); 5934 grid.setSelectionModel(new Slick.CellSelectionModel());
5935 grid.registerPlugin(new Slick.CellExternalCopyManager(pluginOptions)); 5936 5937 // Gestion du menu contextuel 5938 grid.onContextMenu.subscribe(function (e) { 5939 if(!jQuery("#"+idContextMenu).length) return; 5940 e.preventDefault(); 5941 var cell = grid.getCellFromEvent(e); 5942 var gridelem = jQuery('#'+idGrid); 5943 var postop = gridelem.offset().top - gridelem.position().top; 5944 var posleft = gridelem.offset().left - gridelem.position().left; 5945 jQuery("#"+idContextMenu) 5946 .data("row", cell.row) 5947 .data("col", cell.cell) 5948 .css("top", e.pageY - postop) 5949 .css("left", e.pageX - posleft) 5950 .show(); 5951 jQuery("body").one("click", function () { 5952 jQuery("#"+idContextMenu).hide(); 5953 }); 5954 }); 5955 5956 // Gestion du tri 5957 grid.onSort.subscribe(function (e, args) { 5958 var field = args.sortCol.field; 5959 var sign = args.sortAsc ? 1 : -1; 5960 5961 data.sort(function (dataRow1, dataRow2) { 5962 var value1 = dataRow1[field], value2 = dataRow2[field]; 5963 return (value1 == value2 ? 0 : ((value1 > value2 ? 1 : -1) * sign)); 5964 }); 5965 5966 grid.majDatas(); 5967 }); 5968 5969 // Gestion de annuler/refaire 5970 grid.undoRedoBuffer = { 5971 commandQueue : [], 5972 commandCtr : 0, 5973 queueAndExecuteCommand : function(editCommand) { 5974 this.commandQueue[this.commandCtr] = editCommand; 5975 this.commandCtr++; 5976 editCommand.execute(); 5977 grid.majDatas(); 5978 }, 5979 undo : function() { 5980 if (this.commandCtr == 0) 5981 return; 5982 5983 this.commandCtr--; 5984 var command = this.commandQueue[this.commandCtr]; 5985 5986 if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) { 5987 command.undo(); 5988 grid.majDatas(); 5989 } 5990 }, 5991 redo : function() { 5992 if (this.commandCtr >= this.commandQueue.length) 5993 return; 5994 var command = this.commandQueue[this.commandCtr]; 5995 this.commandCtr++; 5996 if (command && Slick.GlobalEditorLock.cancelCurrentEdit()) { 5997 command.execute(); 5998 grid.majDatas(); 5999 } 6000 } 6001 } 6002 6003 // Gestion des racourcis claviers pour Annuler/Refaire et pour modifier une cellule sans avoir besoin de double cliquer 6004 jQuery("#"+idGrid).keydown(function(e) { 6005 if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) { 6006 if (e.which == 90 && (e.ctrlKey || e.metaKey) && e.shiftKey) { 6007 // Ctrl + Shift + Z ==> Refaire 6008 grid.undoRedoBuffer.redo(); 6009 } 6010 else if (e.which == 90 && (e.ctrlKey || e.metaKey)){ 6011 // Ctrl + Z ==> Annuler 6012 grid.undoRedoBuffer.undo(); 6013 } 6014 } 6015 else if(!Slick.GlobalEditorLock.isActive()) { 6016 // Si on presse une touche simple on edite la cellule en cours si on n'est pas déjà en train d'éditer 6017 grid.editActiveCell(); 6018 } 6019 }); 6020 6021 // Actions du context menu 6022 jQuery("#"+idContextMenu).click(function (e) { 6023 var col = jQuery(this).data("col"); 6024 var row = jQuery(this).data("row"); 6025 6026 switch(jQuery(e.target).attr("data")) { 6027 case "addCol" : 6028 lastColNumber++; 6029 var colToAdd = {id: "col"+lastColNumber, field: "col"+lastColNumber, editor: Slick.Editors.Text, name: ""}; 6030 columns.splice(col+1, 0, colToAdd); 6031 data.forEach(function(e){e["col"+lastColNumber]=""}); 6032 break; 6033 case "addRow" : 6034 var rowToAdd = jQuery.extend(true, {}, data[row]); 6035 for(i in rowToAdd) {rowToAdd[i] = '';} 6036 data.splice(row+1, 0, rowToAdd); 6037 break; 6038 case "delCol" : 6039 columns.splice(col, 1); 6040 break; 6041 case "delRow" : 6042 data.splice(row, 1); 6043 break; 6044 case "editCol" : 6045 return grid.editColumnName(col); 6046 break; 6047 case "undo" : 6048 grid.undoRedoBuffer.undo(); 6049 break; 6050 case "redo" : 6051 grid.undoRedoBuffer.redo(); 6052 break; 6053 default : 6054 return; 6055 } 6056 6057 grid.majDatas(); 6058 }); 6059 6060 // Modification du nom d'une colonne 6061 grid.editColumnName = function (col) { 6062 var container = jQuery("#"+idGrid+" .slick-header-column:nth-child("+(col+1)+") .slick-column-name"); 6063 var val = container.html(); 6064 container.html(''); 6065 6066 // On annule l'edit en cours et on empeche un autre edit 6067 Slick.GlobalEditorLock.cancelCurrentEdit(); 6068 Slick.GlobalEditorLock.activate(grid.getEditController()); 6069 6070 var input = jQuery("<INPUT type=text class='editor-text' />") 6071 .appendTo(container) 6072 .bind("keydown.nav", function (e) { 6073 if (e.keyCode === jQuery.ui.keyCode.ENTER) { 6074 // Quand on appuie sur entree on sauvegarde la modif 6075 e.stopPropagation(); 6076 e.preventDefault(); 6077 columns[col].name = input.val(); 6078 Slick.GlobalEditorLock.deactivate(grid.getEditController()); 6079 grid.majDatas(); 6080 } 6081 }) 6082 .val(val) 6083 .focus() 6084 .select(); 6085 6086 jQuery("body").one("click", function () { 6087 jQuery("body").one("click", function() { 6088 // Quand on clique n'importe où, on sauvegarde la modif. On ignore le prmier click qui est appellé sur le context menu. 6089 columns[col].name = input.val(); 6090 Slick.GlobalEditorLock.deactivate(grid.getEditController()); 6091 grid.majDatas(); 6092 }); 6093 }); 6094 } 6095
6096 // Création des inputs hidden pour envoi du formulaire 6097 grid.majDatas = function (init) { 6098 grid.setColumns(columns); 6099 grid.setData(data); 6100 grid.render(); 6101 6102 if(!jQuery("#"+idDatas).length) jQuery("#"+idGrid).after('<div id="'+idDatas+'"></div>'); 6103 6104 jQuery("#"+idDatas).html(''); 6105 data.forEach(function(row, i){ 6106 columns.forEach(function(col, j) { 6107 jQuery("#"+idDatas).append('<input type="hidden" name="'+fieldName+'['+i+']['+j+']" value="'+row[col.id]+'">'); 6108 }); 6109 }); 6110 columns.forEach(function(col, i) { 6111 jQuery("#"+idDatas).append('<input type="hidden" name="'+fieldName+'[_labels]['+i+']" value="'+col["name"]+'">'); 6112 }); 6113 6114 if(typeof TZR.Table != "undefined" && TZR.Table.saveSomeLangsCheckFields && !init) { 6115 TZR.Table.saveSomeLangsCheckFields(jQuery("#"+idDatas).find("input")[0]); 6116 } 6117 } 6118 6119 return grid; 6120} 6121; 6122/*/csx/src/Core/public/genericX.js*/; 6123//DEBUG 6124jQuery.ajaxSettings.cache=false; 6125 6126var click_event; 6127click_event = (jQuery.support.touch ? "tap" : "click"); 6128TZR.click_event = click_event; // = 'click'; ? 6129 6130TZR.getModuleContainer = function(id) { 6131 var module = jQuery('#cv8-uniqdiv-'+id).parents('div.cv8-module:first')[0]; 6132 return jQuery('div.cv8-module-container:first',module)[0]; 6133}; 6134// 6135 6136 6137 if (typeof(TZR.unloadMgt) == "undefined"){ 6138 TZR.unloadMgt = { 6139 containers:[], 6140 unloadMessage:(typeof(TZR._unloadMessage) != "undefined")?TZR._unloadMessage:"\\o/", 6141 registerContainer:function(id, func, divid){ 6142 if (!divid) 6143 divid = `cv8-uniqdiv-${id}`; 6144 this.containers.push({id:id,func:func,divid:divid,active:true}); 6145 }, 6146 removeRegistered:function(id){ 6147 for(var i=0; this.containers[i].id!=id && i<this.containers.length; i++){} 6148 if (i<this.containers.length){ 6149 this.containers.splice(i, 1); 6150 } 6151 }, 6152 onBeforeUnloadPage:function(evt){ 6153 if (!this.pageHasUpdates()) 6154 return null; 6155 let mess = this.unloadMessage; 6156 evt.returnValue = mess; // Gecko, Trident, Chrome 34+ 6157 return mess; // Gecko, WebKit, Chrome <34 6158 }, 6159 pageHasUpdates:function(){ 6160 let updated = false; 6161 for(let bu of this.containers){ 6162 if (!bu.active) 6163 continue; 6164 let elm = document.getElementById(bu.divid); 6165 if (elm){ 6166 updated = bu.func(bu.id); 6167 } else { 6168 bu.active = false; 6169 } 6170 } 6171 return updated; 6172 }, 6173 containerHasUpdates:function(uniqid){ 6174 let updated = false; 6175 for(let bu of this.containers){ 6176 if (!bu.active) 6177 continue; 6178 if (bu.id === uniqid){ 6179 let elm = document.getElementById(bu.divid); 6180 if (elm) 6181 updated = bu.func(); 6182 break; 6183 } 6184 } 6185 return updated; 6186 }, 6187 checkoutPageUnload:function(){ 6188 if (!this.pageHasUpdates()) 6189 return true; 6190 else 6191 return confirm(this.unloadMessage); 6192 }, 6193 checkoutContainerUnload:function(uniqid){ 6194 if (!this.containerHasUpdates(uniqid)) 6195 return true; 6196 else 6197 return confirm(this.unloadMessage); 6198 } 6199 }; 6200 TZR.onBeforeUnloadPage = function(evt){ 6201 return TZR.unloadMgt.onBeforeUnloadPage.call(TZR.unloadMgt, evt); 6202 }; 6203 window.addEventListener('beforeunload', TZR.onBeforeUnloadPage); 6204 } 6205 6206 6207 6208//Tooltips and popovers 6209// ===================== 6210TZR.initToolsTipsAndPopOvers = function(){ 6211 if(jQuery('[data-toggle="tooltip"]').tooltip) { 6212 jQuery('[data-toggle="tooltip"]').tooltip(); 6213 } 6214 if(jQuery('[data-toggle="popover"]').popover) { 6215 jQuery('[data-toggle="popover"]').popover(); 6216 } 6217} 6218// ===================== 6219// -Menu 6220// ===================== 6221TZR.Menu = new Object(); 6222TZR.Menu.load = function(obj,force) { 6223 if (force === undefined){ 6224 force=false; 6225 } 6226 var $this = $(obj); 6227 var target = $this.attr("data-target"); 6228 if ($(target).children().length > 0 && !force) { 6229 return false; 6230 } 6231 TZR.jQueryLoad({url:$this.attr("data-url"), target:target, overlay:$this.attr("data-overlay")}); 6232 return true; 6233}; 6234TZR.Menu.inlineTreeRelocate = function(target,responseText,textStatus,XMLHttpRequest){ 6235 $(target).after(responseText); 6236 $(target).empty(); 6237}; 6238TZR.Menu.inlineTreeLoad = function(obj) { 6239 var $this = $(obj); 6240 var target = $this.attr("data-target"); 6241 var callback = $this.attr("data-cb") ? $this.attr("data-cb") : "TZR.Menu.inlineTreeRelocate"; 6242 var callbackArgs = $this.attr("data-cbargs") ? $this.attr("data-cbargs") : target; 6243 TZR.jQueryLoad({url:$this.attr("data-url"), target:target, overlay:$this.attr("data-overlay"), cb:callback, cb_args:callbackArgs}); 6244}; 6245jQuery(document).ready(function($) { 6246 // MENU 6247 $("#main-nav").on(click_event, ".treeMenuAjax", function(e) { 6248 return TZR.Menu.load(this); 6249 }); 6250 $("#main-nav .inlineTreeMenuAjax").each(function(e) {
6251 TZR.Menu.inlineTreeLoad(this); 6252 }); 6253 var body, content, nav, nav_toggler; 6254 nav_toggler = $("header .toggle-nav"); 6255 nav = $("#main-nav"); 6256 content = $("#content"); 6257 body = $("body"); 6258 6259 $("#main-nav").on(click_event, ".dropdown-collapse", function(e) { 6260 var link, childrenList; 6261 e.preventDefault(); 6262 link = $(this); 6263 childrenList = link.closest("li").children("ul:first"); 6264 parentLink = link.closest("ul").closest("li").children("a:first"); 6265 6266 //lien final: fermer tous les autres dropdown (limite: menu à 2 niveaux) 6267 if (childrenList.length == 0) { 6268 $("#main-nav").find('a.active').removeClass('active'); 6269 $("#main-nav .dropdown-collapse.in").each(function() { 6270 if (link[0] == $(this)[0] || parentLink[0] == $(this)[0]) 6271 return; 6272 var openedList = $(this).closest("li").children("ul:first"); 6273 if (openedList.length == 0) 6274 return; 6275 $(this).removeClass("in"); 6276 openedList.slideUp(300); 6277 }); 6278 link.addClass("active"); 6279 return; 6280 } 6281 //dropdown ouverte 6282 if (childrenList.is(":visible")) { 6283 if (body.hasClass("main-nav-closed") && link.parents("li").length === 1) { 6284 return false; 6285 } else { 6286 link.removeClass("in"); 6287 link.removeClass("active"); 6288 childrenList.slideUp(300); 6289 } 6290 } 6291 //dropdown fermée 6292 else { 6293 if (childrenList.parents("ul.nav.nav-stacked").length === 1) { 6294 $(document).trigger("nav-open"); 6295 } 6296 $("#main-nav").find('a.active').removeClass('active'); 6297 link.addClass("in"); 6298 link.addClass("active"); 6299 childrenList.slideDown(300); 6300 } 6301 return false; 6302 }); 6303 if (jQuery.support.touch) { 6304 nav.on("swiperight", function(e) { 6305 return $(document).trigger("nav-open"); 6306 }); 6307 nav.on("swipeleft", function(e) { 6308 return $(document).trigger("nav-close"); 6309 }); 6310 } 6311 nav_toggler.on(click_event, function() { 6312 if (nav_open()) { 6313 $(document).trigger("nav-close"); 6314 } else { 6315 $(document).trigger("nav-open"); 6316 } 6317 return false; 6318 }); 6319 $(document).bind("nav-close", function(event, params) { 6320 var nav_open; 6321 body.removeClass("main-nav-opened").addClass("main-nav-closed"); 6322 return nav_open = false; 6323 }); 6324 $(document).bind("nav-open", function(event, params) { 6325 var nav_open; 6326 body.addClass("main-nav-opened").removeClass("main-nav-closed"); 6327 return nav_open = true; 6328 }); 6329 6330 function nav_open() { 6331 return $("body").hasClass("main-nav-opened") || $("#main-nav").width() > 50; 6332 }; 6333 6334 6335 // -ToolbarX 6336 $('#content-wrapper').on(click_event,'div.toolbar-nav .btn', function(obj) { 6337 var $this = $(obj.currentTarget); 6338 if ($this.attr("data-url") == undefined) return; 6339 TZR.jQueryLoad({url:$this.attr("data-url"), cb:$this.attr("data-cb")}); 6340 }); 6341 6342 // ===================== 6343 $('#content-wrapper').on(click_event,'[data-toggle="tabajax"]', function(e) { 6344 TZR.Tabs.load($(this)); 6345 }); 6346 6347 6348 //Tooltips and popovers 6349 // ===================== 6350 TZR.initToolsTipsAndPopOvers(); 6351}); 6352 6353//===================== 6354// 6355//===================== 6356// Ajoute un item à un menu 6357TZR.toolBarX = {}; 6358TZR.toolBarX.initMenu = function(menubarid){ 6359 jQuery('#'+menubarid+' .btn-group.btn-group-dropdown-menu').each(function(i,o) { 6360 // groupe seul 6361 if (jQuery("ul.dropdown-menu li", o).length == 0) { 6362 jQuery(o).remove(); 6363 } 6364 // groupe composé 6365 jQuery("ul.btn-group-ul>li", o).each(function(i, o){ 6366 if (jQuery("ul.dropdown-menu li", o).length == 0) { 6367 jQuery(o).remove(); 6368 } 6369 }); 6370 }); 6371}; 6372TZR.toolBarX.addMenuItem=function(mid,group,text,url,conf,newgroup,separator,target,shortkey){ 6373 var datashortkey = ''; 6374 if (!shortkey){ 6375 datashortkey = shortkey = ''; 6376 } else { 6377 datashortkey = 'data-shortkey="'+shortkey+'"'; 6378 shortkey = ' ('+shortkey+')'; 6379 } 6380 var li='<li'; 6381 var _class=""; 6382 // a voir ... cf en dessous 6383 if(separator) _class+=' jd_separator'; 6384 if(_class!="") li+=' class="'+_class.substr(1)+'"'; 6385 if(url=='#' && newgroup != undefined) { 6386 li+=' id="'+mid+'-'+newgroup+'" class="dropdown-header" '; 6387 } 6388 li+='>'; 6389 // Echappe la confirmation 6390 if(conf) conf=conf.replace(/\'/g,'\\\'').replace(/\"/g,'"'); 6391 // Creation du lien 6392 if(url==undefined){ 6393 li+=text; 6394 }else if(url=='#' || newgroup){ 6395 li+='<span>'+text+'</span>'; 6396 }else if(url.substr(0,11)=='javascript:'){ 6397 url=url.replace("javascript:","").replace(/\"/g,'"'); 6398 li+='<a '+datashortkey+' class="accessible" href="#" onclick="'+(conf?'if(!confirm(\''+conf+'\')) return false;':'')+url+'return false;">'+text+'</a>'; 6399 }else{ 6400 li+='<a'+datashortkey+' '+(target?' target="'+target+'"':'')+' class="'+(target?'':'accessible cv8-ajaxlink')+'" href="'+url+'"'+(conf?' x-confirm="var ret=confirm(\''+conf+'\')"':'')+'> '+text+'</a>'; 6401 } 6402 li+='</li>'; 6403 var p = jQuery('#'+mid+'-'+group); 6404 if (p.is('ul')){ 6405 jQuery(p).append(li); 6406 } else { 6407 jQuery(li).insertAfter(p).addClass('cs-menu-subitem'); 6408 } 6409}; 6410TZR.toolBarX.addToolBarItem=function(tid,group,order,picto, shortkey){ 6411 var datashortkey = ''; 6412 if (!shortkey){ 6413 datashortkey = shortkey = ''; 6414 } else { 6415 datashortkey = 'data-shortkey="'+shortkey+'"'; 6416 shortkey = ' ('+shortkey+')'; 6417 } 6418 if(document.getElementById(tid+'-'+group)==undefined){ 6419 jQuery('#'+tid).append('<div class="btn-group" role="group" id="'+tid+'-'+group+'"></div>'); 6420 }else{ 6421 jQuery('#'+tid+'-'+group).show(); 6422 } 6423 var li=picto; 6424 var added=false; 6425 var jul=jQuery('#'+tid+'-'+group); 6426 jul.find('button').each(function(){ 6427 var that = jQuery(this); 6428 if(parseInt(that.attr('morder'))>order){ 6429 that.before(li); 6430 added=true; 6431 return false;
6432 } 6433 }); 6434 if(!added) jul.append(li); 6435}; 6436//====================== 6437//Tabs 6438//====================== 6439TZR.Tabs = new Object(); 6440TZR.Tabs.showTab = function($anchor){ 6441 $anchor.tab('show'); 6442}; 6443TZR.Tabs.loadBy = function(uniqid, selector, options){ 6444 var anchor = null; 6445 if (typeof(selector) == "string" && !(/^[0-9]+$/.test(selector))){ 6446 var anchor = jQuery("#tzr-tablist-"+uniqid+" a[data-tabname='"+selector+"']"); 6447 } else { 6448 var anchor = jQuery("#tzr-tablist-"+uniqid+">ul>li:nth-child("+selector+")>a"); 6449 } 6450 if (anchor && anchor.length){ 6451 TZR.Tabs.load(anchor, options); 6452 } 6453}; 6454TZR.Tabs.load = function($anchor, options){ 6455 options = jQuery.extend({refresh:false,cb:null,cbargs:null}, options); 6456 var target = $anchor.attr("href"); 6457 if (!options.refresh && $(target).children().length > 0 ) { 6458 $anchor.tab('show'); 6459 return; 6460 } 6461 var callback = TZR.Tabs.showTab; 6462 var callbackArgs = $anchor; 6463 if ($anchor.attr("data-cb")) 6464 callback = $anchor.attr("data-cb"); 6465 if ($anchor.attr("data-cbargs")) 6466 callbackArgs = $anchor.attr("data-cbargs"); 6467 if (options.cb !== null) 6468 callback = options.cb; 6469 if (options.cbargs !== null) 6470 callbackArgs = options.cbargs; 6471 6472 TZR.jQueryLoad({url:$anchor.attr("data-url"), 6473 target:target, 6474 overlay:$anchor.attr("data-overlay"), 6475 cb:callback, 6476 cb_args:callbackArgs}); 6477 //cb: add tooltips? 6478}; 6479TZR.Tabs.refreshTitle = function(tabid, title){ 6480 jQuery("a[href='#"+tabid+"']").text(title); 6481}; 6482TZR.Tabs.activeTabUrl = function($anchor){ 6483 return "_tabs="+escape(this.activeTag($anchor).data("tabname")); 6484}; 6485TZR.Tabs.activeTag = function($anchor){ 6486 return jQuery("ul>li.active>a", $anchor); 6487}; 6488//Locales / labels en js 6489TZR.Locales = {}; 6490TZR.Locales.labels = {}; 6491TZR.Locales.addLabels = function(labels){ 6492 for(var i=0; i<labels.length; i++){ 6493 this.labels[labels[i][0]+'.'+labels[i][1]]=labels[i][2]; 6494 } 6495}; 6496TZR.Locales.getLabel = function(name, lang){ 6497 if (!lang) 6498 lang = TZR._lang_user; 6499 if (typeof(this.labels[lang+'.'+name]) != "undefined"){ 6500 return this.labels[lang+'.'+name]; 6501 } else { 6502 return name; 6503 } 6504}; 6505 6506//DateRangePicker requires bootstrap daterangepicker 6507// ===================== 6508try{ 6509 if (typeof(BSdaterangepicker_locale) == 'undefined') 6510 BSdaterangepicker_locale = {}; 6511}catch(e){} 6512TZR.Daterangepicker = {locales:{},localoptions:{}}; 6513TZR.Daterangepicker.getInterVal = function(picker){ 6514 var fmt = picker.locale.format; 6515 return picker.startDate.format(fmt)+picker.locale.separator+picker.endDate.format(fmt); 6516}; 6517TZR.Daterangepicker.apply = function(elm, ev, picker){ 6518 jQuery(elm).val(this.getInterVal(picker)); 6519} 6520TZR.Daterangepicker.cancel = function(elm, ev, picker){ 6521 jQuery(elm).val(''); 6522} 6523TZR.Daterangepicker.init = function(elem, config) { 6524 if (!jQuery().daterangepicker) { 6525 console.log("missing daterangepicker!"); 6526 return; 6527 } 6528 if (config){ 6529 if (typeof(config.localoptions) == "string" && typeof(this.localoptions[config.localoptions])!="undefined"){ 6530 config = Object.assign(config, this.localoptions[config.localoptions]); 6531 } 6532 jQuery(elem).daterangepicker(config); 6533 elem.on('apply.daterangepicker', function(ev, picker){ 6534 TZR.Daterangepicker.apply.call(TZR.Daterangepicker, this, ev, picker) 6535 }); 6536 elem.on('cancel.daterangepicker', function(ev, picker){ 6537 TZR.Daterangepicker.cancel.call(TZR.Daterangepicker, this, ev, picker) 6538 }); 6539 } else { 6540 jQuery(elem).daterangepicker(BSdaterangepicker_locale); 6541 } 6542}; 6543 6544//========================================== 6545// Login, access control, "redirection" ajax 6546//========================================== 6547// gestion des redirections (ex : liens voir une fiche de la fonction avertir / envoyer à , quand on a &gopage dans l'url 6548TZR.handleRequestedPage = function(){ 6549 if (TZR._request.gopage != null && !top.location.hash){ 6550 TZR.jQueryLoad({target:'#cv8-content',url:TZR._request.gopage}); 6551 } 6552 /* bloc original à voir dans : a5a7644319f42392c3e643b745f6e85188cf47e9 et generic8.html de v8 6553 <%if $xuser->_cur.bohome%> 6554 if(!top.location.hash) home_viewpage('<%$xuser->_cur.bohome%>'); 6555 <%/if%> 6556 */ 6557}; 6558// refresh global variables and topbar elements 6559TZR.authReconnect = function(){ 6560 jQuery.get(TZR._self, 6561 {"skip":1, 6562 "_mime":"application/json", 6563 "_ajax":1, 6564 "function":"portail", 6565 "template":"Core.layout/top/reconnexion.json", 6566 "moid":TZR._sysmods_xmodadmin}, 6567 TZR.refreshConnexion,
6568 "json"); 6569}; 6570TZR.refreshConnexion = function(data, status){ 6571 if (typeof data._infotreeadmin_sec != "undefined"){ 6572 TZR._infotreeadmin_sec = data._infotreeadmin_sec; 6573 } 6574 if (typeof data.profile != "undefined"){ 6575 jQuery("#cvx-user-profile").html(data.profile); 6576 } 6577}; 6578// redirection CAS (en cas de perte de session, ? pack) 6579TZR.AuthCAS = { 6580 authAlert:function(options,cb){ 6581 document.location=options.url; 6582 } 6583}; 6584// popup login/password for reconnexion 6585TZR.authAlert = function(cb){ 6586 if (TZR._authMngt != null){ 6587 TZR.executeFunctionByName(TZR._authMngt+".authAlert", window, TZR._authMngtOptions, cb) 6588 return; 6589 } 6590 var alertArgs = Array.from(arguments); 6591 alertArgs.shift(); 6592 var authModal = jQuery("#cvx-auth"); 6593 /* suppress previously registerer handlers - case 'goto page' for instance */ 6594 authModal.off('hidden.bs.modal'); 6595 /* process initial action on modal hide */ 6596 authModal.on('hidden.bs.modal', function () { 6597 if(authModal.data('callcb') && cb){ 6598 var args = alertArgs; 6599 cb.apply(TZR,args); 6600 } 6601 authModal.data('callcb',false); 6602 }); 6603 authModal.modal('show'); 6604}; 6605// login form submission, console reconnexion, interrupted action continuation (on modal hide) 6606TZR.submitLogin=function(form){ 6607 jQuery.post(form.action,jQuery(form).serializeArray(),function(data,status){ 6608 if(data=='ok'){ 6609 jQuery("#cvx-auth-error").css('visibility','hidden'); 6610 TZR.authReconnect(); 6611 jQuery("#cvx-auth").data('callcb',true); 6612 jQuery("#cvx-auth").modal('hide'); 6613 }else{ 6614 var errmess = jQuery("#cvx-auth-error"); 6615 var res = /nok\[\[(.+)\]\]/.exec(data); 6616 if (res != null && res[1]){ 6617 errmess.html(res[1]).css('visibility','visible'); 6618 } else { 6619 errmess.html(errmess.data('default')).css('visibility','visible'); 6620 } 6621 } 6622 }); 6623}; 6624//============================ 6625// Doubles selects, compléments 6626// la reste est dans TZR.doubleAdd etc 6627//============================ 6628TZR.DoubleBox = { 6629 initFilter : function(elm){ 6630 elm.on('change keyup search',function(evt) { 6631 TZR.DoubleBox.filter.call(TZR.DoubleBox, jQuery(this), evt); 6632 }); 6633 }, 6634 filter : function(src, evt){ 6635 var select = jQuery(src.data("doublebox-selector"),src.parents("table.doublebox")); 6636 var text = src.val().toLowerCase(); 6637 var exp = new RegExp(text,'i'); 6638 select.find("option").hide().filter(function(){ 6639 var opt = jQuery(this); 6640 return (exp.test(opt.val()) || exp.test(opt.html())) 6641 }).show(); 6642 } 6643}; 6644//================= 6645//Liens en treeview 6646//================= 6647if (typeof(TZR.xlinkdef_treeview) == "undefined"){ 6648 TZR.xlinkdef_treeview = { 6649 init:function(selector, namefield, selected, selectedLabels, maxdepth, options){ 6650 var container = jQuery(selector); 6651 var that=this; 6652 container.addClass("xlinkdef_treeview"); 6653 container.data("selected", []); 6654 container.data("namefield", namefield); 6655 container.data("list", container.prev()); 6656 container.data("maxdepth", maxdepth); 6657 container.data("options", options); 6658 for(i in selected){ 6659 this.addSelected(selected[i], selectedLabels[i], container); 6660 } 6661 container.simpleTree({ 6662 autoclose:false, 6663 drag:false, 6664 animate:true, 6665 closeroot:true, 6666 afterClick:function(node){ 6667 that.afterClick.call(that, node, container); 6668 }, 6669 afterAjax:function(node){ 6670 that.afterAjax.call(that, node, container); 6671 } 6672 }); 6673 }, 6674 unselectItem:function(item){ 6675 var container = item.parent().next(); 6676 var data = item.data(); 6677 this.deleteItem(data.oid, container); 6678 }, 6679 deleteItem:function(oid, container){ 6680 var selected = container.data('selected'); 6681 selected.splice(selected.indexOf(oid), 1); 6682 jQuery('li[data-value="'+oid+'"] span>span', container).removeClass('selected'); 6683 jQuery('input[value="'+oid+'"]', container).remove(); 6684 jQuery('div[data-oid="'+oid+'"]', container.data('list')).remove(); 6685 container.data('selected', selected); 6686 }, 6687 prepareAdd:function(container){ 6688 var options = container.data("options"); 6689 if (options.multivalued != "1"){ 6690 container.data("selected").map((oid)=>{ 6691 this.deleteItem(oid, container); 6692 }); 6693 } 6694 }, 6695 addSelectedFromAutoCompletion:function(oid, label, container){ 6696 if (!this.isSelectedOid(oid, container)){ 6697 this.addSelected(oid, label, container); 6698 } 6699 }, 6700 addSelected:function(oid, label, container){ 6701 this.prepareAdd(container); 6702 var button=" <button onclick=\"TZR.xlinkdef_treeview.unselectItem.call(TZR.xlinkdef_treeview, jQuery(this).parent());\" class=\"btn btn-default btn-md btn-inverse\" type=\"button\"><span class=\"glyphicon csico-delete\" aria-hidden=\"true\"></span></button>";
6703 var input = TZR.sprintf("<input name=\"%s[]\" type=\"hidden\" value=\"%s\">", container.data('namefield'), oid); 6704 jQuery(container.data('list')).append(TZR.sprintf("<div data-oid=\"%s\">%s %s %s</div>", oid, button, label, input)); 6705 container.data('selected').push(oid); 6706 jQuery('li[data-value="'+oid+'"] span>span', container).addClass('selected'); 6707 }, 6708 afterAjax:function(node, container){ 6709 var selected = container.data('selected'); 6710 jQuery("span:first span:first", node.parent()).addClass("hselected"); 6711 jQuery('li[data-type="leaf"]', node).each(function(i, o){ 6712 var oid = jQuery(o).data('value'); 6713 var li = jQuery(this); 6714 if (selected.indexOf(oid)!=-1){ 6715 jQuery("span:first span:first", li).addClass("selected"); 6716 } 6717 }); 6718 var pli = node.parent(); 6719 if (!pli.hasClass("folder-loaded")) 6720 pli.addClass('folder-loaded'); 6721 }, 6722 afterClick:function(node,container){ 6723 var span = jQuery("span:first span:first",node); 6724 if (node.data("type") == "leaf"){ 6725 if (!this.isSelected(node, container)){ 6726 this.addSelected(node.data('value'), span.html(), container); 6727 } else { 6728 this.deleteItem(node.data("value"), container); 6729 } 6730 } else { 6731 if (!node.hasClass("folder-loaded")){ 6732 node.addClass('folder-loaded'); 6733 var that = this; 6734 setTimeout(function(){ 6735 jQuery("img.trigger", node).trigger('click'); 6736 }, 100); 6737 } else { 6738 var that = this; 6739 if (node.data("level") < container.data("maxdepth")){ 6740 jQuery("img.trigger:first", node).trigger("click"); 6741 } else if ((node.hasClass('folder-close') || node.hasClass('folder-last'))&& node.hasClass('folder-loaded')){ 6742 jQuery("img.trigger:first", node).trigger("click"); 6743 } else { 6744 jQuery("span:first span:first", node).toggleClass('folder-selected'); 6745 var sel = jQuery("span:first span:first", node).hasClass('folder-selected'); 6746 jQuery('ul>li[data-type="leaf"]', node).each(function(i, o){ 6747 var li = jQuery(o); 6748 if (sel && !that.isSelected(li, container)){ 6749 that.addSelected(li.data('value'), li.find("span:first span:first").html(), container); 6750 } else { 6751 that.deleteItem(li.data('value'), container); 6752 } 6753 }); 6754 } 6755 } 6756 } 6757 }, 6758 isSelectedOid(oid, container){ 6759 return container.data('selected').indexOf(oid) !== -1; 6760 }, 6761 isSelected(leaf, container){ 6762 return this.isSelectedOid(leaf.data('value'), container); 6763 }, 6764 isValid:function(id, fmt, color){ 6765 var container = jQuery(`#${id}tree`); 6766 var selected = container.data("selected").join(); 6767 var exp = new RegExp(fmt); 6768 if (!exp.test(selected)){ 6769 TZR.setElementErrorState(jQuery(container).parent(),false,color); 6770 TZR.isFormOk = false; 6771 return false; 6772 } 6773 return true; 6774 }, 6775 getFormInput:function(id){ 6776 var container = jQuery(`#${id}tree`); 6777 var fieldname = container.data('namefield') 6778 var o = jQuery(`#${id}selected>input[name="${fieldname}"]`); 6779 return o[0]; // native element 6780 }, 6781 addAutoComplete:function(varid){ 6782 TZR.addAutoComplete(varid); 6783 }, 6784 autoComplete:function(fromvarid, oid, label){ 6785 var datatree = jQuery(`#${fromvarid}`).data("tree"); 6786 var container = jQuery(`#${datatree.varid}`); 6787 TZR.xlinkdef_treeview.addSelectedFromAutoCompletion.call(TZR.xlinkdef_treeview, 6788 oid, 6789 label, 6790 container); 6791 } 6792 }; 6793}; 6794 6795//================= 6796// miscellaneous 6797//================= 6798TZR.copy2clipboard = function(text, mess=false, addanchor=true){ 6799 try{ 6800 var el = jQuery('<input style="position:absolute;">'); 6801 if (addanchor){ 6802 el.val('<a href="'+text+'">Document</a>').appendTo('body').select(); 6803 } else { 6804 el.val(text).appendTo('body').select(); 6805 } 6806 document.execCommand("copy"); 6807 el.remove(); 6808 if (mess){ 6809 const closeb = this.Locales.getLabel("Seolan_Core_General.close"); 6810 TZR.Dialog.show(`<div class="title">${mess}</div> 6811 <div>${text}</div> 6812 <div class="tzr-action"> 6813 <button class="btn bt-default cvx-cancel" type="button" data-dismiss="modal">${closeb}</button></div> 6814 `); 6815 } 6816 }catch(e){ 6817 } 6818} 6819 6820TZR.copyHTML2Clipboard = function(html, el) { 6821 var tmpEl; 6822 if (typeof el !== "undefined") { 6823 // you may want some specific styling for your content - then provide a custom DOM node with classes, inline styles or whatever you want 6824 tmpEl = el; 6825 } else { 6826 // else we'll just create one 6827 tmpEl = document.createElement("div"); 6828 6829 // since we remove the element immedeately we'd actually not have to style it - but IE 11 prompts us to confirm the clipboard interaction and until you click the confirm button, the element would show. so: still extra stuff for IE, as usual. 6830/* tmpEl.style.opacity = 0; 6831 tmpEl.style.position = "absolute"; 6832 tmpEl.style.pointerEvents = "none"; 6833 tmpEl.style.zIndex = -1;*/ 6834 } 6835 6836 // fill it with your HTML 6837 tmpEl.innerHTML = html; 6838 6839 // append the temporary node to the DOM 6840 document.body.appendChild(tmpEl); 6841
6842 // select the newly added node 6843 var range = document.createRange(); 6844 range.selectNode(tmpEl); 6845 window.getSelection().addRange(range); 6846 6847 // copy 6848 document.execCommand("copy"); 6849 6850 // and remove the element immediately 6851 document.body.removeChild(tmpEl); 6852 6853 alert("Copie terminée"); 6854} 6855 6856 6857 6858TZR.updateModulePath = function(id, paths, options){ 6859 options = jQuery.extend({}, {full:false}, options); 6860 var container = jQuery("#chemin"+id+">ol"); 6861 if (options.full){ 6862 container.html(""); 6863 } else { 6864 var lang = jQuery(">li", container).filter(':nth-child(1)').clone(); 6865 var module = jQuery(">li", container).filter(':nth-child(2)').clone(); 6866 container.html(""); 6867 container.append(lang); 6868 container.append(module); 6869 } 6870 for(var i=0; i<paths.length; i++){ 6871 container.append("<li>"+paths[i]+"</li>"); 6872 } 6873}; 6874TZR.applyFunction=function(form,data,selectonly,conf,popup){ 6875 if(typeof(form)=="string") form=document.forms[form]; 6876 if(selectonly){ 6877 if(!TZR.checkBoxesIsChecked(form, false, false, /_selected\[/)){ 6878 TZR.alert(TZR._noobjectselected, ''); 6879 return; 6880 } 6881 } 6882 if(conf){ 6883 if(!confirm(conf)) return false; 6884 } 6885 if(data){ 6886 for(var attr in data){ 6887 if(form[attr]) form[attr].value=data[attr]; 6888 else jQuery(form).append('<input type="hidden" name="'+attr+'" value="'+data[attr]+'">'); 6889 } 6890 } 6891 if (popup != undefined && typeof popup == 'object' && popup.dialog == true){ 6892 TZR.Dialog.openFromForm(form, data, popup.options /* id et options */); 6893 }else if(popup){
6894 window.open('','tzrpopup','width=650,height=550,scrollbars=yes,location=no,resizable=yes'); 6895 form.target='tzrpopup'; 6896 form.method='post'; 6897 return form.submit(); 6898 }else{ 6899 return TZR.ajaxSubmitForm(form); 6900 } 6901} 6902//================= 6903// Modals & Dialogs 6904//================= 6905TZR.Dialog = { 6906 modalId:"#cs-default-dialog", 6907 currentId:function(){ 6908 return jQuery(this.modalId).data('id'); 6909 }, 6910 getContents:function(url, data, options){ 6911 options = jQuery.extend({overlay:null}, options); 6912 if (options.overlay == "auto") 6913 options.overlay = this.modalId+" .modal-content"; 6914 url += "&_dialogid="+options.id; 6915 TZR.jQueryAjax({ 6916 url:url, 6917 data:data, 6918 mode:'post', 6919 nocache:true, 6920 noautoscroll : true, 6921 overlay:options.overlay, 6922 cb:function(html, status, xhr){ 6923 // context = TZR.Dialog 6924 this.show(html, options); 6925 }, 6926 cb_context:TZR.Dialog 6927 }); 6928 }, 6929 hideActions:function(){ 6930 jQuery(this.modalId+" div.modal-footer>div.tzr-action").hide(); 6931 }, 6932 showActions:function(){ 6933 jQuery(this.modalId+" div.modal-footer>div.tzr-action").show(); 6934 }, 6935 setTitle:function(elm, titleElm){ 6936 var newTitle = jQuery("div.title", elm).detach(); 6937 titleElm.html(newTitle.html()); 6938 }, 6939 changeTitle:function(title){
6940 var titleElm = jQuery(".modal-header>h4", jQuery(this.modalId)); 6941 titleElm.html(title); 6942 }, 6943 setFooter:function(elm, footerElm){ 6944 var newActions = jQuery("div.tzr-action", elm).detach(); 6945 footerElm.append(newActions); 6946 }, 6947 getOptions:function(){ 6948 return jQuery(this.modalId).data('_options'); 6949 }, 6950 show:function(html, options){ 6951 6952 options = jQuery.extend({sizeClass:'modal-lg', initCallback:null, closeCallback:null, backdrop:'static', allowMove:true}, options); 6953 6954 var elm = jQuery(this.modalId); 6955 6956 elm.data('id', options.id); 6957 elm.data('_options', options); 6958 6959 //reset des classes à la valeur par defaut, modal-lg modal-sm modal-md 6960 jQuery('div.modal-dialog', elm).attr("class", "modal-dialog"); 6961 jQuery('div.modal-dialog', elm).addClass(options.sizeClass); 6962 6963 // les containers 6964 var bodyElm = jQuery("div.modal-body", elm); 6965 var titleElm = jQuery(".modal-header>h4", elm); 6966 var footerElm = jQuery(".modal-footer", elm); 6967 6968 bodyElm.html(''); 6969 titleElm.html(''); 6970 footerElm.html(''); 6971 6972 // le body 6973 bodyElm.html(html); 6974 // initialisation des contenus 6975 if (options.initCallback != null){ 6976 if (typeof(options.initCallback) == "function"){ 6977 options.initCallback(); 6978 } else { 6979 TZR.executeFunctionByName(options.initCallback._function, window, [options.initCallback._param]); 6980 } 6981 } 6982 6983 this.setTitle(elm, titleElm); 6984 6985 this.setFooter(elm, footerElm); 6986 6987 elm.modal({backdrop:options.backdrop,show:true}); 6988 6989 elm.off('hide.bs.modal', TZR.Dialog.onClose); 6990 if (options.closeCallback != null){ 6991 elm.on('hide.bs.modal', {closeCallback:options.closeCallback}, TZR.Dialog.onClose); 6992 } else { 6993 elm.on('hide.bs.modal', {closeCallback:null}, TZR.Dialog.onClose); 6994 } 6995 6996 elm.modal('show'); 6997 6998 if (options.allowMove){
6999 jQuery(".modal-header", elm).css('cursor','move'); 7000 elm.draggable({handle: "div.modal-header"}); 7001 } 7002 7003 }, 7004 openFromAnchor:function(srcElm){ 7005 var elm = jQuery(srcElm); 7006 var url = elm.data("url"); 7007 var options = elm.data("options"); 7008 var data = elm.data("parameters"); 7009 return this.openURL(url, data, options); 7010 }, 7011 openURL:function(url, data, options){ 7012 data = jQuery.extend({}, data); 7013 options = jQuery.extend({}, options); 7014 this.getContents(url, data, options); 7015 return false; 7016 }, 7017 openFromForm:function(form, data, options){ 7018 data = jQuery.extend({}, data); 7019 options = jQuery.extend({}, options); 7020 var jform = jQuery(form); 7021 var formValues = jform.serializeArray(); 7022 for(var i in formValues){ 7023 var pn = formValues[i]["name"]; 7024 if (typeof(data[pn]) != "undefined"){ 7025 formValues[i]["value"] = data[pn]; 7026 } 7027 // ? ajouter les autres paramètres ? 7028 } 7029 this.getContents(TZR._self, formValues, options); 7030 }, 7031 closeDialog:function(){ 7032 jQuery(this.modalId).modal('hide'); 7033 }, 7034 onClose:function(event){ 7035 if (typeof event.data != "undefined" && typeof event.data.closeCallback != "undefined" && event.data.closeCallback != null){ 7036 if (typeof event.data.closeCallback == 'function') 7037 event.data.closeCallback(event.data.closeCallback._param); 7038 else 7039 TZR.executeFunctionByName(event.data.closeCallback._function, window, [event.data.closeCallback._param]); 7040 } 7041 // permettre le garbage TZR sur id du container : on vide 7042 var elm = jQuery(TZR.Dialog.modalId); 7043 jQuery("div.modal-body", elm).html(''); 7044 }, 7045 setData:function(data){ 7046 jQuery(this.modalId).data(data); 7047 }, 7048 getData:function(){ 7049 return jQuery(this.modalId).data(); 7050 } 7051}; 7052TZR.Modal = { 7053 dismissAll:function() { 7054 //seul le hash de la selection apparait et permet d'implémenter le forward 7055 if (top.location.hash != TZR.Modal.alert.elem) 7056 jQuery(TZR.Modal.alert.elem).modal('hide'); 7057 else 7058 jQuery(TZR.Modal.alert.elem).modal('show'); 7059 if (top.location.hash != TZR.Modal.confirm_delete.elem) 7060 jQuery(TZR.Modal.confirm_delete.elem).modal('hide'); 7061 else 7062 jQuery(TZR.Modal.confirm_delete.elem).modal('show'); 7063 if (top.location.hash != TZR.Modal.auth.elem) 7064 jQuery(TZR.Modal.auth.elem).modal('hide'); 7065 else 7066 jQuery(TZR.Modal.auth.elem).modal('show'); 7067 if (top.location.hash != TZR.SELECTION.Modal.elem) 7068 jQuery(TZR.SELECTION.Modal.elem).modal('hide'); 7069 else 7070 jQuery(TZR.SELECTION.Modal.elem).modal('show'); 7071 if (top.location.hash.slice(0, TZR.Modal.selectedFields.startId.length) != TZR.Modal.selectedFields.startId) 7072 jQuery(TZR.Modal.selectedFields.elem).modal('hide'); 7073 else 7074 jQuery(TZR.Modal.selectedFields.elem).modal('show'); 7075 }, 7076 config:function(modalId,action,args,title,message) { 7077 var m = jQuery('#'+modalId); 7078 // reset functionnal class (modal-export for instance) 7079 jQuery('div.modal-dialog', m).attr("class", "modal-dialog"); 7080 m.find('.modal-footer .cvx-confirm').data('args', args); 7081 m.find('.modal-footer .cvx-confirm').data('action', action); 7082 if (title) 7083 m.find('.modal-title').text(title); 7084 else 7085 m.find('.modal-title').text(''); 7086 if (message){ 7087 if (m.find('.modal-body p').length>0){ 7088 if (m.find('.modal-body p').length>1){ 7089 m.find('.modal-body').html("<p></p>"); 7090 } 7091 m.find('.modal-body p').html(message); 7092 } else { 7093 m.find('.modal-body').html(message); 7094 } 7095 } 7096 }, 7097 show:function(e, modal) { 7098 TZR.Modal.relatedTarget = null; 7099 var modalId = jQuery(modal).attr("id"); 7100 var relatedTarget = jQuery(e.relatedTarget); 7101 if (relatedTarget != undefined && relatedTarget.data('action') != undefined) { 7102 var message = relatedTarget.data('message'); 7103 var title = relatedTarget.data('title'); 7104 var args = relatedTarget.data('args'); 7105 var action = relatedTarget.data('action'); 7106 TZR.Modal.config(modalId,action,args,title,message); 7107 TZR.Modal.relatedTarget = relatedTarget; 7108 }
7108 else if (jQuery(modal).find('.modal-footer .cvx-confirm').data('action') === undefined) { 7109 e.preventDefault(); 7110 e.stopImmediatePropagation(); 7111 return false; 7112 } 7113 jQuery('#'+modalId+' .modal-footer .cvx-confirm').off().on(click_event, function(e) { 7114 var actionFunction = jQuery(this).data('action'); 7115 if (typeof actionFunction == 'function'){ 7116 actionFunction(jQuery(this).data('args')); 7117 return; 7118 } 7119 var args = [jQuery(this).data('action'),window]; 7120 // data-args = "a1,a2,....,an" ou un objet 7121 var modalArgs = jQuery(this).data('args'); 7122 if (typeof(modalArgs) == "string"){ 7123 args = args.concat(modalArgs.split(",")); 7124 } else if (Array.isArray(modalArgs)){ 7125 args = args.concat(modalArgs); 7126 } else { 7127 args.push(modalArgs); 7128 } 7129 if (relatedTarget != undefined && relatedTarget.length > 0) 7130 args.push(relatedTarget); 7131 // args : functionName, context, args 7132 TZR.executeFunctionByName.apply(this,args); 7133 }); 7134 }, 7135 callerAction:function(e){ 7136 var relatedTarget = TZR.Modal.relatedTarget; 7137 var args = [jQuery(this).data('action'),window]; 7138 var modalArgs = jQuery(this).data('args'); 7139 // data-args = "a1,a2,....,an" ou un objet 7140 if (typeof(modalArgs) == "string"){ 7141 args = args.concat(modalArgs.split(",")); 7142 } else { 7143 args.push(modalArgs); 7144 } 7145 if (relatedTarget != undefined && relatedTarget.length > 0) 7146 args.push(relatedTarget); 7147 TZR.executeFunctionByName.apply(this,args); 7148 }, 7149 initialize:function(){ 7150 //modale non incluse dans le main => delegue 7151 jQuery('#cv8-content').on('show.bs.modal', TZR.Modal.selectedFields.elem, function(e) { 7152 TZR.Modal.show(e,this); 7153 }); 7154 var deleteModal = jQuery(TZR.Modal.confirm_delete.elem).on('show.bs.modal', function(e) { 7155 TZR.Modal.show(e,this); 7156 }); 7157 jQuery('.modal-footer .cvx-confirm', deleteModal).on('click', TZR.Modal.callerAction); 7158 } 7159}; 7160TZR.Modal.confirm_delete = { 7161 elem:'#cvx-confirm-delete', 7162 config:function(action,args,title,message) { 7163 TZR.Modal.config("cvx-confirm-delete",action,args,title,message); 7164 }, 7165 show:function() { 7166 jQuery(TZR.Modal.confirm_delete.elem).modal('show'); 7167 } 7168}; 7169TZR.Modal.alert = { 7170 elem:'#cvx-alert-message', 7171 config:function(title,message) { 7172 TZR.Modal.config("cvx-alert-message",null,null,title,message); 7173 }, 7174 show:function() { 7175 jQuery(TZR.Modal.alert.elem).modal('show'); 7176 } 7177}; 7178TZR.alert = function(message, title){ 7179 TZR.Modal.alert.config(title, message); 7180 TZR.Modal.alert.show(); 7181}; 7182TZR.Modal.auth = { 7183 elem : '#cvx-auth', 7184 errorelem : '#cvx-auth-error' 7185}; 7186/// Modale "generique" de confirmation 7187TZR.Modal.Confirm = function(title, message, options){ 7188 this.id = "cvx-confirm-generic"; 7189 this.elem = jQuery("#"+this.id); 7190 this.options = options; 7191 var that = this; 7192 this.config = function(title,message,options) { 7193 if (title){ 7194 this.elem.find('.modal-title').text(title); 7195 } 7196 if (message){ 7197 if (this.elem.find('.modal-body p').length>0){ 7198 if (this.elem.find('.modal-body p').length>1){ 7199 this.elem.find('.modal-body').html("<p></p>"); 7200 } 7201 this.elem.find('.modal-body p').html(message); 7202 } else { 7203 this.elem.find('.modal-body').html(message); 7204 } 7205 } 7206 }; 7207 this.done = function(event){ 7208 if (typeof(this.options.done) == "function"){ 7209 this.options.done(this.options); 7210 } 7211 }; 7212 this.canceled = function(event){ 7213 if (typeof(this.options.canceled) == "function"){ 7214 this.options.canceled(this.options); 7215 } 7216 }; 7217 this.show = function(){ 7218 jQuery("#"+that.id).off('show.bs.modal.tzr-confirm').on('show.bs.modal.tzr-confirm', function(){ 7219 if (typeof(that.options.done) == "function"){ 7220 jQuery('.modal-footer .cvx-confirm', that.elem).off(); 7221 jQuery('.modal-footer .cvx-confirm', that.elem).on(TZR.click_event+".tzr-confirm", function(e) { 7222 that.done(e); 7223 }); 7224 } 7225 if (typeof(that.options.canceled) == "function"){ 7226 jQuery('.modal-footer .cvx-cancel', that.elem).off(); 7227 jQuery('.modal-footer .cvx-cancel', that.elem).on(TZR.click_event+".tzr-cancel", function(e) { 7228 that.canceled(e); 7229 }); 7230 } 7231 }); 7232 jQuery("#"+that.id).modal('show'); 7233 }; 7234 7235 this.config(title,message,options); 7236 7237}; 7238 7239TZR.Modal.selectedFields = {}; 7240//id = cvx-selectedFields+uniqid, il peut y avoir potentiellement plusieurs modales 7241TZR.Modal.selectedFields.elem = '.cvx-selectedFields'; 7242TZR.Modal.selectedFields.startId = '#cvx-selectedFields'; 7243 7244//======== 7245//image edit 7246//========= 7247TZR.imageEditorOpen = function(params){ 7248 var jthumb = jQuery("#"+params.varid+"-img"); 7249 jthumb.data('xparams', params); 7250 if ((workingcopy = jthumb.data('xworkingcopy'))){ 7251 params.urlImage = params.downloader+workingcopy+"&_"+escape(new Date().getTime()); 7252 } else { 7253 params.urlImage += "&_"+escape(new Date().getTime()); 7254 } 7255 jQuery().imageEditor(params); 7256}; 7257 7258TZR.imageEditorUploaded = function(data, varid){ 7259 var data = jQuery.parseJSON(data); 7260 jQuery("#"+varid+"-updated").val('yes'); 7261 var jthumb = jQuery("#"+varid+"-img"); 7262 var params = jthumb.data("xparams"); 7263 jthumb.attr('src', params.downloader+data.thumb+"&_"+escape(new Date().getTime())).data('xworkingcopy', data.tmp); 7264 jQuery().imageEditor('hide'); 7265}; 7266//======================== 7267// initialisations modales 7268//======================== 7269jQuery(document).ready(function($) { 7270 TZR.Modal.initialize(); 7271}); 7272 7273jQuery( document ).ajaxComplete(function(event, xhr, settings) { 7274 TZR.initToolsTipsAndPopOvers(); 7275 //DateRangePicker requires bootstrap daterangepicker 7276 // ===================== 7277try{ 7278 jQuery('[data-toggle="bs-daterangepicker"]').each( function() { 7279 TZR.Daterangepicker.init(this); 7280 }); 7281}catch(e){} 7282}); 7283//==================== 7284// raccourcis clavier 7285//==================== 7286TZR.ShortKeys = { 7287 handleKey : function(event, vuniqid){ 7288 var eventkeys = ""; 7289 if (event.ctrlKey === true) 7290 eventkeys += "CTRL-" 7291 if (event.altKey === true) 7292 eventkeys += "ALT-"; 7293 eventkeys += event.key.toUpperCase(); 7294 if (typeof(vuniqid.shortkeys[eventkeys]) !== "undefined"){ 7295 vuniqid.shortkeys[eventkeys].anchor.trigger('click'); 7296 } 7297 }, 7298 init : function(vuniqid){ 7299 if (typeof(vuniqid.shortkeys) == "undefined") 7300 vuniqid.shortkeys = {}; 7301 // fait ainsi shortkeys possibles dans le contenu module 7302 var activate = false;
7303 jQuery("[data-shortkey]", jQuery(vuniqid.module)).each(function(i, o){ 7304 var jitem = jQuery(o); 7305 var sk = jitem.data('shortkey').toUpperCase(); 7306 vuniqid.shortkeys[sk] = {shortkeys:sk.split("-"),anchor:jitem}; 7307 activate = true; 7308 }); 7309 if (activate === true){ 7310 var jmc = jQuery("#cv8-uniqdiv-"+vuniqid.uniqid).parents(".cv8-module"); 7311 jmc.attr("tabindex","0"); // !important pour avoir les events key 7312 var eventname = "keydown.tzr"+vuniqid.uniqid; 7313 jmc.unbind(eventname); 7314 jmc.on(eventname, {vuniqid:vuniqid}, function(event){ 7315 TZR.ShortKeys.handleKey.call(TZR, event, event.data.vuniqid); 7316 }); 7317 vuniqid.unbinds.push({container:jmc,eventname:eventname}); 7318 } 7319 } 7320} 7321 7322//========================== 7323// Service de test anti spam 7324//========================== 7325TZR.checkSenderMail = function(url,email){ 7326 var res = false; 7327 jQuery.ajax({ 7328 url : url, 7329 async : false, 7330 data : { 7331 email : email 7332 }, 7333 method : 'GET', 7334 error:function(jqXHR, textStatus){ 7335 if(jqXHR.status==401){ 7336 TZR.authAlert(); 7337 res = null; 7338 } 7339 res = null; 7340 }, 7341 success: function(data){ 7342 if(data !== 'OK') { 7343 res = false; 7344 } else { 7345 res = true; 7346 } 7347 } 7348 }); 7349 return res; 7350}; 7351TZR.sprintf = function(){ 7352 var model = arguments[0]; 7353 var i=1; 7354 var exp = new RegExp("%s"); 7355 while(i<arguments.length && exp.test(model)){ 7356 model = model.replace("%s", arguments[i]) 7357 i++; 7358 } 7359 return model; 7360}; 7361// mise à jour du champ avec l'icone choisie et traitement d'initialisation 7362TZR.IconField = {}; 7363TZR.IconField.unSelect=function(varid){ 7364 jQuery('#dis-ico'+varid).html("<span class='bordered-icon empty'></span>"); 7365 jQuery('#'+varid).val(''); 7366}; 7367TZR.IconField.select = function(ico, varid) { 7368 var boformat = jQuery('#dis-ico'+varid).data('boformat');; 7369 jQuery('#dis-ico'+varid).html("<span class='bordered-icon'>"+TZR.sprintf(boformat, ico, ico, ico, ico)+"</span>"); 7370 jQuery('#'+varid).val(ico); 7371 jQuery('#ico_Modal'+varid).modal('toggle'); 7372}; 7373TZR.IconField.initialize = function(options, val){ 7374 7375 var sheets = { 7376 files : [], 7377 slist:[], 7378 complete:false, 7379 init:function(files){ 7380 this.files = files; 7381 files.forEach((fn)=>{ 7382 this.slist[fn] = 'tofind'; 7383 }); 7384 }, 7385 add:function(fn,sheet){ 7386 this.slist[fn] = sheet; 7387 this.complete = true; 7388 for(let fn in this.slist){ 7389 if (this.slist[fn] == 'tofind') 7390 this.complete = false; 7391 } 7392 }, 7393 scanList:function(list){ 7394 for(let i=0; i<list.length && !this.complete; i++){ 7395 const item = list.item(i); 7396 let filename = null; 7397 if (item.href != null){ 7398 filename = item.href.split('/').pop(); 7399 } 7400 if (this.files.indexOf(filename) != -1){ 7401 this.add(filename,item); 7402 } 7403 if (!this.complete && item.rules){ 7404 this.scanList(item.rules); 7405 } 7406 } 7407 }, 7408 getIcons:function(exp){ 7409 let icons = []; 7410 for(let fn in this.slist){ 7411 const item = this.slist[fn]; 7412 if (typeof(item.styleSheet) != "undefined"){ 7413 for(let i=0; i<item.styleSheet.rules.length; i++){ 7414 let rule = item.styleSheet.rules[i]; 7415 // on garde ce qui correspond 7416 let matches = exp.exec(rule.selectorText); 7417 if(matches){ 7418 icons.push(matches[1]); 7419 } 7420 } 7421 } 7422 } 7423 return icons; 7424 } 7425 }; 7426 7427 7428 let current = TZR.sprintf(options.display_format,val, val, val, val); 7429 let empty = (val == "")?"empty":""; 7430 7431 jQuery(`#dis-ico${options.varid}`).append(`<span class="bordered-icon ${empty}">${current}</span>`); 7432 7433 const styleSheetList = document.styleSheets; 7434 7435 sheets.init(options.files.split(',')); 7436 sheets.scanList(styleSheetList); 7437 7438 const iconsClasses = sheets.getIcons(new RegExp(options['regexp'])); 7439 7440 this.setSelectionList(iconsClasses, options.display_format, options['varid']); 7441 7442 jQuery(`#search-ico${options.varid}`).on('keyup', (event)=>{ 7443 var filtre=String(event.target.value); 7444 const exp = new RegExp(`.*${filtre}.*`); 7445 var icogroups = jQuery(`#dis-ico-body-${options.varid} ul li`).show(); 7446 icogroups.each(function(i, o){ 7447 if (exp.test(jQuery(o).data('iconclass'))) 7448 jQuery(o).show(); 7449 else 7450 jQuery(o).hide(); 7451 }); 7452 }); 7453}; 7454
7455TZR.IconField.setSelectionList = function(iconsClasses, display_format, varid){ 7456 const target = jQuery(`#dis-ico-body-${varid} ul`); 7457 iconsClasses.forEach((classname)=>{ 7458 // nettyage d'ev. '.' du selecteur ... 7459 classname = classname.replace(/^\./,''); 7460 const span = TZR.sprintf(display_format, classname, classname, classname); 7461 const elt = jQuery(`<li data-iconclass="${classname}">${span}<span class="glyphicon-class">${classname}</span></li>`); 7462 elt.on('click', (event)=>TZR.IconField.select(classname, varid)); 7463 target.append(elt); 7464 }); 7465}; 7466 7467;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.