stormfront-rails 0.1.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/stormfront/rails/version.rb +2 -2
- data/lib/stormfront/rails.rb +2 -0
- data/stormfront-rails.gemspec +3 -3
- data/vendor/assets/javascripts/src/handlebars.js +4604 -0
- data/vendor/assets/javascripts/src/stormfront.js +1137 -0
- data/vendor/assets/javascripts/stormfront.js +3 -32
- metadata +24 -47
- data/vendor/assets/javascripts/stormfront/Alert.js +0 -17
- data/vendor/assets/javascripts/stormfront/Container.js +0 -31
- data/vendor/assets/javascripts/stormfront/Entity.js +0 -53
- data/vendor/assets/javascripts/stormfront/Errors.js +0 -25
- data/vendor/assets/javascripts/stormfront/KeyboardEvents.js +0 -52
- data/vendor/assets/javascripts/stormfront/Layout.js +0 -60
- data/vendor/assets/javascripts/stormfront/List.js +0 -123
- data/vendor/assets/javascripts/stormfront/MouseEvents.js +0 -146
- data/vendor/assets/javascripts/stormfront/Namespaces.js +0 -5
- data/vendor/assets/javascripts/stormfront/Overlay.js +0 -178
- data/vendor/assets/javascripts/stormfront/Reducer.js +0 -9
- data/vendor/assets/javascripts/stormfront/Request.js +0 -39
- data/vendor/assets/javascripts/stormfront/View.js +0 -55
- data/vendor/assets/javascripts/stormfront/ViewBase.js +0 -57
- data/vendor/assets/javascripts/stormfront/mixin/Dispatch.js +0 -19
- data/vendor/assets/javascripts/stormfront/mixin/Other.js +0 -25
- data/vendor/assets/javascripts/stormfront/support/Chaperone.js +0 -69
- data/vendor/assets/javascripts/stormfront/support/Template.js +0 -75
- data/vendor/assets/javascripts/stormfront/types/Arguments.js +0 -27
- data/vendor/assets/javascripts/stormfront/types/Class.js +0 -25
- data/vendor/assets/javascripts/stormfront/types/Hash.js +0 -23
- data/vendor/assets/javascripts/stormfront/types/Number.js +0 -15
- data/vendor/assets/javascripts/stormfront/types/Response.js +0 -31
- data/vendor/assets/javascripts/stormfront/types/String.js +0 -44
- data/vendor/assets/javascripts/stormfront/types/Time.js +0 -29
@@ -1,31 +0,0 @@
|
|
1
|
-
Stormfront.Response = Stormfront.Class.extend({
|
2
|
-
initialize: function(xhr){
|
3
|
-
this.xhr = xhr;
|
4
|
-
},
|
5
|
-
isActionable: function(){
|
6
|
-
return !(this.hasBeenHandled() || this.isUserUnauthorized() || this.hasBeenAborted());
|
7
|
-
},
|
8
|
-
hasBeenHandled: function(){
|
9
|
-
return this.xhr.handled === true;
|
10
|
-
},
|
11
|
-
markAsHandled: function(){
|
12
|
-
this.xhr.handled = true;
|
13
|
-
},
|
14
|
-
isUserUnauthorized: function(){
|
15
|
-
return this.xhr.status === 401;
|
16
|
-
},
|
17
|
-
hasBeenAborted: function(){
|
18
|
-
//TODO: consider xhr.status === 'abort'?
|
19
|
-
return this.xhr.readyState != 4;
|
20
|
-
},
|
21
|
-
getError: function(){
|
22
|
-
try {
|
23
|
-
var message = JSON.parse(this.xhr.responseText);
|
24
|
-
return message.error || message.message;
|
25
|
-
}
|
26
|
-
catch (e){
|
27
|
-
console.warn('Unhandled error', this.xhr, e);
|
28
|
-
return Stormfront.Errors.FEEDBACK;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
});
|
@@ -1,44 +0,0 @@
|
|
1
|
-
stormfront.string = function(text){
|
2
|
-
return new Stormfront.String(text);
|
3
|
-
};
|
4
|
-
|
5
|
-
Stormfront.String = Stormfront.Class.extend({
|
6
|
-
initialize: function(text){
|
7
|
-
this.text = text;
|
8
|
-
},
|
9
|
-
title: function(){
|
10
|
-
var sentence = _.str.capitalize(_.str.camelize(this.text)).split(/(?=[A-Z\d])/);
|
11
|
-
var displaySentence = "";
|
12
|
-
function processCharacter(character, i){
|
13
|
-
function whenPreviousWordIsNotAnAcronym() {
|
14
|
-
return i > 0 && sentence[i - 1].length > 1;
|
15
|
-
}
|
16
|
-
function whenPreviousWordISAnAcronymAndCurrentWordIsNotAnAcronym() {
|
17
|
-
return i > 0 && sentence[i - 1].length == 1 && sentence[i].length > 1;
|
18
|
-
}
|
19
|
-
if (whenPreviousWordIsNotAnAcronym() || whenPreviousWordISAnAcronymAndCurrentWordIsNotAnAcronym())
|
20
|
-
displaySentence += " ";
|
21
|
-
displaySentence += character;
|
22
|
-
}
|
23
|
-
_.each(sentence, processCharacter);
|
24
|
-
return displaySentence;
|
25
|
-
},
|
26
|
-
decimal: function(places, placeholder){
|
27
|
-
placeholder = placeholder || '';
|
28
|
-
places = places || 3;
|
29
|
-
var candidate = parseFloat(this.text);
|
30
|
-
return isNaN(candidate) ? placeholder : candidate.toFixed(places);
|
31
|
-
},
|
32
|
-
scientific: function(){
|
33
|
-
return this.text === null || $.trim(this.text) === '' ? '' : parseFloat(this.text).toExponential(3);
|
34
|
-
},
|
35
|
-
decimal_format: function(){
|
36
|
-
return this.decimal(this.text);
|
37
|
-
},
|
38
|
-
scientific_notation: function(){
|
39
|
-
return this.scientific(this.text);
|
40
|
-
},
|
41
|
-
firstWord: function(){
|
42
|
-
return this.text ? this.text.split(' ')[0] : '';
|
43
|
-
}
|
44
|
-
});
|
@@ -1,29 +0,0 @@
|
|
1
|
-
stormfront.time = function(datetime){
|
2
|
-
return new Stormfront.Time(datetime);
|
3
|
-
};
|
4
|
-
|
5
|
-
Stormfront.Time = Stormfront.Class.extend({
|
6
|
-
initialize: function(datetime){
|
7
|
-
this.time = moment(datetime || (new Date()).getTime());
|
8
|
-
},
|
9
|
-
now: function(){
|
10
|
-
return this.time;
|
11
|
-
},
|
12
|
-
getDiff: function(unit){
|
13
|
-
unit = unit || 'hours';
|
14
|
-
var now = moment().format();
|
15
|
-
return this.time.diff(now, unit);
|
16
|
-
},
|
17
|
-
getTimeAgo: function(){
|
18
|
-
return this.time.fromNow();
|
19
|
-
},
|
20
|
-
getLongDate: function(){
|
21
|
-
return this.time.format('MMMM D, YYYY h:mm:ss a');
|
22
|
-
},
|
23
|
-
getShortDate: function(){
|
24
|
-
return this.time.format('MMMM D, YYYY');
|
25
|
-
}
|
26
|
-
});
|
27
|
-
|
28
|
-
|
29
|
-
|