On Github ValeriiVasin / moscowjs2013
$.widget('lj.colorpicker, $.lj.basicWidget, { options: { selectors: { button: ‘.b-colorpicker-button’ } } }, _create: function() { $.lj.basicWidget.prototype._create.apply(this); }, _bindControls: function() { this._el(‘button’).click(this._clickHandler.bind(this)); }, /* ... */ });
<div data-widget="colorpicker" data-widget-options="{...}"></div>
LJ::need_res(qw{ lib1.js lib2.js widget1.js widget2.js style1.css style2.css }); # => <script src="/??lib1.js,lib2.js,widget1.js,widget2.js"... # => <link href="/??style1.css,style2.css"... LJ::need_string(qw{ colorpicker.button.save }); # => Site.page.ml['colorpicker.button.save']
# Config colorpicker => { js => [ 'js/color.js', 'js/jquery/jquery.lj.colorpicker.js' ], css => [ 'stc/popup/popupus.css' ], templates => ['templates/Widgets/colorpicker.tmpl'], ml => [ 'colorpicker.title.new' ] } # Controller LJ::need_res_group('colorpicker')
//= require js/core/string.js //= require js/core/object.js ;(function () { 'use strict'; /** Module implementation */ }());
/* popup.js */ //= require_template core/popup.html
Site.page.templates['core/popup.html'] = '<div class="b-popup"><!-- ... --></div>';
Site.page.templates[...] => $templateCache
//= require js/lib/angular.min.js //= require js/core/angular/common.js //= require_template angular/controlstrip/friend.ng.tmpl //= require_template angular/controlstrip/join.ng.tmpl // add templates module as a dependency angular.module('Controlstrip', ['LJ.Templates']);
//= require js/core/angular/common.js //= require_template angular/controlstrip/friend.ng.tmpl // add directives module as a dependency angular.module('Controlstrip', ['LJ.Directives']);
<!-- friend.ng.tmpl --> <span lj-ml="users.filters.link.addingroup"></span> <input lj-ml="users.filters.link.addingroup" lj-ml-attr="placeholder">