Commit 6fc4cef2 authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

parents 6017618e 09315d6f
.priority .icon {background:url(../dialogs/icons/iconpriority.png) 0 0}
.progress .icon{background:url(../dialogs/icons/iconprogress.png) 0 0}
.icon.p2{background-position: -20px 0}
.icon.p3{background-position: -40px 0}
.icon.p4{background-position: -60px 0}
.icon.p5{background-position: -80px 0}
\ No newline at end of file
( function () {
var helpContent = '<div class="help-content" style="padding:20px;width:360px;">';
helpContent += '<h2>基本操作</h2>';
helpContent += '<p>编辑脑图的时候,最基本的操作是插入节点、编辑节点、删除节点、设置节点样式</p>';
helpContent += '<ul>';
helpContent += ' <li><h3>插入子节点:</h3>在选中的节点中按 Tab 键</li>';
helpContent += ' <li><h3>插入同级节点:</h3>在选中的节点中按 Enter/Return 键</li>';
helpContent += ' <li><h3>编辑节点:</h3>刚插入的子节点和同级节点会进入编辑模式;其他节点双击也能进入编辑模式;编辑模式下可以编辑节点的文本</li>';
helpContent += ' <li><h3>设置节点样式:</h3>你可以选中一个或多个节点后,在工具栏中改变选中节点的样式。也可以使用快捷键来使用这些功能:撤销(Ctrl+Z)、重做(Ctrl+Y)、加粗(Ctrl+B)、斜体(Ctrl+I)</li>';
helpContent += '</ul>';
helpContent += '<h2>导入导出</h2>';
helpContent += '<p>您可以导出你的脑图到本地,方法是点击工具栏上的导出按钮,然后选择要导出的格式。下面列出支持的格式列表:</p>';
helpContent += '<ul>';
helpContent += ' <li><h3>大纲文本:</h3>导出成以制表符界定大纲的文本,此格式可以被导入</li>';
helpContent += ' <li><h3>KityMinder格式:</h3>KityMinder自身的保存格式(JSON),此格式可以被导入</li>';
helpContent += ' <li><h3>PNG 图片:</h3>导出成 PNG 位图格式,此格式不可被导入</li>';
helpContent += ' <li><h3>SVG 矢量图:</h3>导出成 SVG 矢量图格式,可以被矢量工具二次加工,此格式不可被导入</li>';
helpContent += '</ul>';
helpContent += '<p>导出的文件可以直接拖放到 KityMinder 上直接打开</p>';
helpContent += '<h2>云盘功能</h2>';
helpContent += '<p>使用百度账号登录后,您可以使用云存储和分享功能</p>';
helpContent += '<ul>';
helpContent += ' <li><h3>登录:</h3>点击登录按钮</li>';
helpContent += ' <li><h3>保存(CTRL+S):</h3>点击保存按钮,将会把文件保存到你的云盘里</li>';
helpContent += ' <li><h3>分享(CTRL+SHIFT+S):</h3>点击分享按钮,会生成分享链接,该链接可以打开您分享的脑图</li>';
helpContent += ' <li><h3>打开:</h3>点击您账号的下拉按钮,会列出最近保存的脑图文件,点击即可打开</li>';
helpContent += '</ul>';
helpContent += '<h2>视野导航</h2>';
helpContent += '<p>视野导航包括以下几个功能:</p>';
helpContent += '<ul>';
helpContent += ' <li><h3>视野拖动:</h3>根节点未被选中的情况下,拖动根节点可以拖动视野;或者使用空格键切换拖动状态</li>';
helpContent += ' <li><h3>视野缩放:</h3>点击工具栏中的“放大”和“缩小”按钮可以缩放视野,或者按着 Ctrl 键使用滚轮缩放</li>';
helpContent += ' <li><h3>视野复位:</h3>双击空白处,可以将视野复位</li>';
helpContent += '</ul>';
helpContent += '</div>';
KM.registerWidget( 'help', {
tpl: helpContent,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.help' ),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
initEvent: function ( km, $w ) {},
width: 400
} );
} )();
\ No newline at end of file
( function () {
var utils = KM.utils;
KM.registerWidget( 'markers', {
tpl: "<ul class='icon-list priority'>" +
"<li value='1' type='priority'><span class='icon p1'></span><span><%= priority %>1</span></li>" +
"<li value='2' type='priority'><span class='icon p2'></span><span><%= priority %>2</span></li>" +
"<li value='3' type='priority'><span class='icon p3'></span><span><%= priority %>3</span></li>" +
"<li value='4' type='priority'><span class='icon p4'></span><span><%= priority %>4</span></li>" +
"<li value='5' type='priority'><span class='icon p5'></span><span><%= priority %>5</span></li>" +
"</ul>" +
"<ul class='icon-list progress'>" +
"<li value='1' type='progress'><span class='icon p1'></span><span><%= progress.notdone %></span></li>" +
"<li value='2' type='progress'><span class='icon p2'></span><span><%= progress.quarterdone %></span></li>" +
"<li value='3' type='progress'><span class='icon p3'></span><span><%= progress.halfdone %></span></li>" +
"<li value='4' type='progress'><span class='icon p4'></span><span><%= progress.threequartersdone %></span></li>" +
"<li value='5' type='progress'><span class='icon p5'></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
( function () {
//todo 这里先写死成中文
var preferenceContent = '<div class="help-content" style="padding:20px;width:360px;">';
preferenceContent += '<h3>展开属性设置</h3>';
preferenceContent += '<p><label><input type="checkbox" name="expand" />是否全部展开</label></p>';
preferenceContent += '</div>';
//todo 偏好设置暂时都在这里处理
function execExpand(km,$w){
var checked = $w.find('[name=expand]').checked();
if(checked){
}
}
KM.registerWidget( 'preference', {
tpl: preferenceContent,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.help' ),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
initEvent: function ( km, $w ) {
$w.on( 'click', '.kmui-close', function ( e ) {
km.fire('preferenceschange')
} );
},
width: 400
} );
} )();
\ No newline at end of file
/*! /*!
* ==================================================== * ====================================================
* kityminder - v1.0.0 - 2014-04-15 * kityminder - v1.0.0 - 2014-05-07
* https://github.com/fex-team/kityminder * https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git * GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT * Copyright (c) 2014 f-cube @ FEX; Licensed MIT
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
var KityMinder = window.KM = window.KityMinder = function () { var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0; var instanceMap = {}, instanceId = 0;
return { return {
version: '1.1.1', version: '1.1.3',
createMinder: function ( renderTarget, options ) { createMinder: function ( renderTarget, options ) {
options = options || {}; options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget; options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
...@@ -378,11 +378,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -378,11 +378,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
this.rc = new kity.Group(); this.rc = new kity.Group();
this.rc.addClass( 'km-minderNode' ); this.rc.addClass( 'km-minderNode' );
this.rc.minderNode = this; this.rc.minderNode = this;
this._createBgGroup(); this._createBgGroup();
this._createContGroup(); this._createContGroup();
this._createIconShape();
this._createTextShape();
}, },
_createGroup: function ( type ) { _createGroup: function ( type ) {
var g = new kity.Group(); var g = new kity.Group();
...@@ -395,16 +392,6 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -395,16 +392,6 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
_createContGroup: function () { _createContGroup: function () {
this._createGroup( 'contrc' ); this._createGroup( 'contrc' );
}, },
_createTextShape: function () {
var textShape = new kity.Text( this.getData( 'text' ) || '' );
textShape.setAttr( '_nodeTextShape', true );
this.getContRc().appendShape( textShape );
},
_createIconShape: function () {
var g = new kity.Group();
this.getContRc().appendShape( g );
this._iconRc = g;
},
getContRc: function () { getContRc: function () {
var groups = this.rc.getShapesByType( 'group' ), var groups = this.rc.getShapesByType( 'group' ),
result; result;
...@@ -427,9 +414,6 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -427,9 +414,6 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
} ); } );
return result; return result;
}, },
getIconRc: function () {
return this._iconRc;
},
setPoint: function ( x, y ) { setPoint: function ( x, y ) {
if ( arguments.length < 2 ) { if ( arguments.length < 2 ) {
this.setData( "point", x ); this.setData( "point", x );
...@@ -676,6 +660,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", { ...@@ -676,6 +660,8 @@ var MinderNode = KityMinder.MinderNode = kity.createClass( "MinderNode", {
return false; return false;
} }
} ); } );
if(textShape === undefined)
debugger
return textShape; return textShape;
}, },
isSelected: function () { isSelected: function () {
...@@ -798,16 +784,31 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -798,16 +784,31 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this.fire( 'ready' ); this.fire( 'ready' );
}, },
getOptions: function ( key ) { getOptions: function ( key ) {
return this._options[ key ]; var val;
if(key){
val = this.getPreferences(key);
return val === null || val === undefined ? this._options[ key ] : val;
}else{
val = this.getPreferences();
if(val){
return utils.extend(val,this._options,true)
}else{
return this._options;
}
}
}, },
setDefaultOptions: function ( key, val ) { setDefaultOptions: function ( key, val,cover) {
var obj = {}; var obj = {};
if ( Utils.isString( key ) ) { if ( Utils.isString( key ) ) {
obj[ key ] = val; obj[ key ] = val;
} else { } else {
obj = key; obj = key;
} }
utils.extend( this._options, obj, true ); utils.extend( this._options, obj, !cover );
},
setOptions: function ( key, val ) {
this.setPreferences(key,val)
}, },
_initMinder: function () { _initMinder: function () {
...@@ -823,6 +824,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -823,6 +824,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._root.setType( "root" ); this._root.setType( "root" );
if ( this._options.renderTo ) { if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo ); this.renderTo( this._options.renderTo );
//this._paper.setStyle( 'font-family', 'Arial,"Microsoft YaHei",sans-serif' );
} }
}, },
_addRenderContainer: function () { _addRenderContainer: function () {
...@@ -1045,7 +1047,7 @@ function importNode( node, json, km ) { ...@@ -1045,7 +1047,7 @@ function importNode( node, json, km ) {
for ( var field in data ) { for ( var field in data ) {
node.setData( field, data[ field ] ); node.setData( field, data[ field ] );
} }
node.setText( data.text || km.getLang( DEFAULT_TEXT[ node.getType() ] ) ); node.setData( 'text',data.text || km.getLang( DEFAULT_TEXT[ node.getType() ] ) );
var childrenTreeData = json.children; var childrenTreeData = json.children;
if ( !childrenTreeData ) return; if ( !childrenTreeData ) return;
...@@ -1057,6 +1059,7 @@ function importNode( node, json, km ) { ...@@ -1057,6 +1059,7 @@ function importNode( node, json, km ) {
return node; return node;
} }
// 导入导出 // 导入导出
kity.extendClass( Minder, { kity.extendClass( Minder, {
exportData: function ( protocalName ) { exportData: function ( protocalName ) {
...@@ -1064,6 +1067,13 @@ kity.extendClass( Minder, { ...@@ -1064,6 +1067,13 @@ kity.extendClass( Minder, {
json = exportNode( this.getRoot() ); json = exportNode( this.getRoot() );
protocal = KityMinder.findProtocal( protocalName ); protocal = KityMinder.findProtocal( protocalName );
if(this._fire( new MinderEvent( 'beforeexport', {
json:json,
protocalName: protocalName,
protocal: protocal
},true ) ) === true) return;
if ( protocal ) { if ( protocal ) {
return protocal.encode( json, this ); return protocal.encode( json, this );
} else { } else {
...@@ -1100,15 +1110,47 @@ kity.extendClass( Minder, { ...@@ -1100,15 +1110,47 @@ kity.extendClass( Minder, {
var stoped = this._fire( new MinderEvent( 'beforeimport', params, true ) ); var stoped = this._fire( new MinderEvent( 'beforeimport', params, true ) );
if ( stoped ) return this; if ( stoped ) return this;
//*******************
function ts(d, str, last){
var h = d.getHours(),
m = d.getMinutes(),
s = d.getSeconds(),
ms = d.getMilliseconds();
if(last){
console.log('--- '+str+': '+(d-last)+' ---');
}else{
console.log('--- '+str+' ---');
}
return d;
}
var t1 = ts(new Date(), '开始解析');
//*******************
json = params.json || ( params.json = protocal.decode( local ) ); json = params.json || ( params.json = protocal.decode( local ) );
if ( typeof json === 'object' && 'then' in json ) { if ( typeof json === 'object' && 'then' in json ) {
var self = this; var self = this;
json.then( local, function ( data ) { json.then( local, function ( data ) {
//*******************
var t2 = ts(new Date(), '解压解析耗时', t1);
//*******************
self._afterImportData( data, params ); self._afterImportData( data, params );
//*******************
ts(new Date(), '渲染耗时', t2);
//*******************
} ); } );
} else { } else {
//*******************
var t2 = ts(new Date(), '解压解析耗时', t1);
//*******************
this._afterImportData( json, params ); this._afterImportData( json, params );
//*******************
ts(new Date(), '渲染耗时', t2);
//*******************
} }
return this; return this;
}, },
...@@ -1154,6 +1196,7 @@ kity.extendClass( Minder, { ...@@ -1154,6 +1196,7 @@ kity.extendClass( Minder, {
this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend', this._firePharse.bind( this ) ); this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend', this._firePharse.bind( this ) );
if ( window ) { if ( window ) {
window.addEventListener( 'resize', this._firePharse.bind( this ) ); window.addEventListener( 'resize', this._firePharse.bind( this ) );
window.addEventListener( 'blur', this._firePharse.bind( this ) );
} }
}, },
_bindKeyboardEvents: function () { _bindKeyboardEvents: function () {
...@@ -1441,9 +1484,10 @@ kity.extendClass( Minder, { ...@@ -1441,9 +1484,10 @@ kity.extendClass( Minder, {
}, },
handelNodeInsert: function ( node ) { handelNodeInsert: function ( node ) {
var rc = this._rc; var rc = this._rc;
node.traverse( function ( current ) { // node.traverse( function ( current ) {
rc.addShape( current.getRenderContainer() ); // rc.addShape( current.getRenderContainer() );
} ); // } );
rc.addShape( node.getRenderContainer() );
}, },
handelNodeRemove: function ( node ) { handelNodeRemove: function ( node ) {
var rc = this._rc; var rc = this._rc;
...@@ -1462,7 +1506,7 @@ kity.extendClass( Minder, { ...@@ -1462,7 +1506,7 @@ kity.extendClass( Minder, {
km.renderNode( nodes ); km.renderNode( nodes );
} }
}, },
getMinderTitle: function() { getMinderTitle: function () {
return this.getRoot().getText(); return this.getRoot().getText();
} }
...@@ -1473,41 +1517,45 @@ var keymap = KityMinder.keymap = { ...@@ -1473,41 +1517,45 @@ var keymap = KityMinder.keymap = {
'Tab' : 9, 'Tab' : 9,
'Enter' : 13, 'Enter' : 13,
'Shift':16, 'Shift' : 16,
'Control':17, 'Control' : 17,
'Alt':18, 'Alt' : 18,
'CapsLock':20, 'CapsLock' : 20,
'Esc': 27,
'Esc':27, 'Spacebar' : 32,
'Spacebar':32, 'PageUp' : 33,
'PageDown' : 34,
'End' : 35,
'Home' : 36,
'PageUp':33, 'Left' : 37,
'PageDown':34, 'Up' : 38,
'End':35, 'Right' : 39,
'Home':36, 'Down' : 40,
'Left':37, 'Insert' : 45,
'Up':38,
'Right':39,
'Down':40,
'Insert':45, 'Del' : 46,
'Del':46, 'NumLock' : 144,
'NumLock':144, 'Cmd' : 91,
'Cmd':91, 'F2' : 113,
'F3' : 114,
'F4' : 115,
'=':187, '=' : 187,
'-':189, '-' : 189,
"b":66, "b" : 66,
'i':73, 'i' : 73,
//回退 //回退
'z':90, 'z' : 90,
'y':89, 'y' : 89,
//粘贴 //粘贴
'v' : 86, 'v' : 86,
'x' : 88, 'x' : 88,
...@@ -1541,6 +1589,336 @@ KM.defaultOptions = { ...@@ -1541,6 +1589,336 @@ KM.defaultOptions = {
readyOnly:false readyOnly:false
}; };
kity.extendClass( Minder, function(){
var ROOTKEY = 'kityminder_preference';
//创建存储机制
var LocalStorage = ( function () {
var storage = window.localStorage,
LOCAL_FILE = "localStorage";
return {
saveLocalData: function ( key, data ) {
if ( storage && data) {
storage.setItem( key, data );
return true;
}
return false;
},
getLocalData: function ( key ) {
if ( storage ) {
return storage.getItem( key );
}
return null;
},
removeItem: function ( key ) {
storage && storage.removeItem( key );
}
};
} )();
return {
setPreferences:function(key,value){
var obj = {};
if ( Utils.isString( key ) ) {
obj[ key ] = value;
} else {
obj = key;
}
var data = LocalStorage.getLocalData(ROOTKEY);
if(data){
data = JSON.parse(data);
utils.extend(data, obj);
}else{
data = obj;
}
LocalStorage.saveLocalData(ROOTKEY,JSON.stringify(data));
},
getPreferences:function(key){
var data = LocalStorage.getLocalData(ROOTKEY);
if(data){
data = JSON.parse(data);
return key ? data[key] : data
}
return null;
},
resetPreferences:function(pres){
var str = pres ? JSON.stringify(pres) : '';
LocalStorage.saveLocalData(str)
}
}
}() );
/**
* 浏览器判断模块
* @file
* @module UE.browser
* @since 1.2.6.1
*/
/**
* 提供浏览器检测的模块
* @unfile
* @module KM.browser
*/
var browser = KityMinder.browser = function(){
var agent = navigator.userAgent.toLowerCase(),
opera = window.opera,
browser = {
/**
* @property {boolean} ie 检测当前浏览器是否为IE
* @example
* ```javascript
* if ( UE.browser.ie ) {
* console.log( '当前浏览器是IE' );
* }
* ```
*/
ie : /(msie\s|trident.*rv:)([\w.]+)/.test(agent),
/**
* @property {boolean} opera 检测当前浏览器是否为Opera
* @example
* ```javascript
* if ( UE.browser.opera ) {
* console.log( '当前浏览器是Opera' );
* }
* ```
*/
opera : ( !!opera && opera.version ),
/**
* @property {boolean} webkit 检测当前浏览器是否是webkit内核的浏览器
* @example
* ```javascript
* if ( UE.browser.webkit ) {
* console.log( '当前浏览器是webkit内核浏览器' );
* }
* ```
*/
webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ),
/**
* @property {boolean} mac 检测当前浏览器是否是运行在mac平台下
* @example
* ```javascript
* if ( UE.browser.mac ) {
* console.log( '当前浏览器运行在mac平台下' );
* }
* ```
*/
mac : ( agent.indexOf( 'macintosh' ) > -1 ),
/**
* @property {boolean} quirks 检测当前浏览器是否处于“怪异模式”下
* @example
* ```javascript
* if ( UE.browser.quirks ) {
* console.log( '当前浏览器运行处于“怪异模式”' );
* }
* ```
*/
quirks : ( document.compatMode == 'BackCompat' )
};
/**
* @property {boolean} gecko 检测当前浏览器内核是否是gecko内核
* @example
* ```javascript
* if ( UE.browser.gecko ) {
* console.log( '当前浏览器内核是gecko内核' );
* }
* ```
*/
browser.gecko =( navigator.product == 'Gecko' && !browser.webkit && !browser.opera && !browser.ie);
var version = 0;
// Internet Explorer 6.0+
if ( browser.ie ){
var v1 = agent.match(/(?:msie\s([\w.]+))/);
var v2 = agent.match(/(?:trident.*rv:([\w.]+))/);
if(v1 && v2 && v1[1] && v2[1]){
version = Math.max(v1[1]*1,v2[1]*1);
}else if(v1 && v1[1]){
version = v1[1]*1;
}else if(v2 && v2[1]){
version = v2[1]*1;
}else{
version = 0;
}
browser.ie11Compat = document.documentMode == 11;
/**
* @property { boolean } ie9Compat 检测浏览器模式是否为 IE9 兼容模式
* @warning 如果浏览器不是IE, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.ie9Compat ) {
* console.log( '当前浏览器运行在IE9兼容模式下' );
* }
* ```
*/
browser.ie9Compat = document.documentMode == 9;
/**
* @property { boolean } ie8 检测浏览器是否是IE8浏览器
* @warning 如果浏览器不是IE, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.ie8 ) {
* console.log( '当前浏览器是IE8浏览器' );
* }
* ```
*/
browser.ie8 = !!document.documentMode;
/**
* @property { boolean } ie8Compat 检测浏览器模式是否为 IE8 兼容模式
* @warning 如果浏览器不是IE, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.ie8Compat ) {
* console.log( '当前浏览器运行在IE8兼容模式下' );
* }
* ```
*/
browser.ie8Compat = document.documentMode == 8;
/**
* @property { boolean } ie7Compat 检测浏览器模式是否为 IE7 兼容模式
* @warning 如果浏览器不是IE, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.ie7Compat ) {
* console.log( '当前浏览器运行在IE7兼容模式下' );
* }
* ```
*/
browser.ie7Compat = ( ( version == 7 && !document.documentMode )
|| document.documentMode == 7 );
/**
* @property { boolean } ie6Compat 检测浏览器模式是否为 IE6 模式 或者怪异模式
* @warning 如果浏览器不是IE, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.ie6Compat ) {
* console.log( '当前浏览器运行在IE6模式或者怪异模式下' );
* }
* ```
*/
browser.ie6Compat = ( version < 7 || browser.quirks );
browser.ie9above = version > 8;
browser.ie9below = version < 9;
}
// Gecko.
if ( browser.gecko ){
var geckoRelease = agent.match( /rv:([\d\.]+)/ );
if ( geckoRelease )
{
geckoRelease = geckoRelease[1].split( '.' );
version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1;
}
}
/**
* @property { Number } chrome 检测当前浏览器是否为Chrome, 如果是,则返回Chrome的大版本号
* @warning 如果浏览器不是chrome, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.chrome ) {
* console.log( '当前浏览器是Chrome' );
* }
* ```
*/
if (/chrome\/(\d+\.\d)/i.test(agent)) {
browser.chrome = + RegExp['\x241'];
}
/**
* @property { Number } safari 检测当前浏览器是否为Safari, 如果是,则返回Safari的大版本号
* @warning 如果浏览器不是safari, 则该值为undefined
* @example
* ```javascript
* if ( UE.browser.safari ) {
* console.log( '当前浏览器是Safari' );
* }
* ```
*/
if(/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(agent) && !/chrome/i.test(agent)){
browser.safari = + (RegExp['\x241'] || RegExp['\x242']);
}
// Opera 9.50+
if ( browser.opera )
version = parseFloat( opera.version() );
// WebKit 522+ (Safari 3+)
if ( browser.webkit )
version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] );
/**
* @property { Number } version 检测当前浏览器版本号
* @remind
* <ul>
* <li>IE系列返回值为5,6,7,8,9,10等</li>
* <li>gecko系列会返回10900,158900等</li>
* <li>webkit系列会返回其build号 (如 522等)</li>
* </ul>
* @example
* ```javascript
* console.log( '当前浏览器版本号是: ' + UE.browser.version );
* ```
*/
browser.version = version;
/**
* @property { boolean } isCompatible 检测当前浏览器是否能够与UEditor良好兼容
* @example
* ```javascript
* if ( UE.browser.isCompatible ) {
* console.log( '浏览器与UEditor能够良好兼容' );
* }
* ```
*/
browser.isCompatible =
!browser.mobile && (
( browser.ie && version >= 6 ) ||
( browser.gecko && version >= 10801 ) ||
( browser.opera && version >= 9.5 ) ||
( browser.air && version >= 1 ) ||
( browser.webkit && version >= 522 ) ||
false );
return browser;
}();
//快捷方式
var ie = browser.ie,
webkit = browser.webkit,
gecko = browser.gecko,
opera = browser.opera;
KityMinder.Geometry = ( function () { KityMinder.Geometry = ( function () {
var g = {}; var g = {};
var min = Math.min, var min = Math.min,
...@@ -1713,8 +2091,8 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -1713,8 +2091,8 @@ KityMinder.registerModule( "HistoryModule", function () {
this.km.initStyle(); this.km.initStyle();
this.update(); this.update();
this.km.fire('restoreScene'); this.km.fire( 'restoreScene' );
this.km.fire('contentChange'); this.km.fire( 'contentChange' );
}, },
getScene: function () { getScene: function () {
return new Scene( this.km.getRoot() ) return new Scene( this.km.getRoot() )
...@@ -1750,8 +2128,18 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -1750,8 +2128,18 @@ KityMinder.registerModule( "HistoryModule", function () {
this.historyManager = new HistoryManager( this ); this.historyManager = new HistoryManager( this );
var keys = { var keys = {
/*Shift*/ 16:1, /*Ctrl*/ 17:1, /*Alt*/ 18:1,/*Command*/91:1, /*Shift*/
37:1, 38:1, 39:1, 40:1 16: 1,
/*Ctrl*/
17: 1,
/*Alt*/
18: 1,
/*Command*/
91: 1,
37: 1,
38: 1,
39: 1,
40: 1
}, },
keycont = 0, keycont = 0,
lastKeyCode, lastKeyCode,
...@@ -1759,7 +2147,7 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -1759,7 +2147,7 @@ KityMinder.registerModule( "HistoryModule", function () {
return { return {
defaultOptions: { defaultOptions: {
maxUndoCount: 20, maxUndoCount: 20,
maxInputCount:20 maxInputCount: 20
}, },
"commands": { "commands": {
"undo": kity.createClass( "UndoCommand", { "undo": kity.createClass( "UndoCommand", {
...@@ -1800,36 +2188,36 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -1800,36 +2188,36 @@ KityMinder.registerModule( "HistoryModule", function () {
"saveScene": function ( e ) { "saveScene": function ( e ) {
this.historyManager.saveScene(); this.historyManager.saveScene();
}, },
"renderNode":function(e){ "renderNode": function ( e ) {
var node = e.node; var node = e.node;
if(node.isHighlight()){ if ( node.isHighlight() ) {
km.select(node); km.select( node );
} }
}, },
"keydown":function(e){ "keydown": function ( e ) {
var orgEvt = e.originEvent; var orgEvt = e.originEvent;
var keyCode = orgEvt.keyCode || orgEvt.which; var keyCode = orgEvt.keyCode || orgEvt.which;
if (!keys[keyCode] && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey) { if ( !keys[ keyCode ] && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey ) {
if (km.historyManager.list.length == 0) { if ( km.historyManager.list.length == 0 ) {
km.historyManager.saveScene(); km.historyManager.saveScene();
} }
clearTimeout(saveSceneTimer); clearTimeout( saveSceneTimer );
saveSceneTimer = setTimeout(function(){ saveSceneTimer = setTimeout( function () {
km.historyManager.saveScene(); km.historyManager.saveScene();
},200); }, 200 );
lastKeyCode = keyCode; lastKeyCode = keyCode;
keycont++; keycont++;
if (keycont >= km.getOptions('maxInputCount') ) { if ( keycont >= km.getOptions( 'maxInputCount' ) ) {
km.historyManager.saveScene() km.historyManager.saveScene()
} }
} }
}, },
"import":function(){ "import": function () {
this.historyManager.reset() this.historyManager.reset()
} }
} }
...@@ -1837,17 +2225,22 @@ KityMinder.registerModule( "HistoryModule", function () { ...@@ -1837,17 +2225,22 @@ KityMinder.registerModule( "HistoryModule", function () {
} ); } );
KityMinder.registerModule( "IconModule", function () { KityMinder.registerModule( "IconModule", function () {
var minder = this;
var renderPriorityIcon = function ( node, val ) { var renderPriorityIcon = function ( node, val ) {
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ]; var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 ); 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 _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 );
var _rc = new kity.Group(); var _rc = new kity.Group();
_rc.addShapes( [ _bg, _number ] ); _rc.addShapes( [ _bg, _number ] );
node.getIconRc().addShape( _rc ); node.getContRc().addShape( _rc );
_number.setTransform( new kity.Matrix().translate( 6, 15 ) ); _number.setTranslate( 6, 15 );
var rcHeight = _rc.getHeight();
_rc.setTranslate( 0, -rcHeight / 2 );
}; };
var renderProgressIcon = function ( node, val, left ) {
var renderProgressIcon = function ( node, val ) {
var _rc = new kity.Group(); var _rc = new kity.Group();
var _contRc = node.getContRc();
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) ); var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) );
var _percent, d; var _percent, d;
if ( val < 5 ) { if ( val < 5 ) {
...@@ -1856,19 +2249,18 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -1856,19 +2249,18 @@ KityMinder.registerModule( "IconModule", function () {
d.moveTo( 0, 0 ).lineTo( 6, 0 ); d.moveTo( 0, 0 ).lineTo( 6, 0 );
} else _percent = new kity.Group(); } else _percent = new kity.Group();
_rc.addShapes( [ _bg, _percent ] ); _rc.addShapes( [ _bg, _percent ] );
node.getIconRc().addShape( _rc ); _contRc.addShape( _rc );
_rc.setTransform( new kity.Matrix().translate( left, 10 ) );
switch ( val ) { switch ( val ) {
case 1: case 1:
break; break;
case 2: case 2:
d.carcTo( 6, 0, -6 ); d.carcTo( 6, 0, 0, 0, -6 );
break; break;
case 3: case 3:
d.carcTo( 6, -6, 0 ); d.carcTo( 6, 0, 0, -6, 0 );
break; break;
case 4: case 4:
d.carcTo( 6, 0, 6, 1, 0 ); d.carcTo( 6, 1, 0, 0, 6 );
break; break;
case 5: case 5:
var check = new kity.Path(); var check = new kity.Path();
...@@ -1879,6 +2271,10 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -1879,6 +2271,10 @@ KityMinder.registerModule( "IconModule", function () {
} }
if ( val < 5 ) d.close(); if ( val < 5 ) d.close();
_percent.fill( "#29A6BD" ); _percent.fill( "#29A6BD" );
var pre = node.getData( "PriorityIcon" );
var style = minder.getCurrentLayoutStyle()[ node.getType() ];
if ( !pre ) _rc.setTranslate( _rc.getWidth() / 2, 0 );
else _rc.setTranslate( _contRc.getWidth() + style.spaceLeft, 0 );
}; };
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () { var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
return { return {
...@@ -1928,27 +2324,17 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -1928,27 +2324,17 @@ KityMinder.registerModule( "IconModule", function () {
"progress": setProgressCommand "progress": setProgressCommand
}, },
"events": { "events": {
"RenderNode": function ( e ) { "RenderNodeLeft": function ( e ) {
var node = e.node; var node = e.node;
var iconRc = node.getIconRc();
var contRc = node.getContRc();
var PriorityIconVal = node.getData( "PriorityIcon" ); var PriorityIconVal = node.getData( "PriorityIcon" );
var ProgressIconVal = node.getData( "ProgressIcon" ); var ProgressIconVal = node.getData( "ProgressIcon" );
//依次排布图标、文字 var contRc = node.getContRc();
iconRc.clear();
var PriorityIconWidth = 0;
if ( PriorityIconVal ) { if ( PriorityIconVal ) {
renderPriorityIcon( node, PriorityIconVal ); renderPriorityIcon( node, PriorityIconVal );
PriorityIconWidth = 22;
} }
if ( ProgressIconVal ) { if ( ProgressIconVal ) {
renderProgressIcon( node, ProgressIconVal, PriorityIconWidth + 10 ); renderProgressIcon( node, ProgressIconVal );
} }
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 ) );
} }
} }
}; };
...@@ -1963,6 +2349,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -1963,6 +2349,7 @@ KityMinder.registerModule( "LayoutModule", function () {
getLayoutStyle: function ( name ) { getLayoutStyle: function ( name ) {
return this._layoutStyles[ name ]; return this._layoutStyles[ name ];
}, },
getLayoutStyleItems: function () { getLayoutStyleItems: function () {
var items = []; var items = [];
for ( var key in this._layoutStyles ) { for ( var key in this._layoutStyles ) {
...@@ -1979,15 +2366,18 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -1979,15 +2366,18 @@ KityMinder.registerModule( "LayoutModule", function () {
_root.setData( "currentstyle", name ); _root.setData( "currentstyle", name );
return name; return name;
}, },
getCurrentLayoutStyle: function () {
var curStyle = this.getCurrentStyle();
return this.getLayoutStyle( curStyle ).getCurrentLayoutStyle.call( this );
},
highlightNode: function ( node ) { highlightNode: function ( node ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).highlightNode.call( this, node ); this.getLayoutStyle( curStyle ).highlightNode.call( this, node );
}, },
initStyle: function () { initStyle: function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
var lastTransform = this._rc.getTransform();
this._rc.remove(); this._rc.remove();
this._rc = new kity.Group().setTransform( lastTransform ); this._rc = new kity.Group();
this._paper.addShape( this._rc ); this._paper.addShape( this._rc );
var _root = this.getRoot(); var _root = this.getRoot();
...@@ -1995,6 +2385,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -1995,6 +2385,7 @@ KityMinder.registerModule( "LayoutModule", function () {
n.clearLayout(); n.clearLayout();
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this ); this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire( 'afterinitstyle' );
}, },
appendChildNode: function ( parent, node, focus, index ) { appendChildNode: function ( parent, node, focus, index ) {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
...@@ -2063,10 +2454,9 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2063,10 +2454,9 @@ KityMinder.registerModule( "LayoutModule", function () {
execute: function ( km, node, focus, silbling ) { execute: function ( km, node, focus, silbling ) {
var parent = km.getSelectedNode(); var parent = km.getSelectedNode();
if( !parent ){ if ( !parent ) {
return null; return null;
} }
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) { if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
km.expandNode( parent ); km.expandNode( parent );
} }
...@@ -2090,7 +2480,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2090,7 +2480,7 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command, base: Command,
execute: function ( km, node, focus ) { execute: function ( km, node, focus ) {
var selectedNode = km.getSelectedNode(); var selectedNode = km.getSelectedNode();
if( !selectedNode ){ if ( !selectedNode ) {
return null; return null;
} }
...@@ -2119,7 +2509,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2119,7 +2509,7 @@ KityMinder.registerModule( "LayoutModule", function () {
base: Command, base: Command,
execute: function ( km ) { execute: function ( km ) {
if( km.getRoot().children.length == 0 ){ if ( km.getRoot().children.length == 0 ) {
return; return;
} }
...@@ -2147,18 +2537,43 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2147,18 +2537,43 @@ KityMinder.registerModule( "LayoutModule", function () {
} }
}; };
} )() ); } )() );
var EditNodeCommand = kity.createClass( "EditNodeCommand", ( function () {
return {
base: Command,
execute: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return null;
}
km.select( selectedNode, true );
},
queryState: function ( km ) {
var selectedNode = km.getSelectedNode();
if ( !selectedNode ) {
return -1;
} else {
return 0;
}
},
isNeedUndo: function () {
return false;
}
};
} )() );
return { return {
"commands": { "commands": {
"appendchildnode": AppendChildNodeCommand, "appendchildnode": AppendChildNodeCommand,
"appendsiblingnode": AppendSiblingNodeCommand, "appendsiblingnode": AppendSiblingNodeCommand,
"removenode": RemoveNodeCommand, "removenode": RemoveNodeCommand,
"editnode": EditNodeCommand,
"switchlayout": SwitchLayoutCommand "switchlayout": SwitchLayoutCommand
}, },
"events": { "events": {
"ready": function () { "ready": function () {
this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() ); this.setDefaultOptions( 'layoutstyle', this.getLayoutStyleItems() );
switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) ); switchLayout( this, this.getOptions( 'defaultlayoutstyle' ) );
}, },
"click": function ( e ) { "click": function ( e ) {
var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container; var ico = e.kityEvent.targetShape && e.kityEvent.targetShape.container;
...@@ -2188,6 +2603,12 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2188,6 +2603,12 @@ KityMinder.registerModule( "LayoutModule", function () {
this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) ) this.execCommand( 'appendchildnode', new MinderNode( this.getLang( 'topic' ) ) )
}, },
cmdName: 'appendchildnode' cmdName: 'appendchildnode'
}, {
label: this.getLang( 'node.editnode' ),
exec: function () {
this.execCommand( 'editnode', null );
},
cmdName: 'editnode'
}, { }, {
label: this.getLang( 'node.removenode' ), label: this.getLang( 'node.removenode' ),
cmdName: 'removenode' cmdName: 'removenode'
...@@ -2201,7 +2622,12 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -2201,7 +2622,12 @@ KityMinder.registerModule( "LayoutModule", function () {
"node": { "node": {
'appendsiblingnode': 'appendsiblingnode', 'appendsiblingnode': 'appendsiblingnode',
'appendchildnode': 'appendchildnode', 'appendchildnode': 'appendchildnode',
'editnode': 'editnode',
'removenode': 'removenode' 'removenode': 'removenode'
},
'defaultExpand': {
'defaultLayer': 0,
'defaultSubShow': 0
} }
} }
}; };
...@@ -2242,7 +2668,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2242,7 +2668,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
minder.getRenderContainer().addShape( iconShape ); minder.getRenderContainer().addShape( iconShape );
iconShape.addShapes( [ circle, plus, dec ] ); iconShape.addShapes( [ circle, plus, dec ] );
this.update(); this.update();
this.switchState();
}, },
switchState: function () { switchState: function () {
if ( !this._show ) { if ( !this._show ) {
...@@ -2267,7 +2692,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2267,7 +2692,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
nodeX = nodeShape.getRenderBox().closurePoints[ 0 ].x + 6; nodeX = nodeShape.getRenderBox().closurePoints[ 0 ].x + 6;
if ( node.getType() === "main" ) nodeX -= 3; if ( node.getType() === "main" ) nodeX -= 3;
} }
this.shape.setTransform( new kity.Matrix().translate( nodeX, nodeY ) ); this.shape.setTranslate( nodeX, nodeY );
}, },
remove: function () { remove: function () {
this.shape.remove(); this.shape.remove();
...@@ -2293,7 +2718,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2293,7 +2718,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
padding: [ 15.5, 25.5, 15.5, 25.5 ], padding: [ 15.5, 25.5, 15.5, 25.5 ],
margin: [ 0, 0, 0, 0 ], margin: [ 0, 0, 0, 0 ],
radius: 30, radius: 30,
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 3,
spaceRight: 0,
spaceTop: 3,
spaceBottom: 3
}, },
"main": { "main": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -2303,7 +2732,12 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2303,7 +2732,12 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 16, fontSize: 16,
margin: [ 0, 10, 30, 50 ], margin: [ 0, 10, 30, 50 ],
radius: 10, radius: 10,
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 5,
spaceRight: 0,
spaceTop: 2,
spaceBottom: 2
}, },
"sub": { "sub": {
stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ), stroke: new kity.Pen( "white", 2 ).setLineCap( "round" ).setLineJoin( "round" ),
...@@ -2311,7 +2745,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2311,7 +2745,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
fontSize: 12, fontSize: 12,
margin: [ 0, 10, 20, 6 ], margin: [ 0, 10, 20, 6 ],
padding: [ 5, 10, 5.5, 10 ], padding: [ 5, 10, 5.5, 10 ],
highlight: 'rgb(254, 219, 0)' highlight: 'rgb(254, 219, 0)',
spaceLeft: 4,
spaceRight: 0,
spaceTop: 2,
spaceBottom: 2
} }
}; };
//更新背景 //更新背景
...@@ -2342,8 +2780,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2342,8 +2780,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ]; var nodeStyle = nodeStyles[ nodeType ];
var txtShape = node.getTextShape(); //var txtShape = node.getTextShape();
txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ).setY( -3 ); //txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ).setY( -3 );
if ( nodeType === "root" ) { if ( nodeType === "root" ) {
Layout.leftList = []; Layout.leftList = [];
Layout.rightList = []; Layout.rightList = [];
...@@ -2385,7 +2823,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2385,7 +2823,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
default: default:
break; break;
} }
contRc.setTransform( new kity.Matrix().translate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + node.getTextShape().getHeight() ) ); contRc.setTranslate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + _contRCHeight / 2 );
}; };
//计算节点在垂直方向的位置 //计算节点在垂直方向的位置
var updateLayoutVertical = function ( node, parent, action ) { var updateLayoutVertical = function ( node, parent, action ) {
...@@ -2428,7 +2866,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2428,7 +2866,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
effectSet.push( node ); effectSet.push( node );
} else { } else {
if ( action === "append" || action === "contract" ) { if ( action === "append" || action === "contract" ) {
Layout.branchheight = node.getRenderContainer().getHeight() + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ]; var nodeHeight = node.getRenderContainer().getHeight() || ( node.getContRc().getHeight() + nodeStyle.padding[ 0 ] + nodeStyle.padding[ 2 ] );
Layout.branchheight = nodeHeight + nodeStyle.margin[ 0 ] + nodeStyle.margin[ 2 ];
} else if ( action === "change" ) { } else if ( action === "change" ) {
Layout.branchheight = countBranchHeight( node ); Layout.branchheight = countBranchHeight( node );
} }
...@@ -2452,6 +2891,16 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2452,6 +2891,16 @@ KityMinder.registerModule( "LayoutDefault", function () {
while ( _buffer.length > 0 ) { while ( _buffer.length > 0 ) {
var _buffer0Layout = _buffer[ 0 ].getLayout(); var _buffer0Layout = _buffer[ 0 ].getLayout();
var children = _buffer0Layout[ appendside + "List" ] || _buffer[ 0 ].getChildren(); var children = _buffer0Layout[ appendside + "List" ] || _buffer[ 0 ].getChildren();
var children = ( function () {
var result = [];
for ( var len = 0; len < children.length; len++ ) {
var l = children[ len ].getLayout();
if ( l.added ) {
result.push( children[ len ] );
}
}
return result;
} )();
_buffer = _buffer.concat( children ); _buffer = _buffer.concat( children );
var sY = _buffer0Layout.y - ( _buffer0Layout[ appendside + "Height" ] || _buffer0Layout.branchheight ) / 2; var sY = _buffer0Layout.y - ( _buffer0Layout[ appendside + "Height" ] || _buffer0Layout.branchheight ) / 2;
for ( var i = 0; i < children.length; i++ ) { for ( var i = 0; i < children.length; i++ ) {
...@@ -2459,7 +2908,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2459,7 +2908,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
childLayout.y = sY + childLayout.branchheight / 2; childLayout.y = sY + childLayout.branchheight / 2;
sY += childLayout.branchheight; sY += childLayout.branchheight;
} }
if ( _buffer[ 0 ] !== root ) effectSet.push( _buffer[ 0 ] ); if ( _buffer[ 0 ] !== root && _buffer[ 0 ].getLayout().added ) effectSet.push( _buffer[ 0 ] );
_buffer.shift(); _buffer.shift();
} }
}; };
...@@ -2481,7 +2930,18 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2481,7 +2930,18 @@ KityMinder.registerModule( "LayoutDefault", function () {
var _buffer = [ node ]; var _buffer = [ node ];
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
var prt = _buffer[ 0 ].getParent(); var prt = _buffer[ 0 ].getParent();
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); var children = _buffer[ 0 ].getChildren();
children = ( function () {
var result = [];
for ( var len = 0; len < children.length; len++ ) {
var l = children[ len ].getLayout();
if ( l.added ) {
result.push( children[ len ] );
}
}
return result;
} )();
_buffer = _buffer.concat( children );
if ( !prt ) { if ( !prt ) {
Layout.x = getMinderSize().width / 2; Layout.x = getMinderSize().width / 2;
_buffer.shift(); _buffer.shift();
...@@ -2513,13 +2973,13 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2513,13 +2973,13 @@ KityMinder.registerModule( "LayoutDefault", function () {
var _rectWidth = nodeShape.getWidth(); var _rectWidth = nodeShape.getWidth();
switch ( align ) { switch ( align ) {
case "right": case "right":
nodeShape.setTransform( new kity.Matrix().translate( Layout.x - _rectWidth, Layout.y - _rectHeight / 2 ) ); nodeShape.setTranslate( Layout.x - _rectWidth, Layout.y - _rectHeight / 2 );
break; break;
case "center": case "center":
nodeShape.setTransform( new kity.Matrix().translate( Layout.x - _rectWidth / 2, Layout.y - _rectHeight / 2 ) ); nodeShape.setTranslate( Layout.x - _rectWidth / 2, Layout.y - _rectHeight / 2 );
break; break;
default: default:
nodeShape.setTransform( new kity.Matrix().translate( Layout.x, Layout.y - _rectHeight / 2 ) ); nodeShape.setTranslate( Layout.x, Layout.y - _rectHeight / 2 );
break; break;
} }
node.setPoint( Layout.x, Layout.y ); node.setPoint( Layout.x, Layout.y );
...@@ -2579,8 +3039,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2579,8 +3039,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
.clear() .clear()
.moveTo( sX, sY ) .moveTo( sX, sY )
.lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) ); .lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) );
if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], nodeX, nodeY, 0, 1 ); if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 1, nodeX, nodeY );
else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], nodeX, nodeY ); else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 0, nodeX, nodeY );
connect.stroke( nodeStyle.stroke ); connect.stroke( nodeStyle.stroke );
} else { } else {
sX = parentBox.closurePoints[ 0 ].x + parentStyle.margin[ 1 ]; sX = parentBox.closurePoints[ 0 ].x + parentStyle.margin[ 1 ];
...@@ -2589,8 +3049,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2589,8 +3049,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
.clear() .clear()
.moveTo( sX, sY ) .moveTo( sX, sY )
.lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) ); .lineTo( sX, nodeY > sY ? ( nodeY - nodeStyle.margin[ 3 ] ) : ( nodeY + nodeStyle.margin[ 3 ] ) );
if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], nodeX, nodeY ); if ( nodeY > sY ) connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 0, nodeX, nodeY );
else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], nodeX, nodeY, 0, 1 ); else connect.getDrawer().carcTo( nodeStyle.margin[ 3 ], 0, 1, nodeX, nodeY );
connect.stroke( nodeStyle.stroke ); connect.stroke( nodeStyle.stroke );
} }
} }
...@@ -2598,26 +3058,32 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2598,26 +3058,32 @@ KityMinder.registerModule( "LayoutDefault", function () {
if ( nodeType !== "root" && node.getChildren().length !== 0 ) { if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) { if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node ); Layout.shicon = new ShIcon( node );
if ( node.getData( 'expand' ) ) {
Layout.shicon.switchState();
}
} }
Layout.shicon.update(); Layout.shicon.update();
} }
}; };
var showNodeInView = function( node ){ var showNodeInView = function ( node ) {
var padding = 5; var padding = 5;
var viewport = minder.getPaper().getViewPort(); var viewport = minder.getPaper().getViewPort();
var offset = node.getRenderContainer().getRenderBox( minder.getRenderContainer() ); var offset = node.getRenderContainer().getRenderBox( minder.getRenderContainer() );
var tmpX = viewport.center.x * 2 - (offset.x + offset.width); var tmpX = viewport.center.x * 2 - ( offset.x + offset.width );
var tmpY = viewport.center.y * 2 - (offset.y + offset.height); var tmpY = viewport.center.y * 2 - ( offset.y + offset.height );
var dx = offset.x < 0 ? -offset.x : Math.min(tmpX, 0); var dx = offset.x < 0 ? -offset.x : Math.min( tmpX, 0 );
var dy = offset.y < 0 ? -offset.y : Math.min(tmpY, 0); var dy = offset.y < 0 ? -offset.y : Math.min( tmpY, 0 );
km.getRenderContainer().fxTranslate( dx, dy, 100, "easeOutQuint" ); minder.getRenderContainer().fxTranslate( dx, dy, 100, "easeOutQuint" );
}; };
var _style = { var _style = {
getCurrentLayoutStyle: function () {
return nodeStyles;
},
highlightNode: function ( node ) { highlightNode: function ( node ) {
var highlight = node.isHighlight(); var highlight = node.isHighlight();
var nodeType = node.getType(); var nodeType = node.getType();
...@@ -2644,18 +3110,22 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2644,18 +3110,22 @@ KityMinder.registerModule( "LayoutDefault", function () {
default: default:
break; break;
} }
this._fire( new MinderEvent( "beforeRenderNode", { },
updateLayout: function ( node ) {
node.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: node node: node
}, false ) ); }, false ) );
}, this._firePharse( new MinderEvent( "RenderNodeRight", {
updateLayout: function ( node ) {
this._fire( new MinderEvent( "beforeRenderNode", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
node: node node: node
}, false ) ); }, false ) );
...@@ -2667,6 +3137,9 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2667,6 +3137,9 @@ KityMinder.registerModule( "LayoutDefault", function () {
translateNode( set[ i ] ); translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] ); updateConnectAndshIcon( set[ i ] );
} }
if ( this.isNodeSelected( node ) ) {
this.highlightNode( node )
}
}, },
initStyle: function () { initStyle: function () {
var _root = minder.getRoot(); var _root = minder.getRoot();
...@@ -2677,50 +3150,87 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2677,50 +3150,87 @@ KityMinder.registerModule( "LayoutDefault", function () {
_root.getLayout().align = "center"; _root.getLayout().align = "center";
updateBg( _root ); updateBg( _root );
initLayout( _root ); initLayout( _root );
this._fire( new MinderEvent( "beforeRenderNode", { _root.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: _root node: _root
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
node: _root node: _root
}, false ) ); }, false ) );
updateShapeByCont( _root ); updateShapeByCont( _root );
updateLayoutHorizon( _root ); updateLayoutHorizon( _root );
updateLayoutVertical( _root ); updateLayoutVertical( _root );
translateNode( _root ); translateNode( _root );
var _buffer = [ _root ]; if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y );
var _cleanbuffer = []; var expandoptions = minder.getOptions( 'defaultExpand' );
//打散结构 var cur_layer = 0;
while ( _buffer.length !== 0 ) { var expand_layer = expandoptions.defaultLayer;
var children = _buffer[ 0 ].getChildren(); var mains = _root.getChildren();
_buffer = _buffer.concat( children ); for ( var i = 0; i < mains.length; i++ ) {
for ( var i = 0; i < children.length; i++ ) { this.appendChildNode( _root, mains[ i ] );
children[ i ].getLayout().parent = _buffer[ 0 ]; }
cur_layer++;
//创建一级节点的副本
var _buffer = ( function () {
var items = [];
for ( var i = 0; i < mains.length; i++ ) {
items.push( mains[ i ] );
} }
_buffer[ 0 ].clearChildren(); return items;
if ( _buffer[ 0 ] !== _root ) _cleanbuffer.push( _buffer[ 0 ] ); } )();
_buffer.shift(); next = [];
var layer_nolimit = ( expand_layer < 1 ) || false;
var sub_nolimit = ( expandoptions.defaultSubShow < 1 ) || false;
var loopcontinue = function () {
return ( layer_nolimit ? ( _buffer.length !== 0 ) : ( _buffer.length !== 0 && cur_layer < expand_layer ) );
};
while ( loopcontinue() ) {
cur_layer++;
var layer_len = _buffer.length;
for ( var j = 0; j < layer_len; j++ ) {
var c = _buffer[ j ].getChildren();
if ( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && c.length !== 0 ) {
this.expandNode( _buffer[ j ] );
_buffer = _buffer.concat( _buffer[ j ].getChildren() );
} }
if ( historyPoint ) {
_root.setPoint( historyPoint );
} }
//重组结构 _buffer.splice( 0, layer_len );
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y ); _root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
appendChildNode: function ( parent, node, focus, sibling ) { appendChildNode: function ( parent, node, focus, sibling ) {
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getData( "expand" ) === false ) {
minder.expandNode( parent );
}
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
node.clearLayout(); node.clearLayout();
node.getContRc().clear();
node.setData( 'expand', false );
if ( parent.getType() !== 'root' ) {
parent.setData( 'expand', true );
}
var Layout = node.getLayout(); var Layout = node.getLayout();
Layout.added = true;
var parentLayout = parent.getLayout(); var parentLayout = parent.getLayout();
var children = parent.getChildren();
var exist = ( children.indexOf( node ) !== -1 );
if ( sibling ) { if ( sibling ) {
if ( !exist ) parent.insertChild( node, sibling.getIndex() + 1 );
var siblingLayout = sibling.getLayout(); var siblingLayout = sibling.getLayout();
Layout.appendside = siblingLayout.appendside; Layout.appendside = siblingLayout.appendside;
Layout.align = siblingLayout.align; Layout.align = siblingLayout.align;
parent.insertChild( node, sibling.getIndex() + 1 );
if ( parent.getType() === "root" ) { if ( parent.getType() === "root" ) {
var len = parent.getChildren().length; minder.handelNodeInsert( node );
var len = children.length;
if ( len < 7 ) { if ( len < 7 ) {
if ( len % 2 ) { if ( len % 2 ) {
Layout.appendside = "right"; Layout.appendside = "right";
...@@ -2739,7 +3249,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2739,7 +3249,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
var prtLayout = parent.getLayout(); var prtLayout = parent.getLayout();
Layout.appendside = prtLayout.appendside; Layout.appendside = prtLayout.appendside;
Layout.align = prtLayout.align; Layout.align = prtLayout.align;
parent.appendChild( node ); if ( !exist ) parent.appendChild( node );
} else { } else {
var nodeP = node.getPoint(); var nodeP = node.getPoint();
if ( nodeP && nodeP.x && nodeP.y ) { if ( nodeP && nodeP.x && nodeP.y ) {
...@@ -2767,7 +3277,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2767,7 +3277,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
} else { } else {
idx1 = parent.getChildren().length; idx1 = parent.getChildren().length;
} }
parent.insertChild( node, idx1 ); if ( !exist ) parent.insertChild( node, idx1 );
} }
} }
//设置分支类型 //设置分支类型
...@@ -2779,10 +3289,19 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2779,10 +3289,19 @@ KityMinder.registerModule( "LayoutDefault", function () {
//计算位置等流程 //计算位置等流程
updateBg( node ); updateBg( node );
initLayout( node ); initLayout( node );
this._fire( new MinderEvent( "beforeRenderNode", { this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeTop", {
node: node node: node
}, false ) ); }, false ) );
updateShapeByCont( node ); updateShapeByCont( node );
...@@ -2794,7 +3313,7 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2794,7 +3313,7 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateConnectAndshIcon( set[ i ] ); updateConnectAndshIcon( set[ i ] );
} }
if( focus ){ if ( focus ) {
showNodeInView( node ); showNodeInView( node );
} }
}, },
...@@ -2857,34 +3376,23 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2857,34 +3376,23 @@ KityMinder.registerModule( "LayoutDefault", function () {
} }
node.setData( "expand", isExpand ); node.setData( "expand", isExpand );
var _buffer = node.getChildren(); var _buffer = node.getChildren();
var _cleanbuffer = [];
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( isExpand ) { if ( isExpand ) {
var parent = _buffer[ 0 ].getParent(); for ( var j = 0; j < _buffer.length; j++ ) {
Layout.parent = parent; minder.appendChildNode( node, _buffer[ j ] );
_cleanbuffer.push( _buffer[ 0 ] ); }
Layout.connect = null;
Layout.shicon = null;
} else { } else {
try { var _buffer = node.getChildren();
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( Layout.added ) {
Layout.added = false;
_buffer[ 0 ].getRenderContainer().remove(); _buffer[ 0 ].getRenderContainer().remove();
Layout.connect.remove(); Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove(); if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
} }
//if ( _buffer[ 0 ].getData( "expand" ) !== false )
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
} }
if ( isExpand ) {
node.clearChildren();
for ( var j = 0; j < _cleanbuffer.length; j++ ) {
//if ( _cleanbuffer[ j ].getData( "expand" ) !== false )
_cleanbuffer[ j ].clearChildren();
minder.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
}
} }
var set = []; var set = [];
if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" ); if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
...@@ -2957,7 +3465,7 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -2957,7 +3465,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
var nodeType = node.getType(); var nodeType = node.getType();
var nodeX = nodeShape.getRenderBox().closurePoints[ 1 ].x + 5; var nodeX = nodeShape.getRenderBox().closurePoints[ 1 ].x + 5;
var nodeY = nodeShape.getRenderBox().closurePoints[ 0 ].y; var nodeY = nodeShape.getRenderBox().closurePoints[ 0 ].y;
this.shape.setTransform( new kity.Matrix().translate( nodeX, nodeY ) ); this.shape.setTranslate( nodeX, nodeY );
}, },
remove: function () { remove: function () {
this.shape.remove(); this.shape.remove();
...@@ -3023,8 +3531,8 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3023,8 +3531,8 @@ KityMinder.registerModule( "LayoutBottom", function () {
var Layout = node.getLayout(); var Layout = node.getLayout();
var nodeType = node.getType(); var nodeType = node.getType();
var nodeStyle = nodeStyles[ nodeType ]; var nodeStyle = nodeStyles[ nodeType ];
var txtShape = node.getTextShape(); // var txtShape = node.getTextShape();
txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ).setY( -3 ); // txtShape.fill( nodeStyle.color ).setSize( nodeStyle.fontSize ).setY( -3 );
if ( nodeType === "main" ) { if ( nodeType === "main" ) {
var subgroup = Layout.subgroup = new kity.Group(); var subgroup = Layout.subgroup = new kity.Group();
minder.getRenderContainer().addShape( subgroup ); minder.getRenderContainer().addShape( subgroup );
...@@ -3054,7 +3562,7 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3054,7 +3562,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
default: default:
break; break;
} }
contRc.setTransform( new kity.Matrix().translate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + node.getTextShape().getHeight() ) ); contRc.setTranslate( nodeStyle.padding[ 3 ], nodeStyle.padding[ 0 ] + _contRCHeight / 2 );
}; };
var updateLayoutMain = function () { var updateLayoutMain = function () {
var _root = minder.getRoot(); var _root = minder.getRoot();
...@@ -3160,17 +3668,17 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3160,17 +3668,17 @@ KityMinder.registerModule( "LayoutBottom", function () {
var _rectWidth = nodeShape.getWidth(); var _rectWidth = nodeShape.getWidth();
switch ( align ) { switch ( align ) {
case "right": case "right":
nodeShape.setTransform( new kity.Matrix().translate( Layout.x - _rectWidth, Layout.y ) ); nodeShape.setTranslate( Layout.x - _rectWidth, Layout.y );
break; break;
case "center": case "center":
nodeShape.setTransform( new kity.Matrix().translate( Layout.x - _rectWidth / 2, Layout.y ) ); nodeShape.setTranslate( Layout.x - _rectWidth / 2, Layout.y );
break; break;
default: default:
nodeShape.setTransform( new kity.Matrix().translate( Layout.x, Layout.y ) ); nodeShape.setTranslate( Layout.x, Layout.y );
break; break;
} }
if ( node.getType() === "main" ) { if ( node.getType() === "main" ) {
Layout.subgroup.setTransform( new kity.Matrix().translate( Layout.x, Layout.y + node.getRenderContainer().getHeight() ) ); Layout.subgroup.setTranslate( Layout.x, Layout.y + node.getRenderContainer().getHeight() );
} }
node.setPoint( Layout.x, Layout.y ); node.setPoint( Layout.x, Layout.y );
}; };
...@@ -3230,6 +3738,9 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3230,6 +3738,9 @@ KityMinder.registerModule( "LayoutBottom", function () {
} }
}; };
var _style = { var _style = {
getCurrentLayoutStyle: function () {
return nodeStyles;
},
highlightNode: function ( node ) { highlightNode: function ( node ) {
var highlight = node.isHighlight(); var highlight = node.isHighlight();
var nodeType = node.getType(); var nodeType = node.getType();
...@@ -3248,21 +3759,24 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3248,21 +3759,24 @@ KityMinder.registerModule( "LayoutBottom", function () {
default: default:
break; break;
} }
this._fire( new MinderEvent( "beforeRenderNode", { },
updateLayout: function ( node ) {
node.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: node node: node
}, false ) ); }, false ) );
}, this._firePharse( new MinderEvent( "RenderNodeRight", {
updateLayout: function ( node ) {
this._fire( new MinderEvent( "beforeRenderNode", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
node: node node: node
}, false ) ); }, false ) );
updateShapeByCont( node ); updateShapeByCont( node );
var set = updateLayoutAll( node, node.getParent(), "change" ); var set = updateLayoutAll( node, node.getParent(), "change" );
for ( var i = 0; i < set.length; i++ ) { for ( var i = 0; i < set.length; i++ ) {
...@@ -3284,10 +3798,20 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3284,10 +3798,20 @@ KityMinder.registerModule( "LayoutBottom", function () {
_root.getLayout().align = "center"; _root.getLayout().align = "center";
updateBg( _root ); updateBg( _root );
initLayout( _root ); initLayout( _root );
this._fire( new MinderEvent( "beforeRenderNode", { _root.getContRc().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: _root node: _root
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeRight", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: _root
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeTop", {
node: _root node: _root
}, false ) ); }, false ) );
updateShapeByCont( _root ); updateShapeByCont( _root );
...@@ -3334,10 +3858,26 @@ KityMinder.registerModule( "LayoutBottom", function () { ...@@ -3334,10 +3858,26 @@ KityMinder.registerModule( "LayoutBottom", function () {
//计算位置等流程 //计算位置等流程
updateBg( node ); updateBg( node );
initLayout( node ); initLayout( node );
this._fire( new MinderEvent( "beforeRenderNode", { // this._fire( new MinderEvent( "beforeRenderNode", {
// node: node
// }, false ) );
// this._fire( new MinderEvent( "RenderNode", {
// node: node
// }, false ) );
node.getRenderContainer().clear();
this._firePharse( new MinderEvent( "RenderNodeLeft", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeCenter", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeRight", {
node: node
}, false ) );
this._firePharse( new MinderEvent( "RenderNodeBottom", {
node: node node: node
}, false ) ); }, false ) );
this._fire( new MinderEvent( "RenderNode", { this._firePharse( new MinderEvent( "RenderNodeTop", {
node: node node: node
}, false ) ); }, false ) );
updateShapeByCont( node ); updateShapeByCont( node );
...@@ -3666,7 +4206,7 @@ KityMinder.registerModule( 'View', function () { ...@@ -3666,7 +4206,7 @@ KityMinder.registerModule( 'View', function () {
base: Command, base: Command,
execute: function ( km, focusNode ) { execute: function ( km, focusNode ) {
var viewport = km.getPaper().getViewPort(); var viewport = km.getPaper().getViewPort();
var offset = focusNode.getRenderContainer().getRenderBox( km.getRenderContainer() ); var offset = focusNode.getRenderContainer().getRenderBox( 'paper' );
var dx = viewport.center.x - offset.x - offset.width / 2, var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y; dy = viewport.center.y - offset.y;
km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" ); km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
...@@ -3745,11 +4285,10 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', { ...@@ -3745,11 +4285,10 @@ var MoveToParentCommand = kity.createClass( 'MoveToParentCommand', {
for ( var i = nodes.length - 1; i >= 0; i-- ) { for ( var i = nodes.length - 1; i >= 0; i-- ) {
node = nodes[ i ]; node = nodes[ i ];
if ( node.getParent() ) { if ( node.getParent() ) {
node.getParent().removeChild( node ); minder.removeNode( [ node ] );
parent.appendChild( node ); minder.appendChildNode( parent, node );
} }
} }
minder.initStyle( minder.getRoot() );
minder.select( nodes, true ); minder.select( nodes, true );
} }
} ); } );
...@@ -3852,6 +4391,7 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -3852,6 +4391,7 @@ var DragBox = kity.createClass( "DragBox", {
this.remove(); this.remove();
this._dragMode = false; this._dragMode = false;
this._dropSucceedTarget = null; this._dropSucceedTarget = null;
this._removeDropHint();
}, },
_drawForDragMode: function () { _drawForDragMode: function () {
this._text.setContent( this._dragSources.length + ' items' ); this._text.setContent( this._dragSources.length + ' items' );
...@@ -3916,6 +4456,13 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -3916,6 +4456,13 @@ var DragBox = kity.createClass( "DragBox", {
this._lastSucceedTarget = target; this._lastSucceedTarget = target;
}, },
_removeDropHint: function () {
var lastTarget = this._lastSucceedTarget;
if ( lastTarget ) {
this._removeDropStyle( lastTarget );
}
},
_removeDropStyle: function ( node ) { _removeDropStyle: function ( node ) {
node._layout.bgRect.stroke( 'none' ); node._layout.bgRect.stroke( 'none' );
this._rect.stroke( '#3399ff', 1 ); this._rect.stroke( '#3399ff', 1 );
...@@ -3952,7 +4499,7 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -3952,7 +4499,7 @@ var DragBox = kity.createClass( "DragBox", {
var movement = kity.Vector.fromPoints( this._startPosition, this._dragPosition ); var movement = kity.Vector.fromPoints( this._startPosition, this._dragPosition );
this.setTransform( new kity.Matrix().translate( movement.x, movement.y ) ); this.setTranslate( movement );
this._dropTest(); this._dropTest();
this._updateDropHint(); this._updateDropHint();
...@@ -4021,6 +4568,11 @@ KityMinder.registerModule( "DropFile", function () { ...@@ -4021,6 +4568,11 @@ KityMinder.registerModule( "DropFile", function () {
e.stopPropagation(); e.stopPropagation();
var minder = this; var minder = this;
if( kity.Browser.ie && Number(kity.Browser.version) < 10 ){
alert('文件导入对IE浏览器仅支持10以上版本');
return;
}
var files = e.dataTransfer.files; var files = e.dataTransfer.files;
if ( files ) { if ( files ) {
...@@ -4225,8 +4777,12 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -4225,8 +4777,12 @@ KityMinder.registerModule( "KeyboardModule", function () {
break; break;
case keys.Backspace: case keys.Backspace:
case keys.Del: case keys.Del:
this.execCommand( 'removenode' );
e.preventDefault(); e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break;
case keys.F2:
e.preventDefault();
if ( this.queryCommandState( 'editnode' ) !== -1 ) this.execCommand( 'editnode' );
break; break;
case keys.Left: case keys.Left:
...@@ -4418,11 +4974,11 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -4418,11 +4974,11 @@ KityMinder.registerModule( "TextEditModule", function () {
var selectionByClick = false; var selectionByClick = false;
return { return {
"events": {
//插入光标 //插入光标
"init":function(){ "afterinitstyle":function(){
this.getPaper().addShape(sel); this.getRenderContainer().addShape(sel);
}, },
"events": {
'normal.beforemousedown textedit.beforemousedown':function(e){ 'normal.beforemousedown textedit.beforemousedown':function(e){
if(e.isRightMB()){ if(e.isRightMB()){
e.stopPropagationImmediately(); e.stopPropagationImmediately();
...@@ -4446,6 +5002,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -4446,6 +5002,7 @@ KityMinder.registerModule( "TextEditModule", function () {
textShape.setStyle('cursor','default'); textShape.setStyle('cursor','default');
if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text' if ( this.isSingleSelect() && node.isSelected()) {// && e.kityEvent.targetShape.getType().toLowerCase()== 'text'
sel.collapse(); sel.collapse();
node.getTextShape().setStyle('cursor','text'); node.getTextShape().setStyle('cursor','text');
km.setStatus('textedit'); km.setStatus('textedit');
...@@ -4493,7 +5050,8 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -4493,7 +5050,8 @@ KityMinder.registerModule( "TextEditModule", function () {
var offset = e.getPosition(); var offset = e.getPosition();
if(Math.abs(offset.y - lastEvtPosition.y) > 2 && Math.abs(lastEvtPosition.x - offset.x) < 1 ){ if(Math.abs(offset.y - lastEvtPosition.y) >= 1 && Math.abs(lastEvtPosition.x - offset.x) <= 1 ){
sel.setHide(); sel.setHide();
mouseDownStatus = false; mouseDownStatus = false;
return; return;
...@@ -4530,12 +5088,13 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -4530,12 +5088,13 @@ KityMinder.registerModule( "TextEditModule", function () {
"resize": function ( e ) { "resize": function ( e ) {
sel.setHide(); sel.setHide();
}, },
'execCommand':function(e){ "execCommand": function( e ) {
var cmds = { var cmds = {
'appendchildnode':1, 'appendchildnode' : 1,
'appendsiblingnode':1 'appendsiblingnode' : 1,
'editnode' : 1
}; };
if(cmds[e.commandName]){ if ( cmds[ e.commandName ] ){
var node = km.getSelectedNode(); var node = km.getSelectedNode();
if( !node ){ if( !node ){
...@@ -4592,6 +5151,12 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -4592,6 +5151,12 @@ KityMinder.registerModule( "TextEditModule", function () {
'selectionclear':function(){ 'selectionclear':function(){
km.setStatus('normal'); km.setStatus('normal');
receiver.setTextEditStatus(false).clear() receiver.setTextEditStatus(false).clear()
},
blur:function(){
receiver.clear()
},
'textedit.mousewheel':function(){
receiver.setContainerStyle()
} }
} }
}; };
...@@ -4651,8 +5216,8 @@ Minder.Range = kity.createClass('Range',{ ...@@ -4651,8 +5216,8 @@ Minder.Range = kity.createClass('Range',{
}); });
//接收者 //接收者
Minder.Receiver = kity.createClass('Receiver',{ Minder.Receiver = kity.createClass( 'Receiver', {
clear : function(){ clear: function () {
this.container.innerHTML = ''; this.container.innerHTML = '';
this.selection && this.selection.setHide(); this.selection && this.selection.setHide();
this.range && this.range.nativeSel.removeAllRanges(); this.range && this.range.nativeSel.removeAllRanges();
...@@ -4660,337 +5225,376 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -4660,337 +5225,376 @@ Minder.Receiver = kity.createClass('Receiver',{
this.inputLength = 0; this.inputLength = 0;
return this; return this;
}, },
setTextEditStatus : function(status){ setTextEditStatus: function ( status ) {
this.textEditStatus = status || false; this.textEditStatus = status || false;
return this; return this;
}, },
isTextEditStatus:function(){ isTextEditStatus: function () {
return this.textEditStatus; return this.textEditStatus;
}, },
constructor : function(km){ constructor: function ( km ) {
this.setKityMinder(km); this.setKityMinder( km );
this.textEditStatus = false; this.textEditStatus = false;
var _div = document.createElement('div'); var _div = document.createElement( 'div' );
_div.setAttribute('contenteditable',true); _div.setAttribute( 'contenteditable', true );
_div.className = 'km_receiver'; _div.className = 'km_receiver';
this.container = document.body.insertBefore(_div,document.body.firstChild); this.container = document.body.insertBefore( _div, document.body.firstChild );
utils.addCssRule('km_receiver_css',' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}');// utils.addCssRule( 'km_receiver_css', ' .km_receiver{position:absolute;padding:0;margin:0;word-wrap:break-word;clip:rect(1em 1em 1em 1em);}' ); //
this.km.on('textedit.beforekeyup textedit.keydown textedit.paste', utils.proxy(this.keyboardEvents,this)); this.km.on( 'textedit.beforekeyup textedit.keydown textedit.keypress textedit.paste', utils.proxy( this.keyboardEvents, this ) );
this.timer = null; this.timer = null;
this.index = 0; this.index = 0;
}, },
setRange : function(range,index){ setRange: function ( range, index ) {
this.index = index || this.index; this.index = index || this.index;
var text = this.container.firstChild; var text = this.container.firstChild;
this.range = range; this.range = range;
range.setStart(text || this.container, this.index).collapse(true); range.setStart( text || this.container, this.index ).collapse( true );
var me = this; var me = this;
setTimeout(function(){ setTimeout( function () {
me.container.focus(); me.container.focus();
range.select() range.select()
}); } );
return this; return this;
}, },
setTextShape:function(textShape){ setTextShape: function ( textShape ) {
if(!textShape){ if ( !textShape ) {
textShape = new kity.Text(); textShape = new kity.Text();
} }
this.textShape = textShape; this.textShape = textShape;
this.container.innerHTML = textShape.getContent(); this.container.innerHTML = textShape.getContent();
return this; return this;
}, },
setTextShapeSize:function(size){ setTextShapeSize: function ( size ) {
this.textShape.setSize(size); this.textShape.setSize( size );
return this; return this;
}, },
getTextShapeHeight:function(){ getTextShapeHeight: function () {
return this.textShape.getRenderBox().height; return this.textShape.getRenderBox().height;
}, },
appendTextShapeToPaper:function(paper){ appendTextShapeToPaper: function ( paper ) {
paper.addShape(this.textShape); paper.addShape( this.textShape );
return this; return this;
}, },
setKityMinder:function(km){ setKityMinder: function ( km ) {
this.km = km; this.km = km;
return this; return this;
}, },
setMinderNode:function(node){ setMinderNode: function ( node ) {
this.minderNode = node; this.minderNode = node;
return this; return this;
}, },
keyboardEvents : function(e){ keyboardEvents: function ( e ) {
clearTimeout(this.timer); clearTimeout( this.timer );
var me = this; var me = this;
var orgEvt = e.originEvent; var orgEvt = e.originEvent;
var keyCode = orgEvt.keyCode; var keyCode = orgEvt.keyCode;
var keys = KityMinder.keymap; var keys = KityMinder.keymap;
function setTextToContainer(){
var text = me.container.textContent.replace(/[\u200b\t\r\n]/g,'');
if(me.textShape.getOpacity() == 0){ function setTextToContainer() {
me.textShape.setOpacity(1); var text = me.container.textContent.replace( /[\u200b\t\r\n]/g, '' );
if ( me.textShape.getOpacity() == 0 ) {
me.textShape.setOpacity( 1 );
}
//#46 修复在ff下定位到文字后方空格光标不移动问题
if ( browser.gecko && /\s$/.test( text ) ) {
text += "\u200b";
} }
me.textShape.setContent(text); me.textShape.setContent( text );
me.setContainerStyle(); me.setContainerStyle();
me.minderNode.setText(text); me.minderNode.setText( text );
if(text.length == 0){ if ( text.length == 0 ) {
me.textShape.setContent('a');
me.textShape.setOpacity(0); me.minderNode.setText( 'a' );
}
me.km.updateLayout( me.minderNode );
me.textShape = me.minderNode.getTextShape();
if ( text.length == 0 ) {
me.textShape.setOpacity( 0 );
} }
me.km.updateLayout(me.minderNode);
me.setBaseOffset(); me.setBaseOffset();
me.updateTextData(); me.updateTextData();
me.updateIndex(); me.updateIndex();
me.updateSelection(); me.updateSelection();
me.timer = setTimeout(function(){ me.timer = setTimeout( function () {
me.selection.setShow() me.selection.setShow()
},500); }, 500 );
} }
switch(e.type){ var isTypeText = false;
var isKeypress = false;
switch ( e.type ) {
case 'keydown': case 'keydown':
isTypeText = false;
isKeypress = false;
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case keys.Enter: case keys.Enter:
case keys.Tab: case keys.Tab:
this.selection.setHide(); this.selection.setHide();
this.clear().setTextEditStatus(false); this.clear().setTextEditStatus( false );
this.km.fire('contentchange'); this.km.fire( 'contentchange' );
this.km.setStatus('normal'); this.km.setStatus( 'normal' );
e.preventDefault(); e.preventDefault();
return;
break; break;
case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
return;
} }
if ( e.originEvent.ctrlKey || e.originEvent.metaKey ){ if ( e.originEvent.ctrlKey || e.originEvent.metaKey ) {
//粘贴 //粘贴
if(keyCode == keymap.v){ if ( keyCode == keymap.v ) {
setTimeout(function(){ setTimeout( function () {
me.range.updateNativeRange().insertNode($('<span>$$_kityminder_bookmark_$$</span>')[0]); me.range.updateNativeRange().insertNode( $( '<span>$$_kityminder_bookmark_$$</span>' )[ 0 ] );
me.container.innerHTML = me.container.textContent.replace(/[\u200b\t\r\n]/g,''); me.container.innerHTML = me.container.textContent.replace( /[\u200b\t\r\n]/g, '' );
var index = me.container.textContent.indexOf('$$_kityminder_bookmark_$$'); var index = me.container.textContent.indexOf( '$$_kityminder_bookmark_$$' );
me.container.textContent = me.container.textContent.replace('$$_kityminder_bookmark_$$',''); me.container.textContent = me.container.textContent.replace( '$$_kityminder_bookmark_$$', '' );
me.range.setStart(me.container.firstChild,index).collapse(true).select(); me.range.setStart( me.container.firstChild, index ).collapse( true ).select();
setTextToContainer() setTextToContainer()
},100); }, 100 );
} }
//剪切 //剪切
if(keyCode == keymap.x){ if ( keyCode == keymap.x ) {
setTimeout(function(){ setTimeout( function () {
setTextToContainer() setTextToContainer()
},100); }, 100 );
} }
return; return;
} }
isTypeText = true;
break; break;
case 'keypress':
if ( isTypeText )
setTextToContainer();
isKeypress = true;
break;
case 'beforekeyup': case 'beforekeyup':
switch(keyCode){ switch ( keyCode ) {
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
if(this.keydownNode === this.minderNode){ case keymap.F2:
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus(); this.rollbackStatus();
this.setTextEditStatus(false); this.setTextEditStatus( false );
this.clear(); this.clear();
} }
e.preventDefault(); e.preventDefault();
return; return;
case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
return;
} }
if ( !isKeypress ) {
setTextToContainer(); setTextToContainer();
}
return true; return true;
} }
}, },
updateIndex:function(){ updateIndex: function () {
this.index = this.range.getStart().startOffset; this.index = this.range.getStart().startOffset;
}, },
updateTextData : function(){ updateTextData: function () {
this.textShape.textData = this.getTextOffsetData(); this.textShape.textData = this.getTextOffsetData();
}, },
setSelection : function(selection){ setSelection: function ( selection ) {
this.selection = selection; this.selection = selection;
return this; return this;
}, },
updateSelection : function(){ updateSelection: function () {
this.selection.setShowHold(); this.selection.setShowHold();
this.selection.bringTop(); this.selection.bringTop();
//更新模拟选区的范围 //更新模拟选区的范围
this.selection.setStartOffset(this.index).collapse(true); this.selection.setStartOffset( this.index ).collapse( true );
if(this.index == this.textData.length){ if ( this.index == this.textData.length ) {
if(this.index == 0){ if ( this.index == 0 ) {
this.selection.setPosition(this.getBaseOffset()) this.selection.setPosition( this.getBaseOffset() )
}else{ } else {
this.selection.setPosition({ this.selection.setPosition( {
x : this.textData[this.index-1].x + this.textData[this.index-1].width, x: this.textData[ this.index - 1 ].x + this.textData[ this.index - 1 ].width,
y : this.textData[this.index-1].y y: this.textData[ this.index - 1 ].y
}) } )
} }
}else{ } else {
this.selection.setPosition(this.textData[this.index]) this.selection.setPosition( this.textData[ this.index ] )
} }
return this; return this;
}, },
getBaseOffset:function(){ getBaseOffset: function ( ) {
return this.textShape.getRenderBox('top'); var rb = this.textShape.getRenderBox( this.km.getRenderContainer() );
// if(!this.pr) {
// this.km.getRenderContainer().addShape(this.pr = new kity.Rect().stroke('green'));
// }
// this.pr.setSize(rb.width, rb.height).setPosition(rb.x, rb.y);
return rb;
}, },
setBaseOffset :function(){ setBaseOffset: function () {
this.offset = this.textShape.getRenderBox('top'); this.offset = this.textShape.getRenderBox( this.km.getRenderContainer() );
return this; return this;
}, },
setContainerStyle : function(){ setContainerStyle: function () {
var textShapeBox = this.textShape.getRenderBox(); var textShapeBox = this.getBaseOffset();
this.container.style.cssText = ";left:" + this.offset.x this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
+ 'px;top:' + (this.offset.y+textShapeBox.height)
+ 'px;width:' + textShapeBox.width
+ 'px;height:' + textShapeBox.height + 'px;';
return this; return this;
}, },
getTextOffsetData:function(){ getTextOffsetData: function () {
var text = this.textShape.getContent(); var text = this.textShape.getContent();
this.textData = []; this.textData = [];
for(var i= 0,l = text.length;i<l;i++){ for ( var i = 0, l = text.length; i < l; i++ ) {
var box = this.textShape.getExtentOfChar(i); try {
this.textData.push({ var box = this.textShape.getExtentOfChar( i );
x:box.x + this.offset.x, } catch ( e ) {
y:this.offset.y, debugger
width:box.width, }
height:box.height
}) this.textData.push( {
x: box.x + this.offset.x,
y: this.offset.y,
width: box.width,
height: box.height
} )
} }
return this; return this;
}, },
setCurrentIndex:function(offset){ setCurrentIndex: function ( offset ) {
var me = this; var me = this;
this.getTextOffsetData(); this.getTextOffsetData();
var hadChanged = false; var hadChanged = false;
utils.each(this.textData,function(i,v){ utils.each( this.textData, function ( i, v ) {
//点击开始之前 //点击开始之前
if(i == 0 && offset.x <= v.x){ if ( i == 0 && offset.x <= v.x ) {
me.index = 0; me.index = 0;
return false; return false;
} }
if ( offset.x >= v.x && offset.x <= v.x + v.width ) {
if(i == me.textData.length -1 && offset.x >= v.x){ if ( offset.x - v.x > v.width / 2 ) {
me.index = me.textData.length;
return false;
}
if(offset.x >= v.x && offset.x <= v.x + v.width){
if(offset.x - v.x > v.width/2){
me.index = i + 1; me.index = i + 1;
}else { } else {
me.index = i me.index = i
} }
hadChanged = true; hadChanged = true;
return false; return false;
} }
}); if ( i == me.textData.length - 1 && offset.x >= v.x ) {
me.index = me.textData.length;
return false;
}
} );
return this; return this;
}, },
setSelectionHeight:function(){ setSelectionHeight: function () {
this.selection.setHeight(this.getTextShapeHeight()); this.selection.setHeight( this.getTextShapeHeight() );
return this; return this;
}, },
updateSelectionByMousePosition:function(offset,dir){ updateSelectionByMousePosition: function ( offset, dir ) {
var me = this; var me = this;
utils.each(this.textData,function(i,v){ utils.each( this.textData, function ( i, v ) {
//点击开始之前 //点击开始之前
if(i == 0 && offset.x <= v.x){ if ( i == 0 && offset.x <= v.x ) {
me.selection.setStartOffset(0); me.selection.setStartOffset( 0 );
return false; return false;
} }
if(i == me.textData.length -1 && offset.x >= v.x){ if ( i == me.textData.length - 1 && offset.x >= v.x ) {
me.selection.setEndOffset(me.textData.length); me.selection.setEndOffset( me.textData.length );
return false; return false;
} }
if(offset.x >= v.x && offset.x <= v.x + v.width){ if ( offset.x >= v.x && offset.x <= v.x + v.width ) {
if(me.index == i){ if ( me.index == i ) {
if(i == 0){ if ( i == 0 ) {
me.selection.setStartOffset(i) me.selection.setStartOffset( i )
} }
if(offset.x <= v.x + v.width/2){ if ( offset.x <= v.x + v.width / 2 ) {
me.selection.collapse() me.selection.collapse()
}else { } else {
me.selection.setEndOffset(i + (me.selection.endOffset > i || dir == 1 ? 1 : 0)) me.selection.setEndOffset( i + ( me.selection.endOffset > i || dir == 1 ? 1 : 0 ) )
} }
}else if(i > me.index){ } else if ( i > me.index ) {
me.selection.setStartOffset(me.index); me.selection.setStartOffset( me.index );
me.selection.setEndOffset(i + 1) me.selection.setEndOffset( i + 1 )
}else{ } else {
if(dir == 1){ if ( dir == 1 ) {
me.selection.setStartOffset(i + (offset.x >= v.x + v.width/2 ? 1 : 0)); me.selection.setStartOffset( i + ( offset.x >= v.x + v.width / 2 ? 1 : 0 ) );
}else{ } else {
me.selection.setStartOffset(i); me.selection.setStartOffset( i );
} }
me.selection.setEndOffset(me.index) me.selection.setEndOffset( me.index )
} }
return false; return false;
} }
}); } );
return this; return this;
}, },
updateSelectionShow:function(){ updateSelectionShow: function () {
var startOffset = this.textData[this.selection.startOffset], var startOffset = this.textData[ this.selection.startOffset ],
endOffset = this.textData[this.selection.endOffset], endOffset = this.textData[ this.selection.endOffset ],
width = 0 ; width = 0;
if(this.selection.collapsed){ if ( this.selection.collapsed ) {
this.selection.updateShow(startOffset||this.textData[this.textData.length-1],0); this.selection.updateShow( startOffset || this.textData[ this.textData.length - 1 ], 0 );
return this; return this;
} }
if(!endOffset){ if ( !endOffset ) {
var lastOffset = this.textData[this.textData.length -1]; var lastOffset = this.textData[ this.textData.length - 1 ];
width = lastOffset.x - startOffset.x + lastOffset.width; width = lastOffset.x - startOffset.x + lastOffset.width;
}else{ } else {
width = endOffset.x - startOffset.x; width = endOffset.x - startOffset.x;
} }
this.selection.updateShow(startOffset,width); this.selection.updateShow( startOffset, width );
return this; return this;
}, },
updateRange:function(range){ updateRange: function ( range ) {
var node = this.container.firstChild; var node = this.container.firstChild;
range.setStart(node,this.selection.startOffset); range.setStart( node, this.selection.startOffset );
range.setEnd(node,this.selection.endOffset); range.setEnd( node, this.selection.endOffset );
range.select(); range.select();
return this; return this;
}, },
setIndex:function(index){ setIndex: function ( index ) {
this.index = index; this.index = index;
return this return this
}, },
setContainerTxt:function(txt){ setContainerTxt: function ( txt ) {
this.container.textContent = txt; this.container.textContent = txt;
return this; return this;
} }
}); } );
//模拟光标 //模拟光标
Minder.Selection = kity.createClass( 'Selection', { Minder.Selection = kity.createClass( 'Selection', {
...@@ -4998,7 +5602,7 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -4998,7 +5602,7 @@ Minder.Selection = kity.createClass( 'Selection', {
constructor: function ( height, color, width ) { constructor: function ( height, color, width ) {
this.callBase(); this.callBase();
this.height = height || 20; this.height = height || 20;
this.setAttr('id','_kity_selection');
this.stroke( color || 'rgb(27,171,255)', width || 1 ); this.stroke( color || 'rgb(27,171,255)', width || 1 );
this.width = 0; this.width = 0;
this.fill('rgb(27,171,255)'); this.fill('rgb(27,171,255)');
...@@ -5016,7 +5620,7 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -5016,7 +5620,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.width = 1; this.width = 1;
this.collapsed = true; this.collapsed = true;
if(toEnd){ if(toEnd){
this.startOffset = this.endOffset this.startOffset = this.endOffset;
}else{ }else{
this.endOffset = this.startOffset; this.endOffset = this.startOffset;
} }
...@@ -5092,13 +5696,12 @@ Minder.Selection = kity.createClass( 'Selection', { ...@@ -5092,13 +5696,12 @@ Minder.Selection = kity.createClass( 'Selection', {
clearInterval( this.timer ); clearInterval( this.timer );
var me = this, var me = this,
state = ''; state = '';
me.setStyle( 'display', '' );
if(this.collapsed){ if(this.collapsed){
this.timer = setInterval( function () { this.timer = setInterval( function () {
me.setStyle( 'display', state ); me.setStyle( 'display', state );
state = state ? '' : 'none'; state = state ? '' : 'none';
}, 300 ); }, 400 );
}else{
me.setStyle( 'display', '' );
} }
return this; return this;
...@@ -5202,7 +5805,7 @@ KityMinder.registerModule( "basestylemodule", function () { ...@@ -5202,7 +5805,7 @@ KityMinder.registerModule( "basestylemodule", function () {
"italic": "ctrl+i" //italic "italic": "ctrl+i" //italic
}, },
"events": { "events": {
"beforeRenderNode": function ( e ) { "afterrendernodecenter": function ( e ) {
//加粗 //加粗
if ( e.node.getData( 'bold' ) ) { if ( e.node.getData( 'bold' ) ) {
e.node.getTextShape().setAttr( 'font-weight', 'bold' ); e.node.getTextShape().setAttr( 'font-weight', 'bold' );
...@@ -5308,7 +5911,7 @@ KityMinder.registerModule( "fontmodule", function () { ...@@ -5308,7 +5911,7 @@ KityMinder.registerModule( "fontmodule", function () {
}, },
"events": { "events": {
"beforeRenderNode": function ( e ) { "afterrendernodecenter": function ( e ) {
var val; var val;
if ( val = e.node.getData( 'fontfamily' ) ) { if ( val = e.node.getData( 'fontfamily' ) ) {
e.node.getTextShape().setAttr( 'font-family', val ); e.node.getTextShape().setAttr( 'font-family', val );
...@@ -5439,6 +6042,78 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -5439,6 +6042,78 @@ KityMinder.registerModule( 'Zoom', function () {
}; };
} ); } );
KityMinder.registerModule( "NodeText", function () {
return {
events: {
'renderNodeCenter': function ( e ) {
var node = e.node;
var width = node.getContRc().getWidth();
var textShape = new kity.Text( node.getData( 'text' ) || '' );
textShape.setAttr( '_nodeTextShape', true );
node.getContRc().appendShape( textShape );
var style = this.getCurrentLayoutStyle()[ node.getType() ];
textShape.fill( style.color ).setSize( style.fontSize );
textShape.setTranslate( width + style.spaceLeft, 0 );
textShape.setVerticalAlign( 'middle' );
}
}
}
} );
KityMinder.registerModule( "hyperlink", function () {
return {
"commands": {
"createlink" : kity.createClass( "hyperlink", {
base: Command,
execute: function (url) {
var nodes = km.getSelectedNodes();
if ( this.queryState( 'hyperlink' ) == 1 ) {
utils.each( nodes, function ( i, n ) {
n.setData( 'hyperlink' );
} )
} else {
utils.each( nodes, function ( i, n ) {
n.setData( 'hyperlink', url );
} )
}
},
queryState: function () {
var nodes = km.getSelectedNodes(),
result = 0;
if ( nodes.length == 0 ) {
return -1;
}
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'hyperlink' ) ) {
result = 1;
return false;
}
} );
return result;
}
} )
},
"events": {
"RenderNodeRight": function ( e ) {
var node = e.node,url;
if(url = node.getData('h')){
var link = new kity.HyperLink(url);
var rect = new kity.Rect();
var box = node.getContRc().getBoundaryBox();
rect.setWidth(10).setHeight(10).fill('#ccc').setPosition(box.x + box.width + 2,rect.getHeight()/-2);
link.appendChild(rect);
node.getContRc().appendChild(link);
}
}
}
};
} );
/*! jQuery UI - v1.10.4 - 2014-02-18 /*! jQuery UI - v1.10.4 - 2014-02-18
* http://jqueryui.com * http://jqueryui.com
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js
...@@ -6314,7 +6989,7 @@ KM.ui.define('colorpicker', { ...@@ -6314,7 +6989,7 @@ KM.ui.define('colorpicker', {
"<%}%>" + "<%}%>" +
"<%}%>" + "<%}%>" +
"<%for( var i=0, label; label = items[i]; i++ ) {%>" + "<%for( var i=0, label; label = items[i]; i++ ) {%>" +
"<li class=\"<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%><%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" + "<li class=\"<%=itemClassName%><%if( selected == i && enabledSelected ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%><%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" +
"<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" + "<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" + "<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" +
"</li>" + "</li>" +
...@@ -6335,7 +7010,8 @@ KM.ui.define('colorpicker', { ...@@ -6335,7 +7010,8 @@ KM.ui.define('colorpicker', {
autoRecord: true, autoRecord: true,
//最多记录条数 //最多记录条数
recordCount: 5, recordCount: 5,
enabledRecord:true enabledRecord:true,
enabledSelected:true
}, },
init: function( options ){ init: function( options ){
...@@ -7404,14 +8080,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -7404,14 +8080,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
itemStyles: [], itemStyles: [],
value: [], value: [],
autowidthitem: [], autowidthitem: [],
enabledRecord: false enabledRecord: false,
enabledSelected: false
}, },
$combox = null, $combox = null,
comboboxWidget = null; comboboxWidget = null;
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) { utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k ); var p = KityMinder.findProtocal( k );
if( p.encode ){ if ( p.encode ) {
var text = p.fileDescription + '(' + p.fileExtension + ')'; var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k ); options.value.push( k );
options.items.push( text ); options.items.push( text );
...@@ -7428,20 +8105,59 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -7428,20 +8105,59 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var a = document.createElement( 'a' ); var a = document.createElement( 'a' );
a.setAttribute( 'download', filename ); a.setAttribute( 'download', filename );
a.setAttribute( 'href', url ); a.setAttribute( 'href', url );
a.dispatchEvent( new MouseEvent( 'click' ) ); var evt;
try {
evt = new MouseEvent( 'click' );
} catch ( error ) {
evt = document.createEvent( 'MouseEvents' );
evt.initEvent( 'click', true, true );
}
a.dispatchEvent( evt );
} }
var ie_ver = function () {
var iev = 0;
var ieold = ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) );
var trident = !! navigator.userAgent.match( /Trident\/7.0/ );
var rv = navigator.userAgent.indexOf( "rv:11.0" );
if ( ieold ) iev = new Number( RegExp.$1 );
if ( navigator.appVersion.indexOf( "MSIE 10" ) != -1 ) iev = 10;
if ( trident && rv != -1 ) iev = 11;
return iev;
};
var doSave = function ( urltype, d, filename ) {
var iframe = document.createElement( 'iframe' );
iframe.style.display = 'none';
document.body.appendChild( iframe );
iframe.contentDocument.open( urltype, 'replace' );
iframe.contentDocument.writeln( d );
iframe.contentDocument.execCommand( 'saveas', '', filename );
};
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value ); var data = me.exportData( res.value );
var p = KityMinder.findProtocal( res.value ); var p = KityMinder.findProtocal( res.value );
var filename = me.getMinderTitle() + p.fileExtension; var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) { if ( typeof ( data ) == 'string' ) {
var url = 'data:text/plain; utf-8,' + encodeURI( data ); var url = 'data:text/plain; utf-8,' + encodeURIComponent( data );
if ( ie_ver() > 0 ) {
//console.log( p.fileExtension );
if ( p.fileExtension === '.km' ) {
doSave( 'application/x-javascript', data, me.getMinderTitle() );
} else if ( p.fileExtension === '.svg' ) {
//doSave( 'image/svg+xml', data, filename );
} else {
doSave( 'text/html', data, filename );
}
} else {
doDownload( url, filename ); doDownload( url, filename );
}
} else if ( data && data.then ) { } else if ( data && data.then ) {
data.then( function ( url ) { data.then( function ( url ) {
if ( ie_ver() > 0 ) {
//doSave( 'application/base64', url.replace( 'image/octet-stream,', '' ), filename );
} else {
doDownload( url, filename ); doDownload( url, filename );
}
} ); } );
} }
} ).on( "beforeshow", function () { } ).on( "beforeshow", function () {
...@@ -7572,7 +8288,8 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -7572,7 +8288,8 @@ KM.registerToolbarUI( 'node', function ( name ) {
var shortcutKeys = { var shortcutKeys = {
"appendsiblingnode": "enter", "appendsiblingnode": "enter",
"appendchildnode": "tab", "appendchildnode": "tab",
"removenode": "del|backspace" "removenode": "del|backspace",
"editnode": "F2"
}; };
var me = this, var me = this,
...@@ -7616,12 +8333,12 @@ KM.registerToolbarUI( 'node', function ( name ) { ...@@ -7616,12 +8333,12 @@ KM.registerToolbarUI( 'node', function ( name ) {
//状态反射 //状态反射
me.on( 'interactchange', function () { me.on( 'interactchange', function () {
var state = 0; var state = 0;
utils.each(shortcutKeys,function(k){ utils.each( shortcutKeys, function ( k ) {
state = me.queryCommandState(k); state = me.queryCommandState( k );
if(state!=-1){ if ( state != -1 ) {
return false; return false;
} }
}); } );
//设置按钮状态 //设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 ); comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
...@@ -7721,7 +8438,7 @@ KM.registerUI( 'contextmenu', function () { ...@@ -7721,7 +8438,7 @@ KM.registerUI( 'contextmenu', function () {
KM.registerToolbarUI( 'markers help', function ( name ) { KM.registerToolbarUI( 'markers help preference', function ( name ) {
var me = this, var me = this,
currentRange, $dialog, currentRange, $dialog,
...@@ -7981,68 +8698,69 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -7981,68 +8698,69 @@ KityMinder.registerProtocal( 'mindmanager', function () {
// 标签 map // 标签 map
var markerMap = { var markerMap = {
'urn:mindjet:Prio1' : ['PriorityIcon', 1] 'urn:mindjet:Prio1': [ 'PriorityIcon', 1 ],
,'urn:mindjet:Prio2' : ['PriorityIcon', 2] 'urn:mindjet:Prio2': [ 'PriorityIcon', 2 ],
,'urn:mindjet:Prio3' : ['PriorityIcon', 3] 'urn:mindjet:Prio3': [ 'PriorityIcon', 3 ],
,'urn:mindjet:Prio4' : ['PriorityIcon', 4] 'urn:mindjet:Prio4': [ 'PriorityIcon', 4 ],
,'urn:mindjet:Prio5' : ['PriorityIcon', 5] 'urn:mindjet:Prio5': [ 'PriorityIcon', 5 ],
'0': [ 'ProgressIcon', 1 ],
,'0' : ['ProgressIcon', 1] '25': [ 'ProgressIcon', 2 ],
,'25' : ['ProgressIcon', 2] '50': [ 'ProgressIcon', 3 ],
,'50' : ['ProgressIcon', 3] '75': [ 'ProgressIcon', 4 ],
,'75' : ['ProgressIcon', 4] '100': [ 'ProgressIcon', 5 ]
,'100' : ['ProgressIcon', 5]
}; };
function processTopic(topic, obj){ function processTopic( topic, obj ) {
//处理文本 //处理文本
obj.data = { text : topic.Text && topic.Text.PlainText || '' }; // 节点默认的文本,没有Text属性 obj.data = {
text: topic.Text && topic.Text.PlainText || ''
}; // 节点默认的文本,没有Text属性
// 处理标签 // 处理标签
if(topic.Task){ if ( topic.Task ) {
var type; var type;
if(topic.Task.TaskPriority){ if ( topic.Task.TaskPriority ) {
type = markerMap[ topic.Task.TaskPriority ]; type = markerMap[ topic.Task.TaskPriority ];
type && (obj.data[ type[0] ] = type[1]); type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
} }
if(topic.Task.TaskPercentage){ if ( topic.Task.TaskPercentage ) {
type = markerMap[ topic.Task.TaskPercentage ]; type = markerMap[ topic.Task.TaskPercentage ];
type && (obj.data[ type[0] ] = type[1]); type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
} }
} }
//处理子节点 //处理子节点
if( topic.SubTopics && topic.SubTopics.Topic ){ if ( topic.SubTopics && topic.SubTopics.Topic ) {
var tmp = topic.SubTopics.Topic; var tmp = topic.SubTopics.Topic;
if( tmp.length && tmp.length > 0 ){ //多个子节点 if ( tmp.length && tmp.length > 0 ) { //多个子节点
obj.children = []; obj.children = [];
for(var i in tmp){ for ( var i in tmp ) {
obj.children.push({}); obj.children.push( {} );
processTopic(tmp[i], obj.children[i]); processTopic( tmp[ i ], obj.children[ i ] );
} }
}else{ //一个子节点 } else { //一个子节点
obj.children = [{}]; obj.children = [ {} ];
processTopic(tmp, obj.children[0]); processTopic( tmp, obj.children[ 0 ] );
} }
} }
} }
function xml2km(xml){ function xml2km( xml ) {
var json = $.xml2json(xml); var json = $.xml2json( xml );
var result = {}; var result = {};
processTopic(json.OneTopic.Topic, result); processTopic( json.OneTopic.Topic, result );
return result; return result;
} }
function getEntries(file, onend) { function getEntries( file, onend ) {
zip.createReader(new zip.BlobReader(file), function(zipReader) { zip.createReader( new zip.BlobReader( file ), function ( zipReader ) {
zipReader.getEntries(onend); zipReader.getEntries( onend );
}, onerror); }, onerror );
} }
return { return {
...@@ -8052,18 +8770,18 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -8052,18 +8770,18 @@ KityMinder.registerProtocal( 'mindmanager', function () {
decode: function ( local ) { decode: function ( local ) {
return { return {
then : function(local, callback){ then: function ( local, callback ) {
getEntries( local, function( entries ) { getEntries( local, function ( entries ) {
entries.forEach(function( entry ) { entries.forEach( function ( entry ) {
if(entry.filename == 'Document.xml'){ if ( entry.filename == 'Document.xml' ) {
entry.getData(new zip.TextWriter(), function(text) { entry.getData( new zip.TextWriter(), function ( text ) {
var km = xml2km($.parseXML(text)); var km = xml2km( $.parseXML( text ) );
callback && callback( km ); callback && callback( km );
}); } );
} }
}); } );
}); } );
} }
}; };
...@@ -8074,9 +8792,6 @@ KityMinder.registerProtocal( 'mindmanager', function () { ...@@ -8074,9 +8792,6 @@ KityMinder.registerProtocal( 'mindmanager', function () {
} ); } );
KityMinder.registerProtocal( "plain", function () { KityMinder.registerProtocal( "plain", function () {
var LINE_ENDING = '\n', var LINE_ENDING = '\n',
TAB_CHAR = '\t'; TAB_CHAR = '\t';
...@@ -8207,11 +8922,12 @@ KityMinder.registerProtocal( "png", function () { ...@@ -8207,11 +8922,12 @@ KityMinder.registerProtocal( "png", function () {
function loadImage( url, callback ) { function loadImage( url, callback ) {
var image = new Image(); var image = new Image();
image.onload = callback; image.onload = callback;
console.log( url );
image.src = url; image.src = url;
} }
return { return {
fileDescription: 'PNG 图片', fileDescription: 'PNG 图片(暂不支持IE)',
fileExtension: '.png', fileExtension: '.png',
encode: function ( json, km ) { encode: function ( json, km ) {
var domContainer = km.getPaper().container, var domContainer = km.getPaper().container,
...@@ -8232,7 +8948,7 @@ KityMinder.registerProtocal( "png", function () { ...@@ -8232,7 +8948,7 @@ KityMinder.registerProtocal( "png", function () {
ctx = canvas.getContext( '2d' ), ctx = canvas.getContext( '2d' ),
blob, DomURL, url, img, finishCallback; blob, DomURL, url, img, finishCallback;
bgUrl = bgUrl.replace( /"/g, '' );
renderContainer.translate( -renderBox.x, -renderBox.y ); renderContainer.translate( -renderBox.x, -renderBox.y );
svgXml = km.getPaper().container.innerHTML; svgXml = km.getPaper().container.innerHTML;
...@@ -8243,14 +8959,14 @@ KityMinder.registerProtocal( "png", function () { ...@@ -8243,14 +8959,14 @@ KityMinder.registerProtocal( "png", function () {
$svg.attr( { $svg.attr( {
width: renderBox.width, width: renderBox.width,
height: renderBox.height, height: renderBox.height,
style: 'font-family: Arial, "Heiti SC", "Microsoft Yahei";' style: 'font-family: Arial, "Microsoft Yahei","Heiti SC";'
} ); } );
// need a xml with width and height // need a xml with width and height
svgXml = $( '<div></div' ).append( $svg ).html(); svgXml = $( '<div></div>' ).append( $svg ).html();
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined // svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;'); svgXml = svgXml.replace( /&nbsp;/g, '&#xa0;' );
blob = new Blob( [ svgXml ], { blob = new Blob( [ svgXml ], {
type: "image/svg+xml;charset=utf-8" type: "image/svg+xml;charset=utf-8"
...@@ -8278,7 +8994,6 @@ KityMinder.registerProtocal( "png", function () { ...@@ -8278,7 +8994,6 @@ KityMinder.registerProtocal( "png", function () {
var url = canvas.toDataURL( 'png' ); var url = canvas.toDataURL( 'png' );
return url.replace( 'image/png', 'image/octet-stream' ); return url.replace( 'image/png', 'image/octet-stream' );
} }
loadImage( url, function () { loadImage( url, function () {
var svgImage = this; var svgImage = this;
loadImage( bgUrl, function () { loadImage( bgUrl, function () {
...@@ -8305,7 +9020,7 @@ KityMinder.registerProtocal( "png", function () { ...@@ -8305,7 +9020,7 @@ KityMinder.registerProtocal( "png", function () {
KityMinder.registerProtocal( "svg", function () { KityMinder.registerProtocal( "svg", function () {
return { return {
fileDescription: 'SVG 矢量图', fileDescription: 'SVG 矢量图(暂不支持IE)',
fileExtension: '.svg', fileExtension: '.svg',
encode: function ( json, km ) { encode: function ( json, km ) {
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined // svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
......
This source diff could not be displayed because it is too large. You can view the blob instead.
KityMinder.LANG[ 'zh-cn' ] = {
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
'undo': '撤销',
'redo': '重做',
'bold': '加粗',
'italic': '斜体',
'forecolor': '字体颜色',
'fontfamily': '字体',
'fontsize': '字号',
'layoutstyle': '主题',
'node': '节点操作',
'saveto': '导出',
'hand': '允许拖拽',
'zoom-in': '放大',
'zoom-out': '缩小',
'markers': '添加标签',
'switchlayout': '切换主题',
'help': '帮助',
'preference': '偏好设置'
},
'popupcolor': {
'clearColor': '清空颜色',
'standardColor': '标准颜色',
'themeColor': '主题颜色'
},
'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': '已完成'
}
},
'help': {
}
},
'node': {
'appendsiblingnode': '插入同级节点',
'appendchildnode': '插入子节点',
'removenode': '删除节点',
'editnode': '编辑节点'
},
'layout': {
'default': '左右展开',
'bottom': '向下展开'
}
};
\ No newline at end of file
/*!
* ZeroClipboard
* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
* Copyright (c) 2013 Jon Rohan, James M. Greene
* Licensed MIT
* http://zeroclipboard.org/
* v1.2.3
*/
!function(){"use strict";var a,b=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),c=function(a,c){var d,e,f,g,h,i;if(window.getComputedStyle?d=window.getComputedStyle(a,null).getPropertyValue(c):(e=b(c),d=a.currentStyle?a.currentStyle[e]:a.style[e]),"cursor"===c&&(!d||"auto"===d))for(f=a.tagName.toLowerCase(),g=["a"],h=0,i=g.length;i>h;h++)if(f===g[h])return"pointer";return d},d=function(a){if(p.prototype._singleton){a||(a=window.event);var b;this!==window?b=this:a.target?b=a.target:a.srcElement&&(b=a.srcElement),p.prototype._singleton.setCurrent(b)}},e=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)},f=function(a,b,c){a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c)},g=function(a,b){if(a.addClass)return a.addClass(b),a;if(b&&"string"==typeof b){var c=(b||"").split(/\s+/);if(1===a.nodeType)if(a.className){for(var d=" "+a.className+" ",e=a.className,f=0,g=c.length;g>f;f++)d.indexOf(" "+c[f]+" ")<0&&(e+=" "+c[f]);a.className=e.replace(/^\s+|\s+$/g,"")}else a.className=b}return a},h=function(a,b){if(a.removeClass)return a.removeClass(b),a;if(b&&"string"==typeof b||void 0===b){var c=(b||"").split(/\s+/);if(1===a.nodeType&&a.className)if(b){for(var d=(" "+a.className+" ").replace(/[\n\t]/g," "),e=0,f=c.length;f>e;e++)d=d.replace(" "+c[e]+" "," ");a.className=d.replace(/^\s+|\s+$/g,"")}else a.className=""}return a},i=function(){var a,b,c,d=1;return"function"==typeof document.body.getBoundingClientRect&&(a=document.body.getBoundingClientRect(),b=a.right-a.left,c=document.body.offsetWidth,d=Math.round(100*(b/c))/100),d},j=function(a){var b={left:0,top:0,width:0,height:0,zIndex:999999999},d=c(a,"z-index");if(d&&"auto"!==d&&(b.zIndex=parseInt(d,10)),a.getBoundingClientRect){var e,f,g,h=a.getBoundingClientRect();"pageXOffset"in window&&"pageYOffset"in window?(e=window.pageXOffset,f=window.pageYOffset):(g=i(),e=Math.round(document.documentElement.scrollLeft/g),f=Math.round(document.documentElement.scrollTop/g));var j=document.documentElement.clientLeft||0,k=document.documentElement.clientTop||0;b.left=h.left+e-j,b.top=h.top+f-k,b.width="width"in h?h.width:h.right-h.left,b.height="height"in h?h.height:h.bottom-h.top}return b},k=function(a,b){var c=!(b&&b.useNoCache===!1);return c?(-1===a.indexOf("?")?"?":"&")+"nocache="+(new Date).getTime():""},l=function(a){var b=[],c=[];return a.trustedOrigins&&("string"==typeof a.trustedOrigins?c.push(a.trustedOrigins):"object"==typeof a.trustedOrigins&&"length"in a.trustedOrigins&&(c=c.concat(a.trustedOrigins))),a.trustedDomains&&("string"==typeof a.trustedDomains?c.push(a.trustedDomains):"object"==typeof a.trustedDomains&&"length"in a.trustedDomains&&(c=c.concat(a.trustedDomains))),c.length&&b.push("trustedOrigins="+encodeURIComponent(c.join(","))),"string"==typeof a.amdModuleId&&a.amdModuleId&&b.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),"string"==typeof a.cjsModuleId&&a.cjsModuleId&&b.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),b.join("&")},m=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;d>c;c++)if(b[c]===a)return c;return-1},n=function(a){if("string"==typeof a)throw new TypeError("ZeroClipboard doesn't accept query strings.");return a.length?a:[a]},o=function(a,b,c,d,e){e?window.setTimeout(function(){a.call(b,c,d)},0):a.call(b,c,d)},p=function(a,b){if(a&&(p.prototype._singleton||this).glue(a),p.prototype._singleton)return p.prototype._singleton;p.prototype._singleton=this,this.options={};for(var c in s)this.options[c]=s[c];for(var d in b)this.options[d]=b[d];this.handlers={},p.detectFlashSupport()&&v()},q=[];p.prototype.setCurrent=function(b){a=b,this.reposition();var d=b.getAttribute("title");d&&this.setTitle(d);var e=this.options.forceHandCursor===!0||"pointer"===c(b,"cursor");return r.call(this,e),this},p.prototype.setText=function(a){return a&&""!==a&&(this.options.text=a,this.ready()&&this.flashBridge.setText(a)),this},p.prototype.setTitle=function(a){return a&&""!==a&&this.htmlBridge.setAttribute("title",a),this},p.prototype.setSize=function(a,b){return this.ready()&&this.flashBridge.setSize(a,b),this},p.prototype.setHandCursor=function(a){return a="boolean"==typeof a?a:!!a,r.call(this,a),this.options.forceHandCursor=a,this};var r=function(a){this.ready()&&this.flashBridge.setHandCursor(a)};p.version="1.2.3";var s={moviePath:"ZeroClipboard.swf",trustedOrigins:null,text:null,hoverClass:"zeroclipboard-is-hover",activeClass:"zeroclipboard-is-active",allowScriptAccess:"sameDomain",useNoCache:!0,forceHandCursor:!1};p.setDefaults=function(a){for(var b in a)s[b]=a[b]},p.destroy=function(){p.prototype._singleton.unglue(q);var a=p.prototype._singleton.htmlBridge;a.parentNode.removeChild(a),delete p.prototype._singleton},p.detectFlashSupport=function(){var a=!1;if("function"==typeof ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(a=!0)}catch(b){}return!a&&navigator.mimeTypes["application/x-shockwave-flash"]&&(a=!0),a};var t=null,u=null,v=function(){var a,b,c=p.prototype._singleton,d=document.getElementById("global-zeroclipboard-html-bridge");if(!d){var e={};for(var f in c.options)e[f]=c.options[f];e.amdModuleId=t,e.cjsModuleId=u;var g=l(e),h=' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="'+c.options.moviePath+k(c.options.moviePath,c.options)+'"/> <param name="allowScriptAccess" value="'+c.options.allowScriptAccess+'"/> <param name="scale" value="exactfit"/> <param name="loop" value="false"/> <param name="menu" value="false"/> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff"/> <param name="wmode" value="transparent"/> <param name="flashvars" value="'+g+'"/> <embed src="'+c.options.moviePath+k(c.options.moviePath,c.options)+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+g+'" scale="exactfit"> </embed> </object>';d=document.createElement("div"),d.id="global-zeroclipboard-html-bridge",d.setAttribute("class","global-zeroclipboard-container"),d.setAttribute("data-clipboard-ready",!1),d.style.position="absolute",d.style.left="-9999px",d.style.top="-9999px",d.style.width="15px",d.style.height="15px",d.style.zIndex="9999",d.innerHTML=h,document.body.appendChild(d)}c.htmlBridge=d,a=document["global-zeroclipboard-flash-bridge"],a&&(b=a.length)&&(a=a[b-1]),c.flashBridge=a||d.children[0].lastElementChild};p.prototype.resetBridge=function(){return this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),h(a,this.options.activeClass),a=null,this.options.text=null,this},p.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return"true"===a||a===!0},p.prototype.reposition=function(){if(!a)return!1;var b=j(a);return this.htmlBridge.style.top=b.top+"px",this.htmlBridge.style.left=b.left+"px",this.htmlBridge.style.width=b.width+"px",this.htmlBridge.style.height=b.height+"px",this.htmlBridge.style.zIndex=b.zIndex+1,this.setSize(b.width,b.height),this},p.dispatch=function(a,b){p.prototype._singleton.receiveEvent(a,b)},p.prototype.on=function(a,b){for(var c=a.toString().split(/\s/g),d=0;d<c.length;d++)a=c[d].toLowerCase().replace(/^on/,""),this.handlers[a]||(this.handlers[a]=b);return this.handlers.noflash&&!p.detectFlashSupport()&&this.receiveEvent("onNoFlash",null),this},p.prototype.addEventListener=p.prototype.on,p.prototype.off=function(a,b){for(var c=a.toString().split(/\s/g),d=0;d<c.length;d++){a=c[d].toLowerCase().replace(/^on/,"");for(var e in this.handlers)e===a&&this.handlers[e]===b&&delete this.handlers[e]}return this},p.prototype.removeEventListener=p.prototype.off,p.prototype.receiveEvent=function(b,c){b=b.toString().toLowerCase().replace(/^on/,"");var d=a,e=!0;switch(b){case"load":if(c&&parseFloat(c.flashVersion.replace(",",".").replace(/[^0-9\.]/gi,""))<10)return this.receiveEvent("onWrongFlash",{flashVersion:c.flashVersion}),void 0;this.htmlBridge.setAttribute("data-clipboard-ready",!0);break;case"mouseover":g(d,this.options.hoverClass);break;case"mouseout":h(d,this.options.hoverClass),this.resetBridge();break;case"mousedown":g(d,this.options.activeClass);break;case"mouseup":h(d,this.options.activeClass);break;case"datarequested":var f=d.getAttribute("data-clipboard-target"),i=f?document.getElementById(f):null;if(i){var j=i.value||i.textContent||i.innerText;j&&this.setText(j)}else{var k=d.getAttribute("data-clipboard-text");k&&this.setText(k)}e=!1;break;case"complete":this.options.text=null}if(this.handlers[b]){var l=this.handlers[b];"string"==typeof l&&"function"==typeof window[l]&&(l=window[l]),"function"==typeof l&&o(l,d,this,c,e)}},p.prototype.glue=function(a){a=n(a);for(var b=0;b<a.length;b++)-1==m(a[b],q)&&(q.push(a[b]),e(a[b],"mouseover",d));return this},p.prototype.unglue=function(a){a=n(a);for(var b=0;b<a.length;b++){f(a[b],"mouseover",d);var c=m(a[b],q);-1!=c&&q.splice(c,1)}return this},"function"==typeof define&&define.amd?define(["require","exports","module"],function(a,b,c){return t=c&&c.id||null,p}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?(u=module.id||null,module.exports=p):window.ZeroClipboard=p}();
\ No newline at end of file
var baidu = baidu || {};
baidu.frontia = {}, function(e) {
baidu.frontia.version = "1.0.0", baidu.frontia.serviceHost = {PCS: "https://c.pcs.baidu.com",Frontia: "https://frontia.baidu.com",PBLog: "http://frontialog.smrapp.baidu.com",Social: "https://openapi.baidu.com"}, baidu.frontia.currentAccount = null, baidu.frontia.apiKey = null, baidu.frontia._CURRENT_USER_KEY = "currentUser", "undefined" != typeof localStorage && (baidu.frontia.localStorage = localStorage), baidu.frontia.DomainManager = {getSocialDomain: function() {
return baidu.frontia.serviceHost.Social
},getPCSDomain: function() {
return baidu.frontia.serviceHost.PCS
},getFrontiaDomain: function() {
return baidu.frontia.serviceHost.Frontia
},getPBLogDomain: function() {
return baidu.frontia.serviceHost.PBLog
}}, baidu.frontia.Base = Object.defineProperty(function() {
}, "extend", {value: function(e, t) {
var r = e && e.hasOwnProperty("constructor") ? e.constructor : this, n = function() {
r.apply(this, arguments)
};
if (n.prototype = function(e, t) {
return Object.getOwnPropertyNames(t).forEach(function(r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r))
}), e
}(Object.create(this.prototype), e || {}), t)
for (var a in t)
t.hasOwnProperty(a) && (n[a] = t[a]);
return Object.defineProperty(n, "extend", Object.getOwnPropertyDescriptor(this, "extend")), n
}}), baidu.frontia.Object = baidu.frontia.Base.extend({acl: null,constructor: function(t) {
if (t && !(t instanceof e.ACL))
throw new Error("[construct ]: acl is invalid");
this.acl = t || null
},setAcl: function(t) {
if (t && !(t instanceof e.ACL))
throw new Error("[setAcl ]: acl is invalid");
this.acl = t || null
},getACL: function() {
return this.acl
},_getACLInfo: function() {
var t = null;
return this.acl instanceof e.ACL && (t = this.acl.toJSON()), t
}}), baidu.frontia.setCurrentAccount = function(t) {
if (!(t instanceof e.User || t instanceof e.Role))
throw new Error("[setCurrentAccount]: account is invalid");
var r = t.toJSON();
baidu.frontia.localStorage.setItem(baidu.frontia._getLocalStorageKey(baidu.frontia._CURRENT_USER_KEY), JSON.stringify(r)), baidu.frontia.currentAccount = t
}, baidu.frontia.logOutCurrentAccount = function() {
baidu.frontia.currentAccount = null, baidu.frontia.localStorage.removeItem(baidu.frontia._getLocalStorageKey(baidu.frontia._CURRENT_USER_KEY))
}, baidu.frontia.getCurrentAccount = function() {
if (baidu.frontia.currentAccount)
return baidu.frontia.currentAccount;
var e = baidu.frontia.localStorage.getItem(baidu.frontia._getLocalStorageKey(baidu.frontia._CURRENT_USER_KEY));
if (!e)
return null;
var t = JSON.parse(e);
return "user" === t.type ? new baidu.frontia.User({socialId: t.socialId,accessToken: t.accessToken,name: t.name,mediaType: t.mediaType,expiresIn: t.expiresIn}) : new baidu.frontia.Role(t.roleId)
}, baidu.frontia.init = function(e) {
if (!e)
throw new Error("[init]: apiKey is invaild");
baidu.frontia.apiKey = e
}, baidu.frontia.getApiKey = function() {
return baidu.frontia.apiKey
}, baidu.frontia._getLocalStorageKey = function(e) {
if (!baidu.frontia.apiKey)
throw "Should call baidu.frontia.init before using baidu.frontia";
if (e || (e = ""), "string" != typeof e)
throw "userKey must be a string when getting localStorage key";
return "baidu.frontia/" + baidu.frontia.apiKey + "/" + e
}
}(baidu.frontia), "undefined" != typeof module && module.exports && (module.exports = baidu), baidu.frontia.error = baidu.frontia.error || {}, function() {
baidu.frontia.error = function(e, t) {
t = t || "error", this.code = e.error_code || e.Code, this.message = e.error_msg || e.Message, this.message += " [" + t + "]"
}, baidu.frontia.ERR_MSG = {NO_AK: {error_code: -1,error_msg: "No AK found, please config AK by calling BaiduFrontia.init(yourak) at first"},INVALID_AK: {error_code: -1,error_msg: "Invalid AK"},INVALID_PARAMS: {error_code: -1,error_msg: "Invalid params"},INVALID_RES_TYPE: {error_code: -1,error_msg: "Invalid params: response_type"},INVALID_MEDIA_TYPE: {error_code: -1,error_msg: "Invalid params: media_type"}}
}(baidu.frontia), function() {
"use strict";
function e(e, t) {
var r = e.split("."), n = g;
!(r[0] in n) && n.execScript && n.execScript("var " + r[0]);
for (var a; r.length && (a = r.shift()); )
r.length || t === h ? n = n[a] ? n[a] : n[a] = {} : n[a] = t
}
function t(e, t) {
if (this.index = "number" == typeof t ? t : 0, this.f = 0, this.buffer = e instanceof (m ? Uint8Array : Array) ? e : new (m ? Uint8Array : Array)(32768), 2 * this.buffer.length <= this.index)
throw Error("invalid index");
this.buffer.length <= this.index && r(this)
}
function r(e) {
var t, r = e.buffer, n = r.length, a = new (m ? Uint8Array : Array)(n << 1);
if (m)
a.set(r);
else
for (t = 0; n > t; ++t)
a[t] = r[t];
return e.buffer = a
}
function n(e, t, r) {
var n, a = "number" == typeof t ? t : t = 0, o = "number" == typeof r ? r : e.length;
for (n = -1, a = 7 & o; a--; ++t)
n = n >>> 8 ^ S[255 & (n ^ e[t])];
for (a = o >> 3; a--; t += 8)
n = n >>> 8 ^ S[255 & (n ^ e[t])], n = n >>> 8 ^ S[255 & (n ^ e[t + 1])], n = n >>> 8 ^ S[255 & (n ^ e[t + 2])], n = n >>> 8 ^ S[255 & (n ^ e[t + 3])], n = n >>> 8 ^ S[255 & (n ^ e[t + 4])], n = n >>> 8 ^ S[255 & (n ^ e[t + 5])], n = n >>> 8 ^ S[255 & (n ^ e[t + 6])], n = n >>> 8 ^ S[255 & (n ^ e[t + 7])];
return (4294967295 ^ n) >>> 0
}
function a(e) {
this.buffer = new (m ? Uint16Array : Array)(2 * e), this.length = 0
}
function o(e, t) {
this.h = j, this.j = 0, this.input = m && e instanceof Array ? new Uint8Array(e) : e, this.c = 0, t && (t.lazy && (this.j = t.lazy), "number" == typeof t.compressionType && (this.h = t.compressionType), t.outputBuffer && (this.a = m && t.outputBuffer instanceof Array ? new Uint8Array(t.outputBuffer) : t.outputBuffer), "number" == typeof t.outputIndex && (this.c = t.outputIndex)), this.a || (this.a = new (m ? Uint8Array : Array)(32768))
}
function i(e, t) {
this.length = e, this.k = t
}
function s(e, t) {
function r(e, t) {
var r, n = e.k, a = [], o = 0;
r = O[e.length], a[o++] = 65535 & r, a[o++] = 255 & r >> 16, a[o++] = r >> 24;
var i;
switch (d) {
case 1 === n:
i = [0, n - 1, 0];
break;
case 2 === n:
i = [1, n - 2, 0];
break;
case 3 === n:
i = [2, n - 3, 0];
break;
case 4 === n:
i = [3, n - 4, 0];
break;
case 6 >= n:
i = [4, n - 5, 1];
break;
case 8 >= n:
i = [5, n - 7, 1];
break;
case 12 >= n:
i = [6, n - 9, 2];
break;
case 16 >= n:
i = [7, n - 13, 2];
break;
case 24 >= n:
i = [8, n - 17, 3];
break;
case 32 >= n:
i = [9, n - 25, 3];
break;
case 48 >= n:
i = [10, n - 33, 4];
break;
case 64 >= n:
i = [11, n - 49, 4];
break;
case 96 >= n:
i = [12, n - 65, 5];
break;
case 128 >= n:
i = [13, n - 97, 5];
break;
case 192 >= n:
i = [14, n - 129, 6];
break;
case 256 >= n:
i = [15, n - 193, 6];
break;
case 384 >= n:
i = [16, n - 257, 7];
break;
case 512 >= n:
i = [17, n - 385, 7];
break;
case 768 >= n:
i = [18, n - 513, 8];
break;
case 1024 >= n:
i = [19, n - 769, 8];
break;
case 1536 >= n:
i = [20, n - 1025, 9];
break;
case 2048 >= n:
i = [21, n - 1537, 9];
break;
case 3072 >= n:
i = [22, n - 2049, 10];
break;
case 4096 >= n:
i = [23, n - 3073, 10];
break;
case 6144 >= n:
i = [24, n - 4097, 11];
break;
case 8192 >= n:
i = [25, n - 6145, 11];
break;
case 12288 >= n:
i = [26, n - 8193, 12];
break;
case 16384 >= n:
i = [27, n - 12289, 12];
break;
case 24576 >= n:
i = [28, n - 16385, 13];
break;
case 32768 >= n:
i = [29, n - 24577, 13];
break;
default:
throw "invalid distance"
}
r = i, a[o++] = r[0], a[o++] = r[1], a[o++] = r[2];
var s, c;
for (s = 0, c = a.length; c > s; ++s)
y[_++] = a[s];
v[a[0]]++, b[a[3]]++, A = e.length + t - 1, l = null
}
var n, a, o, i, s, u, f, l, p, g = {}, y = m ? new Uint16Array(2 * t.length) : [], _ = 0, A = 0, v = new (m ? Uint32Array : Array)(286), b = new (m ? Uint32Array : Array)(30), w = e.j;
if (!m) {
for (o = 0; 285 >= o; )
v[o++] = 0;
for (o = 0; 29 >= o; )
b[o++] = 0
}
for (v[256] = 1, n = 0, a = t.length; a > n; ++n) {
for (o = s = 0, i = 3; i > o && n + o !== a; ++o)
s = s << 8 | t[n + o];
if (g[s] === h && (g[s] = []), u = g[s], !(0 < A--)) {
for (; 0 < u.length && 32768 < n - u[0]; )
u.shift();
if (n + 3 >= a) {
for (l && r(l, -1), o = 0, i = a - n; i > o; ++o)
p = t[n + o], y[_++] = p, ++v[p];
break
}
0 < u.length ? (f = c(t, n, u), l ? l.length < f.length ? (p = t[n - 1], y[_++] = p, ++v[p], r(f, 0)) : r(l, -1) : f.length < w ? l = f : r(f, 0)) : l ? r(l, -1) : (p = t[n], y[_++] = p, ++v[p])
}
u.push(n)
}
return y[_++] = 256, v[256]++, e.n = v, e.m = b, m ? y.subarray(0, _) : y
}
function c(e, t, r) {
var n, a, o, s, c, u, f = 0, l = e.length;
s = 0, u = r.length;
e: for (; u > s; s++) {
if (n = r[u - s - 1], o = 3, f > 3) {
for (c = f; c > 3; c--)
if (e[n + c - 1] !== e[t + c - 1])
continue e;
o = f
}
for (; 258 > o && l > t + o && e[n + o] === e[t + o]; )
++o;
if (o > f && (a = n, f = o), 258 === o)
break
}
return new i(f, t - a)
}
function u(e, t) {
var r, n, o, i, s, c = e.length, u = new a(572), l = new (m ? Uint8Array : Array)(c);
if (!m)
for (i = 0; c > i; i++)
l[i] = 0;
for (i = 0; c > i; ++i)
0 < e[i] && u.push(i, e[i]);
if (r = Array(u.length / 2), n = new (m ? Uint32Array : Array)(u.length / 2), 1 === r.length)
return l[u.pop().index] = 1, l;
for (i = 0, s = u.length / 2; s > i; ++i)
r[i] = u.pop(), n[i] = r[i].value;
for (o = f(n, n.length, t), i = 0, s = r.length; s > i; ++i)
l[r[i].index] = o[i];
return l
}
function f(e, t, r) {
function n(e) {
var r = h[e][d[e]];
r === t ? (n(e + 1), n(e + 1)) : --l[r], ++d[e]
}
var a, o, i, s, c, u = new (m ? Uint16Array : Array)(r), f = new (m ? Uint8Array : Array)(r), l = new (m ? Uint8Array : Array)(t), p = Array(r), h = Array(r), d = Array(r), g = (1 << r) - t, y = 1 << r - 1;
for (u[r - 1] = t, o = 0; r > o; ++o)
y > g ? f[o] = 0 : (f[o] = 1, g -= y), g <<= 1, u[r - 2 - o] = (0 | u[r - 1 - o] / 2) + t;
for (u[0] = f[0], p[0] = Array(u[0]), h[0] = Array(u[0]), o = 1; r > o; ++o)
u[o] > 2 * u[o - 1] + f[o] && (u[o] = 2 * u[o - 1] + f[o]), p[o] = Array(u[o]), h[o] = Array(u[o]);
for (a = 0; t > a; ++a)
l[a] = r;
for (i = 0; i < u[r - 1]; ++i)
p[r - 1][i] = e[i], h[r - 1][i] = i;
for (a = 0; r > a; ++a)
d[a] = 0;
for (1 === f[r - 1] && (--l[0], ++d[r - 1]), o = r - 2; o >= 0; --o) {
for (s = a = 0, c = d[o + 1], i = 0; i < u[o]; i++)
s = p[o + 1][c] + p[o + 1][c + 1], s > e[a] ? (p[o][i] = s, h[o][i] = t, c += 2) : (p[o][i] = e[a], h[o][i] = a, ++a);
d[o] = 0, 1 === f[o] && n(o)
}
return l
}
function l(e) {
var t, r, n, a, o = new (m ? Uint16Array : Array)(e.length), i = [], s = [], c = 0;
for (t = 0, r = e.length; r > t; t++)
i[e[t]] = (0 | i[e[t]]) + 1;
for (t = 1, r = 16; r >= t; t++)
s[t] = c, c += 0 | i[t], c <<= 1;
for (t = 0, r = e.length; r > t; t++)
for (c = s[e[t]], s[e[t]] += 1, n = o[t] = 0, a = e[t]; a > n; n++)
o[t] = o[t] << 1 | 1 & c, c >>>= 1;
return o
}
function p(e, t) {
this.input = e, this.c = this.i = 0, this.d = {}, t && (t.flags && (this.d = t.flags), "string" == typeof t.filename && (this.filename = t.filename), "string" == typeof t.comment && (this.l = t.comment), t.deflateOptions && (this.e = t.deflateOptions)), this.e || (this.e = {})
}
var h = void 0, d = !0, g = this, m = "undefined" != typeof Uint8Array && "undefined" != typeof Uint16Array && "undefined" != typeof Uint32Array;
t.prototype.b = function(e, t, n) {
var a, o = this.buffer, i = this.index, s = this.f, c = o[i];
if (n && t > 1 && (e = t > 8 ? (w[255 & e] << 24 | w[255 & e >>> 8] << 16 | w[255 & e >>> 16] << 8 | w[255 & e >>> 24]) >> 32 - t : w[e] >> 8 - t), 8 > t + s)
c = c << t | e, s += t;
else
for (a = 0; t > a; ++a)
c = c << 1 | 1 & e >> t - a - 1, 8 === ++s && (s = 0, o[i++] = w[c], c = 0, i === o.length && (o = r(this)));
o[i] = c, this.buffer = o, this.f = s, this.index = i
}, t.prototype.finish = function() {
var e, t = this.buffer, r = this.index;
return 0 < this.f && (t[r] <<= 8 - this.f, t[r] = w[t[r]], r++), m ? e = t.subarray(0, r) : (t.length = r, e = t), e
};
var y, _ = new (m ? Uint8Array : Array)(256);
for (y = 0; 256 > y; ++y) {
for (var A = y, v = A, b = 7, A = A >>> 1; A; A >>>= 1)
v <<= 1, v |= 1 & A, --b;
_[y] = (255 & v << b) >>> 0
}
var w = _, T = [0, 1996959894, 3993919788, 2567524794, 124634137, 1886057615, 3915621685, 2657392035, 249268274, 2044508324, 3772115230, 2547177864, 162941995, 2125561021, 3887607047, 2428444049, 498536548, 1789927666, 4089016648, 2227061214, 450548861, 1843258603, 4107580753, 2211677639, 325883990, 1684777152, 4251122042, 2321926636, 335633487, 1661365465, 4195302755, 2366115317, 997073096, 1281953886, 3579855332, 2724688242, 1006888145, 1258607687, 3524101629, 2768942443, 901097722, 1119000684, 3686517206, 2898065728, 853044451, 1172266101, 3705015759, 2882616665, 651767980, 1373503546, 3369554304, 3218104598, 565507253, 1454621731, 3485111705, 3099436303, 671266974, 1594198024, 3322730930, 2970347812, 795835527, 1483230225, 3244367275, 3060149565, 1994146192, 31158534, 2563907772, 4023717930, 1907459465, 112637215, 2680153253, 3904427059, 2013776290, 251722036, 2517215374, 3775830040, 2137656763, 141376813, 2439277719, 3865271297, 1802195444, 476864866, 2238001368, 4066508878, 1812370925, 453092731, 2181625025, 4111451223, 1706088902, 314042704, 2344532202, 4240017532, 1658658271, 366619977, 2362670323, 4224994405, 1303535960, 984961486, 2747007092, 3569037538, 1256170817, 1037604311, 2765210733, 3554079995, 1131014506, 879679996, 2909243462, 3663771856, 1141124467, 855842277, 2852801631, 3708648649, 1342533948, 654459306, 3188396048, 3373015174, 1466479909, 544179635, 3110523913, 3462522015, 1591671054, 702138776, 2966460450, 3352799412, 1504918807, 783551873, 3082640443, 3233442989, 3988292384, 2596254646, 62317068, 1957810842, 3939845945, 2647816111, 81470997, 1943803523, 3814918930, 2489596804, 225274430, 2053790376, 3826175755, 2466906013, 167816743, 2097651377, 4027552580, 2265490386, 503444072, 1762050814, 4150417245, 2154129355, 426522225, 1852507879, 4275313526, 2312317920, 282753626, 1742555852, 4189708143, 2394877945, 397917763, 1622183637, 3604390888, 2714866558, 953729732, 1340076626, 3518719985, 2797360999, 1068828381, 1219638859, 3624741850, 2936675148, 906185462, 1090812512, 3747672003, 2825379669, 829329135, 1181335161, 3412177804, 3160834842, 628085408, 1382605366, 3423369109, 3138078467, 570562233, 1426400815, 3317316542, 2998733608, 733239954, 1555261956, 3268935591, 3050360625, 752459403, 1541320221, 2607071920, 3965973030, 1969922972, 40735498, 2617837225, 3943577151, 1913087877, 83908371, 2512341634, 3803740692, 2075208622, 213261112, 2463272603, 3855990285, 2094854071, 198958881, 2262029012, 4057260610, 1759359992, 534414190, 2176718541, 4139329115, 1873836001, 414664567, 2282248934, 4279200368, 1711684554, 285281116, 2405801727, 4167216745, 1634467795, 376229701, 2685067896, 3608007406, 1308918612, 956543938, 2808555105, 3495958263, 1231636301, 1047427035, 2932959818, 3654703836, 1088359270, 936918e3, 2847714899, 3736837829, 1202900863, 817233897, 3183342108, 3401237130, 1404277552, 615818150, 3134207493, 3453421203, 1423857449, 601450431, 3009837614, 3294710456, 1567103746, 711928724, 3020668471, 3272380065, 1510334235, 755167117], S = m ? new Uint32Array(T) : T;
a.prototype.getParent = function(e) {
return 2 * (0 | (e - 2) / 4)
}, a.prototype.push = function(e, t) {
var r, n, a, o = this.buffer;
for (r = this.length, o[this.length++] = t, o[this.length++] = e; r > 0 && (n = this.getParent(r), o[r] > o[n]); )
a = o[r], o[r] = o[n], o[n] = a, a = o[r + 1], o[r + 1] = o[n + 1], o[n + 1] = a, r = n;
return this.length
}, a.prototype.pop = function() {
var e, t, r, n, a, o = this.buffer;
for (t = o[0], e = o[1], this.length -= 2, o[0] = o[this.length], o[1] = o[this.length + 1], a = 0; (n = 2 * a + 2, !(n >= this.length)) && (n + 2 < this.length && o[n + 2] > o[n] && (n += 2), o[n] > o[a]); )
r = o[a], o[a] = o[n], o[n] = r, r = o[a + 1], o[a + 1] = o[n + 1], o[n + 1] = r, a = n;
return {index: e,value: t,length: this.length}
};
var k, j = 2, I = [];
for (k = 0; 288 > k; k++)
switch (d) {
case 143 >= k:
I.push([k + 48, 8]);
break;
case 255 >= k:
I.push([k - 144 + 400, 9]);
break;
case 279 >= k:
I.push([k - 256 + 0, 7]);
break;
case 287 >= k:
I.push([k - 280 + 192, 8]);
break;
default:
throw "invalid literal: " + k
}
o.prototype.g = function() {
var e, r, n, a, o = this.input;
switch (this.h) {
case 0:
for (n = 0, a = o.length; a > n; ) {
r = m ? o.subarray(n, n + 65535) : o.slice(n, n + 65535), n += r.length;
var i = r, c = n === a, f = h, p = h, g = h, y = h, _ = h, A = this.a, v = this.c;
if (m) {
for (A = new Uint8Array(this.a.buffer); A.length <= v + i.length + 5; )
A = new Uint8Array(A.length << 1);
A.set(this.a)
}
if (f = c ? 1 : 0, A[v++] = 0 | f, p = i.length, g = 65535 & ~p + 65536, A[v++] = 255 & p, A[v++] = 255 & p >>> 8, A[v++] = 255 & g, A[v++] = 255 & g >>> 8, m)
A.set(i, v), v += i.length, A = A.subarray(0, v);
else {
for (y = 0, _ = i.length; _ > y; ++y)
A[v++] = i[y];
A.length = v
}
this.c = v, this.a = A
}
break;
case 1:
var b = new t(m ? new Uint8Array(this.a.buffer) : this.a, this.c);
b.b(1, 1, d), b.b(1, 2, d);
var w, T, S, k = s(this, o);
for (w = 0, T = k.length; T > w; w++)
if (S = k[w], t.prototype.b.apply(b, I[S]), S > 256)
b.b(k[++w], k[++w], d), b.b(k[++w], 5), b.b(k[++w], k[++w], d);
else if (256 === S)
break;
this.a = b.finish(), this.c = this.a.length;
break;
case j:
var x, O, R, D, N, P, E, C, U, L, M, q, F, K, J, B = new t(m ? new Uint8Array(this.a.buffer) : this.a, this.c), z = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], V = Array(19);
for (x = j, B.b(1, 1, d), B.b(x, 2, d), O = s(this, o), P = u(this.n, 15), E = l(P), C = u(this.m, 7), U = l(C), R = 286; R > 257 && 0 === P[R - 1]; R--)
;
for (D = 30; D > 1 && 0 === C[D - 1]; D--)
;
var H, G, Q, Y, $, X, Z = R, W = D, et = new (m ? Uint32Array : Array)(Z + W), tt = new (m ? Uint32Array : Array)(316), rt = new (m ? Uint8Array : Array)(19);
for (H = G = 0; Z > H; H++)
et[G++] = P[H];
for (H = 0; W > H; H++)
et[G++] = C[H];
if (!m)
for (H = 0, Y = rt.length; Y > H; ++H)
rt[H] = 0;
for (H = $ = 0, Y = et.length; Y > H; H += G) {
for (G = 1; Y > H + G && et[H + G] === et[H]; ++G)
;
if (Q = G, 0 === et[H])
if (3 > Q)
for (; 0 < Q--; )
tt[$++] = 0, rt[0]++;
else
for (; Q > 0; )
X = 138 > Q ? Q : 138, X > Q - 3 && Q > X && (X = Q - 3), 10 >= X ? (tt[$++] = 17, tt[$++] = X - 3, rt[17]++) : (tt[$++] = 18, tt[$++] = X - 11, rt[18]++), Q -= X;
else if (tt[$++] = et[H], rt[et[H]]++, Q--, 3 > Q)
for (; 0 < Q--; )
tt[$++] = et[H], rt[et[H]]++;
else
for (; Q > 0; )
X = 6 > Q ? Q : 6, X > Q - 3 && Q > X && (X = Q - 3), tt[$++] = 16, tt[$++] = X - 3, rt[16]++, Q -= X
}
for (e = m ? tt.subarray(0, $) : tt.slice(0, $), L = u(rt, 7), K = 0; 19 > K; K++)
V[K] = L[z[K]];
for (N = 19; N > 4 && 0 === V[N - 1]; N--)
;
for (M = l(L), B.b(R - 257, 5, d), B.b(D - 1, 5, d), B.b(N - 4, 4, d), K = 0; N > K; K++)
B.b(V[K], 3, d);
for (K = 0, J = e.length; J > K; K++)
if (q = e[K], B.b(M[q], L[q], d), q >= 16) {
switch (K++, q) {
case 16:
F = 2;
break;
case 17:
F = 3;
break;
case 18:
F = 7;
break;
default:
throw "invalid code: " + q
}
B.b(e[K], F, d)
}
var nt, at, ot, it, st, ct, ut, ft, lt = [E, P], pt = [U, C];
for (st = lt[0], ct = lt[1], ut = pt[0], ft = pt[1], nt = 0, at = O.length; at > nt; ++nt)
if (ot = O[nt], B.b(st[ot], ct[ot], d), ot > 256)
B.b(O[++nt], O[++nt], d), it = O[++nt], B.b(ut[it], ft[it], d), B.b(O[++nt], O[++nt], d);
else if (256 === ot)
break;
this.a = B.finish(), this.c = this.a.length;
break;
default:
throw "invalid compression type"
}
return this.a
};
var x = function() {
function e(e) {
switch (d) {
case 3 === e:
return [257, e - 3, 0];
case 4 === e:
return [258, e - 4, 0];
case 5 === e:
return [259, e - 5, 0];
case 6 === e:
return [260, e - 6, 0];
case 7 === e:
return [261, e - 7, 0];
case 8 === e:
return [262, e - 8, 0];
case 9 === e:
return [263, e - 9, 0];
case 10 === e:
return [264, e - 10, 0];
case 12 >= e:
return [265, e - 11, 1];
case 14 >= e:
return [266, e - 13, 1];
case 16 >= e:
return [267, e - 15, 1];
case 18 >= e:
return [268, e - 17, 1];
case 22 >= e:
return [269, e - 19, 2];
case 26 >= e:
return [270, e - 23, 2];
case 30 >= e:
return [271, e - 27, 2];
case 34 >= e:
return [272, e - 31, 2];
case 42 >= e:
return [273, e - 35, 3];
case 50 >= e:
return [274, e - 43, 3];
case 58 >= e:
return [275, e - 51, 3];
case 66 >= e:
return [276, e - 59, 3];
case 82 >= e:
return [277, e - 67, 4];
case 98 >= e:
return [278, e - 83, 4];
case 114 >= e:
return [279, e - 99, 4];
case 130 >= e:
return [280, e - 115, 4];
case 162 >= e:
return [281, e - 131, 5];
case 194 >= e:
return [282, e - 163, 5];
case 226 >= e:
return [283, e - 195, 5];
case 257 >= e:
return [284, e - 227, 5];
case 258 === e:
return [285, e - 258, 0];
default:
throw "invalid length: " + e
}
}
var t, r, n = [];
for (t = 3; 258 >= t; t++)
r = e(t), n[t] = r[2] << 24 | r[1] << 16 | r[0];
return n
}(), O = m ? new Uint32Array(x) : x;
p.prototype.g = function() {
var e, t, r, a, i, s, c, u, f = new (m ? Uint8Array : Array)(32768), l = 0, p = this.input, d = this.i, g = this.filename, y = this.l;
if (f[l++] = 31, f[l++] = 139, f[l++] = 8, e = 0, this.d.fname && (e |= N), this.d.fcomment && (e |= P), this.d.fhcrc && (e |= D), f[l++] = e, t = 0 | (Date.now ? Date.now() : +new Date) / 1e3, f[l++] = 255 & t, f[l++] = 255 & t >>> 8, f[l++] = 255 & t >>> 16, f[l++] = 255 & t >>> 24, f[l++] = 0, f[l++] = R, this.d.fname !== h) {
for (c = 0, u = g.length; u > c; ++c)
s = g.charCodeAt(c), s > 255 && (f[l++] = 255 & s >>> 8), f[l++] = 255 & s;
f[l++] = 0
}
if (this.d.comment) {
for (c = 0, u = y.length; u > c; ++c)
s = y.charCodeAt(c), s > 255 && (f[l++] = 255 & s >>> 8), f[l++] = 255 & s;
f[l++] = 0
}
return this.d.fhcrc && (r = 65535 & n(f, 0, l), f[l++] = 255 & r, f[l++] = 255 & r >>> 8), this.e.outputBuffer = f, this.e.outputIndex = l, i = new o(p, this.e), f = i.g(), l = i.c, m && (l + 8 > f.buffer.byteLength ? (this.a = new Uint8Array(l + 8), this.a.set(new Uint8Array(f.buffer)), f = this.a) : f = new Uint8Array(f.buffer)), a = n(p, h, h), f[l++] = 255 & a, f[l++] = 255 & a >>> 8, f[l++] = 255 & a >>> 16, f[l++] = 255 & a >>> 24, u = p.length, f[l++] = 255 & u, f[l++] = 255 & u >>> 8, f[l++] = 255 & u >>> 16, f[l++] = 255 & u >>> 24, this.i = d, m && l < f.length && (this.a = f = f.subarray(0, l)), f
};
var R = 255, D = 2, N = 8, P = 16;
e("Zlib.Gzip", p), e("Zlib.Gzip.prototype.compress", p.prototype.g)
}.call(this), baidu.frontia.util = {}, function(namespace_) {
var now = +new Date, util = {};
util.guid = function() {
return "baidu_frontia_" + now++
}, util.mix = function(e) {
for (var t = 1; t < arguments.length; t++) {
var r = arguments[t];
if (r)
for (var n in r)
r.hasOwnProperty(n) && (e[n] = r[n])
}
return e
}, util.noop = function() {
}, util.parseJSON = function(text) {
return window.JSON && "function" == typeof JSON.parse ? JSON.parse(text) : eval("(" + text + ")")
};
var whitespace = /(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g;
util.trim = function(e) {
return e.replace(whitespace, "")
}, util.encodeHTML = function(e) {
return e += "", e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;")
}, util.serializeURL = function(e) {
if (!e)
return "";
var t = "";
for (var r in e)
if (e.hasOwnProperty(r)) {
var n = e[r];
t += "&" + encodeURIComponent(r) + "=" + encodeURIComponent(n)
}
return t.slice(1)
}, function(e) {
"use strict";
if (!e.Base64) {
var t, r = "2.1.2";
"undefined" != typeof module && module.exports && (t = require("buffer").Buffer);
var n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = function(e) {
for (var t = {}, r = 0, n = e.length; n > r; r++)
t[e.charAt(r)] = r;
return t
}(n), o = String.fromCharCode, i = function(e) {
if (e.length < 2) {
var t = e.charCodeAt(0);
return 128 > t ? e : 2048 > t ? o(192 | t >>> 6) + o(128 | 63 & t) : o(224 | 15 & t >>> 12) + o(128 | 63 & t >>> 6) + o(128 | 63 & t)
}
var t = 65536 + 1024 * (e.charCodeAt(0) - 55296) + (e.charCodeAt(1) - 56320);
return o(240 | 7 & t >>> 18) + o(128 | 63 & t >>> 12) + o(128 | 63 & t >>> 6) + o(128 | 63 & t)
}, s = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, c = function(e) {
return e.replace(s, i)
}, u = function(e) {
var t = [0, 2, 1][e.length % 3], r = e.charCodeAt(0) << 16 | (e.length > 1 ? e.charCodeAt(1) : 0) << 8 | (e.length > 2 ? e.charCodeAt(2) : 0), a = [n.charAt(r >>> 18), n.charAt(63 & r >>> 12), t >= 2 ? "=" : n.charAt(63 & r >>> 6), t >= 1 ? "=" : n.charAt(63 & r)];
return a.join("")
}, f = e.btoa || function(e) {
return e.replace(/[\s\S]{1,3}/g, u)
}, l = t ? function(e) {
return new t(e).toString("base64")
} : function(e) {
return f(c(e))
}, p = function(e, t) {
return t ? l(e).replace(/[+\/]/g, function(e) {
return "+" == e ? "-" : "_"
}).replace(/=/g, "") : l(e)
}, h = function(e) {
return p(e, !0)
}, d = new RegExp(["[À-ß][€-¿]", "[à-ï][€-¿]{2}", "[ð-÷][€-¿]{3}"].join("|"), "g"), g = function(e) {
switch (e.length) {
case 4:
var t = (7 & e.charCodeAt(0)) << 18 | (63 & e.charCodeAt(1)) << 12 | (63 & e.charCodeAt(2)) << 6 | 63 & e.charCodeAt(3), r = t - 65536;
return o((r >>> 10) + 55296) + o((1023 & r) + 56320);
case 3:
return o((15 & e.charCodeAt(0)) << 12 | (63 & e.charCodeAt(1)) << 6 | 63 & e.charCodeAt(2));
default:
return o((31 & e.charCodeAt(0)) << 6 | 63 & e.charCodeAt(1))
}
}, m = function(e) {
return e.replace(d, g)
}, y = function(e) {
var t = e.length, r = t % 4, n = (t > 0 ? a[e.charAt(0)] << 18 : 0) | (t > 1 ? a[e.charAt(1)] << 12 : 0) | (t > 2 ? a[e.charAt(2)] << 6 : 0) | (t > 3 ? a[e.charAt(3)] : 0), i = [o(n >>> 16), o(255 & n >>> 8), o(255 & n)];
return i.length -= [0, 0, 2, 1][r], i.join("")
}, _ = e.atob || function(e) {
return e.replace(/[\s\S]{1,4}/g, y)
}, A = t ? function(e) {
return new t(e, "base64").toString()
} : function(e) {
return m(_(e))
}, v = function(e) {
return A(e.replace(/[-_]/g, function(e) {
return "-" == e ? "+" : "/"
}).replace(/[^A-Za-z0-9\+\/]/g, ""))
};
e.mix(e, {VERSION: r,atob: _,btoa: f,fromBase64: v,toBase64: p,utob: c,encode: p,encodeURI: h,btou: m,decode: v})
}
}(util), util.isBoolean = function(e) {
return e === !0 || e === !1 || "[object Boolean]" == toString.call(e)
}, namespace_.util = util
}(baidu.frontia), baidu.frontia.ajax = {}, function(e) {
function t(e, t) {
var r = a.serializeURL(t);
if (r) {
var n = e.indexOf("?") >= 0 ? "&" : "?";
return e + n + r
}
return e
}
function r(e, t) {
null == t && (t = "");
var a = n.hooks.serializeData.getKey, o = e ? encodeURIComponent(e) : "", i = Object.prototype.toString.call(t);
switch (i) {
case "[object Array]":
for (var s = [], c = 0; c < t.length; c++) {
var u = t[c];
s[c] = r("", u)
}
return o ? o + "=" + s.join(",") : s.join(",");
case "[object Object]":
var f = [];
for (var l in t) {
var p = a(l, e), h = r(p, t[l]);
f.push(h)
}
return f.join("&");
default:
return o ? o + "=" + encodeURIComponent(t) : encodeURIComponent(t)
}
}
var n = {}, a = e.util;
n.hooks = {}, n.hooks.serializeData = function(e) {
return r("", e)
}, n.hooks.serializeData.getKey = function(e, t) {
return t ? t + "." + e : e
}, n.request = function(e) {
var r = {method: "POST",data: {},cache: !0,callback: function() {
},onerror: function() {
}};
e = a.mix(r, e);
var o, i = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
i.onreadystatechange = function() {
if (4 === i.readyState) {
clearTimeout(o);
var t = i.status;
if (0 === t ? t = 200 : 1223 === t && (t = 204), 200 > t || t >= 300 && 304 !== t)
return e.onerror(i), void 0;
var r = i.responseText;
if ("json" === e.dataType)
try {
r = a.parseJSON(r)
} catch (n) {
return e.onerror(i, n), void 0
}
e.callback(r)
}
};
var s = e.method.toUpperCase(), c = {};
"GET" === s && a.mix(c, e.data), e.cache === !1 && (c._ = +new Date);
var u = t(e.url, c);
if (i.open(s, u, !0), e.header) {
var f;
for (f in e.header)
e.header.hasOwnProperty(f) && i.setRequestHeader(f, e.header[f])
}
if ("GET" === s)
i.send();
else {
var l = e.contentType || "application/x-www-form-urlencoded";
i.setRequestHeader("Content-type", l);
var p = n.hooks.serializeData(e.data);
i.send(p), i.send(e.data)
}
return e.timeout > 0 && (o = setTimeout(function() {
i.status = 408, e.onerror(i)
}, e.timeout)), i
}, n.get = function(e, t, r) {
var o = {method: "GET",url: e,data: t,cache: !1};
return r = a.mix(o, r), n.request(r)
}, n.getJSON = function(e, t, r) {
var o = {method: "GET",url: e,data: t,dataType: "json",cache: cache || !1};
return r = a.mix(o, r), n.request(r)
}, n.request1 = function(e) {
var r = {method: "POST",data: {},cache: !0,callback: function() {
},onerror: function() {
}};
e = a.mix(r, e);
var o, i = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
i.onreadystatechange = function() {
if (4 === i.readyState) {
clearTimeout(o);
var t = i.status;
if (0 === t ? t = 200 : 1223 === t && (t = 204), 200 > t || t >= 300 && 304 !== t)
return e.onerror(i), void 0;
var r = i.responseText;
if ("json" === e.dataType && r)
try {
r = a.parseJSON(r)
} catch (n) {
return e.onerror(i, n), void 0
}
e.callback(r)
}
};
var s = e.method.toUpperCase(), c = {};
"GET" === s && a.mix(c, e.data), e.cache === !1 && (c._ = +new Date);
var u = t(e.url, c);
if (i.open(s, u, !0), e.header) {
var f;
for (f in e.header)
e.header.hasOwnProperty(f) && i.setRequestHeader(f, e.header[f])
}
if ("GET" === s)
i.send();
else if (e.contentLength && i.setRequestHeader("Content-Length", e.contentLength), "multipart/form-data" === e.contentType)
i.send(e.data);
else if ("application/json" === e.contentType)
i.setRequestHeader("Content-type", e.contentType), i.send(e.data);
else if ("application/octet-stream" === e.contentType)
i.setRequestHeader("Content-type", e.contentType), i.send(e.data);
else {
var l = e.contentType || "application/x-www-form-urlencoded";
i.setRequestHeader("Content-type", l);
var p = n.hooks.serializeData(e.data);
i.send(p)
}
return e.timeout > 0 && (o = setTimeout(function() {
i.status = 408, e.onerror(i)
}, e.timeout)), i
}, n.post = function(e, t, r, o) {
var i = {method: "POST",url: e,data: t,dataType: r || "json"};
return o = a.mix(i, o), n.request1(o)
}, n.put = function(e, t, r, o) {
var i = {method: "PUT",url: e,data: t,dataType: r || "json"};
return o = a.mix(i, o), n.request1(o)
}, e.ajax = n
}(baidu.frontia), baidu.frontia.jsonp = {}, function(e) {
e.jsonp = function() {
function e(e, t) {
var r = document.createElement("script"), n = !1;
r.src = e, r.async = !0;
var o = t || s.error;
"function" == typeof o && (r.onerror = function(t) {
o({url: e,event: t})
}), r.onload = r.onreadystatechange = function() {
n || this.readyState && "loaded" !== this.readyState && "complete" !== this.readyState || (n = !0, r.onload = r.onreadystatechange = null, r && r.parentNode && r.parentNode.removeChild(r))
}, a || (a = document.getElementsByTagName("head")[0]), a.appendChild(r)
}
function t(e) {
return encodeURIComponent(e)
}
function r(r, n, a, c, u) {
var f, l = -1 === (r || "").indexOf("?") ? "?" : "&";
u = u || s.callbackName || "callback";
var p = "baidu_frontia_" + u + "_json" + ++o;
n = n || {};
for (f in n)
n.hasOwnProperty(f) && (l += t(f) + "=" + t(n[f]) + "&");
return i[p] = function(e) {
a(e);
try {
delete i[p]
} catch (t) {
}
i[p] = null
}, e(r + l + u + "=" + p, c), p
}
function n(e) {
s = e
}
var a, o = 0, i = this, s = {};
return {get: r,init: n}
}()
}(baidu.frontia), baidu.frontia.Account = baidu.frontia.Account || {}, baidu.frontia.User = baidu.frontia.User || {}, baidu.frontia.Role = baidu.frontia.Role || {}, baidu.frontia.ACL = baidu.frontia.ACL || {}, function(e) {
function t(t) {
var r = e.util.toBase64("Application:" + t);
return "Basic " + r
}
function r(t) {
var r = {application_info: [{app_frontia_version: e.version,app_appid: e.getApiKey(),user_id: e.getCurrentAccount().getId() || "",frontia_action: [{action_name: "",timestamp: null,restimestamp: null,err_code: "",err_msg: ""}]}]};
r.application_info[0].frontia_action[0] = t;
var n = {}, a = new Zlib.Gzip(new Uint8Array(JSON.stringify(r).split("").map(function(e) {
return e.charCodeAt(0)
}))), o = a.compress();
n.stats = btoa(String.fromCharCode.apply(null, o));
var i = e.ajax;
i.post(c, JSON.stringify(n), "json", {contentType: "application/json"})
}
function n() {
var e = Math.floor((new Date).getTime() / 1e3);
return e
}
var a = e.error, o = e.ERR_MSG, i = e.DomainManager.getFrontiaDomain() + "/role", s = e.DomainManager.getFrontiaDomain() + "/user", c = e.DomainManager.getPBLogDomain() + "/pushlog";
e.Account = e.Object.extend({accountId: null,accountType: null,accountName: null,constructor: function(e, t, r) {
if (!e || "string" != typeof e && "number" != typeof e)
throw new a(o.INVALID_PARAMS, "[construct Role/User]: accountId is invalid, the typeof accountId is string or number");
this.accountType = t, this.accountId = e, this.accountName = r
},getId: function() {
return this.accountId
},getType: function() {
return this.accountType
},getName: function() {
return this.accountName
}}), e.User = e.Account.extend({accessToken: null,expirationIn: null,mediaType: null,constructor: function(t) {
t = t || {}, this.accessToken = t.accessToken, this.expiresIn = t.expiresIn, this.mediaType = t.mediaType, e.Account.prototype.constructor.call(this, t.socialId, "user", t.name)
},getAccessToken: function() {
return this.accessToken
},getExpiresIn: function() {
return this.expiresIn
},getMediaType: function() {
return this.mediaType
},getDetailInfo: function(t) {
t = t || {}, t.error || (t.error = function() {
}), t.success || (t.success = function() {
}), e.User.find({userId: this.accountId}, {error: function(e) {
t.error(e)
},success: function(e) {
0 === e.count ? t.error(new a({Code: "1701",Message: "user not exists"})) : t.success(e.result[0])
}})
},toJSON: function() {
return {socialId: this.getId(),name: this.getName(),type: this.getType(),mediaType: this.getMediaType(),expiresIn: this.getExpiresIn(),accessToken: this.getAccessToken()}
}});
var u = {options: {error: function() {
},success: function() {
}},_configure: function(e) {
e = e || {}, e.error && (this.options.error = e.error), e.success && (this.options.success = e.success)
},_checkParams: function(t, r) {
var n = this;
return t.every(function(t) {
return "string" !== t.type || t.value && "string" == typeof t.value ? "role" !== t.type || t.value && t.value instanceof e.Role ? "array" !== t.type || t.value && "Array" === Object.prototype.toString.call(t.value).slice(8, -1) ? !0 : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: targets is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: role is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: target is invalid")), !1)
})
},find: function(o, i) {
var c = {};
c.action_name = "User.list", c.timestamp = n();
var u = this;
if (1 === arguments.length)
var i = o;
i || (i = {}), u._configure(i);
var f = {};
o.mediaType && (f.media_type = o.mediaType), o.sex && (f.sex = o.sex), o.userId && (f.user_id = o.userId), o.userName && (f.username = o.userName);
var l = u._attachAccount({method: "list",criteria: f}), p = u._createAjaxOpt(c, {header: {authorization: t(e.getApiKey())},contentType: "application/json"});
p.callback = function(t) {
if (t.error_code) {
var o = new a(t);
u.options.error(o), c.err_code = o.code, c.err_msg = o.message
} else {
var i = [];
t.response_params.users.forEach(function(t) {
var r = new e.User({socialId: t.user_id,mediaType: t.media_type,name: t.username});
r.extra = t;
i.push(r);
}), u.options.success({result: i,count: t.response_params.count}), c.err_code = 0
}
c.restimestamp = n(), r(c)
};
var h = e.ajax;
h.post(s, JSON.stringify(l), "json", p)
},_attachAccount: function(t) {
var r = null;
return e.currentAccount && e.currentAccount instanceof e.Role && e.currentAccount.getId() ? (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getId()) : e.currentAccount && e.currentAccount instanceof e.User && e.currentAccount.getAccessToken() && (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getAccessToken()), t
},_createAjaxOpt: function(t, o) {
var i = this, s = {callback: function(e) {
if (e.error_code) {
var o = new a(e);
i.options.error(o), t.err_code = o.code, t.err_msg = o.message
} else
i.options.success(e), t.err_code = 0;
t.restimestamp = n(), r(t)
},onerror: function(o, s) {
try {
var c = e.util.parseJSON(o.responseText)
} catch (u) {
return i.options.error(u, o), void 0
}
var s = new a(c);
i.options.error(new a(c), o), t.err_code = s.code, t.err_msg = s.message, t.restimestamp = n(), r(t)
}};
return e.util.mix(s, o)
}};
e.util.mix(e.User, u), e.Role = e.Account.extend({roleList: {},constructor: function(t, r) {
var n = this;
n.roleList = {}, Array.isArray(r) && r.forEach(function(t) {
if (!(t instanceof e.User || t instanceof e.Role))
throw new a(o.INVALID_PARAMS, "[construct Role]: account is invalid");
n.roleList[t.getId()] = t
}), e.Account.prototype.constructor.call(this, t, "role", t)
},add: function(t) {
if (!(t instanceof e.User || t instanceof e.Role))
throw new a(o.INVALID_PARAMS, "[add Role]: account is invalid");
this.roleList[t.getId()] = t
},"delete": function(e) {
delete this.roleList[e]
},getInfo: function() {
var e = [];
for (var t in this.roleList)
this.roleList.hasOwnProperty(t) && e.push(this.roleList[t].getType() + ":" + this.roleList[t].getId());
return e
},toJSON: function() {
return {roleId: this.getId(),name: this.getName(),memberList: this.getInfo()}
}});
var f = {options: {error: function() {
},success: function() {
}},_configure: function(e) {
e = e || {}, e.error && (this.options.error = e.error), e.success && (this.options.success = e.success)
},_checkParams: function(t, r) {
var n = this;
return t.every(function(t) {
return "string" !== t.type || t.value && "string" == typeof t.value ? "role" !== t.type || t.value && t.value instanceof e.Role ? "array" !== t.type || t.value && "Array" === Object.prototype.toString.call(t.value).slice(8, -1) ? !0 : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: targets is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: role is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: target is invalid")), !1)
})
},remove: function(r, a) {
var o = {};
o.action_name = "Role.remove", o.timestamp = n();
var s = this;
if (a = a || {}, s._configure(a), s._checkParams([{value: r,type: "string"}], "Role remove")) {
var c = s._attachAccount({method: "remove",role_id: r}), u = s._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), f = e.ajax;
f.post(i, JSON.stringify(c), "json", u)
}
},get: function(r, a) {
var o = {};
o.action_name = "Role.get", o.timestamp = n();
var s = this;
if (a = a || {}, s._configure(a), s._checkParams([{value: r,type: "string"}], "Role get")) {
var c = s._attachAccount({method: "describe",role_id: r}), u = s._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), f = e.ajax;
f.post(i, JSON.stringify(c), "json", u)
}
},save: function(r, a) {
var o = {};
o.action_name = "Role.save", o.timestamp = n();
var s = this;
if (a = a || {}, s._configure(a), s._checkParams([{value: r,type: "role"}], "Role save")) {
var c = r.getInfo(), u = s._attachAccount({method: "create",role_id: r.getId(),child: c}), f = r.getACL();
f && (u._acl = f.toJSON());
var l = s._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), p = e.ajax;
p.post(i, JSON.stringify(u), "json", l)
}
},update: function(r, s) {
var c = {};
c.action_name = "Role.update", c.timestamp = n();
var u = this, f = null;
if (s = s || {}, u._configure(s), u._checkParams([{value: r,type: "string"}], "Role update")) {
var l = u._attachAccount({method: "modify",role_id: r});
if (s.acl && s.acl instanceof e.ACL && (l._acl = s.acl.toJSON()), f = "add" === s.update_type ? "push_child" : "del" === s.update_type ? "pull_child" : "set" === s.update_type ? "set_child" : null) {
var p = [];
s.accounts.forEach(function(t) {
if (!(t instanceof e.User || t instanceof e.Role))
throw new a(o.INVALID_PARAMS, "[update Role]: account is invalid");
p.push(t.getType() + ":" + t.getId())
}), l[f] = p
}
var h = u._createAjaxOpt(c, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), d = e.ajax;
d.post(i, JSON.stringify(l), "json", h)
}
},list: function(o) {
var s = {};
s.action_name = "Role.list", s.timestamp = n();
var c = this;
o = o || {}, c._configure(o);
var u = c._attachAccount({method: "list"}), f = c._createAjaxOpt(s, {header: {authorization: t(e.getApiKey())},contentType: "application/json"});
f.callback = function(t) {
if (t.error_code) {
var o = new a(t);
c.options.error(o), s.err_code = o.code, s.err_msg = o.message
} else {
var i = [];
t.response_params.roles.forEach(function(t) {
var r = new e.ACL;
t._acl && (r._setPermission(t._acl), delete t._acl);
var n = new e.Role(t.role_id);
t.child.forEach(function(t) {
var r = t.split(":");
"user" === r[0] ? n.add(new e.User({socialId: r[1]})) : n.add(new e.Role(r[1]))
}), i.push(n)
}), c.options.success({result: i,count: t.response_params.count}), s.err_code = 0
}
s.restimestamp = n(), r(s)
};
var l = e.ajax;
l.post(i, JSON.stringify(u), "json", f)
},_attachAccount: function(t) {
var r = null;
return e.currentAccount && e.currentAccount instanceof e.Role && e.currentAccount.getId() ? (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getId()) : e.currentAccount && e.currentAccount instanceof e.User && e.currentAccount.getAccessToken() && (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getAccessToken()), t
},_createAjaxOpt: function(t, o) {
var i = this, s = {callback: function(e) {
if (e.error_code) {
var o = new a(e);
i.options.error(o), t.err_code = o.code, t.err_msg = o.message
} else
i.options.success(e), t.err_code = 0;
t.restimestamp = n(), r(t)
},onerror: function(o, s) {
try {
var c = e.util.parseJSON(o.responseText)
} catch (u) {
return i.options.error(u, o), void 0
}
var s = new a(c);
i.options.error(s, o), t.err_code = s.code, t.err_msg = s.message, t.restimestamp = n(), r(t)
}};
return e.util.mix(s, o)
}};
e.util.mix(e.Role, f), e.ACL = e.Base.extend({permissions: null,constructor: function() {
this.permissions = {}
},_setAccess: function(t, r, n) {
if (!(r instanceof e.User || r instanceof e.Role))
throw new a(o.INVALID_PARAMS, "[setAccess]: account is invalid");
if (!e.util.isBoolean(n))
throw new a(o.INVALID_PARAMS, "[setAccess]: allowed is invalid");
var i = [r.getType(), ":", r.getId()].join("");
this.permissions[i] = this.permissions[i] || {}, this.permissions[i][t] = n
},_isAccess: function(t, r) {
if (!(r instanceof e.User || r instanceof e.Role))
throw new a(o.INVALID_PARAMS, "[isAccess]: account is invalid");
if (this.permissions["role:*"] && this.permissions["role:*"][t])
return !0;
var n = [r.getType(), ":", r.getId()].join(""), i = this.permissions[n];
return i ? i[t] : !1
},_setPermission: function(e) {
this.permissions = {};
for (var t in e)
if (e.hasOwnProperty(t))
switch (e[t]) {
case 1:
this.permissions[t] = this.permissions[t] || {}, this.permissions[t].write = !0;
break;
case 2:
this.permissions[t] = this.permissions[t] || {}, this.permissions[t].read = !0;
break;
case 3:
this.permissions[t] = this.permissions[t] || {}, this.permissions[t].write = !0, this.permissions[t].read = !0
}
},setReadAccess: function(e, t) {
this._setAccess("read", e, t)
},setPublicReadAccess: function(t) {
var r = new e.Role("*");
this._setAccess("read", r, t)
},setWriteAccess: function(e, t) {
this._setAccess("write", e, t)
},setPublicWriteAccess: function(t) {
var r = new e.Role("*");
this._setAccess("write", r, t)
},isReadAccess: function(e) {
this._isAccess("read", e)
},isWriteAccess: function(e) {
this._isAccess("write", e)
},toJSON: function() {
var e = {};
for (var t in this.permissions)
if (this.permissions.hasOwnProperty(t)) {
var r = this.permissions[t];
e[t] = (r.read ? 2 : 0) + (r.write ? 1 : 0)
}
return e
}})
}(baidu.frontia), baidu.frontia.social = baidu.frontia.social || {}, function(e) {
function t(e) {
return encodeURIComponent(e + "")
}
function r(e, r, n, a, o, i, s, c) {
var u = f + "?" + "response_type=" + r + "&" + "client_id=" + e + "&" + "media_type=" + n + "&" + "redirect_uri=" + t(a);
return o && (u += "&state=" + o), i && (u += "&display=" + i), s && (u += "&client_type=" + s), c && (u += "&scope=" + c), u + "&secure=1"
}
function n(t) {
var n = e.getApiKey(), a = r(n, t.response_type, t.media_type, t.redirect_uri, t.state, t.display, t.client_type, t.scope);
return a
}
function a() {
function e() {
var e = {};
if (t) {
var r = t.indexOf("#");
if (-1 !== r) {
var n = t.slice(r + 1);
if (n) {
var a = n.split("&");
a.forEach(function(t) {
var r = t.split("=");
e[r[0]] = r[1]
})
}
}
}
return e
}
var t = location.hash, r = e();
return {access_token: r.access_token,expires_in: r.expires_in,media_type: r.media_type}
}
function o(t) {
var r = null;
return e.currentAccount && e.currentAccount instanceof e.Role && e.currentAccount.getId() ? (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getId()) : e.currentAccount && e.currentAccount instanceof e.User && e.currentAccount.getAccessToken() && (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getAccessToken()), t
}
function i(t) {
var r = e.util.toBase64("Application:" + t);
return "Basic " + r
}
function s(t) {
var r = {application_info: [{app_frontia_version: e.version,app_appid: e.getApiKey(),user_id: e.getCurrentAccount().getId() || "",frontia_action: [{action_name: "",timestamp: null,restimestamp: null,err_code: "",err_msg: ""}]}]};
r.application_info[0].frontia_action[0] = t;
var n = {}, a = new Zlib.Gzip(new Uint8Array(JSON.stringify(r).split("").map(function(e) {
return e.charCodeAt(0)
}))), o = a.compress();
n.stats = btoa(String.fromCharCode.apply(null, o));
var i = e.ajax;
i.post(p, JSON.stringify(n), "json", {contentType: "application/json"})
}
function c() {
var e = Math.floor((new Date).getTime() / 1e3);
return e
}
var u = e.error, f = e.DomainManager.getSocialDomain() + "/social/oauth/2.0/authorize", l = e.DomainManager.getSocialDomain() + "/social/api/2.0/user/info", p = e.DomainManager.getPBLogDomain() + "/pushlog", h = e.DomainManager.getFrontiaDomain() + "/user", d = {TOKEN: "token",CODE: "code"}, g = {setLoginCallback: function(t) {
var r = a();
if (!e.getCurrentAccount() && r.access_token && t) {
var n = {};
n.action_name = "social.login", n.timestamp = c(), t.success || (t.success = function() {
}), t.error || (t.error = function() {
}), e.jsonp.get(l, {access_token: r.access_token}, function(a) {
if (a.error_code) {
var f = new u(a);
t.error(f), n.err_code = f.code, n.err_msg = f.message
} else {
var l = new e.User({socialId: a.social_uid,name: a.username,accessToken: r.access_token,expiresIn: r.expires_in,mediaType: r.media_type});
e.setCurrentAccount(l);
var p = o({method: "register"}), d = {header: {authorization: i(e.getApiKey())},contentType: "application/json"}, g = e.ajax;
g.post(h, JSON.stringify(p), "json", d), t.success(l), n.err_code = 0
}
n.restimestamp = c(), s(n)
}, function() {
})
}
},login: function(t) {
if (e.logOutCurrentAccount(), !t)
throw new baidu.frontia.error(baidu.frontia.ERR_MSG.INVALID_PARAMS);
if (t.error = t.error || function() {
}, !t.response_type)
throw new baidu.frontia.error(baidu.frontia.ERR_MSG.INVALID_PARAMS);
if (!t.media_type)
throw new baidu.frontia.error(baidu.frontia.ERR_MSG.INVALID_PARAMS);
if (t.response_type != d.TOKEN)
throw new baidu.frontia.error(baidu.frontia.ERR_MSG.INVALID_PARAMS);
var r = n(t);
location.href = r
}};
e.social = g
}(baidu.frontia), baidu.frontia.storage = baidu.frontia.storage || {}, function(e) {
function t(t) {
var r = e.util.toBase64("Application:" + t);
return "Basic " + r
}
function r(t) {
var r = {application_info: [{app_frontia_version: e.version,app_appid: e.getApiKey(),user_id: e.getCurrentAccount().getId() || "",frontia_action: [{action_name: "",timestamp: null,restimestamp: null,err_code: "",err_msg: ""}]}]};
r.application_info[0].frontia_action[0] = t;
var n = {}, a = new Zlib.Gzip(new Uint8Array(JSON.stringify(r).split("").map(function(e) {
return e.charCodeAt(0)
}))), o = a.compress();
n.stats = btoa(String.fromCharCode.apply(null, o));
var i = e.ajax;
i.post(c, JSON.stringify(n), "json", {contentType: "application/json"})
}
function n() {
var e = Math.floor((new Date).getTime() / 1e3);
return e
}
var a = e.error, o = e.ERR_MSG, i = e.DomainManager.getFrontiaDomain() + "/bss/document", s = e.DomainManager.getFrontiaDomain() + "/bcs/object", c = e.DomainManager.getPBLogDomain() + "/pushlog";
e.File = e.Object.extend({constructor: function(t, r, n) {
if (t && !(t instanceof File))
throw new a(o.INVALID_PARAMS, "[baidu.frontia.File.constructor]: file is invalid");
this.file = t, this.target = r, this.detail = null, e.Object.prototype.constructor.call(this, n)
},getFileInfo: function() {
return this.detail
},_getFile: function() {
return this.file
},_getTarget: function() {
return this.target
},_setFileInfo: function(e) {
this.detail = e
}}), e.Data = e.Object.extend({constructor: function(t, r) {
this.obj = t || {}, e.Object.prototype.constructor.call(this, r)
},getData: function() {
return this.obj
}});
var u = {options: {error: function() {
},success: function() {
}},_configure: function(e) {
e = e || {}, e.error && (this.options.error = e.error), e.success && (this.options.success = e.success)
},_checkParams: function(t, r) {
var n = this;
return t.every(function(t) {
return "file" !== t.type || t.value && t.value instanceof e.File ? "string" !== t.type || t.value && "string" == typeof t.value ? "array" !== t.type || t.value && "Array" === Object.prototype.toString.call(t.value).slice(8, -1) ? "query" !== t.type || t.value && t.value instanceof u.Query ? "data" !== t.type || t.value && t.value instanceof e.Data ? !0 : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: data is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: query is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: targets is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: target is invalid")), !1) : (n.options.error(new a(o.INVALID_PARAMS, "[" + r + "]: file is null or not typeof File of baidu.frontia")), !1)
})
},uploadFile: function(o, i) {
var c = {};
c.action_name = "storage.uploadFile", c.timestamp = n();
var u = this;
if (i = i || {}, u._configure(i), u._checkParams([{value: o,type: "file"}], "storage.uploadFile")) {
var f = {file: o._getFile(),acl: o._getACLInfo(),target: o._getTarget()}, l = u._attachAccount({method: "getuploadurl"}), p = e.ajax;
p.post(s, JSON.stringify(l), "json", {header: {authorization: t(e.getApiKey())},contentType: "application/json",callback: function(o) {
if (o.error_code)
u.options.error(new a(o));
else {
var i = o.response_params.url + "&dumpheader=1", l = new FileReader;
l.onload = function() {
var o = l.result;
p.put(i, o, "json", {contentType: "application/octet-stream",callback: function(r) {
if (0 !== r.Error.Code)
u.options.error(new a(r.Error));
else {
var n = u._createAjaxOpt(c, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), o = u._attachAccount({method: "create",md5s: [r.Header["Content-MD5"]],object: f.target,_acl: f.acl});
p.post(s, JSON.stringify(o), "json", n)
}
},onerror: function(e, t) {
try {
var o = JSON.parse(e.responseText)
} catch (i) {
return u.options.error(i, e), void 0
}
var t = new a(o.Error);
u.options.error(t, e), c.err_code = t.code, c.err_msg = t.message, c.restimestamp = n(), r(c)
}})
}, l.readAsArrayBuffer(f.file)
}
},onerror: function(e, t) {
try {
var o = JSON.parse(e.responseText)
} catch (i) {
return u.options.error(i, e), void 0
}
var t = new a(o);
u.options.error(t, e), c.err_code = t.code, c.err_msg = t.message, c.restimestamp = n(), r(c)
}})
}
},getFileUrl: function(r, a) {
var o = {};
o.action_name = "storage.getFileUrl", o.timestamp = n();
var i = this;
if (a = a || {}, i._configure(a), i._checkParams([{value: r,type: "string"}], "storage.getFileUrl")) {
var c = i._attachAccount({method: "getdownloadurl",object: r}), u = i._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), f = e.ajax;
f.post(s, JSON.stringify(c), "json", u)
}
},deleteFile: function(r, a) {
var o = {};
o.action_name = "storage.deleteFile", o.timestamp = n();
var i = this;
if (a = a || {}, i._configure(a), i._checkParams([{value: r,type: "string"}], "storage.deleteFile")) {
var c = i._attachAccount({method: "delete",object: r}), u = i._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), f = e.ajax;
f.post(s, JSON.stringify(c), "json", u)
}
},listFile: function(o, i) {
var c = {};
c.action_name = "storage.listFile", c.timestamp = n();
var u = this;
if (i = i || {}, u._configure(i), u._checkParams([{value: o,type: "string"}], "storage.listFile")) {
var f = u._attachAccount({method: "list",object: o}), l = u._createAjaxOpt(c, {header: {authorization: t(e.getApiKey())},contentType: "application/json"});
l.callback = function(t) {
if (t.error_code) {
var o = new a(t);
u.options.error(o), c.err_code = o.code, c.err_msg = o.message
} else {
var i = [];
t.response_params.object_list.forEach(function(t) {
var r = new e.ACL;
t._acl && (r._setPermission(t._acl), delete t._acl);
var n = new e.File(null, null, r);
n._setFileInfo(t), i.push(n)
}), u.options.success({result: i,count: t.response_params.object_total}), c.err_code = 0
}
c.restimestamp = n(), r(c)
};
var p = e.ajax;
p.post(s, JSON.stringify(f), "json", l)
}
},insertData: function(r, a) {
var o = {};
if (o.action_name = "storage.insertData", o.timestamp = n(), a = a || {}, this._configure(a), this._checkParams([{value: r,type: "data"}], "storage.insertData")) {
var s = r.getData(), c = r._getACLInfo();
c && (s._acl = c);
var u = this._attachAccount({method: "insert",documents: s}), f = this._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), l = e.ajax;
l.post(i, JSON.stringify(u), "json", f)
}
},deleteData: function(r, a) {
var o = {};
if (o.action_name = "storage.deleteData", o.timestamp = n(), a = a || {}, this._configure(a), this._checkParams([{value: r,type: "query"}], "storage.deleteData")) {
var s = this._attachAccount({method: "remove",criteria: r.query}), c = this._createAjaxOpt(o, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), u = e.ajax;
u.post(i, JSON.stringify(s), "json", c)
}
},updateData: function(r, a, o) {
var s = {};
if (s.action_name = "storage.updateData", s.timestamp = n(), o = o || {}, this._configure(o), this._checkParams([{value: r,type: "query"}, {value: a,type: "data"}], "storage.updateData")) {
var c = a.getData(), u = a._getACLInfo();
if (u)
if (c.hasOwnProperty("$set"))
c.$set._acl = u;
else {
var f = 0;
for (var l in c)
if (c.hasOwnProperty(l) && "$" === l[0]) {
f = 1, c.$set = {}, c.$set._acl = u;
break
}
0 === f && (c._acl = u)
}
var p = this._attachAccount({method: "update",criteria: r.query,document: c}), h = this._createAjaxOpt(s, {header: {authorization: t(e.getApiKey())},contentType: "application/json"}), d = e.ajax;
d.post(i, JSON.stringify(p), "json", h)
}
},findData: function(o, s) {
var c = {};
c.action_name = "storage.findData", c.timestamp = n();
var u = this;
if (s = s || {}, this._configure(s), this._checkParams([{value: o,type: "query"}], "storage.findData")) {
var f = this._attachAccount({method: "query",criteria: o.query}), l = this._createAjaxOpt(c, {header: {authorization: t(e.getApiKey())},contentType: "application/json"});
l.callback = function(t) {
if (t.error_code) {
var o = new a(t);
u.options.error(o), c.err_code = o.code, c.err_msg = o.message
} else {
var i = [];
t.response_params.documents.forEach(function(t) {
var r = new e.ACL;
t._acl && (r._setPermission(t._acl), delete t._acl);
var n = new e.Data(t, r);
i.push(n)
}), u.options.success({result: i,count: t.response_params.count}), c.err_code = 0
}
c.restimestamp = n(), r(c)
};
var p = e.ajax;
p.post(i, JSON.stringify(f), "json", l)
}
},_attachAccount: function(t) {
var r = null;
return e.currentAccount && e.currentAccount instanceof e.Role && e.currentAccount.getId() ? (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getId()) : e.currentAccount && e.currentAccount instanceof e.User && e.currentAccount.getAccessToken() && (r = "requester", t[r] = e.currentAccount.getType() + ":" + e.currentAccount.getAccessToken()), t
},_createAjaxOpt: function(t, o) {
var i = this, s = {callback: function(e) {
if (e.error_code) {
var o = new a(e);
i.options.error(o), t.err_code = o.code, t.err_msg = o.message
} else
i.options.success(e), t.err_code = 0;
t.restimestamp = n(), r(t)
},onerror: function(o, s) {
try {
var c = e.util.parseJSON(o.responseText)
} catch (u) {
return i.options.error(u, o), void 0
}
var s = new a(c);
i.options.error(s, o), t.err_code = s.code, t.err_msg = s.message, t.restimestamp = n(), r(t)
}};
return e.util.mix(s, o)
}};
u.Query = e.Base.extend({currentKey: null,query: null,constructor: function() {
},_set: function(e, t) {
this.query = this.query || {}, this.query[e] instanceof Object || (this.query[e] = {});
for (var r in t)
t.hasOwnProperty(r) && (this.query[e][r] = t[r])
},_build: function(e, t) {
if (null === this.currentKey)
throw new a("Query key must not be null");
switch (e) {
case u.Query.EQUAL:
this.query = this.query || {}, this.query[this.currentKey] = t;
break;
case u.Query.LESSTHAN:
this._set(this.currentKey, {$lt: t});
break;
case u.Query.LESSTHANEQUAL:
this._set(this.currentKey, {$lte: t});
break;
case u.Query.GREATERTHAN:
this._set(this.currentKey, {$gt: t});
break;
case u.Query.GREATERTHANEQUAL:
this._set(this.currentKey, {$gte: t});
break;
default:
throw new a("Query " + e + " is not supported")
}
},equal: function(e) {
return this._build(u.Query.EQUAL, e), this
},lessThan: function(e) {
return this._build(u.Query.LESSTHAN, e), this
},lessThanEqual: function(e) {
return this._build(u.Query.LESSTHANEQUAL, e), this
},greaterThan: function(e) {
return this._build(u.Query.GREATERTHAN, e), this
},greaterThanEqual: function(e) {
return this._build(u.Query.GREATERTHANEQUAL, e), this
},on: function(e) {
return this.currentKey = e, this
}}, {EQUAL: 1,LESSTHAN: 2,LESSTHANEQUAL: 3,GREATERTHAN: 4,GREATERTHANEQUAL: 5}), e.storage = u
}(baidu.frontia), baidu.frontia.personalStorage = baidu.frontia.personalStorage || {}, function(e) {
function t(e, t, r) {
var n, a = {}, o = null, i = null;
t = t || {}, "string" == typeof e ? (o = "/" === e.slice(0, 1) ? e : "/".concat(e), a.path = o) : e && (i = {list: []}, e.forEach(function(e) {
o = "/" === e.slice(0, 1) ? e : "/".concat(e), i.list.push({path: o})
}), i = JSON.stringify(i));
for (n in t)
t.hasOwnProperty(n) && -1 === r.indexOf(n) && (a[n] = t[n]);
return {query: a,body: i}
}
function r(t, r) {
var n = [s, t, e.util.serializeURL(r)].join("");
return n
}
function n(t) {
var r = {application_info: [{app_frontia_version: e.version,app_appid: e.getApiKey(),user_id: e.getCurrentAccount().getId() || "",frontia_action: [{action_name: "",timestamp: null,restimestamp: null,err_code: "",err_msg: ""}]}]};
r.application_info[0].frontia_action[0] = t;
var n = {}, a = new Zlib.Gzip(new Uint8Array(JSON.stringify(r).split("").map(function(e) {
return e.charCodeAt(0)
}))), o = a.compress();
n.stats = btoa(String.fromCharCode.apply(null, o));
var i = e.ajax;
i.post(c, JSON.stringify(n), "json", {contentType: "application/json"})
}
function a() {
var e = Math.floor((new Date).getTime() / 1e3);
return e
}
var o = baidu.frontia.error, i = baidu.frontia.ERR_MSG, s = e.DomainManager.getPCSDomain() + "/rest/2.0/pcs/", c = e.DomainManager.getPBLogDomain() + "/pushlog";
e.apiKey;
var u = {};
u = {options: {error: function() {
},success: function() {
}},_configure: function(e) {
e = e || {}, e.error && (this.options.error = e.error), e.success && (this.options.success = e.success)
},_checkParams: function(e, t) {
var r = this;
return e.every(function(e) {
return "file" !== e.type || e.value && e.value instanceof File ? "string" !== e.type || e.value && "string" == typeof e.value ? "array" !== e.type || e.value && "Array" === Object.prototype.toString.call(e.value).slice(8, -1) ? !0 : (r.options.error(new o(i.INVALID_PARAMS, "[" + t + "]: targets is invalid")), !1) : (r.options.error(new o(i.INVALID_PARAMS, "[" + t + "]: target is invalid")), !1) : (r.options.error(new o(i.INVALID_PARAMS, "[" + t + "]: file is null or not typeof File of DOM")), !1)
})
},_createAjaxOpt: function(t, r, cb) {
var i = this, s = {callback: function(e) {
if (e.error_code) {
var r = new o(e);
i.options.error(r), t.err_code = r.code, t.err_msg = r.message
} else
(cb && cb.success || i.options.success)(e), t.err_code = 0;
t.restimestamp = a(), n(t)
},onerror: function(r, s) {
try {
var c = e.util.parseJSON(r.responseText)
} catch (u) {
return i.options.error(u, r), void 0
}
var s = new o(c);
i.options.error(s, r), t.err_code = s.code, t.err_msg = s.message, t.restimestamp = a(), n(t)
}};
return e.util.mix(s, r)
},uploadFile: function(n, o, i) {
var s = {};
s.action_name = "personalStorage.uploadFile", s.timestamp = a();
var c = this;
if (i = i || {}, c._configure(i), c._checkParams([{value: n,type: "file"}, {value: o,type: "string"}], "personalStorage.uploadFile")) {
i.method = "upload";
var u = e.getCurrentAccount();
u && (accessToken = u.getAccessToken()), i.access_token = accessToken;
var f = t(o, i, ["success", "error"]), l = r("file?", f.query), p = c._createAjaxOpt(s, {contentType: "multipart/form-data"}), h = e.ajax, d = new FormData;
d.append("baidu_frontia_file", n), h.post(l, d, "json", p)
}
},uploadTextFile: function(text, target, options) {
var s = {};
s.action_name = "personalStorage.uploadFile", s.timestamp = a();
var c = this;
if (options = options || {}, c._configure(options), c._checkParams([{value: text,type: "string"}, {value: target,type: "string"}], "personalStorage.uploadFile")) {
options.method = "upload";
var u = e.getCurrentAccount();
u && (accessToken = u.getAccessToken()), options.access_token = accessToken;
var f = t(target, options, ["success", "error"]), l = r("file?", f.query), p = c._createAjaxOpt(s, {contentType: "multipart/form-data"}), h = e.ajax, d = new FormData;
var blob = new Blob([text], {type: 'text/plain'});
d.append("baidu_frontia_file", blob), h.post(l, d, "json", p);
}
},getFileUrl: function(i, s) {
var c = {};
c.action_name = "personalStorage.getFileUrl", c.timestamp = a();
var u = this;
if (s = s || {}, u._configure(s), u._checkParams([{value: i,type: "string"}], "personalStorage.getFileUrl")) {
var f = e.getCurrentAccount();
f && (accessToken = f.getAccessToken()), s.access_token = accessToken, s.method = "download";
var l = t(i, s, ["success", "error"]), p = r("file?", l.query);
s.method = "meta", l = t(i, s, ["success", "error"]);
var h = r("file?", l.query), d = {callback: function(e) {
if (e.error_code) {
var t = new o(e);
u.options.error(t), c.err_code = t.code, c.err_msg = t.message
} else
(s.success || u.options.success)(p), c.err_code = 0;
c.restimestamp = a(), n(c)
},onerror: function(t, r) {
try {
var i = e.util.parseJSON(t.responseText)
} catch (ss) {
return (s.error || u.options.error)(ss, t), void 0
}
var r = new o(i);
u.options.error(r, t), c.err_code = r.code, c.err_msg = r.message, c.restimestamp = a(), n(c)
},dataType: "json"}, g = e.ajax;
g.get(h, {}, d)
}
},deleteFile: function(n, o) {
var i = {};
i.action_name = "personalStorage.deleteFile", i.timestamp = a();
var s = this;
if (o = o || {}, s._configure(o), s._checkParams([{value: n,type: "array"}], "personalStorage.deleteFile")) {
o.method = "delete";
var c = e.getCurrentAccount();
c && (accessToken = c.getAccessToken()), o.access_token = accessToken;
var u = t(n, o, ["success", "error"]), f = r("file?", u.query), l = s._createAjaxOpt(i), p = e.ajax;
p.post(f, {param: u.body}, "json", l)
}
},listFile: function(n, o) {
var i = {};
i.action_name = "personalStorage.listFile", i.timestamp = a();
var s = this;
if (o = o || {}, s._configure(o), s._checkParams([{value: n,type: "string"}], "personalStorage.listFile")) {
o.method = "list";
var c = e.getCurrentAccount();
c && (accessToken = c.getAccessToken()), o.access_token = accessToken;
var u = t(n, o, ["success", "error"]), f = r("file?", u.query), l = s._createAjaxOpt(i, {dataType: "json"}, o), p = e.ajax;
p.get(f, {}, l)
}
},listStreamFile: function(n) {
var o = {};
o.action_name = "personalStorage.listStreamFile", o.timestamp = a();
var i = this;
n = n || {}, i._configure(n), n.method = "list";
var s = e.getCurrentAccount();
s && (accessToken = s.getAccessToken()), n.access_token = accessToken;
var c = t(null, n, ["success", "error"]);
n.filter_path && (c.query.filter_path = n.filter_path);
var u = r("stream?", c.query), f = i._createAjaxOpt(o, {dataType: "json"}), l = e.ajax;
l.get(u, {}, f)
},makeDir: function(n, o) {
var i = {};
i.action_name = "personalStorage.makeDir", i.timestamp = a();
var s = this;
if (o = o || {}, s._configure(o), s._checkParams([{value: n,type: "string"}], "personalStorage.makeDir")) {
o.method = "mkdir";
var c = e.getCurrentAccount();
c && (accessToken = c.getAccessToken()), o.access_token = accessToken;
var u = t(n, o, ["success", "error"]), f = r("file?", u.query), l = s._createAjaxOpt({dataType: "json"}), p = e.ajax;
p.post(f, {}, "json", l)
}
},getQuota: function(n) {
var o = {};
o.action_name = "personalStorage.getQuota", o.timestamp = a();
var i = this;
if (n = n || {}, i._configure(n), i._checkParams([], "psersonalStorage.getQuota")) {
n.method = "info";
var s = e.getCurrentAccount();
s && (accessToken = s.getAccessToken()), n.access_token = accessToken;
var c = t(null, n, ["success", "error"]), u = r("quota?", c.query), f = i._createAjaxOpt(o, {dataType: "json"}), l = e.ajax;
l.get(u, {}, f)
}
}}, u.constant = {ONDUP_OVERWRITE: "overwrite",ONDUP_NEWCOPY: "newcopy",BY_NAME: "name",BY_TIME: "time",BY_SIZE: "size",ORDER_ASC: "asc",ORDER_DESC: "desc",TYPE_STREAM_VIDEO: "video",TYPE_STREAM_AUDIO: "audio",TYPE_STREAM_IMAGE: "image",TYPE_STREAM_DOC: "doc"}, e.personalStorage = u
}(baidu.frontia), baidu.frontia.store = baidu.frontia.store || {}, function(e) {
function t(t) {
var r = e.util.toBase64("Application:" + t);
return "Basic " + r
}
function r() {
var e = Math.floor((new Date).getTime() / 1e3);
return e
}
var n = e.error;
e.ERR_MSG;
var a = e.DomainManager.getFrontiaDomain() + "/push";
e.DomainManager.getPBLogDomain() + "/pushlog";
var o = {options: {error: function() {
},success: function() {
}},_configure: function(e) {
e = e || {}, e.error && (this.options.error = e.error), e.success && (this.options.success = e.success)
},send: function(n, o) {
var i = {};
i.action_name = "Push.list", i.timestamp = r();
var s = this;
o = o || {}, s._configure(o);
var c = a, u = {method: "pushmsg",messages: n.messages,msg_keys: n.msg_keys};
for (var f in o)
o.hasOwnProperty(f) && "success" !== f && "error" !== f && (u[f] = o[f]);
var l = s._createAjaxOpt({header: {authorization: t(e.getApiKey())},contentType: "application/json"}), p = e.ajax;
p.post(c, JSON.stringify(u), "json", l)
},_createAjaxOpt: function(t) {
var r = this, a = {callback: function(e) {
e.error_code ? r.options.error(new n(e)) : e && e.error_code ? r.options.error(new n(e)) : r.options.success(e)
},onerror: function(t) {
try {
var a = e.util.parseJSON(t.responseText)
} catch (o) {
return r.options.error(o, t), void 0
}
r.options.error(new n(a), t)
}};
return e.util.mix(a, t)
}};
e.Push = o
}(baidu.frontia);
/*
Copyright (c) 2012 Gildas Lormeau. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
* JZlib is based on zlib-1.1.3, so all credit should go authors
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
* and contributors of zlib.
*/
(function(obj) {
// Global
var MAX_BITS = 15;
var Z_OK = 0;
var Z_STREAM_END = 1;
var Z_NEED_DICT = 2;
var Z_STREAM_ERROR = -2;
var Z_DATA_ERROR = -3;
var Z_MEM_ERROR = -4;
var Z_BUF_ERROR = -5;
var inflate_mask = [ 0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff,
0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff ];
var MANY = 1440;
// JZlib version : "1.0.2"
var Z_NO_FLUSH = 0;
var Z_FINISH = 4;
// InfTree
var fixed_bl = 9;
var fixed_bd = 5;
var fixed_tl = [ 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0,
0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40,
0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13,
0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60,
0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7,
35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8,
26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80,
7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0,
8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0,
8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97,
0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210,
81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117,
0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154,
84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83,
0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230,
80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139,
0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174,
0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111,
0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9,
193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8,
120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8,
227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8,
92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9,
249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8,
130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9,
181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8,
102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9,
221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0,
8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9,
147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8,
85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9,
235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8,
141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9,
167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8,
107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9,
207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8,
127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255 ];
var fixed_td = [ 80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5,
8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5,
24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577 ];
// Tables for deflate from PKZIP's appnote.txt.
var cplens = [ // Copy lengths for literal codes 257..285
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ];
// see note #13 above about 258
var cplext = [ // Extra bits for literal codes 257..285
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112 // 112==invalid
];
var cpdist = [ // Copy offsets for distance codes 0..29
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ];
var cpdext = [ // Extra bits for distance codes
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ];
// If BMAX needs to be larger than 16, then h and x[] should be uLong.
var BMAX = 15; // maximum bit length of any code
function InfTree() {
var that = this;
var hn; // hufts used in space
var v; // work area for huft_build
var c; // bit length count table
var r; // table entry for structure assignment
var u; // table stack
var x; // bit offsets, then code stack
function huft_build(b, // code lengths in bits (all assumed <=
// BMAX)
bindex, n, // number of codes (assumed <= 288)
s, // number of simple-valued codes (0..s-1)
d, // list of base values for non-simple codes
e, // list of extra bits for non-simple codes
t, // result: starting table
m, // maximum lookup bits, returns actual
hp,// space for trees
hn,// hufts used in space
v // working area: values in order of bit length
) {
// Given a list of code lengths and a maximum table size, make a set of
// tables to decode that set of codes. Return Z_OK on success,
// Z_BUF_ERROR
// if the given code set is incomplete (the tables are still built in
// this
// case), Z_DATA_ERROR if the input is invalid (an over-subscribed set
// of
// lengths), or Z_MEM_ERROR if not enough memory.
var a; // counter for codes of length k
var f; // i repeats in table every f entries
var g; // maximum code length
var h; // table level
var i; // counter, current code
var j; // counter
var k; // number of bits in current code
var l; // bits per table (returned in m)
var mask; // (1 << w) - 1, to avoid cc -O bug on HP
var p; // pointer into c[], b[], or v[]
var q; // points to current table
var w; // bits before this table == (l * h)
var xp; // pointer into x
var y; // number of dummy codes added
var z; // number of entries in current table
// Generate counts for each bit length
p = 0;
i = n;
do {
c[b[bindex + p]]++;
p++;
i--; // assume all entries <= BMAX
} while (i !== 0);
if (c[0] == n) { // null input--all zero length codes
t[0] = -1;
m[0] = 0;
return Z_OK;
}
// Find minimum and maximum length, bound *m by those
l = m[0];
for (j = 1; j <= BMAX; j++)
if (c[j] !== 0)
break;
k = j; // minimum code length
if (l < j) {
l = j;
}
for (i = BMAX; i !== 0; i--) {
if (c[i] !== 0)
break;
}
g = i; // maximum code length
if (l > i) {
l = i;
}
m[0] = l;
// Adjust last length count to fill out codes, if needed
for (y = 1 << j; j < i; j++, y <<= 1) {
if ((y -= c[j]) < 0) {
return Z_DATA_ERROR;
}
}
if ((y -= c[i]) < 0) {
return Z_DATA_ERROR;
}
c[i] += y;
// Generate starting offsets into the value table for each length
x[1] = j = 0;
p = 1;
xp = 2;
while (--i !== 0) { // note that i == g from above
x[xp] = (j += c[p]);
xp++;
p++;
}
// Make a table of values in order of bit lengths
i = 0;
p = 0;
do {
if ((j = b[bindex + p]) !== 0) {
v[x[j]++] = i;
}
p++;
} while (++i < n);
n = x[g]; // set n to length of v
// Generate the Huffman codes and for each, make the table entries
x[0] = i = 0; // first Huffman code is zero
p = 0; // grab values in bit order
h = -1; // no tables yet--level -1
w = -l; // bits decoded == (l * h)
u[0] = 0; // just to keep compilers happy
q = 0; // ditto
z = 0; // ditto
// go through the bit lengths (k already is bits in shortest code)
for (; k <= g; k++) {
a = c[k];
while (a-- !== 0) {
// here i is the Huffman code of length k bits for value *p
// make tables up to required level
while (k > w + l) {
h++;
w += l; // previous table always l bits
// compute minimum size table less than or equal to l bits
z = g - w;
z = (z > l) ? l : z; // table size upper limit
if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table
// too few codes for
// k-w bit table
f -= a + 1; // deduct codes from patterns left
xp = k;
if (j < z) {
while (++j < z) { // try smaller tables up to z bits
if ((f <<= 1) <= c[++xp])
break; // enough codes to use up j bits
f -= c[xp]; // else deduct codes from patterns
}
}
}
z = 1 << j; // table entries for j-bit table
// allocate new table
if (hn[0] + z > MANY) { // (note: doesn't matter for fixed)
return Z_DATA_ERROR; // overflow of MANY
}
u[h] = q = /* hp+ */hn[0]; // DEBUG
hn[0] += z;
// connect to last table, if there is one
if (h !== 0) {
x[h] = i; // save pattern for backing up
r[0] = /* (byte) */j; // bits in this table
r[1] = /* (byte) */l; // bits to dump before this table
j = i >>> (w - l);
r[2] = /* (int) */(q - u[h - 1] - j); // offset to this table
hp.set(r, (u[h - 1] + j) * 3);
// to
// last
// table
} else {
t[0] = q; // first table is returned result
}
}
// set up table entry in r
r[1] = /* (byte) */(k - w);
if (p >= n) {
r[0] = 128 + 64; // out of values--invalid code
} else if (v[p] < s) {
r[0] = /* (byte) */(v[p] < 256 ? 0 : 32 + 64); // 256 is
// end-of-block
r[2] = v[p++]; // simple code is just the value
} else {
r[0] = /* (byte) */(e[v[p] - s] + 16 + 64); // non-simple--look
// up in lists
r[2] = d[v[p++] - s];
}
// fill code-like entries with r
f = 1 << (k - w);
for (j = i >>> w; j < z; j += f) {
hp.set(r, (q + j) * 3);
}
// backwards increment the k-bit code i
for (j = 1 << (k - 1); (i & j) !== 0; j >>>= 1) {
i ^= j;
}
i ^= j;
// backup over finished tables
mask = (1 << w) - 1; // needed on HP, cc -O bug
while ((i & mask) != x[h]) {
h--; // don't need to update q
w -= l;
mask = (1 << w) - 1;
}
}
}
// Return Z_BUF_ERROR if we were given an incomplete table
return y !== 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
}
function initWorkArea(vsize) {
var i;
if (!hn) {
hn = []; // []; //new Array(1);
v = []; // new Array(vsize);
c = new Int32Array(BMAX + 1); // new Array(BMAX + 1);
r = []; // new Array(3);
u = new Int32Array(BMAX); // new Array(BMAX);
x = new Int32Array(BMAX + 1); // new Array(BMAX + 1);
}
if (v.length < vsize) {
v = []; // new Array(vsize);
}
for (i = 0; i < vsize; i++) {
v[i] = 0;
}
for (i = 0; i < BMAX + 1; i++) {
c[i] = 0;
}
for (i = 0; i < 3; i++) {
r[i] = 0;
}
// for(int i=0; i<BMAX; i++){u[i]=0;}
u.set(c.subarray(0, BMAX), 0);
// for(int i=0; i<BMAX+1; i++){x[i]=0;}
x.set(c.subarray(0, BMAX + 1), 0);
}
that.inflate_trees_bits = function(c, // 19 code lengths
bb, // bits tree desired/actual depth
tb, // bits tree result
hp, // space for trees
z // for messages
) {
var result;
initWorkArea(19);
hn[0] = 0;
result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);
if (result == Z_DATA_ERROR) {
z.msg = "oversubscribed dynamic bit lengths tree";
} else if (result == Z_BUF_ERROR || bb[0] === 0) {
z.msg = "incomplete dynamic bit lengths tree";
result = Z_DATA_ERROR;
}
return result;
};
that.inflate_trees_dynamic = function(nl, // number of literal/length codes
nd, // number of distance codes
c, // that many (total) code lengths
bl, // literal desired/actual bit depth
bd, // distance desired/actual bit depth
tl, // literal/length tree result
td, // distance tree result
hp, // space for trees
z // for messages
) {
var result;
// build literal/length tree
initWorkArea(288);
hn[0] = 0;
result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
if (result != Z_OK || bl[0] === 0) {
if (result == Z_DATA_ERROR) {
z.msg = "oversubscribed literal/length tree";
} else if (result != Z_MEM_ERROR) {
z.msg = "incomplete literal/length tree";
result = Z_DATA_ERROR;
}
return result;
}
// build distance tree
initWorkArea(288);
result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);
if (result != Z_OK || (bd[0] === 0 && nl > 257)) {
if (result == Z_DATA_ERROR) {
z.msg = "oversubscribed distance tree";
} else if (result == Z_BUF_ERROR) {
z.msg = "incomplete distance tree";
result = Z_DATA_ERROR;
} else if (result != Z_MEM_ERROR) {
z.msg = "empty distance tree with lengths";
result = Z_DATA_ERROR;
}
return result;
}
return Z_OK;
};
}
InfTree.inflate_trees_fixed = function(bl, // literal desired/actual bit depth
bd, // distance desired/actual bit depth
tl,// literal/length tree result
td// distance tree result
) {
bl[0] = fixed_bl;
bd[0] = fixed_bd;
tl[0] = fixed_tl;
td[0] = fixed_td;
return Z_OK;
};
// InfCodes
// waiting for "i:"=input,
// "o:"=output,
// "x:"=nothing
var START = 0; // x: set up for LEN
var LEN = 1; // i: get length/literal/eob next
var LENEXT = 2; // i: getting length extra (have base)
var DIST = 3; // i: get distance next
var DISTEXT = 4;// i: getting distance extra
var COPY = 5; // o: copying bytes in window, waiting
// for space
var LIT = 6; // o: got literal, waiting for output
// space
var WASH = 7; // o: got eob, possibly still output
// waiting
var END = 8; // x: got eob and all data flushed
var BADCODE = 9;// x: got error
function InfCodes() {
var that = this;
var mode; // current inflate_codes mode
// mode dependent information
var len = 0;
var tree; // pointer into tree
var tree_index = 0;
var need = 0; // bits needed
var lit = 0;
// if EXT or COPY, where and how much
var get = 0; // bits to get for extra
var dist = 0; // distance back to copy from
var lbits = 0; // ltree bits decoded per branch
var dbits = 0; // dtree bits decoder per branch
var ltree; // literal/length/eob tree
var ltree_index = 0; // literal/length/eob tree
var dtree; // distance tree
var dtree_index = 0; // distance tree
// Called with number of bytes left to write in window at least 258
// (the maximum string length) and number of input bytes available
// at least ten. The ten bytes are six bytes for the longest length/
// distance pair plus four bytes for overloading the bit buffer.
function inflate_fast(bl, bd, tl, tl_index, td, td_index, s, z) {
var t; // temporary pointer
var tp; // temporary pointer
var tp_index; // temporary pointer
var e; // extra bits or operation
var b; // bit buffer
var k; // bits in bit buffer
var p; // input data pointer
var n; // bytes available there
var q; // output window write pointer
var m; // bytes to end of window or read pointer
var ml; // mask for literal/length tree
var md; // mask for distance tree
var c; // bytes to copy
var d; // distance back to copy from
var r; // copy source pointer
var tp_index_t_3; // (tp_index+t)*3
// load input, output, bit values
p = z.next_in_index;
n = z.avail_in;
b = s.bitb;
k = s.bitk;
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
// initialize masks
ml = inflate_mask[bl];
md = inflate_mask[bd];
// do until not enough input or output space for fast loop
do { // assume called with m >= 258 && n >= 10
// get literal/length code
while (k < (20)) { // max bits for literal/length code
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
t = b & ml;
tp = tl;
tp_index = tl_index;
tp_index_t_3 = (tp_index + t) * 3;
if ((e = tp[tp_index_t_3]) === 0) {
b >>= (tp[tp_index_t_3 + 1]);
k -= (tp[tp_index_t_3 + 1]);
s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2];
m--;
continue;
}
do {
b >>= (tp[tp_index_t_3 + 1]);
k -= (tp[tp_index_t_3 + 1]);
if ((e & 16) !== 0) {
e &= 15;
c = tp[tp_index_t_3 + 2] + (/* (int) */b & inflate_mask[e]);
b >>= e;
k -= e;
// decode distance base of block to copy
while (k < (15)) { // max bits for distance code
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
t = b & md;
tp = td;
tp_index = td_index;
tp_index_t_3 = (tp_index + t) * 3;
e = tp[tp_index_t_3];
do {
b >>= (tp[tp_index_t_3 + 1]);
k -= (tp[tp_index_t_3 + 1]);
if ((e & 16) !== 0) {
// get extra bits to add to distance base
e &= 15;
while (k < (e)) { // get extra bits (up to 13)
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
d = tp[tp_index_t_3 + 2] + (b & inflate_mask[e]);
b >>= (e);
k -= (e);
// do the copy
m -= c;
if (q >= d) { // offset before dest
// just copy
r = q - d;
if (q - r > 0 && 2 > (q - r)) {
s.window[q++] = s.window[r++]; // minimum
// count is
// three,
s.window[q++] = s.window[r++]; // so unroll
// loop a
// little
c -= 2;
} else {
s.window.set(s.window.subarray(r, r + 2), q);
q += 2;
r += 2;
c -= 2;
}
} else { // else offset after destination
r = q - d;
do {
r += s.end; // force pointer in window
} while (r < 0); // covers invalid distances
e = s.end - r;
if (c > e) { // if source crosses,
c -= e; // wrapped copy
if (q - r > 0 && e > (q - r)) {
do {
s.window[q++] = s.window[r++];
} while (--e !== 0);
} else {
s.window.set(s.window.subarray(r, r + e), q);
q += e;
r += e;
e = 0;
}
r = 0; // copy rest from start of window
}
}
// copy all or what's left
if (q - r > 0 && c > (q - r)) {
do {
s.window[q++] = s.window[r++];
} while (--c !== 0);
} else {
s.window.set(s.window.subarray(r, r + c), q);
q += c;
r += c;
c = 0;
}
break;
} else if ((e & 64) === 0) {
t += tp[tp_index_t_3 + 2];
t += (b & inflate_mask[e]);
tp_index_t_3 = (tp_index + t) * 3;
e = tp[tp_index_t_3];
} else {
z.msg = "invalid distance code";
c = z.avail_in - n;
c = (k >> 3) < c ? k >> 3 : c;
n += c;
p -= c;
k -= c << 3;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return Z_DATA_ERROR;
}
} while (true);
break;
}
if ((e & 64) === 0) {
t += tp[tp_index_t_3 + 2];
t += (b & inflate_mask[e]);
tp_index_t_3 = (tp_index + t) * 3;
if ((e = tp[tp_index_t_3]) === 0) {
b >>= (tp[tp_index_t_3 + 1]);
k -= (tp[tp_index_t_3 + 1]);
s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2];
m--;
break;
}
} else if ((e & 32) !== 0) {
c = z.avail_in - n;
c = (k >> 3) < c ? k >> 3 : c;
n += c;
p -= c;
k -= c << 3;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return Z_STREAM_END;
} else {
z.msg = "invalid literal/length code";
c = z.avail_in - n;
c = (k >> 3) < c ? k >> 3 : c;
n += c;
p -= c;
k -= c << 3;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return Z_DATA_ERROR;
}
} while (true);
} while (m >= 258 && n >= 10);
// not enough input or output--restore pointers and return
c = z.avail_in - n;
c = (k >> 3) < c ? k >> 3 : c;
n += c;
p -= c;
k -= c << 3;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return Z_OK;
}
that.init = function(bl, bd, tl, tl_index, td, td_index) {
mode = START;
lbits = /* (byte) */bl;
dbits = /* (byte) */bd;
ltree = tl;
ltree_index = tl_index;
dtree = td;
dtree_index = td_index;
tree = null;
};
that.proc = function(s, z, r) {
var j; // temporary storage
var tindex; // temporary pointer
var e; // extra bits or operation
var b = 0; // bit buffer
var k = 0; // bits in bit buffer
var p = 0; // input data pointer
var n; // bytes available there
var q; // output window write pointer
var m; // bytes to end of window or read pointer
var f; // pointer to copy strings from
// copy input/output information to locals (UPDATE macro restores)
p = z.next_in_index;
n = z.avail_in;
b = s.bitb;
k = s.bitk;
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
// process input and output based on current state
while (true) {
switch (mode) {
// waiting for "i:"=input, "o:"=output, "x:"=nothing
case START: // x: set up for LEN
if (m >= 258 && n >= 10) {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z);
p = z.next_in_index;
n = z.avail_in;
b = s.bitb;
k = s.bitk;
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
if (r != Z_OK) {
mode = r == Z_STREAM_END ? WASH : BADCODE;
break;
}
}
need = lbits;
tree = ltree;
tree_index = ltree_index;
mode = LEN;
case LEN: // i: get length/literal/eob next
j = need;
while (k < (j)) {
if (n !== 0)
r = Z_OK;
else {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
tindex = (tree_index + (b & inflate_mask[j])) * 3;
b >>>= (tree[tindex + 1]);
k -= (tree[tindex + 1]);
e = tree[tindex];
if (e === 0) { // literal
lit = tree[tindex + 2];
mode = LIT;
break;
}
if ((e & 16) !== 0) { // length
get = e & 15;
len = tree[tindex + 2];
mode = LENEXT;
break;
}
if ((e & 64) === 0) { // next table
need = e;
tree_index = tindex / 3 + tree[tindex + 2];
break;
}
if ((e & 32) !== 0) { // end of block
mode = WASH;
break;
}
mode = BADCODE; // invalid code
z.msg = "invalid literal/length code";
r = Z_DATA_ERROR;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
case LENEXT: // i: getting length extra (have base)
j = get;
while (k < (j)) {
if (n !== 0)
r = Z_OK;
else {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
len += (b & inflate_mask[j]);
b >>= j;
k -= j;
need = dbits;
tree = dtree;
tree_index = dtree_index;
mode = DIST;
case DIST: // i: get distance next
j = need;
while (k < (j)) {
if (n !== 0)
r = Z_OK;
else {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
tindex = (tree_index + (b & inflate_mask[j])) * 3;
b >>= tree[tindex + 1];
k -= tree[tindex + 1];
e = (tree[tindex]);
if ((e & 16) !== 0) { // distance
get = e & 15;
dist = tree[tindex + 2];
mode = DISTEXT;
break;
}
if ((e & 64) === 0) { // next table
need = e;
tree_index = tindex / 3 + tree[tindex + 2];
break;
}
mode = BADCODE; // invalid code
z.msg = "invalid distance code";
r = Z_DATA_ERROR;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
case DISTEXT: // i: getting distance extra
j = get;
while (k < (j)) {
if (n !== 0)
r = Z_OK;
else {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
dist += (b & inflate_mask[j]);
b >>= j;
k -= j;
mode = COPY;
case COPY: // o: copying bytes in window, waiting for space
f = q - dist;
while (f < 0) { // modulo window size-"while" instead
f += s.end; // of "if" handles invalid distances
}
while (len !== 0) {
if (m === 0) {
if (q == s.end && s.read !== 0) {
q = 0;
m = q < s.read ? s.read - q - 1 : s.end - q;
}
if (m === 0) {
s.write = q;
r = s.inflate_flush(z, r);
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
if (q == s.end && s.read !== 0) {
q = 0;
m = q < s.read ? s.read - q - 1 : s.end - q;
}
if (m === 0) {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
}
}
s.window[q++] = s.window[f++];
m--;
if (f == s.end)
f = 0;
len--;
}
mode = START;
break;
case LIT: // o: got literal, waiting for output space
if (m === 0) {
if (q == s.end && s.read !== 0) {
q = 0;
m = q < s.read ? s.read - q - 1 : s.end - q;
}
if (m === 0) {
s.write = q;
r = s.inflate_flush(z, r);
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
if (q == s.end && s.read !== 0) {
q = 0;
m = q < s.read ? s.read - q - 1 : s.end - q;
}
if (m === 0) {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
}
}
r = Z_OK;
s.window[q++] = /* (byte) */lit;
m--;
mode = START;
break;
case WASH: // o: got eob, possibly more output
if (k > 7) { // return unused byte, if any
k -= 8;
n++;
p--; // can always return one
}
s.write = q;
r = s.inflate_flush(z, r);
q = s.write;
m = q < s.read ? s.read - q - 1 : s.end - q;
if (s.read != s.write) {
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
mode = END;
case END:
r = Z_STREAM_END;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
case BADCODE: // x: got error
r = Z_DATA_ERROR;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
default:
r = Z_STREAM_ERROR;
s.bitb = b;
s.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
s.write = q;
return s.inflate_flush(z, r);
}
}
};
that.free = function() {
// ZFREE(z, c);
};
}
// InfBlocks
// Table for deflate from PKZIP's appnote.txt.
var border = [ // Order of the bit length code lengths
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
var TYPE = 0; // get type bits (3, including end bit)
var LENS = 1; // get lengths for stored
var STORED = 2;// processing stored block
var TABLE = 3; // get table lengths
var BTREE = 4; // get bit lengths tree for a dynamic
// block
var DTREE = 5; // get length, distance trees for a
// dynamic block
var CODES = 6; // processing fixed or dynamic block
var DRY = 7; // output remaining window bytes
var DONELOCKS = 8; // finished last block, done
var BADBLOCKS = 9; // ot a data error--stuck here
function InfBlocks(z, w) {
var that = this;
var mode = TYPE; // current inflate_block mode
var left = 0; // if STORED, bytes left to copy
var table = 0; // table lengths (14 bits)
var index = 0; // index into blens (or border)
var blens; // bit lengths of codes
var bb = [ 0 ]; // bit length tree depth
var tb = [ 0 ]; // bit length decoding tree
var codes = new InfCodes(); // if CODES, current state
var last = 0; // true if this block is the last block
var hufts = new Int32Array(MANY * 3); // single malloc for tree space
var check = 0; // check on output
var inftree = new InfTree();
that.bitk = 0; // bits in bit buffer
that.bitb = 0; // bit buffer
that.window = new Uint8Array(w); // sliding window
that.end = w; // one byte after sliding window
that.read = 0; // window read pointer
that.write = 0; // window write pointer
that.reset = function(z, c) {
if (c)
c[0] = check;
// if (mode == BTREE || mode == DTREE) {
// }
if (mode == CODES) {
codes.free(z);
}
mode = TYPE;
that.bitk = 0;
that.bitb = 0;
that.read = that.write = 0;
};
that.reset(z, null);
// copy as much as possible from the sliding window to the output area
that.inflate_flush = function(z, r) {
var n;
var p;
var q;
// local copies of source and destination pointers
p = z.next_out_index;
q = that.read;
// compute number of bytes to copy as far as end of window
n = /* (int) */((q <= that.write ? that.write : that.end) - q);
if (n > z.avail_out)
n = z.avail_out;
if (n !== 0 && r == Z_BUF_ERROR)
r = Z_OK;
// update counters
z.avail_out -= n;
z.total_out += n;
// copy as far as end of window
z.next_out.set(that.window.subarray(q, q + n), p);
p += n;
q += n;
// see if more to copy at beginning of window
if (q == that.end) {
// wrap pointers
q = 0;
if (that.write == that.end)
that.write = 0;
// compute bytes to copy
n = that.write - q;
if (n > z.avail_out)
n = z.avail_out;
if (n !== 0 && r == Z_BUF_ERROR)
r = Z_OK;
// update counters
z.avail_out -= n;
z.total_out += n;
// copy
z.next_out.set(that.window.subarray(q, q + n), p);
p += n;
q += n;
}
// update pointers
z.next_out_index = p;
that.read = q;
// done
return r;
};
that.proc = function(z, r) {
var t; // temporary storage
var b; // bit buffer
var k; // bits in bit buffer
var p; // input data pointer
var n; // bytes available there
var q; // output window write pointer
var m; // bytes to end of window or read pointer
var i;
// copy input/output information to locals (UPDATE macro restores)
// {
p = z.next_in_index;
n = z.avail_in;
b = that.bitb;
k = that.bitk;
// }
// {
q = that.write;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
// }
// process input based on current state
// DEBUG dtree
while (true) {
switch (mode) {
case TYPE:
while (k < (3)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
t = /* (int) */(b & 7);
last = t & 1;
switch (t >>> 1) {
case 0: // stored
// {
b >>>= (3);
k -= (3);
// }
t = k & 7; // go to byte boundary
// {
b >>>= (t);
k -= (t);
// }
mode = LENS; // get length of stored block
break;
case 1: // fixed
// {
var bl = []; // new Array(1);
var bd = []; // new Array(1);
var tl = [ [] ]; // new Array(1);
var td = [ [] ]; // new Array(1);
InfTree.inflate_trees_fixed(bl, bd, tl, td);
codes.init(bl[0], bd[0], tl[0], 0, td[0], 0);
// }
// {
b >>>= (3);
k -= (3);
// }
mode = CODES;
break;
case 2: // dynamic
// {
b >>>= (3);
k -= (3);
// }
mode = TABLE;
break;
case 3: // illegal
// {
b >>>= (3);
k -= (3);
// }
mode = BADBLOCKS;
z.msg = "invalid block type";
r = Z_DATA_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
break;
case LENS:
while (k < (32)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)) {
mode = BADBLOCKS;
z.msg = "invalid stored block lengths";
r = Z_DATA_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
left = (b & 0xffff);
b = k = 0; // dump bits
mode = left !== 0 ? STORED : (last !== 0 ? DRY : TYPE);
break;
case STORED:
if (n === 0) {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
if (m === 0) {
if (q == that.end && that.read !== 0) {
q = 0;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
}
if (m === 0) {
that.write = q;
r = that.inflate_flush(z, r);
q = that.write;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
if (q == that.end && that.read !== 0) {
q = 0;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
}
if (m === 0) {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
}
}
r = Z_OK;
t = left;
if (t > n)
t = n;
if (t > m)
t = m;
that.window.set(z.read_buf(p, t), q);
p += t;
n -= t;
q += t;
m -= t;
if ((left -= t) !== 0)
break;
mode = last !== 0 ? DRY : TYPE;
break;
case TABLE:
while (k < (14)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
table = t = (b & 0x3fff);
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) {
mode = BADBLOCKS;
z.msg = "too many length or distance symbols";
r = Z_DATA_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f);
if (!blens || blens.length < t) {
blens = []; // new Array(t);
} else {
for (i = 0; i < t; i++) {
blens[i] = 0;
}
}
// {
b >>>= (14);
k -= (14);
// }
index = 0;
mode = BTREE;
case BTREE:
while (index < 4 + (table >>> 10)) {
while (k < (3)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
blens[border[index++]] = b & 7;
// {
b >>>= (3);
k -= (3);
// }
}
while (index < 19) {
blens[border[index++]] = 0;
}
bb[0] = 7;
t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z);
if (t != Z_OK) {
r = t;
if (r == Z_DATA_ERROR) {
blens = null;
mode = BADBLOCKS;
}
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
index = 0;
mode = DTREE;
case DTREE:
while (true) {
t = table;
if (!(index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f))) {
break;
}
var j, c;
t = bb[0];
while (k < (t)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
// if (tb[0] == -1) {
// System.err.println("null...");
// }
t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1];
c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2];
if (c < 16) {
b >>>= (t);
k -= (t);
blens[index++] = c;
} else { // c == 16..18
i = c == 18 ? 7 : c - 14;
j = c == 18 ? 11 : 3;
while (k < (t + i)) {
if (n !== 0) {
r = Z_OK;
} else {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
n--;
b |= (z.read_byte(p++) & 0xff) << k;
k += 8;
}
b >>>= (t);
k -= (t);
j += (b & inflate_mask[i]);
b >>>= (i);
k -= (i);
i = index;
t = table;
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) {
blens = null;
mode = BADBLOCKS;
z.msg = "invalid bit length repeat";
r = Z_DATA_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
c = c == 16 ? blens[i - 1] : 0;
do {
blens[i++] = c;
} while (--j !== 0);
index = i;
}
}
tb[0] = -1;
// {
var bl_ = []; // new Array(1);
var bd_ = []; // new Array(1);
var tl_ = []; // new Array(1);
var td_ = []; // new Array(1);
bl_[0] = 9; // must be <= 9 for lookahead assumptions
bd_[0] = 6; // must be <= 9 for lookahead assumptions
t = table;
t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl_, bd_, tl_, td_, hufts, z);
if (t != Z_OK) {
if (t == Z_DATA_ERROR) {
blens = null;
mode = BADBLOCKS;
}
r = t;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
codes.init(bl_[0], bd_[0], hufts, tl_[0], hufts, td_[0]);
// }
mode = CODES;
case CODES:
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
if ((r = codes.proc(that, z, r)) != Z_STREAM_END) {
return that.inflate_flush(z, r);
}
r = Z_OK;
codes.free(z);
p = z.next_in_index;
n = z.avail_in;
b = that.bitb;
k = that.bitk;
q = that.write;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
if (last === 0) {
mode = TYPE;
break;
}
mode = DRY;
case DRY:
that.write = q;
r = that.inflate_flush(z, r);
q = that.write;
m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q);
if (that.read != that.write) {
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
mode = DONELOCKS;
case DONELOCKS:
r = Z_STREAM_END;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
case BADBLOCKS:
r = Z_DATA_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
default:
r = Z_STREAM_ERROR;
that.bitb = b;
that.bitk = k;
z.avail_in = n;
z.total_in += p - z.next_in_index;
z.next_in_index = p;
that.write = q;
return that.inflate_flush(z, r);
}
}
};
that.free = function(z) {
that.reset(z, null);
that.window = null;
hufts = null;
// ZFREE(z, s);
};
that.set_dictionary = function(d, start, n) {
that.window.set(d.subarray(start, start + n), 0);
that.read = that.write = n;
};
// Returns true if inflate is currently at the end of a block generated
// by Z_SYNC_FLUSH or Z_FULL_FLUSH.
that.sync_point = function() {
return mode == LENS ? 1 : 0;
};
}
// Inflate
// preset dictionary flag in zlib header
var PRESET_DICT = 0x20;
var Z_DEFLATED = 8;
var METHOD = 0; // waiting for method byte
var FLAG = 1; // waiting for flag byte
var DICT4 = 2; // four dictionary check bytes to go
var DICT3 = 3; // three dictionary check bytes to go
var DICT2 = 4; // two dictionary check bytes to go
var DICT1 = 5; // one dictionary check byte to go
var DICT0 = 6; // waiting for inflateSetDictionary
var BLOCKS = 7; // decompressing blocks
var DONE = 12; // finished check, done
var BAD = 13; // got an error--stay here
var mark = [ 0, 0, 0xff, 0xff ];
function Inflate() {
var that = this;
that.mode = 0; // current inflate mode
// mode dependent information
that.method = 0; // if FLAGS, method byte
// if CHECK, check values to compare
that.was = [ 0 ]; // new Array(1); // computed check value
that.need = 0; // stream check value
// if BAD, inflateSync's marker bytes count
that.marker = 0;
// mode independent information
that.wbits = 0; // log2(window size) (8..15, defaults to 15)
// this.blocks; // current inflate_blocks state
function inflateReset(z) {
if (!z || !z.istate)
return Z_STREAM_ERROR;
z.total_in = z.total_out = 0;
z.msg = null;
z.istate.mode = BLOCKS;
z.istate.blocks.reset(z, null);
return Z_OK;
}
that.inflateEnd = function(z) {
if (that.blocks)
that.blocks.free(z);
that.blocks = null;
// ZFREE(z, z->state);
return Z_OK;
};
that.inflateInit = function(z, w) {
z.msg = null;
that.blocks = null;
// set window size
if (w < 8 || w > 15) {
that.inflateEnd(z);
return Z_STREAM_ERROR;
}
that.wbits = w;
z.istate.blocks = new InfBlocks(z, 1 << w);
// reset state
inflateReset(z);
return Z_OK;
};
that.inflate = function(z, f) {
var r;
var b;
if (!z || !z.istate || !z.next_in)
return Z_STREAM_ERROR;
f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
r = Z_BUF_ERROR;
while (true) {
// System.out.println("mode: "+z.istate.mode);
switch (z.istate.mode) {
case METHOD:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
if (((z.istate.method = z.read_byte(z.next_in_index++)) & 0xf) != Z_DEFLATED) {
z.istate.mode = BAD;
z.msg = "unknown compression method";
z.istate.marker = 5; // can't try inflateSync
break;
}
if ((z.istate.method >> 4) + 8 > z.istate.wbits) {
z.istate.mode = BAD;
z.msg = "invalid window size";
z.istate.marker = 5; // can't try inflateSync
break;
}
z.istate.mode = FLAG;
case FLAG:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
b = (z.read_byte(z.next_in_index++)) & 0xff;
if ((((z.istate.method << 8) + b) % 31) !== 0) {
z.istate.mode = BAD;
z.msg = "incorrect header check";
z.istate.marker = 5; // can't try inflateSync
break;
}
if ((b & PRESET_DICT) === 0) {
z.istate.mode = BLOCKS;
break;
}
z.istate.mode = DICT4;
case DICT4:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
z.istate.need = ((z.read_byte(z.next_in_index++) & 0xff) << 24) & 0xff000000;
z.istate.mode = DICT3;
case DICT3:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 16) & 0xff0000;
z.istate.mode = DICT2;
case DICT2:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
z.istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 8) & 0xff00;
z.istate.mode = DICT1;
case DICT1:
if (z.avail_in === 0)
return r;
r = f;
z.avail_in--;
z.total_in++;
z.istate.need += (z.read_byte(z.next_in_index++) & 0xff);
z.istate.mode = DICT0;
return Z_NEED_DICT;
case DICT0:
z.istate.mode = BAD;
z.msg = "need dictionary";
z.istate.marker = 0; // can try inflateSync
return Z_STREAM_ERROR;
case BLOCKS:
r = z.istate.blocks.proc(z, r);
if (r == Z_DATA_ERROR) {
z.istate.mode = BAD;
z.istate.marker = 0; // can try inflateSync
break;
}
if (r == Z_OK) {
r = f;
}
if (r != Z_STREAM_END) {
return r;
}
r = f;
z.istate.blocks.reset(z, z.istate.was);
z.istate.mode = DONE;
case DONE:
return Z_STREAM_END;
case BAD:
return Z_DATA_ERROR;
default:
return Z_STREAM_ERROR;
}
}
};
that.inflateSetDictionary = function(z, dictionary, dictLength) {
var index = 0;
var length = dictLength;
if (!z || !z.istate || z.istate.mode != DICT0)
return Z_STREAM_ERROR;
if (length >= (1 << z.istate.wbits)) {
length = (1 << z.istate.wbits) - 1;
index = dictLength - length;
}
z.istate.blocks.set_dictionary(dictionary, index, length);
z.istate.mode = BLOCKS;
return Z_OK;
};
that.inflateSync = function(z) {
var n; // number of bytes to look at
var p; // pointer to bytes
var m; // number of marker bytes found in a row
var r, w; // temporaries to save total_in and total_out
// set up
if (!z || !z.istate)
return Z_STREAM_ERROR;
if (z.istate.mode != BAD) {
z.istate.mode = BAD;
z.istate.marker = 0;
}
if ((n = z.avail_in) === 0)
return Z_BUF_ERROR;
p = z.next_in_index;
m = z.istate.marker;
// search
while (n !== 0 && m < 4) {
if (z.read_byte(p) == mark[m]) {
m++;
} else if (z.read_byte(p) !== 0) {
m = 0;
} else {
m = 4 - m;
}
p++;
n--;
}
// restore
z.total_in += p - z.next_in_index;
z.next_in_index = p;
z.avail_in = n;
z.istate.marker = m;
// return no joy or set up to restart on a new block
if (m != 4) {
return Z_DATA_ERROR;
}
r = z.total_in;
w = z.total_out;
inflateReset(z);
z.total_in = r;
z.total_out = w;
z.istate.mode = BLOCKS;
return Z_OK;
};
// Returns true if inflate is currently at the end of a block generated
// by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
// implementation to provide an additional safety check. PPP uses
// Z_SYNC_FLUSH
// but removes the length bytes of the resulting empty stored block. When
// decompressing, PPP checks that at the end of input packet, inflate is
// waiting for these length bytes.
that.inflateSyncPoint = function(z) {
if (!z || !z.istate || !z.istate.blocks)
return Z_STREAM_ERROR;
return z.istate.blocks.sync_point();
};
}
// ZStream
function ZStream() {
}
ZStream.prototype = {
inflateInit : function(bits) {
var that = this;
that.istate = new Inflate();
if (!bits)
bits = MAX_BITS;
return that.istate.inflateInit(that, bits);
},
inflate : function(f) {
var that = this;
if (!that.istate)
return Z_STREAM_ERROR;
return that.istate.inflate(that, f);
},
inflateEnd : function() {
var that = this;
if (!that.istate)
return Z_STREAM_ERROR;
var ret = that.istate.inflateEnd(that);
that.istate = null;
return ret;
},
inflateSync : function() {
var that = this;
if (!that.istate)
return Z_STREAM_ERROR;
return that.istate.inflateSync(that);
},
inflateSetDictionary : function(dictionary, dictLength) {
var that = this;
if (!that.istate)
return Z_STREAM_ERROR;
return that.istate.inflateSetDictionary(that, dictionary, dictLength);
},
read_byte : function(start) {
var that = this;
return that.next_in.subarray(start, start + 1)[0];
},
read_buf : function(start, size) {
var that = this;
return that.next_in.subarray(start, start + size);
}
};
// Inflater
function Inflater() {
var that = this;
var z = new ZStream();
var bufsize = 512;
var flush = Z_NO_FLUSH;
var buf = new Uint8Array(bufsize);
var nomoreinput = false;
z.inflateInit();
z.next_out = buf;
that.append = function(data, onprogress) {
var err, buffers = [], lastIndex = 0, bufferIndex = 0, bufferSize = 0, array;
if (data.length === 0)
return;
z.next_in_index = 0;
z.next_in = data;
z.avail_in = data.length;
do {
z.next_out_index = 0;
z.avail_out = bufsize;
if ((z.avail_in === 0) && (!nomoreinput)) { // if buffer is empty and more input is available, refill it
z.next_in_index = 0;
nomoreinput = true;
}
err = z.inflate(flush);
if (nomoreinput && (err == Z_BUF_ERROR))
return -1;
if (err != Z_OK && err != Z_STREAM_END)
throw "inflating: " + z.msg;
if ((nomoreinput || err == Z_STREAM_END) && (z.avail_in == data.length))
return -1;
if (z.next_out_index)
if (z.next_out_index == bufsize)
buffers.push(new Uint8Array(buf));
else
buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index)));
bufferSize += z.next_out_index;
if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) {
onprogress(z.next_in_index);
lastIndex = z.next_in_index;
}
} while (z.avail_in > 0 || z.avail_out === 0);
array = new Uint8Array(bufferSize);
buffers.forEach(function(chunk) {
array.set(chunk, bufferIndex);
bufferIndex += chunk.length;
});
return array;
};
that.flush = function() {
z.inflateEnd();
};
}
var inflater;
if (obj.zip)
obj.zip.Inflater = Inflater;
else {
inflater = new Inflater();
obj.addEventListener("message", function(event) {
var message = event.data;
if (message.append)
obj.postMessage({
onappend : true,
data : inflater.append(message.data, function(current) {
obj.postMessage({
progress : true,
current : current
});
})
});
if (message.flush) {
inflater.flush();
obj.postMessage({
onflush : true
});
}
}, false);
}
})(this);
\ No newline at end of file
/*! jQuery v2.1.0 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k="".trim,l={},m=a.document,n="2.1.0",o=function(a,b){return new o.fn.init(a,b)},p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};o.fn=o.prototype={jquery:n,constructor:o,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=o.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return o.each(this,a,b)},map:function(a){return this.pushStack(o.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},o.extend=o.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||o.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(o.isPlainObject(d)||(e=o.isArray(d)))?(e?(e=!1,f=c&&o.isArray(c)?c:[]):f=c&&o.isPlainObject(c)?c:{},g[b]=o.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},o.extend({expando:"jQuery"+(n+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===o.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return a-parseFloat(a)>=0},isPlainObject:function(a){if("object"!==o.type(a)||a.nodeType||o.isWindow(a))return!1;try{if(a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(b){return!1}return!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=o.trim(a),a&&(1===a.indexOf("use strict")?(b=m.createElement("script"),b.text=a,m.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":k.call(a)},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?o.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),o.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||o.guid++,f):void 0},now:Date.now,support:l}),o.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b=a.length,c=o.type(a);return"function"===c||o.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s="sizzle"+-new Date,t=a.document,u=0,v=0,w=eb(),x=eb(),y=eb(),z=function(a,b){return a===b&&(j=!0),0},A="undefined",B=1<<31,C={}.hasOwnProperty,D=[],E=D.pop,F=D.push,G=D.push,H=D.slice,I=D.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},J="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",K="[\\x20\\t\\r\\n\\f]",L="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",M=L.replace("w","w#"),N="\\["+K+"*("+L+")"+K+"*(?:([*^$|!~]?=)"+K+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+M+")|)|)"+K+"*\\]",O=":("+L+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+N.replace(3,8)+")*)|.*)\\)|)",P=new RegExp("^"+K+"+|((?:^|[^\\\\])(?:\\\\.)*)"+K+"+$","g"),Q=new RegExp("^"+K+"*,"+K+"*"),R=new RegExp("^"+K+"*([>+~]|"+K+")"+K+"*"),S=new RegExp("="+K+"*([^\\]'\"]*?)"+K+"*\\]","g"),T=new RegExp(O),U=new RegExp("^"+M+"$"),V={ID:new RegExp("^#("+L+")"),CLASS:new RegExp("^\\.("+L+")"),TAG:new RegExp("^("+L.replace("w","w*")+")"),ATTR:new RegExp("^"+N),PSEUDO:new RegExp("^"+O),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+K+"*(even|odd|(([+-]|)(\\d*)n|)"+K+"*(?:([+-]|)"+K+"*(\\d+)|))"+K+"*\\)|)","i"),bool:new RegExp("^(?:"+J+")$","i"),needsContext:new RegExp("^"+K+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+K+"*((?:-\\d)?\\d*)"+K+"*\\)|)(?=[^-]|$)","i")},W=/^(?:input|select|textarea|button)$/i,X=/^h\d$/i,Y=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,$=/[+~]/,_=/'|\\/g,ab=new RegExp("\\\\([\\da-f]{1,6}"+K+"?|("+K+")|.)","ig"),bb=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{G.apply(D=H.call(t.childNodes),t.childNodes),D[t.childNodes.length].nodeType}catch(cb){G={apply:D.length?function(a,b){F.apply(a,H.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function db(a,b,d,e){var f,g,h,i,j,m,p,q,u,v;if((b?b.ownerDocument||b:t)!==l&&k(b),b=b||l,d=d||[],!a||"string"!=typeof a)return d;if(1!==(i=b.nodeType)&&9!==i)return[];if(n&&!e){if(f=Z.exec(a))if(h=f[1]){if(9===i){if(g=b.getElementById(h),!g||!g.parentNode)return d;if(g.id===h)return d.push(g),d}else if(b.ownerDocument&&(g=b.ownerDocument.getElementById(h))&&r(b,g)&&g.id===h)return d.push(g),d}else{if(f[2])return G.apply(d,b.getElementsByTagName(a)),d;if((h=f[3])&&c.getElementsByClassName&&b.getElementsByClassName)return G.apply(d,b.getElementsByClassName(h)),d}if(c.qsa&&(!o||!o.test(a))){if(q=p=s,u=b,v=9===i&&a,1===i&&"object"!==b.nodeName.toLowerCase()){m=ob(a),(p=b.getAttribute("id"))?q=p.replace(_,"\\$&"):b.setAttribute("id",q),q="[id='"+q+"'] ",j=m.length;while(j--)m[j]=q+pb(m[j]);u=$.test(a)&&mb(b.parentNode)||b,v=m.join(",")}if(v)try{return G.apply(d,u.querySelectorAll(v)),d}catch(w){}finally{p||b.removeAttribute("id")}}}return xb(a.replace(P,"$1"),b,d,e)}function eb(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function fb(a){return a[s]=!0,a}function gb(a){var b=l.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function hb(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function ib(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||B)-(~a.sourceIndex||B);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function jb(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function kb(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function lb(a){return fb(function(b){return b=+b,fb(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function mb(a){return a&&typeof a.getElementsByTagName!==A&&a}c=db.support={},f=db.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},k=db.setDocument=function(a){var b,e=a?a.ownerDocument||a:t,g=e.defaultView;return e!==l&&9===e.nodeType&&e.documentElement?(l=e,m=e.documentElement,n=!f(e),g&&g!==g.top&&(g.addEventListener?g.addEventListener("unload",function(){k()},!1):g.attachEvent&&g.attachEvent("onunload",function(){k()})),c.attributes=gb(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=gb(function(a){return a.appendChild(e.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=Y.test(e.getElementsByClassName)&&gb(function(a){return a.innerHTML="<div class='a'></div><div class='a i'></div>",a.firstChild.className="i",2===a.getElementsByClassName("i").length}),c.getById=gb(function(a){return m.appendChild(a).id=s,!e.getElementsByName||!e.getElementsByName(s).length}),c.getById?(d.find.ID=function(a,b){if(typeof b.getElementById!==A&&n){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ab,bb);return function(a){var c=typeof a.getAttributeNode!==A&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return typeof b.getElementsByTagName!==A?b.getElementsByTagName(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return typeof b.getElementsByClassName!==A&&n?b.getElementsByClassName(a):void 0},p=[],o=[],(c.qsa=Y.test(e.querySelectorAll))&&(gb(function(a){a.innerHTML="<select t=''><option selected=''></option></select>",a.querySelectorAll("[t^='']").length&&o.push("[*^$]="+K+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||o.push("\\["+K+"*(?:value|"+J+")"),a.querySelectorAll(":checked").length||o.push(":checked")}),gb(function(a){var b=e.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&o.push("name"+K+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||o.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),o.push(",.*:")})),(c.matchesSelector=Y.test(q=m.webkitMatchesSelector||m.mozMatchesSelector||m.oMatchesSelector||m.msMatchesSelector))&&gb(function(a){c.disconnectedMatch=q.call(a,"div"),q.call(a,"[s!='']:x"),p.push("!=",O)}),o=o.length&&new RegExp(o.join("|")),p=p.length&&new RegExp(p.join("|")),b=Y.test(m.compareDocumentPosition),r=b||Y.test(m.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},z=b?function(a,b){if(a===b)return j=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===e||a.ownerDocument===t&&r(t,a)?-1:b===e||b.ownerDocument===t&&r(t,b)?1:i?I.call(i,a)-I.call(i,b):0:4&d?-1:1)}:function(a,b){if(a===b)return j=!0,0;var c,d=0,f=a.parentNode,g=b.parentNode,h=[a],k=[b];if(!f||!g)return a===e?-1:b===e?1:f?-1:g?1:i?I.call(i,a)-I.call(i,b):0;if(f===g)return ib(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)k.unshift(c);while(h[d]===k[d])d++;return d?ib(h[d],k[d]):h[d]===t?-1:k[d]===t?1:0},e):l},db.matches=function(a,b){return db(a,null,null,b)},db.matchesSelector=function(a,b){if((a.ownerDocument||a)!==l&&k(a),b=b.replace(S,"='$1']"),!(!c.matchesSelector||!n||p&&p.test(b)||o&&o.test(b)))try{var d=q.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return db(b,l,null,[a]).length>0},db.contains=function(a,b){return(a.ownerDocument||a)!==l&&k(a),r(a,b)},db.attr=function(a,b){(a.ownerDocument||a)!==l&&k(a);var e=d.attrHandle[b.toLowerCase()],f=e&&C.call(d.attrHandle,b.toLowerCase())?e(a,b,!n):void 0;return void 0!==f?f:c.attributes||!n?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},db.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},db.uniqueSort=function(a){var b,d=[],e=0,f=0;if(j=!c.detectDuplicates,i=!c.sortStable&&a.slice(0),a.sort(z),j){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return i=null,a},e=db.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=db.selectors={cacheLength:50,createPseudo:fb,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ab,bb),a[3]=(a[4]||a[5]||"").replace(ab,bb),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||db.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&db.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return V.CHILD.test(a[0])?null:(a[3]&&void 0!==a[4]?a[2]=a[4]:c&&T.test(c)&&(b=ob(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ab,bb).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=w[a+" "];return b||(b=new RegExp("(^|"+K+")"+a+"("+K+"|$)"))&&w(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==A&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=db.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),t=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&t){k=q[s]||(q[s]={}),j=k[a]||[],n=j[0]===u&&j[1],m=j[0]===u&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[u,n,m];break}}else if(t&&(j=(b[s]||(b[s]={}))[a])&&j[0]===u)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(t&&((l[s]||(l[s]={}))[a]=[u,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||db.error("unsupported pseudo: "+a);return e[s]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?fb(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=I.call(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:fb(function(a){var b=[],c=[],d=g(a.replace(P,"$1"));return d[s]?fb(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:fb(function(a){return function(b){return db(a,b).length>0}}),contains:fb(function(a){return function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:fb(function(a){return U.test(a||"")||db.error("unsupported lang: "+a),a=a.replace(ab,bb).toLowerCase(),function(b){var c;do if(c=n?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===m},focus:function(a){return a===l.activeElement&&(!l.hasFocus||l.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return X.test(a.nodeName)},input:function(a){return W.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:lb(function(){return[0]}),last:lb(function(a,b){return[b-1]}),eq:lb(function(a,b,c){return[0>c?c+b:c]}),even:lb(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:lb(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:lb(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:lb(function(a,b,c){for(var d=0>c?c+b:c;++d<b;)a.push(d);return a})}},d.pseudos.nth=d.pseudos.eq;for(b in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})d.pseudos[b]=jb(b);for(b in{submit:!0,reset:!0})d.pseudos[b]=kb(b);function nb(){}nb.prototype=d.filters=d.pseudos,d.setFilters=new nb;function ob(a,b){var c,e,f,g,h,i,j,k=x[a+" "];if(k)return b?0:k.slice(0);h=a,i=[],j=d.preFilter;while(h){(!c||(e=Q.exec(h)))&&(e&&(h=h.slice(e[0].length)||h),i.push(f=[])),c=!1,(e=R.exec(h))&&(c=e.shift(),f.push({value:c,type:e[0].replace(P," ")}),h=h.slice(c.length));for(g in d.filter)!(e=V[g].exec(h))||j[g]&&!(e=j[g](e))||(c=e.shift(),f.push({value:c,type:g,matches:e}),h=h.slice(c.length));if(!c)break}return b?h.length:h?db.error(a):x(a,i).slice(0)}function pb(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function qb(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=v++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[u,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[s]||(b[s]={}),(h=i[d])&&h[0]===u&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function rb(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function sb(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function tb(a,b,c,d,e,f){return d&&!d[s]&&(d=tb(d)),e&&!e[s]&&(e=tb(e,f)),fb(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||wb(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:sb(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=sb(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?I.call(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=sb(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):G.apply(g,r)})}function ub(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],i=g||d.relative[" "],j=g?1:0,k=qb(function(a){return a===b},i,!0),l=qb(function(a){return I.call(b,a)>-1},i,!0),m=[function(a,c,d){return!g&&(d||c!==h)||((b=c).nodeType?k(a,c,d):l(a,c,d))}];f>j;j++)if(c=d.relative[a[j].type])m=[qb(rb(m),c)];else{if(c=d.filter[a[j].type].apply(null,a[j].matches),c[s]){for(e=++j;f>e;e++)if(d.relative[a[e].type])break;return tb(j>1&&rb(m),j>1&&pb(a.slice(0,j-1).concat({value:" "===a[j-2].type?"*":""})).replace(P,"$1"),c,e>j&&ub(a.slice(j,e)),f>e&&ub(a=a.slice(e)),f>e&&pb(a))}m.push(c)}return rb(m)}function vb(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,i,j,k){var m,n,o,p=0,q="0",r=f&&[],s=[],t=h,v=f||e&&d.find.TAG("*",k),w=u+=null==t?1:Math.random()||.1,x=v.length;for(k&&(h=g!==l&&g);q!==x&&null!=(m=v[q]);q++){if(e&&m){n=0;while(o=a[n++])if(o(m,g,i)){j.push(m);break}k&&(u=w)}c&&((m=!o&&m)&&p--,f&&r.push(m))}if(p+=q,c&&q!==p){n=0;while(o=b[n++])o(r,s,g,i);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=E.call(j));s=sb(s)}G.apply(j,s),k&&!f&&s.length>0&&p+b.length>1&&db.uniqueSort(j)}return k&&(u=w,h=t),r};return c?fb(f):f}g=db.compile=function(a,b){var c,d=[],e=[],f=y[a+" "];if(!f){b||(b=ob(a)),c=b.length;while(c--)f=ub(b[c]),f[s]?d.push(f):e.push(f);f=y(a,vb(e,d))}return f};function wb(a,b,c){for(var d=0,e=b.length;e>d;d++)db(a,b[d],c);return c}function xb(a,b,e,f){var h,i,j,k,l,m=ob(a);if(!f&&1===m.length){if(i=m[0]=m[0].slice(0),i.length>2&&"ID"===(j=i[0]).type&&c.getById&&9===b.nodeType&&n&&d.relative[i[1].type]){if(b=(d.find.ID(j.matches[0].replace(ab,bb),b)||[])[0],!b)return e;a=a.slice(i.shift().value.length)}h=V.needsContext.test(a)?0:i.length;while(h--){if(j=i[h],d.relative[k=j.type])break;if((l=d.find[k])&&(f=l(j.matches[0].replace(ab,bb),$.test(i[0].type)&&mb(b.parentNode)||b))){if(i.splice(h,1),a=f.length&&pb(i),!a)return G.apply(e,f),e;break}}}return g(a,m)(f,b,!n,e,$.test(a)&&mb(b.parentNode)||b),e}return c.sortStable=s.split("").sort(z).join("")===s,c.detectDuplicates=!!j,k(),c.sortDetached=gb(function(a){return 1&a.compareDocumentPosition(l.createElement("div"))}),gb(function(a){return a.innerHTML="<a href='#'></a>","#"===a.firstChild.getAttribute("href")})||hb("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&gb(function(a){return a.innerHTML="<input/>",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||hb("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),gb(function(a){return null==a.getAttribute("disabled")})||hb(J,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),db}(a);o.find=t,o.expr=t.selectors,o.expr[":"]=o.expr.pseudos,o.unique=t.uniqueSort,o.text=t.getText,o.isXMLDoc=t.isXML,o.contains=t.contains;var u=o.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(o.isFunction(b))return o.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return o.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return o.filter(b,a,c);b=o.filter(b,a)}return o.grep(a,function(a){return g.call(b,a)>=0!==c})}o.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?o.find.matchesSelector(d,a)?[d]:[]:o.find.matches(a,o.grep(b,function(a){return 1===a.nodeType}))},o.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(o(a).filter(function(){for(b=0;c>b;b++)if(o.contains(e[b],this))return!0}));for(b=0;c>b;b++)o.find(a,e[b],d);return d=this.pushStack(c>1?o.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?o(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=o.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof o?b[0]:b,o.merge(this,o.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:m,!0)),v.test(c[1])&&o.isPlainObject(b))for(c in b)o.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=m.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=m,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):o.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(o):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),o.makeArray(a,this))};A.prototype=o.fn,y=o(m);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};o.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&o(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),o.fn.extend({has:function(a){var b=o(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(o.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?o(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&o.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?o.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(o(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(o.unique(o.merge(this.get(),o(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}o.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return o.dir(a,"parentNode")},parentsUntil:function(a,b,c){return o.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return o.dir(a,"nextSibling")},prevAll:function(a){return o.dir(a,"previousSibling")},nextUntil:function(a,b,c){return o.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return o.dir(a,"previousSibling",c)},siblings:function(a){return o.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return o.sibling(a.firstChild)},contents:function(a){return a.contentDocument||o.merge([],a.childNodes)}},function(a,b){o.fn[a]=function(c,d){var e=o.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=o.filter(d,e)),this.length>1&&(C[a]||o.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return o.each(a.match(E)||[],function(a,c){b[c]=!0}),b}o.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):o.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){o.each(b,function(b,c){var d=o.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&o.each(arguments,function(a,b){var c;while((c=o.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?o.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},o.extend({Deferred:function(a){var b=[["resolve","done",o.Callbacks("once memory"),"resolved"],["reject","fail",o.Callbacks("once memory"),"rejected"],["notify","progress",o.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return o.Deferred(function(c){o.each(b,function(b,f){var g=o.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&o.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?o.extend(a,d):d}},e={};return d.pipe=d.then,o.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&o.isFunction(a.promise)?e:0,g=1===f?a:o.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&o.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;o.fn.ready=function(a){return o.ready.promise().done(a),this},o.extend({isReady:!1,readyWait:1,holdReady:function(a){a?o.readyWait++:o.ready(!0)},ready:function(a){(a===!0?--o.readyWait:o.isReady)||(o.isReady=!0,a!==!0&&--o.readyWait>0||(H.resolveWith(m,[o]),o.fn.trigger&&o(m).trigger("ready").off("ready")))}});function I(){m.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),o.ready()}o.ready.promise=function(b){return H||(H=o.Deferred(),"complete"===m.readyState?setTimeout(o.ready):(m.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},o.ready.promise();var J=o.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===o.type(c)){e=!0;for(h in c)o.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,o.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(o(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};o.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=o.expando+Math.random()}K.uid=1,K.accepts=o.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,o.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(o.isEmptyObject(f))o.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,o.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{o.isArray(b)?d=b.concat(b.map(o.camelCase)):(e=o.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!o.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?o.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}o.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),o.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;
while(c--)d=g[c].name,0===d.indexOf("data-")&&(d=o.camelCase(d.slice(5)),P(f,d,e[d]));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=o.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),o.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||o.isArray(c)?d=L.access(a,b,o.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=o.queue(a,b),d=c.length,e=c.shift(),f=o._queueHooks(a,b),g=function(){o.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:o.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),o.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.length<c?o.queue(this[0],a):void 0===b?this:this.each(function(){var c=o.queue(this,a,b);o._queueHooks(this,a),"fx"===a&&"inprogress"!==c[0]&&o.dequeue(this,a)})},dequeue:function(a){return this.each(function(){o.dequeue(this,a)})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,b){var c,d=1,e=o.Deferred(),f=this,g=this.length,h=function(){--d||e.resolveWith(f,[f])};"string"!=typeof a&&(b=a,a=void 0),a=a||"fx";while(g--)c=L.get(f[g],a+"queueHooks"),c&&c.empty&&(d++,c.empty.add(h));return h(),e.promise(b)}});var Q=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,R=["Top","Right","Bottom","Left"],S=function(a,b){return a=b||a,"none"===o.css(a,"display")||!o.contains(a.ownerDocument,a)},T=/^(?:checkbox|radio)$/i;!function(){var a=m.createDocumentFragment(),b=a.appendChild(m.createElement("div"));b.innerHTML="<input type='radio' checked='checked' name='t'/>",l.checkClone=b.cloneNode(!0).cloneNode(!0).lastChild.checked,b.innerHTML="<textarea>x</textarea>",l.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";l.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return m.activeElement}catch(a){}}o.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=o.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof o!==U&&o.event.triggered!==b.type?o.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n&&(l=o.event.special[n]||{},n=(e?l.delegateType:l.bindType)||n,l=o.event.special[n]||{},k=o.extend({type:n,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&o.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[n])||(m=i[n]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(n,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),o.event.global[n]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],n=q=h[1],p=(h[2]||"").split(".").sort(),n){l=o.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=i[n]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||o.removeEvent(a,n,r.handle),delete i[n])}else for(n in i)o.event.remove(a,n+b[j],c,d,!0);o.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,l,n,p=[d||m],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||m,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+o.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[o.expando]?b:new o.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:o.makeArray(c,[b]),n=o.event.special[q]||{},e||!n.trigger||n.trigger.apply(d,c)!==!1)){if(!e&&!n.noBubble&&!o.isWindow(d)){for(i=n.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||m)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:n.bindType||q,l=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),l&&l.apply(g,c),l=k&&g[k],l&&l.apply&&o.acceptData(g)&&(b.result=l.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||n._default&&n._default.apply(p.pop(),c)!==!1||!o.acceptData(d)||k&&o.isFunction(d[q])&&!o.isWindow(d)&&(h=d[k],h&&(d[k]=null),o.event.triggered=q,d[q](),o.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=o.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=o.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=o.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((o.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?o(e,this).index(i)>=0:o.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h<b.length&&g.push({elem:this,handlers:b.slice(h)}),g},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return null==a.which&&(a.which=null!=b.charCode?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,b){var c,d,e,f=b.button;return null==a.pageX&&null!=b.clientX&&(c=a.target.ownerDocument||m,d=c.documentElement,e=c.body,a.pageX=b.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0),a.pageY=b.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)),a.which||void 0===f||(a.which=1&f?1:2&f?3:4&f?2:0),a}},fix:function(a){if(a[o.expando])return a;var b,c,d,e=a.type,f=a,g=this.fixHooks[e];g||(this.fixHooks[e]=g=W.test(e)?this.mouseHooks:V.test(e)?this.keyHooks:{}),d=g.props?this.props.concat(g.props):this.props,a=new o.Event(f),b=d.length;while(b--)c=d[b],a[c]=f[c];return a.target||(a.target=m),3===a.target.nodeType&&(a.target=a.target.parentNode),g.filter?g.filter(a,f):a},special:{load:{noBubble:!0},focus:{trigger:function(){return this!==_()&&this.focus?(this.focus(),!1):void 0},delegateType:"focusin"},blur:{trigger:function(){return this===_()&&this.blur?(this.blur(),!1):void 0},delegateType:"focusout"},click:{trigger:function(){return"checkbox"===this.type&&this.click&&o.nodeName(this,"input")?(this.click(),!1):void 0},_default:function(a){return o.nodeName(a.target,"a")}},beforeunload:{postDispatch:function(a){void 0!==a.result&&(a.originalEvent.returnValue=a.result)}}},simulate:function(a,b,c,d){var e=o.extend(new o.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?o.event.trigger(e,null,b):o.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},o.removeEvent=function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)},o.Event=function(a,b){return this instanceof o.Event?(a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||void 0===a.defaultPrevented&&a.getPreventDefault&&a.getPreventDefault()?Z:$):this.type=a,b&&o.extend(this,b),this.timeStamp=a&&a.timeStamp||o.now(),void(this[o.expando]=!0)):new o.Event(a,b)},o.Event.prototype={isDefaultPrevented:$,isPropagationStopped:$,isImmediatePropagationStopped:$,preventDefault:function(){var a=this.originalEvent;this.isDefaultPrevented=Z,a&&a.preventDefault&&a.preventDefault()},stopPropagation:function(){var a=this.originalEvent;this.isPropagationStopped=Z,a&&a.stopPropagation&&a.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Z,this.stopPropagation()}},o.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){o.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c,d=this,e=a.relatedTarget,f=a.handleObj;return(!e||e!==d&&!o.contains(d,e))&&(a.type=f.origType,c=f.handler.apply(this,arguments),a.type=b),c}}}),l.focusinBubbles||o.each({focus:"focusin",blur:"focusout"},function(a,b){var c=function(a){o.event.simulate(b,a.target,o.event.fix(a),!0)};o.event.special[b]={setup:function(){var d=this.ownerDocument||this,e=L.access(d,b);e||d.addEventListener(a,c,!0),L.access(d,b,(e||0)+1)},teardown:function(){var d=this.ownerDocument||this,e=L.access(d,b)-1;e?L.access(d,b,e):(d.removeEventListener(a,c,!0),L.remove(d,b))}}}),o.fn.extend({on:function(a,b,c,d,e){var f,g;if("object"==typeof a){"string"!=typeof b&&(c=c||b,b=void 0);for(g in a)this.on(g,b,c,a[g],e);return this}if(null==c&&null==d?(d=b,c=b=void 0):null==d&&("string"==typeof b?(d=c,c=void 0):(d=c,c=b,b=void 0)),d===!1)d=$;else if(!d)return this;return 1===e&&(f=d,d=function(a){return o().off(a),f.apply(this,arguments)},d.guid=f.guid||(f.guid=o.guid++)),this.each(function(){o.event.add(this,a,d,c,b)})},one:function(a,b,c,d){return this.on(a,b,c,d,1)},off:function(a,b,c){var d,e;if(a&&a.preventDefault&&a.handleObj)return d=a.handleObj,o(a.delegateTarget).off(d.namespace?d.origType+"."+d.namespace:d.origType,d.selector,d.handler),this;if("object"==typeof a){for(e in a)this.off(e,b,a[e]);return this}return(b===!1||"function"==typeof b)&&(c=b,b=void 0),c===!1&&(c=$),this.each(function(){o.event.remove(this,a,c,b)})},trigger:function(a,b){return this.each(function(){o.event.trigger(a,b,this)})},triggerHandler:function(a,b){var c=this[0];return c?o.event.trigger(a,b,c,!0):void 0}});var ab=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bb=/<([\w:]+)/,cb=/<|&#?\w+;/,db=/<(?:script|style|link)/i,eb=/checked\s*(?:[^=]|=\s*.checked.)/i,fb=/^$|\/(?:java|ecma)script/i,gb=/^true\/(.*)/,hb=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,ib={option:[1,"<select multiple='multiple'>","</select>"],thead:[1,"<table>","</table>"],col:[2,"<table><colgroup>","</colgroup></table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:[0,"",""]};ib.optgroup=ib.option,ib.tbody=ib.tfoot=ib.colgroup=ib.caption=ib.thead,ib.th=ib.td;function jb(a,b){return o.nodeName(a,"table")&&o.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function kb(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function lb(a){var b=gb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function mb(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function nb(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)o.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=o.extend({},h),M.set(b,i))}}function ob(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&o.nodeName(a,b)?o.merge([a],c):c}function pb(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}o.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=o.contains(a.ownerDocument,a);if(!(l.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||o.isXMLDoc(a)))for(g=ob(h),f=ob(a),d=0,e=f.length;e>d;d++)pb(f[d],g[d]);if(b)if(c)for(f=f||ob(a),g=g||ob(h),d=0,e=f.length;e>d;d++)nb(f[d],g[d]);else nb(a,h);return g=ob(h,"script"),g.length>0&&mb(g,!i&&ob(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,n=a.length;n>m;m++)if(e=a[m],e||0===e)if("object"===o.type(e))o.merge(l,e.nodeType?[e]:e);else if(cb.test(e)){f=f||k.appendChild(b.createElement("div")),g=(bb.exec(e)||["",""])[1].toLowerCase(),h=ib[g]||ib._default,f.innerHTML=h[1]+e.replace(ab,"<$1></$2>")+h[2],j=h[0];while(j--)f=f.lastChild;o.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===o.inArray(e,d))&&(i=o.contains(e.ownerDocument,e),f=ob(k.appendChild(e),"script"),i&&mb(f),c)){j=0;while(e=f[j++])fb.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f,g,h=o.event.special,i=0;void 0!==(c=a[i]);i++){if(o.acceptData(c)&&(f=c[L.expando],f&&(b=L.cache[f]))){if(d=Object.keys(b.events||{}),d.length)for(g=0;void 0!==(e=d[g]);g++)h[e]?o.event.remove(c,e):o.removeEvent(c,e,b.handle);L.cache[f]&&delete L.cache[f]}delete M.cache[c[M.expando]]}}}),o.fn.extend({text:function(a){return J(this,function(a){return void 0===a?o.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=jb(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?o.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||o.cleanData(ob(c)),c.parentNode&&(b&&o.contains(c.ownerDocument,c)&&mb(ob(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(o.cleanData(ob(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return o.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!db.test(a)&&!ib[(bb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ab,"<$1></$2>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(o.cleanData(ob(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,o.cleanData(ob(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,k=this.length,m=this,n=k-1,p=a[0],q=o.isFunction(p);if(q||k>1&&"string"==typeof p&&!l.checkClone&&eb.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(k&&(c=o.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=o.map(ob(c,"script"),kb),g=f.length;k>j;j++)h=c,j!==n&&(h=o.clone(h,!0,!0),g&&o.merge(f,ob(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,o.map(f,lb),j=0;g>j;j++)h=f[j],fb.test(h.type||"")&&!L.access(h,"globalEval")&&o.contains(i,h)&&(h.src?o._evalUrl&&o._evalUrl(h.src):o.globalEval(h.textContent.replace(hb,"")))}return this}}),o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){o.fn[a]=function(a){for(var c,d=[],e=o(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),o(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qb,rb={};function sb(b,c){var d=o(c.createElement(b)).appendTo(c.body),e=a.getDefaultComputedStyle?a.getDefaultComputedStyle(d[0]).display:o.css(d[0],"display");return d.detach(),e}function tb(a){var b=m,c=rb[a];return c||(c=sb(a,b),"none"!==c&&c||(qb=(qb||o("<iframe frameborder='0' width='0' height='0'/>")).appendTo(b.documentElement),b=qb[0].contentDocument,b.write(),b.close(),c=sb(a,b),qb.detach()),rb[a]=c),c}var ub=/^margin/,vb=new RegExp("^("+Q+")(?!px)[a-z%]+$","i"),wb=function(a){return a.ownerDocument.defaultView.getComputedStyle(a,null)};function xb(a,b,c){var d,e,f,g,h=a.style;return c=c||wb(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||o.contains(a.ownerDocument,a)||(g=o.style(a,b)),vb.test(g)&&ub.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function yb(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}!function(){var b,c,d="padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box",e=m.documentElement,f=m.createElement("div"),g=m.createElement("div");g.style.backgroundClip="content-box",g.cloneNode(!0).style.backgroundClip="",l.clearCloneStyle="content-box"===g.style.backgroundClip,f.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",f.appendChild(g);function h(){g.style.cssText="-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%",e.appendChild(f);var d=a.getComputedStyle(g,null);b="1%"!==d.top,c="4px"===d.width,e.removeChild(f)}a.getComputedStyle&&o.extend(l,{pixelPosition:function(){return h(),b},boxSizingReliable:function(){return null==c&&h(),c},reliableMarginRight:function(){var b,c=g.appendChild(m.createElement("div"));return c.style.cssText=g.style.cssText=d,c.style.marginRight=c.style.width="0",g.style.width="1px",e.appendChild(f),b=!parseFloat(a.getComputedStyle(c,null).marginRight),e.removeChild(f),g.innerHTML="",b}})}(),o.swap=function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e};var zb=/^(none|table(?!-c[ea]).+)/,Ab=new RegExp("^("+Q+")(.*)$","i"),Bb=new RegExp("^([+-])=("+Q+")","i"),Cb={position:"absolute",visibility:"hidden",display:"block"},Db={letterSpacing:0,fontWeight:400},Eb=["Webkit","O","Moz","ms"];function Fb(a,b){if(b in a)return b;var c=b[0].toUpperCase()+b.slice(1),d=b,e=Eb.length;while(e--)if(b=Eb[e]+c,b in a)return b;return d}function Gb(a,b,c){var d=Ab.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function Hb(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=o.css(a,c+R[f],!0,e)),d?("content"===c&&(g-=o.css(a,"padding"+R[f],!0,e)),"margin"!==c&&(g-=o.css(a,"border"+R[f]+"Width",!0,e))):(g+=o.css(a,"padding"+R[f],!0,e),"padding"!==c&&(g+=o.css(a,"border"+R[f]+"Width",!0,e)));return g}function Ib(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=wb(a),g="border-box"===o.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=xb(a,b,f),(0>e||null==e)&&(e=a.style[b]),vb.test(e))return e;d=g&&(l.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+Hb(a,b,c||(g?"border":"content"),d,f)+"px"}function Jb(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=L.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&S(d)&&(f[g]=L.access(d,"olddisplay",tb(d.nodeName)))):f[g]||(e=S(d),(c&&"none"!==c||!e)&&L.set(d,"olddisplay",e?c:o.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}o.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=xb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":"cssFloat"},style:function(a,b,c,d){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var e,f,g,h=o.camelCase(b),i=a.style;return b=o.cssProps[h]||(o.cssProps[h]=Fb(i,h)),g=o.cssHooks[b]||o.cssHooks[h],void 0===c?g&&"get"in g&&void 0!==(e=g.get(a,!1,d))?e:i[b]:(f=typeof c,"string"===f&&(e=Bb.exec(c))&&(c=(e[1]+1)*e[2]+parseFloat(o.css(a,b)),f="number"),null!=c&&c===c&&("number"!==f||o.cssNumber[h]||(c+="px"),l.clearCloneStyle||""!==c||0!==b.indexOf("background")||(i[b]="inherit"),g&&"set"in g&&void 0===(c=g.set(a,c,d))||(i[b]="",i[b]=c)),void 0)}},css:function(a,b,c,d){var e,f,g,h=o.camelCase(b);return b=o.cssProps[h]||(o.cssProps[h]=Fb(a.style,h)),g=o.cssHooks[b]||o.cssHooks[h],g&&"get"in g&&(e=g.get(a,!0,c)),void 0===e&&(e=xb(a,b,d)),"normal"===e&&b in Db&&(e=Db[b]),""===c||c?(f=parseFloat(e),c===!0||o.isNumeric(f)?f||0:e):e}}),o.each(["height","width"],function(a,b){o.cssHooks[b]={get:function(a,c,d){return c?0===a.offsetWidth&&zb.test(o.css(a,"display"))?o.swap(a,Cb,function(){return Ib(a,b,d)}):Ib(a,b,d):void 0},set:function(a,c,d){var e=d&&wb(a);return Gb(a,c,d?Hb(a,b,d,"border-box"===o.css(a,"boxSizing",!1,e),e):0)}}}),o.cssHooks.marginRight=yb(l.reliableMarginRight,function(a,b){return b?o.swap(a,{display:"inline-block"},xb,[a,"marginRight"]):void 0}),o.each({margin:"",padding:"",border:"Width"},function(a,b){o.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];4>d;d++)e[a+R[d]+b]=f[d]||f[d-2]||f[0];return e}},ub.test(a)||(o.cssHooks[a+b].set=Gb)}),o.fn.extend({css:function(a,b){return J(this,function(a,b,c){var d,e,f={},g=0;if(o.isArray(b)){for(d=wb(a),e=b.length;e>g;g++)f[b[g]]=o.css(a,b[g],!1,d);return f}return void 0!==c?o.style(a,b,c):o.css(a,b)},a,b,arguments.length>1)},show:function(){return Jb(this,!0)},hide:function(){return Jb(this)},toggle:function(a){return"boolean"==typeof a?a?this.show():this.hide():this.each(function(){S(this)?o(this).show():o(this).hide()})}});function Kb(a,b,c,d,e){return new Kb.prototype.init(a,b,c,d,e)}o.Tween=Kb,Kb.prototype={constructor:Kb,init:function(a,b,c,d,e,f){this.elem=a,this.prop=c,this.easing=e||"swing",this.options=b,this.start=this.now=this.cur(),this.end=d,this.unit=f||(o.cssNumber[c]?"":"px")},cur:function(){var a=Kb.propHooks[this.prop];return a&&a.get?a.get(this):Kb.propHooks._default.get(this)},run:function(a){var b,c=Kb.propHooks[this.prop];return this.pos=b=this.options.duration?o.easing[this.easing](a,this.options.duration*a,0,1,this.options.duration):a,this.now=(this.end-this.start)*b+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),c&&c.set?c.set(this):Kb.propHooks._default.set(this),this}},Kb.prototype.init.prototype=Kb.prototype,Kb.propHooks={_default:{get:function(a){var b;return null==a.elem[a.prop]||a.elem.style&&null!=a.elem.style[a.prop]?(b=o.css(a.elem,a.prop,""),b&&"auto"!==b?b:0):a.elem[a.prop]},set:function(a){o.fx.step[a.prop]?o.fx.step[a.prop](a):a.elem.style&&(null!=a.elem.style[o.cssProps[a.prop]]||o.cssHooks[a.prop])?o.style(a.elem,a.prop,a.now+a.unit):a.elem[a.prop]=a.now}}},Kb.propHooks.scrollTop=Kb.propHooks.scrollLeft={set:function(a){a.elem.nodeType&&a.elem.parentNode&&(a.elem[a.prop]=a.now)}},o.easing={linear:function(a){return a},swing:function(a){return.5-Math.cos(a*Math.PI)/2}},o.fx=Kb.prototype.init,o.fx.step={};var Lb,Mb,Nb=/^(?:toggle|show|hide)$/,Ob=new RegExp("^(?:([+-])=|)("+Q+")([a-z%]*)$","i"),Pb=/queueHooks$/,Qb=[Vb],Rb={"*":[function(a,b){var c=this.createTween(a,b),d=c.cur(),e=Ob.exec(b),f=e&&e[3]||(o.cssNumber[a]?"":"px"),g=(o.cssNumber[a]||"px"!==f&&+d)&&Ob.exec(o.css(c.elem,a)),h=1,i=20;if(g&&g[3]!==f){f=f||g[3],e=e||[],g=+d||1;do h=h||".5",g/=h,o.style(c.elem,a,g+f);while(h!==(h=c.cur()/d)&&1!==h&&--i)}return e&&(g=c.start=+g||+d||0,c.unit=f,c.end=e[1]?g+(e[1]+1)*e[2]:+e[2]),c}]};function Sb(){return setTimeout(function(){Lb=void 0}),Lb=o.now()}function Tb(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=R[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function Ub(a,b,c){for(var d,e=(Rb[b]||[]).concat(Rb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function Vb(a,b,c){var d,e,f,g,h,i,j,k=this,l={},m=a.style,n=a.nodeType&&S(a),p=L.get(a,"fxshow");c.queue||(h=o._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,k.always(function(){k.always(function(){h.unqueued--,o.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[m.overflow,m.overflowX,m.overflowY],j=o.css(a,"display"),"none"===j&&(j=tb(a.nodeName)),"inline"===j&&"none"===o.css(a,"float")&&(m.display="inline-block")),c.overflow&&(m.overflow="hidden",k.always(function(){m.overflow=c.overflow[0],m.overflowX=c.overflow[1],m.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],Nb.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(n?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;n=!0}l[d]=p&&p[d]||o.style(a,d)}if(!o.isEmptyObject(l)){p?"hidden"in p&&(n=p.hidden):p=L.access(a,"fxshow",{}),f&&(p.hidden=!n),n?o(a).show():k.done(function(){o(a).hide()}),k.done(function(){var b;L.remove(a,"fxshow");for(b in l)o.style(a,b,l[b])});for(d in l)g=Ub(n?p[d]:0,d,k),d in p||(p[d]=g.start,n&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function Wb(a,b){var c,d,e,f,g;for(c in a)if(d=o.camelCase(c),e=b[d],f=a[c],o.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=o.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function Xb(a,b,c){var d,e,f=0,g=Qb.length,h=o.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Lb||Sb(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:o.extend({},b),opts:o.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Lb||Sb(),duration:c.duration,tweens:[],createTween:function(b,c){var d=o.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(Wb(k,j.opts.specialEasing);g>f;f++)if(d=Qb[f].call(j,a,k,j.opts))return d;return o.map(k,Ub,j),o.isFunction(j.opts.start)&&j.opts.start.call(a,j),o.fx.timer(o.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}o.Animation=o.extend(Xb,{tweener:function(a,b){o.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;e>d;d++)c=a[d],Rb[c]=Rb[c]||[],Rb[c].unshift(b)},prefilter:function(a,b){b?Qb.unshift(a):Qb.push(a)}}),o.speed=function(a,b,c){var d=a&&"object"==typeof a?o.extend({},a):{complete:c||!c&&b||o.isFunction(a)&&a,duration:a,easing:c&&b||b&&!o.isFunction(b)&&b};return d.duration=o.fx.off?0:"number"==typeof d.duration?d.duration:d.duration in o.fx.speeds?o.fx.speeds[d.duration]:o.fx.speeds._default,(null==d.queue||d.queue===!0)&&(d.queue="fx"),d.old=d.complete,d.complete=function(){o.isFunction(d.old)&&d.old.call(this),d.queue&&o.dequeue(this,d.queue)},d},o.fn.extend({fadeTo:function(a,b,c,d){return this.filter(S).css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,d){var e=o.isEmptyObject(a),f=o.speed(b,c,d),g=function(){var b=Xb(this,o.extend({},a),f);(e||L.get(this,"finish"))&&b.stop(!0)};return g.finish=g,e||f.queue===!1?this.each(g):this.queue(f.queue,g)},stop:function(a,b,c){var d=function(a){var b=a.stop;delete a.stop,b(c)};return"string"!=typeof a&&(c=b,b=a,a=void 0),b&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){var b=!0,e=null!=a&&a+"queueHooks",f=o.timers,g=L.get(this);if(e)g[e]&&g[e].stop&&d(g[e]);else for(e in g)g[e]&&g[e].stop&&Pb.test(e)&&d(g[e]);for(e=f.length;e--;)f[e].elem!==this||null!=a&&f[e].queue!==a||(f[e].anim.stop(c),b=!1,f.splice(e,1));(b||!c)&&o.dequeue(this,a)})},finish:function(a){return a!==!1&&(a=a||"fx"),this.each(function(){var b,c=L.get(this),d=c[a+"queue"],e=c[a+"queueHooks"],f=o.timers,g=d?d.length:0;for(c.finish=!0,o.queue(this,a,[]),e&&e.stop&&e.stop.call(this,!0),b=f.length;b--;)f[b].elem===this&&f[b].queue===a&&(f[b].anim.stop(!0),f.splice(b,1));for(b=0;g>b;b++)d[b]&&d[b].finish&&d[b].finish.call(this);delete c.finish})}}),o.each(["toggle","show","hide"],function(a,b){var c=o.fn[b];o.fn[b]=function(a,d,e){return null==a||"boolean"==typeof a?c.apply(this,arguments):this.animate(Tb(b,!0),a,d,e)}}),o.each({slideDown:Tb("show"),slideUp:Tb("hide"),slideToggle:Tb("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){o.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),o.timers=[],o.fx.tick=function(){var a,b=0,c=o.timers;for(Lb=o.now();b<c.length;b++)a=c[b],a()||c[b]!==a||c.splice(b--,1);c.length||o.fx.stop(),Lb=void 0},o.fx.timer=function(a){o.timers.push(a),a()?o.fx.start():o.timers.pop()},o.fx.interval=13,o.fx.start=function(){Mb||(Mb=setInterval(o.fx.tick,o.fx.interval))},o.fx.stop=function(){clearInterval(Mb),Mb=null},o.fx.speeds={slow:600,fast:200,_default:400},o.fn.delay=function(a,b){return a=o.fx?o.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},function(){var a=m.createElement("input"),b=m.createElement("select"),c=b.appendChild(m.createElement("option"));a.type="checkbox",l.checkOn=""!==a.value,l.optSelected=c.selected,b.disabled=!0,l.optDisabled=!c.disabled,a=m.createElement("input"),a.value="t",a.type="radio",l.radioValue="t"===a.value}();var Yb,Zb,$b=o.expr.attrHandle;o.fn.extend({attr:function(a,b){return J(this,o.attr,a,b,arguments.length>1)},removeAttr:function(a){return this.each(function(){o.removeAttr(this,a)})}}),o.extend({attr:function(a,b,c){var d,e,f=a.nodeType;if(a&&3!==f&&8!==f&&2!==f)return typeof a.getAttribute===U?o.prop(a,b,c):(1===f&&o.isXMLDoc(a)||(b=b.toLowerCase(),d=o.attrHooks[b]||(o.expr.match.bool.test(b)?Zb:Yb)),void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=o.find.attr(a,b),null==e?void 0:e):null!==c?d&&"set"in d&&void 0!==(e=d.set(a,c,b))?e:(a.setAttribute(b,c+""),c):void o.removeAttr(a,b))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(E);if(f&&1===a.nodeType)while(c=f[e++])d=o.propFix[c]||c,o.expr.match.bool.test(c)&&(a[d]=!1),a.removeAttribute(c)},attrHooks:{type:{set:function(a,b){if(!l.radioValue&&"radio"===b&&o.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}}}),Zb={set:function(a,b,c){return b===!1?o.removeAttr(a,c):a.setAttribute(c,c),c}},o.each(o.expr.match.bool.source.match(/\w+/g),function(a,b){var c=$b[b]||o.find.attr;$b[b]=function(a,b,d){var e,f;
return d||(f=$b[b],$b[b]=e,e=null!=c(a,b,d)?b.toLowerCase():null,$b[b]=f),e}});var _b=/^(?:input|select|textarea|button)$/i;o.fn.extend({prop:function(a,b){return J(this,o.prop,a,b,arguments.length>1)},removeProp:function(a){return this.each(function(){delete this[o.propFix[a]||a]})}}),o.extend({propFix:{"for":"htmlFor","class":"className"},prop:function(a,b,c){var d,e,f,g=a.nodeType;if(a&&3!==g&&8!==g&&2!==g)return f=1!==g||!o.isXMLDoc(a),f&&(b=o.propFix[b]||b,e=o.propHooks[b]),void 0!==c?e&&"set"in e&&void 0!==(d=e.set(a,c,b))?d:a[b]=c:e&&"get"in e&&null!==(d=e.get(a,b))?d:a[b]},propHooks:{tabIndex:{get:function(a){return a.hasAttribute("tabindex")||_b.test(a.nodeName)||a.href?a.tabIndex:-1}}}}),l.optSelected||(o.propHooks.selected={get:function(a){var b=a.parentNode;return b&&b.parentNode&&b.parentNode.selectedIndex,null}}),o.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){o.propFix[this.toLowerCase()]=this});var ac=/[\t\r\n\f]/g;o.fn.extend({addClass:function(a){var b,c,d,e,f,g,h="string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).addClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):" ")){f=0;while(e=b[f++])d.indexOf(" "+e+" ")<0&&(d+=e+" ");g=o.trim(d),c.className!==g&&(c.className=g)}return this},removeClass:function(a){var b,c,d,e,f,g,h=0===arguments.length||"string"==typeof a&&a,i=0,j=this.length;if(o.isFunction(a))return this.each(function(b){o(this).removeClass(a.call(this,b,this.className))});if(h)for(b=(a||"").match(E)||[];j>i;i++)if(c=this[i],d=1===c.nodeType&&(c.className?(" "+c.className+" ").replace(ac," "):"")){f=0;while(e=b[f++])while(d.indexOf(" "+e+" ")>=0)d=d.replace(" "+e+" "," ");g=a?o.trim(d):"",c.className!==g&&(c.className=g)}return this},toggleClass:function(a,b){var c=typeof a;return"boolean"==typeof b&&"string"===c?b?this.addClass(a):this.removeClass(a):this.each(o.isFunction(a)?function(c){o(this).toggleClass(a.call(this,c,this.className,b),b)}:function(){if("string"===c){var b,d=0,e=o(this),f=a.match(E)||[];while(b=f[d++])e.hasClass(b)?e.removeClass(b):e.addClass(b)}else(c===U||"boolean"===c)&&(this.className&&L.set(this,"__className__",this.className),this.className=this.className||a===!1?"":L.get(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;d>c;c++)if(1===this[c].nodeType&&(" "+this[c].className+" ").replace(ac," ").indexOf(b)>=0)return!0;return!1}});var bc=/\r/g;o.fn.extend({val:function(a){var b,c,d,e=this[0];{if(arguments.length)return d=o.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,o(this).val()):a,null==e?e="":"number"==typeof e?e+="":o.isArray(e)&&(e=o.map(e,function(a){return null==a?"":a+""})),b=o.valHooks[this.type]||o.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=o.valHooks[e.type]||o.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(bc,""):null==c?"":c)}}}),o.extend({valHooks:{select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||0>e,g=f?null:[],h=f?e+1:d.length,i=0>e?h:f?e:0;h>i;i++)if(c=d[i],!(!c.selected&&i!==e||(l.optDisabled?c.disabled:null!==c.getAttribute("disabled"))||c.parentNode.disabled&&o.nodeName(c.parentNode,"optgroup"))){if(b=o(c).val(),f)return b;g.push(b)}return g},set:function(a,b){var c,d,e=a.options,f=o.makeArray(b),g=e.length;while(g--)d=e[g],(d.selected=o.inArray(o(d).val(),f)>=0)&&(c=!0);return c||(a.selectedIndex=-1),f}}}}),o.each(["radio","checkbox"],function(){o.valHooks[this]={set:function(a,b){return o.isArray(b)?a.checked=o.inArray(o(a).val(),b)>=0:void 0}},l.checkOn||(o.valHooks[this].get=function(a){return null===a.getAttribute("value")?"on":a.value})}),o.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){o.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),o.fn.extend({hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return 1===arguments.length?this.off(a,"**"):this.off(b,a||"**",c)}});var cc=o.now(),dc=/\?/;o.parseJSON=function(a){return JSON.parse(a+"")},o.parseXML=function(a){var b,c;if(!a||"string"!=typeof a)return null;try{c=new DOMParser,b=c.parseFromString(a,"text/xml")}catch(d){b=void 0}return(!b||b.getElementsByTagName("parsererror").length)&&o.error("Invalid XML: "+a),b};var ec,fc,gc=/#.*$/,hc=/([?&])_=[^&]*/,ic=/^(.*?):[ \t]*([^\r\n]*)$/gm,jc=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,kc=/^(?:GET|HEAD)$/,lc=/^\/\//,mc=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,nc={},oc={},pc="*/".concat("*");try{fc=location.href}catch(qc){fc=m.createElement("a"),fc.href="",fc=fc.href}ec=mc.exec(fc.toLowerCase())||[];function rc(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(E)||[];if(o.isFunction(c))while(d=f[e++])"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function sc(a,b,c,d){var e={},f=a===oc;function g(h){var i;return e[h]=!0,o.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||f||e[j]?f?!(i=j):void 0:(b.dataTypes.unshift(j),g(j),!1)}),i}return g(b.dataTypes[0])||!e["*"]&&g("*")}function tc(a,b){var c,d,e=o.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&o.extend(!0,a,d),a}function uc(a,b,c){var d,e,f,g,h=a.contents,i=a.dataTypes;while("*"===i[0])i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function vc(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];f=k.shift();while(f)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}o.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:fc,type:"GET",isLocal:jc.test(ec[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":pc,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":o.parseJSON,"text xml":o.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?tc(tc(a,o.ajaxSettings),b):tc(o.ajaxSettings,a)},ajaxPrefilter:rc(nc),ajaxTransport:rc(oc),ajax:function(a,b){"object"==typeof a&&(b=a,a=void 0),b=b||{};var c,d,e,f,g,h,i,j,k=o.ajaxSetup({},b),l=k.context||k,m=k.context&&(l.nodeType||l.jquery)?o(l):o.event,n=o.Deferred(),p=o.Callbacks("once memory"),q=k.statusCode||{},r={},s={},t=0,u="canceled",v={readyState:0,getResponseHeader:function(a){var b;if(2===t){if(!f){f={};while(b=ic.exec(e))f[b[1].toLowerCase()]=b[2]}b=f[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===t?e:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return t||(a=s[c]=s[c]||a,r[a]=b),this},overrideMimeType:function(a){return t||(k.mimeType=a),this},statusCode:function(a){var b;if(a)if(2>t)for(b in a)q[b]=[q[b],a[b]];else v.always(a[v.status]);return this},abort:function(a){var b=a||u;return c&&c.abort(b),x(0,b),this}};if(n.promise(v).complete=p.add,v.success=v.done,v.error=v.fail,k.url=((a||k.url||fc)+"").replace(gc,"").replace(lc,ec[1]+"//"),k.type=b.method||b.type||k.method||k.type,k.dataTypes=o.trim(k.dataType||"*").toLowerCase().match(E)||[""],null==k.crossDomain&&(h=mc.exec(k.url.toLowerCase()),k.crossDomain=!(!h||h[1]===ec[1]&&h[2]===ec[2]&&(h[3]||("http:"===h[1]?"80":"443"))===(ec[3]||("http:"===ec[1]?"80":"443")))),k.data&&k.processData&&"string"!=typeof k.data&&(k.data=o.param(k.data,k.traditional)),sc(nc,k,b,v),2===t)return v;i=k.global,i&&0===o.active++&&o.event.trigger("ajaxStart"),k.type=k.type.toUpperCase(),k.hasContent=!kc.test(k.type),d=k.url,k.hasContent||(k.data&&(d=k.url+=(dc.test(d)?"&":"?")+k.data,delete k.data),k.cache===!1&&(k.url=hc.test(d)?d.replace(hc,"$1_="+cc++):d+(dc.test(d)?"&":"?")+"_="+cc++)),k.ifModified&&(o.lastModified[d]&&v.setRequestHeader("If-Modified-Since",o.lastModified[d]),o.etag[d]&&v.setRequestHeader("If-None-Match",o.etag[d])),(k.data&&k.hasContent&&k.contentType!==!1||b.contentType)&&v.setRequestHeader("Content-Type",k.contentType),v.setRequestHeader("Accept",k.dataTypes[0]&&k.accepts[k.dataTypes[0]]?k.accepts[k.dataTypes[0]]+("*"!==k.dataTypes[0]?", "+pc+"; q=0.01":""):k.accepts["*"]);for(j in k.headers)v.setRequestHeader(j,k.headers[j]);if(k.beforeSend&&(k.beforeSend.call(l,v,k)===!1||2===t))return v.abort();u="abort";for(j in{success:1,error:1,complete:1})v[j](k[j]);if(c=sc(oc,k,b,v)){v.readyState=1,i&&m.trigger("ajaxSend",[v,k]),k.async&&k.timeout>0&&(g=setTimeout(function(){v.abort("timeout")},k.timeout));try{t=1,c.send(r,x)}catch(w){if(!(2>t))throw w;x(-1,w)}}else x(-1,"No Transport");function x(a,b,f,h){var j,r,s,u,w,x=b;2!==t&&(t=2,g&&clearTimeout(g),c=void 0,e=h||"",v.readyState=a>0?4:0,j=a>=200&&300>a||304===a,f&&(u=uc(k,v,f)),u=vc(k,u,v,j),j?(k.ifModified&&(w=v.getResponseHeader("Last-Modified"),w&&(o.lastModified[d]=w),w=v.getResponseHeader("etag"),w&&(o.etag[d]=w)),204===a||"HEAD"===k.type?x="nocontent":304===a?x="notmodified":(x=u.state,r=u.data,s=u.error,j=!s)):(s=x,(a||!x)&&(x="error",0>a&&(a=0))),v.status=a,v.statusText=(b||x)+"",j?n.resolveWith(l,[r,x,v]):n.rejectWith(l,[v,x,s]),v.statusCode(q),q=void 0,i&&m.trigger(j?"ajaxSuccess":"ajaxError",[v,k,j?r:s]),p.fireWith(l,[v,x]),i&&(m.trigger("ajaxComplete",[v,k]),--o.active||o.event.trigger("ajaxStop")))}return v},getJSON:function(a,b,c){return o.get(a,b,c,"json")},getScript:function(a,b){return o.get(a,void 0,b,"script")}}),o.each(["get","post"],function(a,b){o[b]=function(a,c,d,e){return o.isFunction(c)&&(e=e||d,d=c,c=void 0),o.ajax({url:a,type:b,dataType:e,data:c,success:d})}}),o.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){o.fn[b]=function(a){return this.on(b,a)}}),o._evalUrl=function(a){return o.ajax({url:a,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})},o.fn.extend({wrapAll:function(a){var b;return o.isFunction(a)?this.each(function(b){o(this).wrapAll(a.call(this,b))}):(this[0]&&(b=o(a,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstElementChild)a=a.firstElementChild;return a}).append(this)),this)},wrapInner:function(a){return this.each(o.isFunction(a)?function(b){o(this).wrapInner(a.call(this,b))}:function(){var b=o(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=o.isFunction(a);return this.each(function(c){o(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){o.nodeName(this,"body")||o(this).replaceWith(this.childNodes)}).end()}}),o.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0},o.expr.filters.visible=function(a){return!o.expr.filters.hidden(a)};var wc=/%20/g,xc=/\[\]$/,yc=/\r?\n/g,zc=/^(?:submit|button|image|reset|file)$/i,Ac=/^(?:input|select|textarea|keygen)/i;function Bc(a,b,c,d){var e;if(o.isArray(b))o.each(b,function(b,e){c||xc.test(a)?d(a,e):Bc(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==o.type(b))d(a,b);else for(e in b)Bc(a+"["+e+"]",b[e],c,d)}o.param=function(a,b){var c,d=[],e=function(a,b){b=o.isFunction(b)?b():null==b?"":b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(void 0===b&&(b=o.ajaxSettings&&o.ajaxSettings.traditional),o.isArray(a)||a.jquery&&!o.isPlainObject(a))o.each(a,function(){e(this.name,this.value)});else for(c in a)Bc(c,a[c],b,e);return d.join("&").replace(wc,"+")},o.fn.extend({serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=o.prop(this,"elements");return a?o.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!o(this).is(":disabled")&&Ac.test(this.nodeName)&&!zc.test(a)&&(this.checked||!T.test(a))}).map(function(a,b){var c=o(this).val();return null==c?null:o.isArray(c)?o.map(c,function(a){return{name:b.name,value:a.replace(yc,"\r\n")}}):{name:b.name,value:c.replace(yc,"\r\n")}}).get()}}),o.ajaxSettings.xhr=function(){try{return new XMLHttpRequest}catch(a){}};var Cc=0,Dc={},Ec={0:200,1223:204},Fc=o.ajaxSettings.xhr();a.ActiveXObject&&o(a).on("unload",function(){for(var a in Dc)Dc[a]()}),l.cors=!!Fc&&"withCredentials"in Fc,l.ajax=Fc=!!Fc,o.ajaxTransport(function(a){var b;return l.cors||Fc&&!a.crossDomain?{send:function(c,d){var e,f=a.xhr(),g=++Cc;if(f.open(a.type,a.url,a.async,a.username,a.password),a.xhrFields)for(e in a.xhrFields)f[e]=a.xhrFields[e];a.mimeType&&f.overrideMimeType&&f.overrideMimeType(a.mimeType),a.crossDomain||c["X-Requested-With"]||(c["X-Requested-With"]="XMLHttpRequest");for(e in c)f.setRequestHeader(e,c[e]);b=function(a){return function(){b&&(delete Dc[g],b=f.onload=f.onerror=null,"abort"===a?f.abort():"error"===a?d(f.status,f.statusText):d(Ec[f.status]||f.status,f.statusText,"string"==typeof f.responseText?{text:f.responseText}:void 0,f.getAllResponseHeaders()))}},f.onload=b(),f.onerror=b("error"),b=Dc[g]=b("abort"),f.send(a.hasContent&&a.data||null)},abort:function(){b&&b()}}:void 0}),o.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return o.globalEval(a),a}}}),o.ajaxPrefilter("script",function(a){void 0===a.cache&&(a.cache=!1),a.crossDomain&&(a.type="GET")}),o.ajaxTransport("script",function(a){if(a.crossDomain){var b,c;return{send:function(d,e){b=o("<script>").prop({async:!0,charset:a.scriptCharset,src:a.url}).on("load error",c=function(a){b.remove(),c=null,a&&e("error"===a.type?404:200,a.type)}),m.head.appendChild(b[0])},abort:function(){c&&c()}}}});var Gc=[],Hc=/(=)\?(?=&|$)|\?\?/;o.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Gc.pop()||o.expando+"_"+cc++;return this[a]=!0,a}}),o.ajaxPrefilter("json jsonp",function(b,c,d){var e,f,g,h=b.jsonp!==!1&&(Hc.test(b.url)?"url":"string"==typeof b.data&&!(b.contentType||"").indexOf("application/x-www-form-urlencoded")&&Hc.test(b.data)&&"data");return h||"jsonp"===b.dataTypes[0]?(e=b.jsonpCallback=o.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h?b[h]=b[h].replace(Hc,"$1"+e):b.jsonp!==!1&&(b.url+=(dc.test(b.url)?"&":"?")+b.jsonp+"="+e),b.converters["script json"]=function(){return g||o.error(e+" was not called"),g[0]},b.dataTypes[0]="json",f=a[e],a[e]=function(){g=arguments},d.always(function(){a[e]=f,b[e]&&(b.jsonpCallback=c.jsonpCallback,Gc.push(e)),g&&o.isFunction(f)&&f(g[0]),g=f=void 0}),"script"):void 0}),o.parseHTML=function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||m;var d=v.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=o.buildFragment([a],b,e),e&&e.length&&o(e).remove(),o.merge([],d.childNodes))};var Ic=o.fn.load;o.fn.load=function(a,b,c){if("string"!=typeof a&&Ic)return Ic.apply(this,arguments);var d,e,f,g=this,h=a.indexOf(" ");return h>=0&&(d=a.slice(h),a=a.slice(0,h)),o.isFunction(b)?(c=b,b=void 0):b&&"object"==typeof b&&(e="POST"),g.length>0&&o.ajax({url:a,type:e,dataType:"html",data:b}).done(function(a){f=arguments,g.html(d?o("<div>").append(o.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,f||[a.responseText,b,a])}),this},o.expr.filters.animated=function(a){return o.grep(o.timers,function(b){return a===b.elem}).length};var Jc=a.document.documentElement;function Kc(a){return o.isWindow(a)?a:9===a.nodeType&&a.defaultView}o.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=o.css(a,"position"),l=o(a),m={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=o.css(a,"top"),i=o.css(a,"left"),j=("absolute"===k||"fixed"===k)&&(f+i).indexOf("auto")>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),o.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(m.top=b.top-h.top+g),null!=b.left&&(m.left=b.left-h.left+e),"using"in b?b.using.call(a,m):l.css(m)}},o.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){o.offset.setOffset(this,a,b)});var b,c,d=this[0],e={top:0,left:0},f=d&&d.ownerDocument;if(f)return b=f.documentElement,o.contains(b,d)?(typeof d.getBoundingClientRect!==U&&(e=d.getBoundingClientRect()),c=Kc(f),{top:e.top+c.pageYOffset-b.clientTop,left:e.left+c.pageXOffset-b.clientLeft}):e},position:function(){if(this[0]){var a,b,c=this[0],d={top:0,left:0};return"fixed"===o.css(c,"position")?b=c.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),o.nodeName(a[0],"html")||(d=a.offset()),d.top+=o.css(a[0],"borderTopWidth",!0),d.left+=o.css(a[0],"borderLeftWidth",!0)),{top:b.top-d.top-o.css(c,"marginTop",!0),left:b.left-d.left-o.css(c,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||Jc;while(a&&!o.nodeName(a,"html")&&"static"===o.css(a,"position"))a=a.offsetParent;return a||Jc})}}),o.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(b,c){var d="pageYOffset"===c;o.fn[b]=function(e){return J(this,function(b,e,f){var g=Kc(b);return void 0===f?g?g[c]:b[e]:void(g?g.scrollTo(d?a.pageXOffset:f,d?f:a.pageYOffset):b[e]=f)},b,e,arguments.length,null)}}),o.each(["top","left"],function(a,b){o.cssHooks[b]=yb(l.pixelPosition,function(a,c){return c?(c=xb(a,b),vb.test(c)?o(a).position()[b]+"px":c):void 0})}),o.each({Height:"height",Width:"width"},function(a,b){o.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){o.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return J(this,function(b,c,d){var e;return o.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?o.css(b,c,g):o.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),o.fn.size=function(){return this.length},o.fn.andSelf=o.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return o});var Lc=a.jQuery,Mc=a.$;return o.noConflict=function(b){return a.$===o&&(a.$=Mc),b&&a.jQuery===o&&(a.jQuery=Lc),o},typeof b===U&&(a.jQuery=a.$=o),o});
/*
### jQuery XML to JSON Plugin v1.3 - 2013-02-18 ###
* http://www.fyneworks.com/ - diego@fyneworks.com
* Licensed under http://en.wikipedia.org/wiki/MIT_License
###
Website: http://www.fyneworks.com/jquery/xml-to-json/
*//*
# INSPIRED BY: http://www.terracoder.com/
AND: http://www.thomasfrank.se/xml_to_json.html
AND: http://www.kawa.net/works/js/xml/objtree-e.html
*//*
This simple script converts XML (document of code) into a JSON object. It is the combination of 2
'xml to json' great parsers (see below) which allows for both 'simple' and 'extended' parsing modes.
*/
// Avoid collisions
;if(window.jQuery) (function($){
// Add function to jQuery namespace
$.extend({
// converts xml documents and xml text to json object
xml2json: function(xml, extended) {
if(!xml) return {}; // quick fail
//### PARSER LIBRARY
// Core function
function parseXML(node, simple){
if(!node) return null;
var txt = '', obj = null, att = null;
var nt = node.nodeType, nn = jsVar(node.localName || node.nodeName);
var nv = node.text || node.nodeValue || '';
/*DBG*/ //if(window.console) console.log(['x2j',nn,nt,nv.length+' bytes']);
if(node.childNodes){
if(node.childNodes.length>0){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'CHILDREN',node.childNodes]);
$.each(node.childNodes, function(n,cn){
var cnt = cn.nodeType, cnn = jsVar(cn.localName || cn.nodeName);
var cnv = cn.text || cn.nodeValue || '';
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>a',cnn,cnt,cnv]);
if(cnt == 8){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>b',cnn,'COMMENT (ignore)']);
return; // ignore comment node
}
else if(cnt == 3 || cnt == 4 || !cnn){
// ignore white-space in between tags
if(cnv.match(/^\s+$/)){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>c',cnn,'WHITE-SPACE (ignore)']);
return;
};
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>d',cnn,'TEXT']);
txt += cnv.replace(/^\s+/,'').replace(/\s+$/,'');
// make sure we ditch trailing spaces from markup
}
else{
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>e',cnn,'OBJECT']);
obj = obj || {};
if(obj[cnn]){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>f',cnn,'ARRAY']);
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
if(!obj[cnn].length) obj[cnn] = myArr(obj[cnn]);
obj[cnn] = myArr(obj[cnn]);
obj[cnn][ obj[cnn].length ] = parseXML(cn, true/* simple */);
obj[cnn].length = obj[cnn].length;
}
else{
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>g',cnn,'dig deeper...']);
obj[cnn] = parseXML(cn);
};
};
});
};//node.childNodes.length>0
};//node.childNodes
if(node.attributes){
if(node.attributes.length>0){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'ATTRIBUTES',node.attributes])
att = {}; obj = obj || {};
$.each(node.attributes, function(a,at){
var atn = jsVar(at.name), atv = at.value;
att[atn] = atv;
if(obj[atn]){
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'ARRAY']);
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
//if(!obj[atn].length) obj[atn] = myArr(obj[atn]);//[ obj[ atn ] ];
obj[cnn] = myArr(obj[cnn]);
obj[atn][ obj[atn].length ] = atv;
obj[atn].length = obj[atn].length;
}
else{
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'TEXT']);
obj[atn] = atv;
};
});
//obj['attributes'] = att;
};//node.attributes.length>0
};//node.attributes
if(obj){
obj = $.extend( (txt!='' ? new String(txt) : {}),/* {text:txt},*/ obj || {}/*, att || {}*/);
//txt = (obj.text) ? (typeof(obj.text)=='object' ? obj.text : [obj.text || '']).concat([txt]) : txt;
txt = (obj.text) ? ([obj.text || '']).concat([txt]) : txt;
if(txt) obj.text = txt;
txt = '';
};
var out = obj || txt;
//console.log([extended, simple, out]);
if(extended){
if(txt) out = {};//new String(out);
txt = out.text || txt || '';
if(txt) out.text = txt;
if(!simple) out = myArr(out);
};
return out;
};// parseXML
// Core Function End
// Utility functions
var jsVar = function(s){ return String(s || '').replace(/-/g,"_"); };
// NEW isNum function: 01/09/2010
// Thanks to Emile Grau, GigaTecnologies S.L., www.gigatransfer.com, www.mygigamail.com
function isNum(s){
// based on utility function isNum from xml2json plugin (http://www.fyneworks.com/ - diego@fyneworks.com)
// few bugs corrected from original function :
// - syntax error : regexp.test(string) instead of string.test(reg)
// - regexp modified to accept comma as decimal mark (latin syntax : 25,24 )
// - regexp modified to reject if no number before decimal mark : ".7" is not accepted
// - string is "trimmed", allowing to accept space at the beginning and end of string
var regexp=/^((-)?([0-9]+)(([\.\,]{0,1})([0-9]+))?$)/
return (typeof s == "number") || regexp.test(String((s && typeof s == "string") ? jQuery.trim(s) : ''));
};
// OLD isNum function: (for reference only)
//var isNum = function(s){ return (typeof s == "number") || String((s && typeof s == "string") ? s : '').test(/^((-)?([0-9]*)((\.{0,1})([0-9]+))?$)/); };
var myArr = function(o){
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
//if(!o.length) o = [ o ]; o.length=o.length;
if(!$.isArray(o)) o = [ o ]; o.length=o.length;
// here is where you can attach additional functionality, such as searching and sorting...
return o;
};
// Utility functions End
//### PARSER LIBRARY END
// Convert plain text to xml
if(typeof xml=='string') xml = $.text2xml(xml);
// Quick fail if not xml (or if this is a node)
if(!xml.nodeType) return;
if(xml.nodeType == 3 || xml.nodeType == 4) return xml.nodeValue;
// Find xml root node
var root = (xml.nodeType == 9) ? xml.documentElement : xml;
// Convert xml to json
var out = parseXML(root, true /* simple */);
// Clean-up memory
xml = null; root = null;
// Send output
return out;
},
// Convert text to XML DOM
text2xml: function(str) {
// NOTE: I'd like to use jQuery for this, but jQuery makes all tags uppercase
//return $(xml)[0];
/* prior to jquery 1.9 */
/*
var out;
try{
var xml = ((!$.support.opacity && !$.support.style))?new ActiveXObject("Microsoft.XMLDOM"):new DOMParser();
xml.async = false;
}catch(e){ throw new Error("XML Parser could not be instantiated") };
try{
if((!$.support.opacity && !$.support.style)) out = (xml.loadXML(str))?xml:false;
else out = xml.parseFromString(str, "text/xml");
}catch(e){ throw new Error("Error parsing XML string") };
return out;
*/
/* jquery 1.9+ */
return $.parseXML(str);
}
}); // extend $
})(jQuery);
\ No newline at end of file
!function(){var a,b,c,d;!function(){var e={},f={};a=function(a,b,c){e[a]={deps:b,callback:c}},d=c=b=function(a){function c(b){if("."!==b.charAt(0))return b;for(var c=b.split("/"),d=a.split("/").slice(0,-1),e=0,f=c.length;f>e;e++){var g=c[e];if(".."===g)d.pop();else{if("."===g)continue;d.push(g)}}return d.join("/")}if(d._eak_seen=e,f[a])return f[a];if(f[a]={},!e[a])throw new Error("Could not find module "+a);for(var g,h=e[a],i=h.deps,j=h.callback,k=[],l=0,m=i.length;m>l;l++)"exports"===i[l]?k.push(g={}):k.push(b(c(i[l])));var n=j.apply(this,k);return f[a]=g||n}}(),a("promise/all",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to all.");return new b(function(b,c){function d(a){return function(b){f(a,b)}}function f(a,c){h[a]=c,0===--i&&b(h)}var g,h=[],i=a.length;0===i&&b([]);for(var j=0;j<a.length;j++)g=a[j],g&&e(g.then)?g.then(d(j),c):f(j,g)})}var d=a.isArray,e=a.isFunction;b.all=c}),a("promise/asap",["exports"],function(a){"use strict";function b(){return function(){process.nextTick(e)}}function c(){var a=0,b=new i(e),c=document.createTextNode("");return b.observe(c,{characterData:!0}),function(){c.data=a=++a%2}}function d(){return function(){j.setTimeout(e,1)}}function e(){for(var a=0;a<k.length;a++){var b=k[a],c=b[0],d=b[1];c(d)}k=[]}function f(a,b){var c=k.push([a,b]);1===c&&g()}var g,h="undefined"!=typeof window?window:{},i=h.MutationObserver||h.WebKitMutationObserver,j="undefined"!=typeof global?global:this,k=[];g="undefined"!=typeof process&&"[object process]"==={}.toString.call(process)?b():i?c():d(),a.asap=f}),a("promise/cast",["exports"],function(a){"use strict";function b(a){if(a&&"object"==typeof a&&a.constructor===this)return a;var b=this;return new b(function(b){b(a)})}a.cast=b}),a("promise/config",["exports"],function(a){"use strict";function b(a,b){return 2!==arguments.length?c[a]:(c[a]=b,void 0)}var c={instrument:!1};a.config=c,a.configure=b}),a("promise/polyfill",["./promise","./utils","exports"],function(a,b,c){"use strict";function d(){var a="Promise"in window&&"cast"in window.Promise&&"resolve"in window.Promise&&"reject"in window.Promise&&"all"in window.Promise&&"race"in window.Promise&&function(){var a;return new window.Promise(function(b){a=b}),f(a)}();a||(window.Promise=e)}var e=a.Promise,f=b.isFunction;c.polyfill=d}),a("promise/promise",["./config","./utils","./cast","./all","./race","./resolve","./reject","./asap","exports"],function(a,b,c,d,e,f,g,h,i){"use strict";function j(a){if(!w(a))throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");if(!(this instanceof j))throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this._subscribers=[],k(a,this)}function k(a,b){function c(a){p(b,a)}function d(a){r(b,a)}try{a(c,d)}catch(e){d(e)}}function l(a,b,c,d){var e,f,g,h,i=w(c);if(i)try{e=c(d),g=!0}catch(j){h=!0,f=j}else e=d,g=!0;o(b,e)||(i&&g?p(b,e):h?r(b,f):a===F?p(b,e):a===G&&r(b,e))}function m(a,b,c,d){var e=a._subscribers,f=e.length;e[f]=b,e[f+F]=c,e[f+G]=d}function n(a,b){for(var c,d,e=a._subscribers,f=a._detail,g=0;g<e.length;g+=3)c=e[g],d=e[g+b],l(b,c,d,f);a._subscribers=null}function o(a,b){var c,d=null;try{if(a===b)throw new TypeError("A promises callback cannot return that same promise.");if(v(b)&&(d=b.then,w(d)))return d.call(b,function(d){return c?!0:(c=!0,b!==d?p(a,d):q(a,d),void 0)},function(b){return c?!0:(c=!0,r(a,b),void 0)}),!0}catch(e){return c?!0:(r(a,e),!0)}return!1}function p(a,b){a===b?q(a,b):o(a,b)||q(a,b)}function q(a,b){a._state===D&&(a._state=E,a._detail=b,u.async(s,a))}function r(a,b){a._state===D&&(a._state=E,a._detail=b,u.async(t,a))}function s(a){n(a,a._state=F)}function t(a){n(a,a._state=G)}var u=a.config,v=(a.configure,b.objectOrFunction),w=b.isFunction,x=(b.now,c.cast),y=d.all,z=e.race,A=f.resolve,B=g.reject,C=h.asap;u.async=C;var D=void 0,E=0,F=1,G=2;j.prototype={constructor:j,_state:void 0,_detail:void 0,_subscribers:void 0,then:function(a,b){var c=this,d=new this.constructor(function(){});if(this._state){var e=arguments;u.async(function(){l(c._state,d,e[c._state-1],c._detail)})}else m(this,d,a,b);return d},"catch":function(a){return this.then(null,a)}},j.all=y,j.cast=x,j.race=z,j.resolve=A,j.reject=B,i.Promise=j}),a("promise/race",["./utils","exports"],function(a,b){"use strict";function c(a){var b=this;if(!d(a))throw new TypeError("You must pass an array to race.");return new b(function(b,c){for(var d,e=0;e<a.length;e++)d=a[e],d&&"function"==typeof d.then?d.then(b,c):b(d)})}var d=a.isArray;b.race=c}),a("promise/reject",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b,c){c(a)})}a.reject=b}),a("promise/resolve",["exports"],function(a){"use strict";function b(a){var b=this;return new b(function(b){b(a)})}a.resolve=b}),a("promise/utils",["exports"],function(a){"use strict";function b(a){return c(a)||"object"==typeof a&&null!==a}function c(a){return"function"==typeof a}function d(a){return"[object Array]"===Object.prototype.toString.call(a)}var e=Date.now||function(){return(new Date).getTime()};a.objectOrFunction=b,a.isFunction=c,a.isArray=d,a.now=e}),b("promise/polyfill").polyfill()}();
\ No newline at end of file
/*
Copyright (c) 2012 Gildas Lormeau. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution.
3. The names of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function(obj) {
var ERR_BAD_FORMAT = "File format is not recognized.";
var ERR_ENCRYPTED = "File contains encrypted entry.";
var ERR_ZIP64 = "File is using Zip64 (4gb+ file size).";
var ERR_READ = "Error while reading zip file.";
var ERR_WRITE = "Error while writing zip file.";
var ERR_WRITE_DATA = "Error while writing file data.";
var ERR_READ_DATA = "Error while reading file data.";
var ERR_DUPLICATED_NAME = "File already exists.";
var ERR_HTTP_RANGE = "HTTP Range not supported.";
var CHUNK_SIZE = 512 * 1024;
var INFLATE_JS = "inflate.js";
var DEFLATE_JS = "deflate.js";
var appendABViewSupported;
try {
appendABViewSupported = new Blob([ getDataHelper(0).view ]).size == 0;
} catch (e) {
}
function Crc32() {
var crc = -1, that = this;
that.append = function(data) {
var offset, table = that.table;
for (offset = 0; offset < data.length; offset++)
crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF];
};
that.get = function() {
return ~crc;
};
}
Crc32.prototype.table = (function() {
var i, j, t, table = [];
for (i = 0; i < 256; i++) {
t = i;
for (j = 0; j < 8; j++)
if (t & 1)
t = (t >>> 1) ^ 0xEDB88320;
else
t = t >>> 1;
table[i] = t;
}
return table;
})();
function blobSlice(blob, index, length) {
if (blob.slice)
return blob.slice(index, index + length);
else if (blob.webkitSlice)
return blob.webkitSlice(index, index + length);
else if (blob.mozSlice)
return blob.mozSlice(index, index + length);
else if (blob.msSlice)
return blob.msSlice(index, index + length);
}
function getDataHelper(byteLength, bytes) {
var dataBuffer, dataArray;
dataBuffer = new ArrayBuffer(byteLength);
dataArray = new Uint8Array(dataBuffer);
if (bytes)
dataArray.set(bytes, 0);
return {
buffer : dataBuffer,
array : dataArray,
view : new DataView(dataBuffer)
};
}
// Readers
function Reader() {
}
function TextReader(text) {
var that = this, blobReader;
function init(callback, onerror) {
var blob = new Blob([ text ], {
type : "text/plain"
});
blobReader = new BlobReader(blob);
blobReader.init(function() {
that.size = blobReader.size;
callback();
}, onerror);
}
function readUint8Array(index, length, callback, onerror) {
blobReader.readUint8Array(index, length, callback, onerror);
}
that.size = 0;
that.init = init;
that.readUint8Array = readUint8Array;
}
TextReader.prototype = new Reader();
TextReader.prototype.constructor = TextReader;
function Data64URIReader(dataURI) {
var that = this, dataStart;
function init(callback) {
var dataEnd = dataURI.length;
while (dataURI.charAt(dataEnd - 1) == "=")
dataEnd--;
dataStart = dataURI.indexOf(",") + 1;
that.size = Math.floor((dataEnd - dataStart) * 0.75);
callback();
}
function readUint8Array(index, length, callback) {
var i, data = getDataHelper(length);
var start = Math.floor(index / 3) * 4;
var end = Math.ceil((index + length) / 3) * 4;
var bytes = obj.atob(dataURI.substring(start + dataStart, end + dataStart));
var delta = index - Math.floor(start / 4) * 3;
for (i = delta; i < delta + length; i++)
data.array[i - delta] = bytes.charCodeAt(i);
callback(data.array);
}
that.size = 0;
that.init = init;
that.readUint8Array = readUint8Array;
}
Data64URIReader.prototype = new Reader();
Data64URIReader.prototype.constructor = Data64URIReader;
function BlobReader(blob) {
var that = this;
function init(callback) {
this.size = blob.size;
callback();
}
function readUint8Array(index, length, callback, onerror) {
var reader = new FileReader();
reader.onload = function(e) {
callback(new Uint8Array(e.target.result));
};
reader.onerror = onerror;
reader.readAsArrayBuffer(blobSlice(blob, index, length));
}
that.size = 0;
that.init = init;
that.readUint8Array = readUint8Array;
}
BlobReader.prototype = new Reader();
BlobReader.prototype.constructor = BlobReader;
function HttpReader(url) {
var that = this;
function getData(callback, onerror) {
var request;
if (!that.data) {
request = new XMLHttpRequest();
request.addEventListener("load", function() {
if (!that.size)
that.size = Number(request.getResponseHeader("Content-Length"));
that.data = new Uint8Array(request.response);
callback();
}, false);
request.addEventListener("error", onerror, false);
request.open("GET", url);
request.responseType = "arraybuffer";
request.send();
} else
callback();
}
function init(callback, onerror) {
var request = new XMLHttpRequest();
request.addEventListener("load", function() {
that.size = Number(request.getResponseHeader("Content-Length"));
callback();
}, false);
request.addEventListener("error", onerror, false);
request.open("HEAD", url);
request.send();
}
function readUint8Array(index, length, callback, onerror) {
getData(function() {
callback(new Uint8Array(that.data.subarray(index, index + length)));
}, onerror);
}
that.size = 0;
that.init = init;
that.readUint8Array = readUint8Array;
}
HttpReader.prototype = new Reader();
HttpReader.prototype.constructor = HttpReader;
function HttpRangeReader(url) {
var that = this;
function init(callback, onerror) {
var request = new XMLHttpRequest();
request.addEventListener("load", function() {
that.size = Number(request.getResponseHeader("Content-Length"));
if (request.getResponseHeader("Accept-Ranges") == "bytes")
callback();
else
onerror(ERR_HTTP_RANGE);
}, false);
request.addEventListener("error", onerror, false);
request.open("HEAD", url);
request.send();
}
function readArrayBuffer(index, length, callback, onerror) {
var request = new XMLHttpRequest();
request.open("GET", url);
request.responseType = "arraybuffer";
request.setRequestHeader("Range", "bytes=" + index + "-" + (index + length - 1));
request.addEventListener("load", function() {
callback(request.response);
}, false);
request.addEventListener("error", onerror, false);
request.send();
}
function readUint8Array(index, length, callback, onerror) {
readArrayBuffer(index, length, function(arraybuffer) {
callback(new Uint8Array(arraybuffer));
}, onerror);
}
that.size = 0;
that.init = init;
that.readUint8Array = readUint8Array;
}
HttpRangeReader.prototype = new Reader();
HttpRangeReader.prototype.constructor = HttpRangeReader;
// Writers
function Writer() {
}
Writer.prototype.getData = function(callback) {
callback(this.data);
};
function TextWriter() {
var that = this, blob;
function init(callback) {
blob = new Blob([], {
type : "text/plain"
});
callback();
}
function writeUint8Array(array, callback) {
blob = new Blob([ blob, appendABViewSupported ? array : array.buffer ], {
type : "text/plain"
});
callback();
}
function getData(callback, onerror) {
var reader = new FileReader();
reader.onload = function(e) {
callback(e.target.result);
};
reader.onerror = onerror;
reader.readAsText(blob);
}
that.init = init;
that.writeUint8Array = writeUint8Array;
that.getData = getData;
}
TextWriter.prototype = new Writer();
TextWriter.prototype.constructor = TextWriter;
function Data64URIWriter(contentType) {
var that = this, data = "", pending = "";
function init(callback) {
data += "data:" + (contentType || "") + ";base64,";
callback();
}
function writeUint8Array(array, callback) {
var i, delta = pending.length, dataString = pending;
pending = "";
for (i = 0; i < (Math.floor((delta + array.length) / 3) * 3) - delta; i++)
dataString += String.fromCharCode(array[i]);
for (; i < array.length; i++)
pending += String.fromCharCode(array[i]);
if (dataString.length > 2)
data += obj.btoa(dataString);
else
pending = dataString;
callback();
}
function getData(callback) {
callback(data + obj.btoa(pending));
}
that.init = init;
that.writeUint8Array = writeUint8Array;
that.getData = getData;
}
Data64URIWriter.prototype = new Writer();
Data64URIWriter.prototype.constructor = Data64URIWriter;
function FileWriter(fileEntry, contentType) {
var writer, that = this;
function init(callback, onerror) {
fileEntry.createWriter(function(fileWriter) {
writer = fileWriter;
callback();
}, onerror);
}
function writeUint8Array(array, callback, onerror) {
var blob = new Blob([ appendABViewSupported ? array : array.buffer ], {
type : contentType
});
writer.onwrite = function() {
writer.onwrite = null;
callback();
};
writer.onerror = onerror;
writer.write(blob);
}
function getData(callback) {
fileEntry.file(callback);
}
that.init = init;
that.writeUint8Array = writeUint8Array;
that.getData = getData;
}
FileWriter.prototype = new Writer();
FileWriter.prototype.constructor = FileWriter;
function BlobWriter(contentType) {
var blob, that = this;
function init(callback) {
blob = new Blob([], {
type : contentType
});
callback();
}
function writeUint8Array(array, callback) {
blob = new Blob([ blob, appendABViewSupported ? array : array.buffer ], {
type : contentType
});
callback();
}
function getData(callback) {
callback(blob);
}
that.init = init;
that.writeUint8Array = writeUint8Array;
that.getData = getData;
}
BlobWriter.prototype = new Writer();
BlobWriter.prototype.constructor = BlobWriter;
// inflate/deflate core functions
function launchWorkerProcess(worker, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
var chunkIndex = 0, index, outputSize;
function onflush() {
worker.removeEventListener("message", onmessage, false);
onend(outputSize);
}
function onmessage(event) {
var message = event.data, data = message.data;
if (message.onappend) {
outputSize += data.length;
writer.writeUint8Array(data, function() {
onappend(false, data);
step();
}, onwriteerror);
}
if (message.onflush)
if (data) {
outputSize += data.length;
writer.writeUint8Array(data, function() {
onappend(false, data);
onflush();
}, onwriteerror);
} else
onflush();
if (message.progress && onprogress)
onprogress(index + message.current, size);
}
function step() {
index = chunkIndex * CHUNK_SIZE;
if (index < size)
reader.readUint8Array(offset + index, Math.min(CHUNK_SIZE, size - index), function(array) {
worker.postMessage({
append : true,
data : array
});
chunkIndex++;
if (onprogress)
onprogress(index, size);
onappend(true, array);
}, onreaderror);
else
worker.postMessage({
flush : true
});
}
outputSize = 0;
worker.addEventListener("message", onmessage, false);
step();
}
function launchProcess(process, reader, writer, offset, size, onappend, onprogress, onend, onreaderror, onwriteerror) {
var chunkIndex = 0, index, outputSize = 0;
function step() {
var outputData;
index = chunkIndex * CHUNK_SIZE;
if (index < size)
reader.readUint8Array(offset + index, Math.min(CHUNK_SIZE, size - index), function(inputData) {
var outputData = process.append(inputData, function() {
if (onprogress)
onprogress(offset + index, size);
});
outputSize += outputData.length;
onappend(true, inputData);
writer.writeUint8Array(outputData, function() {
onappend(false, outputData);
chunkIndex++;
setTimeout(step, 1);
}, onwriteerror);
if (onprogress)
onprogress(index, size);
}, onreaderror);
else {
outputData = process.flush();
if (outputData) {
outputSize += outputData.length;
writer.writeUint8Array(outputData, function() {
onappend(false, outputData);
onend(outputSize);
}, onwriteerror);
} else
onend(outputSize);
}
}
step();
}
function inflate(reader, writer, offset, size, computeCrc32, onend, onprogress, onreaderror, onwriteerror) {
var worker, crc32 = new Crc32();
function oninflateappend(sending, array) {
if (computeCrc32 && !sending)
crc32.append(array);
}
function oninflateend(outputSize) {
onend(outputSize, crc32.get());
}
if (obj.zip.useWebWorkers) {
worker = new Worker(obj.zip.inflateJSPath || INFLATE_JS);//INFLATE_JS
launchWorkerProcess(worker, reader, writer, offset, size, oninflateappend, onprogress, oninflateend, onreaderror, onwriteerror);
} else
launchProcess(new obj.zip.Inflater(), reader, writer, offset, size, oninflateappend, onprogress, oninflateend, onreaderror, onwriteerror);
return worker;
}
function deflate(reader, writer, level, onend, onprogress, onreaderror, onwriteerror) {
var worker, crc32 = new Crc32();
function ondeflateappend(sending, array) {
if (sending)
crc32.append(array);
}
function ondeflateend(outputSize) {
onend(outputSize, crc32.get());
}
function onmessage() {
worker.removeEventListener("message", onmessage, false);
launchWorkerProcess(worker, reader, writer, 0, reader.size, ondeflateappend, onprogress, ondeflateend, onreaderror, onwriteerror);
}
if (obj.zip.useWebWorkers) {
worker = new Worker(obj.zip.workerScriptsPath + DEFLATE_JS);
worker.addEventListener("message", onmessage, false);
worker.postMessage({
init : true,
level : level
});
} else
launchProcess(new obj.zip.Deflater(), reader, writer, 0, reader.size, ondeflateappend, onprogress, ondeflateend, onreaderror, onwriteerror);
return worker;
}
function copy(reader, writer, offset, size, computeCrc32, onend, onprogress, onreaderror, onwriteerror) {
var chunkIndex = 0, crc32 = new Crc32();
function step() {
var index = chunkIndex * CHUNK_SIZE;
if (index < size)
reader.readUint8Array(offset + index, Math.min(CHUNK_SIZE, size - index), function(array) {
if (computeCrc32)
crc32.append(array);
if (onprogress)
onprogress(index, size, array);
writer.writeUint8Array(array, function() {
chunkIndex++;
step();
}, onwriteerror);
}, onreaderror);
else
onend(size, crc32.get());
}
step();
}
// ZipReader
function decodeASCII(str) {
var i, out = "", charCode, extendedASCII = [ '\u00C7', '\u00FC', '\u00E9', '\u00E2', '\u00E4', '\u00E0', '\u00E5', '\u00E7', '\u00EA', '\u00EB',
'\u00E8', '\u00EF', '\u00EE', '\u00EC', '\u00C4', '\u00C5', '\u00C9', '\u00E6', '\u00C6', '\u00F4', '\u00F6', '\u00F2', '\u00FB', '\u00F9',
'\u00FF', '\u00D6', '\u00DC', '\u00F8', '\u00A3', '\u00D8', '\u00D7', '\u0192', '\u00E1', '\u00ED', '\u00F3', '\u00FA', '\u00F1', '\u00D1',
'\u00AA', '\u00BA', '\u00BF', '\u00AE', '\u00AC', '\u00BD', '\u00BC', '\u00A1', '\u00AB', '\u00BB', '_', '_', '_', '\u00A6', '\u00A6',
'\u00C1', '\u00C2', '\u00C0', '\u00A9', '\u00A6', '\u00A6', '+', '+', '\u00A2', '\u00A5', '+', '+', '-', '-', '+', '-', '+', '\u00E3',
'\u00C3', '+', '+', '-', '-', '\u00A6', '-', '+', '\u00A4', '\u00F0', '\u00D0', '\u00CA', '\u00CB', '\u00C8', 'i', '\u00CD', '\u00CE',
'\u00CF', '+', '+', '_', '_', '\u00A6', '\u00CC', '_', '\u00D3', '\u00DF', '\u00D4', '\u00D2', '\u00F5', '\u00D5', '\u00B5', '\u00FE',
'\u00DE', '\u00DA', '\u00DB', '\u00D9', '\u00FD', '\u00DD', '\u00AF', '\u00B4', '\u00AD', '\u00B1', '_', '\u00BE', '\u00B6', '\u00A7',
'\u00F7', '\u00B8', '\u00B0', '\u00A8', '\u00B7', '\u00B9', '\u00B3', '\u00B2', '_', ' ' ];
for (i = 0; i < str.length; i++) {
charCode = str.charCodeAt(i) & 0xFF;
if (charCode > 127)
out += extendedASCII[charCode - 128];
else
out += String.fromCharCode(charCode);
}
return out;
}
function decodeUTF8(str_data) {
var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;
str_data += '';
while (i < str_data.length) {
c1 = str_data.charCodeAt(i);
if (c1 < 128) {
tmp_arr[ac++] = String.fromCharCode(c1);
i++;
} else if (c1 > 191 && c1 < 224) {
c2 = str_data.charCodeAt(i + 1);
tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = str_data.charCodeAt(i + 1);
c3 = str_data.charCodeAt(i + 2);
tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return tmp_arr.join('');
}
function getString(bytes) {
var i, str = "";
for (i = 0; i < bytes.length; i++)
str += String.fromCharCode(bytes[i]);
return str;
}
function getDate(timeRaw) {
var date = (timeRaw & 0xffff0000) >> 16, time = timeRaw & 0x0000ffff;
try {
return new Date(1980 + ((date & 0xFE00) >> 9), ((date & 0x01E0) >> 5) - 1, date & 0x001F, (time & 0xF800) >> 11, (time & 0x07E0) >> 5,
(time & 0x001F) * 2, 0);
} catch (e) {
}
}
function readCommonHeader(entry, data, index, centralDirectory, onerror) {
entry.version = data.view.getUint16(index, true);
entry.bitFlag = data.view.getUint16(index + 2, true);
entry.compressionMethod = data.view.getUint16(index + 4, true);
entry.lastModDateRaw = data.view.getUint32(index + 6, true);
entry.lastModDate = getDate(entry.lastModDateRaw);
if ((entry.bitFlag & 0x01) === 0x01) {
onerror(ERR_ENCRYPTED);
return;
}
if (centralDirectory || (entry.bitFlag & 0x0008) != 0x0008) {
entry.crc32 = data.view.getUint32(index + 10, true);
entry.compressedSize = data.view.getUint32(index + 14, true);
entry.uncompressedSize = data.view.getUint32(index + 18, true);
}
if (entry.compressedSize === 0xFFFFFFFF || entry.uncompressedSize === 0xFFFFFFFF) {
onerror(ERR_ZIP64);
return;
}
entry.filenameLength = data.view.getUint16(index + 22, true);
entry.extraFieldLength = data.view.getUint16(index + 24, true);
}
function createZipReader(reader, onerror) {
function Entry() {
}
Entry.prototype.getData = function(writer, onend, onprogress, checkCrc32) {
var that = this, worker;
function terminate(callback, param) {
if (worker)
worker.terminate();
worker = null;
if (callback)
callback(param);
}
function testCrc32(crc32) {
var dataCrc32 = getDataHelper(4);
dataCrc32.view.setUint32(0, crc32);
return that.crc32 == dataCrc32.view.getUint32(0);
}
function getWriterData(uncompressedSize, crc32) {
if (checkCrc32 && !testCrc32(crc32))
onreaderror();
else
writer.getData(function(data) {
terminate(onend, data);
});
}
function onreaderror() {
terminate(onerror, ERR_READ_DATA);
}
function onwriteerror() {
terminate(onerror, ERR_WRITE_DATA);
}
reader.readUint8Array(that.offset, 30, function(bytes) {
var data = getDataHelper(bytes.length, bytes), dataOffset;
if (data.view.getUint32(0) != 0x504b0304) {
onerror(ERR_BAD_FORMAT);
return;
}
readCommonHeader(that, data, 4, false, function(error) {
onerror(error);
return;
});
dataOffset = that.offset + 30 + that.filenameLength + that.extraFieldLength;
writer.init(function() {
if (that.compressionMethod === 0)
copy(reader, writer, dataOffset, that.compressedSize, checkCrc32, getWriterData, onprogress, onreaderror, onwriteerror);
else
worker = inflate(reader, writer, dataOffset, that.compressedSize, checkCrc32, getWriterData, onprogress, onreaderror, onwriteerror);
}, onwriteerror);
}, onreaderror);
};
function seekEOCDR(offset, entriesCallback) {
reader.readUint8Array(reader.size - offset, offset, function(bytes) {
var dataView = getDataHelper(bytes.length, bytes).view;
if (dataView.getUint32(0) != 0x504b0506) {
seekEOCDR(offset + 1, entriesCallback);
} else {
entriesCallback(dataView);
}
}, function() {
onerror(ERR_READ);
});
}
return {
getEntries : function(callback) {
if (reader.size < 22) {
onerror(ERR_BAD_FORMAT);
return;
}
// look for End of central directory record
seekEOCDR(22, function(dataView) {
var datalength, fileslength;
datalength = dataView.getUint32(16, true);
fileslength = dataView.getUint16(8, true);
reader.readUint8Array(datalength, reader.size - datalength, function(bytes) {
var i, index = 0, entries = [], entry, filename, comment, data = getDataHelper(bytes.length, bytes);
for (i = 0; i < fileslength; i++) {
entry = new Entry();
if (data.view.getUint32(index) != 0x504b0102) {
onerror(ERR_BAD_FORMAT);
return;
}
readCommonHeader(entry, data, index + 6, true, function(error) {
onerror(error);
return;
});
entry.commentLength = data.view.getUint16(index + 32, true);
entry.directory = ((data.view.getUint8(index + 38) & 0x10) == 0x10);
entry.offset = data.view.getUint32(index + 42, true);
filename = getString(data.array.subarray(index + 46, index + 46 + entry.filenameLength));
entry.filename = ((entry.bitFlag & 0x0800) === 0x0800) ? decodeUTF8(filename) : decodeASCII(filename);
if (!entry.directory && entry.filename.charAt(entry.filename.length - 1) == "/")
entry.directory = true;
comment = getString(data.array.subarray(index + 46 + entry.filenameLength + entry.extraFieldLength, index + 46
+ entry.filenameLength + entry.extraFieldLength + entry.commentLength));
entry.comment = ((entry.bitFlag & 0x0800) === 0x0800) ? decodeUTF8(comment) : decodeASCII(comment);
entries.push(entry);
index += 46 + entry.filenameLength + entry.extraFieldLength + entry.commentLength;
}
callback(entries);
}, function() {
onerror(ERR_READ);
});
});
},
close : function(callback) {
if (callback)
callback();
}
};
}
// ZipWriter
function encodeUTF8(string) {
var n, c1, enc, utftext = [], start = 0, end = 0, stringl = string.length;
for (n = 0; n < stringl; n++) {
c1 = string.charCodeAt(n);
enc = null;
if (c1 < 128)
end++;
else if (c1 > 127 && c1 < 2048)
enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128);
else
enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);
if (enc != null) {
if (end > start)
utftext += string.slice(start, end);
utftext += enc;
start = end = n + 1;
}
}
if (end > start)
utftext += string.slice(start, stringl);
return utftext;
}
function getBytes(str) {
var i, array = [];
for (i = 0; i < str.length; i++)
array.push(str.charCodeAt(i));
return array;
}
function createZipWriter(writer, onerror, dontDeflate) {
var worker, files = [], filenames = [], datalength = 0;
function terminate(callback, message) {
if (worker)
worker.terminate();
worker = null;
if (callback)
callback(message);
}
function onwriteerror() {
terminate(onerror, ERR_WRITE);
}
function onreaderror() {
terminate(onerror, ERR_READ_DATA);
}
return {
add : function(name, reader, onend, onprogress, options) {
var header, filename, date;
function writeHeader(callback) {
var data;
date = options.lastModDate || new Date();
header = getDataHelper(26);
files[name] = {
headerArray : header.array,
directory : options.directory,
filename : filename,
offset : datalength,
comment : getBytes(encodeUTF8(options.comment || ""))
};
header.view.setUint32(0, 0x14000808);
if (options.version)
header.view.setUint8(0, options.version);
if (!dontDeflate && options.level != 0 && !options.directory)
header.view.setUint16(4, 0x0800);
header.view.setUint16(6, (((date.getHours() << 6) | date.getMinutes()) << 5) | date.getSeconds() / 2, true);
header.view.setUint16(8, ((((date.getFullYear() - 1980) << 4) | (date.getMonth() + 1)) << 5) | date.getDate(), true);
header.view.setUint16(22, filename.length, true);
data = getDataHelper(30 + filename.length);
data.view.setUint32(0, 0x504b0304);
data.array.set(header.array, 4);
data.array.set(filename, 30);
datalength += data.array.length;
writer.writeUint8Array(data.array, callback, onwriteerror);
}
function writeFooter(compressedLength, crc32) {
var footer = getDataHelper(16);
datalength += compressedLength || 0;
footer.view.setUint32(0, 0x504b0708);
if (typeof crc32 != "undefined") {
header.view.setUint32(10, crc32, true);
footer.view.setUint32(4, crc32, true);
}
if (reader) {
footer.view.setUint32(8, compressedLength, true);
header.view.setUint32(14, compressedLength, true);
footer.view.setUint32(12, reader.size, true);
header.view.setUint32(18, reader.size, true);
}
writer.writeUint8Array(footer.array, function() {
datalength += 16;
terminate(onend);
}, onwriteerror);
}
function writeFile() {
options = options || {};
name = name.trim();
if (options.directory && name.charAt(name.length - 1) != "/")
name += "/";
if (files[name])
throw ERR_DUPLICATED_NAME;
filename = getBytes(encodeUTF8(name));
filenames.push(name);
writeHeader(function() {
if (reader)
if (dontDeflate || options.level == 0)
copy(reader, writer, 0, reader.size, true, writeFooter, onprogress, onreaderror, onwriteerror);
else
worker = deflate(reader, writer, options.level, writeFooter, onprogress, onreaderror, onwriteerror);
else
writeFooter();
}, onwriteerror);
}
if (reader)
reader.init(writeFile, onreaderror);
else
writeFile();
},
close : function(callback) {
var data, length = 0, index = 0;
filenames.forEach(function(name) {
var file = files[name];
length += 46 + file.filename.length + file.comment.length;
});
data = getDataHelper(length + 22);
filenames.forEach(function(name) {
var file = files[name];
data.view.setUint32(index, 0x504b0102);
data.view.setUint16(index + 4, 0x1400);
data.array.set(file.headerArray, index + 6);
data.view.setUint16(index + 32, file.comment.length, true);
if (file.directory)
data.view.setUint8(index + 38, 0x10);
data.view.setUint32(index + 42, file.offset, true);
data.array.set(file.filename, index + 46);
data.array.set(file.comment, index + 46 + file.filename.length);
index += 46 + file.filename.length + file.comment.length;
});
data.view.setUint32(index, 0x504b0506);
data.view.setUint16(index + 8, filenames.length, true);
data.view.setUint16(index + 10, filenames.length, true);
data.view.setUint32(index + 12, length, true);
data.view.setUint32(index + 16, datalength, true);
writer.writeUint8Array(data.array, function() {
terminate(function() {
writer.getData(callback);
});
}, onwriteerror);
}
};
}
obj.zip = {
Reader : Reader,
Writer : Writer,
BlobReader : BlobReader,
HttpReader : HttpReader,
HttpRangeReader : HttpRangeReader,
Data64URIReader : Data64URIReader,
TextReader : TextReader,
BlobWriter : BlobWriter,
FileWriter : FileWriter,
Data64URIWriter : Data64URIWriter,
TextWriter : TextWriter,
createReader : function(reader, callback, onerror) {
reader.init(function() {
callback(createZipReader(reader, onerror));
}, onerror);
},
createWriter : function(writer, callback, onerror, dontDeflate) {
writer.init(function() {
callback(createZipWriter(writer, onerror, dontDeflate));
}, onerror);
},
workerScriptsPath : "",
inflateJSPath:"",
useWebWorkers : true
};
})(this);
function DraftManager( minder ) {
var current = null,
localStorage = window.localStorage,
drafts,
MAX_SIZE = 15;
init();
function init() {
drafts = localStorage.getItem( 'drafts' );
drafts = drafts ? JSON.parse( drafts ) : [];
loadDraftForOldVersion();
}
/**
* @todo 1.2 版本中删除该方法
*
* 加载老版本的草稿
*/
function loadDraftForOldVersion() {
var path = localStorage.getItem( 'draft_filename' ),
data = localStorage.getItem( 'draft_data' );
if ( path && data ) {
drafts.push( {
path: path,
data: data,
name: JSON.parse( data ).data.text,
update: new Date()
} );
localStorage.removeItem( 'draft_filename' );
localStorage.removeItem( 'draft_data' );
}
}
function store() {
localStorage.setItem( 'drafts', JSON.stringify( drafts.slice( 0, MAX_SIZE ) ) );
}
function create( path ) {
current = {
path: path || 'local/' + ( +new Date() )
};
drafts.unshift( current );
save();
}
function open( index ) {
current = drafts[ index ];
if ( !current ) return false;
// bring it first
drafts.splice( index, 1 );
drafts.unshift( current );
store();
return current;
}
function load() {
if ( current ) {
minder.importData( current.data, "json" );
}
return current;
}
function getCurrent() {
return current;
}
function openByPath( path ) {
for ( var i = 0; i < drafts.length; i++ ) {
if ( drafts[ i ].path == path ) return open( i );
}
return false;
}
function save( path ) {
if ( !current ) {
create();
} else {
current.path = path || current.path;
current.name = minder.getMinderTitle();
current.data = minder.exportData( "json" );
current.sync = false;
current.update = new Date();
store();
}
return current;
}
function sync() {
current.sync = true;
store();
}
function list() {
return drafts.slice( 0, 15 );
}
function remove( remove_index ) {
drafts.splice( remove_index, 1 );
store();
}
function clear() {
drafts.splice( 1 );
store();
}
return {
open: open,
openByPath: openByPath,
load: load,
save: save,
create: create,
list: list,
remove: remove,
clear: clear,
getCurrent: getCurrent,
sync: sync
};
}
\ No newline at end of file
#social{position:absolute;right:10px;top:10px;line-height:20px;text-align:right;overflow:hidden}
.dropdown{padding-right:28px}.dropdown:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
button{font-family:Arial,"Heiti SC","Microsoft Yahei";outline:none;display:inline-block;vertical-align:middle;padding:0 15px;height:35px;font-size:13px;line-height:35px;text-align:center;border-radius:5px;color:#fff;text-decoration:none;border:none;margin-left:5px;cursor:pointer;background:#0099f2;background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);}button:hover,button.hover{background:#009fff}
button:active,button.active{background:#007fcc;box-shadow:inset 0 2px 3px rgba(0,0,0,0.2)}
button[disabled]{background:#aaa;cursor:default}
button.baidu-cloud{padding-left:35px;position:relative}button.baidu-cloud:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/baiducloud.png);position:absolute;left:7px;top:5px}
button.share{padding-left:35px;position:relative}button.share:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/share.png) no-repeat;position:absolute;left:7px;top:5px}
button img{position:relative;top:3px;border-radius:2px;margin-right:7px}
button.user-file{position:relative;padding-right:28px}button.user-file img{border:none;outline:none}
button.user-file span.text{display:inline-block;height:24px;line-height:24px}
button.user-file:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
#draft-btn{position:absolute;left:10px;bottom:10px;padding-left:35px;padding-right:28px}#draft-btn:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/draft.png) no-repeat;position:absolute;left:7px;top:5px}
#draft-btn:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
.draft-menu span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px}
.draft-menu li.draft-item a{position:relative}.draft-menu li.draft-item a:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/draft.png) no-repeat 0 -24px;position:absolute;left:4px;top:2px}
.draft-menu li.draft-item:hover a:before{background-position:0 -48px}
.draft-menu li.draft-item{position:relative}.draft-menu li.draft-item:hover a.delete{display:block}
.draft-menu li.draft-item a.delete{display:none;cursor:pointer;position:absolute;width:20px;height:20px;right:4px;top:4px;padding:0;background:url(../themes/default/images/close-button.png) no-repeat 0 0}.draft-menu li.draft-item a.delete:before{display:none}
.draft-menu li.draft-item a.delete:hover{background-position:0 -20px}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked{overflow:hidden;opacity:1;color:#ccc}.draft-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon{float:left;margin:5px 0;width:28px;background-position:center 0;opacity:.3}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-item-label{display:block;margin-left:28px}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked:hover{color:#ccc}.draft-menu.kmui-combobox-menu .kmui-combobox-checked:hover .kmui-combobox-icon{background-position:center 0}
.user-file-menu{margin-top:20px;margin-left:1px}
#share-dialog{position:absolute;padding:20px;border-radius:4px;right:10px;top:65px;background:#fff;width:350px;box-shadow:1px 2px 16px rgba(0,0,0,0.5);display:none}#share-dialog h3{margin:0;font-size:16px;color:#666}
#share-dialog input{width:260px;height:22px;line-height:22px;padding:4px 4px 0;border:1px solid #999;vertical-align:middle;margin-right:3px;background:#eee}#share-dialog input:focus{border:1px solid #99f;outline:none}
#share-dialog p,#share-dialog #share-platform{margin:20px 0 30px}
#share-dialog #copy-share-url{display:inline-block;margin:0;width:70px;height:28px;line-height:28px;border-radius:2px;vertical-align:middle}
#share-dialog #share-platform{margin-bottom:0}
#share-dialog:before{position:absolute;content:' ';width:0;height:0;line-height:0;display:block;border:10px solid transparent;border-bottom-color:#fff;right:30px;top:-20px}
/* global Promise: true */
/**
* 百度脑图社会化功能
*
* 1. 百度账号登陆
* 2. 百度云存储
* 3. 分享
* 4. 草稿箱同步
* 5. 配置文件同步
* @author techird
*/
$.extend( $.fn, {
disabled: function ( value ) {
if ( value === undefined ) return !!this.attr( 'disabled' );
if ( value ) {
this.attr( 'disabled', 'disabled' );
} else {
this.removeAttr( 'disabled' );
}
return this;
},
loading: function ( text ) {
if ( text ) {
this.disabled( true );
this.attr( 'origin-text', this.text() );
this.text( text );
} else {
this.text( this.attr( 'origin-text' ) );
this.removeAttr( 'origin-text' );
this.disabled( false );
}
return this;
},
text: ( function () {
var originFn = $.fn.text;
return function () {
var textSpan = this.children( 'span.text' );
if ( textSpan.length ) {
return originFn.apply( textSpan, arguments );
} else {
return originFn.apply( this, arguments );
}
};
} )()
} );
/**
* 核心业务逻辑
*/
$( function () {
// UI 元素
var $panel, $login_btn, $save_btn, $share_btn, $user_btn, $user_menu,
$draft_btn, $draft_menu, $share_dialog, $share_url, $copy_url_btn,
// 当前文件的远端路径
remotePath = null,
// 当前登录的账户
currentAccount,
// 当前连接是否指示要加载一个分享的脑图
isShareLink,
isPathLink,
uuid = function () {
return ( ( +new Date() * 10000 ) + ( Math.random() * 9999 ) ).toString( 36 );
},
// 当前脑图的分享ID
shareId = uuid(),
titleSuffix = document.title || '百度脑图',
// 脑图实例
minder = window.km,
// 草稿箱实例
draftManager = window.draftManager || ( window.draftManager = new window.DraftManager( minder ) ),
// 当前是否要检测文档内容是否变化的开关
watchingChanges = true,
notice = ( function () {
return window.alert;
} )();
start();
function start() {
initUI();
initFrontia();
if ( checkLogin() ) {
return;
}
loadShare();
bindShortCuts();
bindDraft();
watchChanges();
if ( !loadPath() && !isShareLink ) loadDraft( 0 );
}
// 创建 UI
function initUI() {
$panel = $( '<div id="social"></div>' ).appendTo( 'body' );
$login_btn = $( '<button>登录</button>' ).addClass( 'login' ).click( login ).appendTo( $panel );
$user_btn = $( '<button><span class="text"></span></button>' ).addClass( 'user-file' );
$user_menu = $.kmuidropmenu( {
data: [ {
label: '新建脑图',
click: newFile
}, {
label: '到网盘管理文件...',
click: function () {
window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' );
}
}, {
label: '注销',
click: logout
}, {
divider: true
} ]
} ).addClass( 'user-file-menu' ).appendTo( 'body' ).kmui();
$user_menu.attachTo( $user_btn );
$save_btn = $( '<button id="save-btn">保存</button>' ).click( save )
.addClass( 'baidu-cloud' );
$share_btn = $( '<button id="share-btn">分享</button>' ).click( share )
.addClass( 'share' ).appendTo( $panel );
$draft_btn = $( '<button id="draft-btn">草稿箱</button>' ).appendTo( 'body' );
$draft_menu = $.kmuidropmenu().addClass( 'draft-menu kmui-combobox-menu' ).appendTo( 'body' );
$draft_menu.kmui().attachTo( $draft_btn );
$draft_menu.on( 'aftershow', showDraftList );
$share_dialog = $( '#share-dialog' );
$share_url = $( '#share-url' );
$copy_url_btn = $( '#copy-share-url' );
$share_dialog.mousedown( function ( e ) {
e.stopPropagation();
} );
var copyTrickTimer = 0;
$( 'body' ).on( 'mousedown', function ( e ) {
copyTrickTimer = setTimeout( function () {
$share_dialog.hide();
$share_btn.loading( false );
$copy_url_btn.loading( false );
}, 30 );
} );
var clip = new window.ZeroClipboard( $copy_url_btn, {
hoverClass: 'hover',
activeClass: 'active'
} );
clip.on( 'dataRequested', function ( client, args ) {
$copy_url_btn.loading( '已复制' );
clearTimeout( copyTrickTimer );
} );
}
// 初始化云平台 frontia
function initFrontia() {
var AK = 'wiE55BGOG8BkGnpPs6UNtPbb';
baidu.frontia.init( AK );
baidu.frontia.social.setLoginCallback( {
success: setAccount,
error: function ( error ) {
notice( '登录失败!' );
}
} );
}
function initPreferneceSync() {
if ( currentAccount ) {
}
}
// 检查 URL 是否分享连接,是则加载分享内容
function loadShare() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return;
var shareId = match[ 1 ];
var query = new baidu.frontia.storage.Query();
query.on( 'shareMinder.id' ).equal( shareId );
$share_btn.loading( '正在加载分享内容...' );
baidu.frontia.storage.findData( query, {
success: function ( ret ) {
if ( ret.count === 0 ) {
$share_btn.loading( false );
return notice( '加载分享内容失败!请确认分享链接正确。' );
}
var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) {
draftManager.load();
} else {
draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
setRemotePath( null, false );
$share_btn.loading( false );
},
error: function ( e ) {
console.log( e );
}
} );
isShareLink = true;
}
// 检查 URL 是否请求加载用户文件,是则加载
function loadPath() {
var pattern = /path=(.+?)([&#]|$)/;
// documemt.referrer 是为了支持被嵌在 iframe 里的情况
var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return;
if ( !currentAccount ) {
setTimeout( function () {
if ( !currentAccount ) return login();
setRemotePath( decodeURIComponent( match[ 1 ], true ) );
loadRemote();
}, 1000 );
return false;
}
setRemotePath( decodeURIComponent( match[ 1 ], true ) );
loadRemote();
return true;
}
function setRemotePath( path, saved ) {
var filename;
remotePath = path;
if ( remotePath ) {
filename = getFileName( remotePath );
if ( !saved ) {
filename = '* ' + filename;
}
$user_btn.text( filename );
} else if ( currentAccount ) {
$user_btn.text( '* ' + minder.getMinderTitle() );
}
document.title = [ filename || minder.getMinderTitle(), titleSuffix ].join( ' - ' );
if ( saved ) {
$save_btn.disabled( true ).text( '已保存' );
} else {
$save_btn.disabled( false ).text( '保存' );
}
}
// 检查是否在 Cookie 中登录过了
function checkLogin() {
var account = baidu.frontia.getCurrentAccount();
if ( account ) {
login();
return true;
}
return false;
}
// 用户点击登录按钮主动登录
function login() {
baidu.frontia.social.login( {
response_type: 'token',
media_type: 'baidu',
redirect_uri: window.location.href,
client_type: 'web'
} );
}
function logout() {
baidu.frontia.logOutCurrentAccount();
setAccount( null );
}
// 设置用户后为其初始化
function setAccount( account ) {
currentAccount = account;
if ( account ) {
$user_btn.prependTo( $panel );
$save_btn.appendTo( $panel );
$share_btn.appendTo( $panel );
$login_btn.detach();
loadAvator();
loadUserFiles();
window.location.hash = '';
} else {
$user_btn.detach();
$save_btn.detach();
$login_btn.prependTo( $panel );
}
}
// 加载用户头像
function loadAvator() {
var $img = $( '<img />' ).attr( {
'src': 'social/loading.gif',
'width': 16,
'height': 16
} ).prependTo( $user_btn );
currentAccount.getDetailInfo( {
success: function ( user ) {
$img.attr( {
'src': user.extra.tinyurl
} );
}
} );
}
// 加载用户最近使用的文件
function loadUserFiles() {
var sto = baidu.frontia.personalStorage;
//$user_btn.loading( '加载最近脑图...' );
sto.listFile( 'apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
//$user_btn.loading( false );
addToRecentMenu( result.list.filter( function ( file ) {
return getFileFormat( file.path ) in fileLoader;
} ) );
syncPreference( result.list );
}
},
error: function () {
notice( '加载最近脑图失败!' );
//$user_btn.loading( false );
}
} );
}
// 同步用户配置文件
function syncPreference( fileList ) {
// frontia 接口对象引用
var sto = baidu.frontia.personalStorage;
// 配置文件在网盘的路径
var remotePreferencesPath = '/apps/kityminder/app.preferences';
// 检查是否存在线上的配置文件
var hasRemotePreferences = ~fileList.map( function ( file ) {
return file.path;
} ).indexOf( remotePreferencesPath );
// 记录远端配置的和本地配置的版本
// - 远端配置保存在 json 内容的 version 字段中
// - 本地配置用 localStorage 来记录
var remoteVersion = 0,
localVersion = localStorage.preferencesVersion || 0;
// 远端配置和本地配置的内容
var remotePreferences, localPreferences;
// 远端有配置,下载远端配置
if ( hasRemotePreferences ) {
downloadPreferences();
}
// 绑定实例上配置改变的事件,配置有变需要上传
minder.on( 'preferenceschange', function () {
localStorage.preferencesVersion = ++localVersion;
uploadPreferences();
} );
// 下载远端配置
function downloadPreferences() {
// 比较远端和本地版本
// - 远端版本较新则设置本地版本为远端版本
// - 本地版本较新则上传本地版本
function merge( remote ) {
remoteVersion = remote.version;
remotePreferences = remote.preferences;
localPreferences = minder.getPreferences();
if ( localVersion < remoteVersion ) {
minder.resetPreferences( remotePreferences );
} else if ( localVersion > remoteVersion ) {
uploadPreferences();
}
}
// 下载配置的过程
// 需要先获得下载的 URL 再使用 ajax 请求内容
sto.getFileUrl( remotePreferencesPath, {
success: function ( url ) {
$.ajax( {
url: url,
cache: false,
dataType: 'json',
success: merge,
error: function () {
notice( '下载配置失败!' );
}
} );
}
} );
}
// 上传本地配置
function uploadPreferences() {
localPreferences = minder.getPreferences();
// 上传的数据需要附带版本信息
var data = {
version: localVersion,
preferences: localPreferences
};
var text = JSON.stringify( data );
sto.uploadTextFile( text, remotePreferencesPath, {
// 文件重复选择覆盖
ondup: sto.constant.ONDUP_OVERWRITE,
success: function ( savedFile ) {
console && console.log( '配置已上传' );
},
error: function ( e ) {
notice( '上传配置失败' );
}
} );
}
}
// 加载当前 remoteUrl 中制定的文件
function loadRemote() {
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载“' + getFileName( remotePath ) + '”...' );
sto.getFileUrl( remotePath, {
success: function ( url ) {
// the url to download the file on cloud dist
var format = getFileFormat( remotePath );
if ( format in fileLoader ) {
fileLoader[ format ]( url );
}
},
error: notice
} );
}
function getFileFormat( fileUrl ) {
return fileUrl.split( '.' ).pop();
}
var fileLoader = {
'km': loadPlainType,
'json': loadPlainType,
'xmind': loadXMind,
'mmap': loadMindManager,
'mm': loadFreeMind
};
function loadPlainType( url ) {
$.ajax( {
cache: false,
url: url,
dataType: 'text',
success: function ( result ) {
importFile( result, 'json' );
}
} );
}
function loadXMind( url ) {
var xhr = new XMLHttpRequest();
xhr.open( "get", url, true );
xhr.responseType = "blob";
xhr.onload = function () {
if ( this.status == 200 && this.readyState ) {
var blob = this.response;
importFile( blob, 'xmind' );
}
};
xhr.send();
}
function loadMindManager( url ) {
var xhr = new XMLHttpRequest();
xhr.open( "get", url, true );
xhr.responseType = "blob";
xhr.onload = function () {
if ( this.status == 200 && this.readyState ) {
var blob = this.response;
importFile( blob, 'mindmanager' );
}
};
xhr.send();
}
function loadFreeMind( url ) {
$.ajax( {
cache: false,
url: url,
dataType: 'text',
success: function ( result ) {
importFile( result, 'freemind' );
}
} );
}
// 见文件数据导入minder
function importFile( data, format ) {
watchingChanges = false;
minder.importData( data, format );
if ( !draftManager.openByPath( remotePath ) ) {
draftManager.create();
}
draftManager.save( remotePath );
draftManager.sync();
minder.execCommand( 'camera', minder.getRoot() );
$user_btn.loading( false ).text( getFileName( remotePath ) );
watchingChanges = true;
}
// 添加文件到最近文件列表
function addToRecentMenu( list ) {
list.splice( 12 );
list.forEach( function ( file ) {
$user_menu.appendItem( {
item: {
label: getFileName( file.path ),
value: file.path
},
click: openFile
} );
} );
}
// 从路径中抽取文件名
function getFileName( path ) {
return path.split( '/' ).pop();
}
// 点击文件菜单
function openFile( e ) {
var path = $( this ).data( 'value' );
var draft = draftManager.getCurrent();
if ( draft && draft.path == path ) {
if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) {
setRemotePath( path, true );
loadRemote();
}
} else {
draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync );
if ( draft ) {
watchingChanges = false;
draftManager.load();
watchingChanges = true;
} else {
loadRemote();
}
}
}
// 新建文件
function newFile() {
setRemotePath( null, true );
draftManager.create();
minder.importData( '新建脑图', 'plain' );
minder.execCommand( 'camera', minder.getRoot() );
}
function generateRemotePath() {
var filename = window.prompt( "请输入文件名: ", minder.getMinderTitle() ) || minder.getMinderTitle();
return '/apps/kityminder/' + filename + '.km';
}
function save() {
if ( !currentAccount ) return;
var data = minder.exportData( 'json' );
var sto = baidu.frontia.personalStorage;
function error( reason ) {
notice( reason + '\n建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false );
clearTimeout( timeout );
}
var timeout = setTimeout( function () {
error( '保存到云盘超时,可能是网络不稳定导致。' );
}, 15000 );
sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
draftManager.save( remotePath );
draftManager.sync();
clearTimeout( timeout );
} else {
error( '保存到云盘失败,可能是网络问题导致!' );
}
},
error: function ( e ) {
error( '保存到云盘失败' );
}
} );
$save_btn.loading( '正在保存...' );
}
function share() {
if ( $share_btn.disabled() ) {
return;
}
var baseUrl = /^(.*?)(\?|\#|$)/.exec( window.location.href )[ 1 ];
var shareUrl = baseUrl + '?shareId=' + shareId,
shareData = new baidu.frontia.Data( {
shareMinder: {
id: shareId,
data: minder.exportData( 'json' )
}
} );
var shareConfig = window._bd_share_config.common,
resetShare = window._bd_share_main.init;
$share_btn.loading( '正在分享...' );
baidu.frontia.storage.insertData( shareData, {
success: function () {
$share_dialog.show();
$share_url.val( shareUrl )[ 0 ].select();
}
} );
shareConfig.bdTitle = shareConfig.bdText = minder.getMinderTitle();
shareConfig.bdDesc = shareConfig.bdText = '“' + minder.getMinderTitle() + '” - 我用百度脑图制作的思维导图,快看看吧!(地址:' + shareUrl + ')';
shareConfig.bdUrl = shareUrl;
resetShare();
}
function bindShortCuts() {
$( document.body ).keydown( function ( e ) {
var keyCode = e.keyCode || e.which;
//添加快捷键
if ( ( e.ctrlKey || e.metaKey ) ) {
switch ( keyCode ) {
//保存
case KM.keymap.s:
if ( e.shiftKey ) {
share();
} else {
save();
}
e.preventDefault();
break;
case KM.keymap.n:
newFile();
e.preventDefault();
break;
}
}
} );
}
function watchChanges() {
minder.on( 'contentchange', function () {
if ( !watchingChanges ) return;
var current = draftManager.save();
if ( currentAccount ) {
$save_btn.disabled( current.sync ).text( '保存' );
setRemotePath( remotePath, current.sync );
}
} );
}
function showDraftList() {
var list = draftManager.list(),
draft, $draft, index;
if ( !list.length ) {
draftManager.create();
list = draftManager.list();
}
draft = list.shift();
$draft_menu.empty().append( '<li disabled="disabled" class="current-draft kmui-combobox-item kmui-combobox-item-disabled kmui-combobox-checked">' +
'<span class="kmui-combobox-icon"></span>' +
'<label class="kmui-combobox-item-label">' + draft.name +
'<span class="update-time">' + getFriendlyTimeSpan( +new Date( draft.update ), +new Date() ) + '</span>' +
'</label>' +
'</li>' );
$draft_menu.append( '<li class="kmui-divider"></li>' );
index = 1;
while ( list.length ) {
draft = list.shift();
$draft = $( '<li class="draft-item">' +
'<a href="#">' + draft.name + '<span class="update-time">' + getFriendlyTimeSpan( +new Date( draft.update ), +new Date() ) + '</span></a><a class="delete" title="删除该草稿"></a></li>' );
$draft.data( 'draft-index', index++ );
$draft.appendTo( $draft_menu );
}
if ( index > 1 ) {
$draft_menu.append( '<li class="kmui-divider"></li>' );
$draft_menu.append( '<li class="draft-clear"><a href="#">清空草稿箱</a></li>' );
}
adjustDraftMenu();
}
function adjustDraftMenu() {
var pos = $draft_btn.offset();
pos.top -= $draft_menu.outerHeight() + 5;
$draft_menu.offset( pos );
}
function bindDraft() {
$draft_menu.delegate( 'a.delete', 'click', function ( e ) {
var $li = $( this ).closest( 'li.draft-item' );
draftManager.remove( +$li.data( 'draft-index' ) );
$li.remove();
showDraftList();
e.stopPropagation();
} )
.delegate( 'li.draft-clear', 'click', function ( e ) {
if ( window.confirm( '确认清除草稿箱吗?' ) ) {
draftManager.clear();
showDraftList();
}
e.stopPropagation();
} )
.delegate( 'li.draft-item', 'click', function ( e ) {
loadDraft( +$( this ).data( 'draft-index' ) );
} );
}
function loadDraft( index ) {
var draft = draftManager.open( index ),
isRemote;
if ( !draft ) return;
isRemote = draft.path.indexOf( '/apps/kityminder' ) === 0;
if ( isRemote ) {
setRemotePath( draft.path, draft.sync );
}
watchingChanges = false;
draftManager.load();
watchingChanges = true;
if ( !isRemote ) {
setRemotePath( null, false );
}
}
function getFriendlyTimeSpan( t1_in_ms, t2_in_ms ) {
var ms = Math.abs( t1_in_ms - t2_in_ms ),
s = ms / 1000,
m = s / 60,
h = m / 60,
d = h / 24;
if ( s < 60 ) return "刚刚";
if ( m < 60 ) return ( m | 0 ) + "分钟前";
if ( h < 24 ) return ( h | 0 ) + "小时前";
if ( d <= 30 ) return ( d | 0 ) + "天前";
return "很久之前";
}
window.social = {
setRemotePath: setRemotePath,
watchChanges: function ( value ) {
watchingChanges = value;
}
};
} );
\ No newline at end of file
#social {
position: absolute;
right: 10px;
top: 10px;
line-height: 20px;
text-align: right;
overflow: hidden;
}
.dropdown {
padding-right: 28px;
&:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 15px;
width: 0;
height: 0;
border: solid;
border-width: 4px 5px;
border-color: #FFFFFF transparent transparent transparent;
}
}
button {
font-family: Arial, "Heiti SC", "Microsoft Yahei";
outline: none;
display: inline-block;
vertical-align: middle;
padding: 0 15px;
height: 35px;
font-size: 13px;
line-height: 35px;
text-align: center;
border-radius: 5px;
color: #ffffff;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;
background: #0099f2; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
&:hover, &.hover {
background: #009fff;
}
&:active, &.active {
background: darken(#009fff, 10%);
box-shadow: inset 0 2px 3px rgba(0,0,0, .2);
}
&[disabled] {
background: #AAA;
cursor: default;
}
&.baidu-cloud {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/baiducloud.png);
position: absolute;
left: 7px;
top: 5px;
}
}
&.share {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/share.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
}
img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
}
&.user-file {
position: relative;
img {
border: none;
outline: none;
}
span.text {
display: inline-block;
height: 24px;
line-height: 24px;
}
.dropdown;
}
}
#draft-btn {
position: absolute;
left: 10px;
bottom: 10px;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/draft.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
padding-left: 35px;
.dropdown;
}
.draft-menu {
span.update-time {
float: right;
color: #CCC;
margin-left: 20px;
padding-right: 16px;
}
li.draft-item a {
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/draft.png) no-repeat 0 -24px;
position: absolute;
left: 4px;
top: 2px;
}
}
li.draft-item:hover a:before {
background-position: 0 -48px;
}
li.draft-item {
position: relative;
&:hover a.delete{
display: block;
}
a.delete {
display: none;
cursor: pointer;
position: absolute;
width: 20px;
height: 20px;
right: 4px;
top: 4px;
padding: 0;
background: url(../themes/default/images/close-button.png) no-repeat 0 0;
&:before {
display: none;
}
&:hover {
background-position: 0 -20px;
}
}
}
&.kmui-combobox-menu .kmui-combobox-checked {
overflow: hidden;
opacity: 1;
color: #CCC;
.kmui-combobox-icon {
float: left;
margin: 5px 0;
width: 28px;
background-position: center 0;
opacity: .3;
}
.kmui-combobox-item-label {
display: block;
margin-left: 28px;
}
&:hover {
color: #CCC;
.kmui-combobox-icon {
background-position: center 0;
}
}
}
}
.user-file-menu {
margin-top: 20px;
margin-left: 1px;
}
#share-dialog {
position: absolute;
padding: 20px;
border-radius: 4px;
right: 10px;
top: 65px;
background: white;
width: 350px;
box-shadow: 1px 2px 16px rgba(0, 0, 0, .5);
display: none;
h3 {
margin: 0;
font-size: 16px;
color: #666;
}
input {
width: 260px;
height: 22px;
line-height: 22px;
padding: 4px 4px 0;
border: 1px solid #999;
vertical-align: middle;
margin-right: 3px;
background: #EEE;
&:focus {
border: 1px solid #99f;
outline: none;
}
}
p, #share-platform {
margin: 20px 0 30px;
}
#copy-share-url {
display: inline-block;
margin: 0;
width: 70px;
height: 28px;
line-height: 28px;
border-radius: 2px;
vertical-align: middle;
}
#share-platform {
margin-bottom: 0;
}
&:before {
position: absolute;
content: ' ';
width: 0;
height: 0;
line-height: 0;
display: block;
border: 10px solid transparent;
border-bottom-color: white;
right: 30px;
top: -20px;
}
}
\ No newline at end of file
/*普通按钮*/
.kmui-btn-toolbar .kmui-btn{
position: relative;
display: inline-block;
vertical-align: middle;
*display: inline;
*zoom:1;
width:auto;
margin: 0 1px;
padding:1px;
border:none;
background: none;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon{
width: 20px;
height: 20px;
margin: 0;
padding:0;
background-repeat: no-repeat;
background-image: url(../images/icons.png);
background-image: url(../images/icons.gif) \9;
}
/*状态反射*/
.kmui-btn-toolbar .kmui-btn.kmui-hover,
.kmui-btn-toolbar .kmui-btn.kmui-active{
background-color: #d5e1f2;
border: 1px solid #a3bde3;
padding: 0;
_z-index: 1;
}
.kmui-btn-toolbar .kmui-btn.kmui-disabled{
opacity: 0.3;
filter: alpha(opacity = 30);
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-btn .kmui-icon-undo {
background-position: -160px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-redo {
background-position: -100px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-bold{
background-position: 0 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-italic {
background-position: -60px 0;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-font, .kmui-btn-toolbar .kmui-btn .kmui-icon-forecolor {
background-position: -720px 1px;
}
.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;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-help {
background: url(../images/help.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-preference {
background: url(../images/setting.png) no-repeat 2px 2px;
}
\ No newline at end of file
.kmui-splitbutton-color-label {
width: 16px;
height: 3px;
position: absolute;
bottom: 2px;
left: 50%;
margin-left: -8px;
overflow: hidden;
line-height: 3px;
}
.kmui-popup .kmui-colorpicker {
margin: 10px;
font-size: 12px;
}
.kmui-colorpicker .kmui-colorpicker-topbar{
height: 27px;
width: 200px;
overflow: hidden;
}
.kmui-colorpicker .kmui-colorpicker-topbar .kmui-colorpicker-preview{
height: 20px;
border: 1px inset black;
margin-left: 1px;
width: 128px;
float: left;
}
.kmui-colorpicker .kmui-colorpicker-topbar .kmui-colorpicker-nocolor{
float: right;
margin-right: 1px;
font-size: 12px;
line-height: 14px;
height: 14px;
border: 1px solid #333;
padding: 3px 5px;
cursor: pointer;
}
.kmui-colorpicker table{
border-collapse: collapse;
border-spacing: 2px;
}
.kmui-colorpicker tr.kmui-colorpicker-firstrow{
height: 30px;
}
.kmui-colorpicker table td{
padding: 0 2px;
}
.kmui-colorpicker table td .kmui-colorpicker-colorcell{
display: block;
text-decoration: none;
color: black;
width: 14px;
height: 14px;
margin: 0;
cursor: pointer;
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-combobox{
border: 1px solid transparent;
padding:0;
margin:0 2px;
line-height: 20px;
font-family: Arial, "Heiti SC", "Microsoft Yahei";
}
.kmui-combobox .kmui-button-label{
position: relative;
display: inline-block;
vertical-align: middle;
*display: inline ;
*zoom:1;
height:20px;
line-height: 20px;
padding: 2px 5px;
margin: 0;
font-size: 12px;
text-align: center;
cursor: default;
}
.kmui-combobox .kmui-button-spacing{
position: relative;
display: inline-block ;
vertical-align: middle;
*display: inline ;
*zoom:1;
height:20px;
margin: 0;
/*padding:0 3px;*/
padding: 0;
}
.kmui-combobox .kmui-caret{
position: relative;
display: inline-block ;
vertical-align: middle;
*display: inline ;
*zoom:1;
height:20px;
width: 12px;
margin: 0;
padding: 0;
background: url(../images/icons.png) -740px 2px no-repeat;
_background: url(../images/icons.gif) -740px 2px no-repeat;
padding: 2px 0;
border-left: 1px solid transparent;
}
.kmui-combobox:hover .kmui-caret {
border-left-color: #a3bde3;
}
.kmui-btn-toolbar .kmui-combobox.kmui-disabled{
opacity: 0.2;
filter: alpha(opacity = 20);
}
.kmui-combobox-menu{
position: absolute;
display: none;
list-style: none;
text-decoration: none;
margin: 0;
padding: 5px 0;
background-color: #ffffff;
font-size: 12px;
box-shadow: 2px 5px 15px rgba(0, 0, 0, .5);
border-radius: 3px;
min-width: 160px;
_width: 160px;
-webkit-transform: translateX(2px);
font-family: Arial, "Heiti SC", "Microsoft Yahei";
}
.kmui-combobox-menu .kmui-combobox-item {
display: block;
padding: 2px 15px 2px 2px;
white-space:nowrap;
}
.kmui-combobox-menu .kmui-combobox-item:first-child:last-child {
border-radius: 2px;
}
.kmui-combobox-menu .kmui-combobox-item-label {
height: 25px;
line-height: 25px;
display: inline-block;
vertical-align: middle;
_display: inline;
_zoom: 1;
}
.kmui-combobox-menu .kmui-combobox-item:hover, .kmui-combobox-menu .kmui-combobox-stack-item:hover, .kmui-combobox-menu .kmui-combobox-item-hover {
background: #0099f2; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
/*border: 1px solid #a3bde3;*/
}
.kmui-combobox-menu .kmui-combobox-item .kmui-combobox-icon {
display: inline-block;
*zoom: 1;
*display: inline;
width: 30px;
height: 12px;
line-height: 12px;
vertical-align: middle;
background: url(../images/check.png) no-repeat 1000px 1000px;
}
.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon {
background-position: center 0;
}
.kmui-combobox-menu .kmui-combobox-checked:hover .kmui-combobox-icon {
background-position: center -12px;
}
.kmui-combobox-menu .kmui-combobox-item-separator {
min-width: 160px;
height: 1px;
line-height: 1px;
overflow: hidden;
background: #d3d3d3;
margin: 5px 0;
*margin-top: -8px;
}
/* 字体样式校正 */
.kmui-combobox-menu .kmui-combobox-item-disabled {
color: black;
opacity: 0.3;
}
.kmui-combobox-menu .kmui-combobox-item-disabled:hover {
border-color: #fff;
background: #fff;
color: black;
}
\ No newline at end of file
.kmui-modal {
position: fixed;
top: 60px;
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;
width:20px;
height:20px;
margin-top: 2px;
padding: 1px;
border: 0;
background: url("../images/close.png") no-repeat center center;
cursor: pointer;
}
.kmui-modal-header .kmui-close.kmui-hover {
background-color: #d5e1f2;
padding:0;
border: 1px solid #a3bde3;
}
.kmui-modal-header .kmui-title {
margin: 0;
line-height: 25px;
font-size: 20px;
}
.kmui-modal-body {
position: relative;
max-height: 400px;
font-size: 12px;
overflow-y: auto;
overflow-x: hidden;
}
.kmui-modal-footer {
float: right;
padding: 5px 15px 15px;
overflow: hidden;
}
.kmui-modal-footer .kmui-btn {
float: left;
height: 24px;
width: 96px;
margin: 0 10px;
background-color: #ffffff;
padding: 0;
border: 1px solid #ababab;
font-size: 12px;
line-height: 24px;
text-align: center;
cursor: pointer;
}
.kmui-modal-footer .kmui-btn.kmui-hover{
background-color: #d5e1f2;
border: 1px solid #a3bde3;
}
.kmui-modal-backdrop{
opacity: 0.5;
filter: alpha(opacity=50);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: #c6c6c6;
}
.kmui-modal .kmui-modal-tip {
color: red;
position: absolute;
bottom: 10px;
left: 10px;
height: 30px;
line-height: 30px;
display: none;
}
\ No newline at end of file
.kmui-dropdown-menu {
position: absolute;
z-index: 1000;
display: none;
min-width: 160px;
padding: 5px 0;
font-size: 12px;
list-style: none;
background-color: #ffffff;
border-radius: 3px;
box-shadow: 2px 5px 15px rgba(0, 0, 0, .5);
background-clip: padding-box;
font-family: Arial, "Heiti SC", "Microsoft Yahei";
}
.kmui-dropdown-menu.pull-right {
right: 0;
left: auto;
}
.kmui-dropdown-menu .kmui-divider {
height: 1px;
margin: 5px 0;
overflow: hidden;
background-color: #e5e5e5;
}
.kmui-dropdown-menu .kmui-divider:first-child,
.kmui-dropdown-menu .kmui-divider:last-child {
display: none;
}
.kmui-dropdown-menu > li > a {
display: block;
padding: 2px 15px 2px 30px;
height: 25px;
line-height: 25px;
clear: both;
font-weight: normal;
color: #333333;
white-space: nowrap;
text-decoration: none;
}
.kmui-dropdown-menu > li:hover > a,
.kmui-dropdown-menu > li:focus > a {
background: #0099f2; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
}
.kmui-dropdown-menu > .active > a,
.kmui-dropdown-menu > .active > a:hover,
.kmui-dropdown-menu > .active > a:focus {
color: #ffffff;
text-decoration: none;
background-color: #428bca;
outline: 0;
}
.kmui-dropdown-menu > .disabled > a,
.kmui-dropdown-menu > .disabled > a:hover,
.kmui-dropdown-menu > .disabled > a:focus {
color: #999999;
}
.kmui-dropdown-menu > .disabled > a:hover,
.kmui-dropdown-menu > .disabled > a:focus {
text-decoration: none;
cursor: not-allowed;
background-color: transparent;
background-image: none;
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
}
.kmui-dropdown-menu >li > a:active, .kmui-dropdown-menu >li > a:hover {
outline: 0;
}
.help-content{
line-height: 20px;
font-size: 12px;
}
.help-content ul{
list-style: none;
padding:0;
}
.help-content ul li{
color:#666;
}
.help-content h2{color:#333;font-size: 18px;}
.help-content h3{
color:#333;
display: inline;
font-size: 14px;
}
\ No newline at end of file
@import "kityminder.css";
@import "button.css";
@import "buttonicon.css";
@import "splitbutton.css";
@import "combobox.css";
@import "comboboxmenu.css";
@import "dialog.css";
@import "dialogsize.css";
@import "popup.css";
@import "tab.css";
@import "tooltip.css";
@import "colorpicker.css";
@import "separator.css";
@import "markers.css";
@import "help.css";
@import "dropmenu.css";
\ No newline at end of file
html, body, div {
margin: 0;
padding: 0;
}
html, body, #kityminder, div.kmui-editor-body {
height: 100%;
width: 100%;
overflow: hidden;
-moz-user-select: none;
}
.km_receiver{
width:0;
height:0;
}
.km-minderNode{
cursor:default;
}
.kmui-container {
height: 100%;
}
.kmui-container {
}
.kmui-container .kmui-toolbar{
background-color: #fafafa;
z-index: 99999;
margin-right: 400px;
}
.kmui-toolbar .kmui-btn-toolbar{
padding: 5px;
}
.kmui-toolbar {
position: absolute;
left: 10px;
top: 10px;
border-radius: 4px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
}
.kmui-container .kmui-editor-body {
background: rgb(50, 60, 61) url(../images/grid.png) repeat;
/*line-height: 0;*/
overflow: hidden;
}
svg {
font-family: Arial, "Microsoft Yahei","Heiti SC",sans-serif;
}
\ 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
.kmui-popup{
display: none;
/*background: url('../images/pop-bg.png') repeat #fff;*/
background: white;
padding: 2px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, .5);
}
.kmui-popup .kmui-popup-body{
/*border: 1px solid #bfbfbf;*/
background-color: #fff;
}
.kmui-popup .kmui-popup-caret{
width: 21px;
height: 11px;
}
.kmui-popup .kmui-popup-caret.up{
/*background:url('../images/caret.png') no-repeat 0 0;*/
}
.kmui-popup .kmui-popup-caret.down{
/*background:url('../images/caret.png') no-repeat 0 0;*/
}
.kmui-toolbar .kmui-separator{
width: 2px;
height: 20px;
padding: 1px 2px;
background: url(../images/icons.png) -179px 1px;
background: url(../images/icons.gif) -179px 1px \9;
display: inline-block ;
vertical-align: middle;
*display: inline ;
*zoom:1;
border:none;
}
\ No newline at end of file
.kmui-btn-toolbar .kmui-splitbutton{
position: relative;
display: inline-block ;
vertical-align: middle;
*display: inline ;
*zoom:1;
margin:0 2px;
}
.kmui-splitbutton .kmui-btn{
margin: 0;
}
.kmui-splitbutton .kmui-caret{
position: relative;
display: inline-block ;
vertical-align: middle;
*display: inline ;
*zoom:1;
width: 8px;
height: 20px;
background: url(../images/icons.png) -741px 0;
_background: url(../images/icons.gif) -741px 0;
}
.kmui-btn-toolbar .kmui-splitbutton {
border: 1px solid transparent;
}
.kmui-btn-toolbar .kmui-splitbutton .kmui-dropdown-toggle {
padding: 1px 2px;
margin-left: -1px;
border-left: 1px solid transparent;
}
.kmui-btn-toolbar .kmui-splitbutton .kmui-dropdown-toggle:hover {
border-left-color: #a3bde3;
background-color: #dbe7f8;
}
/*状态反射*/
.kmui-btn-toolbar .kmui-splitbutton.kmui-hover {
background-color: #d5e1f2;
border: 1px solid #a3bde3;
}
.kmui-btn-toolbar .kmui-splitbutton.kmui-disabled{
opacity: 0.3;
filter: alpha(opacity = 30);
}
.kmui-tab-nav {
margin: 0;
padding:0;
border-bottom: 1px solid #ddd;
list-style: none;
height:30px;
}
.kmui-tab-nav .kmui-tab-item {
float:left;
margin-bottom: -1px;
margin-top: 1px;
margin-top: 0\9;
}
.kmui-tab-nav .kmui-tab-item .kmui-tab-text{
display: block;
padding:8px 12px;
border: 1px solid transparent;
color: #0088cc;
text-decoration: none;
outline: 0;
_border:1px solid #fff ;
cursor: pointer;
}
.kmui-tab-nav .kmui-tab-item .kmui-tab-text:FOCUS {
outline: none;
}
.kmui-tab-nav .kmui-tab-item.kmui-active .kmui-tab-text{
border: 1px solid #ddd;
border-bottom-color: transparent;
background-color: #fff;
padding:8px 12px;
color: #555555;
cursor: default;
}
.kmui-tab-content .kmui-tab-pane{
padding: 1px;
position: relative;
display: none;
background-color: #fff;
clear: both;
}
.kmui-tab-content .kmui-tab-pane.kmui-active{
display: block;
}
.kmui-btn-toolbar .kmui-tooltip{
position: absolute;
padding: 5px 0;
display: none;
/*opacity: 0.8;*/
/*filter: alpha(opacity=80);*/
z-index: 99999;
}
.kmui-tooltip .kmui-tooltip-arrow{
position: absolute;
top: 0;
_top: -19px;
left: 50%;
width: 0;
height: 0;
padding: 0;
margin-left: -5px;
border-color: transparent;
border-style: dashed dashed solid dashed;
border-bottom-color: #000000;
border-width: 0 5px 5px;
background: transparent;
}
.kmui-tooltip .kmui-tooltip-inner{
padding: 6px;
color: #ffffff;
text-align: center;
text-decoration: none;
font-size: 10px;
background-color: #000000;
white-space: nowrap;
line-height: 12px;
}
\ No newline at end of file
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ toolbars: [
'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | preference | help' 'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
...@@ -82,10 +82,10 @@ ...@@ -82,10 +82,10 @@
//,zIndex : 1000 //,zIndex : 1000
//设置初始加载时展开的层数和子节点数目阈值 //设置初始加载时展开的层数和子节点数目阈值
//默认是全部展开,0表示全部展开 //默认是全部展开,0表示全部展开
, // ,
defaultExpand: { // defaultExpand: {
defaultLayer: 1, // defaultLayer: 1,
defaultSubShow: 5 // defaultSubShow: 5
} // }
}; };
} )(); } )();
\ No newline at end of file
KityMinder.registerModule( "Expand", function () { KityMinder.registerModule( "Expand", function () {
var ExpandCommand = kity.createClass( "ExpandCommand", ( function () { var EXPAND_STATE_DATA = 'expandState',
return { STATE_EXPAND = 'expand',
base: Command, STATE_COLLAPSE = 'collapse';
execute: function ( km ) {
km.initStyle( true ); /**
* 节点展开和收缩的策略常量
*
* 策略是一个处理函数,处理函数接受 3 个参数:
*
* @param {MinderNode} node 要处理的节点
* @param {Enum} state 取值为 "expand" | "collapse",表示要对节点进行的操作是展开还是收缩
* @param {Function} policy 提供当前策略的函数,方便递归调用
*/
MinderNode.EXAPND_POLICY = {
/**
* 策略 1:只修改当前节点的状态,不递归子节点的状态
*/
KEEP_STATE: function ( node, state, policy ) {
node.setData( expandStateData, state === STATE_EXPAND );
}, },
queryState: function ( km ) {
return 0; /**
} * 策略 2:该函数返回一个策略,表示递归到节点指定的层数
* 返回的策略表示把操作(展开/收起)进行到指定的层数
*
* @param {int} deep_level 指定的层数
*/
DEEP_TO_LEVEL: function ( deep_level ) {
return function ( node, state, policy ) {
}; };
} )() );
var ContractCommand = kity.createClass( "ContractCommand", ( function () {
return {
base: Command,
execute: function ( km ) {
km.initStyle();
}, },
queryState: function ( km ) { DEEP_TO_CHILD: function () {
return 0;
},
DEEP_TO_LEAVE: function () {
} }
}; };
} )() );
return { kity.extendClass( MinderNode, {
'commands': { expand: function ( policy ) {
'expand': ExpandCommand, node.setData( EXPAND_STATE_DATA, STATE_EXPAND );
'contract': ContractCommand },
collapse: function () {
node.setData( EXPAND_STATE_DATA, STATE_COLLAPSE );
},
isExpanded: function () {
return this.getData( EXPAND_STATE_DATA ) === STATE_EXPAND;
} }
} );
return {
'commands': {}
}; };
} ); } );
\ No newline at end of file
...@@ -423,9 +423,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -423,9 +423,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
if ( nodeType !== "root" && node.getChildren().length !== 0 ) { if ( nodeType !== "root" && node.getChildren().length !== 0 ) {
if ( !Layout.shicon ) { if ( !Layout.shicon ) {
Layout.shicon = new ShIcon( node ); Layout.shicon = new ShIcon( node );
if ( Layout.expand ) {
Layout.shicon.switchState();
}
} }
Layout.shicon.update(); Layout.shicon.update();
} }
...@@ -508,7 +505,8 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -508,7 +505,8 @@ KityMinder.registerModule( "LayoutDefault", function () {
this.highlightNode( node ) this.highlightNode( node )
} }
}, },
initStyle: function ( expandall ) { initStyle: function () {
//渲染根节点
var _root = minder.getRoot(); var _root = minder.getRoot();
var historyPoint = _root.getPoint(); var historyPoint = _root.getPoint();
if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) ); if ( historyPoint ) historyPoint = JSON.parse( JSON.stringify( historyPoint ) );
...@@ -541,53 +539,71 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -541,53 +539,71 @@ KityMinder.registerModule( "LayoutDefault", function () {
updateLayoutVertical( _root ); updateLayoutVertical( _root );
translateNode( _root ); translateNode( _root );
if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y ); if ( historyPoint ) _root.setPoint( historyPoint.x, historyPoint.y );
var expandoptions = minder.getOptions( 'defaultExpand' ); //渲染首层节点
var cur_layer = 0;
var expand_layer = expandoptions.defaultLayer;
var mains = _root.getChildren(); var mains = _root.getChildren();
for ( var i = 0; i < mains.length; i++ ) { for ( var i = 0; i < mains.length; i++ ) {
this.appendChildNode( _root, mains[ i ] ); this.appendChildNode( _root, mains[ i ] );
//console.log( mains[ i ].isExpanded() );
if ( mains[ i ].isExpanded() && mains[ i ].getChildren().length > 0 ) {
debugger;
minder.expandNode( mains[ i ] );
} }
cur_layer++;
var clonelayer0 = function () {
var items = [];
for ( var i = 0; i < mains.length; i++ ) {
items.push( mains[ i ] );
} }
return items; _root.setPoint( _root.getLayout().x, _root.getLayout().y );
}; },
//创建一级节点的副本 expandNode: function ( ico ) {
var _buffer = clonelayer0(); var isExpand, node;
next = []; if ( ico instanceof MinderNode ) {
var layer_nolimit = expandall || ( expand_layer < 1 ) || false; node = ico;
var sub_nolimit = expandall || ( expandoptions.defaultSubShow < 1 ) || false; isExpand = node.getLayout().shicon.switchState();
} else {
isExpand = ico.icon.switchState();
node = ico.icon._node;
}
var _buffer;
if ( isExpand ) {
node.expand();
//遍历子树展开需要展开的节点
_buffer = [ node ];
debugger;
while ( _buffer.length !== 0 ) { while ( _buffer.length !== 0 ) {
cur_layer++; var c = _buffer[ 0 ].getChildren();
var layer_len = _buffer.length; if ( _buffer[ 0 ].isExpanded() && c.length !== 0 ) {
for ( var j = 0; j < layer_len; j++ ) { for ( var x = 0; x < c.length; x++ ) {
var c = _buffer[ j ].getChildren(); minder.appendChildNode( _buffer[ 0 ], c[ x ] );
if (
(
( ( sub_nolimit || ( c.length <= expandoptions.defaultSubShow ) ) && ( layer_nolimit || ( cur_layer <= expand_layer ) ) ) ||
_buffer[ j ].getLayout().expand
) && c.length !== 0 ) {
this.expandNode( _buffer[ j ] );
_buffer = _buffer.concat( _buffer[ j ].getChildren() );
} }
_buffer = _buffer.concat( c );
}
_buffer.shift();
}
} else {
node.collapse();
//遍历子树移除需要移除的节点
_buffer = node.getChildren();
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( Layout.added ) {
Layout.added = false;
_buffer[ 0 ].getRenderContainer().remove();
Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift();
}
var set = updateLayoutVertical( node, node.getParent(), "contract" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
} }
_buffer.splice( 0, layer_len );
} }
_root.setPoint( _root.getLayout().x, _root.getLayout().y );
}, },
appendChildNode: function ( parent, node, focus, sibling ) { appendChildNode: function ( parent, node, focus, sibling ) {
minder.handelNodeInsert( node ); minder.handelNodeInsert( node );
var Layout = node.getLayout();
node.clearLayout(); node.clearLayout();
node.getContRc().clear(); node.getContRc().clear();
var Layout = node.getLayout(); Layout = node.getLayout();
Layout.expand = false;
if ( parent.getType() !== 'root' ) {
parent.getLayout().expand = true;
}
Layout.added = true; Layout.added = true;
var parentLayout = parent.getLayout(); var parentLayout = parent.getLayout();
var children = parent.getChildren(); var children = parent.getChildren();
...@@ -736,43 +752,6 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -736,43 +752,6 @@ KityMinder.registerModule( "LayoutDefault", function () {
_buffer.shift(); _buffer.shift();
} }
} }
},
expandNode: function ( ico ) {
var isExpand, node;
if ( ico instanceof MinderNode ) {
node = ico;
isExpand = node.getLayout().shicon.switchState();
} else {
isExpand = ico.icon.switchState();
node = ico.icon._node;
}
var Layout = node.getLayout();
Layout.expand = isExpand;
var _buffer = node.getChildren();
if ( isExpand ) {
for ( var j = 0; j < _buffer.length; j++ ) {
minder.appendChildNode( node, _buffer[ j ] );
}
} else {
var _buffer = node.getChildren();
while ( _buffer.length !== 0 ) {
var Layout = _buffer[ 0 ].getLayout();
if ( Layout.added ) {
Layout.added = false;
_buffer[ 0 ].getRenderContainer().remove();
Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
}
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift();
}
}
var set = [];
if ( !isExpand ) set = updateLayoutVertical( node, node.getParent(), "contract" );
for ( var i = 0; i < set.length; i++ ) {
translateNode( set[ i ] );
updateConnectAndshIcon( set[ i ] );
}
} }
}; };
this.addLayoutStyle( "default", _style ); this.addLayoutStyle( "default", _style );
......
...@@ -38,7 +38,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -38,7 +38,7 @@ KityMinder.registerModule( "LayoutModule", function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this.getLayoutStyle( curStyle ).highlightNode.call( this, node ); this.getLayoutStyle( curStyle ).highlightNode.call( this, node );
}, },
initStyle: function ( expandall ) { initStyle: function () {
var curStyle = this.getCurrentStyle(); var curStyle = this.getCurrentStyle();
this._rc.remove(); this._rc.remove();
this._rc = new kity.Group(); this._rc = new kity.Group();
...@@ -48,7 +48,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -48,7 +48,7 @@ KityMinder.registerModule( "LayoutModule", function () {
_root.preTraverse( function ( n ) { _root.preTraverse( function ( n ) {
n.clearLayout(); n.clearLayout();
} ); } );
this.getLayoutStyle( curStyle ).initStyle.call( this, expandall ); this.getLayoutStyle( curStyle ).initStyle.call( this );
this.fire( 'afterinitstyle' ); this.fire( 'afterinitstyle' );
}, },
restoreStyle: function () { restoreStyle: function () {
...@@ -126,7 +126,7 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -126,7 +126,7 @@ KityMinder.registerModule( "LayoutModule", function () {
if ( !parent ) { if ( !parent ) {
return null; return null;
} }
if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && parent.getLayout().expand === false ) { if ( parent.getType() !== "root" && parent.getChildren().length !== 0 && !parent.isExpanded() ) {
km.expandNode( parent ); km.expandNode( parent );
} }
......
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