diff --git a/Gemfile b/Gemfile index b300784..2f3e68e 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gem 'sass-rails', '~> 4.0.2' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0' gem 'jquery-rails' +gem 'jquery-ui-rails', "4.0.5" gem 'turbolinks' #password diff --git a/app/assets/javascripts/basic.js b/app/assets/javascripts/basic.js new file mode 100755 index 0000000..0017ff5 --- /dev/null +++ b/app/assets/javascripts/basic.js @@ -0,0 +1,10 @@ +//= require jquery +//= require jquery_ujs + +//= require basic/bootstrap +//= require jquery.ui.tooltip +//= require basic/iscroll +//= require basic/orbit_js_1.0.1.js +//= require basic/jquery.nanoscroller.js +//= require basic/jquery.easing.1.3.js + diff --git a/app/assets/javascripts/basic/bootstrap.js b/app/assets/javascripts/basic/bootstrap.js new file mode 100755 index 0000000..33b2ce0 --- /dev/null +++ b/app/assets/javascripts/basic/bootstrap.js @@ -0,0 +1,2167 @@ +/* =================================================== + * bootstrap-transition.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#transitions + * =================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* CSS TRANSITION SUPPORT (http://www.modernizr.com/) + * ======================================================= */ + + $(function () { + + $.support.transition = (function () { + + var transitionEnd = (function () { + + var el = document.createElement('bootstrap') + , transEndEventNames = { + 'WebkitTransition' : 'webkitTransitionEnd' + , 'MozTransition' : 'transitionend' + , 'OTransition' : 'oTransitionEnd otransitionend' + , 'transition' : 'transitionend' + } + , name + + for (name in transEndEventNames){ + if (el.style[name] !== undefined) { + return transEndEventNames[name] + } + } + + }()) + + return transitionEnd && { + end: transitionEnd + } + + })() + + }) + +}(window.jQuery);/* ========================================================== + * bootstrap-alert.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* ALERT CLASS DEFINITION + * ====================== */ + + var dismiss = '[data-dismiss="alert"]' + , Alert = function (el) { + $(el).on('click', dismiss, this.close) + } + + Alert.prototype.close = function (e) { + var $this = $(this) + , selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + + e && e.preventDefault() + + $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) + + $parent.trigger(e = $.Event('close')) + + if (e.isDefaultPrevented()) return + + $parent.removeClass('in') + + function removeElement() { + $parent + .trigger('closed') + .remove() + } + + $.support.transition && $parent.hasClass('fade') ? + $parent.on($.support.transition.end, removeElement) : + removeElement() + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + var old = $.fn.alert + + $.fn.alert = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Constructor = Alert + + + /* ALERT NO CONFLICT + * ================= */ + + $.fn.alert.noConflict = function () { + $.fn.alert = old + return this + } + + + /* ALERT DATA-API + * ============== */ + + $(document).on('click.alert.data-api', dismiss, Alert.prototype.close) + +}(window.jQuery);/* ============================================================ + * bootstrap-button.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#buttons + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* BUTTON PUBLIC CLASS DEFINITION + * ============================== */ + + var Button = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, $.fn.button.defaults, options) + } + + Button.prototype.setState = function (state) { + var d = 'disabled' + , $el = this.$element + , data = $el.data() + , val = $el.is('input') ? 'val' : 'html' + + state = state + 'Text' + data.resetText || $el.data('resetText', $el[val]()) + + $el[val](data[state] || this.options[state]) + + // push to event loop to allow forms to submit + setTimeout(function () { + state == 'loadingText' ? + $el.addClass(d).attr(d, d) : + $el.removeClass(d).removeAttr(d) + }, 0) + } + + Button.prototype.toggle = function () { + var $parent = this.$element.closest('[data-toggle="buttons-radio"]') + + $parent && $parent + .find('.active') + .removeClass('active') + + this.$element.toggleClass('active') + } + + + /* BUTTON PLUGIN DEFINITION + * ======================== */ + + var old = $.fn.button + + $.fn.button = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('button') + , options = typeof option == 'object' && option + if (!data) $this.data('button', (data = new Button(this, options))) + if (option == 'toggle') data.toggle() + else if (option) data.setState(option) + }) + } + + $.fn.button.defaults = { + loadingText: 'loading...' + } + + $.fn.button.Constructor = Button + + + /* BUTTON NO CONFLICT + * ================== */ + + $.fn.button.noConflict = function () { + $.fn.button = old + return this + } + + + /* BUTTON DATA-API + * =============== */ + + $(document).on('click.button.data-api', '[data-toggle^=button]', function (e) { + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') + }) + +}(window.jQuery);/* ========================================================== + * bootstrap-carousel.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#carousel + * ========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* CAROUSEL CLASS DEFINITION + * ========================= */ + + var Carousel = function (element, options) { + this.$element = $(element) + this.options = options + this.options.pause == 'hover' && this.$element + .on('mouseenter', $.proxy(this.pause, this)) + .on('mouseleave', $.proxy(this.cycle, this)) + } + + Carousel.prototype = { + + cycle: function (e) { + if (!e) this.paused = false + this.options.interval + && !this.paused + && (this.interval = setInterval($.proxy(this.next, this), this.options.interval)) + return this + } + + , to: function (pos) { + var $active = this.$element.find('.item.active') + , children = $active.parent().children() + , activePos = children.index($active) + , that = this + + if (pos > (children.length - 1) || pos < 0) return + + if (this.sliding) { + return this.$element.one('slid', function () { + that.to(pos) + }) + } + + if (activePos == pos) { + return this.pause().cycle() + } + + return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos])) + } + + , pause: function (e) { + if (!e) this.paused = true + if (this.$element.find('.next, .prev').length && $.support.transition.end) { + this.$element.trigger($.support.transition.end) + this.cycle() + } + clearInterval(this.interval) + this.interval = null + return this + } + + , next: function () { + if (this.sliding) return + return this.slide('next') + } + + , prev: function () { + if (this.sliding) return + return this.slide('prev') + } + + , slide: function (type, next) { + var $active = this.$element.find('.item.active') + , $next = next || $active[type]() + , isCycling = this.interval + , direction = type == 'next' ? 'left' : 'right' + , fallback = type == 'next' ? 'first' : 'last' + , that = this + , e + + this.sliding = true + + isCycling && this.pause() + + $next = $next.length ? $next : this.$element.find('.item')[fallback]() + + e = $.Event('slide', { + relatedTarget: $next[0] + }) + + if ($next.hasClass('active')) return + + if ($.support.transition && this.$element.hasClass('slide')) { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $next.addClass(type) + $next[0].offsetWidth // force reflow + $active.addClass(direction) + $next.addClass(direction) + this.$element.one($.support.transition.end, function () { + $next.removeClass([type, direction].join(' ')).addClass('active') + $active.removeClass(['active', direction].join(' ')) + that.sliding = false + setTimeout(function () { that.$element.trigger('slid') }, 0) + }) + } else { + this.$element.trigger(e) + if (e.isDefaultPrevented()) return + $active.removeClass('active') + $next.addClass('active') + this.sliding = false + this.$element.trigger('slid') + } + + isCycling && this.cycle() + + return this + } + + } + + + /* CAROUSEL PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.carousel + + $.fn.carousel = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('carousel') + , options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option) + , action = typeof option == 'string' ? option : options.slide + if (!data) $this.data('carousel', (data = new Carousel(this, options))) + if (typeof option == 'number') data.to(option) + else if (action) data[action]() + else if (options.interval) data.cycle() + }) + } + + $.fn.carousel.defaults = { + interval: 5000 + , pause: 'hover' + } + + $.fn.carousel.Constructor = Carousel + + + /* CAROUSEL NO CONFLICT + * ==================== */ + + $.fn.carousel.noConflict = function () { + $.fn.carousel = old + return this + } + + /* CAROUSEL DATA-API + * ================= */ + + $(document).on('click.carousel.data-api', '[data-slide]', function (e) { + var $this = $(this), href + , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7 + , options = $.extend({}, $target.data(), $this.data()) + $target.carousel(options) + e.preventDefault() + }) + +}(window.jQuery);/* ============================================================= + * bootstrap-collapse.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#collapse + * ============================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* COLLAPSE PUBLIC CLASS DEFINITION + * ================================ */ + + var Collapse = function (element, options) { + this.$element = $(element) + this.options = $.extend({}, $.fn.collapse.defaults, options) + + if (this.options.parent) { + this.$parent = $(this.options.parent) + } + + this.options.toggle && this.toggle() + } + + Collapse.prototype = { + + constructor: Collapse + + , dimension: function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + , show: function () { + var dimension + , scroll + , actives + , hasData + + if (this.transitioning) return + + dimension = this.dimension() + scroll = $.camelCase(['scroll', dimension].join('-')) + actives = this.$parent && this.$parent.find('> .accordion-group > .in') + + if (actives && actives.length) { + hasData = actives.data('collapse') + if (hasData && hasData.transitioning) return + actives.collapse('hide') + hasData || actives.data('collapse', null) + } + + this.$element[dimension](0) + this.transition('addClass', $.Event('show'), 'shown') + $.support.transition && this.$element[dimension](this.$element[0][scroll]) + } + + , hide: function () { + var dimension + if (this.transitioning) return + dimension = this.dimension() + this.reset(this.$element[dimension]()) + this.transition('removeClass', $.Event('hide'), 'hidden') + this.$element[dimension](0) + } + + , reset: function (size) { + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + [dimension](size || 'auto') + [0].offsetWidth + + this.$element[size !== null ? 'addClass' : 'removeClass']('collapse') + + return this + } + + , transition: function (method, startEvent, completeEvent) { + var that = this + , complete = function () { + if (startEvent.type == 'show') that.reset() + that.transitioning = 0 + that.$element.trigger(completeEvent) + } + + this.$element.trigger(startEvent) + + if (startEvent.isDefaultPrevented()) return + + this.transitioning = 1 + + this.$element[method]('in') + + $.support.transition && this.$element.hasClass('collapse') ? + this.$element.one($.support.transition.end, complete) : + complete() + } + + , toggle: function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + } + + + /* COLLAPSE PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.collapse + + $.fn.collapse = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('collapse') + , options = typeof option == 'object' && option + if (!data) $this.data('collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.defaults = { + toggle: true + } + + $.fn.collapse.Constructor = Collapse + + + /* COLLAPSE NO CONFLICT + * ==================== */ + + $.fn.collapse.noConflict = function () { + $.fn.collapse = old + return this + } + + + /* COLLAPSE DATA-API + * ================= */ + + $(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) { + var $this = $(this), href + , target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + , option = $(target).data('collapse') ? 'toggle' : $this.data() + $this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed') + $(target).collapse(option) + + /* for Orbit */ + $this.parents('li').siblings().removeClass('active'); + $this.parents('li').toggleClass('active'); + if($('#filter').length) { + $this.parents('li').hasClass('active') ? $('#filter').addClass('open'):$('#filter').removeClass('open'); + } + + }) + +}(window.jQuery);/* ============================================================ + * bootstrap-dropdown.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#dropdowns + * ============================================================ + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* DROPDOWN CLASS DEFINITION + * ========================= */ + + var toggle = '[data-toggle=dropdown]' + , Dropdown = function (element) { + var $el = $(element).on('click.dropdown.data-api', this.toggle) + $('html').on('click.dropdown.data-api', function () { + $el.parent().removeClass('open') + }) + } + + Dropdown.prototype = { + + constructor: Dropdown + + , toggle: function (e) { + var $this = $(this) + , $parent + , isActive + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + clearMenus() + + if (!isActive) { + $parent.toggleClass('open') + } + + $this.focus() + + return false + } + + , keydown: function (e) { + var $this + , $items + , $active + , $parent + , isActive + , index + + if (!/(38|40|27)/.test(e.keyCode)) return + + $this = $(this) + + e.preventDefault() + e.stopPropagation() + + if ($this.is('.disabled, :disabled')) return + + $parent = getParent($this) + + isActive = $parent.hasClass('open') + + if (!isActive || (isActive && e.keyCode == 27)) return $this.click() + + $items = $('[role=menu] li:not(.divider):visible a', $parent) + + if (!$items.length) return + + index = $items.index($items.filter(':focus')) + + if (e.keyCode == 38 && index > 0) index-- // up + if (e.keyCode == 40 && index < $items.length - 1) index++ // down + if (!~index) index = 0 + + $items + .eq(index) + .focus() + } + + } + + function clearMenus() { + $(toggle).each(function () { + getParent($(this)).removeClass('open') + }) + } + + function getParent($this) { + var selector = $this.attr('data-target') + , $parent + + if (!selector) { + selector = $this.attr('href') + selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) + $parent.length || ($parent = $this.parent()) + + return $parent + } + + + /* DROPDOWN PLUGIN DEFINITION + * ========================== */ + + var old = $.fn.dropdown + + $.fn.dropdown = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('dropdown') + if (!data) $this.data('dropdown', (data = new Dropdown(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.dropdown.Constructor = Dropdown + + + /* DROPDOWN NO CONFLICT + * ==================== */ + + $.fn.dropdown.noConflict = function () { + $.fn.dropdown = old + return this + } + + + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + $(document) + .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) + .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) + .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() }) + .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) + .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) + +}(window.jQuery);/* ========================================================= + * bootstrap-modal.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#modals + * ========================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* MODAL CLASS DEFINITION + * ====================== */ + + var Modal = function (element, options) { + this.options = options + this.$element = $(element) + .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) + this.options.remote && this.$element.find('.modal-body').load(this.options.remote) + } + + Modal.prototype = { + + constructor: Modal + + , toggle: function () { + return this[!this.isShown ? 'show' : 'hide']() + } + + , show: function () { + var that = this + , e = $.Event('show') + + this.$element.trigger(e) + + if (this.isShown || e.isDefaultPrevented()) return + + this.isShown = true + + this.escape() + + this.backdrop(function () { + var transition = $.support.transition && that.$element.hasClass('fade') + + if (!that.$element.parent().length) { + that.$element.appendTo(document.body) //don't move modals dom position + } + + that.$element + .show() + + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + .attr('aria-hidden', false) + + that.enforceFocus() + + transition ? + that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown') }) : + that.$element.focus().trigger('shown') + + }) + } + + , hide: function (e) { + e && e.preventDefault() + + var that = this + + e = $.Event('hide') + + this.$element.trigger(e) + + if (!this.isShown || e.isDefaultPrevented()) return + + this.isShown = false + + this.escape() + + $(document).off('focusin.modal') + + this.$element + .removeClass('in') + .attr('aria-hidden', true) + + $.support.transition && this.$element.hasClass('fade') ? + this.hideWithTransition() : + this.hideModal() + } + + , enforceFocus: function () { + var that = this + $(document).on('focusin.modal', function (e) { + if (that.$element[0] !== e.target && !that.$element.has(e.target).length) { + that.$element.focus() + } + }) + } + + , escape: function () { + var that = this + if (this.isShown && this.options.keyboard) { + this.$element.on('keyup.dismiss.modal', function ( e ) { + e.which == 27 && that.hide() + }) + } else if (!this.isShown) { + this.$element.off('keyup.dismiss.modal') + } + } + + , hideWithTransition: function () { + var that = this + , timeout = setTimeout(function () { + that.$element.off($.support.transition.end) + that.hideModal() + }, 500) + + this.$element.one($.support.transition.end, function () { + clearTimeout(timeout) + that.hideModal() + }) + } + + , hideModal: function (that) { + this.$element + .hide() + .trigger('hidden') + + this.backdrop() + } + + , removeBackdrop: function () { + this.$backdrop.remove() + this.$backdrop = null + } + + , backdrop: function (callback) { + var that = this + , animate = this.$element.hasClass('fade') ? 'fade' : '' + + if (this.isShown && this.options.backdrop) { + var doAnimate = $.support.transition && animate + + this.$backdrop = $('
') + .appendTo(document.body) + + this.$backdrop.click( + this.options.backdrop == 'static' ? + $.proxy(this.$element[0].focus, this.$element[0]) + : $.proxy(this.hide, this) + ) + + if (doAnimate) this.$backdrop[0].offsetWidth // force reflow + + this.$backdrop.addClass('in') + + doAnimate ? + this.$backdrop.one($.support.transition.end, callback) : + callback() + + } else if (!this.isShown && this.$backdrop) { + this.$backdrop.removeClass('in') + + $.support.transition && this.$element.hasClass('fade')? + this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) : + this.removeBackdrop() + + } else if (callback) { + callback() + } + } + } + + + /* MODAL PLUGIN DEFINITION + * ======================= */ + + var old = $.fn.modal + + $.fn.modal = function (option) { + return this.each(function () { + var $this = $(this) + , data = $this.data('modal') + , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option) + if (!data) $this.data('modal', (data = new Modal(this, options))) + if (typeof option == 'string') data[option]() + else if (options.show) data.show() + }) + } + + $.fn.modal.defaults = { + backdrop: true + , keyboard: true + , show: true + } + + $.fn.modal.Constructor = Modal + + + /* MODAL NO CONFLICT + * ================= */ + + $.fn.modal.noConflict = function () { + $.fn.modal = old + return this + } + + + /* MODAL DATA-API + * ============== */ + + $(document).on('click.modal.data-api', '[data-toggle="modal"]', function (e) { + var $this = $(this) + , href = $this.attr('href') + , $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7 + , option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data()) + + e.preventDefault() + + $target + .modal(option) + .one('hide', function () { + $this.focus() + }) + }) + +}(window.jQuery); +/* =========================================================== + * bootstrap-tooltip.js v2.2.2 + * http://twitter.github.com/bootstrap/javascript.html#tooltips + * Inspired by the original jQuery.tipsy by Jason Frame + * =========================================================== + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function ($) { + + "use strict"; // jshint ;_; + + + /* TOOLTIP PUBLIC CLASS DEFINITION + * =============================== */ + + var Tooltip = function (element, options) { + this.init('tooltip', element, options) + } + + Tooltip.prototype = { + + constructor: Tooltip + + , init: function (type, element, options) { + var eventIn + , eventOut + + this.type = type + this.$element = $(element) + this.options = this.getOptions(options) + this.enabled = true + + if (this.options.trigger == 'click') { + this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) + } else if (this.options.trigger != 'manual') { + eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus' + eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur' + this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) + this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this)) + } + + this.options.selector ? + (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) : + this.fixTitle() + } + + , getOptions: function (options) { + options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data()) + + if (options.delay && typeof options.delay == 'number') { + options.delay = { + show: options.delay + , hide: options.delay + } + } + + return options + } + + , enter: function (e) { + var self = $(e.currentTarget)[this.type](this._options).data(this.type) + + if (!self.options.delay || !self.options.delay.show) return self.show() + + clearTimeout(this.timeout) + self.hoverState = 'in' + this.timeout = setTimeout(function() { + if (self.hoverState == 'in') self.show() + }, self.options.delay.show) + } + + , leave: function (e) { + var self = $(e.currentTarget)[this.type](this._options).data(this.type) + + if (this.timeout) clearTimeout(this.timeout) + if (!self.options.delay || !self.options.delay.hide) return self.hide() + + self.hoverState = 'out' + this.timeout = setTimeout(function() { + if (self.hoverState == 'out') self.hide() + }, self.options.delay.hide) + } + + , show: function () { + var $tip + , inside + , pos + , actualWidth + , actualHeight + , placement + , tp + + if (this.hasContent() && this.enabled) { + $tip = this.tip() + this.setContent() + + if (this.options.animation) { + $tip.addClass('fade') + } + + placement = typeof this.options.placement == 'function' ? + this.options.placement.call(this, $tip[0], this.$element[0]) : + this.options.placement + + inside = /in/.test(placement) + + $tip + .detach() + .css({ top: 0, left: 0, display: 'block' }) + .insertAfter(this.$element) + + pos = this.getPosition(inside) + + actualWidth = $tip[0].offsetWidth + actualHeight = $tip[0].offsetHeight + + switch (inside ? placement.split(' ')[1] : placement) { + case 'bottom': + tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2} + break + case 'top': + tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2} + break + case 'left': + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth} + break + case 'right': + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width} + break + } + + $tip + .offset(tp) + .addClass(placement) + .addClass('in') + } + } + + , setContent: function () { + var $tip = this.tip() + , title = this.getTitle() + + $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title) + $tip.removeClass('fade in top bottom left right') + } + + , hide: function () { + var that = this + , $tip = this.tip() + + $tip.removeClass('in') + + function removeWithAnimation() { + var timeout = setTimeout(function () { + $tip.off($.support.transition.end).detach() + }, 500) + + $tip.one($.support.transition.end, function () { + clearTimeout(timeout) + $tip.detach() + }) + } + + $.support.transition && this.$tip.hasClass('fade') ? + removeWithAnimation() : + $tip.detach() + + return this + } + + , fixTitle: function () { + var $e = this.$element + if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { + $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title') + } + } + + , hasContent: function () { + return this.getTitle() + } + + , getPosition: function (inside) { + return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), { + width: this.$element[0].offsetWidth + , height: this.$element[0].offsetHeight + }) + } + + , getTitle: function () { + var title + , $e = this.$element + , o = this.options + + title = $e.attr('data-original-title') + || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) + + return title + } + + , tip: function () { + return this.$tip = this.$tip || $(this.options.template) + } + + , validate: function () { + if (!this.$element[0].parentNode) { + this.hide() + this.$element = null + this.options = null + } + } + + , enable: function () { + this.enabled = true + } + + , disable: function () { + this.enabled = false + } + + , toggleEnabled: function () { + this.enabled = !this.enabled + } + + , toggle: function (e) { + var self = $(e.currentTarget)[this.type](this._options).data(this.type) + self[self.tip().hasClass('in') ? 'hide' : 'show']() + } + + , destroy: function () { + this.hide().$element.off('.' + this.type).removeData(this.type) + } + + } + + + /* TOOLTIP PLUGIN DEFINITION + * ========================= */ + + var old = $.fn.tooltip + + $.fn.tooltip = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('tooltip') + , options = typeof option == 'object' && option + if (!data) $this.data('tooltip', (data = new Tooltip(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.tooltip.Constructor = Tooltip + + $.fn.tooltip.defaults = { + animation: true + , placement: 'top' + , selector: false + , template: ''+$(this).data().title+'
'); + } + } + }) + $checked.each(function(i) { + if($(this).attr('type') == "checkbox") { + if($(this).data().disabled) { + console.log("d") + $(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled'); + if($(this).prop('checked')) { + $(this).parent('.togglebox').removeClass('disable').closest('li').removeClass('disabled'); + }; + } else { + if($(this).prop('checked')) { + $(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled'); + }; + } + $(this).on({ + change: function() { + $(this).parent('.togglebox').toggleClass('disable'); + $(this).closest('tr').toggleClass('disable'); + } + }); + }; + if($(this).attr('type') == "radio") { + if(!$(this).prop('checked')) { + $(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled'); + $(this).closest('tr').addClass('disable'); + }; + $(this).on({ + change: function() { + $checked.not($(".toggle-check[type='checkbox']")).each(function(i) { + if(!$(this).parent('.togglebox').hasClass('disable')) { + $(this).parent('.togglebox').toggleClass('disable'); + $(this).closest('tr').toggleClass('disable'); + }; + }); + $(this).parent('.togglebox').toggleClass('disable') + $(this).closest('tr').toggleClass('disable'); + } + }); + }; + if($('#sitemap').length) { + $(this).on({ + change: function() { + $(this).closest('li').toggleClass('disabled'); + if($(this).prop('checked')) { + $(this).attr('checked', 'checked'); + $(this).parents('h6') + .siblings('ul') + .find('li') + .addClass('disabled') + .find('h6 .togglebox') + .addClass('disable') + .find('input[type="checkbox"]') + .prop('checked', true) + .attr('checked', 'checked'); + } else { + $(this).removeAttr('checked'); + $(this).parents('h6') + .siblings('ul') + .find('li') + .removeClass('disabled') + .find('h6 .togglebox') + .removeClass('disable') + .find('input[type="checkbox"]') + .prop('checked', false) + .removeAttr('checked'); + }; + // $('.toggle-check').each(function(i) { + // var len = $(this).closest('ul').children('li').length, + // checLen = $(this).closest('ul').children('li').find('input[checked]').length, + // checLen = checLen - $(this).closest('ul').children('li').find('ul').find('input[checked]').length; + // if(len == checLen) { + // $(this).closest('ul') + // .parent('li') + // .addClass('disabled') + // .children('h6') + // .find('.togglebox') + // .addClass('disable') + // .find('input[type="checkbox"]') + // .prop('checked', true) + // .attr('checked', 'checked'); + // } else { + // $(this).closest('ul') + // .parent('li') + // .removeClass('disabled') + // .children('h6') + // .find('.togglebox') + // .removeClass('disable') + // .find('input[type="checkbox"]') + // .prop('checked', false) + // .removeAttr('checked'); + // }; + // }); + }, + }); + }; + }); + }; + + + // Search Clear + $.fn.searchClear = function (param){ + _defaultSettings = { + inputName: ':input', + inputIcon: 'inputIcon', + clearBtnIcon: 'clearBtnIcon', + liveFilter: false, + }; + _set = $.extend(_defaultSettings, param); + $this = this; + $input = this.find(_set.inputName); + $tmp = ''; + $input.wrap(''); + $this.find('.sc-field').prepend($tmp); + $searchClear = $this.find(".search-clear"); + function run(e) { + $searchClear.hide(); + $($input).each(function() { + if($(this).val().length > 0) { + $(this).prev($searchClear).show(); + }else { + $(this).prev($searchClear).hide(); + } + $(this).on("blur keyup", function(){ + if($(this).val().length > 0) { + $(this).prev($searchClear).show(); + }else { + $(this).prev($searchClear).hide(); + } + }); + if(_set.liveFilter) { + $(this).prevAll($searchClear).on({ + click: function(){ + $(this).hide(); + $(this).next($input).val(""); + $('.checkbox-card .mark').removeClass('mark') + }, + }); + } else { + $(this).prevAll($searchClear).on({ + click: function(){ + $(this).hide(); + $(this).next($input).val(""); + }, + }); + } + }); + } + + // Checking IE10 + // if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right + if(/Windows NT 6.2/g.test(navigator.userAgent)){ + if(/MSIE/g.test(navigator.userAgent)){ + $searchClear.remove(); + $input.css({ + 'padding-right': '5px', + }); + }else{run()} + }else{run()} + } + + + // Fixed Nav + fixedNav = function () { + if($('.fixed-nav').length){ + var $fixedNav = $('.fixed-nav'); + if($sidebarState){ + $fixedNav.addClass('open'); + } + $fixedNav.on(clickEvent, function() { + if($sidebarState) { + window.localStorage.removeItem('sidebarState'); + $fixedNav.removeClass('open'); + }else{ + window.localStorage.setItem('sidebarState', 1); + $fixedNav.addClass('open'); + } + $sidebarState = window.localStorage.getItem('sidebarState') + }); + } + }; + + + // Sidebar + sidebarNav = function () { + var $sidebar = $('#sidebar'), + $sidebarMenu = $('#sidebar-menu'), + $scroller = $('.scroller'), + $sidebarNav = $('.sidebar-nav'), + $el = $('.sidebar-nav').children('li'), + $elIndex = null, + $blockList = $('.sub-nav-block-list'), + $block = $('.sub-nav-block'), + $blockIndex = 0, + $arrow = $('.sub-nav-arrow'), + $wrap = $('#main-wrap'), + $wrapLeft = $wrap.css('margin-left'), + $position = $arrow.outerHeight(true)*-1, + $arrowHeightFormat = $arrow.outerHeight(true)/2; + if($('#sidebar').length>0) { + $wrap.css({'margin-left': 61}); + $wrapLeft = 61; + } + if($el.hasClass('active')) { + // Menu defaults active + $elIndex = $el.filter('.active').index(); + if($sidebarState && !$sidebarNav.hasClass('no-sub-nav')) { + $block.eq($elIndex).addClass('show'); + $blockList.css({'width': 180}); + $wrap.css({ + 'margin-left': 241, + }); + } + + // Arrow defaults position + $position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top; + $arrow.css({ + 'top': $position, + }); + } + if($.support.touch && !$sidebarNav.hasClass('no-sub-nav')) { + $el.find('a').removeAttr('href'); + }; + $el.on(mouseenterEvent, function(e) { + $block.siblings().removeClass('show').eq($(this).index()).addClass('show'); + $arrow.stop(true, false).animate({ + top: ($(this).position().top+$(this).height()/2)-$arrowHeightFormat+$('.scroller').position().top, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + if(!$sidebarState || !$el.hasClass('active')) { + $blockList.css({'width': 180}); + if($('#pageslide').length) { + if($('#pageslide').is(":hidden")) { + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + }else{ + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + // if($('.topnav').length) { + // $('.topnav').css({ + // 'left': $blockList.width()+$sidebarNav.width()+20, + // }); + // } + if($('.bottomnav').length) { + $('.bottomnav').css({ + 'left': $blockList.width()+$sidebarNav.width()+20, + }); + } + $sidebar.css({ + 'width': $blockList.width()+$sidebarNav.width(), + }); + } + }); + if ($sidebarNav.hasClass('no-sub-nav')) { + $sidebar.on('mouseleave', function() { + $arrow.stop(true, false).animate({ + 'top': $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + }) + }; + // $el.on('mouseleave', function() { + // $el.hasClass('active') ? $position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top; + // $(this).hasClass('active') ? '':$(this).children('span').removeClass('hover'); + // }); + $block.on({ + mouseenter: function() { + $blockIndex = $block.filter('.sub-nav-block show').index(); + $el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').addClass('hover'); + }, + mouseleave: function() { + $block.removeClass('show'); + if(!$sidebarState || !$el.hasClass('active')) { + $blockList.css({'width': 0}); + if($('#pageslide').length) { + if($('#pageslide').is(":hidden")) { + $wrap.css({ + 'margin-left': $wrapLeft, + }); + // if($('.topnav').length) { + // if($sidebarState) { + // $('.topnav').css({ + // 'left': 261, + // }); + // } + // } + } + } else { + $wrap.css({ + 'margin-left': $blockList.width()+$sidebarNav.width(), + }); + } + // if($('.topnav').length) { + // $('.topnav').css({ + // 'left': $blockList.width()+$sidebarNav.width()+20, + // }); + // } + if($('.bottomnav').length) { + $('.bottomnav').css({ + 'left': $blockList.width()+$sidebarNav.width()+20, + }); + } + $sidebar.css({'width': 61}); + }else{ + $block.eq($elIndex).addClass('show'); + }; + + + if($elIndex === null) { + $position = $arrow.outerHeight(true)*-1; + } else { + $position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top; + } + $arrow.stop(true, false).animate({ + top: $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + } + }); + // Touch Start + $wrap.on({ + touchstart: function() { + if(!$sidebarState || !$el.hasClass('active')) { + if($block.hasClass('show')) { + $blockIndex = $block.filter('.sub-nav-block show').index(); + $block.removeClass('show'); + $blockList.css({'width': 0}); + $wrap.css({ + 'margin-left': $wrapLeft, + }); + $sidebar.css({'width': 61}); + $arrow.stop().animate({ + top: $position, + },{ + duration: 500, + easing: 'easeInOutBack', + }); + $el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').removeClass('hover'); + } + } + } + }); + // Sidebar Nav Drag + if(/MSIE 8.0/g.test($ua)){ + $arrow.remove(); + $sidebarMenu.addClass('nano') + .children('.scroller') + .addClass('content') + .removeClass('scroller'); + $sidebarMenu.nanoScroller({ scrollTop: 0 }); + } else { + if($('#sidebar').length) { + var sidebarMenu = new iScroll('sidebar-menu', { + vScrollbar: true, + scrollbarClass: 'myScrollbar', + onBeforeScrollStart: function (e) { + var target = e.target; + clearTimeout(this.hoverTimeout); + while (target.nodeName != "SPAN") target = target.parentNode; + $target = $(target.parentNode).index(); + }, + touch: function () { + if (this.hoverTarget) { + clearTimeout(this.hoverTimeout); + $('.sub-nav-block').removeClass('show') + $('.sub-nav-block').eq($target).addClass('show') + } + }, + }); + } + }; + }; + + + + // Initial State + initialState = function () { + if($('.bottomnav').length) { + var $bottomnavHeight = $('.bottomnav').outerHeight(); + $('.wrap-inner').css({ + 'padding-bottom': $bottomnavHeight, + }) + if($sidebarState) { + if(!$('.sidebar-nav').hasClass('no-sub-nav')) { + if($('#basic-info').length) { + $('.bottomnav').css({ + 'left': 631, + }); + } else { + $('.bottomnav').css({ + 'left': 261, + }); + } + } + } + } + // if($('.topnav').length) { + // if($sidebarState) { + // $('.topnav').css({ + // 'left': 261, + // }); + // } + // } + }; + $.fn.delayKeyup = function(callback, ms){ + var timer = 0; + $(this).keyup(function(){ + clearTimeout (timer); + timer = setTimeout(callback, ms); + }); + return $(this); + }; +}(window.jQuery); + + +var ini = function() { + api = this + api.modal = function(e) { + $('#dialog a.delete-item').attr("href", e); + $('#dialog').modal('show'); + } + +} + +var ini = function() { + api = this + api.modal = function(e) { + $('#dialog a.delete-item').attr("href", e); + $('#dialog').modal('show'); + } + +} + +// Open Slide +function openSlide() { + var $openSlide = $('.open-slide'); + typeof customOpenSlide === 'function' ? customOpenSlide($openSlide) : $openSlide.pageslide(); +} + +function formTip() { + if($('.main-forms').length && $('.add-on').length || $('.phtot-action').length) { + $('.main-forms .add-on, .main-forms .file-link, .phtot-action li').tooltip({ + position: { + my: "center bottom-4", + at: "center top" + } + }); + } + if($('.no-sub-nav').length) { + $('.no-sub-nav li').tooltip({ + position: { + my: "left+20 center", + at: "right center" + }, + track: true, + tooltipClass: "sidebar-tooltip", + }); + } +} +function changeStatusHidden() { + $('#status').find('label.checkbox').each(function() { + $(this).find('input[type="hidden"]').clone().appendTo($(this)); + $(this).find('input[type="hidden"]').eq(0).remove(); + $(this).find('input[type="checkbox"]').after + }); +}; + + +// Document Ready +$(function() { + showFiltersOnPageRefresh(); + + new ini(); + $('#main-wrap').on('click', '.delete', function() { + api.modal($(this).attr('rel')); + }) + initialState(); + $('#login').on('shown', function () { + $(document.body).addClass('modalBlur'); + $('#login').focusFirstField(); + }).on("hide", function() { + $(document.body).removeClass('modalBlur'); + }); + $('#orbit-bar .searchClear').searchClear({ + inputName: '.search-query', + inputIcon: 'icon-search', + clearBtnIcon: 'icons-cross-3', + + }); + $('#filter .searchClear').searchClear({ + inputName: '.search-query', + inputIcon: 'icon-search', + clearBtnIcon: 'icons-cross-3', + liveFilter: true, + }); + $('#member-filter').on('shown', function() { + $(this).find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true }); + }); + if($('#sidebar').length) { + if(!/MSIE 8.0/g.test(navigator.userAgent)){ + document.getElementById('sidebar').addEventListener('touchmove', function (e) { e.preventDefault(); }, false); + } + } + if($('#pageslide').length) { + openSlide(); + } + if($('.tags').length) { + $('#filter-input').fastLiveFilter('#tags-list', '.filter-item', '.tag'); + } + if($('#card-list').length) { + $('#filter-input').fastLiveFilter('#card-list', '.filter-item', '.user-name'); + } + if($('.toggle-check').length) { + $('.toggle-check').togglebox(); + } + if($('#status').length) { + changeStatusHidden(); + } + formTip() + sidebarNav(); +}); + +var showFiltersOnPageRefresh = function(){ + var params = getUrlVars(), + paramfilter = params['new_filter[type]']; + + // switch (paramfilter){ + // case "role": + // paramfilter = "status"; + // break; + // } + + if( paramfilter ){ + $( "#filter" ).addClass('open'); + $( '#filter a[href="#collapse-' + paramfilter + '"]').parent().parent().addClass('active'); + $( '#filter #collapse-' + paramfilter ).addClass('in'); + } +} + +var getUrlVars = function(){ + var vars = [], hash; + var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for(var i = 0; i < hashes.length; i++){ + hash = hashes[i].split('='); + vars.push(decodeURIComponent(hash[0])); + vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]); + } + if(vars[0] == window.location.href){ + vars =[]; + } + return vars; +} diff --git a/app/assets/javascripts/lib/ad_banner/banner_preview.js b/app/assets/javascripts/lib/ad_banner/banner_preview.js new file mode 100755 index 0000000..d740ebe --- /dev/null +++ b/app/assets/javascripts/lib/ad_banner/banner_preview.js @@ -0,0 +1,81 @@ +function slideshow (element, bannerEffect, bannerTime, bannerSpeed) { + element.cycle('destroy'); + element.children('img').removeAttr('class');; + element.cycle({ + fx: bannerEffect, + timeout: bannerTime, + speed: bannerSpeed, + }); +}; +function setSlideshow(element, data) { + $("#pageslide .ad_banner_ad_fx").children('option:selected').each(function(index, el) { + $(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide(); + }); + slideshow(element, data['fx'], 2000, 1000); +} + +function preview() { + $('.open-modal').on('click', function() { + var _data = $(this).data(); + bannerName = _data.name; + bannerEffect = _data.fx; + bannerTime = _data.time; + bannerSpeed = _data.speed; + bannerW = _data.w; + bannerH = _data.h; + $('#preview').modal('show'); + }); + + $('#preview').on('shown', function() { + $(this).attr('aria-labelledby', bannerName.toString()).find('h3').text(bannerName.toString()) + if(bannerW > 500) { + var resize = 500/bannerW + bannerW = Math.floor(bannerW*resize); + bannerH = Math.floor(bannerH*resize); + console.log(bannerW) + }; + if(bannerH > 300) { + var resize = 300/bannerH + bannerW = Math.floor(bannerW*resize); + bannerH = Math.floor(bannerH*resize); + } + slideshow($(this).find('.preview'), bannerEffect, bannerTime, bannerSpeed); + $(this).find('.preview').css({ + 'width': bannerW, + 'height': bannerH + }); + $(this).find('.preview img').css({ + 'width': '100%', + 'height': '100%' + }); + }); + $('#preview').on('hidden', function() { + $(this).attr('aria-labelledby', '').find('h3').text('') + $(this).find('.preview').cycle('destroy'); + $(this).find('.preview img').removeAttr('style'); + }); +}; + +$(function() { + var bannerName = null, + bannerEffect = null, + bannerTime = null, + bannerSpeed = null, + bannerW = null, + bannerH = null, + $preview = $('#pageslide .preview'); + + $(".ad_banner_ad_fx").change(function () { + var suckIE = false; + // bannerTime = $("#pageslide #timeout").val()*1000; + // bannerSpeed = $("#pageslide #speed").val()*1000; + + bannerTime = parseInt(bannerTime) || 300; + bannerSpeed = parseInt(bannerSpeed) || 300; + $(this).children('option:selected').each(function(index, el) { + $(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide(); + }); + slideshow($preview, $(this).val(), 2000, 1000); + }); + preview(); +}); diff --git a/app/assets/javascripts/lib/all-list.js b/app/assets/javascripts/lib/all-list.js new file mode 100755 index 0000000..2af073d --- /dev/null +++ b/app/assets/javascripts/lib/all-list.js @@ -0,0 +1,3 @@ +$(function(){ + $('.main-list').footable(); +}); \ No newline at end of file diff --git a/app/assets/javascripts/lib/bootstrap-datetimepicker.js b/app/assets/javascripts/lib/bootstrap-datetimepicker.js new file mode 100755 index 0000000..a4ff68b --- /dev/null +++ b/app/assets/javascripts/lib/bootstrap-datetimepicker.js @@ -0,0 +1,1293 @@ +/** + * @license + * ========================================================= + * bootstrap-datetimepicker.js + * http://www.eyecon.ro/bootstrap-datepicker + * ========================================================= + * Copyright 2012 Stefan Petre + * + * Contributions: + * - Andrew Rowls + * - Thiago de Arruda + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================= + */ + +(function($) { + + // Picker object + var smartPhone = (window.orientation != undefined); + var DateTimePicker = function(element, options) { + this.id = dpgId++; + this.init(element, options); + }; + + DateTimePicker.prototype = { + constructor: DateTimePicker, + + init: function(element, options) { + var icon; + if (!(options.pickTime || options.pickDate)) + throw new Error('Must choose at least one picker'); + this.options = options; + this.$element = $(element); + this.language = options.language in dates ? options.language : 'en' + this.pickDate = options.pickDate; + this.pickTime = options.pickTime; + this.isInput = this.$element.is('input'); + // this.component = this.$element.is('.input-prepend') ? this.$element.find('.iconbtn') : false; + this.component = this.$element.is('.input-append') ? this.$element.find('.iconbtn') : false; + this.clearDate = this.$element.is('.input-append') ? this.$element.find('.clearDate') : false; + this.format = options.format; + if (!this.format) { + if (this.isInput) this.format = this.$element.data('format'); + else this.format = this.$element.find('input').data('format'); + if (!this.format) this.format = 'MM/dd/yyyy'; + } + this._compileFormat(); + if (this.component) { + icon = this.component.find('i'); + } + if (this.pickTime) { + if (icon && icon.length) this.timeIcon = icon.data('time-icon'); + if (!this.timeIcon) this.timeIcon = 'icon-time'; + icon.addClass(this.timeIcon); + } + if (this.pickDate) { + if (icon && icon.length) this.dateIcon = icon.data('date-icon'); + if (!this.dateIcon) this.dateIcon = 'icon-calendar'; + icon.removeClass(this.timeIcon); + icon.addClass(this.dateIcon); + } + this.widget = $(getTemplate(this.format, this.timeIcon, options.pickDate, options.pickTime, options.pick12HourFormat)).appendTo('body'); + this.minViewMode = options.minViewMode||this.$element.data('date-minviewmode')||0; + if (typeof this.minViewMode === 'string') { + switch (this.minViewMode) { + case 'months': + this.minViewMode = 1; + break; + case 'years': + this.minViewMode = 2; + break; + default: + this.minViewMode = 0; + break; + } + } + this.viewMode = options.viewMode||this.$element.data('date-viewmode')||0; + if (typeof this.viewMode === 'string') { + switch (this.viewMode) { + case 'months': + this.viewMode = 1; + break; + case 'years': + this.viewMode = 2; + break; + default: + this.viewMode = 0; + break; + } + } + this.startViewMode = this.viewMode; + this.weekStart = options.weekStart||this.$element.data('date-weekstart')||0; + this.weekEnd = this.weekStart === 0 ? 6 : this.weekStart - 1; + this.fillDow(); + this.fillMonths(); + this.fillHours(); + this.fillMinutes(); + this.fillSeconds(); + this.update(); + this.showMode(); + this._attachDatePickerEvents(); + }, + + show: function(e) { + if(!e.currentTarget.value) this.setValue(new Date()); + this.widget.show(); + this.height = this.component ? this.component.outerHeight() : this.$element.outerHeight(); + this.width = this.component ? this.component.outerWidth() : this.$element.outerWidth(); + this.place(); + this.$element.trigger({ + type: 'show', + date: this._date + }); + this._attachDatePickerGlobalEvents(); + if (e) { + e.stopPropagation(); + e.preventDefault(); + } + }, + + hide: function() { + // Ignore event if in the middle of a picker transition + var collapse = this.widget.find('.collapse') + for (var i = 0; i < collapse.length; i++) { + var collapseData = collapse.eq(i).data('collapse'); + if (collapseData && collapseData.transitioning) + return; + } + this.widget.hide(); + this.viewMode = this.startViewMode; + this.showMode(); + // this.set(); + this.$element.trigger({ + type: 'hide', + date: this._date + }); + this.actions.showPicker.call(this); + this._detachDatePickerGlobalEvents(); + }, + + set: function() { + var formatted = ''; + if (!this._unset) formatted = this.formatDate(this._date); + if (!this.isInput) { + if (this.component){ + var input = this.$element.find('input'); + input.val(formatted); + this._resetMaskPos(input); + } + this.$element.data('date', formatted); + } else { + this.$element.val(formatted); + this._resetMaskPos(this.$element); + } + }, + + setValue: function(newDate) { + if (!newDate) { + this._unset = true; + } else { + this._unset = false; + } + if (typeof newDate === 'string') { + this._date = this.parseDate(newDate); + } else { + this._date = new Date(newDate); + this._date.setTime( this._date.getTime() - this._date.getTimezoneOffset()*60*1000 ); + } + this.set(); + this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); + this.fillDate(); + this.fillTime(); + }, + + getDate: function() { + if (this._unset) return null; + return new Date(this._date.valueOf()); + }, + + setDate: function(date) { + if (!date) this.setValue(null); + else this.setValue(date.valueOf()); + }, + + getLocalDate: function() { + if (this._unset) return null; + var d = this._date; + return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), + d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds()); + }, + + setLocalDate: function(localDate) { + if (!localDate) this.setValue(null); + else + this.setValue(Date.UTC( + localDate.getFullYear(), + localDate.getMonth(), + localDate.getDate(), + localDate.getHours(), + localDate.getMinutes(), + localDate.getSeconds(), + localDate.getMilliseconds())); + }, + + place: function(){ + var offset = this.component ? this.component.offset() : this.$element.offset(), + input = this.$element.find('input'); + this.widget.css({ + top: offset.top + this.height, + left: offset.left - input.outerWidth() - this.width, + }); + }, + + notifyChange: function(){ + this.$element.trigger({ + type: 'changeDate', + date: this.getDate(), + localDate: this.getLocalDate() + }); + }, + + update: function(newDate){ + var dateStr = newDate; + if (!dateStr) { + if (this.isInput) { + dateStr = this.$element.val(); + } else { + dateStr = this.$element.find('input').val(); + } + if (!dateStr) { + var tmp = new Date() + this._date = UTCDate(tmp.getFullYear(), + tmp.getMonth(), + tmp.getDate(), + tmp.getHours(), + tmp.getMinutes(), + tmp.getSeconds(), + tmp.getMilliseconds()) + } else { + this._date = this.parseDate(dateStr); + } + } + this.viewDate = UTCDate(this._date.getUTCFullYear(), this._date.getUTCMonth(), 1, 0, 0, 0, 0); + this.fillDate(); + this.fillTime(); + }, + + fillDow: function() { + var dowCnt = this.weekStart; + var html = '