questia.Package( "coreweb.reader" );
coreweb.reader.viewTypeOnChange = function(form) {
form.submit();
}
coreweb.reader.isLoggedIn = function(){
return questia.Dictionary.user.loggedIn;
}
function showHideLogin(input){
if(input == "show"){
parent.document.getElementById("loginWindow").style.display="block";
}else if(input == "hide" || input == null || input == ""){
parent.document.getElementById("loginWindow").style.display="none";
}
}
coreweb.reader.showFeatureDialog = function(messageText, toolName) {
var newwidth = window.screen.width;
document.getElementById("loginWindow").style.left = (newwidth-450)/2+"px";
document.getElementById("loginWindow").style.top = coreweb.common.ComponentUtils.getPosition(document.getElementById("readerToolbar") ).top + 10 + 'px';
showHideLogin("show");
}
coreweb.reader.getSelectedText = function() {
return encodeURI(coreweb.reader.selectedText);
}
coreweb.reader.updateSelectedText = function() {
// alert( coreweb.reader.globalSelectedText);
coreweb.reader.selectedText = coreweb.reader.globalSelectedText;
}
coreweb.reader.doHighlight = function(color){
var selection = coreweb.reader.getSelectedText();
//alert('plain='+coreweb.reader.selectedText.length +'total='+selection.length);
if(coreweb.reader.isLoggedIn() && selection.length <= 1900){
coreweb.reader.globalSelectedText='';
var pageCoords = questia.Dictionary.innerReaderArea.pageCoords;
var offset = 0;
if( typeof( window.frames.controlFrame.pageYOffset ) == 'number' ) {
//Netscape compliant
offset = window.frames.controlFrame.pageYOffset;
} else if( window.frames.controlFrame.document.body && window.frames.controlFrame.document.body.scrollTop ) {
//DOM compliant
offset = window.frames.controlFrame.document.body.scrollTop;
} else if( window.frames.controlFrame.document.documentElement && window.frames.controlFrame.document.documentElement.scrollTop ) {
//IE6 standards compliant mode
offset = window.frames.controlFrame.document.documentElement.scrollTop;
}
if ( pageCoords ) {
//alert('The Highlight feature is not available for image books at this time. Coming soon!\n');
if(questia.Dictionary.innerReaderArea.imageHeight > 0 || questia.Dictionary.innerReaderArea.imageWidth > 0) {
var imageInfo = {offset:offset , color:color };
questia.Events.notify(this,'page.reader','doHighlightForImages', imageInfo);
return false;
} else{
alert('Highlight feature cannot be used with a rotated image.\n');
}
} else {
if (selection=='') {
alert('To use the highlight feature please select some text on the page first.\nThen select which color to use for the highlight from the menu.');
} else{
var url = "/reader/action/text/highlight?highlight_color=" + color+ "&offset="+offset+"&highlight_text=" + selection;
window.controlFrame.location.href=url;
}
}
}else if(selection.length > 1900) {
alert("The amount of text you tried to highlight is bigger than the maximum allowed.\nPlease try again highlighting less text.");
}else{
coreweb.reader.showFeatureDialog("highlight words or passages in the publication you are reading.","highlights");
}
}
coreweb.reader.cite = function(){
if(coreweb.reader.isLoggedIn()){
coreweb.reader.updateSelectedText();
var selection = coreweb.reader.getSelectedText();
var forward = '/CitationHandler.qst?citeaction=createCitationBegin¤t_docid='+questia.Dictionary.reader.docId;
var url = '/reader/action/selectTextRedirect?docId=' + questia.Dictionary.reader.docId + '&text=' + selection + '&url=' + escape(forward);
coreweb.common.openWindow(url, 'Citation', 600,500 );
} else{
coreweb.reader.showFeatureDialog("create a citation to the page you are reading that you can paste into your paper. Highlight a passage to include that passage as a quotation.","citation");
}
}
coreweb.reader.showDictionary = function() {
if(coreweb.reader.isLoggedIn()){
coreweb.reader.updateSelectedText();
var selection = coreweb.reader.getSelectedText();
var forward = '/RefToolsHTMLMediator.qst?action=dict_word';
var url = '/reader/action/selectTextRedirect?docId=' + questia.Dictionary.reader.docId + '&text=' + selection + '&url=' + escape(forward);
coreweb.common.openWindow( url, 'Reference', 680, 480, 'yes', 'yes');
}else{
coreweb.reader.showFeatureDialog("look up words in a dictionary, thesaurus, or encyclopedia.","reference");
}
}
coreweb.reader.showThesaurus = function() {
if(coreweb.reader.isLoggedIn()){
coreweb.reader.updateSelectedText();
var selection = coreweb.reader.getSelectedText();
var forward = '/RefToolsHTMLMediator.qst?action=th_list_word';
var url = '/reader/action/selectTextRedirect?docId=' + questia.Dictionary.reader.docId + '&text=' + selection + '&url=' + escape(forward);
coreweb.common.openWindow( url, 'Reference', 680, 480, 'yes', 'yes');
}else{
coreweb.reader.showFeatureDialog("look up words in a dictionary, thesaurus, or encyclopedia.","reference");
}
}
coreweb.reader.addBibliography = function() {
if(coreweb.reader.isLoggedIn()){
var callback = function( responseText ) {
document.body.style.cursor = "default";
var response = eval("(" + responseText + ")");
alert(response.message);
}
document.body.style.cursor = "wait";
questia.asyncRequest.get( "/reader/action/addBibliography/" + questia.Dictionary.reader.docId, callback );
}else{
coreweb.reader.showFeatureDialog("save a reference to the publication you are reading for your bibliography or generate a bibliography you can paste into your paper.","bibliography");
}
}
coreweb.reader.createBibliography = function() {
if(coreweb.reader.isLoggedIn()){
var url = "/CitationHandler.qst?citeaction=createBibliographyBegin";
coreweb.common.openWindow(url, 'Bilbiography', 600, 500);
}else{
coreweb.reader.showFeatureDialog("save a reference to the publication you are reading for your bibliography or generate a bibliography you can paste into your paper.","bibliography");
}
}
coreweb.reader.showProjects = function() {
if(coreweb.reader.isLoggedIn()){
window.location.href = '/workspace/projects?returnUrl=/reader';
}else{
coreweb.reader.showFeatureDialog("create and manage separate folders for your different research projects. Highlights, bookmarks, bibliographies, etc. are saved in your current project.","projects");
}
}
coreweb.reader.printPage = function() {
/**
* define in pritnDialog.html
*/
coreweb.reader.showPrintDialog();
}
coreweb.reader.addBookshelf = function() {
if(coreweb.reader.isLoggedIn()){
var callback = function( responseText ) {
document.body.style.cursor = "default";
var expr = "(" + responseText + ")";
var response = eval(expr);
if ( response.result ) {
alert( response.message );
}
}
document.body.style.cursor = "wait";
questia.asyncRequest.get( "/reader/action/addBookshelf/"+questia.Dictionary.reader.docId, callback );
}else{
coreweb.reader.showFeatureDialog("save a link to the publication you are reading or view all the publications you have put on your bookshelf.","bookshelf");
}
}
coreweb.reader.viewBookshelf = function() {
if(coreweb.reader.isLoggedIn()){
coreweb.common.openWindow( "/reader/action/viewBookshelf", 'Bookshelf', 440,360 );
}else{
coreweb.reader.showFeatureDialog("save a link to the publication you are reading or view all the publications you have put on your bookshelf.","bookshelf");
}
}
coreweb.reader.bookmark = function() {
if(coreweb.reader.isLoggedIn()){
var callback = function( responseText ) {
document.body.style.cursor = "default";
var expr = "(" + responseText + ")";
var response = eval(expr);
if ( response.result ) {
if(response.message == 'visible'){
alert('This page has been bookmarked.');
}
questia.Events.notify(this,'page.reader','bookmark',response.message);
}else{
alert('Sorry, there has been a problem with your bookmark: '+response.message);
}
}
document.body.style.cursor = "wait";
questia.asyncRequest.get( "/reader/action/bookmark/" + questia.Dictionary.reader.docId, callback );
}else{
coreweb.reader.showFeatureDialog("save a link to the page you are reading, which you can later return to from Workspace.","bookmark");
}
}
coreweb.reader.addNote = function(){
if(coreweb.reader.isLoggedIn()){
coreweb.common.openWindow( "/reader/action/addNote?docId=" + questia.Dictionary.reader.docId, 'Notes', 460,360 );
}else{
coreweb.reader.showFeatureDialog("save a note you write on the publication page you are reading.","notes");
}
}
coreweb.reader.showEncyclopedia = function() {
if(coreweb.reader.isLoggedIn()){
var url = "/PM.qst?a=o&docId=112841714";
coreweb.common.openWindow( url, 'Reference', 750, 550, 'yes','yes' );
}else{
coreweb.reader.showFeatureDialog("look up words in a dictionary, thesaurus, or encyclopedia.","reference");
}
}
// Help messages
coreweb.reader.showBookshelfHelp = function() {
coreweb.reader.helpTool('/WebHelp/bookshelf_help.htm' );
}
coreweb.reader.showHighlightHelp = function() {
coreweb.reader.helpTool('/WebHelp/page_view_highlighter_help.htm' );
}
coreweb.reader.showBibliographyHelp = function() {
coreweb.reader.helpTool( '/WebHelp/page_view_citation_help.htm');
}
coreweb.reader.showDictionaryHelp = function() {
coreweb.reader.helpTool( '/WebHelp/page_view_dictionthes_help.htm');
}
coreweb.reader.helpTool = function(url){
coreweb.common.openWindow( url, 'Help', 640, 480, 'yes', 'yes' );
}
var highlightMenu='Highlight';
var quoteCiteMenu='Quote/Cite';
var referenceMenu='Reference';
var yellowIcon ="
";
var pinkIcon = "
";
var limeIcon = "
";
var blueIcon = "
";
var orangeIcon ="
";
var violetIcon ="
";
//Submenus are defined here as links in order to maintain the text highlighted when user clicks in a color.
var yellowsubmenu='Yellow';
var pinksubmenu='Pink';
var greensubmenu='Lime Green';
var bluesubmenu='Light Blue';
var orangesubmenu='Orange';
var violetsubmenu='Violet';
var dictionarySubmenu='Dictionary';
var thesaurusSubmenu='Thesaurus';
var encyclopediaSubmenu='Encyclopedia';
coreweb.reader.doHighlightYellow = function(){ coreweb.reader.doHighlight('yellow');}
coreweb.reader.doHighlightPink = function(){ coreweb.reader.doHighlight('pink');}
coreweb.reader.doHighlightGreen = function(){ coreweb.reader.doHighlight('lime_green');}
coreweb.reader.doHighlightBlue = function(){ coreweb.reader.doHighlight('light_blue');}
coreweb.reader.doHighlightOrange = function(){ coreweb.reader.doHighlight('orange');}
coreweb.reader.doHighlightViolet = function(){ coreweb.reader.doHighlight('violet');}
coreweb.reader.clearSearchHiglights = function(){ questia.Events.notify(this,'page.reader','clearHL');}
coreweb.reader.initMenu = function(){
var myMenu =
[
[null, 'Projects', coreweb.reader.showProjects, null, new coreweb.ui.QTip('manageTipMenu','manageTip', enableTips)], // a menu item
_cmSplit,
[null, 'Bookshelf', null, null, new coreweb.ui.QTip('bookshelfTipMenu','bookshelfTip', enableTips), // a folder item
[null, 'Add to Bookshelf', coreweb.reader.addBookshelf, null, null], // a menu item
[null, 'View Bookshelf', coreweb.reader.viewBookshelf, null, null], // a menu item
[null, 'Help', coreweb.reader.showBookshelfHelp, null, null] // a menu item
],
_cmSplit,
[null, 'Bookmark', coreweb.reader.bookmark, null, new coreweb.ui.QTip('bibliographyTipMenu','bookmarkTip', enableTips)],
_cmSplit,
[null, highlightMenu, null, null, new coreweb.ui.QTip('highlightfTipMenu','highlightTip', enableTips), // a folder item
[yellowIcon, yellowsubmenu, coreweb.reader.doHighlightYellow, null, null],
[pinkIcon, pinksubmenu, coreweb.reader.doHighlightPink, null, null],
[limeIcon, greensubmenu, coreweb.reader.doHighlightGreen, null, null],
[blueIcon, bluesubmenu, coreweb.reader.doHighlightBlue, null, null],
[orangeIcon, orangesubmenu, coreweb.reader.doHighlightOrange, null, null],
[violetIcon, violetsubmenu, coreweb.reader.doHighlightViolet, null, null],
_cmSplit,
[null,'Clear Search Highlights',coreweb.reader.clearSearchHiglights , null, null],
[null,'Help', coreweb.reader.showHighlightHelp, null, null]
],
_cmSplit,
[null, 'Add Note', coreweb.reader.addNote, null, new coreweb.ui.QTip('addNoteTipMenu','addNoteTip', enableTips)],
_cmSplit,
[null, quoteCiteMenu, coreweb.reader.cite, null, new coreweb.ui.QTip('citeTipMenu','citeTip', enableTips)],
_cmSplit,
[null, 'Bibliography', null, null, new coreweb.ui.QTip('biblioTipMenu','biblioTip', enableTips), // a folder item
[null, 'Add to Bibliography', coreweb.reader.addBibliography, null, null], // a menu item
[null, 'Create Bibliography', coreweb.reader.createBibliography, null, null], // a menu item
[null, 'Help', coreweb.reader.showBibliographyHelp, null, null] // a menu item
],
_cmSplit,
[null, 'Print', coreweb.reader.printPage, null, new coreweb.ui.QTip('printTipMenu','printTip', enableTips)], // print menu
_cmSplit,
[null, referenceMenu, null, null, new coreweb.ui.QTip('referenceTipMenu','referenceTip', enableTips ),
[null, dictionarySubmenu, coreweb.reader.showDictionary, null, null],
[null, thesaurusSubmenu, coreweb.reader.showThesaurus, null, null],
[null, encyclopediaSubmenu, coreweb.reader.showEncyclopedia, null, null],
[null, 'Help', coreweb.reader.showDictionaryHelp, null, null]
]
];
return myMenu;
}