o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1355206950.172409: @value"Þ{I" class:EFI"BundledAsset;FI"logical_path;FI"amalgam/admin/popover.js;FI" pathname;FI"Y/Users/brownjohn/code/amalgam/app/assets/javascripts/amalgam/admin/popover.js.coffee;FI"content_type;FI"application/javascript;FI" mtime;FI"2012-08-08T15:53:16+08:00;FI" length;FiüI" digest;F"%372ef48f0f43bcf18e13601428adc4e5I" source;FI"ü(function() { var $, $win, App, findOrCreate, processScroll; $ = window.jQuery; $win = $(window); findOrCreate = function(selector, content) { var el; if ((el = $(selector)).length) { return el; } else { return $(content).prependTo($('body')).hide(); } }; App = { warnning: function(msg) { return this._msg("" + msg + ""); }, success: function(msg) { return this._msg("" + msg + "").delay(500).fadeOut(function() { return $(this).remove(); }); }, error: function(msg) { return this._msg("" + msg + "").click(function() { return $(this).fadeOut(function() { return $(this).remove(); }); }); }, _msg: function(content) { var $loader; $loader = findOrCreate('#ajax-loader', '
'); $loader.html(content); return $loader.fadeIn(); }, init: function() { App.rebind(); processScroll(); return $win.on('scroll', processScroll); }, rebind: function() { return $('[rel*=tooltip]').tooltip(); } }; $(App.init); $(document).on('ajax:beforeSend', '[data-remote]', function(e, xhr) { var $el, msgDone, msgError, msgLoading; $el = $(e.target); msgLoading = $el.data('loading') || 'Loading...'; msgDone = $el.data('done') || 'Done!'; msgError = $el.data('error') || 'Error!'; App.warnning(msgLoading); return xhr.done(function() { App.success(msgDone); return App.rebind(); }).fail(function() { return App.error(msgError); }); }); processScroll = function() { var scrollTop; scrollTop = $win.scrollTop(); return $('[data-scroll=fixed]').each(function() { var el, isFixed, navTop, substitute; el = $(this); navTop = el.data('app.navtop'); if (!navTop) { navTop = el.offset().top - 40; el.data('app.navtop', navTop); } substitute = el.next('.substitute'); if (!substitute.length) { substitute = $('
').insertAfter(el); substitute.height(el.outerHeight()).hide(); } isFixed = el.is('.scroll_fixed'); if (scrollTop >= navTop && !isFixed) { el.addClass('scroll_fixed'); return substitute.show(); } else if (scrollTop <= navTop && isFixed) { el.removeClass('scroll_fixed'); return substitute.hide(); } }); }; window.App = App; }).call(this); (function() { var $; $ = window.jQuery; App.Popover = (function() { Popover.template = '

'; function Popover(bind, options) { this.bind = bind; this.options = options != null ? options : {}; this.options = $.extend({ content: this.bind.data('content'), title: this.bind.attr('title') }, options); this.el = $(this.constructor.template).appendTo($('body')).hide(); } Popover.prototype.render = function() { this.el.find('.popover-title').html(this.options.title); this.el.find('.popover-content').html(this.options.content); return this.position(); }; Popover.prototype.position = function() { var $arrow, $window, cssClass, h, margin, padding, pos, tp, view, visible, w; visible = this.el.is(':visible'); this.el.show(); w = this.el.width(); h = this.el.innerHeight(); pos = $.extend({}, this.bind.offset(), { width: this.bind[0].offsetWidth, height: this.bind[0].offsetHeight }); padding = parseInt(this.el.css('padding-left')); margin = 5; $window = $(window); $arrow = this.el.find('.arrow'); view = { top: $window.scrollTop(), left: $window.scrollLeft(), width: $window.width(), height: $window.height() }; this.el.css({ top: 0, left: 0, display: 'block' }); this.el.removeClass('top'); this.el.removeClass('bottom'); tp = {}; if ((pos.left + w) <= view.left + view.width) { tp.left = pos.left - padding; $arrow.css('left', pos.width / 2 + padding); } else { tp.left = pos.left + pos.width - w - margin; $arrow.css('left', w - pos.width / 2 - padding); } if ((pos.top + pos.height + h) <= view.top + view.height) { cssClass = 'bottom'; tp.top = pos.top + pos.height - margin; } else { cssClass = 'top'; tp.top = pos.top - h + margin; } this.el.css(tp); this.el.addClass(cssClass); if (!visible) { this.el.hide(); } return this.el; }; Popover.prototype.toggle = function() { if (this.el.is(':visible')) { return this.el.fadeOut('fast'); } else { this.render(); return this.el.fadeIn('fast'); } }; Popover.prototype.content = function(content) { if (!content) { return options.content; } this.options.content = content; return this.render(); }; Popover.prototype.title = function(title) { if (!title) { return options.title; } this.options.title = title; return this.render(); }; return Popover; })(); $.fn.popo = function(options) { var $el, data, popover; if (options == null) { options = {}; } $el = $(this); data = $el.data('app.popover'); if (data) { return data; } popover = new App.Popover($el, options); $el.data('app.popover', popover); return popover; }; }).call(this); ;FI"required_assets_digest;F"%1cadd6803a7512584a3edf1c9b469f8dI" _version;F"%9f3b95dd7ea3030dc35985c0a8020862