function sfish(){ var elist = [ 'sclick', 'sclick2', 'documents', 'sidemenu' ]; var toggleover = function(ev){ var li = $(this).closest(ev.data.elm); var eid = ev.data.eid; if(li.hasClass('over')) { li.removeClass('over'); $(document).unbind('click.closesclick' + eid); } else { li.siblings('li').removeClass('over'); $.each(elist,function(num, eli){ if(eli != eid){ $('.' + eli).find('.over').removeClass('over'); $('.' + eli).removeClass('over'); } }); $(document).unbind('click.closesclick' + eid); li.addClass('over'); $(document).one('click.closesclick' + eid, function(){ li.removeClass('over'); }); li.bind('click.closesclick' + eid, function(e){ e.stopPropagation(); }); } }; var togglemnu = function(ev){ var li = $(this).closest(ev.data.elm); var eid = ev.data.eid; if(li.hasClass('over')) { li.removeClass('over'); li.find('.over').removeClass('over'); $(document).unbind('click.closesclick' + eid); } else { li.siblings('li').removeClass('over'); li.siblings('li').find('.over').removeClass('over'); $.each(elist,function(num, eli){ if(eli != eid){ $('.' + eli).find('.over').removeClass('over'); $('.' + eli).removeClass('over'); } }); $(document).unbind('click.closesclick' + eid); li.addClass('over'); $(document).one('click.closesclick' + eid, function(){ $('.' + eid).find('.over').removeClass('over'); $('.' + eid).removeClass('over'); }); li.click(function(e){ e.stopPropagation(); }); } if(li.hasClass('more')){ return false; } }; $('.sclick').children('li').children('a').click({elm:'li', eid:'sclick'}, toggleover); $('.sclick2').children('li').children('a').click({elm:'li', eid:'sclick2'}, toggleover); $('.documents').children('a').click({elm:'div', eid:'documents'}, toggleover); $('.sidemenu li.more').children('a').click({elm:'li', eid:'sidemenu'}, togglemnu); } function newbasket() { $(document).on('click','.basket-add .add .kent-ico',function () { var elt=$(this); var rec = $(this).prev('input').attr('id'); var val = $(this).prev('input').val(); if(val == '') { alert('Vous devez renseigner un nom de sélection.'); return false; } $.post( 'RecordBasket.htm', /* rank update URL */ 'rec2b='+encodeURIComponent(rec)+'&sel_act=new&select_name='+encodeURIComponent(val)+'&cx_set='+kParams.context+'&isAjax=true', /* post variables */ function(data) { if(data.search(/Erreur/)<0) { let displayVal=val.replace(//g,'>'); var newBasket = new Basket({id:parseInt(data),name:displayVal,comment:'',count:0,niv:0}); newBasket.add(rec.match(/_([0-9]+)$/)[1]); basketList.unshift(newBasket); $(document).trigger('loadBaskets'); } else return false; }); return false; }); $(document).on('keyup','.contents .basket-add .add input',function (event) { //enter key press if(event.keyCode==13) $(this).parent().find('a.kent-ico').click(); }); } function loadBaskets(elt,attrs,callback) { /* create basket list elt= parent element to create the list in attrs= (object) synth(bool) full list or just baskets count docs(bool) if synth==1, whether to display nb of documents in all baskets checkboxes(bool) whether to display checkboxes quickedit(bool) whether to display buttons to delete or empty basket recnum(string) recnum of the current document, so checkboxes are checked accordingly format(string) format of the string to send back for each basket - use [name],[comment],[url],[num],[count],[box],[edit],[style] to replace with basket data niv (int, bool) formula to apply to calculate string to display hierarchy ([niv] will be replaced by level), set to false to not display hierarchy readonly(bool) include readonly baskets (defaults to true)*/ if (typeof basketList=='undefined') return false; var data=''; if(attrs.readonly===undefined) attrs.readonly=true; if(attrs.synth=='true') //synthesis { if(basketList.length==0) data+='Aucun favori créé'; else { data+=basketList.length + ' Favoris'; if(attrs.docs=='true') { var tot=0; for(x in basketList) if(attrs.readonly || !(basketList[x].readonly)) tot+=basketList[x].count; data+= ' ['+tot+']'; } } } else //list { for(x in basketList) { if(attrs.readonly || !(basketList[x].readonly)) { if(attrs.format===undefined) attrs.format='
  • [box] [name] [[count]][edit]
  • '; var str=attrs.format; if(attrs.checkboxes=='true') { var checked=''; if(array_find(basketList[x].records,attrs.recnum)>=0) checked=' checked="checked"'; str=str.replace('[box]',''); str=str.replace('[name]',''); } else { str=str.replace('[name]',basketList[x].name); str=str.replace('[box]',''); } str=str.replace('[count]',basketList[x].count); str=str.replace('[comment]',basketList[x].comment); str=str.replace('[num]',basketList[x].id); str=str.replace('[url]','ListRecord.htm?list=selection&select='+basketList[x].id); if(attrs.quickEdit=='true') { var act=''; act+=''; act+=''; str=str.replace('[edit]',act); } else str=str.replace('[edit]',''); if(typeof attrs.niv=='undefined') attrs.niv='\'padding-left:\'+(10*[niv])+\'px\''; else if(typeof attrs.niv=='number') attrs.niv='\'padding-left:\'+('+attrs.niv+'*[niv])+\'px\''; if (attrs.niv) str=str.replace('[niv]',eval(attrs.niv.replace('[niv]',basketList[x].niv))); data+=str; } } if(data==='') data+='
  • Aucun favori créé
  • '; } elt.html(data); if(arguments.length ==3 && typeof callback == 'function') callback(); } function submitbasket() { $(document).on('click','.basket-add input[type="checkbox"],.#record_basket input[type="checkbox"]',function(){ var rec = $(this).attr('id') ; var check = $(this).is(':checked'); var container = $(this).closest('.contents'); var title=$(this).closest('.article').find('h2 .title'); if(title.length===0) title=$(this).closest('.record').find('.section>.header'); if(title.length===0) title=$(this).closest('.article').find('td.col4'); var doc=title.text().trim(); if(doc.length>50) doc=doc.substr(0,50)+'...'; var basketName=$(this).siblings('label').text().trim(); $.post( 'RecordBasket.htm', /* rank update URL */ { rec2b: rec, check: check, sel_act: "insert",isAjax:true}, /* post variables */ function(data) { if(data.search(/Erreur/)<0) { var id = parseInt(rec.match(/_([0-9]+)$/)[1]); var recnum = rec.match(/_([0-9]+)_/)[1]; if(check) findBasket(id).add(recnum); else findBasket(id).remove(recnum); $(document).trigger('loadBaskets'); if(check) kMessageBox.send('Enregistrement \"$1\" ajouté aux favoris \"$2\"'.replace('$1',doc).replace('$2',basketName)); else kMessageBox.send('Enregistrement \"$1\" enlevé des favoris \"$2\"'.replace('$1',doc).replace('$2',basketName)); } else return false; }); }); } function removeFromBasket() { $(document).on('click','.basketOff',function (e) { e.preventDefault(); $(this).kLoader(); var rec=$(this).attr('id'); var elt=$(this); $.post( 'RecordBasket.htm', /* rank update URL */ { rec2b: rec, check: false, sel_act: "insert",isAjax:true}, /* post variables */ function(data) { var id = parseInt(rec.match(/_([0-9]+)$/)[1]); var recnum = rec.match(/_([0-9]+)_/)[1]; findBasket(id).remove(recnum); $(document).trigger('loadBaskets'); kMessageBox.send('"'+elt.closest('.article').find('h2 .title').text()+'" supprimé des favoris "'+elt.data('basketName')+'". La liste sera mise à jour au prochain affichage du contenu du dossier de favoris.'); elt.remove(); }); }); } function showAjax(elt,pos) //pos = left or right { if(arguments.length < 2) pos='right'; var static=false; if(elt.css('position')=='static') //change css position if static { elt.css('position','relative'); static=true; } var check =$('H'); check.css({ 'opacity':'0', 'filter':'Alpha(opacity=0)', 'position':'absolute', 'display':'inline', 'top':'5px', 'line-height':'100%', 'font-size':'20px' }); check.css(pos,'5px'); elt.append(check); check.animate({opacity:1},300,function() { setTimeout(function () { check.animate({opacity:0},300,function () { check.remove(); if(static) elt.css('position',''); }); },100); }); } function showmore(){ $('body').on('click',' .article .more,.article .showFull',function(e){ e.preventDefault(); var trigger = $(this); if(!trigger[0].hasAttribute('href')) trigger=$(this).find('[href]'); var extra = trigger.closest('.article').find('.extra'); var parent = extra.closest('.article'); if(parent.hasClass('opened')) //hide extra parent.removeClass('opened'); else {//show extra parent.addClass('opened'); if(extra.is(':empty,.loadingError') && !$(this).is('.showFull')) {//load extra extra.kLoader(); var url = trigger.attr('href'); kAjax(url,{},function (data) { //success if(data=='') data='

    Pas de contenu supplémentaire à afficher.

    ' extra.html(data); extra.removeClass('loadingError'); },function (error) { //error extra.html('

    '+error+'

    '); extra.addClass('loadingError'); }); } } }); } function showsub(){ $(document).on('click','.showsub2',function (e) { if($(this).siblings('.submenu').length==0) return true; var elt=$(this); var target=elt.nextAll('.submenu'); function showsub_changeIcons() { document.querySelectorAll('#mainCol .submenu>a.kent-ico').forEach(function (el) { el.classList.remove('kent-ico'); el.innerHTML=el.getAttribute('title'); el.removeAttribute('title'); }); document.querySelectorAll('#mainCol .submenu>span').forEach(function(el) { if(el.innerHTML=='|') el.outerHTML='
    '; }); } function showsub_show(){ elt.siblings('.submenu').modalShow({show:function () { $(this).removeClass('hide'); elt.data('alt-icon',elt.is('.kent-ico-burger')?'burger':'bullets'); elt.changeIcon('x'); if(elt.offset().left<($(window).innerWidth()/2)) elt.siblings('.submenu').css({right:'auto',left:0}); },hide:function () { $(this).addClass('hide'); elt.changeIcon('x',elt.data('alt-icon')); },menu:true}); } e.preventDefault(); if($(this).closest('.record.contents,#listRecTab').length==1) //record or table { if(!target.is('.loaded') || e.shiftKey) { target.kLoader({type:'circle'}); showsub_show(); kAjax('ajax_'+($(this).closest('.record.contents').length===1?'record':'table')+'Submenu.htm',{record:getRN(elt),monoGed:elt.closest('.record').is('.monoGed'),idlist:kParams.idlist},function (data) { target.html(data); target.addClass('loaded'); showsub_changeIcons(); let $basketList=target.find('.basket-add'); if($basketList.length>0) {//load baskets (submenu_loadBasket=function () { loadBaskets($basketList.find('.check-list'),{checkboxes:'true',recnum:getRN(elt),readonly:false}); })(); $(document).on('loadBaskets',submenu_loadBasket); } },function (error) { target.html(error); }); } else { showsub_show(); } } else //list { showsub_changeIcons(); showsub_show(); } }); $(document).on('click','.submenu a',function (e) { if($(this).closest('.inactive').length>0) return false; if($(this).attr('href').indexOf('#')<0 || $(this).attr('href')=='#' || $(this).is('.popupTrigger')) return true; e.preventDefault(); var act=$(this).attr('href').substr(1); var iKey=$(this).closest('.submenu').attr('data-i-key'); switch(act) { case 'lock': gedPlus_lockFile(iKey,($(this).data('act')=='lock'),this); break; case 'editProperties': gedPlus_editPropertiesPopup(iKey,this); break; case 'triggerFile': gedPlus_uploadFile(iKey,this); break; case 'directLink': popup('popup_geideDirect.htm?arckey='+iKey,{width:400}); break; } }); //click on filter $(document).on('click','.showToolsE',function (e) { e.preventDefault(); if($(this).is('#listBody a')) { //show if($('#floatingToolsE').length>0) { if($(this).is('.showToolsELeftCol')) $(this).css('visibility','hidden'); else $(this).addClass('hide'); $('#floatingToolsE').removeClass('hide'); } else { var button=$(this); var box=$('
    '); var leftCol=$('#leftCol').length>0; if(leftCol) { var css={}; css.width=$('#leftCol').width(); css.position='absolute'; css.top=0; css.height=$('#leftCol').height(); css.left=-css.width; box.css(css).addClass('showToolsELeftCol'); button.css('visibility','hidden').addClass('showToolsELeftCol'); } else button.addClass('hide'); $('#listRecord').prepend(box); box.append(''); content=$('
    ').appendTo(box); content.kLoader({type:'circle'}); var cat=window.location.toString().match(/((&|\?)sublist_[0-9]+=on)+(&comb=[0-9])?/i); if(cat!==null) cat='&'+cat[0].substr(1); else cat=''; kAjax('ajax_menu_k2.htm','tab=2&idlist='+kParams.idlist+(kGetParam('reload')==='on'?'reload=on':undefined)+cat,function (data) { content.html(data); },function (error) { kMessageBox.send(error,{type:'error'}); button.css('visibility','').removeClass('hide'); }); } } else { //hide $('#floatingToolsE').addClass('hide'); $('#listRecord .showToolsE').css('visibility','').removeClass('hide'); } }); //old version, still used to editrecord and record_modify2 $(document).on('click','.contents .header a.showsub',function(){ if($(this).siblings('.submenu').hasClass('active')) { $(this).siblings('.submenu').removeClass('active'); if(!$(this).is('#mainCol .record *')) $(this).html('O'); } else { $(this).siblings('.submenu').addClass('active'); if(!$(this).is('#mainCol .record *')) $(this).html('N'); } return false; }); } function checkSubmenuEmpty() { if($('#listBody .settings .submenu').children('a').length===0) { $('#listBody .settings .submenu').prev('.showsub2').remove(); $('#listBody .settings .submenu').remove(); } } function selectall() { $(document).on('click','.contents .selectall .checkbox',function(){ $(this).parents('.contents').find('.section .header .checkbox').prop('checked', $(this).prop('checked')); }); $(document).on('change','.boxesGroup input[type="checkbox"]',function (e) { var master=$(this).closest('.boxesGroup').find('input.selectAll'); if(master.length===0) return true; var all=$(this).closest('.boxesGroup').find('input[type="checkbox"]:not(.selectAll)'); if($(this).is(master)) { //click on master : select/unselect others all.prop('checked',master.is(':checked')); master.prop('indeterminate',false); } else { //click on any other : change master status var checked=all.filter(':checked'); if(checked.length===all.length || checked.length===0) master.prop({checked:(checked.length>0),indeterminate:false}); else master.prop({checked:false,indeterminate:true}); } }); } function changetabs(tabmenu){ $(tabmenu + ' .tab-list').on('click','a',function(){ $(this).parents('.tabs').find('.tab-contents').removeClass('active'); $(this).parents('.tabs').find('a.active').removeClass('active'); var uri = $(this).attr('href'); $(uri).addClass('active'); $(this).addClass('active'); return false; }); } function changefontsize() { $('.contents .fontsize').on('click','a',function (e) { e.preventDefault(); if(!$(this).is('.active')) return false; var ns=clearIP($(this).attr('href')).replace(/#plus/,''); ns=parseInt(ns); if(ns != NaN && ns !== false && ns >=0 && ns<5) { var s = $('.section,.sizeVar, .CKE, .CKE [class^="f"]'); s.each(function () { $(this).attr('class',$(this).attr('class').replace(/ ?plus_[0-5]/,'')); $(this).addClass('plus_'+ns); }); if($(this).is('.smaller')) { $(this).attr('href','#plus'+Math.max(0,ns-1)).addClass('active'); if(ns==0) $(this).removeClass('active'); $(this).siblings('.larger').attr('href','#plus'+(ns+1)).addClass('active'); } else if($(this).is('.larger')) { $(this).attr('href','#plus'+Math.min(5,ns+1)).addClass('active'); if(ns==5) $(this).removeClass('active'); $(this).siblings('.smaller').attr('href','#plus'+(ns-1)).addClass('active'); } } }); } function hoverrating() { $(document).on('mouseenter','.rating span',function () { var el = $(this).addClass('jsactive'); /* Add class jsactive to hovered element */ el.prevAll().addClass('jsactive'); /* Add class jsactive to elemements before hovered element */ el.nextAll().addClass('jsnotactive'); /* Add class jsnotactive to elemements after hovered element */ }); $(document).on('mouseleave',' .rating span',function() { $(this).siblings().andSelf().removeClass('jsactive jsnotactive'); /* Remove js classes from ratings */ }); } function submitrating() { $(document).on('click','.rating span a',function() { var ln = $(this); var ar = $(this).attr('rel').split('|'); var cnt = ln.parents('.rating'); $.post( 'RecordRating.htm', /* rank update URL */ { level: ar[0], record: ar[1]} /* post variables */ ).success(function(newhtml) { /* If no errors */ var conf=ln.parent().clone(); conf.css('position','absolute'); conf.addClass('active'); ln.before(conf); var size = parseInt(conf.css('height'))-30; conf.animate({'font-size':'30px',opacity:0,'margin-top':size,'margin-left':size},400,function () {cnt.html(newhtml);}); }) .error(function() { /* If errors */ alert('no response from server !'); }) .complete(function() { /* If errors or no errors */ }); return false; } ); } function showmoretable(){ var al = $('.contents.table-contents tr.article .showmore a'); var ael = $('.contents.table-contents tr.extraline'); al.click(function(){ var l = $(this); var el = l.parents('tr').next('.extraline'); var e = el.find('.extra'); if(l.hasClass('active')){ l.removeClass('active'); l.html('1'); l.parents('tr').next('.extraline').hide(); } else { al.removeClass('active'); al.html('1'); ael.hide(); var url = l.attr('href'); if(e.is(':empty')){ l.html('Chargement en cours……'); $.get(url, function(data) { e.html(data); }).complete(function(){ l.addClass('active'); l.html('0'); el.show(); }); } else { l.addClass('active'); l.html('0'); el.show(); } } return false; }); } function addRss() { // below : 2 filters for compatibility reasons $('.contents').on('click','.article .recordFooter a[href^=ajax_Record_RSS_Add.htm?],.article .actions a[href^=ajax_Record_RSS_Add.htm?],.article .actions a[href^=Record_RSSAdd.htm?]',function () { var url = $(this).attr('href'); var container=$(this).closest('.recordFooter,.actions'); container.kLoader(); $.post(url, function(data) { container.closest('.article').replaceWith($(data).filter('.section').html()); setTimeout(function () {$(document).trigger('loadBaskets');},0); if($('.inputList').length > 0) updateRight(); }); return false; }); } function rss_read() { //click on article $('.contents').on('click','.article .rss-status',function (e) { e.preventDefault(); var elt=$(this).closest('.article'); updateRSSArticle(elt); }); //global functions $('.rss-global-act a').click(function (e) { e.preventDefault(); var q=clearIP($(this).attr('href')).substr(1); updateRSSList(q); }); } function updateRSSArticle(elt,callback) { if(arguments.length<2) var callback=''; var rec=getRN(elt); var act='rP'+(elt.is('.read')?'1':'2'); $.post('ajax_KP_RSSupdate.htm',{record:rec,actrss:act},function (d) { if(d.indexOf('OK')>=0) { //if no error var data = d.match(/([0-9]+)::(\[.+\])::([0-9]+)/i); if(data[3]<2) elt.removeClass('read'); else elt.addClass('read'); label=elt.find('.rss-status'); if(label.length>0) { label.html(data[2]); label.removeClass('status'+status).addClass('status'+data[3]); } if(typeof callback == 'function') callback(); } else alert(' erreur détectée ...'); }); } function updateRSSList(q,callback) { if(arguments.length<2) var callback=''; popup(1); $.post('ajax_KP_RSSupdate.htm',q, function (d) { popup(0); if(d.indexOf('OK')>=0) { var data = d.match(/[^0]::(\[.+\])::([0-9]+)/i); var articles=$('.article .rss-status').closest('.article'); articles.find('.rss-status').html(data[1]); articles.find('.rss-status').removeClass('status'+status).addClass('status'+data[2]); if(data[2]<2) articles.removeClass('read'); else articles.addClass('read'); if(typeof callback == 'function') callback(); } else alert(' erreur détectée ...'); }); } function deadLink() { $(document).on('click','a[href="#"],a[href=""]',function(e) {e.preventDefault();}); } function searchPanel() { $('#main-top-bar #search .more').click(function () { var box = $('#main-top-bar #search>div'); (box.is(':visible'))? box.fadeOut(300) : box.fadeIn(300); }); $('#main-top-bar #search .contents a.kent-ico').click(function () { $('#main-top-bar #search>div').fadeOut(300); }); } function clickPopup() { $(document).on('click','a.popupTrigger',function (e) { var href=this.getAttribute('href'); var elt=$(this); var move=1; //move is true if popup position is automatic let inMenu=($(this).closest('.submenu').length>0); if(href.charAt(0)== '#' && href.length>1) { move=0; var target = $(href); } else { var target = $(this).nextAll('.popup').first(); if(target.length==0) target = $(this).parent('p').nextAll('.popup').first(); if(inMenu) { //menu in submenu move=0; //set an id if(target[0].id=='') target[0].id=crypto.randomUUID(); else id=target[0].id; this.href='#'+target[0].id; //move target after submenu target.parents('.submenu').after(target); } } target.data('trigger',$(this)); e.preventDefault(); target.modalShow({show:function () { var w = target.outerWidth()/2; var y = elt.position().top + elt.height() -1; var l =elt.position().left+(elt.outerWidth()/2)-w; var offset=elt.offset().left-elt.position().left; if($(window).width() < offset+l+target.outerWidth()+20) l=$(window).width()-target.outerWidth()-offset-20; else if(offset+l<20) l=20-offset; if (w==0) w=80; if(move) target.css({'left':l,'top':y}); target.fadeIn(300); elt.addClass('active'); if(elt.is('.popupAsync')) { //async loading let url=elt.data('href'); let query={} for(i in elt[0].dataset) if(i.indexOf('query')===0) query[i.substring(5).toLowerCase()]=elt[0].dataset[i]; target.kLoader(); kAjax(url,query,function (data) { target.html(data); elt.removeClass('popupAsync'); },function (error) { target.html('

    '+error+'

    '); }); } },hide:function () { $(this).fadeOut(300); elt.removeClass('active'); } }); }); $(document).on('click','.popup .close a',function () { $(this).parents('.popup').fadeOut(300); $(this).parents('.popup').prevAll('a.popupTrigger').first().removeClass('active'); }); // reposition popup on mouse over popupHover $(document).on('mouseenter','.popupHover',function () { var target = $(this).find('.popup').first(); var trigger = $(this).find('p,a').first(); setTimeout(function () { var w = target.outerWidth()/2; var y = trigger.position().top + trigger.height() -1; if(target.is('.left')) { w=target.find('.arrow').first().width()/2; y-=30; } if (w==0) w=80; target.css({'left':trigger.position().left+(trigger.outerWidth()/2)-w,'top':y}); },0); }); } function popupLabel() { $('.popupLabel').each(function () { var elt=$(this); if(elt.attr('href').match(/^#.+/)) var target=$(elt.attr('href')); else { var target=elt.nextAll('.popup').first(); if(target.length==0) target = trigger.parent('p').nextAll('.popup').first(); } if(target.find('input[type=checkbox],input[type=radio]').length==0) return true; elt.data('defaultValue',elt.html()); target.data('labelTarget',elt); function popupLabel_change () { var txt=''; var target=$(this).closest('.popup'); var elt=target.data('labelTarget'); target.find('input:checked').each(function (i) { if(i>0) txt+=', '; var lib=$(this).nextAll('label'); txt+=lib.html(); }); if(txt==='') txt=elt.data('defaultValue'); elt.html(txt); }; popupLabel_change.apply(target); target.off('change.popupLabel'); target.on('change.popupLabel','input',popupLabel_change); }); } function focusReadonly() { $('input[readonly]').click(function () { this.select(); return false; }); } function basketEdit() { $(document).on('click','.basket-list .actions a', function () { if($(this).is('.empty_basket')) basketAct('empty',$(this).closest('[data-basket]').data('basket')); else if($(this).is('.del_basket')) basketAct('del',$(this).closest('[data-basket]').data('basket')); return false; }); } function basketAct(act,id,callback) { if(act=='del' && confirm("Voulez-vous vraiment supprimer cette sélection ?")) { $.post('ListTags_MAJ.htm?sel_act=del&numselect='+id,function () { typeof callback == "function" && callback(); var pos = array_find(basketList,findBasket(parseInt(id))); var name=basketList[pos].name; basketList.splice(pos,1); $(document).trigger('loadBaskets'); kMessageBox.send('Le dossier de favoris $$$ a été supprimé'.replace('$$$',name)); }); } else if(act=='empty' && confirm("Voulez-vous vraiment vider cette sélection ?")) { $.post('ListTags_MAJ.htm?sel_act=empty&numselect='+id,function () { typeof callback == "function" && callback(); var pos = array_find(basketList,findBasket(parseInt(id))); var name=basketList[pos].name; findBasket(parseInt(id)).empty(); $(document).trigger('loadBaskets'); kMessageBox.send('Le dossier de favoris $$$ a été vidé'.replace('$$$',name)); }); } } function recorddel(idlist,record,mes,mode) { var action = mes[0]; if(action == '0') alert("Impossible de supprimer cet enregistrement"); else { if (confirm("Supprimer définitivement cet enregistrement ?"+"\n"+mes.substr(1))) { if(mode!=='quick') { if(confirm("Etes-vous certain ?")) window.location="info.htm?idlist="+idlist+"&record="+record+"&eForm_Action=-9&goTo=listrecord.htm"; else alert("Suppression annulée"); } else {//quick mode kAjax('ajax_act.htm',{record:record,action:'deleterecord'},function (data) { if(data.toLowerCase()=='suppression effectuée - record deleted') $('#record'+record+',tr.article[data-record="'+record+'"]').fadeOut(200,function (){$(this).remove();}); else popup('Impossible de supprimer l\\\'enregistrement : '+data,{buttonOK:true,type:'error'}); },function (error) { popup(error,{buttonOK:true,type:'error'}) }); } } } } function modifyCodes() { function modifyCodes_displayLink(elt,the) { if(the===undefined) the=(elt.tagName==='INPUT'?$(elt):$(elt).closest('li').find('input[type=checkbox]')).data('the'); if(the!==undefined) { //themes linked to products $theBox=$(elt).closest('ul').siblings('.kpLinkedThe'); if(the==='$all$') $theBox.find('li').removeClass('hide'); else { the=the.split('/'); $theBox.find('li').addClass('hide').filter((a,b)=>the.indexOf(b.querySelector('input[type=checkbox]').dataset.val)>=0).removeClass('hide'); } if($theBox.find('li:not(.hide)').length>0) $theBox.removeClass('hide'); else $theBox.addClass('hide'); $(elt).closest('li').siblings('li.opened').removeClass('opened'); } } $(document).on('change','.directEdit input',function() { var r=$(this).attr('name').match(/^Record.*?_.+_([0-9]+)$/); if(r!==null) var recnum=r[1]; else var recnum=this.dataset.recnum; r=$(this).attr('id').match(/edit.*?_([0-9]+)_(.+)_/); if(r!==null) { var rubr=r[1]; var cod=r[2]; } else { var rubr=this.dataset.rubr; var cod=this.value; } var check=($(this).is(':checked')) ? 'on' : ''; var elt=$(this); var script=$(this).closest('[data-script]',$(this).closest('.directEdit').get()).data('script'); var params={record: recnum, field: rubr, val: cod, checked: check}; if(script) params.exec=script; kAjax('ajaxDirectEdit.htm',params, function (data) { var trigger=elt.closest('.popup').data('trigger'); if(trigger.is('.popupLabel')) var lib=trigger.data('defaultValue'); else var lib=trigger.text(); kMessageBox.send('Rubrique "$" changée :'.replace('$',lib)+' '+elt.siblings('label').text()); },function (error) { kMessageBox.send(error,{type:'error'}); }); $(this).closest('li').addClass('opened'); modifyCodes_displayLink(this); }); $(document).on('click','.directEdit.linkedValues ul:first-child li a',function (e) { e.preventDefault(); $(this).closest('li').toggleClass('opened'); if($(this).closest('li').is('.opened')) modifyCodes_displayLink(this); else modifyCodes_displayLink(this,''); }); $(document).find('.directEdit.linkedValues ul:first-child li').each(function () { //ajouter des flèches pour afficher/cacher $(this).append(''); }); } function showInstructions() { $('.helpTrigger').hover(function () { var box = $(this).getPopup('.instructionsPopup'); box.css('display','block'); $(this).positionInstructions(); },function () { var box = $(this).getPopup('.instructionsPopup'); box.css('display','none'); }); $('.instructionsPopup').hover(function () { $(this).css('display','block'); },function () { $(this).css('display','none'); }); } $.fn.positionInstructions = function(pos) { if(arguments.length==0) pos='auto'; if(pos == 'auto' && $(this).data('pos')!==undefined) pos = $(this).data('pos'); var box=$(this).getPopup('.instructionsPopup'); box.css('padding','0px'); var bw = box.outerWidth(); var bh = box.outerHeight(); var bmh = parseInt(box.find('div:first-child').css('min-height')); //box's min height var h = $(this).outerHeight(); var w = $(this).outerWidth(); var x = $(this).offset().left - $(document).scrollLeft(); var y = $(this).offset().top - $(document).scrollTop(); var shift = 13; //size of arrow in its small dimension if(pos == 'auto') { if(x-bw-shift >= 0 && y+(h/2)-(bmh/2) >= 0) pos='left'; else if(y+h+bh+shift <= $(window).height() && x+(w/2)+(bw/2) <= $(window).width() && x+(w/2)-(bw/2) >= 0) pos='bottom'; else if(x+w+bw+shift <= $(window).width() && y+(h/2)-(bmh/2) >= 0 && y+(h/2)+(bmh/2) <= $(window).height()) pos='right'; else if(y-bh-shift >= 0 && x+(w/2)+(bw/2) <= $(window).width() && x+(w/2)-(bw/2) >= 0) pos='top'; else pos='bottom'; } box.children('p').css('display','none'); switch(pos) { case 'left': bw+=shift; box.css({ 'padding-right':shift+'px', top:(-1)*Number((bmh/2)+$(this).position().top-(h/2))+'px', left:(-1)*(bw-$(this).position().left)+'px'}); box.find('.rightArrow').css('display','block'); break; case 'bottom': bh+=shift; box.css({ 'padding-top':shift+'px', top:($(this).position().top+h)+'px', left:($(this).position().left+(w/2)-(bw/2))+'px'}); box.find('.topArrow').css('display','block'); break; case 'right': bw+=shift; box.css({ 'padding-left':shift+'px', top:(-1)*Number((bmh/2)+$(this).position().top-(h/2))+'px', left:($(this).position().left+w)+'px'}); box.find('.leftArrow').css('display','block'); break; case 'top': bh+=shift; box.css({ 'padding-bottom':shift+'px', top:($(this).position().top-bh)+'px', left:($(this).position().left+(w/2)-(bw/2))+'px'}); box.find('.bottomArrow').css('display','block'); break; } } $.fn.getPopup = function(name) { var parent=$(this); var popup = parent.nextAll(name).first(); while(popup.length == 0 && parent.prop('tagName').toLowerCase()!='body') { parent=parent.parent(); popup=parent.nextAll(name).first(); } if(popup.length == 0) return undefined; return popup; } function noHoverOnFocus() { $('#main-top-bar #connecti input').focus(function() { $(this).closest('.popupHover').addClass('hover-force'); }); $('#main-top-bar #connecti input').blur(function() { $(this).closest('.popupHover').removeClass('hover-force'); }); } function submit_noRepeat() { $('form').submit(function () { var last = $(this).data('last'); if (last == undefined) last ='0'; last=parseInt(last); var d = new Date(); if(d.getTime() - last <= 2000) return false; //if last submit less than 2 seconds ago, cancel submit $(this).data('last',d.getTime()); }); } function popupQueueClass() { var queue=[]; var i=0; this.push = function () { i++; queue.push(i); return i; } this.display = function (id,checkLast) { var pos = queue.indexOf(id); if(pos<0 || (checkLast && pos!=(queue.length-1))) return false; else { queue=queue.slice(pos+1); return true; } } } //end popopQueueClass var popupQueue = new popupQueueClass(); function popup(mes,w,h,show) { // mes = message, show=true/false //automatic buttons /* args.buttonOK : true or label args.buttonCancel : true or label args.onOK : function on OK args.onCancel : function on Cancel args.callback : function called after loading //automatic formatting args.type : 'error',' warning' or 'info' args.title : string to use as title //others args.push : keep any previously opened popup opened to revert back to it on closing current one */ if(arguments.length==2 && typeof arguments[1]=='object') { var args=arguments[1]; if(args.height!==undefined) h=args.height; if(args.width!==undefined) w=args.width; else w=undefined; } else var args={}; if(arguments.length < 4) show=-1; if(arguments.length==0) //if no arguments, set show by default mes=true; if(arguments.length == 2 && typeof w=='function') { args.callback=w; w=undefined; } if(h === undefined) h = 'auto'; if(w === undefined) w = 'auto'; if(arguments.length<=1 && (typeof mes=='boolean' || typeof mes=='number')) { //if mes is bool and only argument, then it is show show=mes; mes='loader'; h=200; w=200; } else show=true; args.width=w; args.height=h; if(show==-1) { if($('#modalPopup').is(':visible')) show=0; else show=1; } if(show) { var requestID=popupQueue.push(); //if already a popup opened and args.push is true, create new div to keep old one if(!$('#modalPopup').is('.hide') & args.push) { let previous=document.getElementById('modalPopup'); previous.id='modalPopup'+(document.querySelectorAll('[id^="modalPopup"]').length+1); previous.style.display='none'; $(previous).after('
    '); } //set up events if(!$('#modalPopup').is('.eventsSetup')) { $('#modalPopup').addClass('eventsSetup'); $('#modalPopup').on('mousedown',function (e) { if($(e.target).is('#modalPopup') && $('#modalPopup .contents .submit').find('button,input[type="submit"],input[type="button"]').add('#modalPopup .contents a.closePopup').length>0) popup(0); }); $('#modalPopup').on('keyup',function (e) { if((e.key && e.key.indexOf('Esc')==0) && $('#modalPopup .contents .submit').find('button,input[type="submit"],input[type="button"]').add('#modalPopup .contents a.closePopup').length>0) popup(0); else if(e.key=='Enter' && e.target.tagName!=='TEXTAREA') $('#modalPopup .submit .ok:not([disabled]):not(.inactive)').trigger('click'); }); } $('#modalPopup').removeClass('popupImg'); //remove style classes if(args.type==='image' || args.type==='img') { args.type='image'; $('#modalPopup').addClass('popupImg'); if(mes instanceof jQuery) mes=mes[0]; if(mes instanceof Element && mes.tagName==='IMG') mes=mes.src; mes=''; args.buttonClose=true; $('#modalPopup .contents').html(mes); $('#modalPopup .contents img').on('load',function () { popupResize(args); }); } else if($.type(mes)==='object') { //if message is a jQuery object if(!popupQueue.display(requestID)) return false; $('#modalPopup .contents').append(mes.contents().clone(true)); setTimeout(function() {popupResize(args);},0); } else if(mes.search(/\.(html?|txt|jpe?g|gif|bmp)($|\?)/)>0 && mes.replace(/^([^\s]+?)(?:\?.+)?$/,'$1').search(/\s/)<0 && mes.indexOf('href=')<0) { //if url : extension + no "href" and no space before query part $('#modalPopup .contents').kLoader({type:'circle'}); kAjax(mes,{},function (data) { //success if(!popupQueue.display(requestID)) return false; $('#modalPopup .contents').html(data); setTimeout(function() {popupResize(args);},0); //resize popup after all images have loaded var imgs=$('#modalPopup .contents img'); $('#modalPopup .contents img').on('load',function () { imgs=imgs.filter($(this)); if(imgs.length==0) popupResize({width:args.w,height:args.h}); }); },function (error) { //error if(!popupQueue.display(requestID)) return false; popup('Popup load error',{buttonOK:true,type:'error'}); }); } else { //if text if(!popupQueue.display(requestID)) return false; if(mes!=='loader') $('#modalPopup .contents').html(mes); else $('#modalPopup .contents').kLoader({type:'circle'}); setTimeout(function() {popupResize(args);},0); } $('#modalPopup').removeClass('hide'); } else { if($('#modalPopup #helpdiv').length>0) window.helpbox.move(0); let others=[...document.querySelectorAll('[id^="modalPopup"]:not(#modalPopup)')]; if(others.length===0) { $('#modalPopup').addClass('hide'); $('#modalPopup .contents').html(''); } else { let previous=others.sort(a=>a.id)[others.length-1]; $('#modalPopup').remove(); previous.id='modalPopup'; previous.style.display=null; } } } function popupResize(args) { //adds menus, title, etc. if(args===undefined) { args={width:'auto',height:'auto'}; } var w=args.width; var h=args.height; //title if((args.type!==undefined | args.title!==undefined) && args.type!=='image' && $('#modalPopup .contents>.title').length===0) { var title=$('

    '); var titleVal=''; switch(args.type) { case 'error': title.addClass('error').append('5'); titleVal='Erreur'; break; case 'warning': title.addClass('warning').append('0'); titleVal='Attention'; break; case 'info': title.addClass('info').append('7'); titleVal='Information'; break; } if(typeof args.title=='string') titleVal=args.title; title.append(titleVal); $('#modalPopup .contents').prepend(title); } //buttons if((args.buttonOK!==undefined || args.buttonCancel!==undefined) && $('#modalPopup .contents>.submit').length===0) { var submit=$('
    '); if(args.buttonCancel!==undefined) submit.append(''); if(args.buttonOK!==undefined) submit.append(''); if(args.buttonOK!==undefined && typeof args.onOK!='function') submit.find('.ok').on('click',function () {popup(0);}); else submit.find('.ok').on('click',args.onOK); if(args.buttonCancel!==undefined && typeof args.onCancel!='function') submit.find('.cancel').on('click',function () {popup(0);}); else submit.find('.cancel').on('click',args.onCancel); $('#modalPopup .contents').append(submit); } if(args.buttonClose!==undefined) { $('#modalPopup .contents').append(''); } if(typeof w === 'string' && w.indexOf('%')==w.length-1) w=$(window).width()*parseInt(w)/100; if(typeof h === 'string' && h.indexOf('%')==h.length-1) h=$(window).height()*parseInt(h)/100; if(typeof w ==='string' && w.indexOf('px')==w.length-2) w=parseInt(w); if(typeof h ==='string' && h.indexOf('px')==h.length-2) h=parseInt(h); if(args.type==='image' && h==='auto' & w==='auto') { var img=$('#modalPopup .contents img')[0]; w=img.naturalWidth; h=img.naturalHeight; } if(w=='auto') w=500; if(w>$(window).width()) w=$(window).width()-30; $('#modalPopup>.contents').css({'height':'','width':w}); //focus if fields var first=$('#modalPopup').find('[autofocus]').first(); if(first.length===0) first=$('#modalPopup').find('input:not([type=hidden]),textarea,select').first(); first.focus().select(); if(typeof args.callback == 'function') args.callback(); if(window.popupResizeTimeout) clearTimeout(window.popupResizeTimeout); window.popupResizeTimeout=setTimeout(function () { //change height after animation for width is done if(h=='auto') h=Math.max($('#modalPopup>.contents').innerHeight()+2,100); if(h>$(window).height()) h=$(window).height()-30; $('#modalPopup>.contents').css({'width':w,'height':h}); },400); } function hoverDelay() //change how popups and supermenus are opened { var mode=1; // 0 : Hover, 1 : Hover + delay, 2 : Click var targets='.popupHover,#main-menu .more'; var timer; $('body').on((mode!=2?'mouseenter ':'')+'click',targets,function (e) { var elt=$(this); if(mode==2 || e.type=='click') { //if($(e.target).is('#main-menu .super-menu *,.popupHover .popupTarget *,.popupHover .popup *')) return true; //e.preventDefault(); if(elt.is('.hover')) elt.modalShow(0); else elt.modalShow({show:function () {$(this).addClass('hover');}, hide:function () {$(this).removeClass('hover');}}) } else if(mode==0) { elt.addClass('hover'); } else if(mode==1) { timer=setTimeout(function () {elt.addClass('hover');},300); } }); if(mode!=2) $('body').on('mouseleave',targets,function () { clearTimeout(timer); $(this).removeClass('hover'); }); } function toggleEditMode() { // event 'editToggle' fired on parent, with 2nd parameter at 'on' or 'off' $('.editToggle').on('click',function (e) { e.preventDefault(); var cont = $(this).closest($(this).data('target')); if(!$(this).is('.editToggleOff')) // to edit mode { $(this).html('w').addClass('editToggleOff'); cont.find('.readMode').addClass('hide'); cont.find('.editMode').removeClass('hide'); cont.trigger('editToggle','on'); } else // to read mode { $(this).html('L').removeClass('editToggleOff'); cont.find('.editMode').addClass('hide'); cont.find('.readMode').removeClass('hide'); cont.trigger('editToggle','off'); } }); $('.editMode').addClass('hide'); } function leftCol_resize() { $('#left_resize').on('mousedown',function (e) { $('*').kToggleSelect(false); var startX=e.pageX; var startW=$('#leftCol').width(); var maxW=0.5*$('#contentsWrapper').width(); var minW=0.5*startW; $(document).on('mousemove.colResize',function (e) { var y=e.pageX-startX; var w=Math.max(Math.min(startW+y,maxW),minW); $('#leftCol').css('width',w); $('#floatingToolsE').css({width:w,left:-w}); }); $(document).one('mouseup',function () { $('*').kToggleSelect(true); var prefs={}; prefs['colLeftWidth'+kParams.context]=$('#leftCol').css('width'); setUserPrefs(prefs); $(window).trigger('resize'); $(document).off('mousemove.colResize'); }); }); } function categoriesDeploy() { $(document).on('click','.categories .more a', function () { var list = $(this).closest('.check-list'); list.find('.group.hide:lt(7)').removeClass('hide'); if(list.find('.group.hide').length==0) $(this).closest('p').addClass('hide'); //resize menu if required if($(this).is('#menu_k2 *') && ($(this).closest('form').height()+$(this).closest('form').position().top) > $(this).closest('.menuWrapper').innerHeight()) { $(this).closest('.section').css('height',''); $(this).closest('.menuWrapper').height($(this).closest('.section').css('height')); } }); $(document).on('click','.categories h5',function () { $(this).toggleClass('collapse'); }) } function clickCookies() { $('#is_cookies a.submit').on('click',function (e) { e.preventDefault(); $.get('okcookies.htm','ident='+$('body').data('ident')); $('#is_cookies').remove(); }); } function record_resize() { if($('.contents.record .section.emptyRight').length>0) { var section=$('.contents.record>.section.emptyRight'); var box=$('#recordInsert'); if(section.height() < box.height()) section.css('min-height',box.height()+'px'); } } function foldersUpdate() //reset folder file count { $('.gedPlus .folder').each(function () { $(this).find('.icon .num span').first().html($(this).find('li.file').length); }); } function gedPlusToggleFolder(elt,args) { if(!(elt instanceof jQuery)) elt=$(elt); if(typeof args==='undefined') args={}; elt=elt.closest('li.folder'); var once=true; const after=function () { if(!once) return true; else once=false; if(elt.is('.opened')) elt.removeClass('opened'); else elt.addClass('opened'); if(typeof args.callback==='function') args.callback.apply(elt[0]); } if(args.open===undefined) elt.children('ul').slideToggle(after); else if(args.open==true) elt.children('ul').slideDown(after); else elt.children('ul').slideUp(after); } function toggleFolders() { //toggle folders $(document).on('click','.gedPlus .caret',function () { var parent=$(this).closest('li'); gedPlusToggleFolder(parent); }); } function iconsFolders() { //show alert icons on parent folders $('.gedPlus .iconsInfo .kent-ico').each(function () { var $icon=$(this); var val=calcIcon($icon); $icon.parents('.folder:not(.root)').each(function () { let folder=$(this); if(!hasIcon(folder,val)) { if(folder.children('div').find('.iconsInfo .kent-ico').length===0) $(this).children('div').find('.iconsInfo').append($icon.clone().addClass('child').data('tbPreviewFor',$icon)); else { let $preview=$(this).children('div').find('.iconsInfo .kent-ico'); changeIcon($preview[0],'stage-warning'); let $d=$preview.data('tbPreviewFor'); $preview.removeClass('green late black').addClass('grey').data('tbPreviewFor',$d.add($icon)); } } }); }); function calcIcon(elt) { //calculate a string to identify similar icons return elt.text()+'/'+elt.attr('class').match(/\b(kent-ico-.+?|font[0-9])(?= |$)/g).sort().join(' '); } function hasIcon(elt,val) { var ret=false; elt.children('div').find('.iconsInfo .kent-ico').each(function () { if(calcIcon($(this))===val) { ret=true; return false; } }); return ret; } } //rename folders/files function ged_rename() { $('body').on('click','.gedPlus .title a',function () { var elt=$(this); var title=elt.closest('.title'); if(elt.is('.cancel')) title.html(title.data('val')); if(elt.is('.submit')) { var newVal=title.find('input').val(); if(elt.closest('li').is('.folder')) args={ record:getRN(), act_GED:'folder_rename', folder_key:title.closest('.folder').data('key'), folder_nom2:newVal, folder_calc:'on' }; else args={ record:getRN(), i_key:elt.closest('li').attr('id').substr(7), act_GED:'ged_up_nom', archive_nom:newVal, folder_calc:'on' }; title.kLoader(); kAjax('ajax_gedPlus_misc.htm',args,function (data) { reloadGed(data); },function (error) { title.html(title.data('val')); popup(error,{buttonOK:true,type:'error'}) }); //end ajax } }); $('body').on('keyup','.gedPlus .title input[type="text"]',function (e) { if(this.value.indexOf(':')>=0) { this.value=this.value.replace(/:/g,''); kMessageBox.send('Impossible de saisir \":\" dans le nom d\'un dossier',{type:'error'}); } }); } function ged_tags() { /* deactivated : modify tags from click on tags instead of toolbox $('.gedPlus .tags').on('click','.tags.readwrite>span',function () { var elt=$(this); var tags=$(this).parent().find('span'); var val=''; var selected=$(this).is(':last-child')?'':elt.text(); tags.not(':last-child').each(function (i) {val+=(i==0?'':' ; ')+$(this).text();}); var input = $(''); input.data('val',val).val(val); if(selected=='') input.val(input.val()+' ; '); elt.parent().html('').append(input).appendSubmit(); input.focus(); if(selected!='') input[0].setSelectionRange(val.indexOf(selected),val.indexOf(selected)+selected.length); else input[0].setSelectionRange(input.val().length,input.val().length); });*/ $('.gedPlus .tags').on('click','a',function () { var tags=$(this).closest('.tags'); var elt=tags.find('input'); if($(this).is('.cancel')) tags.html(valToTags(elt.data('val'))); else if($(this).is('.submit')) { popup(1); kAjax('ajax_gedPlus_misc.htm',{ act_GED:'ged_up_tag_mod', tag:cleanupTags(elt.val()), record:getRN(), i_key:elt.closest('.file').attr('id').substr(7) }, function () { //success popup(0); tags.html(valToTags(elt.val(),true)); }, function (error) { //error tags.html(valToTags(elt.data('val'))); popup(error,{buttonOK:true,type:'error'}); }); } function valToTags(val,clean) { if(arguments.length==1) clean=false; if(clean) val=cleanupTags(val); ret=''; if(val.search(/^\s*$/)<0) ret= ''+val.replace(/ ; /g,'')+''; return ret; } }); } function ged_confirmKey() { $('.gedPlus').on('keyup','.title input, .tags input',function (e) { var target=''; if(e.keyCode==13) target='submit'; //enter else if(e.keyCode==27) target='cancel'; //escape else return true; $(this).next('.temp-form').find('.'+target).trigger('click'); }); } function cleanupTags(val) { var init=val.split(';'); var final=[]; for(x in init) if(init[x].trim()!=='' && array_find(final,init[x])<0) final.push(init[x].trim()); val=''; for(x in final) val+=(x>0?' ; ':'')+final[x]; return val; } $.fn.appendSubmit=function () //add submit buttons { $(this).each(function () { $(this).append($('pq')); }); return $(this); } function gedDragDrop() { if($('.gedPlus,#menu_k2').length==0 || window.gedDrop!==undefined) return false; var gedGhost=$(); var isMini= false; window.gedDrop = new DD(function (drag,trigger) { //initDrag trigger.closest('#contentsWrapper>div').css('z-index','3'); var row=trigger.closest('.gedlist>li.folder,.filelist>li'); isMini=row.is('#transitMini *'); if(isMini & row.is('.local')) { popup('Cet alias référence un document de la notice courante et ne peut donc y être déposé.',{buttonOK:true,type:'error',title:'Impossible de déplacer cet alias.'}); return false; } //hide preview gedToolbox.show(false); var clone=row.clone(); clone.find('.gedlist').remove(); clone.css('width',row.css('width')); clone.css('background-color',row.closest('#main,.menuWrapper').css('background-color')); clone.setBgAlpha(0.8); clone.add(clone.find('*')).each(function () { if($(this).attr('id')!='') $(this).attr('id',$(this).attr('id')+'_dragger'); }); row.addClass('dragged'); drag.append(clone); gedGhost=$('
  • '); if(isMini) gedGhost.css('display','none'); row.after(gedGhost); gedDrop.trigger=row; if(!isMini) { $('#menu_k2').data('faceBak',$('#menu_k2_nav span.active').index('#menu_k2_nav span')); menuK2_goTo(3); } },function (target,coords) { //dropAction clearTimeout(tGedDeploy); var orig=$('.dragged'); orig.closest('#contentsWrapper>div').css('z-index',''); if(target.is('#transitMini') && !isMini) {//can't drop from mini to mini $('#menu_k2').data('faceBak',''); $('#transitMini').find('.wrapper').kLoader(); kAjax('ajax_gedPlus_misc.htm',{ record:$('#menu_k2').attr('data-record'), i_key:orig.attr('id').substr(7), act_GED:'file2transfer', folder_calc:'on' },function (data) {//success orig.remove(); miniLoad(); gedGhost.remove(); gedGhost=$(); reloadGed(data); },function (error) {//error orig.remove(); miniLoad(); gedGhost.remove(); gedGhost=$(); popup(error,{buttonOK:true,type:'error'}); }); } else { if((orig.next().is(gedGhost) || orig.prev().is(gedGhost) || $('#dragger').next().is(gedGhost) || !gedGhost.is(':visible')) && (!target.is('.article') && $('.gedGhostFolder').length==0)) {//if same position orig.removeClass('dragged'); gedGhost.remove(); gedGhost=$(); return true; } if (!isMini) menuK2_goTo($('#menu_k2').data('faceBak')); $('#menu_k2').data('faceBak',''); if(!target.is('.article')) { //if adding on folder, move gedGhost into folder if($('.gedGhostFolder').length>0) $('.gedGhostFolder>div').kLoader(); else gedGhost.kLoader(); //calculate position var currentLi=gedGhost; var allLi=currentLi.closest('.folder.root').find('li[data-pos]:not([id$=_dragger])').add(currentLi); var p=allLi.index(currentLi)+1; if(p>=allLi.length) order=allLi.not(currentLi).last().data('pos')+1; else var order=allLi.eq(p).data('pos'); } else //if target is .article order=0; var targetRN=getRN(); if(isMini) var args= { i_key:(orig.is('.alias')?-1:1)*Number(orig.attr('id').substr(7)), act_GED:(orig.is('.alias')?'attach_alias':'transfer2record'), record:targetRN, folder_code_move_to:gedGhost.closest('.folder').data('code'), move_folder2order:order, folder_calc:'on' }; else if($('.dragged').is('.file')) var args={ record:targetRN, i_key:orig.attr('id').substr(7), act_GED:'move_file2folder', folder_code_move_to:gedGhost.closest('.folder').data('code'), move_folder2order:order, folder_calc:'on' }; else args={ record:targetRN, act_GED:'move_folder2folder', folder_code_to_move:$('.dragged').data('code'), folder_key:$('.dragged').data('key'), folder_code_move_to:gedGhost.closest('.folder').data('code'), move_folder2order:order, folder_calc:'on' }; function sendAjax() { kAjax('ajax_gedPlus_misc.htm',args,function (data) {//success if(target.is('.gedPlus *')) {//record if(args.copyAlias!='on') orig.remove(); gedGhost=$(); reloadGed(data); } else {//list orig.remove(); popup(0); //update count if(target.find('.figure .num').length>0) //if > 1 target.find('.figure .num>span').html(Number(target.find('.figure .num>span').html())+1); else // if 1 or 0 target.find('.figure').append(''+(1+Number(target.find('.figure .kent-ico').length<2))+''); } },function (error) { //error orig.removeClass('dragged'); gedGhost.remove(); gedGhost=$(); reloadGed(); popup(error,{buttonOK:true,type:'error'}); }); } if(isMini && orig.is('.alias')) //popup for aliases popup('

    Voulez-vous déplacer l\\\'alias ou le copier (et donc en conserver une copie dans la zone de transfert) ?

    ',{ title:'Déplacer Alias', buttonOK:'Déplacer', buttonCancel:'Copier', onOK:function () {args.copyAlias='on';popup(0);sendAjax();}, onCancel:function () {popup(0);sendAjax();} }); else sendAjax(); } },'.gedlist>li,#transitMini,.gedPlus',{shiftTop:0,shiftLeft:0,minStart:5}); //END new DD $('body').dd_bind(gedDrop,'.gedPlus .move'); $('#menu_k2').dd_bind(gedDrop,' #transitMini li[id^="archive"]'); var tGedDeploy=null; //dragLeave $('body').on('dragLeave','.gedlist>li.folder:not(.opened)',function (e) { e.stopPropagation(); clearTimeout(tGedDeploy); }); $('body').on('dragLeave','.gedPlus', function (e,args) { if (args.type!='drop' && $(e.target).is('.gedPlus')) { gedGhost.css('display','none'); $('.gedGhostFolder').removeClass('gedGhostFolder'); } }); //dragMove $('body').on('dragOver','.gedlist>li:not(.gedGhost)',function (e,args) { e.stopPropagation(); clearTimeout(tGedDeploy); var elt=$(this); if($('.dragged').is('.file') || isMini) {//dragging file if($(this).is('.file')) {//dragging file over file $('.gedGhostFolder').removeClass('gedGhostFolder'); $('.gedGhost').css('display',''); if(args.y>=$(this).offset().top+($(this).height()/2)) gedGhost.insertAfter($(this)); else if(args.y<$(this).offset().top+($(this).height()/2)) gedGhost.insertBefore($(this)); } else if($(this).children('div').isUnder(args.x,args.y)) { //dragging file over folder $('.gedGhostFolder').removeClass('gedGhostFolder'); if($(this).is('.opened')) { $('.gedGhost').prependTo($(this).find('.filelist').first()); $('.gedGhost').css('display',''); } else { tGedDeploy=setTimeout(function () {elt.find('.caret').click();},2000); $(this).addClass('gedGhostFolder'); if($(this).children('.filelist').length==0) $(this).children('div').after(''); $('.gedGhost').prependTo($(this).children('.filelist')); $('.gedGhost').css('display','none'); } } } else {//dragging folder if($(this).is('.file')) { $('.gedGhostFolder').removeClass('gedGhostFolder'); $('.gedGhost').css('display',''); if($(this).closest('.folder').find('.folderlist').length==0) $(this).closest('.folder').append(''); $(this).closest('.folder').find('.folderlist').first().prepend(gedGhost); } else if($(this).is('.folder')) { $('.gedGhostFolder').removeClass('gedGhostFolder'); if($(this).is('.local') && args.y<$(this).offset().top+($(this).children('div').height()/4)) { gedGhost.insertBefore($(this)); $('.gedGhost').css('display',''); } else if($(this).is('.local') && args.y>$(this).offset().top+($(this).height()-($(this).children('div').height()/4))) { gedGhost.insertAfter($(this)); $('.gedGhost').css('display',''); } else if ($(this).children('div').isUnder(args.x,args.y)) {//insert into if($(this).is('.opened')) { if($(this).closest('.folder').find('.folderlist').length==0) $(this).closest('.folder').append(''); $('.gedGhost').prependTo($(this).find('.folderlist').first()); $('.gedGhost').css('display',''); } else { tGedDeploy=setTimeout(function () {elt.find('.caret').click();},2000); $(this).addClass('gedGhostFolder'); $('.gedGhost').css('display','none'); if($(this).children('.folderlist').length==0) $(this).children('div').after(''); $('.gedGhost').prependTo($(this).children('.folderlist')); } } } } }); $('#menu_k2').on('dragEnter','#transitMini',function () { gedGhost.css('display','none'); if(isMini) return true; $('#transitMini').addClass('dragOver'); }); $('#menu_k2').on('dragLeave','#transitMini',function () { if(isMini) return true; $('#transitMini').removeClass('dragOver'); }); $('body').on('dragEnter','.section .article',function () { $(this).addClass('dragOver'); }); $('body').on('dragLeave','.section .article',function () { $(this).removeClass('dragOver'); }); } function sendFiles(args) //open sendFile window { if(args===undefined) args={}; var w=530; var h=400; var uArgs={}; var url=''; if(args.mode !== undefined) uArgs.mode=args.mode; if(args.context !== undefined) uArgs.upload_cx=args.context; if(args.url !== undefined) uArgs.url=args.url; if(args.oneFile !== undefined) uArgs.oneFile=true; if(args.fileTypes!==undefined) uArgs.fileTypes=args.fileTypes; if(uArgs.url==='this' || uArgs.url === undefined) uArgs.url=window.location.toString(); uArgs.mode=kParams.gedPlusUploadMode; if(args.params!==undefined) uArgs.params=JSON.stringify(args.params); for(x in uArgs) url+='&'+x+'='+encodeURIComponent(uArgs[x]); url=url.replace(/^&/,'?'); if (window.sendFilesWindow===undefined || window.sendFilesWindow.closed) window.sendFilesWindow=window.open('sendFiles.htm'+url,'Envoyer des fichiers','width='+w+',height='+h+',toolbar=no,scrollbars=yes,left='+(window.screenX+window.outerWidth/2-w/2)+',top='+(window.screenY+window.outerHeight/2-h/2)); //if files is defined, auto upload files if(args.files !== undefined && args.files.length>0) { if(uArgs.getPlusUploadMode!=='java') { (function sendFiles_initFiles() { if(window.sendFilesWindow!=undefined) { if(window.sendFilesWindow.uploaderReady) window.sendFilesWindow.postMessage({files:args.files,args:uArgs},'*'); else setTimeout(sendFiles_initFiles,500); } else { popup('

    La fenêtre de téléchargement a rencontré un problème. Veuillez vérifier qu\'elle n\'a pas été bloquée par votre navigateur ou fermée trop rapidement et re-déposer vos documents.

    ',{type:'error',title:'Erreur lors du glisser-déposer',buttonOK:true}); } })(); } else { //java uploader } } //end auto upload } function showGedToolbox() { var triggerSelector='.toolboxOpener'; $('body').on('click',function (e) { var args={}; if($(e.target).closest('#gedToolbox,#modalPopup').length>0) return true; //close toolbox on click in body (not popup) var elt=$(e.target).closest(triggerSelector); var trigger=$(e.target).closest('.toolboxOpenerTrigger'); //children preview if(trigger.is('.child')) { let $child=trigger.data('tbPreviewFor') gedPlusToggleFolder($child.parentsUntil(trigger.closest('li.folder'),'li.folder').add(trigger.closest('li.folder')),{open:true,callback:function () { $child.first().trigger('click'); }}); return false; } if(trigger.length>0) { elt=trigger.closest('li,p').find(triggerSelector); if(elt.length===0) { //get record args.record=getRN(elt); elt=trigger; if(elt.is('.section>.iconsInfo .wfIcon')) args.tabs='workflow'; } if(trigger.data('toolboxOpen')) args.tab=trigger.data('toolboxOpen'); } if(elt.length==0 || gedToolbox.isOn(elt)) gedToolbox.show(false); else { args.target=elt; if(args.record!=undefined) true; else if(elt.is('.toolboxRecord')) { args.record=getRN(); args.position='below'; args.arrow=false; args.shift=-6; if(elt.closest('.record').is('.monoGed')) args.monoGed=true; } else if(elt.closest('li').is('.folder')) { args.folderKey=elt.closest('.folder').data('key'); args.folderCode=elt.closest('.folder').data('code'); } else args.archive=elt.closest('li').attr('id').substr(7); if(e.shiftKey) args.force=true; if(window.location.pathname.toLowerCase().indexOf('listrecord.htm')>=0) args.gedContext='listRecord'; gedToolbox.show(args); } }); //press "Esc" to close $(document).on('keyup',function (e) { if(e.keyCode==27) gedToolbox.show(false); }); } function GedToolbox() //GedToolBox Class { var targetList=[]; var myClass=this; var actions=[]; var getTargetIndex = function(obj) { var i =0; while(i=targetList.length) return -1; else return i; } var deleteCont = function (i) { targetList[i]=$(); $('#gedToolbox>.wrapper.toolbox'+i).remove(); } this.show = function (args) { /* args.archive : I_Key of archive to load args.record : record num of record to load args.folderCode : code of folder to load args.folderKey : key of folder to load args.target : jQuery object of the element where to point toolbox at args.shift : number of pixels by which to shift box horizontally compared to default position args.tab : Tab to open - first one open by default args.force : true to force reload args.hide : hide box if true (ignores other arguments) args.gedContext : defines where toolbox is loaded (list, record, transitMini, transit...). Can use several values separated by ; args.tabs : which tabs to show (infos,edit,workflow) separated by ; args.position : 'left' or 'below' to show toolbox under or on the left of element args.arrow: true by default, hide arrow if false */ if(args === 0 || args === false) var hide=true; else var hide=false; if (typeof args != 'object') args={}; if(args.hide===undefined) args.hide=hide; if (args.force===undefined) args.force=false; if(args.tabs===undefined) args.tabs=''; var box=$('#gedToolbox'); if(box.length==0) { box=$('
    '); $('body').append(box); } box.css('display',(args.hide?'':'block')); if(args.hide) return true; if(args.target===undefined){ console.log('target not provided in call to gedToolbox'); return false; } var index=getTargetIndex(args.target); box.find('.wrapper').css('display','none'); if(index<0) { cont=$('
    '); box.append(cont); targetList.push(args.target); } else { cont=box.find('.wrapper.toolbox'+index); cont.css('display',''); if(cont.is('.reload')) args.force=true; if(args.force) { cont.removeClass('reload'); if(args.archive===undefined) args.archive=myClass.getParam('iKey'); if(args.record===undefined) args.record=myClass.getParam('record'); if(args.folderCode===undefined) args.folderCode=myClass.getParam('folderCode'); if(args.folderKey===undefined) args.folderKey=myClass.getParam('folderKey'); if(args.monoGed===undefined) args.monoGed=myClass.getParam('isMonoGed'); } } $('#gedToolbox>.wrapper').removeClass('last'); cont.addClass('last'); if(args.force || cont.html().length==0 || cont.html().search(/^\s+$/i)==0) //load content { if(args.archive===undefined && (args.folderKey===undefined || args.folderCode===undefined) && args.record===undefined) { console.log('record, archive or folder not provided in call to gedToolbox'); return false; } if(args.shift!==undefined) cont.data('shift',args.shift); if(args.position!==undefined) cont.data('position',args.position); if(args.arrow!==undefined) cont.data('arrow',args.arrow); var object=myClass.getParam('type'); cont.kLoader({type:'circle'}); myClass.repositionToolbox(args.target); var idlist=kParams.idlist; var record=getRN(args.target); if(object!=undefined) true; else if(args.archive!==undefined) object='file'; else if(args.folderCode!==undefined) object='folder'; else if(args.record!==undefined) object='record'; if(args.record!==undefined) record=args.record; kAjax('ajax_gedPlus_Toolbox.htm',{ object:object, i_key:args.archive, folder_code:args.folderCode, folder_key:args.folderKey, show_tabs:args.tabs.replace(',',';'), idlist:idlist, record:record, gedContext:args.gedContext, monoGed:args.monoGed },function (data) { cont.html(data); cont.find('.contents>a.kent-ico').each(function () { var tDest=$(this).attr('href').substr(1); if(!cont.find('.contents>.'+tDest).isEmpty(true)) $(this).appendTo(cont.find('.tabs')); else $(this).remove(); }); myClass.showTab(args.tab); //set tabs if(args.record!==undefined) myClass.setActionFromSubmenu(); cont.find('.img:visible img').on('load',function () {myClass.repositionToolbox();}); },function (error) { cont.html('

    '+error+'

    '); myClass.repositionToolbox(args.target); }); } else myClass.repositionToolbox(args.target); }//end showGedToolbox this.repositionToolbox=function(target) { var resize=false; //change default width if true var box=$('#gedToolbox'); var position=cont.data('position'); var arrow=cont.data('arrow'); if (arrow===undefined) arrow=true; box.children('.arrow').css('display',arrow?'':'none'); if(position=='below') box.addClass('below'); else box.removeClass('below'); setTimeout(function () { var bigOnly=false; //set to true to change only if size is bigger if(target!== undefined) box.data('target',target); else //if target is undefined, do not change width or target { target=box.data('target'); bigOnly=true; } if(target===undefined) return false; //recalculate width var cont=box.find('.wrapper:visible'); var wi=cont.width(); var hi=cont.height(); cont.css('height',''); if(cont.length>0) { /*if(resize) { cont.css('width',2000); var w=0; cont.children('div').each(function () { w+=$(this).outerWidth(); }); if(bigOnly) w=Math.max(w,wi); cont.css({width:w,height:''}); }*/ if(bigOnly) h=Math.max(cont.height(),hi); else h=''; cont.css('height',h); } var shiftx=cont.data('shift'); var arrowDim={w:box.children('.arrow').outerWidth(),h:box.children('.arrow').outerHeight()}; if(!arrow) arrowDim={w:0,h:0}; if(shiftx===undefined) shiftx=0; else shiftx=Number(shiftx); if(position=='below') { var y=target.offset().top+target.height()+arrowDim.h+shiftx; var x=target.offset().left+(target.width()/2); var shifty=-15-arrowDim.w/2; //align right if required if(x+shifty > $(window).width()/2) { shifty-=box.width()+2*shifty; if(x+shifty<0) shifty=-x+5; //prevent from overflowing left of body } //check if box will be fully on screen if(target.offset().left+(target.width()/2)+box.width()+shifty-$(document).scrollLeft()>$(window).width()) { shifty=-(target.offset().left+(target.width()/2)+box.width()-$(document).scrollLeft()-$(window).width()+5); } box.children('.arrow').css({left:-shifty-(arrowDim.w/2),top:''}); x+=shifty; } //END below else //default positioning (right) { //position y var y=target.offset().top+(target.height()/2); var shifty=-20-(arrowDim.h/2); //check if box will be fully on screen if(target.offset().top+(target.height()/2)+box.height()+shifty-$(document).scrollTop()>$(window).height()) { shifty=-(target.offset().top+(target.height()/2)+box.height()-$(document).scrollTop()-$(window).height()+5); } y+=shifty; box.children('.arrow').css({top:-shifty-(arrowDim.h/2),left:''}); //position x var x=target.offset().left+target.width()+shiftx+arrowDim.w; } //END position default box.css({ top:y, left:x }); },0); } //end repositionToolbox this.showTab = function (tab) { var box=$('#gedToolbox'); var cont=myClass.getLastCont(); cont.find('.contents>div').css('display','none'); cont.find('.tabs a').removeClass('active'); if(tab === undefined) tab=clearIP(cont.find('.tabs a').first().attr('href').substr(1)); if(tab.indexOf('#')==0) tab=tab.substr(1); var div=cont.find('.contents>.'+tab) if(div.length===0) { tab='tab-'+tab; div=cont.find('.contents>.'+tab) } div.css('display',''); if(div.data('noimage')) cont.find('.img').css('display','none'); //if data-noimage is defined on target div, hide image else cont.find('.img').css('display',''); cont.find('.tabs a[href="#'+tab+'"]').addClass('active'); myClass.repositionToolbox(); } //END toolbox show tab //click on tabs $(document).on('click','#gedToolbox .tabs a',function (e) { e.preventDefault(); var send=clearIP($(this).attr('href')); myClass.showTab(send); }); //click on actions $(document).on('click','#gedToolbox .contents a','.img a',function (e) { var href=clearIP($(this).attr('href')); if($(this).is('.inactive')) return false; //do not start inactive actions if(href.indexOf('#')!=0) return true; //only act special if href starts with # e.preventDefault(); href=href.substr(1); myClass.triggerAction(href,e); }); this.getTarget=function (cont) { if (cont===undefined) { var t=$('#gedToolbox').data('target'); if(t===undefined) return $(); if(t.length>0) return t; cont=this.getLastCont(); } var r=cont.attr('class').match(/(?: |^)toolbox([0-9]+)( |$)/i); if(r!==null) return targetList[r[1]]; else return $(); } this.getLastCont = function () { var cont=$('#gedToolbox .wrapper:visible'); if(cont.length==0) cont=$('#gedToolbox .wrapper.last'); if(cont.length==0) cont=$('#gedToolbox .wrapper').last(); return cont; } this.getTabs=function () { let tabs=$('#gedToolbox .wrapper .tabs a'); let ret={list:[],active:''}; tabs.each(function () { ret.list.push($(this).attr('href').substr(1)); if($(this).is('.active')) ret.active=$(this).attr('href').substr(1); }); if(ret.active==='' && ret.list.length>0) ret.active=ret.list[0]; return ret; } this.isOn = function (elt) { return ($('#gedToolbox').is(':visible') && elt.is(myClass.getTarget())); } this.action = function (href,callback) { if(typeof callback != 'function') return false; var a=href.split(','); for(x in a) { var i=array_find(actions,a[x],0,function (val,s) {return (val.href===s);}); if (i==-1) actions.push({href:a[x],callback:callback}); else actions[i]={href:a[x],callback:callback}; } }; this.actionOff = function (href) { var a=href.split(','); for(x in a) { var i=array_find(actions,a[x],0,function (val,s) {return (val.href===s);}); if(i>=0) actions=action.splice(i,1); } }; this.triggerAction = function (href,e) { var i=array_find(actions,href,0,function (val,s) {return (val.href===s);}); if(i>=0) actions[i].callback.apply(e.target,[e]); }; this.reload=function (tab) { let tabs=this.getTabs(); if(tab===undefined) tab=tabs.active; myClass.show({force:true,target:myClass.getTarget(),tab:tab,tabs:tabs.list.join(',')}); }; this.setReload=function (obj) { if(obj.closest('#gedToolbox').length==1) obj.closest('#gedToolbox>.wrapper').addClass('reload'); else { var index=getTargetIndex(obj); if(index>0) box.find('.wrapper.toolbox'+index).addClass('reload'); } } this.getParam=function (param) { var ret=myClass.getLastCont().find('#toolbox_'+param).val(); if(ret==='') ret=undefined; return ret; } this.reset=function(target) { if(!target instanceof jQuery) $('#gedToolbox>.wrapper').remove(); else target.each(function () { var i=getTargetIndex($(this)); if(i>=0) deleteCont(i); }); } this.setActionFromSubmenu=function () { $('#gedToolbox ul.convertActions').children('a,span').each(function () { if($(this).is('span')) $(this).remove(); else { $(this).wrap('
  • '); var val=$(this).html(); var classIco=''; if($(this).is('.kent-ico')) { $(this).removeClass('kent-ico'); classIco='kent-ico'; var r=$(this).attr('class').match(/(?:^| )(font[2-5])(?: |$)/); if(r!==null) classIco+=' '+r[1]; $(this).html(''+val+''); $(this).append($(this).attr('title')); $(this).removeAttr('title'); } } }); }; // END setActionFromSubmenu } //End GedToolBox Class function gedPlus_editPropertiesPopup(key,trigger) { if(trigger===undefined) trigger=$(); popup('popup_gedPlus_properties.htm?i_key='+key,{callback:function () { //tags $('#modalPopup .tags').on('click','a',function () { var alt=$(this).data('alt'); $(this).data('alt',$(this).attr('title')).attr('title',alt); var input=$('#modalPopup input[name="tag_del"]'); if($(this).is('.deleted')) input.val(input.val().replace($(this).data('val'),'')); else input.val(input.val()+';'+$(this).data('val')); $(this).toggleClass('deleted'); }); //send form $('#gedPlus_editPropertiesPopup input[type="submit"]').one('click',function (e) { e.preventDefault(); var url=$('#gedPlus_editPropertiesPopup').formAjax({data:{folder_calc:'on'},init: function () { popup(1); },success:function (data) { popup(0); reloadGed(data); if(trigger.isChildOf('#gedToolbox')) gedToolbox.setReload(trigger); },error:function (data) { popup(error,{buttonOK:true,type:'error'}); }}); }); },width:600}); } function gedPlus_lockFile(key,lock,trigger) { if(trigger===undefined) trigger=$(); else if(!(trigger instanceof jQuery)) trigger=$(trigger); if(trigger.data('unlockMessage')!='' && !confirm(trigger.data('unlockMessage'))) return false; popup(1); kAjax('ajax_gedPlus_misc.htm',{ i_key:key, act_GED:'archive_'+(lock?'':'un')+'lock' },function () { //ok if(lock) $('#archive'+key).addClass('locked'); else $('#archive'+key).removeClass('locked'); kMessageBox.send(lock?'Fichier verrouillé':'Fichier déverrouillé'); if(trigger.isChildOf('#gedToolbox')) gedToolbox.reload('tab-edit'); else if(trigger.isChildOf('.submenu')) trigger.closest('.submenu').removeClass('loaded'); popup(0); },function (error) {//error popup(0); kMessageBox.send(error,{type:'error'}); }); } function gedPlus_uploadFile(key,trigger) { if(!(trigger instanceof jQuery)) trigger=$(trigger); var alias=false; if(trigger.isChildOf('#gedToolbox')) { alias=(gedToolbox.getParam('hasAlias')==1); rn=gedToolbox.getParam('record'); } else if(trigger.isChildOf('.submenu')) { alias=(trigger.data('hasAlias')==1); rn=getRN(); } if(alias) { if(!confirm('Attention : Ce document a des alias dans la base. Si vous le modifiez, tous les alias seront modifiés. Voulez-vous continuer ?')) return false; } sendFiles({params:{i_key:key,act_GED:trigger.data('act')},oneFile:true,context:'rn'+rn}); } function toolboxDefaultActions() { // trigger form upload gedToolbox.action('triggerFile',function (e) { gedPlus_uploadFile(gedToolbox.getParam('iKey'),this); }); //makeAlias gedToolbox.action('makeAlias',function(e) { popup(1); kAjax('ajax_gedPlus_misc.htm',{ i_key:gedToolbox.getParam('iKey'), act_GED:'create_alias' },function () { //ok popup('L\\\'alias a été créé et placé dans votre zone de transfert, onglet \"Mes Alias\".',{buttonOK:true,type:'info',title:'Alias créé'}); },function (error) { //error popup(error,{buttonOK:true,type:'error'}); }); }); //lock/unlock file gedToolbox.action('lock',function (e) { var iKey=gedToolbox.getParam('iKey'); var lock=!$(e.currentTarget).is('.contents.locked *'); gedPlus_lockFile(iKey,lock,this); }); //lock/unlock folder gedToolbox.action('folderLock',function (e) { popup(1); var elt=$(e.currentTarget); var iKey=gedToolbox.getParam('iKey'); var lock=(elt.data('act')!='unlock'); kAjax('ajax_gedPlus_misc.htm',{ ikeys:elt.data('keys'), act_GED:'folder_'+(lock?'':'un')+'lock', folder_code:gedToolbox.getParam('folderCode'), record:gedToolbox.getParam('record') },function () { //ok var row=gedToolbox.getTarget().closest('li.folder'); if(row.length==0) row=$('.gedPlus li.folder.root'); if(lock) row.find('.file').addClass('locked'); else row.find('.file').removeClass('locked'); gedToolbox.reload('tab-edit'); gedToolbox.reset(row.find('.file .toolboxOpener')); popup(0); },function (error) {//error popup(error,{buttonOK:true,type:'error'}); }); }); //delete file gedToolbox.action('deleteFile',function (e) { gedToolbox.show(false); if(confirm('Êtes-vous sûr de vouloir supprimer ce fichier ?'+(gedToolbox.getParam('hasAlias')==1?' Il a des alias dans la base, qui seront également supprimés.':''))) { popup(1); kAjax('ajax_gedPlus_misc.htm',{ act_GED:'delete_file', i_key:gedToolbox.getParam('iKey'), folder_calc:'on' },function (data) { var row=gedToolbox.getTarget().closest('li'); row.animate({opacity:0},200,function () { row.remove(); reloadGed(data); popup(0); }); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); //end ajax } }); //edit Properties gedToolbox.action('fileProperties,folderProperties',function (e) { var key=gedToolbox.getParam('iKey'); if(key===null) key=gedToolbox.getParam('folderKey'); popup('popup_gedPlus_properties.htm?i_key='+key,{callback:function () { //tags $('#modalPopup .tags').on('click','a',function () { var alt=$(this).data('alt'); $(this).data('alt',$(this).attr('title')).attr('title',alt); var input=$('#modalPopup input[name="tag_del"]'); if($(this).is('.deleted')) input.val(input.val().replace($(this).data('val'),'')); else input.val(input.val()+';'+$(this).data('val')); $(this).toggleClass('deleted'); }); //send form $('#gedPlus_editPropertiesPopup input[type="submit"]').one('click',function (e) { e.preventDefault(); var url=$('#gedPlus_editPropertiesPopup').kSerialize(); url+='&folder_calc=on'; popup(1); kAjax('ajax_gedPlus_misc.htm',url,function (data) { reloadGed(data); popup(0); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); }); },width:600}); }); // END edit properties //rename file/folder gedToolbox.action('rename',function (e) { var elt=gedToolbox.getTarget().closest('li').find('.title').first(); gedRenameItem(elt); }); //rename path_fichier gedToolbox.action('renameO',function (e) { var elt=$(e.currentTarget); popup(elt.next('.popupDiv'),{callback:function () { $('#modalPopup .submit input[type="submit"]').one('click',function () { var val=$('#modalPopup input[type="text"]').val(); popup(1); kAjax('ajax_gedPlus_misc.htm',{ i_key:gedToolbox.getParam('iKey'), act_GED:'ged_up_Nom_F', archive_Nom_F:val },function () { popup('Modification effectuée',{buttonOK:true,type:'info'}); elt.next('.popupDiv').find('input[type="text"]').val(val); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); }); }}); }); //modify tags gedToolbox.action('modifyTags',function (e) { var elt=gedToolbox.getTarget().closest('li').find('.tags').first(); tags=elt.children('span'); var val=''; tags.each(function (i) {val+=(i==0?'':' ; ')+$(this).text();}); var input = $(''); input.data('val',val).val(val+' ; '); elt.html('').append(input).appendSubmit(); gedToolbox.show(false); input.focus(); }); //new folder gedToolbox.action('newFolder',function (e) { popup(1); var dName='Nouveau dossier'; // increment name if already exists while($('.gedPlus .folder>div>.title:contains("'+dName+'")').length>0) { var r=dName.match(/^(.+)([0-9]+)$/); if (r===null) dName=dName+' 1'; else dName=r[1]+(Number(r[2])+1); } kAjax('ajax_gedPlus_misc.htm',{ all_ged_folder:'on', record:gedToolbox.getParam('record'), act_GED:'folder_create', folder_code:gedToolbox.getParam('folderCode'), folder_nom:dName },function (data) { var nelt=$(data); var row=gedToolbox.getTarget().closest('li.folder'); if(row.length==0) row=$('.gedPlus li.folder').first(); if(row.children('.folderlist').length==0) row.append('
      '); if(!row.is('.opened')) row.find('.caret').first().click(); row.children('.folderlist').prepend(nelt); popup(0); $(window).scrollTo(nelt); gedRenameItem(nelt.find('.title').first()); },function (error) { //error popup(error,{buttonOK:true,type:'error',title:'Impossible de créer le dossier'}); }); }); //delete Folder gedToolbox.action('deleteFolder',function (e) { var elt=$(e.currentTarget); if(confirm(elt.data('msg'))) { var row=gedToolbox.getTarget().closest('.folder'); if(row.length==0) row=$('.gedPlus li.folder.root'); var all=(elt.data('folder')=='all'); kAjax('ajax_gedPlus_misc.htm',{ record:gedToolbox.getParam('record'), act_GED:'folder_delete'+(all?'all':''), folder_key:gedToolbox.getParam('folderKey'), folder_code:gedToolbox.getParam('folderCode'), folder_calc:'on' },function (data) { gedToolbox.show(false); if(row.is('.local')) var anim=row; else anim=row.find('li.file,li.folder.local'); anim.animate({opacity:0},200,function () { if(!all) { //move content - folders row.closest('.folderlist').append(row.find('.folderlist>li')); //move content - files if(row.find('.filelist').length>0) { var dest=row.parents('.folder').first(); dest=dest.children('.filelist'); dest.append(row.find('.filelist>li')); } } reloadGed(data); }); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); //end ajax } }); //new folder gedToolbox.action('newFolder',function (e) { popup(1); var dName='Nouveau dossier'; // increment name if already exists while($('.gedPlus .folder>div>.title:contains("'+dName+'")').length>0) { var r=dName.match(/^(.+)([0-9]+)$/); if (r===null) dName=dName+' 1'; else dName=r[1]+(Number(r[2])+1); } kAjax('ajax_gedPlus_misc.htm',{ all_ged_folder:'on', record:gedToolbox.getParam('record'), act_GED:'folder_create', folder_code:gedToolbox.getParam('folderCode'), folder_nom:dName },function (data) { var nelt=$(data); var row=gedToolbox.getTarget().closest('li.folder'); if(row.length==0) row=$('.gedPlus li.folder').first(); if(row.children('.folderlist').length==0) row.append('
        '); if(!row.is('.opened')) row.find('.caret').first().click(); if(row.children('.folderlist').find('li.folder:not(.local)').length>0) row.children('.folderlist').find('li.folder:not(.local)').first().before(nelt); else row.children('.folderlist').append(nelt); popup(0); $(window).scrollTo(nelt); gedRenameItem(nelt.find('.title').first()); },function (error) { //error popup(error,{buttonOK:true,type:'error',title:'Impossible de créer le dossier'}); }); }); gedToolbox.action('sortFolder',function (e) { var fKey=gedToolbox.getParam('folderKey'); if(fKey===undefined) fKey=''; var fCode=gedToolbox.getParam('folderCode'); if(fCode===undefined) fCode=''; var record=gedToolbox.getParam('record'); var $rootList=$(); function sortFolderDoSort() { var $root=$('#gedPlus_sortPopup'); $root.children('ul').html($rootList.html()); //reinitialize sort order var opt={ recurse:$root.find('[name="gedPlusSortChildren"]').is(':checked'), folders:$root.find('[name="gedPlusSortFolders"]').is(':checked'), sortBy:$root.find('[name="gedPlusSort"]:checked').val(), desc:($root.find('[name="gedPlusSortDesc"]').is(':checked')?-1:1) }; var $elts=$(); if(opt.recurse) $elts=$root.children('ul').find('li'); else $elts=$root.children('ul').children('li'); var filter='.folder'+(opt.folders?':not(.local)':''); var $sorted=$elts.not(filter).sort(function (a,b) { var sort=''; switch(opt.sortBy) { case 'name':sort='name';break; case 'cDate':sort='date';break; case 'aDate':sort='id';break; } if($(a).is('.folder') && !$(b).is('.folder')) return 1; else if(!$(a).is('.folder') && $(b).is('.folder')) return -1; else if ($(a).data(sort)<$(b).data(sort)) return -opt.desc; else if($(a).data(sort)>$(b).data(sort)) return opt.desc; else return 0; }); $sorted.each(function () { $(this).closest('ul').append($(this)); }) $elts.filter(filter).each(function () { $(this).closest('ul').append($(this)); }); if(opt.recurse) { $root.find('li.folder').removeClass('hide'); popupResize({width:800}); } else $root.find('li.folder').addClass('hide'); } popup('ajax_gedPlus_sort.htm?record='+record+'&folder_key='+fKey+'&folder_code='+fCode+'&act_GED=sortFolder',{ buttonOK:true, buttonCancel:true, width:800, callback:function () { $rootList=$('#gedPlus_sortPopup').children('ul').clone(); $('#gedPlus_sortPopup').find('li.folder').addClass('hide'); $('#gedPlus_sortPopup').on('change','input',sortFolderDoSort); }, onOK:function () { var $root=$('#gedPlus_sortPopup'); var data={ act_GED:'sortFolder', record:record, folder_key:fKey, folder_code:fCode, recurse:($root.find('[name="gedPlusSortChildren"]').is(':checked')?'1':'0'), sortFolders:($root.find('[name="gedPlusSortFolders"]').is(':checked')?'1':'0'), sortBy:$root.find('[name="gedPlusSort"]:checked').val(), desc:($root.find('[name="gedPlusSortDesc"]').is(':checked')?'1':'0'), folder_calc:'on' }; popup(1); kAjax('ajax_gedPlus_misc.htm',data,function (data) { reloadGed(data); popup(0); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); } }); }); // add to folder gedToolbox.action('addToFolder',function () { sendFiles({ context:'rn'+gedToolbox.getParam('record')+'_'+gedToolbox.getParam('folderCode'), url:'this', fileTypes:gedToolbox.getParam('fileTypes') }); }); //new from Template gedToolbox.action('newFromT',function () { popup('popup_GedPlus_AddFromTemplate.htm?Record='+gedToolbox.getParam('record')+'&Xidlist='+gedToolbox.getParam('idlist')+'&AFolder='+encodeURIComponent(gedToolbox.getParam('folderCode')),{ width:800, height:'90%', callback:function () { searchTemplates(); var sTemplatePopup=null; //select files $('#gpTemplatePopup').on('click','li:not(.header,.inactive)',function () { if($(this).is('.searchResults *')) { $(this).clone(true).appendTo($('#modalPopup form')); $(this).addClass('inactive'); } else { $(this).closest('#modalPopup').find('.searchResults input[name="'+$(this).find('input[type="checkbox"]').attr('name')+'"]').closest('li').removeClass('inactive'); $(this).remove(); } }); //search function $('#modalPopup input[name="what"]').on('keyup',function (e) { clearTimeout(sTemplatePopup); sTemplatePopup=setTimeout(searchTemplates,200); }); function searchTemplates() { var box = $('#modalPopup .searchResults'); box.kLoader(); var selected=';'; $('#modalPopup form li input[type="checkbox"]').each(function () { selected+=$(this).attr('name')+';' }); box.load('ajax_addFromTemplate.htm?what='+$('#modalPopup input[name="what"]').val()+'&selected='+selected); } }}); // END popup }); // DEUS gedToolbox.action('deus',function (e) { if(typeof deus == 'object') { deus.sendFile($(e.currentTarget)); } }); gedToolbox.action('newWorkflow',function (e) { var iKey=gedToolbox.getParam('iKey') || ''; Newwindow('wf_actions_edit.htm?K2_act=actionG_add&i_key='+iKey+'&record='+gedToolbox.getParam('record'),'','height=680,width=850,menubar=no,resizable=yes,scrollbars=yes'); }); gedToolbox.action('editWorkflow',function (e) { Newwindow('wf_actions_edit.htm?K2_act=actionG_2mod&i_key='+gedToolbox.getParam('iKey')+'&record='+gedToolbox.getParam('record')+'&actionG_key='+$(e.currentTarget).closest('.gedFlow>div').attr('id').substr(6),'','height=680,width=850,menubar=no,resizable=yes,scrollbars=yes'); }); gedToolbox.action('histoWorkflow',function (e) { var archive=gedToolbox.getParam('iKey'); var recnum=gedToolbox.getParam('record'); wfOpenHistory(recnum,archive); }); gedToolbox.action('cancelWorkflow',function (e) { var archive=gedToolbox.getParam('iKey'); var recnum=gedToolbox.getParam('record'); popup('popup_wf_actions.htm?K2_act=actionG_2annul&i_key='+archive+'&record='+recnum,{width:600}); }); gedToolbox.action('remindWorkflow',function (e) { var archive=gedToolbox.getParam('iKey'); var recnum=gedToolbox.getParam('record'); var action_id=$(e.currentTarget).closest('[id^="action"').attr('id').substr(6); window.open('wf_actions_relance.htm?K2_act=actionG_2relance&i_key='+archive+'&record='+recnum+'&actionG_key='+action_id,'','height=680,width=850,menubar=no,resizable=yes,scrollbars=yes'); }); gedToolbox.action('wfRead',function (e) { var id=$(e.currentTarget).closest('div[data-id]').data('id'); popup('popup_wf_actions.htm?action_key='+id+'&K2_act=read',{width:1000,height:'90%',callback:function () { if($('#wfPopupRead .nav').length>0) { //set up multiple files let $list=$('#wfPopupRead .nav~input[type=hidden]:not([value=""])'); let iframe=document.querySelector('#wfPopupRead iframe'); let counter=document.querySelector('#wfPopupRead .nav .num'); let $nav=$('#wfPopupRead .nav a'); $nav.first().addClass('inactive'); iframe.onload=function () {iframeResize(iframe);}; iframe.src=$list.first().val(); $list.first().remove(); $list=$list.slice(1); counter.innerHTML='1'; $('#wfPopupRead .nav').on('click','a:not(.inactive)',function (e) { if($(this).is(':first-child')) {//prev $('#wfPopupRead iframe:not(.hide)').prev('iframe').removeClass('hide').siblings('iframe').addClass('hide'); if($('#wfPopupRead iframe:not(.hide)').is(':first-of-type')) $nav.first().addClass('inactive'); $nav.last().removeClass('inactive'); counter.innerHTML--; } else {//next let $ifr=$('#wfPopupRead iframe:not(.hide)').next('iframe'); if($ifr.length===0 && $list.length>0) { //load next iframe let $ifr=$(iframe).clone(0,0); $ifr.attr('src',$list.first().val()).removeClass('hide'); $ifr[0].onload=function () {iframeResize($ifr);}; $list.first().remove(); $list=$list.slice(1); $('#wfPopupRead iframe').addClass('hide').last().after($ifr); if($list.length===0) $nav.last().addClass('inactive'); } else { $ifr.removeClass('hide').siblings('iframe').addClass('hide'); if($('#wfPopupRead iframe:not(.hide)').is(':last-of-type') && $list.length===0) $nav.last().addClass('inactive'); } $nav.first().removeClass('inactive'); counter.innerHTML++; } }); } else { ifr=document.querySelector('#wfPopupRead iframe'); if(ifr!==null) ifr.onload=function () {setTimeout(function () { let $popup=$('#modalPopup .contents'); let h=$popup.height() - $popup.children('.header').outerHeight() - parseInt($popup.children('.header').css('margin-bottom')); ifr.style.height=h+'px'; },400)}; } // set buttons $('#wfPopupRead').on('click.wfPopup','.buttons button[class]',function (e) { e.preventDefault(); popup(1); kAjax('ajax_workflow.htm',{ action_key:id, K2_act:'status_'+($(this).is('.read')?'done':'cancel') },function () { popup(0); gedToolbox.reload('tab-workflow'); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); //END ajax $('#wfPopupRead').off('click.wfPopup'); }); }}); }); //END wfRead gedToolbox.action('wfComment',function (e) { var id=$(e.currentTarget).closest('div[data-id]').data('id'); popup('popup_wf_actions.htm?action_key='+id+'&K2_act=comment',{width:600,height:'80%',buttonCancel:true,buttonOK:'Enregistrer',callback:function () { setTimeout(function () {$('#modalPopup textarea').makeCke();},300); //wait for popup animation to complete },onOK:function () { var val=CKEDITOR.instances.evt_com.getData(); //$('#wfPopupCom textarea').val(); popup(1); kAjax('ajax_workflow.htm',{ action_key:id, K2_act:'status_done', evt_com:val },function () { popup(0); gedToolbox.reload('tab-workflow'); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); }}); }); //END wfComment gedToolbox.action('wfContribute',function (e) { var id=$(e.currentTarget).closest('div[data-id]').data('id'); sendFiles({oneFile:true,context:'workflow_action_'+id}); }); gedToolbox.action('wfSign',function (e) { var id=$(e.currentTarget).closest('div[data-id]').data('id'); popup('popup_wf_actions.htm?action_key='+id+'&K2_act=sign',{width:500,callback:function () { //select button on focus in textarea $('#wfPopupSign').on('focus','textarea',function (e) {$(this).closest('label').click();}); // enable submit when a selection is made $('#wfPopupSign').on('change','input[type="radio"]',function () { var $button=$('#wfPopupSign input[type="submit"]'); $button.removeAttr('disabled'); $button.val($(this).attr('title')); }); $('#wfPopupSign').on('click','input[type="submit"]',function (e) { var val=$('#wfPopupSign input:checked').val(); var com=$('#wfPopupSign textarea').val(); if(val=='statut_valid') com=''; //com is only used for denial popup(1); var data={ action_key:id, K2_act:'status_done', evt_com:com }; if(val==='cancel') data.K2_act='status_cancel'; else data.sign=val; kAjax('ajax_workflow.htm',data,function () {//success popup(0); gedToolbox.reload('tab-workflow'); },function (error) { //error popup(error,{buttonOK:true,type:'error'}); }); }); }}); }); gedToolbox.action('wfApply',function (e) { var id=$(e.currentTarget).closest('div[data-id]').data('id'); popup(1); kAjax('ajax_workflow.htm',{action_key:id,K2_act:($(this).is('.action1.done *')?'status_cancel':'status_done')},function () { popup(0); gedToolbox.reload('tab-workflow'); },function (error) { kMessageBox.send(error); }); }); gedToolbox.action('closeWorkflow',function (e) { var archive=gedToolbox.getParam('iKey'); var recnum=gedToolbox.getParam('record'); var action_id=$(e.currentTarget).closest('[id^="action"').attr('id').substr(6); popup('popup_wf_actions.htm?K2_act=actionG_close&i_key='+archive+'&record='+recnum+'&actionG_key='+action_id,{width:600}); }); //directLink gedToolbox.action('directLink',function (e) { popup('popup_geideDirect.htm?arckey='+gedToolbox.getParam('iKey'),{width:400}); }); } // END toolbox actions function gedRenameItem(elt) { var input=$(''); var val=elt.text(); elt.data('val',val); input.val(val); elt.html('').append(input).appendSubmit(); gedToolbox.show(false); input[0].select(); } function ged_unlock() //sent unlock request to server on page unload { if(window.location.pathname.toLowerCase().indexOf('/record.htm')>=0) { var record=getRN(); $(window).on('beforeunload',function () { $.ajax('engine/Record_lock.htm',{ async:false, data:'lock=off&record='+record+'&ID='+kParams.ident }); }); } } function dropFilesFromDesktop() { if(typeof DD==='undefined') return true; $(document).dropTargets('.section .article[id^="record"]'); $(document).dropTargets('.gedPlus .folder>div',{forbidden:function (files) { if($(this).closest('.folder').data('types')==='none') return false; else if($(this).closest('.folder').data('types')==='') return true; return true; }}); } function miniLoad(args) //load minified transit { if(args===undefined) args={}; args.xrecord=$('#menu_k2').attr('data-record'); var wrap=$('#transitMini>.wrapper'); wrap.kLoader(); kAjax('ajax_gedPlus_mini.htm',args,function (data) { wrap.html(data); },function (error) { popup(error,{buttonOK:true,type:'error'}); }); } function miniUpload() //open sendFiles window on click { $('body').on('click', '#menu_k2 #transitMini .kent-ico[href="#sendFiles"]',function (e) { e.preventDefault(); var page=location.pathname.toLowerCase(); var args={url:location.toString()}; // if(page=='/record.htm') args.context='rn'+$('#menu_k2').attr('data-record'); //deactivated 04/05/2018 sendFiles(args); }); } function miniTabs() // click on tabs in minified transit { $('body').on('click','#menu_k2 #transitMini .transit-tabs a',function (e) { e.preventDefault(); $('#transitMini>.wrapper').kLoader(); miniLoad(clearIP($(this).attr('href')).replace(/^\?/,'')); }); } function wfOpenHistory(recnum,archive) { popup('popup_wf_actions.htm?K2_act=listactions&record='+recnum+'&i_key='+archive,{width:'90%',callback:function () { $('#modalPopup table input').tableFilter({ dates:'d', calc:function (txt) { if($(this).data('filter')) return $(this).data('filter'); else return txt; } }); $('#modalPopup .wfHisto').on('click','.logs label',function (e) { e.preventDefault(); $(this).next('table').toggleClass('hide'); changeIcon(this.querySelector('.kent-ico'),'plus-thin','minus'); if(!$(this).next('table').is('.widthCalculated') && false) { $(this).next('table').addClass('widthCalculated').find('th').each(function () { $(this).css('width',$(this).css('width')); }); } }); }}); } function wfTagClick () { $('.wfDash').on('click','table .flowTags>span',function(e) { if($(this).data('href')!==undefined) //only if data-href is set { window.location=$(this).data('href'); return false; } }); } function wfCheckDashWidth() { (checkWfDashWidth=function() { $('.wfDash').each(function () { if($(this).width() < 400) { $(this).addClass('narrow'); $(this).find('.label').each(function () { $(this).closest('a').attr('title',$(this).text()); }); } if($(this).width() >= 400) { $(this).removeClass('narrow'); $(this).find('.label').each(function () { $(this).closest('a').attr('title',''); }); } }); })(); $(window).on('resize',checkWfDashWidth); } function menuK2() { menuK2_goTo(); $('#menu_k2').on('click','#menu_k2_nav a',function (e) { e.preventDefault(); if($(this).attr('href')=='#next') face=$('#menu_k2_nav>span.active').nextAll('span').not('.inactive').index('#menu_k2_nav>span'); else face=$('#menu_k2_nav>span.active').prevAll('span').not('.inactive').index('#menu_k2_nav>span'); menuK2_goTo(face); }); } //END menuK2 function menuK2_goTo(face) { if($('#menu_k2').length==0) return false; var idlist=kParams.idlist; var record=$('#menu_k2').attr('data-record'); var init=false; var resize=($('#menu_k2_nav a.active').index('#menu_k2_nav a')===face) if(face===undefined) { init=true; if(idlist==0) face=0; else if(record=='') face=1; else face=2; $('#menu_k2').siblings().addClass('hide'); } face=Number(face); //deactivate faces as required if(idlist==0 || record!='' || $('#listRecord #listNoContent').length>0) $('#menu_k2_nav span:nth-child(2)').addClass('inactive'); else $('#menu_k2_nav span:nth-child(2)').removeClass('inactive'); if(record=='' || idlist==0) $('#menu_k2_nav span:nth-child(3)').addClass('inactive'); else $('#menu_k2_nav span:nth-child(3)').removeClass('inactive'); function resizeMenu() { /* deleted */ } //load face if not loaded if($('#menu_k2 #menu_k2_'+Number(face+1)).length==0) { $('#menu_k2 .menuWrapper').kLoader('Chargement en cours…',false); //categories var cat=window.location.toString().match(/((&|\?)sublist_[0-9]+=on)+(&comb=[0-9])?/i); if(cat!==null) cat='&'+cat[0].substr(1); else cat=''; kAjax('ajax_menu_K2.htm?tab='+Number(face+1)+'&idlist='+idlist+'&xrecord='+record+'&reload='+(kGetParam('reload')?'on':'')+cat,'',function (data) { $('#menu_k2 .loader').remove(); if(init) $('#menu_k2').siblings(':not(.noK2)').remove(); $('#menu_k2 .menuWrapper').append(data).find('.noK2').remove(); resizeMenu(); if($('#menu_k2_'+Number(face+1)).length==0 && face>0) { if(face==1) kParams.idlist=0; else if(face==2) $('#menu_k2').attr('data-record','') menuK2_goTo(face-1); } },function (error) { popup(error,{type:'error',title:'Impossible de charger le menu gauche',buttonOK:true}); if(init) $('#menu_k2').siblings().removeClass('hide'); $('#menu_k2 .loader').remove(); }); } // switch face var counter=0; $('#menu_k2_nav>span').removeClass('active').eq(face).addClass('active'); $('#menu_k2 .section').addClass('hide').filter('#menu_k2_'+Number(face+1)).removeClass('hide'); $('#menu_k2_nav a.inactive').removeClass('inactive'); if(face==0) $('#menu_k2_nav a:first-of-type').addClass('inactive'); if($('#menu_k2_nav>span.active').nextAll('span:not(.inactive)').length==0) $('#menu_k2_nav a:nth-of-type(2)').addClass('inactive'); }// END menuk2_goTo function reloadGed(data,callback) { if(arguments.length==1 && typeof data=='function') { callback=data; data=undefined; } var open=[]; $('.gedPlus .folder.opened').each(function () { if($(this).data('key')!='') open.push('key:'+$(this).data('key')); else open.push('code:'+$(this).data('code')); }); var scroll=$(window).scrollTop(); if(data!==undefined) { $('.gedPlus').html(data); resetPos(); if(typeof callback=='function') callback(); } else { popup(1); kAjax('ajax_gedPlus_misc.htm','folder_calc=on&record='+getRN(),function (data) { $('.gedPlus').html(data); popup(0); resetPos(); if(typeof callback=='function') callback(); },function (error) { popup(error,{buttonOK:true,type:'error'}) }); } function resetPos() { $('.gedPlus .folder').removeClass('opened').each(function () { if(($(this).data('key')=='' && array_find(open,'code:'+$(this).data('code'))>=0) || array_find(open,'key:'+$(this).data('key'))>=0) $(this).addClass('opened'); }); $(window).scrollTop(scroll); } } //END reloadGed function kaOpenSettings() { $('#kentApps').on('click','.settingsOpener',function () { var box=$(this).closest('.kentApp'); var show=!box.find('.settings').is(':visible'); var t=0.2; box.css({ transition:'transform '+(t/2)+'s', transform:'rotateY(90deg)' }); setTimeout(function () { box.find('.settings').css({display:(show?'block':'')}); box.css({'border-width':(show?'0':'')}); box.css({ transition:'transform '+(t/2)+'s', transform:'rotateY(0deg)' }); },t/2*1000); //close settings if (show) setTimeout(function () { $('body').on('click.closeSettings'+box[0].id,function (e) { if(!$(e.target).isChildOf(box) && !$(e.target).isChildOf('#modalPopup')) { $('body').off('click.closeSettings'+box[0].id); box.find('.settingsOpener').trigger('click'); } }); },300); }); } function kaActions() { //reorder $('#kentApps').on('click','.kentApps_order input[type="submit"]',function () { var app=$(this).closest('.kentApp'); var order=$(this).closest('.kentApps_order').find('input[type="text"]').val(); if(order<=0) order=1; if(order==$('#kentApps .kentApp').index(app)+1) return true; var nextApp=$('#kentApps .kentApp').not(app).eq(order-1); if(nextApp.length>0) order=nextApp.data('order'); else order=$('#kentApps .kentApp').last().data('order')+1; if($('#kentApps .kentApp').last().is(app) && order>app.data('order')) return true; app.kentAppLoader(1); kAjax('ajax_KentApps_Setup.htm',{ KA_act:'app_order', app_num:app.data('id'), app_order:order, KA_User:$('body').data('ident') },function (data) { //success if(nextApp.length>0) nextApp.before(app); else $('#kentApps .kentApp').last().after(app); $('#kentApps .kentApp').each(function (i) { $(this).find('.kentApps_order input[type="text"]').val(i+1); }); var r=data.match(/modifier l'ordre : ([0-9.]+)/); if(r!==null) { nOrder=r[1]; app.data('order',nOrder); } app.kentAppLoader(0); },function (error) { //error app.kentAppLoader(0); popup(error,{type:'error',buttonOK:true}); }); }); //use "enter" while re-ordering $('#kentApps').on('keyup','.kentApp .kentApps_order input',function(e) { if(e.keyCode==13) $(this).closest('.kentApps_order').find('input[type="submit"]').trigger('click'); }); //other actions $('#kentApps').on('click','.kentApp .settings .actions a',function (e) { if(clearIP($(this).attr('href')).indexOf('#')!==0) return true; e.preventDefault(); var act=$(this).attr('href').substr(1); var app=$(this).closest('.kentApp'); switch (act) { case 'settings': kentApps_edit(app.data('id')); break; //END settings case 'disable' : kentApps_disable(app); break; //END disable case 'delete' : popup(1); kAjax('ajax_KentApps_Setup.htm','KA_Act=delete&app_num='+app.data('id'),function (data) { popup(0); app.remove(); },function (error) { popup(error,{type:'error',buttonOK:true}); }); break; //END delete } }); } $.fn.kentAppLoader=function (show) { $(this).each(function () { if(show === undefined) show=($(this).find('.loader').length==0); if (show) $(this).kLoader({type:'circle',replace:false}); else $(this).find('.loader').remove(); }); return $(this); }; function kentApps_edit(num) { var req='KA_act='; if(num===undefined) req+='new'; else req+='mod&app_num='+num; popup('ajax_KentApps_settings.htm?'+req,{width:'800px',height:'90%',callback:function () { showVars=function() { //kentApps variables if(typeof kentAppsVars==='undefined') return false; var cont=$('#KA_Display #KA_vars'); if(cont.length===0) { cont=$('
        '); $('#KA_Display').append(cont); } if(typeof kentAppsVars[$('#KA_Ressource')[0].selectedIndex]==='undefined') return false; var opts=kentAppsVars[$('#KA_Ressource')[0].selectedIndex]; opt=''; for(i in opts) { if(kentAppsVarsVals[opts[i].name]!==undefined) opts[i].value=kentAppsVarsVals[opts[i].name]; if(opts[i].value===undefined) opts[i].value=''; opt+='

        '; if(opts[i].type==='select') { opt+=''; } else if(opts[i].type==='radio' || opts[i].type==='checkbox') { var hasKeys=!(Array.isArray(opts[i].options)); for(j in opts[i].options) { if(typeof j==='number') j=[i].options[j]; opt+=''; } } else if(opts[i].type==='textarea' || opts[i].type==='cke') opt+=''; else opt+=''; opt+='

        '; } cont.html(opt); if(cont.find('textarea.cke').length>0) { w=$('#kentApps .kentApp[data-id='+num+']').width(); h=$('#kentApps .kentApp[data-id='+num+']').height()-$('#kentApps .kentApp[data-id='+num+'] h3:visible').first().height(); if(w===0) w=300; if(h===0) h=300; let css=[...document.querySelectorAll('link[rel="stylesheet"]')].filter(a=>a.getAttribute('href').match(/global\.css$/))[0].getAttribute('href'); cont.find('textarea.cke').makeCke({toolbar:[['Source'],['Bold','Italic','Underline'],['Format','FontSize','TextColor','BGColor'],['Link'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock']],width:w,height:h,stylesheets:css}); } }; (showCorpus=function(){ $('#kentApp_settings div[id^="corpus"]').css('display','none'); var corp=$('#KA_Corpus_1').val(); $('#corpus_'+corp+':not(.hide)').css('display',''); $('#KA_Display').css('display',(corp==''?'none':'')); $('#KA_Filters').css('display',(corp=='' || corp=='NONE'?'none':'')); $('#KA_Sort').css('display',(corp=='' || corp=='NONE' || corp=='SCR' || (corp=='TAB' && $('#corpus_TAB select').val().indexOf('TAB_83')===0)?'none':'')); $('#KA_Ressource option').not(':first-child').each(function () { var show=($(this).val()[0]==(corp=='NONE'?'0':'1')); $(this).css('display',show?'':'none'); }); $('#KA_Users').css('display',(corp==''?'none':'')); if($('#KA_Ressource option:selected').css('display')=='none') $('#KA_Ressource').val(''); //$('#KA_alert').css('display',corp=='NONE'?'none':''); //$('#KA_agenda').css('display',ressAttrs[1]=='1'?'':'none'); showVars(); })(); $('#KA_Corpus_1,#corpus_TAB select').on('change',showCorpus); $('#KA_Ressource').on('change',showVars); $('#kentApp_settings #KentAppSetup').on('submit', function (e) { //submit form e.preventDefault(); $('#kentApp_settings #KentAppSetup textarea.cke').each(function (){ this.value=CKEDITOR.instances[this.id].getData(); }); //cleanup users $('#KentAppSetup input[name="KA_Users_users"]').each(function () { this.value=this.value.split(/ ?[\/-] ?/).join('/'); }); var form=$(this).kSerialize(); popup(1); kAjax('ajax_KentApps_setup.htm',form,function (data) { popup(data,{type:'info',buttonOK:true,onOK:function () {window.location='Main.htm?AllApp='+kGetParam('AllApp');}}); }, function (error) { popup(error,{type:'error',buttonOK:true}); }); }); }}); } function kentApps_disable(app) { popup(1); kAjax('ajax_KentApps_Setup.htm','KA_Act=active&app_num='+app.data('id')+'&KA_User='+$('body').data('ident'),function (data) { popup(0); var active=!(data.indexOf('désactiv')>0); if(!active && !$('#kentApps').is('.settingsMode')) app.remove(); else if(!active) app.addClass('inactive'); else app.removeClass('inactive'); app.find('.settings a[href=#disable]').switchButton(); },function (error) { popup(error,{type:'error',buttonOK:true}); }); } function kaResize () { var timer=null; $('#kentApps').kOnWinResize(function () { if (isIE) return true; var kentapps=$('#kentApps>.kentApp'); if(kentapps.length==0) return true; var mw=parseInt(kentapps.first().css('min-width')); var tw=$('#kentApps').innerWidth(); var c=getComputedStyle(document.querySelector('#kentApps')).getPropertyValue('--kentAppCount'); var y=kentapps.first().position().top; var nb=1; while(nb (mw * (nb+1) + 9 * nb) && (nb.kentApp').each(function () { let data=$(this).data('kentAppCarousel'); if(data && !data.isset) { $(this).setCarousel(data); data.isset=true; $(this).data('kentAppCarousel',data); } }); }); $(window).trigger('resize'); } // declare carousel on kentApps $.fn.kentAppsCarousel = function (args) { if(arguments.length===0) args={}; if(args.wrapper===undefined) args.wrapper=$(this).find('ul').first(); if(args.delay===undefined) args.delay=3; $(this).data('kentAppCarousel',args); return this; }; function DEUS() { var serverPort = 53387; var myClass=this; this.sendFile=function (link) { popup(1); var msg = { uuid: link.attr('data-uuid'), url: kParams.deusURL+ link.data('link'), displayName: link.data('fileName'), siteUuid: link.data('siteUuid'), siteDisplayName: link.data('siteDisplayName') }; var ajaxTimer=setTimeout(function () { popup('popup_deus_open.htm?mode=launch',{callback:function () {$('#modalPopup .submit .ok').on('click',function () {myClass.sendFile(link);});},width:800}); },2000); $.ajax({ url : 'http://localhost:' + serverPort + '/manage', data: msg, dataType: "jsonp", jsonp: 'jsonp', contentType: 'application/json; charset=utf-8', success:function(data) { clearTimeout(ajaxTimer); popup('popup_deus_open.htm',{width:800}); }}); } } var deus=new DEUS(); function team_updateRole(sel) { var mess=sel.data('confirm'); if(sel.val() < sel.closest('li').data('roleInherit') && sel.val()>0) mess+='\r\n'+sel.data('confirm-lower').replace('$',sel.find('option:selected').text()); if(confirm(mess)) { var attrs=sel.closest('form').kSerialize(); kAjax('team_updaterole.htm',attrs,function (data) { kMessageBox.send(data); if(sel.closest('.wfTeamMembers>li').find('.title').find('.warningTeamMod').length==0) sel.closest('.wfTeamMembers>li').find('.title').first().append('0'); },function (error) { kMessageBox.send('Mise-à-jour du rôle : '+error); sel.find('option[selected]').prop('selected',true); }); } else sel.find('option[selected]').prop('selected',true); } function menuClassement() { function rewrite(data) { var newPlan=$('
        '+data+'
        ').find('#menu_folderView'); var opened=[]; var scroll=$(document).scrollTop(); var plan=$('#menu_folderView'); plan.find('li').each(function () { if($(this).is('.opened')) opened.push($(this).attr('data-rn')); }); newPlan.find('li').each(function () { if(opened.indexOf($(this).attr('data-rn'))>=0) $(this).addClass('opened'); }); plan.replaceWith(newPlan); $(document).scrollTop(scroll); } function newFolder(elt) { $().modalShow(0); var newLine=$('
      • Nouveau dossier
      • '); var folder=elt.closest('li'); if(!folder.is('.opened')) folder.addClass('opened'); if(folder.children('ul').length==0) folder.append('
          '); folder.children('ul').prepend(newLine); var lib=newLine.find('.lib'); lib.makeField({confirm:function (val) { popup(1); kAjax('ajax_Classification_act.htm',{act:'SubfolderAdd',team:folder.closest('.team').attr('data-rn'),linkto:folder.attr('data-rn'),subfolderLib:val},function (data){ popup(0); rewrite(data); lib.html(val); },function (error) { popup(error,{title:'Error',type:'error',buttonOK:true}); newLine.remove(); }); },cancel:function (val) { newLine.remove(); } }); } //END newFolder function rename(elt) { var folder=elt.closest('li'); var lib=folder.find('.lib').first(); var oldVal=lib.text(); $().modalShow(0); lib.makeField({confirm:function (val) { lib.html(val); kAjax('ajax_Classification_act.htm',{act:'SubfolderRename',team:folder.closest('.team').attr('data-rn'),recnum:folder.attr('data-rn'),subfolderLib:val},function (data){ kMessageBox.send('Dossier renommé : '+oldVal+' > '+val); },function (error) { popup('Impossible de renommer le dossier '+oldVal+'
          '+error,{title:'Error',type:'error',buttonOK:true}); lib.html(oldVal); }); }}); } //END rename function del(elt) { popup(1); var folder=elt.closest('li'); var lib=folder.find('.lib').first(); kAjax('ajax_Classification_act.htm',{act:'SubfolderDelete',team:folder.closest('.team').attr('data-rn'),recnum:folder.attr('data-rn')},function (data){ popup(0); rewrite(data); folder.remove(); },function (error) { popup(error,{title:'Error',type:'error',buttonOK:true}); }); } //END delete $(document).on('click','#menu_folderView',function (e) { var elt=$(e.target); if(elt.is('.caret')) { e.preventDefault(); var li=elt.closest('li'); if(li.is('.opened')) //close li.children('ul').slideUp(function () {li.removeClass('opened');}); else //open li.children('ul').slideDown(function () {li.addClass('opened');menuK2_goTo(0);}); } else if(elt.closest('.optionsTrigger').length==1) { e.preventDefault(); elt.closest('li').children('.options').modalShow({menu:true}); } else if(elt.is('.options a *')) { //actions elt=elt.closest('a'); if(elt.data('act')===undefined) { if (elt.attr('href').match(/^\/?listrecord\.htm/i)) { elt.closest('li').addClass('active'); ajax_loadList(elt.attr('href')); } else return true; } e.preventDefault(); switch(elt.data('act')) { case 'new' : newFolder(elt);break; case 'rename' :rename(elt);break; case 'delete':del(elt);break; case 'addFile':sendFiles({context:'classification_'+elt.closest('.team').attr('data-rn')+'_'+elt.closest('li').attr('data-pc-rn')}); } } else if(elt.is('li>a *')) //click on link { e.preventDefault(); elt=elt.closest('a'); if(elt.find('.lib input').length>0) { //if new folder name not saved yet var evt=$.Event('keydown'); evt.keyCode=13; elt.find('.lib input').trigger(evt); return false; } $('#menu_folderView li.active').removeClass('active'); elt.closest('li').addClass('active'); var link=elt.attr('href'); ajax_loadList(link); } }); //END click kOnPopState(function (e) { if (e.state!== null && e.state.ajaxLoadList) ajax_loadList(window.location.toString(),false); else return true;//window.location=window.location.toString(); }); } //END menuClassement function ajax_loadList(url,pushState) { if(pushState===undefined) pushState=true; var list=(url.match(/listrecord\.htm/i)!==null); if(window.ajaxLoadQueue===undefined) window.ajaxLoadQueue={time:0,id:0}; //prevent double click : var d=new Date(); if(d.getTime() - window.ajaxLoadQueue.time < 500) return true; if(getRN()>0) $(document).trigger('recordUnload');//unlock record if required window.ajaxLoadQueue.time=d.getTime(); window.ajaxLoadQueue.id++; var queue=window.ajaxLoadQueue.id; if(!list && window.ajaxLoadRecordInit === undefined) { //insert css first time for record var styles=$('link[href$="styles.css"]'); styles.after(''); window.ajaxLoadRecordInit=true; } //prepare loader $('#rightCol,#breadcrumb,#mainCol>.contents, #mainCol>.header').css('display','none'); $('#mainCol .tempLoader').remove(); var temp=$('
          '); temp.kLoader(); if(list) { temp.append('

          '+(kGetParam('liblist',url)!=null?decodeURIComponent(kGetParam('liblist',url).replace(/\+/g,'%20')):'Liste en cours de chargement')+'

          '); temp.append('
          '); for(var i=0;i<3;i++) temp.children('.section').append('




          '); } else { temp.addClass('record'); temp.append('
          '); temp.append('
          '); temp.children('.section').append('

          H

          '); temp.children('.section').append('
          '); for(var i=0;i<3;i++) temp.find('.fields').append('

          '); } $('#mainCol>.contents').before(temp); if($(document).scrollTop()>temp.offset().top) $(document).scrollTop(temp.offset().top) function changeOnChange(elt) { elt.each(function () { var url=$(this).attr('onchange').replace(/window\.location=(.+);/,'$1'); $(this).attr('onchange','ajax_loadList('+url+');'); }); } if(pushState) kPushState(url,{ajaxLoadList:true}); if(url.match(/ajax_(list)?record.htm/i)===null) url=url.replace(/((?:list)?record\.htm)/i,'ajax_$1'); kAjax(url,'',function (data) { if(queue!=window.ajaxLoadQueue.id) return false; $('#rightCol,#breadcrumb,#mainCol>.header').remove(); temp.remove(); $('#mainCol>.contents').replaceWith(data); $('#mainCol>.contents').addClass('ajax_loaded'); if(list) { changeOnChange($('#mainCol>.contents.ajax_loaded>.header .orderby select,#mainCol>.contents.ajax_loaded>.footer select[onchange]')); kParams.idlist=$('#mainCol .contents.ajax_loaded').data('idlist'); $(document).trigger('listLoaded'); } else { gedDragDrop(); $(document).trigger('recordLoaded'); } $(document).trigger('loadBaskets'); if($('#menu_k2').length>0) { if(list) { $('#menu_k2').data('idlist',kParams.idlist); $('#menu_k2').attr('data-record',''); $('#menu_k2_2').remove(); $('#menu_k2_3').remove(); menuK2_goTo(0); if(!$('#menu_k2').hasEvent('click.classification')) { $('#menu_k2').on('click.classification','.categories a',function (e) { e.preventDefault(); ajax_loadList($(this).attr('href')); }); $('#menu_k2').on('submit.classification','.categories form',function (e) { e.preventDefault(); ajax_loadList('ajax_listrecord.htm?'+$(this).kSerialize()); }); } } //end menu_k2/list else { $('#menu_k2').attr('data-record',$('#mainCol .contents.ajax_loaded').attr('data-rn')); $('#menu_k2_3').remove(); menuK2_goTo(2); }//end menu_k2/record } },function (error) { temp.remove(); $('#mainCol>.contents').css('display',''); popup(error,{type:'error',title:'Chargement de liste',buttonOK:true}); }); } function listRecordAjax() { $(document).on('click','.contents.ajax_loaded a',function (e) { var link=$(this).attr('href'); if (link.match(/(\/|^)(ajax_)?(list)?Record\.htm/i)!==null && this.target!=='_blank') { e.preventDefault(); ajax_loadList(link); } }); } function recordDragDrop() {//drag drop notice if(typeof DD==='undefined') return true; var targets='#menu_folderView li>a'; function recordDragDoDrop(mess,params) { kAjax('ajax_Classification_act.htm',params,function (data) { if(mess.folder==mess.team && params.act2==undefined) var message='$$doc a été ajouté à l\\\'équipe $$team'; else if(params.act2==undefined) var message='$$doc a été ajouté au dossier $$folder'; else if(mess.folder==mess.team) var message='$$doc a été déplacé vers l\'équipe $$team'; else var message='$$doc a été déplacé vers le dossier $$folder'; kMessageBox.send(message.replace('$$doc',mess.doc).replace('$$team',mess.team).replace('$$folder',mess.folder)); },function (error) { popup(error,{title:'Error',type:'error',buttonOK:true}) }); } function recordDragDropAllowed(target) { return (target.closest('[data-role]').data('role')<4) || (target.closest('.team').attr('data-rn')==recDrop.elt.data('team-rn') && (target.closest('li').attr('data-pc-rn')==recDrop.elt.data('box-rn') || (target.closest('li').is('.team') && recDrop.elt.data('box-rn')==null))); } var recDrop = new DD(function (drag,trigger) { //initdrag drag.append(trigger.closest('.article').find('.figure').first().clone()).append(''+trigger.find('.title').text()+'').addClass("recordDragger").data({'rn':String(getRN(trigger)),'recordAut':trigger.data('recordAut'),teamRn:trigger.attr('data-team-rn'),boxRn:trigger.attr('data-box-rn')}); drag.find('.figure').find('.hover').remove(); },function (target) { //dropAction if(target.length==0 || recordDragDropAllowed(target)) return false; var mess={doc:recDrop.elt.find('.title').text(),folder:target.find('.lib').text(),team:target.closest('.team').find('.lib').first().text()}; var params={act:'SubfolderDropRecord',team:target.closest('.team').attr('data-rn'),linkto:target.closest('li').attr('data-rn'),recnum:recDrop.elt.data('rn')}; //calculate action : alias (0), move (1), both possible (2) var act=2; if(recDrop.elt.data('recordAut')<2) act=0; else { //in same team, from team to pc or reverse : move only var elt={team:recDrop.elt.data('team-rn'),box:recDrop.elt.data('box-rn')}; var targetData={team:target.closest('.team').attr('data-rn'),isTeam:target.closest('li').is('.team')}; if(elt.team==targetData.team && (targetData.isTeam || elt.box==undefined)) act=1; } if(act==0) recordDragDoDrop(mess,params); else if(act==1) { params.act2='move'; recordDragDoDrop(mess,params); } else { addContextHelp('DEPLACEDOC'); popup('popup_classif_drop.htm',{width:600,callback:function () { $('#modalPopup .submit').on('click','input',function () { if($(this).is(':first-child')) popup(0); else { popup(0); if($(this).is(':nth-child(3)')) params.act2='move'; recordDragDoDrop(mess,params); } }); }}); } },targets); $('body').dd_bind(recDrop,'#listRecord .article:not(#listRecTab *)'); $('body').on('dragEnter',targets,function (e) { $(this).append('
          '); }); $('body').on('dragLeave',targets,function (e) { $(this).children('.recordDropTarget').remove(); }); } //END recordDragDrop function setUserPrefs(prefs,temp,onOk,onError) { /* Save user prefs into database temp is optional and can be : boolean : save in temporary folder int (or text containg num) : save related to idlist */ if(typeof temp==='function') { onError=onOk; onOk=temp; } let query={params:JSON.stringify(prefs),user:kParams.ident,user_temp:kParams.identTemp}; if(temp===true) query.temp=1; else if ((typeof temp==='number') || Number(temp)!==NaN) query.list=Number(temp); kAjax('engine/ajax_setUserPrefs.htm',query,function (data) { if(typeof onOk=='function') onOk(data); },function (error) { if(typeof onError=='function') onError(error); }); } function deconnectInactive() { if(typeof kParams==='undefined' || kParams.deconnectInactive==0 || kParams.ident=='') return false; triggerOnIdle(function () { window.location='/CONNECTD?id2=deconnect&getdoc=main.htm'; },kParams.deconnectInactive*60,false); } function resizeSupermenus() { $('.super-menu').each(function () { if($(this).children('.padding').length==0) { //resize menu $(this).css('visibility','hidden').parent().addClass('hover'); var w=0; var children=$(this).children('div'); for(i=0;i ($(window).width() - 5) && relative + pos.left > 0) pos.left-=50; if(pos.left + w < opener.width()) pos.left=opener.width()-w; if(pos.left<-relative) pos.left=-relative; //check menu does not disappear on the left $(this).css(pos); $(this).parent('li').children('a').children('span').append(''); if($(this).parent('li').children('a').next('.arrow').length===0) $(this).parent('li').children('a').after('
          '); }); } function fixSortOrder() { //change link on sort order when changing sort field, so field is always included in order -> fixes bug where changing the sort order did not take the current field into account $('.orderby').on('click','a',function (e) { var field=$(this).closest('.orderby').find('select'); var obj={}; obj[field.attr('name')]=field.val(); $(this).attr('href',kSetParam(obj,$(this).attr('href'))); }); } function form_imageInput() { $(document).on('change','.kForm-image input[type="file"]',function (e) { var display=this.parentNode.querySelector('.kForm-imageDisplay'); if(this.files.length>0) { var reader=new FileReader(); reader.addEventListener('load',function () { display.style.backgroundImage='url(\''+reader.result+'\')'; }); reader.readAsDataURL(this.files.item(0)); } }); } function checkList_update() { $('.contents').on('change','.article input[type=checkbox][name="cid[]"]',function () { var idlist=kParams.idlist; var recnum=$(this).val(); var action = ($(this).is(':checked'))?'ADD':'DEL'; $.post('list_item_check.htm',{idxlist:idlist,xRecord:recnum,act:action},function (data) { $('body').append(''); $('.selectCount').html($('#TEMP').find('.selectCount').html()); $('#TEMP').remove(); }); if(action=='ADD') kParams.listSelected.push(recnum); else { var p=array_find(kParams.listSelected,recnum); if(p>0) kParams.listSelected.splice(p,1); } }); $('.contents').on('change','.article input.cb-cid2',function (e) { $(this).closest('.article').find('input[type=checkbox][name="cid[]"]').prop('checked',$(this).is(':checked')).trigger('change'); }); } function checkList_selectAll() { $('#listRecord .selectall a').on('click',function (e) { e.preventDefault(); var idlist=kParams.idlist; if($(this).attr('href')=='#all') { var recnum=-1; var action='ADD'; $('.article input[type="checkbox"][name="cid[]"]').each(function () { kParams.listSelected.push($(this).val()); }); } else if($(this).attr('href')=='#none') { var recnum=-9; var action='DEL'; kParams.listSelected=[]; } kAjax('list_item_check.htm',{idxlist:idlist,xRecord:recnum,act:action},function (data) { $('body').append(''); $('.selectCount').html($('#TEMP').find('.selectCount').html()); $('#TEMP').remove(); //select checkboxes $('#listRecord .article input[type="checkbox"][name="cid[]"],#listRecord .article input[type="checkbox"].cb-cid2').prop('checked',(action==='ADD')); }, function (error) { popup(error,{type:'error',buttonOK:true}); }); }); } function checkList_checkGhost() { $('#listRecord .article input[type=checkbox][name="cid[]"]:checked').closest('.article').find('.cb-cid2').prop('checked',true); } function checkList_basketPop() { $('#listselect #baskets').change(function () { if($(this).val()=='') return true; var act=$(this).val(); $(this).val(''); if($('.selectCount').first().html()=='0') { alert('Sélectionnez au moins une ligne'); return true; } if(act == 's') //sub selection { popup(1); setTimeout(function () {location.search='?idlist='+kParams.idlist+'&selectedonly=on&numselect=s&list=recordnums';},0); } else if(act == 'g') //apply formula { popup('ajax_Apply_Formula.htm?idlist='+kParams.idlist+'&selectedonly=on',{width:800,callback:function () { $('#modalPopup .kForm').find('input:not([type="checkbox"]),select,textarea').each(function () { if($(this).is('[type="hidden"],.submit *')) return true; if(!$(this).is('.autocomplete') && $(this).data('comment')!='') $(this).autocomplete({ noServer:true, query_title:$(this).siblings('label').text(), query_comment:$(this).data('comment') }); //end comment only else if($(this).is('.autocomplete')) { $(this).autocomplete({ query_type:'applyFormula', query_title:$(this).siblings('label').text(), query_comment:$(this).data('comment'), field:$(this).attr('id'), code:$(this).siblings('input[type="hidden"]').val(), locked:true }); } }); $('#modalPopup form').on('submit',function (e) { e.preventDefault(); $(this).formAjax({init:function () {popup(1);}, success:function (data) { popup(0); try { var data=JSON.parse(data); } catch (err) { kMessageBox.send(data,{type:'error'}) } if(data.message) { var mess=''; if(data.message.modif_ok) mess+='$ enregistrement(s) modifié(s)
          '.replace('$',data.message.modif_ok); if(data.message.no_access) mess+='Vous n\'avez pas les droits de modifier $ enregistrements. Ils n\'ont pas été modifiés.
          '.replace('$',data.message.no_access); if(data.message.records_locked) mess+='$ enregistrements étaient verrouillés. Ils n\'ont pas été modifiés.
          '.replace('$',data.message.records_locked); kMessageBox.send(mess); } ajax_loadList('listrecord.htm?idlist='+kParams.idlist); }, error:function (error) { popup(0); kMessageBox.send(error,{type:'error'}); } }); }); } //END callback on apply formula }); } else if (act.indexOf('f:')==0) //apply script { var callbackSuccess=$(this).data('success'); var callbackError=$(this).data('error'); popup(1); kAjax('ajax_act.htm',{action:'applyformula',formula:act.substr(2),idlist:kParams.idlist,selectedonly:'on',dataType:'json'},function (data) { popup(0); kMessageBox.send(data.message.replace(/\r\n?/,'
          ')); if(callbackSuccess) eval(callbackSuccess); },function (error,message) { popup(0); kMessageBox.send(message,{type:'error'}); if(callbackError) eval(callbackError); }); } else if(act=='d') //delete { if(confirm('Voulez-vous vraiment supprimer '+$('.selectCount').first().html()+' enregistrement(s) ?')) { if(confirm('Etes-vous certain ?')) { popup(1); kAjax('ajax_act.htm',{idlist:kParams.idlist,selectedonly:'on',action:'deleteList',dataType:'json'},function (data) { popup(0); kMessageBox.send(data.message); ajax_loadList('ListRecord.htm?idlist='+data.idlist); },function (error,message) { if(error==5 || error==1) popup(message,{buttonOK:true,onOK:function () {window.location='Main.htm'}}); else popup(error,{type:'error',buttonOK:true}); }); } else alert('Suppression annulée'); } } else if(act == 'n') //new basket popup('newSelect.htm',{width:530,height:'auto', callback:function () { $('#modalPopup form').on('submit',function (e) { e.preventDefault(); var form=$('form[name="newselect"]').kSerialize(); form+='&idlist='+$('form[name="adminForm"] input[name="idlist"]').val()+'&selectedonly=on&sel_act=addlist&numselect=n&isAjax=true'; popup(1); kAjax('recordBasket.htm',form,function (data) { var oData=JSON.parse(data); var newBasket = new Basket({id:oData.basketNum,name:oData.basketLib,comment:'',count:0,niv:0}); for(x in oData.records) newBasket.add( oData.records[x]); basketList.unshift(newBasket); $(document).trigger('loadBaskets'); popup(0); kMessageBox.send(' éléments ajoutés au dossier de favoris '.replace('$$$',oData.records.length)+oData.basketLib); },function (error) { popup(0); kMessageBox.send('Ajouter des éléments aux favoris :'+error,{type:'error'}); }); }); } }); //END new basket else if(act.match(/^[0-9]+$/)) // baskets { kAjax('recordBasket.htm',{sel_act:'addlist',selectedonly:'on',idlist:kParams.idlist,numselect:act,isAjax:true},function (data) { var oData=JSON.parse(data); for(i=0;i'); bubble.append(''); $('#help').append(bubble); } function popContextHelp(id) { if(window.contextHelp.length===0) return true; if(id===undefined) id=window.contextHelp[0].id; var p; if(window.contextHelp[0].id===id) p=0; else p=array_find(window.contextHelp,id,0,searchInContext); if(p>=0) window.contextHelpSeen.push(window.contextHelp.splice(p,1)[0]); } function getSvg(elt) { if(!(elt instanceof jQuery)) elt=$(elt); var w=$(document).width(); var h=$(document).height(); var ret=''; ret+=''; return ret; } function displayContextHelpArrow() { var elt=$($('#contextHelp').find('.contents').data('args').elt); var arrow=$('#contextHelp>.kent-ico'); arrow.removeClass('hide'); var css={top:'',bottom:'',display:'',transform:''}; if (elt.length==0 || (elt.offset().top < ($(window).scrollTop() + $(window).height()) && (elt.last().offset().top+elt.last().height() > $(window).scrollTop()))) css={display:'none'}; else { if(elt.last().offset().top+elt.last().height() < $(window).scrollTop()) { css.top='30px'; css.transform='rotateZ(180deg)'; } else if(elt.offset().top > ($(window).scrollTop() + $(window).height())) css.bottom='30px'; css.left=elt.offset().left-$(window).scrollLeft()+(elt.width()/2)-(arrow.width()/2); } arrow.css(css); } function hideHelper() { $('#contextHelp').addClass('hide').find('.contents').removeData('id'); } function displayContextHelp(code) { defHelp=(window.contextHelp.length==0 && code===undefined); var helper=$('#contextHelp'); $(window).on('scroll.displayHelp',function () { displayContextHelpArrow(); }); if(helper.length==0) { helper=$('

          Bonjour, je suis Kent, votre assistant sur ce portail.

          '); $('body').prepend(helper); } helper.removeClass('hide left'); var content=helper.find('.contents'); content.kLoader({type:'circle'}); var oldCodes=''; var cxHelp; if(defHelp) { cxHelp={id:'DEFAULT'} var t=[]; for(i in window.contextHelpSeen) t.push(window.contextHelpSeen[i].id); oldCodes='&getLib='+t.join(';'); } else if(code!==undefined) { if(typeof code==='object') cxHelp=code; else { var p=array_find(window.contextHelpSeen,code,0,searchInContext); if(p>=0) cxHelp=window.contextHelpSeen[p]; else { p=array_find(window.contextHelp,code,0,searchInContext); if(p>=0) cxHelp=window.contextHelpSeen[p]; else cxHelp={id:code}; } } } else cxHelp=window.contextHelp[0]; if (cxHelp.args===undefined) cxHelp.args={}; if(!defHelp) content.data({'id':cxHelp.id,'args':cxHelp.args}); else content.data({args:{}}); $('html,body').animate({scrollTop:0},300); if(cxHelp.args.elt!==undefined && $(cxHelp.args.elt).length>0 && $(cxHelp.args.elt).offset().left >=content.offset().left) helper.addClass('left'); kAjax('engine/ajax_contextHelp.htm','lang='+kParams.lang+'&id='+cxHelp.id+oldCodes,function (data) { content.html(data); displayContextHelpArrow(); if(cxHelp.args.elt!==undefined && $(cxHelp.args.elt).length>0){ helper.children('div:first-child').addClass('contour').html(getSvg(cxHelp.args.elt)); } else { helper.children('div:first-child').removeClass('contour').html(''); } var submit=$('
          '); if(defHelp) { submit.append('

          '); } if (!kParams.contextHelp) submit.append('

          ') else submit.append('

          ') submit.append('

          '+(window.contextHelp.length>1 && code===undefined?'suivant':'Terminer')+'

          '); content.append(submit); },function (error,status) { content.removeData('id'); content.html(error+'

          Fermer

          '); }); } if(typeof window.contextHelp=='undefined') { //do once window.contextHelp=[]; window.contextHelpSeen=[]; $(document).on('click','#help',function (e) { e.preventDefault(); $('#help .signal').remove(); displayContextHelp(); }); $(document).on('click','#contextHelp .submit a, #contextHelp .close',function (e) { e.preventDefault(); $(window).off('scroll.displayHelp'); var helper=$('#contextHelp'); var id=helper.find('.contents').data('id'); if(id!=null) { kParams.contextHelp.push(helper.find('.contents').data('id')); if($(this).is('.submit *')) setUserPrefs({contextHelp:JSON.stringify(kParams.contextHelp)}); } if(document.querySelector('#contextHelp #noContextHelp:checked')) { setUserPrefs({noContextHelp:1}); window.contextHelp=[]; kParams.contextHelp=false; } if(document.querySelector('#contextHelp #yesContextHelp:checked')) { setUserPrefs({noContextHelp:0}); kParams.contextHelp=true; } if(document.querySelector('#contextHelp #allContextHelp:checked')) setUserPrefs({contextHelp:'[]'}); if($(this).is('.close')) hideHelper(); else if($(this).attr('href')=='#close' || document.querySelector('#contextHelp #noContextHelp:checked')) { popContextHelp(id); hideHelper(); } else { popContextHelp(id); displayContextHelp(); } }); $(document).on('click','.openHelper',function (e) { e.preventDefault(); displayContextHelp(this.getAttribute('href').substr(1)); }); //resize window for contour $(document).kOnWinResize(function () { if($('#contextHelp>div:first-child').is('.contour')) $('#contextHelp>div.contour').html(getSvg($('#contextHelp').find('.contents').data('args').elt)); }); } if(arguments.length>0) { let ids=id.split(/[;,]/); for(i=0;i=0) {//store already seen in variable, all if Kent is disabled if(array_find(window.contextHelpSeen,ids[i],0,searchInContext)<0) window.contextHelpSeen.push({id:ids[i],args:args}); } else { if(array_find(window.contextHelp,ids[i],0,searchInContext)<0) { window.contextHelp.push({id:ids[i],args:args}); if(window.contextHelp.length==1) { if (document.readyState=='loading') $(window).on('load',signalContextHelp); else signalContextHelp(); } } } } } } function makeScrollable() { $('.kScroll').makeScrollable(); } function listTabSettings() { $(document).on('click','#listRecTabSettings',function (e) { e.preventDefault(); var selected=''; var all=''; for(x in listRecTabFields) { if(listRecTabFields[x].label!=='') all+=''+listRecTabFields[x].label+''; } for(x in listRecTabFieldsSel) { selected+=''+listRecTabFieldsSel[x].label+''; } popup('
          '+selected+'
          '+all+'

          0?' checked':'')+' />

          ',{width:'80%',callback:function () { $('#popupListRecTabSettings').on('click','a',function (e) { e.preventDefault(); if($(this).is('.inactive')) return true; if($(this).is('.sort')) { let $elts=$(this).closest('label').nextAll('a'); $elts.sortElements($(this).is('.active')?'data-sort':(a=>a.innerText.toLowerCase())); $(this).toggleClass('active'); } else { var cont=$(this).closest('div'); if(cont.is(':first-child')) { cont.siblings('div').find('[data-code="'+$(this).data('code')+'"]').removeClass('hide'); $(this).remove(); } else { cont.siblings('div').append($(this).clone()); $(this).addClass('hide'); } } }); let moveFields=new DD(function ($elt,$trigger) { if($trigger.is('.inactive')) return false; $elt.append($trigger.clone()).width($trigger.width()).css('opacity',.4); $trigger.addClass('dragged'); $trigger.after('
          '+$trigger.text()+'
          '); },function ($target) { let $ghost=$('#popupListRecTabSettings #ghost'); if($ghost.length>0) { $ghost.replaceWith($('#popupListRecTabSettings .dragged').removeClass('dragged')); } },'#popupListRecTabSettings>div:first-child>a',{ scrollDist:0 }); $('#popupListRecTabSettings>div:first-child').dd_bind(moveFields,'a'); $(document).on('dragOver','#popupListRecTabSettings a',function (e,pos) { let $ghost=$('#popupListRecTabSettings #ghost'); let $dragged=$('#popupListRecTabSettings .dragged'); let coords=this.getBoundingClientRect(); let y=coords.top+window.scrollY+(coords.height/2); if(pos.ydiv:first-child a').each(function (i) { data+='&col_'+(Number(i+1))+'='+$(this).data('code').replace('#','%23'); }); data+='&showPreviews='+($('#listRecTabHideImages').is(':checked')?'1':'0'); popup(1); window.location=data; },buttonOK:true,buttonCancel:true,title:'Paramétrage des colonnes'}); }); } function listTabEditMode() { //listrecord table edit mode // +some display functions let tabTimer=null; let tabQueue=0; let tabCustom={}; //used to add custom treatment of columns function tabEdit_getCellInfos(cell) { return listRecTabFieldsInfos[$($(cell).closest('tr').find('td,th')).index(cell)]; } function tabEdit_canEditCell(cell) { if($(cell).closest('tr').is('.editModeOff')) return 'Vous n\'avez pas le droit de modifier cet enregistrement.'; else if (!tabEdit_getCellInfos(cell).editable) return 'Cette rubrique n\'est pas modifiable, ou vous n\'avez pas le droit de la modifier.'; else return true; } function tabEdit_getCellCode(cell) { return tabEdit_getCellInfos(cell).code; } function tabEdit_getCellRn(cell) { return $(cell).closest('tr').attr('data-record'); } function tabEdit_selectCell(cell) { if($(cell).closest('table').find('.editModeFocused').length>0) tabEdit_exitCell($(cell).closest('table').find('.editModeSelected')[0]); $(cell).closest('table').find('.editModeSelected').removeClass('editModeSelected'); if($(cell).is('.lastcol,.firstcol')) return true; $(cell).addClass('editModeSelected'); } function tabEdit_getValues(cell) { return listRecTabValues[tabEdit_getCellRn(cell)][tabEdit_getCellCode(cell)]; } function tabEdit_autocompletePosition(cell,hide) { $box=$('#tabAutocomplete'); if(arguments.length===1 || !hide) { if($box.length===0) { $box=$('
          '); $(cell).closest('table').after($box); } if(!$(cell).is('.autocompleteHere')) { $(cell).closest('table').find('td.autocompleteHere').removeClass('autocompleteHere'); $(cell).addClass('autocompleteHere'); } $box.css({ left:$(cell).position().left+'px', top:($(cell).closest('tr').position().top+$(cell).outerHeight())+'px', width:Math.max($(cell).width(),200)+'px' }); $box.removeClass('hide'); } else $box.addClass('hide'); return $box; } function tabEdit_autocompleteDisplay(cell,data) { let $box=tabEdit_autocompletePosition(cell); let txt=''; for(v of data.values) { if($(cell).find('.tag[data-code="'+v.Code_Valeur+'"]').length===0) //if not already in values txt+=''+v.Libelle_Valeur+''; } if(data.values.length===0) txt='

          Aucun enregistrement n\'a été trouvé

          '; else if(!$(cell).is('.editModeMultiple') && !$(cell).is('.editModeRequired')) { txt='Vider la valeur'+txt; } if($box.children('input').length===0 && data.values.length>10) $box.prepend(''); $box.children('div').html(txt); } function tabEdit_autocompleteLoad(cell,query) { if(arguments.length<2) query={}; if(typeof query!=='object') query={search:query}; if(query.field===undefined) query.field=tabEdit_getCellCode(cell); if(query.rn===undefined) query.rn=tabEdit_getCellRn(cell); if(query.dataType===undefined) query.dataType='json'; tabQueue++; let tabQueue_local=tabQueue kAjax('ajax_listTabLoad.htm',query,function (data) { if(tabQueue_local===tabQueue) tabEdit_autocompleteDisplay(cell,data); },function (error) { kMessageBox.send('Error getting values: '+error,{type:'error'}); tabEdit_exitCell(cell,true); //reset values }); } function tabEdit_openPopup(cell) { let txt=''; let infos=tabEdit_getCellInfos(cell); let id=0; let fieldMask; if(infos.type==='date') fieldMask=''; else fieldMask=''; fieldMask='

          '+fieldMask+'

          '; for(val of tabEdit_getValues(cell).displayValue) txt+=fieldMask.replace('$val',val).replace('$id',++id); txt+=fieldMask.replace('$val','').replace('$id',++id); //add empty value txt='
          '+txt+'
          '; popup(txt,{ buttonOK:true, buttonCancel:true, width:1000, title:$(cell).closest('table').find('th').eq($(cell).getCellCoord().left).find('label').text(), onOK:function () { let txt=''; let vals=[] $('#modalPopup .kForm').find('input,textarea').each(function () { if(this.value!='') vals.push(this.value); }); for(v of vals) txt+=''; $(cell).find('.value').append(txt); tabEdit_exitCell(cell); popup(0); }, onCancel:function () { $(cell).removeClass('editModeFocused'); popup(0); }, callback:function () { $('#popupTabEditMore').find('input,textarea').makeMultivalue(); } }); } window.tabEdit_addProcess=function (field,callbacks) { //use to add special processing for field whose code is "field" //callbacks is object that can receive : // focus : function to apply on focus in cell, this is current cell, receives (cell values,cell infos,callback on cell exit, to call if async, with cell as argument) as arguments, returns element to insert in cell, or nothing to leave cell untouched // exit : function to apply on exiting cell (calculate query then sent to ajax_listTabEdit.htm), this is current cell, receives current calculated query. Can return true if no change and cell display need to be reset to original value. // exitTarget : URl to call if not calling ajax_listTabEdit.htm //callback receives "query" and can return "true" if needs to reset value instead of setting it if(typeof field!=='object') field=[field]; for(f of field) { if(typeof f==='number') f='='+f; tabCustom[f]=callbacks; } }; function tabEdit_focusCell(cell) { if(!$(cell).is('.editModeSelected')) tabEdit_selectCell(cell); var canEdit=tabEdit_canEditCell(cell); if(canEdit===true) { var $edit=$(cell).find('.value').first(); $(cell).addClass('editModeFocused'); $(cell).data('originalValue',$(cell).find('.value').first().html()); $value=$(cell).find('.value').first(); infos=tabEdit_getCellInfos(cell); var $elt=$(); if(tabCustom[infos.code]!==undefined && typeof tabCustom[infos.code].focus==='function') { let ret=tabCustom[infos.code].focus.apply(cell,[tabEdit_getValues(cell),infos,tabEdit_exitCell]); if(ret instanceof jQuery || ret instanceof Element) $elt=$(ret); } else { switch(infos.type) { case 'text': if(!infos.multiple) { $elt=$('l
          '); $elt.filter('textarea').css({height:$(cell).innerHeight(),width:$(cell).innerWidth()}); } else tabEdit_openPopup(cell); break; case 'date': if(!infos.multiple) $elt=$(''); else tabEdit_openPopup(cell); break; case 'code': let txt=''; let vals=tabEdit_getValues(cell); for(i in vals.value) txt+=''+vals.displayValue[i]+(infos.multiple?'':'')+''; if(infos.multiple) txt+=''; if(txt==='') txt='
          '; $elt=$(txt); break; case 'link': kMessageBox.send('This datatype is not yet supported.',{type:'error'}); break; } } if($elt.length>0) { if(infos.multiple) $(cell).addClass('editModeMultiple'); if(infos.required) $(cell).addClass('editModeRequired'); $value.html('').append($elt); $value.find('input,textarea').first().trigger('focus').each((i,a)=>{a.setSelectionRange(a.value.length,a.value.length)}); if(infos.type==='code' && !infos.multiple) { let $box=tabEdit_autocompletePosition(cell); $box.children().kLoader(); tabEdit_autocompleteLoad(cell); } } } else { kMessageBox.send(canEdit,{type:'error'}); } } function tabEdit_exitCell(cell,reset) { if(arguments.length<2) reset=false; $(cell).removeClass('editModeFocused'); let $value=$(cell).find('.value').first(); var query={ act:'val', record:tabEdit_getCellRn(cell), field:tabEdit_getCellCode(cell) }; if(tabCustom[infos.code]!==undefined && typeof tabCustom[query.field].exit==='function') { reset=tabCustom[query.field].exit.apply(cell,[query]); } else { switch(tabEdit_getCellInfos(cell).type) { case 'text': case 'date': let $fields=$value.find('textarea,input'); if($fields.length===1) { query.val=$fields.val(); if(query.val==='') query.replace=1; } else { query.val='$multiple:'+$fields.length; $fields.each(function (i) { query['val'+(i+1)]=this.value; }); query.replace=1; } break; case 'code': query.val=$(cell).find('a.tag:not(.add)').toArray().map(a=>a.dataset.code).join(';'); query.replace=1; break; case 'link': kMessageBox.send('This datatype is not yet supported.',{type:'error'}); break; } } if(reset || (query.val!==undefined && query.val!==tabEdit_getValues(cell).value.join(';'))) { let url='ajax_listTabEdit.htm'; if(tabCustom[infos.code]!==undefined && typeof tabCustom[infos.code].exitTarget!=='undefined') url=tabCustom[infos.code].exitTarget; kAjax(url,query,function (data) { let $data=$('
          ').html(data); $value.html($data.find('#result_html .value').html()); let vals=JSON.parse($data.find('#result_code').text()); tabEdit_getValues(cell).value=vals.value; tabEdit_getValues(cell).displayValue=vals.displayValue; kMessageBox.send('Modification enregistrée'); },function (error) { kMessageBox.send(error,{type:'error'}); $value.html($(cell).data('originalValue')); }); } else { $value.html($(cell).data('originalValue')); } tabEdit_autocompletePosition(cell,true); } $(document).on('click','.listTabToggleEditMode',function (e) { var mode=$(this).data('action'); $('.listTabToggleEditMode[data-action="'+mode+'"]').addClass('hide'); $('.listTabToggleEditMode:not([data-action="'+mode+'"])').removeClass('hide'); if(mode==='on') { $('#listRecTab').addClass('editMode'); setUserPrefs({editMode:true},kParams.idlist); } else { $('#listRecTab').removeClass('editMode'); setUserPrefs({editMode:false},kParams.idlist); } }); $(document).on('click','#listRecTab.editMode td',function (e) { e.preventDefault(); if(!this.matches('.editModeSelected')) tabEdit_selectCell(this); else if(!this.matches('.editModeFocused')) tabEdit_focusCell(this); else if($(e.target).is('.fullSize')) { var $target=$(e.target).closest('td').find('.value textarea'); popup('',{ buttonOK:true, buttonCancel:true, width:800, onOK:function () { $target.val($('#modalPopup textarea').val()); tabEdit_exitCell($target.closest('td')[0]); popup(0); }}); } }); $(document).on('keypress keyup',function (e) { //key shortcuts if($('#listRecTab.editMode').length===0) return true; var mode='none'; var $cell=$(e.target).closest('td'); if($cell.is('.editModeFocused')) mode='focus'; else if($cell.is('.editModeSelected')) mode='selected'; if(e.key==='Enter' && !e.shiftKey && mode==='focus') { e.preventDefault(); tabEdit_exitCell($cell); } else if(e.key==='Escape' && mode==='focus') { e.preventDefault(); tabEdit_exitCell($cell,true); } }); $(document).on('click','#listRecTab.editMode .editModeFocused a.tag',function (e) { //click on tags if($(this).is('.add') || !$(this).closest('td').is('.editModeMultiple')) { var $cell=$(e.target).closest('td'); if($(this).is('.autocompleteHere') && !$('#tabAutocomplete').is('.hide')) //hide box tabEdit_autocompletePosition($cell,true); else { let $box=tabEdit_autocompletePosition($cell); $box.kLoader(); tabEdit_autocompleteLoad($cell); } } else $(this).remove(); }); $(document).on('click','#tabAutocomplete a',function (e) { //autocomplete $cell=$('#listRecTab .autocompleteHere'); if($cell.is('.editModeMultiple')) { $cell.find('.add').before($(this).append('')); setTimeout(tabEdit_autocompletePosition,0,$cell); } else { if($(this).is('.empty')) $cell.find('.tag').remove(); else $cell.find('.value').html('').append(this); setTimeout(tabEdit_autocompletePosition,0,$cell,true); } }); $(document).on('keyup','#tabAutocomplete input',function (e) {//autocomplete typing clearTimeout(tabTimer); tabTimer=setTimeout(function () { $('#tabAutocomplete').children('div').kLoader(); tabEdit_autocompleteLoad($('#listRecTab .autocompleteHere'),$('#tabAutocomplete>input').val()); },300); }); $(document).on('click','#listRecTab:not(.editMode) .seeAll',function (e) { e.preventDefault(); let $cell=$(this).closest('td'); let txt=''; for(val of tabEdit_getValues($cell).displayValue) txt+='
          '+val+'
          '; txt='
          '+txt+'
          '; popup(txt,{buttonClose:true,width:1000,title:$cell.closest('table').find('th').eq($cell.getCellCoord().left).find('label').text()}); }); $(document).on('mousedown','.tabResize',function (e) { let pos=e.clientX; let $cell=$(this).closest('th,td'); //set left cols width $cell.prevAll('th,td').each(function () { $(this).css('width',$(this).width()+'px'); }); let w=$cell.width(); $(document).on('mousemove.tabResize',function (e2) { let pos2=e2.clientX; $cell.css('width',w+pos2-pos); }).on('mouseup.tabResize',function (e2) { $(document).off('mousemove.tabResize mouseup.tabResize'); let query={}; query['tabCol_width_'+tabEdit_getCellCode($cell)]=$cell.width(); setUserPrefs(query); }); }); } function resizePictures() { //check if images are set with background, and have width and height data defined, to add/remove "no-resize" $('.article .figure').each(function () { if(this.style.backgroundImage && this.dataset.imgWidth && this.dataset.imgHeight && this.dataset.imgWidth>0 && this.dataset.imgHeight>0) { if($(this).width()>$(this).data('img-width') && $(this).height()>$(this).data('img-height')) $(this).addClass('no-resize'); else $(this).removeClass('no-resize'); } }); } function askKent(args) { //generate very simple form to send emails to admins /*args : styles : styles to apply to main box, mostly for positionning to : email address to send email to (database by default) record : include record */ var box=$('#askKent'); if(box.length>0) box.remove(); if(arguments.length===0) args={}; box=$('

          Besoin d\'aide ? Posez-moi votre question ci-dessous !

          '); $('body').append(box); box.find('textarea').focus(); if(args.styles!==undefined) box.css(args.styles); if(!window.askKentCalled) { window.askKentCalled=true; $(document).on('click','#askKent a',function (e) { if($(this).attr('href')==='#close') { e.preventDefault(); $('#askKent').remove(); } }); $(document).on('submit','#askKent form',function (e) { box=$('#askKent'); e.preventDefault(); var data={}; if($('#askKentSendInfos').is(':checked')) { data.url=window.location.toString(); data.idlist=kParams.idlist; data.xrecord=getRN(); if(kGetParam('kentapp')!==null) data.kentapp=kGetParam('kentapp'); } if(box.attr('data-record')!='') data.xrecord2=box.attr('data-record'); $(this).formAjax({init:function () { box.find('form').kLoader({type:'circle'}); }, action:'askKent.htm', data:data, success:function (data) { box.find('form').replaceWith(data); }, error:function (error) { box.remove(); kMessageBox.send(error,{type:'error'}); }}); }); } } function setupQuickSearch () { if(!$('.quickSearch').last().find('.optionsLoader>:not(.onFocus)').isEmpty(true)) $('.quickSearch').last().find('.optionsOpener').removeClass('hide'); if(window.setupQuickSearchDone!==undefined) { $('.quickSearch .qsAutocomplete').remove(); return true; } window.setupQuickSearchDone=true; function qSearch_loadAjax($box) { var load=$box.find('.loadOnOpen'); if(load.length>0) { load.each(function () { var elt=$(this); elt.kLoader(); var href=elt.data('href'); if(href.search(/^http|\?|#/)>=0) { //protect against cross site elt.remove(); return true; } kAjax(href,'',function (data) { elt.html(data); elt.removeClass('loadOnOpen'); },function (error) { elt.remove(); }); }); } } $(document).on('click','.quickSearch .optionsOpener',function (e) { var $main=$(this).closest('.quickSearch'); var $box=$main.find('.options'); if($box.length===0) { $box=$('
          '); $main.find('.optionsOpener').after($box); $main.find('.quickSearchTables input:checked').trigger('change'); $main.find('.optionsLoader>div:not(.onFocus)').appendTo($box); qSearch_loadAjax($box); } $box.modalShow(); }); function qSearch_closeFocus() { $('.quickSearch .qsFocus').addClass('hide').find('.acResults').remove(); $('.quickSearch .search-menu').find('.acResults').remove(); if($('.quickSearch .search-menu').isEmpty(true)) $('#topSearch .search-menu').addClass('hide'); } function qSearch_openFocus($form) { if($form.closest('#topSearch').length===0) { var $box=$form.find('.qsFocus'); if($box.length===0) { $box=$('
          '); $form.find('input.sfield').before($box); $form.find('.optionsLoader>div.onFocus').appendTo($box); qSearch_loadAjax($box); $box.css('left',$box.siblings('input.sfield').position().left); } return $box.removeClass('hide'); } else { return $form.find('.search-menu').removeClass('hide'); } } function qSearch_get($form,what) { //get type or table from checkboxes/radio or input var label; switch(what) { case 'type':label='Types';break; case 'table':label='Tables';break; default:label=what[0].toUpperCase()+what.substr(1); } $box=$form.find('.quickSearch'+label); if($box.length===0) return $form.find('input[name="'+what+']').val(); var val=[]; $box.find('input:checked').each(function () { if($(this).val()!=='') val.push($(this).val()); }); return val.join(';'); } $(document).on('focus','.quickSearch input.sfield',function (e) { var $main=$(this).closest('.quickSearch'); qSearch_openFocus($main); }).on('click focus',function (e) { e.stopPropagation(); var $main=$('.quickSearch').has('.qsFocus:not(.hide)'); if($main.length>0 && !$(e.target).closest('.qsFocus').is($main.find('.qsFocus')) && !$(e.target).is($main.find('input.sfield'))) qSearch_closeFocus(); }) .on('submit','.quickSearch',function (e) { //types var $types=$(this).find('.quickSearchTypes'); if($types.length!==0) { var field=$(this).find('input[name="type"]'); if(field.length===0) field=$('').appendTo(this); field.val(qSearch_get($(this),'type')); } //tables var $table=$(this).find('.quickSearchTables input:checked'); if($table.length!==0) { var field=$(this).find('input[name="table"]'); if(field.length===0) field=$('').appendTo(this); field.val(qSearch_get($(this),'table')); } $(this).find('.quickSearchTables').remove(); // delete trailing spaces $(this).find('input[name="what"]').val($(this).find('input[name="what"]').val().trim()); }) .on('change','.quickSearchTables input',function () { var val=this.value; $(this).closest('.quickSearch').find('.quickSearchTypes').each(function () { if(!$(this).is('.table'+val)) { $(this).addClass('hide').find('input[type="checkbox"]:checked').prop('checked',false); $(this).find('input.selectAll').prop('undetermined',false); } else $(this).removeClass('hide'); }); }); function qSearch_doAutocomplete() { var $main=$('.acResults a.active').closest('.quickSearch'); if($main.length===0) return false; var $field=$main.find('input.autocomplete'); var $item=$main.find('.acResults a.active'); $field.val($item.data('value')+' ').trigger('focus'); qSearch_closeFocus(); } if($('.quickSearch .qsAutocomplete').length>0) { $('.quickSearch .qsAutocomplete').remove(); var qsAutocompleteTimout,qsAutocompleteQueue=0; $(document).on('keydown keypress','.quickSearch input.autocomplete',function (e) { if(e.keyCode===13 && $(this).closest('.quickSearch').find('.acResults a.active').length>0) { //enter e.preventDefault(); qSearch_doAutocomplete(); } else if((e.keyCode===38 || e.keyCode===40) && $(this).closest('.quickSearch').find('.acResults a').length>0) { // up/down arrows e.preventDefault(); var dir=(e.keyCode===40?1:-1); $items=$(this).closest('.quickSearch').find('.acResults a'); if($items.filter('.active').length===0) $items.eq(dir>0?0:$items.length-1).addClass('active'); else { var i=$items.index($items.filter('.active'))+dir; if(i<0) i=$items.length-1; else if(i>=$items.length) i=0; $items.removeClass('active').eq(i).addClass('active'); $items.closest('.scrollableViewport').scrollTo($items.filter('.active'),{center:false}); } } else { clearTimeout(qsAutocompleteTimout); let field=this; qsAutocompleteTimout=setTimeout(function () { var queue=++qsAutocompleteQueue; query={ what:field.value, table:qSearch_get($(field).closest('form'),'table'), type:qSearch_get($(field).closest('form'),'type'), dataType:'json' }; if($(field).closest('form').find('input[type="hidden"][name="field_all"]').length>0) query.field_all=$(field).closest('form').find('input[type="hidden"][name="field_all"]').val(); else if($(field).closest('form').find('input[type=checkbox"][name="field_all"]:checked').length>0) query.field_all='on'; kAjax('globalSearch_help.json',query,function (data) { if(queue!==qsAutocompleteQueue) return false; var $main=$(field).closest('.quickSearch'); var $box=qSearch_openFocus($main); if(data.results.length===0) { $box.find('.acResults').html(''); if($box.isEmpty(true)) $box.addClass('hide'); return true; } $acBox=$box.find('.acResults'); if($acBox.length===0) $acBox=$('
          ').prependTo($box); var txt=''; for(d of data.results) txt+=''+d.label+''; $acBox.html(txt); $acBox.makeScrollable(); },function (error) { }); },300); } }) .on('click','.quickSearch .acResults a',function (e) { e.stopPropagation(); $(this).addClass('active').siblings().removeClass('.active'); qSearch_doAutocomplete(); }); } function openSearch() { $('#topSearch').addClass('opened'); if($('#topSearch .search-menu').isEmpty(true)) $('#topSearch .search-menu').addClass('hide'); $('#topSearch .quickSearchTables input:checked').trigger('change'); qSearch_loadAjax($('#topSearch .search-menu')); setTimeout(function () {$('#topSearch input[type="text"]')[0].select();},400); } function closeSearch() { $('#topSearch').removeClass('opened'); qSearch_closeFocus(); } $('#topSearch a').on('click',function (e) { if($(this).is('#topSearch>a')) openSearch(); else if($(this).is('.close')) closeSearch(); }); $(document).on('click',function (e) { if($('#topSearch').is('.opened') && $(e.target).closest('#topSearch').length==0) closeSearch(); }); $('#topSearch input[type="text"]').on('keyup',function (e) { if(e.keyCode==27) closeSearch(); }); } function doTranslate(trigger) { popup(1); kAjax('ajax_translateRecord.htm',{record:getRN(trigger)},function (data) { if($('#listBody').length>0) { //list mode popup(0) if($(trigger).closest('#listRecTab').length===0) $(trigger).closest('.article').replaceWith($(data).filter('.section').html()); else kMessageBox.send('L\'enregistrement a bien été traduit. Rechargez la page pour afficher la traduction.'); } else //record window.location='record.htm?record='+getRN(trigger)+'&idlist='+kParams.idlist; },function (error) { popup(0); kMessageBox.send('Error: Could not translate record: '+error,{type:'error'}); }); } function listRecordWfActions () { if(window.setListRecordWfActions===undefined) { window.setListRecordWfActions=true; $(document).on('click','.article .gedFlow .buttons a',function (e) { let act=this.getAttribute('href'); if(act[0]==='#') { e.preventDefault(); gedToolbox.triggerAction(act.substr(1),e); } }); } } $.fn.homeLoadThemes=function (data,args) { /*args.viewAllOnMain : Permet de gérer si un clic sur une rubrique parente permet de lier les documents des enfants également valeurs possibles : 'never' : pas de lien / 'always' (défaut) : clic sur le parent inclus toujours les enfants / 'option' : ajoute une entrée "voir tout" */ if(args===undefined) args={}; if(args.viewAllOnMain===undefined) args.viewAllOnMain='always'; const root=this; function homeLoadThemes_getHtml(field,val) { let url='ListRecord.htm?list=table&table=3&what='+encodeURIComponent(val.code)+'&field=='+field.field+'&liblist='+encodeURIComponent(field.label+' : '+val.label)+'&sort=D=41'; let isBack=false; if(val.code==='#back') { url=val.code; isBack=true; } return ''+(val.img!=''?'':'')+(val.subvalues?'':'')+(isBack?'f':'')+'
          '+(val.label?'':'')+''+(isBack?'':''); } $(this).each(function () { let txt=''; for(val of data.values) { txt+=homeLoadThemes_getHtml(data.info,val); } $(root).html(txt); }); $(this).on('click','a',function (e) { if($(this).find('.kent-ico').length===0) return true; else { e.preventDefault(); let txt; if(this.matches('.back')) { txt=''; for(val of data.values) { txt+=homeLoadThemes_getHtml(data.info,val); } } else { const parent=data.values.find(a=>a.code===this.dataset.code); txt=homeLoadThemes_getHtml(data.info,{code:'#back',label:'',img:parent.img}); txt+=homeLoadThemes_getHtml(data.info,{code:parent.code+(args.viewAllOnMain==='always'?' / '+parent.code+'.@':''),label:parent.label,img:parent.img}); for(val of parent.subvalues) txt+=homeLoadThemes_getHtml(data.infoSub,val); if(args.viewAllOnMain==='option') txt+=homeLoadThemes_getHtml(data.info,{code:parent.code+' / '+parent.code+'.@',label:parent.label+' (Voir tout)',img:parent.img}); } $(root).html(txt); } }); }; function ckeLoadData() { $('.cke-data:not(.loading):not(.loaded)').addClass('loading').kLoader(); let $div=$('.cke-data:not(.loaded)').first(); if($div.length===0) return true; kAjax('ajax_cke_data.htm',$div[0].dataset,function (data) { $div.html(data).addClass('loaded').removeClass('loading'); ckeLoadData(); },function (error) { $div.html('

          Impossible de charger les données : '+error+'

          '); }); } $(document).on('recordUnload',function () { kAjax('record_unlock.htm','record='+getRN()); }); //functions called before even loading var gedToolbox; deadLink(); clickPopup(); menuClassement(); listRecordAjax(); // functions called when top is loaded $(document).on('topLoaded',function () { clickCookies(); newbasket(); submitbasket(); removeFromBasket(); basketEdit(); showsub(); selectall(); searchPanel(); hoverDelay(); noHoverOnFocus(); $(document).trigger('loadBaskets'); categoriesDeploy(); miniUpload(); miniTabs(); recordDragDrop(); resizeSupermenus(); listTabSettings(); listTabEditMode(); }); //functions called when list is loaded $(document).on('listLoaded',function () { checkList_update(); checkList_selectAll(); checkList_basketPop(); checkList_checkGhost(); addRss(); rss_read(); checkSubmenuEmpty(); resizePictures(); }); //functions called when page is loaded $(document).ready(function() { if(typeof $.fn.lightbox==='function') $('.lightbox').lightbox(); showmore(); showmoretable(); changetabs('.tabs'); popupLabel(); changefontsize(); hoverrating(); submitrating(); focusReadonly(); modifyCodes(); showInstructions(); submit_noRepeat(); leftCol_resize(); record_resize(); $(document).trigger('loadBaskets'); /* GedPlus */ toggleFolders(); iconsFolders(); ged_rename(); ged_tags(); ged_confirmKey(); gedDragDrop(); showGedToolbox(); gedToolbox=new GedToolbox(); toolboxDefaultActions(); ged_unlock(); dropFilesFromDesktop(); fixSortOrder(); wfTagClick(); wfCheckDashWidth(); makeScrollable(); kaOpenSettings(); kaActions(); kaResize(); deconnectInactive(); form_imageInput(); ckeLoadData(); $('#mainCol').removeClass('loading'); //keep at the end });