beautiful_scaffold 0.2.7 → 0.3.0.pre

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.
Files changed (43) hide show
  1. data/CHANGELOG +18 -0
  2. data/Gemfile +2 -2
  3. data/README.rdoc +10 -0
  4. data/beautiful_scaffold.gemspec +1 -1
  5. data/lib/generators/beautiful_jointable_generator.rb +1 -1
  6. data/lib/generators/beautiful_locale_generator.rb +95 -7
  7. data/lib/generators/beautiful_scaffold_common_methods.rb +49 -12
  8. data/lib/generators/beautiful_scaffold_generator.rb +12 -22
  9. data/lib/generators/templates/app/assets/javascripts/application-bs.js +34 -0
  10. data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +123 -19
  11. data/lib/generators/templates/app/assets/javascripts/bootstrap-datetimepicker-for-beautiful-scaffold.js +42 -39
  12. data/lib/generators/templates/app/assets/javascripts/fixed_menu.js +19 -0
  13. data/lib/generators/templates/app/assets/stylesheets/application-bs.css +26 -0
  14. data/lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss +46 -1
  15. data/lib/generators/templates/app/views/_form_habtm_tag.html.erb +3 -26
  16. data/lib/generators/templates/app/views/_mass_inserting.html.erb +2 -9
  17. data/lib/generators/templates/app/views/_modal_columns.html.erb +1 -29
  18. data/lib/generators/templates/app/views/dashboard.html.erb +1 -0
  19. data/lib/generators/templates/app/views/edit.html.erb +1 -1
  20. data/lib/generators/templates/app/views/index.html.erb +4 -8
  21. data/lib/generators/templates/app/views/layout.html.erb +40 -44
  22. data/lib/generators/templates/app/views/new.html.erb +1 -1
  23. data/lib/generators/templates/app/views/partials/_form_field.html.erb +8 -14
  24. data/lib/generators/templates/app/views/partials/_index_search.html.erb +1 -5
  25. data/lib/generators/templates/app/views/partials/_index_search_default_fields.html.erb +3 -0
  26. data/lib/generators/templates/app/views/partials/_show_field.html.erb +1 -1
  27. data/lib/generators/templates/app/views/partials/_sign_in_form.html.erb +0 -5
  28. data/lib/generators/templates/app/views/show.html.erb +1 -1
  29. data/lib/generators/templates/app/views/treeview.html.erb +9 -11
  30. metadata +9 -18
  31. data/lib/generators/templates/app/assets/images/glyphicons-halflings-white.png +0 -0
  32. data/lib/generators/templates/app/assets/images/glyphicons-halflings.png +0 -0
  33. data/lib/generators/templates/app/assets/javascripts/bootstrap-alert.js +0 -90
  34. data/lib/generators/templates/app/assets/javascripts/bootstrap-dropdown.js +0 -100
  35. data/lib/generators/templates/app/assets/javascripts/bootstrap-modal.js +0 -218
  36. data/lib/generators/templates/app/assets/javascripts/bootstrap-tooltip.js +0 -275
  37. data/lib/generators/templates/app/assets/javascripts/bootstrap.js +0 -2027
  38. data/lib/generators/templates/app/assets/javascripts/bootstrap.min.js +0 -6
  39. data/lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.css +0 -1040
  40. data/lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.min.css +0 -9
  41. data/lib/generators/templates/app/assets/stylesheets/bootstrap.css +0 -5624
  42. data/lib/generators/templates/app/assets/stylesheets/bootstrap.min.css +0 -9
  43. data/lib/generators/templates/app/views/_treeview_js.html.erb +0 -42
