<commit_before>(function(window, root, factory){
	'use strict';
	var transEndEventNames = {
			'WebkitTransition': 'webkitTransitionEnd',
			'MozTransition': 'transitionend',
			'OTransition': 'oTransitionEnd',
			'msTransition': 'MSTransitionEnd',
			'transition': 'transitionend'
		},
		transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
		support = { transitions : Modernizr.csstransitions };

	function extend( a, b ) {
		for( var key in b ) {
			if( b.hasOwnProperty( key ) ) {
				a[key] = b[key];
			}
		}
		return a;
	}

	function UIMorphingButton(el, morphTrigger, morphSection, options) {
		this.el = el;
		this.button = morphTrigger;
		this.contentEl = morphSection;
		this.options = extend( {}, this.options );
		extend( this.options, options );
		this._init();
	}

	UIMorphingButton.prototype.options = {
		closeEl : '',
		onBeforeOpen : function() { return false; },
		onAfterOpen : function() { return false; },
		onBeforeClose : function() { return false; },
		onAfterClose : function() { return false; }
	}

	UIMorphingButton.prototype._init = function(){
		// state
		this.expanded = false;
		// init events
		this._initEvents();
	}

	UIMorphingButton.prototype._initEvents = function(){
		var self = this;
		// open
		this.button.on('click', function(){ self.toggle(); });
		// close
		if(this.options.closeEl !== ''){
			var closeEl = this.options.closeEl;
			if( closeEl ) {
				closeEl.on('click', function(){ self.toggle(); });
			}
		}
	}

	UIMorphingButton.prototype.toggle = function(){
		if(this.isAnimating) return false;
		this.contentEl.css('width', this.button[0].offsetWidth + "px");
		this.contentEl.css('height', this.button[0].offsetHeight + "px");

		// callback
		if(this.expanded){
			this.options.onBeforeClose();
		}else{
			// add class active (solves z-index problem when more than one button is in the page)
			if(!this.options.onBeforeOpen(this.toggle, this)) return false;
			this.el.addClass('active');
		}

		this.isAnimating = true;

		var self = this,
			onEndTransitionFn = function(ev){
				if(ev.target !== this) return false;

				if(support.transitions){
					// open: first opacity then width/height/left/top
					// close: first width/height/left/top then opacity
					if( self.expanded && ev.propertyName !== 'opacity' || !self.expanded && ev.propertyName !== 'width' && ev.propertyName !== 'height' && ev.propertyName !== 'left' && ev.propertyName !== 'top' ) {
						return false;
					}
					self.contentEl.off(transEndEventName, onEndTransitionFn);
				}
				self.isAnimating = false;

				// callback
				if(self.expanded){
					// remove class active (after closing)
					self.el.removeClass('active');
					self.options.onAfterClose();
				}else{
					self.options.onAfterOpen();
				}

				self.expanded = !self.expanded;
			};

		if(support.transitions){
			this.contentEl.on(transEndEventName, onEndTransitionFn);
		}else{
			onEndTransitionFn();
		}

		// set the left and top values of the contentEl (same like the button)
		var buttonPos = this.button[0].getBoundingClientRect();
		// need to reset
		this.contentEl.addClass('no-transition');
		this.contentEl.css('left', 'auto');
		this.contentEl.css('top', 'auto');

		// add/remove class "open" to the button wraper
		setTimeout( function() {
			self.contentEl.css('left', buttonPos.left + 'px');
			self.contentEl.css('top', buttonPos.top + 'px');

			if( self.expanded ) {
				self.contentEl.removeClass('no-transition');
				self.el.removeClass('open');
			}
			else {
				setTimeout( function() {
					self.contentEl.removeClass('no-transition');
					self.el.addClass('open');
				}, 25 );
			}
		}, 25 );
	}

	// add to global namespace
	window.UIMorphingButton = UIMorphingButton;

	if (typeof module !== 'undefined' && module.exports) {
		// CommonJS
		if (typeof angular === 'undefined') {
			factory(require('angular'));
		} else {
			factory(angular);
		}
		module.exports = 'ngDialog';
	} else if (typeof define === 'function' && define.amd) {
		// AMD
		define(['angular'], factory);
	} else {
		// Global Variables
		factory(root.angular);
	}
})(window, this, function(angular){
	angular.module("ngMorph", [

	]).directive("morph", function(){
		return {
			scope: true,
			controller: function($scope, $element, $attrs){
				var docElem = window.document.documentElement, didScroll, scrollPosition;
				function onBeforeOpen(toggleFn, that){
					if(!$scope.$parent.$parent.$eval($scope.eval)) return false;
					$scope.morph(toggleFn, that);
					noScroll();
					return true;
				}

				function onAfterOpen(){
					$scope.$parent.$parent.$eval($scope.evalAfter);
					canScroll();
				}

				// trick to prevent scrolling when opening/closing button
				function noScrollFn() {
					window.scrollTo( scrollPosition ? scrollPosition.x : 0, scrollPosition ? scrollPosition.y : 0 );
				}

				function noScroll() {
					window.removeEventListener('scroll', scrollHandler);
					window.addEventListener('scroll', noScrollFn);
				}

				function scrollFn() {
					window.addEventListener('scroll', scrollHandler);
				}

				function canScroll() {
					window.removeEventListener('scroll', noScrollFn);
					scrollFn();
				}

				function scrollHandler() {
					if( !didScroll ) {
						didScroll = true;
						setTimeout( function() { scrollPage(); }, 60 );
					}
				};

				function scrollPage() {
					scrollPosition = { x : window.pageXOffset || docElem.scrollLeft, y : window.pageYOffset || docElem.scrollTop };
					didScroll = false;
				};

				scrollFn();

				$scope.button = false;
				this.morphDOMReady = function(el, eval, evalAfter, $evalScope){
					if(el !== undefined){
						$scope.morphTrigger = el;
						$scope.eval = eval;
						$scope.evalAfter = evalAfter;
						$scope.$evalScope = $evalScope;
					}
					if($scope.button == false && $scope.morphSection !== undefined && $scope.morphTrigger !== undefined && $scope.morphContainer !== undefined){
						$scope.button = true;
						new window.UIMorphingButton(
							$scope.morphContainer,
							$scope.morphTrigger,
							$scope.morphSection,
							{
								closeEl : $scope.morphClose,
								onBeforeOpen : onBeforeOpen,
								onAfterOpen : onAfterOpen,
								onBeforeClose : noScroll,
								onAfterClose : canScroll
							}
						);
					}
				}
				$scope.morphClose = "";
				$scope.morphContainer = $element;
				this.morphDOMReady();
			}
		};
	}).directive("morphTrigger", function(){
		return {
			scope: {
				morphTrigger: "@",
				morphEval: "@"
			},
			require: "^morph",
			link: function(scope, el, attrs, morphController){
				morphController.morphDOMReady(el, scope.morphTrigger, scope.morphEval, scope);
			}
		};
	}).directive("morphSection", function($window){
		return {
			require: "^morph",
			link: function(scope, el, attrs, morphController){
				scope.morphSection = el;
				morphController.morphDOMReady();
			}
		}
	});
//	.directive("morphCloseButton", function(){
//		return {
//			require: "^morph",
//			link: function(scope, el, attrs, morphController){
//				scope.morphClose = el;
//				morphController.morphDOMReady();
//			}
//		}
//	});
});<commit_msg>Just in case.<commit_after>(function(window, root, factory){
	'use strict';
	var transEndEventNames = {
			'WebkitTransition': 'webkitTransitionEnd',
			'MozTransition': 'transitionend',
			'OTransition': 'oTransitionEnd',
			'msTransition': 'MSTransitionEnd',
			'transition': 'transitionend'
		},
		transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
		support = { transitions : Modernizr.csstransitions };

	function extend( a, b ) {
		for( var key in b ) {
			if( b.hasOwnProperty( key ) ) {
				a[key] = b[key];
			}
		}
		return a;
	}

	function UIMorphingButton(el, morphTrigger, morphSection, options) {
		this.el = el;
		this.button = morphTrigger;
		this.contentEl = morphSection;
		this.options = extend( {}, this.options );
		extend( this.options, options );
		this._init();
	}

	UIMorphingButton.prototype.options = {
		closeEl : '',
		onBeforeOpen : function() { return false; },
		onAfterOpen : function() { return false; },
		onBeforeClose : function() { return false; },
		onAfterClose : function() { return false; }
	}

	UIMorphingButton.prototype._init = function(){
		// state
		this.expanded = false;
		// init events
		this._initEvents();
	}

	UIMorphingButton.prototype._initEvents = function(){
		var self = this;
		// open
		this.button.on('click', function(){ self.toggle(); });
		// close
		if(this.options.closeEl !== ''){
			var closeEl = this.options.closeEl;
			if( closeEl ) {
				closeEl.on('click', function(){ self.toggle(); });
			}
		}
	}

	UIMorphingButton.prototype.toggle = function(){
		if(this.isAnimating) return false;
		this.contentEl.css('width', this.button[0].offsetWidth + "px");
		this.contentEl.css('height', this.button[0].offsetHeight + "px");

		// callback
		if(this.expanded){
			this.options.onBeforeClose();
		}else{
			// add class active (solves z-index problem when more than one button is in the page)
			if(!this.options.onBeforeOpen(this.toggle, this)) return false;
			this.el.addClass('active');
		}

		this.isAnimating = true;

		var self = this,
			onEndTransitionFn = function(ev){
				if(ev.target !== this) return false;

				if(support.transitions){
					// open: first opacity then width/height/left/top
					// close: first width/height/left/top then opacity
					if( self.expanded && ev.propertyName !== 'opacity' || !self.expanded && ev.propertyName !== 'width' && ev.propertyName !== 'height' && ev.propertyName !== 'left' && ev.propertyName !== 'top' ) {
						return false;
					}
					self.contentEl.off(transEndEventName, onEndTransitionFn);
				}
				self.isAnimating = false;

				// callback
				if(self.expanded){
					// remove class active (after closing)
					self.el.removeClass('active');
					self.options.onAfterClose();
				}else{
					self.options.onAfterOpen();
				}

				self.expanded = !self.expanded;
			};

		if(support.transitions){
			this.contentEl.on(transEndEventName, onEndTransitionFn);
		}else{
			onEndTransitionFn();
		}

		// set the left and top values of the contentEl (same like the button)
		var buttonPos = this.button[0].getBoundingClientRect();
		// need to reset
		this.contentEl.addClass('no-transition');
		this.contentEl.css('left', 'auto');
		this.contentEl.css('top', 'auto');

		// add/remove class "open" to the button wraper
		setTimeout( function() {
			self.contentEl.css('left', buttonPos.left + 'px');
			self.contentEl.css('top', buttonPos.top + 'px');

			if( self.expanded ) {
				self.contentEl.removeClass('no-transition');
				self.el.removeClass('open');
			}
			else {
				setTimeout( function() {
					self.contentEl.removeClass('no-transition');
					self.el.addClass('open');
				}, 25 );
			}
		}, 25 );
	}

	// add to global namespace
	window.UIMorphingButton = UIMorphingButton;

	if (typeof module !== 'undefined' && module.exports) {
		// CommonJS
		if (typeof angular === 'undefined') {
			factory(require('angular'));
		} else {
			factory(angular);
		}
		module.exports = 'ngDialog';
	} else if (typeof define === 'function' && define.amd) {
		// AMD
		define(['angular'], factory);
	} else {
		// Global Variables
		factory(root.angular);
	}
})(window, this, function(angular){
	angular.module("ngMorph", [

	]).directive("morph", function(){
		return {
			scope: true,
			controller: function($scope, $element, $attrs){
				var docElem = window.document.documentElement, didScroll, scrollPosition;
				function onBeforeOpen(toggleFn, that){
					if(!$scope.$parent.$parent.$eval($scope.eval)) return false;
					$scope.morph(toggleFn, that);
					noScroll();
					return true;
				}

				function onAfterOpen(){
					$scope.$parent.$parent.$eval($scope.evalAfter);
					canScroll();
				}

				// trick to prevent scrolling when opening/closing button
				function noScrollFn() {
					window.scrollTo( scrollPosition ? scrollPosition.x : 0, scrollPosition ? scrollPosition.y : 0 );
				}

				function noScroll() {
					window.removeEventListener('scroll', scrollHandler);
					window.addEventListener('scroll', noScrollFn);
				}

				function scrollFn() {
					window.addEventListener('scroll', scrollHandler);
				}

				function canScroll() {
					window.removeEventListener('scroll', noScrollFn);
					scrollFn();
				}

				function scrollHandler() {
					if( !didScroll ) {
						didScroll = true;
						setTimeout( function() { scrollPage(); }, 60 );
					}
				};

				function scrollPage() {
					scrollPosition = { x : window.pageXOffset || docElem.scrollLeft, y : window.pageYOffset || docElem.scrollTop };
					didScroll = false;
				};

				scrollFn();

				$scope.button = false;
				this.morphDOMReady = function(el, eval, evalAfter, $evalScope){
					if(el !== undefined){
						$scope.morphTrigger = el;
						$scope.eval = eval;
						$scope.evalAfter = evalAfter;
						$scope.$evalScope = $evalScope;
					}
					if($scope.button == false && $scope.morphSection !== undefined && $scope.morphTrigger !== undefined && $scope.morphContainer !== undefined){
						$scope.button = true;
						new window.UIMorphingButton(
							$scope.morphContainer,
							$scope.morphTrigger,
							$scope.morphSection,
							{
								closeEl : $scope.morphClose,
								onBeforeOpen : onBeforeOpen,
								onAfterOpen : onAfterOpen,
								onBeforeClose : noScroll,
								onAfterClose : canScroll
							}
						);
						//TODO: DESTRUCT
					}
				}
				$scope.morphClose = "";
				$scope.morphContainer = $element;
				this.morphDOMReady();
			}
		};
	}).directive("morphTrigger", function(){
		return {
			scope: {
				morphTrigger: "@",
				morphEval: "@"
			},
			require: "^?morph",
			link: function(scope, el, attrs, morphController){
				if(!morphController) return;
				morphController.morphDOMReady(el, scope.morphTrigger, scope.morphEval, scope);
			}
		};
	}).directive("morphSection", function($window){
		return {
			require: "^?morph",
			link: function(scope, el, attrs, morphController){
				if(!morphController) return;
				scope.morphSection = el;
				morphController.morphDOMReady();
			}
		}
	});
//	.directive("morphCloseButton", function(){
//		return {
//			require: "^morph",
//			link: function(scope, el, attrs, morphController){
//				scope.morphClose = el;
//				morphController.morphDOMReady();
//			}
//		}
//	});
});<|endoftext|>


