123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- UE.registerUI('combox',function(editor,uiName){
-
- editor.registerCommand(uiName,{
- execCommand:function(cmdName,value){
-
- this.execCommand('fontsize',value + 'px')
- },
- queryCommandValue:function(){
-
- return this.queryCommandValue('fontsize')
- }
- });
-
- var items = [];
- for(var i= 0,ci;ci=[10, 11, 12, 14, 16, 18, 20, 24, 36][i++];){
- items.push({
-
- label:'字体:' + ci + 'px',
-
- value:ci,
-
- renderLabelHtml:function () {
-
- return '<div class="edui-label %%-label" style="line-height:2;font-size:' +
- this.value + 'px;">' + (this.label || '') + '</div>';
- }
- });
- }
-
- var combox = new UE.ui.Combox({
-
- editor:editor,
-
- items:items,
-
- onselect:function (t, index) {
-
- editor.execCommand(uiName, this.items[index].value);
- },
-
- title:uiName,
-
- initValue:uiName
- });
- editor.addListener('selectionchange', function (type, causeByUi, uiReady) {
- if (!uiReady) {
- var state = editor.queryCommandState(uiName);
- if (state == -1) {
- combox.setDisabled(true);
- } else {
- combox.setDisabled(false);
- var value = editor.queryCommandValue(uiName);
- if(!value){
- combox.setValue(uiName);
- return;
- }
-
- value && (value = value.replace(/['"]/g, '').split(',')[0]);
- combox.setValue(value);
- }
- }
- });
- return combox;
- },2);
|