├── .gitignore ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── jsonform-rails.gemspec ├── lib └── jsonform │ ├── rails.rb │ └── rails │ └── version.rb ├── package.json └── vendor └── assets └── javascripts ├── deps ├── README.md ├── img │ └── glyphicons-halflings.png ├── jquery.min.js ├── opt │ ├── ace │ │ ├── ace.js │ │ ├── mode-css.js │ │ ├── mode-html.js │ │ ├── mode-javascript.js │ │ ├── mode-json.js │ │ ├── mode-less.js │ │ ├── mode-markdown.js │ │ ├── theme-twilight.js │ │ ├── worker-css.js │ │ ├── worker-javascript.js │ │ └── worker-json.js │ ├── bootstrap-dropdown.js │ ├── bootstrap-wysihtml5.css │ ├── bootstrap-wysihtml5.js │ ├── bootstrap.css │ ├── emmet.js │ ├── jquery.transloadit2.js │ ├── jquery.ui.core.js │ ├── jquery.ui.mouse.js │ ├── jquery.ui.sortable.js │ ├── jquery.ui.widget.js │ ├── jsv.js │ ├── spectrum.css │ └── spectrum.js └── underscore.js ├── example.html ├── lib ├── jsonform-defaults.js ├── jsonform-split.js └── jsonform.js ├── playground-wiwo ├── README.md ├── data │ ├── __wiwo-repayment-widget-simple.json │ ├── wiwo-repayment-widget-full.json │ └── wiwo-repayment-widget-simplest.json ├── index.html ├── playground.js └── schemas │ ├── wiwo-repayment-widget-full.json │ ├── wiwo-repayment-widget-simple.json │ └── wiwo-repayment-widget-simplest.json ├── playground ├── README.md ├── examples │ ├── events.json │ ├── factory-sleek.json │ ├── fields-ace.json │ ├── fields-actions.json │ ├── fields-advancedfieldset.json │ ├── fields-array.json │ ├── fields-authfieldset.json │ ├── fields-checkbox.json │ ├── fields-checkboxes.json │ ├── fields-color.json │ ├── fields-common.json │ ├── fields-fieldset.json │ ├── fields-help.json │ ├── fields-hidden.json │ ├── fields-imageselect.json │ ├── fields-password.json │ ├── fields-questions.json │ ├── fields-radiobuttons.json │ ├── fields-radios.json │ ├── fields-range.json │ ├── fields-section.json │ ├── fields-select.json │ ├── fields-selectfieldset-key.json │ ├── fields-selectfieldset.json │ ├── fields-submit.json │ ├── fields-tabarray-maxitems.json │ ├── fields-tabarray-value.json │ ├── fields-tabarray.json │ ├── fields-textarea.json │ ├── gettingstarted.json │ ├── previousvalues.json │ ├── schema-array.json │ ├── schema-basic.json │ ├── schema-morecomplex.json │ ├── templating-idx.json │ ├── templating-tpldata.json │ ├── templating-value.json │ └── templating-values.json ├── index.html └── playground.js └── tests ├── ace └── t.js ├── actions └── t.js ├── array └── t.js ├── checkbox └── t.js ├── checkboxes └── t.js ├── color └── t.js ├── fieldset └── t.js ├── file └── t.js ├── help └── t.js ├── hidden └── t.js ├── i18n └── t.js ├── imageselect └── t.js ├── index.html ├── number └── t.js ├── other ├── array.html ├── checkboxes.html ├── complexlists.html ├── defaults.html ├── expandable.html ├── forms │ ├── array.js │ ├── basic.js │ ├── checkboxes.js │ ├── complexlists.js │ ├── defaults.js │ ├── expandable.js │ ├── prefix.js │ ├── tabarray.js │ ├── tabs-array.js │ ├── tabs-values.js │ ├── tabs.js │ └── titleMap.js ├── index.html ├── prefix.html ├── tabarray.html ├── tabs-array.html ├── tabs-values.html ├── tabs.html └── titleMap.html ├── runner.js ├── section └── t.js ├── select └── t.js ├── selectfieldset └── t.js ├── tabarray └── t.js ├── template └── t.js ├── text └── t.js ├── value └── t.js └── wysihtml5 └── t.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.gem 3 | *.rbc 4 | .bundle 5 | .config 6 | .yardoc 7 | Gemfile.lock 8 | InstalledFiles 9 | _yardoc 10 | coverage 11 | doc/ 12 | lib/bundler/man 13 | pkg 14 | rdoc 15 | spec/reports 16 | test/tmp 17 | test/version_tmp 18 | tmp 19 | .idea/ 20 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in jsonform-rails.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Joshfire 2 | 3 | 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: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | 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. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | JSON Form 2 | ========= 3 | 4 | The JSON Form library is a JavaScript client-side library that takes a 5 | structured data model defined using [JSON Schema](http://json-schema.org/) as 6 | input and returns a [Bootstrap](http://twitter.github.com/bootstrap/)-friendly 7 | HTML form that matches the schema. 8 | 9 | The generated HTML form includes client-side validation logic that provides direct inline feedback to the user upon form submission (provided a JSON Schema validator is available). If values are valid, the JSON Form library uses submitted values to create the JavaScript data structure that matches the data model. 10 | 11 | The layout of the generated HTML form may be entirely fine-tuned through 12 | a simple declarative mechanism. 13 | 14 | 15 | # Jsonform::Rails 16 | 17 | Jsonform-rails wraps joshfire's JSONForm into an easy to bundle asset gem. 18 | 19 | TODO: helpers as the need emerges 20 | 21 | ## Installation 22 | 23 | Add this line to your application's Gemfile: 24 | 25 | gem 'jsonform-rails' 26 | 27 | And then execute: 28 | 29 | $ bundle 30 | 31 | Or install it yourself as: 32 | 33 | $ gem install jsonform-rails 34 | 35 | ## Usage 36 | 37 | Step 1: Make sure you're calling the javascript file in your application.js. There is no CSS, jsonform styles for bootstrap and lets you handle that: 38 | 39 | //= require jsonform 40 | 41 | Step 2: Use is as described in the jsonform doco 42 | 43 | 44 | Getting started 45 | --------------- 46 | 47 | The example below creates a form that asks for the user's name and age. The user's name is a required field, while the age is optional. 48 | 49 | ```html 50 | 51 | 52 | 53 | 54 | Getting started with JSON Form 55 | 56 | 57 | 58 |

Getting started with JSON Form

59 |
60 |
61 | 62 | 63 | 64 | 65 | 90 | 91 | 92 | ``` 93 | 94 | Loading this page in a browser renders a form with two input fields and a submit button. The ```onSubmit``` function is called upon form submission. If you press "Submit" without entering values or if the age you enter is not a number, error messages appear next to the input fields. 95 | 96 | NB: Paths in this example are relative to the root of the JSON Form project. 97 | 98 | 99 | Documentation 100 | ------------- 101 | 102 | You can do much more with the JSON Form library. You may define a more complex data model that includes arrays and objects for instance, or you may control the layout of the form to include fieldsets, expandable sections or tabs. For more information, check the [reference documentation for JSON Form](http://github.com/joshfire/jsonform/wiki). 103 | 104 | 105 | Playground 106 | ---------- 107 | If you're more of the acting type than of the reading type, the [JSON Form Playground](https://github.com/joshfire/jsonform/tree/master/playground#readme) is a simple JSON Form editor that lets you try out and extend all the examples in the doc. 108 | 109 | 110 | Dependencies 111 | ------------ 112 | 113 | At a minimum, the JSON Form library depends on: 114 | - [jQuery](http://jquery.com/) 115 | - The [Underscore.js](http://documentcloud.github.com/underscore/) utility belt 116 | 117 | The JSON Form library may require further libraries, depending on the features you need for the forms you need to render. In particular: 118 | - [ACE](http://ace.ajax.org/) is needed to render rich text input fields. The [deps/opt/ace](https://github.com/joshfire/jsonform/tree/master/deps/opt/ace) folder contains a minimal set of files from ACE to render a JSON input field. Beware that the code of `ace.js` needs to be encapsulated in `(function(require,define,requirejs) {...})(undefined,undefined,undefined);` before it may be used within JSON Form. 119 | - [Bootstrap](http://twitter.github.com/bootstrap/) v2.0.3 or above is more or less needed (unless you enjoy ugly forms, that is) if you don't provide your own styles. JSON Form only needs the ```bootstrap.css``` file. 120 | - The [JSON Schema Validator](https://github.com/garycourt/JSV) is used to detect and report validation errors upon form submission. The [deps/opt](https://github.com/joshfire/jsonform/tree/master/deps/opt) folder contains a "build" of the JSON Schema Validator for use in JSON Form. 121 | - [Bootstrap Dropdowns](http://twitter.github.com/bootstrap/javascript.html#dropdowns) v2.0.3 or above is needed for ```imageselect``` fields. 122 | - [jQuery UI Sortable](http://jqueryui.com/demos/sortable/) v1.8.20 or above is required for drag-and-drop support within arrays and tabarrays. Note the plugin itself depends on jQuery IU Core, jQuery UI Mouse, and jQuery UI Widget. 123 | - [wysihtml5](http://jhollingworth.github.com/bootstrap-wysihtml5/) is required if the form uses ```wysihtml5``` textarea fields. 124 | - [Spectrum](http://bgrins.github.com/spectrum/) is required if the form uses `color` fields. 125 | 126 | All of these libraries are in the [deps](https://github.com/joshfire/jsonform/tree/master/deps) folder, although you might want to check their respective Web site for more recent versions. 127 | 128 | NB: JSON Form also uses ```JSON.parse``` and ```JSON.stringify``` which is normally already natively supported by all modern browsers. You may use a JSON library otherwise. 129 | 130 | 131 | License 132 | ------- 133 | 134 | The JSON Form library is licensed under the [MIT license](https://raw.github.com/joshfire/jsonform/master/LICENSE). 135 | 136 | All the libraries that JSON Form may depend on are licensed under the MIT license, except for the JSON Schema Validator, licensed under the BSD 3 Clause license and the ACE editor licensed under the Mozilla tri-license (MPL/GPL/LGPL). 137 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /jsonform-rails.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'jsonform/rails/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "jsonform-rails" 8 | spec.version = Jsonform::Rails::VERSION 9 | spec.authors = ["Nathaniel Fitzgerald-Hood"] 10 | spec.email = ["nathaniel@widgetworks.com.au"] 11 | spec.description = %q{Asset wrapper gem for joshfire's jsonform: Build forms from JSON Schema. Easily template-able. Compatible with Twitter Bootstrap out of the box.} 12 | spec.summary = %q{Build forms from JSON Schema using Javascript} 13 | spec.homepage = "https://github.com/mrthan/jsonform-rails" 14 | spec.license = "MIT" 15 | 16 | spec.files = Dir["{lib,vendor}/**/*"] + ["LICENSE", "README.md"] 17 | spec.require_paths = ["lib"] 18 | 19 | spec.add_development_dependency "bundler", "~> 1.3" 20 | spec.add_development_dependency "rake" 21 | spec.add_development_dependency "railties", "~> 3.1" 22 | end 23 | -------------------------------------------------------------------------------- /lib/jsonform/rails.rb: -------------------------------------------------------------------------------- 1 | require "jsonform/rails/version" 2 | 3 | module Jsonform 4 | module Rails 5 | class Engine < ::Rails::Engine 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/jsonform/rails/version.rb: -------------------------------------------------------------------------------- 1 | module Jsonform 2 | module Rails 3 | VERSION = "1.0.6" 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "json-form", 3 | "version" : "1.0.6", 4 | "main" : "./lib/jsonform.js", 5 | "user" : "Joshfire", 6 | "domain": "joshfire.com", 7 | "description": "Client-side JavaScript library that generates HTML forms from structured data models expressed using a JSON schema, possibly completed by a form layout description.", 8 | "keywords": [ 9 | "JSON", 10 | "schema", 11 | "HTML5", 12 | "form" 13 | ], 14 | "maintainers": [ 15 | { 16 | "name": "Joshfire", 17 | "email": "contact@joshfire.com", 18 | "web": "http://www.joshfire.com" 19 | } 20 | ], 21 | "licenses": [ 22 | { 23 | "type": "MIT", 24 | "url": "LICENSE" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/README.md: -------------------------------------------------------------------------------- 1 | JSON Form dependencies 2 | ====================== 3 | 4 | This folder contains required and optional dependencies for JSON Form. 5 | 6 | Required 7 | -------- 8 | - [jQuery](http://jquery.com/) v1.7.2 or above 9 | - [Underscore.js](http://documentcloud.github.com/underscore/) v1.3.3 or above 10 | 11 | 12 | Optional 13 | -------- 14 | The libraries in the ```opt``` subfolder are optional as long as you do not use the feature they enable: 15 | - [JSON Schema Validator](https://github.com/garycourt/JSV) is required to validate sumbitted values against the JSON schema that gave birth to the form. This folder includes a "build" of the validator (basically a merge of its different components scoped to avoid leaking variables to the global context. 16 | - [Bootstrap](http://twitter.github.com/bootstrap/) v2.0.3 or above for styling purpose (JSON Form only uses the ```bootstrap.css``` file) 17 | - [wysihtml5](http://jhollingworth.github.com/bootstrap-wysihtml5/) if the form uses ```wysihtml5``` textarea fields 18 | - [jQuery UI Sortable](http://jqueryui.com/demos/sortable/) v1.8.20 or above for drag-and-drop support within arrays and tabarrays. Note the plugin itself depends on jQuery IU Core, jQuery UI Mouse, and jQuery UI Widget. -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrthan/jsonform-rails/6ae0810e80675bee24cf845c5123f5f7024b3694/vendor/assets/javascripts/deps/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/opt/ace/theme-twilight.js: -------------------------------------------------------------------------------- 1 | /* ***** BEGIN LICENSE BLOCK ***** 2 | * Version: MPL 1.1/GPL 2.0/LGPL 2.1 3 | * 4 | * The contents of this file are subject to the Mozilla Public License Version 5 | * 1.1 (the "License"); you may not use this file except in compliance with 6 | * the License. You may obtain a copy of the License at 7 | * http://www.mozilla.org/MPL/ 8 | * 9 | * Software distributed under the License is distributed on an "AS IS" basis, 10 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 11 | * for the specific language governing rights and limitations under the 12 | * License. 13 | * 14 | * The Original Code is Ajax.org Code Editor (ACE). 15 | * 16 | * The Initial Developer of the Original Code is 17 | * Ajax.org B.V. 18 | * Portions created by the Initial Developer are Copyright (C) 2010 19 | * the Initial Developer. All Rights Reserved. 20 | * 21 | * Contributor(s): 22 | * Fabian Jakobs 23 | * 24 | * Alternatively, the contents of this file may be used under the terms of 25 | * either the GNU General Public License Version 2 or later (the "GPL"), or 26 | * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 27 | * in which case the provisions of the GPL or the LGPL are applicable instead 28 | * of those above. If you wish to allow use of your version of this file only 29 | * under the terms of either the GPL or the LGPL, and not to allow others to 30 | * use your version of this file under the terms of the MPL, indicate your 31 | * decision by deleting the provisions above and replace them with the notice 32 | * and other provisions required by the GPL or the LGPL. If you do not delete 33 | * the provisions above, a recipient may use your version of this file under 34 | * the terms of any one of the MPL, the GPL or the LGPL. 35 | * 36 | * ***** END LICENSE BLOCK ***** */ 37 | 38 | ace.define('ace/theme/twilight', ['require', 'exports', 'module', 'ace/lib/dom'], function(require, exports, module) { 39 | 40 | exports.isDark = true; 41 | exports.cssClass = "ace-twilight"; 42 | exports.cssText = "\ 43 | .ace-twilight .ace_editor {\ 44 | border: 2px solid rgb(159, 159, 159);\ 45 | }\ 46 | \ 47 | .ace-twilight .ace_editor.ace_focus {\ 48 | border: 2px solid #327fbd;\ 49 | }\ 50 | \ 51 | .ace-twilight .ace_gutter {\ 52 | background: #e8e8e8;\ 53 | color: #333;\ 54 | }\ 55 | \ 56 | .ace-twilight .ace_print_margin {\ 57 | width: 1px;\ 58 | background: #e8e8e8;\ 59 | }\ 60 | \ 61 | .ace-twilight .ace_scroller {\ 62 | background-color: #141414;\ 63 | }\ 64 | \ 65 | .ace-twilight .ace_text-layer {\ 66 | cursor: text;\ 67 | color: #F8F8F8;\ 68 | }\ 69 | \ 70 | .ace-twilight .ace_cursor {\ 71 | border-left: 2px solid #A7A7A7;\ 72 | }\ 73 | \ 74 | .ace-twilight .ace_cursor.ace_overwrite {\ 75 | border-left: 0px;\ 76 | border-bottom: 1px solid #A7A7A7;\ 77 | }\ 78 | \ 79 | .ace-twilight .ace_marker-layer .ace_selection {\ 80 | background: rgba(221, 240, 255, 0.20);\ 81 | }\ 82 | \ 83 | .ace-twilight.multiselect .ace_selection.start {\ 84 | box-shadow: 0 0 3px 0px #141414;\ 85 | border-radius: 2px;\ 86 | }\ 87 | \ 88 | .ace-twilight .ace_marker-layer .ace_step {\ 89 | background: rgb(102, 82, 0);\ 90 | }\ 91 | \ 92 | .ace-twilight .ace_marker-layer .ace_bracket {\ 93 | margin: -1px 0 0 -1px;\ 94 | border: 1px solid rgba(255, 255, 255, 0.25);\ 95 | }\ 96 | \ 97 | .ace-twilight .ace_marker-layer .ace_active_line {\ 98 | background: rgba(255, 255, 255, 0.031);\ 99 | }\ 100 | \ 101 | .ace-twilight .ace_gutter_active_line {\ 102 | background-color : #dcdcdc;\ 103 | }\ 104 | \ 105 | .ace-twilight .ace_marker-layer .ace_selected_word {\ 106 | border: 1px solid rgba(221, 240, 255, 0.20);\ 107 | }\ 108 | \ 109 | .ace-twilight .ace_invisible {\ 110 | color: rgba(255, 255, 255, 0.25);\ 111 | }\ 112 | \ 113 | .ace-twilight .ace_keyword, .ace-twilight .ace_meta {\ 114 | color:#CDA869;\ 115 | }\ 116 | \ 117 | .ace-twilight .ace_constant, .ace-twilight .ace_constant.ace_other {\ 118 | color:#CF6A4C;\ 119 | }\ 120 | \ 121 | .ace-twilight .ace_constant.ace_character, {\ 122 | color:#CF6A4C;\ 123 | }\ 124 | \ 125 | .ace-twilight .ace_constant.ace_character.ace_escape, {\ 126 | color:#CF6A4C;\ 127 | }\ 128 | \ 129 | .ace-twilight .ace_invalid.ace_illegal {\ 130 | color:#F8F8F8;\ 131 | background-color:rgba(86, 45, 86, 0.75);\ 132 | }\ 133 | \ 134 | .ace-twilight .ace_invalid.ace_deprecated {\ 135 | text-decoration:underline;\ 136 | font-style:italic;\ 137 | color:#D2A8A1;\ 138 | }\ 139 | \ 140 | .ace-twilight .ace_support {\ 141 | color:#9B859D;\ 142 | }\ 143 | \ 144 | .ace-twilight .ace_support.ace_constant {\ 145 | color:#CF6A4C;\ 146 | }\ 147 | \ 148 | .ace-twilight .ace_fold {\ 149 | background-color: #AC885B;\ 150 | border-color: #F8F8F8;\ 151 | }\ 152 | \ 153 | .ace-twilight .ace_support.ace_function {\ 154 | color:#DAD085;\ 155 | }\ 156 | \ 157 | .ace-twilight .ace_storage {\ 158 | color:#F9EE98;\ 159 | }\ 160 | \ 161 | .ace-twilight .ace_variable {\ 162 | color:#AC885B;\ 163 | }\ 164 | \ 165 | .ace-twilight .ace_string {\ 166 | color:#8F9D6A;\ 167 | }\ 168 | \ 169 | .ace-twilight .ace_string.ace_regexp {\ 170 | color:#E9C062;\ 171 | }\ 172 | \ 173 | .ace-twilight .ace_comment {\ 174 | font-style:italic;\ 175 | color:#5F5A60;\ 176 | }\ 177 | \ 178 | .ace-twilight .ace_variable {\ 179 | color:#7587A6;\ 180 | }\ 181 | \ 182 | .ace-twilight .ace_xml_pe {\ 183 | color:#494949;\ 184 | }\ 185 | \ 186 | .ace-twilight .ace_meta.ace_tag {\ 187 | color:#AC885B;\ 188 | }\ 189 | \ 190 | .ace-twilight .ace_entity.ace_name.ace_function {\ 191 | color:#AC885B;\ 192 | }\ 193 | \ 194 | .ace-twilight .ace_markup.ace_underline {\ 195 | text-decoration:underline;\ 196 | }\ 197 | \ 198 | .ace-twilight .ace_markup.ace_heading {\ 199 | color:#CF6A4C;\ 200 | }\ 201 | \ 202 | .ace-twilight .ace_markup.ace_list {\ 203 | color:#F9EE98;\ 204 | }"; 205 | 206 | var dom = require("../lib/dom"); 207 | dom.importCssString(exports.cssText, exports.cssClass); 208 | }); 209 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/opt/bootstrap-dropdown.js: -------------------------------------------------------------------------------- 1 | /* ============================================================ 2 | * bootstrap-dropdown.js v2.0.4 3 | * http://twitter.github.com/bootstrap/javascript.html#dropdowns 4 | * ============================================================ 5 | * Copyright 2012 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ============================================================ */ 19 | 20 | 21 | !function ($) { 22 | 23 | "use strict"; // jshint ;_; 24 | 25 | 26 | /* DROPDOWN CLASS DEFINITION 27 | * ========================= */ 28 | 29 | var toggle = '[data-toggle="dropdown"]' 30 | , Dropdown = function (element) { 31 | var $el = $(element).on('click.dropdown.data-api', this.toggle) 32 | $('html').on('click.dropdown.data-api', function () { 33 | $el.parent().removeClass('open') 34 | }) 35 | } 36 | 37 | Dropdown.prototype = { 38 | 39 | constructor: Dropdown 40 | 41 | , toggle: function (e) { 42 | var $this = $(this) 43 | , $parent 44 | , selector 45 | , isActive 46 | 47 | if ($this.is('.disabled, :disabled')) return 48 | 49 | selector = $this.attr('data-target') 50 | 51 | if (!selector) { 52 | selector = $this.attr('href') 53 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 54 | } 55 | 56 | $parent = $(selector) 57 | $parent.length || ($parent = $this.parent()) 58 | 59 | isActive = $parent.hasClass('open') 60 | 61 | clearMenus() 62 | 63 | if (!isActive) $parent.toggleClass('open') 64 | 65 | return false 66 | } 67 | 68 | } 69 | 70 | function clearMenus() { 71 | $(toggle).parent().removeClass('open') 72 | } 73 | 74 | 75 | /* DROPDOWN PLUGIN DEFINITION 76 | * ========================== */ 77 | 78 | $.fn.dropdown = function (option) { 79 | return this.each(function () { 80 | var $this = $(this) 81 | , data = $this.data('dropdown') 82 | if (!data) $this.data('dropdown', (data = new Dropdown(this))) 83 | if (typeof option == 'string') data[option].call($this) 84 | }) 85 | } 86 | 87 | $.fn.dropdown.Constructor = Dropdown 88 | 89 | 90 | /* APPLY TO STANDARD DROPDOWN ELEMENTS 91 | * =================================== */ 92 | 93 | $(function () { 94 | $('html').on('click.dropdown.data-api', clearMenus) 95 | $('body') 96 | .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() }) 97 | .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) 98 | }) 99 | 100 | }(window.jQuery); -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/opt/bootstrap-wysihtml5.css: -------------------------------------------------------------------------------- 1 | ul.wysihtml5-toolbar { 2 | margin: 0; 3 | padding: 0; 4 | display: block; 5 | } 6 | 7 | ul.wysihtml5-toolbar::after { 8 | clear: both; 9 | display: table; 10 | content: ""; 11 | } 12 | 13 | ul.wysihtml5-toolbar > li { 14 | float: left; 15 | display: list-item; 16 | list-style: none; 17 | margin: 0 5px 10px 0; 18 | } 19 | 20 | ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] { 21 | font-weight: bold; 22 | } 23 | 24 | ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] { 25 | font-style: italic; 26 | } 27 | 28 | ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] { 29 | text-decoration: underline; 30 | } 31 | 32 | ul.wysihtml5-toolbar a.btn.wysihtml5-command-active { 33 | background-image: none; 34 | -webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); 35 | -moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); 36 | box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05); 37 | background-color: #E6E6E6; 38 | background-color: #D9D9D9 9; 39 | outline: 0; 40 | } 41 | 42 | ul.wysihtml5-commands-disabled .dropdown-menu { 43 | display: none !important; 44 | } -------------------------------------------------------------------------------- /vendor/assets/javascripts/deps/opt/bootstrap-wysihtml5.js: -------------------------------------------------------------------------------- 1 | !function($, wysi) { 2 | "use strict" 3 | 4 | var templates = { 5 | "font-styles": "", 15 | "emphasis": "
  • " + 16 | "
    " 17 | + "Bold" 18 | + "Italic" 19 | + "Underline" 20 | + "
    " 21 | + "
  • ", 22 | "lists": "
  • " 23 | + "
    " 24 | + "" 25 | + "" 26 | + "" 27 | + "" 28 | + "
    " 29 | + "
  • ", 30 | 31 | "link": "
  • " 32 | 33 | + "" 46 | 47 | + "" 48 | 49 | + "
  • ", 50 | 51 | "image": "
  • " 52 | 53 | + "" 66 | 67 | + "" 68 | 69 | + "
  • ", 70 | 71 | "html": 72 | "
  • " 73 | + "
    " 74 | + "" 75 | + "
    " 76 | + "
  • " 77 | }; 78 | 79 | var defaultOptions = { 80 | "font-styles": true, 81 | "emphasis": true, 82 | "lists": true, 83 | "html": false, 84 | "link": true, 85 | "image": true, 86 | events: {}, 87 | parserRules: { 88 | tags: { 89 | "b": {}, 90 | "i": {}, 91 | "br": {}, 92 | "ol": {}, 93 | "ul": {}, 94 | "li": {}, 95 | "h1": {}, 96 | "h2": {}, 97 | "u": 1, 98 | "img": { 99 | "check_attributes": { 100 | "width": "numbers", 101 | "alt": "alt", 102 | "src": "url", 103 | "height": "numbers" 104 | } 105 | }, 106 | "a": { 107 | set_attributes: { 108 | target: "_blank", 109 | rel: "nofollow" 110 | }, 111 | check_attributes: { 112 | href: "url" // important to avoid XSS 113 | } 114 | } 115 | } 116 | } 117 | }; 118 | 119 | var Wysihtml5 = function(el, options) { 120 | this.el = el; 121 | this.toolbar = this.createToolbar(el, options || defaultOptions); 122 | this.editor = this.createEditor(options); 123 | 124 | window.editor = this.editor; 125 | 126 | $('iframe.wysihtml5-sandbox').each(function(i, el){ 127 | $(el.contentWindow).off('focus.wysihtml5').on({ 128 | 'focus.wysihtml5' : function(){ 129 | $('li.dropdown').removeClass('open'); 130 | } 131 | }); 132 | }); 133 | }; 134 | 135 | Wysihtml5.prototype = { 136 | constructor: Wysihtml5, 137 | 138 | createEditor: function(options) { 139 | var parserRules = defaultOptions.parserRules; 140 | 141 | if(options && options.parserRules) { 142 | parserRules = options.parserRules; 143 | } 144 | 145 | var editor = new wysi.Editor(this.el.attr('id'), { 146 | toolbar: this.toolbar.attr('id'), 147 | parserRules: parserRules 148 | }); 149 | 150 | if(options && options.events) { 151 | for(var eventName in options.events) { 152 | editor.on(eventName, options.events[eventName]); 153 | } 154 | } 155 | 156 | return editor; 157 | }, 158 | 159 | createToolbar: function(el, options) { 160 | var self = this; 161 | var toolbar = $("