-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue/1523: added xapi model state functions #1524
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
eebd3ba
issue/1523: added array notation state functions
oliverfoster 7016cfb
issue/1523: added array notation state functions
oliverfoster 573f520
issue/1523: fix array reference
oliverfoster 989c892
issue/1523: added helper libraries for defaults
oliverfoster 223d87a
issue/1523: fixes
oliverfoster f44c3c8
issue/1523: updated backbone.controller.results
oliverfoster 97c89aa
issue/1523: changed to batched-synchronous
oliverfoster 0b7f12d
issue/1523: cleanup
oliverfoster 9d0f766
issue-1523: corrected typo
oliverfoster b30c15d
Merge branch 'master' into issue/1523
brian-learningpool 7080e31
issue/1523: simplified libraries
oliverfoster 9313cf7
issue/1523: reverted quotation changes
oliverfoster 65d3e1a
issue/1523: reverted change to jqueryMobile
oliverfoster 72e6aea
issue/1524: updated according to suggestions
oliverfoster File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// 2017-09-06 https://github.com/cgkineo/backbone.controller.results | ||
/* | ||
These functions are useful to resolve instance properties which are an array or object | ||
or instance functions which return an array/object, to copy and extend the returned value. | ||
*/ | ||
define('backbone.controller.results', [ | ||
'underscore.results', | ||
'backbone.controller' | ||
], function(_, Backbone) { | ||
|
||
var extend = [ Backbone.View, Backbone.Model, Backbone.Collection, Backbone.Controller ]; | ||
|
||
function resultExtendClass() { | ||
|
||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.unshift(this.prototype); | ||
|
||
return _.resultExtend.apply(this, args); | ||
|
||
}; | ||
|
||
function resultExtendInstance() { | ||
|
||
var args = Array.prototype.slice.call(arguments, 0); | ||
args.unshift(this); | ||
|
||
return _.resultExtend.apply(this, args); | ||
|
||
}; | ||
|
||
_.each(extend, function(item) { | ||
|
||
item.resultExtend = resultExtendClass; | ||
item.prototype.resultExtend = resultExtendInstance; | ||
|
||
}); | ||
|
||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 2017-09-06 https://github.com/cgkineo/underscore.results | ||
define('underscore.results', [ | ||
'underscore' | ||
], function(_) { | ||
|
||
_.mixin({ | ||
|
||
/* | ||
This function is useful to resolve instance properties which are an array or object | ||
or instance functions which return an array/object, to copy and extend the returned value. | ||
*/ | ||
resultExtend: function(instance, propertyName, withData) { | ||
|
||
/* | ||
Resolve the propertyName on the instance, it should be an object or array or | ||
a function returning an object or an array | ||
*/ | ||
var result = _.result(instance, propertyName); | ||
var resultType = (result instanceof Array ? "array" : typeof result); | ||
|
||
if (!withData) { | ||
|
||
// If no withData assume we're just copying the result | ||
switch (resultType) { | ||
case "array": | ||
// Create a copy of result and return | ||
return result.slice(0); | ||
case "object": | ||
// Create a copy of result and return | ||
return _.extend({}, result); | ||
default: | ||
throw "Incorrect types in resultExtend"; | ||
} | ||
|
||
} | ||
|
||
var withType = (withData instanceof Array ? "array" : typeof withData); | ||
|
||
// If no result, make a dummy one from the withData type | ||
if (!result) { | ||
|
||
switch (withType) { | ||
case "array": | ||
result = []; | ||
resultType = "array"; | ||
break; | ||
case "object": | ||
result = {}; | ||
resultType = "object"; | ||
break; | ||
default: | ||
throw "Incorrect types in resultExtend"; | ||
} | ||
|
||
} | ||
|
||
if (resultType !== withType) { | ||
throw "Incorrect types in resultExtend"; | ||
} | ||
|
||
switch (resultType) { | ||
case "array": | ||
// Create a copy of result, concat new data and return | ||
return result.slice(0).concat(withData); | ||
case "object": | ||
// Create a copy of result, overwrite with new data and return | ||
return _.extend({}, result, withData); | ||
} | ||
|
||
// If the resolved result isn't an array or object throw an error | ||
throw "Incorrect types in resultExtend"; | ||
|
||
} | ||
|
||
}); | ||
|
||
return _; | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 17 here is a magic number. Also, why 17?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
60fps ish. anywhere between 17ms and 40ms is usually good for stuff like this (25-60fps).
a defer would probably suffice but i wanted to group as many model changes as i could into one trigger, these numbers allow for a few short asynchronous model changes to occur before a callback without it seeming too laggy. > 250ms is probably too laggy (4 fps)