Revision: 549
Author: geof.glass
Date: Fri Jun 22 14:05:41 2012
Log: Eliminate SHOWANNOTATIONS preference, replace with SHEET_NONE
This should fix inconsistency with annotation display and drop-down
http://code.google.com/p/marginalia/source/detail?r=549
Modified:
/moodle/trunk/moodle/blocks/marginalia/MoodleMarginalia.js
/moodle/trunk/moodle/blocks/marginalia/moodle_marginalia.php
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/MoodleMarginalia.js Fri Jun 22
12:59:32 2012
+++ /moodle/trunk/moodle/blocks/marginalia/MoodleMarginalia.js Fri Jun 22
14:05:41 2012
@@ -38,8 +38,7 @@
this.preferences = new Preferences(
new RestPreferenceService( this.annotationPath + '/user-preference.php'
),
prefs );
- this.showAnnotations = prefs[ Marginalia.P_SHOWANNOTATIONS ];
- this.showAnnotations = this.showAnnotations == 'true';
+ this.sheet = prefs[ Marginalia.P_SHEET ];
this.splash = prefs[ Marginalia.P_SPLASH ] == 'true' ? params[ 'splash'
] : null;
this.useSmartquote = params.useSmartquote;
this.allowAnyUserPatch = params.allowAnyUserPatch;
@@ -81,8 +80,6 @@
mia_notes: new Selector( '.mia_margin', '.content .posting .mia_margin' )
};
// URL is blank! Should be a function to construct it from
window.location + '#' + id
-
- this.sheet = prefs[ Marginalia.P_SHEET ];
}
/**
@@ -179,7 +176,7 @@
// Display annotations
var url = this.url;
- if ( this.showAnnotations )
+ if ( Marginalia.SHEET_NONE != this.sheet )
window.marginalia.showAnnotations( url );
// Fix all control margins
@@ -198,7 +195,7 @@
this.smartquote.enable( marginalia.listPosts( ), marginalia.skipContent
);
}
- if ( this.showAnnotations && this.splash )
+ if ( this.splash && this.sheet != Marginalia.SHEET_NONE )
{
var onclose = function() {
window.marginalia.preferences.setPreference(
Marginalia.P_SPLASH, 'false', null);
@@ -325,14 +322,11 @@
else
{
marginalia.hideAnnotations( );
- if ( null == sheet || '' == sheet )
- marginalia.preferences.setPreference(
Marginalia.P_SHOWANNOTATIONS, 'false', null);
- else
+ marginalia.preferences.setPreference( Marginalia.P_SHEET, sheet, null );
+ if ( Marginalia.SHEET_NONE != sheet )
{
marginalia.sheet = sheet;
marginalia.showAnnotations( url );
- marginalia.preferences.setPreference(
Marginalia.P_SHOWANNOTATIONS, 'true', null);
- marginalia.preferences.setPreference( Marginalia.P_SHEET, sheet, null );
this.fixAllControlMargins( );
}
}
=======================================
--- /moodle/trunk/moodle/blocks/marginalia/moodle_marginalia.php Wed May 30
15:12:10 2012
+++ /moodle/trunk/moodle/blocks/marginalia/moodle_marginalia.php Fri Jun 22
14:05:41 2012
@@ -51,7 +51,6 @@
define( 'ANNOTATION_STRINGS', 'block_marginalia' );
define( 'AN_SHEET_PREF', 'annotations.sheet' ); // 'annotations.user' );
-define( 'AN_SHOWANNOTATIONS_PREF', 'annotations.show' );
define( 'AN_NOTEEDITMODE_PREF', 'annotations.note-edit-mode' );
define( 'AN_SPLASH_PREF', 'annotations.splash' );
//define( 'SMARTCOPY_PREF', 'smartcopy' );
@@ -59,6 +58,7 @@
define( 'AN_DBTABLE', 'marginalia' );
define( 'AN_READ_TABLE', 'marginalia_read' );
+define( 'AN_SHEET_NONE' , 0 );
define( 'AN_SHEET_PRIVATE', 0x1 );
define( 'AN_SHEET_AUTHOR', 0x2 );
define( 'AN_SHEET_PUBLIC', 0xffff );
@@ -178,12 +178,10 @@
// in the database if not already present.
$prefs = array(
AN_SHEET_PREF => $this->moodlemia->get_pref( AN_SHEET_PREF, 'public' ),
- AN_SHOWANNOTATIONS_PREF => $this->moodlemia->get_pref(
AN_SHOWANNOTATIONS_PREF, 'false' ),
AN_NOTEEDITMODE_PREF => $this->moodlemia->get_pref(
AN_NOTEEDITMODE_PREF, 'freeform' ),
AN_SPLASH_PREF => $this->moodlemia->get_pref( AN_SPLASH_PREF, 'true' )
);
- $showannotationspref = $prefs[ AN_SHOWANNOTATIONS_PREF ];
$showsplashpref = $prefs[ AN_SPLASH_PREF ];
// Build a string of initial preference values for passing to Marginalia
@@ -290,23 +288,22 @@
$refurl = $this->get_refurl( );
$sheet = $this->get_sheet( );
- $showannotationspref = $this->moodlemia->get_show_annotations_pref( )
== 'true';
echo "<div class='discussioncontrols miacontrols clearfix'>";
echo "<div class='discussioncontrol nullcontrol'> </div><div
class='discussioncontrol'> </div>\n";
echo "<select name='ansheet' class='discussioncontrol miacontrol'
id='ansheet'
onchange='window.moodleMarginalia.changeSheet(this,\"".$refurl."\");'>\n";
- $selected = $showannotationspref ? '' : " selected='selected' ";
- echo " <option $selected value=''>".get_string('sheet_none',
ANNOTATION_STRINGS)."</option>\n";
+ $selected = $sheet == AN_SHEET_NONE ? " selected='selected' " : '';
+ echo " <option $selected
value='".$this->moodlemia->sheet_str(AN_SHEET_NONE,null)."'>".get_string('sheet_none',
ANNOTATION_STRINGS)."</option>\n";
if ( ! isguestuser() ) {
- $selected = ( $showannotationspref && $sheet == AN_SHEET_PRIVATE
) ? "selected='selected' " : '';
+ $selected = $sheet == AN_SHEET_PRIVATE ? "selected='selected' " : '';
echo " <option $selected"
."value='".$this->moodlemia->sheet_str(AN_SHEET_PRIVATE,null)."'>".get_string('sheet_private',
ANNOTATION_STRINGS)."</option>\n";
}
// Show item for all users
if ( true ) {
- $selected = ( $showannotationspref && $sheet == AN_SHEET_PUBLIC
) ? "selected='selected' " : '';
+ $selected = $sheet == AN_SHEET_PUBLIC ? "selected='selected' " : '';
echo " <option $selected
value='".$this->moodlemia->sheet_str(AN_SHEET_PUBLIC,null)."'>".get_string('sheet_public',
ANNOTATION_STRINGS)."</option>\n";
}
echo " <option disabled='disabled'>——————————</option>\n";
@@ -706,10 +703,12 @@
{
if ( 'public' == $sheet_str )
return AN_SHEET_PUBLIC;
+ elseif ( 'private' == $sheet_str )
+ return AN_SHEET_PRIVATE;
elseif ( 'author' == $sheet_str )
return AN_SHEET_AUTHOR;
else
- return AN_SHEET_PRIVATE;
+ return AN_SHEET_NONE;
}
/**
@@ -723,7 +722,8 @@
return 'private';
elseif ( AN_SHEET_AUTHOR == $sheet_type )
return 'author';
- return '';
+ else
+ return 'none';
}
/**
@@ -877,11 +877,6 @@
{
return $this->get_pref( AN_SHEET_PREF, 'public' );
}
-
- public function get_show_annotations_pref( )
- {
- return $this->get_pref( AN_SHOWANNOTATIONS_PREF, 'false' );
- }
/**
* Get JS for strings