Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "bean", | ||
"description": "an events api for javascript", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "https://github.com/fat/bean", | ||
@@ -6,0 +6,0 @@ "authors": ["Jacob Thornton <@fat>"], |
@@ -20,6 +20,4 @@ !function () { | ||
listen: add, | ||
delegate: add, | ||
unbind: remove, | ||
unlisten: remove, | ||
undelegate: remove, | ||
trigger: integrate('fire'), | ||
@@ -49,2 +47,21 @@ cloneEvents: integrate('clone'), | ||
$.ender(methods, true); | ||
$.ender({ | ||
delegate: function (selector, type, fn) { | ||
var args = [].slice.call(arguments, 0), i, _args; | ||
args.push($); | ||
for (i = 0, l = this.length; i < l; i++) { | ||
_args = [this[i]].concat(args); | ||
b.add.apply(this, _args); | ||
} | ||
return this; | ||
}, | ||
undelegate: function (selector, type, fn) { | ||
var args = [].slice.call(arguments, 0), i, _args; | ||
for (i = 0, l = this.length; i < l; i++) { | ||
_args = [this[i]].concat(args); | ||
b.remove.apply(this, _args); | ||
} | ||
return this; | ||
} | ||
}, true); | ||
}(); |
@@ -10,5 +10,5 @@ (function(){ | ||
// this is for opera, so we don't have to focus to type how we think we would | ||
if(document.activeElement | ||
&& document.activeElement != el | ||
&& el.selectionStart == el.selectionEnd | ||
if(document.activeElement | ||
&& document.activeElement != el | ||
&& el.selectionStart == el.selectionEnd | ||
&& el.selectionStart == 0){ | ||
@@ -21,4 +21,4 @@ return {start: el.value.length, end: el.value.length}; | ||
//if(document.activeElement && document.activeElement != el){ | ||
//} | ||
@@ -30,3 +30,3 @@ try { | ||
r.setEndPoint("EndToStart", real); | ||
var start = r.text.length | ||
@@ -64,3 +64,3 @@ return { | ||
} | ||
} | ||
} | ||
}, | ||
@@ -74,3 +74,3 @@ // gets all focusable elements | ||
len = els.length; | ||
for(var i=0; i< len; i++){ | ||
@@ -80,4 +80,4 @@ Syn.isFocusable(els[i]) && els[i] != document.documentElement && res.push(els[i]) | ||
return res; | ||
}; | ||
@@ -95,8 +95,8 @@ | ||
* Syn('key','delete','title'); | ||
* | ||
* //or | ||
* | ||
* | ||
* //or | ||
* | ||
* Syn('type','One Two Three[left][left][delete]','title') | ||
* @codeend | ||
* | ||
* | ||
* The following are a list of keys you can type: | ||
@@ -133,12 +133,12 @@ * @codestart text | ||
'\b':'8', | ||
//tab | ||
'\t':'9', | ||
//enter | ||
'\r':'13', | ||
//special | ||
'shift':'16','ctrl':'17','alt':'18', | ||
//weird | ||
@@ -151,7 +151,7 @@ 'pause-break':'19', | ||
'print' : '44', | ||
//navigation | ||
'page-up':'33','page-down':'34','end':'35','home':'36', | ||
'left':'37','up':'38','right':'39','down':'40','insert':'45','delete':'46', | ||
//normal characters | ||
@@ -178,14 +178,14 @@ ' ':'32', | ||
"'":'222', | ||
//ignore these, you shouldn't use them | ||
'left window key':'91','right window key':'92','select key':'93', | ||
'f1':'112','f2':'113','f3':'114','f4':'115','f5':'116','f6':'117', | ||
'f7':'118','f8':'119','f9':'120','f10':'121','f11':'122','f12':'123' | ||
}, | ||
// what we can type in | ||
typeable : /input|textarea/i, | ||
// selects text on an element | ||
@@ -207,5 +207,5 @@ selectText: function( el, start, end ) { | ||
r.moveEnd('character', end - el.value.length); | ||
r.select(); | ||
} | ||
} | ||
}, | ||
@@ -247,3 +247,3 @@ getText: function( el ) { | ||
}, | ||
//returns the special key if special | ||
@@ -266,3 +266,3 @@ isSpecial: function( keyCode ) { | ||
var keyData = Syn.key.data(key); | ||
if(!keyData[event]){ | ||
@@ -272,7 +272,7 @@ //we shouldn't be creating this event | ||
} | ||
var charCode = keyData[event][0], | ||
keyCode = keyData[event][1], | ||
result = {}; | ||
if(keyCode == 'key'){ | ||
@@ -285,3 +285,3 @@ result.keyCode = Syn.keycodes[key] | ||
} | ||
if(charCode == 'char'){ | ||
@@ -292,4 +292,4 @@ result.charCode = key.charCodeAt(0) | ||
} | ||
return result | ||
@@ -323,3 +323,3 @@ }, | ||
} | ||
if(force || (!S.support.keyCharacters && Syn.typeable.test(this.nodeName))){ | ||
@@ -330,4 +330,4 @@ var current = this.value, | ||
character = key; | ||
console.log("setting",this.value,before, character, after) | ||
this.value = before+character+after; | ||
@@ -337,3 +337,3 @@ //handle IE inserting \r\n | ||
Syn.selectText(this, before.length + charLength) | ||
} | ||
} | ||
}, | ||
@@ -402,3 +402,3 @@ 'c' : function( options, scope, key, force, sel ) { | ||
after = current.substr(sel.end); | ||
if(sel.start == sel.end && sel.start > 0){ | ||
@@ -412,5 +412,5 @@ //remove a character | ||
} | ||
//set back the selection | ||
} | ||
} | ||
}, | ||
@@ -426,9 +426,9 @@ 'delete' : function( options, scope, key, force, sel ) { | ||
this.value = before+after; | ||
} | ||
Syn.selectText(this, sel.start) | ||
} | ||
} | ||
}, | ||
'\r' : function( options, scope, key, force, sel ) { | ||
var nodeName = this.nodeName.toLowerCase() | ||
@@ -441,3 +441,3 @@ // submit a form | ||
} | ||
} | ||
@@ -453,10 +453,10 @@ //newline in textarea | ||
}, | ||
// | ||
// | ||
// Gets all focusable elements. If the element (this) | ||
// doesn't have a tabindex, finds the next element after. | ||
// If the element (this) has a tabindex finds the element | ||
// If the element (this) has a tabindex finds the element | ||
// with the next higher tabindex OR the element with the same | ||
// tabindex after it in the document. | ||
// @return the next element | ||
// | ||
// | ||
'\t' : function( options, scope ) { | ||
@@ -474,3 +474,3 @@ // focusable elements | ||
i = 0, | ||
el, | ||
el, | ||
//the tabindex of the tabable element we are looking at | ||
@@ -517,6 +517,6 @@ elIndex, | ||
} | ||
} | ||
} | ||
//restart if we didn't find anything | ||
@@ -545,7 +545,7 @@ if(!current){ | ||
} | ||
} | ||
} | ||
}, | ||
'up' : function() { | ||
if(/select/i.test(this.nodeName)){ | ||
this.selectedIndex = this.selectedIndex ? this.selectedIndex-1 : 0; | ||
@@ -601,3 +601,3 @@ //set this to change on blur? | ||
} : options; | ||
//don't change the orignial | ||
@@ -609,3 +609,3 @@ options = h.extend({}, options) | ||
} | ||
options = h.extend({ | ||
@@ -617,3 +617,3 @@ ctrlKey: !!Syn.key.ctrlKey, | ||
}, options) | ||
return options; | ||
@@ -626,8 +626,8 @@ }, | ||
var event; | ||
try { | ||
event = element.ownerDocument.createEvent("KeyEvents"); | ||
event.initKeyEvent(type, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode); | ||
} | ||
} | ||
catch (e) { | ||
@@ -642,3 +642,3 @@ event = h.createBasicStandardEvent(type, options, doc); | ||
h.extend(event, options) | ||
return event; | ||
@@ -665,5 +665,5 @@ } | ||
* Types a single key. The key should be | ||
* a string that matches a | ||
* a string that matches a | ||
* [Syn.static.keycodes]. | ||
* | ||
* | ||
* The following sends a carridge return | ||
@@ -683,3 +683,3 @@ * to the 'name' element. | ||
//first check if it is a special up | ||
if(/-up$/.test(options) | ||
if(/-up$/.test(options) | ||
&& h.inArray(options.replace("-up",""),Syn.key.kinds.special )!= -1){ | ||
@@ -690,4 +690,4 @@ Syn.trigger('keyup',options.replace("-up",""), element ) | ||
} | ||
var caret = Syn.typeable.test(element.nodeName) && getSelection(element), | ||
@@ -697,16 +697,16 @@ key = convert[options] || options, | ||
runDefaults = Syn.trigger('keydown',key, element ), | ||
// a function that gets the default behavior for a key | ||
getDefault = Syn.key.getDefault, | ||
// how this browser handles preventing default events | ||
prevent = Syn.key.browser.prevent, | ||
// the result of the default event | ||
defaultResult, | ||
// options for keypress | ||
keypressOptions = Syn.key.options(key, 'keypress') | ||
if(runDefaults){ | ||
@@ -732,3 +732,3 @@ //if the browser doesn't create keypresses for this key, run default | ||
} | ||
if(defaultResult !== null){ | ||
@@ -742,10 +742,10 @@ setTimeout(function(){ | ||
} | ||
//do mouseup | ||
return element; | ||
// is there a keypress? .. if not , run default | ||
// yes -> did we prevent it?, if not run ... | ||
}, | ||
@@ -758,3 +758,3 @@ /** | ||
* enclosed in square brackents. | ||
* | ||
* | ||
* The following types 'JavaScript MVC' then deletes the space. | ||
@@ -764,5 +764,5 @@ * @codestart | ||
* @codeend | ||
* | ||
* Type is able to handle (and move with) tabs (\t). | ||
* The following simulates tabing and entering values in a form and | ||
* | ||
* Type is able to handle (and move with) tabs (\t). | ||
* The following simulates tabing and entering values in a form and | ||
* eventually submitting the form. | ||
@@ -793,5 +793,5 @@ * @codestart | ||
} | ||
runNextPart(); | ||
} | ||
@@ -808,7 +808,7 @@ }); | ||
var div = document.createElement("div"), | ||
checkbox, | ||
submit, | ||
form, | ||
input, | ||
var div = document.createElement("div"), | ||
checkbox, | ||
submit, | ||
form, | ||
input, | ||
submitted = false, | ||
@@ -818,3 +818,3 @@ anchor, | ||
inputter; | ||
div.innerHTML = "<form id='outer'>"+ | ||
@@ -830,3 +830,3 @@ "<input name='checkbox' type='checkbox'/>"+ | ||
"</form>"; | ||
document.documentElement.appendChild(div); | ||
@@ -839,5 +839,5 @@ form = div.firstChild; | ||
inputter = form.childNodes[3]; | ||
form.onsubmit = function(ev){ | ||
if (ev.preventDefault) | ||
if (ev.preventDefault) | ||
ev.preventDefault(); | ||
@@ -851,14 +851,14 @@ S.support.keypressSubmits = true; | ||
Syn.trigger("keypress", "\r", inputter); | ||
Syn.trigger("keypress", "a", inputter); | ||
S.support.keyCharacters = inputter.value == "a"; | ||
inputter.value = "a"; | ||
Syn.trigger("keypress", "\b", inputter); | ||
S.support.backspaceWorks = inputter.value == ""; | ||
inputter.onchange = function(){ | ||
@@ -870,9 +870,9 @@ S.support.focusChanges = true; | ||
form.childNodes[5].focus(); // this will throw a change event | ||
Syn.trigger("keypress", "b", inputter); | ||
S.support.keysOnNotFocused = inputter.value == "ab"; | ||
S.support.keysOnNotFocused = inputter.value == "ab"; | ||
//test keypress \r on anchor submits | ||
S.bind(anchor,"click",function(ev){ | ||
if (ev.preventDefault) | ||
if (ev.preventDefault) | ||
ev.preventDefault(); | ||
@@ -884,8 +884,8 @@ S.support.keypressOnAnchorClicks = true; | ||
Syn.trigger("keypress", "\r", anchor); | ||
S.support.textareaCarriage = textarea.value.length == 4 | ||
document.documentElement.removeChild(div); | ||
S.support.ready++; | ||
})(); | ||
}()) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
639757
106
17570
1