diff --git a/pub/System/Html5EditContrib/hallo.css b/pub/System/Html5EditContrib/hallo.css index a59b97d..0b6316d 100644 --- a/pub/System/Html5EditContrib/hallo.css +++ b/pub/System/Html5EditContrib/hallo.css @@ -1,4 +1,3 @@ - div.hallotoolbar { border: 1px solid #babdb6; padding: 2px; @@ -6,69 +5,107 @@ div.hallotoolbar { border-radius: 6px; font-size: 12pt; line-height: 1.1em; - width: 260px; - z-index: 99999; - display: block; + z-index: 500; } -div.hallotoolbar input { - display: none; +div.halloEditIndicator { + background-color: #000000; + color: #ffffff; + padding: 4px; + border-radius: 4px; } -div.hallotoolbar .ui-buttonset, -div.hallotoolbar .ui-buttonset label { - display: inline; + +/* Drag n Drop */ +[contenteditable] .tmp { + opacity: 0.3 } -div.hallotoolbar .dropdown-menu { +[contenteditable] .tmpLine{ + background-color: #ffffff; + width: 98%; + height: 2px; + margin: 0 auto 10px auto; + border-top: 2px solid #1cb8d6; + border-bottom: 2px solid #1cb8d6; + opacity: 1; + padding: 1px; +} + +.dropdown-menu { width: "200px"; background-color: #eeeeec; - margin-top: -1px; - border-left: 1px solid #babdb6; - border-bottom: 1px solid #babdb6; - border-right: 1px solid #babdb6; - border-bottom-left-radius: 6px; - border-bottom-right-radius: 6px; } -div.hallotoolbar .dropdown-menu .selected { +.dropdown-target .selected { background-color: #729fcf; } -textarea#source { - width: 100%; - min-height: 400px; - color: #ffffff !important; - background-color: #2e3436; - border: none; - border-radius: 8px; - font-weight: bold; +button.blockselector, button.blockselector:focus{ + display:block; + width: 100%; + margin:0px; + padding: 0px; + background: transparent; + border: none; + -moz-appearance: none; + -webkit-appearance: none; + outline: none; } -[contenteditable="true"].inEditMode { - outline-style: auto; - outline-width: 3px; - outline-color: #111111; +.bigOverlay, .smallOverlay { + display: none; + position: absolute; + top: 0; + left: 0; + background-color: rgba(28, 184, 214, 0.4); } -/* ANNOTATIONS */ -.inEditMode .entity, .inEditMode a[typeof][about] { - border-bottom: 1px #729fcf dotted; +.bigOverlayRight{ + display : block; + border-right : 3px dashed rgb(28, 184, 214); + border-left : none; } -.inEditMode .entity.withSuggestions { - border-color: #73d216; - border-bottom-style: double; + +.bigOverlayLeft{ + display : block; + border-left : 3px dashed rgb(28, 184, 214); + border-right : none; } -.inEditMode .entity.person, .inEditMode a[typeof][about].person { - border-color: #e9b96e; +.smallOverlayLeft{ + border-right : 3px dashed rgb(28, 184, 214); } -.inEditMode .entity.place, .inEditMode a[typeof][about].place { - border-color: #c17d11; +.smallOverlayRight{ + border-left : 3px dashed rgb(28, 184, 214); } -.inEditMode .entity.organisation, .inEditMode a[typeof][about].organisation { - border-color: #8f5902; +.ui-draggable{ + cursor: move; } +.ui-draggable-dragging{ + border: 3px solid white; +} + +[contenteditable] img.ui-state-disabled { + opacity: 1; +} +.customHelper{ + background-size: cover; + width: 100px; + height: 100px; + z-index: 1050; +} + +.trashcan{ + width: 50px; + height: 50px; + position: relative; + top: 25px; + left: 25px; + background: rgba(0,0,0,0.8) url('images/trash.png') no-repeat 12px 12px; + border-radius: 10px; + cursor: none; +} diff --git a/pub/System/Html5EditContrib/hallo.js b/pub/System/Html5EditContrib/hallo.js index b19e9d5..99e78b6 100644 --- a/pub/System/Html5EditContrib/hallo.js +++ b/pub/System/Html5EditContrib/hallo.js @@ -11,11 +11,12 @@ http://hallojs.org (function() { (function(jQuery) { - return jQuery.widget("IKS.hallo", { + return jQuery.widget('IKS.hallo', { toolbar: null, bound: false, - originalContent: "", - uuid: "", + originalContent: '', + previousContent: '', + uuid: '', selection: null, _keepActivated: false, originalHref: null, @@ -25,13 +26,20 @@ http://hallojs.org toolbar: 'halloToolbarContextual', parentElement: 'body', buttonCssClass: null, + toolbarCssClass: null, + toolbarPositionAbove: false, placeholder: '', - forceStructured: true + forceStructured: true, + checkTouch: true, + touchScreen: null }, _create: function() { var options, plugin, _ref, _this = this; this.id = this._generateUUID(); + if (this.options.checkTouch && this.options.touchScreen === null) { + this.checkTouch(); + } _ref = this.options.plugins; for (plugin in _ref) { options = _ref[plugin]; @@ -57,15 +65,31 @@ http://hallojs.org return this.disable(); } }, + destroy: function() { + var options, plugin, _ref; + this.disable(); + if (this.toolbar) { + this.toolbar.remove(); + this.element[this.options.toolbar]('destroy'); + } + _ref = this.options.plugins; + for (plugin in _ref) { + options = _ref[plugin]; + jQuery(this.element)[plugin]('destroy'); + } + return jQuery.Widget.prototype.destroy.call(this); + }, disable: function() { var _this = this; this.element.attr("contentEditable", false); - this.element.unbind("focus", this._activated); - this.element.unbind("blur", this._deactivated); - this.element.unbind("keyup paste change", this._checkModified); - this.element.unbind("keyup", this._keys); - this.element.unbind("keyup mouseup", this._checkSelection); + this.element.off("focus", this._activated); + this.element.off("blur", this._deactivated); + this.element.off("keyup paste change", this._checkModified); + this.element.off("keyup", this._keys); + this.element.off("keyup mouseup", this._checkSelection); this.bound = false; + jQuery(this.element).removeClass('isModified'); + jQuery(this.element).removeClass('inEditMode'); this.element.parents('a').andSelf().each(function(idx, elem) { var element; element = jQuery(elem); @@ -80,8 +104,7 @@ http://hallojs.org return this._trigger("disabled", null); }, enable: function() { - var widget, - _this = this; + var _this = this; this.element.parents('a[href]').andSelf().each(function(idx, elem) { var element; element = jQuery(elem); @@ -94,14 +117,17 @@ http://hallojs.org this.element.attr("contentEditable", true); if (!this.element.html()) { this.element.html(this.options.placeholder); + this.element.css({ + 'min-width': this.element.innerWidth(), + 'min-height': this.element.innerHeight() + }); } if (!this.bound) { - this.element.bind("focus", this, this._activated); - this.element.bind("blur", this, this._deactivated); - this.element.bind("keyup paste change", this, this._checkModified); - this.element.bind("keyup", this, this._keys); - this.element.bind("keyup mouseup", this, this._checkSelection); - widget = this; + this.element.on("focus", this, this._activated); + this.element.on("blur", this, this._deactivated); + this.element.on("keyup paste change", this, this._checkModified); + this.element.on("keyup", this, this._keys); + this.element.on("keyup mouseup", this, this._checkSelection); this.bound = true; } if (this.options.forceStructured) { @@ -112,33 +138,26 @@ http://hallojs.org activate: function() { return this.element.focus(); }, + containsSelection: function() { + var range; + range = this.getSelection(); + return this.element.has(range.startContainer).length > 0; + }, getSelection: function() { - var range, userSelection; - if (jQuery.browser.msie) { - range = document.selection.createRange(); + var range, sel; + sel = rangy.getSelection(); + range = null; + if (sel.rangeCount > 0) { + range = sel.getRangeAt(0); } else { - if (window.getSelection) { - userSelection = window.getSelection(); - } else if (document.selection) { - userSelection = document.selection.createRange(); - } else { - throw "Your browser does not support selection handling"; - } - if (userSelection.rangeCount > 0) { - range = userSelection.getRangeAt(0); - } else { - range = userSelection; - } + range = rangy.createRange(); } return range; }, restoreSelection: function(range) { - if (jQuery.browser.msie) { - return range.select(); - } else { - window.getSelection().removeAllRanges(); - return window.getSelection().addRange(range); - } + var sel; + sel = rangy.getSelection(); + return sel.setSingleRange(range); }, replaceSelection: function(cb) { var newTextNode, r, range, sel, t; @@ -164,9 +183,13 @@ http://hallojs.org } }, getContents: function() { - var contentClone, plugin; + var cleanup, contentClone, plugin; contentClone = this.element.clone(); for (plugin in this.options.plugins) { + cleanup = jQuery(this.element).data(plugin).cleanupContentClone; + if (!jQuery.isFunction(cleanup)) { + continue; + } jQuery(this.element)[plugin]('cleanupContentClone', contentClone); } return contentClone.html(); @@ -175,12 +198,17 @@ http://hallojs.org return this.element.html(contents); }, isModified: function() { - return this.originalContent !== this.getContents(); + if (!this.previousContent) { + this.previousContent = this.originalContent; + } + return this.previousContent !== this.getContents(); }, setUnmodified: function() { - return this.originalContent = this.getContents(); + jQuery(this.element).removeClass('isModified'); + return this.previousContent = this.getContents(); }, setModified: function() { + jQuery(this.element).addClass('isModified'); return this._trigger('modified', null, { editable: this, content: this.getContents() @@ -195,13 +223,12 @@ http://hallojs.org } }, protectFocusFrom: function(el) { - var widget; - widget = this; - return el.bind("mousedown", function(event) { + var _this = this; + return el.on("mousedown", function(event) { event.preventDefault(); - widget._protectToolbarFocus = true; + _this._protectToolbarFocus = true; return setTimeout(function() { - return widget._protectToolbarFocus = false; + return _this._protectToolbarFocus = false; }, 300); }); }, @@ -216,19 +243,47 @@ http://hallojs.org return "" + (S4()) + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + "-" + (S4()) + (S4()) + (S4()); }, _prepareToolbar: function() { - var plugin; + var plugin, populate; this.toolbar = jQuery('
').hide(); - jQuery(this.element)[this.options.toolbar]({ + if (this.options.toolbarCssClass) { + this.toolbar.addClass(this.options.toolbarCssClass); + } + this.element[this.options.toolbar]({ editable: this, parentElement: this.options.parentElement, - toolbar: this.toolbar + toolbar: this.toolbar, + positionAbove: this.options.toolbarPositionAbove }); for (plugin in this.options.plugins) { - jQuery(this.element)[plugin]('populateToolbar', this.toolbar); + populate = jQuery(this.element).data(plugin).populateToolbar; + if (!jQuery.isFunction(populate)) { + continue; + } + this.element[plugin]('populateToolbar', this.toolbar); } - jQuery(this.element)[this.options.toolbar]('setPosition'); + this.element[this.options.toolbar]('setPosition'); return this.protectFocusFrom(this.toolbar); }, + changeToolbar: function(element, toolbar, hide) { + var originalToolbar; + if (hide == null) { + hide = false; + } + originalToolbar = this.options.toolbar; + this.options.parentElement = element; + if (toolbar) { + this.options.toolbar = toolbar; + } + if (!this.toolbar) { + return; + } + this.element[originalToolbar]('destroy'); + this.toolbar.remove(); + this._prepareToolbar(); + if (hide) { + return this.toolbar.hide(); + } + }, _checkModified: function(event) { var widget; widget = event.data; @@ -251,7 +306,19 @@ http://hallojs.org } }, _rangesEqual: function(r1, r2) { - return r1.startContainer === r2.startContainer && r1.startOffset === r2.startOffset && r1.endContainer === r2.endContainer && r1.endOffset === r2.endOffset; + if (r1.startContainer !== r2.startContainer) { + return false; + } + if (r1.startOffset !== r2.startOffset) { + return false; + } + if (r1.endContainer !== r2.endContainer) { + return false; + } + if (r1.endOffset !== r2.endOffset) { + return false; + } + return true; }, _checkSelection: function(event) { var widget; @@ -306,11 +373,11 @@ http://hallojs.org this.setContents(''); } jQuery(this.element).addClass('inEditMode'); - return this._trigger("activated", this); + return this._trigger("activated", null, this); }, turnOff: function() { jQuery(this.element).removeClass('inEditMode'); - this._trigger("deactivated", this); + this._trigger("deactivated", null, this); if (!this.getContents()) { return this.setContents(this.options.placeholder); } @@ -344,6 +411,9 @@ http://hallojs.org } } } + }, + checkTouch: function() { + return this.options.touchScreen = !!('createTouch' in document); } }); })(jQuery); @@ -355,6 +425,13 @@ http://hallojs.org className: 'halloEditIndicator' }, _create: function() { + var _this = this; + return this.element.on('halloenabled', function() { + return _this.buildIndicator(); + }); + }, + populateToolbar: function() {}, + buildIndicator: function() { var editButton; editButton = jQuery('
Edit
'); editButton.addClass(this.options.className); @@ -365,12 +442,15 @@ http://hallojs.org }, bindIndicator: function(indicator) { var _this = this; - indicator.bind('click', function() { + indicator.on('click', function() { return _this.options.editable.element.focus(); }); - this.element.bind('halloactivated', function() { + this.element.on('halloactivated', function() { return indicator.hide(); }); + this.element.on('hallodisabled', function() { + return indicator.remove(); + }); return this.options.editable.element.hover(function() { if (jQuery(this).hasClass('inEditMode')) { return; @@ -389,13 +469,362 @@ http://hallojs.org setIndicatorPosition: function(indicator) { var offset; indicator.css('position', 'absolute'); - offset = this.element.offset(); + offset = this.element.position(); indicator.css('top', offset.top + 2); return indicator.css('left', offset.left + 2); } }); })(jQuery); + $.widget("ncri.hallo-image-insert-edit", { + options: { + editable: null, + toolbar: null, + uuid: "", + insert_file_dialog_ui_url: null, + lang: 'en', + dialogOpts: { + autoOpen: false, + width: 560, + height: 'auto', + modal: false, + resizable: true, + draggable: true, + dialogClass: 'insert-image-dialog' + }, + dialog: null, + buttonCssClass: null + }, + translations: { + en: { + title_insert: 'Insert Image', + title_properties: 'Image Properties', + insert: 'Insert', + chage_image: 'Change Image:', + source: 'URL', + width: 'Width', + height: 'Height', + alt: 'Alt Text', + padding: 'Padding', + float: 'Float', + float_left: 'left', + float_right: 'right', + float_none: 'No' + }, + de: { + title_insert: 'Bild einfügen', + title_properties: 'Bildeigenschaften', + insert: 'Einfügen', + chage_image: 'Bild ändern:', + source: 'URL', + width: 'Breite', + height: 'Höhe', + alt: 'Alt Text', + padding: 'Padding', + float: 'Float', + float_left: 'Links', + float_right: 'Rechts', + float_none: 'Nein' + } + }, + texts: null, + dialog_image_selection_ui_loaded: false, + $image: null, + populateToolbar: function($toolbar) { + var $buttonHolder, $buttonset, dialog_html, widget; + widget = this; + this.texts = this.translations[this.options.lang]; + this.options.toolbar = $toolbar; + dialog_html = "
"; + if (this.options.insert_file_dialog_ui_url) { + dialog_html += "
"; + } + this.options.dialog = $("
").attr('id', "" + this.options.uuid + "-insert-image-dialog").html(dialog_html); + $buttonset = $("").addClass(this.widgetName); + $buttonHolder = $(''); + $buttonHolder.hallobutton({ + label: this.texts.title_insert, + icon: 'icon-picture', + editable: this.options.editable, + command: null, + queryState: false, + uuid: this.options.uuid, + cssClass: this.options.buttonCssClass + }); + $buttonset.append($buttonHolder); + this.button = $buttonHolder; + this.button.click(function() { + if (widget.options.dialog.dialog("isOpen")) { + widget._closeDialog(); + } else { + widget.lastSelection = widget.options.editable.getSelection(); + widget._openDialog(); + } + return false; + }); + this.options.editable.element.on("halloselected, hallounselected", function() { + if (widget.options.dialog.dialog("isOpen")) { + return widget.lastSelection = widget.options.editable.getSelection(); + } + }); + this.options.editable.element.on("hallodeactivated", function() { + return widget._closeDialog(); + }); + $(this.options.editable.element).on("click", "img", function(e) { + widget._openDialog($(this)); + return false; + }); + this.options.editable.element.on('halloselected', function(event, data) { + var toolbar_option; + toolbar_option = widget.options.editable.options.toolbar; + if (toolbar_option === "halloToolbarContextual" && $(data.originalEvent.target).is('img')) { + $toolbar.hide(); + return false; + } + }); + $toolbar.append($buttonset); + return this.options.dialog.dialog(this.options.dialogOpts); + }, + _openDialog: function($image) { + var $editableEl, widget, xposition, yposition, + _this = this; + this.$image = $image; + widget = this; + $editableEl = $(this.options.editable.element); + xposition = $editableEl.offset().left + $editableEl.outerWidth() + 10; + if (this.$image) { + yposition = this.$image.offset().top - $(document).scrollTop(); + } else { + yposition = this.options.toolbar.offset().top - $(document).scrollTop(); + } + this.options.dialog.dialog("option", "position", [xposition, yposition]); + this.options.editable.keepActivated(true); + this.options.dialog.dialog("open"); + if (this.$image) { + this.options.dialog.dialog("option", "title", this.texts.title_properties); + $(document).keyup(function(e) { + if (e.keyCode === 46 || e.keyCode === 8) { + $(document).off(); + widget._closeDialog(); + widget.$image.remove(); + widget.$image = null; + } + return e.preventDefault(); + }); + this.options.editable.element.on("click", function() { + widget.$image = null; + return widget._closeDialog(); + }); + } else { + this.options.dialog.children('#hallo_img_properties').hide(); + this.options.dialog.dialog("option", "title", this.texts.title_insert); + if ($('#hallo_img_file_select_title').length > 0) { + $('#hallo_img_file_select_title').text(''); + } + } + this._load_dialog_image_properties_ui(); + this.options.dialog.on('dialogclose', function() { + var scrollbar_pos; + $('label', _this.button).removeClass('ui-state-active'); + scrollbar_pos = $(document).scrollTop(); + _this.options.editable.element.focus(); + $(document).scrollTop(scrollbar_pos); + return _this.options.editable.keepActivated(false); + }); + if (this.options.insert_file_dialog_ui_url && !this.dialog_image_selection_ui_loaded) { + this.options.dialog.on('click', ".reload_link", function() { + widget._load_dialog_image_selection_ui(); + return false; + }); + this.options.dialog.on('click', '.file_preview img', function() { + var new_source; + if (widget.$image) { + new_source = $(this).attr('src').replace(/-thumb/, ''); + widget.$image.attr('src', new_source); + $('#hallo_img_source').val(new_source); + } else { + widget._insert_image($(this).attr('src').replace(/-thumb/, '')); + } + return false; + }); + return this._load_dialog_image_selection_ui(); + } + }, + _insert_image: function(source) { + this.options.editable.restoreSelection(this.lastSelection); + document.execCommand("insertImage", null, source); + this.options.editable.element.trigger('change'); + this.options.editable.removeAllSelections(); + return this._closeDialog(); + }, + _closeDialog: function() { + return this.options.dialog.dialog("close"); + }, + _load_dialog_image_selection_ui: function() { + var widget; + widget = this; + return $.ajax({ + url: this.options.insert_file_dialog_ui_url, + success: function(data, textStatus, jqXHR) { + var $properties, file_select_title, t; + file_select_title = ''; + $properties = widget.options.dialog.children('#hallo_img_properties'); + if ($properties.is(':visible')) { + file_select_title = widget.texts.change_image; + } + t = "
" + file_select_title + "
"; + widget.options.dialog.children('#hallo_img_file_select_ui').html(t + data); + return widget.dialog_image_selection_ui_loaded = true; + }, + beforeSend: function() { + return widget.options.dialog.children('#hallo_img_file_select_ui').html('
'); + } + }); + }, + _load_dialog_image_properties_ui: function() { + var $img_properties, button, height, html, widget, width; + widget = this; + $img_properties = this.options.dialog.children('#hallo_img_properties'); + if (this.$image) { + width = this.$image.is('[width]') ? this.$image.attr('width') : ''; + height = this.$image.is('[height]') ? this.$image.attr('height') : ''; + html = this._property_input_html('source', this.$image.attr('src'), { + label: this.texts.source + }) + this._property_input_html('alt', this.$image.attr('alt') || '', { + label: this.texts.alt + }) + this._property_row_html(this._property_input_html('width', width, { + label: this.texts.width, + row: false + }) + this._property_input_html('height', height, { + label: this.texts.height, + row: false + })) + this._property_input_html('padding', this.$image.css('padding'), { + label: this.texts.padding + }) + this._property_row_html(this._property_cb_html('float_left', this.$image.css('float') === 'left', { + label: this.texts.float_left, + row: false + }) + this._property_cb_html('float_right', this.$image.css('float') === 'right', { + label: this.texts.float_right, + row: false + }) + this._property_cb_html('unfloat', this.$image.css('float') === 'none', { + label: this.texts.float_none, + row: false + }), this.texts.float); + $img_properties.html(html); + $img_properties.show(); + } else { + if (!this.options.insert_file_dialog_ui_url) { + $img_properties.html(this._property_input_html('source', '', { + label: this.texts.source + })); + $img_properties.show(); + } + } + if (this.$image) { + if (!this.options.insert_file_dialog_ui_url) { + $('#insert_image_btn').remove(); + } + if ($('#hallo_img_file_select_title').length > 0) { + $('#hallo_img_file_select_title').text(this.texts.chage_image); + } + $('#hallo_img_properties #hallo_img_source').keyup(function() { + return widget.$image.attr('src', this.value); + }); + $('#hallo_img_properties #hallo_img_alt').keyup(function() { + return widget.$image.attr('alt', this.value); + }); + $('#hallo_img_properties #hallo_img_padding').keyup(function() { + return widget.$image.css('padding', this.value); + }); + $('#hallo_img_properties #hallo_img_height').keyup(function() { + widget.$image.css('height', this.value); + return widget.$image.attr('height', this.value); + }); + $('#hallo_img_properties #hallo_img_width').keyup(function() { + widget.$image.css('width', this.value); + return widget.$image.attr('width', this.value); + }); + $('#hallo_img_properties #hallo_img_float_left').click(function() { + if (!this.checked) { + return false; + } + widget.$image.css('float', 'left'); + $('#hallo_img_properties #hallo_img_float_right').removeAttr('checked'); + return $('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked'); + }); + $('#hallo_img_properties #hallo_img_float_right').click(function() { + if (!this.checked) { + return false; + } + widget.$image.css('float', 'right'); + $('#hallo_img_properties #hallo_img_unfloat').removeAttr('checked'); + return $('#hallo_img_properties #hallo_img_float_left').removeAttr('checked'); + }); + return $('#hallo_img_properties #hallo_img_unfloat').click(function() { + if (!this.checked) { + return false; + } + widget.$image.css('float', 'none'); + $('#hallo_img_properties #hallo_img_float_right').removeAttr('checked'); + return $('#hallo_img_properties #hallo_img_float_left').removeAttr('checked'); + }); + } else { + if (!this.options.insert_file_dialog_ui_url) { + button = ""; + $img_properties.after(button); + return $('#insert_image_btn').click(function() { + var $img_source; + $img_source = $('#hallo_img_properties #hallo_img_source'); + return widget._insert_image($img_source.val()); + }); + } + } + }, + _property_col_html: function(col_html) { + return "
" + col_html + "
"; + }, + _property_row_html: function(row_html, label) { + if (label == null) { + label = ''; + } + row_html = this._property_col_html(label) + this._property_col_html(row_html); + return "
" + row_html + "
"; + }, + _property_html: function(property_html, options) { + var entry; + if (options == null) { + options = {}; + } + if (options.row === false) { + if (options.label) { + entry = "" + options.label + " " + property_html; + property_html = "" + entry + ""; + } + return property_html; + } else { + entry = "" + property_html + ""; + return this._property_row_html(entry, options.label); + } + }, + _property_input_html: function(id, value, options) { + var text_field; + if (options == null) { + options = {}; + } + text_field = ""; + return this._property_html(text_field, options); + }, + _property_cb_html: function(id, checked, options) { + var cb, checked_attr; + if (options == null) { + options = {}; + } + checked_attr = checked ? 'checked=checked' : ''; + cb = ""; + return this._property_html(cb, options); + } + }); + (function(jQuery) { return jQuery.widget("IKS.hallolists", { options: { @@ -431,7 +860,7 @@ http://hallojs.org if (this.options.lists.unordered) { buttonize("Unordered", "UL"); } - buttonset.buttonset(); + buttonset.hallobuttonset(); return toolbar.append(buttonset); } }); @@ -446,27 +875,30 @@ http://hallojs.org headers: [1, 2, 3] }, populateToolbar: function(toolbar) { - var button, buttonize, buttonset, header, id, label, widget, _i, _len, _ref, + var button, buttonize, buttonset, header, id, label, markup, widget, _i, _len, _ref, _this = this; widget = this; buttonset = jQuery(""); id = "" + this.options.uuid + "-paragraph"; label = "P"; - buttonset.append(jQuery("").button()); + markup = " "; + buttonset.append(jQuery(markup).button()); button = jQuery("#" + id, buttonset); button.attr("hallo-command", "formatBlock"); - button.bind("change", function(event) { + button.on("change", function(event) { var cmd; cmd = jQuery(this).attr("hallo-command"); return widget.options.editable.execute(cmd, "P"); }); buttonize = function(headerSize) { + var buttonMarkup; label = "H" + headerSize; id = "" + _this.options.uuid + "-" + headerSize; - buttonset.append(jQuery("").button()); + buttonMarkup = " "; + buttonset.append(jQuery(buttonMarkup).button()); button = jQuery("#" + id, buttonset); button.attr("hallo-size", "H" + headerSize); - return button.bind("change", function(event) { + return button.on("change", function(event) { var size; size = jQuery(this).attr("hallo-size"); return widget.options.editable.execute("formatBlock", size); @@ -478,7 +910,7 @@ http://hallojs.org buttonize(header); } buttonset.buttonset(); - this.element.bind("keyup paste change mouseup", function(event) { + this.element.on("keyup paste change mouseup", function(event) { var format, formatNumber, labelParent, matches, selectedButton; try { format = document.queryCommandValue("formatBlock").toUpperCase(); @@ -502,8 +934,7 @@ http://hallojs.org } }); return toolbar.append(buttonset); - }, - _init: function() {} + } }); })(jQuery); @@ -522,19 +953,19 @@ http://hallojs.org widget = this; if (!this.options.bound) { this.options.bound = true; - widget.options.editable.element.bind("halloactivated", function(event, data) { + this.options.editable.element.on("halloactivated", function(event, data) { widget.options.currentEditable = jQuery(event.target); if (!widget.options.visible) { return widget.showOverlay(); } }); - widget.options.editable.element.bind("hallomodified", function(event, data) { + this.options.editable.element.on("hallomodified", function(event, data) { widget.options.currentEditable = jQuery(event.target); if (widget.options.visible) { return widget.resizeOverlay(); } }); - return widget.options.editable.element.bind("hallodeactivated", function(event, data) { + return this.options.editable.element.on("hallodeactivated", function(event, data) { widget.options.currentEditable = jQuery(event.target); if (widget.options.visible) { return widget.hideOverlay(); @@ -542,24 +973,23 @@ http://hallojs.org }); } }, - _init: function() {}, showOverlay: function() { this.options.visible = true; if (this.options.overlay === null) { if (jQuery("#halloOverlay").length > 0) { this.options.overlay = jQuery("#halloOverlay"); } else { - this.options.overlay = jQuery('
'); + this.options.overlay = jQuery("
"); jQuery(document.body).append(this.options.overlay); } - this.options.overlay.bind('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable)); + this.options.overlay.on('click', jQuery.proxy(this.options.editable.turnOff, this.options.editable)); } this.options.overlay.show(); if (this.options.background === null) { if (jQuery("#halloBackground").length > 0) { this.options.background = jQuery("#halloBackground"); } else { - this.options.background = jQuery('
'); + this.options.background = jQuery("
"); jQuery(document.body).append(this.options.background); } } @@ -573,12 +1003,12 @@ http://hallojs.org resizeOverlay: function() { var offset; offset = this.options.currentEditable.offset(); - this.options.background.css({ + return this.options.background.css({ top: offset.top - this.options.padding, - left: offset.left - this.options.padding + left: offset.left - this.options.padding, + width: this.options.currentEditable.width() + 2 * this.options.padding, + height: this.options.currentEditable.height() + 2 * this.options.padding }); - this.options.background.width(this.options.currentEditable.width() + 2 * this.options.padding); - return this.options.background.height(this.options.currentEditable.height() + 2 * this.options.padding); }, hideOverlay: function() { this.options.visible = false; @@ -619,9 +1049,6 @@ http://hallojs.org
\ \
\ - \
'); this.element.hide(); return this._prepareDnD(); @@ -631,7 +1058,6 @@ http://hallojs.org editable = jQuery(this.options.editable.element); widget = this; jQuery('img', editable).each(function(index, elem) { - elem.contentEditable = false; return widget._initDraggable(elem, editable); }); return jQuery('p', editable).each(function(index, elem) { @@ -668,13 +1094,15 @@ http://hallojs.org width: this.options.third * 2, height: editable.height() }), - left: jQuery("
").addClass("smallOverlay smallOverlayLeft").css(overlayMiddleConfig), - right: jQuery("
").addClass("smallOverlay smallOverlayRight").css(overlayMiddleConfig).css("left", this.options.third * 2) + left: jQuery("
").addClass("smallOverlay smallOverlayLeft"), + right: jQuery("
").addClass("smallOverlay smallOverlayRight") }; - editable.bind('halloactivated', function() { + this.overlay.left.css(overlayMiddleConfig); + this.overlay.right.css(overlayMiddleConfig).css("left", this.options.third * 2); + editable.on('halloactivated', function() { return widget._enableDragging(); }); - return editable.bind('hallodeactivated', function() { + return editable.on('hallodeactivated', function() { return widget._disableDragging(); }); }, @@ -686,7 +1114,6 @@ http://hallojs.org jQuery('.activeImage', this.element).attr('src', image.url); if (image.label) { jQuery('input', this.element).val(image.label); - jQuery('.metadata', this.element).show(); } return this._initImage(jQuery(this.options.editable.element)); }, @@ -698,45 +1125,27 @@ http://hallojs.org } }, _calcDropPosition: function(offset, event) { - var position; + var position, rightTreshold; position = offset.left + this.options.third; - if (event.pageX >= position && event.pageX <= (offset.left + this.options.third * 2)) { + rightTreshold = offset.left + this.options.third * 2; + if (event.pageX >= position && event.pageX <= rightTreshold) { return 'middle'; } else if (event.pageX < position) { return 'left'; - } else if (event.pageX > (offset.left + this.options.third * 2)) { + } else if (event.pageX > rightTreshold) { return 'right'; } }, _createInsertElement: function(image, tmp) { - var imageInsert, maxHeight, maxWidth, tmpImg; + var imageInsert, tmpImg; imageInsert = jQuery(''); tmpImg = new Image(); - maxWidth = this.options.maxWidth; - maxHeight = this.options.maxHeight; - jQuery(tmpImg).bind('load', function() { - var height, ratio, width; - width = tmpImg.width; - height = tmpImg.height; - if (width > maxWidth || height > maxHeight) { - if (width > height) { - ratio = (tmpImg.width / maxWidth).toFixed(); - } else { - ratio = (tmpImg.height / maxHeight).toFixed(); - } - width = (tmpImg.width / ratio).toFixed(); - height = (tmpImg.height / ratio).toFixed(); - } - return imageInsert.attr({ - width: width, - height: height - }); - }); + jQuery(tmpImg).on('load', function() {}); tmpImg.src = image.src; imageInsert.attr({ src: tmpImg.src, alt: !tmp ? jQuery(image).attr('alt') : void 0, - "class": tmp ? 'halloTmp' : '' + "class": tmp ? 'halloTmp' : 'imageInText' }); imageInsert.show(); return imageInsert; @@ -745,6 +1154,9 @@ http://hallojs.org return jQuery('
').addClass('halloTmpLine'); }, _removeFeedbackElements: function() { + this.overlay.big.remove(); + this.overlay.left.remove(); + this.overlay.right.remove(); return jQuery('.halloTmp, .halloTmpLine', this.options.editable.element).remove(); }, _removeCustomHelper: function() { @@ -753,7 +1165,9 @@ http://hallojs.org _showOverlay: function(position) { var eHeight, editable; editable = jQuery(this.options.editable.element); - eHeight = editable.height() + parseFloat(editable.css('paddingTop')) + parseFloat(editable.css('paddingBottom')); + eHeight = editable.height(); + eHeight += parseFloat(editable.css('paddingTop')); + eHeight += parseFloat(editable.css('paddingBottom')); this.overlay.big.css({ height: eHeight }); @@ -765,9 +1179,12 @@ http://hallojs.org }); switch (position) { case 'left': - this.overlay.big.addClass("bigOverlayLeft").removeClass("bigOverlayRight").css({ + this.overlay.big.addClass("bigOverlayLeft"); + this.overlay.big.removeClass("bigOverlayRight"); + this.overlay.big.css({ left: this.options.third - }).show(); + }); + this.overlay.big.show(); this.overlay.left.hide(); return this.overlay.right.hide(); case 'middle': @@ -776,9 +1193,12 @@ http://hallojs.org this.overlay.left.show(); return this.overlay.right.show(); case 'right': - this.overlay.big.addClass("bigOverlayRight").removeClass("bigOverlayLeft").css({ + this.overlay.big.addClass("bigOverlayRight"); + this.overlay.big.removeClass("bigOverlayLeft"); + this.overlay.big.css({ left: 0 - }).show(); + }); + this.overlay.big.show(); this.overlay.left.hide(); return this.overlay.right.hide(); } @@ -789,7 +1209,7 @@ http://hallojs.org } return false; }, - _createTmpFeedback: function(image, position) { + _createFeedback: function(image, position) { var el; if (position === 'middle') { return this._createLineFeedbackElement(); @@ -802,20 +1222,21 @@ http://hallojs.org widget = this; editable = jQuery(this.options.editable); postPone = function() { - var position; + var position, target; window.waitWithTrash = clearTimeout(window.waitWithTrash); position = widget._calcDropPosition(widget.options.offset, event); jQuery('.trashcan', ui.helper).remove(); - editable.append(widget.overlay.big); - editable.append(widget.overlay.left); - editable.append(widget.overlay.right); + editable[0].element.append(widget.overlay.big); + editable[0].element.append(widget.overlay.left); + editable[0].element.append(widget.overlay.right); widget._removeFeedbackElements(); - jQuery(event.target).prepend(widget._createTmpFeedback(ui.draggable[0], position)); + target = jQuery(event.target); + target.prepend(widget._createFeedback(ui.draggable[0], position)); if (position === 'middle') { - jQuery(event.target).prepend(widget._createTmpFeedback(ui.draggable[0], 'right')); + target.prepend(widget._createFeedback(ui.draggable[0], 'right')); jQuery('.halloTmp', event.target).hide(); } else { - jQuery(event.target).prepend(widget._createTmpFeedback(ui.draggable[0], 'middle')); + target.prepend(widget._createFeedback(ui.draggable[0], 'middle')); jQuery('.halloTmpLine', event.target).hide(); } return widget._showOverlay(position); @@ -836,7 +1257,9 @@ http://hallojs.org tmpFeedbackLR.hide(); } else { tmpFeedbackMiddle.hide(); - tmpFeedbackLR.removeClass('inlineImage-left inlineImage-right').addClass("inlineImage-" + position).show(); + tmpFeedbackLR.removeClass('inlineImage-left inlineImage-right'); + tmpFeedbackLR.addClass("inlineImage-" + position); + tmpFeedbackLR.show(); } return this._showOverlay(position); }, @@ -874,23 +1297,28 @@ http://hallojs.org return jQuery(document).trigger('stopPreventSave'); }, _handleDropEvent: function(event, ui) { - var editable, imageInsert, internalDrop, position; + var classes, editable, imageInsert, internalDrop, left, position; editable = jQuery(this.options.editable.element); internalDrop = this._checkOrigin(event); position = this._calcDropPosition(this.options.offset, event); this._removeFeedbackElements(); this._removeCustomHelper(); imageInsert = this._createInsertElement(ui.draggable[0], false); + classes = 'inlineImage-middle inlineImage-left inlineImage-right'; if (position === 'middle') { imageInsert.show(); - imageInsert.removeClass('inlineImage-middle inlineImage-left inlineImage-right'); + imageInsert.removeClass(classes); + left = editable.width(); + left += parseFloat(editable.css('paddingLeft')); + left += parseFloat(editable.css('paddingRight')); + left -= imageInsert.attr('width'); imageInsert.addClass("inlineImage-" + position).css({ position: 'relative', - left: ((editable.width() + parseFloat(editable.css('paddingLeft')) + parseFloat(editable.css('paddingRight'))) - imageInsert.attr('width')) / 2 + left: left / 2 }); imageInsert.insertBefore(jQuery(event.target)); } else { - imageInsert.removeClass('inlineImage-middle inlineImage-left inlineImage-right'); + imageInsert.removeClass(classes); imageInsert.addClass("inlineImage-" + position); imageInsert.css('display', 'block'); jQuery(event.target).prepend(imageInsert); @@ -965,9 +1393,10 @@ http://hallojs.org _create: function() { return this.element.html('\
\ - \ - \ - \ + \ + \ + \ + \
\ '); }, @@ -977,7 +1406,7 @@ http://hallojs.org if (widget.options.uploadUrl && !widget.options.uploadCallback) { widget.options.uploadCallback = widget._iframeUpload; } - return jQuery('.uploadSubmit', this.element).bind('click', function(event) { + return jQuery('.uploadSubmit', this.element).on('click', function(event) { event.preventDefault(); event.stopPropagation(); return widget.options.uploadCallback({ @@ -993,12 +1422,13 @@ http://hallojs.org }, _prepareIframe: function(widget) { var iframe, iframeName; - iframeName = ("" + widget.widgetName + "_postframe_" + widget.options.uuid).replace(/-/g, '_'); + iframeName = "" + widget.widgetName + "_postframe_" + widget.options.uuid; + iframeName = iframeName.replace(/-/g, '_'); iframe = jQuery("#" + iframeName); if (iframe.length) { return iframe; } - iframe = jQuery("