Skip to content

Commit

Permalink
New controller for Iframe #17
Browse files Browse the repository at this point in the history
  • Loading branch information
VarshaSarah committed Jul 28, 2014
1 parent b440af4 commit 37cf62c
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 25 deletions.
Binary file removed app/assets/123.png
Binary file not shown.
8 changes: 5 additions & 3 deletions app/assets/javascripts/screamout.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@ screamout = ->
}).appendTo('body')


jQ('*','body').not("#screamout").css("opacity","0.9")
jQ('*','body').not("#screamout").css("pointer-events","none")

jQ('<iframe>', {
style: "background-color: red"
id: 'screamout',
name: "newpage",
frameborder: 0,
scrolling: "no",
src: "http://localhost:8080/contents/new",
src: "http://localhost:8080/iframe_contents/new",
allowTransparency: true
}).appendTo('body')

jQ('*','body').not("#screamout").css("opacity","0.8")
jQ('*','body').not("#screamout").css("pointer-events","none")

$("body").not('#screamout').click ->
jQ('#screamout').remove()
jQ('*','body').not("#screamout").css("opacity","1")
jQ('*','body').not("#screamout").css("pointer-events","none")

test = ->
if @jQuery
@jQ = jQuery
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Place all the styles related to the New_Contents controller here.
// Place all the styles related to the IframeContents controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
4 changes: 2 additions & 2 deletions app/controllers/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ContentsController < ApplicationController

def index
#binding.pry
@contents = Content.all.desc(:created_at)
Expand All @@ -16,7 +16,7 @@ def show

def new
@content = Content.new
@con = []
@con = []
end

def details
Expand Down
24 changes: 24 additions & 0 deletions app/controllers/iframe_contents_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
class IframeContentsController < ApplicationController
layout 'iframe_application'
def new
@content = Content.new
@con = []
end

def create
@content = Content.new(content_params_input)
@content.image_file_name = @content.title

if @content.save
ImageWorker.perform_async(@content.id.to_s)
respond_to do |format|
format.html {redirect_to contents_path}
end
else
respond_to do |format|
format.html { render action: 'new' }
end
end
end

end
2 changes: 0 additions & 2 deletions app/controllers/new_contents_controller.rb

This file was deleted.

2 changes: 2 additions & 0 deletions app/helpers/iframe_contents_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module IframeContentsHelper
end
2 changes: 0 additions & 2 deletions app/helpers/new_contents_helper.rb

This file was deleted.

5 changes: 4 additions & 1 deletion app/views/contents/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
= f.input :user_id, :label =>'UserId', :placeholder => "UserId"
= f.input :tags, :label =>'Tags', :input_html => {"data-pre" => @content.tag_map.to_json, :id => "contentTags"}
= f.button :submit ,'Create', :class => 'btn btn-primary'
= link_to t('.cancel', :default => t("helpers.links.cancel")),contents_path, :class => 'btn btn-danger'
= f.button :button ,'Cancel',:class => 'btn btn-danger'
:javascript
$('#cancel').on ('click',function(){$('#myModal').modal('hide');})

19 changes: 19 additions & 0 deletions app/views/iframe_contents/_new_content2.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- content_for :indexpg do
= stylesheet_link_tag :blu
%button.close#cancel{type: "button"}
%span{"aria-hidden" => "true"} &times
%span.sr-only Close
.container-fluid{:style => "opacity:1;"}
.col-md-8
= simple_form_for(@content, wrapper: :horizontal, :html=>{:class => 'form-horizontal', :id=>"newform"}) do |f|
= f.error_notification
= f.input :url, :label =>'URL', :placeholder => "Url"
= f.input :title, :label =>'Title', :placeholder => "Title"
= f.input :rates, :label =>'Rates'
= f.input :user_id, :label =>'UserId', :placeholder => "UserId"
= f.input :tags, :label =>'Tags', :input_html => {"data-pre" => @content.tag_map.to_json, :id => "contentTags"}
= f.button :submit ,'Create', :class => 'btn btn-primary', :id => "create"
:javascript
$('#cancel').on ('click',function(){parent.window.postMessage("removetheiframe", "*");})
3 changes: 3 additions & 0 deletions app/views/iframe_contents/new.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

- model_class = Content
= render :partial => 'new_content2'
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Screamout</title>
<title>Latest----------------Screamout</title>

<%= stylesheet_link_tag "application", "token-input-facebook.css" %>
<%= stylesheet_link_tag "screamout", "token-input-facebook.css" %>

<%= stylesheet_link_tag media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>


<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body >

<%= yield %>

</body>
</html>
</html>
2 changes: 1 addition & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Rails.application.config.assets.precompile += [ 'jquery.tokeninput.js','token-input-facebook.css','token-input.css', 'contents.js.coffee','screamout.js.coffee']
Rails.application.config.assets.precompile += [ 'jquery.tokeninput.js','token-input-facebook.css','token-input.css', 'contents.js.coffee','screamout.js.coffee','screamout.css']
5 changes: 5 additions & 0 deletions spec/controllers/iframe_contents_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'spec_helper'

describe IframeContentsController do

end
5 changes: 0 additions & 5 deletions spec/controllers/new_contents_controller_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the NewContentsHelper. For example:
# the IframeContentsHelper. For example:
#
# describe NewContentsHelper do
# describe IframeContentsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
describe NewContentsHelper do
describe IframeContentsHelper do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 37cf62c

Please sign in to comment.