social_stream 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/README.rdoc +17 -7
  2. data/app/controllers/frontpage_controller.rb +16 -0
  3. data/app/models/actor.rb +25 -10
  4. data/app/models/user.rb +4 -0
  5. data/app/views/{home → activities}/_activities.html.erb +4 -4
  6. data/app/views/activities/_new.html.erb +2 -2
  7. data/app/views/comments/_new.html.erb +1 -1
  8. data/app/views/frontpage/_header.html.erb +23 -0
  9. data/app/views/frontpage/_sponsor.html.erb +13 -0
  10. data/app/views/frontpage/index.html.erb +87 -0
  11. data/app/views/groups/_follow.html.erb +9 -0
  12. data/app/views/groups/_followers.html.erb +14 -0
  13. data/app/views/groups/_logo.html.erb +4 -0
  14. data/app/views/groups/_middle_show.html.erb +7 -0
  15. data/app/views/groups/_right_show.html.erb +6 -0
  16. data/app/views/groups/_tabs.html.erb +32 -0
  17. data/app/views/groups/show.html.erb +5 -12
  18. data/app/views/home/_contacts.html.erb +17 -0
  19. data/app/views/home/_groups.html.erb +6 -7
  20. data/app/views/home/_location.html.erb +1 -1
  21. data/app/views/home/_middle.html.erb +4 -0
  22. data/app/views/home/_options.html.erb +14 -0
  23. data/app/views/home/_right.html.erb +22 -0
  24. data/app/views/home/index.html.erb +15 -3
  25. data/app/views/layouts/_footer.html.erb +12 -0
  26. data/app/views/layouts/_header.erb +36 -0
  27. data/app/views/layouts/application.html.erb +81 -0
  28. data/app/views/layouts/frontpage.html.erb +51 -0
  29. data/app/views/ties/_suggestions.html.erb +18 -14
  30. data/app/views/users/_contacts.html.erb +19 -0
  31. data/app/views/users/_logo.html.erb +6 -0
  32. data/app/views/users/_menu.html.erb +30 -0
  33. data/app/views/users/_middle_show.html.erb +2 -0
  34. data/app/views/users/_profile.html.erb +121 -0
  35. data/app/views/users/_right_show.html.erb +5 -0
  36. data/app/views/users/show.html.erb +18 -0
  37. data/config/locales/en.yml +1 -1
  38. data/config/routes.rb +5 -1
  39. data/init.rb +2 -0
  40. data/lib/generators/social_stream/install_generator.rb +13 -1
  41. data/lib/generators/social_stream/templates/public/images/boxy/boxy-ne.png +0 -0
  42. data/lib/generators/social_stream/templates/public/images/boxy/boxy-nw.png +0 -0
  43. data/lib/generators/social_stream/templates/public/images/boxy/boxy-se.png +0 -0
  44. data/lib/generators/social_stream/templates/public/images/boxy/boxy-sw.png +0 -0
  45. data/lib/generators/social_stream/templates/public/images/btn/_notes/btn_certificates.png.mno +4 -0
  46. data/lib/generators/social_stream/templates/public/images/btn/arrows-ffffff.png +0 -0
  47. data/lib/generators/social_stream/templates/public/images/btn/bold.png +0 -0
  48. data/lib/generators/social_stream/templates/public/images/btn/btn_activities.png +0 -0
  49. data/lib/generators/social_stream/templates/public/images/btn/btn_bookmark.png +0 -0
  50. data/lib/generators/social_stream/templates/public/images/btn/btn_browse.png +0 -0
  51. data/lib/generators/social_stream/templates/public/images/btn/btn_certificates.png +0 -0
  52. data/lib/generators/social_stream/templates/public/images/btn/btn_check.png +0 -0
  53. data/lib/generators/social_stream/templates/public/images/btn/btn_conferences.png +0 -0
  54. data/lib/generators/social_stream/templates/public/images/btn/btn_config.png +0 -0
  55. data/lib/generators/social_stream/templates/public/images/btn/btn_date.png +0 -0
  56. data/lib/generators/social_stream/templates/public/images/btn/btn_delete.png +0 -0
  57. data/lib/generators/social_stream/templates/public/images/btn/btn_documents.png +0 -0
  58. data/lib/generators/social_stream/templates/public/images/btn/btn_embebed.png +0 -0
  59. data/lib/generators/social_stream/templates/public/images/btn/btn_exit.png +0 -0
  60. data/lib/generators/social_stream/templates/public/images/btn/btn_find.png +0 -0
  61. data/lib/generators/social_stream/templates/public/images/btn/btn_follow.png +0 -0
  62. data/lib/generators/social_stream/templates/public/images/btn/btn_follower.png +0 -0
  63. data/lib/generators/social_stream/templates/public/images/btn/btn_foward.png +0 -0
  64. data/lib/generators/social_stream/templates/public/images/btn/btn_friend.png +0 -0
  65. data/lib/generators/social_stream/templates/public/images/btn/btn_gallery.png +0 -0
  66. data/lib/generators/social_stream/templates/public/images/btn/btn_help.png +0 -0
  67. data/lib/generators/social_stream/templates/public/images/btn/btn_home.png +0 -0
  68. data/lib/generators/social_stream/templates/public/images/btn/btn_inbox.png +0 -0
  69. data/lib/generators/social_stream/templates/public/images/btn/btn_info.png +0 -0
  70. data/lib/generators/social_stream/templates/public/images/btn/btn_like.png +0 -0
  71. data/lib/generators/social_stream/templates/public/images/btn/btn_next.png +0 -0
  72. data/lib/generators/social_stream/templates/public/images/btn/btn_notifications.png +0 -0
  73. data/lib/generators/social_stream/templates/public/images/btn/btn_outline.png +0 -0
  74. data/lib/generators/social_stream/templates/public/images/btn/btn_partner.png +0 -0
  75. data/lib/generators/social_stream/templates/public/images/btn/btn_photo.png +0 -0
  76. data/lib/generators/social_stream/templates/public/images/btn/btn_profile.png +0 -0
  77. data/lib/generators/social_stream/templates/public/images/btn/btn_rank.png +0 -0
  78. data/lib/generators/social_stream/templates/public/images/btn/btn_security.png +0 -0
  79. data/lib/generators/social_stream/templates/public/images/btn/btn_send.png +0 -0
  80. data/lib/generators/social_stream/templates/public/images/btn/btn_share.png +0 -0
  81. data/lib/generators/social_stream/templates/public/images/btn/btn_spam.png +0 -0
  82. data/lib/generators/social_stream/templates/public/images/btn/btn_tag.png +0 -0
  83. data/lib/generators/social_stream/templates/public/images/btn/btn_video.png +0 -0
  84. data/lib/generators/social_stream/templates/public/images/btn/btn_write.png +0 -0
  85. data/lib/generators/social_stream/templates/public/images/btn/close.png +0 -0
  86. data/lib/generators/social_stream/templates/public/images/btn/facebook.png +0 -0
  87. data/lib/generators/social_stream/templates/public/images/btn/flyer.png +0 -0
  88. data/lib/generators/social_stream/templates/public/images/btn/index_71.png +0 -0
  89. data/lib/generators/social_stream/templates/public/images/btn/italic.png +0 -0
  90. data/lib/generators/social_stream/templates/public/images/btn/keynote.png +0 -0
  91. data/lib/generators/social_stream/templates/public/images/btn/live.png +0 -0
  92. data/lib/generators/social_stream/templates/public/images/btn/new.png +0 -0
  93. data/lib/generators/social_stream/templates/public/images/btn/next_conference.png +0 -0
  94. data/lib/generators/social_stream/templates/public/images/btn/next_space.png +0 -0
  95. data/lib/generators/social_stream/templates/public/images/btn/notifications.png +0 -0
  96. data/lib/generators/social_stream/templates/public/images/btn/pixel.png +0 -0
  97. data/lib/generators/social_stream/templates/public/images/btn/point_blue.png +0 -0
  98. data/lib/generators/social_stream/templates/public/images/btn/point_gray.png +0 -0
  99. data/lib/generators/social_stream/templates/public/images/btn/subtime.png +0 -0
  100. data/lib/generators/social_stream/templates/public/images/btn/tag_cloud.png +0 -0
  101. data/lib/generators/social_stream/templates/public/images/btn/time.png +0 -0
  102. data/lib/generators/social_stream/templates/public/images/btn/title_background.png +0 -0
  103. data/lib/generators/social_stream/templates/public/images/btn/viewer.png +0 -0
  104. data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif +0 -0
  105. data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.png +0 -0
  106. data/lib/generators/social_stream/templates/public/images/frontpage/comments.png +0 -0
  107. data/lib/generators/social_stream/templates/public/images/frontpage/facebook.png +0 -0
  108. data/lib/generators/social_stream/templates/public/images/frontpage/green_sq.png +0 -0
  109. data/lib/generators/social_stream/templates/public/images/frontpage/join.gif +0 -0
  110. data/lib/generators/social_stream/templates/public/images/frontpage/meet.gif +0 -0
  111. data/lib/generators/social_stream/templates/public/images/frontpage/meet.png +0 -0
  112. data/lib/generators/social_stream/templates/public/images/frontpage/people.png +0 -0
  113. data/lib/generators/social_stream/templates/public/images/frontpage/purple_sq.png +0 -0
  114. data/lib/generators/social_stream/templates/public/images/frontpage/right_comments.gif +0 -0
  115. data/lib/generators/social_stream/templates/public/images/frontpage/right_organizers.gif +0 -0
  116. data/lib/generators/social_stream/templates/public/images/frontpage/right_people.gif +0 -0
  117. data/lib/generators/social_stream/templates/public/images/frontpage/right_social.gif +0 -0
  118. data/lib/generators/social_stream/templates/public/images/frontpage/right_tags.gif +0 -0
  119. data/lib/generators/social_stream/templates/public/images/frontpage/right_webcam.gif +0 -0
  120. data/lib/generators/social_stream/templates/public/images/frontpage/share.gif +0 -0
  121. data/lib/generators/social_stream/templates/public/images/frontpage/share.png +0 -0
  122. data/lib/generators/social_stream/templates/public/images/frontpage/tags.png +0 -0
  123. data/lib/generators/social_stream/templates/public/images/frontpage/yellow_sq.png +0 -0
  124. data/lib/generators/social_stream/templates/public/images/logo.png +0 -0
  125. data/lib/generators/social_stream/templates/public/images/logo/dit.png +0 -0
  126. data/lib/generators/social_stream/templates/public/images/logos/original/group.png +0 -0
  127. data/lib/generators/social_stream/templates/public/images/logos/original/user.png +0 -0
  128. data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +84 -0
  129. data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-personalized-1.5.2.packed.js +1 -0
  130. data/lib/generators/social_stream/templates/public/javascripts/jquery.boxy.js +570 -0
  131. data/lib/generators/social_stream/templates/public/javascripts/jquery.livequery.js +250 -0
  132. data/lib/generators/social_stream/templates/public/javascripts/main.js +82 -0
  133. data/lib/generators/social_stream/templates/public/javascripts/menu.js +99 -0
  134. data/lib/generators/social_stream/templates/public/javascripts/superfish.js +121 -0
  135. data/lib/generators/social_stream/templates/public/stylesheets/activities.css +231 -0
  136. data/lib/generators/social_stream/templates/public/stylesheets/base.css +68 -0
  137. data/lib/generators/social_stream/templates/public/stylesheets/boxy.css +49 -0
  138. data/lib/generators/social_stream/templates/public/stylesheets/browse.css +120 -0
  139. data/lib/generators/social_stream/templates/public/stylesheets/frontpage.css +708 -0
  140. data/lib/generators/social_stream/templates/public/stylesheets/header.css +107 -0
  141. data/lib/generators/social_stream/templates/public/stylesheets/home.css +98 -0
  142. data/lib/generators/social_stream/templates/public/stylesheets/index.css +632 -0
  143. data/lib/generators/social_stream/templates/public/stylesheets/menu.css +83 -0
  144. data/lib/generators/social_stream/templates/public/stylesheets/middle.css +94 -0
  145. data/lib/generators/social_stream/templates/public/stylesheets/right.css +57 -0
  146. data/lib/generators/social_stream/templates/public/stylesheets/social_stream.css +75 -0
  147. data/lib/generators/social_stream/templates/seeds.yml +1 -1
  148. data/lib/paperclip/{ext.rb → social_stream.rb} +0 -0
  149. data/lib/social_stream/models/actor.rb +1 -1
  150. data/lib/social_stream/rails.rb +3 -2
  151. data/lib/social_stream/rails/common.rb +1 -0
  152. data/lib/social_stream/version.rb +1 -1
  153. data/social_stream.gemspec +2 -1
  154. metadata +156 -11
