');
+ $.each(folders, function(k,v)
+ {
+ select.append($('' + k + ' '));
+ });
+
+ $('#redactor_image_box').before(select);
+ select.change(onchangeFunc);
+ }
+
+ }, this));
+ }
+ else
+ {
+ $('#redactor_tabs a').eq(1).remove();
+ }
+
+ if (this.opts.imageUpload !== false)
+ {
+
+ // dragupload
+ if (this.opts.uploadCrossDomain === false && this.isMobile() === false)
+ {
+
+ if ($('#redactor_file').size() !== 0)
+ {
+ $('#redactor_file').dragupload(
+ {
+ url: this.opts.imageUpload,
+ uploadFields: this.opts.uploadFields,
+ success: $.proxy(this.imageUploadCallback, this),
+ error: $.proxy(this.opts.imageUploadErrorCallback, this)
+ });
+ }
+ }
+
+ // ajax upload
+ this.uploadInit('redactor_file',
+ {
+ auto: true,
+ url: this.opts.imageUpload,
+ success: $.proxy(this.imageUploadCallback, this),
+ error: $.proxy(this.opts.imageUploadErrorCallback, this)
+ });
+ }
+ else
+ {
+ $('.redactor_tab').hide();
+ if (this.opts.imageGetJson === false)
+ {
+ $('#redactor_tabs').remove();
+ $('#redactor_tab3').show();
+ }
+ else
+ {
+ var tabs = $('#redactor_tabs a');
+ tabs.eq(0).remove();
+ tabs.eq(1).addClass('redactor_tabs_act');
+ $('#redactor_tab2').show();
+ }
+ }
+
+ $('#redactor_upload_btn').click($.proxy(this.imageUploadCallbackLink, this));
+
+ if (this.opts.imageUpload === false && this.opts.imageGetJson === false)
+ {
+ setTimeout(function()
+ {
+ $('#redactor_file_link').focus();
+ }, 200);
+
+ }
+
+ }, this);
+
+ this.modalInit(RLANG.image, this.opts.modal_image, 610, callback);
+
+ },
+ imageSetThumb: function(e)
+ {
+ this._imageSet(' ', true);
+ },
+ imageUploadCallbackLink: function()
+ {
+ if ($('#redactor_file_link').val() !== '')
+ {
+ var data = ' ';
+ this._imageSet(data, true);
+ }
+ else
+ {
+ this.modalClose();
+ }
+ },
+ imageUploadCallback: function(data)
+ {
+ this._imageSet(data);
+ },
+ _imageSet: function(json, link)
+ {
+ this.restoreSelection();
+
+ if (json !== false)
+ {
+ var html = '';
+ if (link !== true)
+ {
+ html = '
';
+ }
+ else
+ {
+ html = json;
+ }
+
+ this.execCommand('inserthtml', html);
+
+ // upload image callback
+ if (link !== true && typeof this.opts.imageUploadCallback === 'function')
+ {
+ this.opts.imageUploadCallback(this, json);
+ }
+ }
+
+ this.modalClose();
+ this.observeImages();
+ },
+
+ // INSERT LINK
+ showLink: function()
+ {
+ this.saveSelection();
+
+ var callback = $.proxy(function()
+ {
+ this.insert_link_node = false;
+ var sel = this.getSelection();
+ var url = '', text = '', target = '';
+
+ if (this.browser('msie'))
+ {
+ var parent = this.getParentNode();
+ if (parent.nodeName === 'A')
+ {
+ this.insert_link_node = $(parent);
+ text = this.insert_link_node.text();
+ url = this.insert_link_node.attr('href');
+ target = this.insert_link_node.attr('target');
+ }
+ else
+ {
+ if (this.oldIE())
+ {
+ text = sel.text;
+ }
+ else
+ {
+ text = sel.toString();
+ }
+ }
+ }
+ else
+ {
+ if (sel && sel.anchorNode && sel.anchorNode.parentNode.tagName === 'A')
+ {
+ url = sel.anchorNode.parentNode.href;
+ text = sel.anchorNode.parentNode.text;
+ target = sel.anchorNode.parentNode.target;
+
+ if (sel.toString() === '')
+ {
+ this.insert_link_node = sel.anchorNode.parentNode;
+ }
+ }
+ else
+ {
+ text = sel.toString();
+ }
+ }
+
+ $('.redactor_link_text').val(text);
+
+ var thref = self.location.href.replace(/\/$/i, '');
+ var turl = url.replace(thref, '');
+
+ if (url.search('mailto:') === 0)
+ {
+ this.setModalTab(2);
+
+ $('#redactor_tab_selected').val(2);
+ $('#redactor_link_mailto').val(url.replace('mailto:', ''));
+ }
+ else if (turl.search(/^#/gi) === 0)
+ {
+ this.setModalTab(3);
+
+ $('#redactor_tab_selected').val(3);
+ $('#redactor_link_anchor').val(turl.replace(/^#/gi, ''));
+ }
+ else
+ {
+ $('#redactor_link_url').val(turl);
+ }
+
+ if (target === '_blank')
+ {
+ $('#redactor_link_blank').attr('checked', true);
+ }
+
+ $('#redactor_insert_link_btn').click($.proxy(this.insertLink, this));
+
+ setTimeout(function()
+ {
+ $('#redactor_link_url').focus();
+ }, 200);
+
+ }, this);
+
+ this.modalInit(RLANG.link, this.opts.modal_link, 460, callback);
+
+ },
+ insertLink: function()
+ {
+ var tab_selected = $('#redactor_tab_selected').val();
+ var link = '', text = '', target = '';
+
+ if (tab_selected === '1') // url
+ {
+ link = $('#redactor_link_url').val();
+ text = $('#redactor_link_url_text').val();
+
+ if ($('#redactor_link_blank').attr('checked'))
+ {
+ target = ' target="_blank"';
+ }
+
+ // test url
+ var pattern = '/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/';
+ //var pattern = '((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}';
+ var re = new RegExp('^(http|ftp|https)://' + pattern,'i');
+ var re2 = new RegExp('^' + pattern,'i');
+ if (link.search(re) == -1 && link.search(re2) == 0 && this.opts.protocol !== false)
+ {
+ link = this.opts.protocol + link;
+ }
+
+ }
+ else if (tab_selected === '2') // mailto
+ {
+ link = 'mailto:' + $('#redactor_link_mailto').val();
+ text = $('#redactor_link_mailto_text').val();
+ }
+ else if (tab_selected === '3') // anchor
+ {
+ link = '#' + $('#redactor_link_anchor').val();
+ text = $('#redactor_link_anchor_text').val();
+ }
+
+ this._insertLink('' + text + ' ', $.trim(text), link, target);
+
+ },
+ _insertLink: function(a, text, link, target)
+ {
+ this.$editor.focus();
+ this.restoreSelection();
+
+ if (text !== '')
+ {
+ if (this.insert_link_node)
+ {
+ $(this.insert_link_node).text(text);
+ $(this.insert_link_node).attr('href', link);
+ if (target !== '')
+ {
+ $(this.insert_link_node).attr('target', target);
+ }
+ else
+ {
+ $(this.insert_link_node).removeAttr('target');
+ }
+
+ this.syncCode();
+ }
+ else
+ {
+ this.execCommand('inserthtml', a);
+ }
+ }
+
+ this.modalClose();
+ },
+
+ // INSERT FILE
+ showFile: function()
+ {
+ this.saveSelection();
+
+ var callback = $.proxy(function()
+ {
+ var sel = this.getSelection();
+
+ var text = '';
+
+ if (this.oldIE())
+ {
+ text = sel.text;
+ }
+ else
+ {
+ text = sel.toString();
+ }
+
+ $('#redactor_filename').val(text);
+
+ // dragupload
+ if (this.opts.uploadCrossDomain === false && this.isMobile() === false)
+ {
+ $('#redactor_file').dragupload(
+ {
+ url: this.opts.fileUpload,
+ uploadFields: this.opts.uploadFields,
+ success: $.proxy(this.fileUploadCallback, this),
+ error: $.proxy(this.opts.fileUploadErrorCallback, this)
+ });
+ }
+
+ this.uploadInit('redactor_file',
+ {
+ auto: true,
+ url: this.opts.fileUpload,
+ success: $.proxy(this.fileUploadCallback, this),
+ error: $.proxy(this.opts.fileUploadErrorCallback, this)
+ });
+
+ }, this);
+
+ this.modalInit(RLANG.file, this.opts.modal_file, 500, callback);
+ },
+ fileUploadCallback: function(json)
+ {
+ this.restoreSelection();
+
+ if (json !== false)
+ {
+ var text = $('#redactor_filename').val();
+
+ if (text === '')
+ {
+ text = json.filename;
+ }
+
+ var link = '' + text + ' ';
+
+ // chrome fix
+ if (this.browser('webkit') && !!this.window.chrome)
+ {
+ link = link + ' ';
+ }
+
+ this.execCommand('inserthtml', link);
+
+ // file upload callback
+ if (typeof this.opts.fileUploadCallback === 'function')
+ {
+ this.opts.fileUploadCallback(this, json);
+ }
+ }
+
+ this.modalClose();
+ },
+
+
+
+ // MODAL
+ modalInit: function(title, content, width, callback)
+ {
+ // modal overlay
+ if ($('#redactor_modal_overlay').size() === 0)
+ {
+ this.overlay = $('
');
+ $('body').prepend(this.overlay);
+ }
+
+ if (this.opts.overlay)
+ {
+ $('#redactor_modal_overlay').show();
+ $('#redactor_modal_overlay').click($.proxy(this.modalClose, this));
+ }
+
+ if ($('#redactor_modal').size() === 0)
+ {
+ this.modal = $('');
+ $('body').append(this.modal);
+ }
+
+ $('#redactor_modal_close').click($.proxy(this.modalClose, this));
+
+ this.hdlModalClose = $.proxy(function(e) { if ( e.keyCode === 27) { this.modalClose(); return false; } }, this);
+
+ $(document).keyup(this.hdlModalClose);
+ this.$editor.keyup(this.hdlModalClose);
+
+ // set content
+ if (content.indexOf('#') == 0)
+ {
+ $('#redactor_modal_inner').empty().append($(content).html());
+ }
+ else
+ {
+ $('#redactor_modal_inner').empty().append(content);
+ }
+
+
+ $('#redactor_modal_header').html(title);
+
+ // draggable
+ if (typeof $.fn.draggable !== 'undefined')
+ {
+ $('#redactor_modal').draggable({ handle: '#redactor_modal_header' });
+ $('#redactor_modal_header').css('cursor', 'move');
+ }
+
+ // tabs
+ if ($('#redactor_tabs').size() !== 0)
+ {
+ var that = this;
+ $('#redactor_tabs a').each(function(i,s)
+ {
+ i++;
+ $(s).click(function()
+ {
+ $('#redactor_tabs a').removeClass('redactor_tabs_act');
+ $(this).addClass('redactor_tabs_act');
+ $('.redactor_tab').hide();
+ $('#redactor_tab' + i).show();
+ $('#redactor_tab_selected').val(i);
+
+ if (that.isMobile() === false)
+ {
+ var height = $('#redactor_modal').outerHeight();
+ $('#redactor_modal').css('margin-top', '-' + (height+10)/2 + 'px');
+ }
+ });
+ });
+ }
+
+ $('#redactor_modal .redactor_btn_modal_close').click($.proxy(this.modalClose, this));
+
+ if (this.isMobile() === false)
+ {
+ $('#redactor_modal').css({ position: 'fixed', top: '-2000px', left: '50%', width: width + 'px', marginLeft: '-' + (width+60)/2 + 'px' }).show();
+
+ this.modalSaveBodyOveflow = $(document.body).css('overflow');
+ $(document.body).css('overflow', 'hidden');
+ }
+ else
+ {
+ $('#redactor_modal').css({ position: 'fixed', width: '100%', height: '100%', top: '0', left: '0', margin: '0', minHeight: '300px' }).show();
+ }
+
+ // callback
+ if (typeof callback === 'function')
+ {
+ callback();
+ }
+
+ if (this.isMobile() === false)
+ {
+ setTimeout(function()
+ {
+ var height = $('#redactor_modal').outerHeight();
+ $('#redactor_modal').css({ top: '50%', height: 'auto', minHeight: 'auto', marginTop: '-' + (height+10)/2 + 'px' });
+
+ }, 20);
+ }
+
+ },
+ modalClose: function()
+ {
+ $('#redactor_modal_close').unbind('click', this.modalClose);
+ $('#redactor_modal').fadeOut('fast', $.proxy(function()
+ {
+ $('#redactor_modal_inner').html('');
+
+ if (this.opts.overlay)
+ {
+ $('#redactor_modal_overlay').hide();
+ $('#redactor_modal_overlay').unbind('click', this.modalClose);
+ }
+
+ $(document).unbind('keyup', this.hdlModalClose);
+ this.$editor.unbind('keyup', this.hdlModalClose);
+
+ }, this));
+
+
+ if (this.isMobile() === false)
+ {
+ $(document.body).css('overflow', this.modalSaveBodyOveflow ? this.modalSaveBodyOveflow : 'visible');
+ }
+
+ return false;
+
+ },
+ setModalTab: function(num)
+ {
+ $('.redactor_tab').hide();
+ var tabs = $('#redactor_tabs a');
+ tabs.removeClass('redactor_tabs_act');
+ tabs.eq(num-1).addClass('redactor_tabs_act');
+ $('#redactor_tab' + num).show();
+ },
+
+ // UPLOAD
+ uploadInit: function(element, options)
+ {
+ // Upload Options
+ this.uploadOptions = {
+ url: false,
+ success: false,
+ error: false,
+ start: false,
+ trigger: false,
+ auto: false,
+ input: false
+ };
+
+ $.extend(this.uploadOptions, options);
+
+ // Test input or form
+ if ($('#' + element).size() !== 0 && $('#' + element).get(0).tagName === 'INPUT')
+ {
+ this.uploadOptions.input = $('#' + element);
+ this.element = $($('#' + element).get(0).form);
+ }
+ else
+ {
+ this.element = $('#' + element);
+ }
+
+ this.element_action = this.element.attr('action');
+
+ // Auto or trigger
+ if (this.uploadOptions.auto)
+ {
+ $(this.uploadOptions.input).change($.proxy(function()
+ {
+ this.element.submit(function(e) { return false; });
+ this.uploadSubmit();
+ }, this));
+
+ }
+ else if (this.uploadOptions.trigger)
+ {
+ $('#' + this.uploadOptions.trigger).click($.proxy(this.uploadSubmit, this));
+ }
+ },
+ uploadSubmit : function()
+ {
+ this.uploadForm(this.element, this.uploadFrame());
+ },
+ uploadFrame : function()
+ {
+ this.id = 'f' + Math.floor(Math.random() * 99999);
+
+ var d = this.document.createElement('div');
+ var iframe = '';
+ d.innerHTML = iframe;
+ $(d).appendTo("body");
+
+ // Start
+ if (this.uploadOptions.start)
+ {
+ this.uploadOptions.start();
+ }
+
+ $('#' + this.id).load($.proxy(this.uploadLoaded, this));
+
+ return this.id;
+ },
+ uploadForm : function(f, name)
+ {
+ if (this.uploadOptions.input)
+ {
+ var formId = 'redactorUploadForm' + this.id;
+ var fileId = 'redactorUploadFile' + this.id;
+ this.form = $('');
+
+ // append hidden fields
+ if (this.opts.uploadFields !== false && typeof this.opts.uploadFields === 'object')
+ {
+ $.each(this.opts.uploadFields, $.proxy(function(k,v)
+ {
+ if (v.toString().indexOf('#') === 0)
+ {
+ v = $(v).val();
+ }
+
+ var hidden = $(' ', {'type': "hidden", 'name': k, 'value': v});
+ $(this.form).append(hidden);
+
+ }, this));
+ }
+
+ var oldElement = this.uploadOptions.input;
+ var newElement = $(oldElement).clone();
+ $(oldElement).attr('id', fileId);
+ $(oldElement).before(newElement);
+ $(oldElement).appendTo(this.form);
+ $(this.form).css('position', 'absolute');
+ $(this.form).css('top', '-2000px');
+ $(this.form).css('left', '-2000px');
+ $(this.form).appendTo('body');
+
+ this.form.submit();
+ }
+ else
+ {
+ f.attr('target', name);
+ f.attr('method', 'POST');
+ f.attr('enctype', 'multipart/form-data');
+ f.attr('action', this.uploadOptions.url);
+
+ this.element.submit();
+ }
+
+ },
+ uploadLoaded : function()
+ {
+ var i = $('#' + this.id)[0];
+ var d;
+
+ if (i.contentDocument)
+ {
+ d = i.contentDocument;
+ }
+ else if (i.contentWindow)
+ {
+ d = i.contentWindow.document;
+ }
+ else
+ {
+ d = window.frames[this.id].document;
+ }
+
+ // Success
+ if (this.uploadOptions.success)
+ {
+ if (typeof d !== 'undefined')
+ {
+ // Remove bizarre tag wrappers around our json data:
+ var rawString = d.body.innerHTML;
+ var jsonString = rawString.match(/\{(.|\n)*\}/)[0];
+ var json = $.parseJSON(jsonString);
+
+ if (typeof json.error == 'undefined')
+ {
+ this.uploadOptions.success(json);
+ }
+ else
+ {
+ this.uploadOptions.error(this, json);
+ this.modalClose();
+ }
+ }
+ else
+ {
+ alert('Upload failed!');
+ this.modalClose();
+ }
+ }
+
+ this.element.attr('action', this.element_action);
+ this.element.attr('target', '');
+
+ },
+
+ // UTILITY
+ browser: function(browser)
+ {
+ var ua = navigator.userAgent.toLowerCase();
+ var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
+
+ if (browser == 'version')
+ {
+ return match[2];
+ }
+
+ if (browser == 'webkit')
+ {
+ return (match[1] == 'chrome' || match[1] == 'webkit');
+ }
+
+ return match[1] == browser;
+ },
+ oldIE: function()
+ {
+ if (this.browser('msie') && parseInt(this.browser('version'), 10) < 9)
+ {
+ return true;
+ }
+
+ return false;
+ },
+ outerHTML: function(s)
+ {
+ return $("").append($(s).eq(0).clone()).html();
+ },
+ normalize: function(str)
+ {
+ return parseInt(str.replace('px',''), 10);
+ },
+ isMobile: function(ipad)
+ {
+ if (ipad === true && /(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent))
+ {
+ return true;
+ }
+ else if (/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ };
+
+
+ // API
+ $.fn.getObject = function()
+ {
+ return this.data('redactor');
+ };
+
+ $.fn.getEditor = function()
+ {
+ return this.data('redactor').$editor;
+ };
+
+ $.fn.getCode = function()
+ {
+ return $.trim(this.data('redactor').getCode());
+ };
+
+ $.fn.getText = function()
+ {
+ return this.data('redactor').$editor.text();
+ };
+
+ $.fn.getSelected = function()
+ {
+ return this.data('redactor').getSelectedHtml();
+ };
+
+ $.fn.setCode = function(html)
+ {
+ this.data('redactor').setCode(html);
+ };
+
+ $.fn.insertHtml = function(html)
+ {
+ this.data('redactor').insertHtml(html);
+ };
+
+ $.fn.destroyEditor = function()
+ {
+ this.each(function()
+ {
+ if (typeof $(this).data('redactor') != 'undefined')
+ {
+ $(this).data('redactor').destroy();
+ $(this).removeData('redactor');
+ }
+ });
+ };
+
+ $.fn.setFocus = function()
+ {
+ this.data('redactor').$editor.focus();
+ };
+
+ $.fn.execCommand = function(cmd, param)
+ {
+ this.data('redactor').execCommand(cmd, param);
+ };
+
+})(jQuery);
+
+/*
+ Plugin Drag and drop Upload v1.0.2
+ http://imperavi.com/
+ Copyright 2012, Imperavi Inc.
+*/
+(function($){
+
+ "use strict";
+
+ // Initialization
+ $.fn.dragupload = function(options)
+ {
+ return this.each(function() {
+ var obj = new Construct(this, options);
+ obj.init();
+ });
+ };
+
+ // Options and variables
+ function Construct(el, options) {
+
+ this.opts = $.extend({
+
+ url: false,
+ success: false,
+ error: false,
+ preview: false,
+ uploadFields: false,
+
+ text: RLANG.drop_file_here,
+ atext: RLANG.or_choose
+
+ }, options);
+
+ this.$el = $(el);
+ }
+
+ // Functionality
+ Construct.prototype = {
+ init: function()
+ {
+ if (navigator.userAgent.search("MSIE") === -1)
+ {
+ this.droparea = $('
');
+ this.dropareabox = $('' + this.opts.text + '
');
+ this.dropalternative = $('' + this.opts.atext + '
');
+
+ this.droparea.append(this.dropareabox);
+
+ this.$el.before(this.droparea);
+ this.$el.before(this.dropalternative);
+
+ // drag over
+ this.dropareabox.bind('dragover', $.proxy(function() { return this.ondrag(); }, this));
+
+ // drag leave
+ this.dropareabox.bind('dragleave', $.proxy(function() { return this.ondragleave(); }, this));
+
+ var uploadProgress = $.proxy(function(e)
+ {
+ var percent = parseInt(e.loaded / e.total * 100, 10);
+ this.dropareabox.text('Loading ' + percent + '%');
+
+ }, this);
+
+ var xhr = jQuery.ajaxSettings.xhr();
+
+ if (xhr.upload)
+ {
+ xhr.upload.addEventListener('progress', uploadProgress, false);
+ }
+
+ var provider = function () { return xhr; };
+
+ // drop
+ this.dropareabox.get(0).ondrop = $.proxy(function(event)
+ {
+ event.preventDefault();
+
+ this.dropareabox.removeClass('hover').addClass('drop');
+
+ var file = event.dataTransfer.files[0];
+ var fd = new FormData();
+
+ // append hidden fields
+ if (this.opts.uploadFields !== false && typeof this.opts.uploadFields === 'object')
+ {
+ $.each(this.opts.uploadFields, $.proxy(function(k,v)
+ {
+ if (v.toString().indexOf('#') === 0)
+ {
+ v = $(v).val();
+ }
+
+ fd.append(k, v);
+
+ }, this));
+ }
+
+ // append file data
+ fd.append('file', file);
+
+ $.ajax({
+ url: this.opts.url,
+ dataType: 'html',
+ data: fd,
+ xhr: provider,
+ cache: false,
+ contentType: false,
+ processData: false,
+ type: 'POST',
+ success: $.proxy(function(data)
+ {
+ var json = $.parseJSON(data);
+
+ if (typeof json.error == 'undefined')
+ {
+ this.opts.success(json);
+ }
+ else
+ {
+ this.opts.error(this, json);
+ this.opts.success(false);
+ }
+
+ }, this)
+ });
+
+
+ }, this);
+ }
+ },
+ ondrag: function()
+ {
+ this.dropareabox.addClass('hover');
+ return false;
+ },
+ ondragleave: function()
+ {
+ this.dropareabox.removeClass('hover');
+ return false;
+ }
+ };
+
+})(jQuery);
+
+
+
+// Define: Linkify plugin from stackoverflow
+(function($){
+
+ "use strict";
+
+ var protocol = 'http://';
+ var url1 = /(^|<|\s)(www\..+?\..+?)(\s|>|$)/g,
+ url2 = /(^|<|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|>|$)/g,
+
+ linkifyThis = function ()
+ {
+ var childNodes = this.childNodes,
+ i = childNodes.length;
+ while(i--)
+ {
+ var n = childNodes[i];
+ if (n.nodeType === 3)
+ {
+ var html = n.nodeValue;
+ if (html)
+ {
+ html = html.replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(url1, '$1$2 $3')
+ .replace(url2, '$1$2 $5');
+
+ $(n).after(html).remove();
+ }
+ }
+ else if (n.nodeType === 1 && !/^(a|button|textarea)$/i.test(n.tagName))
+ {
+ linkifyThis.call(n);
+ }
+ }
+ };
+
+ $.fn.linkify = function ()
+ {
+ this.each(linkifyThis);
+ };
+
+})(jQuery);
+
+
+/* jQuery plugin textselect
+ * version: 0.9
+ * author: Josef Moravec, josef.moravec@gmail.com
+ * updated: Imperavi Inc.
+ *
+ */
+eval(function(p,a,c,k,e,d){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5($){$.1.4.7={t:5(0,v){$(2).0("8",c);$(2).0("r",0);$(2).l(\'g\',$.1.4.7.b)},u:5(0){$(2).w(\'g\',$.1.4.7.b)},b:5(1){9 0=$(2).0("r");9 3=$.1.4.7.f(0).h();6(3!=\'\'){$(2).0("8",x);1.j="7";1.3=3;$.1.i.m(2,k)}},f:5(0){9 3=\'\';6(q.e){3=q.e()}o 6(d.e){3=d.e()}o 6(d.p){3=d.p.B().3}A 3}};$.1.4.a={t:5(0,v){$(2).0("n",0);$(2).0("8",c);$(2).l(\'g\',$.1.4.a.b);$(2).l(\'D\',$.1.4.a.s)},u:5(0){$(2).w(\'g\',$.1.4.a.b)},b:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6(3==\'\'){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}},s:5(1){6($(2).0("8")){9 0=$(2).0("n");9 3=$.1.4.7.f(0).h();6((1.y=z)&&(3==\'\')){$(2).0("8",c);1.j="a";$.1.i.m(2,k)}}}}})(C);',40,40,'data|event|this|text|special|function|if|textselect|textselected|var|textunselect|handler|false|rdocument|getSelection|getSelectedText|mouseup|toString|handle|type|arguments|bind|apply|rttt|else|selection|rwindow|ttt|handlerKey|setup|teardown|namespaces|unbind|true|keyCode|27|return|createRange|jQuery|keyup'.split('|'),0,{}))
+
+
+
+if (!RedactorPlugins) var RedactorPlugins = {};
+
+RedactorPlugins.fontsize = {
+ init: function()
+ {
+ var fonts = [10, 11, 12, 14, 16, 18, 20, 24, 28, 30];
+ var that = this;
+ var dropdown = {};
+
+ $.each(fonts, function(i, s)
+ {
+ dropdown['s' + i] = { title: s + 'px', callback: function() { that.setFontsize(s); } };
+ });
+
+ dropdown['remove'] = { title: 'Remove font size', callback: function() { that.resetFontsize(); } };
+
+ this.buttonAdd( 'fontsize', 'Change font size', false, dropdown);
+ },
+ setFontsize: function(size)
+ {
+ this.inlineSetStyle('font-size', size + 'px');
+ },
+ resetFontsize: function()
+ {
+ this.inlineRemoveStyle('font-size');
+ }
+};
+
+
+if (!RedactorPlugins) var RedactorPlugins = {};
+
+RedactorPlugins.fontfamily = {
+ init: function ()
+ {
+ var fonts = [ 'Arial', 'Helvetica', 'Georgia', 'Times New Roman', 'Monospace' ];
+ var that = this;
+ var dropdown = {};
+
+ $.each(fonts, function(i, s)
+ {
+ dropdown['s' + i] = { title: s, callback: function() { that.setFontfamily(s); }};
+ });
+
+ dropdown['remove'] = { title: 'Remove font', callback: function() { that.resetFontfamily(); }};
+
+ this.buttonAdd('fontfamily', 'Change font family', false, dropdown);
+ },
+ setFontfamily: function (value)
+ {
+ this.inlineSetStyle('font-family', value);
+ },
+ resetFontfamily: function()
+ {
+ this.inlineRemoveStyle('font-family');
+ }
+};
\ No newline at end of file
diff --git a/app/assets/javascripts/shared/jquery-ui.js b/app/assets/javascripts/shared/jquery-ui.js
new file mode 100755
index 0000000..14c9064
--- /dev/null
+++ b/app/assets/javascripts/shared/jquery-ui.js
@@ -0,0 +1,791 @@
+/*!
+ * jQuery UI 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI
+ */
+(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16",
+keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=
+this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,
+"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":
+"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,
+outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,
+"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&
+a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
+false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
+;/*
+ * jQuery UI Position 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Position
+ */
+(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
+left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
+k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
+m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
+d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
+a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
+g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
+;/*
+ * jQuery UI Draggable 1.8.16
+ *
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * http://docs.jquery.com/UI/Draggables
+ *
+ * Depends:
+ * jquery.ui.core.js
+ * jquery.ui.mouse.js
+ * jquery.ui.widget.js
+ */
+(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
+"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
+this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;if(b.iframeFix)d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options;
+this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
+this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true},
+_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=
+false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,
+10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||
+!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&
+a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=
+this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
+10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
+10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
+(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!=
+"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),
+10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+
+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&
+!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.leftg[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.topg[3])?h:!(h-this.offset.click.topg[2])?e:!(e-this.offset.click.left=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e=j&&f<=l||h>=j&&h<=l||fl)&&(e>=
+i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f