<commit_before>
/**
 * [options description]
 * @type {Object}
 */
UI.Layout.implement({
	options: {
		resizer: {
			modifier: {
				row: {
					size: 'width',
					from: 'left',
					mode: {
						y: false
					}
				},
				column: {
					size: 'height',
					from: 'top',
					mode: {
						x: false
					}
				}
			}
		}
	},

	/**
	 * [_initResizeBorder description]
	 * @param  {[type]} component [description]
	 * @param  {[type]} border    [description]
	 * @return {[type]}           [description]
	 */
	_initResizer: function(component) {
		//_log('_initResizer', component.options.name);

		var self = this,
			name = component.options.name,
			element = component.element,
			container = component.container,
			last = component.options.last;

		this._initMaximize(component);

		if (!container) return;

		var direction = container.getStyle('flex-direction');

		if (!direction)	return;

		var modifier = this.options.resizer.modifier[direction];

		if (!modifier) return;

		//console.log('direction', direction, modifier);

		//_log(element, coord);
		var resizer = this.resizer[name] = new Element('div', {
			'class': 'ui-resizer',
			'data-name': component.options.name
		}).addEvents({
			click: function(e){
				e.stop();
			},
			mousedown: function(e) {
				e.stop();
			}
		}).inject(container);

		if (modifier.size) {
			resizer.addClass('resizer-'+ modifier.size);
		}

		if (last) {
			//_log('------last' );
			//resizer.addClass('resizer-last');
		}

		this._initResizerDrag(resizer, modifier, component);
		this._initResizerEvent(component, resizer, modifier);

		this.fireEvent('drag');
	},

	/**
	 * [_initDrag description]
	 * @param  {[type]} resizer  [description]
	 * @param  {[type]} modifier [description]
	 * @return {[type]}          [description]
	 */
	_initResizerDrag: function(resizer, modifier, component) {
		var self = this;
		//_log('initResizerDrag', resizer, modifier);

		var element = component.element,
			container = component.container,
			last = component.options.last;

		var drag = new Drag.Move(resizer, {
			modifiers: modifier.mode,
		    onStart: function(el){
				//_log('onStart', el);
				//self.fireEvent('resizeStart', el);
			},
			onDrag: function(el, ev){
				//_log('onDrag', el);
				var coord = element.getCoordinates(container);
				var coordc = container.getCoordinates();
				var c = resizer.getCoordinates(container);
				//element.setStyle('flex','none');
				//element.setStyle(modifier.size, c[modifier.from] - coord[modifier.from]);
				if (last){
					//_log(modifier.size, coordc[modifier.size], c[modifier.from]);
					element.setStyle(modifier.size, coordc[modifier.size] - c[modifier.from]);
				}
				else {
					element.setStyle(modifier.size, c[modifier.from] - coord[modifier.from]);
				}

				self.fireEvent('drag');
			},
			onComplete: function(el){
				//_log('onComplete', component.main, modifier.size, size);
				//_log('onComplete', modifier.size, element.getCoordinates(container)[modifier.size]);
				var coord = element.getCoordinates(container);
				var size = element.getCoordinates(container)[modifier.size];
				self.fireEvent('resizer', [component.main, modifier.size, size]);
				component.fireEvent('resizeComplete', [modifier.size, size]);

				//_log('size', modifier, size);

				component[modifier.size] = size;
			}
		});

		return drag;
	},

	/**
	 * [_initResizerEvent description]
	 * @param  {[type]} component [description]
	 * @param  {[type]} resizer   [description]
	 * @param  {[type]} modifier  [description]
	 * @return {[type]}           [description]
	 */
	// will definitly use a controller for that
	_initResizerEvent: function(component, resizer, modifier) {
		//_log('_initResizerEvent', component.options.name, component.options.last);
		var self = this;

		this.addEvents({
			drag: function(e) {
				//_log('drag', e);
				self._updateSize(component, resizer, modifier);
			},
			maximize: function() {
				//_log(direction);
				self._updateSize(component, resizer, modifier);
			},
			normalize: function() {
				//_log(direction);
				self._updateSize(component, resizer, modifier);
			},
			resize: function() {
				//_log('resize', component.element, resizer);

				self._updateSize(component, resizer, modifier);
			}
		});
	},

	_updateSize: function(component, resizer, modifier) {
		//_log('_updazeSize');
		var container = component.container,
			element = component.element;

		var coord = element.getCoordinates(container);
		//_log('coord',  coord[modifier.from]);
		//
		// the last container doesnt need resizedr
		if (component.options.last) {
			resizer.setStyle(modifier.from, coord[modifier.from] -3);
		} else {
			resizer.setStyle(modifier.from, coord[modifier.from] + coord[modifier.size] -3);
		}
	},

	/**
	 * Init maximisation. dblclick trigger the toggle
	 * @param  {[type]} component [description]
	 * @return {[type]}           [description]
	 */
	_initMaximize: function(component) {
		//_log('_initMaximize', component);
		var self = this;
		var element = component.element;
		var container = component.container;

		if (!container) return;

		component.addEvent('max', function() {
			var name = component.options.name;

			_log('max', component);
			if (element.hasClass('container-max')) {
				element.removeClass('container-max');
				container.getChildren('.ui-container').each(function(c) {
					c.setStyle('display', c.retrieve('display'));
				});

				element.setStyle('width', element.retrieve('width'));
				element.setStyle('height', element.retrieve('height'));

				self.fireEvent('normalize', component);
			} else{
				element.addClass('container-max');
				element.store('width', element.getStyle('width'));
				element.store('height', element.getStyle('height'));
				element.setStyle('width', 'initial');
				element.setStyle('height', 'initial');
				container.getChildren('.ui-container').each(function(c) {
					if (!c.hasClass('container-'+name)) {
						c.store('display', c.getStyle('display'));
						c.hide();
					}
				});

				self.fireEvent('resize', component);
			}
		});
	},

	/**
	 * [_initResize description]
	 * @return {[type]} [description]
	 */
	_initResizers: function(components) {
		//_log('_initResizers');
		var len = components.length;

		// add resize Border on the right or on the bottom
		// execpt for the last one
		for (var i = 0; i < len; i++) {
			var component = components[i];

			if (component.options.noResizer) {
				//console.log('--', component.main);
				continue;
			}

			this._initResizer(component);

		}
	},

});
<commit_msg>update doc<commit_after>
/**
 * UI Layout Resize
 * @implement UI.Layout
 */