<commit_before>/* eslint-disable import/no-dynamic-require, no-console */
const chalk = require('chalk');
const path = require('path');
const fetch = require('node-fetch');
const simpleGit = require('simple-git/promise');

const cwd = process.cwd();
const git = simpleGit(cwd);

const { version } = require(path.resolve(cwd, 'package.json'));

function exitProcess(code = 1) {
  console.log(''); // Keep an empty line here to make looks good~
  process.exit(code);
}

async function checkVersion() {
  const { versions } = await fetch('http://registry.npmjs.org/antd').then(res => res.json());
  if (version in versions) {
    console.log(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
    console.log(chalk.cyan(' => Current:'), version);
    exitProcess();
  }
}

async function checkBranch({ current }) {
  if (current !== 'master' || current !== '4.0-prepare') {
    console.log(chalk.yellow('🤔 You are not in the master branch!'));
    exitProcess();
  }
}

async function checkCommit({ files }) {
  if (files.length) {
    console.log(chalk.yellow('🙄 You forgot something to commit.'));
    files.forEach(({ path: filePath, working_dir: mark }) => {
      console.log(' -', chalk.red(mark), filePath);
    });
    exitProcess();
  }
}

async function checkRemote() {
  const { remote } = await git.fetch('origin', 'master');
  if (remote.indexOf('ant-design/ant-design') === -1) {
    console.log(
      chalk.yellow('😓 Your remote origin is not ant-design/ant-design, did you fork it?'),
    );
    exitProcess();
  }
}

async function checkAll() {
  const status = await git.status();

  await checkVersion();

  await checkBranch(status);

  await checkCommit(status);

  await checkRemote();
}

checkAll();
<commit_msg>adjust branch check logic<commit_after>/* eslint-disable import/no-dynamic-require, no-console */
const chalk = require('chalk');
const path = require('path');
const fetch = require('node-fetch');
const simpleGit = require('simple-git/promise');

const cwd = process.cwd();
const git = simpleGit(cwd);

const { version } = require(path.resolve(cwd, 'package.json'));

function exitProcess(code = 1) {
  console.log(''); // Keep an empty line here to make looks good~
  process.exit(code);
}

async function checkVersion() {
  const { versions } = await fetch('http://registry.npmjs.org/antd').then(res => res.json());
  if (version in versions) {
    console.log(chalk.yellow('😈 Current version already exists. Forget update package.json?'));
    console.log(chalk.cyan(' => Current:'), version);
    exitProcess();
  }
}

async function checkBranch({ current }) {
  if (current !== 'master' && current !== '4.0-prepare') {
    console.log(chalk.yellow('🤔 You are not in the master branch!'));
    exitProcess();
  }
}

async function checkCommit({ files }) {
  if (files.length) {
    console.log(chalk.yellow('🙄 You forgot something to commit.'));
    files.forEach(({ path: filePath, working_dir: mark }) => {
      console.log(' -', chalk.red(mark), filePath);
    });
    exitProcess();
  }
}

async function checkRemote() {
  const { remote } = await git.fetch('origin', 'master');
  if (remote.indexOf('ant-design/ant-design') === -1) {
    console.log(
      chalk.yellow('😓 Your remote origin is not ant-design/ant-design, did you fork it?'),
    );
    exitProcess();
  }
}

async function checkAll() {
  const status = await git.status();

  await checkVersion();

  await checkBranch(status);

  await checkCommit(status);

  await checkRemote();
}

checkAll();
<|endoftext|>


<commit_before>'use strict';

const delay = require('delay');
const MongoClient = require('mongodb').MongoClient;

const config = require('./config');

function PubChemConnection() {}

PubChemConnection.prototype.close = function close() {
  if (this.connection) return this.connection.close();
  return undefined;
};

PubChemConnection.prototype.getMoleculesCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('molecules');
};

