Permalink
Browse files

move preview button among the save buttons; UI cleanup

  • Loading branch information...
1 parent 60701a1 commit 55031c85cab1718b83a6aa7c96303c4aa7880b17 @mislav mislav committed with matthewfallshaw Feb 21, 2010
@@ -0,0 +1,5 @@
+module PagePreviewHelper
+ def save_model_and_continue_editing_button(model)
+ super.to_s + submit_tag('Preview', :class => 'button', :id => 'show-preview')
+ end
+end
@@ -1,2 +1,3 @@
+- include_javascript 'admin/page_preview'
%iframe{:id => 'page-preview', :name => 'page-preview', :src => '/loading-iframe.html', :frameborder => 0, :style => 'width:100%;height:40em;display:none;border:1px solid black;'}
You don't support iframes. No preview for you.
@@ -1,5 +0,0 @@
-= javascript_include_tag 'admin/page_preview'
-%p.buttons
- %input{:type=>'submit', :id => 'show-preview', :value => 'Preview', :class => 'button', :onclick => 'return preview(this)'}
-%div#preview-notice{:style => 'display:none; background-color:#FFC;border:1px solid yellow; color:black;margin:5px 20px -10px 20px; padding: 0.75em;'}
- This is a preview, your changes have not yet been saved!
View
@@ -1,19 +1,10 @@
-# Uncomment this if you reference any of your controllers in activate
-# require_dependency 'application'
-
class PagePreviewExtension < Radiant::Extension
version "1.0"
description "Enables previewing pages from the edit screen"
- url "http://github.com/tricycle/raidant-page-preview-extension/"
+ url "http://github.com/tricycle/raidant-page-preview-extension"
def activate
- # admin.tabs.add "Page Preview", "/admin/page_preview", :after => "Layouts", :visibility => [:all]
- admin.page.edit.add :form_bottom, "/preview/show", :before => 'edit_buttons'
- admin.page.edit.add :form_bottom, "/preview/preview_iframe", :after => 'edit_buttons'
+ admin.page.edit.add :form_bottom, 'preview/preview_iframe', :after => 'edit_buttons'
+ Admin::PagesController.helper PagePreviewHelper
end
-
- def deactivate
- # doesn't work
- end
-
end
@@ -1,20 +1,20 @@
-function preview(button) {
- form = button.form;
- oldtarget = form.target;
- oldaction = form.action;
-
- $('page-preview').show();
- $('preview-notice').show();
-
- location.hash = 'show-preview';
-
- form.target = 'page-preview';
- form.action = '/admin/preview';
-
- form.submit();
-
- form.target = oldtarget;
- form.action = oldaction;
-
- return false;
-}
+document.observe('dom:loaded', function() {
+ $('show-preview').observe('click', function(e) {
+ e.preventDefault()
+
+ var form = this.form,
+ oldTarget = form.target,
+ oldAction = form.action
+
+ try {
+ var iframe = $('page-preview').show()
+ location.hash = this.id
+ form.target = iframe.id
+ form.action = '/admin/preview'
+ form.submit()
+ } finally {
+ form.target = oldTarget
+ form.action = oldAction
+ }
+ })
+})

0 comments on commit 55031c8

Please sign in to comment.