Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

apostrophe

Package Overview
Dependencies
Maintainers
8
Versions
1081
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apostrophe - npm Package Compare versions

Comparing version 0.4.23 to 0.4.24

views/cropEditor.html

4

package.json
{
"name": "apostrophe",
"version": "0.4.23",
"version": "0.4.24",
"description": "Apostrophe is a user-friendly content management system. This core module of Apostrophe provides rich content editing and essential facilities to integrate Apostrophe into your Express project. Apostrophe also includes simple facilities for storing your rich content areas in MongoDB and fetching them back again. Additional functionality is available in modules like apostrophe-pages, apostrophe-snippets, apostrophe-blog, apostrophe-events, apostrophe-twitter and apostrophe-rss.",

@@ -61,2 +61,2 @@ "main": "apostrophe.js",

"license": "MIT"
}
}

@@ -96,2 +96,8 @@ /* jshint undef: true */

}
// NOTE: the crop must actually exist already, you can't just invent them
// browser-side without the crop API never having come into play
if (file.crop) {
var c = file.crop;
path += '.' + c.left + '.' + c.top + '.' + c.width + '.' + c.height;
}
return path + '.' + file.extension;

@@ -434,5 +440,8 @@ };

var $el = apos.fromTemplate(sel);
console.log(sel);
console.log($el.length);
// It's not uncommon to have duplicates of a template that hasn't
// been overridden for a derived type yet. Behave well in this case
$el = $el.filter(':first');
console.log($el[0]);

@@ -575,4 +584,5 @@ // Make sure they can provide their own afterHide

// Convert camel case to a hyphenated css name. Not especially fast,
// Convert everything else to a hyphenated css name. Not especially fast,
// hopefully you only do this during initialization and remember the result
// KEEP IN SYNC WITH SERVER SIDE VERSION in apostrophe.js
apos.cssName = function(camel) {

@@ -673,2 +683,11 @@ var i;

// pad an integer with leading zeroes, creating a string
apos.padInteger = function(i, places) {
var s = i + '';
while (s.length < places) {
s = '0' + s;
}
return s;
};
// MINOR JQUERY EXTENSIONS

@@ -675,0 +694,0 @@

@@ -981,2 +981,12 @@ /* global rangy, $, _ */

self.busy = function(state) {
if (state) {
$('[data-progress]').show();
$('[data-finished]').hide();
} else {
$('[data-progress]').hide();
$('[data-finished]').show();
}
}
// Our current thinking is that preview is redundant for slideshows.

@@ -1009,14 +1019,16 @@ // Another approach would be to make it much smaller. We might want that

start: function (e) {
$('[data-progress]').show();
$('[data-finished]').hide();
self.busy(true);
},
stop: function (e) {
$('[data-progress]').hide();
$('[data-finished]').show();
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
self.$el.find('[data-progress-percentage]').text(progress);
},
// This is not the same thing as really being ready to work with the files,
// so wait for 'done'
// stop: function (e) {
// },
// Progress percentages are just misleading due to image rendering time,
// so just show a spinner
// progressall: function (e, data) {
// var progress = parseInt(data.loaded / data.total * 100, 10);
// self.$el.find('[data-progress-percentage]').text(progress);
// },
done: function (e, data) {
self.busy(false);
if (data.result.files) {

@@ -1064,2 +1076,67 @@ _.each(data.result.files, function (file) {

// on Edit button click, reveal extra fields
self.$el.on('click', '[data-extra-fields-edit]', function(){
self.$el.find('[data-item]').removeClass('apos-slideshow-reveal-extra-fields');
var $button = $(this);
$button.closest('[data-item]').toggleClass('apos-slideshow-reveal-extra-fields');
});
// on Extra Fields Save, reflect and close Extra Fields
self.$el.on('click', '[data-extra-fields-save]', function(){
reflect();
var $button = $(this);
$button.closest('[data-item]').removeClass('apos-slideshow-reveal-extra-fields');
});
// on Crop button click, configure and reveal cropping modal
self.$el.on('click', '[data-crop]', function() {
var $item = $(this).closest('[data-item]');
var item = $item.data('item');
self.busy(true);
var $cropModal = apos.modalFromTemplate('.apos-slideshow-crop', {
init: function(callback) {
// Cropping should use the full size original. This gives us both the right
// coordinates and a chance to implement zoom if desired
var $cropImage = $cropModal.find('[data-crop-image]');
$cropImage.attr('src', apos.data.uploadsUrl + '/files/' + item._id + '-' + item.name + '.' + item.extension);
apos.whenImagesReady($item, function() {
var jcropArgs = {};
if (item.crop) {
jcropArgs.setSelect = [ item.crop.left, item.crop.top, item.crop.left + item.crop.width, item.crop.top + item.crop.height ];
}
// Pass jcrop arguments and capture the jcrop API object so we can call
// tellSelect at a convenient time
$cropImage.Jcrop(jcropArgs, function() {
$item.data('jcrop', this);
});
self.busy(false);
});
return callback(null);
},
save: function(callback) {
var c = $item.data('jcrop').tellSelect();
item.crop = {
top: c.y,
left: c.x,
width: c.w,
height: c.h
};
// Ask the server to render this crop
self.busy(true);
$.post('/apos/crop', { _id: $item.data('item')._id, crop: item.crop }, function(data) {
reflect();
apos.log('removing class');
$item.removeClass('apos-slideshow-reveal-crop');
self.busy(false);
return callback(null);
}).error(function() {
self.busy(false);
alert('Server error, please retry');
return callback('fail');
});
}
});
});
};

@@ -1085,34 +1162,2 @@

});
// on Edit button click, reveal extra fields
self.$el.find('[data-extra-fields-edit]').on('click', function(){
self.$el.find('[data-item]').removeClass('apos-slideshow-reveal-extra-fields');
var $button = $(this);
$button.closest('[data-item]').toggleClass('apos-slideshow-reveal-extra-fields');
});
// on Extra Fields Save, reflect and close Extra Fields
self.$el.find('[data-extra-fields-save]').on('click', function(){
reflect();
var $button = $(this);
$button.closest('[data-item]').removeClass('apos-slideshow-reveal-extra-fields');
});
// on Crop button click, reveal cropping window
self.$el.find('[data-crop]').on('click', function(){
self.$el.find('[data-item]').removeClass('apos-slideshow-reveal-crop');
var $button = $(this);
$button.closest('[data-item]').toggleClass('apos-slideshow-reveal-crop');
});
// on Crop Save, reflect and close Crop
self.$el.find('[data-crop-save]').on('click', function(){
reflect();
var $button = $(this);
$button.closest('[data-item]').removeClass('apos-slideshow-reveal-crop');
});
callback();
};

@@ -1125,13 +1170,2 @@

function updateCoords(id, c){
var $el = self.$el.find("[data-crop-id='" + id + "']");
$el.attr('data-crop-x', c.x);
$el.attr('data-crop-y', c.y);
$el.attr('data-crop-x2', c.x2);
$el.attr('data-crop-y2', c.y2);
$el.attr('data-crop-w', c.w);
$el.attr('data-crop-h', c.h);
}
function addItem(item) {

@@ -1154,4 +1188,2 @@ var count = self.count();

// $item.find('[data-image]').attr('src', apos.data.uploadsUrl + '/files/' + item._id + '-' + item.name + '.one-third.' + item.extension);
$item.find('[data-crop-image]').attr('src', apos.data.uploadsUrl + '/files/' + item._id + '-' + item.name + '.one-third.' + item.extension);
$item.find('[data-crop-image]').attr('data-crop-id', item._id);

@@ -1173,25 +1205,2 @@ $item.find('[data-title]').val(item.title);

}
if (item.cropCoords) {
var thumbnailCoords = [];
for (var i = 0; i < item.cropCoords.length; i++) {
thumbnailCoords.push(item.cropCoords[i] / 3);
}
$item.find('[data-crop-image]').Jcrop({
setSelect: thumbnailCoords,
onChange: function(c) {
updateCoords(item._id,c);
}
});
} else{
$item.find('[data-crop-image]').Jcrop({
onChange: function(c) {
updateCoords(item._id,c);
}
});
}
$item.data('item', item);

@@ -1252,16 +1261,3 @@ $item.find('[data-remove]').click(function() {

info.credit = $item.find('[data-credit]').val();
if (typeof $item.find('[data-crop-image]').attr('data-crop-x') !== 'undefined') {
var cropCoords = [];
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-x'), 10) * 3);
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-y'), 10) * 3);
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-x2'), 10) * 3);
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-y2'), 10) * 3);
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-w'), 10) * 3);
cropCoords.push(parseInt($item.find('[data-crop-image]').attr('data-crop-h'), 10) * 3);
info.cropCoords = cropCoords;
}
self.data.items.push(info);

@@ -1268,0 +1264,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc