From 759d24d246282fe358a867b4f98fed36308c9a30 Mon Sep 17 00:00:00 2001 From: Harris Lapiroff Date: Wed, 6 Jul 2011 14:40:29 -0400 Subject: [PATCH] Updated styles to work in the original admin. Updated the javascript to overload the dismissAddAnotherPopup function as well. --- philo/forms/widgets.py | 2 +- philo/static/philo/css/EmbedWidget.css | 40 ++++++++++++++++++-------- philo/static/philo/js/EmbedWidget.js | 17 +++++++++++ 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/philo/forms/widgets.py b/philo/forms/widgets.py index 739adc7..d223605 100644 --- a/philo/forms/widgets.py +++ b/philo/forms/widgets.py @@ -16,7 +16,7 @@ class EmbedWidget(Textarea): json_ = json.dumps(data) - default_attrs = {'class': 'embedding', 'data-content-types': json_ } + default_attrs = {'class': 'embedding vLargeTextField', 'data-content-types': json_ } if attrs: default_attrs.update(attrs) diff --git a/philo/static/philo/css/EmbedWidget.css b/philo/static/philo/css/EmbedWidget.css index 3b21016..6b85410 100644 --- a/philo/static/philo/css/EmbedWidget.css +++ b/philo/static/philo/css/EmbedWidget.css @@ -1,15 +1,20 @@ .embed-widget{ - background:#DDD; - padding:2px; - border:1px solid #CCC; - border-radius:5px; - -webkit-border-radius:5px; - -moz-border-radius:5px; - display:inline-block; - margin:0 -3px; + float:left; } .embed-toolbar{ - padding-bottom:3px; + border:1px solid #CCC; + border-bottom:0; + padding:3px 5px; + background:#EEE -webkit-linear-gradient(#F5F5F5, #DDD); + background:#EEE -moz-linear-gradient(#F5F5F5, #DDD); + background-color:#EEE; +} +.embed-widget textarea{ + margin-top:0; +} +.embed-widget button, .embed-widget select{ + vertical-align:middle; + margin-right:3px; } .embed-toolbar button{ background:#FFF; @@ -19,9 +24,6 @@ -moz-border-radius:3px; color:#666; } -.embed-toolbar select, .embed-toolbar button{ - margin-right:3px; -} .embed-toolbar button:hover{ color:#444; } @@ -29,4 +31,18 @@ color:#FFF; background:#666; border-color:#666; +} + +.grappelli .embed-widget{ + background:#DDD; + padding:2px; + border:1px solid #CCC; + border-radius:5px; + -webkit-border-radius:5px; + -moz-border-radius:5px; + display:inline-block; + margin:0 -3px; +} +.grappelli .embed-toolbar{ + padding-bottom:3px; } \ No newline at end of file diff --git a/philo/static/philo/js/EmbedWidget.js b/philo/static/philo/js/EmbedWidget.js index 210bb9a..f946740 100644 --- a/philo/static/philo/js/EmbedWidget.js +++ b/philo/static/philo/js/EmbedWidget.js @@ -40,6 +40,23 @@ // otherwise, do what you usually do oldDismissRelatedLookupPopup.apply(this, arguments); } + + // overload the dismissAddAnotherPopup function + oldDismissAddAnotherPopup = window.dismissAddAnotherPopup; + window.dismissAddAnotherPopup = function (win, newId, newRepr) { + var name = windowname_to_id(win.name), + elem = $('#'+win.name), val; + if (elem.parent().hasClass('embed-widget')) { + dismissRelatedLookupPopup(win, newId); + } + // otherwise, do what you usually do + oldDismissAddAnotherPopup.apply(this, arguments); + } + + // Add grappelli to the body class if the admin is grappelli. This will allow us to customize styles accordingly. + if (window.grappelli) { + $(document.body).addClass('grappelli'); + } }, parseContentTypes: function () { var string = widget.EmbedFields.eq(0).attr('data-content-types'), -- 2.20.1