nitdoc: move folding facilities to its own plugin file
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 12 Feb 2014 00:41:33 +0000 (19:41 -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/folding.js [new file with mode: 0644]
share/nitdoc/js/plugins/ui.js

index 0bc61a7..025c668 100644 (file)
@@ -12,6 +12,7 @@ require.config({
 
 // nitdoc main module
 define([
+       "plugins/folding",
        "plugins/ui",
        "plugins/quicksearch",
        "plugins/github",
diff --git a/share/nitdoc/js/plugins/folding.js b/share/nitdoc/js/plugins/folding.js
new file mode 100644 (file)
index 0000000..6205e47
--- /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 Folding\r
+ *\r
+ * Allow user to fold sidebar blocks\r
+ */\r
+define([\r
+       "jquery"\r
+], function($) {\r
+\r
+       var Folding = {\r
+               enable: function(containerSelector) {\r
+                       var container = $(containerSelector);\r
+                       var foldLink = $(document.createElement("a"))\r
+                       .addClass("nitdoc-ui-fold")\r
+                       .html("-");\r
+\r
+                       container.find("nav h3")\r
+                       .prepend(foldLink)\r
+                       .css("cursor", "pointer")\r
+                       .toggle(\r
+                               function() {\r
+                                       $(this).find("a.nitdoc-ui-fold").html("+");\r
+                                       $(this).nextAll().toggle();\r
+                               },\r
+                               function() {\r
+                                       $(this).find("a.nitdoc-ui-fold").html("-");\r
+                                       $(this).nextAll().toggle();\r
+                               }\r
+                       );\r
+               }\r
+       };\r
+\r
+       Folding.enable(".sidebar");\r
+\r
+       return Folding;\r
+});\r
index fe479e2..0603567 100644 (file)
@@ -29,28 +29,6 @@ define([
 \r
        var UI = {\r
 \r
-               // Allow user to fold sidebar nav elements on click\r
-               enableFolding: function(containerSelector) {\r
-                       var container = $(containerSelector);\r
-                       var foldLink = $(document.createElement("a"))\r
-                       .addClass("nitdoc-ui-fold")\r
-                       .html("-");\r
-\r
-                       container.find("nav h3")\r
-                       .prepend(foldLink)\r
-                       .css("cursor", "pointer")\r
-                       .toggle(\r
-                               function() {\r
-                                       $(this).find("a.nitdoc-ui-fold").html("+");\r
-                                       $(this).nextAll().toggle();\r
-                               },\r
-                               function() {\r
-                                       $(this).find("a.nitdoc-ui-fold").html("-");\r
-                                       $(this).nextAll().toggle();\r
-                               }\r
-                       );\r
-               },\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
@@ -200,7 +178,6 @@ define([
                }\r
        };\r
 \r
-       UI.enableFolding(".sidebar");\r
        UI.enableCopyToClipboard(".signature");\r
        UI.enableSidebarTextFilters("nav.filterable h3");\r
        UI.enableSidebarTypeFilters("nav.filterable");\r