Commit 2b995142 authored by Sindre Sorhus's avatar Sindre Sorhus

Convert from .select() to .focus()

#203
parent dbe7faa2
......@@ -28,7 +28,7 @@
},
'dblclick .view': function() {
this.view.$().addClass('editing');
this.view.$('.edit').select();
this.view.$('.edit').focus();
},
'click .destroy': function() {
this.destroy();
......
......@@ -9,7 +9,6 @@ todomvc.directive('todoFocus', function( $timeout ) {
if ( newval ) {
$timeout(function() {
elem[0].focus();
elem[0].select();
}, 0, false);
}
});
......
......@@ -9,7 +9,6 @@ todomvc.directive('todoFocus', function( $timeout ) {
if ( newval ) {
$timeout(function() {
elem[0].focus();
elem[0].select();
}, 0, false);
}
});
......
......@@ -114,7 +114,7 @@ fa(W)||f(Error("Invalid component class "+W));fa(V)||f(Error("Invalid renderer c
Md.prototype.remove=function(a){Ka(this.V,function(b){return a.o()===b.o()});Nd(this)};function Nd(a,b){(b===i||b)&&Pd(a);a.dispatchEvent(new Qd(a))}Md.prototype.getAll=p("V");function Pd(a){if(a.K){var b=[];D(a.V,function(a){b.push({completed:a.ia,title:a.vb,id:a.o()})});a.K.set("todos-closure",b)}}function Qd(a){K.call(this,"change",a)}B(Qd,K);G&&J(8);"ScriptEngine"in v&&"JScript"==v.ScriptEngine()&&(v.ScriptEngineMajorVersion(),v.ScriptEngineMinorVersion(),v.ScriptEngineBuildVersion());function Rd(a){return"object"===typeof a&&a&&0===a.oc?a.content:(""+a).replace(Sd,Td)}var Ud={"\x00":"&#0;",'"':"&quot;","&":"&amp;","'":"&#39;","<":"&lt;",">":"&gt;","\t":"&#9;","\n":"&#10;","\x0B":"&#11;","\u000c":"&#12;","\r":"&#13;"," ":"&#32;","-":"&#45;","/":"&#47;","=":"&#61;","`":"&#96;","\u0085":"&#133;","\u00a0":"&#160;","\u2028":"&#8232;","\u2029":"&#8233;"};function Td(a){return Ud[a]}var Sd=/[\x00\x22\x26\x27\x3c\x3e]/g;function Vd(a){return"<strong>"+Rd(a.wb)+"</strong> "+(1==a.wb?"item":"items")+" left"};function Wd(){}B(Wd,V);y(Wd);Wd.prototype.j=function(a){var b='<button id="clear-completed">'+("Clear completed ("+Rd(a.C)+")")+"</button>",b=ac(b);vd(a,b);return b};Wd.prototype.L=s(m);Wd.prototype.T=function(a,b){a.innerHTML="Clear completed ("+Rd(b)+")"};Wd.prototype.r=function(a,b,c){(a=a.a())&&zd(a,b,c)};function Xd(){}B(Xd,V);y(Xd);Xd.prototype.j=function(a){var b='<span id="todo-count">'+Vd({wb:a.C})+"</span>",b=ac(b);vd(a,b);return b};Xd.prototype.L=s(m);Xd.prototype.T=function(a,b){a.innerHTML=Vd({wb:b})};Xd.prototype.r=function(a,b,c){(a=a.a())&&zd(a,b,c)};function Yd(){}B(Yd,V);y(Yd);Yd.prototype.j=function(a){var b;b='<li><div class="view"><input class="toggle" type="checkbox" '+(a.f&16?"checked":"")+"><label>"+Rd(a.C)+'</label><button class="destroy"></button></div><input class="edit" value="Rule the web"></li>';b=ac(b);vd(a,b);this.r(a,a.f,j);return b};Yd.prototype.r=function(a,b,c){var d=a.a();if(d){switch(b){case 16:this.Z(a,"done",c);(d?(d?d.childNodes[0]:k).childNodes[0]:k).checked=c;break;case 8:this.Z(a,"editing",c)}zd(d,b,c)}};
Yd.prototype.k=function(a){return a.a()?a.a().childNodes[1]:k};Yd.prototype.w=function(a){return a?(a?a.childNodes[0]:k).childNodes[1]:k};function Y(a){W.call(this,"",Yd.N(),a);Id(this,16,j);Id(this,8,j);this.ua&=-17;this.ua&=-9;this.Ea(j)}B(Y,W);Y.prototype.v=function(){Y.d.v.call(this);R(Vc(this),this.a(),"click",function(a){a.preventDefault()});R(Vc(this),this.a(),"dblclick",function(){this.Ia(j)});var a=this.a()?this.a().childNodes[1]:k;R(Vc(this),a,"keyup",function(a){13===a.H.keyCode&&this.Fa(m)})};
Y.prototype.xa=function(a){Y.d.xa.call(this,a);this.isEnabled()&&(a.target===(this.a()?(this.a()?this.a().childNodes[0]:k).childNodes[0]:k)?(Gd(this,!(this.f&16)),this.dispatchEvent("edit")):a.target===(this.a()?(this.a()?this.a().childNodes[0]:k).childNodes[2]:k)&&this.dispatchEvent("destroy"))};Y.prototype.Fa=function(a){Y.d.Fa.call(this,a);!a&&this.f&8&&(a=sa((this.a()?this.a().childNodes[1]:k).value),""===a?this.dispatchEvent("destroy"):(this.T(a),this.Ia(m),this.dispatchEvent("edit")))};
Y.prototype.Ia=function(a){Y.d.Ia.call(this,a);a&&(a=this.a()?this.a().childNodes[1]:k,a.value=this.C,a.select())};function Zd(){}B(Zd,V);y(Zd);Zd.prototype.j=function(a){return a.Pa().j("div",this.z())};Zd.prototype.Y=function(a,b){b.id&&a.Ga(b.id);if("HR"==b.tagName){var c=b,b=this.j(a);c.parentNode&&c.parentNode.insertBefore(b,c);cc(c)}else Rb(b,this.z());return b};Zd.prototype.T=function(){};Zd.prototype.z=s("goog-menuseparator");function $d(a,b){W.call(this,k,a||Zd.N(),b);Id(this,1,m);Id(this,2,m);Id(this,4,m);Id(this,32,m);this.f=1}B($d,W);$d.prototype.v=function(){$d.d.v.call(this);td(this.a(),"separator")};Bd("goog-menuseparator",function(){return new $d});function ae(){}y(ae);function be(a,b){a&&(a.tabIndex=b?0:-1)}u=ae.prototype;u.j=function(a){return a.Pa().j("div",this.lb(a).join(" "))};u.w=function(a){return a};u.L=function(a){return"DIV"==a.tagName};u.Y=function(a,b){b.id&&a.Ga(b.id);var c=this.z(),d=m,e=Qb(b);e&&D(e,function(b){b==c?d=j:b&&(b==c+"-disabled"?a.J(m):b==c+"-horizontal"?ce(a,de):b==c+"-vertical"&&ce(a,ee))},this);d||Rb(b,c);fe(a,this.w(b));return b};
Y.prototype.Ia=function(a){Y.d.Ia.call(this,a);a&&(a=this.a()?this.a().childNodes[1]:k,a.value=this.C,a.focus())};function Zd(){}B(Zd,V);y(Zd);Zd.prototype.j=function(a){return a.Pa().j("div",this.z())};Zd.prototype.Y=function(a,b){b.id&&a.Ga(b.id);if("HR"==b.tagName){var c=b,b=this.j(a);c.parentNode&&c.parentNode.insertBefore(b,c);cc(c)}else Rb(b,this.z());return b};Zd.prototype.T=function(){};Zd.prototype.z=s("goog-menuseparator");function $d(a,b){W.call(this,k,a||Zd.N(),b);Id(this,1,m);Id(this,2,m);Id(this,4,m);Id(this,32,m);this.f=1}B($d,W);$d.prototype.v=function(){$d.d.v.call(this);td(this.a(),"separator")};Bd("goog-menuseparator",function(){return new $d});function ae(){}y(ae);function be(a,b){a&&(a.tabIndex=b?0:-1)}u=ae.prototype;u.j=function(a){return a.Pa().j("div",this.lb(a).join(" "))};u.w=function(a){return a};u.L=function(a){return"DIV"==a.tagName};u.Y=function(a,b){b.id&&a.Ga(b.id);var c=this.z(),d=m,e=Qb(b);e&&D(e,function(b){b==c?d=j:b&&(b==c+"-disabled"?a.J(m):b==c+"-horizontal"?ce(a,de):b==c+"-vertical"&&ce(a,ee))},this);d||Rb(b,c);fe(a,this.w(b));return b};
function fe(a,b){if(b)for(var c=b.firstChild,d;c&&c.parentNode==b;){d=c.nextSibling;if(1==c.nodeType){var e;a:{e=i;for(var g=Qb(c),h=0,l=g.length;h<l;h++)if(e=g[h]in Cd?Cd[g[h]]():k)break a;e=k}e&&(e.b=c,a.isEnabled()||e.J(m),a.La(e),e.Y(c))}else(!c.nodeValue||""==sa(c.nodeValue))&&b.removeChild(c);c=d}}u.Ua=function(a){a=a.a();Rc(a,j,H);G&&(a.hideFocus=j)};u.k=function(a){return a.a()};u.z=s("goog-container");
u.lb=function(a){var b=this.z(),c=[b,a.da==de?b+"-horizontal":b+"-vertical"];a.isEnabled()||c.push(b+"-disabled");return c};function Z(a,b,c){T.call(this,c);this.c=b||ae.N();this.da=a||ee}B(Z,T);var de="horizontal",ee="vertical";u=Z.prototype;u.rb=k;u.A=k;u.c=k;u.da=k;u.i=j;u.p=j;u.kb=j;u.n=-1;u.h=k;u.ca=m;u.Ab=m;u.kc=j;u.Q=k;u.k=function(){return this.rb||this.c.k(this)};u.Qa=function(){return this.A||(this.A=new md(this.k()))};u.j=function(){this.b=this.c.j(this)};u.w=function(){return this.c.w(this.a())};u.L=function(a){return this.c.L(a)};u.hb=function(a){this.b=this.c.Y(this,a);"none"==a.style.display&&(this.i=m)};
u.v=function(){Z.d.v.call(this);id(this,function(a){a.e&&ge(this,a)},this);var a=this.a();this.c.Ua(this);this.ta(this.i,j);R(R(R(R(R(R(R(R(Vc(this),this,"enter",this.Zb),this,"highlight",this.$b),this,"unhighlight",this.dc),this,"open",this.cc),this,"close",this.Xb),a,"mousedown",this.la),Q(a),"mouseup",this.Yb),a,["mousedown","mouseup","mouseover","mouseout"],this.Wb);this.ba()&&he(this,j)};
......
......@@ -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);
};
......@@ -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();
}
};
......@@ -20,9 +20,9 @@ import com.google.gwt.safehtml.shared.SafeHtmlUtils;
* 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> {
......@@ -139,7 +139,6 @@ public class ToDoCell extends AbstractCell<ToDoItem> {
beginningEdit = true;
InputElement input = getInputElement(parent);
input.focus();
input.select();
beginningEdit = false;
}
......
......@@ -17,7 +17,7 @@
init: function(element, value_accessor, all_bindings_accessor) {
ko.bindingHandlers.hasfocus.init(element, value_accessor, all_bindings_accessor);
return ko.utils.registerEventHandler(element, 'focus', function() {
return element.select();
return element.focus();
});
},
update: function(element, value_accessor) {
......
......@@ -45,7 +45,7 @@
this.onCheckEditBegin = function() {
if (!_this.editing() && !_this.completed()) {
_this.editing(true);
return $('.todo-input').focus();
return;
}
};
this.onCheckEditEnd = function(view_model, event) {
......
......@@ -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 ) {
......@@ -182,4 +182,4 @@
};
crossroads.parse( location.hash.replace('#', '') );
}());
\ No newline at end of file
}());
......@@ -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) ->
......@@ -79,4 +79,4 @@ class Alfred.Todo extends Batman.Model
set: (key, value) -> core.set.call(@, key, value?.trim())
window.Alfred = Alfred
Alfred.run()
\ No newline at end of file
Alfred.run()
......@@ -118,7 +118,7 @@
editing = todo.set('editing', !todo.get('editing'));
if (editing) {
input = document.getElementById("todo-input-" + (todo.get('id')));
return input.select();
return input.focus();
} else {
if (((_ref = todo.get('title')) != null ? _ref.length : void 0) > 0) {
return todo.save(function(err, todo) {
......
......@@ -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.
......@@ -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',
......@@ -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){
......@@ -52,7 +52,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -66,7 +66,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -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){
......@@ -91,7 +91,7 @@ Todo = can.Model({
def.resolve({});
return def
}
},{
prettyDate: function(raw){
......@@ -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) {
......@@ -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;
......@@ -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({
......@@ -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'));
......@@ -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());
});
},
......@@ -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--) {
......@@ -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"]);
......@@ -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) {
......
......@@ -4,18 +4,18 @@ require({
location: "http://canjs.us/release/latest/",
main: "can.dojo"
}]
}, ['can/dojo',
"dojo/dom",
"dojo/dom-construct",
"dojo/dom-attr",
"dojo/NodeList-manipulate",
"dijit/focus",
"dojo/domReady!"],
}, ['can/dojo',
"dojo/dom",
"dojo/dom-construct",
"dojo/dom-attr",
"dojo/NodeList-manipulate",
"dijit/focus",
"dojo/domReady!"],
function(can, dom, domConstruct, domAttr){
// Basic Todo entry model
// { text: 'todo', complete: false }
Todo = can.Model({
// Implement local storage handling
localStore: function(cb){
var name = 'todos-canjs-dojo',
......@@ -28,7 +28,7 @@ Todo = can.Model({
window.localStorage[name] = dojo.toJson(data);
}
},
findAll: function(params){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -41,7 +41,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -55,7 +55,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -65,7 +65,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},
update: function(id, attrs){
var def = new dojo.Deferred();
this.localStore(function(todos){
......@@ -80,31 +80,31 @@ Todo = can.Model({
def.resolve({});
return def
}
},{});
// 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({
......@@ -115,7 +115,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'));
},
......@@ -136,11 +136,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());
});
},
......@@ -182,7 +182,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--) {
......
......@@ -10,7 +10,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-jquery-widget',
......@@ -23,7 +23,7 @@ Todo = can.Model({
window.localStorage[name] = JSON.stringify(data);
}
},
findAll: function(params){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -36,7 +36,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -50,7 +50,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -60,7 +60,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},
update: function(id, attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -75,9 +75,9 @@ Todo = can.Model({
def.resolve({});
return def
}
},{
prettyDate: function(raw){
var raw = this.attr('dueDate');
if (!raw) {
......@@ -86,7 +86,7 @@ Todo = can.Model({
var date = new Date(raw),
diff = difference(new Date(), date);
if(diff === -1) {
return 'Tomorrow';
} else if(diff === 0) {
......@@ -97,7 +97,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;
......@@ -107,26 +107,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({
......@@ -137,12 +137,12 @@ Todos = can.Control({
this.element.append(can.view('todo', {
todos: this.options.todos
}));
// Clear the new todo field
$('#new-todo').val('').focus();
},
// Listen for when a new Todo has been entered
'#new-todo keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -154,16 +154,16 @@ Todos = can.Control({
});
}
},
// Handle a newly created Todo
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},
// Listen for editing a Todo
'.todo dblclick' : function(el, ev) {
el.data('todo').attr('editing', true).save(function() {
el.children('.edit').focus().select();
el.children('.edit').focus();
});
},
......@@ -175,7 +175,7 @@ Todos = can.Control({
text: el.val()
}).save();
},
// Listen for an edited Todo
'.todo .edit keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -185,19 +185,19 @@ Todos = can.Control({
'.todo .edit focusout' : function(el, ev) {
this.updateTodo(el);
},
// Listen for the toggled completion of a Todo
'.todo .toggle click' : function(el, ev) {
el.closest('.todo').data('todo')
.attr('complete', el.is(':checked'))
.save();
},
// Listen for a removed Todo
'.todo .destroy click' : function(el){
el.closest('.todo').data('todo').destroy();
},
// Listen for toggle all completed Todos
'#toggle-all click' : function(el, ev) {
var toggle = el.prop('checked');
......@@ -205,21 +205,21 @@ 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--) {
todo.attr('complete') && todo.destroy();
}
},
// Listen for a change due date request
'.todo .due-date click' : function(el, ev){
ev.preventDefault();
// Cache the todo
var todo = el.closest('.todo').data('todo');
// Display the calendar
var cal = this.options.calendar;
$('#calendar').css('top', el.offset().top + 'px');
......@@ -227,13 +227,13 @@ Todos = can.Control({
this._todo = todo;
cal.show();
},
// Listen for a clear due date
'.todo .clear-date click' : function(el, e){
el.closest('.todo').data('todo').attr('dueDate', null).save();
},
// Date change for Todo
// Date change for Todo
'{calendar} datepickerselect': function(calendar, ev){
// Update the todo if one exists
if (this._todo) {
......
......@@ -3,7 +3,7 @@
// Basic Todo entry model
// { text: 'todo', complete: false }
Todo = can.Model({
// Implement local storage handling
localStore: function(cb){
var name = 'todos-canjs-jquery',
......@@ -16,7 +16,7 @@ Todo = can.Model({
window.localStorage[name] = JSON.stringify(data);
}
},
findAll: function(params){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -29,7 +29,7 @@ Todo = can.Model({
});
return def;
},
destroy: function(id){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -43,7 +43,7 @@ Todo = can.Model({
});
return def;
},
create: function(attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -53,7 +53,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def;
},
update: function(id, attrs){
var def = new can.Deferred(), todo;
this.localStore(function(todos){
......@@ -68,31 +68,31 @@ Todo = can.Model({
def.resolve({});
return def;
}
},{});
// 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({
......@@ -103,11 +103,11 @@ Todos = can.Control({
this.element.append(can.view('todo', {
todos: this.options.todos
}));
// Clear the new todo field
$('#new-todo').val('').focus();
},
// Listen for when a new Todo has been entered
'#new-todo keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -119,16 +119,16 @@ Todos = can.Control({
});
}
},
// Handle a newly created Todo
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},
// Listen for editing a Todo
'.todo dblclick' : function(el, ev) {
el.data('todo').attr('editing', true).save(function() {
el.children('.edit').focus().select();
el.children('.edit').focus();
});
},
......@@ -140,7 +140,7 @@ Todos = can.Control({
text: el.val()
}).save();
},
// Listen for an edited Todo
'.todo .edit keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -150,19 +150,19 @@ Todos = can.Control({
'.todo .edit focusout' : function(el, ev) {
this.updateTodo(el);
},
// Listen for the toggled completion of a Todo
'.todo .toggle click' : function(el, ev) {
el.closest('.todo').data('todo')
.attr('complete', el.is(':checked'))
.save();
},
// Listen for a removed Todo
'.todo .destroy click' : function(el){
el.closest('.todo').data('todo').destroy();
},
// Listen for toggle all completed Todos
'#toggle-all click' : function(el, ev) {
var toggle = el.prop('checked');
......@@ -170,7 +170,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--) {
......
......@@ -3,7 +3,7 @@
// Basic Todo entry model
// { text: 'todo', complete: false }
Todo = can.Model({
// Implement local storage handling
localStore: function(cb){
var name = 'todos-canjs-mootools',
......@@ -16,7 +16,7 @@ Todo = can.Model({
window.localStorage[name] = JSON.encode(data);
}
},
findAll: function(params){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -29,7 +29,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -43,7 +43,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -53,7 +53,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},
update: function(id, attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -68,31 +68,31 @@ Todo = can.Model({
def.resolve({});
return def
}
},{});
// 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({
......@@ -103,13 +103,13 @@ Todos = can.Control({
this.element[0].appendChild(can.view('todo', {
todos: this.options.todos
}));
window.todos = this.options.todos;
// Clear the new todo field
$$('#new-todo').set('value','')[0].focus();
},
// Listen for when a new Todo has been entered
'#new-todo keyup' : function(el, ev){
if(ev.code == 13){
......@@ -121,21 +121,20 @@ Todos = can.Control({
});
}
},
// Handle a newly created Todo
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},
// Listen for editing a Todo
'.todo dblclick' : function(el, ev) {
el.retrieve('todo')[0].attr('editing', true).save(function() {
var edit = el.getElement('.edit')[0];
edit.focus();
edit.select();
});
},
// Update a todo
updateTodo: function(el) {
el.getParent('.todo').retrieve('todo')[0]
......@@ -144,7 +143,7 @@ Todos = can.Control({
text: el.get('value')[0]
}).save();
},
// Listen for an edited Todo
'.todo .edit keyup' : function(el, ev){
if(ev.code == 13){
......@@ -154,19 +153,19 @@ Todos = can.Control({
'.todo .edit blur' : function(el, ev) {
this.updateTodo(el);
},
// Listen for the toggled completion of a Todo
'.todo .toggle click' : function(el, ev) {
el.getParent('.todo').retrieve('todo')[0]
.attr('complete', el.get('checked')[0])
.save();
},
// Listen for a removed Todo
'.todo .destroy click' : function(el){
el.getParent('.todo').retrieve('todo')[0].destroy();
},
// Listen for toggle all completed Todos
'#toggle-all click' : function(el, ev) {
var toggle = el.get('checked')[0];
......@@ -174,7 +173,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--) {
......
......@@ -12,7 +12,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-yui-widget',
......@@ -25,7 +25,7 @@ Todo = can.Model({
window.localStorage[name] = Y.JSON.stringify(data);
}
},
findAll: function(params){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -38,7 +38,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -52,7 +52,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -62,7 +62,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},
update: function(id, attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -77,9 +77,9 @@ Todo = can.Model({
def.resolve({});
return def
}
},{
prettyDate: function(raw){
var raw = this.attr('dueDate');
if (!raw) {
......@@ -88,7 +88,7 @@ Todo = can.Model({
var date = new Date(raw),
diff = difference(new Date(), date);
if(diff === -1) {
return 'Tomorrow';
} else if(diff === 0) {
......@@ -99,7 +99,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;
......@@ -109,26 +109,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({
......@@ -139,10 +139,10 @@ Todos = can.Control({
this.element.append(can.view('todo', {
todos: this.options.todos
}));
// Clear the new todo field
Y.one('#new-todo').set('value','').focus();
// Hide the calendar on page click
var cal = this.options.calendar;
Y.one(document).on('click', function(ev) {
......@@ -151,7 +151,7 @@ Todos = can.Control({
}
});
},
// Listen for when a new Todo has been entered
'#new-todo keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -163,16 +163,16 @@ Todos = can.Control({
});
}
},
// Handle a newly created Todo
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},
// Listen for editing a Todo
'.todo dblclick' : function(el) {
el.getData('todo').attr('editing', true).save(function() {
el.one('.edit').focus().select();
el.one('.edit').focus();
});
},
......@@ -184,7 +184,7 @@ Todos = can.Control({
text: el.get('value')
}).save();
},
// Listen for an edited Todo
'.todo .edit keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -194,19 +194,19 @@ Todos = can.Control({
'.todo .edit blur' : function(el, ev) {
this.updateTodo(el);
},
// Listen for the toggled completion of a Todo
'.todo .toggle click' : function(el, ev) {
el.ancestor('.todo').getData('todo')
.attr('complete', el.get('checked'))
.save();
},
// Listen for a removed Todo
'.todo .destroy click' : function(el){
el.ancestor('.todo').getData('todo').destroy();
},
// Listen for toggle all completed Todos
'#toggle-all click' : function(el, ev) {
var toggle = el.get('checked');
......@@ -214,21 +214,21 @@ 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--) {
todo.attr('complete') && todo.destroy();
}
},
// Listen for a change due date request
'.todo .due-date click' : function(el, ev){
ev.preventDefault();
// Cache the todo
var todo = el.ancestor('.todo').getData('todo');
// Display the calendar
var cal = this.options.calendar;
Y.one('#calendar').setStyle('top', el.getY() + 'px');
......@@ -237,13 +237,13 @@ Todos = can.Control({
this._todo = todo;
cal.show();
},
// Listen for a clear due date
'.todo .clear-date click' : function(el, e){
el.ancestor('.todo').getData('todo').attr('dueDate', null).save();
},
// Date change for Todo
// Date change for Todo
'{calendar} selectionChange': function(calendar, ev){
// Update the todo if one exists
if (this._todo) {
......
......@@ -5,7 +5,7 @@ YUI().use(/* CanJS */ 'can', 'json', 'node', function(Y) {
// Basic Todo entry model
// { text: 'todo', complete: false }
Todo = can.Model({
// Implement local storage handling
localStore: function(cb){
var name = 'todos-canjs-yui',
......@@ -18,7 +18,7 @@ Todo = can.Model({
window.localStorage[name] = Y.JSON.stringify(data);
}
},
findAll: function(params){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -31,7 +31,7 @@ Todo = can.Model({
})
return def;
},
destroy: function(id){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -45,7 +45,7 @@ Todo = can.Model({
});
return def
},
create: function(attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -55,7 +55,7 @@ Todo = can.Model({
def.resolve({id : attrs.id});
return def
},
update: function(id, attrs){
var def = new can.Deferred();
this.localStore(function(todos){
......@@ -70,31 +70,31 @@ Todo = can.Model({
def.resolve({});
return def
}
},{});
// 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({
......@@ -105,11 +105,11 @@ Todos = can.Control({
this.element.append(can.view('todo', {
todos: this.options.todos
}));
// Clear the new todo field
Y.one('#new-todo').set('value','').focus();
},
// Listen for when a new Todo has been entered
'#new-todo keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -121,16 +121,16 @@ Todos = can.Control({
});
}
},
// Handle a newly created Todo
'{Todo} created' : function(list, ev, item){
this.options.todos.push(item);
},
// Listen for editing a Todo
'.todo dblclick' : function(el) {
el.getData('todo').attr('editing', true).save(function() {
el.one('.edit').focus().select();
el.one('.edit').focus();
});
},
......@@ -142,7 +142,7 @@ Todos = can.Control({
text: el.get('value')
}).save();
},
// Listen for an edited Todo
'.todo .edit keyup' : function(el, ev){
if(ev.keyCode == 13){
......@@ -152,19 +152,19 @@ Todos = can.Control({
'.todo .edit blur' : function(el, ev) {
this.updateTodo(el);
},
// Listen for the toggled completion of a Todo
'.todo .toggle click' : function(el, ev) {
el.ancestor('.todo').getData('todo')
.attr('complete', el.get('checked'))
.save();
},
// Listen for a removed Todo
'.todo .destroy click' : function(el){
el.ancestor('.todo').getData('todo').destroy();
},
// Listen for toggle all completed Todos
'#toggle-all click' : function(el, ev) {
var toggle = el.get('checked');
......@@ -172,7 +172,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--) {
......
......@@ -33,7 +33,7 @@ define(function () {
* @param node {Node} Dom node of the todo
*/
beginEditTodo: function(node) {
this.querySelector('.edit', node).select();
this.querySelector('.edit', node).focus();
},
/**
......@@ -127,4 +127,4 @@ define(function () {
}
}
});
\ No newline at end of file
});
......@@ -25,7 +25,7 @@ maria.ElementView.subclass(checkit, 'TodoView', {
var input = this.find('.todo-input');
input.value = this.getModel().getContent();
aristocrat.addClass(this.find('.todo'), 'editing');
input.select();
input.focus();
},
showDisplay: function() {
aristocrat.removeClass(this.find('.todo'), 'editing');
......
......@@ -9,7 +9,7 @@ if Meteor.is_client
hasTask = Tasks.find().count() > 0
if hasTask
$('#main, #footer').removeClass('hidden')
else
else
$('#main, #footer').addClass('hidden')
# Listen to change on collection Tasks.
......@@ -69,7 +69,7 @@ if Meteor.is_client
'click .toggle': (evt) ->
task = Tasks.findOne this._id
task.completed = $(evt.target).prop('checked')
Tasks.update _id: this._id, task
Tasks.update _id: this._id, task
# force DOM redraw
Meteor.flush()
......@@ -84,7 +84,7 @@ if Meteor.is_client
# force DOM redraw, so we can select the edit field
Meteor.flush()
$('.edit').select()
$('.edit').focus()
'blur input.edit': (evt) ->
text = $(evt.target).val().trim()
......@@ -111,6 +111,6 @@ if Meteor.is_client
Template.item.completedClass = ->
if this.completed then 'completed' else ''
Template.item.completedCheck = ->
if this.completed then 'checked' else ''
......@@ -119,7 +119,7 @@ exports.TodoView = Montage.create(Component, {
value: function() {
if (this.isEditing) {
this.element.classList.add("editing");
this.editInput.element.select();
this.editInput.element.focus();
} else {
this.element.classList.remove("editing");
this.editInput.element.blur();
......
......@@ -16,7 +16,7 @@
this.editing( true );
var self = this;
setTimeout(function() {
$( self.el ).parent().find('input.edit').select();
$( self.el ).parent().find('input.edit').focus();
}, 0);
},
......@@ -177,4 +177,4 @@
// kick it off
main();
})( window );
\ No newline at end of file
})( window );
define( 'Todos/List',
define( 'Todos/List',
[ 'Olives/OObject', 'Olives/Event-plugin', 'Olives/Model-plugin', 'Todos/Tools' ],
// The List UI
function List( OObject, EventPlugin, ModelPlugin, Tools ) {
return function ListInit( view, model, stats ) {
// The OObject (the controller) inits with a default model which is a simple store
// But it can be init'ed with any other store, like the LocalStore
var list = new OObject( model ),
ENTER_KEY = 13;
// The plugins
list.plugins.addAll({
'event': new EventPlugin( list ),
......@@ -25,29 +25,29 @@ function List( OObject, EventPlugin, ModelPlugin, Tools ) {
}
})
});
// Remove the completed task
list.remove = function remove( event, node ) {
model.del( node.getAttribute('data-model_id') );
};
// Un/check all tasks
list.toggleAll = function toggleAll( event, node ) {
var checked = !!node.checked;
model.loop( function ( value, idx ) {
this.update( idx, 'completed', checked );
}, model);
};
// Enter edit mode
list.startEdit = function ( event, node ) {
var taskId = node.getAttribute('data-model_id');
Tools.toggleClass.call( view.querySelector('li[data-model_id="' + taskId + '"]'), true, 'editing' );
view.querySelector('input.edit[data-model_id="' + taskId + '"]').select();
view.querySelector('input.edit[data-model_id="' + taskId + '"]').focus();
};
// Leave edit mode
list.stopEdit = function ( event, node ) {
var taskId = node.getAttribute('data-model_id'),
......@@ -55,7 +55,7 @@ function List( OObject, EventPlugin, ModelPlugin, Tools ) {
if ( event.keyCode === ENTER_KEY ) {
value = node.value.trim();
if ( value ) {
model.update( taskId, 'title', value );
} else {
......@@ -70,10 +70,10 @@ function List( OObject, EventPlugin, ModelPlugin, Tools ) {
Tools.toggleClass.call( view.querySelector('li[data-model_id="' + taskId + '"]'), false, 'editing' );
}
};
// Alive applies the plugins to the HTML view
list.alive( view );
};
});
\ No newline at end of file
});
......@@ -57,7 +57,7 @@ function xc(a,b){"-"==b.charAt(0)&&(b="."+b.substring(1));var c;if("."==b.charAt
n.bind=function(a,b,c){a=this.l.bind(a,b,c||this);this.N.push(a);return a};n.ea=function(a,b){var c=this.l.ea(a,b||this);this.N.push(c);return c};n.fa=function(a,b){var c=this.l.fa(a,b||this);this.N.push(c);return c};n.ta=function(a,b){var c=this.l.ta(a,b||this);this.N.push(c);return c};n.Da=function(a,b){var c=this.l.Da(a,b||this);this.N.push(c);return c};n.t=function(a){return this.l.t(a)};n.d=function(){B(this.N,function(a){this.t(a)},this);this.r=k;Z.j.d.call(this)};F&&J(8);var yc={};"ScriptEngine"in o&&"JScript"==o.ScriptEngine()&&(o.ScriptEngineMajorVersion(),o.ScriptEngineMinorVersion(),o.ScriptEngineBuildVersion());function zc(a){return"object"===typeof a&&a&&0===a.Hb?a.content:(""+a).replace(Ac,Bc)}var Cc={"\x00":"&#0;",'"':"&quot;","&":"&amp;","'":"&#39;","<":"&lt;",">":"&gt;","\t":"&#9;","\n":"&#10;","\x0B":"&#11;","\u000c":"&#12;","\r":"&#13;"," ":"&#32;","-":"&#45;","/":"&#47;","=":"&#61;","`":"&#96;","\u0085":"&#133;","\u00a0":"&#160;","\u2028":"&#8232;","\u2029":"&#8233;"};function Bc(a){return Cc[a]}var Ac=/[\x00\x22\x26\x27\x3c\x3e]/g;function Dc(a){Z.call(this,a)}y(Dc,Z);
Dc.prototype.xa=function(){var a={g:this.l.ra()},b=new nb(k)||mb(),a="<li "+((a||yc).g.completed?'class="completed"':"")+'><div class="view"><input class="toggle" type="checkbox" '+((a||yc).g.completed?"checked":"")+"><label>"+zc((a||yc).g.title)+'</label><button class="destroy"></button></div><input class="edit" type="text" value=""></li>';var c=b.B,b=c.createElement("div");F?(b.innerHTML="<br>"+a,b.removeChild(b.firstChild)):b.innerHTML=a;if(1==b.childNodes.length)a=b.removeChild(b.firstChild);
else for(a=c.createDocumentFragment();b.firstChild;)a.appendChild(b.firstChild);this.h=a};
Dc.prototype.C=function(){var a=this.l;this.click(function(b){a.set("completed",b.target.checked)},"toggle");this.click(function(){a.k()},"destroy");wc(this,"dblclick",function(){var a=xc(this,".edit")[0];eb(this.w(),"editing");a.value=this.l.get("title");a.select()},"view");var b=xc(this,".edit")[0];wc(this,"keyup",function(c){13===c.keyCode&&a.set("title",b.value)},"edit");wc(this,"blur",function(){a.set("title",b.value)},"edit")};function Ec(a){Z.call(this,a);this.Qa=Fc}y(Ec,Z);function Fc(){return j}function Gc(a){return!a.get("completed")}function Hc(a){return a.get("completed")}
Dc.prototype.C=function(){var a=this.l;this.click(function(b){a.set("completed",b.target.checked)},"toggle");this.click(function(){a.k()},"destroy");wc(this,"dblclick",function(){var a=xc(this,".edit")[0];eb(this.w(),"editing");a.value=this.l.get("title");a.focus()},"view");var b=xc(this,".edit")[0];wc(this,"keyup",function(c){13===c.keyCode&&a.set("title",b.value)},"edit");wc(this,"blur",function(){a.set("title",b.value)},"edit")};function Ec(a){Z.call(this,a);this.Qa=Fc}y(Ec,Z);function Fc(){return j}function Gc(a){return!a.get("completed")}function Hc(a){return a.get("completed")}
Ec.prototype.C=function(){Ec.j.C.call(this);var a=this.l,b=xc(this,"input")[0];wc(this,"keyup",function(c){13===c.keyCode&&(c=la(b.value),""!==c&&(c=new a.Va({title:c}),a.add(c,0,i),b.value=""))},"todo-entry");this.click(function(){B(a.get("completed"),function(a){a.k()})},"clear-completed");this.click(function(b){var d=b.target.checked;B(Ub(a),function(a){a.set("completed",d)})},"toggle-all");this.ta(function(){this.refresh();a.save()},this);this.Da(function(){Ic(!!a.a.length)},this);Ic(!!a.a.length);
this.bind("completed",function(b){var d=M("todo-count"),e;e=a.a.length-b.length;e="<strong>"+zc(e)+"</strong> item"+(1!=e?"s":"")+" left";d.innerHTML=e;d=M("clear-completed");e="Clear completed ("+b.length+")";if("textContent"in d)d.textContent=e;else if(d.firstChild&&3==d.firstChild.nodeType){for(;d.lastChild!=d.firstChild;)d.removeChild(d.lastChild);d.firstChild.data=e}else tb(d),d.appendChild(L(d).createTextNode(e));d.style.display=b.length?"":"none";xc(this,".toggle-all")[0].checked=b.length===
a.a.length});a.aa.Za(a,i)};function Ic(a){var b=M("main"),c=ob("footer",i,i)[0];b.style.display=a?"":"none";c.style.display=a?"":"none"}function Jc(a){var b=Kc;b.Qa=a;b.refresh()}
......@@ -66,4 +66,4 @@ this.i&&a.getParent()==this?(c=this.h,c.insertBefore(a.w(),c.childNodes[b]||k)):
function Oc(a,b,c){switch(typeof b){case "string":Pc(b,c);break;case "number":c.push(isFinite(b)&&!isNaN(b)?b:"null");break;case "boolean":c.push(b);break;case "undefined":c.push("null");break;case "object":if(b==k){c.push("null");break}if(r(b)){var d=b.length;c.push("[");for(var e="",f=0;f<d;f++)c.push(e),e=b[f],Oc(a,a.na?a.na.call(b,""+f,e):e,c),e=",";c.push("]");break}c.push("{");d="";for(f in b)Object.prototype.hasOwnProperty.call(b,f)&&(e=b[f],"function"!=typeof e&&(c.push(d),Pc(f,c),c.push(":"),
Oc(a,a.na?a.na.call(b,f,e):e,c),d=","));c.push("}");break;case "function":break;default:g(Error("Unknown type: "+typeof b))}}var Qc={'"':'\\"',"\\":"\\\\","/":"\\/","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\x0B":"\\u000b"},Rc=/\uffff/.test("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
function Pc(a,b){b.push('"',a.replace(Rc,function(a){if(a in Qc)return Qc[a];var b=a.charCodeAt(0),e="\\u";16>b?e+="000":256>b?e+="00":4096>b&&(e+="0");return Qc[a]=e+b.toString(16)}),'"')};function Sc(){};function Tc(a){this.Y=a;this.cb=new Mc}n=Tc.prototype;n.Y=k;n.cb=k;n.set=function(a,b){q(b)?this.Y.set(a,Nc(this.cb,b)):this.Y.remove(a)};n.get=function(a){a=this.Y.get(a);if(a!==k)try{return Lc(a)}catch(b){g("Storage: Invalid value was encountered")}};n.remove=function(a){this.Y.remove(a)};function Uc(){}y(Uc,Sc);function Vc(a){this.pa=a}y(Vc,Uc);Vc.prototype.set=function(a,b){try{this.pa.setItem(a,b)}catch(c){g("Storage mechanism: Quota exceeded")}};Vc.prototype.get=function(a){a=this.pa.getItem(a);if(u(a)||a===k)return a;g("Storage mechanism: Invalid value was encountered")};Vc.prototype.remove=function(a){this.pa.removeItem(a)};function Wc(){var a=k;try{a=window.localStorage||k}catch(b){}this.pa=a}y(Wc,Vc);function Xc(){this.qa=new Tc(new Wc)}Xc.prototype.create=function(a){var b;this.Na=this.Na||0;b=this.Na++ +"|"+parseInt((new Date).getTime(),36);a.set("id",b)};Xc.prototype.Za=function(a){a.set(this.qa.get(a.get("id")))};Xc.prototype.update=function(a){this.qa.set(a.get("id"),a.ra())};function Yc(){Xc.call(this)}y(Yc,Xc);Yc.prototype.Za=function(a){var b=this.qa.get(a.get("id"))||[];B(b,function(b){b=new a.Va(b);a.add(b,0,j)});a.u()};function Zc(a){V.call(this,a);Rb(this,function(a){a=la(a);a.length||g(new Pb);return a});Tb(this,function(){this.k()})}y(Zc,V);function $c(){W.call(this,{id:"todos-plastronjs",sync:new Yc,schema:{completed:{get:function(){return Ub(this,function(a){return a.get("completed")})},wb:j}},modelType:Zc})}y($c,W);$c.prototype.ra=function(){return C(Ub(this),function(a){return a.ra()})};var ad=new $c,Kc=new Ec(ad),$=Kc,bd=M("todoapp");$.i&&g(Error("Component already rendered"));if(bd){$.jb=j;if(!$.I||$.I.B!=L(bd))$.I=mb(bd);$.h=bd;$.C()}else g(Error("Invalid element to decorate"));var cd=new pc;
function dd(a){var b=ob("A",i,M("filters"));B(b,function(b){var d;cb&&"innerText"in b?d=b.innerText.replace(/(\r\n|\r|\n)/g,"\n"):(d=[],xb(b,d,j),d=d.join(""));d=d.replace(/ \xAD /g," ").replace(/\xAD/g,"");d=d.replace(/\u200B/g,"");cb||(d=d.replace(/ +/g," "));" "!=d&&(d=d.replace(/^\s*/,""));d===a?eb(b,"selected"):fb(b,"selected")})}cd.$("/",function(){Jc(Fc);dd("All")});cd.$("/active",function(){Jc(Gc);dd("Active")});cd.$("/completed",function(){Jc(Hc);dd("Completed")});})();
\ No newline at end of file
function dd(a){var b=ob("A",i,M("filters"));B(b,function(b){var d;cb&&"innerText"in b?d=b.innerText.replace(/(\r\n|\r|\n)/g,"\n"):(d=[],xb(b,d,j),d=d.join(""));d=d.replace(/ \xAD /g," ").replace(/\xAD/g,"");d=d.replace(/\u200B/g,"");cb||(d=d.replace(/ +/g," "));" "!=d&&(d=d.replace(/^\s*/,""));d===a?eb(b,"selected"):fb(b,"selected")})}cd.$("/",function(){Jc(Fc);dd("All")});cd.$("/active",function(){Jc(Gc);dd("Active")});cd.$("/completed",function(){Jc(Hc);dd("Completed")});})();
......@@ -59,7 +59,7 @@ todomvc.todocontrol.prototype.enterDocument = function() {
this.on( goog.events.EventType.DBLCLICK, function( e ) {
goog.dom.classes.add( this.getElement(), 'editing' );
inputEl.value = model.get('title');
inputEl.select();
inputEl.focus();
}, 'view' );
// Save on edit
......
......@@ -18,7 +18,7 @@
this.set( 'editing', true );
e.preventDefault();
this.$.inputElement.$el.select();
this.$.inputElement.$el.focus();
return false;
},
......@@ -81,4 +81,4 @@
<input class="edit" cid="inputElement" type="text" value="{{todo.title|trim()}}"
onkeyup="updateTodo" onblur="updateTodo" updateOnEvent="change"/>
</js:Template>
</ui:View>
\ No newline at end of file
</ui:View>
......@@ -39,7 +39,7 @@ var todo = window.todo || {};
},
edit: function( event ) {
$( this ).closest('li').addClass('editing').find('.edit').select();
$( this ).closest('li').addClass('editing').find('.edit').focus();
},
update: function( event ) {
......@@ -118,4 +118,4 @@ var todo = window.todo || {};
todo.FooterView.NAME = 'FooterView';
})( window );
\ No newline at end of file
})( window );
......@@ -181,7 +181,7 @@ define( [ "troopjs-core/component/widget", "troopjs-core/store/local", "jquery",
$input
.val(items[index].title)
.removeProp("disabled")
.select();
.focus();
})
.fail(function failGet() {
$li.removeClass("editing");
......
......@@ -9,7 +9,6 @@ define(['app'], function ( app ) {
if ( newval ) {
$timeout(function() {
elem[0].focus();
elem[0].select();
}, 0, false);
}
});
......
......@@ -32,7 +32,7 @@ define([
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 ) {
......@@ -43,4 +43,4 @@ define([
}, 0 );
}
};
});
\ No newline at end of file
});
......@@ -82,7 +82,7 @@
inputEditTodo = document.getElementById( 'input_' + todoId );
div.className = 'editing';
inputEditTodo.select();
inputEditTodo.focus();
}
function checkboxChangeHandler( event ) {
......@@ -310,4 +310,4 @@
}
return uuid;
}
})();
\ No newline at end of file
})();
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment