From 92893cfc21a2f338c46505e0417b092d7ae80cdc Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Thu, 10 Apr 2014 18:52:59 +0200 Subject: [PATCH] grosse modification forum & changement version rails --- Gemfile | 97 +- Gemfile.lock | 314 +- app/assets/javascripts/admin.js | 1 + app/assets/javascripts/connexion.coffee | 6 + app/assets/javascripts/connexion.js | 10 - app/assets/javascripts/forum.coffee | 84 + app/assets/javascripts/forum.js | 137 - app/assets/javascripts/plaquettes.coffee | 108 +- app/assets/javascripts/redactor.js | 4269 +++++++++++++++++ app/assets/javascripts/shared/jquery-ui.js | 791 +++ app/assets/stylesheets/admin.css.less | 2 +- .../admin/framework/accordion.less | 34 + .../stylesheets/admin/framework/alerts.less | 79 + .../admin/framework/bootstrap.less | 67 + .../admin/framework/breadcrumbs.less | 24 + .../admin/framework/button-groups.less | 229 + .../stylesheets/admin/framework/buttons.less | 228 + .../stylesheets/admin/framework/carousel.less | 158 + .../stylesheets/admin/framework/close.less | 32 + .../stylesheets/admin/framework/code.less | 61 + .../admin/framework/component-animations.less | 22 + .../admin/framework/dropdowns.less | 248 + .../stylesheets/admin/framework/forms.less | 695 +++ .../stylesheets/admin/framework/formt.less | 310 ++ .../stylesheets/admin/framework/grid.less | 21 + .../admin/framework/hero-unit.less | 25 + .../admin/framework/labels-badges.less | 84 + .../stylesheets/admin/framework/layouts.less | 16 + .../stylesheets/admin/framework/media.less | 55 + .../stylesheets/admin/framework/mixins.less | 702 +++ .../stylesheets/admin/framework/modals.less | 95 + .../stylesheets/admin/framework/navbar.less | 497 ++ .../stylesheets/admin/framework/navs.less | 409 ++ .../stylesheets/admin/framework/pager.less | 43 + .../admin/framework/pagination.less | 123 + .../stylesheets/admin/framework/popovers.less | 133 + .../admin/framework/progress-bars.less | 122 + .../stylesheets/admin/framework/reset.less | 216 + .../framework/responsive-1200px-min.less | 28 + .../admin/framework/responsive-767px-max.less | 193 + .../framework/responsive-768px-979px.less | 19 + .../admin/framework/responsive-navbar.less | 189 + .../admin/framework/responsive-utilities.less | 59 + .../admin/framework/responsive.less | 48 + .../admin/framework/scaffolding.less | 53 + .../stylesheets/admin/framework/slider.less | 104 + .../stylesheets/admin/framework/sprites.less | 197 + .../stylesheets/admin/framework/tables.less | 244 + .../admin/framework/thumbnails.less | 53 + .../stylesheets/admin/framework/tooltip.less | 70 + .../stylesheets/admin/framework/type.less | 247 + .../admin/framework/utilities.less | 30 + .../admin/framework/variables.less | 301 ++ .../stylesheets/admin/framework/wells.less | 29 + app/assets/stylesheets/admin/lesshat.less | 2200 +++++++++ ...{application.css.scss => application.less} | 2 +- app/assets/stylesheets/connexion.css.scss | 155 - app/assets/stylesheets/connexion.less | 41 + .../fontawesome/bordered-pulled.less | 16 + app/assets/stylesheets/fontawesome/core.less | 12 + .../stylesheets/fontawesome/fixed-width.less | 6 + .../stylesheets/fontawesome/font-awesome.less | 17 + app/assets/stylesheets/fontawesome/icons.less | 412 ++ .../stylesheets/fontawesome/larger.less | 13 + app/assets/stylesheets/fontawesome/list.less | 19 + .../stylesheets/fontawesome/mixins.less | 20 + app/assets/stylesheets/fontawesome/path.less | 14 + .../fontawesome/rotated-flipped.less | 9 + .../stylesheets/fontawesome/spinning.less | 30 + .../stylesheets/fontawesome/stacked.less | 20 + .../stylesheets/fontawesome/variables.less | 381 ++ app/assets/stylesheets/forum.css.scss | 271 -- app/assets/stylesheets/forum.less | 282 ++ app/assets/stylesheets/gaspillage.css.less | 567 +++ app/assets/stylesheets/plaquettes.css.less | 11 +- app/assets/stylesheets/redactor.less | 693 +++ .../vendor/framework/variables.less | 4 +- app/controllers/admin/admins_controller.rb | 4 +- .../admin/newsgroups_controller.rb | 4 +- .../admin/newsletters_controller.rb | 4 +- app/controllers/admin/notes_controller.rb | 4 +- app/controllers/admin/people_controller.rb | 4 +- app/controllers/admin/petitions_controller.rb | 4 +- .../admin/sheet_years_controller.rb | 4 +- app/controllers/admin/sheets_controller.rb | 6 +- app/controllers/admin/tiny_urls_controller.rb | 4 +- app/controllers/admin/topics_controller.rb | 4 +- app/controllers/forum/auths_controller.rb | 10 +- .../forum/forum_categories_controller.rb | 4 +- .../forum/forum_messages_controller.rb | 8 +- .../forum/forum_topics_controller.rb | 10 +- .../forum/forum_users_controller.rb | 15 +- app/controllers/petitions_controller.rb | 2 +- app/controllers/plaquettes_controller.rb | 5 + app/controllers/survey_sets_controller.rb | 2 +- app/helpers/icon_helper.rb | 4 +- app/helpers/plaquettes_helper.rb | 3 +- app/models/admin.rb | 2 +- app/models/answer_set.rb | 2 +- app/models/donate.rb | 2 +- app/models/forum.rb | 2 +- app/models/forum_category.rb | 2 +- app/models/forum_message.rb | 2 +- app/models/forum_topic.rb | 2 +- app/models/forum_user.rb | 28 +- app/models/forum_user_image.rb | 2 +- app/models/newsgroup.rb | 2 +- app/models/newsletter.rb | 2 +- app/models/note.rb | 2 +- app/models/note_file.rb | 2 +- app/models/person.rb | 2 +- app/models/petition.rb | 2 +- app/models/petition_signator.rb | 2 +- app/models/question_set.rb | 2 +- app/models/sheet.rb | 4 +- app/models/sheet_year.rb | 2 +- app/models/survey_item.rb | 2 +- app/models/survey_item_answer.rb | 2 +- app/models/survey_set.rb | 2 +- app/models/survey_type.rb | 2 +- app/models/tiny_url.rb | 2 +- app/models/topic.rb | 2 +- app/uploaders/user_image_uploader.rb | 2 +- app/views/admin/donates/_form.html.haml | 2 +- app/views/admin/newsgroups/index.html.haml | 2 +- app/views/admin/newsletters/_form.haml | 2 +- app/views/admin/newsletters/index.html.haml | 6 +- .../newsletters/select_recipients.html.haml | 2 +- app/views/admin/people/_form.html.haml | 2 +- app/views/admin/petitions/index.html.haml | 2 +- app/views/admin/petitions/new.html.haml | 4 +- app/views/admin/sheet_years/_form.html.haml | 2 +- app/views/admin/sheets/_sheet.html.haml | 2 +- app/views/admin/sheets/edit.html.haml | 2 +- app/views/admin/sheets/index.html.haml | 22 +- app/views/admin/sheets/show.html.haml | 2 +- .../admin/survey_types/_survey.html.haml | 4 +- app/views/admin/tiny_urls/index.html.haml | 2 +- app/views/admins/passwords/edit.html.haml | 2 +- app/views/admins/passwords/new.html.haml | 2 +- app/views/admins/sessions/new.html.haml | 33 +- app/views/forum/auths/new.haml | 24 +- app/views/forum/forum_categories/_form.haml | 2 +- app/views/forum/forum_categories/show.haml | 17 - app/views/forum/forum_messages/_form.haml | 72 +- .../forum/forum_messages/_forum_message.haml | 62 +- app/views/forum/forum_messages/edit.haml | 6 +- app/views/forum/forum_messages/new.haml | 7 +- app/views/forum/forum_topics/_form.haml | 48 +- .../forum/forum_topics/_forum_topic.haml | 35 +- app/views/forum/forum_topics/index.haml | 16 + app/views/forum/forum_topics/new.haml | 3 +- app/views/forum/forum_topics/show.haml | 14 +- .../forum_user_images/_forum_user_image.haml | 12 +- .../forum/forum_user_images/_images_form.haml | 53 +- app/views/forum/forum_users/_form.haml | 30 +- app/views/forum/forum_users/_forum_user.haml | 3 +- app/views/forum/forum_users/edit.haml | 1 + app/views/forum/forum_users/index.haml | 4 +- app/views/forum/forum_users/new.haml | 17 +- app/views/forum/forum_users/show.haml | 38 +- app/views/forum/forums/show.html.haml | 2 +- app/views/layouts/application.html.haml | 2 +- app/views/layouts/connexion.html.haml | 67 +- app/views/layouts/forum.haml | 143 +- app/views/layouts/gaspillage.html.haml | 26 + app/views/layouts/plaquettes.html.haml | 9 +- .../newsletter_mails/newsletter.html.haml | 8 +- .../plaquettes/animaux-batiment.html.haml | 7 +- app/views/plaquettes/gaspillage.haml | 18 + .../histoire-decomposition.html.haml | 2 +- .../histoire-pollinisation.html.haml | 26 - app/views/plaquettes/index.html.haml | 6 +- app/views/plaquettes/jeu-arbre.html.haml | 1 + app/views/plaquettes/mur-insectes.haml | 1 + .../plaquettes/puzzle-chauve-souris.html.haml | 6 +- app/views/plaquettes/puzzle-insectes.haml | 4 +- app/views/plaquettes/quizz-arbres.html.haml | 2 +- .../plaquettes/quizz-batiments.html.haml | 2 +- app/views/plaquettes/vie-arbre.html.haml | 6 +- config/deploy.rb | 2 +- config/environments/development.rb | 37 +- config/environments/production.rb | 83 +- config/initializers/devise.rb | 3 + config/routes.rb | 27 +- config/unicorn_dev.rb | 2 + ...10151036_add_sheet_number_to_forum_user.rb | 12 + db/schema.rb | 187 +- oldGemfile | 71 + public/apple-iconp.png | Bin 0 -> 14679 bytes public/favicon copy.ico | Bin 0 -> 1406 bytes public/favicon.ico | 0 public/faviconp.ico | Bin 0 -> 1406 bytes public/fonts/FontAwesome.otf | Bin 0 -> 62856 bytes public/fonts/fontawesome-webfont.eot | Bin 29360 -> 38205 bytes public/fonts/fontawesome-webfont.svg | 103 +- public/fonts/fontawesome-webfont.ttf | Bin 64960 -> 80652 bytes public/fonts/fontawesome-webfont.woff | Bin 34420 -> 44432 bytes public/gaspmanifest.appcache | 21 + public/login_background.jpg | Bin 0 -> 1458816 bytes public/login_background2.jpg | Bin 0 -> 697092 bytes public/login_background3.jpg | Bin 0 -> 697092 bytes public/manifest.appcache | 26 +- 203 files changed, 17835 insertions(+), 1427 deletions(-) create mode 100644 app/assets/javascripts/connexion.coffee delete mode 100644 app/assets/javascripts/connexion.js create mode 100644 app/assets/javascripts/forum.coffee delete mode 100644 app/assets/javascripts/forum.js create mode 100755 app/assets/javascripts/redactor.js create mode 100755 app/assets/javascripts/shared/jquery-ui.js create mode 100755 app/assets/stylesheets/admin/framework/accordion.less create mode 100755 app/assets/stylesheets/admin/framework/alerts.less create mode 100755 app/assets/stylesheets/admin/framework/bootstrap.less create mode 100755 app/assets/stylesheets/admin/framework/breadcrumbs.less create mode 100755 app/assets/stylesheets/admin/framework/button-groups.less create mode 100755 app/assets/stylesheets/admin/framework/buttons.less create mode 100755 app/assets/stylesheets/admin/framework/carousel.less create mode 100755 app/assets/stylesheets/admin/framework/close.less create mode 100755 app/assets/stylesheets/admin/framework/code.less create mode 100755 app/assets/stylesheets/admin/framework/component-animations.less create mode 100755 app/assets/stylesheets/admin/framework/dropdowns.less create mode 100755 app/assets/stylesheets/admin/framework/forms.less create mode 100644 app/assets/stylesheets/admin/framework/formt.less create mode 100755 app/assets/stylesheets/admin/framework/grid.less create mode 100755 app/assets/stylesheets/admin/framework/hero-unit.less create mode 100755 app/assets/stylesheets/admin/framework/labels-badges.less create mode 100755 app/assets/stylesheets/admin/framework/layouts.less create mode 100755 app/assets/stylesheets/admin/framework/media.less create mode 100755 app/assets/stylesheets/admin/framework/mixins.less create mode 100755 app/assets/stylesheets/admin/framework/modals.less create mode 100755 app/assets/stylesheets/admin/framework/navbar.less create mode 100755 app/assets/stylesheets/admin/framework/navs.less create mode 100755 app/assets/stylesheets/admin/framework/pager.less create mode 100755 app/assets/stylesheets/admin/framework/pagination.less create mode 100755 app/assets/stylesheets/admin/framework/popovers.less create mode 100755 app/assets/stylesheets/admin/framework/progress-bars.less create mode 100755 app/assets/stylesheets/admin/framework/reset.less create mode 100755 app/assets/stylesheets/admin/framework/responsive-1200px-min.less create mode 100755 app/assets/stylesheets/admin/framework/responsive-767px-max.less create mode 100755 app/assets/stylesheets/admin/framework/responsive-768px-979px.less create mode 100755 app/assets/stylesheets/admin/framework/responsive-navbar.less create mode 100755 app/assets/stylesheets/admin/framework/responsive-utilities.less create mode 100755 app/assets/stylesheets/admin/framework/responsive.less create mode 100755 app/assets/stylesheets/admin/framework/scaffolding.less create mode 100755 app/assets/stylesheets/admin/framework/slider.less create mode 100755 app/assets/stylesheets/admin/framework/sprites.less create mode 100755 app/assets/stylesheets/admin/framework/tables.less create mode 100755 app/assets/stylesheets/admin/framework/thumbnails.less create mode 100755 app/assets/stylesheets/admin/framework/tooltip.less create mode 100755 app/assets/stylesheets/admin/framework/type.less create mode 100755 app/assets/stylesheets/admin/framework/utilities.less create mode 100755 app/assets/stylesheets/admin/framework/variables.less create mode 100755 app/assets/stylesheets/admin/framework/wells.less create mode 100755 app/assets/stylesheets/admin/lesshat.less rename app/assets/stylesheets/{application.css.scss => application.less} (99%) delete mode 100644 app/assets/stylesheets/connexion.css.scss create mode 100644 app/assets/stylesheets/connexion.less create mode 100644 app/assets/stylesheets/fontawesome/bordered-pulled.less create mode 100644 app/assets/stylesheets/fontawesome/core.less create mode 100644 app/assets/stylesheets/fontawesome/fixed-width.less create mode 100644 app/assets/stylesheets/fontawesome/font-awesome.less create mode 100644 app/assets/stylesheets/fontawesome/icons.less create mode 100644 app/assets/stylesheets/fontawesome/larger.less create mode 100644 app/assets/stylesheets/fontawesome/list.less create mode 100644 app/assets/stylesheets/fontawesome/mixins.less create mode 100644 app/assets/stylesheets/fontawesome/path.less create mode 100644 app/assets/stylesheets/fontawesome/rotated-flipped.less create mode 100644 app/assets/stylesheets/fontawesome/spinning.less create mode 100644 app/assets/stylesheets/fontawesome/stacked.less create mode 100644 app/assets/stylesheets/fontawesome/variables.less delete mode 100644 app/assets/stylesheets/forum.css.scss create mode 100644 app/assets/stylesheets/forum.less create mode 100644 app/assets/stylesheets/gaspillage.css.less create mode 100755 app/assets/stylesheets/redactor.less delete mode 100644 app/views/forum/forum_categories/show.haml create mode 100644 app/views/forum/forum_topics/index.haml create mode 100644 app/views/layouts/gaspillage.html.haml create mode 100644 app/views/plaquettes/gaspillage.haml create mode 100644 config/unicorn_dev.rb create mode 100644 db/migrate/20140410151036_add_sheet_number_to_forum_user.rb create mode 100644 oldGemfile create mode 100644 public/apple-iconp.png create mode 100644 public/favicon copy.ico delete mode 100644 public/favicon.ico create mode 100644 public/faviconp.ico create mode 100644 public/fonts/FontAwesome.otf create mode 100644 public/gaspmanifest.appcache create mode 100644 public/login_background.jpg create mode 100644 public/login_background2.jpg create mode 100644 public/login_background3.jpg diff --git a/Gemfile b/Gemfile index 4c818e2..1c6639b 100644 --- a/Gemfile +++ b/Gemfile @@ -1,71 +1,86 @@ source 'https://rubygems.org' -gem 'rails', '3.2.9' - -# Bundle edge Rails instead: -# gem 'rails', :git => 'git://github.com/rails/rails.git' - -gem "mysql2" - - -# Gems used only for assets and not required -# in production environments by default. -group :assets do - gem 'sass-rails', '~> 3.2.3' - gem 'coffee-rails', '~> 3.2.1' - - # See https://github.com/sstephenson/execjs#readme for more supported runtimes - # gem 'therubyracer', :platforms => :ruby - - gem 'uglifier', '>= 1.0.3' +# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' +gem 'rails', '4.0.0' +gem 'bcrypt-ruby', '~> 3.0.0' +# Use sqlite3 as the database for Active Record + +gem 'mysql2' + gem 'sass-rails' gem 'compass-rails' gem 'zurb-foundation', ">= 3.2" -end +# Use Uglifier as compressor for JavaScript assets +gem 'uglifier', '>= 1.3.0' +# Use CoffeeScript for .js.coffee assets and views +gem 'coffee-rails', '~> 4.0.0' + +# See https://github.com/sstephenson/execjs#readme for more supported runtimes +# gem 'therubyracer', platforms: :ruby + +# Use jquery as the JavaScript library gem 'jquery-rails' gem 'jquery-ui-rails' -gem "raptor-editor-rails" -# To use ActiveModel has_secure_password +# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks +gem 'turbolinks' + +# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder +gem 'jbuilder', '~> 1.0.1' + +gem "therubyracer" +gem "less-rails" +gem "twitter-bootstrap-rails" + +gem 'haml-rails' + +gem 'nokogiri' +gem 'acts_as_tree' +gem 'formtastic', :git => 'git://github.com/justinfrench/formtastic.git' + + +gem 'kaminari-bootstrap' + + +gem "htmlentities" + + +group :doc do + # bundle exec rake doc:rails generates the API under doc/api. + gem 'sdoc', require: false +end + +gem "capistrano", group: :development +gem "rvm-capistrano", group: :development + +# Use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' -# To use Jbuilder templates for JSON -# gem 'jbuilder' - # Use unicorn as the app server -# gem 'unicorn' +gem 'unicorn' -# Deploy with Capistrano -# gem 'capistrano' +gem "nokogiri" -# To use debugger -# gem 'debugger' -gem 'capistrano' -gem 'rvm-capistrano' -gem 'gravatar_image_tag' +gem 'kaminari-bootstrap' -gem 'formtastic' -gem 'haml' +gem 'acts_as_commentable' -gem 'acts_as_tree' -gem "pg" gem "devise" gem "cancan" gem 'kaminari' -gem 'carrierwave' gem 'rmagick' +gem 'carrierwave', "0.9.0" + gem "geocoder" #markdown gem 'pygments.rb' gem 'redcarpet' -gem 'nokogiri' -gem "therubyracer" -gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS -gem "twitter-bootstrap-rails" +# Use debugger +# gem 'debugger', group: [:development, :test] diff --git a/Gemfile.lock b/Gemfile.lock index 50e4edd..c31f95d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,222 +1,242 @@ +GIT + remote: git://github.com/justinfrench/formtastic.git + revision: f630fb0bee233c75301cc0a362cfbe58ae7b5001 + specs: + formtastic (2.3.0.rc2) + actionpack (>= 3.0) + GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.9) - actionpack (= 3.2.9) - mail (~> 2.4.4) - actionpack (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - builder (~> 3.0.0) + actionmailer (4.0.0) + actionpack (= 4.0.0) + mail (~> 2.5.3) + actionpack (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) erubis (~> 2.7.0) - journey (~> 1.0.4) - rack (~> 1.4.0) - rack-cache (~> 1.2) - rack-test (~> 0.6.1) - sprockets (~> 2.2.1) - activemodel (3.2.9) - activesupport (= 3.2.9) - builder (~> 3.0.0) - activerecord (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - arel (~> 3.0.2) - tzinfo (~> 0.3.29) - activeresource (3.2.9) - activemodel (= 3.2.9) - activesupport (= 3.2.9) - activesupport (3.2.9) - i18n (~> 0.6) - multi_json (~> 1.0) - acts_as_tree (1.2.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.0) + activesupport (= 4.0.0) + builder (~> 3.1.0) + activerecord (4.0.0) + activemodel (= 4.0.0) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.0) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.3) + activesupport (4.0.0) + i18n (~> 0.6, >= 0.6.4) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + acts_as_commentable (4.0.1) + acts_as_tree (1.5.1) activerecord (>= 3.0.0) - arel (3.0.2) + arel (4.0.2) + bcrypt (3.1.7) bcrypt-ruby (3.0.1) - builder (3.0.4) - cancan (1.6.8) - capistrano (2.13.5) + builder (3.1.4) + cancan (1.6.10) + capistrano (2.15.5) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) - carrierwave (0.7.1) + carrierwave (0.9.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) - chunky_png (1.2.7) - coffee-rails (3.2.2) + json (>= 1.7) + chunky_png (1.3.0) + coffee-rails (4.0.1) coffee-script (>= 2.2.0) - railties (~> 3.2.0) + railties (>= 4.0.0, < 5.0) coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.4.0) - commonjs (0.2.6) - compass (0.12.2) + coffee-script-source (1.7.0) + commonjs (0.2.7) + compass (0.12.5) chunky_png (~> 1.2) fssm (>= 0.2.7) - sass (~> 3.1) - compass-rails (1.0.3) - compass (>= 0.12.2, < 0.14) - devise (2.1.2) - bcrypt-ruby (~> 3.0) + sass (~> 3.2.19) + compass-rails (1.1.6) + compass (>= 0.12.2) + devise (3.2.4) + bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (~> 3.1) - warden (~> 1.2.1) + railties (>= 3.2.6, < 5) + thread_safe (~> 0.1) + warden (~> 1.2.3) erubis (2.7.0) - execjs (1.4.0) - multi_json (~> 1.0) - formtastic (2.2.1) - actionpack (>= 3.0) - fssm (0.2.9) - geocoder (1.1.6) - gravatar_image_tag (1.1.3) - haml (3.1.7) - highline (1.6.15) - hike (1.2.1) - i18n (0.6.1) - journey (1.0.4) - jquery-rails (2.1.4) + execjs (2.0.2) + fssm (0.2.10) + geocoder (1.1.9) + haml (4.0.5) + tilt + haml-rails (0.5.1) + actionpack (~> 4.0.0) + activesupport (~> 4.0.0) + haml (>= 3.1, < 5.0) + railties (~> 4.0.0) + highline (1.6.21) + hike (1.2.3) + htmlentities (4.3.1) + i18n (0.6.9) + jbuilder (1.0.2) + activesupport (>= 3.0.0) + jquery-rails (3.1.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (4.0.1) - jquery-rails - railties (>= 3.1.0) - json (1.7.6) - kaminari (0.14.1) + jquery-ui-rails (4.2.0) + railties (>= 3.2.16) + json (1.8.1) + kaminari (0.15.1) actionpack (>= 3.0.0) activesupport (>= 3.0.0) - less (2.3.2) - commonjs (~> 0.2.6) - less-rails (2.3.3) + kaminari-bootstrap (3.0.1) + kaminari (>= 0.13.0) + rails + kgio (2.9.2) + less (2.5.0) + commonjs (~> 0.2.7) + less-rails (2.5.0) actionpack (>= 3.1) - less (~> 2.3.1) - libv8 (3.11.8.17) - mail (2.4.4) - i18n (>= 0.4.0) + less (~> 2.5.0) + libv8 (3.16.14.3) + mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.19) - modular-scale (1.0.2) - compass (>= 0.11.5) - sassy-math (>= 1.2) - multi_json (1.5.0) - mysql2 (0.3.11) - net-scp (1.0.4) - net-ssh (>= 1.99.1) - net-sftp (2.0.5) - net-ssh (>= 2.0.9) - net-ssh (2.6.2) - net-ssh-gateway (1.1.0) - net-ssh (>= 1.99.1) - nokogiri (1.5.6) - orm_adapter (0.4.0) - pg (0.14.1) - polyglot (0.3.3) - posix-spawn (0.3.6) - pygments.rb (0.3.7) + mime-types (1.25.1) + mini_portile (0.5.3) + minitest (4.7.5) + multi_json (1.9.2) + mysql2 (0.3.15) + net-scp (1.1.2) + net-ssh (>= 2.6.5) + net-sftp (2.1.2) + net-ssh (>= 2.6.5) + net-ssh (2.8.0) + net-ssh-gateway (1.2.0) + net-ssh (>= 2.6.5) + nokogiri (1.6.1) + mini_portile (~> 0.5.0) + orm_adapter (0.5.0) + polyglot (0.3.4) + posix-spawn (0.3.8) + pygments.rb (0.5.4) posix-spawn (~> 0.3.6) yajl-ruby (~> 1.1.0) - rack (1.4.5) - rack-cache (1.2) - rack (>= 0.4) - rack-ssl (1.3.2) - rack + rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (3.2.9) - actionmailer (= 3.2.9) - actionpack (= 3.2.9) - activerecord (= 3.2.9) - activeresource (= 3.2.9) - activesupport (= 3.2.9) - bundler (~> 1.0) - railties (= 3.2.9) - railties (3.2.9) - actionpack (= 3.2.9) - activesupport (= 3.2.9) - rack-ssl (~> 1.3.2) + rails (4.0.0) + actionmailer (= 4.0.0) + actionpack (= 4.0.0) + activerecord (= 4.0.0) + activesupport (= 4.0.0) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.0) + sprockets-rails (~> 2.0.0) + railties (4.0.0) + actionpack (= 4.0.0) + activesupport (= 4.0.0) rake (>= 0.8.7) - rdoc (~> 3.4) - thor (>= 0.14.6, < 2.0) - rake (10.0.3) - raptor-editor-rails (0.2.1) - rails (> 3.1) - rdoc (3.12) + thor (>= 0.18.1, < 2.0) + raindrops (0.13.0) + rake (10.2.2) + rdoc (4.1.1) json (~> 1.4) - redcarpet (2.2.2) + redcarpet (3.1.1) ref (1.0.5) - rmagick (2.13.1) - rvm-capistrano (1.2.7) - capistrano (>= 2.0.0) - sass (3.2.5) - sass-rails (3.2.5) - railties (~> 3.2.0) + rmagick (2.13.2) + rvm-capistrano (1.5.1) + capistrano (~> 2.15.4) + sass (3.2.19) + sass-rails (4.0.1) + railties (>= 4.0.0, < 5.0) sass (>= 3.1.10) - tilt (~> 1.3) - sassy-math (1.2) - compass (~> 0.11) - sprockets (2.2.2) + sprockets-rails (~> 2.0.0) + sdoc (0.4.0) + json (~> 1.8) + rdoc (~> 4.0, < 5.0) + sprockets (2.12.0) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - therubyracer (0.11.4) - libv8 (~> 3.11.8.12) + sprockets-rails (2.0.1) + actionpack (>= 3.0) + activesupport (>= 3.0) + sprockets (~> 2.8) + therubyracer (0.12.1) + libv8 (~> 3.16.14.0) ref - thor (0.16.0) - tilt (1.3.3) - treetop (1.4.12) + thor (0.19.1) + thread_safe (0.3.3) + tilt (1.4.1) + treetop (1.4.15) polyglot polyglot (>= 0.3.1) - twitter-bootstrap-rails (2.2.7) + turbolinks (2.2.2) + coffee-rails + twitter-bootstrap-rails (2.2.8) actionpack (>= 3.1) execjs rails (>= 3.1) railties (>= 3.1) - tzinfo (0.3.35) - uglifier (1.3.0) + tzinfo (0.3.39) + uglifier (2.5.0) execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - warden (1.2.1) + json (>= 1.8.0) + unicorn (4.8.2) + kgio (~> 2.6) + rack + raindrops (~> 0.7) + warden (1.2.3) rack (>= 1.0) yajl-ruby (1.1.0) - zurb-foundation (3.2.3) - compass (>= 0.12.2) - modular-scale (>= 1.0.2) - rake + zurb-foundation (4.3.2) sass (>= 3.2.0) PLATFORMS ruby DEPENDENCIES + acts_as_commentable acts_as_tree + bcrypt-ruby (~> 3.0.0) cancan capistrano - carrierwave - coffee-rails (~> 3.2.1) + carrierwave (= 0.9.0) + coffee-rails (~> 4.0.0) compass-rails devise - formtastic + formtastic! geocoder - gravatar_image_tag - haml + haml-rails + htmlentities + jbuilder (~> 1.0.1) jquery-rails jquery-ui-rails kaminari + kaminari-bootstrap less-rails mysql2 nokogiri - pg pygments.rb - rails (= 3.2.9) - raptor-editor-rails + rails (= 4.0.0) redcarpet rmagick rvm-capistrano - sass-rails (~> 3.2.3) + sass-rails + sdoc therubyracer + turbolinks twitter-bootstrap-rails - uglifier (>= 1.0.3) + uglifier (>= 1.3.0) + unicorn zurb-foundation (>= 3.2) diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index fc679e8..de912ab 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -27,6 +27,7 @@ require ./shared/modernizr.js */ + $(document).ready(function(){ diff --git a/app/assets/javascripts/connexion.coffee b/app/assets/javascripts/connexion.coffee new file mode 100644 index 0000000..5127ddf --- /dev/null +++ b/app/assets/javascripts/connexion.coffee @@ -0,0 +1,6 @@ +#= require jquery +#= require jquery.ui.all +#= require twitter/bootstrap + +#= require ./shared/jquery.backstretch.js + diff --git a/app/assets/javascripts/connexion.js b/app/assets/javascripts/connexion.js deleted file mode 100644 index 54517a1..0000000 --- a/app/assets/javascripts/connexion.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - -*= require jquery -*= require jquery_ujs - -*= require ./shared/modernizr - - - -*/ \ No newline at end of file diff --git a/app/assets/javascripts/forum.coffee b/app/assets/javascripts/forum.coffee new file mode 100644 index 0000000..7d14ee2 --- /dev/null +++ b/app/assets/javascripts/forum.coffee @@ -0,0 +1,84 @@ + +#= require jquery +#= require ./shared/jquery-ui +#= require twitter/bootstrap +#= require jquery_ujs + +#= require ./note_files/ajquery.ui.widget +#= require ./note_files/jquery.fileupload + + + +#= require redactor + + + +$(document).on "scroll", () -> + + if( $(this).scrollTop() <= 40 ) + top = 40 - $(this).scrollTop() + else + top = 0 + + $("#toolbar-text, .fix-submit").css + top : top + + +@init_user_images = -> + $(".images .user_image").click -> + src = undefined + src = $(this).data("src") + $("#message_form .content").redactor().insertHtml "" + false + + return + +editor = new Array() +$(document).ready -> + + $(".user_images").on "click", (event) -> + $(this).toggleClass("open") + + + $(".redactor_editor").on "click", "img", (event) -> + event.stopPropagation() + return + + + + #upload + drop = $(".user_images") + $(".user_images .fileupload").fileupload + url: $(this).attr("action") + dropZone: drop + autoUpload: true + progressall: (e, data) -> + progress = parseInt(data.loaded / data.total * 100, 10) + if progress is 100 + $(this).find(".progress").html "traitement en cours." + else + $(this).find(".progress").html progress + "% téléchargé." + return + + always: (e, data) -> + $(this).find(".progress").html "" + return + + drop: (e, data) -> + + drop.css "background", "white" + return + + drop.bind "dragover", (e) -> + $(this).css "background", "#B7DF63" + return + + drop.bind "dragleave", (e) -> + $(this).css "background", "white" + return + + $(".user_images .add_files").on "click", -> + $(this).next("input").click() + false + + return diff --git a/app/assets/javascripts/forum.js b/app/assets/javascripts/forum.js deleted file mode 100644 index ee0cf3d..0000000 --- a/app/assets/javascripts/forum.js +++ /dev/null @@ -1,137 +0,0 @@ -/* -*= require jquery - -*= require jquery_ujs - -*= require ./note_files/ajquery.ui.widget -*= require ./note_files/jquery.fileupload - -*= require ./shared/ace.js -*= require ./shared/mode-markdown.js -*= require ./shared/theme-textmate.js - -*/ - -var editor = new Array(); - -function init_user_images(){ - - $(".message_form").find(".images .user_image").click(function(){ - - var src; - src = $(this).data("src"); - - r= $(this).closest(".message_form").find("textarea.markdown").data("id"); - editor[r].focus(); - editor[r].insert("\n\n![]()\n\n"); - editor[r].focus(); - - - - - return false; - - - }); -} - -$(document).ready(function(){ - - $("textarea.markdown").each(function(){ - var r; - var ed; - - - - r = Math.floor((Math.random()*1000)+1); - - $(this).data("id", r); - - - $(this).attr("id", r+"-textarea"); - $(this).after('
bla
'); - - - - - editor[r] = ace.edit(r+"-editor"); - editor[r].setTheme("ace/theme/textmate"); - editor[r].getSession().setMode("ace/mode/markdown"); - - editor[r].setPrintMarginColumn(0); - - editor[r].session.setUseWrapMode(true); - - - - - - - editor[r].setHighlightActiveLine(false); - - editor[r].renderer.setShowGutter(false); - editor[r].renderer.setShowPrintMargin(false); - - editor[r].setFontSize("14px"); - - - - var textarea = $('#'+r+'-textarea').hide(); - editor[r].getSession().setValue(textarea.val()); - - editor[r].getSession().on('change', function(){ - - textarea.val(editor[r].getSession().getValue()); - - - }); - - - }); - - //upload - - drop = $('.user_images'); - - $('.user_images .fileupload').fileupload({ - url: $(this).attr("action"), - dropZone: drop, - autoUpload: true, - progressall: function (e, data) { - var progress = parseInt(data.loaded / data.total * 100, 10); - if(progress == 100){ - $(this).find('.progress').html('traitement en cours.'); - } - else{ - $(this).find('.progress').html(progress + '% téléchargé.');} - }, - always: function (e, data) { - $(this).find('.progress').html(""); - }, - - drop: function (e, data) { - - drop.css("background", "transparent"); - } - }); - - - drop.bind('dragover', function (e) { - $(this).css("background", "#B7DF63"); - - }); - - drop.bind('dragleave', function (e) { - $(this).css("background", "transparent"); - - }); - - $(".user_images .add_files").live("click",function(){ - - $(this).next('input').click(); - return false; - }); - - -}); - diff --git a/app/assets/javascripts/plaquettes.coffee b/app/assets/javascripts/plaquettes.coffee index 3c6f198..52b3e2c 100644 --- a/app/assets/javascripts/plaquettes.coffee +++ b/app/assets/javascripts/plaquettes.coffee @@ -1,6 +1,6 @@ #= require jquery #= require jquery_ujs -#= require jquery-ui +#= require jquery.ui.all #= require ./shared/jquery.ui.touch-punch #= require ./shared/jquery-jPuzzle @@ -100,49 +100,6 @@ $ -> - - - $(".places_jeu2").each -> - $(this).find(".receptable").droppable - tolerance: "touch" - accept: (e) -> - if e.hasClass("intru") == false and $(this).find("img").size() == 0 - true - drop: ( event, ui ) -> - - $( this ).append(ui.draggable) - ui.draggable.attr("style", "") - - if $(this).closest(".places_jeu2").find(".vignettes img").size() == 2 - $(this).closest(".places_jeu2").find(".success").show() - - $(this).find(".vignettes img").draggable - #connectWith: ".receptable" - tolerance: "pointer" - revert: "invalid" - - - - $(".places_jeu").each -> - $(this).find(".receptable").droppable - tolerance: "touch" - accept: (e) -> - if e.data("rep") == $(this).data("rep") - true - drop: ( event, ui ) -> - - $( this ).append(ui.draggable) - ui.draggable.attr("style", "") - - if $(this).closest(".places_jeu").find(".vignettes img").size() == 0 - $(this).closest(".places_jeu").find(".success").show() - - $(this).find(".vignettes img").draggable - #connectWith: ".receptable" - tolerance: "pointer" - revert: "invalid" - - @@ -179,7 +136,65 @@ $ -> test_question($(this).closest(".question")) + + + + +intialize_places_jeu2 = () -> + $(".places_jeu2").each -> + archive = $(this).html() + $(this).find(".receptable").droppable + tolerance: "touch" + accept: (e) -> + if e.hasClass("intru") == false and $(this).find("img").size() == 0 + true + drop: ( event, ui ) -> + + $( this ).append(ui.draggable) + ui.draggable.attr("style", "") + + if $(this).closest(".places_jeu2").find(".vignettes img").size() == 2 + $(this).closest(".places_jeu2").find(".success").show() + + $(this).find(".vignettes img").draggable + #connectWith: ".receptable" + tolerance: "pointer" + revert: "invalid" + + $(this).find(".reset").click -> + $(this).closest(".places_jeu2").html archive + $(this).closest(".places_jeu2").find(".success").hide() + intialize_places_jeu2() + + +intialize_places_jeu = () -> + $(".places_jeu").each -> + archive = $(this).html() + $(this).find(".receptable").droppable + tolerance: "touch" + accept: (e) -> + if e.data("rep") == $(this).data("rep") + true + drop: ( event, ui ) -> + + $( this ).append(ui.draggable) + ui.draggable.attr("style", "") + if $(this).closest(".places_jeu").find(".vignettes img").size() == 0 + $(this).closest(".places_jeu").find(".success").show() + + $(this).find(".vignettes img").draggable + #connectWith: ".receptable" + tolerance: "pointer" + revert: "invalid" + + $(this).find(".reset").click -> + $(this).closest(".places_jeu").html archive + $(this).closest(".places_jeu").find(".success").hide() + intialize_places_jeu() + + + intialize_puzzle = () -> $(".puzzle").each -> archive = $(this).html() @@ -220,7 +235,7 @@ intialize_arbre = () -> win = false unless i is $(this).data("order") if win is true - $(".success").show() + $(".vie-arbre-place .success").show() $(".vie-arbre.story").closest(".sortable_quizz").find(".reset").click -> $(".vie-arbre.story").closest(".sortable_quizz").html archive @@ -259,7 +274,8 @@ $(document).ready -> - + intialize_places_jeu2() + intialize_places_jeu() diff --git a/app/assets/javascripts/redactor.js b/app/assets/javascripts/redactor.js new file mode 100755 index 0000000..ec3659a --- /dev/null +++ b/app/assets/javascripts/redactor.js @@ -0,0 +1,4269 @@ +/* + Redactor v8.2.2 + Updated: January 17, 2013 + + http://redactorjs.com/ + + Copyright (c) 2009-2013, Imperavi Inc. + License: http://redactorjs.com/license/ + + Usage: $('#content').redactor(); +*/ + +var rwindow, rdocument; + +if (typeof RELANG === 'undefined') +{ + var RELANG = {}; +} + +var RLANG = { + html: 'HTML', + video: 'Insert Video', + image: 'Insert Image', + table: 'Table', + link: 'Link', + link_insert: 'Insert link', + unlink: 'Unlink', + formatting: 'Formatting', + paragraph: 'Paragraph', + quote: 'Quote', + code: 'Code', + header1: 'Header 1', + header2: 'Header 2', + header3: 'Header 3', + header4: 'Header 4', + bold: 'Bold', + italic: 'Italic', + fontcolor: 'Font Color', + backcolor: 'Back Color', + unorderedlist: 'Unordered List', + orderedlist: 'Ordered List', + outdent: 'Outdent', + indent: 'Indent', + cancel: 'Cancel', + insert: 'Insert', + save: 'Save', + _delete: 'Delete', + insert_table: 'Insert Table', + insert_row_above: 'Add Row Above', + insert_row_below: 'Add Row Below', + insert_column_left: 'Add Column Left', + insert_column_right: 'Add Column Right', + delete_column: 'Delete Column', + delete_row: 'Delete Row', + delete_table: 'Delete Table', + rows: 'Rows', + columns: 'Columns', + add_head: 'Add Head', + delete_head: 'Delete Head', + title: 'Title', + image_position: 'Position', + none: 'None', + left: 'Left', + right: 'Right', + image_web_link: 'Image Web Link', + text: 'Text', + mailto: 'Email', + web: 'URL', + video_html_code: 'Video Embed Code', + file: 'Insert File', + upload: 'Upload', + download: 'Download', + choose: 'Choose', + or_choose: 'Or choose', + drop_file_here: 'Drop file here', + align_left: 'Align text to the left', + align_center: 'Center text', + align_right: 'Align text to the right', + align_justify: 'Justify text', + horizontalrule: 'Insert Horizontal Rule', + deleted: 'Deleted', + anchor: 'Anchor', + link_new_tab: 'Open link in new tab', + underline: 'Underline', + alignment: 'Alignment' +}; + +(function($){ + + // Plugin + jQuery.fn.redactor = function(option) + { + return this.each(function() + { + var $obj = $(this); + + var data = $obj.data('redactor'); + if (!data) + { + $obj.data('redactor', (data = new Redactor(this, option))); + } + }); + }; + + + // Initialization + var Redactor = function(element, options) + { + // Element + this.$el = $(element); + + // Lang + if (typeof options !== 'undefined' && typeof options.lang !== 'undefined' && options.lang !== 'en' && typeof RELANG[options.lang] !== 'undefined') + { + RLANG = RELANG[options.lang]; + } + + // Options + this.opts = $.extend({ + + iframe: false, + css: false, // url + + lang: 'en', + direction: 'ltr', // ltr or rtl + + callback: false, // function + keyupCallback: false, // function + keydownCallback: false, // function + execCommandCallback: false, // function + + plugins: false, + cleanup: true, + + focus: false, + tabindex: false, + autoresize: true, + minHeight: false, + fixed: false, + fixedTop: 0, // pixels + fixedBox: false, + source: true, + shortcuts: true, + + mobile: true, + air: false, // true or toolbar + wym: false, + + convertLinks: true, + convertDivs: true, + protocol: 'http://', // for links http or https or ftp or false + + autosave: false, // false or url + autosaveCallback: false, // function + interval: 60, // seconds + + imageGetJson: false, // url (ex. /folder/images.json ) or false + + imageUpload: false, // url + imageUploadCallback: false, // function + imageUploadErrorCallback: false, // function + + fileUpload: false, // url + fileUploadCallback: false, // function + fileUploadErrorCallback: false, // function + + uploadCrossDomain: false, + uploadFields: false, + + observeImages: true, + overlay: true, // modal overlay + + allowedTags: ["form", "input", "button", "select", "option", "datalist", "output", "textarea", "fieldset", "legend", + "section", "header", "hgroup", "aside", "footer", "article", "details", "nav", "progress", "time", "canvas", + "code", "span", "div", "label", "a", "br", "p", "b", "i", "del", "strike", "u", + "img", "video", "source", "track", "audio", "iframe", "object", "embed", "param", "blockquote", + "mark", "cite", "small", "ul", "ol", "li", "hr", "dl", "dt", "dd", "sup", "sub", + "big", "pre", "code", "figure", "figcaption", "strong", "em", "table", "tr", "td", + "th", "tbody", "thead", "tfoot", "h1", "h2", "h3", "h4", "h5", "h6"], + + toolbarExternal: false, // ID selector + + buttonsCustom: {}, + buttonsAdd: [], + buttons: ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', + 'image', 'video', 'file', 'table', 'link', '|', + 'fontcolor', 'backcolor', '|', 'alignment', '|', 'horizontalrule'], // 'underline', 'alignleft', 'aligncenter', 'alignright', 'justify' + + airButtons: ['formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'fontcolor', 'backcolor'], + + formattingTags: ['p', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4'], + + activeButtons: ['deleted', 'italic', 'bold', 'underline', 'unorderedlist', 'orderedlist'], // 'alignleft', 'aligncenter', 'alignright', 'justify' + activeButtonsStates: { + b: 'bold', + strong: 'bold', + i: 'italic', + em: 'italic', + del: 'deleted', + strike: 'deleted', + ul: 'unorderedlist', + ol: 'orderedlist', + u: 'underline' + }, + + colors: [ + '#ffffff', '#000000', '#eeece1', '#1f497d', '#4f81bd', '#c0504d', '#9bbb59', '#8064a2', '#4bacc6', '#f79646', '#ffff00', + '#f2f2f2', '#7f7f7f', '#ddd9c3', '#c6d9f0', '#dbe5f1', '#f2dcdb', '#ebf1dd', '#e5e0ec', '#dbeef3', '#fdeada', '#fff2ca', + '#d8d8d8', '#595959', '#c4bd97', '#8db3e2', '#b8cce4', '#e5b9b7', '#d7e3bc', '#ccc1d9', '#b7dde8', '#fbd5b5', '#ffe694', + '#bfbfbf', '#3f3f3f', '#938953', '#548dd4', '#95b3d7', '#d99694', '#c3d69b', '#b2a2c7', '#b7dde8', '#fac08f', '#f2c314', + '#a5a5a5', '#262626', '#494429', '#17365d', '#366092', '#953734', '#76923c', '#5f497a', '#92cddc', '#e36c09', '#c09100', + '#7f7f7f', '#0c0c0c', '#1d1b10', '#0f243e', '#244061', '#632423', '#4f6128', '#3f3151', '#31859b', '#974806', '#7f6000'], + + // private + emptyHtml: '


