diff --git a/gulpfile.js b/gulpfile.js index b17c989..c3e18e3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -64,9 +64,9 @@ gulp.task('styles', function() { //build ditributable and sourcemaps after other tasks completed gulp.task('zip', ['html', 'scripts', 'styles', 'copy'], function() { - var manifest = require('./src/manifest'), - distFileName = manifest.name + ' v' + manifest.version + '.zip', - mapFileName = manifest.name + ' v' + manifest.version + '-maps.zip'; + var manifest = require('./src/manifest.json'), + distFileName = 'avim-chrome-' + manifest.version + '.zip', + mapFileName = 'avim-chrome-' + manifest.version + '-maps.zip'; //collect all source maps gulp.src('build/scripts/**/*.map') .pipe(zip(mapFileName)) @@ -80,4 +80,4 @@ gulp.task('zip', ['html', 'scripts', 'styles', 'copy'], function() { //run all tasks after build directory has been cleaned gulp.task('default', ['clean'], function() { gulp.start('zip'); -}); \ No newline at end of file +}); diff --git a/package.json b/package.json index ae0a7c1..c89c4e9 100644 --- a/package.json +++ b/package.json @@ -16,13 +16,13 @@ }, "homepage": "https://github.com/kimkha/avim-chrome", "devDependencies": { - "gulp-cleanhtml": "0.0.2", - "gulp-clean": "~0.3.1", - "gulp-minify-css": "~0.3.11", - "gulp-uglify": "~1.0.1", - "gulp-jshint": "~1.9.0", - "gulp-zip": "~2.0.2", - "gulp": "~3.8.10", - "gulp-strip-debug": "~1.0.1" + "gulp": "^3.8.11", + "gulp-clean": "^0.3.1", + "gulp-cleanhtml": "^0.1.0", + "gulp-jshint": "^1.10.0", + "gulp-minify-css": "^1.0.0", + "gulp-strip-debug": "^1.0.2", + "gulp-uglify": "^1.1.0", + "gulp-zip": "^3.0.2" } } diff --git a/src/scripts/avim.js b/src/scripts/avim.js index 50ef105..051488b 100644 --- a/src/scripts/avim.js +++ b/src/scripts/avim.js @@ -814,40 +814,40 @@ } word = unV(word); // TODO: NEW CODE - return; + //return; // TODO: OLD CODE - //if(!space && !AVIMObj.changed) { - // word += k; - //} + if(!AVIMObj.changed) { + word += k; + } - //var sp = AVIMObj.oc.selectionStart, pos = sp; - //if(!AVIMObj.changed) { - // var sst = AVIMObj.oc.scrollTop; - // pos += k.length; - // if(!AVIMObj.oc.data) { - // AVIMObj.oc.value = AVIMObj.oc.value.substr(0, sp) + k + AVIMObj.oc.value.substr(AVIMObj.oc.selectionEnd); - // AVIMObj.changed = true; - // AVIMObj.oc.scrollTop = sst; - // } else { - // AVIMObj.oc.insertData(AVIMObj.oc.pos, k); - // AVIMObj.oc.pos++; - // AVIMObj.range.setEnd(AVIMObj.oc, AVIMObj.oc.pos); - // AVIMObj.specialChange = true; - // } - //} - //if(!AVIMObj.oc.data) { - // AVIMObj.oc.setSelectionRange(pos, pos); - //} - //if(!ckspell(word, fS)) { - // replaceChar(AVIMObj.oc, i - j, c); - // if(!AVIMObj.oc.data) { - // var a = [AVIMObj.D]; - // main(word, fS, pos, a, false); - // } else { - // var ww = mozGetText(AVIMObj.oc), a = [AVIMObj.D]; - // main(ww[0], fS, ww[1], a, false); - // } - //} + var sp = AVIMObj.oc.selectionStart, pos = sp; + if(!AVIMObj.changed) { + var sst = AVIMObj.oc.scrollTop; + pos += k.length; + if(!AVIMObj.oc.data) { + AVIMObj.oc.value = AVIMObj.oc.value.substr(0, sp) + k + AVIMObj.oc.value.substr(AVIMObj.oc.selectionEnd); + AVIMObj.changed = true; + AVIMObj.oc.scrollTop = sst; + } else { + AVIMObj.oc.insertData(AVIMObj.oc.pos, k); + AVIMObj.oc.pos++; + AVIMObj.range.setEnd(AVIMObj.oc, AVIMObj.oc.pos); + AVIMObj.specialChange = true; + } + } + if(!AVIMObj.oc.data) { + AVIMObj.oc.setSelectionRange(pos, pos); + } + if(!ckspell(word, fS)) { + replaceChar(AVIMObj.oc, i - j, c); + var a = [AVIMObj.D]; + if(!AVIMObj.oc.data) { + main(word, fS, pos, a, false); + } else { + var ww = mozGetText(AVIMObj.oc); + main(ww[0], fS, ww[1], a, false); + } + } } } } @@ -890,65 +890,6 @@ } } - function ifMoz(e) { - // Init code for editable iframes and divs - var code = e.which, avim = AVIMObj.AVIM, cwi = e.target.parentNode.wi; - if(typeof(avim) == "undefined") avim = AVIMObj; - if(typeof(cwi) == "undefined") cwi = e.target.parentNode.parentNode.wi; - if(typeof(cwi) == "undefined") cwi = window; - if(e.ctrlKey || (e.altKey && (code != 92) && (code != 126))) return; - - // get current caret and its node - var sel = cwi.getSelection(); - var range = sel.getRangeAt(0); - var node = range.endContainer, newPos; - - avim.sk = fcc(code); - avim.saveStr = ""; - if(checkCode(code) || !range.startOffset || (typeof(node.data) == 'undefined')) return; - node.sel = false; - - if(node.data) { - avim.saveStr = node.data.substr(range.endOffset); - if(range.startOffset != range.endOffset) { - node.sel=true; - } - node.deleteData(range.startOffset, node.data.length); - } - - if(!node.data) { - range.setStart(node, 0); - range.setEnd(node, range.endOffset); - sel.removeAllRanges(); - sel.addRange(range); - return; - } - - node.value = node.data; - node.pos = node.data.length; - node.which=code; - start(node, e); - node.insertData(node.data.length, avim.saveStr); - newPos = node.data.length - avim.saveStr.length + avim.kl; - - // Set caret back to node - range.setStart(node, newPos); - range.setEnd(node, newPos); - sel.removeAllRanges(); - sel.addRange(range); - - avim.kl = 0; - if(avim.specialChange) { - avim.specialChange = false; - avim.changed = false; - node.deleteData(node.pos - 1, 1); - } - if(avim.changed) { - avim.changed = false; - e.preventDefault(); - } - } - function unV(word) { var u = repSign(null), b, a; for(a = 1; a <= word.length; a++) { @@ -1021,6 +962,65 @@ AVIMObj.range = sel ? sel.getRangeAt(0) : document.createRange(); }/**/ + function ifMoz(e) { + // Init code for editable iframes and divs + var code = e.which, avim = AVIMObj.AVIM, cwi = e.target.parentNode.wi; + if(typeof(avim) == "undefined") avim = AVIMObj; + if(typeof(cwi) == "undefined") cwi = e.target.parentNode.parentNode.wi; + if(typeof(cwi) == "undefined") cwi = window; + if(e.ctrlKey || (e.altKey && (code != 92) && (code != 126))) return; + + // get current caret and its node + var sel = cwi.getSelection(); + var range = sel.getRangeAt(0); + var node = range.endContainer, newPos; + + avim.sk = fcc(code); + avim.saveStr = ""; + if(checkCode(code) || !range.startOffset || (typeof(node.data) == 'undefined')) return; + node.sel = false; + + if(node.data) { + avim.saveStr = node.data.substr(range.endOffset); + if(range.startOffset != range.endOffset) { + node.sel=true; + } + node.deleteData(range.startOffset, node.data.length); + } + + if(!node.data) { + range.setStart(node, 0); + range.setEnd(node, range.endOffset); + sel.removeAllRanges(); + sel.addRange(range); + return; + } + + node.value = node.data; + node.pos = node.data.length; + node.which=code; + start(node, e); + node.insertData(node.data.length, avim.saveStr); + newPos = node.data.length - avim.saveStr.length + avim.kl; + + // Set caret back to node + range.setStart(node, newPos); + range.setEnd(node, newPos); + sel.removeAllRanges(); + sel.addRange(range); + + avim.kl = 0; + if(avim.specialChange) { + avim.specialChange = false; + avim.changed = false; + node.deleteData(node.pos - 1, 1); + } + if(avim.changed) { + avim.changed = false; + e.preventDefault(); + } + } + /*function FKeyPress() { var obj = findFrame(); AVIMObj.sk = fcc(obj.event.keyCode); @@ -1177,7 +1177,7 @@ } function AVIMInit(AVIM, isAttach) { - if(AVIM.support) { + /*if(AVIM.support) { AVIM.fID = document.getElementsByTagName("iframe"); for(AVIM.g = 0; AVIM.g < AVIM.fID.length; AVIM.g++) { if(findIgnore(AVIM.fID[AVIM.g])) { @@ -1200,7 +1200,7 @@ } } catch(e) {} } - } + }*/ } function AVIMAJAXFix(counter) {