Search Results

Search found 243 results on 10 pages for 'keyup'.

Page 6/10 | < Previous Page | 2 3 4 5 6 7 8 9 10  | Next Page >

  • What's the problem of this piece of JavaScript code?

    - by Yousui
    Hi guys, The following piece of JavaScript code is a cross browser way to add/remove event handler. It will save a deleting method as a property of an HTML element object. Now it works well in FireFox but not in IE6. I can't find out why so I came here for help. Great thanks. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>pop</title> </head> <body> <input type="text" name="input1" id="input1" value="" /> <div id="result"> </div> <div id="result2" style="width:200px;height:100px;border:1px solid red;"> </div> <button id="stop" name="stop">click me</button><button id="stop2" name="stop2">click me</button> <script type="text/javascript" charset="utf-8"> function handler(e){ e = e || window.event; var key_code = e.keyCode || e.charCode || e.which, source = e.srcElement || e.target; document.getElementById("result").innerHTML = "" + key_code; } function handler2(e){ e = e || window.event; var key_code = e.keyCode || e.charCode || e.which, source = e.srcElement || e.target; document.getElementById("result2").innerHTML = e.button; } function add_event(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; if(document.addEventListener){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; capture = typeof(capture) === "undefined" ? false : true; o.addEventListener(event_type, callback, capture); o.removes = o.removes || {}; o.removes[event_type] = function(){ o.removeEventListener(event_type, callback, capture); }; if(!o.remove_event){ o.remove_event = function(type){ if(typeof type === "undefined"){ return; } o.removes[type](); } } } }else if(document.attachEvent){ add_event = function(o, event_type, callback, capture){ o = typeof o === "string" ? document.getElementById(o) : o; capture = typeof(capture) === "undefined" ? false : true; o.attachEvent(event_type, callback); o.removes = o.removes || {}; o.removes[event_type] = function(){ o.detachEvent(event_type, callback); } if(!o.remove_event){ o.remove_event = function(type){ if(typeof type === "undefined"){ return; } o.removes[type](); } } } } add_event(o, event_type, callback, capture); } add_event("input1", "keyup", handler); add_event("input1", "click", handler2); add_event("stop", "click", function(){ document.getElementById("input1").remove_event("keyup"); }); add_event("stop2", "click", function(){ document.getElementById("input1").remove_event("click"); }); </script> </body> </html>

    Read the article

  • auto tabbing not working on iphone

    - by Sarita
    I have problem with auto tabbing on Iphone or android. This auto tabbing code work perfectly on each browser of pc but not on mobile. please help me. its urgent. $(document).ready(function() { WireAutoTab('<%= PartOne.ClientID %', '<%= PartTwo.ClientID %', 3); WireAutoTab('<%= PartTwo.ClientID %', '<%= PartThree.ClientID %', 2); }); function WireAutoTab(CurrentElementID, NextElementID, FieldLength) { //Get a reference to the two elements in the tab sequence. var CurrentElement = $('#' + CurrentElementID); var NextElement = $('#' + NextElementID); CurrentElement.keyup(function(e) { //Retrieve which key was pressed. var KeyID = (window.event) ? event.keyCode : e.keyCode; //If the user has filled the textbox to the given length and //the user just pressed a number or letter, then move the //cursor to the next element in the tab sequence. if (CurrentElement.val().length >= FieldLength && ((KeyID >= 48 && KeyID <= 90) || (KeyID >= 96 && KeyID <= 105))) NextElement.focus(); }); }

    Read the article

  • Pass variable to regular expression pattern string in jquery

    - by phil
    Is that possible to pass variable into regular expression pattern string in jquery ( or javascript)? For example, I want to validate a zip code input field every time while user type in a character by passing variable i to the regular expression pattern. How to do it right? $('#zip').keyup( function(){ var i=$('#zip').val().length for ( i; i<=5; i++){ var pattern=/^[0-9]{i}$/; if ( !pattern.test( $('#zip').val() ) ) {$('#zip_error').css('display','inline');} else {$('#zip_error').css('display','none');} } })

    Read the article

  • Pygame camera follow in a 2d tile game

    - by Pipyaddict
    import pygame, sys from pygame.locals import * pygame.init() size = width, height = 480,320 screen = pygame.display.set_mode(size) r = 0 bif = pygame.image.load("map5.png") pygame.display.set_caption("Pygame 2D RPG !") x,y=0,0 movex, movey=0,0 character="boy.png" player=pygame.image.load(character).convert_alpha() while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() if event.type==KEYDOWN: if event.key==K_a: movex=-1 elif event.key==K_d: movex=+1 elif event.key==K_w: movey=-1 elif event.key==K_s: movey=+1 if event.type==KEYUP: if event.key==K_a: movex=0 elif event.key==K_d: movex=0 elif event.key==K_w: movey=0 elif event.key==K_s: movey=0 x+=movex y+=movey screen.fill((r,0,0)) screen.blit(bif,(0,0)) screen.blit(player,(x,y)) pygame.display.flip() Everything works fine except I was wondering how on earth I was going to be able to move the camera where the player goes sorry that I can't show you the map file as you can't add images to it. But Thanks for your time The map is here: https://dl.dropboxusercontent.com/u/110087275/2d%20pygame/map5.png And finally the code is here: https://dl.dropboxusercontent.com/u/110087275/2d%20pygame/2d_pygame.py Thanks again for your time and effort!!!!!

    Read the article

  • Help with Nicedit - removeFormat function

    - by Franck
    Hello, I'm trying to get around Nicedit, and especially the "removeFormat" function. The problem is I cannot find the "removeFormat" method source code in the code below. The JS syntax looks strange to me. Can someone help me ? /* NicEdit - Micro Inline WYSIWYG * Copyright 2007-2008 Brian Kirchoff * * NicEdit is distributed under the terms of the MIT license * For more information visit http://nicedit.com/ * Do not remove this copyright message */ var bkExtend = function(){ var A = arguments; if (A.length == 1) { A = [this, A[0]] } for (var B in A[1]) { A[0][B] = A[1][B] } return A[0] }; function bkClass(){ } bkClass.prototype.construct = function(){ }; bkClass.extend = function(C){ var A = function(){ if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments) } }; var B = new this(bkClass); bkExtend(B, C); A.prototype = B; A.extend = this.extend; return A }; var bkElement = bkClass.extend({ construct: function(B, A){ if (typeof(B) == "string") { B = (A || document).createElement(B) } B = $BK(B); return B }, appendTo: function(A){ A.appendChild(this); return this }, appendBefore: function(A){ A.parentNode.insertBefore(this, A); return this }, addEvent: function(B, A){ bkLib.addEvent(this, B, A); return this }, setContent: function(A){ this.innerHTML = A; return this }, pos: function(){ var C = curtop = 0; var B = obj = this; if (obj.offsetParent) { do { C += obj.offsetLeft; curtop += obj.offsetTop } while (obj = obj.offsetParent) } var A = (!window.opera) ? parseInt(this.getStyle("border-width") || this.style.border) || 0 : 0; return [C + A, curtop + A + this.offsetHeight] }, noSelect: function(){ bkLib.noSelect(this); return this }, parentTag: function(A){ var B = this; do { if (B && B.nodeName && B.nodeName.toUpperCase() == A) { return B } B = B.parentNode } while (B); return false }, hasClass: function(A){ return this.className.match(new RegExp("(\s|^)nicEdit-" + A + "(\s|$)")) }, addClass: function(A){ if (!this.hasClass(A)) { this.className += " nicEdit-" + A } return this }, removeClass: function(A){ if (this.hasClass(A)) { this.className = this.className.replace(new RegExp("(\s|^)nicEdit-" + A + "(\s|$)"), " ") } return this }, setStyle: function(A){ var B = this.style; for (var C in A) { switch (C) { case "float": B.cssFloat = B.styleFloat = A[C]; break; case "opacity": B.opacity = A[C]; B.filter = "alpha(opacity=" + Math.round(A[C] * 100) + ")"; break; case "className": this.className = A[C]; break; default: B[C] = A[C] } } return this }, getStyle: function(A, C){ var B = (!C) ? document.defaultView : C; if (this.nodeType == 1) { return (B && B.getComputedStyle) ? B.getComputedStyle(this, null).getPropertyValue(A) : this.currentStyle[bkLib.camelize(A)] } }, remove: function(){ this.parentNode.removeChild(this); return this }, setAttributes: function(A){ for (var B in A) { this[B] = A[B] } return this } }); var bkLib = { isMSIE: (navigator.appVersion.indexOf("MSIE") != -1), addEvent: function(C, B, A){ (C.addEventListener) ? C.addEventListener(B, A, false) : C.attachEvent("on" + B, A) }, toArray: function(C){ var B = C.length, A = new Array(B); while (B--) { A[B] = C[B] } return A }, noSelect: function(B){ if (B.setAttribute && B.nodeName.toLowerCase() != "input" && B.nodeName.toLowerCase() != "textarea") { B.setAttribute("unselectable", "on") } for (var A = 0; A < B.childNodes.length; A++) { bkLib.noSelect(B.childNodes[A]) } }, camelize: function(A){ return A.replace(/-(.)/g, function(B, C){ return C.toUpperCase() }) }, inArray: function(A, B){ return (bkLib.search(A, B) != null) }, search: function(A, C){ for (var B = 0; B < A.length; B++) { if (A[B] == C) { return B } } return null }, cancelEvent: function(A){ A = A || window.event; if (A.preventDefault && A.stopPropagation) { A.preventDefault(); A.stopPropagation() } return false }, domLoad: [], domLoaded: function(){ if (arguments.callee.done) { return } arguments.callee.done = true; for (i = 0; i < bkLib.domLoad.length; i++) { bkLib.domLoadi } }, onDomLoaded: function(A){ this.domLoad.push(A); if (document.addEventListener) { document.addEventListener("DOMContentLoaded", bkLib.domLoaded, null) } else { if (bkLib.isMSIE) { document.write(".nicEdit-main p { margin: 0; }<\/script"); $BK("__ie_onload").onreadystatechange = function(){ if (this.readyState == "complete") { bkLib.domLoaded() } } } } window.onload = bkLib.domLoaded } }; function $BK(A){ if (typeof(A) == "string") { A = document.getElementById(A) } return (A && !A.appendTo) ? bkExtend(A, bkElement.prototype) : A } var bkEvent = { addEvent: function(A, B){ if (B) { this.eventList = this.eventList || {}; this.eventList[A] = this.eventList[A] || []; this.eventList[A].push(B) } return this }, fireEvent: function(){ var A = bkLib.toArray(arguments), C = A.shift(); if (this.eventList && this.eventList[C]) { for (var B = 0; B < this.eventList[C].length; B++) { this.eventList[C][B].apply(this, A) } } } }; function __(A){ return A } Function.prototype.closure = function(){ var A = this, B = bkLib.toArray(arguments), C = B.shift(); return function(){ if (typeof(bkLib) != "undefined") { return A.apply(C, B.concat(bkLib.toArray(arguments))) } } }; Function.prototype.closureListener = function(){ var A = this, C = bkLib.toArray(arguments), B = C.shift(); return function(E){ E = E || window.event; if (E.target) { var D = E.target } else { var D = E.srcElement } return A.apply(B, [E, D].concat(C)) } }; var nicEditorConfig = bkClass.extend({ buttons: { 'bold': { name: _('Mettre en gras'), command: 'Bold', tags: ['B', 'STRONG'], css: { 'font-weight': 'bold' }, key: 'b' }, 'italic': { name: _('Mettre en italique'), command: 'Italic', tags: ['EM', 'I'], css: { 'font-style': 'italic' }, key: 'i' }, 'underline': { name: _('Souligner'), command: 'Underline', tags: ['U'], css: { 'text-decoration': 'underline' }, key: 'u' }, 'left': { name: _('Aligné à gauche'), command: 'justifyleft', noActive: true }, 'center': { name: _('Centré'), command: 'justifycenter', noActive: true }, 'right': { name: _('Aligné à droite'), command: 'justifyright', noActive: true }, 'justify': { name: _('Justifié'), command: 'justifyfull', noActive: true }, 'ol': { name: _('Liste non ordonnée'), command: 'insertorderedlist', tags: ['OL'] }, 'ul': { name: _('Liste non ordonnée'), command: 'insertunorderedlist', tags: ['UL'] }, 'subscript': { name: _('Placer en indice'), command: 'subscript', tags: ['SUB'] }, 'superscript': { name: _('Placer en exposant'), command: 'superscript', tags: ['SUP'] }, 'strikethrough': { name: _('Barrer le texte'), command: 'strikeThrough', css: { 'text-decoration': 'line-through' } }, 'removeformat': { name: _('Supprimer la mise en forme'), command: 'removeformat', noActive: true }, 'indent': { name: _('Indenter'), command: 'indent', noActive: true }, 'outdent': { name: _('Remove Indent'), command: 'outdent', noActive: true }, 'hr': { name: _('Ligne horizontale'), command: 'insertHorizontalRule', noActive: true } }, iconsPath: 'http://js.nicedit.com/nicEditIcons-latest.gif', buttonList: ['save', 'bold', 'italic', 'underline', 'left', 'center', 'right', 'justify', 'ol', 'ul', 'fontSize', 'fontFamily', 'fontFormat', 'indent', 'outdent', 'image', 'upload', 'link', 'unlink', 'forecolor', 'bgcolor'], iconList: { "xhtml": 1, "bgcolor": 2, "forecolor": 3, "bold": 4, "center": 5, "hr": 6, "indent": 7, "italic": 8, "justify": 9, "left": 10, "ol": 11, "outdent": 12, "removeformat": 13, "right": 14, "save": 25, "strikethrough": 16, "subscript": 17, "superscript": 18, "ul": 19, "underline": 20, "image": 21, "link": 22, "unlink": 23, "close": 24, "arrow": 26, "upload": 27, "question":2 } }); ; var nicEditors = { nicPlugins: [], editors: [], registerPlugin: function(B, A){ this.nicPlugins.push({ p: B, o: A }) }, allTextAreas: function(C){ var A = document.getElementsByTagName("textarea"); for (var B = 0; B < A.length; B++) { nicEditors.editors.push(new nicEditor(C).panelInstance(A[B])) } return nicEditors.editors }, findEditor: function(C){ var B = nicEditors.editors; for (var A = 0; A < B.length; A++) { if (B[A].instanceById(C)) { return B[A].instanceById(C) } } } }; var nicEditor = bkClass.extend({ construct: function(C){ this.options = new nicEditorConfig(); bkExtend(this.options, C); this.nicInstances = new Array(); this.loadedPlugins = new Array(); var A = nicEditors.nicPlugins; for (var B = 0; B < A.length; B++) { this.loadedPlugins.push(new A[B].p(this, A[B].o)) } nicEditors.editors.push(this); bkLib.addEvent(document.body, "mousedown", this.selectCheck.closureListener(this)) }, panelInstance: function(B, C){ B = this.checkReplace($BK(B)); var A = new bkElement("DIV").setStyle({ width: (parseInt(B.getStyle("width")) || B.clientWidth) + "px" }).appendBefore(B); this.setPanel(A); return this.addInstance(B, C) }, checkReplace: function(B){ var A = nicEditors.findEditor(B); if (A) { A.removeInstance(B); A.removePanel() } return B }, addInstance: function(B, C){ B = this.checkReplace($BK(B)); if (B.contentEditable || !!window.opera) { var A = new nicEditorInstance(B, C, this) } else { var A = new nicEditorIFrameInstance(B, C, this) } this.nicInstances.push(A); return this }, removeInstance: function(C){ C = $BK(C); var B = this.nicInstances; for (var A = 0; A < B.length; A++) { if (B[A].e == C) { B[A].remove(); this.nicInstances.splice(A, 1) } } }, removePanel: function(A){ if (this.nicPanel) { this.nicPanel.remove(); this.nicPanel = null } }, instanceById: function(C){ C = $BK(C); var B = this.nicInstances; for (var A = 0; A < B.length; A++) { if (B[A].e == C) { return B[A] } } }, setPanel: function(A){ this.nicPanel = new nicEditorPanel($BK(A), this.options, this); this.fireEvent("panel", this.nicPanel); return this }, nicCommand: function(B, A){ if (this.selectedInstance) { this.selectedInstance.nicCommand(B, A) } }, getIcon: function(D, A){ var C = this.options.iconList[D]; var B = (A.iconFiles) ? A.iconFiles[D] : ""; return { backgroundImage: "url('" + ((C) ? this.options.iconsPath : B) + "')", backgroundPosition: ((C) ? ((C - 1) * -18) : 0) + "px 0px" } }, selectCheck: function(C, A){ var B = false; do { if (A.className && A.className.indexOf("nicEdit") != -1) { return false } } while (A = A.parentNode); this.fireEvent("blur", this.selectedInstance, A); this.lastSelectedInstance = this.selectedInstance; this.selectedInstance = null; return false } }); nicEditor = nicEditor.extend(bkEvent); var nicEditorInstance = bkClass.extend({ isSelected: false, construct: function(G, D, C){ this.ne = C; this.elm = this.e = G; this.options = D || {}; newX = parseInt(G.getStyle("width")) || G.clientWidth; newY = parseInt(G.getStyle("height")) || G.clientHeight; this.initialHeight = newY - 8; var H = (G.nodeName.toLowerCase() == "textarea"); if (H || this.options.hasPanel) { var B = (bkLib.isMSIE && !((typeof document.body.style.maxHeight != "undefined") && document.compatMode == "CSS1Compat")); var E = { width: newX + "px", border: "1px solid #ccc", borderTop: 0, overflowY: "auto", overflowX: "hidden" }; E[(B) ? "height" : "maxHeight"] = (this.ne.options.maxHeight) ? this.ne.options.maxHeight + "px" : null; this.editorContain = new bkElement("DIV").setStyle(E).appendBefore(G); var A = new bkElement("DIV").setStyle({ width: (newX - 8) + "px", margin: "4px", minHeight: newY + "px" }).addClass("main").appendTo(this.editorContain); G.setStyle({ display: "none" }); A.innerHTML = G.innerHTML; if (H) { A.setContent(G.value); this.copyElm = G; var F = G.parentTag("FORM"); if (F) { bkLib.addEvent(F, "submit", this.saveContent.closure(this)) } } A.setStyle((B) ? { height: newY + "px" } : { overflow: "hidden" }); this.elm = A } this.ne.addEvent("blur", this.blur.closure(this)); this.init(); this.blur() }, init: function(){ this.elm.setAttribute("contentEditable", "true"); if (this.getContent() == "") { this.setContent("") } this.instanceDoc = document.defaultView; this.elm.addEvent("mousedown", this.selected.closureListener(this)).addEvent("keypress", this.keyDown.closureListener(this)).addEvent("focus", this.selected.closure(this)).addEvent("blur", this.blur.closure(this)).addEvent("keyup", this.selected.closure(this)); this.elm.addEvent("resizestart",function(){return false}); this.elm.addEvent("dragstart",function(){return false}); this.ne.fireEvent("add", this); }, remove: function(){ this.saveContent(); if (this.copyElm || this.options.hasPanel) { this.editorContain.remove(); this.e.setStyle({ display: "block" }); this.ne.removePanel() } this.disable(); this.ne.fireEvent("remove", this) }, disable: function(){ this.elm.setAttribute("contentEditable", "false") }, getSel: function(){ return (window.getSelection) ? window.getSelection() : document.selection }, getRng: function(){ var A = this.getSel(); if (!A) { return null } return (A.rangeCount 0) ? A.getRangeAt(0) : A.createRange() }, selRng: function(A, B){ if (window.getSelection) { B.removeAllRanges(); B.addRange(A) } else { A.select() } }, selElm: function(){ var C = this.getRng(); if (C.startContainer) { var D = C.startContainer; if (C.cloneContents().childNodes.length == 1) { for (var B = 0; B < D.childNodes.length; B++) { var A = D.childNodes[B].ownerDocument.createRange(); A.selectNode(D.childNodes[B]); if (C.compareBoundaryPoints(Range.START_TO_START, A) != 1 && C.compareBoundaryPoints(Range.END_TO_END, A) != -1) { return $BK(D.childNodes[B]) } } } return $BK(D) } else { return $BK((this.getSel().type == "Control") ? C.item(0) : C.parentElement()) } }, saveRng: function(){ this.savedRange = this.getRng(); this.savedSel = this.getSel() }, restoreRng: function(){ if (this.savedRange) { this.selRng(this.savedRange, this.savedSel) } }, keyDown: function(B, A){ if (B.ctrlKey) { this.ne.fireEvent("key", this, B) } }, selected: function(C, A){ if (!A) { A = this.selElm() } if (!C.ctrlKey) { var B = this.ne.selectedInstance; if (B != this) { if (B) { this.ne.fireEvent("blur", B, A) } this.ne.selectedInstance = this; this.ne.fireEvent("focus", B, A) } this.ne.fireEvent("selected", B, A); this.isFocused = true; this.elm.addClass("selected") } return false }, blur: function(){ this.isFocused = false; this.elm.removeClass("selected") }, saveContent: function(){ if (this.copyElm || this.options.hasPanel) { this.ne.fireEvent("save", this); (this.copyElm) ? this.copyElm.value = this.getContent() : this.e.innerHTML = this.getContent() } }, getElm: function(){ return this.elm }, getContent: function(){ this.content = this.getElm().innerHTML; this.ne.fireEvent("get", this); return this.content }, setContent: function(A){ this.content = A; this.ne.fireEvent("set", this); this.elm.innerHTML = this.content }, nicCommand: function(B, A){ document.execCommand(B, false, A) } }); var nicEditorIFrameInstance = nicEditorInstance.extend({ savedStyles: [], init: function(){ var B = this.elm.innerHTML.replace(/^\s+|\s+$/g, ""); this.elm.innerHTML = ""; (!B) ? B = "" : B; this.initialContent = B; this.elmFrame = new bkElement("iframe").setAttributes({ src: "javascript:;", frameBorder: 0, allowTransparency: "true", scrolling: "no" }).setStyle({ height: "100px", width: "100%" }).addClass("frame").appendTo(this.elm); if (this.copyElm) { this.elmFrame.setStyle({ width: (this.elm.offsetWidth - 4) + "px" }) } var A = ["font-size", "font-family", "font-weight", "color"]; for (itm in A) { this.savedStyles[bkLib.camelize(itm)] = this.elm.getStyle(itm) } setTimeout(this.initFrame.closure(this), 50) }, disable: function(){ this.elm.innerHTML = this.getContent() }, initFrame: function(){ var B = $BK(this.elmFrame.contentWindow.document); B.designMode = "on"; B.open(); var A = this.ne.options.externalCSS; B.write("" + ((A) ? '' : "") + '' + this.initialContent + ""); B.close(); this.frameDoc = B; this.frameWin = $BK(this.elmFrame.contentWindow); this.frameContent = $BK(this.frameWin.document.body).setStyle(this.savedStyles); this.instanceDoc = this.frameWin.document.defaultView; this.heightUpdate(); this.frameDoc.addEvent("mousedown", this.selected.closureListener(this)).addEvent("keyup", this.heightUpdate.closureListener(this)).addEvent("keydown", this.keyDown.closureListener(this)).addEvent("keyup", this.selected.closure(this)); this.ne.fireEvent("add", this) }, getElm: function(){ return this.frameContent }, setContent: function(A){ this.content = A; this.ne.fireEvent("set", this); this.frameContent.innerHTML = this.content; this.heightUpdate() }, getSel: function(){ return (this.frameWin) ? this.frameWin.getSelection() : this.frameDoc.selection }, heightUpdate: function(){ this.elmFrame.style.height = Math.max(this.frameContent.offsetHeight, this.initialHeight) + "px" }, nicCommand: function(B, A){ this.frameDoc.execCommand(B, false, A); setTimeout(this.heightUpdate.closure(this), 100) } }); var nicEditorPanel = bkClass.extend({ construct: function(E, B, A){ this.elm = E; this.options = B; this.ne = A; this.panelButtons = new Array(); this.buttonList = bkExtend([], this.ne.options.buttonList); this.panelContain = new bkElement("DIV").setStyle({ overflow: "hidden", width: "100%", border: "1px solid #cccccc", backgroundColor: "#efefef" }).addClass("panelContain"); this.panelElm = new bkElement("DIV").setStyle({ margin: "2px", marginTop: "0px", zoom: 1, overflow: "hidden" }).addClass("panel").appendTo(this.panelContain); this.panelContain.appendTo(E); var C = this.ne.options; var D = C.buttons; for (button in D) { this.addButton(button, C, true) } this.reorder(); E.noSelect() }, addButton: function(buttonName, options, noOrder){ var button = options.buttons[buttonName]; var type = (button.type) ? eval("(typeof(" + button.type + ') == "undefined") ? null : ' + button.type + ";") : nicEditorButton; var hasButton = bkLib.inArray(this.buttonList, buttonName); if (type && (hasButton || this.ne.options.fullPanel)) { this.panelButtons.push(new type(this.panelElm, buttonName, options, this.ne)); if (!hasButton) { this.buttonList.push(buttonName) } } }, findButton: function(B){ for (var A = 0; A < this.panelButtons.length; A++) { if (this.panelButtons[A].name == B) { return this.panelButtons[A] } } }, reorder: function(){ var C = this.buttonList; for (var B = 0; B < C.length; B++) { var A = this.findButton(C[B]); if (A) { this.panelElm.appendChild(A.margin) } } }, remove: function(){ this.elm.remove() } }); var nicEditorButton = bkClass.extend({ construct: function(D, A, C, B){ this.options = C.buttons[A]; this.name = A; this.ne = B; this.elm = D; this.margin = new bkElement("DIV").setStyle({ "float": "left", marginTop: "2px" }).appendTo(D); this.contain = new bkElement("DIV").setStyle({ width: "20px", height: "20px" }).addClass("buttonContain").appendTo(this.margin); this.border = new bkElement("DIV").setStyle({ backgroundColor: "#efefef", border: "1px solid #efefef" }).appendTo(this.contain); this.button = new bkElement("DIV").setStyle({ width: "18px", height: "18px", overflow: "hidden", zoom: 1, cursor: "pointer" }).addClass("button").setStyle(this.ne.getIcon(A, C)).appendTo(this.border); this.button.addEvent("mouseover", this.hoverOn.closure(this)).addEvent("mouseout", this.hoverOff.closure(this)).addEvent("mousedown", this.mouseClick.closure(this)).noSelect(); if (!window.opera) { this.button.onmousedown = this.button.onclick = bkLib.cancelEvent } B.addEvent("selected", this.enable.closure(this)).addEvent("blur", this.disable.closure(this)).addEvent("key", this.key.closure(this)); this.disable(); this.init() }, init: function(){ }, hide: function(){ this.contain.setStyle({ display: "none" }) }, updateState: function(){ if (this.isDisabled) { this.setBg() } else { if (this.isHover) { this.setBg("hover") } else { if (this.isActive) { this.setBg("active") } else { this.setBg() } } } }, setBg: function(A){ switch (A) { case "hover": var B = { border: "1px solid #666", backgroundColor: "#ddd" }; break; case "active": var B = { border: "1px solid #666", backgroundColor: "#ccc" }; break; default: var B = { border: "1px solid #efefef", backgroundColor: "#efefef" } } this.border.setStyle(B).addClass("button-" + A) }, checkNodes: function(A){ var B = A; do { if (this.options.tags && bkLib.inArray(this.options.tags, B.nodeName)) { this.activate(); return true } } while (B = B.parentNode && B.className != "nicEdit"); B = $BK(A); while (B.nodeType == 3) { B = $BK(B.parentNode) } if (this.options.css) { for (itm in this.options.css) { if (B.getStyle(itm, this.ne.selectedInstance.instanceDoc) == this.options.css[itm]) { this.activate(); return true } } } this.deactivate(); return false }, activate: function(){ if (!this.isDisabled) { this.isActive = true; this.updateState(); this.ne.fireEvent("buttonActivate", this) } }, deactivate: function(){ this.isActive = false; this.updateState(); if (!this.isDisabled) { th

    Read the article

  • Using RIA Services FilterDescriptor from code behind

    - by Fermin
    Hi, I was wondering if it's possible to use the FilterDescriptor control from code behind? On the page load of my form I set the datasource of a grid in the code behind, not using a DomainDataSource control, like: TestDomainContext context = new TestDomainContext(); dataGridEmployees.ItemsSource = context.EmployeePositions; context.Load(context.GetEmployeesWithPositionQuery()); I have a textbox on my page that the user can enter into to filter on employee position. Is it now possible to add FilterDescriptor to the source of the DataGrid in code behind? Or would I manually need to filter the results of the context.GetEmployeesWithPositionQuery, for example on KeyUp event of the filter TextBox?

    Read the article

  • Is it possible to sendkeys / Post Message directly to a HtmlElement rather than to a C# webbrowser

    - by Jakub
    I would like to send keys to a c# web browser control element directly, not just the window with the correct focus. Right now I am able to send a key using PostMessage and documentHandle and focus like this i.e. Pseudo Code HtmlElement el = getelement(); el.Focus(); IntPtr docptr = browser.Handle; PostMessage(docptr,WM_KEYDOWN,1,0); .... KEYCHAR, KEYUP.. I was wondering if anyone knows of any way to be able to do this in a background, so that the focus is not on the element. Basically is there a way to get a IntPtr to the HtmlElement itself, than use that instead in the PostMessage or SendKeys API rather than the browser handle/ptr.

    Read the article

  • jQuery calculation plugin: show total in form field rather than text

    - by Katherine
    I'm embarrassed by the 'basicness' of this question, but after wasted hours, here goes. In an effort to do something with the jQuery Calculation plugin, I am playing with the basic example of the order form on the plugin site. I want to have the grand total as a form field,rather than text, so I can use the value. The function that calculates and shows the grand total is: function ($this){ // sum the total of the $("[id^=total_item]") selector var sum = $this.sum(); $("#grandTotal").text( // round the results to 2 digits sum.toFixed(2) ); } the total updates on keyup in: <span id="grandTotal"></span> But this does not work with: <input type="text" id="grandTotal" value=""/> Can anyone point me to what I need to add/change to make that work? To call my javascript basic would be a compliment, so please talk to me like I know nothing!

    Read the article

  • Opera IME support

    - by Fionn
    Hi, i am currently trying to get Input Mode Editor (IME) support working with a designMode enabled IFrame. The problem here is with Opera it seems I don't get any useful notifications from the IME. It seems I get a single keydown with a keycode of 197 if the first time the IME is used - and nothing else ever again (No keycode 229 messages, no textinput event). With all other browsers keydown events with an keycode of 229 seem to be common if there is something happening in the scope of the IME. And with some goodwill and combination of keyup with keycode 13 and textinput events it seems to be possible to detect the moment the sequence is done. Thanks

    Read the article

  • jquery write protection in textarea for wildcards

    - by Juri
    Hi everybody. Does anyone know a possibilty to protect a string-wildcard from changing in a textarea? HTML: <textarea name="mail_text" id="mail_text"> {salutation} {recipient}, thanks for your email. Regards {username} </textarea> I would like to catch when someone tries to change one of the wildcards: {salutation},*{recipient}* and {username} $("textarea").keyup(function() { var val = $(this).val(); //protect the wildcards }); Thanks!

    Read the article

  • Use of "setTimeout()" in my jQuery Expression

    - by Aaron Salazar
    I'm trying to add the JavaScript function setTimeout() to my jQuery expression. Without the setTimeout() my function loads a partial view with updated information when I enter text into my textbox. But, it loads the information with every keystroke. My logic is that if I can put in a timer then when the user stops typing, a second later the data is updated. As you can see I tried to put a setTimer() in but it doesn't seem to be working. $(function() { $('#DocId').live('keyup', function() { setTimeout(var styleValue = $(this).val(); $('#tableContent').load( '/CurReport/TableResults', { style: $(this).val()}), 1000); }), }); Thank you, Aaron

    Read the article

  • Make character escape from shot

    - by M28
    Hello all math masters, I got a problem for you: I have a 2D game (top down), and I would like to make the character escape from a shot, but not just walk away from the shot (I mean, don't be pushed by the shot), I want it to have a good dodging skills. The variables are: shotX - shot x position shotY - shot y position shotSpeedX - shot x speed shotSpeedY - shot x speed charX - character x position charY - character y position keyLeft - Set to true to make the character press the to left key keyRight - Set to true to make the character press the to right key keyUp - Set to true to make the character press the to up key keyDown - Set to true to make the character press the down key I can understand the following languages: C/C++ Java Actionscript 2/3 Javascript

    Read the article

  • asp.net - csharp - jquery - looking for a better and usage solution

    - by LostLord
    hi my dear friends i have a little problem about using jquery...(i reeally do not know jquery but i forced to use it) i am using vs 2008 - asp.net web app with c# also i am using telerik controls in my pages also i am using sqldatasources (Connecting to storedprocedures) in my pages my pages base on master and content pages and in content pages i have mutiviews ================================================================================= in one of the views(inside one of those multiviews)i had made two radcombo boxes for country and city requirement like cascading dropdowns as parent and child combo boxes. i used old way for doing that , i mean i used update panel and in the SelectedIndexChange Event of Parent RadComboBox(Country) i Wrote this code : protected void RadcomboboxCountry_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { hfSelectedCo_ID.Value = RadcomboboxCountry.SelectedValue; RadcomboboxCity.Items.Clear(); RadcomboboxCity.Items.Add(new RadComboBoxItem(" ...", "5")); RadcomboboxCity.DataBind(); RadcomboboxCity.SelectedIndex = 0; } my child radcombo box can fill by upper code , let me tell you how : the child sqldatasource have a sp that has a parameter and i fill that parameter by this line - hfSelectedCo_ID.Value = RadcbCoNameInInsert.SelectedValue; RadcbCoNameInInsert.SelectedValue means country ID. after doing that SelectedIndexChange Event of Parent RadComboBox(Country) could not be fire therefore i forced to set the autopostback property to true. afetr doing that every thing was ok until some one told me can u control focus and keydown of your radcombo boxes (when u press enter key on the parent combobox[country] , so child combobox gets focus -- and when u press upperkey on child radcombobox [city], so parent combobox[country] gets focus) (For Users That Do Not Want To Use Mouse for Input Info And Choose items) i told him this is web app , not win form and we can not do that. i googled it and i found jquery the only way for doing that ... so i started using jquery . i wrote this code with jquery for both of them : <script src="../JQuery/jquery-1.4.1.js" language="javascript" type="text/javascript"></script> <script type="text/javascript"> $(function() { $('input[id$=RadcomboboxCountry_Input]').focus(); $('input[id$=RadcomboboxCountry_Input]').select(); $('input[id$=RadcomboboxCountry_Input]').bind('keyup', function(e) { var code = (e.keyCode ? e.keyCode : e.which); if (code == 13) { -----------> Enter Key $('input[id$=RadcomboboxCity_Input]').focus(); $('input[id$=RadcomboboxCity_Input]').select(); } }); $('input[id$=RadcomboboxCity_Input]').bind('keyup', function(e) { var code = (e.keyCode ? e.keyCode : e.which); if (code == 38) { -----------> Upper Key $('input[id$=RadcomboboxCountry_Input]').focus(); $('input[id$=RadcomboboxCountry_Input]').select(); } }); }); </script> this jquery code worked BBBBBBUUUUUUUTTTTTT autopostback=true of the Parent RadComboBox Became A Problem , Because when SelectedIndex Change Of ParentRadComboBox is fired after that Telerik Skins runs and after that i lost parent ComboBox Focus and we should use mouse but we don't want it.... for fix this problem i decided to set autopostback of perentCB to false and convert protected void RadcomboboxCountry_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { hfSelectedCo_ID.Value = RadcomboboxCountry.SelectedValue; RadcomboboxCity.Items.Clear(); RadcomboboxCity.Items.Add(new RadComboBoxItem(" ...", "5")); RadcomboboxCity.DataBind(); RadcomboboxCity.SelectedIndex = 0; } to a public non static method without parameters and call it with jquey like this : (i used onclientchanged property of parentcombo box like onclientchanged = "MyMethodForParentCB_InJquery();" insread of selectedindexchange event) public void MyMethodForParentCB_InCodeBehind() { hfSelectedCo_ID.Value = RadcomboboxCountry.SelectedValue; RadcomboboxCity.Items.Clear(); RadcomboboxCity.Items.Add(new RadComboBoxItem(" ...", "5")); RadcomboboxCity.DataBind(); RadcomboboxCity.SelectedIndex = 0; } for doing that i read the blow manual and do that step by step : ======================================================================= http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=732 ======================================================================= but this manual is about static methods and this is my new problem ... when i am using static method like : public static void MyMethodForParentCB_InCodeBehind() { hfSelectedCo_ID.Value = RadcomboboxCountry.SelectedValue; RadcomboboxCity.Items.Clear(); RadcomboboxCity.Items.Add(new RadComboBoxItem(" ...", "5")); RadcomboboxCity.DataBind(); RadcomboboxCity.SelectedIndex = 0; } so i recieved some errors and this method could not recognize my controls and hidden field... one of those errors like this : Error 2 An object reference is required for the non-static field, method, or property 'Darman.SuperAdmin.Users.hfSelectedCo_ID' C:\Javad\Copy of Darman 6\Darman\SuperAdmin\Users.aspx.cs 231 13 Darman any idea or is there any way to call non static methods with jquery (i know we can not do that but is there another way to solve my problem)???????????????

    Read the article

  • WYSIWYG iframe editor and oninput event.

    - by teehoo
    I'm writing a simple WYSIWYG editor in an iframe, but having trouble registering the "oninput" event to detect when the user modifies the text field such as pasting in data etc. var txtArea = document.getElementById('txtArea'); txtArea.contentWindow.document.designMode="on"; txtArea.contentWindow.document.open(); txtArea.contentWindow.document.write("<head><style type='text/css'>body{font-size:13px;}</style></head><body>"+data.document+"</body>"); txtArea.contentWindow.document.close(); $([txtArea.contentWindow.document]).bind("click", updateCaretPosMouse); //fires $([txtArea.contentWindow.document]).bind("keyup", updateCaretPosKeyboard); //fires $([txtArea.contentWindow.document]).bind("input", textChanged); //doesn't fire If I create a plain old element, and add the "input" event to this, then it works. Do 'input" events not work with iframes WYSIWYG editors?

    Read the article

  • Customising event delegates in the jQuery validation plug-in

    - by Russell
    I am currently setting up the jQuery validation plug-in for use in our project. By default, there are some events automatically set up for handling. I.e. focus in/out, key up events on all inputs fire validation. I want it to only fire when the submit button is clicked. This functionality seems to be in-built into the plug-in, which is making it difficult to do this (without modifying the plug-in code, Not What I Want To Do). I have found the eventDelegate function calls in the plugin code prototype method: $(this.currentForm) .validateDelegate(":text, :password, :file, select, textarea", "focusin focusout keyup", delegate) .validateDelegate(":radio, :checkbox, select, option", "click", delegate); When I remove these lines from the plug-in I get my result, however I would much rather do something Outside the plug-in to achieve this. Can anybody please help me? If you need any more details, please let me know. I have searched google with little success. Thanks

    Read the article

  • jquery button click not firing asp.net button

    - by lloydphillips
    I've got a .net button that has an href attribute value set to 'javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cp1$ucInvoiceSearch$btnSearch", "", true, "", "", false, true))'. I've got a textbox that when I press enter I want it to fire this event. Doing the 'Enter' event isn't an issue but I can't get the event on the href to fire using .click(). Here's my function so far: $("[id*='tbInvNo']").keyup(function(event){ var $btn = $(".pnl-invoice-search"); if(event.keyCode == 13) $btn.click(); }); I've got no idea how to get this to fire. Hope someone can help - jQuery and asp.net are driving me up the wall today! :(

    Read the article

  • Spotlight search with PHP

    - by htf
    Hi. I want to add a spotlight search functionality - search results being displayed with rich contents like thumbnail etc in a drop down menu changing on each keyup event - just like the apple.com search - to a site, having data in MySQL InnoDB tables. The data is spread into separate tables for categories, help pages, blog pages and so on. The search script must take into account just a subset of columns. Since it seems to be a popular demand, I guess there are some PHP search engine projects (preferably open-source and with memcached support), which could be integrated into the existing system on the basis of regular exports of relevant data from the working db/tables. Are there any solutions out there? Which one would you recommend? Or maybe it would be better to implement it the other way around? Thanks

    Read the article

  • javascript keypress function: case-insensitive a-z, numbers and a few special chars?

    - by user239831
    hey guys, $('.s').keyup(function(e) { if (!/[A-Za-z0-9]/.test(String.fromCharCode(e.which))) { return false; } I wonder what is the best regex solution for my application. I have an ajax-based search that should just trigger the search when actual characters are pressed like a-Z (upper and lowercase), numbers and maybe a questionmark, a dash(hyphen), and an exclamation mark. Also the spacebar should be enabled. Otherwise the ajax search would be triggered as well if the shift-, option, or control-key, is pressed. What's the easiest regex pattern to understand here? thank you for your help

    Read the article

  • .NET --- Textbox control - wait till user is done typing

    - by Cj Anderson
    Greetings all, Is there a built in way to know when a user is done typing into a textbox? (Before hitting tab, Or moving the mouse) I have a database query that occurs on the textchanged event and everything works perfectly. However, I noticed that there is a bit of lag of course because if a user is quickly typing into the textbox the program is busy doing a query for each character. So what I was hoping for was a way to see if the user has finished typing. So if they type "a" and stop then an event fires. However, if they type "all the way" the event fires after the y keyup. I have some ideas floating around my head but I'm sure they aren't the most efficient. Like measuring the time since the last textchange event and if it was than a certain value then it would proceed to run the rest of my procedures. let me know what you think. Language: VB.NET Framework: .Net 2.0 --Edited to clarify "done typing"

    Read the article

  • Passing null as a param for replace() in javascript behaving weird?

    - by Babiker
    I have the follwing jQuery: $("#textArea").keyup(function(){ var textAreaValue = $("textArea"); if(!textArea.value.indexOf("some string")){ textArea.value = textArea.value.replace("some string",null); alert("It was there!"); } }); Is it normal for element.value.replace("some string",null); to replace "some string" with "null"as a string? And if normal can you please explain why? I have tested it with element.value.replace("some string",""), and that works fine, so what would be the difference between null and ""? Thanks in advance.

    Read the article

  • Simple iframe editor and oninput event.

    - by teehoo
    I'm writing a simple editor in an iframe, but having trouble registering the "oninput" event to detect when the user modifies the text field such as pasting in data etc. var txtArea = document.getElementById('txtArea'); txtArea.contentWindow.document.designMode="on"; txtArea.contentWindow.document.open(); txtArea.contentWindow.document.write("body{font-size:13px;}"+data.document+""); txtArea.contentWindow.document.close(); $([txtArea.contentWindow.document]).bind("click", updateCaretPosMouse); //fires $([txtArea.contentWindow.document]).bind("keyup", updateCaretPosKeyboard); //fires $([txtArea.contentWindow.document]).bind("input", textChanged); //doesn't fire If I create a plain old textarea element, and add the "input" event to this, then it works. Do 'input" events not work with iframes WYSIWYG editors?

    Read the article

  • In XAML is there way to bind key press and key release to specific commands?

    - by Ashley Davis
    In my application I have keys that bound to commands using the KeyBinding class. The command is executed when the key is pressed and released. I have a special case where I want to bind separate commands to the pressed action and to the released action. For example when the space key is pressed I want my app to run a command to enter a special mode. Then when the space key is released I want to run another command to exit that special mode. Currently I do this by manually handling the KeyUp and KeyDown events. Is there anyway to execute commands for pressed and released purely in XAML?

    Read the article

  • Avoid multiple autocomplete calls by wrapping it with SetTimeOut

    - by pixelboy
    Here's my issue : using an autocomplete jQuery plugin, I'd like to avoid multiple ajax requests when user strikes his keynoard by surrounding the $('#query1').autocomplete({ serviceUrl:'/actions/autocomplete?population=salon', minChars:3, maxHeight:300, width:200, clearCache:true, onSelect: function(suggestions,data){ $(".btn1").attr("href", "${pageContext.request.contextPath}/actions/espaceClients?participantId=" + data) } }); with something like var search = false; $('#query1, #query2, #query3').keyup(function(){ if (!search){ search = true; } if (search) { search = false; autocompleteThem(); } }); A you can see, above code is stupid, but it kinda shows what i'm trying to do. In simple words, if user dosen't type anything else in a certain period of time, then you can call autocomplete. I hope i'm being clear, as my brains are a mess...

    Read the article

  • jquery - add to hidden input field on keypress?

    - by Simpson88Keys
    I've got a hidden input field that I want to append text to depending upon what a user enters in two other fields. So, <input type="hidden" name="name" value="" /> <input type="text" name="first" value="" /> <input type="text" name="second" value="" /> If the user types First in the first input field and Second in the second input field, I want the name input field to be "First Second"... Tried using keyup and keypress, but can't get it to append to what's already there?

    Read the article

  • Date Input in safari

    - by Fresheyeball
    So I am using the HTML5 date input type, primary to trigger the 'wheels' in iOS. Everything is working fine in ie7-9 Chrome and FF. But Safari for OSX is very upset. It sees the need to add little 'up and down' buttons to the right hand side and generally mess up my visual stylings. My attempt to fix this, is to change the date inputs back to text inputs for desktop browsers, and leave it as date inputs for mobile: unless device.is # 'device' is a lib I use to detect mobile browsers dateFields = $ 'input[type="date"]' dateFields.attr 'type', 'text' #this fails dateFields.datepicker() dateFields.on 'keyup', (e) -> e.preventDefault() $(@).val '' Beyond altering the input type with js, I am at a loss for how to fix this little bugger. Have you had to deal with this problem?

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10  | Next Page >