now smart seen by works also reply added.
This commit is contained in:
parent
2fe61680e3
commit
7fba2d782d
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Viewport - jQuery selectors for finding elements in viewport
|
||||
*
|
||||
* Copyright (c) 2008-2009 Mika Tuupola
|
||||
*
|
||||
* Licensed under the MIT license:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Project home:
|
||||
* http://www.appelsiini.net/projects/viewport
|
||||
*
|
||||
*/
|
||||
(function($) {
|
||||
|
||||
$.belowthefold = function(element, settings) {
|
||||
var fold = $(window).height() + $(window).scrollTop();
|
||||
return fold <= $(element).offset().top - settings.threshold;
|
||||
};
|
||||
|
||||
$.abovethetop = function(element, settings) {
|
||||
var top = $(window).scrollTop();
|
||||
return top >= $(element).offset().top + $(element).height() - settings.threshold;
|
||||
};
|
||||
|
||||
$.rightofscreen = function(element, settings) {
|
||||
var fold = $(window).width() + $(window).scrollLeft();
|
||||
return fold <= $(element).offset().left - settings.threshold;
|
||||
};
|
||||
|
||||
$.leftofscreen = function(element, settings) {
|
||||
var left = $(window).scrollLeft();
|
||||
return left >= $(element).offset().left + $(element).width() - settings.threshold;
|
||||
};
|
||||
|
||||
$.inviewport = function(element, settings) {
|
||||
return !$.rightofscreen(element, settings) && !$.leftofscreen(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
|
||||
};
|
||||
|
||||
$.extend($.expr[':'], {
|
||||
"below-the-fold": function(a, i, m) {
|
||||
return $.belowthefold(a, {threshold : 0});
|
||||
},
|
||||
"above-the-top": function(a, i, m) {
|
||||
return $.abovethetop(a, {threshold : 0});
|
||||
},
|
||||
"left-of-screen": function(a, i, m) {
|
||||
return $.leftofscreen(a, {threshold : 0});
|
||||
},
|
||||
"right-of-screen": function(a, i, m) {
|
||||
return $.rightofscreen(a, {threshold : 0});
|
||||
},
|
||||
"in-viewport": function(a, i, m) {
|
||||
return $.inviewport(a, {threshold : 0});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})(jQuery);
|
|
@ -44,7 +44,7 @@ class Admin::TicketsController < OrbitAdminController
|
|||
@members = []
|
||||
MemberProfile.all.each do |mp|
|
||||
user = mp.user rescue nil
|
||||
if !user.nil? && user.id.to_s != current_user.id.to_s && user.user_name != "rulingcom"
|
||||
if !user.nil? && user.id.to_s != current_user.id.to_s
|
||||
avatar = (mp.avatar.thumb.url == "thumb_person.png" ? "/assets/thumb_person.png" : mp.avatar.thumb.url rescue "/assets/thumb_person.png")
|
||||
@members << {
|
||||
"id" => user.id.to_s,
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="ticket-internal-response-wrap">
|
||||
<div class="ticket-internal-response">
|
||||
<input type="hidden" name="ticket_query_id" value="<%= query.id.to_s %>" />
|
||||
<input type="checkbox" name="internal_response" value="1">
|
||||
<input type="checkbox" checked="checked" name="internal_response" value="1">
|
||||
<span class="ticket-internal-response">Internal Response</span>
|
||||
</div>
|
||||
<div class="ticket-tag-member">
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="ticket-response-item" data-scroll-id="response_<%= response.id.to_s %>">
|
||||
<div class="ticket-response-item" data-scroll-id="response_<%= response.id.to_s %>" data-response-by="<%= response.response_by %>">
|
||||
<div class="ticket-response-meta">
|
||||
<div class="ticket-response-author">
|
||||
<% user = User.find(response.response_by) rescue nil %>
|
||||
|
@ -14,15 +14,20 @@
|
|||
<div class="ticket-response-created-date">
|
||||
<% dt = DateTime.parse(response.created_at.to_s) %> <%= dt.strftime("%d %B %Y - %H:%M") %>
|
||||
</div>
|
||||
<% if user.id.to_s == current_user.id.to_s %>
|
||||
<div class="ticket-response-delete-wrap">
|
||||
<% if user.id.to_s == current_user.id.to_s %>
|
||||
<a class="ticket-response-delete" href="/admin/ticket/delete_response" data-response-id="<%= response.id.to_s %>">
|
||||
<i class="ticket-response-delete-icon fa fa-trash"></i>
|
||||
Delete
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if response.user_tags.include?(current_user.id.to_s) %>
|
||||
<a href="" class="reply-response" data-response-id="<%= response.id.to_s %>">
|
||||
<i class="fa fa-share"></i>
|
||||
Reply
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="ticket-internal-comment-wrap">
|
||||
<div class="ticket-internal-wrap">
|
||||
<% response.user_tags.each do |u|
|
||||
|
@ -42,7 +47,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ticket-response-content <%= response.internal_response ? "in-house" : "" %>">
|
||||
<div class="ticket-response-content <%= response.internal_response ? "in-house" : "" %>" data-user-tags="<%= response.user_tags.to_s %>" data-response-id="<%= response.id.to_s %>">
|
||||
<%= response.response.html_safe %>
|
||||
</div>
|
||||
</div>
|
|
@ -7,6 +7,7 @@
|
|||
<%= javascript_include_tag "lib/jquery.form.js" %>
|
||||
<%= javascript_include_tag "validator" %>
|
||||
<%= javascript_include_tag "select2/select2.min" %>
|
||||
<%= javascript_include_tag "jquery.viewport" %>
|
||||
<% end %>
|
||||
<% if !@ticket .nil? %>
|
||||
<% case @ticket.status
|
||||
|
@ -176,8 +177,11 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<script type="text/javascript">
|
||||
var locale = "<%= I18n.locale.to_s %>";
|
||||
var fv = new FormValidator($("#reopen-form"));
|
||||
(function(){
|
||||
var locale = "<%= I18n.locale.to_s %>",
|
||||
fv = new FormValidator($("#reopen-form")),
|
||||
user_id = "<%= current_user.id.to_s %>";
|
||||
|
||||
$("#reopen-form-submit").on("click",function(){
|
||||
for (instance in CKEDITOR.instances) {
|
||||
CKEDITOR.instances[instance].updateElement();
|
||||
|
@ -245,7 +249,7 @@ $(document).ready(function(){
|
|||
);
|
||||
return $state;
|
||||
},
|
||||
placeholder: "Add Members"
|
||||
placeholder: "Tag Members"
|
||||
});
|
||||
|
||||
})
|
||||
|
@ -264,12 +268,11 @@ $(document).ready(function(){
|
|||
|
||||
|
||||
function switchTooltip() {
|
||||
var $switch = $('.onoffswitch');
|
||||
var $input = $switch.children('input');
|
||||
var $tooltip = $switch.find('.ticket-tooltip-wrap');
|
||||
var activeCls = 'active';
|
||||
var $switch = $('.onoffswitch'),
|
||||
$input = $switch.children('input'),
|
||||
$tooltip = $switch.find('.ticket-tooltip-wrap');
|
||||
|
||||
if ($input.hasClass(activeCls)) {
|
||||
if ($input.hasClass("active")) {
|
||||
$tooltip.text('This ticket is marked urgent, click to unmark');
|
||||
} else {
|
||||
$tooltip.text('Click to mark this ticket urgent');
|
||||
|
@ -330,4 +333,36 @@ $(document).ready(function(){
|
|||
return false;
|
||||
})
|
||||
|
||||
$("body").on("click",".reply-response",function(){
|
||||
var el = $(this),
|
||||
response_id = el.data("response-id");
|
||||
$(".member_tags").select2("val",[$("div[data-scroll-id=response_" + response_id + "]").data("response-by")]);
|
||||
$("html, body").animate({ scrollTop: ($("#form_container").offset().top - 50) }, "slow");
|
||||
return false;
|
||||
})
|
||||
|
||||
var timer = null;
|
||||
$(document).on("scroll",function(){
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function(){
|
||||
var responses_seen = $("div[data-user-tags*=" + user_id + "]:in-viewport");
|
||||
$.each(responses_seen,function(){
|
||||
var el = $(this),
|
||||
avatar = $("div[data-scroll-id=response_" + el.data("response-id") + "]").find("img[data-avatar-id="+ user_id +"]");
|
||||
if(!avatar.hasClass("read")){
|
||||
$.ajax({
|
||||
url : "/admin/comments/read",
|
||||
dataType : "json",
|
||||
type : "post",
|
||||
data : {"response_id" : el.data("response-id")}
|
||||
}).done(function(data){
|
||||
if(data.success){
|
||||
avatar.addClass("read");
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
},1000);
|
||||
})
|
||||
})();
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue