From: Alexandre Terrasa Date: Wed, 14 Aug 2013 13:46:36 +0000 (-0400) Subject: ni_nitdoc: added fast copy past utility to signatures. X-Git-Tag: v0.6.1~35^2~4 X-Git-Url: http://nitlanguage.org ni_nitdoc: added fast copy past utility to signatures. The "copy signature" button is added by JS. Copy to clipboard functionality is provided by the Zeroclipboard JS lib. Signed-off-by: Alexandre Terrasa --- diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..0ca65b9 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,5 @@ +The MIT License (MIT) +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/NOTICE b/NOTICE index e85c0fc..72c94fe 100644 --- a/NOTICE +++ b/NOTICE @@ -36,3 +36,8 @@ Copyright: 2009-2012 Alexis Laferrière 2006 Gabriel Bauman License: GPL 2.0 (see LICENSE-GPL-2) Comment: GPL because the original work is GPL + +Files: share/nitdoc/ZeroClipboard.swf + share/nitdoc/scripts/ZeroClipboard.min.js +Copyright: 2013 Jon Rohan, James M. Greene +Licence: MIT (see LICENSE-MIT) diff --git a/share/nitdoc/ZeroClipboard.swf b/share/nitdoc/ZeroClipboard.swf new file mode 100644 index 0000000..8b707aa Binary files /dev/null and b/share/nitdoc/ZeroClipboard.swf differ diff --git a/share/nitdoc/resources/icons/copy.png b/share/nitdoc/resources/icons/copy.png new file mode 100644 index 0000000..f1d9599 Binary files /dev/null and b/share/nitdoc/resources/icons/copy.png differ diff --git a/share/nitdoc/scripts/ZeroClipboard.min.js b/share/nitdoc/scripts/ZeroClipboard.min.js new file mode 100644 index 0000000..9038520 --- /dev/null +++ b/share/nitdoc/scripts/ZeroClipboard.min.js @@ -0,0 +1,8 @@ +/*! + * zeroclipboard + * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. + * Copyright 2013 Jon Rohan, James M. Greene, . + * Released under the MIT license + * http://zeroclipboard.github.io/ZeroClipboard/ + * v1.2.0-beta.4 + */(function(){"use strict";var a=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),b=function(b,c){var d,e,f,g,h,i;window.getComputedStyle?d=window.getComputedStyle(b,null).getPropertyValue(c):(e=a(c),b.currentStyle?d=b.currentStyle[e]:d=b.style[e]);if(c==="cursor")if(!d||d==="auto"){f=b.tagName.toLowerCase(),g=["a"];for(h=0,i=g.length;h=0?"&nocache=":"?nocache=")+(new Date).getTime():""},k=function(a){var b=[];if(a.trustedDomains){var c;typeof a.trustedDomains=="string"&&a.trustedDomains?c=[a.trustedDomains]:"length"in a.trustedDomains&&(c=a.trustedDomains),b.push("trustedDomain="+encodeURIComponent(c.join(",")))}return typeof a.amdModuleId=="string"&&a.amdModuleId&&b.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),typeof a.cjsModuleId=="string"&&a.cjsModuleId&&b.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),b.join("&")},l=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;c ';b=document.createElement("div"),b.id="global-zeroclipboard-html-bridge",b.setAttribute("class","global-zeroclipboard-container"),b.setAttribute("data-clipboard-ready",!1),b.style.position="absolute",b.style.left="-9999px",b.style.top="-9999px",b.style.width="15px",b.style.height="15px",b.style.zIndex="9999",b.innerHTML=f,document.body.appendChild(b)}a.htmlBridge=b,a.flashBridge=document["global-zeroclipboard-flash-bridge"]||b.children[0].lastElementChild};o.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),g(p,this.options.activeClass),p=null,this.options.text=null},o.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return a==="true"||a===!0},o.prototype.reposition=function(){if(!p)return!1;var a=i(p);this.htmlBridge.style.top=a.top+"px",this.htmlBridge.style.left=a.left+"px",this.htmlBridge.style.width=a.width+"px",this.htmlBridge.style.height=a.height+"px",this.htmlBridge.style.zIndex=a.zIndex+1,this.setSize(a.width,a.height)},o.dispatch=function(a,b){o.prototype._singleton.receiveEvent(a,b)},o.prototype.on=function(a,b){var c=a.toString().split(/\s/g);for(var d=0;d= 0; }; - /* * Quick Search global vars */ @@ -354,6 +353,18 @@ $(document).ready(function() { //Preload filter fields with query string preloadFilters(); + + //Copy to clipboard utility on signatures + $(".signature").each(function(){ + $(this).append( + $("") + .append($("")) + ) + }); + + var clip = new ZeroClipboard($(".copyButton"), { + moviePath: "./ZeroClipboard.swf" + } ); }); /* Parse current URL and return anchor name */ diff --git a/share/nitdoc/styles/main.css b/share/nitdoc/styles/main.css index af49faa..6d1d80a 100644 --- a/share/nitdoc/styles/main.css +++ b/share/nitdoc/styles/main.css @@ -106,6 +106,28 @@ footer { width: 100%; } +article:hover > .signature .copyButton, .copyButton.zeroclipboard-is-hover { + visibility: visible; +} + +.copyButton.zeroclipboard-is-active { + border-color: #0D8921; +} + +.copyButton { + visibility: hidden; + vertical-align: middle; + margin: -2px 0px 0px 10px; + width: 22px; + height: 19px; + padding: 1px; + cursor: pointer; +} + +.copyButton img { + width: 16px; +} + /* Webkit scroll bars */ .menu { diff --git a/src/ni_nitdoc.nit b/src/ni_nitdoc.nit index 32c668a..535614b 100644 --- a/src/ni_nitdoc.nit +++ b/src/ni_nitdoc.nit @@ -203,6 +203,7 @@ abstract class NitdocPage protected fun head do append("") append("") + append("") append("") append("") append("") @@ -929,9 +930,9 @@ class NitdocClass if mclass.arity > 0 and nclass isa AStdClassdef then for ft, bound in mclass.parameter_types do append("
") - append("

{ft}: ") + append("

{ft}: ") bound.html_link(self) - append("

") + append("") append("
formal generic type
") append("
") end @@ -1443,13 +1444,15 @@ redef class MMethodDef classes.add(mproperty.visibility.to_s) page.append("
") if page.ctx.mbuilder.mpropdef2npropdef.has_key(self) then - page.append("

{mproperty.name}") + page.append("

") + page.append("{mproperty.name}") msignature.html_signature(page) - page.append("

") + page.append("") else - page.append("

init") + page.append("

") + page.append("init") msignature.html_signature(page) - page.append("

") + page.append("") end html_info(page) html_comment(page) @@ -1478,9 +1481,9 @@ redef class MVirtualTypeDef if is_redef then classes.add("redef") classes.add(mproperty.visibility.to_s) page.append("
") - page.append("

{mproperty.name}: ") + page.append("

{mproperty.name}: ") bound.html_link(page) - page.append("

") + page.append("") html_info(page) html_comment(page) page.append("
") @@ -1510,6 +1513,19 @@ redef class MSignature return_mtype.html_link(page) end end + + private fun untyped_signature(page: NitdocPage): String do + var res = new Buffer + if not mparameters.is_empty then + res.append("(") + for i in [0..mparameters.length[ do + res.append(mparameters[i].name) + if i < mparameters.length - 1 then res.append(", ") + end + res.append(")") + end + return res.to_s + end end redef class MParameter