@@ -0,0 +1,5 @@
1
+ <%= render :partial => 'logo' %>
2
+ <div class="space_center">
3
+ </div>
4
+ <%= render :partial => 'menu' %>
5
+
@@ -0,0 +1,18 @@
1
+ <% content_for :middle do %>
2
+ <%= render :partial => 'middle_show' %>
3
+ <% end %>
4
+
5
+ <% content_for :right do %>
6
+ <%= render :partial => 'right_show' %>
7
+ <% end %>
8
+
9
+ <%= render :partial => 'home/location' %>
10
+
11
+ <br class="clearfloat" />
12
+ <div class="space_center">
13
+ </div>
14
+
15
+ <%= render :partial => "users/mygroups" %>
16
+ <%= render :partial => "activities/activities",
17
+ :locals => { :activities => @user.wall_profile,
18
+ :owner => @user } %>
@@ -9,10 +9,10 @@ en:
9
9
  like: I like
10
10
  unlike: Already I do not like
11
11
  last: Last Activities
12
- all_rights_reserved: All rights reserved
13
12
  comment:
14
13
  input: "Write a comment..."
15
14
  confirm_delete: "Delete comment?"
15
+ copyright: "2010 Copyright - All rights reserved"
16
16
  days: Days
17
17
  delete:
18
18
  confirm: Delete %{element}}?
data/config/routes.rb CHANGED
@@ -1,9 +1,11 @@
1
1
  Rails.application.routes.draw do
2
2
  devise_for :users
3
3
  resources :users
4
- resources :groups
5
4
 
6
5
  match 'home' => 'home#index', :as => :home
6
+ match 'home' => 'home#index', :as => :user_root # devise after_sign_in_path_for
7
+
8
+ resources :groups
7
9
 
8
10
  resources :ties
9
11
  resources :activities do
@@ -11,4 +13,6 @@ Rails.application.routes.draw do
11
13
  end
12
14
  resources :posts
13
15
  resources :comments
16
+
17
+ root :to => "frontpage#index"
14
18
  end
data/init.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  require 'social_stream'
2
2
 