PubChemConnection.prototype.getAdminCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('admin');
};

PubChemConnection.prototype.getMfsCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('mfs');
};

PubChemConnection.prototype.getMfStatsCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('mfstats');
};

PubChemConnection.prototype.getDatabase = async function getDatabase() {
  while (true) {
    try {
      await this.init();
      break;
    } catch (e) {
      console.log('Connection to mongo failed, waiting 5s');
      await delay(5000);
    }
  }
  return this.connection.db(config.databaseName);
};

PubChemConnection.prototype.getCollection = async function getCollection(
  collectionName
) {
  return (await this.getDatabase()).collection(collectionName);
};

PubChemConnection.prototype.init = async function init() {
  if (this.connection) return;

  this.connection = await MongoClient.connect(
    config.mongodbUrl,
    {
      autoReconnect: true
      connectTimeoutMS: 60 * 60 * 1000,
      socketTimeoutMS: 60 * 60 * 1000
    }
  );
};

module.exports = PubChemConnection;
<commit_msg>fix comma<commit_after>'use strict';

const delay = require('delay');
const MongoClient = require('mongodb').MongoClient;

const config = require('./config');

function PubChemConnection() {}

PubChemConnection.prototype.close = function close() {
  if (this.connection) return this.connection.close();
  return undefined;
};

PubChemConnection.prototype.getMoleculesCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('molecules');
};

PubChemConnection.prototype.getAdminCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('admin');
};

PubChemConnection.prototype.getMfsCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('mfs');
};

PubChemConnection.prototype.getMfStatsCollection = async function getDatabase() {
  return (await this.getDatabase()).collection('mfstats');
};

PubChemConnection.prototype.getDatabase = async function getDatabase() {
  while (true) {
    try {
      await this.init();
      break;
    } catch (e) {
      console.log('Connection to mongo failed, waiting 5s');
      await delay(5000);
    }
  }
  return this.connection.db(config.databaseName);
};

PubChemConnection.prototype.getCollection = async function getCollection(
  collectionName
) {
  return (await this.getDatabase()).collection(collectionName);
};

PubChemConnection.prototype.init = async function init() {
  if (this.connection) return;

  this.connection = await MongoClient.connect(
    config.mongodbUrl,
    {
      autoReconnect: true,
      connectTimeoutMS: 60 * 60 * 1000,
      socketTimeoutMS: 60 * 60 * 1000
    }
  );
};

module.exports = PubChemConnection;
<|endoftext|>


