<commit_before>var bb = bb || {};

bb.DataManager = function(dataStore) {
  this.accountService = new bb.DataService('accounts', dataStore);
  this.budgetService = new bb.DataService('budget', dataStore);
  this.categoryService = new bb.DataService('categories', dataStore);
  this.incomeSourceService = new bb.DataService('incomeSources', dataStore);
  this.payeeService = new bb.DataService('payees', dataStore);
  this.transactionService = new bb.DataService('transactions', dataStore);
};

bb.DataManager.prototype.accountNameContains = function(accountId, lowerCaseQuery) {
  const accountName = this.getAccountNameById(accountId);
  return accountName && (accountName.toLowerCase().indexOf(lowerCaseQuery) >= 0);
};

bb.DataManager.prototype.addAccount = function(account) {
  return this.accountService.add(account);
};

bb.DataManager.prototype.addCategory = function(category) {
  return this.categoryService.add(category);
};

bb.DataManager.prototype.addTransactionToList = function(id, entry) {
  return this.transactionService.addToList(id, entry);
};

bb.DataManager.prototype.ensureIncomeSourceExists = function(name) {
  this.incomeSourceService.setPropertyOfEntryTo('byName', name, true);
};

bb.DataManager.prototype.ensurePayeeExists = function(name) {
  this.payeeService.setPropertyOfEntryTo('byName', name, true);
};

bb.DataManager.prototype.getAccountById = function(id) {
  return this.accountService.getById(id);
};

bb.DataManager.prototype.getAccountNameById = function(id) {
  var account = this.getAccountById(id);
  return (account ? account.name : undefined);
};

bb.DataManager.prototype.getAccounts = function() {
  return this.accountService.getAll();
};

bb.DataManager.prototype.getBudgetForMonth = function(yearMonthId) {
  yearMonthId = yearMonthId || bb.Date.getCurrentYearMonthString();
  return this.budgetService.getById(yearMonthId) || {};
};

bb.DataManager.prototype.getCategories = function() {
  return this.categoryService.getAll();
};

bb.DataManager.prototype.getCategoryById = function(categoryId) {
  return this.categoryService.getById(categoryId);
};

bb.DataManager.prototype.getCategoryName = function(categoryId) {
  var category = this.categoryService.getById(categoryId);
  return (category ? category.name : undefined);
};

bb.DataManager.prototype.getDefaultAccountId = function() {
  var accountIds = Object.keys(this.getAccounts());
  return (accountIds.length > 0) ? accountIds[0] : undefined;
};

bb.DataManager.prototype.getTransactionById = function(id) {
  return this.transactionService.getById(id);
};

bb.DataManager.prototype.getTransactions = function() {
  return this.transactionService.getAll();
};

bb.DataManager.prototype.getTransactionsMatching = function(query) {
  if (query === '' || query == undefined) {
    return [];
  }

  var matchingTransactions = [];
  var dm = this;

  for (const yearMonthId of Object.keys(this.getTransactions())) {
    var monthTransactions = this.getTransactionById(yearMonthId);

    var monthMatches = monthTransactions.filter(function(transaction) {
      return bb.Transaction.isTransactionMatchFor(
        transaction,
        query,
        dm.accountNameContains.bind(dm)
      );
    });

    matchingTransactions = matchingTransactions.concat(monthMatches);
  }

  return matchingTransactions;
};

bb.DataManager.prototype.isAccountNameInUse = function(name) {
  return this.accountService.isNameInUse(name);
};

bb.DataManager.prototype.isCategoryNameInUse = function(name) {
  return this.categoryService.isNameInUse(name);
};

bb.DataManager.prototype.listIncomeSourcesByName = function() {
  return this.incomeSourceService.getKeysFrom('byName');
};

bb.DataManager.prototype.listPayeesByName = function() {
  return this.payeeService.getKeysFrom('byName');
};

bb.DataManager.prototype.renameAccount = function(id, newName) {
  return this.accountService.rename(id, newName);
};

bb.DataManager.prototype.renameCategory = function(id, newName) {
  return this.categoryService.rename(id, newName);
};

bb.DataManager.prototype.updateCategory = function(category) {
  return this.categoryService.update(category);
};
<commit_msg>Simplify check for empty search query.<commit_after>var bb = bb || {};

bb.DataManager = function(dataStore) {
  this.accountService = new bb.DataService('accounts', dataStore);
  this.budgetService = new bb.DataService('budget', dataStore);
  this.categoryService = new bb.DataService('categories', dataStore);
  this.incomeSourceService = new bb.DataService('incomeSources', dataStore);
  this.payeeService = new bb.DataService('payees', dataStore);
  this.transactionService = new bb.DataService('transactions', dataStore);
};

bb.DataManager.prototype.accountNameContains = function(accountId, lowerCaseQuery) {
  const accountName = this.getAccountNameById(accountId);
  return accountName && (accountName.toLowerCase().indexOf(lowerCaseQuery) >= 0);
};

bb.DataManager.prototype.addAccount = function(account) {
  return this.accountService.add(account);
};

bb.DataManager.prototype.addCategory = function(category) {
  return this.categoryService.add(category);
};

bb.DataManager.prototype.addTransactionToList = function(id, entry) {
  return this.transactionService.addToList(id, entry);
};

bb.DataManager.prototype.ensureIncomeSourceExists = function(name) {
  this.incomeSourceService.setPropertyOfEntryTo('byName', name, true);
};

bb.DataManager.prototype.ensurePayeeExists = function(name) {
  this.payeeService.setPropertyOfEntryTo('byName', name, true);
};

bb.DataManager.prototype.getAccountById = function(id) {
  return this.accountService.getById(id);
};

bb.DataManager.prototype.getAccountNameById = function(id) {
  var account = this.getAccountById(id);
  return (account ? account.name : undefined);
};

bb.DataManager.prototype.getAccounts = function() {
  return this.accountService.getAll();
};

bb.DataManager.prototype.getBudgetForMonth = function(yearMonthId) {
  yearMonthId = yearMonthId || bb.Date.getCurrentYearMonthString();
  return this.budgetService.getById(yearMonthId) || {};
};

bb.DataManager.prototype.getCategories = function() {
  return this.categoryService.getAll();
};

bb.DataManager.prototype.getCategoryById = function(categoryId) {
  return this.categoryService.getById(categoryId);
};

bb.DataManager.prototype.getCategoryName = function(categoryId) {
  var category = this.categoryService.getById(categoryId);
  return (category ? category.name : undefined);
};

bb.DataManager.prototype.getDefaultAccountId = function() {
  var accountIds = Object.keys(this.getAccounts());
  return (accountIds.length > 0) ? accountIds[0] : undefined;
};

bb.DataManager.prototype.getTransactionById = function(id) {
  return this.transactionService.getById(id);
};

bb.DataManager.prototype.getTransactions = function() {
  return this.transactionService.getAll();
};

bb.DataManager.prototype.getTransactionsMatching = function(query) {
  if (!query) {
    return [];
  }

  var matchingTransactions = [];
  var dm = this;

  for (const yearMonthId of Object.keys(this.getTransactions())) {
    var monthTransactions = this.getTransactionById(yearMonthId);

    var monthMatches = monthTransactions.filter(function(transaction) {
      return bb.Transaction.isTransactionMatchFor(
        transaction,
        query,
        dm.accountNameContains.bind(dm)
      );
    });

    matchingTransactions = matchingTransactions.concat(monthMatches);
  }

  return matchingTransactions;
};

bb.DataManager.prototype.isAccountNameInUse = function(name) {
  return this.accountService.isNameInUse(name);
};

bb.DataManager.prototype.isCategoryNameInUse = function(name) {
  return this.categoryService.isNameInUse(name);
};

bb.DataManager.prototype.listIncomeSourcesByName = function() {
  return this.incomeSourceService.getKeysFrom('byName');
};

bb.DataManager.prototype.listPayeesByName = function() {
  return this.payeeService.getKeysFrom('byName');
};

bb.DataManager.prototype.renameAccount = function(id, newName) {
  return this.accountService.rename(id, newName);
};

bb.DataManager.prototype.renameCategory = function(id, newName) {
  return this.categoryService.rename(id, newName);
};

bb.DataManager.prototype.updateCategory = function(category) {
  return this.categoryService.update(category);
};
<|endoftext|>


<commit_before>// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'app/bower_components/underscore/underscore.js',
  'app/bower_components/jquery/jquery.js',
  'app/bower_components/angular/angular.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-route/angular-route.js',
  'app/bower_components/jscrollpane/script/jquery.mousewheel.js',
  'app/bower_components/jscrollpane/script/jquery.jscrollpane.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js',
  'test/lib/**/*.js',
  'test/unit/**/*.js',
  'test/e2e/**/*.js'
];

// list of files to exclude
exclude = [];

// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];

// web server port
port = 8080;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = false;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Chrome','Firefox','Safari'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
<commit_msg>singleRun und autoWatch fuer Ausfuehrung der Tests bei Speichern anpassen.<commit_after>// Karma configuration

// base path, that will be used to resolve files and exclude
basePath = '';

// list of files / patterns to load in the browser
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'app/bower_components/underscore/underscore.js',
  'app/bower_components/jquery/jquery.js',
  'app/bower_components/angular/angular.js',
  'app/bower_components/angular-mocks/angular-mocks.js',
  'app/bower_components/angular-route/angular-route.js',
  'app/bower_components/jscrollpane/script/jquery.mousewheel.js',
  'app/bower_components/jscrollpane/script/jquery.jscrollpane.js',
  'app/scripts/*.js',
  'app/scripts/**/*.js',
  'test/lib/**/*.js',
  'test/unit/**/*.js'
];

// list of files to exclude
exclude = [];

// test results reporter to use
// possible values: dots || progress || growl
reporters = ['progress'];

// web server port
port = 8081;

// cli runner port
runnerPort = 9100;

// enable / disable colors in the output (reporters and logs)
colors = true;

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;

// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers = ['Chrome','Firefox','Safari'];

// If browser does not capture in given timeout [ms], kill it
captureTimeout = 5000;

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = false;
<|endoftext|>


<commit_before>define(["Ti/_/declare", "Ti/_/lang", "Ti/UI", "Ti/UI/View"], function(declare, lang, UI, View) {

	var sessionId = Math.random(),
		historyStack = [],
		hist = window.history,
		POP_STATE_WAITING_FOR_OPERATION = -1,
		POP_STATE_UNDOING_OPERATION = -2,
		POP_STATE_PUSHING = -3,
		POP_STATE_REWINDING_HISTORY = -4,
		POP_STATE_RESETTING = -5,
		historyPopState = POP_STATE_WAITING_FOR_OPERATION,
		startingHistoryLength = hist.length,
		prefix = location.href.split("#"), // Strip off any hash incase the user reloaded the page and a hash currently exists
		startingHash = prefix[1],
		prefix = prefix[0],
		widgetToClose;

	function pushToHistory(widget) {
		historyPopState = POP_STATE_PUSHING;
		historyStack.push(widget);
		location.href = prefix + "#" + sessionId + "," + widget.widgetId;
	}

	function removeFromHistory(widget, recursive) {
		if (historyPopState === POP_STATE_WAITING_FOR_OPERATION) {
			var historyStackIndex = historyStack.indexOf(widget);
			if (~historyStackIndex) {
				historyStack.splice(historyStackIndex,recursive ? historyStack.length - historyStackIndex : 1);
				historyPopState = POP_STATE_REWINDING_HISTORY;
				hist.go(-historyStack.length - (hist.length - startingHistoryLength - historyStack.length));
			}
		}
	}

	window.addEventListener("hashchange", function(e) {
		function hashIteration(){
			if (historyPopState < historyStack.length) {
				// Check if we need to skip the first state. Some browsers will view the first window as the root (i.e. they skip the hashless version), meaning we need to skip it too
				var widget = historyStack[historyPopState++],
					newLocation = prefix + "#" + sessionId + "," + widget.widgetId;
				if (location.href === newLocation) {
					hashIteration();
				} else {
					location.href = newLocation;
				}
			} else {
				var currentWidget = historyStack[historyPopState - 1];
				currentWidget && (document.title = currentWidget.title || require.config.app.name);
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
			}
		}
		if (historyPopState >= 0) {
			hashIteration();
			return;
		}
		switch(historyPopState) {
			case POP_STATE_WAITING_FOR_OPERATION:
				// We need to undo the previous operation and redo it
				var listItem = window.location.href.split("#")[1];
				listItem && (listItem = listItem.split(",")[1]);
				if (hist.length === startingHistoryLength) {
					listItem = historyStack[0].widgetId;
				}
				if (listItem) {
					var historyStackIndex = -1,
						historyStackLength = historyStack.length,
						widget;
					historyPopState = POP_STATE_UNDOING_OPERATION;
					for (var i = 0; i < historyStackLength; i++) {
						widget = historyStack[i];
						if (listItem === widget.widgetId) {
							historyStackIndex = i + 1;
							break;
						}
					}
					if (~historyStackIndex) {
						historyPopState = POP_STATE_WAITING_FOR_OPERATION;
						return;
					}
					for (i = historyStackIndex; i < historyStackLength; i++) {
						historyStack[i].close();
					}
					widgetToClose = historyStack[historyStackIndex];
					hist.go(historyStackLength - historyStackIndex);
				}
				break;
			case POP_STATE_UNDOING_OPERATION:
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
				removeFromHistory(widgetToClose, true);
				break;
			case POP_STATE_PUSHING:
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
				break;
			case POP_STATE_REWINDING_HISTORY:
				historyPopState = POP_STATE_RESETTING;
				location.href = prefix + "#history_reset";
				break;
			case POP_STATE_RESETTING:
				historyPopState = 0;
				hist.back();
				break;
		}
	});

	return declare("Ti._.UI.SuperView", View, {

		constructor: function() {
			this.addEventListener("focus", lang.hitch(this, function() {
				this.setWindowTitle(this.title);
			}));
		},

		destroy: function() {
			this.close();
			View.prototype.destroy.apply(this, arguments);
		},

		open: function(args) {
			if (!this._opened) {
				this._opened = 1;
				UI._addWindow(this, 1).show();

				pushToHistory(this);

				this.fireEvent("open");
				this.fireEvent("focus", this._state);
			}
		},

		close: function(args) {
			if (this._opened) {
				this._opened = 0;
				UI._removeWindow(this);

				if (historyPopState === POP_STATE_WAITING_FOR_OPERATION) {
					removeFromHistory(this);
				}

				this.fireEvent("close");
			}
		},

		setWindowTitle: function(title) {
			document.title = title || require.config.app.name;
			return title;
		}

	});

});<commit_msg>[timob-7566] Bug fix.<commit_after>define(["Ti/_/declare", "Ti/_/lang", "Ti/UI", "Ti/UI/View"], function(declare, lang, UI, View) {

	var sessionId = Math.random(),
		historyStack = [],
		hist = window.history,
		POP_STATE_WAITING_FOR_OPERATION = -1,
		POP_STATE_UNDOING_OPERATION = -2,
		POP_STATE_PUSHING = -3,
		POP_STATE_REWINDING_HISTORY = -4,
		POP_STATE_RESETTING = -5,
		historyPopState = POP_STATE_WAITING_FOR_OPERATION,
		startingHistoryLength = hist.length,
		prefix = location.href.split("#"), // Strip off any hash incase the user reloaded the page and a hash currently exists
		startingHash = prefix[1],
		prefix = prefix[0],
		widgetToClose;

	function pushToHistory(widget) {
		historyPopState = POP_STATE_PUSHING;
		historyStack.push(widget);
		location.href = prefix + "#" + sessionId + "," + widget.widgetId;
	}

	function removeFromHistory(widget, recursive) {
		if (historyPopState === POP_STATE_WAITING_FOR_OPERATION) {
			var historyStackIndex = historyStack.indexOf(widget);
			if (~historyStackIndex) {
				historyStack.splice(historyStackIndex,recursive ? historyStack.length - historyStackIndex : 1);
				historyPopState = POP_STATE_REWINDING_HISTORY;
				hist.go(-historyStack.length - (hist.length - startingHistoryLength - historyStack.length));
			}
		}
	}

	window.addEventListener("hashchange", function(e) {
		function hashIteration(){
			if (historyPopState < historyStack.length) {
				// Check if we need to skip the first state. Some browsers will view the first window as the root (i.e. they skip the hashless version), meaning we need to skip it too
				var widget = historyStack[historyPopState++],
					newLocation = prefix + "#" + sessionId + "," + widget.widgetId;
				if (location.href === newLocation) {
					hashIteration();
				} else {
					location.href = newLocation;
				}
			} else {
				var currentWidget = historyStack[historyPopState - 1];
				currentWidget && (document.title = currentWidget.title || require.config.app.name);
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
			}
		}
		if (historyPopState >= 0) {
			hashIteration();
			return;
		}
		switch(historyPopState) {
			case POP_STATE_WAITING_FOR_OPERATION:
				// We need to undo the previous operation and redo it
				var listItem = window.location.href.split("#")[1];
				listItem && (listItem = listItem.split(",")[1]);
				if (hist.length === startingHistoryLength) {
					listItem = historyStack[0].widgetId;
				}
				if (listItem) {
					var historyStackIndex = -1,
						historyStackLength = historyStack.length,
						widget;
					historyPopState = POP_STATE_UNDOING_OPERATION;
					for (var i = 0; i < historyStackLength; i++) {
						widget = historyStack[i];
						if (listItem === widget.widgetId) {
							historyStackIndex = i + 1;
							break;
						}
					}
					if (historyStackIndex === -1) {
						historyPopState = POP_STATE_WAITING_FOR_OPERATION;
						return;
					}
					for (i = historyStackIndex; i < historyStackLength; i++) {
						historyStack[i].close();
					}
					widgetToClose = historyStack[historyStackIndex];
					hist.go(historyStackLength - historyStackIndex);
				}
				break;
			case POP_STATE_UNDOING_OPERATION:
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
				removeFromHistory(widgetToClose, true);
				break;
			case POP_STATE_PUSHING:
				historyPopState = POP_STATE_WAITING_FOR_OPERATION;
				break;
			case POP_STATE_REWINDING_HISTORY:
				historyPopState = POP_STATE_RESETTING;
				location.href = prefix + "#history_reset";
				break;
			case POP_STATE_RESETTING:
				historyPopState = 0;
				hist.back();
				break;
		}
	});

	return declare("Ti._.UI.SuperView", View, {

		constructor: function() {
			this.addEventListener("focus", lang.hitch(this, function() {
				this.setWindowTitle(this.title);
			}));
		},

		destroy: function() {
			this.close();
			View.prototype.destroy.apply(this, arguments);
		},

		open: function(args) {
			if (!this._opened) {
				this._opened = 1;
				UI._addWindow(this, 1).show();

				pushToHistory(this);

				this.fireEvent("open");
				this.fireEvent("focus", this._state);
			}
		},

		close: function(args) {
			if (this._opened) {
				this._opened = 0;
				UI._removeWindow(this);

				if (historyPopState === POP_STATE_WAITING_FOR_OPERATION) {
					removeFromHistory(this);
				}

				this.fireEvent("close");
			}
		},

		setWindowTitle: function(title) {
			document.title = title || require.config.app.name;
			return title;
		}

	});

});<|endoftext|>


<commit_before>/*
 * Copyright (c) 2014 airbug inc. http://airbug.com
 *
 * bugpack may be freely distributed under the MIT license.
 */

//-------------------------------------------------------------------------------
// Requires
//-------------------------------------------------------------------------------

var buildbug            = require("buildbug");

//-------------------------------------------------------------------------------
// Simplify References
//-------------------------------------------------------------------------------

var buildProject        = buildbug.buildProject;
var buildProperties     = buildbug.buildProperties;
var buildScript         = buildbug.buildScript;
var buildTarget         = buildbug.buildTarget;
var enableModule        = buildbug.enableModule;
var parallel            = buildbug.parallel;
var series              = buildbug.series;
var targetTask          = buildbug.targetTask;

//-------------------------------------------------------------------------------
// Enable Modules
//-------------------------------------------------------------------------------

var aws                 = enableModule("aws");
var bugpack             = enableModule('bugpack');
var bugunit             = enableModule('bugunit');
var core                = enableModule('core');
var lintbug             = enableModule("lintbug");
var nodejs              = enableModule('nodejs');
var uglifyjs            = enableModule("uglifyjs");

//-------------------------------------------------------------------------------
// Values
//-------------------------------------------------------------------------------

var version             = "0.1.14";

//-------------------------------------------------------------------------------
// Declare Properties
//-------------------------------------------------------------------------------

buildProperties({
    node: {
        packageJson: {
            name: "bugpack",
            version: version,
            description: "Package manager and loader to help make browser and node js package loading consistent and easier",
            main: "./lib/BugPackApi.js",
            author: "Brian Neisler <brian@airbug.com>",
            repository: {
                type: "git",
                url: "https://github.com/airbug/bugpack.git"
            },
            bugs: {
                url: "https://github.com/airbug/bugpack/issues"
            },
            licenses: [
                {
                    type : "MIT",
                    url : "https://raw.githubusercontent.com/airbug/bugpack/master/LICENSE"
                }
            ]
        },
        sourcePaths: [
            "./projects/bugpack-node/js/src"
        ],
        readmePath: "./README.md"
    },
    web: {
        name: "bugpack",
        version: version,
        sourcePaths: [
            "./projects/bugpack-client/js/src/BugPackKey.js",
            "./projects/bugpack-client/js/src/BugPackPackage.js",
            "./projects/bugpack-client/js/src/BugPackLibrary.js",
            "./projects/bugpack-client/js/src/BugPackSource.js",
            "./projects/bugpack-client/js/src/BugPackSourceProcessor.js",
            "./projects/bugpack-client/js/src/BugPackRegistryEntry.js",
            "./projects/bugpack-client/js/src/BugPackRegistry.js",
            "./projects/bugpack-client/js/src/BugPackRegistryFile.js",
            "./projects/bugpack-client/js/src/BugPackContext.js",
            "./projects/bugpack-client/js/src/BugPackApi.js"
        ],
        outputFile: "{{distPath}}/{{web.name}}-{{web.version}}.js",
        outputMinFile: "{{distPath}}/{{web.name}}-{{web.version}}.min.js"
    },
    lint: {
        targetPaths: [
            "."
        ],
        ignorePatterns: [
            ".*\\.buildbug$",
            ".*\\.bugunit$",
            ".*\\.git$",
            ".*node_modules$"
        ]
    }
});

//-------------------------------------------------------------------------------
// BuildTargets
//-------------------------------------------------------------------------------

// Clean BuildTarget
//-------------------------------------------------------------------------------

buildTarget("clean").buildFlow(
    targetTask("clean")
);

// Local BuildTarget
//-------------------------------------------------------------------------------

buildTarget("local").buildFlow(

    series([
        targetTask("clean"),
        targetTask('lint', {
            properties: {
                targetPaths: buildProject.getProperty("lint.targetPaths"),
                ignores: buildProject.getProperty("lint.ignorePatterns"),
                lintTasks: [
                    "cleanupExtraSpacingAtEndOfLines",
                    "ensureNewLineEnding",
                    "indentEqualSignsForPreClassVars",
                    "orderBugpackRequires",
                    "orderRequireAnnotations",
                    "updateCopyright"
                ]
            }
        }),
        parallel([
            series([
                targetTask("createNodePackage", {
                    properties: {
                        packageJson: buildProject.getProperty("node.packageJson"),
                        packagePaths: {
                            "./": [buildProject.getProperty("node.readmePath")],
                            "./lib": buildProject.getProperty("node.sourcePaths")
                        }
                    }
                }),
                targetTask("packNodePackage", {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                }),
                targetTask("s3PutFile", {
                    init: function(task, buildProject, properties) {
                        var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("node.packageJson.name"),
                            buildProject.getProperty("node.packageJson.version"));
                        task.updateProperties({
                            file: packedNodePackage.getFilePath(),
                            options: {
                                acl: 'public-read',
                                encrypt: true
                            }
                        });
                    },
                    properties: {
                        bucket: "{{local-bucket}}"
                    }
                })
            ]),
            series([
                targetTask("concat", {
                    properties: {
                        sources: buildProject.getProperty("web.sourcePaths"),
                        outputFile: "{{web.outputFile}}"
                    }
                }),
                parallel([
                    targetTask("s3PutFile", {
                        properties: {
                            file:  "{{web.outputFile}}",
                            options: {
                                acl: 'public-read',
                                gzip: true
                            },
                            bucket: "{{local-bucket}}"
                        }
                    }),
                    series([
                        targetTask("uglifyjsMinify", {
                            properties: {
                                sources: ["{{web.outputFile}}"],
                                outputFile: "{{web.outputMinFile}}"
                            }
                        }),
                        targetTask("s3PutFile", {
                            properties: {
                                file:  "{{web.outputMinFile}}",
                                options: {
                                    acl: 'public-read',
                                    gzip: true
                                },
                                bucket: "{{local-bucket}}"
                            }
                        })
                    ])
                ])
            ])
        ])
    ])
).makeDefault();

// Prod BuildTarget
//-------------------------------------------------------------------------------

