Multi-State Objects (MSOs) are a great way to change content onscreen, but InDesign only lets buttons control MSOs that are on the same page.


So how do switch Object States throughout a document (like you would need to when switching languages)?


in5 is easy to customize in this way. I've included the necessary steps, as well as the exact code below that you can copy-and-paste to customize you output.


1) Create an Object Style within InDesign


Creating an Object Style effectively marks an object with a CSS class name in the in5 output.


Apply an Object Style to all of the MSO elements in your document that will switch languages (in sync with each other).

custom object style in the InDesign Object Style's panel


Not only will the name of the Object Style come through as a CSS class name in the output (sanitized to remove spaces and restricted characters), but you can apply an additional class in the Class field of the Export Tagging within the Object Style Options (shown in the image below).


Other than the Export Tagging, most/all of the other attributes should be set to pass through (designated with a dash [-]), meaning that the Object Style won't override these settings on objects. This way, your Object Styles simply "marks" the items, but doesn't change their appearance properties.


Object Style settings with export tagging


2) Apply the custom code

Save the code below using a plain text editor (e.g., BBEdit, Notepad++, Dreamweaver, etc) as a .js file.


$(function(){
  var switchingStates = false;
  function checkState(e){
    if(switchingStates) return;
    var $this = $(this);
    if(!$this.parents('.activePage').length) return;
    var classes = this.className.replace(/ *(mso|flipcard-[^ ]+|pageItem)/g,'');
    if(!classes.match(/\w{2,}/)){ $this.off('newState',checkState); return; }
    classes = classes.split(' ').join('.').replace(/\.{2,}/g,'.');
    switchingStates = true;
    var currentState = $this.children('.state.active').index();
    $('.mso').not($this).filter(classes).each(function(index,el){
      toState($(this).attr('data-id'), currentState);
    });
    switchingStates = false;
  }
  $('.mso').on('newState',checkState);
});


Now when you export, you can attach this code to your in5 document.


How the code works


This code listens for changes in your MSO when the have a custom class applied. If a custom class is applied and the MSO state is changed, it checks for other MSOs with the exact same class name(s) and switches those to the same numbered state...so make sure your MSOs are configured the same way.


With this custom code applied, changing any one of these MSOs will change the matching MSOs on all other pages of your document.