Permalink
Browse files

Merge branch 'next' into to_merge

  • Loading branch information...
2 parents 7ff1c4e + 6fd9b72 commit ed11b2d36df545738aa2f76f52bdb80d1dd233a7 @psy-q psy-q committed May 15, 2012
@@ -19,7 +19,8 @@
//= require video-js/video
//= require department-selection/department-selection
//= require set-widget/set-widget
-//= require mediaset-popup/mediaset-popup
+//= require media_set_popup/media_set_popup
+//= require media_entry_popup/media_entry_popup
//= require permission/permission
//= require iframe-wrapper/iframe-wrapper
//= require_tree ./media_resource
@@ -102,6 +102,9 @@ function setupBatch(json) {
if($(this).closest(".set_popup").length) {
// if target is a popup forward original
toggleSelected($(this).closest(".set_popup").data("target").tmplItem().data);
+ } else if($(this).closest(".entry_popup").length) {
+ // if target is a popup forward original
+ toggleSelected($(this).closest(".entry_popup").data("target").tmplItem().data);
} else {
toggleSelected($(this).closest(".item_box").tmplItem().data);
}
@@ -0,0 +1,87 @@
+###
+
+MediaEntry Popup
+
+This script extends the mediaentry thumb box of a grid view with an informative popup
+
+###
+
+jQuery ->
+ setup()
+
+setup = ->
+ $("#content_body.media_resources.miniature.index .item_box:not(.set):not(.popup_target) .thumb_box").live "mouseenter", -> enter_target $(this)
+ $("#content_body.media_resources.miniature.index .item_box:not(.set).popup_target:not(.popup) .thumb_box").live "mouseenter", -> enter_target $(this)
+ $("#content_body.media_resources.miniature.index .item_box:not(.set):not(.popup_target) .thumb_box").live "click", -> stop_target_popup $(this)
+ $("#content_body.media_resources.miniature.index .item_box:not(.set):not(.popup) .thumb_box").live "mouseleave", -> leave_target $(this)
+
+stop_target_popup = (target) ->
+ target = $(target).closest(".item_box")
+ window.clearTimeout($(target).data "popup_timeout")
+
+enter_target = (target)->
+ target = $(target).closest(".item_box")
+ window.clearTimeout($(target).data "popup_timeout")
+ $(target).data "popup_timeout", window.setTimeout ->
+ open_popup target
+ , 800
+
+open_popup = (target)->
+ $(".entry_popup").each (i, element)-> close_popup element
+ $(target).addClass("popup_target")
+ create_popup target if($(target).data("popup") == undefined)
+
+create_popup = (target)->
+ # create copy of target
+ copy = $(target).clone()
+ copy.addClass("popup")
+ # create container
+ container = $("<div class='entry_popup'></div>")
+ container.css
+ "width": copy.outerWidth()
+ "position": "absolute"
+ "z-index": 9999
+ # add pop up to target
+ $(target).data "popup", container
+ # add target to data
+ $(container).data "target", target
+ # add to dom
+ $(container).append copy
+ $(container).hide()
+ $("body").append container
+ # positioning
+ $(container).position
+ my: "top left",
+ at: "top left",
+ of: $(target)
+ offset: "0 25px"
+ $(container).show()
+ $(container).bind "mouseleave", -> leave_popup $(this)
+
+close_popup = (popup_container)->
+ # clear timeouts
+ window.clearTimeout($(popup_container).data("popup_timeout"))
+ window.clearTimeout($(popup_container).data("load_timeout"))
+ # TODO: animate closing
+ # remove popup from dom
+ remove_popup popup_container
+
+remove_popup = (popup_container)->
+ target = $(popup_container).data("target")
+ $(target).removeData("popup")
+ $(popup_container).remove()
+ window.setTimeout ->
+ $(target).removeClass("popup_target")
+ , 200
+
+leave_target = (target)->
+ container = $(target).closest(".item_box")
+ window.clearTimeout($(container).data("popup_timeout"))
+ window.clearTimeout($(container).data("load_timeout"))
+
+leave_popup = (popup)->
+ target = $(target).closest(".item_box")
+ target = $(popup).closest(".entry_popup")
+ close_popup target
+
+
@@ -170,7 +170,7 @@ create_popup = (target)->
container.append copy
$("body").append container
# positioning
- offset = if $(".media_resources.index.miniature").length then "0 48" else 0
+ offset = if $(".media_resources.index.miniature").length then "0 40" else 0
$(container).position {
my: "top left",
at: "top left",
@@ -15,7 +15,7 @@ section.media_resources.index
display: inline
#results
- margin-top: 18px
+ margin-top: 26px
.item_box
display: inline-block
@@ -52,6 +52,10 @@ section.media_resources.index
img
max-height: 50px
max-width: 50px
+
+ &>.thumb_box
+ margin-right: 4px
+ width: 60
.item_title, .item_author, .actions, .item_permission
display: none !important
@@ -1,5 +1,10 @@
@import "../mixins.scss";
+.entry_popup .item_box {
+ border: 2px solid #f1f1f1;
+ @include box-shadow(0 0 9px rgba(0, 0, 0, 0.3));
+}
+
.set_popup {
.popup {
@@ -85,7 +85,7 @@ def index(ids = (params[:collection_id] ? MediaResource.by_collection(current_us
per_page = [(params[:per_page] || PER_PAGE.first).to_i, PER_PAGE.first].min,
meta_key_id = params[:meta_key_id],
meta_term_id = params[:meta_term_id] )
-
+
respond_to do |format|
format.html
format.json {

0 comments on commit ed11b2d

Please sign in to comment.