CC-2511:Phone Home Metric: add error display on popup
- refactoring was needed to solve this problem. - javascript error check is not necessary anymore. - The form is preloaded to nowplaying page, only when it's needed, hence ajax call to pull up the form is not needed anymore.
This commit is contained in:
parent
883cacd220
commit
daf6f9963f
6 changed files with 155 additions and 143 deletions
|
@ -1,60 +1,51 @@
|
|||
$(document).ready(function(){
|
||||
var dialogGlob;
|
||||
|
||||
function doNotShowPopup(){
|
||||
$.get("/Preference/donotshowpopup");
|
||||
}
|
||||
|
||||
$.get("/Preference/register", {format:"json"}, function(json){
|
||||
var dialog = $(json.dialog);
|
||||
dialogGlob = dialog;
|
||||
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
position:['center',50],
|
||||
close: doNotShowPopup,
|
||||
buttons: [
|
||||
{
|
||||
id: "remind_me",
|
||||
text: "Remind me in 1 week",
|
||||
click: function() {
|
||||
var url = '/Preference/remindme';
|
||||
$.ajax({
|
||||
url: url,
|
||||
});
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: "Yes, help Airtime",
|
||||
click: function() {
|
||||
if($("#Publicise").is(':checked')){
|
||||
if(validateFields()){
|
||||
$("#register-form").submit();
|
||||
}
|
||||
}else{
|
||||
$("#register-form").submit();
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var button = $("#help_airtime");
|
||||
button.attr('disabled', 'disabled').addClass('ui-state-disabled');
|
||||
dialog.dialog('open');
|
||||
})
|
||||
|
||||
function doNotShowPopup(){
|
||||
$.get("/Nowplaying/donotshowpopup");
|
||||
}
|
||||
|
||||
var dialog = $("#register_popup");
|
||||
|
||||
dialog.dialog({
|
||||
autoOpen: false,
|
||||
width: 500,
|
||||
resizable: false,
|
||||
modal: true,
|
||||
position:['center',50],
|
||||
close: doNotShowPopup,
|
||||
buttons: [
|
||||
{
|
||||
id: "remind_me",
|
||||
text: "Remind me in 1 week",
|
||||
click: function() {
|
||||
var url = '/Nowplaying/remindme';
|
||||
$.ajax({
|
||||
url: url,
|
||||
});
|
||||
$(this).dialog("close");
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "help_airtime",
|
||||
text: "Yes, help Airtime",
|
||||
click: function() {
|
||||
$("#register-form").submit();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
var button = $("#help_airtime");
|
||||
button.attr('disabled', 'disabled').addClass('ui-state-disabled');
|
||||
dialog.dialog('open');
|
||||
|
||||
|
||||
$('.collapsible-header').live('click',function() {
|
||||
$(this).next().toggle('fast');
|
||||
$(this).toggleClass("close");
|
||||
return false;
|
||||
}).next().hide();
|
||||
|
||||
|
||||
$("#SupportFeedback").live('click', function(){
|
||||
var pub = $("#Publicise");
|
||||
var privacy = $("#Privacy");
|
||||
|
@ -72,13 +63,17 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
|
||||
$("#Publicise").live('click', function(){
|
||||
var promote = $("#Publicise");
|
||||
promote.live('click', function(){
|
||||
if($(this).is(':checked')){
|
||||
$("#public-info").show();
|
||||
}else{
|
||||
$("#public-info").hide();
|
||||
}
|
||||
});
|
||||
if( promote.is(":checked")){
|
||||
$("#public-info").show();
|
||||
}
|
||||
|
||||
$("#Privacy").live('click', function(){
|
||||
var support = $("#SupportFeedback");
|
||||
|
@ -90,6 +85,12 @@ $(document).ready(function(){
|
|||
}
|
||||
});
|
||||
|
||||
if($("#SupportFeedback").is(':checked') && $("#Privacy").is(':checked')){
|
||||
button.removeAttr('disabled').removeClass('ui-state-disabled');
|
||||
}else{
|
||||
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled');
|
||||
}
|
||||
|
||||
$("#link_to_whos_using").live('click', function(){
|
||||
window.open("http://sourcefabric.org/en/products/airtime_whosusing");
|
||||
});
|
||||
|
@ -103,32 +104,6 @@ $(document).ready(function(){
|
|||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function validateFields(){
|
||||
var stnName = $("#stnName");
|
||||
|
||||
var errors = new Array();
|
||||
|
||||
errors[0] = displayError(stnName);
|
||||
|
||||
for( e in errors ){
|
||||
if(errors[e]){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function displayError(ele){
|
||||
var errorMsg = "Value is required and can't be empty";
|
||||
|
||||
ele.parent().find("ul").remove();
|
||||
if($.trim(ele.val()) == ''){
|
||||
ele.parent().append("<ul class='errors'><li>"+errorMsg+"</li></ul>");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function resizeImg(ele){
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue