Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions lib/jquery.timezone-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ methods.init = function(initOpts) {
// Set the instance options.
opts = $.extend({}, $.fn.timezonePicker.defaults, initOpts);
selectedTimzone = opts.timezone;

changeHandler = opts.changeHandler;

return $origCall.each(function(index, item) {
Expand Down Expand Up @@ -56,7 +56,7 @@ methods.init = function(initOpts) {
top: (pinCoords[1] - pinHeight) + 'px'
});
}

var timezoneName = $(areaElement).attr('data-timezone');
var countryName = $(areaElement).attr('data-country');
var offset = $(areaElement).attr('data-offset');
Expand All @@ -65,7 +65,7 @@ methods.init = function(initOpts) {
if (typeof changeHandler === 'function') {
changeHandler(timezoneName, countryName, offset);
}

// Update the target select list.
if (opts.target) {
if (timezoneName) $(opts.target).val(timezoneName);
Expand Down Expand Up @@ -244,6 +244,13 @@ methods.detectLocation = function(detectOpts) {
* the current dimensions of the image.
*/
methods.resize = function() {
var rescale = imgElement.width/imgElement.getAttribute('width');

// Adjust the image size.
$(imgElement).parent().css({
width: $(imgElement).width() + 'px'
});

$(mapElement).find('area').each(function(m, areaElement) {
// Save the original coordinates for further resizing.
if (!areaElement.originalCoords) {
Expand All @@ -254,12 +261,6 @@ methods.resize = function() {
pin: areaElement.getAttribute('data-pin')
};
}
var rescale = imgElement.width/imgElement.getAttribute('width');

// Adjust the image size.
$(imgElement).parent().css({
width: $(imgElement).width() + 'px'
});

// Adjust the coords attribute.
var originalCoords = areaElement.originalCoords.coords.split(',');
Expand All @@ -274,14 +275,13 @@ methods.resize = function() {
pinCoords[0] = Math.round(parseInt(pinCoords[0]) * rescale);
pinCoords[1] = Math.round(parseInt(pinCoords[1]) * rescale);
areaElement.setAttribute('data-pin', pinCoords.join(','));

// Fire the change handler on the target.
if (opts.target) {
$(opts.target).triggerHandler('change');
}

});

// Fire the change handler on the target.
if (opts.target) {
$(opts.target).triggerHandler('change');
}

return this;
};

Expand All @@ -295,7 +295,7 @@ $.fn.timezonePicker = function(method) {
}
else {
$.error('Method ' + method + ' does not exist on jQuery.timezonePicker');
}
}
};

$.fn.timezonePicker.defaults = {
Expand Down