Skip to content

Commit

Permalink
Convert from .select() to .focus()
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 3, 2012
1 parent dbe7faa commit 2b99514
Show file tree
Hide file tree
Showing 34 changed files with 233 additions and 238 deletions.
2 changes: 1 addition & 1 deletion architecture-examples/agilityjs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
'dblclick .view': function() {
this.view.$().addClass('editing');
this.view.$('.edit').select();
this.view.$('.edit').focus();
},
'click .destroy': function() {
this.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ todomvc.directive('todoFocus', function( $timeout ) {
if ( newval ) {
$timeout(function() {
elem[0].focus();
elem[0].select();
}, 0, false);
}
});
Expand Down
1 change: 0 additions & 1 deletion architecture-examples/angularjs/js/directives/todoFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ todomvc.directive('todoFocus', function( $timeout ) {
if ( newval ) {
$timeout(function() {
elem[0].focus();
elem[0].select();
}, 0, false);
}
});
Expand Down
2 changes: 1 addition & 1 deletion architecture-examples/closure/js/compiled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ todomvc.view.ToDoItemControl = function(opt_domHelper) {
// disable auto handling of CHECKED and SELECTED states
this.setAutoStates(goog.ui.Component.State.CHECKED, false);
this.setAutoStates(goog.ui.Component.State.SELECTED, false);

// allow text selection
this.setAllowTextSelection(true);
};
Expand Down Expand Up @@ -145,6 +145,6 @@ todomvc.view.ToDoItemControl.prototype.setSelected = function(selected) {
var inputElement = this.getRenderer().getInputElement(
this.getElement());
inputElement.value = this.getContent();
inputElement.select();
inputElement.focus();
}
};

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions architecture-examples/gwt/src/com/todo/client/ToDoCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* A cell that renders {@link ToDoItem} instances. This cell is rendered in both view and edit modes
* based on user interaction. In edit mode, browser events are handled in order to update the model
* item state.
*
*
* @author ceberhardt
*
*
*/
public class ToDoCell extends AbstractCell<ToDoItem> {

Expand Down Expand Up @@ -139,7 +139,6 @@ public void onBrowserEvent(Context context, Element parent, ToDoItem value, Nati
beginningEdit = true;
InputElement input = getInputElement(parent);
input.focus();
input.select();
beginningEdit = false;
}

Expand Down
2 changes: 1 addition & 1 deletion architecture-examples/knockback/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion architecture-examples/knockback/js/viewmodels/todos.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions architecture-examples/knockoutjs/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
init: function( element, valueAccessor, allBindingsAccessor ) {
ko.bindingHandlers.hasfocus.init( element, valueAccessor, allBindingsAccessor );
ko.utils.registerEventHandler( element, 'focus', function() {
element.select();
element.focus();
});
},
update: function( element, valueAccessor ) {
Expand Down Expand Up @@ -182,4 +182,4 @@
};

crossroads.parse( location.hash.replace('#', '') );
}());
}());
4 changes: 2 additions & 2 deletions labs/architecture-examples/batman/js/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Alfred.TodosController extends Batman.Controller
editing = todo.set('editing', !todo.get('editing'))
if editing
input = document.getElementById("todo-input-#{todo.get('id')}")
input.select()
input.focus()
else
if todo.get('title')?.length > 0
todo.save (err, todo) ->
Expand Down Expand Up @@ -79,4 +79,4 @@ class Alfred.Todo extends Batman.Model
set: (key, value) -> core.set.call(@, key, value?.trim())

window.Alfred = Alfred
Alfred.run()
Alfred.run()
2 changes: 1 addition & 1 deletion labs/architecture-examples/batman/js/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 30 additions & 30 deletions labs/architecture-examples/canjs/dojo-widget/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ require({
location: "http://canjs.us/release/latest/",
main: "can.dojo"
}]
}, ['can/dojo',
"dojo/dom",
"dojo/dom-construct",
"dojo/dom-attr",
"dojo/dom-geometry",
"dojo/NodeList-manipulate",
"dijit/CalendarLite",
"dijit/place",
"dijit/focus",
"dojo/domReady!"],
}, ['can/dojo',
"dojo/dom",
"dojo/dom-construct",
"dojo/dom-attr",
"dojo/dom-geometry",
"dojo/NodeList-manipulate",
"dijit/CalendarLite",
"dijit/place",
"dijit/focus",
"dojo/domReady!"],
function(can, dom, domConstruct, domAttr){

// Calculates the difference between two dates by number of days.
Expand All @@ -26,7 +26,7 @@ var difference = function(date1, date2) {
// Basic Todo entry model
// { text: 'todo', complete: false }
Todo = can.Model({

// Implement local storage handling
localStore: function(cb){
var name = 'todos-canjs-dojo-widget',
Expand All @@ -39,7 +39,7 @@ Todo = can.Model({
window.localStorage[name] = dojo.toJson(data);
}
},

findAll: function(params){
var def = new dojo.Deferred();
this.localStore(function(todos){
Expand All @@ -52,7 +52,7 @@ Todo = can.Model({
})
return def;
},

destroy: function(id){
var def = new dojo.Deferred();
this.localStore(function(todos){
Expand All @@ -66,7 +66,7 @@ Todo = can.Model({
});
return def
},

create: function(attrs){
var def = new dojo.Deferred();
this.localStore(function(todos){
Expand All @@ -76,7 +76,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},

update: function(id, attrs){
var def = new dojo.Deferred();
this.localStore(function(todos){
Expand All @@ -91,7 +91,7 @@ Todo = can.Model({
def.resolve({});
return def
}

},{

prettyDate: function(raw){
Expand All @@ -102,7 +102,7 @@ Todo = can.Model({

var date = new Date(raw),
diff = difference(new Date(), date);

if(diff === -1) {
return 'Tomorrow';
} else if(diff === 0) {
Expand All @@ -113,7 +113,7 @@ Todo = can.Model({
return (date.getMonth()+1) + '/' + (date.getDate()) + '/' + date.getFullYear();
}
},

isLate: function(raw) {
var raw = this.attr('dueDate');
return !raw ? false : difference(new Date(), new Date(raw)) > 0;
Expand All @@ -122,26 +122,26 @@ Todo = can.Model({

// List for Todos
Todo.List = can.Model.List({

completed: function() {
// Ensure this triggers on length change
this.attr('length');

var completed = 0;
this.each(function(todo) {
completed += todo.attr('complete') ? 1 : 0
});
return completed;
},

remaining: function() {
return this.attr('length') - this.completed();
},

allComplete: function() {
return this.attr('length') === this.completed();
}

});

Todos = can.Control({
Expand All @@ -152,7 +152,7 @@ Todos = can.Control({
this.element.append(can.view('todo', {
todos: this.options.todos
}));

// Clear the new todo field
dijit.focus(dojo.byId('new-todo'));

Expand Down Expand Up @@ -181,11 +181,11 @@ Todos = can.Control({
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},

// Listen for editing a Todo
'.todo dblclick' : function(el) {
can.data(el, 'todo').attr('editing', true).save(function(){
dijit.focus(el.children('.edit')[0].select());
dijit.focus(el.children('.edit')[0].focus());
});
},

Expand Down Expand Up @@ -227,7 +227,7 @@ Todos = can.Control({
todo.attr('complete', toggle).save();
});
},

// Listen for removing all completed Todos
'#clear-completed click' : function() {
for (var i = this.options.todos.length - 1, todo; i > -1 && (todo = this.options.todos[i]); i--) {
Expand All @@ -241,7 +241,7 @@ Todos = can.Control({

// Cache the todo
var todo = can.data(el.closest('.todo'), 'todo');

// Display the calendar
var cal = this.options.calendar;
dijit.place.at(cal.domNode, {x: 510, y: dojo.position(el[0]).y}, ["TL"]);
Expand All @@ -254,8 +254,8 @@ Todos = can.Control({
'.todo .clear-date click' : function(el, e){
can.data(el.closest('.todo'), 'todo').attr('dueDate', null).save();
},
// Date change for Todo

// Date change for Todo
'{calendar} change': function(calendar, date){
// Update the todo if one exists
if (this._todo) {
Expand Down
Loading

0 comments on commit 2b99514

Please sign in to comment.