<commit_before>var f = function() {
	var _  = NEJ.P,
		_f = NEJ.F,
        _u = _('nej.u'),
        _e = _('nej.e'),
        _u = _('nej.u'),
        _p = _('nej.ut');
    /**
     * 初始化特效参数
     * @param  {Object} 特效参数
     * @return {Object} 特效参数
     */
    _e.__initOptions = function(_options){
    	_options = _options||{};
    	_options.onstop = _options.onstop||_f;
    	_options.onplaystate = _options.onplaystate||_f;
    	return _options;
    };

    /**
     * 检查
     * @param  {[type]} _node [description]
     * @return {[type]}       [description]
     */
    _e.__doBeforeStart = (function(){
        // 检查节点是否隐藏
        var _doCheckdisplay = function(_node){
            var _d = _e._$getStyle(_node,'display')
            if(_d == 'none')
                return false;
            return true;
        };
        // 如果有一个属性是没有变化的，此属性的回调不会发生，避免此情况
        var _doCheckState = function(_node,_objs){
            var _v,_fg = true;
            _u._$forIn(_objs,function(_value,_name){
                if(_name == 'opacity' && nej.p._$KERNEL.engine=='trident' && nej.p._$KERNEL.release != '5.0'){
                    _name = 'filter';
                    var _filter = _e._$getStyle(_node,_name);
                    _v = parseFloat(_filter.split('=')[1])||0;
                    _value = _value * 100;
                }else{
                    _v = _e._$getStyle(_node,_name);
                }
                if(parseInt(_v) == _value)
                    _fg = false;
            }._$bind(this));
            return _fg;
        }
        return function(_node,_objs){
            if(!_doCheckState(_node,_objs))
                return !1;
            if(!_node.effectLock && _doCheckdisplay(_node))
                _node.effectLock = true;
            else
                return !1;
            return _node.effectLock;
        };
    })();

    /**
     * 淡入淡出操作
     * @param  {String|Node} _node  节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @param  {Number} 1表示淡入，0表示淡出，优先使用opacity配置
     * @return {nej.e}
     */
    _e.__doFade = function(_node,_options,_default){
        var _opacity = _options.opacity||_default;
        if(!_e.__doBeforeStart(_node,{opacity:_opacity})){
            return false;
        }
        _options = _e.__initOptions(_options);
        _node = _e._$get(_node);
        var _effect = _p._$$Effect._$allocate(
            {
                node:_node,
                transition:[
                    {
                        property:'opacity',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    }
                ],
                styles:['opacity:'+_opacity],
                onstop:function(_state){
                    _node.effectLock = !1;
                    _options.onstop.call(this,_state);
                    _effect = _p._$$Effect._$recycle(_effect);
                },
                onplaystate:_options.onplaystate._$bind(_effect)
            }
        );
        _effect._$start();
        return this;
    };

    /**
     * 淡入动画
     * 页面结构举例
     * [code type="html"]
     *   // 必须有opactiy属性
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$fadeIn(_node,{
     *       // 注意两位小数可能没有预期效果
     *       opactiy:0.8,
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$fadeIn}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$fadeIn = function(_node,_options){
        return _e.__doFade(_node,_options,1);
    };

    /**
     * 淡出动画
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$fadeOut(_node,{
     *       // 注意两位小数可能没有预期效果
     *       opactiy:0.8,
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$fadeOut}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$fadeOut = function(_node,_options){
        return _e.__doFade(_node,_options,0);
    };

    /**
     * 移动节点
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   // 需要配合预先定义的position属性
     *   _e._$moveTo(_node,{top:100,left:100}{
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$moveTo}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} top      移动节点的top值
     * @config {String} left     移动节点的left值
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$moveTo = function(_node,_position,_options){
        if(!_e.__doBeforeStart(_node,_position)){
            return false;
        }
    	_options = _e.__initOptions(_options);
    	   _node = _e._$get(_node);
    	var _top = _position.top||0,
    		_left= _position.left||0;
    	var _effect = _p._$$Effect._$allocate(
            {
                node:_node,
                transition:[
                    {
                        property:'top',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    },
                    {
                        property:'left',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    }
                ],
                styles:['top:'+_top,'left:'+_left],
                onstop:function(_state){
                    _node.effectLock = !1;
				    _options.onstop.call(this,_state);
                    _effect = _p._$$Effect._$recycle(_effect);
                },
                onplaystate:_options.onplaystate._$bind(_effect)
            }
        );
        _effect._$start();
        return this;
    };

    /**
     * 移动节点
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   // 需要配合预先定义的position属性
     *   _e._$silde(_node,'top:+100'{
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$moveTo}
     * @param  {Node|String} 节点或者节点ID
     * @param  {String}      滑动的方向
     * @param  {Object}      配置参数
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$silde = (function(){
        var _setPst = function(_node,_position){
            var _list  = _position.split(':');
            var _pst = _list[0];
            var _styles = [];
            _styles.push(_position);
            if(_pst == 'top' || _pst == 'bottom'){
                _styles.push('left:' + _e._$getStyle(_node,'left'));
            }else{
                _styles.push('top:' + _e._$getStyle(_node,'top'));
            }
            return _styles;
        };
        return function(_node,_position,_options){
            if(!_node.effectLock)
                _node.effectLock = true;
            else
                return !1;
            _node = _e._$get(_node);
            var _list  = _position.split(':');
            var _pro0 = _list[0];
            var _pro1 = '';
            if(_pro0 == 'top' || _pro0 == 'bottom'){
                _pro1 = 'left';
            }else{
                _pro1 = 'top';
            }
            var _styles = _setPst.call(this,_node,_position);
            var _effect = _p._$$Effect._$allocate(
                {
                    node:_node,
                    transition:[
                        {
                            property:_pro0,
                            timing:_options.timing||'ease-in',
                            delay:_options.delay||0,
                            duration:_options.duration||1
                        },
                        {
                            property:_pro1,
                            timing:_options.timing||'ease-in',
                            delay:_options.delay||0,
                            duration:_options.duration||1
                        }
                    ],
                    styles:_styles,
                    onstop:function(_state){
                        _node.effectLock = !1;
                        _options.onstop.call(this,_state);
                        _effect = _p._$$Effect._$recycle(_effect);
                    },
                    onplaystate:_options.onplaystate._$bind(_effect)
                }
            );
            _effect._$start();
            return this;
        };
    })();

    /**
     * toggle效果
     * 页面结构举例
     * [code type="html"]
     *   // overflow:hidden;visibility:hidden;display:none;
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$toggle(_box,'height',{value:100,timing:'ease-out',duration:'1.2'});
     * [/code]
     * @api    {nej.e._$toggle}
     * @param  {Node|String} 节点或者节点ID
     * @param  {String}      需要改变的属性，height或width
     * @param  {Object}      配置参数
     * @config {Number} value    属性值
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$toggleEffect = (function(){
        var _doCheck = function(_node,_type){
            return _type == 'height' ? _node.clientHeight : _node.clientWidth;
        };
        return function(_node,_type,_options){
            if(!_node.effectLock)
                _node.effectLock = true;
            else
                return !1;
            var _effect;
            _options = _e.__initOptions(_options);
            // set
            var _value = _options.value||false;
            if(!_value){
                _e._$setStyle(_node,'display','block');
                var _node = _e._$get(_node);
                _value = _doCheck(_node,_type);
            }
            var _flag = _e._$getStyle(_node,'visibility');
            if(_flag == 'hidden'){
                _node.style.height = 0;
                _e._$setStyle(_node,'visibility','inherit');
                _effect = _p._$$Effect._$allocate(
                    {
                        node:_node,
                        transition:[
                            {
                                property:_type,
                                timing:_options.timing||'ease-in',
                                delay:_options.delay||0,
                                duration:_options.duration||1
                            }
                        ],
                        styles:[_type + ':' + _value],
                        onstop:function(_state){
                            _node.effectLock = !1;
                            _options.onstop.call(this,_state);
                            _effect = _p._$$Effect._$recycle(_effect);
                            _sto = window.clearTimeout(_sto);
                        },
                        onplaystate:_options.onplaystate._$bind(_effect)
                    }
                );
            }else{
                _node.style.height = _value;
                _effect = _p._$$Effect._$allocate(
                    {
                        node:_node,
                        transition:[
                            {
                                property:_type,
                                timing:_options.timing||'ease-in',
                                delay:_options.delay||0,
                                duration:_options.duration||1
                            }
                        ],
                        styles:[_type + ':' + 0],
                        onstop:function(_state){
                            // _e._$setStyle(_node,'display','none');
                            _e._$setStyle(_node,'visibility','hidden');
                            _e._$setStyle(_node,_type,'auto');
                            _node.effectLock = !1;
                            _options.onstop.call(this,_state);
                            _effect = _p._$$Effect._$recycle(_effect);
                            _sto = window.clearTimeout(_sto);
                        },
                        onplaystate:_options.onplaystate._$bind(_effect)
                    }
                );
            }
            var _sto = window.setTimeout(function(){_effect._$start()}._$bind(this),0);
            return _effect;
        };
    })();

};
NEJ.define('{lib}util/effect/effect.api.js',
      ['{lib}util/effect/effect.js'],f);<commit_msg>IE10 effect bugfix<commit_after>var f = function() {
	var _  = NEJ.P,
		_f = NEJ.F,
        _u = _('nej.u'),
        _e = _('nej.e'),
        _u = _('nej.u'),
        _p = _('nej.ut');
    /**
     * 初始化特效参数
     * @param  {Object} 特效参数
     * @return {Object} 特效参数
     */
    _e.__initOptions = function(_options){
    	_options = _options||{};
    	_options.onstop = _options.onstop||_f;
    	_options.onplaystate = _options.onplaystate||_f;
    	return _options;
    };

    /**
     * 检查
     * @param  {[type]} _node [description]
     * @return {[type]}       [description]
     */
    _e.__doBeforeStart = (function(){
        // 检查节点是否隐藏
        var _doCheckdisplay = function(_node){
            var _d = _e._$getStyle(_node,'display')
            if(_d == 'none')
                return false;
            return true;
        };
        // 如果有一个属性是没有变化的，此属性的回调不会发生，避免此情况
        var _doCheckState = function(_node,_objs){
            var _v,_fg = true;
            _u._$forIn(_objs,function(_value,_name){
                if(_name == 'opacity' && nej.p._$KERNEL.engine=='trident' && (nej.p._$KERNEL.release - 5) < 0){
                    _name = 'filter';
                    var _filter = _e._$getStyle(_node,_name);
                    _v = parseFloat(_filter.split('=')[1])||0;
                    _value = _value * 100;
                }else{
                    _v = _e._$getStyle(_node,_name);
                }
                if(parseInt(_v) == _value)
                    _fg = false;
            }._$bind(this));
            return _fg;
        }
        return function(_node,_objs){
            if(!_doCheckState(_node,_objs))
                return !1;
            if(!_node.effectLock && _doCheckdisplay(_node))
                _node.effectLock = true;
            else
                return !1;
            return _node.effectLock;
        };
    })();

    /**
     * 淡入淡出操作
     * @param  {String|Node} _node  节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @param  {Number} 1表示淡入，0表示淡出，优先使用opacity配置
     * @return {nej.e}
     */
    _e.__doFade = function(_node,_options,_default){
        var _opacity = _options.opacity||_default;
        if(!_e.__doBeforeStart(_node,{opacity:_opacity})){
            return false;
        }
        _options = _e.__initOptions(_options);
        _node = _e._$get(_node);
        var _effect = _p._$$Effect._$allocate(
            {
                node:_node,
                transition:[
                    {
                        property:'opacity',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    }
                ],
                styles:['opacity:'+_opacity],
                onstop:function(_state){
                    _node.effectLock = !1;
                    _options.onstop.call(this,_state);
                    _effect = _p._$$Effect._$recycle(_effect);
                },
                onplaystate:_options.onplaystate._$bind(_effect)
            }
        );
        _effect._$start();
        return this;
    };

    /**
     * 淡入动画
     * 页面结构举例
     * [code type="html"]
     *   // 必须有opactiy属性
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$fadeIn(_node,{
     *       // 注意两位小数可能没有预期效果
     *       opactiy:0.8,
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$fadeIn}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$fadeIn = function(_node,_options){
        return _e.__doFade(_node,_options,1);
    };

    /**
     * 淡出动画
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$fadeOut(_node,{
     *       // 注意两位小数可能没有预期效果
     *       opactiy:0.8,
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$fadeOut}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} opacity  目标透明度
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$fadeOut = function(_node,_options){
        return _e.__doFade(_node,_options,0);
    };

    /**
     * 移动节点
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   // 需要配合预先定义的position属性
     *   _e._$moveTo(_node,{top:100,left:100}{
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$moveTo}
     * @param  {Node|String} 节点或者节点ID
     * @param  {Object}      配置参数
     * @config {String} top      移动节点的top值
     * @config {String} left     移动节点的left值
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$moveTo = function(_node,_position,_options){
        if(!_e.__doBeforeStart(_node,_position)){
            return false;
        }
    	_options = _e.__initOptions(_options);
    	   _node = _e._$get(_node);
    	var _top = _position.top||0,
    		_left= _position.left||0;
    	var _effect = _p._$$Effect._$allocate(
            {
                node:_node,
                transition:[
                    {
                        property:'top',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    },
                    {
                        property:'left',
                        timing:_options.timing||'ease-in',
                        delay:_options.delay||0,
                        duration:_options.duration||1
                    }
                ],
                styles:['top:'+_top,'left:'+_left],
                onstop:function(_state){
                    _node.effectLock = !1;
				    _options.onstop.call(this,_state);
                    _effect = _p._$$Effect._$recycle(_effect);
                },
                onplaystate:_options.onplaystate._$bind(_effect)
            }
        );
        _effect._$start();
        return this;
    };

    /**
     * 移动节点
     * 页面结构举例
     * [code type="html"]
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   // 需要配合预先定义的position属性
     *   _e._$silde(_node,'top:+100'{
     *       timing:'ease-out',
     *       delay:0,
     *       duration:5
     *   });
     * [/code]
     * @api    {nej.e._$moveTo}
     * @param  {Node|String} 节点或者节点ID
     * @param  {String}      滑动的方向
     * @param  {Object}      配置参数
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$silde = (function(){
        var _setPst = function(_node,_position){
            var _list  = _position.split(':');
            var _pst = _list[0];
            var _styles = [];
            _styles.push(_position);
            if(_pst == 'top' || _pst == 'bottom'){
                _styles.push('left:' + _e._$getStyle(_node,'left'));
            }else{
                _styles.push('top:' + _e._$getStyle(_node,'top'));
            }
            return _styles;
        };
        return function(_node,_position,_options){
            if(!_node.effectLock)
                _node.effectLock = true;
            else
                return !1;
            _node = _e._$get(_node);
            var _list  = _position.split(':');
            var _pro0 = _list[0];
            var _pro1 = '';
            if(_pro0 == 'top' || _pro0 == 'bottom'){
                _pro1 = 'left';
            }else{
                _pro1 = 'top';
            }
            var _styles = _setPst.call(this,_node,_position);
            var _effect = _p._$$Effect._$allocate(
                {
                    node:_node,
                    transition:[
                        {
                            property:_pro0,
                            timing:_options.timing||'ease-in',
                            delay:_options.delay||0,
                            duration:_options.duration||1
                        },
                        {
                            property:_pro1,
                            timing:_options.timing||'ease-in',
                            delay:_options.delay||0,
                            duration:_options.duration||1
                        }
                    ],
                    styles:_styles,
                    onstop:function(_state){
                        _node.effectLock = !1;
                        _options.onstop.call(this,_state);
                        _effect = _p._$$Effect._$recycle(_effect);
                    },
                    onplaystate:_options.onplaystate._$bind(_effect)
                }
            );
            _effect._$start();
            return this;
        };
    })();

    /**
     * toggle效果
     * 页面结构举例
     * [code type="html"]
     *   // overflow:hidden;visibility:hidden;display:none;
     *
123

     * [/code]
     * 脚本举例
     * [code]
     *   var _e = NEJ.P("nej.e");
     *   var _node = _e._$get("box");
     *   _e._$toggle(_box,'height',{value:100,timing:'ease-out',duration:'1.2'});
     * [/code]
     * @api    {nej.e._$toggle}
     * @param  {Node|String} 节点或者节点ID
     * @param  {String}      需要改变的属性，height或width
     * @param  {Object}      配置参数
     * @config {Number} value    属性值
     * @config {String} timing   运动曲线
     * @config {Number} delay    延迟时间
     * @config {String} duration 运动时间
     * @return {nej.e}
     */
    _e._$toggleEffect = (function(){
        var _doCheck = function(_node,_type){
            return _type == 'height' ? _node.clientHeight : _node.clientWidth;
        };
        return function(_node,_type,_options){
            if(!_node.effectLock)
                _node.effectLock = true;
            else
                return !1;
            var _effect;
            _options = _e.__initOptions(_options);
            // set
            var _value = _options.value||false;
            if(!_value){
                _e._$setStyle(_node,'display','block');
                var _node = _e._$get(_node);
                _value = _doCheck(_node,_type);
            }
            var _flag = _e._$getStyle(_node,'visibility');
            if(_flag == 'hidden'){
                _node.style.height = 0;
                _e._$setStyle(_node,'visibility','inherit');
                _effect = _p._$$Effect._$allocate(
                    {
                        node:_node,
                        transition:[
                            {
                                property:_type,
                                timing:_options.timing||'ease-in',
                                delay:_options.delay||0,
                                duration:_options.duration||1
                            }
                        ],
                        styles:[_type + ':' + _value],
                        onstop:function(_state){
                            _node.effectLock = !1;
                            _options.onstop.call(this,_state);
                            _effect = _p._$$Effect._$recycle(_effect);
                            _sto = window.clearTimeout(_sto);
                        },
                        onplaystate:_options.onplaystate._$bind(_effect)
                    }
                );
            }else{
                _node.style.height = _value;
                _effect = _p._$$Effect._$allocate(
                    {
                        node:_node,
                        transition:[
                            {
                                property:_type,
                                timing:_options.timing||'ease-in',
                                delay:_options.delay||0,
                                duration:_options.duration||1
                            }
                        ],
                        styles:[_type + ':' + 0],
                        onstop:function(_state){
                            // _e._$setStyle(_node,'display','none');
                            _e._$setStyle(_node,'visibility','hidden');
                            _e._$setStyle(_node,_type,'auto');
                            _node.effectLock = !1;
                            _options.onstop.call(this,_state);
                            _effect = _p._$$Effect._$recycle(_effect);
                            _sto = window.clearTimeout(_sto);
                        },
                        onplaystate:_options.onplaystate._$bind(_effect)
                    }
                );
            }
            var _sto = window.setTimeout(function(){_effect._$start()}._$bind(this),0);
            return _effect;
        };
    })();

};
NEJ.define('{lib}util/effect/effect.api.js',
      ['{lib}util/effect/effect.js'],f);<|endoftext|>