data/CHANGELOG CHANGED
@@ -1,3 +1,21 @@
1
+ == 0.3.0
2
+
3
+ * enhancement
4
+ * Refactoring i18n (avoid reserved words) :
5
+ * t(:my_model) -> t('models.my_model.caption')
6
+ * t(:my_attribute) -> t('models.my_model.attributes.my_attribute')
7
+ * Add javascript/css to change DOM for a fixed menu
8
+ * Add responsive menu
9
+ * Update for rails 4
10
+ * Replace PJAX with turbolinks
11
+ * Update prawn version 1.0.0.rc2
12
+ * Big refactoring with javascript
13
+ * Using twitter-bootstrap-rails with turbolinks compatibility and last version of bootstrap and fontawesome
14
+
15
+ * Bugfix
16
+ * Avoid to re-generate created_at, updated_at, id search field at each migration
17
+ * Bugfix for several responsive behavior
18
+
1
19
  == 0.2.7
2
20
 
3
21
  * enhancement
data/Gemfile CHANGED
@@ -2,13 +2,13 @@ source "http://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 3.1.0"
5
+ gem "rails", "~> 4.0"
6
6
  # Pagination
7
7
  gem "will_paginate"
8
8
  # Search and filter
9
9
  gem "ransack"
10
10
  # Pdf
11
- gem 'prawn', '1.0.0.rc1'
11
+ gem 'prawn', '1.0.0.rc2'
12
12
  # Textile
13
13
  gem 'RedCloth'
14
14
  # BBCode
data/README.rdoc CHANGED
@@ -7,8 +7,18 @@ Demo : http://demo.beautiful-scaffold.com/
7
7
 
8
8
  == Install
9
9
 
10
+ === RubyOnRails 3.X
11
+
10
12
  Add this in your Gemfile :
11
13
  gem 'beautiful_scaffold', '0.2.7'
14
+
15
+ === RubyOnRails 4.X
16
+
17
+ Add this in your Gemfile :
18
+ gem 'beautiful_scaffold', '0.3.0'
19
+
20
+ === Next
21
+
12
22
  And run
13
23
  bundle install
14
24
 
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "beautiful_scaffold"
6
- s.version = "0.2.7"
6
+ s.version = "0.3.0.pre"
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.summary = "Beautiful Scaffold generate fully customizable scaffold"
9
9
  s.email = "claudel.sylvain@gmail.com"
@@ -9,7 +9,7 @@ class BeautifulJointableGenerator < Rails::Generators::Base
9
9
 
10
10
  def create_join_table
11
11
  if join_models.length != 2 then
12
- puts "Error need two singular models : example : user product"
12
+ say_status("Error", "Error need two singular models : example : user product", :red)
13
13
  else
14
14
  sorted_model = join_models.sort
15
15
 
@@ -13,22 +13,110 @@ class BeautifulLocaleGenerator < Rails::Generators::Base
13
13
  localestr = name.downcase
14
14
 
15
15
  locale_to_process = []
16
- if availablelocale.include?(localestr) then
17
- locale_to_process << localestr
18
- elsif localestr == 'all' then
16
+
17
+ if localestr == 'all' then
19
18
  locale_to_process = availablelocale
20
19
  else
21
- puts "This locale #{localestr} doesn't exist !"
20
+ locale_to_process << localestr
22
21
  end
23
22
 
24
23
  locale_to_process.each{ |temp_locale|
25
24
  filename = "beautiful_scaffold.#{temp_locale}.yml"
26
25
  gem_localepath = "app/locales/#{filename}"
27
26
  app_localepath = "config/locales/#{filename}"
28
- copy_file gem_localepath, app_localepath
27
+ begin
28
+ copy_file gem_localepath, app_localepath
29
+ rescue
30
+ say_status("Error", "This beautiful_locale #{localestr} doesn't exist !", :red)
31
+ end
32
+
33
+ rails_locale_file = "#{temp_locale}.yml"
34
+ download_path = "https://raw.github.com/svenfuchs/rails-i18n/master/rails/locale/#{rails_locale_file}"
35
+ begin
36
+ get download_path, "config/locales/#{rails_locale_file}"
37
+ rescue
38
+ say_status("Error", "Error to download locale, verify if locale exist at : #{download_path}", :red)
39
+ end
29
40
  }
