Commits

Scott Nixon committed 6cd9bf1

Fancybox implemented in Admin. Media not independent yet.

Comments (0)

Files changed (1)

 from django import forms
+from django.utils.safestring import mark_safe
 
 
 class CloudImages(forms.TextInput):
     class Media:
         js = (
-             'jquery/fancybox/jquery.fancybox-1.3.4.pack.js',
+             'admin/jquery/fancybox/jquery.fancybox-1.3.4.pack.js',
             )
         css = {
-            'screen': ('jquery/fancybox/jquery.fancybox-1.3.4.css',),
+            'screen': ('admin/jquery/fancybox/jquery.fancybox-1.3.4.css',),
             }
+
+
+    def __init__(self, attrs=None):
+        self.attrs = {'class': 'cloudimages'}
+        if attrs:
+            self.attrs.update(attrs)
+        super(CloudImages, self).__init__(attrs)
+
+    def render(self, name, value, attrs=None):
+        rendered = super(CloudImages, self).render(name, value, attrs)
+        return rendered + mark_safe(u'''<script type="text/javascript">
+            $(document).ready(function () {
+                $('#id_%s').after("<a class='cloudimages' href='/cloud/'>Upload Image</a>");
+                $('.cloudimages').fancybox({
+                'autoScale'         : false,
+                'transitionIn'      : 'none',
+                'transitionOut'     : 'none',
+                'type'              : 'iframe'
+                 });
+
+            });                        
+            </script>''' % (name,))
+