Permalink
Browse files

adding a simple post partial that should be callable from anything wi…

…th a story object; some minor tweaks to the media items simple form to allow hiding (these changes shouldn't be breaking)
  • Loading branch information...
1 parent 897ae6e commit 75b96554a5d5c451e519fe9fcd0bae8669d65c2b @gaorlov committed Jan 27, 2012
View
107 app/stylesheets/default_v3.sass
@@ -1579,56 +1579,69 @@ body div.jGrowl div.jGrowl-closer
width: auto
form.formtastic
padding: $ninesixty_gutter_width / 2 0 0 0
- fieldset
- margin-bottom: $ninesixty_gutter_width / 2
- &.share-story-input
- +grid(6)
- +alpha()
- &.share-story-submit
- padding: 0
- border: 0
- +grid(2)
- +omega()
- input
- margin: 0
- .post-input-wrap
- +grid(5)
- +omega()
+ fieldset.form-desc
+ #sharing_box
+ margin-bottom: $ninesixty_gutter_width / 2
+ &.share-story-input
+ +grid(6)
+ +alpha()
+ &.share-story-submit
+ padding: 0
+ border: 0
+ +grid(2)
+ +omega()
+ input
+ margin: 0
+ .post-input-wrap
+ +grid(5)
+ +omega()
+ #media
+ fieldset.titles
+ float: right
+ width: 70%
+ input
+ float: left
+ #content_caption
+ width: 100%
+ #display_url
+ font-weight: bold
+ font-color: #666
+ font-size: 12px
+ margin-left: 6px
+ .media.inputs, .media_content
+ float: left
+ width: 100%
+ .hidden_image_form, .image-fieldset
+ display: none
+ #scrollbox
+ width: 30%
+ floar:left
.img-rotator-wrap
- +grid(3)
+ width: 100%
+alpha()
- .img-viewport-wrap, .no-img-input
- +grid(3)
- +alpha()
- +omega()
- .img-viewport-wrap
- padding-top: 10px
- position: relative
- .img-viewport
- min-height: 100px
- background: #fff
- margin-bottom: 30px
- .img-rotate-btn
- height: 20px
- width: 20px
- display: block
- position: absolute
- text-align: center
- bottom: 0px
- &.prev
- background: image_url("site/ir-arrows.png") top left no-repeat
- left: 10px
- &:hover
- background-position: bottom left
- &.next
- background: image_url("site/ir-arrows.png") top right no-repeat
- right: 10px
- &:hover
- background-position: bottom right
-
- .no-img-input
- padding: 10px 0
+ .scrollable
+ width: 130px
+ .img-rotate-btn
+ height: 20px
+ width: 20px
+ display: block
+ position: absolute
text-align: center
+ bottom: 0px
+ &.prev
+ background: image_url("site/ir-arrows.png") top left no-repeat
+ left: 10px
+ &:hover
+ background-position: bottom left
+ &.next
+ background: image_url("site/ir-arrows.png") top right no-repeat
+ right: 10px
+ &:hover
+ background-position: bottom right
+
+ .no-img-input
+ padding: 10px 0
+ text-align: center
// External Header Widget
View
62 app/views/shared/forms/_media_items_simple.html.haml
@@ -1,37 +1,39 @@
-%h1= t('media.add_video')
+.media_content.video
+ %h1= t('media.add_video')
-%fieldset
- %p
- Add an video to display along with your story from another website i.e. YouTube
+ %fieldset
+ %p
+ Add an video to display along with your story from another website i.e. YouTube
-%h3= t('media.add_video_title')
+ %h3= t('media.add_video_title')
-%fieldset.inputs
- - item.videos.build if item.videos.empty?
- - form.semantic_fields_for :videos do |video_form|
- = video_form.input :remote_video_url, :label => false, :required => false
- = video_form.input :embed_code, :required => false, :input_html => {:class => 'hide embed-video'}
- %a.toggle-embed-video{:href=> "#"}= t('add_by_embed_code')
- -# = video_form.input :embed_code, :label => false, :required => false
- -#%a{:href=> "#"}= t('edit_caption')
+ %fieldset.inputs
+ - item.videos.build if item.videos.empty?
+ - form.semantic_fields_for :videos do |video_form|
+ = video_form.input :remote_video_url, :label => false, :required => false
+ = video_form.input :embed_code, :required => false, :input_html => {:class => 'hide embed-video'}
+ %a.toggle-embed-video{:href=> "#"}= t('add_by_embed_code')
+ -# = video_form.input :embed_code, :label => false, :required => false
+ -#%a{:href=> "#"}= t('edit_caption')
-%h1= t('media.add_audio')
+.media_content.audio
+ %h1= t('media.add_audio')
-%fieldset
- %p
- Add an audio track to display along with your story from another website.
+ %fieldset
+ %p
+ Add an audio track to display along with your story from another website.
-%h3= t('media.add_audio_title')
-%fieldset.inputs
- - item.audios.build if item.audios.empty?
- - form.semantic_fields_for :audios do |audio_form|
- = audio_form.input :url, :required => false, :label => false
- - if get_setting_value('enable_audio_embed') and current_user.is_moderator?
- = audio_form.input :embed_code, :required => false, :input_html => {:class => 'hide embed-audio'}
- %a.toggle-embed-audio{:href=> "#"}= t('add_by_embed_code')
- -#%a{:href=> "#"}= t('edit_caption')
- -#
- = audio_form.input :title, :required => false
- = audio_form.input :album, :required => false
- = audio_form.input :artist, :required => false
+ %h3= t('media.add_audio_title')
+ %fieldset.inputs
+ - item.audios.build if item.audios.empty?
+ - form.semantic_fields_for :audios do |audio_form|
+ = audio_form.input :url, :required => false, :label => false
+ - if get_setting_value('enable_audio_embed') and current_user.is_moderator?
+ = audio_form.input :embed_code, :required => false, :input_html => {:class => 'hide embed-audio'}
+ %a.toggle-embed-audio{:href=> "#"}= t('add_by_embed_code')
+ -#%a{:href=> "#"}= t('edit_caption')
+ -#
+ = audio_form.input :title, :required => false
+ = audio_form.input :album, :required => false
+ = audio_form.input :artist, :required => false
View
143 app/views/shared/forms/_simple_story_post.html.haml
@@ -0,0 +1,143 @@
+:javascript
+ $(function() {
+ $('#media .media_content').each(function(){
+ $(this).hide();
+ });
+ $('.toggle-embed-video').click(function(event) {
+ event.preventDefault();
+ $('#media .video').show();
+ $(this).remove();
+ });
+ $('.toggle-embed-audio').click(function(event) {
+ event.preventDefault();
+ $('#media .audio').show();
+ $(this).remove();
+ });
+
+ var index = 0;
+ var count = 0;
+
+ $('#parse_url_button').click(function(event){
+ event.preventDefault();
+ url_bar = $('form.post_story #content_url');
+ if (url_bar.val() != '') {
+ url_bar.addClass('process');
+ $('#content_title').addClass('process');
+ $('#sharing_box .loader').show();
+ $.ajax({
+ type: "POST",
+ url: "/stories/parse_page",
+ data: {url: url_bar.val()},
+ dataType: "json",
+ success: function(data, textStatus) {
+ if ($('#content_title').val() == '') {
+ $('#content_title').val(data.title);
+ }
+ if (data.description) {
+ if ($('#content_caption').val() == '') {
+ $('#content_caption').val(data.description);
+ }
+ }
+ if (data.images.length > 0) {
+ // Hack to make this work in chrome..
+ // can't use your typical itemLoadCallback
+ $("#scrollbox").show();
+ count = data.images.length;
+ $(".scrollable").scrollable();
+
+ var api = $(".scrollable").data("scrollable");
+ jQuery.each(data.images, function(i, url) {
+ api.addItem('<img src="'+url+'" width="75" height="75" />');
+ });
+ $(".items img").click(function() {
+ if($('.image-url-input').length != 0){
+ $('.image-url-input').each(function(){$(this).parent().find('.delete_image').click();});}
+ $('#add_image').click();
+ $('.image-url-input').last().val($(this).attr('src'));
+ $('.image-url-input').last().parent().next().remove();
+ $('.image-url-input').last().next().remove();
+ $('.image-url-input').last().after($('.delete_image').last());
+ });
+ $($(".items img")[0]).click();
+ }else{
+ $('#media .titles').css({'width': '100%'});
+ }
+ $('#content_url').removeClass('process');
+ $('#content_title').removeClass('process');
+ $('#display_url').html(url_bar.val());
+ $('#sharing_box').hide();
+ $('#media').show();
+ },
+ error: function(xhr, status, errorThrown) {
+ var result = $.parseJSON(xhr.responseText);
+ alert(result.error);
+ $('#content_url').removeClass('process');
+ $('#content_title').removeClass('process');
+ }
+ });
+ }
+ return false;
+ });
+ $(".no-img-input input").click(function(event){
+ if(event.currentTarget.checked){
+ $('.image-url-input').each(function(){$(this).parent().find('.delete_image').click();})}
+ else
+ $($(".items img")[index]).click();
+ });
+ $(".prev.img-rotate-btn").live('click', function(){
+ index = index == 0 ? 0 : index - 1;
+ $($(".items img")[index]).click();
+ console.debug(index)
+ return false;
+ });
+
+ $(".next.img-rotate-btn").live('click', function(){
+ index = index == count ? count : index + 1;
+ $($(".items img")[index]).click();
+ console.debug(index)
+ return false;
+ });
+ });
+#flowplayer-block
+ - semantic_form_for story, :url => stories_path, :html => { :multipart => true, :class => "post_story" } do |form|
+ .simple-post-wrap.clearfix
+ .close-btn
+ .simple-post
+ .panel-bar
+ %h2 Simple Posting Widget
+ %form.formtastic
+ %fieldset.form-desc
+ %p Share a Story
+ #sharing_box
+ -form.inputs do
+ =form.input :url
+ .loader{:style => "display:block;background:url('/images/site/spinner.gif');height:11px;width:16px;float:right;margin-right:12px;display:none;"}
+ - form.buttons do
+ = form.commit_button 'Look up!', :class => "float-right", :button_html => {:id => "parse_url_button", :class => 'button-input next create' }
+ #media{:style => "display:none"}
+ - form.inputs :class => "inputs titles" do
+ = form.input :title
+ %p#display_url
+ = form.input :caption, :input_html => { :rows => '3', :cols => '20' }
+ .hidden_image_form
+ =add_image_simple(form)
+ #scrollbox
+ .img-rotator-wrap
+ %a.prev.browse.img-rotate-btn
+ .scrollable
+ .items
+ %a.next.browse.img-rotate-btn
+ .no-img-input
+ %label
+ %input{ :type => 'checkbox', :id => "no_image"}
+ No Image
+ %p
+ %fieldset.media.inputs
+ %ol
+ %li
+ %a.media-link.toggle-embed-video Add Video
+ %li
+ %a.media-link.toggle-embed-audio Add Audio
+ = render :partial => 'shared/forms/media_items_simple', :locals => { :form => form, :item => story }
+ - form.buttons do
+ = form.commit_button t('wizard.post_now'), :class => 'float-right', :button_html => { :class => 'button-input' }

0 comments on commit 75b9655

Please sign in to comment.