Commit 60602081 authored by Akikonata's avatar Akikonata

layout

parent 7497dff9
......@@ -49,8 +49,8 @@
}, lang));
}
this.root().html(html);
var valPri = km.queryCommandValue("priority");
var valPro = km.queryCommandValue("progress");
var valPri = km.queryCommandValue("priority") || 0;
var valPro = km.queryCommandValue("progress") || 0;
$w.find("li[type='priority']").removeClass("active");
$w.find("li[type='priority'][value='" + valPri + "']").addClass("active");
$w.find("li[type='progress']").removeClass("active");
......
( function () {
function getKMBasePath( docUrl, confUrl ) {
(function () {
function getKMBasePath(docUrl, confUrl) {
return getBasePath( docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath() );
return getBasePath(docUrl || self.document.URL || self.location.href, confUrl || getConfigFilePath());
}
function getConfigFilePath() {
var configPath = document.getElementsByTagName( 'script' );
var configPath = document.getElementsByTagName('script');
return configPath[ configPath.length - 1 ].src;
return configPath[configPath.length - 1].src;
}
function getBasePath( docUrl, confUrl ) {
function getBasePath(docUrl, confUrl) {
var basePath = confUrl;
if ( /^(\/|\\\\)/.test( confUrl ) ) {
if (/^(\/|\\\\)/.test(confUrl)) {
basePath = /^.+?\w(\/|\\\\)/.exec( docUrl )[ 0 ] + confUrl.replace( /^(\/|\\\\)/, '' );
basePath = /^.+?\w(\/|\\\\)/.exec(docUrl)[0] + confUrl.replace(/^(\/|\\\\)/, '');
} else if ( !/^[a-z]+:/i.test( confUrl ) ) {
} else if (!/^[a-z]+:/i.test(confUrl)) {
docUrl = docUrl.split( "#" )[ 0 ].split( "?" )[ 0 ].replace( /[^\\\/]+$/, '' );
docUrl = docUrl.split("#")[0].split("?")[0].replace(/[^\\\/]+$/, '');
basePath = docUrl + "" + confUrl;
}
return optimizationPath( basePath );
return optimizationPath(basePath);
}
function optimizationPath( path ) {
function optimizationPath(path) {
var protocol = /^[a-z]+:\/\//.exec( path )[ 0 ],
var protocol = /^[a-z]+:\/\//.exec(path)[0],
tmp = null,
res = [];
path = path.replace( protocol, "" ).split( "?" )[ 0 ].split( "#" )[ 0 ];
path = path.replace(protocol, "").split("?")[0].split("#")[0];
path = path.replace( /\\/g, '/' ).split( /\// );
path = path.replace(/\\/g, '/').split(/\//);
path[ path.length - 1 ] = "";
path[path.length - 1] = "";
while ( path.length ) {
while (path.length) {
if ( ( tmp = path.shift() ) === ".." ) {
if ((tmp = path.shift()) === "..") {
res.pop();
} else if ( tmp !== "." ) {
res.push( tmp );
} else if (tmp !== ".") {
res.push(tmp);
}
}
return protocol + res.join( "/" );
return protocol + res.join("/");
}
window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
toolbars: [
'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink image removeimage | markers resource | node | help'
'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | switchlayout | hyperlink unhyperlink image removeimage | markers resource | node | help'
]
//只读模式,默认是false
//readOnly: true
......@@ -95,4 +95,4 @@
//,maxImageHeight: 200
//
};
} )();
\ No newline at end of file
})();
\ No newline at end of file
KM.registerToolbarUI( 'switchlayout', function ( name ) {
KM.registerToolbarUI('switchlayout', function (name) {
var me = this,
label = me.getLang( 'tooltips.' + name ),
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
......@@ -13,54 +12,55 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
enabledRecord: false
},
$combox = null;
if ( options.items.length == 0 ) {
if (options.items.length == 0) {
return null;
}
utils.each( options.items, function ( i, item ) {
options.items[ i ] = me.getLang( 'layout' )[ item ];
} );
utils.each(options.items, function (i, item) {
options.items[i] = me.getLang('layout')[item];
});
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
comboboxWidget.on('comboboxselect', function (evt, res) {
me.execCommand(name, res.value);
me.initStyle();
}).on("beforeshow", function () {
if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
}
} );
});
//状态反射
me.on( 'interactchange', function () {
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
me.on('interactchange', function () {
var state = this.queryCommandState(name),
value = this.queryCommandValue(name);
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
if ( value ) {
if (value) {
//设置label
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value );
value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
comboboxWidget.selectItemByLabel(value);
}
} );
});
var data = [];
utils.each( me.getLayoutStyleItems(), function ( i, v ) {
data.push( {
label: me.getLang( 'tooltips.' + name ) + ' ' + v,
utils.each(me.getLayoutStyleItems(), function (i, v) {
data.push({
label: me.getLang('tooltips.' + name) + ' ' + v,
cmdName: 'switchlayout',
exec: function () {
me.execCommand( 'switchlayout', v );
me.execCommand('switchlayout', v);
}
} )
} );
data.push( {
})
});
data.push({
divider: 1
} );
me.addContextmenu( data );
return comboboxWidget.button().addClass( 'kmui-combobox' );
} );
\ No newline at end of file
});
me.addContextmenu(data);
return comboboxWidget.button().addClass('kmui-combobox');
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
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