Skip to content
Next Next commit
CUI
- removed jQuery and added jQueryCompat.coffee CUI.DOM - new: children, width, height, append, prepend, empty insertBefore, insertAfter, is, getRelativePosition, setDimension, getDimension - removed: setStylePx, use setStyle instead - getDimensions: new values, borderTop* and offsetTopScrolled, offsetLeftScrolled
  • Loading branch information
martinrode committed Sep 1, 2016
commit cd81f2f1359447ff320fd5f208cbf5f786d27305
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ call_scss = sass --scss --no-cache --sourcemap=inline
easydbui_js = $(target)/easydbui.js

coffee_files = src/base/Common.coffee \
src/base/jQueryCompat.coffee \
src/base/CUI.coffee \
src/base/jQuery.fn.coffee \
src/base/Deferred/Deferred.coffee \
src/base/Deferred/Promise.coffee \
src/base/Deferred/when.coffee \
Expand Down Expand Up @@ -130,8 +130,9 @@ test_files = src/tests/Test.coffee.js \
src/tests/Test_MoveInArray.coffee.js \
src/tests/Test_Promise.coffee.js

thirdparty_files = thirdparty/*/jquery-2.1.0.js \
thirdparty/moment/*js \
# thirdparty/*/jquery-2.1.0.js \

