--- loncom/interface/lonpreferences.pm	2016/08/10 23:50:07	1.196.4.19
+++ loncom/interface/lonpreferences.pm	2016/09/19 03:21:20	1.196.4.23
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.196.4.19 2016/08/10 23:50:07 raeburn Exp $
+# $Id: lonpreferences.pm,v 1.196.4.23 2016/09/19 03:21:20 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1394,13 +1394,19 @@ sub client_form {
     my $output = '<form name="client" action="">'
                 .&Apache::lonhtmlcommon::start_pick_box();
     if ($caller eq 'reset_by_email') {
+        my $mobileargs;
+        (undef,undef,undef,undef,undef,undef,my $clientmobile) =
+            &Apache::loncommon::decode_user_agent();
+        if ($clientmobile) {
+            $mobileargs = 'autocapitalize="off" autocorrect="off" ';
+        }
         $output .= &Apache::lonhtmlcommon::row_title(
                        '<label for="email">'.$lt{'email'}.'</label>')
-                  .'<input type="text" name="email" size="30" />'
+                  .'<input type="text" name="email" size="30" '.$mobileargs.'/>'
                   .&Apache::lonhtmlcommon::row_closure()
                   .&Apache::lonhtmlcommon::row_title(
                        '<label for="uname">'.$lt{'username'}.'</label>')
-                  .'<input type="text" name="uname" size="20" />'
+                  .'<input type="text" name="uname" size="20" '.$mobileargs.'/>'
                   .'<input type="hidden" name="currentpass" value="'.$currentpass.'" />'
                   .&Apache::lonhtmlcommon::row_closure()
                   .&Apache::lonhtmlcommon::row_title(
@@ -1860,6 +1866,58 @@ sub verify_and_change_coursepage {
     &print_main_menu($r,$message);
 }
 
+sub author_space_settings {
+    my $r = shift;
+    &Apache::lonhtmlcommon::add_breadcrumb(
+            {   href => '/adm/preferences?action=authorsettings',
+                text => 'Authoring Space Settings'});
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+    if (keys(%author_roles) > 0) {
+            $r->print(Apache::loncommon::start_page('Authoring Space Settings'));
+            $r->print(Apache::lonhtmlcommon::breadcrumbs('Authoring Space Settings'));
+            my %userenv = &Apache::lonnet::get('environment',['nocodemirror']);
+            my $constchecked='';
+            if ($env{'environment.nocodemirror'}) {
+               $constchecked=' checked="checked"';
+            }
+            my $text=&mt('By default, CodeMirror an editor with advanced functionality for editing code is activated for authors.');
+            my $cmoff=&mt('Deactivate CodeMirror. This can improve performance on slow computers and accessibility.');
+            my $change=&mt('Save');
+            $r->print(<<ENDSCREEN);
+        <form name="prefs" action="/adm/preferences" method="post">
+        <input type="hidden" name="action" value="change_authoring_settings" />
+        $text<br />
+        <label><input type="checkbox" name="cmoff"$constchecked />$cmoff</label><br />
+        <input type="submit" value="$change" />
+        </form>
+ENDSCREEN
+    }
+}
+
+sub change_authoring_settings {
+    my $r = shift;
+    my $user       = $env{'user.name'};
+    my $domain     = $env{'user.domain'};
+    my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+    if (keys(%author_roles) > 0) {
+            my %ausettings=('environment.nocodemirror' => '');
+            if ($env{'form.cmoff'}) { $ausettings{'environment.nocodemirror'}='yes'; }
+            &Apache::lonnet::put('environment',\%ausettings);
+            &Apache::lonnet::appenv({'environment.nocodemirror' => $ausettings{'environment.nocodemirror'}});
+            my $status='';
+            if ($ausettings{'environment.nocodemirror'} eq 'yes') {
+                $status=&mt('on');
+            } else {
+                $status=&mt('off');
+            }
+            my $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.&mt('Deactivate CodeMirror in Authoring Space').'</i>','<tt>'.$status.'</tt>'));
+            $message=&Apache::loncommon::confirmwrapper($message);
+            &print_main_menu($r,$message);
+    }
+}
+
 sub lockednameschanger {
     my $r = shift;
     &Apache::lonhtmlcommon::add_breadcrumb(
@@ -2120,6 +2178,18 @@ push(@{ $menu[4]->{items} }, {
 	});
 
     }
+
+    my %author_coauthor_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au','ca','aa']);
+    if (keys(%author_coauthor_roles) > 0) {
+        push(@{ $menu[4]->{items} }, {
+            linktext => 'Authoring Space Configuration',
+            url => '/adm/preferences?action=authorsettings',
+            permission => 'F',
+            icon => 'codemirror.png',
+            linktitle => 'Settings for your authoring space.',
+        });
+    }
+
     if (&can_toggle_debug()) {
 push(@{ $menu[4]->{items} }, {
 	linktext => 'Toggle Debug Messages (Currently '.($env{'user.debug'} ? 'on)' : 'off)'),
@@ -2228,6 +2298,10 @@ sub handler {
         &coursedisplaychanger($r);
     }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
         &verify_and_change_coursepage($r);
+    }elsif($env{'form.action'} eq 'authorsettings'){
+        &author_space_settings($r);
+    }elsif($env{'form.action'} eq 'change_authoring_settings'){
+        &change_authoring_settings($r);
     }elsif($env{'form.action'} eq 'debugtoggle'){
         if (&can_toggle_debug()) {
             &toggle_debug();