If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Prerequisite for building new or extending existing controls.

Code review standards and Control level guidelines with examples.

  • A control should have one javascript file and one HTML template file with the same name.
    example: html/BillingShippingAddress.html and js/BillingShippingAddress.js

  • A javascript variable will be created that will act as a collection for all of the controls objects. 
    example : var eb_billingShippingAddress = eb_billingShippingAddress || {};

  • Any object at the collection level should be generic to all instances of that control. Instance-specific information should live at the model level. SitePath, TemplatePath and ServicePath would be fixed properties for each control. These variables should be prefixed with eb so that it does not collide with other JavaScript systems.
    example : 
    eb_billingShippingAddress.SitePath = eb_Config.SitePath;
    eb_billingShippingAddress.TemplatePath = "html/BillingShippingAddress.html";
    eb_billingShippingAddress.ServicePath = eb_Config.ServicePath;

  • The Path of the HTML template should mirror that of the path to the JS.
    example: eb_billingShippingAddress.TemplatePath = "html/BillingShippingAddress.html";

  • If there is more than one model for a control, a collection called models will be added to the control collection.
  • Sitewide settings such as the dom, service data, template path and dependent objects etc. will be passed into the control's javascript collection at the time of model creation.
    example : 

    var options = {}
    options.domElement = $('#BillingShippingAddress')[0];
    options.templatePath = eb_Config.SitePath + "html/BillingShippingAddress.html";

    options.userContext = eb_UserContext.live;

    options.shoppingCart = eb_shoppingCart.live;

  •  

  • Controls will be loaded asynchronously by the browser in whatever order the browser chooses.
  • The control will know the default relative path to its HTML and it will be declared in a variable in the collection.
  • YUIDoc comments should be used and should be meaningful information that developers can use to understand what a function is doing.
  • Instance initiation should not happen at the control level.
  • Control dependencies will be passed into the control when an instance is created.
  • References to JS objects outside of the scope of the control should be avoided.
  • It should only take 1 call to the server to get all of the initial data to show to the user.
  • A render function should exist.
    • Its job is to grab the template and insert it into a dom element that is passed into the function.
    • It should accept a user-supplied template in the place of the default template.

Page level guidelines with examples.

  • References to all of the Javascript and CSS needed should be loaded at the page level.
  • Control models should be instantiated at the page level inside of a document. ready jQuery object.
  • Instances of the control's model should be added to that controls collection for reference. ex. ebLogin.live
  • Site-wide settings should be loaded and passed into the controls at the page level. This eliminates the dependency to the config file at the time the files are being loaded.

Sitewide guidelines with examples.

  • Sitewide settings should live in the sitewide configuration file.

 

  • No labels