JavaXT
|
|||||||||||||||||||||||||||||||||||||||||||||||
utils ClassCommon functions and utilities used by the webcontrols
ConstructorsThere are no public constructors.EventsonRender( el, callback ) Used to check whether DOM element has been added to the document. Calls a callback if it exists or when it is added. Public Methodsget( url, config ) Used to execute an HTTP GET request. Example:
get(url + "?filter=" + encodeURIComponent(filter), { success: function(text){ var arr = JSON.parse(text).records; }, failure: function(request){ alert(request.status); } });
getParameter( name, url ) Returns the value of a given parameter name in a URL querystring
merge( settings, defaults ) Used to merge properties from one json object into another. Credit: https://github.com/stevenleadbeater/JSONT/blob/master/JSONT.js diff( obj1, obj2 ) Used to compare 2 json objects. Returns a json object with differences. Credit: https://stackoverflow.com/a/13389935/ isArray( obj ) Used to check whether a given object is an array. Note that this check does not use the "instanceof Array" approach because of issues with frames. isDate( d ) Return true if a given object can be parsed into a date. Returns false if the object is a number (e.g. "3", "1.2") setStyle( el, style ) Used to set the style for a given element, replacing whatever style was there before.
addStyle( el, style ) Used to add style to a given element.
hasStyleRule( selector ) Returns true if there is a style rule defined for a given selector.
addNoSelectRule( ) Inserts the "javaxt-noselect" class into the document if it is not present. createElement( type, obj, style ) Used to create a DOM element
createTable( parent ) Used to create a table element.
createClipboard( parent ) Used to create a hidden clipboard in a given parent. Text and other data can be inserted into the clipboard via the insert() method on the DOM object returned by this method. Once data is inserted into the clipboard, clients can retrieve the data via the browser "paste" event (e.g. ctrl+v on windows).
getSuggestedColumnWidths( records, pixelsPerChar, maxWidth ) Used to analyze a given dataset and suggest column widths for a table or a datagrid
updateDOM( ) Used to update the default befaviour of the browser to prevent things like right mouse click, scrolling beyond a page, and drag and drop. getZScores( values, normalize ) Returns z-scores for a given set of values
initDrag( dragHandle, config ) Used to update a DOM element and enable dragging. It is up to the caller to process the drag events and update the DOM element via event handlers defined in the config. Example:
initDrag(div, { onDragStart: function(mouseX, mouseY){ //Do something, like compute x/y offsets, update cursor, etc }, onDrag: function(mouseX, mouseY){ this.style.left = x + 'px'; this.style.top = y + 'px'; }, onDragEnd: function(){ //Do something, like repost position, update cursor, etc } }); getHighestElements( obj ) Returns an array of elements at the highest z-index in the document getNextHighestZindex( obj ) Returns an integer represeting the highest z-value of all the DOM elements that appear with the given object + 1 alert( msg, config ) Used to render an alert dialog using the javaxt.dhtml.Window class.
confirm( msg, config ) Used to render a confirm dialog using the javaxt.dhtml.Window class. Example:
javaxt.dhtml.utils.confirm({ title: "Quit Game?", text: "Are you sure you want to quit the game?", leftButton: { label: "Yes", value: true }, rightButton: { label: "No", value: false }, callback: function(answer){ if (answer===true) console.log("quit game"); else console.log("continue game"); } });
|