mix-rails-core 0.23.1 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/app/assets/images/blank.gif +0 -0
  3. data/app/assets/images/jqzoom/advertise.jpg +0 -0
  4. data/app/assets/images/jqzoom/zoomloader.gif +0 -0
  5. data/app/assets/images/loadinfo.net.gif +0 -0
  6. data/app/assets/javascripts/angular-google-maps.js +531 -0
  7. data/app/assets/javascripts/angular-ui.min.js +7 -0
  8. data/app/assets/javascripts/angular.min.js +161 -0
  9. data/app/assets/javascripts/gmaps.js +1909 -0
  10. data/app/assets/javascripts/jquery-gmaps-latlon-picker.js +231 -0
  11. data/app/assets/javascripts/jquery.jqzoom.js +1 -0
  12. data/app/assets/javascripts/jquery.krioImageLoader.js +47 -0
  13. data/app/assets/javascripts/jquery.lazyload.js +227 -0
  14. data/app/assets/javascripts/jquery.maskedinput.js +290 -0
  15. data/app/assets/javascripts/jquery.meio.mask.min.js +1 -0
  16. data/app/assets/javascripts/jquery.ui.addresspicker.js +194 -0
  17. data/app/assets/javascripts/jquery/jquery.jqzoom-core.js +733 -0
  18. data/app/assets/javascripts/multizoom.js +388 -0
  19. data/app/assets/stylesheets/angular-ui.min.css +1 -0
  20. data/app/assets/stylesheets/jquery-gmaps-latlon-picker.css +2 -0
  21. data/app/assets/stylesheets/jquery.jqzoom.css +3 -0
  22. data/app/assets/stylesheets/jquery/jquery.jqzoom.css.erb +120 -0
  23. data/app/assets/stylesheets/multizoom.css +48 -0
  24. data/app/helpers/core_helper.rb +4 -0
  25. data/app/inputs/cell_input.rb +5 -0
  26. data/app/inputs/cep_input.rb +5 -0
  27. data/app/inputs/phone_input.rb +5 -0
  28. data/app/inputs/state_input.rb +5 -0
  29. data/app/models/attachment.rb +4 -1
  30. data/app/models/category.rb +4 -1
  31. data/app/models/ckeditor/asset.rb +7 -0
  32. data/app/models/ckeditor/attachment_file.rb +7 -0
  33. data/app/models/ckeditor/picture.rb +7 -0
  34. data/app/uploaders/ckeditor_attachment_file_uploader.rb +36 -0
  35. data/app/uploaders/ckeditor_picture_uploader.rb +47 -0
  36. data/app/views/admix/categories/_form_config.haml +3 -0
  37. data/config/initializers/ckeditor.rb +21 -0
  38. data/config/initializers/defaults_rails.rb +10 -1
  39. data/config/locales/core.pt-BR.yml +25 -2
  40. data/config/routes.rb +2 -0
  41. data/db/migrate/20130226152256_create_ckeditor_assets.rb +26 -0
  42. data/lib/mix-rails-core.rb +3 -0
  43. data/lib/mix-rails-core/version.rb +2 -2
  44. metadata +73 -120
  45. data/app/assets/javascripts/jquery/jquery.maskedinput-1.3.min.js +0 -7
  46. data/app/models/admix/categories_datagrid.rb +0 -14
  47. data/app/views/admix/categories/_form_fields.haml +0 -1
