tribeca_cms 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +58 -0
- data/LICENSE +1 -0
- data/README.textile +0 -0
- data/app/assets/images/locomotive/background/body.png +0 -0
- data/app/assets/images/locomotive/datepicker/ui-widget-content-top.png +0 -0
- data/app/assets/images/locomotive/form/error-arrow.png +0 -0
- data/app/assets/images/locomotive/form/input-sep.png +0 -0
- data/app/assets/images/locomotive/icons/flags/de.png +0 -0
- data/app/assets/images/locomotive/icons/flags/en.png +0 -0
- data/app/assets/images/locomotive/icons/flags/es.png +0 -0
- data/app/assets/images/locomotive/icons/flags/et.png +0 -0
- data/app/assets/images/locomotive/icons/flags/fr.png +0 -0
- data/app/assets/images/locomotive/icons/flags/it.png +0 -0
- data/app/assets/images/locomotive/icons/flags/nb.png +0 -0
- data/app/assets/images/locomotive/icons/flags/nl.png +0 -0
- data/app/assets/images/locomotive/icons/flags/pl.png +0 -0
- data/app/assets/images/locomotive/icons/flags/pt-BR.png +0 -0
- data/app/assets/images/locomotive/icons/flags/ru.png +0 -0
- data/app/assets/images/locomotive/icons/start.png +0 -0
- data/app/assets/images/locomotive/list/empty.png +0 -0
- data/app/assets/images/locomotive/list/item-left.png +0 -0
- data/app/assets/images/locomotive/nocoffee.png +0 -0
- data/app/assets/images/locomotive/plugins/sites_picker_top_arrow.png +0 -0
- data/app/assets/images/locomotive/rails.png +0 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/css/image.css +3 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/img/image.gif +0 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/lib/locomotive_media-plugin.js +96 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/nls/fr/i18n.js +1 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/nls/i18n.js +4 -0
- data/app/assets/javascripts/aloha/plugins/custom/locomotive_media/package.json +1 -0
- data/app/assets/javascripts/locomotive.js +25 -0
- data/app/assets/javascripts/locomotive/aloha.js.coffee +2 -0
- data/app/assets/javascripts/locomotive/application.js.coffee +12 -0
- data/app/assets/javascripts/locomotive/inline_editor.js.coffee +22 -0
- data/app/assets/javascripts/locomotive/models/account.js.coffee +11 -0
- data/app/assets/javascripts/locomotive/models/content_asset.js.coffee +20 -0
- data/app/assets/javascripts/locomotive/models/content_entry.js.coffee +61 -0
- data/app/assets/javascripts/locomotive/models/content_type.js.coffee +26 -0
- data/app/assets/javascripts/locomotive/models/custom_field.js.coffee +38 -0
- data/app/assets/javascripts/locomotive/models/custom_field_select_option.js.coffee +16 -0
- data/app/assets/javascripts/locomotive/models/domain.js.coffee +3 -0
- data/app/assets/javascripts/locomotive/models/editable_element.js.coffee +27 -0
- data/app/assets/javascripts/locomotive/models/membership.js.coffee +13 -0
- data/app/assets/javascripts/locomotive/models/page.js.coffee +27 -0
- data/app/assets/javascripts/locomotive/models/site.js.coffee +34 -0
- data/app/assets/javascripts/locomotive/models/snippet.js.coffee +11 -0
- data/app/assets/javascripts/locomotive/models/theme_asset.js.coffee +11 -0
- data/app/assets/javascripts/locomotive/models/translation.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/not_logged_in.js.coffee +1 -0
- data/app/assets/javascripts/locomotive/utils/aloha_settings.js.coffee +37 -0
- data/app/assets/javascripts/locomotive/utils/core_ext.js +75 -0
- data/app/assets/javascripts/locomotive/utils/growl.js +14 -0
- data/app/assets/javascripts/locomotive/utils/handlebar_helpers.js.coffee +9 -0
- data/app/assets/javascripts/locomotive/utils/tinymce_settings.js.coffee +48 -0
- data/app/assets/javascripts/locomotive/views/application_view.js.coffee +92 -0
- data/app/assets/javascripts/locomotive/views/content_assets/picker_item_view.js.coffee +30 -0
- data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +58 -0
- data/app/assets/javascripts/locomotive/views/content_entries/_form_view.js.coffee +144 -0
- data/app/assets/javascripts/locomotive/views/content_entries/_popup_form_view.js.coffee +90 -0
- data/app/assets/javascripts/locomotive/views/content_entries/edit_view.js.coffee +9 -0
- data/app/assets/javascripts/locomotive/views/content_entries/index_view.js.coffee +36 -0
- data/app/assets/javascripts/locomotive/views/content_entries/new_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/content_types/_form_view.js.coffee +86 -0
- data/app/assets/javascripts/locomotive/views/content_types/custom_field_entry_view.js.coffee +104 -0
- data/app/assets/javascripts/locomotive/views/content_types/custom_fields_view.coffee +94 -0
- data/app/assets/javascripts/locomotive/views/content_types/edit_view.coffee +14 -0
- data/app/assets/javascripts/locomotive/views/content_types/new_view.js.coffee +11 -0
- data/app/assets/javascripts/locomotive/views/content_types/select_options_view.js.coffee +89 -0
- data/app/assets/javascripts/locomotive/views/current_site/edit_view.js.coffee +86 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/control_view.js.coffee +24 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_all_view.js.coffee +83 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/file_view.js.coffee +74 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/long_text_view.js.coffee +36 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/short_text_view.js.coffee +22 -0
- data/app/assets/javascripts/locomotive/views/inline_editor/application_view.js.coffee +124 -0
- data/app/assets/javascripts/locomotive/views/inline_editor/toolbar_view.js.coffee +145 -0
- data/app/assets/javascripts/locomotive/views/my_account/edit_view.js.coffee +24 -0
- data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +162 -0
- data/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee +31 -0
- data/app/assets/javascripts/locomotive/views/pages/index_view.js.coffee +11 -0
- data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +40 -0
- data/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/shared/asset_picker_view.js.coffee +92 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/file_view.js.coffee +88 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/has_many_view.js.coffee +125 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/many_to_many_view.js.coffee +131 -0
- data/app/assets/javascripts/locomotive/views/shared/fields/select_view.js.coffee +83 -0
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +138 -0
- data/app/assets/javascripts/locomotive/views/shared/list_item_view.js.coffee +22 -0
- data/app/assets/javascripts/locomotive/views/shared/list_view.js.coffee +53 -0
- data/app/assets/javascripts/locomotive/views/sites/domain_entry_view.js.coffee +26 -0
- data/app/assets/javascripts/locomotive/views/sites/domains_view.js.coffee +84 -0
- data/app/assets/javascripts/locomotive/views/sites/membership_entry_view.js.coffee +31 -0
- data/app/assets/javascripts/locomotive/views/sites/memberships_view.js.coffee +41 -0
- data/app/assets/javascripts/locomotive/views/sites/new_view.js.coffee +43 -0
- data/app/assets/javascripts/locomotive/views/snippets/_form_view.js.coffee +75 -0
- data/app/assets/javascripts/locomotive/views/snippets/edit_view.js.coffee +6 -0
- data/app/assets/javascripts/locomotive/views/snippets/list_item_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/snippets/list_view.js.coffee +17 -0
- data/app/assets/javascripts/locomotive/views/snippets/new_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/_form_view.js.coffee +104 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/edit_view.js.coffee +16 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/image_picker_view.js.coffee +48 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/index_view.js.coffee +91 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/list_item_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/list_view.js.coffee +17 -0
- data/app/assets/javascripts/locomotive/views/theme_assets/new_view.js.coffee +8 -0
- data/app/assets/javascripts/locomotive/views/translations/_form_view.js.coffee +20 -0
- data/app/assets/javascripts/locomotive/views/translations/edit_view.js.coffee +6 -0
- data/app/assets/javascripts/locomotive/views/translations/new_view.js.coffee +8 -0
- data/app/assets/javascripts/tinymce/plugins/jqueryinlinepopups/editor_plugin.js +240 -0
- data/app/assets/javascripts/tinymce/plugins/locomotive_media/editor_plugin.js +78 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/content.css +66 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/dialog.css.scss +78 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/butt2.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/button-bg.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/buttons.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/down_arrow.gif +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/fade-butt.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/icons.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/items.gif +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/menu-arrow.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/menu-check.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/progress.gif +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/tabs.gif +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/img/toolbarbg.png +0 -0
- data/app/assets/javascripts/tinymce/themes/advanced/skins/locomotive/ui.css +1018 -0
- data/app/assets/stylesheets/locomotive.css +16 -0
- data/app/assets/stylesheets/locomotive/backoffice/_box.css.scss +157 -0
- data/app/assets/stylesheets/locomotive/backoffice/_buttons.css.scss +178 -0
- data/app/assets/stylesheets/locomotive/backoffice/application.css.scss +332 -0
- data/app/assets/stylesheets/locomotive/backoffice/codemirror_changes.css.scss +19 -0
- data/app/assets/stylesheets/locomotive/backoffice/content_assets.css.scss +130 -0
- data/app/assets/stylesheets/locomotive/backoffice/datepicker.css.scss +178 -0
- data/app/assets/stylesheets/locomotive/backoffice/dialog_changes.css.scss +141 -0
- data/app/assets/stylesheets/locomotive/backoffice/editable_elements.css.scss +71 -0
- data/app/assets/stylesheets/locomotive/backoffice/formtastic_changes.css.scss +735 -0
- data/app/assets/stylesheets/locomotive/backoffice/layout.css.scss +205 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu.css +8 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu/_colors.css.scss +125 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu/_helpers.css.scss +6 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu/default.css.scss +32 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu/main.css.scss +127 -0
- data/app/assets/stylesheets/locomotive/backoffice/menu/sub.css.scss +276 -0
- data/app/assets/stylesheets/locomotive/backoffice/sites_picker.css.scss +12 -0
- data/app/assets/stylesheets/locomotive/inline_editor.css +13 -0
- data/app/assets/stylesheets/locomotive/inline_editor/_buttons.css.scss +60 -0
- data/app/assets/stylesheets/locomotive/inline_editor/layout.css.scss +22 -0
- data/app/assets/stylesheets/locomotive/inline_editor/toolbar.css.scss +114 -0
- data/app/assets/stylesheets/locomotive/not_logged_in.css +8 -0
- data/app/assets/stylesheets/locomotive/not_logged_in/installation.css.scss +62 -0
- data/app/assets/stylesheets/locomotive/not_logged_in/layout.css.scss +185 -0
- data/app/assets/stylesheets/locomotive/shared/_helpers.css.scss +150 -0
- data/app/assets/stylesheets/locomotive/shared/_picker.css.scss +73 -0
- data/app/assets/stylesheets/locomotive/shared/common.css.scss +34 -0
- data/app/assets/stylesheets/locomotive/shared/content_locale_picker.css.scss +80 -0
- data/app/assets/stylesheets/locomotive/shared/growl.css.scss +29 -0
- data/app/cells/locomotive/content_locale_picker/show.html.haml +7 -0
- data/app/cells/locomotive/content_locale_picker_cell.rb +21 -0
- data/app/cells/locomotive/global_actions/show.html.haml +12 -0
- data/app/cells/locomotive/global_actions_cell.rb +36 -0
- data/app/cells/locomotive/main_menu/show.html.haml +13 -0
- data/app/cells/locomotive/main_menu_cell.rb +12 -0
- data/app/cells/locomotive/menu/show.html.haml +1 -0
- data/app/cells/locomotive/menu_cell.rb +102 -0
- data/app/cells/locomotive/settings_menu_cell.rb +14 -0
- data/app/cells/locomotive/sub_menu/show.html.haml +4 -0
- data/app/cells/locomotive/sub_menu_cell.rb +13 -0
- data/app/controllers/locomotive/accounts_controller.rb +18 -0
- data/app/controllers/locomotive/api/accounts_controller.rb +79 -0
- data/app/controllers/locomotive/api/base_controller.rb +50 -0
- data/app/controllers/locomotive/api/content_assets_controller.rb +39 -0
- data/app/controllers/locomotive/api/content_entries_controller.rb +45 -0
- data/app/controllers/locomotive/api/content_types_controller.rb +39 -0
- data/app/controllers/locomotive/api/current_site_controller.rb +58 -0
- data/app/controllers/locomotive/api/documentation_controller.rb +15 -0
- data/app/controllers/locomotive/api/memberships_controller.rb +97 -0
- data/app/controllers/locomotive/api/my_account_controller.rb +35 -0
- data/app/controllers/locomotive/api/pages_controller.rb +41 -0
- data/app/controllers/locomotive/api/sites_controller.rb +93 -0
- data/app/controllers/locomotive/api/snippets_controller.rb +40 -0
- data/app/controllers/locomotive/api/theme_assets_controller.rb +39 -0
- data/app/controllers/locomotive/api/tokens_controller.rb +54 -0
- data/app/controllers/locomotive/api/translations_controller.rb +31 -0
- data/app/controllers/locomotive/base_controller.rb +61 -0
- data/app/controllers/locomotive/content_assets_controller.rb +23 -0
- data/app/controllers/locomotive/content_entries_controller.rb +71 -0
- data/app/controllers/locomotive/content_types_controller.rb +40 -0
- data/app/controllers/locomotive/current_site_controller.rb +52 -0
- data/app/controllers/locomotive/installation_controller.rb +72 -0
- data/app/controllers/locomotive/memberships_controller.rb +29 -0
- data/app/controllers/locomotive/my_account_controller.rb +24 -0
- data/app/controllers/locomotive/pages_controller.rb +63 -0
- data/app/controllers/locomotive/passwords_controller.rb +19 -0
- data/app/controllers/locomotive/public/base_controller.rb +22 -0
- data/app/controllers/locomotive/public/content_entries_controller.rb +55 -0
- data/app/controllers/locomotive/public/pages_controller.rb +50 -0
- data/app/controllers/locomotive/public/robots_controller.rb +16 -0
- data/app/controllers/locomotive/public/sitemaps_controller.rb +14 -0
- data/app/controllers/locomotive/sessions_controller.rb +29 -0
- data/app/controllers/locomotive/sites_controller.rb +33 -0
- data/app/controllers/locomotive/snippets_controller.rb +47 -0
- data/app/controllers/locomotive/theme_assets_controller.rb +52 -0
- data/app/controllers/locomotive/translations_controller.rb +32 -0
- data/app/helpers/locomotive/accounts_helper.rb +13 -0
- data/app/helpers/locomotive/base_helper.rb +182 -0
- data/app/helpers/locomotive/content_entries_helper.rb +15 -0
- data/app/helpers/locomotive/content_types_helper.rb +72 -0
- data/app/helpers/locomotive/custom_fields_helper.rb +70 -0
- data/app/helpers/locomotive/installation_helper.rb +9 -0
- data/app/helpers/locomotive/pages_helper.rb +95 -0
- data/app/helpers/locomotive/sites_helper.rb +15 -0
- data/app/helpers/locomotive/snippets_helper.rb +20 -0
- data/app/helpers/locomotive/theme_assets_helper.rb +30 -0
- data/app/helpers/locomotive/translations_helper.rb +19 -0
- data/app/inputs/locomotive/code_input.rb +51 -0
- data/app/inputs/locomotive/empty_input.rb +35 -0
- data/app/inputs/locomotive/file_input.rb +45 -0
- data/app/inputs/locomotive/locale_input.rb +40 -0
- data/app/inputs/locomotive/locales_input.rb +60 -0
- data/app/inputs/locomotive/rte_input.rb +13 -0
- data/app/inputs/locomotive/small_code_input.rb +22 -0
- data/app/inputs/locomotive/subdomain_input.rb +22 -0
- data/app/inputs/locomotive/toggle_input.rb +13 -0
- data/app/mailers/locomotive/devise_mailer.rb +10 -0
- data/app/mailers/locomotive/notifications.rb +15 -0
- data/app/models/locomotive/ability.rb +89 -0
- data/app/models/locomotive/account.rb +117 -0
- data/app/models/locomotive/content_asset.rb +40 -0
- data/app/models/locomotive/content_entry.rb +197 -0
- data/app/models/locomotive/content_type.rb +224 -0
- data/app/models/locomotive/editable_control.rb +52 -0
- data/app/models/locomotive/editable_element.rb +122 -0
- data/app/models/locomotive/editable_file.rb +85 -0
- data/app/models/locomotive/editable_long_text.rb +5 -0
- data/app/models/locomotive/editable_short_text.rb +66 -0
- data/app/models/locomotive/extensions/asset/types.rb +31 -0
- data/app/models/locomotive/extensions/asset/vignette.rb +19 -0
- data/app/models/locomotive/extensions/content_type/default_values.rb +57 -0
- data/app/models/locomotive/extensions/content_type/item_template.rb +49 -0
- data/app/models/locomotive/extensions/content_type/sync.rb +62 -0
- data/app/models/locomotive/extensions/page/editable_elements.rb +105 -0
- data/app/models/locomotive/extensions/page/listed.rb +18 -0
- data/app/models/locomotive/extensions/page/parse.rb +125 -0
- data/app/models/locomotive/extensions/page/redirect.rb +25 -0
- data/app/models/locomotive/extensions/page/render.rb +93 -0
- data/app/models/locomotive/extensions/page/templatized.rb +163 -0
- data/app/models/locomotive/extensions/page/tree.rb +133 -0
- data/app/models/locomotive/extensions/shared/seo.rb +16 -0
- data/app/models/locomotive/extensions/site/first_installation.rb +20 -0
- data/app/models/locomotive/extensions/site/locales.rb +112 -0
- data/app/models/locomotive/extensions/site/subdomain_domains.rb +91 -0
- data/app/models/locomotive/membership.rb +75 -0
- data/app/models/locomotive/page.rb +130 -0
- data/app/models/locomotive/site.rb +79 -0
- data/app/models/locomotive/snippet.rb +70 -0
- data/app/models/locomotive/theme_asset.rb +175 -0
- data/app/models/locomotive/translation.rb +32 -0
- data/app/presenters/locomotive/account_presenter.rb +19 -0
- data/app/presenters/locomotive/base_presenter.rb +99 -0
- data/app/presenters/locomotive/content_asset_presenter.rb +43 -0
- data/app/presenters/locomotive/content_entry_presenter.rb +217 -0
- data/app/presenters/locomotive/content_field_presenter.rb +71 -0
- data/app/presenters/locomotive/content_type_presenter.rb +68 -0
- data/app/presenters/locomotive/editable_control_presenter.rb +19 -0
- data/app/presenters/locomotive/editable_element_presenter.rb +40 -0
- data/app/presenters/locomotive/editable_file_presenter.rb +29 -0
- data/app/presenters/locomotive/editable_long_text_presenter.rb +5 -0
- data/app/presenters/locomotive/editable_short_text_presenter.rb +27 -0
- data/app/presenters/locomotive/membership_presenter.rb +36 -0
- data/app/presenters/locomotive/page_presenter.rb +58 -0
- data/app/presenters/locomotive/site_presenter.rb +36 -0
- data/app/presenters/locomotive/snippet_presenter.rb +22 -0
- data/app/presenters/locomotive/theme_asset_presenter.rb +61 -0
- data/app/presenters/locomotive/translation_presenter.rb +9 -0
- data/app/uploaders/locomotive/content_asset_uploader.rb +13 -0
- data/app/uploaders/locomotive/editable_file_uploader.rb +15 -0
- data/app/uploaders/locomotive/theme_asset_uploader.rb +28 -0
- data/app/views/locomotive/accounts/new.html.haml +21 -0
- data/app/views/locomotive/content_assets/_asset.html.haml +5 -0
- data/app/views/locomotive/content_assets/_picker.html.haml +33 -0
- data/app/views/locomotive/content_entries/_form.html.haml +22 -0
- data/app/views/locomotive/content_entries/_list.html.haml +18 -0
- data/app/views/locomotive/content_entries/edit.html.haml +21 -0
- data/app/views/locomotive/content_entries/index.html.haml +32 -0
- data/app/views/locomotive/content_entries/new.html.haml +19 -0
- data/app/views/locomotive/content_types/_form.html.haml +39 -0
- data/app/views/locomotive/content_types/edit.html.haml +19 -0
- data/app/views/locomotive/content_types/new.html.haml +15 -0
- data/app/views/locomotive/current_site/_form.html.haml +36 -0
- data/app/views/locomotive/current_site/edit.html.haml +19 -0
- data/app/views/locomotive/custom_fields/_form.html.haml +61 -0
- data/app/views/locomotive/custom_fields/_select_templates.html.haml +16 -0
- data/app/views/locomotive/custom_fields/types/_belongs_to.html.haml +5 -0
- data/app/views/locomotive/custom_fields/types/_boolean.html.haml +4 -0
- data/app/views/locomotive/custom_fields/types/_date.html.haml +5 -0
- data/app/views/locomotive/custom_fields/types/_file.html.haml +4 -0
- data/app/views/locomotive/custom_fields/types/_has_many.html.haml +70 -0
- data/app/views/locomotive/custom_fields/types/_many_to_many.html.haml +41 -0
- data/app/views/locomotive/custom_fields/types/_select.html.haml +34 -0
- data/app/views/locomotive/custom_fields/types/_string.html.haml +4 -0
- data/app/views/locomotive/custom_fields/types/_text.html.haml +5 -0
- data/app/views/locomotive/devise_mailer/reset_password_instructions.html.haml +12 -0
- data/app/views/locomotive/errors/404.html.haml +7 -0
- data/app/views/locomotive/errors/500.html.haml +7 -0
- data/app/views/locomotive/errors/no_page.html.haml +1 -0
- data/app/views/locomotive/errors/no_site.html.haml +1 -0
- data/app/views/locomotive/installation/step_1.html.haml +23 -0
- data/app/views/locomotive/installation/step_2.html.haml +24 -0
- data/app/views/locomotive/layouts/application.html.haml +34 -0
- data/app/views/locomotive/layouts/error.html.haml +1 -0
- data/app/views/locomotive/layouts/not_logged_in.html.haml +18 -0
- data/app/views/locomotive/memberships/new.html.haml +14 -0
- data/app/views/locomotive/my_account/edit.html.haml +40 -0
- data/app/views/locomotive/notifications/new_content_entry.html.haml +29 -0
- data/app/views/locomotive/pages/_editable_elements.html.haml +64 -0
- data/app/views/locomotive/pages/_form.html.haml +61 -0
- data/app/views/locomotive/pages/_page.html.haml +42 -0
- data/app/views/locomotive/pages/edit.html.haml +18 -0
- data/app/views/locomotive/pages/index.html.haml +19 -0
- data/app/views/locomotive/pages/new.html.haml +15 -0
- data/app/views/locomotive/passwords/edit.html.haml +18 -0
- data/app/views/locomotive/passwords/new.html.haml +17 -0
- data/app/views/locomotive/public/pages/show_toolbar.html.haml +64 -0
- data/app/views/locomotive/public/sitemaps/show.xml.builder +29 -0
- data/app/views/locomotive/sessions/new.html.haml +17 -0
- data/app/views/locomotive/shared/_footer.html.haml +1 -0
- data/app/views/locomotive/shared/_form_actions.html.haml +14 -0
- data/app/views/locomotive/shared/_head.html.haml +38 -0
- data/app/views/locomotive/shared/_header.html.haml +10 -0
- data/app/views/locomotive/shared/_locale_picker_link.html.haml +6 -0
- data/app/views/locomotive/shared/_main_app_head.html.haml +1 -0
- data/app/views/locomotive/shared/_site_picker.html.haml +10 -0
- data/app/views/locomotive/shared/actions/_contents.html.haml +7 -0
- data/app/views/locomotive/shared/menu/_contents.html.haml +51 -0
- data/app/views/locomotive/sites/_domains.html.haml +22 -0
- data/app/views/locomotive/sites/_form.html.haml +12 -0
- data/app/views/locomotive/sites/_memberships.html.haml +27 -0
- data/app/views/locomotive/sites/new.html.haml +12 -0
- data/app/views/locomotive/snippets/_form.html.haml +13 -0
- data/app/views/locomotive/snippets/_snippet.html.haml +8 -0
- data/app/views/locomotive/snippets/edit.html.haml +18 -0
- data/app/views/locomotive/snippets/new.html.haml +15 -0
- data/app/views/locomotive/theme_assets/_asset.html.haml +11 -0
- data/app/views/locomotive/theme_assets/_form.html.haml +35 -0
- data/app/views/locomotive/theme_assets/_list.html.haml +7 -0
- data/app/views/locomotive/theme_assets/_picker.html.haml +25 -0
- data/app/views/locomotive/theme_assets/edit.html.haml +21 -0
- data/app/views/locomotive/theme_assets/index.html.haml +50 -0
- data/app/views/locomotive/theme_assets/new.html.haml +12 -0
- data/app/views/locomotive/translations/_form.html.haml +12 -0
- data/app/views/locomotive/translations/edit.html.haml +15 -0
- data/app/views/locomotive/translations/index.html.haml +26 -0
- data/app/views/locomotive/translations/new.html.haml +12 -0
- data/config/cucumber.yml +8 -0
- data/config/initializers/deny_phantomjs_ttf.rb +29 -0
- data/config/initializers/devise.rb +15 -0
- data/config/initializers/formtastic.rb +4 -0
- data/config/initializers/haml.rb +2 -0
- data/config/initializers/locomotive_loaded_first.rb +19 -0
- data/config/locales/admin_ui.de.yml +316 -0
- data/config/locales/admin_ui.en.yml +332 -0
- data/config/locales/admin_ui.es.yml +296 -0
- data/config/locales/admin_ui.et.yml +315 -0
- data/config/locales/admin_ui.fr.yml +326 -0
- data/config/locales/admin_ui.it.yml +295 -0
- data/config/locales/admin_ui.nb.yml +314 -0
- data/config/locales/admin_ui.nl.yml +279 -0
- data/config/locales/admin_ui.pl.yml +319 -0
- data/config/locales/admin_ui.pt-BR.yml +274 -0
- data/config/locales/admin_ui.ru.yml +313 -0
- data/config/locales/carrierwave.de.yml +4 -0
- data/config/locales/carrierwave.en.yml +4 -0
- data/config/locales/carrierwave.es.yml +4 -0
- data/config/locales/carrierwave.et.yml +4 -0
- data/config/locales/carrierwave.fr.yml +4 -0
- data/config/locales/carrierwave.it.yml +4 -0
- data/config/locales/carrierwave.nb.yml +4 -0
- data/config/locales/carrierwave.nl.yml +4 -0
- data/config/locales/carrierwave.pl.yml +4 -0
- data/config/locales/carrierwave.pt-BR.yml +4 -0
- data/config/locales/carrierwave.ru.yml +4 -0
- data/config/locales/default.de.yml +244 -0
- data/config/locales/default.en.yml +43 -0
- data/config/locales/default.es.yml +216 -0
- data/config/locales/default.et.yml +240 -0
- data/config/locales/default.fr.yml +224 -0
- data/config/locales/default.it.yml +243 -0
- data/config/locales/default.nb.yml +313 -0
- data/config/locales/default.nl.yml +170 -0
- data/config/locales/default.pl.yml +317 -0
- data/config/locales/default.pt-BR.yml +211 -0
- data/config/locales/default.ru.yml +279 -0
- data/config/locales/devise.de.yml +62 -0
- data/config/locales/devise.en.yml +63 -0
- data/config/locales/devise.es.yml +63 -0
- data/config/locales/devise.et.yml +64 -0
- data/config/locales/devise.fr.yml +67 -0
- data/config/locales/devise.it.yml +63 -0
- data/config/locales/devise.nb.yml +63 -0
- data/config/locales/devise.nl.yml +63 -0
- data/config/locales/devise.pl.yml +63 -0
- data/config/locales/devise.pt-BR.yml +61 -0
- data/config/locales/devise.ru.yml +63 -0
- data/config/locales/flash.de.yml +106 -0
- data/config/locales/flash.en.yml +115 -0
- data/config/locales/flash.es.yml +106 -0
- data/config/locales/flash.et.yml +106 -0
- data/config/locales/flash.fr.yml +106 -0
- data/config/locales/flash.it.yml +106 -0
- data/config/locales/flash.nb.yml +106 -0
- data/config/locales/flash.nl.yml +106 -0
- data/config/locales/flash.pl.yml +106 -0
- data/config/locales/flash.pt-BR.yml +106 -0
- data/config/locales/flash.ru.yml +106 -0
- data/config/locales/formtastic.de.yml +97 -0
- data/config/locales/formtastic.en.yml +105 -0
- data/config/locales/formtastic.es.yml +84 -0
- data/config/locales/formtastic.et.yml +103 -0
- data/config/locales/formtastic.fr.yml +94 -0
- data/config/locales/formtastic.it.yml +99 -0
- data/config/locales/formtastic.nb.yml +103 -0
- data/config/locales/formtastic.nl.yml +85 -0
- data/config/locales/formtastic.pl.yml +105 -0
- data/config/locales/formtastic.pt-BR.yml +70 -0
- data/config/locales/formtastic.ru.yml +103 -0
- data/config/routes.rb +116 -0
- data/lib/generators/locomotive/install/install_generator.rb +35 -0
- data/lib/generators/locomotive/install/templates/README +26 -0
- data/lib/generators/locomotive/install/templates/carrierwave.rb +28 -0
- data/lib/generators/locomotive/install/templates/dragonfly.rb +22 -0
- data/lib/generators/locomotive/install/templates/locomotive.rb +69 -0
- data/lib/generators/locomotive/install/templates/mongoid.yml +34 -0
- data/lib/locomotive.rb +136 -0
- data/lib/locomotive/action_controller.rb +5 -0
- data/lib/locomotive/action_controller/locale_helpers.rb +61 -0
- data/lib/locomotive/action_controller/public_responder.rb +17 -0
- data/lib/locomotive/action_controller/responder.rb +78 -0
- data/lib/locomotive/action_controller/section_helpers.rb +29 -0
- data/lib/locomotive/action_controller/url_helpers.rb +38 -0
- data/lib/locomotive/carrierwave.rb +10 -0
- data/lib/locomotive/carrierwave/asset.rb +72 -0
- data/lib/locomotive/carrierwave/base.rb +15 -0
- data/lib/locomotive/carrierwave/patches.rb +32 -0
- data/lib/locomotive/configuration.rb +122 -0
- data/lib/locomotive/core_ext.rb +64 -0
- data/lib/locomotive/custom_fields.rb +66 -0
- data/lib/locomotive/dependencies.rb +30 -0
- data/lib/locomotive/devise.rb +1 -0
- data/lib/locomotive/dragonfly.rb +38 -0
- data/lib/locomotive/engine.rb +37 -0
- data/lib/locomotive/formtastic.rb +13 -0
- data/lib/locomotive/haml.rb +1 -0
- data/lib/locomotive/httparty.rb +2 -0
- data/lib/locomotive/httparty/patches.rb +18 -0
- data/lib/locomotive/httparty/webservice.rb +42 -0
- data/lib/locomotive/kaminari.rb +35 -0
- data/lib/locomotive/liquid.rb +7 -0
- data/lib/locomotive/liquid/drops/base.rb +42 -0
- data/lib/locomotive/liquid/drops/content_entry.rb +76 -0
- data/lib/locomotive/liquid/drops/content_types.rb +50 -0
- data/lib/locomotive/liquid/drops/current_user.rb +21 -0
- data/lib/locomotive/liquid/drops/page.rb +55 -0
- data/lib/locomotive/liquid/drops/proxy_collection.rb +56 -0
- data/lib/locomotive/liquid/drops/site.rb +19 -0
- data/lib/locomotive/liquid/drops/uploader.rb +15 -0
- data/lib/locomotive/liquid/errors.rb +7 -0
- data/lib/locomotive/liquid/filters/base.rb +47 -0
- data/lib/locomotive/liquid/filters/date.rb +54 -0
- data/lib/locomotive/liquid/filters/html.rb +115 -0
- data/lib/locomotive/liquid/filters/misc.rb +65 -0
- data/lib/locomotive/liquid/filters/resize.rb +16 -0
- data/lib/locomotive/liquid/filters/text.rb +45 -0
- data/lib/locomotive/liquid/filters/translate.rb +16 -0
- data/lib/locomotive/liquid/patches.rb +21 -0
- data/lib/locomotive/liquid/tags/consume.rb +67 -0
- data/lib/locomotive/liquid/tags/csrf.rb +40 -0
- data/lib/locomotive/liquid/tags/editable.rb +5 -0
- data/lib/locomotive/liquid/tags/editable/base.rb +88 -0
- data/lib/locomotive/liquid/tags/editable/control.rb +31 -0
- data/lib/locomotive/liquid/tags/editable/file.rb +39 -0
- data/lib/locomotive/liquid/tags/editable/long_text.rb +33 -0
- data/lib/locomotive/liquid/tags/editable/short_text.rb +41 -0
- data/lib/locomotive/liquid/tags/extends.rb +47 -0
- data/lib/locomotive/liquid/tags/google_analytics.rb +39 -0
- data/lib/locomotive/liquid/tags/inherited_block.rb +31 -0
- data/lib/locomotive/liquid/tags/inline_editor.rb +40 -0
- data/lib/locomotive/liquid/tags/locale_switcher.rb +83 -0
- data/lib/locomotive/liquid/tags/nav.rb +155 -0
- data/lib/locomotive/liquid/tags/paginate.rb +111 -0
- data/lib/locomotive/liquid/tags/seo.rb +72 -0
- data/lib/locomotive/liquid/tags/snippet.rb +75 -0
- data/lib/locomotive/liquid/tags/with_scope.rb +47 -0
- data/lib/locomotive/logger.rb +11 -0
- data/lib/locomotive/middlewares.rb +4 -0
- data/lib/locomotive/middlewares/cache.rb +27 -0
- data/lib/locomotive/middlewares/fonts.rb +42 -0
- data/lib/locomotive/middlewares/inline_editor.rb +36 -0
- data/lib/locomotive/middlewares/seo_trailing_slash.rb +24 -0
- data/lib/locomotive/misc/api_documentation.rb +96 -0
- data/lib/locomotive/misc/api_documentation/bootstrap.html.haml +119 -0
- data/lib/locomotive/mongoid.rb +4 -0
- data/lib/locomotive/mongoid/document.rb +19 -0
- data/lib/locomotive/mongoid/liquid.rb +39 -0
- data/lib/locomotive/mongoid/patches.rb +106 -0
- data/lib/locomotive/mongoid/presenter.rb +73 -0
- data/lib/locomotive/presentable.rb +212 -0
- data/lib/locomotive/rails.rb +1 -0
- data/lib/locomotive/rails/action_view.rb +9 -0
- data/lib/locomotive/regexps.rb +11 -0
- data/lib/locomotive/render.rb +177 -0
- data/lib/locomotive/routing.rb +2 -0
- data/lib/locomotive/routing/default_constraint.rb +42 -0
- data/lib/locomotive/routing/site_dispatcher.rb +54 -0
- data/lib/locomotive/session_store.rb +64 -0
- data/lib/locomotive/version.rb +3 -0
- data/lib/locomotive_cms.rb +1 -0
- data/lib/tasks/cucumber.rake +66 -0
- data/lib/tasks/locomotive.rake +220 -0
- data/public/favicon.ico +0 -0
- data/vendor/assets/fonts/locomotive/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/locomotive/fontawesome-webfont.svg +255 -0
- data/vendor/assets/fonts/locomotive/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/locomotive/fontawesome-webfont.woff +0 -0
- data/vendor/assets/javascripts/locomotive/ICanHandlebarz.js +88 -0
- data/vendor/assets/javascripts/locomotive/backbone.modelbinding.js +565 -0
- data/vendor/assets/javascripts/locomotive/backbone.sync.js +113 -0
- data/vendor/assets/javascripts/locomotive/cmd.js +31 -0
- data/vendor/assets/javascripts/locomotive/cookies.js +96 -0
- data/vendor/assets/javascripts/locomotive/datepicker_i18n.js.erb +28 -0
- data/vendor/assets/javascripts/locomotive/editable_field.js +50 -0
- data/vendor/assets/javascripts/locomotive/form_submit_notification.js +39 -0
- data/vendor/assets/javascripts/locomotive/growl.js +143 -0
- data/vendor/assets/javascripts/locomotive/handlebars.js +1493 -0
- data/vendor/assets/javascripts/locomotive/liquid_mode.js +42 -0
- data/vendor/assets/javascripts/locomotive/menu_toggler.js +37 -0
- data/vendor/assets/javascripts/locomotive/resize.js +9 -0
- data/vendor/assets/javascripts/locomotive/slugify.js +31 -0
- data/vendor/assets/javascripts/locomotive/smartupdater.js +296 -0
- data/vendor/assets/javascripts/locomotive/subscribe.js +367 -0
- data/vendor/assets/javascripts/locomotive/toggle.js +143 -0
- data/vendor/assets/javascripts/locomotive/vendor.js +1 -0
- data/vendor/assets/stylesheets/locomotive/blueprint/ie.css +26 -0
- data/vendor/assets/stylesheets/locomotive/blueprint/print.css +30 -0
- data/vendor/assets/stylesheets/locomotive/blueprint/screen.css +253 -0
- data/vendor/assets/stylesheets/locomotive/font-awesome.scss +329 -0
- data/vendor/assets/stylesheets/locomotive/jquery.css +3 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_2e83ff_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_454545_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_888888_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/images/ui-icons_ffffff_256x240.png +0 -0
- data/vendor/assets/stylesheets/locomotive/jquery/ui.css +406 -0
- data/vendor/assets/stylesheets/locomotive/liquid_mode.css +7 -0
- data/vendor/assets/stylesheets/locomotive/toggle.css.scss +75 -0
- metadata +1171 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
This overlay provides a 'liquid' mode to the excellent CodeMirror editor (http://codemirror.net/).
|
3
|
+
Add something like this to your CSS:
|
4
|
+
|
5
|
+
.cm-liquid-tag {
|
6
|
+
color: #32273f;
|
7
|
+
background: #ead9ff;
|
8
|
+
}
|
9
|
+
|
10
|
+
.cm-liquid-variable {
|
11
|
+
color: #29739b
|
12
|
+
background: #c2e0f0;
|
13
|
+
}
|
14
|
+
|
15
|
+
https://gist.github.com/1356686
|
16
|
+
*/
|
17
|
+
|
18
|
+
CodeMirror.defineMode("liquid", function(config, parserConfig) {
|
19
|
+
var liquidOverlay = {
|
20
|
+
token: function(stream, state) {
|
21
|
+
|
22
|
+
// Variables.
|
23
|
+
if (stream.match("{{")) {
|
24
|
+
while ((ch = stream.next()) != null)
|
25
|
+
if (ch == "}" && stream.next() == "}") break;
|
26
|
+
return "liquid-variable";
|
27
|
+
}
|
28
|
+
|
29
|
+
// Tags.
|
30
|
+
if(stream.match("{%")) {
|
31
|
+
while ((ch = stream.next()) != null)
|
32
|
+
if (ch == "%" && stream.next() == "}") break;
|
33
|
+
return "liquid-tag";
|
34
|
+
}
|
35
|
+
|
36
|
+
while (stream.next() != null && !stream.match("{{", false) && !stream.match("{%", false)) {}
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
};
|
40
|
+
|
41
|
+
return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), liquidOverlay);
|
42
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
/**
|
2
|
+
* Version 1.0.1
|
3
|
+
* Init and deploy childs on menu (admin)
|
4
|
+
* Benjamin Athlan - Bewcultures
|
5
|
+
* Andrew Bennett - Delorum
|
6
|
+
* Didier Lafforgue - NoCoffee
|
7
|
+
*/
|
8
|
+
$.fn.toggleMe = function(settings) {
|
9
|
+
|
10
|
+
settings = $.extend({}, settings);
|
11
|
+
|
12
|
+
var toggle = function(event) {
|
13
|
+
var toggler = $(this);
|
14
|
+
var children = toggler.parent().find('> ul.folder');
|
15
|
+
var openClass = toggler.data('open')
|
16
|
+
var closedClass = toggler.data('closed')
|
17
|
+
|
18
|
+
children.each(function() {
|
19
|
+
var child = $(this);
|
20
|
+
|
21
|
+
if (child.is(':visible')) {
|
22
|
+
child.slideUp('fast', function() {
|
23
|
+
toggler.removeClass(openClass).addClass(closedClass)
|
24
|
+
$.cookie(child.attr('id'), 'none');
|
25
|
+
});
|
26
|
+
} else {
|
27
|
+
child.slideDown('fast', function() {
|
28
|
+
toggler.removeClass(closedClass).addClass(openClass)
|
29
|
+
$.cookie(child.attr('id'), 'block');
|
30
|
+
});
|
31
|
+
}
|
32
|
+
});
|
33
|
+
};
|
34
|
+
|
35
|
+
return $(this).bind('click', toggle);
|
36
|
+
|
37
|
+
};
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery resize event - v1.1 - 3/14/2010
|
3
|
+
* http://benalman.com/projects/jquery-resize-plugin/
|
4
|
+
*
|
5
|
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
6
|
+
* Dual licensed under the MIT and GPL licenses.
|
7
|
+
* http://benalman.com/about/license/
|
8
|
+
*/
|
9
|
+
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
@@ -0,0 +1,31 @@
|
|
1
|
+
/**
|
2
|
+
* Version 0.0.1
|
3
|
+
* Fill in an input field from another one (source)
|
4
|
+
* and apply a filter on the string (slugify)
|
5
|
+
* Didier Lafforgue
|
6
|
+
*/
|
7
|
+
$.fn.slugify = function(settings) {
|
8
|
+
|
9
|
+
settings = $.extend({
|
10
|
+
sep: '-'
|
11
|
+
}, settings);
|
12
|
+
|
13
|
+
var target = $(settings.target);
|
14
|
+
target.data('touched', (target.val() != ''));
|
15
|
+
|
16
|
+
var makeSlug = function(event) {
|
17
|
+
var source = $(this);
|
18
|
+
var newVal = source.val().slugify(settings.sep);
|
19
|
+
|
20
|
+
if (!target.data('touched')) {
|
21
|
+
target.val(newVal);
|
22
|
+
target.trigger('change');
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
target.bind('keyup', function(event) {
|
27
|
+
$(this).data('touched', ($(this).val() != ''));
|
28
|
+
});
|
29
|
+
|
30
|
+
return $(this).bind('keyup', makeSlug);
|
31
|
+
};
|
@@ -0,0 +1,296 @@
|
|
1
|
+
/**
|
2
|
+
* smartupdater - jQuery Plugin
|
3
|
+
*
|
4
|
+
* Version - 4.0.beta
|
5
|
+
* Copyright (c) 2010 - 2011 Vadim Kiryukhin
|
6
|
+
* vkiryukhin @ gmail.com
|
7
|
+
*
|
8
|
+
* http://www.eslinstructor.net/smartupdater/
|
9
|
+
*
|
10
|
+
* Dual licensed under the MIT and GPL licenses:
|
11
|
+
* http://www.opensource.org/licenses/mit-license.php
|
12
|
+
* http://www.gnu.org/licenses/gpl.html
|
13
|
+
*
|
14
|
+
* USAGE:
|
15
|
+
*
|
16
|
+
* $("#myObject").smartupdater({
|
17
|
+
* url : "foo.php"
|
18
|
+
* }, function (data) {
|
19
|
+
* //process data here;
|
20
|
+
* }
|
21
|
+
* );
|
22
|
+
*
|
23
|
+
* Public functions:
|
24
|
+
* $("#myObject").smartupdater("stop")
|
25
|
+
* $("#myObject").smartupdater("restart");
|
26
|
+
* $("#myObject").smartupdater("setTimeout",timeout);
|
27
|
+
* $("#myObject").smartupdater("alterUrl"[,"foo.php"[,data]]);
|
28
|
+
* $("#myObject").smartupdater("alterCallback"[, foo]);
|
29
|
+
*
|
30
|
+
* Public Attributes:
|
31
|
+
* var status = $("#myObject").smartupdater("getState");
|
32
|
+
* var timeout = $("#myObject").smartupdater("getTimeout");
|
33
|
+
*
|
34
|
+
**/
|
35
|
+
|
36
|
+
(function($) {
|
37
|
+
|
38
|
+
|
39
|
+
var methods = {
|
40
|
+
|
41
|
+
init : function( options, callback) {
|
42
|
+
return this.each(function () {
|
43
|
+
var elem = this,
|
44
|
+
es = {};
|
45
|
+
|
46
|
+
elem.settings = jQuery.extend(true,{
|
47
|
+
url : '', // see jQuery.ajax for details
|
48
|
+
type : 'get', // see jQuery.ajax for details
|
49
|
+
data : '', // see jQuery.ajax for details
|
50
|
+
dataType : 'text', // see jQuery.ajax for details
|
51
|
+
|
52
|
+
minTimeout : 60000, // 1 minute
|
53
|
+
maxFailedRequests : 10, // max. number of consecutive ajax failures
|
54
|
+
maxFailedRequestsCb : false, // falure callback function
|
55
|
+
httpCache : false, // http cache
|
56
|
+
rCallback : false, // remote callback functions
|
57
|
+
selfStart : true, // start automatically after initializing
|
58
|
+
smartStop : { active: false, //disabled by default
|
59
|
+
monitorTimeout: 2500, // 2.5 seconds
|
60
|
+
minHeight: 1, // 1px
|
61
|
+
minWidth: 1 // 1px
|
62
|
+
}
|
63
|
+
|
64
|
+
}, options);
|
65
|
+
|
66
|
+
elem.smartupdaterStatus = {state:'',timeout:0};
|
67
|
+
|
68
|
+
es = elem.settings;
|
69
|
+
|
70
|
+
es.prevContent = '';
|
71
|
+
es.failedRequests = 0;
|
72
|
+
es.etag = '0';
|
73
|
+
es.lastModified = '0';
|
74
|
+
es.callback = callback;
|
75
|
+
es.origReq = {url:es.url,data:es.data,callback:callback};
|
76
|
+
es.stopFlag = false;
|
77
|
+
|
78
|
+
|
79
|
+
function start() {
|
80
|
+
|
81
|
+
/* check if element has been deleted and clean it up */
|
82
|
+
if(!$(elem).parents('body').length) {
|
83
|
+
clearInterval(elem.smartupdaterStatus.smartStop);
|
84
|
+
clearTimeout(elem.settings.h);
|
85
|
+
elem = {};
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
|
89
|
+
$.ajax({
|
90
|
+
url : es.url,
|
91
|
+
type : es.type,
|
92
|
+
data : es.data,
|
93
|
+
dataType: es.dataType,
|
94
|
+
cache : false, // MUST be set to false to prevent IE caching issue.
|
95
|
+
|
96
|
+
success: function (data, statusText, xhr) {
|
97
|
+
|
98
|
+
var dataNotModified = false,
|
99
|
+
rCallback = false,
|
100
|
+
xSmart = jQuery.parseJSON(xhr.getResponseHeader("X-Smartupdater")),
|
101
|
+
xhrEtag, xhrLM;
|
102
|
+
|
103
|
+
if(xSmart) { // remote control
|
104
|
+
|
105
|
+
/* remote timeout */
|
106
|
+
es.minTimeout = xSmart.timeout ? xSmart.timeout : es.minTimeout;
|
107
|
+
|
108
|
+
/* remote callback */
|
109
|
+
rCallback = xSmart.callback ? xSmart.callback : false;
|
110
|
+
}
|
111
|
+
|
112
|
+
if(es.httpCache) { // http cache process here
|
113
|
+
|
114
|
+
xhrEtag = xhr.getResponseHeader("ETag");
|
115
|
+
xhrLM = xhr.getResponseHeader("Last-Modified");
|
116
|
+
|
117
|
+
dataNotModified = (es.etag == xhrEtag || es.lastModified == xhrLM) ? true : false;
|
118
|
+
es.etag = xhrEtag ? xhrEtag : es.etag;
|
119
|
+
es.lastModified = xhrLM ? xhrLM : es.lastModified;
|
120
|
+
}
|
121
|
+
|
122
|
+
if ( dataNotModified ||
|
123
|
+
es.prevContent == xhr.responseText ||
|
124
|
+
xhr.status == 304 ) { // data is not changed
|
125
|
+
|
126
|
+
if(!es.stopFlag) {
|
127
|
+
clearTimeout(es.h);
|
128
|
+
es.h = setTimeout(start, es.minTimeout);
|
129
|
+
}
|
130
|
+
|
131
|
+
} else { // data is changed
|
132
|
+
|
133
|
+
/* cache response data */
|
134
|
+
es.prevContent = xhr.responseText;
|
135
|
+
|
136
|
+
/* reset timeout */
|
137
|
+
if(!es.stopFlag) {
|
138
|
+
clearTimeout(es.h);
|
139
|
+
es.h = setTimeout(start, es.minTimeout);
|
140
|
+
}
|
141
|
+
|
142
|
+
/* run callback function */
|
143
|
+
if(es.rCallback && rCallback && es.rCallback.search(rCallback) != -1) {
|
144
|
+
window[rCallback](data);
|
145
|
+
} else {
|
146
|
+
es.callback(data);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
elem.smartupdaterStatus.timeout = es.minTimeout;
|
151
|
+
es.failedRequests = 0;
|
152
|
+
},
|
153
|
+
|
154
|
+
error: function(xhr, textStatus, errorThrown) {
|
155
|
+
if ( ++es.failedRequests < es.maxFailedRequests ) {
|
156
|
+
|
157
|
+
/* increment falure counter and reset timeout */
|
158
|
+
if(!es.stopFlag) {
|
159
|
+
clearTimeout(es.h);
|
160
|
+
es.h = setTimeout(start, es.minTimeout);
|
161
|
+
elem.smartupdaterStatus.timeout = es.minTimeout;
|
162
|
+
}
|
163
|
+
|
164
|
+
} else {
|
165
|
+
|
166
|
+
/* stop smartupdater */
|
167
|
+
clearTimeout(es.h);
|
168
|
+
elem.smartupdaterStatus.state = 'OFF';
|
169
|
+
if( typeof(es.maxFailedRequestsCb)==='function') {
|
170
|
+
es.maxFailedRequestsCb(xhr, textStatus, errorThrown);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
},
|
174
|
+
|
175
|
+
beforeSend: function(xhr, settings) {
|
176
|
+
|
177
|
+
if(es.httpCache) {
|
178
|
+
|
179
|
+
/* set http cache-related headers */
|
180
|
+
xhr.setRequestHeader("If-None-Match", es.etag );
|
181
|
+
xhr.setRequestHeader("If-Modified-Since", es.lastModified );
|
182
|
+
}
|
183
|
+
|
184
|
+
/* Feedback: Smartupdater sends it's current timeout to server */
|
185
|
+
xhr.setRequestHeader("X-Smartupdater", '{"timeout":"'+elem.smartupdaterStatus.timeout+'"}');
|
186
|
+
}
|
187
|
+
});
|
188
|
+
|
189
|
+
elem.smartupdaterStatus.state = 'ON';
|
190
|
+
}
|
191
|
+
|
192
|
+
es.fnStart = start;
|
193
|
+
|
194
|
+
if(es.selfStart) {
|
195
|
+
start();
|
196
|
+
}
|
197
|
+
|
198
|
+
if(es.smartStop.active) {
|
199
|
+
|
200
|
+
elem.smartupdaterStatus.smartStop = setInterval(function(){
|
201
|
+
|
202
|
+
// check if object has been deleted
|
203
|
+
if(!$(elem).parents('body').length) {
|
204
|
+
clearInterval(elem.smartupdaterStatus.smartStop);
|
205
|
+
clearTimeout(elem.settings.h);
|
206
|
+
elem = {};
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
|
210
|
+
var $elem = $(elem);
|
211
|
+
var width = $elem.width(),
|
212
|
+
height = $elem.height(),
|
213
|
+
hidden = $elem.is(":hidden");
|
214
|
+
|
215
|
+
//element has been expanded, so smartupdater should be re-started.
|
216
|
+
if(!hidden && height > es.smartStop.minHeight && width > es.smartStop.minWidth
|
217
|
+
&& elem.smartupdaterStatus.state=="OFF") {
|
218
|
+
$elem.smartupdater("restart");
|
219
|
+
} else
|
220
|
+
//element has been minimized, so smartupdater should be stopped.
|
221
|
+
if( (hidden || height <= es.smartStop.minHeight || width <= es.smartStop.minWidth)
|
222
|
+
&& elem.smartupdaterStatus.state=="ON") {
|
223
|
+
$elem.smartupdater("stop");
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
},es.smartStop.monitorTimeout);
|
228
|
+
}
|
229
|
+
|
230
|
+
});
|
231
|
+
|
232
|
+
},// init()
|
233
|
+
|
234
|
+
stop : function () {
|
235
|
+
return this.each(function () {
|
236
|
+
this.settings.stopFlag = true;
|
237
|
+
clearTimeout(this.settings.h);
|
238
|
+
this.smartupdaterStatus.state = 'OFF';
|
239
|
+
});
|
240
|
+
},
|
241
|
+
|
242
|
+
restart : function () {
|
243
|
+
return this.each(function () {
|
244
|
+
this.settings.stopFlag = false;
|
245
|
+
clearTimeout(this.settings.h);
|
246
|
+
this.settings.failedRequests = 0;
|
247
|
+
this.settings.etag = "0";
|
248
|
+
this.settings.lastModified = "0";
|
249
|
+
this.settings.fnStart();
|
250
|
+
})
|
251
|
+
},
|
252
|
+
|
253
|
+
setTimeout : function (period) {
|
254
|
+
return this.each(function () {
|
255
|
+
clearTimeout(this.settings.h);
|
256
|
+
this.settings.minTimeout = period;
|
257
|
+
this.settings.fnStart();
|
258
|
+
});
|
259
|
+
},
|
260
|
+
|
261
|
+
alterCallback : function (callback) {
|
262
|
+
return this.each(function () {
|
263
|
+
this.settings.callback = callback ? callback : this.settings.origReq.callback;
|
264
|
+
});
|
265
|
+
},
|
266
|
+
|
267
|
+
alterUrl : function (url,data) {
|
268
|
+
return this.each(function () {
|
269
|
+
this.settings.url = url ? url : this.settings.origReq.url;
|
270
|
+
this.settings.data = data ? data : this.settings.origReq.data;
|
271
|
+
});
|
272
|
+
},
|
273
|
+
|
274
|
+
getTimeout : function () {
|
275
|
+
return this[0].smartupdaterStatus.timeout;
|
276
|
+
},
|
277
|
+
|
278
|
+
getState : function () {
|
279
|
+
return this[0].smartupdaterStatus.state;
|
280
|
+
}
|
281
|
+
|
282
|
+
}; //methods
|
283
|
+
|
284
|
+
jQuery.fn.smartupdater = function (options, callback) {
|
285
|
+
|
286
|
+
if ( methods[options] ) {
|
287
|
+
return methods[ options ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
288
|
+
} else if ( typeof options === 'object' || ! method ) {
|
289
|
+
return methods.init.apply( this, arguments );
|
290
|
+
} else {
|
291
|
+
$.error( 'Method ' + options + ' does not exist on jQuery.tooltip' );
|
292
|
+
}
|
293
|
+
};
|
294
|
+
|
295
|
+
|
296
|
+
})(jQuery);
|
@@ -0,0 +1,367 @@
|
|
1
|
+
/*
|
2
|
+
* jquery.subscribe.1.1
|
3
|
+
*
|
4
|
+
* Implementation of publish/subcription framework for jQuery
|
5
|
+
* Requires use of jQuery. Tested with jQuery 1.3 and above
|
6
|
+
*
|
7
|
+
*
|
8
|
+
* Copyright (c) 2008 Eric Chijioke (obinna a-t g mail dot c o m)
|
9
|
+
*
|
10
|
+
*
|
11
|
+
* Dual licensed under the MIT and GPL licenses:
|
12
|
+
* http://www.opensource.org/licenses/mit-license.php
|
13
|
+
* http://www.gnu.org/licenses/gpl.html
|
14
|
+
*
|
15
|
+
* Release Notes:
|
16
|
+
*
|
17
|
+
* version 1.1:
|
18
|
+
*
|
19
|
+
* Fixed unexpected behavior which can occur when a script in a embedded page (page loaded in div,tab etc.) subscribes a handler for a topic using
|
20
|
+
* the jQuery subscribe ($.subscribe) or a no-id element but this subscribe plugin is not reloaded within that embedded page (for example, when
|
21
|
+
* script is included in containing page) . In this case, if the embedded page is reloaded without reloading the entire page (and plugin), the
|
22
|
+
* subscription could be made multiple times for the topic, which will call the handler multiple times each time the topic is published.
|
23
|
+
* Code has been added to prevent this when the subscription is made using the non-element subscribe ($.subscribe()), which assures that only one
|
24
|
+
* subscription is made for a topic for a given window/frame. To prevent this from happening for an element subscription ($elem.subscribe()), make
|
25
|
+
* sure that the element has an id attribute.
|
26
|
+
*/
|
27
|
+
|
28
|
+
|
29
|
+
(function($){
|
30
|
+
|
31
|
+
_subscribe_topics = {};
|
32
|
+
_subscribe_handlers = {};
|
33
|
+
|
34
|
+
_subscribe_getDocumentWindow = function(document){
|
35
|
+
|
36
|
+
return document.parentWindow || document.defaultView;
|
37
|
+
};
|
38
|
+
|
39
|
+
$.fn.extend({
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Creates a new topic without any subscribers.
|
43
|
+
* Not usually used explicitly
|
44
|
+
*/
|
45
|
+
createTopic : function(topic) {
|
46
|
+
if(topic && !_subscribe_topics[topic]) {
|
47
|
+
|
48
|
+
_subscribe_topics[topic] = {};
|
49
|
+
_subscribe_topics[topic].objects = {};
|
50
|
+
_subscribe_topics[topic].objects['__noId__'] = [];
|
51
|
+
}
|
52
|
+
|
53
|
+
return this;
|
54
|
+
},
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Destroy an existing topic and unsubscribe all subscribers
|
58
|
+
*/
|
59
|
+
destroyTopic : function(topic) {
|
60
|
+
|
61
|
+
if(topic && _subscribe_topics[topic]) {
|
62
|
+
|
63
|
+
for(i in _subscribe_topics[topic].objects) {
|
64
|
+
|
65
|
+
var object = _subscribe_topics[topic].objects[i];
|
66
|
+
|
67
|
+
if($.isArray(object)) { // handle '__noId__' elements
|
68
|
+
|
69
|
+
if(object.length > 0) {
|
70
|
+
|
71
|
+
for(j in object) {
|
72
|
+
|
73
|
+
object[j].unbind(topic);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
} else {
|
78
|
+
|
79
|
+
object.unbind(topic,data);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
delete _subscribe_topics[topic];
|
85
|
+
|
86
|
+
return this;
|
87
|
+
},
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Subscribes an object to particular topic with a handler.
|
91
|
+
* When the topic is published, this handler will be executed.
|
92
|
+
*
|
93
|
+
* Parameters:
|
94
|
+
* -topic- is the string name of the topic
|
95
|
+
* -handler- is a handler function and is of the form function(event, data), in which the 'this' refers to the element itself.
|
96
|
+
* handler can be a function or can be a string referring to a function previously registered using the $.subscribeHandler() function
|
97
|
+
* Note: returning 'false' from the handler will prevent subsequent handlers from being executed on this element during
|
98
|
+
* this call.
|
99
|
+
* -data- (optional) is additional data that is passed to the event handler as event.data when the topic is published
|
100
|
+
*
|
101
|
+
* Note: Unexpected behavior can occur when a script in a embedded page (page loaded in div,tab etc.) subscribes a handler for a topic using
|
102
|
+
* the jQuery subscribe ($.subscribe) or a no-id element but this subscribe plugin is not reloaded within that embedded page (for example, when
|
103
|
+
* script is included in containing page) . In this case, if the embedded page is reloaded without reloading the entire page (and plugin), the
|
104
|
+
* subscription could be made multiple times for the topic, which will call the handler multiple times each time the topic is published.
|
105
|
+
* Code has been added to prevent this when the subscription is made using the non-element subscribe ($.subscribe()), which assures that only one
|
106
|
+
* subscription is made for a topic for a given window/frame. To prevent this from happening for an element subscription ($elem.subscribe()), make
|
107
|
+
* sure that the element has an id attribute.
|
108
|
+
*/
|
109
|
+
subscribe : function(topic, handler, data) {
|
110
|
+
|
111
|
+
if(this[0] && topic && handler) {
|
112
|
+
|
113
|
+
this.createTopic(topic);
|
114
|
+
|
115
|
+
if(this.attr('id')) {
|
116
|
+
|
117
|
+
_subscribe_topics[topic].objects[this.attr('id')] = this;
|
118
|
+
|
119
|
+
} else {
|
120
|
+
|
121
|
+
//do not subscribe the same window/frame document multiple times, this causes unexpected behavior of executing embedded scripts multiple times
|
122
|
+
var noIdObjects = _subscribe_topics[topic].objects['__noId__'];
|
123
|
+
|
124
|
+
if(this[0].nodeType == 9) { //if document is being bound (the case for non-element jQuery subscribing ($.subscribe)
|
125
|
+
|
126
|
+
for ( var index in noIdObjects) {
|
127
|
+
|
128
|
+
var noIdObject = noIdObjects[index];
|
129
|
+
|
130
|
+
if(noIdObject[0].nodeType == 9 && _subscribe_getDocumentWindow(this[0]).frameElement == _subscribe_getDocumentWindow(noIdObject[0]).frameElement ) {
|
131
|
+
|
132
|
+
return this;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
var exists = false;
|
138
|
+
for(var i = 0; i < noIdObjects.length; i++){
|
139
|
+
if(noIdObjects[i] == this){
|
140
|
+
exists = true;
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
if(!exists) {
|
146
|
+
|
147
|
+
_subscribe_topics[topic].objects['__noId__'].push(this);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
|
151
|
+
if(typeof(handler) == 'function') {
|
152
|
+
|
153
|
+
this.bind(topic, data, handler);
|
154
|
+
|
155
|
+
} else if(typeof(handler) == 'string' && typeof(_subscribe_handlers[handler]) == 'function') {
|
156
|
+
|
157
|
+
this.bind(topic, data, _subscribe_handlers[handler]);
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
return this;
|
162
|
+
},
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Remove a subscription of an element to a topic.
|
166
|
+
* This will unbind stop all handlers from executing on this element when the topic
|
167
|
+
* is published
|
168
|
+
*/
|
169
|
+
unsubscribe : function(topic) {
|
170
|
+
|
171
|
+
if(topic) {
|
172
|
+
|
173
|
+
if(_subscribe_topics[topic]) {
|
174
|
+
|
175
|
+
if(this.attr('id')) {
|
176
|
+
|
177
|
+
var object = _subscribe_topics[topic].objects[this.attr('id')];
|
178
|
+
|
179
|
+
if(object) {
|
180
|
+
|
181
|
+
delete _subscribe_topics[topic].objects[this.attr('id')];
|
182
|
+
}
|
183
|
+
|
184
|
+
} else {
|
185
|
+
|
186
|
+
var noIdObjects = _subscribe_topics[topic].objects['__noId__'];
|
187
|
+
|
188
|
+
for(var i = 0; i < noIdObjects.length; i++){
|
189
|
+
|
190
|
+
if(noIdObjects[i] == this){
|
191
|
+
|
192
|
+
subscribe_topics[topic].objects['__noId__'].splice(index,1);
|
193
|
+
break;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
|
199
|
+
this.unbind(topic);
|
200
|
+
}
|
201
|
+
|
202
|
+
return this;
|
203
|
+
},
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Publishes a topic (triggers handlers on all topic subscribers)
|
207
|
+
* This ends up calling any subscribed handlers which are functions of the form function (event, data)
|
208
|
+
* where: event - is a standard jQuery event object
|
209
|
+
* data - is the data parameter that was passed to this publish() method
|
210
|
+
* event.data - is the data parameter passed to the subscribe() function when this published topic was subscribed to
|
211
|
+
* event.target - is the dom element that subscribed to the event (or the document element if $.subscribe() was used)
|
212
|
+
*
|
213
|
+
* Parameters:
|
214
|
+
* -topic- is the string name of the topic
|
215
|
+
* -data- (optional) is additional data that is passed to the event handler 'data' parameter when the topic is published
|
216
|
+
* handler can be a function or can be a string referring to a function previously registered using the $.subscribeHandler() function
|
217
|
+
* -originalEvent- (optional) may be passed in a reference to an event which triggered this publishing. This will be passed as the
|
218
|
+
* 'originalEvent' field of the triggered event which will allow for controlling the propagation of higher level events
|
219
|
+
* from within the topic handler. In other words, this allows one to cancel execution of all subsequent handlers on the originalEvent
|
220
|
+
* for this element by return 'false' from a handler that is subscribed to the topic published here. This can be especially useful
|
221
|
+
* in conjunction with publishOnEvent(), where a topic is published when an event executes (such as a click) and we want our
|
222
|
+
* handler logic prevent additional topics from being published (For example if our topic displays a 'delete confirm' dialog on click and
|
223
|
+
* the user cancels, we may want to prevent subsequent topics bound to the original click event from being published).
|
224
|
+
*/
|
225
|
+
publish : function(topic, data, originalEvent) {
|
226
|
+
|
227
|
+
if(topic) {
|
228
|
+
|
229
|
+
this.createTopic(topic);
|
230
|
+
|
231
|
+
//if an orginal event exists, need to modify the event object to prevent execution of all
|
232
|
+
//other handlers if the result of the handler is false (which calls stopPropagation())
|
233
|
+
|
234
|
+
var subscriberStopPropagation = function(){
|
235
|
+
|
236
|
+
this.isImmediatePropagationStopped = function(){
|
237
|
+
return true;
|
238
|
+
};
|
239
|
+
|
240
|
+
(new $.Event).stopPropagation();
|
241
|
+
|
242
|
+
if(this.originalEvent) {
|
243
|
+
|
244
|
+
this.originalEvent.isImmediatePropagationStopped = function(){
|
245
|
+
return true;
|
246
|
+
};
|
247
|
+
|
248
|
+
this.originalEvent.stopPropagation = subscriberStopPropagation;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
var event = jQuery.Event(topic);
|
253
|
+
$.extend(event,{originalEvent: originalEvent, stopPropagation: subscriberStopPropagation});
|
254
|
+
|
255
|
+
for(i in _subscribe_topics[topic].objects) {
|
256
|
+
|
257
|
+
var object = _subscribe_topics[topic].objects[i];
|
258
|
+
|
259
|
+
if($.isArray(object)) { // handle '__noId__' elements (if any)
|
260
|
+
|
261
|
+
if(object.length > 0) {
|
262
|
+
|
263
|
+
for(j in object) {
|
264
|
+
|
265
|
+
object[j].trigger( event,data);
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
} else {
|
270
|
+
|
271
|
+
object.trigger( event,data);
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
return this;
|
278
|
+
},
|
279
|
+
|
280
|
+
/**
|
281
|
+
* Binds an objects event handler to a publish call
|
282
|
+
*
|
283
|
+
* Upon the event triggering, this ends up calling any subscribed handlers which are functions of the form function (event, data)
|
284
|
+
* where: event- is a standard jQuery event object
|
285
|
+
* event.data- is the data parameter passed to the subscribe() function when this published topic was subscribed to
|
286
|
+
* data- is the data parameter that was passed to this publishOnEvent() method
|
287
|
+
* Parameters:
|
288
|
+
* -event- is the string name of the event upon which to publish the topic
|
289
|
+
* -topic- is the string name of the topic to publish when the event occurs
|
290
|
+
* -data- (optional) is additional data which will be passed in to the publish() method ant hen available as the second ('data')
|
291
|
+
* parameter to the topic handler
|
292
|
+
*/
|
293
|
+
publishOnEvent : function(event, topic, data) {
|
294
|
+
|
295
|
+
if(event && topic) {
|
296
|
+
|
297
|
+
this.createTopic(topic);
|
298
|
+
|
299
|
+
this.bind(event, data, function (e) {
|
300
|
+
|
301
|
+
$(this).publish(topic, e.data, e);
|
302
|
+
});
|
303
|
+
}
|
304
|
+
|
305
|
+
return this;
|
306
|
+
}
|
307
|
+
});
|
308
|
+
|
309
|
+
/**
|
310
|
+
* Make publish(), createTopic() and destroyTopic() callable without an element context
|
311
|
+
* Often don't need a context to subscribe, publish, create or destroy a topic.
|
312
|
+
* We will call from the document context
|
313
|
+
*/
|
314
|
+
$.extend({
|
315
|
+
|
316
|
+
/**
|
317
|
+
* Subscribe an event handler to a topic without an element context
|
318
|
+
*
|
319
|
+
* Note: Caution about subscribing using same document to topic multiple time (maybe by loading subscribe script multiple times)
|
320
|
+
*
|
321
|
+
*/
|
322
|
+
subscribe : function(topic, handler, data) {
|
323
|
+
return $(window).subscribe(topic, handler, data);
|
324
|
+
|
325
|
+
},
|
326
|
+
|
327
|
+
/**
|
328
|
+
* Unsubscribe an event handler for a topic without an element context
|
329
|
+
*
|
330
|
+
*/
|
331
|
+
unsubscribe : function(topic, handler, data) {
|
332
|
+
|
333
|
+
return $(window).unsubscribe(topic, handler, data);
|
334
|
+
|
335
|
+
},
|
336
|
+
|
337
|
+
/**
|
338
|
+
* Register a handler function which can then be referenced by name when calling subscribe()
|
339
|
+
*/
|
340
|
+
subscribeHandler: function(name, handler) {
|
341
|
+
|
342
|
+
if(name && handler && typeof(handler) == "function") {
|
343
|
+
|
344
|
+
_subscribe_handlers[name] = handler;
|
345
|
+
}
|
346
|
+
|
347
|
+
return $(window);
|
348
|
+
},
|
349
|
+
|
350
|
+
publish: function(topic, data) {
|
351
|
+
|
352
|
+
return $(window).publish(topic,data);
|
353
|
+
},
|
354
|
+
|
355
|
+
createTopic: function(topic) {
|
356
|
+
|
357
|
+
return $(window).createTopic(topic);
|
358
|
+
},
|
359
|
+
|
360
|
+
destroyTopic: function(topic) {
|
361
|
+
|
362
|
+
return $(window).destroyTopic(topic);
|
363
|
+
}
|
364
|
+
|
365
|
+
});
|
366
|
+
|
367
|
+
})(jQuery);
|