SlideShare une entreprise Scribd logo
1  sur  31
in 37 minutes Episode 23 Fine-tuning the DITA  authoring experience: Customizing the XMetaL DITA customization Tom Magliery, XML Technology Specialist 9 June 2011 Brought to you by XMetaL Technical Services
What is a “customization” of XMetaL? What is the “DITA customization”? What do we mean by “do not support modifying the DITA customization”? So then, what can be customized? Introduction and background
0.	A few things not covered today: DITA OT Conditional text dialogs Application macros Templates Editor styles (CSS) Scripting extensions What can be customized
1. Templates XMetaL Author default task template Customized  “procedure”  template for  Acme Widget  Company
A template (DITA or otherwise) is just an XML file, saved in a specific location Edit the file Open any XML file in any XML editor, edit it normally Recommendation: Use XMetaL, of course!  Put the file in the right place Will show where that is shortly ... Editing templates in XMetaL
You’ve seen these bits of replaceable text: They are created by using replace-text PIs* Put them anywhere text is allowed to go Edit them in Plain Text View in XMetaL Replaceable text This can be any text you want <p><?xm-replace_text Paragraph?></p> The rest must be exactly as shown here * PI == XML “processing instruction”
If you are editing DITA templates in XMetaL, a normal “Save” or “Save As” won’t do XMetaL automatically adds IDs and other stuff that you don’t want in your template Instead of “Save”, use the “Save Copy as Template” DITA macro Strips out auto-generated IDs and other stuff NOTE: You still must fix the DOCTYPE ! More in a moment ... “Save Copy as Template”
Finding the “Save Copy as Template” macro 1. Enable the “Macros”  toolbar by right-clicking  in the toolbar area 2. Select the macro from  the pull-down menu 3. Run it by clicking the       button
After you save a DITA template with that macro, you must open it in a text editor (not XMetaL) and repair the DOCTYPE declaration First line of the file will look like this: 	<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "C:rogram FilesMetaL 6.0uthorITAACsaskask_ditabase.dtd"> Remove path info and “_ditabase”: 	<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> Fixing the DOCTYPE
Where to save your templates Replace any/all of these folders with your own
Where to save your templates Replace any/all of these files with your own
2. Editor styles (CSS) Primary CSS file for each DITA doctype customization merely imports five other files: “Mytopic” can also be concept, task, reference, etc.
The CSS files are loaded in this order: 	ditabase-base.cssditabase-base-override.css         [yours]ditabase-derived.cssditabase-derived-override.css      [yours]mytopic_ditabase-specialized.css   [yours] If two rules match the same element and assign the same properties, the one that was loaded last will “win” Also, more specific selector rules will win over less specific ones Order of CSS loading
Give <note> elements a yellow background Add this to ditabase-base-override.css: Note use of attribute-value matching instead of the element name CSS example 1 [class~="topic/note"] { 	background-color: yellow; } ditabase-base.cssditabase-base-override.cssditabase-derived.cssditabase-derived-override.css mytopic_ditabase-specialized.css
Give <note> elements a different colored background for one specific topic type Add this to concept_ditabase-specialized.css: Now <note>s in <concept> topics will be green. CSS example 2 [class~="topic/note"] { 	background-color: #ffccff; } ditabase-base.cssditabase-base-override.cssditabase-derived.cssditabase-derived-override.css mytopic_ditabase-specialized.css
Add new JScript code specific to any one DITA doctype (including concept, task, reference) Examples: Change the ID auto-generation algorithm Override default “properties” dialogs Add items to the context menu Modify menus/toolbars 3. Adding script code withDitaSpecializationExtender
Copy this file (sample code included with XMetaL): C:rogram FilesMetaL 6.0uthorITAACsitabaseditabase_ditabase.off.js Paste into this directory: C:rogram FilesMetaL 6.0uthorITAACsoncept Rename to mytopic_ditabase.js Global search/replace “ditabase_ditabase” with “mytopic_ditabase” Add your custom code to the function implementations in the file Using DitaSpecializationExtender
XMetaL automatically assigns IDs to certain elements using a built-in algorithm Which elements – depends on your user preferences You can change the algorithm that will be used You can even use different algorithms for different elements ID auto-generation algorithm
Write code for the following function: ID auto-generation algorithm concept_ditabase.prototype.makeUniqueId = function(domNode) {     // Complete the function with code that     // returns a string. The returned string     // will be used as the new unique ID.     // Be sure the string is a valid XML ID! }
Example: ID auto-generation algorithm concept_ditabase.prototype.makeUniqueId = function(domNode) {   // for the root, allow XMetaL default behaviour   if (domNode.nodeName == "concept")    {     return null;   }   // Otherwise choose a random integer,    // convert it to hexadecimal, and append   // the result to the nodename. varhstr = Math.floor(1000000000*Math.random()).toString(16);   return domNode.nodeName + "_37mins_" + hstr; }
XMetaL has a “Properties” command on the context menu Launches a dialog to set properties of the element Some properties dialogs are already “custom”, e.g. <image> Others are generic default dialogs, e.g. <p> The doProperties function allows you to override the generic defaults and launch your own custom dialogs (or whatever you want) Overriding properties dialogs
Write code for the following function: Overriding properties dialogs concept_ditabase.prototype.doProperties = function(rng) {    // rng will be a Range representing the location     // that was selected.    // Your function should return “true” if you have    // handled the properties command with behavior of    // your own.    // Your function should return “false” if you wish    // to allow the default XMetaL behavior to occur. }
Example: NOTE: With XFT you can do fancier stuff Overriding properties dialogs concept_ditabase.prototype.doProperties = function(rng) {   // Do something special if selection is in a paragraph   if (rng.ContainerName == "p")   { varstr = Application.Prompt("Enter a new ID"); rng.ContainerNode.setAttribute("id", str);     return true;   }   // ...otherwise, let built-in behavior run   return false;  }
You can add commands to the context menu for performing additional operations on the selected element There must be a macro available to perform each command you wish to add Adding items to the context menu
Write code for the following function: Adding items to the context menu concept_ditabase.prototype.OnSpecializeContextMenu =  	function(cmdPopup) {   // cmdPopup is a CommandBar representing the context menu   // Use the CommandBar interface to add item(s)   // No need to return any value from this function. }
Example: Adding items to the context menu concept_ditabase.prototype.OnSpecializeContextMenu =  	function(cmdPopup) {   // Add "Hello, world" menu item var ctrl = cmdPopup.Controls.Add(sqcbcTypePopup, null);   if (ctrl) { ctrl.BeginGroup      = true; ctrl.DescriptionText = "The old classic, XMetaL style."; ctrl.OnAction        = "Hello World";  ctrl.Caption         = "Say hello!"; ctrl.FaceId          = 0;   } }
Command bars is the collective name for all the toolbars and menus in XMetaL You can add items for inserting specialized elements ... or anything else Function is called while XMetaL is initializing the command bars Modifying command bars
Write code for the following function: This type of code is a bit long and tedious – not showing an example today Modifying toolbars and menus concept_ditabase.prototype.OnSpecializeCommandBars =  	function(cmdBars) {   // cmdBars is a CommandBars object representing the   // XMetaL command bars collection (menus + toolbars)   // Write code in here to add/remove items from   // the menus and toolbars as desired. }
For XMetaL scripting and customization information XMetaL Customization Guide XMetaL Programmer’s Guide Both are available here: http://na.justsystems.com/content-support-user-guides Those guides are very deep and comprehensive Feel free to ask us for specific advice Where to go from here?
XMetaL users:  XMetaL Community Forums http://forums.xmetal.com/ JustSystems partners: JustSystems Partner Center http://justpartnercenter.com/ Ask us for help (partner tech support) partnersupport-na@justsystems.com Community resources
Thank you for attending! Q&A

Contenu connexe

Tendances

Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]Irfan Maulana
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JSikhwanhayat
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans Fabrizio Giudici
 
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...Irfan Maulana
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript DevelopmentAddy Osmani
 
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Roman Zenner
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its featuresAbhishek Sur
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsMohammad Shaker
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentIvan Chepurnyi
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)WebStackAcademy
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial EnAnkur Dongre
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010Tim Clark
 
JavaScript
JavaScriptJavaScript
JavaScriptSunil OS
 

Tendances (19)

Extjs
ExtjsExtjs
Extjs
 
Schema webinar
Schema webinarSchema webinar
Schema webinar
 
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
Sencha ExtJs Learning Part 2 - MVC And MVVM Architecture in ExtJs [ENGLISH]
 
Schema201 webinar
Schema201 webinarSchema201 webinar
Schema201 webinar
 
Basics of Ext JS
Basics of Ext JSBasics of Ext JS
Basics of Ext JS
 
Rich Internet Applications con JavaFX e NetBeans
Rich Internet Applications  con JavaFX e NetBeans Rich Internet Applications  con JavaFX e NetBeans
Rich Internet Applications con JavaFX e NetBeans
 
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...
Sencha ExtJs Learning Part 1 - Layout And Container in Sencha ExtJs - By Irfa...
 
Large-Scale JavaScript Development
Large-Scale JavaScript DevelopmentLarge-Scale JavaScript Development
Large-Scale JavaScript Development
 
WPF Concepts
WPF ConceptsWPF Concepts
WPF Concepts
 
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
 
WPF and Databases
WPF and DatabasesWPF and Databases
WPF and Databases
 
Introduction to XAML and its features
Introduction to XAML and its featuresIntroduction to XAML and its features
Introduction to XAML and its features
 
TY.BSc.IT Java QB U2
TY.BSc.IT Java QB U2TY.BSc.IT Java QB U2
TY.BSc.IT Java QB U2
 
C# Advanced L07-Design Patterns
C# Advanced L07-Design PatternsC# Advanced L07-Design Patterns
C# Advanced L07-Design Patterns
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)JavaScript - Chapter 13 - Browser Object Model(BOM)
JavaScript - Chapter 13 - Browser Object Model(BOM)
 
Ejb3 Struts Tutorial En
Ejb3 Struts Tutorial EnEjb3 Struts Tutorial En
Ejb3 Struts Tutorial En
 
XPages Blast - ILUG 2010
XPages Blast - ILUG 2010XPages Blast - ILUG 2010
XPages Blast - ILUG 2010
 
JavaScript
JavaScriptJavaScript
JavaScript
 

Similaire à Customizing the XMetaL DITA authoring experience

AD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLAD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLStephan H. Wissel
 
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6DITA Open Toolkit Deployment with XMetaL Author Enterprise 6
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6XMetaL
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsSuite Solutions
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handlingSuite Solutions
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend developmentsparkfabrik
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
Some useful tips with qtp
Some useful tips with qtpSome useful tips with qtp
Some useful tips with qtpSandeep
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - TryoutMatthias Noback
 
Creating A Language Editor Using Dltk
Creating A Language Editor Using DltkCreating A Language Editor Using Dltk
Creating A Language Editor Using DltkKaniska Mandal
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magentohainutemicute
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014Matthias Noback
 
SolidWorks Advanced Customization Techniques
SolidWorks Advanced Customization TechniquesSolidWorks Advanced Customization Techniques
SolidWorks Advanced Customization Techniquesfcsuper
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Rajeev Rastogi (KRR)
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native CompilationPGConf APAC
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in DrupalWingston
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentationsasidhar
 

Similaire à Customizing the XMetaL DITA authoring experience (20)

AD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLAD215 - Practical Magic with DXL
AD215 - Practical Magic with DXL
 
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6DITA Open Toolkit Deployment with XMetaL Author Enterprise 6
DITA Open Toolkit Deployment with XMetaL Author Enterprise 6
 
CustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputsCustomizingStyleSheetsForHTMLOutputs
CustomizingStyleSheetsForHTMLOutputs
 
Debugging and Error handling
Debugging and Error handlingDebugging and Error handling
Debugging and Error handling
 
Drupal 8: frontend development
Drupal 8: frontend developmentDrupal 8: frontend development
Drupal 8: frontend development
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
HTML literals, the JSX of the platform
HTML literals, the JSX of the platformHTML literals, the JSX of the platform
HTML literals, the JSX of the platform
 
Some useful tips with qtp
Some useful tips with qtpSome useful tips with qtp
Some useful tips with qtp
 
The Naked Bundle - Tryout
The Naked Bundle - TryoutThe Naked Bundle - Tryout
The Naked Bundle - Tryout
 
Creating A Language Editor Using Dltk
Creating A Language Editor Using DltkCreating A Language Editor Using Dltk
Creating A Language Editor Using Dltk
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magento
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
Clean code
Clean codeClean code
Clean code
 
The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014The Naked Bundle - Symfony Live London 2014
The Naked Bundle - Symfony Live London 2014
 
SolidWorks Advanced Customization Techniques
SolidWorks Advanced Customization TechniquesSolidWorks Advanced Customization Techniques
SolidWorks Advanced Customization Techniques
 
Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2Go faster with_native_compilation Part-2
Go faster with_native_compilation Part-2
 
Go Faster With Native Compilation
Go Faster With Native CompilationGo Faster With Native Compilation
Go Faster With Native Compilation
 
7 Theming in Drupal
7 Theming in Drupal7 Theming in Drupal
7 Theming in Drupal
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
treeview
treeviewtreeview
treeview
 

Customizing the XMetaL DITA authoring experience

  • 1. in 37 minutes Episode 23 Fine-tuning the DITA authoring experience: Customizing the XMetaL DITA customization Tom Magliery, XML Technology Specialist 9 June 2011 Brought to you by XMetaL Technical Services
  • 2. What is a “customization” of XMetaL? What is the “DITA customization”? What do we mean by “do not support modifying the DITA customization”? So then, what can be customized? Introduction and background
  • 3. 0. A few things not covered today: DITA OT Conditional text dialogs Application macros Templates Editor styles (CSS) Scripting extensions What can be customized
  • 4. 1. Templates XMetaL Author default task template Customized “procedure” template for Acme Widget Company
  • 5. A template (DITA or otherwise) is just an XML file, saved in a specific location Edit the file Open any XML file in any XML editor, edit it normally Recommendation: Use XMetaL, of course! Put the file in the right place Will show where that is shortly ... Editing templates in XMetaL
  • 6. You’ve seen these bits of replaceable text: They are created by using replace-text PIs* Put them anywhere text is allowed to go Edit them in Plain Text View in XMetaL Replaceable text This can be any text you want <p><?xm-replace_text Paragraph?></p> The rest must be exactly as shown here * PI == XML “processing instruction”
  • 7. If you are editing DITA templates in XMetaL, a normal “Save” or “Save As” won’t do XMetaL automatically adds IDs and other stuff that you don’t want in your template Instead of “Save”, use the “Save Copy as Template” DITA macro Strips out auto-generated IDs and other stuff NOTE: You still must fix the DOCTYPE ! More in a moment ... “Save Copy as Template”
  • 8. Finding the “Save Copy as Template” macro 1. Enable the “Macros” toolbar by right-clicking in the toolbar area 2. Select the macro from the pull-down menu 3. Run it by clicking the button
  • 9. After you save a DITA template with that macro, you must open it in a text editor (not XMetaL) and repair the DOCTYPE declaration First line of the file will look like this: <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "C:rogram FilesMetaL 6.0uthorITAACsaskask_ditabase.dtd"> Remove path info and “_ditabase”: <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd"> Fixing the DOCTYPE
  • 10. Where to save your templates Replace any/all of these folders with your own
  • 11. Where to save your templates Replace any/all of these files with your own
  • 12. 2. Editor styles (CSS) Primary CSS file for each DITA doctype customization merely imports five other files: “Mytopic” can also be concept, task, reference, etc.
  • 13. The CSS files are loaded in this order: ditabase-base.cssditabase-base-override.css [yours]ditabase-derived.cssditabase-derived-override.css [yours]mytopic_ditabase-specialized.css [yours] If two rules match the same element and assign the same properties, the one that was loaded last will “win” Also, more specific selector rules will win over less specific ones Order of CSS loading
  • 14. Give <note> elements a yellow background Add this to ditabase-base-override.css: Note use of attribute-value matching instead of the element name CSS example 1 [class~="topic/note"] { background-color: yellow; } ditabase-base.cssditabase-base-override.cssditabase-derived.cssditabase-derived-override.css mytopic_ditabase-specialized.css
  • 15. Give <note> elements a different colored background for one specific topic type Add this to concept_ditabase-specialized.css: Now <note>s in <concept> topics will be green. CSS example 2 [class~="topic/note"] { background-color: #ffccff; } ditabase-base.cssditabase-base-override.cssditabase-derived.cssditabase-derived-override.css mytopic_ditabase-specialized.css
  • 16. Add new JScript code specific to any one DITA doctype (including concept, task, reference) Examples: Change the ID auto-generation algorithm Override default “properties” dialogs Add items to the context menu Modify menus/toolbars 3. Adding script code withDitaSpecializationExtender
  • 17. Copy this file (sample code included with XMetaL): C:rogram FilesMetaL 6.0uthorITAACsitabaseditabase_ditabase.off.js Paste into this directory: C:rogram FilesMetaL 6.0uthorITAACsoncept Rename to mytopic_ditabase.js Global search/replace “ditabase_ditabase” with “mytopic_ditabase” Add your custom code to the function implementations in the file Using DitaSpecializationExtender
  • 18. XMetaL automatically assigns IDs to certain elements using a built-in algorithm Which elements – depends on your user preferences You can change the algorithm that will be used You can even use different algorithms for different elements ID auto-generation algorithm
  • 19. Write code for the following function: ID auto-generation algorithm concept_ditabase.prototype.makeUniqueId = function(domNode) { // Complete the function with code that // returns a string. The returned string // will be used as the new unique ID. // Be sure the string is a valid XML ID! }
  • 20. Example: ID auto-generation algorithm concept_ditabase.prototype.makeUniqueId = function(domNode) { // for the root, allow XMetaL default behaviour if (domNode.nodeName == "concept") { return null; } // Otherwise choose a random integer, // convert it to hexadecimal, and append // the result to the nodename. varhstr = Math.floor(1000000000*Math.random()).toString(16); return domNode.nodeName + "_37mins_" + hstr; }
  • 21. XMetaL has a “Properties” command on the context menu Launches a dialog to set properties of the element Some properties dialogs are already “custom”, e.g. <image> Others are generic default dialogs, e.g. <p> The doProperties function allows you to override the generic defaults and launch your own custom dialogs (or whatever you want) Overriding properties dialogs
  • 22. Write code for the following function: Overriding properties dialogs concept_ditabase.prototype.doProperties = function(rng) { // rng will be a Range representing the location // that was selected. // Your function should return “true” if you have // handled the properties command with behavior of // your own. // Your function should return “false” if you wish // to allow the default XMetaL behavior to occur. }
  • 23. Example: NOTE: With XFT you can do fancier stuff Overriding properties dialogs concept_ditabase.prototype.doProperties = function(rng) { // Do something special if selection is in a paragraph if (rng.ContainerName == "p") { varstr = Application.Prompt("Enter a new ID"); rng.ContainerNode.setAttribute("id", str); return true; } // ...otherwise, let built-in behavior run return false; }
  • 24. You can add commands to the context menu for performing additional operations on the selected element There must be a macro available to perform each command you wish to add Adding items to the context menu
  • 25. Write code for the following function: Adding items to the context menu concept_ditabase.prototype.OnSpecializeContextMenu = function(cmdPopup) { // cmdPopup is a CommandBar representing the context menu // Use the CommandBar interface to add item(s) // No need to return any value from this function. }
  • 26. Example: Adding items to the context menu concept_ditabase.prototype.OnSpecializeContextMenu = function(cmdPopup) { // Add "Hello, world" menu item var ctrl = cmdPopup.Controls.Add(sqcbcTypePopup, null); if (ctrl) { ctrl.BeginGroup = true; ctrl.DescriptionText = "The old classic, XMetaL style."; ctrl.OnAction = "Hello World"; ctrl.Caption = "Say hello!"; ctrl.FaceId = 0; } }
  • 27. Command bars is the collective name for all the toolbars and menus in XMetaL You can add items for inserting specialized elements ... or anything else Function is called while XMetaL is initializing the command bars Modifying command bars
  • 28. Write code for the following function: This type of code is a bit long and tedious – not showing an example today Modifying toolbars and menus concept_ditabase.prototype.OnSpecializeCommandBars = function(cmdBars) { // cmdBars is a CommandBars object representing the // XMetaL command bars collection (menus + toolbars) // Write code in here to add/remove items from // the menus and toolbars as desired. }
  • 29. For XMetaL scripting and customization information XMetaL Customization Guide XMetaL Programmer’s Guide Both are available here: http://na.justsystems.com/content-support-user-guides Those guides are very deep and comprehensive Feel free to ask us for specific advice Where to go from here?
  • 30. XMetaL users: XMetaL Community Forums http://forums.xmetal.com/ JustSystems partners: JustSystems Partner Center http://justpartnercenter.com/ Ask us for help (partner tech support) partnersupport-na@justsystems.com Community resources
  • 31. Thank you for attending! Q&A