tb_core 1.3.6 → 1.3.7

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: f6bf453f0beae57a1071c09c8d17bb2af451d8f1
4
- data.tar.gz: 24fcc7c6774cf0957886dd28675a5fa9fd8cdc6f
3
+ metadata.gz: 9e447994850df42f2d94bace466371bcc952a6bb
4
+ data.tar.gz: 3d2363bf502fdfc50ce228186bfd403ab7401498
5
5
  SHA512:
6
- metadata.gz: 6e82de4ddd86404ab8a03bce734b7bc6a5f57e63e1528d9b9c4e58b687cb0eee48bb41f6921997463e68d7062bc09f76f52cd4b3bdfebb544ba75e3db32b33e5
7
- data.tar.gz: ed7a6ac11107b0602eb0d21a50af16662657aa0462e7a288acb5f00c9dda9c78e364478d45e9d0b6a93438f2629fb7bb92a401df7a57da0978ddeca17586defe
6
+ metadata.gz: 7f5a259c7068627afd84e7fccb1e45704660d5db6e814e8295a20d2d5318b86f30f92750e1602ee805700a2ca2abcac5ec3074fc300a48eae176e84060a3da9c
7
+ data.tar.gz: 53bb1073d4757b407f1d2a0ddffbff390c45a4c2b00579eabb09e5b9502b83e3f14badb3b5500434afc68bb198419e078a789b2e0cd745f158f14cc31c00173f
@@ -1,5 +1,4 @@
1
1
  //= require jquery
2
- //= require tinymce-jquery
3
2
  //= require bootstrap-sprockets
4
3
  //= require ../../tb_core
5
4
  //= require_self
@@ -31,7 +30,6 @@ $(document).ready(function() {
31
30
  remote: url +".js",
32
31
  show:true
33
32
  });
34
-
35
33
  return false;
36
34
  });
37
35
 
@@ -3,6 +3,8 @@ spud.admin.editor = {};
3
3
  (function(){
4
4
 
5
5
  var editor = spud.admin.editor;
6
+
7
+ editor.tinymce = {loaded:false};
6
8
 
7
9
  var registeredPlugins = [
8
10
  'autolink','lists','image','link','media','paste', 'code'
@@ -39,44 +41,23 @@ spud.admin.editor = {};
39
41
  "q[cite],samp,select[disabled|multiple|name|size],small," +
40
42
  "textarea[cols|rows|disabled|name|readonly],tt,var,big";
41
43
 
42
- var extendedValidElements = [];
44
+ var extendedValidElements = [
45
+ "iframe[src|width|height|name|align|frameborder|allowfullscreen]"
46
+ ];
43
47
 
44
48
  editor.init = function(options) {
45
- editor.monitorFormatters();
46
- options = options || {};
47
- var selector = options.selector || 'textarea.tinymce';
48
- $(selector).each(function() {
49
- var $this = $(this);
50
- var dataFormat = $this.attr('data-format');
51
- if(dataFormat == 'Markdown'){
52
- console.warn('Markdown is not supported at this time.');
53
- }
54
- editor.initMCEWithOptions(this, options || {});
55
- });
56
-
57
- };
58
-
59
- editor.monitorFormatters = function() {
60
- $('select[data-formatter]').off('onchange');
61
- $('select[data-formatter]').change(editor.formatterChanged);
62
- };
63
-
64
- editor.formatterChanged = function() {
65
- var formatId = $(this).attr('data-formatter');
66
- editor.unload('#' + formatId);
67
- $('#' + formatId).attr('data-format',$(this).val());
68
- editor.init({selector: '#' + formatId});
49
+ editor.unload();
50
+ editor.checkAndCallTinyMce(options);
69
51
  };
70
52
 
71
53
  editor.initMCEWithOptions = function(element, options){
72
-
73
54
  var theme = options.theme || 'modern';
74
55
  var height = options.height || 400;
75
56
  var width = options.width || $(element).width();
76
57
  var buttons = options.buttons || registeredButtons;
77
58
  var plugins = options.plugins || registeredPlugins;
78
59
 
79
- $(element).tinymce({
60
+ $(element).tinymce({
80
61
  theme: theme,
81
62
  language: 'en',
82
63
  menubar: false,
@@ -92,7 +73,9 @@ spud.admin.editor = {};
92
73
  };
93
74
 
94
75
  editor.unload = function() {
95
- tinyMCE.remove();
76
+ if(typeof tinymce != "undefined"){
77
+ tinyMCE.remove();
78
+ }
96
79
  };
97
80
 
98
81
  editor.registerPlugin = function(pluginName){
@@ -121,10 +104,39 @@ spud.admin.editor = {};
121
104
  console.warn('rowNum parameter is no longer used.');
122
105
  }
123
106
  if(typeof(buttonNameOrArray) == 'object'){
124
- registeredButtons.concat(buttonNameOrArray);
107
+ registeredButtons = registeredButtons.concat(buttonNameOrArray);
125
108
  }
126
109
  else{
127
110
  registeredButtons.push(buttonNameOrArray);
128
111
  }
129
112
  };
113
+
114
+ var loadScript = null;
115
+
116
+ editor.checkAndCallTinyMce = function(options){
117
+ options = options || {};
118
+ var selector = options.selector || 'textarea.tinymce';
119
+ var $elements = $(selector);
120
+
121
+ if($elements.length === 0){
122
+ return;
123
+ }
124
+
125
+ if(loadScript === null){
126
+ loadScript = $.when(
127
+ $.ajax({url: '//cdn.tinymce.com/4.3/tinymce.jquery.min.js', dataType: 'script', cache: true}),
128
+ $.ajax({url: '//cdn.tinymce.com/4.3/jquery.tinymce.min.js', dataType: 'script', cache: true})
129
+ ).done(function(){
130
+ $('body').trigger("tb:tinymce-loaded");
131
+ editor.tinymce.loaded = true;
132
+ });
133
+ }
134
+
135
+ loadScript.done(function(){
136
+ $elements.each(function(){
137
+ editor.initMCEWithOptions(this, options);
138
+ });
139
+ });
140
+ };
141
+
130
142
  })();
@@ -2,5 +2,8 @@
2
2
  //= require_directory ./tb_core
3
3
 
4
4
  (function(){
5
- window.tb = {};
5
+ window.tb = {
6
+
7
+ };
8
+
6
9
  })();
@@ -104,6 +104,17 @@ body {
104
104
  }
105
105
 
106
106
  // Forms
107
+ .form-horizontal .col-sm-10 .help-block{
108
+ margin: 5px 0;
109
+ &:last-child{
110
+ margin-bottom: 0;
111
+ }
112
+ }
113
+ .form-horizontal .form-sub-title{
114
+ margin: 0;
115
+ border-bottom: 1px solid #ccc;
116
+ padding: 0 0 4px 0;
117
+ }
107
118
 
108
119
  // Old Errors
109
120
  div.field_with_errors {
@@ -1,7 +1,5 @@
1
1
  class Spud::ApplicationController < ActionController::Base
2
2
 
3
- ActiveSupport.run_load_hooks(:spud_application_controller, self)
4
-
5
3
  protect_from_forgery
6
4
  helper_method :current_user_session, :current_user, :current_user_id, :back_or_default
7
5
  before_action :check_requires_password_change
@@ -130,4 +128,6 @@ private
130
128
  handle_request_error(error)
131
129
  end
132
130
 
131
+ ActiveSupport.run_load_hooks(:spud_application_controller, self)
132
+
133
133
  end
@@ -7,7 +7,6 @@ require 'autoprefixer-rails'
7
7
  require 'will_paginate'
8
8
  require 'will_paginate-bootstrap'
9
9
  require 'breadcrumbs_on_rails'
10
- require 'tinymce-rails'
11
10
 
12
11
  # this should eventually replace the Spud::Core namespace
13
12
  module TbCore
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.3.6"
3
+ VERSION = "1.3.7"
4
4
  end
5
5
  end
@@ -20,8 +20,13 @@ class TbCore::FormBuilder < ActionView::Helpers::FormBuilder
20
20
 
21
21
  # Build a label
22
22
  #
23
- def tb_label(attribute)
24
- label(attribute, @object.class.human_attribute_name(attribute), :class => 'col-sm-2 control-label')
23
+ def tb_label(attribute, options={})
24
+ if options[:label_text] != nil
25
+ text = options[:label_text]
26
+ else
27
+ text = @object.class.human_attribute_name(attribute)
28
+ end
29
+ label(attribute, text, :class => 'col-sm-2 control-label')
25
30
  end
26
31
 
27
32
  # Builds an input field with error message
@@ -36,8 +41,11 @@ class TbCore::FormBuilder < ActionView::Helpers::FormBuilder
36
41
  concat send(input_type, attribute, objectify_options(options))
37
42
  end
38
43
  error_message = @object.errors[attribute].first
44
+ if options[:help_text]
45
+ concat content_tag(:p, @template.raw(options[:help_text]), :class => 'help-block')
46
+ end
39
47
  if error_message
40
- concat content_tag(:p, error_message, :class => 'help-block form-field-error')
48
+ concat content_tag(:p, error_message, :class => 'form-error form-error-inline')
41
49
  end
42
50
  end
43
51
  end
@@ -130,11 +138,19 @@ class TbCore::FormBuilder < ActionView::Helpers::FormBuilder
130
138
  # ie, container div + label + input + error message
131
139
  #
132
140
 
141
+ def tb_sub_title(text)
142
+ content_tag :div, options.merge(:class => 'form-group') do
143
+ content_tag :div, :class => 'col-sm-offset-2 col-sm-10' do
144
+ content_tag :h4, text, :class => 'form-sub-title'
145
+ end
146
+ end
147
+ end
148
+
133
149
  # Builds a form group, label, and input tag all in one
134
150
  #
135
151
  def tb_input_field(attribute, input_type=nil, options={})
136
152
  tb_form_group() do
137
- concat tb_label(attribute)
153
+ concat tb_label(attribute, options)
138
154
  if block_given?
139
155
  concat(
140
156
  tb_input_field_tag(attribute) do
@@ -57,6 +57,7 @@ module Dummy
57
57
 
58
58
  # Version of your assets, change this if you want to expire all your assets
59
59
  config.assets.version = '1.0'
60
+
60
61
  end
61
62
  end
62
63
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tb_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Woods
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,20 +178,6 @@ dependencies:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: tinymce-rails
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - "~>"
186
- - !ruby/object:Gem::Version
187
- version: 4.1.6
188
- type: :runtime
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - "~>"
193
- - !ruby/object:Gem::Version
194
- version: 4.1.6
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: mysql2
197
183
  requirement: !ruby/object:Gem::Requirement
@@ -503,7 +489,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
489
  version: '0'
504
490
  requirements: []
505
491
  rubyforge_project:
506
- rubygems_version: 2.4.6
492
+ rubygems_version: 2.4.8
507
493
  signing_key:
508
494
  specification_version: 4
509
495
  summary: Twice Baked Core Engine