Commit 9f1ad585 authored by campaign's avatar campaign

by zhanyi

parent 2084f398
utils.extend( KityMinder, function () {
var _kityminderUI = {},
_kityminderToolbarUI ={},
_activeWidget = null,
_widgetData = {},
_widgetCallBack = {};
......@@ -9,6 +10,16 @@ utils.extend( KityMinder, function () {
_kityminderUI[ name ] = fn;
} )
},
registerToolbarUI: function ( uiname, fn ) {
utils.each( uiname.split( /\s+/ ), function ( i, name ) {
_kityminderToolbarUI[ name ] = fn;
} )
},
loadUI:function(km){
utils.each( _kityminderUI, function ( i, fn ) {
fn.call(km)
} )
},
_createUI: function ( id ) {
var $cont = $( '<div class="kmui-container"></div>' ),
$toolbar = $.kmuitoolbar(),
......@@ -17,6 +28,7 @@ utils.extend( KityMinder, function () {
$cont.append( $toolbar ).append( $kmbody ).append( $statusbar );
$( utils.isString( id ) ? '#' + id : id ).append( $cont );
return {
'$container': $cont,
'$toolbar': $toolbar,
......@@ -33,8 +45,8 @@ utils.extend( KityMinder, function () {
if ( name == '|' ) {
$.kmuiseparator && btns.push( $.kmuiseparator() );
} else {
if ( _kityminderUI[ name ] ) {
var ui = _kityminderUI[ name ].call( km, name );
if ( _kityminderToolbarUI[ name ] ) {
var ui = _kityminderToolbarUI[ name ].call( km, name );
ui && btns.push( ui );
}
......@@ -55,6 +67,8 @@ utils.extend( KityMinder, function () {
this._createToolbar( containers.$toolbar, km );
this._createStatusbar( containers.$statusbar, km );
km.$container = containers.$container;
this.loadUI(km);
return km.fire( 'interactchange' );
},
registerWidget: function ( name, pro, cb ) {
......
KM.registerUI( 'bold italic redo undo',
KM.registerToolbarUI( 'bold italic redo undo',
function ( name ) {
var me = this;
var $btn = $.kmuibutton( {
......
KM.registerUI( 'layoutstyle fontfamily fontsize', function ( name ) {
KM.registerToolbarUI( 'layoutstyle fontfamily fontsize', function ( name ) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
......@@ -130,7 +130,7 @@ KM.registerUI( 'layoutstyle fontfamily fontsize', function ( name ) {
} );
KM.registerUI( 'forecolor', function ( name ) {
KM.registerToolbarUI( 'forecolor', function ( name ) {
function getCurrentColor() {
return $colorLabel.css( 'background-color' );
}
......
KM.registerUI( 'markers', function ( name ) {
KM.registerToolbarUI( 'markers', function ( name ) {
var me = this,
currentRange, $dialog,
......
......@@ -27,7 +27,7 @@ function zoom( paper, rate ) {
return zoomValue;
}
KM.registerUI( 'hand zoom-in zoom-out',
KM.registerToolbarUI( 'hand zoom-in zoom-out',
function ( name ) {
var me = this;
var $btn = $.kmuibutton( {
......
KM.registerUI( 'saveto', function ( name ) {
KM.registerToolbarUI( 'saveto', function ( name ) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
......
KM.registerUI( 'tooltips',
function ( name ) {
var km = this;
//添加tooltip;
if($.kmuitooltip){
$("[data-original-title]",km.$container).each(function(i,n){
var tooltips = km.getLang('tooltips');
var tooltip = $(n).data('original-title');
utils.each(tooltips,function(v,k){
if(k == tooltip && km.getShortcutKey(v)){
$(n).attr('data-original-title',tooltip + ' (' + km.getShortcutKey(v).toUpperCase() + ')');
}
})
});
$.kmuitooltip('attachTo', $("[data-original-title]",km.$container)).css('z-index',km.getOptions('zIndex')+1);
}
km.$container.find('a').click(function(evt){
evt.preventDefault()
});
}
);
\ No newline at end of file
......@@ -70,13 +70,19 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._bindshortcutKeys();
},
addShortcutKeys: function ( cmd, keys ) {
var obj = {};
var obj = {},km = this;
if ( keys ) {
obj[ cmd ] = keys
} else {
obj = cmd;
}
utils.extend( this._shortcutkeys, obj )
utils.each(obj,function(k,v){
km._shortcutkeys[k.toLowerCase()] = v;
});
},
getShortcutKey : function(cmdName){
return this._shortcutkeys[cmdName]
},
_bindshortcutKeys: function () {
var me = this,
......
......@@ -134,6 +134,9 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'selectionclear':function(){
receiver.setTextEditStatus(false).clear()
}
}
};
......
......@@ -2,7 +2,7 @@
Minder.Receiver = kity.createClass('Receiver',{
clear : function(){
this.container.innerHTML = '';
this.selection.setHide();
this.selection && this.selection.setHide();
this.index = 0;
return this;
},
......@@ -127,16 +127,24 @@ Minder.Receiver = kity.createClass('Receiver',{
//更新模拟选区的范围
this.selection.setStartOffset(this.index).collapse(true);
if(this.index == this.textData.length){
if(this.index == 0){
this.selection.setPosition(this.getBaseOffset())
}else{
this.selection.setPosition({
x : this.textData[this.index-1].x + this.textData[this.index-1].width,
y : this.textData[this.index-1].y
})
}
}else{
this.selection.setPosition(this.textData[this.index])
}
return this;
},
getBaseOffset:function(){
return this.textShape.getRenderBox('top');
},
setBaseOffset :function(){
this.offset = this.textShape.getRenderBox('top');
return this;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment