Changed alert to use toastr

This commit is contained in:
Fergal Moran
2013-04-22 13:30:00 +01:00
parent 8b405948d4
commit 9ac6dee9a3
11 changed files with 30 additions and 51 deletions

View File

@@ -207,7 +207,7 @@ var AppRouter = Backbone.Router.extend({
$('#site-content-fill').html('');
},
loginRedirect: function () {
com.podnoms.utils.showAlert("Success", "Thank you for logging in.", "alert-success", true);
com.podnoms.utils.showAlert("Success", "Thank you for logging in.");
this.defaultRoute();
},
connectAccounts: function () {

View File

@@ -11,23 +11,7 @@ postFacebookLike = function (mixId) {
$.getJSON(
'social/like/' + mixId + '/',
function (data) {
com.podnoms.utils.showAlert("Posted your like to facebook, you can stop this in your settings page.", "Cheers feen", "alert-success", true);
/*
if (data.value) {
FB.api(
'/me/deepsouthsounds:like',
'post',
{ mix:'http://' + window.location.host + '/social/redirect/mix/' + mixId},
function (response) {
if (!response || response.error) {
com.podnoms.utils.showAlert(response.error.message, 'Error occurred: ', "alert-error", true);
} else {
com.podnoms.utils.showAlert("Posted your like to facebook, you can stop this in your settings page.", "Cheers feen", "alert-success", true);
}
}
);
}
*/
com.podnoms.utils.showAlert("Posted your like to facebook, you can stop this in your settings page.", "Cheers feen");
}
);
};
@@ -54,19 +38,19 @@ sharePageToTwitter = function (model) {
};
sharePageToFacebook = function (model) {
FB.ui({
method:'feed',
name:'Check out this mix on Deep South Sounds',
display:'popup',
link:'http://' + window.location.host + "/" + model.get('item_url'),
picture:model.get('mix_image'),
caption:model.get('title'),
description:model.get('description')
method: 'feed',
name: 'Check out this mix on Deep South Sounds',
display: 'popup',
link: 'http://' + window.location.host + "/" + model.get('item_url'),
picture: model.get('mix_image'),
caption: model.get('title'),
description: model.get('description')
},
function (response) {
if (response && response.post_id) {
com.podnoms.utils.showAlert("Success", "Post shared to facebook", "alert-success", true);
com.podnoms.utils.showAlert("Success", "Post shared to facebook");
} else {
com.podnoms.utils.showAlert("Error", "Failure sharing post", "alert-error", true);
com.podnoms.utils.showError("Error", "Failure sharing post");
}
}
);

View File

@@ -38,7 +38,7 @@ window.CommentListView = Backbone.View.extend({
view.render();
},
error:function () {
com.podnoms.utils.showAlert("Error", "Unable to save comment", "alert-error");
com.podnoms.utils.showError("Error", "Unable to save comment");
}});
$('textarea[name=new-comment]').val('');
}

View File

@@ -89,7 +89,7 @@ var EventCreateView = DSSEditableView.extend({
this.model.set('event_date', $('#event_date', this.el).val());
this._saveChanges({
success:function () {
com.podnoms.utils.showAlert("Success", "Event successfully added", "alert-info", true);
com.podnoms.utils.showAlert("Success", "Event successfully added");
Backbone.router.navigate('/event/' + model.get('id'));
}
});

View File

@@ -34,7 +34,7 @@ window.HeaderView = Backbone.View.extend({
});
},
logout: function () {
com.podnoms.utils.showAlert("Success", "You are now logged out", "alert-success", true);
com.podnoms.utils.showAlert("Success", "You are now logged out");
},
trackChanged:function (data) {
$(this.el).find('#track-description').text(data.title);

View File

@@ -93,10 +93,10 @@ window.MixListItemView = Backbone.View.extend({
var result = JSON.parse(data);
if (result.value == "Liked") {
parent.setLikeButton(id, true);
com.podnoms.utils.showAlert("Success", "Thanks for liking!!", "alert-success", true);
com.podnoms.utils.showAlert("Success", "Thanks for liking!!");
} else if (result.value == "Unliked") {
parent.setLikeButton(id, false);
com.podnoms.utils.showAlert("Success", "Mix unliked!!", "alert-success", true);
com.podnoms.utils.showAlert("Success", "Mix unliked!!");
}
}
);
@@ -352,7 +352,7 @@ window.MixCreateView = DSSEditableView.extend({
}
},
error: function (model, response) {
com.podnoms.utils.showAlert("Error", "Something went wrong<br />Nerd stuff is: " + response, "alert-info", false);
com.podnoms.utils.showError("Error", "Something went wrong<br />Nerd stuff is: " + response);
}
});
return false;

View File

@@ -106,7 +106,7 @@ var ReleaseCreateView = DSSEditableView.extend({
this._saveChanges({
success:function () {
com.podnoms.utils.showAlert("Success", "Release successfully added", "alert-info", true);
com.podnoms.utils.showAlert("Success", "Release successfully added");
Backbone.history.navigate('/release/' + model.get('id'), {trigger:true});
}
});

View File

@@ -50,11 +50,11 @@ window.UserView = DSSEditableView.extend({
var model = this.model;
this._saveChanges({
success:function () {
com.podnoms.utils.showAlert("Success", "Successfully updated yourself", "alert-info", true);
com.podnoms.utils.showAlert("Success", "Successfully updated yourself");
Backbone.history.navigate('/me', {trigger:true});
},
error:function () {
com.podnoms.utils.showAlert("Success", "Successfully updated yourself", "alert-info", false);
com.podnoms.utils.showAlert("Success", "Successfully updated yourself");
alert("Error");
}
});

View File

@@ -64,7 +64,7 @@ com.podnoms.player = {
this.playButtonEl
.removeClass('play-button-small-loading')
.addClass('play-button-small-pause');
this.trackLoaded = true;r r sharing
this.trackLoaded = true;
}
this.currentPosition = this.currentSound.position;
var duration = this._getDurationEstimate(this.currentSound);

View File

@@ -35,7 +35,7 @@ com.podnoms.utils = {
this.addValidationError(key, messages[key]);
}
}
this.showAlert('Warning!', 'Fix validation errors and try again', 'alert-warning');
this.showWarning('Warning!', 'Fix validation errors and try again');
},
addValidationError: function (field, message) {
var controlGroup = $('#' + field).parent().parent();
@@ -64,20 +64,13 @@ com.podnoms.utils = {
}
},
showError: function (title, message) {
this.showAlert(title, message, 'alert-error', true);
toastr.error(message, title);
},
showAlert: function (title, text, klass, fade) {
$('.alert').removeClass("alert-error alert-warning alert-success alert-info");
$('.alert').addClass(klass);
$('.alert').html('<strong>' + title + '</strong> ' + text);
$('.alert').show();
if (fade) {
$('.alert').fadeOut(5000, function () {
});
}
$('.alert').click(function () {
this.hideAlert();
});
showWarning: function(title, message){
toastr.warning(message, title);
},
showAlert: function (title, message) {
toastr.success(message, title);
},
showAlertModal: function (title, message) {
$('#alert-proxy-title').text(title);

View File

@@ -19,6 +19,7 @@
<link rel="stylesheet" href="{{ STATIC_URL }}css/uploadifive.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/com.podnoms.player.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/emoticons.css">
<link rel="stylesheet" href="{{ STATIC_URL }}css/toastr.css">
{% endcompress %}
{% block headerscripts %}
{% endblock %}
@@ -89,6 +90,7 @@
<script src="{{ STATIC_URL }}js/libs/backbone/backbone.mine.js"></script>
<script src="{{ STATIC_URL }}js/libs/backbone/backbone.infiniscroll.js"></script>
<script src="{{ STATIC_URL }}js/libs/globalize.js"></script>
<script src="{{ STATIC_URL }}js/libs/toastr.js"></script>
<script src="{{ STATIC_URL }}js/libs/jquery.colorbox.js"></script>
<script src="{{ STATIC_URL }}js/com.podnoms.utils.js"></script>
<script src="{{ STATIC_URL }}js/com.podnoms.storage.js"></script>