coolstrap-generator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.DS_Store +0 -0
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Rakefile +6 -0
- data/bin/coolstrap +5 -0
- data/coolstrap-generator.gemspec +42 -0
- data/lib/.DS_Store +0 -0
- data/lib/coolstrap-generator.rb +39 -0
- data/lib/coolstrap-generator/.DS_Store +0 -0
- data/lib/coolstrap-generator/builder/middleman.rb +0 -0
- data/lib/coolstrap-generator/cli.rb +71 -0
- data/lib/coolstrap-generator/generate/project.rb +96 -0
- data/lib/coolstrap-generator/generate/view.rb +54 -0
- data/lib/coolstrap-generator/logger.rb +13 -0
- data/lib/coolstrap-generator/middleman/helpers.rb +176 -0
- data/lib/coolstrap-generator/templates/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/assets/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.eot +0 -0
- data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.svg +255 -0
- data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/coolstrap-generator/templates/app/assets/fonts/fontawesome-webfont.woff +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/arrow-list.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/arrow.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/menu.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/smatphone.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/smatphone@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-landscape.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-landscape@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-portrait.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/coolstrap/startup/tablet-portrait@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/smatphone.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/smatphone@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-landscape.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-landscape@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-portrait.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/images/startup/tablet-portrait@2x.png +0 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/app.js +18 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.App.coffee +39 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.Console.coffee +49 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.Constants.coffee +89 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/_Coolstrap.js +13 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/build/_wrap-start.js +18 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/coolstrap-0.1.js +20 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/coolstrap-0.1.packed.js +23 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/fallback/_Coolstrap.Fallback.Android.coffee +53 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/fallback/_Coolstrap.Fallback.iOS.coffee +29 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Articles.coffee +34 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Dialogs.coffee +33 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Navigation.coffee +118 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/framework/_Coolstrap.Framework.Sections.coffee +60 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/iscroll.js +1076 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/modernizr-2.5.3.js +1265 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/lib/zepto-1.0rc1.js +1357 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/navigate/_Coolstrap.Navigate.History.coffee +164 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/navigate/_Coolstrap.Navigate.coffee +105 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/plugins/_Coolstrap.Plugins.coffee +157 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.Core.coffee +54 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.Platform.coffee +89 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.UI.coffee +96 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.coffee +41 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Article.coffee +43 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Aside.coffee +65 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Dialog.coffee +129 -0
- data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/view/_Coolstrap.View.Scroll.coffee +191 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/_structure.scss +8 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/coolstrap.css.scss +2 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_components.scss +5 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_layout.scss +4 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/_utilities.scss +6 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_dialog.scss +122 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_formelements.scss +89 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_listview.scss +76 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_navigations.scss +192 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/components/_tools.scss +169 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_layers.scss +57 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_layout.scss +62 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_positions.scss +38 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/layout/_transitions.scss +35 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_animate.scss +63 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_helpers.scss +82 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_icons.scss +336 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_mixins.scss +45 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_reset.scss +367 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/structure/utilities/_variables.scss +176 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/themes/_default.scss +255 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/coolstrap/themes/coolstrap.css.scss +164 -0
- data/lib/coolstrap-generator/templates/app/assets/stylesheets/customtheme.css.scss +19 -0
- data/lib/coolstrap-generator/templates/app/components/_formelements.html.haml +130 -0
- data/lib/coolstrap-generator/templates/app/components/_tabbar.html.haml +343 -0
- data/lib/coolstrap-generator/templates/app/components/_toolbar.html.haml +463 -0
- data/lib/coolstrap-generator/templates/app/components/formelements.html.haml +196 -0
- data/lib/coolstrap-generator/templates/app/components/listview/_complexlistavatar.html.haml.erb +77 -0
- data/lib/coolstrap-generator/templates/app/components/listview/_simplelist.html.haml.erb +31 -0
- data/lib/coolstrap-generator/templates/app/components/tabbar.html.haml.erb +16 -0
- data/lib/coolstrap-generator/templates/app/components/toolbar.html.haml.erb +32 -0
- data/lib/coolstrap-generator/templates/app/index.html.haml.erb +21 -0
- data/lib/coolstrap-generator/templates/app/layout.haml.erb +79 -0
- data/lib/coolstrap-generator/templates/app/views/.DS_Store +0 -0
- data/lib/coolstrap-generator/templates/app/views/_home.haml.erb +31 -0
- data/lib/coolstrap-generator/templates/app/views/shared/_aside_onbottom.haml +2 -0
- data/lib/coolstrap-generator/templates/app/views/shared/_aside_onleft.haml +56 -0
- data/lib/coolstrap-generator/templates/app/views/shared/_aside_onright.haml +66 -0
- data/lib/coolstrap-generator/templates/app/views/shared/_aside_ontop.haml +19 -0
- data/lib/coolstrap-generator/templates/defaults/Gemfile.erb +3 -0
- data/lib/coolstrap-generator/templates/defaults/LICENSE.erb +1 -0
- data/lib/coolstrap-generator/templates/defaults/Readme.mkd.erb +1 -0
- data/lib/coolstrap-generator/templates/defaults/config.erb +42 -0
- data/lib/coolstrap-generator/templates/defaults/gitignore.erb +2 -0
- data/lib/coolstrap-generator/templates/rakefile +102 -0
- data/lib/coolstrap-generator/templates/specs/app_spec.coffee +3 -0
- data/lib/coolstrap-generator/utils.rb +82 -0
- data/lib/coolstrap-generator/version.rb +5 -0
- data/readme.md +107 -0
- data/spec/cli/command_spec.rb +88 -0
- data/spec/coolstrap-generator/generate/project_spec.rb +126 -0
- data/spec/coolstrap-generator/generate/view_spec.rb +26 -0
- data/spec/coolstrap-generator/logger_spec.rb +25 -0
- data/spec/coolstrap-generator/middleman/helpers_spec.rb +16 -0
- data/spec/coolstrap-generator/utils_spec.rb +120 -0
- data/spec/spec_helper.rb +39 -0
- metadata +321 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Coolstrap Platform functions
|
|
3
|
+
*
|
|
4
|
+
* @namespace COOLSTRAP.Util
|
|
5
|
+
* @class Platform
|
|
6
|
+
*
|
|
7
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
8
|
+
* Inspired by LungoJS
|
|
9
|
+
###
|
|
10
|
+
|
|
11
|
+
COOLSTRAP.Util.Platform = ((cool) ->
|
|
12
|
+
SUPPORTED_OS =
|
|
13
|
+
android: /(Android)\s+([\d.]+)/
|
|
14
|
+
ipad: /(iPad).*OS\s([\d_]+)/
|
|
15
|
+
iphone: /(iPhone\sOS)\s([\d_]+)/
|
|
16
|
+
blackberry: /(BlackBerry).*Version\/([\d.]+)/
|
|
17
|
+
webos: /(webOS|hpwOS)[\s\/]([\d.]+)/
|
|
18
|
+
windows: /(Windows Phone OS)[\s\/]([\d.]+)/
|
|
19
|
+
|
|
20
|
+
_current_environment = null
|
|
21
|
+
_detectBrowser = (user_agent) ->
|
|
22
|
+
is_webkit = user_agent.match(/WebKit\/([\d.]+)/)
|
|
23
|
+
(if (is_webkit) then is_webkit[0] else user_agent)
|
|
24
|
+
|
|
25
|
+
_detectOS = (user_agent) ->
|
|
26
|
+
detected_os = undefined
|
|
27
|
+
for os of SUPPORTED_OS
|
|
28
|
+
supported = user_agent.match(SUPPORTED_OS[os])
|
|
29
|
+
if supported
|
|
30
|
+
detected_os =
|
|
31
|
+
name: (if (os is "iphone" or os is "ipad") then "ios" else os)
|
|
32
|
+
version: supported[2].replace("_", ".")
|
|
33
|
+
|
|
34
|
+
break
|
|
35
|
+
detected_os
|
|
36
|
+
|
|
37
|
+
_detectEnvironment = ->
|
|
38
|
+
ua = navigator.userAgent
|
|
39
|
+
environment = {}
|
|
40
|
+
environment.browser = _detectBrowser(ua)
|
|
41
|
+
environment.os = _detectOS(ua)
|
|
42
|
+
environment.isMobile = (if (environment.os) then true else false)
|
|
43
|
+
environment.screen =
|
|
44
|
+
width: window.innerWidth
|
|
45
|
+
height: window.innerHeight
|
|
46
|
+
|
|
47
|
+
environment
|
|
48
|
+
###
|
|
49
|
+
* Determine if the current environment is a mobile environment
|
|
50
|
+
*
|
|
51
|
+
* @method isMobile
|
|
52
|
+
*
|
|
53
|
+
* @return {boolean} true if is mobile environment, false if not.
|
|
54
|
+
###
|
|
55
|
+
isMobile = ->
|
|
56
|
+
_current_environment = _current_environment or _detectEnvironment()
|
|
57
|
+
_current_environment.isMobile
|
|
58
|
+
###
|
|
59
|
+
* Get from current environment
|
|
60
|
+
*
|
|
61
|
+
* Inspired by LungoJS
|
|
62
|
+
*
|
|
63
|
+
* @method environment
|
|
64
|
+
###
|
|
65
|
+
environment = (reload_environment) ->
|
|
66
|
+
_current_environment = (if reload_environment then _detectEnvironment() else _current_environment or _detectEnvironment())
|
|
67
|
+
_current_environment
|
|
68
|
+
|
|
69
|
+
###
|
|
70
|
+
* Reload current environment
|
|
71
|
+
*
|
|
72
|
+
* @method reloadEnvironment
|
|
73
|
+
###
|
|
74
|
+
reloadEnvironment = ->
|
|
75
|
+
environment true
|
|
76
|
+
|
|
77
|
+
###
|
|
78
|
+
* Detect if browser is online
|
|
79
|
+
*
|
|
80
|
+
* @method isOnline
|
|
81
|
+
###
|
|
82
|
+
isOnline = ->
|
|
83
|
+
navigator.onLine
|
|
84
|
+
|
|
85
|
+
isMobile: isMobile
|
|
86
|
+
environment: environment
|
|
87
|
+
isOnline: isOnline
|
|
88
|
+
reloadEnvironment: reloadEnvironment
|
|
89
|
+
)(COOLSTRAP)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Coolstrap UI Utils functions
|
|
3
|
+
*
|
|
4
|
+
* @namespace COOLSTRAP.Util
|
|
5
|
+
* @class UI
|
|
6
|
+
*
|
|
7
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
8
|
+
*
|
|
9
|
+
###
|
|
10
|
+
|
|
11
|
+
COOLSTRAP.Util.UI = ((cool) ->
|
|
12
|
+
VIEWPORT_META = document.querySelector and document.querySelector("meta[name=\"viewport\"]")
|
|
13
|
+
|
|
14
|
+
###
|
|
15
|
+
* Normalized hide address bar for iOS & Android
|
|
16
|
+
* (c) Scott Jehl, scottjehl.com
|
|
17
|
+
* MIT License
|
|
18
|
+
*
|
|
19
|
+
* If we split this up into two functions we can reuse
|
|
20
|
+
* this function if we aren't doing full page reloads.
|
|
21
|
+
* If we cache this we don't need to re-calibrate everytime we call
|
|
22
|
+
* the hide url bar
|
|
23
|
+
*
|
|
24
|
+
* So we don't redefine this function everytime we call hideUrlBar
|
|
25
|
+
* Inspired by MBP Helper
|
|
26
|
+
###
|
|
27
|
+
hideNavigationBar = ->
|
|
28
|
+
_window = window
|
|
29
|
+
_document = _window.document
|
|
30
|
+
if not location.hash or not _window.addEventListener
|
|
31
|
+
_window.scrollTo 0, 1
|
|
32
|
+
scrollTop = 1
|
|
33
|
+
# reset to 0 on bodyready, if needed
|
|
34
|
+
bodycheck = setInterval(->
|
|
35
|
+
if _document.body
|
|
36
|
+
clearInterval bodycheck
|
|
37
|
+
scrollTop = (if "scrollTop" of _document.body then _document.body.scrollTop else 1)
|
|
38
|
+
_window.scrollTo 0, (if scrollTop is 1 then 0 else 1)
|
|
39
|
+
, 15)
|
|
40
|
+
_window.addEventListener "load", (->
|
|
41
|
+
setTimeout (->
|
|
42
|
+
_window.scrollTo 0, (if scrollTop is 1 then 0 else 1)
|
|
43
|
+
), 0
|
|
44
|
+
), false
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
###
|
|
48
|
+
* Autogrow
|
|
49
|
+
* http://googlecode.blogspot.com/2009/07/gmail-for-mobile-html5-series.html
|
|
50
|
+
*
|
|
51
|
+
###
|
|
52
|
+
autogrow = (element, lh) ->
|
|
53
|
+
handler = (e) ->
|
|
54
|
+
newHeight = @scrollHeight
|
|
55
|
+
currentHeight = @clientHeight
|
|
56
|
+
@style.height = newHeight + 3 * textLineHeight + "px" if newHeight > currentHeight
|
|
57
|
+
setLineHeight = (if (lh) then lh else 12)
|
|
58
|
+
textLineHeight = (if element.currentStyle then element.currentStyle.lineHeight else getComputedStyle(element, null).lineHeight)
|
|
59
|
+
textLineHeight = (if (textLineHeight.indexOf("px") is -1) then setLineHeight else parseInt(textLineHeight, 10))
|
|
60
|
+
element.style.overflow = "hidden"
|
|
61
|
+
(if element.addEventListener then element.addEventListener("keyup", handler, false) else element.attachEvent("onkeyup", handler))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
###
|
|
65
|
+
* Enable active
|
|
66
|
+
*
|
|
67
|
+
* Enable CSS active pseudo styles in Mobile Safari
|
|
68
|
+
* http://miniapps.co.uk/blog/post/enable-css-active-pseudo-styles-in-mobile-safari/
|
|
69
|
+
###
|
|
70
|
+
enableActive = ->
|
|
71
|
+
document.addEventListener "touchstart", (->
|
|
72
|
+
), false
|
|
73
|
+
|
|
74
|
+
###
|
|
75
|
+
* Prevent iOS from zooming onfocus
|
|
76
|
+
*
|
|
77
|
+
* https://github.com/h5bp/mobile-boilerplate/pull/108
|
|
78
|
+
###
|
|
79
|
+
preventZoom = ->
|
|
80
|
+
formFields = document.querySelectorAll("input, select, textarea")
|
|
81
|
+
contentString = "width=device-width,initial-scale=1,maximum-scale="
|
|
82
|
+
i = 0
|
|
83
|
+
i = 0
|
|
84
|
+
while i < formFields.length
|
|
85
|
+
formFields[i].onfocus = ->
|
|
86
|
+
VIEWPORT_META.content = contentString + "1"
|
|
87
|
+
|
|
88
|
+
formFields[i].onblur = ->
|
|
89
|
+
VIEWPORT_META.content = contentString + "10"
|
|
90
|
+
i++
|
|
91
|
+
|
|
92
|
+
hideNavigationBar: hideNavigationBar
|
|
93
|
+
autogrow: autogrow
|
|
94
|
+
enableActive: enableActive
|
|
95
|
+
preventZoom: preventZoom
|
|
96
|
+
)(COOLSTRAP)
|
data/lib/coolstrap-generator/templates/app/assets/javascripts/coolstrap/util/_Coolstrap.Util.coffee
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Coolstrapp Utils functions
|
|
3
|
+
*
|
|
4
|
+
* @namespace COOLSTRAP
|
|
5
|
+
* @class Util
|
|
6
|
+
*
|
|
7
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
8
|
+
###
|
|
9
|
+
|
|
10
|
+
COOLSTRAP.Util = ((cool) ->
|
|
11
|
+
###
|
|
12
|
+
* Returns a correct URL using hashtag character
|
|
13
|
+
*
|
|
14
|
+
* @method parseUrl
|
|
15
|
+
*
|
|
16
|
+
* @param {string} Url
|
|
17
|
+
* @return {string} Url parsed
|
|
18
|
+
###
|
|
19
|
+
parseUrl = (href) ->
|
|
20
|
+
href_hashtag = href.lastIndexOf("#")
|
|
21
|
+
if href_hashtag > 0
|
|
22
|
+
href = href.substring(href_hashtag)
|
|
23
|
+
else href = "#" + href if href_hashtag is -1
|
|
24
|
+
href
|
|
25
|
+
|
|
26
|
+
###
|
|
27
|
+
* Returns a URL without hashtag character
|
|
28
|
+
*
|
|
29
|
+
* @method cleanUrl
|
|
30
|
+
*
|
|
31
|
+
* @param {string} Url
|
|
32
|
+
* @return {string} Url parsed
|
|
33
|
+
###
|
|
34
|
+
cleanUrl = (href) ->
|
|
35
|
+
href_hashtag = href.lastIndexOf("#")
|
|
36
|
+
href = href.substring(href_hashtag + 1) if href_hashtag >= 0
|
|
37
|
+
href
|
|
38
|
+
|
|
39
|
+
parseUrl: parseUrl
|
|
40
|
+
cleanUrl: cleanUrl
|
|
41
|
+
)(COOLSTRAP)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Initialize the <articles> layout of a certain <section>
|
|
3
|
+
* Inspired by LungoJS
|
|
4
|
+
*
|
|
5
|
+
* @namespace COOLSTRAP.View
|
|
6
|
+
* @class Article
|
|
7
|
+
*
|
|
8
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
9
|
+
###
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
COOLSTRAP.View.Article = ((cool) ->
|
|
13
|
+
ELEMENT = cool.Constants.ELEMENT
|
|
14
|
+
CLASS = cool.Constants.CLASS
|
|
15
|
+
ATTRIBUTE = cool.Constants.ATTRIBUTE
|
|
16
|
+
TRIGGER = cool.Constants.TRIGGER
|
|
17
|
+
SELECTORS = NAVIGATION_ITEM: "a[href][data-target=\"article\"]"
|
|
18
|
+
_showContainer = (section_id, article_id) ->
|
|
19
|
+
section_articles = section_id + " " + ELEMENT.ARTICLE + "." + CLASS.CURRENT
|
|
20
|
+
current_active_article_id = "#" + cool.dom(section_articles).attr(ATTRIBUTE.ID)
|
|
21
|
+
cool.dom(section_articles).removeClass(CLASS.CURRENT).trigger TRIGGER.UNLOAD
|
|
22
|
+
_fallbackAndroidInputs current_active_article_id, false
|
|
23
|
+
cool.dom(article_id).addClass CLASS.CURRENT
|
|
24
|
+
_fallbackAndroidInputs article_id, true
|
|
25
|
+
|
|
26
|
+
_fallbackAndroidInputs = (article_id, enable) ->
|
|
27
|
+
cool.Fallback.Android.inputs article_id, enable if cool.Fallback.Android
|
|
28
|
+
|
|
29
|
+
_setTitle = (id, item) ->
|
|
30
|
+
title = item.attr(ATTRIBUTE.TITLE)
|
|
31
|
+
if title
|
|
32
|
+
section_title = id + " header h1, " + id + " footer h1"
|
|
33
|
+
cool.dom(section_title).text title
|
|
34
|
+
###
|
|
35
|
+
* Show section
|
|
36
|
+
*
|
|
37
|
+
* @method show
|
|
38
|
+
###
|
|
39
|
+
show = (section_id, article_id) ->
|
|
40
|
+
_showContainer section_id, article_id
|
|
41
|
+
|
|
42
|
+
show: show
|
|
43
|
+
)(COOLSTRAP)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Initialize the <Aisde> layout
|
|
3
|
+
*
|
|
4
|
+
* @namespace COOLSTRAP.View
|
|
5
|
+
* @class Aside
|
|
6
|
+
*
|
|
7
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
8
|
+
###
|
|
9
|
+
|
|
10
|
+
COOLSTRAP.View.Aside = ((cool) ->
|
|
11
|
+
ELEMENT = cool.Constants.ELEMENT
|
|
12
|
+
CLASS = cool.Constants.CLASS
|
|
13
|
+
ATTRIBUTE = cool.Constants.ATTRIBUTE
|
|
14
|
+
TRANSITION = cool.Constants.TRANSITION
|
|
15
|
+
###
|
|
16
|
+
* Display an aside element
|
|
17
|
+
*
|
|
18
|
+
* @method show
|
|
19
|
+
*
|
|
20
|
+
* @param {string} Aside id.
|
|
21
|
+
###
|
|
22
|
+
show = (aside_id) ->
|
|
23
|
+
aside = cool.dom(ELEMENT.ASIDE + aside_id)
|
|
24
|
+
body_class = CLASS.SHOW + CLASS.ASIDE + _classFromAside(aside)
|
|
25
|
+
_initFirstSection aside
|
|
26
|
+
cool.dom(ELEMENT.BODY).addClass(body_class).addClass CLASS.ASIDE
|
|
27
|
+
aside.addClass CLASS.CURRENT
|
|
28
|
+
|
|
29
|
+
_initFirstSection = (aside) ->
|
|
30
|
+
aside_id = aside.attr(ATTRIBUTE.ID)
|
|
31
|
+
sections = cool.dom("#" + aside_id + " " + ELEMENT.SECTION + "." + CLASS.CURRENT)
|
|
32
|
+
section_to_show = sections.first()
|
|
33
|
+
if not section_to_show or section_to_show.length is 0
|
|
34
|
+
sections = cool.dom("#" + aside_id + " " + ELEMENT.SECTION)
|
|
35
|
+
section_to_show = sections.first()
|
|
36
|
+
section_id = "#" + section_to_show.attr(ATTRIBUTE.ID)
|
|
37
|
+
section_to_show.addClass CLASS.CURRENT
|
|
38
|
+
cool.Navigate.History.add
|
|
39
|
+
section_id: section_id
|
|
40
|
+
container_id: aside_id
|
|
41
|
+
init_container: true
|
|
42
|
+
###
|
|
43
|
+
* Hide an aside element
|
|
44
|
+
*
|
|
45
|
+
* @method hide
|
|
46
|
+
*
|
|
47
|
+
* @param {string} Aside id.
|
|
48
|
+
###
|
|
49
|
+
hide = (aside_id) ->
|
|
50
|
+
aside = cool.dom(ELEMENT.ASIDE + aside_id)
|
|
51
|
+
body_class = CLASS.SHOW + CLASS.ASIDE + _classFromAside(aside)
|
|
52
|
+
cool.dom(ELEMENT.BODY).removeClass(body_class).removeClass CLASS.ASIDE
|
|
53
|
+
setTimeout (->
|
|
54
|
+
current_aside = ELEMENT.ASIDE + aside_id + "." + CLASS.CURRENT
|
|
55
|
+
cool.dom(current_aside).removeClass CLASS.CURRENT
|
|
56
|
+
), TRANSITION.DURATION
|
|
57
|
+
cool.Navigate.History.clear aside_id
|
|
58
|
+
|
|
59
|
+
_classFromAside = (aside) ->
|
|
60
|
+
aside_class = aside.attr(ATTRIBUTE.CLASS)
|
|
61
|
+
aside_class or ""
|
|
62
|
+
|
|
63
|
+
show: show
|
|
64
|
+
hide: hide
|
|
65
|
+
)(COOLSTRAP)
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
###
|
|
2
|
+
* Initialize the <dialog> layout
|
|
3
|
+
*
|
|
4
|
+
* @namespace COOLSTRAP.View
|
|
5
|
+
* @class Dialog
|
|
6
|
+
*
|
|
7
|
+
* @author Abraham Barrera <abarrerac@gmail.com> || @abraham_barrera
|
|
8
|
+
###
|
|
9
|
+
|
|
10
|
+
COOLSTRAP.View.Dialog = ((cool) ->
|
|
11
|
+
ELEMENT = cool.Constants.ELEMENT
|
|
12
|
+
CLASS = cool.Constants.CLASS
|
|
13
|
+
DIALOG = cool.Constants.DIALOG
|
|
14
|
+
TRANSITION = cool.Constants.TRANSITION
|
|
15
|
+
console = cool.Console
|
|
16
|
+
_getPosition = (element) ->
|
|
17
|
+
cool.dom.extend {}, (element.offset()),
|
|
18
|
+
width: element[0].offsetWidth
|
|
19
|
+
height: element[0].offsetHeight
|
|
20
|
+
|
|
21
|
+
_getPositionFromSource = (source_pos, dialog_width, dialog_height, placement) ->
|
|
22
|
+
dialog_pos = undefined
|
|
23
|
+
switch placement
|
|
24
|
+
when CLASS.BOTTOM
|
|
25
|
+
dialog_pos =
|
|
26
|
+
top: source_pos.top + source_pos.height
|
|
27
|
+
left: source_pos.left + source_pos.width / 2 - dialog_width / 2
|
|
28
|
+
when CLASS.TOP
|
|
29
|
+
dialog_pos =
|
|
30
|
+
top: source_pos.top - dialog_height
|
|
31
|
+
left: source_pos.left + source_pos.width / 2 - dialog_width / 2
|
|
32
|
+
when CLASS.LEFT
|
|
33
|
+
dialog_pos =
|
|
34
|
+
top: source_pos.top + source_pos.height / 2 - dialog_height / 2
|
|
35
|
+
left: source_pos.left - dialog_width
|
|
36
|
+
when CLASS.RIGHT
|
|
37
|
+
dialog_pos =
|
|
38
|
+
top: source_pos.top + source_pos.height / 2 - dialog_height / 2
|
|
39
|
+
left: source_pos.left + source_pos.width
|
|
40
|
+
dialog_pos.left = 0 if dialog_pos.left < 0
|
|
41
|
+
dialog_pos.top = 0 if dialog_pos.top < 0
|
|
42
|
+
dialog_pos
|
|
43
|
+
|
|
44
|
+
_getPositionCenterOnScreen = (source_size) ->
|
|
45
|
+
dialog_pos = undefined
|
|
46
|
+
update = true
|
|
47
|
+
environment = cool.Util.Platform.reloadEnvironment()
|
|
48
|
+
screen_size = environment.screen
|
|
49
|
+
dialog_pos =
|
|
50
|
+
top: screen_size.height / 2 - source_size.height / 2
|
|
51
|
+
left: screen_size.width / 2 - source_size.width / 2
|
|
52
|
+
"margin-left": 0
|
|
53
|
+
|
|
54
|
+
dialog_pos.left = 0 if dialog_pos.left < 0
|
|
55
|
+
dialog_pos.top = 0 if dialog_pos.top < 0
|
|
56
|
+
dialog_pos
|
|
57
|
+
|
|
58
|
+
_preparePopover = (dialog, options) ->
|
|
59
|
+
source_element = options.source_element
|
|
60
|
+
dialog_pos = undefined
|
|
61
|
+
if source_element
|
|
62
|
+
options.placement = options.placement or source_element.data("placement")
|
|
63
|
+
options.animation = options.animation or source_element.data("animation")
|
|
64
|
+
else
|
|
65
|
+
console.warn "WTF! you must set a source_element"
|
|
66
|
+
return
|
|
67
|
+
options.placement = options.placement or CLASS.RIGHT
|
|
68
|
+
dialog.addClass CLASS.FADE_IN if options.animation
|
|
69
|
+
dialog.removeClass()
|
|
70
|
+
dialog_pos = _getPositionFromSource(_getPosition(source_element), dialog[0].offsetWidth, dialog[0].offsetHeight, options.placement)
|
|
71
|
+
dialog.css(dialog_pos).addClass options.placement
|
|
72
|
+
|
|
73
|
+
_prepareAlert = (dialog, options) ->
|
|
74
|
+
set_alert_position = ->
|
|
75
|
+
dialog_pos = _getPositionCenterOnScreen(_getPosition(dialog))
|
|
76
|
+
dialog.css dialog_pos
|
|
77
|
+
|
|
78
|
+
set_alert_position()
|
|
79
|
+
cool.dom(window).on "resize", ->
|
|
80
|
+
set_alert_position()
|
|
81
|
+
|
|
82
|
+
_prepareModal = (dialog, options) ->
|
|
83
|
+
|
|
84
|
+
_prepareAction = (dialog, options) ->
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
###
|
|
89
|
+
* Show dialog
|
|
90
|
+
*
|
|
91
|
+
* @method show
|
|
92
|
+
###
|
|
93
|
+
show = (dialog_id, options) ->
|
|
94
|
+
dialog = cool.dom(ELEMENT.DIALOG + dialog_id)
|
|
95
|
+
dialog_type = dialog.data("type")
|
|
96
|
+
options = options or {}
|
|
97
|
+
switch dialog_type
|
|
98
|
+
when DIALOG.MODAL
|
|
99
|
+
_prepareModal dialog, options
|
|
100
|
+
when DIALOG.ALERT
|
|
101
|
+
_prepareAlert dialog, options
|
|
102
|
+
when DIALOG.ACTION
|
|
103
|
+
_prepareAction dialog, options
|
|
104
|
+
when DIALOG.POPOVER
|
|
105
|
+
_preparePopover dialog, options
|
|
106
|
+
dialog.removeClass(CLASS.HIDE).addClass(CLASS.CURRENT).addClass CLASS.SHOW
|
|
107
|
+
|
|
108
|
+
###
|
|
109
|
+
* Close dialog
|
|
110
|
+
*
|
|
111
|
+
* @method show
|
|
112
|
+
###
|
|
113
|
+
close = (dialog_id) ->
|
|
114
|
+
dialog = cool.dom(ELEMENT.DIALOG + dialog_id)
|
|
115
|
+
dialog_type = dialog.data("type")
|
|
116
|
+
dialog_animation = dialog.data("transition")
|
|
117
|
+
dialog_animation = dialog_animation or "slideUp" if dialog_type is DIALOG.ACTION
|
|
118
|
+
dialog_animation = dialog_animation or "bounceOut" if dialog_type is DIALOG.MODAL
|
|
119
|
+
dialog.removeClass(CLASS.SHOW).addClass CLASS.HIDE
|
|
120
|
+
unless dialog_animation
|
|
121
|
+
dialog.removeClass CLASS.CURRENT
|
|
122
|
+
else
|
|
123
|
+
setTimeout (->
|
|
124
|
+
dialog.removeClass CLASS.CURRENT
|
|
125
|
+
), TRANSITION.DURATION
|
|
126
|
+
|
|
127
|
+
show: show
|
|
128
|
+
close: close
|
|
129
|
+
)(COOLSTRAP)
|