]> git.wh0rd.org Git - tt-rss.git/blob - lib/dijit/_editor/plugins/NewPage.js.uncompressed.js
upgrade dojo to 1.8.3 (refs #570)
[tt-rss.git] / lib / dijit / _editor / plugins / NewPage.js.uncompressed.js
1 define("dijit/_editor/plugins/NewPage", [
2         "dojo/_base/declare", // declare
3         "dojo/i18n", // i18n.getLocalization
4         "dojo/_base/lang", // lang.hitch
5         "../_Plugin",
6         "../../form/Button",
7         "dojo/i18n!../nls/commands"
8 ], function(declare, i18n, lang, _Plugin, Button){
9
10 // module:
11 //              dijit/_editor/plugins/NewPage
12
13
14 var NewPage = declare("dijit._editor.plugins.NewPage",_Plugin,{
15         // summary:
16         //              This plugin provides a simple 'new page' capability.  In other
17         //              words, set content to some default user defined string.
18
19         // content: [public] String
20         //              The default content to insert into the editor as the new page.
21         //              The default is the `<br>` tag, a single blank line.
22         content: "<br>",
23
24         _initButton: function(){
25                 // summary:
26                 //              Over-ride for creation of the Print button.
27                 var strings = i18n.getLocalization("dijit._editor", "commands"),
28                         editor = this.editor;
29                 this.button = new Button({
30                         label: strings["newPage"],
31                         ownerDocument: editor.ownerDocument,
32                         dir: editor.dir,
33                         lang: editor.lang,
34                         showLabel: false,
35                         iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "NewPage",
36                         tabIndex: "-1",
37                         onClick: lang.hitch(this, "_newPage")
38                 });
39         },
40
41         setEditor: function(/*dijit/Editor*/ editor){
42                 // summary:
43                 //              Tell the plugin which Editor it is associated with.
44                 // editor: Object
45                 //              The editor object to attach the newPage capability to.
46                 this.editor = editor;
47                 this._initButton();
48         },
49
50         updateState: function(){
51                 // summary:
52                 //              Over-ride for button state control for disabled to work.
53                 this.button.set("disabled", this.get("disabled"));
54         },
55
56         _newPage: function(){
57                 // summary:
58                 //              Function to set the content to blank.
59                 // tags:
60                 //              private
61                 this.editor.beginEditing();
62                 this.editor.set("value", this.content);
63                 this.editor.endEditing();
64                 this.editor.focus();
65         }
66 });
67
68 // Register this plugin.
69 // For back-compat accept "newpage" (all lowercase) too, remove in 2.0
70 _Plugin.registry["newPage"] = _Plugin.registry["newpage"] = function(args){
71         return new NewPage({
72                 content: ("content" in args)?args.content:"<br>"
73         });
74 };
75
76 return NewPage;
77 });