diff --git a/code/modules/client/asset_cache.dm b/code/modules/client/asset_cache.dm index d52f9947193..ea7587327af 100644 --- a/code/modules/client/asset_cache.dm +++ b/code/modules/client/asset_cache.dm @@ -208,6 +208,7 @@ proc/getFilesSlow(var/client/client, var/list/files, var/register_asset = TRUE) var/list/common = list() var/list/common_dirs = list( + "nano/assets/", "nano/css/", "nano/js/", "nano/images/", diff --git a/code/modules/nano/nanoui.dm b/code/modules/nano/nanoui.dm index dea02f984f7..739077b6a43 100644 --- a/code/modules/nano/nanoui.dm +++ b/code/modules/nano/nanoui.dm @@ -106,13 +106,7 @@ nanoui is used to open and update nano browser uis */ /datum/nanoui/proc/add_common_assets() add_script("libraries.min.js") // A JS file comprising of jQuery, doT.js and jQuery Timer libraries (compressed together) - add_script("nano_utility.js") // The NanoUtility JS, this is used to store utility functions. - add_script("nano_template.js") // The NanoTemplate JS, this is used to render templates. - add_script("nano_state_manager.js") // The NanoStateManager JS, it handles updates from the server and passes data to the current state - add_script("nano_state.js") // The NanoState JS, this is the base state which all states must inherit from - add_script("nano_state_default.js") // The NanoStateDefault JS, this is the "default" state (used by all UIs by default), which inherits from NanoState - add_script("nano_base_callbacks.js") // The NanoBaseCallbacks JS, this is used to set up (before and after update) callbacks which are common to all UIs - add_script("nano_base_helpers.js") // The NanoBaseHelpers JS, this is used to set up template helpers which are common to all UIs + add_script("nano.js") // A JS file of the NanoUI JavaScript concatenated into one file. add_stylesheet("shared.css") // this CSS sheet is common to all UIs add_stylesheet("icons.css") // this CSS sheet is common to all UIs diff --git a/nano/.gitignore b/nano/.gitignore new file mode 100644 index 00000000000..68b9e27759d --- /dev/null +++ b/nano/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +bower_components/ diff --git a/nano/Gulpfile.coffee b/nano/Gulpfile.coffee new file mode 100644 index 00000000000..d414457a46d --- /dev/null +++ b/nano/Gulpfile.coffee @@ -0,0 +1,48 @@ +### Settings ### +util = require("gulp-util") +s = + min: util.env.min + +# Project Paths +input = + scripts: + lib: "scripts/libraries" + main: "scripts/nano" + +output = + dir: "assets" + scripts: + lib: "libraries.min.js" + main: "nano.js" + +### Pacakages ### +del = require "del" +gulp = require "gulp" +merge = require "merge-stream" + +### Plugins ### +g = require("gulp-load-plugins")({replaceString: /^gulp(-|\.)|-/g}) + +### Helpers ### + +glob = (path) -> + "#{path}/*" + +### Tasks ### +gulp.task "default", ["scripts"] + +gulp.task "clean", -> + del glob output.dir + +gulp.task "scripts", ["clean"], -> + lib = gulp.src glob input.scripts.lib + .pipe g.concat(output.scripts.lib) + .pipe g.uglify().on('error', util.log) + .pipe gulp.dest output.dir + + main = gulp.src glob input.scripts.main + .pipe g.concat(output.scripts.main) + .pipe g.uglify().on('error', util.log) + .pipe gulp.dest output.dir + + merge lib, main \ No newline at end of file diff --git a/nano/Gulpfile.js b/nano/Gulpfile.js new file mode 100644 index 00000000000..203c68bf5c2 --- /dev/null +++ b/nano/Gulpfile.js @@ -0,0 +1,2 @@ +require('coffee-script/register'); +require('./Gulpfile.coffee'); diff --git a/nano/README.md b/nano/README.md new file mode 100644 index 00000000000..c7687c44fa3 --- /dev/null +++ b/nano/README.md @@ -0,0 +1,66 @@ +# NanoUI + +NanoUI is a user interface library, used for over 100 different interfaces, and rising. +It is + +## Folder Rundown + +### /assets +The assets folder is used by the Gulp compiling system, and stores the minified version of +the NanoUI JavaScript Library and prerequisites. Everything within this folder is sent to +the client as-is. + +### /css +This folder is used for the CSS components of NanoUI. Everything within this folder is +sent to the client as-is. + +### /images +This folder is used to store any image files. It is sent to the client as-is. + +### /js +This folder is for JavaScript which cannot be compiled and put in the assets folder. +Currently, it is only used by the pre-minifed CodeMirror JavaScript. It is sent to the +client as-is. + +### /layouts +This folder is used for the central "layout" template files, which is loaded before the +UI's actual template file. It is sent to the client as-is. + +### /scripts +This folder is used for anything that will be compiled by the Gulp compilation system. +Currently, it is split into two folders. The file names must start with a number, as this +is how Gulp decides what order to put the concatenated and possibly minified files in. +Anything within this folder is not sent to the client directly. + +#### /scripts/libraries +This folder is used to store the source code of the prerequisites of NanoUI. Currently, +it contains jQuery, jQuery UI, jQuery timers, and the doT template system. + +#### /scripts/nano +This folder contains the primary JavaScript for NanoUI. + +### /templates +This folder is used to store the .tmpl files which are later compiled by the NanoUtility +JavaScript, using a modified version of the doT template engine. It is sent to the client +as-is. + +## Compiling +To compile any changes to the NanoUI JavaScript, you must first setup the building +environment. + +### Prerequisites +You will first need to install the primary prerequisite of NanoUI, [Node.js](https://nodejs.org). + +Node.js is used to obtain all of the remaining prerequisites to compile NanoUI. This is +done by running the following two commands. + - `npm install -g gulp` + - `npm install` + +### Running Gulp +NanoUI is built using the `gulp` task automation system. This system uses the contents +of the `Gulpfile.js` and `Gulpfile.coffee` files to perform compilation tasks. + +In order to build an un-minified version of NanoUI, you may simply run `gulp` in the +`nanoui` directory. However, this should only be used while testing, and you should run +the command `gulp --min` before commiting changes, in order to produce minified +JavaScript. diff --git a/nano/assets/libraries.min.js b/nano/assets/libraries.min.js new file mode 100644 index 00000000000..a7a9d42ff80 --- /dev/null +++ b/nano/assets/libraries.min.js @@ -0,0 +1,5 @@ +!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t="length"in e&&e.length,n=oe.type(e);return"function"===n||oe.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e}function i(e,t,n){if(oe.isFunction(t))return oe.grep(e,function(e,i){return!!t.call(e,i,e)!==n});if(t.nodeType)return oe.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(de.test(t))return oe.filter(t,e,n);t=oe.filter(t,e)}return oe.grep(e,function(e){return oe.inArray(e,t)>=0!==n})}function o(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function r(e){var t=xe[e]={};return oe.each(e.match(be)||[],function(e,n){t[n]=!0}),t}function s(){he.addEventListener?(he.removeEventListener("DOMContentLoaded",a,!1),e.removeEventListener("load",a,!1)):(he.detachEvent("onreadystatechange",a),e.detachEvent("onload",a))}function a(){(he.addEventListener||"load"===event.type||"complete"===he.readyState)&&(s(),oe.ready())}function l(e,t,n){if(void 0===n&&1===e.nodeType){var i="data-"+t.replace(Ne,"-$1").toLowerCase();if(n=e.getAttribute(i),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:Ce.test(n)?oe.parseJSON(n):n}catch(o){}oe.data(e,t,n)}else n=void 0}return n}function u(e){var t;for(t in e)if(("data"!==t||!oe.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,i){if(oe.acceptData(e)){var o,r,s=oe.expando,a=e.nodeType,l=a?oe.cache:e,u=a?e[s]:e[s]&&s;if(u&&l[u]&&(i||l[u].data)||void 0!==n||"string"!=typeof t)return u||(u=a?e[s]=Q.pop()||oe.guid++:s),l[u]||(l[u]=a?{}:{toJSON:oe.noop}),("object"==typeof t||"function"==typeof t)&&(i?l[u]=oe.extend(l[u],t):l[u].data=oe.extend(l[u].data,t)),r=l[u],i||(r.data||(r.data={}),r=r.data),void 0!==n&&(r[oe.camelCase(t)]=n),"string"==typeof t?(o=r[t],null==o&&(o=r[oe.camelCase(t)])):o=r,o}}function f(e,t,n){if(oe.acceptData(e)){var i,o,r=e.nodeType,s=r?oe.cache:e,a=r?e[oe.expando]:oe.expando;if(s[a]){if(t&&(i=n?s[a]:s[a].data)){oe.isArray(t)?t=t.concat(oe.map(t,oe.camelCase)):t in i?t=[t]:(t=oe.camelCase(t),t=t in i?[t]:t.split(" ")),o=t.length;for(;o--;)delete i[t[o]];if(n?!u(i):!oe.isEmptyObject(i))return}(n||(delete s[a].data,u(s[a])))&&(r?oe.cleanData([e],!0):ne.deleteExpando||s!=s.window?delete s[a]:s[a]=null)}}}function d(){return!0}function p(){return!1}function h(){try{return he.activeElement}catch(e){}}function g(e){var t=We.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function m(e,t){var n,i,o=0,r=typeof e.getElementsByTagName!==_e?e.getElementsByTagName(t||"*"):typeof e.querySelectorAll!==_e?e.querySelectorAll(t||"*"):void 0;if(!r)for(r=[],n=e.childNodes||e;null!=(i=n[o]);o++)!t||oe.nodeName(i,t)?r.push(i):oe.merge(r,m(i,t));return void 0===t||t&&oe.nodeName(e,t)?oe.merge([e],r):r}function v(e){Pe.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t){return oe.nodeName(e,"table")&&oe.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function b(e){return e.type=(null!==oe.find.attr(e,"type"))+"/"+e.type,e}function x(e){var t=Ye.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function w(e,t){for(var n,i=0;null!=(n=e[i]);i++)oe._data(n,"globalEval",!t||oe._data(t[i],"globalEval"))}function T(e,t){if(1===t.nodeType&&oe.hasData(e)){var n,i,o,r=oe._data(e),s=oe._data(t,r),a=r.events;if(a){delete s.handle,s.events={};for(n in a)for(i=0,o=a[n].length;o>i;i++)oe.event.add(t,n,a[n][i])}s.data&&(s.data=oe.extend({},s.data))}}function _(e,t){var n,i,o;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!ne.noCloneEvent&&t[oe.expando]){o=oe._data(t);for(i in o.events)oe.removeEvent(t,i,o.handle);t.removeAttribute(oe.expando)}"script"===n&&t.text!==e.text?(b(t).text=e.text,x(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),ne.html5Clone&&e.innerHTML&&!oe.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Pe.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function C(t,n){var i,o=oe(n.createElement(t)).appendTo(n.body),r=e.getDefaultComputedStyle&&(i=e.getDefaultComputedStyle(o[0]))?i.display:oe.css(o[0],"display");return o.detach(),r}function N(e){var t=he,n=Ze[e];return n||(n=C(e,t),"none"!==n&&n||(Je=(Je||oe("