Mercurial > defr > drupal > scald > dnd
comparison js/dnd.js @ 11:99ba5941779c
JS Linted.
author | David Eads <eads@chicagotech.org> |
---|---|
date | Fri, 27 Feb 2009 00:49:22 -0600 |
parents | c2eb995212bf |
children | a5b2b9fa2a1a |
comparison
equal
deleted
inserted
replaced
10:5d2ae5b8eae2 | 11:99ba5941779c |
---|---|
133 preprocessDrop: function(target, drop) { | 133 preprocessDrop: function(target, drop) { |
134 var old_parent = false; | 134 var old_parent = false; |
135 var element_id = ''; | 135 var element_id = ''; |
136 | 136 |
137 var parents = drop.parents(); | 137 var parents = drop.parents(); |
138 for (i=0; i < parents.length; i++) { | 138 for (var i=0; i < parents.length; i++) { |
139 if ($(parents[i]).is('body')) { | 139 if ($(parents[i]).is('body')) { |
140 element_id = $(drop).get(0).id; | 140 element_id = $(drop).get(0).id; |
141 $(old_parent).after(drop.clone()); | 141 $(old_parent).after(drop.clone()); |
142 drop.remove(); | 142 drop.remove(); |
143 } | 143 } |
152 | 152 |
153 }, opt); | 153 }, opt); |
154 | 154 |
155 // Initialize plugin | 155 // Initialize plugin |
156 var targets = opt.processTargets(opt.targets); | 156 var targets = opt.processTargets(opt.targets); |
157 if (opt.disableClick) { this.click(function() { return false; }) } | 157 if (opt.disableClick) { this.click(function() { return false; }); } |
158 | 158 |
159 // Process! | 159 // Process! |
160 return this.each(function() { | 160 return this.each(function() { |
161 | 161 |
162 var element = this; | 162 var element = this; |
175 targets.each(function() { | 175 targets.each(function() { |
176 if ($(this).is('iframe')) { | 176 if ($(this).is('iframe')) { |
177 var target = this; | 177 var target = this; |
178 | 178 |
179 // Watch the iframe for changes | 179 // Watch the iframe for changes |
180 t = setInterval(function() { | 180 var t = setInterval(function() { |
181 var match = $('#' + element.id, $(target).contents()); | 181 var match = $('#' + element.id, $(target).contents()); |
182 if (match.length > 0) { | 182 if (match.length > 0) { |
183 drop = opt.preprocessDrop(target, match); // Must return a jquery object | 183 var drop = opt.preprocessDrop(target, match); // Must return a jquery object |
184 drop | 184 drop |
185 .before(opt.insertBefore) | 185 .before(opt.insertBefore) |
186 .after(opt.insertAfter) | 186 .after(opt.insertAfter) |
187 .wrap(opt.dropWrapper) | 187 .wrap(opt.dropWrapper) |
188 .replaceWith(opt.renderRepresentation(target, drop, representation_id)); | 188 .replaceWith(opt.renderRepresentation(target, drop, representation_id)); |
189 opt.postprocessDrop(target, drop, element); | 189 opt.postprocessDrop(target, drop, element); |
190 } | 190 } |
191 }, 100); | 191 }, 100); |
192 // @TODO track the timer with $.data() so we can clear it? | 192 // @TODO track the timer with $.data() so we can clear it? |
193 } else if ($(this).is('textarea')) { | 193 } else if ($(this).is('textarea')) { |
194 console.log('@TODO handle textareas via.... regexp?'); | 194 //console.log('@TODO handle textareas via.... regexp?'); |
195 } | 195 } |
196 }); | 196 }); |
197 }); | 197 }); |
198 } | 198 }; |
199 })(jQuery); | 199 })(jQuery); |