Ticket #5447: trac_5447-jquery_upgrade.patch

File trac_5447-jquery_upgrade.patch, 11.1 KB (added by mpatel, 12 years ago)

For p0 spkgs.

  • sage/server/notebook/interact.py

    # HG changeset patch
    # User Mitesh Patel <qed777@gmail.com>
    # Date 1249269805 25200
    # Node ID fa71d381705c0299007e28884f79a4bd17ad456c
    # Parent  ad78ef7abf55e63eb92596395d034f3b9c2ee9fb
    #5447, jQuery and jQuery UI upgrade tweaks
    
    diff --git a/sage/server/notebook/interact.py b/sage/server/notebook/interact.py
    a b def html_slider(id, values, callback, st 
    229229        <html>...</html>
    230230    """
    231231    s = """<table><tr><td>
    232         <div id='%s' class='ui-slider ui-slider-3' style='margin:%spx;'><span class='ui-slider-handle'></span></div>
     232        <div id='%s' style='margin:%spx; margin-left: 1.0em; margin-right: 1.0em; width: 15.0em;'></div>
    233233        </td>"""%(id,int(margin))
    234234    if values != "null":
    235235        s += "<td><font color='black' id='%s-lbl'></font></td>"%id
    def html_slider(id, values, callback, st 
    240240    # below which gets passed an anonymous function.
    241241    s += """<script>(function(){ var values = %(values)s; setTimeout(function() {
    242242    $('#%(id)s').slider({
    243         stepping: 1, min: 0, max: %(maxvalue)s, startValue: %(startvalue)s,
     243        step: 1, min: 0, max: %(maxvalue)s, value: %(startvalue)s,
    244244        change: function (e,ui) { var position = ui.value; if(values!=null) $('#%(id)s-lbl').text(values[position]); %(callback)s; },
    245245        slide: function(e,ui) { if(values!=null) $('#%(id)s-lbl').text(values[ui.value]); }
    246246    });
    def html_rangeslider(id, values, callbac 
    273273        sage: html(html_rangeslider('slider-007', 'null', 'alert(pos[0]+", "+pos[1])', steps=5, default_l=2, default_r=3, margin=5))
    274274        <html>...</html>
    275275    """
    276     s = """<table>
    277     <tr><td><div id='%s' class='ui-slider ui-slider-3' style='margin:%spx;'>
    278     <span class='ui-slider-handle'></span><span class='ui-slider-handle'></span>
    279     </div></td></tr>"""%(id,int(margin))
     276    s = """<table><tr><td>
     277        <div id='%s' style='margin:%spx; margin-left: 1.0em; margin-right: 1.0em; width: 20.0em;'></div>
     278        </td></tr>"""%(id,int(margin))
    280279    if values != "null":
    281280        s += "<tr><td><font color='black' id='%s-lbl'></font></td></tr>"%id
    282281    s += "</table>"
    def html_rangeslider(id, values, callbac 
    291290        var sel = '#%s';
    292291        var updatePos = function()
    293292        {
    294             pos[0]=$(sel).slider('value', 0);
    295             pos[1]=$(sel).slider('value', 1);
     293            pos[0]=$(sel).slider('values', 0);
     294            pos[1]=$(sel).slider('values', 1);
    296295            if(values!=null) $(sel+'-lbl').text("("+values[pos[0]]+", "+values[pos[1]]+")");
    297296        };
    298297        setTimeout(function()
    def html_rangeslider(id, values, callbac 
    300299            $(sel).slider(
    301300            {
    302301                range: true,
    303                 stepping: 1,                   
     302                step: 1,                   
    304303                min: 0,
    305304                max: %s,
    306                 handles: [{start: %s},{start:%s}],
     305                values: [%s, %s],
    307306                change: function(e,ui){ updatePos(); %s; },
    308307                slide: updatePos
    309308            });
  • sage/server/notebook/notebook.py

    diff --git a/sage/server/notebook/notebook.py b/sage/server/notebook/notebook.py
    a b class Notebook(SageObject): 
    17171717    def _html_head(self, worksheet_filename, username):
    17181718        if worksheet_filename is not None:
    17191719            worksheet = self.get_worksheet_with_filename(worksheet_filename)
    1720             head = '\n<title>%s (Sage)</title>'%(worksheet.name())
     1720            head = '\n<title>%s (Sage)</title>\n'%(worksheet.name())
    17211721        else:
    1722             head = '\n<title>Sage Notebook | Welcome</title>'
     1722            head = '\n<title>Sage Notebook | Welcome</title>\n'
    17231723
    1724         head += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
    1725         # Load the Sage javascript libray.
    1726         head += '\n<script type="text/javascript" src="/javascript_local/jquery/jquery.js"></script>'
    1727         head += '\n<script type="text/javascript" src="/javascript/main.js"></script>\n'
    1728         head += '\n<link rel=stylesheet href="/css/main.css" type="text/css">\n'
     1724        head += '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n'
     1725
     1726        # jQuery -- general-purpose functions.
     1727        head += '<script type="text/javascript" src="/javascript_local/jquery/jquery.js"></script>\n'
     1728        # Sage notebook library and stylesheet.
     1729        head += '<script type="text/javascript" src="/javascript/main.js"></script>\n'
     1730        head += '<link rel=stylesheet href="/css/main.css" type="text/css">\n'
    17291731
    17301732        if JSMATH:
    1731             # turn off the ugly scary font warning.
    1732             head += '\n <STYLE> #jsMath_Warning {display: none} </STYLE>\n'
     1733            # Turn off jsMath's ugly-scary font warning.
     1734            head += '<style>#jsMath_Warning {display: none}</style>\n'
    17331735            head += '<script type="text/javascript">jsMath = {Controls: {cookie: {scale: 115}}}</script>\n'
    17341736            if not JSMATH_IMAGE_FONTS:
    1735                 head +=' <script type="text/javascript" src="/javascript_local/jsmath/plugins/noImageFonts.js"></script>\n'
     1737                head +='<script type="text/javascript" src="/javascript_local/jsmath/plugins/noImageFonts.js"></script>\n'
    17361738
    1737             # Move the jsMath button 20 pixels from the right edge
    1738             # (apparently in some browsers, it covers up the scroll
    1739             # bar)
    1740             head += """<script type="text/javascript">
    1741 jsMath.styles = {
    1742         '#jsMath_button':   'position:fixed; bottom:1px; right:20px; background-color:white; '
    1743                                 + 'border: solid 1px #959595; margin:0px; padding: 0px 3px 1px 3px; '
    1744                                 + 'z-index:102; color:black; text-decoration:none; font-size:x-small; '
    1745                                 + 'width:auto; cursor:hand;',
    1746       };
    1747     </script>
    1748 """
     1739            # Move jsMath button -- covers scroll bar in some browsers.
     1740            head += '''<script type="text/javascript">
     1741    jsMath.styles = {
     1742        '#jsMath_button' : 'position:fixed; bottom:1px; right:20px; background-color:white; '
     1743                         + 'border: solid 1px #959595; margin:0px; padding: 0px 3px 1px 3px; '
     1744                         + 'z-index:102; color:black; text-decoration:none; font-size:x-small; '
     1745                         + 'width:auto; cursor:hand;'
     1746};
     1747</script>
     1748'''
    17491749            head += '<script type="text/javascript" src="/javascript_local/jsmath/jsMath.js"></script>\n'
    1750             head += r'''<script type="text/javascript">/*The extensions here do the following:
    1751       - verb implements the \verb command:
    1752         see http://www.math.union.edu/~dpvc/jsMath/authors/verb.html
    1753       - moreArrows implements \xrightarrow, among other things:
    1754         see http://www.math.union.edu/~dpvc/jsMath/authors//moreArrows.html
    1755       - AMSmath implements a number of AMS math commands:
    1756         see http://www.math.union.edu/~dpvc/jsMath/authors/AMSmath.html
    1757     */
    1758          jsMath.Extension.Require("verb");
    1759          jsMath.Extension.Require("moreArrows");
    1760          jsMath.Extension.Require("AMSmath");
    1761          jsMath.Extension.Require("AMSsymbols");
    1762 </script>'''
     1750            head += '''<script type="text/javascript">
     1751    jsMath.Extension.Require("verb");
     1752    jsMath.Extension.Require("moreArrows");
     1753    jsMath.Extension.Require("AMSmath");
     1754    jsMath.Extension.Require("AMSsymbols");
     1755</script>
     1756'''
    17631757
    1764         # import latex macros
     1758        # jsMath LaTeX macros.
    17651759        for m in sage_jsmath_macros:
    17661760            head += '<script>' + m + '</script>\n'
    17671761       
    1768         # Load the jquery and ui-jquery javascript library.
    1769         # This is used for interact functionality in the notebook, and will be used
    1770         # to enable drag and drop, image zoom, etc.
    1771         head += '''
    1772 <script type="text/javascript" src="/javascript_local/jqueryui/jquery.ui.all.min.js"></script>
    1773 <script type="text/javascript" src="/javascript_local/jquery/plugins/farbtastic/farbtastic.min.js"></script>
    1774 <script type="text/javascript" src="/javascript_local/jquery/plugins/dimensions/jquery.dimensions.min.js"></script>
     1762        # jQuery UI -- interacts, widgets.
     1763        head += '''<script type="text/javascript" src="/javascript_local/jqueryui/jquery-ui.js"></script>
     1764<script type="text/javascript" src="/javascript_local/jquery/plugins/farbtastic/farbtastic.js"></script>
    17751765<script type="text/javascript" src="/javascript_local/jquery/plugins/jquery.event.extendedclick.js"></script>
     1766<link rel="stylesheet" href="/javascript_local/jquery/plugins/farbtastic/farbtastic.css" type="text/css" /> 
     1767<link rel="stylesheet" href="/javascript_local/jqueryui/themes/sage/sage.css">
     1768'''
    17761769
    1777 <link rel="stylesheet" href="/javascript_local/jquery/plugins/farbtastic/farbtastic.css" type="text/css" /> 
    1778 <link rel="stylesheet" href="/javascript_local/jqueryui/themes/flora/flora.all.css">
    1779          '''
    1780 # TODO: get the lazy loading plugin
     1770        head +='<script type="text/javascript" src="/javascript/sage3d.js"></script>\n'
     1771        # Jmol -- embedded 3d graphics.
     1772        head +='<script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>\n'
     1773        # This must stay in <head>:
     1774        head +='<script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script>\n'
    17811775
    1782 # TODO: Load individual ui plugins, not the whole package:
    1783 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.mouse.min.js"></script>
    1784 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.slider.min.js"></script>
    1785 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.draggable.min.js"></script>
    1786 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.draggable.ext.min.js"></script>
    1787 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.resizable.min.js"></script>
    1788 # <script type="text/javascript" src="/javascript_local/jqueryui/ui.dialog.min.js"></script>
    1789 
    1790 
    1791         # This was for syntax hilighting 
    1792 #        head +=' <script type="text/javascript" src="/javascript/highlight/prettify.js"></script>\n'
    1793 #        head += '<link rel=stylesheet href="/css/highlight/prettify.css" type="text/css">\n'
    1794 
    1795         head +=' <script type="text/javascript" src="/javascript/sage3d.js"></script>\n'
    1796 
    1797         # Jmol -- embedded 3d graphics.
    1798         head +=' <script type="text/javascript" src="/java/jmol/appletweb/Jmol.js"></script>\n'
    1799        
    1800         head +=' <script>jmolInitialize("/java/jmol");jmolSetCallback("menuFile","/java/jmol/appletweb/SageMenu.mnu");</script>\n' # this must stay in the <head>
    1801 
    1802         # TinyMCE and jEditable -- in-place editing of text cells
     1776        # TinyMCE and jEditable -- in-place editing of text cells.
    18031777        if JEDITABLE_TINYMCE:
    18041778            head += """<script type="text/javascript" src="/javascript_local/tiny_mce/tiny_mce.js"></script>
    1805 <script src="/javascript_local/jquery/plugins/jquery.jeditable.mini.js" type="text/javascript" charset="utf-8"></script>
     1779<script src="/javascript_local/jquery/plugins/jeditable/jquery.jeditable.mini.js" type="text/javascript" charset="utf-8"></script>
    18061780<script type="text/javascript">
    18071781
    18081782function toggleEditor(id) {