', + buffer: false, + visual: true, + + // modal windows container + modal_file: String() + + '
' + + '
' + + '' + + '' + + '
' + + '' + + '
' + + '

' + + '
', + + modal_image_edit: String() + + '
' + + '' + + '' + + '' + + '' + + '' + + '' + + '
' + + '', + + modal_image: String() + + '
' + + '' + + '
' + + '
' + + '' + + '
' + + '' + + '
' + + '' + + '
' + + '', + + modal_link: String() + + '
' + + '
' + + '
' + + 'URL' + + 'Email' + + '' + RLANG.anchor + '' + + '
' + + '' + + '
' + + '' + + '' + + '' + + '
' + + '' + + '' + + '
' + + '
' + + '', + + modal_table: String() + + '
' + + '' + + '' + + '' + + '' + + '
' + + '', + + modal_video: String() + + '
' + + '
' + + '' + + '' + + '
' + + '
'+ + '', + + toolbar: { + html: + { + title: RLANG.html, + func: 'toggle' + }, + formatting: + { + title: RLANG.formatting, + func: 'show', + dropdown: + { + p: + { + title: RLANG.paragraph, + exec: 'formatblock' + }, + blockquote: + { + title: RLANG.quote, + exec: 'formatblock', + className: 'redactor_format_blockquote' + }, + pre: + { + title: RLANG.code, + exec: 'formatblock', + className: 'redactor_format_pre' + }, + h1: + { + title: RLANG.header1, + exec: 'formatblock', + className: 'redactor_format_h1' + }, + h2: + { + title: RLANG.header2, + exec: 'formatblock', + className: 'redactor_format_h2' + }, + h3: + { + title: RLANG.header3, + exec: 'formatblock', + className: 'redactor_format_h3' + }, + h4: + { + title: RLANG.header4, + exec: 'formatblock', + className: 'redactor_format_h4' + } + } + }, + bold: + { + title: RLANG.bold, + exec: 'bold' + }, + italic: + { + title: RLANG.italic, + exec: 'italic' + }, + deleted: + { + title: RLANG.deleted, + exec: 'strikethrough' + }, + underline: + { + title: RLANG.underline, + exec: 'underline' + }, + unorderedlist: + { + title: '• ' + RLANG.unorderedlist, + exec: 'insertunorderedlist' + }, + orderedlist: + { + title: '1. ' + RLANG.orderedlist, + exec: 'insertorderedlist' + }, + outdent: + { + title: '< ' + RLANG.outdent, + exec: 'outdent' + }, + indent: + { + title: '> ' + RLANG.indent, + exec: 'indent' + }, + image: + { + title: RLANG.image, + func: 'showImage' + }, + video: + { + title: RLANG.video, + func: 'showVideo' + }, + file: + { + title: RLANG.file, + func: 'showFile' + }, + table: + { + title: RLANG.table, + func: 'show', + dropdown: + { + insert_table: + { + title: RLANG.insert_table, + func: 'showTable' + }, + separator_drop1: + { + name: 'separator' + }, + insert_row_above: + { + title: RLANG.insert_row_above, + func: 'insertRowAbove' + }, + insert_row_below: + { + title: RLANG.insert_row_below, + func: 'insertRowBelow' + }, + insert_column_left: + { + title: RLANG.insert_column_left, + func: 'insertColumnLeft' + }, + insert_column_right: + { + title: RLANG.insert_column_right, + func: 'insertColumnRight' + }, + separator_drop2: + { + name: 'separator' + }, + add_head: + { + title: RLANG.add_head, + func: 'addHead' + }, + delete_head: + { + title: RLANG.delete_head, + func: 'deleteHead' + }, + separator_drop3: + { + name: 'separator' + }, + delete_column: + { + title: RLANG.delete_column, + func: 'deleteColumn' + }, + delete_row: + { + title: RLANG.delete_row, + func: 'deleteRow' + }, + delete_table: + { + title: RLANG.delete_table, + func: 'deleteTable' + } + } + }, + link: + { + title: RLANG.link, + func: 'show', + dropdown: + { + link: + { + title: RLANG.link_insert, + func: 'showLink' + }, + unlink: + { + title: RLANG.unlink, + exec: 'unlink' + } + } + }, + fontcolor: + { + title: RLANG.fontcolor, + func: 'show' + }, + backcolor: + { + title: RLANG.backcolor, + func: 'show' + }, + alignment: + { + title: RLANG.alignment, + func: 'show', + dropdown: + { + alignleft: + { + title: RLANG.align_left, + exec: 'JustifyLeft' + }, + aligncenter: + { + title: RLANG.align_center, + exec: 'JustifyCenter' + }, + alignright: + { + title: RLANG.align_right, + exec: 'JustifyRight' + }, + justify: + { + title: RLANG.align_justify, + exec: 'JustifyFull' + } + } + }, + alignleft: + { + exec: 'JustifyLeft', + title: RLANG.align_left + }, + aligncenter: + { + exec: 'JustifyCenter', + title: RLANG.align_center + }, + alignright: + { + exec: 'JustifyRight', + title: RLANG.align_right + }, + justify: + { + exec: 'JustifyFull', + title: RLANG.align_justify + }, + horizontalrule: + { + exec: 'inserthorizontalrule', + title: RLANG.horizontalrule + } + } + + + }, options, this.$el.data()); + + this.dropdowns = []; + + // Init + this.init(); + }; + + // Functionality + Redactor.prototype = { + + + // Initialization + init: function() + { + // get dimensions + this.height = this.$el.css('height'); + this.width = this.$el.css('width'); + + rdocument = this.document = document; + rwindow = this.window = window; + + // mobile + if (this.opts.mobile === false && this.isMobile()) + { + this.build(true); + return false; + } + + // iframe + if (this.opts.iframe) + { + this.opts.autoresize = false; + } + + // extend buttons + if (this.opts.air) + { + this.opts.buttons = this.opts.airButtons; + } + else if (this.opts.toolbar !== false) + { + if (this.opts.source === false) + { + var index = this.opts.buttons.indexOf('html'); + var next = this.opts.buttons[index+1]; + this.opts.buttons.splice(index, 1); + if (typeof next !== 'undefined' && next === '|') + { + this.opts.buttons.splice(index, 1); + } + } + + $.extend(this.opts.toolbar, this.opts.buttonsCustom); + $.each(this.opts.buttonsAdd, $.proxy(function(i,s) + { + this.opts.buttons.push(s); + + }, this)); + } + + // formatting tags + if (this.opts.toolbar !== false) + { + $.each(this.opts.toolbar.formatting.dropdown, $.proxy(function(i,s) + { + if ($.inArray(i, this.opts.formattingTags) == '-1') + { + delete this.opts.toolbar.formatting.dropdown[i]; + } + + }, this)); + } + + function afterBuild() + { + // air enable + this.enableAir(); + + // toolbar + this.buildToolbar(); + + // PLUGINS + if (typeof this.opts.plugins === 'object') + { + $.each(this.opts.plugins, $.proxy(function(i,s) + { + if (typeof RedactorPlugins[s] !== 'undefined') + { + $.extend(this, RedactorPlugins[s]); + + if (typeof RedactorPlugins[s].init !== 'undefined') + { + this.init(); + } + } + + }, this)); + } + + // buttons response + if (this.opts.activeButtons !== false && this.opts.toolbar !== false) + { + var observeFormatting = $.proxy(function() { this.observeFormatting(); }, this); + this.$editor.click(observeFormatting).keyup(observeFormatting); + } + + // paste + var oldsafari = false; + if (this.browser('webkit') && navigator.userAgent.indexOf('Chrome') === -1) + { + var arr = this.browser('version').split('.'); + if (arr[0] < 536) oldsafari = true; + } + + if (this.isMobile(true) === false && oldsafari === false) + { + this.$editor.bind('paste', $.proxy(function(e) + { + if (this.opts.cleanup === false) + { + return true; + } + + this.pasteRunning = true; + + this.setBuffer(); + + if (this.opts.autoresize === true) + { + this.saveScroll = this.document.body.scrollTop; + } + else + { + this.saveScroll = this.$editor.scrollTop(); + } + + var frag = this.extractContent(); + + setTimeout($.proxy(function() + { + var pastedFrag = this.extractContent(); + this.$editor.append(frag); + + this.restoreSelection(); + + var html = this.getFragmentHtml(pastedFrag); + this.pasteCleanUp(html); + this.pasteRunning = false; + + }, this), 1); + + }, this)); + } + + // key handlers + this.keyup(); + this.keydown(); + + // autosave + if (this.opts.autosave !== false) + { + this.autoSave(); + } + + // observers + setTimeout($.proxy(function() + { + this.observeImages(); + this.observeTables(); + + }, this), 1); + + // FF fix + if (this.browser('mozilla')) + { + this.$editor.click($.proxy(function() + { + this.saveSelection(); + }, this)); + + try + { + this.document.execCommand('enableObjectResizing', false, false); + this.document.execCommand('enableInlineTableEditing', false, false); + } + catch (e) {} + } + + // focus + if (this.opts.focus) + { + setTimeout($.proxy(function(){ + this.$editor.focus(); + }, this), 1); + } + + // fixed + if (this.opts.fixed) + { + this.observeScroll(); + $(document).scroll($.proxy(this.observeScroll, this)); + } + + // callback + if (typeof this.opts.callback === 'function') + { + this.opts.callback(this); + } + + if (this.opts.toolbar !== false) + { + this.$toolbar.find('a').attr('tabindex', '-1'); + } + } + + // construct editor + this.build(false, afterBuild); + + }, + shortcuts: function(e, cmd) + { + e.preventDefault(); + this.execCommand(cmd, false); + }, + keyup: function() + { + this.$editor.keyup($.proxy(function(e) + { + var key = e.keyCode || e.which; + + if (this.browser('mozilla') && !this.pasteRunning) + { + this.saveSelection(); + } + + // callback as you type + if (typeof this.opts.keyupCallback === 'function') + { + this.opts.keyupCallback(this, e); + } + + // if empty + if (key === 8 || key === 46) + { + this.observeImages(); + return this.formatEmpty(e); + } + + // new line p + if (key === 13 && !e.shiftKey && !e.ctrlKey && !e.metaKey) + { + if (this.browser('webkit')) + { + this.formatNewLine(e); + } + + // convert links + if (this.opts.convertLinks) + { + this.$editor.linkify(); + } + } + + this.syncCode(); + + }, this)); + }, + keydown: function() + { + this.$editor.keydown($.proxy(function(e) + { + var key = e.keyCode || e.which; + var parent = this.getParentNode(); + var current = this.getCurrentNode(); + var pre = false; + var ctrl = e.ctrlKey || e.metaKey; + + if ((parent || current) && ($(parent).get(0).tagName === 'PRE' || $(current).get(0).tagName === 'PRE')) + { + pre = true; + } + + // callback keydown + if (typeof this.opts.keydownCallback === 'function') + { + this.opts.keydownCallback(this, e); + } + + if (ctrl && this.opts.shortcuts) + { + if (key === 90) + { + if (this.opts.buffer !== false) + { + e.preventDefault(); + this.getBuffer(); + } + else if (e.shiftKey) + { + this.shortcuts(e, 'redo'); // Ctrl + Shift + z + } + else + { + this.shortcuts(e, 'undo'); // Ctrl + z + } + } + else if (key === 77) + { + this.shortcuts(e, 'removeFormat'); // Ctrl + m + } + else if (key === 66) + { + this.shortcuts(e, 'bold'); // Ctrl + b + } + else if (key === 73) + { + this.shortcuts(e, 'italic'); // Ctrl + i + } + else if (key === 74) + { + this.shortcuts(e, 'insertunorderedlist'); // Ctrl + j + } + else if (key === 75) + { + this.shortcuts(e, 'insertorderedlist'); // Ctrl + k + } + else if (key === 76) + { + this.shortcuts(e, 'superscript'); // Ctrl + l + } + else if (key === 72) + { + this.shortcuts(e, 'subscript'); // Ctrl + h + } + } + + // clear undo buffer + if (!ctrl && key !== 90) + { + this.opts.buffer = false; + } + + // enter + if (pre === true && key === 13) + { + e.preventDefault(); + + var html = $(current).parent().text(); + this.insertNodeAtCaret(this.document.createTextNode('\r\n')); + if (html.search(/\s$/) == -1) + { + this.insertNodeAtCaret(this.document.createTextNode('\r\n')); + } + this.syncCode(); + + return false; + } + + // tab + if (this.opts.shortcuts && !e.shiftKey && key === 9) + { + if (pre === false) + { + this.shortcuts(e, 'indent'); // Tab + } + else + { + e.preventDefault(); + this.insertNodeAtCaret(this.document.createTextNode('\t')); + this.syncCode(); + return false; + } + } + else if (this.opts.shortcuts && e.shiftKey && key === 9 ) + { + this.shortcuts(e, 'outdent'); // Shift + tab + } + + // safari shift key + enter + if (this.browser('webkit') && navigator.userAgent.indexOf('Chrome') === -1) + { + return this.safariShiftKeyEnter(e, key); + } + }, this)); + }, + build: function(mobile, whendone) + { + if (mobile !== true) + { + // container + this.$box = $('
'); + + // air box + if (this.opts.air) + { + this.air = $(''); + } + + this.$content = null; + + function initFrame() + { + this.$editor = this.$content.contents().find("body").attr('contenteditable', true).attr('dir', this.opts.direction); + + rdocument = this.document = this.$editor[0].ownerDocument; + rwindow = this.window = this.document.defaultView || window; + + if (this.opts.css !== false) + { + this.$content.contents().find('head').append(''); + } + + this.$editor.html(html); + + if (whendone) + { + whendone.call(this); + whendone = null; + } + } + + // editor + this.textareamode = true; + if (this.$el.get(0).tagName === 'TEXTAREA') + { + if(this.opts.iframe) + { + var me = this; + this.$content = $('').load(function() + { + initFrame.call(me); + }); + } + else + { + this.$content = this.$editor = $('
'); + } + + var classlist = this.$el.get(0).className.split(/\s+/); + $.each(classlist, $.proxy(function(i,s) + { + this.$content.addClass('redactor_' + s); + }, this)); + } + else + { + this.textareamode = false; + this.$content = this.$editor = this.$el; + this.$el = $('').css('height', this.height); + } + + if (this.$editor) + { + this.$editor.addClass('redactor_editor').attr('contenteditable', true).attr('dir', this.opts.direction); + } + + if (this.opts.tabindex !== false) + { + this.$content.attr('tabindex', this.opts.tabindex); + } + + if (this.opts.minHeight !== false) + { + this.$content.css('min-height', this.opts.minHeight + 'px'); + } + + if (this.opts.wym === true) + { + this.$content.addClass('redactor_editor_wym'); + } + + if (this.opts.autoresize === false) + { + this.$content.css('height', this.height); + } + + // hide textarea + this.$el.hide(); + + // append box and frame + var html = ''; + if (this.textareamode) + { + // get html + html = this.$el.val(); + html = this.savePreCode(html); + + this.$box.insertAfter(this.$el).append(this.$content).append(this.$el); + } + else + { + // get html + html = this.$editor.html(); + html = this.savePreCode(html); + + this.$box.insertAfter(this.$content).append(this.$el).append(this.$editor); + + } + + // conver newlines to p + html = this.paragraphy(html); + + // enable + if (this.$editor) + { + this.$editor.html(html); + } + + if (this.textareamode === false) + { + this.syncCode(); + } + } + else + { + if (this.$el.get(0).tagName !== 'TEXTAREA') + { + var html = this.$el.val(); + var textarea = $('').css('height', this.height).val(html); + this.$el.hide(); + this.$el.after(textarea); + } + } + + if (whendone && this.$editor) + { + whendone.call(this); + } + + }, + enableAir: function() + { + if (this.opts.air === false) + { + return false; + } + + this.air.hide(); + + this.$editor.bind('textselect', $.proxy(function(e) + { + this.showAir(e); + + }, this)); + + this.$editor.bind('textunselect', $.proxy(function() + { + this.air.hide(); + + }, this)); + + }, + showAir: function(e) + { + $('.redactor_air').hide(); + + var width = this.air.innerWidth(); + var left = e.clientX; + + if ($(this.document).width() < (left + width)) + { + left = left - width; + } + + var top = e.clientY + $(document).scrollTop() + 14; + if (this.opts.iframe === true) + { + top = top + this.$box.position().top; + left = left + this.$box.position().left; + } + + this.air.css({ left: left + 'px', top: top + 'px' }).show(); + }, + syncCode: function() + { + this.$el.val(this.$editor.html()); + }, + + // API functions + setCode: function(html) + { + html = this.stripTags(html); + this.$editor.html(html).focus(); + + this.syncCode(); + }, + getCode: function() + { + var html = ''; + if (this.opts.visual) + { + html = this.$editor.html() + } + else + { + html = this.$el.val(); + } + + return this.stripTags(html); + }, + insertHtml: function(html) + { + this.$editor.focus(); + this.pasteHtmlAtCaret(html); + this.observeImages(); + this.syncCode(); + }, + + pasteHtmlAtCaret: function (html) + { + var sel, range; + if (this.document.getSelection) + { + sel = this.window.getSelection(); + if (sel.getRangeAt && sel.rangeCount) + { + range = sel.getRangeAt(0); + range.deleteContents(); + var el = this.document.createElement("div"); + el.innerHTML = html; + var frag = this.document.createDocumentFragment(), node, lastNode; + while (node = el.firstChild) + { + lastNode = frag.appendChild(node); + } + range.insertNode(frag); + + if (lastNode) + { + range = range.cloneRange(); + range.setStartAfter(lastNode); + range.collapse(true); + sel.removeAllRanges(); + sel.addRange(range); + } + } + } + else if (this.document.selection && this.document.selection.type != "Control") + { + this.document.selection.createRange().pasteHTML(html); + } + }, + + destroy: function() + { + var html = this.getCode(); + + if (this.textareamode) + { + this.$box.after(this.$el); + this.$box.remove(); + this.$el.height(this.height).val(html).show(); + } + else + { + this.$box.after(this.$editor); + this.$box.remove(); + this.$editor.removeClass('redactor_editor').removeClass('redactor_editor_wym').attr('contenteditable', false).html(html).show(); + } + + if (this.opts.toolbarExternal) + { + $(this.opts.toolbarExternal).empty(); + } + + $('.redactor_air').remove(); + + for (var i = 0; i < this.dropdowns.length; i++) + { + this.dropdowns[i].remove(); + delete(this.dropdowns[i]); + } + + if (this.opts.autosave !== false) + { + clearInterval(this.autosaveInterval); + } + + }, + // end API functions + + // OBSERVERS + observeFormatting: function() + { + var parent = this.getCurrentNode(); + + this.inactiveAllButtons(); + + $.each(this.opts.activeButtonsStates, $.proxy(function(i,s) + { + if ($(parent).closest(i,this.$editor.get()[0]).length != 0) + { + this.setBtnActive(s); + } + + }, this)); + + var tag = $(parent).closest(['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'td']); + + if (typeof tag[0] !== 'undefined' && typeof tag[0].elem !== 'undefined' && $(tag[0].elem).size() != 0) + { + var align = $(tag[0].elem).css('text-align'); + + switch (align) + { + case 'right': + this.setBtnActive('alignright'); + break; + case 'center': + this.setBtnActive('aligncenter'); + break; + case 'justify': + this.setBtnActive('justify'); + break; + default: + this.setBtnActive('alignleft'); + break; + } + } + }, + observeImages: function() + { + /*if (this.opts.observeImages === false) + { + return false; + } + + this.$editor.find('img').each($.proxy(function(i,s) + { + if (this.browser('msie')) + { + $(s).attr('unselectable', 'on'); + } + + this.resizeImage(s); + + }, this));*/ + + }, + observeTables: function() + { + this.$editor.find('table').click($.proxy(this.tableObserver, this)); + }, + observeScroll: function() + { + var scrolltop = $(this.document).scrollTop(); + var boxtop = this.$box.offset().top; + var left = 0; + + if (scrolltop > boxtop) + { + var width = '100%'; + if (this.opts.fixedBox) + { + left = this.$box.offset().left; + width = this.$box.innerWidth(); + } + + this.fixed = true; + this.$toolbar.css({ position: 'fixed', width: width, zIndex: 1005, top: this.opts.fixedTop + 'px', left: left }); + } + else + { + this.fixed = false; + this.$toolbar.css({ position: 'relative', width: 'auto', zIndex: 1, top: 0, left: left }); + } + }, + + // BUFFER + setBuffer: function() + { + this.saveSelection(); + this.opts.buffer = this.$editor.html(); + }, + getBuffer: function() + { + if (this.opts.buffer === false) + { + return false; + } + + this.$editor.html(this.opts.buffer); + + if (!this.browser('msie')) + { + this.restoreSelection(); + } + + this.opts.buffer = false; + }, + + + + // EXECCOMMAND + execCommand: function(cmd, param) + { + if (this.opts.visual == false) + { + this.$el.focus(); + return false; + } + + try + { + + var parent; + + if (cmd === 'inserthtml') + { + if (this.browser('msie')) + { + this.$editor.focus(); + this.document.selection.createRange().pasteHTML(param); + } + else + { + this.pasteHtmlAtCaret(param); + //this.execRun(cmd, param); + } + + this.observeImages(); + } + else if (cmd === 'unlink') + { + parent = this.getParentNode(); + if ($(parent).get(0).tagName === 'A') + { + $(parent).replaceWith($(parent).text()); + } + else + { + this.execRun(cmd, param); + } + } + else if (cmd === 'JustifyLeft' || cmd === 'JustifyCenter' || cmd === 'JustifyRight' || cmd === 'JustifyFull') + { + parent = this.getCurrentNode(); + var tag = $(parent).get(0).tagName; + + if (this.opts.iframe === false && $(parent).parents('.redactor_editor').size() == 0) + { + return false; + } + + var tagsArray = ['P', 'DIV', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE', 'TD']; + if ($.inArray(tag, tagsArray) != -1) + { + var align = false; + + if (cmd === 'JustifyCenter') + { + align = 'center'; + } + else if (cmd === 'JustifyRight') + { + align = 'right'; + } + else if (cmd === 'JustifyFull') + { + align = 'justify'; + } + + if (align === false) + { + $(parent).css('text-align', ''); + } + else + { + $(parent).css('text-align', align); + } + } + else + { + this.execRun(cmd, param); + } + } + else if (cmd === 'formatblock' && param === 'blockquote') + { + parent = this.getCurrentNode(); + if ($(parent).get(0).tagName === 'BLOCKQUOTE') + { + if (this.browser('msie')) + { + var node = $('

' + $(parent).html() + '

'); + $(parent).replaceWith(node); + } + else + { + this.execRun(cmd, 'p'); + } + } + else if ($(parent).get(0).tagName === 'P') + { + var parent2 = $(parent).parent(); + if ($(parent2).get(0).tagName === 'BLOCKQUOTE') + { + var node = $('

' + $(parent).html() + '

'); + $(parent2).replaceWith(node); + this.setSelection(node[0], 0, node[0], 0); + } + else + { + if (this.browser('msie')) + { + var node = $('
' + $(parent).html() + '
'); + $(parent).replaceWith(node); + } + else + { + this.execRun(cmd, param); + } + } + } + else + { + this.execRun(cmd, param); + } + } + else if (cmd === 'formatblock' && (param === 'pre' || param === 'p')) + { + parent = this.getParentNode(); + + if ($(parent).get(0).tagName === 'PRE') + { + $(parent).replaceWith('

' + this.encodeEntities($(parent).text()) + '

'); + } + else + { + this.execRun(cmd, param); + } + } + else + { + if (cmd === 'inserthorizontalrule' && this.browser('msie')) + { + this.$editor.focus(); + } + + if (cmd === 'formatblock' && this.browser('mozilla')) + { + this.$editor.focus(); + } + + this.execRun(cmd, param); + } + + if (cmd === 'inserthorizontalrule') + { + this.$editor.find('hr').removeAttr('id'); + } + + this.syncCode(); + + if (this.oldIE()) + { + this.$editor.focus(); + } + + if (typeof this.opts.execCommandCallback === 'function') + { + this.opts.execCommandCallback(this, cmd); + } + + if (this.opts.air) + { + this.air.hide(); + } + } + catch (e) { } + }, + execRun: function(cmd, param) + { + if (cmd === 'formatblock' && this.browser('msie')) + { + param = '<' + param + '>'; + } + + this.document.execCommand(cmd, false, param); + }, + + // FORMAT NEW LINE + formatNewLine: function(e) + { + var parent = this.getParentNode(); + + if (parent.nodeName === 'DIV' && parent.className === 'redactor_editor') + { + var element = $(this.getCurrentNode()); + + if (element.get(0).tagName === 'DIV' && (element.html() === '' || element.html() === '
')) + { + var newElement = $('

').append(element.clone().get(0).childNodes); + element.replaceWith(newElement); + newElement.html('
'); + this.setSelection(newElement[0], 0, newElement[0], 0); + } + } + }, + + // SAFARI SHIFT KEY + ENTER + safariShiftKeyEnter: function(e, key) + { + if (e.shiftKey && key === 13) + { + e.preventDefault(); + this.insertNodeAtCaret($('
').get(0)); + this.syncCode(); + return false; + } + else + { + return true; + } + }, + + // FORMAT EMPTY + formatEmpty: function(e) + { + var html = $.trim(this.$editor.html()); + + if (this.browser('mozilla')) + { + html = html.replace(/
/i, ''); + } + + var thtml = html.replace(/<(?:.|\n)*?>/gm, ''); + + if (html === '' || thtml === '') + { + e.preventDefault(); + + var node = $(this.opts.emptyHtml).get(0); + this.$editor.html(node); + this.setSelection(node, 0, node, 0); + + this.syncCode(); + return false; + } + else + { + this.syncCode(); + } + }, + + // PARAGRAPHY + paragraphy: function (str) + { + str = $.trim(str); + if (str === '' || str === '

') + { + return this.opts.emptyHtml; + } + + // convert div to p + if (this.opts.convertDivs) + { + str = str.replace(/([\w\W]*?)<\/div>/gi, '

$2

'); + } + + // inner functions + var X = function(x, a, b) { return x.replace(new RegExp(a, 'g'), b); }; + var R = function(a, b) { return X(str, a, b); }; + + // block elements + var blocks = '(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])'; + + //str = '

' + str; + str += '\n'; + + R('
\\s*
', '\n\n'); + R('(<' + blocks + '[^>]*>)', '\n$1'); + R('()', '$1\n\n'); + R('\r\n|\r', '\n'); // newlines + R('\n\n+', '\n\n'); // remove duplicates + R('\n?((.|\n)+?)$', '

$1

\n'); // including one at the end + R('

\\s*?

', ''); // remove empty p + R('

(]*>\\s*)', '$1

'); + R('

([^<]+)\\s*?(]*>)', '

$1

$2'); + R('

\\s*(]*>)\\s*

', '$1'); + R('

(', '$1'); + R('

\\s*(]*>)', '$1'); + R('(]*>)\\s*

', '$1'); + R('(]*>)\\s*
', '$1'); + R('
(\\s*]*>)', '$1'); + + // pre + if (str.indexOf(')((.|\n)*?)', function(m0, m1, m2, m3) + { + return X(m1, '\\\\([\'\"\\\\])', '$1') + X(X(X(m3, '

', '\n'), '

|
', ''), '\\\\([\'\"\\\\])', '$1') + ''; + }); + } + + return R('\n

$', '

'); + }, + + // REMOVE TAGS + stripTags: function(html) + { + var allowed = this.opts.allowedTags; + var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi; + return html.replace(tags, function ($0, $1) + { + return $.inArray($1.toLowerCase(), allowed) > '-1' ? $0 : ''; + }); + }, + + + savePreCode: function(html) + { + var pre = html.match(/([\w\W]*?)<\/pre>/gi); + if (pre !== null) + { + $.each(pre, $.proxy(function(i,s) + { + var arr = s.match(/([\w\W]*?)<\/pre>/i); + arr[2] = this.encodeEntities(arr[2]); + html = html.replace(s, '' + arr[2] + ''); + }, this)); + } + + return html; + }, + encodeEntities: function(str) + { + str = String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"'); + return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"'); + }, + cleanupPre: function(s) + { + s = s.replace(/
/gi, '\n'); + s = s.replace(/<\/p>/gi, '\n'); + s = s.replace(/<\/div>/gi, '\n'); + + var tmp = this.document.createElement("div"); + tmp.innerHTML = s; + return tmp.textContent||tmp.innerText; + + }, + + + // PASTE CLEANUP + pasteCleanUp: function(html) + { + var parent = this.getParentNode(); + + // clean up pre + if ($(parent).get(0).tagName === 'PRE') + { + html = this.cleanupPre(html); + this.pasteCleanUpInsert(html); + return true; + } + + // remove comments and php tags + html = html.replace(/|<\?(?:php)?[\s\S]*?\?>/gi, ''); + + // remove nbsp + html = html.replace(/( ){2,}/gi, ' '); + + // remove google docs marker + html = html.replace(/([\w\W]*?)<\/b>/gi, "$2"); + + // strip tags + html = this.stripTags(html); + + // prevert + html = html.replace(/<\/td>/gi, '[td]'); + html = html.replace(/ <\/td>/gi, '[td]'); + html = html.replace(/
<\/td>/gi, '[td]'); + html = html.replace(/([\w\W]*?)<\/a>/gi, '[a href="$2"]$4[/a]'); + html = html.replace(/([\w\W]*?)<\/iframe>/gi, '[iframe$1]$2[/iframe]'); + html = html.replace(/([\w\W]*?)<\/video>/gi, '[video$1]$2[/video]'); + html = html.replace(/([\w\W]*?)<\/audio>/gi, '[audio$1]$2[/audio]'); + html = html.replace(/([\w\W]*?)<\/embed>/gi, '[embed$1]$2[/embed]'); + html = html.replace(/([\w\W]*?)<\/object>/gi, '[object$1]$2[/object]'); + html = html.replace(//gi, '[param$1]'); + html = html.replace(//gi, '[img$1$3]'); + + // remove attributes + html = html.replace(/<(\w+)([\w\W]*?)>/gi, '<$1>'); + + // remove empty + html = html.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |
)<\/[^>]+>/gi, ''); + html = html.replace(/<[^\/>][^>]*>(\s*|\t*|\n*| |
)<\/[^>]+>/gi, ''); + + // revert + html = html.replace(/\[td\]/gi, ' '); + html = html.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi, '$2'); + html = html.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi, '$2'); + html = html.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi, '$2'); + html = html.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi, '$2'); + html = html.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi, '$2'); + html = html.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi, '$2'); + html = html.replace(/\[param(.*?)\]/gi, ''); + html = html.replace(/\[img(.*?)\]/gi, ''); + + + // convert div to p + if (this.opts.convertDivs) + { + html = html.replace(/([\w\W]*?)<\/div>/gi, '

$2

'); + } + + // remove span + html = html.replace(/([\w\W]*?)<\/span>/gi, '$1'); + + html = html.replace(/\n{3,}/gi, '\n'); + + // remove dirty p + html = html.replace(/

/gi, '

'); + html = html.replace(/<\/p><\/p>/gi, '

'); + + // FF fix + if (this.browser('mozilla')) + { + html = html.replace(/
$/gi, ''); + } + + this.pasteCleanUpInsert(html); + + }, + + pasteCleanUpInsert: function(html) + { + this.execCommand('inserthtml', html); + + if (this.opts.autoresize === true) + { + $(this.document.body).scrollTop(this.saveScroll); + } + else + { + this.$editor.scrollTop(this.saveScroll); + } + }, + + + // TEXTAREA CODE FORMATTING + formattingRemove: function(html) + { + // save pre + var prebuffer = []; + var pre = html.match(/([\w\W]*?)<\/pre>/gi); + if (pre !== null) + { + $.each(pre, function(i,s) + { + html = html.replace(s, 'prebuffer_' + i); + prebuffer.push(s); + }); + } + + html = html.replace(/\s{2,}/g, ' '); + html = html.replace(/\n/g, ' '); + html = html.replace(/[\t]*/g, ''); + html = html.replace(/\n\s*\n/g, "\n"); + html = html.replace(/^[\s\n]*/g, ''); + html = html.replace(/[\s\n]*$/g, ''); + html = html.replace(/>\s+<'); + + if (prebuffer) + { + $.each(prebuffer, function(i,s) + { + html = html.replace('prebuffer_' + i, s); + }); + + prebuffer = []; + } + + return html; + }, + formattingIndenting: function(html) + { + html = html.replace(/
  • /g, "\t"); + + return html; + }, + formattingEmptyTags: function(html) + { + var etags = ["
    ","
    \\s*
    ","\\s*","
      ","
        ","
      1. ","
        ","","\\s*", " ", "\\s*", " ", "

        \\s*

        ", "

         

        ", "

        \\s*
        \\s*

        ", "
        \\s*
        ", "
        \\s*
        \\s*
        "]; + for (var i = 0; i < etags.length; ++i) + { + var bbb = etags[i]; + html = html.replace(new RegExp(bbb,'gi'), ""); + } + + return html; + }, + formattingAddBefore: function(html) + { + var lb = '\r\n'; + var btags = ["", '', "","', '', '', '', '', '', '', '', '
        ', '
        ', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']; + for (var i = 0; i < atags.length; ++i) + { + var aaa = atags[i]; + html = html.replace(new RegExp(aaa,'gi'),aaa+lb); + } + + return html; + }, + formatting: function(html) + { + html = this.formattingRemove(html); + + // empty tags + html = this.formattingEmptyTags(html); + + // add formatting before + html = this.formattingAddBefore(html); + + // add formatting after + html = this.formattingAddAfter(html); + + // indenting + html = this.formattingIndenting(html); + + return html; + }, + + // TOGGLE + toggle: function() + { + var html; + + if (this.opts.visual) + { + var height = this.$editor.innerHeight(); + + this.$editor.hide(); + this.$content.hide(); + + html = this.$editor.html(); + //html = $.trim(this.formatting(html)); + + this.$el.height(height).val(html).show().focus(); + + this.setBtnActive('html'); + this.opts.visual = false; + } + else + { + this.$el.hide(); + var html = this.$el.val(); + + //html = this.savePreCode(html); + + // clean up + //html = this.stripTags(html); + + // set code + this.$editor.html(html).show(); + this.$content.show(); + + if (this.$editor.html() === '') + { + this.setCode(this.opts.emptyHtml); + } + + this.$editor.focus(); + + this.setBtnInactive('html'); + this.opts.visual = true; + + this.observeImages(); + this.observeTables(); + } + }, + + // AUTOSAVE + autoSave: function() + { + this.autosaveInterval = setInterval($.proxy(function() + { + $.ajax({ + url: this.opts.autosave, + type: 'post', + data: this.$el.attr('name') + '=' + escape(encodeURIComponent(this.getCode())), + success: $.proxy(function(data) + { + // callback + if (typeof this.opts.autosaveCallback === 'function') + { + this.opts.autosaveCallback(data, this); + } + + }, this) + }); + + + }, this), this.opts.interval*1000); + }, + + // TOOLBAR + buildToolbar: function() + { + if (this.opts.toolbar === false) + { + return false; + } + + this.$toolbar = $('