Skip to content

Commit

Permalink
Update codestyle & prepare version 4.1.0 (AppStore)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelte Lagendijk committed Feb 9, 2016
1 parent 6363af9 commit a252de0
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 144 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"undef" : true,
"globals" : {
"mendix" : false,
"mx" : false
"mx" : false,
"logger" : false
},

// Relaxing
Expand Down
64 changes: 23 additions & 41 deletions src/DynamicImage/widget/DynamicImage.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
/*jslint white:true, nomen: true, plusplus: true */
/*global mx, define, require, browser, devel, console, document, jQuery, window */
/*mendix */
/*
DynamicImage
========================
@file : DynamicImage.js
@version : 1.1
@author : Gerhard Richard Edens
@date : Tue, 09 Jun 2015 07:51:58 GMT
@copyright : Mendix bv
@license : Apache 2
Documentation
========================
Describe your widget here.
*/

define([
"dojo/_base/declare", "mxui/widget/_WidgetBase", "dijit/_TemplatedMixin",
Expand All @@ -37,12 +19,12 @@ define([
},

postCreate: function () {
console.log(this.id + ".postCreate");
logger.debug(this.id + ".postCreate");
this._updateRendering();
},

update: function (obj, callback) {
console.log(this.id + ".update");
logger.debug(this.id + ".update");
this._contextObj = obj;
if (obj !== null) {
this._resetSubscriptions();
Expand All @@ -53,7 +35,7 @@ define([
},

applyContext: function (context, callback) {
console.log(this.id + ".applyContext");
logger.debug(this.id + ".applyContext");
if (context && !!context.getTrackId()) {
var obj = context.getTrackObject();
if (obj !== null) {
Expand All @@ -72,7 +54,7 @@ define([
},

uninitialize: function () {
console.log(this.id + ".uninitialize");
logger.debug(this.id + ".uninitialize");
try {
if (this._handles) {
this._handles.forEach(function (handle, i) {
Expand All @@ -81,20 +63,20 @@ define([
this._handles = [];
}
} catch (e) {
console.warn('Unitialize of Dynamic Image Viewer failed');
console.warn("Unitialize of Dynamic Image Viewer failed");
}
},

// Rerender the interface.
_updateRendering: function (callback) {
console.log(this.id + "._updateRendering");
logger.debug(this.id + "._updateRendering");

var targetObj,
loaded = false;

if (this._contextObj !== null) {
try {
if (this.imageattr !== '') {
if (this.imageattr !== "") {
if (this.imageattr.indexOf("/") === -1) {
loaded = this._loadImagefromUrl(this._contextObj.get(this.imageattr));
} else {
Expand All @@ -116,23 +98,23 @@ define([
}
this.connect(this.imageNode, "onclick", this.execclick);
} catch (err) {
console.warn(this.id +'.setDataobject: error while loading image' + err);
console.warn(this.id +".setDataobject: error while loading image" + err);
loaded = false;
}
} else {
console.warn(this.id + '.setDataobject: received null object');
console.warn(this.id + ".setDataobject: received null object");
}

if (!loaded) {
this._setToDefaultImage();
}
if (callback)
callback();

if (callback)
callback();
},

_loadImagefromUrl : function(url) {
console.log(this.id + "._loadImagefromUrl");
logger.debug(this.id + "._loadImagefromUrl");

if (url !== "" && typeof url !== "undefined" && url !== null) {
this.imageNode.onerror = lang.hitch(this, this._setToDefaultImage);
Expand All @@ -147,7 +129,7 @@ define([
},

_resizeImage: function() {
console.log(this.id + "._resizeImage");
logger.debug(this.id + "._resizeImage");
var origw, origh, factorw, factorh, factor;
origw = this.imageNode.width;
origh = this.imageNode.height;
Expand All @@ -156,14 +138,14 @@ define([
factorh = this.height / origh;
factor = (factorw < factorh ? factorw : factorh);
if (factor < 1) {//check prevents upscaling
domStyle.add(this.imageNode, 'width', (factor * origw) + 'px');
domStyle.add(this.imageNode, 'height', (factor * origh) + 'px');
domStyle.add(this.imageNode, "width", (factor * origw) + "px");
domStyle.add(this.imageNode, "height", (factor * origh) + "px");
}
}
},

_setToDefaultImage : function() {
console.log(this.id + "._setToDefaultImage");
logger.debug(this.id + "._setToDefaultImage");
if (this.imageNode) {
this.imageNode.onerror = null; //do not catch exceptions when loading default
this.imageNode.src = this.defaultImage;
Expand All @@ -172,7 +154,7 @@ define([

_execClick : function(index) {
if (this._contextObj !== null && this.imageNode) {
if (this.clickmicroflow !== '')
if (this.clickmicroflow !== "")
{
mx.data.action({
params : {
Expand All @@ -187,10 +169,10 @@ define([
}
});
}
if (this.linkattr !== '')
if (this.linkattr !== "")
{
var url = this._contextObj.get(this.linkattr);
if (url !== '' && url !== undefined && url !== null) {
if (url !== "" && url !== undefined && url !== null) {
window.open(url, this.linktarget);
}
}
Expand All @@ -199,7 +181,7 @@ define([

// Reset subscriptions.
_resetSubscriptions: function () {
console.log(this.id + "._resetSubscriptions");
logger.debug(this.id + "._resetSubscriptions");
var _objectHandle = null;

// Release handles on previous object, if any.
Expand All @@ -210,7 +192,7 @@ define([
this._handles = [];
}

// When a mendix object exists create subscribtions.
// When a mendix object exists create subscribtions.
if (this._contextObj) {
_objectHandle = this.subscribe({
guid: this._contextObj.getGuid(),
Expand All @@ -225,4 +207,4 @@ define([
});
require(["DynamicImage/widget/DynamicImage"], function () {
"use strict";
});
});
64 changes: 23 additions & 41 deletions src/DynamicImage/widget/MobileDynamicImage.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
/*jslint white:true, nomen: true, plusplus: true */
/*global mx, define, require, browser, devel, console, document, jQuery, window */
/*mendix */
/*
DynamicImage
========================
@file : DynamicImage.js
@version : 1.1
@author : Gerhard Richard Edens
@date : Tue, 09 Jun 2015 07:51:58 GMT
@copyright : Mendix bv
@license : Apache 2
Documentation
========================
Describe your widget here.
*/

define([
"dojo/_base/declare", "mxui/widget/_WidgetBase", "dijit/_TemplatedMixin",
"mxui/dom", "dojo/dom", "dojo/query", "dojo/dom-prop", "dojo/dom-geometry", "dojo/dom-class", "dojo/dom-style", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang", "dojo/text", "dojo/html", "dojo/_base/event",
"dojo/text!DynamicImage/widget/template/MobileDynamicImage.html"
"dojo/text!DynamicImage/widget/template/DynamicImage.html"
], function (declare, _WidgetBase, _TemplatedMixin, dom, dojoDom, domQuery, domProp, domGeom, domClass, domStyle, domConstruct, dojoArray, lang, text, html, event, widgetTemplate) {
"use strict";

Expand All @@ -40,12 +22,12 @@ define([
},

postCreate: function () {
console.log(this.id + ".postCreate");
logger.debug(this.id + ".postCreate");
this._updateRendering();
},

update: function (obj, callback) {
console.log(this.id + ".update");
logger.debug(this.id + ".update");
this._contextObj = obj;
if (obj !== null) {
this._resetSubscriptions();
Expand All @@ -56,7 +38,7 @@ define([
},

applyContext: function (context, callback) {
console.log(this.id + ".applyContext");
logger.debug(this.id + ".applyContext");
if (context && !!context.getTrackId()) {
var obj = context.getTrackObject();
if (obj !== null) {
Expand All @@ -75,7 +57,7 @@ define([
},

uninitialize: function () {
console.log(this.id + ".uninitialize");
logger.debug(this.id + ".uninitialize");
try {
if (this._handles) {
this._handles.forEach(function (handle, i) {
Expand All @@ -84,20 +66,20 @@ define([
this._handles = [];
}
} catch (e) {
console.warn('Unitialize of Dynamic Image Viewer failed');
console.warn("Unitialize of Dynamic Image Viewer failed");
}
},

// Rerender the interface.
_updateRendering: function (callback) {
console.log(this.id + "._updateRendering");
logger.debug(this.id + "._updateRendering");

var targetObj,
loaded = false;

if (this._contextObj !== null) {
try {
if (this.imageattr !== '') {
if (this.imageattr !== "") {
if (this.imageattr.indexOf("/") === -1) {
loaded = this._loadImagefromUrl(this._contextObj.get(this.imageattr));
} else {
Expand All @@ -119,23 +101,23 @@ define([
}
this.connect(this.imageNode, "onclick", this.execclick);
} catch (err) {
console.warn(this.id +'.setDataobject: error while loading image' + err);
console.warn(this.id +".setDataobject: error while loading image" + err);
loaded = false;
}
} else {
console.warn(this.id + '.setDataobject: received null object');
console.warn(this.id + ".setDataobject: received null object");
}

if (!loaded) {
this._setToDefaultImage();
}

if (callback)
callback();
if (callback)
callback();
},

_loadImagefromUrl : function(url) {
console.log(this.id + "._loadImagefromUrl");
logger.debug(this.id + "._loadImagefromUrl");

if (url !== "" && typeof url !== "undefined" && url !== null) {
this.imageNode.onerror = lang.hitch(this, this._setToDefaultImage);
Expand All @@ -150,7 +132,7 @@ define([
},

_resizeImage: function() {
console.log(this.id + "._resizeImage");
logger.debug(this.id + "._resizeImage");
var origw, origh, factorw, factorh, factor;
origw = this.imageNode.width;
origh = this.imageNode.height;
Expand All @@ -159,14 +141,14 @@ define([
factorh = this.height / origh;
factor = (factorw < factorh ? factorw : factorh);
if (factor < 1) {//check prevents upscaling
domStyle.add(this.imageNode, 'width', (factor * origw) + 'px');
domStyle.add(this.imageNode, 'height', (factor * origh) + 'px');
domStyle.add(this.imageNode, "width", (factor * origw) + "px");
domStyle.add(this.imageNode, "height", (factor * origh) + "px");
}
}
},

_setToDefaultImage : function() {
console.log(this.id + "._setToDefaultImage");
logger.debug(this.id + "._setToDefaultImage");
if (this.imageNode) {
this.imageNode.onerror = null; //do not catch exceptions when loading default
this.imageNode.src = this.defaultImage;
Expand All @@ -175,7 +157,7 @@ define([

_execClick : function(index) {
if (this._contextObj !== null && this.imageNode) {
if (this.clickmicroflow !== '')
if (this.clickmicroflow !== "")
{
mx.data.action({
params : {
Expand All @@ -190,10 +172,10 @@ define([
}
});
}
if (this.linkattr !== '')
if (this.linkattr !== "")
{
var url = this._contextObj.get(this.linkattr);
if (url !== '' && url !== undefined && url !== null) {
if (url !== "" && url !== undefined && url !== null) {
window.open(url, this.linktarget);
}
}
Expand All @@ -202,7 +184,7 @@ define([

// Reset subscriptions.
_resetSubscriptions: function () {
console.log(this.id + "._resetSubscriptions");
logger.debug(this.id + "._resetSubscriptions");
var _objectHandle = null;

// Release handles on previous object, if any.
Expand All @@ -213,7 +195,7 @@ define([
this._handles = [];
}

// When a mendix object exists create subscribtions.
// When a mendix object exists create subscribtions.
if (this._contextObj) {
_objectHandle = this.subscribe({
guid: this._contextObj.getGuid(),
Expand All @@ -228,4 +210,4 @@ define([
});
require(["DynamicImage/widget/MobileDynamicImage"], function () {
"use strict";
});
});
Loading

0 comments on commit a252de0

Please sign in to comment.