@@ -0,0 +1,290 @@
1
+ /*
2
+ Masked Input plugin for jQuery
3
+ Copyright (c) 2007-2011 Josh Bush (digitalbush.com)
4
+ Licensed under the MIT license (http://digitalbush.com/projects/masked-input-plugin/#license)
5
+ Version: 1.3
6
+ */
7
+ (function($) {
8
+ var pasteEventName = ($.browser.msie ? 'paste' : 'input') + ".mask";
9
+ var iPhone = (window.orientation != undefined);
10
+
11
+ $.mask = {
12
+ //Predefined character definitions
13
+ definitions: {
14
+ '9': "[0-9]",
15
+ 'a': "[A-Za-z]",
16
+ '*': "[A-Za-z0-9]"
17
+ },
18
+ dataName:"rawMaskFn"
19
+ };
20
+
21
+ $.fn.extend({
22
+ //Helper Function for Caret positioning
23
+ caret: function(begin, end) {
24
+ if (this.length == 0) return;
25
+ if (typeof begin == 'number') {
26
+ end = (typeof end == 'number') ? end : begin;
27
+ return this.each(function() {
28
+ if (this.setSelectionRange) {
29
+ this.setSelectionRange(begin, end);
30
+ } else if (this.createTextRange) {
31
+ var range = this.createTextRange();
32
+ range.collapse(true);
33
+ range.moveEnd('character', end);
34
+ range.moveStart('character', begin);
35
+ range.select();
36
+ }
37
+ });
38
+ } else {
39
+ if (this[0].setSelectionRange) {
40
+ begin = this[0].selectionStart;
41
+ end = this[0].selectionEnd;
42
+ } else if (document.selection && document.selection.createRange) {
43
+ var range = document.selection.createRange();
44
+ begin = 0 - range.duplicate().moveStart('character', -100000);
45
+ end = begin + range.text.length;
46
+ }
47
+ return { begin: begin, end: end };
48
+ }
49
+ },
50
+ unmask: function() { return this.trigger("unmask"); },
51
+ isMaskValid: function(){
52
+ return $(this).data('mask-isvalid');
53
+ },
54
+ mask: function(mask, settings) {
55
+ if (!mask && this.length > 0) {
56
+ var input = $(this[0]);
57
+ return input.data($.mask.dataName)();
58
+ }
59
+ settings = $.extend({
60
+ placeholder: "_",
61
+ completed: null
62
+ }, settings);
63
+
64
+ var defs = $.mask.definitions;
65
+ var tests = [];
66
+ var partialPosition = mask.length;
67
+ var firstNonMaskPos = null;
68
+ var len = mask.length;
69
+
70
+ $.each(mask.split(""), function(i, c) {
71
+ if (c == '?') {
72
+ len--;
73
+ partialPosition = i;
74
+ } else if (defs[c]) {
75
+ tests.push(new RegExp(defs[c]));
76
+ if(firstNonMaskPos==null)
77
+ firstNonMaskPos = tests.length - 1;
78
+ } else {
79
+ tests.push(null);
80
+ }
81
+ });
82
+
83
+ return this.trigger("unmask").each(function() {
84
+ var input = $(this);
85
+ var buffer = $.map(mask.split(""), function(c, i) { if (c != '?') return defs[c] ? settings.placeholder : c });
86
+ var focusText = input.val();
87
+
88
+ function seekNext(pos) {
89
+ while (++pos <= len && !tests[pos]);
90
+ return pos;
91
+ };
92
+ function seekPrev(pos) {
93
+ while (--pos >= 0 && !tests[pos]);
94
+ return pos;
95
+ };
96
+
97
+ function shiftL(begin,end) {
98
+ if(begin<0)
99
+ return;
100
+ for (var i = begin,j = seekNext(end); i < len; i++) {
101
+ if (tests[i]) {
102
+ if (j < len && tests[i].test(buffer[j])) {
103
+ buffer[i] = buffer[j];
104
+ buffer[j] = settings.placeholder;
105
+ } else
106
+ break;
107
+ j = seekNext(j);
108
+ }
109
+ }
110
+ writeBuffer();
111
+ input.caret(Math.max(firstNonMaskPos, begin));
112
+ };
113
+
114
+ function shiftR(pos) {
115
+ for (var i = pos, c = settings.placeholder; i < len; i++) {
116
+ if (tests[i]) {
117
+ var j = seekNext(i);
118
+ var t = buffer[i];
119
+ buffer[i] = c;
120
+ if (j < len && tests[j].test(t))
121
+ c = t;
122
+ else
123
+ break;
124
+ }
125
+ }
126
+ };
127
+
128
+ function keydownEvent(e) {
129
+ var k=e.which;
130
+
131
+ //backspace, delete, and escape get special treatment
132
+ if(k == 8 || k == 46 || (iPhone && k == 127)){
133
+ var pos = input.caret(),
134
+ begin = pos.begin,
135
+ end = pos.end;
136
+
137
+ if(end-begin==0){
138
+ begin=k!=46?seekPrev(begin):(end=seekNext(begin-1));
139
+ end=k==46?seekNext(end):end;
140
+ }
141
+ clearBuffer(begin, end);
142
+ shiftL(begin,end-1);
143
+ isValid(); //twarogowski
144
+
145
+ return false;
146
+ } else if (k == 27) {//escape
147
+ input.val(focusText);
148
+ input.caret(0, checkVal());
149
+ return false;
150
+ }
151
+ };
152
+
153
+ function keypressEvent(e) {
154
+ var k = e.which,
155
+ pos = input.caret();
156
+ if (e.ctrlKey || e.altKey || e.metaKey || k<32) {//Ignore
157
+ return true;
158
+ } else if (k) {
159
+ if(pos.end-pos.begin!=0){
160
+ clearBuffer(pos.begin, pos.end);
161
+ shiftL(pos.begin, pos.end-1);
162
+ isValid(); //twarogowski
163
+ }
164
+
165
+ var p = seekNext(pos.begin - 1);
166
+ if (p < len) {
167
+ var c = String.fromCharCode(k);
168
+ if (tests[p].test(c)) {
169
+ shiftR(p);
170
+ buffer[p] = c;
171
+ writeBuffer();
172
+ var next = seekNext(p);
173
+ input.caret(next);
174
+ isValid(); //twarogowski
175
+ if (settings.completed && next >= len)
176
+ settings.completed.call(input);
177
+ }
178
+ }
179
+ return false;
180
+ }
181
+ };
182
+
183
+ function clearBuffer(start, end) {
184
+ for (var i = start; i < end && i < len; i++) {
185
+ if (tests[i])
186
+ buffer[i] = settings.placeholder;
187
+ }
188
+ };
189
+
190
+ function writeBuffer() { return input.val(buffer.join('')).val(); };
191
+
192
+ function isValid(){
193
+ var test = input.val();
194
+ var lastMatch = -1;
195
+ for (var i = 0, pos = 0; i < len; i++) {
196
+ if (tests[i]) {
197
+ buffer[i] = settings.placeholder;
198
+ while (pos++ < test.length) {
199
+ var c = test.charAt(pos - 1);
200
+ if (tests[i].test(c)) {
201
+ buffer[i] = c;
202
+ lastMatch = i;
203
+ break;
204
+ }
205
+ }
206
+ if (pos > test.length)
207
+ break;
208
+ } else if (buffer[i] == test.charAt(pos) && i!=partialPosition) {
209
+ pos++;
210
+ lastMatch = i;
211
+ }
212
+ }
213
+ var valid = (lastMatch + 1 >= partialPosition);
214
+ input.data('mask-isvalid',valid);
215
+ return valid;
216
+ }
217
+
218
+ function checkVal(allow) {
219
+ //try to place characters where they belong
220
+ var test = input.val();
221
+ var lastMatch = -1;
222
+ for (var i = 0, pos = 0; i < len; i++) {
223
+ if (tests[i]) {
224
+ buffer[i] = settings.placeholder;
225
+ while (pos++ < test.length) {
226
+ var c = test.charAt(pos - 1);
227
+ if (tests[i].test(c)) {
228
+ buffer[i] = c;
229
+ lastMatch = i;
230
+ break;
231
+ }
232
+ }
233
+ if (pos > test.length)
234
+ break;
235
+ } else if (buffer[i] == test.charAt(pos) && i!=partialPosition) {
236
+ pos++;
237
+ lastMatch = i;
238
+ }
239
+ }
240
+ if (!allow && lastMatch + 1 < partialPosition) {
241
+ input.val("");
242
+ clearBuffer(0, len);
243
+ } else if (allow || lastMatch + 1 >= partialPosition) {
244
+ writeBuffer();
245
+ if (!allow) input.val(input.val().substring(0, lastMatch + 1));
246
+ }
247
+ return (partialPosition ? i : firstNonMaskPos);
248
+ };
249
+
250
+ input.data($.mask.dataName,function(){
251
+ return $.map(buffer, function(c, i) {
252
+ return tests[i]&&c!=settings.placeholder ? c : null;
253
+ }).join('');
254
+ })
255
+
256
+ if (!input.attr("readonly"))
257
+ input
258
+ .one("unmask", function() {
259
+ input
260
+ .unbind(".mask")
261
+ .removeData($.mask.dataName);
262
+ })
263
+ .bind("focus.mask", function() {
264
+ focusText = input.val();
265
+ var pos = checkVal();
266
+ writeBuffer();
267
+ var moveCaret=function(){
268
+ if (pos == mask.length)
269
+ input.caret(0, pos);
270
+ else
271
+ input.caret(pos);
272
+ };
273
+ ($.browser.msie ? moveCaret:function(){setTimeout(moveCaret,0)})();
274
+ })
275
+ .bind("blur.mask", function() {
276
+ checkVal();
277
+ if (input.val() != focusText)
278
+ input.change();
279
+ })
280
+ .bind("keydown.mask", keydownEvent)
281
+ .bind("keypress.mask", keypressEvent)
282
+ .bind(pasteEventName, function() {
283
+ setTimeout(function() { input.caret(checkVal(true)); }, 0);
284
+ });
285
+
286
+ checkVal(); //Perform initial check for existing values
287
+ });
288
+ }
289
+ });
290
+ })(jQuery);
@@ -0,0 +1 @@
1
+ (function(D){var C=(window.orientation!=null);var A=((D.browser.opera||(D.browser.mozilla&&parseFloat(D.browser.version.substr(0,3))<1.9))?"input":"paste");var B=function(F){F=D.event.fix(F||window.event);F.type="paste";var E=F.target;setTimeout(function(){D.event.dispatch.call(E,F)},1)};D.event.special.paste={setup:function(){if(this.addEventListener){this.addEventListener(A,B,false)}else{if(this.attachEvent){this.attachEvent("on"+A,B)}}},teardown:function(){if(this.removeEventListener){this.removeEventListener(A,B,false)}else{if(this.detachEvent){this.detachEvent("on"+A,B)}}}};D.extend({mask:{rules:{"z":/[a-z]/,"Z":/[A-Z]/,"a":/[a-zA-Z]/,"*":/[0-9a-zA-Z]/,"@":/[0-9a-zA-ZçÇáàãâéèêíìóòôõúùü]/},keyRepresentation:{8:"backspace",9:"tab",13:"enter",16:"shift",17:"control",18:"alt",27:"esc",33:"page up",34:"page down",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"insert",46:"delete",116:"f5",123:"f12",224:"command"},iphoneKeyRepresentation:{10:"go",127:"delete"},signals:{"+":"","-":"-"},options:{attr:"alt",mask:null,type:"fixed",maxLength:-1,defaultValue:"",signal:false,textAlign:true,selectCharsOnFocus:true,autoTab:true,setSize:false,fixedChars:"[(),.:/ -]",onInvalid:function(){},onValid:function(){},onOverflow:function(){}},masks:{"phone":{mask:"(99) 9999-9999"},"phone-us":{mask:"(999) 999-9999"},"cpf":{mask:"999.999.999-99"},"cnpj":{mask:"99.999.999/9999-99"},"date":{mask:"39/19/9999"},"date-us":{mask:"19/39/9999"},"cep":{mask:"99999-999"},"time":{mask:"29:59"},"cc":{mask:"9999 9999 9999 9999"},"integer":{mask:"999.999.999.999",type:"reverse"},"decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"000"},"decimal-us":{mask:"99.999,999,999,999",type:"reverse",defaultValue:"000"},"signed-decimal":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"},"signed-decimal-us":{mask:"99,999.999.999.999",type:"reverse",defaultValue:"+000"}},init:function(){if(!this.hasInit){var E=this,F,G=(C)?this.iphoneKeyRepresentation:this.keyRepresentation;this.ignore=false;for(F=0;F<=9;F++){this.rules[F]=new RegExp("[0-"+F+"]")}this.keyRep=G;this.ignoreKeys=[];D.each(G,function(H){E.ignoreKeys.push(parseInt(H,10))});this.hasInit=true}},set:function(I,F){var E=this,G=D(I),H="maxLength";F=F||{};this.init();return G.each(function(){if(F.attr){E.options.attr=F.attr}var O=D(this),Q=D.extend({},E.options),N=O.attr(Q.attr),J="";J=(typeof F=="string")?F:(N!=="")?N:null;if(J){Q.mask=J}if(E.masks[J]){Q=D.extend(Q,E.masks[J])}if(typeof F=="object"&&F.constructor!=Array){Q=D.extend(Q,F)}if(D.metadata){Q=D.extend(Q,O.metadata())}if(Q.mask!=null){Q.mask+="";if(O.data("mask")){E.unset(O)}var K=Q.defaultValue,L=(Q.type==="reverse"),M=new RegExp(Q.fixedChars,"g");if(Q.maxLength===-1){Q.maxLength=O.attr(H)}Q=D.extend({},Q,{fixedCharsReg:new RegExp(Q.fixedChars),fixedCharsRegG:M,maskArray:Q.mask.split(""),maskNonFixedCharsArray:Q.mask.replace(M,"").split("")});if((Q.type=="fixed"||L)&&Q.setSize&&!O.attr("size")){O.attr("size",Q.mask.length)}if(L&&Q.textAlign){O.css("text-align","right")}if(this.value!==""||K!==""){var P=E.string((this.value!=="")?this.value:K,Q);this.defaultValue=P;O.val(P)}if(Q.type=="infinite"){Q.type="repeat"}O.data("mask",Q);O.removeAttr(H);O.bind("keydown.mask",{func:E._onKeyDown,thisObj:E},E._onMask).bind("keypress.mask",{func:E._onKeyPress,thisObj:E},E._onMask).bind("keyup.mask",{func:E._onKeyUp,thisObj:E},E._onMask).bind("paste.mask",{func:E._onPaste,thisObj:E},E._onMask).bind("focus.mask",E._onFocus).bind("blur.mask",E._onBlur).bind("change.mask",E._onChange)}})},unset:function(F){var E=D(F);return E.each(function(){var H=D(this);if(H.data("mask")){var G=H.data("mask").maxLength;if(G!=-1){H.attr("maxLength",G)}H.unbind(".mask").removeData("mask")}})},string:function(J,F){this.init();var I={};if(typeof J!="string"){J=String(J)}switch(typeof F){case"string":if(this.masks[F]){I=D.extend(I,this.masks[F])}else{I.mask=F}break;case"object":I=F}if(!I.fixedChars){I.fixedChars=this.options.fixedChars}var E=new RegExp(I.fixedChars),G=new RegExp(I.fixedChars,"g");if((I.type==="reverse")&&I.defaultValue){if(typeof this.signals[I.defaultValue.charAt(0)]!="undefined"){var H=J.charAt(0);I.signal=(typeof this.signals[H]!="undefined")?this.signals[H]:this.signals[I.defaultValue.charAt(0)];I.defaultValue=I.defaultValue.substring(1)}}return this.__maskArray(J.split(""),I.mask.replace(G,"").split(""),I.mask.split(""),I.type,I.maxLength,I.defaultValue,E,I.signal)},_onFocus:function(G){var F=D(this),E=F.data("mask");E.inputFocusValue=F.val();E.changed=false;if(E.selectCharsOnFocus){F.select()}},_onBlur:function(G){var F=D(this),E=F.data("mask");if(E.inputFocusValue!=F.val()&&!E.changed){F.trigger("change")}},_onChange:function(E){D(this).data("mask").changed=true},_onMask:function(E){var G=E.data.thisObj,F={};F._this=E.target;F.$this=D(F._this);F.data=F.$this.data("mask");if(F.$this.attr("readonly")||!F.data){return true}F[F.data.type]=true;F.value=F.$this.val();F.nKey=G.__getKeyNumber(E);F.range=G.__getRange(F._this);F.valueArray=F.value.split("");return E.data.func.call(G,E,F)},_onKeyDown:function(F,G){this.ignore=D.inArray(G.nKey,this.ignoreKeys)>-1||F.ctrlKey||F.metaKey||F.altKey;if(this.ignore){var E=this.keyRep[G.nKey];G.data.onValid.call(G._this,E||"",G.nKey)}return C?this._onKeyPress(F,G):true},_onKeyUp:function(E,F){if(F.nKey===9||F.nKey===16){return true}if(F.repeat){this.__autoTab(F);return true}return this._onPaste(E,F)},_onPaste:function(F,G){if(G.reverse){this.__changeSignal(F.type,G)}var E=this.__maskArray(G.valueArray,G.data.maskNonFixedCharsArray,G.data.maskArray,G.data.type,G.data.maxLength,G.data.defaultValue,G.data.fixedCharsReg,G.data.signal);G.$this.val(E);if(!G.reverse&&G.data.defaultValue.length&&(G.range.start===G.range.end)){this.__setRange(G._this,G.range.start,G.range.end)}if((D.browser.msie||D.browser.safari)&&!G.reverse){this.__setRange(G._this,G.range.start,G.range.end)}if(this.ignore){return true}this.__autoTab(G);return true},_onKeyPress:function(L,E){if(this.ignore){return true}if(E.reverse){this.__changeSignal(L.type,E)}var M=String.fromCharCode(E.nKey),O=E.range.start,I=E.value,G=E.data.maskArray;if(E.reverse){var H=I.substr(0,O),K=I.substr(E.range.end,I.length);I=H+M+K;if(E.data.signal&&(O-E.data.signal.length>0)){O-=E.data.signal.length}}var N=I.replace(E.data.fixedCharsRegG,"").split(""),F=this.__extraPositionsTill(O,G,E.data.fixedCharsReg);E.rsEp=O+F;if(E.repeat){E.rsEp=0}if(!this.rules[G[E.rsEp]]||(E.data.maxLength!=-1&&N.length>=E.data.maxLength&&E.repeat)){E.data.onOverflow.call(E._this,M,E.nKey);return false}else{if(!this.rules[G[E.rsEp]].test(M)){E.data.onInvalid.call(E._this,M,E.nKey);return false}else{E.data.onValid.call(E._this,M,E.nKey)}}var J=this.__maskArray(N,E.data.maskNonFixedCharsArray,G,E.data.type,E.data.maxLength,E.data.defaultValue,E.data.fixedCharsReg,E.data.signal,F);if(!E.repeat){E.$this.val(J)}return(E.reverse)?this._keyPressReverse(L,E):(E.fixed)?this._keyPressFixed(L,E):true},_keyPressFixed:function(E,F){if(F.range.start==F.range.end){if((F.rsEp===0&&F.value.length===0)||F.rsEp<F.value.length){this.__setRange(F._this,F.rsEp,F.rsEp+1)}}else{this.__setRange(F._this,F.range.start,F.range.end)}return true},_keyPressReverse:function(E,F){if(D.browser.msie&&((F.range.start===0&&F.range.end===0)||F.range.start!=F.range.end)){this.__setRange(F._this,F.value.length)}return false},__autoTab:function(F){if(F.data.autoTab&&((F.$this.val().length>=F.data.maskArray.length&&!F.repeat)||(F.data.maxLength!=-1&&F.valueArray.length>=F.data.maxLength&&F.repeat))){var E=this.__getNextInput(F._this,F.data.autoTab);if(E){F.$this.trigger("blur");E.focus().select()}}},__changeSignal:function(F,G){if(G.data.signal!==false){var E=(F==="paste")?G.value.charAt(0):String.fromCharCode(G.nKey);if(this.signals&&(typeof this.signals[E]!=="undefined")){G.data.signal=this.signals[E]}}},__getKeyNumber:function(E){return(E.charCode||E.keyCode||E.which)},__maskArray:function(M,H,G,J,E,K,N,L,F){if(J==="reverse"){M.reverse()}M=this.__removeInvalidChars(M,H,J==="repeat"||J==="infinite");if(K){M=this.__applyDefaultValue.call(M,K)}M=this.__applyMask(M,G,F,N);switch(J){case"reverse":M.reverse();return(L||"")+M.join("").substring(M.length-G.length);case"infinite":case"repeat":var I=M.join("");return(E!==-1&&M.length>=E)?I.substring(0,E):I;default:return M.join("").substring(0,G.length)}return""},__applyDefaultValue:function(G){var E=G.length,F=this.length,H;for(H=F-1;H>=0;H--){if(this[H]==G.charAt(0)){this.pop()}else{break}}for(H=0;H<E;H++){if(!this[H]){this[H]=G.charAt(H)}}return this},__removeInvalidChars:function(H,G,E){for(var F=0,I=0;F<H.length;F++){if(G[I]&&this.rules[G[I]]&&!this.rules[G[I]].test(H[F])){H.splice(F,1);if(!E){I--}F--}if(!E){I++}}return H},__applyMask:function(H,F,I,E){if(typeof I=="undefined"){I=0}for(var G=0;G<H.length+I;G++){if(F[G]&&E.test(F[G])){H.splice(G,0,F[G])}}return H},__extraPositionsTill:function(H,F,E){var G=0;while(E.test(F[H++])){G++}return G},__getNextInput:function(Q,G){var F=Q.form;if(F==null){return null}var J=F.elements,I=D.inArray(Q,J)+1,L=J.length,O=null,K;for(K=I;K<L;K++){O=D(J[K]);if(this.__isNextInput(O,G)){return O}}var E=document.forms,H=D.inArray(Q.form,E)+1,N,M,P=E.length;for(N=H;N<P;N++){M=E[N].elements;L=M.length;for(K=0;K<L;K++){O=D(M[K]);if(this.__isNextInput(O,G)){return O}}}return null},__isNextInput:function(G,E){var F=G.get(0);return F&&(F.offsetWidth>0||F.offsetHeight>0)&&F.nodeName!="FIELDSET"&&(E===true||(typeof E=="string"&&G.is(E)))},__setRange:function(G,H,E){if(typeof E=="undefined"){E=H}if(G.setSelectionRange){G.setSelectionRange(H,E)}else{var F=G.createTextRange();F.collapse();F.moveStart("character",H);F.moveEnd("character",E-H);F.select()}},__getRange:function(F){if(!D.browser.msie){return{start:F.selectionStart,end:F.selectionEnd}}var G={start:0,end:0},E=document.selection.createRange();G.start=0-E.duplicate().moveStart("character",-100000);G.end=G.start+E.text.length;return G},unmaskedVal:function(E){return D(E).val().replace(D.mask.fixedCharsRegG,"")}}});D.fn.extend({setMask:function(E){return D.mask.set(this,E)},unsetMask:function(){return D.mask.unset(this)},unmaskedVal:function(){return D.mask.unmaskedVal(this[0])}})})(jQuery)
@@ -0,0 +1,194 @@
1
+ /*
2
+ * jQuery UI addresspicker @VERSION
3
+ *
4
+ * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI/Progressbar
9
+ *
10
+ * Depends:
11
+ * jquery.ui.core.js
12
+ * jquery.ui.widget.js
13
+ * jquery.ui.autocomplete.js
14
+ */
15
+ (function( $, undefined ) {
16
+
17
+ $.widget( "ui.addresspicker", {
18
+ options: {
19
+ appendAddressString: "",
20
+ draggableMarker: true,
21
+ regionBias: null,
22
+ mapOptions: {
23
+ zoom: 5,
24
+ center: new google.maps.LatLng(46, 2),
25
+ scrollwheel: false,
26
+ mapTypeId: google.maps.MapTypeId.ROADMAP
27
+ },
28
+ elements: {
29
+ map: false,
30
+ lat: false,
31
+ lng: false,
32
+ locality: false,
33
+ administrative_area_level_2: false,
34
+ administrative_area_level_1: false,
35
+ country: false,
36
+ postal_code: false,
37
+ type: false
38
+
39
+ }
40
+ },
41
+
42
+ marker: function() {
43
+ return this.gmarker;
44
+ },
45
+
46
+ map: function() {
47
+ return this.gmap;
48
+ },
49
+
50
+ updatePosition: function() {
51
+ this._updatePosition(this.gmarker.getPosition());
52
+ },
53
+
54
+ reloadPosition: function() {
55
+ this.gmarker.setVisible(true);
56
+ this.gmarker.setPosition(new google.maps.LatLng(this.lat.val(), this.lng.val()));
57
+ this.gmap.setCenter(this.gmarker.getPosition());
58
+ },
59
+
60
+ selected: function() {
61
+ return this.selectedResult;
62
+ },
63
+
64
+ _create: function() {
65
+ this.geocoder = new google.maps.Geocoder();
66
+ this.element.autocomplete({
67
+ source: $.proxy(this._geocode, this),
68
+ focus: $.proxy(this._focusAddress, this),
69
+ select: $.proxy(this._selectAddress, this)
70
+ });
71
+
72
+ this.lat = $(this.options.elements.lat);
73
+ this.lng = $(this.options.elements.lng);
74
+ this.locality = $(this.options.elements.locality);
75
+ this.administrative_area_level_2 = $(this.options.elements.administrative_area_level_2);
76
+ this.administrative_area_level_1 = $(this.options.elements.administrative_area_level_1);
77
+ this.country = $(this.options.elements.country);
78
+ this.postal_code = $(this.options.elements.postal_code);
79
+ this.type = $(this.options.elements.type);
80
+ if (this.options.elements.map) {
81
+ this.mapElement = $(this.options.elements.map);
82
+ this._initMap();
83
+ }
84
+ },
85
+
86
+ _initMap: function() {
87
+ if (this.lat && this.lat.val()) {
88
+ this.options.mapOptions.center = new google.maps.LatLng(this.lat.val(), this.lng.val());
89
+ }
90
+
91
+ this.gmap = new google.maps.Map(this.mapElement[0], this.options.mapOptions);
92
+ this.gmarker = new google.maps.Marker({
93
+ position: this.options.mapOptions.center,
94
+ map:this.gmap,
95
+ draggable: this.options.draggableMarker});
96
+ google.maps.event.addListener(this.gmarker, 'dragend', $.proxy(this._markerMoved, this));
97
+ this.gmarker.setVisible(false);
98
+ },
99
+
100
+ _updatePosition: function(location) {
101
+ if (this.lat) {
102
+ this.lat.val(location.lat());
103
+ }
104
+ if (this.lng) {
105
+ this.lng.val(location.lng());
106
+ }
107
+ },
108
+
109
+ _markerMoved: function() {
110
+ this._updatePosition(this.gmarker.getPosition());
111
+ },
112
+
113
+ // Autocomplete source method: fill its suggests with google geocoder results
114
+ _geocode: function(request, response) {
115
+ var address = request.term, self = this;
116
+ this.geocoder.geocode({
117
+ 'address': address + this.options.appendAddressString,
118
+ 'region': this.options.regionBias
119
+ }, function(results, status) {
120
+ if (status == google.maps.GeocoderStatus.OK) {
121
+ for (var i = 0; i < results.length; i++) {
122
+ results[i].label = results[i].formatted_address;
123
+ };
124
+ }
125
+ response(results);
126
+ })
127
+ },
128
+
129
+ _findInfo: function(result, type) {
130
+ for (var i = 0; i < result.address_components.length; i++) {
131
+ var component = result.address_components[i];
132
+ if (component.types.indexOf(type) !=-1) {
133
+ return component.long_name;
134
+ }
135
+ }
136
+ return false;
137
+ },
138
+
139
+ _focusAddress: function(event, ui) {
140
+ var address = ui.item;
141
+ if (!address) {
142
+ return;
143
+ }
144
+
145
+ if (this.gmarker) {
146
+ this.gmarker.setPosition(address.geometry.location);
147
+ this.gmarker.setVisible(true);
148
+
149
+ this.gmap.fitBounds(address.geometry.viewport);
150
+ }
151
+ this._updatePosition(address.geometry.location);
152
+
153
+ if (this.locality) {
154
+ this.locality.val(this._findInfo(address, 'locality'));
155
+ }
156
+ if (this.administrative_area_level_2) {
157
+ this.administrative_area_level_2.val(this._findInfo(address, 'administrative_area_level_2'));
158
+ }
159
+ if (this.administrative_area_level_1) {
160
+ this.administrative_area_level_1.val(this._findInfo(address, 'administrative_area_level_1'));
161
+ }
162
+ if (this.country) {
163
+ this.country.val(this._findInfo(address, 'country'));
164
+ }
165
+ if (this.postal_code) {
166
+ this.postal_code.val(this._findInfo(address, 'postal_code'));
167
+ }
168
+ if (this.type) {
169
+ this.type.val(address.types[0]);
170
+ }
171
+ },
172
+
173
+ _selectAddress: function(event, ui) {
174
+ this.selectedResult = ui.item;
175
+ }
176
+ });
177
+
178
+ $.extend( $.ui.addresspicker, {
179
+ version: "@VERSION"
180
+ });
181
+
182
+ // make IE think it doesn't suck
183
+ if(!Array.indexOf){
184
+ Array.prototype.indexOf = function(obj){
185
+ for(var i=0; i<this.length; i++){
186
+ if(this[i]==obj){
187
+ return i;
188
+ }
189
+ }
190
+ return -1;
191
+ }
192
+ }
193
+
194
+ })( jQuery );