Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed field selector #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions assets/customfieldcaptions.publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
-----------------------------------------------------------------------------*/

jQuery(document).ready(function() {
// Add a input field for every field instance

// Add an input field for every field instance
var $fields = jQuery('#contents').find('div.field'),

// Get JSON data for the fields
Expand All @@ -15,14 +16,28 @@
if(data === undefined) return;

$fields.each(function(i) {

// Field variables
var $field = jQuery(this),
field_id = $field.attr('id').replace(/^field-/i, '');
field_id = $field.attr('id').replace(/^field-/i, ''),

// Get the textnodes inside the label element
textNodes = $field.find('label').contents().filter( isTextNode ),
firstTextNode = textNodes.first();

if(isNaN(parseInt(field_id)) || data[field_id].caption == undefined) return;

template = caption_template.clone();
template.html(data[field_id].caption);

// Append the content after the first textNode
firstTextNode.after(template)

$field.find('label > :input:last, label > .frame').before(template);
});
});

// Filter
function isTextNode(){
return( this.nodeType === 3 );
}

});
3 changes: 3 additions & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
</author>
</authors>
<releases>
<release version="0.4.1" date="2014-03-21" min="2.3">
- Append content after first text node so that it consistantly displays for all fields.
</release>
<release version="0.4" date="2012-08-08" min="2.3">
- Break compatibility with Symphony 2.2.x
- [#13](https://github.com/brendo/customfieldcaptions/issues/13) - Fix errors in Symphony 2.3 when saving sections
Expand Down