{I" class:ETI"ProcessedAsset; FI"logical_path; TI"alchemy/alchemy.dialog.js; FI" pathname; TI"}/Users/tvd/.rvm/gems/ruby-2.1.2/bundler/gems/alchemy_cms-7fe2839068da/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee; FI"content_type; TI"application/javascript; TI" mtime; Tl+/-TI"length; Ti'I"digest; TI"%374850273edab3dfd613fde9c54cf905; FI"source; TI"'(function() { window.Alchemy.Dialog = (function() { Dialog.prototype.DEFAULTS = { header_height: 36, size: '400x300', padding: true, title: '', modal: true, overflow: 'visible', ready: function() {}, closed: function() {} }; function Dialog(url, options) { var size; this.url = url; this.options = options != null ? options : {}; this.options = $.extend({}, this.DEFAULTS, this.options); this.$document = $(document); this.$window = $(window); this.$body = $('body'); size = this.options.size.split('x'); this.width = parseInt(size[0], 10); this.height = parseInt(size[1], 10); this.build(); } Dialog.prototype.open = function() { this.dialog.trigger('Alchemy.DialogOpen'); this.bind_close_events(); window.requestAnimationFrame((function(_this) { return function() { _this.dialog_container.addClass('open'); if (_this.overlay != null) { return _this.overlay.addClass('open'); } }; })(this)); this.dialog.draggable({ iframeFix: true, handle: '.alchemy-dialog-title', containment: 'parent' }); this.$body.addClass('prevent-scrolling'); Alchemy.currentDialogs.push(this); this.load(); return true; }; Dialog.prototype.close = function() { this.$document.off('keydown'); this.dialog_container.removeClass('open'); if (this.overlay != null) { this.overlay.removeClass('open'); } this.$document.on('webkitTransitionEnd transitionend oTransitionEnd', (function(_this) { return function() { _this.$document.off('webkitTransitionEnd transitionend oTransitionEnd'); _this.dialog_container.remove(); if (_this.overlay != null) { _this.overlay.remove(); } _this.$body.removeClass('prevent-scrolling'); Alchemy.currentDialogs.pop(_this); if (_this.options.closed != null) { return _this.options.closed(); } }; })(this)); return true; }; Dialog.prototype.load = function() { this.show_spinner(); $.get(this.url, (function(_this) { return function(data) { return _this.replace(data); }; })(this)).fail((function(_this) { return function(xhr) { return _this.show_error(xhr); }; })(this)); return true; }; Dialog.prototype.reload = function() { this.dialog_body.empty(); return this.load(); }; Dialog.prototype.replace = function(data) { this.remove_spinner(); this.dialog_body.hide(); this.dialog_body.html(data); this.init(); if (this.options.ready != null) { this.options.ready(this.dialog_body); } this.dialog_body.show('fade', 200); return true; }; Dialog.prototype.show_spinner = function() { this.spinner = Alchemy.Spinner.medium(); return this.spinner.spin(this.dialog_body[0]); }; Dialog.prototype.remove_spinner = function() { return this.spinner.stop(); }; Dialog.prototype.init = function() { Alchemy.GUI.init(this.dialog_body); $('#overlay_tabs', this.dialog_body).tabs(); return this.watch_remote_forms(); }; Dialog.prototype.watch_remote_forms = function() { var form; form = $('[data-remote="true"]', this.dialog_body); return form.bind("ajax:complete", (function(_this) { return function(e, xhr, status) { var content_type; content_type = xhr.getResponseHeader('Content-Type'); Alchemy.Buttons.enable(_this.dialog_body); if (status === 'success') { if (content_type.match(/javascript/)) { } else { _this.dialog_body.html(xhr.responseText); return _this.init(); } } else { return _this.show_error(xhr, status); } }; })(this)); }; Dialog.prototype.show_error = function(xhr, status_message) { var $errorDiv, error_body, error_header, error_type; error_type = "warning"; switch (xhr.status) { case 0: error_header = "The server does not respond."; error_body = "Please check server and try again."; break; case 403: error_header = "You are not authorized!"; error_body = "Please close this window."; break; default: error_type = "error"; if (status_message) { error_header = status_message; console.error(eval(xhr.responseText)); } else { error_header = "" + xhr.statusText + " (" + xhr.status + ")"; } error_body = "Please check log and try again."; } $errorDiv = $("
"); $errorDiv.append(""); $errorDiv.append("" + error_body + "
"); return this.dialog_body.html($errorDiv); }; Dialog.prototype.bind_close_events = function() { this.close_button.click((function(_this) { return function() { _this.close(); return false; }; })(this)); this.dialog_container.addClass('closable').click((function(_this) { return function(e) { if (e.target !== _this.dialog_container.get(0)) { return true; } _this.close(); return false; }; })(this)); return this.$document.keydown((function(_this) { return function(e) { if (e.which === 27) { _this.close(); return false; } else { return true; } }; })(this)); }; Dialog.prototype.build = function() { this.dialog_container = $(''); this.dialog = $(''); this.dialog_body = $(''); this.dialog_header = $(''); this.dialog_title = $(''); this.close_button = $(''); this.dialog_title.text(this.options.title); this.dialog_header.append(this.dialog_title); this.dialog_header.append(this.close_button); this.dialog.append(this.dialog_header); this.dialog.append(this.dialog_body); this.dialog_container.append(this.dialog); if (this.options.modal) { this.dialog.addClass('modal'); } if (this.options.padding) { this.dialog_body.addClass('padded'); } if (this.options.modal) { this.overlay = $(''); this.$body.append(this.overlay); } this.$body.append(this.dialog_container); this.resize(); return this.dialog; }; Dialog.prototype.resize = function() { var $doc_height, $doc_width, padding, _ref; padding = 16; $doc_width = this.$window.width(); $doc_height = this.$window.height(); if (this.options.size === 'fullscreen') { _ref = [$doc_width, $doc_height], this.width = _ref[0], this.height = _ref[1]; } if (this.width >= $doc_width) { this.width = $doc_width - padding; } if (this.height >= $doc_height) { this.height = $doc_height - padding - this.DEFAULTS.header_height; } this.dialog.css({ 'width': this.width, 'min-height': this.height, overflow: this.options.overflow }); if (this.options.overflow === 'hidden') { this.dialog_body.css({ height: this.height, overflow: 'auto' }); } else { this.dialog_body.css({ 'min-height': this.height, overflow: 'visible' }); } }; return Dialog; })(); window.Alchemy.currentDialogs = []; window.Alchemy.currentDialog = function() { var length; length = Alchemy.currentDialogs.length; if (length === 0) { return; } return Alchemy.currentDialogs[length - 1]; }; window.Alchemy.closeCurrentDialog = function(callback) { var dialog; dialog = Alchemy.currentDialog(); if (dialog != null) { dialog.options.closed = callback; return dialog.close(); } }; window.Alchemy.openDialog = function(url, options) { var dialog; if (!url) { throw 'No url given! Please provide an url.'; } dialog = new Alchemy.Dialog(url, options); return dialog.open(); }; window.Alchemy.watchForDialogs = function(scope) { $('a[data-alchemy-dialog]', scope).click(function(e) { var $this, options, url; $this = $(this); url = $this.attr('href'); options = $this.data('alchemy-dialog'); Alchemy.openDialog(url, options); return false; }); $('a[data-alchemy-confirm-delete]', scope).click(function(event) { var $this, options; $this = $(this); options = $this.data('alchemy-confirm-delete'); Alchemy.confirmToDeleteDialog($this.attr('href'), options); return false; }); return $('input[data-alchemy-confirm], button[data-alchemy-confirm]', scope).click(function(event) { var options; options = $(this).data('alchemy-confirm'); Alchemy.openConfirmDialog(options.message, $.extend(options, { ok_label: options.ok_label, cancel_label: options.cancel_label, on_ok: (function(_this) { return function() { Alchemy.pleaseWaitOverlay(); _this.form.submit(); }; })(this) })); return false; }); }; }).call(this); ; TI"dependency_digest; TI"%0ef2bd0a4751cfd0e75d32730e011e26; FI"required_paths; T[I"}/Users/tvd/.rvm/gems/ruby-2.1.2/bundler/gems/alchemy_cms-7fe2839068da/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee; FI"dependency_paths; T[{I" path; TI"}/Users/tvd/.rvm/gems/ruby-2.1.2/bundler/gems/alchemy_cms-7fe2839068da/app/assets/javascripts/alchemy/alchemy.dialog.js.coffee; FI" mtime; TI"2014-10-02T11:38:55+02:00; TI"digest; TI"%81bbfaad11382637569c7c486ed593e1; FI" _version; TI"%1005ed9f20e25fb0a0599a7017dd0e6b; F