nitdoc: move clipboard facilities to its own plugin file
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 12 Feb 2014 00:47:38 +0000 (19:47 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 20 Feb 2014 19:11:58 +0000 (14:11 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitdoc/js/nitdoc.js
share/nitdoc/js/plugins/clipboard.js [new file with mode: 0644]
share/nitdoc/js/plugins/ui.js

index 025c668..f064863 100644 (file)
@@ -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 (file)
index 0000000..1d12b85
--- /dev/null
@@ -0,0 +1,54 @@
+/* This file is part of NIT ( http://www.nitlanguage.org ).\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+   http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+   Documentation generator for the nit language.\r
+   Generate API documentation in HTML format from nit source code.\r
+*/\r
+\r
+/*\r
+ * Nitdoc Clipboard\r
+ *\r
+ * Allow user to copy signatures to clipboard\r
+ */\r
+define([\r
+       "jquery",\r
+       "ZeroClipboard"\r
+], function($, ZeroClipboard) {\r
+\r
+       //FIXME mouseover makes button disappear\r
+       var Clipboard = {\r
+               // Allow user to copy signatures to clipboard with ZeroClipboard flahs plugin\r
+               // See: https://github.com/zeroclipboard/ZeroClipboard\r
+               enable: function(copySelector) {\r
+                       $(copySelector).each(function() {\r
+                               var btn = $(document.createElement("button"))\r
+                               .addClass("nitdoc-ui-copy")\r
+                               .attr("data-clipboard-text", $(this).attr("data-untyped-signature"))\r
+                               .append(\r
+                                       $(document.createElement("img"))\r
+                                       .attr("src", './resources/icons/copy.png')\r
+                               );\r
+                               $(this).append(btn);\r
+                       });\r
+\r
+                       var clip = new ZeroClipboard($("button.nitdoc-ui-copy"), {\r
+                               moviePath: "./ZeroClipboard.swf"\r
+                       });\r
+               }\r
+       }\r
+\r
+       Clipboard.enable(".signature");\r
+\r
+       return Clipboard;\r
+});\r
index 0603567..7153da6 100644 (file)
  */\r
 define([\r
        "jquery",\r
-       "ZeroClipboard",\r
        "plugins/utils"\r
-], function($, ZeroClipboard, utils) {\r
+], function($, utils) {\r
 \r
        var UI = {\r
 \r
-               // Allow user to copy signatures to clipboard with ZeroClipboard flahs plugin\r
-               // See: https://github.com/zeroclipboard/ZeroClipboard\r
-               enableCopyToClipboard: function(copySelector) {\r
-                       $(copySelector).each(function() {\r
-                               var btn = $(document.createElement("button"))\r
-                               .addClass("nitdoc-ui-copy")\r
-                               .attr("data-clipboard-text", $(this).attr("data-untyped-signature"))\r
-                               .append(\r
-                                       $(document.createElement("img"))\r
-                                       .attr("src", './resources/icons/copy.png')\r
-                               );\r
-                               $(this).append(btn);\r
-                       });\r
-\r
-                       var clip = new ZeroClipboard($("button.nitdoc-ui-copy"), {\r
-                               moviePath: "./ZeroClipboard.swf"\r
-                       });\r
-               },\r
-\r
                // Allow user to filter sidebar box entries by name\r
                enableSidebarTextFilters: function(filterSelector) {\r
                        var div = $(document.createElement("div"))\r
@@ -178,7 +158,6 @@ define([
                }\r
        };\r
 \r
-       UI.enableCopyToClipboard(".signature");\r
        UI.enableSidebarTextFilters("nav.filterable h3");\r
        UI.enableSidebarTypeFilters("nav.filterable");\r
        UI.enableSearchPageField(".content.fullpage h1:contains('Search')");\r