apostrophe
Advanced tools
Comparing version 0.4.38 to 0.4.39
{ | ||
"name": "apostrophe", | ||
"version": "0.4.38", | ||
"version": "0.4.39", | ||
"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.", | ||
@@ -5,0 +5,0 @@ "main": "apostrophe.js", |
@@ -118,4 +118,9 @@ /* jshint undef: true */ | ||
// The first argument to the callback is the maximum width | ||
// of all of the images, the second is the maximum height. | ||
// of all of the images, the second is the maximum height. The third | ||
// is the highest ratio of height to width encountered. This is useful | ||
// for determining the height of a slideshow with a predetermined width. | ||
// | ||
// The sizes returned are always the TRUE pixel sizes of the images, regardless | ||
// of any CSS that may be present. | ||
// | ||
// Useful when you need to calculate sizes that depend on images or | ||
@@ -136,22 +141,51 @@ // just want to wait for all of the images to exist. | ||
function attempt() { | ||
var ready = true; | ||
var maxWidth = 0; | ||
var maxHeightToWidth = 0 ; | ||
var maxHeight = 0; | ||
var tmps = []; | ||
$images.each(function(i, item) { | ||
if (!item.complete) { | ||
ready = false; | ||
return; | ||
} | ||
var $item = $(item); | ||
var width = $item.width(); | ||
var height = $item.height(); | ||
if (width > maxWidth) { | ||
maxWidth = width; | ||
// Great, the image loaded, but CSS may have scaled it and we need | ||
// to know its true dimensions. So jam it into a temporary image element | ||
// and wait for that to be ready too. (You'd think this would always be | ||
// ready immediately, but we've seen otherwise.) | ||
if (!tmps[i]) { | ||
tmps[i] = new Image(); | ||
tmps[i].src = $item.attr('src'); | ||
} | ||
if (height > maxHeight) { | ||
maxHeight = height; | ||
var tmp = tmps[i]; | ||
if (!tmp.complete) { | ||
ready = false; | ||
return; | ||
} | ||
function attemptTmp() { | ||
if (!tmp.complete) { | ||
return setTimeout(attemptTmp, 50); | ||
} | ||
var width = tmp.width; | ||
var height = tmp.height; | ||
if (width > maxWidth) { | ||
maxWidth = width; | ||
} | ||
if (height > maxHeight) { | ||
maxHeight = height; | ||
} | ||
if (width && height) { | ||
var heightToWidth = height / width; | ||
if (heightToWidth > maxHeightToWidth) { | ||
maxHeightToWidth = heightToWidth; | ||
} | ||
} | ||
} | ||
attemptTmp(); | ||
}); | ||
if (ready) { | ||
return callback(maxWidth, maxHeight); | ||
return callback(maxWidth, maxHeight, maxHeightToWidth); | ||
} else { | ||
@@ -236,5 +270,10 @@ setTimeout(attempt, 50); | ||
function adjustSize() { | ||
apos.whenImagesReady($widget, '[data-image]', function(maxWidth, maxHeight) { | ||
$widget.find('[data-slideshow-items]').height(maxHeight); | ||
$widget.height(maxHeight); | ||
apos.whenImagesReady($widget, '[data-image]', function(maxWidth, maxHeight, maxHeightToWidth) { | ||
var proportion = $widget.width() * maxHeightToWidth; | ||
if(!$widget.parents().hasClass('apos-no-height')) { | ||
$widget.find('[data-slideshow-items]').height(proportion); | ||
$widget.height(proportion); | ||
} | ||
}); | ||
@@ -602,2 +641,87 @@ } | ||
// Enhance a plaintext date field with a nice jquery ui date widget. | ||
// Just pass a jquery object referring to the text element as the | ||
// first argument. | ||
// | ||
// Uses the YYYY-MM-DD format we use on the back end. | ||
// | ||
// If $minFor is set, any date selected for $el becomes the | ||
// minimum date for $minFor. For instance, start_date should be the | ||
// minimum date for the end_date field. | ||
// | ||
// Similarly, if $maxFor is set, any date selected for $el becomes the maximum | ||
// date for $maxFor. | ||
apos.enhanceDate = function($el, options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
$el.datepicker({ | ||
defaultDate: "+0w", | ||
dateFormat: 'yy-mm-dd', | ||
changeMonth: true, | ||
numberOfMonths: 1, | ||
onClose: function(selectedDate) { | ||
if (options.$minFor) { | ||
options.$minFor.datepicker( "option", "minDate", selectedDate); | ||
} | ||
if (options.$maxFor) { | ||
options.$maxFor.datepicker( "option", "maxDate", selectedDate); | ||
} | ||
} | ||
}); | ||
}; | ||
// Accepts a time in 24-hour HH:MM:SS format and returns a time | ||
// in the user's preferred format as determined by apos.data.timeFormat, | ||
// which may be either 24 or 12. Useful to allow 12-hour format editing | ||
// of times previously saved in the 24-hour format (always used on the back end). | ||
// Seconds are not included in the returned value unless options.seconds is | ||
// explicitly true. If options.timeFormat is set to 24 or 12, that format is | ||
// used, otherwise apos.data.timeFormat is consulted, which allows the format | ||
// to be pushed to the browser via apos.pushGlobalData on the server side | ||
// | ||
// For convenience, the values null, undefined and empty string are returned as | ||
// themselves rather than throwing an exception. This is useful when the absence of any | ||
// setting is an acceptable value. | ||
apos.formatTime = function(time, options) { | ||
if ((time === null) || (time === undefined) || (time === '')) { | ||
return time; | ||
} | ||
if (!options) { | ||
options = {}; | ||
} | ||
var timeFormat = options.timeFormat || apos.data.timeFormat || 12; | ||
var showSeconds = options.seconds || false; | ||
var matches, hours, minutes, seconds, tail; | ||
if (apos.data.timeFormat === 24) { | ||
if (showSeconds) { | ||
return time; | ||
} else { | ||
matches = time.match(/^(\d+):(\d+):(\d+)$/); | ||
return matches[1] + ':' + matches[2]; | ||
} | ||
} else { | ||
matches = time.match(/^(\d+):(\d+):(\d+)$/); | ||
hours = parseInt(matches[1], 10); | ||
minutes = matches[2]; | ||
seconds = matches[3]; | ||
tail = minutes; | ||
if (showSeconds) { | ||
tail += ':' + seconds; | ||
} | ||
if (hours < 1) { | ||
return '12:' + tail + 'am'; | ||
} | ||
if (hours < 12) { | ||
return apos.padInteger(hours, 2) + ':' + tail + 'am'; | ||
} | ||
if (hours === 12) { | ||
return '12:' + tail + 'pm'; | ||
} | ||
hours -= 12; | ||
return apos.padInteger(hours, 2) + ':' + tail + 'pm'; | ||
} | ||
}; | ||
// KEEP IN SYNC WITH SERVER SIDE VERSION IN apostrophe.js | ||
@@ -604,0 +728,0 @@ // |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4396118
26822