Skip to content

Commit 0f46728

Browse files
author
Leonix
committed
Photos v.2.1.0:
* User interface mode 2.0: numerous visual improvements on single photo viewing and photos listing pages. * Bug fixes.
1 parent 6dc3971 commit 0f46728

File tree

27 files changed

+1992
-1980
lines changed

27 files changed

+1992
-1980
lines changed

wa-apps/photos/css/photos.css

Lines changed: 780 additions & 1 deletion
Large diffs are not rendered by default.

wa-apps/photos/js/common.js

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ var PhotoStream = (function() {
195195
var photo = this.getById(before_id);
196196
place = photo ? photo.index : 0;
197197
}
198-
198+
199199
Array.prototype.splice.apply(photo_stream, [place, 0].concat(photos));
200200
// clear spaces ('undefined' after delete operator) and reindex
201201
this.clear();
@@ -235,46 +235,73 @@ Date.parseISO = function (string) {
235235

236236
/**
237237
* Replace old src with new src in img tag with or not preloading. Also taking into account competition problem
238-
*
238+
*
239239
* @param jquery object img
240240
* @param string new_src
241-
* @param mixed fn. Optinality.
242-
* If parameter is null than just change src (without preloading).
241+
* @param mixed fn. Optinality.
242+
* If parameter is null than just change src (without preloading).
243243
* If fn is function than it is callback after src changed (with preloading)
244244
* If omitted (undefined) - with preloading
245-
* @param string namespace. Optionality.
246-
* Need for solving competition problem. Render only image of last calling of this namespace.
247-
* If omitted try to use id of tag or generate random namespace
245+
* @param string namespace. Optionality.
246+
* Need for solving competition problem. Render only image of last calling of this namespace.
247+
* If omitted try to use id of tag or generate random namespace
248248
*/
249249
function replaceImg (img, new_src, fn, namespace) {
250250
namespace = namespace || img.attr('id') || ('' + Math.random()).slice(2);
251251
replaceImg.loading_map = replaceImg.loading_map || {};
252252
replaceImg.loading_map[namespace] = new_src;
253253
img.unbind('load');
254254
if (fn === null) {
255+
if (img.smallSize) {
256+
img.attr({
257+
src: new_src,
258+
srcset: ''
259+
});
260+
261+
return;
262+
}
263+
255264
img.attr({
256265
src: new_src,
257-
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + '2x' : ""}`
266+
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + ' 2x' : ""}`
258267
});
259268
} else {
260-
$('<img>').attr({
261-
src: new_src,
262-
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + '2x' : ""}`
263-
}).load(function() {
264-
// setTimeout need for fix FF "blink" problem with image rendering
265-
setTimeout(function() {
269+
if (img.smallSize) {
270+
$('<img>').attr({
271+
src: new_src,
272+
srcset: ''
273+
}).load(function() {
266274
// render img only of last calling of function for this namespace
267275
if (replaceImg.loading_map[namespace] == new_src) {
268276
img.attr({
269277
src: new_src,
270-
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + '2x' : ""}`
278+
srcset: ''
271279
});
272280
if (typeof fn == 'function') {
273281
fn.call(img);
274282
}
275283
}
276284
$(this).remove();
277-
}, 100);
285+
});
286+
287+
return;
288+
}
289+
290+
$('<img>').attr({
291+
src: new_src,
292+
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + ' 2x' : ""}`
293+
}).load(function() {
294+
// render img only of last calling of function for this namespace
295+
if (replaceImg.loading_map[namespace] == new_src) {
296+
img.attr({
297+
src: new_src,
298+
srcset: `${img.proper_thumb ? img.proper_thumb.url + ' 1x, ' + img.proper_thumb.url2x + ' 2x' : ""}`
299+
});
300+
if (typeof fn == 'function') {
301+
fn.call(img);
302+
}
303+
}
304+
$(this).remove();
278305
});
279306
}
280307
return namespace;
@@ -398,4 +425,4 @@ function getRealSizesOfThumb(photo, size)
398425
width: w,
399426
height: h
400427
};
401-
}
428+
}

wa-apps/photos/js/jquery.fileupload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@
642642
(resolve !== false &&
643643
that._trigger('send', e, options) !== false &&
644644
(that._chunkedUpload(options) || $.ajax(options))) ||
645-
that._getXHRPromise(false, options.context, args)
645+
that._getXHRPromise(false, [options.context, args])
646646
).done(function (result, textStatus, jqXHR) {
647647
that._onDone(result, textStatus, jqXHR, options);
648648
}).fail(function (jqXHR, textStatus, errorThrown) {

wa-apps/photos/js/legacy/jquery.fileupload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@
642642
(resolve !== false &&
643643
that._trigger('send', e, options) !== false &&
644644
(that._chunkedUpload(options) || $.ajax(options))) ||
645-
that._getXHRPromise(false, options.context, args)
645+
that._getXHRPromise(false, [options.context, args])
646646
).done(function (result, textStatus, jqXHR) {
647647
that._onDone(result, textStatus, jqXHR, options);
648648
}).fail(function (jqXHR, textStatus, errorThrown) {

wa-apps/photos/js/legacy/photos.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,7 +1349,7 @@
13491349
placeholderClass: 'gray',
13501350
makeReadableBy: ['esc'],
13511351
updateBy: ['ctrl+enter'],
1352-
html: true,
1352+
html: false,
13531353
allowEmpty: true,
13541354
beforeMakeEditable: function(input) {
13551355
var button = $('#photo-description-save');
@@ -1376,7 +1376,7 @@
13761376
id: $.photos.photo_stream_cache.getCurrent().id,
13771377
type: 'photo',
13781378
name: 'description',
1379-
value: $(input).val(),
1379+
value: $.wa.encodeHTML($(input).val()),
13801380
fn: function() {}
13811381
});
13821382
},
@@ -1508,7 +1508,7 @@
15081508
$('#photo-save-tags-status').html('<i style="vertical-align: middle" class="icon16 yes"></i>'+$_('Saving')).fadeIn('slow');
15091509
$.photos.assignTags({
15101510
photo_id: $.photos.getPhotoId(),
1511-
tags: $('#photo-tags').val(),
1511+
tags: $.wa.encodeHTML($('#photo-tags').val()),
15121512
fn: function() {
15131513
$('#photo-save-tags-status').html('<i style="vertical-align: middle" class="icon16 yes"></i>'+$_('Saved')).fadeOut('slow');
15141514
},
@@ -1862,7 +1862,7 @@
18621862
updatePhotoDescription: function(description, edit_status) {
18631863
if (typeof description === 'boolean' || typeof description === 'undefined') {
18641864
edit_status = description;
1865-
description = $('#photo-description').html();
1865+
description = $.wa.encodeHTML($('#photo-description').html());
18661866
}
18671867
var photo_description = $('#photo-description'),
18681868
placeholder = null,
@@ -2788,7 +2788,7 @@
27882788

27892789
highlightSidebarItem: function() {
27902790
var href = decodeURIComponent($.photos.hash);
2791-
2791+
27922792
$('#p-sidebar li.selected').removeClass('selected');
27932793
var link = $('#p-sidebar li a[href="#'+(href||'/')+'"]');
27942794
if (!link.length) {

wa-apps/photos/js/list.menu.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@
205205
let form = $('#blog-post-form');
206206
let photo_ids = [...document.querySelectorAll('#photo-list > li.selected')].map(el => el.getAttribute('data-photo-id'));
207207

208+
if (!photo_ids.length) {
209+
alert($_('Please select at least one photo'));
210+
return;
211+
}
212+
208213
let counter =[0,0];
209214
for(let i=0;i<photo_ids.length;i++) {
210215
let photo = $.photos.photo_stream_cache.getById(photo_ids[i]);
@@ -822,6 +827,15 @@
822827
selectPhotosAction: function(item) {
823828
var $counter = $('.js-toolbar-dropdown-button > .js-count');
824829

830+
if (!$.photos.total_count) {
831+
const alertNoItems = $(`<div class="alert-fixed-box"><span class="alert warning">${item[0].dataset.errorMsg}</span></div>`);
832+
$('body').append(alertNoItems);
833+
setTimeout(() => {
834+
alertNoItems.remove();
835+
}, 2000)
836+
return;
837+
}
838+
825839
if (!item.data('checked')) {
826840
item.data('checked', true);
827841
item.find('.checked').show().end().
@@ -845,4 +859,4 @@
845859
}
846860
}
847861
});
848-
})(jQuery);
862+
})(jQuery);

0 commit comments

Comments
 (0)