o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1368639740.6034298: @value"{I" class:EFI"ProcessedAsset;FI"logical_path;F"1ample_assets/classes/ample_assets_gravity.jsI" pathname;F"{/Users/tcmacdonald/Sites/ample/ample_assets/app/assets/javascripts/ample_assets/classes/ample_assets_gravity.js.coffeeI"content_type;FI"application/javascript;FI" mtime;FI"2012-05-16T12:26:59-04:00;FI" length;FirI" digest;F"%394ec8989edeaf6b54142252af771494I" source;FI"r(function() { var __hasProp = {}.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; window.AmpleAssetsGravity = (function(_super) { __extends(AmpleAssetsGravity, _super); function AmpleAssetsGravity() { return AmpleAssetsGravity.__super__.constructor.apply(this, arguments); } AmpleAssetsGravity.prototype.default_options = { debug: false, uid: false, url: "/ample_assets/files/{{ id }}/gravity", min_width: 100, min_height: 100, max_width: 480, max_height: 300 }; AmpleAssetsGravity.prototype.init = function() { this.log("init()"); this.handle = $("#asset-gravity-handle"); this.image = $(".asset-media img"); return this.test(); }; AmpleAssetsGravity.prototype.test = function() { var _this = this; if (this.image.width() > 0) { return this.html(); } else { this.log("@image not loaded"); return setTimeout((function() { return _this.test(); }), 500); } }; AmpleAssetsGravity.prototype.html = function() { var _this = this; this.log("html()"); if (!(this.image.height() > this.options.min_width && this.image.height() > this.options.min_height)) { return false; } this.gravity = $("#file_attachment_gravity").val() || "c"; this.gravity_grid = { top: this.image.height() / 3, left: this.image.width() / 3 }; this.image_pos = this.image.position(); this.image_center = { top: this.image_pos.top + (this.image.height() / 2) - (this.handle.height() / 2), left: this.image_pos.left + (this.image.width() / 2) - (this.handle.width() / 2) }; this.handle.css({ position: "absolute", left: (this.image_center.left - this.gravity_grid.left) + (this.gravity_grid.left * this.gravities()[this.gravity][0]), top: (this.image_center.top - this.gravity_grid.top) + (this.gravity_grid.top * this.gravities()[this.gravity][1]) }); this.handle.draggable({ containment: this.image, grid: [this.gravity_grid.left, this.gravity_grid.top], scroll: false, start: function(event, ui) { return $('div.ui-droppable, textarea.ui-droppable').addClass('asset-inactive-target'); }, stop: function(event, ui) { var gravity, gravity_pos, key, left, top, value, _ref; $('div.ui-droppable, textarea.ui-droppable').removeClass('asset-inactive-target'); left = ui.position.left; top = ui.position.top; if (_this.image.width() < _this.options.max_width) { left = Math.abs(((_this.options.max_width - _this.image.width()) / 2) - left); } if (_this.image.height() < _this.options.max_height) { top = Math.abs(((_this.options.max_height - _this.image.height()) / 2) - top); } gravity_pos = [Math.floor(left / _this.gravity_grid.left), Math.floor(top / _this.gravity_grid.top)]; _ref = _this.gravities(); for (key in _ref) { value = _ref[key]; if (value[0] === gravity_pos[0] && value[1] === gravity_pos[1]) { gravity = key; break; } } $("#file_attachment_gravity").val(gravity); _this.submit(gravity); return _this.log(gravity); } }); return this.handle.fadeIn(); }; AmpleAssetsGravity.prototype.submit = function(gravity) { var _this = this; this.log("submit(" + gravity + ")"); return $.post(this.options.url, { gravity: gravity }, function(e) { $("a[data-uid='" + _this.options.uid + "']").attr('data-gravity', gravity); return $('#asset-gravity-notification').show().delay(2500).fadeOut(); }); }; AmpleAssetsGravity.prototype.gravities = function() { return { nw: [0, 0], n: [1, 0], ne: [2, 0], w: [0, 1], c: [1, 1], e: [2, 1], sw: [0, 2], s: [1, 2], se: [2, 2] }; }; return AmpleAssetsGravity; })(CoffeeCup); }).call(this); ;TI"dependency_digest;F"%390fdfc356593b22b12c3518201dc353I"required_paths;F["{/Users/tcmacdonald/Sites/ample/ample_assets/app/assets/javascripts/ample_assets/classes/ample_assets_gravity.js.coffeeI"dependency_paths;F[{I" path;F"{/Users/tcmacdonald/Sites/ample/ample_assets/app/assets/javascripts/ample_assets/classes/ample_assets_gravity.js.coffeeI" mtime;FI"2012-05-16T12:26:59-04:00;FI" digest;F"%e3928ceb13f1e43cacee1a6d8887702cI" _version;F"%979b712d447c42bc88f489bb52e370d7