[LON-CAPA-cvs] cvs: loncom /interface lonhtmlcommon.pm lonpreferences.pm

foxr foxr at source.lon-capa.org
Mon Oct 8 06:26:35 EDT 2012


foxr		Mon Oct  8 10:26:35 2012 EDT

  Modified files:              
    /loncom/interface	lonhtmlcommon.pm lonpreferences.pm 
  Log:
  1. Use Jpicker for color preferences.
  2. Ensure that Jpicker dialog will not be partially off-screen.
  
  
  
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.325 loncom/interface/lonhtmlcommon.pm:1.326
--- loncom/interface/lonhtmlcommon.pm:1.325	Mon Sep 24 11:04:20 2012
+++ loncom/interface/lonhtmlcommon.pm	Mon Oct  8 10:26:34 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.325 2012/09/24 11:04:20 foxr Exp $
+# $Id: lonhtmlcommon.pm,v 1.326 2012/10/08 10:26:34 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1101,6 +1101,7 @@
     undef(%$prog_state);
 }
 
+
 # ------------------------------------------------------- Puts directory header
 
 sub crumbs {
@@ -1230,6 +1231,17 @@
     return $lang;
 }
 
+# return javacsript to activate elements of .colorchooser with jpicker:
+# Caller is responsible for enclosing this in <script> tags:
+#
+sub color_picker {
+    return '
+$(document).ready(function(){
+    $.fn.jPicker.defaults.images.clientPath="/adm/jpicker/images/";
+    $(".colorchooser").jPicker({window: { position: {x: "screenCenter", y: "bottom"}}});
+});';
+}
+
 # ----------------------------------------- Script to activate only some fields
 
 sub htmlareaselectactive {
@@ -1349,6 +1361,8 @@
 
 	});
 ';
+    $output .= &color_picker;
+
     # Code to put a due date countdown in 'duedatecountdown' span.
     # This is currently located in the breadcrumb headers.
     # note that the dueDateLayout is internatinoalized below.
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.199 loncom/interface/lonpreferences.pm:1.200
--- loncom/interface/lonpreferences.pm:1.199	Thu Oct  4 13:41:10 2012
+++ loncom/interface/lonpreferences.pm	Mon Oct  8 10:26:34 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Preferences
 #
-# $Id: lonpreferences.pm,v 1.199 2012/10/04 13:41:10 bisitz Exp $
+# $Id: lonpreferences.pm,v 1.200 2012/10/08 10:26:34 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1227,12 +1227,9 @@
     foreach my $item (sort(keys(%colortypes))) {
        my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
        $chtable.=&Apache::loncommon::start_data_table_row().
-	   '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol.
-        '">      </td><td><input name="'.$item.
-        '" size="10" value="'.$curcol.
-'" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
-"','".$curcol."','"
-	    .$item."','parmform.pres','psub'".');">'.&mt('Select').'</a></td>'.
+	   '<td>'.$colortypes{$item}.'<td><input name="'.$item.
+        '" class="colorchooser"  size="10" value="'.$curcol.
+'" /></td>'.
 	    &Apache::loncommon::end_data_table_row()."\n";
     }
     my $end_data_table = &Apache::loncommon::end_data_table();
@@ -1240,27 +1237,13 @@
     my $savebutton = &mt('Save');
     my $resetbutton = &mt('Reset All');
     my $resetbuttondesc = &mt('Reset All Colors to Default');
+    my $colorchooser=&Apache::lonhtmlcommon::color_picker();
+    $r-print('<script type="text/javascript" language="JavaScript">
+' . $colorchooser . '
+</script>
+');
     $r->print(<<ENDCOL);
-<script type="text/javascript" language="JavaScript">
-
-    $pjump_def
-
-    function psub() {
-        modalWindow.close();
-        if (document.parmform.pres_marker.value!='') {
-            if (document.parmform.pres_type.value!='') {
-                eval('document.prefs.'+
-                     document.parmform.pres_marker.value+
-		     '.value=document.parmform.pres_value.value;');
-	    }
-        } else {
-            document.parmform.pres_value.value='';
-            document.parmform.pres_marker.value='';
-        }
-    }
-
 
-</script>
 <form name="parmform">
 <input type="hidden" name="pres_marker" />
 <input type="hidden" name="pres_type" />
@@ -1299,6 +1282,9 @@
     my $message='';
     foreach my $item (keys %colortypes) {
         my $color=$env{'form.'.$item};
+	if (!($color =~ /^#/)) {
+	    $color = '#' . $color;
+	}
         my $entry='color.'.$function.'.'.$item;
 	if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
 	    &Apache::lonnet::put('environment',{$entry => $color});




More information about the LON-CAPA-cvs mailing list