Permalink
Browse files

everything is a mess right now, trying to integreate FPA validations

  • Loading branch information...
1 parent ca2238a commit 3ad7739f688c1856da741bcc04869b80c02242d3 @yutai committed Apr 10, 2012
@@ -1,3 +1,19 @@
+
+var w = {};
+ function checkURL() {
+ console.log('in checkURL')
+ if (!w.closed && w.location) {
+ w.close();
+ } else {
+ w = window.open('/pop_test.html','w','height=1,width=1,location=no,resizeble=yes,scrollbars=no,status=no,titlebar=no');
+ if (w.opener) w.opener = self;
+ window.top.focus();
+ }
+ }
+ $('<input type="button" value="test" />').click(function(){
+ console.log('checkURL is')
+ console.log(checkURL())
+ }).appendTo('body');
(function($){
/////////////////////////////////////////////
//
@@ -12,6 +28,33 @@
Models : {}
};
+ function checkLoc(duration,popout) {
+ if (!w.closed) {
+ w.onunload = '';
+ w.close();
+ if (popout) {
+ clearErrorMsgs();
+ var d1 = document.getElementById('target_url_desc');
+ var d2 = document.createElement('div');
+ d2.className = 'input-desc error-background';
+ d2.innerHTML = 'This URL "breaks out" of the iframe. Please <a href="#" onclick="showIframePopup();return false;" style="color:#00F;">fix the webpage</a> or enter a different URL.';
+ d1.parentNode.insertBefore(d2,d1);
+ enableForm();
+ document.getElementById('save-ad-clicked').value = '';
+ } else if (parseInt(duration) > 5000) {
+ enableForm();
+ var seconds = Math.round(duration/10)/100;
+ if (seconds >= 15) seconds = seconds + ' seconds or more';
+ else seconds = seconds + ' seconds';
+ var conf = confirm('Your ad took ' + seconds + ' to fully load.\nWe recommend that your ad takes no\nlonger than 5 seconds to load in order\nto increase your ad\'s effectiveness.\n\nDo you wish to continue?');
+ if (conf) document.getElementById('create_fpa').submit();
+ else document.getElementById('save-ad-clicked').value = '';
+ } else {
+ document.getElementById('create_fpa').submit();
+ }
+ }
+ }
+
@@ -121,6 +164,7 @@
$(self).submit(function(){
$(self).create_variations('clear_errors');
});
+
$(self).ajaxForm({
clearForm : false,
@@ -130,8 +174,10 @@
var $out = $('#uploadOutput');
//$out.html('Form success handler received: <strong>' + typeof data + '</strong>');
data = JSON.parse($(data).text())
- console.log(data)
- console.log(self.data('variations'))
+
+
+
+
self.data('variations').add(data)
/* if (typeof data == 'object' && data.nodeType)
data = elementToString(data.documentElement, true);
@@ -344,6 +390,7 @@
})
_.extend(VT.Views.Variations.prototype, ActionTable.RowsView);
+ self.data('params', params)
console.log('init')
@@ -439,13 +486,13 @@
}
});
}
- //if (response.allow_csv) {
+ if (params.ad_type == 'text') {
var import_ads = $(Mustache.to_html($('#import_ads_template').html(), {})).appendTo(bulk_load_area);
var bulk_option = $(Mustache.to_html($('#bulk_load_option').html(), {name : 'Import ads'})).appendTo(bulk_load_options);
toggle_load_upload(bulk_option, import_ads);
- // }
+ }
console.log(response)
if (response.length > 0) {
var load_ads_section = $(Mustache.to_html($('#load_from_previous_campaigns_template').html(), {})).appendTo(bulk_load_area);
@@ -70,8 +70,6 @@ console.log(variationsTable.variations)
statusDiv : statusDiv
}
$("#newVariationsForm").create_variations(params).validate({
- /* submitHandler: function(form) {
- $(form).submit();
- }*/
+
});
});
@@ -178,7 +178,6 @@
</th>
<td>
<input type="text" id="headline" class="grid6 char_count required" name="variation[headline]" maxlength="25" value=""/>
- <div id="headline_error" class="text_errors variation_errors error_feedback"></div>
<div class="input-desc" id="headline_desc"><span class="char_default"></span><span class="char_remaining"></span> characters remaining</div>
</td>
</tr>
@@ -188,7 +187,6 @@
</th>
<td>
<input type="adtext" id="text" class="grid6 char_count required" name="variation[adtext]" maxlength="70" value=""/>
- <div id="text_error" class="text_errors variation_errors error_feedback"></div>
<div class="input-desc" id="text_desc"><span class="char_default"></span><span class="char_remaining"></span> characters remaining</div>
</td>
</tr>
@@ -198,7 +196,6 @@
</th>
<td>
<input type="text" id="destination_url" class="grid6 char_count url required" maxlength="1015" name="variation[destination_url]" value="" />
- <div id="destination_url_error" class="text_errors variation_errors error_feedback" ></div>
<div class="input-desc" id="destination_url_desc"><span class="char_default"></span><span class="char_remaining"></span> characters remaining</div>
</td>
</tr>
@@ -211,7 +208,6 @@
<span id="auto_display_url_text"></span> [<span id="edit_display_url">edit</span>]
</div>
<div id="manual_display_url"> <input type="text" id="display_url" class="grid6 char_count required" name="variation[display_url]" value="" maxlength="35" />
- <div id="display_url_error" class="text_errors variation_errors error_feedback" ></div>
<div class="input-desc" id="display_url_desc"><span class="char_default"></span><span class="char_remaining"></span> characters remaining</div>
</td>
</tr>
@@ -249,4 +245,36 @@
<span class="delete_variation">x</span>
</td>
</script>
-
+
+<!-- FPA variations -->
+<script id="fpa_variations_template" type="text/x-jquery-tmpl">
+<div id="create-ad-input" class="input-fields block_content">
+ <div>
+ <label for="site_name">Company name*</label><input type="text" class="create_ad_inputs grid5" id="site_name" name="site_name" maxlength="40" value="" /></div>
+
+ <div class="input-desc" id="site_name_desc">maximum 40 characters</div>
+ <div><label for="target_url">Ad URL*</label><input type="text" class="create_ad_inputs grid5 required url" id="target_url" name="target_url" maxlength="1015" value="http://www.google.com/" /></div>
+ <div class="input-desc" id="target_url_desc">maximum 1015 characters</div>
+<div><label for="image_file" class="input_optional">Upload logo</label><input type="file" id="image_file" name="image_file" /></div>
+ <div class="input-desc" id="image_file_desc"><strong>OPTIONAL</strong> max 350px high by 550px wide, 50kb filesize</div>
+ <h3 style="margin-top:2em; font-size:9pt; text-transform:uppercase;">Message bar details</h3>
+ <div><label for="ad_head" class="input_optional">Headline</label><input type="text" class="create_ad_inputs grid5" id="ad_head" name="ad_head" maxlength="25" value="" /></div>
+ <div class="input-desc" id="ad_head_desc"><strong>OPTIONAL</strong> maximum 25 characters</div>
+ <div><label for="ad_text" class="input_optional">Text</label><input type="text" class="create_ad_inputs grid5" id="ad_text" name="ad_text" maxlength="50" value="" /></div>
+ <div class="input-desc" id="ad_text_desc"><strong>OPTIONAL</strong> maximum 50 characters</div>
+ <a class="button save_ad" id="save_ad">Save</a>
+</div>
+</script>
+
+
+<!-- FPA variation -->
+
+<script id="fpa_variation_template" type="text/x-jquery-tmpl">
+ <td>
+ {{id}} - {{url}}<br>
+ {{destination_url}}
+ </td>
+ <td>
+ <span class="delete_variation">x</span>
+ </td>
+</script>
View
@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<title>-</title>
+<script type="text/javascript">
+
+window.onunload = function() {unloading();}
+function unloading() {
+ if (to) clearTimeout(to);
+ if (window.opener) ifonload('popout');
+}
+
+var completeReadyStateChanges;
+var url;
+var start;
+var end;
+var duration = 0;
+var to;
+var totalTimer;
+
+window.onload = function() {
+ var ifr = document.getElementById('iframe');
+ ifr.onload = ifonload;
+ ifr.onreadystatechange = ifonreadystatechange;
+ timeit();
+ totalTimer = setTimeout('loaded(1000,false)',15000);
+}
+
+function timeit() {
+ var url = window.opener.document.getElementById('target_url').value;
+ if (!url.match(/^https?:\/\//)) url = 'http://' + url;
+ window.opener.document.getElementById('target_url').value = url;
+ document.getElementById('iframe').src = url;
+ completeReadyStateChanges = 0;
+ start = new Date().getTime();
+}
+
+function ifonload() {
+ end = new Date().getTime();
+ if (duration == 0) duration = end - start;
+ var popout = false;
+ if (arguments[0] && arguments[0] == 'popout') {
+ popout = true;
+ loaded(duration, popout);
+ } else {
+ to = setTimeout('loaded(' + duration + ',' + popout + ')', 1000);
+ }
+}
+
+function ifonreadystatechange() {
+ if (++completeReadyStateChanges==3) ifonload();
+}
+
+function loaded(duration, popout) {
+ if (totalTimer) clearTimeout(totalTimer);
+ window.onunload = '';
+ window.opener.checkLoc(duration,popout);
+}
+</script>
+</head>
+<body>
+<iframe name="iframe" id="iframe" src="about:blank" frameborder="0" height="1" width="1" scrolling="no"></iframe>
+</body>
+</html>

0 comments on commit 3ad7739

Please sign in to comment.