Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit f9ec3474afbbdabf9e03139e82d2fbc62f8296ef 0 parents
@Nerian authored
2  .gitignore
@@ -0,0 +1,2 @@
+Gemfile.lock
+*.gem
4 Gemfile
@@ -0,0 +1,4 @@
+source 'http://rubygems.org'
+
+# Specify your gem's dependencies in bootstrap-rails.gemspec
+gemspec
67 README.md
@@ -0,0 +1,67 @@
+# Bootstrap Wysihtml5 for Rails
+
+Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites.
+It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more.
+
+http://twitter.github.com/bootstrap/
+
+Bootstrap Wysihtml5 is a plugin for Bootstrap designed by James Hollingworth. It provides a stylish wysiwyg editor for Bootstrap.
+
+https://github.com/jhollingworth/bootstrap-wysihtml5
+
+bootstrap-wysihtml5-rails project integrates it with Rails 3 assets pipeline.
+
+http://github.com/Nerian/bootstrap-wysihtml5
+
+
+## Rails > 3.1
+Include bootstrap-wysihtml5-rails in Gemfile;
+
+``` ruby
+gem 'bootstrap-wysihtml5-rails'
+```
+
+or you can install from latest build;
+
+``` ruby
+gem 'bootstrap-wysihtml5-rails', :require => 'bootstrap-wysihtml5-rails',
+ :git => 'git://github.com/Nerian/bootstrap-wysihtml5-rails.git'
+```
+
+and run bundle install.
+
+## Stylesheets
+
+Add necessary stylesheet file to app/assets/stylesheets/application.css
+
+``` css
+*= require bootstrap-wysihtml5
+```
+
+## Javascripts
+
+Add necessary javascript(s) files to app/assets/javascripts/application.js
+
+``` javascript
+//= require wysihtml5
+//= require bootstrap-wysihtml5
+```
+
+## Using bootstrap-wysihtml5-rails
+
+Just call wysihtml5() with any selector.
+
+```html
+<textarea id="some-textarea" placeholder="Enter text ..."></textarea>
+
+<script type="text/javascript">
+ $('#some-textarea').wysihtml5();
+</script>
+```
+
+## License
+Copyright (c) 2011 Gonzalo Rodríguez-Baltanás Díaz
+
+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:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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.
12 Rakefile
@@ -0,0 +1,12 @@
+#!/usr/bin/env rake
+require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
+
+desc "Build the gem"
+task "build" do
+ system("gem build bootstrap-wysihtml5-rails.gemspec")
+end
+
+desc "Publish the gem"
+task 'publish' do
+ system("gem push bootstrap-wysihtml5-rails-#{BootstrapWysihtml5Rails::Rails::VERSION}.gem")
+end
19 bootstrap-wysihtml5-rails.gemspec
@@ -0,0 +1,19 @@
+# -*- encoding: utf-8 -*-
+require File.expand_path('../lib/bootstrap-wysihtml5-rails/version', __FILE__)
+
+Gem::Specification.new do |gem|
+ gem.authors = ["Gonzalo Rodríguez-Baltanás Díaz"]
+ gem.email = ["siotopo@gmail.com"]
+ gem.description = %q{A wysiwyg text editor for Twitter Bootstrap}
+ gem.homepage = "https://github.com/Nerian/bootstrap-datepicker-rails"
+ gem.summary = gem.description
+
+ gem.name = "bootstrap-wysihtml5-rails"
+ gem.require_paths = ["lib"]
+ gem.files = `git ls-files`.split("\n")
+ gem.version = BootstrapWysihtml5Rails::Rails::VERSION
+
+ gem.add_dependency "railties", ">= 3.0"
+ gem.add_development_dependency "bundler", ">= 1.0"
+ gem.add_development_dependency "rake"
+end
12 lib/bootstrap-wysihtml5-rails.rb
@@ -0,0 +1,12 @@
+require "rails"
+require "bootstrap-wysihtml5-rails/version"
+
+module BootstrapWysihtml5Rails
+ module Rails
+ if ::Rails.version < "3.1"
+ require "bootstrap-wysihtml5-rails/railtie"
+ else
+ require "bootstrap-wysihtml5-rails/engine"
+ end
+ end
+end
6 lib/bootstrap-wysihtml5-rails/engine.rb
@@ -0,0 +1,6 @@
+module BootstrapWysihtml5Rails
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+end
5 lib/bootstrap-wysihtml5-rails/railtie.rb
@@ -0,0 +1,5 @@
+module BootstrapWysihtml5Rails
+ module Rails
+ class Railtie < ::Rails::Railtie; end
+ end
+end
5 lib/bootstrap-wysihtml5-rails/version.rb
@@ -0,0 +1,5 @@
+module BootstrapWysihtml5Rails
+ module Rails
+ VERSION = "0.1"
+ end
+end
99 vendor/assets/javascripts/bootstrap-wysihtml5.js
@@ -0,0 +1,99 @@
+!function($, wysi) {
+ "use strict"
+
+ var templates = {
+ "font-styles": "<li class='dropdown'>" +
+ "<a class='btn dropdown-toggle' data-toggle='dropdown' href='#'>" +
+ "<i class='icon-font'></i>&nbsp;<span class='current-font'>Normal text</span>&nbsp;<b class='caret'></b>" +
+ "</a>" +
+ "<ul class='dropdown-menu'>" +
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='div'>Normal text</a></li>" +
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h1'>Heading 1</a></li>" +
+ "<li><a data-wysihtml5-command='formatBlock' data-wysihtml5-command-value='h2'>Heading 2</a></li>" +
+ "</ul>" +
+ "</li>",
+ "emphasis": "<li>" +
+ "<div class='btn-group'>" +
+ "<a class='btn' data-wysihtml5-command='bold' title='CTRL+B'>Bold</a>" +
+ "<a class='btn' data-wysihtml5-command='italic' title='CTRL+I'>Italic</a>" +
+ "</div>" +
+ "</li>",
+ "lists": "<li>" +
+ "<div class='btn-group'>" +
+ "<a class='btn' data-wysihtml5-command='insertUnorderedList'><i class='icon-list'></i></a>" +
+ "<a class='btn' data-wysihtml5-command='insertOrderedList'><i class='icon-th-list'></i></a>" +
+ "</div>" +
+ "</li>"
+ };
+
+ var defaultOptions = {
+ "font-styles": true,
+ "emphasis": true,
+ "lists": true
+ };
+
+ var Wysihtml5 = function(el, options) {
+ this.el = el;
+ this.toolbar = this.createToolbar(el, options || defaultOptions);
+ this.editor = new wysi.Editor(this.el.attr('id'), {
+ toolbar: this.toolbar.attr('id')
+ });
+
+ $('iframe.wysihtml5-sandbox').each(function(i, el){
+ $(el.contentWindow).off('focus.wysihtml5').on({
+ 'focus.wysihtml5' : function(){
+ $('li.dropdown').removeClass('open');
+ }
+ });
+ });
+ };
+
+ Wysihtml5.prototype = {
+ constructor: Wysihtml5,
+
+ createToolbar: function(el, options) {
+ var toolbar = $("<ul/>", {
+ id : el.attr('id') + "-wysihtml5-toolbar",
+ class : "wysihtml5-toolbar",
+ style: "display:none"
+ }).button();
+
+ for(var key in defaultOptions) {
+ var value;
+
+ if(options[key] != undefined) {
+ if(options[key] == true) {
+ value = true;
+ }
+ } else {
+ value = defaultOptions[key];
+ }
+
+ if(value == true) {
+ toolbar.append(templates[key]);
+ }
+ }
+
+ var self = this;
+
+ toolbar.find("a[data-wysihtml5-command='formatBlock']").click(function(e) {
+ var el = $(e.srcElement);
+ self.toolbar.find('.current-font').text(el.html())
+ });
+
+ this.el.before(toolbar);
+
+ return toolbar;
+ }
+ };
+
+ $.fn.wysihtml5 = function (options) {
+ return this.each(function () {
+ var $this = $(this);
+ $this.data('wysihtml5', new Wysihtml5($this, options));
+ })
+ };
+
+ $.fn.wysihtml5.Constructor = Wysihtml5;
+
+}(window.jQuery, window.wysihtml5);
258 vendor/assets/javascripts/wysihtml5.js
258 additions, 0 deletions not shown
36 vendor/assets/stylesheets/bootstrap-wysihtml5.css
@@ -0,0 +1,36 @@
+ul.wysihtml5-toolbar {
+ margin: 0;
+ padding: 0;
+ display: block;
+}
+
+ul.wysihtml5-toolbar::after {
+ clear: both;
+ display: table;
+ content: "";
+}
+
+ul.wysihtml5-toolbar > li {
+ float: left;
+ display: list-item;
+ list-style: none;
+ margin: 0 5px 10px 0;
+}
+
+ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] {
+ font-weight: bold;
+}
+
+ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
+ font-style: italic;
+}
+
+ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
+ background-image: none;
+ -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
+ -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
+ box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
+ background-color: #E6E6E6;
+ background-color: #D9D9D9 9;
+ outline: 0;
+}

0 comments on commit f9ec347

Please sign in to comment.
Something went wrong with that request. Please try again.