Commit 60602081 authored by Akikonata's avatar Akikonata

layout

parent 7497dff9
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
}, lang)); }, lang));
} }
this.root().html(html); this.root().html(html);
var valPri = km.queryCommandValue("priority"); var valPri = km.queryCommandValue("priority") || 0;
var valPro = km.queryCommandValue("progress"); var valPro = km.queryCommandValue("progress") || 0;
$w.find("li[type='priority']").removeClass("active"); $w.find("li[type='priority']").removeClass("active");
$w.find("li[type='priority'][value='" + valPri + "']").addClass("active"); $w.find("li[type='priority'][value='" + valPri + "']").addClass("active");
$w.find("li[type='progress']").removeClass("active"); $w.find("li[type='progress']").removeClass("active");
......
( function () { (function () {
function getKMBasePath( docUrl, confUrl ) { 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() { 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; 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; 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, tmp = null,
res = []; 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(); res.pop();
} else if ( tmp !== "." ) { } else if (tmp !== ".") {
res.push( tmp ); res.push(tmp);
} }
} }
return protocol + res.join( "/" ); return protocol + res.join("/");
} }
window.KITYMINDER_CONFIG = { window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ 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 //只读模式,默认是false
//readOnly: true //readOnly: true
...@@ -95,4 +95,4 @@ ...@@ -95,4 +95,4 @@
//,maxImageHeight: 200 //,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, var me = this,
label = me.getLang( 'tooltips.' + name ), label = me.getLang('tooltips.' + name),
options = { options = {
label: label, label: label,
title: label, title: label,
...@@ -13,54 +12,55 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -13,54 +12,55 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
enabledRecord: false enabledRecord: false
}, },
$combox = null; $combox = null;
if ( options.items.length == 0 ) { if (options.items.length == 0) {
return null; return null;
} }
utils.each( options.items, function ( i, item ) { utils.each(options.items, function (i, item) {
options.items[ i ] = me.getLang( 'layout' )[ 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(); var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on('comboboxselect', function (evt, res) {
me.execCommand( name, res.value ); me.execCommand(name, res.value);
} ).on( "beforeshow", function () { me.initStyle();
if ( $combox.parent().length === 0 ) { }).on("beforeshow", function () {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) ); if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
} }
} ); });
//状态反射 //状态反射
me.on( 'interactchange', function () { me.on('interactchange', function () {
var state = this.queryCommandState( name ), var state = this.queryCommandState(name),
value = this.queryCommandValue( 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 //设置label
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ ); value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
comboboxWidget.selectItemByLabel( value ); comboboxWidget.selectItemByLabel(value);
} }
} ); });
var data = []; var data = [];
utils.each( me.getLayoutStyleItems(), function ( i, v ) { utils.each(me.getLayoutStyleItems(), function (i, v) {
data.push( { data.push({
label: me.getLang( 'tooltips.' + name ) + ' ' + v, label: me.getLang('tooltips.' + name) + ' ' + v,
cmdName: 'switchlayout', cmdName: 'switchlayout',
exec: function () { exec: function () {
me.execCommand( 'switchlayout', v ); me.execCommand('switchlayout', v);
} }
} ) })
} ); });
data.push( { data.push({
divider: 1 divider: 1
} ); });
me.addContextmenu( data ); me.addContextmenu(data);
return comboboxWidget.button().addClass( 'kmui-combobox' ); return comboboxWidget.button().addClass('kmui-combobox');
} ); });
\ No newline at end of file \ 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