Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is structure we use in our Backbone projects</p> <pre><code>&lt;!-- Libs Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/jquery-1.5.2.min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/jquery.validate.min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/jquery.maskedinput-1.3.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/jquery.mousewheel.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/jquery.scrollpane.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/fileuploader.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/modernizr.min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/json2.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/underscore-min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/libs/backbone-min.js")"&gt;&lt;/script&gt; &lt;!-- Libs Section --&gt; &lt;!-- Core Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/config.js")"&gt;&lt;/script&gt; &lt;!-- Global configs --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/core.js")"&gt;&lt;/script&gt; &lt;!-- Core methods for easier working with views, models and collections + additional useful utils --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/app.js")"&gt;&lt;/script&gt; &lt;!-- Application object inherites core.js as prototype --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/renisans.js")"&gt;&lt;/script&gt; &lt;!-- Project Object. Creates Namespace and Extends it with project specific methods --&gt; &lt;!-- Core Section --&gt; &lt;!-- Routers Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/routers/workspace.js")"&gt;&lt;/script&gt; &lt;!-- Routers Section --&gt; &lt;!-- Models Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/models/profile.js")"&gt;&lt;/script&gt; ... &lt;!-- Models Section --&gt; &lt;!-- Collections Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/collections/messages.js")"&gt;&lt;/script&gt; ... &lt;!-- Collections Section --&gt; &lt;!-- Views Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/views/workspace.js")"&gt;&lt;/script&gt; ... &lt;!-- Views Section --&gt; &lt;!-- Localization Section --&gt; &lt;script type="text/javascript" src="@Url.Content("~/Content/static/js/localizations/ru_RU.js")"&gt;&lt;/script&gt; &lt;!-- Localization Section --&gt; &lt;!-- Init Section --&gt; &lt;script type="text/javascript"&gt; $(function() { Rens.container = $('.l-wrapper'); // Some parameters Rens.init({ Localization: LocalizationStrings || {}, // Object with localization strings Profile: { // Bootstraping initial data to Profile model } }); }); &lt;/script&gt; &lt;!-- Init Section --&gt; </code></pre> <p>content of app.js</p> <pre><code>var App = function() { this.Views = {}; this.Routers = {}; this.Models = {}; this.Collections = {}; this.User = {}; this.router = null; this.view = null; this.baseLocation = null; this.beforeInit = function() {}; this.afterInit = function() {}; this.init = function(initData) { if (typeof(this.beforeInit) === 'function') { this.beforeInit.apply(this, arguments); } if (this.Views.Workspace) { this.view = new this.Views.Workspace(); } this.baseLocation = window.location.href.replace(/[?#].*/, '') == Config.web.host; if (this.Routers.Workspace) { this.router = new this.Routers.Workspace(initData); } this.view &amp;&amp; this.view.setListeners &amp;&amp; this.view.setListeners(); Backbone.history.start(); if (typeof(this.afterInit) === 'function') { this.afterInit.apply(this, arguments); } }.bind(this); }; App.prototype = Core; </code></pre> <p>and content of renisans.js</p> <pre><code>var Rens = new App(); $.extend(Rens, { container: null, Error: function(data) { // Handling error }, Localization: function(dictionary) { return { get: function(name) { var argumentsList = Array.prototype.slice.call(arguments), strings = argumentsList.slice(1), text = this[name]; if (text &amp;&amp; strings.length) { $(strings).each(function(i, string) { var reg = new RegExp('\\$' + i, 'go'); text = text.replace(reg, string); }); } return text || 'SLB.Localization.' + name + ' not found!'; }.bind(dictionary) } }, formatDate: function(rawDate) { var timestamp = /\d+/.exec(rawDate)[0], date = Rens.DateUTC(timestamp), months = Rens.Localization.get('months'); return { date: date, fullDate: [date.dd, months[date.mm], date.hh].join(' '), shortDate: [date.dd, date.MM, date.hh].join('.') }; }, beforeInit: function(initData) { this.Localization = new this.Localization(initData.Localization); } }); </code></pre> <p>also simplified content of models/profile.js</p> <pre><code>Rens.Models.Profile = Backbone.Model.extend({ ... }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload