From a8f21ff5d78914add8de871d2a3975b74c33f471 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 11 Feb 2014 19:47:38 -0500 Subject: [PATCH] nitdoc: move clipboard facilities to its own plugin file Signed-off-by: Alexandre Terrasa --- share/nitdoc/js/nitdoc.js | 1 + share/nitdoc/js/plugins/clipboard.js | 54 ++++++++++++++++++++++++++++++++++ share/nitdoc/js/plugins/ui.js | 23 +-------------- 3 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 share/nitdoc/js/plugins/clipboard.js diff --git a/share/nitdoc/js/nitdoc.js b/share/nitdoc/js/nitdoc.js index 025c668..f064863 100644 --- a/share/nitdoc/js/nitdoc.js +++ b/share/nitdoc/js/nitdoc.js @@ -13,6 +13,7 @@ require.config({ // nitdoc main module define([ "plugins/folding", + "plugins/clipboard", "plugins/ui", "plugins/quicksearch", "plugins/github", diff --git a/share/nitdoc/js/plugins/clipboard.js b/share/nitdoc/js/plugins/clipboard.js new file mode 100644 index 0000000..1d12b85 --- /dev/null +++ b/share/nitdoc/js/plugins/clipboard.js @@ -0,0 +1,54 @@ +/* This file is part of NIT ( http://www.nitlanguage.org ). + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + Documentation generator for the nit language. + Generate API documentation in HTML format from nit source code. +*/ + +/* + * Nitdoc Clipboard + * + * Allow user to copy signatures to clipboard + */ +define([ + "jquery", + "ZeroClipboard" +], function($, ZeroClipboard) { + + //FIXME mouseover makes button disappear + var Clipboard = { + // Allow user to copy signatures to clipboard with ZeroClipboard flahs plugin + // See: https://github.com/zeroclipboard/ZeroClipboard + enable: function(copySelector) { + $(copySelector).each(function() { + var btn = $(document.createElement("button")) + .addClass("nitdoc-ui-copy") + .attr("data-clipboard-text", $(this).attr("data-untyped-signature")) + .append( + $(document.createElement("img")) + .attr("src", './resources/icons/copy.png') + ); + $(this).append(btn); + }); + + var clip = new ZeroClipboard($("button.nitdoc-ui-copy"), { + moviePath: "./ZeroClipboard.swf" + }); + } + } + + Clipboard.enable(".signature"); + + return Clipboard; +}); diff --git a/share/nitdoc/js/plugins/ui.js b/share/nitdoc/js/plugins/ui.js index 0603567..7153da6 100644 --- a/share/nitdoc/js/plugins/ui.js +++ b/share/nitdoc/js/plugins/ui.js @@ -23,31 +23,11 @@ */ define([ "jquery", - "ZeroClipboard", "plugins/utils" -], function($, ZeroClipboard, utils) { +], function($, utils) { var UI = { - // Allow user to copy signatures to clipboard with ZeroClipboard flahs plugin - // See: https://github.com/zeroclipboard/ZeroClipboard - enableCopyToClipboard: function(copySelector) { - $(copySelector).each(function() { - var btn = $(document.createElement("button")) - .addClass("nitdoc-ui-copy") - .attr("data-clipboard-text", $(this).attr("data-untyped-signature")) - .append( - $(document.createElement("img")) - .attr("src", './resources/icons/copy.png') - ); - $(this).append(btn); - }); - - var clip = new ZeroClipboard($("button.nitdoc-ui-copy"), { - moviePath: "./ZeroClipboard.swf" - }); - }, - // Allow user to filter sidebar box entries by name enableSidebarTextFilters: function(filterSelector) { var div = $(document.createElement("div")) @@ -178,7 +158,6 @@ define([ } }; - UI.enableCopyToClipboard(".signature"); UI.enableSidebarTextFilters("nav.filterable h3"); UI.enableSidebarTypeFilters("nav.filterable"); UI.enableSearchPageField(".content.fullpage h1:contains('Search')"); -- 1.7.9.5