quick_script 0.0.47

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+
6
+ *.swp
7
+ *.swo
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in quick_script.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,147 @@
1
+ @import mixins
2
+
3
+ .p-rel
4
+ +p-rel
5
+
6
+ .img-shadow-dark
7
+ +img-shadow-dark
8
+
9
+ body
10
+ .mceContentBody
11
+ font-size: 20px
12
+
13
+ h1
14
+ +t-shadow
15
+ +t-center
16
+ +bold
17
+ margin-top: 0px
18
+ h2
19
+ +t-shadow
20
+
21
+ hr
22
+ +colruler
23
+
24
+ .field
25
+ +p-rel
26
+ +inline
27
+ input, textarea
28
+ +animate
29
+ +box-shadow(0 1px 1px rgba(0,0,0,0.2) inset)
30
+ outline: none
31
+ label
32
+ +animate
33
+ +p-abs
34
+ +no-select
35
+ top: 20px
36
+ left: 10px
37
+ z-index: 20
38
+ color: #D7D7D7
39
+ input:focus + label, textarea:focus + label
40
+ opacity: 0.5
41
+ input:focus, textarea:focus
42
+ +box-shadow(0 1px 1px rgba(0,0,0,0.2) inset,0 0 6px #8ed928)
43
+
44
+
45
+ .container
46
+ +clear-border
47
+ .colborder
48
+ +colborder
49
+
50
+ .backdrop
51
+ +animate(0.5s)
52
+ position: fixed
53
+ width: 100%
54
+ height: 100%
55
+ background-color: rgba(0,0,0,.4)
56
+ top: 0px
57
+ left: 0px
58
+ z-index: 10
59
+
60
+ .overlay
61
+ +animate(0.5s)
62
+ +p-fix
63
+ width: 800px
64
+ top: 50px
65
+ left: 50%
66
+ margin: 0px -400px
67
+
68
+ .content
69
+ +clear-border(0.1)
70
+ +bfg-grad($white, #000, 20)
71
+ +p-rel
72
+ +border-radius
73
+ padding: 10px
74
+ overflow: auto
75
+
76
+ .header
77
+ +bfg-grad($blue, $white, 10)
78
+ +t-shadow-dark
79
+ +bold
80
+ +t-4
81
+ +padded
82
+ +t-center
83
+ +border-radius
84
+ margin-bottom: 10px
85
+
86
+ .notify
87
+ +padded
88
+ +p-fix
89
+ +img-shadow
90
+ +t-4
91
+ +t-center
92
+ +t-shadow-dark
93
+ width: 500px
94
+ top: 0px
95
+ left: 50%
96
+ margin-left: -265px
97
+ z-index: 10000
98
+ background: $green
99
+ color: white
100
+ border-left: 2px solid $white
101
+ border-right: 2px solid $white
102
+ border-bottom: 2px solid $white
103
+ font-weight: bold
104
+ opacity: 0.9
105
+
106
+ .loading-overlay
107
+ +p-abs
108
+ +border-radius
109
+ +img-shadow
110
+ background-color: rgba(0,0,0,.4)
111
+ z-index: 10
112
+ top: 0px
113
+ bottom: 0px
114
+ left: 0px
115
+ right: 0px
116
+
117
+ span
118
+ +p-abs
119
+ +border-radius
120
+ +padded
121
+ +clear-border(0.1)
122
+ text-transform: uppercase
123
+ letter-spacing: 3px
124
+ display: block
125
+ height: 30px
126
+ top: 50%
127
+ left: 50%
128
+ margin: -25px -100px
129
+ color: #FFF
130
+ text-align: center
131
+ font-size: 20px
132
+ font-weight: bold
133
+ width: 200px
134
+ background-color: rgba(255, 255, 255, .2)
135
+
136
+ .section-header
137
+ +t-0
138
+ +f-ga
139
+ +t-center
140
+ +t-upper
141
+ +ls(2px)
142
+ +bfg($red, $white)
143
+ +img-shadow-dark
144
+ &.title
145
+ +bold
146
+ font-size: 20px
147
+
@@ -0,0 +1,137 @@
1
+ /* http://www.webdesignerwall.com/demo/css-buttons.html */
2
+ /* button
3
+ ---------------------------------------------- */
4
+ .button {
5
+ display: inline-block;
6
+ zoom: 1; /* zoom and *display = ie7 hack for display:inline-block */
7
+ *display: inline;
8
+ vertical-align: baseline;
9
+ margin: 0 2px;
10
+ outline: none;
11
+ cursor: pointer;
12
+ text-align: center;
13
+ text-decoration: none;
14
+ font: 14px/100% Arial, Helvetica, sans-serif;
15
+ font-weight: bold;
16
+ padding: .5em 2em .55em;
17
+ text-shadow: 0 1px 1px rgba(0,0,0,.3);
18
+ -webkit-border-radius: .5em;
19
+ -moz-border-radius: .5em;
20
+ border-radius: .5em;
21
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.2);
22
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.2);
23
+ box-shadow: 0 1px 2px rgba(0,0,0,.2);
24
+ }
25
+ .button:hover {
26
+ text-decoration: none;
27
+ }
28
+ .button:active {
29
+ position: relative;
30
+ top: 1px;
31
+ }
32
+
33
+ .button.bigrounded {
34
+ -webkit-border-radius: 2em;
35
+ -moz-border-radius: 2em;
36
+ border-radius: 2em;
37
+ }
38
+ .button.medium {
39
+ font-size: 12px;
40
+ padding: .4em 1.5em .42em;
41
+ }
42
+ .button.small {
43
+ font-size: 11px;
44
+ padding: .2em 1em .275em;
45
+ }
46
+
47
+ /* color styles
48
+ ---------------------------------------------- */
49
+
50
+ /* white */
51
+ .button.white {
52
+ color: #606060;
53
+ border: solid 1px #b7b7b7;
54
+ background: #fff;
55
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#ededed));
56
+ background: -moz-linear-gradient(top, #fff, #ededed);
57
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#ededed');
58
+ }
59
+ .button.white:hover {
60
+ background: #ededed;
61
+ background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#dcdcdc));
62
+ background: -moz-linear-gradient(top, #fff, #dcdcdc);
63
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#dcdcdc');
64
+ }
65
+ .button.white:active {
66
+ color: #999;
67
+ background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#fff));
68
+ background: -moz-linear-gradient(top, #ededed, #fff);
69
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#ffffff');
70
+ }
71
+
72
+ /* red */
73
+ .button.red {
74
+ color: #faddde;
75
+ border: solid 1px #980c10;
76
+ background: #d81b21;
77
+ background: -webkit-gradient(linear, left top, left bottom, from(#ed1c24), to(#aa1317));
78
+ background: -moz-linear-gradient(top, #ed1c24, #aa1317);
79
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ed1c24', endColorstr='#aa1317');
80
+ }
81
+ .button.red:hover {
82
+ background: #b61318;
83
+ background: -webkit-gradient(linear, left top, left bottom, from(#c9151b), to(#a11115));
84
+ background: -moz-linear-gradient(top, #c9151b, #a11115);
85
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#c9151b', endColorstr='#a11115');
86
+ }
87
+ .button.red:active {
88
+ color: #de898c;
89
+ background: -webkit-gradient(linear, left top, left bottom, from(#aa1317), to(#ed1c24));
90
+ background: -moz-linear-gradient(top, #aa1317, #ed1c24);
91
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#aa1317', endColorstr='#ed1c24');
92
+ }
93
+
94
+ /* blue */
95
+ .button.blue {
96
+ color: #d9eef7;
97
+ border: solid 1px #0076a3;
98
+ background: #0095cd;
99
+ background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
100
+ background: -moz-linear-gradient(top, #00adee, #0078a5);
101
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
102
+ }
103
+ .button.blue:hover {
104
+ background: #007ead;
105
+ background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
106
+ background: -moz-linear-gradient(top, #0095cc, #00678e);
107
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
108
+ }
109
+ .button.blue:active {
110
+ color: #80bed6;
111
+ background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
112
+ background: -moz-linear-gradient(top, #0078a5, #00adee);
113
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
114
+ }
115
+
116
+ /* green */
117
+ .button.green {
118
+ color: #e8f0de;
119
+ border: solid 1px #538312;
120
+ background: #64991e;
121
+ background: -webkit-gradient(linear, left top, left bottom, from(#7db72f), to(#4e7d0e));
122
+ background: -moz-linear-gradient(top, #7db72f, #4e7d0e);
123
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#7db72f', endColorstr='#4e7d0e');
124
+ }
125
+ .button.green:hover {
126
+ background: #538018;
127
+ background: -webkit-gradient(linear, left top, left bottom, from(#6b9d28), to(#436b0c));
128
+ background: -moz-linear-gradient(top, #6b9d28, #436b0c);
129
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6b9d28', endColorstr='#436b0c');
130
+ }
131
+ .button.green:active {
132
+ color: #a9c08c;
133
+ background: -webkit-gradient(linear, left top, left bottom, from(#4e7d0e), to(#7db72f));
134
+ background: -moz-linear-gradient(top, #4e7d0e, #7db72f);
135
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#4e7d0e', endColorstr='#7db72f');
136
+ }
137
+
@@ -0,0 +1,78 @@
1
+ @import blueprint
2
+ @import compass
3
+
4
+ $blue: #06C
5
+ $white: #FFF
6
+ $red: #C60
7
+ $green: #6C0
8
+ $black: #000
9
+ $dark-gray: rgba(0,0,0,.75)
10
+
11
+ =bold
12
+ font-weight: bold
13
+ =t-4
14
+ font-size: 30px
15
+ .t-4
16
+ +t-4
17
+ =t-3
18
+ font-size: 20px
19
+ .t-3
20
+ +t-3
21
+ =t-2
22
+ font-size: 18px
23
+ =t-1
24
+ font-size: 14px
25
+ .t-1
26
+ +t-1
27
+ =t-0
28
+ font-size: 12px
29
+ =t-upper
30
+ text-transform: uppercase
31
+ .t-upper
32
+ +t-upper
33
+ =t-center
34
+ text-align: center
35
+ =f-ga
36
+ font-family: 'Georgia'
37
+ =bfg($bg, $fg)
38
+ background-color: $bg
39
+ color: $fg
40
+ =mb($val)
41
+ margin-bottom: $val
42
+ =ls($val)
43
+ letter-spacing: $val
44
+ =inline
45
+ display: inline-block
46
+ =padded
47
+ padding: 10px
48
+ =pad-lr
49
+ padding: 0px 10px
50
+ =p-rel
51
+ position: relative
52
+ =p-abs
53
+ position: absolute
54
+ =p-fix
55
+ position: fixed
56
+ =t-shadow
57
+ text-shadow: 0px 1px 1px #AAA
58
+ =t-shadow-dark
59
+ text-shadow: 0px 1px 1px #444
60
+ =clear-border($color: 0.5)
61
+ +box-shadow(0 0 0 5px rgba(0,0,0,$color),0 0 0 1px rgba(0,0,0,($color + 0.1)))
62
+ =img-shadow($op:.3)
63
+ +box-shadow(0px 0px 8px 1px rgba(0, 0, 0, $op))
64
+ =img-shadow-dark
65
+ +box-shadow(0px 0px 8px 1px rgba(0,0,0,.7))
66
+ =box-shadow-1
67
+ +box-shadow(0px 1px 3px rgba(34, 25, 25, 0.4))
68
+ =bfg-grad($bg, $fg, $dark)
69
+ +background-image(linear-gradient($bg, $bg, darken($bg, $dark)))
70
+ color: $fg
71
+ =animate($time : 0.16s)
72
+ -moz-transition: all $time ease-in-out
73
+ -webkit-transition: all $time ease-in-out
74
+ =no-select
75
+ -webkit-user-select: none
76
+ -moz-user-select: none
77
+ pointer-events: none
78
+
@@ -0,0 +1,4 @@
1
+ /* QS_VERSION=0.0.47;
2
+ *= require ./basics
3
+ *= require ./buttons
4
+ */
@@ -0,0 +1,226 @@
1
+ ## EXTENSIONS
2
+ Array.prototype.indexAt = (val) ->
3
+ for i in [0...this.length]
4
+ if this[i] == val
5
+ return i
6
+ return -1
7
+ Array.prototype.includes = (val) ->
8
+ return this.indexAt(val) != -1
9
+ Array.prototype.pushOnce = (item) ->
10
+ if (!this.includes(item))
11
+ this.push(item)
12
+ Date.from_utc = (utc) ->
13
+ new Date(utc * 1000)
14
+ String.prototype.endsWith = (suffix) ->
15
+ this.indexOf(suffix, this.length - suffix.length) != -1
16
+ String.prototype.includes = (str) ->
17
+ this.indexOf(str) != -1
18
+
19
+ class @SelectOpts
20
+ constructor : ->
21
+ @options = []
22
+ add : (val, str)->
23
+ @options.push {val : val, str : str}
24
+ return this
25
+ find : (val)->
26
+ for obj in @options
27
+ return obj.str if obj.val == val
28
+ return ""
29
+
30
+ ## PAGETIMER
31
+ class @PageTimer
32
+ constructor: (func, time) ->
33
+ @callback = func
34
+ @frequency = time * 1000
35
+ @t_id = -1
36
+ start : =>
37
+ @t_id = setInterval(@callback, @frequency)
38
+ stop : =>
39
+ clearInterval(@t_id)
40
+ setFrequency : (time) =>
41
+ @stop()
42
+ @frequency = time * 1000
43
+ @start()
44
+ getFrequency : =>
45
+ return @frequency / 1000
46
+ increasePollTime : =>
47
+ @setFrequency( @getFrequency() + (if @getFrequency() % 5 == 0 then 9 else 1) )
48
+
49
+ ## NOTIFIER
50
+ class @Notifier
51
+ constructor: ->
52
+ @popup = null
53
+ @tid = null
54
+ @nids = []
55
+ hasSupport : ->
56
+ if (window.webkitNotifications)
57
+ return true
58
+ else
59
+ return false
60
+ hasPermission : ->
61
+ return (window.webkitNotifications.checkPermission() == 0)
62
+ requestPermission : (cb) ->
63
+ window.webkitNotifications.requestPermission ->
64
+ cb(window.webkitNotifications.checkPermission() == 0) if (cb)
65
+ notify : (icon, title, body, opts) ->
66
+ if (@hasSupport() && @hasPermission() && !@isActive())
67
+ opts = {} if !opts?
68
+ stay = opts["stay"]
69
+ delay = opts["delay"]
70
+ nid = opts["nid"]
71
+ if (nid?)
72
+ if (@nids.includes(nid))
73
+ return false
74
+ else
75
+ @nids.pushOnce(nid)
76
+ @popup = window.webkitNotifications.createNotification(icon, title, body)
77
+ if (!stay? || !stay)
78
+ @popup.ondisplay = ->
79
+ setTimeout('notifier.Hide()', 5000)
80
+
81
+ if (delay?)
82
+ @tid = setTimeout('notifier.popup.show()', delay * 1000)
83
+ else
84
+ @popup.show()
85
+ return true
86
+
87
+ return false
88
+
89
+ hide : ->
90
+ if (@popup != null)
91
+ @popup.cancel()
92
+ @popup = null
93
+ if (@tid != null)
94
+ clearTimeout(@tid)
95
+ @tid = null
96
+ isActive : ->
97
+ if (@popup != null)
98
+ return true
99
+ else
100
+ return false
101
+
102
+ ## OVERLAY
103
+ class @Overlay
104
+ constructor : ->
105
+ @zindex = 100
106
+ @notifyTimer = null
107
+ closeDialog : =>
108
+ @remove('dialog')
109
+ add : (vm, tmp, options, cls) =>
110
+ id = vm.name
111
+ template = tmp
112
+ cls = cls || ''
113
+ options = {} if !options?
114
+ options['z-index'] = @zindex + 10
115
+ $('body').prepend("<div class='backdrop' id='backdrop-#{id}' style='z-index: #{(@zindex + 9)}'></div><div id='overlay-" + id + "' class='overlay'><div class='content' data-bind=\"template: '" + template + "'\"></div></div>")
116
+ $('#overlay-' + id).css(options)
117
+ $('#overlay-' + id).addClass(cls)
118
+ $('#overlay-' + id).css({'margin-left' : -1 * $('#overlay-' + id).width() / 2})
119
+ $('.overlay .content').css({'max-height' : ($(window).height() - 100)})
120
+ $('#backdrop-' + id).click =>
121
+ console.log('backdrop clicked.')
122
+ @remove(id)
123
+ $('#overlay-' + id).koBind(vm)
124
+ @zindex = @zindex + 10
125
+ dialog : (msg, opts) ->
126
+ self = this
127
+ vm =
128
+ name : 'dialog'
129
+ message : ko.observable(msg)
130
+ yes : opts.yes
131
+ no : opts.no
132
+ cancel : self.remove('dialog')
133
+ @add(vm, 'view-dialog', { width : 300 })
134
+ notify : (msg, cls, tm) ->
135
+ cls = cls || ''
136
+ tm = tm || 3000
137
+ @clearNotifications()
138
+ $('body').prepend("<div id='notify' class='notify' style='display: none;'>" + msg + "</div>")
139
+ if (cls)
140
+ $('#notify').addClass(cls)
141
+ $('#notify').slideDown 'slow', ->
142
+ @notifyTimeout = setTimeout ->
143
+ $('#notify').fadeOut('slow')
144
+ , tm
145
+ clearNotifications : ->
146
+ clearTimeout(@notifyTimeout)
147
+ $('#notify').remove()
148
+ remove : (id) ->
149
+ $('#overlay-' + id).koClean()
150
+ $('#overlay-' + id).remove()
151
+ $('#backdrop-' + id).remove()
152
+
153
+ class @TimeLength
154
+ constructor : (@date1, @date2)->
155
+ @date2 = new Date() unless @date2?
156
+ seconds : ->
157
+ Math.floor( ( @date2.getTime() - @date1.getTime() ) / 1000 )
158
+ minutes : ->
159
+ Math.floor( @seconds() / 60 )
160
+ hours : ->
161
+ Math.floor( @seconds() / (60 * 60) )
162
+ days : ->
163
+ Math.floor( @seconds() / (24 * 60 * 60) )
164
+ weeks : ->
165
+ Math.floor( @seconds() / (24 * 60 * 60 * 7) )
166
+ months : ->
167
+ Math.floor( @seconds() / (24 * 60 * 60 * 31) )
168
+ years : ->
169
+ Math.floor( @seconds() / (24 * 60 * 60 * 365) )
170
+ toString : ->
171
+ val = 0
172
+ str = ""
173
+ if @years() > 0
174
+ val = @years()
175
+ str = "year"
176
+ else if @months() > 0
177
+ val = @months()
178
+ str = "month"
179
+ else if @weeks() > 0
180
+ val = @weeks()
181
+ str = "week"
182
+ else if @days() > 0
183
+ val = @days()
184
+ str = "day"
185
+ else if @hours() > 0
186
+ val = @hours()
187
+ str = "hour"
188
+ else if @minutes() > 0
189
+ val = @minutes()
190
+ str = "minute"
191
+ else
192
+ val = @seconds()
193
+ str = "second"
194
+ attr = str + ( if (val > 1) then "s" else "" )
195
+ "#{val} #{attr}"
196
+
197
+ # Helpful functions
198
+ loadScript = (u, d) ->
199
+ d = typeof(d) != 'undefined' ? d : ""
200
+ $.ajax({type: "POST", url: u, data: d, dataType: "script"})
201
+
202
+ timeFromUnix = (tm) ->
203
+ date = new Date(tm * 1000)
204
+ return date.toLocaleTimeString()
205
+
206
+ cropImage = (img_url, img_width, img_height) ->
207
+ return $('<div>').css({
208
+ background: 'url(' + img_url + ')',
209
+ backgroundSize: 'cover',
210
+ 'background-position': 'center',
211
+ backgroundColor: '#FFF',
212
+ width: img_width,
213
+ height: img_height,
214
+ display: 'inline-block'
215
+ })
216
+
217
+ link_to = (text, url) ->
218
+ return $('<a>').attr('href', url).html(text)
219
+ link_to_rel = (text, url) ->
220
+ return $('<a>').attr('href', "#" + url).html(text)
221
+ link_to_span = (text) ->
222
+ return $('<span>').addClass('clickable').html(text)
223
+
224
+ fadeInElement = (elem) ->
225
+ $(elem).hide().fadeIn()
226
+