Rewrite Mayan's Javascript suite MayanApp into ECMAScript2015. Remove use is waitForJQuery.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,26 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var app = new App();
|
||||
// Make it globally available. Used by event.links
|
||||
|
||||
var MayanAppClass = MayanApp;
|
||||
|
||||
var partialNavigation = new PartialNavigation({
|
||||
initialURL: initialURL,
|
||||
disabledAnchorClasses: ['disabled'],
|
||||
excludeAnchorClasses: ['fancybox', 'new_window', 'non-ajax'],
|
||||
formBeforeSerializeCallbacks: [App.MultiObjectFormProcess],
|
||||
formBeforeSerializeCallbacks: [MayanApp.MultiObjectFormProcess],
|
||||
});
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
app.setupAutoSubmit();
|
||||
app.setupFullHeightResizing();
|
||||
app.setupItemsSelector();
|
||||
app.setupNavbarCollapse();
|
||||
app.setupNewWindowAnchor();
|
||||
app.setupAJAXperiodicWorkers();
|
||||
partialNavigation.initialize();
|
||||
});
|
||||
|
||||
var afterBaseLoad = function () {
|
||||
MayanImage.intialize();
|
||||
app.doToastrMessages();
|
||||
app.resizeFullHeight();
|
||||
app.setupSelect2();
|
||||
app.setupScrollView();
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
var MayanImage = function (options) {
|
||||
this.element = options.element;
|
||||
this.load();
|
||||
}
|
||||
class MayanImage {
|
||||
constructor (options) {
|
||||
this.element = options.element;
|
||||
this.load();
|
||||
}
|
||||
|
||||
MayanImage.intialize = function () {
|
||||
var app = this;
|
||||
static intialize () {
|
||||
var app = this;
|
||||
|
||||
this.fancybox = $().fancybox({
|
||||
animationDuration : 300,
|
||||
buttons : [
|
||||
'fullScreen',
|
||||
'close',
|
||||
],
|
||||
selector: 'a.fancybox',
|
||||
afterShow: function (instance, current) {
|
||||
$('a.a-caption').on('click', function(event) {
|
||||
instance.close(true);
|
||||
});
|
||||
},
|
||||
infobar: true,
|
||||
this.fancybox = $().fancybox({
|
||||
animationDuration : 300,
|
||||
buttons : [
|
||||
'fullScreen',
|
||||
'close',
|
||||
],
|
||||
selector: 'a.fancybox',
|
||||
afterShow: function (instance, current) {
|
||||
$('a.a-caption').on('click', function(event) {
|
||||
instance.close(true);
|
||||
});
|
||||
},
|
||||
infobar: true,
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('img.lazy-load').lazyload({
|
||||
appear: function(elements_left, settings) {
|
||||
new MayanImage({element: $(this)});
|
||||
},
|
||||
threshold: 400,
|
||||
});
|
||||
$('img.lazy-load').lazyload({
|
||||
appear: function(elements_left, settings) {
|
||||
new MayanImage({element: $(this)});
|
||||
},
|
||||
threshold: 400,
|
||||
});
|
||||
|
||||
$('img.lazy-load-carousel').lazyload({
|
||||
appear: function(elements_left, settings) {
|
||||
new MayanImage({element: $(this)});
|
||||
},
|
||||
container: $('#carousel-container'),
|
||||
threshold: 2000,
|
||||
});
|
||||
$('img.lazy-load-carousel').lazyload({
|
||||
appear: function(elements_left, settings) {
|
||||
new MayanImage({element: $(this)});
|
||||
},
|
||||
container: $('#carousel-container'),
|
||||
threshold: 2000,
|
||||
});
|
||||
|
||||
$('.lazy-load').on('load', function() {
|
||||
$(this).hide();
|
||||
$(this).fadeIn(300);
|
||||
$(this).siblings('.spinner-container').remove();
|
||||
$(this).removeClass('lazy-load pull-left');
|
||||
});
|
||||
$('.lazy-load').on('load', function() {
|
||||
$(this).hide();
|
||||
$(this).fadeIn(300);
|
||||
$(this).siblings('.spinner-container').remove();
|
||||
$(this).removeClass('lazy-load pull-left');
|
||||
});
|
||||
|
||||
$('.lazy-load-carousel').on('load', function() {
|
||||
$(this).hide();
|
||||
$(this).fadeIn(300);
|
||||
$(this).siblings('.spinner-container').remove();
|
||||
$(this).removeClass('lazy-load-carousel pull-left');
|
||||
});
|
||||
$('.lazy-load-carousel').on('load', function() {
|
||||
$(this).hide();
|
||||
$(this).fadeIn(300);
|
||||
$(this).siblings('.spinner-container').remove();
|
||||
$(this).removeClass('lazy-load-carousel pull-left');
|
||||
});
|
||||
}
|
||||
|
||||
static timerFunction () {
|
||||
$.fn.matchHeight._maintainScroll = true;
|
||||
$.fn.matchHeight._update();
|
||||
}
|
||||
|
||||
load () {
|
||||
var self = this;
|
||||
var container = this.element.parent().parent().parent();
|
||||
|
||||
this.element.on('error', (function(event) {
|
||||
container.html(MayanImage.templateInvalidDocument);
|
||||
}));
|
||||
|
||||
this.element.attr('src', this.element.attr('data-url'));
|
||||
$.fn.matchHeight._maintainScroll = true;
|
||||
|
||||
clearTimeout(MayanImage.timer);
|
||||
MayanImage.timer = setTimeout(MayanImage.timerFunction, 100);
|
||||
};
|
||||
}
|
||||
|
||||
MayanImage.templateInvalidDocument = $('#template-invalid-document').html();
|
||||
|
||||
MayanImage.timer = setTimeout(null);
|
||||
|
||||
MayanImage.timerFunction = function () {
|
||||
$.fn.matchHeight._maintainScroll = true;
|
||||
$.fn.matchHeight._update();
|
||||
}
|
||||
|
||||
MayanImage.prototype.load = function () {
|
||||
var self = this;
|
||||
var container = this.element.parent().parent().parent();
|
||||
|
||||
this.element.on('error', (function(event) {
|
||||
container.html(MayanImage.templateInvalidDocument);
|
||||
}));
|
||||
|
||||
this.element.attr('src', this.element.attr('data-url'));
|
||||
$.fn.matchHeight._maintainScroll = true;
|
||||
|
||||
clearTimeout(MayanImage.timer);
|
||||
MayanImage.timer = setTimeout(MayanImage.timerFunction, 100);
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user