 BigApi.ObjectController.BlocRss = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId); this.buildSliding()}, buildSliding:function() { var canal_header = this.mainContainer.down('.rss_canal_header'); if(canal_header) this.canal_sliding = new BigApi.Graphic.SlidingContainer(canal_header.up(), { onEvent:'click', classNames: { toggle:'rss_canal_header', toggleActive:'rss_canal_header_active', content:'rss_canal_content' } }); var canal_content = this.mainContainer.down('.rss_canal_items'); if(canal_content) { this.items_sliding = new BigApi.Graphic.SlidingContainer(canal_content, { onEvent:'click', classNames: { toggle:'rss_item_header', toggleActive:'rss_item_header_active', content:'rss_item_content' } })} }, onTemplateChanged:function() { if(this.canal_sliding) this.canal_sliding.dispose(); if(this.items_sliding) this.items_sliding.dispose(); this.buildSliding()}, dispose:function($super) { $super(); if(this.canal_sliding) this.canal_sliding.dispose(); if(this.items_sliding) this.items_sliding.dispose()} }); BigApi.ObjectController.TreeMenu = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId); this._bindMenuItemsEvents(); this.addObserver(document, 'BigApiObjectTreeMenu:Action', this._onBigApiObjectTreeMenuAction.bindAsEventListener(this))}, _onBigApiObjectTreeMenuAction:function(event) { if(event.memo.controller != this) { this._onClickMenuItem(null)} }, _bindMenuItemsEvents:function() { this.currentDepthsItems = $A(); this.mainContainer.select('.menu_item').each(function(item) { var depth = this._findItemDepth(item); if (depth >= 0) { if (item.hasClassName('menu_depth' + depth + '_item_over')) { this.currentDepthsItems[depth] = item} } this.addObserver(item,'click', this._onClickMenuItem.bind(this, item))}.bind(this))}, _onClickMenuItem:function(item) { if(item) { var depth = this._findItemDepth(item); if(this.currentDepthsItems[depth]) this.currentDepthsItems[depth].removeClassName('menu_depth'+depth+'_item_over'); this.currentDepthsItems[depth] = item; item.addClassName('menu_depth'+depth+'_item_over'); document.fire('BigApiObjectTreeMenu:Action', {action:'item_selected', item:item, controller:this})} else { this.currentDepthsItems.each(function(item, depth){ item.removeClassName('menu_depth'+depth+'_item_over')}); this.currentDepthsItems = $A()} }, _findItemDepth:function(item) { var depthclass = item.classNames().grep(/menu_depth([0-9]+)_item/).first(); var depth = -1; if(depthclass) { var results =/depth([0-9]+)/.exec(depthclass); if(results) { depth = parseInt(results[1])} } return depth}, onTemplateChanged:function() { this._bindMenuItemsEvents()}, dispose:function($super) { $super()} }); BigApi.ObjectController.ContainerDocumentVisitor = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options); this.footerWrap = this.getBodyContainer().down('.ContainerDocument_footer_wrap'); if(this.footerWrap) { this.updateFooterPos(); this.addObserver(window, 'resize', this.updateFooterPos.bind(this)); this.addObserver(document, 'BigApi.Document:ContentChanged', function(){setTimeout(this.updateFooterPos.bind(this), 500)}.bind(this))} }, updateFooterPos:function() { footerElement = this.footerWrap; var containerHeight = this.getWindowHeight(); var contentHeight= this.mainContainer.offsetHeight; var footerHeight = footerElement.getHeight(); if(!this.baseFooterYOffset) this.baseFooterYOffset = footerElement.positionedOffset()[1]; var footerTop = footerElement.style.top ? parseInt(footerElement.style.top) : 0; var footerYOffset = footerElement.positionedOffset()[1]-footerTop; if (containerHeight-(contentHeight)>=0) { footerElement.style.position='relative'; footerElement.style.top= (containerHeight-(footerYOffset+footerHeight))+'px'} else { footerElement.style.position='static'} }, getWindowHeight:function() { var windowHeight=0; if (typeof(window.innerHeight)=='number') { windowHeight=window.innerHeight} else { if (document.documentElement&& document.documentElement.clientHeight) { windowHeight = document.documentElement.clientHeight} else { if (document.body&&document.body.clientHeight) { windowHeight=document.body.clientHeight} } } return windowHeight} }); BigApi.ObjectController.TreeContextZoneVisitor = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options); this.elements = {}; this.inputs = {}; this.contextDatas = BigApi.Context.Pool.getCurrentContextDatas(); this.elements.container = this.mainContainer.down('div'); this.addObserver(document, 'BigApi.Context:onUpdateContext', this._onUpdateContext.bindAsEventListener(this))}, _refreshContent:function() { BigApi.ObjectController.ZonesPool.unregisterZoneControllers(this.displayContainerId); new Ajax.Request('ajax/BigApiObjectTreeContextZoneVisitor', { parameters:{ displayContainerId:this.displayContainerId }, onSuccess:this._refreshContentSuccess.bind(this) })}, _refreshContentSuccess:function(transport) { var object = BigApi.Utils.ajaxJsonEval(transport); var jsFiles = []; $A(object.objects).each(function(elem) { if(elem.linkedFiles && elem.linkedFiles.css) { elem.linkedFiles.css.each(function(file) { BigApi.Loader.requireDynamicCssFile(file)})} if(elem.linkedFiles && elem.linkedFiles.js) { elem.linkedFiles.js.each(function(file) { jsFiles.push(file)})} }); this.elements.container.update(object.content); if (!BigApi.Browser.IE || BigApi.Browser.IEVersion > 6) { this.elements.container.hide(); new Effect.Appear(this.elements.container, { duration: 0.5 })} if (window.Shadowbox) { Shadowbox.clearCache(); Shadowbox.setup()} var js_sync_loader = null; var js_sync_loader = new BigApi.Loader.JsSyncLoader({onLoadedHandler:this._onJsFilesLoaded.bind(this, object)}); $A(jsFiles).each(function(file){ js_sync_loader.addFile(file)}); js_sync_loader.process()}, _onJsFilesLoaded:function(object) { $A(object.objects).each(function(elem) { if(elem.linkedJsExpr) { var result = eval(elem.linkedJsExpr)} }.bind(this)); document.fire('BigApi.Document:ContentChanged')}, dispose:function($super) { BigApi.ObjectController.ZonesPool.unregisterZoneControllers(this.displayContainerId); $super()}, _onUpdateContext:function(event) { lastParams = event.memo.lastParams; newParams = event.memo.newParams; this.contextDatas = newParams; this._refreshContent()} }); BigApi.ObjectController.ContainerPageVisitor = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId); var sup_container = $$('body')[0]; if(sup_container) sup_container.addClassName(this.getTemplateClass()+'_supbody')}, dispose:function($super) { $super(); var sup_container = $$('body')[0]; if(sup_container) sup_container.removeClassName(this.getTemplateClass()+'_supbody')} }); BigApi.ObjectController.BlocEditionAgenda = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId); this.buildSliding()}, buildSliding:function() { this.mainSliding = new BigApi.Graphic.SlidingContainer(this.mainContainer, { onEvent:'click', classNames: { toggle:'section_title', toggleActive:'section_title_active', content:'section_content' }, enableEventOnActive:true, mode:'classic' }); var sections = this.mainContainer.select('div.section_content'); this.sectionsSliding = $A(); sections.each(function(section){ this.sectionsSliding.push(new BigApi.Graphic.SlidingContainer(section, { onEvent:'click', classNames: { toggle:'item_title', toggleActive:'item_title_active', content:'item_content' }, enableEventOnActive:true }))}.bind(this))}, onTemplateChanged:function() { if(this.mainSliding) this.mainSliding.dispose(); this.mainSliding = null; if(this.sectionsSliding) { this.sectionsSliding.each(function(sliding){ sliding.dispose()})} this.sectionsSliding = $A(); this.buildSliding()}, dispose:function($super) { $super(); if(this.mainSliding) this.mainSliding.dispose(); this.mainSliding = null; if(this.sectionsSliding) { this.sectionsSliding.each(function(sliding){ sliding.dispose()})} this.sectionsSliding = $A()} }); BigApi.ObjectController.BlocClientInfos = Class.create(BigApi.ObjectController.IBasicForm, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options)}, _onSuccessActions:function(obj) { var action = this.lastSubmitParams.actionOnSuccess ? this.lastSubmitParams.actionOnSuccess : obj.actionOnSuccess; if(action == 'nextStep') { BigApi.Context.Loader.updateContext(null, {"client_infos_livraison":""})} else { BigApi.Context.Loader.updateContext(null, {"client_infos":""})} } }); BigApi.ObjectController.BlocEditionRechercheRapide = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options); this.form = this.mainContainer.down('form'); if(this.form) this.addObserver(this.form, 'submit', this._onFormSubmit.bindAsEventListener(this))}, _onFormSubmit:function(event) { Event.stop(event); var input = this.form.getInputs('text')[0]; if(input && input.value != '') { BigApi.Context.Loader.updateContext(null, {recherche:input.value}); input.value = ''} return false}, _onFormSubmitSuccess:function(transport) { }, dispose:function($super) { $super()} }); BigApi.ObjectController.BlocEditionRechercheResultats = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId); this.buildSliding()}, buildSliding:function() { this.mainSliding = new BigApi.Graphic.SlidingContainer(this.mainContainer, { onEvent:'click', classNames: { toggle:'section_title', toggleActive:'section_title_active', content:'section_content' }, enableEventOnActive:true, mode:'classic' }); var sections = this.mainContainer.select('div.section_content'); this.sectionsSliding = $A(); sections.each(function(section){ this.sectionsSliding.push(new BigApi.Graphic.SlidingContainer(section, { onEvent:'click', classNames: { toggle:'item_title', toggleActive:'item_title_active', content:'item_content' }, enableEventOnActive:true }))}.bind(this))}, onTemplateChanged:function() { if(this.mainSliding) this.mainSliding.dispose(); this.mainSliding = null; if(this.sectionsSliding) { this.sectionsSliding.each(function(sliding){ sliding.dispose()})} this.sectionsSliding = $A(); this.buildSliding()}, dispose:function($super) { $super(); if(this.mainSliding) this.mainSliding.dispose(); this.mainSliding = null; if(this.sectionsSliding) { this.sectionsSliding.each(function(sliding){ sliding.dispose()})} this.sectionsSliding = $A()} }); BigApi.ObjectController.TreeMenuHorizontal2 = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options); this._buildSliding()}, _buildSliding:function() { this.sliding = new BigApi.Graphic.SlidingContainer2(this.mainContainer, { onEvent:'click', classNames: { toggle:'depth0_item', toggleActive:'depth0_item_over', toggleRegexp:'TreeBranch([0-9]+)', content:'depth1_inner', contentRegexp:'TreeBranch([0-9]+)' } }); this.bindDepth1Events(); this.addObserver(document, 'BigApiObjectTreeMenu:Action', this._onBigApiObjectTreeMenuAction.bindAsEventListener(this))}, _onBigApiObjectTreeMenuAction:function(event) { if(event.memo && event.memo.controller != this) { if(this.currentDepth1Item) { this.currentDepth1Item.removeClassName('depth1_item_over')} this.sliding.closeAll()} }, bindDepth1Events:function() { this.currentDepth1Item = null; var elem = this.mainContainer.down('.depth1_item_over'); if(elem) { this.currentDepth1Item = elem} this.mainContainer.select('.depth1_item').each(function(item) { this.addObserver(item,'click', this._onClickDepth1Button.bind(this, item))}.bind(this)); this.mainContainer.select('.depth0_item').each(function(item) { this.addObserver(item,'click', this._onClickDepth0Button.bind(this, item))}.bind(this))}, _onClickDepth0Button:function(item) { if(this.currentDepth1Item) this.currentDepth1Item.removeClassName('depth1_item_over'); this.currentDepth1Item = null; document.fire('BigApiObjectTreeMenu:Action', {action:'item_selected', item:item, controller:this})}, _onClickDepth1Button:function(item) { if (item != this.currentDepth1Item) { if(this.currentDepth1Item) this.currentDepth1Item.removeClassName('depth1_item_over'); item.addClassName('depth1_item_over'); this.currentDepth1Item = item} document.fire('BigApiObjectTreeMenu:Action', {action:'item_selected', item:item, controller:this})}, onTemplateChanged:function() { if(this.sliding) this.sliding.dispose(); this._buildSliding(); this.bindDepth1Events()}, dispose:function($super) { $super(); if(this.sliding) this.sliding.dispose()} }); BigApi.ObjectController.BlocClientConnexion = Class.create(BigApi.ObjectController.IBasic, { initialize:function($super, displayContainerId, options) { $super(displayContainerId, options); if(this.mainContainer.down('.not_logged')) this._processNonLogged(); else this._processLogged()}, _processNonLogged:function() { this.form = this.mainContainer.down('form'); this.error_container = null; if(this.form) this.addObserver(this.form, 'submit', this._onSubmit.bindAsEventListener(this))}, _processLogged:function() { this.addObserver(document, 'BigApiObjectBlocClientConnexion:Logout', this.logout.bind(this))}, logout:function() { new Ajax.Request('ajax/BigApiObjectBlocClientConnexionAction', { parameters: { action:'logout' }, onSuccess:this._onLogoutSuccess.bind(this) })}, _onLogoutSuccess:function(transport) { var obj = BigApi.Utils.ajaxJsonEval(transport); if (obj.success) window.location.reload(true)}, _onSubmit:function(event) { Event.stop(event); var inputs = this.form.getElements(); var error_messages = $A(); inputs.each(function(input) { if(input.type != 'submit' && input.type != 'button') { var has_error = false; if(input.value == '') { error_messages.clear(); error_messages.push('Un ou plusieurs champs obligatoires n\'ont pas été renseignés'); input.addClassName('error'); has_error = true} if(!has_error) input.removeClassName('error')} }); if (error_messages.size()) this._errorsDisplay(error_messages); else { this._errorsDisplay(null); new Ajax.Request('ajax/BigApiObjectBlocClientConnexionAction', { parameters:Object.extend(this.form.serialize(true), {action:'login'}), onSuccess:this._onSubmitSuccess.bind(this) }) } }, _onSubmitSuccess:function(transport) { var obj = BigApi.Utils.ajaxJsonEval(transport); if (obj.success) window.location.reload(true); else { this.form.getInputs('password')[0].value = ''; this._errorsDisplay($A(obj.errors))} }, _errorsDisplay:function(messages) { if(messages) { var concat = ''; messages.each(function(message) { concat += message}.bind(this)); alert(concat)} }, dispose:function($super) { $super()} }); 