buildTarget("prod").buildFlow(
    series([
        targetTask("clean"),
        targetTask('lint', {
            properties: {
                targetPaths: buildProject.getProperty("lint.targetPaths"),
                ignores: buildProject.getProperty("lint.ignorePatterns"),
                lintTasks: [
                    "cleanupExtraSpacingAtEndOfLines",
                    "ensureNewLineEnding",
                    "indentEqualSignsForPreClassVars",
                    "orderBugpackRequires",
                    "orderRequireAnnotations",
                    "updateCopyright"
                ]
            }
        }),
        parallel([
            series([
                targetTask("createNodePackage", {
                    properties: {
                        packageJson: buildProject.getProperty("node.packageJson"),
                        packagePaths: {
                            "./": [buildProject.getProperty("node.readmePath")],
                            "./lib": buildProject.getProperty("node.sourcePaths")
                        }
                    }
                }),
                targetTask("packNodePackage", {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                }),
                targetTask("s3PutFile", {
                    init: function(task, buildProject, properties) {
                        var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("node.packageJson.name"),
                            buildProject.getProperty("node.packageJson.version"));
                        task.updateProperties({
                            file: packedNodePackage.getFilePath(),
                            options: {
                                acl: 'public-read',
                                encrypt: true
                            }
                        });
                    },
                    properties: {
                        bucket: "{{public-bucket}}"
                    }
                }),
                targetTask('npmConfigSet', {
                    properties: {
                        config: buildProject.getProperty("npmConfig")
                    }
                }),
                targetTask('npmAddUser'),
                targetTask('publishNodePackage', {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                })
            ]),
            series([
                targetTask("concat", {
                    properties: {
                        sources: buildProject.getProperty("web.sourcePaths"),
                        outputFile: "{{web.outputFile}}"
                    }
                }),
                parallel([
                    targetTask("s3PutFile", {
                        properties: {
                            file:  "{{web.outputFile}}",
                            options: {
                                acl: 'public-read',
                                gzip: true,
                                cacheControl: "max-age=31536000, public"
                            },
                            bucket: "{{public-bucket}}"
                        }
                    }),
                    series([
                        targetTask("uglifyjsMinify", {
                            properties: {
                                sources: ["{{web.outputFile}}"],
                                outputFile: "{{web.outputMinFile}}"
                            }
                        }),
                        targetTask("s3PutFile", {
                            properties: {
                                file:  "{{web.outputMinFile}}",
                                options: {
                                    acl: 'public-read',
                                    gzip: true,
                                    cacheControl: "max-age=31536000, public"
                                },
                                bucket: "{{public-bucket}}"
                            }
                        })
                    ])
                ])
            ])
        ])
    ])
);

//-------------------------------------------------------------------------------
// Build Scripts
//-------------------------------------------------------------------------------

buildScript({
    dependencies: [
        "bugcore",
        "bugflow",
        "bugfs"
    ],
    script: "./lintbug.js"
});
<commit_msg>Update buildbug script to use name and version propertis<commit_after>/*
 * Copyright (c) 2014 airbug inc. http://airbug.com
 *
 * bugpack may be freely distributed under the MIT license.
 */

//-------------------------------------------------------------------------------
// Requires
//-------------------------------------------------------------------------------

var buildbug            = require("buildbug");

//-------------------------------------------------------------------------------
// Simplify References
//-------------------------------------------------------------------------------

var buildProject        = buildbug.buildProject;
var buildProperties     = buildbug.buildProperties;
var buildScript         = buildbug.buildScript;
var buildTarget         = buildbug.buildTarget;
var enableModule        = buildbug.enableModule;
var parallel            = buildbug.parallel;
var series              = buildbug.series;
var targetTask          = buildbug.targetTask;

//-------------------------------------------------------------------------------
// Enable Modules
//-------------------------------------------------------------------------------

var aws                 = enableModule("aws");
var bugpack             = enableModule('bugpack');
var bugunit             = enableModule('bugunit');
var core                = enableModule('core');
var lintbug             = enableModule("lintbug");
var nodejs              = enableModule('nodejs');
var uglifyjs            = enableModule("uglifyjs");

//-------------------------------------------------------------------------------
// Values
//-------------------------------------------------------------------------------

var name                = "bugpack";
var version             = "0.1.14";

//-------------------------------------------------------------------------------
// Declare Properties
//-------------------------------------------------------------------------------

buildProperties({
    name: name,
    version: version
});

buildProperties({
    node: {
        packageJson: {
            name: "{{name}}",
            version: "{{version}}",
            description: "Package manager and loader to help make browser and node js package loading consistent and easier",
            main: "./lib/BugPackApi.js",
            author: "Brian Neisler <brian@airbug.com>",
            repository: {
                type: "git",
                url: "https://github.com/airbug/bugpack.git"
            },
            bugs: {
                url: "https://github.com/airbug/bugpack/issues"
            },
            licenses: [
                {
                    type : "MIT",
                    url : "https://raw.githubusercontent.com/airbug/bugpack/master/LICENSE"
                }
            ]
        },
        sourcePaths: [
            "./projects/bugpack-node/js/src"
        ],
        readmePath: "./README.md"
    },
    web: {
        name: "{{name}}",
        version: "{{version}}",
        sourcePaths: [
            "./projects/bugpack-client/js/src/BugPackKey.js",
            "./projects/bugpack-client/js/src/BugPackPackage.js",
            "./projects/bugpack-client/js/src/BugPackLibrary.js",
            "./projects/bugpack-client/js/src/BugPackSource.js",
            "./projects/bugpack-client/js/src/BugPackSourceProcessor.js",
            "./projects/bugpack-client/js/src/BugPackRegistryEntry.js",
            "./projects/bugpack-client/js/src/BugPackRegistry.js",
            "./projects/bugpack-client/js/src/BugPackRegistryFile.js",
            "./projects/bugpack-client/js/src/BugPackContext.js",
            "./projects/bugpack-client/js/src/BugPackApi.js"
        ],
        outputFile: "{{distPath}}/{{web.name}}-{{web.version}}.js",
        outputMinFile: "{{distPath}}/{{web.name}}-{{web.version}}.min.js"
    },
    lint: {
        targetPaths: [
            "."
        ],
        ignorePatterns: [
            ".*\\.buildbug$",
            ".*\\.bugunit$",
            ".*\\.git$",
            ".*node_modules$"
        ]
    }
});

//-------------------------------------------------------------------------------
// BuildTargets
//-------------------------------------------------------------------------------

// Clean BuildTarget
//-------------------------------------------------------------------------------

buildTarget("clean").buildFlow(
    targetTask("clean")
);

// Local BuildTarget
//-------------------------------------------------------------------------------

buildTarget("local").buildFlow(

    series([
        targetTask("clean"),
        targetTask('lint', {
            properties: {
                targetPaths: buildProject.getProperty("lint.targetPaths"),
                ignores: buildProject.getProperty("lint.ignorePatterns"),
                lintTasks: [
                    "cleanupExtraSpacingAtEndOfLines",
                    "ensureNewLineEnding",
                    "indentEqualSignsForPreClassVars",
                    "orderBugpackRequires",
                    "orderRequireAnnotations",
                    "updateCopyright"
                ]
            }
        }),
        parallel([
            series([
                targetTask("createNodePackage", {
                    properties: {
                        packageJson: buildProject.getProperty("node.packageJson"),
                        packagePaths: {
                            "./": [buildProject.getProperty("node.readmePath")],
                            "./lib": buildProject.getProperty("node.sourcePaths")
                        }
                    }
                }),
                targetTask("packNodePackage", {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                }),
                targetTask("s3PutFile", {
                    init: function(task, buildProject, properties) {
                        var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("node.packageJson.name"),
                            buildProject.getProperty("node.packageJson.version"));
                        task.updateProperties({
                            file: packedNodePackage.getFilePath(),
                            options: {
                                acl: 'public-read',
                                encrypt: true
                            }
                        });
                    },
                    properties: {
                        bucket: "{{local-bucket}}"
                    }
                })
            ]),
            series([
                targetTask("concat", {
                    properties: {
                        sources: buildProject.getProperty("web.sourcePaths"),
                        outputFile: "{{web.outputFile}}"
                    }
                }),
                parallel([
                    targetTask("s3PutFile", {
                        properties: {
                            file:  "{{web.outputFile}}",
                            options: {
                                acl: 'public-read',
                                gzip: true
                            },
                            bucket: "{{local-bucket}}"
                        }
                    }),
                    series([
                        targetTask("uglifyjsMinify", {
                            properties: {
                                sources: ["{{web.outputFile}}"],
                                outputFile: "{{web.outputMinFile}}"
                            }
                        }),
                        targetTask("s3PutFile", {
                            properties: {
                                file:  "{{web.outputMinFile}}",
                                options: {
                                    acl: 'public-read',
                                    gzip: true
                                },
                                bucket: "{{local-bucket}}"
                            }
                        })
                    ])
                ])
            ])
        ])
    ])
).makeDefault();

// Prod BuildTarget
//-------------------------------------------------------------------------------

buildTarget("prod").buildFlow(
    series([
        targetTask("clean"),
        targetTask('lint', {
            properties: {
                targetPaths: buildProject.getProperty("lint.targetPaths"),
                ignores: buildProject.getProperty("lint.ignorePatterns"),
                lintTasks: [
                    "cleanupExtraSpacingAtEndOfLines",
                    "ensureNewLineEnding",
                    "indentEqualSignsForPreClassVars",
                    "orderBugpackRequires",
                    "orderRequireAnnotations",
                    "updateCopyright"
                ]
            }
        }),
        parallel([
            series([
                targetTask("createNodePackage", {
                    properties: {
                        packageJson: buildProject.getProperty("node.packageJson"),
                        packagePaths: {
                            "./": [buildProject.getProperty("node.readmePath")],
                            "./lib": buildProject.getProperty("node.sourcePaths")
                        }
                    }
                }),
                targetTask("packNodePackage", {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                }),
                targetTask("s3PutFile", {
                    init: function(task, buildProject, properties) {
                        var packedNodePackage = nodejs.findPackedNodePackage(buildProject.getProperty("node.packageJson.name"),
                            buildProject.getProperty("node.packageJson.version"));
                        task.updateProperties({
                            file: packedNodePackage.getFilePath(),
                            options: {
                                acl: 'public-read',
                                encrypt: true
                            }
                        });
                    },
                    properties: {
                        bucket: "{{public-bucket}}"
                    }
                }),
                targetTask('npmConfigSet', {
                    properties: {
                        config: buildProject.getProperty("npmConfig")
                    }
                }),
                targetTask('npmAddUser'),
                targetTask('publishNodePackage', {
                    properties: {
                        packageName: "{{node.packageJson.name}}",
                        packageVersion: "{{node.packageJson.version}}"
                    }
                })
            ]),
            series([
                targetTask("concat", {
                    properties: {
                        sources: buildProject.getProperty("web.sourcePaths"),
                        outputFile: "{{web.outputFile}}"
                    }
                }),
                parallel([
                    targetTask("s3PutFile", {
                        properties: {
                            file:  "{{web.outputFile}}",
                            options: {
                                acl: 'public-read',
                                gzip: true,
                                cacheControl: "max-age=31536000, public"
                            },
                            bucket: "{{public-bucket}}"
                        }
                    }),
                    series([
                        targetTask("uglifyjsMinify", {
                            properties: {
                                sources: ["{{web.outputFile}}"],
                                outputFile: "{{web.outputMinFile}}"
                            }
                        }),
                        targetTask("s3PutFile", {
                            properties: {
                                file:  "{{web.outputMinFile}}",
                                options: {
                                    acl: 'public-read',
                                    gzip: true,
                                    cacheControl: "max-age=31536000, public"
                                },
                                bucket: "{{public-bucket}}"
                            }
                        })
                    ])
                ])
            ])
        ])
    ])
);

//-------------------------------------------------------------------------------
// Build Scripts
//-------------------------------------------------------------------------------

buildScript({
    dependencies: [
        "bugcore",
        "bugflow",
        "bugfs"
    ],
    script: "./lintbug.js"
});
<|endoftext|>


<commit_before>/**
 * iSlider Plugin
 * A simple, efficent mobile slider
 * @Author BEFE
 *
 */
iSlider.prototype.extend({

    _checkDevice: function() {
        var system = {
            win: false,
            mac: false,
            xll: false,
            ipad: false
        };
        var p = navigator.platform;
        system.win = p.indexOf('Win') === 0;
        system.mac = p.indexOf('Mac') === 0;
        system.xll = (p === 'X11') || (p.indexOf('Linux') === 0);
        system.ipad = (navigator.userAgent.match(/iPad/i) !== null) ? true : false;

        if (system.xll || system.ipad) {
            return true;
        }
        return false;
    },

    // * Dots Navgitation Menu
    // * @param {Object}      dotMenuOpts                参数集         Options
    // * @param {Boolean}     dotMenuOpts.isVertical     垂直/居中      Veritcal/Horizontal
    // * @param {String}      dotMenuOpts.width          宽度           width
    // * @param {String}      dotMenuOpts.height         高度           height
    // * @param {String}      dotMenuOpts.top            距高           top position
    // * @param {String}      dotMenuOpts.bottom         距底           bottom position
    // * @param {String}      dotMenuOpts.left           距左           left position
    // * @param {String}      dotMenuOpts.right          距右           right position
    // * @param {String}      dotMenuOpts.diameter       直径           diameter of points
    // * @param {String}      dotMenuOpts.borderColor    边框颜色        color of border
    // * @param {String}      dotMenuOpts.className      CSS类          css class

    renderDot: function(dotMenuOpts) {

        this.dotMenuOpts = dotMenuOpts || {};
        var data = this.data;
        var len = data.length;
        var wrap = this.wrap;
        var pointList = [];

        var indexLayer = document.createElement('ul');
        indexLayer.style.margin = 0;
        indexLayer.className = dotMenuOpts.className || '';
        if (dotMenuOpts.isVertical && dotMenuOpts.isVertical === true) {
            indexLayer.style.width = dotMenuOpts.width || '10%';
            indexLayer.style.height = dotMenuOpts.height || '50%';
            indexLayer.style.margin = 'auto 0';
        }
        else {
            indexLayer.style.width = dotMenuOpts.width || '50%';
            indexLayer.style.height = dotMenuOpts.height || '10%';
            indexLayer.style.margin = '0 auto';
            indexLayer.style.textAlign = 'center';
        }

        indexLayer.style.padding = '0';
        indexLayer.style.position = 'absolute';
        indexLayer.style.left = dotMenuOpts.left || '0';
        indexLayer.style.right = dotMenuOpts.right || '0';
        indexLayer.style.top = dotMenuOpts.top || '0';
        indexLayer.style.bottom = dotMenuOpts.bottom || '0';

        indexLayer.style.zIndex = '10000';

        wrap.parentNode.insertBefore(indexLayer, wrap.nextSibling);
        var fragment = document.createDocumentFragment();
        for (var i = 0; i < len; i++) {
            var point = document.createElement('li');
            point.id = 'point' + i;
            point.style.height = dotMenuOpts.diameter || '1em';
            point.style.width = dotMenuOpts.diameter || '1em';
            point.style.borderRadius = '50%';
            point.style.border = '1px solid';
            point.style.borderColor = dotMenuOpts.borderColor || '#fff';
            point.style.listStyleType = 'none';
            point.style.position = 'relative';
            point.style.margin = '5px';

            if (dotMenuOpts.isVertical && dotMenuOpts.isVertical === true) {
                point.style.display = 'block';
            }
            else {
                point.style.display = 'inline-block';
            }

            pointList.push(point);

            if (i === 0) {
                point.style.backgroundColor = dotMenuOpts.borderColor || '#fff';
            }
            this._bindTouchEvent(point, this._bindTouchEventDot);

            fragment.appendChild(point);
        }

        indexLayer.appendChild(fragment);
        this.pointList = pointList;
    },

    changeIndexDot: function() {

        var dotMenuOpts = this.dotMenuOpts;
        var idx = this.slideIndex;
        var data = this.data;
        var len = data.length;
        var pointList = this.pointList;

        for (var i = 0; i < len; i++) {
            pointList[i].style.backgroundColor = '';
            if (i === idx) {
                pointList[i].style.backgroundColor = dotMenuOpts.borderColor || '#fff';
            }
        }
    },

    _bindTouchEventDot: function(evt) {
        var self = this.self;
        var idx = parseInt(evt.target.id.substring(5));
        self.slideTo(idx);
    },

    // Button Navigation Menu
    // * @param {Object}      menuOpts                    参数集         Options
    // * @param {Boolean}     menuOpts.isVertical         垂直/居中      Veritcal/Horizontal
    // * @param {String}      menuOpts.width              宽度           width
    // * @param {String}      menuOpts.height             高度           height
    // * @param {String}      menuOpts.top                距高           top position
    // * @param {String}      menuOpts.bottom             距底           bottom position
    // * @param {String}      menuOpts.left               距左           left position
    // * @param {String}      menuOpts.right              距右           right position
    // * @param {String}      menuOpts.border             边框样式        style of border
    // * @param {String}      menuOpts.backgroundColor    背景颜色        background color
    // * @param {String}      menuOpts.className          CSS类          css class

    renderBtn: function(btnMenuOpts) {

        this.btnMenuOpts = btnMenuOpts || {};
        var wrap = this.wrap;
        var btnLayer = [];
        var btnLayerChild = [];
        var size = btnMenuOpts.width || '3em';
        var borderStyle = btnMenuOpts.border || '2px solid #fff';

        for (var i = 0; i < 2; i++) {
            btnLayer[i] = document.createElement('div');
            btnLayer[i].className = btnMenuOpts.className || '';
            btnLayer[i].style.position = 'absolute';
            btnLayer[i].style.width = size;
            btnLayer[i].style.height = size;
            btnLayer[i].style.cursor = 'pointer';
            btnLayer[i].style.backgroundColor = btnMenuOpts.backgroundColor || '#777';

            btnLayerChild[i] = document.createElement('div');
            btnLayerChild[i].style.position = 'absolute';
            btnLayerChild[i].style.width = '50%';
            btnLayerChild[i].style.height = '50%';
            btnLayerChild[i].style.borderTop = borderStyle;
            btnLayerChild[i].style.borderLeft = borderStyle;
            btnLayerChild[i].style.top = '0';
            btnLayerChild[i].style.bottom = '0';
            btnLayerChild[i].style.left = '0';
            btnLayerChild[i].style.right = '0';
            btnLayerChild[i].style.margin = 'auto';

            if (btnMenuOpts.isVertical) {
                btnLayer[i].style.left = '0';
                btnLayer[i].style.right = '0';
                btnLayer[i].style.margin = '0 auto';

                if (i === 0) {
                    btnLayer[i].style.top = btnMenuOpts.top || '2%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(45deg)';
                }
                else {
                    btnLayer[i].style.bottom = btnMenuOpts.bottom || '2%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(225deg)';
                }
            }
            else {
                btnLayer[i].style.top = '0';
                btnLayer[i].style.bottom = '0';
                btnLayer[i].style.margin = 'auto 0';

                if (i === 0) {
                    btnLayer[i].style.left = btnMenuOpts.left || '5%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(-45deg)';
                }
                else {
                    btnLayer[i].style.right = btnMenuOpts.right || '5%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(135deg)';
                }
            }
            btnLayer[i].direction = i;
            this._bindTouchEvent(btnLayer[i], this._bindTouchEventBtn);

            if (this.btnMenuOpts.isLooping === false) {
                if (this.slideIndex === 0) {
                    btnLayer[0].style.display = 'none';
                }
            }

            btnLayer[i].appendChild(btnLayerChild[i]);
            wrap.parentNode.insertBefore(btnLayer[i], wrap.nextSibling);
        }

        this.buttonLayer = btnLayer;
    },

    changeIndexBtn: function() {

        var btnMenuOpts = this.btnMenuOpts;
        var len = this.data.length;
        this.buttonLayer[0].style.display = 'block';
        this.buttonLayer[1].style.display = 'block';
        if (btnMenuOpts.isLooping === false) {
            if (this.slideIndex === len - 1) {
                this.buttonLayer[1].style.display = 'none';
            }
            else if (this.slideIndex === 0) {
                this.buttonLayer[0].style.display = 'none';
            }
        }
    },

    _bindTouchEventBtn: function(evt) {

        var self = this.self;
        self.direction = this.direction;

        if (self.direction === 0) {
            self.direction = -1;
        }
        else {
            self.direction = 1;
        }

        self.slideTo(self.slideIndex + self.direction);
    },

    _bindTouchEvent: function(target, func) {
        target.self = this;
        if (this._checkDevice() === true) {
            target.addEventListener('touchstart', func, false);
        }
        else {
            target.addEventListener('click', func, false);
        }
    }
});
<commit_msg>improve description in islider_plugin.js<commit_after>/**
 * iSlider Plugin
 * A simple, efficent mobile slider
 * @Author BEFE
 *
 */
iSlider.prototype.extend({

    _checkDevice: function() {
        var system = {
            win: false,
            mac: false,
            xll: false,
            ipad: false
        };
        var p = navigator.platform;
        system.win = p.indexOf('Win') === 0;
        system.mac = p.indexOf('Mac') === 0;
        system.xll = (p === 'X11') || (p.indexOf('Linux') === 0);
        system.ipad = (navigator.userAgent.match(/iPad/i) !== null) ? true : false;

        if (system.xll || system.ipad) {
            return true;
        }
        return false;
    },

    // * Dots Navgitation Menu
    // * @param {Object}      dotMenuOpts                参数集         Options
    // * @param {Boolean}     dotMenuOpts.isVertical     垂直/居中      Veritcal/Horizontal
    // * @param {String}      dotMenuOpts.width          宽度           width
    // * @param {String}      dotMenuOpts.height         高度           height
    // * @param {String}      dotMenuOpts.top            距高           top position
    // * @param {String}      dotMenuOpts.bottom         距底           bottom position
    // * @param {String}      dotMenuOpts.left           距左           left position
    // * @param {String}      dotMenuOpts.right          距右           right position
    // * @param {String}      dotMenuOpts.diameter       直径           diameter of points
    // * @param {String}      dotMenuOpts.borderColor    边框颜色        color of border
    // * @param {String}      dotMenuOpts.className      CSS类          css class

    renderDot: function(dotMenuOpts) {

        this.dotMenuOpts = dotMenuOpts || {};
        var data = this.data;
        var len = data.length;
        var wrap = this.wrap;
        var pointList = [];

        var indexLayer = document.createElement('ul');
        indexLayer.style.margin = 0;
        indexLayer.className = dotMenuOpts.className || '';
        if (dotMenuOpts.isVertical && dotMenuOpts.isVertical === true) {
            indexLayer.style.width = dotMenuOpts.width || '10%';
            indexLayer.style.height = dotMenuOpts.height || '50%';
            indexLayer.style.margin = 'auto 0';
        }
        else {
            indexLayer.style.width = dotMenuOpts.width || '50%';
            indexLayer.style.height = dotMenuOpts.height || '10%';
            indexLayer.style.margin = '0 auto';
            indexLayer.style.textAlign = 'center';
        }

        indexLayer.style.padding = '0';
        indexLayer.style.position = 'absolute';
        indexLayer.style.left = dotMenuOpts.left || '0';
        indexLayer.style.right = dotMenuOpts.right || '0';
        indexLayer.style.top = dotMenuOpts.top || '0';
        indexLayer.style.bottom = dotMenuOpts.bottom || '0';

        indexLayer.style.zIndex = '10000';

        wrap.parentNode.insertBefore(indexLayer, wrap.nextSibling);
        var fragment = document.createDocumentFragment();
        for (var i = 0; i < len; i++) {
            var point = document.createElement('li');
            point.id = 'point' + i;
            point.style.height = dotMenuOpts.diameter || '1em';
            point.style.width = dotMenuOpts.diameter || '1em';
            point.style.borderRadius = '50%';
            point.style.border = '1px solid';
            point.style.borderColor = dotMenuOpts.borderColor || '#fff';
            point.style.listStyleType = 'none';
            point.style.position = 'relative';
            point.style.margin = '5px';

            if (dotMenuOpts.isVertical && dotMenuOpts.isVertical === true) {
                point.style.display = 'block';
            }
            else {
                point.style.display = 'inline-block';
            }

            pointList.push(point);

            if (i === 0) {
                point.style.backgroundColor = dotMenuOpts.borderColor || '#fff';
            }
            this._bindTouchEvent(point, this._bindTouchEventDot);

            fragment.appendChild(point);
        }

        indexLayer.appendChild(fragment);
        this.pointList = pointList;
    },

    changeIndexDot: function() {

        var dotMenuOpts = this.dotMenuOpts;
        var idx = this.slideIndex;
        var data = this.data;
        var len = data.length;
        var pointList = this.pointList;

        for (var i = 0; i < len; i++) {
            pointList[i].style.backgroundColor = '';
            if (i === idx) {
                pointList[i].style.backgroundColor = dotMenuOpts.borderColor || '#fff';
            }
        }
    },

    _bindTouchEventDot: function(evt) {
        var self = this.self;
        var idx = parseInt(evt.target.id.substring(5));
        self.slideTo(idx);
    },

    // Button Navigation Menu
    // * @param {Object}      menuOpts                    参数集         Options
    // * @param {Boolean}     menuOpts.isVertical         垂直/居中      Veritcal/Horizontal
    // * @param {Boolean}     menuOpts.isLooping          内容循环       Looping content or not
    // * @param {String}      menuOpts.width              宽度           width
    // * @param {String}      menuOpts.height             高度           height
    // * @param {String}      menuOpts.top                距高           top position
    // * @param {String}      menuOpts.bottom             距底           bottom position
    // * @param {String}      menuOpts.left               距左           left position
    // * @param {String}      menuOpts.right              距右           right position
    // * @param {String}      menuOpts.border             边框样式        style of border
    // * @param {String}      menuOpts.backgroundColor    背景颜色        background color
    // * @param {String}      menuOpts.className          CSS类          css class

    renderBtn: function(btnMenuOpts) {

        this.btnMenuOpts = btnMenuOpts || {};
        var wrap = this.wrap;
        var btnLayer = [];
        var btnLayerChild = [];
        var size = btnMenuOpts.width || '3em';
        var borderStyle = btnMenuOpts.border || '2px solid #fff';

        for (var i = 0; i < 2; i++) {
            btnLayer[i] = document.createElement('div');
            btnLayer[i].className = btnMenuOpts.className || '';
            btnLayer[i].style.position = 'absolute';
            btnLayer[i].style.width = size;
            btnLayer[i].style.height = size;
            btnLayer[i].style.cursor = 'pointer';
            btnLayer[i].style.backgroundColor = btnMenuOpts.backgroundColor || '#777';

            btnLayerChild[i] = document.createElement('div');
            btnLayerChild[i].style.position = 'absolute';
            btnLayerChild[i].style.width = '50%';
            btnLayerChild[i].style.height = '50%';
            btnLayerChild[i].style.borderTop = borderStyle;
            btnLayerChild[i].style.borderLeft = borderStyle;
            btnLayerChild[i].style.top = '0';
            btnLayerChild[i].style.bottom = '0';
            btnLayerChild[i].style.left = '0';
            btnLayerChild[i].style.right = '0';
            btnLayerChild[i].style.margin = 'auto';

            if (btnMenuOpts.isVertical) {
                btnLayer[i].style.left = '0';
                btnLayer[i].style.right = '0';
                btnLayer[i].style.margin = '0 auto';

                if (i === 0) {
                    btnLayer[i].style.top = btnMenuOpts.top || '2%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(45deg)';
                }
                else {
                    btnLayer[i].style.bottom = btnMenuOpts.bottom || '2%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(225deg)';
                }
            }
            else {
                btnLayer[i].style.top = '0';
                btnLayer[i].style.bottom = '0';
                btnLayer[i].style.margin = 'auto 0';

                if (i === 0) {
                    btnLayer[i].style.left = btnMenuOpts.left || '5%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(-45deg)';
                }
                else {
                    btnLayer[i].style.right = btnMenuOpts.right || '5%';
                    btnLayerChild[i].style.webkitTransform = 'rotate(135deg)';
                }
            }
            btnLayer[i].direction = i;
            this._bindTouchEvent(btnLayer[i], this._bindTouchEventBtn);

            if (this.btnMenuOpts.isLooping === false) {
                if (this.slideIndex === 0) {
                    btnLayer[0].style.display = 'none';
                }
            }

            btnLayer[i].appendChild(btnLayerChild[i]);
            wrap.parentNode.insertBefore(btnLayer[i], wrap.nextSibling);
        }

        this.buttonLayer = btnLayer;
    },

    changeIndexBtn: function() {

        var btnMenuOpts = this.btnMenuOpts;
        var len = this.data.length;
        this.buttonLayer[0].style.display = 'block';
        this.buttonLayer[1].style.display = 'block';
        if (btnMenuOpts.isLooping === false) {
            if (this.slideIndex === len - 1) {
                this.buttonLayer[1].style.display = 'none';
            }
            else if (this.slideIndex === 0) {
                this.buttonLayer[0].style.display = 'none';
            }
        }
    },

    _bindTouchEventBtn: function(evt) {

        var self = this.self;
        self.direction = this.direction;

        if (self.direction === 0) {
            self.direction = -1;
        }
        else {
            self.direction = 1;
        }

        self.slideTo(self.slideIndex + self.direction);
    },

    _bindTouchEvent: function(target, func) {
        target.self = this;
        if (this._checkDevice() === true) {
            target.addEventListener('touchstart', func, false);
        }
        else {
            target.addEventListener('click', func, false);
        }
    }
});
<|endoftext|>


