Permalink
Browse files

making routing work for create variationts. in the middle of setting …

…up a fetch of banner info, and them passing the banner to the create_ui. right now, the create vars plugin is looking for something called params, be sure to swap it out for params.banner where ever banner info is concerned
  • Loading branch information...
1 parent a0112b7 commit 0c1bfda7e7881be7b3a257fd36a559026c18d085 @yutai committed Apr 13, 2012
@@ -407,6 +407,7 @@ ActionTable.RowsView = {
_.bindAll(this,'render','appendItem','appendItem2','addToCollection');
this.collection.bind('add',this.addToCollection);
this.collection.bind('change',this.render);
+ this.collection.bind('destroy',this.render)
this.collection.bind('reset',this.render);
this.collection.bind('sort',this.sort);
this.container_type = $(this.el).prop('tagName').toLowerCase();
@@ -650,7 +651,7 @@ ActionTable.RowView = {
initialize : function()
{
_.bindAll(this,'render','unrender','remove');
- this.bind('remove',this.unrender);
+ //this.model.bind('destroy',this.unrender)
this.model.bind('save', this.render)
},
@@ -668,14 +669,12 @@ ActionTable.RowView = {
},
unrender: function()
{
+ console.log('RowView Unrender')
var el = $(this.el);
el.fadeOut('fast', function(){
el.remove()
});
- },
- remove: function()
- {
- this.model.destroy();
}
+
};
@@ -1,19 +1,71 @@
-/*
-var w = {};
+///////////////////////////////////////////////////////////////
+//
+// This hack was design to test if the FPA breaks frame
+// It needs to open a new window to do so.
+// In order for it to work, the for must use the name 'variation[destination_url]' and
+// id of 'destination_url' for the relevant input
+//
+///////////////////////////////////////////////////////////////
+
+var FPAHack = function (varForm){
+ this.w = '';
+ this.checkURL = function () {
+ if (!this.w.closed && this.w.location) {
+ this.w.close();
+ } else {
+ this.w = window.open('/pop_test2.html','w','height=1,width=1,location=no,resizeble=yes,scrollbars=no,status=no,titlebar=no');
+ this.w.opener = self;
+ window.top.focus();
+ }
+ };
+ this.enableForm = function(){
+ console.log('in enable form')
+ $(varForm.currentForm).find('input').removeProp('disabled')
+ };
+
+ this.checkLoc = function (duration,popout) {
+ w = this.w;
+ console.log(varForm)
+
+ this.enableForm();
+ if (!w.closed) {
+ w.onunload = '';
+ w.close();
+
+ if (popout) {
+ console.log('popout')
+ varForm.showErrors({"variation[destination_url]" : '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.'});
+ console.log($(varForm.currentForm).find('input'))
+ document.getElementById('save-ad-clicked').value = '';
+ } else if (parseInt(duration) > 5000) {
+ console.log('in long duration')
+ 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) $(varForm.currentForm).submit();
+
+// else document.getElementById('save-ad-clicked').value = '';
+ } else {
+ console.log('all good')
+ $(varForm.currentForm).submit();
+ }
+ }
+ };
+
+ this.ensure_close = function()
+ {
+ window.onunload = function() {
+ if (!fpa_hack.w.closed && fpa_hack.w.location) {
+ this.w.close();
+ }
+ };
+ }
+
+};
-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();
- }
-}
-*/
+var fpa_hack = {};
@@ -119,12 +171,13 @@ function checkURL() {
{
var self = this;
return this.each(function(){
- self.data('w',{})
$('<input type="button" value="test" />').click(function(){
console.log('checkURL is')
- self.create_variations('checkURL')
+ $(self).find('input').prop('disabled','disabled')
+ fpa_hack.checkURL();
}).appendTo('body');
-
+
+
VT.Models.Variation = Backbone.Model.extend();
_.extend(VT.Models.Variation.prototype, ActionTable.Row);
@@ -142,7 +195,7 @@ function checkURL() {
{
var view = this;
console.log(view.model)
- $(view.el).find('span.delete_variation').click(function(){view.model.set('display_url','www.setset.com');view.model.save();});
+ $(view.el).find('span.delete_variation').click(function(){view.model.destroy();});
}
});
_.extend(VT.Views.Variation.prototype, ActionTable.RowView)
@@ -332,24 +385,25 @@ function checkURL() {
});
console.log('deeeeeee')
},
+ /*
checkURL : function () {
var self = this;
console.log('in checkURL')
console.log(self.data())
- if (self.data('w') && !self.data('w').closed && self.data('w').location) {
- self.data('w').close();
+ if (fpa_hack.w && !fpa_hack.w.closed && fpa_hack.w.location) {
+ fpa_hack.w.close();
} else {
- self.data('w',window.open('/pop_test.html','w','height=1,width=1,location=no,resizeble=yes,scrollbars=no,status=no,titlebar=no'));
+ fpa_hack.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();
}
},
checkLoc :function (duration,popout) {
console.log('in checkLoc')
var self = this;
- var w = self.data('w');
+ var w = fpa_hack.w;
console.log(self.data())
- if (!w.closed) {
+ if (w && !w.closed) {
w.onunload = '';
//w.close();
if (popout) {
@@ -373,10 +427,11 @@ function checkURL() {
else document.getElementById('save-ad-clicked').value = '';
} else {
console.log('all good')
- document.getElementById('create_fpa').submit();
+ //document.getElementById('create_fpa').submit();
}
}
},
+ */
wink : function(w)
{
//w.close();
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -8,6 +8,31 @@ $(document).ready(function() {
}
});
*/
+var Workspace = Backbone.Router.extend({
+
+ routes: {
+ ":banner_id" : "fetch_banner"
+ },
+
+ fetch_banner: function(banner_id) {
+
+ },
+ create_ui : function(banner)
+ {
+ var statusDiv = $('<div></div>');
+ statusDiv.top_of_page_status();
+
+ var params =
+ {
+ banner : banner,
+ statusDiv : statusDiv
+ }
+ var varForm = $("#newVariationsForm");
+ var varForm = varForm.create_variations(params).validate();
+ fpa_hack = new FPAHack(varForm);
+ }
+
+});
/*
@@ -59,17 +84,6 @@ var variationsTable = new VariationsTable();
console.log('about to print variations')
console.log(variationsTable.variations)
*/
- var statusDiv = $('<div></div>');
- statusDiv.top_of_page_status();
- var params =
- {
- banner_id : banner_id,
- ad_type : ad_type,
- bid_type : bid_type,
- statusDiv : statusDiv
- }
- $("#newVariationsForm").create_variations(params).validate({
-
- });
+
});
@@ -0,0 +1,3 @@
+// Place all the styles related to the ui controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,13 @@
+class UiController < ApplicationController
+ def create_variations
+ end
+
+ def otex
+ end
+
+ def initalize_banner
+ end
+
+ def banner_details
+ end
+end
View
@@ -0,0 +1,2 @@
+module UiHelper
+end
@@ -0,0 +1,2 @@
+<h1>Ui#banner_details</h1>
+<p>Find me in app/views/ui/banner_details.html.erb</p>
Oops, something went wrong.

0 comments on commit 0c1bfda

Please sign in to comment.