diff --git a/README.md b/README.md index 20af5401..3bccfd31 100644 --- a/README.md +++ b/README.md @@ -7,25 +7,17 @@ The AngularJS client for the bioacoustic workbench --- ## Install instructions -Normally this would work: - $ npm -g install grunt-cli karma bower +`npm` is required. -Specific version of karma due to dependency issues. -Temporary fix: - $ npm install -g karma@0.10.10 - $ npm -g install grunt-cli karma bower - -cd to your cloned directory and then install `npm` and `bower` modules. +Run: - $ npm i -g karma@0.10.10 - - $ npm install - - $ bower install + $ npm run setup + +This will execute `npm install` and `bower install` to install build and vendor dependencies respectively. ## To develop: - $ grunt watch + $ npm run watch and browse to the karma tab first `localhost:` (see output for port number), then `localhost:8080` after the karma unit tests have run. @@ -37,9 +29,9 @@ You'll need to configure `build.config.js` when adding any new grunt packages to ## To build: - $ grunt + $ npm run build -and copy the artefacts from the `/bin` directory. +and copy the artifacts from the `/bin` directory. The `grunt` runner will accept three build options that will rewrite important variables. diff --git a/package.json b/package.json index 3fd4a196..57b925d4 100644 --- a/package.json +++ b/package.json @@ -13,34 +13,44 @@ "url": "https://github.com/QutBioacoustics/baw-client.git" }, "devDependencies": { + "babel": "^5.5.4", "connect-gzip-static": "^1.0.0", "connect-modrewrite": "0.7.x", "grunt": "~0.4.1", "grunt-babel": "^5.0.1", "grunt-bump": "^0.3", "grunt-changelog": "^0.3", + "grunt-cli": "^0.1.13", "grunt-contrib-clean": "^0.6.0", "grunt-contrib-concat": "^0.5.0", - "grunt-contrib-connect": "^0.10", + "grunt-contrib-connect": "^0.11", "grunt-contrib-copy": "^0.8", "grunt-contrib-jshint": "^0.11", "grunt-contrib-uglify": "^0.9", "grunt-contrib-watch": "~0.6.x", - "grunt-conventional-changelog": "^1.2", + "grunt-conventional-changelog": "^3.0", "grunt-html2js": "~0.3.2", - "grunt-karma": "^0.10", - "grunt-sass": "^0.18.1", - "karma-chrome-launcher": "~0.1.1", - "karma-coverage": "^0.3", + "grunt-karma": "^0.12", + "grunt-sass": "^1.0.0", + "karma": "^0.13", + "karma-chrome-launcher": "~0.2", + "karma-coverage": "^0.4", "karma-firefox-launcher": "~0.1.3", "karma-jasmine": "^0.3.x", - "karma-phantomjs-launcher": "~0.1.1", + "phantomjs": "^1.9", + "karma-phantomjs-launcher": "~0.2", "karma-sourcemap-loader": "^0.3.5", + "bower": "^1.4", "lodash": "^3.7", "slash": "^1.0.0" }, + "scripts": { + "watch": "grunt watch", + "build": "grunt", + "setup": "npm install && bower install", + "start": "npm run build", + "test": "npm run build" + }, "private": true, - "dependencies": { - "babel": "^5.5.4" - } + "dependencies": {} } diff --git a/src/common/knockout.drawabox.js b/src/common/knockout.drawabox.js deleted file mode 100644 index a9068f2b..00000000 --- a/src/common/knockout.drawabox.js +++ /dev/null @@ -1,182 +0,0 @@ -//function TagModel() { -// var self = this; -//// var to = function (value) { -//// return ko.asyncComputedObservable(function() { -//// return value() + "px"; -//// }); -//// }; -// -// self.left = ko.observable(0); -// self.top = ko.observable(0); -// self.width = ko.observable(0); -// self.height = ko.observable(0); -//}; -// -//function TaggerModel(valueAcessor) { -//// // ensure we are working with a single target -//// if (target.length !== 1) { -//// throw new Error("only made to work with one element"); -//// } -// -// var self = this; -// -// self.tags = ko.observableArray(); -// var aChildTag = ko.observable(); -// -// self.clear = function() { -// self.tags.removeAll(); -// }; -// -// //self.dirtyFlag = ko.dirtyFlag(self); -// self.somethingChanged = ko.computed(function () { -// self.tags(); -// aChildTag(); -// }).extend({ throttle: 1500 }); -// -//// var getV = function () { -//// return self; -//// //return ko.utils.unwrapObservable(valueAcessor()); -//// }; -// var update = function(bounds) { -// var t = self; -// var old = ko.utils.arrayFirst(t.tags(), function(item) { -// return item.id === bounds.id; -// }); -// -// if (old) { -// // update it -// old.top = bounds.top; -// old.left = bounds.left; -// old.width = bounds.width; -// old.height = bounds.height; -// } -// -// aChildTag.valueHasMutated(); -// -// }; -// -// self.newBox = function(tag, bounds) { -// console.info("eventMap.newBox"); -// var t = self; -// t.tags.push(bounds); -// }; -// -// self.boxChanged = function(tag, bounds) { -// console.info("eventMap." + arguments.callee.caller.name); -// update(bounds); -// }; -// -// self.brs = function boxResizing(t, b) {self.boxChanged(t, b);}; -// self.brsd = function boxResized(t, b) {self.boxChanged(t, b);}; -// self.bmv = function boxMoving(t, b) {self.boxChanged(t, b);}; -// self.bmvd = function boxMoved(t, b) { self.boxChanged(t, b); }; -// -// self.removeBox = function (tag, bounds) { -// console.info("eventMap.boxDeleted"); -// var t = self; -// var removed = t.tags.remove(function (item) { -// return item.id === bounds.id; -// }); -// -// if (!removed) { -// console.error("nothing removed!"); -// } -// }; -// -// -//} -// -//function unwrapDrawABoxInput(valueAcessor) { -// var val = valueAcessor(); -// -// if ((ko.isObservable(val))) { -// val = { -// data: val, -// tagLimit: undefined, -// showOnlt: undefined -// }; -// } -// else { -// if (val === undefined || -// val.data == undefined || -// !ko.isObservable(val.data)) { -// throw new Error("The drawabox binding is meant to work with a base observeable"); -// } -// } -// tagLimit = val.maxBoxes; -// -// return val; -//} -// -//ko.bindingHandlers.drawabox = { -// // element — The DOM element involved in this binding -// // valueAccessor — A JavaScript function that you can call to get the current model -// // property that is involved in this binding. Call this without passing any parameters -// // (i.e., call valueAccessor()) to get the current model property value. -// // allBindingsAccessor — A JavaScript function that you can call to get all the model -// // properties bound to this DOM element. Like valueAccessor, call it without any parameters to get the -// // current bound model properties. -// // viewModel — The view model object that was passed to ko.applyBindings. Inside a nested binding -// // context, this parameter will be set to the current data item (e.g., inside a with: person binding, -// // viewModel will be set to person). -// init: function (element, valueAcessor, allBindingsAcessor, viewModel) { -// // This will be called when the binding is first applied to an element -// // Set up any initial state, event handlers, etc. here -// -// var $ele = $(element); -// if (!$ele.is("div")) { -// throw new Error("The drawabox binding must be applied to a div"); -// } -// -// var val = unwrapDrawABoxInput(valueAcessor); -// -// // the viewModel for the tagger -// var tm = new TaggerModel(valueAcessor); -// -// // now setup element to work with draw a box -// var options = { -// maxBoxes: val.tagLimit, -// newBox: tm.newBox, -// boxResizing: tm.brs, -// boxResized: tm.brsd, -// boxMoving: tm.bmv, -// boxMoved: tm.bmvd, -// boxDeleted: tm.removeBox, -// boxSelected: function (tag, bounds) { -// console.info("eventMap.boxSelected"); -// }, -// showOnly: val.showOnly -// }; -// $ele.drawabox(options); -// -// val(tm); -// return { 'controlsDescendantBindings': true }; -// }, -// update: function (element, valueAcessor, allBindingsAcessor, viewModel) { -// // This will be called once when the binding is first applied to an element, -// // and again whenever the associated observable changes value. -// // Update the DOM element based on the supplied values here. -// -// var $ele = $(element); -// var value = unwrapDrawABoxInput(valueAcessor); -// } -//}; -// -//ko.bindingHandlers.showabox = { -// init: function (element, valueAcessor, allBindingsAcessor, viewModel) { -// // This will be called when the binding is first applied to an element -// // Set up any initial state, event handlers, etc. here -// -// // wrap value accessor -// var newAcessor = function() { -// var v = unwrapDrawABoxInput(valueAcessor); -// v.showOnly = true; -// return v; -// }; -// return ko.bindingHandlers.drawabox.init(element, newAcessor, allBindingsAcessor, viewModel); -// }, -// update: ko.bindingHandlers.drawabox.update -//}; -// -// -//