thirdparty_files = thirdparty/moment/*js \
thirdparty/moment/*json \
thirdparty/marked/lib/marked.js

Expand Down
3 changes: 1 addition & 2 deletions demo/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>easydbui - demo</title>
<script src="../jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script src="../moment-with-locales.js" type="text/javascript" charset="utf-8"></script>
<script src="../moment-timezone-with-data.min.js" type="text/javascript" charset="utf-8"></script>
<!-- <script src="../moment-timezone-with-data.min.js" type="text/javascript" charset="utf-8"></script> -->
<script src="../easydbui.js" type="text/javascript" charset="utf-8"></script>
<script src="../marked.js" type="text/javascript" charset="utf-8"></script>
<script src="easydbui_demo.js" type="text/javascript" charset="utf-8"></script>
Expand Down
11 changes: 6 additions & 5 deletions demo/src/demo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,16 @@ class RunDemo extends Element
old_group = null

for demo in demos
demo.getGroup()
if old_group != demo.getGroup()
old_group = demo.getGroup()
items.push(label: old_group)

group_sort = (1000-(idxInArray(demo.getGroup(), groups)+1))+""
# group_sort = (1000-(idxInArray(demo.getGroup(), groups)+1))+"_"+demo.getName()

do (demo) =>
items.push
active: demo == @current_demo
# text: demo.getGroup()+" - "+demo.getName()
# text: demo.getGroup() + group_sort
text: demo.getName()
_demo: demo
onClick: =>
Expand Down Expand Up @@ -211,7 +210,7 @@ class RunDemo extends Element
center:
content: @center_layout

@root.DOM.prependTo(document.body)
DOM.prepend(document.body, @root.DOM)
@root.append( @main_menu_pane )

CUI.loadHTMLFile("demo/easydbui_demo.html")
Expand Down Expand Up @@ -247,7 +246,9 @@ class RunDemo extends Element
if demo_content.DOM
demo_content = demo_content.DOM

if not $(demo_content).hasClass("cui-pane")
console.debug "received demo content", demo, demo_content

if CUI.isArray(demo_content) or not demo_content.classList.contains("cui-pane")
demo_content = new Pane
center:
content:
Expand Down
44 changes: 21 additions & 23 deletions demo/src/scss/themes/ng/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,34 +52,32 @@ $font_awesome_url: '../../font-awesome/css/font-awesome.min.css';
.cui-demo-table {
@include flex-table();

> tbody {
> tr {
+ .cui-demo-divider {
> td {
padding-top: 20px;
}
}

> tr {
+ .cui-demo-divider {
> td {
vertical-align: top;
padding: 2px;
padding-top: 20px;
}
}

&.cui-demo-full-row > td {
flex: 1 1 auto;
> td {
vertical-align: top;
padding: 2px;
}

&.cui-demo-full-row > td {
flex: 1 1 auto;
}

&:not(.cui-demo-full-row) > td {
&:nth-child(1) {
width: 200px;
flex: 0 0 auto;
font-weight: bold;
}

&:not(.cui-demo-full-row) > td {
&:nth-child(1) {
width: 200px;
flex: 0 0 auto;
font-weight: bold;
}

&:nth-child(2) {
position: relative;
flex: 1 1 auto;
}
&:nth-child(2) {
position: relative;
flex: 1 1 auto;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/base/CSS/CSS.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class CSS extends Element
href: url
)

DOM.data(cssNode[0], "element", @)
DOM.data(cssNode, "element", @)

Events.listen
node: cssNode
Expand All @@ -97,8 +97,8 @@ class CSS extends Element

old_css_nodes = []
for css_node in DOM.matchSelector(document.head, "link[name='"+@__cssName+"']")
if css_node != cssNode[0]
css_node.parentNode.removeChild(css_node)
if css_node != cssNode
DOM.remove(css_node)
old_css_nodes.push(css_node)

CUI.info("CSS.load: loading went fine: ", url, "Removing the old CSS node: ", old_css_nodes)
Expand All @@ -119,7 +119,7 @@ class CSS extends Element
dfr.reject()
return

document.head.appendChild(cssNode[0])
document.head.appendChild(cssNode)

# anchor_node.after(@__cssNode)
dfr.promise()
Expand Down
46 changes: 25 additions & 21 deletions src/base/CUI.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class CUI
@start: ->
@getPathToScript()

$window = $(window)
$body = $(document.body)

trigger_viewport_resize = =>
CUI.info("CUI: trigger viewport resize.")
Events.trigger
Expand Down Expand Up @@ -46,9 +43,9 @@ class CUI
ev.preventDefault()
return

$body[0].scrollTop=0
document.body.scrollTop=0

if not $(".ez-tmpl-dummy").length
if not DOM.matchSelector(document.documentElement, ".ez-tmpl-dummy").length
@loadHTMLFile("easydbui.html")
.done =>
@ready()
Expand Down Expand Up @@ -122,7 +119,7 @@ class CUI

@getPathToScript: ->
if not @pathToScript
for s, idx in $("script")
for s, idx in DOM.matchSelector(document.documentElement, "script")
if m = s.src.match("(.*)/easydbui.js")
@pathToScript = m[1]
@script = s
Expand All @@ -142,14 +139,14 @@ class CUI
responseType: "text"
.start()
.done (data) ->
div.html(data)
div.appendTo(document.body)
div.innerHTML = data
document.body.appendChild(div)
.fail (xhr) ->
CUI.error("CUI.loadHTMLFile: Unable to load filename: \"#{filename}\", see Console for more details. You can however, output easydbui.html manually before loading easydbui.js.", xhr)

@getViewport: ->
width: $(window).width()
height: $(window).height()
width: window.innerWidth
height: window.innerHeight

@ready: (func) ->
if func instanceof Function
Expand Down Expand Up @@ -212,14 +209,15 @@ class CUI

scroll()

jQuery.when.apply($, promises)
CUI.when(promises)

@defaults:
FileUpload:
name:
"files[]"

debug: true
jQueryCompatWarningLevel: 0 # 2 # 0: off, 1: warn, 2: error with more info
asserts: true
class: {}

Expand Down Expand Up @@ -273,7 +271,7 @@ class CUI
return


if $.isFunction(args[idx])
if CUI.isFunction(args[idx])
if __this != CUI
ret = args[idx].call(__this)
else
Expand Down Expand Up @@ -385,7 +383,7 @@ class CUI


@setTimeout: (_func, ms=0, track) ->
if $.isPlainObject(_func)
if CUI.isPlainObject(_func)
ms = _func.ms or 0
track = _func.track
func = _func.call
Expand All @@ -400,7 +398,7 @@ class CUI
else
track = true

assert($.isFunction(func), "CUI.setTimeout", "Function needs to be a Function (opts.call)", parameter: _func)
assert(CUI.isFunction(func), "CUI.setTimeout", "Function needs to be a Function (opts.call)", parameter: _func)
timeout =
call: =>
timeout.__isRunning = true
Expand Down Expand Up @@ -569,7 +567,7 @@ class CUI
for k, v of mergeMap
if not targetMap.hasOwnProperty(k)
targetMap[k] = v
else if $.isPlainObject(targetMap[k]) and $.isPlainObject(v)
else if CUI.isPlainObject(targetMap[k]) and CUI.isPlainObject(v)
CUI.mergeMap(targetMap[k], v)
targetMap

Expand All @@ -593,7 +591,7 @@ class CUI
encode_func = (v) -> encodeURIComponent(v)

for k, v of params
if $.isArray(v)
if CUI.isArray(v)
for _v in v
url.push(encode_func(k) + connect_pair + encode_func(_v))
else
Expand Down Expand Up @@ -659,13 +657,21 @@ class CUI
v instanceof Function

@isPlainObject: (v) ->
jQuery.isPlainObject(v)
typeof(v) == "object" and v.constructor == Object

@isEmptyObject: (v) ->
for k of v
return false
return true

@isMap: (v) ->
jQuery.isPlainObject(v)
@isPlainObject(v)

@isArray: (v) ->
jQuery.isArray(v)
v instanceof Array

@isString: (s) ->
typeof(s) == "string"

@downloadData: (data, fileName) ->
json = JSON.stringify(data)
Expand Down Expand Up @@ -796,8 +802,6 @@ class CUI
console.warn.apply(console, arguments)


assert(jQuery().jquery >= "2.1.0", "easydbui", "You need jQuery version >= 2.1.0 loaded before loading easydbui.js. Your version is \"#{jQuery().jquery}\".")

CUI.ready =>

# initialize a markdown renderer
Expand Down
Loading