<commit_before>const path = require('path');
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const exportJson = require('node-sass-export');
const npmSass = require('npm-sass');
const fs = require('fs-extra');
// const WorkboxPlugin = require('workbox-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const autoprefixer = require('autoprefixer');
const pkg = require('./package.json');
const ConcatPlugin = require('webpack-concat-plugin');
const { CommonsChunkPlugin/*, UglifyJsPlugin*/ } = webpack.optimize;

const isDev = process.argv.find(arg => arg.includes('webpack-dev-server'));
const ENV = isDev ? 'development' : 'production';
const outputPath = isDev ? path.resolve('src') : path.resolve('./dist');

const merge = require('merge').recursive;

// const IS_MODULE_BUILD = BROWSERS[0].includes('Chrome');
const processEnv = {
  NODE_ENV: JSON.stringify(ENV)
  // appVersion: JSON.stringify(pkg.version)
};

const sassDataExportPath = `${process.cwd()}/dist`;
const defaultConfig = {
  // entry: './src/index.js',
  entry: {
    'critical-fonts': './src/_patterns/02-components/bolt-critical-fonts/src/critical-fonts',

    'critical-fonts': './src/_patterns/02-components/bolt-button/src/button',
    // './src/components/bolt-icon/dist/icon': [
    //   // './src/scripts/native-shim.js', //Wrapper for custom-elements-es5-adapter.js so this doesn't break in other browsers like IE11
    //   // './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
    //   // './node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
    //   './src/components/bolt-icon/src/icon'
    // ],
    // './dist/scripts/bolt-icon': [
    //   './node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
    //   './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
    //   './src/components/bolt-icon/src/icon'
    // ],

    'bolt-app': [
      // './src/scripts/native-shim.js', //Wrapper for custom-elements-es5-adapter.js so this doesn't break in other browsers like IE11
      // './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
      // './node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
      './src/scripts/bolt-app'
    ],
    'bolt-critical-path': './src/scripts/bolt-critical-path',
  },
  output: {
    path: `${process.cwd()}/dist/scripts/`,
    filename: '[name].min.js',
    publicPath: `/scripts/`,
    chunkFilename: `[id].chunk.js`
  },
  devtool: 'cheap-module-source-map',
  // devtool: 'cheap-source-map',
  resolve: {
    alias: {
      styles: path.resolve(__dirname, 'src/styles'),
    },
    extensions: ['.js', '.jsx', '.json', '.svg', '.scss']
  },

  module: {
    rules: [
      // {
      //   test: /node_modules\/skatejs\/**\/*\.js?$/,
      //   // include: /skatejs/,
      //   // exclude: /!node_modules\/skatejs/,
      //   use: ['awesome-typescript-loader']
      // },
      {
        test: /\.js$/,
        // exclude: /\.es6.js$/,
        exclude: /(native-shim\.js|node_modules\/\@webcomponents\/webcomponentsjs\/custom-elements-es5-adapter\.js|\@webcomponents\/webcomponentsjs\/custom-elements-es5-adapter\.js|custom-elements-es5-adapter\.js|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            babelrc: false,
            plugins: [
              [
                'jsx-pragmatic',
                {
                  module: 'preact',
                  export: 'h',
                  import: 'h'
                }
              ],
              [
                'transform-react-jsx',
                {
                  pragma: 'h'
                }
              ],
              ['module-resolver',
                {
                  root: [
                    './src'
                  ],
                  alias: {
                    h: 'preact'
                  }
                }
              ],
              'transform-class-properties',
              // 'transform-custom-element-classes',
              // 'transform-es2015-classes',
              'transform-object-assign',
              'transform-object-rest-spread',
              // 'inline-react-svg'
            ],

            presets: [
              ['env', {
                targets: {
                  browsers: [
                    'last 3 versions',
                    'not ie < 9'
                  ]
                },
                debug: false
              }],
              "flow",
              "react",
              'stage-0'
            ]
          }
        }
      },
      {
        test: /\.scss$/,
        exclude: /\.scoped.scss$/,
        use: [
          {
            loader: 'css-loader',
            // options: {
            //   sourceMap: true,
            //   modules: true,
            //   importLoaders: true,
            //   localIdentName: '[name]__[local]___[hash:base64:5]'
            // }
          },
          {
            loader: 'postcss-loader',
            options: {
              plugins: function () {
                return [
                  require('autoprefixer')
                ];
              }
            }
          },
          {
            loader: 'clean-css-loader',
            options: {
              skipWarn: true,
              compatibility: 'ie9',
              level: 2,
              inline: ['remote']
            }
          },
          {
            loader: 'sass-loader',
            options: {
              importer: require('npm-sass').importer,
              functions: exportJson(sassDataExportPath, 'export_data'),
              outputStyle: 'compressed',
              precision: 2
            }
          }
        ]
      },
      {
        test: /\.scoped.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader',
              options: {
                sourceMap: true,
                modules: true,
                importLoaders: true,
                localIdentName: '[local]'
              }
            },
            {
              loader: 'postcss-loader',
              options: {
                plugins: function () {
                  return [
                    require('autoprefixer')
                  ];
                }
              }
            },
            {
              loader: 'clean-css-loader',
              options: {
                skipWarn: true,
                compatibility: 'ie9',
                level: 2,
                inline: ['remote']
              }
            },
            {
              loader: 'sass-loader',
              options: {
                importer: require('npm-sass').importer,
                functions: exportJson(sassDataExportPath, 'export_data'),
                outputStyle: 'compressed',
                precision: 2
              }
            }
          ]
        })
      },
      {
        test: /\.html$/,
        use: ['text-loader']
      },
      {
        test: /\.svg$/,
        loader: 'svg-inline-loader'
      }
    ]
  },
  performance: {
    maxAssetSize: 1500000,
    maxEntrypointSize: 1500000
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      // name: "app",
      // or
      // names: ["app", "subPageA"],
      // the name or list of names must match the name or names
      // of the entry points that create the async chunks
      children: true,
      // (use all children of the chunk)

      async: true,
      // (create an async commons chunk)

      minChunks: 2,
      // (3 children must share the module before it's separated)
    }),
    new webpack.IgnorePlugin(/vertx/), // needed to ignore vertx dependency in webcomponentsjs-lite
    new ExtractTextPlugin({
      filename: '[name].css?[hash]-[chunkhash]-[contenthash]-[name]',
      disable: false,
      allChunks: true
    }),
    new ManifestPlugin({
      fileName: 'bolt-manifest.json',
      // basePath: '/scripts/',
      publicPath: '/',
      writeToFileEmit: true,
      seed: {
        name: 'Bolt Manifest'
      }
    }),
    new webpack.optimize.ModuleConcatenationPlugin(),
    new webpack.DefinePlugin({ 'process.env': processEnv }),
    new webpack.ProvidePlugin({
      h: 'preact',
      Promise: 'es6-promise'
    })
  ],
  devServer: {
    contentBase: path.resolve(outputPath),
    compress: true,
    overlay: {
      errors: true
    },
    port: 3000,
    host: '0.0.0.0',
    disableHostCheck: true
  }
};

