diff --git a/app/assets/javascripts/edit-main.js b/app/assets/javascripts/edit-main.js
index bc1f709..e6be154 100644
--- a/app/assets/javascripts/edit-main.js
+++ b/app/assets/javascripts/edit-main.js
@@ -1,50 +1,5 @@
(function(){
- var getUrlVars = function(){
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++){
- hash = hashes[i].split('=');
- vars.push(decodeURIComponent(hash[0]));
- vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]);
- }
- if(vars[0] == window.location.href){
- vars =[];
- }
- return vars;
- }
- var page_params = getUrlVars();
$(document).ready(function(){
$("head").append(" ");
- var dataObject = (page_params['mobile_view'] ? {"page_id" : page_params["id"],"mobile_view" : 1} : {"page_id" : page_params["id"]})
- $.ajax({
- url : "/page_parts/info",
- dataType : "json",
- type : "get",
- data : dataObject
- }).done(function(data){
- $.each(data.parts,function(i,part){
- var page_part = $("*[" + part.name + "]");
- $.each(part.subparts,function(x,subpart){
- var newsub = (subpart.kind == "module_widget" ? $("
" + subpart.module + "/" + subpart.widget + "
") : $("Text
"));
- page_part.prepend(newsub);
- newsub.click(function(){
- window.location.href = "/page_parts/edit_sub_part?page_id=" + page_params["id"] + "&part_id=" + $(this).data("partid") + "&sub_part_id=" + $(this).data("ps")+(page_params["mobile_view"] ? "&mobile_view=1": "");
- })
- })
- })
- })
-
- $("*[data-pp]").each(function(){
- var add_btn = $(""),
- part = $(this);
- add_btn.click(function(){
- if(part.find("*[data-ps]").length){
- window.location.href = "/page_parts/" + part.data("pp") + "/edit?page_id=" + page_params["id"]+(page_params["mobile_view"] ? "&mobile_view=1": "");
- }else{
- window.location.href = "/page_parts/new?part=" + part.data("pp") + "&page_id=" + page_params["id"]+(page_params["mobile_view"] ? "&mobile_view=1": "");
- }
- })
- part.append(add_btn);
- })
})
})();
\ No newline at end of file
diff --git a/app/assets/stylesheets/pp-add-edit.css b/app/assets/stylesheets/pp-add-edit.css
index b07b3cf..cb34687 100644
--- a/app/assets/stylesheets/pp-add-edit.css
+++ b/app/assets/stylesheets/pp-add-edit.css
@@ -8,63 +8,84 @@
margin: 0 auto;
position: relative;
}
-*[data-pp] > *[data-ps] {
- padding: 3px;
- height: 50px;
- outline: thin dotted #EBB666;
- cursor: pointer;
+*[data-pp] > .editmode-ps {
position: relative;
+ min-height: 150px;
+ outline: 2px dotted #EBB666;
+ cursor: pointer;
}
-*[data-pp] > *[data-ps]:before {
- content: "";
- line-height: 100%;
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- background-color: #a1a1a1;
- opacity: 0.6;
- filter: alpha(opacity=60);
-}
-*[data-pp] > *[data-ps]:after {
- font-size: 1rem;
- font-weight: 300;
- content: "Edit";
- text-align: center;
- margin-top: -0.7rem;
+*[data-pp] > .editmode-ps:before {
+ content: attr(title);
+ display: block;
position: absolute;
top: 50%;
- right: 0;
- left: 0;
-}
-*[data-pp] > *[data-ps]:hover:before {
- opacity: 0.8;
- filter: alpha(opacity=80);
-}
-*[data-pp] > *[data-ps]:hover:after {
- font-weight: 400;
-}
-*[data-pp] > .add-ps {
- text-align: center;
- position: relative;
width: 100%;
- min-height: 2rem;
- line-height: 2rem;
- cursor: pointer;
+ color: #47bab5;
+ margin-top: 10px;
+ text-align: center;
+ font-size: 1.3em;
+ z-index: 778;
}
-*[data-pp] > .add-ps:after {
- font-size: 1rem;
- font-weight: 300;
- content: "Add";
+*[data-pp] > .editmode-ps > a {
+ display: block;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
- background-color: #e0dbcb;
+ background-color: rgba(255, 255, 255, .5);
+ z-index: 777;
}
-*[data-pp] > .add-ps:hover:after {
- font-weight: 400;
- background-color: #923132;
+*[data-pp] > .editmode-ps > a:before {
+ content: "\f044";
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ font-size: 3.4em;
+ width: 40px;
+ height: 40px;
+ margin: -30px 0 0 -20px;
+ display: inline-block;
+ font-family: FontAwesome;
+ font-style: normal;
+ font-weight: normal;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+*[data-pp] > .editmode-ps:hover:before {
+ color: #FFF;
+}
+*[data-pp] > .editmode-ps:hover > a {
+ color: #FFF;
+ background-color: rgba(17, 117, 184, .8);
+}
+*[data-pp] > a {
+ position: relative;
+ display: block;
+ height: 40px;
+ margin: 10px 0;
+ border-radius: 5px;
+ color: #8DE2FD;
+ background-color: #14A1AD;
+}
+*[data-pp] > a:before {
+ content: "\f055";
+ position: absolute;
+ top: 50%;
+ left: 50%;
+ font-size: 1.5em;
+ width: 20px;
+ height: 20px;
+ margin: -10px 0 0 -10px;
+ display: inline-block;
+ font-family: FontAwesome;
+ font-style: normal;
+ font-weight: normal;
+ line-height: 1;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+}
+*[data-pp] > a:hover {
+ color: #FFF;
}
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index e65e323..162b1f6 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -8,6 +8,7 @@ class PagesController < ApplicationController
include PagesHelper
before_filter :check_frontend_open, :only => [:home,:show]
before_filter :check_authorization, :except => [:home,:show]
+ before_filter :set_edit_mode
def index
@pages = Page.all
@@ -17,8 +18,6 @@ class PagesController < ApplicationController
def edit_view
@manifest = @key
@dataApi = "edit"
-
- # @qq = render_to_string(:partial => @p, :layout => false)
view = get_view
if File.exists?(view)
render view
@@ -27,7 +26,6 @@ class PagesController < ApplicationController
def home
@manifest = @key
- @dataApi = nil
page = Page.first
impressionist(page)
OrbitHelper.set_params params
@@ -74,7 +72,6 @@ class PagesController < ApplicationController
params[:url] = page.url
@manifest = @key
- @dataApi = nil
OrbitHelper.set_params params
OrbitHelper.set_site_locale locale
OrbitHelper.set_this_module_app module_app.singularize
@@ -267,10 +264,18 @@ class PagesController < ApplicationController
custom_value = subpart.custom_string_field || subpart.custom_array_field rescue nil
if !custom_value.nil?
OrbitHelper.set_widget_custom_value custom_value
- end
- partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type)
+ end
+ if @editmode
+ partials << " " + render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type) + "
"
+ else
+ partials << render_widget_for_frontend(subpart.module,subpart.widget_method,subpart.widget_type)
+ end
elsif subpart.kind == "text"
- partials << subpart.content
+ if @editmode
+ partials << ""
+ else
+ partials << subpart.content
+ end
end
end
@part_partials["data-pp='#{part.part_id}'"] = partials
@@ -298,6 +303,19 @@ class PagesController < ApplicationController
end
end
+ if @editmode
+ pps = doc.css("*[data-pp]")
+ pps.each do |pp|
+ number = pp.attributes["data-pp"].value
+ if pp.inner_html == ""
+ pp.inner_html = " "
+ else
+ inner_html = pp.inner_html
+ pp.inner_html = inner_html + " "
+ end
+ end
+ end
+
if original_view != "home"
viewarea = doc.css("*[data-content='true']")[0]
viewarea.inner_html = render_to_string(original_view) rescue ""
@@ -384,6 +402,21 @@ class PagesController < ApplicationController
redirect_to '/admin/dashboards'
end
end
+
+ def set_edit_mode
+ if !current_user.nil? and current_user.is_admin?
+ if params[:editmode] == "on"
+ @editmode = true
+ @dataApi = "edit"
+ else
+ @dataApi = nil
+ @editmode = false
+ end
+ else
+ @dataApi = nil
+ @editmode = false
+ end
+ end
def change_to_language(final_html)
if session[:zh_cn]
diff --git a/app/views/admin/items/_node.html.erb b/app/views/admin/items/_node.html.erb
index a92d6f5..b4c3a07 100644
--- a/app/views/admin/items/_node.html.erb
+++ b/app/views/admin/items/_node.html.erb
@@ -18,7 +18,7 @@
<%= link_to node.name, node.external_url %>
<% end %>