All Downloads are FREE. Search and download functionalities are using the official Maven repository.

html_res.adg.aui.js.aui.js Maven / Gradle / Ivy

Go to download

Clover is an award winning code coverage and testing tool for Java and Groovy. It integrates easily with Maven, Ant, Grails, Eclipse and IntelliJ IDEA as well as with continuous integration servers such as Bamboo, Jenkins or Hudson. Note: before Clover 4.0 this artifact was named com.cenqua.clover:clover.

The newest version!
;
(function () {

  'use strict';


  // The rules used to hide elements during the ready lifecycle callback.
  var hiddenRules = document.createElement('style');


  // Observers
  // ---------

  // Normalise the mutaiton observer constructor.
  var MutationObserver = window.MutationObserver || window.WebkitMutationObserver || window.MozMutationObserver;

  if (!MutationObserver) {
    MutationObserver = function (callback) {
      this.callback = callback;
      this.elements = [];
    };

    MutationObserver.prototype = {
      observe: function (target, options) {
        var that = this;
        var attributeOldValueCache = {};
        var item = {
          target: target,
          options: options,
          insertHandler: function (e) {
            if (!canTriggerInsertOrRemove(e)) {
              return;
            }

            that.callback([
              mutationRecord(e, {
                addedNodes: [e.target]
              })
            ]);
          },
          removeHandler: function (e) {
            if (!canTriggerInsertOrRemove(e)) {
              return;
            }

            that.callback([
              mutationRecord(e, {
                removedNodes: [e.target]
              })
            ]);
          },
          attributeHandler: function (e) {
            if (!canTriggerAttributeModification(e)) {
              return;
            }

            that.callback([
              mutationRecord(e, {
                attributeName: e.attrName,
                oldValue: options.attributeOldValue ? (attributeOldValueCache[e.attrName] || e.prevValue || null) : null,
                type: 'attributes'
              })
            ]);

            // We keep track of old values so that when IE incorrectly reports the old value we can ensure it is
            // actually correct.
            if (options.attributeOldValue) {
              attributeOldValueCache[e.attrName] = e.newValue;
            }
          }
        };

        this.elements.push(item);

        if (options.childList) {
          target.addEventListener('DOMSubtreeModified', item.insertHandler);
          target.addEventListener('DOMNodeRemoved', item.removeHandler);
        }

        if (options.attributes) {
          target.addEventListener('DOMAttrModified', item.attributeHandler);
        }

        return this;

        function canTriggerInsertOrRemove (e) {
          return options.childList && (options.subtree || e.target.parentNode === target);
        }

        function canTriggerAttributeModification (e) {
          return e.target === target;
        }

        function mutationRecord (e, merge) {
          return inherit(merge, {
            addedNodes: null,
            attributeName: null,
            attributeNamespace: null,
            nextSibling: e.target.nextSibling,
            oldValue: null,
            previousSibling: e.target.previousSibling,
            removedNodes: null,
            target: e.target,
            type: 'childList'
          });
        }
      },

      disconnect: function () {
        for (var a in this.elements) {
          var item = this.elements[a];
          item.target.removeEventListener('DOMSubtreeModified', item.insertHandler);
          item.target.removeEventListener('DOMNodeRemoved', item.removeHandler);
          item.target.removeEventListener('DOMAttrModified', item.attributeHandler);
        }
      }
    };
  }


  // Public API
  // ----------

  var documentObserver;
  var skateComponents = {};

  /**
   * Creates a listener for the specified component.
   *
   * @param {String} id The ID of the component.
   * @param {Object | Function} component The component definition.
   *
   * @return {Function} Function or constructor that creates a custom-element for the component.
   */
  function skate (id, component) {
    if (!documentObserver) {
      documentObserver = new MutationObserver(function (mutations) {
        mutations.forEach(function (mutation) {
          skate.init(mutation.addedNodes);
          triggerRemoveAll(mutation.removedNodes);
        });
      });

      documentObserver.observe(document, {
        childList: true,
        subtree: true
      });
    }

    if (!component) {
      component = {};
    }

    if (typeof component === 'function') {
      component = {
        insert: component
      };
    }

    inherit(component, skate.defaults);

    var Element = makeElementConstructor(id, component);

    if (component.ready) {
      hiddenRules.sheet.insertRule(
        id + ':not(.' + component.classname + '),' +
        '[' + id + ']:not(.' + component.classname + '),' +
        '.' + id + ':not(.' + component.classname + '){display:none}',
        hiddenRules.sheet.cssRules.length
      );
    }

    var existing = Element.existing();

    for (var a = 0; a < existing.length; a++) {
      triggerLifecycle(id, component, existing[a]);
    }

    skateComponents[id] = component;

    return Element;
  }

  // Restriction type constants.
  skate.types = {
    ANY: 'act',
    ATTR: 'a',
    CLASS: 'c',
    NOATTR: 'ct',
    NOCLASS: 'at',
    NOTAG: 'ac',
    TAG: 't'
  };

  // Default configuration.
  skate.defaults = {
    // Set to `{...}` of `attrName: `{ init: ..., update: ..., remove: ... }` to listen to specific attributes.
    attributes: false,

    // The classname to use when showing this component.
    classname: '__skate',

    // Whether or not to start listening right away.
    listen: true,

    // Properties and methods to add to each element.
    prototype: {},

    // The type of bindings to allow.
    type: skate.types.ANY
  };

  /**
   * Ensures the passed element or elements aren't initialised.
   *
   * @param {Element | Traversable} elements The element or elements to blacklist.
   * @param {Boolean} andDescendants Whether or not to blacklist element descendants.
   *
   * @return {skate}
   */
  skate.blacklist = function (elements, andDescendants) {
    if (andDescendants === undefined) {
      andDescendants = true;
    }

    eachElement(elements, function (element) {
      data(element, 'blacklisted', true);

      if (andDescendants) {
        skate.blacklist(element.children, true);
      }
    });

    return skate;
  };

  /**
   * Stops listening.
   *
   * @return {skate}
   */
  skate.destroy = function () {
    documentObserver.disconnect();
    documentObserver = undefined;
    skateComponents = {};
    return skate;
  };

  /**
   * Synchronously initialises the specified element or elements.
   *
   * @param {Element | Traversable} elements The element or elements to init.
   *
   * @return {skate}
   */
  skate.init = function (elements) {
    eachElement(elements, function (element) {
      for (var possibleId in possibleIds(element)) {
        if (possibleId in skateComponents) {
          triggerLifecycle(possibleId, skateComponents[possibleId], element);
        }
      }

      skate.init(element.children);
    });

    return skate;
  };

  /**
   * Creates a new mutation observer for the specified element.
   *
   * @param {Function} callback The callback to execute for the observer.
   *
   * @return {MutationObserver}
   */
  skate.watch = function (callback) {
    return new MutationObserver(callback);
  };

  /**
   * Ensures the passed element or elements aren't blacklisted.
   *
   * @param {Element | Traversable} elements The element or elements to blacklist.
   * @param {Boolean} andDescendants Whether or not to whitelist element descendants.
   *
   * @return {skate}
   */
  skate.whitelist = function (elements, andDescendants) {
    if (andDescendants === undefined) {
      andDescendants = true;
    }

    eachElement(elements, function (element) {
      data(element, 'blacklisted', undefined);

      if (andDescendants) {
        skate.whitelist(element.children, true);
      }
    });

    return skate;
  };


  // Lifecycle Triggers
  // ------------------

  // Triggers the entire lifecycle.
  function triggerLifecycle (id, component, target) {
    if (data(target, 'blacklisted')) {
      return;
    }

    triggerReady(id, component, target, function (replaceWith) {
      if (!replaceWith) {
        return triggerInsert(id, component, target);
      }

      if (replaceWith === target || !target.parentNode) {
        return;
      }

      // A placeholder for replacing the current element.
      var comment = document.createComment('placeholder');

      // Replace the target with the placeholder.
      target.parentNode.insertBefore(comment, target);
      target.parentNode.removeChild(target);

      // Handle HTML.
      if (typeof replaceWith === 'string') {
        var div = document.createElement('div');
        div.innerHTML = replaceWith;
        replaceWith = div.children;
      }

      // Place each item before the comment in sequence.
      eachElement(replaceWith, function (element) {
        comment.parentNode.insertBefore(element, comment);
      });

      // Cleanup.
      comment.parentNode.removeChild(comment);
    });
  }

  // Triggers the ready callback and continues execution to the insert callback.
  function triggerReady (id, component, target, done) {
    var definedMultipleArgs = /^[^(]+\([^,)]+,/;
    var readyFn = component.ready;
    done = done || function () {};

    if (data(target, id + '.ready-called')) {
      return done();
    }

    data(target, id + '.ready-called', true);
    inherit(target, component.prototype);

    if (readyFn && definedMultipleArgs.test(readyFn)) {
      readyFn(target, done);
    } else if (readyFn) {
      done(readyFn(target));
    } else {
      done();
    }
  }

  // Triggers insert on the target.
  function triggerInsert (id, component, target) {
    var insertFn = component.insert;

    if (data(target, id + '.insert-called')) {
      return;
    }

    if (!target.parentNode) {
      return;
    }

    data(target, id + '.insert-called', true);
    triggerAttributes(id, component, target);
    addClass(target, component.classname);

    if (insertFn) {
      insertFn(target);
    }
  }

  // Triggers remove on the target.
  function triggerRemove (id, component, target) {
    if (component.remove && !data(target, 'blacklisted') && !data(target, id + '.remove-called')) {
      data(target, id + '.remove-called', true);
      component.remove(target);
    }
  }

  // Triggers the remove callbacks of the specified elements and their descendants.
  function triggerRemoveAll (elements) {
    eachElement(elements, function (element) {
      triggerRemoveAll(element.children);
      for (var possibleId in possibleIds(element)) {
        if (possibleId in skateComponents) {
          triggerRemove(possibleId, skateComponents[possibleId], element);
        }
      }
    });
  }

  // Initialises and binds attribute handlers.
  function triggerAttributes (id, component, target) {
    if (!component.attributes || data(target, id + '.attributes-called')) {
      return;
    }

    data(target, id + '.attributes-called', true);

    var observer = new MutationObserver(function (mutations) {
      mutations.forEach(function (mutation) {
        var name = mutation.attributeName;
        var attr = target.attributes[name];
        var lifecycle = component.attributes[name];

        if (!lifecycle) {
          return;
        }

        if (attr && mutation.oldValue === null && (lifecycle.insert || lifecycle.update || lifecycle)) {
          insert(lifecycle, target, attr.nodeValue);
        } else if (attr && mutation.oldValue !== null && (lifecycle.update || lifecycle)) {
          update(lifecycle, target, attr.nodeValue, mutation.oldValue);
        } else if (!attr && lifecycle.remove) {
          remove(lifecycle, target, mutation.oldValue);
        }
      });
    });

    observer.observe(target, {
      attributes: true,
      attributeOldValue: true
    });

    // Now trigger init on each attribute.
    for (var a = 0; a < target.attributes.length; a++) {
      var attribute = target.attributes[a];
      var lifecycle = component.attributes[attribute.nodeName];

      if (lifecycle) {
        insert(lifecycle, target, attribute.nodeValue);
      }
    }

    function insert (lifecycle, element, newValue) {
      (lifecycle.insert || lifecycle.update || lifecycle)(element, newValue);
    }

    function update (lifecycle, element, newValue, oldValue) {
      (lifecycle.update || lifecycle)(element, newValue, oldValue);
    }

    function remove (lifecycle, element, oldValue) {
      lifecycle.remove(element, oldValue);
    }
  }


  // Utilities
  // ---------

  function data (element, name, value) {
    if (value === undefined) {
      return element.__SKATE_DATA && element.__SKATE_DATA[name];
    }

    if (!element.__SKATE_DATA) {
      element.__SKATE_DATA = {};
    }

    element.__SKATE_DATA[name] = value;

    return element;
  }

  // Adds the specified class to the element.
  function addClass (element, classname) {
    if (element.classList) {
      element.classList.add(classname);
    } else {
      element.className += element.className ? ' ' + classname : classname;
    }
  }

  // Calls the specified callback for each element.
  function eachElement (elements, callback) {
    if (!elements) {
      return;
    }

    if (elements.nodeType) {
      if (elements.nodeType === 1) {
        elements = [elements];
      } else {
        return;
      }
    }

    if (!elements.length) {
      return;
    }

    for (var a = 0; a < elements.length; a++) {
      if (elements[a] && elements[a].nodeType === 1) {
        callback(elements[a], a);
      }
    }
  }

  // Returns the possible ids from an element.
  function possibleIds (element) {
    var ids = data(element, 'possible-ids');

    if (ids) {
      return ids;
    }

    var tag = element.tagName.toLowerCase();

    ids = {};
    ids[tag] = tag;

    for (var a = 0; a < element.attributes.length; a++) {
      var name = element.attributes[a].nodeName;
      ids[name] = name;
    }

    element.className.split(' ').forEach(function (id) {
      if (id) {
        ids[id] = id;
      }
    });

    data(element, 'possible-ids', ids);

    return ids;
  }

  // Merges the second argument into the first.
  function inherit (child, parent) {
    for (var prop in parent) {
      if (child[prop] === undefined) {
        child[prop] = parent[prop];
      }
    }

    return child;
  }

  // Creates a constructor for the specified component.
  function makeElementConstructor (id, component) {
    var isTag = component.type.indexOf(skate.types.TAG) > -1;
    var isAttr = component.type.indexOf(skate.types.ATTR) > -1;
    var isClass = component.type.indexOf(skate.types.CLASS) > -1;
    var selector = (function () {
        var selectors = [];

        if (isTag) {
          selectors.push(id);
        }

        if (isAttr) {
          selectors.push('[' + id + ']');
        }

        if (isClass) {
          selectors.push('.' + id);
        }

        return selectors.join(', ');
      }());
    var ctor = function () {
        if (!isTag) {
          throw new Error('Cannot construct "' + id + '" as a custom element.');
        }

        var element = document.createElement(id);
        triggerReady(id, component, element);
        return element;
      };

    ctor.existing = function (within) {
      return (within || document).querySelectorAll(ctor.selector());
    };

    ctor.selector = function () {
      return selector;
    };

    return ctor;
  }


  // Global Setup
  // ------------

  // Rules that hide elements as they're inserted so that elements are hidden
  // prior to calling the ready callback to prevent FOUC if the component
  // modifies the element in which it is bound.
  document.getElementsByTagName('head')[0].appendChild(hiddenRules);


  // Exporting
  // ---------

  if (typeof define === 'function' && define.amd) {
    define('skate', [], function () {
      return skate;
    });
  } else {
    window.skate = skate;
  }

})();

jQuery.os = {};
var jQueryOSplatform = navigator.platform.toLowerCase();
jQuery.os.windows = (jQueryOSplatform.indexOf("win") != -1);
jQuery.os.mac = (jQueryOSplatform.indexOf("mac") != -1);
jQuery.os.linux = (jQueryOSplatform.indexOf("linux") != -1);
/**
 *
 * @module Controls
 * @requires AJS, jQuery
 */

/**
 * If not visible, moves the scroll position of the screen to the element
 *
 * 
 * Usage:
 * jQuery("li.item").moveTo();
 * 
* * This plugin also supports options as an argument. The options * that can be defined are: *
    *
  • transition - if set to true will cause a smooth scrolling transition (false by default)
  • *
  • scrollOffset - defines an offset to scroll past the element to view in pixels such that * all of it can be viewed (35 pixels by default)
  • *
* * @class moveTo * @constuctor moveTo * @namespace jQuery.fn * @param {Object} options */ jQuery.fn.moveTo = function (options) { var defaults = { transition: false, scrollOffset: 35 }; var opts = jQuery.extend(defaults, options), instance = this, topOffset = instance.offset().top, scrollTarget; if ((jQuery(window).scrollTop() + jQuery(window).height() - this.outerHeight() < topOffset || jQuery(window).scrollTop() + opts.scrollOffset > topOffset) && jQuery(window).height() > opts.scrollOffset) { if(jQuery(window).scrollTop() + opts.scrollOffset > topOffset) { //move up scrollTarget = topOffset - (jQuery(window).height() - this.outerHeight()) + opts.scrollOffset; } else { //move down scrollTarget = topOffset - opts.scrollOffset; } if (!jQuery.fn.moveTo.animating && opts.transition) { jQuery(document).trigger("moveToStarted", this); jQuery.fn.moveTo.animating = true; jQuery("html,body").animate({ scrollTop: scrollTarget }, 1000, function () { jQuery(document).trigger("moveToFinished", instance); delete jQuery.fn.moveTo.animating; }); return this; } else { var jQueryCache = jQuery('html, body'); if (jQueryCache.is(":animated")) { jQueryCache.stop(); delete jQuery.fn.moveTo.animating; } jQuery(document).trigger("moveToStarted"); jQuery(window).scrollTop(scrollTarget); //need to put a slight timeout for the moveToFinished event such that recipients of this event //have time to act on it. setTimeout(function() { jQuery(document).trigger("moveToFinished", instance); }, 100); return this; } } jQuery(document).trigger("moveToFinished", this); return this; }; (function() { if (window.CustomEvent) { return; } function CustomEvent (event, params) { params = params || {}; var evt = document.createEvent('CustomEvent'); evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); return evt; }; CustomEvent.prototype = window.Event.prototype; window.CustomEvent = CustomEvent; }()); /*! Atlassian UI and the Atlassian Design Guidelines are created by Atlassian. See https://developer.atlassian.com/display/AUI/ for API documentation and https://developer.atlassian.com/design/ for license details. */ /** * A collection of Atlassian JavaScript UI components. * * AUI components/functions should be assumed Private unless included in the API documentation at http://developer.atlassian.com/display/AUI * * @module AJS * @requires jQuery */ (function () { 'use strict'; if (!window.jQuery && !window.Zepto) { throw new Error('either jQuery or Zepto is required for AJS to function.'); } if (typeof window.console === 'undefined') { window.console = { messages: [], log: function (text) { this.messages.push(text); }, show: function () { alert(this.messages.join('\n')); this.messages = []; } }; } else { // Firebug console - show not required to do anything. console.show = function () {}; } /** * AJS contains utility methods, used by various components. It also provides the namespacing for all AUI components. * * @class AJS * @requires jQuery */ window.AJS = (function () { var included = []; var uniqueID; var uniqueIDstring; var uniqueIDcounter = 0; function escapeHtmlReplacement(str) { var special = { '<': '<', '>': '>', '&': '&', '\'': ''', '`': '`' }; if (typeof special[str] === 'string') { return special[str]; } return '"'; } var ESCAPE_HTML_SPECIAL_CHARS = /[&"'<>`]/g; var res = { /** * Version number to allow for rough backwards compatibility via conditionals * NOTE: Don't change. Generated by the Maven at build. * @property version */ version: '5.6.8', /** * Parameters are loaded from the DOM on page load. * @property params */ params: {}, /** * Returns an HTMLElement reference. * @method $ * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements. * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements. */ $: window.jQuery || window.Zepto, /** * Logs the given object to the console. * @param obj object to log */ log: (function () { if (typeof console !== 'undefined' && console.log) { if (Function.prototype.bind) { return Function.prototype.bind.call(console.log, console); } else { return function() { Function.prototype.apply.call(console.log, console, arguments); } } } return function() {}; }()), /** * Logs the given object to the console as a warning. * @param obj object to log */ warn: function () { if (typeof console !== 'undefined' && console.warn) { Function.prototype.apply.apply(console.warn, [console, arguments]); } }, /** * Logs the given object to the console as an error. * @param obj object to log */ error: function () { if (typeof console !== 'undefined' && console.error) { Function.prototype.apply.apply(console.error, [console, arguments]); } }, /** * Calls e.preventDefault. This is designed for event handlers that only need to prevent the default browser * action, eg: * AJS.$(".my-class").click(AJS.preventDefault) * @param e jQuery event */ preventDefault: function (e) { e.preventDefault(); }, /** * Prevent further handling of an event. Returns false, which you should use as the return value of your event handler: * return AJS.stopEvent(e); * @param e jQuery event * @deprecated use AJS.preventDefault() instead */ stopEvent: function (e) { e.stopPropagation(); return false; // required for JWebUnit pop-up links to work properly }, include: function (url) { if (!this.contains(included, url)) { included.push(url); var s = document.createElement('script'); s.src = url; this.$('body').append(s); } }, /** * Shortcut function to toggle class name of an element. * @method toggleClassName * @param {String | HTMLElement} element The HTMLElement or an ID to toggle class name on. * @param {String} className The class name to remove or add. */ toggleClassName: function (element, className) { if (!(element = this.$(element))) { return; } element.toggleClass(className); }, /** * Shortcut function adds or removes 'hidden' classname to an element based on a passed boolean. * @method setVisible * @param {String | HTMLElement} element The HTMLElement or an ID to show or hide. * @param {boolean} show true to show, false to hide */ setVisible: function (element, show) { if (!(element = this.$(element))) { return; } // aliased for use inside function below var $ = this.$; $(element).each(function () { var isHidden = $(this).hasClass('hidden'); if (isHidden && show) { $(this).removeClass('hidden'); } else if (!isHidden && !show) { $(this).addClass('hidden'); } }); }, /** * Shortcut function adds or removes 'current' classname to an element based on a passed boolean. * @param {String | HTMLElement} element The HTMLElement or an ID to show or hide. * @param {boolean} show true to add 'current' class, false to remove */ setCurrent: function (element, current) { if (!(element = this.$(element))) { return; } if (current) { element.addClass('current'); } else { element.removeClass('current'); } }, /** * Shortcut function to see if passed element is currently visible on screen. * @method isVisible * @param {String | HTMLElement} element The HTMLElement or an jQuery selector to check. */ isVisible: function (element) { return !this.$(element).hasClass('hidden'); }, /** * Shortcut function to see if passed element is truncated/clipped, eg. with text-overflow: ellipsis * @method isClipped * @param {String | HTMLElement} element The HTMLElement or an jQuery selector to check. */ isClipped: function (el) { el = AJS.$(el); return (el.prop('scrollWidth') > el.prop('clientWidth')); }, /** * Find parameters in the DOM and store them in the provided object, or the ajs.params object if parameter is not present. */ populateParameters: function (parameters) { if (!parameters) { parameters = this.params; } var ajs = this; this.$('.parameters input').each(function () { var value = this.value, id = this.title || this.id; if (ajs.$(this).hasClass('list')) { if (parameters[id]) { parameters[id].push(value); } else { parameters[id] = [value]; } } else { parameters[id] = (value.match(/^(tru|fals)e$/i) ? value.toLowerCase() === 'true' : value); } }); }, /** * Adds functions to the list of methods to be run on initialisation. Wraps * error handling around the provided function so its failure won't prevent * other init functions running. * @method toInit * @param {Function} func Function to be call on initialisation. * @return AJS object. */ toInit: function (func) { var ajs = this; this.$(function () { try { func.apply(this, arguments); } catch (ex) { ajs.log('Failed to run init function: ' + ex + '\n' + func.toString()); } }); return this; }, /** * Finds the index of an element in the array. * @method indexOf * @param item Array element which will be searched. * @param fromIndex (optional) the index from which the item will be searched. Negative values will search from the * end of the array. * @return a zero based index of the element. */ indexOf: function (array, item, fromIndex) { var length = array.length; if (!fromIndex) { fromIndex = 0; } else if (fromIndex < 0) { fromIndex = Math.max(0, length + fromIndex); } for (var i = fromIndex; i < length; i++) { if (array[i] === item) { return i; } } return -1; }, /** * Looks for an element inside the array. * @method contains * @param item Array element which will be searched. * @return {Boolean} Is element in array. */ contains: function (array, item) { return this.indexOf(array, item) > -1; }, /** * Includes firebug lite for debugging in IE. Especially in IE. * @method firebug * @usage Type in addressbar "javascript:alert(AJS.firebug());" * @deprecated */ firebug: function () { // Deprecated in 5.1 AJS.log('DEPRECATED: AJS.firebug should no longer be used.'); var script = this.$(document.createElement('script')); script.attr('src', 'https://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'); this.$('head').append(script); (function () { if (window.firebug) { firebug.init(); } else { setTimeout(AJS.firebug, 0); } })(); }, /** * Clones the element specified by the selector and removes the id attribute * @param selector a jQuery selector */ clone : function (selector) { return AJS.$(selector).clone().removeAttr('id'); }, /** * Compare two strings in alphanumeric way * @method alphanum * @param {String} a first string to compare * @param {String} b second string to compare * @return {Number(-1|0|1)} -1 if a < b, 0 if a = b, 1 if a > b * @usage a.sort(AJS.alphanum) */ alphanum: function (a, b) { a = (a + '').toLowerCase(); b = (b + '').toLowerCase(); var chunks = /(\d+|\D+)/g; var am = a.match(chunks); var bm = b.match(chunks); var len = Math.max(am.length, bm.length); for (var i = 0; i < len; i++) { if (i === am.length) { return -1; } if (i === bm.length) { return 1; } var ad = parseInt(am[i], 10) + ''; var bd = parseInt(bm[i], 10) + ''; if (ad === am[i] && bd === bm[i] && ad !== bd) { return (ad - bd) / Math.abs(ad - bd); } if ((ad !== am[i] || bd !== bm[i]) && am[i] !== bm[i]) { return am[i] < bm[i] ? -1 : 1; } } return 0; }, onTextResize: function (f) { if (typeof f === 'function') { if (AJS.onTextResize['on-text-resize']) { AJS.onTextResize['on-text-resize'].push(function (emsize) { f(emsize); }); } else { var em = AJS('div'); em.css({ width: '1em', height: '1em', position: 'absolute', top: '-9999em', left: '-9999em' }); this.$('body').append(em); em.size = em.width(); setInterval(function () { if (em.size !== em.width()) { em.size = em.width(); for (var i = 0, ii = AJS.onTextResize['on-text-resize'].length; i < ii; i++) { AJS.onTextResize['on-text-resize'][i](em.size); } } }, 0); AJS.onTextResize.em = em; AJS.onTextResize['on-text-resize'] = [function (emsize) { f(emsize); }]; } } }, unbindTextResize: function (f) { for (var i = 0, ii = AJS.onTextResize['on-text-resize'].length; i < ii; i++) { if (AJS.onTextResize['on-text-resize'][i] === f) { return AJS.onTextResize['on-text-resize'].splice(i, 1); } } }, /** * Similar to Javascript's in-built escape() function, but where the built-in escape() * might encode unicode charaters as %uHHHH, this function will leave them as-is. * * NOTE: this function does not do html-escaping, see AJS.escapeHtml() */ escape: function (string) { return escape(string).replace(/%u\w{4}/gi, function (w) { return unescape(w); }); }, /** * Sanitise a string for use with innerHTML or as an attribute. * * @param {String} str */ escapeHtml: function (str) { return str.replace(ESCAPE_HTML_SPECIAL_CHARS, escapeHtmlReplacement); }, /** * Filters a list of entries by a passed search term. * * Options : * - "keywordsField" - name of entry field containing keywords, default "keywords" * - "ignoreForCamelCase" - ignore search case for camel case, e.g. CB matches Code Block *and* Code block * - "matchBoundary" - match words only at boundary, e.g. link matches "linking" but not "hyperlinks" * - "splitRegex" - regex to split search words, instead of on whitespace * * @param entries an index array of objects with a "keywords" property * @param search one or more words to search on, which may include camel-casing. * @param options - optional - specifiy to override default behaviour */ filterBySearch : function (entries, search, options) { // search for nothing, get nothing - up to calling code to handle. if (!search) { return []; } var $ = this.$; var keywordsField = (options && options.keywordsField) || 'keywords'; var camelCaseFlags = (options && options.ignoreForCamelCase) ? 'i' : ''; var boundaryFlag = (options && options.matchBoundary) ? '\\b' : ''; var splitRegex = (options && options.splitRegex) || (/\s+/); // each word in the input is considered a distinct filter that has to match a keyword in the record var filterWords = search.split(splitRegex); var filters = []; filterWords.forEach(function(word) { // anchor on word boundaries var subfilters = [new RegExp(boundaryFlag + word, 'i')]; // split camel-case into separate words if (/^([A-Z][a-z]*) {2,}$/.test(this)) { var camelRegexStr = this.replace(/([A-Z][a-z]*)/g, '\\b$1[^,]*'); subfilters.push(new RegExp(camelRegexStr, camelCaseFlags)); } filters.push(subfilters); }); var result = []; entries.forEach(function(entry) { for (var i = 0; i < filters.length; i++) { var somethingMatches = false; for (var j = 0; j < filters[i].length; j++) { if (filters[i][j].test(entry[keywordsField])) { somethingMatches = true; break; } } if (!somethingMatches) { return; } } result.push(entry); }); return result; }, /** * Draws an AUI logo with SVG. * @deprecated */ drawLogo : function (options) { // Deprecated in 5.1 AJS.log('DEPRECATED: AJS.drawLogo should no longer be used.'); var scale = options.scaleFactor || 1; var fill = options.fill || '#fff'; var stroke = options.stroke || '#000'; var width = 400 * scale; var height = 40 * scale; var strokeWidth = options.strokeWidth || 1; var containerID = options.containerID || '.aui-logo'; if (!AJS.$('.aui-logo').length) { AJS.$('body').append('




© 2015 - 2025 Weber Informatics LLC | Privacy Policy