[LON-CAPA-cvs] cvs: loncom /interface londocs.pm
raeburn
raeburn at source.lon-capa.org
Mon Aug 15 12:31:55 EDT 2011
raeburn Mon Aug 15 16:31:55 2011 EDT
Modified files:
/loncom/interface londocs.pm
Log:
- scrollbox height resized dynamically onload, and when category selected from
tools tab.
Work in progress.
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.456 loncom/interface/londocs.pm:1.457
--- loncom/interface/londocs.pm:1.456 Thu Jul 21 03:31:12 2011
+++ loncom/interface/londocs.pm Mon Aug 15 16:31:55 2011
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.456 2011/07/21 03:31:12 raeburn Exp $
+# $Id: londocs.pm,v 1.457 2011/08/15 16:31:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1759,8 +1759,8 @@
&Apache::loncommon::end_data_table_count();
if ($shown) {
- $r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px')
- .&Apache::loncommon::start_data_table());
+ $r->print(&Apache::loncommon::start_scrollbox('900px','880px','400px','contentscroll')
+ .&Apache::loncommon::start_data_table(undef,'contentlist'));
if ($allowed) {
$r->print(&Apache::loncommon::start_data_table_header_row()
.'<th colspan="2">'.&mt('Move').'</th>'
@@ -1812,7 +1812,7 @@
$LONCAPA::map::resources[1]='';
}
if ($fatal) {
- $$upload_output = '<p><span class="LC_error">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</span></p>';
+ $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('The uploaded file has not been stored as an error occurred reading the contents of the current folder.').'</div>';
return;
}
my $destination = 'docs/';
@@ -1838,7 +1838,7 @@
} else {
my ($filename) = ($env{'form.uploaddoc.filename'} =~ m{([^/]+)$});
- $$upload_output = '<p><span class="LC_error">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</span></p>';
+ $$upload_output = '<div class="LC_error" id="uploadfileresult">'.&mt('Unable to save file [_1].','<span class="LC_filename">'.$filename.'</span>').'</div>';
return;
}
my $ext='false';
@@ -1857,7 +1857,7 @@
($errtext,$fatal)=&storemap($coursenum,$coursedom,
$folder.'.'.$container);
if ($fatal) {
- $$upload_output = '<p><span class="LC_error">'.$errtext.'</span></p>';
+ $$upload_output = '<div class="LC_error" id="uploadfileresult">'.$errtext.'</div>';
return;
} else {
if ($parseaction eq 'parse' && $mimetype eq 'text/html') {
@@ -1884,6 +1884,7 @@
} else {
$$upload_output .= &mt('No embedded items identified').'<br />';
}
+ $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
}
}
}
@@ -2752,14 +2753,14 @@
if ($allowed) {
$r->print('<li '.(($mode eq 'docs')?' class="active"':'').
- '><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>');
+ ' id="tabbededitor"><a href="/adm/coursedocs?forcestandard=1"><b> '.&mt('Content Editor').' </b></a></li>');
}
$r->print('<li'.(($mode eq 'coursesearch')?' class="active"':'').'><a href="/adm/searchcourse"><b> '.&mt('Content Search').' </b></a></li>');
$r->print('<li'.(($mode eq 'courseindex')?' class="active"':'').'><a href="/adm/indexcourse"><b> '.&mt('Content Index').' </b></a></li>');
$r->print('<li '.(($mode eq 'supdocs')?' class="active"':'').
'><a href="/adm/coursedocs?forcesupplement=1"><b>'.&mt('Supplemental Documents').'</b></a></li>');
$r->print('</ul>');
- $r->print('<div class="LC_Box" style="clear:both;margin:0;">'
+ $r->print('<div class="LC_Box" style="clear:both;margin:0;" id="contenteditor">'
.'<div id="maincoursedoc" style="margin:0 0;padding:0 0;">');
$r->print('<div class="LC_ContentBox" id="mainCourseDocuments" style="display: block;">');
}
@@ -2859,6 +2860,7 @@
my $script='';
my $showdoc=0;
+ my $addentries = {};
my $containertag;
my $uploadtag;
@@ -2959,7 +2961,12 @@
$iconpath = &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL') . "/");
if ($allowed) {
- $script .= &editing_js($udom,$uname);
+ $script .= &editing_js($udom,$uname).
+ &resize_contentdiv_js();
+ $addentries = {
+ onload => "javascript:resize_contentdiv('contentscroll');",
+ onresize => "javascript:resize_contentdiv('contentscroll');",
+ };
}
# -------------------------------------------------------------------- Body tag
$script = '<script type="text/javascript">'."\n"
@@ -2975,7 +2982,9 @@
href=>"/adm/coursedocs",text=>"$crstype Contents"});
$r->print(&Apache::loncommon::start_page("$crstype Contents", $script,
- {'force_register' => $showdoc,})
+ {'force_register' => $showdoc,
+ 'add_entries' => $addentries,
+ })
.&Apache::loncommon::help_open_menu('','',273,'RAT')
.&Apache::lonhtmlcommon::breadcrumbs(
'Editing the Table of Contents for your '.$crstype,
@@ -3113,14 +3122,12 @@
$simpleeditdefaultform .= &create_form_ul(&create_list_elements(@simpleeditdefaultforma));
$simpleeditdefaultform .=(<<SEDFFORM);
<hr />
- <p>
$lt{'copm'}<br />
<input type="text" size="40" name="importmap" /><br />
<span class="LC_nobreak"><input type="button"
onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
$help{'Load_Map'}</span>
- </p>
</form>
SEDFFORM
@@ -3943,6 +3950,7 @@
current.className = 'active';
currentData = document.getElementById(pageId);
currentData.style.display = 'block';
+ resize_contentdiv('contentscroll');
if (nav == 'mainnav') {
var storedpath = "$docs_folderpath";
if (storedpath == '') {
@@ -3989,6 +3997,74 @@
ENDNEWSCRIPT
}
+
+sub resize_contentdiv_js {
+ my $viewport_js = &Apache::loncommon::viewport_geometry_js();
+ return <<ENDRESIZESCRIPT;
+
+$viewport_js
+
+function resize_contentdiv(scrollboxid) {
+ if (document.getElementById("contenteditor") == null) {
+ return;
+ }
+ init_geometry();
+ var vph = Geometry.getViewportHeight();
+
+ var primaryheight = document.getElementById("LC_nav_bar").offsetHeight;
+ var secondaryheight = document.getElementById("LC_secondary_menu").offsetHeight;
+ var crumbsheight = document.getElementById("LC_breadcrumbs").offsetHeight;
+ var dccidheight = document.getElementById("dccid").offsetHeight;
+
+ var uploadresultheight = 0;
+ if (document.getElementById("uploadfileresult") != null) {
+ uploadresultheight = document.getElementById("uploadfileresult").offsetHeight;
+ }
+ var tabbedheight = document.getElementById("tabbededitor").offsetHeight;
+ var contenteditorheight = document.getElementById("contenteditor").offsetHeight;
+ if (document.getElementById(scrollboxid) != null) {
+ var scrollbox = document.getElementById(scrollboxid);
+ var scrollboxheight = scrollbox.offsetHeight;
+ var scrollboxscrollheight = scrollbox.scrollHeight;
+
+ var freespace = vph-(primaryheight+secondaryheight+crumbsheight+dccidheight+uploadresultheight+tabbedheight+contenteditorheight);
+
+ var minscrollbox = 60;
+ var offset = 20;
+ var newscrollboxheight;
+ if (freespace < 0) {
+ newscrollboxheight = scrollboxheight+freespace-offset;
+ if (newscrollboxheight < minscrollbox) {
+ newscrollboxheight = minscrollbox;
+ }
+ scrollbox.style.height = newscrollboxheight + "px";
+ } else {
+ if (scrollboxscrollheight > scrollboxheight) {
+ if (freespace > offset) {
+ newscrollboxheight = scrollboxheight+freespace-offset;
+ if (newscrollboxheight < minscrollbox) {
+ newscrollboxheight = minscrollbox;
+ }
+ scrollbox.style.height = newscrollboxheight+"px";
+ }
+ }
+ }
+ scrollboxheight = scrollbox.offsetHeight;
+
+ if (scrollboxscrollheight <= scrollboxheight) {
+ var contentlistheight = document.getElementById("contentlist").offsetHeight;
+ if ((contentlistheight+offset)<scrollboxheight) {
+ newscrollheight = contentlistheight;
+ scrollbox.style.height = newscrollheight+"px";
+ }
+ }
+ }
+}
+
+ENDRESIZESCRIPT
+ return;
+}
+
1;
__END__
More information about the LON-CAPA-cvs
mailing list