From f5a8ee0b7a363b86a0528a659e261c8895d35a01 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Fri, 28 Nov 2014 14:08:51 +0900 Subject: [PATCH 1/1] clean --- .../addons/circle_speech_balloons/init.js.coffee | 15 +++--- .../addons/plain_speech_balloons/init.js.coffee | 15 +++--- .../addons/square_speech_balloons/init.js.coffee | 15 +++--- .../javascripts/controllers/artists.js.coffee | 9 ++-- .../javascripts/controllers/authors.js.coffee | 9 ++-- .../javascripts/controllers/balloons.js.coffee | 7 ++- .../controllers/comic_stories.js.coffee | 7 ++- .../javascripts/controllers/comics.js.coffee | 9 ++-- .../javascripts/controllers/folders.js.coffee | 19 +++---- .../controllers/ground_colors.js.coffee | 9 ++-- .../controllers/ground_pictures.js.coffee | 9 ++-- .../controllers/license_groups.js.coffee | 9 ++-- .../javascripts/controllers/licenses.js.coffee | 5 +- .../controllers/original_pictures.js.coffee | 7 ++- .../controllers/panel_pictures.js.coffee | 9 ++-- .../javascripts/controllers/panels.js.coffee | 14 +++-- .../javascripts/controllers/pictures.js.coffee | 7 ++- .../controllers/resource_pictures.js.coffee | 7 ++- .../controllers/scroll_panels.js.coffee | 7 ++- .../javascripts/controllers/scrolls.js.coffee | 25 ++++----- .../javascripts/controllers/sheet_panels.js.coffee | 7 ++- .../javascripts/controllers/sheets.js.coffee | 9 ++-- .../controllers/speech_balloon_templates.js.coffee | 9 ++-- .../controllers/speech_balloons.js.coffee | 9 ++-- .../javascripts/controllers/speeches.js.coffee | 7 ++- .../javascripts/controllers/stories.js.coffee | 9 ++-- .../javascripts/controllers/story_sheets.js.coffee | 7 ++- .../controllers/system_pictures.js.coffee | 7 ++- .../controllers/writing_formats.js.coffee | 9 ++-- app/assets/javascripts/locmare/bucket.js.coffee | 23 ++++----- .../locmare/filer/body/file_body.js.coffee | 14 +++-- .../symbol/default/face/picture.js.coffee | 9 ++-- app/assets/javascripts/locmare/form.js.coffee | 51 +++++++++---------- .../locmare/form/extend_field.js.coffee | 10 ++-- .../javascripts/locmare/form/field.js.coffee | 10 ++-- .../locmare/form/field/helper/tail_angle.js.coffee | 5 +- .../locmare/form/field/tag/select.js.coffee | 9 ++-- .../locmare/list_group/lib/pager.js.coffee | 5 +- .../locmare/list_group/list/base.js.coffee | 8 ++- .../locmare/profiler/association.js.coffee | 13 +++-- .../profiler/association/belongs_to.js.coffee | 11 ++-- .../profiler/association/has_many.js.coffee | 15 +++--- .../locmare/profiler/association/has_one.js.coffee | 15 +++--- .../javascripts/locmare/profiler/column.js.coffee | 12 ++--- .../locmare/profiler/column/base.js.coffee | 19 +++---- app/assets/javascripts/pettanr.js.coffee | 59 ++++++---------------- app/assets/javascripts/tags.js.coffee | 5 +- lib/locmare/list_group/list/base.rb | 5 +- 48 files changed, 244 insertions(+), 340 deletions(-) diff --git a/app/assets/javascripts/addons/circle_speech_balloons/init.js.coffee b/app/assets/javascripts/addons/circle_speech_balloons/init.js.coffee index 9ff71b8b..38777a94 100644 --- a/app/assets/javascripts/addons/circle_speech_balloons/init.js.coffee +++ b/app/assets/javascripts/addons/circle_speech_balloons/init.js.coffee @@ -84,10 +84,9 @@ class Pettanr.CircleSpeechBalloon.Speech extends Backbone.Model class Pettanr.CircleSpeechBalloon.SpeechBalloonModule supply_default: () -> super() - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.speech_balloon_template_module_name = sbt.get('module_name') + sbt.fetch({cache: true}).done => + @speech_balloon_template_module_name = sbt.get('module_name') speech_balloon_extend: () -> @new_speech_balloon() if not @sbex @@ -129,10 +128,9 @@ class Pettanr.CircleSpeechBalloon.BalloonModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() select_system_picture: () -> tr = @get('r') % 360 @@ -175,10 +173,9 @@ class Pettanr.CircleSpeechBalloon.SpeechModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() arrayed_quotes: () -> q = if Pettanr.is_blank(@get('quotes')) diff --git a/app/assets/javascripts/addons/plain_speech_balloons/init.js.coffee b/app/assets/javascripts/addons/plain_speech_balloons/init.js.coffee index b923e02f..4bcf8a95 100644 --- a/app/assets/javascripts/addons/plain_speech_balloons/init.js.coffee +++ b/app/assets/javascripts/addons/plain_speech_balloons/init.js.coffee @@ -84,10 +84,9 @@ class Pettanr.PlainSpeechBalloon.Speech extends Backbone.Model class Pettanr.PlainSpeechBalloon.SpeechBalloonModule supply_default: () -> super() - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.speech_balloon_template_module_name = sbt.get('module_name') + sbt.fetch({cache: true}).done => + @speech_balloon_template_module_name = sbt.get('module_name') speech_balloon_extend: () -> @new_speech_balloon() if not @sbex @@ -129,10 +128,9 @@ class Pettanr.PlainSpeechBalloon.BalloonModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() select_system_picture: () -> s = @parsed_settings()['all']['balloon'] @@ -169,10 +167,9 @@ class Pettanr.PlainSpeechBalloon.SpeechModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() arrayed_quotes: () -> q = if Pettanr.is_blank(@get('quotes')) diff --git a/app/assets/javascripts/addons/square_speech_balloons/init.js.coffee b/app/assets/javascripts/addons/square_speech_balloons/init.js.coffee index b6d46ad8..2fd53659 100644 --- a/app/assets/javascripts/addons/square_speech_balloons/init.js.coffee +++ b/app/assets/javascripts/addons/square_speech_balloons/init.js.coffee @@ -84,10 +84,9 @@ class Pettanr.SquareSpeechBalloon.Speech extends Backbone.Model class Pettanr.SquareSpeechBalloon.SpeechBalloonModule supply_default: () -> super() - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.speech_balloon_template_module_name = sbt.get('module_name') + sbt.fetch({cache: true}).done => + @speech_balloon_template_module_name = sbt.get('module_name') speech_balloon_extend: () -> @new_speech_balloon() if not @sbex @@ -129,10 +128,9 @@ class Pettanr.SquareSpeechBalloon.BalloonModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() select_system_picture: () -> s = @parsed_settings()['all']['balloon'] @@ -169,10 +167,9 @@ class Pettanr.SquareSpeechBalloon.SpeechModule parsed_settings: () -> return @parsed if @parsed - _this = this sbt = @speech_balloon_template() - sbt.fetch({cache: true}).done -> - _this.parsed = sbt.parsed_settings() + sbt.fetch({cache: true}).done => + @parsed = sbt.parsed_settings() arrayed_quotes: () -> q = if Pettanr.is_blank(@get('quotes')) diff --git a/app/assets/javascripts/controllers/artists.js.coffee b/app/assets/javascripts/controllers/artists.js.coffee index 769a3d63..bee94dfe 100644 --- a/app/assets/javascripts/controllers/artists.js.coffee +++ b/app/assets/javascripts/controllers/artists.js.coffee @@ -5,13 +5,12 @@ class Pettanr.ArtistsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('title')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('title')) view = new Pettanr.Views.Artist.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/authors.js.coffee b/app/assets/javascripts/controllers/authors.js.coffee index 94cf3179..240772c5 100644 --- a/app/assets/javascripts/controllers/authors.js.coffee +++ b/app/assets/javascripts/controllers/authors.js.coffee @@ -5,13 +5,12 @@ class Pettanr.AuthorsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('name')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('name')) view = new Pettanr.Views.Author.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/balloons.js.coffee b/app/assets/javascripts/controllers/balloons.js.coffee index 0731262e..d09e6d85 100644 --- a/app/assets/javascripts/controllers/balloons.js.coffee +++ b/app/assets/javascripts/controllers/balloons.js.coffee @@ -14,12 +14,11 @@ class Pettanr.BalloonsController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.Balloon.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/comic_stories.js.coffee b/app/assets/javascripts/controllers/comic_stories.js.coffee index f1686b93..b0e760a4 100644 --- a/app/assets/javascripts/controllers/comic_stories.js.coffee +++ b/app/assets/javascripts/controllers/comic_stories.js.coffee @@ -18,12 +18,11 @@ class Pettanr.ComicStoriesController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.ComicStory.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/comics.js.coffee b/app/assets/javascripts/controllers/comics.js.coffee index 4db24e99..1cbca39e 100644 --- a/app/assets/javascripts/controllers/comics.js.coffee +++ b/app/assets/javascripts/controllers/comics.js.coffee @@ -13,13 +13,12 @@ class Pettanr.ComicsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('title')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('title')) view = new Pettanr.Views.Comic.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/folders.js.coffee b/app/assets/javascripts/controllers/folders.js.coffee index ddafdb2f..5fa72b53 100644 --- a/app/assets/javascripts/controllers/folders.js.coffee +++ b/app/assets/javascripts/controllers/folders.js.coffee @@ -8,9 +8,8 @@ class Pettanr.FoldersController extends Pettanr.AppController @redraw_title(@params) @set_model() @item = new Pettanr.Folder.Root() - _this = this - @item.fetch({cache: true}).done -> - _this.children_html() + @item.fetch({cache: true}).done => + @children_html() show_html_format: (format) -> @@ -27,24 +26,22 @@ class Pettanr.FoldersController extends Pettanr.AppController $("#pettanr").html(f.render().el) show: () -> - console.log(@params) if @params['format'] == 'prof' @set_show() @item = new Pettanr.FolderWatch({id: @params['id']}) # replace refference item @show_prof() else @item = new Pettanr.FolderWatch({id: @params['id']}) - _this = this - @item.fetch({cache: true}).done () -> - if _this.item.is_remote() - c = _this.item.get('controller_name') - a = if Pettanr.is_blank(_this.item.get('action_name')) + @item.fetch({cache: true}).done () => + if @item.is_remote() + c = @item.get('controller_name') + a = if Pettanr.is_blank(@item.get('action_name')) 'index' else - _this.item.get('action_name') + @item.get('action_name') window.router['c_i'](c, a, '') # call action event in router for redirect else - _this.children_html() + @children_html() count: () -> diff --git a/app/assets/javascripts/controllers/ground_colors.js.coffee b/app/assets/javascripts/controllers/ground_colors.js.coffee index daaf9436..a06b2982 100644 --- a/app/assets/javascripts/controllers/ground_colors.js.coffee +++ b/app/assets/javascripts/controllers/ground_colors.js.coffee @@ -13,13 +13,12 @@ class Pettanr.GroundColorsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.GroundColor.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) #view.render() diff --git a/app/assets/javascripts/controllers/ground_pictures.js.coffee b/app/assets/javascripts/controllers/ground_pictures.js.coffee index 53e311b0..41e10aa9 100644 --- a/app/assets/javascripts/controllers/ground_pictures.js.coffee +++ b/app/assets/javascripts/controllers/ground_pictures.js.coffee @@ -14,13 +14,12 @@ class Pettanr.GroundPicturesController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.GroundPicture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) #view.render() diff --git a/app/assets/javascripts/controllers/license_groups.js.coffee b/app/assets/javascripts/controllers/license_groups.js.coffee index 2794e6f2..ec4cfc82 100644 --- a/app/assets/javascripts/controllers/license_groups.js.coffee +++ b/app/assets/javascripts/controllers/license_groups.js.coffee @@ -5,13 +5,12 @@ class Pettanr.LicenseGroupsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.LicenseGroup.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/licenses.js.coffee b/app/assets/javascripts/controllers/licenses.js.coffee index 032dccab..807471ef 100644 --- a/app/assets/javascripts/controllers/licenses.js.coffee +++ b/app/assets/javascripts/controllers/licenses.js.coffee @@ -13,9 +13,8 @@ class Pettanr.LicensesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.License.Show({ el: "#pettanr", item: @item, diff --git a/app/assets/javascripts/controllers/original_pictures.js.coffee b/app/assets/javascripts/controllers/original_pictures.js.coffee index 5648e68f..d014a073 100644 --- a/app/assets/javascripts/controllers/original_pictures.js.coffee +++ b/app/assets/javascripts/controllers/original_pictures.js.coffee @@ -9,13 +9,12 @@ class Pettanr.OriginalPicturesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this @redraw_title(@params) - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.OriginalPicture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/panel_pictures.js.coffee b/app/assets/javascripts/controllers/panel_pictures.js.coffee index d20aec96..832aee12 100644 --- a/app/assets/javascripts/controllers/panel_pictures.js.coffee +++ b/app/assets/javascripts/controllers/panel_pictures.js.coffee @@ -13,13 +13,12 @@ class Pettanr.PanelPicturesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.PanelPicture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) #view.render() diff --git a/app/assets/javascripts/controllers/panels.js.coffee b/app/assets/javascripts/controllers/panels.js.coffee index 9bb5d2c1..6fc280bd 100644 --- a/app/assets/javascripts/controllers/panels.js.coffee +++ b/app/assets/javascripts/controllers/panels.js.coffee @@ -21,14 +21,13 @@ class Pettanr.PanelsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this @item = new Pettanr.Panel({id: @item.get('id')}, {with_elements: true}) # retake panel for 'with_elements' mode - @item.fetch({cache: false}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: false}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.Panel.Show({ el: "#pettanr", - panel: _this.item, - operators: _this.operators, + panel: @item, + operators: @operators, spot: null }) view.render() @@ -52,11 +51,10 @@ class Pettanr.PanelsController extends Pettanr.AppController edit: () -> @redraw_title(@params) - _this = this @set_model() @item = new Pettanr.Panel({id: @params['id']}, {with_elements: true}) - @item.fetch({cache: false}).done -> - editor = new Editor.PanelEditor({root_item: _this.item, operators: _this.operators}) + @item.fetch({cache: false}).done => + editor = new Editor.PanelEditor({root_item: @item, operators: @operators}) $("#pettanr").html(editor.render().el) create: () -> diff --git a/app/assets/javascripts/controllers/pictures.js.coffee b/app/assets/javascripts/controllers/pictures.js.coffee index 6aade7f9..9073a6ae 100644 --- a/app/assets/javascripts/controllers/pictures.js.coffee +++ b/app/assets/javascripts/controllers/pictures.js.coffee @@ -10,12 +10,11 @@ class Pettanr.PicturesController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.Picture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/resource_pictures.js.coffee b/app/assets/javascripts/controllers/resource_pictures.js.coffee index f8c8dd01..2df82568 100644 --- a/app/assets/javascripts/controllers/resource_pictures.js.coffee +++ b/app/assets/javascripts/controllers/resource_pictures.js.coffee @@ -18,12 +18,11 @@ class Pettanr.ResourcePicturesController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.ResourcePicture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/scroll_panels.js.coffee b/app/assets/javascripts/controllers/scroll_panels.js.coffee index cac28e60..c0fa60d4 100644 --- a/app/assets/javascripts/controllers/scroll_panels.js.coffee +++ b/app/assets/javascripts/controllers/scroll_panels.js.coffee @@ -18,12 +18,11 @@ class Pettanr.ScrollPanelsController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.ScrollPanel.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/scrolls.js.coffee b/app/assets/javascripts/controllers/scrolls.js.coffee index 0351b22c..5b6fcbd5 100644 --- a/app/assets/javascripts/controllers/scrolls.js.coffee +++ b/app/assets/javascripts/controllers/scrolls.js.coffee @@ -13,13 +13,12 @@ class Pettanr.ScrollsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('title')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('title')) view = new Pettanr.Views.Scroll.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() @@ -33,22 +32,18 @@ class Pettanr.ScrollsController extends Pettanr.AppController play: () -> @set_play() - _list = @list - _this = this - @item.fetch({cache: true}).done -> - _list.open(() -> - _this.redraw_title(_this.params, _this.item.get('title')) + @item.fetch({cache: true}).done => + @list.open(() => + @redraw_title(@params, @item.get('title')) view = new Pettanr.Views.Scroll.Play({ el: "#pettanr", - item: _this.item, - list: _this.list, - operators: _this.operators + item: @item, + list: @list, + operators: @operators }) view.render() ) - count: () -> - new: () -> @redraw_title(@params) @form_new() diff --git a/app/assets/javascripts/controllers/sheet_panels.js.coffee b/app/assets/javascripts/controllers/sheet_panels.js.coffee index 3c0eb383..3a1dd2e2 100644 --- a/app/assets/javascripts/controllers/sheet_panels.js.coffee +++ b/app/assets/javascripts/controllers/sheet_panels.js.coffee @@ -18,12 +18,11 @@ class Pettanr.SheetPanelsController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.SheetPanel.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/sheets.js.coffee b/app/assets/javascripts/controllers/sheets.js.coffee index 530f6f83..0c7da59e 100644 --- a/app/assets/javascripts/controllers/sheets.js.coffee +++ b/app/assets/javascripts/controllers/sheets.js.coffee @@ -17,13 +17,12 @@ class Pettanr.SheetsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.Sheet.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/speech_balloon_templates.js.coffee b/app/assets/javascripts/controllers/speech_balloon_templates.js.coffee index 9fadbe1d..1025cf19 100644 --- a/app/assets/javascripts/controllers/speech_balloon_templates.js.coffee +++ b/app/assets/javascripts/controllers/speech_balloon_templates.js.coffee @@ -13,13 +13,12 @@ class Pettanr.SpeechBalloonTemplatesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.SpeechBalloonTemplate.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/speech_balloons.js.coffee b/app/assets/javascripts/controllers/speech_balloons.js.coffee index 40b34e77..eacb165b 100644 --- a/app/assets/javascripts/controllers/speech_balloons.js.coffee +++ b/app/assets/javascripts/controllers/speech_balloons.js.coffee @@ -17,13 +17,12 @@ class Pettanr.SpeechBalloonsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.SpeechBalloon.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) #view.render() diff --git a/app/assets/javascripts/controllers/speeches.js.coffee b/app/assets/javascripts/controllers/speeches.js.coffee index 7895a58a..68aa806d 100644 --- a/app/assets/javascripts/controllers/speeches.js.coffee +++ b/app/assets/javascripts/controllers/speeches.js.coffee @@ -14,12 +14,11 @@ class Pettanr.SpeechesController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.Speech.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/stories.js.coffee b/app/assets/javascripts/controllers/stories.js.coffee index bbaf39c4..13fb5fcf 100644 --- a/app/assets/javascripts/controllers/stories.js.coffee +++ b/app/assets/javascripts/controllers/stories.js.coffee @@ -17,13 +17,12 @@ class Pettanr.StoriesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('title')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('title')) view = new Pettanr.Views.Story.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/story_sheets.js.coffee b/app/assets/javascripts/controllers/story_sheets.js.coffee index c8564812..a6d328b5 100644 --- a/app/assets/javascripts/controllers/story_sheets.js.coffee +++ b/app/assets/javascripts/controllers/story_sheets.js.coffee @@ -18,12 +18,11 @@ class Pettanr.StorySheetsController extends Pettanr.AppController show_html: () -> @redraw_title(@params) - _this = this - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.StorySheet.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/system_pictures.js.coffee b/app/assets/javascripts/controllers/system_pictures.js.coffee index a323e490..b22af431 100644 --- a/app/assets/javascripts/controllers/system_pictures.js.coffee +++ b/app/assets/javascripts/controllers/system_pictures.js.coffee @@ -5,13 +5,12 @@ class Pettanr.SystemPicturesController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this @redraw_title(@params) - @item.fetch({cache: true}).done -> + @item.fetch({cache: true}).done => view = new Pettanr.Views.SystemPicture.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/controllers/writing_formats.js.coffee b/app/assets/javascripts/controllers/writing_formats.js.coffee index f33bc553..8ae4b8c5 100644 --- a/app/assets/javascripts/controllers/writing_formats.js.coffee +++ b/app/assets/javascripts/controllers/writing_formats.js.coffee @@ -9,13 +9,12 @@ class Pettanr.WritingFormatsController extends Pettanr.AppController @filer_list() show_html: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.redraw_title(_this.params, _this.item.get('caption')) + @item.fetch({cache: true}).done => + @redraw_title(@params, @item.get('caption')) view = new Pettanr.Views.WritingFormat.Show({ el: "#pettanr", - item: _this.item, - operators: _this.operators + item: @item, + operators: @operators }) view.render() diff --git a/app/assets/javascripts/locmare/bucket.js.coffee b/app/assets/javascripts/locmare/bucket.js.coffee index 442c71c4..64f939cf 100644 --- a/app/assets/javascripts/locmare/bucket.js.coffee +++ b/app/assets/javascripts/locmare/bucket.js.coffee @@ -56,40 +56,37 @@ class Locmare.Bucket extends Backbone.View @members_fold_extend_settings @item, params[@item.item_name()], @manifest members_fold_extend_settings: (fold_item, attr, man) -> - _this = this - _.each man.members, (member_manifest, member_name) -> + _.each man.members, (member_manifest, member_name) => member_item = fold_item[member_name]() member_item.my_class().fold_extend_settings attr[member_name + '_attributes'] - _this.members_fold_extend_settings member_item, attr[member_name + '_attributes'], member_manifest + @members_fold_extend_settings member_item, attr[member_name + '_attributes'], member_manifest push_form: (key, form_name, item) -> init_forms: (key, man, item) -> - _this = this - _.each man.members, (member_manifest, member_name) -> + _.each man.members, (member_manifest, member_name) => form_name = member_name # write exchange function if you want member_item = item.get(form_name) new_key = key + '.' + form_name - _this.forms[new_key] = new Locmare.Form({ + @forms[new_key] = new Locmare.Form({ form_name: new_key, item: member_item, - mounted: _this.mounted, + mounted: @mounted, submit: false, - operators: _this.operators + operators: @operators }) - _this.init_forms(new_key, member_manifest, member_item) + @init_forms(new_key, member_manifest, member_item) init_fields: () -> - _this = this _.each @manifest.form_field_names, (form_field_name) -> r = if Pettanr.is_blank(form_field_name.form_name) '' else '.' + form_field_name.form_name - key = _this.item.item_name() + r - form = _this.forms[key] + key = @item.item_name() + r + form = @forms[key] field = form.fields[form_field_name.field_name] - _this.form_fields.push(field) + @form_fields.push(field) image_dir: () -> '/images/' diff --git a/app/assets/javascripts/locmare/filer/body/file_body.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body.js.coffee index bb143f22..191fa484 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body.js.coffee @@ -4,17 +4,15 @@ class Locmare.FilerModule.BodyModule.FileBody extends Backbone.View initialize: (options) -> @body = options.body @file_items = [] - _this = this - @file_items = _.map @filer().items, (item) -> - fi = _this.file_item_class() - new fi({'file_body': _this, 'item': item}) - _this.render() + @file_items = _.map @filer().items, (item) => + fi = @file_item_class() + new fi({'file_body': this, 'item': item}) + @render() render: () -> - _this = this this.$el.html('') - _.each @file_items, (file_item) -> - _this.$el.append(file_item.render().el) + _.each @file_items, (file_item) => + this.$el.append(file_item.render().el) this file_item_class: () -> diff --git a/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default/face/picture.js.coffee b/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default/face/picture.js.coffee index 10802e18..34642f93 100644 --- a/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default/face/picture.js.coffee +++ b/app/assets/javascripts/locmare/filer/body/file_body/file_item/symbol/default/face/picture.js.coffee @@ -2,11 +2,10 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.SymbolItemCol initialize: (options) -> super(options) - _this = this if @item[@method_name()] - @item[@method_name()]((pic) -> - _this.picture = pic - _this.render() + @item[@method_name()]((pic) => + @picture = pic + @render() ) else @picture = new Pettanr.Image.SymbolImg({ @@ -14,7 +13,7 @@ class Locmare.FilerModule.BodyModule.FileBodyModule.FileItemModule.SymbolItemCol src: '/images/error.png' } }) - _this.render() + @render() render: () -> if @picture diff --git a/app/assets/javascripts/locmare/form.js.coffee b/app/assets/javascripts/locmare/form.js.coffee index bd2c9e59..9a32fbdc 100644 --- a/app/assets/javascripts/locmare/form.js.coffee +++ b/app/assets/javascripts/locmare/form.js.coffee @@ -71,28 +71,27 @@ class Locmare.Form extends Locmare.FormBase this init_fields: () -> - _this = this - _.each _this.manifest.field_names, (field_name) -> - field_manifest = _this.manifest.fields[field_name] - boost_name = _this.item.my_class().find_boost_name(field_name) + _.each @manifest.field_names, (field_name) => + field_manifest = @manifest.fields[field_name] + boost_name = @item.my_class().find_boost_name(field_name) extend_model = if boost_name - _this.item.boosters[boost_name].extend_model() + @item.boosters[boost_name].extend_model() else null if boost_name and extend_model # field is extend setting AND template has a extend model - extend_form_name = _this.item.boosters[boost_name].item_name() - extend_item = _this.item.boosters[boost_name].extend_item() - _this.fields[field_name] = new Locmare.ExtendForm({ - parent: _this, + extend_form_name = @item.boosters[boost_name].item_name() + extend_item = @item.boosters[boost_name].extend_item() + @fields[field_name] = new Locmare.ExtendForm({ + parent: this, form_name: extend_form_name, item: extend_item, - mounted: _this.mounted, - operators: _this.operators, + mounted: @mounted, + operators: @operators, field_name: field_name }) else - _this.fields[field_name] = new Locmare.FormModule.Field({ - form: _this, + @fields[field_name] = new Locmare.FormModule.Field({ + form: this, field_name: field_name, field_manifest: field_manifest }) @@ -106,9 +105,8 @@ class Locmare.Form extends Locmare.FormBase @submits()[@submit] post: () -> - _this = this - _.each @fields, (field) -> - _this.item.set(field.field_name, field.val()) + _.each @fields, (field) => + @item.set(field.field_name, field.val()) if @item.save() window.router.navigate('/' + @item.table_name() + '/' + Pettanr.to_s(@item.get('id')), true) return false @@ -116,9 +114,8 @@ class Locmare.Form extends Locmare.FormBase alert('invalid') put: () -> - _this = this - _.each @fields, (field) -> - _this.item.set(field.field_name, field.val()) + _.each @fields, (field) => + @item.set(field.field_name, field.val()) @item.overwrite({operators: @operators}) if @item.save() window.router.navigate('/' + @item.table_name() + '/' + Pettanr.to_s(@item.get('id')), true) @@ -151,11 +148,10 @@ class Locmare.ExtendForm extends Locmare.FormBase this init_fields: () -> - _this = this - _.each _this.manifest.field_names, (field_name) -> - field_manifest = _this.manifest.fields[field_name] - _this.fields[field_name] = new Locmare.FormModule.ExtendField({ - form: _this, + _.each @manifest.field_names, (field_name) => + field_manifest = @manifest.fields[field_name] + @fields[field_name] = new Locmare.FormModule.ExtendField({ + form: this, field_name: field_name, field_manifest: field_manifest }) @@ -174,10 +170,9 @@ class Locmare.FormModule.Fields extends Backbone.View render: () -> this.$el.html('') - _this = this - _.each @fields, (field) -> - _this.$el.append(field.render().el) - _this.$el.append(field.rb.render().el) if field.rb + _.each @fields, (field) => + this.$el.append(field.render().el) + this.$el.append(field.rb.render().el) if field.rb this class Locmare.FormModule.SubmitModule diff --git a/app/assets/javascripts/locmare/form/extend_field.js.coffee b/app/assets/javascripts/locmare/form/extend_field.js.coffee index 492685dd..4f450d26 100644 --- a/app/assets/javascripts/locmare/form/extend_field.js.coffee +++ b/app/assets/javascripts/locmare/form/extend_field.js.coffee @@ -9,9 +9,8 @@ class Locmare.FormModule.ExtendField extends Backbone.View @label = Locmare.FormModule.FieldModule.LabelFactory.factory this, @field_manifest.label @tag = Locmare.FormModule.FieldModule.TagFactory.factory this, @field_manifest.tag @helpers = {} - _this = this - _.each @field_manifest.helpers, (helper_manifest, helper_name) -> - _this.helpers[helper_name] = Locmare.FormModule.FieldModule.HelperFactory.factory(_this, helper_manifest) + _.each @field_manifest.helpers, (helper_manifest, helper_name) => + @helpers[helper_name] = Locmare.FormModule.FieldModule.HelperFactory.factory(this, helper_manifest) @rb = @row_break() @options = {'data-model': @field_manifest.item_name()} @@ -19,9 +18,8 @@ class Locmare.FormModule.ExtendField extends Backbone.View this.$el.html('') this.$el.append(@label.render().el) if not @label.hidden() this.$el.append(@tag.render().el) - _this = this - _.each @helpers, (helper) -> - _this.$el.append(helper.render().el) + _.each @helpers, (helper) => + this.$el.append(helper.render().el) this.$el.append(@rb.render().el) if @rb this diff --git a/app/assets/javascripts/locmare/form/field.js.coffee b/app/assets/javascripts/locmare/form/field.js.coffee index 476216b1..3a92a9e2 100644 --- a/app/assets/javascripts/locmare/form/field.js.coffee +++ b/app/assets/javascripts/locmare/form/field.js.coffee @@ -63,14 +63,12 @@ class Locmare.FormModule.FieldModule.Helpers extends Backbone.View @field = options.field @field_manifest = options.field_manifest @helpers = {} - _this = this - _.each @field_manifest.helpers, (helper_manifest, helper_name) -> - _this.helpers[helper_name] = Locmare.FormModule.FieldModule.HelperFactory.factory(_this.field, helper_manifest) + _.each @field_manifest.helpers, (helper_manifest, helper_name) => + @helpers[helper_name] = Locmare.FormModule.FieldModule.HelperFactory.factory(@field, helper_manifest) render: () -> this.$el.html('') - _this = this - _.each @helpers, (helper) -> - _this.$el.append(helper.render().el) + _.each @helpers, (helper) => + this.$el.append(helper.render().el) this diff --git a/app/assets/javascripts/locmare/form/field/helper/tail_angle.js.coffee b/app/assets/javascripts/locmare/form/field/helper/tail_angle.js.coffee index f52f25ef..ca0b0cab 100644 --- a/app/assets/javascripts/locmare/form/field/helper/tail_angle.js.coffee +++ b/app/assets/javascripts/locmare/form/field/helper/tail_angle.js.coffee @@ -10,9 +10,8 @@ class Locmare.FormModule.FieldModule.HelperModule.TailAngle extends Locmare.Form @speech_balloon_template = new Pettanr.SpeechBalloonTemplate({ id: @field.item().get('speech_balloon_template_id') }) - _this = this - @speech_balloon_template.fetch({cache: true}).done -> - _this.r_step = _this._r_step() + @speech_balloon_template.fetch({cache: true}).done => + @r_step = @_r_step() render: () -> @attr = { diff --git a/app/assets/javascripts/locmare/form/field/tag/select.js.coffee b/app/assets/javascripts/locmare/form/field/tag/select.js.coffee index 0a1eec30..f3db69f7 100644 --- a/app/assets/javascripts/locmare/form/field/tag/select.js.coffee +++ b/app/assets/javascripts/locmare/form/field/tag/select.js.coffee @@ -8,14 +8,13 @@ class Locmare.FormModule.FieldModule.TagModule.SelectTag extends Locmare.FormMod } _.extend(@attr, @options()) this.$el.attr(@attr) - _this = this - @select_values((members) -> - _.each members, (member) -> - selected = if _this.is_selected(member) + @select_values((members) => + _.each members, (member) => + selected = if @is_selected(member) ' selected' else '' - _this.$el.append('') + this.$el.append('') ) this diff --git a/app/assets/javascripts/locmare/list_group/lib/pager.js.coffee b/app/assets/javascripts/locmare/list_group/lib/pager.js.coffee index c2d093ed..05a0d2ca 100644 --- a/app/assets/javascripts/locmare/list_group/lib/pager.js.coffee +++ b/app/assets/javascripts/locmare/list_group/lib/pager.js.coffee @@ -46,11 +46,10 @@ class Locmare.ListGroupModule.LibModule.PagerModule.Default extends Backbone.Vie this.$el.append( (new Locmare.ListGroupModule.LibModule.PagerModule.PageGap()).render().el ) - _this = this - _.each @range(), (page) -> + _.each @range(), (page) => _this.$el.append( (new Locmare.ListGroupModule.LibModule.PagerModule.Page({ - parent: _this, page: page, class_name: 'page' + parent: this, page: page, class_name: 'page' })).render().el ) if @hasNextPageGap() diff --git a/app/assets/javascripts/locmare/list_group/list/base.js.coffee b/app/assets/javascripts/locmare/list_group/list/base.js.coffee index 9b6d4f2c..bf6dea2a 100644 --- a/app/assets/javascripts/locmare/list_group/list/base.js.coffee +++ b/app/assets/javascripts/locmare/list_group/list/base.js.coffee @@ -22,17 +22,15 @@ class Locmare.ListGroupModule.Base extends Backbone.Collection res.list items: () -> - _this = this - _.map @models, (model) -> - new _this.model_class(model.attributes) + _.map @models, (model) => + new @model_class(model.attributes) count: () -> new Pettanr.CounterModel({}, {url: '/' + @action_manifest.counter_url(@params)}) open: (cb) -> @url = '/' + @action_manifest.url(@params) - _this = this - @fetch({cache: true}).done -> + @fetch({cache: true}).done => #_this.boost(items) cb() diff --git a/app/assets/javascripts/locmare/profiler/association.js.coffee b/app/assets/javascripts/locmare/profiler/association.js.coffee index 3dedcf40..2d6bb1fd 100644 --- a/app/assets/javascripts/locmare/profiler/association.js.coffee +++ b/app/assets/javascripts/locmare/profiler/association.js.coffee @@ -14,21 +14,20 @@ class Locmare.ProfilerModule.Association extends Backbone.View render: () -> this.$el.html('') - _this = this caption = new Tag.Div({class_name: 'caption', content: 'associations'}) this.$el.append(caption.render().el) caption = new Tag.Div({class_name: 'caption', content: 'belongs_to'}) this.$el.append(caption.render().el) - _.each @belongs_to, (f) -> - _this.$el.append(f.render().el) + _.each @belongs_to, (f) => + this.$el.append(f.render().el) caption = new Tag.Div({class_name: 'caption', content: 'has_many'}) this.$el.append(caption.render().el) - _.each @has_many, (f) -> - _this.$el.append(f.render().el) + _.each @has_many, (f) => + this.$el.append(f.render().el) caption = new Tag.Div({class_name: 'caption', content: 'has_one'}) this.$el.append(caption.render().el) - _.each @has_one, (f) -> - _this.$el.append(f.render().el) + _.each @has_one, (f) => + this.$el.append(f.render().el) this item: () -> diff --git a/app/assets/javascripts/locmare/profiler/association/belongs_to.js.coffee b/app/assets/javascripts/locmare/profiler/association/belongs_to.js.coffee index d10b9832..7ac40467 100644 --- a/app/assets/javascripts/locmare/profiler/association/belongs_to.js.coffee +++ b/app/assets/javascripts/locmare/profiler/association/belongs_to.js.coffee @@ -6,15 +6,14 @@ class Locmare.ProfilerModule.AssociationModule.BelongsTo extends Backbone.View @belongs_to_manifest = options.belongs_to_manifest pm = @parent_model() m = new pm({id: @parent_id()}) - _this = this - m.fetch({cache: true}).done -> - _this.filer = new Locmare.Filer({ - item_name: _this.parent_model().item_name(), + m.fetch({cache: true}).done => + @filer = new Locmare.Filer({ + item_name: @parent_model().item_name(), items: [m], pager: null, - operators: _this.profiler().operators + operators: @profiler().operators }) - _this.render() + @render() render: () -> this.$el.html(@filer.el) if @filer diff --git a/app/assets/javascripts/locmare/profiler/association/has_many.js.coffee b/app/assets/javascripts/locmare/profiler/association/has_many.js.coffee index 7e6d8471..d2475a14 100644 --- a/app/assets/javascripts/locmare/profiler/association/has_many.js.coffee +++ b/app/assets/javascripts/locmare/profiler/association/has_many.js.coffee @@ -11,15 +11,14 @@ class Locmare.ProfilerModule.AssociationModule.HasMany extends Backbone.View action.path_name(), action.name, @profiler().operators, {id: @item().get('id'), page: 1, page_size: 3} ) - _this = this - @list.open((page_status) -> - _this.filer = new Locmare.Filer({ - item_name: _this.has_many_model().item_name(), - items: _this.list.items(), - pager: _this.pager, - operators: _this.profiler().operators + @list.open((page_status) => + @filer = new Locmare.Filer({ + item_name: @has_many_model().item_name(), + items: @list.items(), + pager: @pager, + operators: @profiler().operators }) - _this.render() + @render() ) render: () -> diff --git a/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee b/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee index 7ea42b4c..a07f4f88 100644 --- a/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee +++ b/app/assets/javascripts/locmare/profiler/association/has_one.js.coffee @@ -11,15 +11,14 @@ class Locmare.ProfilerModule.AssociationModule.HasOne extends Backbone.View action.path_name(), action.name, @profiler().operators, {id: @item().get('id')} ) - _this = this - @list.open((page_status) -> - _this.filer = new Locmare.Filer({ - item_name: _this.has_one_model().item_name(), - items: _this.list.items(), - pager: _this.pager, - operators: _this.profiler().operators + @list.open((page_status) => + @filer = new Locmare.Filer({ + item_name: @has_one_model().item_name(), + items: @list.items(), + pager: @pager, + operators: @profiler().operators }) - _this.render() + @render() ) render: () -> diff --git a/app/assets/javascripts/locmare/profiler/column.js.coffee b/app/assets/javascripts/locmare/profiler/column.js.coffee index 42c89bdf..663341b1 100644 --- a/app/assets/javascripts/locmare/profiler/column.js.coffee +++ b/app/assets/javascripts/locmare/profiler/column.js.coffee @@ -6,15 +6,13 @@ class Locmare.ProfilerModule.Column extends Backbone.View @profiler = options.profiler @profiler_manifest = @profiler.profiler_manifest @columns = {} - _this = this - _.each @profiler_manifest.columns, (column, name) -> - _this.columns[name] = _this.factory(_this.profiler, column) + _.each @profiler_manifest.columns, (column, name) => + @columns[name] = @factory(@profiler, column) render: () -> - _this = this this.$el.html('') - _.each @sorted_columns(), (column) -> - _this.$el.append(column.render().el) + _.each @sorted_columns(), (column) => + this.$el.append(column.render().el) this types: () -> @@ -35,7 +33,7 @@ class Locmare.ProfilerModule.Column extends Backbone.View sorted_columns: () -> _.map @profiler_manifest.column_names, (column_name) => - _this.columns[column_name] + @columns[column_name] class Locmare.ProfilerModule.ColumnModule diff --git a/app/assets/javascripts/locmare/profiler/column/base.js.coffee b/app/assets/javascripts/locmare/profiler/column/base.js.coffee index 9b97ffa0..cb9802ec 100644 --- a/app/assets/javascripts/locmare/profiler/column/base.js.coffee +++ b/app/assets/javascripts/locmare/profiler/column/base.js.coffee @@ -91,26 +91,23 @@ class Locmare.ProfilerModule.ColumnModule.ExtendValue extends Backbone.View initialize: (options) -> @column = options.column @columns = {} - _this = this - _.each @extend_settings().column_names, (extend_column_name) -> - extend_column_manifest = _this.extend_settings().columns[extend_column_name] || {} - _this.columns[extend_column_name] = new Locmare.ProfilerModule.ColumnModule.ExtendModule.ExtendColumn({ - column: _this, + _.each @extend_settings().column_names, (extend_column_name) => + extend_column_manifest = @extend_settings().columns[extend_column_name] || {} + @columns[extend_column_name] = new Locmare.ProfilerModule.ColumnModule.ExtendModule.ExtendColumn({ + column: this, extend_column_name: extend_column_name, extend_column_manifest: extend_column_manifest }) render: () -> - _this = this this.$el.html('') - _.each @sorted_columns(), (extend_column) -> - _this.$el.append(extend_column.render().el) + _.each @sorted_columns(), (extend_column) => + this.$el.append(extend_column.render().el) this sorted_columns: () -> - _this = this - _.map @extend_settings().column_names, (column_name) -> - _this.columns[column_name] + _.map @extend_settings().column_names, (column_name) => + @columns[column_name] extend_settings: () -> @template_model_profiler().extend_settings[@booster().item_name()] diff --git a/app/assets/javascripts/pettanr.js.coffee b/app/assets/javascripts/pettanr.js.coffee index 0ea32bde..a9175300 100644 --- a/app/assets/javascripts/pettanr.js.coffee +++ b/app/assets/javascripts/pettanr.js.coffee @@ -127,16 +127,14 @@ class Pettanr filer_list: () -> @set_list() - _this = this - _list = @list - @list.open(() -> - pager = Locmare.ListGroupModule.LibModule.Pager.factory(_list.page_status, _this.params) + @list.open(() => + pager = Locmare.ListGroupModule.LibModule.Pager.factory(@list.page_status, @params) f = new Locmare.Filer({ el: "#pettanr", - item_name: _this.my_list_model_class.item_name(), - items: _this.list.items(), + item_name: @my_list_model_class.item_name(), + items: @list.items(), pager: pager, - operators: _this.operators + operators: @operators }) ) false @@ -150,24 +148,21 @@ class Pettanr @item = new @binder_model_class({id: @params['id']}) play_list: () -> - _this = this - _list = @list - @list.open(() -> - console.log _this.list.items() + @list.open(() => + console.log @list.items() ) false show_prof: () -> - _this = this - @item.fetch({cache: true}).done -> - _this.item.boosts 'post' + @item.fetch({cache: true}).done => + @item.boosts 'post' profiler = new Locmare.Profiler({ - item_name: _this.item.item_name(), - item: _this.item, - operators: _this.operators + item_name: @item.item_name(), + item: @item, + operators: @operators }) $("#pettanr").html(profiler.render().el) - _this.redraw_title(_this.params) + @redraw_title(@params) set_new: () -> @set_model() @@ -179,10 +174,9 @@ class Pettanr set_edit: () -> @set_model() @item = new @my_model_class({id: @params['id']}) - _this = this - @item.fetch({cache: true}).done -> - _this.item.boosts 'post' - _this.render_form() + @item.fetch({cache: true}).done => + @item.boosts 'post' + @render_form() render_form: () -> @form = new Locmare.Form({ @@ -207,27 +201,6 @@ class Pettanr site_caption = Manifest.manifest().magic_numbers.profile.users.caption $(document).attr('title', t + ' - ' + site_caption) - class Pettanr.FilerRender - constructor: (item_name, list_result, pager_type, operators) -> - @item_name = item_name - @list_result = list_result - @pager_type = pager_type - @operators = operators - _this = this - @list_result.fetch({cache: true}).done () -> - _this.render() - - render: () -> - items = @list_result.models - f = new Locmare.Filer({ - item_name: @item_name, - items: items, - list_result: @list_result, - pager_type: @pager_type, - operators: @operators - }) - $("#pettanr").html(f.render().el) - #>> https://gist.github.com/davidjbeveridge/3813724 @xeach: (arr, func, index=0) -> if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else [] diff --git a/app/assets/javascripts/tags.js.coffee b/app/assets/javascripts/tags.js.coffee index 471b96ed..47826898 100644 --- a/app/assets/javascripts/tags.js.coffee +++ b/app/assets/javascripts/tags.js.coffee @@ -63,11 +63,10 @@ class Tag.Ul extends Backbone.View render: () -> @el.className = @class_name if @class_name - _this = this this.$el.attr(@attr) this.$el.html('') - _.each @contents, (content) -> - _this.$el.append(content.render().el) + _.each @contents, (content) => + this.$el.append(content.render().el) this class Tag.RowBreak extends Tag.Div diff --git a/lib/locmare/list_group/list/base.rb b/lib/locmare/list_group/list/base.rb index 0f576090..dc7881f2 100644 --- a/lib/locmare/list_group/list/base.rb +++ b/lib/locmare/list_group/list/base.rb @@ -27,7 +27,10 @@ module Locmare end def init - @page_status = LibModule::PageStatus.load self, self.total, @options + end + + def page_status + @page_status ||= LibModule::PageStatus.load self, self.total, @options end def model_name -- 2.11.0