app/assets/javascripts/ants/menu.coffee in ants-0.3.5 vs app/assets/javascripts/ants/menu.coffee in ants-0.3.9

- old
+ new

@@ -1,28 +1,38 @@ class @AntsMenu - constructor: (title, apiPath) -> - config = - title: title + constructor: (@title, @apiPath) -> + @objectStore = new RailsObjectStore + resource: 'menu' + path: "#{ @apiPath }" - objectStore: new RailsObjectStore({ - resource: 'menu' - path: "#{ apiPath }" - }) + @formSchema = + links: + type: 'documents' + newButtonLabel: 'Add a Link' + sortBy: '_position' + label: false + formSchema: + title: + type: "string" + placeholder: "Title" - formSchema: - links: - type: 'documents' - newButtonLabel: 'Add a Link' - sortBy: '_position' - formSchema: - title: - type: 'string' + url: + type: "url" + placeholder: "Path or URL, e.g. /about" + onInitialize: (input) => + @_add_preview_action(input) - url: - type: 'string' + @onViewShow = (view) -> + view.$el.addClass "view-menu" - target_blank: - type: 'checkbox' - default: false - label: 'Open in a new tab' + _add_preview_action: (input) -> + input.$actions =$ "<span class='input-actions'></span>" + input.$el.append input.$actions - return config + input.$previewBtn =$ """<a href='#{input.value}' target='_blank'> + #{Icons.preview} + </a>""" + input.$actions.append input.$previewBtn + + input.$input.on "change", (e) -> + link = input.$input.val() + input.$previewBtn.attr "href", link