UI.Layout.implement({
	options: {
		resizer: {
			modifier: {
				row: {
					size: 'width',
					from: 'left',
					mode: {
						y: false
					}
				},
				column: {
					size: 'height',
					from: 'top',
					mode: {
						x: false
					}
				}
			}
		}
	},

	/**
	 * [_initResizeBorder description]
	 * @param  {[type]} component [description]
	 * @param  {[type]} border    [description]
	 * @return {[type]}           [description]
	 */
	_initResizer: function(component) {
		//_log('_initResizer', component.options.name);

		var self = this,
			name = component.options.name,
			element = component.element,
			container = component.container,
			last = component.options.last;

		this._initMaximize(component);

		if (!container) return;

		var direction = container.getStyle('flex-direction');

		if (!direction)	return;

		var modifier = this.options.resizer.modifier[direction];

		if (!modifier) return;

		//console.log('direction', direction, modifier);

		//_log(element, coord);
		var resizer = this.resizer[name] = new Element('div', {
			'class': 'ui-resizer',
			'data-name': component.options.name
		}).addEvents({
			click: function(e){
				e.stop();
			},
			mousedown: function(e) {
				e.stop();
			}
		}).inject(container);

		if (modifier.size) {
			resizer.addClass('resizer-'+ modifier.size);
		}

		if (last) {
			//_log('------last' );
			//resizer.addClass('resizer-last');
		}

		this._initResizerDrag(resizer, modifier, component);
		this._initResizerEvent(component, resizer, modifier);

		this.fireEvent('drag');
	},

	/**
	 * [_initDrag description]
	 * @param  {[type]} resizer  [description]
	 * @param  {[type]} modifier [description]
	 * @return {[type]}          [description]
	 */
	_initResizerDrag: function(resizer, modifier, component) {
		var self = this;
		//_log('initResizerDrag', resizer, modifier);

		var element = component.element,
			container = component.container,
			last = component.options.last;

		var drag = new Drag.Move(resizer, {
			modifiers: modifier.mode,
		    onStart: function(el){
				//_log('onStart', el);
				//self.fireEvent('resizeStart', el);
			},
			onDrag: function(el, ev){
				//_log('onDrag', el);
				var coord = element.getCoordinates(container);
				var coordc = container.getCoordinates();
				var c = resizer.getCoordinates(container);
				//element.setStyle('flex','none');
				//element.setStyle(modifier.size, c[modifier.from] - coord[modifier.from]);
				if (last){
					//_log(modifier.size, coordc[modifier.size], c[modifier.from]);
					element.setStyle(modifier.size, coordc[modifier.size] - c[modifier.from]);
				}
				else {
					element.setStyle(modifier.size, c[modifier.from] - coord[modifier.from]);
				}

				self.fireEvent('drag');
			},
			onComplete: function(el){
				//_log('onComplete', component.main, modifier.size, size);
				//_log('onComplete', modifier.size, element.getCoordinates(container)[modifier.size]);
				var coord = element.getCoordinates(container);
				var size = element.getCoordinates(container)[modifier.size];
				self.fireEvent('resizer', [component.main, modifier.size, size]);
				component.fireEvent('resizeComplete', [modifier.size, size]);

				//_log('size', modifier, size);

				component[modifier.size] = size;
			}
		});

		return drag;
	},

	/**
	 * [_initResizerEvent description]
	 * @param  {[type]} component [description]
	 * @param  {[type]} resizer   [description]
	 * @param  {[type]} modifier  [description]
	 * @return {[type]}           [description]
	 */
	// will definitly use a controller for that
	_initResizerEvent: function(component, resizer, modifier) {
		//_log('_initResizerEvent', component.options.name, component.options.last);
		var self = this;

		this.addEvents({
			drag: function(e) {
				//_log('drag', e);
				self._updateSize(component, resizer, modifier);
			},
			maximize: function() {
				//_log(direction);
				self._updateSize(component, resizer, modifier);
			},
			normalize: function() {
				//_log(direction);
				self._updateSize(component, resizer, modifier);
			},
			resize: function() {
				//_log('resize', component.element, resizer);

				self._updateSize(component, resizer, modifier);
			}
		});
	},

	_updateSize: function(component, resizer, modifier) {
		//_log('_updazeSize');
		var container = component.container,
			element = component.element;

		var coord = element.getCoordinates(container);
		//_log('coord',  coord[modifier.from]);
		//
		// the last container doesnt need resizedr
		if (component.options.last) {
			resizer.setStyle(modifier.from, coord[modifier.from] -3);
		} else {
			resizer.setStyle(modifier.from, coord[modifier.from] + coord[modifier.size] -3);
		}
	},

	/**
	 * Init maximisation. dblclick trigger the toggle
	 * @param  {[type]} component [description]
	 * @return {[type]}           [description]
	 */
	_initMaximize: function(component) {
		//_log('_initMaximize', component);
		var self = this;
		var element = component.element;
		var container = component.container;

		if (!container) return;

		component.addEvent('max', function() {
			var name = component.options.name;

			_log('max', component);
			if (element.hasClass('container-max')) {
				element.removeClass('container-max');
				container.getChildren('.ui-container').each(function(c) {
					c.setStyle('display', c.retrieve('display'));
				});

				element.setStyle('width', element.retrieve('width'));
				element.setStyle('height', element.retrieve('height'));

				self.fireEvent('normalize', component);
			} else{
				element.addClass('container-max');
				element.store('width', element.getStyle('width'));
				element.store('height', element.getStyle('height'));
				element.setStyle('width', 'initial');
				element.setStyle('height', 'initial');
				container.getChildren('.ui-container').each(function(c) {
					if (!c.hasClass('container-'+name)) {
						c.store('display', c.getStyle('display'));
						c.hide();
					}
				});

				self.fireEvent('resize', component);
			}
		});
	},

	/**
	 * [_initResize description]
	 * @return {[type]} [description]
	 */
	_initResizers: function(components) {
		//_log('_initResizers');
		var len = components.length;

		// add resize Border on the right or on the bottom
		// execpt for the last one
		for (var i = 0; i < len; i++) {
			var component = components[i];

			if (component.options.noResizer) {
				//console.log('--', component.main);
				continue;
			}

			this._initResizer(component);

		}
	},

});
<|endoftext|>


<commit_before>/***
*   Copyright 2014 Sean Wragg <seanwragg@gmail.com>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*	   http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/

var Database = require('./Database.js'),
	Q = require('q');

var Player = {
	locate: function(search) {
		var deferred = Q.defer();

		if (!search.name || !search.lid) {
			deferred.reject({
				status: 400
			});

			return deferred.promise;
		}

		var query = Database.format(
			'SELECT pid, uid FROM wol_players WHERE name = ? AND lid = ?', [search.name, search.lid]
		);

		Database.query(query, function(err, result) {
            if (result.length > 0) {
                search.pid = result[0].pid;
				search.uid = result[0].uid;
				search.exists = true; // player located
				return deferred.resolve(search);
            }

            if (!search.create) {
                // return player not found
                return deferred.reject({
                    status: 404
                });
            }

            // create player
            var insert = {
                name: search.name,
                lid: search.lid,
                ctime: Math.floor(new Date().getTime() / 1000)
            };

            if (search.uid) {
                insert.uid = search.uid;
            }

            Database.insert('wol_players', insert, function(pid) {
                search.pid = pid;
                deferred.resolve(search);
            });

		});

		return deferred.promise;
	}
};

module.exports = Player;
<commit_msg>clearing up logic<commit_after>/***
*   Copyright 2014 Sean Wragg <seanwragg@gmail.com>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*	   http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/

var Database = require('./Database.js'),
	Q = require('q');

var Player = {
	locate: function(search) {
		var deferred = Q.defer();

		if (!search.name || !search.lid) {
			deferred.reject({
				status: 400
			});

			return deferred.promise;
		}

		var query = Database.format(
			'SELECT pid, uid FROM wol_players WHERE name = ? AND lid = ?', [search.name, search.lid]
		);

		Database.query(query, function(err, result) {
            if (result.length > 0) {
                search.pid = result[0].pid;
				search.uid = result[0].uid;
				search.exists = true; // player located
				return deferred.resolve(search);
            }

            if (search.create) {
                // create player
                var insert = {
                    name: search.name,
                    lid: search.lid,
                    ctime: Math.floor(new Date().getTime() / 1000)
                };

                if (search.uid) {
                    insert.uid = search.uid;
                }

                Database.insert('wol_players', insert, function(pid) {
                    search.pid = pid;
                    deferred.resolve(search);
                });

                return;
            }

            // return player not found
            return deferred.reject({
                status: 404
            });
		});

		return deferred.promise;
	}
};

module.exports = Player;
<|endoftext|>


<commit_before>import logger from 'redux-logger';
import path from 'path';
import { createStore as _createStore, applyMiddleware, compose } from 'redux';
import routing from './middleware/routing';

export default function createStore(reduxReactRouter, getRoutes, createHistory, customMiddleware, reducers, data) {
  const defaultMiddleware = [routing];
  const middleware = defaultMiddleware.concat(customMiddleware);

  if (__CLIENT__ && __LOGGER__) {
    middleware.push(logger);
  }

  let finalCreateStore;
  if (__DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) {
    const { persistState } = require('redux-devtools');
    const DevTools = require('../containers/DevTools/DevTools');
    finalCreateStore = compose(
      applyMiddleware(...middleware),
      window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
      persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
    )(_createStore);
  } else {
    finalCreateStore = applyMiddleware(...middleware)(_createStore);
  }

  finalCreateStore = reduxReactRouter({ getRoutes, createHistory })(finalCreateStore);

  const store = finalCreateStore(reducers, data);

  // if (__DEVELOPMENT__ && module.hot) {
  //   module.hot.accept(__REDUCER_INDEX__, () => {
  //   module.hot.accept('../../../../src/redux/modules/index', () => {
  //     store.replaceReducer(require(path.resolve(__REDUCER_INDEX__)));
  //     store.replaceReducer(require('../../../../src/redux/modules/index'));
  //   });
  // }

  return store;
}
<commit_msg>fix linting error<commit_after>import logger from 'redux-logger';
// import path from 'path';
import { createStore as _createStore, applyMiddleware, compose } from 'redux';
import routing from './middleware/routing';

export default function createStore(reduxReactRouter, getRoutes, createHistory, customMiddleware, reducers, data) {
  const defaultMiddleware = [routing];
  const middleware = defaultMiddleware.concat(customMiddleware);

  if (__CLIENT__ && __LOGGER__) {
    middleware.push(logger);
  }

  let finalCreateStore;
  if (__DEVELOPMENT__ && __CLIENT__ && __DEVTOOLS__) {
    const { persistState } = require('redux-devtools');
    const DevTools = require('../containers/DevTools/DevTools');
    finalCreateStore = compose(
      applyMiddleware(...middleware),
      window.devToolsExtension ? window.devToolsExtension() : DevTools.instrument(),
      persistState(window.location.href.match(/[?&]debug_session=([^&]+)\b/))
    )(_createStore);
  } else {
    finalCreateStore = applyMiddleware(...middleware)(_createStore);
  }

  finalCreateStore = reduxReactRouter({ getRoutes, createHistory })(finalCreateStore);

  const store = finalCreateStore(reducers, data);

  // if (__DEVELOPMENT__ && module.hot) {
  //   module.hot.accept(__REDUCER_INDEX__, () => {
  //   module.hot.accept('../../../../src/redux/modules/index', () => {
  //     store.replaceReducer(require(path.resolve(__REDUCER_INDEX__)));
  //     store.replaceReducer(require('../../../../src/redux/modules/index'));
  //   });
  // }

  return store;
}
<|endoftext|>


<commit_before>import {createNode, selectNodes, removeNode} from "./util/nodes.js";
import {Selection} from "./selection.js";

//Scene class
export function Scene () {
    this.node = createNode("svg", null); //Create the scene node
    this.node.setAttribute("width", "0px"); //Initialize scene width
    this.node.setAttribute("height", "0px"); //Initialize scene height
    //this.parent = null; //Parent node
}

//Scene prototype
Scene.prototype = {
    //Set the scene width
    "width": function (value) {
        return this.node.setAttribute("width", value);
    },
    //Set the scene height
    "height": function (value) {
        return this.node.setAttribute("height", value);
    },
    //Calculate the scene size
    "size": function () {
        return this.node.getBoundingClientRect();
    },
    //Mount the scene
    "mount": function (query) {
        let parent = selectNodes(query); //Select parent node
        if (parentNode.nodes.length > 0) {
            parentNode.nodes[0].appendChild(this.node); //Mount
        }
    },
    //Unmount the scene
    "unmount": function () {
        if (this.node.parentNode !== null) {
            return removeNode(this.node); //Remove node
        }
    },
    //Append a new element to the scene
    "append": function (name) {
        let element = createNode(name, this.node);
        this.node.appendChild(element); //Append the new element
        return new Selection([element], this.node); //Return a selection with the element
    }
};

//Create a new scene
export function createScene () {
    return new Scene();
}

//Check if the provided value is an instance of a scene
export function isScene (value) {
    return value instanceof Scene;
}

<commit_msg>Fixed minor bug mounting scene into a DOM node<commit_after>import {createNode, selectNodes, removeNode} from "./util/nodes.js";
import {Selection} from "./selection.js";

//Scene class
export function Scene () {
    this.node = createNode("svg", null); //Create the scene node
    this.node.setAttribute("width", "0px"); //Initialize scene width
    this.node.setAttribute("height", "0px"); //Initialize scene height
    //this.parent = null; //Parent node
}

//Scene prototype
Scene.prototype = {
    //Set the scene width
    "width": function (value) {
        return this.node.setAttribute("width", value);
    },
    //Set the scene height
    "height": function (value) {
        return this.node.setAttribute("height", value);
    },
    //Calculate the scene size
    "size": function () {
        return this.node.getBoundingClientRect();
    },
    //Mount the scene
    "mount": function (query) {
        let parent = selectNodes(query); //Select parent node
        if (parent.nodes.length > 0) {
            parent.nodes[0].appendChild(this.node); //Mount
        }
    },
    //Unmount the scene
    "unmount": function () {
        if (this.node.parentNode !== null) {
            return removeNode(this.node); //Remove node
        }
    },
    //Append a new element to the scene
    "append": function (name) {
        let element = createNode(name, this.node);
        this.node.appendChild(element); //Append the new element
        return new Selection([element], this.node); //Return a selection with the element
    }
};

//Create a new scene
export function createScene () {
    return new Scene();
}

//Check if the provided value is an instance of a scene
export function isScene (value) {
    return value instanceof Scene;
}

<|endoftext|>


<commit_before>/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
    /**
     * Represent plain text selection range.
     */
    CKEDITOR.plugins.add('textselection',
    {
        version: 1.01,
        init: function (editor) {
            // Corresponding text range of wysiwyg bookmark.
            var wysiwygBookmark;

            // Auto sync text selection with 'WYSIWYG' mode selection range.
            if (editor.config.syncSelection
                    && CKEDITOR.plugins.sourcearea) {
                editor.on('beforeModeUnload', function (evt) {
                    if (editor.mode === 'source') {
                        if (editor.mode === 'source' && !editor.plugins.codemirror) {
                            var range = editor.getTextSelection();

                            // Fly the range when create bookmark.
                            delete range.element;
                            range.createBookmark();
                            sourceBookmark = true;
                            evt.data = range.content;
                        }
                    }
                });
                editor.on('mode', function () {
                    if (editor.mode === 'wysiwyg' && sourceBookmark) {

                        editor.focus();
                        var doc = editor.document,
                            range = new CKEDITOR.dom.range(editor.document),
                            walker,
                            startNode,
                            endNode;

                        range.setStartAt(doc.getBody(), CKEDITOR.POSITION_AFTER_START);
                        range.setEndAt(doc.getBody(), CKEDITOR.POSITION_BEFORE_END);
                        walker = new CKEDITOR.dom.walker(range);
                        walker.type = CKEDITOR.NODE_COMMENT;
                        walker.evaluator = function (comment) {

                            var match = /cke_bookmark_\d+(\w)/.exec(comment.$.nodeValue);
                            if (match) {
                                if (match[1] === 'S') {
                                    startNode = comment;
                                } else if (match[1] === 'E') {
                                    endNode = comment;
                                    return false;
                                }
                            }
                        };
                        walker.lastForward();
                        range.setStartAfter(startNode);
                        range.setEndBefore(endNode);
                        range.select();
                        // Scroll into view for non-IE.
                        if (!CKEDITOR.env.ie || (CKEDITOR.env.ie && CKEDITOR.env.version === 9)) {
                            editor.getSelection().getStartElement().scrollIntoView(true);
                        } // Remove the comments node which are out of range.
                        startNode.remove();
                        endNode.remove();
                    }
                }, null, null, 10);

                editor.on('beforeGetModeData', function () {
                    if (editor.mode === 'wysiwyg') {
                        var sel = editor.getSelection(), range;
                        if (sel && (range = sel.getRanges()[0])) {
                            wysiwygBookmark = range.createBookmark(true);
                        }
                    }
                });
                // Build text range right after wysiwyg has unloaded.
                editor.on('afterModeUnload', function (evt) {
                    if (editor.mode === 'wysiwyg' && wysiwygBookmark) {
                        textRange = new CKEDITOR.dom.textRange(evt.data);
                        textRange.moveToBookmark(wysiwygBookmark);

                        evt.data = textRange.content;
                    }
                });
                editor.on('mode', function () {
                    if (editor.mode === 'source' && textRange) {
                        textRange.element = new CKEDITOR.dom.element(editor._.editable.$);
                        textRange.select();
                    }
                });
            }
        }
    });

    /**
     * Gets the current text selection from the editing area when in Source mode.
     * @returns {CKEDITOR.dom.textRange} Text range represent the caret positoins.
     * @example
     * var textSelection = CKEDITOR.instances.editor1.getTextSelection();
     * alert( textSelection.startOffset );
     * alert( textSelection.endOffset );
     */
    CKEDITOR.editor.prototype.getTextSelection = function () {
        return this._.editable && getTextSelection(this._.editable.$) || null;
    };

    /**
     * Returns the caret position of the specified textfield/textarea.
     * @param {HTMLTextArea|HTMLTextInput} element
     */
    function getTextSelection(element) {
        var startOffset, endOffset;

        if (!CKEDITOR.env.ie) {
            startOffset = element.selectionStart;
            endOffset = element.selectionEnd;
        } else {
            element.focus();

            // The current selection
            if (window.getSelection) {
                startOffset = element.selectionStart;
                endOffset = element.selectionEnd;
            } else {
                var range = document.selection.createRange(),
                    textLength = range.text.length;

                // Create a 'measuring' range to help calculate the start offset by
                // stretching it from start to current position.
                var measureRange = range.duplicate();
                measureRange.moveToElementText(element);
                measureRange.setEndPoint('EndToEnd', range);

                endOffset = measureRange.text.length;
                startOffset = endOffset - textLength;
            }
        }
        return new CKEDITOR.dom.textRange(
            new CKEDITOR.dom.element(element), startOffset, endOffset);
    }

    /**
     * Represent the selection range within a html textfield/textarea element,
     * or even a flyweight string content represent the text content.
     * @constructor
     * @param {CKEDITOR.dom.element|String} element
     * @param {Number} start
     * @param {Number} end
     */
    CKEDITOR.dom.textRange = function (element, start, end) {
        if (element instanceof CKEDITOR.dom.element
            && (element.is('textarea')
                || element.is('input') && element.getAttribute('type') == 'text')) {
            this.element = element;
            this.content = element.$.value;
        } else if (typeof element == 'string')
            this.content = element;
        else
            throw 'Unkown "element" type.';
        this.startOffset = start || 0;
        this.endOffset = end || 0;
    };

     /**
     * Changes the editing mode of this editor instance. (Override of the original function)
     *
     * **Note:** The mode switch could be asynchronous depending on the mode provider.
     * Use the `callback` to hook subsequent code.
     *
     *                // Switch to "source" view.
     *                CKEDITOR.instances.editor1.setMode( 'source' );
     *                // Switch to "wysiwyg" view and be notified on completion.
     *                CKEDITOR.instances.editor1.setMode( 'wysiwyg', function() { alert( 'wysiwyg mode loaded!' ); } );
     *
     * @param {String} [newMode] If not specified, the {@link CKEDITOR.config#startupMode} will be used.
     * @param {Function} [callback] Optional callback function which is invoked once the mode switch has succeeded.
     */
    CKEDITOR.editor.prototype.setMode = function (newMode, callback) {
        var editor = this;

        var modes = this._.modes;

        // Mode loading quickly fails.
        if (newMode == editor.mode || !modes || !modes[newMode])
            return;

        editor.fire('beforeSetMode', newMode);

        if (editor.mode) {
            var isDirty = editor.checkDirty();

            editor._.previousMode = editor.mode;

            editor.fire('beforeModeUnload');

            editor.fire('beforeGetModeData');
            var data = editor.getData();
            data = editor.fire('beforeModeUnload', data);
            data = editor.fire('afterModeUnload', data);

            // Detach the current editable.
            editor.editable(0);

            editor._.data = data;

            // Clear up the mode space.
            editor.ui.space('contents').setHtml('');

            editor.mode = '';
        }

        // Fire the mode handler.
        this._.modes[newMode](function () {
            // Set the current mode.
            editor.mode = newMode;

            if (isDirty !== undefined) {
                !isDirty && editor.resetDirty();
            }

            // Delay to avoid race conditions (setMode inside setMode).
            setTimeout(function () {
                editor.fire('mode');
                callback && callback.call(editor);
            }, 0);
        });
    };

    CKEDITOR.dom.textRange.prototype =
    {
        /**
         * Sets the text selection of the specified textfield/textarea.
         * @param {HTMLTextArea|HTMLTextInput} element
         * @param {CKEDITOR.dom.textRange} range
         */
        select: function() {

            var startOffset = this.startOffset,
                endOffset = this.endOffset,
                element = this.element.$;
            if (endOffset == undefined) {
                endOffset = startOffset;
            }

            if (CKEDITOR.env.ie && CKEDITOR.env.version == 9) {
                element.focus();
                element.selectionStart = startOffset;
                element.selectionEnd = startOffset;
                setTimeout(function() {
                    element.selectionStart = startOffset;
                    element.selectionEnd = endOffset;
                }, 20);

            } else {
                if (element.setSelectionRange) {
                    if (CKEDITOR.env.ie) {
                        element.focus();
                    }
                    element.setSelectionRange(startOffset, endOffset);
                    if (!CKEDITOR.env.ie) {
                        element.focus();
                    }
                } else if (element.createTextRange) {
                    element.focus();
                    var range = element.createTextRange();
                    range.collapse(true);
                    range.moveStart('character', startOffset);
                    range.moveEnd('character', endOffset - startOffset);
                    range.select();
                }
            }
        },

        /**
         * Select the range included within the bookmark text with the bookmark
         * text removed.
         * @param {Object} bookmark Exactly the one created by CKEDITOR.dom.range.createBookmark( true ).
         */
        moveToBookmark: function(bookmark) {
            var content = this.content;

            function removeBookmarkText(bookmarkId) {

                var bookmarkRegex = new RegExp('<span[^<]*?' + bookmarkId + '.*?/span>'),
                    offset;
                content = content.replace(bookmarkRegex, function(str, index) {
                    offset = index;
                    return '';
                });
                return offset;
            }

            this.startOffset = removeBookmarkText(bookmark.startNode);
            this.endOffset = removeBookmarkText(bookmark.endNode);
            this.content = content;
            this.updateElement();
        },

        /**
         * If startOffset/endOffset anchor inside element tag, start the range before/after the element
         */
        enlarge: function() {
            var htmlTagRegexp = /<[^>]+>/g;
            var content = this.content,
                start = this.startOffset,
                end = this.endOffset,
                match,
                tagStartIndex,
                tagEndIndex;

            // Adjust offset position on parsing result.
            while (match = htmlTagRegexp.exec(content)) {
                tagStartIndex = match.index;
                tagEndIndex = tagStartIndex + match[0].length;
                if (start > tagStartIndex && start < tagEndIndex)
                    start = tagStartIndex;
                if (end > tagStartIndex && end < tagEndIndex) {
                    end = tagEndIndex;
                    break;
                }
            }

            this.startOffset = start;
            this.endOffset = end;
        },

        createBookmark: function() {
            // Enlarge the range to avoid tag partial selection.
            this.enlarge();
            var content = this.content,
                start = this.startOffset,
                end = this.endOffset,
                id = CKEDITOR.tools.getNextNumber(),
                bookmarkTemplate = '';

            content = content.substring(0, start) + bookmarkTemplate.replace('%1', id + 'S')
                + content.substring(start, end) + bookmarkTemplate.replace('%1', id + 'E')
                + content.substring(end);

            this.content = content;
            this.updateElement();
        },

        updateElement: function() {
            if (this.element)
                this.element.$.value = this.content;
        }
    };

    var Browser = {
        Version: function() {
            var version = 999;
            if (navigator.appVersion.indexOf("MSIE") != -1)
                version = parseFloat(navigator.appVersion.split("MSIE")[1]);
            return version;
        }
    };

    // Seamless selection range across different modes.
    CKEDITOR.config.syncSelection = true;

    var textRange,sourceBookmark;<commit_msg>more fixes<commit_after>/*
Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
    /**
     * Represent plain text selection range.
     */
    CKEDITOR.plugins.add('textselection',
    {
        version: 1.01,
        init: function (editor) {
            // Corresponding text range of wysiwyg bookmark.
            var wysiwygBookmark;

            // Auto sync text selection with 'WYSIWYG' mode selection range.
            if (editor.config.syncSelection
                    && CKEDITOR.plugins.sourcearea) {
                editor.on('beforeModeUnload', function (evt) {
                    if (editor.mode === 'source') {
                        if (editor.mode === 'source' && !editor.plugins.codemirror) {
                            var range = editor.getTextSelection();

                            // Fly the range when create bookmark.
                            delete range.element;
                            range.createBookmark();
                            sourceBookmark = true;
                            evt.data = range.content;
                        }
                    }
                });
                editor.on('mode', function () {
                    if (editor.mode === 'wysiwyg' && sourceBookmark) {

                        editor.focus();
                        var doc = editor.document,
                            range = new CKEDITOR.dom.range(editor.document),
                            walker,
                            startNode,
                            endNode;

                        range.setStartAt(doc.getBody(), CKEDITOR.POSITION_AFTER_START);
                        range.setEndAt(doc.getBody(), CKEDITOR.POSITION_BEFORE_END);
                        walker = new CKEDITOR.dom.walker(range);
                       // walker.type = CKEDITOR.NODE_COMMENT;
                        walker.evaluator = function (comment) {
                           //

                            var match = /cke_bookmark_\d+(\w)/.exec(comment.$.nodeValue);
                            if (match) {

                                if (match[1] === 'S') {
                                    startNode = comment;
                                } else if (match[1] === 'E') {
                                    endNode = comment;
                                    return false;
                                }
                            }
                        };
                        walker.lastForward();
                        range.setStartAfter(startNode);
                        range.setEndBefore(endNode);
                        range.select();
                        // Scroll into view for non-IE.
                        // Scroll into view for non-IE.
                        if (!CKEDITOR.env.ie || (CKEDITOR.env.ie && CKEDITOR.env.version === 9)) {
                            editor.getSelection().getStartElement().scrollIntoView(true);
                        } // Remove the comments node which are out of range.
                        startNode.remove();
                        endNode.remove();
                    }
                }, null, null, 10);

                editor.on('beforeGetModeData', function () {
                    if (editor.mode === 'wysiwyg') {
                        if (CKEDITOR.env.gecko && !editor.focusManager.hasFocus) {
                            return;
                        }
                        var sel = editor.getSelection(), range;
                        if (sel && (range = sel.getRanges()[0])) {
                            wysiwygBookmark = range.createBookmark(true);
                        }
                    }
                });
                // Build text range right after wysiwyg has unloaded.
                editor.on('afterModeUnload', function (evt) {
                    if (editor.mode === 'wysiwyg' && wysiwygBookmark) {
                        textRange = new CKEDITOR.dom.textRange(evt.data);
                        textRange.moveToBookmark(wysiwygBookmark);

                        evt.data = textRange.content;
                    }
                });
                editor.on('mode', function () {
                    if (editor.mode === 'source' && textRange && !editor.plugins.codemirror) {
                        textRange.element = new CKEDITOR.dom.element(editor._.editable.$);
                        textRange.select();
                    }
                });
            }
        }
    });

    /**
     * Gets the current text selection from the editing area when in Source mode.
     * @returns {CKEDITOR.dom.textRange} Text range represent the caret positoins.
     * @example
     * var textSelection = CKEDITOR.instances.editor1.getTextSelection();
     * alert( textSelection.startOffset );
     * alert( textSelection.endOffset );
     */
    CKEDITOR.editor.prototype.getTextSelection = function () {
        return this._.editable && getTextSelection(this._.editable.$) || null;
    };

    /**
     * Returns the caret position of the specified textfield/textarea.
     * @param {HTMLTextArea|HTMLTextInput} element
     */
    function getTextSelection(element) {
        var startOffset, endOffset;

        if (!CKEDITOR.env.ie) {
            startOffset = element.selectionStart;
            endOffset = element.selectionEnd;
        } else {
            element.focus();

            // The current selection
            if (window.getSelection) {
                startOffset = element.selectionStart;
                endOffset = element.selectionEnd;
            } else {
                var range = document.selection.createRange(),
                    textLength = range.text.length;

                // Create a 'measuring' range to help calculate the start offset by
                // stretching it from start to current position.
                var measureRange = range.duplicate();
                measureRange.moveToElementText(element);
                measureRange.setEndPoint('EndToEnd', range);

                endOffset = measureRange.text.length;
                startOffset = endOffset - textLength;
            }
        }
        return new CKEDITOR.dom.textRange(
            new CKEDITOR.dom.element(element), startOffset, endOffset);
    }

    /**
     * Represent the selection range within a html textfield/textarea element,
     * or even a flyweight string content represent the text content.
     * @constructor
     * @param {CKEDITOR.dom.element|String} element
     * @param {Number} start
     * @param {Number} end
     */
    CKEDITOR.dom.textRange = function (element, start, end) {
        if (element instanceof CKEDITOR.dom.element
            && (element.is('textarea')
                || element.is('input') && element.getAttribute('type') == 'text')) {
            this.element = element;
            this.content = element.$.value;
        } else if (typeof element == 'string')
            this.content = element;
        else
            throw 'Unkown "element" type.';
        this.startOffset = start || 0;
        this.endOffset = end || 0;
    };

     /**
     * Changes the editing mode of this editor instance. (Override of the original function)
     *
     * **Note:** The mode switch could be asynchronous depending on the mode provider.
     * Use the `callback` to hook subsequent code.
     *
     *                // Switch to "source" view.
     *                CKEDITOR.instances.editor1.setMode( 'source' );
     *                // Switch to "wysiwyg" view and be notified on completion.
     *                CKEDITOR.instances.editor1.setMode( 'wysiwyg', function() { alert( 'wysiwyg mode loaded!' ); } );
     *
     * @param {String} [newMode] If not specified, the {@link CKEDITOR.config#startupMode} will be used.
     * @param {Function} [callback] Optional callback function which is invoked once the mode switch has succeeded.
     */
    CKEDITOR.editor.prototype.setMode = function (newMode, callback) {
        var editor = this;

        var modes = this._.modes;

        // Mode loading quickly fails.
        if (newMode == editor.mode || !modes || !modes[newMode])
            return;

        editor.fire('beforeSetMode', newMode);

        if (editor.mode) {
            var isDirty = editor.checkDirty();

            editor._.previousMode = editor.mode;

            editor.fire('beforeModeUnload');

            editor.fire('beforeGetModeData');
            var data = editor.getData();

            data = editor.fire('beforeModeUnload', data);
            data = editor.fire('afterModeUnload', data);

            // Detach the current editable.
            editor.editable(0);

            editor._.data = data;

            // Clear up the mode space.
            editor.ui.space('contents').setHtml('');

            editor.mode = '';
        }

        // Fire the mode handler.
        this._.modes[newMode](function () {
            // Set the current mode.
            editor.mode = newMode;

            if (isDirty !== undefined) {
                !isDirty && editor.resetDirty();
            }

            // Delay to avoid race conditions (setMode inside setMode).
            setTimeout(function () {
                editor.fire('mode');
                callback && callback.call(editor);
            }, 0);
        });
    };

    CKEDITOR.dom.textRange.prototype =
    {
        /**
         * Sets the text selection of the specified textfield/textarea.
         * @param {HTMLTextArea|HTMLTextInput} element
         * @param {CKEDITOR.dom.textRange} range
         */
        select: function() {

            var startOffset = this.startOffset,
                endOffset = this.endOffset,
                element = this.element.$;
            if (endOffset == undefined) {
                endOffset = startOffset;
            }

            if (CKEDITOR.env.ie && CKEDITOR.env.version == 9) {
                element.focus();
                element.selectionStart = startOffset;
                element.selectionEnd = startOffset;
                setTimeout(function() {
                    element.selectionStart = startOffset;
                    element.selectionEnd = endOffset;
                }, 20);

            } else {
                if (element.setSelectionRange) {
                    if (CKEDITOR.env.ie) {
                        element.focus();
                    }
                    element.setSelectionRange(startOffset, endOffset);
                    if (!CKEDITOR.env.ie) {
                        element.focus();
                    }
                } else if (element.createTextRange) {
                    element.focus();
                    var range = element.createTextRange();
                    range.collapse(true);
                    range.moveStart('character', startOffset);
                    range.moveEnd('character', endOffset - startOffset);
                    range.select();
                }
            }
        },

        /**
         * Select the range included within the bookmark text with the bookmark
         * text removed.
         * @param {Object} bookmark Exactly the one created by CKEDITOR.dom.range.createBookmark( true ).
         */
        moveToBookmark: function(bookmark) {
            var content = this.content;

            function removeBookmarkText(bookmarkId) {

                var bookmarkRegex = new RegExp('<span[^<]*?' + bookmarkId + '.*?/span>'),
                    offset;
                content = content.replace(bookmarkRegex, function(str, index) {
                    offset = index;
                    return '';
                });
                return offset;
            }

            this.startOffset = removeBookmarkText(bookmark.startNode);
            this.endOffset = removeBookmarkText(bookmark.endNode);
            this.content = content;
            this.updateElement();
        },

        /**
         * If startOffset/endOffset anchor inside element tag, start the range before/after the element
         */
        enlarge: function() {
            var htmlTagRegexp = /<[^>]+>/g;
            var content = this.content,
                start = this.startOffset,
                end = this.endOffset,
                match,
                tagStartIndex,
                tagEndIndex;

            // Adjust offset position on parsing result.
            while (match = htmlTagRegexp.exec(content)) {
                tagStartIndex = match.index;
                tagEndIndex = tagStartIndex + match[0].length;
                if (start > tagStartIndex && start < tagEndIndex)
                    start = tagStartIndex;
                if (end > tagStartIndex && end < tagEndIndex) {
                    end = tagEndIndex;
                    break;
                }
            }

            this.startOffset = start;
            this.endOffset = end;
        },

        createBookmark: function() {
            // Enlarge the range to avoid tag partial selection.
            this.enlarge();
            var content = this.content,
                start = this.startOffset,
                end = this.endOffset,
                id = CKEDITOR.tools.getNextNumber(),
                bookmarkTemplate = '';

            content = content.substring(0, start) + bookmarkTemplate.replace('%1', id + 'S')
                + content.substring(start, end) + bookmarkTemplate.replace('%1', id + 'E')
                + content.substring(end);

            this.content = content;
            this.updateElement();
        },

        updateElement: function() {
            if (this.element)
                this.element.$.value = this.content;
        }
    };

    var Browser = {
        Version: function() {
            var version = 999;
            if (navigator.appVersion.indexOf("MSIE") != -1)
                version = parseFloat(navigator.appVersion.split("MSIE")[1]);
            return version;
        }
    };

    // Seamless selection range across different modes.
    CKEDITOR.config.syncSelection = true;

    var textRange,sourceBookmark;<|endoftext|>


<commit_before>/*eslint-disable object-shorthand*/
const colors = {
  primary: "#f9c300",
  secondary: "black",
  tertiary: "white"
};

const fonts = {
  primary: "Open Sans Condensed",
  secondary: "Lobster Two",
  tertiary: "monospace"
};

module.exports = {
  colors: colors,
  fonts: fonts,
  global: {
    body: {
      background: colors.primary,
      fontFamily: fonts.primary,
      fontWeight: "normal",
      fontSize: "2em",
      color: colors.secondary,
      overflow: "hidden"
    },
    "html, body": {
      height: "100%"
    },
    "*": {
      boxSizing: "border-box"
    }
  },
  progress: {
    pacman: {
      container: {
        position: "absolute",
        bottom: "5px",
        left: "50%",
        transition: "all 1s ease-in-out 0.2s",
        zIndex: 1000
      },
      pacman: {
        position: "absolute",
        transition: "left 0.3s ease-in-out 0.2s",
        width: "20px",
        height: "20px",
        transform: "translate(-5px, -5px)"
      },
      pacmanTop: {
        position: "absolute",
        content: " ",
        width: "20px",
        height: "10px",
        borderTopLeftRadius: "10px",
        borderTopRightRadius: "10px",
        background: colors.tertiary
      },
      pacmanBottom: {
        position: "absolute",
        content: " ",
        width: "20px",
        height: "10px",
        borderBottomLeftRadius: "10px",
        borderBottomRightRadius: "10px",
        background: colors.tertiary,
        top: "10px"
      },
      point: {
        position: "absolute",
        float: "left",
        background: "transparent",
        width: "10px",
        height: "10px",
        borderWidth: 2,
        borderStyle: "solid",
        borderColor: colors.tertiary,
        borderRadius: "50%",
        transition: "all 0.01s ease-out 0.4s"
      }
    },
    bar: {
      container: {
        position: "absolute",
        height: "10px",
        width: "100%",
        bottom: 0,
        left: 0,
        transition: "all 1s ease-in-out 0.2s",
        zIndex: 1000
      },
      bar: {
        height: "100%",
        background: colors.tertiary,
        transition: "all 0.3s ease-out"
      }
    },
    number: {
      container: {
        position: "absolute",
        bottom: 10,
        right: 10,
        zIndex: 1000,
        color: colors.tertiary
      }
    }
  },
  components: {
    blockquote: {
      textAlign: "left",
      position: "relative",
      display: "inline-block"
    },
    quote: {
      borderLeft: "1px solid " + colors.primary,
      paddingLeft: 40,
      display: "block",
      color: colors.primary,
      fontSize: "4.9em",
      lineHeight: 1,
      fontWeight: "bold"
    },
    cite: {
      color: colors.tertiary,
      display: "block",
      clear: "left",
      fontSize: "2em",
      marginTop: "1em"
    },
    content: {
      margin: "0 auto",
      textAlign: "center"
    },
    codePane: {
      pre: {
        margin: "auto",
        fontSize: "1em",
        fontWeight: "normal",
        fontFamily: fonts.tertiary,
        minWidth: "100%",
        maxWidth: 800
      },
      code: {
        textAlign: "left",
        padding: 20,
        fontWeight: "normal"
      }
    },
    code: {
      color: "black",
      fontSize: "2.66em",
      fontFamily: fonts.tertiary,
      margin: "0.25em auto",
      backgroundColor: "rgba(0,0,0,0.15)",
      padding: "0 10px",
      borderRadius: 3
    },
    heading: {
      h1: {
        color: colors.tertiary,
        fontSize: "7.05em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: 0,
        zoom: 1
      },
      h2: {
        color: colors.secondary,
        fontSize: "5.88em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: 0
      },
      h3: {
        color: "black",
        fontSize: "4.9em",
        fontFamily: fonts.secondary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h4: {
        color: "black",
        fontSize: "3.82em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h5: {
        color: "black",
        fontSize: "3.19em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h6: {
        color: "black",
        fontSize: "2.66em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      }
    },
    image: {
      display: "block",
      margin: "0.5em auto"
    },
    link: {
      textDecoration: "none"
    },
    listItem: {
      fontSize: "2.66em"
    },
    list: {
      textAlign: "left",
      listStylePosition: "inside",
      padding: 0
    },
    s: {
      strikethrough: {}
    },
    text: {
      color: "black",
      fontSize: "2.66em",
      fontFamily: fonts.primary,
      margin: "0.25em auto"
    }
  }
};
<commit_msg>Update color scheme<commit_after>/*eslint-disable object-shorthand*/
const colors = {
  primary: "#cb3837",
  secondary: "white",
  tertiary: "#37cacb"
};

const fonts = {
  primary: "Open Sans Condensed",
  secondary: "Lobster Two",
  tertiary: "monospace"
};

module.exports = {
  colors: colors,
  fonts: fonts,
  global: {
    body: {
      background: colors.primary,
      fontFamily: fonts.primary,
      fontWeight: "normal",
      fontSize: "2em",
      color: colors.secondary,
      overflow: "hidden"
    },
    "html, body": {
      height: "100%"
    },
    "*": {
      boxSizing: "border-box"
    }
  },
  progress: {
    pacman: {
      container: {
        position: "absolute",
        bottom: "5px",
        left: "50%",
        transition: "all 1s ease-in-out 0.2s",
        zIndex: 1000
      },
      pacman: {
        position: "absolute",
        transition: "left 0.3s ease-in-out 0.2s",
        width: "20px",
        height: "20px",
        transform: "translate(-5px, -5px)"
      },
      pacmanTop: {
        position: "absolute",
        content: " ",
        width: "20px",
        height: "10px",
        borderTopLeftRadius: "10px",
        borderTopRightRadius: "10px",
        background: colors.tertiary
      },
      pacmanBottom: {
        position: "absolute",
        content: " ",
        width: "20px",
        height: "10px",
        borderBottomLeftRadius: "10px",
        borderBottomRightRadius: "10px",
        background: colors.tertiary,
        top: "10px"
      },
      point: {
        position: "absolute",
        float: "left",
        background: "transparent",
        width: "10px",
        height: "10px",
        borderWidth: 2,
        borderStyle: "solid",
        borderColor: colors.tertiary,
        borderRadius: "50%",
        transition: "all 0.01s ease-out 0.4s"
      }
    },
    bar: {
      container: {
        position: "absolute",
        height: "10px",
        width: "100%",
        bottom: 0,
        left: 0,
        transition: "all 1s ease-in-out 0.2s",
        zIndex: 1000
      },
      bar: {
        height: "100%",
        background: colors.tertiary,
        transition: "all 0.3s ease-out"
      }
    },
    number: {
      container: {
        position: "absolute",
        bottom: 10,
        right: 10,
        zIndex: 1000,
        color: colors.tertiary
      }
    }
  },
  components: {
    blockquote: {
      textAlign: "left",
      position: "relative",
      display: "inline-block"
    },
    quote: {
      borderLeft: "1px solid " + colors.primary,
      paddingLeft: 40,
      display: "block",
      color: colors.primary,
      fontSize: "4.9em",
      lineHeight: 1,
      fontWeight: "bold"
    },
    cite: {
      color: colors.tertiary,
      display: "block",
      clear: "left",
      fontSize: "2em",
      marginTop: "1em"
    },
    content: {
      margin: "0 auto",
      textAlign: "center"
    },
    codePane: {
      pre: {
        margin: "auto",
        fontSize: "1em",
        fontWeight: "normal",
        fontFamily: fonts.tertiary,
        minWidth: "100%",
        maxWidth: 800
      },
      code: {
        textAlign: "left",
        padding: 20,
        fontWeight: "normal"
      }
    },
    code: {
      color: "black",
      fontSize: "2.66em",
      fontFamily: fonts.tertiary,
      margin: "0.25em auto",
      backgroundColor: "rgba(0,0,0,0.15)",
      padding: "0 10px",
      borderRadius: 3
    },
    heading: {
      h1: {
        color: colors.tertiary,
        fontSize: "7.05em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: 0,
        zoom: 1
      },
      h2: {
        color: colors.secondary,
        fontSize: "5.88em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: 0
      },
      h3: {
        color: colors.secondary,
        fontSize: "4.9em",
        fontFamily: fonts.secondary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h4: {
        color: colors.secondary,
        fontSize: "3.82em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h5: {
        color: colors.secondary,
        fontSize: "3.19em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      },
      h6: {
        color: colors.secondary,
        fontSize: "2.66em",
        fontFamily: fonts.primary,
        lineHeight: 1,
        fontWeight: "bold",
        margin: "0.5em auto"
      }
    },
    image: {
      display: "block",
      margin: "0.5em auto"
    },
    link: {
      textDecoration: "none"
    },
    listItem: {
      fontSize: "2.66em"
    },
    list: {
      textAlign: "left",
      listStylePosition: "inside",
      padding: 0
    },
    s: {
      strikethrough: {}
    },
    text: {
      color: "white",
      fontSize: "2.66em",
      fontFamily: fonts.primary,
      margin: "0.25em auto"
    }
  }
};
<|endoftext|>


<commit_before>var _ = Npm.require('lodash');
var Future = Npm.require('fibers/future');
var sass = Npm.require('node-sass');

Plugin.registerSourceHandlers = function(extensions, options, handler) {
	_.each(extensions, function(extension) {
		Plugin.registerSourceHandler(extension, options, handler);
	});
};

Plugin.registerSourceHandlers(['sass', 'scss'], {archMatching: 'web'}, function(compileStep) {
	var source = compileStep.read().toString('utf8');
	console.log("Compiling file:", compileStep.inputPath);
	var future = new Future();

	try {
		sass.render({
			file: compileStep.fullInputPath,
			sourceMap: true,
			omitSourceMapUrl: true,
			outFile: "file.css", // required for source maps in node-sass, it's removed below
			success: function(result) {
				future.return(result);
			},
			error: function(e) {
				future.throw(e);
			}
		});

		var result = future.wait();
		console.log("Result:", result);

		var sourceMap;
		if (result.map) {
			sourceMap = JSON.parse(result.map);
			delete sourceMap.file;
			sourceMap.sources = [compileStep.inputPath];
			sourceMap.sourcesContent = [source];
			console.log("Source map:", sourceMap);
			sourceMap = JSON.stringify(sourceMap);
		}

		compileStep.addStylesheet({
			path: compileStep.inputPath + ".css",
			data: result.css,
			sourceMap: sourceMap
		});
	} catch (e) {
		compileStep.error({
			message: "Sass compiler error: " + e.message,
			sourcePath: e.file || compileStep.inputPath,
			line: e.line,
			column: e.column
		});
	}
});
<commit_msg>Don't compile partials<commit_after>var _ = Npm.require('lodash');
var Future = Npm.require('fibers/future');
var sass = Npm.require('node-sass');
var path = Npm.require('path');

Plugin.registerSourceHandlers = function(extensions, options, handler) {
	_.each(extensions, function(extension) {
		Plugin.registerSourceHandler(extension, options, handler);
	});
};

Plugin.registerSourceHandlers(['sass', 'scss'], {archMatching: 'web'}, function(compileStep) {
	if (path.basename(compileStep.inputPath)[0] === '_') {
		console.log("Compiling partial:", compileStep.inputPath);
		return;
	}

	console.log("Compiling file:", compileStep.inputPath);
	var source = compileStep.read().toString('utf8');
	var future = new Future();

	try {
		sass.render({
			file: compileStep.fullInputPath,
			sourceMap: true,
			omitSourceMapUrl: true,
			outFile: "file.css", // required for source maps in node-sass, it's removed below
			success: function(result) {
				future.return(result);
			},
			error: function(e) {
				future.throw(e);
			}
		});

		var result = future.wait();
		console.log("Result:", result);

		var sourceMap;
		if (result.map) {
			sourceMap = JSON.parse(result.map);
			delete sourceMap.file;
			sourceMap.sources = [compileStep.inputPath];
			sourceMap.sourcesContent = [source];
			console.log("Source map:", sourceMap);
			sourceMap = JSON.stringify(sourceMap);
		}

		compileStep.addStylesheet({
			path: compileStep.inputPath + ".css",
			data: result.css,
			sourceMap: sourceMap
		});
	} catch (e) {
		compileStep.error({
			message: "Sass compiler error: " + e.message,
			sourcePath: e.file || compileStep.inputPath,
			line: e.line,
			column: e.column
		});
	}
});
<|endoftext|>


<commit_before>const $ = require('dekko');

$('lib')
  .isDirectory()
  .hasFile('index.js')
  .hasFile('index.d.ts');

$('lib/*')
  .filter((filename) => {
    return !filename.endsWith('index.js') &&
      !filename.endsWith('index.d.ts');
  })
  .isDirectory()
  .filter((filename) => {
    return !filename.endsWith('style') &&
      !filename.endsWith('_util');
  })
  .hasFile('index.js')
  .hasFile('index.d.ts')
  .hasDirectory('style');

$('lib/*/style')
  .hasFile('css.js')
  .hasFile('index.js')
  .hasFile('v2-compatible-reset.less.css');

// eslint-disable-next-line
console.log('`lib` directory is valid.');

<commit_msg>Fix typo<commit_after>const $ = require('dekko');

$('lib')
  .isDirectory()
  .hasFile('index.js')
  .hasFile('index.d.ts');

$('lib/*')
  .filter((filename) => {
    return !filename.endsWith('index.js') &&
      !filename.endsWith('index.d.ts');
  })
  .isDirectory()
  .filter((filename) => {
    return !filename.endsWith('style') &&
      !filename.endsWith('_util');
  })
  .hasFile('index.js')
  .hasFile('index.d.ts')
  .hasDirectory('style');

$('lib/*/style')
  .hasFile('css.js')
  .hasFile('index.js')
  .hasFile('v2-compatible-reset.css');

// eslint-disable-next-line
console.log('`lib` directory is valid.');

<|endoftext|>


<commit_before>require([
    'chai',
    'jquery',
    'underscore',
    'tests/utils',
    'text!static/diffDataParent/parse.xml',
    'text!static/diffDataParent/sibling-as-child.xml'
], function (
    chai, $,
    _,
    util,
    PARSE_XML,
    SIBLING_AS_CHILD
) {
    var assert = chai.assert,
        call = util.call;

    describe("Control elements with different data parents", function() {
        before(function (done) {
            util.init({
                javaRosa: {langs: ['en']},
                core: {onReady: done}
            });
        });

        it("should not allow repeat group children to have other data parents", function() {
            util.loadXML("");
            var repeat = util.addQuestion("Repeat", 'repeat1'),
                text1 = util.addQuestion.bind({prevId: repeat.p.nodeID})("Text", 'text1'),
                text2 = util.addQuestion.bind({prevId: repeat.p.nodeID})("Text", 'text2');

            text2.p.dataParent = '/data';
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert(!util.isTreeNodeValid(text2), "text2 should not be valid");
        });

        it("should not allow a data parent to be an input", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                text2 = util.addQuestion("Text", 'text2');

            text2.p.dataParent = '/data/text1';
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert(!util.isTreeNodeValid(text2), "text2 should not be valid");
        });

        it("should keep the same data parent after a move", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                text2 = util.addQuestion("Text", 'text2'),
                form = call("getData").core.form;

            util.addQuestion("Group", 'group1');
            text2.p.dataParent = '/data/group1';

            form.moveMug(text2, text1, 'before');

            assert.equal(text2.p.dataParent, '/data/group1');
        });

        it("should update data tree after a change to data parent", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                group1 = util.addQuestion("Group", 'group1'),
                group2 = util.addQuestion.bind({prevId: text1.p.nodeID})("Group", 'group2'),
                form = call("getData").core.form;

            text1.p.dataParent = '/data/group1';
            assert.equal(text1.p.dataParent, "/data/group1");
            form.moveMug(group1, group2, 'into');
            assert.equal(text1.p.dataParent, "/data/group2/group1");
        });

        it("should clear the data parent when moving to a repeat group", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1');
            util.addQuestion("Group", 'group1');
            var repeat1= util.addQuestion.bind({prevId: text1.p.nodeID})("Repeat", 'repeat1'),
                form = call("getData").core.form;
            text1.p.dataParent = '/data/group1';
            form.moveMug(text1, repeat1, 'into');
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert.isUndefined(text1.p.dataParent);
        });

        it("should have proper data parent after change through UI", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                form = call("getData").core.form;

            util.addQuestion("Group", 'group1');

            text1.p.dataParent = '/data/group1';
            util.loadXML(call("createXML"));
            assert.equal(text1.p.dataParent, '/data/group1');
            util.assertTreeState(form.dataTree(),
                "group1",
                "  text1"
            );
        });

        it("should parse and write XML to have the same order", function() {
            util.loadXML(PARSE_XML);
            util.assertXmlEqual(call("createXML"), PARSE_XML);
        });

        it("should have proper data parent after being loaded from xml", function() {
            util.loadXML(PARSE_XML);
            var question1 = util.getMug("/data/question4/question1");
            assert.equal(question1.p.dataParent, "/data/question4");
            util.assertJSTreeState(
                "question1",
                "question4",
                "  question3"
            );
        });

        it("should use the control parent when inserting after a mug with different data parent", function() {
            util.loadXML("");
            var form = call("getData").core.form,
                text1 = util.addQuestion("Text", 'text1');
            util.addQuestion("Group", 'group');
            util.addQuestion("Text", 'text2');

            text1.p.dataParent = '/data/group';
            util.addQuestion.bind({prevId: text1.p.nodeID})("Text", 'text3');
            // questions with alternate dataParent always come last in the data tree
            util.assertTreeState(form.dataTree(),
                "text3",
                "group",
                "  text2",
                "  text1"
            );
            util.assertJSTreeState(
                "text1",
                "text3",
                "group",
                "  text2"
            );
        });

        it("should properly load group before sibling/child", function() {
            util.loadXML(SIBLING_AS_CHILD);
            var text = util.getMug("/data/text");
            assert.equal(text.p.dataParent, "/data");
            util.assertJSTreeState(
                "group",
                "  text"
            );
            util.assertXmlEqual(call("createXML"), SIBLING_AS_CHILD);
        });
    });
});
<commit_msg>Change test name<commit_after>require([
    'chai',
    'jquery',
    'underscore',
    'tests/utils',
    'text!static/diffDataParent/parse.xml',
    'text!static/diffDataParent/sibling-as-child.xml'
], function (
    chai, $,
    _,
    util,
    PARSE_XML,
    SIBLING_AS_CHILD
) {
    var assert = chai.assert,
        call = util.call;

    describe("Control elements with different data parents", function() {
        before(function (done) {
            util.init({
                javaRosa: {langs: ['en']},
                core: {onReady: done}
            });
        });

        it("should not allow repeat group children to have other data parents", function() {
            util.loadXML("");
            var repeat = util.addQuestion("Repeat", 'repeat1'),
                text1 = util.addQuestion.bind({prevId: repeat.p.nodeID})("Text", 'text1'),
                text2 = util.addQuestion.bind({prevId: repeat.p.nodeID})("Text", 'text2');

            text2.p.dataParent = '/data';
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert(!util.isTreeNodeValid(text2), "text2 should not be valid");
        });

        it("should not allow a data parent to be an input", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                text2 = util.addQuestion("Text", 'text2');

            text2.p.dataParent = '/data/text1';
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert(!util.isTreeNodeValid(text2), "text2 should not be valid");
        });

        it("should keep the same data parent after a move", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                text2 = util.addQuestion("Text", 'text2'),
                form = call("getData").core.form;

            util.addQuestion("Group", 'group1');
            text2.p.dataParent = '/data/group1';

            form.moveMug(text2, text1, 'before');

            assert.equal(text2.p.dataParent, '/data/group1');
        });

        it("should update data tree after a change to data parent", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                group1 = util.addQuestion("Group", 'group1'),
                group2 = util.addQuestion.bind({prevId: text1.p.nodeID})("Group", 'group2'),
                form = call("getData").core.form;

            text1.p.dataParent = '/data/group1';
            assert.equal(text1.p.dataParent, "/data/group1");
            form.moveMug(group1, group2, 'into');
            assert.equal(text1.p.dataParent, "/data/group2/group1");
        });

        it("should clear the data parent when moving to a repeat group", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1');
            util.addQuestion("Group", 'group1');
            var repeat1= util.addQuestion.bind({prevId: text1.p.nodeID})("Repeat", 'repeat1'),
                form = call("getData").core.form;
            text1.p.dataParent = '/data/group1';
            form.moveMug(text1, repeat1, 'into');
            assert(util.isTreeNodeValid(text1), "text1 should be valid");
            assert.isUndefined(text1.p.dataParent);
        });

        it("should have proper data parent after reloading the form", function() {
            util.loadXML("");
            var text1 = util.addQuestion("Text", 'text1'),
                form = call("getData").core.form;

            util.addQuestion("Group", 'group1');

            text1.p.dataParent = '/data/group1';
            util.loadXML(call("createXML"));
            assert.equal(text1.p.dataParent, '/data/group1');
            util.assertTreeState(form.dataTree(),
                "group1",
                "  text1"
            );
        });

        it("should parse and write XML to have the same order", function() {
            util.loadXML(PARSE_XML);
            util.assertXmlEqual(call("createXML"), PARSE_XML);
        });

        it("should have proper data parent after being loaded from xml", function() {
            util.loadXML(PARSE_XML);
            var question1 = util.getMug("/data/question4/question1");
            assert.equal(question1.p.dataParent, "/data/question4");
            util.assertJSTreeState(
                "question1",
                "question4",
                "  question3"
            );
        });

        it("should use the control parent when inserting after a mug with different data parent", function() {
            util.loadXML("");
            var form = call("getData").core.form,
                text1 = util.addQuestion("Text", 'text1');
            util.addQuestion("Group", 'group');
            util.addQuestion("Text", 'text2');

            text1.p.dataParent = '/data/group';
            util.addQuestion.bind({prevId: text1.p.nodeID})("Text", 'text3');
            // questions with alternate dataParent always come last in the data tree
            util.assertTreeState(form.dataTree(),
                "text3",
                "group",
                "  text2",
                "  text1"
            );
            util.assertJSTreeState(
                "text1",
                "text3",
                "group",
                "  text2"
            );
        });

        it("should properly load group before sibling/child", function() {
            util.loadXML(SIBLING_AS_CHILD);
            var text = util.getMug("/data/text");
            assert.equal(text.p.dataParent, "/data");
            util.assertJSTreeState(
                "group",
                "  text"
            );
            util.assertXmlEqual(call("createXML"), SIBLING_AS_CHILD);
        });
    });
});
<|endoftext|>


<commit_before>// Licensed under the Apache License, Version 2.0 (the “License”); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
// @flow

import { Component } from 'react'

export type ResolvedFlair = {|
  flair?:string,
  presenter?:Component<*>
|}

const NO_FLAIR_RESOLVED = {
  flair: undefined,
  presenter: undefined
}

const EXTRACTOR = /\s*(\w+(?:\s+\w+)*)?(?:\s*!\s*(\w+))?\s*/

export function resolveFlair(resolvedTheme, pattern):ResolvedFlair {
  if (!resolvedTheme.componentTheme)
    return NO_FLAIR_RESOLVED

  const COMPONENT_THEME = resolvedTheme.componentTheme
  const DEFAULT_FLAIR = COMPONENT_THEME.flairs.default
  const DEFAULT_PRESENTER = COMPONENT_THEME.presenters.default

  let flair = COMPONENT_THEME.flairs[DEFAULT_FLAIR]
  let presenter = COMPONENT_THEME.presenters[DEFAULT_PRESENTER]

  if (!pattern)
    return { flair, presenter }

  const MATCHES = EXTRACTOR.exec(pattern)
  if (!MATCHES)
    return { flair, presenter }

  const TARGET_FLAIRS = MATCHES[1]
  const TARGET_PRESENTER = MATCHES[2]

  if (TARGET_PRESENTER)
    presenter = COMPONENT_THEME.presenters[TARGET_PRESENTER]

  if (!TARGET_FLAIRS)
    return { flair, presenter }

  flair = ''
  for (const TARGET of TARGET_FLAIRS.split(/\s+/)) {
    const EXTRACTED = COMPONENT_THEME.flairs[TARGET]
    if (!EXTRACTED)
      continue
    flair += ` ${Array.isArray(EXTRACTED) ? EXTRACTED.join(' ') : EXTRACTED}`
  }

  // Remove unnecessary spaces.
  flair = flair.replace(/\s+/g, ' ').trim()

  return { flair, presenter }
}

