Created
September 4, 2012 14:59
-
-
Save Dykam/3621979 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| $.fn.replaceTag = (replacement) -> | |
| result = new jQuery.fn.init | |
| for element in this | |
| $element = $(element) | |
| attributes = {} | |
| for attribute in element.attributes | |
| attributes[attribute.name] = attribute.value | |
| changed = $element.wrapInner($("<#{replacement}>", attributes)).children().unwrap() | |
| result = result.add changed | |
| result | |
| $.fn.copyAndFillTemplate = (fields) -> | |
| result = new jQuery.fn.init | |
| for element in this | |
| clone = @.clone() | |
| becomes = clone.data("becomes") ? "div" | |
| clone.removeData("becomes") | |
| clone = clone.replaceTag(becomes) | |
| for field in $("field", clone) | |
| $field = $(field) | |
| name = $field.text() | |
| unless fields[name] | |
| $field.remove() | |
| next | |
| becomes = $field.data("becomes") ? "span" | |
| $field.removeData("becomes") | |
| $field.replaceTag(becomes).text(fields[name]) | |
| result = result.add clone | |
| result |
This file contains hidden or 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 class="InfoWindow"> | |
| <div><span>description</span></div> | |
| <fieldset class="Directions"> | |
| <legend>Route</legend> | |
| <div class="Container"> | |
| <label>Van</label><input type="text" class="Dest" /> | |
| <label>naar</label><span class="Wrapped">address</span><input type="submit" value="Route zoeken" class="Search" /> | |
| </div> | |
| </fieldset> | |
| </div> |
This file contains hidden or 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
| <template class="InfoWindow" data-becomes="div"> | |
| <div><field>description</field></div> | |
| <fieldset class="Directions"> | |
| <legend>Route</legend> | |
| <div class="Container"> | |
| <label>Van</label><input type="text" class="Dest" /> | |
| <label>naar</label><field class="Wrapped">address</field><input type="submit" value="Route zoeken" class="Search" /> | |
| </div> | |
| </fieldset> | |
| </template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment