o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1364984313.449497: @value"‰"{I" class:EFI"ProcessedAsset;FI"logical_path;FI")locomotive/views/pages/_form_view.js;TI" pathname;FI"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee;TI"content_type;FI"application/javascript;FI" mtime;FI"2013-04-03T11:01:13+02:00;FI" length;Fi¿I" digest;F"%5048b270a6b78323746283ce3772422dI" source;FI"¿(function() { var _base, _ref, __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; }; (_base = Locomotive.Views).Pages || (_base.Pages = {}); Locomotive.Views.Pages.FormView = (function(_super) { __extends(FormView, _super); function FormView() { _ref = FormView.__super__.constructor.apply(this, arguments); return _ref; } FormView.prototype.el = '#content'; FormView.prototype.events = { 'change #page_parent_id': 'change_page_url', 'click a#image-picker-link': 'open_image_picker', 'click a#copy-template-link': 'replace_template', 'submit': 'save' }; FormView.prototype.initialize = function() { _.bindAll(this, 'insert_image'); this.model = new Locomotive.Models.Page(this.options.page); this.touched_url = false; this.image_picker_view = new Locomotive.Views.ThemeAssets.ImagePickerView({ collection: new Locomotive.Models.ThemeAssetsCollection(), on_select: this.insert_image }); this.image_picker_view.render(); Backbone.ModelBinding.bind(this); return this.editable_elements_view = new Locomotive.Views.EditableElements.EditAllView({ collection: this.model.get('editable_elements') }); }; FormView.prototype.render = function() { FormView.__super__.render.call(this); this.slugify_title(); this.listen_for_url_changes(); this.enable_response_type_select(); this.enable_templatized_checkbox(); this.enable_redirect_checkbox(); this.enable_other_checkboxes(); this.enable_liquid_editing(); this.render_editable_elements(); return this; }; FormView.prototype.open_image_picker = function(event) { event.stopPropagation() & event.preventDefault(); this.image_picker_view.editor = this.editor; return this.image_picker_view.fetch_assets(); }; FormView.prototype.insert_image = function(path) { var text; text = "{{ '" + path + "' | theme_image_url }}"; this.editor.replaceSelection(text); return this.image_picker_view.close(); }; FormView.prototype.replace_template = function(event) { var link, _this = this; event.stopPropagation() & event.preventDefault(); link = $(event.target).closest('a'); return $.rails.ajax({ url: link.attr('href'), type: 'get', dataType: 'json', success: function(data) { return _this.editor.setValue(data.raw_template); } }); }; FormView.prototype.enable_liquid_editing = function() { var input, _this = this; input = this.$('#page_raw_template'); if (input.size() > 0) { return this.editor = CodeMirror.fromTextArea(input.get()[0], { mode: 'liquid', autoMatchParens: false, lineNumbers: true, passDelay: 50, tabMode: 'shift', theme: 'default', onChange: function(editor) { return _this.model.set({ raw_template: editor.getValue() }); } }); } }; FormView.prototype.after_inputs_fold = function() { return this.editor.refresh(); }; FormView.prototype.render_editable_elements = function() { this.$('.formtastic fieldset.inputs:first').before(this.editable_elements_view.render().el); return this.editable_elements_view.after_render(); }; FormView.prototype.reset_editable_elements = function() { this.editable_elements_view.remove(); this.editable_elements_view.collection = this.model.get('editable_elements'); return this.render_editable_elements(); }; FormView.prototype.refresh_editable_elements = function() { this.editable_elements_view.unbind_model(); this.editable_elements_view.collection = this.model.get('editable_elements'); return this.editable_elements_view.refresh(); }; FormView.prototype.slugify_title = function() { var _this = this; this.$('#page_title').slugify({ target: this.$('#page_slug'), url: window.permalink_service_url }); return this.$('#page_slug').bind('change', (function(event) { return _this.touched_url = true; })); }; FormView.prototype.listen_for_url_changes = function() { var _this = this; return setInterval((function() { if (_this.touched_url) { return _this.change_page_url() & (_this.touched_url = false); } }), 2000); }; FormView.prototype.change_page_url = function() { var _this = this; return $.rails.ajax({ url: this.$('#page_slug').data('url'), type: 'get', dataType: 'json', data: { parent_id: this.$('#page_parent_id').val(), slug: this.$('#page_slug').val() }, success: function(data) { _this.$('#page_slug_input .inline-hints').html(data.url).effect('highlight'); if (data.templatized_parent) { _this.$('li#page_slug_input').show(); return _this.$('li#page_templatized_input, li#page_target_klass_name_input').hide(); } else { if (!_this.model.get('redirect')) { return _this.$('li#page_templatized_input').show(); } } } }); }; FormView.prototype.enable_response_type_select = function() { var _this = this; return this.$('li#page_response_type_input').change(function(event) { if ($(event.target).val() === 'text/html') { return _this.$('li#page_redirect_input, li#page_redirect_url_input, li#page_redirect_type_input').show(); } else { _this.model.set({ redirect: false }); return _this.$('li#page_redirect_input, li#page_redirect_url_input, li#page_redirect_type_input').hide(); } }); }; FormView.prototype.enable_templatized_checkbox = function() { var _this = this; this._enable_checkbox('templatized', { features: ['slug', 'redirect', 'listed'], on_callback: function() { return _this.$('li#page_target_klass_name_input').show(); }, off_callback: function() { return _this.$('li#page_target_klass_name_input').hide(); } }); if (this.model.get('templatized_from_parent') === true) { return this.$('li#page_templatized_input').hide(); } }; FormView.prototype.enable_redirect_checkbox = function() { var _this = this; return this._enable_checkbox('redirect', { features: ['templatized', 'cache_strategy'], on_callback: function() { return _this.$('li#page_redirect_url_input, li#page_redirect_type_input').show(); }, off_callback: function() { return _this.$('li#page_redirect_url_input, li#page_redirect_type_input').hide(); } }); }; FormView.prototype.enable_other_checkboxes = function() { var _this = this; return _.each(['published', 'listed'], function(exp) { return _this.$('li#page_' + exp + '_input input[type=checkbox]').checkToggle(); }); }; return FormView; })(Locomotive.Views.Shared.FormView); }).call(this); ;TI"dependency_digest;F"%573f22098561739e030eab4a48acb073I"required_paths;F[I"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;TI"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee;TI"dependency_paths;F[{I" path;FI"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee;TI" mtime;FI"2013-04-03T11:01:13+02:00;FI" digest;F"%4baaaf1fb75931a5edb4f6d10846853a{I" path;FI"p/Users/papipo/Projects/locomotive/engine/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee;TI" mtime;FI"2013-04-03T11:01:13+02:00;FI" digest;F"%a6e3a1e43e6f34490cc614f779383a34I" _version;F"%6776f581a4329e299531e1d52aa59832