Permalink
Browse files

use application css and built in jquery

  • Loading branch information...
1 parent 2f48034 commit f745f1ad3abbc29460c8bdd2d6431d82ae279879 @philchristensen philchristensen committed Mar 12, 2012
View
@@ -0,0 +1,4 @@
+*.pyc
+*.egg-info
+.DS_Store
+
View
@@ -1,7 +1,14 @@
from django.contrib import admin
from django.conf.urls.defaults import patterns, url
+from django.views.generic.list_detail import object_detail
class PreviewAdmin(admin.ModelAdmin):
+ class Media:
+ js = ['js/jquery.adminpreview.js']
+ css = dict(
+ all = ['css/adminpreview.css']
+ )
+
def admin_slide_preview(self, obj):
"""
Add this to your ModelAdmin:
@@ -22,7 +29,3 @@ def get_urls(self):
url(r'^(?P<object_id>\d+)/preview/$', self.admin_site.admin_view(self.get_preview)),
)
return my_urls + super(PreviewAdmin, self).get_urls()
-
- class Media:
- js = ('js/jquery.js',
- 'js/jquery.adminpreview.js')
@@ -1,21 +1,23 @@
-$(document).ready(function(){
- $(".previewslide").click(function(){
- $.ajax({
- url:$(this).attr('id'),
- context: $(this).parent().parent(),
- success:function(data){
- var $html = $(data);
- $('.previewed').each(function(){
- $(this).remove();
- });
+(function($){
+ $(document).ready(function(){
+ $(".previewslide").click(function(){
+ $.ajax({
+ url:$(this).attr('id'),
+ context: $(this).parent().parent(),
+ success:function(data){
+ var $html = $(data);
+ $('.previewed').each(function(){
+ $(this).remove();
+ });
- if(!$html.hasClass('previewed')){
- $html.addClass('previewed');
- }
+ if(!$html.hasClass('previewed')){
+ $html.addClass('previewed');
+ }
- $html.addClass($(this.context).attr('class'));
- $(this.context).after($html);
- }
+ $html.addClass($(this.context).attr('class'));
+ $(this.context).after($html);
+ }
+ });
});
});
-});
+})(django.jQuery);

0 comments on commit f745f1a

Please sign in to comment.