<commit_before>(function($){

	/* behaviour */
	$.hpanel = {
        settings: {},
		current_data: {},
        resize_start: function(event, mydata) {
			console.log('Panel ' + mydata.panel.attr('id') + ' started resizing');
			$(document).bind('mousemove', mydata, $.hpanel.resize_changed).
				bind('mouseup', mydata, $.hpanel.resize_stop);
			return false;
		},
		resize_changed: function(event) {
			var old_width = parseInt(event.data.panel.css('width'));
			var delta = event.pageX + event.data.hotspot_x - old_width;

			console.log('o: ' + (old_width) + ' pX: ' + event.pageX + ' hX: ' + event.data.hotspot_x);
			console.log('next_panel: ' + $(event.data.panel.next_panel).attr('id'));
			event.data.panel.css({'width': old_width + delta});

			if(event.data.panel.next_panel) {
				var left = parseInt(event.data.panel.next_panel.css('left'));
				console.log('left: ' + left + ' new_left: ' + (left+delta) );
				event.data.panel.next_panel.css('left', left+delta);
			}

            return false;
        },
        resize_stop: function(event) {
            $(document).unbind('mousemove', $.hpanel.resize_changed).unbind('mouseup', $.hpanel.resize_stop);
            $('body').css('cursor', 'auto');
        }
    };

    $.fn.make_hpanel = function(options)
	{
		console.log('Making an hpanel out of "#' +  $(this).attr('id') + '"');
		var root = $(this)
		var all_panels = $('.panel-wrap', root)
		console.log('Panels: ' + all_panels);

		var prev = null;

		all_panels.each(function(i) {
			var panel = $(all_panels[i]);
			var handle = $('.panel-slider', panel)

			panel.next_panel = null;
			if (prev) prev.next_panel = panel;

			/* attach the trigger */
	        handle.mousedown(function(event) {
				var touch_data = {
					panel_root: root,
					panel: panel,
					hotspot_x: event.pageX - handle.position().left
				};
				$(this).trigger('hpanel:panel-resize-start', touch_data);
				return false;
			});
			prev = panel;
        });

		root.bind('hpanel:panel-resize-start', $.hpanel.resize_start);
    };
})(jQuery);

<commit_msg>Nothing interesting.<commit_after>(function($){

	/* behaviour */
	$.hpanel = {
        settings: {},
		current_data: {},
        resize_start: function(event, mydata) {
			console.log('Panel ' + mydata.panel.attr('id') + ' started resizing');
			$(document).bind('mousemove', mydata, $.hpanel.resize_changed).
				bind('mouseup', mydata, $.hpanel.resize_stop);
			$('iframe').bind('mousemove', mydata, $.hpanel.resize_changed).
				bind('mouseup', mydata, $.hpanel.resize_stop);
			return false;
		},
		resize_changed: function(event) {
			var old_width = parseInt(event.data.panel.css('width'));
			var delta = event.pageX + event.data.hotspot_x - old_width;
			event.data.panel.css({'width': old_width + delta});

			if(event.data.panel.next_panel) {
				var left = parseInt(event.data.panel.next_panel.css('left'));
				console.log('left: ' + left + ' new_left: ' + (left+delta) );
				event.data.panel.next_panel.css('left', left+delta);
			}

            return false;
        },
        resize_stop: function(event) {
            $(document).unbind('mousemove', $.hpanel.resize_changed).unbind('mouseup', $.hpanel.resize_stop);
	    $('iframe').unbind('mousemove', $.hpanel.resize_changed).unbind('mouseup', $.hpanel.resize_stop);
            $('body').css('cursor', 'auto');
        }
    };

    $.fn.make_hpanel = function(options)
	{
		console.log('Making an hpanel out of "#' +  $(this).attr('id') + '"');
		var root = $(this)
		var all_panels = $('.panel-wrap', root)
		console.log('Panels: ' + all_panels);

		var prev = null;

		all_panels.each(function(i) {
			var panel = $(all_panels[i]);
			var handle = $('.panel-slider', panel)

			panel.next_panel = null;
			if (prev) prev.next_panel = panel;

			/* attach the trigger */
	        handle.mousedown(function(event) {
				var touch_data = {
					panel_root: root,
					panel: panel,
					hotspot_x: event.pageX - handle.position().left
				};
				$(this).trigger('hpanel:panel-resize-start', touch_data);
				return false;
			});
			prev = panel;
        });

		root.bind('hpanel:panel-resize-start', $.hpanel.resize_start);
    };
})(jQuery);

<|endoftext|>


<commit_before>/* global require exports next */
/* eslint no-unused-vars: off */
const Payee = require("../models/Payee");
const Payments = require("../models/Payment");

exports.getPayees = async (req, res) => {
    return Payee.find({ owner: req.params.userid })
        .sort({ day: 1 })
        .cache(0, req.params.userid + "__payees")
        .then(payees => {
            res.json(payees);
        });
}

exports.getPayee = async (req, res) => {
    return Payee.findOne({ owner: req.params.userid, _id: req.params.payeeid })
        .then(payee => {
            res.json(payee);
        })
};

exports.getPayments = async (req, res) => {
    return Payments.find({ owner: req.params.userid })
        .sort({ ref: -1 })
        .cache(0, req.params.userid + "__payments")
        .then(payments => {
            res.json(payments);
        })
}

exports.getPayeePayments = async (req, res) => {
    return Payments.find({ owner: req.params.userid, payee: req.params.payeeid })
        .sort({ ref: -1 })
        .then(payments => {
            res.json(payments);
        });
};<commit_msg>Adding CORS for API routes<commit_after>/* global require exports next */
/* eslint no-unused-vars: off */
const Payee = require("../models/Payee");
const Payments = require("../models/Payment");

