spud_core 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ //= require codemirror
2
+ //= require codemirror/modes/markdown
1
3
 
2
4
  spud.admin.editor = {};
3
5
 
@@ -40,41 +42,93 @@ spud.admin.editor = {};
40
42
 
41
43
  var validFormats = "p,h1,h2,h3,h4,h5,h6";
42
44
 
43
- theme_advanced_blockformats :
44
- editor.init = function(){
45
- editor.initWithOptions({});
46
- };
47
45
 
48
- editor.initWithOptions = function(options){
46
+ editor.init = function(options) {
47
+ editor.monitorFormatters();
48
+ options = options || {};
49
49
  var selector = options.selector || 'textarea.tinymce';
50
+ $(selector).each(function() {
51
+ var $this = $(this);
52
+ var dataFormat = $this.attr('data-format');
53
+ switch(dataFormat) {
54
+ case 'Markdown':
55
+ editor.initCodeMirrorWithOptions(this,'markdown', options || {});
56
+ break;
57
+ case 'HTML':
58
+ default:
59
+ editor.initMCEWithOptions(this, options || {});
60
+ };
61
+
62
+
63
+ });
64
+
65
+ };
66
+
67
+ editor.monitorFormatters = function() {
68
+ $('select[data-formatter]').off('onchange');
69
+ $('select[data-formatter]').change(editor.formatterChanged);
70
+ };
71
+
72
+ editor.formatterChanged = function() {
73
+ var formatId = $(this).attr('data-formatter');
74
+ editor.unload('#' + formatId);
75
+ $('#' + formatId).attr('data-format',$(this).val());
76
+ editor.init({selector: '#' + formatId});
77
+ };
78
+
79
+ editor.initMCEWithOptions = function(element, options){
80
+
50
81
  var theme = options.theme || 'advanced';
51
82
  var height = options.height || 400;
52
- $(selector).each(function() {
53
- $(this).tinymce({
54
- theme: theme,
55
- plugins: registeredPlugins.join(','),
56
- theme_advanced_toolbar_location: "top",
57
- theme_advanced_buttons1: registeredButtons[0].join(','),
58
- theme_advanced_buttons2: registeredButtons[1].join(','),
59
- theme_advanced_buttons3: registeredButtons[2].join(','),
60
- theme_advanced_buttons4: registeredButtons[3].join(','),
61
- theme_advanced_toolbar_align: 'left',
62
- theme_advanced_blockformats: validFormats,
63
- convert_urls: false,
64
- valid_elements: validElements,
65
- width: $(this).width(),
66
- height: height
67
- });
83
+
84
+ $(element).tinymce({
85
+ theme: theme,
86
+ plugins: registeredPlugins.join(','),
87
+ theme_advanced_toolbar_location: "top",
88
+ theme_advanced_buttons1: registeredButtons[0].join(','),
89
+ theme_advanced_buttons2: registeredButtons[1].join(','),
90
+ theme_advanced_buttons3: registeredButtons[2].join(','),
91
+ theme_advanced_buttons4: registeredButtons[3].join(','),
92
+ theme_advanced_toolbar_align: 'left',
93
+ theme_advanced_blockformats: validFormats,
94
+ convert_urls: false,
95
+ valid_elements: validElements,
96
+ width: $(element).width(),
97
+ height: height
68
98
  });
69
99
 
100
+
101
+ };
102
+
103
+ var codeMirrors = [];
104
+ editor.initCodeMirrorWithOptions = function(element, format, options) {
105
+ var editor = CodeMirror.fromTextArea(element, {
106
+ mode: 'markdown',
107
+ lineNumbers: true,
108
+ theme: "default",
109
+ extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"}
110
+ });
111
+ codeMirrors.push(editor);
112
+
113
+ $(element).attr('code-mirror-id',codeMirrors.length-1);
70
114
  };
71
115
 
72
116
  editor.unload = function(selectorOptional) {
73
117
  var selector = selectorOptional || 'textarea.tinymce';
74
- $(selector).each(function() {$(this).tinymce().execCommand('mceRemoveControl',false,this.id);});
118
+ $(selector).each(function() {
119
+ var $this = $(this);
120
+ if($this.attr('code-mirror-id')) {
121
+ codeMirrors[parseInt($this.attr('code-mirror-id'),10)].toTextArea();
122
+ codeMirrors[parseInt($this.attr('code-mirror-id'),10)] = null;
123
+ $this.removeAttr('code-mirror-id');
124
+ }
125
+ tinyMCE.execCommand('mceRemoveControl',false,this.id);
126
+ });
75
127
 
76
128
  };
77
129
 
130
+
131
+
78
132
  editor.registerPlugin = function(pluginName){
79
133
  if($.inArray(registeredPlugins, pluginName) < 0){
80
134
  registeredPlugins.push(pluginName);
@@ -2,6 +2,7 @@
2
2
  *= require bootstrap/css/bootstrap
3
3
  *= require datepicker/css/datepicker
4
4
  *= require jquery-ui/css/flick/jquery-ui-1.9.1.custom
5
+ *= require codemirror/themes/night
5
6
  *= require_self
6
7
  */
7
8
 
@@ -471,3 +472,9 @@ form input.full-width {
471
472
  height:10px;
472
473
  bottom:10px;
473
474
  }
475
+
476
+ /* Modal Dialogs
477
+ ---------------*/
478
+ #modal_window .form-actions-no-modal{
479
+ display: none;
480
+ }
@@ -5,6 +5,10 @@
5
5
  <%=form_for @user,:url => spud_admin_user_path(:id => @user.id),:html=>{:class=>"form-horizontal"} do |f|%>
6
6
  <%=render :partial => "form",:locals => {:f => f}%>
7
7
 
8
+ <div class="form-actions form-actions-no-modal">
9
+ <%=f.submit "Save User", :class=>"btn btn-primary"%> or <%=link_to "cancel",request.referer,:class => "btn"%>
10
+ </div>
11
+
8
12
  <%end%>
9
13
 
10
14
 
@@ -5,6 +5,10 @@
5
5
  <%=form_for @user,:url => spud_admin_users_path(),:html=>{:class=>"form-horizontal"} do |f|%>
6
6
  <%=render :partial => "form",:locals => {:f => f}%>
7
7
 
8
+ <div class="form-actions form-actions-no-modal">
9
+ <%=f.submit "Save User", :class=>"btn btn-primary"%> or <%=link_to "cancel",request.referer,:class => "btn"%>
10
+ </div>
11
+
8
12
  <%end%>
9
13
 
10
14
 
@@ -31,6 +31,7 @@ module Spud
31
31
  "tiny_mce/themes/**/*",
32
32
  "tiny_mce/utils/*",
33
33
  "tiny_mce/langs/*",
34
+ 'tiny_mce/tiny_mce_popup.js',
34
35
  "tiny_mce/*",
35
36
  "spud/admin*"
36
37
  ]
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "0.9.7"
3
+ VERSION = "0.9.8"
4
4
  end
5
5
  end
@@ -1,39 +1,17 @@
1
1
  Connecting to database specified by database.yml
2
-  (65.4ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
3
-  (144.1ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
4
-  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
5
- Migrating to CreateSpudAdminPermissions (20111214161011)
6
-  (103.8ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
7
-  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20111214161011')
8
- Migrating to CreateSpudUsers (20111214161146)
9
-  (113.1ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
10
-  (117.7ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
11
-  (111.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
12
-  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20111214161146')
13
- Migrating to AddTimeZoneToSpudUser (20120327124229)
14
-  (149.1ms) ALTER TABLE `spud_users` ADD `time_zone` varchar(255)
15
-  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120327124229')
16
- Migrating to AddScopeToSpudAdminPermissions (20120328235431)
17
-  (130.5ms) ALTER TABLE `spud_admin_permissions` ADD `scope` varchar(255)
18
-  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120328235431')
19
- Migrating to CreateSpudUserSettings (20120329174000)
20
-  (105.9ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
21
-  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120329174000')
22
-  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
23
- Connecting to database specified by database.yml
24
-  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
25
-  (0.5ms) DROP DATABASE IF EXISTS `spud_core_test`
2
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
3
+  (22.6ms) DROP DATABASE IF EXISTS `spud_core_test`
26
4
   (0.3ms) CREATE DATABASE `spud_core_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
27
-  (54.2ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `scope` varchar(255)) ENGINE=InnoDB
28
-  (177.3ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
29
-  (191.0ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `time_zone` varchar(255)) ENGINE=InnoDB
30
-  (105.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
31
-  (100.1ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
32
-  (115.5ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
33
-  (127.3ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
34
-  (0.3ms) SELECT version FROM `schema_migrations`
35
-  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120329174000')
36
-  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161011')
37
-  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161146')
38
-  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20120327124229')
39
-  (0.3ms) INSERT INTO `schema_migrations` (version) VALUES ('20120328235431')
5
+  (23.9ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `scope` varchar(255)) ENGINE=InnoDB
6
+  (20.2ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
7
+  (9.2ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `time_zone` varchar(255)) ENGINE=InnoDB
8
+  (13.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
9
+  (11.9ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
10
+  (10.6ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
11
+  (15.6ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
12
+  (0.1ms) SELECT version FROM `schema_migrations`
13
+  (1.3ms) INSERT INTO `schema_migrations` (version) VALUES ('20120329174000')
14
+  (0.2ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161011')
15
+  (0.7ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161146')
16
+  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120327124229')
17
+  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120328235431')