| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/i18n", |
| 4 |
"dojo/_base/lang", |
| 5 |
"../_Plugin", |
| 6 |
"../../form/Button", |
| 7 |
"dojo/i18n!../nls/commands" |
| 8 |
], function(declare, i18n, lang, _Plugin, Button){ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
var NewPage = declare("dijit._editor.plugins.NewPage", _Plugin, { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
content: "<br>", |
| 22 |
|
| 23 |
_initButton: function(){ |
| 24 |
|
| 25 |
|
| 26 |
var strings = i18n.getLocalization("dijit._editor", "commands"), |
| 27 |
editor = this.editor; |
| 28 |
this.button = new Button({ |
| 29 |
label: strings["newPage"], |
| 30 |
ownerDocument: editor.ownerDocument, |
| 31 |
dir: editor.dir, |
| 32 |
lang: editor.lang, |
| 33 |
showLabel: false, |
| 34 |
iconClass: this.iconClassPrefix + " " + this.iconClassPrefix + "NewPage", |
| 35 |
tabIndex: "-1", |
| 36 |
onClick: lang.hitch(this, "_newPage") |
| 37 |
}); |
| 38 |
}, |
| 39 |
|
| 40 |
setEditor: function( editor){ |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
this.editor = editor; |
| 46 |
this._initButton(); |
| 47 |
}, |
| 48 |
|
| 49 |
updateState: function(){ |
| 50 |
|
| 51 |
|
| 52 |
this.button.set("disabled", this.get("disabled")); |
| 53 |
}, |
| 54 |
|
| 55 |
_newPage: function(){ |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
this.editor.beginEditing(); |
| 61 |
this.editor.set("value", this.content); |
| 62 |
this.editor.endEditing(); |
| 63 |
this.editor.focus(); |
| 64 |
} |
| 65 |
}); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
_Plugin.registry["newPage"] = _Plugin.registry["newpage"] = function(args){ |
| 70 |
return new NewPage({ |
| 71 |
content: ("content" in args) ? args.content : "<br>" |
| 72 |
}); |
| 73 |
}; |
| 74 |
|
| 75 |
return NewPage; |
| 76 |
}); |