Commit ede03010 authored by Artem Iksanov's avatar Artem Iksanov
Browse files

Initial commit

parents
No related merge requests found
Showing with 273 additions and 0 deletions
+273 -0
.gitignore 0 → 100644
## Packages
#-------------------------
node_modules
## Trash
#-------------------------
desktop.ini
.DS_Store
.DS_Store?
.Trashes
# IDE Files
#-------------------------
/nbproject
/.idea
## Sublime Text cache files
#-------------------------
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
*.sublime-workspace
*.sublime-project
\ No newline at end of file
LICENSE 0 → 100644
MIT License
Copyright (c) 2019 Meiji
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
'use strict';
const gulp = require('gulp');
const fs = require('fs');
const plumber = require('gulp-plumber');
const sourcemaps = require('gulp-sourcemaps');
gulp.distPath = 'dist/';
gulp.task('build', function () {
var concat = require('gulp-concat'),
minify = require('gulp-minify');
var core = [
'node_modules/underscore/underscore.js',
'node_modules/underscore.string/dist/underscore.string.min.js',
'node_modules/js-cookie/src/js.cookie.js',
'node_modules/jquery/dist/jquery.js',
'node_modules/urijs/src/URI.min.js',
'node_modules/jquery-migrate/dist/jquery-migrate.min.js',
'node_modules/inputmask/dist/min/jquery.inputmask.bundle.min.js',
'node_modules/inputmask/dist/min/inputmask/phone-codes/phone.min.js',
'node_modules/inputmask/dist/min/inputmask/phone-codes/phone-ru.min.js',
'node_modules/parsleyjs/dist/parsley.min.js',
'node_modules/jquery-form/dist/jquery.form.min.js',
'node_modules/backbone/backbone.js',
'src/javascript/core/app.js',
'src/javascript/core/extension/**/*.js',
'src/javascript/core/superstructure/**/*.js'
];
gulp.src(core)
.pipe(sourcemaps.init({largeFile: true}))
.pipe(plumber())
.pipe(concat('basis.js'))
.pipe(gulp.dest(gulp.distPath))
.pipe(minify({
noSource: true,
ext: {
min: '.min.js'
}
}))
.pipe(sourcemaps.write('/'))
.pipe(gulp.dest(gulp.distPath + '/min'));
});
gulp.task('default', ['build']);
This diff is collapsed.
{
"name": "meiji-basis-js",
"version": "2.2.3",
"description": "Extendable front-end application",
"author": "Artem Iksanov",
"license": "MIT",
"dependencies": {
"backbone": "^1.3.3",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.1",
"gulp-minify": "^3.1.0",
"gulp-rename": "^1.4.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-plumber": "^1.2.1",
"inputmask": "^3.3.0",
"jquery": "^3.3.1",
"jquery-form": "^4.2.0",
"jquery-migrate": "~3.0.1",
"js-cookie": "^2.2.0",
"parsleyjs": "^2.8.0",
"underscore": "^1.9.1",
"underscore.string": "~3.2.1",
"urijs": "~1.19.1"
}
}
src/app.js 0 → 100644
var Basis = _.create(Object.prototype, {
Views: _.create(Object.prototype, {}),
Plugins: _.create(Object.prototype, {}),
Control: {
instance: function (options) {
Backbone.View.call(this, options);
},
Delayed: {},
install: function (options) {
Backbone.$(function () {
var pluginName = options.name;
if (!_.isEmpty(Basis.Plugins[pluginName])) {
console.error('Basis error: "' + pluginName + '" plugin is already define.');
}
Basis.Plugins[pluginName] = options;
if (!_.isEmpty(Basis.Control.Delayed[pluginName])) {
_.each(Basis.Control.Delayed[pluginName], function (options, index) {
Basis.Control.extend(pluginName, options);
Basis.Control.Delayed[pluginName].splice(index, 1);
});
}
if (!Backbone.$(options.el).length) {
return false;
}
Basis.Views[pluginName] = [];
var objArr = [];
Backbone.$(options.el).each(function () {
objArr.push(Basis.Control.construct(Backbone.$(this), options));
});
Basis.Views[pluginName] = objArr;
return Basis.Views[pluginName];
});
},
construct: function ($el, options) {
var vOpts = _.extend(_.clone(options), {el: $el});
var CBasisViewInstance = this.instance.extend(vOpts);
var CBasisView = new CBasisViewInstance;
CBasisView.initializeEx.apply(CBasisView, arguments);
$el.attr('cid', CBasisView.cid);
$el.addClass(options.name + 'Control');
return CBasisView;
},
extend: function (pluginName, options) {
Backbone.$(function () {
if (_.isEmpty(Basis.Plugins[pluginName])) {
Basis.Control.Delayed[pluginName] = Basis.Control.Delayed[pluginName] || [];
Basis.Control.Delayed[pluginName].push(options);
setTimeout(function () {
if (!_.isEmpty(Basis.Control.Delayed[pluginName])) {
_.each(Basis.Control.Delayed[pluginName], function (options) {
console.error('Basis error: can not install "' + options.name + '" plugin. Extendable "' + pluginName + '" plugin is not define.');
});
}
}, 3300);
return;
}
Basis.Control.install(_.extend(_.clone(Basis.Plugins[pluginName]), options));
});
}
}
});
var BasisFx = _.create(Object.prototype);
_.extend(Basis.Control.instance.prototype, Backbone.View.prototype, {
initialize: function () { },
initializeEx: function () { }
});
Basis.Control.instance.extend = Backbone.View.extend;
Backbone.$(function () {
Backbone.$(document).ajaxComplete(function (event, request, settings) {
_.each(Basis.Plugins, function (options) {
Backbone.$(options.el).not('.' + options.name + 'Control').each(function () {
Basis.Views[options.name] = Basis.Views[options.name] || [];
Basis.Views[options.name].push(Basis.Control.construct(Backbone.$(this), options));
});
});
});
});
function numbersOnly(e) {
const charCode = e.which;
// We only want to allow certain special characters and numbers
// for our currency input (0-9, tab, delete, left and right arrow)
if (!e.shiftKey && (charCode === 8 || charCode === 37 || charCode === 39 ||
charCode === 9 || (charCode >= 48 && charCode <= 58) ||
(charCode >= 96 && charCode <= 105))
) {
return true;
}
e.preventDefault();
return false;
}
\ No newline at end of file
if (!_(BasisFx).has('isTouch')) {
BasisFx.isTouch = function () {
return !!(('ontouchstart' in window)
|| navigator.maxTouchPoints
|| (window.DocumentTouch && document instanceof DocumentTouch));
};
}
Parsley.addMessages('ru', {
defaultMessage: 'Некорректное значение.',
type: {
email: 'Введите адрес электронной почты.',
url: 'Введите URL адрес.',
number: 'Введите число.',
integer: 'Введите целое число.',
digits: 'Введите только цифры.',
alphanum: 'Введите буквенно-цифровое значение.'
},
notblank: 'Это поле должно быть заполнено.',
required: 'Обязательное поле.',
pattern: 'Это значение некорректно.',
min: 'Это значение должно быть не менее чем %s.',
max: 'Это значение должно быть не более чем %s.',
range: 'Это значение должно быть от %s до %s.',
minlength: 'Это значение должно содержать не менее %s символов.',
maxlength: 'Это значение должно содержать не более %s символов.',
length: 'Это значение должно содержать от %s до %s символов.',
mincheck: 'Выберите не менее %s значений.',
maxcheck: 'Выберите не более %s значений.',
check: 'Выберите от %s до %s значений.',
equalto: 'Это значение должно совпадать.',
dateiso: 'Это значение должно быть корректной датой (ГГГГ-ММ-ДД).',
minwords: 'Это значение должно содержать не менее %s слов.',
maxwords: 'Это значение должно содержать не более %s слов.',
words: 'Это значение должно содержать от %s до %s слов.',
gt: 'Это значение должно быть больше.',
gte: 'Это значение должно быть больше или равно.',
lt: 'Это значение должно быть меньше.',
lte: 'Это значение должно быть меньше или равно.',
notequalto: 'Это значение должно отличаться.'
});
Parsley.setLocale('ru');
Parsley.addValidator('phone', {
validateString: function (value, option, instance) {
return instance.$element.inputmask('isComplete');
}
});
Parsley.addValidator('mustchecked', {
validateMultiple: function (value, option, instance) {
return instance.$element.prop('checked');
}
});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment