markitup-rails 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.ruby-version +1 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +20 -0
- data/README.md +199 -0
- data/Rakefile +12 -0
- data/app/controllers/markitup/rails/preview_controller.rb +13 -0
- data/app/views/layouts/markitup.html.erb +16 -0
- data/app/views/markitup/rails/preview/preview.html.erb +2 -0
- data/config/routes.rb +3 -0
- data/lib/markitup/rails/configuration.rb +22 -0
- data/lib/markitup/rails/engine.rb +15 -0
- data/lib/markitup/rails/version.rb +5 -0
- data/markitup-rails.gemspec +24 -0
- data/test/configuration_test.rb +52 -0
- data/test/controllers/markitup/rails/preview_controller_test.rb +12 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +68 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/markitup_rails.rb +1 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +11 -0
- data/test/dummy/db/schema.rb +16 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/markitup-rails_test.rb +7 -0
- data/test/minitest_helper.rb +24 -0
- data/vendor/assets/images/markitup/sets/bbcode/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/clean.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/code.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/fonts.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/link.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/list-item.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/bbcode/underline.png +0 -0
- data/vendor/assets/images/markitup/sets/css/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/css/css.png +0 -0
- data/vendor/assets/images/markitup/sets/css/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/css/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/css/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/css/tag.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_align_center.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_align_justify.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_align_left.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_align_right.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_indent.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_letterspacing.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_linespacing.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_lowercase.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_padding_bottom.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_padding_left.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_padding_right.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_padding_top.png +0 -0
- data/vendor/assets/images/markitup/sets/css/text_uppercase.png +0 -0
- data/vendor/assets/images/markitup/sets/default/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/default/clean.png +0 -0
- data/vendor/assets/images/markitup/sets/default/image.png +0 -0
- data/vendor/assets/images/markitup/sets/default/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/default/link.png +0 -0
- data/vendor/assets/images/markitup/sets/default/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/default/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/default/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/default/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/default/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/code.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/link.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/dotclear/url.png +0 -0
- data/vendor/assets/images/markitup/sets/html/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/html/clean.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/html/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/html/image.png +0 -0
- data/vendor/assets/images/markitup/sets/html/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/html/link.png +0 -0
- data/vendor/assets/images/markitup/sets/html/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/html/list-item.png +0 -0
- data/vendor/assets/images/markitup/sets/html/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/html/paragraph.png +0 -0
- data/vendor/assets/images/markitup/sets/html/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/html/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/html/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/code.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/link.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/markdown/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/code.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/link.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/markmin/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/code.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/link.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/rest/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/code.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/link.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/paragraph.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/textile/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/code.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/disconnect.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/link.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/page_white_code.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/texy/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/code.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/disconnect.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/link.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/txt2tags/underline.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/code.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/link.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/quotes.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/stroke.png +0 -0
- data/vendor/assets/images/markitup/sets/wiki/url.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/bold.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/clean.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h1.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h2.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h3.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h4.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h5.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/h6.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/image.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/italic.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/link.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/list-bullet.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/list-item.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/list-numeric.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/paragraph.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/picture.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/preview.png +0 -0
- data/vendor/assets/images/markitup/sets/xbbcode/stroke.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-container.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-bbcode.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-dotclear.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-html.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-json.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-markdown.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-textile.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-wiki.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor-xml.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/bg-editor.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/handle.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/menu.png +0 -0
- data/vendor/assets/images/markitup/skins/markitup/submenu.png +0 -0
- data/vendor/assets/images/markitup/skins/simple/handle.png +0 -0
- data/vendor/assets/images/markitup/skins/simple/menu.png +0 -0
- data/vendor/assets/images/markitup/skins/simple/submenu.png +0 -0
- data/vendor/assets/javascripts/markitup.js +634 -0
- data/vendor/assets/javascripts/markitup/sets/bbcode/set.js +39 -0
- data/vendor/assets/javascripts/markitup/sets/css/set.js +52 -0
- data/vendor/assets/javascripts/markitup/sets/default/set.js +30 -0
- data/vendor/assets/javascripts/markitup/sets/dotclear/set.js +37 -0
- data/vendor/assets/javascripts/markitup/sets/html/set.js +39 -0
- data/vendor/assets/javascripts/markitup/sets/markdown/set.js +52 -0
- data/vendor/assets/javascripts/markitup/sets/markmin/set.js +49 -0
- data/vendor/assets/javascripts/markitup/sets/rest/set.js +51 -0
- data/vendor/assets/javascripts/markitup/sets/textile/set.js +40 -0
- data/vendor/assets/javascripts/markitup/sets/texy/set.js +51 -0
- data/vendor/assets/javascripts/markitup/sets/txt2tags/set.js +41 -0
- data/vendor/assets/javascripts/markitup/sets/wiki/set.js +37 -0
- data/vendor/assets/javascripts/markitup/sets/xbbcode/set.js +36 -0
- data/vendor/assets/stylesheets/markitup/sets/bbcode/style.scss +47 -0
- data/vendor/assets/stylesheets/markitup/sets/css/style.scss +72 -0
- data/vendor/assets/stylesheets/markitup/sets/default/style.scss +34 -0
- data/vendor/assets/stylesheets/markitup/sets/dotclear/style.scss +54 -0
- data/vendor/assets/stylesheets/markitup/sets/html/style.scss +59 -0
- data/vendor/assets/stylesheets/markitup/sets/markdown/style.scss +54 -0
- data/vendor/assets/stylesheets/markitup/sets/markmin/style.scss +54 -0
- data/vendor/assets/stylesheets/markitup/sets/rest/style.scss +53 -0
- data/vendor/assets/stylesheets/markitup/sets/textile/style.scss +60 -0
- data/vendor/assets/stylesheets/markitup/sets/texy/style.scss +51 -0
- data/vendor/assets/stylesheets/markitup/sets/txt2tags/style.scss +62 -0
- data/vendor/assets/stylesheets/markitup/sets/wiki/style.scss +57 -0
- data/vendor/assets/stylesheets/markitup/sets/xbbcode/style.scss +59 -0
- data/vendor/assets/stylesheets/markitup/skins/markitup/style.scss +147 -0
- data/vendor/assets/stylesheets/markitup/skins/simple/style.css +118 -0
- metadata +308 -2
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,634 @@
|
|
1
|
+
// ----------------------------------------------------------------------------
|
2
|
+
// markItUp! Universal MarkUp Engine, JQuery plugin
|
3
|
+
// v 1.1.x
|
4
|
+
// Dual licensed under the MIT and GPL licenses.
|
5
|
+
// ----------------------------------------------------------------------------
|
6
|
+
// Copyright (C) 2007-2012 Jay Salvat
|
7
|
+
// http://markitup.jaysalvat.com/
|
8
|
+
// ----------------------------------------------------------------------------
|
9
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
|
+
// of this software and associated documentation files (the "Software"), to deal
|
11
|
+
// in the Software without restriction, including without limitation the rights
|
12
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
13
|
+
// copies of the Software, and to permit persons to whom the Software is
|
14
|
+
// furnished to do so, subject to the following conditions:
|
15
|
+
//
|
16
|
+
// The above copyright notice and this permission notice shall be included in
|
17
|
+
// all copies or substantial portions of the Software.
|
18
|
+
//
|
19
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
21
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
22
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
23
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
24
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
|
+
// THE SOFTWARE.
|
26
|
+
// ----------------------------------------------------------------------------
|
27
|
+
(function($) {
|
28
|
+
$.fn.markItUp = function(settings, extraSettings) {
|
29
|
+
var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false;
|
30
|
+
|
31
|
+
if (typeof settings == 'string') {
|
32
|
+
method = settings;
|
33
|
+
params = extraSettings;
|
34
|
+
}
|
35
|
+
|
36
|
+
options = { id: '',
|
37
|
+
nameSpace: '',
|
38
|
+
root: '',
|
39
|
+
previewHandler: false,
|
40
|
+
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
|
41
|
+
previewInElement: '',
|
42
|
+
previewAutoRefresh: true,
|
43
|
+
previewPosition: 'after',
|
44
|
+
previewTemplatePath: '~/templates/preview.html',
|
45
|
+
previewParser: false,
|
46
|
+
previewParserPath: '',
|
47
|
+
previewParserVar: 'data',
|
48
|
+
resizeHandle: true,
|
49
|
+
beforeInsert: '',
|
50
|
+
afterInsert: '',
|
51
|
+
onEnter: {},
|
52
|
+
onShiftEnter: {},
|
53
|
+
onCtrlEnter: {},
|
54
|
+
onTab: {},
|
55
|
+
markupSet: [ { /* set */ } ]
|
56
|
+
};
|
57
|
+
$.extend(options, settings, extraSettings);
|
58
|
+
|
59
|
+
// compute markItUp! path
|
60
|
+
if (!options.root) {
|
61
|
+
$('script').each(function(a, tag) {
|
62
|
+
miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
|
63
|
+
if (miuScript !== null) {
|
64
|
+
options.root = miuScript[1];
|
65
|
+
}
|
66
|
+
});
|
67
|
+
}
|
68
|
+
|
69
|
+
return this.each(function() {
|
70
|
+
var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
|
71
|
+
clicked, hash, header, footer, previewWindow, template, iFrame, abort;
|
72
|
+
$$ = $(this);
|
73
|
+
textarea = this;
|
74
|
+
levels = [];
|
75
|
+
abort = false;
|
76
|
+
scrollPosition = caretPosition = 0;
|
77
|
+
caretOffset = -1;
|
78
|
+
|
79
|
+
options.previewParserPath = localize(options.previewParserPath);
|
80
|
+
options.previewTemplatePath = localize(options.previewTemplatePath);
|
81
|
+
|
82
|
+
if (method) {
|
83
|
+
switch(method) {
|
84
|
+
case 'remove':
|
85
|
+
remove();
|
86
|
+
break;
|
87
|
+
case 'insert':
|
88
|
+
markup(params);
|
89
|
+
break;
|
90
|
+
default:
|
91
|
+
$.error('Method ' + method + ' does not exist on jQuery.markItUp');
|
92
|
+
}
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
// apply the computed path to ~/
|
97
|
+
function localize(data, inText) {
|
98
|
+
if (inText) {
|
99
|
+
return data.replace(/("|')~\//g, "$1"+options.root);
|
100
|
+
}
|
101
|
+
return data.replace(/^~\//, options.root);
|
102
|
+
}
|
103
|
+
|
104
|
+
// init and build editor
|
105
|
+
function init() {
|
106
|
+
id = ''; nameSpace = '';
|
107
|
+
if (options.id) {
|
108
|
+
id = 'id="'+options.id+'"';
|
109
|
+
} else if ($$.attr("id")) {
|
110
|
+
id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
|
111
|
+
|
112
|
+
}
|
113
|
+
if (options.nameSpace) {
|
114
|
+
nameSpace = 'class="'+options.nameSpace+'"';
|
115
|
+
}
|
116
|
+
$$.wrap('<div '+nameSpace+'></div>');
|
117
|
+
$$.wrap('<div '+id+' class="markItUp"></div>');
|
118
|
+
$$.wrap('<div class="markItUpContainer"></div>');
|
119
|
+
$$.addClass("markItUpEditor");
|
120
|
+
|
121
|
+
// add the header before the textarea
|
122
|
+
header = $('<div class="markItUpHeader"></div>').insertBefore($$);
|
123
|
+
$(dropMenus(options.markupSet)).appendTo(header);
|
124
|
+
|
125
|
+
// add the footer after the textarea
|
126
|
+
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
|
127
|
+
|
128
|
+
// add the resize handle after textarea
|
129
|
+
if (options.resizeHandle === true && $.browser.safari !== true) {
|
130
|
+
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
|
131
|
+
.insertAfter($$)
|
132
|
+
.bind("mousedown.markItUp", function(e) {
|
133
|
+
var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
|
134
|
+
mouseMove = function(e) {
|
135
|
+
$$.css("height", Math.max(20, e.clientY+h-y)+"px");
|
136
|
+
return false;
|
137
|
+
};
|
138
|
+
mouseUp = function(e) {
|
139
|
+
$("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp);
|
140
|
+
return false;
|
141
|
+
};
|
142
|
+
$("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp);
|
143
|
+
});
|
144
|
+
footer.append(resizeHandle);
|
145
|
+
}
|
146
|
+
|
147
|
+
// listen key events
|
148
|
+
$$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed);
|
149
|
+
|
150
|
+
// bind an event to catch external calls
|
151
|
+
$$.bind("insertion.markItUp", function(e, settings) {
|
152
|
+
if (settings.target !== false) {
|
153
|
+
get();
|
154
|
+
}
|
155
|
+
if (textarea === $.markItUp.focused) {
|
156
|
+
markup(settings);
|
157
|
+
}
|
158
|
+
});
|
159
|
+
|
160
|
+
// remember the last focus
|
161
|
+
$$.bind('focus.markItUp', function() {
|
162
|
+
$.markItUp.focused = this;
|
163
|
+
});
|
164
|
+
|
165
|
+
if (options.previewInElement) {
|
166
|
+
refreshPreview();
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
// recursively build header with dropMenus from markupset
|
171
|
+
function dropMenus(markupSet) {
|
172
|
+
var ul = $('<ul></ul>'), i = 0;
|
173
|
+
$('li:hover > ul', ul).css('display', 'block');
|
174
|
+
$.each(markupSet, function() {
|
175
|
+
var button = this, t = '', title, li, j;
|
176
|
+
title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||'');
|
177
|
+
key = (button.key) ? 'accesskey="'+button.key+'"' : '';
|
178
|
+
if (button.separator) {
|
179
|
+
li = $('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);
|
180
|
+
} else {
|
181
|
+
i++;
|
182
|
+
for (j = levels.length -1; j >= 0; j--) {
|
183
|
+
t += levels[j]+"-";
|
184
|
+
}
|
185
|
+
li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
|
186
|
+
.bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click
|
187
|
+
return false;
|
188
|
+
}).bind('click.markItUp', function() {
|
189
|
+
return false;
|
190
|
+
}).bind("focusin.markItUp", function(){
|
191
|
+
$$.focus();
|
192
|
+
}).bind('mouseup', function() {
|
193
|
+
if (button.call) {
|
194
|
+
eval(button.call)();
|
195
|
+
}
|
196
|
+
setTimeout(function() { markup(button) },1);
|
197
|
+
return false;
|
198
|
+
}).bind('mouseenter.markItUp', function() {
|
199
|
+
$('> ul', this).show();
|
200
|
+
$(document).one('click', function() { // close dropmenu if click outside
|
201
|
+
$('ul ul', header).hide();
|
202
|
+
}
|
203
|
+
);
|
204
|
+
}).bind('mouseleave.markItUp', function() {
|
205
|
+
$('> ul', this).hide();
|
206
|
+
}).appendTo(ul);
|
207
|
+
if (button.dropMenu) {
|
208
|
+
levels.push(i);
|
209
|
+
$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
|
210
|
+
}
|
211
|
+
}
|
212
|
+
});
|
213
|
+
levels.pop();
|
214
|
+
return ul;
|
215
|
+
}
|
216
|
+
|
217
|
+
// markItUp! markups
|
218
|
+
function magicMarkups(string) {
|
219
|
+
if (string) {
|
220
|
+
string = string.toString();
|
221
|
+
string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
|
222
|
+
function(x, a) {
|
223
|
+
var b = a.split('|!|');
|
224
|
+
if (altKey === true) {
|
225
|
+
return (b[1] !== undefined) ? b[1] : b[0];
|
226
|
+
} else {
|
227
|
+
return (b[1] === undefined) ? "" : b[0];
|
228
|
+
}
|
229
|
+
}
|
230
|
+
);
|
231
|
+
// [![prompt]!], [![prompt:!:value]!]
|
232
|
+
string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,
|
233
|
+
function(x, a) {
|
234
|
+
var b = a.split(':!:');
|
235
|
+
if (abort === true) {
|
236
|
+
return false;
|
237
|
+
}
|
238
|
+
value = prompt(b[0], (b[1]) ? b[1] : '');
|
239
|
+
if (value === null) {
|
240
|
+
abort = true;
|
241
|
+
}
|
242
|
+
return value;
|
243
|
+
}
|
244
|
+
);
|
245
|
+
return string;
|
246
|
+
}
|
247
|
+
return "";
|
248
|
+
}
|
249
|
+
|
250
|
+
// prepare action
|
251
|
+
function prepare(action) {
|
252
|
+
if ($.isFunction(action)) {
|
253
|
+
action = action(hash);
|
254
|
+
}
|
255
|
+
return magicMarkups(action);
|
256
|
+
}
|
257
|
+
|
258
|
+
// build block to insert
|
259
|
+
function build(string) {
|
260
|
+
var openWith = prepare(clicked.openWith);
|
261
|
+
var placeHolder = prepare(clicked.placeHolder);
|
262
|
+
var replaceWith = prepare(clicked.replaceWith);
|
263
|
+
var closeWith = prepare(clicked.closeWith);
|
264
|
+
var openBlockWith = prepare(clicked.openBlockWith);
|
265
|
+
var closeBlockWith = prepare(clicked.closeBlockWith);
|
266
|
+
var multiline = clicked.multiline;
|
267
|
+
|
268
|
+
if (replaceWith !== "") {
|
269
|
+
block = openWith + replaceWith + closeWith;
|
270
|
+
} else if (selection === '' && placeHolder !== '') {
|
271
|
+
block = openWith + placeHolder + closeWith;
|
272
|
+
} else {
|
273
|
+
string = string || selection;
|
274
|
+
|
275
|
+
var lines = [string], blocks = [];
|
276
|
+
|
277
|
+
if (multiline === true) {
|
278
|
+
lines = string.split(/\r?\n/);
|
279
|
+
}
|
280
|
+
|
281
|
+
for (var l = 0; l < lines.length; l++) {
|
282
|
+
line = lines[l];
|
283
|
+
var trailingSpaces;
|
284
|
+
if (trailingSpaces = line.match(/ *$/)) {
|
285
|
+
blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces);
|
286
|
+
} else {
|
287
|
+
blocks.push(openWith + line + closeWith);
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
block = blocks.join("\n");
|
292
|
+
}
|
293
|
+
|
294
|
+
block = openBlockWith + block + closeBlockWith;
|
295
|
+
|
296
|
+
return { block:block,
|
297
|
+
openWith:openWith,
|
298
|
+
replaceWith:replaceWith,
|
299
|
+
placeHolder:placeHolder,
|
300
|
+
closeWith:closeWith
|
301
|
+
};
|
302
|
+
}
|
303
|
+
|
304
|
+
// define markup to insert
|
305
|
+
function markup(button) {
|
306
|
+
var len, j, n, i;
|
307
|
+
hash = clicked = button;
|
308
|
+
get();
|
309
|
+
$.extend(hash, { line:"",
|
310
|
+
root:options.root,
|
311
|
+
textarea:textarea,
|
312
|
+
selection:(selection||''),
|
313
|
+
caretPosition:caretPosition,
|
314
|
+
ctrlKey:ctrlKey,
|
315
|
+
shiftKey:shiftKey,
|
316
|
+
altKey:altKey
|
317
|
+
}
|
318
|
+
);
|
319
|
+
// callbacks before insertion
|
320
|
+
prepare(options.beforeInsert);
|
321
|
+
prepare(clicked.beforeInsert);
|
322
|
+
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
323
|
+
prepare(clicked.beforeMultiInsert);
|
324
|
+
}
|
325
|
+
$.extend(hash, { line:1 });
|
326
|
+
|
327
|
+
if ((ctrlKey === true && shiftKey === true)) {
|
328
|
+
lines = selection.split(/\r?\n/);
|
329
|
+
for (j = 0, n = lines.length, i = 0; i < n; i++) {
|
330
|
+
if ($.trim(lines[i]) !== '') {
|
331
|
+
$.extend(hash, { line:++j, selection:lines[i] } );
|
332
|
+
lines[i] = build(lines[i]).block;
|
333
|
+
} else {
|
334
|
+
lines[i] = "";
|
335
|
+
}
|
336
|
+
}
|
337
|
+
|
338
|
+
string = { block:lines.join('\n')};
|
339
|
+
start = caretPosition;
|
340
|
+
len = string.block.length + (($.browser.opera) ? n-1 : 0);
|
341
|
+
} else if (ctrlKey === true) {
|
342
|
+
string = build(selection);
|
343
|
+
start = caretPosition + string.openWith.length;
|
344
|
+
len = string.block.length - string.openWith.length - string.closeWith.length;
|
345
|
+
len = len - (string.block.match(/ $/) ? 1 : 0);
|
346
|
+
len -= fixIeBug(string.block);
|
347
|
+
} else if (shiftKey === true) {
|
348
|
+
string = build(selection);
|
349
|
+
start = caretPosition;
|
350
|
+
len = string.block.length;
|
351
|
+
len -= fixIeBug(string.block);
|
352
|
+
} else {
|
353
|
+
string = build(selection);
|
354
|
+
start = caretPosition + string.block.length ;
|
355
|
+
len = 0;
|
356
|
+
start -= fixIeBug(string.block);
|
357
|
+
}
|
358
|
+
if ((selection === '' && string.replaceWith === '')) {
|
359
|
+
caretOffset += fixOperaBug(string.block);
|
360
|
+
|
361
|
+
start = caretPosition + string.openWith.length;
|
362
|
+
len = string.block.length - string.openWith.length - string.closeWith.length;
|
363
|
+
|
364
|
+
caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
|
365
|
+
caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
|
366
|
+
}
|
367
|
+
$.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
|
368
|
+
|
369
|
+
if (string.block !== selection && abort === false) {
|
370
|
+
insert(string.block);
|
371
|
+
set(start, len);
|
372
|
+
} else {
|
373
|
+
caretOffset = -1;
|
374
|
+
}
|
375
|
+
get();
|
376
|
+
|
377
|
+
$.extend(hash, { line:'', selection:selection });
|
378
|
+
|
379
|
+
// callbacks after insertion
|
380
|
+
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
381
|
+
prepare(clicked.afterMultiInsert);
|
382
|
+
}
|
383
|
+
prepare(clicked.afterInsert);
|
384
|
+
prepare(options.afterInsert);
|
385
|
+
|
386
|
+
// refresh preview if opened
|
387
|
+
if (previewWindow && options.previewAutoRefresh) {
|
388
|
+
refreshPreview();
|
389
|
+
}
|
390
|
+
|
391
|
+
// reinit keyevent
|
392
|
+
shiftKey = altKey = ctrlKey = abort = false;
|
393
|
+
}
|
394
|
+
|
395
|
+
// Substract linefeed in Opera
|
396
|
+
function fixOperaBug(string) {
|
397
|
+
if ($.browser.opera) {
|
398
|
+
return string.length - string.replace(/\n*/g, '').length;
|
399
|
+
}
|
400
|
+
return 0;
|
401
|
+
}
|
402
|
+
// Substract linefeed in IE
|
403
|
+
function fixIeBug(string) {
|
404
|
+
if ($.browser.msie) {
|
405
|
+
return string.length - string.replace(/\r*/g, '').length;
|
406
|
+
}
|
407
|
+
return 0;
|
408
|
+
}
|
409
|
+
|
410
|
+
// add markup
|
411
|
+
function insert(block) {
|
412
|
+
if (document.selection) {
|
413
|
+
var newSelection = document.selection.createRange();
|
414
|
+
newSelection.text = block;
|
415
|
+
} else {
|
416
|
+
textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length);
|
417
|
+
}
|
418
|
+
}
|
419
|
+
|
420
|
+
// set a selection
|
421
|
+
function set(start, len) {
|
422
|
+
if (textarea.createTextRange){
|
423
|
+
// quick fix to make it work on Opera 9.5
|
424
|
+
if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
|
425
|
+
return false;
|
426
|
+
}
|
427
|
+
range = textarea.createTextRange();
|
428
|
+
range.collapse(true);
|
429
|
+
range.moveStart('character', start);
|
430
|
+
range.moveEnd('character', len);
|
431
|
+
range.select();
|
432
|
+
} else if (textarea.setSelectionRange ){
|
433
|
+
textarea.setSelectionRange(start, start + len);
|
434
|
+
}
|
435
|
+
textarea.scrollTop = scrollPosition;
|
436
|
+
textarea.focus();
|
437
|
+
}
|
438
|
+
|
439
|
+
// get the selection
|
440
|
+
function get() {
|
441
|
+
textarea.focus();
|
442
|
+
|
443
|
+
scrollPosition = textarea.scrollTop;
|
444
|
+
if (document.selection) {
|
445
|
+
selection = document.selection.createRange().text;
|
446
|
+
if ($.browser.msie) { // ie
|
447
|
+
var range = document.selection.createRange(), rangeCopy = range.duplicate();
|
448
|
+
rangeCopy.moveToElementText(textarea);
|
449
|
+
caretPosition = -1;
|
450
|
+
while(rangeCopy.inRange(range)) {
|
451
|
+
rangeCopy.moveStart('character');
|
452
|
+
caretPosition ++;
|
453
|
+
}
|
454
|
+
} else { // opera
|
455
|
+
caretPosition = textarea.selectionStart;
|
456
|
+
}
|
457
|
+
} else { // gecko & webkit
|
458
|
+
caretPosition = textarea.selectionStart;
|
459
|
+
|
460
|
+
selection = textarea.value.substring(caretPosition, textarea.selectionEnd);
|
461
|
+
}
|
462
|
+
return selection;
|
463
|
+
}
|
464
|
+
|
465
|
+
// open preview window
|
466
|
+
function preview() {
|
467
|
+
if (typeof options.previewHandler === 'function') {
|
468
|
+
previewWindow = true;
|
469
|
+
} else if (options.previewInElement) {
|
470
|
+
previewWindow = $(options.previewInElement);
|
471
|
+
} else if (!previewWindow || previewWindow.closed) {
|
472
|
+
if (options.previewInWindow) {
|
473
|
+
previewWindow = window.open('', 'preview', options.previewInWindow);
|
474
|
+
$(window).unload(function() {
|
475
|
+
previewWindow.close();
|
476
|
+
});
|
477
|
+
} else {
|
478
|
+
iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
|
479
|
+
if (options.previewPosition == 'after') {
|
480
|
+
iFrame.insertAfter(footer);
|
481
|
+
} else {
|
482
|
+
iFrame.insertBefore(header);
|
483
|
+
}
|
484
|
+
previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
|
485
|
+
}
|
486
|
+
} else if (altKey === true) {
|
487
|
+
if (iFrame) {
|
488
|
+
iFrame.remove();
|
489
|
+
} else {
|
490
|
+
previewWindow.close();
|
491
|
+
}
|
492
|
+
previewWindow = iFrame = false;
|
493
|
+
}
|
494
|
+
if (!options.previewAutoRefresh) {
|
495
|
+
refreshPreview();
|
496
|
+
}
|
497
|
+
if (options.previewInWindow) {
|
498
|
+
previewWindow.focus();
|
499
|
+
}
|
500
|
+
}
|
501
|
+
|
502
|
+
// refresh Preview window
|
503
|
+
function refreshPreview() {
|
504
|
+
renderPreview();
|
505
|
+
}
|
506
|
+
|
507
|
+
function renderPreview() {
|
508
|
+
var phtml;
|
509
|
+
if (options.previewHandler && typeof options.previewHandler === 'function') {
|
510
|
+
options.previewHandler( $$.val() );
|
511
|
+
} else if (options.previewParser && typeof options.previewParser === 'function') {
|
512
|
+
var data = options.previewParser( $$.val() );
|
513
|
+
writeInPreview(localize(data, 1) );
|
514
|
+
} else if (options.previewParserPath !== '') {
|
515
|
+
$.ajax({
|
516
|
+
type: 'POST',
|
517
|
+
dataType: 'text',
|
518
|
+
global: false,
|
519
|
+
url: options.previewParserPath,
|
520
|
+
data: options.previewParserVar+'='+encodeURIComponent($$.val()),
|
521
|
+
success: function(data) {
|
522
|
+
writeInPreview( localize(data, 1) );
|
523
|
+
}
|
524
|
+
});
|
525
|
+
} else {
|
526
|
+
if (!template) {
|
527
|
+
$.ajax({
|
528
|
+
url: options.previewTemplatePath,
|
529
|
+
dataType: 'text',
|
530
|
+
global: false,
|
531
|
+
success: function(data) {
|
532
|
+
writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
|
533
|
+
}
|
534
|
+
});
|
535
|
+
}
|
536
|
+
}
|
537
|
+
return false;
|
538
|
+
}
|
539
|
+
|
540
|
+
function writeInPreview(data) {
|
541
|
+
if (options.previewInElement) {
|
542
|
+
$(options.previewInElement).html(data);
|
543
|
+
} else if (previewWindow && previewWindow.document) {
|
544
|
+
try {
|
545
|
+
sp = previewWindow.document.documentElement.scrollTop
|
546
|
+
} catch(e) {
|
547
|
+
sp = 0;
|
548
|
+
}
|
549
|
+
previewWindow.document.open();
|
550
|
+
previewWindow.document.write(data);
|
551
|
+
previewWindow.document.close();
|
552
|
+
previewWindow.document.documentElement.scrollTop = sp;
|
553
|
+
}
|
554
|
+
}
|
555
|
+
|
556
|
+
// set keys pressed
|
557
|
+
function keyPressed(e) {
|
558
|
+
shiftKey = e.shiftKey;
|
559
|
+
altKey = e.altKey;
|
560
|
+
ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false;
|
561
|
+
|
562
|
+
if (e.type === 'keydown') {
|
563
|
+
if (ctrlKey === true) {
|
564
|
+
li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li');
|
565
|
+
if (li.length !== 0) {
|
566
|
+
ctrlKey = false;
|
567
|
+
setTimeout(function() {
|
568
|
+
li.triggerHandler('mouseup');
|
569
|
+
},1);
|
570
|
+
return false;
|
571
|
+
}
|
572
|
+
}
|
573
|
+
if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
|
574
|
+
if (ctrlKey === true) { // Enter + Ctrl
|
575
|
+
ctrlKey = false;
|
576
|
+
markup(options.onCtrlEnter);
|
577
|
+
return options.onCtrlEnter.keepDefault;
|
578
|
+
} else if (shiftKey === true) { // Enter + Shift
|
579
|
+
shiftKey = false;
|
580
|
+
markup(options.onShiftEnter);
|
581
|
+
return options.onShiftEnter.keepDefault;
|
582
|
+
} else { // only Enter
|
583
|
+
markup(options.onEnter);
|
584
|
+
return options.onEnter.keepDefault;
|
585
|
+
}
|
586
|
+
}
|
587
|
+
if (e.keyCode === 9) { // Tab key
|
588
|
+
if (shiftKey == true || ctrlKey == true || altKey == true) {
|
589
|
+
return false;
|
590
|
+
}
|
591
|
+
if (caretOffset !== -1) {
|
592
|
+
get();
|
593
|
+
caretOffset = $$.val().length - caretOffset;
|
594
|
+
set(caretOffset, 0);
|
595
|
+
caretOffset = -1;
|
596
|
+
return false;
|
597
|
+
} else {
|
598
|
+
markup(options.onTab);
|
599
|
+
return options.onTab.keepDefault;
|
600
|
+
}
|
601
|
+
}
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
function remove() {
|
606
|
+
$$.unbind(".markItUp").removeClass('markItUpEditor');
|
607
|
+
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
|
608
|
+
$$.data('markItUp', null);
|
609
|
+
}
|
610
|
+
|
611
|
+
init();
|
612
|
+
});
|
613
|
+
};
|
614
|
+
|
615
|
+
$.fn.markItUpRemove = function() {
|
616
|
+
return this.each(function() {
|
617
|
+
$(this).markItUp('remove');
|
618
|
+
}
|
619
|
+
);
|
620
|
+
};
|
621
|
+
|
622
|
+
$.markItUp = function(settings) {
|
623
|
+
var options = { target:false };
|
624
|
+
$.extend(options, settings);
|
625
|
+
if (options.target) {
|
626
|
+
return $(options.target).each(function() {
|
627
|
+
$(this).focus();
|
628
|
+
$(this).trigger('insertion', [options]);
|
629
|
+
});
|
630
|
+
} else {
|
631
|
+
$('textarea').trigger('insertion', [options]);
|
632
|
+
}
|
633
|
+
};
|
634
|
+
})(jQuery);
|