Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Store
Commits
cc8cc2ae
Commit
cc8cc2ae
authored
Dec 14, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search
parent
8dc364d9
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
298 additions
and
338 deletions
+298
-338
assets/javascripts/decks.coffee
assets/javascripts/decks.coffee
+24
-24
assets/javascripts/decks.js
assets/javascripts/decks.js
+28
-29
decks/new/index.html
decks/new/index.html
+246
-285
No files found.
assets/javascripts/decks.coffee
View file @
cc8cc2ae
...
...
@@ -8,7 +8,6 @@ class Card extends Spine.Model
@
configure
'Card'
,
'id'
,
'name'
,
'card_type'
,
'type'
,
'attribute'
,
'level'
,
'atk'
,
'def'
,
'description'
@
extend
Spine
.
Model
.
Local
@
extend
Spine
.
Events
@
hasMany
'card_usages'
,
CardUsage
@
url
:
"http://my-card.in/cards"
@
locale_url
:
"http://my-card.in/cards_
#{
locale
}
"
image_url
:
->
...
...
@@ -50,14 +49,14 @@ class Card extends Spine.Model
cards_id
=
[]
for
lang
in
langs
try
result
.
push
Card
.
find
lang
.
_id
result
.
push
Card
.
find
(
lang
.
_id
)
catch
e
cards_id
.
push
lang
.
_id
if
cards_id
.
length
$
.
getJSON
"
#{
@
url
}
?q=
#{
JSON
.
stringify
({
_id
:
{
$in
:
cards_id
}
})}"
,
(
cards
)
=>
@
load
cards
,
langs
for
card
in
cards
result
.
push
Card
.
find
card
.
_id
result
.
push
Card
.
find
(
card
.
_id
)
callback
(
result
)
else
callback
(
result
)
...
...
@@ -176,7 +175,6 @@ class Deck extends Spine.Model
else
throw
'无效卡组'
card_usages
.
push
{
id
:
"
#{
result
.
cid
}
_
#{
side
}
_
#{
last_id
}
"
,
card_id
:
last_id
,
side
:
side
,
count
:
count
}
if
last_id
alert
card_usages
result
.
card_usages
card_usages
result
...
...
@@ -190,7 +188,7 @@ class Deck extends Spine.Model
"http://my-card.in"
+
@
location_ydk
()
add
:
(
card_usage
)
->
if
!
card_usage
.
card_id
#card
card_usage
=
@
card_usages
().
findByAttribute
(
'card_id'
,
card
.
id
)
||
new
CardUsage
(
card_id
:
card
.
id
,
deck_id
:
deck
.
id
,
main
:
true
,
count
:
0
)
card_usage
=
@
card_usages
().
findByAttribute
(
'card_id'
,
card
.
id
)
||
new
CardUsage
(
card_id
:
card
_usage
.
id
,
deck_id
:
@
id
,
main
:
true
,
count
:
0
)
count
=
0
for
c
in
@
card_usages
().
findAllByAttribute
(
'card_id'
,
card_usage
.
card_id
)
#TODO: alias
count
+=
c
.
count
...
...
@@ -199,7 +197,7 @@ class Deck extends Spine.Model
card_usage
.
save
()
minus
:
(
card_usage
)
->
if
!
card_usage
.
card_id
#card
card_usage
=
@
card_usages
().
findByAttribute
(
'card_id'
,
card
.
id
)
card_usage
=
@
card_usages
().
findByAttribute
(
'card_id'
,
card
_usage
.
id
)
return
if
!
card_usage
card_usage
.
count
--
if
card_usage
.
count
...
...
@@ -308,7 +306,7 @@ class DecksController extends Spine.Controller
else
$
(
'#deck_url_ydk'
).
attr
'href'
,
@
deck
().
url_ydk
()
@
tab_control
:
->
tab_control
:
->
$
(
".bottom_area div"
).
click
->
$
(
this
).
addClass
(
"bottom_button_active"
).
removeClass
(
"bottom_button"
)
$
(
this
).
siblings
().
addClass
(
"bottom_button"
).
removeClass
(
"bottom_button_active"
)
...
...
@@ -322,16 +320,15 @@ class DecksController extends Spine.Controller
{
btn
:
false
}})
;
show
:
(
e
)
->
card
=
$
(
e
.
target
).
tmplItem
().
data
.
card
()
@
show_card
(
card
)
show_card
:
(
card
)
->
card
=
$
(
e
.
target
).
tmplItem
().
data
card
=
card
.
card
()
if
card
.
card_id
$
(
'#card'
).
removeClass
(
Card
.
card_types
.
join
(
' '
))
active_page_index
=
$
(
'.bottom_area div'
).
index
$
(
".bottom_button_active"
)
$
(
'#card'
).
html
$
(
"#card_template"
).
tmpl
(
card
)
$
(
'#card'
).
addClass
(
card
.
card_type
.
join
(
' '
))
$
(
'.card_frame .frame_element'
).
eq
(
active_page_index
).
addClass
(
'card_frame_focus'
)
$
(
'.bottom_area div'
).
eq
(
active_page_index
).
addClass
(
'bottom_button_active'
).
removeClass
(
"bottom_button"
)
DecksController
.
tab_control
()
@
tab_control
()
add
:
(
e
)
->
@
deck
().
add
$
(
e
.
target
).
tmplItem
().
data
minus
:
(
e
)
->
...
...
@@ -340,22 +337,25 @@ class DecksController extends Spine.Controller
class
CardsController
extends
Spine
.
Controller
events
:
'mouseover .
card_search_result
'
:
'show'
,
'click .
card_search_result
'
:
'add'
,
'contextmenu .
card_search_result
'
:
'minus'
'mouseover .
search_card
'
:
'show'
,
'click .
search_card
'
:
'add'
,
'contextmenu .
search_card
'
:
'minus'
add
:
(
e
)
->
decks
.
deck
().
add
(
$
(
this
).
tmplItem
().
data
)
decks
.
deck
().
add
(
$
(
e
.
target
).
tmplItem
().
data
)
minus
:
(
e
)
->
decks
.
deck
().
minus
(
$
(
this
).
tmplItem
().
data
)
e
.
preventDefault
()
decks
.
deck
().
minus
(
$
(
e
.
target
).
tmplItem
().
data
)
show
:
(
e
)
->
decks
.
show_card
(
$
(
this
).
tmplItem
().
data
)
decks
.
show
(
e
)
template
:
->
$
(
'#search_cards_'
+
if
$
(
'.operate_area'
).
hasClass
(
'text'
)
then
'text'
else
'graphic'
+
'_template'
)
search
:
(
name
)
->
Card
.
fetch_by_name
name
,
(
cards
)
=>
@
html
$
(
'#cards_search_result_template'
).
tmpl
cards
@
html
@
template
(
).
tmpl
cards
decks
=
new
DecksController
(
el
:
$
(
"#deck"
))
cards
=
new
CardsController
(
el
:
$
(
"#
cards_search
"
))
cards
=
new
CardsController
(
el
:
$
(
"#
search_cards
"
))
$
(
document
).
ready
->
decks
.
load_from_url
()
...
...
@@ -400,18 +400,18 @@ $(document).ready ->
$
(
'#deck_load'
).
change
->
decks
.
upload
(
@
files
)
window
.
addEventListener
'popstate'
,
(
ev
)
->
$
(
window
).
bind
'popstate'
,
(
ev
)
->
if
ev
.
state
deck
.
refresh
ev
.
state
,
false
$
(
'.main_div'
).
bind
'dragover'
,
(
ev
)
->
$
(
"#drop_upload_dialog"
).
dialog
(
'open'
)
false
ev
.
preventDefault
();
#$("#drop_upload_dialog").dialog('open')
$
(
"#drop_upload_dialog"
).
bind
'drop'
,
(
ev
)
->
$
(
'.main_div'
).
bind
'drop'
,
(
ev
)
->
ev
.
preventDefault
();
$
(
"#drop_upload_dialog"
).
dialog
(
'close'
)
decks
.
upload
event
.
dataTransfer
.
files
false
$
(
".rename_ope"
).
click
->
$
(
".text,.graphic"
).
toggleClass
(
"graphic text"
)
...
...
assets/javascripts/decks.js
View file @
cc8cc2ae
...
...
@@ -32,8 +32,6 @@
Card
.
extend
(
Spine
.
Events
);
Card
.
hasMany
(
'
card_usages
'
,
CardUsage
);
Card
.
url
=
"
http://my-card.in/cards
"
;
Card
.
locale_url
=
"
http://my-card.in/cards_
"
+
locale
;
...
...
@@ -415,7 +413,6 @@
count
:
count
});
}
alert
(
card_usages
);
result
.
card_usages
(
card_usages
);
return
result
;
};
...
...
@@ -440,8 +437,8 @@
var
c
,
count
,
_i
,
_len
,
_ref
;
if
(
!
card_usage
.
card_id
)
{
card_usage
=
this
.
card_usages
().
findByAttribute
(
'
card_id
'
,
card
.
id
)
||
new
CardUsage
({
card_id
:
card
.
id
,
deck_id
:
deck
.
id
,
card_id
:
card
_usage
.
id
,
deck_id
:
this
.
id
,
main
:
true
,
count
:
0
});
...
...
@@ -460,7 +457,7 @@
Deck
.
prototype
.
minus
=
function
(
card_usage
)
{
if
(
!
card_usage
.
card_id
)
{
card_usage
=
this
.
card_usages
().
findByAttribute
(
'
card_id
'
,
card
.
id
);
card_usage
=
this
.
card_usages
().
findByAttribute
(
'
card_id
'
,
card
_usage
.
id
);
}
if
(
!
card_usage
)
{
return
;
...
...
@@ -689,7 +686,7 @@
}
};
DecksController
.
tab_control
=
function
()
{
DecksController
.
prototype
.
tab_control
=
function
()
{
$
(
"
.bottom_area div
"
).
click
(
function
()
{
var
$dangqian
;
$
(
this
).
addClass
(
"
bottom_button_active
"
).
removeClass
(
"
bottom_button
"
);
...
...
@@ -707,20 +704,18 @@
};
DecksController
.
prototype
.
show
=
function
(
e
)
{
var
card
;
card
=
$
(
e
.
target
).
tmplItem
().
data
.
card
();
return
this
.
show_card
(
card
);
};
DecksController
.
prototype
.
show_card
=
function
(
card
)
{
var
active_page_index
;
var
active_page_index
,
card
;
card
=
$
(
e
.
target
).
tmplItem
().
data
;
if
(
card
.
card_id
)
{
card
=
card
.
card
();
}
$
(
'
#card
'
).
removeClass
(
Card
.
card_types
.
join
(
'
'
));
active_page_index
=
$
(
'
.bottom_area div
'
).
index
(
$
(
"
.bottom_button_active
"
));
$
(
'
#card
'
).
html
(
$
(
"
#card_template
"
).
tmpl
(
card
));
$
(
'
#card
'
).
addClass
(
card
.
card_type
.
join
(
'
'
));
$
(
'
.card_frame .frame_element
'
).
eq
(
active_page_index
).
addClass
(
'
card_frame_focus
'
);
$
(
'
.bottom_area div
'
).
eq
(
active_page_index
).
addClass
(
'
bottom_button_active
'
).
removeClass
(
"
bottom_button
"
);
return
DecksController
.
tab_control
();
return
this
.
tab_control
();
};
DecksController
.
prototype
.
add
=
function
(
e
)
{
...
...
@@ -745,27 +740,32 @@
}
CardsController
.
prototype
.
events
=
{
'
mouseover .
card_search_result
'
:
'
show
'
,
'
click .
card_search_result
'
:
'
add
'
,
'
contextmenu .
card_search_result
'
:
'
minus
'
'
mouseover .
search_card
'
:
'
show
'
,
'
click .
search_card
'
:
'
add
'
,
'
contextmenu .
search_card
'
:
'
minus
'
};
CardsController
.
prototype
.
add
=
function
(
e
)
{
return
decks
.
deck
().
add
(
$
(
this
).
tmplItem
().
data
);
return
decks
.
deck
().
add
(
$
(
e
.
target
).
tmplItem
().
data
);
};
CardsController
.
prototype
.
minus
=
function
(
e
)
{
return
decks
.
deck
().
minus
(
$
(
this
).
tmplItem
().
data
);
e
.
preventDefault
();
return
decks
.
deck
().
minus
(
$
(
e
.
target
).
tmplItem
().
data
);
};
CardsController
.
prototype
.
show
=
function
(
e
)
{
return
decks
.
show_card
(
$
(
this
).
tmplItem
().
data
);
return
decks
.
show
(
e
);
};
CardsController
.
prototype
.
template
=
function
()
{
return
$
(
'
#search_cards_
'
+
(
$
(
'
.operate_area
'
).
hasClass
(
'
text
'
)
?
'
text
'
:
'
graphic
'
+
'
_template
'
));
};
CardsController
.
prototype
.
search
=
function
(
name
)
{
var
_this
=
this
;
return
Card
.
fetch_by_name
(
name
,
function
(
cards
)
{
return
_this
.
html
(
$
(
'
#cards_search_result_template
'
).
tmpl
(
cards
));
return
_this
.
html
(
_this
.
template
(
).
tmpl
(
cards
));
});
};
...
...
@@ -778,7 +778,7 @@
});
cards
=
new
CardsController
({
el
:
$
(
"
#
cards_search
"
)
el
:
$
(
"
#
search_cards
"
)
});
$
(
document
).
ready
(
function
()
{
...
...
@@ -825,19 +825,18 @@
$
(
'
#deck_load
'
).
change
(
function
()
{
return
decks
.
upload
(
this
.
files
);
});
window
.
addEventListener
(
'
popstate
'
,
function
(
ev
)
{
$
(
window
).
bind
(
'
popstate
'
,
function
(
ev
)
{
if
(
ev
.
state
)
{
return
deck
.
refresh
(
ev
.
state
,
false
);
}
});
$
(
'
.main_div
'
).
bind
(
'
dragover
'
,
function
(
ev
)
{
$
(
"
#drop_upload_dialog
"
).
dialog
(
'
open
'
);
return
false
;
return
ev
.
preventDefault
();
});
$
(
"
#drop_upload_dialog
"
).
bind
(
'
drop
'
,
function
(
ev
)
{
$
(
'
.main_div
'
).
bind
(
'
drop
'
,
function
(
ev
)
{
ev
.
preventDefault
();
$
(
"
#drop_upload_dialog
"
).
dialog
(
'
close
'
);
decks
.
upload
(
event
.
dataTransfer
.
files
);
return
false
;
return
decks
.
upload
(
event
.
dataTransfer
.
files
);
});
$
(
"
.rename_ope
"
).
click
(
function
()
{
$
(
"
.text,.graphic
"
).
toggleClass
(
"
graphic text
"
);
...
...
decks/new/index.html
View file @
cc8cc2ae
This diff is collapsed.
Click to expand it.
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