9184eda24c2728ee2e55fbdef2ad8c661ecbaccc
[fnpeditor.git] / src / editor / plugins / core / metadataEditor / action.js
1 define(function(require) {
2     
3 'use strict';
4 /* globals gettext */
5
6 var Dialog = require('views/dialog/dialog'),
7     View = require('./view');
8
9
10 return function(ctx) {
11     return {
12         name: 'showMetadataEditor',
13         params: {
14             doc: {type: 'context', name: 'document'}
15         },
16         stateDefaults: {
17             allowed: true,
18             label: gettext('Metadata'),
19             execute: function(callback, params) {
20                 void(callback);
21                 var dialog = Dialog.create({
22                         title: gettext('Document Metadata'),
23                         executeButtonText: gettext('Close'),
24                         cssClass: 'metadataEditor'
25                     }),
26                     view = new View(params.doc.root, ctx.config);
27                 dialog.show();
28                 dialog.setContentView(view.dom);
29                 dialog.on('execute', function(e) {
30                     e.success();
31                 });
32             }
33         },
34         getState: function(params) {
35             return {
36                 allowed: !!params.doc
37             };
38         }
39     };
40 };
41
42 });