Simple Structures Base

The Simple Structures base (ss-base.js) consists of many utility functions used by the library components.

Function: SS.generateGUID()

Returns an auto-incrementing id string that is unique on the page. Used by UI widgets to generate unique id's when no id is specified upon creation.

 
SS.generateGUID(); //returns "__SS__GUID__1"
SS.generateGUID(); //returns "__SS__GUID__2"
SS.generateGUID(); //returns "__SS__GUID__3"
SS.generateGUID(); //returns "__SS__GUID__4"
                

Function: SS.execute(fn, params, scope)

Executes a series of functions. When an object is passed in as the scope argument, SS.execute() will first search the scope object for a matching function to execute. If no function is found within the scope object, SS.execute() will search the window scope for a matching function to execute.

Arguments

  • fn (string, function, or array of strings or functions: required) - Functions defined as strings will execute global functions by the same name when no scope option is specified. When scope is set, the function lookup will begin in the object specified by the scope. When passed an array, the functions in the array will be executed in order.
  • params (array or any valid argument: optional) - Single parameter can be passed in, multiple parameters must be enclosed in an array. When multiple functions are passed to SS.execute(), params should be an array. Each function will receive the corresponding array item's values for their paramters. For example values in array[0] will be passed to the first function, values in array[1] position will be passed to the second function.
  • scope (object or array: optional) - Sets the function execution scope to find the function inside an object. When no function is found within an object, the scope will be set to window.
function sayHi(name) {
    var person = name ? " "+name : "";
    alert("Hi there" + person + "!");
}
// Example object with utility function methodds.
MyStuff = {
    Utils: {
        demoMessage: function(A, B, C) {
            var msg = "Go ahead and call a function nested inside an object.";
            msg += "\nA is " + A;
            msg += "\nB is " + B;
            msg += "\nC is " + C;           
            alert(msg);
        }
    }
}

// Execute 3 functions. Call sayHi(), then inline function, then MyStuff.Utils.demoMessage().
SS.execute (
    ['sayHi', function() { alert("Inline functions work too!");}, 'demoMessage'], // Array of functions
    ['Bob',"",["first","second","third"]], // Array of parameters 
    MyStuff.Utils // Scope object containing the demoMessage function.
);
                

Function: SS.getElement(el)

Returns an element object when passed a string "id" or object. Returns null if no match is found.

Arguments

  • el (Element object or string: required) - HTML element object or id of HTML element.
SS.getElement("some-element") // Returns element with id="some-element"
                

Function: SS.getHTML(target)

Returns the content of the target element as a String.

Arguments

  • target (Element object or string: required) - HTML element object or id of HTML element.
SS.getHTML("some-element") // Returns the content of the element with id="some-element".
                

Function: SS.setHTML(target, content)

Sets the innerHTML of an element with a text string, element, or element collection.

Arguments

  • target (Element object or string: required) - HTML element object or id of HTML element.
  • content (String, Element object, or element collection: required) - Sets the content of the target element.
SS.setHTML('target-element-id', 'Hello World');
                

Function: SS.image(css, desc, id, target)

Utility function that returns or injects a transparent .png image that can be used as a place-holder for icons, CSS sprites, etc. By default, this function will return an image element of a blank or invisible 1px x 1px image. However, if the "target" parameter is set, the function will inject an image element into the specified target element location.

Arguments

  • css (string: optional, defaults to '') - Defines the image's CLASS property.
  • desc (string: optional, defaults to '') - Defines the image's ALT and TITLE properties.
  • id (string: optional, defaults to '') - Defines the image's ID property.
  • target (Element object or string: optional, defaults to '') - Defines a target HTML element to inject the image into.
SS.image(); // Returns a 1px by 1px transparent image element object.

<img id="" class="" alt="" src="http://www.estringmedia.com/simplestructures/js/css/themes/ss-1px.png" title="">
                
SS.image('help-icon', 'Get Help!','btn-help', 'buttons'); // Inject the image into element with id="buttons".

<div id="buttons">
    <img id="btn-help" class="help-icon" alt="Get Help!" src="http://www.estringmedia.com/simplestructures/js/css/themes/ss-1px.png" title="Get Help!">
</div>
                

Function: SS.shadow.add(element, options)

Adds cross-browser compatible shadow to an element using a combination of browser-specific CSS prefixed styles and proprietary Internet Explorer filters for IE 6-8. Fallback to CSS3 box-shadow if supported by the browser.

Arguments

  • element (Element object or string: required) - HTML element object or id of HTML element.
  • options (object: optional) - Contains members color and shadow.
    • color (optional, defaults to #000) - Defines the color of the shadow.
    • size (optional, defaults to #000) - Defines the color of the shadow.
  • size (number: optional, defaults to 10) - Size of the shadow in pixels
SS.shadow.add("shadow-me", {
    color: '#0000FF',
    size: 20
});
                

Function: SS.shadow.remove(element)

Removes shadow from element.

Arguments

  • element (Element object or string: required) - HTML element object or id of HTML element.

Examples

SS.shadow.remove("my-element-id");
                

Function: SS.getPixelHeight(el, percent)

Returns the number of pixels that's equal to a percentage of the height of an element minus the top and bottom padding.

Arguments

  • el (Element object or string: optional) - HTML element object or id of HTML element. When no element is defined, the height of the body will be calculated.
  • percent (Number: optional) - When no value is passed, pixels will be calculated based on 100% height.

Function: SS.getPixelWidth(el, percent)

Returns the number of pixels that's equal to a percentage of the height of an element minus the top and bottom padding.

Arguments

  • el (Element object or string: optional) - HTML element object or id of HTML element. When no element is defined, the width of the body will be calculated.
  • percent (Number: optional) - When no value is passed, pixels will be calculated based on 100% width.
tacrolimus creme onde comprar where to buy clomid in stores valacyclovir buy uk zovirax tablets uk buy where to buy baclofen uk buy adobe illustrator upgrade doxycycline online kaufen buy valtrex in the uk discount adobe photoshop elements 9 cheapest cialis online canada adobe creative suite 5.5 kopen buy adobe illustrator fonts average cost of cialis in canada