diff -r 000000000000 -r d970ebf37754 wp/wp-content/plugins/page-columnist/page-columnist-assistance.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/wp/wp-content/plugins/page-columnist/page-columnist-assistance.js Wed Nov 06 03:21:17 2013 +0000 @@ -0,0 +1,240 @@ + +(function($) { + + //jQuery UI 1.5.2 doesn't support "option" as getter/setter, so we have to apply a hotfix instead + var needs_jquery_hotfix = (($.ui.version === undefined) || (parseInt($.ui.version.split('.')[1]) < 6)); + if (needs_jquery_hotfix) { + $.extend($.ui.draggable.prototype, { + option: function(key, value) { + if (value === undefined) { + return this.options[key]; + } + if (key == 'containment') { + this.containment = value; + } + else{ + this.options[key] = value; + } + } + }); + $.extend($.ui.draggable, { + getter : 'option' + }); + } + + //extend jQuery with pageColumnist object + $.fn.extend({ + pageColumnist: function() { + var self = $(this); + + self.box = function(elem) { + var box = $(elem).offset(); + box.width = $(elem).width(); + box.height = $(elem).height(); + return box; + } + + self.update_info = function(i, elem) { + var b = self.box(self.columns[i]); + var o = self.box(self); + $(elem).css({top: b.top+'px', left: b.left+3+'px', width: '50px'}); + //changed to extended data info + $(elem).find('b').html(Math.round(parseFloat($(self.columns[i]).attr('data')) * 100.0) / 100.0); + $(elem).find('span').html(b.width); + } + + self.update_spacer = function(i, elem) { + var b1 = self.box(self.columns[i]); + var b2 = self.box(self.columns[i+1]); + $(elem).css({top: b1.top+'px', left: b1.left+b1.width+'px', width: b2.left - (b1.left+b1.width)+'px', height: b1.height+'px' }); + } + + self.recalc_containments = function(i, elem) { + var b1 = self.box(self.columns[i]); + var b2 = self.box(self.columns[i+1]); + var body = self.box($('body')); + self.containments[i] = [b1.left+50, 0, b2.left+b2.width-50-self.box(elem).width, body.height] + } + + self.adjust_columns = function(spacer) { + var idx = $(spacer).draggable('option', 'colidx'); + var perc = $(spacer).draggable('option', 'initial_perc'); + var s = self.box(spacer); + var b1 = self.box(self.columns[idx]); + var b2 = self.box(self.columns[idx+1]); + var main = self.box(self); + //reset affected columns + var w = '0px'; + $(self.columns[idx]).css({width: w}); + $(self.columns[idx+1]).css({width: w}); + //calculate new width + w = Math.round((s.left - b1.left) * 100.0) / main.width; + $(self.columns[idx]).css({ width: w + '%'}).attr('data', w); + b1 = self.box(self.columns[idx]); + w = perc - w; + $(self.columns[idx+1]).css({ width: w + '%'}).attr('data', w); + self.make_equal_height(); + } + + self.make_equal_height = function() { + var h = 0; + $(self.columns).each(function(i, elem) { h = Math.max(h, $(elem).height()); }); + $('#cscp_ghost').css({'height' : h+'px'}); + $('.cspc-assist-spacer').css({'height' : h+'px'}); + } + + self.columns = $('.cspc-column', self); + self.containments = []; + + $('body').prepend('
'); + $('#cscp_ghost').css(self.box(self)).hide(); + for (var i=0; i