bootstrap-wysihtml5-rails-font-awesome 0.3.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.rvmrc +60 -0
  4. data/CONTRIBUTING.md +5 -0
  5. data/Gemfile +4 -0
  6. data/README.md +103 -0
  7. data/Rakefile +78 -0
  8. data/bootstrap-wysihtml5-rails.gemspec +20 -0
  9. data/lib/bootstrap-wysihtml5-rails.rb +12 -0
  10. data/lib/bootstrap-wysihtml5-rails/engine.rb +9 -0
  11. data/lib/bootstrap-wysihtml5-rails/railtie.rb +5 -0
  12. data/lib/bootstrap-wysihtml5-rails/version.rb +5 -0
  13. data/vendor/assets/javascripts/bootstrap-wysihtml5/b3.js +2 -0
  14. data/vendor/assets/javascripts/bootstrap-wysihtml5/core-b3.js.erb +520 -0
  15. data/vendor/assets/javascripts/bootstrap-wysihtml5/core.js.erb +511 -0
  16. data/vendor/assets/javascripts/bootstrap-wysihtml5/index.js +2 -0
  17. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ar-AR.js +49 -0
  18. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/bg-BG.js +49 -0
  19. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ca-CT.js +47 -0
  20. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/cs-CZ.js +48 -0
  21. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/da-DK.js +48 -0
  22. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/de-DE.js +49 -0
  23. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/el-GR.js +48 -0
  24. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/es-AR.js +49 -0
  25. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/es-ES.js +48 -0
  26. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/fr-FR.js +49 -0
  27. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/fr-NL.js +48 -0
  28. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/hr-HR.js +48 -0
  29. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/index.js +1 -0
  30. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/it-IT.js +47 -0
  31. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ja-JP.js +49 -0
  32. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ko-KR.js +49 -0
  33. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/lt-LT.js +48 -0
  34. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/mo-MD.js +48 -0
  35. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/nb-NB.js +49 -0
  36. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/nl-NL.js +48 -0
  37. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/pl-PL.js +48 -0
  38. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/pt-BR.js +48 -0
  39. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ru-RU.js +49 -0
  40. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/sk-SK.js +48 -0
  41. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/sv-SE.js +48 -0
  42. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/tr-TR.js +48 -0
  43. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/ua-UA.js +49 -0
  44. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-CN.js +48 -0
  45. data/vendor/assets/javascripts/bootstrap-wysihtml5/locales/zh-TW.js +48 -0
  46. data/vendor/assets/javascripts/bootstrap-wysihtml5/wysihtml5.js +9523 -0
  47. data/vendor/assets/stylesheets/bootstrap-wysihtml5/b3.css +3 -0
  48. data/vendor/assets/stylesheets/bootstrap-wysihtml5/core-b3.css +92 -0
  49. data/vendor/assets/stylesheets/bootstrap-wysihtml5/core.css +102 -0
  50. data/vendor/assets/stylesheets/bootstrap-wysihtml5/index.css +3 -0
  51. data/vendor/assets/stylesheets/bootstrap-wysihtml5/wysiwyg-color.css +67 -0
  52. metadata +136 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a747cad0a38d18ef0af52dc262b3f26bfeee6986
4
+ data.tar.gz: 3138f0e17ae3ccb3825be25ff0678d67cc8581ce
5
+ SHA512:
6
+ metadata.gz: ce7d7708f0500523b6fc4a6907cc3ad3fa06a2b6d4ea06175f3d3ffc66eab7a34519fc5dea5aa99087d01ee0c71effff92d70ec2144a22b650a9033e6cd5c8b4
7
+ data.tar.gz: e0c6988858df284146f6036a652e145aa0327aaf2eaa2969f51a2097690158f7ffad39158f73ea77103310468d91ddfbf448d8453f4cbfe3b5f67a522986b568
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ /bootstrap-wysihtml5
data/.rvmrc ADDED
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 2.0.0" > .rvmrc
9
+ environment_id="ruby-2.0.0-p195@wysihtml5"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.20.13 (master)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ for __hook in "${rvm_path:-$HOME/.rvm}/hooks/after_use"*
27
+ do
28
+ if [[ -f "${__hook}" && -x "${__hook}" && -s "${__hook}" ]]
29
+ then \. "${__hook}" || true
30
+ fi
31
+ done
32
+ unset __hook
33
+ if (( ${rvm_use_flag:=1} >= 2 )) # display only when forced
34
+ then
35
+ if [[ $- == *i* ]] # check for interactive shells
36
+ then printf "%b" "Using: \E[32m$GEM_HOME\E[0m" # show the user the ruby and gemset they are using in green
37
+ else printf "%b" "Using: $GEM_HOME" # don't use colors in non-interactive shells
38
+ fi
39
+ fi
40
+ else
41
+ # If the environment file has not yet been created, use the RVM CLI to select.
42
+ rvm --create "$environment_id" || {
43
+ echo "Failed to create RVM environment '${environment_id}'."
44
+ return 1
45
+ }
46
+ fi
47
+
48
+ # If you use bundler, this might be useful to you:
49
+ # if [[ -s Gemfile ]] && {
50
+ # ! builtin command -v bundle >/dev/null ||
51
+ # builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
52
+ # }
53
+ # then
54
+ # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
55
+ # gem install bundler
56
+ # fi
57
+ # if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
58
+ # then
59
+ # bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
60
+ # fi
@@ -0,0 +1,5 @@
1
+ If this is a set of changes on bootstrap-wysihtml5 itself, then you want to make you pull request here:
2
+
3
+ https://github.com/jhollingworth/bootstrap-wysihtml5
4
+
5
+ If this is a set of changes on bootstrap-wysihtml5-rails, then go ahead
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrap-rails.gemspec
4
+ gemspec
@@ -0,0 +1,103 @@
1
+ # Bootstrap Wysihtml5 for Rails
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/bootstrap-wysihtml5-rails.png)](http://badge.fury.io/rb/bootstrap-wysihtml5-rails)
4
+
5
+ [![endorse](https://api.coderwall.com/nerian/endorsecount.png)](https://coderwall.com/nerian)
6
+
7
+ Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
8
+ It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
9
+
10
+ http://twitter.github.com/bootstrap/
11
+
12
+ Bootstrap Wysihtml5 is a plugin for Bootstrap designed by James Hollingworth. It provides a stylish wysiwyg editor for Bootstrap.
13
+
14
+ https://github.com/jhollingworth/bootstrap-wysihtml5
15
+
16
+ bootstrap-wysihtml5-rails project integrates it with Rails 3 assets pipeline.
17
+
18
+ https://github.com/Nerian/bootstrap-wysihtml5-rails
19
+
20
+
21
+ ## Rails > 3.1
22
+ Include bootstrap-wysihtml5-rails in Gemfile;
23
+
24
+ ``` ruby
25
+ gem 'bootstrap-wysihtml5-rails'
26
+ ```
27
+
28
+ or you can install from latest build;
29
+
30
+ ``` ruby
31
+ gem 'bootstrap-wysihtml5-rails', :require => 'bootstrap-wysihtml5-rails',
32
+ :git => 'git://github.com/Nerian/bootstrap-wysihtml5-rails.git'
33
+ ```
34
+
35
+ and run bundle install.
36
+
37
+ This gem doesn't include Bootstrap. You can get Bootstrap here: https://github.com/anjlab/bootstrap-rails
38
+
39
+ ## Configuration
40
+
41
+ Bootstrap-wysihtml5 depends on jquery and bootstrap.
42
+
43
+ app/assets/stylesheets/application.css
44
+ ``` css
45
+ *= require bootstrap-wysihtml5
46
+ // or
47
+ *= require bootstrap-wysihtml5/b3
48
+ ```
49
+
50
+ app/assets/javascripts/application.js
51
+ ```javascript
52
+ //= require bootstrap-wysihtml5
53
+ // or
54
+ //= require bootstrap-wysihtml5/b3
55
+
56
+
57
+ You may include all locales like this:
58
+
59
+ //= require bootstrap-wysihtml5/locales
60
+
61
+ Or just add the ones that you want
62
+
63
+ //= require bootstrap-wysihtml5/locales/de-DE
64
+ //= require bootstrap-wysihtml5/locales/es-ES
65
+ ```
66
+
67
+ You may need to restart your rails server.
68
+
69
+ ## Using bootstrap-wysihtml5-rails
70
+
71
+ Just call wysihtml5() with any selector.
72
+
73
+ ```html
74
+ <textarea id="some-textarea" class='wysihtml5' placeholder="Enter text ..."></textarea>
75
+
76
+ <script type="text/javascript">
77
+ $(document).ready(function(){
78
+
79
+ $('.wysihtml5').each(function(i, elem) {
80
+ $(elem).wysihtml5();
81
+ });
82
+
83
+ })
84
+ </script>
85
+
86
+ ```
87
+
88
+ A live example: http://jsfiddle.net/5UUrg/
89
+
90
+ ## If using Turbolinks
91
+
92
+ ```
93
+ $(document).on('page:load', function(){
94
+ window['rangy'].initialized = false
95
+ })
96
+ ```
97
+
98
+ ## License
99
+ Copyright (c) 2012-2013 Gonzalo Rodríguez-Baltanás Díaz
100
+
101
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
102
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
103
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env rake
2
+ require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
3
+
4
+ ORIGIN_LIB_PATH = "bootstrap-wysihtml5/lib"
5
+ ORIGIN_SRC_PATH = "bootstrap-wysihtml5/src"
6
+ DEST_JAVASCRIPT_PATH = "vendor/assets/javascripts/bootstrap-wysihtml5"
7
+ DEST_CSS_PATH = "vendor/assets/stylesheets/bootstrap-wysihtml5"
8
+
9
+ def b2
10
+ system("cd bootstrap-wysihtml5 && git checkout master")
11
+
12
+ system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core.css")
13
+
14
+ core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
15
+ original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
16
+ objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
17
+
18
+ replaced = core_file.gsub(original_string, objective_string)
19
+
20
+ File.open("#{DEST_JAVASCRIPT_PATH}/core.js.erb", "w") { |file| file.puts replaced }
21
+ end
22
+
23
+ def b3
24
+ system("cd bootstrap-wysihtml5 && git checkout tb3")
25
+
26
+ system("cp #{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.css #{DEST_CSS_PATH}/core-b3.css")
27
+
28
+ core_file = File.read("#{ORIGIN_SRC_PATH}/bootstrap-wysihtml5.js")
29
+ original_string = /stylesheets: \[".\/lib\/css\/wysiwyg-color.css"\]/
30
+ objective_string = "stylesheets: [\"<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>\"]"
31
+
32
+ replaced = core_file.gsub(original_string, objective_string)
33
+
34
+ File.open("#{DEST_JAVASCRIPT_PATH}/core-b3.js.erb", "w") { |file| file.puts replaced }
35
+ end
36
+
37
+
38
+
39
+ desc "Update assets"
40
+ task 'update' do
41
+ if Dir.exist?('bootstrap-wysihtml5')
42
+ system("cd bootstrap-wysihtml5 && git pull && cd ..")
43
+ else
44
+ system("git clone git://github.com/jhollingworth/bootstrap-wysihtml5.git bootstrap-wysihtml5")
45
+ system("cd bootstrap-wysihtml5 && git remote add b3 git@github.com:artillery/bootstrap-wysihtml5.git")
46
+ system("cd bootstrap-wysihtml5 && git fetch b3")
47
+ system("cd bootstrap-wysihtml5 && git checkout -b tb3 b3/master")
48
+ end
49
+
50
+ Dir.foreach("bootstrap-wysihtml5/src/locales") do |file|
51
+ unless file == '.' || file == '..'
52
+ abbreviated_file_name = file.gsub('bootstrap-wysihtml5.', '')
53
+ system("cp #{ORIGIN_SRC_PATH}/locales/#{file} #{DEST_JAVASCRIPT_PATH}/locales/#{abbreviated_file_name}")
54
+ end
55
+ end
56
+
57
+ system("cp #{ORIGIN_LIB_PATH}/js/wysihtml5-0.3.0.js #{DEST_JAVASCRIPT_PATH}/wysihtml5.js")
58
+ system("cp #{ORIGIN_LIB_PATH}/css/wysiwyg-color.css #{DEST_CSS_PATH}/wysiwyg-color.css")
59
+
60
+ b2
61
+ b3
62
+
63
+ system("git status")
64
+ end
65
+
66
+ desc "Build"
67
+ task "build" do
68
+ system("gem build bootstrap-wysihtml5-rails.gemspec")
69
+ end
70
+
71
+ desc "Publish a new version"
72
+ task :publish => :build do
73
+ tags = `git tag`.split
74
+ version = BootstrapWysihtml5Rails::Rails::VERSION
75
+ system("git tag -a #{version} -m 'Release #{version}' ") unless tags.include?(version)
76
+ system("gem push bootstrap-wysihtml5-rails-font-awesome-#{version}.gem")
77
+ system("git push --follow-tags")
78
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Gonzalo Rodríguez-Baltanás Díaz"]
6
+ gem.email = ["siotopo@gmail.com"]
7
+ gem.description = %q{A wysiwyg text editor for Twitter Bootstrap}
8
+ gem.homepage = "https://github.com/Nerian/bootstrap-wysihtml5-rails"
9
+ gem.summary = gem.description
10
+ gem.license = 'MIT'
11
+
12
+ gem.name = "bootstrap-wysihtml5-rails-font-awesome"
13
+ gem.require_paths = ["lib"]
14
+ gem.files = `git ls-files`.split("\n").reject { |i| i=~/testapp/}
15
+ gem.version = BootstrapWysihtml5Rails::Rails::VERSION
16
+
17
+ gem.add_dependency "railties", ">= 3.0"
18
+ gem.add_development_dependency "bundler", ">= 1.0"
19
+ gem.add_development_dependency "rake"
20
+ end
@@ -0,0 +1,12 @@
1
+ require "rails"
2
+ require "bootstrap-wysihtml5-rails/version"
3
+
4
+ module BootstrapWysihtml5Rails
5
+ module Rails
6
+ if ::Rails.version.to_s < "3.1"
7
+ require "bootstrap-wysihtml5-rails/railtie"
8
+ else
9
+ require "bootstrap-wysihtml5-rails/engine"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module BootstrapWysihtml5Rails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer "BootstrapWysihtml5Rails precompile hook", :group => :all do |app|
5
+ app.config.assets.precompile += %w(bootstrap-wysihtml5.css bootstrap-wysihtml5.js bootstrap-wysihtml5/wysiwyg-color.css)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module BootstrapWysihtml5Rails
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module BootstrapWysihtml5Rails
2
+ module Rails
3
+ VERSION = "0.3.1.25"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ //= require ./wysihtml5
2
+ //= require ./core-b3
@@ -0,0 +1,520 @@
1
+ !function($, wysi) {
2
+ "use strict";
3
+
4
+ var tpl = {
5
+ "font-styles": function(locale, options) {
6
+ var size = (options && options.size) ? ' btn-'+options.size : '';
7
+ return "<li class='dropdown'>" +
8
+ "<a class='btn btn-default btn" + size + " dropdown-toggle' data-toggle='dropdown' href='#'>" +
9
+ "<i class='glyphicon glyphicon-font'></i>&nbsp;<span class='current-font'>" + locale.font_styles.normal + "</span>&nbsp;<b class='caret'></b>" +
10
+ "</a>" +
11
+ "<ul class='dropdown-menu'>" +
12
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div' tabindex='-1'>" + locale.font_styles.normal + "</a></li>" +
13
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1' tabindex='-1'>" + locale.font_styles.h1 + "</a></li>" +
14
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2' tabindex='-1'>" + locale.font_styles.h2 + "</a></li>" +
15
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h3' tabindex='-1'>" + locale.font_styles.h3 + "</a></li>" +
16
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h4'>" + locale.font_styles.h4 + "</a></li>" +
17
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h5'>" + locale.font_styles.h5 + "</a></li>" +
18
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h6'>" + locale.font_styles.h6 + "</a></li>" +
19
+ "</ul>" +
20
+ "</li>";
21
+ },
22
+
23
+ "emphasis": function(locale, options) {
24
+ var size = (options && options.size) ? ' btn-'+options.size : '';
25
+ return "<li>" +
26
+ "<div class='btn-group'>" +
27
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='bold' title='CTRL+B' tabindex='-1'>" + locale.emphasis.bold + "</a>" +
28
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='italic' title='CTRL+I' tabindex='-1'>" + locale.emphasis.italic + "</a>" +
29
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='underline' title='CTRL+U' tabindex='-1'>" + locale.emphasis.underline + "</a>" +
30
+ "</div>" +
31
+ "</li>";
32
+ },
33
+
34
+ "lists": function(locale, options) {
35
+ var size = (options && options.size) ? ' btn-'+options.size : '';
36
+ return "<li>" +
37
+ "<div class='btn-group'>" +
38
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertUnorderedList' title='" + locale.lists.unordered + "' tabindex='-1'><i class='glyphicon glyphicon-list'></i></a>" +
39
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertOrderedList' title='" + locale.lists.ordered + "' tabindex='-1'><i class='glyphicon glyphicon-th-list'></i></a>" +
40
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Outdent' title='" + locale.lists.outdent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-right'></i></a>" +
41
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='Indent' title='" + locale.lists.indent + "' tabindex='-1'><i class='glyphicon glyphicon-indent-left'></i></a>" +
42
+ "</div>" +
43
+ "</li>";
44
+ },
45
+
46
+ "link": function(locale, options) {
47
+ var size = (options && options.size) ? ' btn-'+options.size : '';
48
+ return "<li>" +
49
+ "<div class='bootstrap-wysihtml5-insert-link-modal modal fade'>" +
50
+ "<div class='modal-dialog'>" +
51
+ "<div class='modal-content'>" +
52
+ "<div class='modal-header'>" +
53
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
54
+ "<h3 class='modal-title'>" + locale.link.insert + "</h3>" +
55
+ "</div>" +
56
+ "<div class='modal-body'>" +
57
+ "<input value='http://' class='bootstrap-wysihtml5-insert-link-url form-control'>" +
58
+ "<label class='checkbox'> <input type='checkbox' class='bootstrap-wysihtml5-insert-link-target' checked>" + locale.link.target + "</label>" +
59
+ "</div>" +
60
+ "<div class='modal-footer'>" +
61
+ "<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.link.cancel + "</a>" +
62
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.link.insert + "</a>" +
63
+ "</div>" +
64
+ "</div>" +
65
+ "</div>" +
66
+ "</div>" +
67
+ "<a class='btn btn-default" + size + "' data-wysihtml5-command='createLink' title='" + locale.link.insert + "' tabindex='-1'><i class='glyphicon glyphicon-share'></i></a>" +
68
+ "</li>";
69
+ },
70
+
71
+ "image": function(locale, options) {
72
+ var size = (options && options.size) ? ' btn-'+options.size : '';
73
+ return "<li>" +
74
+ "<div class='bootstrap-wysihtml5-insert-image-modal modal fade'>" +
75
+ "<div class='modal-dialog'>" +
76
+ "<div class='modal-content'>" +
77
+ "<div class='modal-header'>" +
78
+ "<a class='close' data-dismiss='modal'>&times;</a>" +
79
+ "<h3 class='modal-title'>" + locale.image.insert + "</h3>" +
80
+ "</div>" +
81
+ "<div class='modal-body'>" +
82
+ "<input value='http://' class='bootstrap-wysihtml5-insert-image-url form-control'>" +
83
+ "</div>" +
84
+ "<div class='modal-footer'>" +
85
+ "<a href='#' class='btn btn-default' data-dismiss='modal'>" + locale.image.cancel + "</a>" +
86
+ "<a href='#' class='btn btn-primary' data-dismiss='modal'>" + locale.image.insert + "</a>" +
87
+ "</div>" +
88
+ "</div>" +
89
+ "</div>" +
90
+ "</div>" +
91
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-command='insertImage' title='" + locale.image.insert + "' tabindex='-1'><i class='glyphicon glyphicon-picture'></i></a>" +
92
+ "</li>";
93
+ },
94
+
95
+ "html": function(locale, options) {
96
+ var size = (options && options.size) ? ' btn-'+options.size : '';
97
+ return "<li>" +
98
+ "<div class='btn-group'>" +
99
+ "<a class='btn btn-default btn" + size + "' data-wysihtml5-action='change_view' title='" + locale.html.edit + "' tabindex='-1'><i class='glyphicon glyphicon-pencil'></i></a>" +
100
+ "</div>" +
101
+ "</li>";
102
+ },
103
+
104
+ "color": function(locale, options) {
105
+ var size = (options && options.size) ? ' btn-'+options.size : '';
106
+ return "<li class='dropdown'>" +
107
+ "<a class='btn btn-default dropdown-toggle" + size + "' data-toggle='dropdown' href='#' tabindex='-1'>" +
108
+ "<span class='current-color'>" + locale.colours.black + "</span>&nbsp;<b class='caret'></b>" +
109
+ "</a>" +
110
+ "<ul class='dropdown-menu'>" +
111
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='black'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='black'>" + locale.colours.black + "</a></li>" +
112
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='silver'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='silver'>" + locale.colours.silver + "</a></li>" +
113
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='gray'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='gray'>" + locale.colours.gray + "</a></li>" +
114
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='maroon'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='maroon'>" + locale.colours.maroon + "</a></li>" +
115
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='red'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='red'>" + locale.colours.red + "</a></li>" +
116
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='purple'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='purple'>" + locale.colours.purple + "</a></li>" +
117
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='green'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='green'>" + locale.colours.green + "</a></li>" +
118
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='olive'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='olive'>" + locale.colours.olive + "</a></li>" +
119
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='navy'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='navy'>" + locale.colours.navy + "</a></li>" +
120
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='blue'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='blue'>" + locale.colours.blue + "</a></li>" +
121
+ "<li><div class='wysihtml5-colors' data-wysihtml5-command-value='orange'></div><a class='wysihtml5-colors-title' data-wysihtml5-command='foreColor' data-wysihtml5-command-value='orange'>" + locale.colours.orange + "</a></li>" +
122
+ "</ul>" +
123
+ "</li>";
124
+ }
125
+ };
126
+
127
+ var templates = function(key, locale, options) {
128
+ return tpl[key](locale, options);
129
+ };
130
+
131
+
132
+ var Wysihtml5 = function(el, options) {
133
+ this.el = el;
134
+ var toolbarOpts = options || defaultOptions;
135
+ for(var t in toolbarOpts.customTemplates) {
136
+ tpl[t] = toolbarOpts.customTemplates[t];
137
+ }
138
+ this.toolbar = this.createToolbar(el, toolbarOpts);
139
+ this.editor = this.createEditor(options);
140
+
141
+ window.editor = this.editor;
142
+
143
+ $('iframe.wysihtml5-sandbox').each(function(i, el){
144
+ $(el.contentWindow).off('focus.wysihtml5').on({
145
+ 'focus.wysihtml5' : function(){
146
+ $('li.dropdown').removeClass('open');
147
+ }
148
+ });
149
+ });
150
+ };
151
+
152
+ Wysihtml5.prototype = {
153
+
154
+ constructor: Wysihtml5,
155
+
156
+ createEditor: function(options) {
157
+ options = options || {};
158
+
159
+ // Add the toolbar to a clone of the options object so multiple instances
160
+ // of the WYISYWG don't break because "toolbar" is already defined
161
+ options = $.extend(true, {}, options);
162
+ options.toolbar = this.toolbar[0];
163
+
164
+ var editor = new wysi.Editor(this.el[0], options);
165
+
166
+ if(options && options.events) {
167
+ for(var eventName in options.events) {
168
+ editor.on(eventName, options.events[eventName]);
169
+ }
170
+ }
171
+ return editor;
172
+ },
173
+
174
+ createToolbar: function(el, options) {
175
+ var self = this;
176
+ var toolbar = $("<ul/>", {
177
+ 'class' : "wysihtml5-toolbar",
178
+ 'style': "display:none"
179
+ });
180
+ var culture = options.locale || defaultOptions.locale || "en";
181
+ for(var key in defaultOptions) {
182
+ var value = false;
183
+
184
+ if(options[key] !== undefined) {
185
+ if(options[key] === true) {
186
+ value = true;
187
+ }
188
+ } else {
189
+ value = defaultOptions[key];
190
+ }
191
+
192
+ if(value === true) {
193
+ toolbar.append(templates(key, locale[culture], options));
194
+
195
+ if(key === "html") {
196
+ this.initHtml(toolbar);
197
+ }
198
+
199
+ if(key === "link") {
200
+ this.initInsertLink(toolbar);
201
+ }
202
+
203
+ if(key === "image") {
204
+ this.initInsertImage(toolbar);
205
+ }
206
+ }
207
+ }
208
+
209
+ if(options.toolbar) {
210
+ for(key in options.toolbar) {
211
+ toolbar.append(options.toolbar[key]);
212
+ }
213
+ }
214
+
215
+ toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
216
+ var target = e.target || e.srcElement;
217
+ var el = $(target);
218
+ self.toolbar.find('.current-font').text(el.html());
219
+ });
220
+
221
+ toolbar.find("a[data-wysihtml5-command='foreColor']").click(function(e) {
222
+ var target = e.target || e.srcElement;
223
+ var el = $(target);
224
+ self.toolbar.find('.current-color').text(el.html());
225
+ });
226
+
227
+ this.el.before(toolbar);
228
+
229
+ return toolbar;
230
+ },
231
+
232
+ initHtml: function(toolbar) {
233
+ var changeViewSelector = "a[data-wysihtml5-action='change_view']";
234
+ toolbar.find(changeViewSelector).click(function(e) {
235
+ toolbar.find('a.btn').not(changeViewSelector).toggleClass('disabled');
236
+ });
237
+ },
238
+
239
+ initInsertImage: function(toolbar) {
240
+ var self = this;
241
+ var insertImageModal = toolbar.find('.bootstrap-wysihtml5-insert-image-modal');
242
+ var urlInput = insertImageModal.find('.bootstrap-wysihtml5-insert-image-url');
243
+ var insertButton = insertImageModal.find('a.btn-primary');
244
+ var initialValue = urlInput.val();
245
+ var caretBookmark;
246
+
247
+ var insertImage = function() {
248
+ var url = urlInput.val();
249
+ urlInput.val(initialValue);
250
+ self.editor.currentView.element.focus();
251
+ if (caretBookmark) {
252
+ self.editor.composer.selection.setBookmark(caretBookmark);
253
+ caretBookmark = null;
254
+ }
255
+ self.editor.composer.commands.exec("insertImage", url);
256
+ };
257
+
258
+ urlInput.keypress(function(e) {
259
+ if(e.which == 13) {
260
+ insertImage();
261
+ insertImageModal.modal('hide');
262
+ }
263
+ });
264
+
265
+ insertButton.click(insertImage);
266
+
267
+ insertImageModal.on('shown', function() {
268
+ urlInput.focus();
269
+ });
270
+
271
+ insertImageModal.on('hide', function() {
272
+ self.editor.currentView.element.focus();
273
+ });
274
+
275
+ toolbar.find('a[data-wysihtml5-command=insertImage]').click(function() {
276
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
277
+
278
+ if (!activeButton) {
279
+ self.editor.currentView.element.focus(false);
280
+ caretBookmark = self.editor.composer.selection.getBookmark();
281
+ insertImageModal.appendTo('body').modal('show');
282
+ insertImageModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
283
+ e.stopPropagation();
284
+ });
285
+ return false;
286
+ }
287
+ else {
288
+ return true;
289
+ }
290
+ });
291
+ },
292
+
293
+ initInsertLink: function(toolbar) {
294
+ var self = this;
295
+ var insertLinkModal = toolbar.find('.bootstrap-wysihtml5-insert-link-modal');
296
+ var urlInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-url');
297
+ var targetInput = insertLinkModal.find('.bootstrap-wysihtml5-insert-link-target');
298
+ var insertButton = insertLinkModal.find('a.btn-primary');
299
+ var initialValue = urlInput.val();
300
+ var caretBookmark;
301
+
302
+ var insertLink = function() {
303
+ var url = urlInput.val();
304
+ urlInput.val(initialValue);
305
+ self.editor.currentView.element.focus();
306
+ if (caretBookmark) {
307
+ self.editor.composer.selection.setBookmark(caretBookmark);
308
+ caretBookmark = null;
309
+ }
310
+
311
+ var newWindow = targetInput.prop("checked");
312
+ self.editor.composer.commands.exec("createLink", {
313
+ 'href' : url,
314
+ 'target' : (newWindow ? '_blank' : '_self'),
315
+ 'rel' : (newWindow ? 'nofollow' : '')
316
+ });
317
+ };
318
+ var pressedEnter = false;
319
+
320
+ urlInput.keypress(function(e) {
321
+ if(e.which == 13) {
322
+ insertLink();
323
+ insertLinkModal.modal('hide');
324
+ }
325
+ });
326
+
327
+ insertButton.click(insertLink);
328
+
329
+ insertLinkModal.on('shown', function() {
330
+ urlInput.focus();
331
+ });
332
+
333
+ insertLinkModal.on('hide', function() {
334
+ self.editor.currentView.element.focus();
335
+ });
336
+
337
+ toolbar.find('a[data-wysihtml5-command=createLink]').click(function() {
338
+ var activeButton = $(this).hasClass("wysihtml5-command-active");
339
+
340
+ if (!activeButton) {
341
+ self.editor.currentView.element.focus(false);
342
+ caretBookmark = self.editor.composer.selection.getBookmark();
343
+ insertLinkModal.appendTo('body').modal('show');
344
+ insertLinkModal.on('click.dismiss.modal', '[data-dismiss="modal"]', function(e) {
345
+ e.stopPropagation();
346
+ });
347
+ return false;
348
+ }
349
+ else {
350
+ return true;
351
+ }
352
+ });
353
+ }
354
+ };
355
+
356
+ // these define our public api
357
+ var methods = {
358
+ resetDefaults: function() {
359
+ $.fn.wysihtml5.defaultOptions = $.extend(true, {}, $.fn.wysihtml5.defaultOptionsCache);
360
+ },
361
+ bypassDefaults: function(options) {
362
+ return this.each(function () {
363
+ var $this = $(this);
364
+ $this.data('wysihtml5', new Wysihtml5($this, options));
365
+ });
366
+ },
367
+ shallowExtend: function (options) {
368
+ var settings = $.extend({}, $.fn.wysihtml5.defaultOptions, options || {}, $(this).data());
369
+ var that = this;
370
+ return methods.bypassDefaults.apply(that, [settings]);
371
+ },
372
+ deepExtend: function(options) {
373
+ var settings = $.extend(true, {}, $.fn.wysihtml5.defaultOptions, options || {});
374
+ var that = this;
375
+ return methods.bypassDefaults.apply(that, [settings]);
376
+ },
377
+ init: function(options) {
378
+ var that = this;
379
+ return methods.shallowExtend.apply(that, [options]);
380
+ }
381
+ };
382
+
383
+ $.fn.wysihtml5 = function ( method ) {
384
+ if ( methods[method] ) {
385
+ return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
386
+ } else if ( typeof method === 'object' || ! method ) {
387
+ return methods.init.apply( this, arguments );
388
+ } else {
389
+ $.error( 'Method ' + method + ' does not exist on jQuery.wysihtml5' );
390
+ }
391
+ };
392
+
393
+ $.fn.wysihtml5.Constructor = Wysihtml5;
394
+
395
+ var defaultOptions = $.fn.wysihtml5.defaultOptions = {
396
+ "font-styles": true,
397
+ "color": false,
398
+ "emphasis": true,
399
+ "lists": true,
400
+ "html": false,
401
+ "link": true,
402
+ "image": true,
403
+ events: {},
404
+ parserRules: {
405
+ classes: {
406
+ // (path_to_project/lib/css/wysiwyg-color.css)
407
+ "wysiwyg-color-silver" : 1,
408
+ "wysiwyg-color-gray" : 1,
409
+ "wysiwyg-color-white" : 1,
410
+ "wysiwyg-color-maroon" : 1,
411
+ "wysiwyg-color-red" : 1,
412
+ "wysiwyg-color-purple" : 1,
413
+ "wysiwyg-color-fuchsia" : 1,
414
+ "wysiwyg-color-green" : 1,
415
+ "wysiwyg-color-lime" : 1,
416
+ "wysiwyg-color-olive" : 1,
417
+ "wysiwyg-color-yellow" : 1,
418
+ "wysiwyg-color-navy" : 1,
419
+ "wysiwyg-color-blue" : 1,
420
+ "wysiwyg-color-teal" : 1,
421
+ "wysiwyg-color-aqua" : 1,
422
+ "wysiwyg-color-orange" : 1
423
+ },
424
+ tags: {
425
+ "b": {},
426
+ "i": {},
427
+ "br": {},
428
+ "ol": {},
429
+ "ul": {},
430
+ "li": {},
431
+ "h1": {},
432
+ "h2": {},
433
+ "h3": {},
434
+ "h4": {},
435
+ "h5": {},
436
+ "h6": {},
437
+ "blockquote": {},
438
+ "u": 1,
439
+ "img": {
440
+ "check_attributes": {
441
+ "width": "numbers",
442
+ "alt": "alt",
443
+ "src": "url",
444
+ "height": "numbers"
445
+ }
446
+ },
447
+ "a": {
448
+ check_attributes: {
449
+ 'href': "url", // important to avoid XSS
450
+ 'target': 'alt',
451
+ 'rel': 'alt'
452
+ }
453
+ },
454
+ "span": 1,
455
+ "div": 1,
456
+ // to allow save and edit files with code tag hacks
457
+ "code": 1,
458
+ "pre": 1
459
+ }
460
+ },
461
+ stylesheets: ["<%= stylesheet_path('bootstrap-wysihtml5/wysiwyg-color.css') %>"], // (path_to_project/lib/css/wysiwyg-color.css)
462
+ locale: "en"
463
+ };
464
+
465
+ if (typeof $.fn.wysihtml5.defaultOptionsCache === 'undefined') {
466
+ $.fn.wysihtml5.defaultOptionsCache = $.extend(true, {}, $.fn.wysihtml5.defaultOptions);
467
+ }
468
+
469
+ var locale = $.fn.wysihtml5.locale = {
470
+ en: {
471
+ font_styles: {
472
+ normal: "Normal text",
473
+ h1: "Heading 1",
474
+ h2: "Heading 2",
475
+ h3: "Heading 3",
476
+ h4: "Heading 4",
477
+ h5: "Heading 5",
478
+ h6: "Heading 6"
479
+ },
480
+ emphasis: {
481
+ bold: "Bold",
482
+ italic: "Italic",
483
+ underline: "Underline"
484
+ },
485
+ lists: {
486
+ unordered: "Unordered list",
487
+ ordered: "Ordered list",
488
+ outdent: "Outdent",
489
+ indent: "Indent"
490
+ },
491
+ link: {
492
+ insert: "Insert link",
493
+ cancel: "Cancel",
494
+ target: "Open link in new window"
495
+ },
496
+ image: {
497
+ insert: "Insert image",
498
+ cancel: "Cancel"
499
+ },
500
+ html: {
501
+ edit: "Edit HTML"
502
+ },
503
+ colours: {
504
+ black: "Black",
505
+ silver: "Silver",
506
+ gray: "Grey",
507
+ maroon: "Maroon",
508
+ red: "Red",
509
+ purple: "Purple",
510
+ green: "Green",
511
+ olive: "Olive",
512
+ navy: "Navy",
513
+ blue: "Blue",
514
+ orange: "Orange"
515
+ }
516
+ }
517
+ };
518
+
519
+ }(window.jQuery, window.wysihtml5);
520
+