module.exports = (userConfig) => {
  // Merge together the default webpack config + any overrides passed in
  const config = merge(defaultConfig, userConfig, {});

  // if (!fs.existsSync(config.sassDataExportPath)) {
  //   fs.mkdirp(config.sassDataExportPath);
  // }

  return config;
};
<commit_msg>fix: revert webpack config update -- no longer needed.<commit_after>const path = require('path');
const webpack = require('webpack');
const ManifestPlugin = require('webpack-manifest-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const exportJson = require('node-sass-export');
const npmSass = require('npm-sass');
const fs = require('fs-extra');
// const WorkboxPlugin = require('workbox-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const autoprefixer = require('autoprefixer');
const pkg = require('./package.json');
const ConcatPlugin = require('webpack-concat-plugin');
const { CommonsChunkPlugin/*, UglifyJsPlugin*/ } = webpack.optimize;

const isDev = process.argv.find(arg => arg.includes('webpack-dev-server'));
const ENV = isDev ? 'development' : 'production';
const outputPath = isDev ? path.resolve('src') : path.resolve('./dist');

const merge = require('merge').recursive;

// const IS_MODULE_BUILD = BROWSERS[0].includes('Chrome');
const processEnv = {
  NODE_ENV: JSON.stringify(ENV)
  // appVersion: JSON.stringify(pkg.version)
};

const sassDataExportPath = `${process.cwd()}/dist`;
const defaultConfig = {
  // entry: './src/index.js',
  entry: {
    'critical-fonts': './src/_patterns/02-components/bolt-critical-fonts/src/critical-fonts',
    // './src/components/bolt-icon/dist/icon': [
    //   // './src/scripts/native-shim.js', //Wrapper for custom-elements-es5-adapter.js so this doesn't break in other browsers like IE11
    //   // './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
    //   // './node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
    //   './src/components/bolt-icon/src/icon'
    // ],
    // './dist/scripts/bolt-icon': [
    //   './node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js',
    //   './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
    //   './src/components/bolt-icon/src/icon'
    // ],

    'bolt-app': [
      // './src/scripts/native-shim.js', //Wrapper for custom-elements-es5-adapter.js so this doesn't break in other browsers like IE11
      // './node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js',
      // './node_modules/@webcomponents/webcomponentsjs/webcomponents-sd-ce.js',
      './src/scripts/bolt-app'
    ],
    'bolt-critical-path': './src/scripts/bolt-critical-path',
  },
  output: {
    path: `${process.cwd()}/dist/scripts/`,
    filename: '[name].min.js',
    publicPath: `/scripts/`,
    chunkFilename: `[id].chunk.js`
  },
  devtool: 'cheap-module-source-map',
  // devtool: 'cheap-source-map',
  resolve: {
    alias: {
      styles: path.resolve(__dirname, 'src/styles'),
    },
    extensions: ['.js', '.jsx', '.json', '.svg', '.scss']
  },

  module: {
    rules: [
      // {
      //   test: /node_modules\/skatejs\/**\/*\.js?$/,
      //   // include: /skatejs/,
      //   // exclude: /!node_modules\/skatejs/,
      //   use: ['awesome-typescript-loader']
      // },
      {
        test: /\.js$/,
        // exclude: /\.es6.js$/,
        exclude: /(native-shim\.js|node_modules\/\@webcomponents\/webcomponentsjs\/custom-elements-es5-adapter\.js|\@webcomponents\/webcomponentsjs\/custom-elements-es5-adapter\.js|custom-elements-es5-adapter\.js|bower_components)/,
        use: {
          loader: 'babel-loader',
          options: {
            babelrc: false,
            plugins: [
              [
                'jsx-pragmatic',
                {
                  module: 'preact',
                  export: 'h',
                  import: 'h'
                }
              ],
              [
                'transform-react-jsx',
                {
                  pragma: 'h'
                }
              ],
              ['module-resolver',
                {
                  root: [
                    './src'
                  ],
                  alias: {
                    h: 'preact'
                  }
                }
              ],
              'transform-class-properties',
              // 'transform-custom-element-classes',
              // 'transform-es2015-classes',
              'transform-object-assign',
              'transform-object-rest-spread',
              // 'inline-react-svg'
            ],

            presets: [
              ['env', {
                targets: {
                  browsers: [
                    'last 3 versions',
                    'not ie < 9'
                  ]
                },
                debug: false
              }],
              "flow",
              "react",
              'stage-0'
            ]
          }
        }
      },
      {
        test: /\.scss$/,
        exclude: /\.scoped.scss$/,
        use: [
          {
            loader: 'css-loader',
            // options: {
            //   sourceMap: true,
            //   modules: true,
            //   importLoaders: true,
            //   localIdentName: '[name]__[local]___[hash:base64:5]'
            // }
          },
          {
            loader: 'postcss-loader',
            options: {
              plugins: function () {
                return [
                  require('autoprefixer')
                ];
              }
            }
          },
          {
            loader: 'clean-css-loader',
            options: {
              skipWarn: true,
              compatibility: 'ie9',
              level: 2,
              inline: ['remote']
            }
          },
          {
            loader: 'sass-loader',
            options: {
              importer: require('npm-sass').importer,
              functions: exportJson(sassDataExportPath, 'export_data'),
              outputStyle: 'compressed',
              precision: 2
            }
          }
        ]
      },
      {
        test: /\.scoped.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: [
            {
              loader: 'css-loader',
              options: {
                sourceMap: true,
                modules: true,
                importLoaders: true,
                localIdentName: '[local]'
              }
            },
            {
              loader: 'postcss-loader',
              options: {
                plugins: function () {
                  return [
                    require('autoprefixer')
                  ];
                }
              }
            },
            {
              loader: 'clean-css-loader',
              options: {
                skipWarn: true,
                compatibility: 'ie9',
                level: 2,
                inline: ['remote']
              }
            },
            {
              loader: 'sass-loader',
              options: {
                importer: require('npm-sass').importer,
                functions: exportJson(sassDataExportPath, 'export_data'),
                outputStyle: 'compressed',
                precision: 2
              }
            }
          ]
        })
      },
      {
        test: /\.html$/,
        use: ['text-loader']
      },
      {
        test: /\.svg$/,
        loader: 'svg-inline-loader'
      }
    ]
  },
  performance: {
    maxAssetSize: 1500000,
    maxEntrypointSize: 1500000
  },
  plugins: [
    new webpack.optimize.CommonsChunkPlugin({
      // name: "app",
      // or
      // names: ["app", "subPageA"],
      // the name or list of names must match the name or names
      // of the entry points that create the async chunks
      children: true,
      // (use all children of the chunk)

      async: true,
      // (create an async commons chunk)

      minChunks: 2,
      // (3 children must share the module before it's separated)
    }),
    new webpack.IgnorePlugin(/vertx/), // needed to ignore vertx dependency in webcomponentsjs-lite
    new ExtractTextPlugin({
      filename: '[name].css?[hash]-[chunkhash]-[contenthash]-[name]',
      disable: false,
      allChunks: true
    }),
    new ManifestPlugin({
      fileName: 'bolt-manifest.json',
      // basePath: '/scripts/',
      publicPath: '/',
      writeToFileEmit: true,
      seed: {
        name: 'Bolt Manifest'
      }
    }),
    new webpack.optimize.ModuleConcatenationPlugin(),
    new webpack.DefinePlugin({ 'process.env': processEnv }),
    new webpack.ProvidePlugin({
      h: 'preact',
      Promise: 'es6-promise'
    })
  ],
  devServer: {
    contentBase: path.resolve(outputPath),
    compress: true,
    overlay: {
      errors: true
    },
    port: 3000,
    host: '0.0.0.0',
    disableHostCheck: true
  }
};

module.exports = (userConfig) => {
  // Merge together the default webpack config + any overrides passed in
  const config = merge(defaultConfig, userConfig, {});

  // if (!fs.existsSync(config.sassDataExportPath)) {
  //   fs.mkdirp(config.sassDataExportPath);
  // }

  return config;
};
<|endoftext|>


<commit_before>// @flow
/**
 * A module for i18n utilities
 * @module localizationUtils
 */

// locale data comes from https://github.com/andyearnshaw/Intl.js/tree/master/locale-data/json
import LocaleDataFR from 'react-intl/locale-data/fr';
import LocaleDataDE from 'react-intl/locale-data/de';
import LocaleDataES from 'react-intl/locale-data/es';
import LocaleDataIT from 'react-intl/locale-data/it';
import LocaleDataJA from 'react-intl/locale-data/ja';
import LocaleDataPT from 'react-intl/locale-data/pt';
import LocaleDataKO from 'react-intl/locale-data/ko';
import LocaleDataNL from 'react-intl/locale-data/nl';
import LocaleDataPL from 'react-intl/locale-data/pl';
import LocaleDataTH from 'react-intl/locale-data/th';
import LocaleDataTR from 'react-intl/locale-data/tr';

import { addLocaleData } from 'react-intl';

const localeMap: { [string]: { data?: Object } } = {
	'en-US': {
		// Use built-in locale-data for en
	},
	'en-AU': {
		// Use built-in locale-data for en
	},
	es: {
		data: LocaleDataES,
	},
	'es-ES': {
		data: LocaleDataES,
	},
	'fr-FR': {
		data: LocaleDataFR,
	},
	'de-DE': {
		data: LocaleDataDE,
	},
	'it-IT': {
		data: LocaleDataIT,
	},
	'ja-JP': {
		data: LocaleDataJA,
	},
	'ko-KR': {
		data: LocaleDataKO,
	},
	'nl-NL': {
		data: LocaleDataNL,
	},
	'pl-PL': {
		data: LocaleDataPL,
	},
	'pt-BR': {
		data: LocaleDataPT,
	},
	'th-TH': {
		data: LocaleDataTH,
	},
	'tr-TR': {
		data: LocaleDataTR,
	},
};

/*
 * Load data for given localeCode into ReactIntl
 */
export function loadLocale(localeCode: string) {
	if (!(localeCode in localeMap)) {
		console.warn(`${localeCode} not supported`);
	}
	const locale = localeMap[localeCode] || {};
	addLocaleData(locale.data);
}

/*
 * Get locale code and for given member
 *
 * Note:
 * The api currently returns locale codes with underscores
 * instead of dashes, so this method supports both until fixed.
 */
export function getLocaleCode(self: { lang?: string, [string]: Object }) {
	// Retreive locale code from state (api response)
	return ((self && self.lang) || 'en-US').replace('_', '-');
}
<commit_msg>accept undefined localeCode<commit_after>// @flow
/**
 * A module for i18n utilities
 * @module localizationUtils
 */

// locale data comes from https://github.com/andyearnshaw/Intl.js/tree/master/locale-data/json
import LocaleDataFR from 'react-intl/locale-data/fr';
import LocaleDataDE from 'react-intl/locale-data/de';
import LocaleDataES from 'react-intl/locale-data/es';
import LocaleDataIT from 'react-intl/locale-data/it';
import LocaleDataJA from 'react-intl/locale-data/ja';
import LocaleDataPT from 'react-intl/locale-data/pt';
import LocaleDataKO from 'react-intl/locale-data/ko';
import LocaleDataNL from 'react-intl/locale-data/nl';
import LocaleDataPL from 'react-intl/locale-data/pl';
import LocaleDataTH from 'react-intl/locale-data/th';
import LocaleDataTR from 'react-intl/locale-data/tr';

import { addLocaleData } from 'react-intl';

const localeMap: { [string]: { data?: Object } } = {
	'en-US': {
		// Use built-in locale-data for en
	},
	'en-AU': {
		// Use built-in locale-data for en
	},
	es: {
		data: LocaleDataES,
	},
	'es-ES': {
		data: LocaleDataES,
	},
	'fr-FR': {
		data: LocaleDataFR,
	},
	'de-DE': {
		data: LocaleDataDE,
	},
	'it-IT': {
		data: LocaleDataIT,
	},
	'ja-JP': {
		data: LocaleDataJA,
	},
	'ko-KR': {
		data: LocaleDataKO,
	},
	'nl-NL': {
		data: LocaleDataNL,
	},
	'pl-PL': {
		data: LocaleDataPL,
	},
	'pt-BR': {
		data: LocaleDataPT,
	},
	'th-TH': {
		data: LocaleDataTH,
	},
	'tr-TR': {
		data: LocaleDataTR,
	},
};

/*
 * Load data for given localeCode into ReactIntl
 */
export function loadLocale(localeCode: ?string) {
	if (!localeCode) {
		return;
	}
	if (!(localeCode in localeMap)) {
		console.warn(`${localeCode} not supported`);
	}
	const locale = localeMap[localeCode] || {};
	addLocaleData(locale.data);
}

/*
 * Get locale code and for given member
 *
 * Note:
 * The api currently returns locale codes with underscores
 * instead of dashes, so this method supports both until fixed.
 */
export function getLocaleCode(self: { lang?: string, [string]: Object }) {
	// Retreive locale code from state (api response)
	return ((self && self.lang) || 'en-US').replace('_', '-');
}
<|endoftext|>


