Commit c5603e4c authored by techird's avatar techird

Merge branch 'dev' into gh-pages

parents d0599807 3de023b6
......@@ -20,6 +20,9 @@
"KITYMINDER_CONFIG",
"keymap",
"Utils",
"utils"
"utils",
"$",
"KM",
"keymap"
]
}
\ No newline at end of file
window.KITYMINDER_CONFIG = {
(function(){
function getKMBasePath ( docUrl, confUrl ) {
return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
}
function getConfigFilePath () {
var configPath = document.getElementsByTagName('script');
return configPath[ configPath.length -1 ].src;
}
function getBasePath ( docUrl, confUrl ) {
var basePath = confUrl;
if(/^(\/|\\\\)/.test(confUrl)){
basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/,'');
}else if ( !/^[a-z]+:/i.test( confUrl ) ) {
docUrl = docUrl.split( "#" )[0].split( "?" )[0].replace( /[^\\\/]+$/, '' );
basePath = docUrl + "" + confUrl;
}
return optimizationPath( basePath );
}
function optimizationPath ( path ) {
var protocol = /^[a-z]+:\/\//.exec( path )[ 0 ],
tmp = null,
res = [];
path = path.replace( protocol, "" ).split( "?" )[0].split( "#" )[0];
path = path.replace( /\\/g, '/').split( /\// );
path[ path.length - 1 ] = "";
while ( path.length ) {
if ( ( tmp = path.shift() ) === ".." ) {
res.pop();
} else if ( tmp !== "." ) {
res.push( tmp );
}
}
return protocol + res.join( "/" );
}
window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand | undo redo | bold italic | fontfamily fontsize forecolor | saveto'
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers'
]
//设置主题
......@@ -16,6 +78,5 @@ window.KITYMINDER_CONFIG = {
//设置km整体的z-index大小
//,zIndex : 1000
};
\ No newline at end of file
};
})()
( function () {
var utils = KM.utils;
KM.registerWidget( 'markers', {
tpl: "<ul class='icon-list'>" +
"<li value='1' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) 0 0'></span><span><%= priority %>1</span></li>" +
"<li value='2' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -20px 0'></span><span><%= priority %>2</span></li>" +
"<li value='3' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -40px 0'></span><span><%= priority %>3</span></li>" +
"<li value='4' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -60px 0'></span><span><%= priority %>4</span></li>" +
"<li value='5' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -80px 0'></span><span><%= priority %>5</span></li>" +
"</ul>" +
"<ul class='icon-list'>" +
"<li value='1' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) 0 0'></span><span><%= progress.notdone %></span></li>" +
"<li value='2' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -20px 0'></span><span><%= progress.quarterdone %></span></li>" +
"<li value='3' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -40px 0'></span><span><%= progress.halfdone %></span></li>" +
"<li value='4' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -60px 0'></span><span><%= progress.threequartersdone %></span></li>" +
"<li value='5' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -80px 0'></span><span><%= progress.done %></span></li>" +
"</ul>",
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.markers' );
if ( lang ) {
var html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
initEvent: function ( km, $w ) {
$w.on( "click", "li", function () {
var $this = $( this );
$this.siblings().removeClass( "active" );
$this.toggleClass( "active" );
var val = $this.val();
if ( !$this.hasClass( "active" ) ) {
val = null;
}
var type = $this.attr( "type" );
km.execCommand( type, val );
} );
km.on( 'interactchange', function ( e ) {
var valPri = this.queryCommandValue( "priority" );
var valPro = this.queryCommandValue( "progress" );
$w.find( "li[type='priority']" ).removeClass( "active" );
$w.find( "li[type='priority'][value='" + valPri + "']" ).addClass( "active" );
$w.find( "li[type='progress']" ).removeClass( "active" );
$w.find( "li[type='progress'][value='" + valPro + "']" ).addClass( "active" );
} );
},
buttons: {
'ok': {
exec: function ( km, $w ) {
var href = $( '#kmui-link-Jhref' ).val().replace( /^\s+|\s+$/g, '' );
if ( href ) {
km.execCommand( 'link', {
'href': href,
'target': $( "#kmui-link-Jtarget:checked" ).length ? "_blank" : '_self',
'title': $( "#kmui-link-Jtitle" ).val().replace( /^\s+|\s+$/g, '' ),
'_href': href
} );
}
}
},
'cancel': {}
},
width: 200,
} )
} )();
\ No newline at end of file
......@@ -23,7 +23,7 @@ $dependency = Array(
,'src/module/layout.default.js'
,'src/module/layout.bottom.js'
,'src/core/minder.select.js'
,'src/module/dragview.js'
,'src/module/hand.js'
,'src/module/dragtree.js'
,'src/module/dropfile.js'
,'src/module/keyboard.js'
......@@ -36,6 +36,7 @@ $dependency = Array(
,'src/module/basestyle.js'
,'src/module/font.js'
,'src/module/zoom.js'
,'src/ui/jquery-ui-1.10.4.custom.min.js'
,'src/ui/widget.js'
,'src/ui/button.js'
,'src/ui/toolbar.js'
......@@ -58,7 +59,9 @@ $dependency = Array(
,'src/adapter/button.js'
,'src/adapter/combobox.js'
,'src/adapter/saveto.js'
,'src/adapter/hand.js'
,'src/adapter/view.js'
,'src/adapter/dialog.js'
,'src/adapter/tooltips.js'
,'src/protocal/plain.js'
,'src/protocal/json.js'
);
......
Subproject commit dd0e68ce6b5467c07d1e92ba7af16d4569232365
Subproject commit df7b361ae5098710eca0fec1080dce4bc822bf24
KityMinder.LANG[ 'zh-cn' ] = {
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
'undo': '撤销',
'redo': '重做',
......@@ -8,13 +10,34 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontfamily': '字体',
'fontsize': '字号',
'layoutstyle': '主题',
'saveto': '导出'
'saveto': '导出',
'hand': '允许拖拽',
'zoom-in': '放大',
'zoom-out': '缩小',
'markers': '添加标签'
},
'popupcolor': {
'clearColor': '清空颜色',
'standardColor': '标准颜色',
'themeColor': '主题颜色'
},
'hand': '允许拖拽'
'dialogs': {
'markers': {
'static': {
'lang_input_text': '文本内容:',
'lang_input_url': '链接地址:',
'lang_input_title': '标题:',
'lang_input_target': '是否在新窗口打开:'
},
'priority': '优先级',
'progress': {
'notdone': "未完成",
'quarterdone': '完成1/4',
'halfdone': '完成1/2',
'threequartersdone': '完成3/4',
'done': '已完成',
}
}
}
};
\ No newline at end of file
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',
function(name) {
KM.registerToolbarUI( 'bold italic redo undo',
function ( name ) {
var me = this;
var $btn = $.kmuibutton({
icon : name,
click : function(){
me.execCommand(name);
var $btn = $.kmuibutton( {
icon: name,
click: function () {
me.execCommand( name );
},
title: this.getLang('tooltips')[name] || ''
});
this.on('interactchange',function(){
var state = this.queryCommandState(name);
$btn.kmui().disabled(state == -1).active(state == 1)
});
title: this.getLang( 'tooltips' )[ name ] || ''
} );
this.on( 'interactchange', function () {
var state = this.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 );
} );
return $btn;
}
);
\ No newline at end of file
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.registerToolbarUI( 'markers', function ( name ) {
var me = this,
currentRange, $dialog,
opt = {
width: 200,
title: this.getLang( 'tooltips' )[ name ] || '',
url: me.getOptions( 'KITYMINDER_HOME_URL' ) + 'dialogs/' + name + '/' + name + '.js',
};
var $btn = $.kmuibutton( {
icon: name,
title: this.getLang( 'tooltips' )[ name ] || ''
} );
//加载模版数据
utils.loadFile( document, {
src: opt.url,
tag: "script",
type: "text/javascript",
defer: "defer"
}, function () {
$dialog = $.kmuimodal( opt );
$dialog.attr( 'id', 'kmui-dialog-' + name ).addClass( 'kmui-dialog-' + name )
.find( '.kmui-modal-body' ).addClass( 'kmui-dialog-' + name + '-body' );
$dialog.kmui().on( 'beforeshow', function () {
var $root = this.root(),
win = null,
offset = null;
if ( !$root.parent()[ 0 ] ) {
me.$container.find( '.kmui-dialog-container' ).append( $root );
}
KM.setWidgetBody( name, $dialog, me );
} ).attachTo( $btn )
} );
me.on( 'interactchange', function () {
var state = this.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 )
} );
return $btn;
} );
\ No newline at end of file
KM.registerUI( 'hand',
function ( name ) {
var me = this;
var $btn = $.kmuibutton( {
icon: name,
click: function ( e ) {
var drag = me._onDragMode = !me._onDragMode;
me._paper.setStyle( 'cursor', drag ? 'pointer' : 'default' );
me._paper.setStyle( 'cursor', drag ? '-webkit-grab' : 'default' );
$btn.kmui().active( drag );
if ( drag ) {
me._paper.drag();
} else {
me._paper.undrag();
}
},
title: this.getLang( 'hand' )[ name ] || ''
} );
me.on( 'beforemousemove', function ( e ) {
if ( this._onDragMode ) {
e.stopPropagation();
}
} );
kity.extendClass( kity.Paper, kity.Draggable );
return $btn;
}
);
\ No newline at end of file
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
KM.registerToolbarUI( 'hand zoom-in zoom-out',
function ( name ) {
var me = this;
var $btn = $.kmuibutton( {
icon: name,
click: function () {
me.execCommand( name );
},
title: this.getLang( 'tooltips.' )[ name ] || ''
} );
me.on('interactchange', function() {
var state = me.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 );
});
return $btn;
}
);
\ No newline at end of file
var KityMinder =
window.KM =
window.KityMinder = function(){
window.KityMinder = function () {
var instanceMap = {}, instanceId = 0;
return {
version : '1.0.0',
createMinder : function ( renderTarget, options ) {
version: '1.0.0',
createMinder: function ( renderTarget, options ) {
options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
var minder = new Minder( options );
this.addMinder(options.renderTo,minder);
this.addMinder( options.renderTo, minder );
return minder;
},
addMinder : function ( target, minder ) {
addMinder: function ( target, minder ) {
var id;
if ( typeof ( target ) === 'string' ) {
id = target;
......@@ -20,17 +20,16 @@ var KityMinder =
}
instanceMap[ id ] = minder;
},
getMinder : function(target,options){
getMinder: function ( target, options ) {
var id;
if ( typeof ( target ) === 'string' ) {
id = target;
} else {
id = target.id || ( "KM_INSTANCE_" + instanceId++ );
}
return instanceMap[ id ] || this.createMinder(target,options);
return instanceMap[ id ] || this.createMinder( target, options );
},
//挂接多语言
LANG:{}
LANG: {}
}
}();
}();
\ No newline at end of file
......@@ -72,7 +72,7 @@ kity.extendClass( Minder, {
if ( test.recognize && test.recognize( local ) ) {
protocal = test;
}
return !test;
return !protocal;
} );
}
......
......@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
},
// TODO: mousemove lazy bind
_bindPaperEvents: function () {
this._paper.on( 'click mousedown mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) );
this._paper.on( 'click dblclick mousedown mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) );
if ( window ) {
window.addEventListener( 'resize', this._firePharse.bind( this ) );
}
......
......@@ -39,7 +39,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._addRenderContainer();
this._root = new MinderNode( "Main Topic" );
this._root = new MinderNode( this.getLang().maintopic );
this._root.setType( "root" );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
......@@ -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,
......
//添加多语言模块
kity.extendClass( Minder, {
getLang:function(path){
getLang: function ( path ) {
var lang = KM.LANG[this.getOptions('lang')];
if (!lang) {
throw Error("not import language file");
var lang = KM.LANG[ this.getOptions( 'lang' ) ];
if ( !lang ) {
throw Error( "not import language file" );
}
path = (path || "").split(".");
for (var i = 0, ci; ci = path[i++];) {
lang = lang[ci];
if (!lang)break;
path = ( path || "" ).split( "." );
for ( var i = 0, ci; ci = path[ i++ ]; ) {
lang = lang[ ci ];
if ( !lang ) break;
}
return lang;
}
......
......@@ -38,12 +38,12 @@ kity.extendClass( Minder, {
}
}
if(moduleDeals.defaultOptions){
this.setDefaultOptions(moduleDeals.defaultOptions);
if ( moduleDeals.defaultOptions ) {
this.setDefaultOptions( moduleDeals.defaultOptions );
}
//添加模块的快捷键
if(moduleDeals.addShortcutKeys){
this.addShortcutKeys(moduleDeals.addShortcutKeys)
if ( moduleDeals.addShortcutKeys ) {
this.addShortcutKeys( moduleDeals.addShortcutKeys )
}
}
......
......@@ -26,6 +26,7 @@ kity.extendClass( Minder, function () {
unhighlightNode( me, n );
} );
this._selectedNodes = [];
return this.fire( 'selectionclear' );
},
removeSelectedNodes: function ( nodes ) {
var me = this;
......
......@@ -185,7 +185,89 @@ var utils = Utils = KityMinder.Utils = {
parent = parent.parent;
}
return parent;
},
loadFile:function () {
var tmpList = [];
function getItem(doc, obj) {
try {
for (var i = 0, ci; ci = tmpList[i++];) {
if (ci.doc === doc && ci.url == (obj.src || obj.href)) {
return ci;
}
}
} catch (e) {
return null;
}
}
return function (doc, obj, fn) {
var item = getItem(doc, obj);
if (item) {
if (item.ready) {
fn && fn();
} else {
item.funs.push(fn)
}
return;
}
tmpList.push({
doc:doc,
url:obj.src || obj.href,
funs:[fn]
});
if (!doc.body) {
var html = [];
for (var p in obj) {
if (p == 'tag')continue;
html.push(p + '="' + obj[p] + '"')
}
doc.write('<' + obj.tag + ' ' + html.join(' ') + ' ></' + obj.tag + '>');
return;
}
if (obj.id && doc.getElementById(obj.id)) {
return;
}
var element = doc.createElement(obj.tag);
delete obj.tag;
for (var p in obj) {
element.setAttribute(p, obj[p]);
}
element.onload = element.onreadystatechange = function () {
if (!this.readyState || /loaded|complete/.test(this.readyState)) {
item = getItem(doc, obj);
if (item.funs.length > 0) {
item.ready = 1;
for (var fi; fi = item.funs.pop();) {
fi();
}
}
element.onload = element.onreadystatechange = null;
}
};
element.onerror = function () {
throw Error('The load ' + (obj.href || obj.src) + ' fails,check the url settings of file umeditor.config.js ')
};
doc.getElementsByTagName("head")[0].appendChild(element);
}
}(),
clone:function (source, target) {
var tmp;
target = target || {};
for (var i in source) {
if (source.hasOwnProperty(i)) {
tmp = source[i];
if (typeof tmp == 'object') {
target[i] = utils.isArray(tmp) ? [] : {};
utils.clone(source[i], target[i])
} else {
target[i] = tmp;
}
}
}
return target;
},
};
......
This diff is collapsed.
......@@ -27,7 +27,7 @@ KityMinder.registerModule( "TextEditModule", function () {
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
if ( this.isSingleSelect() && node.isSelected() ) {
if ( this.isSingleSelect() && node.isSelected() && e.kityEvent.targetShape.getType().toLowerCase()== 'text') {
sel.collapse();
node.getTextShape().setStyle('cursor','text');
......@@ -48,7 +48,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'mouseup':function(e){
if(!sel.collapsed){
if(!sel.collapsed && mouseDownStatus){
receiver.updateRange(range)
}
mouseDownStatus = false;
......@@ -57,25 +57,86 @@ KityMinder.registerModule( "TextEditModule", function () {
'beforemousemove':function(e){
if(mouseDownStatus){
e.stopPropagationImmediately();
setTimeout(function(){
var offset = e.getPosition();
dir = offset.x > lastEvtPosition.x ? 1 : (offset.x < lastEvtPosition.x ? -1 : dir);
receiver.updateSelectionByMousePosition(offset,dir)
.updateSelectionShow(dir);
sel.stroke('none',0);
lastEvtPosition = e.getPosition();
},100)
}
},
'dblclick':function(e){
var text = e.kityEvent.targetShape;
if ( text.getType().toLowerCase()== 'text') {
sel.setStartOffset(0);
sel.setEndOffset(text.getContent().length);
sel.setShow();
receiver.updateSelectionShow(1)
.updateRange(range);
}
},
'restoreScene':function(){
sel.setHide();
},
'stopTextEdit':function(){
sel.setHide();
receiver.clear().setTextEditStatus(false);
},
'execCommand':function(e){
var cmds = {
'appendchildnode':1,
'appendsiblingnode':1
};
if(cmds[e.commandName]){
var node = km.getSelectedNode();
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
node.getTextShape().setStyle('cursor','text');
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
.setMinderNode(node)
.setTextShape(textShape)
.setBaseOffset()
.setContainerStyle()
.setSelectionHeight()
.getTextOffsetData()
.setIndex(0)
.updateSelection()
.setRange(range);
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
sel.setShow();
receiver.updateSelectionShow(1)
.updateRange(range);
}
if(e.commandName == 'priority' || e.commandName == 'progress'){
receiver.setBaseOffset()
.getTextOffsetData();
if(sel.collapsed){
receiver.updateSelection();
}else{
receiver.updateSelectionShow(1)
}
}
},
'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;
},
......@@ -77,8 +77,10 @@ Minder.Receiver = kity.createClass('Receiver',{
switch(keyCode){
case keymap.Enter:
case keymap.Tab:
if(this.keydownNode === this.minderNode){
this.setTextEditStatus(false);
this.clear();
}
e.preventDefault();
return;
case keymap.Shift:
......@@ -125,26 +127,26 @@ 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(){
var nodeOffset = this.minderNode.getRenderContainer().getRenderBox();
// var textOffset = this.textShape.getRenderBox();
var contRcOffset = this.minderNode.getContRc().getRenderBox();
this.offset = {
x : nodeOffset.x + contRcOffset.x,
y : nodeOffset.y + contRcOffset.y
};
this.offset = this.textShape.getRenderBox('top');
return this;
},
setContainerStyle : function(){
......@@ -223,6 +225,9 @@ Minder.Receiver = kity.createClass('Receiver',{
if(offset.x >= v.x && offset.x <= v.x + v.width){
if(me.index == i){
if(i == 0){
me.selection.setStartOffset(i)
}
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
}else if(i > me.index){
me.selection.setEndOffset(i + (dir == 1 ? 1 : 0))
......@@ -236,7 +241,6 @@ Minder.Receiver = kity.createClass('Receiver',{
return this;
},
updateSelectionShow:function(){
var startOffset = this.textData[this.selection.startOffset],
endOffset = this.textData[this.selection.endOffset],
width = 0 ;
......@@ -261,5 +265,9 @@ Minder.Receiver = kity.createClass('Receiver',{
range.setEnd(node,this.selection.endOffset);
range.select();
return this;
},
setIndex:function(index){
this.index = index;
return this
}
});
\ No newline at end of file
......@@ -86,10 +86,15 @@ Minder.Selection = kity.createClass( 'Selection', {
clearInterval( this.timer );
var me = this,
state = '';
if(this.collapsed){
this.timer = setInterval( function () {
me.setStyle( 'display', state );
state = state ? '' : 'none';
}, 300 );
}else{
me.setStyle( 'display', '' );
}
return this;
},
setTextShape: function ( text ) {
......
......@@ -101,9 +101,11 @@ kity.Draggable = ( function () {
paper.off( DRAG_MOVE_EVENT, dragFn );
dragTarget.trigger( 'dragend' );
if ( e ) {
e.stopPropagation();
e.preventDefault();
}
}
} );
}
......@@ -128,6 +130,7 @@ kity.Draggable = ( function () {
undrag: function () {
var target = this.dragTarget;
target.off( DRAG_START_EVENT, target._dragStartHandler );
target._dragEndHandler();
target.getPaper().off( DRAG_END_EVENT, target._dragEndHandler );
delete target._dragStartHandler;
delete target._dragEndHandler;
......@@ -136,3 +139,45 @@ kity.Draggable = ( function () {
}
} );
} )();
KityMinder.registerModule( 'Hand', function () {
var ToggleHandCommand = kity.createClass( "ToggleHandCommand", {
base: Command,
execute: function ( minder ) {
var drag = minder._onDragMode = !minder._onDragMode;
minder.getPaper().setStyle( 'cursor', drag ? 'pointer' : 'default' );
minder.getPaper().setStyle( 'cursor', drag ? '-webkit-grab' : 'default' );
if ( drag ) {
minder.getPaper().drag();
} else {
minder.getPaper().undrag();
}
},
queryState: function ( minder ) {
return minder._onDragMode ? 1 : 0;
}
} );
return {
init: function () {
this._onDragMode = false;
kity.extendClass( kity.Paper, kity.Draggable );
},
commands: {
'hand': ToggleHandCommand
},
events: {
keyup: function ( e ) {
if ( e.originEvent.keyCode == keymap.Spacebar && this.getSelectedNodes().length === 0 ) {
this.execCommand( 'hand' );
e.preventDefault();
}
},
beforemousemove: function ( e ) {
if ( this._onDragMode ) {
e.stopPropagation();
}
}
}
};
} );
\ No newline at end of file
KityMinder.registerModule( "IconModule", function () {
var renderPriorityIcon = function ( node, val ) {
var colors = [ "", "red", "blue", "green", "orange", "purple" ];
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 );
var _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 );
var _rc = new kity.Group();
......@@ -10,7 +10,7 @@ KityMinder.registerModule( "IconModule", function () {
};
var renderProgressIcon = function ( node, val, left ) {
var _rc = new kity.Group();
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "blue", 2 ) );
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) );
var _percent, d;
if ( val < 5 ) {
_percent = new kity.Path();
......@@ -34,49 +34,70 @@ KityMinder.registerModule( "IconModule", function () {
d.carcTo( 6, 0, 6, 1, 0 );
break;
case 5:
_percent.addShape( new kity.Circle().setRadius( 6 ).fill( "blue" ) );
var check = new kity.Path();
_percent.addShapes( [ new kity.Circle().setRadius( 6 ).fill( "#29A6BD" ), check ] );
check.getDrawer().moveTo( -3, 0 ).lineTo( -1, 3 ).lineTo( 3, -2 );
check.stroke( new kity.Pen( "white", 2 ).setLineCap( "round" ) );
break;
}
if ( val < 5 ) d.close();
_percent.fill( "blue" );
_percent.fill( "#29A6BD" );
};
var ChangeIconCommand = kity.createClass( "AddIconCommand", ( function () {
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
return {
base: Command,
execute: function ( km, iconType, value ) {
execute: function ( km, value ) {
var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) {
nodes[ i ].setData( iconType, value );
nodes[ i ].setData( "PriorityIcon", value );
km.updateLayout( nodes[ i ] );
}
},
queryValue: function ( km ) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "PriorityIcon" );
if ( val ) break;
}
return val;
}
};
} )() );
var RemoveIconCommand = kity.createClass( "RemoveIconCommand", ( function () {
var setProgressCommand = kity.createClass( "SetProgressCommand", ( function () {
return {
base: Command,
execute: function ( km, iconType ) {
execute: function ( km, value ) {
var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) {
nodes[ i ].setData( iconType, null );
nodes[ i ].setData( "ProgressIcon", value );
km.updateLayout( nodes[ i ] );
}
},
queryValue: function ( km ) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "ProgressIcon" );
if ( val ) break;
}
return val;
}
};
} )() );
return {
"commands": {
"changeicon": ChangeIconCommand,
"removeicon": RemoveIconCommand
"priority": setPriorityCommand,
"progress": setProgressCommand
},
"events": {
"RenderNode": function ( e ) {
var node = e.node;
var iconRc = node.getIconRc();
var contRc = node.getContRc();
var PriorityIconVal = node.getData( "PriorityIcon" );
var ProgressIconVal = node.getData( "ProgressIcon" );
//依次排布图标、文字
iconRc.setTransform( new kity.Matrix().translate( 0, -20 ) );
iconRc.clear();
var PriorityIconWidth = 0;
if ( PriorityIconVal ) {
......@@ -89,6 +110,8 @@ KityMinder.registerModule( "IconModule", function () {
var iconWidth = iconRc.getWidth();
var textShape = node.getTextShape();
if ( iconWidth ) textShape.setTransform( new kity.Matrix().translate( iconWidth + 5, 0 ) );
else textShape.setTransform( new kity.Matrix().translate( 0, 0 ) );
iconRc.setTransform( new kity.Matrix().translate( 0, -( iconRc.getHeight() + textShape.getHeight() ) / 2 ) );
}
}
};
......
......@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
buildPositionNetwork( this.getRoot() );
},
keydown: function ( e ) {
var keys = KityMinder.keymap;
if ( this.receiver.isTextEditStatus() ) {
switch ( e.originEvent.keyCode ) {
......@@ -85,13 +86,15 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
return;
}
var node = e.getTargetNode();
this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) {
case keys.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( 'Topic' ) );
this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ) );
e.preventDefault();
break;
case keys.Tab:
this.execCommand( 'appendChildNode', new MinderNode( 'Topic' ) );
this.execCommand( 'appendChildNode', new MinderNode( this.getLang().topic ) );
e.preventDefault();
break;
case keys.Backspace:
......
This diff is collapsed.
......@@ -53,9 +53,10 @@ KityMinder.registerModule( "LayoutDefault", function () {
var nodeShape = node.getRenderContainer();
var nodeX, nodeY = ( node.getType() === "main" ? Layout.y : ( Layout.y + nodeShape.getHeight() / 2 - 5 ) );
if ( Layout.appendside === "left" ) {
nodeX = nodeShape.getRenderBox().closurePoints[ 1 ].x - 6;
nodeX = nodeShape.getRenderBox().closurePoints[ 1 ].x - 5;
} else {
nodeX = nodeShape.getRenderBox().closurePoints[ 0 ].x + 6;
if ( node.getType() === "main" ) nodeX -= 3;
}
this.shape.setTransform( new kity.Matrix().translate( nodeX, nodeY ) );
},
......@@ -121,7 +122,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
case "sub":
var underline = Layout.underline = new kity.Path();
var highlightshape = Layout.highlightshape = new kity.Rect().setRadius( 4 );
node.getBgRc().clear().addShapes( [ highlightshape, underline ] );
node.getBgRc().clear().addShapes( [ Layout.bgRect = new kity.Rect().setRadius( 4 ), highlightshape, underline ] );
break;
default:
break;
......@@ -160,6 +161,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
case "sub":
var _contWidth = contRc.getWidth();
var _contHeight = contRc.getHeight();
width = _contWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ];
height = _contHeight + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ];
Layout.underline.getDrawer()
.clear()
.moveTo( 0, _contHeight + nodeStyle.padding[ 2 ] + nodeStyle.padding[ 0 ] )
......@@ -168,6 +171,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.highlightshape
.setWidth( _contWidth + nodeStyle.padding[ 1 ] + nodeStyle.padding[ 3 ] )
.setHeight( _contHeight + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ] );
Layout.bgRect.setWidth( width ).setHeight( height );
break;
default:
break;
......@@ -216,7 +220,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else {
if ( action === "append" || action === "contract" ) {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ];
} else if ( action === "change" ) { //展开
} else if ( action === "change" ) {
Layout.branchheight = countBranchHeight( node );
}
var parentLayout = parent.getLayout();
......@@ -328,16 +332,16 @@ KityMinder.registerModule( "LayoutDefault", function () {
var endPos;
if ( Layout.appendside === "left" ) {
sPos = new kity.BezierPoint( rootX - 30, nodeClosurePoints[ 2 ].y + nodeShape.getHeight() / 2 );
endPos = new kity.BezierPoint( nodeClosurePoints[ 2 ].x, nodeClosurePoints[ 2 ].y + nodeShape.getHeight() / 2 );
endPos = new kity.BezierPoint( nodeClosurePoints[ 2 ].x + 3, nodeClosurePoints[ 2 ].y + nodeShape.getHeight() / 2 );
} else {
sPos = new kity.BezierPoint( rootX + 30, nodeClosurePoints[ 3 ].y + nodeShape.getHeight() / 2 );
endPos = new kity.BezierPoint( nodeClosurePoints[ 3 ].x, nodeClosurePoints[ 3 ].y + nodeShape.getHeight() / 2 );
endPos = new kity.BezierPoint( nodeClosurePoints[ 3 ].x - 3, nodeClosurePoints[ 3 ].y + nodeShape.getHeight() / 2 );
}
var sPosV = sPos.getVertex();
var endPosV = endPos.getVertex();
sPos.setVertex( rootX, rootY );
connect.bezier.setPoints( [ sPos, endPos ] ).stroke( nodeStyle.stroke );
connect.circle.setCenter( endPosV.x + ( Layout.appendside === "left" ? 3 : -3 ), endPosV.y ).fill( "white" ).stroke( "gray" ).setRadius( 3 );
connect.circle.setCenter( endPosV.x + ( Layout.appendside === "left" ? -0.5 : -1.5 ), endPosV.y ).fill( "white" ).setRadius( 4 );
} else if ( nodeType === "sub" ) {
if ( !Layout.connect ) {
connect = Layout.connect = new kity.Path();
......@@ -374,7 +378,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
}
}
//更新收放icon
if ( nodeType !== "root" ) {
if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node );
}
......@@ -472,6 +476,16 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.align = siblingLayout.align;
parent.insertChild( node, sibling.getIndex() + 1 );
if ( parent.getType() === "root" ) {
var len = parent.getChildren().length;
if ( len < 7 ) {
if ( len % 2 ) {
Layout.appendside = "right";
Layout.align = "left";
} else {
Layout.appendside = "left";
Layout.align = "right";
}
}
var sideList = parentLayout[ Layout.appendside + "List" ];
var idx = sideList.indexOf( sibling );
sideList.splice( idx + 1, 0, node );
......@@ -543,6 +557,10 @@ KityMinder.registerModule( "LayoutDefault", function () {
removeNode: function ( nodes ) {
while ( nodes.length !== 0 ) {
var parent = nodes[ 0 ].getParent();
if ( !parent ) {
nodes.splice( 0, 1 );
return false;
}
var nodeLayout = nodes[ 0 ].getLayout();
if ( parent.getType() === "root" ) {
var sideList = parent.getLayout()[ nodeLayout.appendside + "List" ];
......@@ -593,7 +611,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else {
_buffer[ 0 ].getRenderContainer().remove();
Layout.connect.remove();
Layout.shicon.remove();
if ( Layout.shicon ) Layout.shicon.remove();
}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift();
......
......@@ -132,6 +132,11 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command,
execute: function ( km ) {
var selectedNodes = km.getSelectedNodes();
var _root = km.getRoot();
if ( selectedNodes.length === 0 || ( selectedNodes.length === 1 && !selectedNodes[ 0 ].getParent() ) ) {
km.select( _root );
return false;
}
var _buffer = [];
for ( var i = 0; i < selectedNodes.length; i++ ) {
_buffer.push( selectedNodes[ i ] );
......@@ -140,7 +145,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var parent = _buffer[ 0 ].getParent();
if ( parent && _buffer.indexOf( parent ) === -1 ) _buffer.push( parent );
_buffer.shift();
} while ( _buffer.length !== 1 );
} while ( _buffer.length > 1 );
km.removeNode( selectedNodes );
km.select( _buffer[ 0 ] );
}
......
......@@ -2,11 +2,19 @@ KityMinder.registerModule( "Select", function () {
var minder = this;
var g = KityMinder.Geometry;
// 框选控制
// 在实例上渲染框选矩形、计算框选范围的对象
var marqueeActivator = ( function () {
// 记录选区的开始位置(mousedown的位置)
var startPosition = null;
// 选区的图形
var marqueeShape = new kity.Path().fill( 'rgba(255,255,255,.3)' ).stroke( 'white' );
// 标记是否已经启动框选状态
// 并不是 mousedown 发生之后就启动框选状态,而是检测到移动了一定的距离(MARQUEE_MODE_THRESHOLD)之后
var marqueeMode = false;
var MARQUEE_MODE_THRESHOLD = 10;
return {
selectStart: function ( e ) {
......@@ -17,20 +25,26 @@ KityMinder.registerModule( "Select", function () {
if ( startPosition ) {
return this.selectEnd();
}
startPosition = g.snapToSharp( e.getPosition() );
minder.getPaper().addShape( marqueeShape );
marqueeShape.setOpacity( 0.8 ).getDrawer().clear();
},
selectMove: function ( e ) {
if ( !startPosition ) return;
var p1 = startPosition,
p2 = e.getPosition();
// 检测是否要进入选区模式
if ( !marqueeMode ) {
if ( g.getDistance( p1, p2 ) < 10 ) {
// 距离没达到阈值,退出
if ( g.getDistance( p1, p2 ) < MARQUEE_MODE_THRESHOLD ) {
return;
}
// 已经达到阈值,记录下来并且重置选区形状
marqueeMode = true;
minder.getPaper().addShape( marqueeShape );
marqueeShape.setOpacity( 0.8 ).getDrawer().clear();
}
var marquee = g.getBox( p1, p2 ),
......@@ -49,7 +63,7 @@ KityMinder.registerModule( "Select", function () {
this.close();
} );
// 选中节点数据更新
// 计算选中范围
minder.getRoot().traverse( function ( node ) {
var renderBox = node.getRenderContainer().getRenderBox();
if ( g.isBoxIntersect( renderBox, marquee ) ) {
......@@ -57,6 +71,7 @@ KityMinder.registerModule( "Select", function () {
}
} );
// 应用选中范围
minder.select( selectedNodes, true );
},
selectEnd: function ( e ) {
......@@ -65,7 +80,7 @@ KityMinder.registerModule( "Select", function () {
}
if ( marqueeMode ) {
marqueeShape.fadeOut( 200, 'ease', 0, function () {
marqueeShape.remove();
if(marqueeShape.remove) marqueeShape.remove();
} );
marqueeMode = false;
}
......@@ -73,25 +88,49 @@ KityMinder.registerModule( "Select", function () {
};
} )();
var lastDownNode = null;
return {
"events": {
mousedown: function ( e ) {
var clickNode = e.getTargetNode();
if ( !clickNode ) {
var downNode = e.getTargetNode();
// 没有点中节点:
// 清除选中状态,并且标记选区开始位置
if ( !downNode ) {
this.removeAllSelectedNodes();
marqueeActivator.selectStart( e );
} else if ( e.originEvent.shiftKey ) {
this.toggleSelect( clickNode );
} else if ( !clickNode.isSelected() ) {
this.select( clickNode, true );
}
// 点中了节点,并且按了 shift 键:
// 被点中的节点切换选中状态
else if ( e.originEvent.shiftKey ) {
this.toggleSelect( downNode );
}
// 点中的节点没有被选择:
// 单选点中的节点
else if ( !downNode.isSelected() ) {
this.select( downNode, true );
}
// 点中的节点被选中了,并且不是单选:
// 完成整个点击之后需要使其变为单选。
// 不能马上变为单选,因为可能是需要拖动选中的多个节点
else if ( !this.isSingleSelect() ) {
lastDownNode = downNode;
}
},
mousemove: marqueeActivator.selectMove,
mouseup: function ( e ) {
var clickNode = e.getTargetNode();
if ( clickNode && clickNode.isSelected() && !this.isSingleSelect() ) {
this.select( clickNode, true );
var upNode = e.getTargetNode();
// 如果 mouseup 发生在 lastDownNode 外,是无需理会的
if ( upNode && upNode == lastDownNode ) {
this.select( lastDownNode, true );
lastDownNode = null;
}
// 清理一下选择状态
marqueeActivator.selectEnd( e );
}
}
......
KityMinder.registerModule( 'Zoom', function () {
/*
var MAX_ZOOM = 2,
MIN_ZOOM = 0.5,
ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) {
var paper = minder.getPaper();
var viewbox = paper.getViewBox();
var zoomValue = minder._zoomValue;
var w = viewbox.width,
h = viewbox.height,
x = viewbox.x,
y = viewbox.y;
var ww = w * rate,
hh = h * rate,
xx = x + ( w - ww ) / 2,
yy = y + ( h - hh ) / 2;
var animator = new kity.Animator( {
beginValue: viewbox,
finishValue: {
width: ww,
height: hh,
x: xx,
y: yy
},
setter: function ( target, value ) {
target.setViewBox( value.x, value.y, value.width, value.height );
}
} );
animator.start( paper, 100, 'ease' );
minder._zoomValue = zoomValue *= rate;
}
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue > MIN_ZOOM) ? 0 : -1;
}
} );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue < MAX_ZOOM) ? 0 : -1;
}
} );
return {
commands: {
'zoom-in': ZoomInCommand,
'zoom-out': ZoomOutCommand
},
addShortcutKeys: {
"zoom-in": "+", //=
"zoom-out": "-" //-
},
events: {
'ready': function () {
this._zoomValue = 1;
},
'mousewheel': function ( e ) {
if ( e.originEvent.wheelDelta > 0 ) {
if ( this._zoom < 0.2 ) return;
this._zoom *= 0.95;
this.getRenderContainer().scale( 0.95 );
var delta = e.originEvent.wheelDelta;
var me = this;
// 稀释
if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout );
} else {
if ( this._zoom > 5 ) return;
this._zoom /= 0.95;
this.getRenderContainer().scale( 1 / 0.95 );
return;
}
this._wheelZoomTimeout = setTimeout( function () {
var value;
var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) {
me.execCommand('zoom-in');
} else if ( delta > 0 ) {
me.execCommand('zoom-out');
}
}, 100 );
e.originEvent.preventDefault();
},
'ready': function () {
this._zoom = 1;
}
}
};*/
return {};
};
} );
\ No newline at end of file
This diff is collapsed.
/*modal 类*/
KM.ui.define('modal', {
KM.ui.define( 'modal', {
tpl: '<div class="kmui-modal" tabindex="-1" >' +
'<div class="kmui-modal-header">' +
'<div class="kmui-close" data-hide="modal"></div>' +
......@@ -24,70 +24,79 @@ KM.ui.define('modal', {
backdrop: true,
keyboard: true
},
init: function (options) {
init: function ( options ) {
var me = this;
me.root($($.parseTmpl(me.tpl, options || {})));
me.root( $( $.parseTmpl( me.tpl, options || {} ) ) );
me.data("options", options);
if (options.okFn) {
me.on('ok', $.proxy(options.okFn, me))
me.data( "options", options );
if ( options.okFn ) {
me.on( 'ok', $.proxy( options.okFn, me ) )
}
if (options.cancelFn) {
me.on('beforehide', $.proxy(options.cancelFn, me))
if ( options.cancelFn ) {
me.on( 'beforehide', $.proxy( options.cancelFn, me ) )
}
me.root().delegate('[data-hide="modal"]', 'click', $.proxy(me.hide, me))
.delegate('[data-ok="modal"]', 'click', $.proxy(me.ok, me));
me.root().delegate( '[data-hide="modal"]', 'click', $.proxy( me.hide, me ) )
.delegate( '[data-ok="modal"]', 'click', $.proxy( me.ok, me ) );
$('[data-hide="modal"],[data-ok="modal"]',me.root()).hover(function(){
$(this).toggleClass('kmui-hover')
});
$( '[data-hide="modal"],[data-ok="modal"]', me.root() ).hover( function () {
$( this ).toggleClass( 'kmui-hover' )
} );
setTimeout( function () {
$( '.kmui-modal' ).draggable( {
handle: '.kmui-modal-header'
} );
}, 100 );
},
toggle: function () {
var me = this;
return me[!me.data("isShown") ? 'show' : 'hide']();
return me[ !me.data( "isShown" ) ? 'show' : 'hide' ]();
},
show: function () {
var me = this;
me.trigger("beforeshow");
me.trigger( "beforeshow" );
if (me.data("isShown")) return;
if ( me.data( "isShown" ) ) return;
me.data("isShown", true);
me.data( "isShown", true );
me.escape();
me.backdrop(function () {
me.backdrop( function () {
me.autoCenter();
me.root()
.show()
.focus()
.trigger('aftershow');
})
.trigger( 'aftershow' );
} );
$( '.kmui-modal' ).draggable( {
handle: '.kmui-modal-header'
} );
},
showTip: function ( text ) {
$( '.kmui-modal-tip', this.root() ).html( text ).fadeIn();
},
hideTip: function ( text ) {
$( '.kmui-modal-tip', this.root() ).fadeOut( function (){
$(this).html('');
$( '.kmui-modal-tip', this.root() ).fadeOut( function () {
$( this ).html( '' );
} );
},
autoCenter: function () {
//ie6下不用处理了
!$.IE6 && this.root().css("margin-left", -(this.root().width() / 2));
!$.IE6 && this.root().css( "margin-left", -( this.root().width() / 2 ) );
},
hide: function () {
var me = this;
me.trigger("beforehide");
me.trigger( "beforehide" );
if (!me.data("isShown")) return;
if ( !me.data( "isShown" ) ) return;
me.data("isShown", false);
me.data( "isShown", false );
me.escape();
......@@ -95,61 +104,58 @@ KM.ui.define('modal', {
},
escape: function () {
var me = this;
if (me.data("isShown") && me.data("options").keyboard) {
me.root().on('keyup', function (e) {
if ( me.data( "isShown" ) && me.data( "options" ).keyboard ) {
me.root().on( 'keyup', function ( e ) {
e.which == 27 && me.hide();
})
}
else if (!me.data("isShown")) {
me.root().off('keyup');
} )
} else if ( !me.data( "isShown" ) ) {
me.root().off( 'keyup' );
}
},
hideModal: function () {
var me = this;
me.root().hide();
me.backdrop(function () {
me.backdrop( function () {
me.removeBackdrop();
me.trigger('afterhide');
})
me.trigger( 'afterhide' );
} )
},
removeBackdrop: function () {
this.$backdrop && this.$backdrop.remove();
this.$backdrop = null;
},
backdrop: function (callback) {
backdrop: function ( callback ) {
var me = this;
if (me.data("isShown") && me.data("options").backdrop) {
me.$backdrop = $('<div class="kmui-modal-backdrop" />').click(
me.data("options").backdrop == 'static' ?
$.proxy(me.root()[0].focus, me.root()[0])
: $.proxy(me.hide, me)
if ( me.data( "isShown" ) && me.data( "options" ).backdrop ) {
me.$backdrop = $( '<div class="kmui-modal-backdrop" />' ).click(
me.data( "options" ).backdrop == 'static' ?
$.proxy( me.root()[ 0 ].focus, me.root()[ 0 ] ) : $.proxy( me.hide, me )
)
}
me.trigger('afterbackdrop');
me.trigger( 'afterbackdrop' );
callback && callback();
},
attachTo: function ($obj) {
attachTo: function ( $obj ) {
var me = this
if (!$obj.data('$mergeObj')) {
if ( !$obj.data( '$mergeObj' ) ) {
$obj.data('$mergeObj', me.root());
$obj.on('click', function () {
me.toggle($obj)
});
me.data('$mergeObj', $obj)
$obj.data( '$mergeObj', me.root() );
$obj.on( 'click', function () {
me.toggle( $obj )
} );
me.data( '$mergeObj', $obj )
}
},
ok: function () {
var me = this;
me.trigger('beforeok');
if (me.trigger("ok", me) === false) {
me.trigger( 'beforeok' );
if ( me.trigger( "ok", me ) === false ) {
return;
}
me.hide();
},
getBodyContainer: function () {
return this.root().find('.kmui-modal-body')
return this.root().find( '.kmui-modal-body' )
}
});
} );
\ No newline at end of file
.kmui-modal-header .kmui-title{
font-size: 14px;
}
.kmui-dialog-markers-body {
padding-bottom: 5px
}
.icon-list{
margin: 0;
padding: 0
}
.icon-list li{
padding: 5px 10px;
margin: 0;
list-style: none;
cursor: pointer;
color: #333;
font-family:Arial, "Heiti SC", "Microsoft Yahei";
}
.icon-list li:hover,.icon-list li.active{
background: #cfe0f7
}
.icon-list li span.icon{
display: inline-block;
width: 20px;
height: 20px;
vertical-align: middle;
margin-right: 10px;
}
\ No newline at end of file
......@@ -17,3 +17,15 @@
.kmui-btn-toolbar .kmui-btn .kmui-icon-hand {
background: url(../images/hand.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-markers {
background: url(../images/flag.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-clock {
background: url(../images/clock.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-zoom-in {
background: url(../images/zoom_in.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-zoom-out {
background: url(../images/zoom_out.png) no-repeat 2px 2px;
}
\ No newline at end of file
.kmui-modal {
position: fixed;
_position: absolute;
top: 10%;
left: 50%;
border: 1px solid #acacac;
box-shadow: 2px 2px 5px #d3d6da;
top: 10px;
right:10px;
background-color: #ffffff;
outline: 0;
border-radius: 5px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
}
.kmui-modal-header {
padding: 5px 10px;
border-bottom: 1px solid #eee;
cursor: move;
}
.kmui-modal-header .kmui-close {
float: right;
......
/*图片上传*/
.kmui-dialog-image-body {
width: 700px;
height: 400px;
}
/*插入视频*/
.kmui-dialog-video-body{
width: 600px;
height: 350px;
}
/*谷歌地图*/
.kmui-dialog-gmap-body{
width:550px;
height: 400px;
}
/*百度地图*/
.kmui-dialog-map-body{
width:580px;
height: 400px;
}
/*链接*/
.kmui-dialog-link-body{
width:400px;
height:200px;
}
\ No newline at end of file
......@@ -11,3 +11,4 @@
@import "tooltip.css";
@import "colorpicker.css";
@import "separator.css";
@import "markers.css";
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