Added .map files and fixed one issue with value editor

pull/78/head
Jim Heising 2014-09-29 11:50:13 -07:00
parent 36ce5bb0d7
commit b6ac25061f
11 changed files with 96 additions and 119 deletions

View File

@ -65,12 +65,18 @@ module.exports = function(grunt) {
fb: {
files: {
'js/freeboard.min.js' : [ 'js/freeboard.js' ]
}
},
options:{
sourceMap : true
}
},
plugins: {
files: {
'js/freeboard.plugins.min.js' : [ 'js/freeboard.plugins.js' ]
}
},
options:{
sourceMap : true
}
},
thirdparty :{
options: {
@ -85,7 +91,10 @@ module.exports = function(grunt) {
'fb+plugins': {
files: {
'js/freeboard+plugins.min.js' : [ 'js/freeboard+plugins.js' ]
}
},
options:{
sourceMap : true
}
}
},
'string-replace': {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

5
js/freeboard.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -225,10 +225,15 @@ ValueEditor = function(theFreeboardModel)
}
}).focus(function()
{
$(element).css({"z-index" : 3001});
_resizeValueEditor(element);
}).focusout(function()
{
$(element).css({height: ""});
$(element).css({
"height": "",
"z-index" : 3000
});
$(element).next("ul#value-selector").remove();
dropdown = null;
selectedOptionIndex = -1;

View File

@ -1,11 +1,7 @@
function WidgetModel(theFreeboardModel, widgetPlugins)
{
function disposeWidgetInstance()
{
if(!_.isUndefined(self.widgetInstance))
{
if(_.isFunction(self.widgetInstance.onDispose))
{
function WidgetModel(theFreeboardModel, widgetPlugins) {
function disposeWidgetInstance() {
if (!_.isUndefined(self.widgetInstance)) {
if (_.isFunction(self.widgetInstance.onDispose)) {
self.widgetInstance.onDispose();
}
@ -22,18 +18,14 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
this.fillSize = ko.observable(false);
this.type = ko.observable();
this.type.subscribe(function(newValue)
{
this.type.subscribe(function (newValue) {
disposeWidgetInstance();
if((newValue in widgetPlugins) && _.isFunction(widgetPlugins[newValue].newInstance))
{
if ((newValue in widgetPlugins) && _.isFunction(widgetPlugins[newValue].newInstance)) {
var widgetType = widgetPlugins[newValue];
function finishLoad()
{
widgetType.newInstance(self.settings(), function(widgetInstance)
{
function finishLoad() {
widgetType.newInstance(self.settings(), function (widgetInstance) {
self.fillSize((widgetType.fill_size === true));
self.widgetInstance = widgetInstance;
@ -44,22 +36,18 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
}
// Do we need to load any external scripts?
if(widgetType.external_scripts)
{
if (widgetType.external_scripts) {
head.js(widgetType.external_scripts.slice(0), finishLoad); // Need to clone the array because head.js adds some weird functions to it
}
else
{
else {
finishLoad();
}
}
});
this.settings = ko.observable({});
this.settings.subscribe(function(newValue)
{
if(!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onSettingsChanged))
{
this.settings.subscribe(function (newValue) {
if (!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onSettingsChanged)) {
self.widgetInstance.onSettingsChanged(newValue);
}
@ -67,74 +55,58 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
self._heightUpdate.valueHasMutated();
});
this.processDatasourceUpdate = function(datasourceName)
{
this.processDatasourceUpdate = function (datasourceName) {
var refreshSettingNames = self.datasourceRefreshNotifications[datasourceName];
if(_.isArray(refreshSettingNames))
{
_.each(refreshSettingNames, function(settingName)
{
if (_.isArray(refreshSettingNames)) {
_.each(refreshSettingNames, function (settingName) {
self.processCalculatedSetting(settingName);
});
}
}
this.callValueFunction = function(theFunction)
{
this.callValueFunction = function (theFunction) {
return theFunction.call(undefined, theFreeboardModel.datasourceData);
}
this.processSizeChange = function()
{
if(!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onSizeChanged))
{
this.processSizeChange = function () {
if (!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onSizeChanged)) {
self.widgetInstance.onSizeChanged();
}
}
this.processCalculatedSetting = function(settingName)
{
if(_.isFunction(self.calculatedSettingScripts[settingName]))
{
this.processCalculatedSetting = function (settingName) {
if (_.isFunction(self.calculatedSettingScripts[settingName])) {
var returnValue = undefined;
try
{
try {
returnValue = self.callValueFunction(self.calculatedSettingScripts[settingName]);
}
catch(e)
{
catch (e) {
var rawValue = self.settings()[settingName];
// If there is a reference error and the value just contains letters and numbers, then
if(e instanceof ReferenceError && (/^\w+$/).test(rawValue))
{
if (e instanceof ReferenceError && (/^\w+$/).test(rawValue)) {
returnValue = rawValue;
}
}
if(!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onCalculatedValueChanged) && !_.isUndefined(returnValue))
{
try
{
if (!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.onCalculatedValueChanged) && !_.isUndefined(returnValue)) {
try {
self.widgetInstance.onCalculatedValueChanged(settingName, returnValue);
}
catch(e)
{
catch (e) {
console.log(e.toString());
}
}
}
}
this.updateCalculatedSettings = function()
{
this.updateCalculatedSettings = function () {
self.datasourceRefreshNotifications = {};
self.calculatedSettingScripts = {};
if(_.isUndefined(self.type()))
{
if (_.isUndefined(self.type())) {
return;
}
@ -143,28 +115,22 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
var datasourceRegex = new RegExp("datasources.([\\w_-]+)|datasources\\[['\"]([^'\"]+)", "g");
var currentSettings = self.settings();
_.each(settingsDefs, function(settingDef)
{
if(settingDef.type == "calculated")
{
_.each(settingsDefs, function (settingDef) {
if (settingDef.type == "calculated") {
var script = currentSettings[settingDef.name];
if(!_.isUndefined(script))
{
if (!_.isUndefined(script)) {
// If there is no return, add one
if((script.match(/;/g) || []).length <= 1 && script.indexOf("return") == -1)
{
if ((script.match(/;/g) || []).length <= 1 && script.indexOf("return") == -1) {
script = "return " + script;
}
var valueFunction;
try
{
try {
valueFunction = new Function("datasources", script);
}
catch(e)
{
catch (e) {
var literalText = currentSettings[settingDef.name].replace(/"/g, '\\"').replace(/[\r\n]/g, ' \\\n');
// If the value function cannot be created, then go ahead and treat it as literal text
@ -177,13 +143,11 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
// Are there any datasources we need to be subscribed to?
var matches;
while(matches = datasourceRegex.exec(script))
{
var dsName = (matches[1] || matches[2]);
while (matches = datasourceRegex.exec(script)) {
var dsName = (matches[1] || matches[2]);
var refreshSettingNames = self.datasourceRefreshNotifications[dsName];
if(_.isUndefined(refreshSettingNames))
{
if (_.isUndefined(refreshSettingNames)) {
refreshSettingNames = [];
self.datasourceRefreshNotifications[dsName] = refreshSettingNames;
}
@ -197,12 +161,10 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
this._heightUpdate = ko.observable();
this.height = ko.computed({
read: function()
{
read: function () {
self._heightUpdate();
if(!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.getHeight))
{
if (!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.getHeight)) {
return self.widgetInstance.getHeight();
}
@ -211,32 +173,27 @@ function WidgetModel(theFreeboardModel, widgetPlugins)
});
this.shouldRender = ko.observable(false);
this.render = function(element)
{
this.render = function (element) {
self.shouldRender(false);
if(!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.render))
{
if (!_.isUndefined(self.widgetInstance) && _.isFunction(self.widgetInstance.render)) {
self.widgetInstance.render(element);
self.updateCalculatedSettings();
}
}
this.dispose = function()
{
this.dispose = function () {
}
this.serialize = function()
{
this.serialize = function () {
return {
title : self.title(),
type : self.type(),
title: self.title(),
type: self.type(),
settings: self.settings()
};
}
this.deserialize = function(object)
{
this.deserialize = function (object) {
self.title(object.title);
self.settings(object.settings);
self.type(object.type);

View File

@ -7,7 +7,7 @@
"grunt-contrib-concat": "0.1.3",
"grunt-contrib-cssmin": "0.6.1",
"grunt-contrib-watch": "0.5.3",
"grunt-contrib-uglify": "0.2.0",
"grunt-contrib-uglify": "0.6.0",
"grunt-string-replace": "^0.2.7"
}
}