From 067f7b18e542b6f50f9dd3d3a413c4aa95ce0b94 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 3 Nov 2014 20:00:59 +0800 Subject: [PATCH] added some method in orbit helper and some mods --- app/controllers/pages_controller.rb | 4 +- app/helpers/orbit_helper.rb | 20 ++- app/helpers/pages_helper.rb | 6 +- .../stylesheets/template/base/_tab.scss | 166 ++++++++++++++++++ .../assets/stylesheets/template/template.scss | 1 + .../_content.html.erb | 35 ++++ .../_widget1.html.erb | 116 ++++++++---- config/initializers/keyword_constraint.rb | 2 +- 8 files changed, 309 insertions(+), 41 deletions(-) create mode 100644 app/templates/orbit_bootstrap/assets/stylesheets/template/base/_tab.scss create mode 100644 app/templates/orbit_bootstrap/widgets/announcement_link_widget/_content.html.erb diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index a61308b..6d72ba0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -289,9 +289,9 @@ class PagesController < ApplicationController OrbitHelper.set_widget_custom_value custom_value end if @editmode - partials << "
" + render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type) + "
" + partials << "
" + render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type,subpart.id.to_s) + "
" else - partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type) + partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type,subpart.id.to_s) end elsif subpart.kind == "text" if @editmode diff --git a/app/helpers/orbit_helper.rb b/app/helpers/orbit_helper.rb index 0c3c627..cbb01e0 100644 --- a/app/helpers/orbit_helper.rb +++ b/app/helpers/orbit_helper.rb @@ -12,6 +12,24 @@ module OrbitHelper @tags = tags; end + def self.register_subpart(subpart_id) + subpart = SubPart.find(subpart_id) rescue nil + if !subpart.nil? + self.set_current_widget subpart + self.set_widget_data_count subpart.data_count + self.set_widget_categories subpart.categories + self.set_widget_module_app subpart.module + self.set_widget_item_url subpart + self.set_widget_title subpart.title + self.set_widget_categories subpart.categories || [] + self.set_widget_tags subpart.tags || [] + custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil + if !custom_value.nil? + self.set_widget_custom_value custom_value + end + end + end + def self.set_page_role_status(role_status) @role_status = role_status; end @@ -182,7 +200,7 @@ module OrbitHelper self.set_widget_module_app module_app @url_widget_for_show = "" pages = Page.where(:module => module_app) - widget_categories = self.get_current_widget.categories + widget_categories = self.get_current_widget.categories rescue [] finalpage = nil pages.each do |p| if p.categories == widget_categories diff --git a/app/helpers/pages_helper.rb b/app/helpers/pages_helper.rb index 7177a65..54dd677 100644 --- a/app/helpers/pages_helper.rb +++ b/app/helpers/pages_helper.rb @@ -11,7 +11,7 @@ module PagesHelper doc.to_html end - def render_widget_for_frontend(controller_name, widget_method, widget_file) + def render_widget_for_frontend(controller_name, widget_method, widget_file, subpart_id=nil) def widget_parsing_repeats_again(elements,d,level) newhtml = [] oldhtml = [] @@ -45,6 +45,7 @@ module PagesHelper end [oldhtml,newhtml] end + @key = Site.first.template if @key.nil? controller_name = controller_name.downcase.singularize f = File.join(Rails.root, 'app', 'templates', "#{@key}", 'modules', "#{controller_name}", "_#{widget_file}.html.erb"); if !File.exists?f @@ -64,6 +65,9 @@ module PagesHelper end s = render_to_string(f) doc = Nokogiri::HTML(s, nil, "UTF-8") + if !subpart_id.nil? + doc.css("body").children.first.set_attribute("data-subpart-id", subpart_id) rescue nil + end wrap_elements = doc.css("*[data-repeat]") controller = "#{controller_name.capitalize.pluralize}_controller".classify.constantize.new OrbitHelper.set_current_widget_module controller_name diff --git a/app/templates/orbit_bootstrap/assets/stylesheets/template/base/_tab.scss b/app/templates/orbit_bootstrap/assets/stylesheets/template/base/_tab.scss new file mode 100644 index 0000000..e666ec0 --- /dev/null +++ b/app/templates/orbit_bootstrap/assets/stylesheets/template/base/_tab.scss @@ -0,0 +1,166 @@ +.w-annc-weblink { + .pagination { + position: absolute; + top: 8px; + right: 0; + margin: 0; + a { + text-indent: -9999px; + display: inline-block; + width: 14px; + height: 14px; + border-radius: 3px; + margin-left: -2px; + color: #cc0033; + background-color: #fff; + border: 1px solid #dcdcdc; + font-family: 'entypo'; + text-align: center; + position: relative; + &.next { + &:before { + content: "\e0d4"; + } + } + &.prev { + color: #6C6C6C; + &:before { + content: "\e0d1"; + } + } + &:before { + text-indent: 0; + position: absolute; + top: 0; + left: 0; + width: 12px; + height: 12px; + line-height: 12px; + } + } + } + .tab { + padding: 1em; + position: relative; + z-index: 1; + min-height: 240px; + } + .tab-list { + position: relative; + .tab-item { + position: relative; + width: 105px; + padding: 0.5em 0; + z-index: 2; + a { + display: block; + padding: 0.3em 0.5em; + margin-right: 1em; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + color: #333; + text-decoration: none; + line-height: 14px; + } + &.active, + &:hover { + a { + color: #000; + font-weight: bold; + background: transparent url(/assets/tag.png) left -6px no-repeat; + &:after { + content: ""; + position: absolute; + top: 0.5em; + right: 0; + width: 1em; + height: 21px; + background: transparent url(/assets/tag.png) right -6px no-repeat; + } + } + } + &:hover { + a { + background: transparent url(/assets/tag.png) left -36px no-repeat; + &:after { + background: transparent url(/assets/tag.png) right -36px no-repeat; + } + } + } + } + } + .tab-body { + display: none; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + z-index: 0; + &.active { + display: block; + z-index: 1; + } + } + .annc-content { + position: absolute; + top: 0; + right: 140px; + left: 115px; + background-color: #fff; + .annc-heading { + line-height: 1.5em; + height: 1.6em; + margin: 0; + font-size: 18px; + border-bottom: 1px solid #C2C2C2; + .annc-more { + padding-top: 0; + color: #6C6C6C; + text-align: left; + font-weight: normal; + } + } + } + .wlink-content { + position: absolute; + top: 0; + right: 0; + width: 120px; + .wlink-heading { + height: 1.6em; + margin: 0; + line-height: 1.6em; + font-size: 18px; + padding-bottom: 0.3em; + border-bottom: 1px solid #C2C2C2; + } + } + .list { + margin: 0; + padding: 0; + list-style: none; + .list-item { + display: none; + padding: 0.5em 0; + width: 100%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + border-bottom: 1px solid #ccc; + & > a { + color: #333; + &:hover { + color: #cc0033; + } + } + } + } + a { + display: inline; + color: #6C6C6C; + line-height: 2em; + outline: none; + } +} \ No newline at end of file diff --git a/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss b/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss index 2fdace2..6dd0409 100644 --- a/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss +++ b/app/templates/orbit_bootstrap/assets/stylesheets/template/template.scss @@ -5,6 +5,7 @@ @import "base/mixins"; @import "base/variables"; @import "base/unity"; +@import "base/tab"; // Layout @import "layout/header"; diff --git a/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_content.html.erb b/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_content.html.erb new file mode 100644 index 0000000..98d3dd4 --- /dev/null +++ b/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_content.html.erb @@ -0,0 +1,35 @@ +
+
+ +
+ + +
+
+
\ No newline at end of file diff --git a/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_widget1.html.erb b/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_widget1.html.erb index 9bdf3b8..eae2bb0 100644 --- a/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_widget1.html.erb +++ b/app/templates/orbit_bootstrap/widgets/announcement_link_widget/_widget1.html.erb @@ -1,37 +1,81 @@ -