sunrise-cms 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +5 -0
- data/README.md +4 -1
- data/app/assets/images/sunrise/chosen-sprite.png +0 -0
- data/app/assets/images/sunrise/chosen-sprite@2x.png +0 -0
- data/app/assets/javascripts/sunrise/application.js +0 -1
- data/app/assets/javascripts/sunrise/chosen.jquery.js +534 -413
- data/app/assets/javascripts/sunrise/manage.js.coffee +6 -6
- data/app/assets/stylesheets/sunrise/chosen.css +323 -261
- data/app/views/sunrise/manager/_field.html.erb +3 -1
- data/lib/generators/sunrise/templates/config/seeds.rb +2 -2
- data/lib/sunrise/config/field.rb +9 -1
- data/lib/sunrise/config/has_fields.rb +2 -2
- data/lib/sunrise/config/nested_field.rb +2 -2
- data/lib/sunrise/version.rb +1 -1
- metadata +2 -3
- data/app/assets/javascripts/sunrise/chosen.overflow.fix.js +0 -66
@@ -1,7 +1,9 @@
|
|
1
1
|
<% options ||= {} %>
|
2
2
|
<%= content_tag :div, field.html_options do -%>
|
3
3
|
<% if field.visible?(form.object) -%>
|
4
|
-
<% if field.
|
4
|
+
<% if field.block_given? %>
|
5
|
+
<%= field.block.call(form, @record) %>
|
6
|
+
<% elsif field.nested? -%>
|
5
7
|
<div class="nested">
|
6
8
|
<div class="title-switcher up"><%= form.label field.name %></div>
|
7
9
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
def insert_user
|
4
|
-
User.
|
4
|
+
User.delete_all
|
5
5
|
password = Rails.env.production? ? Devise.friendly_token : (1..9).to_a.join
|
6
6
|
|
7
7
|
admin = User.new do |u|
|
@@ -20,7 +20,7 @@ def insert_user
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def insert_structures
|
23
|
-
Structure.
|
23
|
+
Structure.delete_all
|
24
24
|
|
25
25
|
main_page = Structure.create!(title: "Главная страница", slug: "main-page", structure_type: StructureType.main, parent: nil)
|
26
26
|
# Structure.create!(title: "Трансляции", slug: "broadcasts", structure_type: StructureType.broadcasts, parent: main_page)
|
data/lib/sunrise/config/field.rb
CHANGED
@@ -10,8 +10,11 @@ module Sunrise
|
|
10
10
|
|
11
11
|
# The condition that must *not* be met on an object
|
12
12
|
attr_reader :unless_condition
|
13
|
+
|
14
|
+
# Store form block
|
15
|
+
attr_reader :block
|
13
16
|
|
14
|
-
def initialize(abstract_model, parent, options = {})
|
17
|
+
def initialize(abstract_model, parent, options = {}, &block)
|
15
18
|
options = {:multiply => false, :sort => false}.merge(options)
|
16
19
|
|
17
20
|
super(abstract_model, parent, options)
|
@@ -19,6 +22,11 @@ module Sunrise
|
|
19
22
|
# Build conditionals
|
20
23
|
@if_condition = options.delete(:if)
|
21
24
|
@unless_condition = options.delete(:unless)
|
25
|
+
@block = block
|
26
|
+
end
|
27
|
+
|
28
|
+
def block_given?
|
29
|
+
!block.nil?
|
22
30
|
end
|
23
31
|
|
24
32
|
def visible?(object = nil)
|
@@ -12,9 +12,9 @@ module Sunrise
|
|
12
12
|
end
|
13
13
|
|
14
14
|
# Defines a configuration for a field.
|
15
|
-
def field(name, options = {})
|
15
|
+
def field(name = :custom, options = {}, &block)
|
16
16
|
options = { :name => name.to_sym }.merge(options)
|
17
|
-
fields << Field.new(abstract_model, self, options)
|
17
|
+
fields << Field.new(abstract_model, self, options, &block)
|
18
18
|
end
|
19
19
|
|
20
20
|
# Defines a configuration for a nested attributes
|
@@ -10,9 +10,9 @@ module Sunrise
|
|
10
10
|
end
|
11
11
|
|
12
12
|
# Defines a configuration for a field.
|
13
|
-
def field(name, options = {})
|
13
|
+
def field(name = :custom, options = {}, &block)
|
14
14
|
options = { :name => name.to_sym }.merge(options)
|
15
|
-
fields << Field.new(abstract_model, self, options)
|
15
|
+
fields << Field.new(abstract_model, self, options, &block)
|
16
16
|
end
|
17
17
|
|
18
18
|
def nested?
|
data/lib/sunrise/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunrise-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -415,7 +415,6 @@ files:
|
|
415
415
|
- app/assets/images/sunrise/vline.gif
|
416
416
|
- app/assets/javascripts/sunrise/application.js
|
417
417
|
- app/assets/javascripts/sunrise/chosen.jquery.js
|
418
|
-
- app/assets/javascripts/sunrise/chosen.overflow.fix.js
|
419
418
|
- app/assets/javascripts/sunrise/jquery-ui-timepicker-addon.js
|
420
419
|
- app/assets/javascripts/sunrise/jquery.cookie.js
|
421
420
|
- app/assets/javascripts/sunrise/jquery.ddmenu.js.coffee
|
@@ -1,66 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Chosen gets "cut" when placed in area with "overflow:hidden".
|
3
|
-
https://github.com/harvesthq/chosen/issues/86#issuecomment-11632999
|
4
|
-
*/
|
5
|
-
Chosen.prototype.results_reposition = function() {
|
6
|
-
var dd_top, offset, scrolly, toppy;
|
7
|
-
|
8
|
-
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
|
9
|
-
|
10
|
-
// when in a modal get the scroll distance and apply to top of .chzn-drop
|
11
|
-
offset = this.container.offset();
|
12
|
-
scrolly = parseInt($(window).scrollTop(), 10);
|
13
|
-
scrolly = scrolly < 0 ? 0 : scrolly;
|
14
|
-
toppy = offset.top+ dd_top - scrolly;
|
15
|
-
|
16
|
-
this.dropdown.css({
|
17
|
-
"top": toppy + "px",
|
18
|
-
"left": offset.left + "px"
|
19
|
-
});
|
20
|
-
};
|
21
|
-
|
22
|
-
Chosen.prototype.results_show = function() {
|
23
|
-
var dd_top;
|
24
|
-
var self = this;
|
25
|
-
|
26
|
-
// hide .chzn-drop when the window resizes else it will stay fixed with previous top and left coordinates
|
27
|
-
$(window).resize(function() {
|
28
|
-
self.results_hide();
|
29
|
-
});
|
30
|
-
|
31
|
-
if (!this.is_multiple) {
|
32
|
-
this.selected_item.addClass("chzn-single-with-drop");
|
33
|
-
if (this.result_single_selected) {
|
34
|
-
this.result_do_highlight(this.result_single_selected);
|
35
|
-
}
|
36
|
-
} else if (this.max_selected_options <= this.choices) {
|
37
|
-
this.form_field_jq.trigger("liszt:maxselected", {
|
38
|
-
chosen: this
|
39
|
-
});
|
40
|
-
return false;
|
41
|
-
}
|
42
|
-
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
|
43
|
-
this.form_field_jq.trigger("liszt:showing_dropdown", {
|
44
|
-
chosen: this
|
45
|
-
});
|
46
|
-
|
47
|
-
if($('.post-edit-holder').length) {
|
48
|
-
this.results_reposition();
|
49
|
-
|
50
|
-
$(window).scroll(function() {
|
51
|
-
if (self.results_showing) {
|
52
|
-
self.results_reposition();
|
53
|
-
}
|
54
|
-
});
|
55
|
-
} else {
|
56
|
-
this.dropdown.css({
|
57
|
-
"top": dd_top + "px",
|
58
|
-
"left": 0
|
59
|
-
});
|
60
|
-
}
|
61
|
-
|
62
|
-
this.results_showing = true;
|
63
|
-
this.search_field.focus();
|
64
|
-
this.search_field.val(this.search_field.val());
|
65
|
-
return this.winnow_results();
|
66
|
-
};
|