Permalink
Browse files

Checkboxes, hurrah

  • Loading branch information...
1 parent 3185cb6 commit 9d39667f2abf2b50164aa8feecf4ac17029110bc @eKoeS committed Feb 8, 2011
Showing with 161 additions and 0 deletions.
  1. BIN assets/images/tick.png
  2. +2 −0 assets/init.js
  3. +71 −0 assets/symphony.checkbox.css
  4. +86 −0 assets/symphony.checkbox.js
  5. +2 −0 extension.driver.php
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -32,6 +32,8 @@
});
});
+ $('input[type="checkbox"]').symphonyCheckbox();
+
});
@@ -0,0 +1,71 @@
+/*-----------------------------------------------------------------------------
+ General
+-----------------------------------------------------------------------------*/
+
+.checkbox {
+ margin: 0 5px 0 0;
+ height: 12px;
+ width: 12px;
+ margin-top: 1px;
+ border: 1px solid #AFAFAF;
+
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+
+ background: rgb(250, 250, 250);
+ background: -webkit-gradient(
+ linear,
+ left bottom,
+ left top,
+ color-stop(0.00, rgb(250, 250, 250)),
+ color-stop(0.95, rgb(242, 242, 242))
+ );
+ background: -moz-linear-gradient(
+ center bottom,
+ rgb(250, 250, 250) 0%,
+ rgb(240, 240, 240) 95%
+ );
+
+ color: #444;
+ font: 11px/22px 'Lucida Grande', Tahoma, Verdana, sans-serif !important;
+
+ -webkit-box-shadow: 0 0 2px rgb(200, 200, 200), inset 0 1px 1px rgb(255, 255, 255);
+ -moz-box-shadow: 0 0 2px rgb(200, 200, 200), inset 0 1px 1px rgb(255, 255, 255);
+ box-shadow: 0 0 2px rgb(200, 200, 200), inset 0 1px 1px rgb(255, 255, 255);
+}
+
+.checkbox.checked .value {
+ position: relative;
+ top: -4px; left: 1px;
+ width: 16px;
+ height: 16px;
+ background: url(images/tick.png) center center no-repeat;
+}
+
+/*-----------------------------------------------------------------------------
+ DO NOT EDIT
+-----------------------------------------------------------------------------*/
+
+.group.contextual.sections + label input[type=checkbox],
+input[type=checkbox] {
+ position: absolute;
+ left: -9999px;
+}
+
+.checkbox {
+ cursor: pointer;
+ position: relative;
+ top: -1px;
+ display: inline-block;
+ vertical-align: top;
+ text-align: left;
+}
+
+/*--- Compatibility ---*/
+
+.group.contextual.sections + label .checkbox {
+ vertical-align: top;
+ position: relative;
+ top: 2px;
+}
@@ -0,0 +1,86 @@
+(function($) {
+
+ $.fn.symphonyCheckbox = function(custom_settings) {
+ var objects = this;
+ var settings = {
+ ignore: 'div.contextual.irrelevant, table.selectable',
+ delay_initialize: false,
+ };
+
+ $.extend(settings, custom_settings);
+
+ /*-----------------------------------------------------------------------*/
+
+ objects = objects.map(function() {
+ var object = this;
+
+ var click = function() {
+ $(this).toggleClass('checked');
+ }
+
+ var update = function() {
+ var checkbox = $(this).siblings('.checkbox');
+
+ checkbox.toggleClass('checked', $(this).is(':checked'));
+ }
+
+ /*-------------------------------------------------------------------*/
+
+ if (object instanceof $ === false) {
+ object = $(object);
+ }
+
+ object.checkbox = {
+
+ initialize: function() {
+ if (object.parents(settings.ignore).length != 0) return false;
+ if (object.siblings('.checkbox').length != 0)
+ object.siblings('.checkbox').remove();
+
+ var div = {
+ main: $('<div class="checkbox" />'),
+ value: $('<div class="value" />')
+ };
+
+ Symphony.Language.add({
+ 'Select all': false,
+ 'Deselect all': false
+ });
+
+ div.main.append(div.value);
+ div.main.insertAfter(object);
+
+ if (object.is(':checked')) div.main.addClass('checked');
+
+ /* Event handlers */
+
+ div.main.bind('click.checkbox', click);
+ object.bind('change.checkbox', update);
+
+ object.parent().click(function(event) {
+ event.preventDefault();
+ })
+ },
+
+ check: function() {
+ object.attr('checked', true);
+ },
+
+ uncheck: function() {
+ object.attr('checked', false);
+ }
+
+ };
+
+ if (settings.delay_initialize !== true) {
+ object.checkbox.initialize();
+ }
+
+ return object;
+ });
+
+ return objects;
+ };
+
+
+})(jQuery.noConflict());
@@ -29,9 +29,11 @@ public function __appendAssets($context) {
$page = $context['parent']->Page;
$page->addStylesheetToHead(URL . '/extensions/better_selectboxes/assets/symphony.selectbox.css', 'screen', 222);
$page->addStylesheetToHead(URL . '/extensions/better_selectboxes/assets/symphony.textbox.css', 'screen', 222);
+ $page->addStylesheetToHead(URL . '/extensions/better_selectboxes/assets/symphony.checkbox.css', 'screen', 222);
$page->addStylesheetToHead(URL . '/extensions/better_selectboxes/assets/symphony.button.css', 'screen', 222);
$page->addScriptToHead(URL . '/extensions/better_selectboxes/assets/symphony.selectbox.js', 222);
+ $page->addScriptToHead(URL . '/extensions/better_selectboxes/assets/symphony.checkbox.js', 222);
$page->addScriptToHead(URL . '/extensions/better_selectboxes/assets/init.js', 222);
}

0 comments on commit 9d39667

Please sign in to comment.