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