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:
+2
-1
@@ -25,7 +25,8 @@
|
|||||||
- Include querystring when force reload of a bare template view.
|
- Include querystring when force reload of a bare template view.
|
||||||
- Speed up document image fade in reveal.
|
- Speed up document image fade in reveal.
|
||||||
- Use reseteable timer to ensure more document panels heights are matched.
|
- Use reseteable timer to ensure more document panels heights are matched.
|
||||||
|
- Rewrote Mayan's Javascript suite MayanApp into ECMAScript2015.
|
||||||
|
- Remove use is waitForJQuery.
|
||||||
|
|
||||||
3.0.1 (2018-07-08)
|
3.0.1 (2018-07-08)
|
||||||
=================
|
=================
|
||||||
|
|||||||
@@ -1,26 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var app = new App();
|
// Make it globally available. Used by event.links
|
||||||
|
|
||||||
|
var MayanAppClass = MayanApp;
|
||||||
|
|
||||||
var partialNavigation = new PartialNavigation({
|
var partialNavigation = new PartialNavigation({
|
||||||
initialURL: initialURL,
|
initialURL: initialURL,
|
||||||
|
disabledAnchorClasses: ['disabled'],
|
||||||
excludeAnchorClasses: ['fancybox', 'new_window', 'non-ajax'],
|
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';
|
'use strict';
|
||||||
|
|
||||||
var MayanImage = function (options) {
|
class MayanImage {
|
||||||
this.element = options.element;
|
constructor (options) {
|
||||||
this.load();
|
this.element = options.element;
|
||||||
}
|
this.load();
|
||||||
|
}
|
||||||
|
|
||||||
MayanImage.intialize = function () {
|
static intialize () {
|
||||||
var app = this;
|
var app = this;
|
||||||
|
|
||||||
this.fancybox = $().fancybox({
|
this.fancybox = $().fancybox({
|
||||||
animationDuration : 300,
|
animationDuration : 300,
|
||||||
buttons : [
|
buttons : [
|
||||||
'fullScreen',
|
'fullScreen',
|
||||||
'close',
|
'close',
|
||||||
],
|
],
|
||||||
selector: 'a.fancybox',
|
selector: 'a.fancybox',
|
||||||
afterShow: function (instance, current) {
|
afterShow: function (instance, current) {
|
||||||
$('a.a-caption').on('click', function(event) {
|
$('a.a-caption').on('click', function(event) {
|
||||||
instance.close(true);
|
instance.close(true);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
infobar: true,
|
infobar: true,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$('img.lazy-load').lazyload({
|
$('img.lazy-load').lazyload({
|
||||||
appear: function(elements_left, settings) {
|
appear: function(elements_left, settings) {
|
||||||
new MayanImage({element: $(this)});
|
new MayanImage({element: $(this)});
|
||||||
},
|
},
|
||||||
threshold: 400,
|
threshold: 400,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('img.lazy-load-carousel').lazyload({
|
$('img.lazy-load-carousel').lazyload({
|
||||||
appear: function(elements_left, settings) {
|
appear: function(elements_left, settings) {
|
||||||
new MayanImage({element: $(this)});
|
new MayanImage({element: $(this)});
|
||||||
},
|
},
|
||||||
container: $('#carousel-container'),
|
container: $('#carousel-container'),
|
||||||
threshold: 2000,
|
threshold: 2000,
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.lazy-load').on('load', function() {
|
$('.lazy-load').on('load', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$(this).fadeIn(300);
|
$(this).fadeIn(300);
|
||||||
$(this).siblings('.spinner-container').remove();
|
$(this).siblings('.spinner-container').remove();
|
||||||
$(this).removeClass('lazy-load pull-left');
|
$(this).removeClass('lazy-load pull-left');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.lazy-load-carousel').on('load', function() {
|
$('.lazy-load-carousel').on('load', function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$(this).fadeIn(300);
|
$(this).fadeIn(300);
|
||||||
$(this).siblings('.spinner-container').remove();
|
$(this).siblings('.spinner-container').remove();
|
||||||
$(this).removeClass('lazy-load-carousel pull-left');
|
$(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.templateInvalidDocument = $('#template-invalid-document').html();
|
||||||
|
|
||||||
MayanImage.timer = setTimeout(null);
|
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
@@ -31,16 +31,6 @@
|
|||||||
if (currentHash.length) {
|
if (currentHash.length) {
|
||||||
window.location = currentHash.substring(1);
|
window.location = currentHash.substring(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function waitForJQuery(func) {
|
|
||||||
if (window.jQuery) {
|
|
||||||
func();
|
|
||||||
} else {
|
|
||||||
setTimeout(function() {
|
|
||||||
waitForJQuery(func)
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -27,17 +27,6 @@
|
|||||||
<link href="{% static 'appearance/vendors/pace-0.7.8/themes/pace-theme-flash.css' %}" media="screen" rel="stylesheet" type="text/css" />
|
<link href="{% static 'appearance/vendors/pace-0.7.8/themes/pace-theme-flash.css' %}" media="screen" rel="stylesheet" type="text/css" />
|
||||||
<link href="{% static 'appearance/css/base.css' %}" media="screen" rel="stylesheet" type="text/css" />
|
<link href="{% static 'appearance/css/base.css' %}" media="screen" rel="stylesheet" type="text/css" />
|
||||||
{% block stylesheets %}{% endblock %}
|
{% block stylesheets %}{% endblock %}
|
||||||
<script>
|
|
||||||
function waitForJQuery(func) {
|
|
||||||
if (window.jQuery) {
|
|
||||||
func();
|
|
||||||
} else {
|
|
||||||
setTimeout(function() {
|
|
||||||
waitForJQuery(func)
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{% if appearance_type == 'plain' %}
|
{% if appearance_type == 'plain' %}
|
||||||
@@ -152,15 +141,28 @@
|
|||||||
<script src="{% static 'appearance/js/mayan_app.js' %}" type="text/javascript"></script>
|
<script src="{% static 'appearance/js/mayan_app.js' %}" type="text/javascript"></script>
|
||||||
<script src="{% static 'appearance/js/mayan_image.js' %}" type="text/javascript"></script>
|
<script src="{% static 'appearance/js/mayan_image.js' %}" type="text/javascript"></script>
|
||||||
<script src="{% static 'appearance/js/partial_navigation.js' %}" type="text/javascript"></script>
|
<script src="{% static 'appearance/js/partial_navigation.js' %}" type="text/javascript"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
{# Transfer variable from Django to javascript #}
|
{# Transfer variable from Django to javascript #}
|
||||||
var initialURL = '{% url home_view %}';
|
var initialURL = '{% url home_view %}';
|
||||||
var djangoDEBUG = {% if debug %}true{% else %}false{% endif %};
|
var djangoDEBUG = {% if debug %}true{% else %}false{% endif %};
|
||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="{% static 'appearance/js/base.js' %}" type="text/javascript"></script>
|
<script src="{% static 'appearance/js/base.js' %}" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
var app = new MayanApp();
|
||||||
|
|
||||||
|
var afterBaseLoad = function () {
|
||||||
|
MayanImage.intialize();
|
||||||
|
app.doToastrMessages();
|
||||||
|
app.resizeFullHeight();
|
||||||
|
app.setupSelect2();
|
||||||
|
app.setupScrollView();
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery(document).ready(function() {
|
||||||
|
app.initialize();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ link_user_notifications_list = Link(
|
|||||||
html_data={
|
html_data={
|
||||||
'apw-attribute': 'count', 'apw-interval': '5000',
|
'apw-attribute': 'count', 'apw-interval': '5000',
|
||||||
'apw-url': '/api/notifications/?read=False',
|
'apw-url': '/api/notifications/?read=False',
|
||||||
'apw-callback': 'App.mayanNotificationBadge'
|
'apw-callback': 'MayanAppClass.mayanNotificationBadge'
|
||||||
}, icon_class=icon_user_notifications_list, text='',
|
}, icon_class=icon_user_notifications_list, text='',
|
||||||
view='events:user_notifications_list'
|
view='events:user_notifications_list'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
waitForJQuery(function() {
|
jQuery(document).ready(function() {
|
||||||
jQuery(document).ready(function() {
|
$('.metadata-value').on('input', function(event) {
|
||||||
$('.metadata-value').on('input', function(event) {
|
// Check the checkbox next to a metadata value input when there is
|
||||||
// Check the checkbox next to a metadata value input when there is
|
// data entry in the value's input.
|
||||||
// data entry in the value's input.
|
$(event.target).parents('tr').find(':checkbox').prop('checked', true);
|
||||||
$(event.target).parents('tr').find(':checkbox').prop('checked', true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user