in_place_edit_with_datepicker 0.0.1

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.
@@ -0,0 +1,10 @@
1
+ require 'rails/railtie'
2
+ require 'action_view/base'
3
+
4
+ module BestInPlace
5
+ class Railtie < ::Rails::Railtie #:nodoc:
6
+ config.after_initialize do
7
+ BestInPlace::ViewHelpers = ActionView::Base.new
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,61 @@
1
+ module BestInPlace
2
+ module TestHelpers
3
+ include ActionView::Helpers::JavaScriptHelper
4
+
5
+ def bip_area(model, attr, new_value)
6
+ id = BestInPlace::Utils.build_best_in_place_id model, attr
7
+ find("##{id}").trigger('click')
8
+ execute_script <<-JS
9
+ $("##{id} form textarea").val('#{escape_javascript new_value.to_s}');
10
+ $("##{id} form textarea").blur();
11
+ JS
12
+ wait_for_ajax
13
+ end
14
+
15
+ def bip_text(model, attr, new_value)
16
+ id = BestInPlace::Utils.build_best_in_place_id model, attr
17
+ find("##{id}").click
18
+ execute_script <<-JS
19
+ $("##{id} input[name='#{attr}']").val('#{escape_javascript new_value.to_s}');
20
+ $("##{id} form").submit();
21
+ JS
22
+ wait_for_ajax
23
+ end
24
+
25
+ def bip_bool(model, attr)
26
+ id = BestInPlace::Utils.build_best_in_place_id model, attr
27
+ find("##{id}").trigger('click')
28
+ wait_for_ajax
29
+ end
30
+
31
+ def bip_select(model, attr, name)
32
+ id = BestInPlace::Utils.build_best_in_place_id model, attr
33
+ find("##{id}").trigger('click')
34
+ find("##{id}").select(name)
35
+ wait_for_ajax
36
+ end
37
+
38
+ def wait_for_ajax
39
+ return unless respond_to?(:evaluate_script)
40
+ wait_until { finished_all_ajax_requests? }
41
+ end
42
+
43
+ def finished_all_ajax_requests?
44
+ evaluate_script('!window.jQuery') || evaluate_script('jQuery.active').zero?
45
+ end
46
+
47
+ def wait_until(max_execution_time_in_seconds = Capybara.default_wait_time)
48
+ Timeout.timeout(max_execution_time_in_seconds) do
49
+ loop do
50
+ if yield
51
+ return true
52
+ else
53
+ sleep(0.2)
54
+ next
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,29 @@
1
+ module BestInPlace
2
+ module Utils #:nodoc:
3
+ module_function
4
+ def build_best_in_place_id(object, field)
5
+ case object
6
+ when Symbol, String
7
+ "best_in_place_#{object}_#{field}"
8
+ else
9
+ id = "best_in_place_#{object_to_key(object)}"
10
+ id << "_#{object.id}" if object.persisted?
11
+ id << "_#{field}"
12
+ id
13
+ end
14
+ end
15
+
16
+ def object_to_key(object)
17
+ model_name_from_record_or_class(object).param_key
18
+ end
19
+
20
+ def convert_to_model(object)
21
+ object.respond_to?(:to_model) ? object.to_model : object
22
+ end
23
+
24
+ def model_name_from_record_or_class(record_or_class)
25
+ (record_or_class.is_a?(Class) ? record_or_class : convert_to_model(record_or_class).class).model_name
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module BestInPlace
2
+ VERSION = '3.0.3'
3
+ end
@@ -0,0 +1,7 @@
1
+ require "in_place_edit_with_datepicker/version"
2
+
3
+ require 'best_in_place'
4
+
5
+ module InPlaceEditWithDatepicker
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ module InPlaceEditWithDatepicker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,272 @@
1
+ /*!
2
+ Autosize v1.18.9 - 2014-05-27
3
+ Automatically adjust textarea height based on user input.
4
+ (c) 2014 Jack Moore - http://www.jacklmoore.com/autosize
5
+ license: http://www.opensource.org/licenses/mit-license.php
6
+ */
7
+ (function ($) {
8
+ 'use strict';
9
+ var defaults = {
10
+ className: 'autosizejs',
11
+ id: 'autosizejs',
12
+ append: '\n',
13
+ callback: false,
14
+ resizeDelay: 10,
15
+ placeholder: true
16
+ },
17
+
18
+ // border:0 is unnecessary, but avoids a bug in Firefox on OSX
19
+ copy = '<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',
20
+
21
+ // line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
22
+ typographyStyles = [
23
+ 'fontFamily',
24
+ 'fontSize',
25
+ 'fontWeight',
26
+ 'fontStyle',
27
+ 'letterSpacing',
28
+ 'textTransform',
29
+ 'wordSpacing',
30
+ 'textIndent'
31
+ ],
32
+
33
+ // to keep track which textarea is being mirrored when adjust() is called.
34
+ mirrored,
35
+
36
+ // the mirror element, which is used to calculate what size the mirrored element should be.
37
+ mirror = $(copy).data('autosize', true)[0];
38
+
39
+ // test that line-height can be accurately copied.
40
+ mirror.style.lineHeight = '99px';
41
+ if ($(mirror).css('lineHeight') === '99px') {
42
+ typographyStyles.push('lineHeight');
43
+ }
44
+ mirror.style.lineHeight = '';
45
+
46
+ $.fn.autosize = function (options) {
47
+ if (!this.length) {
48
+ return this;
49
+ }
50
+
51
+ options = $.extend({}, defaults, options || {});
52
+
53
+ if (mirror.parentNode !== document.body) {
54
+ $(document.body).append(mirror);
55
+ }
56
+
57
+ return this.each(function () {
58
+ var
59
+ ta = this,
60
+ $ta = $(ta),
61
+ maxHeight,
62
+ minHeight,
63
+ boxOffset = 0,
64
+ callback = $.isFunction(options.callback),
65
+ originalStyles = {
66
+ height: ta.style.height,
67
+ overflow: ta.style.overflow,
68
+ overflowY: ta.style.overflowY,
69
+ wordWrap: ta.style.wordWrap,
70
+ resize: ta.style.resize
71
+ },
72
+ timeout,
73
+ width = $ta.width(),
74
+ taResize = $ta.css('resize');
75
+
76
+ if ($ta.data('autosize')) {
77
+ // exit if autosize has already been applied, or if the textarea is the mirror element.
78
+ return;
79
+ }
80
+ $ta.data('autosize', true);
81
+
82
+ if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
83
+ boxOffset = $ta.outerHeight() - $ta.height();
84
+ }
85
+
86
+ // IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
87
+ minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
88
+
89
+ $ta.css({
90
+ overflow: 'hidden',
91
+ overflowY: 'hidden',
92
+ wordWrap: 'break-word' // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
93
+ });
94
+
95
+ if (taResize === 'vertical') {
96
+ $ta.css('resize','none');
97
+ } else if (taResize === 'both') {
98
+ $ta.css('resize', 'horizontal');
99
+ }
100
+
101
+ // The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
102
+ // window.getComputedStyle, getBoundingClientRect returning a width are unsupported, but also unneeded in IE8 and lower.
103
+ function setWidth() {
104
+ var width;
105
+ var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false;
106
+
107
+ if (style) {
108
+
109
+ width = ta.getBoundingClientRect().width;
110
+
111
+ if (width === 0 || typeof width !== 'number') {
112
+ width = parseInt(style.width,10);
113
+ }
114
+
115
+ $.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
116
+ width -= parseInt(style[val],10);
117
+ });
118
+ } else {
119
+ width = $ta.width();
120
+ }
121
+
122
+ mirror.style.width = Math.max(width,0) + 'px';
123
+ }
124
+
125
+ function initMirror() {
126
+ var styles = {};
127
+
128
+ mirrored = ta;
129
+ mirror.className = options.className;
130
+ mirror.id = options.id;
131
+ maxHeight = parseInt($ta.css('maxHeight'), 10);
132
+
133
+ // mirror is a duplicate textarea located off-screen that
134
+ // is automatically updated to contain the same text as the
135
+ // original textarea. mirror always has a height of 0.
136
+ // This gives a cross-browser supported way getting the actual
137
+ // height of the text, through the scrollTop property.
138
+ $.each(typographyStyles, function(i,val){
139
+ styles[val] = $ta.css(val);
140
+ });
141
+
142
+ $(mirror).css(styles).attr('wrap', $ta.attr('wrap'));
143
+
144
+ setWidth();
145
+
146
+ // Chrome-specific fix:
147
+ // When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
148
+ // made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
149
+ if (window.chrome) {
150
+ var width = ta.style.width;
151
+ ta.style.width = '0px';
152
+ var ignore = ta.offsetWidth;
153
+ ta.style.width = width;
154
+ }
155
+ }
156
+
157
+ // Using mainly bare JS in this function because it is going
158
+ // to fire very often while typing, and needs to very efficient.
159
+ function adjust() {
160
+ var height, original;
161
+
162
+ if (mirrored !== ta) {
163
+ initMirror();
164
+ } else {
165
+ setWidth();
166
+ }
167
+
168
+ if (!ta.value && options.placeholder) {
169
+ // If the textarea is empty, copy the placeholder text into
170
+ // the mirror control and use that for sizing so that we
171
+ // don't end up with placeholder getting trimmed.
172
+ mirror.value = ($ta.attr("placeholder") || '') + options.append;
173
+ } else {
174
+ mirror.value = ta.value + options.append;
175
+ }
176
+
177
+ mirror.style.overflowY = ta.style.overflowY;
178
+ original = parseInt(ta.style.height,10);
179
+
180
+ // Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
181
+ mirror.scrollTop = 0;
182
+
183
+ mirror.scrollTop = 9e4;
184
+
185
+ // Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
186
+ height = mirror.scrollTop;
187
+
188
+ if (maxHeight && height > maxHeight) {
189
+ ta.style.overflowY = 'scroll';
190
+ height = maxHeight;
191
+ } else {
192
+ ta.style.overflowY = 'hidden';
193
+ if (height < minHeight) {
194
+ height = minHeight;
195
+ }
196
+ }
197
+
198
+ height += boxOffset;
199
+
200
+ if (original !== height) {
201
+ ta.style.height = height + 'px';
202
+ if (callback) {
203
+ options.callback.call(ta,ta);
204
+ }
205
+ }
206
+ }
207
+
208
+ function resize () {
209
+ clearTimeout(timeout);
210
+ timeout = setTimeout(function(){
211
+ var newWidth = $ta.width();
212
+
213
+ if (newWidth !== width) {
214
+ width = newWidth;
215
+ adjust();
216
+ }
217
+ }, parseInt(options.resizeDelay,10));
218
+ }
219
+
220
+ if ('onpropertychange' in ta) {
221
+ if ('oninput' in ta) {
222
+ // Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
223
+ // so binding to onkeyup to catch most of those occasions. There is no way that I
224
+ // know of to detect something like 'cut' in IE9.
225
+ $ta.on('input.autosize keyup.autosize', adjust);
226
+ } else {
227
+ // IE7 / IE8
228
+ $ta.on('propertychange.autosize', function(){
229
+ if(event.propertyName === 'value'){
230
+ adjust();
231
+ }
232
+ });
233
+ }
234
+ } else {
235
+ // Modern Browsers
236
+ $ta.on('input.autosize', adjust);
237
+ }
238
+
239
+ // Set options.resizeDelay to false if using fixed-width textarea elements.
240
+ // Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
241
+
242
+ if (options.resizeDelay !== false) {
243
+ $(window).on('resize.autosize', resize);
244
+ }
245
+
246
+ // Event for manual triggering if needed.
247
+ // Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
248
+ $ta.on('autosize.resize', adjust);
249
+
250
+ // Event for manual triggering that also forces the styles to update as well.
251
+ // Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
252
+ $ta.on('autosize.resizeIncludeStyle', function() {
253
+ mirrored = null;
254
+ adjust();
255
+ });
256
+
257
+ $ta.on('autosize.destroy', function(){
258
+ mirrored = null;
259
+ clearTimeout(timeout);
260
+ $(window).off('resize', resize);
261
+ $ta
262
+ .off('autosize')
263
+ .off('.autosize')
264
+ .css(originalStyles)
265
+ .removeData('autosize');
266
+ });
267
+
268
+ // Call adjust in case the textarea already contains text.
269
+ adjust();
270
+ });
271
+ };
272
+ }(window.jQuery || window.$)); // jQuery or jQuery-like library, such as Zepto
@@ -0,0 +1,135 @@
1
+ /**
2
+ * jquery.purr.js
3
+ * Copyright (c) 2008 Net Perspective (net-perspective.com)
4
+ * Licensed under the MIT License (http://www.opensource.org/licenses/mit-license.php)
5
+ *
6
+ * @author R.A. Ray
7
+ * @projectDescription jQuery plugin for dynamically displaying unobtrusive messages in the browser. Mimics the behavior of the MacOS program "Growl."
8
+ * @version 0.1.0
9
+ *
10
+ * @requires jquery.js (tested with 1.2.6)
11
+ *
12
+ * @param fadeInSpeed int - Duration of fade in animation in miliseconds
13
+ * default: 500
14
+ * @param fadeOutSpeed int - Duration of fade out animationin miliseconds
15
+ default: 500
16
+ * @param removeTimer int - Timeout, in miliseconds, before notice is removed once it is the top non-sticky notice in the list
17
+ default: 4000
18
+ * @param isSticky bool - Whether the notice should fade out on its own or wait to be manually closed
19
+ default: false
20
+ * @param usingTransparentPNG bool - Whether or not the notice is using transparent .png images in its styling
21
+ default: false
22
+ */
23
+
24
+ (function(jQuery) {
25
+
26
+ jQuery.purr = function(notice, options)
27
+ {
28
+ // Convert notice to a jQuery object
29
+ notice = jQuery(notice);
30
+
31
+ // Add a class to denote the notice as not sticky
32
+ notice.addClass('purr');
33
+
34
+ // Get the container element from the page
35
+ var cont = document.getElementById('purr-container');
36
+
37
+ // If the container doesn't yet exist, we need to create it
38
+ if (!cont)
39
+ {
40
+ cont = '<div id="purr-container"></div>';
41
+ }
42
+
43
+ // Convert cont to a jQuery object
44
+ cont = jQuery(cont);
45
+
46
+ // Add the container to the page
47
+ jQuery('body').append(cont);
48
+
49
+ notify();
50
+
51
+ function notify ()
52
+ {
53
+ // Set up the close button
54
+ var close = document.createElement('a');
55
+ jQuery(close).attr({
56
+ class: 'close',
57
+ href: '#close'
58
+ }).appendTo(notice).click(function() {
59
+ removeNotice();
60
+ return false;
61
+ });
62
+
63
+ // If ESC is pressed remove notice
64
+ jQuery(document).keyup(function(e) {
65
+ if (e.keyCode === 27) {
66
+ removeNotice();
67
+ }
68
+ });
69
+
70
+ // Add the notice to the page and keep it hidden initially
71
+ notice.appendTo(cont).hide();
72
+
73
+ //Fade in the notice we just added
74
+ notice.fadeIn(options.fadeInSpeed);
75
+
76
+ // Set up the removal interval for the added notice if that notice is not a sticky
77
+ if (!options.isSticky)
78
+ {
79
+ var topSpotInt = setInterval(function() {
80
+ // Check to see if our notice is the first non-sticky notice in the list
81
+ if (notice.prevAll('.purr').length === 0)
82
+ {
83
+ // Stop checking once the condition is met
84
+ clearInterval(topSpotInt);
85
+
86
+ // Call the close action after the timeout set in options
87
+ setTimeout(function() {
88
+ removeNotice();
89
+ }, options.removeTimer);
90
+ }
91
+ }, 200);
92
+ }
93
+ }
94
+
95
+ function removeNotice()
96
+ {
97
+ // Fade the object out before reducing its height to produce the sliding effect
98
+ notice.animate({ opacity: '0' },
99
+ {
100
+ duration: options.fadeOutSpeed,
101
+ complete: function ()
102
+ {
103
+ notice.animate({ height: '0px' },
104
+ {
105
+ duration: options.fadeOutSpeed,
106
+ complete: function()
107
+ {
108
+ notice.remove();
109
+ }
110
+ }
111
+ );
112
+ }
113
+ }
114
+ );
115
+ };
116
+ };
117
+
118
+ jQuery.fn.purr = function(options)
119
+ {
120
+ options = options || {};
121
+ options.fadeInSpeed = options.fadeInSpeed || 500;
122
+ options.fadeOutSpeed = options.fadeOutSpeed || 500;
123
+ options.removeTimer = options.removeTimer || 4000;
124
+ options.isSticky = options.isSticky || false;
125
+ options.usingTransparentPNG = options.usingTransparentPNG || false;
126
+
127
+ this.each(function()
128
+ {
129
+ new jQuery.purr( this, options );
130
+ }
131
+ );
132
+
133
+ return this;
134
+ };
135
+ })( jQuery );