right-rails 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- data/init.rb +1 -0
- data/lib/generators/right_rails/right_rails_generator.rb +15 -6
- data/lib/right_rails.rb +1 -1
- data/lib/right_rails/controller_extensions.rb +28 -15
- data/lib/right_rails/helpers/misc.rb +38 -38
- data/lib/right_rails/helpers/rails.rb +50 -7
- data/lib/rjs_renderer.rb +26 -0
- data/spec/lib/right_rails/controller_extensions_spec.rb +25 -14
- data/spec/lib/right_rails/helpers/forms_spec.rb +6 -6
- data/spec/lib/right_rails/helpers/rails_spec.rb +44 -45
- data/vendor/assets/images/rightjs-ui/rte.png +0 -0
- data/vendor/assets/javascripts/right-safe-src.js +2 -2
- data/vendor/assets/javascripts/right-safe.js +2 -2
- data/vendor/assets/javascripts/right-src.js +386 -100
- data/vendor/assets/javascripts/right.js +2 -2
- data/vendor/assets/javascripts/right/calendar-src.js +19 -3
- data/vendor/assets/javascripts/right/calendar.js +2 -2
- data/vendor/assets/javascripts/right/colorpicker-src.js +59 -20
- data/vendor/assets/javascripts/right/colorpicker.js +2 -2
- data/vendor/assets/javascripts/right/i18n/de.js +43 -42
- data/vendor/assets/javascripts/right/i18n/es.js +1 -0
- data/vendor/assets/javascripts/right/i18n/fi.js +1 -0
- data/vendor/assets/javascripts/right/i18n/fr.js +1 -0
- data/vendor/assets/javascripts/right/i18n/hu.js +1 -0
- data/vendor/assets/javascripts/right/i18n/it.js +1 -0
- data/vendor/assets/javascripts/right/i18n/jp.js +1 -0
- data/vendor/assets/javascripts/right/i18n/lt.js +96 -0
- data/vendor/assets/javascripts/right/i18n/nl.js +1 -0
- data/vendor/assets/javascripts/right/i18n/pt-br.js +1 -0
- data/vendor/assets/javascripts/right/i18n/ru.js +1 -0
- data/vendor/assets/javascripts/right/i18n/ua.js +1 -0
- data/vendor/assets/javascripts/right/jquerysh-src.js +4 -4
- data/vendor/assets/javascripts/right/jquerysh.js +2 -2
- data/vendor/assets/javascripts/right/rails-src.js +51 -15
- data/vendor/assets/javascripts/right/rails.js +2 -2
- data/vendor/assets/javascripts/right/resizable-src.js +11 -11
- data/vendor/assets/javascripts/right/rte-src.js +33 -13
- data/vendor/assets/javascripts/right/rte.js +2 -2
- data/vendor/assets/javascripts/right/slider-src.js +137 -28
- data/vendor/assets/javascripts/right/slider.js +2 -2
- metadata +24 -126
- data/generators/right_rails/right_rails_generator.rb +0 -46
- data/generators/right_rails/templates/iframed.html.erb +0 -10
- data/generators/right_scaffold/right_scaffold_generator.rb +0 -53
- data/generators/right_scaffold/templates/controller.rb +0 -99
- data/generators/right_scaffold/templates/helper.rb +0 -2
- data/generators/right_scaffold/templates/layout.html.erb +0 -18
- data/generators/right_scaffold/templates/style.css +0 -54
- data/generators/right_scaffold/templates/view__form.html.erb +0 -16
- data/generators/right_scaffold/templates/view__item.html.erb +0 -13
- data/generators/right_scaffold/templates/view_edit.html.erb +0 -6
- data/generators/right_scaffold/templates/view_index.html.erb +0 -9
- data/generators/right_scaffold/templates/view_new.html.erb +0 -5
- data/generators/right_scaffold/templates/view_show.html.erb +0 -10
- data/lib/generators/right_rails/templates/iframed.html.erb +0 -10
- data/public/images/rightjs-ui/colorpicker.png +0 -0
- data/public/images/rightjs-ui/resizable.png +0 -0
- data/public/images/rightjs-ui/rte.png +0 -0
- data/public/javascripts/right-olds-src.js +0 -652
- data/public/javascripts/right-olds.js +0 -9
- data/public/javascripts/right-safe-src.js +0 -68
- data/public/javascripts/right-safe.js +0 -7
- data/public/javascripts/right-src.js +0 -6014
- data/public/javascripts/right.js +0 -7
- data/public/javascripts/right/autocompleter-src.js +0 -625
- data/public/javascripts/right/autocompleter.js +0 -7
- data/public/javascripts/right/billboard-src.js +0 -564
- data/public/javascripts/right/billboard.js +0 -7
- data/public/javascripts/right/calendar-src.js +0 -1464
- data/public/javascripts/right/calendar.js +0 -7
- data/public/javascripts/right/casting-src.js +0 -183
- data/public/javascripts/right/casting.js +0 -7
- data/public/javascripts/right/colorpicker-src.js +0 -981
- data/public/javascripts/right/colorpicker.js +0 -7
- data/public/javascripts/right/dialog-src.js +0 -768
- data/public/javascripts/right/dialog.js +0 -7
- data/public/javascripts/right/dnd-src.js +0 -591
- data/public/javascripts/right/dnd.js +0 -7
- data/public/javascripts/right/effects-src.js +0 -508
- data/public/javascripts/right/effects.js +0 -7
- data/public/javascripts/right/i18n/de.js +0 -95
- data/public/javascripts/right/i18n/en-us.js +0 -11
- data/public/javascripts/right/i18n/es.js +0 -95
- data/public/javascripts/right/i18n/fi.js +0 -96
- data/public/javascripts/right/i18n/fr.js +0 -95
- data/public/javascripts/right/i18n/hu.js +0 -100
- data/public/javascripts/right/i18n/it.js +0 -95
- data/public/javascripts/right/i18n/jp.js +0 -99
- data/public/javascripts/right/i18n/nl.js +0 -95
- data/public/javascripts/right/i18n/pt-br.js +0 -95
- data/public/javascripts/right/i18n/ru.js +0 -95
- data/public/javascripts/right/i18n/ua.js +0 -99
- data/public/javascripts/right/in-edit-src.js +0 -373
- data/public/javascripts/right/in-edit.js +0 -7
- data/public/javascripts/right/jquerysh-src.js +0 -362
- data/public/javascripts/right/jquerysh.js +0 -7
- data/public/javascripts/right/json-src.js +0 -147
- data/public/javascripts/right/json.js +0 -7
- data/public/javascripts/right/keys-src.js +0 -87
- data/public/javascripts/right/keys.js +0 -7
- data/public/javascripts/right/lightbox-src.js +0 -931
- data/public/javascripts/right/lightbox.js +0 -7
- data/public/javascripts/right/rails-src.js +0 -402
- data/public/javascripts/right/rails.js +0 -7
- data/public/javascripts/right/rater-src.js +0 -384
- data/public/javascripts/right/rater.js +0 -7
- data/public/javascripts/right/resizable-src.js +0 -465
- data/public/javascripts/right/resizable.js +0 -7
- data/public/javascripts/right/rte-src.js +0 -2685
- data/public/javascripts/right/rte.js +0 -7
- data/public/javascripts/right/selectable-src.js +0 -725
- data/public/javascripts/right/selectable.js +0 -7
- data/public/javascripts/right/sizzle-src.js +0 -1132
- data/public/javascripts/right/sizzle.js +0 -7
- data/public/javascripts/right/slider-src.js +0 -395
- data/public/javascripts/right/slider.js +0 -7
- data/public/javascripts/right/sortable-src.js +0 -430
- data/public/javascripts/right/sortable.js +0 -7
- data/public/javascripts/right/table-src.js +0 -176
- data/public/javascripts/right/table.js +0 -7
- data/public/javascripts/right/tabs-src.js +0 -1157
- data/public/javascripts/right/tabs.js +0 -7
- data/public/javascripts/right/tags-src.js +0 -745
- data/public/javascripts/right/tags.js +0 -7
- data/public/javascripts/right/tooltips-src.js +0 -331
- data/public/javascripts/right/tooltips.js +0 -7
- data/public/javascripts/right/uploader-src.js +0 -302
- data/public/javascripts/right/uploader.js +0 -7
@@ -1,7 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RightJS-UI Colorpicker v2.2.0
|
3
|
-
* http://rightjs.org/ui/colorpicker
|
4
|
-
*
|
5
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Colorpicker=RightJS.Colorpicker=function(a,b,c,d){function i(a,b,e){var f=this.reAnchor||(this.reAnchor=new d.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=c(a.getStyle("borderTopWidth")),k=c(a.getStyle("borderLeftWidth")),l=c(a.getStyle("borderRightWidth")),m=c(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),b==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(b==="left"||b==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function h(a,b,c,e){d.Fx&&(c===undefined&&(c=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:d(a.fire).bind(a,b)},b==="hide"&&(e.duration=(d.Fx.Durations[e.duration]||e.duration)/2)))),(!d.Fx||!c)&&a.fire(b);return a.$super(c,e)}function e(a,b){b||(b=a,a="DIV");var c=new d.Class(d.Element.Wrappers[a]||d.Element,{initialize:function(b,c){this.key=b;var e=[{"class":"rui-"+b}];this instanceof d.Input||this instanceof d.Form||e.unshift(a),this.$super.apply(this,e),d.isString(c)&&(c=d.$(c)),c instanceof d.Element&&(this._=c._,"$listeners"in c&&(c.$listeners=c.$listeners),c={}),this.setOptions(c,this);return d.Wrapper.Cache[d.$uid(this._)]=this},setOptions:function(a,b){b&&(a=d.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&d.Options.setOptions.call(this,d.Object.merge(this.options,a));return this}}),e=new d.Class(c,b);d.Observer.createShortcuts(e.prototype,e.EVENTS||d([]));return e}var f=new d.Class(d.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),g={show:function(a,b){this.constructor.current=this;return h(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return h(this,"show",a,b)},showAt:function(a,b,c){this.hide(null).shownAt=a=d.$(a),i.call(this,a,b,c);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},j={assignTo:function(a,b){a=d.$(a),b=d.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var c=d(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:c,change:c}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=d,l=d.$,m=d.$w,n=d.$$,o=d.$E,p=d.$A,q=d.isArray,r=d.Class,s=d.Element,t=d.Input,u=new e({include:[g,j],extend:{version:"2.2.0",EVENTS:m("change show hide done"),Options:{format:"hex",update:null,updateBg:null,trigger:null,fxName:"fade",fxDuration:"short",cssRule:"*[data-colorpicker]"},i18n:{Done:"Done"},hideAll:function(){n("div.rui-colorpicker").each(function(a){a instanceof u&&!a.inlined()&&a.hide()})}},initialize:function(a){this.$super("colorpicker",a).addClass("rui-panel").insert([this.field=new v,this.colors=new w,this.controls=new x]).on({mousedown:this.startTrack,keyup:this.recalc,blur:this.update,focus:this.cancelTimer,done:this.done}),this.options.update&&this.assignTo(this.options.update,this.options.trigger),this.options.updateBg&&this.updateBg(this.options.updateBg),this.tint=k([1,0,0]),this.satur=0,this.bright=1,this.color=k([255,255,255]),this.recalc().update()},setValue:function(a){var b=q(a)?a:this.toColor(a);b&&b.length===3&&(b=b.map(function(a){return this.bound(c(""+a),0,255)},this),this.color=b,this.color2tint().update(),this.colors.size().y||this.update.bind(this).delay(20));return this},getValue:function(a){return a?this.color:this[this.options.format==="rgb"?"toRgb":"toHex"]()},updateBg:function(a){var b=l(a);b&&this.onChange(k(function(a){b._.style.backgroundColor=this.toRgb()}).bind(this));return this},insertTo:function(a,b){return this.$super(a,b).addClass("rui-colorpicker-inline")},inlined:function(){return this.hasClass("rui-colorpicker-inline")},done:function(){this.inlined()||this.hide();return this},setOptions:function(a){a=a||{},this.$super(a,l(a.trigger||a.update))},update:function(){this.field._.style.backgroundColor="rgb("+this.tint.map(function(a){return b.round(a*255)})+")";var a=this.color,c=this.controls;c.preview._.style.backgroundColor=c.display._.value=this.toHex(),c.rDisplay._.value=a[0],c.gDisplay._.value=a[1],c.bDisplay._.value=a[2];var d=this.field.pointer._.style,e=this.field.size(),f=e.y-this.bright*e.y-2,g=this.satur*e.x-2;d.top=this.bound(f,0,e.y-5)+"px",d.left=this.bound(g,0,e.x-5)+"px";var h=this.tint,i;e=this.colors.size(),h[1]==0?i=h[0]==1?h[2]:2-h[0]:h[0]==0?i=2+(h[2]==1?h[1]:2-h[2]):i=4+(h[1]==1?h[0]:2-h[1]),i=i/6*e.y,this.colors.pointer._.style.top=this.bound(i,0,e.y-4)+"px",this.prevColor!==""+this.color&&(this.fire("change",{value:this.color}),this.prevColor=""+this.color);return this},recalc:function(a){if(a){var b=a.target,c=b._.value,d=p(this.color),e=!1;b===this.controls.display&&/#\w{6}/.test(c)?e=d=this.toColor(c):/^\d+$/.test(c)&&(d[b._.cIndex]=c,e=!0),e&&this.setValue(d)}else this.tint2color();return this},startTrack:function(a){this.stopTrack(),this.cancelTimer(),a.target===this.field.pointer?a.target=this.field:a.target===this.colors.pointer&&(a.target=this.colors);if(a.target===this.field||a.target===this.colors)a.stop(),u.tracking=this,a.target.tracking=!0,this.trackMove(a)},stopTrack:function(){u.tracking=!1,this.field.tracking=!1,this.colors.tracking=!1},trackMove:function(a){var b,c=a.position(),d,e;this.field.tracking?b=this.field.dimensions():this.colors.tracking&&(b=this.colors.dimensions());if(b){d=this.bound(c.y-b.top,0,b.height),e=this.bound(c.x-b.left,0,b.width);if(this.field.tracking)this.satur=e/b.width,this.bright=1-d/b.height;else if(this.colors.tracking){d==b.height&&(d=b.height-.1);var f=b.height/6,g=this.tint=[0,0,0],h=d%f/f,i=1-h;d<f?(g[0]=1,g[2]=h):d<f*2?(g[0]=i,g[2]=1):d<f*3?(g[2]=1,g[1]=h):d<f*4?(g[2]=i,g[1]=1):d<f*5?(g[1]=1,g[0]=h):(g[1]=i,g[0]=1)}this.recalc().update()}},cancelTimer:function(a){k(function(){this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}).bind(this).delay(10)}}),v=new r(s,{initialize:function(a){this.$super("div",{"class":"field"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),w=new r(s,{initialize:function(){this.$super("div",{"class":"colors"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),x=new r(s,{initialize:function(){this.$super("div",{"class":"controls"}),this.insert([this.preview=o("div",{"class":"preview",html:" "}),this.display=o("input",{type:"text","class":"display",maxlength:7}),o("div",{"class":"rgb-display"}).insert([o("div").insert([o("label",{html:"R:"}),this.rDisplay=o("input",{maxlength:3,cIndex:0})]),o("div").insert([o("label",{html:"G:"}),this.gDisplay=o("input",{maxlength:3,cIndex:1})]),o("div").insert([o("label",{html:"B:"}),this.bDisplay=o("input",{maxlength:3,cIndex:2})])]),this.button=(new f(u.i18n.Done)).onClick("fire","done")])}});u.include({toRgb:function(a){return"rgb("+this.color.join(",")+")"},toHex:function(a){return"#"+this.color.map(function(a){return(a<16?"0":"")+a.toString(16)}).join("")},toColor:function(a){var b=a.toLowerCase(),d;if(d=/rgb\((\d+),(\d+),(\d+)\)/.exec(b))return[d[1],d[2],d[3]].map(c);if(/#[\da-f]+/.test(b)){if(d=/^#([\da-f])([\da-f])([\da-f])$/.exec(b))b="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3];if(d=/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(b))return[d[1],d[2],d[3]].map(function(a){return c(a,16)})}},color2tint:function(){var a=p(this.color).sort(function(a,b){return a-b}),b=a[0],c=a[2];this.bright=c/255,this.satur=1-b/(c||1),this.tint.each(function(a,d){this.tint[d]=!b&&!c||b==c?d==0?1:0:(this.color[d]-b)/(c-b);return this.tint[d]},this);return this},tint2color:function(){var a=this.tint,c=this.color;for(var d=0;d<3;d++)c[d]=1+this.satur*(a[d]-1),c[d]=b.round(255*c[d]*this.bright);return this},bound:function(a,b,c){var d=a;b<c?d=d<b?b:d>c?c:d:(d>c&&(d=c),d<b&&(d=b));return d}}),l(a).on({mouseup:function(){u.tracking&&u.tracking.stopTrack()},mousemove:function(a){u.tracking&&u.tracking.trackMove(a)},focus:function(a){var b=a.target instanceof t?a.target:null;u.hideAll(),b&&(b.colorpicker||b.match(u.Options.cssRule))&&(b.colorpicker||new u({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.colorpicker;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof s?a.target:null;b&&(b.colorpicker||b.match(u.Options.cssRule))?b instanceof t||(a.stop(),(b.colorpicker||new u({trigger:b})).hide(null).toggleAt(b.assignedInput)):a.find("div.rui-colorpicker")||u.hideAll()},keydown:function(a){var b=u.current,c=({27:"hide",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),b[c]())}});var y=a.createElement("style"),z=a.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default}div.rui-colorpicker .field,div.rui-colorpicker .field *,div.rui-colorpicker .colors,div.rui-colorpicker .colors *{border:none;background:none;width:auto;height:auto;position:static;float:none;top:none;left:none;right:none;bottom:none;margin:0;padding:0;display:block;font-weight:normal;vertical-align:center}div.rui-colorpicker div.field,div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors,div.rui-colorpicker div.colors div.pointer{background:url(/images/rightjs-ui/colorpicker.png) no-repeat 0 0}div.rui-colorpicker div.field,div.rui-colorpicker div.colors,div.rui-colorpicker div.controls{display:inline-block; *display:inline; *zoom:1;position:relative;vertical-align:top;height:150px}div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors div.pointer{position:absolute;top:0px;left:0;width:9px;height:9px}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display,div.rui-colorpicker input.rui-ui-button{font-size:100%;display:block;width:auto;padding:0 .2em}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display input,div.rui-colorpicker input.rui-ui-button{border:1px solid #AAA;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-colorpicker div.field{width:150px;background-color:red;cursor:crosshair;margin-right:1.2em}div.rui-colorpicker div.field div.pointer{background-position:-170px 0;margin-left:-2px;margin-top:-2px}div.rui-colorpicker div.colors{width:16px;background-position:-150px 0;border-color:#EEE;cursor:pointer;margin-right:.6em}div.rui-colorpicker div.colors div.pointer{cursor:default;background-position:-170px -20px;margin-left:-8px;margin-top:-3px}div.rui-colorpicker div.controls{width:5em}div.rui-colorpicker div.preview{height:2em;background:white;border-color:#BBB}div.rui-colorpicker input.display{margin-top:.5em;background:#FFF;width:4.5em}div.rui-colorpicker div.rgb-display{padding:0;text-align:right;margin-top:.5em}div.rui-colorpicker div.rgb-display label{display:inline}div.rui-colorpicker div.rgb-display label:after{content:none}div.rui-colorpicker div.rgb-display input{vertical-align:top;font-size:100%;width:2em;text-align:right;margin-left:.2em;padding:0 .2em;background:#FFF;margin-bottom:1px;display:inline}div.rui-colorpicker div.rui-button{cursor:pointer;position:absolute;bottom:0;right:0;width:4em}div.rui-colorpicker-inline{display:inline-block; *display:inline; *zoom:1;position:relative;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;z-index:auto}");y.type="text/css",a.getElementsByTagName("head")[0].appendChild(y),y.styleSheet?y.styleSheet.cssText=z.nodeValue:y.appendChild(z);return u}(document,Math,parseInt,RightJS)
|
@@ -1,768 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RightJS-UI Dialog v2.2.0
|
3
|
-
* http://rightjs.org/ui/dialog
|
4
|
-
*
|
5
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Dialog = RightJS.Dialog = (function(RightJS) {
|
8
|
-
/**
|
9
|
-
* This module defines the basic widgets constructor
|
10
|
-
* it creates an abstract proxy with the common functionality
|
11
|
-
* which then we reuse and override in the actual widgets
|
12
|
-
*
|
13
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
* The widget units constructor
|
18
|
-
*
|
19
|
-
* @param String tag-name or Object methods
|
20
|
-
* @param Object methods
|
21
|
-
* @return Widget wrapper
|
22
|
-
*/
|
23
|
-
function Widget(tag_name, methods) {
|
24
|
-
if (!methods) {
|
25
|
-
methods = tag_name;
|
26
|
-
tag_name = 'DIV';
|
27
|
-
}
|
28
|
-
|
29
|
-
/**
|
30
|
-
* An Abstract Widget Unit
|
31
|
-
*
|
32
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
33
|
-
*/
|
34
|
-
var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
35
|
-
/**
|
36
|
-
* The common constructor
|
37
|
-
*
|
38
|
-
* @param Object options
|
39
|
-
* @param String optional tag name
|
40
|
-
* @return void
|
41
|
-
*/
|
42
|
-
initialize: function(key, options) {
|
43
|
-
this.key = key;
|
44
|
-
var args = [{'class': 'rui-' + key}];
|
45
|
-
|
46
|
-
// those two have different constructors
|
47
|
-
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
48
|
-
args.unshift(tag_name);
|
49
|
-
}
|
50
|
-
this.$super.apply(this, args);
|
51
|
-
|
52
|
-
if (RightJS.isString(options)) {
|
53
|
-
options = RightJS.$(options);
|
54
|
-
}
|
55
|
-
|
56
|
-
// if the options is another element then
|
57
|
-
// try to dynamically rewrap it with our widget
|
58
|
-
if (options instanceof RightJS.Element) {
|
59
|
-
this._ = options._;
|
60
|
-
if ('$listeners' in options) {
|
61
|
-
options.$listeners = options.$listeners;
|
62
|
-
}
|
63
|
-
options = {};
|
64
|
-
}
|
65
|
-
this.setOptions(options, this);
|
66
|
-
|
67
|
-
return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
|
68
|
-
},
|
69
|
-
|
70
|
-
// protected
|
71
|
-
|
72
|
-
/**
|
73
|
-
* Catches the options
|
74
|
-
*
|
75
|
-
* @param Object user-options
|
76
|
-
* @param Element element with contextual options
|
77
|
-
* @return void
|
78
|
-
*/
|
79
|
-
setOptions: function(options, element) {
|
80
|
-
if (element) {
|
81
|
-
options = RightJS.Object.merge(options, new Function("return "+(
|
82
|
-
element.get('data-'+ this.key) || '{}'
|
83
|
-
))());
|
84
|
-
}
|
85
|
-
|
86
|
-
if (options) {
|
87
|
-
RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
|
88
|
-
}
|
89
|
-
|
90
|
-
return this;
|
91
|
-
}
|
92
|
-
});
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Creating the actual widget class
|
96
|
-
*
|
97
|
-
*/
|
98
|
-
var Klass = new RightJS.Class(AbstractWidget, methods);
|
99
|
-
|
100
|
-
// creating the widget related shortcuts
|
101
|
-
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
|
102
|
-
|
103
|
-
return Klass;
|
104
|
-
}
|
105
|
-
|
106
|
-
|
107
|
-
/**
|
108
|
-
* A shared button unit.
|
109
|
-
* NOTE: we use the DIV units instead of INPUTS
|
110
|
-
* so those buttons didn't interfere with
|
111
|
-
* the user's tab-index on his page
|
112
|
-
*
|
113
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
114
|
-
*/
|
115
|
-
var Button = new RightJS.Class(RightJS.Element, {
|
116
|
-
/**
|
117
|
-
* Constructor
|
118
|
-
*
|
119
|
-
* @param String caption
|
120
|
-
* @param Object options
|
121
|
-
* @return void
|
122
|
-
*/
|
123
|
-
initialize: function(caption, options) {
|
124
|
-
this.$super('div', options);
|
125
|
-
this._.innerHTML = caption;
|
126
|
-
this.addClass('rui-button');
|
127
|
-
this.on('selectstart', 'stopEvent');
|
128
|
-
},
|
129
|
-
|
130
|
-
/**
|
131
|
-
* Disasbles the button
|
132
|
-
*
|
133
|
-
* @return Button this
|
134
|
-
*/
|
135
|
-
disable: function() {
|
136
|
-
return this.addClass('rui-button-disabled');
|
137
|
-
},
|
138
|
-
|
139
|
-
/**
|
140
|
-
* Enables the button
|
141
|
-
*
|
142
|
-
* @return Button this
|
143
|
-
*/
|
144
|
-
enable: function() {
|
145
|
-
return this.removeClass('rui-button-disabled');
|
146
|
-
},
|
147
|
-
|
148
|
-
/**
|
149
|
-
* Checks if the button is disabled
|
150
|
-
*
|
151
|
-
* @return Button this
|
152
|
-
*/
|
153
|
-
disabled: function() {
|
154
|
-
return this.hasClass('rui-button-disabled');
|
155
|
-
},
|
156
|
-
|
157
|
-
/**
|
158
|
-
* Checks if the button is enabled
|
159
|
-
*
|
160
|
-
* @return Button this
|
161
|
-
*/
|
162
|
-
enabled: function() {
|
163
|
-
return !this.disabled();
|
164
|
-
},
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Overloading the method, so it fired the events
|
168
|
-
* only when the button is active
|
169
|
-
*
|
170
|
-
* @return Button this
|
171
|
-
*/
|
172
|
-
fire: function() {
|
173
|
-
if (this.enabled()) {
|
174
|
-
this.$super.apply(this, arguments);
|
175
|
-
}
|
176
|
-
return this;
|
177
|
-
}
|
178
|
-
});
|
179
|
-
|
180
|
-
|
181
|
-
/**
|
182
|
-
* A shared module to create textual spinners
|
183
|
-
*
|
184
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
185
|
-
*/
|
186
|
-
var Spinner = new RightJS.Class(RightJS.Element, {
|
187
|
-
/**
|
188
|
-
* Constructor
|
189
|
-
*
|
190
|
-
* @param Number optional spinner size (4 by default)
|
191
|
-
* @return void
|
192
|
-
*/
|
193
|
-
initialize: function(size) {
|
194
|
-
this.$super('div', {'class': 'rui-spinner'});
|
195
|
-
this.dots = [];
|
196
|
-
|
197
|
-
for (var i=0; i < (size || 4); i++) {
|
198
|
-
this.dots.push(new RightJS.Element('div'));
|
199
|
-
}
|
200
|
-
|
201
|
-
this.dots[0].addClass('glowing');
|
202
|
-
this.insert(this.dots);
|
203
|
-
RightJS(this.shift).bind(this).periodical(300);
|
204
|
-
},
|
205
|
-
|
206
|
-
/**
|
207
|
-
* Shifts the spinner elements
|
208
|
-
*
|
209
|
-
* @return void
|
210
|
-
*/
|
211
|
-
shift: function() {
|
212
|
-
if (this.visible()) {
|
213
|
-
var dot = this.dots.pop();
|
214
|
-
this.dots.unshift(dot);
|
215
|
-
this.insert(dot, 'top');
|
216
|
-
}
|
217
|
-
}
|
218
|
-
});
|
219
|
-
|
220
|
-
|
221
|
-
/**
|
222
|
-
* Dialog widget initialization script
|
223
|
-
*
|
224
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
225
|
-
*/
|
226
|
-
var R = RightJS,
|
227
|
-
$ = RightJS.$,
|
228
|
-
$w = RightJS.$w,
|
229
|
-
$E = RightJS.$E,
|
230
|
-
Class = RightJS.Class,
|
231
|
-
Object = RightJS.Object,
|
232
|
-
Element = RightJS.Element;
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
/**
|
241
|
-
* Basic dialog class
|
242
|
-
*
|
243
|
-
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
244
|
-
*/
|
245
|
-
var Dialog = new Widget({
|
246
|
-
extend: {
|
247
|
-
version: '2.2.0',
|
248
|
-
|
249
|
-
EVENTS: $w('ok cancel help expand collapse resize load'),
|
250
|
-
|
251
|
-
Options: {
|
252
|
-
lockScreen: true, // if you need to lock the scrreen
|
253
|
-
fxDuration: 'short', // dialog appearance duration
|
254
|
-
|
255
|
-
draggable: true, // sets if the user should be able to drag the dialog around
|
256
|
-
closeable: true, // allow the user to close the dialog
|
257
|
-
expandable: false, // show the user to expand/collapse the dialog window width
|
258
|
-
|
259
|
-
showHelp: false, // show the 'Help' button
|
260
|
-
showIcon: null, // null or some text to be show in the dialog body icon
|
261
|
-
|
262
|
-
title: null, // default title to preset
|
263
|
-
html: null, // html content to set on instance
|
264
|
-
url: null // url address that should be loaded on instance
|
265
|
-
},
|
266
|
-
|
267
|
-
i18n: {
|
268
|
-
Ok: 'Ok',
|
269
|
-
Close: 'Close',
|
270
|
-
Cancel: 'Cancel',
|
271
|
-
Help: 'Help',
|
272
|
-
Expand: 'Expand',
|
273
|
-
Collapse: 'Collapse',
|
274
|
-
|
275
|
-
Alert: 'Warning!',
|
276
|
-
Confirm: 'Confirm',
|
277
|
-
Prompt: 'Enter'
|
278
|
-
},
|
279
|
-
|
280
|
-
current: false, // the current dialog reference
|
281
|
-
dragged: false // currently dragged dialog reference
|
282
|
-
},
|
283
|
-
|
284
|
-
/**
|
285
|
-
* Basic constructor
|
286
|
-
*
|
287
|
-
* @param Object options
|
288
|
-
* @return void
|
289
|
-
*/
|
290
|
-
initialize: function(options) {
|
291
|
-
this
|
292
|
-
.$super('dialog', options)
|
293
|
-
.append(
|
294
|
-
this.head = new Dialog.Head(this),
|
295
|
-
this.body = new Dialog.Body(this),
|
296
|
-
this.foot = new Dialog.Foot(this)
|
297
|
-
)
|
298
|
-
.onCancel(this.hide);
|
299
|
-
|
300
|
-
this.locker = $E('div', {'class': 'rui-screen-locker'});
|
301
|
-
|
302
|
-
if (this.options.title) {
|
303
|
-
this.title(this.options.title);
|
304
|
-
}
|
305
|
-
|
306
|
-
if (this.options.html) {
|
307
|
-
this.html(this.options.html);
|
308
|
-
}
|
309
|
-
|
310
|
-
if (this.options.url) {
|
311
|
-
this.load(this.options.url);
|
312
|
-
}
|
313
|
-
},
|
314
|
-
|
315
|
-
/**
|
316
|
-
* Shows the dialog
|
317
|
-
*
|
318
|
-
* @return Dialog this
|
319
|
-
*/
|
320
|
-
show: function() {
|
321
|
-
if (this.options.lockScreen) {
|
322
|
-
this.locker.insertTo(document.body);
|
323
|
-
}
|
324
|
-
|
325
|
-
this
|
326
|
-
.setStyle('visibility:hidden')
|
327
|
-
.insertTo(document.body)
|
328
|
-
.resize()
|
329
|
-
.setStyle('visibility:visible;opacity:0');
|
330
|
-
|
331
|
-
if (this.options.fxDuration) {
|
332
|
-
this.morph({opacity: 1}, {
|
333
|
-
duration: this.options.fxDuration
|
334
|
-
});
|
335
|
-
} else {
|
336
|
-
this.setStyle('opacity:1');
|
337
|
-
}
|
338
|
-
|
339
|
-
return (Dialog.current = this);
|
340
|
-
},
|
341
|
-
|
342
|
-
/**
|
343
|
-
* Hides the dialog
|
344
|
-
*
|
345
|
-
* @return Dialog this
|
346
|
-
*/
|
347
|
-
hide: function() {
|
348
|
-
this.locker.remove();
|
349
|
-
this.remove();
|
350
|
-
|
351
|
-
Dialog.current = false;
|
352
|
-
|
353
|
-
return this;
|
354
|
-
},
|
355
|
-
|
356
|
-
/**
|
357
|
-
* Repositions the dialog to the middle of the screen
|
358
|
-
*
|
359
|
-
* @param normal arguments
|
360
|
-
* @return Dialog this
|
361
|
-
*/
|
362
|
-
resize: function() {
|
363
|
-
if (arguments.length) {
|
364
|
-
this.$super.apply(this, arguments);
|
365
|
-
}
|
366
|
-
|
367
|
-
var size = this.size(), win_size = $(window).size();
|
368
|
-
|
369
|
-
if (this.expanded) {
|
370
|
-
size.x = win_size.x - 20;
|
371
|
-
size.y = win_size.y - 10;
|
372
|
-
this.$super.call(this, size);
|
373
|
-
}
|
374
|
-
|
375
|
-
this.setStyle({
|
376
|
-
top: (win_size.y - size.y)/2 + $(window).scrolls().y + 'px',
|
377
|
-
left: (win_size.x - size.x - 16)/2 + 'px'
|
378
|
-
});
|
379
|
-
|
380
|
-
return this.fire('resize');
|
381
|
-
},
|
382
|
-
|
383
|
-
/**
|
384
|
-
* Bidirectional method to work with titles
|
385
|
-
*
|
386
|
-
* @param String title to set
|
387
|
-
* @return String title or Dialog this
|
388
|
-
*/
|
389
|
-
title: function(text) {
|
390
|
-
if (arguments.length) {
|
391
|
-
this.head.title.html(text);
|
392
|
-
return this;
|
393
|
-
} else {
|
394
|
-
return this.head.title.html();
|
395
|
-
}
|
396
|
-
},
|
397
|
-
|
398
|
-
/**
|
399
|
-
* Overloading the standard method, so that
|
400
|
-
* all the content updates were going into the body element
|
401
|
-
*
|
402
|
-
* @param mixed content
|
403
|
-
* @return Dialog this
|
404
|
-
*/
|
405
|
-
update: function(content) {
|
406
|
-
this.body.update(content);
|
407
|
-
return this.resize();
|
408
|
-
},
|
409
|
-
|
410
|
-
/**
|
411
|
-
* Redirecting the `html` method to work wiht the body html
|
412
|
-
*
|
413
|
-
* @param mixed content
|
414
|
-
* @return Dialog this or html content of the body
|
415
|
-
*/
|
416
|
-
html: function() {
|
417
|
-
return arguments.length ?
|
418
|
-
this.$super.apply(this, arguments) :
|
419
|
-
this.body.html();
|
420
|
-
},
|
421
|
-
|
422
|
-
/**
|
423
|
-
* Overloading the original method to bypass things into the body object
|
424
|
-
*
|
425
|
-
* @param String url
|
426
|
-
* @param Object options
|
427
|
-
* @return Dialog this
|
428
|
-
*/
|
429
|
-
load: function(url, options) {
|
430
|
-
this.show();
|
431
|
-
this.body.load(url, options);
|
432
|
-
return this;
|
433
|
-
},
|
434
|
-
|
435
|
-
/**
|
436
|
-
* Expands a dialog screen-wide
|
437
|
-
*
|
438
|
-
* @return Dialog this
|
439
|
-
*/
|
440
|
-
expand: function() {
|
441
|
-
if (!this.expanded) {
|
442
|
-
this._prevSize = this.size();
|
443
|
-
this.resize({
|
444
|
-
x: $(window).size().x - 20,
|
445
|
-
y: $(window).size().y - 10
|
446
|
-
});
|
447
|
-
|
448
|
-
this.expanded = true;
|
449
|
-
this.fire('expand');
|
450
|
-
}
|
451
|
-
|
452
|
-
return this;
|
453
|
-
},
|
454
|
-
|
455
|
-
/**
|
456
|
-
* Collapses an expanded dialog to it's previous size
|
457
|
-
*
|
458
|
-
* @return Dialog this
|
459
|
-
*/
|
460
|
-
collapse: function() {
|
461
|
-
if (this.expanded) {
|
462
|
-
this.expanded = false;
|
463
|
-
this.resize(this._prevSize);
|
464
|
-
this.fire('collapse');
|
465
|
-
}
|
466
|
-
|
467
|
-
return this;
|
468
|
-
}
|
469
|
-
});
|
470
|
-
|
471
|
-
/**
|
472
|
-
* Dialog header line element
|
473
|
-
*
|
474
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
475
|
-
*/
|
476
|
-
Dialog.Head = new Class(Element, {
|
477
|
-
|
478
|
-
initialize: function(dialog) {
|
479
|
-
this.dialog = dialog;
|
480
|
-
this.options = dialog.options;
|
481
|
-
|
482
|
-
this.$super('div', {'class': 'rui-dialog-head'});
|
483
|
-
|
484
|
-
this.append(
|
485
|
-
this.icon = $E('div', {'class': 'icon'}),
|
486
|
-
this.title = $E('div', {'class': 'title', 'html': ' '}),
|
487
|
-
this.tools = $E('div', {'class': 'tools'})
|
488
|
-
);
|
489
|
-
|
490
|
-
this.fsButton = $E('div', {
|
491
|
-
'class': 'expand', 'html': '≡', 'title': Dialog.i18n.Expand
|
492
|
-
}).onClick(function() {
|
493
|
-
if (dialog.expanded) {
|
494
|
-
dialog.collapse();
|
495
|
-
this.html('≡').set('title', Dialog.i18n.Expand);
|
496
|
-
} else {
|
497
|
-
dialog.expand();
|
498
|
-
this.html('_').set('title', Dialog.i18n.Collapse);
|
499
|
-
}
|
500
|
-
});
|
501
|
-
|
502
|
-
this.closeButton = $E('div', {
|
503
|
-
'class': 'close', 'html': '×', 'title': Dialog.i18n.Close
|
504
|
-
}).onClick(function() { dialog.fire('cancel'); });
|
505
|
-
|
506
|
-
if (this.options.expandable) {
|
507
|
-
this.tools.insert(this.fsButton);
|
508
|
-
}
|
509
|
-
|
510
|
-
if (this.options.closeable) {
|
511
|
-
this.tools.insert(this.closeButton);
|
512
|
-
}
|
513
|
-
|
514
|
-
this.on({
|
515
|
-
selectstart: function(e) { e.stop(); },
|
516
|
-
mousedown: this.dragStart
|
517
|
-
});
|
518
|
-
|
519
|
-
if (!this.options.draggable) {
|
520
|
-
this.dialog.addClass('rui-dialog-nodrag');
|
521
|
-
}
|
522
|
-
},
|
523
|
-
|
524
|
-
// protected
|
525
|
-
|
526
|
-
dragStart: function(event) {
|
527
|
-
if (this.options.draggable && !event.find('div.tools div')) {
|
528
|
-
var dim = this.dialog.dimensions(),
|
529
|
-
ev_pos = event.position();
|
530
|
-
|
531
|
-
this.xDiff = dim.left - ev_pos.x;
|
532
|
-
this.yDiff = dim.top - ev_pos.y;
|
533
|
-
this.maxX = $(window).size().x - dim.width - 20;
|
534
|
-
this.dlgStyle = this.dialog.get('style');
|
535
|
-
|
536
|
-
Dialog.dragged = this.dialog;
|
537
|
-
|
538
|
-
event.stop();
|
539
|
-
}
|
540
|
-
},
|
541
|
-
|
542
|
-
dragMove: function(event) {
|
543
|
-
var event_pos = event.position(),
|
544
|
-
pos_x = event_pos.x + this.xDiff,
|
545
|
-
pos_y = event_pos.y + this.yDiff;
|
546
|
-
|
547
|
-
if (pos_x < 0) { pos_x = 0; }
|
548
|
-
else if (pos_x > this.maxX) { pos_x = this.maxX; }
|
549
|
-
if (pos_y < 0) { pos_y = 0; }
|
550
|
-
|
551
|
-
this.dlgStyle.top = pos_y + 'px';
|
552
|
-
this.dlgStyle.left = pos_x + 'px';
|
553
|
-
},
|
554
|
-
|
555
|
-
dragStop: function(event) {
|
556
|
-
Dialog.dragged = false;
|
557
|
-
}
|
558
|
-
});
|
559
|
-
|
560
|
-
/**
|
561
|
-
* Dialog body element
|
562
|
-
*
|
563
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
564
|
-
*/
|
565
|
-
Dialog.Body = new Class(Element, {
|
566
|
-
|
567
|
-
initialize: function(dialog) {
|
568
|
-
this.dialog = dialog;
|
569
|
-
this.options = dialog.options;
|
570
|
-
|
571
|
-
this.$super('div', {'class': 'rui-dialog-body'});
|
572
|
-
this.locker = $E('div', {'class': 'rui-dialog-body-locker'})
|
573
|
-
.insert(new Spinner());
|
574
|
-
},
|
575
|
-
|
576
|
-
load: function(url, options) {
|
577
|
-
this.insert(this.locker, 'top');
|
578
|
-
|
579
|
-
this.xhr = new Xhr(url, Object.merge({method:'get'}, options))
|
580
|
-
.onComplete(R(function(r) {
|
581
|
-
this.update(r.text);
|
582
|
-
this.dialog.resize().fire('load');
|
583
|
-
}).bind(this))
|
584
|
-
.send();
|
585
|
-
|
586
|
-
return this;
|
587
|
-
},
|
588
|
-
|
589
|
-
update: function(content) {
|
590
|
-
this.$super(content);
|
591
|
-
|
592
|
-
if (this.options.showIcon) {
|
593
|
-
this.insert('<div class="rui-dialog-body-icon">'+ this.options.showIcon + '</div>', 'top');
|
594
|
-
}
|
595
|
-
|
596
|
-
return this;
|
597
|
-
}
|
598
|
-
|
599
|
-
});
|
600
|
-
|
601
|
-
/**
|
602
|
-
* Dialog footer line element
|
603
|
-
*
|
604
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
605
|
-
*/
|
606
|
-
Dialog.Foot = new Class(Element, {
|
607
|
-
|
608
|
-
initialize: function(dialog) {
|
609
|
-
this.$super('div', {'class': 'rui-dialog-foot'});
|
610
|
-
|
611
|
-
this.dialog = dialog;
|
612
|
-
|
613
|
-
dialog.okButton = new Button(Dialog.i18n.Ok, {'class': 'ok'}).onClick(function() { dialog.fire('ok'); });
|
614
|
-
dialog.helpButton = new Button(Dialog.i18n.Help, {'class': 'help'}).onClick(function() { dialog.fire('help'); });
|
615
|
-
dialog.cancelButton = new Button(Dialog.i18n.Cancel, {'class': 'cancel'}).onClick(function() { dialog.fire('cancel'); });
|
616
|
-
|
617
|
-
if (dialog.options.showHelp) {
|
618
|
-
this.insert(dialog.helpButton);
|
619
|
-
}
|
620
|
-
|
621
|
-
if (dialog.options.closeable) {
|
622
|
-
this.insert(dialog.cancelButton);
|
623
|
-
}
|
624
|
-
|
625
|
-
this.insert(dialog.okButton);
|
626
|
-
}
|
627
|
-
|
628
|
-
});
|
629
|
-
|
630
|
-
/**
|
631
|
-
* Alert specific dialog
|
632
|
-
*
|
633
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
634
|
-
*/
|
635
|
-
Dialog.Alert = new Class(Dialog, {
|
636
|
-
|
637
|
-
initialize: function(options) {
|
638
|
-
options = Object.merge({
|
639
|
-
showIcon: '!',
|
640
|
-
title: Dialog.i18n.Alert
|
641
|
-
}, options);
|
642
|
-
|
643
|
-
this.$super(options);
|
644
|
-
this.addClass('rui-dialog-alert');
|
645
|
-
this.on('ok', 'hide');
|
646
|
-
}
|
647
|
-
});
|
648
|
-
|
649
|
-
/**
|
650
|
-
* Confirm specific dialog
|
651
|
-
*
|
652
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
653
|
-
*/
|
654
|
-
Dialog.Confirm = new Class(Dialog, {
|
655
|
-
|
656
|
-
initialize: function(options) {
|
657
|
-
options = Object.merge({
|
658
|
-
showIcon: '?',
|
659
|
-
title: Dialog.i18n.Confirm
|
660
|
-
}, options);
|
661
|
-
|
662
|
-
this.$super(options);
|
663
|
-
this.addClass('rui-dialog-confirm');
|
664
|
-
this.on('ok', 'hide');
|
665
|
-
}
|
666
|
-
|
667
|
-
});
|
668
|
-
|
669
|
-
/**
|
670
|
-
* The prompt dialog class
|
671
|
-
*
|
672
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
673
|
-
*/
|
674
|
-
Dialog.Prompt = new Class(Dialog, {
|
675
|
-
/**
|
676
|
-
* prompts constructor, you can use additional options with this one
|
677
|
-
*
|
678
|
-
* * `label` - the text for the input field label
|
679
|
-
* * `input` - the input field options (standard for Input unit)
|
680
|
-
*
|
681
|
-
* @param Object options
|
682
|
-
* @return void
|
683
|
-
*/
|
684
|
-
initialize: function(options) {
|
685
|
-
options = Object.merge({
|
686
|
-
showIcon: '➥',
|
687
|
-
title: Dialog.i18n.Prompt,
|
688
|
-
label: Dialog.i18n.Prompt
|
689
|
-
}, options);
|
690
|
-
|
691
|
-
this.$super(options);
|
692
|
-
this.addClass('rui-dialog-prompt');
|
693
|
-
|
694
|
-
this.html([
|
695
|
-
$E('label', {html: this.options.label}),
|
696
|
-
this.input = new RightJS.Input(this.options.input || {})
|
697
|
-
]);
|
698
|
-
|
699
|
-
if (this.input.get('type') !== 'textarea') {
|
700
|
-
this.input.onKeydown(R(function(event) {
|
701
|
-
if (event.keyCode === 13) {
|
702
|
-
this.fire('ok');
|
703
|
-
}
|
704
|
-
}).bind(this));
|
705
|
-
}
|
706
|
-
},
|
707
|
-
|
708
|
-
show: function() {
|
709
|
-
this.$super.apply(this, arguments);
|
710
|
-
this.input.select();
|
711
|
-
return this;
|
712
|
-
}
|
713
|
-
|
714
|
-
});
|
715
|
-
|
716
|
-
/**
|
717
|
-
* Document level hooks for the dialogs
|
718
|
-
*
|
719
|
-
* Copyright (C) 2010 Nikolay Nemshilov
|
720
|
-
*/
|
721
|
-
$(document).on({
|
722
|
-
keydown: function(event) {
|
723
|
-
if (event.keyCode === 27 && Dialog.current) {
|
724
|
-
if (Dialog.current.options.closeable) {
|
725
|
-
Dialog.current.fire('cancel');
|
726
|
-
}
|
727
|
-
} else if (event.keyCode === 13 && Dialog.current) {
|
728
|
-
if (!(Dialog.current instanceof Dialog.Prompt)) {
|
729
|
-
event.stop();
|
730
|
-
Dialog.current.fire('ok');
|
731
|
-
}
|
732
|
-
}
|
733
|
-
},
|
734
|
-
|
735
|
-
mousemove: function(event) {
|
736
|
-
if (Dialog.dragged) {
|
737
|
-
Dialog.dragged.head.dragMove(event);
|
738
|
-
}
|
739
|
-
},
|
740
|
-
|
741
|
-
mouseup: function(event) {
|
742
|
-
if (Dialog.dragged) {
|
743
|
-
Dialog.dragged.head.dragStop(event);
|
744
|
-
}
|
745
|
-
}
|
746
|
-
});
|
747
|
-
|
748
|
-
$(window).onResize(function() {
|
749
|
-
if (Dialog.current) {
|
750
|
-
Dialog.current.resize();
|
751
|
-
}
|
752
|
-
});
|
753
|
-
|
754
|
-
var embed_style = document.createElement('style'),
|
755
|
-
embed_rules = document.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}");
|
756
|
-
|
757
|
-
embed_style.type = 'text/css';
|
758
|
-
document.getElementsByTagName('head')[0].appendChild(embed_style);
|
759
|
-
|
760
|
-
if(embed_style.styleSheet) {
|
761
|
-
embed_style.styleSheet.cssText = embed_rules.nodeValue;
|
762
|
-
} else {
|
763
|
-
embed_style.appendChild(embed_rules);
|
764
|
-
}
|
765
|
-
|
766
|
-
|
767
|
-
return Dialog;
|
768
|
-
})(RightJS);
|