mail/js
Christoph Wurst 1917a0b0ac
Merge pull request #565 from nextcloud/refactor/navigation-css-guidelines
Clean up navigation views
2017-10-30 16:54:32 +01:00
..
controller Update Doc Comments 2017-10-04 08:54:13 +07:00
models Cleanup address handling 2017-10-23 09:28:51 +02:00
service Add /api prefix to API routes 2017-10-09 08:55:54 +02:00
templatehelpers Cleanup address handling 2017-10-23 09:28:51 +02:00
templates Merge pull request #565 from nextcloud/refactor/navigation-css-guidelines 2017-10-30 16:54:32 +01:00
tests Cleanup address handling 2017-10-23 09:28:51 +02:00
util Cleanup address handling 2017-10-23 09:28:51 +02:00
views Merge pull request #565 from nextcloud/refactor/navigation-css-guidelines 2017-10-30 16:54:32 +01:00
OC.js add license header script and update php+js license headers 2016-08-04 15:45:00 +02:00
README.md fix nc branding 2016-08-29 14:47:22 +02:00
app.js Enhance loading view working 2017-09-18 11:06:06 +02:00
autoredirect.js JSCS for autoredirect & background 2015-08-30 12:13:34 +02:00
cache.js WIP Move to Webpack3 (#468) 2017-08-27 17:08:05 +02:00
init.js correct writing style 2016-09-28 14:32:57 +02:00
jquery.js add license header script and update php+js license headers 2016-08-04 15:45:00 +02:00
radio.js Sync inboxes in the background 2017-08-23 11:51:53 +02:00
replybuilder.js Cleanup address handling 2017-10-23 09:28:51 +02:00
routecontroller.js Fix mailto routing 2017-08-23 16:03:09 +02:00
router.js WIP Move to Webpack3 (#468) 2017-08-27 17:08:05 +02:00
search.js Merge pull request #1609 from owncloud/search-rework 2016-08-05 17:49:20 +02:00
searchproxy.js add license header script and update php+js license headers 2016-08-04 15:45:00 +02:00
state.js remove client-side message list cache 2016-09-28 10:39:14 +02:00
webpack.config.js WIP Move to Webpack3 (#468) 2017-08-27 17:08:05 +02:00

README.md

JavaScript Development

All source files are stored inside this directory or subdirectories of it. With the help of requirejs any .js and .html template file is loaded into the browser asynchronously if needed. Make sure you have debug mode enabled in your development setup because this loads source files instead of the compressed one.

Optimizing file loading for production use

While it's convenient to be able to change any source file and see those changes on the next page load, it takes some time to load 50+ files right after the browser has loaded the page. Fortunately, requirejs has an optimizer which can be easily executed with the Makefile in the root of this repository. Simply run

make optimize-js

inside the project's root directory. This combines and compresses all used JavaScript source files and HTML template files into one file: js/mail.min.js. If debug mode is disabled, this compressed file is then used.

Coding guidelines

Generally, any code contributed to this repository should comply with the general Nextcloud coding style guidelines.

Currently we use several frameworks and their extensions. Namely, this app is build with jQuery, Underscore.js, Backbone.js and Backbone Marionette. Additionally, Require.js is used for loading module dependencies (code and template).

The client-side software is structured as Model-View-Controller application.

Modules

Since Require.js is used for loading module dependencies, all code (Model, View, Controller, Service, Templates) are structured as modules. A typical module looks like this:

define(function(require) {
  'use strict';
  
  // get any other dependencies
  var Backbone = require('backbone');
  
  // create module here
  var MessageFlag = Backbone.Model.extend{
    defaults: {
      name: '',
      value: false
    },
    doSomethingUseful: function(param1) {
      // Something useful
    }
  };
  
  // return the module
  return MessageFlag;
});

Since this is a model, it would be stored to js/model/messageflag.js. Any other module that depends on that module can require it with require('model/messageflag').

For controllers, services and any other module that is used as singleton, the 'revealing module pattern' is used. There are many tutorials on the internet that explain how it works and what it's advantages are.

Models

All models should be Backbone models. Usually this means you create models by extending Backbone.Model:

define(function(require) {
  'use strict';
  
  return Backbone.Model.extend({
    foo: 13,
    bar: function(input) {
      return input * 2;
    }
  });
});

Views

TODO

Controller

TODO

Templates

TODO