activeadmin-selleo-cms 0.0.47 → 0.0.48

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.
@@ -3,12 +3,27 @@
3
3
  For licensing, see LICENSE.html or http://ckeditor.com/license
4
4
  */
5
5
 
6
+ CKEDITOR.stylesSet.add( 'jips', [
7
+ // Block-level styles.
8
+ { name: 'Header 1', element: 'h1' },
9
+ { name: 'Header 2', element: 'h2' },
10
+ { name: 'Header 3', element: 'h3' },
11
+ { name: 'Header 4', element: 'h4' },
12
+ { name: 'Paragraph', element: 'p' },
13
+
14
+ // Inline styles.
15
+ { name: 'CSS Style', element: 'span', attributes: { 'class': 'my_style' } },
16
+ { name: 'Marker: Yellow', element: 'span', styles: { 'background-color': 'Yellow' } }
17
+ ]);
18
+
6
19
  CKEDITOR.editorConfig = function( config )
7
20
  {
8
21
  // Define changes to default configuration here. For example:
9
22
  // config.language = 'fr';
10
23
  // config.uiColor = '#AADC6E';
11
24
 
25
+ config.allowedContent = true;
26
+
12
27
  /* Filebrowser routes */
13
28
  // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
14
29
  config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
@@ -31,6 +46,8 @@ CKEDITOR.editorConfig = function( config )
31
46
  // The location of a script that handles file uploads.
32
47
  config.filebrowserUploadUrl = "/ckeditor/attachment_files";
33
48
 
49
+ config.extraPlugins = "inlinesave,formswidget";
50
+
34
51
  // Rails CSRF token
35
52
  config.filebrowserParams = function(){
36
53
  var csrf_token, csrf_param, meta,
@@ -72,75 +89,18 @@ CKEDITOR.editorConfig = function( config )
72
89
  return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
73
90
  };
74
91
 
75
- // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
76
- CKEDITOR.on( 'dialogDefinition', function( ev ){
77
- // Take the dialog name and its definition from the event data.
78
- var dialogName = ev.data.name;
79
- var dialogDefinition = ev.data.definition;
80
- var content, upload;
81
-
82
- if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
83
- content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
84
- upload = (content == null ? null : content.get('upload'));
85
-
86
- if (upload && upload.filebrowser['params'] == null) {
87
- upload.filebrowser['params'] = config.filebrowserParams();
88
- upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
89
- }
90
- }
91
-
92
- if (dialogName == 'link') {
93
- var linkInfoTab = dialogDefinition.getContents('info');
94
- var pageField = linkInfoTab.get('page');
95
-
96
- if (!pageField) {
97
- $.ajax({
98
- url: '/en.json',
99
- type: 'GET',
100
- async: false
101
- }).success(function(resp){
102
- linkInfoTab.add( {
103
- type : 'select',
104
- label : 'Page',
105
- id : 'page',
106
- name : 'page',
107
- items: resp,
108
- onChange: function(ev){
109
- var diag = CKEDITOR.dialog.getCurrent();
110
- var url = diag.getContentElement('info','url');
111
- var locale = $('[id*="lang"]:visible').find('input[name*="locale"]:hidden').val();
112
- url.setValue(ev.data.value.replace(':locale', locale));
113
- }
114
- });
115
- });
116
- }
117
- }
118
- });
119
-
120
- config.height = '200px';
121
- config.width = '800px';
122
-
123
- config.toolbar = 'Lite';
124
-
125
- config.forcePasteAsPlainText = true;
126
- config.fontSize_sizes = '12/12px;14/14px;18/18px;24/24px;30/30px;';
127
-
128
- /* Extra plugins */
129
- // works only with en, ru, uk locales
130
- config.extraPlugins = "embed,attachment";
131
-
132
- /* Toolbars */
133
- config.toolbar = 'Lite';
92
+ config.toolbar = 'Full';
134
93
 
