Moved to this.log().

This commit is contained in:
Martin Edenhofer 2015-02-17 16:25:22 +01:00
parent aacb930094
commit dfe7d33bd1
2 changed files with 37 additions and 18 deletions

View file

@ -10,6 +10,7 @@
var pluginName = 'ce',
defaults = {
debug: false,
mode: 'richtext',
multiline: true,
allowKey: {
@ -68,9 +69,9 @@
// handle enter
this.$element.on('keydown', function (e) {
console.log('keydown', e.keyCode)
_this.log('keydown', e.keyCode)
if ( _this.preventInput ) {
console.log('preventInput', _this.preventInput)
this.log('preventInput', _this.preventInput)
return
}
@ -95,7 +96,7 @@
// just paste text
this.$element.on('paste', function (e) {
console.log('paste')
_this.log('paste')
// check existing + paste text for limit
var text
@ -136,6 +137,7 @@
// disable rich text b/u/i
if ( this.options.mode === 'textonly' ) {
this.$element.on('keydown', function (e) {
var _this = this
if ( _this.richTextKey(e) ) {
e.preventDefault()
}
@ -179,7 +181,7 @@
if (typeAhead) {
length = length + typeAhead
}
console.log('maxLengthOk', length, this.options.maxlength)
this.log('maxLengthOk', length, this.options.maxlength)
if ( length > this.options.maxlength ) {
// try to set error on framework form
@ -234,6 +236,13 @@
return this.$element.html().trim()
}
// log method
Plugin.prototype.log = function() {
if (this.options.debug) {
console.log(this._name, arguments)
}
}
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {

View file

@ -10,7 +10,9 @@
*/
var pluginName = 'textmodule',
defaults = {}
defaults = {
debug: false
}
function Plugin( element, options ) {
this.element = element
@ -110,7 +112,7 @@
// backspace + buffer === :: -> close textmodule
if ( _this.buffer === '::' ) {
_this.close()
_this.close(true)
e.preventDefault()
return
}
@ -118,14 +120,14 @@
// reduce buffer and show new result
var length = _this.buffer.length
_this.buffer = _this.buffer.substr( 0, length-1 )
console.log('BS backspace', _this.buffer)
_this.log( 'BS backspace', _this.buffer )
_this.result( _this.buffer.substr( 2, length-1 ) )
}
})
// build buffer
this.$element.on('keypress', function (e) {
console.log('BUFF', _this.buffer, e.keyCode, String.fromCharCode(e.which) )
_this.log('BUFF', _this.buffer, e.keyCode, String.fromCharCode(e.which) )
// shift
if ( e.keyCode === 16 ) return
@ -156,9 +158,9 @@
var sign = String.fromCharCode(e.which)
if ( sign && sign !== ':' && e.which != 8 ) { // 8 == backspace
_this.buffer = _this.buffer + sign
//console.log('BUFF ADD', sign, this.buffer, sign.length, e.which)
//_this.log('BUFF ADD', sign, this.buffer, sign.length, e.which)
}
console.log('BUFF HINT', _this.buffer, _this.buffer.length, e.which, String.fromCharCode(e.which))
_this.log('BUFF HINT', _this.buffer, _this.buffer.length, e.which, String.fromCharCode(e.which))
b = $.proxy(function() {
this.result( this.buffer.substr(2,this.buffer.length) )
@ -228,11 +230,12 @@
}
// close widget
Plugin.prototype.close = function() {
Plugin.prototype.close = function(cutInput) {
this.$widget.removeClass('open')
if ( this.active ) {
if ( cutInput && this.active ) {
this.cutInput(true)
}
this.buffer = ''
this.active = false
}
@ -281,7 +284,7 @@
start = start - 1
}
}
//console.log('CUT FOR', string, "-"+clone.toString()+"-", start, range.startOffset)
//this.log('CUT FOR', string, "-"+clone.toString()+"-", start, range.startOffset)
clone.setStart(range.startContainer, start)
clone.setEnd(range.startContainer, range.startOffset)
clone.deleteContents()
@ -304,7 +307,7 @@
// select text module and insert into text
Plugin.prototype.take = function(id) {
if (!id) {
this.close()
this.close(true)
return
}
for (var i = 0; i < this.collection.length; i++) {
@ -313,7 +316,7 @@
var content = item.content
this.cutInput()
this.paste(content)
this.close()
this.close(true)
return
}
}
@ -348,7 +351,7 @@
})
this.$widget.find('ul').html('')
console.log('result', term, result)
this.log('result', term, result)
for (var i = 0; i < result.length; i++) {
var item = result[i]
var template = "<li><a href=\"#\" class=\"u-textTruncate\" data-id=" + item.id + ">" + App.Utils.htmlEscape(item.name)
@ -372,6 +375,13 @@
this.movePosition()
}
// log method
Plugin.prototype.log = function() {
if (this.options.debug) {
console.log(this._name, arguments)
}
}
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {