Skip to content

Commit 9f17c3e

Browse files
committed
util.assertInstanceOf: simplified call, Icon: reformatted code
1 parent 15b604c commit 9f17c3e

File tree

3 files changed

+74
-73
lines changed

3 files changed

+74
-73
lines changed

src/base/Element.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ class CUI.Element
212212
if CUI.util.isArray(v.check)
213213
CUI.util.assert(v.check.indexOf(value) > -1, cls, "opts.#{k} needs to be one of [\"#{v.check.join('\",\"')}\"].", opts: opts)
214214
else if v.check == Boolean or v.check == String or v.check == Function or v.check == Array
215-
CUI.util.assertInstanceOf.call(@, k, v.check, undefined, value)
215+
CUI.util.assertInstanceOf.call(@, k, v.check, value)
216216
else if CUI.util.isFunction(v.check) and not v.check.__super__ # super is from coffeescript and shows us that we have a "class" here
217217
CUI.util.assert(CUI.util.isEmpty(v.check.name) or v.check.name == "check", cls, "#{k}.check is \"#{v.check.name}\" but has no \"__super__\" method. Use \"extends CUI.Element\" or \"extends CUI.Dummy\" to fix that.", opts: opts, key: k, value: v)
218218
check = v.check.call(@, value)
@@ -234,7 +234,7 @@ class CUI.Element
234234
else if CUI.util.isNull(value) and mandatory
235235
CUI.util.assert(false, cls, "opts.#{k} is mandatory, but is #{value}.", opts: opts)
236236
else
237-
CUI.util.assertInstanceOf.call(@, k, v.check, undefined, value)
237+
CUI.util.assertInstanceOf.call(@, k, v.check, value)
238238

239239
# convenient mapping this to our space
240240
if map_values

src/base/Icon/Icon.coffee

Lines changed: 70 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ class CUI.Icon extends CUI.Element
1111
svg_cls = ""
1212
cls = ""
1313
if @_icon
14-
cls = CUI.Icon.icon_map[@_icon]
15-
if CUI.util.isEmpty(cls)
14+
# common map icon
15+
if not cls
16+
cls = CUI.Icon.icon_map[@_icon]
17+
18+
# fallback to value of icon
19+
if not cls
1620
cls = @_icon
1721

1822
if cls.startsWith("svg-")
@@ -56,85 +60,86 @@ class CUI.Icon extends CUI.Element
5660
CUI.dom.showElement(@DOM)
5761

