diff --git a/hide_code.py b/hide_code.py deleted file mode 100644 index 115a0bf..0000000 --- a/hide_code.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -from os import path -import shutil - - -def __main__(): - install() - - -def install(nb_path=None, DEBUG=False): - print 'starting install' - current_dir = path.abspath(path.dirname(__file__)) - site_packages_path = os.__file__[:-6] + "site-packages" - - #check notebook path - - install_path = site_packages_path + "/notebook/static/custom" - - if nb_path != None: - install_path = np_path - print "Using " + install_path - - if DEBUG: - print install_path - - # copy js into static/custom directory in Jupyter/iPython directory - if(path.isdir(install_path)): - shutil.copyfile(current_dir + "/hide_code.js", install_path + "/hide_code.js") - print 'Copying hide_code.js to notebook/static/custom/' - - # add require to end of custom.js to auto-load on notebook startup - with open(install_path + "/custom.js", 'a') as customJS: - with open(current_dir + "/auto-load.txt") as auto: - customJS.write(auto.read()) - print "Configured custom.js to auto-load hide_code.js" - else: - print install_path + " does not exist. Exiting hide_code install." \ No newline at end of file diff --git a/hide_code/__init__.pyc b/hide_code/__init__.pyc deleted file mode 100644 index 801c0be..0000000 Binary files a/hide_code/__init__.pyc and /dev/null differ diff --git a/hide_code/hide_code.js b/hide_code/hide_code.js index 154d956..cee8705 100644 --- a/hide_code/hide_code.js +++ b/hide_code/hide_code.js @@ -59,6 +59,24 @@ function ($, celltoolbar){ } } + /** + * Add a toolbar button to toggle visibility of all code cells, input/output prompts, and remove any highlighting for the selected cell. + **/ + function addHideCodeButtonToToolbar(){ + IPython.toolbar.add_buttons_group([ + { + 'label' : 'Hide/show code', + 'icon' : 'fa-code', + 'callback' : function() { + $('.input').toggle(); + $('.prompt').toggle(); + $('.ctb_show').toggle(); + $('.selected').removeClass('selected').addClass('unselected'); + } + } + ]); + } + var hideCodeCallback = ctb.utils.checkbox_ui_generator( 'Hide Code ', hideCodeSetter, hideCodeGetter); var hidePromptCallback = ctb.utils.checkbox_ui_generator('Hide Prompts ', hidePromptSetter, hidePromptGetter); @@ -67,6 +85,7 @@ function ($, celltoolbar){ ctb.register_callback('hide_code.hideCode', hideCodeCallback); ctb.register_callback('hide_code.hidePrompts', hidePromptCallback); ctb.register_preset('Hide',['hide_code.hidePrompts','hide_code.hideCode']); + addHideCodeButtonToToolbar(); } setup(); diff --git a/hide_code/hide_code.pyc b/hide_code/hide_code.pyc deleted file mode 100644 index e268312..0000000 Binary files a/hide_code/hide_code.pyc and /dev/null differ