How to copy the style with its media types
HI every we are in the middle of updating an action which converts an items styles into a class style and we are trying to make it work if that item is only referenced within the master style sheet.
At the moment thesis how our action works: Our test action looks at the master style sheet and if it finds the id style associated with that item , it copies that id style into the page’s individual stylesheet then it changes it to a class style.
The bit we are having problems with is in tying to copy the ‘PropertiesForMediaType’, styles. We can’t seem to see those styles. So at the moment as long as there are no associated media styles with that item then it works but the minute you ad break points and that item has different style at those break points, then we have failed to copy those into the page style sheet.
does anyone have any ideas of what we should be looking at:
these are the references that we have… so if anyone else has more info that would be handy:
// Accessing sheets - Master & Document only available with External Stylesheets on
var sheet = fwPage.fwMasterStylesheet; // Read-only
var sheet = fwPage.fwPageStylesheet;
var sheet = fwPage.fwDocumentStylesheet;
// Accessing styles
var styleCount = sheet.fwLength;
var style = sheet[styleIndex];
var style = sheet["stylename"]; // Creates style if it doesn't exist (but doesn't publish it unless modified) - should bring up JS error
// Valid media type strings
// "" (default)
// "all"
// "braille"
// "embossed"
// "handheld"
// "print"
// "projection"
// "screen"
// "speech"
// "tty"
// "tv"
// "(-webkit-min-device-pixel-ratio:1.3), (-o-min-device-pixel-ratio:13/10), (min-resolution:125dpi)"
// Media types (empty string for media type also indicates default media query)
var mediaTypeArray = style.fwMediaTypes; // Array of media strings currently supported by this style
// Style name (selector)
var styleName = style.fwName;
style.fwName = "#item45 .someclass p"
var styleRule = style.fwRule
var mediaStyleRule = style.fwMediaRule("mediaType");
// Accessing properties
var propertyCount = style.fwLength; // Read-only
var property = style[propertyIndex]; // Read-only
var propertyName = property.fwName; // Read-only
var propertyValue = property.fwValue; // Read-only
var propertyValue = style["propertyName"]; // Read-only
style.fwGetPropertyForMediaType("position"); // Default media query
style.fwGetPropertyForMediaType("position", mediaTypeArray[0]); // Specific media query
var propertiesString = style.fwGetPropertiesForMediaType(); // Default media query
var propertiesString = style.fwGetPropertiesForMediaType(mediaTypeString); // Specific media query
// Adding, removing, setting styles
sheet.fwAddStyle("#item45 .someclass p", "position", "absolute", "margin-left", "10px");
sheet.fwAddStyle("#item45 .someclass p", {position: "absolute", margin-left: "10px"});
sheet.fwAddStyle("position: absolute; margin-left: 10px");
sheet["#item45 .someclass p"] = {position: "absolute", margin-left: "10px"}; // Set existing style or create new style from object
sheet["#item45 .someclass p"] = "position: absolute; margin-left: 10px"; // Set existing style or create new style from string
sheet.fwRemoveStyle("#item45 .someclass p");
sheet.fwRemoveStyle(style);
// These all accept objects, alternating property pair strings, and css syntax property strings as methods of specifying the properties to be set
sheet.fwInsertStyleAt(index, "styleName", {position: "absolute", margin-left: "10px"});
sheet.fwInsertBefore("styleNameBefore", "styleName", {position: "absolute", margin-left: "10px"});
sheet.fwInsertAfter("styleNameAfter", "styleName", {position: "absolute", margin-left: "10px"});
// Changing properties
style["position"] = "absolute";
style["position"] = ""; // Remove property (this is also the behaviour in fwSetProperties() if the value is an empty string)
style.fwSetPropertyForMediaType("position", "absolute"); // Default media query
style.fwSetPropertyForMediaType("position", "absolute", mediaTypeArray[0]); // Specific media query
style.fwSetPropertiesForMediaType(mediaTypeString, "position", "absolute", "margin-left", "10px");
style.fwSetPropertiesForMediaType(mediaTypeString, {position: "absolute", margin-left: "10px"});
style.fwSetPropertiesForMediaType(mediaTypeString, "position: absolute; margin-left: 10px");
style.fwPropertyCount(); // Count of properties in default media query
style.fwPropertyCount(mediaTypeArray[0]); // Count of properties in specific media query
style.fwPropertyAt(index); // Property at index in default media query
style.fwPropertyAt(index, mediaTypeArray[0]); // Property at index in default media query
// Adding raw text to the sheet (all added at the end, separated by single newline)
sheet.fwAddRaw("Some raw text added to the stylesheet");
sheet.fwAddRaw(fwMarkups["SomeMarkup"].fwMarkup); // Add lots of raw fixed code
var sheet = fwPage.fwPageStylesheet;
var count = sheet.fwLength;
for (var i = 0; i < count; i++)
{
var style = sheet[i];
var mediaArray = style.fwMediaTypes;
for (var j = 0; j < mediaArray.length; j++)
{
if (mediaArray[j].mediaType.length)
{
style.fwSetPropertiesForMediaType(mediaArray[j], { fnarr : "gribble", gronk : "tone" });
fwAlert(mediaArray[j].type);
fwAlert(mediaArray[j].width);
fwAlert(mediaArray[j].highResolution);
}
}
}
As you can see we should be able to get those refrences but in out test action we are running into problem
This is the test action which we are mucking about with so please note this isnt complete its for us to see whats going on:
https://dl.dropboxusercontent.com/u/4274685/FileChute/test-action.zip
actionsdev mailing list
email@hidden
Update your subscriptions at: