Skip to content

Commit

Permalink
Merge branch 'release-2.20.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
krampstudio committed Mar 18, 2016
2 parents c37588b + 9f734d8 commit 622a9ab
Show file tree
Hide file tree
Showing 10 changed files with 322 additions and 71 deletions.
2 changes: 1 addition & 1 deletion includes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*
*/
#TAO version number
define('TAO_VERSION', '3.1.0-sprint21');
define('TAO_VERSION', '3.1.0-sprint22');

$version = TAO_VERSION;

Expand Down
2 changes: 1 addition & 1 deletion manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
'label' => 'Tao base',
'description' => 'TAO meta-extension',
'license' => 'GPL-2.0',
'version' => '2.19.0',
'version' => '2.20.0',
'author' => 'Open Assessment Technologies, CRP Henri Tudor',
'requires' => array(
'generis' => '>=2.12.0'
Expand Down
8 changes: 5 additions & 3 deletions models/classes/mvc/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use common_ext_ExtensionsManager;
use common_session_SessionManager;
use common_AjaxResponse;
use common_report_Report as Report;
use tao_helpers_Context;
use tao_helpers_Request;
use tao_helpers_Uri;
Expand Down Expand Up @@ -188,7 +189,7 @@ protected function dispatchCli()
$params = $_SERVER['argv'];
$file = array_shift($params);
if (count($params) < 1) {
$report = new \common_report_Report(\common_report_Report::TYPE_ERROR, __('No action specified'));
$report = new Report(Report::TYPE_ERROR, __('No action specified'));
} else {
try {
$resolver = new ActionResolver();
Expand All @@ -198,10 +199,11 @@ protected function dispatchCli()
try {
$report = call_user_func($invocable, $params);
} catch (\Exception $e) {
$report = new \common_report_Report(\common_report_Report::TYPE_ERROR, __('An error occured while running "%s", please check your error log.', $actionIdentifier));
$report = new Report(Report::TYPE_ERROR, __('An exception occured while running "%s"', $actionIdentifier));
$report->add(new Report(Report::TYPE_ERROR, $e->getMessage()));
}
} catch (ResolutionException $e) {
$report = new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Action "%s" not found.', $actionIdentifier));
$report = new Report(Report::TYPE_ERROR, __('Action "%s" not found.', $actionIdentifier));
}
}

Expand Down
3 changes: 3 additions & 0 deletions scripts/update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ public function update($initialVersion) {

$this->setVersion('2.19.0');
}

$this->skip('2.19.0', '2.20.0');

}

private function migrateFsAccess() {
Expand Down
9 changes: 9 additions & 0 deletions views/build/grunt/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ module.exports = function(grunt) {
grunt.config('qunit_junit', {
options : {
dest : reportOutput,

fileNamer : function(url){
return url
.replace(testUrl + '/', '')
.replace('/test.html', '')
.replace(/\//g, '.');
},

classNamer : function (moduleName, url) {
return url
.replace(testUrl + '/', '')
.replace('views/js/test/', '')
.replace('/test.html', '')
.replace(/\//g, '.');
}
}
});
Expand Down
146 changes: 82 additions & 64 deletions views/js/core/eventifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
* });
* });
*
* TODO replace before done syntax by promises
* TODO support flow control for all types of events not only before.
*
* @author Bertrand Chevrier <[email protected]>
*/
define([
Expand Down Expand Up @@ -155,6 +158,17 @@ define([
});
}

/**
* Get the list of events from an eventName string (ie, separated by spaces)
* @param {String} eventNames - the event strings
* @returns {String[]} the event list (no empty, no duplicate)
*/
function getEventNames(eventNames){
if(!_.isString(eventNames) || _.isEmpty(eventNames)){
return [];
}
return _(eventNames.split(/\s/g)).compact().uniq().value();
}

/**
* Get the name part of an event name: the 'foo' of 'foo.bar'
Expand Down Expand Up @@ -207,12 +221,14 @@ define([

/**
* Get the handlers for an event type
* @param {String} name - the event name
* @param {String} ns - the event namespace
* @param {String} eventName - the event name, namespace included
* @param {String} [type = 'between'] - the type of event in before, between and after
* @returns {Function[]} the handlers
*/
var getHandlers = function getHandlers(name, ns, type){
var getHandlers = function getHandlers(eventName, type){
var name = getName(eventName);
var ns = getNamespace(eventName);

type = type || 'between';
eventHandlers[ns] = eventHandlers[ns] || {};
eventHandlers[ns][name] = eventHandlers[ns][name] || getHandlerObject();
Expand All @@ -232,18 +248,16 @@ define([
* @example target.on('foo', function(bar){ console.log('Cool ' + bar) } );
*
* @this the target
* @param {String} eventName - the name of the event to listen
* @param {String} eventNames- the name of the event, or multiple events separated by a space
* @param {Function} handler - the callback to run once the event is triggered
* @returns {Object} the target object
*/
on : function on(eventName, handler){
var ns = getNamespace(eventName);
var name = getName(eventName);

if(typeof handler === 'function'){
getHandlers(name, ns).push(handler);
on : function on(eventNames, handler){
if(_.isFunction(handler)){
_.forEach(getEventNames(eventNames), function(eventName){
getHandlers(eventName).push(handler);
});
}

return this;
},

Expand All @@ -253,25 +267,28 @@ define([
* @example target.off('foo');
*
* @this the target
* @param {String} eventName - the name of the event
* @param {String} eventNames- the name of the event, or multiple events separated by a space
* @returns {Object} the target object
*/
off : function off(eventName){
var ns = getNamespace(eventName);
var name = getName(eventName);

if(ns && !name){
//off the complete namespace
eventHandlers[ns] = {};
} else {

_.forEach(eventHandlers, function(nsHandlers, namespace){
if(nsHandlers[name] && (ns === globalNs || ns === namespace)){
nsHandlers[name] = getHandlerObject();
}
});
}
off : function off(eventNames){

_.forEach(getEventNames(eventNames), function(eventName){

var name = getName(eventName);
var ns = getNamespace(eventName);

if(ns && !name){
//off the complete namespace
eventHandlers[ns] = {};
} else {

_.forEach(eventHandlers, function(nsHandlers, namespace){
if(nsHandlers[name] && (ns === globalNs || ns === namespace)){
nsHandlers[name] = getHandlerObject();
}
});
}
});
return this;
},

Expand All @@ -281,36 +298,39 @@ define([
* @example target.trigger('foo', 'Awesome');
*
* @this the target
* @param {String} eventName - the name of the event to trigger
* @param {String} eventNames- the name of the event to trigger, or multiple events separated by a space
* @returns {Object} the target object
*/
trigger : function trigger(eventName){
trigger : function trigger(eventNames){
var self = this;
var args = [].slice.call(arguments, 1);
var ns = getNamespace(eventName);
var name = getName(eventName);

//check which ns needs to be executed and then merge the handlers to be executed
var mergedHandlers = _(eventHandlers)
.filter(function(nsHandlers, namespace){
return nsHandlers[name] && (ns === globalNs || ns === namespace);
})
.reduce(function(acc, nsHandlers){
acc.before = acc.before.concat(nsHandlers[name].before);
acc.between = acc.between.concat(nsHandlers[name].between);
acc.after = acc.after.concat(nsHandlers[name].after);
return acc;
}, getHandlerObject());

if(mergedHandlers){

//if there is something in before we delay the execution
if(mergedHandlers.before.length){
createAsyncCallstack(mergedHandlers.before, self, args, _.partial(triggerEvent, mergedHandlers));
} else {
triggerEvent(mergedHandlers);

_.forEach(getEventNames(eventNames), function(eventName){
var ns = getNamespace(eventName);
var name = getName(eventName);

//check which ns needs to be executed and then merge the handlers to be executed
var mergedHandlers = _(eventHandlers)
.filter(function(nsHandlers, namespace){
return nsHandlers[name] && (ns === globalNs || ns === namespace);
})
.reduce(function(acc, nsHandlers){
acc.before = acc.before.concat(nsHandlers[name].before);
acc.between = acc.between.concat(nsHandlers[name].between);
acc.after = acc.after.concat(nsHandlers[name].after);
return acc;
}, getHandlerObject());

if(mergedHandlers){

//if there is something in before we delay the execution
if(mergedHandlers.before.length){
createAsyncCallstack(mergedHandlers.before, self, args, _.partial(triggerEvent, mergedHandlers));
} else {
triggerEvent(mergedHandlers);
}
}
}
});

/**
* Execute the given event handlers (between and then after)
Expand Down Expand Up @@ -341,12 +361,11 @@ define([
* @param {String} eventName
* @returns {Object} the target object
*/
before : function before(eventName, handler){
var ns = getNamespace(eventName);
var name = getName(eventName);

if(typeof handler === 'function'){
getHandlers(name, ns, 'before').push(handler);
before : function before(eventNames, handler){
if(_.isFunction(handler)) {
_.forEach(getEventNames(eventNames), function(eventName){
getHandlers(eventName, 'before').push(handler);
});
}
return this;
},
Expand All @@ -359,12 +378,11 @@ define([
* @param {String} eventName
* @returns {Object} the target object
*/
after : function after(eventName, handler){
var ns = getNamespace(eventName);
var name = getName(eventName);

if(typeof handler === 'function'){
getHandlers(name, ns, 'after').push(handler);
after : function after(eventNames, handler){
if(_.isFunction(handler)) {
_.forEach(getEventNames(eventNames), function(eventName){
getHandlers(eventName, 'after').push(handler);
});
}
return this;
}
Expand Down
24 changes: 24 additions & 0 deletions views/js/core/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,30 @@ define(['lib/polyfill/performance-now'], function () {
*/
is : function is(stateName) {
return !!state[stateName];
},

/**
* Add time to the timer
* @param {Number} time
* @returns {timer}
*/
add : function add(time) {
time = parseFloat(time);
duration += time;
last -= time;
return this;
},

/**
* Remove time from the timer
* @param {Number} time
* @returns {timer}
*/
sub : function sub(time) {
time = parseFloat(time);
duration -= time;
last += time;
return this;
}
};

Expand Down
Loading

0 comments on commit 622a9ab

Please sign in to comment.