file_share 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +16 -0
- data/Gemfile.lock +147 -0
- data/README +0 -0
- data/Rakefile +38 -0
- data/VERSION +1 -0
- data/app/controllers/application_controller.rb +4 -0
- data/app/controllers/file_attachments_controller.rb +123 -0
- data/app/controllers/file_share/application_controller.rb +5 -0
- data/app/helpers/file_attachments_helper.rb +9 -0
- data/app/helpers/file_share/application_helper.rb +60 -0
- data/app/models/file_attachment.rb +104 -0
- data/app/models/file_container.rb +30 -0
- data/app/views/file-share-shared/_flash.html.erb +7 -0
- data/app/views/file-share-shared/_main_menu.html.erb +3 -0
- data/app/views/file-share-shared/_navigation.html.erb +2 -0
- data/app/views/file_attachments/_file_attachment.html.erb +17 -0
- data/app/views/file_attachments/_file_attachments.html.erb +52 -0
- data/app/views/file_attachments/_file_container_option.html.erb +4 -0
- data/app/views/file_attachments/_file_container_select.html.erb +14 -0
- data/app/views/file_attachments/_plupload_with_listing.html.erb +142 -0
- data/app/views/file_attachments/_upload_form.html.erb +22 -0
- data/app/views/file_attachments/edit.html.erb +32 -0
- data/app/views/file_attachments/index.html.erb +1 -0
- data/app/views/file_attachments/update.js.rjs +13 -0
- data/app/views/layouts/application.html.erb +56 -0
- data/config/application.rb +42 -0
- data/config/blueprint_settings.yml +9 -0
- data/config/boot.rb +13 -0
- data/config/cucumber.yml +8 -0
- data/config/database.example.yml +22 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +26 -0
- data/config/environments/production.rb +49 -0
- data/config/environments/test.rb +35 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/inflections.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/secret_token.rb +9 -0
- data/config/initializers/session_store.rb +10 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +64 -0
- data/db/migrate/20101020002635_create_file_attachments.rb +19 -0
- data/db/schema.rb +27 -0
- data/db/seeds.rb +7 -0
- data/lib/file_share.rb +3 -0
- data/lib/file_share/engine.rb +25 -0
- data/lib/generators/file_share/install/USAGE +5 -0
- data/lib/generators/file_share/install/install_generator.rb +19 -0
- data/lib/generators/file_share/install/templates/file_share.rake +169 -0
- data/lib/tasks/blueprint.rake +25 -0
- data/lib/tasks/cucumber.rake +53 -0
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/public/favicon.ico +0 -0
- data/public/images/rails.png +0 -0
- data/public/javascripts/file_share.js +62 -0
- data/public/javascripts/file_share_behaviors.js +131 -0
- data/public/javascripts/idselector.js +538 -0
- data/public/javascripts/jquery-1.3.2.min.js +19 -0
- data/public/javascripts/jquery-ui-1.7.2.custom.min.js +298 -0
- data/public/javascripts/jquery.clonePosition.js +27 -0
- data/public/javascripts/jquery.js +154 -0
- data/public/javascripts/jquery.qtip-1.0.0-rc3.js +2149 -0
- data/public/javascripts/jquery.qtip-1.0.0-rc3.min.js +15 -0
- data/public/javascripts/jquery.string.1.0-min.js +6 -0
- data/public/javascripts/jquery.tablesorter.min.js +2 -0
- data/public/javascripts/lowpro.jquery.js +224 -0
- data/public/javascripts/plupload/gears_init.js +86 -0
- data/public/javascripts/plupload/jquery.plupload.queue.min.js +202 -0
- data/public/javascripts/plupload/plupload.browserplus.min.js +1 -0
- data/public/javascripts/plupload/plupload.flash.min.js +1 -0
- data/public/javascripts/plupload/plupload.flash.swf +0 -0
- data/public/javascripts/plupload/plupload.full.min.js +1 -0
- data/public/javascripts/plupload/plupload.gears.min.js +1 -0
- data/public/javascripts/plupload/plupload.html4.min.js +1 -0
- data/public/javascripts/plupload/plupload.html5.min.js +1 -0
- data/public/javascripts/plupload/plupload.min.js +1 -0
- data/public/javascripts/plupload/plupload.silverlight.min.js +1 -0
- data/public/javascripts/plupload/plupload.silverlight.xap +0 -0
- data/public/javascripts/rails.js +132 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/blueprint/grid.css +290 -0
- data/public/stylesheets/blueprint/icons/cross.png +0 -0
- data/public/stylesheets/blueprint/icons/doc.png +0 -0
- data/public/stylesheets/blueprint/icons/email.png +0 -0
- data/public/stylesheets/blueprint/icons/external.png +0 -0
- data/public/stylesheets/blueprint/icons/feed.png +0 -0
- data/public/stylesheets/blueprint/icons/im.png +0 -0
- data/public/stylesheets/blueprint/icons/key.png +0 -0
- data/public/stylesheets/blueprint/icons/pdf.png +0 -0
- data/public/stylesheets/blueprint/icons/tick.png +0 -0
- data/public/stylesheets/blueprint/icons/visited.png +0 -0
- data/public/stylesheets/blueprint/icons/xls.png +0 -0
- data/public/stylesheets/blueprint/ie.css +36 -0
- data/public/stylesheets/blueprint/oldgrid.css +161 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
- data/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
- data/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
- data/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
- data/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
- data/public/stylesheets/blueprint/plugins/rtl/screen.css +110 -0
- data/public/stylesheets/blueprint/plugins/silksprite/sprite.css +1 -0
- data/public/stylesheets/blueprint/plugins/silksprite/sprites.png +0 -0
- data/public/stylesheets/blueprint/print.css +29 -0
- data/public/stylesheets/blueprint/readme.txt +12 -0
- data/public/stylesheets/blueprint/screen.css +402 -0
- data/public/stylesheets/error_messages.css +65 -0
- data/public/stylesheets/formtastic.css +138 -0
- data/public/stylesheets/formtastic_changes.css +33 -0
- data/public/stylesheets/main_elements.css +26 -0
- data/public/stylesheets/plupload/backgrounds.gif +0 -0
- data/public/stylesheets/plupload/buttons-disabled.png +0 -0
- data/public/stylesheets/plupload/buttons.png +0 -0
- data/public/stylesheets/plupload/delete.gif +0 -0
- data/public/stylesheets/plupload/done.gif +0 -0
- data/public/stylesheets/plupload/error.gif +0 -0
- data/public/stylesheets/plupload/screen.css +172 -0
- data/public/stylesheets/plupload/transp50.png +0 -0
- data/public/stylesheets/reset.css +60 -0
- data/public/stylesheets/scaffold.css +55 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/smoothness/jquery-ui-1.7.2.custom.css +406 -0
- data/public/stylesheets/tablesorter/blue/asc.gif +0 -0
- data/public/stylesheets/tablesorter/blue/bg.gif +0 -0
- data/public/stylesheets/tablesorter/blue/desc.gif +0 -0
- data/public/stylesheets/tablesorter/blue/style.css +39 -0
- data/public/stylesheets/text_and_colors.css +49 -0
- data/spec/controllers/file_attachments_controller_spec.rb +305 -0
- data/spec/fixtures/file_share_file_attachments.yml +2 -0
- data/spec/fixtures/somefile.txt +1 -0
- data/spec/helpers/file_attachments_helper_spec.rb +11 -0
- data/spec/models/file_attachment_spec.rb +57 -0
- data/spec/models/file_container_spec.rb +23 -0
- data/spec/spec_helper.rb +27 -0
- metadata +474 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :blueprint do
|
2
|
+
desc "Install/Update blueprint stylesheets (+plugins)"
|
3
|
+
task :install do
|
4
|
+
blueprint_css = File.expand_path("~/.blueprint_css")
|
5
|
+
|
6
|
+
if File.exists?(blueprint_css)
|
7
|
+
blueprint_path = File.new(blueprint_css, 'r').read.strip
|
8
|
+
else
|
9
|
+
puts("What is the path to your blueprint checkout?")
|
10
|
+
blueprint_path = $stdin.gets.strip
|
11
|
+
end
|
12
|
+
|
13
|
+
compress_script = File.join(blueprint_path, 'lib', 'compress.rb')
|
14
|
+
|
15
|
+
while !File.exists?(compress_script)
|
16
|
+
puts("Could not find #{compress_script}. Please enter new path.")
|
17
|
+
blueprint_path = $stdin.gets.strip
|
18
|
+
compress_script = File.join(blueprint_path, 'lib', 'compress.rb')
|
19
|
+
end
|
20
|
+
|
21
|
+
File.open(blueprint_css, 'w'){|f| f.write(blueprint_path)}
|
22
|
+
|
23
|
+
system "ruby #{compress_script} -f #{Rails.root.to_s}/config/blueprint_settings.yml -p default"
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
2
|
+
# It is recommended to regenerate this file in the future when you upgrade to a
|
3
|
+
# newer version of cucumber-rails. Consider adding your own code to a new file
|
4
|
+
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
5
|
+
# files.
|
6
|
+
|
7
|
+
|
8
|
+
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
|
9
|
+
|
10
|
+
vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
11
|
+
$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
|
12
|
+
|
13
|
+
begin
|
14
|
+
require 'cucumber/rake/task'
|
15
|
+
|
16
|
+
namespace :cucumber do
|
17
|
+
Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
|
18
|
+
t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
|
19
|
+
t.fork = true # You may get faster startup if you set this to false
|
20
|
+
t.profile = 'default'
|
21
|
+
end
|
22
|
+
|
23
|
+
Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
|
24
|
+
t.binary = vendored_cucumber_bin
|
25
|
+
t.fork = true # You may get faster startup if you set this to false
|
26
|
+
t.profile = 'wip'
|
27
|
+
end
|
28
|
+
|
29
|
+
Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
|
30
|
+
t.binary = vendored_cucumber_bin
|
31
|
+
t.fork = true # You may get faster startup if you set this to false
|
32
|
+
t.profile = 'rerun'
|
33
|
+
end
|
34
|
+
|
35
|
+
desc 'Run all features'
|
36
|
+
task :all => [:ok, :wip]
|
37
|
+
end
|
38
|
+
desc 'Alias for cucumber:ok'
|
39
|
+
task :cucumber => 'cucumber:ok'
|
40
|
+
|
41
|
+
task :default => :cucumber
|
42
|
+
|
43
|
+
task :features => :cucumber do
|
44
|
+
STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
|
45
|
+
end
|
46
|
+
rescue LoadError
|
47
|
+
desc 'cucumber rake task not available (cucumber not installed)'
|
48
|
+
task :cucumber do
|
49
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
data/public/404.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/422.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/500.html
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
<p>We've been notified about this issue and we'll take a look at it shortly.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
data/public/favicon.ico
ADDED
File without changes
|
Binary file
|
@@ -0,0 +1,62 @@
|
|
1
|
+
// use to give the preview of details for an event below a calendar
|
2
|
+
var updateEventDescription = function(event, jsEvent) {
|
3
|
+
$("#event_quick_description")[0].innerHTML = "";
|
4
|
+
$("#event_quick_description").append(
|
5
|
+
$("<h3/>").append(
|
6
|
+
$('<a/>', { text : event.title, href : event.url })
|
7
|
+
)
|
8
|
+
);
|
9
|
+
$("#event_quick_description")[0].innerHTML += "Location: " + event.location + "<br/>";
|
10
|
+
$("#event_quick_description")[0].innerHTML += event.description;
|
11
|
+
|
12
|
+
$("#event_quick_description").show();
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
jQuery(function($) {
|
17
|
+
$('a.show_hide_link').attach(ShowHideLink);
|
18
|
+
});
|
19
|
+
|
20
|
+
/*
|
21
|
+
http://www.learningjquery.com/2007/08/clearing-form-data
|
22
|
+
*/
|
23
|
+
$.fn.clearForm = function() {
|
24
|
+
return this.each(function() {
|
25
|
+
var type = this.type, tag = this.tagName.toLowerCase();
|
26
|
+
if (tag == 'form')
|
27
|
+
return $(':input',this).clearForm();
|
28
|
+
if (type == 'text' || type == 'password' || tag == 'textarea')
|
29
|
+
this.value = '';
|
30
|
+
else if (type == 'checkbox' || type == 'radio')
|
31
|
+
this.checked = false;
|
32
|
+
else if (tag == 'select')
|
33
|
+
this.selectedIndex = -1;
|
34
|
+
});
|
35
|
+
};
|
36
|
+
|
37
|
+
DynamicForm = $.klass({
|
38
|
+
initialize: function(options) {
|
39
|
+
this.formId = options.formId; // new_description
|
40
|
+
this.formContainer = options.formContainer; // blank_description_form
|
41
|
+
this.targetIdName = options.targetIdName; // file_attachment_id
|
42
|
+
this.targetContentName = options.targetContentName; // file_attachment[description]
|
43
|
+
this.targetContentType = options.targetContentType;
|
44
|
+
this.actionPrefix = options.actionPrefix; // /file_attachments
|
45
|
+
},
|
46
|
+
onclick: function(e) {
|
47
|
+
e.preventDefault();
|
48
|
+
|
49
|
+
var targetIdValue = this.element.attr(this.targetIdName);
|
50
|
+
var targetContentValue = this.element.attr(this.targetContentName);
|
51
|
+
|
52
|
+
$('#' + this.formId).attr("action", this.actionPrefix + "/" + targetIdValue);
|
53
|
+
|
54
|
+
$('#' + this.formId).clearForm();
|
55
|
+
|
56
|
+
$('#' + this.formContainer).insertBefore(this.element);
|
57
|
+
|
58
|
+
$(this.targetContentType + '[name='+ this.targetContentName +']').val(targetContentValue);
|
59
|
+
|
60
|
+
$('#' + this.formContainer).show();
|
61
|
+
}
|
62
|
+
});
|
@@ -0,0 +1,131 @@
|
|
1
|
+
/*
|
2
|
+
* all lowpro behaviors
|
3
|
+
*/
|
4
|
+
|
5
|
+
|
6
|
+
CheckBoxToggle = $.klass({
|
7
|
+
initialize: function(toggle_selector) {
|
8
|
+
this.toggle_selector = toggle_selector;
|
9
|
+
},
|
10
|
+
|
11
|
+
onclick: function() {
|
12
|
+
var to_toggle = this.element[0].checked;
|
13
|
+
$(this.toggle_selector + ' input[type=checkbox]').each(function(index) {
|
14
|
+
$(this)[0].checked = to_toggle;
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
/*
|
20
|
+
* use like:
|
21
|
+
*
|
22
|
+
* $('.some_category_field').attach(SelectPopper, '#div_with_ul');
|
23
|
+
* $('#div_with_ul').attach(SetSelector, '.some_category_field');
|
24
|
+
*
|
25
|
+
*/
|
26
|
+
|
27
|
+
SelectPopper = $.klass({
|
28
|
+
// provide array of select_options
|
29
|
+
// TODO: detect a hash and use it to do option text/value
|
30
|
+
initialize: function(select_options) {
|
31
|
+
if(select_options.length > 0) {
|
32
|
+
var _a_ul = $('<ul/>', { style : 'list-style-type: none; margin: 0' } );
|
33
|
+
$.each(select_options, function(index, value) {
|
34
|
+
$('<li/>', { text : value, style : "padding: 3px;" }).appendTo(_a_ul);
|
35
|
+
});
|
36
|
+
|
37
|
+
this.select_box = $('<div/>', { style : 'display:none; background: white; border: 1px solid #999;',
|
38
|
+
"class" : "select_popper_box" } );
|
39
|
+
_a_ul.appendTo(this.select_box);
|
40
|
+
this.select_box.appendTo('body');
|
41
|
+
this.select_box.attach(SetSelector, this.element);
|
42
|
+
}
|
43
|
+
},
|
44
|
+
|
45
|
+
onfocus: function(e) {
|
46
|
+
if(this.select_box) {
|
47
|
+
this.select_box.clonePosition(this.element, { cloneHeight: false, offsetLeft: 1, offsetTop: this.element.height() });
|
48
|
+
this.select_box.css('width', (this.element.offsetWidth - 2) + 'px');
|
49
|
+
this.select_box.show();
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
onblur: function(e) {
|
54
|
+
if(this.select_box) {
|
55
|
+
var _select_box = this.select_box;
|
56
|
+
setTimeout(function() {
|
57
|
+
_select_box.hide();
|
58
|
+
}, 250);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
});
|
62
|
+
|
63
|
+
SetSelector = $.klass({
|
64
|
+
initialize: function(input_element) {
|
65
|
+
this.select_field = $(input_element);
|
66
|
+
},
|
67
|
+
|
68
|
+
onclick: $.delegate({
|
69
|
+
'li': function(click_target) {
|
70
|
+
this.select_field.val(click_target.text());
|
71
|
+
this.element.hide();
|
72
|
+
}
|
73
|
+
})
|
74
|
+
});
|
75
|
+
|
76
|
+
|
77
|
+
TextareaExpander = $.klass({
|
78
|
+
initialize: function(pixelsToGrowBy, maxHeight) {
|
79
|
+
this.pixelsToGrowBy = (typeof pixelsToGrowBy == 'undefined') ? 20 : pixelsToGrowBy;
|
80
|
+
this.maxHeight = (typeof maxHeight == 'undefined') ? 999 : maxHeight;
|
81
|
+
// run it once to blow up any textareas on first page load
|
82
|
+
this.onkeypress();
|
83
|
+
},
|
84
|
+
|
85
|
+
onkeypress: function(e) {
|
86
|
+
var curr_h = this.element.height();
|
87
|
+
var scroll_h = this.element[0].scrollHeight;
|
88
|
+
while(curr_h < scroll_h && curr_h < this.maxHeight) {
|
89
|
+
this.element.css( { 'height': (curr_h + this.pixelsToGrowBy) + 'px' });
|
90
|
+
curr_h = this.element.height();
|
91
|
+
scroll_h = this.element[0].scrollHeight;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
});
|
95
|
+
|
96
|
+
|
97
|
+
ShowHideLink = $.klass({
|
98
|
+
initialize: function(options) {
|
99
|
+
options = options || {};
|
100
|
+
this.showEffect = options.show_effect;
|
101
|
+
this.hideEffect = options.hide_effect;
|
102
|
+
this.showEffectParams = options.show_effect_params;
|
103
|
+
this.hideEffectParams = options.hide_effect_params;
|
104
|
+
this.showClassName = $.string(this.element[0].href).toQueryParams()['show'];
|
105
|
+
this.hideClassName = $.string(this.element[0].href).toQueryParams()['hide'];
|
106
|
+
this.toggleClassName = $.string(this.element[0].href).toQueryParams()['toggle'];
|
107
|
+
this.hideMe = options.hide_me;
|
108
|
+
this.doNotStop = options.do_not_stop || false;
|
109
|
+
this.myToggleClass = options.my_toggle_class;
|
110
|
+
},
|
111
|
+
|
112
|
+
onclick: function(e) {
|
113
|
+
if(this.hideClassName) {
|
114
|
+
//$('.'+this.hideClassName).invoke(this.hideEffect || 'hide', this.hideEffectParams);
|
115
|
+
$('.'+this.hideClassName).hide();
|
116
|
+
}
|
117
|
+
if(this.showClassName) {
|
118
|
+
//$('.'+this.showClassName).invoke(this.showEffect || 'show', this.showEffectParams);
|
119
|
+
$('.'+this.showClassName).show();
|
120
|
+
}
|
121
|
+
if(this.toggleClassName) {
|
122
|
+
$('.'+this.toggleClassName).toggle();
|
123
|
+
}
|
124
|
+
if(this.hideMe) {
|
125
|
+
this.element.hide();
|
126
|
+
}
|
127
|
+
this.element.blur();
|
128
|
+
|
129
|
+
return this.doNotStop;
|
130
|
+
}
|
131
|
+
});
|
@@ -0,0 +1,538 @@
|
|
1
|
+
(function () {
|
2
|
+
function gen_selector() {
|
3
|
+
var quirksMode = document.compatMode != 'CSS1Compat';
|
4
|
+
|
5
|
+
function log(msg) {
|
6
|
+
if (window.console) {window.console.log('ID Selector: ' + msg);}
|
7
|
+
}
|
8
|
+
|
9
|
+
function readCookie(name) {
|
10
|
+
var nameEQ = name + "=";
|
11
|
+
var ca = document.cookie.split(';');
|
12
|
+
for(var i=0;i < ca.length;i++) {
|
13
|
+
var c = ca[i];
|
14
|
+
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
15
|
+
if (c.indexOf(nameEQ) == 0)
|
16
|
+
return decodeURIComponent(c.substring(nameEQ.length,c.length));
|
17
|
+
}
|
18
|
+
return null;
|
19
|
+
}
|
20
|
+
var openidCookie = readCookie('__openid_selector_openid');
|
21
|
+
var opIdCookie = readCookie('__openid_selector_op_id');
|
22
|
+
var unameCookie = readCookie('__openid_selector_uname');
|
23
|
+
|
24
|
+
var s;
|
25
|
+
var providers = [{longname: "myOpenID", shortname: "myOpenID", url_suffix: ".myopenid.com/", usercalled: "username", icon: "myopenid.ico", id: 8, website: "https://www.myopenid.com/", openid1: true, url_prefix: "http://", openid2: true}, {longname: "Yahoo!", shortname: "Yahoo!", url_suffix: "", usercalled: "yahoo id", icon: "yahoo.ico", id: 15, website: "http://yahoo.com/", openid1: false, url_prefix: "http://me.yahoo.com/", openid2: true}, {longname: "Google", shortname: "Google", url_suffix: "", usercalled: "username", icon: "google.ico", id: 26, website: "https://www.google.com/accounts/o8/id", openid1: false, url_prefix: "", openid2: true}, {longname: "Flickr", shortname: "Flickr", url_suffix: "", usercalled: "username", icon: "flickr.ico", id: 6, website: "http://www.flickr.com/", openid1: false, url_prefix: "http://www.flickr.com/photos/", openid2: true}, {longname: "America Online/AIM", shortname: "AOL", url_suffix: "", usercalled: "screenname", icon: "aol.ico", id: 1, website: "http://www.aol.com/", openid1: true, url_prefix: "http://openid.aol.com/", openid2: false}, {longname: "Google Blogger", shortname: "Blogger", url_suffix: ".blogspot.com/", usercalled: "blog name", icon: "blogger.ico", id: 2, website: "http://www.blogger.com/", openid1: true, url_prefix: "http://", openid2: false}, {longname: "Livejournal", shortname: "Livejournal", url_suffix: ".livejournal.com/", usercalled: "username", icon: "lj.ico", id: 7, website: "http://www.livejournal.com/", openid1: true, url_prefix: "http://", openid2: false}, {longname: "Verisign PIP", shortname: "Verisign", url_suffix: ".pip.verisignlabs.com/", usercalled: "username", icon: "verisign.ico", id: 11, website: "http://pip.verisignlabs.com/", openid1: true, url_prefix: "http://", openid2: true}, {longname: "Vidoop", shortname: "Vidoop", url_suffix: ".myvidoop.com/", usercalled: "username", icon: "vidoop2.ico", id: 12, website: "http://www.vidoop.com/", openid1: true, url_prefix: "http://", openid2: true}, {longname: "claimID", shortname: "claimID", url_suffix: "", usercalled: "username", icon: "claimid.ico", id: 4, website: "http://claimid.com/", openid1: true, url_prefix: "http://claimid.com/", openid2: false}, {longname: "Technorati", shortname: "Technorati", url_suffix: "", usercalled: "username", icon: "technorati.ico", id: 10, website: "http://www.technorati.com/", openid1: true, url_prefix: "http://technorati.com/people/technorati/", openid2: false}, {longname: "Vox", shortname: "Vox", url_suffix: ".vox.com/", usercalled: "username", icon: "vox.ico", id: 13, website: "http://www.vox.com/", openid1: true, url_prefix: "http://", openid2: false}];
|
26
|
+
|
27
|
+
var oidTbId = window.idselector_input_id ? window.idselector_input_id : "openid_identifier";
|
28
|
+
var oidTb = document.getElementById(oidTbId);
|
29
|
+
if (oidTb == null) {
|
30
|
+
log('couldn\'t find openid input box with id = ' + oidTbId);
|
31
|
+
for (i = 0; !oidTb && i < document.forms.length; i++) {
|
32
|
+
oidTb = document.forms[i].openid_identifier;}
|
33
|
+
for (i = 0; !oidTb && i < document.forms.length; i++) {
|
34
|
+
oidTb = document.forms[i].openid_url;}
|
35
|
+
}
|
36
|
+
|
37
|
+
if (oidTb == null) {log('couldn\'t find openid input box'); return;}
|
38
|
+
var orig = oidTb.value;
|
39
|
+
|
40
|
+
var btnIcn = document.createElement('img');
|
41
|
+
s = btnIcn.style; s.width = '16px'; s.height = '16px';
|
42
|
+
s.verticalAlign = 'middle'; s.padding = '0px'; s.border = '0px';
|
43
|
+
s.margin = '0px'; s.display = 'inline';
|
44
|
+
|
45
|
+
var btnMkr = document.createElement('div');
|
46
|
+
btnMkr.innerHTML = "<button type=\"button\"></button>";
|
47
|
+
|
48
|
+
var arrow = document.createElement('img');
|
49
|
+
arrow.src = "../images/idselector/arrow.gif";
|
50
|
+
arrow.style.display = 'inline';
|
51
|
+
|
52
|
+
var btn = btnMkr.firstChild;
|
53
|
+
btnMkr.removeChild(btn);
|
54
|
+
btn.id = '__idselector_button';
|
55
|
+
btn.style.cursor = "pointer";
|
56
|
+
|
57
|
+
btn.appendChild(btnIcn);
|
58
|
+
btn.appendChild(document.createTextNode(" "));
|
59
|
+
btn.appendChild(arrow);
|
60
|
+
|
61
|
+
var popup = document.createElement('iframe');
|
62
|
+
popup.frameBorder = 0; popup.scrolling = 'no';
|
63
|
+
s = popup.style; s.display = 'none'; s.position = 'absolute';
|
64
|
+
s.width = '400px'; s.height = '0px'; s.margin = '0px'; s.padding = '0px'; s.zIndex = 10000;
|
65
|
+
s.border = '0px';
|
66
|
+
|
67
|
+
var prnt = oidTb.parentNode;
|
68
|
+
var target = null;
|
69
|
+
if (window.idselector_target_id) {
|
70
|
+
target = document.getElementById(window.idselector_target_id);
|
71
|
+
if (!target) {log("couldn't find element with id " + window.idselector_target_id);}
|
72
|
+
}
|
73
|
+
if (target) {
|
74
|
+
target.insertBefore(btn, target.firstChild);
|
75
|
+
} else {
|
76
|
+
prnt.insertBefore(btn, oidTb.nextSibling);
|
77
|
+
prnt.insertBefore(document.createTextNode(" "), btn);
|
78
|
+
}
|
79
|
+
document.body.appendChild(popup);
|
80
|
+
|
81
|
+
var pdoc = popup.contentWindow.document;
|
82
|
+
pdoc.open();
|
83
|
+
pdoc.write('<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html><head><title>ID Selector</title><style type=\"text/css\">html{color:#000;background:#6e91af;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:\'\';}abbr,acronym {border:0;font-variant:normal;}sup {vertical-align:text-top;}sub {vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;}body {border:1px solid #6e91af;font:13px/1.231 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}pre,code,kbd,samp,tt{font-family:monospace;*font-size:108%;line-height:100%;}</style></head><body></body></html>');
|
84
|
+
pdoc.close();
|
85
|
+
|
86
|
+
var pbody = pdoc.body;
|
87
|
+
|
88
|
+
var back = pdoc.createElement('img');
|
89
|
+
back.style.verticalAlign = "middle"; back.style.cursor = "pointer";
|
90
|
+
back.src = "../images/idselector/arrow_white_back.png";
|
91
|
+
|
92
|
+
var forward = pdoc.createElement('img');
|
93
|
+
forward.style.verticalAlign = "middle"; forward.style.cursor = "pointer";
|
94
|
+
forward.src = "../images/idselector/arrow_white_forward.png";
|
95
|
+
|
96
|
+
var headRight = pdoc.createElement('div');
|
97
|
+
headRight.style[document.all ? 'styleFloat' : 'cssFloat'] = 'right';
|
98
|
+
headRight.innerHTML = '<a href="http://openid.net/get/" style="color:#fff;" target="_blank">Get an OpenID</a>';
|
99
|
+
|
100
|
+
var header = pdoc.createElement('div');
|
101
|
+
s = header.style; s.fontWeight = "bold"; s.color = "#fff";
|
102
|
+
s.padding = "2px 8px 2px 8px";
|
103
|
+
|
104
|
+
header.appendChild(headRight);
|
105
|
+
header.appendChild(pdoc.createTextNode("Sign in with OpenID using"));
|
106
|
+
|
107
|
+
var nameLabel = pdoc.createElement('span');
|
108
|
+
nameLabel.appendChild(pdoc.createTextNode("xxx:"));
|
109
|
+
|
110
|
+
var nameTb = pdoc.createElement('input');
|
111
|
+
nameTb.type = "text";
|
112
|
+
nameTb.size = 20;
|
113
|
+
s = nameTb.style; s.verticalAlign = 'middle'; s.padding = '2px 2px 2px 20px';
|
114
|
+
s.backgroundRepeat = 'no-repeat'; s.backgroundPosition = '2px 2px';
|
115
|
+
|
116
|
+
var footer = pdoc.createElement('div');
|
117
|
+
s = footer.style;
|
118
|
+
s.color = "#fff";
|
119
|
+
s.padding = "2px 8px 2px 8px";
|
120
|
+
s.textAlign = "right";
|
121
|
+
s.position = "relative";
|
122
|
+
|
123
|
+
footer.appendChild(nameLabel);
|
124
|
+
footer.appendChild(pdoc.createTextNode(" "))
|
125
|
+
footer.appendChild(nameTb);
|
126
|
+
|
127
|
+
function Cell(grid, idx) {
|
128
|
+
this.grid = grid;
|
129
|
+
this.idx = idx;
|
130
|
+
|
131
|
+
var td = this.td = pdoc.createElement('td');
|
132
|
+
s = td.style;
|
133
|
+
s.fontWeight = "bold";
|
134
|
+
s.padding = "4px";
|
135
|
+
s.verticalAlign = "middle";
|
136
|
+
s.cursor = "pointer";
|
137
|
+
|
138
|
+
var _this = this;
|
139
|
+
td.onmouseover = function () {
|
140
|
+
_this.onMouseOver();
|
141
|
+
}
|
142
|
+
td.onmouseout = function () {
|
143
|
+
_this.onMouseOut();
|
144
|
+
}
|
145
|
+
td.onclick = function () {
|
146
|
+
_this.onClick();
|
147
|
+
}
|
148
|
+
|
149
|
+
var provider = providers[idx];
|
150
|
+
var icon = pdoc.createElement("img");
|
151
|
+
icon.src = provider ? ('../images/idselector/' + provider.icon) :
|
152
|
+
'../images/idselector/openid.ico';
|
153
|
+
icon.style.width = "16px";
|
154
|
+
icon.style.height = "16px";
|
155
|
+
icon.style.verticalAlign = "middle";
|
156
|
+
td.appendChild(icon);
|
157
|
+
td.appendChild(pdoc.createTextNode(" "));
|
158
|
+
td.appendChild(pdoc.createTextNode(provider ? provider.shortname : "Other OpenID"));
|
159
|
+
|
160
|
+
this.selected = false;
|
161
|
+
}
|
162
|
+
|
163
|
+
_ = Cell.prototype = {};
|
164
|
+
_.onMouseOver = function () {
|
165
|
+
if (!this.selected) {
|
166
|
+
this.td.style.backgroundColor = "#eee";
|
167
|
+
}
|
168
|
+
}
|
169
|
+
_.onMouseOut = function () {
|
170
|
+
if (!this.selected) {
|
171
|
+
this.td.style.backgroundColor = "";
|
172
|
+
}
|
173
|
+
}
|
174
|
+
_.onClick = function () {
|
175
|
+
this.grid.select(this);
|
176
|
+
provider = providers[this.idx];
|
177
|
+
if (this.idx == -1) {
|
178
|
+
oidTb.value = 'http://';
|
179
|
+
oidTb.focus();
|
180
|
+
} else {
|
181
|
+
if (provider["openid2"] && !provider["openid1"]) {
|
182
|
+
oidTb.form.submit();
|
183
|
+
|
184
|
+
inputs = oidTb.form.getElementsByTagName('input')
|
185
|
+
for( var i = 0; i < inputs.length; i++ ) {
|
186
|
+
inputs[i].disabled = true;
|
187
|
+
}
|
188
|
+
|
189
|
+
setTimeout(hidePopup, 1);
|
190
|
+
} else {
|
191
|
+
nameTb.focus();
|
192
|
+
nameTb.select();
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
_.setSelected = function (selected) {
|
198
|
+
this.td.style.backgroundColor = selected ? '#c6d9e8' : "";
|
199
|
+
this.selected = selected;
|
200
|
+
}
|
201
|
+
|
202
|
+
function Grid() {
|
203
|
+
this.table = pdoc.createElement('table');
|
204
|
+
this.table.style.backgroundColor = "#FFF";
|
205
|
+
this.table.style.width = "100%";
|
206
|
+
this.table.style.border = "1px solid #6e91af";
|
207
|
+
this.tbody = pdoc.createElement('tbody');
|
208
|
+
this.table.appendChild(this.tbody);
|
209
|
+
this.maxOffset = (Math.ceil(providers.length/12) - 1) * 12;
|
210
|
+
this.cells = [];
|
211
|
+
for (var i = 0; i < providers.length; i++) {
|
212
|
+
this.cells[i] = new Cell(this, i);
|
213
|
+
}
|
214
|
+
|
215
|
+
this.rows = [pdoc.createElement('tr'), pdoc.createElement('tr'),
|
216
|
+
pdoc.createElement('tr'), pdoc.createElement('tr')];
|
217
|
+
|
218
|
+
this.otherCell = new Cell(this, -1);
|
219
|
+
var links = pdoc.createElement('td');
|
220
|
+
links.style.padding = "4px";
|
221
|
+
links.style.textAlign = "right";
|
222
|
+
links.style.verticalAlign = "middle";
|
223
|
+
links.colSpan = 2;
|
224
|
+
links.innerHTML = '<a href="http://openid.net/" style="color:#6e91af;" target="_blank">Help</a>';
|
225
|
+
|
226
|
+
var bottom_row = pdoc.createElement('tr');
|
227
|
+
bottom_row.style.borderTop = "1px solid #AAA";
|
228
|
+
bottom_row.appendChild(this.otherCell.td);
|
229
|
+
bottom_row.appendChild(links);
|
230
|
+
|
231
|
+
for (var j = 0; j < 4; j++) {this.tbody.appendChild(this.rows[j]);}
|
232
|
+
this.tbody.appendChild(bottom_row);
|
233
|
+
|
234
|
+
this.offset = 0;
|
235
|
+
}
|
236
|
+
|
237
|
+
_ = Grid.prototype = {};
|
238
|
+
_.forward = function() {
|
239
|
+
this.offset = Math.min(this.offset + 12, this.maxOffset)
|
240
|
+
this.gen();
|
241
|
+
}
|
242
|
+
_.back = function() {
|
243
|
+
this.offset = Math.max(this.offset - 12, 0)
|
244
|
+
this.gen();
|
245
|
+
}
|
246
|
+
_.gen = function() {
|
247
|
+
for (var i = 0; i < 4; i++) {
|
248
|
+
var row = this.rows[i];
|
249
|
+
while (row.firstChild) {row.removeChild(row.firstChild);}
|
250
|
+
}
|
251
|
+
for (var i = 0; i < 12; i++) {
|
252
|
+
var row = this.rows[Math.floor(i/3)];
|
253
|
+
var cell = this.cells[this.offset + i];
|
254
|
+
if (cell) {
|
255
|
+
row.appendChild(cell.td);
|
256
|
+
} else {
|
257
|
+
row.appendChild(pdoc.createElement('td'));
|
258
|
+
}
|
259
|
+
}
|
260
|
+
forward.style.visibility = (this.offset == this.maxOffset) ? 'hidden' : '';
|
261
|
+
back.style.visibility = (this.offset == 0) ? 'hidden' : '';
|
262
|
+
popup.style.height = (pbody.offsetHeight + 2) + "px";
|
263
|
+
}
|
264
|
+
|
265
|
+
_.select = function (cell) {
|
266
|
+
if (this.curr) {
|
267
|
+
this.curr.setSelected(false);
|
268
|
+
}
|
269
|
+
|
270
|
+
this.curr = cell;
|
271
|
+
cell.setSelected(true);
|
272
|
+
if (cell.idx > -1) {
|
273
|
+
var provider = providers[cell.idx];
|
274
|
+
|
275
|
+
if (provider["openid2"] && !provider["openid1"]) {
|
276
|
+
nameLabel.style.visibility = 'hidden';
|
277
|
+
nameTb.style.visibility = 'hidden';
|
278
|
+
oidTb.value = provider['website'];
|
279
|
+
} else {
|
280
|
+
nameLabel.style.visibility = '';
|
281
|
+
nameTb.style.visibility = '';
|
282
|
+
|
283
|
+
nameLabel.removeChild(nameLabel.firstChild);
|
284
|
+
var s = pdoc.createTextNode(provider.longname + " " +
|
285
|
+
provider.usercalled + ":");
|
286
|
+
nameLabel.appendChild(s);
|
287
|
+
nameTb.style.backgroundImage = 'url(../images/idselector/' + provider.icon + ')';
|
288
|
+
oidTb.value = provider.url_prefix + "username" +
|
289
|
+
provider.url_suffix;
|
290
|
+
nameTb.value = "username";
|
291
|
+
}
|
292
|
+
btnIcn.src = '../images/idselector/' + provider.icon;
|
293
|
+
} else {
|
294
|
+
nameLabel.style.visibility = 'hidden';
|
295
|
+
nameTb.style.visibility = 'hidden';
|
296
|
+
btnIcn.src = '../images/idselector/openid.ico';
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
_.setName = function (name) {
|
301
|
+
var p = providers[this.curr.idx];
|
302
|
+
oidTb.value = p.url_prefix + name + p.url_suffix;
|
303
|
+
}
|
304
|
+
|
305
|
+
var grid = new Grid();
|
306
|
+
grid.gen();
|
307
|
+
|
308
|
+
pbody.appendChild(header);
|
309
|
+
pbody.appendChild(grid.table);
|
310
|
+
pbody.appendChild(footer);
|
311
|
+
|
312
|
+
function showPopup() {
|
313
|
+
var scrolled = window.ActiveXObject ? (quirksMode ? document.body.scrollLeft : document.documentElement.scrollLeft) : window.pageXOffset;
|
314
|
+
var viewportWidth = quirksMode ? document.body.clientWidth : document.documentElement.clientWidth;
|
315
|
+
var xUpper = viewportWidth + scrolled - 401;
|
316
|
+
var x = oidTb.offsetLeft;
|
317
|
+
var y = oidTb.offsetTop;
|
318
|
+
if (oidTb.clientTop) {
|
319
|
+
y += oidTb.clientTop;
|
320
|
+
} else if (document.defaultView &&
|
321
|
+
document.defaultView.getComputedStyle) {
|
322
|
+
var cs = document.defaultView.getComputedStyle(oidTb, '');
|
323
|
+
y += parseInt(cs.getPropertyValue('border-top-width'));
|
324
|
+
y += parseInt(cs.getPropertyValue('border-bottom-width'));
|
325
|
+
}
|
326
|
+
|
327
|
+
var w = oidTb.offsetParent;
|
328
|
+
while (w) {
|
329
|
+
x += w.offsetLeft;
|
330
|
+
y += w.offsetTop;
|
331
|
+
if (w.clientLeft) {
|
332
|
+
x += w.clientLeft;
|
333
|
+
y += w.clientTop;
|
334
|
+
} else if (document.defaultView &&
|
335
|
+
document.defaultView.getComputedStyle) {
|
336
|
+
|
337
|
+
var cs = document.defaultView.getComputedStyle(w, '');
|
338
|
+
y += parseInt(cs.getPropertyValue('border-top-width'));
|
339
|
+
x += parseInt(cs.getPropertyValue('border-left-width'));
|
340
|
+
}
|
341
|
+
w = w.offsetParent;
|
342
|
+
}
|
343
|
+
y = y + oidTb.offsetHeight;
|
344
|
+
|
345
|
+
x = Math.max(Math.min(x, xUpper), 0);
|
346
|
+
|
347
|
+
var s = popup.style; s.left = x + "px"; s.top = y + "px";
|
348
|
+
s.display = 'block'; s.height = (pbody.offsetHeight + 2) + "px";
|
349
|
+
var html = document.body.parentNode;
|
350
|
+
}
|
351
|
+
|
352
|
+
function hidePopup() {
|
353
|
+
popup.style.display = 'none';
|
354
|
+
}
|
355
|
+
|
356
|
+
function cursorEnd(tb) {
|
357
|
+
if (tb.isTextEdit) {
|
358
|
+
var rng = tb.createTextRange();
|
359
|
+
if (rng) {
|
360
|
+
rng.move("character", tb.value.length);
|
361
|
+
rng.select();
|
362
|
+
}
|
363
|
+
}
|
364
|
+
|
365
|
+
}
|
366
|
+
|
367
|
+
function oidFocus() {
|
368
|
+
if (oidTb.value == "Click to Sign In") {
|
369
|
+
oidTb.value = 'http://';
|
370
|
+
}
|
371
|
+
cursorEnd(oidTb);
|
372
|
+
showPopup();
|
373
|
+
}
|
374
|
+
|
375
|
+
btn.onclick = function(e) {
|
376
|
+
(popup.style.display == 'none') ? showPopup() : hidePopup();
|
377
|
+
if (e) {e.cancelBubble = true;} /* safari */
|
378
|
+
return false;
|
379
|
+
}
|
380
|
+
|
381
|
+
btn.onfocus = function () {
|
382
|
+
btn.blur();
|
383
|
+
}
|
384
|
+
|
385
|
+
forward.onclick = function() {
|
386
|
+
grid.forward();
|
387
|
+
}
|
388
|
+
|
389
|
+
back.onclick = function() {
|
390
|
+
grid.back();
|
391
|
+
}
|
392
|
+
|
393
|
+
oidTb.onkeypress = function(e) {
|
394
|
+
var key;
|
395
|
+
if(window.event) {
|
396
|
+
key = window.event.keyCode;
|
397
|
+
} else if(e.which) {key = e.which;}
|
398
|
+
if (key != 13 && key != 9) {
|
399
|
+
grid.select(grid.otherCell);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
nameTb.onkeydown = function(e) {
|
405
|
+
var key;
|
406
|
+
if(popup.contentWindow.event) {
|
407
|
+
key = popup.contentWindow.event.keyCode;
|
408
|
+
} else if(e.which) {key = e.which;}
|
409
|
+
if (key == 13 || key == 9) {
|
410
|
+
setTimeout(function () {
|
411
|
+
oidTb.onfocus = oidFocus;
|
412
|
+
oidTb.focus();
|
413
|
+
setTimeout(hidePopup, 1);
|
414
|
+
}, 1);
|
415
|
+
}
|
416
|
+
}
|
417
|
+
|
418
|
+
nameTb.onkeyup = function() {
|
419
|
+
var val = this.value;
|
420
|
+
if (!val) {
|
421
|
+
val = "username";
|
422
|
+
this.value = val;
|
423
|
+
this.select();
|
424
|
+
}
|
425
|
+
grid.setName(val);
|
426
|
+
}
|
427
|
+
|
428
|
+
oldOnResize = window.onresize;
|
429
|
+
window.onresize = function (evt) {
|
430
|
+
try {
|
431
|
+
if (popup.style.display == 'block') {
|
432
|
+
showPopup();
|
433
|
+
}
|
434
|
+
} finally {
|
435
|
+
oldOnResize && oldOnResize(evt);
|
436
|
+
}
|
437
|
+
}
|
438
|
+
|
439
|
+
oldOnScroll = window.onscroll;
|
440
|
+
window.onscroll = function (evt) {
|
441
|
+
try {
|
442
|
+
if (popup.style.display == 'block') {
|
443
|
+
showPopup();
|
444
|
+
}
|
445
|
+
} finally {
|
446
|
+
oldOnScroll && oldOnScroll(evt);
|
447
|
+
}
|
448
|
+
}
|
449
|
+
|
450
|
+
if (opIdCookie) {
|
451
|
+
var cell = null;
|
452
|
+
for (var i = 0; i < providers.length; i++) {
|
453
|
+
if (providers[i].id == opIdCookie) {
|
454
|
+
cell = grid.cells[i];
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
if (cell) {
|
459
|
+
grid.select(cell);
|
460
|
+
nameTb.value = unameCookie;
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
464
|
+
if (!grid.curr) {
|
465
|
+
grid.select(grid.otherCell);
|
466
|
+
}
|
467
|
+
if (openidCookie) {
|
468
|
+
oidTb.value = openidCookie;
|
469
|
+
} else if (orig.length == 0) {
|
470
|
+
oidTb.value = "Click to Sign In";
|
471
|
+
}
|
472
|
+
|
473
|
+
function createCookie(name,value,days) {
|
474
|
+
if (days) {
|
475
|
+
var date = new Date();
|
476
|
+
date.setTime(date.getTime()+(days*24*60*60*1000));
|
477
|
+
var expires = "; expires="+date.toGMTString();
|
478
|
+
}
|
479
|
+
else var expires = "";
|
480
|
+
document.cookie = name+"="+encodeURIComponent(value)+expires+"; path=/";
|
481
|
+
}
|
482
|
+
|
483
|
+
oidTb.onfocus = oidFocus;
|
484
|
+
|
485
|
+
|
486
|
+
var form = null;
|
487
|
+
prnt = oidTb.parentNode;
|
488
|
+
while (prnt && prnt.nodeType == 1) {
|
489
|
+
if (prnt.nodeName == 'FORM') {
|
490
|
+
form = prnt;
|
491
|
+
break;
|
492
|
+
}
|
493
|
+
prnt = prnt.parentNode;
|
494
|
+
}
|
495
|
+
if (form) {
|
496
|
+
var oldOnSubmit = form.onsubmit;
|
497
|
+
form.onsubmit = function(evt) {
|
498
|
+
try {
|
499
|
+
createCookie('__openid_selector_openid', oidTb.value, 365);
|
500
|
+
if (grid.curr.idx > -1) {
|
501
|
+
var opId = providers[grid.curr.idx].id;
|
502
|
+
createCookie('__openid_selector_op_id', opId, 365);
|
503
|
+
createCookie('__openid_selector_uname', nameTb.value, 365);
|
504
|
+
} else {
|
505
|
+
createCookie('__openid_selector_op_id','',-1);
|
506
|
+
createCookie('__openid_selector_uname','',-1);
|
507
|
+
}
|
508
|
+
} finally {
|
509
|
+
if (oldOnSubmit) {
|
510
|
+
return oldOnSubmit(evt);
|
511
|
+
}
|
512
|
+
}
|
513
|
+
};
|
514
|
+
}
|
515
|
+
|
516
|
+
if (window.ActiveXObject) {
|
517
|
+
document.body.parentNode.attachEvent('onclick', function() {
|
518
|
+
if (window.event.srcElement != oidTb &&
|
519
|
+
window.event.srcElement != btn) {
|
520
|
+
hidePopup();
|
521
|
+
}
|
522
|
+
});
|
523
|
+
} else {
|
524
|
+
document.body.parentNode.addEventListener('click', function(evt) {
|
525
|
+
if (evt.target != oidTb && evt.target != btn) {hidePopup();}
|
526
|
+
}, false);
|
527
|
+
}
|
528
|
+
}
|
529
|
+
|
530
|
+
var oldOnLoad = window.onload;
|
531
|
+
window.onload = function(evt) {
|
532
|
+
try {
|
533
|
+
gen_selector();
|
534
|
+
} finally {
|
535
|
+
return oldOnLoad && oldOnLoad(evt);
|
536
|
+
}
|
537
|
+
}
|
538
|
+
})();
|