]> git.openstreetmap.org Git - osqa.git/commitdiff
#SPLUNK-91, modifying the permanent link tool, adding an option to copy to the clipbo...
authorjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 24 Mar 2011 13:59:14 +0000 (13:59 +0000)
committerjordan <jordan@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 24 Mar 2011 13:59:14 +0000 (13:59 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@886 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/media/js/jquery.copy.js [new file with mode: 0644]
forum/skins/default/media/js/jquery.copy.swf [new file with mode: 0644]
forum/skins/default/media/js/osqa.main.js
forum/skins/default/templates/base_content.html
forum/skins/default/templates/node/permanent_link.html
forum/views/commands.py

diff --git a/forum/skins/default/media/js/jquery.copy.js b/forum/skins/default/media/js/jquery.copy.js
new file mode 100644 (file)
index 0000000..93e8475
--- /dev/null
@@ -0,0 +1 @@
+jQuery.copy=function(data){return jQuery.fn.copy.call({},data);};jQuery.fn.copy=function(delimiter){var me=this,flashcopier=(function(fid){return document.getElementById(fid)||(function(){var divnode=document.createElement('div');divnode.id=fid;document.body.appendChild(divnode);return divnode;})();})('_flash_copier'),data=jQuery.map(me,function(bit){return typeof bit==='object'? bit.value||bit.innerHTML.replace(/<.+>/g,''):'';}).join(delimiter||'').replace(/^\s+|\s+$/g,'')||delimiter,divinfo='<embed src="jquery.copy.swf"FlashVars="clipboard='+encodeURIComponent(data)+'"width="0"height="0"'+'type="application/x-shockwave-flash"></embed>';flashcopier.innerHTML=divinfo;return this;};
diff --git a/forum/skins/default/media/js/jquery.copy.swf b/forum/skins/default/media/js/jquery.copy.swf
new file mode 100644 (file)
index 0000000..2cfe371
Binary files /dev/null and b/forum/skins/default/media/js/jquery.copy.swf differ
index d95e4e0523a1f8005f34a1b78029652dcf1a0b48..147cf5482413b98dce69b0b80b72a31aa7f4aeef 100644 (file)
@@ -125,6 +125,10 @@ var response_commands = {
 \r
     set_subscription_status: function(text) {\r
         $('.subscription-status').html(text);\r
+    },\r
+\r
+    copy_url: function(url) {\r
+        $.copy(url);\r
     }\r
 }\r
 \r
index 021437ce4c3115fc3597562056463317b46e3e59..19a6d738cfa90afc3a91034a647550cbc83578dd 100644 (file)
@@ -47,6 +47,7 @@
         /* ]] */
         </script>
         <script type='text/javascript' src='{% media  "/media/js/osqa.main.js" %}'></script>
+        <script type='text/javascript' src='{% media  "/media/js/jquery.copy.js" %}'></script>
         {% if user_messages %}
         <style type="text/css">
             body { margin-top:2.4em; }
index 0ea2941bb8ad33f4394d20fa730531e210bbc556..e4cfcf9d267919b20270b2a547131d4cdb48565a 100644 (file)
@@ -1,13 +1,21 @@
 {% load i18n %}
 
+<p>
+{% blocktrans %}
+Would you like to copy the permanent link to your clipboard?
+{% endblocktrans %}
+</p>
+
+<p>
 {% spaceless %}
 <table>
     <tr>
         <td><label for="permanent_link_url">{% trans "Permanent link" %}:</label></td>
-        <td><input id="permanent_link_url" readonly="readonly" type="text" value="{{ url }}" /></td>
+        <td><input id="permanent_link_url" name="permanent_link_url" readonly="readonly" type="text" value="{{ url }}" /></td>
     </tr>
 </table>
 {% endspaceless %}
+</p>
 
 <script type="text/javascript">
 $(document).ready(function() {
index ae773bdd23476a9d0e0f0314afde7555ac8ffbf6..f88dee8ed2948d17094ad73d5fe352421f14bd71 100644 (file)
@@ -6,6 +6,7 @@ from django.http import HttpResponse, HttpResponseRedirect, Http404
 from django.shortcuts import get_object_or_404, render_to_response
 from django.utils.translation import ungettext, ugettext as _
 from django.template import RequestContext
+from django.template.loader import render_to_string
 from forum.models import *
 from forum.models.node import NodeMetaClass
 from forum.actions import *
@@ -548,8 +549,16 @@ def answer_permanent_link(request, id):
     # Getting the current object URL -- the Application URL + the object relative URL
     url = '%s%s' % (settings.APP_BASE_URL, answer.get_absolute_url())
 
-    # Display the template
-    return render_to_response('node/permanent_link.html', { 'url' : url, })
+    if not request.POST:
+        # Display the template
+        return render_to_response('node/permanent_link.html', { 'url' : url, })
+
+    return {
+        'commands' : {
+            'copy_url' : [request.POST['permanent_link_url'],],
+        },
+        'message' : _("The permanent URL to the answer has been copied to your clipboard."),
+    }
 
 @decorate.withfn(command)
 def award_points(request, user_id, answer_id):