export default resolveFlair
<commit_msg>Make resolveFlair tests pass and add type<commit_after>// Licensed under the Apache License, Version 2.0 (the “License”); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an “AS IS” BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
// @flow

import type { ResolvedTheme } from '../resolveTheme'
import { Component } from 'react'

export type ResolvedFlair = {|
  flair?:string,
  presenter?:Component<*>
|}

/**
 * Remove unnecessary spaces in resolved flairs.
 */
function normalizeFlair(resolvedFlair:ResolvedFlair):ResolvedFlair {
  let { flair, presenter } = resolvedFlair
  return {
    flair: flair.replace(/\s+/g, ' ').trim(),
    presenter
  }
}

const EXTRACTOR = /\s*(\w+(?:\s+\w+)*)?(?:\s*!\s*(\w+))?\s*/

/**
 * Returns the resulting flair and presenter from the resolved theme using the
 * specified pattern.
 *
 * @param pattern
 * A pattern
 */
export function resolveFlair(resolvedTheme:ResolvedTheme, pattern:string):ResolvedFlair {
  const COMPONENT_THEME = resolvedTheme?.componentTheme
  if (!COMPONENT_THEME)
    return undefined

  const FLAIRS = COMPONENT_THEME.flairs
  const PRESENTERS = COMPONENT_THEME.presenters

  if (!FLAIRS && !PRESENTERS)
    return undefined

  const DEFAULT_FLAIR = FLAIRS[FLAIRS.default] || {}
  const DEFAULT_PRESENTER = PRESENTERS[PRESENTERS.default] || {}

  let flair = DEFAULT_FLAIR
  let presenter = DEFAULT_PRESENTER

  if (!pattern)
    return normalizeFlair({ flair, presenter })

  // Extract the flair and presenter portion from the pattern passed.
  const MATCHES = EXTRACTOR.exec(pattern)
  if (!MATCHES)
    return normalizeFlair({ flair, presenter })

  const TARGET_FLAIRS = MATCHES[1]
  const TARGET_PRESENTER = MATCHES[2]

  // If there's a custom presenter, try to extract it.
  if (TARGET_PRESENTER)
    presenter = PRESENTERS[TARGET_PRESENTER] || DEFAULT_PRESENTER

  // There are no custom flairs.
  if (!TARGET_FLAIRS)
    return normalizeFlair({ flair, presenter })

  // Extract each flair from the component theme and concatenate into a string.
  flair = ''
  for (const TARGET of TARGET_FLAIRS.split(/\s+/)) {
    const EXTRACTED = FLAIRS[TARGET]
    if (!EXTRACTED)
      continue
    flair += ` ${Array.isArray(EXTRACTED) ? EXTRACTED.join(' ') : EXTRACTED}`
  }

  return normalizeFlair({ flair, presenter })
}

export default resolveFlair
<|endoftext|>


<commit_before>var assertAST = require("./lib/chai.assert.ast").equalAstToFn;
var docPower = require("../lib/doc-power");
var assert = require('chai').assert;
var escodegen = require("escodegen");
var vm = require('vm');
var path = require("path");
describe("docpower", function () {
    it("When expression + comment", function () {
        var code = "var a = 1;" +
            "a; // > 1";
        var resultAST = docPower.convertFromCodeToTree(code);
        assertAST(resultAST, function () {
            var a = 1;
            assert(a === 1);
        });
    });
    it("When CallExpression ", function () {
        var code = "var a = function(){return 1;};" +
            "a(); // > 1";
        var resultAST = docPower.convertFromCodeToTree(code);
        assertAST(resultAST, function () {
            var a = function () {
                return 1;
            };
            assert(a() === 1);
        });
    });
    describe("#regexpExecuted", function () {
        beforeEach(function () {
            docPower.regexpExecuted(/\s+==>\s(.*?)$/);
        });
        afterEach(function () {
            // reset
            docPower.regexpExecuted(/\s+>\s+(.*)$/);
        });
        it("accept regexp comment ", function () {
            var code = "var a = 1;" +
                "a; // ==> 1";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                var a = 1;
                assert(a === 1);
            });
        });
    });
    describe("#runDocTest", function () {
        context("when success test", function () {
            it("should not result message", function () {
                var code = "var a = 1;\n" +
                    "a; // > 1";
                var resultMessage = docPower.runDocTest(code);
                assert.isUndefined(resultMessage);
            });
        });
        context("when fail test", function () {
            it("should output message", function () {
                var code = "var a = 'test';\n" +
                    "a; // > 'not match'\n";
                var resultMessage = docPower.runDocTest(code);
                assert.isNotNull(resultMessage);
            });
        });
    });
});
<commit_msg>add BlockComment test<commit_after>var assertAST = require("./lib/chai.assert.ast").equalAstToFn;
var docPower = require("../lib/doc-power");
var assert = require('chai').assert;
var escodegen = require("escodegen");
var vm = require('vm');
var path = require("path");
describe("docpower", function () {
    describe("#convertFromCodeToTree", function () {
        it("When expression + comment", function () {
            var code = "var a = 1;" +
                "a; // > 1";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                var a = 1;
                assert(a === 1);
            });
        });
        it("When CallExpression ", function () {
            var code = "var a = function(){return 1;};" +
                "a(); // > 1";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                var a = function () {
                    return 1;
                };
                assert(a() === 1);
            });
        });
        it("When BinaryExpression", function () {
            var code = "var a = function(){return 1;};" +
                "a + 1; // > 2";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                var a = function () {
                    return 1;
                };
                assert(a + 1 === 2);
            });
        });
        it("When BlockComment", function () {
            var code = "1; /* > 1 */";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                assert(1 === 1);
            });
        });
    });
    describe("#regexpExecuted", function () {
        beforeEach(function () {
            docPower.regexpExecuted(/\s+==>\s(.*?)$/);
        });
        afterEach(function () {
            // reset
            docPower.regexpExecuted(/\s+>\s+(.*)$/);
        });
        it("accept regexp comment ", function () {
            var code = "var a = 1;" +
                "a; // ==> 1";
            var resultAST = docPower.convertFromCodeToTree(code);
            assertAST(resultAST, function () {
                var a = 1;
                assert(a === 1);
            });
        });
    });
    describe("#runDocTest", function () {
        context("when success test", function () {
            it("should not result message", function () {
                var code = "var a = 1;\n" +
                    "a; // > 1";
                var resultMessage = docPower.runDocTest(code);
                assert.isUndefined(resultMessage);
            });
        });
        context("when fail test", function () {
            it("should output message", function () {
                var code = "var a = 'test';\n" +
                    "a; // > 'not match'\n";
                var resultMessage = docPower.runDocTest(code);
                assert.isNotNull(resultMessage);
            });
        });
    });
});
<|endoftext|>