Changeset 9097
- Timestamp:
- 10/29/2014 12:36:09 AM (10 years ago)
- Location:
- trunk/src/bp-core/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/js/jquery.atwho.js
-
Property
svn:executable
set to
*
r8958 r9097 1 /*! jquery.atwho - v0.5. 0 - 2014-07-141 /*! jquery.atwho - v0.5.1 - 2014-09-21 2 2 * Copyright (c) 2014 chord.luo <chord.luo@gmail.com>; 3 3 * homepage: http://ichord.github.com/At.js … … 14 14 })(function($) { 15 15 16 var $CONTAINER,Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View,16 var Api, App, Controller, DEFAULT_CALLBACKS, KEY_CODE, Model, View, 17 17 __slice = [].slice; 18 18 … … 23 23 this.alias_maps = {}; 24 24 this.$inputor = $(inputor); 25 this.iframe = null;26 25 this.setIframe(); 27 26 this.listen(); 28 27 } 29 28 30 App.prototype.setIframe = function(iframe) { 29 App.prototype.createContainer = function(doc) { 30 if ((this.$el = $("#atwho-container", doc)).length === 0) { 31 return $(doc.body).append(this.$el = $("<div id='atwho-container'></div>")); 32 } 33 }; 34 35 App.prototype.setIframe = function(iframe, standalone) { 36 var _ref; 37 if (standalone == null) { 38 standalone = false; 39 } 31 40 if (iframe) { 32 41 this.window = iframe.contentWindow; 33 42 this.document = iframe.contentDocument || this.window.document; 34 returnthis.iframe = iframe;43 this.iframe = iframe; 35 44 } else { 36 45 this.document = document; 37 46 this.window = window; 38 return this.iframe = null; 47 this.iframe = null; 48 } 49 if (this.iframeStandalone = standalone) { 50 if ((_ref = this.$el) != null) { 51 _ref.remove(); 52 } 53 return this.createContainer(this.document); 54 } else { 55 return this.createContainer(document); 39 56 } 40 57 }; … … 113 130 delete this.controllers[_]; 114 131 } 115 return this.$inputor.off('.atwhoInner'); 132 this.$inputor.off('.atwhoInner'); 133 return this.$el.remove(); 116 134 }; 117 135 … … 226 244 this.cur_rect = null; 227 245 this.range = null; 228 $CONTAINER.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>")); 246 if ((this.$el = $("#atwho-ground-" + this.id, this.app.$el)).length === 0) { 247 this.app.$el.append(this.$el = $("<div id='atwho-ground-" + this.id + "'></div>")); 248 } 229 249 this.model = new Model(this); 230 250 this.view = new View(this); … … 314 334 315 335 Controller.prototype.rect = function() { 316 var c, scale_bottom;336 var c, iframe_offset, scale_bottom; 317 337 if (!(c = this.$inputor.caret('offset', this.pos - 1, { 318 338 iframe: this.app.iframe … … 320 340 return; 321 341 } 322 if (this.$inputor.attr('contentEditable') === 'true') { 323 c = (this.cur_rect || (this.cur_rect = c)) || c; 342 if (this.app.iframe && !this.app.iframeStandalone) { 343 iframe_offset = $(this.app.iframe).offset(); 344 c.left += iframe_offset.left; 345 c.top += iframe_offset.top; 346 } 347 if (this.$inputor.is('[contentEditable]')) { 348 c = this.cur_rect || (this.cur_rect = c); 324 349 } 325 350 scale_bottom = this.app.document.selection ? 0 : 2; … … 332 357 333 358 Controller.prototype.reset_rect = function() { 334 if (this.$inputor. attr('contentEditable') === 'true') {359 if (this.$inputor.is('[contentEditable]')) { 335 360 return this.cur_rect = null; 336 361 } … … 338 363 339 364 Controller.prototype.mark_range = function() { 340 if (this.$inputor.attr('contentEditable') === 'true') { 341 if (this.app.window.getSelection) { 342 this.range = this.app.window.getSelection().getRangeAt(0); 343 } 344 if (this.app.document.selection) { 345 return this.ie8_range = this.app.document.selection.createRange(); 346 } 365 var sel; 366 if (!this.$inputor.is('[contentEditable]')) { 367 return; 368 } 369 if (this.app.window.getSelection && (sel = this.app.window.getSelection()).rangeCount > 0) { 370 return this.range = sel.getRangeAt(0); 371 } else if (this.app.document.selection) { 372 return this.ie8_range = this.app.document.selection.createRange(); 347 373 } 348 374 }; … … 542 568 543 569 View.prototype.reposition = function(rect) { 544 var offset, _ref; 545 if (rect.bottom + this.$el.height() - $(window).scrollTop() > $(window).height()) { 570 var offset, overflowOffset, _ref, _window; 571 _window = this.context.app.iframeStandalone ? this.context.app.window : window; 572 if (rect.bottom + this.$el.height() - $(_window).scrollTop() > $(_window).height()) { 546 573 rect.bottom = rect.top - this.$el.height(); 574 } 575 if (rect.left > (overflowOffset = $(_window).width() - this.$el.width() - 5)) { 576 rect.left = overflowOffset; 547 577 } 548 578 offset = { … … 678 708 flag = '(?:^|\\s)' + flag; 679 709 } 680 regexp = new RegExp(flag + '([A-Za-z 0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi');710 regexp = new RegExp(flag + '([A-Za-zÀ-ÿ0-9_\+\-]*)$|' + flag + '([^\\x00-\\xff]*)$', 'gi'); 681 711 match = regexp.exec(subtext); 682 712 if (match) { … … 691 721 for (_i = 0, _len = data.length; _i < _len; _i++) { 692 722 item = data[_i]; 693 if (~ item[search_key].toLowerCase().indexOf(query.toLowerCase())) {723 if (~new String(item[search_key]).toLowerCase().indexOf(query.toLowerCase())) { 694 724 _results.push(item); 695 725 } … … 706 736 for (_i = 0, _len = items.length; _i < _len; _i++) { 707 737 item = items[_i]; 708 item.atwho_order = item[search_key].toLowerCase().indexOf(query.toLowerCase());738 item.atwho_order = new String(item[search_key]).toLowerCase().indexOf(query.toLowerCase()); 709 739 if (item.atwho_order > -1) { 710 740 _results.push(item); … … 767 797 } 768 798 }, 769 setIframe: function(iframe ) {770 this.setIframe(iframe );799 setIframe: function(iframe, standalone) { 800 this.setIframe(iframe, standalone); 771 801 return null; 772 802 }, … … 780 810 }; 781 811 782 $CONTAINER = $("<div id='atwho-container'></div>");783 784 812 $.fn.atwho = function(method) { 785 813 var result, _args; 786 814 _args = arguments; 787 $('body').append($CONTAINER);788 815 result = null; 789 this.filter('textarea, input, [contenteditable= true]').each(function() {816 this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function() { 790 817 var $this, app; 791 818 if (!(app = ($this = $(this)).data("atwho"))) { -
Property
svn:executable
set to
-
trunk/src/bp-core/js/jquery.caret.js
-
Property
svn:executable
set to
*
r8958 r9097 37 37 38 38 EditableCaret.prototype.getIEPosition = function() { 39 return $.noop();39 return this.getPosition(); 40 40 }; 41 41 42 42 EditableCaret.prototype.getPosition = function() { 43 return $.noop(); 43 var inputor_offset, offset; 44 offset = this.getOffset(); 45 inputor_offset = this.$inputor.offset(); 46 offset.left -= inputor_offset.left; 47 offset.top -= inputor_offset.top; 48 return offset; 44 49 }; 45 50 … … 98 103 offset = this.getOldIEOffset(); 99 104 } 100 if (offset && !oFrame) {105 if (offset) { 101 106 offset.top += $(oWindow).scrollTop(); 102 107 offset.left += $(oWindow).scrollLeft(); … … 207 212 $inputor = this.$inputor; 208 213 format = function(value) { 209 return value.replace(/</g, '<').replace(/>/g, '>').replace(/`/g, '`').replace(/"/g, '"').replace(/\r\n|\r|\n/g, "<br />");214 return $('<div></div>').text(value).html(); 210 215 }; 211 216 if (pos === void 0) { … … 308 313 }, 309 314 offset: function(pos) { 310 var iOffset,offset;315 var offset; 311 316 offset = this.getOffset(pos); 312 if (oFrame) {313 iOffset = $(oFrame).offset();314 offset.top += iOffset.top;315 offset.left += iOffset.left;316 }317 317 return offset; 318 318 } -
Property
svn:executable
set to
Note: See TracChangeset
for help on using the changeset viewer.