lolita-menu 0.3.6 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c32003725ace089823b958a151e48af409e4f6ee
4
+ data.tar.gz: 8e070736fa01c1271542089f3a3ca291246d0161
5
+ SHA512:
6
+ metadata.gz: 233a2a06346cf39630c4c5a5a50d8821a8ab470773c6f80f2b31b593473c1e023615a96f6f82f1d5f9887ab70f1f9efc16495c868f6599c388d06262d041c5bd
7
+ data.tar.gz: cdeae6f3a7fcf2efe92b7d54a0337b49a69494e6445d6aa9ad6ddfbd6768253618d0aa9baf7709809cf579f48ec16f9f002de4d38ae6b4bb4fdf04020053962e
@@ -0,0 +1,47 @@
1
+ # rcov generated
2
+ test_orm/log/*.log
3
+ test_orm/rails/log/*.log
4
+ Gemfile.lock
5
+ coverage
6
+ .project
7
+ .rvmrc
8
+
9
+ # rdoc generated
10
+ rdoc
11
+
12
+ # yard generated
13
+ doc
14
+ .yardoc
15
+
16
+ # bundler
17
+ .bundle
18
+
19
+ # jeweler generated
20
+ pkg
21
+
22
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
23
+ #
24
+ # * Create a file at ~/.gitignore
25
+ # * Include files you want ignored
26
+ # * Run: git config --global core.excludesfile ~/.gitignore
27
+ #
28
+ # After doing this, these files will be ignored in all your git projects,
29
+ # saving you from having to 'pollute' every project you touch with them
30
+ #
31
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
32
+ #
33
+ # For MacOS:
34
+ #
35
+ #.DS_Store
36
+ #
37
+ # For TextMate
38
+ #*.tmproj
39
+ #tmtags
40
+ #
41
+ # For emacs:
42
+ #*~
43
+ #\#*
44
+ #.\#*
45
+ #
46
+ # For vim:
47
+ *.swp
data/Gemfile CHANGED
@@ -1,13 +1,10 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem 'lolita','~>3.2.0.rc.14'
3
+ gemspec
4
4
 
5
- group :development, :test do
6
- gem "rails", "~>3.2.0"
7
- gem 'rspec', '~>2.9.0'
8
- gem "sqlite3"
9
- gem 'rspec-rails', '~>2.9.0'
10
- gem 'haml-rails'
11
- gem "jeweler", "~> 1.6.0"
12
- gem "database_cleaner", "~>0.6.7"
13
- end
5
+ group :test do
6
+ gem 'rails', '~> 3.2.12'
7
+ gem 'sqlite3', '~> 1.3.7'
8
+ gem 'rspec-rails', '~> 2.14'
9
+ gem 'database_cleaner', '~> 1.0.1'
10
+ end
data/Rakefile CHANGED
@@ -1,46 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
3
+ require 'rspec/core/rake_task'
11
4
 
12
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
- gem.name = "lolita-menu"
16
- gem.homepage = "http://github.com/ithouse/lolita-menu"
17
- gem.license = "MIT"
18
- gem.summary = %Q{Menu managing plugin for Lolita.}
19
- gem.description = %Q{Manage public menus for each project inside Lolita.}
20
- gem.email = "support@ithouse.lv"
21
- gem.authors = ["ITHouse","Arturs Meisters"]
22
- # Include your dependencies below. Runtime dependencies are required when using your gem,
23
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
- # gem.add_development_dependency 'rspec', '> 1.2.3'
26
- end
27
- Jeweler::RubygemsDotOrgTasks.new
28
-
29
- require 'rake/testtask'
30
- Rake::TestTask.new(:test) do |test|
31
- test.libs << 'lib' << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
-
36
- task :default => :test
37
-
38
- require 'rake/rdoctask'
39
- Rake::RDocTask.new do |rdoc|
40
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
-
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = "lolita-menu #{version}"
44
- rdoc.rdoc_files.include('README*')
45
- rdoc.rdoc_files.include('lib/**/*.rb')
46
- end
5
+ Bundler::GemHelper.install_tasks
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ task :default => :spec
@@ -22,7 +22,7 @@ $(document).ready(function(){
22
22
  {
23
23
  var self = null;
24
24
  jQuery.fn.railsAutocomplete = function() {
25
- return this.live('focus',function() {
25
+ return this.on('focus',this,function() {
26
26
  if (!this.railsAutoCompleter) {
27
27
  this.railsAutoCompleter = new jQuery.railsAutocomplete(this);
28
28
  }
@@ -11,7 +11,7 @@ $(document).ready(function(){
11
11
  success:function(){
12
12
  tree.data("old_positions",tree.nestedSortable('serialize'))
13
13
  }
14
- })
14
+ })
15
15
  }
16
16
  }
17
17
 
@@ -41,7 +41,7 @@ $(document).ready(function(){
41
41
  var that=this
42
42
  $(".subrow").hide(0)
43
43
  $("#branch_"+$(this).attr("data-id")).show(0);
44
-
44
+
45
45
  //event.preventDefault();
46
46
  })
47
47
 
@@ -57,7 +57,7 @@ $(document).ready(function(){
57
57
  })
58
58
  })
59
59
 
60
- $(".delete-nested-tree-item").live("click",function(){
60
+ $(document).on("click",".delete-nested-tree-item",function(){
61
61
  var self = this;
62
62
  $.ajax({
63
63
  url:$(this).attr("data-url"),
@@ -70,11 +70,11 @@ $(document).ready(function(){
70
70
  })
71
71
  })
72
72
 
73
- $(".nested-tree-content input").live("focus",function(){
73
+ $(document).on("focus",".nested-tree-content input",function(){
74
74
  $(this).data("value",$(this).val())
75
75
  })
76
76
 
77
- $(".nested-tree-content input").live("blur",function(){
77
+ $(document).on("blur",".nested-tree-content input",function(){
78
78
  var input=$(this);
79
79
  if(input.data("value")!=input.val()){
80
80
  var match = input.attr("name").match(/\[(\w+)\]$/);
@@ -1,7 +1,13 @@
1
+ button.add_new_nested_tree_item {
2
+ margin-top: 10px;
3
+ }
1
4
  ol.nested-tree-items-tree li{
2
5
  list-style:none;
3
6
  width:390px;
4
7
  }
8
+ ol.nested-tree-items-tree{
9
+ margin-bottom: 10px;
10
+ }
5
11
  div.nested-tree-content{
6
12
  width:500px;
7
13
  }
@@ -11,6 +17,21 @@ div.nested-tree-content{
11
17
  padding: 0;
12
18
  margin-right: 10px;
13
19
  }
20
+ #main div.nested-tree-content form input {
21
+ border: 1px solid #cdcdcd;
22
+ -moz-border-radius: 3px;
23
+ -webkit-border-radius: 3px;
24
+ border-radius: 3px;
25
+ -moz-box-sizing: border-box;
26
+ -webkit-box-sizing: border-box;
27
+ box-sizing: border-box;
28
+ padding: 3px 10px;
29
+ color: #494949;
30
+ }
31
+ #main div.nested-tree-content span img {
32
+ position: relative;
33
+ top: 4px;
34
+ }
14
35
  li.placeholder{
15
36
  background-color:white;
16
37
  }
@@ -3,6 +3,10 @@ class MenuItemsController < NestedTreesController
3
3
 
4
4
  before_filter :authenticate_lolita_user!
5
5
 
6
+ def index
7
+ super
8
+ end
9
+
6
10
  def autocomplete_menu_item_url
7
11
  authorization_proxy.authorize!(:read, Menu)
8
12
  urls = Lolita::Menu::Autocomplete::Collector.new(params[:term])
@@ -1,86 +1,86 @@
1
1
  class NestedTreesController < Lolita::RestController
2
- include Lolita::ControllerAdditions
2
+ include Lolita::ControllerAdditions
3
3
 
4
4
  before_filter :authenticate_lolita_user!
5
5
 
6
- def index
7
- super
8
- end
6
+ def index
7
+ super
8
+ end
9
9
 
10
- def create
10
+ def create
11
11
  authorization_proxy.authorize!(:create, tree_class)
12
- item = tree_class.build_empty_branch(attributes.merge(scopes))
12
+ item = tree_class.build_empty_branch(attributes.merge(scopes))
13
13
  item.save!
14
- item.reload
14
+ item.reload
15
15
  notice(I18n.t("lolita.nested_tree.branch created", :name => tree_class.model_name.human))
16
- render_component "lolita/menu/nested_tree/branch_builder", :row, :item => item, :scope => scope
17
- end
16
+ render_component "lolita/menu/nested_tree/branch_builder", :row, :item => item, :scope => scope
17
+ end
18
18
 
19
- def update
19
+ def update
20
20
  authorization_proxy.authorize!(:update,tree_class)
21
- if params[:attribute].present? && item = tree_class.find_by_id(params[:id])
21
+ if params[:attribute].present? && item = tree_class.find_by_id(params[:id])
22
22
  item.send(:"#{params[:attribute]}=",params[:value])
23
23
  item.save
24
24
  render :json=>{:status=>item.errors.any? ? "error" : "saved"}
25
- else
25
+ else
26
26
  render :json=>{:status=>"error"}
27
- end
28
- end
27
+ end
28
+ end
29
29
 
30
- def update_tree
30
+ def update_tree
31
31
  authorization_proxy.authorize!(:update,tree_class)
32
- if tree_class.update_whole_tree(params[:items], scopes)
32
+ if tree_class.update_whole_tree(params[:items], scopes)
33
33
  notice I18n.t("lolita.nested_tree.notice", :name => tree_class.model_name.human)
34
34
  else
35
35
  error I18n.t("lolita.nested_tree.error", :name => tree_class.model_name.human)
36
36
  end
37
37
 
38
38
  render :nothing=>true
39
- end
39
+ end
40
40
 
41
- def destroy
41
+ def destroy
42
42
  authorization_proxy.authorize!(:destroy,tree_class)
43
- item = tree_class.find_by_id(params[:id])
44
- item.destroy
43
+ item = tree_class.find_by_id(params[:id])
44
+ item.destroy
45
45
  notice I18n.t("lolita.nested_tree.branch deleted", :name => tree_class.model_name.human)
46
46
  render :json=>{:id=>item.id}
47
- end
47
+ end
48
48
 
49
49
  def lolita_mapping
50
50
  @lolita_mapping ||= Lolita.mappings[resource_class.to_s.underscore.to_sym]
51
51
  end
52
52
 
53
53
  def resource_name
54
- "nested_tree"
54
+ "nested_tree"
55
55
  end
56
56
 
57
- def resource_class
58
- tree_class
59
- end
57
+ def resource_class
58
+ tree_class
59
+ end
60
60
 
61
- private
61
+ private
62
62
 
63
- # URL:
64
- # /nested_trees?tree_class=MenuItem
65
- def tree_class
66
- @tree_class ||= params[:tree_class].constantize
67
- end
63
+ # URL:
64
+ # /nested_trees?tree_class=MenuItem
65
+ def tree_class
66
+ @tree_class ||= params[:tree_class].constantize
67
+ end
68
68
 
69
- def scopes
70
- @scopes ||= tree_class.lolita_nested_tree.scope_keys.inject({}) do |result, key|
71
- result[key] = params[key]
72
- result
73
- end
74
- end
69
+ def scopes
70
+ @scopes ||= tree_class.lolita_nested_tree.scope_keys.inject({}) do |result, key|
71
+ result[key] = params[key]
72
+ result
73
+ end
74
+ end
75
75
 
76
- def scope
77
- tree_class.lolita_nested_tree.scope_classes.first && tree_class.lolita_nested_tree.scope_classes.first.find_by_id(scopes.values.first)
78
- end
76
+ def scope
77
+ tree_class.lolita_nested_tree.scope_classes.first && tree_class.lolita_nested_tree.scope_classes.first.find_by_id(scopes.values.first)
78
+ end
79
79
 
80
- def attributes
81
- @attributes ||= tree_class.lolita.tabs.first.fields.inject({}) do |result, field|
82
- result[field.name.to_sym] = params[field.name.to_sym]
83
- result
84
- end
85
- end
80
+ def attributes
81
+ @attributes ||= tree_class.lolita.tabs.first.fields.inject({}) do |result, field|
82
+ result[field.name.to_sym] = params[field.name.to_sym] if params[field.name.to_sym]
83
+ result
84
+ end
85
+ end
86
86
  end
@@ -1,7 +1,6 @@
1
1
  class Menu < ActiveRecord::Base
2
-
2
+ self.table_name = 'lolita_menus'
3
3
  has_many :items, :class_name => "MenuItem", :dependent => :destroy
4
-
5
4
  validates :name, :presence => true
6
5
 
7
6
  include Lolita::Configuration
@@ -27,9 +26,4 @@ class Menu < ActiveRecord::Base
27
26
  end
28
27
  end
29
28
 
30
- class << self
31
- def table_name
32
- "lolita_menus"
33
- end
34
- end
35
29
  end
@@ -1,6 +1,7 @@
1
1
  class MenuItem < ActiveRecord::Base
2
- include Lolita::Configuration
3
- include Lolita::Menu::NestedTree
2
+ include Lolita::Configuration
3
+ include Lolita::Menu::NestedTree
4
+ self.table_name = 'lolita_menu_items'
4
5
 
5
6
  belongs_to :menu, :class_name => "Menu"
6
7
  attr_accessible :lft, :rgt, :depth, :parent_id, :menu_id, :url, :name
@@ -10,9 +11,9 @@ class MenuItem < ActiveRecord::Base
10
11
 
11
12
  before_save :normalize_url
12
13
 
13
- lolita_nested_tree :scope => :menu, :build_method => :build_new_item
14
+ lolita_nested_tree :scope => :menu, :build_method => :build_new_item
14
15
 
15
- lolita do
16
+ lolita do
16
17
  list do
17
18
  action :edit do
18
19
  title ::I18n.t("lolita.shared.edit")
@@ -25,20 +26,15 @@ class MenuItem < ActiveRecord::Base
25
26
  html :method => :delete, :confirm => ::I18n.t("lolita.list.confirm")
26
27
  end
27
28
  end
28
- tab(:default) do
29
- field :name
30
- field :url do
29
+ tab(:default) do
30
+ field :name
31
+ field :url do
31
32
  builder :name => "/lolita/menu_item", :state => :display, :if => {:state => :display}
32
33
  end
33
- end
34
- end
35
-
36
- class << self
37
-
38
- def table_name
39
- "lolita_menu_items"
40
34
  end
35
+ end
41
36
 
37
+ class << self
42
38
  def build_new_item(attributes)
43
39
  self.new(attributes.merge(:url => "/", :name => ::I18n.t("lolita.menu_item.new")))
44
40
  end
@@ -51,9 +47,9 @@ class MenuItem < ActiveRecord::Base
51
47
  !!active_item
52
48
  end
53
49
 
54
- def visible?
55
- self.is_visible
56
- end
50
+ def visible?
51
+ self.is_visible
52
+ end
57
53
 
58
54
  def url_match?(request,fullpath=false)
59
55
  if self.url.strip.match(/^http/)
@@ -2,7 +2,6 @@
2
2
  = javascript_include_tag "lolita/menu/application.js"
3
3
  - content_for :style do
4
4
  = stylesheet_link_tag "lolita/menu/application.css"
5
-
6
5
  - has_scopes = list.dbi.klass.lolita_nested_tree.scope_keys.any?
7
6
  .box
8
7
  = render_component list, :title