Best JavaScript code snippet using playwright-internal
sd_131R4.js
Source:sd_131R4.js
...1484 if(SDM.outlineTab=='I') {1485 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);1486 }1487 else {1488 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);1489 }1490 }1491 }1492 else {1493 Outline.getJson ();1494 tocCounter++;1495 trd = trd*SDM.pm.toc.retryFactor;1496 tocIntrvl = setInterval(tocCheck, trd);1497 }1498 }1499 ///////////1500 var tocIntrvl = setInterval(tocCheck, trd);1501 }1502 }1503 else {1504 $('#centerInner').outline( $('#outline'), page.opts );1505 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());1506 if($('#outline').width()>240){1507 $('#outline > ul,#articleLeftAd').css('width', $('#outline').width()-$.scrollBarWidth());1508 }else{1509 $('#outline > ul,#articleLeftAd').css('width', 240);1510 }1511 $('#outline').attr('data-st', 0);1512 }1513 $('#outline').attr('data-st', 0);1514 CollapsibleTextbox.init();1515 page.delayedScrollHandler = _.debounce( page.viewHandler, 300 );1516 $( "#centerPane" ).bind( "scroll.viewHandler", page.delayedScrollHandler );1517 1518 $("#page-area").on("click", ".intra_ref,.authorVitaeLink,.figureLink,.authorName, .viewWS", {z:'centerPane'}, rightSidePane.findTargetElement);1519 if (Fragment.isAvail())1520 $("#outline").on("click", ".tocLink", {z:'leftPane'}, Outline.findTargetFragment);1521 else 1522 $("#outline").on("click", ".tocLink", Outline.moveToSection);1523 1524 $("#centerPane").on('click', '.btnHolder', function(e){page.toggleOptions(e,this);} );1525 $('a.articleOptions').toggle(1526 function() { $('div.articleOptions').css('display', 'block');},1527 function() { $('div.articleOptions').css('display', 'none');}1528 );1529 $('#optImgToggle').click(function() {page.toggleImages('toolbar');});1530 $('#leftPane').height('');1531 page.lazyLoadInit();1532 page.showFullTableLink();1533 $('div.downloadCsv').bind("click", TableDownload.processRequest);1534 $('a.ppt').bind("click", FigureDownload.processRequest);1535 if(SDM.pm.contentType == "BK") EbookTOC.init();1536 if(SDM.isMRWMODArticle && SDM.ldrAvail) {$('.outlineMsg').hide();mrwLeftPane.init();}1537 EComponent.init();1538 CanonicalLink.init();1539 CanonicalHomeLink.init();1540 page.searchWithinInit();1541 if(!SDM.crawlerAvail) { refResolve(); }1542 if(SDM.displayGadgets) {1543 if (SDM.sciverseGadgetDetailsID.length > 0) {1544 GadgetUtil.loadGadgetsParallel();1545 } else {1546 GadgetUtil.loadGadgets();1547 }1548 }1549 Outline.hoverOverOff();1550 $('#centerPane')[0].tabIndex = -1;1551 $('#centerPane')[0].focus();1552 if (typeof(SDM.fab) != 'undefined' && SDM.pm.itemWeight == 'FULL-TEXT') { EReader.fabRequest(); }1553 ready=true; 1554 } //addJS1555 } //page1556 if($('#frag_1').length || !Fragment.isAvail()) {1557 page.addJS();1558 }1559 else {1560 var if1 = setInterval(function() {1561 if($('#frag_1').length) {1562 clearInterval(if1);1563 page.addJS();1564 }1565 else {1566 //nothing wait for it1567 }1568 }, 250);1569 }1570 return page;1571 }();1572} //initializeArticlePage1573function checkSearchWithin() {1574 if($('#searchWithin input[type=text]').prop('value')=='') {1575 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1576 }1577 else {1578 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1579 }1580}1581$.fn.outline = function(oObj, opts, tocJson) {1582 var cfg = {1583 empty: false,1584 selector: '.outlineItem',1585 graphicsToggler: true,1586 searchWithin: false,1587 focusEffect: true,1588 focus: {}1589 };1590 Outline.oObj = oObj;1591 return this.each(function() {1592 if(opts) {1593 $.extend(true, cfg, opts);1594 }1595 oObj.append('<ul id="itemOutline"></ul>');1596 var $iOutline = $('#itemOutline');1597 if(cfg.graphicsToggler) {1598 $('#outline.js').css('top', 32);1599 if(SDM.pm.contentType=="BK") {1600 $('#outline.book').css('top', 44);1601 }1602 if(SDM.isMRWMODArticle) {1603 $('#outline.book').css('top', 10);1604 }1605 1606 oObj.parent().prepend('<div id="olGraphCbBox">'1607 + '<label><input id="outlineGraphicsCheckBox" type="checkBox" checked="true">Show thumbnails in outline</label>'1608 + '</div>');1609 }1610 if(cfg.searchWithin) {1611 oObj.parent().prepend('<div id="searchWithin" class="textEntry" role="Search" aria-label="Book">'1612 + '<form name="searchWithinForm" action="javascript:checkSearchWithin();ArticlePage.searchWithinSubmit();">'1613 + '<input type="text" value="Search this book" title="Search this book" size="26" maxlength="450"></input></form>'1614 + '<button class="clearWithin" title="Clear book search"><div class="clearXHide"></div></button>'1615 + '<button class="submit" title="Search this book"></button>'1616 + '</div>');1617 $('#searchWithin button.clearWithin').click(function() {1618 $('#searchWithin input[type=text]').prop('value', 'Search this book');1619 $(this).children().addClass('clearXHide').removeClass('clearXShow');1620 SearchWithin.clear();1621 });1622 $('#leftPane button.submit').click(function() {ArticlePage.searchWithinSubmit();});1623 $('#searchWithin input[type=text]').focusin(function() {1624 if($(this).prop('value')=='Search this book') {1625 $(this).prop('value', '');1626 }1627 });1628 $('#searchWithin input[type=text]').focusout(function() {1629 if($(this).prop('value')=='') {1630 $(this).prop('value', 'Search this book');1631 $(this).parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1632 }1633 else {1634 $(this).parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1635 }1636 });1637 }1638 var level = "";1639 var isGraphics = false;1640 prs.rt('outlineLoop_start');1641 if (SDM.tocCacheAvail) {1642 if(typeof tocJson == 'undefined') {1643 //miss and retries are done1644 Outline.buildOutlineUnavailable(cfg);1645 Outline.postBuild(cfg);1646 }1647 else {1648 // build outline from JSON1649 var outlineObj;1650 try {1651 outlineObj = $.parseJSON(tocJson);1652 Outline.buildOutlineJsonSide(cfg, outlineObj);1653 }1654 catch(e) {1655 SDM.tocCacheAvail = false;1656 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid + "/ftp");1657 if(Fragment.isAvail()) {1658 //Pull in the rest of the article and build it clientside1659 Fragment.get('all', null, {successCb: Outline.buildOutlineClientSide,1660 successCbArg: cfg,1661 failureCb: Outline.buildOutlineUnavailable,1662 failureCbArg: cfg1663 });1664 return;1665 }1666 else {1667 Outline.buildOutlineClientSide(cfg);1668 }1669 }1670 }1671 }1672 else {1673 // Build outline from center pane contents1674 Outline.buildOutlineClientSide(cfg);1675 }1676 }); //return1677 if(mathRenderer.opt.renderOn)mathRenderer.handleRerender($('#rightPane'));1678} //.outline1679var CrossMark = {1680 cssUrl:'',1681 init:function() {1682 $("#open-crossmark").delegate("#crossmark-icon", "click",function(event){1683 $.get(SDM.crossMarkURL +'/'+ SDM.pm.pii + '/article/rightPane/displayPopup/' + SDM.keOriginContentFamily +'/'+ SDM.issn_or_isbn);1684 });1685 if($('#open-crossmark')[0]){1686 LazyLoad.js([SDM.crossMarkLib], function() {1687 $("#open-crossmark").css({'display':'inline-block'}).find('img').css('padding-top','10px');1688 $('#open-crossmark').click(function(){$(".ui-dialog-titlebar").css('top','0px').css('width','520px');});1689 });1690 }1691 $('#open-crossmark').bind('mouseover',function(){setTimeout(CrossMark.setCss,1000);});1692 $('#open-crossmark').bind('mouseout',function(){setTimeout(CrossMark.removeCss,1000);});1693 $('body').bind('mousemove',CrossMark.removeCss);1694 },1695 setCss:function(){1696 if(!$('link[href*="crossmark_widget.css"]')[0]){1697 if(document.createStyleSheet){1698 document.createStyleSheet(CrossMark.cssUrl);1699 }else{1700 $('head').append('<link href="'+CrossMark.cssUrl+'" rel="stylesheet" type="text/css"/>');1701 } 1702 }else{1703 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1704 }1705 },1706 removeCss:function(){1707 if($('link[href*="crossmark_widget.css"]')[0] && !$('.ui-widget-overlay').is(':visible') && !$('#crossmark-tooltip-130').is(':visible')){1708 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1709 $('link[href*="crossmark_widget.css"]').remove();1710 }1711 }1712}1713var SearchWithin = {1714 init:function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1715 var val = SearchWithin.loadSearch();1716 if(val.cid==SDM.pm.cid && val.str) {1717 var swObj = SearchWithin.loadResult();1718 if(swObj) {1719 if(swObj && swObj.cid==SDM.pm.cid) {1720 if(swObj.status!=0) {1721 SearchWithin.clear();1722 }1723 else {1724 SearchWithin.processResult(swObj, bkOutlineSelStr, selStr, idConvert);1725 }1726 }1727 else {1728 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1729 }1730 }1731 else {1732 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1733 }1734 }1735 },1736 loadSearch:function() {1737 var flag=true;1738 var searchStr='';1739 var cidStr = '';1740 var beg = document.cookie.indexOf('SEARCHWITHIN=');1741 if(beg!=-1) {1742 beg = beg + 'SEARCHWITHIN='.length;1743 var end = document.cookie.indexOf(';', beg);1744 var cookieStr = document.cookie.slice(beg, end);1745 flag = cookieStr.split('SW()')[0];1746 searchStr = cookieStr.split('SW()')[1];1747 cidStr = cookieStr.split('SW()')[2];1748 }1749 else {1750 return {f:'',str:'',cid:''};1751 }1752 return {f:flag,str:searchStr,cid:cidStr}; //[searchStr, cidStr];1753 },1754 saveSearch: function(f, sStr) {1755 var site = document.location.pathname.split('/article/pii/')[0];1756 document.cookie='SEARCHWITHIN' + '=' + f + 'SW()' + sStr + 'SW()' + SDM.pm.cid + ';;path=' + site;1757 },1758 reqResult: function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1759 $.get('/science/searchwithin', function(res) {1760 var result;1761 try {1762 result = $.parseJSON(res);1763 }1764 catch(e) {1765 DBG.out(1, 'SearchWithin failed');1766 return;1767 }1768 if(result.status==1 || typeof result.hitTerms=="undefined") {1769 funcNoResult();1770 }1771 else {1772 if(result.status==0) {1773 SearchWithin.processResult(result, bkOutlineSelStr, selStr, idConvert);1774 }1775 }1776 });1777 },1778 processResult: function(result, bkOutlineSelStr, selStr, idConvert) {1779 var len = result.piis.length;1780 for(var i=0; i<len; i++) {1781 if(SDM.pm.pii==result.piis[i]) {1782 SearchWithin.hlCenterPane(result.hitTerms.toString().replace(/,/g, ' '), selStr, idConvert);1783 }1784 }1785 SearchWithin.hlOutline(result.piis, bkOutlineSelStr);1786 SearchWithin.saveResult(result);1787 },1788 saveResult: function(rslt) {1789 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {1790 sessionStorage.setItem('bk.sw', JSON.stringify(rslt));1791 }1792 },1793 loadResult: function() {1794 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1795 var sw = sessionStorage.getItem('bk.sw');1796 if(sw) {1797 var swObj = $.parseJSON(sw);1798 if(swObj.cid==SDM.pm.cid) {1799 return swObj;1800 }1801 else {1802 SearchWithin.clearResult();1803 return null;1804 }1805 }1806 else {1807 SearchWithin.clearResult();1808 return null;1809 }1810 }1811 },1812 clearResult: function() {1813 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1814 sessionStorage.removeItem('bk.sw');1815 }1816 },1817 clear:function(keepMsg) {1818 $('.swh').removeClass('swh');1819 $('.searchword').removeClass('searchword');1820 var site = document.location.pathname.split('/article/pii/')[0];1821 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;';1822 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;path=' + site;1823 if(typeof keepMsg=="undefined" && typeof ArticlePage!="undefined")1824 ArticlePage.searchWithinErrorMsgClear();1825 }, //searchWithin.clear1826 hlOutline:function(piis, selStr) {1827 var len = piis.length;1828 for(var i=0; i<len; i++) {1829 $(selStr).each(function() {1830 if($(this).attr('data-pii')==piis[i]) {1831 DBG.out(1, 'Highlighting Book TOC item ' + $(this).text());1832 if($(this).attr('data-pii')!=SDM.pm.pii) {1833 $(this).find('div a').addClass('swh');1834 }1835 EbookTOC.getPath2Item(piis[i]).each(function() {1836 $(this).children('a').addClass('swh');1837 });1838 }1839 });1840 }1841 },1842 hlCenterPane:function(hitTerms, selStr, idConvert) {1843 searchStr = hitTerms;1844 //center pane highlighting1845 searchhi.process($('#centerPane')[0], searchStr);1846 //outline highlighting1847 var objs = $('.searchword').each(function() {1848 $(this).attr('data-posy', $(this).position().top);1849 });1850 $(selStr).each(function() {1851 $(this).attr('data-posy', $(this).position().top);1852 objs.push(this);1853 });1854 objs = _.sortBy(objs, function(val) {1855 return $(val).attr('data-posy')*1.0;1856 });1857 objs = _.filter(objs, function(val) {1858 return $(val).parents('.textboxBody').length==0;1859 });1860 objs = objs.reverse();1861 var len = objs.length;1862 for(i=0; i<len; i++) {1863 var $c = $(objs[i]);1864 if($c.hasClass('searchword')) {1865 var ii=i;1866 while($(objs[ii]).length && $(objs[ii]).hasClass('searchword')) {ii++;}1867 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1868 var foundType="h4";1869 if($(objs[ii]).is("h4")) {1870 foundType = "h4";1871 }1872 if($(objs[ii]).is("h3")) {1873 foundType = "h3";1874 }1875 if($(objs[ii]).is("h2")) {1876 foundType = "h2";1877 done=true;1878 }1879 var done=false;1880 while(!done && $(objs[ii]).length) {1881 if(foundType=="h4") {1882 if($(objs[ii]).is("h4")) {}1883 if($(objs[ii]).is("h3")) {1884 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1885 }1886 if($(objs[ii]).is("h2")) {1887 done=true;1888 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1889 }1890 }1891 else if(foundType=="h3") {1892 if($(objs[ii]).is("h4")) {}1893 if($(objs[ii]).is("h3")) {}1894 if($(objs[ii]).is("h2")) {1895 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1896 done=true;1897 }1898 }1899 if($(objs[ii]).is("h2")) {1900 done=true;1901 }1902 ii++;1903 }1904 }1905 }1906 }//searchWithin.highlight1907} //SearchWithin1908var ArticleOutline={1909outline : "",1910init:function(){1911//var toc = $.parseJSON(ArticleOutline.outline);1912 if(typeof SDM.tocJson !='undefined')1913 {1914 var obj = $.parseJSON(SDM.tocJson);1915 for (var i=0;i<=obj.TOC.length;i++) {1916 ArticleOutline.buildSectionItem(obj.TOC[i]);1917 }1918 }1919},1920buildSectionItem:function(sec){1921//var $section;1922var html = '';1923var keyE = '"displayTOCSection", "article", "leftPane", '+SDM.keOriginContentFamily +'';1924//$section = $('<li class="" style="margin-right:16px;"></li>');1925 if(sec.sID != undefined){1926 html += '<div id="ol_'+sec.sID+'" class="io item h2sec"></div>';1927 //$section.append('<div id="ol_'+sec.sID+'" class="io item h2sec"></div>');1928 }1929 if(sec.sT != undefined){1930 html += '<a onclick="SD_UTIL.sendUserKeyEvent(\'displayTOCSection\', \'article\', \'leftPane\', '+SDM.keOriginContentFamily +'); return $(\'#centerPane\').moveTo(\''+ sec.sID +'\')" href=\'#'+sec.sID+'\' >'+sec.sT+'</a>';1931 }1932 1933 //$section.append($div);1934 return html;1935}1936}1937var Outline = {1938 onHover:false,1939 pendCloseTimer:null,1940 init:function() {1941 $('#leftPane').hover(1942 function() {1943 Outline.hoverOverOn();1944 if(!pgLayout.showLeftBar) {1945 clearTimeout(Outline.pendingCloseTimer);1946 }1947 }, 1948 function() { 1949 Outline.hoverOverOff();1950 if(!pgLayout.showLeftBar) {1951 Outline.pendingCloseTimer = setTimeout(Outline.sidebarClose, 1000);1952 }1953 } 1954 );1955 $('#leftCloseBar').click(function(e) {Outline.sidebarOpenClick(e)});1956 $('#leftOpenBar').click(function(e) {Outline.sidebarCloseClick(e)});1957 },1958 buildOutlineJsonSide:function(cfg, outlineObj) {1959 var $iOutline = $('#itemOutline');1960 if (outlineObj!=null && outlineObj.TOC != undefined && outlineObj.TOC.length>1) {1961 $(outlineObj.TOC).each(function(i, h2Sec) {1962 if(h2Sec.sT != undefined && h2Sec.sT.length>0){1963 var secTitle = h2Sec.sT;1964 secTitle = secTitle.replace (/'/g, "'"); 1965 if (SDM.pageType == 'article_full') { 1966 $iOutline.append(Outline.addItemSection(h2Sec.sID, secTitle, 'h2'));1967 } else if (SDM.pageType == 'article_abs') {1968 $iOutline.append(Outline.addItemOutline(h2Sec.sID, secTitle, 'h2'));1969 }1970 }1971 if(h2Sec.faID != undefined && h2Sec.faID.length > 0) {1972 $(h2Sec.faID).each(function(i, floatanc) {1973 if(floatanc.fT == 'fig'){1974 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1975 if(floatanc.fI.length>0){1976 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h2', floatanc.fIh));1977 }1978 }1979 else if(floatanc.fT == 'tbl'){1980 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h2'));1981 }1982 else if(floatanc.fT == 'ecomp'){1983 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h2'));1984 }1985 })1986 }1987 if (h2Sec.cT != undefined && h2Sec.cT.length > 0) {1988 $(h2Sec.cT).each(function(i, h3Sec) {1989 if(h3Sec.sT.length>0){1990 var secTitle = h3Sec.sT;1991 secTitle = secTitle.replace (/'/g, "'"); 1992 if (SDM.pageType == 'article_full') {1993 $iOutline.append(Outline.addItemSection(h3Sec.sID, secTitle, 'h3'));1994 }else if (SDM.pageType == 'article_abs'){1995 $iOutline.append(Outline.addItemOutline(h3Sec.sID, secTitle, 'h3'));1996 }1997 }1998 if(h3Sec.faID != undefined && h3Sec.faID.length > 0){1999 $(h3Sec.faID).each(function(i, floatanc){2000 if(floatanc.fT == 'fig'){2001 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;2002 if (floatanc.fI.length>0){2003 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h3', floatanc.fIh));2004 }2005 }2006 else if(floatanc.fT == 'tbl'){2007 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h3'));2008 }2009 else if(floatanc.fT == 'ecomp'){2010 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h3'));2011 }2012 })2013 }2014 if(h3Sec.cT != undefined && h3Sec.cT.length > 0){2015 $(h3Sec.cT).each(function(i, h4Sec) {2016 if(h4Sec.sT.length>0){2017 var secTitle = h4Sec.sT;2018 secTitle = secTitle.replace (/'/g, "'"); 2019 if (SDM.pageType == 'article_full') {2020 $iOutline.append(Outline.addItemSection(h4Sec.sID, secTitle, 'h4'));2021 }else if (SDM.pageType == 'article_abs'){2022 $iOutline.append(Outline.addItemOutline(h4Sec.sID, secTitle, 'h4'));2023 }2024 }2025 if(h4Sec.faID != undefined && h4Sec.faID.length > 0){2026 $(h4Sec.faID).each(function(i, floatanc){2027 if(floatanc.fT == 'fig'){2028 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;2029 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h4', floatanc.fIh));2030 }2031 else if(floatanc.fT == 'tbl'){2032 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h4'));2033 }2034 else if(floatanc.fT == 'ecomp'){2035 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h4'));2036 }2037 })2038 }2039 })2040 }2041 })2042 }2043 })2044 $('#leftPane .outlineMsg').remove();2045 }2046 else {2047 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {2048 $('#outline').css('top', 0);2049 }2050 $('#outline .outlineMsg').html('This document does not have an outline.')2051 .show();2052 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();2053 }2054 Outline.postBuild(cfg);2055 },2056 buildOutlineClientSide:function(cfg) {2057 var level = "";2058 var $iOutline = $('#itemOutline');2059 if($(cfg.selector).length>0) {2060 $(cfg.selector).each(function() {2061 if($(this).parents('.textboxBody').length>0) {}2062 else {2063 if($(this).attr('id')==undefined) {2064 $(this).attr('id', 'bs_' + Math.floor(Math.random()*100000));2065 DBG.out(1, 'fixing id::' + $(this).attr('id') + '::' + $(this).text());2066 }2067 DBG.out(4, 'adding::' + $(this).text());2068 if($(this).is("h2")||$(this).is("h3")||$(this).is("h4")) {2069 level = $(this)[0].tagName;2070 level = level.toLowerCase();2071 var label = $(this).html();2072 var hasMml=$(this).find("#itemOutline .mathmlsrc"); 2073 if(hasMml) { 2074 $("#itemOutline .mathmlsrc").attr('onclick',''); 2075 }2076 if(label==undefined) label='';2077 if (SDM.pageType == 'article_full') {2078 $iOutline.append(Outline.addItemSection($(this).attr('id'), label, level));2079 }2080 else if (SDM.pageType == 'article_abs') {2081 //Note: In case of unentitled view we render the outline from a hidden div in center pane2082 $iOutline.append(Outline.addItemOutline($(this).attr('id'), label, level));2083 }2084 }2085 else {2086 if($(this).hasClass('table')==true) {2087 var label = $(this).attr('data-label');2088 if(label==undefined) label='';2089 $iOutline.append(Outline.addItemTbl($(this).attr('id'), label, level));2090 }2091 else if($(this).hasClass('figure')==true) {2092 var label = $(this).find(".label").html();2093 if(label==undefined) label='';2094 var image = SDM.imageUrlPrefix + $(this).find("dt img").attr('data-thumbEID');2095 var thumbHeight = $(this).find("dt img").attr('data-thumbheight');2096 if(!$(this).children('div').attr('id')){2097 $iOutline.append(Outline.addItemFig($(this).attr('id'), label, image, level, thumbHeight));2098 }2099 }2100 else if($(this).hasClass('ecomponent')==true) {2101 var label = $(this).attr('data-label');2102 if(label==undefined) label='';2103 var ext = $(this).attr('data-ext');2104 $iOutline.append(Outline.addItemMMC($(this).parent('dl').attr('id'), label, ext, level));2105 }2106 else {}2107 }2108 }2109 })2110 $('#leftPane .outlineMsg').remove();2111 }2112 else {2113 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {2114 $('#outline').css('top', 0);2115 }2116 $('#outline .outlineMsg').html('This document does not have an outline.')2117 .show();2118 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();2119 }2120 Outline.postBuild(cfg);2121 },2122 buildOutlineUnavailable:function(cfg) {2123 if(SDM.pm.contentType!='BK') {2124 $('#outline').css('top', 0);2125 }2126 $('#outline .outlineMsg').html('The outline for this document is currently unavailable.')2127 .show();2128 },2129 postBuild:function(cfg) {2130 var oObj = Outline.oObj;2131 prs.rt('outlineLoop_end');2132 oObj.append('<div id="articleLeftAd"></div>');2133 Outline.showLeftAd();2134 2135 //Setup the sync between rightPane scroll and outline highlight2136 if(cfg.focusEffect==true) {2137 oObj.syncTo(cfg);2138 }2139 2140 $('#outline > ul').show();2141 if(SDM.isMRWMODArticle && SDM.ldrAvail)$('#itemOutline').hide(); 2142 2143 if(SDM.outlineImgFence==true) {2144 if($('li div.fig, li div.tbl, li div.mmc').length > 0) {2145 if(SDM.outlineGraphics == true) {2146 $('#outlineGraphicsCheckBox').prop('checked', true);2147 }2148 else {2149 $('#outlineGraphicsCheckBox').prop('checked', false)2150 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2151 }2152 $('#outlineGraphicsCheckBox').change(function() {2153 Outline.toggleGraphics();2154 if($('#outlineGraphicsCheckBox').prop('checked')==true) {2155 SD_UTIL.sendUserKeyEvent('enableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2156 }2157 else {2158 SD_UTIL.sendUserKeyEvent('disableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2159 }2160 });2161 }2162 else {2163 $('#outlineGraphicsCheckBox').prop('checked', false);2164 $('#olGraphCbBox label').hide();2165 }2166 }2167 else {2168 $('#olGraphCbBox').hide();2169 $('#outlineGraphicsCheckBox').prop('checked', false)2170 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2171 }2172 oObj.scroll();2173 },2174 itemAction: function() {2175 SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');2176 2177 },2178 addItemMMC: function(hashId, lbl, ext, hStr) {2179 var ecn = "olIconMMCDef";2180 if(ext=="pdf"){extCls="olIconMMCPdf"}2181 else if(ext=="avi"){ecn="olIconMMCMov"}2182 else if(ext=="csv"){ecn="olIconMMCCsv"}2183 else if(ext=="eps"){ecn="olIconMMCEps"}2184 else if(ext=="flv"){ecn="olIconMMCFlv"}2185 else if(ext=="gif"){ecn="olIconMMCImg"}2186 else if(ext=="jpg"){ecn="olIconMMCJpg"}2187 else if(ext=="kmz"){ecn="olIconMMCDef"}2188 else if(ext=="mml"){ecn="olIconMMCDef"}2189 else if(ext=="xls"){ecn="olIconMMCExcel"}2190 else if(ext=="ppt"){ecn="olIconMMCPpt"}2191 else if(ext=="doc"){ecn="olIconMMCWord"}2192 else if(ext=="mp3"){ecn="olIconMMCAud"}2193 else if(ext=="mpg"){ecn="olIconMMCMov"}2194 else if(ext=="mp4"){ecn="olIconMMCMpg4"}2195 else if(ext=="txt"){ecn="olIconMMCTxt"}2196 else if(ext=="png"){ecn="olIconMMCPng"}2197 else if(ext=="mov"){ecn="olIconMMCMov"}2198 else if(ext=="rtf"){ecn="olIconMMCRtf"}2199 else if(ext=="svg"){ecn="olIconMMCSvg"}2200 else if(ext=="tar"){ecn="olIconMMCDef"}2201 else if(ext=="tif"){ecn="olIconMMCDef"}2202 else if(ext=="zip"){ecn="olIconMMCZip"}2203 else {ecn = "olIconMMCDef";}2204 var html;2205 if(SDM.entitled==true){2206 html = "<li><div id='ol_" + hashId + "' class='tocLink io item " + hStr + "sec mmc'>"2207 + "<div class=\"olIcon " + ecn + "\"></div><a class=\"olIcon " + ecn + "\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \">"2208 + lbl + "</a></div></li>";2209 }2210 else{2211 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec mmc'>"2212 + "<div class=\"olIcon " + ecn + "\"></div><a class=\"olIcon " + ecn + " cLink\" queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>"2213 + lbl 2214 + "</a></div></li>";2215 }2216 return html;2217 }, //Outline.addItemMMC2218 addItemTbl: function(hashId, lbl, hStr) {2219 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec tbl'>"2220 + "<div class=\"olIcon olIconTbl\"></div><a class=\"tocLink olIcon olIconTbl\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \">"2221 + lbl + "</a></div></li>";2222 return html;2223 }, //Outline.addOutlineItemTbl2224 addItemFig: function(hashId, lbl, img, hStr, thumbHeight) {2225 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec fig'>"2226 + "<a class='tocLink' href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');\">"2227 html += "<img src=\"/sd/grey_pxl.gif\" class=\"smlImgLazyJSB greyImg\" data-smlsrc='" + img + "' data-thumbheight='" + thumbHeight + "'/></a></div></li>";2228 return html;2229 }, //Outline.addOutlineItemFig2230 addItemSection: function(hashId, lbl, hStr) {2231 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec'>"2232 + "<a class='tocLink'href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');\">"2233 + lbl + "<br>"2234 + "</a></div></li>";2235 return html;2236 }, //Outline.addOutlineItemSection2237 addItemOutline: function(hashId, lbl, hStr) {2238 var html = "<li><div class='io item " + hStr + "sec'>"2239 + "<a class='cLink' queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>"2240 + lbl + "<br>"2241 + "</a></div></li>";2242 return html;2243 }, //Outline.addOutlineItemSection2244 sidebarOpenClick: function(e) {2245 Outline.sidebarOpen(true);2246 SD_UTIL.sendUserKeyEvent('openLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2247 return false;2248 },2249 sidebarCloseClick: function(e) {2250 Outline.sidebarClose(); 2251 SD_UTIL.sendUserKeyEvent('closeLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2252 return false;2253 },2254 sidebarOpen: function(e) {2255 if($('#leftPane').css('display')=='none') {2256 $('#leftCloseBar').hide();2257 $('#leftPane').height('').height($('#leftPane').height()).show();2258 $('#leftPane').animate({'margin-left':'0px'}, 250, function() {2259 var ol = $('#outline');2260 ol.css('overflow-y', 'auto');2261 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2262 else {2263 ol.scrollTop(ol.attr('data-st'));2264 }2265 ol.css('overflow-y', 'hidden');2266 if(e==true) {2267 Outline.hoverOverOn();2268 }2269 });2270 }2271 },2272 sidebarClose: function() {2273 if($('#leftPane').css('display')=='block' && $('#leftPane').attr('data-closing')!='y') {2274 var ol = $('#outline');2275 var st = ol.scrollTop();2276 ol.attr('data-st', st);2277 ol.css('overflow-y', 'hidden');2278 $('#leftPane').attr('data-closing', 'y');2279 $('#leftPane').height('').height($('#leftPane').height());2280 $('#leftPane').animate({'margin-left':'-280px'},250,function(){2281 $(this).hide();2282 $('#leftCloseBar').show();2283 $('#leftPane').attr('data-closing', '');2284 });2285 }2286 },2287 collapseSmallLeft: function() {2288 }, //Outline.collapseSmallLeft2289 expandSmallLeft: function() {2290 }, //Outline.expandSmallLeft2291 toggleGraphics: function(force) {2292 if(SDM.outlineImgFence==false) return;2293 2294 if(typeof(force)!=undefined) {2295 if(force=="hide") {2296 SDM.outlineGraphics=true;2297 }2298 else if(force=="show") {2299 SDM.outlineGraphics=false;2300 }2301 else {}2302 }2303 2304 if(SDM.outlineGraphics == true) {2305 SDM.outlineGraphics = false;2306 var ulWidthBefore = $('#outline ul').width();2307 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2308 var ulWidthAfter = $('#outline ul').width();2309 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2310 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)$('#outline').css('overflow-x', 'hidden');2311 $('#outline').attr('data-osbp', 'n');2312 }2313 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2314 $('#outline').attr('data-osbp', 'y');2315 }2316 }2317 else {2318 SDM.outlineGraphics = true;2319 var ulWidthBefore = $('#outline ul').width();2320 $('li div.fig, li div.tbl, li div.mmc').parent().show();2321 var ulWidthAfter = $('#outline ul').width();2322 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2323 $('#outline').attr('data-osbp', 'n');2324 }2325 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2326 $('#outline').css('overflow-x', 'auto');2327 $('#outline').attr('data-osbp', 'y');2328 }2329 }2330 }, //Outline.toggleGraphics2331 hoverOverOn: function() {2332 this.onHover = true;2333 var ol = $('#outline');2334 ol.doTheScrollJitter();2335 2336 var ulWidthBefore = $('#outline ul').width();2337 if(SDU.isIE7()) {}2338 else {2339 //ol.css('overflow-x', 'auto');2340 }2341 2342 ol.css('overflow-y', 'auto');2343 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2344 else {2345 ol.scrollTop(ol.attr('data-st'));2346 }2347 2348 var ulWidthAfter = $('#outline ul').width();2349 if(ulWidthAfter < ulWidthBefore) {2350 ol.attr('data-osbp', 'y');2351 if(SDU.isIE7()) {}2352 else {2353 if($('#lpTabs .leftTab').hasClass('activeTab')) {2354 ol.find('.srcli').each(function() {2355 if($(this).children('div.activeChapter').length) {2356 $(this).children('div.activeChapter').children('span').css('margin-right', 0);2357 $(this).find('li').css('margin-right', 0);2358 }2359 else {2360 $(this).css('margin-right', 0);2361 }2362 });2363 }2364 else {2365 ol.find('li').css('margin-right', 0);2366 }2367 }2368 }2369 else {2370 ol.attr('data-osbp', 'n');2371 if(SDU.isIE7()) {}2372 else {2373 ol.find('li').not('.outlineFocus').css('margin-right', 0);2374 }2375 ol.find('li.outlineFocus').parent().css('background', '#ffffff');2376 }2377 ol.css('background', '#ffffff');2378 ol.children('ul').css('background', '#ffffff');2379 ol.addClass('active');2380 2381 $('#articleLeftAd').css('background', '#ffffff');2382 if( $("#articleLeftAd iframe").length > 0 ){2383 $('#articleLeftAd iframe').contents().find('body').css('background', '#ffffff');2384 $('#articleLeftAd iframe').css('background', '#ffffff');2385 }2386 },2387 hoverOverOff: function() {2388 this.onHover = false;2389 var ol = $('#outline');2390 ol.doTheScrollJitter()2391 var ulWidthBefore = $('#outline ul').width();2392 var st = ol.scrollTop();2393 ol.attr('data-st', st);2394 ol.css('overflow-y', 'hidden');2395 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)ol.css('overflow-x', 'hidden');2396 var ulWidthAfter = $('#outline ul').width();2397 if(SDU.isIE7()) {2398 if(ulWidthAfter < ulWidthBefore) {}2399 else {2400 if($('#lpTabs .leftTab').hasClass('activeTab')) {2401 $('#outline > ul > li').css('margin-right', 0);2402 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2403 }2404 else {2405 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2406 }2407 }2408 }2409 else {2410 if(ulWidthAfter < ulWidthBefore) {2411 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2412 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2413 }2414 else {2415 ol.find('#itemOutline > li').each(function() {2416 if($(this).children('div.activeChapter').length) {2417 $(this).children('div.activeChapter').children('span').css('margin-right', $.scrollBarWidth());2418 $(this).find('li').css('margin-right', 0);2419 }2420 else {2421 $(this).css('margin-right', $.scrollBarWidth());2422 }2423 });2424 }2425 }2426 ol.find('li.outlineFocus').parent().css('background', '#ecf2f6');2427 ol.css('background', '#ecf2f6');2428 ol.children('ul').css('background', '#ecf2f6');2429 ol.removeClass('active');2430 //This must be at end or FF will reset the scroll2431 ol.scrollTop(st);2432 2433 $('#articleLeftAd').css('background', '#ecf2f6');2434 if( $("#articleLeftAd iframe").length > 0 ) {2435 $('#articleLeftAd iframe').contents().find('body').css('background', '#ecf2f6');2436 $('#articleLeftAd iframe').css('background', '#ecf2f6');2437 } 2438 },2439 moveToSection: function(e) {2440 var selID=$(e.target).closest('a').attr('href').split('#');2441 selID=selID[1];2442 $('#centerPane').moveTo(selID);2443 e.preventDefault();2444 e.stopPropagation(); 2445 },2446 findTargetFragment: function(e) {2447 var selID = e;2448 if(typeof e != 'string') {2449 var selID=$(e.target).closest('a').attr('href').split('#');2450 selID=selID[1];2451 }2452 var id = selID; 2453 id = id.replace(/[\.]/g, '\\.');2454 id = id.replace(/[\:]/g, '\\:'); 2455 var obj = $('#'+id); 2456 if (!$(obj)[0]) {2457 // Fragment not loaded yet.2458 if (Fragment.crossRefMap) {2459 var targetFrag = Fragment.getIntraRefFragId (selID);2460 var targetFragNum = targetFrag.substr(targetFrag.indexOf('_')+1)*1;2461 Fragment.get ('frag_' + (targetFragNum-1), e.data.z);2462 Fragment.get (targetFrag, e.data.z, {successCb: function(ee) {Outline.findTargetFragment(ee)},2463 successCbArg: e,2464 failureCb: function(selId) {2465 Fragment.bail(300, 'fndtgt', selId);2466 },2467 failureCbArg: selID2468 });2469 Fragment.get ('frag_' + (targetFragNum+1), e.data.z);2470 }2471 } else {2472 $('.page_fragment').show();2473 Fragment.scrollFlag = false;2474 $('#centerPane').moveTo(selID, { cbFunc: function() {Fragment.scrollFlag=true;}});2475 } 2476 if(typeof e != 'string') {2477 e.preventDefault();2478 e.stopPropagation();2479 }2480 },2481 getJson: function() {2482 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid, function(jsonStr, b, c) {2483 SDM.tocJson = String(jsonStr);2484 }, 'text')2485 .error (function() {2486 DBG.out (1, "Returned Error");2487 });2488 },2489 showLeftAd:function() {2490 if(SDM.adPreventOutline == true) return;2491 if ( typeof SDM.adArticleLeftURL!='undefined') {2492 $("#articleLeftAd").append('<iframe scrolling="no" frameborder="0" border="0" cellspacing="0" src="' + SDM.adArticleLeftURL + '"></iframe>');2493 }2494 } 2495} //Outline2496var DBG = {2497 out: function(lvl, str) {2498 if(SDM.debugFlag=="undefined") {return;}2499 if(SDM.debugFlag >= lvl || lvl==0 || typeof ut == 'object') {2500 if(typeof console=== "undefined" || typeof console.log==="undefined") {2501// if(!$('#sdConsole').length) {2502// $('body').append('<textarea id="sdConsole" class="ui-widget-content" cols="60"></textarea>');2503// $('#sdConsole').resizable();2504// }2505// $('#sdConsole').append(str + "<br>");2506 }2507 else{console.log(str) }2508 }2509 }2510} //DBG2511$(document).ready(function() {2512 if (SDM.pru!='') {2513 SD_UTIL.sendPageLoadStats();2514 }2515 if(!SDM.blk_all_social_logins && SDU.cookieAvail()){2516 LazyLoad.js([SDM.ep.gigyaLib], function() {2517 $('.socialContainer').each(function(){2518 if($(this).attr('id')!=''){2519 loadSocialLoginOptions($(this).attr('id'));2520 }2521 });2522 initGigyaHelp();2523 });2524 }2525 //loadBreadCrumbs();2526});2527function initGigyaHelp()2528{2529 $('#socialHelpPage').click(function(e){2530 e.stopPropagation();2531 e.preventDefault();2532 openPopup($(this).attr('href'),'help',800,600);2533 });2534}2535var SD_UTIL = {2536 killEvent:function(e){2537 if(!e) return;2538 e.preventDefault()2539 e.stopPropagation();2540 },2541 sendUserKeyEvent: function(a, o, z, ocf) {2542 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+ocf+'/'+a);2543 },2544 sendUserKeyEventForPPV: function(a, o, z) {2545 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+a);2546 },2547 sendDownloadKeyEvent: function(o, z, ocf, f) {2548 $.get(SDM.ep.downloadActionURL+'/'+o+'/'+z+'/'+ocf+'/'+f);2549 },2550 loadLib: function(urlStr) {2551 var headID = document.getElementsByTagName('head')[0];2552 var newScript = document.createElement('script');2553 newScript.type = 'text/javascript';2554 newScript.src = urlStr;2555 headID.appendChild(newScript);2556 },2557 isPerfTimingAvail:function() {2558 return !(typeof window.performance==="undefined" || typeof window.performance.timing==="undefined")2559 },2560 isSendStatsReady:function() {2561 if(SD_UTIL.isPerfTimingAvail()) {2562 if(window.performance.timing.domComplete&&window.performance.timing.loadEventStart&&window.performance.timing.loadEventEnd) return true;2563 else return false;2564 }2565 return true;2566 },2567 sendStats:function(){2568 if(SD_UTIL.isSendStatsReady()) {}2569 else {setTimeout(SD_UTIL.sendStats, 250);return;}2570 var params = '';2571 if(SD_UTIL.isPerfTimingAvail()) {2572 for(var k in window.performance.timing) {2573 prs.rt(("wpt_"+k), window.performance.timing[k]);2574 }2575 }2576 var prs2 = _.sortBy(prs, function(val) {2577 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1]*1.0;2578 });2579 for( var i = 0;i < prs2.length;i++){2580 params += "data=" + prs2[i].toString() + "&";2581 }2582 params += "key=" + SDM.pageTransKey + "&";2583 params += "pagetype=" + SDM.pageType;2584 },2585 printStats:function() {2586 var newprs = _.sortBy(prs, function(val) {2587 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2588 });2589 for( var i = 0;i < newprs.length;i++){2590 var dParts = newprs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g);2591 DBG.out(1, dParts[1].split(':')[1] + ',' + dParts[0].split(':')[1] + ',');2592 }2593 },2594 sendPageLoadStats:function() {2595 var params = '';2596 if (window.performance && window.performance.timing) {2597 if (window.performance.timing.loadEventEnd > 0) {2598 params = SD_UTIL.getArtSpdStats();2599 for(var k in window.performance.timing) {2600 params += "&" + k + "=" + window.performance.timing[k];2601 }2602 var url = SDM.pru+"/pageReport?"+params;2603 $('body').append('<img style="display:none" src="' + url + '">');2604 }2605 else {2606 setTimeout(SD_UTIL.sendPageLoadStats, 100);2607 }2608 }2609 else {2610 params = SD_UTIL.getArtSpdStats();2611 params += "&loadEventEnd=" + new Date().getTime();2612 var url = SDM.pru+"/pageReport?"+params;2613 $('body').append('<img style="display:none" src="' + url + '">');2614 }2615 },2616 getArtSpdStats:function(){2617 var params,lbl,timer;2618 params = "cpc=SD";2619 for( var i = 0;i < prs.length;i++){2620 lbl=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[0].split(':')[1];2621 if (lbl.indexOf("wpt_") == -1) {2622 timer=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2623 params += "&" + lbl + "=" + timer;2624 }2625 }2626 params += "&key=" + encodeURIComponent(SDM.pageTransKey);2627 params += "&pagetype=" + SDM.pageType;2628 params += "&sds=" + SDM.sds;2629 params += "&tid=" + SDM.tid;2630 if(SDM.tm.ahm != undefined)params += "&ahm=" + SDM.tm.ahm;2631 if(SDM.tm.chm != undefined)params += "&chm=" + SDM.tm.chm;2632 if (document.location.href) {2633 params += "&href=" + encodeURIComponent(document.location.href);2634 }2635 if (document.documentElement.clientWidth &&2636 document.documentElement.clientHeight) { 2637 params += "&winHeight=" + document.documentElement.clientHeight;2638 params += "&winWidth=" + document.documentElement.clientWidth;2639 }2640 params += "&domCount=" + document.getElementsByTagName("*").length;2641 return params;2642 },2643 getProdColor: function(){2644 return (SDM.prodColor==""?"sci_dir":SDM.prodColor);2645 },2646 getIFrameHeight: function(ifr) {2647 var ifrDoc=ifr.contentWindow||ifr.contentDocument||ifr.document;2648 if(ifrDoc.document!=undefined) ifrDoc=ifrDoc.document;2649 return $(ifrDoc.body).height();2650 },2651 resizeIFrame: function(iframeBox, iframeHeight) {2652 $('#' + iframeBox + ' iframe').height(iframeHeight);2653 }2654}2655// Lazy Loader2656$.fn.lazyLoadImages = function(opts) {2657 var cfg = {2658 imgSel: 'img',2659 preLoadLine: 102660 };2661 var lastScrollTop=0;2662 function scrollAction() {2663 var bottom = $(window).height() + $('#centerPane').scrollTop();2664 var totalCount=$(cfg.imgSel).size();2665 var loopBool = true;2666 var st=$('#centerPane').scrollTop();2667 if (st > lastScrollTop){2668 var scrollDown=true;2669 } else {2670 var scrollUp=true;2671 }2672 for(i=0;i<totalCount && loopBool==true ;i++){2673 var obj = $(cfg.imgSel)[i];2674 if( Math.abs($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerInner').top+$(obj).height()) < 2675 $(window).height() + cfg.preLoadLine2676 || Math.abs($('#centerPane').scrollTop() - $(obj).positionA('#centerInner').top) < $(window).height() + cfg.preLoadLine) {2677 var imgObj = $(obj);2678 if(imgObj.attr('data-loaded')!='true' ) {2679 var dataGabsImgEID = imgObj.attr('data-gabsEID');2680 var dataFullImgEID = imgObj.attr('data-fullEID');2681 var dataThumbImgEID = imgObj.attr('data-thumbEID');2682 var dataInlImgEid = imgObj.attr('data-inlimgeid');2683 var dataInlImg = imgObj.attr('data-inlimg');2684 var dataPubLogo = imgObj.attr('data-publogo');2685 var dataDefaultLogo = imgObj.attr('data-defaultlogo');2686 if (dataGabsImgEID != undefined && dataGabsImgEID != '' && SDM.entitled) {2687 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-gabsEID')).attr('data-loaded', 'true');2688 }else if (SDM.fullSize==true && dataFullImgEID != undefined && dataFullImgEID != '') {2689 if(SDM.entitled) {2690 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-fullEID')).attr('data-loaded', 'true');2691 if(imgObj.attr('data-fullwidth')<580 || imgObj.attr('data-fullwidth')>800){2692 $(obj).css('height', $(obj).attr('data-fullheight')).css('width', $(obj).attr('data-fullwidth'));2693 } 2694 } else {2695 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true'); 2696 }2697 } else if (dataThumbImgEID != undefined && dataThumbImgEID != '') {2698 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true');2699 $(obj).css('height', $(obj).attr('data-thumbheight')).css('width', $(obj).attr('data-thumbwidth'));2700 } else if (dataInlImgEid != undefined && dataInlImgEid != '') {2701 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-inlimgeid')).attr('data-loaded', 'true');2702 if(imgObj.closest('.formula')[0] && imgObj.width()>=595){2703 imgObj.closest('.formula').find('.mathmlsrc').addClass('scrollOn');2704 }2705 } else if (dataDefaultLogo != undefined && dataDefaultLogo != '') {2706 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-defaultlogo')).attr('data-loaded', 'true');2707 } else if (dataPubLogo != undefined && dataPubLogo != '') {2708 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-publogo')).attr('data-loaded', 'true');2709 } else if (dataInlImg != undefined && dataInlImg != '') {2710 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-inlimg')).attr('data-loaded', 'true');2711 }2712 }2713 }2714 else {2715 if($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerInner').top+$(obj).height() < 2716 $(window).height() + cfg.preLoadLine && scrollDown){ 2717 loopBool=false;2718 }2719 if($('#centerPane').scrollTop() - $(obj).positionA('#centerInner').top < $(window).height() + cfg.preLoadLine && scrollUp){2720 loopBool=false;2721 }2722 }2723 }2724 lastScrollTop=$('#centerPane').scrollTop();2725 } //scroll2726 return this.each(function() {2727 if(opts) {2728 $.extend(cfg, opts);2729 }2730 scrollAction(); // run it once for any images that are currently on the screen2731 var lazyScroll = _.debounce(scrollAction, 300);2732 $(this).scroll( lazyScroll );2733 }) //return2734};2735$.fn.lazyLoadOutlineImages = function(opts) {2736 var cfg = {2737 imgSel: 'img',2738 preLoadLine: 2002739 };2740 function lazyDisplay() {2741 var cnt = 0;2742 var myTop = 0;2743 var myHeight = 0;2744 var myWidth = 0;2745 var thumbHeight = 0;2746 $(cfg.imgSel).each(function() {2747 var outlineTop = Math.abs($('#outline').scrollTop());2748 var outlineBottom = Math.abs(outlineTop + $('#outline').height());2749 var outlineHeight = $('#outline').height();2750 var windowHeight = Math.abs($(window).height());2751 if (cnt == 0) {2752 myTop = Math.abs($(this).position().top);2753 }2754 else {2755 myTop += (myHeight * 1); // add last height to position2756 }2757 myHeight = Math.abs($(this).height());2758 thumbHeight = $(this).attr('data-thumbheight');2759 if (thumbHeight == undefined) {2760 thumbHeight = 0;2761 }2762 if (thumbHeight > 0 && thumbHeight < myHeight) {2763 myHeight = thumbHeight;2764 }2765 myWidth = Math.abs($(this).width());2766 var myDims = myTop * 1 + myHeight * 1;2767 if( Math.abs(myDims - outlineTop) < Math.abs(outlineBottom + cfg.preLoadLine) 2768 || Math.abs(outlineTop - myTop) < Math.abs(outlineHeight + cfg.preLoadLine)) {2769 var imgObj = $(this);2770 if(imgObj.attr('data-loaded')!='true' ) {2771 if (imgObj.attr('data-smlsrc') != undefined) {2772 imgObj.attr('src', imgObj.attr('data-smlsrc')).attr('data-loaded', 'true');2773 } else if (imgObj.attr('data-mmlEID') != undefined) {2774 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-mmlEID')).attr('data-loaded', 'true');2775 } 2776 imgObj.addClass("displayImg");2777 } 2778 $(this).parent().parent().css('height', '').css('width', '');2779 } 2780 cnt++;2781 })2782 } //scroll2783 return this.each(function() {2784 if(opts) {2785 $.extend(cfg, opts);2786 }2787 2788 lazyDisplay(); // run it once to show images that are currently on page2789 var lazyScroll = _.debounce(lazyDisplay, 300);2790 $(this).scroll( lazyScroll );2791 }) //return2792};2793$.fn.lazyLoad = function( cfg ){2794 // Internal function used to implement `_.throttle` and `_.debounce`.2795 var limit = function(func, wait, debounce) {2796 var timeout;2797 return function() {2798 var context = this, args = arguments;2799 var throttler = function() {2800 timeout = null;2801 func.apply(context, args);2802 };2803 if (debounce) clearTimeout(timeout);2804 if (debounce || !timeout) timeout = setTimeout(throttler, wait);2805 };2806 };2807 var plugin = {2808 buffer: cfg.buffer?cfg.buffer:50, // 50 pixels by default2809 batchSize: cfg.batchSize?cfg.batchSize:1, // 1 is the default batch size.2810 scrollSrc: cfg.scrollSrc?cfg.scrollSrc:'#centerPane',2811 callback: cfg.intoView?cfg.intoView:function(obj,idx){},2812 selector: '.refPlaceHolder',2813 screenTop: $(window).scrollTop(),2814 screenHeight:$(window).height(),2815 debounce: function(func, wait) {2816 return limit(func, wait, true);2817 },2818 calculateView: function() {2819 //pagination get all needs this2820 if(refResolveEnabled==false) {return;}2821 2822 if( plugin.applyPatch() ) {2823 plugin.buffer += 500;2824 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2825 }2826 else{2827 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2828 }2829 var screenBot = plugin.screenTop + $(window).height() + plugin.buffer;2830 var batch = [];2831 $refs = $(plugin.selector).not(function() {2832 return $(this).attr('data-sr')=='Y';2833 });2834 $refs.each(function() {2835 var tmpTop = $(this).position().top;2836 if( plugin.applyPatch() ) {2837 tmpTop = this.offsetTop;2838 }2839 if( tmpTop > plugin.screenTop && tmpTop < screenBot ) { 2840 $(this).attr('data-sr', 'Y'); 2841 batch.push( this ); 2842 if( plugin.batchSize == 1 ){ 2843 plugin.callback( batch );2844 batch = [];2845 }2846 else{ 2847 if( batch.length == plugin.batchSize ){2848 plugin.callback( batch );2849 batch = [];2850 }2851 }2852 }2853 else {2854 $(this).attr('data-sr', 'N'); 2855 } 2856 }); 2857 if( batch ){ plugin.callback( batch ); } // run any remainder in batch2858 },2859 applyPatch:function() {2860 return ($.browser.msie && $.browser.version < 9)2861 }2862 }2863 var lazyResize = plugin.debounce(plugin.calculateView,300);2864 var lazyScroll = plugin.debounce(plugin.calculateView, 300);2865 2866 $(window).resize( lazyResize );2867 $(plugin.scrollSrc).scroll( lazyScroll );2868 plugin.calculateView();2869 return plugin;2870} 2871// end of Lazy Loader2872// small enhancement2873// this method will be called by gadget services to get2874// encrypted cookie from web2875function getEuid() {2876 return SDM.euidCookieObject; 2877}2878function isNotNumber(o) {2879 if (o == -1) {2880 return true;2881 }2882 return isNaN (o-0);2883}2884function getNumber(str) {2885 if(!str) {2886 return -1;2887 }2888 var i=0;2889 while(i < str.length) {2890 var charat = str.charAt(i);2891 if(!isNotNumber(charat)) {2892 if(charat != "0") {2893 return str.substring(i);2894 }2895 }2896 i++;2897 }2898}2899//Reference resolution2900var ajaxRefResol;2901var ajaxCitedByUpdate;2902function updateCitedByCounts(citedByCounts,isHoover,start,count) {2903 citedByCounts = citedByCounts.substring(0,citedByCounts.length-1);2904 var updateCitedUrl = SDM.ep.updatedCitedBy + citedByCounts;2905 ajaxCitedByUpdate = new $.ajax({2906 url: updateCitedUrl,2907 type: 'GET',2908 async : isHoover,2909 dataType : 'text',2910 error: function() {2911 $(".citedBy_").each(function(){2912 $(this).html("");2913 });2914 },2915 success: function(res) {2916 var citedBy = decodeURIComponent(res);2917 if (citedBy != null) {2918 this.$citedByDiv = $('<div></div>')2919 .hide()2920 .append($(citedBy)2921 );2922 $(".citedBy_").each(function(){2923 if(myXabsCounts[this.id]) {2924 if( this.innerHTML.match('Cited By in Scopus') == null) {2925 $(this).html( myXabsCounts[this.id]);2926 $(this).attr ("data-citeres", "Y");2927 }2928 } else {2929 $(this).html("");2930 $(this).attr ("data-citeres", "Y");2931 }2932 });2933 }2934 }2935 }); 2936}2937String.prototype.substringBetween = function (string1, string2) {2938 if ((this.indexOf(string1, 0) == -1) || (this.indexOf(string2, this.indexOf(string1, 0)) == -1)) {2939 return (-1);2940 } else {2941 return this.substring((this.indexOf(string1, 0) + string1.length), (this.indexOf(string2, this.indexOf(string1, 0))));2942 }2943};2944var lazyRefs = null;2945function refResolve() {2946 lazyRefs = $(".refPlaceHolder").lazyLoad({2947 batchSize:50,2948 intoView:function(objs,idx){2949 if( objs ){2950 if( objs[0] ){2951 var start = $(objs[0]).attr("id").substring(8);2952 if(!start) {2953 start = 1;2954 }2955 var count = objs.length;2956 if (idx) {2957 resolveRefs(idx,1);2958 }2959 else {2960 resolveRefs( start, count );2961 }2962 }2963 }2964 }2965 });2966}2967function resolveRefs( start, count ){2968 var url = SDM.ep.refResolvePath + "&_refRangeStart="+start+"&_refRangeCount="+count;2969 var isHoover = true;2970 if (count == 1) {2971 isHoover = false;2972 }2973 ajaxRefResol = new $.ajax({2974 url: url,2975 type: 'GET',2976 async : isHoover,2977 dataType : 'text',2978 error: function() {2979 $(".refPlaceHolder").each(function(){2980 $(this).html(' <span style="color:red;"> [SD-008]<\/span>');2981 });2982 return;2983 },2984 success: function(res) {2985 var refMap = decodeURIComponent(res);2986 var citedBySCEids = refMap.substringBetween("#","^");2987 var tmp = "#"+citedBySCEids+"^";2988 refMap = refMap.replace(tmp,"");2989 if (refMap != null) {2990 this.$OuterDiv = $('<div></div>').hide().append($(refMap));2991 $(".refPlaceHolder").each(function(){2992 if (myMap[this.id.toLowerCase()]['refHtml'] || myMap[this.id.toLowerCase()]['refHtml'] != "") {2993 if(this.innerHTML.match('/science?') == null){2994 $(this).html(myMap[this.id.toLowerCase()]['refHtml'] );2995 $(this).attr ("data-refres", "Y");2996 }2997 // Add abstarct url to the <li> tag2998 if (myMap[this.id.toLowerCase()]['absUrl']) {2999 $(this).attr ("data-absurl", myMap[this.id.toLowerCase()]['absUrl']);3000 }3001 }3002 else {3003 $(this).html("");3004 $(this).attr ("data-refres", "Y");3005 }3006 });3007 // update Cited by counts3008 if(citedBySCEids != null && citedBySCEids != ""){3009 updateCitedByCounts(citedBySCEids,isHoover,start,count);3010 }3011 }3012 }3013 }); 3014}3015//Reference resolution End3016var EbookTOC = {3017 eBookTOCTimeout: 1000,3018 currentLink: null,3019 tocObj: null,3020 init: function() {3021 var eBookTOCURL = $('div.publicationHead div.title a').attr("href").replace('book', 'toc');3022 3023 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {3024 var tocStr = sessionStorage.getItem('bk.toc');3025 if(tocStr) {3026 EbookTOC.tocObj = $.parseJSON(tocStr);3027 if(EbookTOC.tocObj.eBookCID==SDM.pm.cid) {3028 DBG.out(1, 'Found bk.toc using...');3029 }3030 else {3031 EbookTOC.tocObj=null;3032 sessionStorage.removeItem('bk.toc');3033 DBG.out(1, 'Found different bk.toc removing...');3034 }3035 }3036 }3037 3038 if(EbookTOC.tocObj==null) {3039 $.getJSON(eBookTOCURL, function(res) {3040 if (res){3041 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {3042 sessionStorage.setItem('bk.toc', JSON.stringify(res));3043 DBG.out(1, 'Storing bk.toc');3044 }3045 }3046 EbookTOC.load(res);3047 });3048 }3049 else {3050 EbookTOC.load(EbookTOC.tocObj);3051 }3052 $('#leftPane #srcOutline li div.so a').ellipsis();3053 }, //init3054 load:function(res) {3055 var $bookToc = EbookTOC.buildToc(res);3056 $('#leftPane').prepend('<ul id="lpTabs">'3057 + '<li class="leftTab tab" tabindex="0">Book contents</li>'3058 + '<li class="rightTab tab" tabindex="0">Chapter contents</li>'3059 + '</ul>');3060 $('#lpTabs .leftTab').click(function() {3061 if($('#srcOutline').css('display')!='none') return;3062 EbookTOC.showSourceTab(this);3063 SD_UTIL.sendUserKeyEvent('sourceTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3064 });3065 $('#lpTabs .rightTab').click(function() {3066 if($('#srcOutline').css('display')=='none') return;3067 EbookTOC.showItemTab(this);3068 SD_UTIL.sendUserKeyEvent('itemTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3069 });3070 $('#outline').prepend($bookToc);3071 $('#outline, #leftPane, #leftPaneInner').addClass('book');3072 //Initially set all parent nodes to collapsed.3073 EbookTOC.showPath2Item(SDM.pm.pii);3074 $('.activeChapter >a').attr('href', "");3075 if(SDM.outlineTab=='I') {3076 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);3077 }3078 else {3079 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);3080 $('#outline').scrollToTopic({selTopic:'div.activeChapter'}); 3081 }3082 $('.leftPaneToggle').unbind('click').bind('click',function(e){3083 e.preventDefault();3084 e.stopPropagation();3085 EbookTOC.nodeClick($(this)[0]);3086 });3087 }, //load3088 showSourceTab:function(e) {3089 $(e).parent().children('.tab').removeClass('activeTab');3090 $(e).addClass('activeTab');3091 $('.outlineMsg').hide();3092 $('#srcOutline').show();3093 $('.activeChapter').parent().append($('#itemOutline')[0]);...
sd_131.js
Source:sd_131.js
...1478 if(SDM.outlineTab=='I') {1479 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);1480 }1481 else {1482 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);1483 }1484 }1485 }1486 else {1487 Outline.getJson ();1488 tocCounter++;1489 trd = trd*SDM.pm.toc.retryFactor;1490 tocIntrvl = setInterval(tocCheck, trd);1491 }1492 }1493 ///////////1494 var tocIntrvl = setInterval(tocCheck, trd);1495 }1496 }1497 else {1498 $('#centerInner').outline( $('#outline'), page.opts );1499 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());1500 if($('#outline').width()>240){1501 $('#outline > ul,#articleLeftAd').css('width', $('#outline').width()-$.scrollBarWidth());1502 }else{1503 $('#outline > ul,#articleLeftAd').css('width', 240);1504 }1505 $('#outline').attr('data-st', 0);1506 }1507 $('#outline').attr('data-st', 0);1508 CollapsibleTextbox.init();1509 page.delayedScrollHandler = _.debounce( page.viewHandler, 300 );1510 $( "#centerPane" ).bind( "scroll.viewHandler", page.delayedScrollHandler );1511 1512 $("#page-area").on("click", ".intra_ref,.authorVitaeLink,.figureLink,.authorName, .viewWS", {z:'centerPane'}, rightSidePane.findTargetElement);1513 if (Fragment.isAvail())1514 $("#outline").on("click", ".tocLink", {z:'leftPane'}, Outline.findTargetFragment);1515 else 1516 $("#outline").on("click", ".tocLink", Outline.moveToSection);1517 1518 $("#centerPane").on('click', '.btnHolder', function(e){page.toggleOptions(e,this);} );1519 $('a.articleOptions').toggle(1520 function() { $('div.articleOptions').css('display', 'block');},1521 function() { $('div.articleOptions').css('display', 'none');}1522 );1523 $('#optImgToggle').click(function() {page.toggleImages('toolbar');});1524 $('#leftPane').height('');1525 page.lazyLoadInit();1526 page.showFullTableLink();1527 $('div.downloadCsv').bind("click", TableDownload.processRequest);1528 $('a.ppt').bind("click", FigureDownload.processRequest);1529 if(SDM.pm.contentType == "BK") EbookTOC.init();1530 if(SDM.isMRWMODArticle && SDM.ldrAvail) {$('.outlineMsg').hide();mrwLeftPane.init();}1531 EComponent.init();1532 CanonicalLink.init();1533 CanonicalHomeLink.init();1534 page.searchWithinInit();1535 if(!SDM.crawlerAvail) { refResolve(); }1536 if(SDM.displayGadgets) {1537 if (SDM.sciverseGadgetDetailsID.length > 0) {1538 GadgetUtil.loadGadgetsParallel();1539 } else {1540 GadgetUtil.loadGadgets();1541 }1542 }1543 Outline.hoverOverOff();1544 $('#centerPane')[0].tabIndex = -1;1545 $('#centerPane')[0].focus();1546 ready=true; 1547 } //addJS1548 } //page1549 if($('#frag_1').length || !Fragment.isAvail()) {1550 page.addJS();1551 }1552 else {1553 var if1 = setInterval(function() {1554 if($('#frag_1').length) {1555 clearInterval(if1);1556 page.addJS();1557 }1558 else {1559 //nothing wait for it1560 }1561 }, 250);1562 }1563 return page;1564 }();1565} //initializeArticlePage1566function checkSearchWithin() {1567 if($('#searchWithin input[type=text]').prop('value')=='') {1568 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1569 }1570 else {1571 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1572 }1573}1574$.fn.outline = function(oObj, opts, tocJson) {1575 var cfg = {1576 empty: false,1577 selector: '.outlineItem',1578 graphicsToggler: true,1579 searchWithin: false,1580 focusEffect: true,1581 focus: {}1582 };1583 Outline.oObj = oObj;1584 return this.each(function() {1585 if(opts) {1586 $.extend(true, cfg, opts);1587 }1588 oObj.append('<ul id="itemOutline"></ul>');1589 var $iOutline = $('#itemOutline');1590 if(cfg.graphicsToggler) {1591 $('#outline.js').css('top', 32);1592 if(SDM.pm.contentType=="BK") {1593 $('#outline.book').css('top', 44);1594 }1595 if(SDM.isMRWMODArticle) {1596 $('#outline.book').css('top', 10);1597 }1598 1599 oObj.parent().prepend('<div id="olGraphCbBox">'1600 + '<label><input id="outlineGraphicsCheckBox" type="checkBox" checked="true">Show thumbnails in outline</label>'1601 + '</div>');1602 }1603 if(cfg.searchWithin) {1604 oObj.parent().prepend('<div id="searchWithin" class="textEntry" role="Search" aria-label="Book">'1605 + '<form name="searchWithinForm" action="javascript:checkSearchWithin();ArticlePage.searchWithinSubmit();">'1606 + '<input type="text" value="Search this book" title="Search this book" size="26" maxlength="450"></input></form>'1607 + '<button class="clearWithin" title="Clear book search"><div class="clearXHide"></div></button>'1608 + '<button class="submit" title="Search this book"></button>'1609 + '</div>');1610 $('#searchWithin button.clearWithin').click(function() {1611 $('#searchWithin input[type=text]').prop('value', 'Search this book');1612 $(this).children().addClass('clearXHide').removeClass('clearXShow');1613 SearchWithin.clear();1614 });1615 $('#leftPane button.submit').click(function() {ArticlePage.searchWithinSubmit();});1616 $('#searchWithin input[type=text]').focusin(function() {1617 if($(this).prop('value')=='Search this book') {1618 $(this).prop('value', '');1619 }1620 });1621 $('#searchWithin input[type=text]').focusout(function() {1622 if($(this).prop('value')=='') {1623 $(this).prop('value', 'Search this book');1624 $(this).parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1625 }1626 else {1627 $(this).parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1628 }1629 });1630 }1631 var level = "";1632 var isGraphics = false;1633 prs.rt('outlineLoop_start');1634 if (SDM.tocCacheAvail) {1635 if(typeof tocJson == 'undefined') {1636 //miss and retries are done1637 Outline.buildOutlineUnavailable(cfg);1638 Outline.postBuild(cfg);1639 }1640 else {1641 // build outline from JSON1642 var outlineObj;1643 try {1644 outlineObj = $.parseJSON(tocJson);1645 Outline.buildOutlineJsonSide(cfg, outlineObj);1646 }1647 catch(e) {1648 SDM.tocCacheAvail = false;1649 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid + "/ftp");1650 if(Fragment.isAvail()) {1651 //Pull in the rest of the article and build it clientside1652 Fragment.get('all', null, {successCb: Outline.buildOutlineClientSide,1653 successCbArg: cfg,1654 failureCb: Outline.buildOutlineUnavailable,1655 failureCbArg: cfg1656 });1657 return;1658 }1659 else {1660 Outline.buildOutlineClientSide(cfg);1661 }1662 }1663 }1664 }1665 else {1666 // Build outline from center pane contents1667 Outline.buildOutlineClientSide(cfg);1668 }1669 }); //return1670 if(mathRenderer.opt.renderOn)mathRenderer.handleRerender($('#rightPane'));1671} //.outline1672var CrossMark = {1673 cssUrl:'',1674 init:function() {1675 $("#open-crossmark").delegate("#crossmark-icon", "click",function(event){1676 $.get(SDM.crossMarkURL +'/'+ SDM.pm.pii + '/article/rightPane/displayPopup/' + SDM.keOriginContentFamily +'/'+ SDM.issn_or_isbn);1677 });1678 if($('#open-crossmark')[0]){1679 LazyLoad.js([SDM.crossMarkLib], function() {1680 $("#open-crossmark").css({'display':'inline-block'}).find('img').css('padding-top','10px');1681 $('#open-crossmark').click(function(){$(".ui-dialog-titlebar").css('top','0px').css('width','520px');});1682 });1683 }1684 $('#open-crossmark').bind('mouseover',function(){setTimeout(CrossMark.setCss,1000);});1685 $('#open-crossmark').bind('mouseout',function(){setTimeout(CrossMark.removeCss,1000);});1686 $('body').bind('mousemove',CrossMark.removeCss);1687 },1688 setCss:function(){1689 if(!$('link[href*="crossmark_widget.css"]')[0]){1690 if(document.createStyleSheet){1691 document.createStyleSheet(CrossMark.cssUrl);1692 }else{1693 $('head').append('<link href="'+CrossMark.cssUrl+'" rel="stylesheet" type="text/css"/>');1694 } 1695 }else{1696 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1697 }1698 },1699 removeCss:function(){1700 if($('link[href*="crossmark_widget.css"]')[0] && !$('.ui-widget-overlay').is(':visible') && !$('#crossmark-tooltip-130').is(':visible')){1701 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1702 $('link[href*="crossmark_widget.css"]').remove();1703 }1704 }1705}1706var SearchWithin = {1707 init:function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1708 var val = SearchWithin.loadSearch();1709 if(val.cid==SDM.pm.cid && val.str) {1710 var swObj = SearchWithin.loadResult();1711 if(swObj) {1712 if(swObj && swObj.cid==SDM.pm.cid) {1713 if(swObj.status!=0) {1714 SearchWithin.clear();1715 }1716 else {1717 SearchWithin.processResult(swObj, bkOutlineSelStr, selStr, idConvert);1718 }1719 }1720 else {1721 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1722 }1723 }1724 else {1725 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1726 }1727 }1728 },1729 loadSearch:function() {1730 var flag=true;1731 var searchStr='';1732 var cidStr = '';1733 var beg = document.cookie.indexOf('SEARCHWITHIN=');1734 if(beg!=-1) {1735 beg = beg + 'SEARCHWITHIN='.length;1736 var end = document.cookie.indexOf(';', beg);1737 var cookieStr = document.cookie.slice(beg, end);1738 flag = cookieStr.split('SW()')[0];1739 searchStr = cookieStr.split('SW()')[1];1740 cidStr = cookieStr.split('SW()')[2];1741 }1742 else {1743 return {f:'',str:'',cid:''};1744 }1745 return {f:flag,str:searchStr,cid:cidStr}; //[searchStr, cidStr];1746 },1747 saveSearch: function(f, sStr) {1748 var site = document.location.pathname.split('/article/pii/')[0];1749 document.cookie='SEARCHWITHIN' + '=' + f + 'SW()' + sStr + 'SW()' + SDM.pm.cid + ';;path=' + site;1750 },1751 reqResult: function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1752 $.get('/science/searchwithin', function(res) {1753 var result;1754 try {1755 result = $.parseJSON(res);1756 }1757 catch(e) {1758 DBG.out(1, 'SearchWithin failed');1759 return;1760 }1761 if(result.status==1 || typeof result.hitTerms=="undefined") {1762 funcNoResult();1763 }1764 else {1765 if(result.status==0) {1766 SearchWithin.processResult(result, bkOutlineSelStr, selStr, idConvert);1767 }1768 }1769 });1770 },1771 processResult: function(result, bkOutlineSelStr, selStr, idConvert) {1772 var len = result.piis.length;1773 for(var i=0; i<len; i++) {1774 if(SDM.pm.pii==result.piis[i]) {1775 SearchWithin.hlCenterPane(result.hitTerms.toString().replace(/,/g, ' '), selStr, idConvert);1776 }1777 }1778 SearchWithin.hlOutline(result.piis, bkOutlineSelStr);1779 SearchWithin.saveResult(result);1780 },1781 saveResult: function(rslt) {1782 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {1783 sessionStorage.setItem('bk.sw', JSON.stringify(rslt));1784 }1785 },1786 loadResult: function() {1787 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1788 var sw = sessionStorage.getItem('bk.sw');1789 if(sw) {1790 var swObj = $.parseJSON(sw);1791 if(swObj.cid==SDM.pm.cid) {1792 return swObj;1793 }1794 else {1795 SearchWithin.clearResult();1796 return null;1797 }1798 }1799 else {1800 SearchWithin.clearResult();1801 return null;1802 }1803 }1804 },1805 clearResult: function() {1806 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1807 sessionStorage.removeItem('bk.sw');1808 }1809 },1810 clear:function(keepMsg) {1811 $('.swh').removeClass('swh');1812 $('.searchword').removeClass('searchword');1813 var site = document.location.pathname.split('/article/pii/')[0];1814 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;';1815 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;path=' + site;1816 if(typeof keepMsg=="undefined" && typeof ArticlePage!="undefined")1817 ArticlePage.searchWithinErrorMsgClear();1818 }, //searchWithin.clear1819 hlOutline:function(piis, selStr) {1820 var len = piis.length;1821 for(var i=0; i<len; i++) {1822 $(selStr).each(function() {1823 if($(this).attr('data-pii')==piis[i]) {1824 DBG.out(1, 'Highlighting Book TOC item ' + $(this).text());1825 if($(this).attr('data-pii')!=SDM.pm.pii) {1826 $(this).find('div a').addClass('swh');1827 }1828 EbookTOC.getPath2Item(piis[i]).each(function() {1829 $(this).children('a').addClass('swh');1830 });1831 }1832 });1833 }1834 },1835 hlCenterPane:function(hitTerms, selStr, idConvert) {1836 searchStr = hitTerms;1837 //center pane highlighting1838 searchhi.process($('#centerPane')[0], searchStr);1839 //outline highlighting1840 var objs = $('.searchword').each(function() {1841 $(this).attr('data-posy', $(this).position().top);1842 });1843 $(selStr).each(function() {1844 $(this).attr('data-posy', $(this).position().top);1845 objs.push(this);1846 });1847 objs = _.sortBy(objs, function(val) {1848 return $(val).attr('data-posy')*1.0;1849 });1850 objs = _.filter(objs, function(val) {1851 return $(val).parents('.textboxBody').length==0;1852 });1853 objs = objs.reverse();1854 var len = objs.length;1855 for(i=0; i<len; i++) {1856 var $c = $(objs[i]);1857 if($c.hasClass('searchword')) {1858 var ii=i;1859 while($(objs[ii]).length && $(objs[ii]).hasClass('searchword')) {ii++;}1860 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1861 var foundType="h4";1862 if($(objs[ii]).is("h4")) {1863 foundType = "h4";1864 }1865 if($(objs[ii]).is("h3")) {1866 foundType = "h3";1867 }1868 if($(objs[ii]).is("h2")) {1869 foundType = "h2";1870 done=true;1871 }1872 var done=false;1873 while(!done && $(objs[ii]).length) {1874 if(foundType=="h4") {1875 if($(objs[ii]).is("h4")) {}1876 if($(objs[ii]).is("h3")) {1877 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1878 }1879 if($(objs[ii]).is("h2")) {1880 done=true;1881 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1882 }1883 }1884 else if(foundType=="h3") {1885 if($(objs[ii]).is("h4")) {}1886 if($(objs[ii]).is("h3")) {}1887 if($(objs[ii]).is("h2")) {1888 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1889 done=true;1890 }1891 }1892 if($(objs[ii]).is("h2")) {1893 done=true;1894 }1895 ii++;1896 }1897 }1898 }1899 }//searchWithin.highlight1900} //SearchWithin1901var ArticleOutline={1902outline : "",1903init:function(){1904//var toc = $.parseJSON(ArticleOutline.outline);1905 if(typeof SDM.tocJson !='undefined')1906 {1907 var obj = $.parseJSON(SDM.tocJson);1908 for (var i=0;i<=obj.TOC.length;i++) {1909 ArticleOutline.buildSectionItem(obj.TOC[i]);1910 }1911 }1912},1913buildSectionItem:function(sec){1914//var $section;1915var html = '';1916var keyE = '"displayTOCSection", "article", "leftPane", '+SDM.keOriginContentFamily +'';1917//$section = $('<li class="" style="margin-right:16px;"></li>');1918 if(sec.sID != undefined){1919 html += '<div id="ol_'+sec.sID+'" class="io item h2sec"></div>';1920 //$section.append('<div id="ol_'+sec.sID+'" class="io item h2sec"></div>');1921 }1922 if(sec.sT != undefined){1923 html += '<a onclick="SD_UTIL.sendUserKeyEvent(\'displayTOCSection\', \'article\', \'leftPane\', '+SDM.keOriginContentFamily +'); return $(\'#centerPane\').moveTo(\''+ sec.sID +'\')" href=\'#'+sec.sID+'\' >'+sec.sT+'</a>';1924 }1925 1926 //$section.append($div);1927 return html;1928}1929}1930var Outline = {1931 onHover:false,1932 pendCloseTimer:null,1933 init:function() {1934 $('#leftPane').hover(1935 function() {1936 Outline.hoverOverOn();1937 if(!pgLayout.showLeftBar) {1938 clearTimeout(Outline.pendingCloseTimer);1939 }1940 }, 1941 function() { 1942 Outline.hoverOverOff();1943 if(!pgLayout.showLeftBar) {1944 Outline.pendingCloseTimer = setTimeout(Outline.sidebarClose, 1000);1945 }1946 } 1947 );1948 $('#leftCloseBar').click(function(e) {Outline.sidebarOpenClick(e)});1949 $('#leftOpenBar').click(function(e) {Outline.sidebarCloseClick(e)});1950 },1951 buildOutlineJsonSide:function(cfg, outlineObj) {1952 var $iOutline = $('#itemOutline');1953 if (outlineObj!=null && outlineObj.TOC != undefined && outlineObj.TOC.length>1) {1954 $(outlineObj.TOC).each(function(i, h2Sec) {1955 if(h2Sec.sT != undefined && h2Sec.sT.length>0){1956 var secTitle = h2Sec.sT;1957 secTitle = secTitle.replace (/'/g, "'"); 1958 if (SDM.pageType == 'article_full') { 1959 $iOutline.append(Outline.addItemSection(h2Sec.sID, secTitle, 'h2'));1960 } else if (SDM.pageType == 'article_abs') {1961 $iOutline.append(Outline.addItemOutline(h2Sec.sID, secTitle, 'h2'));1962 }1963 }1964 if(h2Sec.faID != undefined && h2Sec.faID.length > 0) {1965 $(h2Sec.faID).each(function(i, floatanc) {1966 if(floatanc.fT == 'fig'){1967 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1968 if(floatanc.fI.length>0){1969 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h2', floatanc.fIh));1970 }1971 }1972 else if(floatanc.fT == 'tbl'){1973 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h2'));1974 }1975 else if(floatanc.fT == 'ecomp'){1976 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h2'));1977 }1978 })1979 }1980 if (h2Sec.cT != undefined && h2Sec.cT.length > 0) {1981 $(h2Sec.cT).each(function(i, h3Sec) {1982 if(h3Sec.sT.length>0){1983 var secTitle = h3Sec.sT;1984 secTitle = secTitle.replace (/'/g, "'"); 1985 if (SDM.pageType == 'article_full') {1986 $iOutline.append(Outline.addItemSection(h3Sec.sID, secTitle, 'h3'));1987 }else if (SDM.pageType == 'article_abs'){1988 $iOutline.append(Outline.addItemOutline(h3Sec.sID, secTitle, 'h3'));1989 }1990 }1991 if(h3Sec.faID != undefined && h3Sec.faID.length > 0){1992 $(h3Sec.faID).each(function(i, floatanc){1993 if(floatanc.fT == 'fig'){1994 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1995 if (floatanc.fI.length>0){1996 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h3', floatanc.fIh));1997 }1998 }1999 else if(floatanc.fT == 'tbl'){2000 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h3'));2001 }2002 else if(floatanc.fT == 'ecomp'){2003 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h3'));2004 }2005 })2006 }2007 if(h3Sec.cT != undefined && h3Sec.cT.length > 0){2008 $(h3Sec.cT).each(function(i, h4Sec) {2009 if(h4Sec.sT.length>0){2010 var secTitle = h4Sec.sT;2011 secTitle = secTitle.replace (/'/g, "'"); 2012 if (SDM.pageType == 'article_full') {2013 $iOutline.append(Outline.addItemSection(h4Sec.sID, secTitle, 'h4'));2014 }else if (SDM.pageType == 'article_abs'){2015 $iOutline.append(Outline.addItemOutline(h4Sec.sID, secTitle, 'h4'));2016 }2017 }2018 if(h4Sec.faID != undefined && h4Sec.faID.length > 0){2019 $(h4Sec.faID).each(function(i, floatanc){2020 if(floatanc.fT == 'fig'){2021 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;2022 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h4', floatanc.fIh));2023 }2024 else if(floatanc.fT == 'tbl'){2025 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h4'));2026 }2027 else if(floatanc.fT == 'ecomp'){2028 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h4'));2029 }2030 })2031 }2032 })2033 }2034 })2035 }2036 })2037 $('#leftPane .outlineMsg').remove();2038 }2039 else {2040 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {2041 $('#outline').css('top', 0);2042 }2043 $('#outline .outlineMsg').html('This document does not have an outline.')2044 .show();2045 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();2046 }2047 Outline.postBuild(cfg);2048 },2049 buildOutlineClientSide:function(cfg) {2050 var level = "";2051 var $iOutline = $('#itemOutline');2052 if($(cfg.selector).length>0) {2053 $(cfg.selector).each(function() {2054 if($(this).parents('.textboxBody').length>0) {}2055 else {2056 if($(this).attr('id')==undefined) {2057 $(this).attr('id', 'bs_' + Math.floor(Math.random()*100000));2058 DBG.out(1, 'fixing id::' + $(this).attr('id') + '::' + $(this).text());2059 }2060 DBG.out(4, 'adding::' + $(this).text());2061 if($(this).is("h2")||$(this).is("h3")||$(this).is("h4")) {2062 level = $(this)[0].tagName;2063 level = level.toLowerCase();2064 var label = $(this).html();2065 var hasMml=$(this).find("#itemOutline .mathmlsrc"); 2066 if(hasMml) { 2067 $("#itemOutline .mathmlsrc").attr('onclick',''); 2068 }2069 if(label==undefined) label='';2070 if (SDM.pageType == 'article_full') {2071 $iOutline.append(Outline.addItemSection($(this).attr('id'), label, level));2072 }2073 else if (SDM.pageType == 'article_abs') {2074 //Note: In case of unentitled view we render the outline from a hidden div in center pane2075 $iOutline.append(Outline.addItemOutline($(this).attr('id'), label, level));2076 }2077 }2078 else {2079 if($(this).hasClass('table')==true) {2080 var label = $(this).attr('data-label');2081 if(label==undefined) label='';2082 $iOutline.append(Outline.addItemTbl($(this).attr('id'), label, level));2083 }2084 else if($(this).hasClass('figure')==true) {2085 var label = $(this).find(".label").html();2086 if(label==undefined) label='';2087 var image = SDM.imageUrlPrefix + $(this).find("dt img").attr('data-thumbEID');2088 var thumbHeight = $(this).find("dt img").attr('data-thumbheight');2089 if(!$(this).children('div').attr('id')){2090 $iOutline.append(Outline.addItemFig($(this).attr('id'), label, image, level, thumbHeight));2091 }2092 }2093 else if($(this).hasClass('ecomponent')==true) {2094 var label = $(this).attr('data-label');2095 if(label==undefined) label='';2096 var ext = $(this).attr('data-ext');2097 $iOutline.append(Outline.addItemMMC($(this).parent('dl').attr('id'), label, ext, level));2098 }2099 else {}2100 }2101 }2102 })2103 $('#leftPane .outlineMsg').remove();2104 }2105 else {2106 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {2107 $('#outline').css('top', 0);2108 }2109 $('#outline .outlineMsg').html('This document does not have an outline.')2110 .show();2111 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();2112 }2113 Outline.postBuild(cfg);2114 },2115 buildOutlineUnavailable:function(cfg) {2116 if(SDM.pm.contentType!='BK') {2117 $('#outline').css('top', 0);2118 }2119 $('#outline .outlineMsg').html('The outline for this document is currently unavailable.')2120 .show();2121 },2122 postBuild:function(cfg) {2123 var oObj = Outline.oObj;2124 prs.rt('outlineLoop_end');2125 oObj.append('<div id="articleLeftAd"></div>');2126 Outline.showLeftAd();2127 2128 //Setup the sync between rightPane scroll and outline highlight2129 if(cfg.focusEffect==true) {2130 oObj.syncTo(cfg);2131 }2132 2133 $('#outline > ul').show();2134 if(SDM.isMRWMODArticle && SDM.ldrAvail)$('#itemOutline').hide(); 2135 2136 if(SDM.outlineImgFence==true) {2137 if($('li div.fig, li div.tbl, li div.mmc').length > 0) {2138 if(SDM.outlineGraphics == true) {2139 $('#outlineGraphicsCheckBox').prop('checked', true);2140 }2141 else {2142 $('#outlineGraphicsCheckBox').prop('checked', false)2143 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2144 }2145 $('#outlineGraphicsCheckBox').change(function() {2146 Outline.toggleGraphics();2147 if($('#outlineGraphicsCheckBox').prop('checked')==true) {2148 SD_UTIL.sendUserKeyEvent('enableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2149 }2150 else {2151 SD_UTIL.sendUserKeyEvent('disableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2152 }2153 });2154 }2155 else {2156 $('#outlineGraphicsCheckBox').prop('checked', false);2157 $('#olGraphCbBox label').hide();2158 }2159 }2160 else {2161 $('#olGraphCbBox').hide();2162 $('#outlineGraphicsCheckBox').prop('checked', false)2163 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2164 }2165 oObj.scroll();2166 },2167 itemAction: function() {2168 SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');2169 2170 },2171 addItemMMC: function(hashId, lbl, ext, hStr) {2172 var ecn = "olIconMMCDef";2173 if(ext=="pdf"){extCls="olIconMMCPdf"}2174 else if(ext=="avi"){ecn="olIconMMCMov"}2175 else if(ext=="csv"){ecn="olIconMMCCsv"}2176 else if(ext=="eps"){ecn="olIconMMCEps"}2177 else if(ext=="flv"){ecn="olIconMMCFlv"}2178 else if(ext=="gif"){ecn="olIconMMCImg"}2179 else if(ext=="jpg"){ecn="olIconMMCJpg"}2180 else if(ext=="kmz"){ecn="olIconMMCDef"}2181 else if(ext=="mml"){ecn="olIconMMCDef"}2182 else if(ext=="xls"){ecn="olIconMMCExcel"}2183 else if(ext=="ppt"){ecn="olIconMMCPpt"}2184 else if(ext=="doc"){ecn="olIconMMCWord"}2185 else if(ext=="mp3"){ecn="olIconMMCAud"}2186 else if(ext=="mpg"){ecn="olIconMMCMov"}2187 else if(ext=="mp4"){ecn="olIconMMCMpg4"}2188 else if(ext=="txt"){ecn="olIconMMCTxt"}2189 else if(ext=="png"){ecn="olIconMMCPng"}2190 else if(ext=="mov"){ecn="olIconMMCMov"}2191 else if(ext=="rtf"){ecn="olIconMMCRtf"}2192 else if(ext=="svg"){ecn="olIconMMCSvg"}2193 else if(ext=="tar"){ecn="olIconMMCDef"}2194 else if(ext=="tif"){ecn="olIconMMCDef"}2195 else if(ext=="zip"){ecn="olIconMMCZip"}2196 else {ecn = "olIconMMCDef";}2197 var html;2198 if(SDM.entitled==true){2199 html = "<li><div id='ol_" + hashId + "' class='tocLink io item " + hStr + "sec mmc'>"2200 + "<div class=\"olIcon " + ecn + "\"></div><a class=\"olIcon " + ecn + "\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \">"2201 + lbl + "</a></div></li>";2202 }2203 else{2204 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec mmc'>"2205 + "<div class=\"olIcon " + ecn + "\"></div><a class=\"olIcon " + ecn + " cLink\" queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>"2206 + lbl 2207 + "</a></div></li>";2208 }2209 return html;2210 }, //Outline.addItemMMC2211 addItemTbl: function(hashId, lbl, hStr) {2212 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec tbl'>"2213 + "<div class=\"olIcon olIconTbl\"></div><a class=\"tocLink olIcon olIconTbl\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \">"2214 + lbl + "</a></div></li>";2215 return html;2216 }, //Outline.addOutlineItemTbl2217 addItemFig: function(hashId, lbl, img, hStr, thumbHeight) {2218 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec fig'>"2219 + "<a class='tocLink' href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');\">"2220 html += "<img src=\"/sd/grey_pxl.gif\" class=\"smlImgLazyJSB greyImg\" data-smlsrc='" + img + "' data-thumbheight='" + thumbHeight + "'/></a></div></li>";2221 return html;2222 }, //Outline.addOutlineItemFig2223 addItemSection: function(hashId, lbl, hStr) {2224 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec'>"2225 + "<a class='tocLink'href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');\">"2226 + lbl + "<br>"2227 + "</a></div></li>";2228 return html;2229 }, //Outline.addOutlineItemSection2230 addItemOutline: function(hashId, lbl, hStr) {2231 var html = "<li><div class='io item " + hStr + "sec'>"2232 + "<a class='cLink' queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>"2233 + lbl + "<br>"2234 + "</a></div></li>";2235 return html;2236 }, //Outline.addOutlineItemSection2237 sidebarOpenClick: function(e) {2238 Outline.sidebarOpen(true);2239 SD_UTIL.sendUserKeyEvent('openLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2240 return false;2241 },2242 sidebarCloseClick: function(e) {2243 Outline.sidebarClose(); 2244 SD_UTIL.sendUserKeyEvent('closeLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2245 return false;2246 },2247 sidebarOpen: function(e) {2248 if($('#leftPane').css('display')=='none') {2249 $('#leftCloseBar').hide();2250 $('#leftPane').height('').height($('#leftPane').height()).show();2251 $('#leftPane').animate({'margin-left':'0px'}, 250, function() {2252 var ol = $('#outline');2253 ol.css('overflow-y', 'auto');2254 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2255 else {2256 ol.scrollTop(ol.attr('data-st'));2257 }2258 ol.css('overflow-y', 'hidden');2259 if(e==true) {2260 Outline.hoverOverOn();2261 }2262 });2263 }2264 },2265 sidebarClose: function() {2266 if($('#leftPane').css('display')=='block' && $('#leftPane').attr('data-closing')!='y') {2267 var ol = $('#outline');2268 var st = ol.scrollTop();2269 ol.attr('data-st', st);2270 ol.css('overflow-y', 'hidden');2271 $('#leftPane').attr('data-closing', 'y');2272 $('#leftPane').height('').height($('#leftPane').height());2273 $('#leftPane').animate({'margin-left':'-280px'},250,function(){2274 $(this).hide();2275 $('#leftCloseBar').show();2276 $('#leftPane').attr('data-closing', '');2277 });2278 }2279 },2280 collapseSmallLeft: function() {2281 }, //Outline.collapseSmallLeft2282 expandSmallLeft: function() {2283 }, //Outline.expandSmallLeft2284 toggleGraphics: function(force) {2285 if(SDM.outlineImgFence==false) return;2286 2287 if(typeof(force)!=undefined) {2288 if(force=="hide") {2289 SDM.outlineGraphics=true;2290 }2291 else if(force=="show") {2292 SDM.outlineGraphics=false;2293 }2294 else {}2295 }2296 2297 if(SDM.outlineGraphics == true) {2298 SDM.outlineGraphics = false;2299 var ulWidthBefore = $('#outline ul').width();2300 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2301 var ulWidthAfter = $('#outline ul').width();2302 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2303 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)$('#outline').css('overflow-x', 'hidden');2304 $('#outline').attr('data-osbp', 'n');2305 }2306 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2307 $('#outline').attr('data-osbp', 'y');2308 }2309 }2310 else {2311 SDM.outlineGraphics = true;2312 var ulWidthBefore = $('#outline ul').width();2313 $('li div.fig, li div.tbl, li div.mmc').parent().show();2314 var ulWidthAfter = $('#outline ul').width();2315 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2316 $('#outline').attr('data-osbp', 'n');2317 }2318 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2319 $('#outline').css('overflow-x', 'auto');2320 $('#outline').attr('data-osbp', 'y');2321 }2322 }2323 }, //Outline.toggleGraphics2324 hoverOverOn: function() {2325 this.onHover = true;2326 var ol = $('#outline');2327 ol.doTheScrollJitter();2328 2329 var ulWidthBefore = $('#outline ul').width();2330 if(SDU.isIE7()) {}2331 else {2332 //ol.css('overflow-x', 'auto');2333 }2334 2335 ol.css('overflow-y', 'auto');2336 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2337 else {2338 ol.scrollTop(ol.attr('data-st'));2339 }2340 2341 var ulWidthAfter = $('#outline ul').width();2342 if(ulWidthAfter < ulWidthBefore) {2343 ol.attr('data-osbp', 'y');2344 if(SDU.isIE7()) {}2345 else {2346 if($('#lpTabs .leftTab').hasClass('activeTab')) {2347 ol.find('.srcli').each(function() {2348 if($(this).children('div.activeChapter').length) {2349 $(this).children('div.activeChapter').children('span').css('margin-right', 0);2350 $(this).find('li').css('margin-right', 0);2351 }2352 else {2353 $(this).css('margin-right', 0);2354 }2355 });2356 }2357 else {2358 ol.find('li').css('margin-right', 0);2359 }2360 }2361 }2362 else {2363 ol.attr('data-osbp', 'n');2364 if(SDU.isIE7()) {}2365 else {2366 ol.find('li').not('.outlineFocus').css('margin-right', 0);2367 }2368 ol.find('li.outlineFocus').parent().css('background', '#ffffff');2369 }2370 ol.css('background', '#ffffff');2371 ol.children('ul').css('background', '#ffffff');2372 ol.addClass('active');2373 2374 $('#articleLeftAd').css('background', '#ffffff');2375 if( $("#articleLeftAd iframe").length > 0 ){2376 $('#articleLeftAd iframe').contents().find('body').css('background', '#ffffff');2377 $('#articleLeftAd iframe').css('background', '#ffffff');2378 }2379 },2380 hoverOverOff: function() {2381 this.onHover = false;2382 var ol = $('#outline');2383 ol.doTheScrollJitter()2384 var ulWidthBefore = $('#outline ul').width();2385 var st = ol.scrollTop();2386 ol.attr('data-st', st);2387 ol.css('overflow-y', 'hidden');2388 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)ol.css('overflow-x', 'hidden');2389 var ulWidthAfter = $('#outline ul').width();2390 if(SDU.isIE7()) {2391 if(ulWidthAfter < ulWidthBefore) {}2392 else {2393 if($('#lpTabs .leftTab').hasClass('activeTab')) {2394 $('#outline > ul > li').css('margin-right', 0);2395 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2396 }2397 else {2398 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2399 }2400 }2401 }2402 else {2403 if(ulWidthAfter < ulWidthBefore) {2404 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2405 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2406 }2407 else {2408 ol.find('#itemOutline > li').each(function() {2409 if($(this).children('div.activeChapter').length) {2410 $(this).children('div.activeChapter').children('span').css('margin-right', $.scrollBarWidth());2411 $(this).find('li').css('margin-right', 0);2412 }2413 else {2414 $(this).css('margin-right', $.scrollBarWidth());2415 }2416 });2417 }2418 }2419 ol.find('li.outlineFocus').parent().css('background', '#ecf2f6');2420 ol.css('background', '#ecf2f6');2421 ol.children('ul').css('background', '#ecf2f6');2422 ol.removeClass('active');2423 //This must be at end or FF will reset the scroll2424 ol.scrollTop(st);2425 2426 $('#articleLeftAd').css('background', '#ecf2f6');2427 if( $("#articleLeftAd iframe").length > 0 ) {2428 $('#articleLeftAd iframe').contents().find('body').css('background', '#ecf2f6');2429 $('#articleLeftAd iframe').css('background', '#ecf2f6');2430 } 2431 },2432 moveToSection: function(e) {2433 var selID=$(e.target).closest('a').attr('href').split('#');2434 selID=selID[1];2435 $('#centerPane').moveTo(selID);2436 e.preventDefault();2437 e.stopPropagation(); 2438 },2439 findTargetFragment: function(e) {2440 var selID = e;2441 if(typeof e != 'string') {2442 var selID=$(e.target).closest('a').attr('href').split('#');2443 selID=selID[1];2444 }2445 var id = selID; 2446 id = id.replace(/[\.]/g, '\\.');2447 id = id.replace(/[\:]/g, '\\:'); 2448 var obj = $('#'+id); 2449 if (!$(obj)[0]) {2450 // Fragment not loaded yet.2451 if (Fragment.crossRefMap) {2452 var targetFrag = Fragment.getIntraRefFragId (selID);2453 var targetFragNum = targetFrag.substr(targetFrag.indexOf('_')+1)*1;2454 Fragment.get ('frag_' + (targetFragNum-1), e.data.z);2455 Fragment.get (targetFrag, e.data.z, {successCb: function(ee) {Outline.findTargetFragment(ee)},2456 successCbArg: e,2457 failureCb: function(selId) {2458 Fragment.bail(300, 'fndtgt', selId);2459 },2460 failureCbArg: selID2461 });2462 Fragment.get ('frag_' + (targetFragNum+1), e.data.z);2463 }2464 } else {2465 $('.page_fragment').show();2466 Fragment.scrollFlag = false;2467 $('#centerPane').moveTo(selID, { cbFunc: function() {Fragment.scrollFlag=true;}});2468 } 2469 if(typeof e != 'string') {2470 e.preventDefault();2471 e.stopPropagation();2472 }2473 },2474 getJson: function() {2475 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid, function(jsonStr, b, c) {2476 SDM.tocJson = String(jsonStr);2477 }, 'text')2478 .error (function() {2479 DBG.out (1, "Returned Error");2480 });2481 },2482 showLeftAd:function() {2483 if(SDM.adPreventOutline == true) return;2484 if ( typeof SDM.adArticleLeftURL!='undefined') {2485 $("#articleLeftAd").append('<iframe scrolling="no" frameborder="0" border="0" cellspacing="0" src="' + SDM.adArticleLeftURL + '"></iframe>');2486 }2487 } 2488} //Outline2489var DBG = {2490 out: function(lvl, str) {2491 if(SDM.debugFlag=="undefined") {return;}2492 if(SDM.debugFlag >= lvl || lvl==0 || typeof ut == 'object') {2493 if(typeof console=== "undefined" || typeof console.log==="undefined") {2494// if(!$('#sdConsole').length) {2495// $('body').append('<textarea id="sdConsole" class="ui-widget-content" cols="60"></textarea>');2496// $('#sdConsole').resizable();2497// }2498// $('#sdConsole').append(str + "<br>");2499 }2500 else{console.log(str) }2501 }2502 }2503} //DBG2504$(document).ready(function() {2505 if (SDM.pru!='') {2506 SD_UTIL.sendPageLoadStats();2507 }2508 if(!SDM.blk_all_social_logins && SDU.cookieAvail()){2509 LazyLoad.js([SDM.ep.gigyaLib], function() {2510 $('.socialContainer').each(function(){2511 if($(this).attr('id')!=''){2512 loadSocialLoginOptions($(this).attr('id'));2513 }2514 });2515 initGigyaHelp();2516 });2517 }2518 //loadBreadCrumbs();2519});2520function initGigyaHelp()2521{2522 $('#socialHelpPage').click(function(e){2523 e.stopPropagation();2524 e.preventDefault();2525 openPopup($(this).attr('href'),'help',800,600);2526 });2527}2528var SD_UTIL = {2529 killEvent:function(e){2530 if(!e) return;2531 e.preventDefault()2532 e.stopPropagation();2533 },2534 sendUserKeyEvent: function(a, o, z, ocf) {2535 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+ocf+'/'+a);2536 },2537 sendUserKeyEventForPPV: function(a, o, z) {2538 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+a);2539 },2540 sendDownloadKeyEvent: function(o, z, ocf, f) {2541 $.get(SDM.ep.downloadActionURL+'/'+o+'/'+z+'/'+ocf+'/'+f);2542 },2543 loadLib: function(urlStr) {2544 var headID = document.getElementsByTagName('head')[0];2545 var newScript = document.createElement('script');2546 newScript.type = 'text/javascript';2547 newScript.src = urlStr;2548 headID.appendChild(newScript);2549 },2550 isPerfTimingAvail:function() {2551 return !(typeof window.performance==="undefined" || typeof window.performance.timing==="undefined")2552 },2553 isSendStatsReady:function() {2554 if(SD_UTIL.isPerfTimingAvail()) {2555 if(window.performance.timing.domComplete&&window.performance.timing.loadEventStart&&window.performance.timing.loadEventEnd) return true;2556 else return false;2557 }2558 return true;2559 },2560 sendStats:function(){2561 if(SD_UTIL.isSendStatsReady()) {}2562 else {setTimeout(SD_UTIL.sendStats, 250);return;}2563 var params = '';2564 if(SD_UTIL.isPerfTimingAvail()) {2565 for(var k in window.performance.timing) {2566 prs.rt(("wpt_"+k), window.performance.timing[k]);2567 }2568 }2569 var prs2 = _.sortBy(prs, function(val) {2570 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1]*1.0;2571 });2572 for( var i = 0;i < prs2.length;i++){2573 params += "data=" + prs2[i].toString() + "&";2574 }2575 params += "key=" + SDM.pageTransKey + "&";2576 params += "pagetype=" + SDM.pageType;2577 },2578 printStats:function() {2579 var newprs = _.sortBy(prs, function(val) {2580 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2581 });2582 for( var i = 0;i < newprs.length;i++){2583 var dParts = newprs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g);2584 DBG.out(1, dParts[1].split(':')[1] + ',' + dParts[0].split(':')[1] + ',');2585 }2586 },2587 sendPageLoadStats:function() {2588 var params = '';2589 if (window.performance && window.performance.timing) {2590 if (window.performance.timing.loadEventEnd > 0) {2591 params = SD_UTIL.getArtSpdStats();2592 for(var k in window.performance.timing) {2593 params += "&" + k + "=" + window.performance.timing[k];2594 }2595 var url = SDM.pru+"/pageReport?"+params;2596 $('body').append('<img style="display:none" src="' + url + '">');2597 }2598 else {2599 setTimeout(SD_UTIL.sendPageLoadStats, 100);2600 }2601 }2602 else {2603 params = SD_UTIL.getArtSpdStats();2604 params += "&loadEventEnd=" + new Date().getTime();2605 var url = SDM.pru+"/pageReport?"+params;2606 $('body').append('<img style="display:none" src="' + url + '">');2607 }2608 },2609 getArtSpdStats:function(){2610 var params,lbl,timer;2611 params = "cpc=SD";2612 for( var i = 0;i < prs.length;i++){2613 lbl=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[0].split(':')[1];2614 if (lbl.indexOf("wpt_") == -1) {2615 timer=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2616 params += "&" + lbl + "=" + timer;2617 }2618 }2619 params += "&key=" + encodeURIComponent(SDM.pageTransKey);2620 params += "&pagetype=" + SDM.pageType;2621 params += "&sds=" + SDM.sds;2622 params += "&tid=" + SDM.tid;2623 if(SDM.tm.ahm != undefined)params += "&ahm=" + SDM.tm.ahm;2624 if(SDM.tm.chm != undefined)params += "&chm=" + SDM.tm.chm;2625 if (document.location.href) {2626 params += "&href=" + encodeURIComponent(document.location.href);2627 }2628 if (document.documentElement.clientWidth &&2629 document.documentElement.clientHeight) { 2630 params += "&winHeight=" + document.documentElement.clientHeight;2631 params += "&winWidth=" + document.documentElement.clientWidth;2632 }2633 params += "&domCount=" + document.getElementsByTagName("*").length;2634 return params;2635 },2636 getProdColor: function(){2637 return (SDM.prodColor==""?"sci_dir":SDM.prodColor);2638 },2639 getIFrameHeight: function(ifr) {2640 var ifrDoc=ifr.contentWindow||ifr.contentDocument||ifr.document;2641 if(ifrDoc.document!=undefined) ifrDoc=ifrDoc.document;2642 return $(ifrDoc.body).height();2643 },2644 resizeIFrame: function(iframeBox, iframeHeight) {2645 $('#' + iframeBox + ' iframe').height(iframeHeight);2646 }2647}2648// Lazy Loader2649$.fn.lazyLoadImages = function(opts) {2650 var cfg = {2651 imgSel: 'img',2652 preLoadLine: 102653 };2654 var lastScrollTop=0;2655 function scrollAction() {2656 var bottom = $(window).height() + $('#centerPane').scrollTop();2657 var totalCount=$(cfg.imgSel).size();2658 var loopBool = true;2659 var st=$('#centerPane').scrollTop();2660 if (st > lastScrollTop){2661 var scrollDown=true;2662 } else {2663 var scrollUp=true;2664 }2665 for(i=0;i<totalCount && loopBool==true ;i++){2666 var obj = $(cfg.imgSel)[i];2667 if( Math.abs($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerInner').top+$(obj).height()) < 2668 $(window).height() + cfg.preLoadLine2669 || Math.abs($('#centerPane').scrollTop() - $(obj).positionA('#centerInner').top) < $(window).height() + cfg.preLoadLine) {2670 var imgObj = $(obj);2671 if(imgObj.attr('data-loaded')!='true' ) {2672 var dataGabsImgEID = imgObj.attr('data-gabsEID');2673 var dataFullImgEID = imgObj.attr('data-fullEID');2674 var dataThumbImgEID = imgObj.attr('data-thumbEID');2675 var dataInlImgEid = imgObj.attr('data-inlimgeid');2676 var dataInlImg = imgObj.attr('data-inlimg');2677 var dataPubLogo = imgObj.attr('data-publogo');2678 var dataDefaultLogo = imgObj.attr('data-defaultlogo');2679 if (dataGabsImgEID != undefined && dataGabsImgEID != '' && SDM.entitled) {2680 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-gabsEID')).attr('data-loaded', 'true');2681 }else if (SDM.fullSize==true && dataFullImgEID != undefined && dataFullImgEID != '') {2682 if(SDM.entitled) {2683 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-fullEID')).attr('data-loaded', 'true');2684 if(imgObj.attr('data-fullwidth')<580 || imgObj.attr('data-fullwidth')>800){2685 $(obj).css('height', $(obj).attr('data-fullheight')).css('width', $(obj).attr('data-fullwidth'));2686 } 2687 } else {2688 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true'); 2689 }2690 } else if (dataThumbImgEID != undefined && dataThumbImgEID != '') {2691 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true');2692 $(obj).css('height', $(obj).attr('data-thumbheight')).css('width', $(obj).attr('data-thumbwidth'));2693 } else if (dataInlImgEid != undefined && dataInlImgEid != '') {2694 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-inlimgeid')).attr('data-loaded', 'true');2695 if(imgObj.closest('.formula')[0] && imgObj.width()>=595){2696 imgObj.closest('.formula').find('.mathmlsrc').addClass('scrollOn');2697 }2698 } else if (dataDefaultLogo != undefined && dataDefaultLogo != '') {2699 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-defaultlogo')).attr('data-loaded', 'true');2700 } else if (dataPubLogo != undefined && dataPubLogo != '') {2701 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-publogo')).attr('data-loaded', 'true');2702 } else if (dataInlImg != undefined && dataInlImg != '') {2703 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-inlimg')).attr('data-loaded', 'true');2704 }2705 }2706 }2707 else {2708 if($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerInner').top+$(obj).height() < 2709 $(window).height() + cfg.preLoadLine && scrollDown){ 2710 loopBool=false;2711 }2712 if($('#centerPane').scrollTop() - $(obj).positionA('#centerInner').top < $(window).height() + cfg.preLoadLine && scrollUp){2713 loopBool=false;2714 }2715 }2716 }2717 lastScrollTop=$('#centerPane').scrollTop();2718 } //scroll2719 return this.each(function() {2720 if(opts) {2721 $.extend(cfg, opts);2722 }2723 scrollAction(); // run it once for any images that are currently on the screen2724 var lazyScroll = _.debounce(scrollAction, 300);2725 $(this).scroll( lazyScroll );2726 }) //return2727};2728$.fn.lazyLoadOutlineImages = function(opts) {2729 var cfg = {2730 imgSel: 'img',2731 preLoadLine: 2002732 };2733 function lazyDisplay() {2734 var cnt = 0;2735 var myTop = 0;2736 var myHeight = 0;2737 var myWidth = 0;2738 var thumbHeight = 0;2739 $(cfg.imgSel).each(function() {2740 var outlineTop = Math.abs($('#outline').scrollTop());2741 var outlineBottom = Math.abs(outlineTop + $('#outline').height());2742 var outlineHeight = $('#outline').height();2743 var windowHeight = Math.abs($(window).height());2744 if (cnt == 0) {2745 myTop = Math.abs($(this).position().top);2746 }2747 else {2748 myTop += (myHeight * 1); // add last height to position2749 }2750 myHeight = Math.abs($(this).height());2751 thumbHeight = $(this).attr('data-thumbheight');2752 if (thumbHeight == undefined) {2753 thumbHeight = 0;2754 }2755 if (thumbHeight > 0 && thumbHeight < myHeight) {2756 myHeight = thumbHeight;2757 }2758 myWidth = Math.abs($(this).width());2759 var myDims = myTop * 1 + myHeight * 1;2760 if( Math.abs(myDims - outlineTop) < Math.abs(outlineBottom + cfg.preLoadLine) 2761 || Math.abs(outlineTop - myTop) < Math.abs(outlineHeight + cfg.preLoadLine)) {2762 var imgObj = $(this);2763 if(imgObj.attr('data-loaded')!='true' ) {2764 if (imgObj.attr('data-smlsrc') != undefined) {2765 imgObj.attr('src', imgObj.attr('data-smlsrc')).attr('data-loaded', 'true');2766 } else if (imgObj.attr('data-mmlEID') != undefined) {2767 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-mmlEID')).attr('data-loaded', 'true');2768 } 2769 imgObj.addClass("displayImg");2770 } 2771 $(this).parent().parent().css('height', '').css('width', '');2772 } 2773 cnt++;2774 })2775 } //scroll2776 return this.each(function() {2777 if(opts) {2778 $.extend(cfg, opts);2779 }2780 2781 lazyDisplay(); // run it once to show images that are currently on page2782 var lazyScroll = _.debounce(lazyDisplay, 300);2783 $(this).scroll( lazyScroll );2784 }) //return2785};2786$.fn.lazyLoad = function( cfg ){2787 // Internal function used to implement `_.throttle` and `_.debounce`.2788 var limit = function(func, wait, debounce) {2789 var timeout;2790 return function() {2791 var context = this, args = arguments;2792 var throttler = function() {2793 timeout = null;2794 func.apply(context, args);2795 };2796 if (debounce) clearTimeout(timeout);2797 if (debounce || !timeout) timeout = setTimeout(throttler, wait);2798 };2799 };2800 var plugin = {2801 buffer: cfg.buffer?cfg.buffer:50, // 50 pixels by default2802 batchSize: cfg.batchSize?cfg.batchSize:1, // 1 is the default batch size.2803 scrollSrc: cfg.scrollSrc?cfg.scrollSrc:'#centerPane',2804 callback: cfg.intoView?cfg.intoView:function(obj,idx){},2805 selector: '.refPlaceHolder',2806 screenTop: $(window).scrollTop(),2807 screenHeight:$(window).height(),2808 debounce: function(func, wait) {2809 return limit(func, wait, true);2810 },2811 calculateView: function() {2812 //pagination get all needs this2813 if(refResolveEnabled==false) {return;}2814 2815 if( plugin.applyPatch() ) {2816 plugin.buffer += 500;2817 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2818 }2819 else{2820 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2821 }2822 var screenBot = plugin.screenTop + $(window).height() + plugin.buffer;2823 var batch = [];2824 $refs = $(plugin.selector).not(function() {2825 return $(this).attr('data-sr')=='Y';2826 });2827 $refs.each(function() {2828 var tmpTop = $(this).position().top;2829 if( plugin.applyPatch() ) {2830 tmpTop = this.offsetTop;2831 }2832 if( tmpTop > plugin.screenTop && tmpTop < screenBot ) { 2833 $(this).attr('data-sr', 'Y'); 2834 batch.push( this ); 2835 if( plugin.batchSize == 1 ){ 2836 plugin.callback( batch );2837 batch = [];2838 }2839 else{ 2840 if( batch.length == plugin.batchSize ){2841 plugin.callback( batch );2842 batch = [];2843 }2844 }2845 }2846 else {2847 $(this).attr('data-sr', 'N'); 2848 } 2849 }); 2850 if( batch ){ plugin.callback( batch ); } // run any remainder in batch2851 },2852 applyPatch:function() {2853 return ($.browser.msie && $.browser.version < 9)2854 }2855 }2856 var lazyResize = plugin.debounce(plugin.calculateView,300);2857 var lazyScroll = plugin.debounce(plugin.calculateView, 300);2858 2859 $(window).resize( lazyResize );2860 $(plugin.scrollSrc).scroll( lazyScroll );2861 plugin.calculateView();2862 return plugin;2863} 2864// end of Lazy Loader2865// small enhancement2866// this method will be called by gadget services to get2867// encrypted cookie from web2868function getEuid() {2869 return SDM.euidCookieObject; 2870}2871function isNotNumber(o) {2872 if (o == -1) {2873 return true;2874 }2875 return isNaN (o-0);2876}2877function getNumber(str) {2878 if(!str) {2879 return -1;2880 }2881 var i=0;2882 while(i < str.length) {2883 var charat = str.charAt(i);2884 if(!isNotNumber(charat)) {2885 if(charat != "0") {2886 return str.substring(i);2887 }2888 }2889 i++;2890 }2891}2892//Reference resolution2893var ajaxRefResol;2894var ajaxCitedByUpdate;2895function updateCitedByCounts(citedByCounts,isHoover,start,count) {2896 citedByCounts = citedByCounts.substring(0,citedByCounts.length-1);2897 var updateCitedUrl = SDM.ep.updatedCitedBy + citedByCounts;2898 ajaxCitedByUpdate = new $.ajax({2899 url: updateCitedUrl,2900 type: 'GET',2901 async : isHoover,2902 dataType : 'text',2903 error: function() {2904 $(".citedBy_").each(function(){2905 $(this).html("");2906 });2907 },2908 success: function(res) {2909 var citedBy = decodeURIComponent(res);2910 if (citedBy != null) {2911 this.$citedByDiv = $('<div></div>')2912 .hide()2913 .append($(citedBy)2914 );2915 $(".citedBy_").each(function(){2916 if(myXabsCounts[this.id]) {2917 if( this.innerHTML.match('Cited By in Scopus') == null) {2918 $(this).html( myXabsCounts[this.id]);2919 $(this).attr ("data-citeres", "Y");2920 }2921 } else {2922 $(this).html("");2923 $(this).attr ("data-citeres", "Y");2924 }2925 });2926 }2927 }2928 }); 2929}2930String.prototype.substringBetween = function (string1, string2) {2931 if ((this.indexOf(string1, 0) == -1) || (this.indexOf(string2, this.indexOf(string1, 0)) == -1)) {2932 return (-1);2933 } else {2934 return this.substring((this.indexOf(string1, 0) + string1.length), (this.indexOf(string2, this.indexOf(string1, 0))));2935 }2936};2937var lazyRefs = null;2938function refResolve() {2939 lazyRefs = $(".refPlaceHolder").lazyLoad({2940 batchSize:50,2941 intoView:function(objs,idx){2942 if( objs ){2943 if( objs[0] ){2944 var start = $(objs[0]).attr("id").substring(8);2945 if(!start) {2946 start = 1;2947 }2948 var count = objs.length;2949 if (idx) {2950 resolveRefs(idx,1);2951 }2952 else {2953 resolveRefs( start, count );2954 }2955 }2956 }2957 }2958 });2959}2960function resolveRefs( start, count ){2961 var url = SDM.ep.refResolvePath + "&_refRangeStart="+start+"&_refRangeCount="+count;2962 var isHoover = true;2963 if (count == 1) {2964 isHoover = false;2965 }2966 ajaxRefResol = new $.ajax({2967 url: url,2968 type: 'GET',2969 async : isHoover,2970 dataType : 'text',2971 error: function() {2972 $(".refPlaceHolder").each(function(){2973 $(this).html(' <span style="color:red;"> [SD-008]<\/span>');2974 });2975 return;2976 },2977 success: function(res) {2978 var refMap = decodeURIComponent(res);2979 var citedBySCEids = refMap.substringBetween("#","^");2980 var tmp = "#"+citedBySCEids+"^";2981 refMap = refMap.replace(tmp,"");2982 if (refMap != null) {2983 this.$OuterDiv = $('<div></div>').hide().append($(refMap));2984 $(".refPlaceHolder").each(function(){2985 if (myMap[this.id.toLowerCase()]['refHtml'] || myMap[this.id.toLowerCase()]['refHtml'] != "") {2986 if(this.innerHTML.match('/science?') == null){2987 $(this).html(myMap[this.id.toLowerCase()]['refHtml'] );2988 $(this).attr ("data-refres", "Y");2989 }2990 // Add abstarct url to the <li> tag2991 if (myMap[this.id.toLowerCase()]['absUrl']) {2992 $(this).attr ("data-absurl", myMap[this.id.toLowerCase()]['absUrl']);2993 }2994 }2995 else {2996 $(this).html("");2997 $(this).attr ("data-refres", "Y");2998 }2999 });3000 // update Cited by counts3001 if(citedBySCEids != null && citedBySCEids != ""){3002 updateCitedByCounts(citedBySCEids,isHoover,start,count);3003 }3004 }3005 }3006 }); 3007}3008//Reference resolution End3009var EbookTOC = {3010 eBookTOCTimeout: 1000,3011 currentLink: null,3012 tocObj: null,3013 init: function() {3014 var eBookTOCURL = $('div.publicationHead div.title a').attr("href").replace('book', 'toc');3015 3016 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {3017 var tocStr = sessionStorage.getItem('bk.toc');3018 if(tocStr) {3019 EbookTOC.tocObj = $.parseJSON(tocStr);3020 if(EbookTOC.tocObj.eBookCID==SDM.pm.cid) {3021 DBG.out(1, 'Found bk.toc using...');3022 }3023 else {3024 EbookTOC.tocObj=null;3025 sessionStorage.removeItem('bk.toc');3026 DBG.out(1, 'Found different bk.toc removing...');3027 }3028 }3029 }3030 3031 if(EbookTOC.tocObj==null) {3032 $.getJSON(eBookTOCURL, function(res) {3033 if (res){3034 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {3035 sessionStorage.setItem('bk.toc', JSON.stringify(res));3036 DBG.out(1, 'Storing bk.toc');3037 }3038 }3039 EbookTOC.load(res);3040 });3041 }3042 else {3043 EbookTOC.load(EbookTOC.tocObj);3044 }3045 $('#leftPane #srcOutline li div.so a').ellipsis();3046 }, //init3047 load:function(res) {3048 var $bookToc = EbookTOC.buildToc(res);3049 $('#leftPane').prepend('<ul id="lpTabs">'3050 + '<li class="leftTab tab" tabindex="0">Book contents</li>'3051 + '<li class="rightTab tab" tabindex="0">Chapter contents</li>'3052 + '</ul>');3053 $('#lpTabs .leftTab').click(function() {3054 if($('#srcOutline').css('display')!='none') return;3055 EbookTOC.showSourceTab(this);3056 SD_UTIL.sendUserKeyEvent('sourceTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3057 });3058 $('#lpTabs .rightTab').click(function() {3059 if($('#srcOutline').css('display')=='none') return;3060 EbookTOC.showItemTab(this);3061 SD_UTIL.sendUserKeyEvent('itemTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3062 });3063 $('#outline').prepend($bookToc);3064 $('#outline, #leftPane, #leftPaneInner').addClass('book');3065 //Initially set all parent nodes to collapsed.3066 EbookTOC.showPath2Item(SDM.pm.pii);3067 $('.activeChapter >a').attr('href', "");3068 if(SDM.outlineTab=='I') {3069 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);3070 }3071 else {3072 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);3073 $('#outline').scrollToTopic({selTopic:'div.activeChapter'}); 3074 }3075 $('.leftPaneToggle').unbind('click').bind('click',function(e){3076 e.preventDefault();3077 e.stopPropagation();3078 EbookTOC.nodeClick($(this)[0]);3079 });3080 }, //load3081 showSourceTab:function(e) {3082 $(e).parent().children('.tab').removeClass('activeTab');3083 $(e).addClass('activeTab');3084 $('.outlineMsg').hide();3085 $('#srcOutline').show();3086 $('.activeChapter').parent().append($('#itemOutline')[0]);...
sd_131_5R1.js
Source:sd_131_5R1.js
...1404 if(SDM.outlineTab=='I') {1405 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);1406 }1407 else {1408 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);1409 }1410 }1411 }1412 else {1413 Outline.getJson ();1414 tocCounter++;1415 trd = trd*SDM.pm.toc.retryFactor;1416 tocIntrvl = setInterval(tocCheck, trd);1417 }1418 }1419 ///////////1420 var tocIntrvl = setInterval(tocCheck, trd);1421 }1422 }1423 else {1424 $('#centerInner').outline( $('#outline'), page.opts );1425 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());1426 if($('#outline').width()>240){1427 $('#outline > ul,#articleLeftAd').css('width', $('#outline').width()-$.scrollBarWidth());1428 }else{1429 $('#outline > ul,#articleLeftAd').css('width', 240);1430 }1431 $('#outline').attr('data-st', 0);1432 }1433 $('#outline').attr('data-st', 0);1434 CollapsibleTextbox.init();1435 page.delayedScrollHandler = _.debounce( page.viewHandler, 300 );1436 $( "#centerPane" ).bind( "scroll.viewHandler", page.delayedScrollHandler );1437 $("#page-area").on("click", ".intra_ref,.authorVitaeLink,.figureLink,.authorName, .viewWS", {z:'centerPane'}, rightSidePane.findTargetElement);1438 if (Fragment.isAvail())1439 $("#outline").on("click", ".tocLink", {z:'leftPane'}, Outline.findTargetFragment);1440 else 1441 $("#outline").on("click", ".tocLink", Outline.moveToSection);1442 1443 $("#centerPane").on('click', '.btnHolder', function(e){page.toggleOptions(e,this);} );1444 $('a.articleOptions').toggle(1445 function() { $('div.articleOptions').css('display', 'block');},1446 function() { $('div.articleOptions').css('display', 'none');}1447 );1448 $('#optImgToggle').click(function() {page.toggleImages('toolbar');});1449 $('#leftPane').height('');1450 page.lazyLoadInit();1451 page.showFullTableLink();1452 $('div.downloadCsv').bind("click", TableDownload.processRequest);1453 $('a.ppt').bind("click", FigureDownload.processRequest);1454 if(SDM.pm.contentType == "BK") EbookTOC.init();1455 if(SDM.isMRWMODArticle && SDM.ldrAvail) {$('.outlineMsg').hide();mrwLeftPane.init();}1456 EComponent.init();1457 CanonicalLink.init();1458 CanonicalHomeLink.init();1459 page.searchWithinInit();1460 if(!SDM.crawlerAvail) { refResolve(); }1461 if(SDM.displayGadgets) {1462 if (SDM.sciverseGadgetDetailsID.length > 0) {1463 GadgetUtil.loadGadgetsParallel();1464 } else {1465 GadgetUtil.loadGadgets();1466 }1467 }1468 Outline.hoverOverOff();1469 $('#centerPane')[0].tabIndex = -1;1470 $('#centerPane')[0].focus();1471 if (typeof(SDM.fab) != 'undefined' && SDM.pm.itemWeight == 'FULL-TEXT') { EReader.fabRequest(); }1472 ready=true; 1473 } //addJS1474 } //page1475 if($('#frag_1').length || !Fragment.isAvail()) {1476 page.addJS();1477 }1478 else {1479 var if1 = setInterval(function() {1480 if($('#frag_1').length) {1481 clearInterval(if1);1482 page.addJS();1483 }1484 else {1485 //nothing wait for it1486 }1487 }, 250);1488 }1489 return page;1490 }();1491} //initializeArticlePage1492function checkSearchWithin() {1493 if($('#searchWithin input[type=text]').prop('value')=='') {1494 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1495 }1496 else {1497 $('#searchWithin input[type=text]').parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1498 }1499}1500$.fn.outline = function(oObj, opts, tocJson) {1501 var cfg = {1502 empty: false,1503 selector: '.outlineItem',1504 graphicsToggler: true,1505 searchWithin: false,1506 focusEffect: true,1507 focus: {}1508 };1509 Outline.oObj = oObj;1510 return this.each(function() {1511 if(opts) {1512 $.extend(true, cfg, opts);1513 }1514 oObj.append('<ul id="itemOutline"></ul>');1515 var $iOutline = $('#itemOutline');1516 if(cfg.graphicsToggler) {1517 $('#outline.js').css('top', 32);1518 if(SDM.pm.contentType=="BK") {1519 $('#outline.book').css('top', 44);1520 }1521 if(SDM.isMRWMODArticle) {1522 $('#outline.book').css('top', 10);1523 }1524 1525 oObj.parent().prepend('<div id="olGraphCbBox">'1526 + '<label><input id="outlineGraphicsCheckBox" type="checkBox" checked="true">Show thumbnails in outline</label>'1527 + '</div>');1528 }1529 if(cfg.searchWithin) {1530 oObj.parent().prepend('<div id="searchWithin" class="textEntry" role="Search" aria-label="Book">'1531 + '<form name="searchWithinForm" action="javascript:checkSearchWithin();ArticlePage.searchWithinSubmit();">'1532 + '<input type="text" value="Search this book" title="Search this book" size="26" maxlength="450"></input></form>'1533 + '<button class="clearWithin" title="Clear book search"><div class="clearXHide"></div></button>'1534 + '<button class="submit" title="Search this book"></button>'1535 + '</div>');1536 $('#searchWithin button.clearWithin').click(function() {1537 $('#searchWithin input[type=text]').prop('value', 'Search this book');1538 $(this).children().addClass('clearXHide').removeClass('clearXShow');1539 SearchWithin.clear();1540 });1541 $('#leftPane button.submit').click(function() {ArticlePage.searchWithinSubmit();});1542 $('#searchWithin input[type=text]').focusin(function() {1543 if($(this).prop('value')=='Search this book') {1544 $(this).prop('value', '');1545 }1546 });1547 $('#searchWithin input[type=text]').focusout(function() {1548 if($(this).prop('value')=='') {1549 $(this).prop('value', 'Search this book');1550 $(this).parent().siblings('.clearWithin').children().addClass('clearXHide').removeClass('clearXShow');1551 }1552 else {1553 $(this).parent().siblings('.clearWithin').children().removeClass('clearXHide').addClass('clearXShow');1554 }1555 });1556 }1557 var level = "";1558 var isGraphics = false;1559 prs.rt('outlineLoop_start');1560 if (SDM.tocCacheAvail) {1561 if(typeof tocJson == 'undefined') {1562 //miss and retries are done1563 Outline.buildOutlineUnavailable(cfg);1564 Outline.postBuild(cfg);1565 }1566 else {1567 // build outline from JSON1568 var outlineObj;1569 try {1570 outlineObj = $.parseJSON(tocJson);1571 Outline.buildOutlineJsonSide(cfg, outlineObj);1572 }1573 catch(e) {1574 SDM.tocCacheAvail = false;1575 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid + "/ftp");1576 if(Fragment.isAvail()) {1577 //Pull in the rest of the article and build it clientside1578 Fragment.get('all', null, {successCb: Outline.buildOutlineClientSide,1579 successCbArg: cfg,1580 failureCb: Outline.buildOutlineUnavailable,1581 failureCbArg: cfg1582 });1583 return;1584 }1585 else {1586 Outline.buildOutlineClientSide(cfg);1587 }1588 }1589 }1590 }1591 else {1592 // Build outline from center pane contents1593 Outline.buildOutlineClientSide(cfg);1594 }1595 }); //return1596 if(mathRenderer.opt.renderOn)mathRenderer.handleRerender($('#rightPane'));1597} //.outline1598var CrossMark = {1599 cssUrl:'',1600 init:function() {1601 $("#open-crossmark").delegate("#crossmark-icon", "click",function(event){1602 $.get(SDM.crossMarkURL +'/'+ SDM.pm.pii + '/article/rightPane/displayPopup/' + SDM.keOriginContentFamily +'/'+ SDM.issn_or_isbn);1603 });1604 if($('#open-crossmark')[0]){1605 LazyLoad.js([SDM.crossMarkLib], function() {1606 $("#open-crossmark").css({'display':'inline-block'}).find('img').css('padding-top','10px');1607 $('#open-crossmark').click(function(){$(".ui-dialog-titlebar").css('top','0px').css('width','520px');});1608 });1609 }1610 $('#open-crossmark').bind('mouseover',function(){setTimeout(CrossMark.setCss,1000);});1611 $('#open-crossmark').bind('mouseout',function(){setTimeout(CrossMark.removeCss,1000);});1612 $('body').bind('mousemove',CrossMark.removeCss);1613 },1614 setCss:function(){1615 if(!$('link[href*="crossmark_widget.css"]')[0]){1616 if(document.createStyleSheet){1617 document.createStyleSheet(CrossMark.cssUrl);1618 }else{1619 $('head').append('<link href="'+CrossMark.cssUrl+'" rel="stylesheet" type="text/css"/>');1620 } 1621 }else{1622 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1623 }1624 },1625 removeCss:function(){1626 if($('link[href*="crossmark_widget.css"]')[0] && !$('.ui-widget-overlay').is(':visible') && !$('#crossmark-tooltip-130').is(':visible')){1627 CrossMark.cssUrl=$('link[href*="crossmark_widget.css"]').attr('href');1628 $('link[href*="crossmark_widget.css"]').remove();1629 }1630 }1631}1632var SearchWithin = {1633 init:function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1634 var val = SearchWithin.loadSearch();1635 if(val.cid==SDM.pm.cid && val.str) {1636 var swObj = SearchWithin.loadResult();1637 if(swObj) {1638 if(swObj && swObj.cid==SDM.pm.cid) {1639 if(swObj.status!=0) {1640 SearchWithin.clear();1641 }1642 else {1643 SearchWithin.processResult(swObj, bkOutlineSelStr, selStr, idConvert);1644 }1645 }1646 else {1647 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1648 }1649 }1650 else {1651 SearchWithin.reqResult(bkOutlineSelStr, selStr, idConvert, funcNoResult);1652 }1653 }1654 },1655 loadSearch:function() {1656 var flag=true;1657 var searchStr='';1658 var cidStr = '';1659 var beg = document.cookie.indexOf('SEARCHWITHIN=');1660 if(beg!=-1) {1661 beg = beg + 'SEARCHWITHIN='.length;1662 var end = document.cookie.indexOf(';', beg);1663 var cookieStr = document.cookie.slice(beg, end);1664 flag = cookieStr.split('SW()')[0];1665 searchStr = cookieStr.split('SW()')[1];1666 cidStr = cookieStr.split('SW()')[2];1667 }1668 else {1669 return {f:'',str:'',cid:''};1670 }1671 return {f:flag,str:searchStr,cid:cidStr}; //[searchStr, cidStr];1672 },1673 saveSearch: function(f, sStr) {1674 var site = document.location.pathname.split('/article/pii/')[0];1675 document.cookie='SEARCHWITHIN' + '=' + f + 'SW()' + sStr + 'SW()' + SDM.pm.cid + ';;path=' + site;1676 },1677 reqResult: function(bkOutlineSelStr, selStr, idConvert, funcNoResult) {1678 $.get('/science/searchwithin', function(res) {1679 var result;1680 try {1681 result = $.parseJSON(res);1682 }1683 catch(e) {1684 DBG.out(1, 'SearchWithin failed');1685 return;1686 }1687 if(result.status==1 || typeof result.hitTerms=="undefined") {1688 funcNoResult();1689 }1690 else {1691 if(result.status==0) {1692 SearchWithin.processResult(result, bkOutlineSelStr, selStr, idConvert);1693 $('#outline').scrollTop($('#outline a.swh:first').position().top);1694 }1695 }1696 });1697 },1698 processResult: function(result, bkOutlineSelStr, selStr, idConvert) {1699 var len = result.piis.length;1700 for(var i=0; i<len; i++) {1701 if(SDM.pm.pii==result.piis[i]) {1702 SearchWithin.hlCenterPane(result.hitTerms.toString().replace(/,/g, ' '), selStr, idConvert);1703 }1704 }1705 SearchWithin.hlOutline(result.piis, bkOutlineSelStr);1706 SearchWithin.saveResult(result);1707 },1708 saveResult: function(rslt) {1709 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {1710 sessionStorage.setItem('bk.sw', JSON.stringify(rslt));1711 }1712 },1713 loadResult: function() {1714 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1715 var sw = sessionStorage.getItem('bk.sw');1716 if(sw) {1717 var swObj = $.parseJSON(sw);1718 if(swObj.cid==SDM.pm.cid) {1719 return swObj;1720 }1721 else {1722 SearchWithin.clearResult();1723 return null;1724 }1725 }1726 else {1727 SearchWithin.clearResult();1728 return null;1729 }1730 }1731 },1732 clearResult: function() {1733 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {1734 sessionStorage.removeItem('bk.sw');1735 }1736 },1737 clear:function(keepMsg) {1738 $('.swh').removeClass('swh');1739 $('.searchword').removeClass('searchword');1740 var site = document.location.pathname.split('/article/pii/')[0];1741 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;';1742 document.cookie = 'SEARCHWITHIN' + '=; expires=Fri, 01-Jan-70 01:02:03 UTC;path=' + site;1743 if(typeof keepMsg=="undefined" && typeof ArticlePage!="undefined")1744 ArticlePage.searchWithinErrorMsgClear();1745 }, //searchWithin.clear1746 hlOutline:function(piis, selStr) {1747 var len = piis.length;1748 for(var i=0; i<len; i++) {1749 $(selStr).each(function() {1750 if($(this).attr('data-pii')==piis[i]) {1751 DBG.out(1, 'Highlighting Book TOC item ' + $(this).text());1752 if($(this).attr('data-pii')!=SDM.pm.pii) {1753 $(this).find('div a').addClass('swh');1754 }1755 EbookTOC.getPath2Item(piis[i]).each(function() {1756 $(this).children('a').addClass('swh');1757 });1758 }1759 });1760 }1761 },1762 hlCenterPane:function(hitTerms, selStr, idConvert) {1763 searchStr = hitTerms;1764 //center pane highlighting1765 searchhi.process($('#centerPane')[0], searchStr);1766 //outline highlighting1767 var objs = $('.searchword').each(function() {1768 $(this).attr('data-posy', $(this).position().top);1769 });1770 $(selStr).each(function() {1771 $(this).attr('data-posy', $(this).position().top);1772 objs.push(this);1773 });1774 objs = _.sortBy(objs, function(val) {1775 return $(val).attr('data-posy')*1.0;1776 });1777 objs = _.filter(objs, function(val) {1778 return $(val).parents('.textboxBody').length==0;1779 });1780 objs = objs.reverse();1781 var len = objs.length;1782 for(i=0; i<len; i++) {1783 var $c = $(objs[i]);1784 if($c.hasClass('searchword')) {1785 var ii=i;1786 while($(objs[ii]).length && $(objs[ii]).hasClass('searchword')) {ii++;}1787 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1788 var foundType="h4";1789 if($(objs[ii]).is("h4")) {1790 foundType = "h4";1791 }1792 if($(objs[ii]).is("h3")) {1793 foundType = "h3";1794 }1795 if($(objs[ii]).is("h2")) {1796 foundType = "h2";1797 done=true;1798 }1799 var done=false;1800 while(!done && $(objs[ii]).length) {1801 if(foundType=="h4") {1802 if($(objs[ii]).is("h4")) {}1803 if($(objs[ii]).is("h3")) {1804 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1805 }1806 if($(objs[ii]).is("h2")) {1807 done=true;1808 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1809 }1810 }1811 else if(foundType=="h3") {1812 if($(objs[ii]).is("h4")) {}1813 if($(objs[ii]).is("h3")) {}1814 if($(objs[ii]).is("h2")) {1815 $('#' + idConvert($(objs[ii]).attr('id'))).addClass('swh');1816 done=true;1817 }1818 }1819 if($(objs[ii]).is("h2")) {1820 done=true;1821 }1822 ii++;1823 }1824 }1825 }1826 }//searchWithin.highlight1827} //SearchWithin1828var ArticleOutline={1829outline : "",1830init:function(){1831//var toc = $.parseJSON(ArticleOutline.outline);1832 if(typeof SDM.tocJson !='undefined')1833 {1834 var obj = $.parseJSON(SDM.tocJson);1835 for (var i=0;i<=obj.TOC.length;i++) {1836 ArticleOutline.buildSectionItem(obj.TOC[i]);1837 }1838 }1839},1840buildSectionItem:function(sec){1841//var $section;1842var html = '';1843var keyE = '"displayTOCSection", "article", "leftPane", '+SDM.keOriginContentFamily +'';1844//$section = $('<li class="" style="margin-right:16px;"></li>');1845 if(sec.sID != undefined){1846 html += '<div id="ol_'+sec.sID+'" class="io item h2sec"></div>';1847 //$section.append('<div id="ol_'+sec.sID+'" class="io item h2sec"></div>');1848 }1849 if(sec.sT != undefined){1850 html += '<a onclick="SD_UTIL.sendUserKeyEvent(\'displayTOCSection\', \'article\', \'leftPane\', '+SDM.keOriginContentFamily +'); return $(\'#centerPane\').moveTo(\''+ sec.sID +'\')" href=\'#'+sec.sID+'\' >'+sec.sT+'</a>';1851 }1852 1853 //$section.append($div);1854 return html;1855}1856}1857var Outline = {1858 onHover:false,1859 pendCloseTimer:null,1860 init:function() {1861 $('#leftPane').hover(1862 function() {1863 Outline.hoverOverOn();1864 if(!pgLayout.showLeftBar) {1865 clearTimeout(Outline.pendingCloseTimer);1866 }1867 }, 1868 function() { 1869 Outline.hoverOverOff();1870 if(!pgLayout.showLeftBar) {1871 Outline.pendingCloseTimer = setTimeout(Outline.sidebarClose, 1000);1872 }1873 } 1874 );1875 $('#leftCloseBar').click(function(e) {Outline.sidebarOpenClick(e)});1876 $('#leftOpenBar').click(function(e) {Outline.sidebarCloseClick(e)});1877 },1878 buildOutlineJsonSide:function(cfg, outlineObj) {1879 var $iOutline = $('#itemOutline');1880 if (outlineObj!=null && outlineObj.TOC != undefined && outlineObj.TOC.length>1) {1881 $(outlineObj.TOC).each(function(i, h2Sec) {1882 if(h2Sec.sT != undefined && h2Sec.sT.length>0){1883 var secTitle = h2Sec.sT;1884 secTitle = secTitle.replace (/'/g, "'"); 1885 if (SDM.pageType == 'article_full') { 1886 $iOutline.append(Outline.addItemSection(h2Sec.sID, secTitle, 'h2'));1887 } else if (SDM.pageType == 'article_abs') {1888 $iOutline.append(Outline.addItemOutline(h2Sec.sID, secTitle, 'h2'));1889 }1890 }1891 if(h2Sec.faID != undefined && h2Sec.faID.length > 0) {1892 $(h2Sec.faID).each(function(i, floatanc) {1893 if(floatanc.fT == 'fig'){1894 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1895 if(floatanc.fI.length>0){1896 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h2', floatanc.fIh));1897 }1898 }1899 else if(floatanc.fT == 'tbl'){1900 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h2'));1901 }1902 else if(floatanc.fT == 'ecomp'){1903 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h2'));1904 }1905 })1906 }1907 if (h2Sec.cT != undefined && h2Sec.cT.length > 0) {1908 $(h2Sec.cT).each(function(i, h3Sec) {1909 if(h3Sec.sT.length>0){1910 var secTitle = h3Sec.sT;1911 secTitle = secTitle.replace (/'/g, "'"); 1912 if (SDM.pageType == 'article_full') {1913 $iOutline.append(Outline.addItemSection(h3Sec.sID, secTitle, 'h3'));1914 }else if (SDM.pageType == 'article_abs'){1915 $iOutline.append(Outline.addItemOutline(h3Sec.sID, secTitle, 'h3'));1916 }1917 }1918 if(h3Sec.faID != undefined && h3Sec.faID.length > 0){1919 $(h3Sec.faID).each(function(i, floatanc){1920 if(floatanc.fT == 'fig'){1921 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1922 if (floatanc.fI.length>0){1923 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h3', floatanc.fIh));1924 }1925 }1926 else if(floatanc.fT == 'tbl'){1927 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h3'));1928 }1929 else if(floatanc.fT == 'ecomp'){1930 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h3'));1931 }1932 })1933 }1934 if(h3Sec.cT != undefined && h3Sec.cT.length > 0){1935 $(h3Sec.cT).each(function(i, h4Sec) {1936 if(h4Sec.sT.length>0){1937 var secTitle = h4Sec.sT;1938 secTitle = secTitle.replace (/'/g, "'"); 1939 if (SDM.pageType == 'article_full') {1940 $iOutline.append(Outline.addItemSection(h4Sec.sID, secTitle, 'h4'));1941 }else if (SDM.pageType == 'article_abs'){1942 $iOutline.append(Outline.addItemOutline(h4Sec.sID, secTitle, 'h4'));1943 }1944 }1945 if(h4Sec.faID != undefined && h4Sec.faID.length > 0){1946 $(h4Sec.faID).each(function(i, floatanc){1947 if(floatanc.fT == 'fig'){1948 var imageURL = SDM.imageUrlPrefix + outlineObj.EID + '-' + floatanc.fI;1949 $iOutline.append(Outline.addItemFig(floatanc.fID, floatanc.fL, imageURL, 'h4', floatanc.fIh));1950 }1951 else if(floatanc.fT == 'tbl'){1952 $iOutline.append(Outline.addItemTbl(floatanc.fID, floatanc.fL, 'h4'));1953 }1954 else if(floatanc.fT == 'ecomp'){1955 $iOutline.append(Outline.addItemMMC(floatanc.fID, floatanc.fL, floatanc.floatEXT, 'h4'));1956 }1957 })1958 }1959 })1960 }1961 })1962 }1963 })1964 $('#leftPane .outlineMsg').remove();1965 }1966 else {1967 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {1968 $('#outline').css('top', 0);1969 }1970 $('#outline .outlineMsg').html('This document does not have an outline.')1971 .show();1972 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();1973 }1974 Outline.postBuild(cfg);1975 },1976 buildOutlineClientSide:function(cfg) {1977 var level = "";1978 var $iOutline = $('#itemOutline');1979 if($(cfg.selector).length>0) {1980 $(cfg.selector).each(function() {1981 if($(this).parents('.textboxBody').length>0) {}1982 else {1983 if($(this).attr('id')==undefined) {1984 $(this).attr('id', 'bs_' + Math.floor(Math.random()*100000));1985 DBG.out(1, 'fixing id::' + $(this).attr('id') + '::' + $(this).text());1986 }1987 DBG.out(4, 'adding::' + $(this).text());1988 if($(this).is("h2")||$(this).is("h3")||$(this).is("h4")) {1989 level = $(this)[0].tagName;1990 level = level.toLowerCase();1991 var label = $(this).html();1992 var hasMml=$(this).find("#itemOutline .mathmlsrc"); 1993 if(hasMml) { 1994 $("#itemOutline .mathmlsrc").attr('onclick',''); 1995 }1996 if(label==undefined) label='';1997 if (SDM.pageType == 'article_full') {1998 $iOutline.append(Outline.addItemSection($(this).attr('id'), label, level));1999 }2000 else if (SDM.pageType == 'article_abs') {2001 //Note: In case of unentitled view we render the outline from a hidden div in center pane2002 $iOutline.append(Outline.addItemOutline($(this).attr('id'), label, level));2003 }2004 }2005 else {2006 if($(this).hasClass('table')==true) {2007 var label = $(this).attr('data-label');2008 if(label==undefined) label='';2009 $iOutline.append(Outline.addItemTbl($(this).attr('id'), label, level));2010 }2011 else if($(this).hasClass('figure')==true) {2012 var label = $(this).find(".label").html();2013 if(label==undefined) label='';2014 var image = SDM.imageUrlPrefix + $(this).find("dt img").attr('data-thumbEID');2015 var thumbHeight = $(this).find("dt img").attr('data-thumbheight');2016 if(!$(this).children('div').attr('id')){2017 $iOutline.append(Outline.addItemFig($(this).attr('id'), label, image, level, thumbHeight));2018 }2019 }2020 else if($(this).hasClass('ecomponent')==true) {2021 var label = $(this).attr('data-label');2022 if(label==undefined) label='';2023 var ext = $(this).attr('data-ext');2024 $iOutline.append(Outline.addItemMMC($(this).parent('dl').attr('id'), label, ext, level));2025 }2026 else {}2027 }2028 }2029 })2030 $('#leftPane .outlineMsg').remove();2031 }2032 else {2033 if(SDM.pm.contentType!='BK' && !SDM.isMRWMODArticle) {2034 $('#outline').css('top', 0);2035 }2036 $('#outline .outlineMsg').html('This document does not have an outline.')2037 .show();2038 if(mrwLeftPane.currentTab=='S' && SDM.isMRWMODArticle)$('#outline .outlineMsg').hide();2039 }2040 Outline.postBuild(cfg);2041 },2042 buildOutlineUnavailable:function(cfg) {2043 if(SDM.pm.contentType!='BK') {2044 $('#outline').css('top', 0);2045 }2046 $('#outline .outlineMsg').html('The outline for this document is currently unavailable.')2047 .show();2048 },2049 postBuild:function(cfg) {2050 var oObj = Outline.oObj;2051 prs.rt('outlineLoop_end');2052 oObj.append('<div id="articleLeftAd"></div>');2053 Outline.showLeftAd();2054 2055 //Setup the sync between rightPane scroll and outline highlight2056 if(cfg.focusEffect==true) {2057 oObj.syncTo(cfg);2058 }2059 2060 $('#outline > ul').show();2061 if(SDM.isMRWMODArticle && SDM.ldrAvail)$('#itemOutline').hide(); 2062 2063 if(SDM.outlineImgFence==true) {2064 if($('li div.fig, li div.tbl, li div.mmc').length > 0) {2065 if(SDM.outlineGraphics == true) {2066 $('#outlineGraphicsCheckBox').prop('checked', true);2067 }2068 else {2069 $('#outlineGraphicsCheckBox').prop('checked', false)2070 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2071 }2072 $('#outlineGraphicsCheckBox').change(function() {2073 Outline.toggleGraphics();2074 if($('#outlineGraphicsCheckBox').prop('checked')==true) {2075 SD_UTIL.sendUserKeyEvent('enableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2076 }2077 else {2078 SD_UTIL.sendUserKeyEvent('disableOutlineGraphics', 'article', 'leftPane', SDM.keOriginContentFamily);2079 }2080 });2081 }2082 else {2083 $('#outlineGraphicsCheckBox').prop('checked', false);2084 $('#olGraphCbBox label').hide();2085 }2086 }2087 else {2088 $('#olGraphCbBox').hide();2089 $('#outlineGraphicsCheckBox').prop('checked', false)2090 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2091 }2092 oObj.scroll();2093 },2094 itemAction: function() {2095 SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');2096 2097 },2098 addItemMMC: function(hashId, lbl, ext, hStr) {2099 var ecn = "olIconMMCDef";2100 if(ext=="pdf"){extCls="olIconMMCPdf"}2101 else if(ext=="avi"){ecn="olIconMMCMov"}2102 else if(ext=="csv"){ecn="olIconMMCCsv"}2103 else if(ext=="eps"){ecn="olIconMMCEps"}2104 else if(ext=="flv"){ecn="olIconMMCFlv"}2105 else if(ext=="gif"){ecn="olIconMMCImg"}2106 else if(ext=="jpg"){ecn="olIconMMCJpg"}2107 else if(ext=="kmz"){ecn="olIconMMCDef"}2108 else if(ext=="mml"){ecn="olIconMMCDef"}2109 else if(ext=="xls"){ecn="olIconMMCExcel"}2110 else if(ext=="ppt"){ecn="olIconMMCPpt"}2111 else if(ext=="doc"){ecn="olIconMMCWord"}2112 else if(ext=="mp3"){ecn="olIconMMCAud"}2113 else if(ext=="mpg"){ecn="olIconMMCMov"}2114 else if(ext=="mp4"){ecn="olIconMMCMpg4"}2115 else if(ext=="txt"){ecn="olIconMMCTxt"}2116 else if(ext=="png"){ecn="olIconMMCPng"}2117 else if(ext=="mov"){ecn="olIconMMCMov"}2118 else if(ext=="rtf"){ecn="olIconMMCRtf"}2119 else if(ext=="svg"){ecn="olIconMMCSvg"}2120 else if(ext=="tar"){ecn="olIconMMCDef"}2121 else if(ext=="tif"){ecn="olIconMMCDef"}2122 else if(ext=="zip"){ecn="olIconMMCZip"}2123 else {ecn = "olIconMMCDef";}2124 var html;2125 if(SDM.entitled==true){2126 html = "<li><div id='ol_" + hashId + "' class='tocLink io item " + hStr + "sec mmc'>"2127 + "<a class=\"tocLink olIcon " + ecn + "\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \"> <div class=\"olIcon " + ecn + "\"></div>"2128 + lbl + "</a></div></li>";2129 }2130 else{2131 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec mmc'>"2132 + "<a class=\"tocLink olIcon " + ecn + " cLink\" queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\> <div class=\"olIcon " + ecn + "\"></div>"2133 + lbl2134 + "</a></div></li>";2135 }2136 return html;2137 }, //Outline.addItemMMC2138addItemTbl: function(hashId, lbl, hStr) {2139 var html;2140 if(SDM.entitled==true){2141 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec tbl'>"2142 + "<a class=\"tocLink olIcon olIconTbl\" href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "'); \"><div class=\"olIcon olIconTbl\"></div>" 2143 + lbl + "</a></div></li>";2144 }2145 else{2146 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec tbl'>"2147 + "<a class=\"olIcon olIconTbl cLink\" queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\><div class=\"olIcon olIconTbl\"></div>" 2148 + lbl + "</a></div></li>";2149 }2150 return html;2151 }, //Outline.addOutlineItemTbl2152 addItemFig: function(hashId, lbl, img, hStr, thumbHeight) {2153 var html;2154 if(SDM.entitled==true){2155 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec fig'>"2156 + "<a class='tocLink' href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection','article','leftPane', '" + SDM.keOriginContentFamily + "');\">"2157 html += "<img src=\"/sd/grey_pxl.gif\" class=\"smlImgLazyJSB greyImg\" data-smlsrc='" + img + "' data-thumbheight='" + thumbHeight + "'/></a></div></li>";2158 }else{2159 html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec fig'>"2160 + "<a class=\"olIcon olIconFig cLink\" queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>" 2161 + "<img src=\"/sd/grey_pxl.gif\" class=\"smlImgLazyJSB greyImg\" data-smlsrc='" + img + "' data-thumbheight='"+thumbHeight + "'/>"2162 + "</a></div></li>";2163 }2164 return html;2165 }, //Outline.addOutlineItemFig2166 addItemSection: function(hashId, lbl, hStr) {2167 var html = "<li><div id='ol_" + hashId + "' class='io item " + hStr + "sec'>"2168 + "<a class='tocLink'href='#" + hashId + "' onClick=\"SD_UTIL.sendUserKeyEvent('displayTOCSection', 'article', 'leftPane', '" + SDM.keOriginContentFamily + "');\">"2169 + lbl + "<br>"2170 + "</a></div></li>";2171 return html;2172 }, //Outline.addOutlineItemSection2173 addItemOutline: function(hashId, lbl, hStr) {2174 var html = "<li><div class='io item " + hStr + "sec'>"2175 + "<a class='cLink' queryStr='" + SDM.urlTOCLinkQueryStr + "' href='" + SDM.urlTOCLink + "'\>"2176 + lbl + "<br>"2177 + "</a></div></li>";2178 return html;2179 }, //Outline.addOutlineItemSection2180 sidebarOpenClick: function(e) {2181 Outline.sidebarOpen(true);2182 SD_UTIL.sendUserKeyEvent('openLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2183 return false;2184 },2185 sidebarCloseClick: function(e) {2186 Outline.sidebarClose(); 2187 SD_UTIL.sendUserKeyEvent('closeLeftPane', 'article', 'leftPane', SDM.keOriginContentFamily);2188 return false;2189 },2190 sidebarOpen: function(e) {2191 if($('#leftPane').css('display')=='none') {2192 $('#leftCloseBar').hide();2193 $('#leftPane').height('').height($('#leftPane').height()).show();2194 $('#leftPane').animate({'margin-left':'0px'}, 250, function() {2195 var ol = $('#outline');2196 ol.css('overflow-y', 'auto');2197 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2198 else {2199 ol.scrollTop(ol.attr('data-st'));2200 }2201 ol.css('overflow-y', 'hidden');2202 if(e==true) {2203 Outline.hoverOverOn();2204 }2205 });2206 }2207 },2208 sidebarClose: function() {2209 if($('#leftPane').css('display')=='block' && $('#leftPane').attr('data-closing')!='y') {2210 var ol = $('#outline');2211 var st = ol.scrollTop();2212 ol.attr('data-st', st);2213 ol.css('overflow-y', 'hidden');2214 $('#leftPane').attr('data-closing', 'y');2215 $('#leftPane').height('').height($('#leftPane').height());2216 $('#leftPane').animate({'margin-left':'-280px'},250,function(){2217 $(this).hide();2218 $('#leftCloseBar').show();2219 $('#leftPane').attr('data-closing', '');2220 });2221 }2222 },2223 collapseSmallLeft: function() {2224 }, //Outline.collapseSmallLeft2225 expandSmallLeft: function() {2226 }, //Outline.expandSmallLeft2227 toggleGraphics: function(force) {2228 if(SDM.outlineImgFence==false) return;2229 2230 if(typeof(force)!=undefined) {2231 if(force=="hide") {2232 SDM.outlineGraphics=true;2233 }2234 else if(force=="show") {2235 SDM.outlineGraphics=false;2236 }2237 else {}2238 }2239 2240 if(SDM.outlineGraphics == true) {2241 SDM.outlineGraphics = false;2242 var ulWidthBefore = $('#outline ul').width();2243 $('li div.fig, li div.tbl, li div.mmc').parent().hide();2244 var ulWidthAfter = $('#outline ul').width();2245 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2246 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)$('#outline').css('overflow-x', 'hidden');2247 $('#outline').attr('data-osbp', 'n');2248 }2249 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2250 $('#outline').attr('data-osbp', 'y');2251 }2252 }2253 else {2254 SDM.outlineGraphics = true;2255 var ulWidthBefore = $('#outline ul').width();2256 $('li div.fig, li div.tbl, li div.mmc').parent().show();2257 var ulWidthAfter = $('#outline ul').width();2258 if(ulWidthAfter > ulWidthBefore && !SDU.isIE7()) {2259 $('#outline').attr('data-osbp', 'n');2260 }2261 else if(ulWidthAfter < ulWidthBefore && !SDU.isIE7()) {2262 $('#outline').css('overflow-x', 'auto');2263 $('#outline').attr('data-osbp', 'y');2264 }2265 }2266 }, //Outline.toggleGraphics2267 hoverOverOn: function() {2268 this.onHover = true;2269 var ol = $('#outline');2270 ol.doTheScrollJitter();2271 2272 var ulWidthBefore = $('#outline ul').width();2273 if(SDU.isIE7()) {}2274 else {2275 //ol.css('overflow-x', 'auto');2276 }2277 2278 ol.css('overflow-y', 'auto');2279 if(ol.attr('data-st')==undefined|| ol.attr('data-st')==0) {}2280 else {2281 ol.scrollTop(ol.attr('data-st'));2282 }2283 2284 var ulWidthAfter = $('#outline ul').width();2285 if(ulWidthAfter < ulWidthBefore) {2286 ol.attr('data-osbp', 'y');2287 if(SDU.isIE7()) {}2288 else {2289 if($('#lpTabs .leftTab').hasClass('activeTab')) {2290 ol.find('.srcli').each(function() {2291 if($(this).children('div.activeChapter').length) {2292 $(this).children('div.activeChapter').children('span').css('margin-right', 0);2293 $(this).find('li').css('margin-right', 0);2294 }2295 else {2296 $(this).css('margin-right', 0);2297 }2298 });2299 }2300 else {2301 ol.find('li').css('margin-right', 0);2302 }2303 }2304 }2305 else {2306 ol.attr('data-osbp', 'n');2307 if(SDU.isIE7()) {}2308 else {2309 ol.find('li').not('.outlineFocus').css('margin-right', 0);2310 }2311 ol.find('li.outlineFocus').parent().css('background', '#ffffff');2312 }2313 ol.css('background', '#ffffff');2314 ol.children('ul').css('background', '#ffffff');2315 ol.addClass('active');2316 2317 $('#articleLeftAd').css('background', '#ffffff');2318 if( $("#articleLeftAd iframe").length > 0 ){2319 $('#articleLeftAd iframe').contents().find('body').css('background', '#ffffff');2320 $('#articleLeftAd iframe').css('background', '#ffffff');2321 }2322 },2323 hoverOverOff: function() {2324 this.onHover = false;2325 var ol = $('#outline');2326 ol.doTheScrollJitter()2327 var ulWidthBefore = $('#outline ul').width();2328 var st = ol.scrollTop();2329 ol.attr('data-st', st);2330 ol.css('overflow-y', 'hidden');2331 if(!$('#srcOutline').is(':visible') && !SDM.isMRWMODArticle)ol.css('overflow-x', 'hidden');2332 var ulWidthAfter = $('#outline ul').width();2333 if(SDU.isIE7()) {2334 if(ulWidthAfter < ulWidthBefore) {}2335 else {2336 if($('#lpTabs .leftTab').hasClass('activeTab')) {2337 $('#outline > ul > li').css('margin-right', 0);2338 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2339 }2340 else {2341 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2342 }2343 }2344 }2345 else {2346 if(ulWidthAfter < ulWidthBefore) {2347 $('#outline > ul > li').css('margin-right', $.scrollBarWidth());2348 ol.find('li.srcli').css('margin-right', $.scrollBarWidth());2349 }2350 else {2351 ol.find('#itemOutline > li').each(function() {2352 if($(this).children('div.activeChapter').length) {2353 $(this).children('div.activeChapter').children('span').css('margin-right', $.scrollBarWidth());2354 $(this).find('li').css('margin-right', 0);2355 }2356 else {2357 $(this).css('margin-right', $.scrollBarWidth());2358 }2359 });2360 }2361 }2362 ol.find('li.outlineFocus').parent().css('background', '#ecf2f6');2363 ol.css('background', '#ecf2f6');2364 ol.children('ul').css('background', '#ecf2f6');2365 ol.removeClass('active');2366 //This must be at end or FF will reset the scroll2367 ol.scrollTop(st);2368 2369 $('#articleLeftAd').css('background', '#ecf2f6');2370 if( $("#articleLeftAd iframe").length > 0 ) {2371 $('#articleLeftAd iframe').contents().find('body').css('background', '#ecf2f6');2372 $('#articleLeftAd iframe').css('background', '#ecf2f6');2373 } 2374 },2375 moveToSection: function(e) {2376 var selID=$(e.target).closest('a').attr('href').split('#');2377 selID=selID[1];2378 $('#centerPane').moveTo(selID);2379 e.preventDefault();2380 e.stopPropagation(); 2381 },2382 findTargetFragment: function(e) {2383 var selID = e;2384 if(typeof e != 'string') {2385 var selID=$(e.target).closest('a').attr('href').split('#');2386 selID=selID[1];2387 }2388 var id = selID; 2389 id = id.replace(/[\.]/g, '\\.');2390 id = id.replace(/[\:]/g, '\\:'); 2391 var obj = $('#'+id); 2392 if (!$(obj)[0]) {2393 // Fragment not loaded yet.2394 if (Fragment.crossRefMap) {2395 var targetFrag = Fragment.getIntraRefFragId (selID);2396 var targetFragNum = targetFrag.substr(targetFrag.indexOf('_')+1)*1;2397 Fragment.get ('frag_' + (targetFragNum-1), e.data.z);2398 Fragment.get (targetFrag, e.data.z, {successCb: function(ee) {Outline.findTargetFragment(ee)},2399 successCbArg: e,2400 failureCb: function(selId) {2401 Fragment.bail(300, 'fndtgt', selId);2402 },2403 failureCbArg: selID2404 });2405 Fragment.get ('frag_' + (targetFragNum+1), e.data.z);2406 }2407 } else {2408 $('.page_fragment').show();2409 Fragment.scrollFlag = false;2410 $('#centerPane').moveTo(selID, { cbFunc: function() {Fragment.scrollFlag=true;}});2411 } 2412 if(typeof e != 'string') {2413 e.preventDefault();2414 e.stopPropagation();2415 }2416 },2417 getJson: function() {2418 $.get(SDM.urlPrefix + "/outlineJson/" + SDM.pm.pii + "/" + SDM.pm.cid, function(jsonStr, b, c) {2419 SDM.tocJson = String(jsonStr);2420 }, 'text')2421 .error (function() {2422 DBG.out (1, "Returned Error");2423 });2424 },2425 showLeftAd:function() {2426 if(SDM.adPreventOutline == true) return;2427 if ( typeof SDM.adArticleLeftURL!='undefined') {2428 $("#articleLeftAd").append('<iframe scrolling="no" frameborder="0" border="0" cellspacing="0" src="' + SDM.adArticleLeftURL + '"></iframe>');2429 }2430 } 2431} //Outline2432var DBG = {2433 out: function(lvl, str) {2434 if(SDM.debugFlag=="undefined") {return;}2435 if(SDM.debugFlag >= lvl || lvl==0 || typeof ut == 'object') {2436 if(typeof console=== "undefined" || typeof console.log==="undefined") {2437// if(!$('#sdConsole').length) {2438// $('body').append('<textarea id="sdConsole" class="ui-widget-content" cols="60"></textarea>');2439// $('#sdConsole').resizable();2440// }2441// $('#sdConsole').append(str + "<br>");2442 }2443 else{console.log(str) }2444 }2445 }2446} //DBG2447$(document).ready(function() {2448 if (SDM.pru!='') {2449 SD_UTIL.sendPageLoadStats();2450 }2451 if(!SDM.blk_all_social_logins && SDU.cookieAvail()){2452 LazyLoad.js([SDM.ep.gigyaLib], function() {2453 $('.socialContainer').each(function(){2454 if($(this).attr('id')!=''){2455 loadSocialLoginOptions($(this).attr('id'));2456 }2457 });2458 initGigyaHelp();2459 });2460 }2461 if(SDU.isIE7())$('#ieWarningMsg').ieWarning();2462 //loadBreadCrumbs();2463});2464function initGigyaHelp()2465{2466 $('#socialHelpPage').click(function(e){2467 e.stopPropagation();2468 e.preventDefault();2469 openPopup($(this).attr('href'),'help',800,600);2470 });2471}2472var SD_UTIL = {2473 killEvent:function(e){2474 if(!e) return;2475 e.preventDefault()2476 e.stopPropagation();2477 },2478 sendUserKeyEvent: function(a, o, z, ocf) {2479 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+ocf+'/'+a);2480 },2481 sendUserKeyEventForPPV: function(a, o, z) {2482 $.get(SDM.userActionURL+'/'+o+'/'+z+'/'+a);2483 },2484 sendDownloadKeyEvent: function(o, z, ocf, f) {2485 $.get(SDM.ep.downloadActionURL+'/'+o+'/'+z+'/'+ocf+'/'+f);2486 },2487 loadLib: function(urlStr) {2488 var headID = document.getElementsByTagName('head')[0];2489 var newScript = document.createElement('script');2490 newScript.type = 'text/javascript';2491 newScript.src = urlStr;2492 headID.appendChild(newScript);2493 },2494 isPerfTimingAvail:function() {2495 return !(typeof window.performance==="undefined" || typeof window.performance.timing==="undefined")2496 },2497 isSendStatsReady:function() {2498 if(SD_UTIL.isPerfTimingAvail()) {2499 if(window.performance.timing.domComplete&&window.performance.timing.loadEventStart&&window.performance.timing.loadEventEnd) return true;2500 else return false;2501 }2502 return true;2503 },2504 sendStats:function(){2505 if(SD_UTIL.isSendStatsReady()) {}2506 else {setTimeout(SD_UTIL.sendStats, 250);return;}2507 var params = '';2508 if(SD_UTIL.isPerfTimingAvail()) {2509 for(var k in window.performance.timing) {2510 prs.rt(("wpt_"+k), window.performance.timing[k]);2511 }2512 }2513 var prs2 = _.sortBy(prs, function(val) {2514 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1]*1.0;2515 });2516 for( var i = 0;i < prs2.length;i++){2517 params += "data=" + prs2[i].toString() + "&";2518 }2519 params += "key=" + SDM.pageTransKey + "&";2520 params += "pagetype=" + SDM.pageType;2521 },2522 printStats:function() {2523 var newprs = _.sortBy(prs, function(val) {2524 return val.toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2525 });2526 for( var i = 0;i < newprs.length;i++){2527 var dParts = newprs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g);2528 DBG.out(1, dParts[1].split(':')[1] + ',' + dParts[0].split(':')[1] + ',');2529 }2530 },2531 sendPageLoadStats:function() {2532 var params = '';2533 if (window.performance && window.performance.timing) {2534 if (window.performance.timing.loadEventEnd > 0) {2535 params = SD_UTIL.getArtSpdStats();2536 for(var k in window.performance.timing) {2537 params += "&" + k + "=" + window.performance.timing[k];2538 }2539 var url = SDM.pru+"/pageReport?"+params;2540 $('body').append('<img style="display:none" src="' + url + '">');2541 }2542 else {2543 setTimeout(SD_UTIL.sendPageLoadStats, 100);2544 }2545 }2546 else {2547 params = SD_UTIL.getArtSpdStats();2548 params += "&loadEventEnd=" + new Date().getTime();2549 var url = SDM.pru+"/pageReport?"+params;2550 $('body').append('<img style="display:none" src="' + url + '">');2551 }2552 },2553 getArtSpdStats:function(){2554 var params,lbl,timer;2555 params = "cpc=SD";2556 for( var i = 0;i < prs.length;i++){2557 lbl=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[0].split(':')[1];2558 if (lbl.indexOf("wpt_") == -1) {2559 timer=prs[i].toString().match(/([A-Za-z_]+:[A-Za-z0-9_]+)/g)[1].split(':')[1];2560 params += "&" + lbl + "=" + timer;2561 }2562 }2563 params += "&key=" + encodeURIComponent(SDM.pageTransKey);2564 params += "&pagetype=" + SDM.pageType;2565 params += "&sds=" + SDM.sds;2566 params += "&tid=" + SDM.tid;2567 if(SDM.tm.ahm != undefined)params += "&ahm=" + SDM.tm.ahm;2568 if(SDM.tm.chm != undefined)params += "&chm=" + SDM.tm.chm;2569 if (document.location.href) {2570 params += "&href=" + encodeURIComponent(document.location.href);2571 }2572 if (document.documentElement.clientWidth &&2573 document.documentElement.clientHeight) { 2574 params += "&winHeight=" + document.documentElement.clientHeight;2575 params += "&winWidth=" + document.documentElement.clientWidth;2576 }2577 params += "&domCount=" + document.getElementsByTagName("*").length;2578 return params;2579 },2580 getProdColor: function(){2581 return (SDM.prodColor==""?"sci_dir":SDM.prodColor);2582 },2583 getIFrameHeight: function(ifr) {2584 var ifrDoc=ifr.contentWindow||ifr.contentDocument||ifr.document;2585 if(ifrDoc.document!=undefined) ifrDoc=ifrDoc.document;2586 return $(ifrDoc.body).height();2587 },2588 resizeIFrame: function(iframeBox, iframeHeight) {2589 $('#' + iframeBox + ' iframe').height(iframeHeight);2590 }2591}2592// Lazy Loader2593$.fn.lazyLoadImages = function(opts) {2594 var cfg = {2595 imgSel: 'img',2596 preLoadLine: 102597 };2598 var lastScrollTop=0;2599 function scrollAction() {2600 var bottom = $(window).height() + $('#centerPane').scrollTop();2601 var totalCount=$(cfg.imgSel).size();2602 var loopBool = true;2603 var st=$('#centerPane').scrollTop();2604 if (st > lastScrollTop){2605 var scrollDown=true;2606 } else {2607 var scrollUp=true;2608 }2609 for(i=0;i<totalCount && loopBool==true ;i++){2610 var obj = $(cfg.imgSel)[i];2611 if( Math.abs($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerContent').top+$(obj).height()) < 2612 $(window).height() + cfg.preLoadLine2613 || Math.abs($('#centerPane').scrollTop() - $(obj).positionA('#centerContent').top) < $(window).height() + cfg.preLoadLine) {2614 var imgObj = $(obj);2615 if(imgObj.attr('data-loaded')!='true' ) {2616 var dataGabsImgEID = imgObj.attr('data-gabsEID');2617 var dataFullImgEID = imgObj.attr('data-fullEID');2618 var dataThumbImgEID = imgObj.attr('data-thumbEID');2619 var dataInlImgEid = imgObj.attr('data-inlimgeid');2620 var dataInlImg = imgObj.attr('data-inlimg');2621 var dataPubLogo = imgObj.attr('data-publogo');2622 var dataDefaultLogo = imgObj.attr('data-defaultlogo');2623 if (dataGabsImgEID != undefined && dataGabsImgEID != '' && SDM.entitled) {2624 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-gabsEID')).attr('data-loaded', 'true');2625 }else if (SDM.fullSize==true && dataFullImgEID != undefined && dataFullImgEID != '') {2626 if(SDM.entitled) {2627 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-fullEID')).attr('data-loaded', 'true');2628 if(imgObj.attr('data-fullwidth')<580 || imgObj.attr('data-fullwidth')>800){2629 $(obj).css('height', $(obj).attr('data-fullheight')).css('width', $(obj).attr('data-fullwidth'));2630 } 2631 } else {2632 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true'); 2633 }2634 } else if (dataThumbImgEID != undefined && dataThumbImgEID != '') {2635 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-thumbEID')).attr('data-loaded', 'true');2636 $(obj).css('height', $(obj).attr('data-thumbheight')).css('width', $(obj).attr('data-thumbwidth'));2637 } else if (dataInlImgEid != undefined && dataInlImgEid != '') {2638 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-inlimgeid')).attr('data-loaded', 'true');2639 if(imgObj.closest('.formula')[0] && imgObj.width()>=595){2640 imgObj.closest('.formula').find('.mathmlsrc').addClass('scrollOn');2641 }2642 } else if (dataDefaultLogo != undefined && dataDefaultLogo != '') {2643 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-defaultlogo')).attr('data-loaded', 'true');2644 } else if (dataPubLogo != undefined && dataPubLogo != '') {2645 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-publogo')).attr('data-loaded', 'true');2646 } else if (dataInlImg != undefined && dataInlImg != '') {2647 imgObj.attr('src', SDM.staticImageUrlPrefix + imgObj.attr('data-inlimg')).attr('data-loaded', 'true');2648 }2649 }2650 }2651 else {2652 if($('#centerPane').scrollTop()+$(window).height() - $(obj).positionA('#centerContent').top+$(obj).height() < 2653 $(window).height() + cfg.preLoadLine && scrollDown){ 2654 loopBool=false;2655 }2656 if($('#centerPane').scrollTop() - $(obj).positionA('#centerContent').top < $(window).height() + cfg.preLoadLine && scrollUp){2657 loopBool=false;2658 }2659 }2660 }2661 lastScrollTop=$('#centerPane').scrollTop();2662 } //scroll2663 return this.each(function() {2664 if(opts) {2665 $.extend(cfg, opts);2666 }2667 scrollAction(); // run it once for any images that are currently on the screen2668 var lazyScroll = _.debounce(scrollAction, 300);2669 $(this).scroll( lazyScroll );2670 }) //return2671};2672$.fn.lazyLoadOutlineImages = function(opts) {2673 var cfg = {2674 imgSel: 'img',2675 preLoadLine: 2002676 };2677 function lazyDisplay() {2678 var cnt = 0;2679 var myTop = 0;2680 var myHeight = 0;2681 var myWidth = 0;2682 var thumbHeight = 0;2683 $(cfg.imgSel).each(function() {2684 var outlineTop = Math.abs($('#outline').scrollTop());2685 var outlineBottom = Math.abs(outlineTop + $('#outline').height());2686 var outlineHeight = $('#outline').height();2687 var windowHeight = Math.abs($(window).height());2688 if (cnt == 0) {2689 myTop = Math.abs($(this).position().top);2690 }2691 else {2692 myTop += (myHeight * 1); // add last height to position2693 }2694 myHeight = Math.abs($(this).height());2695 thumbHeight = $(this).attr('data-thumbheight');2696 if (thumbHeight == undefined) {2697 thumbHeight = 0;2698 }2699 if (thumbHeight > 0 && thumbHeight < myHeight) {2700 myHeight = thumbHeight;2701 }2702 myWidth = Math.abs($(this).width());2703 var myDims = myTop * 1 + myHeight * 1;2704 if( Math.abs(myDims - outlineTop) < Math.abs(outlineBottom + cfg.preLoadLine) 2705 || Math.abs(outlineTop - myTop) < Math.abs(outlineHeight + cfg.preLoadLine)) {2706 var imgObj = $(this);2707 if(imgObj.attr('data-loaded')!='true' ) {2708 if (imgObj.attr('data-smlsrc') != undefined) {2709 imgObj.attr('src', imgObj.attr('data-smlsrc')).attr('data-loaded', 'true');2710 } else if (imgObj.attr('data-mmlEID') != undefined) {2711 imgObj.attr('src', SDM.imageUrlPrefix + imgObj.attr('data-mmlEID')).attr('data-loaded', 'true');2712 } 2713 imgObj.addClass("displayImg");2714 } 2715 $(this).parent().parent().css('height', '').css('width', '');2716 } 2717 cnt++;2718 })2719 } //scroll2720 return this.each(function() {2721 if(opts) {2722 $.extend(cfg, opts);2723 }2724 2725 lazyDisplay(); // run it once to show images that are currently on page2726 var lazyScroll = _.debounce(lazyDisplay, 300);2727 $(this).scroll( lazyScroll );2728 }) //return2729};2730$.fn.lazyLoad = function( cfg ){2731 // Internal function used to implement `_.throttle` and `_.debounce`.2732 var limit = function(func, wait, debounce) {2733 var timeout;2734 return function() {2735 var context = this, args = arguments;2736 var throttler = function() {2737 timeout = null;2738 func.apply(context, args);2739 };2740 if (debounce) clearTimeout(timeout);2741 if (debounce || !timeout) timeout = setTimeout(throttler, wait);2742 };2743 };2744 var plugin = {2745 buffer: cfg.buffer?cfg.buffer:50, // 50 pixels by default2746 batchSize: cfg.batchSize?cfg.batchSize:1, // 1 is the default batch size.2747 scrollSrc: cfg.scrollSrc?cfg.scrollSrc:'#centerPane',2748 callback: cfg.intoView?cfg.intoView:function(obj,idx){},2749 selector: '.refPlaceHolder',2750 screenTop: $(window).scrollTop(),2751 screenHeight:$(window).height(),2752 debounce: function(func, wait) {2753 return limit(func, wait, true);2754 },2755 calculateView: function() {2756 //pagination get all needs this2757 if(refResolveEnabled==false) {return;}2758 2759 if( plugin.applyPatch() ) {2760 plugin.buffer += 500;2761 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2762 }2763 else{2764 plugin.screenTop = $( plugin.scrollSrc ).scrollTop() - plugin.buffer;2765 }2766 var screenBot = plugin.screenTop + $(window).height() + plugin.buffer;2767 var batch = [];2768 $refs = $(plugin.selector).not(function() {2769 return $(this).attr('data-sr')=='Y';2770 });2771 $refs.each(function() {2772 var tmpTop = $(this).position().top;2773 if( plugin.applyPatch() ) {2774 tmpTop = this.offsetTop;2775 }2776 if( tmpTop > plugin.screenTop && tmpTop < screenBot ) { 2777 $(this).attr('data-sr', 'Y'); 2778 batch.push( this ); 2779 if( plugin.batchSize == 1 ){ 2780 plugin.callback( batch );2781 batch = [];2782 }2783 else{ 2784 if( batch.length == plugin.batchSize ){2785 plugin.callback( batch );2786 batch = [];2787 }2788 }2789 }2790 else {2791 $(this).attr('data-sr', 'N'); 2792 } 2793 }); 2794 if( batch ){ plugin.callback( batch ); } // run any remainder in batch2795 },2796 applyPatch:function() {2797 return ($.browser.msie && $.browser.version < 9)2798 }2799 }2800 var lazyResize = plugin.debounce(plugin.calculateView,300);2801 var lazyScroll = plugin.debounce(plugin.calculateView, 300);2802 2803 $(window).resize( lazyResize );2804 $(plugin.scrollSrc).scroll( lazyScroll );2805 plugin.calculateView();2806 return plugin;2807} 2808// end of Lazy Loader2809// small enhancement2810// this method will be called by gadget services to get2811// encrypted cookie from web2812function getEuid() {2813 return SDM.euidCookieObject; 2814}2815function isNotNumber(o) {2816 if (o == -1) {2817 return true;2818 }2819 return isNaN (o-0);2820}2821function getNumber(str) {2822 if(!str) {2823 return -1;2824 }2825 var i=0;2826 while(i < str.length) {2827 var charat = str.charAt(i);2828 if(!isNotNumber(charat)) {2829 if(charat != "0") {2830 return str.substring(i);2831 }2832 }2833 i++;2834 }2835}2836//Reference resolution2837var ajaxRefResol;2838var ajaxCitedByUpdate;2839function updateCitedByCounts(citedByCounts,isHoover,start,count) {2840 citedByCounts = citedByCounts.substring(0,citedByCounts.length-1);2841 var updateCitedUrl = SDM.ep.updatedCitedBy + citedByCounts;2842 ajaxCitedByUpdate = new $.ajax({2843 url: updateCitedUrl,2844 type: 'GET',2845 async : isHoover,2846 dataType : 'text',2847 error: function() {2848 $(".citedBy_").each(function(){2849 $(this).html("");2850 });2851 },2852 success: function(res) {2853 var citedBy = decodeURIComponent(res);2854 if (citedBy != null) {2855 this.$citedByDiv = $('<div></div>')2856 .hide()2857 .append($(citedBy)2858 );2859 $(".citedBy_").each(function(){2860 if(myXabsCounts[this.id]) {2861 if( this.innerHTML.match('Cited By in Scopus') == null) {2862 $(this).html( myXabsCounts[this.id]);2863 $(this).attr ("data-citeres", "Y");2864 }2865 } else {2866 $(this).html("");2867 $(this).attr ("data-citeres", "Y");2868 }2869 });2870 }2871 }2872 }); 2873}2874String.prototype.substringBetween = function (string1, string2) {2875 if ((this.indexOf(string1, 0) == -1) || (this.indexOf(string2, this.indexOf(string1, 0)) == -1)) {2876 return (-1);2877 } else {2878 return this.substring((this.indexOf(string1, 0) + string1.length), (this.indexOf(string2, this.indexOf(string1, 0))));2879 }2880};2881var lazyRefs = null;2882function refResolve() {2883 lazyRefs = $(".refPlaceHolder").lazyLoad({2884 batchSize:50,2885 intoView:function(objs,idx){2886 if( objs ){2887 if( objs[0] ){2888 var start = $(objs[0]).attr("id").substring(8);2889 if(!start) {2890 start = 1;2891 }2892 var count = objs.length;2893 if (idx) {2894 resolveRefs(idx,1);2895 }2896 else {2897 resolveRefs( start, count );2898 }2899 }2900 }2901 }2902 });2903}2904function resolveRefs( start, count ){2905 var url = SDM.ep.refResolvePath + "&_refRangeStart="+start+"&_refRangeCount="+count;2906 var isHoover = true;2907 if (count == 1) {2908 isHoover = false;2909 }2910 ajaxRefResol = new $.ajax({2911 url: url,2912 type: 'GET',2913 async : isHoover,2914 dataType : 'text',2915 error: function() {2916 $(".refPlaceHolder").each(function(){2917 $(this).html(' <span style="color:red;"> [SD-008]<\/span>');2918 });2919 return;2920 },2921 success: function(res) {2922 var refMap = decodeURIComponent(res);2923 var citedBySCEids = refMap.substringBetween("#","^");2924 var tmp = "#"+citedBySCEids+"^";2925 refMap = refMap.replace(tmp,"");2926 if (refMap != null) {2927 this.$OuterDiv = $('<div></div>').hide().append($(refMap));2928 $(".refPlaceHolder").each(function(){2929 if (myMap[this.id.toLowerCase()]['refHtml'] || myMap[this.id.toLowerCase()]['refHtml'] != "") {2930 if(this.innerHTML.match('/science?') == null){2931 $(this).html(myMap[this.id.toLowerCase()]['refHtml'] );2932 $(this).attr ("data-refres", "Y");2933 }2934 // Add abstarct url to the <li> tag2935 if (myMap[this.id.toLowerCase()]['absUrl']) {2936 $(this).attr ("data-absurl", myMap[this.id.toLowerCase()]['absUrl']);2937 }2938 }2939 else {2940 $(this).html("");2941 $(this).attr ("data-refres", "Y");2942 }2943 });2944 // update Cited by counts2945 if(citedBySCEids != null && citedBySCEids != ""){2946 updateCitedByCounts(citedBySCEids,isHoover,start,count);2947 }2948 }2949 }2950 }); 2951}2952//Reference resolution End2953var EbookTOC = {2954 eBookTOCTimeout: 1000,2955 currentLink: null,2956 tocObj: null,2957 init: function() {2958 var eBookTOCURL = $('div.publicationHead div.title a').attr("href").replace('book', 'toc');2959 2960 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()) {2961 var tocStr = sessionStorage.getItem('bk.toc');2962 if(tocStr) {2963 EbookTOC.tocObj = $.parseJSON(tocStr);2964 if(EbookTOC.tocObj.eBookCID==SDM.pm.cid) {2965 DBG.out(1, 'Found bk.toc using...');2966 }2967 else {2968 EbookTOC.tocObj=null;2969 sessionStorage.removeItem('bk.toc');2970 DBG.out(1, 'Found different bk.toc removing...');2971 }2972 }2973 }2974 2975 if(EbookTOC.tocObj==null) {2976 $.getJSON(eBookTOCURL, function(res) {2977 if (res){2978 if(SDU.cookieAvail()&&SDU.sessionStorageAvail()&&typeof JSON!='undefined') {2979 sessionStorage.setItem('bk.toc', JSON.stringify(res));2980 DBG.out(1, 'Storing bk.toc');2981 }2982 }2983 EbookTOC.load(res);2984 });2985 }2986 else {2987 EbookTOC.load(EbookTOC.tocObj);2988 }2989 $('#leftPane #srcOutline li div.so a').ellipsis();2990 }, //init2991 load:function(res) {2992 var $bookToc = EbookTOC.buildToc(res);2993 $('#leftPane').prepend('<ul id="lpTabs">'2994 + '<li class="leftTab tab" tabindex="0">Book contents</li>'2995 + '<li class="rightTab tab" tabindex="0">Chapter contents</li>'2996 + '</ul>');2997 $('#lpTabs .leftTab').click(function() {2998 if($('#srcOutline').css('display')!='none') return;2999 EbookTOC.showSourceTab(this);3000 SD_UTIL.sendUserKeyEvent('sourceTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3001 });3002 $('#lpTabs .rightTab').click(function() {3003 if($('#srcOutline').css('display')=='none') return;3004 EbookTOC.showItemTab(this);3005 SD_UTIL.sendUserKeyEvent('itemTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);3006 });3007 $('#outline').prepend($bookToc);3008 $('#outline, #leftPane, #leftPaneInner').addClass('book');3009 //Initially set all parent nodes to collapsed.3010 EbookTOC.showPath2Item(SDM.pm.pii);3011 $('.activeChapter >a').attr('href', "");3012 if(SDM.outlineTab=='I') {3013 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);3014 }3015 else {3016 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);3017 $('#outline').scrollToTopic({selTopic:'div.activeChapter'}); 3018 }3019 $('.leftPaneToggle').unbind('click').bind('click',function(e){3020 e.preventDefault();3021 e.stopPropagation();3022 EbookTOC.nodeClick($(this)[0]);3023 });3024 }, //load3025 showSourceTab:function(e) {3026 $(e).parent().children('.tab').removeClass('activeTab');3027 $(e).addClass('activeTab');3028 $('.outlineMsg').hide();3029 $('#srcOutline').show();3030 $('.activeChapter').parent().append($('#itemOutline')[0]);...
sd_122.js
Source:sd_122.js
...1797 + '<li class="rightTab tab" tabindex="0">Chapter contents</li>'1798 + '</ul>');1799 $('#lpTabs .leftTab').click(function() {1800 if($('#srcOutline').css('display')!='none') return;1801 EbookTOC.showSourceTab(this);1802 SD_UTIL.sendUserKeyEvent('sourceTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);1803 });1804 $('#lpTabs .rightTab').click(function() {1805 if($('#srcOutline').css('display')=='none') return;1806 EbookTOC.showItemTab(this);1807 SD_UTIL.sendUserKeyEvent('itemTabSelected', 'article', 'leftPane', SDM.keOriginContentFamily);1808 });1809 $('#outline').prepend($bookToc);1810 $('#outline, #leftPane, #leftPaneInner').addClass('book');1811 //Initially set all parent nodes to collapsed.1812 EbookTOC.showPath2Item(SDM.pm.pii);1813 $('.activeChapter >a').attr('href', "");1814 if(SDM.outlineTab=='S') {1815 EbookTOC.showSourceTab($('#lpTabs .leftTab')[0]);1816 }1817 else {1818 EbookTOC.showItemTab($('#lpTabs .rightTab')[0]);1819 }1820 }, //load1821 showSourceTab:function(e) {1822 $(e).parent().children('.tab').removeClass('activeTab');1823 $(e).addClass('activeTab');1824 $('.outlineMsg').hide();1825 $('#srcOutline').show();1826 $('.activeChapter').parent().append($('#itemOutline')[0]);1827 $('#searchWithin').show();1828 $('#olGraphCbBox').hide();1829 Outline.toggleGraphics('hide');...
Using AI Code Generation
1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.showSourceTab();7 await browser.close();8})();9const playwright = require('playwright');10(async () => {11 const browser = await playwright.chromium.launch({12 });13 const context = await browser.newContext();14 const page = await context.newPage();15 await page.showSourceTab();16 await browser.close();17})();18const playwright = require('playwright');19(async () => {20 const browser = await playwright.chromium.launchPersistentContext(21 {22 }23 );24 const page = await browser.newPage();25 await page.showSourceTab();26 await browser.close();27})();28const playwright = require('playwright');29(async () => {30 const browser = await playwright.chromium.launchServer({31 });32 const context = await browser.newContext();33 const page = await context.newPage();34 await page.showSourceTab();35 await browser.close();36})();37const playwright = require('playwright');38(async () => {39 const browser = await playwright.chromium.launchPersistentServer(40 {41 }42 );43 const context = await browser.newContext();
Using AI Code Generation
1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.goto('
Using AI Code Generation
1const { showSourceTab } = require('playwright/lib/server/chromium/crPage');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await browser.close();8})();
Using AI Code Generation
1const { showSourceTab } = require("playwright");2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 const page = await context.newPage();6 await showSourceTab(page);7 await browser.close();8})();
Using AI Code Generation
1const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');2const { chromium } = require('playwright-chromium');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 await showSourceTab(page);8})();9const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');10const { chromium } = require('playwright-chromium');11(async () => {12 const browser = await chromium.launch();13 const context = await browser.newContext();14 const page = await context.newPage();15 await showSourceTab(page);16})();17const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');18const { chromium } = require('playwright-chromium');19(async () => {20 const browser = await chromium.launch();21 const context = await browser.newContext();22 const page = await context.newPage();23 await showSourceTab(page);24})();25const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');26const { chromium } = require('playwright-chromium');27(async () => {28 const browser = await chromium.launch();29 const context = await browser.newContext();30 const page = await context.newPage();31 await showSourceTab(page);32})();33const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');34const { chromium } = require('playwright-chromium');35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 const page = await context.newPage();39 await showSourceTab(page);40})();41const { showSourceTab } = require('playwright-chromium/lib/server/chromium/crPage');42const { chromium } = require('playwright-chromium');43(async () => {44 const browser = await chromium.launch();45 const context = await browser.newContext();
Using AI Code Generation
1const { showSourceTab } = require('playwright/lib/server/inspector');2const { chromium } = require('playwright');3const browser = await chromium.launch();4const context = await browser.newContext();5const page = await context.newPage();6await showSourceTab(page);7await browser.close();8const { showSourceTab } = require('playwright/lib/server/inspector');9const { chromium } = require('playwright');10const browser = await chromium.launch();11const context = await browser.newContext();12const page = await context.newPage();13await showSourceTab(page);14await browser.close();15const { showSourceTab } = require('playwright/lib/server/inspector');16const { chromium } = require('playwright');17const browser = await chromium.launch();18const context = await browser.newContext();19const page = await context.newPage();20await showSourceTab(page);21await browser.close();22const { showSourceTab } = require('playwright/lib/server/inspector');23const { chromium } = require('playwright');24const browser = await chromium.launch();25const context = await browser.newContext();26const page = await context.newPage();27await showSourceTab(page);28await browser.close();29const { showSourceTab } = require('playwright/lib/server/inspector');30const { chromium } = require('playwright');31const browser = await chromium.launch();32const context = await browser.newContext();33const page = await context.newPage();34await showSourceTab(page);35await browser.close();36const { showSourceTab } = require('playwright/lib/server/inspector');37const { chromium } = require('playwright');38const browser = await chromium.launch();39const context = await browser.newContext();40const page = await context.newPage();41await showSourceTab(page);42await browser.close();43const { showSourceTab } = require('playwright/lib/server/inspector');
Using AI Code Generation
1const {showSourceTab} = require('playwright');2(async () => {3 await showSourceTab();4})();5const {showSourceTab} = require('playwright');6describe('showSourceTab', () => {7 it('should show source tab', async () => {8 await showSourceTab();9 });10});
Using AI Code Generation
1const { showSourceTab } = require('@playwright/test/lib/server/traceViewer/index');2showSourceTab();3const { test, expect } = require('@playwright/test');4test('basic test', async ({ page }) => {5 const title = page.locator('.navbar__inner .navbar__title');6 await expect(title).toHaveText('Playwright');7});
Using AI Code Generation
1const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');2await showSourceTab();3await page.evaluate(() => console.log('Hello world!'));4const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');5await showSourceTab();6await page.evaluate(() => console.log('Hello world!'));7const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');8await showSourceTab();9await page.evaluate(() => console.log('Hello world!'));10const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');11await showSourceTab();12await page.evaluate(() => console.log('Hello world!'));13const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');14await showSourceTab();15await page.evaluate(() => console.log('Hello world!'));16const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');17await showSourceTab();18await page.evaluate(() => console.log('Hello world!'));19const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');20await showSourceTab();21await page.evaluate(() => console.log('Hello world!'));22const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');23await showSourceTab();24await page.evaluate(() => console.log('Hello world!'));25const { showSourceTab } = require('playwright/lib/cli/traceViewer/ui/sourceTab.js');26await showSourceTab();27await page.evaluate(() => console.log
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!