Commit 283ad2e69d875384adfd2a22fb2ab6b849f74f19

Authored by Daniela Feitosa
Committed by Antonio Terceiro
1 parent 81029a02

ActionItem785: allowing videos from dailymotion and youtube

  * Adding tags object and embed to allowed_tags for sanitize
  * Fixing lightbox. It was appearing behind videos
config/environment.rb
@@ -66,8 +66,11 @@ Rails::Initializer.run do |config| @@ -66,8 +66,11 @@ Rails::Initializer.run do |config|
66 } 66 }
67 67
68 # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper 68 # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper
69 - config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'align' 69 + config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style'
70 70
  71 + # Adds custom tags to the Set of allowed html tags for the #sanitize helper
  72 + config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param'
  73 +
71 # See Rails::Configuration for more options 74 # See Rails::Configuration for more options
72 75
73 extra_controller_dirs.each do |item| 76 extra_controller_dirs.each do |item|
public/javascripts/lightbox.js
@@ -76,6 +76,7 @@ lightbox.prototype = { @@ -76,6 +76,7 @@ lightbox.prototype = {
76 this.setScroll(0,0); 76 this.setScroll(0,0);
77 this.hideSelects('hidden'); 77 this.hideSelects('hidden');
78 } 78 }
  79 + this.hideObjectsAndEmbeds('hidden');
79 this.displayLightbox("block"); 80 this.displayLightbox("block");
80 }, 81 },
81 82
@@ -84,7 +85,7 @@ lightbox.prototype = { @@ -84,7 +85,7 @@ lightbox.prototype = {
84 bod = document.getElementsByTagName('body')[0]; 85 bod = document.getElementsByTagName('body')[0];
85 bod.style.height = height; 86 bod.style.height = height;
86 bod.style.overflow = overflow; 87 bod.style.overflow = overflow;
87 - 88 +
88 htm = document.getElementsByTagName('html')[0]; 89 htm = document.getElementsByTagName('html')[0];
89 htm.style.height = height; 90 htm.style.height = height;
90 htm.style.overflow = overflow; 91 htm.style.overflow = overflow;
@@ -97,7 +98,20 @@ lightbox.prototype = { @@ -97,7 +98,20 @@ lightbox.prototype = {
97 selects[i].style.visibility = visibility; 98 selects[i].style.visibility = visibility;
98 } 99 }
99 }, 100 },
100 - 101 +
  102 + // In FF, objects and embeds elements hover on top of the lightbox
  103 + hideObjectsAndEmbeds: function(visibility){
  104 + var f = function(collection) {
  105 + for(i = 0; i < collection.length; i++) {
  106 + if (collection[i].style) {
  107 + collection[i].style.visibility = visibility;
  108 + }
  109 + }
  110 + };
  111 + f(document.getElementsByTagName('object'));
  112 + f(document.getElementsByTagName('embed'));
  113 + },
  114 +
101 // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/ 115 // Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
102 getScroll: function(){ 116 getScroll: function(){
103 if (self.pageYOffset) { 117 if (self.pageYOffset) {
@@ -122,8 +136,8 @@ lightbox.prototype = { @@ -122,8 +136,8 @@ lightbox.prototype = {
122 // Begin Ajax request based off of the href of the clicked linked 136 // Begin Ajax request based off of the href of the clicked linked
123 loadInfo: function() { 137 loadInfo: function() {
124 var myAjax = new Ajax.Request( 138 var myAjax = new Ajax.Request(
125 - this.content,  
126 - {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)} 139 + this.content,
  140 + {method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)}
127 ); 141 );
128 142
129 }, 143 },
@@ -168,7 +182,7 @@ lightbox.prototype = { @@ -168,7 +182,7 @@ lightbox.prototype = {
168 this.prepareIE("auto", "auto"); 182 this.prepareIE("auto", "auto");
169 this.hideSelects("visible"); 183 this.hideSelects("visible");
170 } 184 }
171 - 185 + this.hideObjectsAndEmbeds("visible");
172 this.displayLightbox("none"); 186 this.displayLightbox("none");
173 } 187 }
174 } 188 }