Created
September 5, 2012 20:07
-
-
Save agustinhaller/3643750 to your computer and use it in GitHub Desktop.
a
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
<div id="wrapper"> | |
<?php | |
require_once("./templates/top-bar.php"); | |
?> | |
<div class="wrap information" id="top-message" > | |
<h4><?php echo translate("COMPLETE_DATA_TO_CREATE_DRAW"); ?></h4> | |
<p> | |
<?php echo translate("CREATE_DRAW_HELP_1"); ?> | |
<br /> | |
<?php echo translate("CREATE_DRAW_HELP_2")." <b>".DRAW_CREDITS_PRICE." ".strtolower(translate("CREDITS"))."</b>."; ?> | |
</p> | |
</div> | |
<div class="wrap" id="container" data-userId="<?php echo($logged_user_id); ?>"> | |
<form id="create-draw" method="POST" action="../../site_processor.php?a=create_draw" enctype="multipart/form-data"> | |
<input type="hidden" name="rt_user_image" id="rt_user_image" value="<?php echo($logged_user_tw_image); ?>"/> | |
<input type="hidden" name="rt_user_name" id="rt_user_name" value="<?php echo($logged_user_tw_name); ?>"/> | |
<input type="hidden" name="rt_user_username" id="rt_user_username" value="<?php echo($logged_user_tw_username); ?>"/> | |
<input type="hidden" name="draw_coupons_criteria" id="draw_coupons_criteria" value="single"/> | |
<input type="hidden" name="hashtag_suggested_text" id="hashtag_suggested_text" value="<?php echo($hashtag_suggested_text); ?>"/> | |
<input type="hidden" name="mention_suggested_text" id="mention_suggested_text" value="<?php echo($mention_suggested_text); ?>"/> | |
<input type="hidden" name="rules-suffixes" id="rules-suffixes"/> | |
<input type="hidden" name="prizes-suffixes" id="prizes-suffixes"/> | |
<img style="display:none;" id="delete-image" src="<?php echo(STATIC_BASE_URL); ?>/images/delete_icon_red.png"> | |
<div class="twoColumns" id="notLoggedInHomepage"> | |
<!-- LEFT COLUMN --> | |
<div class="wideColumn"> | |
<h2 id="titulo-sorteo" class="edit"> | |
<font ><?php echo translate("DRAW"); ?>:</font> | |
" | |
<input class="decorated draw-title" type="text" name="draw_title" id="draw_title" data-validationMsj="<?php echo translate("DRAW_NAME_VALIDATION_MESSAGE"); ?>" placeholder="<?php echo translate("DRAW_NAME_PLACEHOLDER"); ?>" value="<?php echo($cd_title); ?>"/> | |
" | |
</h2> | |
<div class="clear"></div> | |
<div class="big-image-wrapper"> | |
<div class="overlay-image" style="display:none;"> | |
<img id="show_img" width="600px" /> | |
</div> | |
<div class='upload_stuff'> | |
<input type="hidden" id="hidden_img" name="draw_image" val="" data-validationMsj="Debe introducir una imagen para el sorteo" /> | |
<br/> | |
<h2 style="margin:100px 0px 5px 0px;"><?php echo (translate("DRAW_IMAGE_HERE")); ?></h2> | |
<h4 style="margin:0px 0px 30px 0px;"><?php echo translate("IMAGE_SIZE_RECOMMENDATION"); ?></h4> | |
<input class="grey-btn" style="margin:0px;" type="file" size="45" id="draw_image" name="draw_image_file" onchange="check_file('draw_image')"/> | |
<div class="img_loading" style="display:none;"> | |
<h3>Cargando...</h3> | |
<img src="<?php echo(STATIC_BASE_URL); ?>/images/ajax-loader.gif" /> | |
</div> | |
</div> | |
</div> | |
<!-- Bases y condiciones --> | |
<h2 id="titulo-sorteo" style="margin:20px 0px 0px 0px;"> | |
<font style="color:#2296C7;"><?php echo translate("TERMS_AND_CONDITIONS"); ?></font> | |
</h2> | |
<div class="clear"></div> | |
<textarea class="decorated ckeditor" style="width:592px; height:300px; resize:none;" name="draw_t_and_c" id="draw_t_and_c" data-validationMsj="<?php echo translate("TERMS_VALIDATION_MESSAGE"); ?>" placeholder="<?php echo translate("TERMS_PLACEHOLDER"); ?>"></textarea> | |
<!-- <a class="grey-btn" id="save-draw" style="float:right; margin: 20px 3px;" href="#">Guardar Sorteo</a> --> | |
<div class="clear"></div> | |
</div> | |
<!-- RIGHT COLUMN --> | |
<div class="narrowColumn"> | |
<div id="promo-details"> | |
<h3 class='organized-by-label' ><?php echo translate("ORGANIZED_BY"); ?>:</h3> | |
<div class='organizer-wrapper'> | |
<a class="creator-image" href="<?php echo($logged_user_tw_profile_url); ?>" title="<?php echo($owner_tw_name); ?>" target="_blank"> | |
<img src="<?php echo($logged_user_tw_image); ?>"> | |
</a> | |
<h3 class='name'><?php echo($logged_user_tw_name); ?></h3> | |
<a class='screen-name' href="<?php echo($logged_user_tw_profile_url); ?>"> | |
@<?php echo($logged_user_tw_username); ?> | |
</a> | |
<div class='clear'></div> | |
</div> | |
<hr class='single-hr' /> | |
<h3 class="validity"><?php echo translate("VALIDITY"); ?>:</h3> | |
<div id="new-period-wrapper"> | |
<div class="new-period-container create" > | |
<ul > | |
<li> | |
<label for="start_date"> | |
<?php echo translate("FROM"); ?>: | |
</label> | |
<input type="text" class="datepicker decorated enabledDatepicker" name="start_date" id="start_date" data-validationMsj="<?php echo translate("START_DATE_VALIDATION_MESSAGE"); ?>" placeholder=""> | |
<label for="start_date_hour" style="font-weight:bold; width:30px; margin:0px 3px; float:left;"> | |
<?php echo translate("AT"); ?> | |
</label> | |
<select class="enabledSelect" name="start_date_hour" id="start_date_hour"> | |
<?php | |
$str_hours = ""; | |
for($i=0; $i<=23; $i++) | |
{ | |
$str_num = ($i<10) ? "0".$i : $i; | |
$str_hours .= "<option value='".$i."'>".$str_num."</option>"; | |
} | |
echo($str_hours); | |
?> | |
</select> | |
<select class="enabledSelect" name="start_date_minutes" id="start_date_minutes"> | |
<?php | |
$str_minutes = ""; | |
// for($i=0; $i<=55; $i+=5) | |
// { | |
// $str_num = ($i<10) ? "0".$i : $i; | |
// $str_minutes .= "<option value='".$i."'>".$str_num."</option>"; | |
// } | |
for($i=0; $i<=50; $i+=10) | |
{ | |
$str_num = ($i<10) ? "0".$i : $i; | |
$str_minutes .= "<option value='".$i."'>".$str_num."</option>"; | |
} | |
echo($str_minutes); | |
?> | |
</select> | |
</li> | |
<li > | |
<label for="end_date" class="end_date"> | |
<?php echo translate("TO"); ?>: | |
</label> | |
<input type="text" class="datepicker decorated endDate" name="end_date" id="end_date" data-validationMsj="" placeholder="<?php echo translate("END_DATE_VALIDATION_MESSAGE"); ?>" value="<?php echo($cd_end_date_aux1); ?>"> | |
<label for="end_date_hour" class="at_hour_label" > | |
<?php echo translate("AT"); ?> | |
</label> | |
<select class="selectHour" name="end_date_hour" id="end_date_hour"> | |
<?php | |
echo($str_hours); | |
?> | |
</select> | |
<select class="selectMinutes" name="end_date_minutes" id="end_date_minutes"> | |
<?php | |
echo($str_minutes); | |
?> | |
</select> | |
</li> | |
</ul> | |
</div> | |
</div> | |
<hr class="default" /> | |
<div class="title-wrapper" > | |
<h3><?php echo translate("RULES"); ?>:</h3> | |
<a class="blue-btn add-rule floatRightOnly" href="#"><?php echo translate("ADD_RULE"); ?></a> | |
<div class="clear"></div> | |
</div> | |
<div class='rules-label-wrapper'><?php echo translate("RULES_LABEL_ADMIN"); ?></div> | |
<div id="new-rules-wrapper" class="edit"> | |
<div class="rules-container"> | |
<div class="rule-values"> | |
<ul class="rule-values-list"> | |
<!-- DYNAMIC CONTENT --> | |
</ul> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
<hr class="default" /> | |
<div class="title-wrapper"> | |
<h3 ><?php echo translate("PRIZES"); ?>:</h3> | |
<a class="blue-btn add-prize floatRightOnly" href="#"><?php echo translate("ADD_PRIZE"); ?></a> | |
<div class="clear"></div> | |
</div> | |
<div id="new-prizes-wrapper"> | |
<div class="prizes-container"> | |
<div class="prize-values"> | |
<ul class="prize-values-list"> | |
<!-- DYNAMIC CONTENT --> | |
</ul> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
<!-- | |
<hr class="default" /> | |
<div class="title-wrapper"> | |
<h3><?php echo translate("OTHERS"); ?>:</h3> | |
<div class="clear"></div> | |
</div> | |
<div id="participation_times_definition"><?php echo translate("DEFINE_PARTICIPATION_TIMES"); ?></div> | |
--> | |
<!-- <h3 style="margin: 20px 0px 0px; color:#2296C7;">Otros:</h3> --> | |
<!-- | |
<div id="new-prizes-wrapper"> | |
<div class="new-prize-container edit"> | |
<div class="others-desc edit" > | |
--> | |
<!-- <input class="floatLeftOnly" type="radio" name="draw_coupons_criteria" value="multiple" checked /> | |
<span class="coupons_criteria" ><?php echo translate("MULTIPLE_COUPONS"); ?></span> | |
<br/>--> | |
<!-- | |
<br/> | |
<input class="floatLeftOnly" type="radio" name="draw_coupons_criteria" value="single" checked /> | |
<span class="coupons_criteria" ><?php echo translate("ONE_COUPON"); ?></span> | |
<div class="clear"></div> | |
</div> | |
</div> | |
</div> | |
--> | |
</div> | |
</div> | |
</div> | |
<!-- FOOTER --> | |
<?php | |
// $f = new Footer(); | |
// $f->render(); | |
?> | |
<!-- END FOOTER --> | |
</form> | |
</div> | |
<div class="wrap" id="save-draw-container" style="margin-bottom:0px;"> | |
<a class="grey-btn" id="cancel-draw" href="/dashboard"><?php echo translate("CANCEL"); ?></a> | |
<a class="blue-btn" id="save-draw" href="#"><?php echo translate("CLICK_TO_PREVIEW_DRAW"); ?></a> | |
<div class="clear"></div> | |
</div> | |
<!-- FOOTER --> | |
<?php | |
$f = new Footer(); | |
$f->render(); | |
?> | |
<!-- END FOOTER --> | |
<script> | |
// Here goes the magic! | |
$(document).ready(function(){ | |
// CK editor | |
$("textarea.ckeditor").ckeditor({toolbar : 'Basic'}); | |
// Limit draw date | |
$(document).delegate(".datepicker", "click", function(event){ | |
event.preventDefault(); | |
$(this).datepicker({ dateFormat: "yy-mm-dd", minDate: "today" }).focus(); | |
// $(".datepicker").datepicker("option", "defaultDate", +7); | |
}); | |
$("#start_date").datepicker({ | |
dateFormat: "yy-mm-dd", | |
minDate: "today", | |
// defaultDate: +1, | |
onSelect: function (dateValue, inst) { | |
$("#end_date").datepicker("option", "minDate", dateValue) | |
} | |
}); | |
// Get current time in order to limit draw start hours and minutes | |
var currentTime = new Date(), | |
endTime = new Date(); | |
currentTime.setMinutes(currentTime.getMinutes() + 30); | |
var currentHour = currentTime.getHours(), | |
currentMinutes_aux = currentTime.getMinutes(), | |
c_minutes_mod = currentMinutes_aux % 10, | |
currentMinutes = (currentMinutes_aux - c_minutes_mod); | |
currentTime.setMinutes(currentTime.getMinutes() - c_minutes_mod); | |
currentTime.setSeconds(0); | |
currentTime.setMilliseconds(0); | |
// Set current time to draw start date selects | |
$("#start_date_hour").val(currentHour); | |
$("#start_date_minutes").val(currentMinutes); | |
// Manage end date | |
endTime.setMinutes(endTime.getMinutes() + 50); | |
var endHour = endTime.getHours(), | |
endMinutes_aux = endTime.getMinutes(), | |
e_minutes_mod = endMinutes_aux % 10, | |
endMinutes = (endMinutes_aux - e_minutes_mod); | |
endTime.setMinutes(endTime.getMinutes() - e_minutes_mod); | |
endTime.setSeconds(0); | |
endTime.setMilliseconds(0); | |
// Set current time to draw start date selects | |
$("#end_date_hour").val(endHour); | |
$("#end_date_minutes").val(endMinutes); | |
// Set current day | |
var a_year = currentTime.getFullYear(), | |
a_month_1 = currentTime.getMonth()+1, | |
a_month = (a_month_1<10) ? '0'+a_month_1 : a_month_1, | |
a_day_1 = currentTime.getDate(), | |
a_day = (a_day_1<10) ? '0'+a_day_1 : a_day_1, | |
a_date = a_year+"-"+a_month+"-"+a_day; | |
$("#start_date").val(a_date); | |
$("#end_date").val(a_date); | |
// RULES | |
// CREATE TWEET chars countdown | |
$(document).delegate(".scheduled-tweet-textarea", "keyup", function(event){ | |
var $textarea = $(this), | |
maxlength = parseInt($textarea.attr('data-maxlength')),// Store the maxlength and value of the field. | |
val = $textarea.val(), | |
newVal = val.slice(0, maxlength); | |
// Trim the field if it has content over the maxlength. | |
$textarea.val(newVal); | |
// get updated values | |
var new_num_chars = $textarea.val().length, | |
//new_max_chars = tweetCharsCountdown.getMaxChars(); | |
new_max_chars = maxlength; | |
if(new_num_chars>new_max_chars) | |
{ | |
var val = $textarea.val(), | |
newVal = val.substring(0, new_max_chars); | |
$textarea.val(newVal); | |
} | |
else// Update counter | |
{ | |
var $chars_countdown = $("#chars-left"); | |
// the last ten should be shown in red, otherwise show in light gray | |
(new_num_chars>(new_max_chars-10)) ? $chars_countdown.addClass("last-ten") : $chars_countdown.removeClass("last-ten"); | |
$chars_countdown.text(new_max_chars-new_num_chars); | |
} | |
}); | |
// SUGGESTED MESSAGE STUFF | |
// Site object | |
var suggestedMessages = (function(){ | |
var replacing_value = ''; | |
return { | |
init : function(initValue){ | |
replacing_value = initValue; | |
}, | |
getReplacingValue : function(){ | |
return replacing_value; | |
}, | |
setReplacingValue : function(newValue){ | |
replacing_value = newValue; | |
} | |
} | |
}()); | |
$(document).delegate(".f-plus-h-input", "keyup", function(event){ | |
var $input = $(this), | |
val = $input.val(), | |
val_prev = suggestedMessages.getReplacingValue(), | |
$textarea = $input.closest(".rule-fields").find(".suggested-messages-input"), | |
textarea_text = $textarea.val(), | |
replaced_text = textarea_text.replace(val_prev, "#"+val); | |
// Update replacing value in aux object | |
suggestedMessages.setReplacingValue("#"+val); | |
console.log(val); | |
console.log(textarea_text); | |
console.log(replaced_text); | |
// Replace #tusorteo with the input value | |
$textarea.val(replaced_text); | |
}); | |
// Manage CANCEL button in CREATE NEW RULE fancybox | |
$(document).delegate(".discard-rule", "click", function(event){ | |
event.preventDefault(); | |
$.fancybox.close(); | |
}); | |
// Manage AGREGAR button in CREATE NEW RULE fancybox | |
$(document).delegate(".create-rule", "click", function(event){ | |
event.preventDefault(); | |
// Get all the data | |
var $fields_container = $(this).closest("#create-new-rule-container").find(".rule-fields"), | |
rule_type = $fields_container.find("#h-rule-type").val(), | |
$rules_list = $(".rules-container").find(".rule-values-list"), | |
new_rule_html = '', | |
new_rule_hidden_values = '', | |
delete_img_src = $("#delete-image").attr('src'), | |
random_id = makeid(5), | |
current_rules_count = $(".rule-values-list .rule-item").length; | |
// Depending on the rule type, the way we are going to proccess the creation of the rule | |
switch(rule_type) | |
{ | |
case 'follow': | |
var follow_rules_aux = [], | |
follow_rules_str = '', | |
follow_rules_str_2 = '', | |
follow_rules_val = ''; | |
// Get all follow rules and concat them | |
$fields_container | |
.find(".follow-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
follow_rules_aux.push($(this).val()); | |
}); | |
// Validation | |
if(follow_rules_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_USERS,null,null,false"); ?>"); | |
return false; | |
} | |
else | |
{ | |
follow_rules_val = follow_rules_aux.join("|"); | |
follow_rules_str_2 = follow_rules_aux.join("</b>, <b>@"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_follow_rules" id="'+random_id+'_follow_rules" value="'+follow_rules_val+'"/>'; | |
follow_rules_str = '<?php echo translate("FOLLOW_TO"); ?> <b>@'+follow_rules_str_2+'</b>'; | |
// Create marckup for the new rule | |
// new_rule_html = '<h3 style="margin-bottom: 0px;">Opción '+(current_rules_count+1)+'</h3>'+ | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="follow"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+follow_rules_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>" /></a>'+ | |
'</li>'; | |
} | |
break; | |
case 'hashtag': | |
var hashtag_filters_aux = [], | |
hashtag_filters_str = '', | |
hashtag_filters_str_2 = '', | |
hashtag_filters_val = '', | |
suggested_messages_val = ''; | |
// Get all hashtag filters and concat them | |
$fields_container | |
.find(".hashtag-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
hashtag_filters_aux.push($(this).val()); | |
}); | |
// Get all suggested messages | |
$fields_container | |
.find(".suggested-messages-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
suggested_messages_val = $(this).val(); | |
}); | |
// Validation | |
if(hashtag_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_HASTHAGS"); ?>"); | |
return false; | |
} | |
// Suggested Message validation | |
if(suggested_messages_val.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_SUGGESTION_MESSAGES'); ?>"); | |
return false; | |
} | |
else | |
{ | |
// Now lets check that suggested message has the correct hashtags | |
// Extract hashtags/mentions of the suggested text | |
var text_objects = [], | |
can_add_rule = true; | |
text_objects = twttr.txt.extractHashtags(suggested_messages_val); | |
$(hashtag_filters_aux).each(function(){ | |
var text_valid_aux = $.inArray(""+this+"", text_objects), | |
text_valid = (text_valid_aux!=-1); | |
if(!text_valid) | |
{ | |
alert("<?php echo translate('SUGGESTION_MESSAGES_MUST_INCLUDE_HASHTAG', null, null, false); ?> #"+this); | |
can_add_rule = false; | |
return false; | |
} | |
}); | |
} | |
console.log(can_add_rule); | |
if(can_add_rule) | |
{ | |
// INPUT VALUES | |
hashtag_filters_val = hashtag_filters_aux.join("|"); | |
hashtag_filters_str_2 = hashtag_filters_aux.join("</b>, <b>#"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_hashtag_filters" id="'+random_id+'_hashtag_filters" value="'+hashtag_filters_val+'"/>'; | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_suggested_message" id="'+random_id+'_suggested_message" value="'+suggested_messages_val+'"/>'; | |
hashtag_filters_str = '<?php echo translate("SEND_TWEET_WITH_HASHTAG"); ?> <b>#'+hashtag_filters_str_2+'</b>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="hashtag"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+hashtag_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="Delete value"/></a>'+ | |
'</li>'; | |
} | |
else | |
{ | |
return false; | |
} | |
break; | |
case 'mention': | |
var mention_filters_aux = [], | |
mention_filters_str = '', | |
mention_filters_str_2 = '', | |
mention_filters_val = '', | |
suggested_messages_val = ''; | |
// Get all metion filters and concat them | |
$fields_container | |
.find(".mention-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
mention_filters_aux.push($(this).val()); | |
}); | |
// Get all suggested messages | |
$fields_container | |
.find(".suggested-messages-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
suggested_messages_val = $(this).val(); | |
}); | |
// Validation | |
if(mention_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_USERS_TO_MENTION"); ?>"); | |
return false; | |
} | |
// Suggested Message validation | |
if(suggested_messages_val.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_SUGGESTION_MESSAGES'); ?>"); | |
return false; | |
} | |
else | |
{ | |
// Now lets check that suggested message has the correct hashtags | |
// Extract hashtags/mentions of the suggested text | |
var text_objects = [], | |
can_add_rule = true; | |
text_objects = twttr.txt.extractMentions(suggested_messages_val); | |
$(mention_filters_aux).each(function(){ | |
var text_valid_aux = $.inArray(""+this+"", text_objects), | |
text_valid = (text_valid_aux!=-1); | |
if(!text_valid) | |
{ | |
alert("<?php echo translate('SUGGESTION_MESSAGES_MUST_INCLUDE_MENTION', null, null, false); ?> @"+this); | |
can_add_rule = false; | |
return false; | |
} | |
}); | |
} | |
console.log(can_add_rule); | |
if(can_add_rule) | |
{ | |
// INPUT VALUES | |
mention_filters_val = mention_filters_aux.join("|"); | |
mention_filters_str_2 = mention_filters_aux.join("</b>, <b>@"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_mention_filters" id="'+random_id+'_mention_filters" value="'+mention_filters_val+'"/>'; | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_suggested_message" id="'+random_id+'_suggested_message" value="'+suggested_messages_val+'"/>'; | |
mention_filters_str = '<?php echo translate("SEND_TWEET_MENTIONING_USER"); ?> <b>@'+mention_filters_str_2+'</b>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="mention"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+mention_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>"/></a>'+ | |
'</li>'; | |
} | |
else | |
{ | |
return false; | |
} | |
break; | |
case 'retweet': | |
var retweet_filters_aux = [], | |
retweet_filters_str = '', | |
retweet_filters_str_2 = '', | |
retweet_filters_str_3 = '', | |
retweet_filters_str_2_arr = [], | |
retweet_filters_val = ''; | |
// Get all retweet filters and concat them | |
$fields_container | |
.find(".retweet-object") | |
.filter(function(){ | |
// Consider extracting this method | |
// var is_valid = validateRT(this); | |
// Validate retweet fields | |
var //rt_day = $(this).find(".publish-day-input").val(), | |
rt_text = $(this).find(".tweet-text-input").val(), | |
is_valid = false; | |
// if(rt_day.trim()!="" && rt_text.trim()!="" && rt_text.trim().length<=119) | |
if(rt_text.trim()!="" && rt_text.trim().length<=<?php echo TWEET_MAX_LENGTH; ?>) | |
{ | |
is_valid = true; | |
} | |
return is_valid; | |
}) | |
.each(function(){ | |
// Create object and add it to the RTs array | |
var //rt_day = $(this).find(".publish-day-input").val(), | |
//rt_hour = $(this).find(".publish-hour-input").val(), | |
//rt_minutes = $(this).find(".publish-minutes-input").val(), | |
rt_text = $(this).find(".tweet-text-input").val(), | |
rt_user_image = $("#rt_user_image").val(), | |
rt_user_name = $("#rt_user_name").val(), | |
rt_user_username = $("#rt_user_username").val(), | |
rt_user_profile_url = "http://twitter.com/"+rt_user_username, | |
rt_object = { | |
//publication_day : rt_day, | |
//publication_hour : rt_hour, | |
//publication_minutes : rt_minutes, | |
tweet_text : rt_text | |
}; | |
retweet_filters_aux.push(rt_object); | |
// Build RT markup | |
// retweet_filters_str_2 = '<li>'+rt_text+'</li>'; | |
retweet_filters_str_2 = '<li class="retweet-item">'+ | |
'<a class="retweet-creator-image" href="'+rt_user_profile_url+'" title="'+rt_user_name+'" target="_blank">'+ | |
'<img src="'+rt_user_image+'"/>'+ | |
'</a>'+ | |
'<div class="retweet-data-wrapper">'+ | |
'<h3>'+ | |
'<a target="_blank" href="'+rt_user_profile_url+'">@'+rt_user_username+'</a>'+ | |
'</h3>'+ | |
'<div class="retweet-text">'+ | |
'<span class="prize-desc">'+rt_text+' <a href="http://sortwit.com" target="_blank">sortwit.com/link_al_sorteo</a>'+'</span>'+ | |
'</div>'+ | |
'</div>'+ | |
'</li>'; | |
retweet_filters_str_2_arr.push(retweet_filters_str_2); | |
}); | |
// Validation | |
if(retweet_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_TWEETS_TO_RETWEET"); ?>"); | |
return false; | |
} | |
else | |
{ | |
retweet_filters_val = JSON.stringify(retweet_filters_aux); | |
retweet_filters_str_3 = retweet_filters_str_2_arr.join(""); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_retweet_filters" id="'+random_id+'_retweet_filters" value=\''+retweet_filters_val+'\'/>'; | |
retweet_filters_str = '<?php echo translate("RT_THIS_TWEET_NOT_PUBLISHED_YET"); ?>:'+ | |
'<ul class="retweets-list">'+ | |
retweet_filters_str_3+ | |
'</ul>'+ | |
'<div class="clear"></div>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="retweet"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+retweet_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>"/></a>'+ | |
'</li>'; | |
} | |
break; | |
case 'follow_plus_hashtag': | |
var follow_rules_aux = [], | |
follow_rules_str = '', | |
follow_rules_str_2 = '', | |
follow_rules_val = '', | |
hashtag_filters_aux = [], | |
hashtag_filters_str = '', | |
hashtag_filters_str_2 = '', | |
hashtag_filters_val = '', | |
suggested_messages_val = ''; | |
// Get all follow rules and concat them | |
$fields_container | |
.find(".follow-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
follow_rules_aux.push($(this).val()); | |
}); | |
// Get all hashtag filters and concat them | |
$fields_container | |
.find(".hashtag-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
hashtag_filters_aux.push($(this).val()); | |
}); | |
// Get all suggested messages | |
$fields_container | |
.find(".suggested-messages-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
suggested_messages_val = $(this).val(); | |
}); | |
// Validation | |
if(follow_rules_aux.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_USERS'); ?>"); | |
return false; | |
} | |
// Hashtag validation | |
if(hashtag_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_HASHTAGS'); ?>"); | |
return false; | |
} | |
// Suggested Message validation | |
if(suggested_messages_val.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_SUGGESTION_MESSAGES'); ?>"); | |
return false; | |
} | |
else | |
{ | |
// Now lets check that suggested message has the correct hashtags | |
// Extract hashtags/mentions of the suggested text | |
var text_objects = [], | |
can_add_rule = true; | |
text_objects = twttr.txt.extractHashtags(suggested_messages_val); | |
$(hashtag_filters_aux).each(function(){ | |
var text_valid_aux = $.inArray(""+this+"", text_objects), | |
text_valid = (text_valid_aux!=-1); | |
if(!text_valid) | |
{ | |
alert("<?php echo translate('SUGGESTION_MESSAGES_MUST_INCLUDE_HASHTAG', null, null, false); ?> #"+this); | |
can_add_rule = false; | |
return false; | |
} | |
}); | |
} | |
console.log(can_add_rule); | |
if(can_add_rule) | |
{ | |
// INPUT VALUES | |
follow_rules_val = follow_rules_aux.join("|"); | |
follow_rules_str_2 = follow_rules_aux.join("</b>, <b>@"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_follow_rules" id="'+random_id+'_follow_rules" value="'+follow_rules_val+'"/>'; | |
follow_rules_str = '<?php echo translate("FOLLOW_TO"); ?> <b>@'+follow_rules_str_2+'</b>'; | |
hashtag_filters_val = hashtag_filters_aux.join("|"); | |
hashtag_filters_str_2 = hashtag_filters_aux.join("</b>, <b>#"); | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_hashtag_filters" id="'+random_id+'_hashtag_filters" value="'+hashtag_filters_val+'"/>'; | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_suggested_message" id="'+random_id+'_suggested_message" value="'+suggested_messages_val+'"/>'; | |
hashtag_filters_str = '<?php echo translate("SEND_TWEET_WITH_HASHTAG"); ?> <b>#'+hashtag_filters_str_2+'</b>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="follow_plus_hashtag"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+follow_rules_str+'</li>'+ | |
'<li>'+hashtag_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>" /></a>'+ | |
'</li>'; | |
} | |
else | |
{ | |
return false; | |
} | |
break; | |
case 'follow_plus_mention': | |
var follow_rules_aux = [], | |
follow_rules_str = '', | |
follow_rules_str_2 = '', | |
follow_rules_val = '', | |
mention_filters_aux = [], | |
mention_filters_str = '', | |
mention_filters_str_2 = '', | |
mention_filters_val = '', | |
suggested_messages_val = ''; | |
// Get all follow rules and concat them | |
$fields_container | |
.find(".follow-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
follow_rules_aux.push($(this).val()); | |
}); | |
// Get all metion filters and concat them | |
$fields_container | |
.find(".mention-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
mention_filters_aux.push($(this).val()); | |
}); | |
// Get all suggested messages | |
$fields_container | |
.find(".suggested-messages-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
suggested_messages_val = $(this).val(); | |
}); | |
// Validation | |
if(follow_rules_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_USERS"); ?>"); | |
return false; | |
} | |
if(mention_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_USERS_TO_MENTION"); ?>"); | |
return false; | |
} | |
// Suggested Message validation | |
if(suggested_messages_val.length == 0) | |
{ | |
alert("<?php echo translate('YOU_MUST_ADD_SUGGESTION_MESSAGES'); ?>"); | |
return false; | |
} | |
else | |
{ | |
// Now lets check that suggested message has the correct hashtags | |
// Extract hashtags/mentions of the suggested text | |
var text_objects = [], | |
can_add_rule = true; | |
text_objects = twttr.txt.extractMentions(suggested_messages_val); | |
$(mention_filters_aux).each(function(){ | |
var text_valid_aux = $.inArray(""+this+"", text_objects), | |
text_valid = (text_valid_aux!=-1); | |
if(!text_valid) | |
{ | |
alert("<?php echo translate('SUGGESTION_MESSAGES_MUST_INCLUDE_MENTION', null, null, false); ?> @"+this); | |
can_add_rule = false; | |
return false; | |
} | |
}); | |
} | |
console.log(can_add_rule); | |
if(can_add_rule) | |
{ | |
// INPUT VALUES | |
follow_rules_val = follow_rules_aux.join("|"); | |
follow_rules_str_2 = follow_rules_aux.join("</b>, <b>@"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_follow_rules" id="'+random_id+'_follow_rules" value="'+follow_rules_val+'"/>'; | |
follow_rules_str = '<?php echo translate("FOLLOW_TO"); ?> <b>@'+follow_rules_str_2+'</b>'; | |
mention_filters_val = mention_filters_aux.join("|"); | |
mention_filters_str_2 = mention_filters_aux.join("</b>, <b>@"); | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_mention_filters" id="'+random_id+'_mention_filters" value="'+mention_filters_val+'"/>'; | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_suggested_message" id="'+random_id+'_suggested_message" value="'+suggested_messages_val+'"/>'; | |
mention_filters_str = '<?php echo translate("SEND_TWEET_MENTIONING_USER"); ?> <b>@'+mention_filters_str_2+'</b>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="follow_plus_mention"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+follow_rules_str+'</li>'+ | |
'<li>'+mention_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>"/></a>'+ | |
'</li>'; | |
} | |
else | |
{ | |
return false; | |
} | |
break; | |
case 'follow_plus_retweet': | |
var follow_rules_aux = [], | |
follow_rules_str = '', | |
follow_rules_str_2 = '', | |
follow_rules_val = '', | |
retweet_filters_aux = [], | |
retweet_filters_str = '', | |
retweet_filters_str_2 = '', | |
retweet_filters_str_3 = '', | |
retweet_filters_str_2_arr = [], | |
retweet_filters_val = ''; | |
// Get all follow rules and concat them | |
$fields_container | |
.find(".follow-input") | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
follow_rules_aux.push($(this).val()); | |
}); | |
// Get all retweet filters and concat them | |
$fields_container | |
.find(".retweet-object") | |
.filter(function(){ | |
// Consider extracting this method | |
// var is_valid = validateRT(this); | |
// Validate retweet fields | |
var //rt_day = $(this).find(".publish-day-input").val(), | |
rt_text = $(this).find(".tweet-text-input").val(), | |
is_valid = false; | |
// if(rt_day.trim()!="" && rt_text.trim()!="" && rt_text.trim().length<=119) | |
if(rt_text.trim()!="" && rt_text.trim().length<=<?php echo TWEET_MAX_LENGTH; ?>) | |
{ | |
is_valid = true; | |
} | |
return is_valid; | |
}) | |
.each(function(){ | |
// Create object and add it to the RTs array | |
var //rt_day = $(this).find(".publish-day-input").val(), | |
//rt_hour = $(this).find(".publish-hour-input").val(), | |
//rt_minutes = $(this).find(".publish-minutes-input").val(), | |
rt_text = $(this).find(".tweet-text-input").val(), | |
rt_user_image = $("#rt_user_image").val(), | |
rt_user_name = $("#rt_user_name").val(), | |
rt_user_username = $("#rt_user_username").val(), | |
rt_user_profile_url = "http://twitter.com/"+rt_user_username, | |
rt_object = { | |
//publication_day : rt_day, | |
//publication_hour : rt_hour, | |
//publication_minutes : rt_minutes, | |
tweet_text : rt_text | |
}; | |
retweet_filters_aux.push(rt_object); | |
// Build RT markup | |
retweet_filters_str_2 = '<li class="retweet-item">'+ | |
'<a class="retweet-creator-image" href="'+rt_user_profile_url+'" title="'+rt_user_name+'" target="_blank">'+ | |
'<img src="'+rt_user_image+'"/>'+ | |
'</a>'+ | |
'<div class="retweet-data-wrapper">'+ | |
'<h3>'+ | |
'<a target="_blank" href="'+rt_user_profile_url+'">@'+rt_user_username+'</a>'+ | |
'</h3>'+ | |
'<div class="retweet-text">'+ | |
'<span class="prize-desc">'+rt_text+' <a href="http://sortwit.com" target="_blank">sortwit.com/link_al_sorteo</a>'+'</span>'+ | |
'</div>'+ | |
'</div>'+ | |
'</li>'; | |
retweet_filters_str_2_arr.push(retweet_filters_str_2); | |
}); | |
// Validation | |
if(follow_rules_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_USERS"); ?>"); | |
return false; | |
} | |
if(retweet_filters_aux.length == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_TWEETS_TO_RETWEET"); ?>"); | |
return false; | |
} | |
follow_rules_val = follow_rules_aux.join("|"); | |
follow_rules_str_2 = follow_rules_aux.join("</b>, <b>@"); | |
new_rule_hidden_values = '<input type="hidden" name="'+random_id+'_follow_rules" id="'+random_id+'_follow_rules" value="'+follow_rules_val+'"/>'; | |
follow_rules_str = '<?php echo translate("FOLLOW_TO"); ?> <b>@'+follow_rules_str_2+'</b>'; | |
retweet_filters_val = JSON.stringify(retweet_filters_aux); | |
retweet_filters_str_3 = retweet_filters_str_2_arr.join(""); | |
new_rule_hidden_values += '<input type="hidden" name="'+random_id+'_retweet_filters" id="'+random_id+'_retweet_filters" value=\''+retweet_filters_val+'\'/>'; | |
retweet_filters_str = '<?php echo translate("RT_THIS_TWEET_NOT_PUBLISHED_YET"); ?>:'+ | |
'<ul class="retweets-list">'+ | |
retweet_filters_str_3+ | |
'</ul>'+ | |
'<div class="clear"></div>'; | |
// Create marckup for the new rule | |
new_rule_html = '<li class="rule-item">'+ | |
'<input type="hidden" name="'+random_id+'_type" id="'+random_id+'_type" value="follow_plus_retweet"/>'+ | |
'<input type="hidden" class="rule_suffix" value="'+random_id+'"/>'+ | |
new_rule_hidden_values+ | |
'<ul class="rules-list">'+ | |
'<li>'+follow_rules_str+'</li>'+ | |
'<li>'+retweet_filters_str+'</li>'+ | |
'</ul>'+ | |
'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>"/></a>'+ | |
'</li>'; | |
break; | |
default: | |
new_rule_html = ''; | |
} | |
//console.log(rule_type+" FIELDS", $fields_container); | |
$rules_list.append(new_rule_html); | |
$.fancybox.close(); | |
}); | |
// Manage rule type selection change | |
$(document).delegate(".rule-type-select", "change", function(event){ | |
event.preventDefault(); | |
var rule_type = $(this).val(), | |
$fields_container = $(this).closest("#create-new-rule-container").find(".rule-fields"), | |
$create_rule_button = $(this).closest("#create-new-rule-container").find(".create-rule"), | |
$discard_rule_button = $(this).closest("#create-new-rule-container").find(".discard-rule"), | |
fields_html = '<input type="hidden" name="h-rule-type" id="h-rule-type" value="'+rule_type+'"/>', | |
delete_img_src = '', | |
tweet_random_number = '', | |
username_to_follow = $("#rt_user_username").val(), | |
hashtag_suggested_text = $("#hashtag_suggested_text").val(), | |
mention_suggested_text = $("#mention_suggested_text").val(); | |
// Depending on the rule type the user has selected, then add corresponding fields | |
switch(rule_type) | |
{ | |
case 'follow': | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span class="rule-type-text"><?php echo translate("FOLLOW_USER"); ?></span> <span class="rule-type-character">@</span>'+ | |
'<input class="follow-input decorated rule-input" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled">'; | |
//'<a href="#" class="delete-rule"><img src="'+delete_img_src+'" title="Delete value"/></a>'; | |
break; | |
case 'hashtag': | |
// Init suggested message aux object | |
suggestedMessages.init("#tuhashtag"); | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("SEND_TWEET_WITH"); ?></span> <span class="rule-type-character">#</span>'+ | |
'<input class="hashtag-input decorated rule-input f-plus-h-input" type="text" placeholder="hashtag">'+ | |
'<div style="margin: 10px 8px;" class="retweet-object">'+ | |
'<hr style="margin: 10px 0px 5px 0px;"/>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px; font-size: 10px; color: #2296C7;" class="rule-type-text"><?php echo translate("SUGGESTED_MESSAGE"); ?></span>'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="suggested-messages-input tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("SUGGESTED_MESSAGE_2"); ?>">'+hashtag_suggested_text+'</textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" style="margin: 10px 0px;">'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
// '<div class="draw-link-be-tweeted">- <?php echo translate("HASHTAG_REPLACED_MSG",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
break; | |
case 'mention': | |
// Init suggested message aux object | |
// suggestedMessages.init("#tuhashtag"); | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("SEND_TWEET_WITH_2"); ?></span> <span class="rule-type-character">@</span>'+ | |
'<input class="mention-input decorated rule-input" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled"/>'+ | |
'<div style="margin: 10px 8px;" class="retweet-object">'+ | |
'<hr style="margin: 10px 0px 5px 0px;"/>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px; font-size: 10px; color: #2296C7;" class="rule-type-text"><?php echo translate("SUGGESTED_MESSAGE"); ?></span>'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="suggested-messages-input tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("SUGGESTED_MESSAGE_2"); ?>">'+mention_suggested_text+'</textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" style="margin: 10px 0px;">'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
// '<div class="draw-link-be-tweeted">- <?php echo translate("HASHTAG_REPLACED_MSG",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
// fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
// '<span class="rule-type-text">- <?php echo translate("TWEET_WITH_MENTION_TO"); ?></span> <span class="rule-type-character">@</span>'+ | |
// '<input class="mention-input decorated rule-input" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>">'; | |
break; | |
case 'retweet': | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px;" class="rule-type-text">- <?php echo translate("TWEET_TEXT_2"); ?></span>'+ | |
'<div style="margin: 3px 8px;" class="retweet-object">'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("TWEET_TEXT_3"); ?>"></textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" >'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("TWEET_WILL_BE_SENT_AT",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
break; | |
case 'follow_plus_hashtag': | |
// Init suggested message aux object | |
suggestedMessages.init("#tuhashtag"); | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("FOLLOW_USER_2"); ?></span> <span style="color: #2296C7;">@'+username_to_follow+'</span>'+ | |
'<input class="follow-input decorated" style="display:none;width:105px; padding: 4px 3px; height: 14px;" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled">'+ | |
// '<div class="and-rule-separator"><?php echo translate("AND"); ?></div>'+ | |
'<div class="and-rule-separator"></div>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("SEND_TWEET_WITH"); ?></span> <span class="rule-type-character">#</span>'+ | |
'<input class="hashtag-input decorated rule-input f-plus-h-input" type="text" placeholder="hashtag">'+ | |
'<div style="margin: 10px 8px;" class="retweet-object">'+ | |
'<hr style="margin: 10px 0px 5px 0px;"/>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px; font-size: 10px; color: #2296C7;" class="rule-type-text"><?php echo translate("SUGGESTED_MESSAGE"); ?></span>'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="suggested-messages-input tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("SUGGESTED_MESSAGE_2"); ?>">'+hashtag_suggested_text+'</textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" style="margin: 10px 0px;">'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
// '<div class="draw-link-be-tweeted">- <?php echo translate("HASHTAG_REPLACED_MSG",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
break; | |
case 'follow_plus_mention': | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("FOLLOW_USER_2"); ?></span> <span style="color: #2296C7;">@'+username_to_follow+'</span>'+ | |
'<input class="follow-input decorated" style="display:none;width:105px; padding: 4px 3px; height: 14px;" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled">'+ | |
// '<div class="and-rule-separator"><?php echo translate("AND"); ?></div>'+ | |
'<div class="and-rule-separator"></div>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("SEND_TWEET_WITH_2"); ?></span> <span class="rule-type-character">@</span>'+ | |
'<input class="mention-input decorated rule-input" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled"/>'+ | |
'<div style="margin: 10px 8px;" class="retweet-object">'+ | |
'<hr style="margin: 10px 0px 5px 0px;"/>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px; font-size: 10px; color: #2296C7;" class="rule-type-text"><?php echo translate("SUGGESTED_MESSAGE"); ?></span>'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="suggested-messages-input tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("SUGGESTED_MESSAGE_2"); ?>">'+mention_suggested_text+'</textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" style="margin: 10px 0px;">'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
// '<div class="draw-link-be-tweeted">- <?php echo translate("HASHTAG_REPLACED_MSG",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
// fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
// '<span style="width:auto;" class="rule-type-text">- <?php echo translate("FOLLOW_USER_2"); ?></span> <span style="color: #2296C7;">@'+username_to_follow+'</span>'+ | |
// // '<span style="color: #2296C7; font-weight:normal;" class="rule-type-character">'+username_to_follow+'</span>'+ | |
// '<input class="follow-input decorated" style="display:none;width:105px; padding: 4px 3px; height: 14px;" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled">'+ | |
// '<div class="and-rule-separator"></div>'+ | |
// '<span class="rule-type-text">- <?php echo translate("TWEET_WITH_MENTION_TO"); ?></span> <span class="rule-type-character">@</span>'+ | |
// '<input class="mention-input decorated rule-input" type="text" placeholder="<?php echo translate("TWEET_TEXT"); ?>">'; | |
break; | |
case 'follow_plus_retweet': | |
fields_html += '<h3 style="font-weight: normal; margin: 0px 0px 5px 0px;"><?php echo translate("THE_USER_SHOULD",null,null,false); ?>:</h3>'+ | |
'<span style="width:auto;" class="rule-type-text">- <?php echo translate("FOLLOW_USER_2"); ?></span> <span style="color: #2296C7;">@'+username_to_follow+'</span>'+ | |
// '<span style="color: #2296C7; font-weight:normal;" class="rule-type-character">'+username_to_follow+'</span>'+ | |
'<input class="follow-input decorated" style="display:none;width:105px; padding: 4px 3px; height: 14px;" type="text" placeholder="<?php echo translate("TWITTER_USERNAME"); ?>" value="'+username_to_follow+'" disabled="disabled">'+ | |
'<div class="and-rule-separator"></div>'+ | |
'<span style="width:300px; margin: 0px 0px 5px 0px;" class="rule-type-text">- <?php echo translate("TWEET_TEXT_2"); ?></span>'+ | |
'<div style="margin: 3px 8px;" class="retweet-object">'+ | |
// '<h3><strong><?php echo translate("TWEET_PUBLISH_DATE",null,null,false); ?></strong></h3>'+ | |
// '<div class="firstDiv">'+ | |
// '(<?php echo translate("TWEET_WILL_BE_PUBLISHED_AT_THE_BEGINNING"); ?>)'+ | |
// '<label style="font-weight:bold; width:45px; float:left;">'+ | |
// 'Dia:'+ | |
// '</label>'+ | |
// '<input style="padding: 4px 3px; height: 14px; float:left; width:55px; font-size:10px;" type="text" class="publish-day-input datepicker decorated" data-validationmsj="Debe introducir la fecha de inicio del sorteo" placeholder="">'+ | |
// '<label style="font-weight:bold; width:30px; margin:0px 10px; float:left;">'+ | |
// 'a las'+ | |
// '</label>'+ | |
// '<select style="float:left; margin:3px 5px;" class="publish-hour-input">'+ | |
// '<option value="1">01</option><option value="2">02</option><option value="3">03</option><option value="4">04</option><option value="5">05</option><option value="6">06</option><option value="7">07</option><option value="8">08</option><option value="9">09</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option>'+ | |
// '</select>'+ | |
// '<select style="float:left; margin:3px 5px;" class="publish-minutes-input">'+ | |
// '<option value="0">00</option><option value="5">05</option><option value="10">10</option><option value="15">15</option><option value="20">20</option><option value="25">25</option><option value="30">30</option><option value="35">35</option><option value="40">40</option><option value="45">45</option><option value="50">50</option><option value="55">55</option>'+ | |
// '</select>'+ | |
// '</div>'+ | |
// '<h3><strong><?php echo translate("TWEET_TEXT_2"); ?></strong></h3>'+ | |
'<div class="noMarginBottom">'+ | |
'<textarea style="width: 300px;" class="tweet-text-input scheduled-tweet-textarea decorated" data-maxlength="<?php echo TWEET_MAX_LENGTH; ?>" placeholder="<?php echo translate("TWEET_TEXT_3"); ?>"></textarea>'+ | |
'</div>'+ | |
'<div class="tweet-btns-container" style="margin: 10px 0px;">'+ | |
'<div style="font-size:9px; float: left; width: 245px;" class="explanations-wrapper">'+ | |
'<div class="draw-link-be-tweeted"><?php echo translate("EXPLANATIONS_TITLE",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("A_LINK_TO_THE_DRAW_WILL_BE_INCLUDED",null,null,false); ?></div>'+ | |
'<div class="draw-link-be-tweeted">- <?php echo translate("TWEET_WILL_BE_SENT_AT",null,null,false); ?></div>'+ | |
'</div>'+ | |
'<div id="chars-left"><?php echo TWEET_MAX_LENGTH; ?></div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'+ | |
'</div>'; | |
break; | |
default: | |
fields_html = ""; | |
} | |
if(fields_html!="") | |
{ | |
$fields_container.html(fields_html).show(); | |
$create_rule_button.show(); | |
$discard_rule_button.show(); | |
} | |
else | |
{ | |
$fields_container.html("").hide(); | |
$create_rule_button.hide(); | |
$discard_rule_button.show(); | |
} | |
$.fancybox.center(); | |
}); | |
// Add new fucking rule | |
$("#promo-details").delegate(".add-rule", "click", function(event){ | |
event.preventDefault(); | |
// Count how many rules are there | |
var current_rules = $("#new-rules-wrapper .rule-values-list").find(".rule-item").length, | |
fancybox_html = ''; | |
if(current_rules<3) | |
{ | |
fancybox_html = '<div id="create-new-rule-container">'+ | |
'<h3 style="color: #2296C7;"><strong><?php echo translate("CREATE_NEW_RULE"); ?></strong></h3>'+ | |
'<div class="rule-type" >'+ | |
'<label>'+ | |
'<?php echo translate("RULE_TYPE"); ?>:'+ | |
'</label>'+ | |
'<select class="rule-type-select">'+ | |
'<option value="none"><?php echo translate("CHOOSE_RULE"); ?></option>'+ | |
// '<option value="follow">Seguir usuario</option>'+ | |
'<option value="follow_plus_retweet"><?php echo translate("FOLLOW_AND_RETWEET_RULE"); ?></option>'+ | |
'<option value="follow_plus_hashtag"><?php echo translate("FOLLOW_AND_HASHTAG_RULE"); ?></option>'+ | |
'<option value="follow_plus_mention"><?php echo translate("FOLLOW_AND_MENTION_RULE"); ?></option>'+ | |
'<option value="hashtag"><?php echo translate("TWEET_WITH_HASHTAG"); ?></option>'+ | |
'<option value="mention"><?php echo translate("TWEET_WITH_MENTION"); ?></option>'+ | |
'<option value="retweet"><?php echo translate("RETWEET_OF_A_TWEET"); ?></option>'+ | |
'</select>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="rule-fields" >'+ | |
'<!-- THIS CONTENT IS GENERATED DINAMICALY -->'+ | |
'</div>'+ | |
'<a class="blue-btn create-rule" href="#"><?php echo translate("ADD"); ?></a>'+ | |
'<!--<a style="floatRightOnly" class="grey-btn discard-rule" href="#"><?php echo translate("CANCEL"); ?></a>-->'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>'; | |
// Here we are going to show a fancybox in order to create the new rule | |
// Open all mighty fancybox | |
$.fancybox( | |
fancybox_html, | |
{ | |
'autoDimensions' : true, | |
//'width' : 500, | |
//'height' : 'auto', | |
// 'height' : 800, | |
'transitionIn' : 'none', | |
'transitionOut' : 'none', | |
'centerOnScroll' : true | |
} | |
); | |
} | |
else | |
{ | |
alert('<?php echo translate("MAX_ALLOWED_RULES_IN_DRAW", null, null, false); ?>'); | |
} | |
}); | |
$(document).delegate(".delete-rule", "click", function(event){ | |
event.preventDefault(); | |
// Remove list item | |
$(this).closest(".rule-item").fadeOut().remove(); | |
}); | |
// PRIZES | |
$("#promo-details").delegate(".add-prize", "click", function(event){ | |
event.preventDefault(); | |
var count_options = ''; | |
for(var i = 1; i <= 10; i++) | |
{ | |
count_options += '<option value="'+i+'">'+i+'</option>'; | |
} | |
// Here we are going to show a fancybox in order to create the new prize | |
// Open all mighty fancybox | |
$.fancybox( | |
'<div id="create-new-prize-container">'+ | |
'<h3><strong><?php echo translate("CREATE_NEW_PRIZE"); ?></strong></h3>'+ | |
'<div class="add-prize-description" >'+ | |
'<label>'+ | |
'<?php echo translate("PRODUCT_OR_SERVICE"); ?>:'+ | |
'</label>'+ | |
'<input class="add-prize-description-input decorated" type="text" placeholder="<?php echo translate("PRIZE"); ?>">'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="add-prize-count" >'+ | |
'<label >'+ | |
'<?php echo translate("QUANTITY"); ?>:'+ | |
'</label>'+ | |
'<select class="add-prize-count-select">'+ | |
count_options+ | |
'</select>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<a class="blue-btn create-prize" href="#"><?php echo translate("ADD"); ?></a>'+ | |
'<a class="grey-btn discard-rule floatRightOnly" href="#"><?php echo translate("CANCEL"); ?></a>'+ | |
'<div class="clear"></div>'+ | |
'</div>'+ | |
'<div class="clear"></div>', | |
{ | |
'autoDimensions' : true, | |
//'width' : 500, | |
//'height' : 'auto', | |
// 'height' : 800, | |
'transitionIn' : 'none', | |
'transitionOut' : 'none', | |
'centerOnScroll' : true | |
} | |
); | |
}); | |
$(document).delegate(".delete-prize", "click", function(event){ | |
event.preventDefault(); | |
// Remove list item | |
$(this).closest(".prize-item").fadeOut().remove(); | |
}); | |
// Manage AGREGAR button in CREATE NEW PRIZE fancybox | |
$(document).delegate(".create-prize", "click", function(event){ | |
event.preventDefault(); | |
// Get all the data | |
var $fields_container = $(this).closest("#create-new-prize-container"), | |
prize_count = $fields_container.find(".add-prize-count-select").val(), | |
prize_description = $fields_container.find(".add-prize-description-input").val(), | |
$prizes_list = $(".prizes-container").find(".prize-values-list"), | |
new_prize_html = '', | |
prize_str = '', | |
new_prize_hidden_values = '', | |
delete_img_src = $("#delete-image").attr('src'), | |
random_id = makeid(5); | |
// Validation | |
if(prize_description.trim() == "") | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_A_PRIZE_FIRST"); ?>"); | |
return false; | |
} | |
else | |
{ | |
new_prize_hidden_values = '<input type="hidden" name="'+random_id+'_prize_count" id="'+random_id+'_prize_count" value="'+prize_count+'"/>'+ | |
'<input type="hidden" name="'+random_id+'_prize_desc" id="'+random_id+'_prize_desc" value="'+prize_description+'"/>'; | |
prize_str = '<span class="prizeDescriptionSpan">'+prize_description+'</span>'+ | |
'<span style="floatRightOnly">(x'+prize_count+')</span>'+ | |
'<div class="clear"></div>'; | |
// Create marckup for the new rule | |
new_prize_html = '<li class="prize-item">'+ | |
'<input type="hidden" class="prize_suffix" value="'+random_id+'"/>'+ | |
new_prize_hidden_values+ | |
'<div class="">'+ | |
prize_str+ | |
'<a href="#" class="delete-prize"><img src="'+delete_img_src+'" title="<?php echo translate("DELETE"); ?>" /></a>'+ | |
'</div>'+ | |
'</li>'; | |
} | |
$prizes_list.append(new_prize_html); | |
$.fancybox.close(); | |
}); | |
// SAVE DRAW | |
$("#save-draw-container").delegate("#save-draw", "click", function(event){ | |
event.preventDefault(); | |
// Get all rules suffixes (those are the amount of PARTICIPATION WAYS the draw will have) | |
var $rules_suffixes = $(".rule_suffix"), | |
rules_suffixes = [], | |
rules_suffixes_str = '', | |
rules_count = $rules_suffixes.length, | |
$prizes_suffixes = $(".prize_suffix"), | |
prizes_suffixes = [], | |
prizes_suffixes_str = '', | |
prizes_count = $prizes_suffixes.length; | |
console.log($rules_suffixes); | |
if(rules_count == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_RULES_FIRST"); ?>"); | |
return false; | |
} | |
if(prizes_count == 0) | |
{ | |
alert("<?php echo translate("YOU_MUST_ADD_PRIZES_FIRST"); ?>"); | |
return false; | |
} | |
// Create a hidden input with all the rules and prizes suffixes | |
$rules_suffixes | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
rules_suffixes.push($(this).val()); | |
}); | |
rules_suffixes_str = rules_suffixes.join("|"); | |
$prizes_suffixes | |
.filter(function(){ | |
return ($(this).val().trim()!=""); | |
}) | |
.each(function(){ | |
prizes_suffixes.push($(this).val()); | |
}); | |
prizes_suffixes_str = prizes_suffixes.join("|"); | |
// Set values on hidden inputs | |
$("#rules-suffixes").val(rules_suffixes_str); | |
$("#prizes-suffixes").val(prizes_suffixes_str); | |
// Validate form | |
var valid_form = validateForm(currentTime, endTime); | |
// submit form in order to create the draw | |
if(valid_form) | |
{ | |
$("#create-draw").submit(); | |
} | |
}); | |
}); | |
function validateForm(currentTime, endTime) | |
{ | |
var fields = [ | |
$("#draw_title"), | |
$("#start_date"), | |
$("#end_date"), | |
$("#hidden_img"), | |
$("#draw_t_and_c") | |
], | |
$fields = $(fields), | |
complete_fields=true; | |
//First we validate that all fields are complete | |
$fields.each(function(){ | |
var trimmed_value = this.val().trim(); | |
if(trimmed_value=="") | |
{ | |
alert(this.attr("data-validationMsj")); | |
complete_fields = false; | |
return false; | |
} | |
}); | |
if(!complete_fields) | |
{ | |
return false; | |
} | |
else | |
{ | |
// Validate draw start and end date | |
var selected_start_hour = $("#start_date_hour").val(), | |
selected_start_minutes = $("#start_date_minutes").val(), | |
selected_start_date_str = $("#start_date").val(), | |
selected_start_date_arr = selected_start_date_str.split("-"), | |
selected_start_date_year = selected_start_date_arr[0], | |
selected_start_date_month = selected_start_date_arr[1], | |
selected_start_date_day = selected_start_date_arr[2], | |
selected_end_hour = $("#end_date_hour").val(), | |
selected_end_minutes = $("#end_date_minutes").val(), | |
selected_end_date_str = $("#end_date").val(), | |
selected_end_date_arr = selected_end_date_str.split("-"), | |
selected_end_date_year = selected_end_date_arr[0], | |
selected_end_date_month = selected_end_date_arr[1], | |
selected_end_date_day = selected_end_date_arr[2], | |
min_start_date = currentTime, | |
min_end_date = endTime, | |
selected_start_date = new Date(selected_start_date_year, (selected_start_date_month -1), selected_start_date_day, selected_start_hour, selected_start_minutes), | |
selected_end_date = new Date(selected_end_date_year, (selected_end_date_month -1), selected_end_date_day, selected_end_hour, selected_end_minutes); | |
console.log("min_start_date: ", min_start_date); | |
console.log("min_end_date: ", min_end_date); | |
console.log("selected_start_date: ", selected_start_date); | |
console.log("selected_end_date: ", selected_end_date); | |
if(selected_start_date<min_start_date) | |
{ | |
alert("<?php echo translate('START_DATE_VALIDATION', null, null, false); ?>"); | |
return false; | |
} | |
if(selected_end_date<min_end_date) | |
{ | |
alert("<?php echo translate('END_DATE_VALIDATION_1', null, null, false); ?>"); | |
return false; | |
} | |
if(selected_end_date<=selected_start_date) | |
{ | |
alert("<?php echo translate('END_DATE_VALIDATION_2', null, null, false); ?>"); | |
return false; | |
} | |
} | |
return true; | |
} | |
function check_file(file) | |
{ | |
var $file = $("#"+file+""), | |
file_val = $file.val(), | |
file_extension_aux = file_val.split('.').pop(), | |
file_extension = file_extension_aux.toLowerCase(); | |
//alert(file_extension); | |
if(!(file_extension && /^(gif|jpeg|jpg|png)$/.test(file_extension))) | |
{ | |
// extension is not allowed | |
// alert('Solo se permiten archivos ".gif", ".jpeg", ".jpg", ".png"'); | |
$file.val(''); | |
return false; | |
} | |
else | |
{ | |
//$("#solo_pdf_msg").css({'color': '#999999', 'font-weight': '400'}); | |
//return true; | |
ajaxFileUpload('draw_image','show_img','hidden_img'); | |
} | |
} | |
function makeid(length) | |
{ | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for(var i=0; i < length; i++) | |
{ | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
return text; | |
} | |
</script> | |
</div> | |
<!-- <footer id="footer"></footer> --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment