Changeset 14056

Show
Ignore:
Timestamp:
06/18/08 07:39:20 (5 months ago)
Author:
becky
Message:

refs #4607 added support for a mode to use the tab and shift-tab keys to indent outdent list items. Also added ctrl+m as keyboard shortcut for this behavior. Created a simple icon which needs additional work. Needs more work in FF2 on OSX

Location:
dijit/trunk
Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/Editor.js

    r13977 r14056  
    362362                        if(!dojo.isIE && !this.iframe && e.keyCode==dojo.keys.TAB){ 
    363363                                this._saveSelection(); 
     364                        } 
     365                        if (e.keyCode === dojo.keys.TAB && this.isTabIndent ){ 
     366                                dojo.stopEvent(e); //prevent tab from moving focus out of editor 
     367                                // FIXME: this is a poor-man's indent/outdent. It would be 
     368                                // better if it added 4 " " chars in an undoable way. 
     369                                // Unfortunately pasteHTML does not prove to be undoable 
     370                                if (this.queryCommandEnabled((e.shiftKey ? "outdent" : "indent"))){ 
     371                                        this.execCommand((e.shiftKey ? "outdent" : "indent")); 
     372                                } 
     373                        }else if (dojo.isMoz && this.iframe && !this.isTabIndent){ 
     374                                if(     e.keyCode == dojo.keys.TAB &&  
     375                                        !e.shiftKey &&  
     376                                        !e.ctrlKey &&  
     377                                        !e.altKey 
     378                                ){ 
     379                                        // update iframe document title for screen reader 
     380                                        this.iframe.contentDocument.title = this._localizedIframeTitles.iframeFocusTitle; 
     381                                 
     382                                        // Place focus on the iframe. A subsequent tab or shift tab 
     383                                        // will put focus on the correct control. 
     384                                        this.iframe.focus();  // this.focus(); won't work 
     385                                        dojo.stopEvent(e); 
     386                                }else if(e.keyCode == dojo.keys.TAB && e.shiftKey){ 
     387                                        // if there is a toolbar, set focus to it, otherwise ignore 
     388                                        if(this.toolbar){ // FIXME: this is badly factored!!! 
     389                                                this.toolbar.focus(); 
     390                                        } 
     391                                        dojo.stopEvent(e); 
     392                                } 
    364393                        } 
    365394                        if(!this.customUndo){ 
  • dijit/trunk/tests/_editor/test_ToggleDir.html

    r13735 r14056  
    1010        <script type="text/javascript" src="../../../dojo/dojo.js" 
    1111                djConfig="parseOnLoad: true, isDebug: true"></script> 
     12                 
     13        <!-- required: a default dijit theme: --> 
     14        <link id="themeStyles" rel="stylesheet" href="../../../dijit/themes/tundra/tundra.css"> 
     15                 
    1216        <script type="text/javascript" src="../_testCommon.js"></script> 
    1317 
     
    1620                dojo.require("dijit.Editor"); 
    1721                dojo.require("dijit._editor.plugins.ToggleDir"); 
     22                dojo.require("dijit._editor.plugins.TabIndent"); 
    1823                dojo.require("dojo.parser");    // scan page for widgets and instantiate them 
    1924        </script> 
    2025</head> 
    21 <body> 
     26<body class="tundra"> 
    2227        <div style="border: 1px dotted black;"> 
    23                 <textarea dojoType="dijit.Editor"  
     28                <div dojoType="dijit.Editor"  
    2429                        extraPlugins="['toggleDir','|','dijit._editor.plugins.ToggleDir','|',{name:'dijit._editor.plugins.ToggleDir'}]"> 
    2530                        <ol> 
     
    2833                                        left-to-right languages like English.</li> 
    2934                        </ol> 
    30                 </textarea> 
     35                </div> 
    3136        </div> 
    3237</body> 
  • dijit/trunk/themes/tundra/Editor.css

    r13000 r14056  
    5757.tundra .dijitEditorIconToggleDir { background-position: -540px; /* padding: 0; margin: 0; color:#555555; 
    5858                                                                        font-family:verdana,arial,sans-serif; font-weight: 800; font-size: 70%; */} 
     59.tundra .dijitEditorIconTabIndent { background-position: -702px; } 
  • dijit/trunk/_editor/nls/commands.js

    r13273 r14056  
    3838        'fontSize': 'Font Size', 
    3939        'fontName': 'Font Name', 
     40        'tabIndent': 'Tab Indent', 
    4041        /* Error messages */ 
    4142        'systemShortcutFF': 'The "${0}" action is only available in Mozilla Firefox using a keyboard shortcut. Use ${1}.', 
  • dijit/trunk/_editor/RichText.js

    r13977 r14056  
    461461        //              deferred which is fired when the editor finishes loading 
    462462        onLoadDeferred: null, 
     463         
     464        // isTabIndent: Boolean 
     465        //              used to allow tab key and shift-tab to indent and outdent rather than navigate 
     466        isTabIndent: false, 
    463467 
    464468        postCreate: function(){ 
     
    490494                        a: exec("selectall"), 
    491495                        s: function(){ this.save(true); }, 
     496                        m: function(){ this.isTabIndent = !this.isTabIndent; }, 
    492497 
    493498                        "1": exec("formatblock", "h1"), 
     
    798803                                this.execCommand("delete"); 
    799804                        } 
    800                 }else if (dojo.isMoz && this.iframe){ 
    801                         if(     e.keyCode == dojo.keys.TAB &&  
    802                                 !e.shiftKey &&  
    803                                 !e.ctrlKey &&  
    804                                 !e.altKey 
    805                         ){ 
    806                                 // update iframe document title for screen reader 
    807                                 this.iframe.contentDocument.title = this._localizedIframeTitles.iframeFocusTitle; 
    808                                  
    809                                 // Place focus on the iframe. A subsequent tab or shift tab 
    810                                 // will put focus on the correct control. 
    811                                 this.iframe.focus();  // this.focus(); won't work 
    812                                 dojo.stopEvent(e); 
    813                         }else if(e.keyCode == dojo.keys.TAB && e.shiftKey){ 
    814                                 // if there is a toolbar, set focus to it, otherwise ignore 
    815                                 if(this.toolbar){ // FIXME: this is badly factored!!! 
    816                                         this.toolbar.focus(); 
    817                                 } 
    818                                 dojo.stopEvent(e); 
    819                         } 
    820805                } 
    821806                return true; 
     
    10381023                        case "insertorderedlist": case "insertunorderedlist": 
    10391024                        case "indent": case "outdent": case "formatblock": 
    1040                         case "inserthtml": case "undo": case "redo": case "strikethrough": 
     1025                        case "inserthtml": case "undo": case "redo": case "strikethrough": case "tabindent": 
    10411026                                supportedBy = isSupportedBy(mozilla | ie | opera | safari420); 
    10421027                                break;