scrivito_table_widget 0.5.7.rc2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d48f33865f6e775d054e1b01339da4e479606a5
4
- data.tar.gz: e448e36e1c8ffedd1a9fdaac9484a25dd649b47d
3
+ metadata.gz: ad1b6d8a8f9b3da895b9b3fba02b394e580aa5d0
4
+ data.tar.gz: 852d9095b40fdb8312ba7bb48d7f7ee69c8aeec1
5
5
  SHA512:
6
- metadata.gz: e08a3aaaf381cce6b3668fba7a293671ca4bd9c42f6e5721e8b0d8647d7852953bc1bff6cdd08eebd7d90daecf76e0e2a67e17a117a48f2c69ef347ee4ff06d3
7
- data.tar.gz: f4b56c8178cdab45da4c4792e1f323dddfb0a9e62c8aeed768ea860202955e036ab1deca4fb5c35509da3ea9d4c4be3edcd76f208a250fc53a61181a9fda1506
6
+ metadata.gz: 73e719e5a1c8fc49e7ee29b553b2eab09163a2c06dc65f56b862455d8b6faedcc93f7bd35b72652a4160292c7b67e5bdb4af44ae6e5994ac1da7cdedd47964ee
7
+ data.tar.gz: 7a287d771ebee0272453b886a5b133dd22347db12b4d381e636a16ff1a773a137ab99cacc54e90d86680e2dd446e3e791e77a6a282200030b4a35ebaffe7279e
data/README.md CHANGED
@@ -15,3 +15,11 @@ Add this line to your editing JavaScript manifest:
15
15
  Add this line to your application stylesheet manifest:
16
16
 
17
17
  *= require scrivito_table_widget
18
+
19
+ You have to activate the table editor in your select editor JavaScript:
20
+
21
+ ```js
22
+ scrivito.select_editor(function(element, editor) {
23
+ editor.use("table_editor");
24
+ });
25
+ ```
@@ -9,11 +9,19 @@
9
9
  var rows = 0;
10
10
  var cols = 0;
11
11
 
12
- $.fn.edittable = function(opts) {
12
+ $.fn.edittable = function(event) {
13
+ var elem = $(event.target);
14
+
15
+ // remove and save table if other instanze of table-widget is clicked
16
+ if(!elem.parents('table').is(activeTable)) {
17
+ $.fn.edittable.clear();
18
+ initialized = false;
19
+ }
20
+
13
21
  // initialize
14
- if(!initialized && !$(this).hasClass('table-responsive')) {
15
- activeTable = this.parents('table');
16
- cmsField = this.parents('[data-editor=table-editor]');
22
+ if(!initialized) {
23
+ activeTable = elem.parents('table');
24
+ cmsField = $(event.target).parents('.scrivito-table-editor');
17
25
 
18
26
  initialized = $.fn.edittable.initialize(cmsField, this);
19
27
  rows = $.fn.edittable.getRowCount();
@@ -25,19 +33,14 @@
25
33
  $.fn.edittable.bindKeys();
26
34
  }
27
35
 
28
- var elem = this;
29
-
30
- if($(this).get(0).tagName != "TD" && $(this).get(0).tagName != "TH") {
36
+ if($(elem).get(0).tagName != "TD" && $(elem).get(0).tagName != "TH") {
31
37
  elem = elem.parents('td, th');
32
38
  }
33
39
 
34
- // edit
35
- if($(elem).get(0) != undefined) {
36
- if($(elem).get(0).tagName == "TD" || $(elem).get(0).tagName == "TH") {
37
- activeElement = elem;
38
- cmsField.attr('contenteditable', true);
39
- $.fn.edittable.setButtonPositions();
40
- }
40
+ activeElement = elem;
41
+ cmsField.attr('contenteditable', true);
42
+ if(activeElement) {
43
+ $.fn.edittable.setButtonPositions();
41
44
  }
42
45
  };
43
46
 
@@ -62,8 +65,8 @@
62
65
  var width = activeElement.outerWidth();
63
66
  var height = activeElement.outerHeight();
64
67
 
65
- $('.table-buttons.top').css({ top: "-11px", left: (base.left - 11), width: width + 23});
66
- $('.table-buttons.edit').css({ top: (base.top - 12), left: (base.left - 5)});
68
+ $('.table-buttons.top').css({ top: "-12px", left: (base.left - 11), width: width + 23});
69
+ $('.table-buttons.edit').css({ top: (base.top - 12), left: (base.left + 6)});
67
70
  $('.table-buttons.left').css({ top: (base.top - 12), left: -17, height: height + 24});
68
71
  $('.table-buttons.bottom').css({ bottom: "-4px", left: (base.left + width/2 - 12)});
69
72
  $('.table-buttons.right').css({ top: (base.top + height/2 - 11), right: -23});
@@ -106,8 +109,10 @@
106
109
  }
107
110
 
108
111
  $.fn.edittable.save = function() {
109
- var text = activeTable.get(0).outerHTML;
110
- $(cmsField).scrivito('save', text);
112
+ if(activeTable) {
113
+ var text = activeTable.get(0).outerHTML;
114
+ $(cmsField).scrivito('save', text);
115
+ }
111
116
  }
112
117
 
113
118
  /****
@@ -163,38 +168,38 @@
163
168
  ****/
164
169
 
165
170
  $.fn.edittable.bindButtons = function() {
166
- $('.table-widget').find('.add-top').on('click', function() { $.fn.edittable.addTop(); });
167
- $('.table-widget').find('.add-bottom').on('click', function() { $.fn.edittable.addBottom(); });
168
- $('.table-widget').find('.add-left').on('click', function() { $.fn.edittable.addLeft(); });
169
- $('.table-widget').find('.add-right').on('click', function() { $.fn.edittable.addRight(); });
170
- $('.table-widget').find('.table-bold').on('click', function() { $.fn.edittable.bold(); });
171
- $('.table-widget').find('.table-italic').on('click', function() { $.fn.edittable.italic(); });
172
- $('.table-widget').find('.delete-row').on('click', function() { $.fn.edittable.removeRow(); });
173
- $('.table-widget').find('.delete-column').on('click', function() { $.fn.edittable.removeColumn(); });
174
- $('.table-widget').find('.stripe-table').on('click', function() { $.fn.edittable.tableStriped(); });
175
- $('.table-widget').find('.condence-table').on('click', function() { $.fn.edittable.tableCondensed(); });
176
- $('.table-widget').find('.hover-table').on('click', function() { $.fn.edittable.tableHover(); });
177
- $('.table-widget').find('.border-table').on('click', function() { $.fn.edittable.tableBorder(); });
178
- $('.table-widget').find('.first-column').on('click', function() { $.fn.edittable.firstColumn(); });
179
- $('.table-widget').find('.table-left').on('click', function() { $.fn.edittable.tableLeft(); });
180
- $('.table-widget').find('.table-center').on('click', function() { $.fn.edittable.tableCenter(); });
181
- $('.table-widget').find('.table-right').on('click', function() { $.fn.edittable.tableRight(); });
182
-
183
- $('.table-widget').find('.add-success').on('click', function() { $.fn.edittable.addSuccess(); });
184
- $('.table-widget').find('.add-info').on('click', function() { $.fn.edittable.addInfo(); });
185
- $('.table-widget').find('.add-warning').on('click', function() { $.fn.edittable.addWarning(); });
186
- $('.table-widget').find('.add-danger').on('click', function() { $.fn.edittable.addDanger(); });
187
-
188
- $('.table-widget').find('.edit-the-table').on('click', function() { $.fn.edittable.toggleTableOptions('.table-options.main'); });
189
- $('.table-widget').find('.edit-the-cell').on('click', function() { $.fn.edittable.toggleTableOptions('.table-buttons.edit'); });
190
-
191
- $('.table-widget').find('.add-left, .add-right').on('mouseover', function() { $.fn.edittable.addHoverVerticalAdd($(this)); });
192
- $('.table-widget').find('.add-top, .add-bottom').on('mouseover', function() { $.fn.edittable.addHoverHorizontalAdd($(this)); });
193
-
194
- $('.table-widget').find('.delete-column').on('mouseover', function() { $.fn.edittable.deleteHoverColumn($(this)); });
195
- $('.table-widget').find('.delete-row').on('mouseover', function() { $.fn.edittable.deleteHoverRow($(this)); });
196
-
197
- $('.table-widget').find('.add-left, .add-right, .add-top, .add-bottom, .delete-column, .delete-row').on('mouseout', function() { $.fn.edittable.resetHelperLine(); });
171
+ $(cmsField).parent().find('.add-top').on('click', function() { $.fn.edittable.addTop(); });
172
+ $(cmsField).parent().find('.add-bottom').on('click', function() { $.fn.edittable.addBottom(); });
173
+ $(cmsField).parent().find('.add-left').on('click', function() { $.fn.edittable.addLeft(); });
174
+ $(cmsField).parent().find('.add-right').on('click', function() { $.fn.edittable.addRight(); });
175
+ $(cmsField).parent().find('.table-bold').on('click', function() { $.fn.edittable.bold(); });
176
+ $(cmsField).parent().find('.table-italic').on('click', function() { $.fn.edittable.italic(); });
177
+ $(cmsField).parent().find('.delete-row').on('click', function() { $.fn.edittable.removeRow(); });
178
+ $(cmsField).parent().find('.delete-column').on('click', function() { $.fn.edittable.removeColumn(); });
179
+ $(cmsField).parent().find('.stripe-table').on('click', function() { $.fn.edittable.tableStriped(); });
180
+ $(cmsField).parent().find('.condence-table').on('click', function() { $.fn.edittable.tableCondensed(); });
181
+ $(cmsField).parent().find('.hover-table').on('click', function() { $.fn.edittable.tableHover(); });
182
+ $(cmsField).parent().find('.border-table').on('click', function() { $.fn.edittable.tableBorder(); });
183
+ $(cmsField).parent().find('.first-column').on('click', function() { $.fn.edittable.firstColumn(); });
184
+ $(cmsField).parent().find('.table-left').on('click', function() { $.fn.edittable.tableLeft(); });
185
+ $(cmsField).parent().find('.table-center').on('click', function() { $.fn.edittable.tableCenter(); });
186
+ $(cmsField).parent().find('.table-right').on('click', function() { $.fn.edittable.tableRight(); });
187
+
188
+ $(cmsField).parent().find('.add-success').on('click', function() { $.fn.edittable.addSuccess(); });
189
+ $(cmsField).parent().find('.add-info').on('click', function() { $.fn.edittable.addInfo(); });
190
+ $(cmsField).parent().find('.add-warning').on('click', function() { $.fn.edittable.addWarning(); });
191
+ $(cmsField).parent().find('.add-danger').on('click', function() { $.fn.edittable.addDanger(); });
192
+
193
+ $(cmsField).parent().find('.edit-the-table').on('click', function() { $.fn.edittable.toggleTableOptions('.table-options.main'); });
194
+ $(cmsField).parent().find('.edit-the-cell').on('click', function() { $.fn.edittable.toggleTableOptions('.table-buttons.edit'); });
195
+
196
+ $(cmsField).parent().find('.add-left, .add-right').on('mouseover', function() { $.fn.edittable.addHoverVerticalAdd($(this)); });
197
+ $(cmsField).parent().find('.add-top, .add-bottom').on('mouseover', function() { $.fn.edittable.addHoverHorizontalAdd($(this)); });
198
+
199
+ $(cmsField).parent().find('.delete-column').on('mouseover', function() { $.fn.edittable.deleteHoverColumn($(this)); });
200
+ $(cmsField).parent().find('.delete-row').on('mouseover', function() { $.fn.edittable.deleteHoverRow($(this)); });
201
+
202
+ $(cmsField).parent().find('.add-left, .add-right, .add-top, .add-bottom, .delete-column, .delete-row').on('mouseout', function() { $.fn.edittable.resetHelperLine(); });
198
203
  }
199
204
 
200
205
  /****
@@ -1,39 +1,28 @@
1
1
  (function($, App) {
2
2
  'use strict';
3
3
 
4
- $(function() {
5
- App.tableEditor = {
6
- // set selector for Editor
7
- selector: '[data-editor=table-editor]',
8
-
9
- // set function triggert on click
10
- clickFunction: function(cmsField) {
11
- cmsField.edittable();
12
- },
13
-
14
- blurFunction: function(cmsField) {
15
- var response = $.fn.edittable.clear();
16
- if(response != undefined) return $(response.cmsField).scrivito('save', response.text);
17
- }
18
- };
19
-
20
- // Set click event
21
- scrivito.on('load', function() {
22
- return $('body').on('click', '.table-widget', function(event) {
23
- if(scrivito.in_editable_view()) {
24
- tableEditor.clickFunction($(event.target));
25
- };
4
+ var table_editor = {
5
+ can_edit: function(element) {
6
+ return $(element).is('.scrivito-table-editor');
7
+ },
8
+ activate: function(element) {
9
+ $(element).on('click', function(event) {
10
+ $(element).edittable(event);
11
+ scrivito.editors.medium_editor.activate(element);
26
12
  event.stopPropagation();
27
13
  });
28
- });
29
14
 
30
- scrivito.on('load', function() {
31
- return $('body').on('click', function(event) {
32
- if(scrivito.in_editable_view()) {
33
- tableEditor.blurFunction($(event.target));
34
- };
15
+ $('body').on('click', function(event) {
16
+ if(!$(event.target).parents('.table-buttons').length && !$(event.target).parents('.table-options').length) {
17
+ var response = $.fn.edittable.clear();
18
+ if(response != undefined) return $(response.cmsField).scrivito('save', response.text);
19
+ }
35
20
  });
36
- });
21
+ }
22
+ };
23
+
24
+ scrivito.on('content', function() {
25
+ return scrivito.define_editor('toggle_button_editor', table_editor);
37
26
  });
38
27
 
39
- })(jQuery, this);
28
+ })(jQuery, this);
@@ -25,11 +25,12 @@
25
25
  }
26
26
 
27
27
  .table-buttons.edit {
28
- width: 245px;
28
+ width: auto;
29
+ z-index: 111113;
29
30
  }
30
31
 
31
32
  .table-options.main {
32
- width: 350px;
33
+ width: auto;
33
34
  }
34
35
 
35
36
  .table-buttons.edit div.alert-gray,
@@ -70,6 +71,7 @@
70
71
 
71
72
  .table-buttons.top {
72
73
  height: 25px;
74
+ z-index: 111112;
73
75
  }
74
76
 
75
77
  .table-buttons.top .add-left {
@@ -84,6 +86,7 @@
84
86
 
85
87
  .table-buttons.left {
86
88
  width: 25px;
89
+ z-index: 111112;
87
90
  }
88
91
 
89
92
  .table-buttons.left .add-top {
@@ -107,6 +110,7 @@
107
110
  .helper-line {
108
111
  position: absolute;
109
112
  display: none;
113
+ z-index: 100000;
110
114
  }
111
115
 
112
116
  .delete-marker td,
@@ -1,4 +1,5 @@
1
1
  /*
2
2
  *= require font-awesome
3
- *= require_tree ./scrivito_table_widget
3
+ *= require scrivito_table_widget/application
4
+ *= require scrivito_table_widget/editing
4
5
  */
@@ -1,13 +1,3 @@
1
- <% if widget.table.blank? %>
2
- <%= scrivito_tag(:div, widget, :table, data: {editor: 'create-new-table'}) do %>
3
- <div class="create-new-table">
4
- <div class="alert alert-info">
5
- There is no table present. Click this message to insert a new one.
6
- </div>
7
- </div>
8
- <% end %>
9
- <% else %>
10
- <div class="table-widget">
11
- <%= scrivito_tag(:div, widget, :table, data: {editor: 'table-editor'}, class: 'table-responsive')%>
12
- </div>
13
- <% end %>
1
+ <div class="table-widget">
2
+ <%= scrivito_tag(:div, widget, :table, class: 'table-responsive scrivito-table-editor') %>
3
+ </div>
@@ -1,3 +1,3 @@
1
1
  module ScrivitoTableWidget
2
- VERSION = "0.5.7.rc2"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrivito_table_widget
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7.rc2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scrivito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: scrivito
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -52,20 +38,6 @@ dependencies:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
41
  description: Scrivito Widget for a table.
70
42
  email:
71
43
  - support@scrivito.com
@@ -83,7 +55,6 @@ files:
83
55
  - app/assets/stylesheets/scrivito_table_widget.css
84
56
  - app/assets/stylesheets/scrivito_table_widget/application.css
85
57
  - app/assets/stylesheets/scrivito_table_widget/editing.css
86
- - app/assets/stylesheets/scrivito_table_widget/styles.css
87
58
  - app/models/table_widget.rb
88
59
  - app/views/table_widget/show.html.erb
89
60
  - app/views/table_widget/thumbnail.html.erb
@@ -91,7 +62,6 @@ files:
91
62
  - lib/scrivito_table_widget/engine.rb
92
63
  - lib/scrivito_table_widget/version.rb
93
64
  - lib/tasks/scrivito_table_widget_tasks.rake
94
- - scrivito/migrate/0_create_table_widget.rb
95
65
  homepage: https://www.scrivito.com
96
66
  licenses:
97
67
  - LGPL-3.0
@@ -107,9 +77,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
77
  version: '0'
108
78
  required_rubygems_version: !ruby/object:Gem::Requirement
109
79
  requirements:
110
- - - ">"
80
+ - - ">="
111
81
  - !ruby/object:Gem::Version
112
- version: 1.3.1
82
+ version: '0'
113
83
  requirements: []
114
84
  rubyforge_project:
115
85
  rubygems_version: 2.4.5
@@ -1,5 +0,0 @@
1
- /*
2
- *= require font-awesome
3
- *= require_tree .
4
- *= require_self
5
- */
@@ -1,13 +0,0 @@
1
- class CreateTableWidget < ::Scrivito::Migration
2
- def up
3
- Scrivito::ObjClass.create(
4
- name: 'TableWidget',
5
- type: 'publication',
6
- is_binary: false,
7
- title: 'TableWidget',
8
- attributes: [
9
- {name: "table", type: "html"}
10
- ],
11
- )
12
- end
13
- end