This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Allows you to create a jQuery style (like .attr(), .css()) getter and setter function for any variable or property you choose. | |
* When a property name of your subject is provided, it's returned. if a 2nd argument is passed as well, your subject is set to that value | |
* | |
* @param property The variable or property your getter/setter will operate on | |
* @return [chainTo] {Object} Optionally return the object the subject is a property of, to allow chaining | |
* @author https://github.com/JamieMason | |
*/ | |
function createGetterSetter(subject, chainTo) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A really simple form of templating, this function replaces named tokens in strings with the values of Object properties of the same name. | |
* When an Array is passed, the template is repeated for every object in the Array. | |
* | |
* @author https://github.com/JamieMason | |
* @param {String} template A string containing various ${someVar}, ${someOtherVar} tokens to be found and replaced | |
* @param {Object} data A value object whose properties' values eg: .someVar, .someOtherVar will be merged with the supplied template. If an Array is passed, the template will be applied to each Object in the Array. | |
* @return A copy of the template merged with your data, in those places where the property names of your data matched the named tokens in the template. | |
* @type String | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global ActiveXObject*/ | |
/** | |
* Provides Cross Browser Plugin Detection for Quicktime, Flash, Windows Media, Acrobat, Java, etc... or whatever you extend it to. Modified version of http://www.knallgrau.at/code/plugin_js version 0.5 | |
* @author https://github.com/JamieMason | |
* @constructor | |
*/ | |
function PluginSniffer() | |
{ | |
var self = this; // Reference this instance, whatever it might be called instead of Plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a random number between a specified range, optionally set to a fixed number of decimal places | |
* | |
* @author https://github.com/JamieMason | |
* @param {Number} minimumValue The lowest value the random number can be | |
* @param {Number} maximumValue The highest value the random number can be | |
* @param {Number} decimalPlaces Optional value to set the number of decimal places | |
* @type Number | |
*/ | |
function getRandomNumber(minimumValue, maximumValue, decimalPlaces) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mini-library for getting information on the Browser Chrome and display properties of the client machine. Provides the methods getAvailableScreenHeight, getAvailableScreenWidth, getColourDepth, getScrollBarThickness, getViewPortHeight, getViewPortWidth, getWindowHeight, getWindowLeft, getWindowTop, getWindowWidth | |
* | |
* @author http://github.com/JamieMason | |
* @constructor | |
*/ | |
function BrowserChrome() | |
{ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Performs a find/replace on the contents of a generic view template. eg: A generic template should have quite reusable names which describe the content in respect to the view it's marking up, rather than the data that's being merged into it. Like ${heading} rather than ${brandName} for example. The same view template might be used in different places with different data. | |
* | |
* @author https://github.com/JamieMason | |
* @param {String} templateContents The template to find/replace on, eg: '<div><strong>${boldText}</strong> ${regularText} (${sideNote})</div>' | |
* @return A new template with renamed tokens which match the properties of the model you plan to use it against | |
* @type String | |
*/ | |
function alignTemplate(templateContents, bindings) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var oSuperclass = function (spec, oProtected) | |
{ | |
oProtected = oProtected || {}; | |
var that = {}; | |
oProtected.supMethod = function() | |
{ | |
console.log('superclass says: ', spec.jamie); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine whether the supplied value's datatype is Number. | |
* Odd problems can occur eg: "1"+"6" is "16" not 7. | |
* @param {Mixed} value Could be a true number: 123, 12.00, or eg: "123", "12.00" | |
* @return {Boolean} Whether value's type is Number, eg: "123" would be false whereas 123 would be true. | |
*/ | |
function isNum(data) | |
{ | |
return !isNaN(parseFloat(data)) && typeof data !== 'string'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createNamespace(namespaceString, scope) | |
{ | |
// eg: 'company.section.product.model.version' => ['company', 'section', 'product', 'model', 'version'] | |
var nsNames = namespaceString.split(/[:\.]/g), | |
// store this to save looking it up on every pass of the loop | |
nsNamesLength = nsNames.length, | |
// an optional object to apply the namespace to, eg: myObj.company.* if set, otherwise window.company.* | |
refs = [scope || window], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var simpleData = function (data) | |
{ | |
var that = {}; | |
// Decorators should always hold a simpleData instance, as you can nest instances | |
// we do checking here rather than in every decorator | |
if (typeof data.set === 'function') | |
{ | |
return data; | |
} |
OlderNewer