# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmulti mutate om/dispatch) | |
(defmethod mutate 'element/drag | |
[{:keys [state]} _ params] | |
{:value {:keys [:elements/dragged]} | |
:action (fn [] | |
(if-not (empty? params) | |
(swap! state assoc :elements/dragged params) | |
(swap! state assoc :elements/dragged nil)))}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defui App | |
static om/IQuery | |
(query [this] | |
[{:app/lists (om/get-query ElementList)} | |
:elements/dragged]) | |
Object | |
(render [this] | |
(let [{:keys [app/lists elements/dragged]} (om/props this)] | |
(dom/div nil | |
(dom/h1 nil "Lists with draggable behavior !") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defui ElementList | |
static om/Ident | |
(ident [this {:keys [id]}] | |
[:list/by-id id]) | |
static om/IQuery | |
(query [this] | |
[:id {:elements (om/get-query Element)}]) | |
Object | |
(render [this] | |
(let [{:keys [id elements]} (om/props this)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defui Element | |
static om/Ident | |
(ident [this {:keys [id]}] | |
[:element/by-id id]) | |
static om/IQuery | |
(query [this] | |
[:id :text]) | |
Object | |
(render [this] | |
(let [{:keys [id text]} (om/props this)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; REPL | |
(om/tree->db App init-data true) | |
{:app/lists [[:list/by-id 1] [:list/by-id 2] [:list/by-id 3]], | |
:element/by-id {1 {:id 1, :text "This is a draggable element 1"}, | |
2 {:id 2, :text "This is a draggable element 2"}, | |
3 {:id 3, :text "This is a draggable element 3"}, | |
4 {:id 4, :text "This is a draggable element 4"}, | |
5 {:id 5, :text "This is a draggable element 5"}, | |
6 {:id 6, :text "This is a draggable element 6"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; ============================================================================= | |
;; Initial Data | |
(def init-data {:app/lists [{:id 1 | |
:elements [{:id 1 | |
:text "This is a draggable element 1"} | |
{:id 2 | |
:text "This is a draggable element 2"} | |
{:id 3 | |
:text "This is a draggable element 3"} | |
{:id 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def init-data {:app/lists [{:id 1 | |
:elements [{:id 1 | |
:text "This is a draggable element 1"} | |
{:id 2 | |
:text "This is a draggable element 2"} | |
{:id 3 | |
:text "This is a draggable element 3"} | |
{:id 4 | |
:text "This is a draggable element 4"} | |
{:id 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
angular.module('dailymotionApp') | |
.filter('col', function(){ | |
return function(input, numColumns){ | |
if(input !== undefined) { | |
var filtered = []; | |
for(var x = 0; x < input.length; x++){ | |
if(x % numColumns === 0){ | |
filtered.push(filtered.length); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
while true; | |
do | |
clear | |
git log \ | |
--graph \ | |
--all \ | |
--color \ | |
--date=short \ | |
-10 \ |