Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added StyleSheetSwitcher.mpk
Binary file not shown.
20 changes: 15 additions & 5 deletions src/StyleSheetSwitcher/StyleSheetSwitcherURL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
<category>Behavior</category>
<description>The folder containing the stylesheets (such as: /custom/style/css). A trailing slash is added automatically</description>
</property>
<property key="cssDefault" type="string" required="true" defaultValue="">
<property key="cssDefault" type="microflow" required="true" defaultValue="" entityProperty="urlEntity">
<caption>Default css</caption>
<category>Behavior</category>
<description>The default CSS stylesheet (such as: default.css).</description>
<description>The the default styleshete URLs will be saved (such as: default.css,custom.css).</description>
<returnType type="String" />
</property>

<property key="removeDefault" type="boolean" required="true" defaultValue="true">
<property key="removeDefault" type="boolean" required="true" defaultValue="true">
<caption>Remove default css</caption>
<category>Behavior</category>
<description>Remove the default css when loading a new one (if the custom stylesheet is equal to the default stylesheet it will not be removed from the DOM).</description>
Expand All @@ -43,10 +43,20 @@
<property key="mfToExecute" type="microflow" required="true" defaultValue="" entityProperty="urlEntity">
<caption>Microflow</caption>
<category>Behavior</category>
<description>The microflow to execute in order to find a different stylesheet. Expects URL entity, returns filename.</description>
<description>The microflow to execute in order to find a different stylesheet. Expects URL entity, returns filenames.</description>
<returnType type="String" />
</property>

<property key="CustomCssReload" type="enumeration" required="true" defaultValue="after">
<caption>Delete and reload custom.css</caption>
<category>Behavior</category>
<description></description>
<enumerationValues>
<enumerationValue key="not">No reload</enumerationValue>
<enumerationValue key="after">Reload after change default theme</enumerationValue>
</enumerationValues>
</property>

<property key="mxuiBehavior" type="enumeration" required="true" defaultValue="after">
<caption>Reload mxui.css</caption>
<category>Behavior</category>
Expand Down
38 changes: 37 additions & 1 deletion src/StyleSheetSwitcher/widget/StyleSheetSwitcherURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ define([
this._urlObj = obj;
this._urlObj.set(this.urlAttribute, mx.appUrl);
this._executeMF();
this._cssDefault();
})
});

Expand Down Expand Up @@ -140,6 +141,30 @@ define([
}
},

_cssDefault: function () {
// If a microflow has been set execute the microflow on a click.
logger.debug(this.id + "App URL: " + mx.appUrl);

if (this._cssDefault !== "") {
logger.debug(this.id + " - object: " + this._urlObj.getGuid());

mx.data.action({
params: {
actionname: this.cssDefault,
applyto: "selection",
guids: [this._urlObj.getGuid()]

},
callback: dojoLang.hitch(this, function (resultString) {
this.cssDefault = resultString;
this._updateRendering();
}),
error: dojoLang.hitch(this, function (error) {
logger.info(this.id + ": An error occurred while executing microflow: " + error.description);
})
}, this);
}
},

// Attach events to HTML dom elements
_setupEvents: function () {
Expand Down Expand Up @@ -184,9 +209,13 @@ define([

}

if (this.CustomCssReload === "after") {
logger.debug(this.id + " - Removing path: styles/css/custom/custom.css");
dom.removeCss("styles/css/custom/custom.css");

}


//dom.removeCss(cssPath);
logger.debug(this.id + " - Adding path: " + cssPath);
dom.addCss( cssPath );

Expand All @@ -202,10 +231,17 @@ define([
dom.addCss("mxclientsystem/mxui/ui/mxui.css");
}

if (this.CustomCssReload === "after") {
logger.debug(this.id + " - Removing path: styles/css/custom/custom.css");
dom.addCss("styles/css/custom/custom.css");

}

}
else{
logger.info(this.id + " - Invalid path: " + cssPath);
}

},

// Handle validations.
Expand Down