[LON-CAPA-cvs] cvs: loncom /html/res/adm/pages/annotator admannotations.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 20 Apr 2006 04:19:56 -0000


albertel		Thu Apr 20 00:19:56 2006 EDT

  Modified files:              
    /loncom/html/res/adm/pages/annotator	admannotations.pm 
  Log:
  - support for annotations in inline mode
  
  
Index: loncom/html/res/adm/pages/annotator/admannotations.pm
diff -u loncom/html/res/adm/pages/annotator/admannotations.pm:1.25 loncom/html/res/adm/pages/annotator/admannotations.pm:1.26
--- loncom/html/res/adm/pages/annotator/admannotations.pm:1.25	Tue Apr 11 11:52:33 2006
+++ loncom/html/res/adm/pages/annotator/admannotations.pm	Thu Apr 20 00:19:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # This will take annotations and then plug them into a page.
 #
-# $Id: admannotations.pm,v 1.25 2006/04/11 15:52:33 albertel Exp $
+# $Id: admannotations.pm,v 1.26 2006/04/20 04:19:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -54,17 +54,34 @@
 }
 
 # ------------------------------------------------------------Construct editor
+sub js_get_url {
+    return <<ENDJS;
+function get_url() {
+    var url;
+    if (typeof(window.opener.clientwindow) != 'undefined') {
+	url=window.opener.clientwindow.location.href;
+    } else {
+	url=window.opener.location.href;
+    }
+    return url;
+}
+ENDJS
+}
 
 sub construct_editor {
     my ($annotation,$urlnew) = @_;
     if ($annotation=~/^error:/) { $annotation=''; }
 
+    my $get_url = &js_get_url();
+
     my $js = <<ENDJS;
 <script type="text/javascript">
 var timeout;
 
+$get_url
+
 function changed() {
-    var urlnew=window.opener.clientwindow.location.href;
+    var urlnew=get_url();
     if (urlnew!=document.annotInfo.urlold.value) {
 	document.annotInfo.urlnew.value=urlnew;
         document.annotInfo.submit();
@@ -96,7 +113,7 @@
     <input type="hidden" name="urlold" value="$urlnew" />
     <input type="hidden" name="urlnew" value="" />
     <input type="button" name="send" value="$lt{'save'}"
-           onclick="javascript:this.form.urlnew.value=window.opener.clientwindow.location.href;this.form.submit();" />
+           onclick="javascript:this.form.urlnew.value=get_url();this.form.submit();" />
     <input type="button" name="close" value="$lt{'close no save'}" 
            onclick="javascript:window.close();" />
   </form>
@@ -109,7 +126,15 @@
 
 sub construct_error {
     my ($annot_error,$button_name) = @_;
-    my $start_page = &Apache::loncommon::start_page('Annotations',undef,
+
+    my $get_url = &js_get_url();
+    my $js = <<ENDJS;
+<script type="text/javascript">
+$get_url
+</script>
+ENDJS
+
+    my $start_page = &Apache::loncommon::start_page('Annotations',$js,
 						    {'only_body'   => 1,});
     my $end_page =  &Apache::loncommon::end_page();
 
@@ -131,7 +156,7 @@
     <input type="hidden" name="urlold" value="" />
     <input type="hidden" name="urlnew" value="" />
     <input type="button" name="send" value="$lt{'button'}"
-           onclick="javascript:this.form.urlnew.value=window.opener.clientwindow.location.href;this.form.submit();" />
+           onclick="javascript:this.form.urlnew.value=get_url();this.form.submit();" />
     <input type="button" name="close" value="$lt{'close'}" 
            onclick="javascript:window.close();" />
   </form>