Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
todomvc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eugene Shen
todomvc
Commits
9df98e41
Commit
9df98e41
authored
Nov 22, 2014
by
Olivier Scherrer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Olives: Update Olives and Emily to latest 1.x versions
parent
b9c3b488
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
3934 additions
and
2909 deletions
+3934
-2909
examples/olives/bower.json
examples/olives/bower.json
+2
-2
examples/olives/bower_components/emily/build/Emily.js
examples/olives/bower_components/emily/build/Emily.js
+1423
-1005
examples/olives/bower_components/olives/build/Olives.js
examples/olives/bower_components/olives/build/Olives.js
+1518
-964
examples/olives/bower_components/olives/src/Bind.plugin.js
examples/olives/bower_components/olives/src/Bind.plugin.js
+604
-573
examples/olives/bower_components/olives/src/DomUtils.js
examples/olives/bower_components/olives/src/DomUtils.js
+2
-0
examples/olives/bower_components/olives/src/Event.plugin.js
examples/olives/bower_components/olives/src/Event.plugin.js
+118
-116
examples/olives/bower_components/olives/src/LocalStore.js
examples/olives/bower_components/olives/src/LocalStore.js
+3
-1
examples/olives/bower_components/olives/src/OObject.js
examples/olives/bower_components/olives/src/OObject.js
+180
-174
examples/olives/bower_components/olives/src/Place.plugin.js
examples/olives/bower_components/olives/src/Place.plugin.js
+67
-65
examples/olives/bower_components/olives/src/Plugins.js
examples/olives/bower_components/olives/src/Plugins.js
+2
-0
examples/olives/bower_components/olives/src/SocketIOTransport.js
...s/olives/bower_components/olives/src/SocketIOTransport.js
+15
-9
No files found.
examples/olives/bower.json
View file @
9df98e41
...
...
@@ -2,8 +2,8 @@
"name"
:
"todomvc-olives"
,
"version"
:
"0.0.0"
,
"dependencies"
:
{
"olives"
:
"~1.
4
.0"
,
"emily"
:
"~1.
3.5
"
,
"olives"
:
"~1.
6
.0"
,
"emily"
:
"~1.
8.1
"
,
"requirejs"
:
"~2.1.5"
,
"todomvc-common"
:
"~0.3.0"
}
...
...
examples/olives/bower_components/emily/build/Emily.js
View file @
9df98e41
This diff is collapsed.
Click to expand it.
examples/olives/bower_components/olives/build/Olives.js
View file @
9df98e41
This diff is collapsed.
Click to expand it.
examples/olives/bower_components/olives/src/Bind.plugin.js
View file @
9df98e41
...
...
@@ -13,6 +13,8 @@ define(["Store", "Observable", "Tools", "DomUtils"],
*/
function
BindPlugin
(
Store
,
Observable
,
Tools
,
DomUtils
)
{
"
use strict
"
;
return
function
BindPluginConstructor
(
$model
,
$bindings
)
{
/**
...
...
@@ -32,14 +34,28 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* each foreach has its itemRenderer
* @private
*/
_itemRenderers
=
{};
_itemRenderers
=
{},
/**
* The observers handlers
* for debugging only
* @private
*/
this
.
observers
=
{};
_observers
=
{};
/**
* Exposed for debugging purpose
* @private
*/
this
.
observers
=
_observers
;
function
_removeObserversForId
(
id
)
{
if
(
_observers
[
id
])
{
_observers
[
id
].
forEach
(
function
(
handler
)
{
_model
.
unwatchValue
(
handler
);
});
delete
_observers
[
id
];
}
}
/**
* Define the model to watch for
...
...
@@ -133,7 +149,9 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
_rootNode
=
rootNode
;
renderer
=
_rootNode
.
querySelector
(
"
*
"
);
this
.
setRenderer
(
renderer
);
renderer
&&
_rootNode
.
removeChild
(
renderer
);
if
(
renderer
)
{
_rootNode
.
removeChild
(
renderer
);
}
return
true
;
}
else
{
return
false
;
...
...
@@ -173,7 +191,7 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* The nodes created from the items are stored here
* @private
*/
this
.
items
=
new
Store
([])
;
this
.
items
=
{}
;
/**
* Set the start limit
...
...
@@ -182,7 +200,8 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* @returns the value
*/
this
.
setStart
=
function
setStart
(
start
)
{
return
_start
=
parseInt
(
start
,
10
);
_start
=
parseInt
(
start
,
10
);
return
_start
;
};
/**
...
...
@@ -201,7 +220,8 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* @returns the value
*/
this
.
setNb
=
function
setNb
(
nb
)
{
return
_nb
=
nb
==
"
*
"
?
nb
:
parseInt
(
nb
,
10
);
_nb
=
nb
==
"
*
"
?
nb
:
parseInt
(
nb
,
10
);
return
_nb
;
};
/**
...
...
@@ -223,12 +243,16 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
var
node
,
next
;
if
(
typeof
id
==
"
number
"
&&
!
this
.
items
.
get
(
id
))
{
if
(
typeof
id
==
"
number
"
&&
!
this
.
items
[
id
])
{
next
=
this
.
getNextItem
(
id
);
node
=
this
.
create
(
id
);
if
(
node
)
{
// IE (until 9) apparently fails to appendChild when insertBefore's second argument is null, hence this.
next
=
this
.
getNextItem
(
id
);
next
?
_rootNode
.
insertBefore
(
node
,
next
)
:
_rootNode
.
appendChild
(
node
);
if
(
next
)
{
_rootNode
.
insertBefore
(
node
,
next
);
}
else
{
_rootNode
.
appendChild
(
node
);
}
return
true
;
}
else
{
return
false
;
...
...
@@ -245,11 +269,18 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* @returns
*/
this
.
getNextItem
=
function
getNextItem
(
id
)
{
return
this
.
items
.
alter
(
"
slice
"
,
id
+
1
).
filter
(
function
(
value
)
{
if
(
DomUtils
.
isAcceptedType
(
value
))
{
return
true
;
var
keys
=
Object
.
keys
(
this
.
items
).
map
(
function
(
string
)
{
return
Number
(
string
);
}),
closest
=
Tools
.
closestGreater
(
id
,
keys
),
closestId
=
keys
[
closest
];
// Only return if different
if
(
closestId
!=
id
)
{
return
this
.
items
[
closestId
];
}
else
{
return
;
}
})[
0
];
};
/**
...
...
@@ -259,10 +290,11 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
* @returns
*/
this
.
removeItem
=
function
removeItem
(
id
)
{
var
item
=
this
.
items
.
get
(
id
)
;
var
item
=
this
.
items
[
id
]
;
if
(
item
)
{
_rootNode
.
removeChild
(
item
);
this
.
items
.
set
(
id
);
delete
this
.
items
[
id
];
_removeObserversForId
(
id
);
return
true
;
}
else
{
return
false
;
...
...
@@ -286,7 +318,7 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
child
.
setAttribute
(
"
data-
"
+
_plugins
.
name
+
"
_id
"
,
id
);
});
this
.
items
.
set
(
id
,
newNode
)
;
this
.
items
[
id
]
=
newNode
;
_plugins
.
apply
(
newNode
);
return
newNode
;
}
...
...
@@ -310,8 +342,10 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
if
(
_nb
!==
null
&&
_start
!==
null
)
{
// Loop through the existing items
this
.
items
.
loop
(
function
(
value
,
idx
)
{
Tools
.
loop
(
this
.
items
,
function
(
value
,
idx
)
{
// If an item is out of the boundary
idx
=
Number
(
idx
);
if
(
idx
<
_start
||
idx
>=
(
_start
+
_tmpNb
)
||
!
_model
.
has
(
idx
))
{
// Mark it
marked
.
push
(
idx
);
...
...
@@ -378,10 +412,7 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
_model
.
watch
(
"
deleted
"
,
function
(
idx
)
{
itemRenderer
.
render
();
// Also remove all observers
this
.
observers
[
idx
]
&&
this
.
observers
[
idx
].
forEach
(
function
(
handler
)
{
_model
.
unwatchValue
(
handler
);
},
this
);
delete
this
.
observers
[
idx
];
_removeObserversForId
(
idx
);
},
this
);
this
.
setItemRenderer
(
idItemRenderer
,
itemRenderer
);
...
...
@@ -533,14 +564,14 @@ function BindPlugin(Store, Observable, Tools, DomUtils) {
/**
* Prevents the submit and set the model with all form's inputs
* @param {HTMLFormElement} for
m
* @param {HTMLFormElement} DOMfro
m
* @returns true if valid form
*/
this
.
form
=
function
form
(
form
)
{
if
(
form
&&
form
.
nodeName
==
"
FORM
"
)
{
this
.
form
=
function
form
(
DOM
form
)
{
if
(
DOMform
&&
DOM
form
.
nodeName
==
"
FORM
"
)
{
var
that
=
this
;
form
.
addEventListener
(
"
submit
"
,
function
(
event
)
{
Tools
.
toArray
(
form
.
querySelectorAll
(
"
[name]
"
)).
forEach
(
that
.
set
,
that
);
DOM
form
.
addEventListener
(
"
submit
"
,
function
(
event
)
{
Tools
.
toArray
(
DOM
form
.
querySelectorAll
(
"
[name]
"
)).
forEach
(
that
.
set
,
that
);
event
.
preventDefault
();
},
true
);
return
true
;
...
...
examples/olives/bower_components/olives/src/DomUtils.js
View file @
9df98e41
...
...
@@ -6,6 +6,8 @@
define
([
"
Tools
"
],
function
(
Tools
)
{
"
use strict
"
;
return
{
/**
* Returns a NodeList including the given dom node,
...
...
examples/olives/bower_components/olives/src/Event.plugin.js
View file @
9df98e41
...
...
@@ -14,6 +14,8 @@ define(["DomUtils"],
*/
function
EventPlugin
(
Utils
)
{
"
use strict
"
;
/**
* The event plugin constructor.
* ex: new EventPlugin({method: function(){} ...}, false);
...
...
examples/olives/bower_components/olives/src/LocalStore.js
View file @
9df98e41
...
...
@@ -15,6 +15,8 @@ define(["Store", "Tools"],
*/
function
LocalStore
(
Store
,
Tools
)
{
"
use strict
"
;
function
LocalStoreConstructor
()
{
/**
...
...
@@ -96,7 +98,7 @@ function LocalStore(Store, Tools) {
return
function
LocalStoreFactory
(
init
)
{
LocalStoreConstructor
.
prototype
=
new
Store
(
init
);
return
new
LocalStoreConstructor
;
return
new
LocalStoreConstructor
()
;
};
});
examples/olives/bower_components/olives/src/OObject.js
View file @
9df98e41
...
...
@@ -13,6 +13,8 @@ define(["StateMachine", "Store", "Plugins", "DomUtils", "Tools"],
*/
function
OObject
(
StateMachine
,
Store
,
Plugins
,
DomUtils
,
Tools
)
{
"
use strict
"
;
return
function
OObjectConstructor
(
otherStore
)
{
/**
...
...
@@ -45,7 +47,7 @@ function OObject(StateMachine, Store, Plugins, DomUtils, Tools) {
// as it wouldn't be possible to know which node would belong to which UI
// This is probably a DOM limitation.
if
(
baseNode
.
childNodes
.
length
>
1
)
{
thro
w
Error
(
"
UI.template should have only one parent node
"
);
throw
ne
w
Error
(
"
UI.template should have only one parent node
"
);
}
else
{
UI
.
dom
=
baseNode
.
childNodes
[
0
];
}
...
...
@@ -54,7 +56,7 @@ function OObject(StateMachine, Store, Plugins, DomUtils, Tools) {
}
else
{
// An explicit message I hope
thro
w
Error
(
"
UI.template must be set prior to render
"
);
throw
ne
w
Error
(
"
UI.template must be set prior to render
"
);
}
},
...
...
@@ -63,13 +65,17 @@ function OObject(StateMachine, Store, Plugins, DomUtils, Tools) {
* This dom node should be somewhere in the dom of the application
* @private
*/
place
=
function
place
(
UI
,
place
,
beforeNode
)
{
if
(
place
)
{
place
=
function
place
(
UI
,
DOM
place
,
beforeNode
)
{
if
(
DOM
place
)
{
// IE (until 9) apparently fails to appendChild when insertBefore's second argument is null, hence this.
beforeNode
?
place
.
insertBefore
(
UI
.
dom
,
beforeNode
)
:
place
.
appendChild
(
UI
.
dom
);
if
(
beforeNode
)
{
DOMplace
.
insertBefore
(
UI
.
dom
,
beforeNode
);
}
else
{
DOMplace
.
appendChild
(
UI
.
dom
);
}
// Also save the new place, so next renderings
// will be made inside it
_currentPlace
=
place
;
_currentPlace
=
DOM
place
;
}
},
...
...
@@ -108,7 +114,7 @@ function OObject(StateMachine, Store, Plugins, DomUtils, Tools) {
* It has set/get/del/has/watch/unwatch methods
* @see Emily's doc for more info on how it works.
*/
this
.
model
=
otherStore
instanceof
Store
?
otherStore
:
new
Store
;
this
.
model
=
otherStore
instanceof
Store
?
otherStore
:
new
Store
()
;
/**
* The module that will manage the plugins for this UI
...
...
examples/olives/bower_components/olives/src/Place.plugin.js
View file @
9df98e41
...
...
@@ -12,6 +12,8 @@ define(["OObject", "Tools"],
*/
function
PlacePlugin
(
OObject
,
Tools
)
{
"
use strict
"
;
/**
* Intilialize a Place.plugin with a list of OObjects
* @param {Object} $uis a list of OObjects such as:
...
...
examples/olives/bower_components/olives/src/Plugins.js
View file @
9df98e41
...
...
@@ -17,6 +17,8 @@ define(["Tools", "DomUtils"],
*/
function
Plugins
(
Tools
,
DomUtils
)
{
"
use strict
"
;
return
function
PluginsConstructor
(
$plugins
)
{
/**
...
...
examples/olives/bower_components/olives/src/SocketIOTransport.js
View file @
9df98e41
...
...
@@ -12,6 +12,8 @@ define(["Observable", "Tools"],
*/
function
SocketIOTransport
(
Observable
,
Tools
)
{
"
use strict
"
;
/**
* Defines the SocketIOTransport
* @private
...
...
@@ -47,7 +49,7 @@ function SocketIOTransport(Observable, Tools) {
*/
this
.
getSocket
=
function
getSocket
()
{
return
_socket
;
}
,
}
;
/**
* Subscribe to a socket event
...
...
@@ -56,7 +58,7 @@ function SocketIOTransport(Observable, Tools) {
*/
this
.
on
=
function
on
(
event
,
func
)
{
return
_socket
.
on
(
event
,
func
);
}
,
}
;
/**
* Subscribe to a socket event but disconnect as soon as it fires.
...
...
@@ -95,15 +97,17 @@ function SocketIOTransport(Observable, Tools) {
* @param {Object} scope the scope in which to execute the callback
*/
this
.
request
=
function
request
(
channel
,
data
,
func
,
scope
)
{
if
(
typeof
channel
==
"
string
"
&&
typeof
data
!=
"
undefined
"
)
{
if
(
typeof
channel
==
"
string
"
&&
typeof
data
!=
"
undefined
"
)
{
var
reqData
=
{
eventId
:
Date
.
now
()
+
Math
.
floor
(
Math
.
random
()
*
1
e6
),
data
:
data
},
boundCallback
=
function
()
{
func
&&
func
.
apply
(
scope
||
null
,
arguments
);
if
(
func
)
{
func
.
apply
(
scope
||
null
,
arguments
);
}
};
this
.
once
(
reqData
.
eventId
,
boundCallback
);
...
...
@@ -125,9 +129,9 @@ function SocketIOTransport(Observable, Tools) {
* @returns
*/
this
.
listen
=
function
listen
(
channel
,
data
,
func
,
scope
)
{
if
(
typeof
channel
==
"
string
"
&&
typeof
data
!=
"
undefined
"
&&
typeof
func
==
"
function
"
)
{
if
(
typeof
channel
==
"
string
"
&&
typeof
data
!=
"
undefined
"
&&
typeof
func
==
"
function
"
)
{
var
reqData
=
{
eventId
:
Date
.
now
()
+
Math
.
floor
(
Math
.
random
()
*
1
e6
),
...
...
@@ -135,7 +139,9 @@ function SocketIOTransport(Observable, Tools) {
keepAlive
:
true
},
boundCallback
=
function
()
{
func
&&
func
.
apply
(
scope
||
null
,
arguments
);
if
(
func
)
{
func
.
apply
(
scope
||
null
,
arguments
);
}
},
that
=
this
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment