Fix mobile web in structure

This commit is contained in:
manson 2014-05-29 19:14:30 +08:00
parent 1cdfc53b4d
commit 234a75e425
4 changed files with 18 additions and 10 deletions

View File

@ -28,7 +28,7 @@
var newsub = (subpart.kind == "module_widget" ? $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>" + subpart.module + "/" + subpart.widget + "</div>") : $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>Text</div>")); var newsub = (subpart.kind == "module_widget" ? $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>" + subpart.module + "/" + subpart.widget + "</div>") : $("<div data-partid='" + part.id + "' data-ps='" + subpart.id + "'>Text</div>"));
page_part.prepend(newsub); page_part.prepend(newsub);
newsub.click(function(){ 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"); 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": "");
}) })
}) })
}) })
@ -39,9 +39,9 @@
part = $(this); part = $(this);
add_btn.click(function(){ add_btn.click(function(){
if(part.find("*[data-ps]").length){ if(part.find("*[data-ps]").length){
window.location.href = "/page_parts/" + part.data("pp") + "/edit?page_id=" + page_params["id"]; window.location.href = "/page_parts/" + part.data("pp") + "/edit?page_id=" + page_params["id"]+(page_params["mobile_view"] ? "&mobile_view=1": "");
}else{ }else{
window.location.href = "/page_parts/new?part=" + part.data("pp") + "&page_id=" + page_params["id"]; 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); part.append(add_btn);

View File

@ -4,7 +4,9 @@
<%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %> <%= form_for @part, url: {action: "update"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" /> <input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" /> <input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
<% if OrbitHelper.is_mobile_view %>
<input class="hidden_page_id" name="mobile_view" type="hidden" value="1">
<% end %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<% end %> <% end %>
@ -16,7 +18,7 @@
$.ajax({ $.ajax({
url : "/page_parts/getwidgets", url : "/page_parts/getwidgets",
dataType : "html", dataType : "html",
data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part_number %>}, data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part_number %>, "mobile_view" : <%= OrbitHelper.is_mobile_view ? "1" : "null" %>},
type : "get" type : "get"
}).done(function(html){ }).done(function(html){
widget_area.html(html); widget_area.html(html);
@ -24,6 +26,6 @@
} }
}) })
$("form").on("ajax:success",function(){ $("form").on("ajax:success",function(){
window.location.href = "/pages/edit_view?id=<%= params[:page_id] %><%= OrbitHelper.is_mobile_view ? '&mobile_view=1' %>"; window.location.href = "/pages/edit_view?id=<%= params[:page_id] %><%= OrbitHelper.is_mobile_view ? '&mobile_view=1'.html_safe : '' %>";
}) })
</script> </script>

View File

@ -4,6 +4,9 @@
<%= form_for @part, url: update_sub_part_page_part_path(@subpart), :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %> <%= form_for @part, url: update_sub_part_page_part_path(@subpart), :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<input type="hidden" name="part_id" value="<%= @part.id.to_s %>" /> <input type="hidden" name="part_id" value="<%= @part.id.to_s %>" />
<input type="hidden" name="page_id" value="<%= params[:page_id] %>" /> <input type="hidden" name="page_id" value="<%= params[:page_id] %>" />
<% if OrbitHelper.is_mobile_view %>
<input class="hidden_page_id" name="mobile_view" type="hidden" value="1">
<% end %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<% end %> <% end %>
@ -15,7 +18,7 @@
$.ajax({ $.ajax({
url : "/page_parts/getwidgets", url : "/page_parts/getwidgets",
dataType : "html", dataType : "html",
data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part.part_id %>}, data : {"module" : select.val(), "page_id" : "<%= params[:page_id] %>", "part_id" : <%= @part.part_id %>, "mobile_view" : <%= OrbitHelper.is_mobile_view ? "1" : "null" %>},
type : "get" type : "get"
}).done(function(html){ }).done(function(html){
widget_area.html(html); widget_area.html(html);
@ -23,6 +26,6 @@
} }
}) })
$("form").on("ajax:success",function(){ $("form").on("ajax:success",function(){
window.location.href = "/pages/edit_view?id=<%= params[:page_id] %>"; window.location.href = "/pages/edit_view?id=<%= params[:page_id] %><%= OrbitHelper.is_mobile_view ? '&mobile_view=1'.html_safe : '' %>";
}) })
</script> </script>

View File

@ -4,6 +4,9 @@
<%= form_for @part, url: {:action => "create"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %> <%= form_for @part, url: {:action => "create"}, :remote=>true, html: { class: "form-horizontal main-forms"} do |f| %>
<input class="hidden_part_id" id="part_part_id" name="page_part[part_id]" type="hidden" value="<%= @part_number %>"> <input class="hidden_part_id" id="part_part_id" name="page_part[part_id]" type="hidden" value="<%= @part_number %>">
<input class="hidden_page_id" id="part_page_id" name="page_part[page_id]" type="hidden" value="<%= @page_id %>"> <input class="hidden_page_id" id="part_page_id" name="page_part[page_id]" type="hidden" value="<%= @page_id %>">
<% if OrbitHelper.is_mobile_view %>
<input class="hidden_page_id" name="mobile_view" type="hidden" value="1">
<% end %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<% end %> <% end %>
@ -15,7 +18,7 @@
$.ajax({ $.ajax({
url : "/page_parts/getwidgets", url : "/page_parts/getwidgets",
dataType : "html", dataType : "html",
data : {"module" : select.val(),"part_id" : <%= @part_number %>, "page_id" : "<%= params[:page_id] %>"}, data : {"module" : select.val(),"part_id" : <%= @part_number %>, "page_id" : "<%= params[:page_id] %>", "mobile_view" : <%= OrbitHelper.is_mobile_view ? "1" : "null" %>},
type : "get" type : "get"
}).done(function(html){ }).done(function(html){
widget_area.html(html); widget_area.html(html);
@ -23,6 +26,6 @@
} }
}) })
$("form").on("ajax:success",function(){ $("form").on("ajax:success",function(){
window.location.href = "/pages/edit_view?id=<%= params[:page_id] %>"; window.location.href = "/pages/edit_view?id=<%= params[:page_id] %><%= OrbitHelper.is_mobile_view ? '&mobile_view=1'.html_safe : '' %>";
}) })
</script> </script>