Permalink
Browse files

prepare for preview

  • Loading branch information...
1 parent edd1cb9 commit 65ea969349463ad4e0693bdf99b43013dfafdb79 @saturnflyer saturnflyer committed Mar 26, 2011
Showing with 29 additions and 0 deletions.
  1. +29 −0 public/javascripts/admin/page_preview.js
@@ -0,0 +1,29 @@
+document.observe('dom:loaded', function() {
+ $('show-preview').observe('click', function(e) {
+ e.stop();
+
+ var form = this.form,
+ oldTarget = form.target,
+ oldAction = form.action
+
+ try {
+ var previewer = $('preview_panel').show()
+ var frame = $('page-preview')
+ $$('div.preview_tools a.cancel, div.preview_tools input').each(function(item, index){
+ item.observe('click', function(e){
+ if(item.hasClassName('cancel')) {
+ previewer.hide()
+ frame.src = ''
+ e.stop();
+ }
+ })
+ })
+ form.target = frame.id
+ form.action = '/admin/preview'
+ form.submit()
+ } finally {
+ form.target = oldTarget
+ form.action = oldAction
+ }
+ })
+})

0 comments on commit 65ea969

Please sign in to comment.