5862
@icon_map:
59-
trash: "svg-trash"
60-
reset: "svg-reset"
61-
spinner: "svg-spinner cui-spin-stepped"
62-
remove: "svg-close"
63+
audio: "fa-music"
64+
bolt: "fa-bolt"
65+
calendar: "fa-calendar-plus-o"
66+
camera: "fa-camera"
67+
check: "fa-check"
68+
clock: "fa-clock-o"
6369
close: "svg-close"
64-
folder: "svg-folder"
65-
folder_shared: "svg-folder-shared"
66-
folder_upload: "svg-folder-upload"
67-
folder_shared_upload: "svg-folder-shared-upload"
68-
info_circle: "svg-info-circle"
69-
external_link: "svg-external-link"
70+
cloud: "fa-cloud"
71+
copy: "fa-files-o"
7072
crop: "fa-crop"
71-
fullscreen: "fa-arrows-alt"
73+
dive: "fa-angle-right"
74+
down: "fa-caret-down"
75+
download: "fa-download"
76+
east: "fa-angle-right"
77+
edit: "fa-pencil"
78+
ellipsis_h: "fa-ellipsis-h"
79+
ellipsis_v: "fa-ellipsis-v" #used for sidemenu buttons
80+
email: "fa-envelope-o"
81+
envelope_active: "fa-envelope"
82+
envelope: "fa-envelope-o"
83+
expert_search: "fa-list-ul" #"fa-binoculars" #"fa-mortar-board"
84+
export: "fa-download"
85+
external_link: "svg-external-link"
7286
failed: "fa-warning"
73-
no_right: "fa-slack"
87+
file_text : "fa-file-text-o"
88+
file_text_active : "fa-file-text"
7489
file: "fa-file"
7590
filter: "fa-filter"
76-
sliders: "fa-sliders"
91+
folder_shared_upload: "svg-folder-shared-upload"
92+
folder_shared: "svg-folder-shared"
93+
folder_upload: "svg-folder-upload"
94+
folder: "svg-folder"
95+
fullscreen: "fa-arrows-alt"
96+
heart: "fa-heart"
97+
help: "fa-question"
98+
image: "fa-picture-o"
99+
info_circle: "svg-info-circle"
100+
info_circle_ng: "svg-info-circle-ng"
101+
info: "fa-info-circle"
102+
left: "fa-angle-left"
103+
legal: "fa-legal"
104+
list: "fa-question"
105+
menu: "fa-bars"
106+
minus: "fa-minus"
107+
no_right: "fa-slack"
108+
north: "fa-angle-up"
109+
play: "fa-play"
110+
plus: "fa-plus"
111+
print: "fa-print"
112+
question: "fa-question"
77113
refresh: "fa-refresh"
78-
zip: "fa fa-file-archive-o"
79-
rotate_right: "fa-rotate-right"
114+
remove: "svg-close"
115+
required: "fa-bullhorn"
116+
reset: "svg-reset"
117+
resize_full: "fa-expand"
118+
resize_small: "fa-compress"
119+
right: "fa-angle-right"
120+
rotate_horizontal: "fa-arrows-h"
80121
rotate_left: "fa-rotate-left"
122+
rotate_right: "fa-rotate-right"
81123
rotate_vertical: "fa-arrows-v"
82-
rotate_horizontal: "fa-arrows-h"
83-
calendar: "fa-calendar-plus-o"
84-
show: "fa-question"
85-
help: "fa-question"
86-
question: "fa-question"
87-
settings: "fa-cog"
88-
download: "fa-download"
89-
export: "fa-download"
90-
list: "fa-question"
91-
upload: "fa-upload"
92-
envelope: "fa-envelope-o"
93-
envelope_active: "fa-envelope"
94124
save: "fa-floppy-o"
95-
heart: "fa-heart"
96-
user: "fa-user"
97-
clock: "fa-clock-o"
98-
plus: "fa-plus"
99-
edit: "fa-pencil"
100-
copy: "fa-files-o"
101125
search: "fa-search"
126+
settings: "fa-cog"
102127
share: "fa-share"
103-
play: "fa-play"
104-
audio: "fa-music"
128+
show: "fa-question"
129+
sliders: "fa-sliders"
130+
south: "fa-angle-down"
131+
spinner: "svg-spinner cui-spin-stepped"
105132
start: "fa-play"
106133
stop: "fa-stop"
107-
print: "fa-print"
108-
minus: "fa-minus"
109-
ellipsis_h: "fa-ellipsis-h"
110-
ellipsis_v: "fa-ellipsis-v" #used for sidemenu buttons
111-
menu: "fa-bars"
112-
info: "fa-info-circle"
113-
bolt: "fa-bolt"
114-
check: "fa-check"
134+
trash: "svg-trash"
135+
up: "fa-caret-up"
136+
upload: "fa-upload"
137+
user: "fa-user"
115138
warning: "fa-warning"
116-
legal: "fa-legal"
117-
cloud: "fa-cloud"
118-
left: "fa-angle-left"
119-
right: "fa-angle-right"
120-
dive: "fa-angle-right"
139+
west: "fa-angle-left"
140+
zip: "fa fa-file-archive-o"
121141
zoom_in: "fa-search-plus"
122142
zoom_out: "fa-search-minus"
123-
resize_small: "fa-compress"
124-
resize_full: "fa-expand"
125-
email: "fa-envelope-o"
126-
file_text_active : "fa-file-text"
127-
file_text : "fa-file-text-o"
128-
required: "fa-bullhorn"
129-
west: "fa-angle-left"
130-
east: "fa-angle-right"
131-
south: "fa-angle-down"
132-
north: "fa-angle-up"
133-
up: "fa-caret-up"
134-
down: "fa-caret-down"
135-
camera: "fa-camera"
136-
expert_search: "fa-list-ul" #"fa-binoculars" #"fa-mortar-board"
137-
image: "fa-picture-o"
138143

139144

140145
CUI.proxyMethods(CUI.Icon, CUI.Button, ["hide", "show", "isShown","isHidden"])

src/base/util.coffee

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,13 @@ class CUI.util
8484
CUI.util.assert(needs.length == 0, "#{CUI.util.getObjectClass(inst)}", "Needs implementations for #{needs.join(', ')}.", instance: inst)
8585
return
8686

87-
@assertInstanceOf: (variableName, classClass, opts, value=undefined) ->
87+
@assertInstanceOf: (variableName, classClass, value) ->
8888
if not CUI.defaults.asserts
8989
return
9090

9191
if not CUI.util.isFunction(classClass) and not classClass == "PlainObject"
9292
throw "assertInstanceOf: class is not a Function"
9393

94-
if value == undefined
95-
value = opts[variableName]
96-
CUI.util.assert(CUI.util.isPlainObject(opts), "new #{arguments.callee.caller.name}", "opts needs to be PlainObject but it is #{CUI.util.getObjectClass(opts)}.", opts: opts)
97-
9894
if classClass == "Array"
9995
cn = "Array"
10096
cond = value instanceof Array
@@ -121,7 +117,7 @@ class CUI.util
121117
if not fn
122118
fn = CUI.util.getObjectClass(@)
123119

124-
CUI.util.assert(false, "new #{fn}", "opts.#{variableName} needs to be instance of #{cn} but it is #{CUI.util.getObjectClass(value)}.", opts: opts, value: value, classClass: classClass)
120+
CUI.util.assert(false, "new #{fn}", "opts.#{variableName} needs to be instance of #{cn} but it is #{CUI.util.getObjectClass(value)}.", value: value, classClass: classClass)
125121
return
126122

127123
@$elementIsInDOM: ($el) ->

0 commit comments

Comments
 (0)