{I" class:ETI"ProcessedAsset;FI"logical_path;TI"'type_station/editables/new_page.js;FI" pathname;TI"m/Users/richardadams/github/type_station/app/assets/javascripts/type_station/editables/new_page.js.coffee;FI"content_type;TI"application/javascript;TI" mtime;Tl+Ô.âTI" length;TiI" digest;TI"%0585771eed6d80e71aacbd66a42a594c;FI" source;TI"(function() { var buildFields; buildFields = function(element) { var field, input, inputs, label, o, select, tsFields, _i, _len; tsFields = element.data('tsFields'); inputs = ''; for (_i = 0, _len = tsFields.length; _i < _len; _i++) { field = tsFields[_i]; label = ""; input = (function() { var _j, _k, _len1, _len2, _ref, _ref1; switch (field.type) { case "text": return ""; case "textarea": return ""; case "select": select = ""; return select; case "multiple_select": select = ""; return select; } })(); inputs += "
" + label + "
" + input + "
"; } return inputs; }; window.TS.NewPage = (function() { function NewPage(_at_elements) { this.elements = _at_elements; } NewPage.prototype.enable = function() { this.disable(); return this.elements.show().on('click', function() { var $element, tsData; $element = $(this); tsData = $element.data('tsData'); vex.dialog.buttons.YES.text = 'Create'; return vex.dialog.open({ message: "New " + (tsData.name || 'Page'), input: buildFields($element), $element: $element, afterOpen: function($vexContent) { return $("select.multiple_select", $vexContent).chosen(); }, callback: function(data) { var $el, contents, json, k, model, v; console.log(data); if (data) { $el = this.$element; if (data.title.length > 0) { model = window.TS.getModel($el.data('ts-url')); if ($el.data('tsData')["default"]) { data = $.extend({}, data, $el.data('tsData')["default"]); } contents = []; for (k in data) { v = data[k]; if (k !== 'title') { contents.push({ field: k, value: v, type: $.isArray(v) ? 'multiple_select' : 'text' }); } } json = {}; json['title'] = data.title; if ($el.data('ts-parent-id')) { json['parent_id'] = $el.data('ts-parent-id'); } json['contents'] = contents; return vex.dialog.confirm({ message: 'Are you sure you want to create this?', callback: function(value) { if (value) { return $.ajax({ type: "POST", url: $el.data('ts-url'), dataType: 'json', contentType: 'application/json', data: JSON.stringify(json), success: function(data, status) { return window.location.reload(); } }); } } }); } else { return vex.dialog.alert({ message: 'Please fill in all required fields', callback: function() { return $el.click(); } }); } } } }); }); }; NewPage.prototype.disable = function() { return this.elements.hide().off('click'); }; return NewPage; })(); }).call(this); ;TI"dependency_digest;TI"%1e7bcf81d29fddab9f007e4b6c6cfeae;FI"required_paths;T[I"m/Users/richardadams/github/type_station/app/assets/javascripts/type_station/editables/new_page.js.coffee;FI"dependency_paths;T[{I" path;TI"m/Users/richardadams/github/type_station/app/assets/javascripts/type_station/editables/new_page.js.coffee;FI" mtime;TI"2015-02-16T17:54:28+00:00;TI" digest;TI"%080794e99da06cc7fa3bd24db557f050;FI" _version;TI"%64e62ddc273c2f5847f30d698ca14b67;F