Skip to content

Instantly share code, notes, and snippets.

View shwoodard's full-sized avatar

Sam Woodard shwoodard

View GitHub Profile
$.currActive;
$.imageCount;
$.fn.preCacheImageFromThumb = function () {
return $(this).each(function () {
var img = new Image();
img.src = $(this).attr('href');
});
};
def adjust_wac(time = Time.zone.now)
adjustment_date = time.beginning_of_day
qty = value = '0'.to_d
transaction do
# Compute WAC as of specified time.....then adjust future inventory adjustment entries
first_entry = true
(inv_adj_entries = inventory_adjustment_entries.find_all).each do |entry|
if entry.posted_date >= adjustment_date and !first_entry
# Adjust future entries
def qty_available_for_sale(as_of = Time.zone.new)
qty = wac_and_qty(as_of)[1]
inventory_adjustment_entries.find_after(as_of).each do |entry|
qty = qty + (entry.debit_credit_flag == 'Debit' ? entry.item_qty : -entry.item_qty)
min_qty = [qty, min_qty].min
end
qty
end
(function (){
$.fn.disableUserMoreInfoFields = function() {
return $(this).each(function () {
var fields = $(this).closest('.member').find('.more_info_field');
if(!!$(this).get(0).checked) {
fields.removeAttr('disabled');
fields.removeClass('disabled');
} else {
fields.attr('disabled', 'disabled');
fields.addClass('disabled');
def public
@is_public = true
show
if current_user
if current_user.subscriber.community_subscriber.profile_accessibility == 1
redirect_to '/home' and return
end
if current_user.subscriber != current_subscriber
current_subscriber.community_subscriber.increment_internal_visits!
(function ($) {
$.extend(jQuery ,{
// keep the old one
_ajax: jQuery.ajax,
ajax: function (options) {
var cloneOptions = $.extend({}, options);
this._ajax($.extend(options, {
complete: function (res, status) {
$(document).trigger('ajaxcomplete', arguments);
diff --git a/app/views/messages/_inbox.html.erb b/app/views/messages/_inbox.html.erb
index 3c6f499..17d9c5e 100644
--- a/app/views/messages/_inbox.html.erb
+++ b/app/views/messages/_inbox.html.erb
@@ -21,7 +21,7 @@
<td class="msgcol"><%= link_to(h(message.subject), message_path(message, :from => 'inbox'), :class => 'message_link') %></td>
<td class="msgcol"><%= time_ago_in_words(message.created_at) %> ago</td>
<td class="msgcol">
- <%= link_to "", message_path(message), :class => 'delete' %>
+ <%= link_to "", message_path(message), :class => 'trashcan delete trash_link' %>
$.flashMessage = function(msg, status) {
status = status || 'ok';
$(document).one('reveal.facebox', function () {
var tOut = setTimeout(function () {
$(document).trigger('close.facebox');
}, 3000);
$(document).one('loading.facebox', function () {
clearTimeout(tOut);
});
});
class Message < ActiveRecord::Base
belongs_to :reply_of, :class_name => 'Message', :foreign_key => 'parent_id'
belongs_to :replies, :class_name => 'Message', :foreign_key => 'parent_id'
belongs_to :sender, :class_name => 'CommunityUser', :foreign_key => 'sender_id'
belongs_to :recipient, :class_name => 'CommunityUser', :foreign_key => 'recipient_id'
belongs_to :conversation
named_scope :deleted, lambda { |user|
{:conditions => ["(sender_deleted_at IS NOT NULL AND sender_id = #{user.id} AND sender_deleted_permanently != 1) OR (recipient_deleted_at IS NOT NULL AND recipient_id = #{user.id} AND recipient_deleted_permanently != 1)"]}
}
(function ($) {
$.fn.prototypeList = function (records, map) {
if (!records || !records.length) {
return this;
}
return $(this).each(function () {
var list = $(this);
var prototypeEl = list.find('.prototype');