-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve merge conflicts with seeking branch
- Loading branch information
Showing
7 changed files
with
220 additions
and
32 deletions.
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
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,50 @@ | ||
var baw = window.baw = window.baw || {}; | ||
|
||
|
||
baw.UserProfile = (function () { | ||
|
||
function UserProfile(profile, defaultProfile) { | ||
|
||
if (!(this instanceof UserProfile)) { | ||
throw new Error("Constructor called as a function"); | ||
} | ||
|
||
|
||
if (!profile) { | ||
profile = defaultProfile; | ||
} | ||
|
||
if (!defaultProfile) { | ||
throw new Error("A default profile must be supplied"); | ||
} | ||
|
||
|
||
profile.preferences = profile.preferences || {}; | ||
|
||
|
||
// make read only properties for all profile props returned | ||
var props = Object.keys(profile) | ||
.reduce(function (state, current, index, array) { | ||
state[current] = { | ||
value: profile[current], | ||
writeable: false, | ||
enumerable: true, | ||
configurable: false | ||
}; | ||
return state; | ||
}, {}); | ||
Object.defineProperties(this, props); | ||
|
||
// now create persistence settings logic | ||
var merged = angular.extend(defaultProfile.preferences, this.preferences); | ||
for (var key in merged) { | ||
if (!merged.hasOwnProperty(key)) { | ||
return; | ||
} | ||
|
||
this.preferences[key] = merged[key]; | ||
} | ||
} | ||
|
||
return UserProfile; | ||
})(); |
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
Oops, something went wrong.