30
-
31
- puts "/!\\ Remember to download rails locale and update your application.rb file !"
41
+
42
+ say_status("Warning", "/!\\ Remember to update your application.rb file !", :yellow)
43
+ end
44
+
45
+ def regenerate_app_locale
46
+ require 'net/http'
47
+
48
+ already_processed = { name.downcase => {}}
49
+
50
+ filepath = File.join(Rails.root, 'config', 'locales', "#{Rails.application.class.parent_name.downcase}.#{name.downcase}.yml")
51
+ begin
52
+ hi18n = YAML.load_file(filepath)
53
+ rescue
54
+ end
55
+ hi18n ||= { name.downcase => {} }
56
+ hi18n[name.downcase] ||= { 'app' => {} }
57
+ hi18n[name.downcase]['app'] ||= { 'models' => {} }
58
+ hi18n[name.downcase]['app']['models'] ||= {}
59
+
60
+
61
+ Dir.glob("app/models/**/*").each { |model_file|
62
+ puts model_file
63
+ next if File.directory?(model_file)
64
+ model = File.basename(model_file, File.extname(model_file))
65
+ klass = model.camelize.constantize
66
+
67
+ begin
68
+ sorted_attr = klass.attribute_names.sort
69
+ rescue
70
+ next
71
+ end
72
+
73
+ hi18n[name.downcase]['app']['models'][model] ||= {
74
+ 'bs_caption' => model,
75
+ 'bs_caption_pluralize' => model.pluralize,
76
+ 'bs_attributes' => {},
77
+ }
78
+
79
+ hi18n[name.downcase]['app']['models'][model]['bs_caption'] = translate_string(name.downcase, model)
80
+ hi18n[name.downcase]['app']['models'][model]['bs_caption_pluralize'] = translate_string(name.downcase, model.pluralize)
81
+ hi18n[name.downcase]['app']['models'][model]['bs_attributes'] ||= {}
82
+
83
+ sorted_attr.each { |k|
84
+ if already_processed[name.downcase][k].nil? then
85
+ begin
86
+ attr_translate = translate_string(name.downcase, k)
87
+ already_processed[name.downcase][k] = attr_translate
88
+ rescue
89
+ puts "Plantage translate API"
90
+ attr_translate = k
91
+ end
92
+ else
93
+ attr_translate = already_processed[name.downcase][k]
94
+ end
95
+
96
+ puts "====> #{k} / #{attr_translate} / #{hi18n[name.downcase]['app']['models'][model]}"
97
+ hi18n[name.downcase]['app']['models'][model]['bs_attributes'][k] = attr_translate
98
+ }
99
+ }
100
+
101
+ File.unlink(filepath) if File.exist?(filepath)
102
+
103
+ file = File.open(filepath, "w")
104
+ file.write(hi18n.to_yaml)
105
+ file.close
106
+ end
107
+
108
+ def translate_string(locale, str)
109
+ # See http://www.microsofttranslator.com/dev/
110
+ #
111
+ url_domain = "mymemory.translated.net"
112
+ url_translate = "/api/get?q=to_translate&langpair=en%7C#{locale}"
113
+
114
+ urlstr = url_translate.gsub(/to_translate/, str.gsub(/_/, "%20"))
115
+ json = JSON.parse(Net::HTTP.get(url_domain, urlstr))
116
+ attr_translate = json["responseData"]["translatedText"].strip.downcase
117
+ raise 'Free Limit' if attr_translate =~ /mymemory/
118
+
119
+ return attr_translate
32
120
  end
33
121
 
34
122
  end
@@ -2,28 +2,26 @@ module BeautifulScaffoldCommonMethods
2
2
  require 'erb'
3
3
 
4
4
  private
5
+
6
+ #############
7
+ # Namespace
8
+ #############
5
9
 
6
10
  def namespace_for_class
7
11
  str = namespace_alone
8
- if not str.blank? then
9
- str = str.camelcase + '::'
10
- end
12
+ str = str.camelcase + '::' if not str.blank?
11
13
  return str
12
14
  end
13
15
 
14
16
  def namespace_for_route
15
17
  str = namespace_alone
16
- if not str.blank? then
17
- str = str.downcase + '_'
18
- end
18
+ str = str.downcase + '_' if not str.blank?
19
19
  return str
20
20
  end
21
21
 
22
22
  def namespace_for_url
23
23
  str = namespace_alone
24
- if not str.blank? then
25
- str = str.downcase + '/'
26
- end
24
+ str = str.downcase + '/' if not str.blank?
27
25
  return str
28
26
  end
29
27
 
@@ -37,6 +35,10 @@ module BeautifulScaffoldCommonMethods
37
35
  return result
38
36
  end
39
37
 
38
+ ############
39
+ # Models
40
+ ############
41
+
40
42
  def model_camelize
41
43
  model.camelize
42
44
  end
@@ -49,7 +51,10 @@ module BeautifulScaffoldCommonMethods
49
51
  model.camelize
50
52
  end
51
53
 
52
- # For the views
54
+ ############
55
+ # Table
56
+ ############
57
+
53
58
  def plural_table_name
54
59
  model_pluralize
55
60
  end
@@ -57,6 +62,34 @@ module BeautifulScaffoldCommonMethods
57
62
  model
58
63
  end
59
64
 
65
+ ############
66
+ # I18n
67
+ ############
68
+
69
+ def attribute_path_i18n(model, attribute)
70
+ "app.models.#{model}.bs_attributes.#{attribute}"
71
+ end
72
+
73
+ def model_path_i18n(model)
74
+ "app.models.#{model}.bs_caption"
75
+ end
76
+
77
+ def model_p_path_i18n(model)
78
+ "app.models.#{model}.bs_caption_pluralize"
79
+ end
80
+
81
+ def i18n_t_a(model, attribute)
82
+ "t('#{attribute_path_i18n(model, attribute)}', :default => '#{model}')"
83
+ end
84
+
85
+ def i18n_t_m(model)
86
+ "t('#{model_path_i18n(model)}', :default => '#{model}')"
87
+ end
88
+
89
+ def i18n_t_m_p(model)
90
+ "t('#{model_p_path_i18n(model)}', :default => '#{model}')"
91
+ end
92
+
60
93
  def available_views
61
94
  %w(index edit show new _form)
62
95
  end
@@ -107,14 +140,18 @@ module BeautifulScaffoldCommonMethods
107
140
  end
108
141
 
109
142
  def require_gems
143
+ # for jquery-ui add "2.3.0" version for jquery-rails
144
+ say_status("Warning", "Set 2.0.1 version for jquery-rails (for a good compatibility with beautiful_scaffold)", :yellow)
145
+
110
146
  gem('will_paginate')
111
- gem('ransack')
112
- gem('prawn', '1.0.0.rc1')
147
+ gem('ransack', :github => 'ernie/ransack', :branch => 'rails-4')
148
+ gem('prawn', '1.0.0.rc2')
113
149
  gem('RedCloth')
114
150
  gem('bb-ruby')
115
151
  gem('bluecloth')
116
152
  gem('rdiscount')
117
153
  gem('sanitize')
154
+ gem('twitter-bootstrap-rails')
118
155
  end
119
156
 
120
157
  end
@@ -20,6 +20,9 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
20
20
 
21
21
  def install_gems
22
22
  require_gems
23
+ inside Rails.root do
24
+ run "bundle install"
25
+ end
23
26
  end
24
27
 
25
28
  def add_field_for_fulltext
@@ -48,10 +51,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
48
51
  # Css
49
52
  reset = "#{stylesheetspath}reset.css"
50
53
  bc_css = [
51
- "#{stylesheetspath}bootstrap.css",
52
- "#{stylesheetspath}bootstrap.min.css",
53
- "#{stylesheetspath}bootstrap-responsive.css",
54
- "#{stylesheetspath}bootstrap-responsive.min.css",
54
+ "#{stylesheetspath}application-bs.css",
55
55
  "#{stylesheetspath}datepicker.css",
56
56
  "#{stylesheetspath}timepicker.css",
57
57
  "#{stylesheetspath}beautiful-scaffold.css.scss",
@@ -64,13 +64,8 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
64
64
 
65
65
  # Js
66
66
  bc_js = [
67
+ "#{javascriptspath}application-bs.js",
67
68
  "#{javascriptspath}beautiful_scaffold.js",
68
- "#{javascriptspath}bootstrap.js",
69
- "#{javascriptspath}bootstrap.min.js",
70
- "#{javascriptspath}bootstrap-alert.js",
71
- "#{javascriptspath}bootstrap-dropdown.js",
72
- "#{javascriptspath}bootstrap-modal.js",
73
- "#{javascriptspath}bootstrap-tooltip.js",
74
69
  "#{javascriptspath}bootstrap-datepicker.js",
75
70
  "#{javascriptspath}bootstrap-datetimepicker-for-beautiful-scaffold.js",
76
71
  "#{javascriptspath}bootstrap-timepicker.js",
@@ -79,26 +74,22 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
79
74
  "#{javascriptspath}tagit.js",
80
75
  "#{javascriptspath}bootstrap-colorpicker.js",
81
76
  "#{javascriptspath}a-wysihtml5-0.3.0.min.js",
82
- "#{javascriptspath}bootstrap-wysihtml5.js"
77
+ "#{javascriptspath}bootstrap-wysihtml5.js",
78
+ "#{javascriptspath}fixed_menu.js"
83
79
  ]
84
- pjax_js = "#{javascriptspath}jquery.pjax.js"
85
80
 
86
- [reset, bc_css, bc_js, pjax_js].flatten.each{ |path|
81
+ [reset, bc_css, bc_js].flatten.each{ |path|
87
82
  copy_file path, path
88
83
  }
89
84
 
90
85
  # Jstree theme
91
86
  directory "app/assets/stylesheets/themes", "app/assets/stylesheets/themes"
92
87
 
93
- # Inject jquery-ui
94
- appjs = "app/assets/javascripts/application.js"
95
- if not File.read(appjs)[/\/\/= require jquery-ui/] then
96
- inject_into_file(appjs, "//= require jquery-ui\n", :after => "//= require jquery\n")
97
- end
98
-
99
88
  # Images
100
89
  dir_image = "app/assets/images"
101
90
  directory dir_image, dir_image
91
+
92
+ generate("bootstrap:install","static")
102
93
  end
103
94
 
104
95
  def generate_layout
@@ -114,7 +105,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
114
105
 
115
106
  inject_into_file("app/views/layouts/_beautiful_menu.html.erb",'
116
107
  <li class="<%= "active" if params[:controller] == "' + namespace_for_url + model.pluralize + '" %>">
117
- <%= link_to t(:' + model.pluralize + ', :default => "' + model.pluralize + '").capitalize, ' + namespace_for_route + model.pluralize + '_path %>
108
+ <%= link_to ' + i18n_t_m_p(model) + '.capitalize, ' + namespace_for_route + model.pluralize + '_path %>
118
109
  </li>', :after => "<!-- Beautiful Scaffold Menu Do Not Touch This -->")
119
110
  end
120
111
 
@@ -206,7 +197,6 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
206
197
  template empty_template_path, current_template_path
207
198
  end
208
199
 
209
- copy_file "app/views/_treeview_js.html.erb", "app/views/layouts/_treeview_js.html.erb"
210
200
  copy_file "app/views/_form_habtm_tag.html.erb", "app/views/layouts/_form_habtm_tag.html.erb"
211
201
  end
212
202
 
@@ -219,7 +209,7 @@ class BeautifulScaffoldGenerator < Rails::Generators::Base
219
209
 
220
210
  if not routes_in_text[/beautiful#dashboard/] and not routes_in_text[/beautiful#select_fields/] then
221
211
  myroute = "root :to => 'beautiful#dashboard'\n"
222
- myroute += " match ':model_sym/select_fields' => 'beautiful#select_fields'\n"
212
+ myroute += " match ':model_sym/select_fields' => 'beautiful#select_fields', :via => [:get, :post]\n"
223
213
  route(myroute)
224
214
  end
225
215
 
@@ -0,0 +1,34 @@
1
+ //= require jquery
2
+ //= require jquery-ui
3
+ //= require jquery_ujs
4
+ //= require jquery.livequery
5
+ //= require turbolinks
6
+ //= require a-wysihtml5-0.3.0.min
7
+ //= require bootstrap-colorpicker
8
+ //= require bootstrap-datepicker
9
+ //= require bootstrap-timepicker
10
+ //= require bootstrap-datetimepicker-for-beautiful-scaffold
11
+ //= require bootstrap-wysihtml5
12
+ //= require jquery.jstree
13
+ //= require jquery.markitup
14
+ //= require markitup/sets/bbcode/set
15
+ //= require markitup/sets/default/set
16
+ //= require markitup/sets/html/set
17
+ //= require markitup/sets/markdown/set
18
+ //= require markitup/sets/textile/set
19
+ //= require markitup/sets/wiki/set
20
+ //= require tagit.js
21
+ //= require beautiful_scaffold
22
+ //= require fixed_menu
23
+
24
+ function initPage(){
25
+ datetimepicker_init();
26
+ bs_init();
27
+ modify_dom_init();
28
+ }
29
+ $(function() {
30
+ initPage();
31
+ });
32
+ $(window).bind('page:change', function() {
33
+ initPage();
34
+ })
@@ -1,4 +1,4 @@
1
- $(document).ready(function(){
1
+ function bs_init(){
2
2
 
3
3
  /* Richtext editor */
4
4
  $('.select-richtext').click(function(){
@@ -32,25 +32,129 @@ $(document).ready(function(){
32
32
  $('#' + ideditor).removeClass("bbcode html markdown textile wiki").addClass(newSet);
33
33
  return true;
34
34
  });
35
- });
36
35
 
37
- $(function(){
38
- try{
39
- /* PJAX initializer */
40
- $('a:not(.nopjax)').pjax('#pjax-container').live('click');
41
- $('a:not(.nopjax)').live('click', function(){
42
- /* Work on all bootstrap navbar */
43
- $(this).parent().parent().find('.active').removeClass('active');
44
- $(this).parent().addClass('active');
36
+ // Tagit
37
+ $('.bs-tagit').each(function( index ) {
38
+ var tagitelt = this;
39
+ $(tagitelt).tagit({
40
+ tagSource : function( request, response ) {
41
+
42
+ var par = $(tagitelt).attr("data-param");
43
+ var url = $(tagitelt).attr("data-url");
44
+ var result = $(tagitelt).attr("data-result");
45
+ var data_to_send = {
46
+ "skip_save_search": true
47
+ };
48
+ data_to_send[par] = request.term;
49
+ $.ajax({
50
+ url: url,
51
+ type: "POST",
52
+ data: data_to_send,
53
+ dataType: "json",
54
+ success: function( data ) {
55
+ response( $.map( data, function( item ) {
56
+ return { label: String(item[result]), value: item.id };
57
+ }));
58
+ }
59
+ });
60
+ },
61
+ triggerKeys:['enter', 'comma', 'tab'],
62
+ select : true,
63
+ allowNewTags : false
64
+ });
65
+ });
66
+
67
+ // Wysiwyg and color field
68
+ $('.wysiwyg-editor').wysihtml5({"html": true});
69
+ $('.color').colorpicker({format: 'rgba'});
70
+
71
+ // Processing
72
+ $('#checkall').click(function(){
73
+ $('.cbbatch').attr('checked', ($(this).attr('checked') != undefined));
74
+ });
75
+
76
+ // Filter columns
77
+ $('#filter-columns').on('click', function(){
78
+ var return_json = [];
79
+ $.each($('input[name^="field"]:checked'), function(index, value) {
80
+ return_json.push($(value).val());
81
+ });
82
+ var url = $(this).attr('data-url');
83
+ $.ajax({
84
+ url: url,
85
+ data: { 'fields' : return_json },
86
+ success: function(data) {
87
+ $('table.table th[class^="col"], table.table td[class^="col"]').css('display', 'none');
88
+ $.each(return_json, function(index, value) {
89
+ $('table.table th.col-' + value + ', table.table td.col-' + value).css('display', 'table-cell');
90
+ });
91
+ $('div[class^="col"]').css('display', 'none');
92
+ $.each(return_json, function(index, value) {
93
+ $('div.col-' + value).css('display', 'inline');
94
+ });
95
+ $('#modal-columns').modal('hide');
96
+ }
45
97
  });
46
- $('#pjax-container').bind('pjax:start', function() {
47
- $('.loader').show();
48
- }).bind('pjax:end', function() {
49
- $('.loader').hide();
50
- }).bind('pjax:timeout', function() { $('.loader').show();return false; });
98
+ return false;
99
+ });
100
+ $('#cancel-filter-columns').on('click', function(){
101
+ $('#modal-columns').modal('hide');
102
+ return false;
103
+ });
104
+
105
+ // TreeView JS
106
+ var opened = eval($("#treeview").attr("data-opened"));
107
+ var url = $("#treeview").attr("data-url");
108
+ var model = $("#treeview").attr("data-model");
109
+ $("#treeview")
110
+ .jstree({
111
+ "plugins" : [
112
+ "themes","html_data","ui","dnd"
113
+ ],
114
+ "core" : {
115
+ "initially_open" : [opened]
116
+ }
117
+ })
118
+ .bind("move_node.jstree", function (e, data) {
119
+ data.rslt.o.each(function (i) {
120
+ var dataajax = {
121
+ "operation" : "move_node",
122
+ "position" : data.rslt.cp + i,
123
+ "title" : data.rslt.name,
124
+ "copy" : data.rslt.cy ? 1 : 0
125
+ };
126
+ dataajax[model + "_id"] = data.rslt.cr === -1 ? "" : data.rslt.np.data("id");
127
+ $.ajax({
128
+ async : false,
129
+ type: 'POST',
130
+ url: url + $(this).data("id") + "/treeview_update",
131
+ data : dataajax,
132
+ success : function (r) {
133
+ $(data.rslt.oc).attr("id", "treeelt_" + r.id);
134
+ if(data.rslt.cy && $(data.rslt.oc).children("UL").length) {
135
+ data.inst.refresh(data.inst._get_parent(data.rslt.oc));
136
+ }
137
+ },
138
+ error : function (r) {
139
+ $.jstree.rollback(data.rlbk);
140
+ }
141
+ });
142
+ });
143
+ });
144
+
145
+ // Mass inserting set focus
146
+ elt = $('form.mass-inserting div[style*="inline"][class*="col"] .input-small').first();
147
+ if($('form.mass-inserting').hasClass('setfocus')){
148
+ $(elt).focus();
51
149
  }
52
- catch(err)
53
- {
54
- //Handle errors here
150
+
151
+ // Menu dropdown
152
+ try{
153
+ $('.dropdown-toggle').dropdown();
154
+ $('.dropdown-menu').find('form').click(function (e) {
155
+ e.stopPropagation();
156
+ });
157
+ }catch (e){
55
158
  }
56
- });
159
+
160
+ }