<commit_before>    // GA code
	var gaPlugin;

	function initialize() {
		document.addEventListener("deviceready", onDeviceReady, true);
	}

	function onDeviceReady() {
		gaPlugin = window.plugins.gaPlugin;

		// Note: A request for permission is REQUIRED by google. You probably want to do this just once, though, and remember the answer for subsequent runs.
		navigator.notification.confirm('Artist colony would like your permission to collect usage data. No personal or user identifiable data will be collected.', permissionCallback, 'Attention', 'Allow,Deny');
	}

	function permissionCallback (button) {
		if (button === 1)
			gaPlugin.init(nativePluginResultHandler, nativePluginErrorHandler, "UA-108603-3", 10);
	}

	function nativePluginResultHandler (result) {
		//alert('nativePluginResultHandler - '+result);
		console.log('nativePluginResultHandler: '+result);

	}

	function nativePluginErrorHandler (error) {
		//alert('nativePluginErrorHandler - '+error);
		console.log('nativePluginErrorHandler: '+error);
	}

	function TrackButtonClicked() {
		gaPlugin.trackEvent( nativePluginResultHandler, nativePluginErrorHandler, "Button", "Click", "event only", 1);
	}

	function VariableButtonClicked() {
		// Set a dimension based on index and value. Make sure you have added a dimension in the GA dashboard to the
		// default property for the passed in index, and your desired scope. GA allows up to 20 dimensions for a free account
		gaPlugin.setVariable( nativePluginResultHandler, nativePluginErrorHandler, 1, "Purple");

		// dimensions are are passed to the next event sent to GA. go ahead and fire off an event with the label (key) of your choice
		// In this example, the label for custom dimension 1 will show up in the dashboard as "favoriteColor". This is much more efficent
		// than the old custom variable method introduced in V1, (plus you get 20 free dimensions vs 5 free custom variables)
		gaPlugin.trackEvent( nativePluginResultHandler, nativePluginErrorHandler, "event with variable", "set variable", "favoriteColor", 1);
	}

	function PageButtonClicked() {
		gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler, "some.url.com");
	}

	function goingAway() {
		gaPlugin.exit(nativePluginResultHandler, nativePluginErrorHandler);
	}

	// photoswipe lib call
	(function(window, PhotoSwipe){
		document.addEventListener('DOMContentLoaded', function(){
			var
				options = {
					getImageCaption: function(el){
						var captionText, captionEl;

						// Get the caption from the alt tag
						if (el.nodeName === "IMG"){
							captionText = el.getAttribute('alt');
						}
						var i, j, childEl;
						for (i=0, j=el.childNodes.length; i<j; i++){
							childEl = el.childNodes[i];
							if (el.childNodes[i].nodeName === 'IMG'){
								captionText = childEl.getAttribute('alt');
							}
						}

						// Return a DOM element with custom styling
						captionEl = document.createElement('div');
						captionEl.style.cssText = 'background: black; font-weight: bold; padding: 5px;';
						captionEl.appendChild(document.createTextNode(captionText));
						return captionEl;

					}
				},
				instance = PhotoSwipe.attach( window.document.querySelectorAll('#gallery a'), options );
		}, false);
	}(window, window.Code.PhotoSwipe));

	// init
	$(document).ready(function(){

		(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")

			var slider = new Swipe(document.getElementById('slider'));

			$('.next-but-swipe').click(function(){
				slider.next();
				return false;
			});

			$('.prev-but-swipe').click(function(){
				slider.prev();
				return false;
			});

			$('.toggle-plus').click(function(){
				$(this).toggleClass('toggle-plus-selected');
				$(this).parent().find('.toggle-content').toggle(100);
				return false;
			});

			$('.toggle-arrow').click(function(){
				$(this).toggleClass('toggle-arrow-selected');
				$(this).parent().find('.toggle-content').toggle(100);
				return false;
			});

			$('.checkbox-1').click(function(){
				$(this).toggleClass('checkbox-1-selected')
				return false;
			});

			$('.checkbox-2').click(function(){
				$(this).toggleClass('checkbox-2-selected')
				return false;
			});

			$('.radio-1').click(function(){
				$(this).toggleClass('radio-1-selected')
				return false;
			});

			$('.radio-2').click(function(){
				$(this).toggleClass('radio-2-selected')
				return false;
			});

			$('#one').click(function(){
				$('#one').addClass('selected-page-nav');
				$('#two, #three').removeClass('selected-page-nav');
				$('.two, .three').hide();
				$('.one').fadeIn();
				return false;
			});

			$('#two').click(function(){
				$('#two').addClass('selected-page-nav');
				$('#one, #three').removeClass('selected-page-nav');
				$('.one, .three').hide();
				$('.two').fadeIn();
				return false;
			});

			$('#three').click(function(){
				$('#three').addClass('selected-page-nav');
				$('#two, #one').removeClass('selected-page-nav');
				$('.two, .one').hide();
				$('.three').fadeIn();
				return false;
			});

			$('.navigation').animate({height:'toggle'},0);
			$('.navigation-strip').click(function(){
				$('.navigation').animate({height:'toggle'});
				$('.navigation-strip').toggleClass('selected-navigation-strip');
				return false;
			});

			$('#no').click(function(){
				$('.click-interface').show();
				$('.drag-interface').hide();
				$('.no').hide();
				$('.yes').show();
				return false;
			});

			$('#yes').click(function(){
				$('.click-interface').hide();
				$('.drag-interface').show();
				$('.no').show();
				$('.yes').hide();
				return false;
			});

			$(".notification-quit-red").click(function(){
			  $(".notification-box-red").hide("slow");
			  return false;
			});

			$(".notification-quit-green").click(function(){
			  $(".notification-box-green").hide("slow");
			  return false;
			});

			$(".notification-quit-yellow").click(function(){
			  $(".notification-box-yellow").hide("slow");
			  return false;
			});

			$(".notification-quit-blue").click(function(){
			  $(".notification-box-blue").hide("slow");
			  return false;
			});

			$('.dissmiss-notification-box').click(function(){
				$('.hide-body').fadeOut();
				$('.notification-main-box').fadeOut();
				return false;
			});

			$('a.back-up').click(function(){
				 $('html, body').animate({scrollTop: '0px'}, 300);
				 return false;
			});

		});<commit_msg>Initial build<commit_after>    // GA code
	var gaPlugin;

	function initialize() {
		document.addEventListener("deviceready", onDeviceReady, true);
	}

	function onDeviceReady() {
		gaPlugin = window.plugins.gaPlugin;

		// Note: A request for permission is REQUIRED by google. You probably want to do this just once, though, and remember the answer for subsequent runs.
		navigator.notification.confirm('Artist colony would like your permission to collect usage data. No personal or user identifiable data will be collected.', permissionCallback, 'Attention', 'Allow,Deny');
	}

	function permissionCallback (button) {
		if (button === 1)
			gaPlugin.init(nativePluginResultHandler, nativePluginErrorHandler, "UA-108603-3", 10);
	}

	function nativePluginResultHandler (result) {
		//alert('nativePluginResultHandler - '+result);
		console.log('nativePluginResultHandler: '+result);

	}

	function nativePluginErrorHandler (error) {
		//alert('nativePluginErrorHandler - '+error);
		console.log('nativePluginErrorHandler: '+error);
	}

	function TrackButtonClicked() {
		gaPlugin.trackEvent( nativePluginResultHandler, nativePluginErrorHandler, "Button", "Click", "event only", 1);
	}

	function VariableButtonClicked() {
		// Set a dimension based on index and value. Make sure you have added a dimension in the GA dashboard to the
		// default property for the passed in index, and your desired scope. GA allows up to 20 dimensions for a free account
		gaPlugin.setVariable( nativePluginResultHandler, nativePluginErrorHandler, 1, "Purple");

		// dimensions are are passed to the next event sent to GA. go ahead and fire off an event with the label (key) of your choice
		// In this example, the label for custom dimension 1 will show up in the dashboard as "favoriteColor". This is much more efficent
		// than the old custom variable method introduced in V1, (plus you get 20 free dimensions vs 5 free custom variables)
		gaPlugin.trackEvent( nativePluginResultHandler, nativePluginErrorHandler, "event with variable", "set variable", "favoriteColor", 1);
	}

	function PageButtonClicked() {
		gaPlugin.trackPage( nativePluginResultHandler, nativePluginErrorHandler, "some.url.com");
	}

	function goingAway() {
		gaPlugin.exit(nativePluginResultHandler, nativePluginErrorHandler);
	}

	// photoswipe lib call
	(function(window, PhotoSwipe){
		document.addEventListener('DOMContentLoaded', function(){
			var
				options = {
					getImageCaption: function(el){
						var captionText, captionEl;

						// Get the caption from the alt tag
						if (el.nodeName === "IMG"){
							captionText = el.getAttribute('alt');
						}
						var i, j, childEl;
						for (i=0, j=el.childNodes.length; i<j; i++){
							childEl = el.childNodes[i];
							if (el.childNodes[i].nodeName === 'IMG'){
								captionText = childEl.getAttribute('alt');
							}
						}

						// Return a DOM element with custom styling
						captionEl = document.createElement('div');
						captionEl.style.cssText = 'font-weight: bold; padding: 5px;';
						captionEl.appendChild(document.createTextNode(captionText));
						return captionEl;

					}
				},
				instance = PhotoSwipe.attach( window.document.querySelectorAll('#gallery a'), options );
		}, false);
	}(window, window.Code.PhotoSwipe));

	// init
	$(document).ready(function(){

		(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")

			var slider = new Swipe(document.getElementById('slider'));

			$('.next-but-swipe').click(function(){
				slider.next();
				return false;
			});

			$('.prev-but-swipe').click(function(){
				slider.prev();
				return false;
			});

			$('.toggle-plus').click(function(){
				$(this).toggleClass('toggle-plus-selected');
				$(this).parent().find('.toggle-content').toggle(100);
				return false;
			});

			$('.toggle-arrow').click(function(){
				$(this).toggleClass('toggle-arrow-selected');
				$(this).parent().find('.toggle-content').toggle(100);
				return false;
			});

			$('.checkbox-1').click(function(){
				$(this).toggleClass('checkbox-1-selected')
				return false;
			});

			$('.checkbox-2').click(function(){
				$(this).toggleClass('checkbox-2-selected')
				return false;
			});

			$('.radio-1').click(function(){
				$(this).toggleClass('radio-1-selected')
				return false;
			});

			$('.radio-2').click(function(){
				$(this).toggleClass('radio-2-selected')
				return false;
			});

			$('#one').click(function(){
				$('#one').addClass('selected-page-nav');
				$('#two, #three').removeClass('selected-page-nav');
				$('.two, .three').hide();
				$('.one').fadeIn();
				return false;
			});

			$('#two').click(function(){
				$('#two').addClass('selected-page-nav');
				$('#one, #three').removeClass('selected-page-nav');
				$('.one, .three').hide();
				$('.two').fadeIn();
				return false;
			});

			$('#three').click(function(){
				$('#three').addClass('selected-page-nav');
				$('#two, #one').removeClass('selected-page-nav');
				$('.two, .one').hide();
				$('.three').fadeIn();
				return false;
			});

			$('.navigation').animate({height:'toggle'},0);
			$('.navigation-strip').click(function(){
				$('.navigation').animate({height:'toggle'});
				$('.navigation-strip').toggleClass('selected-navigation-strip');
				return false;
			});

			$('#no').click(function(){
				$('.click-interface').show();
				$('.drag-interface').hide();
				$('.no').hide();
				$('.yes').show();
				return false;
			});

			$('#yes').click(function(){
				$('.click-interface').hide();
				$('.drag-interface').show();
				$('.no').show();
				$('.yes').hide();
				return false;
			});

			$(".notification-quit-red").click(function(){
			  $(".notification-box-red").hide("slow");
			  return false;
			});

			$(".notification-quit-green").click(function(){
			  $(".notification-box-green").hide("slow");
			  return false;
			});

			$(".notification-quit-yellow").click(function(){
			  $(".notification-box-yellow").hide("slow");
			  return false;
			});

			$(".notification-quit-blue").click(function(){
			  $(".notification-box-blue").hide("slow");
			  return false;
			});

			$('.dissmiss-notification-box').click(function(){
				$('.hide-body').fadeOut();
				$('.notification-main-box').fadeOut();
				return false;
			});

			$('a.back-up').click(function(){
				 $('html, body').animate({scrollTop: '0px'}, 300);
				 return false;
			});

		});<|endoftext|>