3
3
  SocialStream::Rails::Common.inflections
4
+
5
+ AssetBundler.paths += Array(File.join(File.dirname(__FILE__), 'app', 'assets'))
@@ -1,6 +1,9 @@
1
1
  class SocialStream::InstallGenerator < Rails::Generators::Base #:nodoc:
2
2
  include Rails::Generators::Migration
3
3
 
4
+ hook_for :javascript
5
+ hook_for :authentication
6
+
4
7
  source_root File.expand_path('../templates', __FILE__)
5
8
 
6
9
  def create_initializer_file
@@ -11,6 +14,16 @@ class SocialStream::InstallGenerator < Rails::Generators::Base #:nodoc:
11
14
  copy_file 'seeds.yml', 'db/seeds/social_stream.yml'
12
15
  end
13
16
 
17
+ def copy_public
18
+ directory "public"
19
+ end
20
+
21
+ def create_application_layout
22
+ copy_file File.join(File.dirname(__FILE__), '../../../',
23
+ 'app/views/layouts/application.html.erb'),
24
+ 'app/views/layouts/application.html.erb'
25
+ end
26
+
14
27
  def create_seed_code
15
28
  seed_code = "\nSocialStream.seed!"
16
29
 
@@ -30,5 +43,4 @@ class SocialStream::InstallGenerator < Rails::Generators::Base #:nodoc:
30
43
  migration_template 'migration.rb', 'db/migrate/create_social_stream.rb'
31
44
  end
32
45
 
33
- hook_for :authentication
34
46
  end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8" ?>
2
+ <info>
3
+ <infoitem key="fw_source" value="/FINALES/images/buttons/btn_info.png" />
4
+ </info>
@@ -0,0 +1,84 @@
1
+ (function($){
2
+ /* hoverIntent by Brian Cherne */
3
+ $.fn.hoverIntent = function(f,g) {
4
+ // default configuration options
5
+ var cfg = {
6
+ sensitivity: 7,
7
+ interval: 100,
8
+ timeout: 0
9
+ };
10
+ // override configuration options with user supplied object
11
+ cfg = $.extend(cfg, g ? { over: f, out: g } : f );
12
+
13
+ // instantiate variables
14
+ // cX, cY = current X and Y position of mouse, updated by mousemove event
15
+ // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
16
+ var cX, cY, pX, pY;
17
+
18
+ // A private function for getting mouse position
19
+ var track = function(ev) {
20
+ cX = ev.pageX;
21
+ cY = ev.pageY;
22
+ };
23
+
24
+ // A private function for comparing current and previous mouse position
25
+ var compare = function(ev,ob) {
26
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
27
+ // compare mouse positions to see if they've crossed the threshold
28
+ if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
29
+ $(ob).unbind("mousemove",track);
30
+ // set hoverIntent state to true (so mouseOut can be called)
31
+ ob.hoverIntent_s = 1;
32
+ return cfg.over.apply(ob,[ev]);
33
+ } else {
34
+ // set previous coordinates for next time
35
+ pX = cX; pY = cY;
36
+ // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
37
+ ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
38
+ }
39
+ };
40
+
41
+ // A private function for delaying the mouseOut function
42
+ var delay = function(ev,ob) {
43
+ ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
44
+ ob.hoverIntent_s = 0;
45
+ return cfg.out.apply(ob,[ev]);
46
+ };
47
+
48
+ // A private function for handling mouse 'hovering'
49
+ var handleHover = function(e) {
50
+ // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
51
+ var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
52
+ while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
53
+ if ( p == this ) { return false; }
54
+
55
+ // copy objects to be passed into t (required for event object to be passed in IE)
56
+ var ev = jQuery.extend({},e);
57
+ var ob = this;
58
+
59
+ // cancel hoverIntent timer if it exists
60
+ if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }
61
+
62
+ // else e.type == "onmouseover"
63
+ if (e.type == "mouseover") {
64
+ // set "previous" X and Y position based on initial entry point
65
+ pX = ev.pageX; pY = ev.pageY;
66
+ // update "current" X and Y position based on mousemove
67
+ $(ob).bind("mousemove",track);
68
+ // start polling interval (self-calling timeout) to compare mouse coordinates over time
69
+ if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}
70
+
71
+ // else e.type == "onmouseout"
72
+ } else {
73
+ // unbind expensive mousemove event
74
+ $(ob).unbind("mousemove",track);
75
+ // if hoverIntent state is true, then call the mouseOut function after the specified delay
76
+ if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
77
+ }
78
+ };
79
+
80
+ // bind the function to the two event listeners
81
+ return this.mouseover(handleHover).mouseout(handleHover);
82
+ };
83
+
84
+ })(jQuery);
@@ -0,0 +1 @@
1
+ eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(3(C){C.8={3o:{19:3(E,F,H){6 G=C.8[E].1h;21(6 D 3p H){G.1I[D]=G.1I[D]||[];G.1I[D].28([F,H[D]])}},2P:3(D,F,E){6 H=D.1I[F];5(!H){7}21(6 G=0;G<H.k;G++){5(D.b[H[G][0]]){H[G][1].1H(D.c,E)}}}},1l:{},n:3(D){5(C.8.1l[D]){7 C.8.1l[D]}6 E=C(\'<2a 3s="8-3r">\').j(D).n({3q:"3i",2g:"-2A",3g:"-2A",1r:"1w"}).22("2C");C.8.1l[D]=!!((!(/3I|3P/).12(E.n("3z"))||(/^[1-9]/).12(E.n("2T"))||(/^[1-9]/).12(E.n("2E"))||!(/2v/).12(E.n("3w"))||!(/3S|3C\\(0, 0, 0, 0\\)/).12(E.n("3D"))));3E{C("2C").2w(0).3B(E.2w(0))}3x(F){}7 C.8.1l[D]},3y:3(D){C(D).v("1p","2I").n("2q","2v")},3H:3(D){C(D).v("1p","3O").n("2q","")},3Q:3(G,E){6 D=/2g/.12(E||"2g")?"3N":"3M",F=e;5(G[D]>0){7 t}G[D]=1;F=G[D]>0?t:e;G[D]=0;7 F}};6 B=C.2e.W;C.2e.W=3(){C("*",2).19(2).z("W");7 B.1H(2,2M)};3 A(E,F,G){6 D=C[E][F].35||[];D=(1F D=="1E"?D.2h(/,?\\s+/):D);7(C.1j(G,D)!=-1)}C.1i=3(E,D){6 F=E.2h(".")[0];E=E.2h(".")[1];C.2e[E]=3(J){6 H=(1F J=="1E"),I=2D.1h.3J.2P(2M,1);5(H&&A(F,E,J)){6 G=C.i(2[0],E);7(G?G[J].1H(G,I):1n)}7 2.14(3(){6 K=C.i(2,E);5(H&&K&&C.3v(K[J])){K[J].1H(K,I)}o{5(!H){C.i(2,E,3e C[F][E](2,J))}}})};C[F][E]=3(I,H){6 G=2;2.15=E;2.2H=F+"-"+E;2.b=C.1A({},C.1i.1k,C[F][E].1k,H);2.c=C(I).u("1e."+E,3(L,J,K){7 G.1e(J,K)}).u("2j."+E,3(K,J){7 G.2j(J)}).u("W",3(){7 G.1b()});2.23()};C[F][E].1h=C.1A({},C.1i.1h,D)};C.1i.1h={23:3(){},1b:3(){2.c.1q(2.15)},2j:3(D){7 2.b[D]},1e:3(D,E){2.b[D]=E;5(D=="f"){2.c[E?"j":"r"](2.2H+"-f")}},1X:3(){2.1e("f",e)},1P:3(){2.1e("f",t)}};C.1i.1k={f:e};C.8.2J={3h:3(){6 D=2;2.c.u("3d."+2.15,3(E){7 D.2G(E)});5(C.x.13){2.2K=2.c.v("1p");2.c.v("1p","2I")}2.3c=e},38:3(){2.c.16("."+2.15);(C.x.13&&2.c.v("1p",2.2K))},2G:3(F){(2.V&&2.1o(F));2.1C=F;6 E=2,G=(F.39==1),D=(1F 2.b.25=="1E"?C(F.2f).2x().19(F.2f).y(2.b.25).k:e);5(!G||D||!2.2S(F)){7 t}2.1D=!2.b.26;5(!2.1D){2.3a=1x(3(){E.1D=t},2.b.26)}5(2.2m(F)&&2.1T(F)){2.V=(2.1U(F)!==e);5(!2.V){F.3b();7 t}}2.2n=3(H){7 E.2r(H)};2.2l=3(H){7 E.1o(H)};C(2N).u("2O."+2.15,2.2n).u("2t."+2.15,2.2l);7 e},2r:3(D){5(C.x.13&&!D.3j){7 2.1o(D)}5(2.V){2.1V(D);7 e}5(2.2m(D)&&2.1T(D)){2.V=(2.1U(2.1C,D)!==e);(2.V?2.1V(D):2.1o(D))}7!2.V},1o:3(D){C(2N).16("2O."+2.15,2.2n).16("2t."+2.15,2.2l);5(2.V){2.V=e;2.2u(D)}7 e},2m:3(D){7(29.3m(29.2z(2.1C.2L-D.2L),29.2z(2.1C.2s-D.2s))>=2.b.2F)},1T:3(D){7 2.1D},1U:3(D){},1V:3(D){},2u:3(D){},2S:3(D){7 t}};C.8.2J.1k={25:U,2F:1,26:0}})(27);(3(A){A.1i("8.4",{23:3(){2.b.Z+=".4";2.1m(t)},1e:3(B,C){5((/^d/).12(B)){2.1v(C)}o{2.b[B]=C;2.1m()}},k:3(){7 2.$4.k},1Q:3(B){7 B.2R&&B.2R.1g(/\\s/g,"2Q").1g(/[^A-4o-4x-9\\-2Q:\\.]/g,"")||2.b.2X+A.i(B)},8:3(C,B){7{b:2.b,4u:C,30:B,11:2.$4.11(C)}},1m:3(O){2.$l=A("1O:4p(a[p])",2.c);2.$4=2.$l.1G(3(){7 A("a",2)[0]});2.$h=A([]);6 P=2,D=2.b;2.$4.14(3(R,Q){5(Q.X&&Q.X.1g("#","")){P.$h=P.$h.19(Q.X)}o{5(A(Q).v("p")!="#"){A.i(Q,"p.4",Q.p);A.i(Q,"q.4",Q.p);6 T=P.1Q(Q);Q.p="#"+T;6 S=A("#"+T);5(!S.k){S=A(D.2d).v("1s",T).j(D.1u).4l(P.$h[R-1]||P.c);S.i("1b.4",t)}P.$h=P.$h.19(S)}o{D.f.28(R+1)}}});5(O){2.c.j(D.2b);2.$h.14(3(){6 Q=A(2);Q.j(D.1u)});5(D.d===1n){5(20.X){2.$4.14(3(S,Q){5(Q.X==20.X){D.d=S;5(A.x.13||A.x.43){6 R=A(20.X),T=R.v("1s");R.v("1s","");1x(3(){R.v("1s",T)},44)}4m(0,0);7 e}})}o{5(D.1c){6 J=46(A.1c("8-4"+A.i(P.c)),10);5(J&&P.$4[J]){D.d=J}}o{5(P.$l.y("."+D.m).k){D.d=P.$l.11(P.$l.y("."+D.m)[0])}}}}D.d=D.d===U||D.d!==1n?D.d:0;D.f=A.41(D.f.40(A.1G(2.$l.y("."+D.1a),3(R,Q){7 P.$l.11(R)}))).31();5(A.1j(D.d,D.f)!=-1){D.f.3V(A.1j(D.d,D.f),1)}2.$h.j(D.18);2.$l.r(D.m);5(D.d!==U){2.$h.w(D.d).1S().r(D.18);2.$l.w(D.d).j(D.m);6 K=3(){A(P.c).z("1K",[P.Y("1K"),P.8(P.$4[D.d],P.$h[D.d])],D.1S)};5(A.i(2.$4[D.d],"q.4")){2.q(D.d,K)}o{K()}}A(3U).u("3W",3(){P.$4.16(".4");P.$l=P.$4=P.$h=U})}21(6 G=0,N;N=2.$l[G];G++){A(N)[A.1j(G,D.f)!=-1&&!A(N).1f(D.m)?"j":"r"](D.1a)}5(D.17===e){2.$4.1q("17.4")}6 C,I,B={"3X-2E":0,1R:1},E="3Z";5(D.1d&&D.1d.3Y==2D){C=D.1d[0]||B,I=D.1d[1]||B}o{C=I=D.1d||B}6 H={1r:"",47:"",2T:""};5(!A.x.13){H.1W=""}3 M(R,Q,S){Q.2p(C,C.1R||E,3(){Q.j(D.18).n(H);5(A.x.13&&C.1W){Q[0].2B.y=""}5(S){L(R,S,Q)}})}3 L(R,S,Q){5(I===B){S.n("1r","1w")}S.2p(I,I.1R||E,3(){S.r(D.18).n(H);5(A.x.13&&I.1W){S[0].2B.y=""}A(P.c).z("1K",[P.Y("1K"),P.8(R,S[0])],D.1S)})}3 F(R,T,Q,S){T.j(D.m).4k().r(D.m);M(R,Q,S)}2.$4.16(".4").u(D.Z,3(){6 T=A(2).2x("1O:w(0)"),Q=P.$h.y(":4e"),S=A(2.X);5((T.1f(D.m)&&!D.1z)||T.1f(D.1a)||A(2).1f(D.1t)||A(P.c).z("2y",[P.Y("2y"),P.8(2,S[0])],D.1v)===e){2.1M();7 e}P.b.d=P.$4.11(2);5(D.1z){5(T.1f(D.m)){P.b.d=U;T.r(D.m);P.$h.1Y();M(2,Q);2.1M();7 e}o{5(!Q.k){P.$h.1Y();6 R=2;P.q(P.$4.11(2),3(){T.j(D.m).j(D.2c);L(R,S)});2.1M();7 e}}}5(D.1c){A.1c("8-4"+A.i(P.c),P.b.d,D.1c)}P.$h.1Y();5(S.k){6 R=2;P.q(P.$4.11(2),Q.k?3(){F(R,T,Q,S)}:3(){T.j(D.m);L(R,S)})}o{4b"27 4c 4d: 3n 49 4a."}5(A.x.13){2.1M()}7 e});5(!(/^24/).12(D.Z)){2.$4.u("24.4",3(){7 e})}},19:3(E,D,C){5(C==1n){C=2.$4.k}6 G=2.b;6 I=A(G.37.1g(/#\\{p\\}/g,E).1g(/#\\{1L\\}/g,D));I.i("1b.4",t);6 H=E.4i("#")==0?E.1g("#",""):2.1Q(A("a:4g-4h",I)[0]);6 F=A("#"+H);5(!F.k){F=A(G.2d).v("1s",H).j(G.18).i("1b.4",t)}F.j(G.1u);5(C>=2.$l.k){I.22(2.c);F.22(2.c[0].48)}o{I.36(2.$l[C]);F.36(2.$h[C])}G.f=A.1G(G.f,3(K,J){7 K>=C?++K:K});2.1m();5(2.$4.k==1){I.j(G.m);F.r(G.18);6 B=A.i(2.$4[0],"q.4");5(B){2.q(C,B)}}2.c.z("2Y",[2.Y("2Y"),2.8(2.$4[C],2.$h[C])],G.19)},W:3(B){6 D=2.b,E=2.$l.w(B).W(),C=2.$h.w(B).W();5(E.1f(D.m)&&2.$4.k>1){2.1v(B+(B+1<2.$4.k?1:-1))}D.f=A.1G(A.34(D.f,3(G,F){7 G!=B}),3(G,F){7 G>=B?--G:G});2.1m();2.c.z("2V",[2.Y("2V"),2.8(E.2k("a")[0],C[0])],D.W)},1X:3(B){6 C=2.b;5(A.1j(B,C.f)==-1){7}6 D=2.$l.w(B).r(C.1a);5(A.x.4n){D.n("1r","4t-1w");1x(3(){D.n("1r","1w")},0)}C.f=A.34(C.f,3(F,E){7 F!=B});2.c.z("33",[2.Y("33"),2.8(2.$4[B],2.$h[B])],C.1X)},1P:3(C){6 B=2,D=2.b;5(C!=D.d){2.$l.w(C).j(D.1a);D.f.28(C);D.f.31();2.c.z("32",[2.Y("32"),2.8(2.$4[C],2.$h[C])],D.1P)}},1v:3(B){5(1F B=="1E"){B=2.$4.11(2.$4.y("[p$="+B+"]")[0])}2.$4.w(B).4q(2.b.Z)},q:3(G,K){6 L=2,D=2.b,E=2.$4.w(G),J=E[0],H=K==1n||K===e,B=E.i("q.4");K=K||3(){};5(!B||!H&&A.i(J,"17.4")){K();7}6 M=3(N){6 O=A(N),P=O.2k("*:4s");7 P.k&&P.4v(":45(3R)")&&P||O};6 C=3(){L.$4.y("."+D.1t).r(D.1t).14(3(){5(D.1N){M(2).3l().1B(M(2).i("1L.4"))}});L.1y=U};5(D.1N){6 I=M(J).1B();M(J).3k("<2o></2o>").2k("2o").i("1L.4",I).1B(D.1N)}6 F=A.1A({},D.1J,{2U:B,2i:3(O,N){A(J.X).1B(O);C();5(D.17){A.i(J,"17.4",t)}A(L.c).z("2Z",[L.Y("2Z"),L.8(L.$4[G],L.$h[G])],D.q);D.1J.2i&&D.1J.2i(O,N);K()}});5(2.1y){2.1y.3f();C()}E.j(D.1t);1x(3(){L.1y=A.3u(F)},0)},2U:3(C,B){2.$4.w(C).1q("17.4").i("q.4",B)},1b:3(){6 B=2.b;2.c.16(".4").r(B.2b).1q("4");2.$4.14(3(){6 C=A.i(2,"p.4");5(C){2.p=C}6 D=A(2).16(".4");A.14(["p","q","17"],3(E,F){D.1q(F+".4")})});2.$l.19(2.$h).14(3(){5(A.i(2,"1b.4")){A(2).W()}o{A(2).r([B.m,B.2c,B.1a,B.1u,B.18].3G(" "))}})},Y:3(B){7 A.Z.3L({3t:B,2f:2.c[0]})}});A.8.4.1k={1z:e,Z:"24",f:[],1c:U,1N:"3F&#3A;",17:e,2X:"8-4-",1J:{},1d:U,37:\'<1O><a p="#{p}"><2W>#{1L}</2W></a></1O>\',2d:"<2a></2a>",2b:"8-4-3K",m:"8-4-d",2c:"8-4-1z",1a:"8-4-f",1u:"8-4-30",18:"8-4-3T",1t:"8-4-4w"};A.8.4.35="k";A.1A(A.8.4.1h,{1Z:U,4r:3(C,F){F=F||e;6 B=2,E=2.b.d;3 G(){B.1Z=42(3(){E=++E<B.$4.k?E:0;B.1v(E)},C)}3 D(H){5(!H||H.4j){4f(B.1Z)}}5(C){G();5(!F){2.$4.u(2.b.Z,D)}o{2.$4.u(2.b.Z,3(){D();E=B.b.d;G()})}}o{D();2.$4.16(2.b.Z,D)}}})})(27);',62,282,'||this|function|tabs|if|var|return|ui|||options|element|selected|false|disabled||panels|data|addClass|length|lis|selectedClass|css|else|href|load|removeClass||true|bind|attr|eq|browser|filter|triggerHandler|||||||||||||||||||||null|_mouseStarted|remove|hash|fakeEvent|event||index|test|msie|each|widgetName|unbind|cache|hideClass|add|disabledClass|destroy|cookie|fx|setData|hasClass|replace|prototype|widget|inArray|defaults|cssCache|tabify|undefined|mouseUp|unselectable|removeData|display|id|loadingClass|panelClass|select|block|setTimeout|xhr|unselect|extend|html|_mouseDownEvent|_mouseDelayMet|string|typeof|map|apply|plugins|ajaxOptions|tabsshow|label|blur|spinner|li|disable|tabId|duration|show|mouseDelayMet|mouseStart|mouseDrag|opacity|enable|stop|rotation|location|for|appendTo|init|click|cancel|delay|jQuery|push|Math|div|navClass|unselectClass|panelTemplate|fn|target|top|split|success|getData|find|_mouseUpDelegate|mouseDistanceMet|_mouseMoveDelegate|em|animate|MozUserSelect|mouseMove|pageY|mouseup|mouseStop|none|get|parents|tabsselect|abs|5000px|style|body|Array|width|distance|mouseDown|widgetBaseClass|on|mouse|_mouseUnselectable|pageX|arguments|document|mousemove|call|_|title|mouseCapture|height|url|tabsremove|span|idPrefix|tabsadd|tabsload|panel|sort|tabsdisable|tabsenable|grep|getter|insertBefore|tabTemplate|mouseDestroy|which|_mouseDelayTimer|preventDefault|started|mousedown|new|abort|left|mouseInit|absolute|button|wrapInner|parent|max|Mismatching|plugin|in|position|gen|class|type|ajax|isFunction|backgroundImage|catch|disableSelection|cursor|8230|removeChild|rgba|backgroundColor|try|Loading|join|enableSelection|auto|slice|nav|fix|scrollLeft|scrollTop|off|default|hasScroll|img|transparent|hide|window|splice|unload|min|constructor|normal|concat|unique|setInterval|opera|500|not|parseInt|overflow|parentNode|fragment|identifier|throw|UI|Tabs|visible|clearInterval|first|child|indexOf|clientX|siblings|insertAfter|scrollTo|safari|Za|has|trigger|rotate|last|inline|tab|is|loading|z0'.split('|'),0,{}))
@@ -0,0 +1,570 @@
1
+ /**
2
+ * Boxy 0.1.4 - Facebook-style dialog, with frills
3
+ *
4
+ * (c) 2008 Jason Frame
5
+ * Licensed under the MIT License (LICENSE)
6
+ */
7
+
8
+ /*
9
+ * jQuery plugin
10
+ *
11
+ * Options:
12
+ * message: confirmation message for form submit hook (default: "Please confirm:")
13
+ *
14
+ * Any other options - e.g. 'clone' - will be passed onto the boxy constructor (or
15
+ * Boxy.load for AJAX operations)
16
+ */
17
+ jQuery.fn.boxy = function(options) {
18
+ options = options || {};
19
+ return this.each(function() {
20
+ var node = this.nodeName.toLowerCase(), self = this;
21
+ if (node == 'a') {
22
+ jQuery(this).click(function() {
23
+ var active = Boxy.linkedTo(this),
24
+ href = this.getAttribute('href'),
25
+ localOptions = jQuery.extend({actuator: this, title: this.title}, options);
26
+
27
+ if (active) {
28
+ active.show();
29
+ } else if (href.indexOf('#') >= 0) {
30
+ var content = jQuery(href.substr(href.indexOf('#'))),
31
+ newContent = content.clone(true);
32
+ content.remove();
33
+ localOptions.unloadOnHide = false;
34
+ new Boxy(newContent, localOptions);
35
+ } else { // fall back to AJAX; could do with a same-origin check
36
+ if (!localOptions.cache) localOptions.unloadOnHide = true;
37
+ Boxy.load(this.href, localOptions);
38
+ }
39
+
40
+ return false;
41
+ });
42
+ } else if (node == 'form') {
43
+ jQuery(this).bind('submit.boxy', function() {
44
+ Boxy.confirm(options.message || 'Please confirm:', function() {
45
+ jQuery(self).unbind('submit.boxy').submit();
46
+ });
47
+ return false;
48
+ });
49
+ }
50
+ });
51
+ };
52
+
53
+ //
54
+ // Boxy Class
55
+
56
+ function Boxy(element, options) {
57
+
58
+ this.boxy = jQuery(Boxy.WRAPPER);
59
+ jQuery.data(this.boxy[0], 'boxy', this);
60
+
61
+ this.visible = false;
62
+ this.options = jQuery.extend({}, Boxy.DEFAULTS, options || {});
63
+
64
+ if (this.options.modal) {
65
+ this.options = jQuery.extend(this.options, {center: true, draggable: false});
66
+ }
67
+
68
+ // options.actuator == DOM element that opened this boxy
69
+ // association will be automatically deleted when this boxy is remove()d
70
+ if (this.options.actuator) {
71
+ jQuery.data(this.options.actuator, 'active.boxy', this);
72
+ }
73
+
74
+ this.setContent(element || "<div></div>");
75
+ this._setupTitleBar();
76
+
77
+ this.boxy.css('display', 'none').appendTo(document.body);
78
+ this.toTop();
79
+
80
+ if (this.options.fixed) {
81
+ if (jQuery.browser.msie && jQuery.browser.version < 7) {
82
+ this.options.fixed = false; // IE6 doesn't support fixed positioning
83
+ } else {
84
+ this.boxy.addClass('fixed');
85
+ }
86
+ }
87
+
88
+ if (this.options.center && Boxy._u(this.options.x, this.options.y)) {
89
+ this.center();
90
+ } else {
91
+ this.moveTo(
92
+ Boxy._u(this.options.x) ? this.options.x : Boxy.DEFAULT_X,
93
+ Boxy._u(this.options.y) ? this.options.y : Boxy.DEFAULT_Y
94
+ );
95
+ }
96
+
97
+ if (this.options.show) this.show();
98
+
99
+ };
100
+
101
+ Boxy.EF = function() {};
102
+
103
+ jQuery.extend(Boxy, {
104
+
105
+ WRAPPER: "<table cellspacing='0' cellpadding='0' border='0' class='boxy-wrapper'>" +
106
+ "<tr><td class='top-left'></td><td class='top'></td><td class='top-right'></td></tr>" +
107
+ "<tr><td class='left'></td><td class='boxy-inner'></td><td class='right'></td></tr>" +
108
+ "<tr><td class='bottom-left'></td><td class='bottom'></td><td class='bottom-right'></td></tr>" +
109
+ "</table>",
110
+
111
+ DEFAULTS: {
112
+ title: null, // titlebar text. titlebar will not be visible if not set.
113
+ closeable: true, // display close link in titlebar?
114
+ draggable: true, // can this dialog be dragged?
115
+ clone: false, // clone content prior to insertion into dialog?
116
+ actuator: null, // element which opened this dialog
117
+ center: true, // center dialog in viewport?
118
+ show: true, // show dialog immediately?
119
+ modal: false, // make dialog modal?
120
+ fixed: true, // use fixed positioning, if supported? absolute positioning used otherwise
121
+ closeText: '[close]', // text to use for default close link
122
+ unloadOnHide: false, // should this dialog be removed from the DOM after being hidden?
123
+ clickToFront: false, // bring dialog to foreground on any click (not just titlebar)?
124
+ behaviours: Boxy.EF, // function used to apply behaviours to all content embedded in dialog.
125
+ afterDrop: Boxy.EF, // callback fired after dialog is dropped. executes in context of Boxy instance.
126
+ afterShow: Boxy.EF, // callback fired after dialog becomes visible. executes in context of Boxy instance.
127
+ afterHide: Boxy.EF, // callback fired after dialog is hidden. executed in context of Boxy instance.
128
+ beforeUnload: Boxy.EF // callback fired after dialog is unloaded. executed in context of Boxy instance.
129
+ },
130
+
131
+ DEFAULT_X: 50,
132
+ DEFAULT_Y: 50,
133
+ zIndex: 1337,
134
+ dragConfigured: false, // only set up one drag handler for all boxys
135
+ resizeConfigured: false,
136
+ dragging: null,
137
+
138
+ // load a URL and display in boxy
139
+ // url - url to load
140
+ // options keys (any not listed below are passed to boxy constructor)
141
+ // type: HTTP method, default: GET
142
+ // cache: cache retrieved content? default: false
143
+ // filter: jQuery selector used to filter remote content
144
+ load: function(url, options) {
145
+
146
+ options = options || {};
147
+
148
+ var ajax = {
149
+ url: url, type: 'GET', dataType: 'html', cache: false, success: function(html) {
150
+ html = jQuery(html);
151
+ if (options.filter) html = jQuery(options.filter, html);
152
+ new Boxy(html, options);
153
+ }
154
+ };
155
+
156
+ jQuery.each(['type', 'cache'], function() {
157
+ if (this in options) {
158
+ ajax[this] = options[this];
159
+ delete options[this];
160
+ }
161
+ });
162
+
163
+ jQuery.ajax(ajax);
164
+
165
+ },
166
+
167
+ // allows you to get a handle to the containing boxy instance of any element
168
+ // e.g. <a href='#' onclick='alert(Boxy.get(this));'>inspect!</a>.
169
+ // this returns the actual instance of the boxy 'class', not just a DOM element.
170
+ // Boxy.get(this).hide() would be valid, for instance.
171
+ get: function(ele) {
172
+ var p = jQuery(ele).parents('.boxy-wrapper');
173
+ return p.length ? jQuery.data(p[0], 'boxy') : null;
174
+ },
175
+
176
+ // returns the boxy instance which has been linked to a given element via the
177
+ // 'actuator' constructor option.
178
+ linkedTo: function(ele) {
179
+ return jQuery.data(ele, 'active.boxy');
180
+ },
181
+
182
+ // displays an alert box with a given message, calling optional callback
183
+ // after dismissal.
184
+ alert: function(message, callback, options) {
185
+ return Boxy.ask(message, ['OK'], callback, options);
186
+ },
187
+
188
+ // displays an alert box with a given message, calling after callback iff
189
+ // user selects OK.
190
+ confirm: function(message, after, options) {
191
+ return Boxy.ask(message, ['OK', 'Cancel'], function(response) {
192
+ if (response == 'OK') after();
193
+ }, options);
194
+ },
195
+
196
+ // asks a question with multiple responses presented as buttons
197
+ // selected item is returned to a callback method.
198
+ // answers may be either an array or a hash. if it's an array, the
199
+ // the callback will received the selected value. if it's a hash,
200
+ // you'll get the corresponding key.
201
+ ask: function(question, answers, callback, options) {
202
+
203
+ options = jQuery.extend({modal: true, closeable: false},
204
+ options || {},
205
+ {show: true, unloadOnHide: true});
206
+
207
+ var body = jQuery('<div></div>').append(jQuery('<div class="question"></div>').html(question));
208
+
209
+ // ick
210
+ var map = {}, answerStrings = [];
211
+ if (answers instanceof Array) {
212
+ for (var i = 0; i < answers.length; i++) {
213
+ map[answers[i]] = answers[i];
214
+ answerStrings.push(answers[i]);
215
+ }
216
+ } else {
217
+ for (var k in answers) {
218
+ map[answers[k]] = k;
219
+ answerStrings.push(answers[k]);
220
+ }
221
+ }
222
+
223
+ var buttons = jQuery('<form class="answers"></form>');
224
+ buttons.html(jQuery.map(answerStrings, function(v) {
225
+ return "<input type='button' value='" + v + "' />";
226
+ }).join(' '));
227
+
228
+ jQuery('input[type=button]', buttons).click(function() {
229
+ var clicked = this;
230
+ Boxy.get(this).hide(function() {
231
+ if (callback) callback(map[clicked.value]);
232
+ });
233
+ });
234
+
235
+ body.append(buttons);
236
+
237
+ new Boxy(body, options);
238
+
239
+ },
240
+
241
+ // returns true if a modal boxy is visible, false otherwise
242
+ isModalVisible: function() {
243
+ return jQuery('.boxy-modal-blackout').length > 0;
244
+ },
245
+
246
+ _u: function() {
247
+ for (var i = 0; i < arguments.length; i++)
248
+ if (typeof arguments[i] != 'undefined') return false;
249
+ return true;
250
+ },
251
+
252
+ _handleResize: function(evt) {
253
+ var d = jQuery(document);
254
+ jQuery('.boxy-modal-blackout').css('display', 'none').css({
255
+ width: d.width(), height: d.height()
256
+ }).css('display', 'block');
257
+ },
258
+
259
+ _handleDrag: function(evt) {
260
+ var d;
261
+ if (d = Boxy.dragging) {
262
+ d[0].boxy.css({left: evt.pageX - d[1], top: evt.pageY - d[2]});
263
+ }
264
+ },
265
+
266
+ _nextZ: function() {
267
+ return Boxy.zIndex++;
268
+ },
269
+
270
+ _viewport: function() {
271
+ var d = document.documentElement, b = document.body, w = window;
272
+ return jQuery.extend(
273
+ jQuery.browser.msie ?
274
+ { left: b.scrollLeft || d.scrollLeft, top: b.scrollTop || d.scrollTop } :
275
+ { left: w.pageXOffset, top: w.pageYOffset },
276
+ !Boxy._u(w.innerWidth) ?
277
+ { width: w.innerWidth, height: w.innerHeight } :
278
+ (!Boxy._u(d) && !Boxy._u(d.clientWidth) && d.clientWidth != 0 ?
279
+ { width: d.clientWidth, height: d.clientHeight } :
280
+ { width: b.clientWidth, height: b.clientHeight }) );
281
+ }
282
+
283
+ });
284
+
285
+ Boxy.prototype = {
286
+
287
+ // Returns the size of this boxy instance without displaying it.
288
+ // Do not use this method if boxy is already visible, use getSize() instead.
289
+ estimateSize: function() {
290
+ this.boxy.css({visibility: 'hidden', display: 'block'});
291
+ var dims = this.getSize();
292
+ this.boxy.css('display', 'none').css('visibility', 'visible');
293
+ return dims;
294
+ },
295
+
296
+ // Returns the dimensions of the entire boxy dialog as [width,height]
297
+ getSize: function() {
298
+ return [this.boxy.width(), this.boxy.height()];
299
+ },
300
+
301
+ // Returns the dimensions of the content region as [width,height]
302
+ getContentSize: function() {
303
+ var c = this.getContent();
304
+ return [c.width(), c.height()];
305
+ },
306
+
307
+ // Returns the position of this dialog as [x,y]
308
+ getPosition: function() {
309
+ var b = this.boxy[0];
310
+ return [b.offsetLeft, b.offsetTop];
311
+ },
312
+
313
+ // Returns the center point of this dialog as [x,y]
314
+ getCenter: function() {
315
+ var p = this.getPosition();
316
+ var s = this.getSize();
317
+ return [Math.floor(p[0] + s[0] / 2), Math.floor(p[1] + s[1] / 2)];
318
+ },
319
+
320
+ // Returns a jQuery object wrapping the inner boxy region.
321
+ // Not much reason to use this, you're probably more interested in getContent()
322
+ getInner: function() {
323
+ return jQuery('.boxy-inner', this.boxy);
324
+ },
325
+
326
+ // Returns a jQuery object wrapping the boxy content region.
327
+ // This is the user-editable content area (i.e. excludes titlebar)
328
+ getContent: function() {
329
+ return jQuery('.boxy-content', this.boxy);
330
+ },
331
+
332
+ // Replace dialog content
333
+ setContent: function(newContent) {
334
+ newContent = jQuery(newContent).css({display: 'block'}).addClass('boxy-content');
335
+ if (this.options.clone) newContent = newContent.clone(true);
336
+ this.getContent().remove();
337
+ this.getInner().append(newContent);
338
+ this._setupDefaultBehaviours(newContent);
339
+ this.options.behaviours.call(this, newContent);
340
+ return this;
341
+ },
342
+
343
+ // Move this dialog to some position, funnily enough
344
+ moveTo: function(x, y) {
345
+ this.moveToX(x).moveToY(y);
346
+ return this;
347
+ },
348
+
349
+ // Move this dialog (x-coord only)
350
+ moveToX: function(x) {
351
+ if (typeof x == 'number') this.boxy.css({left: x});
352
+ else this.centerX();
353
+ return this;
354
+ },
355
+
356
+ // Move this dialog (y-coord only)
357
+ moveToY: function(y) {
358
+ if (typeof y == 'number') this.boxy.css({top: y});
359
+ else this.centerY();
360
+ return this;
361
+ },
362
+
363
+ // Move this dialog so that it is centered at (x,y)
364
+ centerAt: function(x, y) {
365
+ var s = this[this.visible ? 'getSize' : 'estimateSize']();
366
+ if (typeof x == 'number') this.moveToX(x - s[0] / 2);
367
+ if (typeof y == 'number') this.moveToY(y - s[1] / 2);
368
+ return this;
369
+ },
370
+
371
+ centerAtX: function(x) {
372
+ return this.centerAt(x, null);
373
+ },
374
+
375
+ centerAtY: function(y) {
376
+ return this.centerAt(null, y);
377
+ },
378
+
379
+ // Center this dialog in the viewport
380
+ // axis is optional, can be 'x', 'y'.
381
+ center: function(axis) {
382
+ var v = Boxy._viewport();
383
+ var o = this.options.fixed ? [0, 0] : [v.left, v.top];
384
+ if (!axis || axis == 'x') this.centerAt(o[0] + v.width / 2, null);
385
+ if (!axis || axis == 'y') this.centerAt(null, o[1] + v.height / 2);
386
+ return this;
387
+ },
388
+
389
+ // Center this dialog in the viewport (x-coord only)
390
+ centerX: function() {
391
+ return this.center('x');
392
+ },
393
+
394
+ // Center this dialog in the viewport (y-coord only)
395
+ centerY: function() {
396
+ return this.center('y');
397
+ },
398
+
399
+ // Resize the content region to a specific size
400
+ resize: function(width, height, after) {
401
+ if (!this.visible) return;
402
+ var bounds = this._getBoundsForResize(width, height);
403
+ this.boxy.css({left: bounds[0], top: bounds[1]});
404
+ this.getContent().css({width: bounds[2], height: bounds[3]});
405
+ if (after) after(this);
406
+ return this;
407
+ },
408
+
409
+ // Tween the content region to a specific size
410
+ tween: function(width, height, after) {
411
+ if (!this.visible) return;
412
+ var bounds = this._getBoundsForResize(width, height);
413
+ var self = this;
414
+ this.boxy.stop().animate({left: bounds[0], top: bounds[1]});
415
+ this.getContent().stop().animate({width: bounds[2], height: bounds[3]}, function() {
416
+ if (after) after(self);
417
+ });
418
+ return this;
419
+ },
420
+
421
+ // Returns true if this dialog is visible, false otherwise
422
+ isVisible: function() {
423
+ return this.visible;
424
+ },
425
+
426
+ // Make this boxy instance visible
427
+ show: function() {
428
+ if (this.visible) return;
429
+ if (this.options.modal) {
430
+ var self = this;
431
+ if (!Boxy.resizeConfigured) {
432
+ Boxy.resizeConfigured = true;
433
+ jQuery(window).resize(function() { Boxy._handleResize(); });
434
+ }
435
+ this.modalBlackout = jQuery('<div class="boxy-modal-blackout"></div>')
436
+ .css({zIndex: Boxy._nextZ(),
437
+ opacity: 0.7,
438
+ width: jQuery(document).width(),
439
+ height: jQuery(document).height()})
440
+ .appendTo(document.body);
441
+ this.toTop();
442
+ if (this.options.closeable) {
443
+ jQuery(document.body).bind('keypress.boxy', function(evt) {
444
+ var key = evt.which || evt.keyCode;
445
+ if (key == 27) {
446
+ self.hide();
447
+ jQuery(document.body).unbind('keypress.boxy');
448
+ }
449
+ });
450
+ }
451
+ }
452
+ this.boxy.stop().css({opacity: 1}).show();
453
+ this.visible = true;
454
+ this._fire('afterShow');
455
+ return this;
456
+ },
457
+
458
+ // Hide this boxy instance
459
+ hide: function(after) {
460
+ if (!this.visible) return;
461
+ var self = this;
462
+ if (this.options.modal) {
463
+ jQuery(document.body).unbind('keypress.boxy');
464
+ this.modalBlackout.animate({opacity: 0}, function() {
465
+ jQuery(this).remove();
466
+ });
467
+ }
468
+ this.boxy.stop().animate({opacity: 0}, 300, function() {
469
+ self.boxy.css({display: 'none'});
470
+ self.visible = false;
471
+ self._fire('afterHide');
472
+ if (after) after(self);
473
+ if (self.options.unloadOnHide) self.unload();
474
+ });
475
+ return this;
476
+ },
477
+
478
+ toggle: function() {
479
+ this[this.visible ? 'hide' : 'show']();
480
+ return this;
481
+ },
482
+
483
+ hideAndUnload: function(after) {
484
+ this.options.unloadOnHide = true;
485
+ this.hide(after);
486
+ return this;
487
+ },
488
+
489
+ unload: function() {
490
+ this._fire('beforeUnload');
491
+ this.boxy.remove();
492
+ if (this.options.actuator) {
493
+ jQuery.data(this.options.actuator, 'active.boxy', false);
494
+ }
495
+ },
496
+
497
+ // Move this dialog box above all other boxy instances
498
+ toTop: function() {
499
+ this.boxy.css({zIndex: Boxy._nextZ()});
500
+ return this;
501
+ },
502
+
503
+ // Returns the title of this dialog
504
+ getTitle: function() {
505
+ return jQuery('> .title-bar h2', this.getInner()).html();
506
+ },
507
+
508
+ // Sets the title of this dialog
509
+ setTitle: function(t) {
510
+ jQuery('> .title-bar h2', this.getInner()).html(t);
511
+ return this;
512
+ },
513
+
514
+ //
515
+ // Don't touch these privates
516
+
517
+ _getBoundsForResize: function(width, height) {
518
+ var csize = this.getContentSize();
519
+ var delta = [width - csize[0], height - csize[1]];
520
+ var p = this.getPosition();
521
+ return [Math.max(p[0] - delta[0] / 2, 0),
522
+ Math.max(p[1] - delta[1] / 2, 0), width, height];
523
+ },
524
+
525
+ _setupTitleBar: function() {
526
+ if (this.options.title) {
527
+ var self = this;
528
+ var tb = jQuery("<div class='title-bar'></div>").html("<h2>" + this.options.title + "</h2>");
529
+ if (this.options.closeable) {
530
+ tb.append(jQuery("<a href='#' class='close'></a>").html(this.options.closeText));
531
+ }
532
+ if (this.options.draggable) {
533
+ tb[0].onselectstart = function() { return false; }
534
+ tb[0].unselectable = 'on';
535
+ tb[0].style.MozUserSelect = 'none';
536
+ if (!Boxy.dragConfigured) {
537
+ jQuery(document).mousemove(Boxy._handleDrag);
538
+ Boxy.dragConfigured = true;
539
+ }
540
+ tb.mousedown(function(evt) {
541
+ self.toTop();
542
+ Boxy.dragging = [self, evt.pageX - self.boxy[0].offsetLeft, evt.pageY - self.boxy[0].offsetTop];
543
+ jQuery(this).addClass('dragging');
544
+ }).mouseup(function() {
545
+ jQuery(this).removeClass('dragging');
546
+ Boxy.dragging = null;
547
+ self._fire('afterDrop');
548
+ });
549
+ }
550
+ this.getInner().prepend(tb);
551
+ this._setupDefaultBehaviours(tb);
552
+ }
553
+ },
554
+
555
+ _setupDefaultBehaviours: function(root) {
556
+ var self = this;
557
+ if (this.options.clickToFront) {
558
+ root.click(function() { self.toTop(); });
559
+ }
560
+ jQuery('.close', root).click(function() {
561
+ self.hide();
562
+ return false;
563
+ }).mousedown(function(evt) { evt.stopPropagation(); });
564
+ },
565
+
566
+ _fire: function(event) {
567
+ this.options[event].call(this);
568
+ }
569
+
570
+ };