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 Tabs v2.2.3
|
3
|
-
* http://rightjs.org/ui/tabs
|
4
|
-
*
|
5
|
-
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Tabs=RightJS.Tabs=function(a,b,c){function w(a,b,d){if(c.Cookie){var e=v();e=e.without.apply(e,b.map("id")),e.push(d.target.id),r.set("right-tabs-indexes",e.uniq().join(","),a)}}function v(){return f(c.Cookie?(r.get("right-tabs-indexes")||"").split(","):[])}function d(a,b){b||(b=a,a="DIV");var d=new c.Class(c.Element.Wrappers[a]||c.Element,{initialize:function(b,d){this.key=b;var e=[{"class":"rui-"+b}];this instanceof c.Input||this instanceof c.Form||e.unshift(a),this.$super.apply(this,e),c.isString(d)&&(d=c.$(d)),d instanceof c.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return c.Wrapper.Cache[c.$uid(this._)]=this},setOptions:function(a,b){b&&(a=c.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&c.Options.setOptions.call(this,c.Object.merge(this.options,a));return this}}),e=new c.Class(d,b);c.Observer.createShortcuts(e.prototype,e.EVENTS||c([]));return e}var e=new c.Class(c.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var b=0;b<(a||4);b++)this.dots.push(new c.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),c(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),f=c,g=c.$,h=c.$$,i=c.$w,j=c.$E,k=c.Fx,l=c.Object,m=c.Browser,n=c.isArray,o=c.isNumber,p=c.Class,q=c.Element,r=c.Cookie,s=new d("UL",{extend:{version:"2.2.3",EVENTS:i("select hide load disable enable add remove move"),Options:{idPrefix:"",tabsElement:null,resizeFx:"both",resizeDuration:400,scrollTabs:!1,scrollDuration:400,selected:null,disabled:null,closable:!1,loop:!1,loopPause:!0,url:!1,cache:!1,Xhr:null,Cookie:null},rescan:function(b){g(b||a).find(".rui-tabs,*[data-tabs]").each(function(a){a=a instanceof s?a:new s(a)})}},initialize:function(a,b){this.$super("tabs",a).setOptions(b).addClass("rui-tabs"),this.isHarmonica=this._.tagName==="DL",this.isCarousel=this.hasClass("rui-tabs-carousel"),this.isSimple=!this.isHarmonica&&!this.isCarousel,this.findTabs().initScrolls().findCurrent().setStyle("visibility:visible"),this.options.disabled&&this.disable(this.options.disabled),this.options.loop&&this.startLoop()},select:function(a){return this.callTab(a,"select")},disable:function(a){return this.callTab(a,"disable")},enable:function(a){return this.callTab(a,"enable")},current:function(){return this.tabs.first("current")},enabled:function(){return this.tabs.filter("enabled")},callTab:function(a,b){f(n(a)?a:[a]).each(function(a){o(a)&&(a=this.tabs[a]),a&&a instanceof t&&a[b]()},this);return this},findTabs:function(){this.tabsList=this.isHarmonica?this:g(this.options.tabsElement)||this.first(".rui-tabs-list")||(this.first("UL")||j("UL").insertTo(this)).addClass("rui-tabs-list"),this.tabs=f([]),this.tabsList.children(this.isHarmonica?"dt":null).map(function(a){this.tabs.push(new t(a,this))},this);for(var a=0,b=this.tabsList.get("childNodes");a<b.length;a++)b[a].nodeType==3&&this.tabsList._.removeChild(b[a]);return this}}),t=s.Tab=new p(q,{extend:{autoId:0},initialize:function(a,b){this.$super(a._),this.addClass("rui-tabs-tab"),this.main=b,this.link=this.first("a"),this.id=this.link.get("href").split("#")[1]||t.autoId++,this.panel=new u(this.findPanel(),this),this.current()&&this.select(),b.options.closable&&this.link.insert(j("div",{"class":"rui-tabs-tab-close-icon",html:"×"}).onClick(f(this.remove).bind(this))),this.onClick(this._clicked)},select:function(){if(this.enabled()){var a=this.main.current();a&&a.removeClass("rui-tabs-current").fire("hide"),this.addClass("rui-tabs-current"),this.main.scrollToTab(this),this.panel.show()}return this.fire("select")},disable:function(){return this.addClass("rui-tabs-disabled").fire("disable")},enable:function(){return this.removeClass("rui-tabs-disabled").fire("enable")},disabled:function(){return!this.enabled()},enabled:function(){return!this.hasClass("rui-tabs-disabled")},current:function(){return this.hasClass("rui-tabs-current")},remove:function(a){a&&a.stop();if(this.current()){var b=this.main.enabled(),c=b[b.indexOf(this)+1]||b[b.indexOf(this)-1];c&&c.select()}this.main.tabs.splice(this.main.tabs.indexOf(this),1),this.panel.remove();var d=this.parent();this.fire("beforeremove"),this.$super(),d.fire("remove",{target:this});return this},_clicked:function(a){a.stop();return this.select()},findPanel:function(){var a=this.main,b=a.options.idPrefix+this.id,c;if(a.isHarmonica){var d=this.next();c=d&&d._.tagName==="DD"?d:j("DD").insertTo(this,"after")}else c=g(b)||j(a._.tagName==="UL"?"LI":"DIV").insertTo(a);return c.set("id",b)},width:function(){var a=this.next();return a?a.position().x-this.position().x:this.size().x+1}}),u=s.Panel=new p(q,{initialize:function(a,b){this.$super(a._),this.addClass("rui-tabs-panel"),this.tab=b,this.id=this.get("id")},show:function(){return this.resizing(function(){this.tab.main.tabs.each(function(a){a.panel[a.panel===this?"addClass":"removeClass"]("rui-tabs-current")},this)})},update:function(a){this.tab.current()?this.resizing(function(){q.prototype.update.call(this,a||"")}):this.$super(a||"");return this},lock:function(){this.insert(this.locker(),"top")},resizing:function(a){var b=this.tab.main;if(b.__working)return this.resizing.bind(this,a).delay(100);var d=b.options,e=b.tabs.map("panel").first("hasClass","rui-tabs-current"),f=this,g=e!==f,h=this.first("div.rui-tabs-panel-locker");f.parent().hasClass("rui-tabs-resizer")&&f.insertTo(e.parent());if(d.resizeFx&&c.Fx&&e&&(g||h)){b.__working=!0;var i=function(){b.__working=!1},l=d.resizeFx==="both"&&h?"slide":d.resizeFx,m=d.resizeDuration;m=k.Durations[m]||m;var n=l==="fade"?0:l==="slide"?m:m/2,o=m-n;l!=="slide"&&f.setStyle({opacity:0});var p=b.isHarmonica&&g?0:e.size().y;a.call(this);var q=f.size().y,r=null,s=null,t=null;l!=="fade"&&p!==q?(b._.style.height=b.size().y+"px",r=j("div",{"class":"rui-tabs-resizer",style:"height: "+p+"px"}),b.isHarmonica&&g&&(e.addClass("rui-tabs-current"),s=j("div",{"class":"rui-tabs-resizer"}),s._.style.height=e.size().y+"px",t=function(){s.replace(e.removeClass("rui-tabs-current"))},e.wrap(s),r._.style.height="0px"),f.wrap(r),b._.style.height="auto"):(rezise_duration=0,m=o);var u=0,v=function(){if(r){if(l=="both"&&!u)return u++;r.replace(f)}i()};s&&s.morph({height:"0px"},{duration:n,onFinish:t}),r&&r.morph({height:q+"px"},{duration:n,onFinish:v}),l!=="slide"&&f.morph.bind(f,{opacity:1},{duration:o,onFinish:v}).delay(n),!r&&l==="slide"&&v()}else a.call(this);return this},locker:function(){return this._locker||(this._locker=j("div",{"class":"rui-tabs-panel-locker"}).insert(new e(5)))}});s.include({next:function(){return this.pickTab(+1)},prev:function(){return this.pickTab(-1)},scrollLeft:function(){this.prevButton.hasClass("rui-tabs-scroller-disabled")||this[this.isCarousel?"prev":"justScroll"](+.6);return this},scrollRight:function(){this.nextButton.hasClass("rui-tabs-scroller-disabled")||this[this.isCarousel?"next":"justScroll"](-.6);return this},initScrolls:function(){(this.scrollable=this.options.scrollTabs||this.isCarousel)&&this.buildScroller();return this},buildScroller:function(){if(!(this.prevButton=this.first(".rui-tabs-scroller-prev"))||!(this.nextButton=this.first(".rui-tabs-scroller-next")))this.prevButton=j("div",{"class":"rui-tabs-scroller-prev",html:"«"}),this.nextButton=j("div",{"class":"rui-tabs-scroller-next",html:"»"}),j("div").insertTo(this.tabsList,"before").replace(j("div",{"class":"rui-tabs-scroller"}).insert([this.prevButton,this.nextButton,this.scroller=j("div",{"class":"rui-tabs-scroller-body"}).insert(this.tabsList)])).remove();this.prevButton.onClick(f(this.scrollLeft).bind(this)),this.nextButton.onClick(f(this.scrollRight).bind(this))},pickTab:function(a){var b=this.current();if(b&&b.enabled()){var c=this.enabled(),d=c[c.indexOf(b)+a];d&&d.select()}},scrollToTab:function(a){if(this.scroller){var c=0;for(var d=0;d<this.tabs.length;d++){c+=this.tabs[d].width();if(this.tabs[d]===a)break}var e=this.scroller.size().x,f=(this.isCarousel?e/2+a.width()/2:e)-c;if(!this.isCarousel){var g=b(this.tabsList.getStyle("left")||0,10);f>=g&&f<g+e-a.width()?f=g:g>-c&&g<=a.width()-c&&(f=a.width()-c)}this.scrollTo(f)}},justScroll:function(a){if(!this.scroller)return this;var c=b(this.tabsList.getStyle("left")||0,10),d=this.scroller.size().x;this.scrollTo(c+d*a)},scrollTo:function(a){var b=this.scroller.size().x,c=this.tabs.map("width").sum();a<b-c&&(a=b-c),a>0&&(a=0),this.tabsList.morph({left:a+"px"},{duration:this.options.scrollDuration}),this.checkScrollButtons(c,b,a)},checkScrollButtons:function(a,b,c){var d=!1,e=!1;if(this.isCarousel){var f=this.enabled(),g=f.first("current");if(g){var h=f.indexOf(g);d=h>0,e=h<f.length-1}}else d=c!==0,e=c>b-a;this.prevButton[d?"removeClass":"addClass"]("rui-tabs-scroller-disabled"),this.nextButton[e?"removeClass":"addClass"]("rui-tabs-scroller-disabled")}}),s.include({findCurrent:function(){var a=this.enabled(),b=this.tabs[this.options.selected]||this.tabs[this.urlIndex()]||this.tabs[this.cookieIndex()]||a.first("current")||a[0];b&&b.select(),this.options.Cookie&&this.onSelect(f(w).curry(this.options.Cookie,this.tabs));return this},urlIndex:function(){var b=-1,c=a.location.href.split("#")[1];if(c)for(var d=0;d<this.tabs.length;d++)if(this.tabs[d].id==c){b=d;break}return b},cookieIndex:function(){var a=-1;if(this.options.Cookie){var b=v();for(var c=0;c<this.tabs.length;c++)if(b.include(this.tabs[c].id)){a=c;break}}return a}}),s.include({add:function(a,b,c){c=c||{};var d=j(this.isHarmonica?"dt":"li").insert(j("a",{html:a,href:c.url||"#"+(c.id||"")})).insertTo(this.tabsList),e=new t(d,this);e.panel.update(b||""),this.tabs.push(e),e.fire("add"),"position"in c&&this.move(e,c.position);return this},move:function(a,b){a=this.tabs[a]||a,this.tabs[b]&&this.tabs[b]!==a&&(this.tabs[b].insert(a,b===this.tabs.length-1?"after":"before"),this.isHarmonica&&a.insert(a.panel,"after"),this.tabs.splice(this.tabs.indexOf(a),1),this.tabs.splice(b,0,a),a.fire("move",{index:b}));return this},remove:function(a){return arguments.length===0?this.$super():this.callTab(a,"remove")}});var x=t.prototype.select;t.include({select:function(){if(this.dogPiling(arguments))return this;var a=x.apply(this,arguments),b=f(this.link.get("href")),d=this.main.options;b.includes("#")&&(b=d.url?d.url.replace("%{id}",b.split("#")[1]):null);if(b&&!this.request&&(!d.cache&&!this.cache)){this.panel.lock();try{this.request=(new c.Xhr(b,l.merge({method:"get"},d.Xhr))).onComplete(f(function(a){if(this.main.__working)return arguments.callee.bind(this,a).delay(100);this.panel.update(a.text),this.request=null,d.cache&&(this.cache=!0),this.fire("load")}).bind(this)).send()}catch(e){if(!m.OLD)throw e}}return a},dogPiling:function(a){if(this.main.__working){this.main.__timeout&&this.main.__timeout.cancel(),this.main.__timeout=f(function(a){this.select.apply(this,a)}).bind(this,a).delay(100);return!0}return this.main.__timeout=null}}),s.include({startLoop:function(a){if(!a&&!this.options.loop)return this;this.options.loopPause&&(this._stopLoop=this._stopLoop||f(this.stopLoop).bind(this,!0),this._startLoop=this._startLoop||f(this.startLoop).bind(this,a),this.forgetHovers().on({mouseover:this._stopLoop,mouseout:this._startLoop})),this.timer&&this.timer.stop(),this.timer=f(function(){var a=this.enabled(),b=this.current(),c=a[a.indexOf(b)+1];this.select(c||a.first())}).bind(this).periodical(this.options.loop||a);return this},stopLoop:function(a,b){this.timer&&(this.timer.stop(),this.timer=null),!b&&this._startLoop&&this.forgetHovers()},forgetHovers:function(){return this.stopObserving("mouseover",this._stopLoop).stopObserving("mouseout",this._startLoop)}}),g(a).onReady(function(){s.rescan()});var y=a.createElement("style"),z=a.createTextNode("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}.rui-tabs,.rui-tabs-list,.rui-tabs-tab,.rui-tabs-panel,.rui-tabs-scroll-left,.rui-tabs-scroll-right,.rui-tabs-scroll-body,.rui-tabs-panel-locker,.rui-tabs-resizer{margin:0;padding:0;background:none;border:none;list-style:none;display:block;width:auto;height:auto}.rui-tabs{display:block;visibility:hidden;border-bottom:1px solid #CCC}.rui-tabs-resizer{overflow:hidden}.rui-tabs-list{display:block;position:relative;padding:0 .5em;border-bottom:1px solid #CCC;white-space:nowrap}.rui-tabs-list .rui-tabs-tab,.rui-tabs-tab *,.rui-tabs-tab *:hover{display:inline-block; *display:inline; *zoom:1;cursor:pointer;text-decoration:none;vertical-align:center}.rui-tabs-list .rui-tabs-tab{vertical-align:bottom;margin-right:.1em}.rui-tabs-tab a{outline:none;position:relative;border:1px solid #CCC;background:#DDD;color:#444;padding:.3em 1em;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;border-bottom:none;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}.rui-tabs-tab a:hover{border-color:#CCC;background:#EEE}.rui-tabs-list .rui-tabs-current a,.rui-tabs-list .rui-tabs-current a:hover{font-weight:bold;color:#000;background:#FFF;border-bottom:1px solid #FFF;border-top-width:2px;padding-top:.34em;padding-bottom:.34em;top:1px}.rui-tabs-tab a img{border:none;opacity:.6;filter:alpha(opacity=60)}.rui-tabs-tab a:hover img,.rui-tabs-list .rui-tabs-current a img{opacity:1;filter:alpha(opacity=100)}.rui-tabs-disabled a,.rui-tabs-disabled a:hover{background:#EEE;border-color:#DDD;color:#AAA;cursor:default}.rui-tabs-disabled a img,.rui-tabs-disabled a:hover img{opacity:.5;filter:alpha(opacity=50)}.rui-tabs-tab-close-icon{display:inline-block; *display:inline; *zoom:1;margin-right:-0.5em;margin-left:0.5em;cursor:pointer;opacity:0.5;filter:alpha(opacity=50)}.rui-tabs-tab-close-icon:hover{opacity:1;filter:alpha(opacity=100);color:#B00;text-shadow:#888 .15em .15em .2em}.rui-tabs-panel{display:none;position:relative;min-height:4em;padding:.5em 0}.rui-tabs-current{display:block}.rui-tabs-scroller{position:relative;padding:0 1.4em}.rui-tabs-scroller-prev,.rui-tabs-scroller-next{width:1.1em;text-align:center;background:#EEE;color:#666;cursor:pointer;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;position:absolute;bottom:0px;left:0px;padding:0.3em 0;user-select:none;-moz-user-select:none;-webkit-user-select:none}.rui-tabs-scroller-prev:hover,.rui-tabs-scroller-next:hover{color:#000;background:#DDD;border-color:#AAA}.rui-tabs-scroller-prev:active,.rui-tabs-scroller-next:active{background:#eee;border-color:#ccc}.rui-tabs-scroller-next{left:auto;right:0px}.rui-tabs-scroller-disabled,.rui-tabs-scroller-disabled:hover{cursor:default;background:#DDD;border-color:#DDD;color:#AAA}.rui-tabs-scroller-body{overflow:hidden;width:100%;position:relative}.rui-tabs-scroller .rui-tabs-list{padding-left:0;padding-right:0;width:9999em;z-index:10}.rui-tabs-panel-locker{position:absolute;top:0px;left:0px;opacity:0.5;filter:alpha(opacity=50);background:#CCC;width:100%;height:100%;text-align:center}.rui-tabs-panel-locker .rui-spinner{position:absolute;left:44%;top:44%;background:none;border:none;height:2em}.rui-tabs-panel-locker .rui-spinner div{background:#666;width:.65em;margin-left:.15em}.rui-tabs-panel-locker .rui-spinner div.glowing{background:#000}.rui-tabs-carousel .rui-tabs-list{border:none}.rui-tabs-carousel .rui-tabs-tab a,.rui-tabs-carousel .rui-tabs-scroller .rui-tabs-scroller-prev,.rui-tabs-carousel .rui-tabs-scroller .rui-tabs-scroller-next{height:6em;line-height:6em;padding:0;border-bottom:1px solid #ccc;border-radius:.25em;-moz-border-radius:.25em;-webkit-border-radius:.25em}.rui-tabs-carousel .rui-tabs-tab{margin-right:3px}.rui-tabs-carousel .rui-tabs-tab a img{border:1px solid #CCC;vertical-align:middle;margin:.4em;padding:0;border-radius:0;-moz-border-radius:0;-webkit-border-radius:0}.rui-tabs-carousel .rui-tabs-list .rui-tabs-current a{border-width:1px;border-color:#AAA;padding:0;top:auto}.rui-tabs-carousel .rui-tabs-list .rui-tabs-current a img{border-color:#bbb}.rui-tabs-carousel .rui-tabs-panel{text-align:center}dl.rui-tabs{border:none}dt.rui-tabs-tab,dt.rui-tabs-tab a,dt.rui-tabs-tab a:hover{display:block;float:none}dt.rui-tabs-tab a,dt.rui-tabs-tab a:hover{padding:.2em 1em;border:1px solid #ccc;border-radius:.25em;-moz-border-radius:.3em;-webkit-border-radius:.3em}dl.rui-tabs dt.rui-tabs-current a{background:#EEE;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}dl.rui-tabs dd.rui-tabs-current+dt.rui-tabs-tab a{border-top-left-radius:0;border-top-right-radius:0;-moz-border-radius-topleft:0;-moz-border-radius-topright:0;-webkit-border-top-left-radius:0;-webkit-border-top-right-radius:0}");y.type="text/css",a.getElementsByTagName("head")[0].appendChild(y),y.styleSheet?y.styleSheet.cssText=z.nodeValue:y.appendChild(z);return s}(document,parseInt,RightJS)
|
@@ -1,745 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* RightJS-UI Tags v2.2.1
|
3
|
-
* http://rightjs.org/ui/tags
|
4
|
-
*
|
5
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
6
|
-
*/
|
7
|
-
var Tags = RightJS.Tags = (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
|
-
* The tags widget initialization script
|
109
|
-
*
|
110
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
111
|
-
*/
|
112
|
-
var R = RightJS,
|
113
|
-
$ = RightJS.$,
|
114
|
-
$w = RightJS.$w,
|
115
|
-
Class = RightJS.Class,
|
116
|
-
Input = RightJS.Input,
|
117
|
-
Element = RightJS.Element;
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
/**
|
124
|
-
* The main unit for the Tags widget
|
125
|
-
*
|
126
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
127
|
-
*/
|
128
|
-
var Tags = new Widget('INPUT', {
|
129
|
-
extend: {
|
130
|
-
version: '2.2.1',
|
131
|
-
|
132
|
-
EVENTS: $w('add remove'),
|
133
|
-
|
134
|
-
Options: {
|
135
|
-
tags: [], // the tags list
|
136
|
-
vertical: false, // use a vertical tags list
|
137
|
-
|
138
|
-
allowNew: true, // allow new tags to be created
|
139
|
-
nocase: true, // caseinsensitive
|
140
|
-
autocomplete: true, // autocomplete the user's input
|
141
|
-
|
142
|
-
separator: ',', // the tokens separator
|
143
|
-
|
144
|
-
cssRule: 'input[data-tags]' // the autoinitialization css-rule
|
145
|
-
},
|
146
|
-
|
147
|
-
/**
|
148
|
-
* Rescans and initializes the input elements in the area
|
149
|
-
*
|
150
|
-
* @param {Wrapper} optional scope
|
151
|
-
* @return void
|
152
|
-
*/
|
153
|
-
rescan: function(scope) {
|
154
|
-
$(scope || document).find(Tags.Options.cssRule).each(function(input) {
|
155
|
-
if (!(input instanceof Tags)) {
|
156
|
-
input = new Tags(input);
|
157
|
-
}
|
158
|
-
});
|
159
|
-
}
|
160
|
-
},
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Basic constructor
|
164
|
-
*
|
165
|
-
* @param {Input} element
|
166
|
-
* @param {Object} options
|
167
|
-
* @return void
|
168
|
-
*/
|
169
|
-
initialize: function(element, options) {
|
170
|
-
// trying to extract a plain list of tags
|
171
|
-
var tags = R(R(''+ $(element).get('data-tags')).trim());
|
172
|
-
|
173
|
-
if (tags.startsWith('[') && tags.endsWith(']')) {
|
174
|
-
if (!options) { options = {}; }
|
175
|
-
options.tags = new Function('return '+tags)();
|
176
|
-
}
|
177
|
-
|
178
|
-
this
|
179
|
-
.$super('tags', element)
|
180
|
-
.setOptions(options);
|
181
|
-
|
182
|
-
if (RightJS.Browser.OLD) {
|
183
|
-
this.setStyle({color: this.getStyle('backgroundColor')});
|
184
|
-
}
|
185
|
-
|
186
|
-
this.container = new Element('div', {'class': 'rui-tags'}).insertTo(this, 'after');
|
187
|
-
|
188
|
-
this.list = new Tags.List(this);
|
189
|
-
this.input = new Tags.Input(this);
|
190
|
-
this.completer = new Tags.Completer(this);
|
191
|
-
|
192
|
-
this.onFocus(function() { this.input.focus(); });
|
193
|
-
|
194
|
-
// reinitializing with default values
|
195
|
-
this.setValue(this._.value);
|
196
|
-
},
|
197
|
-
|
198
|
-
/**
|
199
|
-
* Overloading the method so that it updated the visible list as well
|
200
|
-
*
|
201
|
-
* @param {String|Array} string tokens
|
202
|
-
* @return {Tags} this
|
203
|
-
*/
|
204
|
-
setValue: function(tags) {
|
205
|
-
if (isString(tags)) {
|
206
|
-
tags = R(tags.split(this.options.separator))
|
207
|
-
.map('trim').reject('blank');
|
208
|
-
}
|
209
|
-
|
210
|
-
// merging the tags into the known list
|
211
|
-
this.options.tags = R(this.options.tags).merge(tags);
|
212
|
-
|
213
|
-
// repopulating the list
|
214
|
-
this.list.setTags(tags);
|
215
|
-
|
216
|
-
// setting the internal value
|
217
|
-
return this.$super(tags.join(this.options.separator + ' '));
|
218
|
-
}
|
219
|
-
});
|
220
|
-
|
221
|
-
|
222
|
-
/**
|
223
|
-
* The tags list element custom wrapper
|
224
|
-
*
|
225
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
226
|
-
*/
|
227
|
-
Tags.List = new Class(Element, {
|
228
|
-
|
229
|
-
/**
|
230
|
-
* Constructor, creates the list and places where it supposed to be
|
231
|
-
*
|
232
|
-
* @param {Tags} tags instance
|
233
|
-
* @return void
|
234
|
-
*/
|
235
|
-
initialize: function(main) {
|
236
|
-
this.main = main;
|
237
|
-
|
238
|
-
this.$super('ul', {'class': 'list'});
|
239
|
-
this.insertTo(main.container);
|
240
|
-
|
241
|
-
if (this.main.options.vertical) {
|
242
|
-
this.addClass('vertical');
|
243
|
-
}
|
244
|
-
|
245
|
-
function double_styles(name) {
|
246
|
-
return main.getStyle(name).replace(
|
247
|
-
/[\d\.]+/, function(m) { return parseFloat(m) * 2; }
|
248
|
-
);
|
249
|
-
}
|
250
|
-
|
251
|
-
this.setStyle({
|
252
|
-
fontSize: main.getStyle('fontSize'),
|
253
|
-
fontFamily: main.getStyle('fontFamily'),
|
254
|
-
fontWeight: main.getStyle('fontWeight'),
|
255
|
-
letterSpacing: main.getStyle('letterSpacing'),
|
256
|
-
paddingTop: double_styles('borderTopWidth'),
|
257
|
-
paddingLeft: double_styles('borderLeftWidth'),
|
258
|
-
paddingRight: double_styles('borderRightWidth'),
|
259
|
-
paddingBottom: main.getStyle('borderBottomWidth')
|
260
|
-
});
|
261
|
-
|
262
|
-
// frakking Opera '0em' sizes bug fallback
|
263
|
-
if (main.getStyle('fontSize') === '0em') {
|
264
|
-
this.setStyle({fontSize: '1em'});
|
265
|
-
}
|
266
|
-
|
267
|
-
this.setWidth(main.size().x);
|
268
|
-
this.reposition(true);
|
269
|
-
|
270
|
-
this.onClick(this._click);
|
271
|
-
},
|
272
|
-
|
273
|
-
/**
|
274
|
-
* Sets a list of tags
|
275
|
-
*
|
276
|
-
* @param {Array} tags
|
277
|
-
* @return {Tags.List} this
|
278
|
-
*/
|
279
|
-
setTags: function(tags) {
|
280
|
-
tags.uniq().each(this.clean().addTag, this);
|
281
|
-
|
282
|
-
return this;
|
283
|
-
},
|
284
|
-
|
285
|
-
/**
|
286
|
-
* Returns a list of tags on the list
|
287
|
-
*
|
288
|
-
* @return {Array} of tokens
|
289
|
-
*/
|
290
|
-
getTags: function() {
|
291
|
-
return this.find('div.text').map('text');
|
292
|
-
},
|
293
|
-
|
294
|
-
/**
|
295
|
-
* adds the tag to the list
|
296
|
-
*
|
297
|
-
* @param {String} tag
|
298
|
-
* @return {Tags.List} this
|
299
|
-
*/
|
300
|
-
addTag: function(tag) {
|
301
|
-
if (this._allowed(tag)) {
|
302
|
-
this
|
303
|
-
.append(
|
304
|
-
'<li>'+
|
305
|
-
'<div class="text">'+ R(tag).trim() +'</div>'+
|
306
|
-
'<div class="close">×</div>' +
|
307
|
-
'</li>'
|
308
|
-
).reposition();
|
309
|
-
|
310
|
-
this.main.fire('add', {tag: tag});
|
311
|
-
}
|
312
|
-
|
313
|
-
this.main._.value = this.getTags().join(
|
314
|
-
this.main.options.separator + ' '
|
315
|
-
);
|
316
|
-
|
317
|
-
return this;
|
318
|
-
},
|
319
|
-
|
320
|
-
/**
|
321
|
-
* Removes the last item from the list
|
322
|
-
*
|
323
|
-
* @return {Tags.List} this
|
324
|
-
*/
|
325
|
-
removeLast: function() {
|
326
|
-
var item = this.find('li').last();
|
327
|
-
|
328
|
-
if (item) {
|
329
|
-
this._remove(item);
|
330
|
-
}
|
331
|
-
|
332
|
-
return this;
|
333
|
-
},
|
334
|
-
|
335
|
-
/**
|
336
|
-
* Adjusts the original input field size and
|
337
|
-
* places the list right above it,
|
338
|
-
* in case if the list will start folding
|
339
|
-
*
|
340
|
-
* @return {Tags.List} this
|
341
|
-
*/
|
342
|
-
reposition: function(force) {
|
343
|
-
var size = this.size().y, main = this.main.size().y, style;
|
344
|
-
|
345
|
-
if (size !== main || force === true) {
|
346
|
-
this.main.setHeight(size);
|
347
|
-
|
348
|
-
style = this._.style;
|
349
|
-
|
350
|
-
style.top = '0px';
|
351
|
-
style.left = '0px';
|
352
|
-
|
353
|
-
size = this.position();
|
354
|
-
main = this.main.position();
|
355
|
-
|
356
|
-
style.top = main.y - size.y + 'px';
|
357
|
-
style.left = main.x - size.x + 'px';
|
358
|
-
}
|
359
|
-
|
360
|
-
return this;
|
361
|
-
},
|
362
|
-
|
363
|
-
// private
|
364
|
-
|
365
|
-
// catches the clicks on the list
|
366
|
-
_click: function(event) {
|
367
|
-
if (event.target.hasClass('close')) {
|
368
|
-
this._remove(event.target.parent());
|
369
|
-
} else {
|
370
|
-
this.main.input.focus();
|
371
|
-
}
|
372
|
-
},
|
373
|
-
|
374
|
-
// checks if the tag is allowed to be added to the list
|
375
|
-
_allowed: function(tag) {
|
376
|
-
var tags = this.getTags(),
|
377
|
-
options = this.main.options,
|
378
|
-
casesensitive = !options.nocase;
|
379
|
-
|
380
|
-
return !(casesensitive ? tags.include(tag) :
|
381
|
-
tags.map('toLowerCase').include(tag.toLowerCase())
|
382
|
-
) && (
|
383
|
-
options.allowNew || (
|
384
|
-
casesensitive ? tags.include(tag) :
|
385
|
-
options.tags.map('toLowerCase').include(tag.toLowerCase())
|
386
|
-
)
|
387
|
-
);
|
388
|
-
},
|
389
|
-
|
390
|
-
// removes an item out of the list
|
391
|
-
_remove: function(item) {
|
392
|
-
var tag = item.first('div.text').text();
|
393
|
-
|
394
|
-
this.main.setValue(
|
395
|
-
this.getTags().without(tag)
|
396
|
-
);
|
397
|
-
|
398
|
-
this.main.fire('remove', {tag: tag});
|
399
|
-
}
|
400
|
-
|
401
|
-
});
|
402
|
-
|
403
|
-
/**
|
404
|
-
* The 'fake' input field element
|
405
|
-
*
|
406
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
407
|
-
*/
|
408
|
-
Tags.Input = new Class(Input, {
|
409
|
-
|
410
|
-
/**
|
411
|
-
* Constructor
|
412
|
-
*
|
413
|
-
* @param {Tabs} the main object
|
414
|
-
* @return void
|
415
|
-
*/
|
416
|
-
initialize: function(main) {
|
417
|
-
this.main = main;
|
418
|
-
this.list = main.list;
|
419
|
-
|
420
|
-
this.$super({type: 'text', size: 1});
|
421
|
-
this.onKeydown(this._keydown);
|
422
|
-
this.onKeyup(this._keyup);
|
423
|
-
this.onBlur(this._blur);
|
424
|
-
this.insertTo(main.list);
|
425
|
-
|
426
|
-
// used to dynamically measure the size of the field
|
427
|
-
this.meter = new Element('div', {
|
428
|
-
'class': 'meter',
|
429
|
-
'style': {
|
430
|
-
whiteSpace: 'nowrap',
|
431
|
-
position: 'absolute',
|
432
|
-
left: '-99999em'
|
433
|
-
}
|
434
|
-
}).insertTo(this, 'after');
|
435
|
-
},
|
436
|
-
|
437
|
-
/**
|
438
|
-
* Inserting itself into the tags list on the 'focus' call
|
439
|
-
*
|
440
|
-
* @return {Tags.Input} this
|
441
|
-
*/
|
442
|
-
focus: function() {
|
443
|
-
this.main.list.append(this, this.meter).reposition();
|
444
|
-
return this.$super();
|
445
|
-
},
|
446
|
-
|
447
|
-
/**
|
448
|
-
* Resets the input field state
|
449
|
-
*
|
450
|
-
* @return {Tags.Input} this
|
451
|
-
*/
|
452
|
-
reset: function() {
|
453
|
-
this.remove();
|
454
|
-
this.meter.remove();
|
455
|
-
this.list.reposition();
|
456
|
-
this._.value = '';
|
457
|
-
|
458
|
-
return this;
|
459
|
-
},
|
460
|
-
|
461
|
-
// private
|
462
|
-
|
463
|
-
_keydown: function(event) {
|
464
|
-
if (event.keyCode === 8 && this._.value === '') {
|
465
|
-
this.list.removeLast(); // deleting the last tag with backspace
|
466
|
-
this.focus();
|
467
|
-
} else if (event.keyCode === 13) {
|
468
|
-
event.preventDefault(); // preventing the for to go off on Enter
|
469
|
-
}
|
470
|
-
},
|
471
|
-
|
472
|
-
_keyup: function(event) {
|
473
|
-
if (!R([9, 27, 37, 38, 39, 40, 13]).include(event.keyCode)) {
|
474
|
-
if (this._.value.indexOf(this.main.options.separator) !== -1) {
|
475
|
-
this._add();
|
476
|
-
this.focus();
|
477
|
-
} else {
|
478
|
-
this._resize();
|
479
|
-
this.main.completer.suggest(this._.value);
|
480
|
-
}
|
481
|
-
}
|
482
|
-
},
|
483
|
-
|
484
|
-
_blur: function(event) {
|
485
|
-
if (this.main.completer.hidden() && this._.value !== '') {
|
486
|
-
this._add();
|
487
|
-
this.reset();
|
488
|
-
}
|
489
|
-
},
|
490
|
-
|
491
|
-
// resizes the field to fit the text
|
492
|
-
_resize: function() {
|
493
|
-
this.meter.html(this._.value + 'xx');
|
494
|
-
this._.style.width = this.meter.size().x + 'px';
|
495
|
-
this.list.reposition();
|
496
|
-
},
|
497
|
-
|
498
|
-
// makes a tag out of the current value
|
499
|
-
_add: function() {
|
500
|
-
var value = this._.value.replace(this.main.options.separator, '');
|
501
|
-
this._.value = '';
|
502
|
-
|
503
|
-
if (!(/^\s*$/).test(value)) {
|
504
|
-
this.list.addTag(value);
|
505
|
-
}
|
506
|
-
|
507
|
-
if (this.main.completer.visible()) {
|
508
|
-
this.main.completer.hide();
|
509
|
-
}
|
510
|
-
}
|
511
|
-
|
512
|
-
});
|
513
|
-
|
514
|
-
/**
|
515
|
-
* The tags completer popup menu
|
516
|
-
*
|
517
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
518
|
-
*/
|
519
|
-
Tags.Completer = new Class(Element, {
|
520
|
-
|
521
|
-
extend: {
|
522
|
-
current: null // currently visible list reference
|
523
|
-
},
|
524
|
-
|
525
|
-
/**
|
526
|
-
* Constructor
|
527
|
-
*
|
528
|
-
* @param {Tags} main object
|
529
|
-
* @return void
|
530
|
-
*/
|
531
|
-
initialize: function(main) {
|
532
|
-
this.main = main;
|
533
|
-
this.list = main.list;
|
534
|
-
this.input = main.input;
|
535
|
-
|
536
|
-
this.$super('ul', {'class': 'completer'});
|
537
|
-
this.addClass('rui-dd-menu');
|
538
|
-
this.insertTo(main.container);
|
539
|
-
|
540
|
-
this.onClick(this._click);
|
541
|
-
},
|
542
|
-
|
543
|
-
/**
|
544
|
-
* Starts the suggesting process
|
545
|
-
*
|
546
|
-
*/
|
547
|
-
suggest: function(value) {
|
548
|
-
if (!(/^\s*$/).test(value) && this.main.options.autocomplete) {
|
549
|
-
var tags = this._filter(this.main.options.tags, value);
|
550
|
-
|
551
|
-
if (tags.length !== 0) {
|
552
|
-
this.html(tags.map(function(tag) {
|
553
|
-
return '<li>'+ tag.replace(value, '<b>'+ value + '</b>') +'</li>';
|
554
|
-
}).join(''));
|
555
|
-
|
556
|
-
this.picked = false;
|
557
|
-
|
558
|
-
return this.show();
|
559
|
-
}
|
560
|
-
}
|
561
|
-
|
562
|
-
return this.hide();
|
563
|
-
},
|
564
|
-
|
565
|
-
/**
|
566
|
-
* Overloading the method so it appeared right below the input field
|
567
|
-
*
|
568
|
-
* @return {Tags.Completer} this
|
569
|
-
*/
|
570
|
-
show: function() {
|
571
|
-
var input = this.input.dimensions(),
|
572
|
-
style = this._.style,
|
573
|
-
pos;
|
574
|
-
|
575
|
-
style.display = 'block';
|
576
|
-
|
577
|
-
style.top = '0px';
|
578
|
-
style.left = '0px';
|
579
|
-
|
580
|
-
pos = this.position();
|
581
|
-
|
582
|
-
style.left = input.left - pos.x + 'px';
|
583
|
-
style.top = input.top - pos.y + input.height + 'px';
|
584
|
-
|
585
|
-
return (Tags.Completer.current = this);
|
586
|
-
},
|
587
|
-
|
588
|
-
/**
|
589
|
-
* Hides the list of suggestions
|
590
|
-
*
|
591
|
-
* @return {Tags.Completer} this
|
592
|
-
*/
|
593
|
-
hide: function() {
|
594
|
-
this._.innerHTML = '';
|
595
|
-
this._.style.display = 'none';
|
596
|
-
|
597
|
-
Tags.Completer.current = null;
|
598
|
-
|
599
|
-
return this;
|
600
|
-
},
|
601
|
-
|
602
|
-
|
603
|
-
/**
|
604
|
-
* Highlights the next item on the list
|
605
|
-
*
|
606
|
-
* @return {Tags.Completer} this
|
607
|
-
*/
|
608
|
-
next: function() {
|
609
|
-
var item = this.first('.current');
|
610
|
-
|
611
|
-
if (item) { item = item.next(); }
|
612
|
-
if (!item) { item = this.first(); }
|
613
|
-
if (item) { item.radioClass('current'); }
|
614
|
-
|
615
|
-
return this;
|
616
|
-
},
|
617
|
-
|
618
|
-
/**
|
619
|
-
* Highlights the previous item on the list
|
620
|
-
*
|
621
|
-
* @return {Tags.Completer} this
|
622
|
-
*/
|
623
|
-
prev: function() {
|
624
|
-
var item = this.first('.current');
|
625
|
-
|
626
|
-
if (item) { item = item.prev(); }
|
627
|
-
if (!item) { item = this.children().last(); }
|
628
|
-
if (item) { item.radioClass('current'); }
|
629
|
-
|
630
|
-
return this;
|
631
|
-
},
|
632
|
-
|
633
|
-
/**
|
634
|
-
* Copies the picked item data into the input field
|
635
|
-
* and hides the list
|
636
|
-
*
|
637
|
-
* @return {Tags.Completer} this
|
638
|
-
*/
|
639
|
-
done: function() {
|
640
|
-
var item = this.first('.current');
|
641
|
-
|
642
|
-
if (item) {
|
643
|
-
this.list.addTag(item.text());
|
644
|
-
this.input.reset().focus();
|
645
|
-
}
|
646
|
-
|
647
|
-
return this.hide();
|
648
|
-
},
|
649
|
-
|
650
|
-
// private
|
651
|
-
|
652
|
-
// handles mouse clicks on the list
|
653
|
-
_click: function(event) {
|
654
|
-
var item = event.find('li');
|
655
|
-
|
656
|
-
if (item) {
|
657
|
-
item.radioClass('current');
|
658
|
-
}
|
659
|
-
|
660
|
-
this.done();
|
661
|
-
},
|
662
|
-
|
663
|
-
// finds an appropriate list of tags for the suggestion
|
664
|
-
_filter: function(tags, value) {
|
665
|
-
var used = this.list.getTags(),
|
666
|
-
nocase = this.main.options.nocase;
|
667
|
-
|
668
|
-
if (nocase) {
|
669
|
-
used = used.map('toLowerCase');
|
670
|
-
value = value.toLowerCase();
|
671
|
-
}
|
672
|
-
|
673
|
-
return tags.filter(function(tag) {
|
674
|
-
var low_tag = nocase ? tag.toLowerCase() : tag;
|
675
|
-
|
676
|
-
return low_tag.indexOf(value) !== -1 && !used.include(low_tag);
|
677
|
-
});
|
678
|
-
}
|
679
|
-
});
|
680
|
-
|
681
|
-
/**
|
682
|
-
* Document - on-load hook
|
683
|
-
*
|
684
|
-
* Copyright (C) 2011 Nikolay Nemshilov
|
685
|
-
*/
|
686
|
-
$(document).on({
|
687
|
-
/**
|
688
|
-
* Triggers autoinitialization when the document is loaded
|
689
|
-
*
|
690
|
-
* @return void
|
691
|
-
*/
|
692
|
-
ready: function() {
|
693
|
-
Tags.rescan();
|
694
|
-
},
|
695
|
-
|
696
|
-
/**
|
697
|
-
* Handles the suggestions list navigation
|
698
|
-
*
|
699
|
-
* @param {Event} event
|
700
|
-
* @return void
|
701
|
-
*/
|
702
|
-
keydown: function(event) {
|
703
|
-
var list = Tags.Completer.current,
|
704
|
-
keys = {
|
705
|
-
13: 'done', // Enter
|
706
|
-
27: 'hide', // Escape
|
707
|
-
38: 'prev', // Up
|
708
|
-
40: 'next' // Down
|
709
|
-
};
|
710
|
-
|
711
|
-
if (list !== null && event.keyCode in keys) {
|
712
|
-
event.stop();
|
713
|
-
list[keys[event.keyCode]]();
|
714
|
-
}
|
715
|
-
},
|
716
|
-
|
717
|
-
/**
|
718
|
-
* Hides the completer menu by an outer click
|
719
|
-
*
|
720
|
-
* @param {Event} click
|
721
|
-
* @return void
|
722
|
-
*/
|
723
|
-
click: function(event) {
|
724
|
-
if (Tags.Completer.current) {
|
725
|
-
Tags.Completer.current.hide();
|
726
|
-
}
|
727
|
-
}
|
728
|
-
|
729
|
-
});
|
730
|
-
|
731
|
-
var embed_style = document.createElement('style'),
|
732
|
-
embed_rules = document.createTextNode("*.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em}div.rui-tags,div.rui-tags ul.list,div.rui-tags ul.list *{position:static;top:auto;left:auto;right:auto;bottom:auto;float:none;margin:0;padding:0;border:none;background:none;display:block}input[data-tags],input.rui-tags{color:transparent;color:rgba(0,0,0,0)}div.rui-tags{position:absolute;display:inline}div.rui-tags ul.list{position:absolute;overflow:hidden;min-height:1.3em}div.rui-tags ul.list li{display:inline-block; *display:inline; *zoom:1;position:relative;cursor:default;margin-right:.1em;margin-bottom:.1em;padding:0 .5em;padding-right:1.1em;background:#ddd;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;vertical-align:top}div.rui-tags ul.list li div.text{position:inline}div.rui-tags ul.list li div.close{margin-left:.25em;cursor:pointer;font-family:Arial;font-weight:normal;opacity:0.5;position:absolute;right:.25em;top:0.04em}div.rui-tags ul.list li div.close:hover{opacity:1}div.rui-tags ul.vertical li{display:block}div.rui-tags ul.list input{width:auto;height:auto;display:inline-block; *display:inline; *zoom:1;width:1em;outline:none;vertical-align:top;font-family:inherit;font-size:inherit;font-weight:inherit;letter-spacing:inherit}");
|
733
|
-
|
734
|
-
embed_style.type = 'text/css';
|
735
|
-
document.getElementsByTagName('head')[0].appendChild(embed_style);
|
736
|
-
|
737
|
-
if(embed_style.styleSheet) {
|
738
|
-
embed_style.styleSheet.cssText = embed_rules.nodeValue;
|
739
|
-
} else {
|
740
|
-
embed_style.appendChild(embed_rules);
|
741
|
-
}
|
742
|
-
|
743
|
-
|
744
|
-
return Tags;
|
745
|
-
})(RightJS);
|