exports.getPayees = async (req, res) => {
    return Payee.find({ owner: req.params.userid })
        .sort({ day: 1 })
        .cache(0, req.params.userid + "__payees")
        .then(payees => {
            res.json(payees);
        });
}

exports.getPayee = async (req, res) => {
    return Payee.findOne({ owner: req.params.userid, _id: req.params.payeeid })
        .then(payee => {
            res.header("Access-Control-Allow-Origin", "*");
            res.header("Access-Control-Allow-Headers", "X-Requested-With");
            res.json(payee);
        })
};

exports.getPayments = async (req, res) => {
    return Payments.find({ owner: req.params.userid })
        .sort({ ref: -1 })
        .cache(0, req.params.userid + "__payments")
        .then(payments => {
            res.header("Access-Control-Allow-Origin", "*");
            res.header("Access-Control-Allow-Headers", "X-Requested-With");
            res.json(payments);
        })
}

exports.getPayeePayments = async (req, res) => {
    return Payments.find({ owner: req.params.userid, payee: req.params.payeeid })
        .sort({ ref: -1 })
        .then(payments => {
            res.header("Access-Control-Allow-Origin", "*");
            res.header("Access-Control-Allow-Headers", "X-Requested-With");
            res.json(payments);
        });
};<|endoftext|>


<commit_before>//main.js
/*var flights = [[{dest: "Poland", price: "242", carrier: "Ryan Air"},
                    {dest: "Poland", price: "60", carrier: "British Airways"},
                    {dest: "Poland", price: "260", carrier: "Joe's Hardware"}],
            [ {dest: "Bristol", price: "160", carrier: "British Airways"},
                    {dest: "Bristol", price: "20", carrier: "Joe's Hardware"}]];
*/
var flights;
var ready = false;
//get flight data
$.get( "/top_flights", function( data ) {
    flights = JSON.parse(data);
    populate_data();
});
$(document).ready( function () {

    $('#chooser a').click(function (e) {
	e.preventDefault();
    if($("#tab-main").hasClass("active")){ $("#tab-main").addClass("hide");}
        else { $("#tab-main").removeClass("hide"); }
    if($("#tab-friends").hasClass("active")){ $("#tab-friends").addClass("hide");}
        else { $("#tab-friends").removeClass("hide"); }
	$(this).tab('show');
    });

    $(".btn-modal").on("click", function () {
        //set modal to loading!
        if(ready) {
            reset_modal();
            $('#myModal').modal('toggle');
            //populate the modal here!!!
            populate_modal($(this).attr("location"));
        }
    });

});
function reset_modal() {
    //resets the modal to a loading screen
    $("#modalTitle").text("Loading...");
    $("#flight-data tr").remove();
    $("#flight-data").html("
Date	Agent	Fly Now!
");
}
function populate_modal(city_id) {
    //this gets all relevant data for the modal
    var data = flights[city_id];
    $("#modalTitle").text(data.name[0]+", "+data.name[1]+", "+data.name[2]);
    $("#skyscanner-url").attr('href', flights[city_id]['url']);
    $("#flight-data tr:last").after(prepare_flight(data.cheapest_quote));
    data.quotes.forEach(function (entry) {
        $("#flight-data tr:last").after(prepare_flight(entry));
    });
    $(".date-tooltip").tooltip();
}
function populate_data() {
    ready = true;
    $("#Loading-Content").addClass("hidden");
    $("#first-location h1").html(flights[0].name[1] + "
£"+flights[0].cheapest_quote.MinPrice);
    $("#first-location p").html("Go and see "+flights[0].friends[0].name+", "+flights[0].friends[1].name" and " = (flights[0].friends.length - 2)+" others in "+flights[0].name[1]+", "+flights[0].name[2]);
    $("#first-location button").attr("location", 0);
    $("#first-location").removeClass("hidden");
    $("#second-location h1").html(flights[1].name[1] + "
£"+flights[1].cheapest_quote.MinPrice);
    $("#second-location p").html("You have "+flights[1].friends.length+" friends near "+flights[1].name[1]+", including "+flights[1].friends[0].name+"");
    $("#second-location button").attr("location", 1);
    $("#second-location").removeClass("hidden");
    $("#third-location h1").html(flights[2].name[1] + "
£"+flights[2].cheapest_quote.MinPrice);
    $("#third-location p").html("Flights available to go and see "+flights[2].friends[0].name+" and "+(flights[2].friends.length -1)+" others in "+flights[2].name[1]);
    $("#third-location button").attr("location", 2);
    $("#third-location").removeClass("hidden");
}
function prepare_flight(dest) {
    var date = moment(dest.InboundLeg.DepartureDate).format('ll');
    var rel_date = moment(dest.InboundLeg.DepartureDate).fromNow();
    //add a 'time until' event using .fromNow() as a tooltip
    var r = "
";
    r += "

"+date+"	";
    r += ""+dest.InboundLeg.Carrier+"	";
    r += "<button class='btn btn-success'>£"+dest.MinPrice+"</button>	";
    r += "
";
    return r;
}
<commit_msg>Fixed teh broke<commit_after>//main.js
/*var flights = [[{dest: "Poland", price: "242", carrier: "Ryan Air"},
                    {dest: "Poland", price: "60", carrier: "British Airways"},
                    {dest: "Poland", price: "260", carrier: "Joe's Hardware"}],
            [ {dest: "Bristol", price: "160", carrier: "British Airways"},
                    {dest: "Bristol", price: "20", carrier: "Joe's Hardware"}]];
*/
var flights;
var ready = false;
//get flight data
$.get( "/top_flights", function( data ) {
    flights = JSON.parse(data);
    populate_data();
});
$(document).ready( function () {

    $('#chooser a').click(function (e) {
	e.preventDefault();
    if($("#tab-main").hasClass("active")){ $("#tab-main").addClass("hide");}
        else { $("#tab-main").removeClass("hide"); }
    if($("#tab-friends").hasClass("active")){ $("#tab-friends").addClass("hide");}
        else { $("#tab-friends").removeClass("hide"); }
	$(this).tab('show');
    });

    $(".btn-modal").on("click", function () {
        //set modal to loading!
        if(ready) {
            reset_modal();
            $('#myModal').modal('toggle');
            //populate the modal here!!!
            populate_modal($(this).attr("location"));
        }
    });

});
function reset_modal() {
    //resets the modal to a loading screen
    $("#modalTitle").text("Loading...");
    $("#flight-data tr").remove();
    $("#flight-data").html("
Date	Agent	Fly Now!
");
}
function populate_modal(city_id) {
    //this gets all relevant data for the modal
    var data = flights[city_id];
    $("#modalTitle").text(data.name[0]+", "+data.name[1]+", "+data.name[2]);
    $("#skyscanner-url").attr('href', flights[city_id]['url']);
    $("#flight-data tr:last").after(prepare_flight(data.cheapest_quote));
    data.quotes.forEach(function (entry) {
        $("#flight-data tr:last").after(prepare_flight(entry));
    });
    $(".date-tooltip").tooltip();
}
function populate_data() {
    ready = true;
    $("#Loading-Content").addClass("hidden");
    $("#first-location h1").html(flights[0].name[1] + "
£"+flights[0].cheapest_quote.MinPrice);
    $("#first-location p").html("Go and see "+flights[0].friends[0].name+", "+flights[0].friends[1].name+" and "+(flights[0].friends.length - 2)+" others in "+flights[0].name[1]+", "+flights[0].name[2]);
    $("#first-location button").attr("location", 0);
    $("#first-location").removeClass("hidden");
    $("#second-location h1").html(flights[1].name[1] + "
£"+flights[1].cheapest_quote.MinPrice);
    $("#second-location p").html("You have "+flights[1].friends.length+" friends near "+flights[1].name[1]+", including "+flights[1].friends[0].name+"");
    $("#second-location button").attr("location", 1);
    $("#second-location").removeClass("hidden");
    $("#third-location h1").html(flights[2].name[1] + "
£"+flights[2].cheapest_quote.MinPrice);
    $("#third-location p").html("Flights available to go and see "+flights[2].friends[0].name+" and "+(flights[2].friends.length -1)+" others in "+flights[2].name[1]);
    $("#third-location button").attr("location", 2);
    $("#third-location").removeClass("hidden");
}
function prepare_flight(dest) {
    var date = moment(dest.InboundLeg.DepartureDate).format('ll');
    var rel_date = moment(dest.InboundLeg.DepartureDate).fromNow();
    //add a 'time until' event using .fromNow() as a tooltip
    var r = "
";
    r += "

"+date+"	";
    r += ""+dest.InboundLeg.Carrier+"	";
    r += "<button class='btn btn-success'>£"+dest.MinPrice+"</button>	";
    r += "
";
    return r;
}
<|endoftext|>