Zoom factor - store / set?

Last post 04-12-2013, 12:12 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  04-11-2013, 2:55 AM 77210

    Zoom factor - store / set?

    Is there any way to get or set the Zoom factor for the text editor?

    If someone changes the Zoom factor using the bottom-right selection, we would like to capture the value (or alternatively when we are saving the content or closing the form) and we can then store that value in our database so that we could set the initial Zoom factor when they next open the text editor.

    Ta

  •  04-11-2013, 1:11 PM 77216 in reply to 77210

    Re: Zoom factor - store / set?

    Hi ederkley,

     

    The Rich TextEditor did not provide the API to catch the zoom function. you can try the way below to get the zoom value.

     

    1. Open file "richtexteditor\plugins\zoomview\plugin.xml", find section below.

     

             option.selectzoom=function(val)
                      {
                            plugin.zoomvalue=val;
                            label.set_text(val+"%");
                            var zoom=plugin.zoomvalue==100?"":(plugin.zoomvalue+"%");
                            editor.GetWindow().document.body.style.zoom=zoom;
                      }

     

    2. Chnage it to

     

              option.selectzoom=function(val)
                      {
                             var input1 = document.getElementById("input1");
                             input1.value=val;
                            plugin.zoomvalue=val;
                            label.set_text(val+"%");
                            var zoom=plugin.zoomvalue==100?"":(plugin.zoomvalue+"%");
                            editor.GetWindow().document.body.style.zoom=zoom;
                      }
     

    3. In your editor page add an input contrl in the page, like below. Each type you change the zoom, the button value will be changed too. The button just use for the sample, you can change it to anything you need to achieve your own requirement. For example, each time the button value has been changed, then fire a javascript function to achieve your other logic. 

     

      <input type="button" value="test" id="input1" />

     

    Regards,

     

    Ken 

  •  04-11-2013, 10:47 PM 77217 in reply to 77216

    Re: Zoom factor - store / set?

    Thanks for that Ken.

    That handles the Get part.

    Is there a way to set the initial zoom view when the editor loads?

     

    I thought it might just be a matter of editing the plugin.zoomvalue in the same plugin.xml but that does not seem to do anything:

    <execute>

    <![CDATA[

    plugin.zoomvalue=125;

    ...

    If I change that to 125 it still loads at 100%

    Similarly editing the text attribute of the label does not do anything, it shows 125% but the text is still shown at 100%

    <label jsml-local="label" dock="fill" vertical_align="middle" horizontal_align="center" width="30" padding="0,2,0,-2" margin="0,0,0,4" text="125%" cursor="pointer" />

     

  •  04-12-2013, 12:12 PM 77222 in reply to 77217

    Re: Zoom factor - store / set?

    Hi,

     

    To set the zoom of the editor body, you can use the code below. It will fire when the editor load. 3 means 300%.

     

    Note that, this code only use to change the zoom of the editor body, it will not change the "zoom" section at the bottom bar. 

     

    1. <script type="text/javascript">  
    2.       
    3.     function RichTextEditor_OnLoad(rteeditor) {  
    4.         rteeditor.GetWindow().document.body.style.zoom = 3;  
    5.     }  
    6. </script>  
     

    Regards,

     

    Ken 

View as RSS news feed in XML