2 Replies Latest reply on Jan 21, 2014 12:48 PM by LeftHead

    ScriptUI resizing

    LeftHead

      Hi

       

      I'm working on a simple conversion tool for indesign to html5. It begins to do the job but I have some problems with the UI.

       

      First one: when I click on the "New" button, the new "tagLine" appears always at the bottom of the stack. Is there a way to make it appears just below the "tagLine" on wich I click?

       

      Next one: when I click on the "Delete" button, the "tagLine" is well removed but others "tagLines" stay at their places. Is there a way to rearrange the remaining "tagLines" withouth the empty spaces?

       

      Any help welcome

       

      A picture is always better than a long speach:

       

      Capture-d’écran-2014-01-17-à-21.25.10.jpg

      Capture-d’écran-2014-01-17-à-21.25.32.jpg

       

      The script:

       

      var count = 0;

      var lineUI = new Array();

      var myPalette = new Window('palette', 'Ma palette');

      initializePalette();

      newTagLine();

      myPalette.show();

       

      function initializePalette() {

          if (myPalette != null) {

              var defaultButtons = myPalette.add('group', undefined, 'defaultButtons');

              defaultButtons.orientation = 'row';

              defaultButtons.alignment = 'right';

              defaultButtons.cancelBt = defaultButtons.add('button', undefined, 'Cancel', {name: 'cancel'});

              defaultButtons.cancelBt.onClick = function () { myPalette.close(); };

              defaultButtons.startBt = defaultButtons.add('button', undefined, 'Start Process', {name: 'start'});

              defaultButtons.startBt.onClick = function () { myPalette.close(); ParagraphStylesManagment(app.selection[0].parentStory.paragraphs); };

              myPalette.layout.layout(true);

              myPalette.layout.resize();

          }

      }

       

      function newTagLine() {

          if (myPalette != null) {

              var i = count;

              var myUiLineName = 'lineUI' + count;

              lineUI[i] = myPalette.add('group', undefined, myUiLineName);

              lineUI[i].orientation = 'row';

              lineUI[i].upperTagName = lineUI[i].add('dropdownlist', undefined, ['--- none ---', 'book', 'part', 'chapter', 'section', 'sub-section', 'sub-sub-section', 'ol', 'ul']);

              lineUI[i].upperTagName.selection = 0;

              lineUI[i].tagName = lineUI[i].add('dropdownlist', undefined, ['--- none ---', 'h1', 'h2', 'h3', 'li', 'p']);

              lineUI[i].tagName.selection = 0;

              lineUI[i].letterSizeStatus = lineUI[i].add('checkbox', undefined, 'Size');

              lineUI[i].letterSize = lineUI[i].add('edittext', undefined, '');

              lineUI[i].letterSize.characters = 3;

              lineUI[i].familyStatus = lineUI[i].add('checkbox', undefined, 'Family');

              lineUI[i].family = lineUI[i].add('edittext', undefined, '');

              lineUI[i].family.characters = 10;

              lineUI[i].fontStyleStatus = lineUI[i].add('checkbox', undefined, 'FontStyle');

              lineUI[i].fontStyle = lineUI[i].add('edittext', undefined, '');

              lineUI[i].fontStyle.characters = 10;

              lineUI[i].catchBt = lineUI[i].add('button', undefined, 'Catch', {name: 'catchTag'});

              lineUI[i].catchBt.onClick = function () { catchTagProperties(i); };

              lineUI[i].newBt = lineUI[i].add('button', undefined, 'New', {name: 'newTag'});

              lineUI[i].newBt.onClick = function () { newTagLine(); };

              lineUI[i].deleteBt = lineUI[i].add('button', undefined, 'Delete', {name: 'deleteTag'});

              lineUI[i].deleteBt.onClick = function () { deleteTagLine(i); };

              myPalette.layout.layout(true);

              myPalette.layout.resize();

              count += 2;

          }

      }

       

      function deleteTagLine(counter) {

          lineUI[counter].hide();

          myPalette.layout.layout(true);

          myPalette.layout.resize();

      }