rafaels-wysihat-engine 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/.gitignore +6 -0
  2. data/CHANGELOG +50 -0
  3. data/MIT-LICENSE +20 -0
  4. data/README.textile +19 -0
  5. data/Rakefile +78 -0
  6. data/TODO +4 -0
  7. data/VERSION +1 -0
  8. data/app/controllers/wysihat_files_controller.rb +30 -0
  9. data/app/helpers/wysihat_files_helper.rb +2 -0
  10. data/app/models/wysihat_file.rb +3 -0
  11. data/app/views/wysihat_files/_form.html.erb +13 -0
  12. data/app/views/wysihat_files/_wysihat_file.html.erb +4 -0
  13. data/app/views/wysihat_files/index.html.erb +5 -0
  14. data/app/views/wysihat_files/new.html.erb +1 -0
  15. data/config/locales/en.yml +5 -0
  16. data/config/locales/pt-BR.yml +5 -0
  17. data/generators/wysihat/templates/css/facebox.css +60 -0
  18. data/generators/wysihat/templates/css/wysihat.css +44 -0
  19. data/generators/wysihat/templates/images/facebox/b.png +0 -0
  20. data/generators/wysihat/templates/images/facebox/bl.png +0 -0
  21. data/generators/wysihat/templates/images/facebox/br.png +0 -0
  22. data/generators/wysihat/templates/images/facebox/closelabel.gif +0 -0
  23. data/generators/wysihat/templates/images/facebox/loading.gif +0 -0
  24. data/generators/wysihat/templates/images/facebox/tl.png +0 -0
  25. data/generators/wysihat/templates/images/facebox/tr.png +0 -0
  26. data/generators/wysihat/templates/images/icons/arrow_redo.png +0 -0
  27. data/generators/wysihat/templates/images/icons/arrow_undo.png +0 -0
  28. data/generators/wysihat/templates/images/icons/exclamation.png +0 -0
  29. data/generators/wysihat/templates/images/icons/image.png +0 -0
  30. data/generators/wysihat/templates/images/icons/link.png +0 -0
  31. data/generators/wysihat/templates/images/icons/page_code.png +0 -0
  32. data/generators/wysihat/templates/images/icons/text_align_center.png +0 -0
  33. data/generators/wysihat/templates/images/icons/text_align_left.png +0 -0
  34. data/generators/wysihat/templates/images/icons/text_align_right.png +0 -0
  35. data/generators/wysihat/templates/images/icons/text_bold.png +0 -0
  36. data/generators/wysihat/templates/images/icons/text_italic.png +0 -0
  37. data/generators/wysihat/templates/images/icons/text_list_bullets.png +0 -0
  38. data/generators/wysihat/templates/images/icons/text_list_numbers.png +0 -0
  39. data/generators/wysihat/templates/images/icons/text_strikethrough.png +0 -0
  40. data/generators/wysihat/templates/images/icons/text_underline.png +0 -0
  41. data/generators/wysihat/templates/javascripts/facebox.js +180 -0
  42. data/generators/wysihat/templates/javascripts/wysihat.js +2073 -0
  43. data/generators/wysihat/templates/javascripts/wysihat_engine.js +79 -0
  44. data/generators/wysihat/templates/javascripts/wysihat_engine_pack.js +1 -0
  45. data/generators/wysihat/templates/migrations/create_wysihat_files.rb +15 -0
  46. data/generators/wysihat/templates/sass/facebox.sass +77 -0
  47. data/generators/wysihat/templates/sass/wysihat.sass +63 -0
  48. data/generators/wysihat/wysihat_generator.rb +79 -0
  49. data/lib/wysihat-engine.rb +40 -0
  50. metadata +123 -0
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ .sass-cache
4
+ coverage
5
+ rdoc
6
+ pkg
data/CHANGELOG ADDED
@@ -0,0 +1,50 @@
1
+ 0.1.8 (December 1st, 2009) - Jeff Kreeftmeijer
2
+ * Merged in champierre's bugfix (bbe4163577f22bfae997c96bdc43eb3fd4497ec0)
3
+
4
+ 0.1.7 (November 6th, 2009) - Jeff Kreeftmeijer
5
+ * Toolbar didn't show up in IE. Fixed :)
6
+
7
+ 0.1.7 (November 1st, 2009) - Jeff Kreeftmeijer
8
+ * added the exclamation.png icon back in the generator.
9
+
10
+ 0.1.7 (October 28th, 2009) - Jeff Kreeftmeijer
11
+ * fixed a bug in the generator; it copied "loading.gif" to "loading.png". Thanks Eric!
12
+ * two functions in the rakefile were called cssify. One should've been called sassify. fixed :)
13
+ * added "render :layout => false" to WysihatFilesController#index
14
+ * put the "exclamation.png" icon back. Was pretty useful after all.
15
+
16
+ 0.1.7 (October 27th, 2009) - Jeff Kreeftmeijer
17
+ * put the facebox images & icons in a subdir
18
+ * created sassify & cssify rake tasks (like the minify one)
19
+ * removed the .sass_cache dir and added it to the .gitignore file.
20
+
21
+ 0.1.6 (October 21st, 2009) - Jeff Kreeftmeijer
22
+ * fixed a bug that sanitized the output (onsumbit) rather than the input (on paste).
23
+
24
+ 0.1.5 (October 11th, 2009) - Jeff Kreeftmeijer
25
+ * fixed a bug that occurred while submitting the form.
26
+
27
+ 0.1.4 (October 5th, 2009) - Jeff Kreeftmeijer
28
+ * removed the :paste button, you can now just paste it in the editor. It will work ;)
29
+ * added a destroy function for the wysihat_files
30
+ * added a locales file to support i18n
31
+
32
+ 0.1.3 (October 5th, 2009) - Jeff Kreeftmeijer
33
+ * added sass support
34
+
35
+ 0.1.2 (October 4th, 2009) - Jeff Kreeftmeijer
36
+
37
+ * added a --no-stylesheet option to the generator
38
+ * removed ResourceController as a dependency. Normal controller now :)
39
+ * moved more javascript to wysihat_engine.js
40
+ * added wysihat_engine_pack.js (all javascripts minfied & concatenated)
41
+
42
+ 0.1.1 (October 3rd, 2009) - Jeff Kreeftmeijer
43
+
44
+ * Moved most of the javascript to the javascript folder (javascripts/wysihat_engine.js) instead of doing it inline.
45
+
46
+ 0.1.0 (October 3rd, 2009) - Jeff Kreeftmeijer
47
+
48
+ * Made it a gem.
49
+ * Created a generator to get rid of the ugly rake task.
50
+ * Removed lots of files (like /public and /config). Everything is in a generator template now.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 80beans
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,19 @@
1
+ h1. WysiHat Engine
2
+
3
+ A Rails engine to help integrate the "37signals WysiHat rich text editor":http://github.com/josh/wysihat/ to your application.
4
+
5
+ h2. Using the WysiHat Engine
6
+
7
+ We've written an "Installation Guide":http://wiki.github.com/80beans/wysihat-engine/installation and some "Examples":http://wiki.github.com/80beans/wysihat-engine/examples to get you started. Any questions? Don't hesitate to "ask":http://github.com/inbox/new/jeffkreeftmeijer.
8
+
9
+ h2. Demo
10
+
11
+ There's a "demo rails app":http://github.com/80beans/wysihat-engine-demo so you can have a quick look around.
12
+
13
+ h2. Contributing
14
+
15
+ Found an issue? Have a great idea? Want to help? Great! Please take a second to read the "Contributing Guide":http://wiki.github.com/80beans/wysihat-engine/contributing.
16
+
17
+ h2. License
18
+
19
+ Copyright (c) 2009 80beans, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,78 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the wysihat_engine plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the wysihat_engine plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'WysiHat Engine'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ desc 'minify and concatenate the javascript files to make a pack'
26
+ task :minify do
27
+ require "yui/compressor"
28
+
29
+ compressor = YUI::JavaScriptCompressor.new(:munge => true)
30
+ dir = 'generators/wysihat/templates/javascripts'
31
+ pack = File.new("#{dir}/wysihat_engine_pack.js", "w")
32
+
33
+ string = ''
34
+ files = ['facebox', 'wysihat', 'wysihat_engine']
35
+ files.each do |file|
36
+ file = open("#{dir}/#{file}.js")
37
+ string << file.read
38
+ file.close
39
+ end
40
+
41
+ pack.write(compressor.compress(string))
42
+ pack.close
43
+ end
44
+
45
+ desc 'create css files from the sass files. It will overwrite files if they already exist.'
46
+ task :cssify do
47
+ files = ['facebox', 'wysihat']
48
+ files.each do |file|
49
+ system "sass generators/wysihat/templates/sass/#{file}.sass generators/wysihat/templates/css/#{file}.css"
50
+ end
51
+ end
52
+
53
+ desc 'create sass files from the css files. It will overwrite files if they already exist.'
54
+ task :sassify do
55
+ files = ['facebox', 'wysihat']
56
+ files.each do |file|
57
+ system "css2sass generators/wysihat/templates/css/#{file}.css generators/wysihat/templates/sass/#{file}.sass"
58
+ end
59
+ end
60
+
61
+
62
+ begin
63
+ require 'jeweler'
64
+ Jeweler::Tasks.new do |gem|
65
+ gem.name = "rafaels-wysihat-engine"
66
+ gem.summary = "A Rails engine to help integrate the 37signals WysiHat rich text editor to your application."
67
+ gem.description = "A Rails engine to help integrate the 37signals WysiHat rich text editor to your application."
68
+ gem.email = "jeff@80beans.com"
69
+ gem.homepage = "http://www.80beans.com/2009/10/01/wysihat-engine/"
70
+ gem.authors = ["Jeff Kreeftmeijer"]
71
+ gem.add_development_dependency "yui-compressor", ">= 0.9.1"
72
+ gem.add_dependency 'paperclip', ">= 2.3.1"
73
+ end
74
+ rescue LoadError
75
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
76
+ end
77
+
78
+ Jeweler::GemcutterTasks.new
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ * add a config.yml file and put some of the settings in there
2
+ * use sprockets for javascripts, stylesheets and images
3
+ * add font selection
4
+ * figure out a way to do a "clean paste". (paste without any markup or styling)
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.8
@@ -0,0 +1,30 @@
1
+ class WysihatFilesController < ApplicationController
2
+ def index
3
+ @wysihat_file, @wysihat_files = WysihatFile.new, WysihatFile.all
4
+ render :layout => false
5
+ end
6
+
7
+ def create
8
+ @wysihat_file = WysihatFile.new(params[:wysihat_file])
9
+
10
+ responds_to_parent do
11
+ render :update do |page|
12
+ if(@wysihat_file.save)
13
+ page.insert_html :bottom, :wysihat_files, :partial => 'wysihat_file', :object => @wysihat_file
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ def destroy
20
+ @wysihat_file = WysihatFile.find(params[:id])
21
+ respond_to do |wants|
22
+ wants.js {
23
+ render :update do |page|
24
+ page.remove "wysihat_file_#{@wysihat_file.id}"
25
+ end
26
+ }
27
+ end
28
+ @wysihat_file.destroy
29
+ end
30
+ end
@@ -0,0 +1,2 @@
1
+ module WysihatFilesHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class WysihatFile < ActiveRecord::Base
2
+ has_attached_file :file
3
+ end
@@ -0,0 +1,13 @@
1
+ <% form_for @wysihat_file, :html => { :multipart => true, :target => 'file_upload' } do |f| %>
2
+
3
+ <p>
4
+ <%= f.label :file %><br/>
5
+ <%= f.file_field :file %>
6
+ </p>
7
+ <p>
8
+ <%= f.submit %>
9
+ </p>
10
+
11
+ <% end %>
12
+
13
+ <iframe id='file_upload' name="file_upload" style="width:1px;height:1px;border:0px" src="about:blank"></iframe>
@@ -0,0 +1,4 @@
1
+ <li id="wysihat_file_<%= wysihat_file.id %>">
2
+ <%= link_to_function(wysihat_file.file_file_name, "$$('iframe##{params[:editor]}')[0].insertImage(this.href); facebox.close();", :href => wysihat_file.file.url) %>
3
+ <%= link_to_remote t('wysihat_files.destroy.name'), :url => wysihat_file, :method => :delete, :confirm => t('wysihat_files.destroy.sure') %>
4
+ </li>
@@ -0,0 +1,5 @@
1
+ <ul id="wysihat_files" class="files">
2
+ <%= render @wysihat_files %>
3
+ </ul>
4
+
5
+ <%= render 'form' %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,5 @@
1
+ en:
2
+ wysihat_files:
3
+ destroy:
4
+ name: delete
5
+ sure: Are you sure you want to delete this file?
@@ -0,0 +1,5 @@
1
+ pt-BR:
2
+ wysihat_files:
3
+ destroy:
4
+ name: deletar
5
+ sure: Você tem certeza que quer deletar este arquivo?
@@ -0,0 +1,60 @@
1
+ #facebox {
2
+ position: absolute;
3
+ top: 0;
4
+ left: 0;
5
+ z-index: 100;
6
+ text-align: left; }
7
+ #facebox .b {
8
+ background: url(../images/facebox/b.png); }
9
+ #facebox .tl {
10
+ background: url(../images/facebox/tl.png); }
11
+ #facebox .tr {
12
+ background: url(../images/facebox/tr.png); }
13
+ #facebox .bl {
14
+ background: url(../images/facebox/bl.png); }
15
+ #facebox .br {
16
+ background: url(../images/facebox/br.png); }
17
+ #facebox .popup {
18
+ position: relative; }
19
+ #facebox table {
20
+ border-collapse: collapse; }
21
+ #facebox td {
22
+ border-bottom: 0;
23
+ padding: 0; }
24
+ #facebox .body {
25
+ padding: 10px;
26
+ background: #fff;
27
+ width: 370px; }
28
+ #facebox .loading, #facebox .image {
29
+ text-align: center; }
30
+ #facebox img {
31
+ border: 0;
32
+ margin: 0; }
33
+ #facebox .footer {
34
+ border-top: 1px solid #DDDDDD;
35
+ padding-top: 5px;
36
+ margin-top: 10px;
37
+ text-align: right; }
38
+ #facebox .tl, #facebox .tr, #facebox .bl, #facebox .br {
39
+ height: 10px;
40
+ width: 10px;
41
+ overflow: hidden;
42
+ padding: 0; }
43
+
44
+ #facebox_overlay {
45
+ position: fixed;
46
+ top: 0px;
47
+ left: 0px;
48
+ height: 100%;
49
+ width: 100%; }
50
+
51
+ .facebox_hide {
52
+ z-index: -100; }
53
+
54
+ .facebox_overlayBG {
55
+ background-color: #000;
56
+ z-index: 99; }
57
+
58
+ * html #facebox_overlay {
59
+ position: absolute;
60
+ height: expression(document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'); }
@@ -0,0 +1,44 @@
1
+ div.editor_toolbar a {
2
+ float: left;
3
+ width: 16px;
4
+ height: 16px;
5
+ margin: 5px;
6
+ background-repeat: no-repeat; }
7
+ div.editor_toolbar span {
8
+ display: none; }
9
+
10
+ .editor_toolbar .button {
11
+ background-image: url('../images/icons/exclamation.png'); }
12
+ .editor_toolbar .bold {
13
+ background-image: url('../images/icons/text_bold.png'); }
14
+ .editor_toolbar .italic {
15
+ background-image: url('../images/icons/text_italic.png'); }
16
+ .editor_toolbar .underline {
17
+ background-image: url('../images/icons/text_underline.png'); }
18
+ .editor_toolbar .strikethrough {
19
+ background-image: url('../images/icons/text_strikethrough.png'); }
20
+ .editor_toolbar .justifyleft {
21
+ background-image: url('../images/icons/text_align_left.png'); }
22
+ .editor_toolbar .justifycenter {
23
+ background-image: url('../images/icons/text_align_center.png'); }
24
+ .editor_toolbar .justifyright {
25
+ background-image: url('../images/icons/text_align_right.png'); }
26
+ .editor_toolbar .undo {
27
+ background-image: url('../images/icons/arrow_undo.png'); }
28
+ .editor_toolbar .redo {
29
+ background-image: url('../images/icons/arrow_redo.png'); }
30
+ .editor_toolbar .insertorderedlist {
31
+ background-image: url('../images/icons/text_list_numbers.png'); }
32
+ .editor_toolbar .insertunorderedlist {
33
+ background-image: url('../images/icons/text_list_bullets.png'); }
34
+ .editor_toolbar .link {
35
+ background-image: url('../images/icons/link.png'); }
36
+ .editor_toolbar .image {
37
+ background-image: url('../images/icons/image.png'); }
38
+ .editor_toolbar .html {
39
+ background-image: url('../images/icons/page_code.png'); }
40
+
41
+ iframe.editor {
42
+ border: 1px solid #999;
43
+ height: 400px;
44
+ width: 100%; }
@@ -0,0 +1,180 @@
1
+ /* Facebox for Prototype
2
+ *
3
+ * This is a slightly updated version of jeffkreeftmeijer's branch of facebox-for-prototype
4
+ * (http://github.com/jeffkreeftmeijer/facebox-for-prototype). The image locations are
5
+ * changed -- from /images/ to /images/facebox/ -- to keep the engine nice and tidy.
6
+ *
7
+ */
8
+
9
+ var Facebox = Class.create({
10
+ initialize : function(extra_set){
11
+ this.settings = {
12
+ loading_image : '/images/facebox/loading.gif',
13
+ close_image : '/images/facebox/closelabel.gif',
14
+ image_types : new RegExp('\.' + ['png', 'jpg', 'jpeg', 'gif'].join('|') + '$', 'i'),
15
+ inited : true,
16
+ facebox_html : '\
17
+ <div id="facebox" style="display:none;"> \
18
+ <div class="popup"> \
19
+ <table id="facebox_table"> \
20
+ <tbody> \
21
+ <tr> \
22
+ <td class="tl"/><td class="b"/><td class="tr"/> \
23
+ </tr> \
24
+ <tr> \
25
+ <td class="b"/> \
26
+ <td class="body"> \
27
+ <div class="content"> \
28
+ </div> \
29
+ <div class="footer"> \
30
+ <a href="#" class="close"> \
31
+ <img src="/images/facebox/closelabel.gif" title="close" class="close_image" /> \
32
+ </a> \
33
+ </div> \
34
+ </td> \
35
+ <td class="b"/> \
36
+ </tr> \
37
+ <tr> \
38
+ <td class="bl"/><td class="b"/><td class="br"/> \
39
+ </tr> \
40
+ </tbody> \
41
+ </table> \
42
+ </div> \
43
+ </div>'
44
+ };
45
+ if (extra_set) Object.extend(this.settings, extra_set);
46
+ $(document.body).insert({bottom: this.settings.facebox_html});
47
+
48
+ this.preload = [ new Image(), new Image() ];
49
+ this.preload[0].src = this.settings.close_image;
50
+ this.preload[1].src = this.settings.loading_image;
51
+
52
+ f = this;
53
+ $$('#facebox .b:first, #facebox .bl, #facebox .br, #facebox .tl, #facebox .tr').each(function(elem){
54
+ f.preload.push(new Image());
55
+ f.preload.slice(-1).src = elem.getStyle('background-image').replace(/url\((.+)\)/, '$1');
56
+ });
57
+
58
+ this.facebox = $('facebox');
59
+ this.keyPressListener = this.watchKeyPress.bindAsEventListener(this);
60
+
61
+ this.watchClickEvents();
62
+ fb = this;
63
+ Event.observe($$('#facebox .close').first(), 'click', function(e){
64
+ Event.stop(e);
65
+ fb.close()
66
+ });
67
+ Event.observe($$('#facebox .close_image').first(), 'click', function(e){
68
+ Event.stop(e);
69
+ fb.close()
70
+ });
71
+ },
72
+
73
+ watchKeyPress : function(e){
74
+ // Close if espace is pressed or if there's a click outside of the facebox
75
+ if (e.keyCode == 27 || !Event.element(e).descendantOf(this.facebox)) this.close();
76
+ },
77
+
78
+ watchClickEvents : function(e){
79
+ var f = this;
80
+ $$('a[rel=facebox]').each(function(elem,i){
81
+ Event.observe(elem, 'click', function(e){
82
+ Event.stop(e);
83
+ f.click_handler(elem, e);
84
+ });
85
+ });
86
+ },
87
+
88
+ loading : function() {
89
+ if ($$('#facebox .loading').length == 1) return true;
90
+
91
+ contentWrapper = $$('#facebox .content').first();
92
+ contentWrapper.childElements().each(function(elem, i){
93
+ elem.remove();
94
+ });
95
+ contentWrapper.insert({bottom: '<div class="loading"><img src="'+this.settings.loading_image+'"/></div>'});
96
+
97
+ var pageScroll = document.viewport.getScrollOffsets();
98
+ this.facebox.setStyle({
99
+ 'top': pageScroll.top + (document.viewport.getHeight() / 10) + 'px',
100
+ 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
101
+ });
102
+
103
+ Event.observe(document, 'keypress', this.keyPressListener);
104
+ Event.observe(document, 'click', this.keyPressListener);
105
+ },
106
+
107
+ reveal : function(data, klass){
108
+ this.loading();
109
+ load = $$('#facebox .loading').first();
110
+ if(load) load.remove();
111
+
112
+ contentWrapper = $$('#facebox .content').first();
113
+ if (klass) contentWrapper.addClassName(klass);
114
+ //contentWrapper.insert({bottom: data});
115
+ contentWrapper.update(data);
116
+
117
+ $$('#facebox .body').first().childElements().each(function(elem,i){
118
+ elem.show();
119
+ });
120
+
121
+ if(!this.facebox.visible()) new Effect.Appear(this.facebox, {duration: .3});
122
+ this.facebox.setStyle({
123
+ 'left': document.viewport.getWidth() / 2 - (this.facebox.getWidth() / 2) + 'px'
124
+ });
125
+
126
+ Event.observe(document, 'keypress', this.keyPressListener);
127
+ Event.observe(document, 'click', this.keyPressListener);
128
+ },
129
+
130
+ close : function(){
131
+ new Effect.Fade('facebox', {duration: .3});
132
+ },
133
+
134
+ click_handler : function(elem, e){
135
+ this.loading();
136
+ Event.stop(e);
137
+
138
+ // support for rel="facebox[.inline_popup]" syntax, to add a class
139
+ var klass = elem.rel.match(/facebox\[\.(\w+)\]/);
140
+ if (klass) klass = klass[1];
141
+
142
+ new Effect.Appear(this.facebox, {duration: .3});
143
+
144
+ if (elem.href.match(/#/)){
145
+ var url = window.location.href.split('#')[0];
146
+ var target = elem.href.replace(url+'#','');
147
+ // var data = $$(target).first();
148
+ var d = $(target);
149
+ // create a new element so as to not delete the original on close()
150
+ var data = new Element(d.tagName);
151
+ data.innerHTML = d.innerHTML;
152
+ this.reveal(data, klass);
153
+ } else if (elem.href.match(this.settings.image_types)) {
154
+ var image = new Image();
155
+ fb = this;
156
+ image.onload = function() {
157
+ fb.reveal('<div class="image"><img src="' + image.src + '" /></div>', klass)
158
+ }
159
+ image.src = elem.href;
160
+ } else {
161
+ var fb = this;
162
+ var url = elem.href;
163
+ new Ajax.Request(url, {
164
+ method : 'get',
165
+ onFailure : function(transport){
166
+ fb.reveal(transport.responseText, klass);
167
+ },
168
+ onSuccess : function(transport){
169
+ fb.reveal(transport.responseText, klass);
170
+ }
171
+ });
172
+
173
+ }
174
+ }
175
+ });
176
+
177
+ var facebox;
178
+ document.observe('dom:loaded', function(){
179
+ facebox = new Facebox();
180
+ });