From 2a1b797767aa549710804e28fba3c6a6cded1b34 Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Mon, 25 Nov 2013 09:19:50 -0800 Subject: [PATCH] Modified OpenSeadragon.version property Let grunt do more of the work! --- Gruntfile.js | 6 ++++++ src/openseadragon.js | 42 ++++++++++++++++++------------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 419752e4..80d133e1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,6 +55,12 @@ module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: packageJson, + version: { + versionStr: packageJson.version, + major: parseInt(packageJson.version.split('.')[0]), + minor: parseInt(packageJson.version.split('.')[1]), + revision: parseInt(packageJson.version.split('.')[2]) + }, clean: { build: ["build"], package: [packageDir], diff --git a/src/openseadragon.js b/src/openseadragon.js index efae6051..f1e6ba8c 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -287,18 +287,12 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * @property {Number} minor - The minor version number. * @property {Number} revision - The revision number. */ - $.version = (function () { - // The version string ('x.x.x') is filled in by the grunt concat build task - // from the 'version' value in package.json - var versionStr = '<%= pkg.version %>', - versionComponents = versionStr.split( '.' ); - return { - versionStr: versionStr, - major: parseInt( versionComponents[ 0 ] ), - minor: parseInt( versionComponents[ 1 ] ), - revision: parseInt( versionComponents[ 2 ] ) - }; - }()); + $.version = { + versionStr: '<%= version.versionStr %>', + major: parseInt('<%= version.major %>'), + minor: parseInt('<%= version.minor %>'), + revision: parseInt('<%= version.revision %>') + }; /** @@ -307,18 +301,18 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){ * @private */ var class2type = { - '[object Boolean]': 'boolean', - '[object Number]': 'number', - '[object String]': 'string', - '[object Function]': 'function', - '[object Array]': 'array', - '[object Date]': 'date', - '[object RegExp]': 'regexp', - '[object Object]': 'object' - }, - // Save a reference to some core methods - toString = Object.prototype.toString, - hasOwn = Object.prototype.hasOwnProperty; + '[object Boolean]': 'boolean', + '[object Number]': 'number', + '[object String]': 'string', + '[object Function]': 'function', + '[object Array]': 'array', + '[object Date]': 'date', + '[object RegExp]': 'regexp', + '[object Object]': 'object' + }, + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty; /** * Taken from jQuery 1.6.1