135
94
  config.toolbar_Easy =
136
95
  [
137
- ['Source','-','Preview'],
138
- ['Cut','Copy','Paste','PasteText','PasteFromWord',],
96
+ ['Source','-','Preview', 'Save'],
97
+ ['Cut','Copy','Paste'],
139
98
  ['Undo','Redo','-','SelectAll','RemoveFormat'],
140
- ['Styles','Format'], ['Subscript', 'Superscript', 'TextColor'], ['Maximize','-','About'], '/',
99
+ ['Font', 'Styles', 'FontSize'],
100
+ ['Subscript', 'Superscript', 'TextColor'], ['Maximize','-','About'], '/',
101
+ ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
141
102
  ['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
142
- ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
143
- ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
103
+ ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash'],
144
104
  ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
145
105
  ];
146
106
 
@@ -176,7 +136,33 @@ CKEDITOR.editorConfig = function( config )
176
136
 
177
137
  config.toolbar_Header =
178
138
  [
179
- ['Bold'],
139
+ ['Bold']
180
140
  ];
181
141
 
182
- };
142
+ config.toolbar_Link =
143
+ [
144
+ ['Link', 'Unlink']
145
+ ];
146
+
147
+ config.stylesSet = 'jips';
148
+
149
+ // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
150
+ CKEDITOR.on( 'dialogDefinition', function( ev ){
151
+ // Take the dialog name and its definition from the event data.
152
+ var dialogName = ev.data.name;
153
+ var dialogDefinition = ev.data.definition;
154
+ var content, upload;
155
+
156
+ if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
157
+ content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
158
+ upload = (content == null ? null : content.get('upload'));
159
+
160
+ if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {
161
+ upload.filebrowser['params'] = config.filebrowserParams();
162
+ upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
163
+ }
164
+ }
165
+ });
166
+ };
167
+
168
+
@@ -0,0 +1,49 @@
1
+ CKEDITOR.dialog.add( 'formswidgetDialog', function ( editor ) {
2
+ var items = [];
3
+ $.ajax({
4
+ url: '/admin/forms.json',
5
+ type: 'GET',
6
+ async: false,
7
+ success: function(resp){
8
+ items = [$.map(resp, function(obj, idx) {
9
+ return [obj.title, obj.id]
10
+ })]
11
+ }
12
+ });
13
+
14
+ return {
15
+ title: 'Insert form',
16
+ minWidth: 400,
17
+ minHeight: 70,
18
+
19
+ contents: [
20
+ {
21
+ id: 'tab-select',
22
+ label: 'Select form',
23
+ elements: [
24
+ {
25
+ type: 'select',
26
+ id: 'form_id',
27
+ label: 'Select a form to insert',
28
+ items: items
29
+ }
30
+ ]
31
+ }
32
+ ],
33
+
34
+ onOk: function() {
35
+ var dialog = this;
36
+ var form = editor.document.createElement('form');
37
+
38
+ var select = dialog.getContentElement('tab-select', 'form_id');
39
+ var input = select.getInputElement().$;
40
+
41
+ form.setAttribute('data-form-id', dialog.getValueOf('tab-select', 'form_id'));
42
+ form.setAttribute('style', 'border: 1px dotted #990000');
43
+
44
+ form.appendText( 'FORM: ' + input.options[ input.selectedIndex ].text );
45
+
46
+ editor.insertElement(form);
47
+ }
48
+ };
49
+ });
@@ -0,0 +1,18 @@
1
+ (function() {
2
+ var pluginName = 'formswidget';
3
+
4
+ CKEDITOR.plugins.add( pluginName, {
5
+ icons: 'form',
6
+ init: function( editor ) {
7
+ CKEDITOR.dialog.add( 'formswidgetDialog', this.path + 'dialogs/formswidget.js' );
8
+
9
+ editor.addCommand('formswidgetDialog', new CKEDITOR.dialogCommand('formswidgetDialog') );
10
+
11
+ editor.ui.addButton( 'form', {
12
+ label: 'Insert form',
13
+ command: 'formswidgetDialog',
14
+ toolbar: 'insert'
15
+ });
16
+ }
17
+ });
18
+ })();
@@ -16,7 +16,8 @@
16
16
  type: 'PUT',
17
17
  data: {
18
18
  'section': {
19
- 'body': editor.getData()
19
+ 'body': editor.getData(),
20
+ 'locale': $('html').attr('lang')
20
21
  }
21
22
  }
22
23
  });
@@ -30,7 +31,7 @@
30
31
 
31
32
  // Register a plugin named "save".
32
33
  CKEDITOR.plugins.add( pluginName, {
33
- icons: 'save', // %REMOVE_LINE_CORE%
34
+ icons: 'formswidget', // %REMOVE_LINE_CORE%
34
35
  init: function( editor ) {
35
36
 
36
37
  editor.addCommand( pluginName, saveCmd );
@@ -0,0 +1,36 @@
1
+ CKEDITOR.on( 'instanceCreated', function( event ) {
2
+ var editor = event.editor,
3
+ element = editor.element;
4
+
5
+ if ( element.getAttribute('data-toolbar') == 'Save' ) {
6
+ editor.on( 'configLoaded', function() {
7
+ editor.config.plugins = 'toolbar,floatingspace';
8
+ editor.config.extraPlugins = 'inlinesave';
9
+ });
10
+ } else if ( element.getAttribute('data-toolbar') == 'Header' ) {
11
+ editor.on( 'configLoaded', function() {
12
+ editor.config.plugins = 'toolbar,floatingspace,basicstyles';
13
+ editor.config.extraPlugins = 'inlinesave';
14
+ });
15
+ } else if ( element.getAttribute('data-toolbar') == 'Link' ) {
16
+ editor.on( 'configLoaded', function() {
17
+ editor.config.plugins = 'toolbar,floatingspace,basicstyles,link';
18
+ editor.config.extraPlugins = 'inlinesave';
19
+ });
20
+ } else if ( element.getAttribute('data-toolbar') == 'Lite' ) {
21
+ editor.on( 'configLoaded', function() {
22
+ editor.config.plugins = "toolbar,floatingspace,basicstyles,stylescombo";
23
+ });
24
+ } else {
25
+ editor.on( 'configLoaded', function() {
26
+ editor.config.plugins = "dialogui,dialog,about,a11yhelp,dialogadvtab,basicstyles,bidi,blockquote,clipboard,button,panelbutton,panel,floatpanel,colorbutton,colordialog,templates,menu,contextmenu,div,resize,toolbar,elementspath,list,indent,enterkey,entities,popup,filebrowser,find,fakeobjects,flash,floatingspace,listblock,richcombo,font,format,htmlwriter,horizontalrule,iframe,wysiwygarea,image,smiley,justify,link,liststyle,magicline,maximize,newpage,pagebreak,pastetext,pastefromword,preview,print,removeformat,save,selectall,showblocks,showborders,sourcearea,specialchar,menubutton,scayt,stylescombo,tab,table,tabletools,undo,wsc";
27
+ });
28
+ }
29
+
30
+ // editor.config.toolbarGroups = [
31
+ // { name: 'editing', groups: [ 'document', 'basicstyles', 'stylescombo', 'link' ] }
32
+ // ];
33
+
34
+ });
35
+
36
+ // plugins "dialogui,dialog,about,a11yhelp,dialogadvtab,basicstyles,bidi,blockquote,clipboard,button,panelbutton,panel,floatpanel,colorbutton,colordialog,templates,menu,contextmenu,div,resize,toolbar,elementspath,list,indent,enterkey,entities,popup,filebrowser,find,fakeobjects,flash,floatingspace,listblock,richcombo,font,forms,format,htmlwriter,horizontalrule,iframe,wysiwygarea,image,smiley,justify,link,liststyle,magicline,maximize,newpage,pagebreak,pastetext,pastefromword,preview,print,removeformat,save,selectall,showblocks,showborders,sourcearea,specialchar,menubutton,scayt,stylescombo,tab,table,tabletools,undo,wsc"
@@ -77,7 +77,7 @@ module ActiveadminSelleoCms
77
77
  section_definition = sectionable.layout.find_section(name) if sectionable and sectionable.respond_to? :layout
78
78
  if section_definition
79
79
  if section_definition.text?
80
- render_body
80
+ render
81
81
  elsif section_definition.image?
82
82
  image ? image.url : ""
83
83
  end
@@ -34,9 +34,8 @@
34
34
  </ol>
35
35
  <% end %>
36
36
 
37
- <%= button_to_function "Print", "$('##{dom_id(form)}').printElement({printMode:'popup'});", class: 'print', title: 'Print' %>
37
+ <%= button_to_function "Print", "print(#{form.id}, '#{dom_id(form)}')", class: 'print', title: 'Print' %>
38
38
  <%= button_to_function "Download PDF", "downloadPDF(#{form.id}, '#{dom_id(form)}')", class: 'save', title: 'Download PDF' %>
39
- <%= button_to_function "Download", "download(#{form.id}, '#{dom_id(form)}')", class: 'save', title: 'Download' %>
40
39
  <%= button_to_function "Send to JIPS", "deliver(#{form.id}, '#{dom_id(form)}')", class: 'send' %>
41
40
 
42
41
  <script>
@@ -48,8 +47,8 @@
48
47
  window.location='/forms/'+form_id+'/download.pdf?form_uuid='+localStorage[form_dom_id];
49
48
  }
50
49
 
51
- function download(form_id, form_dom_id){
52
- window.location='/forms/'+form_id+'/download?form_uuid='+localStorage[form_dom_id];
50
+ function print(form_id, form_dom_id){
51
+ window.open('/forms/'+form_id+'/download?form_uuid='+localStorage[form_dom_id]);
53
52
  }
54
53
 
55
54
  function deliver(form_id, form_dom_id) {
@@ -1 +1,5 @@
1
- <%= render partial: 'download'%>
1
+ <%= render partial: 'download'%>
2
+
3
+ <script>
4
+ window.print();
5
+ </script>
@@ -1,3 +1,3 @@
1
1
  module ActiveadminSelleoCms
2
- VERSION = "0.0.47"
2
+ VERSION = "0.0.48"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-selleo-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.47
4
+ version: 0.0.48
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-09 00:00:00.000000000 Z
12
+ date: 2013-07-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: 2.2.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: jquery-ui-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 4.0.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.1
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: activeadmin
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -428,8 +444,12 @@ files:
428
444
  - app/assets/images/activeadmin-selleo-cms/Jcrop.gif
429
445
  - app/assets/javascripts/active_admin.js
430
446
  - app/assets/javascripts/ckeditor/config.js
447
+ - app/assets/javascripts/ckeditor/toolbars.js
431
448
  - app/assets/javascripts/ckeditor/plugins/inlinesave/icons/save.png
432
449
  - app/assets/javascripts/ckeditor/plugins/inlinesave/plugin.js
450
+ - app/assets/javascripts/ckeditor/plugins/formswidget/dialogs/formswidget.js
451
+ - app/assets/javascripts/ckeditor/plugins/formswidget/icons/formswidget.png
452
+ - app/assets/javascripts/ckeditor/plugins/formswidget/plugin.js
433
453
  - app/assets/javascripts/activeadmin-selleo-cms/jquery.Jcrop.js
434
454
  - app/assets/javascripts/activeadmin-selleo-cms/jquery-ui-timepicker-addon.js
435
455
  - app/assets/javascripts/activeadmin-selleo-cms/jquery.printElement.js