summernote-ext-image-attributes-rails 0.8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5fcc624819c46827d5f2bdea6b143762f11dd37afc739fca248cde4ecb166425
4
+ data.tar.gz: dce76ae8612365fd654320cbe76bc79edd1e07a5593a2f0edc3dff1a543e06d1
5
+ SHA512:
6
+ metadata.gz: d8f6c3781905a1cd3f45876c8277441e0df3b613c9446946331e085ae29c2fdecf3e648caadf0f0a9a3266160495cc2f464ce779c7f93c021ba1497fdbe47fa3
7
+ data.tar.gz: 0fd3ab1fff62a52ff755d34cfa1398d6f7177345376bd825209a4da35c7c2f8198b81d8eb1973a745d0606f1997b8332a939dfb0568341974e6a3602a963fbcc
@@ -0,0 +1,44 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /db/*.sqlite3-journal
8
+ /public/system
9
+ /coverage/
10
+ /spec/tmp
11
+ *.orig
12
+ rerun.txt
13
+ pickle-email-*.html
14
+
15
+ # TODO Comment out this rule if you are OK with secrets being uploaded to the repo
16
+ config/initializers/secret_token.rb
17
+
18
+ # Only include if you have production secrets in this file, which is no longer a Rails default
19
+ # config/secrets.yml
20
+
21
+ # dotenv
22
+ # TODO Comment out this rule if environment variables can be committed
23
+ .env
24
+
25
+ ## Environment normalization:
26
+ /.bundle
27
+ /vendor/bundle
28
+
29
+ # these should all be checked in to normalize the environment:
30
+ # Gemfile.lock, .ruby-version, .ruby-gemset
31
+
32
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
33
+ .rvmrc
34
+
35
+ # if using bower-rails ignore default bower_components path bower.json files
36
+ /vendor/assets/bower_components
37
+ *.bowerrc
38
+ bower.json
39
+
40
+ # Ignore pow environment settings
41
+ .powenv
42
+
43
+ # Ignore Byebug command history file.
44
+ .byebug_history
@@ -0,0 +1,7 @@
1
+ CHANGELOG
2
+ =========
3
+
4
+ 0.8.10.0 (2018-05-09)
5
+ ---------------------
6
+
7
+ Initial stable release.
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at wakematta@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ssummernote-ext-image-attributes-rails.gemspec
4
+ gemspec
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ summernote-ext-image-attributes-rails (0.8.10.0)
5
+ railties (>= 3.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.0)
11
+ actionview (= 5.2.0)
12
+ activesupport (= 5.2.0)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.0)
18
+ activesupport (= 5.2.0)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activesupport (5.2.0)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ builder (3.2.3)
29
+ concurrent-ruby (1.0.5)
30
+ crass (1.0.4)
31
+ erubi (1.7.1)
32
+ gem-release (1.0.0)
33
+ i18n (1.0.1)
34
+ concurrent-ruby (~> 1.0)
35
+ loofah (2.2.2)
36
+ crass (~> 1.0.2)
37
+ nokogiri (>= 1.5.9)
38
+ method_source (0.9.0)
39
+ mini_portile2 (2.3.0)
40
+ minitest (5.11.3)
41
+ nokogiri (1.8.2)
42
+ mini_portile2 (~> 2.3.0)
43
+ rack (2.0.5)
44
+ rack-test (1.0.0)
45
+ rack (>= 1.0, < 3)
46
+ rails-dom-testing (2.0.3)
47
+ activesupport (>= 4.2.0)
48
+ nokogiri (>= 1.6)
49
+ rails-html-sanitizer (1.0.4)
50
+ loofah (~> 2.2, >= 2.2.2)
51
+ railties (5.2.0)
52
+ actionpack (= 5.2.0)
53
+ activesupport (= 5.2.0)
54
+ method_source
55
+ rake (>= 0.8.7)
56
+ thor (>= 0.18.1, < 2.0)
57
+ rake (12.3.1)
58
+ thor (0.20.0)
59
+ thread_safe (0.3.6)
60
+ tzinfo (1.2.5)
61
+ thread_safe (~> 0.1)
62
+
63
+ PLATFORMS
64
+ ruby
65
+
66
+ DEPENDENCIES
67
+ bundler (~> 1.3)
68
+ gem-release
69
+ rake
70
+ summernote-ext-image-attributes-rails!
71
+
72
+ BUNDLED WITH
73
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Mohamed Ziata
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,30 @@
1
+ ## Publish new version
2
+
3
+ ### 1. Update summernote assets
4
+
5
+ ```bash
6
+ bundle exec rake update
7
+ ```
8
+ // TODO : automation using rake
9
+
10
+ ### 2. Update gem version number
11
+
12
+ Edit `lib/summernote-ext-image-attributes-rails/version.rb`
13
+
14
+ ```ruby
15
+ module SummernoteExtImageAttributesRails
16
+ module Rails
17
+ VERSION = x.y.z.0
18
+ end
19
+ end
20
+ ```
21
+
22
+ ### 3. Publish
23
+
24
+ Publish on rubygems
25
+
26
+ ```bash
27
+ gem-release --push
28
+ ```
29
+
30
+ this command git tagging and publish
@@ -0,0 +1,96 @@
1
+ # summernote-ext-image-attributes-rails
2
+
3
+ The gemification of the summernote extension [summernote-image-attributes][summernote-image-attributes]
4
+ for Rails >= 3.1.
5
+
6
+ <p align="center">
7
+ <img src="https://user-images.githubusercontent.com/3450257/39814132-682c4820-5393-11e8-9245-c356d4fa749e.png" />
8
+ </p>
9
+
10
+ ## Demo
11
+
12
+ Also, we have a [**live demo**][summernote-image-attributes-demo] (press the image inside of the editor).
13
+
14
+ ## Installation
15
+
16
+ Add the following gems to your application's `Gemfile`:
17
+
18
+ ```ruby
19
+ gem 'bootstrap-sass' # required
20
+ gem 'summernote-rails' # required
21
+ gem 'summernote-ext-image-attributes-rails', '~> 0.8.10'
22
+ ```
23
+
24
+ And then execute on the terminal:
25
+
26
+ ```bash
27
+ bundle install
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### JavaScript
33
+
34
+ In `app/assets/javascripts/application.js`, you should add in this order:
35
+
36
+ ```js
37
+ //= require bootstrap
38
+ //= require summernote
39
+ //= require summernote-ext-image-attributes
40
+ ```
41
+
42
+ ### CoffeeScript
43
+
44
+ In `app/assets/javascripts/application.coffee`, you should add in this order:
45
+
46
+ ```coffeescript
47
+ #= require bootstrap
48
+ #= require summernote
49
+ #= require summernote-ext-image-attributes
50
+ ```
51
+
52
+ ## Customization
53
+
54
+ ```js
55
+ $('[data-provider="summernote"]').summernote({
56
+ popover: {
57
+ image: [
58
+ ['custom', ['imageAttributes']],
59
+ ['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']],
60
+ ['float', ['floatLeft', 'floatRight', 'floatNone']],
61
+ ['remove', ['removeMedia']]
62
+ ],
63
+ },
64
+ lang: 'en-US', // Change to your chosen language
65
+ imageAttributes: {
66
+ icon: '<i class="note-icon-pencil"/>',
67
+ removeEmpty: false, // true = remove attributes | false = leave empty if present
68
+ disableUpload: false // true = don't display Upload Options | Display Upload Options
69
+ }
70
+ });
71
+ ```
72
+
73
+ More information [**here**][summernote-image-attributes-wiki].
74
+
75
+ ## Versioning
76
+
77
+ | Major | Minor | Patch | Current |
78
+ |:-------:|:-------:|:-------:|:---------:|
79
+ | is the major of [summernote][summernote] | is the minor of [summernote][summernote] | is the patch of [summernote][summernote] | is the vesion of this extension |
80
+
81
+ *Example:*
82
+
83
+ The compatible versions of this gem with [summernote][summernote] `v0.8.10` are:
84
+
85
+ - `summernote-ext-image-attributes-rails v0.8.10.X`
86
+
87
+ ## License
88
+
89
+ [MIT][license]
90
+
91
+
92
+ [summernote]: https://github.com/summernote/summernote
93
+ [summernote-image-attributes]: https://github.com/DiemenDesign/summernote-image-attributes
94
+ [summernote-image-attributes-wiki]: https://github.com/DiemenDesign/summernote-image-attributes
95
+ [summernote-image-attributes-demo]: https://jsfiddle.net/wakematta/w76hmwaj/1/
96
+ [license]: ./LICENSE
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'summernote-ext-image-attributes-rails'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ require 'rails'
2
+ require 'summernote-ext-image-attributes-rails/version'
3
+
4
+ module SummernoteExtImageAttributesRails
5
+ module Rails
6
+ # Rails >= 3.1
7
+ if (::Rails::VERSION::MAJOR > 3) ||
8
+ (::Rails::VERSION::MAJOR == 3 && ::Rails::VERSION::MINOR >= 1)
9
+ require 'summernote-ext-image-attributes-rails/engine'
10
+ else
11
+ require 'summernote-ext-image-attributes-rails/railtie'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ module SummernoteExtImageAttributesRails
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ initializer 'summernote-ext-image-attributess-rails.assets.precompile' do |app|
5
+ if defined? Sprockets::Rails
6
+ # sprockets-rails 3 tracks down the calls to `font_path` and `image_path`
7
+ # and automatically precompiles the referenced assets.
8
+ unless Sprockets::Rails::VERSION.starts_with?('3')
9
+ app.config.assets.precompile << /\.(?:eot|woff|ttf)$/
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module SummernoteExtImageAttributesRails
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module SummernoteExtImageAttributesRails
2
+ module Rails
3
+ VERSION = '0.8.10.0'
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/summernote-ext-image-attributes-rails/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'summernote-ext-image-attributes-rails'
6
+ spec.version = SummernoteExtImageAttributesRails::Rails::VERSION
7
+ spec.authors = ['Dennis Suitters', 'Mohamed Ziata']
8
+ spec.summary = %q{
9
+ Gemify the summernote extension called "summernote-image-attributes" for Rails >= 3.1
10
+ }
11
+ spec.description = %q{
12
+ This gem packages the extencion summernote-ext-image-attributes of Summernote editor
13
+ for Rails' assets pipeline
14
+ }
15
+ spec.homepage = 'https://github.com/WaKeMaTTa/summernote-ext-image-attributes-rails'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_dependency 'railties', '>= 3.1'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake'
27
+ spec.add_development_dependency 'gem-release'
28
+ end
@@ -0,0 +1 @@
1
+ //= require ./summernote-ext-image-attributes
@@ -0,0 +1,367 @@
1
+ /* https://github.com/DiemenDesign/summernote-image-attributes */
2
+ (function (factory) {
3
+ if (typeof define === 'function' && define.amd) {
4
+ define(['jquery'], factory);
5
+ } else if (typeof module === 'object' && module.exports) {
6
+ module.exports = factory(require('jquery'));
7
+ } else {
8
+ factory(window.jQuery);
9
+ }
10
+ }(function ($) {
11
+ var readFileAsDataURL = function (file) {
12
+ return $.Deferred( function (deferred) {
13
+ $.extend(new FileReader(),{
14
+ onload: function (e) {
15
+ var sDataURL = e.target.result;
16
+ deferred.resolve(sDataURL);
17
+ },
18
+ onerror: function () {
19
+ deferred.reject(this);
20
+ }
21
+ }).readAsDataURL(file);
22
+ }).promise();
23
+ };
24
+ $.extend(true,$.summernote.lang, {
25
+ 'en-US': { /* US English(Default Language) */
26
+ imageAttributes: {
27
+ dialogTitle: 'Image Attributes',
28
+ tooltip: 'Image Attributes',
29
+ tabImage: 'Image',
30
+ src: 'Source',
31
+ browse: 'Browse',
32
+ title: 'Title',
33
+ alt: 'Alt Text',
34
+ dimensions: 'Dimensions',
35
+ tabAttributes: 'Attributes',
36
+ class: 'Class',
37
+ style: 'Style',
38
+ role: 'Role',
39
+ tabLink: 'Link',
40
+ linkHref: 'URL',
41
+ linkTarget: 'Target',
42
+ linkTargetInfo: 'Options: _self, _blank, _top, _parent',
43
+ linkClass: 'Class',
44
+ linkStyle: 'Style',
45
+ linkRel: 'Rel',
46
+ linkRelInfo: 'Options: alternate, author, bookmark, help, license, next, nofollow, noreferrer, prefetch, prev, search, tag',
47
+ linkRole: 'Role',
48
+ tabUpload: 'Upload',
49
+ upload: 'Upload',
50
+ tabBrowse: 'Browse',
51
+ editBtn: 'OK'
52
+ }
53
+ }
54
+ });
55
+ $.extend($.summernote.options, {
56
+ imageAttributes: {
57
+ icon: '<i class="note-icon-pencil"/>',
58
+ removeEmpty: true,
59
+ disableUpload: false,
60
+ imageFolder: ''
61
+ }
62
+ });
63
+ $.extend($.summernote.plugins, {
64
+ 'imageAttributes': function (context) {
65
+ var self = this,
66
+ ui = $.summernote.ui,
67
+ $note = context.layoutInfo.note,
68
+ $editor = context.layoutInfo.editor,
69
+ $editable = context.layoutInfo.editable,
70
+ options = context.options,
71
+ lang = options.langInfo,
72
+ imageAttributesLimitation = '';
73
+ if (options.maximumImageFileSize) {
74
+ var unit = Math.floor(Math.log(options.maximumImageFileSize) / Math.log(1024));
75
+ var readableSize = (options.maximumImageFileSize/Math.pow(1024,unit)).toFixed(2) * 1 + ' ' + ' KMGTP'[unit] + 'B';
76
+ imageAttributesLimitation = '<small class="help-block note-help-block">' + lang.image.maximumFileSize + ' : ' + readableSize+'</small>';
77
+ }
78
+ context.memo('button.imageAttributes', function() {
79
+ var button = ui.button({
80
+ contents: options.imageAttributes.icon,
81
+ tooltip: lang.imageAttributes.tooltip,
82
+ click: function () {
83
+ context.invoke('imageAttributes.show');
84
+ }
85
+ });
86
+ return button.render();
87
+ });
88
+ this.initialize = function () {
89
+ var $container = options.dialogsInBody ? $(document.body) : $editor;
90
+ var timestamp = Date.now();
91
+ var body = '<ul class="nav note-nav nav-tabs note-nav-tabs">' +
92
+ ' <li class="active"><a href="#note-imageAttributes' + timestamp + '" data-toggle="tab">' + lang.imageAttributes.tabImage + '</a></li>' +
93
+ ' <li><a href="#note-imageAttributes-attributes' + timestamp + '" data-toggle="tab">' + lang.imageAttributes.tabAttributes + '</a></li>' +
94
+ ' <li><a href="#note-imageAttributes-link' + timestamp + '" data-toggle="tab">' + lang.imageAttributes.tabLink + '</a></li>';
95
+ if (options.imageAttributes.disableUpload == false) {
96
+ body += ' <li><a href="#note-imageAttributes-upload' + timestamp + '" data-toggle="tab">' + lang.imageAttributes.tabUpload + '</a></li>';
97
+ }
98
+ body += '</ul>' +
99
+ '<div class="tab-content note-tab-content">' +
100
+ // Tab 2
101
+ ' <div class="tab-pane note-tab-pane" id="note-imageAttributes-attributes' + timestamp + '">' +
102
+ ' <div class="note-form-group form-group note-group-imageAttributes-class">' +
103
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.class + '</label>' +
104
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
105
+ ' <input class="note-imageAttributes-class form-control note-form-control note-input" type="text">' +
106
+ ' </div>' +
107
+ ' </div>' +
108
+ ' <div class="note-form-group form-group note-group-imageAttributes-style">' +
109
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.style + '</label>' +
110
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
111
+ ' <input class="note-imageAttributes-style form-control note-form-control note-input" type="text">' +
112
+ ' </div>' +
113
+ ' </div>' +
114
+ ' <div class="note-form-group form-group note-group-imageAttributes-role">' +
115
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.role + '</label>' +
116
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
117
+ ' <input class="note-imageAttributes-role form-control note-form-control note-input" type="text">' +
118
+ ' </div>' +
119
+ ' </div>' +
120
+ ' </div>' +
121
+ // Tab 3
122
+ ' <div class="tab-pane note-tab-pane" id="note-imageAttributes-link' + timestamp + '">' +
123
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-href">' +
124
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkHref + '</label>' +
125
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
126
+ ' <input class="note-imageAttributes-link-href form-control note-form-control note-input" type="text">' +
127
+ ' </div>' +
128
+ ' </div>' +
129
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-target">' +
130
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkTarget + '</label>' +
131
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
132
+ ' <input class="note-imageAttributes-link-target form-control note-form-control note-input" type="text">' +
133
+ ' </div>' +
134
+ ' <small class="help-block note-help-block text-right">' + lang.imageAttributes.linkTargetInfo + '</small>' +
135
+ ' </div>' +
136
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-class">' +
137
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkClass + '</label>' +
138
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
139
+ ' <input class="note-imageAttributes-link-class form-control note-form-control note-input" type="text">' +
140
+ ' </div>' +
141
+ ' </div>' +
142
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-style">' +
143
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkStyle + '</label>' +
144
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
145
+ ' <input class="note-imageAttributes-link-style form-control note-form-control note-input" type="text">' +
146
+ ' </div>' +
147
+ ' </div>' +
148
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-rel">' +
149
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkRel + '</label>' +
150
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
151
+ ' <input class="note-imageAttributes-link-rel form-control note-form-control note-input" type="text">' +
152
+ ' </div>' +
153
+ ' <small class="help-block note-help-block text-right">' + lang.imageAttributes.linkRelInfo + '</small>' +
154
+ ' </div>' +
155
+ ' <div class="note-form-group form-group note-group-imageAttributes-link-role">' +
156
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.linkRole + '</label>' +
157
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
158
+ ' <input class="note-imageAttributes-link-role form-control note-form-control note-input" type="text">' +
159
+ ' </div>' +
160
+ ' </div>' +
161
+ ' </div>';
162
+ if (options.imageAttributes.disableUpload == false) {
163
+ // Tab 4
164
+ body += ' <div class="tab-pane note-tab-pane" id="note-imageAttributes-upload' + timestamp + '">' +
165
+ ' <label class="control-label note-form-label col-xs-3">' + lang.imageAttributes.upload + '</label>' +
166
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
167
+ ' <input class="note-imageAttributes-input form-control note-form-control note-input" type="file" name="files" accept="image/*" multiple="multiple" />' +
168
+ imageAttributesLimitation +
169
+ ' </div>' +
170
+ ' </div>';
171
+ }
172
+ // Tab 1
173
+ body += ' <div class="tab-pane note-tab-pane fade in active" id="note-imageAttributes' + timestamp + '">' +
174
+ ' <div class="note-form-group form-group note-group-imageAttributes-url">' +
175
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.src + '</label>' +
176
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
177
+ ' <input class="note-imageAttributes-src form-control note-form-control note-input" type="text" />' +
178
+ // ' <span class="input-group-btn">' +
179
+ // ' <button class="btn btn-default class="note-imageAttributes-browse">' + lang.imageAttributes.browse + '</button>' +
180
+ // ' </span>' +
181
+ ' </div>' +
182
+ ' </div>' +
183
+ ' <div class="note-form-group form-group note-group-imageAttributes-title">' +
184
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.title + '</label>' +
185
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
186
+ ' <input class="note-imageAttributes-title form-control note-form-control note-input" type="text" />' +
187
+ ' </div>' +
188
+ ' </div>' +
189
+ ' <div class="note-form-group form-group note-group-imageAttributes-alt">' +
190
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.alt + '</label>' +
191
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
192
+ ' <input class="note-imageAttributes-alt form-control note-form-control note-input" type="text" />' +
193
+ ' </div>' +
194
+ ' </div>' +
195
+ ' <div class="note-form-group form-group note-group-imageAttributes-dimensions">' +
196
+ ' <label class="control-label note-form-label col-sm-3">' + lang.imageAttributes.dimensions + '</label>' +
197
+ ' <div class="input-group note-input-group col-xs-12 col-sm-9">' +
198
+ ' <input class="note-imageAttributes-width form-control note-form-control note-input" type="text" />' +
199
+ ' <span class="input-group-addon note-input-group-addon">x</span>' +
200
+ ' <input class="note-imageAttributes-height form-control note-form-control note-input" type="text" />' +
201
+ ' </div>' +
202
+ ' </div>' +
203
+ ' </div>' +
204
+ '</div>';
205
+ this.$dialog=ui.dialog({
206
+ title: lang.imageAttributes.dialogTitle,
207
+ body: body,
208
+ footer: '<button href="#" class="btn btn-primary note-btn note-btn-primary note-imageAttributes-btn">' + lang.imageAttributes.editBtn + '</button>'
209
+ }).render().appendTo($container);
210
+ };
211
+ this.destroy = function () {
212
+ ui.hideDialog(this.$dialog);
213
+ this.$dialog.remove();
214
+ };
215
+ this.bindEnterKey = function ($input,$btn) {
216
+ $input.on('keypress', function (e) {
217
+ if (e.keyCode === 13) $btn.trigger('click');
218
+ });
219
+ };
220
+ this.bindLabels = function () {
221
+ self.$dialog.find('.form-control:first').focus().select();
222
+ self.$dialog.find('label').on('click', function () {
223
+ $(this).parent().find('.form-control:first').focus();
224
+ });
225
+ };
226
+ this.show = function () {
227
+ var $img = $($editable.data('target'));
228
+ var imgInfo = {
229
+ imgDom: $img,
230
+ title: $img.attr('title'),
231
+ src: $img.attr('src'),
232
+ alt: $img.attr('alt'),
233
+ width: $img.attr('width'),
234
+ height: $img.attr('height'),
235
+ role: $img.attr('role'),
236
+ class: $img.attr('class'),
237
+ style: $img.attr('style'),
238
+ imgLink: $($img).parent().is("a") ? $($img).parent() : null
239
+ };
240
+ this.showImageAttributesDialog(imgInfo).then( function (imgInfo) {
241
+ ui.hideDialog(self.$dialog);
242
+ var $img = imgInfo.imgDom;
243
+ if (options.imageAttributes.removeEmpty) {
244
+ if (imgInfo.alt) $img.attr('alt', imgInfo.alt); else $img.removeAttr('alt');
245
+ if (imgInfo.width) $img.attr('width', imgInfo.width); else $img.removeAttr('width');
246
+ if (imgInfo.height) $img.attr('height',imgInfo.height); else $img.removeAttr('height');
247
+ if (imgInfo.title) $img.attr('title', imgInfo.title); else $img.removeAttr('title');
248
+ if (imgInfo.src) $img.attr('src', imgInfo.src); else $img.attr('src', '#');
249
+ if (imgInfo.class) $img.attr('class', imgInfo.class); else $img.removeAttr('class');
250
+ if (imgInfo.style) $img.attr('style', imgInfo.style); else $img.removeAttr('style');
251
+ if (imgInfo.role) $img.attr('role', imgInfo.role); else $img.removeAttr('role');
252
+ } else {
253
+ if (imgInfo.src) $img.attr('src', imgInfo.src); else $img.attr('src', '#');
254
+ $img.attr('alt', imgInfo.alt);
255
+ $img.attr('width', imgInfo.width);
256
+ $img.attr('height', imgInfo.height);
257
+ $img.attr('title', imgInfo.title);
258
+ $img.attr('class', imgInfo.class);
259
+ $img.attr('style', imgInfo.style);
260
+ $img.attr('role', imgInfo.role);
261
+ }
262
+ if($img.parent().is("a")) $img.unwrap();
263
+ if (imgInfo.linkHref) {
264
+ var linkBody = '<a';
265
+ if (imgInfo.linkClass) linkBody += ' class="' + imgInfo.linkClass + '"';
266
+ if (imgInfo.linkStyle) linkBody += ' style="' + imgInfo.linkStyle + '"';
267
+ linkBody += ' href="' + imgInfo.linkHref + '" target="' + imgInfo.linkTarget + '"';
268
+ if (imgInfo.linkRel) linkBody += ' rel="' + imgInfo.linkRel + '"';
269
+ if (imgInfo.linkRole) linkBody += ' role="' + imgInfo.linkRole + '"';
270
+ linkBody += '></a>';
271
+ $img.wrap(linkBody);
272
+ }
273
+ $note.val(context.invoke('code'));
274
+ $note.change();
275
+ });
276
+ };
277
+ this.showImageAttributesDialog = function (imgInfo) {
278
+ return $.Deferred( function (deferred) {
279
+ var $imageTitle = self.$dialog.find('.note-imageAttributes-title'),
280
+ $imageInput = self.$dialog.find('.note-imageAttributes-input'),
281
+ $imageSrc = self.$dialog.find('.note-imageAttributes-src'),
282
+ $imageAlt = self.$dialog.find('.note-imageAttributes-alt'),
283
+ $imageWidth = self.$dialog.find('.note-imageAttributes-width'),
284
+ $imageHeight = self.$dialog.find('.note-imageAttributes-height'),
285
+ $imageClass = self.$dialog.find('.note-imageAttributes-class'),
286
+ $imageStyle = self.$dialog.find('.note-imageAttributes-style'),
287
+ $imageRole = self.$dialog.find('.note-imageAttributes-role'),
288
+ $linkHref = self.$dialog.find('.note-imageAttributes-link-href'),
289
+ $linkTarget = self.$dialog.find('.note-imageAttributes-link-target'),
290
+ $linkClass = self.$dialog.find('.note-imageAttributes-link-class'),
291
+ $linkStyle = self.$dialog.find('.note-imageAttributes-link-style'),
292
+ $linkRel = self.$dialog.find('.note-imageAttributes-link-rel'),
293
+ $linkRole = self.$dialog.find('.note-imageAttributes-link-role'),
294
+ $editBtn = self.$dialog.find('.note-imageAttributes-btn');
295
+ $linkHref.val();
296
+ $linkClass.val();
297
+ $linkStyle.val();
298
+ $linkRole.val();
299
+ $linkTarget.val();
300
+ $linkRel.val();
301
+ if (imgInfo.imgLink) {
302
+ $linkHref.val(imgInfo.imgLink.attr('href'));
303
+ $linkClass.val(imgInfo.imgLink.attr('class'));
304
+ $linkStyle.val(imgInfo.imgLink.attr('style'));
305
+ $linkRole.val(imgInfo.imgLink.attr('role'));
306
+ $linkTarget.val(imgInfo.imgLink.attr('target'));
307
+ $linkRel.val(imgInfo.imgLink.attr('rel'));
308
+ }
309
+ ui.onDialogShown(self.$dialog, function () {
310
+ context.triggerEvent('dialog.shown');
311
+ $imageInput.replaceWith(
312
+ $imageInput.clone().on('change', function () {
313
+ var callbacks = options.callbacks;
314
+ if (callbacks.onImageUpload) {
315
+ context.triggerEvent('image.upload',this.files[0]);
316
+ } else {
317
+ readFileAsDataURL(this.files[0]).then( function (dataURL) {
318
+ $imageSrc.val(dataURL);
319
+ }).fail( function () {
320
+ context.triggerEvent('image.upload.error');
321
+ });
322
+ }
323
+ }).val('')
324
+ );
325
+ $editBtn.click( function (e) {
326
+ e.preventDefault();
327
+ deferred.resolve({
328
+ imgDom: imgInfo.imgDom,
329
+ title: $imageTitle.val(),
330
+ src: $imageSrc.val(),
331
+ alt: $imageAlt.val(),
332
+ width: $imageWidth.val(),
333
+ height: $imageHeight.val(),
334
+ class: $imageClass.val(),
335
+ style: $imageStyle.val(),
336
+ role: $imageRole.val(),
337
+ linkHref: $linkHref.val(),
338
+ linkTarget: $linkTarget.val(),
339
+ linkClass: $linkClass.val(),
340
+ linkStyle: $linkStyle.val(),
341
+ linkRel: $linkRel.val(),
342
+ linkRole: $linkRole.val()
343
+ }).then(function (img) {
344
+ context.triggerEvent('change', $editable.html());
345
+ });
346
+ });
347
+ $imageTitle.val(imgInfo.title);
348
+ $imageSrc.val(imgInfo.src);
349
+ $imageAlt.val(imgInfo.alt);
350
+ $imageWidth.val(imgInfo.width);
351
+ $imageHeight.val(imgInfo.height);
352
+ $imageClass.val(imgInfo.class);
353
+ $imageStyle.val(imgInfo.style);
354
+ $imageRole.val(imgInfo.role);
355
+ self.bindEnterKey($editBtn);
356
+ self.bindLabels();
357
+ });
358
+ ui.onDialogHidden(self.$dialog, function () {
359
+ $editBtn.off('click');
360
+ if (deferred.state() === 'pending') deferred.reject();
361
+ });
362
+ ui.showDialog(self.$dialog);
363
+ });
364
+ };
365
+ }
366
+ });
367
+ }));
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: summernote-ext-image-attributes-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.10.0
5
+ platform: ruby
6
+ authors:
7
+ - Dennis Suitters
8
+ - Mohamed Ziata
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-05-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: railties
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '3.1'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '3.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: gem-release
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ description: "\n This gem packages the extencion summernote-ext-image-attributes
71
+ of Summernote editor\n for Rails' assets pipeline\n "
72
+ email:
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE
83
+ - MAINTAIN.md
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/summernote-ext-image-attributes-rails.rb
89
+ - lib/summernote-ext-image-attributes-rails/engine.rb
90
+ - lib/summernote-ext-image-attributes-rails/railtie.rb
91
+ - lib/summernote-ext-image-attributes-rails/version.rb
92
+ - summernote-ext-addclass-rails.gemspec
93
+ - vendor/assets/javascripts/summernote-ext-image-attributes/index.js
94
+ - vendor/assets/javascripts/summernote-ext-image-attributes/summernote-ext-image-attributes.js
95
+ homepage: https://github.com/WaKeMaTTa/summernote-ext-image-attributes-rails
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.7.6
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: Gemify the summernote extension called "summernote-image-attributes" for
119
+ Rails >= 3.1
120
+ test_files: []