-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend js from base. move theme specific js in corresponding folders
- Loading branch information
Showing
16 changed files
with
315 additions
and
396 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import $ from 'jquery'; | ||
import {DictBase} from '../dict.js'; | ||
|
||
export class DictWidget extends DictBase { | ||
|
||
static initialize(context) { | ||
$('table.dictwidget', context).each(function() { | ||
let elem = $(this); | ||
if (window.yafowil_array !== undefined && | ||
window.yafowil_array.inside_template(elem)) { | ||
return; | ||
} | ||
new DictWidget(elem); | ||
}); | ||
} | ||
|
||
create_row(action) { | ||
let key_css = this.row_class(action, 'key'), | ||
val_css = this.row_class(action, 'value'), | ||
row = ''; | ||
row += '<tr>'; | ||
row += '<td class="key">'; | ||
row += '<input type="text" class="' + key_css + '" value="" />'; | ||
row += '</td>'; | ||
row += '<td class="value">'; | ||
row += '<input type="text" class="' + val_css + '" value="" />'; | ||
row += '</td>'; | ||
row += '<td class="actions">'; | ||
row += '<div class="dict_actions">'; | ||
row += '<a class="dict_row_add" href="#">'; | ||
row += '<span class="bi-plus-circle-fill"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_remove" href="#">'; | ||
row += '<span class="bi-dash-circle-fill"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_up" href="#">'; | ||
row += '<span class="bi-arrow-up-circle-fill"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_down" href="#">'; | ||
row += '<span class="bi-arrow-down-circle-fill"> </span>'; | ||
row += '</a>'; | ||
row += '</div>'; | ||
row += '</td>'; | ||
row += '</tr>'; | ||
return row; | ||
} | ||
|
||
on_row_moved(row) { | ||
row.addClass('row-moved'); | ||
setTimeout(function() { | ||
row.removeClass('row-moved'); | ||
}, 1000); | ||
} | ||
|
||
up_handle(evt) { | ||
evt.preventDefault(); | ||
let row = this.get_row(evt.currentTarget); | ||
row.insertBefore(row.prev()); | ||
this.reset_indices(row.parent()); | ||
this.on_row_moved(row); | ||
} | ||
|
||
down_handle(evt) { | ||
evt.preventDefault(); | ||
let row = this.get_row(evt.currentTarget); | ||
row.insertAfter(row.next()); | ||
this.reset_indices(row.parent()); | ||
this.on_row_moved(row); | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// yafowil.widget.array integration | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
function dict_on_array_add(inst, context) { | ||
DictWidget.initialize(context); | ||
} | ||
|
||
export function register_array_subscribers() { | ||
if (window.yafowil_array !== undefined) { | ||
window.yafowil_array.on_array_event('on_add', dict_on_array_add); | ||
} else if (yafowil.array !== undefined) { | ||
$.extend(yafowil.array.hooks.add, { | ||
dictwidget_binder: DictWidget.initialize | ||
}); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import $ from 'jquery'; | ||
import {DictBase} from '../dict.js'; | ||
|
||
export class DictWidget extends DictBase { | ||
|
||
static initialize(context) { | ||
$('table.dictwidget', context).each(function() { | ||
let elem = $(this); | ||
if (window.yafowil_array !== undefined && | ||
window.yafowil_array.inside_template(elem)) { | ||
return; | ||
} | ||
new DictWidget(elem); | ||
}); | ||
} | ||
|
||
create_row(action) { | ||
let key_css = this.row_class(action, 'key'), | ||
val_css = this.row_class(action, 'value'), | ||
row = ''; | ||
row += '<tr>'; | ||
row += '<td class="key">'; | ||
row += '<input type="text" class="' + key_css + '" value="" />'; | ||
row += '</td>'; | ||
row += '<td class="value">'; | ||
row += '<input type="text" class="' + val_css + '" value="" />'; | ||
row += '</td>'; | ||
row += '<td class="actions">'; | ||
row += '<div class="dict_actions">'; | ||
row += '<a class="dict_row_add" href="#">'; | ||
row += '<span class="icon-plus-sign"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_remove" href="#">'; | ||
row += '<span class="icon-minus-sign"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_up" href="#">'; | ||
row += '<span class="icon-circle-arrow-up"> </span>'; | ||
row += '</a>'; | ||
row += '<a class="dict_row_down" href="#">'; | ||
row += '<span class="icon-circle-arrow-down"> </span>'; | ||
row += '</a>'; | ||
row += '</div>'; | ||
row += '</td>'; | ||
row += '</tr>'; | ||
return row; | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////// | ||
// yafowil.widget.array integration | ||
////////////////////////////////////////////////////////////////////////////// | ||
|
||
function dict_on_array_add(inst, context) { | ||
DictWidget.initialize(context); | ||
} | ||
|
||
export function register_array_subscribers() { | ||
if (window.yafowil_array !== undefined) { | ||
window.yafowil_array.on_array_event('on_add', dict_on_array_add); | ||
} else if (yafowil.array !== undefined) { | ||
$.extend(yafowil.array.hooks.add, { | ||
dictwidget_binder: DictWidget.initialize | ||
}); | ||
} | ||
} |
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
Oops, something went wrong.