-
Notifications
You must be signed in to change notification settings - Fork 10
isp: @zhigalov @frgt #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,69 +2,73 @@ function notImplemented() { | |
| throw new Error('Method is not implemented'); | ||
| } | ||
|
|
||
| function AbstractButton(label) { | ||
| this.label = label; | ||
| function AbstractButton(options) { | ||
| this.label = options.label; | ||
| this.$el = this.render(); | ||
| this.bind(); | ||
| } | ||
| AbstractButton.prototype = { | ||
| getLabel: function() { | ||
| return this.label; | ||
| }, | ||
| getIcon: function () { | ||
| notImplemented(); | ||
| }, | ||
| getUrl: function () { | ||
| notImplemented(); | ||
| }, | ||
| onClick: function (e) { | ||
| notImplemented(); | ||
| }, | ||
| onClick: function (e) {}, | ||
| render: function () { | ||
| var icon = this.getIcon(); | ||
| var url = this.getUrl(); | ||
| var label = this.getLabel(); | ||
| var $el = $('<button></button>'); | ||
|
|
||
| if (icon) { | ||
| $el.append($('<img/>').attr('src', icon)); | ||
| } | ||
|
|
||
| if (label) { | ||
| $el.append(label); | ||
| } | ||
|
|
||
| if (url) { | ||
| $el.wrap('<a href="' + url + '"></a>'); | ||
| } | ||
|
|
||
| return $el; | ||
| }, | ||
| bind: function () { | ||
| this.$el.click(this.onClick); | ||
| } | ||
| }; | ||
|
|
||
| function IconButton(icon) { | ||
| AbstractButton.call(this, void 0); | ||
| this.icon = icon; | ||
| function IconButton(options) { | ||
| AbstractButton.call(this, options); | ||
| this.icon = options.icon; | ||
| } | ||
| IconButton.prototype = Object.extend(Object.create(AbstractButton.prototype), { | ||
| getIcon: function () { | ||
| return this.icon; | ||
| }, | ||
| getUrl: function () {}, | ||
| onClick: function (e) {} | ||
| onClick: function (e) { | ||
| // some logic | ||
| }, | ||
| render: function () { | ||
| var icon = this.getIcon(), | ||
| $el = IconButton.prototype.render.call(this); | ||
|
|
||
| if (icon) { | ||
| $el.append($('<img/>').attr('src', icon)); | ||
| } | ||
|
|
||
| return $el; | ||
| } | ||
| }); | ||
|
|
||
| function AnchorButton(label, url) { | ||
| AbstractButton.call(this, label); | ||
| this.url = url; | ||
| function AnchorButton(options) { | ||
| AbstractButton.call(this, options); | ||
| this.url = options.url || '#'; | ||
| } | ||
| AnchorButton.prototype = Object.extend(Object.create(AbstractButton.prototype), { | ||
| getIcon: function () {}, | ||
| getUrl: function () { | ||
| return this.url; | ||
| }, | ||
| onClick: function (e) {} | ||
| onClick: function (e) { | ||
| // some logic | ||
| }, | ||
| render: function () { | ||
| var label = this.getLabel(); | ||
| var $el = $('<a href="' + this.getUrl() + '"></a>'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. offtop: ссылка должна оборачивать кнопку
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не юзабельно ведь. сделали как в бутстрапе, типа ссылка стилизуется под кнопку. и кнопка блочный элемент, а ссылка инлайн There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Собственно в лего точно так же делается |
||
|
|
||
| if (label) { | ||
| $el.append(label); | ||
| } | ||
|
|
||
| return $el; | ||
| } | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У IconButton label никак не используется
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
может использоваться. кнопка, у которой надпись и иконка