social_stream 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +6 -0
- data/app/controllers/api_controller.rb +39 -0
- data/app/controllers/frontpage_controller.rb +2 -0
- data/app/controllers/groups_controller.rb +8 -2
- data/app/controllers/likes_controller.rb +9 -29
- data/app/controllers/logos_controller.rb +21 -0
- data/app/controllers/mailbox/conversation_controller.rb +110 -0
- data/app/controllers/mailbox_controller.rb +35 -0
- data/app/controllers/posts_controller.rb +2 -0
- data/app/controllers/profiles_controller.rb +3 -0
- data/app/controllers/ties_controller.rb +10 -0
- data/app/controllers/users_controller.rb +5 -5
- data/app/helpers/groups_helper.rb +0 -2
- data/app/helpers/subjects_helper.rb +11 -0
- data/app/helpers/ties_helper.rb +1 -1
- data/app/models/activity.rb +24 -1
- data/app/models/activity_object.rb +10 -0
- data/app/models/activity_object_activity.rb +10 -0
- data/app/models/actor.rb +87 -60
- data/app/models/group.rb +10 -4
- data/app/models/like.rb +34 -0
- data/app/models/logo.rb +51 -0
- data/app/models/permission.rb +7 -5
- data/app/models/profile.rb +24 -8
- data/app/models/tie.rb +15 -2
- data/app/models/user.rb +2 -2
- data/app/views/activities/_activities.html.erb +1 -1
- data/app/views/activities/_new.html.erb +12 -7
- data/app/views/api/activity_atom_feed.atom.builder +40 -0
- data/app/views/comments/_new.html.erb +1 -1
- data/app/views/devise/passwords/edit.html.erb +21 -0
- data/app/views/devise/passwords/new.html.erb +16 -0
- data/app/views/devise/registrations/new.html.erb +35 -19
- data/app/views/devise/sessions/new.html.erb +30 -0
- data/app/views/frontpage/_header.html.erb +18 -20
- data/app/views/frontpage/_search.html.erb +13 -0
- data/app/views/frontpage/_sponsor.html.erb +12 -13
- data/app/views/frontpage/index.html.erb +88 -80
- data/app/views/groups/_group.html.erb +2 -6
- data/app/views/groups/_index.html.erb +22 -25
- data/app/views/groups/_logo.html.erb +1 -1
- data/app/views/groups/_new.html.erb +56 -39
- data/app/views/groups/_profile.html.erb +142 -0
- data/app/views/groups/_sidebar_index.html.erb +73 -0
- data/app/views/groups/{_middle_show.html.erb → _sidebar_show.html.erb} +2 -2
- data/app/views/groups/_tabs.html.erb +37 -31
- data/app/views/groups/_toolbar_show.html.erb +12 -0
- data/app/views/groups/edit.html.erb +136 -0
- data/app/views/groups/index.html.erb +47 -46
- data/app/views/groups/new.html.erb +2 -0
- data/app/views/groups/show.html.erb +9 -4
- data/app/views/groups/update.js.erb +39 -0
- data/app/views/home/_groups.html.erb +4 -5
- data/app/views/{users/_middle_index.html.erb → home/_sidebar.html.erb} +0 -2
- data/app/views/home/index.html.erb +3 -5
- data/app/views/layouts/_footer.html.erb +4 -0
- data/app/views/layouts/_header.erb +29 -37
- data/app/views/layouts/_representation.html.erb +2 -2
- data/app/views/layouts/application.html.erb +47 -74
- data/app/views/layouts/frontpage.html.erb +27 -48
- data/app/views/layouts/test.html +44 -0
- data/app/views/likes/create.js.erb +1 -1
- data/app/views/likes/destroy.js.erb +1 -1
- data/app/views/logos/_form.html.erb +33 -0
- data/app/views/logos/_precrop.html.erb +48 -0
- data/app/views/logos/edit.html.erb +6 -0
- data/app/views/logos/index.html.erb +27 -0
- data/app/views/logos/new.html.erb +20 -0
- data/app/views/logos/show.html.erb +5 -0
- data/app/views/mailbox/_conversation.html.erb +23 -0
- data/app/views/mailbox/_conversations.html.erb +9 -0
- data/app/views/mailbox/_index.html.erb +16 -0
- data/app/views/{messages → mailbox}/_location.html.erb +0 -0
- data/app/views/mailbox/_menu_options.html.erb +19 -0
- data/app/views/mailbox/_show.html.erb +15 -0
- data/app/views/mailbox/conversation/_conversation.html.erb +40 -0
- data/app/views/mailbox/conversation/_form.html.erb +54 -0
- data/app/views/mailbox/conversation/_location.html.erb +3 -0
- data/app/views/mailbox/conversation/_new.html.erb +19 -0
- data/app/views/mailbox/conversation/_show.html.erb +27 -0
- data/app/views/mailbox/conversation/edit.html.erb +6 -0
- data/app/views/mailbox/conversation/new.html.erb +10 -0
- data/app/views/mailbox/conversation/new.js.erb +1 -0
- data/app/views/mailbox/conversation/show.html.erb +1 -0
- data/app/views/{messages → mailbox}/edit.html.erb +0 -0
- data/app/views/mailbox/index.html.erb +10 -0
- data/app/views/{messages → mailbox}/index.js.erb +0 -0
- data/app/views/mailbox/new.html.erb +14 -0
- data/app/views/mailbox/show.html.erb +11 -0
- data/app/views/mailbox/show.js.erb +1 -0
- data/app/views/menu/_group.html.erb +15 -0
- data/{lib/generators/social_stream/templates/public/stylesheets/users.css → app/views/menu/_home_user.html.erb} +0 -0
- data/app/views/menu/_options.html.erb +11 -0
- data/app/views/menu/_services.html.erb +11 -0
- data/app/views/menu/_tiesGroup.html.erb +14 -0
- data/app/views/menu/_tiesUser.html.erb +11 -0
- data/app/views/menu/_user.html.erb +15 -0
- data/app/views/profiles/show.html.erb +1 -0
- data/app/views/subjects/_contacts.html.erb +8 -9
- data/app/views/subjects/_menu_options.html.erb +14 -0
- data/app/views/subjects/_toolbar.html.erb +15 -0
- data/app/views/ties/_new.html.erb +3 -2
- data/app/views/ties/_pendings.html.erb +7 -12
- data/app/views/ties/_suggestions.html.erb +12 -12
- data/app/views/ties/_tie.html.erb +9 -7
- data/app/views/ties/new.js.erb +1 -2
- data/app/views/users/_groups.html.erb +4 -3
- data/app/views/users/_index.html.erb +24 -22
- data/app/views/users/_logo.html.erb +1 -1
- data/app/views/users/_profile.html.erb +167 -164
- data/app/views/users/_sidebar_index.html.erb +6 -0
- data/app/views/users/{_middle_show.html.erb → _sidebar_show.html.erb} +0 -0
- data/app/views/users/_toolbar_show.html.erb +17 -0
- data/app/views/users/edit.html.erb +193 -165
- data/app/views/users/index.html.erb +34 -47
- data/{spec/dummy/public/stylesheets/.gitkeep → app/views/users/info.html.erb} +0 -0
- data/app/views/users/show.html.erb +4 -4
- data/app/views/users/show.xml.builder +28 -0
- data/app/views/users/update.js.erb +3 -1
- data/config/locales/en.yml +88 -9
- data/config/routes.rb +30 -14
- data/lib/generators/social_stream/install_generator.rb +8 -2
- data/lib/generators/social_stream/templates/migration.rb +75 -81
- data/lib/generators/social_stream/templates/public/images/{frontpage/facebook.png → btn/1-facebook.png} +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/edit.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/facebook.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/linkedin.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/twitter-follow-icon.png +0 -0
- data/lib/generators/social_stream/templates/public/images/btn/twitter.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/meet.png +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/share.png +0 -0
- data/lib/generators/social_stream/templates/public/images/icons/favicon.ico +0 -0
- data/lib/generators/social_stream/templates/public/images/logo.png +0 -0
- data/lib/generators/social_stream/templates/public/images/w3c_css.png +0 -0
- data/lib/generators/social_stream/templates/public/images/w3c_xhtml.png +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-1.8.4.custom.min.js +3 -3
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui-personalized-1.5.2.packed.js +1 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery-ui.min.js +3 -3
- data/lib/generators/social_stream/templates/public/javascripts/jquery.Jcrop.min.js +163 -0
- data/lib/generators/social_stream/templates/public/javascripts/jquery.fcbkcomplete.min.js +76 -76
- data/lib/generators/social_stream/templates/public/javascripts/jquery.min.js +156 -5
- data/lib/generators/social_stream/templates/public/javascripts/main.js +9 -0
- data/lib/generators/social_stream/templates/public/javascripts/menu-collapsed.js +42 -0
- data/lib/generators/social_stream/templates/public/javascripts/menu.js +1 -1
- data/lib/generators/social_stream/templates/public/javascripts/rails.js +30 -29
- data/lib/generators/social_stream/templates/public/javascripts/superfish.js +121 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/activities.css +72 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/base.css +150 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/carousel.css +23 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{fcbkComplete.css → default/fcbkComplete.css} +2 -2
- data/lib/generators/social_stream/templates/public/stylesheets/default/footer.css +25 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/frontpage.css +54 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/header.css +44 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/home.css +44 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{images → default/images}/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jqcloud.css +15 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{jquery-ui.css → default/jquery-ui.css} +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/jquery.Jcrop.css +35 -0
- data/lib/generators/social_stream/templates/public/stylesheets/default/menu.css +33 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.7.3.custom.css +0 -0
- data/lib/generators/social_stream/templates/public/stylesheets/{smoothness → default/smoothness}/jquery-ui-1.8.4.custom.css +0 -0
- data/lib/social_stream.rb +11 -2
- data/lib/social_stream/ability.rb +21 -3
- data/lib/social_stream/models/object.rb +5 -3
- data/lib/social_stream/models/subject.rb +50 -31
- data/lib/social_stream/rails.rb +5 -0
- data/lib/social_stream/test_helpers.rb +11 -0
- data/lib/social_stream/test_helpers/controllers.rb +64 -0
- data/lib/social_stream/version.rb +1 -1
- data/lib/tasks/db/populate.rake +110 -25
- data/social_stream.gemspec +7 -1
- data/spec/controllers/contacts_controller_spec.rb +1 -1
- data/spec/controllers/groups_controller_spec.rb +8 -0
- data/spec/controllers/home_controller_spec.rb +15 -0
- data/spec/controllers/likes_controller_spec.rb +29 -0
- data/spec/controllers/posts_controller_spec.rb +41 -0
- data/spec/controllers/profiles_controller_spec.rb +46 -0
- data/spec/controllers/users_controller_spec.rb +2 -2
- data/spec/dummy/.gitignore +4 -0
- data/spec/dummy/config/database.yml +8 -0
- data/spec/dummy/config/environments/test_pg.rb +35 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/factories/group.rb +1 -1
- data/spec/integration/navigation_spec.rb +1 -1
- data/spec/models/actor_spec.rb +4 -4
- data/spec/models/user_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -1
- data/spec/support/db.rb +7 -0
- metadata +198 -116
- data/app/controllers/messages_controller.rb +0 -3
- data/app/models/message.rb +0 -2
- data/app/views/groups/_middle_index.html.erb +0 -74
- data/app/views/groups/_right_index.html.erb +0 -19
- data/app/views/groups/_right_show.html.erb +0 -8
- data/app/views/home/_middle.html.erb +0 -4
- data/app/views/home/_options.html.erb +0 -8
- data/app/views/home/_right.html.erb +0 -17
- data/app/views/messages/_form.html.erb +0 -24
- data/app/views/messages/_index.html.erb +0 -24
- data/app/views/messages/_message.html.erb +0 -17
- data/app/views/messages/_messages.html.erb +0 -2
- data/app/views/messages/index.html.erb +0 -1
- data/app/views/messages/new.html.erb +0 -14
- data/app/views/messages/show.html.erb +0 -21
- data/app/views/users/_menu.html.erb +0 -7
- data/app/views/users/_options.html.erb +0 -5
- data/app/views/users/_right_index.html.erb +0 -19
- data/app/views/users/_right_show.html.erb +0 -14
- data/lib/generators/social_stream/templates/public/images/btn/btn_share.png +0 -0
- data/lib/generators/social_stream/templates/public/images/favicon.ico +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/collaborate.gif +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/meet.gif +0 -0
- data/lib/generators/social_stream/templates/public/images/frontpage/share.gif +0 -0
- data/lib/generators/social_stream/templates/public/javascripts/hoverIntent.js +0 -84
- data/lib/generators/social_stream/templates/public/stylesheets/activities.css +0 -235
- data/lib/generators/social_stream/templates/public/stylesheets/base.css +0 -68
- data/lib/generators/social_stream/templates/public/stylesheets/boxy.css +0 -49
- data/lib/generators/social_stream/templates/public/stylesheets/browse.css +0 -162
- data/lib/generators/social_stream/templates/public/stylesheets/carousel.css +0 -57
- data/lib/generators/social_stream/templates/public/stylesheets/edit_user.css +0 -104
- data/lib/generators/social_stream/templates/public/stylesheets/frontpage.css +0 -708
- data/lib/generators/social_stream/templates/public/stylesheets/header.css +0 -116
- data/lib/generators/social_stream/templates/public/stylesheets/home.css +0 -121
- data/lib/generators/social_stream/templates/public/stylesheets/index.css +0 -625
- data/lib/generators/social_stream/templates/public/stylesheets/jqcloud.css +0 -62
- data/lib/generators/social_stream/templates/public/stylesheets/menu.css +0 -83
- data/lib/generators/social_stream/templates/public/stylesheets/message.css +0 -46
- data/lib/generators/social_stream/templates/public/stylesheets/middle.css +0 -113
- data/lib/generators/social_stream/templates/public/stylesheets/right.css +0 -58
- data/lib/generators/social_stream/templates/public/stylesheets/social_stream.css +0 -78
- data/lib/generators/social_stream/templates/public/stylesheets/ui.dropdownchecklist.css +0 -21
- data/spec/dummy/db/.gitignore +0 -2
- data/spec/dummy/log/.gitignore +0 -1
- data/spec/dummy/public/javascripts/application.js +0 -2
- data/spec/dummy/public/javascripts/controls.js +0 -965
- data/spec/dummy/public/javascripts/dragdrop.js +0 -974
- data/spec/dummy/public/javascripts/effects.js +0 -1123
- data/spec/dummy/public/javascripts/prototype.js +0 -6001
- data/spec/dummy/public/javascripts/rails.js +0 -175
@@ -1,175 +0,0 @@
|
|
1
|
-
(function() {
|
2
|
-
// Technique from Juriy Zaytsev
|
3
|
-
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
|
4
|
-
function isEventSupported(eventName) {
|
5
|
-
var el = document.createElement('div');
|
6
|
-
eventName = 'on' + eventName;
|
7
|
-
var isSupported = (eventName in el);
|
8
|
-
if (!isSupported) {
|
9
|
-
el.setAttribute(eventName, 'return;');
|
10
|
-
isSupported = typeof el[eventName] == 'function';
|
11
|
-
}
|
12
|
-
el = null;
|
13
|
-
return isSupported;
|
14
|
-
}
|
15
|
-
|
16
|
-
function isForm(element) {
|
17
|
-
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
|
18
|
-
}
|
19
|
-
|
20
|
-
function isInput(element) {
|
21
|
-
if (Object.isElement(element)) {
|
22
|
-
var name = element.nodeName.toUpperCase()
|
23
|
-
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
|
24
|
-
}
|
25
|
-
else return false
|
26
|
-
}
|
27
|
-
|
28
|
-
var submitBubbles = isEventSupported('submit'),
|
29
|
-
changeBubbles = isEventSupported('change')
|
30
|
-
|
31
|
-
if (!submitBubbles || !changeBubbles) {
|
32
|
-
// augment the Event.Handler class to observe custom events when needed
|
33
|
-
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
|
34
|
-
function(init, element, eventName, selector, callback) {
|
35
|
-
init(element, eventName, selector, callback)
|
36
|
-
// is the handler being attached to an element that doesn't support this event?
|
37
|
-
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
|
38
|
-
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
|
39
|
-
// "submit" => "emulated:submit"
|
40
|
-
this.eventName = 'emulated:' + this.eventName
|
41
|
-
}
|
42
|
-
}
|
43
|
-
)
|
44
|
-
}
|
45
|
-
|
46
|
-
if (!submitBubbles) {
|
47
|
-
// discover forms on the page by observing focus events which always bubble
|
48
|
-
document.on('focusin', 'form', function(focusEvent, form) {
|
49
|
-
// special handler for the real "submit" event (one-time operation)
|
50
|
-
if (!form.retrieve('emulated:submit')) {
|
51
|
-
form.on('submit', function(submitEvent) {
|
52
|
-
var emulated = form.fire('emulated:submit', submitEvent, true)
|
53
|
-
// if custom event received preventDefault, cancel the real one too
|
54
|
-
if (emulated.returnValue === false) submitEvent.preventDefault()
|
55
|
-
})
|
56
|
-
form.store('emulated:submit', true)
|
57
|
-
}
|
58
|
-
})
|
59
|
-
}
|
60
|
-
|
61
|
-
if (!changeBubbles) {
|
62
|
-
// discover form inputs on the page
|
63
|
-
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
|
64
|
-
// special handler for real "change" events
|
65
|
-
if (!input.retrieve('emulated:change')) {
|
66
|
-
input.on('change', function(changeEvent) {
|
67
|
-
input.fire('emulated:change', changeEvent, true)
|
68
|
-
})
|
69
|
-
input.store('emulated:change', true)
|
70
|
-
}
|
71
|
-
})
|
72
|
-
}
|
73
|
-
|
74
|
-
function handleRemote(element) {
|
75
|
-
var method, url, params;
|
76
|
-
|
77
|
-
var event = element.fire("ajax:before");
|
78
|
-
if (event.stopped) return false;
|
79
|
-
|
80
|
-
if (element.tagName.toLowerCase() === 'form') {
|
81
|
-
method = element.readAttribute('method') || 'post';
|
82
|
-
url = element.readAttribute('action');
|
83
|
-
params = element.serialize();
|
84
|
-
} else {
|
85
|
-
method = element.readAttribute('data-method') || 'get';
|
86
|
-
url = element.readAttribute('href');
|
87
|
-
params = {};
|
88
|
-
}
|
89
|
-
|
90
|
-
new Ajax.Request(url, {
|
91
|
-
method: method,
|
92
|
-
parameters: params,
|
93
|
-
evalScripts: true,
|
94
|
-
|
95
|
-
onComplete: function(request) { element.fire("ajax:complete", request); },
|
96
|
-
onSuccess: function(request) { element.fire("ajax:success", request); },
|
97
|
-
onFailure: function(request) { element.fire("ajax:failure", request); }
|
98
|
-
});
|
99
|
-
|
100
|
-
element.fire("ajax:after");
|
101
|
-
}
|
102
|
-
|
103
|
-
function handleMethod(element) {
|
104
|
-
var method = element.readAttribute('data-method'),
|
105
|
-
url = element.readAttribute('href'),
|
106
|
-
csrf_param = $$('meta[name=csrf-param]')[0],
|
107
|
-
csrf_token = $$('meta[name=csrf-token]')[0];
|
108
|
-
|
109
|
-
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
|
110
|
-
element.parentNode.insert(form);
|
111
|
-
|
112
|
-
if (method !== 'post') {
|
113
|
-
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
|
114
|
-
form.insert(field);
|
115
|
-
}
|
116
|
-
|
117
|
-
if (csrf_param) {
|
118
|
-
var param = csrf_param.readAttribute('content'),
|
119
|
-
token = csrf_token.readAttribute('content'),
|
120
|
-
field = new Element('input', { type: 'hidden', name: param, value: token });
|
121
|
-
form.insert(field);
|
122
|
-
}
|
123
|
-
|
124
|
-
form.submit();
|
125
|
-
}
|
126
|
-
|
127
|
-
|
128
|
-
document.on("click", "*[data-confirm]", function(event, element) {
|
129
|
-
var message = element.readAttribute('data-confirm');
|
130
|
-
if (!confirm(message)) event.stop();
|
131
|
-
});
|
132
|
-
|
133
|
-
document.on("click", "a[data-remote]", function(event, element) {
|
134
|
-
if (event.stopped) return;
|
135
|
-
handleRemote(element);
|
136
|
-
event.stop();
|
137
|
-
});
|
138
|
-
|
139
|
-
document.on("click", "a[data-method]", function(event, element) {
|
140
|
-
if (event.stopped) return;
|
141
|
-
handleMethod(element);
|
142
|
-
event.stop();
|
143
|
-
});
|
144
|
-
|
145
|
-
document.on("submit", function(event) {
|
146
|
-
var element = event.findElement(),
|
147
|
-
message = element.readAttribute('data-confirm');
|
148
|
-
if (message && !confirm(message)) {
|
149
|
-
event.stop();
|
150
|
-
return false;
|
151
|
-
}
|
152
|
-
|
153
|
-
var inputs = element.select("input[type=submit][data-disable-with]");
|
154
|
-
inputs.each(function(input) {
|
155
|
-
input.disabled = true;
|
156
|
-
input.writeAttribute('data-original-value', input.value);
|
157
|
-
input.value = input.readAttribute('data-disable-with');
|
158
|
-
});
|
159
|
-
|
160
|
-
var element = event.findElement("form[data-remote]");
|
161
|
-
if (element) {
|
162
|
-
handleRemote(element);
|
163
|
-
event.stop();
|
164
|
-
}
|
165
|
-
});
|
166
|
-
|
167
|
-
document.on("ajax:after", "form", function(event, element) {
|
168
|
-
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
|
169
|
-
inputs.each(function(input) {
|
170
|
-
input.value = input.readAttribute('data-original-value');
|
171
|
-
input.removeAttribute('data-original-value');
|
172
|
-
input.disabled = false;
|
173
|
-
});
|
174
|
-
});
|
175
|
-
})();
|