adva 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adva.gemspec +3 -0
- data/app/assets/config/manifest.js +6 -0
- data/app/assets/javascripts/adva_cms/ckeditor.js.erb +12 -0
- data/app/assets/javascripts/adva_cms/concat_main_menus.js +13 -0
- data/app/assets/javascripts/adva_cms/jquery.table_tree.js +704 -0
- data/app/assets/javascripts/adva_cms.js +7 -0
- data/app/assets/javascripts/ckeditor/config.js.erb +94 -0
- data/app/assets/stylesheets/adva_cms/admin/common.scss +15 -1
- data/app/assets/stylesheets/adva_cms/admin/projection.scss +2 -5
- data/app/assets/stylesheets/adva_cms/admin/sidebar.scss +30 -9
- data/app/assets/stylesheets/adva_cms/admin.scss +1 -1
- data/app/controllers/admin/base_controller.rb +10 -24
- data/app/controllers/admin/page/articles_controller.rb +8 -27
- data/app/controllers/admin/page/categories_controller.rb +6 -9
- data/app/controllers/admin/page/links_controller.rb +6 -9
- data/app/controllers/admin/sections_controller.rb +7 -9
- data/app/controllers/admin/sites_controller.rb +9 -12
- data/app/controllers/admin/users_controller.rb +6 -9
- data/app/controllers/articles_controller.rb +30 -52
- data/app/controllers/base_controller.rb +8 -8
- data/app/controllers/password_controller.rb +3 -5
- data/app/controllers/session_controller.rb +3 -5
- data/app/helpers/activities_helper.rb +9 -20
- data/app/helpers/admin/base_helper.rb +4 -22
- data/app/helpers/base_helper.rb +1 -1
- data/app/helpers/content_helper.rb +7 -5
- data/app/helpers/resource_helper.rb +4 -5
- data/app/helpers/users_helper.rb +1 -1
- data/app/models/activity.rb +3 -0
- data/app/models/article.rb +0 -11
- data/app/models/category.rb +3 -3
- data/app/models/content.rb +10 -39
- data/app/models/link.rb +0 -1
- data/app/models/password_mailer.rb +6 -9
- data/app/models/section.rb +6 -7
- data/app/models/site.rb +0 -2
- data/app/models/user.rb +1 -2
- data/app/views/activity_notifier/new_content_notification.html.erb +5 -5
- data/app/views/admin/activities/_activities.html.erb +4 -4
- data/app/views/admin/activities/_comment.html.erb +21 -21
- data/app/views/admin/activities/_content.html.erb +4 -3
- data/app/views/admin/activities/_topic.html.erb +5 -5
- data/app/views/admin/install/confirmation.html.erb +3 -3
- data/app/views/admin/install/index.html.erb +14 -14
- data/app/views/admin/page/articles/_form.html.erb +28 -25
- data/app/views/admin/page/articles/_options.html.erb +3 -4
- data/app/views/admin/page/articles/edit.html.erb +3 -3
- data/app/views/admin/page/articles/new.html.erb +4 -4
- data/app/views/admin/page/categories/edit.html.erb +9 -9
- data/app/views/admin/page/categories/index.html.erb +16 -16
- data/app/views/admin/page/categories/new.html.erb +5 -3
- data/app/views/admin/page/contents/index.html.erb +3 -18
- data/app/views/admin/page/links/_form.html.erb +17 -17
- data/app/views/admin/page/links/_options.html.erb +16 -19
- data/app/views/admin/page/links/edit.html.erb +3 -3
- data/app/views/admin/page/links/new.html.erb +3 -3
- data/app/views/admin/sections/_form.html.haml +5 -5
- data/app/views/admin/sections/edit.html.haml +2 -2
- data/app/views/admin/sections/index.html.erb +18 -18
- data/app/views/admin/sections/new.html.erb +15 -13
- data/app/views/admin/sections/settings/_page.html.haml +4 -6
- data/app/views/admin/shared/_header.html.erb +5 -4
- data/app/views/admin/shared/_section_tree.html.erb +2 -2
- data/app/views/admin/sites/_email_notifications.html.erb +6 -7
- data/app/views/admin/sites/_form.html.erb +7 -7
- data/app/views/admin/sites/_recent_users.html.erb +4 -2
- data/app/views/admin/sites/_unapproved_comments.html.erb +1 -1
- data/app/views/admin/sites/index.html.erb +1 -1
- data/app/views/admin/sites/new.html.erb +2 -2
- data/app/views/admin/sites/show.html.erb +7 -8
- data/app/views/admin/users/edit.html.erb +1 -1
- data/app/views/admin/users/index.html.erb +10 -10
- data/app/views/admin/users/new.html.erb +1 -1
- data/app/views/admin/users/show.html.erb +7 -7
- data/app/views/layouts/admin.html.haml +3 -5
- data/app/views/layouts/login.html.erb +1 -1
- data/app/views/password/edit.html.erb +12 -5
- data/app/views/password/new.html.erb +7 -7
- data/app/views/password_mailer/reset_password_email.html.erb +21 -1
- data/app/views/password_mailer/updated_password_email.html.erb +3 -1
- data/app/views/session/new.html.erb +9 -9
- data/app/views/shared/_flash.html.erb +2 -2
- data/app/views/shared/_sidebar.html.erb +2 -2
- data/config/initializers/ckeditor.rb +61 -0
- data/config/initializers/menus.rb +1 -1
- data/config/initializers/time_format.rb +2 -0
- data/lib/adva/authenticate_user.rb +193 -0
- data/lib/{active_record → adva}/belongs_to_author.rb +4 -4
- data/lib/adva/event.rb +34 -0
- data/lib/adva/extensible_forms.rb +285 -0
- data/lib/{has_options.rb → adva/has_options.rb} +5 -7
- data/lib/adva/has_permalink.rb +36 -0
- data/lib/adva/version.rb +1 -1
- data/lib/adva.rb +10 -36
- data/lib/rails_ext/action_controller/event_helper.rb +1 -1
- data/lib/rails_ext.rb +0 -9
- data/vendor/gems/cacheable_flash/.gitignore +8 -0
- data/vendor/gems/cacheable_flash/Gemfile +8 -0
- data/vendor/gems/cacheable_flash/README.md +35 -0
- data/vendor/gems/cacheable_flash/Rakefile +4 -0
- data/vendor/gems/cacheable_flash/bin/console +15 -0
- data/vendor/gems/cacheable_flash/bin/setup +8 -0
- data/vendor/gems/cacheable_flash/cacheable_flash.gemspec +38 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/controller.rb +29 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/javascript.js +19 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/middleware.rb +30 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/version.rb +5 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash.rb +12 -0
- data/vendor/gems/simple_taggable/lib/tag_list.rb +1 -1
- data/vendor/gems/tags/lib/menu.rb +1 -1
- data/vendor/gems/tags/lib/tags/tag.rb +1 -1
- metadata +72 -145
- data/app/assets/javascripts/adva_cms/admin/jquery.admin.js +0 -23
- data/app/assets/javascripts/adva_cms/admin/jquery.article.js +0 -22
- data/app/assets/javascripts/adva_cms/admin/jquery.cached_pages.js +0 -14
- data/app/assets/javascripts/adva_cms/admin/jquery.table_tree.js +0 -7
- data/app/assets/javascripts/adva_cms/application.js +0 -13
- data/app/assets/javascripts/adva_cms/base.js +0 -4
- data/app/assets/javascripts/adva_cms/cookie.js +0 -49
- data/app/assets/javascripts/adva_cms/jquery/jquery-lowpro.js +0 -224
- data/app/assets/javascripts/adva_cms/jquery/jquery.qtip.js +0 -2085
- data/app/assets/javascripts/adva_cms/jquery/jquery.table_tree.js +0 -307
- data/app/assets/javascripts/adva_cms/jquery/jquery.tablednd_0_5.js +0 -386
- data/app/assets/javascripts/adva_cms/jquery.common.js +0 -41
- data/app/assets/javascripts/adva_cms/jquery.dates.js +0 -51
- data/app/assets/javascripts/adva_cms/jquery.flash.js +0 -59
- data/app/assets/javascripts/adva_cms/jquery.roles.js +0 -25
- data/app/assets/javascripts/adva_cms/json.js +0 -139
- data/app/controllers/admin/base_account_controller.rb +0 -13
- data/app/controllers/admin/install_controller.rb +0 -61
- data/app/controllers/admin/plugins_controller.rb +0 -38
- data/app/helpers/meta_tags_helper.rb +0 -30
- data/app/models/account.rb +0 -7
- data/app/models/event.rb +0 -34
- data/app/views/admin/articles/_meta_tags.html.erb +0 -7
- data/app/views/admin/cached_pages/_filter.html.erb +0 -8
- data/app/views/admin/cached_pages/destroy.js.erb +0 -18
- data/app/views/admin/cached_pages/index.html.erb +0 -26
- data/app/views/admin/plugins/_form.html.erb +0 -11
- data/app/views/admin/plugins/index.html.erb +0 -16
- data/app/views/admin/plugins/show.html.erb +0 -43
- data/app/views/admin/shared/_language_select.html.erb +0 -6
- data/app/views/admin/shared/_section_summary.html.erb +0 -23
- data/app/views/admin/sites/_meta_tags.html.erb +0 -15
- data/app/views/layouts/default.html.erb +0 -38
- data/app/views/layouts/simple.html.erb +0 -22
- data/app/views/shared/_footer.html.erb +0 -4
- data/app/views/shared/messages/insufficient_permissions.html.erb +0 -4
- data/config/initializers/article.rb +0 -8
- data/config/initializers/has_options.rb +0 -2
- data/config/initializers/has_permalink.rb +0 -2
- data/config/initializers/site.rb +0 -8
- data/config/locales/en.yml +0 -1319
- data/lib/action_controller/authenticate_anonymous.rb +0 -69
- data/lib/action_controller/authenticate_user.rb +0 -203
- data/lib/core_ext.rb +0 -7
- data/lib/extensible_forms.rb +0 -284
- data/lib/has_permalink.rb +0 -33
- data/lib/login/helper_integration.rb +0 -11
- data/lib/login/mail_config.rb +0 -39
- data/lib/rails_ext/action_controller/cacheable_flash.rb +0 -30
- data/lib/rails_ext/action_controller/content_for_assignments.rb +0 -106
- data/lib/rails_ext/action_controller/page_caching.rb +0 -23
- data/lib/rails_ext/action_controller/responds_to_parent.rb +0 -46
- data/lib/rails_ext/active_record/exists.rb +0 -5
- data/lib/rails_ext/active_record/sti_instantiation.rb +0 -35
- data/lib/rails_ext/active_record/sticky_changes.rb +0 -30
- data/lib/rails_ext/railties/plugin.rb +0 -58
- data/lib/rails_ext/railties/plugin_configuration.rb +0 -72
- data/lib/registry.rb +0 -49
- data/lib/tasks/translation.rake +0 -69
- data/lib/time_hacks.rb +0 -57
- data/lib/webrat_patch.rb +0 -11
- data/test/meta_tags_test.rb +0 -42
- data/vendor/gems/has_counter/.gitignore +0 -17
- data/vendor/gems/has_counter/Gemfile +0 -4
- data/vendor/gems/has_counter/LICENSE +0 -22
- data/vendor/gems/has_counter/MIT-LICENSE +0 -20
- data/vendor/gems/has_counter/README.markdown +0 -64
- data/vendor/gems/has_counter/README.md +0 -29
- data/vendor/gems/has_counter/Rakefile +0 -2
- data/vendor/gems/has_counter/db/migrate/20080601194338_create_counters_table.rb.rb +0 -13
- data/vendor/gems/has_counter/has_counter.gemspec +0 -17
- data/vendor/gems/has_counter/lib/active_record/has_counter.rb +0 -67
- data/vendor/gems/has_counter/lib/counter.rb +0 -23
- data/vendor/gems/has_counter/lib/has_counter/version.rb +0 -3
- data/vendor/gems/has_counter/lib/has_counter.rb +0 -4
- data/vendor/gems/has_counter/spec/has_counter.sqlite3.db +0 -0
- data/vendor/gems/has_counter/spec/has_counter_spec.rb +0 -55
- data/vendor/gems/has_counter/spec/spec_helper.rb +0 -117
- data/vendor/gems/has_filter/.gitignore +0 -17
- data/vendor/gems/has_filter/Gemfile +0 -4
- data/vendor/gems/has_filter/LICENSE +0 -22
- data/vendor/gems/has_filter/README.md +0 -29
- data/vendor/gems/has_filter/Rakefile +0 -2
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_add.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_left.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_right.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_remove.png +0 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/filter.js +0 -35
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/jquery.filter.js +0 -23
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/alternate/filter.scss +0 -102
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/filter.scss +0 -100
- data/vendor/gems/has_filter/app/helpers/filter_helper.rb +0 -3
- data/vendor/gems/has_filter/has_filter.gemspec +0 -17
- data/vendor/gems/has_filter/init.rb +0 -3
- data/vendor/gems/has_filter/lib/has_filter/active_record/act_macro.rb +0 -102
- data/vendor/gems/has_filter/lib/has_filter/filter/base.rb +0 -67
- data/vendor/gems/has_filter/lib/has_filter/filter/categorized.rb +0 -24
- data/vendor/gems/has_filter/lib/has_filter/filter/chain.rb +0 -45
- data/vendor/gems/has_filter/lib/has_filter/filter/set.rb +0 -80
- data/vendor/gems/has_filter/lib/has_filter/filter/state.rb +0 -25
- data/vendor/gems/has_filter/lib/has_filter/filter/tagged.rb +0 -22
- data/vendor/gems/has_filter/lib/has_filter/filter/text.rb +0 -55
- data/vendor/gems/has_filter/lib/has_filter/filter.rb +0 -17
- data/vendor/gems/has_filter/lib/has_filter/version.rb +0 -3
- data/vendor/gems/has_filter/lib/has_filter.rb +0 -22
- data/vendor/gems/has_filter/test/db/setup.rb +0 -45
- data/vendor/gems/has_filter/test/db/test.sqlite3.db +0 -0
- data/vendor/gems/has_filter/test/fixtures.rb +0 -15
- data/vendor/gems/has_filter/test/has_filter/filter_chain_test.rb +0 -41
- data/vendor/gems/has_filter/test/has_filter/filter_scopes_test.rb +0 -102
- data/vendor/gems/has_filter/test/has_filter/filter_tags_test.rb +0 -113
- data/vendor/gems/has_filter/test/has_filter/integration.rb +0 -15
- data/vendor/gems/has_filter/test/has_filter/scopes_test.rb +0 -48
- data/vendor/gems/has_filter/test/log/test.log +0 -34346
- data/vendor/gems/has_filter/test/models.rb +0 -23
- data/vendor/gems/has_filter/test/templates/has_filter/test/index.html.erb +0 -5
- data/vendor/gems/has_filter/test/test_helper.rb +0 -66
- data/vendor/gems/xss_terminate/.gitignore +0 -17
- data/vendor/gems/xss_terminate/Gemfile +0 -4
- data/vendor/gems/xss_terminate/LICENSE +0 -22
- data/vendor/gems/xss_terminate/MIT-LICENSE +0 -20
- data/vendor/gems/xss_terminate/README +0 -94
- data/vendor/gems/xss_terminate/README.md +0 -29
- data/vendor/gems/xss_terminate/Rakefile +0 -23
- data/vendor/gems/xss_terminate/lib/html5lib_sanitize.rb +0 -2453
- data/vendor/gems/xss_terminate/lib/rails_sanitize.rb +0 -8
- data/vendor/gems/xss_terminate/lib/xss_terminate/version.rb +0 -3
- data/vendor/gems/xss_terminate/lib/xss_terminate.rb +0 -141
- data/vendor/gems/xss_terminate/tasks/xss_terminate_tasks.rake +0 -7
- data/vendor/gems/xss_terminate/test/models/comment.rb +0 -5
- data/vendor/gems/xss_terminate/test/models/entry.rb +0 -7
- data/vendor/gems/xss_terminate/test/models/message.rb +0 -3
- data/vendor/gems/xss_terminate/test/models/person.rb +0 -5
- data/vendor/gems/xss_terminate/test/models/review.rb +0 -5
- data/vendor/gems/xss_terminate/test/schema.rb +0 -34
- data/vendor/gems/xss_terminate/test/setup_test.rb +0 -16
- data/vendor/gems/xss_terminate/test/xss_terminate_test.rb +0 -50
- data/vendor/gems/xss_terminate/xss_terminate.gemspec +0 -17
- /data/lib/tasks/{adva_cms.rake → adva.rake} +0 -0
@@ -1,22 +0,0 @@
|
|
1
|
-
var Excerpt = {
|
2
|
-
show: function(event) {
|
3
|
-
event.preventDefault();
|
4
|
-
$('#article_excerpt_wrapper').show();
|
5
|
-
$('#add_excerpt_hint').hide();
|
6
|
-
$('#hide_excerpt_hint').show();
|
7
|
-
$('#article_excerpt').removeAttr('disabled');
|
8
|
-
},
|
9
|
-
|
10
|
-
hide: function(event) {
|
11
|
-
event.preventDefault();
|
12
|
-
$('#article_excerpt_wrapper').hide();
|
13
|
-
$('#hide_excerpt_hint').hide();
|
14
|
-
$('#add_excerpt_hint').show();
|
15
|
-
$('#article_excerpt').attr('disabled', 'disabled');
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
$(document).ready(function() {
|
20
|
-
$('a#add_excerpt').click(Excerpt.show);
|
21
|
-
$('a#hide_excerpt').click(Excerpt.hide);
|
22
|
-
});
|
@@ -1,14 +0,0 @@
|
|
1
|
-
var CachedPage = {
|
2
|
-
clearAll: function(event) {
|
3
|
-
event.preventDefault();
|
4
|
-
$.ajax({
|
5
|
-
url: this.href,
|
6
|
-
type: 'delete',
|
7
|
-
dataType: 'script'
|
8
|
-
});
|
9
|
-
}
|
10
|
-
}
|
11
|
-
|
12
|
-
$(document).ready(function() {
|
13
|
-
$('td.actions a.clear').click(CachedPage.clearAll);
|
14
|
-
});
|
@@ -1,13 +0,0 @@
|
|
1
|
-
//= require jquery
|
2
|
-
//= require jquery_ujs
|
3
|
-
//= require adva_cms/base
|
4
|
-
//= require adva_cms/jquery/jquery.qtip
|
5
|
-
//= require adva_cms/jquery/jquery-lowpro
|
6
|
-
//= require adva_cms/jquery.common
|
7
|
-
//= require adva_cms/admin/jquery.admin
|
8
|
-
//= require adva_cms/jquery/jquery.tablednd_0_5
|
9
|
-
//= require adva_cms/jquery/jquery.table_tree
|
10
|
-
//= require adva_cms/admin/jquery.table_tree
|
11
|
-
//= require adva_cms/admin/jquery.article
|
12
|
-
//= require adva_cms/admin/jquery.cached_pages
|
13
|
-
//= require has_filter/jquery.filter
|
@@ -1,49 +0,0 @@
|
|
1
|
-
// From http://wiki.script.aculo.us/scriptaculous/show/Cookie
|
2
|
-
var Cookie = {
|
3
|
-
set: function(name, value, daysToExpire) {
|
4
|
-
var expire = '';
|
5
|
-
if(!daysToExpire) daysToExpire = 365;
|
6
|
-
var d = new Date();
|
7
|
-
d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));
|
8
|
-
expire = 'expires=' + d.toGMTString();
|
9
|
-
var path = "path=/"
|
10
|
-
var cookieValue = escape(name) + '=' + escape(value || '') + '; ' + path + '; ' + expire + ';';
|
11
|
-
return document.cookie = cookieValue;
|
12
|
-
},
|
13
|
-
get: function(name) {
|
14
|
-
var cookie = document.cookie.match(new RegExp('(^|;)\\s*' + escape(name) + '=([^;\\s]+)'));
|
15
|
-
return (cookie ? unescape(cookie[2]) : null);
|
16
|
-
},
|
17
|
-
erase: function(name) {
|
18
|
-
var cookie = Cookie.get(name) || true;
|
19
|
-
Cookie.set(name, '', -1);
|
20
|
-
return cookie;
|
21
|
-
},
|
22
|
-
eraseAll: function() {
|
23
|
-
// Get cookie string and separate into individual cookie phrases:
|
24
|
-
var cookieString = "" + document.cookie;
|
25
|
-
var cookieArray = cookieString.split("; ");
|
26
|
-
|
27
|
-
// Try to delete each cookie:
|
28
|
-
for(var i = 0; i < cookieArray.length; ++ i)
|
29
|
-
{
|
30
|
-
var singleCookie = cookieArray[i].split("=");
|
31
|
-
if(singleCookie.length != 2)
|
32
|
-
continue;
|
33
|
-
var name = unescape(singleCookie[0]);
|
34
|
-
Cookie.erase(name);
|
35
|
-
}
|
36
|
-
},
|
37
|
-
accept: function() {
|
38
|
-
if (typeof navigator.cookieEnabled == 'boolean') {
|
39
|
-
return navigator.cookieEnabled;
|
40
|
-
}
|
41
|
-
Cookie.set('_test', '1');
|
42
|
-
return (Cookie.erase('_test') === '1');
|
43
|
-
},
|
44
|
-
exists: function(cookieName) {
|
45
|
-
var cookieValue = Cookie.get(cookieName);
|
46
|
-
if(!cookieValue) return false;
|
47
|
-
return cookieValue.toString() != "";
|
48
|
-
}
|
49
|
-
};
|
@@ -1,224 +0,0 @@
|
|
1
|
-
// http://github.com/danwrong/low-pro-for-jquery/
|
2
|
-
|
3
|
-
(function($) {
|
4
|
-
|
5
|
-
var addMethods = function(source) {
|
6
|
-
var ancestor = this.superclass && this.superclass.prototype;
|
7
|
-
var properties = $.keys(source);
|
8
|
-
|
9
|
-
if (!$.keys({ toString: true }).length) properties.push("toString", "valueOf");
|
10
|
-
|
11
|
-
for (var i = 0, length = properties.length; i < length; i++) {
|
12
|
-
var property = properties[i], value = source[property];
|
13
|
-
if (ancestor && $.isFunction(value) && $.argumentNames(value)[0] == "$super") {
|
14
|
-
|
15
|
-
var method = value, value = $.extend($.wrap((function(m) {
|
16
|
-
return function() { return ancestor[m].apply(this, arguments) };
|
17
|
-
})(property), method), {
|
18
|
-
valueOf: function() { return method },
|
19
|
-
toString: function() { return method.toString() }
|
20
|
-
});
|
21
|
-
}
|
22
|
-
this.prototype[property] = value;
|
23
|
-
}
|
24
|
-
|
25
|
-
return this;
|
26
|
-
}
|
27
|
-
|
28
|
-
$.extend({
|
29
|
-
keys: function(obj) {
|
30
|
-
var keys = [];
|
31
|
-
for (var key in obj) keys.push(key);
|
32
|
-
return keys;
|
33
|
-
},
|
34
|
-
|
35
|
-
argumentNames: function(func) {
|
36
|
-
var names = func.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(/, ?/);
|
37
|
-
return names.length == 1 && !names[0] ? [] : names;
|
38
|
-
},
|
39
|
-
|
40
|
-
bind: function(func, scope) {
|
41
|
-
return function() {
|
42
|
-
return func.apply(scope, $.makeArray(arguments));
|
43
|
-
}
|
44
|
-
},
|
45
|
-
|
46
|
-
wrap: function(func, wrapper) {
|
47
|
-
var __method = func;
|
48
|
-
return function() {
|
49
|
-
return wrapper.apply(this, [$.bind(__method, this)].concat($.makeArray(arguments)));
|
50
|
-
}
|
51
|
-
},
|
52
|
-
|
53
|
-
klass: function() {
|
54
|
-
var parent = null, properties = $.makeArray(arguments);
|
55
|
-
if ($.isFunction(properties[0])) parent = properties.shift();
|
56
|
-
|
57
|
-
var klass = function() {
|
58
|
-
this.initialize.apply(this, arguments);
|
59
|
-
};
|
60
|
-
|
61
|
-
klass.superclass = parent;
|
62
|
-
klass.subclasses = [];
|
63
|
-
klass.addMethods = addMethods;
|
64
|
-
|
65
|
-
if (parent) {
|
66
|
-
var subclass = function() { };
|
67
|
-
subclass.prototype = parent.prototype;
|
68
|
-
klass.prototype = new subclass;
|
69
|
-
parent.subclasses.push(klass);
|
70
|
-
}
|
71
|
-
|
72
|
-
for (var i = 0; i < properties.length; i++)
|
73
|
-
klass.addMethods(properties[i]);
|
74
|
-
|
75
|
-
if (!klass.prototype.initialize)
|
76
|
-
klass.prototype.initialize = function() {};
|
77
|
-
|
78
|
-
klass.prototype.constructor = klass;
|
79
|
-
|
80
|
-
return klass;
|
81
|
-
},
|
82
|
-
delegate: function(rules) {
|
83
|
-
return function(e) {
|
84
|
-
var target = $(e.target), parent = null;
|
85
|
-
for (var selector in rules) {
|
86
|
-
if (target.is(selector) || ((parent = target.parents(selector)) && parent.length > 0)) {
|
87
|
-
return rules[selector].apply(this, [parent || target].concat($.makeArray(arguments)));
|
88
|
-
}
|
89
|
-
parent = null;
|
90
|
-
}
|
91
|
-
}
|
92
|
-
}
|
93
|
-
});
|
94
|
-
|
95
|
-
var bindEvents = function(instance) {
|
96
|
-
for (var member in instance) {
|
97
|
-
if (member.match(/^on(.+)/) && typeof instance[member] == 'function') {
|
98
|
-
instance.element.bind(RegExp.$1, $.bind(instance[member], instance));
|
99
|
-
}
|
100
|
-
}
|
101
|
-
}
|
102
|
-
|
103
|
-
var behaviorWrapper = function(behavior) {
|
104
|
-
return $.klass(behavior, {
|
105
|
-
initialize: function($super, element, args) {
|
106
|
-
this.element = $(element);
|
107
|
-
if ($super) $super.apply(this, args);
|
108
|
-
}
|
109
|
-
});
|
110
|
-
}
|
111
|
-
|
112
|
-
var attachBehavior = function(el, behavior, args) {
|
113
|
-
var wrapper = behaviorWrapper(behavior);
|
114
|
-
instance = new wrapper(el, args);
|
115
|
-
|
116
|
-
bindEvents(instance);
|
117
|
-
|
118
|
-
if (!behavior.instances) behavior.instances = [];
|
119
|
-
|
120
|
-
behavior.instances.push(instance);
|
121
|
-
|
122
|
-
return instance;
|
123
|
-
};
|
124
|
-
|
125
|
-
|
126
|
-
$.fn.extend({
|
127
|
-
attach: function() {
|
128
|
-
var args = $.makeArray(arguments), behavior = args.shift();
|
129
|
-
|
130
|
-
if ($.livequery && this.selector) {
|
131
|
-
return this.livequery(function() {
|
132
|
-
attachBehavior(this, behavior, args);
|
133
|
-
});
|
134
|
-
} else {
|
135
|
-
return this.each(function() {
|
136
|
-
attachBehavior(this, behavior, args);
|
137
|
-
});
|
138
|
-
}
|
139
|
-
},
|
140
|
-
attachAndReturn: function() {
|
141
|
-
var args = $.makeArray(arguments), behavior = args.shift();
|
142
|
-
|
143
|
-
return $.map(this, function(el) {
|
144
|
-
return attachBehavior(el, behavior, args);
|
145
|
-
});
|
146
|
-
},
|
147
|
-
delegate: function(type, rules) {
|
148
|
-
return this.bind(type, $.delegate(rules));
|
149
|
-
},
|
150
|
-
attached: function(behavior) {
|
151
|
-
var instances = [];
|
152
|
-
|
153
|
-
if (!behavior.instances) return instances;
|
154
|
-
|
155
|
-
this.each(function(i, element) {
|
156
|
-
$.each(behavior.instances, function(i, instance) {
|
157
|
-
if (instance.element.get(0) == element) instances.push(instance);
|
158
|
-
});
|
159
|
-
});
|
160
|
-
|
161
|
-
return instances;
|
162
|
-
},
|
163
|
-
firstAttached: function(behavior) {
|
164
|
-
return this.attached(behavior)[0];
|
165
|
-
}
|
166
|
-
});
|
167
|
-
|
168
|
-
Remote = $.klass({
|
169
|
-
initialize: function(options) {
|
170
|
-
if (this.element.attr('nodeName') == 'FORM') this.element.attach(Remote.Form, options);
|
171
|
-
else this.element.attach(Remote.Link, options);
|
172
|
-
}
|
173
|
-
});
|
174
|
-
|
175
|
-
Remote.Base = $.klass({
|
176
|
-
initialize : function(options) {
|
177
|
-
this.options = $.extend({
|
178
|
-
|
179
|
-
}, options || {});
|
180
|
-
},
|
181
|
-
_makeRequest : function(options) {
|
182
|
-
$.ajax(options);
|
183
|
-
return false;
|
184
|
-
}
|
185
|
-
});
|
186
|
-
|
187
|
-
Remote.Link = $.klass(Remote.Base, {
|
188
|
-
onclick: function() {
|
189
|
-
var options = $.extend({ url: this.element.attr('href'), type: 'GET' }, this.options);
|
190
|
-
return this._makeRequest(options);
|
191
|
-
}
|
192
|
-
});
|
193
|
-
|
194
|
-
Remote.Form = $.klass(Remote.Base, {
|
195
|
-
onclick: function(e) {
|
196
|
-
var target = e.target;
|
197
|
-
|
198
|
-
if ($.inArray(target.nodeName.toLowerCase(), ['input', 'button']) >= 0 && target.type.match(/submit|image/))
|
199
|
-
this._submitButton = target;
|
200
|
-
},
|
201
|
-
onsubmit: function() {
|
202
|
-
var data = this.element.serializeArray();
|
203
|
-
|
204
|
-
if (this._submitButton) data.push({ name: this._submitButton.name, value: this._submitButton.value });
|
205
|
-
|
206
|
-
var options = $.extend({
|
207
|
-
url : this.element.attr('action'),
|
208
|
-
type : this.element.attr('method') || 'GET',
|
209
|
-
data : data
|
210
|
-
}, this.options);
|
211
|
-
|
212
|
-
this._makeRequest(options);
|
213
|
-
|
214
|
-
return false;
|
215
|
-
}
|
216
|
-
});
|
217
|
-
|
218
|
-
$.ajaxSetup({
|
219
|
-
beforeSend: function(xhr) {
|
220
|
-
xhr.setRequestHeader("Accept", "text/javascript, text/html, application/xml, text/xml, */*");
|
221
|
-
}
|
222
|
-
});
|
223
|
-
|
224
|
-
})(jQuery);
|