nitdoc: create js module utils
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 7 Feb 2014 06:58:58 +0000 (01:58 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 20 Feb 2014 19:11:57 +0000 (14:11 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

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

diff --git a/share/nitdoc/js/plugins/utils.js b/share/nitdoc/js/plugins/utils.js
new file mode 100644 (file)
index 0000000..4ce7c04
--- /dev/null
@@ -0,0 +1,41 @@
+/* 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
+ * Utils module\r
+ */\r
+define([\r
+       "jquery",\r
+], function($) {\r
+\r
+       // JQuery Case Insensitive :icontains selector\r
+       $.expr[':'].icontains = function(obj, index, meta, stack){\r
+               return (obj.textContent.replace(/\[[0-9]+\]/g, "") || obj.innerText.replace(/\[[0-9]+\]/g, "") || jQuery(obj).text().replace(/\[[0-9]+\]/g, "") || '').toLowerCase().indexOf(meta[3].toLowerCase()) >= 0;\r
+       };\r
+\r
+       return {\r
+               // Extract anchor part (after #) from URL string\r
+               extractAnchor: function(url) {\r
+                       var index = url.indexOf("#");\r
+                       if (index >= 0) {\r
+                               return url.substring(index + 1);\r
+                       }\r
+                       return null;\r
+               }\r
+       };\r
+});\r