(function(){ // Base64 string methods taken from http://www.webtoolkit.info/ var Base64 = { _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", encode : function (input) { var output = ""; var chr1, chr2, chr3, enc1, enc2, enc3, enc4; var i = 0; input = Base64._utf8_encode(input); while (i < input.length) { chr1 = input.charCodeAt(i++); chr2 = input.charCodeAt(i++); chr3 = input.charCodeAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if (isNaN(chr3)) { enc4 = 64; }; output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); }; return output; }, decode : function (input) { var output = ""; var chr1, chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); while (i < input.length) { enc1 = this._keyStr.indexOf(input.charAt(i++)); enc2 = this._keyStr.indexOf(input.charAt(i++)); enc3 = this._keyStr.indexOf(input.charAt(i++)); enc4 = this._keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); }; if (enc4 != 64) { output = output + String.fromCharCode(chr3); }; }; output = Base64._utf8_decode(output); return output; }, // private method for UTF-8 encoding _utf8_encode : function (string) { string = string.replace(/\r\n/g,"\n"); var utftext = ""; for (var n = 0; n < string.length; n++) { var c = string.charCodeAt(n); if (c < 128) { utftext += String.fromCharCode(c); } else if((c > 127) && (c < 2048)) { utftext += String.fromCharCode((c >> 6) | 192); utftext += String.fromCharCode((c & 63) | 128); } else { utftext += String.fromCharCode((c >> 12) | 224); utftext += String.fromCharCode(((c >> 6) & 63) | 128); utftext += String.fromCharCode((c & 63) | 128); }; }; return utftext; }, _utf8_decode : function (utftext) { var string = ""; var i = 0; var c = c1 = c2 = 0; while ( i < utftext.length ) { c = utftext.charCodeAt(i); if (c < 128) { string += String.fromCharCode(c); i++; } else if((c > 191) && (c < 224)) { c2 = utftext.charCodeAt(i+1); string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); i += 2; } else { c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2); string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); i += 3; }; }; return string; } }; String.implement({ toBase64: function(){ return Base64.encode(this); }, decodeBase64: function(){ return Base64.decode(this); } }); })(); // TVFI i18n registry var I18nRegistry = {}; var ReadMore = new Class({ Implements: [Events], initialize: function(link,container) { this.container = container; this.fullText = this.container.get('html'); this.visibleText = this.fullText; this.link = link; this.isOpened = false; this.readmoreLinkLabel = 'Afficher la suite'; this.readlessLinkLabel = 'Réduire'; this.cutOff = 300; this.minimumHeight = 66; this.openedHeight = this.container.getSize().y; if(this.openedHeight > this.minimumHeight) { var cutoff = this.cutOff; var textToHide = this.fullText.substring(cutoff); if (this.fullText.length > cutoff) { var period = textToHide.indexOf('.'); var space = textToHide.indexOf(' '); cutoff += Math.max(Math.min(period, space), 0); // Assign the rest again, because we recalculated the cutoff textToHide = this.fullText.substring(cutoff); this.visibleText = this.fullText.substring(0, cutoff) + '...'; this.container.set('html', this.visibleText); this.link.setStyle('display', 'block'); this.link.set('html', this.readmoreLinkLabel ); this.link.getParent('p').setStyle('display', 'block'); var new_h = Math.max(0, (20 - (this.container.getParent().getSize().y -40))); this.link.getParent('p').setStyle('height', new_h); this.link.onclick = function(){ if(!this.isOpened) { this.container.set('html', this.fullText ); this.link.set('html', this.readlessLinkLabel ); this.isOpened = true; } else { this.container.set('html', this.visibleText ); this.link.set('html', this.readmoreLinkLabel ); this.isOpened = false; } return false; }.bind(this); } } } }); /** * Site */ var Site = new Class({ /** * Initialize object */ initialize: function(){ // Order is important! Zebratable, then Tabs, then Togglers if($$('.zebraTable').length > 0) this.initZebraTable(); if($$('.ZebraList').length > 0) this.initZebraList(); if($$('input.defaults').length > 0) this.initInputDefaults(); if($$('input.autocomplete').length > 0) this.initAutocomplete(); if($$('a.ajoutFavoris').length > 0) this.ajoutFavoris(); if($$('a.suppressionFavoris').length > 0) this.suppressionFavoris(); if($$('div.ajaxPages').length > 0) this.ajaxPages(); if($$('div.ajaxFilters').length > 0) this.ajaxFilters(); if($$('div.ajaxColumnSort').length > 0) this.ajaxColumnSort(); if($$('.boxSlide').length > 0) this.initSlider(); if($$('.boxPhotoSlide').length > 0) this.initPhotoSlider(); if($$('.infobulles').length > 0) this.initTips(); if($$('.scrollBox').length > 0) this.initScrollBoxes(); if($$('#modifySearch').length > 0) this.initSearchResults(); if($$('#searchDrawer').length > 0) this.initAdvSearchForms(); if($$('.readmore').length > 0 && $$('.linkReadMore').length > 0) this.initReadMore(); if($$('.displaySelect').length > 0) this.initDisplaySelect(); if($$('.selectAll').length > 0) this.initSelectAll(); if($('SimpleSearchForm')) this.initSimpleSearch(); if($('js_printWindow')) this.initPrintWindow(); if($('js_sharebtn')) this.initShareBox(); // MO if($$('.suppressionContacts').length > 0) this.suppressionContacts(); if($$('.ajaxSimpleForm').length > 0) this.initAjaxSimpleForm(); }, postLoad: function(){ if($$('div.toggledbox').length > 0) this.boxtoggler(); if($$('.boxTabsLeft').length > 0) this.initTabsLeft(); if($$('.boxTabsTop').length > 0) this.initTabsTop(); // SEARCH RESULTS this.checkHash(); var status = getURLParameter('status'); if (null != status) { var title = "Votre formulaire a été sauvegardé"; var message = "Votre formulaire a été sauvegardé. Veillez à l'envoyer prochainement aux équipes TV France International."; if ("1_pending_review" == status) { title = "Votre formulaire a été envoyé"; message = "Votre formulaire a bien été envoyé, vous recevrez un mail prochainement pour confirmer votre participation."; } this.showModalBox($$('body'), message, 'ok', title); } }, groupCSSClass: function() { return ''; }, initSimpleSearch: function() { $('SimpleSearchForm').addEvent('submit', function(e){ if($('SimpleSearchKeyword').value =='') e.stop(); }); }, /** * Check if current location URL contains hash and so an ajax request to launch */ checkHash: function() { var url = new URI( window.location.href ); var hash = url.get('fragment'); var page = $('ajaxPages'); var site = this; var strUrl= window.location.href; if( strUrl.contains('?') ){ strUrl = '&'; } else { strUrl = '?'; } // If we have a hash value from the URL if(hash != "") { if(hash.contains('query')) { url.set('fragment', ''); var req = new Request.JSON({ method: 'get', url: url.toString() + strUrl + 'ajax=true&' + hash, evalScripts : true, onSuccess: function(response) { if( response.status == 'OK' ) { // Reload the target element with content received. var content = response.content; var reload = response.noReload; if (content!==''){ page.set('html', content); page.fade('in'); site.ajaxPages(); site.ajaxColumnSort(); site.ajaxFilters(); site.initTips(); site.ajoutFavoris(); site.initZebraTable(); site.initDisplaySelect(); } if (response.query!==''){ var addToFavoriteBtn = $('advancedSearchAddToFavorites'); if( addToFavoriteBtn ) { addToFavoriteBtn.set('href', response.addToFavorite); } window.location.hash = response.query; // TODO : On pourrait passer ça en paramètre de la requête plutôt que de rechercher le bouton sur chaque page var exportXLBtn = $('js_exportXl'); if( exportXLBtn ) { var url = exportXLBtn.get( 'href' ) + '?' + response.query; exportXLBtn.set( 'href', url); } var exportPDFBtn = $('js_exportPdf'); if( exportPDFBtn ) { var url = exportPDFBtn.get( 'href' ) + '?' + response.query; exportPDFBtn.set( 'href', url); } } if (response.totalFound !== ''){ $('advancedSearchFeedback').set('html', response.totalFound); var exportPDFBtn = $('js_exportPdf'); if( exportPDFBtn ) { // Disable the PdfExport Btn if it is limited to a certain total results if( exportPDFBtn.hasClass('js_exportLimited') ) { // Let's store the title for further use $('js_exportPdf').store('title', $('js_exportPdf').getProperty('title') ); var args = exportPDFBtn.getProperty('rel').split(':'); if( response.totalResults > args[0] ) { exportPDFBtn.setProperty('title', args[1]); exportPDFBtn.fade( 0.5 ); exportPDFBtn.removeEvent( 'click' ); exportPDFBtn.addEvent( 'click', function(e) { e.stop(); return false; } ) } else { exportPDFBtn.setProperty('title', $('js_exportPdf').retrieve('title') ) exportPDFBtn.fade(1); exportPDFBtn.removeEvent( 'click' ); exportPDFBtn.addEvent( 'click', function(e) { return true; }) } } } if( reload != 1 ) { // TODO : ça devrait être chargé directement dans le template par PHP $('advancedSearchKeywords').set('html', response.keywords.replace(/\\/g, '') ); } } } // Response status is not OK else { $('advancedSearchFeedback').set('html', response.content); var addToFavoriteBtn = $('advancedSearchAddToFavorites'); if( addToFavoriteBtn ) { addToFavoriteBtn.hide(); } } } }).send(); return false; } } return false; }, /** * Initialize advanced search forms */ initAdvSearchForms : function() { this.advSearchForms = new AdvSearchForms({level1ActiveTabId : level1ActiveTabId, level2ActiveTabId : level2ActiveTabId}); }, initSearchResults : function(){ var site = this; $('modifySearch').addEvent('click', function(e) { site.advSearchForms.toggleDrawer(); }); }, initPrintWindow : function() { $('js_printWindow').addEvent( 'click', function(e) { e.stop(); window.print(); return false; }); }, initShareBox : function() { $('js_sharebox').fade('hide'); $('js_sharebtn').addEvent( 'click', function(e) { e.stop(); $('js_sharebox').fade('toggle'); return false; }); }, initReadMore : function() { $$('.linkReadMore').each( function(btn, i) { btn.setStyles({'display' : 'none', 'cursor' : 'pointer'}); }); var links = $$('.linkReadMore'); $$('.readmore').each( function(strText, i) { var readmore = new ReadMore(links[i],strText); }); }, initTabsTop : function(){ $$('.boxTabsTop').each( function(tabs, i) { var tabset = new TabSet(tabs.id, {topMargin:50, bottomMargin:5}); }); }, initTabsLeft : function(){ $$('.boxTabsLeft').each( function(tabs, i) { var tabset = new TabSetLeft(tabs.id, {topMargin : 10, bottomMargin: 30, leftMargin:240}); }); }, initScrollBoxes : function(){ $$('.scrollBox').each( function(scrollbox, i) { if ( ! scrollbox.getParent( '.AjoutProgrammeCasting' ) ){ var scrollBox = new MooScroll({selector:'#' + scrollbox.id}); } }); }, initInputDefaults : function(){ var defs = new dwDefaults({ collection: $$('input.defaults') }); }, initAutocomplete : function(){ $$('input.autocomplete').each( function(inputs, i) { new Meio.Autocomplete.Select(inputs.id, inputs.get('alt'), { valueField: $(inputs.name + '_value'), valueFilter: function(data){ return data.identifier; }, maxVisibleItems : 10, filter: { type: 'contains', path: 'value', } }); }); }, initSlider : function(){ $$('.boxSlide').each( function(slider, i) { var elementScrolled = slider.getFirst(' .slide'); var thumbsContainer = elementScrolled.getFirst(' .items'); new SlideItMoo({ overallContainer: slider.id, elementScrolled: elementScrolled.id, thumbsContainer: 'program_slide_items', itemsVisible:1, duration:300, itemsSelector: '.item', itemWidth: 150, showControls:1, itemsVisible:4, startIndex:1, navs:{fwd:'.NavSlideRight',bk:'.NavSlideLeft'}, onChange: function(index){} }); slider.setStyles({ 'overflow' : 'hidden', 'width' : '615px', 'padding' : '0 15px' }); }); }, initPhotoSlider : function(){ $$('.boxPhotoSlide').each( function(slider, i) { var elementScrolled = slider.getFirst(' .slide'); var thumbsContainer = elementScrolled.getFirst(' .items'); new SlideItMoo({ overallContainer: slider.id, elementScrolled: elementScrolled.id, thumbsContainer: 'program_slide_items', itemsVisible:1, duration:300, itemsSelector: '.item', itemWidth: 628, showControls:1, itemsVisible:1, startIndex:1, navs:{fwd:'.NavSlideRight',bk:'.NavSlideLeft'}, onChange: function(index){} }); slider.setStyles({ 'overflow' : 'hidden', 'width' : '628px', 'padding' : '0 0' }); }); }, initZebraTable : function(){ $$('.zebraTable').each( function(table, i) { var zebraHtmlTable = new HtmlTable($(table.id), { classZebra: "odd", zebra:true}); }); }, initSelectAll : function(){ $$('.selectAll').each( function(element, i) { element.addEvents({ 'click' : function(){ $$('.' + element.name).each(function(el) { el.checked = element.checked; }); } }); // Checking the box if all the elements are already selected elChildren = $$('.' + element.name); elChildrenChecked = 0; $$('.' + element.name).each(function(el) { if(el.checked) elChildrenChecked ++; }); if(elChildren.length == elChildrenChecked) element.checked = true; }); }, initDisplaySelect : function() { page = $('ajaxPages'); var site = this; $$('select.displaySelect').each(function(element,index) { var field = new DisplaySelect({htmlElement:element}); }); }, initAjaxSimpleForm : function() { page = $('ajaxPages'); var fields = $$('input.ajaxSimpleFormField'); var site = this; $$('.ajaxSimpleFormSubmit').each(function(element,index) { fields[ index ].addEvent( 'keypress', function( event ){ if ( event.key == 'enter' ){ element.fireEvent( 'click', event ); } }); element.addEvents({ 'click' : function(e){ e.stop(); var req = new Request.JSON({ method: 'get', url: element.href + '?' + fields[index].name + '=' + fields[index].value + '&ajax=true', onRequest: function(){ page.fade('out'); site.destroyInfoBulles(); }, onSuccess: function(response) { // Reload the target element with content received. var content = response.content; if (content!==''){ page.set('html', content); page.fade('in'); site.destroyInfoBulles(); site.ajaxPages(); site.ajaxColumnSort(); site.ajaxFilters(); site.initTips(); site.ajoutFavoris(); site.initZebraTable(); site.initDisplaySelect(); //spinner.hide(); // FIX Ticket #582 if ( $('ListeProgrammes') ){ window.program_delete = new ProgramDelete( $('ListeProgrammes') ); } } // Process any post action var postAction = response.postAction; if(postAction !==''){ eval(postAction); } } }).send(); return false; } }); }); }, initTips : function() { $$('a.infobulles').each(function(element,index) { var content = element.get('title').split('::'); element.store('tip:title', content[0]); element.store('tip:text', content[1]); }); this.infobulles = new Tips('.infobulles',{ className: 'infobulle', fixed: true, hideDelay: 50, showDelay: 0 }); this.infobulles.addEvents({ 'show': function(tip) { tip.fade('in'); }, 'hide': function(tip) { tip.fade('out'); } }); }, destroyInfoBulles : function() { //alert('Destroying Tips'); if($$('.infobulle').length > 0) { $$('.infobulle').each( function(el,index) { el.dispose(); }); } }, initZebraList : function(){ $$('.ZebraList').each( function(list,index) { var elements = list.getChildren('li'); elements.each( function(el,indx){ if(el.hasClass('odd')) el.removeClass('odd'); if(el.hasClass('even')) el.removeClass('even'); el.addClass( (indx % 2 == 0) ? 'even' : 'odd' ); }); }); }, /** * Creates the modal box system used throughout the site * @param sender * @param message * @param style */ showModalBox: function(sender,message,style,title) { var site = this; if(!style) style = 'info'; var modalBoxTitle; var modalBoxMessage; var boxShadow; var modalBoxOverlay = $('modalBoxOverlay'); if (!modalBoxOverlay) { modalBoxOverlay = new Element('div').setProperty('id', 'modalBoxOverlay').setStyles({ width:'100%', height:'100%', position:'absolute', top:0, left:0, 'background-color':'#FFFFFF', '-moz-opacity':.6, opacity:.6, 'z-index' : 10, }).injectInside($(document.body)); } var modalBox = $('modalBox'); if (!modalBox) { modalBox = new Element('div').setProperty('id', 'modalBox').setStyles({ opacity:0, display:'block', position:'absolute', top:'30px', left:'40%', 'z-index' : 11, }).injectInside($(document.body)); modalBox.addClass('box_320'); modalBoxTitle = new Element('div').setProperty('id', 'modalBoxTitle').injectInside(modalBox); modalBoxTitle.addClass('boxTopGris'); boxBottom = new Element('div').setProperty('id', 'boxBottom').injectInside(modalBox); boxBottom.addClass('boxBottom'); modalBox.setStyles({ opacity:0, display:'block', }); boxShadow = new Element('div').setProperty('id', 'boxShadow').injectInside(boxBottom); boxShadow.addClass('ombreBox3'); modalBoxMessage = new Element('div').setProperty('id', 'modalBoxMessage').injectInside(boxShadow); } else { modalBoxTitle = $$('#modalBox #modalBoxTitle'); modalBoxMessage = $$('#modalBox #modalBoxMessage'); boxShadow = $$('#modalBox #boxShadow'); } var scroll = window.getScroll().y; modalBoxMessage.set('html', '

' +message + '

 
'); if (typeof title == 'undefined') { modalBoxTitle.set('html', '

Alerte

'); } else { modalBoxTitle.set('html', '

'+title+'

'); } if (style == 'info') { modalBoxBtnContainer = new Element('div').setProperty('id', 'ABoxBtnContainer').injectInside(boxShadow); modalBoxBtnContainer.addClass('submit_container'); modalBoxOkBtn = new Element('a').setProperty('id', 'modalBoxValidateBtn').inject(modalBoxBtnContainer); modalBoxOkBtn.addClass('modalBoxBtn'); modalBoxCancelBtn = new Element('a').setProperty('id', 'modalBoxCancelBtn').inject(modalBoxBtnContainer); modalBoxCancelBtn.addClass('modalBoxBtn'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside(modalBoxBtnContainer); modalBoxBtnContainerClear.addClass('clear'); modalBoxCancelBtn.addEvent('click', function() { site.closeModalBox(sender, 'cancelled');} ); modalBoxOkBtn.addEvent('click', function() { site.closeModalBox(sender, 'accepted');} ); } else if (style == 'ok') { btnContainer = new Element('div').setProperty('style', 'text-align:center;width:100%;').inject(boxShadow); modalBoxOkBtn = new Element('button').setProperty('id', 'modalBoxOkBtn').inject(btnContainer); modalBoxOkBtn.set('html', 'Ok'); modalBoxOkBtn.addClass('bt_grey bt_tout'); modalBoxOkBtn.addEvent('click', function() { site.closeModalBox(sender, 'cancelled');} ); } else if (style == 'cancelDelete') { modalBoxCancelBtn = new Element('a').setProperty('id', 'modalBoxCancelBtn').inject(boxShadow); modalBoxCancelBtn.set('html', 'Cancel'); modalBoxCancelBtn.addClass('modalBoxBtn'); modalBoxActionBtn = new Element('a').setProperty('id', 'modalBoxActionBtn').inject(boxShadow); modalBoxActionBtn.set('html', 'Delete'); modalBoxActionBtn.addClass('modalBoxBtn'); modalBoxCancelBtn.addEvent('click', function() { site.closeModalBox(sender, 'cancelled');} ); modalBoxActionBtn.addEvent('click', function() { site.closeModalBox(sender, 'confirmed');}); modalBoxActionBtn.addClass('delete'); } modalBox.setStyle('top', (scroll + 300) + 'px'); modalBox.setStyles({ '-moz-opacity':0, opacity:0 }); modalBox.show(); modalBoxOverlay.show(); modalBoxOverlay.setStyles({ '-moz-opacity':.6, opacity:.6 }); modalBox.fade('in'); }, /** * Close modal box * @param sender * @param event */ closeModalBox: function(sender, event) { var modalBox = $('modalBox'); var modalBoxOverlay = $('modalBoxOverlay'); modalBox.hide(); modalBoxOverlay.hide(); $$('.modalBoxBtn').each(function(btn, i) { btn.dispose().destroy(); }); sender.fireEvent(event); }, ajoutFavoris: function(){ var roar = new CenteredRoar({ duration: 3000, margin: {x: 20, y: 50}, offset: 10, className: 'roar_' + this.groupCSSClass() }); $$('a.ajoutFavoris').each( function(favBtn, i) { favBtn.removeEvents(); favBtn.addEvent('click', function(e){ e.stop(); var req = new Request.JSON({ method: 'get', url: favBtn.href, onSuccess: function(response) { // Reload the target element with content received. var content = response.content; if (content!==''){ roar.alert('+1',content); favBtn.hide(); } // Process any post action var postAction = response.postAction; if(postAction !==''){ eval(postAction); } // Return any value to calling script var returnedValue = response.returnedValue; if(returnedValue !==''){ return returnedValue; } } }).send(); return false; }); }); }, suppressionFavoris: function(){ var site = this; $$('a.suppressionFavoris').each( function(delBtn, i) { delBtn.addEvent('click', function(e){ row = delBtn.getParent(); row = row.getParent(); isRowOdd = row.hasClass('odd'); if(isRowOdd) { row.swapClass('odd','ToDelete'); } else { row.addClass('ToDelete'); } // TODO : Ce message n'existe pas. Il faudrait le créer site.showModalBox(delBtn, '', 'cancelDelete'); e.stop(); return false; }); delBtn.addEvent('cancelled', function(e){ if(isRowOdd) { row.swapClass('ToDelete','odd'); } else { row.removeClass('ToDelete'); } }); delBtn.addEvent('confirmed', function(e){ var roar = new Roar({ duration: 30000, position: 'lowerRight', margin: {x: 20, y: 50}, offset: 10, className: 'roar_' + site.groupCSSClass() }); var req = new Request.JSON({ url: delBtn.href, method: 'get', onRequest: function() { new Fx.Tween(row,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function(response) { new Fx.Tween(row,{ duration:300, property: 'opacity', onComplete: function() { row.dispose(); zebraSortableTable.updateZebras(); } }).start(0); var content = response.content; if (content!==''){ roar.alert('-1',content); } } }).send(); }); }); }, suppressionContacts: function(){ var site = this; $$('a.suppressionContacts').each( function(delBtn, i) { delBtn.addEvent('click', function(e){ row = delBtn.getParent(); row = row.getParent(); isRowOdd = row.hasClass('odd'); if(isRowOdd) { row.swapClass('odd','ToDelete'); } else { row.addClass('ToDelete'); } site.showAlertModalBox(delBtn, 'Afin de nous aider à mettre à jours notre carnet d\'adresse merci de bien vouloir préciser pourquoi vous souhaitez supprimer ce contact

', 'cancelDeleteWhy'); e.stop(); return false; }); delBtn.addEvent('cancelled', function(e){ if(isRowOdd) { row.swapClass('ToDelete','odd'); } else { row.removeClass('ToDelete'); } }); delBtn.addEvent('confirmed', function(e){ var roar = new Roar({ duration: 30000, position: 'lowerRight', margin: {x: 20, y: 50}, offset: 10, className: 'roar_' + site.groupCSSClass() }); var req = new Request.JSON({ url: delBtn.href, method: 'get', onRequest: function() { new Fx.Tween(row,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function(response) { new Fx.Tween(row,{ duration:300, property: 'opacity', onComplete: function() { row.dispose(); zebraSortableTable.updateZebras(); } }).start(0); var content = response.content; if (content!==''){ roar.alert('-1',content); } } }).send(); }); delBtn.addEvent('raison1', function(e){ var roar = new Roar({ duration: 30000, position: 'lowerRight', margin: {x: 20, y: 50}, offset: 10, className: 'roar_' + site.groupCSSClass() }); var req = new Request.JSON({ url: delBtn.href+"?raison=1", method: 'get', onRequest: function() { new Fx.Tween(row,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function(response) { new Fx.Tween(row,{ duration:300, property: 'opacity', onComplete: function() { row.dispose(); zebraSortableTable.updateZebras(); } }).start(0); var content = response.content; if (content!==''){ roar.alert('-1',content); } } }).send(); }); delBtn.addEvent('raison2', function(e){ var roar = new Roar({ duration: 30000, position: 'lowerRight', margin: {x: 20, y: 50}, offset: 10, className: 'roar_' + site.groupCSSClass() }); var req = new Request.JSON({ url: delBtn.href+"?raison=2", method: 'get', onRequest: function() { new Fx.Tween(row,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function(response) { new Fx.Tween(row,{ duration:300, property: 'opacity', onComplete: function() { row.dispose(); zebraSortableTable.updateZebras(); } }).start(0); var content = response.content; if (content!==''){ roar.alert('-1',content); } } }).send(); }); }); }, showAlertModalBox: function(sender,message,style){ // Creates the modal box system used throughout the site var site = this; if(!style) style = 'info'; var modalBoxOverlay = $('lightbox'); if (!modalBoxOverlay) { modalBoxOverlay = new Element('div').setProperty('id', 'lightbox').setStyles({ width:'100%', height:'100%', position:'absolute', top:0, left:0, 'z-index' : 10 }).injectInside($(document.body)); } var modalBox = $('ABox'); if (!modalBox) { var modalBox = new Element('div').setProperty('id', 'ABox').setStyles({ opacity:0, display:'block', position:'absolute', top:'30px', left:'30%', 'z-index' : 11 }).injectInside($('lightbox')); modalBox.addClass('popup_482'); modalBoxTitle = new Element('div').setProperty('id', 'ABoxTitle').injectInside($('ABox')); modalBoxTitle.addClass('top'); boxBottom = new Element('div').setProperty('id', 'ABoxBottom').injectInside($('ABox')); boxBottom.addClass('bottom'); modalBox.setStyles({ opacity:0, display:'block' }); boxShadow = new Element('div').setProperty('id', 'ABoxShadow').injectInside($('ABoxBottom')); boxShadow.addClass('formbody'); } var modalBoxTitle = $('ABoxTitle'); var boxBottom = $('ABoxBottom'); var boxShadow = $('ABoxShadow'); var modalBoxMessage = $('ABoxMessage'); var scroll = window.getScroll().y; if(!modalBoxMessage) var modalBoxMessage = new Element('h4').setProperty('id', 'ABoxMessage').injectInside($('ABoxShadow')); modalBoxMessage.set('html', '

' +message + '

 
'); if(style == 'cancelDelete') { modalBoxBtnContainer = new Element('div').setProperty('id', 'ABoxBtnContainer').injectInside($('ABoxShadow')); modalBoxBtnContainer.addClass('submit_container'); modalBoxCancelBtn = new Element('a').setProperty('id', 'ABoxCancelBtn').inject($('ABoxBtnContainer')); modalBoxCancelBtn.addClass('btnNon'); modalBoxActionBtn = new Element('a').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); modalBoxActionBtn.addClass('btnOui'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside($('ABoxBtnContainer')); modalBoxBtnContainerClear.addClass('clear'); modalBoxCancelBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'cancelled');} ); modalBoxActionBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'confirmed');}); var modalBoxCancelBtn = $('ABoxCancelBtn'); var modalBoxActionBtn = $('ABoxActionBtn'); //modalBoxActionBtn.addClass('delete'); }else if(style == 'cancelDeleteWhy') { if ($('ABoxBtnContainer')) $('ABoxBtnContainer').remove(); modalBoxBtnContainer = new Element('div').setProperty('id', 'ABoxBtnContainer').injectInside($('ABoxShadow')); modalBoxBtnContainer.addClass('submit_container'); new Element('div').set('html', 'Le contact ne travaille plus pour la société

').inject($('ABoxBtnContainer')); new Element('div').set('html', 'Nous ne souhaitons pas que ce contact apparaisse sur le site

').inject($('ABoxBtnContainer')); //modalBoxActionBtn = new Element('a').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); //modalBoxActionBtn.addClass('btnOui'); //new Element('div').set('html', 'Nous ne souhaitons pas que ce contact apparaisse sur le site').inject($('ABoxBtnContainer')); //modalBoxActionBtnn = new Element('a').set('text', 'Nous ne souhaitons pas que ce contact apparaisse sur le site').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); //modalBoxActionBtnn.addClass('btnOui'); modalBoxCancelBtn = new Element('a').setProperty('id', 'ABoxCancelBtn').inject($('ABoxBtnContainer')); modalBoxCancelBtn.addClass('btnAnnuler'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside($('ABoxBtnContainer')); modalBoxBtnContainerClear.addClass('clear'); modalBoxCancelBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'cancelled');} ); //modalBoxActionBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'confirmed');}); $('raison1').addEvent('click', function() { site.closeAlertModalBox(sender,'raison1');} ); $('raison2').addEvent('click', function() { site.closeAlertModalBox(sender,'raison2');} ); var modalBoxCancelBtn = $('ABoxCancelBtn'); //var modalBoxActionBtn = $('ABoxActionBtn'); //modalBoxActionBtn.addClass('delete'); } else if(style="actionDone") { // Un seul bouton ok modalBoxBtnContainer = new Element('div').setProperty('id', 'ABoxBtnContainer').injectInside($('ABoxShadow')); modalBoxBtnContainer.addClass('submit_container'); modalBoxActionBtn = new Element('a').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); modalBoxActionBtn.addClass('btnOk'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside($('ABoxBtnContainer')); modalBoxBtnContainerClear.addClass('clear'); modalBoxActionBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'confirmed');}); var modalBoxActionBtn = $('ABoxActionBtn'); } modalBox.setStyle('top', (scroll + 300) + 'px'); modalBox.setStyles({ '-moz-opacity':1, opacity:1, visibility: 'visible', display:'block' }); modalBox.show(); modalBoxOverlay.show(); modalBoxOverlay.setStyles({ '-moz-opacity':1, opacity:1 }); modalBox.fade('in'); }, closeAlertModalBox: function(sender,event) { var modalBox = $('ABox'); var modalBoxOverlay = $('lightbox'); var modalBoxCancelBtn = $('ABoxCancelBtn'); var modalBoxActionBtn = $('ABoxActionBtn'); modalBox.hide(); modalBoxOverlay.hide(); if(modalBoxCancelBtn) modalBoxCancelBtn.dispose().destroy(); if(modalBoxActionBtn) modalBoxActionBtn.dispose().destroy(); sender.fireEvent(event); }, showABNewDeptBox: function(sender) { var site = this; var modalBoxOverlay = $('lightbox'); var scroll = window.getScroll().y; if (!modalBoxOverlay) { modalBoxOverlay = new Element('div').setProperty('id', 'lightbox').setStyles({ width:'100%', height:'100%', position:'absolute', top:0, left:0, 'z-index' : 10 }).injectInside($(document.body)); } var modalBox = $('ABox'); if (!modalBox) { var modalBox = new Element('div').setProperty('id', 'ABox').setStyles({ opacity:0, display:'block', position:'absolute', left:'30%', 'z-index' : 11 }).injectInside($('lightbox')); } modalBox.set('html', '

Nom du département

'); modalBoxCancelBtn = new Element('a').setProperty('id', 'ABoxCancelBtn').inject($('ABoxBtnContainer')); modalBoxCancelBtn.set('html', 'annuler'); modalBoxCancelBtn.addClass('btnAnnuler'); modalBoxActionBtn = new Element('a').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); modalBoxActionBtn.set('html', 'ajouter'); modalBoxActionBtn.addClass('btnAjouter'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside($('ABoxBtnContainer')); modalBoxBtnContainerClear.addClass('clear'); modalBoxCancelBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'cancelled');} ); modalBoxActionBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'confirmed');}); modalBox.setStyle('top', (scroll + 300) + 'px'); modalBox.setStyles({ '-moz-opacity':0, opacity:0 }); modalBox.show(); modalBox.addClass('popup_482'); modalBoxOverlay.show(); modalBoxOverlay.setStyles({ '-moz-opacity':1, opacity:1 }); modalBox.fade('in'); }, showABEditDeptBox: function(sender) { var site = this; var modalBoxOverlay = $('lightbox'); var scroll = window.getScroll().y; if (!modalBoxOverlay) { modalBoxOverlay = new Element('div').setProperty('id', 'lightbox').setStyles({ width:'100%', height:'100%', position:'absolute', top:0, left:0, 'z-index' : 10 }).injectInside($(document.body)); } var modalBox = $('ABox'); if (!modalBox) { var modalBox = new Element('div').setProperty('id', 'ABox').setStyles({ opacity:0, display:'block', position:'absolute', left:'30%', 'z-index' : 11 }).injectInside($('lightbox')); } modalBox.set('html', '

Changer le nom du département


Français :
  Anglais :
'); modalBoxCancelBtn = new Element('a').setProperty('id', 'ABoxCancelBtn').inject($('ABoxBtnContainer')); modalBoxCancelBtn.set('html', 'annuler'); modalBoxCancelBtn.addClass('btnAnnuler'); modalBoxActionBtn = new Element('a').setProperty('id', 'ABoxActionBtn').inject($('ABoxBtnContainer')); modalBoxActionBtn.set('html', 'ajouter'); modalBoxActionBtn.addClass('btnOkk'); modalBoxBtnContainerClear = new Element('div').setProperty('id', 'ABoxBtnContainerClear').injectInside($('ABoxBtnContainer')); modalBoxBtnContainerClear.addClass('clear'); modalBoxCancelBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'cancelled');} ); modalBoxActionBtn.addEvent('click', function() { site.closeAlertModalBox(sender,'confirmed');}); modalBox.setStyle('top', (scroll + 300) + 'px'); modalBox.setStyles({ '-moz-opacity':0, opacity:0 }); modalBox.show(); modalBox.addClass('popup_482'); modalBoxOverlay.show(); modalBoxOverlay.setStyles({ '-moz-opacity':1, opacity:1 }); modalBox.fade('in'); }, showSpinner: function() { if($('spinner')) { $('spinner').show(); } else { spinner = new Spinner($('advancedSearchResults')).show(); } }, ajaxPages: function(){ var ajaxPages = $$('div.ajaxPages'); var site = this; ajaxPages.each( function(page, i){ var links = page.getElements('div.ajaxPagination li a'); links.each( function(link, i) { link.addEvent('click', function(e){ e.stop(); var url= link.href; if(!url.contains('ajax=true')) url = url + '&ajax=true'; var req = new Request.JSON({ method: 'get', url: url, onRequest: function(){ page.fade('out'); site.destroyInfoBulles(); }, onSuccess: function(response) { // Reload the target element with content received. var content = response.content; if (content!==''){ page.set('html', content); page.fade('in'); site.destroyInfoBulles(); site.ajaxPages(); site.ajaxFilters(); site.ajaxColumnSort(); site.initTips(); site.ajoutFavoris(); site.initZebraTable(); site.initDisplaySelect(); //spinner.hide(); } if (response.query!==''){ window.location.hash = response.query; } // Process any post action var postAction = response.postAction; if(postAction !==''){ //eval(postAction); } } }).send(); return false; }) }); }); }, ajaxFilters: function(){ var site = this; var ajaxFilters = $$('div.ajaxFilters'); ajaxFilters.each( function(filter, i){ var links = $$('.ajaxFilter'); links.each( function(link, i) { link.addEvent('click', function(e){ e.stop(); var url= link.href; if(!url.contains('ajax=true')) url = url + '&ajax=true'; var req = new Request.JSON({ method: 'get', url: url, onRequest: function(){ page.fade('out'); site.destroyInfoBulles(); }, onSuccess: function(response) { // Reload the target element with content received. var content = response.content; if (content!==''){ page.set('html', content); page.fade('in'); site.destroyInfoBulles(); site.ajaxPages(); site.ajaxFilters(); site.ajaxColumnSort(); site.initTips(); site.ajoutFavoris(); site.initZebraTable(); site.initDisplaySelect(); //spinner.hide(); } if (response.query!==''){ window.location.hash = response.query; } if (response.keywords!==''){ $('advancedSearchKeywords').set('html', response.keywords); } if (response.totalFound!==''){ $('advancedSearchFeedback').set('html', response.totalFound); } // Process any post action var postAction = response.postAction; if(postAction !==''){ //eval(postAction); } } }).send(); return false; }) }); }); }, ajaxColumnSort: function(){ var site = this; var ajaxColumnSort = $$('div.ajaxColumnSort'); ajaxColumnSort.each( function(column, i){ var links = column.getElements('a.sortable'); links.each( function(link, i) { link.onclick = function(){ site.destroyInfoBulles(); var url= link.href; if(!url.contains('ajax=true')) url = url + '&ajax=true'; var req = new Request.JSON({ method: 'get', url: url, onRequest: function(){ site.destroyInfoBulles(); $('ajaxPages').fade('out'); }, onSuccess: function(response) { // Reload the target element with content received. var content = response.content; if (content!==''){ $('ajaxPages').set('html', content); $('ajaxPages').fade('in'); site.ajaxPages(); site.ajaxFilters(); site.ajaxColumnSort(); site.initTips(); site.ajoutFavoris(); site.initZebraTable(); site.initDisplaySelect(); } if (response.query!==''){ window.location.hash = response.query } // Process any post action var postAction = response.postAction; if(postAction !==''){ eval(postAction); } } }).send(); return false; } }); }); }, /** * Initialise box toggler (i.e. block that can be opened and closed) */ boxtoggler: function(){ var list = $$('div.toggledbox div.boxBottom'); var headings = $$('div.boxtoggler'); headings.each( function(heading, i) { var collapsible = new Fx.Slide(list[i], { duration: 500, transition: Fx.Transitions.Quad.easeIn, onComplete: function(request){ var open = request.getStyle('margin-top').toInt(); if (open >= 0) new Fx.Scroll(window).toElement(headings[i]); } }); heading.onclick = function() { if (heading.hasClass('open')) { heading.swapClass('open', 'close'); } else { heading.swapClass('close', 'open'); } collapsible.toggle(); return false; } var span = $('span', heading); if(span) span.setHTML('-'); }); }, accordion: function(){ var list = $$('#accordion li div.collapse'); var headings = $$('#accordion li h3'); var collapsibles = new Array(); var spans = new Array(); headings.each( function(heading, i) { var collapsible = new Fx.Slide(list[i], { duration: 500, transition: Fx.Transitions.quadIn }); collapsibles[i] = collapsible; spans[i] = $E('span', heading); heading.onclick = function(){ var span = $E('span', heading); if(span){ var newHTML = span.innerHTML == '+' ? '-' : '+'; span.setHTML(newHTML); } for(var j = 0; j < collapsibles.length; j++){ if(j!=i) { collapsibles[j].slideOut(); if(spans[j]) spans[j].setHTML('+'); } } collapsible.toggle(); return false; } collapsible.hide(); }); }, showLoginModalBox : function(errorLoginMessage) { var site = this; var errorParagraph = $('error_login_message'); errorParagraph.set('html', errorLoginMessage); var modalBoxOverlay = $('modalBoxOverlay'); modalBoxOverlay.injectInside($(document.body)); var modalBox = $('loginFormBox'); modalBox.injectInside($(document.body)); var loginBoxCloseBtn = $('loginBoxCloseBtn'); loginBoxCloseBtn.addEvent('click', function() { site.closeLoginModalBox();} ); loginBoxCloseBtn.setStyles({ cursor: 'pointer' }); var loginBoxCancelBtn = $('loginBoxCancelBtn'); loginBoxCancelBtn.addEvent('click', function() { site.closeLoginModalBox();}); loginBoxCancelBtn.setStyles({ cursor: 'pointer' }); var scroll = window.getScroll().y; modalBox.setStyle('top', (scroll + 300) + 'px'); modalBox.show(); modalBoxOverlay.show(); modalBox.fade('in'); }, closeLoginModalBox: function() { var modalBox = $('loginFormBox'); var modalBoxOverlay = $('modalBoxOverlay'); var loginBoxCloseBtn = $('loginBoxCloseBtn'); var loginBoxCancelBtn = $('loginBoxCancelBtn'); modalBox.hide(); modalBoxOverlay.hide(); } }); // Site class var site = null; window.addEvent('domready', function() { site = new Site(); }); window.addEvent('domready', function() { site.postLoad(); }); function checkDate(el) { // Only digits if(el.value.test(/[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}/)) { var exp = new RegExp('([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})'); var matches = exp.exec( el.value ); var error = 0; // Right ranges if(matches[1]>31 || matches[1]<1) error++; if(matches[2]>12 || matches[2]<1) error++; if(matches[3]>(new Date()).getFullYear() || matches[3]<1970) error++; if(error > 0) { el.errors.push('Format incorrect'); return false; } else return true; } else { el.errors.push('Format incorrect'); return false; } } // STYLING FILE INPUTS 1.0 | Shaun Inman | 2007-09-07 if (!window.SI) { var SI = {}; }; SI.Files = { htmlClass : 'SI-FILES-STYLIZED', fileClass : 'file', wrapClass : 'cabinet', fini : false, able : false, init : function() { this.fini = true; var ie = 0 //@cc_on + @_jscript_version if (window.opera || (ie && ie < 5.5) || !document.getElementsByTagName) { return; } // no support for opacity or the DOM this.able = true; var html = document.getElementsByTagName('html')[0]; html.className += (html.className != '' ? ' ' : '') + this.htmlClass; }, stylize : function(elem) { if (!this.fini) { this.init(); }; if (!this.able) { return; }; elem.parentNode.file = elem; elem.parentNode.onmousemove = function(e) { if (typeof e == 'undefined') e = window.event; if (typeof e.pageY == 'undefined' && typeof e.clientX == 'number' && document.documentElement) { e.pageX = e.clientX + document.documentElement.scrollLeft; e.pageY = e.clientY + document.documentElement.scrollTop; }; var ox = oy = 0; var elem = this; if (elem.offsetParent) { ox = elem.offsetLeft; oy = elem.offsetTop; while (elem = elem.offsetParent) { ox += elem.offsetLeft; oy += elem.offsetTop; }; }; var x = e.pageX - ox; var y = e.pageY - oy; var w = this.file.offsetWidth; var h = this.file.offsetHeight; this.file.style.top = y - (h / 2) + 'px'; this.file.style.left = x - (w - 30) + 'px'; }; }, stylizeById : function(id) { this.stylize(document.getElementById(id)); }, stylizeAll : function() { if (!this.fini) { this.init(); }; if (!this.able) { return; }; var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { var input = inputs[i]; if (input.type == 'file' && input.className.indexOf(this.fileClass) != -1 && input.parentNode.className.indexOf(this.wrapClass) != -1) { this.stylize(input); }; }; } }; function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null; }