Changeset 6757


Ignore:
Timestamp:
04/22/11 05:34:05 (3 years ago)
Author:
fredck
Message:

Enhancements to the sample.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CKEditor/branches/features/readonly/_samples/readonly.html

    r6751 r6757  
    1818        //<![CDATA[ 
    1919 
     20var editor; 
     21 
    2022// The instanceReady event is fired, when an instance of CKEditor has finished 
    2123// its initialization. 
    2224CKEDITOR.on( 'instanceReady', function( ev ) 
    2325        { 
    24                 // Show this sample buttons. 
    25                  document.getElementById( 'eButtons' ).style.display = 'block'; 
     26                editor = ev.editor; 
     27 
     28                // Show this "on" button. 
     29                document.getElementById( 'readOnlyOn' ).style.display = ''; 
     30 
     31                // Event fired when the readOnly property changes. 
     32                editor.on( 'readOnly', function() 
     33                        { 
     34                                document.getElementById( 'readOnlyOn' ).style.display = this.readOnly ? 'none' : ''; 
     35                                document.getElementById( 'readOnlyOff' ).style.display = this.readOnly ? '' : 'none'; 
     36                        }); 
    2637        }); 
    2738 
    2839function toggleReadOnly( makeEditable ) 
    2940{ 
    30         // Get the editor instance that we want to interact with. 
    31         var editor = CKEDITOR.instances.editor1; 
    32  
    33         // Change the read-only state of editor. 
     41        // Change the read-only state of the editor. 
    3442        // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setReadOnly 
    3543        editor.setReadOnly( makeEditable ); 
     
    6977                        <textarea class="ckeditor" id="editor1" name="editor1" cols="100" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea> 
    7078                </p> 
    71                 <p id="eButtons" style="display: none"> 
    72                         <input onclick="toggleReadOnly();" type="button" value="Turn on read-only" /> 
    73                         <input onclick="toggleReadOnly( true );" type="button" value="Turn off read-only" /> 
     79                <p> 
     80                        <input id="readOnlyOn" onclick="toggleReadOnly();" type="button" value="Make it read-only" style="display:none" /> 
     81                        <input id="readOnlyOff" onclick="toggleReadOnly( true );" type="button" value="Make it editable again" style="display:none" /> 
    7482                </p> 
    7583        </form> 
Note: See TracChangeset for help on using the changeset viewer.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy