Commit 6e66b9a2 authored by Jingqin Lynn's avatar Jingqin Lynn

Change Attribute editing method.

parent 29d818b3
...@@ -27,20 +27,13 @@ $(document).ready -> ...@@ -27,20 +27,13 @@ $(document).ready ->
$(element).removeClass 'editable' $(element).removeClass 'editable'
@document.value = $('.card')[0].outerHTML @document.value = $('.card')[0].outerHTML
#editable
$('.attribute').editable (value, settings) ->
$(this).attr 'data-attribute', value
, {
placeholder: ""
data: JSON.stringify {'dark': '暗', 'divine': '神', 'earth': '地', 'fire': '炎', 'light': '光', 'water': '水', 'wind': '风'}
type: 'select'
submit: 'OK'
}
$('.editable').each (_, element) -> $('.editable').each (_, element) ->
if element.classList.contains('attribute') if element.classList.contains('attribute')
# TODO(lynn): Improve Attribute editing. $(element).click (e) ->
attrs = ['dark', 'divine', 'earth', 'fire', 'light', 'water', 'wind']
old_attr = element.dataset['attribute']
new_attr = attrs[(attrs.indexOf(old_attr) + 1) % attrs.length]
element.dataset['attribute'] = new_attr
else if element.classList.contains('level') else if element.classList.contains('level')
$(element).click (e) -> $(element).click (e) ->
delta = 0 delta = 0
......
...@@ -28,25 +28,15 @@ ...@@ -28,25 +28,15 @@
}); });
return this.document.value = $('.card')[0].outerHTML; return this.document.value = $('.card')[0].outerHTML;
}); });
$('.attribute').editable(function(value, settings) {
return $(this).attr('data-attribute', value);
}, {
placeholder: "",
data: JSON.stringify({
'dark': '',
'divine': '',
'earth': '',
'fire': '',
'light': '',
'water': '',
'wind': ''
}),
type: 'select',
submit: 'OK'
});
$('.editable').each(function(_, element) { $('.editable').each(function(_, element) {
if (element.classList.contains('attribute')) { if (element.classList.contains('attribute')) {
return $(element).click(function(e) {
var attrs, new_attr, old_attr;
attrs = ['dark', 'divine', 'earth', 'fire', 'light', 'water', 'wind'];
old_attr = element.dataset['attribute'];
new_attr = attrs[(attrs.indexOf(old_attr) + 1) % attrs.length];
return element.dataset['attribute'] = new_attr;
});
} else if (element.classList.contains('level')) { } else if (element.classList.contains('level')) {
return $(element).click(function(e) { return $(element).click(function(e) {
var delta, new_level, old_level; var delta, new_level, old_level;
......
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