refinerycms-core 0.9.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/admin/base_controller.rb +10 -0
- data/app/controllers/admin/dialogs_controller.rb +26 -0
- data/app/controllers/admin/refinery_core_controller.rb +12 -0
- data/app/controllers/application_controller.rb +6 -0
- data/app/controllers/refinery/fast_controller.rb +9 -0
- data/app/controllers/sitemap_controller.rb +14 -0
- data/app/helpers/application_helper.rb +5 -0
- data/app/views/admin/_head.html.erb +43 -0
- data/app/views/admin/_javascripts.html.erb +32 -0
- data/app/views/admin/_menu.html.erb +17 -0
- data/app/views/admin/dialogs/show.html.erb +19 -0
- data/app/views/layouts/admin.html.erb +24 -0
- data/app/views/layouts/admin_dialog.html.erb +14 -0
- data/app/views/layouts/application.html.erb +21 -0
- data/app/views/shared/_content_page.html.erb +63 -0
- data/app/views/shared/_draft_page_message.html.erb +3 -0
- data/app/views/shared/_footer.html.erb +4 -0
- data/app/views/shared/_google_analytics.html.erb +8 -0
- data/app/views/shared/_head.html.erb +42 -0
- data/app/views/shared/_header.html.erb +8 -0
- data/app/views/shared/_html_tag.html.erb +6 -0
- data/app/views/shared/_ie6check.html.erb +63 -0
- data/app/views/shared/_javascripts.html.erb +10 -0
- data/app/views/shared/_menu.html.erb +30 -0
- data/app/views/shared/_menu_branch.html.erb +26 -0
- data/app/views/shared/_message.html.erb +10 -0
- data/app/views/shared/_no_script.html.erb +9 -0
- data/app/views/shared/_site_bar.html.erb +25 -0
- data/app/views/shared/admin/_continue_editing.html.erb +3 -0
- data/app/views/shared/admin/_error_messages.html.erb +16 -0
- data/app/views/shared/admin/_form_actions.html.erb +75 -0
- data/app/views/shared/admin/_image_picker.html.erb +60 -0
- data/app/views/shared/admin/_make_sortable.html.erb +13 -0
- data/app/views/shared/admin/_resource_picker.html.erb +66 -0
- data/app/views/shared/admin/_search.html.erb +6 -0
- data/app/views/shared/admin/_sortable_list.html.erb +7 -0
- data/app/views/shared/admin/_tabbed_fields.html.erb +42 -0
- data/app/views/welcome.html.erb +17 -0
- data/app/views/wymiframe.html.erb +15 -0
- data/config/locales/cs.yml +77 -0
- data/config/locales/da.yml +75 -0
- data/config/locales/de.yml +75 -0
- data/config/locales/el.yml +75 -0
- data/config/locales/en.yml +75 -0
- data/config/locales/es.yml +68 -0
- data/config/locales/fr.yml +72 -0
- data/config/locales/it.yml +96 -0
- data/config/locales/lolcat.yml +68 -0
- data/config/locales/lt.yml +75 -0
- data/config/locales/lv.yml +72 -0
- data/config/locales/nb.yml +75 -0
- data/config/locales/nl.yml +75 -0
- data/config/locales/pl.yml +75 -0
- data/config/locales/pt-BR.yml +72 -0
- data/config/locales/rs.yml +76 -0
- data/config/locales/ru.yml +71 -0
- data/config/locales/sl.yml +72 -0
- data/config/locales/sv.yml +75 -0
- data/config/locales/vi.yml +75 -0
- data/config/locales/zh-CN.yml +75 -0
- data/config/locales/zh-TW.yml +75 -0
- data/config/routes.rb +19 -0
- data/crud.md +197 -0
- data/doc/included-jquery-ui-packages.jpg +0 -0
- data/engines.md +179 -0
- data/features/search.feature +55 -0
- data/features/site_bar.feature +24 -0
- data/features/step_definitions/core_steps.rb +61 -0
- data/features/support/paths.rb +14 -0
- data/features/uploads/beach.jpeg +0 -0
- data/features/uploads/refinery_is_awesome.txt +1 -0
- data/lib/gemspec.rb +43 -0
- data/lib/generators/refinerycms_generator.rb +110 -0
- data/lib/generators/templates/.gitignore +83 -0
- data/lib/generators/templates/app/views/sitemap/index.xml.builder +22 -0
- data/lib/generators/templates/autotest/autotest.rb +17 -0
- data/lib/generators/templates/autotest/discover.rb +2 -0
- data/lib/generators/templates/config/database.yml.mysql +20 -0
- data/lib/generators/templates/config/database.yml.postgresql +57 -0
- data/lib/generators/templates/config/database.yml.sqlite3 +26 -0
- data/lib/generators/templates/config/i18n-js.yml +6 -0
- data/lib/generators/templates/config/initializers/devise.rb +142 -0
- data/lib/generators/templates/config/settings.rb +2 -0
- data/lib/generators/templates/db/seeds.rb +5 -0
- data/lib/refinery/activity.rb +45 -0
- data/lib/refinery/admin/base_controller.rb +111 -0
- data/lib/refinery/admin_base_controller.rb +5 -0
- data/lib/refinery/application.rb +48 -0
- data/lib/refinery/application_controller.rb +120 -0
- data/lib/refinery/application_helper.rb +19 -0
- data/lib/refinery/base_presenter.rb +27 -0
- data/lib/refinery/catch_all_routes.rb +11 -0
- data/lib/refinery/crud.rb +295 -0
- data/lib/refinery/helpers/form_helper.rb +66 -0
- data/lib/refinery/helpers/head_helper.rb +17 -0
- data/lib/refinery/helpers/html_truncation_helper.rb +25 -0
- data/lib/refinery/helpers/image_helper.rb +49 -0
- data/lib/refinery/helpers/menu_helper.rb +68 -0
- data/lib/refinery/helpers/meta_helper.rb +67 -0
- data/lib/refinery/helpers/pagination_helper.rb +16 -0
- data/lib/refinery/helpers/script_helper.rb +36 -0
- data/lib/refinery/helpers/site_bar_helper.rb +24 -0
- data/lib/refinery/helpers/tag_helper.rb +21 -0
- data/lib/refinery/helpers/translation_helper.rb +17 -0
- data/lib/refinery/link_renderer.rb +55 -0
- data/lib/refinery/plugin.rb +106 -0
- data/lib/refinery/plugins.rb +75 -0
- data/lib/refinerycms-core.rb +156 -0
- data/lib/tasks/doc.rake +29 -0
- data/lib/tasks/refinery.rake +231 -0
- data/lib/tasks/yard.rake +30 -0
- data/license.md +21 -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/refinery/add.png +0 -0
- data/public/images/refinery/admin_bg.png +0 -0
- data/public/images/refinery/ajax-loader.gif +0 -0
- data/public/images/refinery/branch-end.gif +0 -0
- data/public/images/refinery/branch-start.gif +0 -0
- data/public/images/refinery/branch.gif +0 -0
- data/public/images/refinery/carousel-left.png +0 -0
- data/public/images/refinery/carousel-right.png +0 -0
- data/public/images/refinery/cross.png +0 -0
- data/public/images/refinery/dialogLoadingAnimation.gif +0 -0
- data/public/images/refinery/header_background.png +0 -0
- data/public/images/refinery/hover-gradient.jpg +0 -0
- data/public/images/refinery/icons/accept.png +0 -0
- data/public/images/refinery/icons/add.png +0 -0
- data/public/images/refinery/icons/ajax-loader.gif +0 -0
- data/public/images/refinery/icons/application_edit.png +0 -0
- data/public/images/refinery/icons/application_go.png +0 -0
- data/public/images/refinery/icons/arrow_left.png +0 -0
- data/public/images/refinery/icons/arrow_switch.png +0 -0
- data/public/images/refinery/icons/arrow_up.png +0 -0
- data/public/images/refinery/icons/bin.png +0 -0
- data/public/images/refinery/icons/bin_closed.png +0 -0
- data/public/images/refinery/icons/cancel.png +0 -0
- data/public/images/refinery/icons/cog_add.png +0 -0
- data/public/images/refinery/icons/cog_edit.png +0 -0
- data/public/images/refinery/icons/cross.png +0 -0
- data/public/images/refinery/icons/delete.png +0 -0
- data/public/images/refinery/icons/doc.png +0 -0
- data/public/images/refinery/icons/down.gif +0 -0
- data/public/images/refinery/icons/edit.png +0 -0
- data/public/images/refinery/icons/email.png +0 -0
- data/public/images/refinery/icons/email_edit.png +0 -0
- data/public/images/refinery/icons/email_go.png +0 -0
- data/public/images/refinery/icons/email_open.png +0 -0
- data/public/images/refinery/icons/eye.png +0 -0
- data/public/images/refinery/icons/folder_page_white.png +0 -0
- data/public/images/refinery/icons/image_add.png +0 -0
- data/public/images/refinery/icons/image_edit.png +0 -0
- data/public/images/refinery/icons/img.png +0 -0
- data/public/images/refinery/icons/information.png +0 -0
- data/public/images/refinery/icons/layout_add.png +0 -0
- data/public/images/refinery/icons/layout_edit.png +0 -0
- data/public/images/refinery/icons/music.png +0 -0
- data/public/images/refinery/icons/page_add.png +0 -0
- data/public/images/refinery/icons/page_edit.png +0 -0
- data/public/images/refinery/icons/page_white_edit.png +0 -0
- data/public/images/refinery/icons/page_white_gear.png +0 -0
- data/public/images/refinery/icons/page_white_put.png +0 -0
- data/public/images/refinery/icons/pdf.png +0 -0
- data/public/images/refinery/icons/ppt.png +0 -0
- data/public/images/refinery/icons/star.png +0 -0
- data/public/images/refinery/icons/tick.png +0 -0
- data/public/images/refinery/icons/up.gif +0 -0
- data/public/images/refinery/icons/user_add.png +0 -0
- data/public/images/refinery/icons/user_comment.png +0 -0
- data/public/images/refinery/icons/user_edit.png +0 -0
- data/public/images/refinery/icons/xls.png +0 -0
- data/public/images/refinery/icons/zip.png +0 -0
- data/public/images/refinery/icons/zoom.png +0 -0
- data/public/images/refinery/logo-large.png +0 -0
- data/public/images/refinery/logo-medium.png +0 -0
- data/public/images/refinery/logo-site-bar.png +0 -0
- data/public/images/refinery/logo-small-medium.png +0 -0
- data/public/images/refinery/logo-small.png +0 -0
- data/public/images/refinery/logo-tiny.png +0 -0
- data/public/images/refinery/logo.png +0 -0
- data/public/images/refinery/nav-3-background.gif +0 -0
- data/public/images/refinery/nav_inactive_background.png +0 -0
- data/public/images/refinery/orange_button.png +0 -0
- data/public/images/refinery/page_bg.png +0 -0
- data/public/images/refinery/resolve_digital_footer_logo.png +0 -0
- data/public/images/refinery/text_field_background.png +0 -0
- data/public/images/refinery/tooltip-nib.gif +0 -0
- data/public/images/refinery/tooltip-nib.png +0 -0
- data/public/images/wymeditor/skins/refinery/arrow_redo.png +0 -0
- data/public/images/wymeditor/skins/refinery/arrow_undo.png +0 -0
- data/public/images/wymeditor/skins/refinery/eye.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-blockquote.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h1.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h2.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h3.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h4.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h5.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-h6.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-p.png +0 -0
- data/public/images/wymeditor/skins/refinery/iframe/lbl-pre.png +0 -0
- data/public/images/wymeditor/skins/refinery/link_add.png +0 -0
- data/public/images/wymeditor/skins/refinery/link_break.png +0 -0
- data/public/images/wymeditor/skins/refinery/page_code.png +0 -0
- data/public/images/wymeditor/skins/refinery/page_paste.png +0 -0
- data/public/images/wymeditor/skins/refinery/photo_add.png +0 -0
- data/public/images/wymeditor/skins/refinery/right.png +0 -0
- data/public/images/wymeditor/skins/refinery/style.png +0 -0
- data/public/images/wymeditor/skins/refinery/table_add.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_align_center.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_align_justify.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_align_left.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_align_right.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_bold.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_1.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_2.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_3.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_4.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_5.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_heading_6.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_indent.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_indent_remove.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_italic.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_list_bullets.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_list_numbers.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_paragraph.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_strikethrough.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_subscript.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_superscript.png +0 -0
- data/public/images/wymeditor/skins/refinery/text_underline.png +0 -0
- data/public/images/wymeditor/skins/wymeditor_icon.png +0 -0
- data/public/javascripts/admin.js +7 -0
- data/public/javascripts/application.js +1 -0
- data/public/javascripts/dd_belatedpng.js +13 -0
- data/public/javascripts/i18n-messages.js +2 -0
- data/public/javascripts/jquery-min.js +16 -0
- data/public/javascripts/jquery-ui-custom-min.js +251 -0
- data/public/javascripts/jquery.js +8176 -0
- data/public/javascripts/jquery/GPL-LICENSE.txt +278 -0
- data/public/javascripts/jquery/MIT-LICENSE.txt +20 -0
- data/public/javascripts/jquery/jquery.corner.js +345 -0
- data/public/javascripts/jquery/jquery.html5-placeholder-shim.js +88 -0
- data/public/javascripts/jquery/jquery.jcarousel.js +900 -0
- data/public/javascripts/jquery/jquery.textTruncate.js +174 -0
- data/public/javascripts/jquery/jquery.timers.js +138 -0
- data/public/javascripts/modernizr-min.js +30 -0
- data/public/javascripts/rails.js +175 -0
- data/public/javascripts/refinery/admin.js +1114 -0
- data/public/javascripts/refinery/boot_wym.js +285 -0
- data/public/javascripts/refinery/core.js +18 -0
- data/public/javascripts/refinery/i18n.js +340 -0
- data/public/javascripts/refinery/nestedsortables.js +164 -0
- data/public/javascripts/refinery/serializelist.js +66 -0
- data/public/javascripts/refinery/site_bar.js +16 -0
- data/public/javascripts/refinery/submenu.js +49 -0
- data/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +5156 -0
- data/public/javascripts/wymeditor/lang/ca.js +45 -0
- data/public/javascripts/wymeditor/lang/cs.js +45 -0
- data/public/javascripts/wymeditor/lang/da.js +48 -0
- data/public/javascripts/wymeditor/lang/de.js +45 -0
- data/public/javascripts/wymeditor/lang/en.js +47 -0
- data/public/javascripts/wymeditor/lang/es.js +48 -0
- data/public/javascripts/wymeditor/lang/fa.js +46 -0
- data/public/javascripts/wymeditor/lang/fr.js +45 -0
- data/public/javascripts/wymeditor/lang/he.js +45 -0
- data/public/javascripts/wymeditor/lang/hu.js +45 -0
- data/public/javascripts/wymeditor/lang/it.js +48 -0
- data/public/javascripts/wymeditor/lang/lv.js +47 -0
- data/public/javascripts/wymeditor/lang/nb.js +48 -0
- data/public/javascripts/wymeditor/lang/nl.js +47 -0
- data/public/javascripts/wymeditor/lang/nn.js +45 -0
- data/public/javascripts/wymeditor/lang/pl.js +45 -0
- data/public/javascripts/wymeditor/lang/pt-BR.js +47 -0
- data/public/javascripts/wymeditor/lang/pt.js +45 -0
- data/public/javascripts/wymeditor/lang/rs.js +47 -0
- data/public/javascripts/wymeditor/lang/ru.js +45 -0
- data/public/javascripts/wymeditor/lang/sl.js +47 -0
- data/public/javascripts/wymeditor/lang/sv.js +45 -0
- data/public/javascripts/wymeditor/lang/tr.js +45 -0
- data/public/javascripts/wymeditor/lang/vi.js +47 -0
- data/public/javascripts/wymeditor/lang/zh_cn.js +47 -0
- data/public/javascripts/wymeditor/skins/refinery/skin.js +48 -0
- data/public/robots.txt +3 -0
- data/public/stylesheets/application.css +4 -0
- data/public/stylesheets/formatting.css +4 -0
- data/public/stylesheets/home.css +4 -0
- data/public/stylesheets/refinery/application.css +72 -0
- data/public/stylesheets/refinery/formatting.css +57 -0
- data/public/stylesheets/refinery/home.css +0 -0
- data/public/stylesheets/refinery/refinery.css +1579 -0
- data/public/stylesheets/refinery/site_bar.css +87 -0
- data/public/stylesheets/refinery/submenu.css +22 -0
- data/public/stylesheets/refinery/theme.css +36 -0
- data/public/stylesheets/refinery/tooltips.css +34 -0
- data/public/stylesheets/refinery/ui.css +107 -0
- data/public/stylesheets/theme.css +4 -0
- data/public/stylesheets/wymeditor/skins/refinery/skin.css +528 -0
- data/public/stylesheets/wymeditor/skins/refinery/wymiframe.css +96 -0
- data/public/wymeditor/GPL-license.txt +278 -0
- data/public/wymeditor/MIT-license.txt +20 -0
- data/public/wymeditor/README +35 -0
- data/refinerycms-core.gemspec +391 -0
- data/spec/lib/refinery/plugins_spec.rb +90 -0
- metadata +482 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
{ // a dummy block, so I can collapse all the meta stuff in the editor
|
2
|
+
/****************************************************************************
|
3
|
+
* jQuery 1.3.x plugin to shorten styled text to fit in a block, appending
|
4
|
+
* an ellipsis ("...", …, Unicode: 2026) or other text.
|
5
|
+
* (Only supports ltr text for now.)
|
6
|
+
*
|
7
|
+
* This is achieved by placing the text of the 'selected' element (eg. span or
|
8
|
+
* div) inside a table and measuring its width. If it's too big to big to fit in
|
9
|
+
* the element's parent block it's shortened and measured again until it (and
|
10
|
+
* appended ellipsis or text) fits inside the block. A tooltip on the 'selected'
|
11
|
+
* element displays the full original text.
|
12
|
+
*
|
13
|
+
* If the browser supports truncating text using the 'text-overflow:ellipsis'
|
14
|
+
* CSS property then that will be used (if the text to append is the default
|
15
|
+
* ellipsis).
|
16
|
+
*
|
17
|
+
* If the text is truncated by the plugin any markup in the text will be
|
18
|
+
* stripped (eg: "<a" starts stripping, "< a" does not). This behaviour is
|
19
|
+
* dictated by the jQuery .text(val) method.
|
20
|
+
* The appended text may contain HTML however (a link or span for example).
|
21
|
+
*
|
22
|
+
* Usage Example ('selecting' a div with an id of "element"):
|
23
|
+
|
24
|
+
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
|
25
|
+
<script type="text/javascript" src="jquery.textTruncate.js"></script>
|
26
|
+
<script type="text/javascript">
|
27
|
+
$(function() {
|
28
|
+
$("#element").textTruncate();
|
29
|
+
});
|
30
|
+
</script>
|
31
|
+
|
32
|
+
* By default the plugin will use the parent block's width as maximum width and
|
33
|
+
* an ellipsis as appended text when truncating.
|
34
|
+
*
|
35
|
+
* There are three ways of configuring the plugin:
|
36
|
+
*
|
37
|
+
* 1) Passing a configuration hash as the plugin's argument, eg:
|
38
|
+
|
39
|
+
.textTruncate({
|
40
|
+
width: 300,
|
41
|
+
tail: ' <a href="#">more</a>',
|
42
|
+
tooltip: false
|
43
|
+
});
|
44
|
+
|
45
|
+
* 2) Using two optional arguments (deprecated!):
|
46
|
+
* width = the desired pixel width, integer
|
47
|
+
* tail = text/html to append when truncating
|
48
|
+
*
|
49
|
+
* 3) By changing the plugin defaults, eg:
|
50
|
+
|
51
|
+
$.fn.textTruncate.defaults.tail = ' <a href="#">more</a>';
|
52
|
+
|
53
|
+
* Note: there is no default width (unless you create one).
|
54
|
+
*
|
55
|
+
* You may want to set the element's css to {visibility:hidden;} so it won't
|
56
|
+
* initially flash at full width.
|
57
|
+
*
|
58
|
+
*
|
59
|
+
* Created by M. David Green (www.mdavidgreen.com) in 2009. Free to use for
|
60
|
+
* personal or commercial purposes under MIT (X11) license with no warranty
|
61
|
+
*
|
62
|
+
* Heavily modified/simplified/improved by Marc Diethelm (http://web5.me/).
|
63
|
+
*
|
64
|
+
****************************************************************************/
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
(function ($) {
|
69
|
+
|
70
|
+
$.fn.textTruncate = function() {
|
71
|
+
|
72
|
+
var userOptions = {};
|
73
|
+
var args = arguments; // for better minification
|
74
|
+
var func = args.callee // dito; and much shorter than $.fn.textTruncate
|
75
|
+
|
76
|
+
if ( args.length ) {
|
77
|
+
|
78
|
+
if ( args[0].constructor == Object ) {
|
79
|
+
userOptions = args[0];
|
80
|
+
} else if ( args[0] == "options" ) {
|
81
|
+
return $(this).eq(0).data("options-truncate");
|
82
|
+
} else {
|
83
|
+
userOptions = {
|
84
|
+
width: parseInt(args[0]),
|
85
|
+
tail: args[1]
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
this.css("visibility","hidden"); // Hide the element(s) while manipulating them
|
91
|
+
|
92
|
+
// apply options vs. defaults
|
93
|
+
var options = $.extend({}, func.defaults, userOptions);
|
94
|
+
|
95
|
+
|
96
|
+
/**
|
97
|
+
* HERE WE GO!
|
98
|
+
**/
|
99
|
+
return this.each(function () {
|
100
|
+
|
101
|
+
var $this = $(this);
|
102
|
+
$this.data("options-truncate", options);
|
103
|
+
|
104
|
+
/**
|
105
|
+
* If browser implements text-overflow:ellipsis in CSS and tail is "...", use it!
|
106
|
+
**/
|
107
|
+
if ( options.tail == "..." && func._native ) {
|
108
|
+
|
109
|
+
this.style[func._native] = "ellipsis";
|
110
|
+
/*var css_obj = {}
|
111
|
+
css_obj[func._native] = "ellipsis";
|
112
|
+
$this.css(css_obj);*/
|
113
|
+
$this.css("visibility","visible");
|
114
|
+
|
115
|
+
return true;
|
116
|
+
}
|
117
|
+
|
118
|
+
var width = options.width || $this.parent().width();
|
119
|
+
|
120
|
+
var text = $this.text();
|
121
|
+
var textlength = text.length;
|
122
|
+
var css = "padding:0; margin:0; border:none; font:inherit;";
|
123
|
+
var $table = $('<table style="'+ css +'width:auto;zoom:1;position:absolute;"><tr style="'+ css +'"><td style="'+ css +'white-space:nowrap;">' + options.tail + '</td></tr></table>');
|
124
|
+
var $td = $("td", $table);
|
125
|
+
$this.html( $table );
|
126
|
+
|
127
|
+
var tailwidth = $td.width();
|
128
|
+
var targetWidth = width - tailwidth;
|
129
|
+
|
130
|
+
$td.text( text );
|
131
|
+
|
132
|
+
if ($td.width() > width) {
|
133
|
+
if ( options.tooltip ) {
|
134
|
+
$this.attr("title", text);
|
135
|
+
}
|
136
|
+
|
137
|
+
while ($td.width() >= targetWidth ) {
|
138
|
+
textlength--;
|
139
|
+
$td.html($td.html().substring(0, textlength)); // .html(val) is faster than .text(val) and we already used .text(val) to strip/escape html
|
140
|
+
}
|
141
|
+
|
142
|
+
text = $.trim( $td.html() );
|
143
|
+
$this.html( text + options.tail );
|
144
|
+
|
145
|
+
} else {
|
146
|
+
$this.html( text );
|
147
|
+
}
|
148
|
+
|
149
|
+
this.style.visibility = "visible";
|
150
|
+
|
151
|
+
return true;
|
152
|
+
});
|
153
|
+
|
154
|
+
return true;
|
155
|
+
|
156
|
+
};
|
157
|
+
|
158
|
+
var css = document.documentElement.style;
|
159
|
+
var _native = false;
|
160
|
+
|
161
|
+
if ( "textOverflow" in css ) {
|
162
|
+
_native = "textOverflow";
|
163
|
+
} else if ( "OTextOverflow" in css ) {
|
164
|
+
_native = "OTextOverflow";
|
165
|
+
}
|
166
|
+
|
167
|
+
$.fn.textTruncate._native = _native;
|
168
|
+
|
169
|
+
$.fn.textTruncate.defaults = {
|
170
|
+
tail: "…",
|
171
|
+
tooltip: true
|
172
|
+
};
|
173
|
+
|
174
|
+
})(jQuery);
|
@@ -0,0 +1,138 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery.timers - Timer abstractions for jQuery
|
3
|
+
* Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com)
|
4
|
+
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
|
5
|
+
* Date: 2009/10/16
|
6
|
+
*
|
7
|
+
* @author Blair Mitchelmore
|
8
|
+
* @version 1.2
|
9
|
+
*
|
10
|
+
**/
|
11
|
+
|
12
|
+
$.fn.extend({
|
13
|
+
everyTime: function(interval, label, fn, times) {
|
14
|
+
return this.each(function() {
|
15
|
+
$.timer.add(this, interval, label, fn, times);
|
16
|
+
});
|
17
|
+
},
|
18
|
+
oneTime: function(interval, label, fn) {
|
19
|
+
return this.each(function() {
|
20
|
+
$.timer.add(this, interval, label, fn, 1);
|
21
|
+
});
|
22
|
+
},
|
23
|
+
stopTime: function(label, fn) {
|
24
|
+
return this.each(function() {
|
25
|
+
$.timer.remove(this, label, fn);
|
26
|
+
});
|
27
|
+
}
|
28
|
+
});
|
29
|
+
|
30
|
+
$.extend({
|
31
|
+
timer: {
|
32
|
+
global: [],
|
33
|
+
guid: 1,
|
34
|
+
dataKey: "$.timer",
|
35
|
+
regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
|
36
|
+
powers: {
|
37
|
+
// Yeah this is major overkill...
|
38
|
+
'ms': 1,
|
39
|
+
'cs': 10,
|
40
|
+
'ds': 100,
|
41
|
+
's': 1000,
|
42
|
+
'das': 10000,
|
43
|
+
'hs': 100000,
|
44
|
+
'ks': 1000000
|
45
|
+
},
|
46
|
+
timeParse: function(value) {
|
47
|
+
if (value == undefined || value == null)
|
48
|
+
return null;
|
49
|
+
var result = this.regex.exec($.trim(value.toString()));
|
50
|
+
if (result[2]) {
|
51
|
+
var num = parseFloat(result[1]);
|
52
|
+
var mult = this.powers[result[2]] || 1;
|
53
|
+
return num * mult;
|
54
|
+
} else {
|
55
|
+
return value;
|
56
|
+
}
|
57
|
+
},
|
58
|
+
add: function(element, interval, label, fn, times) {
|
59
|
+
var counter = 0;
|
60
|
+
|
61
|
+
if ($.isFunction(label)) {
|
62
|
+
if (!times)
|
63
|
+
times = fn;
|
64
|
+
fn = label;
|
65
|
+
label = interval;
|
66
|
+
}
|
67
|
+
|
68
|
+
interval = $.timer.timeParse(interval);
|
69
|
+
|
70
|
+
if (typeof interval != 'number' || isNaN(interval) || interval < 0)
|
71
|
+
return;
|
72
|
+
|
73
|
+
if (typeof times != 'number' || isNaN(times) || times < 0)
|
74
|
+
times = 0;
|
75
|
+
|
76
|
+
times = times || 0;
|
77
|
+
|
78
|
+
var timers = $.data(element, this.dataKey) || $.data(element, this.dataKey, {});
|
79
|
+
|
80
|
+
if (!timers[label])
|
81
|
+
timers[label] = {};
|
82
|
+
|
83
|
+
fn.timerID = fn.timerID || this.guid++;
|
84
|
+
|
85
|
+
var handler = function() {
|
86
|
+
if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
|
87
|
+
$.timer.remove(element, label, fn);
|
88
|
+
};
|
89
|
+
|
90
|
+
handler.timerID = fn.timerID;
|
91
|
+
|
92
|
+
if (!timers[label][fn.timerID])
|
93
|
+
timers[label][fn.timerID] = window.setInterval(handler,interval);
|
94
|
+
|
95
|
+
this.global.push( element );
|
96
|
+
|
97
|
+
},
|
98
|
+
remove: function(element, label, fn) {
|
99
|
+
var timers = $.data(element, this.dataKey), ret;
|
100
|
+
|
101
|
+
if ( timers ) {
|
102
|
+
|
103
|
+
if (!label) {
|
104
|
+
for ( label in timers )
|
105
|
+
this.remove(element, label, fn);
|
106
|
+
} else if ( timers[label] ) {
|
107
|
+
if ( fn ) {
|
108
|
+
if ( fn.timerID ) {
|
109
|
+
window.clearInterval(timers[label][fn.timerID]);
|
110
|
+
delete timers[label][fn.timerID];
|
111
|
+
}
|
112
|
+
} else {
|
113
|
+
for ( var fn in timers[label] ) {
|
114
|
+
window.clearInterval(timers[label][fn]);
|
115
|
+
delete timers[label][fn];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
for ( ret in timers[label] ) break;
|
120
|
+
if ( !ret ) {
|
121
|
+
ret = null;
|
122
|
+
delete timers[label];
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
for ( ret in timers ) break;
|
127
|
+
if ( !ret )
|
128
|
+
$.removeData(element, this.dataKey);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
$(window).bind("unload", function() {
|
135
|
+
$.each($.timer.global, function(index, item) {
|
136
|
+
$.timer.remove(item);
|
137
|
+
});
|
138
|
+
});
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/*
|
2
|
+
* Modernizr v1.6
|
3
|
+
* http://www.modernizr.com
|
4
|
+
*
|
5
|
+
* Developed by:
|
6
|
+
* - Faruk Ates http://farukat.es/
|
7
|
+
* - Paul Irish http://paulirish.com/
|
8
|
+
*
|
9
|
+
* Copyright (c) 2009-2010
|
10
|
+
* Dual-licensed under the BSD or MIT licenses.
|
11
|
+
* http://www.modernizr.com/license/
|
12
|
+
*/
|
13
|
+
window.Modernizr=function(i,e,u){function s(a,b){return(""+a).indexOf(b)!==-1}function D(a,b){for(var c in a)if(j[a[c]]!==u&&(!b||b(a[c],E)))return true}function n(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1);c=(a+" "+F.join(c+" ")+c).split(" ");return!!D(c,b)}function S(){f.input=function(a){for(var b=0,c=a.length;b<c;b++)L[a[b]]=!!(a[b]in h);return L}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" "));f.inputtypes=function(a){for(var b=0,c,k=a.length;b<
|
14
|
+
k;b++){h.setAttribute("type",a[b]);if(c=h.type!=="text"){h.value=M;if(/^range$/.test(h.type)&&h.style.WebkitAppearance!==u){l.appendChild(h);c=e.defaultView;c=c.getComputedStyle&&c.getComputedStyle(h,null).WebkitAppearance!=="textfield"&&h.offsetHeight!==0;l.removeChild(h)}else/^(search|tel)$/.test(h.type)||(c=/^(url|email)$/.test(h.type)?h.checkValidity&&h.checkValidity()===false:h.value!=M)}N[a[b]]=!!c}return N}("search tel url email datetime date month week time datetime-local number range color".split(" "))}
|
15
|
+
var f={},l=e.documentElement,E=e.createElement("modernizr"),j=E.style,h=e.createElement("input"),M=":)",O=Object.prototype.toString,q=" -webkit- -moz- -o- -ms- -khtml- ".split(" "),F="Webkit Moz O ms Khtml".split(" "),v={svg:"http://www.w3.org/2000/svg"},d={},N={},L={},P=[],w,Q=function(a){var b=document.createElement("style"),c=e.createElement("div");b.textContent=a+"{#modernizr{height:3px}}";(e.head||e.getElementsByTagName("head")[0]).appendChild(b);c.id="modernizr";l.appendChild(c);a=c.offsetHeight===
|
16
|
+
3;b.parentNode.removeChild(b);c.parentNode.removeChild(c);return!!a},o=function(){var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return function(b,c){c=c||document.createElement(a[b]||"div");b="on"+b;var k=b in c;if(!k){c.setAttribute||(c=document.createElement("div"));if(c.setAttribute&&c.removeAttribute){c.setAttribute(b,"");k=typeof c[b]=="function";if(typeof c[b]!="undefined")c[b]=u;c.removeAttribute(b)}}return k}}(),G={}.hasOwnProperty,R;R=
|
17
|
+
typeof G!=="undefined"&&typeof G.call!=="undefined"?function(a,b){return G.call(a,b)}:function(a,b){return b in a&&typeof a.constructor.prototype[b]==="undefined"};d.flexbox=function(){var a=e.createElement("div"),b=e.createElement("div");(function(k,g,r,x){g+=":";k.style.cssText=(g+q.join(r+";"+g)).slice(0,-g.length)+(x||"")})(a,"display","box","width:42px;padding:0;");b.style.cssText=q.join("box-flex:1;")+"width:10px;";a.appendChild(b);l.appendChild(a);var c=b.offsetWidth===42;a.removeChild(b);
|
18
|
+
l.removeChild(a);return c};d.canvas=function(){var a=e.createElement("canvas");return!!(a.getContext&&a.getContext("2d"))};d.canvastext=function(){return!!(f.canvas&&typeof e.createElement("canvas").getContext("2d").fillText=="function")};d.webgl=function(){var a=e.createElement("canvas");try{if(a.getContext("webgl"))return true}catch(b){}try{if(a.getContext("experimental-webgl"))return true}catch(c){}return false};d.touch=function(){return"ontouchstart"in i||Q("@media ("+q.join("touch-enabled),(")+
|
19
|
+
"modernizr)")};d.geolocation=function(){return!!navigator.geolocation};d.postmessage=function(){return!!i.postMessage};d.websqldatabase=function(){return!!i.openDatabase};d.indexedDB=function(){for(var a=-1,b=F.length;++a<b;){var c=F[a].toLowerCase();if(i[c+"_indexedDB"]||i[c+"IndexedDB"])return true}return false};d.hashchange=function(){return o("hashchange",i)&&(document.documentMode===u||document.documentMode>7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&&
|
20
|
+
o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize=
|
21
|
+
function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients=
|
22
|
+
function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective",
|
23
|
+
"MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g,
|
24
|
+
0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"');
|
25
|
+
b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in
|
26
|
+
i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="<svg/>";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&&
|
27
|
+
/SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div");
|
28
|
+
a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m<r;)p.createElement(g[m])}function k(p,m){for(var I=p.length,t=-1,y,J=[];++t<I;){y=p[t];m=y.media||m;J.push(k(y.imports,m));J.push(y.cssText)}return J.join("")}var g="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video".split("|"),r=g.length,x=RegExp("<(/*)(abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video)",
|
29
|
+
"gi"),T=RegExp("\\b(abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video)\\b(?!.*[;}])","gi"),z=b.createDocumentFragment(),A=b.documentElement,K=A.firstChild,B=b.createElement("style"),C=b.createElement("body");B.media="all";c(b);c(z);a.attachEvent("onbeforeprint",function(){for(var p=-1;++p<r;)for(var m=b.getElementsByTagName(g[p]),I=m.length,t=-1;++t<I;)if(m[t].className.indexOf("iepp_")<0)m[t].className+=" iepp_"+
|
30
|
+
g[p];K.insertBefore(B,K.firstChild);B.styleSheet.cssText=k(b.styleSheets,"all").replace(T,".iepp_$1");z.appendChild(b.body);A.appendChild(C);C.innerHTML=z.firstChild.innerHTML.replace(x,"<$1bdo")});a.attachEvent("onafterprint",function(){C.innerHTML="";A.removeChild(C);K.removeChild(B);A.appendChild(z.firstChild)})}(this,document);f._enableHTML5=true;f._version="1.6";l.className=l.className.replace(/\bno-js\b/,"")+" js";l.className+=" "+P.join(" ");return f}(this,this.document);
|
@@ -0,0 +1,175 @@
|
|
1
|
+
/*
|
2
|
+
Taken from http://github.com/rails/jquery-ujs
|
3
|
+
At version http://github.com/rails/jquery-ujs/blob/900d714300b284d7480e1e3f09fbecf8f0e23b27/src/rails.js
|
4
|
+
(Because that was the current master version)
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Unobtrusive scripting adapter for jQuery
|
9
|
+
*
|
10
|
+
* Requires jQuery 1.4.3 or later.
|
11
|
+
* https://github.com/rails/jquery-ujs
|
12
|
+
*/
|
13
|
+
|
14
|
+
(function($) {
|
15
|
+
// Make sure that every Ajax request sends the CSRF token
|
16
|
+
function CSRFProtection(fn) {
|
17
|
+
var token = $('meta[name="csrf-token"]').attr('content');
|
18
|
+
if (token) fn(function(xhr) { xhr.setRequestHeader('X-CSRF-Token', token) });
|
19
|
+
}
|
20
|
+
if ($().jquery == '1.5') { // gruesome hack
|
21
|
+
var factory = $.ajaxSettings.xhr;
|
22
|
+
$.ajaxSettings.xhr = function() {
|
23
|
+
var xhr = factory();
|
24
|
+
CSRFProtection(function(setHeader) {
|
25
|
+
var open = xhr.open;
|
26
|
+
xhr.open = function() { open.apply(this, arguments); setHeader(this) };
|
27
|
+
});
|
28
|
+
return xhr;
|
29
|
+
};
|
30
|
+
}
|
31
|
+
else $(document).ajaxSend(function(e, xhr) {
|
32
|
+
CSRFProtection(function(setHeader) { setHeader(xhr) });
|
33
|
+
});
|
34
|
+
|
35
|
+
// Triggers an event on an element and returns the event result
|
36
|
+
function fire(obj, name, data) {
|
37
|
+
var event = new $.Event(name);
|
38
|
+
obj.trigger(event, data);
|
39
|
+
return event.result !== false;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Submits "remote" forms and links with ajax
|
43
|
+
function handleRemote(element) {
|
44
|
+
var method, url, data,
|
45
|
+
dataType = element.attr('data-type') || ($.ajaxSettings && $.ajaxSettings.dataType);
|
46
|
+
|
47
|
+
if (element.is('form')) {
|
48
|
+
method = element.attr('method');
|
49
|
+
url = element.attr('action');
|
50
|
+
data = element.serializeArray();
|
51
|
+
// memoized value from clicked submit button
|
52
|
+
var button = element.data('ujs:submit-button');
|
53
|
+
if (button) {
|
54
|
+
data.push(button);
|
55
|
+
element.data('ujs:submit-button', null);
|
56
|
+
}
|
57
|
+
} else {
|
58
|
+
method = element.attr('data-method');
|
59
|
+
url = element.attr('href');
|
60
|
+
data = null;
|
61
|
+
}
|
62
|
+
|
63
|
+
$.ajax({
|
64
|
+
url: url, type: method || 'GET', data: data, dataType: dataType,
|
65
|
+
// stopping the "ajax:beforeSend" event will cancel the ajax request
|
66
|
+
beforeSend: function(xhr, settings) {
|
67
|
+
if (settings.dataType === undefined) {
|
68
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
69
|
+
}
|
70
|
+
return fire(element, 'ajax:beforeSend', [xhr, settings]);
|
71
|
+
},
|
72
|
+
success: function(data, status, xhr) {
|
73
|
+
element.trigger('ajax:success', [data, status, xhr]);
|
74
|
+
},
|
75
|
+
complete: function(xhr, status) {
|
76
|
+
element.trigger('ajax:complete', [xhr, status]);
|
77
|
+
},
|
78
|
+
error: function(xhr, status, error) {
|
79
|
+
element.trigger('ajax:error', [xhr, status, error]);
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
|
84
|
+
// Handles "data-method" on links such as:
|
85
|
+
// <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
|
86
|
+
function handleMethod(link) {
|
87
|
+
var href = link.attr('href'),
|
88
|
+
method = link.attr('data-method'),
|
89
|
+
csrf_token = $('meta[name=csrf-token]').attr('content'),
|
90
|
+
csrf_param = $('meta[name=csrf-param]').attr('content'),
|
91
|
+
form = $('<form method="post" action="' + href + '"></form>'),
|
92
|
+
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
|
93
|
+
|
94
|
+
if (csrf_param !== undefined && csrf_token !== undefined) {
|
95
|
+
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
|
96
|
+
}
|
97
|
+
|
98
|
+
form.hide().append(metadata_input).appendTo('body');
|
99
|
+
form.submit();
|
100
|
+
}
|
101
|
+
|
102
|
+
function disableFormElements(form) {
|
103
|
+
form.find('input[data-disable-with]').each(function() {
|
104
|
+
var input = $(this);
|
105
|
+
input.data('ujs:enable-with', input.val())
|
106
|
+
.val(input.attr('data-disable-with'))
|
107
|
+
.attr('disabled', 'disabled');
|
108
|
+
});
|
109
|
+
}
|
110
|
+
|
111
|
+
function enableFormElements(form) {
|
112
|
+
form.find('input[data-disable-with]').each(function() {
|
113
|
+
var input = $(this);
|
114
|
+
input.val(input.data('ujs:enable-with')).removeAttr('disabled');
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
118
|
+
function allowAction(element) {
|
119
|
+
var message = element.attr('data-confirm');
|
120
|
+
return !message || (fire(element, 'confirm') && confirm(message));
|
121
|
+
}
|
122
|
+
|
123
|
+
function requiredValuesMissing(form) {
|
124
|
+
var missing = false;
|
125
|
+
form.find('input[name][required]').each(function() {
|
126
|
+
if (!$(this).val()) missing = true;
|
127
|
+
});
|
128
|
+
return missing;
|
129
|
+
}
|
130
|
+
|
131
|
+
$('a[data-confirm], a[data-method], a[data-remote]').live('click.rails', function(e) {
|
132
|
+
var link = $(this);
|
133
|
+
if (!allowAction(link)) return false;
|
134
|
+
|
135
|
+
if (link.attr('data-remote') != undefined) {
|
136
|
+
handleRemote(link);
|
137
|
+
return false;
|
138
|
+
} else if (link.attr('data-method')) {
|
139
|
+
handleMethod(link);
|
140
|
+
return false;
|
141
|
+
}
|
142
|
+
});
|
143
|
+
|
144
|
+
$('form').live('submit.rails', function(e) {
|
145
|
+
var form = $(this), remote = form.attr('data-remote') != undefined;
|
146
|
+
if (!allowAction(form)) return false;
|
147
|
+
|
148
|
+
// skip other logic when required values are missing
|
149
|
+
if (requiredValuesMissing(form)) return !remote;
|
150
|
+
|
151
|
+
if (remote) {
|
152
|
+
handleRemote(form);
|
153
|
+
return false;
|
154
|
+
} else {
|
155
|
+
// slight timeout so that the submit button gets properly serialized
|
156
|
+
setTimeout(function(){ disableFormElements(form) }, 13);
|
157
|
+
}
|
158
|
+
});
|
159
|
+
|
160
|
+
$('form input[type=submit], form button[type=submit], form button:not([type])').live('click.rails', function() {
|
161
|
+
var button = $(this);
|
162
|
+
if (!allowAction(button)) return false;
|
163
|
+
// register the pressed submit button
|
164
|
+
var name = button.attr('name'), data = name ? {name:name, value:button.val()} : null;
|
165
|
+
button.closest('form').data('ujs:submit-button', data);
|
166
|
+
});
|
167
|
+
|
168
|
+
$('form').live('ajax:beforeSend.rails', function(event) {
|
169
|
+
if (this == event.target) disableFormElements($(this));
|
170
|
+
});
|
171
|
+
|
172
|
+
$('form').live('ajax:complete.rails', function(event) {
|
173
|
+
if (this == event.target) enableFormElements($(this));
|
174
|
+
});
|
175
|
+
})( jQuery );
|